diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000..2369228 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_PATH: "vendor/bundle" diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index e31d81c..6db7abb 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -1,51 +1,36 @@ -# Sample workflow for building and deploying a Jekyll site to GitHub Pages -name: Deploy Jekyll with GitHub Pages dependencies preinstalled +name: Jekyll site CI on: - # Runs on pushes targeting the default branch push: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false + branches: + - pull_request + - main jobs: - # Build job build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup Pages uses: actions/configure-pages@v5 - - name: Build with Jekyll - uses: actions/jekyll-build-pages@v1 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 with: - source: ./ - destination: ./_site - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + ruby-version: '3.0' # Specify the Ruby version you are using + + - name: Install dependencies + run: | + gem install bundler + bundle install + + - name: Build with Jekyll + run: bundle exec jekyll build - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..167ee20 --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'jekyll' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..296b901 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,169 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + bigdecimal (3.1.8) + colorator (1.1.0) + concurrent-ruby (1.3.4) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + eventmachine (1.2.7) + ffi (1.17.0) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + forwardable-extended (2.6.0) + google-protobuf (4.27.3) + bigdecimal + rake (>= 13) + google-protobuf (4.27.3-aarch64-linux) + bigdecimal + rake (>= 13) + google-protobuf (4.27.3-arm64-darwin) + bigdecimal + rake (>= 13) + google-protobuf (4.27.3-x86-linux) + bigdecimal + rake (>= 13) + google-protobuf (4.27.3-x86_64-darwin) + bigdecimal + rake (>= 13) + google-protobuf (4.27.3-x86_64-linux) + bigdecimal + rake (>= 13) + http_parser.rb (0.8.0) + i18n (1.14.5) + concurrent-ruby (~> 1.0) + jekyll (4.3.3) + addressable (~> 2.4) + colorator (~> 1.0) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (>= 2.0, < 4.0) + jekyll-watch (~> 2.0) + kramdown (~> 2.3, >= 2.3.1) + kramdown-parser-gfm (~> 1.0) + liquid (~> 4.0) + mercenary (>= 0.3.6, < 0.5) + pathutil (~> 0.9) + rouge (>= 3.0, < 5.0) + safe_yaml (~> 1.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-sass-converter (3.0.0) + sass-embedded (~> 1.54) + jekyll-watch (2.2.1) + listen (~> 3.0) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.4) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + mercenary (0.4.0) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + public_suffix (6.0.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rexml (3.3.5) + strscan + rouge (4.3.0) + safe_yaml (1.0.5) + sass-embedded (1.77.8) + google-protobuf (~> 4.26) + rake (>= 13) + sass-embedded (1.77.8-aarch64-linux-android) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-aarch64-linux-gnu) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-aarch64-linux-musl) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-aarch64-mingw-ucrt) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-arm-linux-androideabi) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-arm-linux-gnueabihf) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-arm-linux-musleabihf) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-arm64-darwin) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-riscv64-linux-android) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-riscv64-linux-gnu) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-riscv64-linux-musl) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86-cygwin) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86-linux-android) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86-linux-gnu) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86-linux-musl) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86-mingw-ucrt) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86_64-cygwin) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86_64-darwin) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86_64-linux-android) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86_64-linux-gnu) + google-protobuf (~> 4.26) + sass-embedded (1.77.8-x86_64-linux-musl) + google-protobuf (~> 4.26) + strscan (3.1.0) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.5.0) + webrick (1.8.1) + +PLATFORMS + aarch64-linux + aarch64-linux-android + aarch64-linux-gnu + aarch64-linux-musl + aarch64-mingw-ucrt + arm-linux-androideabi + arm-linux-gnu + arm-linux-gnueabihf + arm-linux-musl + arm-linux-musleabihf + arm64-darwin + riscv64-linux-android + riscv64-linux-gnu + riscv64-linux-musl + ruby + x86-cygwin + x86-linux + x86-linux-android + x86-linux-gnu + x86-linux-musl + x86-mingw-ucrt + x86_64-cygwin + x86_64-darwin + x86_64-linux-android + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + jekyll + +BUNDLED WITH + 2.5.17 diff --git a/README.md b/README.md index 160c2e9..6579735 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,42 @@ help us help humanity, with ideas, support, and donations X.COM/DOGEOPEN +name: Jekyll site CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' # Specify the Ruby version you are using + + - name: Install dependencies + run: | + gem install bundler + bundle install + + - name: Build the site + run: bundle exec jekyll build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site + @@ -32,6 +68,10 @@ X.COM/DOGEOPEN +## Dogecoin Price Ticker + + + diff --git a/_site/README.md b/_site/README.md new file mode 100644 index 0000000..6579735 --- /dev/null +++ b/_site/README.md @@ -0,0 +1,77 @@ +# dogeopen + +* [projects](projects.md) +* [ideas](ideas.md) +* [donors](donors.md) +* [linux](linux.md) + + + + +# Mission Statement: +# economic empowerment using opensource technology + +# donate to those in need + +# transparency through blockchain + +# we are one // you are vital + + +help us help humanity, with ideas, support, and donations + +X.COM/DOGEOPEN + +name: Jekyll site CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' # Specify the Ruby version you are using + + - name: Install dependencies + run: | + gem install bundler + bundle install + + - name: Build the site + run: bundle exec jekyll build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site + + + + + + + *UNDER CONSTRUCTION* + + + + +## Dogecoin Price Ticker + + + + + + diff --git a/_site/donors.md b/_site/donors.md new file mode 100644 index 0000000..2aed819 --- /dev/null +++ b/_site/donors.md @@ -0,0 +1,2 @@ +# donors + diff --git a/_site/ideas.md b/_site/ideas.md new file mode 100644 index 0000000..273b9bc --- /dev/null +++ b/_site/ideas.md @@ -0,0 +1,2 @@ +# ideas + diff --git a/_site/linux.md b/_site/linux.md new file mode 100644 index 0000000..5229d16 --- /dev/null +++ b/_site/linux.md @@ -0,0 +1,2 @@ +# linux + diff --git a/_site/projects.md b/_site/projects.md new file mode 100644 index 0000000..9d7231c --- /dev/null +++ b/_site/projects.md @@ -0,0 +1,3 @@ +# projects + + diff --git a/vendor/bundle/ruby/3.2.0/bin/jekyll b/vendor/bundle/ruby/3.2.0/bin/jekyll new file mode 100755 index 0000000..2a51348 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/bin/jekyll @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'jekyll' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +Gem.use_gemdeps + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('jekyll', 'jekyll', version) +else +gem "jekyll", version +load Gem.bin_path("jekyll", "jekyll", version) +end diff --git a/vendor/bundle/ruby/3.2.0/bin/jekyll.lock b/vendor/bundle/ruby/3.2.0/bin/jekyll.lock new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/bin/kramdown b/vendor/bundle/ruby/3.2.0/bin/kramdown new file mode 100755 index 0000000..80d0907 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/bin/kramdown @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'kramdown' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +Gem.use_gemdeps + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('kramdown', 'kramdown', version) +else +gem "kramdown", version +load Gem.bin_path("kramdown", "kramdown", version) +end diff --git a/vendor/bundle/ruby/3.2.0/bin/kramdown.lock b/vendor/bundle/ruby/3.2.0/bin/kramdown.lock new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/bin/listen b/vendor/bundle/ruby/3.2.0/bin/listen new file mode 100755 index 0000000..3cd5cbe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/bin/listen @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'listen' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +Gem.use_gemdeps + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('listen', 'listen', version) +else +gem "listen", version +load Gem.bin_path("listen", "listen", version) +end diff --git a/vendor/bundle/ruby/3.2.0/bin/listen.lock b/vendor/bundle/ruby/3.2.0/bin/listen.lock new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/bin/rake b/vendor/bundle/ruby/3.2.0/bin/rake new file mode 100755 index 0000000..3a26cbd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/bin/rake @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +Gem.use_gemdeps + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('rake', 'rake', version) +else +gem "rake", version +load Gem.bin_path("rake", "rake", version) +end diff --git a/vendor/bundle/ruby/3.2.0/bin/rake.lock b/vendor/bundle/ruby/3.2.0/bin/rake.lock new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/bin/rougify b/vendor/bundle/ruby/3.2.0/bin/rougify new file mode 100755 index 0000000..ff47323 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/bin/rougify @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'rouge' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +Gem.use_gemdeps + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('rouge', 'rougify', version) +else +gem "rouge", version +load Gem.bin_path("rouge", "rougify", version) +end diff --git a/vendor/bundle/ruby/3.2.0/bin/rougify.lock b/vendor/bundle/ruby/3.2.0/bin/rougify.lock new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/bin/safe_yaml b/vendor/bundle/ruby/3.2.0/bin/safe_yaml new file mode 100755 index 0000000..90f917c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/bin/safe_yaml @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'safe_yaml' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +Gem.use_gemdeps + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('safe_yaml', 'safe_yaml', version) +else +gem "safe_yaml", version +load Gem.bin_path("safe_yaml", "safe_yaml", version) +end diff --git a/vendor/bundle/ruby/3.2.0/bin/safe_yaml.lock b/vendor/bundle/ruby/3.2.0/bin/safe_yaml.lock new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/bin/sass b/vendor/bundle/ruby/3.2.0/bin/sass new file mode 100755 index 0000000..24bb691 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/bin/sass @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'sass-embedded' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +Gem.use_gemdeps + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('sass-embedded', 'sass', version) +else +gem "sass-embedded", version +load Gem.bin_path("sass-embedded", "sass", version) +end diff --git a/vendor/bundle/ruby/3.2.0/bin/sass.lock b/vendor/bundle/ruby/3.2.0/bin/sass.lock new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/cache/addressable-2.8.7.gem b/vendor/bundle/ruby/3.2.0/cache/addressable-2.8.7.gem new file mode 100644 index 0000000..c489068 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/addressable-2.8.7.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/bigdecimal-3.1.8.gem b/vendor/bundle/ruby/3.2.0/cache/bigdecimal-3.1.8.gem new file mode 100644 index 0000000..281be50 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/bigdecimal-3.1.8.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/colorator-1.1.0.gem b/vendor/bundle/ruby/3.2.0/cache/colorator-1.1.0.gem new file mode 100644 index 0000000..d5616ad Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/colorator-1.1.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/concurrent-ruby-1.3.4.gem b/vendor/bundle/ruby/3.2.0/cache/concurrent-ruby-1.3.4.gem new file mode 100644 index 0000000..a656fd0 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/concurrent-ruby-1.3.4.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/em-websocket-0.5.3.gem b/vendor/bundle/ruby/3.2.0/cache/em-websocket-0.5.3.gem new file mode 100644 index 0000000..e5a3da1 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/em-websocket-0.5.3.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/eventmachine-1.2.7.gem b/vendor/bundle/ruby/3.2.0/cache/eventmachine-1.2.7.gem new file mode 100644 index 0000000..708d366 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/eventmachine-1.2.7.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/ffi-1.17.0-x86_64-linux-gnu.gem b/vendor/bundle/ruby/3.2.0/cache/ffi-1.17.0-x86_64-linux-gnu.gem new file mode 100644 index 0000000..cf4f489 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/ffi-1.17.0-x86_64-linux-gnu.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/forwardable-extended-2.6.0.gem b/vendor/bundle/ruby/3.2.0/cache/forwardable-extended-2.6.0.gem new file mode 100644 index 0000000..370222f Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/forwardable-extended-2.6.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/google-protobuf-4.27.3-x86_64-linux.gem b/vendor/bundle/ruby/3.2.0/cache/google-protobuf-4.27.3-x86_64-linux.gem new file mode 100644 index 0000000..d316249 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/google-protobuf-4.27.3-x86_64-linux.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/http_parser.rb-0.8.0.gem b/vendor/bundle/ruby/3.2.0/cache/http_parser.rb-0.8.0.gem new file mode 100644 index 0000000..b7e137f Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/http_parser.rb-0.8.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/i18n-1.14.5.gem b/vendor/bundle/ruby/3.2.0/cache/i18n-1.14.5.gem new file mode 100644 index 0000000..904ea78 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/i18n-1.14.5.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/jekyll-4.3.3.gem b/vendor/bundle/ruby/3.2.0/cache/jekyll-4.3.3.gem new file mode 100644 index 0000000..ab1f668 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/jekyll-4.3.3.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/jekyll-sass-converter-3.0.0.gem b/vendor/bundle/ruby/3.2.0/cache/jekyll-sass-converter-3.0.0.gem new file mode 100644 index 0000000..74ebca1 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/jekyll-sass-converter-3.0.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/jekyll-watch-2.2.1.gem b/vendor/bundle/ruby/3.2.0/cache/jekyll-watch-2.2.1.gem new file mode 100644 index 0000000..0defcd7 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/jekyll-watch-2.2.1.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/kramdown-2.4.0.gem b/vendor/bundle/ruby/3.2.0/cache/kramdown-2.4.0.gem new file mode 100644 index 0000000..0ade96d Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/kramdown-2.4.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/kramdown-parser-gfm-1.1.0.gem b/vendor/bundle/ruby/3.2.0/cache/kramdown-parser-gfm-1.1.0.gem new file mode 100644 index 0000000..f087be5 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/kramdown-parser-gfm-1.1.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/liquid-4.0.4.gem b/vendor/bundle/ruby/3.2.0/cache/liquid-4.0.4.gem new file mode 100644 index 0000000..fb32676 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/liquid-4.0.4.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/listen-3.9.0.gem b/vendor/bundle/ruby/3.2.0/cache/listen-3.9.0.gem new file mode 100644 index 0000000..e6c0fe2 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/listen-3.9.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/mercenary-0.4.0.gem b/vendor/bundle/ruby/3.2.0/cache/mercenary-0.4.0.gem new file mode 100644 index 0000000..33576f5 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/mercenary-0.4.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/pathutil-0.16.2.gem b/vendor/bundle/ruby/3.2.0/cache/pathutil-0.16.2.gem new file mode 100644 index 0000000..9dd34cc Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/pathutil-0.16.2.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/public_suffix-6.0.1.gem b/vendor/bundle/ruby/3.2.0/cache/public_suffix-6.0.1.gem new file mode 100644 index 0000000..5242a94 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/public_suffix-6.0.1.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/rake-13.2.1.gem b/vendor/bundle/ruby/3.2.0/cache/rake-13.2.1.gem new file mode 100644 index 0000000..40a47b3 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/rake-13.2.1.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/rb-fsevent-0.11.2.gem b/vendor/bundle/ruby/3.2.0/cache/rb-fsevent-0.11.2.gem new file mode 100644 index 0000000..e645266 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/rb-fsevent-0.11.2.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/rb-inotify-0.11.1.gem b/vendor/bundle/ruby/3.2.0/cache/rb-inotify-0.11.1.gem new file mode 100644 index 0000000..e52c22c Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/rb-inotify-0.11.1.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/rexml-3.3.5.gem b/vendor/bundle/ruby/3.2.0/cache/rexml-3.3.5.gem new file mode 100644 index 0000000..12610b9 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/rexml-3.3.5.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/rouge-4.3.0.gem b/vendor/bundle/ruby/3.2.0/cache/rouge-4.3.0.gem new file mode 100644 index 0000000..39056bc Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/rouge-4.3.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/safe_yaml-1.0.5.gem b/vendor/bundle/ruby/3.2.0/cache/safe_yaml-1.0.5.gem new file mode 100644 index 0000000..b539b54 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/safe_yaml-1.0.5.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/sass-embedded-1.77.8-x86_64-linux-gnu.gem b/vendor/bundle/ruby/3.2.0/cache/sass-embedded-1.77.8-x86_64-linux-gnu.gem new file mode 100644 index 0000000..52ca106 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/sass-embedded-1.77.8-x86_64-linux-gnu.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/strscan-3.1.0.gem b/vendor/bundle/ruby/3.2.0/cache/strscan-3.1.0.gem new file mode 100644 index 0000000..e7bd707 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/strscan-3.1.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/terminal-table-3.0.2.gem b/vendor/bundle/ruby/3.2.0/cache/terminal-table-3.0.2.gem new file mode 100644 index 0000000..cab512c Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/terminal-table-3.0.2.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/unicode-display_width-2.5.0.gem b/vendor/bundle/ruby/3.2.0/cache/unicode-display_width-2.5.0.gem new file mode 100644 index 0000000..7f3e24b Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/unicode-display_width-2.5.0.gem differ diff --git a/vendor/bundle/ruby/3.2.0/cache/webrick-1.8.1.gem b/vendor/bundle/ruby/3.2.0/cache/webrick-1.8.1.gem new file mode 100644 index 0000000..ac0894b Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/cache/webrick-1.8.1.gem differ diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/bigdecimal.so b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/bigdecimal.so new file mode 100755 index 0000000..f483680 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/bigdecimal.so differ diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/gem.build_complete b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/gem.build_complete new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/gem_make.out b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/gem_make.out new file mode 100644 index 0000000..5c31cc4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/gem_make.out @@ -0,0 +1,48 @@ +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal +/usr/bin/ruby extconf.rb +checking for __builtin_clz()... yes +checking for __builtin_clzl()... yes +checking for __builtin_clzll()... yes +checking for float.h... yes +checking for math.h... yes +checking for stdbool.h... yes +checking for stdlib.h... yes +checking for x86intrin.h... yes +checking for _lzcnt_u32() in x86intrin.h... no +checking for _lzcnt_u64() in x86intrin.h... no +checking for intrin.h... no +checking for __lzcnt() in intrin.h... no +checking for __lzcnt64() in intrin.h... no +checking for _BitScanReverse() in intrin.h... no +checking for _BitScanReverse64() in intrin.h... no +checking for labs() in stdlib.h... yes +checking for llabs() in stdlib.h... yes +checking for finite() in math.h... yes +checking for isfinite() in math.h... no +checking for ruby/atomic.h... yes +checking for ruby/internal/has/builtin.h... yes +checking for ruby/internal/static_assert.h... yes +checking for rb_rational_num() in ruby.h... yes +checking for rb_rational_den() in ruby.h... yes +checking for rb_complex_real() in ruby.h... yes +checking for rb_complex_imag() in ruby.h... yes +checking for rb_opts_exception_p() in ruby.h... yes +checking for rb_category_warn() in ruby.h... yes +checking for RB_WARN_CATEGORY_DEPRECATED in ruby.h... yes +creating Makefile + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-rpxjq8 sitelibdir\=./.gem.20240817-4872-rpxjq8 clean + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-rpxjq8 sitelibdir\=./.gem.20240817-4872-rpxjq8 +compiling bigdecimal.c +compiling missing.c +linking shared-object bigdecimal.so + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-rpxjq8 sitelibdir\=./.gem.20240817-4872-rpxjq8 install +/usr/bin/install -c -m 0755 bigdecimal.so ./.gem.20240817-4872-rpxjq8 + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-rpxjq8 sitelibdir\=./.gem.20240817-4872-rpxjq8 clean diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/mkmf.log b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/mkmf.log new file mode 100644 index 0000000..c0fd6f0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/bigdecimal-3.1.8/mkmf.log @@ -0,0 +1,825 @@ +have_builtin_func: checking for __builtin_clz()... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return !!argv[argc]; +6: } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int foo; +4: int main() { __builtin_clz(0); return 0; } +/* end */ + +-------------------- + +have_builtin_func: checking for __builtin_clzl()... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int foo; +4: int main() { __builtin_clzl(0); return 0; } +/* end */ + +-------------------- + +have_builtin_func: checking for __builtin_clzll()... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int foo; +4: int main() { __builtin_clzll(0); return 0; } +/* end */ + +-------------------- + +have_header: checking for float.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_header: checking for math.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_header: checking for stdbool.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_header: checking for stdlib.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_header: checking for x86intrin.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_func: checking for _lzcnt_u32() in x86intrin.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: /tmp/ccR4ArI3.o: in function `t': +/home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/conftest.c:16:(.text+0xb): undefined reference to `_lzcnt_u32' +collect2: error: ld returned 1 exit status +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))_lzcnt_u32; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:16:13: error: conflicting types for ‘_lzcnt_u32’; have ‘void()’ + 16 | extern void _lzcnt_u32(); + | ^~~~~~~~~~ +In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include/x86gprintrin.h:61, + from /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include/x86intrin.h:27, + from conftest.c:3: +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include/lzcntintrin.h:51:1: note: previous definition of ‘_lzcnt_u32’ with type ‘unsigned int(unsigned int)’ + 51 | _lzcnt_u32 (unsigned int __X) + | ^~~~~~~~~~ +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void _lzcnt_u32(); +17: int t(void) { _lzcnt_u32(); return 0; } +/* end */ + +-------------------- + +have_func: checking for _lzcnt_u64() in x86intrin.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: /tmp/ccnoNft3.o: in function `t': +/home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/conftest.c:16:(.text+0xb): undefined reference to `_lzcnt_u64' +collect2: error: ld returned 1 exit status +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))_lzcnt_u64; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:16:13: error: conflicting types for ‘_lzcnt_u64’; have ‘void()’ + 16 | extern void _lzcnt_u64(); + | ^~~~~~~~~~ +In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include/x86gprintrin.h:61, + from /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include/x86intrin.h:27, + from conftest.c:3: +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include/lzcntintrin.h:64:1: note: previous definition of ‘_lzcnt_u64’ with type ‘long long unsigned int(long long unsigned int)’ + 64 | _lzcnt_u64 (unsigned long long __X) + | ^~~~~~~~~~ +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void _lzcnt_u64(); +17: int t(void) { _lzcnt_u64(); return 0; } +/* end */ + +-------------------- + +have_header: checking for intrin.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_func: checking for __lzcnt() in intrin.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))__lzcnt; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void __lzcnt(); +17: int t(void) { __lzcnt(); return 0; } +/* end */ + +-------------------- + +have_func: checking for __lzcnt64() in intrin.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))__lzcnt64; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void __lzcnt64(); +17: int t(void) { __lzcnt64(); return 0; } +/* end */ + +-------------------- + +have_func: checking for _BitScanReverse() in intrin.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))_BitScanReverse; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void _BitScanReverse(); +17: int t(void) { _BitScanReverse(); return 0; } +/* end */ + +-------------------- + +have_func: checking for _BitScanReverse64() in intrin.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))_BitScanReverse64; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c:3:10: fatal error: intrin.h: No such file or directory + 3 | #include + | ^~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void _BitScanReverse64(); +17: int t(void) { _BitScanReverse64(); return 0; } +/* end */ + +-------------------- + +have_func: checking for labs() in stdlib.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))labs; return !p; } +/* end */ + +-------------------- + +have_func: checking for llabs() in stdlib.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))llabs; return !p; } +/* end */ + +-------------------- + +have_func: checking for finite() in math.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))finite; return !p; } +/* end */ + +-------------------- + +have_func: checking for isfinite() in math.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c: In function ‘t’: +conftest.c:16:57: error: ‘isfinite’ undeclared (first use in this function); did you mean ‘finite’? + 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))isfinite; return !p; } + | ^~~~~~~~ + | finite +conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))isfinite; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: /tmp/cc4TN7nB.o: in function `t': +/home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/conftest.c:17:(.text+0xb): undefined reference to `__builtin_isfinite' +collect2: error: ld returned 1 exit status +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void isfinite(); +17: int t(void) { isfinite(); return 0; } +/* end */ + +-------------------- + +have_header: checking for ruby/atomic.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_header: checking for ruby/internal/has/builtin.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_header: checking for ruby/internal/static_assert.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_func: checking for rb_rational_num() in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_rational_num; return !p; } +/* end */ + +-------------------- + +have_func: checking for rb_rational_den() in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_rational_den; return !p; } +/* end */ + +-------------------- + +have_func: checking for rb_complex_real() in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_complex_real; return !p; } +/* end */ + +-------------------- + +have_func: checking for rb_complex_imag() in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_complex_imag; return !p; } +/* end */ + +-------------------- + +have_func: checking for rb_opts_exception_p() in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c: In function ‘t’: +conftest.c:16:57: error: ‘rb_opts_exception_p’ undeclared (first use in this function); did you mean ‘rb_make_exception’? + 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_opts_exception_p; return !p; } + | ^~~~~~~~~~~~~~~~~~~ + | rb_make_exception +conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_opts_exception_p; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void rb_opts_exception_p(); +17: int t(void) { rb_opts_exception_p(); return 0; } +/* end */ + +-------------------- + +have_func: checking for rb_category_warn() in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_category_warn; return !p; } +/* end */ + +-------------------- + +have_const: checking for RB_WARN_CATEGORY_DEPRECATED in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +4: +5: /*top*/ +6: typedef int conftest_type; +7: conftest_type conftestval = (int)RB_WARN_CATEGORY_DEPRECATED; +/* end */ + +-------------------- + diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/fastfilereaderext.so b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/fastfilereaderext.so new file mode 100755 index 0000000..fe89b4c Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/fastfilereaderext.so differ diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/gem.build_complete b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/gem.build_complete new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/gem_make.out b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/gem_make.out new file mode 100644 index 0000000..ea0b522 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/gem_make.out @@ -0,0 +1,19 @@ +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader +/usr/bin/ruby extconf.rb +creating Makefile + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-v5hsre sitelibdir\=./.gem.20240817-4872-v5hsre clean + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-v5hsre sitelibdir\=./.gem.20240817-4872-v5hsre +compiling mapper.cpp +compiling rubymain.cpp +linking shared-object fastfilereaderext.so + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-v5hsre sitelibdir\=./.gem.20240817-4872-v5hsre install +/usr/bin/install -c -m 0755 fastfilereaderext.so ./.gem.20240817-4872-v5hsre + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-v5hsre sitelibdir\=./.gem.20240817-4872-v5hsre clean diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/mkmf.log b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/mkmf.log new file mode 100644 index 0000000..b730815 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/mkmf.log @@ -0,0 +1,647 @@ +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib pkg-config --exists openssl +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib pkg-config --libs openssl | +=> "-lssl -lcrypto\n" +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return !!argv[argc]; +6: } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lssl -lcrypto -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return !!argv[argc]; +6: } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib pkg-config --cflags-only-I openssl | +=> "\n" +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib pkg-config --cflags-only-other openssl | +=> "\n" +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib pkg-config --libs-only-l openssl | +=> "-lssl -lcrypto\n" +package configuration for openssl +incflags: +cflags: +ldflags: +libs: -lssl -lcrypto + +have_library: checking for -lcrypto... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lruby -lssl -lcrypto -lcrypto -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: +15: int t(void) { ; return 0; } +/* end */ + +-------------------- + +have_library: checking for -lssl... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: +15: int t(void) { ; return 0; } +/* end */ + +-------------------- + +have_header: checking for openssl/ssl.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_header: checking for openssl/err.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_var: checking for rb_trap_immediate in ruby.h,rubysig.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +conftest.c:4:10: fatal error: rubysig.h: No such file or directory + 4 | #include + | ^~~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: #include + 5: + 6: /*top*/ + 7: extern int t(void); + 8: int main(int argc, char **argv) + 9: { +10: if (argc > 1000000) { +11: int (* volatile tp)(void)=(int (*)(void))&t; +12: printf("%d", (*tp)()); +13: } +14: +15: return !!argv[argc]; +16: } +17: int t(void) { const volatile void *volatile p; p = &(&rb_trap_immediate)[0]; return !p; } +/* end */ + +-------------------- + +have_func: checking for rb_thread_blocking_region()... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +conftest.c: In function ‘t’: +conftest.c:14:57: error: ‘rb_thread_blocking_region’ undeclared (first use in this function) + 14 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return !p; } + | ^~~~~~~~~~~~~~~~~~~~~~~~~ +conftest.c:14:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: /tmp/cc3ZaNEt.o: in function `t': +/home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/conftest.c:15:(.text+0xb): undefined reference to `rb_thread_blocking_region' +collect2: error: ld returned 1 exit status +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: extern void rb_thread_blocking_region(); +15: int t(void) { rb_thread_blocking_region(); return 0; } +/* end */ + +-------------------- + +have_func: checking for rb_thread_call_without_gvl() in ruby/thread.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_call_without_gvl; return !p; } +/* end */ + +-------------------- + +have_func: checking for rb_thread_fd_select()... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_fd_select; return !p; } +/* end */ + +-------------------- + +have_type: checking for rb_fdset_t in ruby/intern.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +4: +5: /*top*/ +6: typedef rb_fdset_t conftest_type; +7: int conftestval[sizeof(conftest_type)?1:-1]; +/* end */ + +-------------------- + +have_func: checking for rb_wait_for_single_fd()... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +conftest.c: In function ‘t’: +conftest.c:14:57: error: ‘rb_wait_for_single_fd’ undeclared (first use in this function) + 14 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; return !p; } + | ^~~~~~~~~~~~~~~~~~~~~ +conftest.c:14:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: extern void rb_wait_for_single_fd(); +15: int t(void) { rb_wait_for_single_fd(); return 0; } +/* end */ + +-------------------- + +have_func: checking for rb_enable_interrupt()... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +conftest.c: In function ‘t’: +conftest.c:14:57: error: ‘rb_enable_interrupt’ undeclared (first use in this function); did you mean ‘rb_eInterrupt’? + 14 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enable_interrupt; return !p; } + | ^~~~~~~~~~~~~~~~~~~ + | rb_eInterrupt +conftest.c:14:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enable_interrupt; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: /tmp/cczg3Yd3.o: in function `t': +/home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/conftest.c:15:(.text+0xb): undefined reference to `rb_enable_interrupt' +collect2: error: ld returned 1 exit status +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: extern void rb_enable_interrupt(); +15: int t(void) { rb_enable_interrupt(); return 0; } +/* end */ + +-------------------- + +have_func: checking for rb_time_new()... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_time_new; return !p; } +/* end */ + +-------------------- + +have_func: checking for inotify_init() in sys/inotify.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))inotify_init; return !p; } +/* end */ + +-------------------- + +have_func: checking for writev() in sys/uio.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))writev; return !p; } +/* end */ + +-------------------- + +have_func: checking for pipe2() in unistd.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))pipe2; return !p; } +/* end */ + +-------------------- + +have_func: checking for accept4() in sys/socket.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))accept4; return !p; } +/* end */ + +-------------------- + +have_const: checking for SOCK_CLOEXEC in sys/socket.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +4: +5: /*top*/ +6: typedef int conftest_type; +7: conftest_type conftestval = (int)SOCK_CLOEXEC; +/* end */ + +-------------------- + +have_header: checking for sys/event.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +conftest.c:3:10: fatal error: sys/event.h: No such file or directory + 3 | #include + | ^~~~~~~~~~~~~ +compilation terminated. +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +/* end */ + +-------------------- + +have_func: checking for epoll_create() in sys/epoll.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))epoll_create; return !p; } +/* end */ + +-------------------- + +have_func: checking for clock_gettime()... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: /*top*/ + 4: extern int t(void); + 5: int main(int argc, char **argv) + 6: { + 7: if (argc > 1000000) { + 8: int (* volatile tp)(void)=(int (*)(void))&t; + 9: printf("%d", (*tp)()); +10: } +11: +12: return !!argv[argc]; +13: } +14: int t(void) { void ((*volatile p)()); p = (void ((*)()))clock_gettime; return !p; } +/* end */ + +-------------------- + +have_const: checking for CLOCK_MONOTONIC_RAW in time.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +4: +5: /*top*/ +6: typedef int conftest_type; +7: conftest_type conftestval = (int)CLOCK_MONOTONIC_RAW; +/* end */ + +-------------------- + +have_const: checking for CLOCK_MONOTONIC in time.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC -c conftest.c" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +4: +5: /*top*/ +6: typedef int conftest_type; +7: conftest_type conftestval = (int)CLOCK_MONOTONIC; +/* end */ + +-------------------- + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-g++ -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -Wall -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main() {return 0;} +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-g++ -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -Wextra -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main() {return 0;} +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-g++ -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -Wno-deprecated-declarations -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main() {return 0;} +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-g++ -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -Wno-ignored-qualifiers -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main() {return 0;} +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-g++ -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -Wno-unused-result -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main() {return 0;} +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-g++ -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -Wno-address -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main() {return 0;} +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-g++ -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lssl -lcrypto -lcrypto -lssl -lruby -lstdc++ -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: #include +4: using namespace std; +5: int main(){ pair tuple = make_pair(1,2); } +/* end */ + diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/rubyeventmachine.so b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/rubyeventmachine.so new file mode 100755 index 0000000..1aced66 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/eventmachine-1.2.7/rubyeventmachine.so differ diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/gem.build_complete b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/gem.build_complete new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/gem_make.out b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/gem_make.out new file mode 100644 index 0000000..5b0654d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/gem_make.out @@ -0,0 +1,19 @@ +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser +/usr/bin/ruby extconf.rb +creating Makefile + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-wotwcs sitelibdir\=./.gem.20240817-4872-wotwcs clean + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-wotwcs sitelibdir\=./.gem.20240817-4872-wotwcs +compiling ruby_http_parser.c +compiling ryah_http_parser.c +linking shared-object ruby_http_parser.so + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-wotwcs sitelibdir\=./.gem.20240817-4872-wotwcs install +/usr/bin/install -c -m 0755 ruby_http_parser.so ./.gem.20240817-4872-wotwcs + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-wotwcs sitelibdir\=./.gem.20240817-4872-wotwcs clean diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/ruby_http_parser.so b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/ruby_http_parser.so new file mode 100755 index 0000000..bd01fdf Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/http_parser.rb-0.8.0/ruby_http_parser.so differ diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/gem.build_complete b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/gem.build_complete new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/gem_make.out b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/gem_make.out new file mode 100644 index 0000000..a67e4d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/gem_make.out @@ -0,0 +1,20 @@ +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan +/usr/bin/ruby extconf.rb +checking for onig_region_memsize() in ruby.h... yes +checking for rb_reg_onig_match() in ruby.h... no +creating Makefile + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-asddnf sitelibdir\=./.gem.20240817-4872-asddnf clean + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-asddnf sitelibdir\=./.gem.20240817-4872-asddnf +compiling strscan.c +linking shared-object strscan.so + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-asddnf sitelibdir\=./.gem.20240817-4872-asddnf install +/usr/bin/install -c -m 0755 strscan.so ./.gem.20240817-4872-asddnf + +current directory: /home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan +make DESTDIR\= sitearchdir\=./.gem.20240817-4872-asddnf sitelibdir\=./.gem.20240817-4872-asddnf clean diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/mkmf.log b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/mkmf.log new file mode 100644 index 0000000..8d0b833 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/mkmf.log @@ -0,0 +1,119 @@ +have_func: checking for onig_region_memsize() in ruby.h... -------------------- yes + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return !!argv[argc]; +6: } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c: In function ‘t’: +conftest.c:16:57: error: ‘onig_region_memsize’ undeclared (first use in this function) + 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))onig_region_memsize; return !p; } + | ^~~~~~~~~~~~~~~~~~~ +conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))onig_region_memsize; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void onig_region_memsize(); +17: int t(void) { onig_region_memsize(); return 0; } +/* end */ + +-------------------- + +have_func: checking for rb_reg_onig_match() in ruby.h... -------------------- no + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +conftest.c: In function ‘t’: +conftest.c:16:57: error: ‘rb_reg_onig_match’ undeclared (first use in this function); did you mean ‘rb_reg_nth_match’? + 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_reg_onig_match; return !p; } + | ^~~~~~~~~~~~~~~~~ + | rb_reg_nth_match +conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_reg_onig_match; return !p; } +/* end */ + +LD_LIBRARY_PATH=.:/usr/lib/x86_64-linux-gnu:/app/lib "x86_64-unknown-linux-gnu-gcc -o conftest -I/usr/include/ruby-3.2.0/x86_64-linux -I/usr/include/ruby-3.2.0/ruby/backward -I/usr/include/ruby-3.2.0 -I. -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -lruby -lm -lpthread -lc" +/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: /tmp/ccfxFEns.o: in function `t': +/home/glass/Documents/dogeopen/DO/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/conftest.c:17:(.text+0xb): undefined reference to `rb_reg_onig_match' +collect2: error: ld returned 1 exit status +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void rb_reg_onig_match(); +17: int t(void) { rb_reg_onig_match(); return 0; } +/* end */ + +-------------------- + diff --git a/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/strscan.so b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/strscan.so new file mode 100755 index 0000000..23d5768 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/strscan-3.1.0/strscan.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/CHANGELOG.md b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/CHANGELOG.md new file mode 100644 index 0000000..bf21002 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/CHANGELOG.md @@ -0,0 +1,301 @@ +# Addressable 2.8.7 +- Allow `public_suffix` 6 ([#535]) + +[#535]: https://github.com/sporkmonger/addressable/pull/535 + +# Addressable 2.8.6 +- Memoize regexps for common character classes ([#524]) + +[#524]: https://github.com/sporkmonger/addressable/pull/524 + +# Addressable 2.8.5 +- Fix thread safety issue with encoding tables ([#515]) +- Define URI::NONE as a module to avoid serialization issues ([#509]) +- Fix YAML serialization ([#508]) + +[#508]: https://github.com/sporkmonger/addressable/pull/508 +[#509]: https://github.com/sporkmonger/addressable/pull/509 +[#515]: https://github.com/sporkmonger/addressable/pull/515 + +# Addressable 2.8.4 +- Restore `Addressable::IDNA.unicode_normalize_kc` as a deprecated method ([#504]) + +[#504]: https://github.com/sporkmonger/addressable/pull/504 + +# Addressable 2.8.3 +- Fix template expand level 2 hash support for non-string objects ([#499], [#498]) + +[#499]: https://github.com/sporkmonger/addressable/pull/499 +[#498]: https://github.com/sporkmonger/addressable/pull/498 + +# Addressable 2.8.2 +- Improve cache hits and JIT friendliness ([#486](https://github.com/sporkmonger/addressable/pull/486)) +- Improve code style and test coverage ([#482](https://github.com/sporkmonger/addressable/pull/482)) +- Ensure reset of deferred validation ([#481](https://github.com/sporkmonger/addressable/pull/481)) +- Resolve normalization differences between `IDNA::Native` and `IDNA::Pure` ([#408](https://github.com/sporkmonger/addressable/issues/408), [#492]) +- Remove redundant colon in `Addressable::URI::CharacterClasses::AUTHORITY` regex ([#438](https://github.com/sporkmonger/addressable/pull/438)) (accidentally reverted by [#449] merge but [added back](https://github.com/sporkmonger/addressable/pull/492#discussion_r1105125280) in [#492]) + +[#492]: https://github.com/sporkmonger/addressable/pull/492 + +# Addressable 2.8.1 +- refactor `Addressable::URI.normalize_path` to address linter offenses ([#430](https://github.com/sporkmonger/addressable/pull/430)) +- update gemspec to reflect supported Ruby versions ([#466], [#464], [#463]) +- compatibility w/ public_suffix 5.x ([#466], [#465], [#460]) +- fixes "invalid byte sequence in UTF-8" exception when unencoding URLs containing non UTF-8 characters ([#459](https://github.com/sporkmonger/addressable/pull/459)) +- `Ractor` compatibility ([#449]) +- use the whole string instead of a single line for template match ([#431](https://github.com/sporkmonger/addressable/pull/431)) +- force UTF-8 encoding only if needed ([#341](https://github.com/sporkmonger/addressable/pull/341)) + +[#449]: https://github.com/sporkmonger/addressable/pull/449 +[#460]: https://github.com/sporkmonger/addressable/pull/460 +[#463]: https://github.com/sporkmonger/addressable/pull/463 +[#464]: https://github.com/sporkmonger/addressable/pull/464 +[#465]: https://github.com/sporkmonger/addressable/pull/465 +[#466]: https://github.com/sporkmonger/addressable/pull/466 + +# Addressable 2.8.0 +- fixes ReDoS vulnerability in Addressable::Template#match +- no longer replaces `+` with spaces in queries for non-http(s) schemes +- fixed encoding ipv6 literals +- the `:compacted` flag for `normalized_query` now dedupes parameters +- fix broken `escape_component` alias +- dropping support for Ruby 2.0 and 2.1 +- adding Ruby 3.0 compatibility for development tasks +- drop support for `rack-mount` and remove Addressable::Template#generate +- performance improvements +- switch CI/CD to GitHub Actions + +# Addressable 2.7.0 +- added `:compacted` flag to `normalized_query` +- `heuristic_parse` handles `mailto:` more intuitively +- dropped explicit support for JRuby 9.0.5.0 +- compatibility w/ public_suffix 4.x +- performance improvements + +# Addressable 2.6.0 +- added `tld=` method to allow assignment to the public suffix +- most `heuristic_parse` patterns are now case-insensitive +- `heuristic_parse` handles more `file://` URI variations +- fixes bug in `heuristic_parse` when uri starts with digit +- fixes bug in `request_uri=` with query strings +- fixes template issues with `nil` and `?` operator +- `frozen_string_literal` pragmas added +- minor performance improvements in regexps +- fixes to eliminate warnings + +# Addressable 2.5.2 +- better support for frozen string literals +- fixed bug w/ uppercase characters in scheme +- IDNA errors w/ emoji URLs +- compatibility w/ public_suffix 3.x + +# Addressable 2.5.1 +- allow unicode normalization to be disabled for URI Template expansion +- removed duplicate test + +# Addressable 2.5.0 +- dropping support for Ruby 1.9 +- adding support for Ruby 2.4 preview +- add support for public suffixes and tld; first runtime dependency +- hostname escaping should match RFC; underscores in hostnames no longer escaped +- paths beginning with // and missing an authority are now considered invalid +- validation now also takes place after setting a path +- handle backslashes in authority more like a browser for `heuristic_parse` +- unescaped backslashes in host now raise an `InvalidURIError` +- `merge!`, `join!`, `omit!` and `normalize!` don't disable deferred validation +- `heuristic_parse` now trims whitespace before parsing +- host parts longer than 63 bytes will be ignored and not passed to libidn +- normalized values always encoded as UTF-8 + +# Addressable 2.4.0 +- support for 1.8.x dropped +- double quotes in a host now raises an error +- newlines in host will no longer get unescaped during normalization +- stricter handling of bogus scheme values +- stricter handling of encoded port values +- calling `require 'addressable'` will now load both the URI and Template files +- assigning to the `hostname` component with an `IPAddr` object is now supported +- assigning to the `origin` component is now supported +- fixed minor bug where an exception would be thrown for a missing ACE suffix +- better partial expansion of URI templates + +# Addressable 2.3.8 +- fix warnings +- update dependency gems +- support for 1.8.x officially deprecated + +# Addressable 2.3.7 +- fix scenario in which invalid URIs don't get an exception until inspected +- handle hostnames with two adjacent periods correctly +- upgrade of RSpec + +# Addressable 2.3.6 +- normalization drops empty query string +- better handling in template extract for missing values +- template modifier for `'?'` now treated as optional +- fixed issue where character class parameters were modified +- templates can now be tested for equality +- added `:sorted` option to normalization of query strings +- fixed issue with normalization of hosts given in `'example.com.'` form + +# Addressable 2.3.5 +- added Addressable::URI#empty? method +- Addressable::URI#hostname methods now strip square brackets from IPv6 hosts +- compatibility with Net::HTTP in Ruby 2.0.0 +- Addressable::URI#route_from should always give relative URIs + +# Addressable 2.3.4 +- fixed issue with encoding altering its inputs +- query string normalization now leaves ';' characters alone +- FakeFS is detected before attempting to load unicode tables +- additional testing to ensure frozen objects don't cause problems + +# Addressable 2.3.3 +- fixed issue with converting common primitives during template expansion +- fixed port encoding issue +- removed a few warnings +- normalize should now ignore %2B in query strings +- the IDNA logic should now be handled by libidn in Ruby 1.9 +- no template match should now result in nil instead of an empty MatchData +- added license information to gemspec + +# Addressable 2.3.2 +- added Addressable::URI#default_port method +- fixed issue with Marshalling Unicode data on Windows +- improved heuristic parsing to better handle IPv4 addresses + +# Addressable 2.3.1 +- fixed missing unicode data file + +# Addressable 2.3.0 +- updated Addressable::Template to use RFC 6570, level 4 +- fixed compatibility problems with some versions of Ruby +- moved unicode tables into a data file for performance reasons +- removing support for multiple query value notations + +# Addressable 2.2.8 +- fixed issues with dot segment removal code +- form encoding can now handle multiple values per key +- updated development environment + +# Addressable 2.2.7 +- fixed issues related to Addressable::URI#query_values= +- the Addressable::URI.parse method is now polymorphic + +# Addressable 2.2.6 +- changed the way ambiguous paths are handled +- fixed bug with frozen URIs +- https supported in heuristic parsing + +# Addressable 2.2.5 +- 'parsing' a pre-parsed URI object is now a dup operation +- introduced conditional support for libidn +- fixed normalization issue on ampersands in query strings +- added additional tests around handling of query strings + +# Addressable 2.2.4 +- added origin support from draft-ietf-websec-origin-00 +- resolved issue with attempting to navigate below root +- fixed bug with string splitting in query strings + +# Addressable 2.2.3 +- added :flat_array notation for query strings + +# Addressable 2.2.2 +- fixed issue with percent escaping of '+' character in query strings + +# Addressable 2.2.1 +- added support for application/x-www-form-urlencoded. + +# Addressable 2.2.0 +- added site methods +- improved documentation + +# Addressable 2.1.2 +- added HTTP request URI methods +- better handling of Windows file paths +- validation_deferred boolean replaced with defer_validation block +- normalization of percent-encoded paths should now be correct +- fixed issue with constructing URIs with relative paths +- fixed warnings + +# Addressable 2.1.1 +- more type checking changes +- fixed issue with unicode normalization +- added method to find template defaults +- symbolic keys are now allowed in template mappings +- numeric values and symbolic values are now allowed in template mappings + +# Addressable 2.1.0 +- refactored URI template support out into its own class +- removed extract method due to being useless and unreliable +- removed Addressable::URI.expand_template +- removed Addressable::URI#extract_mapping +- added partial template expansion +- fixed minor bugs in the parse and heuristic_parse methods +- fixed incompatibility with Ruby 1.9.1 +- fixed bottleneck in Addressable::URI#hash and Addressable::URI#to_s +- fixed unicode normalization exception +- updated query_values methods to better handle subscript notation +- worked around issue with freezing URIs +- improved specs + +# Addressable 2.0.2 +- fixed issue with URI template expansion +- fixed issue with percent escaping characters 0-15 + +# Addressable 2.0.1 +- fixed issue with query string assignment +- fixed issue with improperly encoded components + +# Addressable 2.0.0 +- the initialize method now takes an options hash as its only parameter +- added query_values method to URI class +- completely replaced IDNA implementation with pure Ruby +- renamed Addressable::ADDRESSABLE_VERSION to Addressable::VERSION +- completely reworked the Rakefile +- changed the behavior of the port method significantly +- Addressable::URI.encode_segment, Addressable::URI.unencode_segment renamed +- documentation is now in YARD format +- more rigorous type checking +- to_str method implemented, implicit conversion to Strings now allowed +- Addressable::URI#omit method added, Addressable::URI#merge method replaced +- updated URI Template code to match v 03 of the draft spec +- added a bunch of new specifications + +# Addressable 1.0.4 +- switched to using RSpec's pending system for specs that rely on IDN +- fixed issue with creating URIs with paths that are not prefixed with '/' + +# Addressable 1.0.3 +- implemented a hash method + +# Addressable 1.0.2 +- fixed minor bug with the extract_mapping method + +# Addressable 1.0.1 +- fixed minor bug with the extract_mapping method + +# Addressable 1.0.0 +- heuristic parse method added +- parsing is slightly more strict +- replaced to_h with to_hash +- fixed routing methods +- improved specifications +- improved heckle rake task +- no surviving heckle mutations + +# Addressable 0.1.2 +- improved normalization +- fixed bug in joining algorithm +- updated specifications + +# Addressable 0.1.1 +- updated documentation +- added URI Template variable extraction + +# Addressable 0.1.0 +- initial release +- implementation based on RFC 3986, 3987 +- support for IRIs via libidn +- support for the URI Template draft spec diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/Gemfile b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/Gemfile new file mode 100644 index 0000000..87cf771 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/Gemfile @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +gemspec + +group :test do + gem 'bigdecimal' if RUBY_VERSION > '2.4' + gem 'rspec', '~> 3.8' + gem 'rspec-its', '~> 1.3' +end + +group :coverage do + gem "coveralls", "> 0.7", require: false, platforms: :mri + gem "simplecov", require: false +end + +group :development do + gem 'launchy', '~> 2.4', '>= 2.4.3' + gem 'redcarpet', :platform => :mri_19 + gem 'yard' +end + +group :test, :development do + gem 'memory_profiler' + gem "rake", ">= 12.3.3" +end + +unless ENV["IDNA_MODE"] == "pure" + gem "idn-ruby", platform: :mri +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/LICENSE.txt new file mode 100644 index 0000000..ef51da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/README.md b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/README.md new file mode 100644 index 0000000..9892f61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/README.md @@ -0,0 +1,121 @@ +# Addressable + +
+
Homepage
github.com/sporkmonger/addressable
+
Author
Bob Aman
+
Copyright
Copyright © Bob Aman
+
License
Apache 2.0
+
+ +[![Gem Version](https://img.shields.io/gem/dt/addressable.svg)][gem] +[![Build Status](https://github.com/sporkmonger/addressable/workflows/CI/badge.svg)][actions] +[![Test Coverage Status](https://img.shields.io/coveralls/sporkmonger/addressable.svg)][coveralls] +[![Documentation Coverage Status](https://inch-ci.org/github/sporkmonger/addressable.svg?branch=master)][inch] + +[gem]: https://rubygems.org/gems/addressable +[actions]: https://github.com/sporkmonger/addressable/actions +[coveralls]: https://coveralls.io/r/sporkmonger/addressable +[inch]: https://inch-ci.org/github/sporkmonger/addressable + +# Description + +Addressable is an alternative implementation to the URI implementation +that is part of Ruby's standard library. It is flexible, offers heuristic +parsing, and additionally provides extensive support for IRIs and URI templates. + +Addressable closely conforms to RFC 3986, RFC 3987, and RFC 6570 (level 4). + +# Reference + +- {Addressable::URI} +- {Addressable::Template} + +# Example usage + +```ruby +require "addressable/uri" + +uri = Addressable::URI.parse("http://example.com/path/to/resource/") +uri.scheme +#=> "http" +uri.host +#=> "example.com" +uri.path +#=> "/path/to/resource/" + +uri = Addressable::URI.parse("http://www.詹姆斯.com/") +uri.normalize +#=> # +``` + + +# URI Templates + +For more details, see [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.txt). + + +```ruby + +require "addressable/template" + +template = Addressable::Template.new("http://example.com/{?query*}") +template.expand({ + "query" => { + 'foo' => 'bar', + 'color' => 'red' + } +}) +#=> # + +template = Addressable::Template.new("http://example.com/{?one,two,three}") +template.partial_expand({"one" => "1", "three" => 3}).pattern +#=> "http://example.com/?one=1{&two}&three=3" + +template = Addressable::Template.new( + "http://{host}{/segments*}/{?one,two,bogus}{#fragment}" +) +uri = Addressable::URI.parse( + "http://example.com/a/b/c/?one=1&two=2#foo" +) +template.extract(uri) +#=> +# { +# "host" => "example.com", +# "segments" => ["a", "b", "c"], +# "one" => "1", +# "two" => "2", +# "fragment" => "foo" +# } +``` + +# Install + +```console +$ gem install addressable +``` + +You may optionally turn on native IDN support by installing libidn and the +idn gem: + +```console +$ sudo apt-get install libidn11-dev # Debian/Ubuntu +$ brew install libidn # OS X +$ gem install idn-ruby +``` + +# Semantic Versioning + +This project uses [Semantic Versioning](https://semver.org/). You can (and should) specify your +dependency using a pessimistic version constraint covering the major and minor +values: + +```ruby +spec.add_dependency 'addressable', '~> 2.7' +``` + +If you need a specific bug fix, you can also specify minimum tiny versions +without preventing updates to the latest minor release: + +```ruby +spec.add_dependency 'addressable', '~> 2.3', '>= 2.3.7' +``` diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/Rakefile b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/Rakefile new file mode 100644 index 0000000..46fbbd0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/Rakefile @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'rubygems' +require 'rake' + +require File.join(File.dirname(__FILE__), 'lib', 'addressable', 'version') + +PKG_DISPLAY_NAME = 'Addressable' +PKG_NAME = PKG_DISPLAY_NAME.downcase +PKG_VERSION = Addressable::VERSION::STRING +PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" + +RELEASE_NAME = "REL #{PKG_VERSION}" + +PKG_SUMMARY = "URI Implementation" +PKG_DESCRIPTION = <<-TEXT +Addressable is an alternative implementation to the URI implementation that is +part of Ruby's standard library. It is flexible, offers heuristic parsing, and +additionally provides extensive support for IRIs and URI templates. +TEXT + +PKG_FILES = FileList[ + "data/**/*", + "lib/**/*.rb", + "spec/**/*.rb", + "tasks/**/*.rake", + "addressable.gemspec", + "CHANGELOG.md", + "Gemfile", + "LICENSE.txt", + "README.md", + "Rakefile", +] + +task :default => "spec" + +Dir['tasks/**/*.rake'].each { |rake| load rake } diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/addressable.gemspec b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/addressable.gemspec new file mode 100644 index 0000000..bb1f2fa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/addressable.gemspec @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +# stub: addressable 2.8.7 ruby lib + +Gem::Specification.new do |s| + s.name = "addressable".freeze + s.version = "2.8.7".freeze + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md#v2.8.7" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Bob Aman".freeze] + s.date = "2024-06-21" + s.description = "Addressable is an alternative implementation to the URI implementation that is\npart of Ruby's standard library. It is flexible, offers heuristic parsing, and\nadditionally provides extensive support for IRIs and URI templates.\n".freeze + s.email = "bob@sporkmonger.com".freeze + s.extra_rdoc_files = ["README.md".freeze] + s.files = ["CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE.txt".freeze, "README.md".freeze, "Rakefile".freeze, "addressable.gemspec".freeze, "data/unicode.data".freeze, "lib/addressable.rb".freeze, "lib/addressable/idna.rb".freeze, "lib/addressable/idna/native.rb".freeze, "lib/addressable/idna/pure.rb".freeze, "lib/addressable/template.rb".freeze, "lib/addressable/uri.rb".freeze, "lib/addressable/version.rb".freeze, "spec/addressable/idna_spec.rb".freeze, "spec/addressable/net_http_compat_spec.rb".freeze, "spec/addressable/security_spec.rb".freeze, "spec/addressable/template_spec.rb".freeze, "spec/addressable/uri_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tasks/clobber.rake".freeze, "tasks/gem.rake".freeze, "tasks/git.rake".freeze, "tasks/metrics.rake".freeze, "tasks/profile.rake".freeze, "tasks/rspec.rake".freeze, "tasks/yard.rake".freeze] + s.homepage = "https://github.com/sporkmonger/addressable".freeze + s.licenses = ["Apache-2.0".freeze] + s.rdoc_options = ["--main".freeze, "README.md".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze) + s.rubygems_version = "3.5.11".freeze + s.summary = "URI Implementation".freeze + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, [">= 2.0.2".freeze, "< 7.0".freeze]) + s.add_development_dependency(%q.freeze, [">= 1.0".freeze, "< 3.0".freeze]) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/data/unicode.data b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/data/unicode.data new file mode 100644 index 0000000..cdfc224 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/data/unicode.data differ diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable.rb new file mode 100644 index 0000000..b4e98b6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +require 'addressable/uri' +require 'addressable/template' diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna.rb new file mode 100644 index 0000000..2dbd393 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +#-- +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#++ + + +begin + require "addressable/idna/native" +rescue LoadError + # libidn or the idn gem was not available, fall back on a pure-Ruby + # implementation... + require "addressable/idna/pure" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna/native.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna/native.rb new file mode 100644 index 0000000..a718364 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna/native.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +#-- +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#++ + + +require "idn" + +module Addressable + module IDNA + def self.punycode_encode(value) + IDN::Punycode.encode(value.to_s) + end + + def self.punycode_decode(value) + IDN::Punycode.decode(value.to_s) + end + + class << self + # @deprecated Use {String#unicode_normalize(:nfkc)} instead + def unicode_normalize_kc(value) + value.to_s.unicode_normalize(:nfkc) + end + + extend Gem::Deprecate + deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4 + end + + def self.to_ascii(value) + value.to_s.split('.', -1).map do |segment| + if segment.size > 0 && segment.size < 64 + IDN::Idna.toASCII(segment, IDN::Idna::ALLOW_UNASSIGNED) + elsif segment.size >= 64 + segment + else + '' + end + end.join('.') + end + + def self.to_unicode(value) + value.to_s.split('.', -1).map do |segment| + if segment.size > 0 && segment.size < 64 + IDN::Idna.toUnicode(segment, IDN::Idna::ALLOW_UNASSIGNED) + elsif segment.size >= 64 + segment + else + '' + end + end.join('.') + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna/pure.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna/pure.rb new file mode 100644 index 0000000..3d6ffba --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/idna/pure.rb @@ -0,0 +1,505 @@ +# frozen_string_literal: true + +#-- +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#++ + + +module Addressable + module IDNA + # This module is loosely based on idn_actionmailer by Mick Staugaard, + # the unicode library by Yoshida Masato, and the punycode implementation + # by Kazuhiro Nishiyama. Most of the code was copied verbatim, but + # some reformatting was done, and some translation from C was done. + # + # Without their code to work from as a base, we'd all still be relying + # on the presence of libidn. Which nobody ever seems to have installed. + # + # Original sources: + # http://github.com/staugaard/idn_actionmailer + # http://www.yoshidam.net/Ruby.html#unicode + # http://rubyforge.org/frs/?group_id=2550 + + + UNICODE_TABLE = File.expand_path( + File.join(File.dirname(__FILE__), '../../..', 'data/unicode.data') + ) + + ACE_PREFIX = "xn--" + + UTF8_REGEX = /\A(?: + [\x09\x0A\x0D\x20-\x7E] # ASCII + | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte + | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs + | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte + | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates + | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 + | [\xF1-\xF3][\x80-\xBF]{3} # planes 4nil5 + | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 + )*\z/mnx + + UTF8_REGEX_MULTIBYTE = /(?: + [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte + | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs + | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte + | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates + | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 + | [\xF1-\xF3][\x80-\xBF]{3} # planes 4nil5 + | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 + )/mnx + + # :startdoc: + + # Converts from a Unicode internationalized domain name to an ASCII + # domain name as described in RFC 3490. + def self.to_ascii(input) + input = input.to_s unless input.is_a?(String) + input = input.dup.force_encoding(Encoding::UTF_8).unicode_normalize(:nfkc) + if input.respond_to?(:force_encoding) + input.force_encoding(Encoding::ASCII_8BIT) + end + if input =~ UTF8_REGEX && input =~ UTF8_REGEX_MULTIBYTE + parts = unicode_downcase(input).split('.') + parts.map! do |part| + if part.respond_to?(:force_encoding) + part.force_encoding(Encoding::ASCII_8BIT) + end + if part =~ UTF8_REGEX && part =~ UTF8_REGEX_MULTIBYTE + ACE_PREFIX + punycode_encode(part) + else + part + end + end + parts.join('.') + else + input + end + end + + # Converts from an ASCII domain name to a Unicode internationalized + # domain name as described in RFC 3490. + def self.to_unicode(input) + input = input.to_s unless input.is_a?(String) + parts = input.split('.') + parts.map! do |part| + if part =~ /^#{ACE_PREFIX}(.+)/ + begin + punycode_decode(part[/^#{ACE_PREFIX}(.+)/, 1]) + rescue Addressable::IDNA::PunycodeBadInput + # toUnicode is explicitly defined as never-fails by the spec + part + end + else + part + end + end + output = parts.join('.') + if output.respond_to?(:force_encoding) + output.force_encoding(Encoding::UTF_8) + end + output + end + + class << self + # @deprecated Use {String#unicode_normalize(:nfkc)} instead + def unicode_normalize_kc(value) + value.to_s.unicode_normalize(:nfkc) + end + + extend Gem::Deprecate + deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4 + end + + ## + # Unicode aware downcase method. + # + # @api private + # @param [String] input + # The input string. + # @return [String] The downcased result. + def self.unicode_downcase(input) + input = input.to_s unless input.is_a?(String) + unpacked = input.unpack("U*") + unpacked.map! { |codepoint| lookup_unicode_lowercase(codepoint) } + return unpacked.pack("U*") + end + private_class_method :unicode_downcase + + def self.lookup_unicode_lowercase(codepoint) + codepoint_data = UNICODE_DATA[codepoint] + (codepoint_data ? + (codepoint_data[UNICODE_DATA_LOWERCASE] || codepoint) : + codepoint) + end + private_class_method :lookup_unicode_lowercase + + UNICODE_DATA_COMBINING_CLASS = 0 + UNICODE_DATA_EXCLUSION = 1 + UNICODE_DATA_CANONICAL = 2 + UNICODE_DATA_COMPATIBILITY = 3 + UNICODE_DATA_UPPERCASE = 4 + UNICODE_DATA_LOWERCASE = 5 + UNICODE_DATA_TITLECASE = 6 + + begin + if defined?(FakeFS) + fakefs_state = FakeFS.activated? + FakeFS.deactivate! + end + # This is a sparse Unicode table. Codepoints without entries are + # assumed to have the value: [0, 0, nil, nil, nil, nil, nil] + UNICODE_DATA = File.open(UNICODE_TABLE, "rb") do |file| + Marshal.load(file.read) + end + ensure + if defined?(FakeFS) + FakeFS.activate! if fakefs_state + end + end + + COMPOSITION_TABLE = {} + UNICODE_DATA.each do |codepoint, data| + canonical = data[UNICODE_DATA_CANONICAL] + exclusion = data[UNICODE_DATA_EXCLUSION] + + if canonical && exclusion == 0 + COMPOSITION_TABLE[canonical.unpack("C*")] = codepoint + end + end + + UNICODE_MAX_LENGTH = 256 + ACE_MAX_LENGTH = 256 + + PUNYCODE_BASE = 36 + PUNYCODE_TMIN = 1 + PUNYCODE_TMAX = 26 + PUNYCODE_SKEW = 38 + PUNYCODE_DAMP = 700 + PUNYCODE_INITIAL_BIAS = 72 + PUNYCODE_INITIAL_N = 0x80 + PUNYCODE_DELIMITER = 0x2D + + PUNYCODE_MAXINT = 1 << 64 + + PUNYCODE_PRINT_ASCII = + "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + + "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + + " !\"\#$%&'()*+,-./" + + "0123456789:;<=>?" + + "@ABCDEFGHIJKLMNO" + + "PQRSTUVWXYZ[\\]^_" + + "`abcdefghijklmno" + + "pqrstuvwxyz{|}~\n" + + # Input is invalid. + class PunycodeBadInput < StandardError; end + # Output would exceed the space provided. + class PunycodeBigOutput < StandardError; end + # Input needs wider integers to process. + class PunycodeOverflow < StandardError; end + + def self.punycode_encode(unicode) + unicode = unicode.to_s unless unicode.is_a?(String) + input = unicode.unpack("U*") + output = [0] * (ACE_MAX_LENGTH + 1) + input_length = input.size + output_length = [ACE_MAX_LENGTH] + + # Initialize the state + n = PUNYCODE_INITIAL_N + delta = out = 0 + max_out = output_length[0] + bias = PUNYCODE_INITIAL_BIAS + + # Handle the basic code points: + input_length.times do |j| + if punycode_basic?(input[j]) + if max_out - out < 2 + raise PunycodeBigOutput, + "Output would exceed the space provided." + end + output[out] = input[j] + out += 1 + end + end + + h = b = out + + # h is the number of code points that have been handled, b is the + # number of basic code points, and out is the number of characters + # that have been output. + + if b > 0 + output[out] = PUNYCODE_DELIMITER + out += 1 + end + + # Main encoding loop: + + while h < input_length + # All non-basic code points < n have been + # handled already. Find the next larger one: + + m = PUNYCODE_MAXINT + input_length.times do |j| + m = input[j] if (n...m) === input[j] + end + + # Increase delta enough to advance the decoder's + # state to , but guard against overflow: + + if m - n > (PUNYCODE_MAXINT - delta) / (h + 1) + raise PunycodeOverflow, "Input needs wider integers to process." + end + delta += (m - n) * (h + 1) + n = m + + input_length.times do |j| + # Punycode does not need to check whether input[j] is basic: + if input[j] < n + delta += 1 + if delta == 0 + raise PunycodeOverflow, + "Input needs wider integers to process." + end + end + + if input[j] == n + # Represent delta as a generalized variable-length integer: + + q = delta; k = PUNYCODE_BASE + while true + if out >= max_out + raise PunycodeBigOutput, + "Output would exceed the space provided." + end + t = ( + if k <= bias + PUNYCODE_TMIN + elsif k >= bias + PUNYCODE_TMAX + PUNYCODE_TMAX + else + k - bias + end + ) + break if q < t + output[out] = + punycode_encode_digit(t + (q - t) % (PUNYCODE_BASE - t)) + out += 1 + q = (q - t) / (PUNYCODE_BASE - t) + k += PUNYCODE_BASE + end + + output[out] = punycode_encode_digit(q) + out += 1 + bias = punycode_adapt(delta, h + 1, h == b) + delta = 0 + h += 1 + end + end + + delta += 1 + n += 1 + end + + output_length[0] = out + + outlen = out + outlen.times do |j| + c = output[j] + unless c >= 0 && c <= 127 + raise StandardError, "Invalid output char." + end + unless PUNYCODE_PRINT_ASCII[c] + raise PunycodeBadInput, "Input is invalid." + end + end + + output[0..outlen].map { |x| x.chr }.join("").sub(/\0+\z/, "") + end + private_class_method :punycode_encode + + def self.punycode_decode(punycode) + input = [] + output = [] + + if ACE_MAX_LENGTH * 2 < punycode.size + raise PunycodeBigOutput, "Output would exceed the space provided." + end + punycode.each_byte do |c| + unless c >= 0 && c <= 127 + raise PunycodeBadInput, "Input is invalid." + end + input.push(c) + end + + input_length = input.length + output_length = [UNICODE_MAX_LENGTH] + + # Initialize the state + n = PUNYCODE_INITIAL_N + + out = i = 0 + max_out = output_length[0] + bias = PUNYCODE_INITIAL_BIAS + + # Handle the basic code points: Let b be the number of input code + # points before the last delimiter, or 0 if there is none, then + # copy the first b code points to the output. + + b = 0 + input_length.times do |j| + b = j if punycode_delimiter?(input[j]) + end + if b > max_out + raise PunycodeBigOutput, "Output would exceed the space provided." + end + + b.times do |j| + unless punycode_basic?(input[j]) + raise PunycodeBadInput, "Input is invalid." + end + output[out] = input[j] + out+=1 + end + + # Main decoding loop: Start just after the last delimiter if any + # basic code points were copied; start at the beginning otherwise. + + in_ = b > 0 ? b + 1 : 0 + while in_ < input_length + + # in_ is the index of the next character to be consumed, and + # out is the number of code points in the output array. + + # Decode a generalized variable-length integer into delta, + # which gets added to i. The overflow checking is easier + # if we increase i as we go, then subtract off its starting + # value at the end to obtain delta. + + oldi = i; w = 1; k = PUNYCODE_BASE + while true + if in_ >= input_length + raise PunycodeBadInput, "Input is invalid." + end + digit = punycode_decode_digit(input[in_]) + in_+=1 + if digit >= PUNYCODE_BASE + raise PunycodeBadInput, "Input is invalid." + end + if digit > (PUNYCODE_MAXINT - i) / w + raise PunycodeOverflow, "Input needs wider integers to process." + end + i += digit * w + t = ( + if k <= bias + PUNYCODE_TMIN + elsif k >= bias + PUNYCODE_TMAX + PUNYCODE_TMAX + else + k - bias + end + ) + break if digit < t + if w > PUNYCODE_MAXINT / (PUNYCODE_BASE - t) + raise PunycodeOverflow, "Input needs wider integers to process." + end + w *= PUNYCODE_BASE - t + k += PUNYCODE_BASE + end + + bias = punycode_adapt(i - oldi, out + 1, oldi == 0) + + # I was supposed to wrap around from out + 1 to 0, + # incrementing n each time, so we'll fix that now: + + if i / (out + 1) > PUNYCODE_MAXINT - n + raise PunycodeOverflow, "Input needs wider integers to process." + end + n += i / (out + 1) + i %= out + 1 + + # Insert n at position i of the output: + + # not needed for Punycode: + # raise PUNYCODE_INVALID_INPUT if decode_digit(n) <= base + if out >= max_out + raise PunycodeBigOutput, "Output would exceed the space provided." + end + + #memmove(output + i + 1, output + i, (out - i) * sizeof *output) + output[i + 1, out - i] = output[i, out - i] + output[i] = n + i += 1 + + out += 1 + end + + output_length[0] = out + + output.pack("U*") + end + private_class_method :punycode_decode + + def self.punycode_basic?(codepoint) + codepoint < 0x80 + end + private_class_method :punycode_basic? + + def self.punycode_delimiter?(codepoint) + codepoint == PUNYCODE_DELIMITER + end + private_class_method :punycode_delimiter? + + def self.punycode_encode_digit(d) + d + 22 + 75 * ((d < 26) ? 1 : 0) + end + private_class_method :punycode_encode_digit + + # Returns the numeric value of a basic codepoint + # (for use in representing integers) in the range 0 to + # base - 1, or PUNYCODE_BASE if codepoint does not represent a value. + def self.punycode_decode_digit(codepoint) + if codepoint - 48 < 10 + codepoint - 22 + elsif codepoint - 65 < 26 + codepoint - 65 + elsif codepoint - 97 < 26 + codepoint - 97 + else + PUNYCODE_BASE + end + end + private_class_method :punycode_decode_digit + + # Bias adaptation method + def self.punycode_adapt(delta, numpoints, firsttime) + delta = firsttime ? delta / PUNYCODE_DAMP : delta >> 1 + # delta >> 1 is a faster way of doing delta / 2 + delta += delta / numpoints + difference = PUNYCODE_BASE - PUNYCODE_TMIN + + k = 0 + while delta > (difference * PUNYCODE_TMAX) / 2 + delta /= difference + k += PUNYCODE_BASE + end + + k + (difference + 1) * delta / (delta + PUNYCODE_SKEW) + end + private_class_method :punycode_adapt + end + # :startdoc: +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/template.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/template.rb new file mode 100644 index 0000000..08556d9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/template.rb @@ -0,0 +1,1029 @@ +# frozen_string_literal: true + +#-- +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#++ + + +require "addressable/version" +require "addressable/uri" + +module Addressable + ## + # This is an implementation of a URI template based on + # RFC 6570 (http://tools.ietf.org/html/rfc6570). + class Template + # Constants used throughout the template code. + anything = + Addressable::URI::CharacterClasses::RESERVED + + Addressable::URI::CharacterClasses::UNRESERVED + + + variable_char_class = + Addressable::URI::CharacterClasses::ALPHA + + Addressable::URI::CharacterClasses::DIGIT + '_' + + var_char = + "(?>(?:[#{variable_char_class}]|%[a-fA-F0-9][a-fA-F0-9])+)" + RESERVED = + "(?:[#{anything}]|%[a-fA-F0-9][a-fA-F0-9])" + UNRESERVED = + "(?:[#{ + Addressable::URI::CharacterClasses::UNRESERVED + }]|%[a-fA-F0-9][a-fA-F0-9])" + variable = + "(?:#{var_char}(?:\\.?#{var_char})*)" + varspec = + "(?:(#{variable})(\\*|:\\d+)?)" + VARNAME = + /^#{variable}$/ + VARSPEC = + /^#{varspec}$/ + VARIABLE_LIST = + /^#{varspec}(?:,#{varspec})*$/ + operator = + "+#./;?&=,!@|" + EXPRESSION = + /\{([#{operator}])?(#{varspec}(?:,#{varspec})*)\}/ + + + LEADERS = { + '?' => '?', + '/' => '/', + '#' => '#', + '.' => '.', + ';' => ';', + '&' => '&' + } + JOINERS = { + '?' => '&', + '.' => '.', + ';' => ';', + '&' => '&', + '/' => '/' + } + + ## + # Raised if an invalid template value is supplied. + class InvalidTemplateValueError < StandardError + end + + ## + # Raised if an invalid template operator is used in a pattern. + class InvalidTemplateOperatorError < StandardError + end + + ## + # Raised if an invalid template operator is used in a pattern. + class TemplateOperatorAbortedError < StandardError + end + + ## + # This class represents the data that is extracted when a Template + # is matched against a URI. + class MatchData + ## + # Creates a new MatchData object. + # MatchData objects should never be instantiated directly. + # + # @param [Addressable::URI] uri + # The URI that the template was matched against. + def initialize(uri, template, mapping) + @uri = uri.dup.freeze + @template = template + @mapping = mapping.dup.freeze + end + + ## + # @return [Addressable::URI] + # The URI that the Template was matched against. + attr_reader :uri + + ## + # @return [Addressable::Template] + # The Template used for the match. + attr_reader :template + + ## + # @return [Hash] + # The mapping that resulted from the match. + # Note that this mapping does not include keys or values for + # variables that appear in the Template, but are not present + # in the URI. + attr_reader :mapping + + ## + # @return [Array] + # The list of variables that were present in the Template. + # Note that this list will include variables which do not appear + # in the mapping because they were not present in URI. + def variables + self.template.variables + end + alias_method :keys, :variables + alias_method :names, :variables + + ## + # @return [Array] + # The list of values that were captured by the Template. + # Note that this list will include nils for any variables which + # were in the Template, but did not appear in the URI. + def values + @values ||= self.variables.inject([]) do |accu, key| + accu << self.mapping[key] + accu + end + end + alias_method :captures, :values + + ## + # Accesses captured values by name or by index. + # + # @param [String, Symbol, Fixnum] key + # Capture index or name. Note that when accessing by with index + # of 0, the full URI will be returned. The intention is to mimic + # the ::MatchData#[] behavior. + # + # @param [#to_int, nil] len + # If provided, an array of values will be returned with the given + # parameter used as length. + # + # @return [Array, String, nil] + # The captured value corresponding to the index or name. If the + # value was not provided or the key is unknown, nil will be + # returned. + # + # If the second parameter is provided, an array of that length will + # be returned instead. + def [](key, len = nil) + if len + to_a[key, len] + elsif String === key or Symbol === key + mapping[key.to_s] + else + to_a[key] + end + end + + ## + # @return [Array] + # Array with the matched URI as first element followed by the captured + # values. + def to_a + [to_s, *values] + end + + ## + # @return [String] + # The matched URI as String. + def to_s + uri.to_s + end + alias_method :string, :to_s + + # Returns multiple captured values at once. + # + # @param [String, Symbol, Fixnum] *indexes + # Indices of the captures to be returned + # + # @return [Array] + # Values corresponding to given indices. + # + # @see Addressable::Template::MatchData#[] + def values_at(*indexes) + indexes.map { |i| self[i] } + end + + ## + # Returns a String representation of the MatchData's state. + # + # @return [String] The MatchData's state, as a String. + def inspect + sprintf("#<%s:%#0x RESULT:%s>", + self.class.to_s, self.object_id, self.mapping.inspect) + end + + ## + # Dummy method for code expecting a ::MatchData instance + # + # @return [String] An empty string. + def pre_match + "" + end + alias_method :post_match, :pre_match + end + + ## + # Creates a new Addressable::Template object. + # + # @param [#to_str] pattern The URI Template pattern. + # + # @return [Addressable::Template] The initialized Template object. + def initialize(pattern) + if !pattern.respond_to?(:to_str) + raise TypeError, "Can't convert #{pattern.class} into String." + end + @pattern = pattern.to_str.dup.freeze + end + + ## + # Freeze URI, initializing instance variables. + # + # @return [Addressable::URI] The frozen URI object. + def freeze + self.variables + self.variable_defaults + self.named_captures + super + end + + ## + # @return [String] The Template object's pattern. + attr_reader :pattern + + ## + # Returns a String representation of the Template object's state. + # + # @return [String] The Template object's state, as a String. + def inspect + sprintf("#<%s:%#0x PATTERN:%s>", + self.class.to_s, self.object_id, self.pattern) + end + + ## + # Returns true if the Template objects are equal. This method + # does NOT normalize either Template before doing the comparison. + # + # @param [Object] template The Template to compare. + # + # @return [TrueClass, FalseClass] + # true if the Templates are equivalent, false + # otherwise. + def ==(template) + return false unless template.kind_of?(Template) + return self.pattern == template.pattern + end + + ## + # Addressable::Template makes no distinction between `==` and `eql?`. + # + # @see #== + alias_method :eql?, :== + + ## + # Extracts a mapping from the URI using a URI Template pattern. + # + # @param [Addressable::URI, #to_str] uri + # The URI to extract from. + # + # @param [#restore, #match] processor + # A template processor object may optionally be supplied. + # + # The object should respond to either the restore or + # match messages or both. The restore method should + # take two parameters: `[String] name` and `[String] value`. + # The restore method should reverse any transformations that + # have been performed on the value to ensure a valid URI. + # The match method should take a single + # parameter: `[String] name`. The match method should return + # a String containing a regular expression capture group for + # matching on that particular variable. The default value is `".*?"`. + # The match method has no effect on multivariate operator + # expansions. + # + # @return [Hash, NilClass] + # The Hash mapping that was extracted from the URI, or + # nil if the URI didn't match the template. + # + # @example + # class ExampleProcessor + # def self.restore(name, value) + # return value.gsub(/\+/, " ") if name == "query" + # return value + # end + # + # def self.match(name) + # return ".*?" if name == "first" + # return ".*" + # end + # end + # + # uri = Addressable::URI.parse( + # "http://example.com/search/an+example+search+query/" + # ) + # Addressable::Template.new( + # "http://example.com/search/{query}/" + # ).extract(uri, ExampleProcessor) + # #=> {"query" => "an example search query"} + # + # uri = Addressable::URI.parse("http://example.com/a/b/c/") + # Addressable::Template.new( + # "http://example.com/{first}/{second}/" + # ).extract(uri, ExampleProcessor) + # #=> {"first" => "a", "second" => "b/c"} + # + # uri = Addressable::URI.parse("http://example.com/a/b/c/") + # Addressable::Template.new( + # "http://example.com/{first}/{-list|/|second}/" + # ).extract(uri) + # #=> {"first" => "a", "second" => ["b", "c"]} + def extract(uri, processor=nil) + match_data = self.match(uri, processor) + return (match_data ? match_data.mapping : nil) + end + + ## + # Extracts match data from the URI using a URI Template pattern. + # + # @param [Addressable::URI, #to_str] uri + # The URI to extract from. + # + # @param [#restore, #match] processor + # A template processor object may optionally be supplied. + # + # The object should respond to either the restore or + # match messages or both. The restore method should + # take two parameters: `[String] name` and `[String] value`. + # The restore method should reverse any transformations that + # have been performed on the value to ensure a valid URI. + # The match method should take a single + # parameter: `[String] name`. The match method should return + # a String containing a regular expression capture group for + # matching on that particular variable. The default value is `".*?"`. + # The match method has no effect on multivariate operator + # expansions. + # + # @return [Hash, NilClass] + # The Hash mapping that was extracted from the URI, or + # nil if the URI didn't match the template. + # + # @example + # class ExampleProcessor + # def self.restore(name, value) + # return value.gsub(/\+/, " ") if name == "query" + # return value + # end + # + # def self.match(name) + # return ".*?" if name == "first" + # return ".*" + # end + # end + # + # uri = Addressable::URI.parse( + # "http://example.com/search/an+example+search+query/" + # ) + # match = Addressable::Template.new( + # "http://example.com/search/{query}/" + # ).match(uri, ExampleProcessor) + # match.variables + # #=> ["query"] + # match.captures + # #=> ["an example search query"] + # + # uri = Addressable::URI.parse("http://example.com/a/b/c/") + # match = Addressable::Template.new( + # "http://example.com/{first}/{+second}/" + # ).match(uri, ExampleProcessor) + # match.variables + # #=> ["first", "second"] + # match.captures + # #=> ["a", "b/c"] + # + # uri = Addressable::URI.parse("http://example.com/a/b/c/") + # match = Addressable::Template.new( + # "http://example.com/{first}{/second*}/" + # ).match(uri) + # match.variables + # #=> ["first", "second"] + # match.captures + # #=> ["a", ["b", "c"]] + def match(uri, processor=nil) + uri = Addressable::URI.parse(uri) unless uri.is_a?(Addressable::URI) + mapping = {} + + # First, we need to process the pattern, and extract the values. + expansions, expansion_regexp = + parse_template_pattern(pattern, processor) + + return nil unless uri.to_str.match(expansion_regexp) + unparsed_values = uri.to_str.scan(expansion_regexp).flatten + + if uri.to_str == pattern + return Addressable::Template::MatchData.new(uri, self, mapping) + elsif expansions.size > 0 + index = 0 + expansions.each do |expansion| + _, operator, varlist = *expansion.match(EXPRESSION) + varlist.split(',').each do |varspec| + _, name, modifier = *varspec.match(VARSPEC) + mapping[name] ||= nil + case operator + when nil, '+', '#', '/', '.' + unparsed_value = unparsed_values[index] + name = varspec[VARSPEC, 1] + value = unparsed_value + value = value.split(JOINERS[operator]) if value && modifier == '*' + when ';', '?', '&' + if modifier == '*' + if unparsed_values[index] + value = unparsed_values[index].split(JOINERS[operator]) + value = value.inject({}) do |acc, v| + key, val = v.split('=') + val = "" if val.nil? + acc[key] = val + acc + end + end + else + if (unparsed_values[index]) + name, value = unparsed_values[index].split('=') + value = "" if value.nil? + end + end + end + if processor != nil && processor.respond_to?(:restore) + value = processor.restore(name, value) + end + if processor == nil + if value.is_a?(Hash) + value = value.inject({}){|acc, (k, v)| + acc[Addressable::URI.unencode_component(k)] = + Addressable::URI.unencode_component(v) + acc + } + elsif value.is_a?(Array) + value = value.map{|v| Addressable::URI.unencode_component(v) } + else + value = Addressable::URI.unencode_component(value) + end + end + if !mapping.has_key?(name) || mapping[name].nil? + # Doesn't exist, set to value (even if value is nil) + mapping[name] = value + end + index = index + 1 + end + end + return Addressable::Template::MatchData.new(uri, self, mapping) + else + return nil + end + end + + ## + # Expands a URI template into another URI template. + # + # @param [Hash] mapping The mapping that corresponds to the pattern. + # @param [#validate, #transform] processor + # An optional processor object may be supplied. + # @param [Boolean] normalize_values + # Optional flag to enable/disable unicode normalization. Default: true + # + # The object should respond to either the validate or + # transform messages or both. Both the validate and + # transform methods should take two parameters: name and + # value. The validate method should return true + # or false; true if the value of the variable is valid, + # false otherwise. An InvalidTemplateValueError + # exception will be raised if the value is invalid. The transform + # method should return the transformed variable value as a String. + # If a transform method is used, the value will not be percent + # encoded automatically. Unicode normalization will be performed both + # before and after sending the value to the transform method. + # + # @return [Addressable::Template] The partially expanded URI template. + # + # @example + # Addressable::Template.new( + # "http://example.com/{one}/{two}/" + # ).partial_expand({"one" => "1"}).pattern + # #=> "http://example.com/1/{two}/" + # + # Addressable::Template.new( + # "http://example.com/{?one,two}/" + # ).partial_expand({"one" => "1"}).pattern + # #=> "http://example.com/?one=1{&two}/" + # + # Addressable::Template.new( + # "http://example.com/{?one,two,three}/" + # ).partial_expand({"one" => "1", "three" => 3}).pattern + # #=> "http://example.com/?one=1{&two}&three=3" + def partial_expand(mapping, processor=nil, normalize_values=true) + result = self.pattern.dup + mapping = normalize_keys(mapping) + result.gsub!( EXPRESSION ) do |capture| + transform_partial_capture(mapping, capture, processor, normalize_values) + end + return Addressable::Template.new(result) + end + + ## + # Expands a URI template into a full URI. + # + # @param [Hash] mapping The mapping that corresponds to the pattern. + # @param [#validate, #transform] processor + # An optional processor object may be supplied. + # @param [Boolean] normalize_values + # Optional flag to enable/disable unicode normalization. Default: true + # + # The object should respond to either the validate or + # transform messages or both. Both the validate and + # transform methods should take two parameters: name and + # value. The validate method should return true + # or false; true if the value of the variable is valid, + # false otherwise. An InvalidTemplateValueError + # exception will be raised if the value is invalid. The transform + # method should return the transformed variable value as a String. + # If a transform method is used, the value will not be percent + # encoded automatically. Unicode normalization will be performed both + # before and after sending the value to the transform method. + # + # @return [Addressable::URI] The expanded URI template. + # + # @example + # class ExampleProcessor + # def self.validate(name, value) + # return !!(value =~ /^[\w ]+$/) if name == "query" + # return true + # end + # + # def self.transform(name, value) + # return value.gsub(/ /, "+") if name == "query" + # return value + # end + # end + # + # Addressable::Template.new( + # "http://example.com/search/{query}/" + # ).expand( + # {"query" => "an example search query"}, + # ExampleProcessor + # ).to_str + # #=> "http://example.com/search/an+example+search+query/" + # + # Addressable::Template.new( + # "http://example.com/search/{query}/" + # ).expand( + # {"query" => "an example search query"} + # ).to_str + # #=> "http://example.com/search/an%20example%20search%20query/" + # + # Addressable::Template.new( + # "http://example.com/search/{query}/" + # ).expand( + # {"query" => "bogus!"}, + # ExampleProcessor + # ).to_str + # #=> Addressable::Template::InvalidTemplateValueError + def expand(mapping, processor=nil, normalize_values=true) + result = self.pattern.dup + mapping = normalize_keys(mapping) + result.gsub!( EXPRESSION ) do |capture| + transform_capture(mapping, capture, processor, normalize_values) + end + return Addressable::URI.parse(result) + end + + ## + # Returns an Array of variables used within the template pattern. + # The variables are listed in the Array in the order they appear within + # the pattern. Multiple occurrences of a variable within a pattern are + # not represented in this Array. + # + # @return [Array] The variables present in the template's pattern. + def variables + @variables ||= ordered_variable_defaults.map { |var, val| var }.uniq + end + alias_method :keys, :variables + alias_method :names, :variables + + ## + # Returns a mapping of variables to their default values specified + # in the template. Variables without defaults are not returned. + # + # @return [Hash] Mapping of template variables to their defaults + def variable_defaults + @variable_defaults ||= + Hash[*ordered_variable_defaults.reject { |k, v| v.nil? }.flatten] + end + + ## + # Coerces a template into a `Regexp` object. This regular expression will + # behave very similarly to the actual template, and should match the same + # URI values, but it cannot fully handle, for example, values that would + # extract to an `Array`. + # + # @return [Regexp] A regular expression which should match the template. + def to_regexp + _, source = parse_template_pattern(pattern) + Regexp.new(source) + end + + ## + # Returns the source of the coerced `Regexp`. + # + # @return [String] The source of the `Regexp` given by {#to_regexp}. + # + # @api private + def source + self.to_regexp.source + end + + ## + # Returns the named captures of the coerced `Regexp`. + # + # @return [Hash] The named captures of the `Regexp` given by {#to_regexp}. + # + # @api private + def named_captures + self.to_regexp.named_captures + end + + private + def ordered_variable_defaults + @ordered_variable_defaults ||= begin + expansions, _ = parse_template_pattern(pattern) + expansions.flat_map do |capture| + _, _, varlist = *capture.match(EXPRESSION) + varlist.split(',').map do |varspec| + varspec[VARSPEC, 1] + end + end + end + end + + + ## + # Loops through each capture and expands any values available in mapping + # + # @param [Hash] mapping + # Set of keys to expand + # @param [String] capture + # The expression to expand + # @param [#validate, #transform] processor + # An optional processor object may be supplied. + # @param [Boolean] normalize_values + # Optional flag to enable/disable unicode normalization. Default: true + # + # The object should respond to either the validate or + # transform messages or both. Both the validate and + # transform methods should take two parameters: name and + # value. The validate method should return true + # or false; true if the value of the variable is valid, + # false otherwise. An InvalidTemplateValueError exception + # will be raised if the value is invalid. The transform method + # should return the transformed variable value as a String. If a + # transform method is used, the value will not be percent encoded + # automatically. Unicode normalization will be performed both before and + # after sending the value to the transform method. + # + # @return [String] The expanded expression + def transform_partial_capture(mapping, capture, processor = nil, + normalize_values = true) + _, operator, varlist = *capture.match(EXPRESSION) + + vars = varlist.split(",") + + if operator == "?" + # partial expansion of form style query variables sometimes requires a + # slight reordering of the variables to produce a valid url. + first_to_expand = vars.find { |varspec| + _, name, _ = *varspec.match(VARSPEC) + mapping.key?(name) && !mapping[name].nil? + } + + vars = [first_to_expand] + vars.reject {|varspec| varspec == first_to_expand} if first_to_expand + end + + vars. + inject("".dup) do |acc, varspec| + _, name, _ = *varspec.match(VARSPEC) + next_val = if mapping.key? name + transform_capture(mapping, "{#{operator}#{varspec}}", + processor, normalize_values) + else + "{#{operator}#{varspec}}" + end + # If we've already expanded at least one '?' operator with non-empty + # value, change to '&' + operator = "&" if (operator == "?") && (next_val != "") + acc << next_val + end + end + + ## + # Transforms a mapped value so that values can be substituted into the + # template. + # + # @param [Hash] mapping The mapping to replace captures + # @param [String] capture + # The expression to replace + # @param [#validate, #transform] processor + # An optional processor object may be supplied. + # @param [Boolean] normalize_values + # Optional flag to enable/disable unicode normalization. Default: true + # + # + # The object should respond to either the validate or + # transform messages or both. Both the validate and + # transform methods should take two parameters: name and + # value. The validate method should return true + # or false; true if the value of the variable is valid, + # false otherwise. An InvalidTemplateValueError exception + # will be raised if the value is invalid. The transform method + # should return the transformed variable value as a String. If a + # transform method is used, the value will not be percent encoded + # automatically. Unicode normalization will be performed both before and + # after sending the value to the transform method. + # + # @return [String] The expanded expression + def transform_capture(mapping, capture, processor=nil, + normalize_values=true) + _, operator, varlist = *capture.match(EXPRESSION) + return_value = varlist.split(',').inject([]) do |acc, varspec| + _, name, modifier = *varspec.match(VARSPEC) + value = mapping[name] + unless value == nil || value == {} + allow_reserved = %w(+ #).include?(operator) + # Common primitives where the .to_s output is well-defined + if Numeric === value || Symbol === value || + value == true || value == false + value = value.to_s + end + length = modifier.gsub(':', '').to_i if modifier =~ /^:\d+/ + + unless (Hash === value) || + value.respond_to?(:to_ary) || value.respond_to?(:to_str) + raise TypeError, + "Can't convert #{value.class} into String or Array." + end + + value = normalize_value(value) if normalize_values + + if processor == nil || !processor.respond_to?(:transform) + # Handle percent escaping + if allow_reserved + encode_map = + Addressable::URI::CharacterClasses::RESERVED + + Addressable::URI::CharacterClasses::UNRESERVED + else + encode_map = Addressable::URI::CharacterClasses::UNRESERVED + end + if value.kind_of?(Array) + transformed_value = value.map do |val| + if length + Addressable::URI.encode_component(val[0...length], encode_map) + else + Addressable::URI.encode_component(val, encode_map) + end + end + unless modifier == "*" + transformed_value = transformed_value.join(',') + end + elsif value.kind_of?(Hash) + transformed_value = value.map do |key, val| + if modifier == "*" + "#{ + Addressable::URI.encode_component( key, encode_map) + }=#{ + Addressable::URI.encode_component( val, encode_map) + }" + else + "#{ + Addressable::URI.encode_component( key, encode_map) + },#{ + Addressable::URI.encode_component( val, encode_map) + }" + end + end + unless modifier == "*" + transformed_value = transformed_value.join(',') + end + else + if length + transformed_value = Addressable::URI.encode_component( + value[0...length], encode_map) + else + transformed_value = Addressable::URI.encode_component( + value, encode_map) + end + end + end + + # Process, if we've got a processor + if processor != nil + if processor.respond_to?(:validate) + if !processor.validate(name, value) + display_value = value.kind_of?(Array) ? value.inspect : value + raise InvalidTemplateValueError, + "#{name}=#{display_value} is an invalid template value." + end + end + if processor.respond_to?(:transform) + transformed_value = processor.transform(name, value) + if normalize_values + transformed_value = normalize_value(transformed_value) + end + end + end + acc << [name, transformed_value] + end + acc + end + return "" if return_value.empty? + join_values(operator, return_value) + end + + ## + # Takes a set of values, and joins them together based on the + # operator. + # + # @param [String, Nil] operator One of the operators from the set + # (?,&,+,#,;,/,.), or nil if there wasn't one. + # @param [Array] return_value + # The set of return values (as [variable_name, value] tuples) that will + # be joined together. + # + # @return [String] The transformed mapped value + def join_values(operator, return_value) + leader = LEADERS.fetch(operator, '') + joiner = JOINERS.fetch(operator, ',') + case operator + when '&', '?' + leader + return_value.map{|k,v| + if v.is_a?(Array) && v.first =~ /=/ + v.join(joiner) + elsif v.is_a?(Array) + v.map{|inner_value| "#{k}=#{inner_value}"}.join(joiner) + else + "#{k}=#{v}" + end + }.join(joiner) + when ';' + return_value.map{|k,v| + if v.is_a?(Array) && v.first =~ /=/ + ';' + v.join(";") + elsif v.is_a?(Array) + ';' + v.map{|inner_value| "#{k}=#{inner_value}"}.join(";") + else + v && v != '' ? ";#{k}=#{v}" : ";#{k}" + end + }.join + else + leader + return_value.map{|k,v| v}.join(joiner) + end + end + + ## + # Takes a set of values, and joins them together based on the + # operator. + # + # @param [Hash, Array, String] value + # Normalizes unicode keys and values with String#unicode_normalize (NFC) + # + # @return [Hash, Array, String] The normalized values + def normalize_value(value) + # Handle unicode normalization + if value.respond_to?(:to_ary) + value.to_ary.map! { |val| normalize_value(val) } + elsif value.kind_of?(Hash) + value = value.inject({}) { |acc, (k, v)| + acc[normalize_value(k)] = normalize_value(v) + acc + } + else + value = value.to_s if !value.kind_of?(String) + if value.encoding != Encoding::UTF_8 + value = value.dup.force_encoding(Encoding::UTF_8) + end + value = value.unicode_normalize(:nfc) + end + value + end + + ## + # Generates a hash with string keys + # + # @param [Hash] mapping A mapping hash to normalize + # + # @return [Hash] + # A hash with stringified keys + def normalize_keys(mapping) + return mapping.inject({}) do |accu, pair| + name, value = pair + if Symbol === name + name = name.to_s + elsif name.respond_to?(:to_str) + name = name.to_str + else + raise TypeError, + "Can't convert #{name.class} into String." + end + accu[name] = value + accu + end + end + + ## + # Generates the Regexp that parses a template pattern. Memoizes the + # value if template processor not set (processors may not be deterministic) + # + # @param [String] pattern The URI template pattern. + # @param [#match] processor The template processor to use. + # + # @return [Array, Regexp] + # An array of expansion variables nad a regular expression which may be + # used to parse a template pattern + def parse_template_pattern(pattern, processor = nil) + if processor.nil? && pattern == @pattern + @cached_template_parse ||= + parse_new_template_pattern(pattern, processor) + else + parse_new_template_pattern(pattern, processor) + end + end + + ## + # Generates the Regexp that parses a template pattern. + # + # @param [String] pattern The URI template pattern. + # @param [#match] processor The template processor to use. + # + # @return [Array, Regexp] + # An array of expansion variables nad a regular expression which may be + # used to parse a template pattern + def parse_new_template_pattern(pattern, processor = nil) + # Escape the pattern. The two gsubs restore the escaped curly braces + # back to their original form. Basically, escape everything that isn't + # within an expansion. + escaped_pattern = Regexp.escape( + pattern + ).gsub(/\\\{(.*?)\\\}/) do |escaped| + escaped.gsub(/\\(.)/, "\\1") + end + + expansions = [] + + # Create a regular expression that captures the values of the + # variables in the URI. + regexp_string = escaped_pattern.gsub( EXPRESSION ) do |expansion| + + expansions << expansion + _, operator, varlist = *expansion.match(EXPRESSION) + leader = Regexp.escape(LEADERS.fetch(operator, '')) + joiner = Regexp.escape(JOINERS.fetch(operator, ',')) + combined = varlist.split(',').map do |varspec| + _, name, modifier = *varspec.match(VARSPEC) + + result = processor && processor.respond_to?(:match) ? processor.match(name) : nil + if result + "(?<#{name}>#{ result })" + else + group = case operator + when '+' + "#{ RESERVED }*?" + when '#' + "#{ RESERVED }*?" + when '/' + "#{ UNRESERVED }*?" + when '.' + "#{ UNRESERVED.gsub('\.', '') }*?" + when ';' + "#{ UNRESERVED }*=?#{ UNRESERVED }*?" + when '?' + "#{ UNRESERVED }*=#{ UNRESERVED }*?" + when '&' + "#{ UNRESERVED }*=#{ UNRESERVED }*?" + else + "#{ UNRESERVED }*?" + end + if modifier == '*' + "(?<#{name}>#{group}(?:#{joiner}?#{group})*)?" + else + "(?<#{name}>#{group})?" + end + end + end.join("#{joiner}?") + "(?:|#{leader}#{combined})" + end + + # Ensure that the regular expression matches the whole URI. + regexp_string = "\\A#{regexp_string}\\z" + return expansions, Regexp.new(regexp_string) + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/uri.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/uri.rb new file mode 100644 index 0000000..40b80cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/uri.rb @@ -0,0 +1,2602 @@ +# frozen_string_literal: true + +#-- +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#++ + + +require "addressable/version" +require "addressable/idna" +require "public_suffix" + +## +# Addressable is a library for processing links and URIs. +module Addressable + ## + # This is an implementation of a URI parser based on + # RFC 3986, + # RFC 3987. + class URI + ## + # Raised if something other than a uri is supplied. + class InvalidURIError < StandardError + end + + ## + # Container for the character classes specified in + # RFC 3986. + # + # Note: Concatenated and interpolated `String`s are not affected by the + # `frozen_string_literal` directive and must be frozen explicitly. + # + # Interpolated `String`s *were* frozen this way before Ruby 3.0: + # https://bugs.ruby-lang.org/issues/17104 + module CharacterClasses + ALPHA = "a-zA-Z" + DIGIT = "0-9" + GEN_DELIMS = "\\:\\/\\?\\#\\[\\]\\@" + SUB_DELIMS = "\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=" + RESERVED = (GEN_DELIMS + SUB_DELIMS).freeze + UNRESERVED = (ALPHA + DIGIT + "\\-\\.\\_\\~").freeze + RESERVED_AND_UNRESERVED = RESERVED + UNRESERVED + PCHAR = (UNRESERVED + SUB_DELIMS + "\\:\\@").freeze + SCHEME = (ALPHA + DIGIT + "\\-\\+\\.").freeze + HOST = (UNRESERVED + SUB_DELIMS + "\\[\\:\\]").freeze + AUTHORITY = (PCHAR + "\\[\\]").freeze + PATH = (PCHAR + "\\/").freeze + QUERY = (PCHAR + "\\/\\?").freeze + FRAGMENT = (PCHAR + "\\/\\?").freeze + end + + module NormalizeCharacterClasses + HOST = /[^#{CharacterClasses::HOST}]/ + UNRESERVED = /[^#{CharacterClasses::UNRESERVED}]/ + PCHAR = /[^#{CharacterClasses::PCHAR}]/ + SCHEME = /[^#{CharacterClasses::SCHEME}]/ + FRAGMENT = /[^#{CharacterClasses::FRAGMENT}]/ + QUERY = %r{[^a-zA-Z0-9\-\.\_\~\!\$\'\(\)\*\+\,\=\:\@\/\?%]|%(?!2B|2b)} + end + + module CharacterClassesRegexps + AUTHORITY = /[^#{CharacterClasses::AUTHORITY}]/ + FRAGMENT = /[^#{CharacterClasses::FRAGMENT}]/ + HOST = /[^#{CharacterClasses::HOST}]/ + PATH = /[^#{CharacterClasses::PATH}]/ + QUERY = /[^#{CharacterClasses::QUERY}]/ + RESERVED = /[^#{CharacterClasses::RESERVED}]/ + RESERVED_AND_UNRESERVED = /[^#{CharacterClasses::RESERVED_AND_UNRESERVED}]/ + SCHEME = /[^#{CharacterClasses::SCHEME}]/ + UNRESERVED = /[^#{CharacterClasses::UNRESERVED}]/ + end + + SLASH = '/' + EMPTY_STR = '' + + URIREGEX = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/ + + PORT_MAPPING = { + "http" => 80, + "https" => 443, + "ftp" => 21, + "tftp" => 69, + "sftp" => 22, + "ssh" => 22, + "svn+ssh" => 22, + "telnet" => 23, + "nntp" => 119, + "gopher" => 70, + "wais" => 210, + "ldap" => 389, + "prospero" => 1525 + }.freeze + + ## + # Returns a URI object based on the parsed string. + # + # @param [String, Addressable::URI, #to_str] uri + # The URI string to parse. + # No parsing is performed if the object is already an + # Addressable::URI. + # + # @return [Addressable::URI] The parsed URI. + def self.parse(uri) + # If we were given nil, return nil. + return nil unless uri + # If a URI object is passed, just return itself. + return uri.dup if uri.kind_of?(self) + + # If a URI object of the Ruby standard library variety is passed, + # convert it to a string, then parse the string. + # We do the check this way because we don't want to accidentally + # cause a missing constant exception to be thrown. + if uri.class.name =~ /^URI\b/ + uri = uri.to_s + end + + # Otherwise, convert to a String + begin + uri = uri.to_str + rescue TypeError, NoMethodError + raise TypeError, "Can't convert #{uri.class} into String." + end unless uri.is_a?(String) + + # This Regexp supplied as an example in RFC 3986, and it works great. + scan = uri.scan(URIREGEX) + fragments = scan[0] + scheme = fragments[1] + authority = fragments[3] + path = fragments[4] + query = fragments[6] + fragment = fragments[8] + user = nil + password = nil + host = nil + port = nil + if authority != nil + # The Regexp above doesn't split apart the authority. + userinfo = authority[/^([^\[\]]*)@/, 1] + if userinfo != nil + user = userinfo.strip[/^([^:]*):?/, 1] + password = userinfo.strip[/:(.*)$/, 1] + end + + host = authority.sub( + /^([^\[\]]*)@/, EMPTY_STR + ).sub( + /:([^:@\[\]]*?)$/, EMPTY_STR + ) + + port = authority[/:([^:@\[\]]*?)$/, 1] + port = nil if port == EMPTY_STR + end + + return new( + :scheme => scheme, + :user => user, + :password => password, + :host => host, + :port => port, + :path => path, + :query => query, + :fragment => fragment + ) + end + + ## + # Converts an input to a URI. The input does not have to be a valid + # URI — the method will use heuristics to guess what URI was intended. + # This is not standards-compliant, merely user-friendly. + # + # @param [String, Addressable::URI, #to_str] uri + # The URI string to parse. + # No parsing is performed if the object is already an + # Addressable::URI. + # @param [Hash] hints + # A Hash of hints to the heuristic parser. + # Defaults to {:scheme => "http"}. + # + # @return [Addressable::URI] The parsed URI. + def self.heuristic_parse(uri, hints={}) + # If we were given nil, return nil. + return nil unless uri + # If a URI object is passed, just return itself. + return uri.dup if uri.kind_of?(self) + + # If a URI object of the Ruby standard library variety is passed, + # convert it to a string, then parse the string. + # We do the check this way because we don't want to accidentally + # cause a missing constant exception to be thrown. + if uri.class.name =~ /^URI\b/ + uri = uri.to_s + end + + unless uri.respond_to?(:to_str) + raise TypeError, "Can't convert #{uri.class} into String." + end + # Otherwise, convert to a String + uri = uri.to_str.dup.strip + hints = { + :scheme => "http" + }.merge(hints) + case uri + when /^http:\//i + uri.sub!(/^http:\/+/i, "http://") + when /^https:\//i + uri.sub!(/^https:\/+/i, "https://") + when /^feed:\/+http:\//i + uri.sub!(/^feed:\/+http:\/+/i, "feed:http://") + when /^feed:\//i + uri.sub!(/^feed:\/+/i, "feed://") + when %r[^file:/{4}]i + uri.sub!(%r[^file:/+]i, "file:////") + when %r[^file://localhost/]i + uri.sub!(%r[^file://localhost/+]i, "file:///") + when %r[^file:/+]i + uri.sub!(%r[^file:/+]i, "file:///") + when /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ + uri.sub!(/^/, hints[:scheme] + "://") + when /\A\d+\..*:\d+\z/ + uri = "#{hints[:scheme]}://#{uri}" + end + match = uri.match(URIREGEX) + fragments = match.captures + authority = fragments[3] + if authority && authority.length > 0 + new_authority = authority.tr("\\", "/").gsub(" ", "%20") + # NOTE: We want offset 4, not 3! + offset = match.offset(4) + uri = uri.dup + uri[offset[0]...offset[1]] = new_authority + end + parsed = self.parse(uri) + if parsed.scheme =~ /^[^\/?#\.]+\.[^\/?#]+$/ + parsed = self.parse(hints[:scheme] + "://" + uri) + end + if parsed.path.include?(".") + if parsed.path[/\b@\b/] + parsed.scheme = "mailto" unless parsed.scheme + elsif new_host = parsed.path[/^([^\/]+\.[^\/]*)/, 1] + parsed.defer_validation do + new_path = parsed.path.sub( + Regexp.new("^" + Regexp.escape(new_host)), EMPTY_STR) + parsed.host = new_host + parsed.path = new_path + parsed.scheme = hints[:scheme] unless parsed.scheme + end + end + end + return parsed + end + + ## + # Converts a path to a file scheme URI. If the path supplied is + # relative, it will be returned as a relative URI. If the path supplied + # is actually a non-file URI, it will parse the URI as if it had been + # parsed with Addressable::URI.parse. Handles all of the + # various Microsoft-specific formats for specifying paths. + # + # @param [String, Addressable::URI, #to_str] path + # Typically a String path to a file or directory, but + # will return a sensible return value if an absolute URI is supplied + # instead. + # + # @return [Addressable::URI] + # The parsed file scheme URI or the original URI if some other URI + # scheme was provided. + # + # @example + # base = Addressable::URI.convert_path("/absolute/path/") + # uri = Addressable::URI.convert_path("relative/path") + # (base + uri).to_s + # #=> "file:///absolute/path/relative/path" + # + # Addressable::URI.convert_path( + # "c:\\windows\\My Documents 100%20\\foo.txt" + # ).to_s + # #=> "file:///c:/windows/My%20Documents%20100%20/foo.txt" + # + # Addressable::URI.convert_path("http://example.com/").to_s + # #=> "http://example.com/" + def self.convert_path(path) + # If we were given nil, return nil. + return nil unless path + # If a URI object is passed, just return itself. + return path if path.kind_of?(self) + unless path.respond_to?(:to_str) + raise TypeError, "Can't convert #{path.class} into String." + end + # Otherwise, convert to a String + path = path.to_str.strip + + path.sub!(/^file:\/?\/?/, EMPTY_STR) if path =~ /^file:\/?\/?/ + path = SLASH + path if path =~ /^([a-zA-Z])[\|:]/ + uri = self.parse(path) + + if uri.scheme == nil + # Adjust windows-style uris + uri.path.sub!(/^\/?([a-zA-Z])[\|:][\\\/]/) do + "/#{$1.downcase}:/" + end + uri.path.tr!("\\", SLASH) + if File.exist?(uri.path) && + File.stat(uri.path).directory? + uri.path.chomp!(SLASH) + uri.path = uri.path + '/' + end + + # If the path is absolute, set the scheme and host. + if uri.path.start_with?(SLASH) + uri.scheme = "file" + uri.host = EMPTY_STR + end + uri.normalize! + end + + return uri + end + + ## + # Joins several URIs together. + # + # @param [String, Addressable::URI, #to_str] *uris + # The URIs to join. + # + # @return [Addressable::URI] The joined URI. + # + # @example + # base = "http://example.com/" + # uri = Addressable::URI.parse("relative/path") + # Addressable::URI.join(base, uri) + # #=> # + def self.join(*uris) + uri_objects = uris.collect do |uri| + unless uri.respond_to?(:to_str) + raise TypeError, "Can't convert #{uri.class} into String." + end + uri.kind_of?(self) ? uri : self.parse(uri.to_str) + end + result = uri_objects.shift.dup + uri_objects.each do |uri| + result.join!(uri) + end + return result + end + + ## + # Tables used to optimize encoding operations in `self.encode_component` + # and `self.normalize_component` + SEQUENCE_ENCODING_TABLE = (0..255).map do |byte| + format("%02x", byte).freeze + end.freeze + + SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE = (0..255).map do |byte| + format("%%%02X", byte).freeze + end.freeze + + ## + # Percent encodes a URI component. + # + # @param [String, #to_str] component The URI component to encode. + # + # @param [String, Regexp] character_class + # The characters which are not percent encoded. If a String + # is passed, the String must be formatted as a regular + # expression character class. (Do not include the surrounding square + # brackets.) For example, "b-zB-Z0-9" would cause + # everything but the letters 'b' through 'z' and the numbers '0' through + # '9' to be percent encoded. If a Regexp is passed, the + # value /[^b-zB-Z0-9]/ would have the same effect. A set of + # useful String values may be found in the + # Addressable::URI::CharacterClasses module. The default + # value is the reserved plus unreserved character classes specified in + # RFC 3986. + # + # @param [Regexp] upcase_encoded + # A string of characters that may already be percent encoded, and whose + # encodings should be upcased. This allows normalization of percent + # encodings for characters not included in the + # character_class. + # + # @return [String] The encoded component. + # + # @example + # Addressable::URI.encode_component("simple/example", "b-zB-Z0-9") + # => "simple%2Fex%61mple" + # Addressable::URI.encode_component("simple/example", /[^b-zB-Z0-9]/) + # => "simple%2Fex%61mple" + # Addressable::URI.encode_component( + # "simple/example", Addressable::URI::CharacterClasses::UNRESERVED + # ) + # => "simple%2Fexample" + def self.encode_component(component, character_class=CharacterClassesRegexps::RESERVED_AND_UNRESERVED, upcase_encoded='') + return nil if component.nil? + + begin + if component.kind_of?(Symbol) || + component.kind_of?(Numeric) || + component.kind_of?(TrueClass) || + component.kind_of?(FalseClass) + component = component.to_s + else + component = component.to_str + end + rescue TypeError, NoMethodError + raise TypeError, "Can't convert #{component.class} into String." + end if !component.is_a? String + + if ![String, Regexp].include?(character_class.class) + raise TypeError, + "Expected String or Regexp, got #{character_class.inspect}" + end + if character_class.kind_of?(String) + character_class = /[^#{character_class}]/ + end + # We can't perform regexps on invalid UTF sequences, but + # here we need to, so switch to ASCII. + component = component.dup + component.force_encoding(Encoding::ASCII_8BIT) + # Avoiding gsub! because there are edge cases with frozen strings + component = component.gsub(character_class) do |char| + SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE[char.ord] + end + if upcase_encoded.length > 0 + upcase_encoded_chars = upcase_encoded.bytes.map do |byte| + SEQUENCE_ENCODING_TABLE[byte] + end + component = component.gsub(/%(#{upcase_encoded_chars.join('|')})/, + &:upcase) + end + + return component + end + + class << self + alias_method :escape_component, :encode_component + end + + ## + # Unencodes any percent encoded characters within a URI component. + # This method may be used for unencoding either components or full URIs, + # however, it is recommended to use the unencode_component + # alias when unencoding components. + # + # @param [String, Addressable::URI, #to_str] uri + # The URI or component to unencode. + # + # @param [Class] return_type + # The type of object to return. + # This value may only be set to String or + # Addressable::URI. All other values are invalid. Defaults + # to String. + # + # @param [String] leave_encoded + # A string of characters to leave encoded. If a percent encoded character + # in this list is encountered then it will remain percent encoded. + # + # @return [String, Addressable::URI] + # The unencoded component or URI. + # The return type is determined by the return_type + # parameter. + def self.unencode(uri, return_type=String, leave_encoded='') + return nil if uri.nil? + + begin + uri = uri.to_str + rescue NoMethodError, TypeError + raise TypeError, "Can't convert #{uri.class} into String." + end if !uri.is_a? String + if ![String, ::Addressable::URI].include?(return_type) + raise TypeError, + "Expected Class (String or Addressable::URI), " + + "got #{return_type.inspect}" + end + + result = uri.gsub(/%[0-9a-f]{2}/i) do |sequence| + c = sequence[1..3].to_i(16).chr + c.force_encoding(sequence.encoding) + leave_encoded.include?(c) ? sequence : c + end + + result.force_encoding(Encoding::UTF_8) + if return_type == String + return result + elsif return_type == ::Addressable::URI + return ::Addressable::URI.parse(result) + end + end + + class << self + alias_method :unescape, :unencode + alias_method :unencode_component, :unencode + alias_method :unescape_component, :unencode + end + + + ## + # Normalizes the encoding of a URI component. + # + # @param [String, #to_str] component The URI component to encode. + # + # @param [String, Regexp] character_class + # The characters which are not percent encoded. If a String + # is passed, the String must be formatted as a regular + # expression character class. (Do not include the surrounding square + # brackets.) For example, "b-zB-Z0-9" would cause + # everything but the letters 'b' through 'z' and the numbers '0' + # through '9' to be percent encoded. If a Regexp is passed, + # the value /[^b-zB-Z0-9]/ would have the same effect. A + # set of useful String values may be found in the + # Addressable::URI::CharacterClasses module. The default + # value is the reserved plus unreserved character classes specified in + # RFC 3986. + # + # @param [String] leave_encoded + # When character_class is a String then + # leave_encoded is a string of characters that should remain + # percent encoded while normalizing the component; if they appear percent + # encoded in the original component, then they will be upcased ("%2f" + # normalized to "%2F") but otherwise left alone. + # + # @return [String] The normalized component. + # + # @example + # Addressable::URI.normalize_component("simpl%65/%65xampl%65", "b-zB-Z") + # => "simple%2Fex%61mple" + # Addressable::URI.normalize_component( + # "simpl%65/%65xampl%65", /[^b-zB-Z]/ + # ) + # => "simple%2Fex%61mple" + # Addressable::URI.normalize_component( + # "simpl%65/%65xampl%65", + # Addressable::URI::CharacterClasses::UNRESERVED + # ) + # => "simple%2Fexample" + # Addressable::URI.normalize_component( + # "one%20two%2fthree%26four", + # "0-9a-zA-Z &/", + # "/" + # ) + # => "one two%2Fthree&four" + def self.normalize_component(component, character_class= + CharacterClassesRegexps::RESERVED_AND_UNRESERVED, + leave_encoded='') + return nil if component.nil? + + begin + component = component.to_str + rescue NoMethodError, TypeError + raise TypeError, "Can't convert #{component.class} into String." + end if !component.is_a? String + + if ![String, Regexp].include?(character_class.class) + raise TypeError, + "Expected String or Regexp, got #{character_class.inspect}" + end + if character_class.kind_of?(String) + leave_re = if leave_encoded.length > 0 + character_class = "#{character_class}%" unless character_class.include?('%') + + bytes = leave_encoded.bytes + leave_encoded_pattern = bytes.map { |b| SEQUENCE_ENCODING_TABLE[b] }.join('|') + "|%(?!#{leave_encoded_pattern}|#{leave_encoded_pattern.upcase})" + end + + character_class = if leave_re + /[^#{character_class}]#{leave_re}/ + else + /[^#{character_class}]/ + end + end + # We can't perform regexps on invalid UTF sequences, but + # here we need to, so switch to ASCII. + component = component.dup + component.force_encoding(Encoding::ASCII_8BIT) + unencoded = self.unencode_component(component, String, leave_encoded) + begin + encoded = self.encode_component( + unencoded.unicode_normalize(:nfc), + character_class, + leave_encoded + ) + rescue ArgumentError + encoded = self.encode_component(unencoded) + end + encoded.force_encoding(Encoding::UTF_8) + return encoded + end + + ## + # Percent encodes any special characters in the URI. + # + # @param [String, Addressable::URI, #to_str] uri + # The URI to encode. + # + # @param [Class] return_type + # The type of object to return. + # This value may only be set to String or + # Addressable::URI. All other values are invalid. Defaults + # to String. + # + # @return [String, Addressable::URI] + # The encoded URI. + # The return type is determined by the return_type + # parameter. + def self.encode(uri, return_type=String) + return nil if uri.nil? + + begin + uri = uri.to_str + rescue NoMethodError, TypeError + raise TypeError, "Can't convert #{uri.class} into String." + end if !uri.is_a? String + + if ![String, ::Addressable::URI].include?(return_type) + raise TypeError, + "Expected Class (String or Addressable::URI), " + + "got #{return_type.inspect}" + end + uri_object = uri.kind_of?(self) ? uri : self.parse(uri) + encoded_uri = Addressable::URI.new( + :scheme => self.encode_component(uri_object.scheme, + Addressable::URI::CharacterClassesRegexps::SCHEME), + :authority => self.encode_component(uri_object.authority, + Addressable::URI::CharacterClassesRegexps::AUTHORITY), + :path => self.encode_component(uri_object.path, + Addressable::URI::CharacterClassesRegexps::PATH), + :query => self.encode_component(uri_object.query, + Addressable::URI::CharacterClassesRegexps::QUERY), + :fragment => self.encode_component(uri_object.fragment, + Addressable::URI::CharacterClassesRegexps::FRAGMENT) + ) + if return_type == String + return encoded_uri.to_s + elsif return_type == ::Addressable::URI + return encoded_uri + end + end + + class << self + alias_method :escape, :encode + end + + ## + # Normalizes the encoding of a URI. Characters within a hostname are + # not percent encoded to allow for internationalized domain names. + # + # @param [String, Addressable::URI, #to_str] uri + # The URI to encode. + # + # @param [Class] return_type + # The type of object to return. + # This value may only be set to String or + # Addressable::URI. All other values are invalid. Defaults + # to String. + # + # @return [String, Addressable::URI] + # The encoded URI. + # The return type is determined by the return_type + # parameter. + def self.normalized_encode(uri, return_type=String) + begin + uri = uri.to_str + rescue NoMethodError, TypeError + raise TypeError, "Can't convert #{uri.class} into String." + end if !uri.is_a? String + + if ![String, ::Addressable::URI].include?(return_type) + raise TypeError, + "Expected Class (String or Addressable::URI), " + + "got #{return_type.inspect}" + end + uri_object = uri.kind_of?(self) ? uri : self.parse(uri) + components = { + :scheme => self.unencode_component(uri_object.scheme), + :user => self.unencode_component(uri_object.user), + :password => self.unencode_component(uri_object.password), + :host => self.unencode_component(uri_object.host), + :port => (uri_object.port.nil? ? nil : uri_object.port.to_s), + :path => self.unencode_component(uri_object.path), + :query => self.unencode_component(uri_object.query), + :fragment => self.unencode_component(uri_object.fragment) + } + components.each do |key, value| + if value != nil + begin + components[key] = value.to_str.unicode_normalize(:nfc) + rescue ArgumentError + # Likely a malformed UTF-8 character, skip unicode normalization + components[key] = value.to_str + end + end + end + encoded_uri = Addressable::URI.new( + :scheme => self.encode_component(components[:scheme], + Addressable::URI::CharacterClassesRegexps::SCHEME), + :user => self.encode_component(components[:user], + Addressable::URI::CharacterClassesRegexps::UNRESERVED), + :password => self.encode_component(components[:password], + Addressable::URI::CharacterClassesRegexps::UNRESERVED), + :host => components[:host], + :port => components[:port], + :path => self.encode_component(components[:path], + Addressable::URI::CharacterClassesRegexps::PATH), + :query => self.encode_component(components[:query], + Addressable::URI::CharacterClassesRegexps::QUERY), + :fragment => self.encode_component(components[:fragment], + Addressable::URI::CharacterClassesRegexps::FRAGMENT) + ) + if return_type == String + return encoded_uri.to_s + elsif return_type == ::Addressable::URI + return encoded_uri + end + end + + ## + # Encodes a set of key/value pairs according to the rules for the + # application/x-www-form-urlencoded MIME type. + # + # @param [#to_hash, #to_ary] form_values + # The form values to encode. + # + # @param [TrueClass, FalseClass] sort + # Sort the key/value pairs prior to encoding. + # Defaults to false. + # + # @return [String] + # The encoded value. + def self.form_encode(form_values, sort=false) + if form_values.respond_to?(:to_hash) + form_values = form_values.to_hash.to_a + elsif form_values.respond_to?(:to_ary) + form_values = form_values.to_ary + else + raise TypeError, "Can't convert #{form_values.class} into Array." + end + + form_values = form_values.inject([]) do |accu, (key, value)| + if value.kind_of?(Array) + value.each do |v| + accu << [key.to_s, v.to_s] + end + else + accu << [key.to_s, value.to_s] + end + accu + end + + if sort + # Useful for OAuth and optimizing caching systems + form_values = form_values.sort + end + escaped_form_values = form_values.map do |(key, value)| + # Line breaks are CRLF pairs + [ + self.encode_component( + key.gsub(/(\r\n|\n|\r)/, "\r\n"), + CharacterClassesRegexps::UNRESERVED + ).gsub("%20", "+"), + self.encode_component( + value.gsub(/(\r\n|\n|\r)/, "\r\n"), + CharacterClassesRegexps::UNRESERVED + ).gsub("%20", "+") + ] + end + return escaped_form_values.map do |(key, value)| + "#{key}=#{value}" + end.join("&") + end + + ## + # Decodes a String according to the rules for the + # application/x-www-form-urlencoded MIME type. + # + # @param [String, #to_str] encoded_value + # The form values to decode. + # + # @return [Array] + # The decoded values. + # This is not a Hash because of the possibility for + # duplicate keys. + def self.form_unencode(encoded_value) + if !encoded_value.respond_to?(:to_str) + raise TypeError, "Can't convert #{encoded_value.class} into String." + end + encoded_value = encoded_value.to_str + split_values = encoded_value.split("&").map do |pair| + pair.split("=", 2) + end + return split_values.map do |(key, value)| + [ + key ? self.unencode_component( + key.gsub("+", "%20")).gsub(/(\r\n|\n|\r)/, "\n") : nil, + value ? (self.unencode_component( + value.gsub("+", "%20")).gsub(/(\r\n|\n|\r)/, "\n")) : nil + ] + end + end + + ## + # Creates a new uri object from component parts. + # + # @option [String, #to_str] scheme The scheme component. + # @option [String, #to_str] user The user component. + # @option [String, #to_str] password The password component. + # @option [String, #to_str] userinfo + # The userinfo component. If this is supplied, the user and password + # components must be omitted. + # @option [String, #to_str] host The host component. + # @option [String, #to_str] port The port component. + # @option [String, #to_str] authority + # The authority component. If this is supplied, the user, password, + # userinfo, host, and port components must be omitted. + # @option [String, #to_str] path The path component. + # @option [String, #to_str] query The query component. + # @option [String, #to_str] fragment The fragment component. + # + # @return [Addressable::URI] The constructed URI object. + def initialize(options={}) + if options.has_key?(:authority) + if (options.keys & [:userinfo, :user, :password, :host, :port]).any? + raise ArgumentError, + "Cannot specify both an authority and any of the components " + + "within the authority." + end + end + if options.has_key?(:userinfo) + if (options.keys & [:user, :password]).any? + raise ArgumentError, + "Cannot specify both a userinfo and either the user or password." + end + end + + reset_ivs + + defer_validation do + # Bunch of crazy logic required because of the composite components + # like userinfo and authority. + self.scheme = options[:scheme] if options[:scheme] + self.user = options[:user] if options[:user] + self.password = options[:password] if options[:password] + self.userinfo = options[:userinfo] if options[:userinfo] + self.host = options[:host] if options[:host] + self.port = options[:port] if options[:port] + self.authority = options[:authority] if options[:authority] + self.path = options[:path] if options[:path] + self.query = options[:query] if options[:query] + self.query_values = options[:query_values] if options[:query_values] + self.fragment = options[:fragment] if options[:fragment] + end + + to_s # force path validation + end + + ## + # Freeze URI, initializing instance variables. + # + # @return [Addressable::URI] The frozen URI object. + def freeze + self.normalized_scheme + self.normalized_user + self.normalized_password + self.normalized_userinfo + self.normalized_host + self.normalized_port + self.normalized_authority + self.normalized_site + self.normalized_path + self.normalized_query + self.normalized_fragment + self.hash + super + end + + ## + # The scheme component for this URI. + # + # @return [String] The scheme component. + attr_reader :scheme + + ## + # The scheme component for this URI, normalized. + # + # @return [String] The scheme component, normalized. + def normalized_scheme + return nil unless self.scheme + if @normalized_scheme == NONE + @normalized_scheme = if self.scheme =~ /^\s*ssh\+svn\s*$/i + "svn+ssh".dup + else + Addressable::URI.normalize_component( + self.scheme.strip.downcase, + Addressable::URI::NormalizeCharacterClasses::SCHEME + ) + end + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_scheme) + @normalized_scheme + end + + ## + # Sets the scheme component for this URI. + # + # @param [String, #to_str] new_scheme The new scheme component. + def scheme=(new_scheme) + if new_scheme && !new_scheme.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_scheme.class} into String." + elsif new_scheme + new_scheme = new_scheme.to_str + end + if new_scheme && new_scheme !~ /\A[a-z][a-z0-9\.\+\-]*\z/i + raise InvalidURIError, "Invalid scheme format: '#{new_scheme}'" + end + @scheme = new_scheme + @scheme = nil if @scheme.to_s.strip.empty? + + # Reset dependent values + @normalized_scheme = NONE + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # The user component for this URI. + # + # @return [String] The user component. + attr_reader :user + + ## + # The user component for this URI, normalized. + # + # @return [String] The user component, normalized. + def normalized_user + return nil unless self.user + return @normalized_user unless @normalized_user == NONE + @normalized_user = begin + if normalized_scheme =~ /https?/ && self.user.strip.empty? && + (!self.password || self.password.strip.empty?) + nil + else + Addressable::URI.normalize_component( + self.user.strip, + Addressable::URI::NormalizeCharacterClasses::UNRESERVED + ) + end + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_user) + @normalized_user + end + + ## + # Sets the user component for this URI. + # + # @param [String, #to_str] new_user The new user component. + def user=(new_user) + if new_user && !new_user.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_user.class} into String." + end + @user = new_user ? new_user.to_str : nil + + # You can't have a nil user with a non-nil password + if password != nil + @user = EMPTY_STR unless user + end + + # Reset dependent values + @userinfo = nil + @normalized_userinfo = NONE + @authority = nil + @normalized_user = NONE + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # The password component for this URI. + # + # @return [String] The password component. + attr_reader :password + + ## + # The password component for this URI, normalized. + # + # @return [String] The password component, normalized. + def normalized_password + return nil unless self.password + return @normalized_password unless @normalized_password == NONE + @normalized_password = begin + if self.normalized_scheme =~ /https?/ && self.password.strip.empty? && + (!self.user || self.user.strip.empty?) + nil + else + Addressable::URI.normalize_component( + self.password.strip, + Addressable::URI::NormalizeCharacterClasses::UNRESERVED + ) + end + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_password) + @normalized_password + end + + ## + # Sets the password component for this URI. + # + # @param [String, #to_str] new_password The new password component. + def password=(new_password) + if new_password && !new_password.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_password.class} into String." + end + @password = new_password ? new_password.to_str : nil + + # You can't have a nil user with a non-nil password + if @password != nil + self.user = EMPTY_STR if user.nil? + end + + # Reset dependent values + @userinfo = nil + @normalized_userinfo = NONE + @authority = nil + @normalized_password = NONE + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # The userinfo component for this URI. + # Combines the user and password components. + # + # @return [String] The userinfo component. + def userinfo + current_user = self.user + current_password = self.password + (current_user || current_password) && @userinfo ||= begin + if current_user && current_password + "#{current_user}:#{current_password}" + elsif current_user && !current_password + "#{current_user}" + end + end + end + + ## + # The userinfo component for this URI, normalized. + # + # @return [String] The userinfo component, normalized. + def normalized_userinfo + return nil unless self.userinfo + return @normalized_userinfo unless @normalized_userinfo == NONE + @normalized_userinfo = begin + current_user = self.normalized_user + current_password = self.normalized_password + if !current_user && !current_password + nil + elsif current_user && current_password + "#{current_user}:#{current_password}".dup + elsif current_user && !current_password + "#{current_user}".dup + end + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_userinfo) + @normalized_userinfo + end + + ## + # Sets the userinfo component for this URI. + # + # @param [String, #to_str] new_userinfo The new userinfo component. + def userinfo=(new_userinfo) + if new_userinfo && !new_userinfo.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_userinfo.class} into String." + end + new_user, new_password = if new_userinfo + [ + new_userinfo.to_str.strip[/^(.*):/, 1], + new_userinfo.to_str.strip[/:(.*)$/, 1] + ] + else + [nil, nil] + end + + # Password assigned first to ensure validity in case of nil + self.password = new_password + self.user = new_user + + # Reset dependent values + @authority = nil + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # The host component for this URI. + # + # @return [String] The host component. + attr_reader :host + + ## + # The host component for this URI, normalized. + # + # @return [String] The host component, normalized. + def normalized_host + return nil unless self.host + + @normalized_host ||= begin + if !self.host.strip.empty? + result = ::Addressable::IDNA.to_ascii( + URI.unencode_component(self.host.strip.downcase) + ) + if result =~ /[^\.]\.$/ + # Single trailing dots are unnecessary. + result = result[0...-1] + end + result = Addressable::URI.normalize_component( + result, + NormalizeCharacterClasses::HOST + ) + result + else + EMPTY_STR.dup + end + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_host) + @normalized_host + end + + ## + # Sets the host component for this URI. + # + # @param [String, #to_str] new_host The new host component. + def host=(new_host) + if new_host && !new_host.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_host.class} into String." + end + @host = new_host ? new_host.to_str : nil + + # Reset dependent values + @authority = nil + @normalized_host = nil + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # This method is same as URI::Generic#host except + # brackets for IPv6 (and 'IPvFuture') addresses are removed. + # + # @see Addressable::URI#host + # + # @return [String] The hostname for this URI. + def hostname + v = self.host + /\A\[(.*)\]\z/ =~ v ? $1 : v + end + + ## + # This method is same as URI::Generic#host= except + # the argument can be a bare IPv6 address (or 'IPvFuture'). + # + # @see Addressable::URI#host= + # + # @param [String, #to_str] new_hostname The new hostname for this URI. + def hostname=(new_hostname) + if new_hostname && + (new_hostname.respond_to?(:ipv4?) || new_hostname.respond_to?(:ipv6?)) + new_hostname = new_hostname.to_s + elsif new_hostname && !new_hostname.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_hostname.class} into String." + end + v = new_hostname ? new_hostname.to_str : nil + v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v + self.host = v + end + + ## + # Returns the top-level domain for this host. + # + # @example + # Addressable::URI.parse("http://www.example.co.uk").tld # => "co.uk" + def tld + PublicSuffix.parse(self.host, ignore_private: true).tld + end + + ## + # Sets the top-level domain for this URI. + # + # @param [String, #to_str] new_tld The new top-level domain. + def tld=(new_tld) + replaced_tld = host.sub(/#{tld}\z/, new_tld) + self.host = PublicSuffix::Domain.new(replaced_tld).to_s + end + + ## + # Returns the public suffix domain for this host. + # + # @example + # Addressable::URI.parse("http://www.example.co.uk").domain # => "example.co.uk" + def domain + PublicSuffix.domain(self.host, ignore_private: true) + end + + ## + # The authority component for this URI. + # Combines the user, password, host, and port components. + # + # @return [String] The authority component. + def authority + self.host && @authority ||= begin + authority = String.new + if self.userinfo != nil + authority << "#{self.userinfo}@" + end + authority << self.host + if self.port != nil + authority << ":#{self.port}" + end + authority + end + end + + ## + # The authority component for this URI, normalized. + # + # @return [String] The authority component, normalized. + def normalized_authority + return nil unless self.authority + @normalized_authority ||= begin + authority = String.new + if self.normalized_userinfo != nil + authority << "#{self.normalized_userinfo}@" + end + authority << self.normalized_host + if self.normalized_port != nil + authority << ":#{self.normalized_port}" + end + authority + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_authority) + @normalized_authority + end + + ## + # Sets the authority component for this URI. + # + # @param [String, #to_str] new_authority The new authority component. + def authority=(new_authority) + if new_authority + if !new_authority.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_authority.class} into String." + end + new_authority = new_authority.to_str + new_userinfo = new_authority[/^([^\[\]]*)@/, 1] + if new_userinfo + new_user = new_userinfo.strip[/^([^:]*):?/, 1] + new_password = new_userinfo.strip[/:(.*)$/, 1] + end + new_host = new_authority.sub( + /^([^\[\]]*)@/, EMPTY_STR + ).sub( + /:([^:@\[\]]*?)$/, EMPTY_STR + ) + new_port = + new_authority[/:([^:@\[\]]*?)$/, 1] + end + + # Password assigned first to ensure validity in case of nil + self.password = new_password + self.user = new_user + self.host = new_host + self.port = new_port + + # Reset dependent values + @userinfo = nil + @normalized_userinfo = NONE + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # The origin for this URI, serialized to ASCII, as per + # RFC 6454, section 6.2. + # + # @return [String] The serialized origin. + def origin + if self.scheme && self.authority + if self.normalized_port + "#{self.normalized_scheme}://#{self.normalized_host}" + + ":#{self.normalized_port}" + else + "#{self.normalized_scheme}://#{self.normalized_host}" + end + else + "null" + end + end + + ## + # Sets the origin for this URI, serialized to ASCII, as per + # RFC 6454, section 6.2. This assignment will reset the `userinfo` + # component. + # + # @param [String, #to_str] new_origin The new origin component. + def origin=(new_origin) + if new_origin + if !new_origin.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_origin.class} into String." + end + new_origin = new_origin.to_str + new_scheme = new_origin[/^([^:\/?#]+):\/\//, 1] + unless new_scheme + raise InvalidURIError, 'An origin cannot omit the scheme.' + end + new_host = new_origin[/:\/\/([^\/?#:]+)/, 1] + unless new_host + raise InvalidURIError, 'An origin cannot omit the host.' + end + new_port = new_origin[/:([^:@\[\]\/]*?)$/, 1] + end + + self.scheme = new_scheme + self.host = new_host + self.port = new_port + self.userinfo = nil + + # Reset dependent values + @userinfo = nil + @normalized_userinfo = NONE + @authority = nil + @normalized_authority = nil + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + # Returns an array of known ip-based schemes. These schemes typically + # use a similar URI form: + # //:@:/ + def self.ip_based_schemes + return self.port_mapping.keys + end + + # Returns a hash of common IP-based schemes and their default port + # numbers. Adding new schemes to this hash, as necessary, will allow + # for better URI normalization. + def self.port_mapping + PORT_MAPPING + end + + ## + # The port component for this URI. + # This is the port number actually given in the URI. This does not + # infer port numbers from default values. + # + # @return [Integer] The port component. + attr_reader :port + + ## + # The port component for this URI, normalized. + # + # @return [Integer] The port component, normalized. + def normalized_port + return nil unless self.port + return @normalized_port unless @normalized_port == NONE + @normalized_port = begin + if URI.port_mapping[self.normalized_scheme] == self.port + nil + else + self.port + end + end + end + + ## + # Sets the port component for this URI. + # + # @param [String, Integer, #to_s] new_port The new port component. + def port=(new_port) + if new_port != nil && new_port.respond_to?(:to_str) + new_port = Addressable::URI.unencode_component(new_port.to_str) + end + + if new_port.respond_to?(:valid_encoding?) && !new_port.valid_encoding? + raise InvalidURIError, "Invalid encoding in port" + end + + if new_port != nil && !(new_port.to_s =~ /^\d+$/) + raise InvalidURIError, + "Invalid port number: #{new_port.inspect}" + end + + @port = new_port.to_s.to_i + @port = nil if @port == 0 + + # Reset dependent values + @authority = nil + @normalized_port = NONE + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # The inferred port component for this URI. + # This method will normalize to the default port for the URI's scheme if + # the port isn't explicitly specified in the URI. + # + # @return [Integer] The inferred port component. + def inferred_port + if self.port.to_i == 0 + self.default_port + else + self.port.to_i + end + end + + ## + # The default port for this URI's scheme. + # This method will always returns the default port for the URI's scheme + # regardless of the presence of an explicit port in the URI. + # + # @return [Integer] The default port. + def default_port + URI.port_mapping[self.scheme.strip.downcase] if self.scheme + end + + ## + # The combination of components that represent a site. + # Combines the scheme, user, password, host, and port components. + # Primarily useful for HTTP and HTTPS. + # + # For example, "http://example.com/path?query" would have a + # site value of "http://example.com". + # + # @return [String] The components that identify a site. + def site + (self.scheme || self.authority) && @site ||= begin + site_string = "".dup + site_string << "#{self.scheme}:" if self.scheme != nil + site_string << "//#{self.authority}" if self.authority != nil + site_string + end + end + + ## + # The normalized combination of components that represent a site. + # Combines the scheme, user, password, host, and port components. + # Primarily useful for HTTP and HTTPS. + # + # For example, "http://example.com/path?query" would have a + # site value of "http://example.com". + # + # @return [String] The normalized components that identify a site. + def normalized_site + return nil unless self.site + @normalized_site ||= begin + site_string = "".dup + if self.normalized_scheme != nil + site_string << "#{self.normalized_scheme}:" + end + if self.normalized_authority != nil + site_string << "//#{self.normalized_authority}" + end + site_string + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_site) + @normalized_site + end + + ## + # Sets the site value for this URI. + # + # @param [String, #to_str] new_site The new site value. + def site=(new_site) + if new_site + if !new_site.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_site.class} into String." + end + new_site = new_site.to_str + # These two regular expressions derived from the primary parsing + # expression + self.scheme = new_site[/^(?:([^:\/?#]+):)?(?:\/\/(?:[^\/?#]*))?$/, 1] + self.authority = new_site[ + /^(?:(?:[^:\/?#]+):)?(?:\/\/([^\/?#]*))?$/, 1 + ] + else + self.scheme = nil + self.authority = nil + end + end + + ## + # The path component for this URI. + # + # @return [String] The path component. + attr_reader :path + + NORMPATH = /^(?!\/)[^\/:]*:.*$/ + ## + # The path component for this URI, normalized. + # + # @return [String] The path component, normalized. + def normalized_path + @normalized_path ||= begin + path = self.path.to_s + if self.scheme == nil && path =~ NORMPATH + # Relative paths with colons in the first segment are ambiguous. + path = path.sub(":", "%2F") + end + # String#split(delimiter, -1) uses the more strict splitting behavior + # found by default in Python. + result = path.strip.split(SLASH, -1).map do |segment| + Addressable::URI.normalize_component( + segment, + Addressable::URI::NormalizeCharacterClasses::PCHAR + ) + end.join(SLASH) + + result = URI.normalize_path(result) + if result.empty? && + ["http", "https", "ftp", "tftp"].include?(self.normalized_scheme) + result = SLASH.dup + end + result + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_path) + @normalized_path + end + + ## + # Sets the path component for this URI. + # + # @param [String, #to_str] new_path The new path component. + def path=(new_path) + if new_path && !new_path.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_path.class} into String." + end + @path = (new_path || EMPTY_STR).to_str + if !@path.empty? && @path[0..0] != SLASH && host != nil + @path = "/#{@path}" + end + + # Reset dependent values + @normalized_path = nil + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # The basename, if any, of the file in the path component. + # + # @return [String] The path's basename. + def basename + # Path cannot be nil + return File.basename(self.path).sub(/;[^\/]*$/, EMPTY_STR) + end + + ## + # The extname, if any, of the file in the path component. + # Empty string if there is no extension. + # + # @return [String] The path's extname. + def extname + return nil unless self.path + return File.extname(self.basename) + end + + ## + # The query component for this URI. + # + # @return [String] The query component. + attr_reader :query + + ## + # The query component for this URI, normalized. + # + # @return [String] The query component, normalized. + def normalized_query(*flags) + return nil unless self.query + return @normalized_query unless @normalized_query == NONE + @normalized_query = begin + modified_query_class = Addressable::URI::CharacterClasses::QUERY.dup + # Make sure possible key-value pair delimiters are escaped. + modified_query_class.sub!("\\&", "").sub!("\\;", "") + pairs = (query || "").split("&", -1) + pairs.delete_if(&:empty?).uniq! if flags.include?(:compacted) + pairs.sort! if flags.include?(:sorted) + component = pairs.map do |pair| + Addressable::URI.normalize_component( + pair, + Addressable::URI::NormalizeCharacterClasses::QUERY, + "+" + ) + end.join("&") + component == "" ? nil : component + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_query) + @normalized_query + end + + ## + # Sets the query component for this URI. + # + # @param [String, #to_str] new_query The new query component. + def query=(new_query) + if new_query && !new_query.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_query.class} into String." + end + @query = new_query ? new_query.to_str : nil + + # Reset dependent values + @normalized_query = NONE + remove_composite_values + end + + ## + # Converts the query component to a Hash value. + # + # @param [Class] return_type The return type desired. Value must be either + # `Hash` or `Array`. + # + # @return [Hash, Array, nil] The query string parsed as a Hash or Array + # or nil if the query string is blank. + # + # @example + # Addressable::URI.parse("?one=1&two=2&three=3").query_values + # #=> {"one" => "1", "two" => "2", "three" => "3"} + # Addressable::URI.parse("?one=two&one=three").query_values(Array) + # #=> [["one", "two"], ["one", "three"]] + # Addressable::URI.parse("?one=two&one=three").query_values(Hash) + # #=> {"one" => "three"} + # Addressable::URI.parse("?").query_values + # #=> {} + # Addressable::URI.parse("").query_values + # #=> nil + def query_values(return_type=Hash) + empty_accumulator = Array == return_type ? [] : {} + if return_type != Hash && return_type != Array + raise ArgumentError, "Invalid return type. Must be Hash or Array." + end + return nil if self.query == nil + split_query = self.query.split("&").map do |pair| + pair.split("=", 2) if pair && !pair.empty? + end.compact + return split_query.inject(empty_accumulator.dup) do |accu, pair| + # I'd rather use key/value identifiers instead of array lookups, + # but in this case I really want to maintain the exact pair structure, + # so it's best to make all changes in-place. + pair[0] = URI.unencode_component(pair[0]) + if pair[1].respond_to?(:to_str) + value = pair[1].to_str + # I loathe the fact that I have to do this. Stupid HTML 4.01. + # Treating '+' as a space was just an unbelievably bad idea. + # There was nothing wrong with '%20'! + # If it ain't broke, don't fix it! + value = value.tr("+", " ") if ["http", "https", nil].include?(scheme) + pair[1] = URI.unencode_component(value) + end + if return_type == Hash + accu[pair[0]] = pair[1] + else + accu << pair + end + accu + end + end + + ## + # Sets the query component for this URI from a Hash object. + # An empty Hash or Array will result in an empty query string. + # + # @param [Hash, #to_hash, Array] new_query_values The new query values. + # + # @example + # uri.query_values = {:a => "a", :b => ["c", "d", "e"]} + # uri.query + # # => "a=a&b=c&b=d&b=e" + # uri.query_values = [['a', 'a'], ['b', 'c'], ['b', 'd'], ['b', 'e']] + # uri.query + # # => "a=a&b=c&b=d&b=e" + # uri.query_values = [['a', 'a'], ['b', ['c', 'd', 'e']]] + # uri.query + # # => "a=a&b=c&b=d&b=e" + # uri.query_values = [['flag'], ['key', 'value']] + # uri.query + # # => "flag&key=value" + def query_values=(new_query_values) + if new_query_values == nil + self.query = nil + return nil + end + + if !new_query_values.is_a?(Array) + if !new_query_values.respond_to?(:to_hash) + raise TypeError, + "Can't convert #{new_query_values.class} into Hash." + end + new_query_values = new_query_values.to_hash + new_query_values = new_query_values.map do |key, value| + key = key.to_s if key.kind_of?(Symbol) + [key, value] + end + # Useful default for OAuth and caching. + # Only to be used for non-Array inputs. Arrays should preserve order. + new_query_values.sort! + end + + # new_query_values have form [['key1', 'value1'], ['key2', 'value2']] + buffer = "".dup + new_query_values.each do |key, value| + encoded_key = URI.encode_component( + key, CharacterClassesRegexps::UNRESERVED + ) + if value == nil + buffer << "#{encoded_key}&" + elsif value.kind_of?(Array) + value.each do |sub_value| + encoded_value = URI.encode_component( + sub_value, CharacterClassesRegexps::UNRESERVED + ) + buffer << "#{encoded_key}=#{encoded_value}&" + end + else + encoded_value = URI.encode_component( + value, CharacterClassesRegexps::UNRESERVED + ) + buffer << "#{encoded_key}=#{encoded_value}&" + end + end + self.query = buffer.chop + end + + ## + # The HTTP request URI for this URI. This is the path and the + # query string. + # + # @return [String] The request URI required for an HTTP request. + def request_uri + return nil if self.absolute? && self.scheme !~ /^https?$/i + return ( + (!self.path.empty? ? self.path : SLASH) + + (self.query ? "?#{self.query}" : EMPTY_STR) + ) + end + + ## + # Sets the HTTP request URI for this URI. + # + # @param [String, #to_str] new_request_uri The new HTTP request URI. + def request_uri=(new_request_uri) + if !new_request_uri.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_request_uri.class} into String." + end + if self.absolute? && self.scheme !~ /^https?$/i + raise InvalidURIError, + "Cannot set an HTTP request URI for a non-HTTP URI." + end + new_request_uri = new_request_uri.to_str + path_component = new_request_uri[/^([^\?]*)\??(?:.*)$/, 1] + query_component = new_request_uri[/^(?:[^\?]*)\?(.*)$/, 1] + path_component = path_component.to_s + path_component = (!path_component.empty? ? path_component : SLASH) + self.path = path_component + self.query = query_component + + # Reset dependent values + remove_composite_values + end + + ## + # The fragment component for this URI. + # + # @return [String] The fragment component. + attr_reader :fragment + + ## + # The fragment component for this URI, normalized. + # + # @return [String] The fragment component, normalized. + def normalized_fragment + return nil unless self.fragment + return @normalized_fragment unless @normalized_fragment == NONE + @normalized_fragment = begin + component = Addressable::URI.normalize_component( + self.fragment, + Addressable::URI::NormalizeCharacterClasses::FRAGMENT + ) + component == "" ? nil : component + end + # All normalized values should be UTF-8 + force_utf8_encoding_if_needed(@normalized_fragment) + @normalized_fragment + end + + ## + # Sets the fragment component for this URI. + # + # @param [String, #to_str] new_fragment The new fragment component. + def fragment=(new_fragment) + if new_fragment && !new_fragment.respond_to?(:to_str) + raise TypeError, "Can't convert #{new_fragment.class} into String." + end + @fragment = new_fragment ? new_fragment.to_str : nil + + # Reset dependent values + @normalized_fragment = NONE + remove_composite_values + + # Ensure we haven't created an invalid URI + validate() + end + + ## + # Determines if the scheme indicates an IP-based protocol. + # + # @return [TrueClass, FalseClass] + # true if the scheme indicates an IP-based protocol. + # false otherwise. + def ip_based? + if self.scheme + return URI.ip_based_schemes.include?( + self.scheme.strip.downcase) + end + return false + end + + ## + # Determines if the URI is relative. + # + # @return [TrueClass, FalseClass] + # true if the URI is relative. false + # otherwise. + def relative? + return self.scheme.nil? + end + + ## + # Determines if the URI is absolute. + # + # @return [TrueClass, FalseClass] + # true if the URI is absolute. false + # otherwise. + def absolute? + return !relative? + end + + ## + # Joins two URIs together. + # + # @param [String, Addressable::URI, #to_str] The URI to join with. + # + # @return [Addressable::URI] The joined URI. + def join(uri) + if !uri.respond_to?(:to_str) + raise TypeError, "Can't convert #{uri.class} into String." + end + if !uri.kind_of?(URI) + # Otherwise, convert to a String, then parse. + uri = URI.parse(uri.to_str) + end + if uri.to_s.empty? + return self.dup + end + + joined_scheme = nil + joined_user = nil + joined_password = nil + joined_host = nil + joined_port = nil + joined_path = nil + joined_query = nil + joined_fragment = nil + + # Section 5.2.2 of RFC 3986 + if uri.scheme != nil + joined_scheme = uri.scheme + joined_user = uri.user + joined_password = uri.password + joined_host = uri.host + joined_port = uri.port + joined_path = URI.normalize_path(uri.path) + joined_query = uri.query + else + if uri.authority != nil + joined_user = uri.user + joined_password = uri.password + joined_host = uri.host + joined_port = uri.port + joined_path = URI.normalize_path(uri.path) + joined_query = uri.query + else + if uri.path == nil || uri.path.empty? + joined_path = self.path + if uri.query != nil + joined_query = uri.query + else + joined_query = self.query + end + else + if uri.path[0..0] == SLASH + joined_path = URI.normalize_path(uri.path) + else + base_path = self.path.dup + base_path = EMPTY_STR if base_path == nil + base_path = URI.normalize_path(base_path) + + # Section 5.2.3 of RFC 3986 + # + # Removes the right-most path segment from the base path. + if base_path.include?(SLASH) + base_path.sub!(/\/[^\/]+$/, SLASH) + else + base_path = EMPTY_STR + end + + # If the base path is empty and an authority segment has been + # defined, use a base path of SLASH + if base_path.empty? && self.authority != nil + base_path = SLASH + end + + joined_path = URI.normalize_path(base_path + uri.path) + end + joined_query = uri.query + end + joined_user = self.user + joined_password = self.password + joined_host = self.host + joined_port = self.port + end + joined_scheme = self.scheme + end + joined_fragment = uri.fragment + + return self.class.new( + :scheme => joined_scheme, + :user => joined_user, + :password => joined_password, + :host => joined_host, + :port => joined_port, + :path => joined_path, + :query => joined_query, + :fragment => joined_fragment + ) + end + alias_method :+, :join + + ## + # Destructive form of join. + # + # @param [String, Addressable::URI, #to_str] The URI to join with. + # + # @return [Addressable::URI] The joined URI. + # + # @see Addressable::URI#join + def join!(uri) + replace_self(self.join(uri)) + end + + ## + # Merges a URI with a Hash of components. + # This method has different behavior from join. Any + # components present in the hash parameter will override the + # original components. The path component is not treated specially. + # + # @param [Hash, Addressable::URI, #to_hash] The components to merge with. + # + # @return [Addressable::URI] The merged URI. + # + # @see Hash#merge + def merge(hash) + unless hash.respond_to?(:to_hash) + raise TypeError, "Can't convert #{hash.class} into Hash." + end + hash = hash.to_hash + + if hash.has_key?(:authority) + if (hash.keys & [:userinfo, :user, :password, :host, :port]).any? + raise ArgumentError, + "Cannot specify both an authority and any of the components " + + "within the authority." + end + end + if hash.has_key?(:userinfo) + if (hash.keys & [:user, :password]).any? + raise ArgumentError, + "Cannot specify both a userinfo and either the user or password." + end + end + + uri = self.class.new + uri.defer_validation do + # Bunch of crazy logic required because of the composite components + # like userinfo and authority. + uri.scheme = + hash.has_key?(:scheme) ? hash[:scheme] : self.scheme + if hash.has_key?(:authority) + uri.authority = + hash.has_key?(:authority) ? hash[:authority] : self.authority + end + if hash.has_key?(:userinfo) + uri.userinfo = + hash.has_key?(:userinfo) ? hash[:userinfo] : self.userinfo + end + if !hash.has_key?(:userinfo) && !hash.has_key?(:authority) + uri.user = + hash.has_key?(:user) ? hash[:user] : self.user + uri.password = + hash.has_key?(:password) ? hash[:password] : self.password + end + if !hash.has_key?(:authority) + uri.host = + hash.has_key?(:host) ? hash[:host] : self.host + uri.port = + hash.has_key?(:port) ? hash[:port] : self.port + end + uri.path = + hash.has_key?(:path) ? hash[:path] : self.path + uri.query = + hash.has_key?(:query) ? hash[:query] : self.query + uri.fragment = + hash.has_key?(:fragment) ? hash[:fragment] : self.fragment + end + + return uri + end + + ## + # Destructive form of merge. + # + # @param [Hash, Addressable::URI, #to_hash] The components to merge with. + # + # @return [Addressable::URI] The merged URI. + # + # @see Addressable::URI#merge + def merge!(uri) + replace_self(self.merge(uri)) + end + + ## + # Returns the shortest normalized relative form of this URI that uses the + # supplied URI as a base for resolution. Returns an absolute URI if + # necessary. This is effectively the opposite of route_to. + # + # @param [String, Addressable::URI, #to_str] uri The URI to route from. + # + # @return [Addressable::URI] + # The normalized relative URI that is equivalent to the original URI. + def route_from(uri) + uri = URI.parse(uri).normalize + normalized_self = self.normalize + if normalized_self.relative? + raise ArgumentError, "Expected absolute URI, got: #{self.to_s}" + end + if uri.relative? + raise ArgumentError, "Expected absolute URI, got: #{uri.to_s}" + end + if normalized_self == uri + return Addressable::URI.parse("##{normalized_self.fragment}") + end + components = normalized_self.to_hash + if normalized_self.scheme == uri.scheme + components[:scheme] = nil + if normalized_self.authority == uri.authority + components[:user] = nil + components[:password] = nil + components[:host] = nil + components[:port] = nil + if normalized_self.path == uri.path + components[:path] = nil + if normalized_self.query == uri.query + components[:query] = nil + end + else + if uri.path != SLASH and components[:path] + self_splitted_path = split_path(components[:path]) + uri_splitted_path = split_path(uri.path) + self_dir = self_splitted_path.shift + uri_dir = uri_splitted_path.shift + while !self_splitted_path.empty? && !uri_splitted_path.empty? and self_dir == uri_dir + self_dir = self_splitted_path.shift + uri_dir = uri_splitted_path.shift + end + components[:path] = (uri_splitted_path.fill('..') + [self_dir] + self_splitted_path).join(SLASH) + end + end + end + end + # Avoid network-path references. + if components[:host] != nil + components[:scheme] = normalized_self.scheme + end + return Addressable::URI.new( + :scheme => components[:scheme], + :user => components[:user], + :password => components[:password], + :host => components[:host], + :port => components[:port], + :path => components[:path], + :query => components[:query], + :fragment => components[:fragment] + ) + end + + ## + # Returns the shortest normalized relative form of the supplied URI that + # uses this URI as a base for resolution. Returns an absolute URI if + # necessary. This is effectively the opposite of route_from. + # + # @param [String, Addressable::URI, #to_str] uri The URI to route to. + # + # @return [Addressable::URI] + # The normalized relative URI that is equivalent to the supplied URI. + def route_to(uri) + return URI.parse(uri).route_from(self) + end + + ## + # Returns a normalized URI object. + # + # NOTE: This method does not attempt to fully conform to specifications. + # It exists largely to correct other people's failures to read the + # specifications, and also to deal with caching issues since several + # different URIs may represent the same resource and should not be + # cached multiple times. + # + # @return [Addressable::URI] The normalized URI. + def normalize + # This is a special exception for the frequently misused feed + # URI scheme. + if normalized_scheme == "feed" + if self.to_s =~ /^feed:\/*http:\/*/ + return URI.parse( + self.to_s[/^feed:\/*(http:\/*.*)/, 1] + ).normalize + end + end + + return self.class.new( + :scheme => normalized_scheme, + :authority => normalized_authority, + :path => normalized_path, + :query => normalized_query, + :fragment => normalized_fragment + ) + end + + ## + # Destructively normalizes this URI object. + # + # @return [Addressable::URI] The normalized URI. + # + # @see Addressable::URI#normalize + def normalize! + replace_self(self.normalize) + end + + ## + # Creates a URI suitable for display to users. If semantic attacks are + # likely, the application should try to detect these and warn the user. + # See RFC 3986, + # section 7.6 for more information. + # + # @return [Addressable::URI] A URI suitable for display purposes. + def display_uri + display_uri = self.normalize + display_uri.host = ::Addressable::IDNA.to_unicode(display_uri.host) + return display_uri + end + + ## + # Returns true if the URI objects are equal. This method + # normalizes both URIs before doing the comparison, and allows comparison + # against Strings. + # + # @param [Object] uri The URI to compare. + # + # @return [TrueClass, FalseClass] + # true if the URIs are equivalent, false + # otherwise. + def ===(uri) + if uri.respond_to?(:normalize) + uri_string = uri.normalize.to_s + else + begin + uri_string = ::Addressable::URI.parse(uri).normalize.to_s + rescue InvalidURIError, TypeError + return false + end + end + return self.normalize.to_s == uri_string + end + + ## + # Returns true if the URI objects are equal. This method + # normalizes both URIs before doing the comparison. + # + # @param [Object] uri The URI to compare. + # + # @return [TrueClass, FalseClass] + # true if the URIs are equivalent, false + # otherwise. + def ==(uri) + return false unless uri.kind_of?(URI) + return self.normalize.to_s == uri.normalize.to_s + end + + ## + # Returns true if the URI objects are equal. This method + # does NOT normalize either URI before doing the comparison. + # + # @param [Object] uri The URI to compare. + # + # @return [TrueClass, FalseClass] + # true if the URIs are equivalent, false + # otherwise. + def eql?(uri) + return false unless uri.kind_of?(URI) + return self.to_s == uri.to_s + end + + ## + # A hash value that will make a URI equivalent to its normalized + # form. + # + # @return [Integer] A hash of the URI. + def hash + @hash ||= self.to_s.hash * -1 + end + + ## + # Clones the URI object. + # + # @return [Addressable::URI] The cloned URI. + def dup + duplicated_uri = self.class.new( + :scheme => self.scheme ? self.scheme.dup : nil, + :user => self.user ? self.user.dup : nil, + :password => self.password ? self.password.dup : nil, + :host => self.host ? self.host.dup : nil, + :port => self.port, + :path => self.path ? self.path.dup : nil, + :query => self.query ? self.query.dup : nil, + :fragment => self.fragment ? self.fragment.dup : nil + ) + return duplicated_uri + end + + ## + # Omits components from a URI. + # + # @param [Symbol] *components The components to be omitted. + # + # @return [Addressable::URI] The URI with components omitted. + # + # @example + # uri = Addressable::URI.parse("http://example.com/path?query") + # #=> # + # uri.omit(:scheme, :authority) + # #=> # + def omit(*components) + invalid_components = components - [ + :scheme, :user, :password, :userinfo, :host, :port, :authority, + :path, :query, :fragment + ] + unless invalid_components.empty? + raise ArgumentError, + "Invalid component names: #{invalid_components.inspect}." + end + duplicated_uri = self.dup + duplicated_uri.defer_validation do + components.each do |component| + duplicated_uri.send((component.to_s + "=").to_sym, nil) + end + duplicated_uri.user = duplicated_uri.normalized_user + end + duplicated_uri + end + + ## + # Destructive form of omit. + # + # @param [Symbol] *components The components to be omitted. + # + # @return [Addressable::URI] The URI with components omitted. + # + # @see Addressable::URI#omit + def omit!(*components) + replace_self(self.omit(*components)) + end + + ## + # Determines if the URI is an empty string. + # + # @return [TrueClass, FalseClass] + # Returns true if empty, false otherwise. + def empty? + return self.to_s.empty? + end + + ## + # Converts the URI to a String. + # + # @return [String] The URI's String representation. + def to_s + if self.scheme == nil && self.path != nil && !self.path.empty? && + self.path =~ NORMPATH + raise InvalidURIError, + "Cannot assemble URI string with ambiguous path: '#{self.path}'" + end + @uri_string ||= begin + uri_string = String.new + uri_string << "#{self.scheme}:" if self.scheme != nil + uri_string << "//#{self.authority}" if self.authority != nil + uri_string << self.path.to_s + uri_string << "?#{self.query}" if self.query != nil + uri_string << "##{self.fragment}" if self.fragment != nil + uri_string.force_encoding(Encoding::UTF_8) + uri_string + end + end + + ## + # URI's are glorified Strings. Allow implicit conversion. + alias_method :to_str, :to_s + + ## + # Returns a Hash of the URI components. + # + # @return [Hash] The URI as a Hash of components. + def to_hash + return { + :scheme => self.scheme, + :user => self.user, + :password => self.password, + :host => self.host, + :port => self.port, + :path => self.path, + :query => self.query, + :fragment => self.fragment + } + end + + ## + # Returns a String representation of the URI object's state. + # + # @return [String] The URI object's state, as a String. + def inspect + sprintf("#<%s:%#0x URI:%s>", URI.to_s, self.object_id, self.to_s) + end + + ## + # This method allows you to make several changes to a URI simultaneously, + # which separately would cause validation errors, but in conjunction, + # are valid. The URI will be revalidated as soon as the entire block has + # been executed. + # + # @param [Proc] block + # A set of operations to perform on a given URI. + def defer_validation + raise LocalJumpError, "No block given." unless block_given? + @validation_deferred = true + yield + @validation_deferred = false + validate + ensure + @validation_deferred = false + end + + def encode_with(coder) + instance_variables.each do |ivar| + value = instance_variable_get(ivar) + if value != NONE + key = ivar.to_s.slice(1..-1) + coder[key] = value + end + end + nil + end + + def init_with(coder) + reset_ivs + coder.map.each do |key, value| + instance_variable_set("@#{key}", value) + end + nil + end + + protected + SELF_REF = '.' + PARENT = '..' + + RULE_2A = /\/\.\/|\/\.$/ + RULE_2B_2C = /\/([^\/]*)\/\.\.\/|\/([^\/]*)\/\.\.$/ + RULE_2D = /^\.\.?\/?/ + RULE_PREFIXED_PARENT = /^\/\.\.?\/|^(\/\.\.?)+\/?$/ + + ## + # Resolves paths to their simplest form. + # + # @param [String] path The path to normalize. + # + # @return [String] The normalized path. + def self.normalize_path(path) + # Section 5.2.4 of RFC 3986 + + return if path.nil? + normalized_path = path.dup + loop do + mod ||= normalized_path.gsub!(RULE_2A, SLASH) + + pair = normalized_path.match(RULE_2B_2C) + if pair + parent = pair[1] + current = pair[2] + else + parent = nil + current = nil + end + + regexp = "/#{Regexp.escape(parent.to_s)}/\\.\\./|" + regexp += "(/#{Regexp.escape(current.to_s)}/\\.\\.$)" + + if pair && ((parent != SELF_REF && parent != PARENT) || + (current != SELF_REF && current != PARENT)) + mod ||= normalized_path.gsub!(Regexp.new(regexp), SLASH) + end + + mod ||= normalized_path.gsub!(RULE_2D, EMPTY_STR) + # Non-standard, removes prefixed dotted segments from path. + mod ||= normalized_path.gsub!(RULE_PREFIXED_PARENT, SLASH) + break if mod.nil? + end + + normalized_path + end + + ## + # Ensures that the URI is valid. + def validate + return if !!@validation_deferred + if self.scheme != nil && self.ip_based? && + (self.host == nil || self.host.empty?) && + (self.path == nil || self.path.empty?) + raise InvalidURIError, + "Absolute URI missing hierarchical segment: '#{self.to_s}'" + end + if self.host == nil + if self.port != nil || + self.user != nil || + self.password != nil + raise InvalidURIError, "Hostname not supplied: '#{self.to_s}'" + end + end + if self.path != nil && !self.path.empty? && self.path[0..0] != SLASH && + self.authority != nil + raise InvalidURIError, + "Cannot have a relative path with an authority set: '#{self.to_s}'" + end + if self.path != nil && !self.path.empty? && + self.path[0..1] == SLASH + SLASH && self.authority == nil + raise InvalidURIError, + "Cannot have a path with two leading slashes " + + "without an authority set: '#{self.to_s}'" + end + unreserved = CharacterClasses::UNRESERVED + sub_delims = CharacterClasses::SUB_DELIMS + if !self.host.nil? && (self.host =~ /[<>{}\/\\\?\#\@"[[:space:]]]/ || + (self.host[/^\[(.*)\]$/, 1] != nil && self.host[/^\[(.*)\]$/, 1] !~ + Regexp.new("^[#{unreserved}#{sub_delims}:]*$"))) + raise InvalidURIError, "Invalid character in host: '#{self.host.to_s}'" + end + return nil + end + + ## + # Replaces the internal state of self with the specified URI's state. + # Used in destructive operations to avoid massive code repetition. + # + # @param [Addressable::URI] uri The URI to replace self with. + # + # @return [Addressable::URI] self. + def replace_self(uri) + # Reset dependent values + reset_ivs + + @scheme = uri.scheme + @user = uri.user + @password = uri.password + @host = uri.host + @port = uri.port + @path = uri.path + @query = uri.query + @fragment = uri.fragment + return self + end + + ## + # Splits path string with "/" (slash). + # It is considered that there is empty string after last slash when + # path ends with slash. + # + # @param [String] path The path to split. + # + # @return [Array] An array of parts of path. + def split_path(path) + splitted = path.split(SLASH) + splitted << EMPTY_STR if path.end_with? SLASH + splitted + end + + ## + # Resets composite values for the entire URI + # + # @api private + def remove_composite_values + @uri_string = nil + @hash = nil + end + + ## + # Converts the string to be UTF-8 if it is not already UTF-8 + # + # @api private + def force_utf8_encoding_if_needed(str) + if str && str.encoding != Encoding::UTF_8 + str.force_encoding(Encoding::UTF_8) + end + end + + private + + ## + # Resets instance variables + # + # @api private + def reset_ivs + @scheme = nil + @user = nil + @normalized_scheme = NONE + @normalized_user = NONE + @uri_string = nil + @hash = nil + @userinfo = nil + @normalized_userinfo = NONE + @authority = nil + @password = nil + @normalized_authority = nil + @port = nil + @normalized_password = NONE + @host = nil + @normalized_host = nil + @normalized_port = NONE + @path = EMPTY_STR + @normalized_path = nil + @normalized_query = NONE + @fragment = nil + @normalized_fragment = NONE + @query = nil + end + + NONE = Module.new.freeze + + private_constant :NONE + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/version.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/version.rb new file mode 100644 index 0000000..2eec3e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/lib/addressable/version.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +#-- +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#++ + + +# Used to prevent the class/module from being loaded more than once +if !defined?(Addressable::VERSION) + module Addressable + module VERSION + MAJOR = 2 + MINOR = 8 + TINY = 7 + + STRING = [MAJOR, MINOR, TINY].join('.') + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/idna_spec.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/idna_spec.rb new file mode 100644 index 0000000..428c9ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/idna_spec.rb @@ -0,0 +1,302 @@ +# frozen_string_literal: true + +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +require "spec_helper" + +# Have to use RubyGems to load the idn gem. +require "rubygems" + +require "addressable/idna" + +shared_examples_for "converting from unicode to ASCII" do + it "should convert 'www.google.com' correctly" do + expect(Addressable::IDNA.to_ascii("www.google.com")).to eq("www.google.com") + end + + long = 'AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallum.com' + it "should convert '#{long}' correctly" do + expect(Addressable::IDNA.to_ascii(long)).to eq(long) + end + + it "should convert 'www.詹姆斯.com' correctly" do + expect(Addressable::IDNA.to_ascii( + "www.詹姆斯.com" + )).to eq("www.xn--8ws00zhy3a.com") + end + + it "also accepts unicode strings encoded as ascii-8bit" do + expect(Addressable::IDNA.to_ascii( + "www.詹姆斯.com".b + )).to eq("www.xn--8ws00zhy3a.com") + end + + it "should convert 'www.Iñtërnâtiônàlizætiøn.com' correctly" do + "www.Iñtërnâtiônàlizætiøn.com" + expect(Addressable::IDNA.to_ascii( + "www.I\xC3\xB1t\xC3\xABrn\xC3\xA2ti\xC3\xB4" + + "n\xC3\xA0liz\xC3\xA6ti\xC3\xB8n.com" + )).to eq("www.xn--itrntinliztin-vdb0a5exd8ewcye.com") + end + + it "should convert 'www.Iñtërnâtiônàlizætiøn.com' correctly" do + expect(Addressable::IDNA.to_ascii( + "www.In\xCC\x83te\xCC\x88rna\xCC\x82tio\xCC\x82n" + + "a\xCC\x80liz\xC3\xA6ti\xC3\xB8n.com" + )).to eq("www.xn--itrntinliztin-vdb0a5exd8ewcye.com") + end + + it "should convert " + + "'www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp' " + + "correctly" do + expect(Addressable::IDNA.to_ascii( + "www.\343\201\273\343\202\223\343\201\250\343\201\206\343\201\253\343" + + "\201\252\343\201\214\343\201\204\343\202\217\343\201\221\343\201\256" + + "\343\202\217\343\201\213\343\202\211\343\201\252\343\201\204\343\201" + + "\251\343\202\201\343\201\204\343\202\223\343\202\201\343\201\204\343" + + "\201\256\343\202\211\343\201\271\343\202\213\343\201\276\343\201\240" + + "\343\201\252\343\201\214\343\201\217\343\201\227\343\201\252\343\201" + + "\204\343\201\250\343\201\237\343\202\212\343\201\252\343\201\204." + + "w3.mag.keio.ac.jp" + )).to eq( + "www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3" + + "fg11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp" + ) + end + + it "should convert " + + "'www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp' " + + "correctly" do + expect(Addressable::IDNA.to_ascii( + "www.\343\201\273\343\202\223\343\201\250\343\201\206\343\201\253\343" + + "\201\252\343\201\213\343\202\231\343\201\204\343\202\217\343\201\221" + + "\343\201\256\343\202\217\343\201\213\343\202\211\343\201\252\343\201" + + "\204\343\201\250\343\202\231\343\202\201\343\201\204\343\202\223\343" + + "\202\201\343\201\204\343\201\256\343\202\211\343\201\270\343\202\231" + + "\343\202\213\343\201\276\343\201\237\343\202\231\343\201\252\343\201" + + "\213\343\202\231\343\201\217\343\201\227\343\201\252\343\201\204\343" + + "\201\250\343\201\237\343\202\212\343\201\252\343\201\204." + + "w3.mag.keio.ac.jp" + )).to eq( + "www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3" + + "fg11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp" + ) + end + + it "should convert '点心和烤鸭.w3.mag.keio.ac.jp' correctly" do + expect(Addressable::IDNA.to_ascii( + "点心和烤鸭.w3.mag.keio.ac.jp" + )).to eq("xn--0trv4xfvn8el34t.w3.mag.keio.ac.jp") + end + + it "should convert '가각갂갃간갅갆갇갈갉힢힣.com' correctly" do + expect(Addressable::IDNA.to_ascii( + "가각갂갃간갅갆갇갈갉힢힣.com" + )).to eq("xn--o39acdefghijk5883jma.com") + end + + it "should convert " + + "'\347\242\274\346\250\231\346\272\226\350" + + "\220\254\345\234\213\347\242\274.com' correctly" do + expect(Addressable::IDNA.to_ascii( + "\347\242\274\346\250\231\346\272\226\350" + + "\220\254\345\234\213\347\242\274.com" + )).to eq("xn--9cs565brid46mda086o.com") + end + + it "should convert 'リ宠퐱〹.com' correctly" do + expect(Addressable::IDNA.to_ascii( + "\357\276\230\345\256\240\355\220\261\343\200\271.com" + )).to eq("xn--eek174hoxfpr4k.com") + end + + it "should convert 'リ宠퐱卄.com' correctly" do + expect(Addressable::IDNA.to_ascii( + "\343\203\252\345\256\240\355\220\261\345\215\204.com" + )).to eq("xn--eek174hoxfpr4k.com") + end + + it "should convert 'ᆵ' correctly" do + expect(Addressable::IDNA.to_ascii( + "\341\206\265" + )).to eq("xn--4ud") + end + + it "should convert 'ᆵ' correctly" do + expect(Addressable::IDNA.to_ascii( + "\357\276\257" + )).to eq("xn--4ud") + end + + it "should convert '🌹🌹🌹.ws' correctly" do + expect(Addressable::IDNA.to_ascii( + "\360\237\214\271\360\237\214\271\360\237\214\271.ws" + )).to eq("xn--2h8haa.ws") + end + + it "should handle two adjacent '.'s correctly" do + expect(Addressable::IDNA.to_ascii( + "example..host" + )).to eq("example..host") + end +end + +shared_examples_for "converting from ASCII to unicode" do + long = 'AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallum.com' + it "should convert '#{long}' correctly" do + expect(Addressable::IDNA.to_unicode(long)).to eq(long) + end + + it "should return the identity conversion when punycode decode fails" do + expect(Addressable::IDNA.to_unicode("xn--zckp1cyg1.sblo.jp")).to eq( + "xn--zckp1cyg1.sblo.jp") + end + + it "should return the identity conversion when the ACE prefix has no suffix" do + expect(Addressable::IDNA.to_unicode("xn--...-")).to eq("xn--...-") + end + + it "should convert 'www.google.com' correctly" do + expect(Addressable::IDNA.to_unicode("www.google.com")).to eq( + "www.google.com") + end + + it "should convert 'www.詹姆斯.com' correctly" do + expect(Addressable::IDNA.to_unicode( + "www.xn--8ws00zhy3a.com" + )).to eq("www.詹姆斯.com") + end + + it "should convert '詹姆斯.com' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--8ws00zhy3a.com" + )).to eq("詹姆斯.com") + end + + it "should convert 'www.iñtërnâtiônàlizætiøn.com' correctly" do + expect(Addressable::IDNA.to_unicode( + "www.xn--itrntinliztin-vdb0a5exd8ewcye.com" + )).to eq("www.iñtërnâtiônàlizætiøn.com") + end + + it "should convert 'iñtërnâtiônàlizætiøn.com' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--itrntinliztin-vdb0a5exd8ewcye.com" + )).to eq("iñtërnâtiônàlizætiøn.com") + end + + it "should convert " + + "'www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp' " + + "correctly" do + expect(Addressable::IDNA.to_unicode( + "www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3" + + "fg11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp" + )).to eq( + "www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp" + ) + end + + it "should convert '点心和烤鸭.w3.mag.keio.ac.jp' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--0trv4xfvn8el34t.w3.mag.keio.ac.jp" + )).to eq("点心和烤鸭.w3.mag.keio.ac.jp") + end + + it "should convert '가각갂갃간갅갆갇갈갉힢힣.com' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--o39acdefghijk5883jma.com" + )).to eq("가각갂갃간갅갆갇갈갉힢힣.com") + end + + it "should convert " + + "'\347\242\274\346\250\231\346\272\226\350" + + "\220\254\345\234\213\347\242\274.com' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--9cs565brid46mda086o.com" + )).to eq( + "\347\242\274\346\250\231\346\272\226\350" + + "\220\254\345\234\213\347\242\274.com" + ) + end + + it "should convert 'リ宠퐱卄.com' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--eek174hoxfpr4k.com" + )).to eq("\343\203\252\345\256\240\355\220\261\345\215\204.com") + end + + it "should convert 'ᆵ' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--4ud" + )).to eq("\341\206\265") + end + + it "should convert '🌹🌹🌹.ws' correctly" do + expect(Addressable::IDNA.to_unicode( + "xn--2h8haa.ws" + )).to eq("\360\237\214\271\360\237\214\271\360\237\214\271.ws") + end + + it "should handle two adjacent '.'s correctly" do + expect(Addressable::IDNA.to_unicode( + "example..host" + )).to eq("example..host") + end +end + +describe Addressable::IDNA, "when using the pure-Ruby implementation" do + before do + Addressable.send(:remove_const, :IDNA) + load "addressable/idna/pure.rb" + end + + it_should_behave_like "converting from unicode to ASCII" + it_should_behave_like "converting from ASCII to unicode" + + begin + require "fiber" + + it "should not blow up inside fibers" do + f = Fiber.new do + Addressable.send(:remove_const, :IDNA) + load "addressable/idna/pure.rb" + end + f.resume + end + rescue LoadError + # Fibers aren't supported in this version of Ruby, skip this test. + warn('Fibers unsupported.') + end +end + +begin + require "idn" + + describe Addressable::IDNA, "when using the native-code implementation" do + before do + Addressable.send(:remove_const, :IDNA) + load "addressable/idna/native.rb" + end + + it_should_behave_like "converting from unicode to ASCII" + it_should_behave_like "converting from ASCII to unicode" + end +rescue LoadError => error + raise error if ENV["CI"] && TestHelper.native_supported? + + # Cannot test the native implementation without libidn support. + warn('Could not load native IDN implementation.') +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/net_http_compat_spec.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/net_http_compat_spec.rb new file mode 100644 index 0000000..d07a43e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/net_http_compat_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +require "spec_helper" + +require "addressable/uri" +require "net/http" + +describe Net::HTTP do + it "should be compatible with Addressable" do + response_body = + Net::HTTP.get(Addressable::URI.parse('http://www.google.com/')) + expect(response_body).not_to be_nil + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/security_spec.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/security_spec.rb new file mode 100644 index 0000000..3bf90a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/security_spec.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +require "spec_helper" + +require "addressable/uri" + +describe Addressable::URI, "when created with a URI known to cause crashes " + + "in certain browsers" do + it "should parse correctly" do + uri = Addressable::URI.parse('%%30%30') + expect(uri.path).to eq('%%30%30') + expect(uri.normalize.path).to eq('%2500') + end + + it "should parse correctly as a full URI" do + uri = Addressable::URI.parse('http://www.example.com/%%30%30') + expect(uri.path).to eq('/%%30%30') + expect(uri.normalize.path).to eq('/%2500') + end +end + +describe Addressable::URI, "when created with a URI known to cause crashes " + + "in certain browsers" do + it "should parse correctly" do + uri = Addressable::URI.parse('لُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗') + expect(uri.path).to eq('لُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗') + expect(uri.normalize.path).to eq( + '%D9%84%D9%8F%D8%B5%D9%91%D8%A8%D9%8F%D9%84%D9%8F%D9%84%D8%B5%D9%91' + + '%D8%A8%D9%8F%D8%B1%D8%B1%D9%8B%20%E0%A5%A3%20%E0%A5%A3h%20%E0%A5' + + '%A3%20%E0%A5%A3%20%E5%86%97' + ) + end + + it "should parse correctly as a full URI" do + uri = Addressable::URI.parse('http://www.example.com/لُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗') + expect(uri.path).to eq('/لُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗') + expect(uri.normalize.path).to eq( + '/%D9%84%D9%8F%D8%B5%D9%91%D8%A8%D9%8F%D9%84%D9%8F%D9%84%D8%B5%D9%91' + + '%D8%A8%D9%8F%D8%B1%D8%B1%D9%8B%20%E0%A5%A3%20%E0%A5%A3h%20%E0%A5' + + '%A3%20%E0%A5%A3%20%E5%86%97' + ) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/template_spec.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/template_spec.rb new file mode 100644 index 0000000..24616c2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/template_spec.rb @@ -0,0 +1,1264 @@ +# frozen_string_literal: true + +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +require "spec_helper" + +require "bigdecimal" +require "timeout" +require "addressable/template" + +shared_examples_for 'expands' do |tests| + tests.each do |template, expansion| + exp = expansion.is_a?(Array) ? expansion.first : expansion + it "#{template} to #{exp}" do + tmpl = Addressable::Template.new(template).expand(subject) + expect(tmpl.to_str).to eq(expansion) + end + end +end + +describe "eql?" do + let(:template) { Addressable::Template.new('https://www.example.com/{foo}') } + it 'is equal when the pattern matches' do + other_template = Addressable::Template.new('https://www.example.com/{foo}') + expect(template).to be_eql(other_template) + expect(other_template).to be_eql(template) + end + it 'is not equal when the pattern differs' do + other_template = Addressable::Template.new('https://www.example.com/{bar}') + expect(template).to_not be_eql(other_template) + expect(other_template).to_not be_eql(template) + end + it 'is not equal to non-templates' do + uri = 'https://www.example.com/foo/bar' + addressable_template = Addressable::Template.new uri + addressable_uri = Addressable::URI.parse uri + expect(addressable_template).to_not be_eql(addressable_uri) + expect(addressable_uri).to_not be_eql(addressable_template) + end +end + +describe "==" do + let(:template) { Addressable::Template.new('https://www.example.com/{foo}') } + it 'is equal when the pattern matches' do + other_template = Addressable::Template.new('https://www.example.com/{foo}') + expect(template).to eq other_template + expect(other_template).to eq template + end + it 'is not equal when the pattern differs' do + other_template = Addressable::Template.new('https://www.example.com/{bar}') + expect(template).not_to eq other_template + expect(other_template).not_to eq template + end + it 'is not equal to non-templates' do + uri = 'https://www.example.com/foo/bar' + addressable_template = Addressable::Template.new uri + addressable_uri = Addressable::URI.parse uri + expect(addressable_template).not_to eq addressable_uri + expect(addressable_uri).not_to eq addressable_template + end +end + +describe "#to_regexp" do + it "does not match the first line of multiline strings" do + uri = "https://www.example.com/bar" + template = Addressable::Template.new(uri) + expect(template.match(uri)).not_to be_nil + expect(template.match("#{uri}\ngarbage")).to be_nil + end +end + +describe "Type conversion" do + subject { + { + :var => true, + :hello => 1234, + :nothing => nil, + :sym => :symbolic, + :decimal => BigDecimal('1') + } + } + + it_behaves_like 'expands', { + '{var}' => 'true', + '{hello}' => '1234', + '{nothing}' => '', + '{sym}' => 'symbolic', + '{decimal}' => RUBY_VERSION < '2.4.0' ? '0.1E1' : '0.1e1' + } +end + +describe "Level 1:" do + subject { + {:var => "value", :hello => "Hello World!"} + } + it_behaves_like 'expands', { + '{var}' => 'value', + '{hello}' => 'Hello%20World%21' + } +end + +describe "Level 2" do + subject { + { + :var => "value", + :hello => "Hello World!", + :path => "/foo/bar" + } + } + context "Operator +:" do + it_behaves_like 'expands', { + '{+var}' => 'value', + '{+hello}' => 'Hello%20World!', + '{+path}/here' => '/foo/bar/here', + 'here?ref={+path}' => 'here?ref=/foo/bar' + } + end + context "Operator #:" do + it_behaves_like 'expands', { + 'X{#var}' => 'X#value', + 'X{#hello}' => 'X#Hello%20World!' + } + end +end + +describe "Level 3" do + subject { + { + :var => "value", + :hello => "Hello World!", + :empty => "", + :path => "/foo/bar", + :x => "1024", + :y => "768" + } + } + context "Operator nil (multiple vars):" do + it_behaves_like 'expands', { + 'map?{x,y}' => 'map?1024,768', + '{x,hello,y}' => '1024,Hello%20World%21,768' + } + end + context "Operator + (multiple vars):" do + it_behaves_like 'expands', { + '{+x,hello,y}' => '1024,Hello%20World!,768', + '{+path,x}/here' => '/foo/bar,1024/here' + } + end + context "Operator # (multiple vars):" do + it_behaves_like 'expands', { + '{#x,hello,y}' => '#1024,Hello%20World!,768', + '{#path,x}/here' => '#/foo/bar,1024/here' + } + end + context "Operator ." do + it_behaves_like 'expands', { + 'X{.var}' => 'X.value', + 'X{.x,y}' => 'X.1024.768' + } + end + context "Operator /" do + it_behaves_like 'expands', { + '{/var}' => '/value', + '{/var,x}/here' => '/value/1024/here' + } + end + context "Operator ;" do + it_behaves_like 'expands', { + '{;x,y}' => ';x=1024;y=768', + '{;x,y,empty}' => ';x=1024;y=768;empty' + } + end + context "Operator ?" do + it_behaves_like 'expands', { + '{?x,y}' => '?x=1024&y=768', + '{?x,y,empty}' => '?x=1024&y=768&empty=' + } + end + context "Operator &" do + it_behaves_like 'expands', { + '?fixed=yes{&x}' => '?fixed=yes&x=1024', + '{&x,y,empty}' => '&x=1024&y=768&empty=' + } + end +end + +describe "Level 4" do + subject { + { + :var => "value", + :hello => "Hello World!", + :path => "/foo/bar", + :semi => ";", + :list => %w(red green blue), + :keys => {"semi" => ';', "dot" => '.', :comma => ','} + } + } + context "Expansion with value modifiers" do + it_behaves_like 'expands', { + '{var:3}' => 'val', + '{var:30}' => 'value', + '{list}' => 'red,green,blue', + '{list*}' => 'red,green,blue', + '{keys}' => 'semi,%3B,dot,.,comma,%2C', + '{keys*}' => 'semi=%3B,dot=.,comma=%2C', + } + end + context "Operator + with value modifiers" do + it_behaves_like 'expands', { + '{+path:6}/here' => '/foo/b/here', + '{+list}' => 'red,green,blue', + '{+list*}' => 'red,green,blue', + '{+keys}' => 'semi,;,dot,.,comma,,', + '{+keys*}' => 'semi=;,dot=.,comma=,', + } + end + context "Operator # with value modifiers" do + it_behaves_like 'expands', { + '{#path:6}/here' => '#/foo/b/here', + '{#list}' => '#red,green,blue', + '{#list*}' => '#red,green,blue', + '{#keys}' => '#semi,;,dot,.,comma,,', + '{#keys*}' => '#semi=;,dot=.,comma=,', + } + end + context "Operator . with value modifiers" do + it_behaves_like 'expands', { + 'X{.var:3}' => 'X.val', + 'X{.list}' => 'X.red,green,blue', + 'X{.list*}' => 'X.red.green.blue', + 'X{.keys}' => 'X.semi,%3B,dot,.,comma,%2C', + 'X{.keys*}' => 'X.semi=%3B.dot=..comma=%2C', + } + end + context "Operator / with value modifiers" do + it_behaves_like 'expands', { + '{/var:1,var}' => '/v/value', + '{/list}' => '/red,green,blue', + '{/list*}' => '/red/green/blue', + '{/list*,path:4}' => '/red/green/blue/%2Ffoo', + '{/keys}' => '/semi,%3B,dot,.,comma,%2C', + '{/keys*}' => '/semi=%3B/dot=./comma=%2C', + } + end + context "Operator ; with value modifiers" do + it_behaves_like 'expands', { + '{;hello:5}' => ';hello=Hello', + '{;list}' => ';list=red,green,blue', + '{;list*}' => ';list=red;list=green;list=blue', + '{;keys}' => ';keys=semi,%3B,dot,.,comma,%2C', + '{;keys*}' => ';semi=%3B;dot=.;comma=%2C', + } + end + context "Operator ? with value modifiers" do + it_behaves_like 'expands', { + '{?var:3}' => '?var=val', + '{?list}' => '?list=red,green,blue', + '{?list*}' => '?list=red&list=green&list=blue', + '{?keys}' => '?keys=semi,%3B,dot,.,comma,%2C', + '{?keys*}' => '?semi=%3B&dot=.&comma=%2C', + } + end + context "Operator & with value modifiers" do + it_behaves_like 'expands', { + '{&var:3}' => '&var=val', + '{&list}' => '&list=red,green,blue', + '{&list*}' => '&list=red&list=green&list=blue', + '{&keys}' => '&keys=semi,%3B,dot,.,comma,%2C', + '{&keys*}' => '&semi=%3B&dot=.&comma=%2C', + } + end +end +describe "Modifiers" do + subject { + { + :var => "value", + :semi => ";", + :year => [1965, 2000, 2012], + :dom => %w(example com) + } + } + context "length" do + it_behaves_like 'expands', { + '{var:3}' => 'val', + '{var:30}' => 'value', + '{var}' => 'value', + '{semi}' => '%3B', + '{semi:2}' => '%3B' + } + end + context "explode" do + it_behaves_like 'expands', { + 'find{?year*}' => 'find?year=1965&year=2000&year=2012', + 'www{.dom*}' => 'www.example.com', + } + end +end +describe "Expansion" do + subject { + { + :count => ["one", "two", "three"], + :dom => ["example", "com"], + :dub => "me/too", + :hello => "Hello World!", + :half => "50%", + :var => "value", + :who => "fred", + :base => "http://example.com/home/", + :path => "/foo/bar", + :list => ["red", "green", "blue"], + :keys => {"semi" => ";","dot" => ".",:comma => ","}, + :v => "6", + :x => "1024", + :y => "768", + :empty => "", + :empty_keys => {}, + :undef => nil + } + } + context "concatenation" do + it_behaves_like 'expands', { + '{count}' => 'one,two,three', + '{count*}' => 'one,two,three', + '{/count}' => '/one,two,three', + '{/count*}' => '/one/two/three', + '{;count}' => ';count=one,two,three', + '{;count*}' => ';count=one;count=two;count=three', + '{?count}' => '?count=one,two,three', + '{?count*}' => '?count=one&count=two&count=three', + '{&count*}' => '&count=one&count=two&count=three' + } + end + context "simple expansion" do + it_behaves_like 'expands', { + '{var}' => 'value', + '{hello}' => 'Hello%20World%21', + '{half}' => '50%25', + 'O{empty}X' => 'OX', + 'O{undef}X' => 'OX', + '{x,y}' => '1024,768', + '{x,hello,y}' => '1024,Hello%20World%21,768', + '?{x,empty}' => '?1024,', + '?{x,undef}' => '?1024', + '?{undef,y}' => '?768', + '{var:3}' => 'val', + '{var:30}' => 'value', + '{list}' => 'red,green,blue', + '{list*}' => 'red,green,blue', + '{keys}' => 'semi,%3B,dot,.,comma,%2C', + '{keys*}' => 'semi=%3B,dot=.,comma=%2C', + } + end + context "reserved expansion (+)" do + it_behaves_like 'expands', { + '{+var}' => 'value', + '{+hello}' => 'Hello%20World!', + '{+half}' => '50%25', + '{base}index' => 'http%3A%2F%2Fexample.com%2Fhome%2Findex', + '{+base}index' => 'http://example.com/home/index', + 'O{+empty}X' => 'OX', + 'O{+undef}X' => 'OX', + '{+path}/here' => '/foo/bar/here', + 'here?ref={+path}' => 'here?ref=/foo/bar', + 'up{+path}{var}/here' => 'up/foo/barvalue/here', + '{+x,hello,y}' => '1024,Hello%20World!,768', + '{+path,x}/here' => '/foo/bar,1024/here', + '{+path:6}/here' => '/foo/b/here', + '{+list}' => 'red,green,blue', + '{+list*}' => 'red,green,blue', + '{+keys}' => 'semi,;,dot,.,comma,,', + '{+keys*}' => 'semi=;,dot=.,comma=,', + } + end + context "fragment expansion (#)" do + it_behaves_like 'expands', { + '{#var}' => '#value', + '{#hello}' => '#Hello%20World!', + '{#half}' => '#50%25', + 'foo{#empty}' => 'foo#', + 'foo{#undef}' => 'foo', + '{#x,hello,y}' => '#1024,Hello%20World!,768', + '{#path,x}/here' => '#/foo/bar,1024/here', + '{#path:6}/here' => '#/foo/b/here', + '{#list}' => '#red,green,blue', + '{#list*}' => '#red,green,blue', + '{#keys}' => '#semi,;,dot,.,comma,,', + '{#keys*}' => '#semi=;,dot=.,comma=,', + } + end + context "label expansion (.)" do + it_behaves_like 'expands', { + '{.who}' => '.fred', + '{.who,who}' => '.fred.fred', + '{.half,who}' => '.50%25.fred', + 'www{.dom*}' => 'www.example.com', + 'X{.var}' => 'X.value', + 'X{.empty}' => 'X.', + 'X{.undef}' => 'X', + 'X{.var:3}' => 'X.val', + 'X{.list}' => 'X.red,green,blue', + 'X{.list*}' => 'X.red.green.blue', + 'X{.keys}' => 'X.semi,%3B,dot,.,comma,%2C', + 'X{.keys*}' => 'X.semi=%3B.dot=..comma=%2C', + 'X{.empty_keys}' => 'X', + 'X{.empty_keys*}' => 'X' + } + end + context "path expansion (/)" do + it_behaves_like 'expands', { + '{/who}' => '/fred', + '{/who,who}' => '/fred/fred', + '{/half,who}' => '/50%25/fred', + '{/who,dub}' => '/fred/me%2Ftoo', + '{/var}' => '/value', + '{/var,empty}' => '/value/', + '{/var,undef}' => '/value', + '{/var,x}/here' => '/value/1024/here', + '{/var:1,var}' => '/v/value', + '{/list}' => '/red,green,blue', + '{/list*}' => '/red/green/blue', + '{/list*,path:4}' => '/red/green/blue/%2Ffoo', + '{/keys}' => '/semi,%3B,dot,.,comma,%2C', + '{/keys*}' => '/semi=%3B/dot=./comma=%2C', + } + end + context "path-style expansion (;)" do + it_behaves_like 'expands', { + '{;who}' => ';who=fred', + '{;half}' => ';half=50%25', + '{;empty}' => ';empty', + '{;v,empty,who}' => ';v=6;empty;who=fred', + '{;v,bar,who}' => ';v=6;who=fred', + '{;x,y}' => ';x=1024;y=768', + '{;x,y,empty}' => ';x=1024;y=768;empty', + '{;x,y,undef}' => ';x=1024;y=768', + '{;hello:5}' => ';hello=Hello', + '{;list}' => ';list=red,green,blue', + '{;list*}' => ';list=red;list=green;list=blue', + '{;keys}' => ';keys=semi,%3B,dot,.,comma,%2C', + '{;keys*}' => ';semi=%3B;dot=.;comma=%2C', + } + end + context "form query expansion (?)" do + it_behaves_like 'expands', { + '{?who}' => '?who=fred', + '{?half}' => '?half=50%25', + '{?x,y}' => '?x=1024&y=768', + '{?x,y,empty}' => '?x=1024&y=768&empty=', + '{?x,y,undef}' => '?x=1024&y=768', + '{?var:3}' => '?var=val', + '{?list}' => '?list=red,green,blue', + '{?list*}' => '?list=red&list=green&list=blue', + '{?keys}' => '?keys=semi,%3B,dot,.,comma,%2C', + '{?keys*}' => '?semi=%3B&dot=.&comma=%2C', + } + end + context "form query expansion (&)" do + it_behaves_like 'expands', { + '{&who}' => '&who=fred', + '{&half}' => '&half=50%25', + '?fixed=yes{&x}' => '?fixed=yes&x=1024', + '{&x,y,empty}' => '&x=1024&y=768&empty=', + '{&x,y,undef}' => '&x=1024&y=768', + '{&var:3}' => '&var=val', + '{&list}' => '&list=red,green,blue', + '{&list*}' => '&list=red&list=green&list=blue', + '{&keys}' => '&keys=semi,%3B,dot,.,comma,%2C', + '{&keys*}' => '&semi=%3B&dot=.&comma=%2C', + } + end + context "non-string key in match data" do + subject {Addressable::Template.new("http://example.com/{one}")} + + it "raises TypeError" do + expect { subject.expand(Object.new => "1") }.to raise_error TypeError + end + end +end + +class ExampleTwoProcessor + def self.restore(name, value) + return value.gsub(/-/, " ") if name == "query" + return value + end + + def self.match(name) + return ".*?" if name == "first" + return ".*" + end + def self.validate(name, value) + return !!(value =~ /^[\w ]+$/) if name == "query" + return true + end + + def self.transform(name, value) + return value.gsub(/ /, "+") if name == "query" + return value + end +end + +class DumbProcessor + def self.match(name) + return ".*?" if name == "first" + end +end + +describe Addressable::Template do + describe 'initialize' do + context 'with a non-string' do + it 'raises a TypeError' do + expect { Addressable::Template.new(nil) }.to raise_error(TypeError) + end + end + end + + describe 'freeze' do + subject { Addressable::Template.new("http://example.com/{first}/{+second}/") } + it 'freezes the template' do + expect(subject.freeze).to be_frozen + end + end + + describe "Matching" do + let(:uri){ + Addressable::URI.parse( + "http://example.com/search/an-example-search-query/" + ) + } + let(:uri2){ + Addressable::URI.parse("http://example.com/a/b/c/") + } + let(:uri3){ + Addressable::URI.parse("http://example.com/;a=1;b=2;c=3;first=foo") + } + let(:uri4){ + Addressable::URI.parse("http://example.com/?a=1&b=2&c=3&first=foo") + } + let(:uri5){ + "http://example.com/foo" + } + context "first uri with ExampleTwoProcessor" do + subject { + Addressable::Template.new( + "http://example.com/search/{query}/" + ).match(uri, ExampleTwoProcessor) + } + its(:variables){ should == ["query"] } + its(:captures){ should == ["an example search query"] } + end + + context "second uri with ExampleTwoProcessor" do + subject { + Addressable::Template.new( + "http://example.com/{first}/{+second}/" + ).match(uri2, ExampleTwoProcessor) + } + its(:variables){ should == ["first", "second"] } + its(:captures){ should == ["a", "b/c"] } + end + + context "second uri with DumbProcessor" do + subject { + Addressable::Template.new( + "http://example.com/{first}/{+second}/" + ).match(uri2, DumbProcessor) + } + its(:variables){ should == ["first", "second"] } + its(:captures){ should == ["a", "b/c"] } + end + + context "second uri" do + subject { + Addressable::Template.new( + "http://example.com/{first}{/second*}/" + ).match(uri2) + } + its(:variables){ should == ["first", "second"] } + its(:captures){ should == ["a", ["b","c"]] } + end + context "third uri" do + subject { + Addressable::Template.new( + "http://example.com/{;hash*,first}" + ).match(uri3) + } + its(:variables){ should == ["hash", "first"] } + its(:captures){ should == [ + {"a" => "1", "b" => "2", "c" => "3", "first" => "foo"}, nil] } + end + # Note that this expansion is impossible to revert deterministically - the + # * operator means first could have been a key of hash or a separate key. + # Semantically, a separate key is more likely, but both are possible. + context "fourth uri" do + subject { + Addressable::Template.new( + "http://example.com/{?hash*,first}" + ).match(uri4) + } + its(:variables){ should == ["hash", "first"] } + its(:captures){ should == [ + {"a" => "1", "b" => "2", "c" => "3", "first"=> "foo"}, nil] } + end + context "fifth uri" do + subject { + Addressable::Template.new( + "http://example.com/{path}{?hash*,first}" + ).match(uri5) + } + its(:variables){ should == ["path", "hash", "first"] } + its(:captures){ should == ["foo", nil, nil] } + end + end + + describe 'match' do + subject { Addressable::Template.new('http://example.com/first/second/') } + context 'when the URI is the same as the template' do + it 'returns the match data itself with an empty mapping' do + uri = Addressable::URI.parse('http://example.com/first/second/') + match_data = subject.match(uri) + expect(match_data).to be_an Addressable::Template::MatchData + expect(match_data.uri).to eq(uri) + expect(match_data.template).to eq(subject) + expect(match_data.mapping).to be_empty + expect(match_data.inspect).to be_an String + end + end + end + + describe "extract" do + let(:template) { + Addressable::Template.new( + "http://{host}{/segments*}/{?one,two,bogus}{#fragment}" + ) + } + let(:uri){ "http://example.com/a/b/c/?one=1&two=2#foo" } + let(:uri2){ "http://example.com/a/b/c/#foo" } + it "should be able to extract with queries" do + expect(template.extract(uri)).to eq({ + "host" => "example.com", + "segments" => %w(a b c), + "one" => "1", + "bogus" => nil, + "two" => "2", + "fragment" => "foo" + }) + end + it "should be able to extract without queries" do + expect(template.extract(uri2)).to eq({ + "host" => "example.com", + "segments" => %w(a b c), + "one" => nil, + "bogus" => nil, + "two" => nil, + "fragment" => "foo" + }) + end + + context "issue #137" do + subject { Addressable::Template.new('/path{?page,per_page}') } + + it "can match empty" do + data = subject.extract("/path") + expect(data["page"]).to eq(nil) + expect(data["per_page"]).to eq(nil) + expect(data.keys.sort).to eq(['page', 'per_page']) + end + + it "can match first var" do + data = subject.extract("/path?page=1") + expect(data["page"]).to eq("1") + expect(data["per_page"]).to eq(nil) + expect(data.keys.sort).to eq(['page', 'per_page']) + end + + it "can match second var" do + data = subject.extract("/path?per_page=1") + expect(data["page"]).to eq(nil) + expect(data["per_page"]).to eq("1") + expect(data.keys.sort).to eq(['page', 'per_page']) + end + + it "can match both vars" do + data = subject.extract("/path?page=2&per_page=1") + expect(data["page"]).to eq("2") + expect(data["per_page"]).to eq("1") + expect(data.keys.sort).to eq(['page', 'per_page']) + end + end + end + + describe "Partial expand with symbols" do + context "partial_expand with two simple values" do + subject { + Addressable::Template.new("http://example.com/{one}/{two}/") + } + it "builds a new pattern" do + expect(subject.partial_expand(:one => "1").pattern).to eq( + "http://example.com/1/{two}/" + ) + end + end + context "partial_expand query with missing param in middle" do + subject { + Addressable::Template.new("http://example.com/{?one,two,three}/") + } + it "builds a new pattern" do + expect(subject.partial_expand(:one => "1", :three => "3").pattern).to eq( + "http://example.com/?one=1{&two}&three=3/" + ) + end + end + context "partial_expand form style query with missing param at beginning" do + subject { + Addressable::Template.new("http://example.com/{?one,two}/") + } + it "builds a new pattern" do + expect(subject.partial_expand(:two => "2").pattern).to eq( + "http://example.com/?two=2{&one}/" + ) + end + end + context "issue #307 - partial_expand form query with nil params" do + subject do + Addressable::Template.new("http://example.com/{?one,two,three}/") + end + it "builds a new pattern with two=nil" do + expect(subject.partial_expand(two: nil).pattern).to eq( + "http://example.com/{?one}{&three}/" + ) + end + it "builds a new pattern with one=nil and two=nil" do + expect(subject.partial_expand(one: nil, two: nil).pattern).to eq( + "http://example.com/{?three}/" + ) + end + it "builds a new pattern with one=1 and two=nil" do + expect(subject.partial_expand(one: 1, two: nil).pattern).to eq( + "http://example.com/?one=1{&three}/" + ) + end + it "builds a new pattern with one=nil and two=2" do + expect(subject.partial_expand(one: nil, two: 2).pattern).to eq( + "http://example.com/?two=2{&three}/" + ) + end + it "builds a new pattern with one=nil" do + expect(subject.partial_expand(one: nil).pattern).to eq( + "http://example.com/{?two}{&three}/" + ) + end + end + context "partial_expand with query string" do + subject { + Addressable::Template.new("http://example.com/{?two,one}/") + } + it "builds a new pattern" do + expect(subject.partial_expand(:one => "1").pattern).to eq( + "http://example.com/?one=1{&two}/" + ) + end + end + context "partial_expand with path operator" do + subject { + Addressable::Template.new("http://example.com{/one,two}/") + } + it "builds a new pattern" do + expect(subject.partial_expand(:one => "1").pattern).to eq( + "http://example.com/1{/two}/" + ) + end + end + context "partial expand with unicode values" do + subject do + Addressable::Template.new("http://example.com/{resource}/{query}/") + end + it "normalizes unicode by default" do + template = subject.partial_expand("query" => "Cafe\u0301") + expect(template.pattern).to eq( + "http://example.com/{resource}/Caf%C3%A9/" + ) + end + + it "normalizes as unicode even with wrong encoding specified" do + template = subject.partial_expand("query" => "Cafe\u0301".b) + expect(template.pattern).to eq( + "http://example.com/{resource}/Caf%C3%A9/" + ) + end + + it "raises on invalid unicode input" do + expect { + subject.partial_expand("query" => "M\xE9thode".b) + }.to raise_error(ArgumentError, "invalid byte sequence in UTF-8") + end + + it "does not normalize unicode when byte semantics requested" do + template = subject.partial_expand({"query" => "Cafe\u0301"}, nil, false) + expect(template.pattern).to eq( + "http://example.com/{resource}/Cafe%CC%81/" + ) + end + end + end + describe "Partial expand with strings" do + context "partial_expand with two simple values" do + subject { + Addressable::Template.new("http://example.com/{one}/{two}/") + } + it "builds a new pattern" do + expect(subject.partial_expand("one" => "1").pattern).to eq( + "http://example.com/1/{two}/" + ) + end + end + context "partial_expand query with missing param in middle" do + subject { + Addressable::Template.new("http://example.com/{?one,two,three}/") + } + it "builds a new pattern" do + expect(subject.partial_expand("one" => "1", "three" => "3").pattern).to eq( + "http://example.com/?one=1{&two}&three=3/" + ) + end + end + context "partial_expand with query string" do + subject { + Addressable::Template.new("http://example.com/{?two,one}/") + } + it "builds a new pattern" do + expect(subject.partial_expand("one" => "1").pattern).to eq( + "http://example.com/?one=1{&two}/" + ) + end + end + context "partial_expand with path operator" do + subject { + Addressable::Template.new("http://example.com{/one,two}/") + } + it "builds a new pattern" do + expect(subject.partial_expand("one" => "1").pattern).to eq( + "http://example.com/1{/two}/" + ) + end + end + end + describe "Expand" do + context "expand with unicode values" do + subject do + Addressable::Template.new("http://example.com/search/{query}/") + end + it "normalizes unicode by default" do + uri = subject.expand("query" => "Cafe\u0301").to_str + expect(uri).to eq("http://example.com/search/Caf%C3%A9/") + end + + it "normalizes as unicode even with wrong encoding specified" do + uri = subject.expand("query" => "Cafe\u0301".b).to_str + expect(uri).to eq("http://example.com/search/Caf%C3%A9/") + end + + it "raises on invalid unicode input" do + expect { + subject.expand("query" => "M\xE9thode".b).to_str + }.to raise_error(ArgumentError, "invalid byte sequence in UTF-8") + end + + it "does not normalize unicode when byte semantics requested" do + uri = subject.expand({ "query" => "Cafe\u0301" }, nil, false).to_str + expect(uri).to eq("http://example.com/search/Cafe%CC%81/") + end + end + context "expand with a processor" do + subject { + Addressable::Template.new("http://example.com/search/{query}/") + } + it "processes spaces" do + expect(subject.expand({"query" => "an example search query"}, + ExampleTwoProcessor).to_str).to eq( + "http://example.com/search/an+example+search+query/" + ) + end + it "validates" do + expect{ + subject.expand({"query" => "Bogus!"}, + ExampleTwoProcessor).to_str + }.to raise_error(Addressable::Template::InvalidTemplateValueError) + end + end + context "partial_expand query with missing param in middle" do + subject { + Addressable::Template.new("http://example.com/{?one,two,three}/") + } + it "builds a new pattern" do + expect(subject.partial_expand("one" => "1", "three" => "3").pattern).to eq( + "http://example.com/?one=1{&two}&three=3/" + ) + end + end + context "partial_expand with query string" do + subject { + Addressable::Template.new("http://example.com/{?two,one}/") + } + it "builds a new pattern" do + expect(subject.partial_expand("one" => "1").pattern).to eq( + "http://example.com/?one=1{&two}/" + ) + end + end + context "partial_expand with path operator" do + subject { + Addressable::Template.new("http://example.com{/one,two}/") + } + it "builds a new pattern" do + expect(subject.partial_expand("one" => "1").pattern).to eq( + "http://example.com/1{/two}/" + ) + end + end + end + context "Matching with operators" do + describe "Level 1:" do + subject { Addressable::Template.new("foo{foo}/{bar}baz") } + it "can match" do + data = subject.match("foofoo/bananabaz") + expect(data.mapping["foo"]).to eq("foo") + expect(data.mapping["bar"]).to eq("banana") + end + it "can fail" do + expect(subject.match("bar/foo")).to be_nil + expect(subject.match("foobaz")).to be_nil + end + it "can match empty" do + data = subject.match("foo/baz") + expect(data.mapping["foo"]).to eq(nil) + expect(data.mapping["bar"]).to eq(nil) + end + it "lists vars" do + expect(subject.variables).to eq(["foo", "bar"]) + end + end + + describe "Level 2:" do + subject { Addressable::Template.new("foo{+foo}{#bar}baz") } + it "can match" do + data = subject.match("foo/test/banana#bazbaz") + expect(data.mapping["foo"]).to eq("/test/banana") + expect(data.mapping["bar"]).to eq("baz") + end + it "can match empty level 2 #" do + data = subject.match("foo/test/bananabaz") + expect(data.mapping["foo"]).to eq("/test/banana") + expect(data.mapping["bar"]).to eq(nil) + data = subject.match("foo/test/banana#baz") + expect(data.mapping["foo"]).to eq("/test/banana") + expect(data.mapping["bar"]).to eq("") + end + it "can match empty level 2 +" do + data = subject.match("foobaz") + expect(data.mapping["foo"]).to eq(nil) + expect(data.mapping["bar"]).to eq(nil) + data = subject.match("foo#barbaz") + expect(data.mapping["foo"]).to eq(nil) + expect(data.mapping["bar"]).to eq("bar") + end + it "lists vars" do + expect(subject.variables).to eq(["foo", "bar"]) + end + end + + describe "Level 3:" do + context "no operator" do + subject { Addressable::Template.new("foo{foo,bar}baz") } + it "can match" do + data = subject.match("foofoo,barbaz") + expect(data.mapping["foo"]).to eq("foo") + expect(data.mapping["bar"]).to eq("bar") + end + it "lists vars" do + expect(subject.variables).to eq(["foo", "bar"]) + end + end + context "+ operator" do + subject { Addressable::Template.new("foo{+foo,bar}baz") } + it "can match" do + data = subject.match("foofoo/bar,barbaz") + expect(data.mapping["bar"]).to eq("foo/bar,bar") + expect(data.mapping["foo"]).to eq("") + end + it "lists vars" do + expect(subject.variables).to eq(["foo", "bar"]) + end + end + context ". operator" do + subject { Addressable::Template.new("foo{.foo,bar}baz") } + it "can match" do + data = subject.match("foo.foo.barbaz") + expect(data.mapping["foo"]).to eq("foo") + expect(data.mapping["bar"]).to eq("bar") + end + it "lists vars" do + expect(subject.variables).to eq(["foo", "bar"]) + end + end + context "/ operator" do + subject { Addressable::Template.new("foo{/foo,bar}baz") } + it "can match" do + data = subject.match("foo/foo/barbaz") + expect(data.mapping["foo"]).to eq("foo") + expect(data.mapping["bar"]).to eq("bar") + end + it "lists vars" do + expect(subject.variables).to eq(["foo", "bar"]) + end + end + context "; operator" do + subject { Addressable::Template.new("foo{;foo,bar,baz}baz") } + it "can match" do + data = subject.match("foo;foo=bar%20baz;bar=foo;bazbaz") + expect(data.mapping["foo"]).to eq("bar baz") + expect(data.mapping["bar"]).to eq("foo") + expect(data.mapping["baz"]).to eq("") + end + it "lists vars" do + expect(subject.variables).to eq(%w(foo bar baz)) + end + end + context "? operator" do + context "test" do + subject { Addressable::Template.new("foo{?foo,bar}baz") } + it "can match" do + data = subject.match("foo?foo=bar%20baz&bar=foobaz") + expect(data.mapping["foo"]).to eq("bar baz") + expect(data.mapping["bar"]).to eq("foo") + end + it "lists vars" do + expect(subject.variables).to eq(%w(foo bar)) + end + end + + context "issue #137" do + subject { Addressable::Template.new('/path{?page,per_page}') } + + it "can match empty" do + data = subject.match("/path") + expect(data.mapping["page"]).to eq(nil) + expect(data.mapping["per_page"]).to eq(nil) + expect(data.mapping.keys.sort).to eq(['page', 'per_page']) + end + + it "can match first var" do + data = subject.match("/path?page=1") + expect(data.mapping["page"]).to eq("1") + expect(data.mapping["per_page"]).to eq(nil) + expect(data.mapping.keys.sort).to eq(['page', 'per_page']) + end + + it "can match second var" do + data = subject.match("/path?per_page=1") + expect(data.mapping["page"]).to eq(nil) + expect(data.mapping["per_page"]).to eq("1") + expect(data.mapping.keys.sort).to eq(['page', 'per_page']) + end + + it "can match both vars" do + data = subject.match("/path?page=2&per_page=1") + expect(data.mapping["page"]).to eq("2") + expect(data.mapping["per_page"]).to eq("1") + expect(data.mapping.keys.sort).to eq(['page', 'per_page']) + end + end + + context "issue #71" do + subject { Addressable::Template.new("http://cyberscore.dev/api/users{?username}") } + it "can match" do + data = subject.match("http://cyberscore.dev/api/users?username=foobaz") + expect(data.mapping["username"]).to eq("foobaz") + end + it "lists vars" do + expect(subject.variables).to eq(%w(username)) + expect(subject.keys).to eq(%w(username)) + end + end + end + context "& operator" do + subject { Addressable::Template.new("foo{&foo,bar}baz") } + it "can match" do + data = subject.match("foo&foo=bar%20baz&bar=foobaz") + expect(data.mapping["foo"]).to eq("bar baz") + expect(data.mapping["bar"]).to eq("foo") + end + it "lists vars" do + expect(subject.variables).to eq(%w(foo bar)) + end + end + end + end + + context "support regexes:" do + context "EXPRESSION" do + subject { Addressable::Template::EXPRESSION } + it "should be able to match an expression" do + expect(subject).to match("{foo}") + expect(subject).to match("{foo,9}") + expect(subject).to match("{foo.bar,baz}") + expect(subject).to match("{+foo.bar,baz}") + expect(subject).to match("{foo,foo%20bar}") + expect(subject).to match("{#foo:20,baz*}") + expect(subject).to match("stuff{#foo:20,baz*}things") + end + it "should fail on non vars" do + expect(subject).not_to match("!{foo") + expect(subject).not_to match("{foo.bar.}") + expect(subject).not_to match("!{}") + end + end + context "VARNAME" do + subject { Addressable::Template::VARNAME } + it "should be able to match a variable" do + expect(subject).to match("foo") + expect(subject).to match("9") + expect(subject).to match("foo.bar") + expect(subject).to match("foo_bar") + expect(subject).to match("foo_bar.baz") + expect(subject).to match("foo%20bar") + expect(subject).to match("foo%20bar.baz") + end + it "should fail on non vars" do + expect(subject).not_to match("!foo") + expect(subject).not_to match("foo.bar.") + expect(subject).not_to match("foo%2%00bar") + expect(subject).not_to match("foo_ba%r") + expect(subject).not_to match("foo_bar*") + expect(subject).not_to match("foo_bar:20") + end + + it 'should parse in a reasonable time' do + expect do + Timeout.timeout(0.1) do + expect(subject).not_to match("0"*25 + "!") + end + end.not_to raise_error + end + end + context "VARIABLE_LIST" do + subject { Addressable::Template::VARIABLE_LIST } + it "should be able to match a variable list" do + expect(subject).to match("foo,bar") + expect(subject).to match("foo") + expect(subject).to match("foo,bar*,baz") + expect(subject).to match("foo.bar,bar_baz*,baz:12") + end + it "should fail on non vars" do + expect(subject).not_to match(",foo,bar*,baz") + expect(subject).not_to match("foo,*bar,baz") + expect(subject).not_to match("foo,,bar*,baz") + end + end + context "VARSPEC" do + subject { Addressable::Template::VARSPEC } + it "should be able to match a variable with modifier" do + expect(subject).to match("9:8") + expect(subject).to match("foo.bar*") + expect(subject).to match("foo_bar:12") + expect(subject).to match("foo_bar.baz*") + expect(subject).to match("foo%20bar:12") + expect(subject).to match("foo%20bar.baz*") + end + it "should fail on non vars" do + expect(subject).not_to match("!foo") + expect(subject).not_to match("*foo") + expect(subject).not_to match("fo*o") + expect(subject).not_to match("fo:o") + expect(subject).not_to match("foo:") + end + end + end +end + +describe Addressable::Template::MatchData do + let(:template) { Addressable::Template.new('{foo}/{bar}') } + subject(:its) { template.match('ab/cd') } + its(:uri) { should == Addressable::URI.parse('ab/cd') } + its(:template) { should == template } + its(:mapping) { should == { 'foo' => 'ab', 'bar' => 'cd' } } + its(:variables) { should == ['foo', 'bar'] } + its(:keys) { should == ['foo', 'bar'] } + its(:names) { should == ['foo', 'bar'] } + its(:values) { should == ['ab', 'cd'] } + its(:captures) { should == ['ab', 'cd'] } + its(:to_a) { should == ['ab/cd', 'ab', 'cd'] } + its(:to_s) { should == 'ab/cd' } + its(:string) { should == its.to_s } + its(:pre_match) { should == "" } + its(:post_match) { should == "" } + + describe 'values_at' do + it 'returns an array with the values' do + expect(its.values_at(0, 2)).to eq(['ab/cd', 'cd']) + end + it 'allows mixing integer an string keys' do + expect(its.values_at('foo', 1)).to eq(['ab', 'ab']) + end + it 'accepts unknown keys' do + expect(its.values_at('baz', 'foo')).to eq([nil, 'ab']) + end + end + + describe '[]' do + context 'string key' do + it 'returns the corresponding capture' do + expect(its['foo']).to eq('ab') + expect(its['bar']).to eq('cd') + end + it 'returns nil for unknown keys' do + expect(its['baz']).to be_nil + end + end + context 'symbol key' do + it 'returns the corresponding capture' do + expect(its[:foo]).to eq('ab') + expect(its[:bar]).to eq('cd') + end + it 'returns nil for unknown keys' do + expect(its[:baz]).to be_nil + end + end + context 'integer key' do + it 'returns the full URI for index 0' do + expect(its[0]).to eq('ab/cd') + end + it 'returns the corresponding capture' do + expect(its[1]).to eq('ab') + expect(its[2]).to eq('cd') + end + it 'returns nil for unknown keys' do + expect(its[3]).to be_nil + end + end + context 'other key' do + it 'raises an exception' do + expect { its[Object.new] }.to raise_error(TypeError) + end + end + context 'with length' do + it 'returns an array starting at index with given length' do + expect(its[0, 2]).to eq(['ab/cd', 'ab']) + expect(its[2, 1]).to eq(['cd']) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/uri_spec.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/uri_spec.rb new file mode 100644 index 0000000..26ee923 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/addressable/uri_spec.rb @@ -0,0 +1,6840 @@ +# frozen_string_literal: true + +# Copyright (C) Bob Aman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +require "spec_helper" + +require "addressable/uri" +require "uri" +require "ipaddr" +require "yaml" + +if !"".respond_to?("force_encoding") + class String + def force_encoding(encoding) + @encoding = encoding + end + + def encoding + @encoding ||= Encoding::ASCII_8BIT + end + end + + class Encoding + def initialize(name) + @name = name + end + + def to_s + return @name + end + + UTF_8 = Encoding.new("UTF-8") + ASCII_8BIT = Encoding.new("US-ASCII") + end +end + +module Fake + module URI + class HTTP + def initialize(uri) + @uri = uri + end + + def to_s + return @uri.to_s + end + + alias :to_str :to_s + end + end +end + +describe Addressable::URI, "when created with a non-numeric port number" do + it "should raise an error" do + expect do + Addressable::URI.new(:port => "bogus") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with a invalid encoded port number" do + it "should raise an error" do + expect do + Addressable::URI.new(:port => "%eb") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with a non-string scheme" do + it "should raise an error" do + expect do + Addressable::URI.new(:scheme => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string user" do + it "should raise an error" do + expect do + Addressable::URI.new(:user => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string password" do + it "should raise an error" do + expect do + Addressable::URI.new(:password => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string userinfo" do + it "should raise an error" do + expect do + Addressable::URI.new(:userinfo => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string host" do + it "should raise an error" do + expect do + Addressable::URI.new(:host => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string authority" do + it "should raise an error" do + expect do + Addressable::URI.new(:authority => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string path" do + it "should raise an error" do + expect do + Addressable::URI.new(:path => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string query" do + it "should raise an error" do + expect do + Addressable::URI.new(:query => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a non-string fragment" do + it "should raise an error" do + expect do + Addressable::URI.new(:fragment => :bogus) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when created with a scheme but no hierarchical " + + "segment" do + it "should raise an error" do + expect do + Addressable::URI.parse("http:") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "quote handling" do + describe 'in host name' do + it "should raise an error for single quote" do + expect do + Addressable::URI.parse("http://local\"host/") + end.to raise_error(Addressable::URI::InvalidURIError) + end + end +end + +describe Addressable::URI, "newline normalization" do + it "should not accept newlines in scheme" do + expect do + Addressable::URI.parse("ht%0atp://localhost/") + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should not unescape newline in path" do + uri = Addressable::URI.parse("http://localhost/%0a").normalize + expect(uri.to_s).to eq("http://localhost/%0A") + end + + it "should not unescape newline in hostname" do + uri = Addressable::URI.parse("http://local%0ahost/").normalize + expect(uri.to_s).to eq("http://local%0Ahost/") + end + + it "should not unescape newline in username" do + uri = Addressable::URI.parse("http://foo%0abar@localhost/").normalize + expect(uri.to_s).to eq("http://foo%0Abar@localhost/") + end + + it "should not unescape newline in username" do + uri = Addressable::URI.parse("http://example:foo%0abar@example/").normalize + expect(uri.to_s).to eq("http://example:foo%0Abar@example/") + end + + it "should not accept newline in hostname" do + uri = Addressable::URI.parse("http://localhost/") + expect do + uri.host = "local\nhost" + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with ambiguous path" do + it "should raise an error" do + expect do + Addressable::URI.parse("::http") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with an invalid host" do + it "should raise an error" do + expect do + Addressable::URI.new(:host => "") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with a host consisting of " + + "sub-delims characters" do + it "should not raise an error" do + expect do + Addressable::URI.new( + :host => Addressable::URI::CharacterClasses::SUB_DELIMS.gsub(/\\/, '') + ) + end.not_to raise_error + end +end + +describe Addressable::URI, "when created with a host consisting of " + + "unreserved characters" do + it "should not raise an error" do + expect do + Addressable::URI.new( + :host => Addressable::URI::CharacterClasses::UNRESERVED.gsub(/\\/, '') + ) + end.not_to raise_error + end +end + +describe Addressable::URI, "when created from nil components" do + before do + @uri = Addressable::URI.new + end + + it "should have a nil site value" do + expect(@uri.site).to eq(nil) + end + + it "should have an empty path" do + expect(@uri.path).to eq("") + end + + it "should be an empty uri" do + expect(@uri.to_s).to eq("") + end + + it "should have a nil default port" do + expect(@uri.default_port).to eq(nil) + end + + it "should be empty" do + expect(@uri).to be_empty + end + + it "should raise an error if the scheme is set to whitespace" do + expect do + @uri.scheme = "\t \n" + end.to raise_error(Addressable::URI::InvalidURIError, /'\t \n'/) + end + + it "should raise an error if the scheme is set to all digits" do + expect do + @uri.scheme = "123" + end.to raise_error(Addressable::URI::InvalidURIError, /'123'/) + end + + it "should raise an error if the scheme begins with a digit" do + expect do + @uri.scheme = "1scheme" + end.to raise_error(Addressable::URI::InvalidURIError, /'1scheme'/) + end + + it "should raise an error if the scheme begins with a plus" do + expect do + @uri.scheme = "+scheme" + end.to raise_error(Addressable::URI::InvalidURIError, /'\+scheme'/) + end + + it "should raise an error if the scheme begins with a dot" do + expect do + @uri.scheme = ".scheme" + end.to raise_error(Addressable::URI::InvalidURIError, /'\.scheme'/) + end + + it "should raise an error if the scheme begins with a dash" do + expect do + @uri.scheme = "-scheme" + end.to raise_error(Addressable::URI::InvalidURIError, /'-scheme'/) + end + + it "should raise an error if the scheme contains an illegal character" do + expect do + @uri.scheme = "scheme!" + end.to raise_error(Addressable::URI::InvalidURIError, /'scheme!'/) + end + + it "should raise an error if the scheme contains whitespace" do + expect do + @uri.scheme = "sch eme" + end.to raise_error(Addressable::URI::InvalidURIError, /'sch eme'/) + end + + it "should raise an error if the scheme contains a newline" do + expect do + @uri.scheme = "sch\neme" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should raise an error if set into an invalid state" do + expect do + @uri.user = "user" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should raise an error if set into an invalid state" do + expect do + @uri.password = "pass" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should raise an error if set into an invalid state" do + expect do + @uri.scheme = "http" + @uri.fragment = "fragment" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should raise an error if set into an invalid state" do + expect do + @uri.fragment = "fragment" + @uri.scheme = "http" + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when initialized from individual components" do + before do + @uri = Addressable::URI.new( + :scheme => "http", + :user => "user", + :password => "password", + :host => "example.com", + :port => 8080, + :path => "/path", + :query => "query=value", + :fragment => "fragment" + ) + end + + it "returns 'http' for #scheme" do + expect(@uri.scheme).to eq("http") + end + + it "returns 'http' for #normalized_scheme" do + expect(@uri.normalized_scheme).to eq("http") + end + + it "returns 'user' for #user" do + expect(@uri.user).to eq("user") + end + + it "returns 'user' for #normalized_user" do + expect(@uri.normalized_user).to eq("user") + end + + it "returns 'password' for #password" do + expect(@uri.password).to eq("password") + end + + it "returns 'password' for #normalized_password" do + expect(@uri.normalized_password).to eq("password") + end + + it "returns 'user:password' for #userinfo" do + expect(@uri.userinfo).to eq("user:password") + end + + it "returns 'user:password' for #normalized_userinfo" do + expect(@uri.normalized_userinfo).to eq("user:password") + end + + it "returns 'example.com' for #host" do + expect(@uri.host).to eq("example.com") + end + + it "returns 'example.com' for #normalized_host" do + expect(@uri.normalized_host).to eq("example.com") + end + + it "returns 'com' for #tld" do + expect(@uri.tld).to eq("com") + end + + it "returns 'user:password@example.com:8080' for #authority" do + expect(@uri.authority).to eq("user:password@example.com:8080") + end + + it "returns 'user:password@example.com:8080' for #normalized_authority" do + expect(@uri.normalized_authority).to eq("user:password@example.com:8080") + end + + it "returns 8080 for #port" do + expect(@uri.port).to eq(8080) + end + + it "returns 8080 for #normalized_port" do + expect(@uri.normalized_port).to eq(8080) + end + + it "returns 80 for #default_port" do + expect(@uri.default_port).to eq(80) + end + + it "returns 'http://user:password@example.com:8080' for #site" do + expect(@uri.site).to eq("http://user:password@example.com:8080") + end + + it "returns 'http://user:password@example.com:8080' for #normalized_site" do + expect(@uri.normalized_site).to eq("http://user:password@example.com:8080") + end + + it "returns '/path' for #path" do + expect(@uri.path).to eq("/path") + end + + it "returns '/path' for #normalized_path" do + expect(@uri.normalized_path).to eq("/path") + end + + it "returns 'query=value' for #query" do + expect(@uri.query).to eq("query=value") + end + + it "returns 'query=value' for #normalized_query" do + expect(@uri.normalized_query).to eq("query=value") + end + + it "returns 'fragment' for #fragment" do + expect(@uri.fragment).to eq("fragment") + end + + it "returns 'fragment' for #normalized_fragment" do + expect(@uri.normalized_fragment).to eq("fragment") + end + + it "returns #hash" do + expect(@uri.hash).not_to be nil + end + + it "returns #to_s" do + expect(@uri.to_s).to eq( + "http://user:password@example.com:8080/path?query=value#fragment" + ) + end + + it "should not be empty" do + expect(@uri).not_to be_empty + end + + it "should not be frozen" do + expect(@uri).not_to be_frozen + end + + it "should allow destructive operations" do + expect { @uri.normalize! }.not_to raise_error + end +end + +describe Addressable::URI, "when initialized from " + + "frozen individual components" do + before do + @uri = Addressable::URI.new( + :scheme => "http".freeze, + :user => "user".freeze, + :password => "password".freeze, + :host => "example.com".freeze, + :port => "8080".freeze, + :path => "/path".freeze, + :query => "query=value".freeze, + :fragment => "fragment".freeze + ) + end + + it "returns 'http' for #scheme" do + expect(@uri.scheme).to eq("http") + end + + it "returns 'http' for #normalized_scheme" do + expect(@uri.normalized_scheme).to eq("http") + end + + it "returns 'user' for #user" do + expect(@uri.user).to eq("user") + end + + it "returns 'user' for #normalized_user" do + expect(@uri.normalized_user).to eq("user") + end + + it "returns 'password' for #password" do + expect(@uri.password).to eq("password") + end + + it "returns 'password' for #normalized_password" do + expect(@uri.normalized_password).to eq("password") + end + + it "returns 'user:password' for #userinfo" do + expect(@uri.userinfo).to eq("user:password") + end + + it "returns 'user:password' for #normalized_userinfo" do + expect(@uri.normalized_userinfo).to eq("user:password") + end + + it "returns 'example.com' for #host" do + expect(@uri.host).to eq("example.com") + end + + it "returns 'example.com' for #normalized_host" do + expect(@uri.normalized_host).to eq("example.com") + end + + it "returns 'user:password@example.com:8080' for #authority" do + expect(@uri.authority).to eq("user:password@example.com:8080") + end + + it "returns 'user:password@example.com:8080' for #normalized_authority" do + expect(@uri.normalized_authority).to eq("user:password@example.com:8080") + end + + it "returns 8080 for #port" do + expect(@uri.port).to eq(8080) + end + + it "returns 8080 for #normalized_port" do + expect(@uri.normalized_port).to eq(8080) + end + + it "returns 80 for #default_port" do + expect(@uri.default_port).to eq(80) + end + + it "returns 'http://user:password@example.com:8080' for #site" do + expect(@uri.site).to eq("http://user:password@example.com:8080") + end + + it "returns 'http://user:password@example.com:8080' for #normalized_site" do + expect(@uri.normalized_site).to eq("http://user:password@example.com:8080") + end + + it "returns '/path' for #path" do + expect(@uri.path).to eq("/path") + end + + it "returns '/path' for #normalized_path" do + expect(@uri.normalized_path).to eq("/path") + end + + it "returns 'query=value' for #query" do + expect(@uri.query).to eq("query=value") + end + + it "returns 'query=value' for #normalized_query" do + expect(@uri.normalized_query).to eq("query=value") + end + + it "returns 'fragment' for #fragment" do + expect(@uri.fragment).to eq("fragment") + end + + it "returns 'fragment' for #normalized_fragment" do + expect(@uri.normalized_fragment).to eq("fragment") + end + + it "returns #hash" do + expect(@uri.hash).not_to be nil + end + + it "returns #to_s" do + expect(@uri.to_s).to eq( + "http://user:password@example.com:8080/path?query=value#fragment" + ) + end + + it "should not be empty" do + expect(@uri).not_to be_empty + end + + it "should not be frozen" do + expect(@uri).not_to be_frozen + end + + it "should allow destructive operations" do + expect { @uri.normalize! }.not_to raise_error + end +end + +describe Addressable::URI, "when parsed from a frozen string" do + before do + @uri = Addressable::URI.parse( + "http://user:password@example.com:8080/path?query=value#fragment".freeze + ) + end + + it "returns 'http' for #scheme" do + expect(@uri.scheme).to eq("http") + end + + it "returns 'http' for #normalized_scheme" do + expect(@uri.normalized_scheme).to eq("http") + end + + it "returns 'user' for #user" do + expect(@uri.user).to eq("user") + end + + it "returns 'user' for #normalized_user" do + expect(@uri.normalized_user).to eq("user") + end + + it "returns 'password' for #password" do + expect(@uri.password).to eq("password") + end + + it "returns 'password' for #normalized_password" do + expect(@uri.normalized_password).to eq("password") + end + + it "returns 'user:password' for #userinfo" do + expect(@uri.userinfo).to eq("user:password") + end + + it "returns 'user:password' for #normalized_userinfo" do + expect(@uri.normalized_userinfo).to eq("user:password") + end + + it "returns 'example.com' for #host" do + expect(@uri.host).to eq("example.com") + end + + it "returns 'example.com' for #normalized_host" do + expect(@uri.normalized_host).to eq("example.com") + end + + it "returns 'user:password@example.com:8080' for #authority" do + expect(@uri.authority).to eq("user:password@example.com:8080") + end + + it "returns 'user:password@example.com:8080' for #normalized_authority" do + expect(@uri.normalized_authority).to eq("user:password@example.com:8080") + end + + it "returns 8080 for #port" do + expect(@uri.port).to eq(8080) + end + + it "returns 8080 for #normalized_port" do + expect(@uri.normalized_port).to eq(8080) + end + + it "returns 80 for #default_port" do + expect(@uri.default_port).to eq(80) + end + + it "returns 'http://user:password@example.com:8080' for #site" do + expect(@uri.site).to eq("http://user:password@example.com:8080") + end + + it "returns 'http://user:password@example.com:8080' for #normalized_site" do + expect(@uri.normalized_site).to eq("http://user:password@example.com:8080") + end + + it "returns '/path' for #path" do + expect(@uri.path).to eq("/path") + end + + it "returns '/path' for #normalized_path" do + expect(@uri.normalized_path).to eq("/path") + end + + it "returns 'query=value' for #query" do + expect(@uri.query).to eq("query=value") + end + + it "returns 'query=value' for #normalized_query" do + expect(@uri.normalized_query).to eq("query=value") + end + + it "returns 'fragment' for #fragment" do + expect(@uri.fragment).to eq("fragment") + end + + it "returns 'fragment' for #normalized_fragment" do + expect(@uri.normalized_fragment).to eq("fragment") + end + + it "returns #hash" do + expect(@uri.hash).not_to be nil + end + + it "returns #to_s" do + expect(@uri.to_s).to eq( + "http://user:password@example.com:8080/path?query=value#fragment" + ) + end + + it "should not be empty" do + expect(@uri).not_to be_empty + end + + it "should not be frozen" do + expect(@uri).not_to be_frozen + end + + it "should allow destructive operations" do + expect { @uri.normalize! }.not_to raise_error + end +end + +describe Addressable::URI, "when frozen" do + before do + @uri = Addressable::URI.new.freeze + end + + it "returns nil for #scheme" do + expect(@uri.scheme).to eq(nil) + end + + it "returns nil for #normalized_scheme" do + expect(@uri.normalized_scheme).to eq(nil) + end + + it "returns nil for #user" do + expect(@uri.user).to eq(nil) + end + + it "returns nil for #normalized_user" do + expect(@uri.normalized_user).to eq(nil) + end + + it "returns nil for #password" do + expect(@uri.password).to eq(nil) + end + + it "returns nil for #normalized_password" do + expect(@uri.normalized_password).to eq(nil) + end + + it "returns nil for #userinfo" do + expect(@uri.userinfo).to eq(nil) + end + + it "returns nil for #normalized_userinfo" do + expect(@uri.normalized_userinfo).to eq(nil) + end + + it "returns nil for #host" do + expect(@uri.host).to eq(nil) + end + + it "returns nil for #normalized_host" do + expect(@uri.normalized_host).to eq(nil) + end + + it "returns nil for #authority" do + expect(@uri.authority).to eq(nil) + end + + it "returns nil for #normalized_authority" do + expect(@uri.normalized_authority).to eq(nil) + end + + it "returns nil for #port" do + expect(@uri.port).to eq(nil) + end + + it "returns nil for #normalized_port" do + expect(@uri.normalized_port).to eq(nil) + end + + it "returns nil for #default_port" do + expect(@uri.default_port).to eq(nil) + end + + it "returns nil for #site" do + expect(@uri.site).to eq(nil) + end + + it "returns nil for #normalized_site" do + expect(@uri.normalized_site).to eq(nil) + end + + it "returns '' for #path" do + expect(@uri.path).to eq('') + end + + it "returns '' for #normalized_path" do + expect(@uri.normalized_path).to eq('') + end + + it "returns nil for #query" do + expect(@uri.query).to eq(nil) + end + + it "returns nil for #normalized_query" do + expect(@uri.normalized_query).to eq(nil) + end + + it "returns nil for #fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "returns nil for #normalized_fragment" do + expect(@uri.normalized_fragment).to eq(nil) + end + + it "returns #hash" do + expect(@uri.hash).not_to be nil + end + + it "returns #to_s" do + expect(@uri.to_s).to eq('') + end + + it "should be empty" do + expect(@uri).to be_empty + end + + it "should be frozen" do + expect(@uri).to be_frozen + end + + it "should not be frozen after duping" do + expect(@uri.dup).not_to be_frozen + end + + it "should not allow destructive operations" do + expect { @uri.normalize! }.to raise_error { |error| + expect(error.message).to match(/can't modify frozen/) + expect(error).to satisfy { |e| RuntimeError === e || TypeError === e } + } + end +end + +describe Addressable::URI, "when frozen" do + before do + @uri = Addressable::URI.parse( + "HTTP://example.com.:%38%30/%70a%74%68?a=%31#1%323" + ).freeze + end + + it "returns 'HTTP' for #scheme" do + expect(@uri.scheme).to eq("HTTP") + end + + it "returns 'http' for #normalized_scheme" do + expect(@uri.normalized_scheme).to eq("http") + expect(@uri.normalize.scheme).to eq("http") + end + + it "returns nil for #user" do + expect(@uri.user).to eq(nil) + end + + it "returns nil for #normalized_user" do + expect(@uri.normalized_user).to eq(nil) + end + + it "returns nil for #password" do + expect(@uri.password).to eq(nil) + end + + it "returns nil for #normalized_password" do + expect(@uri.normalized_password).to eq(nil) + end + + it "returns nil for #userinfo" do + expect(@uri.userinfo).to eq(nil) + end + + it "returns nil for #normalized_userinfo" do + expect(@uri.normalized_userinfo).to eq(nil) + end + + it "returns 'example.com.' for #host" do + expect(@uri.host).to eq("example.com.") + end + + it "returns nil for #normalized_host" do + expect(@uri.normalized_host).to eq("example.com") + expect(@uri.normalize.host).to eq("example.com") + end + + it "returns 'example.com.:80' for #authority" do + expect(@uri.authority).to eq("example.com.:80") + end + + it "returns 'example.com:80' for #normalized_authority" do + expect(@uri.normalized_authority).to eq("example.com") + expect(@uri.normalize.authority).to eq("example.com") + end + + it "returns 80 for #port" do + expect(@uri.port).to eq(80) + end + + it "returns nil for #normalized_port" do + expect(@uri.normalized_port).to eq(nil) + expect(@uri.normalize.port).to eq(nil) + end + + it "returns 80 for #default_port" do + expect(@uri.default_port).to eq(80) + end + + it "returns 'HTTP://example.com.:80' for #site" do + expect(@uri.site).to eq("HTTP://example.com.:80") + end + + it "returns 'http://example.com' for #normalized_site" do + expect(@uri.normalized_site).to eq("http://example.com") + expect(@uri.normalize.site).to eq("http://example.com") + end + + it "returns '/%70a%74%68' for #path" do + expect(@uri.path).to eq("/%70a%74%68") + end + + it "returns '/path' for #normalized_path" do + expect(@uri.normalized_path).to eq("/path") + expect(@uri.normalize.path).to eq("/path") + end + + it "returns 'a=%31' for #query" do + expect(@uri.query).to eq("a=%31") + end + + it "returns 'a=1' for #normalized_query" do + expect(@uri.normalized_query).to eq("a=1") + expect(@uri.normalize.query).to eq("a=1") + end + + it "returns '/%70a%74%68?a=%31' for #request_uri" do + expect(@uri.request_uri).to eq("/%70a%74%68?a=%31") + end + + it "returns '1%323' for #fragment" do + expect(@uri.fragment).to eq("1%323") + end + + it "returns '123' for #normalized_fragment" do + expect(@uri.normalized_fragment).to eq("123") + expect(@uri.normalize.fragment).to eq("123") + end + + it "returns #hash" do + expect(@uri.hash).not_to be nil + end + + it "returns #to_s" do + expect(@uri.to_s).to eq('HTTP://example.com.:80/%70a%74%68?a=%31#1%323') + expect(@uri.normalize.to_s).to eq('http://example.com/path?a=1#123') + end + + it "should not be empty" do + expect(@uri).not_to be_empty + end + + it "should be frozen" do + expect(@uri).to be_frozen + end + + it "should not be frozen after duping" do + expect(@uri.dup).not_to be_frozen + end + + it "should not allow destructive operations" do + expect { @uri.normalize! }.to raise_error { |error| + expect(error.message).to match(/can't modify frozen/) + expect(error).to satisfy { |e| RuntimeError === e || TypeError === e } + } + end +end + +describe Addressable::URI, "when normalized and then deeply frozen" do + before do + @uri = Addressable::URI.parse( + "http://user:password@example.com:8080/path?query=value#fragment" + ).normalize! + + @uri.instance_variables.each do |var| + @uri.instance_variable_set(var, @uri.instance_variable_get(var).freeze) + end + + @uri.freeze + end + + it "#normalized_scheme should not error" do + expect { @uri.normalized_scheme }.not_to raise_error + end + + it "#normalized_user should not error" do + expect { @uri.normalized_user }.not_to raise_error + end + + it "#normalized_password should not error" do + expect { @uri.normalized_password }.not_to raise_error + end + + it "#normalized_userinfo should not error" do + expect { @uri.normalized_userinfo }.not_to raise_error + end + + it "#normalized_host should not error" do + expect { @uri.normalized_host }.not_to raise_error + end + + it "#normalized_authority should not error" do + expect { @uri.normalized_authority }.not_to raise_error + end + + it "#normalized_port should not error" do + expect { @uri.normalized_port }.not_to raise_error + end + + it "#normalized_site should not error" do + expect { @uri.normalized_site }.not_to raise_error + end + + it "#normalized_path should not error" do + expect { @uri.normalized_path }.not_to raise_error + end + + it "#normalized_query should not error" do + expect { @uri.normalized_query }.not_to raise_error + end + + it "#normalized_fragment should not error" do + expect { @uri.normalized_fragment }.not_to raise_error + end + + it "should be frozen" do + expect(@uri).to be_frozen + end + + it "should not allow destructive operations" do + expect { @uri.normalize! }.to raise_error(RuntimeError) + end +end + +describe Addressable::URI, "when created from string components" do + before do + @uri = Addressable::URI.new( + :scheme => "http", :host => "example.com" + ) + end + + it "should have a site value of 'http://example.com'" do + expect(@uri.site).to eq("http://example.com") + end + + it "should be equal to the equivalent parsed URI" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com")) + end + + it "should raise an error if invalid components omitted" do + expect do + @uri.omit(:bogus) + end.to raise_error(ArgumentError) + expect do + @uri.omit(:scheme, :bogus, :path) + end.to raise_error(ArgumentError) + end +end + +describe Addressable::URI, "when created with a nil host but " + + "non-nil authority components" do + it "should raise an error" do + expect do + Addressable::URI.new(:user => "user", :password => "pass", :port => 80) + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with both an authority and a user" do + it "should raise an error" do + expect do + Addressable::URI.new( + :user => "user", :authority => "user@example.com:80" + ) + end.to raise_error(ArgumentError) + end +end + +describe Addressable::URI, "when created with an authority and no port" do + before do + @uri = Addressable::URI.new(:authority => "user@example.com") + end + + it "should not infer a port" do + expect(@uri.port).to eq(nil) + expect(@uri.default_port).to eq(nil) + expect(@uri.inferred_port).to eq(nil) + end + + it "should have a site value of '//user@example.com'" do + expect(@uri.site).to eq("//user@example.com") + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when created with a host with trailing dots" do + before do + @uri = Addressable::URI.new(:authority => "example...") + end + + it "should have a stable normalized form" do + expect(@uri.normalize.normalize.normalize.host).to eq( + @uri.normalize.host + ) + end +end + +describe Addressable::URI, "when created with a host with a backslash" do + it "should raise an error" do + expect do + Addressable::URI.new(:authority => "example\\example") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with a host with a slash" do + it "should raise an error" do + expect do + Addressable::URI.new(:authority => "example/example") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with a host with a space" do + it "should raise an error" do + expect do + Addressable::URI.new(:authority => "example example") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when created with both a userinfo and a user" do + it "should raise an error" do + expect do + Addressable::URI.new(:user => "user", :userinfo => "user:pass") + end.to raise_error(ArgumentError) + end +end + +describe Addressable::URI, "when created with a path that hasn't been " + + "prefixed with a '/' but a host specified" do + before do + @uri = Addressable::URI.new( + :scheme => "http", :host => "example.com", :path => "path" + ) + end + + it "should prefix a '/' to the path" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com/path")) + end + + it "should have a site value of 'http://example.com'" do + expect(@uri.site).to eq("http://example.com") + end + + it "should have an origin of 'http://example.com" do + expect(@uri.origin).to eq('http://example.com') + end +end + +describe Addressable::URI, "when created with a path that hasn't been " + + "prefixed with a '/' but no host specified" do + before do + @uri = Addressable::URI.new( + :scheme => "http", :path => "path" + ) + end + + it "should not prefix a '/' to the path" do + expect(@uri).to eq(Addressable::URI.parse("http:path")) + end + + it "should have a site value of 'http:'" do + expect(@uri.site).to eq("http:") + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from an Addressable::URI object" do + it "should not have unexpected side-effects" do + original_uri = Addressable::URI.parse("http://example.com/") + new_uri = Addressable::URI.parse(original_uri) + new_uri.host = 'www.example.com' + expect(new_uri.host).to eq('www.example.com') + expect(new_uri.to_s).to eq('http://www.example.com/') + expect(original_uri.host).to eq('example.com') + expect(original_uri.to_s).to eq('http://example.com/') + end + + it "should not have unexpected side-effects" do + original_uri = Addressable::URI.parse("http://example.com/") + new_uri = Addressable::URI.heuristic_parse(original_uri) + new_uri.host = 'www.example.com' + expect(new_uri.host).to eq('www.example.com') + expect(new_uri.to_s).to eq('http://www.example.com/') + expect(original_uri.host).to eq('example.com') + expect(original_uri.to_s).to eq('http://example.com/') + end + + it "should not have unexpected side-effects" do + original_uri = Addressable::URI.parse("http://example.com/") + new_uri = Addressable::URI.parse(original_uri) + new_uri.origin = 'https://www.example.com:8080' + expect(new_uri.host).to eq('www.example.com') + expect(new_uri.to_s).to eq('https://www.example.com:8080/') + expect(original_uri.host).to eq('example.com') + expect(original_uri.to_s).to eq('http://example.com/') + end + + it "should not have unexpected side-effects" do + original_uri = Addressable::URI.parse("http://example.com/") + new_uri = Addressable::URI.heuristic_parse(original_uri) + new_uri.origin = 'https://www.example.com:8080' + expect(new_uri.host).to eq('www.example.com') + expect(new_uri.to_s).to eq('https://www.example.com:8080/') + expect(original_uri.host).to eq('example.com') + expect(original_uri.to_s).to eq('http://example.com/') + end +end + +describe Addressable::URI, "when parsed from something that looks " + + "like a URI object" do + it "should parse without error" do + uri = Addressable::URI.parse(Fake::URI::HTTP.new("http://example.com/")) + expect do + Addressable::URI.parse(uri) + end.not_to raise_error + end +end + +describe Addressable::URI, "when parsed from a standard library URI object" do + it "should parse without error" do + uri = Addressable::URI.parse(URI.parse("http://example.com/")) + expect do + Addressable::URI.parse(uri) + end.not_to raise_error + end +end + +describe Addressable::URI, "when parsed from ''" do + before do + @uri = Addressable::URI.parse("") + end + + it "should have no scheme" do + expect(@uri.scheme).to eq(nil) + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should have a path of ''" do + expect(@uri.path).to eq("") + end + + it "should have a request URI of '/'" do + expect(@uri.request_uri).to eq("/") + end + + it "should be considered relative" do + expect(@uri).to be_relative + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'ftp://ftp.is.co.za/rfc/rfc1808.txt'" do + before do + @uri = Addressable::URI.parse("ftp://ftp.is.co.za/rfc/rfc1808.txt") + end + + it "should use the 'ftp' scheme" do + expect(@uri.scheme).to eq("ftp") + end + + it "should be considered to be ip-based" do + expect(@uri).to be_ip_based + end + + it "should have a host of 'ftp.is.co.za'" do + expect(@uri.host).to eq("ftp.is.co.za") + end + + it "should have inferred_port of 21" do + expect(@uri.inferred_port).to eq(21) + end + + it "should have a path of '/rfc/rfc1808.txt'" do + expect(@uri.path).to eq("/rfc/rfc1808.txt") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have an origin of 'ftp://ftp.is.co.za'" do + expect(@uri.origin).to eq('ftp://ftp.is.co.za') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'http://www.ietf.org/rfc/rfc2396.txt'" do + before do + @uri = Addressable::URI.parse("http://www.ietf.org/rfc/rfc2396.txt") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should be considered to be ip-based" do + expect(@uri).to be_ip_based + end + + it "should have a host of 'www.ietf.org'" do + expect(@uri.host).to eq("www.ietf.org") + end + + it "should have inferred_port of 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/rfc/rfc2396.txt'" do + expect(@uri.path).to eq("/rfc/rfc2396.txt") + end + + it "should have a request URI of '/rfc/rfc2396.txt'" do + expect(@uri.request_uri).to eq("/rfc/rfc2396.txt") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should correctly omit components" do + expect(@uri.omit(:scheme).to_s).to eq("//www.ietf.org/rfc/rfc2396.txt") + expect(@uri.omit(:path).to_s).to eq("http://www.ietf.org") + end + + it "should correctly omit components destructively" do + @uri.omit!(:scheme) + expect(@uri.to_s).to eq("//www.ietf.org/rfc/rfc2396.txt") + end + + it "should have an origin of 'http://www.ietf.org'" do + expect(@uri.origin).to eq('http://www.ietf.org') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'ldap://[2001:db8::7]/c=GB?objectClass?one'" do + before do + @uri = Addressable::URI.parse("ldap://[2001:db8::7]/c=GB?objectClass?one") + end + + it "should use the 'ldap' scheme" do + expect(@uri.scheme).to eq("ldap") + end + + it "should be considered to be ip-based" do + expect(@uri).to be_ip_based + end + + it "should have a host of '[2001:db8::7]'" do + expect(@uri.host).to eq("[2001:db8::7]") + end + + it "should have inferred_port of 389" do + expect(@uri.inferred_port).to eq(389) + end + + it "should have a path of '/c=GB'" do + expect(@uri.path).to eq("/c=GB") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should not allow request URI assignment" do + expect do + @uri.request_uri = "/" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should have a query of 'objectClass?one'" do + expect(@uri.query).to eq("objectClass?one") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should correctly omit components" do + expect(@uri.omit(:scheme, :authority).to_s).to eq("/c=GB?objectClass?one") + expect(@uri.omit(:path).to_s).to eq("ldap://[2001:db8::7]?objectClass?one") + end + + it "should correctly omit components destructively" do + @uri.omit!(:scheme, :authority) + expect(@uri.to_s).to eq("/c=GB?objectClass?one") + end + + it "should raise an error if omission would create an invalid URI" do + expect do + @uri.omit(:authority, :path) + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should have an origin of 'ldap://[2001:db8::7]'" do + expect(@uri.origin).to eq('ldap://[2001:db8::7]') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'mailto:John.Doe@example.com'" do + before do + @uri = Addressable::URI.parse("mailto:John.Doe@example.com") + end + + it "should use the 'mailto' scheme" do + expect(@uri.scheme).to eq("mailto") + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should not have an inferred_port" do + expect(@uri.inferred_port).to eq(nil) + end + + it "should have a path of 'John.Doe@example.com'" do + expect(@uri.path).to eq("John.Doe@example.com") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +# Section 2 of RFC 6068 +describe Addressable::URI, "when parsed from " + + "'mailto:?to=addr1@an.example,addr2@an.example'" do + before do + @uri = Addressable::URI.parse( + "mailto:?to=addr1@an.example,addr2@an.example" + ) + end + + it "should use the 'mailto' scheme" do + expect(@uri.scheme).to eq("mailto") + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should not have an inferred_port" do + expect(@uri.inferred_port).to eq(nil) + end + + it "should have a path of ''" do + expect(@uri.path).to eq("") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should have the To: field value parameterized" do + expect(@uri.query_values(Hash)["to"]).to eq( + "addr1@an.example,addr2@an.example" + ) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'news:comp.infosystems.www.servers.unix'" do + before do + @uri = Addressable::URI.parse("news:comp.infosystems.www.servers.unix") + end + + it "should use the 'news' scheme" do + expect(@uri.scheme).to eq("news") + end + + it "should not have an inferred_port" do + expect(@uri.inferred_port).to eq(nil) + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should have a path of 'comp.infosystems.www.servers.unix'" do + expect(@uri.path).to eq("comp.infosystems.www.servers.unix") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'tel:+1-816-555-1212'" do + before do + @uri = Addressable::URI.parse("tel:+1-816-555-1212") + end + + it "should use the 'tel' scheme" do + expect(@uri.scheme).to eq("tel") + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should not have an inferred_port" do + expect(@uri.inferred_port).to eq(nil) + end + + it "should have a path of '+1-816-555-1212'" do + expect(@uri.path).to eq("+1-816-555-1212") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'telnet://192.0.2.16:80/'" do + before do + @uri = Addressable::URI.parse("telnet://192.0.2.16:80/") + end + + it "should use the 'telnet' scheme" do + expect(@uri.scheme).to eq("telnet") + end + + it "should have a host of '192.0.2.16'" do + expect(@uri.host).to eq("192.0.2.16") + end + + it "should have a port of 80" do + expect(@uri.port).to eq(80) + end + + it "should have a inferred_port of 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a default_port of 23" do + expect(@uri.default_port).to eq(23) + end + + it "should be considered to be ip-based" do + expect(@uri).to be_ip_based + end + + it "should have a path of '/'" do + expect(@uri.path).to eq("/") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have an origin of 'telnet://192.0.2.16:80'" do + expect(@uri.origin).to eq('telnet://192.0.2.16:80') + end +end + +# Section 1.1.2 of RFC 3986 +describe Addressable::URI, "when parsed from " + + "'urn:oasis:names:specification:docbook:dtd:xml:4.1.2'" do + before do + @uri = Addressable::URI.parse( + "urn:oasis:names:specification:docbook:dtd:xml:4.1.2") + end + + it "should use the 'urn' scheme" do + expect(@uri.scheme).to eq("urn") + end + + it "should not have an inferred_port" do + expect(@uri.inferred_port).to eq(nil) + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should have a path of " + + "'oasis:names:specification:docbook:dtd:xml:4.1.2'" do + expect(@uri.path).to eq("oasis:names:specification:docbook:dtd:xml:4.1.2") + end + + it "should not have a request URI" do + expect(@uri.request_uri).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when heuristically parsed from " + + "'192.0.2.16:8000/path'" do + before do + @uri = Addressable::URI.heuristic_parse("192.0.2.16:8000/path") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have a host of '192.0.2.16'" do + expect(@uri.host).to eq("192.0.2.16") + end + + it "should have a port of '8000'" do + expect(@uri.port).to eq(8000) + end + + it "should be considered to be ip-based" do + expect(@uri).to be_ip_based + end + + it "should have a path of '/path'" do + expect(@uri.path).to eq("/path") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have an origin of 'http://192.0.2.16:8000'" do + expect(@uri.origin).to eq('http://192.0.2.16:8000') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com'" do + before do + @uri = Addressable::URI.parse("http://example.com") + end + + it "when inspected, should have the correct URI" do + expect(@uri.inspect).to include("http://example.com") + end + + it "when inspected, should have the correct class name" do + expect(@uri.inspect).to include("Addressable::URI") + end + + it "when inspected, should have the correct object id" do + expect(@uri.inspect).to include("%#0x" % @uri.object_id) + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should be considered to be ip-based" do + expect(@uri).to be_ip_based + end + + it "should have an authority segment of 'example.com'" do + expect(@uri.authority).to eq("example.com") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should be considered ip-based" do + expect(@uri).to be_ip_based + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should not have a specified port" do + expect(@uri.port).to eq(nil) + end + + it "should have an empty path" do + expect(@uri.path).to eq("") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + expect(@uri.query_values).to eq(nil) + end + + it "should have a request URI of '/'" do + expect(@uri.request_uri).to eq("/") + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should be considered absolute" do + expect(@uri).to be_absolute + end + + it "should not be considered relative" do + expect(@uri).not_to be_relative + end + + it "should not be exactly equal to 42" do + expect(@uri.eql?(42)).to eq(false) + end + + it "should not be equal to 42" do + expect(@uri == 42).to eq(false) + end + + it "should not be roughly equal to 42" do + expect(@uri === 42).to eq(false) + end + + it "should be exactly equal to http://example.com" do + expect(@uri.eql?(Addressable::URI.parse("http://example.com"))).to eq(true) + end + + it "should be roughly equal to http://example.com/" do + expect(@uri === Addressable::URI.parse("http://example.com/")).to eq(true) + end + + it "should be roughly equal to the string 'http://example.com/'" do + expect(@uri === "http://example.com/").to eq(true) + end + + it "should not be roughly equal to the string " + + "'http://example.com:bogus/'" do + expect do + expect(@uri === "http://example.com:bogus/").to eq(false) + end.not_to raise_error + end + + it "should result in itself when joined with itself" do + expect(@uri.join(@uri).to_s).to eq("http://example.com") + expect(@uri.join!(@uri).to_s).to eq("http://example.com") + end + + it "should be equivalent to http://EXAMPLE.com" do + expect(@uri).to eq(Addressable::URI.parse("http://EXAMPLE.com")) + end + + it "should be equivalent to http://EXAMPLE.com:80/" do + expect(@uri).to eq(Addressable::URI.parse("http://EXAMPLE.com:80/")) + end + + it "should have the same hash as http://example.com" do + expect(@uri.hash).to eq(Addressable::URI.parse("http://example.com").hash) + end + + it "should have the same hash as http://EXAMPLE.com after assignment" do + @uri.origin = "http://EXAMPLE.com" + expect(@uri.hash).to eq(Addressable::URI.parse("http://EXAMPLE.com").hash) + end + + it "should have a different hash from http://EXAMPLE.com" do + expect(@uri.hash).not_to eq(Addressable::URI.parse("http://EXAMPLE.com").hash) + end + + it "should not allow origin assignment without scheme" do + expect do + @uri.origin = "example.com" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should not allow origin assignment without host" do + expect do + @uri.origin = "http://" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should not allow origin assignment with bogus type" do + expect do + @uri.origin = :bogus + end.to raise_error(TypeError) + end + + # Section 6.2.3 of RFC 3986 + it "should be equivalent to http://example.com/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com/")) + end + + # Section 6.2.3 of RFC 3986 + it "should be equivalent to http://example.com:/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com:/")) + end + + # Section 6.2.3 of RFC 3986 + it "should be equivalent to http://example.com:80/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com:80/")) + end + + # Section 6.2.2.1 of RFC 3986 + it "should be equivalent to http://EXAMPLE.COM/" do + expect(@uri).to eq(Addressable::URI.parse("http://EXAMPLE.COM/")) + end + + it "should have a route of '/path/' to 'http://example.com/path/'" do + expect(@uri.route_to("http://example.com/path/")).to eq( + Addressable::URI.parse("/path/") + ) + end + + it "should have a route of '..' from 'http://example.com/path/'" do + expect(@uri.route_from("http://example.com/path/")).to eq( + Addressable::URI.parse("..") + ) + end + + it "should have a route of '#' to 'http://example.com/'" do + expect(@uri.route_to("http://example.com/")).to eq( + Addressable::URI.parse("#") + ) + end + + it "should have a route of 'http://elsewhere.com/' to " + + "'http://elsewhere.com/'" do + expect(@uri.route_to("http://elsewhere.com/")).to eq( + Addressable::URI.parse("http://elsewhere.com/") + ) + end + + it "when joined with 'relative/path' should be " + + "'http://example.com/relative/path'" do + expect(@uri.join('relative/path')).to eq( + Addressable::URI.parse("http://example.com/relative/path") + ) + end + + it "when joined with a bogus object a TypeError should be raised" do + expect do + @uri.join(42) + end.to raise_error(TypeError) + end + + it "should have the correct username after assignment" do + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq(nil) + expect(@uri.to_s).to eq("http://newuser@example.com") + end + + it "should have the correct username after assignment" do + @uri.user = "user@123!" + expect(@uri.user).to eq("user@123!") + expect(@uri.normalized_user).to eq("user%40123%21") + expect(@uri.password).to eq(nil) + expect(@uri.normalize.to_s).to eq("http://user%40123%21@example.com/") + end + + it "should have the correct password after assignment" do + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + expect(@uri.user).to eq("") + expect(@uri.to_s).to eq("http://:newpass@example.com") + end + + it "should have the correct password after assignment" do + @uri.password = "#secret@123!" + expect(@uri.password).to eq("#secret@123!") + expect(@uri.normalized_password).to eq("%23secret%40123%21") + expect(@uri.user).to eq("") + expect(@uri.normalize.to_s).to eq("http://:%23secret%40123%21@example.com/") + expect(@uri.omit(:password).to_s).to eq("http://example.com") + end + + it "should have the correct user/pass after repeated assignment" do + @uri.user = nil + expect(@uri.user).to eq(nil) + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + # Username cannot be nil if the password is set + expect(@uri.user).to eq("") + expect(@uri.to_s).to eq("http://:newpass@example.com") + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + @uri.password = nil + expect(@uri.password).to eq(nil) + expect(@uri.to_s).to eq("http://newuser@example.com") + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + @uri.password = "" + expect(@uri.password).to eq("") + expect(@uri.to_s).to eq("http://newuser:@example.com") + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + @uri.user = nil + # Username cannot be nil if the password is set + expect(@uri.user).to eq("") + expect(@uri.to_s).to eq("http://:newpass@example.com") + end + + it "should have the correct user/pass after userinfo assignment" do + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + @uri.userinfo = nil + expect(@uri.userinfo).to eq(nil) + expect(@uri.user).to eq(nil) + expect(@uri.password).to eq(nil) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => nil, + :password => nil, + :host => "example.com", + :port => nil, + :path => "", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end +end + +# Section 5.1.2 of RFC 2616 +describe Addressable::URI, "when parsed from " + + "'HTTP://www.w3.org/pub/WWW/TheProject.html'" do + before do + @uri = Addressable::URI.parse("HTTP://www.w3.org/pub/WWW/TheProject.html") + end + + it "should have the correct request URI" do + expect(@uri.request_uri).to eq("/pub/WWW/TheProject.html") + end + + it "should have the correct request URI after assignment" do + @uri.request_uri = "/pub/WWW/TheProject.html?" + expect(@uri.request_uri).to eq("/pub/WWW/TheProject.html?") + expect(@uri.path).to eq("/pub/WWW/TheProject.html") + expect(@uri.query).to eq("") + end + + it "should have the correct request URI after assignment" do + @uri.request_uri = "/some/where/else.html" + expect(@uri.request_uri).to eq("/some/where/else.html") + expect(@uri.path).to eq("/some/where/else.html") + expect(@uri.query).to eq(nil) + end + + it "should have the correct request URI after assignment" do + @uri.request_uri = "/some/where/else.html?query?string" + expect(@uri.request_uri).to eq("/some/where/else.html?query?string") + expect(@uri.path).to eq("/some/where/else.html") + expect(@uri.query).to eq("query?string") + end + + it "should have the correct request URI after assignment" do + @uri.request_uri = "?x=y" + expect(@uri.request_uri).to eq("/?x=y") + expect(@uri.path).to eq("/") + expect(@uri.query).to eq("x=y") + end + + it "should raise an error if the site value is set to something bogus" do + expect do + @uri.site = 42 + end.to raise_error(TypeError) + end + + it "should raise an error if the request URI is set to something bogus" do + expect do + @uri.request_uri = 42 + end.to raise_error(TypeError) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "HTTP", + :user => nil, + :password => nil, + :host => "www.w3.org", + :port => nil, + :path => "/pub/WWW/TheProject.html", + :query => nil, + :fragment => nil + }) + end + + it "should have an origin of 'http://www.w3.org'" do + expect(@uri.origin).to eq('http://www.w3.org') + end +end + +describe Addressable::URI, "when parsing IPv6 addresses" do + it "should not raise an error for " + + "'http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/'" do + Addressable::URI.parse("http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/") + end + + it "should not raise an error for " + + "'http://[fe80:0:0:0:200:f8ff:fe21:67cf]/'" do + Addressable::URI.parse("http://[fe80:0:0:0:200:f8ff:fe21:67cf]/") + end + + it "should not raise an error for " + + "'http://[fe80::200:f8ff:fe21:67cf]/'" do + Addressable::URI.parse("http://[fe80::200:f8ff:fe21:67cf]/") + end + + it "should not raise an error for " + + "'http://[::1]/'" do + Addressable::URI.parse("http://[::1]/") + end + + it "should not raise an error for " + + "'http://[fe80::1]/'" do + Addressable::URI.parse("http://[fe80::1]/") + end + + it "should raise an error for " + + "'http://[]/'" do + expect do + Addressable::URI.parse("http://[]/") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when parsing IPv6 address" do + subject { Addressable::URI.parse("http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/") } + its(:host) { should == '[3ffe:1900:4545:3:200:f8ff:fe21:67cf]' } + its(:hostname) { should == '3ffe:1900:4545:3:200:f8ff:fe21:67cf' } +end + +describe Addressable::URI, "when assigning IPv6 address" do + it "should allow to set bare IPv6 address as hostname" do + uri = Addressable::URI.parse("http://[::1]/") + uri.hostname = '3ffe:1900:4545:3:200:f8ff:fe21:67cf' + expect(uri.to_s).to eq('http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/') + end + + it "should allow to set bare IPv6 address as hostname with IPAddr object" do + uri = Addressable::URI.parse("http://[::1]/") + uri.hostname = IPAddr.new('3ffe:1900:4545:3:200:f8ff:fe21:67cf') + expect(uri.to_s).to eq('http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/') + end + + it "should not allow to set bare IPv6 address as host" do + uri = Addressable::URI.parse("http://[::1]/") + skip "not checked" + expect do + uri.host = '3ffe:1900:4545:3:200:f8ff:fe21:67cf' + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when parsing IPvFuture addresses" do + it "should not raise an error for " + + "'http://[v9.3ffe:1900:4545:3:200:f8ff:fe21:67cf]/'" do + Addressable::URI.parse("http://[v9.3ffe:1900:4545:3:200:f8ff:fe21:67cf]/") + end + + it "should not raise an error for " + + "'http://[vff.fe80:0:0:0:200:f8ff:fe21:67cf]/'" do + Addressable::URI.parse("http://[vff.fe80:0:0:0:200:f8ff:fe21:67cf]/") + end + + it "should not raise an error for " + + "'http://[v12.fe80::200:f8ff:fe21:67cf]/'" do + Addressable::URI.parse("http://[v12.fe80::200:f8ff:fe21:67cf]/") + end + + it "should not raise an error for " + + "'http://[va0.::1]/'" do + Addressable::URI.parse("http://[va0.::1]/") + end + + it "should not raise an error for " + + "'http://[v255.fe80::1]/'" do + Addressable::URI.parse("http://[v255.fe80::1]/") + end + + it "should raise an error for " + + "'http://[v0.]/'" do + expect do + Addressable::URI.parse("http://[v0.]/") + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/'" do + before do + @uri = Addressable::URI.parse("http://example.com/") + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to http://example.com" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com")) + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to HTTP://example.com/" do + expect(@uri).to eq(Addressable::URI.parse("HTTP://example.com/")) + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to http://example.com:/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com:/")) + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to http://example.com:80/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com:80/")) + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to http://Example.com/" do + expect(@uri).to eq(Addressable::URI.parse("http://Example.com/")) + end + + it "should have the correct username after assignment" do + @uri.user = nil + expect(@uri.user).to eq(nil) + expect(@uri.password).to eq(nil) + expect(@uri.to_s).to eq("http://example.com/") + end + + it "should have the correct password after assignment" do + @uri.password = nil + expect(@uri.password).to eq(nil) + expect(@uri.user).to eq(nil) + expect(@uri.to_s).to eq("http://example.com/") + end + + it "should have a request URI of '/'" do + expect(@uri.request_uri).to eq("/") + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => nil, + :password => nil, + :host => "example.com", + :port => nil, + :path => "/", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have the same hash as its duplicate" do + expect(@uri.hash).to eq(@uri.dup.hash) + end + + it "should have a different hash from its equivalent String value" do + expect(@uri.hash).not_to eq(@uri.to_s.hash) + end + + it "should have the same hash as an equal URI" do + expect(@uri.hash).to eq(Addressable::URI.parse("http://example.com/").hash) + end + + it "should be equivalent to http://EXAMPLE.com" do + expect(@uri).to eq(Addressable::URI.parse("http://EXAMPLE.com")) + end + + it "should be equivalent to http://EXAMPLE.com:80/" do + expect(@uri).to eq(Addressable::URI.parse("http://EXAMPLE.com:80/")) + end + + it "should have the same hash as http://example.com/" do + expect(@uri.hash).to eq(Addressable::URI.parse("http://example.com/").hash) + end + + it "should have the same hash as http://example.com after assignment" do + @uri.path = "" + expect(@uri.hash).to eq(Addressable::URI.parse("http://example.com").hash) + end + + it "should have the same hash as http://example.com/? after assignment" do + @uri.query = "" + expect(@uri.hash).to eq(Addressable::URI.parse("http://example.com/?").hash) + end + + it "should have the same hash as http://example.com/? after assignment" do + @uri.query_values = {} + expect(@uri.hash).to eq(Addressable::URI.parse("http://example.com/?").hash) + end + + it "should have the same hash as http://example.com/# after assignment" do + @uri.fragment = "" + expect(@uri.hash).to eq(Addressable::URI.parse("http://example.com/#").hash) + end + + it "should have a different hash from http://example.com" do + expect(@uri.hash).not_to eq(Addressable::URI.parse("http://example.com").hash) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com?#'" do + before do + @uri = Addressable::URI.parse("http://example.com?#") + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => nil, + :password => nil, + :host => "example.com", + :port => nil, + :path => "", + :query => "", + :fragment => "" + }) + end + + it "should have a request URI of '/?'" do + expect(@uri.request_uri).to eq("/?") + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq("http://example.com") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://@example.com/'" do + before do + @uri = Addressable::URI.parse("http://@example.com/") + end + + it "should be equivalent to http://example.com" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com")) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => "", + :password => nil, + :host => "example.com", + :port => nil, + :path => "/", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com./'" do + before do + @uri = Addressable::URI.parse("http://example.com./") + end + + it "should be equivalent to http://example.com" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com")) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://:@example.com/'" do + before do + @uri = Addressable::URI.parse("http://:@example.com/") + end + + it "should be equivalent to http://example.com" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com")) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => "", + :password => "", + :host => "example.com", + :port => nil, + :path => "/", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'HTTP://EXAMPLE.COM/'" do + before do + @uri = Addressable::URI.parse("HTTP://EXAMPLE.COM/") + end + + it "should be equivalent to http://example.com" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com")) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "HTTP", + :user => nil, + :password => nil, + :host => "EXAMPLE.COM", + :port => nil, + :path => "/", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end + + it "should have a tld of 'com'" do + expect(@uri.tld).to eq('com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://www.example.co.uk/'" do + before do + @uri = Addressable::URI.parse("http://www.example.co.uk/") + end + + it "should have an origin of 'http://www.example.co.uk'" do + expect(@uri.origin).to eq('http://www.example.co.uk') + end + + it "should have a tld of 'co.uk'" do + expect(@uri.tld).to eq('co.uk') + end + + it "should have a domain of 'example.co.uk'" do + expect(@uri.domain).to eq('example.co.uk') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://sub_domain.blogspot.com/'" do + before do + @uri = Addressable::URI.parse("http://sub_domain.blogspot.com/") + end + + it "should have an origin of 'http://sub_domain.blogspot.com'" do + expect(@uri.origin).to eq('http://sub_domain.blogspot.com') + end + + it "should have a tld of 'com'" do + expect(@uri.tld).to eq('com') + end + + it "should have a domain of 'blogspot.com'" do + expect(@uri.domain).to eq('blogspot.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/~smith/'" do + before do + @uri = Addressable::URI.parse("http://example.com/~smith/") + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to http://example.com/%7Esmith/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com/%7Esmith/")) + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to http://example.com/%7esmith/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com/%7esmith/")) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/%E8'" do + before do + @uri = Addressable::URI.parse("http://example.com/%E8") + end + + it "should not raise an exception when normalized" do + expect do + @uri.normalize + end.not_to raise_error + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should not change if encoded with the normalizing algorithm" do + expect(Addressable::URI.normalized_encode(@uri).to_s).to eq( + "http://example.com/%E8" + ) + expect(Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s).to be === + "http://example.com/%E8" + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/path%2Fsegment/'" do + before do + @uri = Addressable::URI.parse("http://example.com/path%2Fsegment/") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should be equal to 'http://example.com/path%2Fsegment/'" do + expect(@uri.normalize).to be_eql( + Addressable::URI.parse("http://example.com/path%2Fsegment/") + ) + end + + it "should not be equal to 'http://example.com/path/segment/'" do + expect(@uri).not_to eq( + Addressable::URI.parse("http://example.com/path/segment/") + ) + end + + it "should not be equal to 'http://example.com/path/segment/'" do + expect(@uri.normalize).not_to be_eql( + Addressable::URI.parse("http://example.com/path/segment/") + ) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?%F6'" do + before do + @uri = Addressable::URI.parse("http://example.com/?%F6") + end + + it "should not raise an exception when normalized" do + expect do + @uri.normalize + end.not_to raise_error + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should not change if encoded with the normalizing algorithm" do + expect(Addressable::URI.normalized_encode(@uri).to_s).to eq( + "http://example.com/?%F6" + ) + expect(Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s).to be === + "http://example.com/?%F6" + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/#%F6'" do + before do + @uri = Addressable::URI.parse("http://example.com/#%F6") + end + + it "should not raise an exception when normalized" do + expect do + @uri.normalize + end.not_to raise_error + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should not change if encoded with the normalizing algorithm" do + expect(Addressable::URI.normalized_encode(@uri).to_s).to eq( + "http://example.com/#%F6" + ) + expect(Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s).to be === + "http://example.com/#%F6" + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/%C3%87'" do + before do + @uri = Addressable::URI.parse("http://example.com/%C3%87") + end + + # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence + it "should be equivalent to 'http://example.com/C%CC%A7'" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com/C%CC%A7")) + end + + it "should not change if encoded with the normalizing algorithm" do + expect(Addressable::URI.normalized_encode(@uri).to_s).to eq( + "http://example.com/%C3%87" + ) + expect(Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s).to be === + "http://example.com/%C3%87" + end + + it "should raise an error if encoding with an unexpected return type" do + expect do + Addressable::URI.normalized_encode(@uri, Integer) + end.to raise_error(TypeError) + end + + it "if percent encoded should be 'http://example.com/C%25CC%25A7'" do + expect(Addressable::URI.encode(@uri).to_s).to eq( + "http://example.com/%25C3%2587" + ) + end + + it "if percent encoded should be 'http://example.com/C%25CC%25A7'" do + expect(Addressable::URI.encode(@uri, Addressable::URI)).to eq( + Addressable::URI.parse("http://example.com/%25C3%2587") + ) + end + + it "should raise an error if encoding with an unexpected return type" do + expect do + Addressable::URI.encode(@uri, Integer) + end.to raise_error(TypeError) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?q=string'" do + before do + @uri = Addressable::URI.parse("http://example.com/?q=string") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'example.com'" do + expect(@uri.authority).to eq("example.com") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/'" do + expect(@uri.path).to eq("/") + end + + it "should have a query string of 'q=string'" do + expect(@uri.query).to eq("q=string") + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should be considered absolute" do + expect(@uri).to be_absolute + end + + it "should not be considered relative" do + expect(@uri).not_to be_relative + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com:80/'" do + before do + @uri = Addressable::URI.parse("http://example.com:80/") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'example.com:80'" do + expect(@uri.authority).to eq("example.com:80") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have explicit port 80" do + expect(@uri.port).to eq(80) + end + + it "should have a path of '/'" do + expect(@uri.path).to eq("/") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should be considered absolute" do + expect(@uri).to be_absolute + end + + it "should not be considered relative" do + expect(@uri).not_to be_relative + end + + it "should be exactly equal to http://example.com:80/" do + expect(@uri.eql?(Addressable::URI.parse("http://example.com:80/"))).to eq(true) + end + + it "should be roughly equal to http://example.com/" do + expect(@uri === Addressable::URI.parse("http://example.com/")).to eq(true) + end + + it "should be roughly equal to the string 'http://example.com/'" do + expect(@uri === "http://example.com/").to eq(true) + end + + it "should not be roughly equal to the string " + + "'http://example.com:bogus/'" do + expect do + expect(@uri === "http://example.com:bogus/").to eq(false) + end.not_to raise_error + end + + it "should result in itself when joined with itself" do + expect(@uri.join(@uri).to_s).to eq("http://example.com:80/") + expect(@uri.join!(@uri).to_s).to eq("http://example.com:80/") + end + + # Section 6.2.3 of RFC 3986 + it "should be equal to http://example.com/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com/")) + end + + # Section 6.2.3 of RFC 3986 + it "should be equal to http://example.com:/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com:/")) + end + + # Section 6.2.3 of RFC 3986 + it "should be equal to http://example.com:80/" do + expect(@uri).to eq(Addressable::URI.parse("http://example.com:80/")) + end + + # Section 6.2.2.1 of RFC 3986 + it "should be equal to http://EXAMPLE.COM/" do + expect(@uri).to eq(Addressable::URI.parse("http://EXAMPLE.COM/")) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => nil, + :password => nil, + :host => "example.com", + :port => 80, + :path => "/", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end + + it "should not change if encoded with the normalizing algorithm" do + expect(Addressable::URI.normalized_encode(@uri).to_s).to eq( + "http://example.com:80/" + ) + expect(Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s).to be === + "http://example.com:80/" + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com:8080/'" do + before do + @uri = Addressable::URI.parse("http://example.com:8080/") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'example.com:8080'" do + expect(@uri.authority).to eq("example.com:8080") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 8080" do + expect(@uri.inferred_port).to eq(8080) + end + + it "should have explicit port 8080" do + expect(@uri.port).to eq(8080) + end + + it "should have default port 80" do + expect(@uri.default_port).to eq(80) + end + + it "should have a path of '/'" do + expect(@uri.path).to eq("/") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should be considered absolute" do + expect(@uri).to be_absolute + end + + it "should not be considered relative" do + expect(@uri).not_to be_relative + end + + it "should be exactly equal to http://example.com:8080/" do + expect(@uri.eql?(Addressable::URI.parse( + "http://example.com:8080/"))).to eq(true) + end + + it "should have a route of 'http://example.com:8080/' from " + + "'http://example.com/path/to/'" do + expect(@uri.route_from("http://example.com/path/to/")).to eq( + Addressable::URI.parse("http://example.com:8080/") + ) + end + + it "should have a route of 'http://example.com:8080/' from " + + "'http://example.com:80/path/to/'" do + expect(@uri.route_from("http://example.com:80/path/to/")).to eq( + Addressable::URI.parse("http://example.com:8080/") + ) + end + + it "should have a route of '../../' from " + + "'http://example.com:8080/path/to/'" do + expect(@uri.route_from("http://example.com:8080/path/to/")).to eq( + Addressable::URI.parse("../../") + ) + end + + it "should have a route of 'http://example.com:8080/' from " + + "'http://user:pass@example.com/path/to/'" do + expect(@uri.route_from("http://user:pass@example.com/path/to/")).to eq( + Addressable::URI.parse("http://example.com:8080/") + ) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => nil, + :password => nil, + :host => "example.com", + :port => 8080, + :path => "/", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com:8080'" do + expect(@uri.origin).to eq('http://example.com:8080') + end + + it "should not change if encoded with the normalizing algorithm" do + expect(Addressable::URI.normalized_encode(@uri).to_s).to eq( + "http://example.com:8080/" + ) + expect(Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s).to be === + "http://example.com:8080/" + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com:%38%30/'" do + before do + @uri = Addressable::URI.parse("http://example.com:%38%30/") + end + + it "should have the correct port" do + expect(@uri.port).to eq(80) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end +end + +describe Addressable::URI, "when parsed with empty port" do + subject(:uri) do + Addressable::URI.parse("//example.com:") + end + + it "should not infer a port" do + expect(uri.port).to be(nil) + end + + it "should have a site value of '//example.com'" do + expect(uri.site).to eq("//example.com") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/%2E/'" do + before do + @uri = Addressable::URI.parse("http://example.com/%2E/") + end + + it "should be considered to be in normal form" do + skip( + 'path segment normalization should happen before ' + + 'percent escaping normalization' + ) + @uri.normalize.should be_eql(@uri) + end + + it "should normalize to 'http://example.com/%2E/'" do + skip( + 'path segment normalization should happen before ' + + 'percent escaping normalization' + ) + expect(@uri.normalize).to eq("http://example.com/%2E/") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/..'" do + before do + @uri = Addressable::URI.parse("http://example.com/..") + end + + it "should have the correct port" do + expect(@uri.inferred_port).to eq(80) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/../..'" do + before do + @uri = Addressable::URI.parse("http://example.com/../..") + end + + it "should have the correct port" do + expect(@uri.inferred_port).to eq(80) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/path(/..'" do + before do + @uri = Addressable::URI.parse("http://example.com/path(/..") + end + + it "should have the correct port" do + expect(@uri.inferred_port).to eq(80) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/(path)/..'" do + before do + @uri = Addressable::URI.parse("http://example.com/(path)/..") + end + + it "should have the correct port" do + expect(@uri.inferred_port).to eq(80) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/path(/../'" do + before do + @uri = Addressable::URI.parse("http://example.com/path(/../") + end + + it "should have the correct port" do + expect(@uri.inferred_port).to eq(80) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/(path)/../'" do + before do + @uri = Addressable::URI.parse("http://example.com/(path)/../") + end + + it "should have the correct port" do + expect(@uri.inferred_port).to eq(80) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + end +end + +describe Addressable::URI, "when parsed from " + + "'/..//example.com'" do + before do + @uri = Addressable::URI.parse("/..//example.com") + end + + it "should become invalid when normalized" do + expect do + @uri.normalize + end.to raise_error(Addressable::URI::InvalidURIError, /authority/) + end + + it "should have a path of '/..//example.com'" do + expect(@uri.path).to eq("/..//example.com") + end +end + +describe Addressable::URI, "when parsed from '/a/b/c/./../../g'" do + before do + @uri = Addressable::URI.parse("/a/b/c/./../../g") + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + # Section 5.2.4 of RFC 3986 + it "should normalize to '/a/g'" do + expect(@uri.normalize.to_s).to eq("/a/g") + end +end + +describe Addressable::URI, "when parsed from 'mid/content=5/../6'" do + before do + @uri = Addressable::URI.parse("mid/content=5/../6") + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + # Section 5.2.4 of RFC 3986 + it "should normalize to 'mid/6'" do + expect(@uri.normalize.to_s).to eq("mid/6") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://www.example.com///../'" do + before do + @uri = Addressable::URI.parse('http://www.example.com///../') + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end + + it "should normalize to 'http://www.example.com//'" do + expect(@uri.normalize.to_s).to eq("http://www.example.com//") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/path/to/resource/'" do + before do + @uri = Addressable::URI.parse("http://example.com/path/to/resource/") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'example.com'" do + expect(@uri.authority).to eq("example.com") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/path/to/resource/'" do + expect(@uri.path).to eq("/path/to/resource/") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should be considered absolute" do + expect(@uri).to be_absolute + end + + it "should not be considered relative" do + expect(@uri).not_to be_relative + end + + it "should be exactly equal to http://example.com:8080/" do + expect(@uri.eql?(Addressable::URI.parse( + "http://example.com/path/to/resource/"))).to eq(true) + end + + it "should have a route of 'resource/' from " + + "'http://example.com/path/to/'" do + expect(@uri.route_from("http://example.com/path/to/")).to eq( + Addressable::URI.parse("resource/") + ) + end + + it "should have a route of '../' from " + + "'http://example.com/path/to/resource/sub'" do + expect(@uri.route_from("http://example.com/path/to/resource/sub")).to eq( + Addressable::URI.parse("../") + ) + end + + + it "should have a route of 'resource/' from " + + "'http://example.com/path/to/another'" do + expect(@uri.route_from("http://example.com/path/to/another")).to eq( + Addressable::URI.parse("resource/") + ) + end + + it "should have a route of 'resource/' from " + + "'http://example.com/path/to/res'" do + expect(@uri.route_from("http://example.com/path/to/res")).to eq( + Addressable::URI.parse("resource/") + ) + end + + it "should have a route of 'resource/' from " + + "'http://example.com:80/path/to/'" do + expect(@uri.route_from("http://example.com:80/path/to/")).to eq( + Addressable::URI.parse("resource/") + ) + end + + it "should have a route of 'http://example.com/path/to/' from " + + "'http://example.com:8080/path/to/'" do + expect(@uri.route_from("http://example.com:8080/path/to/")).to eq( + Addressable::URI.parse("http://example.com/path/to/resource/") + ) + end + + it "should have a route of 'http://example.com/path/to/' from " + + "'http://user:pass@example.com/path/to/'" do + expect(@uri.route_from("http://user:pass@example.com/path/to/")).to eq( + Addressable::URI.parse("http://example.com/path/to/resource/") + ) + end + + it "should have a route of '../../path/to/resource/' from " + + "'http://example.com/to/resource/'" do + expect(@uri.route_from("http://example.com/to/resource/")).to eq( + Addressable::URI.parse("../../path/to/resource/") + ) + end + + it "should correctly convert to a hash" do + expect(@uri.to_hash).to eq({ + :scheme => "http", + :user => nil, + :password => nil, + :host => "example.com", + :port => nil, + :path => "/path/to/resource/", + :query => nil, + :fragment => nil + }) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end +end + +describe Addressable::URI, "when parsed from " + + "'relative/path/to/resource'" do + before do + @uri = Addressable::URI.parse("relative/path/to/resource") + end + + it "should not have a scheme" do + expect(@uri.scheme).to eq(nil) + end + + it "should not be considered ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should not have an authority segment" do + expect(@uri.authority).to eq(nil) + end + + it "should not have a host" do + expect(@uri.host).to eq(nil) + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should not have a port" do + expect(@uri.port).to eq(nil) + end + + it "should have a path of 'relative/path/to/resource'" do + expect(@uri.path).to eq("relative/path/to/resource") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should not be considered absolute" do + expect(@uri).not_to be_absolute + end + + it "should be considered relative" do + expect(@uri).to be_relative + end + + it "should raise an error if routing is attempted" do + expect do + @uri.route_to("http://example.com/") + end.to raise_error(ArgumentError, /relative\/path\/to\/resource/) + expect do + @uri.route_from("http://example.com/") + end.to raise_error(ArgumentError, /relative\/path\/to\/resource/) + end + + it "when joined with 'another/relative/path' should be " + + "'relative/path/to/another/relative/path'" do + expect(@uri.join('another/relative/path')).to eq( + Addressable::URI.parse("relative/path/to/another/relative/path") + ) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end +end + +describe Addressable::URI, "when parsed from " + + "'relative_path_with_no_slashes'" do + before do + @uri = Addressable::URI.parse("relative_path_with_no_slashes") + end + + it "should not have a scheme" do + expect(@uri.scheme).to eq(nil) + end + + it "should not be considered ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should not have an authority segment" do + expect(@uri.authority).to eq(nil) + end + + it "should not have a host" do + expect(@uri.host).to eq(nil) + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should not have a port" do + expect(@uri.port).to eq(nil) + end + + it "should have a path of 'relative_path_with_no_slashes'" do + expect(@uri.path).to eq("relative_path_with_no_slashes") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should not be considered absolute" do + expect(@uri).not_to be_absolute + end + + it "should be considered relative" do + expect(@uri).to be_relative + end + + it "when joined with 'another_relative_path' should be " + + "'another_relative_path'" do + expect(@uri.join('another_relative_path')).to eq( + Addressable::URI.parse("another_relative_path") + ) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/file.txt'" do + before do + @uri = Addressable::URI.parse("http://example.com/file.txt") + end + + it "should have a scheme of 'http'" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'example.com'" do + expect(@uri.authority).to eq("example.com") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/file.txt'" do + expect(@uri.path).to eq("/file.txt") + end + + it "should have a basename of 'file.txt'" do + expect(@uri.basename).to eq("file.txt") + end + + it "should have an extname of '.txt'" do + expect(@uri.extname).to eq(".txt") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/file.txt;parameter'" do + before do + @uri = Addressable::URI.parse("http://example.com/file.txt;parameter") + end + + it "should have a scheme of 'http'" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'example.com'" do + expect(@uri.authority).to eq("example.com") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/file.txt;parameter'" do + expect(@uri.path).to eq("/file.txt;parameter") + end + + it "should have a basename of 'file.txt'" do + expect(@uri.basename).to eq("file.txt") + end + + it "should have an extname of '.txt'" do + expect(@uri.extname).to eq(".txt") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/file.txt;x=y'" do + before do + @uri = Addressable::URI.parse("http://example.com/file.txt;x=y") + end + + it "should have a scheme of 'http'" do + expect(@uri.scheme).to eq("http") + end + + it "should have a scheme of 'http'" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'example.com'" do + expect(@uri.authority).to eq("example.com") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have no username" do + expect(@uri.user).to eq(nil) + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/file.txt;x=y'" do + expect(@uri.path).to eq("/file.txt;x=y") + end + + it "should have an extname of '.txt'" do + expect(@uri.extname).to eq(".txt") + end + + it "should have no query string" do + expect(@uri.query).to eq(nil) + end + + it "should have no fragment" do + expect(@uri.fragment).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end +end + +describe Addressable::URI, "when parsed from " + + "'svn+ssh://developername@rubyforge.org/var/svn/project'" do + before do + @uri = Addressable::URI.parse( + "svn+ssh://developername@rubyforge.org/var/svn/project" + ) + end + + it "should have a scheme of 'svn+ssh'" do + expect(@uri.scheme).to eq("svn+ssh") + end + + it "should be considered to be ip-based" do + expect(@uri).to be_ip_based + end + + it "should have a path of '/var/svn/project'" do + expect(@uri.path).to eq("/var/svn/project") + end + + it "should have a username of 'developername'" do + expect(@uri.user).to eq("developername") + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end +end + +describe Addressable::URI, "when parsed from " + + "'ssh+svn://developername@RUBYFORGE.ORG/var/svn/project'" do + before do + @uri = Addressable::URI.parse( + "ssh+svn://developername@RUBYFORGE.ORG/var/svn/project" + ) + end + + it "should have a scheme of 'ssh+svn'" do + expect(@uri.scheme).to eq("ssh+svn") + end + + it "should have a normalized scheme of 'svn+ssh'" do + expect(@uri.normalized_scheme).to eq("svn+ssh") + end + + it "should have a normalized site of 'svn+ssh'" do + expect(@uri.normalized_site).to eq("svn+ssh://developername@rubyforge.org") + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should have a path of '/var/svn/project'" do + expect(@uri.path).to eq("/var/svn/project") + end + + it "should have a username of 'developername'" do + expect(@uri.user).to eq("developername") + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should not be considered to be in normal form" do + expect(@uri.normalize).not_to be_eql(@uri) + end +end + +describe Addressable::URI, "when parsed from " + + "'mailto:user@example.com'" do + before do + @uri = Addressable::URI.parse("mailto:user@example.com") + end + + it "should have a scheme of 'mailto'" do + expect(@uri.scheme).to eq("mailto") + end + + it "should not be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should have a path of 'user@example.com'" do + expect(@uri.path).to eq("user@example.com") + end + + it "should have no user" do + expect(@uri.user).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end +end + +describe Addressable::URI, "when parsed from " + + "'tag:example.com,2006-08-18:/path/to/something'" do + before do + @uri = Addressable::URI.parse( + "tag:example.com,2006-08-18:/path/to/something") + end + + it "should have a scheme of 'tag'" do + expect(@uri.scheme).to eq("tag") + end + + it "should be considered to be ip-based" do + expect(@uri).not_to be_ip_based + end + + it "should have a path of " + + "'example.com,2006-08-18:/path/to/something'" do + expect(@uri.path).to eq("example.com,2006-08-18:/path/to/something") + end + + it "should have no user" do + expect(@uri.user).to eq(nil) + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/x;y/'" do + before do + @uri = Addressable::URI.parse("http://example.com/x;y/") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?x=1&y=2'" do + before do + @uri = Addressable::URI.parse("http://example.com/?x=1&y=2") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end +end + +describe Addressable::URI, "when parsed from " + + "'view-source:http://example.com/'" do + before do + @uri = Addressable::URI.parse("view-source:http://example.com/") + end + + it "should have a scheme of 'view-source'" do + expect(@uri.scheme).to eq("view-source") + end + + it "should have a path of 'http://example.com/'" do + expect(@uri.path).to eq("http://example.com/") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://user:pass@example.com/path/to/resource?query=x#fragment'" do + before do + @uri = Addressable::URI.parse( + "http://user:pass@example.com/path/to/resource?query=x#fragment") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have an authority segment of 'user:pass@example.com'" do + expect(@uri.authority).to eq("user:pass@example.com") + end + + it "should have a username of 'user'" do + expect(@uri.user).to eq("user") + end + + it "should have a password of 'pass'" do + expect(@uri.password).to eq("pass") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/path/to/resource'" do + expect(@uri.path).to eq("/path/to/resource") + end + + it "should have a query string of 'query=x'" do + expect(@uri.query).to eq("query=x") + end + + it "should have a fragment of 'fragment'" do + expect(@uri.fragment).to eq("fragment") + end + + it "should be considered to be in normal form" do + expect(@uri.normalize).to be_eql(@uri) + end + + it "should have a route of '../../' to " + + "'http://user:pass@example.com/path/'" do + expect(@uri.route_to("http://user:pass@example.com/path/")).to eq( + Addressable::URI.parse("../../") + ) + end + + it "should have a route of 'to/resource?query=x#fragment' " + + "from 'http://user:pass@example.com/path/'" do + expect(@uri.route_from("http://user:pass@example.com/path/")).to eq( + Addressable::URI.parse("to/resource?query=x#fragment") + ) + end + + it "should have a route of '?query=x#fragment' " + + "from 'http://user:pass@example.com/path/to/resource'" do + expect(@uri.route_from("http://user:pass@example.com/path/to/resource")).to eq( + Addressable::URI.parse("?query=x#fragment") + ) + end + + it "should have a route of '#fragment' " + + "from 'http://user:pass@example.com/path/to/resource?query=x'" do + expect(@uri.route_from( + "http://user:pass@example.com/path/to/resource?query=x")).to eq( + Addressable::URI.parse("#fragment") + ) + end + + it "should have a route of '#fragment' from " + + "'http://user:pass@example.com/path/to/resource?query=x#fragment'" do + expect(@uri.route_from( + "http://user:pass@example.com/path/to/resource?query=x#fragment" + )).to eq(Addressable::URI.parse("#fragment")) + end + + it "should have a route of 'http://elsewhere.com/' to " + + "'http://elsewhere.com/'" do + expect(@uri.route_to("http://elsewhere.com/")).to eq( + Addressable::URI.parse("http://elsewhere.com/") + ) + end + + it "should have a route of " + + "'http://user:pass@example.com/path/to/resource?query=x#fragment' " + + "from 'http://example.com/path/to/'" do + expect(@uri.route_from("http://elsewhere.com/path/to/")).to eq( + Addressable::URI.parse( + "http://user:pass@example.com/path/to/resource?query=x#fragment") + ) + end + + it "should have the correct scheme after assignment" do + @uri.scheme = "ftp" + expect(@uri.scheme).to eq("ftp") + expect(@uri.to_s).to eq( + "ftp://user:pass@example.com/path/to/resource?query=x#fragment" + ) + expect(@uri.to_str).to eq( + "ftp://user:pass@example.com/path/to/resource?query=x#fragment" + ) + end + + it "should have the correct site segment after assignment" do + @uri.site = "https://newuser:newpass@example.com:443" + expect(@uri.scheme).to eq("https") + expect(@uri.authority).to eq("newuser:newpass@example.com:443") + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("newpass") + expect(@uri.userinfo).to eq("newuser:newpass") + expect(@uri.normalized_userinfo).to eq("newuser:newpass") + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(443) + expect(@uri.inferred_port).to eq(443) + expect(@uri.to_s).to eq( + "https://newuser:newpass@example.com:443" + + "/path/to/resource?query=x#fragment" + ) + end + + it "should have the correct authority segment after assignment" do + @uri.authority = "newuser:newpass@example.com:80" + expect(@uri.authority).to eq("newuser:newpass@example.com:80") + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("newpass") + expect(@uri.userinfo).to eq("newuser:newpass") + expect(@uri.normalized_userinfo).to eq("newuser:newpass") + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(80) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq( + "http://newuser:newpass@example.com:80" + + "/path/to/resource?query=x#fragment" + ) + end + + it "should have the correct userinfo segment after assignment" do + @uri.userinfo = "newuser:newpass" + expect(@uri.userinfo).to eq("newuser:newpass") + expect(@uri.authority).to eq("newuser:newpass@example.com") + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("newpass") + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(nil) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq( + "http://newuser:newpass@example.com" + + "/path/to/resource?query=x#fragment" + ) + end + + it "should have the correct username after assignment" do + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + expect(@uri.authority).to eq("newuser:pass@example.com") + end + + it "should have the correct password after assignment" do + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + expect(@uri.authority).to eq("user:newpass@example.com") + end + + it "should have the correct host after assignment" do + @uri.host = "newexample.com" + expect(@uri.host).to eq("newexample.com") + expect(@uri.authority).to eq("user:pass@newexample.com") + end + + it "should have the correct host after assignment" do + @uri.hostname = "newexample.com" + expect(@uri.host).to eq("newexample.com") + expect(@uri.hostname).to eq("newexample.com") + expect(@uri.authority).to eq("user:pass@newexample.com") + end + + it "should raise an error if assigning a bogus object to the hostname" do + expect do + @uri.hostname = Object.new + end.to raise_error(TypeError) + end + + it "should have the correct port after assignment" do + @uri.port = 8080 + expect(@uri.port).to eq(8080) + expect(@uri.authority).to eq("user:pass@example.com:8080") + end + + it "should have the correct origin after assignment" do + @uri.origin = "http://newexample.com" + expect(@uri.host).to eq("newexample.com") + expect(@uri.authority).to eq("newexample.com") + end + + it "should have the correct path after assignment" do + @uri.path = "/newpath/to/resource" + expect(@uri.path).to eq("/newpath/to/resource") + expect(@uri.to_s).to eq( + "http://user:pass@example.com/newpath/to/resource?query=x#fragment" + ) + end + + it "should have the correct scheme and authority after nil assignment" do + @uri.site = nil + expect(@uri.scheme).to eq(nil) + expect(@uri.authority).to eq(nil) + expect(@uri.to_s).to eq("/path/to/resource?query=x#fragment") + end + + it "should have the correct scheme and authority after assignment" do + @uri.site = "file://" + expect(@uri.scheme).to eq("file") + expect(@uri.authority).to eq("") + expect(@uri.to_s).to eq("file:///path/to/resource?query=x#fragment") + end + + it "should have the correct path after nil assignment" do + @uri.path = nil + expect(@uri.path).to eq("") + expect(@uri.to_s).to eq( + "http://user:pass@example.com?query=x#fragment" + ) + end + + it "should have the correct query string after assignment" do + @uri.query = "newquery=x" + expect(@uri.query).to eq("newquery=x") + expect(@uri.to_s).to eq( + "http://user:pass@example.com/path/to/resource?newquery=x#fragment" + ) + @uri.query = nil + expect(@uri.query).to eq(nil) + expect(@uri.to_s).to eq( + "http://user:pass@example.com/path/to/resource#fragment" + ) + end + + it "should have the correct query string after hash assignment" do + @uri.query_values = {"?uestion mark" => "=sign", "hello" => "g\xC3\xBCnther"} + expect(@uri.query.split("&")).to include("%3Fuestion%20mark=%3Dsign") + expect(@uri.query.split("&")).to include("hello=g%C3%BCnther") + expect(@uri.query_values).to eq({ + "?uestion mark" => "=sign", "hello" => "g\xC3\xBCnther" + }) + end + + it "should have the correct query string after flag hash assignment" do + @uri.query_values = {'flag?1' => nil, 'fl=ag2' => nil, 'flag3' => nil} + expect(@uri.query.split("&")).to include("flag%3F1") + expect(@uri.query.split("&")).to include("fl%3Dag2") + expect(@uri.query.split("&")).to include("flag3") + expect(@uri.query_values(Array).sort).to eq([["fl=ag2"], ["flag3"], ["flag?1"]]) + expect(@uri.query_values(Hash)).to eq({ + 'flag?1' => nil, 'fl=ag2' => nil, 'flag3' => nil + }) + end + + it "should raise an error if query values are set to a bogus type" do + expect do + @uri.query_values = "bogus" + end.to raise_error(TypeError) + end + + it "should have the correct fragment after assignment" do + @uri.fragment = "newfragment" + expect(@uri.fragment).to eq("newfragment") + expect(@uri.to_s).to eq( + "http://user:pass@example.com/path/to/resource?query=x#newfragment" + ) + + @uri.fragment = nil + expect(@uri.fragment).to eq(nil) + expect(@uri.to_s).to eq( + "http://user:pass@example.com/path/to/resource?query=x" + ) + end + + it "should have the correct values after a merge" do + expect(@uri.merge(:fragment => "newfragment").to_s).to eq( + "http://user:pass@example.com/path/to/resource?query=x#newfragment" + ) + end + + it "should have the correct values after a merge" do + expect(@uri.merge(:fragment => nil).to_s).to eq( + "http://user:pass@example.com/path/to/resource?query=x" + ) + end + + it "should have the correct values after a merge" do + expect(@uri.merge(:userinfo => "newuser:newpass").to_s).to eq( + "http://newuser:newpass@example.com/path/to/resource?query=x#fragment" + ) + end + + it "should have the correct values after a merge" do + expect(@uri.merge(:userinfo => nil).to_s).to eq( + "http://example.com/path/to/resource?query=x#fragment" + ) + end + + it "should have the correct values after a merge" do + expect(@uri.merge(:path => "newpath").to_s).to eq( + "http://user:pass@example.com/newpath?query=x#fragment" + ) + end + + it "should have the correct values after a merge" do + expect(@uri.merge(:port => "42", :path => "newpath", :query => "").to_s).to eq( + "http://user:pass@example.com:42/newpath?#fragment" + ) + end + + it "should have the correct values after a merge" do + expect(@uri.merge(:authority => "foo:bar@baz:42").to_s).to eq( + "http://foo:bar@baz:42/path/to/resource?query=x#fragment" + ) + # Ensure the operation was not destructive + expect(@uri.to_s).to eq( + "http://user:pass@example.com/path/to/resource?query=x#fragment" + ) + end + + it "should have the correct values after a destructive merge" do + @uri.merge!(:authority => "foo:bar@baz:42") + # Ensure the operation was destructive + expect(@uri.to_s).to eq( + "http://foo:bar@baz:42/path/to/resource?query=x#fragment" + ) + end + + it "should fail to merge with bogus values" do + expect do + @uri.merge(:port => "bogus") + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should fail to merge with bogus values" do + expect do + @uri.merge(:authority => "bar@baz:bogus") + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should fail to merge with bogus parameters" do + expect do + @uri.merge(42) + end.to raise_error(TypeError) + end + + it "should fail to merge with bogus parameters" do + expect do + @uri.merge("http://example.com/") + end.to raise_error(TypeError) + end + + it "should fail to merge with both authority and subcomponents" do + expect do + @uri.merge(:authority => "foo:bar@baz:42", :port => "42") + end.to raise_error(ArgumentError) + end + + it "should fail to merge with both userinfo and subcomponents" do + expect do + @uri.merge(:userinfo => "foo:bar", :user => "foo") + end.to raise_error(ArgumentError) + end + + it "should be identical to its duplicate" do + expect(@uri).to eq(@uri.dup) + end + + it "should have an origin of 'http://example.com'" do + expect(@uri.origin).to eq('http://example.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/search?q=Q%26A'" do + + before do + @uri = Addressable::URI.parse("http://example.com/search?q=Q%26A") + end + + it "should have a query of 'q=Q%26A'" do + expect(@uri.query).to eq("q=Q%26A") + end + + it "should have query_values of {'q' => 'Q&A'}" do + expect(@uri.query_values).to eq({ 'q' => 'Q&A' }) + end + + it "should normalize to the original uri " + + "(with the ampersand properly percent-encoded)" do + expect(@uri.normalize.to_s).to eq("http://example.com/search?q=Q%26A") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?&x=b'" do + before do + @uri = Addressable::URI.parse("http://example.com/?&x=b") + end + + it "should have a query of '&x=b'" do + expect(@uri.query).to eq("&x=b") + end + + it "should have query_values of {'x' => 'b'}" do + expect(@uri.query_values).to eq({'x' => 'b'}) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?q='one;two'&x=1'" do + before do + @uri = Addressable::URI.parse("http://example.com/?q='one;two'&x=1") + end + + it "should have a query of 'q='one;two'&x=1'" do + expect(@uri.query).to eq("q='one;two'&x=1") + end + + it "should have query_values of {\"q\" => \"'one;two'\", \"x\" => \"1\"}" do + expect(@uri.query_values).to eq({"q" => "'one;two'", "x" => "1"}) + end + + it "should escape the ';' character when normalizing to avoid ambiguity " + + "with the W3C HTML 4.01 specification" do + # HTML 4.01 Section B.2.2 + expect(@uri.normalize.query).to eq("q='one%3Btwo'&x=1") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?&&x=b'" do + before do + @uri = Addressable::URI.parse("http://example.com/?&&x=b") + end + + it "should have a query of '&&x=b'" do + expect(@uri.query).to eq("&&x=b") + end + + it "should have query_values of {'x' => 'b'}" do + expect(@uri.query_values).to eq({'x' => 'b'}) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?q=a&&x=b'" do + before do + @uri = Addressable::URI.parse("http://example.com/?q=a&&x=b") + end + + it "should have a query of 'q=a&&x=b'" do + expect(@uri.query).to eq("q=a&&x=b") + end + + it "should have query_values of {'q' => 'a, 'x' => 'b'}" do + expect(@uri.query_values).to eq({'q' => 'a', 'x' => 'b'}) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?q&&x=b'" do + before do + @uri = Addressable::URI.parse("http://example.com/?q&&x=b") + end + + it "should have a query of 'q&&x=b'" do + expect(@uri.query).to eq("q&&x=b") + end + + it "should have query_values of {'q' => true, 'x' => 'b'}" do + expect(@uri.query_values).to eq({'q' => nil, 'x' => 'b'}) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?q=a+b'" do + before do + @uri = Addressable::URI.parse("http://example.com/?q=a+b") + end + + it "should have a query of 'q=a+b'" do + expect(@uri.query).to eq("q=a+b") + end + + it "should have query_values of {'q' => 'a b'}" do + expect(@uri.query_values).to eq({'q' => 'a b'}) + end + + it "should have a normalized query of 'q=a+b'" do + expect(@uri.normalized_query).to eq("q=a+b") + end +end + +describe Addressable::URI, "when parsed from 'https://example.com/?q=a+b'" do + before do + @uri = Addressable::URI.parse("https://example.com/?q=a+b") + end + + it "should have query_values of {'q' => 'a b'}" do + expect(@uri.query_values).to eq("q" => "a b") + end +end + +describe Addressable::URI, "when parsed from 'example.com?q=a+b'" do + before do + @uri = Addressable::URI.parse("example.com?q=a+b") + end + + it "should have query_values of {'q' => 'a b'}" do + expect(@uri.query_values).to eq("q" => "a b") + end +end + +describe Addressable::URI, "when parsed from 'mailto:?q=a+b'" do + before do + @uri = Addressable::URI.parse("mailto:?q=a+b") + end + + it "should have query_values of {'q' => 'a+b'}" do + expect(@uri.query_values).to eq("q" => "a+b") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?q=a%2bb'" do + before do + @uri = Addressable::URI.parse("http://example.com/?q=a%2bb") + end + + it "should have a query of 'q=a+b'" do + expect(@uri.query).to eq("q=a%2bb") + end + + it "should have query_values of {'q' => 'a+b'}" do + expect(@uri.query_values).to eq({'q' => 'a+b'}) + end + + it "should have a normalized query of 'q=a%2Bb'" do + expect(@uri.normalized_query).to eq("q=a%2Bb") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?v=%7E&w=%&x=%25&y=%2B&z=C%CC%A7'" do + before do + @uri = Addressable::URI.parse("http://example.com/?v=%7E&w=%&x=%25&y=%2B&z=C%CC%A7") + end + + it "should have a normalized query of 'v=~&w=%25&x=%25&y=%2B&z=%C3%87'" do + expect(@uri.normalized_query).to eq("v=~&w=%25&x=%25&y=%2B&z=%C3%87") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?v=%7E&w=%&x=%25&y=+&z=C%CC%A7'" do + before do + @uri = Addressable::URI.parse("http://example.com/?v=%7E&w=%&x=%25&y=+&z=C%CC%A7") + end + + it "should have a normalized query of 'v=~&w=%25&x=%25&y=+&z=%C3%87'" do + expect(@uri.normalized_query).to eq("v=~&w=%25&x=%25&y=+&z=%C3%87") + end +end + +describe Addressable::URI, "when parsed from 'http://example/?b=1&a=2&c=3'" do + before do + @uri = Addressable::URI.parse("http://example/?b=1&a=2&c=3") + end + + it "should have a sorted normalized query of 'a=2&b=1&c=3'" do + expect(@uri.normalized_query(:sorted)).to eq("a=2&b=1&c=3") + end +end + +describe Addressable::URI, "when parsed from 'http://example/?&a&&c&'" do + before do + @uri = Addressable::URI.parse("http://example/?&a&&c&") + end + + it "should have a compacted normalized query of 'a&c'" do + expect(@uri.normalized_query(:compacted)).to eq("a&c") + end +end + +describe Addressable::URI, "when parsed from 'http://example.com/?a=1&a=1'" do + before do + @uri = Addressable::URI.parse("http://example.com/?a=1&a=1") + end + + it "should have a compacted normalized query of 'a=1'" do + expect(@uri.normalized_query(:compacted)).to eq("a=1") + end +end + +describe Addressable::URI, "when parsed from 'http://example.com/?a=1&a=2'" do + before do + @uri = Addressable::URI.parse("http://example.com/?a=1&a=2") + end + + it "should have a compacted normalized query of 'a=1&a=2'" do + expect(@uri.normalized_query(:compacted)).to eq("a=1&a=2") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/sound%2bvision'" do + before do + @uri = Addressable::URI.parse("http://example.com/sound%2bvision") + end + + it "should have a normalized path of '/sound+vision'" do + expect(@uri.normalized_path).to eq('/sound+vision') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/?q='" do + before do + @uri = Addressable::URI.parse("http://example.com/?q=") + end + + it "should have a query of 'q='" do + expect(@uri.query).to eq("q=") + end + + it "should have query_values of {'q' => ''}" do + expect(@uri.query_values).to eq({'q' => ''}) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://user@example.com'" do + before do + @uri = Addressable::URI.parse("http://user@example.com") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have a username of 'user'" do + expect(@uri.user).to eq("user") + end + + it "should have no password" do + expect(@uri.password).to eq(nil) + end + + it "should have a userinfo of 'user'" do + expect(@uri.userinfo).to eq("user") + end + + it "should have a normalized userinfo of 'user'" do + expect(@uri.normalized_userinfo).to eq("user") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have default_port 80" do + expect(@uri.default_port).to eq(80) + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have the correct username after assignment" do + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq(nil) + expect(@uri.to_s).to eq("http://newuser@example.com") + end + + it "should have the correct password after assignment" do + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + expect(@uri.to_s).to eq("http://user:newpass@example.com") + end + + it "should have the correct userinfo segment after assignment" do + @uri.userinfo = "newuser:newpass" + expect(@uri.userinfo).to eq("newuser:newpass") + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("newpass") + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(nil) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq("http://newuser:newpass@example.com") + end + + it "should have the correct userinfo segment after nil assignment" do + @uri.userinfo = nil + expect(@uri.userinfo).to eq(nil) + expect(@uri.user).to eq(nil) + expect(@uri.password).to eq(nil) + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(nil) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq("http://example.com") + end + + it "should have the correct authority segment after assignment" do + @uri.authority = "newuser@example.com" + expect(@uri.authority).to eq("newuser@example.com") + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq(nil) + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(nil) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq("http://newuser@example.com") + end + + it "should raise an error after nil assignment of authority segment" do + expect do + # This would create an invalid URI + @uri.authority = nil + end.to raise_error(Addressable::URI::InvalidURIError) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://user:@example.com'" do + before do + @uri = Addressable::URI.parse("http://user:@example.com") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have a username of 'user'" do + expect(@uri.user).to eq("user") + end + + it "should have a password of ''" do + expect(@uri.password).to eq("") + end + + it "should have a normalized userinfo of 'user:'" do + expect(@uri.normalized_userinfo).to eq("user:") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have the correct username after assignment" do + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("") + expect(@uri.to_s).to eq("http://newuser:@example.com") + end + + it "should have the correct password after assignment" do + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + expect(@uri.to_s).to eq("http://user:newpass@example.com") + end + + it "should have the correct authority segment after assignment" do + @uri.authority = "newuser:@example.com" + expect(@uri.authority).to eq("newuser:@example.com") + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("") + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(nil) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq("http://newuser:@example.com") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://:pass@example.com'" do + before do + @uri = Addressable::URI.parse("http://:pass@example.com") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have a username of ''" do + expect(@uri.user).to eq("") + end + + it "should have a password of 'pass'" do + expect(@uri.password).to eq("pass") + end + + it "should have a userinfo of ':pass'" do + expect(@uri.userinfo).to eq(":pass") + end + + it "should have a normalized userinfo of ':pass'" do + expect(@uri.normalized_userinfo).to eq(":pass") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have the correct username after assignment" do + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("pass") + expect(@uri.to_s).to eq("http://newuser:pass@example.com") + end + + it "should have the correct password after assignment" do + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + expect(@uri.user).to eq("") + expect(@uri.to_s).to eq("http://:newpass@example.com") + end + + it "should have the correct authority segment after assignment" do + @uri.authority = ":newpass@example.com" + expect(@uri.authority).to eq(":newpass@example.com") + expect(@uri.user).to eq("") + expect(@uri.password).to eq("newpass") + expect(@uri.host).to eq("example.com") + expect(@uri.port).to eq(nil) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq("http://:newpass@example.com") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://:@example.com'" do + before do + @uri = Addressable::URI.parse("http://:@example.com") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have a username of ''" do + expect(@uri.user).to eq("") + end + + it "should have a password of ''" do + expect(@uri.password).to eq("") + end + + it "should have a normalized userinfo of nil" do + expect(@uri.normalized_userinfo).to eq(nil) + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have the correct username after assignment" do + @uri.user = "newuser" + expect(@uri.user).to eq("newuser") + expect(@uri.password).to eq("") + expect(@uri.to_s).to eq("http://newuser:@example.com") + end + + it "should have the correct password after assignment" do + @uri.password = "newpass" + expect(@uri.password).to eq("newpass") + expect(@uri.user).to eq("") + expect(@uri.to_s).to eq("http://:newpass@example.com") + end + + it "should have the correct authority segment after assignment" do + @uri.authority = ":@newexample.com" + expect(@uri.authority).to eq(":@newexample.com") + expect(@uri.user).to eq("") + expect(@uri.password).to eq("") + expect(@uri.host).to eq("newexample.com") + expect(@uri.port).to eq(nil) + expect(@uri.inferred_port).to eq(80) + expect(@uri.to_s).to eq("http://:@newexample.com") + end +end + +describe Addressable::URI, "when parsed from " + + "'#example'" do + before do + @uri = Addressable::URI.parse("#example") + end + + it "should be considered relative" do + expect(@uri).to be_relative + end + + it "should have a host of nil" do + expect(@uri.host).to eq(nil) + end + + it "should have a site of nil" do + expect(@uri.site).to eq(nil) + end + + it "should have a normalized_site of nil" do + expect(@uri.normalized_site).to eq(nil) + end + + it "should have a path of ''" do + expect(@uri.path).to eq("") + end + + it "should have a query string of nil" do + expect(@uri.query).to eq(nil) + end + + it "should have a fragment of 'example'" do + expect(@uri.fragment).to eq("example") + end +end + +describe Addressable::URI, "when parsed from " + + "the network-path reference '//example.com/'" do + before do + @uri = Addressable::URI.parse("//example.com/") + end + + it "should be considered relative" do + expect(@uri).to be_relative + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should have a path of '/'" do + expect(@uri.path).to eq("/") + end + + it "should raise an error if routing is attempted" do + expect do + @uri.route_to("http://example.com/") + end.to raise_error(ArgumentError, /\/\/example.com\//) + expect do + @uri.route_from("http://example.com/") + end.to raise_error(ArgumentError, /\/\/example.com\//) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from " + + "'feed://http://example.com/'" do + before do + @uri = Addressable::URI.parse("feed://http://example.com/") + end + + it "should have a host of 'http'" do + expect(@uri.host).to eq("http") + end + + it "should have a path of '//example.com/'" do + expect(@uri.path).to eq("//example.com/") + end +end + +describe Addressable::URI, "when parsed from " + + "'feed:http://example.com/'" do + before do + @uri = Addressable::URI.parse("feed:http://example.com/") + end + + it "should have a path of 'http://example.com/'" do + expect(@uri.path).to eq("http://example.com/") + end + + it "should normalize to 'http://example.com/'" do + expect(@uri.normalize.to_s).to eq("http://example.com/") + expect(@uri.normalize!.to_s).to eq("http://example.com/") + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from " + + "'example://a/b/c/%7Bfoo%7D'" do + before do + @uri = Addressable::URI.parse("example://a/b/c/%7Bfoo%7D") + end + + # Section 6.2.2 of RFC 3986 + it "should be equivalent to eXAMPLE://a/./b/../b/%63/%7bfoo%7d" do + expect(@uri).to eq( + Addressable::URI.parse("eXAMPLE://a/./b/../b/%63/%7bfoo%7d") + ) + end + + it "should have an origin of 'example://a'" do + expect(@uri.origin).to eq('example://a') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://example.com/indirect/path/./to/../resource/'" do + before do + @uri = Addressable::URI.parse( + "http://example.com/indirect/path/./to/../resource/") + end + + it "should use the 'http' scheme" do + expect(@uri.scheme).to eq("http") + end + + it "should have a host of 'example.com'" do + expect(@uri.host).to eq("example.com") + end + + it "should use port 80" do + expect(@uri.inferred_port).to eq(80) + end + + it "should have a path of '/indirect/path/./to/../resource/'" do + expect(@uri.path).to eq("/indirect/path/./to/../resource/") + end + + # Section 6.2.2.3 of RFC 3986 + it "should have a normalized path of '/indirect/path/resource/'" do + expect(@uri.normalize.path).to eq("/indirect/path/resource/") + expect(@uri.normalize!.path).to eq("/indirect/path/resource/") + end +end + +describe Addressable::URI, "when parsed from " + + "'http://under_score.example.com/'" do + it "should not cause an error" do + expect do + Addressable::URI.parse("http://under_score.example.com/") + end.not_to raise_error + end +end + +describe Addressable::URI, "when parsed from " + + "'./this:that'" do + before do + @uri = Addressable::URI.parse("./this:that") + end + + it "should be considered relative" do + expect(@uri).to be_relative + end + + it "should have no scheme" do + expect(@uri.scheme).to eq(nil) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from " + + "'this:that'" do + before do + @uri = Addressable::URI.parse("this:that") + end + + it "should be considered absolute" do + expect(@uri).to be_absolute + end + + it "should have a scheme of 'this'" do + expect(@uri.scheme).to eq("this") + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from '?'" do + before do + @uri = Addressable::URI.parse("?") + end + + it "should normalize to ''" do + expect(@uri.normalize.to_s).to eq("") + end + + it "should have the correct return type" do + expect(@uri.query_values).to eq({}) + expect(@uri.query_values(Hash)).to eq({}) + expect(@uri.query_values(Array)).to eq([]) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from '?one=1&two=2&three=3'" do + before do + @uri = Addressable::URI.parse("?one=1&two=2&three=3") + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({"one" => "1", "two" => "2", "three" => "3"}) + end + + it "should raise an error for invalid return type values" do + expect do + @uri.query_values(Integer) + end.to raise_error(ArgumentError) + end + + it "should have the correct array query values" do + expect(@uri.query_values(Array)).to eq([ + ["one", "1"], ["two", "2"], ["three", "3"] + ]) + end + + it "should have a 'null' origin" do + expect(@uri.origin).to eq('null') + end +end + +describe Addressable::URI, "when parsed from '?one=1=uno&two=2=dos'" do + before do + @uri = Addressable::URI.parse("?one=1=uno&two=2=dos") + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({"one" => "1=uno", "two" => "2=dos"}) + end + + it "should have the correct array query values" do + expect(@uri.query_values(Array)).to eq([ + ["one", "1=uno"], ["two", "2=dos"] + ]) + end +end + +describe Addressable::URI, "when parsed from '?one[two][three]=four'" do + before do + @uri = Addressable::URI.parse("?one[two][three]=four") + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({"one[two][three]" => "four"}) + end + + it "should have the correct array query values" do + expect(@uri.query_values(Array)).to eq([ + ["one[two][three]", "four"] + ]) + end +end + +describe Addressable::URI, "when parsed from '?one.two.three=four'" do + before do + @uri = Addressable::URI.parse("?one.two.three=four") + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({ + "one.two.three" => "four" + }) + end + + it "should have the correct array query values" do + expect(@uri.query_values(Array)).to eq([ + ["one.two.three", "four"] + ]) + end +end + +describe Addressable::URI, "when parsed from " + + "'?one[two][three]=four&one[two][five]=six'" do + before do + @uri = Addressable::URI.parse("?one[two][three]=four&one[two][five]=six") + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({ + "one[two][three]" => "four", "one[two][five]" => "six" + }) + end + + it "should have the correct array query values" do + expect(@uri.query_values(Array)).to eq([ + ["one[two][three]", "four"], ["one[two][five]", "six"] + ]) + end +end + +describe Addressable::URI, "when parsed from " + + "'?one.two.three=four&one.two.five=six'" do + before do + @uri = Addressable::URI.parse("?one.two.three=four&one.two.five=six") + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({ + "one.two.three" => "four", "one.two.five" => "six" + }) + end + + it "should have the correct array query values" do + expect(@uri.query_values(Array)).to eq([ + ["one.two.three", "four"], ["one.two.five", "six"] + ]) + end +end + +describe Addressable::URI, "when parsed from " + + "'?one=two&one=three'" do + before do + @uri = Addressable::URI.parse( + "?one=two&one=three&one=four" + ) + end + + it "should have correct array query values" do + expect(@uri.query_values(Array)).to eq( + [['one', 'two'], ['one', 'three'], ['one', 'four']] + ) + end + + it "should have correct hash query values" do + skip("This is probably more desirable behavior.") + expect(@uri.query_values(Hash)).to eq( + {'one' => ['two', 'three', 'four']} + ) + end + + it "should handle assignment with keys of mixed type" do + @uri.query_values = @uri.query_values(Hash).merge({:one => 'three'}) + expect(@uri.query_values(Hash)).to eq({'one' => 'three'}) + end +end + +describe Addressable::URI, "when parsed from " + + "'?one[two][three][]=four&one[two][three][]=five'" do + before do + @uri = Addressable::URI.parse( + "?one[two][three][]=four&one[two][three][]=five" + ) + end + + it "should have correct query values" do + expect(@uri.query_values(Hash)).to eq({"one[two][three][]" => "five"}) + end + + it "should have correct array query values" do + expect(@uri.query_values(Array)).to eq([ + ["one[two][three][]", "four"], ["one[two][three][]", "five"] + ]) + end +end + +describe Addressable::URI, "when parsed from " + + "'?one[two][three][0]=four&one[two][three][1]=five'" do + before do + @uri = Addressable::URI.parse( + "?one[two][three][0]=four&one[two][three][1]=five" + ) + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({ + "one[two][three][0]" => "four", "one[two][three][1]" => "five" + }) + end +end + +describe Addressable::URI, "when parsed from " + + "'?one[two][three][1]=four&one[two][three][0]=five'" do + before do + @uri = Addressable::URI.parse( + "?one[two][three][1]=four&one[two][three][0]=five" + ) + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({ + "one[two][three][1]" => "four", "one[two][three][0]" => "five" + }) + end +end + +describe Addressable::URI, "when parsed from " + + "'?one[two][three][2]=four&one[two][three][1]=five'" do + before do + @uri = Addressable::URI.parse( + "?one[two][three][2]=four&one[two][three][1]=five" + ) + end + + it "should have the correct query values" do + expect(@uri.query_values).to eq({ + "one[two][three][2]" => "four", "one[two][three][1]" => "five" + }) + end +end + +describe Addressable::URI, "when parsed from " + + "'http://www.詹姆斯.com/'" do + before do + @uri = Addressable::URI.parse("http://www.詹姆斯.com/") + end + + it "should be equivalent to 'http://www.xn--8ws00zhy3a.com/'" do + expect(@uri).to eq( + Addressable::URI.parse("http://www.xn--8ws00zhy3a.com/") + ) + end + + it "should not have domain name encoded during normalization" do + expect(Addressable::URI.normalized_encode(@uri.to_s)).to eq( + "http://www.詹姆斯.com/" + ) + end + + it "should have an origin of 'http://www.xn--8ws00zhy3a.com'" do + expect(@uri.origin).to eq('http://www.xn--8ws00zhy3a.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://www.詹姆斯.com/ some spaces /'" do + before do + @uri = Addressable::URI.parse("http://www.詹姆斯.com/ some spaces /") + end + + it "should be equivalent to " + + "'http://www.xn--8ws00zhy3a.com/%20some%20spaces%20/'" do + expect(@uri).to eq( + Addressable::URI.parse( + "http://www.xn--8ws00zhy3a.com/%20some%20spaces%20/") + ) + end + + it "should not have domain name encoded during normalization" do + expect(Addressable::URI.normalized_encode(@uri.to_s)).to eq( + "http://www.詹姆斯.com/%20some%20spaces%20/" + ) + end + + it "should have an origin of 'http://www.xn--8ws00zhy3a.com'" do + expect(@uri.origin).to eq('http://www.xn--8ws00zhy3a.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://www.xn--8ws00zhy3a.com/'" do + before do + @uri = Addressable::URI.parse("http://www.xn--8ws00zhy3a.com/") + end + + it "should be displayed as http://www.詹姆斯.com/" do + expect(@uri.display_uri.to_s).to eq("http://www.詹姆斯.com/") + end + + it "should properly force the encoding" do + display_string = @uri.display_uri.to_str + expect(display_string).to eq("http://www.詹姆斯.com/") + if display_string.respond_to?(:encoding) + expect(display_string.encoding.to_s).to eq(Encoding::UTF_8.to_s) + end + end + + it "should have an origin of 'http://www.xn--8ws00zhy3a.com'" do + expect(@uri.origin).to eq('http://www.xn--8ws00zhy3a.com') + end +end + +describe Addressable::URI, "when parsed from " + + "'http://www.詹姆斯.com/atomtests/iri/詹.html'" do + before do + @uri = Addressable::URI.parse("http://www.詹姆斯.com/atomtests/iri/詹.html") + end + + it "should normalize to " + + "http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html" do + expect(@uri.normalize.to_s).to eq( + "http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html" + ) + expect(@uri.normalize!.to_s).to eq( + "http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html" + ) + end +end + +describe Addressable::URI, "when parsed from a percent-encoded IRI" do + before do + @uri = Addressable::URI.parse( + "http://www.%E3%81%BB%E3%82%93%E3%81%A8%E3%81%86%E3%81%AB%E3%81%AA" + + "%E3%81%8C%E3%81%84%E3%82%8F%E3%81%91%E3%81%AE%E3%82%8F%E3%81%8B%E3" + + "%82%89%E3%81%AA%E3%81%84%E3%81%A9%E3%82%81%E3%81%84%E3%82%93%E3%82" + + "%81%E3%81%84%E3%81%AE%E3%82%89%E3%81%B9%E3%82%8B%E3%81%BE%E3%81%A0" + + "%E3%81%AA%E3%81%8C%E3%81%8F%E3%81%97%E3%81%AA%E3%81%84%E3%81%A8%E3" + + "%81%9F%E3%82%8A%E3%81%AA%E3%81%84.w3.mag.keio.ac.jp" + ) + end + + it "should normalize to something sane" do + expect(@uri.normalize.to_s).to eq( + "http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" + + "g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp/" + ) + expect(@uri.normalize!.to_s).to eq( + "http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" + + "g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp/" + ) + end + + it "should have the correct origin" do + expect(@uri.origin).to eq( + "http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" + + "g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp" + ) + end +end + +describe Addressable::URI, "with a base uri of 'http://a/b/c/d;p?q'" do + before do + @uri = Addressable::URI.parse("http://a/b/c/d;p?q") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g:h' should resolve to g:h" do + expect((@uri + "g:h").to_s).to eq("g:h") + expect(Addressable::URI.join(@uri, "g:h").to_s).to eq("g:h") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g' should resolve to http://a/b/c/g" do + expect((@uri + "g").to_s).to eq("http://a/b/c/g") + expect(Addressable::URI.join(@uri.to_s, "g").to_s).to eq("http://a/b/c/g") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with './g' should resolve to http://a/b/c/g" do + expect((@uri + "./g").to_s).to eq("http://a/b/c/g") + expect(Addressable::URI.join(@uri.to_s, "./g").to_s).to eq("http://a/b/c/g") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g/' should resolve to http://a/b/c/g/" do + expect((@uri + "g/").to_s).to eq("http://a/b/c/g/") + expect(Addressable::URI.join(@uri.to_s, "g/").to_s).to eq("http://a/b/c/g/") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '/g' should resolve to http://a/g" do + expect((@uri + "/g").to_s).to eq("http://a/g") + expect(Addressable::URI.join(@uri.to_s, "/g").to_s).to eq("http://a/g") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '//g' should resolve to http://g" do + expect((@uri + "//g").to_s).to eq("http://g") + expect(Addressable::URI.join(@uri.to_s, "//g").to_s).to eq("http://g") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '?y' should resolve to http://a/b/c/d;p?y" do + expect((@uri + "?y").to_s).to eq("http://a/b/c/d;p?y") + expect(Addressable::URI.join(@uri.to_s, "?y").to_s).to eq("http://a/b/c/d;p?y") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g?y' should resolve to http://a/b/c/g?y" do + expect((@uri + "g?y").to_s).to eq("http://a/b/c/g?y") + expect(Addressable::URI.join(@uri.to_s, "g?y").to_s).to eq("http://a/b/c/g?y") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '#s' should resolve to http://a/b/c/d;p?q#s" do + expect((@uri + "#s").to_s).to eq("http://a/b/c/d;p?q#s") + expect(Addressable::URI.join(@uri.to_s, "#s").to_s).to eq( + "http://a/b/c/d;p?q#s" + ) + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g#s' should resolve to http://a/b/c/g#s" do + expect((@uri + "g#s").to_s).to eq("http://a/b/c/g#s") + expect(Addressable::URI.join(@uri.to_s, "g#s").to_s).to eq("http://a/b/c/g#s") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g?y#s' should resolve to http://a/b/c/g?y#s" do + expect((@uri + "g?y#s").to_s).to eq("http://a/b/c/g?y#s") + expect(Addressable::URI.join( + @uri.to_s, "g?y#s").to_s).to eq("http://a/b/c/g?y#s") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with ';x' should resolve to http://a/b/c/;x" do + expect((@uri + ";x").to_s).to eq("http://a/b/c/;x") + expect(Addressable::URI.join(@uri.to_s, ";x").to_s).to eq("http://a/b/c/;x") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g;x' should resolve to http://a/b/c/g;x" do + expect((@uri + "g;x").to_s).to eq("http://a/b/c/g;x") + expect(Addressable::URI.join(@uri.to_s, "g;x").to_s).to eq("http://a/b/c/g;x") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with 'g;x?y#s' should resolve to http://a/b/c/g;x?y#s" do + expect((@uri + "g;x?y#s").to_s).to eq("http://a/b/c/g;x?y#s") + expect(Addressable::URI.join( + @uri.to_s, "g;x?y#s").to_s).to eq("http://a/b/c/g;x?y#s") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '' should resolve to http://a/b/c/d;p?q" do + expect((@uri + "").to_s).to eq("http://a/b/c/d;p?q") + expect(Addressable::URI.join(@uri.to_s, "").to_s).to eq("http://a/b/c/d;p?q") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '.' should resolve to http://a/b/c/" do + expect((@uri + ".").to_s).to eq("http://a/b/c/") + expect(Addressable::URI.join(@uri.to_s, ".").to_s).to eq("http://a/b/c/") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with './' should resolve to http://a/b/c/" do + expect((@uri + "./").to_s).to eq("http://a/b/c/") + expect(Addressable::URI.join(@uri.to_s, "./").to_s).to eq("http://a/b/c/") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '..' should resolve to http://a/b/" do + expect((@uri + "..").to_s).to eq("http://a/b/") + expect(Addressable::URI.join(@uri.to_s, "..").to_s).to eq("http://a/b/") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '../' should resolve to http://a/b/" do + expect((@uri + "../").to_s).to eq("http://a/b/") + expect(Addressable::URI.join(@uri.to_s, "../").to_s).to eq("http://a/b/") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '../g' should resolve to http://a/b/g" do + expect((@uri + "../g").to_s).to eq("http://a/b/g") + expect(Addressable::URI.join(@uri.to_s, "../g").to_s).to eq("http://a/b/g") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '../..' should resolve to http://a/" do + expect((@uri + "../..").to_s).to eq("http://a/") + expect(Addressable::URI.join(@uri.to_s, "../..").to_s).to eq("http://a/") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '../../' should resolve to http://a/" do + expect((@uri + "../../").to_s).to eq("http://a/") + expect(Addressable::URI.join(@uri.to_s, "../../").to_s).to eq("http://a/") + end + + # Section 5.4.1 of RFC 3986 + it "when joined with '../../g' should resolve to http://a/g" do + expect((@uri + "../../g").to_s).to eq("http://a/g") + expect(Addressable::URI.join(@uri.to_s, "../../g").to_s).to eq("http://a/g") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with '../../../g' should resolve to http://a/g" do + expect((@uri + "../../../g").to_s).to eq("http://a/g") + expect(Addressable::URI.join(@uri.to_s, "../../../g").to_s).to eq("http://a/g") + end + + it "when joined with '../.././../g' should resolve to http://a/g" do + expect((@uri + "../.././../g").to_s).to eq("http://a/g") + expect(Addressable::URI.join(@uri.to_s, "../.././../g").to_s).to eq( + "http://a/g" + ) + end + + # Section 5.4.2 of RFC 3986 + it "when joined with '../../../../g' should resolve to http://a/g" do + expect((@uri + "../../../../g").to_s).to eq("http://a/g") + expect(Addressable::URI.join( + @uri.to_s, "../../../../g").to_s).to eq("http://a/g") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with '/./g' should resolve to http://a/g" do + expect((@uri + "/./g").to_s).to eq("http://a/g") + expect(Addressable::URI.join(@uri.to_s, "/./g").to_s).to eq("http://a/g") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with '/../g' should resolve to http://a/g" do + expect((@uri + "/../g").to_s).to eq("http://a/g") + expect(Addressable::URI.join(@uri.to_s, "/../g").to_s).to eq("http://a/g") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g.' should resolve to http://a/b/c/g." do + expect((@uri + "g.").to_s).to eq("http://a/b/c/g.") + expect(Addressable::URI.join(@uri.to_s, "g.").to_s).to eq("http://a/b/c/g.") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with '.g' should resolve to http://a/b/c/.g" do + expect((@uri + ".g").to_s).to eq("http://a/b/c/.g") + expect(Addressable::URI.join(@uri.to_s, ".g").to_s).to eq("http://a/b/c/.g") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g..' should resolve to http://a/b/c/g.." do + expect((@uri + "g..").to_s).to eq("http://a/b/c/g..") + expect(Addressable::URI.join(@uri.to_s, "g..").to_s).to eq("http://a/b/c/g..") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with '..g' should resolve to http://a/b/c/..g" do + expect((@uri + "..g").to_s).to eq("http://a/b/c/..g") + expect(Addressable::URI.join(@uri.to_s, "..g").to_s).to eq("http://a/b/c/..g") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with './../g' should resolve to http://a/b/g" do + expect((@uri + "./../g").to_s).to eq("http://a/b/g") + expect(Addressable::URI.join(@uri.to_s, "./../g").to_s).to eq("http://a/b/g") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with './g/.' should resolve to http://a/b/c/g/" do + expect((@uri + "./g/.").to_s).to eq("http://a/b/c/g/") + expect(Addressable::URI.join(@uri.to_s, "./g/.").to_s).to eq("http://a/b/c/g/") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g/./h' should resolve to http://a/b/c/g/h" do + expect((@uri + "g/./h").to_s).to eq("http://a/b/c/g/h") + expect(Addressable::URI.join(@uri.to_s, "g/./h").to_s).to eq("http://a/b/c/g/h") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g/../h' should resolve to http://a/b/c/h" do + expect((@uri + "g/../h").to_s).to eq("http://a/b/c/h") + expect(Addressable::URI.join(@uri.to_s, "g/../h").to_s).to eq("http://a/b/c/h") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g;x=1/./y' " + + "should resolve to http://a/b/c/g;x=1/y" do + expect((@uri + "g;x=1/./y").to_s).to eq("http://a/b/c/g;x=1/y") + expect(Addressable::URI.join( + @uri.to_s, "g;x=1/./y").to_s).to eq("http://a/b/c/g;x=1/y") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g;x=1/../y' should resolve to http://a/b/c/y" do + expect((@uri + "g;x=1/../y").to_s).to eq("http://a/b/c/y") + expect(Addressable::URI.join( + @uri.to_s, "g;x=1/../y").to_s).to eq("http://a/b/c/y") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g?y/./x' " + + "should resolve to http://a/b/c/g?y/./x" do + expect((@uri + "g?y/./x").to_s).to eq("http://a/b/c/g?y/./x") + expect(Addressable::URI.join( + @uri.to_s, "g?y/./x").to_s).to eq("http://a/b/c/g?y/./x") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g?y/../x' " + + "should resolve to http://a/b/c/g?y/../x" do + expect((@uri + "g?y/../x").to_s).to eq("http://a/b/c/g?y/../x") + expect(Addressable::URI.join( + @uri.to_s, "g?y/../x").to_s).to eq("http://a/b/c/g?y/../x") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g#s/./x' " + + "should resolve to http://a/b/c/g#s/./x" do + expect((@uri + "g#s/./x").to_s).to eq("http://a/b/c/g#s/./x") + expect(Addressable::URI.join( + @uri.to_s, "g#s/./x").to_s).to eq("http://a/b/c/g#s/./x") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'g#s/../x' " + + "should resolve to http://a/b/c/g#s/../x" do + expect((@uri + "g#s/../x").to_s).to eq("http://a/b/c/g#s/../x") + expect(Addressable::URI.join( + @uri.to_s, "g#s/../x").to_s).to eq("http://a/b/c/g#s/../x") + end + + # Section 5.4.2 of RFC 3986 + it "when joined with 'http:g' should resolve to http:g" do + expect((@uri + "http:g").to_s).to eq("http:g") + expect(Addressable::URI.join(@uri.to_s, "http:g").to_s).to eq("http:g") + end + + # Edge case to be sure + it "when joined with '//example.com/' should " + + "resolve to http://example.com/" do + expect((@uri + "//example.com/").to_s).to eq("http://example.com/") + expect(Addressable::URI.join( + @uri.to_s, "//example.com/").to_s).to eq("http://example.com/") + end + + it "when joined with a bogus object a TypeError should be raised" do + expect do + Addressable::URI.join(@uri, 42) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when converting the path " + + "'relative/path/to/something'" do + before do + @path = 'relative/path/to/something' + end + + it "should convert to " + + "\'relative/path/to/something\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("relative/path/to/something") + end + + it "should join with an absolute file path correctly" do + @base = Addressable::URI.convert_path("/absolute/path/") + @uri = Addressable::URI.convert_path(@path) + expect((@base + @uri).to_str).to eq( + "file:///absolute/path/relative/path/to/something" + ) + end +end + +describe Addressable::URI, "when converting a bogus path" do + it "should raise a TypeError" do + expect do + Addressable::URI.convert_path(42) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when given a UNIX root directory" do + before do + @path = "/" + end + + it "should convert to \'file:///\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given a Windows root directory" do + before do + @path = "C:\\" + end + + it "should convert to \'file:///c:/\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///c:/") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given the path '/one/two/'" do + before do + @path = '/one/two/' + end + + it "should convert to " + + "\'file:///one/two/\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///one/two/") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given the tld " do + it "'uk' should have a tld of 'uk'" do + uri = Addressable::URI.parse("http://example.com") + uri.tld = "uk" + + expect(uri.tld).to eq("uk") + end + + context "which " do + let (:uri) { Addressable::URI.parse("http://www.comrade.net/path/to/source/") } + + it "contains a subdomain" do + uri.tld = "co.uk" + + expect(uri.to_s).to eq("http://www.comrade.co.uk/path/to/source/") + end + + it "is part of the domain" do + uri.tld = "com" + + expect(uri.to_s).to eq("http://www.comrade.com/path/to/source/") + end + end +end + +describe Addressable::URI, "when given the path " + + "'c:\\windows\\My Documents 100%20\\foo.txt'" do + before do + @path = "c:\\windows\\My Documents 100%20\\foo.txt" + end + + it "should convert to " + + "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///c:/windows/My%20Documents%20100%20/foo.txt") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given the path " + + "'file://c:\\windows\\My Documents 100%20\\foo.txt'" do + before do + @path = "file://c:\\windows\\My Documents 100%20\\foo.txt" + end + + it "should convert to " + + "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///c:/windows/My%20Documents%20100%20/foo.txt") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given the path " + + "'file:c:\\windows\\My Documents 100%20\\foo.txt'" do + before do + @path = "file:c:\\windows\\My Documents 100%20\\foo.txt" + end + + it "should convert to " + + "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///c:/windows/My%20Documents%20100%20/foo.txt") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given the path " + + "'file:/c:\\windows\\My Documents 100%20\\foo.txt'" do + before do + @path = "file:/c:\\windows\\My Documents 100%20\\foo.txt" + end + + it "should convert to " + + "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///c:/windows/My%20Documents%20100%20/foo.txt") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given the path " + + "'file:///c|/windows/My%20Documents%20100%20/foo.txt'" do + before do + @path = "file:///c|/windows/My%20Documents%20100%20/foo.txt" + end + + it "should convert to " + + "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("file:///c:/windows/My%20Documents%20100%20/foo.txt") + end + + it "should have an origin of 'file://'" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.origin).to eq('file://') + end +end + +describe Addressable::URI, "when given an http protocol URI" do + before do + @path = "http://example.com/" + end + + it "should not do any conversion at all" do + @uri = Addressable::URI.convert_path(@path) + expect(@uri.to_str).to eq("http://example.com/") + end +end + +class SuperString + def initialize(string) + @string = string.to_s + end + + def to_str + return @string + end +end + +describe Addressable::URI, "when parsing a non-String object" do + it "should correctly parse anything with a 'to_str' method" do + Addressable::URI.parse(SuperString.new(42)) + end + + it "should raise a TypeError for objects than cannot be converted" do + expect do + Addressable::URI.parse(42) + end.to raise_error(TypeError) + end + + it "should correctly parse heuristically anything with a 'to_str' method" do + Addressable::URI.heuristic_parse(SuperString.new(42)) + end + + it "should raise a TypeError for objects than cannot be converted" do + expect do + Addressable::URI.heuristic_parse(42) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when form encoding a hash" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.form_encode( + [["&one", "/1"], ["=two", "?2"], [":three", "#3"]] + )).to eq("%26one=%2F1&%3Dtwo=%3F2&%3Athree=%233") + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.form_encode( + {"q" => "one two three"} + )).to eq("q=one+two+three") + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.form_encode( + {"key" => nil} + )).to eq("key=") + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.form_encode( + {"q" => ["one", "two", "three"]} + )).to eq("q=one&q=two&q=three") + end + + it "should result in correctly encoded newlines" do + expect(Addressable::URI.form_encode( + {"text" => "one\ntwo\rthree\r\nfour\n\r"} + )).to eq("text=one%0D%0Atwo%0D%0Athree%0D%0Afour%0D%0A%0D%0A") + end + + it "should result in a sorted percent encoded sequence" do + expect(Addressable::URI.form_encode( + [["a", "1"], ["dup", "3"], ["dup", "2"]], true + )).to eq("a=1&dup=2&dup=3") + end +end + +describe Addressable::URI, "when form encoding a non-Array object" do + it "should raise a TypeError for objects than cannot be converted" do + expect do + Addressable::URI.form_encode(42) + end.to raise_error(TypeError) + end +end + +# See https://tools.ietf.org/html/rfc6749#appendix-B +describe Addressable::URI, "when form encoding the example value from OAuth 2" do + it "should result in correct values" do + expect(Addressable::URI.form_encode( + {"value" => " %&+£€"} + )).to eq("value=+%25%26%2B%C2%A3%E2%82%AC") + end +end + +# See https://tools.ietf.org/html/rfc6749#appendix-B +describe Addressable::URI, "when form unencoding the example value from OAuth 2" do + it "should result in correct values" do + expect(Addressable::URI.form_unencode( + "value=+%25%26%2B%C2%A3%E2%82%AC" + )).to eq([["value", " %&+£€"]]) + end +end + +describe Addressable::URI, "when form unencoding a string" do + it "should result in correct values" do + expect(Addressable::URI.form_unencode( + "%26one=%2F1&%3Dtwo=%3F2&%3Athree=%233" + )).to eq([["&one", "/1"], ["=two", "?2"], [":three", "#3"]]) + end + + it "should result in correct values" do + expect(Addressable::URI.form_unencode( + "q=one+two+three" + )).to eq([["q", "one two three"]]) + end + + it "should result in correct values" do + expect(Addressable::URI.form_unencode( + "text=one%0D%0Atwo%0D%0Athree%0D%0Afour%0D%0A%0D%0A" + )).to eq([["text", "one\ntwo\nthree\nfour\n\n"]]) + end + + it "should result in correct values" do + expect(Addressable::URI.form_unencode( + "a=1&dup=2&dup=3" + )).to eq([["a", "1"], ["dup", "2"], ["dup", "3"]]) + end + + it "should result in correct values" do + expect(Addressable::URI.form_unencode( + "key" + )).to eq([["key", nil]]) + end + + it "should result in correct values" do + expect(Addressable::URI.form_unencode("GivenName=Ren%C3%A9")).to eq( + [["GivenName", "René"]] + ) + end +end + +describe Addressable::URI, "when form unencoding a non-String object" do + it "should correctly parse anything with a 'to_str' method" do + Addressable::URI.form_unencode(SuperString.new(42)) + end + + it "should raise a TypeError for objects than cannot be converted" do + expect do + Addressable::URI.form_unencode(42) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when normalizing a non-String object" do + it "should correctly parse anything with a 'to_str' method" do + Addressable::URI.normalize_component(SuperString.new(42)) + end + + it "should raise a TypeError for objects than cannot be converted" do + expect do + Addressable::URI.normalize_component(42) + end.to raise_error(TypeError) + end + + it "should raise a TypeError for objects than cannot be converted" do + expect do + Addressable::URI.normalize_component("component", 42) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when normalizing a path with an encoded slash" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.parse("/path%2Fsegment/").normalize.path).to eq( + "/path%2Fsegment/" + ) + end +end + +describe Addressable::URI, "when normalizing a path with special unicode" do + it "does not stop at or ignore null bytes" do + expect(Addressable::URI.parse("/path%00segment/").normalize.path).to eq( + "/path%00segment/" + ) + end + + it "does apply NFC unicode normalization" do + expect(Addressable::URI.parse("/%E2%84%A6").normalize.path).to eq( + "/%CE%A9" + ) + end + + it "does not apply NFKC unicode normalization" do + expect(Addressable::URI.parse("/%C2%AF%C2%A0").normalize.path).to eq( + "/%C2%AF%C2%A0" + ) + end +end + +describe Addressable::URI, "when normalizing a partially encoded string" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.normalize_component( + "partially % encoded%21" + )).to eq("partially%20%25%20encoded!") + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.normalize_component( + "partially %25 encoded!" + )).to eq("partially%20%25%20encoded!") + end +end + +describe Addressable::URI, "when normalizing a unicode sequence" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.normalize_component( + "/C%CC%A7" + )).to eq("/%C3%87") + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.normalize_component( + "/%C3%87" + )).to eq("/%C3%87") + end +end + +describe Addressable::URI, "when normalizing a multibyte string" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.normalize_component("günther")).to eq( + "g%C3%BCnther" + ) + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.normalize_component("g%C3%BCnther")).to eq( + "g%C3%BCnther" + ) + end +end + +describe Addressable::URI, "when normalizing a string but leaving some characters encoded" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.normalize_component("%58X%59Y%5AZ", "0-9a-zXY", "Y")).to eq( + "XX%59Y%5A%5A" + ) + end + + it "should not modify the character class" do + character_class = "0-9a-zXY" + + character_class_copy = character_class.dup + + Addressable::URI.normalize_component("%58X%59Y%5AZ", character_class, "Y") + + expect(character_class).to eq(character_class_copy) + end +end + +describe Addressable::URI, "when encoding IP literals" do + it "should work for IPv4" do + input = "http://127.0.0.1/" + expect(Addressable::URI.encode(input)).to eq(input) + end + + it "should work for IPv6" do + input = "http://[fe80::200:f8ff:fe21:67cf]/" + expect(Addressable::URI.encode(input)).to eq(input) + end +end + +describe Addressable::URI, "when encoding a string with existing encodings to upcase" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.encode_component("JK%4c", "0-9A-IKM-Za-z%", "L")).to eq("%4AK%4C") + end +end + +describe Addressable::URI, "when encoding a multibyte string" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.encode_component("günther")).to eq("g%C3%BCnther") + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.encode_component( + "günther", /[^a-zA-Z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\-\.\_\~]/ + )).to eq("g%C3%BCnther") + end +end + +describe Addressable::URI, "when form encoding a multibyte string" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.form_encode({"GivenName" => "René"})).to eq( + "GivenName=Ren%C3%A9" + ) + end +end + +describe Addressable::URI, "when encoding a string with ASCII chars 0-15" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.encode_component("one\ntwo")).to eq("one%0Atwo") + end + + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.encode_component( + "one\ntwo", /[^a-zA-Z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\-\.\_\~]/ + )).to eq("one%0Atwo") + end +end + +describe Addressable::URI, "when unencoding a multibyte string" do + it "should result in correct percent encoded sequence" do + expect(Addressable::URI.unencode_component("g%C3%BCnther")).to eq("günther") + end + + it "should consistently use UTF-8 internally" do + expect(Addressable::URI.unencode_component("ski=%BA%DAɫ")).to eq("ski=\xBA\xDAɫ") + end + + it "should not fail with UTF-8 incompatible string" do + url = "/M%E9/\xE9?p=\xFC".b + expect(Addressable::URI.unencode_component(url)).to eq("/M\xE9/\xE9?p=\xFC") + end + + it "should result in correct percent encoded sequence as a URI" do + expect(Addressable::URI.unencode( + "/path?g%C3%BCnther", ::Addressable::URI + )).to eq(Addressable::URI.new( + :path => "/path", :query => "günther" + )) + end +end + +describe Addressable::URI, "when partially unencoding a string" do + it "should unencode all characters by default" do + expect(Addressable::URI.unencode('%%25~%7e+%2b', String)).to eq('%%~~++') + end + + it "should unencode characters not in leave_encoded" do + expect(Addressable::URI.unencode('%%25~%7e+%2b', String, '~')).to eq('%%~%7e++') + end + + it "should leave characters in leave_encoded alone" do + expect(Addressable::URI.unencode('%%25~%7e+%2b', String, '%~+')).to eq('%%25~%7e+%2b') + end +end + +describe Addressable::URI, "when unencoding a bogus object" do + it "should raise a TypeError" do + expect do + Addressable::URI.unencode_component(42) + end.to raise_error(TypeError) + end + + it "should raise a TypeError" do + expect do + Addressable::URI.unencode("/path?g%C3%BCnther", Integer) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when encoding a bogus object" do + it "should raise a TypeError" do + expect do + Addressable::URI.encode(Object.new) + end.to raise_error(TypeError) + end + + it "should raise a TypeError" do + expect do + Addressable::URI.normalized_encode(Object.new) + end.to raise_error(TypeError) + end + + it "should raise a TypeError" do + expect do + Addressable::URI.encode_component("günther", Object.new) + end.to raise_error(TypeError) + end + + it "should raise a TypeError" do + expect do + Addressable::URI.encode_component(Object.new) + end.to raise_error(TypeError) + end +end + +describe Addressable::URI, "when given the input " + + "'http://example.com/'" do + before do + @input = "http://example.com/" + end + + it "should heuristically parse to 'http://example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("http://example.com/") + end + + it "should not raise error when frozen" do + expect do + Addressable::URI.heuristic_parse(@input).freeze.to_s + end.not_to raise_error + end +end + +describe Addressable::URI, "when given the input " + + "'https://example.com/'" do + before do + @input = "https://example.com/" + end + + it "should heuristically parse to 'https://example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("https://example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "'http:example.com/'" do + before do + @input = "http:example.com/" + end + + it "should heuristically parse to 'http://example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("http://example.com/") + end + + it "should heuristically parse to 'http://example.com/' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("http://example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "'https:example.com/'" do + before do + @input = "https:example.com/" + end + + it "should heuristically parse to 'https://example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("https://example.com/") + end + + it "should heuristically parse to 'https://example.com/' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("https://example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "'http://example.com/example.com/'" do + before do + @input = "http://example.com/example.com/" + end + + it "should heuristically parse to 'http://example.com/example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("http://example.com/example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "'http://prefix\\.example.com/'" do + before do + @input = "http://prefix\\.example.com/" + end + + it "should heuristically parse to 'http://prefix/.example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.authority).to eq("prefix") + expect(@uri.to_s).to eq("http://prefix/.example.com/") + end + + it "should heuristically parse to 'http://prefix/.example.com/' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("http://prefix/.example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "'http://p:\\/'" do + before do + @input = "http://p:\\/" + end + + it "should heuristically parse to 'http://p//'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.authority).to eq("p") + expect(@uri.to_s).to eq("http://p//") + end + + it "should heuristically parse to 'http://p//' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("http://p//") + end +end + +describe Addressable::URI, "when given the input " + + "'http://p://'" do + before do + @input = "http://p://" + end + + it "should heuristically parse to 'http://p//'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.authority).to eq("p") + expect(@uri.to_s).to eq("http://p//") + end + + it "should heuristically parse to 'http://p//' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("http://p//") + end +end + +describe Addressable::URI, "when given the input " + + "'http://p://p'" do + before do + @input = "http://p://p" + end + + it "should heuristically parse to 'http://p//p'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.authority).to eq("p") + expect(@uri.to_s).to eq("http://p//p") + end + + it "should heuristically parse to 'http://p//p' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("http://p//p") + end +end + +describe Addressable::URI, "when given the input " + + "'http://prefix .example.com/'" do + before do + @input = "http://prefix .example.com/" + end + + # Justification here being that no browser actually tries to resolve this. + # They all treat this as a web search. + it "should heuristically parse to 'http://prefix%20.example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.authority).to eq("prefix%20.example.com") + expect(@uri.to_s).to eq("http://prefix%20.example.com/") + end + + it "should heuristically parse to 'http://prefix%20.example.com/' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("http://prefix%20.example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "' http://www.example.com/ '" do + before do + @input = " http://www.example.com/ " + end + + it "should heuristically parse to 'http://prefix%20.example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.scheme).to eq("http") + expect(@uri.path).to eq("/") + expect(@uri.to_s).to eq("http://www.example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "'http://prefix%2F.example.com/'" do + before do + @input = "http://prefix%2F.example.com/" + end + + it "should heuristically parse to 'http://prefix%2F.example.com/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.authority).to eq("prefix%2F.example.com") + expect(@uri.to_s).to eq("http://prefix%2F.example.com/") + end + + it "should heuristically parse to 'http://prefix%2F.example.com/' " + + "even with a scheme hint of 'ftp'" do + @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'}) + expect(@uri.to_s).to eq("http://prefix%2F.example.com/") + end +end + +describe Addressable::URI, "when given the input " + + "'/path/to/resource'" do + before do + @input = "/path/to/resource" + end + + it "should heuristically parse to '/path/to/resource'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("/path/to/resource") + end +end + +describe Addressable::URI, "when given the input " + + "'relative/path/to/resource'" do + before do + @input = "relative/path/to/resource" + end + + it "should heuristically parse to 'relative/path/to/resource'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("relative/path/to/resource") + end +end + +describe Addressable::URI, "when given the input " + + "'example.com'" do + before do + @input = "example.com" + end + + it "should heuristically parse to 'http://example.com'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("http://example.com") + end +end + +describe Addressable::URI, "when given the input " + + "'example.com' and a scheme hint of 'ftp'" do + before do + @input = "example.com" + @hints = {:scheme => 'ftp'} + end + + it "should heuristically parse to 'http://example.com'" do + @uri = Addressable::URI.heuristic_parse(@input, @hints) + expect(@uri.to_s).to eq("ftp://example.com") + end +end + +describe Addressable::URI, "when given the input " + + "'example.com:21' and a scheme hint of 'ftp'" do + before do + @input = "example.com:21" + @hints = {:scheme => 'ftp'} + end + + it "should heuristically parse to 'http://example.com:21'" do + @uri = Addressable::URI.heuristic_parse(@input, @hints) + expect(@uri.to_s).to eq("ftp://example.com:21") + end +end + +describe Addressable::URI, "when given the input " + + "'example.com/path/to/resource'" do + before do + @input = "example.com/path/to/resource" + end + + it "should heuristically parse to 'http://example.com/path/to/resource'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("http://example.com/path/to/resource") + end +end + +describe Addressable::URI, "when given the input " + + "'http:///example.com'" do + before do + @input = "http:///example.com" + end + + it "should heuristically parse to 'http://example.com'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("http://example.com") + end +end + +describe Addressable::URI, "when given the input which "\ + "start with digits and has specified port" do + before do + @input = "7777.example.org:8089" + end + + it "should heuristically parse to 'http://7777.example.org:8089'" do + uri = Addressable::URI.heuristic_parse(@input) + expect(uri.to_s).to eq("http://7777.example.org:8089") + end +end + +describe Addressable::URI, "when given the input " + + "'feed:///example.com'" do + before do + @input = "feed:///example.com" + end + + it "should heuristically parse to 'feed://example.com'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("feed://example.com") + end +end + +describe Addressable::URI, "when given the input " + + "'file://localhost/path/to/resource/'" do + before do + @input = "file://localhost/path/to/resource/" + end + + it "should heuristically parse to 'file:///path/to/resource/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("file:///path/to/resource/") + end +end + +describe Addressable::URI, "when given the input " + + "'file://path/to/resource/'" do + before do + @input = "file://path/to/resource/" + end + + it "should heuristically parse to 'file:///path/to/resource/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("file:///path/to/resource/") + end +end + +describe Addressable::URI, "when given the input " + + "'file://///path/to/resource/'" do + before do + @input = "file:///////path/to/resource/" + end + + it "should heuristically parse to 'file:////path/to/resource/'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("file:////path/to/resource/") + end +end + +describe Addressable::URI, "when given the input " + + "'feed://http://example.com'" do + before do + @input = "feed://http://example.com" + end + + it "should heuristically parse to 'feed:http://example.com'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("feed:http://example.com") + end +end + +describe Addressable::URI, "when given the input " + + "::URI.parse('http://example.com')" do + before do + @input = ::URI.parse('http://example.com') + end + + it "should heuristically parse to 'http://example.com'" do + @uri = Addressable::URI.heuristic_parse(@input) + expect(@uri.to_s).to eq("http://example.com") + end +end + +describe Addressable::URI, "when given the input: 'user@domain.com'" do + before do + @input = "user@domain.com" + end + + context "for heuristic parse" do + it "should remain 'mailto:user@domain.com'" do + uri = Addressable::URI.heuristic_parse("mailto:#{@input}") + expect(uri.to_s).to eq("mailto:user@domain.com") + end + + it "should have a scheme of 'mailto'" do + uri = Addressable::URI.heuristic_parse(@input) + expect(uri.to_s).to eq("mailto:user@domain.com") + expect(uri.scheme).to eq("mailto") + end + + it "should remain 'acct:user@domain.com'" do + uri = Addressable::URI.heuristic_parse("acct:#{@input}") + expect(uri.to_s).to eq("acct:user@domain.com") + end + + context "HTTP" do + before do + @uri = Addressable::URI.heuristic_parse("http://#{@input}/") + end + + it "should remain 'http://user@domain.com/'" do + expect(@uri.to_s).to eq("http://user@domain.com/") + end + + it "should have the username 'user' for HTTP basic authentication" do + expect(@uri.user).to eq("user") + end + end + end +end + +describe Addressable::URI, "when assigning query values" do + before do + @uri = Addressable::URI.new + end + + it "should correctly assign {:a => 'a', :b => ['c', 'd', 'e']}" do + @uri.query_values = {:a => "a", :b => ["c", "d", "e"]} + expect(@uri.query).to eq("a=a&b=c&b=d&b=e") + end + + it "should raise an error attempting to assign {'a' => {'b' => ['c']}}" do + expect do + @uri.query_values = { 'a' => {'b' => ['c'] } } + end.to raise_error(TypeError) + end + + it "should raise an error attempting to assign " + + "{:b => '2', :a => {:c => '1'}}" do + expect do + @uri.query_values = {:b => '2', :a => {:c => '1'}} + end.to raise_error(TypeError) + end + + it "should raise an error attempting to assign " + + "{:a => 'a', :b => [{:c => 'c', :d => 'd'}, " + + "{:e => 'e', :f => 'f'}]}" do + expect do + @uri.query_values = { + :a => "a", :b => [{:c => "c", :d => "d"}, {:e => "e", :f => "f"}] + } + end.to raise_error(TypeError) + end + + it "should raise an error attempting to assign " + + "{:a => 'a', :b => [{:c => true, :d => 'd'}, " + + "{:e => 'e', :f => 'f'}]}" do + expect do + @uri.query_values = { + :a => 'a', :b => [{:c => true, :d => 'd'}, {:e => 'e', :f => 'f'}] + } + end.to raise_error(TypeError) + end + + it "should raise an error attempting to assign " + + "{:a => 'a', :b => {:c => true, :d => 'd'}}" do + expect do + @uri.query_values = { + :a => 'a', :b => {:c => true, :d => 'd'} + } + end.to raise_error(TypeError) + end + + it "should raise an error attempting to assign " + + "{:a => 'a', :b => {:c => true, :d => 'd'}}" do + expect do + @uri.query_values = { + :a => 'a', :b => {:c => true, :d => 'd'} + } + end.to raise_error(TypeError) + end + + it "should correctly assign {:a => 1, :b => 1.5}" do + @uri.query_values = { :a => 1, :b => 1.5 } + expect(@uri.query).to eq("a=1&b=1.5") + end + + it "should raise an error attempting to assign " + + "{:z => 1, :f => [2, {999.1 => [3,'4']}, ['h', 'i']], " + + ":a => {:b => ['c', 'd'], :e => true, :y => 0.5}}" do + expect do + @uri.query_values = { + :z => 1, + :f => [ 2, {999.1 => [3,'4']}, ['h', 'i'] ], + :a => { :b => ['c', 'd'], :e => true, :y => 0.5 } + } + end.to raise_error(TypeError) + end + + it "should correctly assign {}" do + @uri.query_values = {} + expect(@uri.query).to eq('') + end + + it "should correctly assign nil" do + @uri.query_values = nil + expect(@uri.query).to eq(nil) + end + + it "should correctly sort {'ab' => 'c', :ab => 'a', :a => 'x'}" do + @uri.query_values = {'ab' => 'c', :ab => 'a', :a => 'x'} + expect(@uri.query).to eq("a=x&ab=a&ab=c") + end + + it "should correctly assign " + + "[['b', 'c'], ['b', 'a'], ['a', 'a']]" do + # Order can be guaranteed in this format, so preserve it. + @uri.query_values = [['b', 'c'], ['b', 'a'], ['a', 'a']] + expect(@uri.query).to eq("b=c&b=a&a=a") + end + + it "should preserve query string order" do + query_string = (('a'..'z').to_a.reverse.map { |e| "#{e}=#{e}" }).join("&") + @uri.query = query_string + original_uri = @uri.to_s + @uri.query_values = @uri.query_values(Array) + expect(@uri.to_s).to eq(original_uri) + end + + describe 'when a hash with mixed types is assigned to query_values' do + it 'should not raise an error' do + skip 'Issue #94' + expect { subject.query_values = { "page" => "1", :page => 2 } }.to_not raise_error + end + end +end + +describe Addressable::URI, "when assigning path values" do + before do + @uri = Addressable::URI.new + end + + it "should correctly assign paths containing colons" do + @uri.path = "acct:bob@sporkmonger.com" + expect(@uri.path).to eq("acct:bob@sporkmonger.com") + expect(@uri.normalize.to_str).to eq("acct%2Fbob@sporkmonger.com") + expect { @uri.to_s }.to raise_error( + Addressable::URI::InvalidURIError + ) + end + + it "should correctly assign paths containing colons" do + @uri.path = "/acct:bob@sporkmonger.com" + @uri.authority = "example.com" + expect(@uri.normalize.to_str).to eq("//example.com/acct:bob@sporkmonger.com") + end + + it "should correctly assign paths containing colons" do + @uri.path = "acct:bob@sporkmonger.com" + @uri.scheme = "something" + expect(@uri.normalize.to_str).to eq("something:acct:bob@sporkmonger.com") + end + + it "should not allow relative paths to be assigned on absolute URIs" do + expect do + @uri.scheme = "http" + @uri.host = "example.com" + @uri.path = "acct:bob@sporkmonger.com" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should not allow relative paths to be assigned on absolute URIs" do + expect do + @uri.path = "acct:bob@sporkmonger.com" + @uri.scheme = "http" + @uri.host = "example.com" + end.to raise_error(Addressable::URI::InvalidURIError) + end + + it "should not allow relative paths to be assigned on absolute URIs" do + expect do + @uri.path = "uuid:0b3ecf60-3f93-11df-a9c3-001f5bfffe12" + @uri.scheme = "urn" + end.not_to raise_error + end +end + +describe Addressable::URI, "when initializing a subclass of Addressable::URI" do + before do + @uri = Class.new(Addressable::URI).new + end + + it "should have the same class after being parsed" do + expect(@uri.class).to eq(Addressable::URI.parse(@uri).class) + end + + it "should have the same class as its duplicate" do + expect(@uri.class).to eq(@uri.dup.class) + end + + it "should have the same class after being normalized" do + expect(@uri.class).to eq(@uri.normalize.class) + end + + it "should have the same class after being merged" do + expect(@uri.class).to eq(@uri.merge(:path => 'path').class) + end + + it "should have the same class after being joined" do + expect(@uri.class).to eq(@uri.join('path').class) + end +end + +describe Addressable::URI, "support serialization roundtrip" do + before do + @uri = Addressable::URI.new( + :scheme => "http", + :user => "user", + :password => "password", + :host => "example.com", + :port => 80, + :path => "/path", + :query => "query=value", + :fragment => "fragment" + ) + end + + it "is in a working state after being serialized with Marshal" do + @uri = Addressable::URI.parse("http://example.com") + cloned_uri = Marshal.load(Marshal.dump(@uri)) + expect(cloned_uri.normalized_scheme).to be == @uri.normalized_scheme + end + + it "is in a working state after being serialized with YAML" do + @uri = Addressable::URI.parse("http://example.com") + cloned_uri = if YAML.respond_to?(:unsafe_load) + YAML.unsafe_load(YAML.dump(@uri)) + else + YAML.load(YAML.dump(@uri)) + end + expect(cloned_uri.normalized_scheme).to be == @uri.normalized_scheme + end +end + +describe Addressable::URI, "when initialized in a non-main `Ractor`" do + it "should have the same value as if used in the main `Ractor`" do + pending("Ruby 3.0+ for `Ractor` support") unless defined?(Ractor) + main = Addressable::URI.parse("http://example.com") + expect( + Ractor.new { Addressable::URI.parse("http://example.com") }.take + ).to eq(main) + end +end + +describe Addressable::URI, "when deferring validation" do + subject(:deferred) { uri.instance_variable_get(:@validation_deferred) } + + let(:uri) { Addressable::URI.parse("http://example.com") } + + it "defers validation within the block" do + uri.defer_validation do + expect(deferred).to be true + end + end + + it "always resets deferral afterward" do + expect { uri.defer_validation { raise "boom" } }.to raise_error("boom") + expect(deferred).to be false + end + + it "returns nil" do + res = uri.defer_validation {} + expect(res).to be nil + end +end + +describe Addressable::URI, "YAML safe loading" do + it "doesn't serialize anonymous objects" do + url = Addressable::URI.parse("http://example.com/") + expect(YAML.dump(url)).to_not include("!ruby/object {}") + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/spec_helper.rb b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/spec_helper.rb new file mode 100644 index 0000000..bd8e395 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/spec/spec_helper.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'bundler/setup' +require 'rspec/its' + +begin + require 'coveralls' + Coveralls.wear! do + add_filter "spec/" + add_filter "vendor/" + end +rescue LoadError + warn "warning: coveralls gem not found; skipping Coveralls" + require 'simplecov' + SimpleCov.start do + add_filter "spec/" + add_filter "vendor/" + end +end if Gem.loaded_specs.key?("simplecov") + +class TestHelper + def self.native_supported? + mri = RUBY_ENGINE == "ruby" + windows = RUBY_PLATFORM.include?("mingw") + + mri && !windows + end +end + +RSpec.configure do |config| + config.warnings = true + config.filter_run_when_matching :focus +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/clobber.rake b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/clobber.rake new file mode 100644 index 0000000..a9e32b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/clobber.rake @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +desc "Remove all build products" +task "clobber" diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/gem.rake b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/gem.rake new file mode 100644 index 0000000..70b1f97 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/gem.rake @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +require "rubygems/package_task" + +namespace :gem do + GEM_SPEC = Gem::Specification.new do |s| + s.name = PKG_NAME + s.version = PKG_VERSION + s.summary = PKG_SUMMARY + s.description = PKG_DESCRIPTION + + s.files = PKG_FILES.to_a + + s.extra_rdoc_files = %w( README.md ) + s.rdoc_options.concat ["--main", "README.md"] + + if !s.respond_to?(:add_development_dependency) + puts "Cannot build Gem with this version of RubyGems." + exit(1) + end + + s.required_ruby_version = ">= 2.2" + + s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 7.0" + s.add_development_dependency "bundler", ">= 1.0", "< 3.0" + + s.require_path = "lib" + + s.author = "Bob Aman" + s.email = "bob@sporkmonger.com" + s.homepage = "https://github.com/sporkmonger/addressable" + s.license = "Apache-2.0" + s.metadata = { + "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md#v#{PKG_VERSION}" + } + end + + Gem::PackageTask.new(GEM_SPEC) do |p| + p.gem_spec = GEM_SPEC + p.need_tar = true + p.need_zip = true + end + + desc "Generates .gemspec file" + task :gemspec do + spec_string = GEM_SPEC.to_ruby + File.open("#{GEM_SPEC.name}.gemspec", "w") do |file| + file.write spec_string + end + end + + desc "Show information about the gem" + task :debug do + puts GEM_SPEC.to_ruby + end + + desc "Install the gem" + task :install => ["clobber", "gem:package"] do + sh "gem install --local ./pkg/#{GEM_SPEC.full_name}.gem" + end + + desc "Uninstall the gem" + task :uninstall do + installed_list = Gem.source_index.find_name(PKG_NAME) + if installed_list && + (installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION)) + sh( + "gem uninstall --version '#{PKG_VERSION}' " + + "--ignore-dependencies --executables #{PKG_NAME}" + ) + end + end + + desc "Reinstall the gem" + task :reinstall => [:uninstall, :install] + + desc "Package for release" + task :release => ["gem:package", "gem:gemspec"] do |t| + v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z" + abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION + pkg = "pkg/#{GEM_SPEC.full_name}" + + changelog = File.open("CHANGELOG.md") { |file| file.read } + + puts "Releasing #{PKG_NAME} v. #{PKG_VERSION}" + Rake::Task["git:tag:create"].invoke + end +end + +desc "Alias to gem:package" +task "gem" => "gem:package" + +task "gem:release" => "gem:gemspec" + +task "clobber" => ["gem:clobber_package"] diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/git.rake b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/git.rake new file mode 100644 index 0000000..1238c8d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/git.rake @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +namespace :git do + namespace :tag do + desc "List tags from the Git repository" + task :list do + tags = `git tag -l` + tags.gsub!("\r", "") + tags = tags.split("\n").sort {|a, b| b <=> a } + puts tags.join("\n") + end + + desc "Create a new tag in the Git repository" + task :create do + changelog = File.open("CHANGELOG.md", "r") { |file| file.read } + puts "-" * 80 + puts changelog + puts "-" * 80 + puts + + v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z" + abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION + + git_status = `git status` + if git_status !~ /^nothing to commit/ + abort "Working directory isn't clean." + end + + tag = "#{PKG_NAME}-#{PKG_VERSION}" + msg = "Release #{PKG_NAME}-#{PKG_VERSION}" + + existing_tags = `git tag -l #{PKG_NAME}-*`.split('\n') + if existing_tags.include?(tag) + warn("Tag already exists, deleting...") + unless system "git tag -d #{tag}" + abort "Tag deletion failed." + end + end + puts "Creating git tag '#{tag}'..." + unless system "git tag -a -m \"#{msg}\" #{tag}" + abort "Tag creation failed." + end + end + end +end + +task "gem:release" => "git:tag:create" diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/metrics.rake b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/metrics.rake new file mode 100644 index 0000000..107cc24 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/metrics.rake @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +namespace :metrics do + task :lines do + lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 + for file_name in FileList["lib/**/*.rb"] + f = File.open(file_name) + while line = f.gets + lines += 1 + next if line =~ /^\s*$/ + next if line =~ /^\s*#/ + codelines += 1 + end + puts "L: #{sprintf("%4d", lines)}, " + + "LOC #{sprintf("%4d", codelines)} | #{file_name}" + total_lines += lines + total_codelines += codelines + + lines, codelines = 0, 0 + end + + puts "Total: Lines #{total_lines}, LOC #{total_codelines}" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/profile.rake b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/profile.rake new file mode 100644 index 0000000..b697d48 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/profile.rake @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +namespace :profile do + desc "Profile Template match memory allocations" + task :template_match_memory do + require "memory_profiler" + require "addressable/template" + + start_at = Time.now.to_f + template = Addressable::Template.new("http://example.com/{?one,two,three}") + report = MemoryProfiler.report do + 30_000.times do + template.match( + "http://example.com/?one=one&two=floo&three=me" + ) + end + end + end_at = Time.now.to_f + print_options = { scale_bytes: true, normalize_paths: true } + puts "\n\n" + + if ENV["CI"] + report.pretty_print(print_options) + else + t_allocated = report.scale_bytes(report.total_allocated_memsize) + t_retained = report.scale_bytes(report.total_retained_memsize) + + puts "Total allocated: #{t_allocated} (#{report.total_allocated} objects)" + puts "Total retained: #{t_retained} (#{report.total_retained} objects)" + puts "Took #{end_at - start_at} seconds" + + FileUtils.mkdir_p("tmp") + report.pretty_print(to_file: "tmp/memprof.txt", **print_options) + end + end + + desc "Profile URI parse memory allocations" + task :memory do + require "memory_profiler" + require "addressable/uri" + if ENV["IDNA_MODE"] == "pure" + Addressable.send(:remove_const, :IDNA) + load "addressable/idna/pure.rb" + end + + start_at = Time.now.to_f + report = MemoryProfiler.report do + 30_000.times do + Addressable::URI.parse( + "http://google.com/stuff/../?with_lots=of¶ms=asdff#!stuff" + ).normalize + end + end + end_at = Time.now.to_f + print_options = { scale_bytes: true, normalize_paths: true } + puts "\n\n" + + if ENV["CI"] + report.pretty_print(**print_options) + else + t_allocated = report.scale_bytes(report.total_allocated_memsize) + t_retained = report.scale_bytes(report.total_retained_memsize) + + puts "Total allocated: #{t_allocated} (#{report.total_allocated} objects)" + puts "Total retained: #{t_retained} (#{report.total_retained} objects)" + puts "Took #{end_at - start_at} seconds" + + FileUtils.mkdir_p("tmp") + report.pretty_print(to_file: "tmp/memprof.txt", **print_options) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/rspec.rake b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/rspec.rake new file mode 100644 index 0000000..e3d9f01 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/rspec.rake @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "rspec/core/rake_task" + +namespace :spec do + RSpec::Core::RakeTask.new(:simplecov) do |t| + t.pattern = FileList['spec/**/*_spec.rb'] + t.rspec_opts = %w[--color --format documentation] unless ENV["CI"] + end + + namespace :simplecov do + desc "Browse the code coverage report." + task :browse => "spec:simplecov" do + require "launchy" + Launchy.open("coverage/index.html") + end + end +end + +desc "Alias to spec:simplecov" +task "spec" => "spec:simplecov" + +task "clobber" => ["spec:clobber_simplecov"] diff --git a/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/yard.rake b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/yard.rake new file mode 100644 index 0000000..515f960 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.7/tasks/yard.rake @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require "rake" + +begin + require "yard" + require "yard/rake/yardoc_task" + + namespace :doc do + desc "Generate Yardoc documentation" + YARD::Rake::YardocTask.new do |yardoc| + yardoc.name = "yard" + yardoc.options = ["--verbose", "--markup", "markdown"] + yardoc.files = FileList[ + "lib/**/*.rb", "ext/**/*.c", + "README.md", "CHANGELOG.md", "LICENSE.txt" + ].exclude(/idna/) + end + end + + task "clobber" => ["doc:clobber_yard"] + + desc "Alias to doc:yard" + task "doc" => "doc:yard" +rescue LoadError + # If yard isn't available, it's not the end of the world + desc "Alias to doc:rdoc" + task "doc" => "doc:rdoc" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/LICENSE b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/LICENSE new file mode 100644 index 0000000..a1f19ff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/LICENSE @@ -0,0 +1,56 @@ +Ruby is copyrighted free software by Yukihiro Matsumoto . +You can redistribute it and/or modify it under either the terms of the +2-clause BSDL (see the file BSDL), or the conditions below: + + 1. You may make and give away verbatim copies of the source form of the + software without restriction, provided that you duplicate all of the + original copyright notices and associated disclaimers. + + 2. You may modify your copy of the software in any way, provided that + you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said + modifications to Usenet or an equivalent medium, or by allowing + the author to include your modifications in the software. + + b) use the modified software only within your corporation or + organization. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 3. You may distribute the software in object code or binary form, + provided that you do at least ONE of the following: + + a) distribute the binaries and library files of the software, + together with instructions (in the manual page or equivalent) + on where to get the original distribution. + + b) accompany the distribution with the machine-readable source of + the software. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 4. You may modify and include the part of the software into any other + software (possibly commercial). But some files in the distribution + are not written by the author, so that they are not under these terms. + + For the list of those files and their copying conditions, see the + file LEGAL. + + 5. The scripts and library files supplied as input to or produced as + output from the software do not automatically fall under the + copyright of the software, but belong to whomever generated them, + and may be sold commercially, and may be aggregated with this + software. + + 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/bigdecimal.gemspec b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/bigdecimal.gemspec new file mode 100644 index 0000000..b6ef8fd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/bigdecimal.gemspec @@ -0,0 +1,57 @@ +# coding: utf-8 + +name = File.basename(__FILE__, '.*') +source_version = ["", "ext/#{name}/"].find do |dir| + begin + break File.foreach(File.join(__dir__, "#{dir}#{name}.c")) {|line| + break $1.sub("-", ".") if /^#define\s+#{name.upcase}_VERSION\s+"(.+)"/o =~ line + } + rescue Errno::ENOENT + end +end or raise "can't find #{name.upcase}_VERSION" + +Gem::Specification.new do |s| + s.name = name + s.version = source_version + s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"] + s.email = ["mrkn@mrkn.jp"] + + s.summary = "Arbitrary-precision decimal floating-point number library." + s.description = "This library provides arbitrary-precision decimal floating-point number class." + s.homepage = "https://github.com/ruby/bigdecimal" + s.licenses = ["Ruby", "BSD-2-Clause"] + + s.require_paths = %w[lib] + s.files = %w[ + LICENSE + bigdecimal.gemspec + lib/bigdecimal.rb + lib/bigdecimal/jacobian.rb + lib/bigdecimal/ludcmp.rb + lib/bigdecimal/math.rb + lib/bigdecimal/newton.rb + lib/bigdecimal/util.rb + sample/linear.rb + sample/nlsolve.rb + sample/pi.rb + ] + if Gem::Platform === s.platform and s.platform =~ 'java' or RUBY_ENGINE == 'jruby' + s.platform = 'java' + else + s.extensions = %w[ext/bigdecimal/extconf.rb] + s.files += %w[ + ext/bigdecimal/bigdecimal.c + ext/bigdecimal/bigdecimal.h + ext/bigdecimal/bits.h + ext/bigdecimal/feature.h + ext/bigdecimal/missing.c + ext/bigdecimal/missing.h + ext/bigdecimal/missing/dtoa.c + ext/bigdecimal/static_assert.h + ] + end + + s.required_ruby_version = Gem::Requirement.new(">= 2.5.0") + + s.metadata["changelog_uri"] = s.homepage + "/blob/master/CHANGES.md" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/Makefile b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/Makefile new file mode 100644 index 0000000..1890a6b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/Makefile @@ -0,0 +1,270 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +V0 = $(V:0=) +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@ :) +ECHO = $(ECHO1:0=@ echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /usr/include/ruby-3.2.0 +hdrdir = $(topdir) +arch_hdrdir = /usr/include/ruby-3.2.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/usr +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(DESTDIR)/usr +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(sitelibdir)/$(sitearch) +sitelibdir = $(sitedir)/$(ruby_version) +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(DESTDIR)/usr/share/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib/x86_64-linux-gnu +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(DESTDIR)/usr/share/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(exec_prefix)/include +runstatedir = $(localstatedir)/run +localstatedir = $(DESTDIR)/var +sharedstatedir = $(DESTDIR)/usr/com +sysconfdir = $(DESTDIR)/etc +datadir = $(DESTDIR)/usr/share +datarootdir = $(prefix)/share +libexecdir = $(DESTDIR)/usr/libexec +sbindir = $(DESTDIR)/usr/bin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC_WRAPPER = +CC = x86_64-unknown-linux-gnu-gcc +CXX = x86_64-unknown-linux-gnu-g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static $(MAINLIBS) +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) +CSRCFLAG = $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = +optflags = -O3 -fno-fast-math +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef +cppflags = +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -DHAVE_BUILTIN___BUILTIN_CLZ -DHAVE_BUILTIN___BUILTIN_CLZL -DHAVE_BUILTIN___BUILTIN_CLZLL -DHAVE_FLOAT_H -DHAVE_MATH_H -DHAVE_STDBOOL_H -DHAVE_STDLIB_H -DHAVE_X86INTRIN_H -DHAVE_LABS -DHAVE_LLABS -DHAVE_FINITE -DHAVE_RUBY_ATOMIC_H -DHAVE_RUBY_INTERNAL_HAS_BUILTIN_H -DHAVE_RUBY_INTERNAL_STATIC_ASSERT_H -DHAVE_RB_RATIONAL_NUM -DHAVE_RB_RATIONAL_DEN -DHAVE_RB_COMPLEX_REAL -DHAVE_RB_COMPLEX_IMAG -DHAVE_RB_OPTS_EXCEPTION_P -DHAVE_RB_CATEGORY_WARN -DHAVE_CONST_RB_WARN_CATEGORY_DEPRECATED $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer $(ARCH_FLAG) +ldflags = -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed +dldflags = -Wl,-z,relro,-z,now -Wl,--as-needed +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CC) -shared +LDSHAREDXX = $(CXX) -shared +AR = x86_64-unknown-linux-gnu-gcc-ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 3.2.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = rm -fr +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lm -lpthread -lc +ORIG_SRCS = bigdecimal.c missing.c +SRCS = $(ORIG_SRCS) +OBJS = bigdecimal.o missing.o +HDRS = $(srcdir)/bigdecimal.h $(srcdir)/bits.h $(srcdir)/feature.h $(srcdir)/missing.h $(srcdir)/static_assert.h +LOCAL_HDRS = +TARGET = bigdecimal +TARGET_NAME = bigdecimal +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = $(TARGET).so +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(sitehdrdir)$(target_prefix) +ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix) +TARGET_SO_DIR = +TARGET_SO = $(TARGET_SO_DIR)$(DLLIB) +CLEANLIBS = $(TARGET_SO) false +CLEANOBJS = $(OBJS) *.bak +TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time +BIGDECIMAL_RB = $(srcdir)/../../lib/bigdecimal.rb + +all: $(DLLIB) +static: $(STATIC_LIB) +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP) + $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) +clean-static:: + -$(Q)$(RM) $(STATIC_LIB) +install-rb: pre-install-rb do-install-rb install-rb-default +install-rb-default: pre-install-rb-default do-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +do-install-rb: +do-install-rb-default: +pre-install-rb-default: + @$(NULLCMD) +$(TARGET_SO_DIR_TIMESTAMP): + $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) + $(Q) $(TOUCH) $@ + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + +.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S + +.cc.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cc.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.mm.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.mm.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cxx.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cxx.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cpp.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cpp.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.c.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.c.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.m.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.m.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +$(TARGET_SO): $(OBJS) Makefile + $(ECHO) linking shared-object $(DLLIB) + -$(Q)$(RM) $(@) + $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) + + + +$(OBJS): $(HDRS) $(ruby_headers) diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bigdecimal.c b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bigdecimal.c new file mode 100644 index 0000000..aa2bf21 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bigdecimal.c @@ -0,0 +1,7794 @@ +/* + * + * Ruby BigDecimal(Variable decimal precision) extension library. + * + * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp) + * + */ + +/* #define BIGDECIMAL_DEBUG 1 */ + +#include "bigdecimal.h" +#include "ruby/util.h" + +#ifndef BIGDECIMAL_DEBUG +# undef NDEBUG +# define NDEBUG +#endif +#include + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_IEEEFP_H +#include +#endif + +#include "bits.h" +#include "static_assert.h" + +#define BIGDECIMAL_VERSION "3.1.8" + +/* #define ENABLE_NUMERIC_STRING */ + +#define SIGNED_VALUE_MAX INTPTR_MAX +#define SIGNED_VALUE_MIN INTPTR_MIN +#define MUL_OVERFLOW_SIGNED_VALUE_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, SIGNED_VALUE_MIN, SIGNED_VALUE_MAX) + +VALUE rb_cBigDecimal; +VALUE rb_mBigMath; + +static ID id_BigDecimal_exception_mode; +static ID id_BigDecimal_rounding_mode; +static ID id_BigDecimal_precision_limit; + +static ID id_up; +static ID id_down; +static ID id_truncate; +static ID id_half_up; +static ID id_default; +static ID id_half_down; +static ID id_half_even; +static ID id_banker; +static ID id_ceiling; +static ID id_ceil; +static ID id_floor; +static ID id_to_r; +static ID id_eq; +static ID id_half; + +#define RBD_NUM_ROUNDING_MODES 11 + +static struct { + ID id; + uint8_t mode; +} rbd_rounding_modes[RBD_NUM_ROUNDING_MODES]; + +/* MACRO's to guard objects from GC by keeping them in stack */ +#ifdef RBIMPL_ATTR_MAYBE_UNUSED +#define ENTER(n) RBIMPL_ATTR_MAYBE_UNUSED() volatile VALUE vStack[n];int iStack=0 +#else +#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0 +#endif +#define PUSH(x) (vStack[iStack++] = (VALUE)(x)) +#define SAVE(p) PUSH((p)->obj) +#define GUARD_OBJ(p,y) ((p)=(y), SAVE(p)) + +#define BASE_FIG BIGDECIMAL_COMPONENT_FIGURES +#define BASE BIGDECIMAL_BASE + +#define HALF_BASE (BASE/2) +#define BASE1 (BASE/10) + +#define LOG10_2 0.3010299956639812 + +#ifndef RRATIONAL_ZERO_P +# define RRATIONAL_ZERO_P(x) (FIXNUM_P(rb_rational_num(x)) && \ + FIX2LONG(rb_rational_num(x)) == 0) +#endif + +#ifndef RRATIONAL_NEGATIVE_P +# define RRATIONAL_NEGATIVE_P(x) RTEST(rb_funcall((x), '<', 1, INT2FIX(0))) +#endif + +#ifndef DECIMAL_SIZE_OF_BITS +#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999) +/* an approximation of ceil(n * log10(2)), upto 65536 at least */ +#endif + +#ifdef PRIsVALUE +# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj) +# define RB_OBJ_STRING(obj) (obj) +#else +# define PRIsVALUE "s" +# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj) +# define RB_OBJ_STRING(obj) StringValueCStr(obj) +#endif + +#ifndef MAYBE_UNUSED +# define MAYBE_UNUSED(x) x +#endif + +#define BIGDECIMAL_POSITIVE_P(bd) ((bd)->sign > 0) +#define BIGDECIMAL_NEGATIVE_P(bd) ((bd)->sign < 0) + +/* + * ================== Memory allocation ============================ + */ + +#ifdef BIGDECIMAL_DEBUG +static size_t rbd_allocation_count = 0; /* Memory allocation counter */ +static inline void +atomic_allocation_count_inc(void) +{ + RUBY_ATOMIC_SIZE_INC(rbd_allocation_count); +} +static inline void +atomic_allocation_count_dec_nounderflow(void) +{ + if (rbd_allocation_count == 0) return; + RUBY_ATOMIC_SIZE_DEC(rbd_allocation_count); +} +static void +check_allocation_count_nonzero(void) +{ + if (rbd_allocation_count != 0) return; + rb_bug("[bigdecimal][rbd_free_struct] Too many memory free calls"); +} +#else +# define atomic_allocation_count_inc() /* nothing */ +# define atomic_allocation_count_dec_nounderflow() /* nothing */ +# define check_allocation_count_nonzero() /* nothing */ +#endif /* BIGDECIMAL_DEBUG */ + +PUREFUNC(static inline size_t rbd_struct_size(size_t const)); + +static inline size_t +rbd_struct_size(size_t const internal_digits) +{ + size_t const frac_len = (internal_digits == 0) ? 1 : internal_digits; + return offsetof(Real, frac) + frac_len * sizeof(DECDIG); +} + +static inline Real * +rbd_allocate_struct(size_t const internal_digits) +{ + size_t const size = rbd_struct_size(internal_digits); + Real *real = ruby_xcalloc(1, size); + atomic_allocation_count_inc(); + real->MaxPrec = internal_digits; + return real; +} + +static size_t +rbd_calculate_internal_digits(size_t const digits, bool limit_precision) +{ + size_t const len = roomof(digits, BASE_FIG); + if (limit_precision) { + size_t const prec_limit = VpGetPrecLimit(); + if (prec_limit > 0) { + /* NOTE: 2 more digits for rounding and division */ + size_t const max_len = roomof(prec_limit, BASE_FIG) + 2; + if (len > max_len) + return max_len; + } + } + + return len; +} + +static inline Real * +rbd_allocate_struct_decimal_digits(size_t const decimal_digits, bool limit_precision) +{ + size_t const internal_digits = rbd_calculate_internal_digits(decimal_digits, limit_precision); + return rbd_allocate_struct(internal_digits); +} + +static VALUE BigDecimal_wrap_struct(VALUE obj, Real *vp); + +static Real * +rbd_reallocate_struct(Real *real, size_t const internal_digits) +{ + size_t const size = rbd_struct_size(internal_digits); + VALUE obj = real ? real->obj : 0; + Real *new_real = (Real *)ruby_xrealloc(real, size); + new_real->MaxPrec = internal_digits; + if (obj) { + new_real->obj = 0; + BigDecimal_wrap_struct(obj, new_real); + } + return new_real; +} + +static void +rbd_free_struct(Real *real) +{ + if (real != NULL) { + check_allocation_count_nonzero(); + ruby_xfree(real); + atomic_allocation_count_dec_nounderflow(); + } +} + +#define NewZero rbd_allocate_struct_zero +static Real * +rbd_allocate_struct_zero(int sign, size_t const digits, bool limit_precision) +{ + Real *real = rbd_allocate_struct_decimal_digits(digits, limit_precision); + VpSetZero(real, sign); + return real; +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_limited(int sign, size_t const digits)); +#define NewZeroLimited rbd_allocate_struct_zero_limited +static inline Real * +rbd_allocate_struct_zero_limited(int sign, size_t const digits) +{ + return rbd_allocate_struct_zero(sign, digits, true); +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_nolimit(int sign, size_t const digits)); +#define NewZeroNolimit rbd_allocate_struct_zero_nolimit +static inline Real * +rbd_allocate_struct_zero_nolimit(int sign, size_t const digits) +{ + return rbd_allocate_struct_zero(sign, digits, false); +} + +#define NewOne rbd_allocate_struct_one +static Real * +rbd_allocate_struct_one(int sign, size_t const digits, bool limit_precision) +{ + Real *real = rbd_allocate_struct_decimal_digits(digits, limit_precision); + VpSetOne(real); + if (sign < 0) + VpSetSign(real, VP_SIGN_NEGATIVE_FINITE); + return real; +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_limited(int sign, size_t const digits)); +#define NewOneLimited rbd_allocate_struct_one_limited +static inline Real * +rbd_allocate_struct_one_limited(int sign, size_t const digits) +{ + return rbd_allocate_struct_one(sign, digits, true); +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_nolimit(int sign, size_t const digits)); +#define NewOneNolimit rbd_allocate_struct_one_nolimit +static inline Real * +rbd_allocate_struct_one_nolimit(int sign, size_t const digits) +{ + return rbd_allocate_struct_one(sign, digits, false); +} + +/* + * ================== Ruby Interface part ========================== + */ +#define DoSomeOne(x,y,f) rb_num_coerce_bin(x,y,f) + +/* + * VP routines used in BigDecimal part + */ +static unsigned short VpGetException(void); +static void VpSetException(unsigned short f); +static void VpCheckException(Real *p, bool always); +static VALUE VpCheckGetValue(Real *p); +static void VpInternalRound(Real *c, size_t ixDigit, DECDIG vPrev, DECDIG v); +static int VpLimitRound(Real *c, size_t ixDigit); +static Real *VpCopy(Real *pv, Real const* const x); +static int VPrint(FILE *fp,const char *cntl_chr,Real *a); + +/* + * **** BigDecimal part **** + */ + +static VALUE BigDecimal_nan(void); +static VALUE BigDecimal_positive_infinity(void); +static VALUE BigDecimal_negative_infinity(void); +static VALUE BigDecimal_positive_zero(void); +static VALUE BigDecimal_negative_zero(void); + +static void +BigDecimal_delete(void *pv) +{ + rbd_free_struct(pv); +} + +static size_t +BigDecimal_memsize(const void *ptr) +{ + const Real *pv = ptr; + return (sizeof(*pv) + pv->MaxPrec * sizeof(DECDIG)); +} + +#ifndef HAVE_RB_EXT_RACTOR_SAFE +# undef RUBY_TYPED_FROZEN_SHAREABLE +# define RUBY_TYPED_FROZEN_SHAREABLE 0 +#endif + +static const rb_data_type_t BigDecimal_data_type = { + "BigDecimal", + { 0, BigDecimal_delete, BigDecimal_memsize, }, +#ifdef RUBY_TYPED_FREE_IMMEDIATELY + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED +#endif +}; + +static Real * +rbd_allocate_struct_zero_wrap_klass(VALUE klass, int sign, size_t const digits, bool limit_precision) +{ + Real *real = rbd_allocate_struct_zero(sign, digits, limit_precision); + if (real != NULL) { + VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0); + BigDecimal_wrap_struct(obj, real); + } + return real; +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_limited_wrap(int sign, size_t const digits)); +#define NewZeroWrapLimited rbd_allocate_struct_zero_limited_wrap +static inline Real * +rbd_allocate_struct_zero_limited_wrap(int sign, size_t const digits) +{ + return rbd_allocate_struct_zero_wrap_klass(rb_cBigDecimal, sign, digits, true); +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_nolimit_wrap(int sign, size_t const digits)); +#define NewZeroWrapNolimit rbd_allocate_struct_zero_nolimit_wrap +static inline Real * +rbd_allocate_struct_zero_nolimit_wrap(int sign, size_t const digits) +{ + return rbd_allocate_struct_zero_wrap_klass(rb_cBigDecimal, sign, digits, false); +} + +static Real * +rbd_allocate_struct_one_wrap_klass(VALUE klass, int sign, size_t const digits, bool limit_precision) +{ + Real *real = rbd_allocate_struct_one(sign, digits, limit_precision); + if (real != NULL) { + VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0); + BigDecimal_wrap_struct(obj, real); + } + return real; +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_limited_wrap(int sign, size_t const digits)); +#define NewOneWrapLimited rbd_allocate_struct_one_limited_wrap +static inline Real * +rbd_allocate_struct_one_limited_wrap(int sign, size_t const digits) +{ + return rbd_allocate_struct_one_wrap_klass(rb_cBigDecimal, sign, digits, true); +} + +MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_nolimit_wrap(int sign, size_t const digits)); +#define NewOneWrapNolimit rbd_allocate_struct_one_nolimit_wrap +static inline Real * +rbd_allocate_struct_one_nolimit_wrap(int sign, size_t const digits) +{ + return rbd_allocate_struct_one_wrap_klass(rb_cBigDecimal, sign, digits, false); +} + +static inline int +is_kind_of_BigDecimal(VALUE const v) +{ + return rb_typeddata_is_kind_of(v, &BigDecimal_data_type); +} + +NORETURN(static void cannot_be_coerced_into_BigDecimal(VALUE, VALUE)); + +static void +cannot_be_coerced_into_BigDecimal(VALUE exc_class, VALUE v) +{ + VALUE str; + + if (rb_special_const_p(v)) { + str = rb_inspect(v); + } + else { + str = rb_class_name(rb_obj_class(v)); + } + + str = rb_str_cat2(rb_str_dup(str), " can't be coerced into BigDecimal"); + rb_exc_raise(rb_exc_new3(exc_class, str)); +} + +static inline VALUE BigDecimal_div2(VALUE, VALUE, VALUE); +static VALUE rb_inum_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception); +static VALUE rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception); +static VALUE rb_rational_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception); +static VALUE rb_cstr_convert_to_BigDecimal(const char *c_str, size_t digs, int raise_exception); +static VALUE rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception); + +static Real* +GetVpValueWithPrec(VALUE v, long prec, int must) +{ + const size_t digs = prec < 0 ? SIZE_MAX : (size_t)prec; + + switch(TYPE(v)) { + case T_FLOAT: + v = rb_float_convert_to_BigDecimal(v, digs, must); + break; + + case T_RATIONAL: + v = rb_rational_convert_to_BigDecimal(v, digs, must); + break; + + case T_DATA: + if (!is_kind_of_BigDecimal(v)) { + goto SomeOneMayDoIt; + } + break; + + case T_FIXNUM: { + char szD[128]; + snprintf(szD, 128, "%ld", FIX2LONG(v)); + v = rb_cstr_convert_to_BigDecimal(szD, VpBaseFig() * 2 + 1, must); + break; + } + +#ifdef ENABLE_NUMERIC_STRING + case T_STRING: { + const char *c_str = StringValueCStr(v); + v = rb_cstr_convert_to_BigDecimal(c_str, RSTRING_LEN(v) + VpBaseFig() + 1, must); + break; + } +#endif /* ENABLE_NUMERIC_STRING */ + + case T_BIGNUM: { + VALUE bg = rb_big2str(v, 10); + v = rb_cstr_convert_to_BigDecimal(RSTRING_PTR(bg), RSTRING_LEN(bg) + VpBaseFig() + 1, must); + RB_GC_GUARD(bg); + break; + } + + default: + goto SomeOneMayDoIt; + } + + Real *vp; + TypedData_Get_Struct(v, Real, &BigDecimal_data_type, vp); + return vp; + +SomeOneMayDoIt: + if (must) { + cannot_be_coerced_into_BigDecimal(rb_eTypeError, v); + } + return NULL; /* NULL means to coerce */ +} + +static inline Real* +GetVpValue(VALUE v, int must) +{ + return GetVpValueWithPrec(v, -1, must); +} + +/* call-seq: + * BigDecimal.double_fig -> integer + * + * Returns the number of digits a Float object is allowed to have; + * the result is system-dependent: + * + * BigDecimal.double_fig # => 16 + * + */ +static inline VALUE +BigDecimal_double_fig(VALUE self) +{ + return INT2FIX(VpDblFig()); +} + +/* call-seq: + * precs -> array + * + * Returns an Array of two Integer values that represent platform-dependent + * internal storage properties. + * + * This method is deprecated and will be removed in the future. + * Instead, use BigDecimal#n_significant_digits for obtaining the number of + * significant digits in scientific notation, and BigDecimal#precision for + * obtaining the number of digits in decimal notation. + * + */ + +static VALUE +BigDecimal_prec(VALUE self) +{ + ENTER(1); + Real *p; + VALUE obj; + + rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, + "BigDecimal#precs is deprecated and will be removed in the future; " + "use BigDecimal#precision instead."); + + GUARD_OBJ(p, GetVpValue(self, 1)); + obj = rb_assoc_new(SIZET2NUM(p->Prec*VpBaseFig()), + SIZET2NUM(p->MaxPrec*VpBaseFig())); + return obj; +} + +static void +BigDecimal_count_precision_and_scale(VALUE self, ssize_t *out_precision, ssize_t *out_scale) +{ + ENTER(1); + + if (out_precision == NULL && out_scale == NULL) + return; + + Real *p; + GUARD_OBJ(p, GetVpValue(self, 1)); + if (VpIsZero(p) || !VpIsDef(p)) { + zero: + if (out_precision) *out_precision = 0; + if (out_scale) *out_scale = 0; + return; + } + + DECDIG x; + + ssize_t n = p->Prec; /* The length of frac without zeros. */ + while (n > 0 && p->frac[n-1] == 0) --n; + if (n == 0) goto zero; + + int nlz = BASE_FIG; + for (x = p->frac[0]; x > 0; x /= 10) --nlz; + + int ntz = 0; + for (x = p->frac[n-1]; x > 0 && x % 10 == 0; x /= 10) ++ntz; + + /* + * Calculate the precision and the scale + * ------------------------------------- + * + * The most significant digit is frac[0], and the least significant digit + * is frac[Prec-1]. When the exponent is zero, the decimal point is + * located just before frac[0]. + * + * When the exponent is negative, the decimal point moves to leftward. + * In this case, the precision can be calculated by + * + * precision = BASE_FIG * (-exponent + n) - ntz, + * + * and the scale is the same as precision. + * + * 0 . 0000 0000 | frac[0] ... frac[n-1] | + * |<----------| exponent == -2 | + * |---------------------------------->| precision + * |---------------------------------->| scale + * + * + * Conversely, when the exponent is positive, the decimal point moves to + * rightward. In this case, the scale equals to + * + * BASE_FIG * (n - exponent) - ntz. + * + * the precision equals to + * + * scale + BASE_FIG * exponent - nlz. + * + * | frac[0] frac[1] . frac[2] ... frac[n-1] | + * |---------------->| exponent == 2 | + * | |---------------------->| scale + * |---------------------------------------->| precision + */ + + ssize_t ex = p->exponent; + + /* Count the number of decimal digits before frac[1]. */ + ssize_t n_digits_head = BASE_FIG; + if (ex < 0) { + n_digits_head += (-ex) * BASE_FIG; /* The number of leading zeros before frac[0]. */ + ex = 0; + } + else if (ex > 0) { + /* Count the number of decimal digits without the leading zeros in + * the most significant digit in the integral part. + */ + n_digits_head -= nlz; /* Make the number of digits */ + } + + if (out_precision) { + ssize_t precision = n_digits_head; + + /* Count the number of decimal digits after frac[0]. */ + if (ex > (ssize_t)n) { + /* In this case the number is an integer with some trailing zeros. */ + precision += (ex - 1) * BASE_FIG; + } + else if (n > 0) { + precision += (n - 1) * BASE_FIG; + + if (ex < (ssize_t)n) { + precision -= ntz; + } + } + + *out_precision = precision; + } + + if (out_scale) { + ssize_t scale = 0; + + if (p->exponent < 0) { + scale = n_digits_head + (n - 1) * BASE_FIG - ntz; + } + else if (n > p->exponent) { + scale = (n - p->exponent) * BASE_FIG - ntz; + } + + *out_scale = scale; + } +} + +/* + * call-seq: + * precision -> integer + * + * Returns the number of decimal digits in +self+: + * + * BigDecimal("0").precision # => 0 + * BigDecimal("1").precision # => 1 + * BigDecimal("1.1").precision # => 2 + * BigDecimal("3.1415").precision # => 5 + * BigDecimal("-1e20").precision # => 21 + * BigDecimal("1e-20").precision # => 20 + * BigDecimal("Infinity").precision # => 0 + * BigDecimal("-Infinity").precision # => 0 + * BigDecimal("NaN").precision # => 0 + * + */ +static VALUE +BigDecimal_precision(VALUE self) +{ + ssize_t precision; + BigDecimal_count_precision_and_scale(self, &precision, NULL); + return SSIZET2NUM(precision); +} + +/* + * call-seq: + * scale -> integer + * + * Returns the number of decimal digits following the decimal digits in +self+. + * + * BigDecimal("0").scale # => 0 + * BigDecimal("1").scale # => 0 + * BigDecimal("1.1").scale # => 1 + * BigDecimal("3.1415").scale # => 4 + * BigDecimal("-1e20").precision # => 0 + * BigDecimal("1e-20").precision # => 20 + * BigDecimal("Infinity").scale # => 0 + * BigDecimal("-Infinity").scale # => 0 + * BigDecimal("NaN").scale # => 0 + */ +static VALUE +BigDecimal_scale(VALUE self) +{ + ssize_t scale; + BigDecimal_count_precision_and_scale(self, NULL, &scale); + return SSIZET2NUM(scale); +} + +/* + * call-seq: + * precision_scale -> [integer, integer] + * + * Returns a 2-length array; the first item is the result of + * BigDecimal#precision and the second one is of BigDecimal#scale. + * + * See BigDecimal#precision. + * See BigDecimal#scale. + */ +static VALUE +BigDecimal_precision_scale(VALUE self) +{ + ssize_t precision, scale; + BigDecimal_count_precision_and_scale(self, &precision, &scale); + return rb_assoc_new(SSIZET2NUM(precision), SSIZET2NUM(scale)); +} + +/* + * call-seq: + * n_significant_digits -> integer + * + * Returns the number of decimal significant digits in +self+. + * + * BigDecimal("0").n_significant_digits # => 0 + * BigDecimal("1").n_significant_digits # => 1 + * BigDecimal("1.1").n_significant_digits # => 2 + * BigDecimal("3.1415").n_significant_digits # => 5 + * BigDecimal("-1e20").n_significant_digits # => 1 + * BigDecimal("1e-20").n_significant_digits # => 1 + * BigDecimal("Infinity").n_significant_digits # => 0 + * BigDecimal("-Infinity").n_significant_digits # => 0 + * BigDecimal("NaN").n_significant_digits # => 0 + */ +static VALUE +BigDecimal_n_significant_digits(VALUE self) +{ + ENTER(1); + + Real *p; + GUARD_OBJ(p, GetVpValue(self, 1)); + if (VpIsZero(p) || !VpIsDef(p)) { + return INT2FIX(0); + } + + ssize_t n = p->Prec; /* The length of frac without trailing zeros. */ + for (n = p->Prec; n > 0 && p->frac[n-1] == 0; --n); + if (n == 0) return INT2FIX(0); + + DECDIG x; + int nlz = BASE_FIG; + for (x = p->frac[0]; x > 0; x /= 10) --nlz; + + int ntz = 0; + for (x = p->frac[n-1]; x > 0 && x % 10 == 0; x /= 10) ++ntz; + + ssize_t n_significant_digits = BASE_FIG*n - nlz - ntz; + return SSIZET2NUM(n_significant_digits); +} + +/* + * call-seq: + * hash -> integer + * + * Returns the integer hash value for +self+. + * + * Two instances of \BigDecimal have the same hash value if and only if + * they have equal: + * + * - Sign. + * - Fractional part. + * - Exponent. + * + */ +static VALUE +BigDecimal_hash(VALUE self) +{ + ENTER(1); + Real *p; + st_index_t hash; + + GUARD_OBJ(p, GetVpValue(self, 1)); + hash = (st_index_t)p->sign; + /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */ + if(hash == 2 || hash == (st_index_t)-2) { + hash ^= rb_memhash(p->frac, sizeof(DECDIG)*p->Prec); + hash += p->exponent; + } + return ST2FIX(hash); +} + +/* + * call-seq: + * _dump -> string + * + * Returns a string representing the marshalling of +self+. + * See module Marshal. + * + * inf = BigDecimal('Infinity') # => Infinity + * dumped = inf._dump # => "9:Infinity" + * BigDecimal._load(dumped) # => Infinity + * + */ +static VALUE +BigDecimal_dump(int argc, VALUE *argv, VALUE self) +{ + ENTER(5); + Real *vp; + char *psz; + VALUE dummy; + volatile VALUE dump; + size_t len; + + rb_scan_args(argc, argv, "01", &dummy); + GUARD_OBJ(vp,GetVpValue(self, 1)); + dump = rb_str_new(0, VpNumOfChars(vp, "E")+50); + psz = RSTRING_PTR(dump); + snprintf(psz, RSTRING_LEN(dump), "%"PRIuSIZE":", VpMaxPrec(vp)*VpBaseFig()); + len = strlen(psz); + VpToString(vp, psz+len, RSTRING_LEN(dump)-len, 0, 0); + rb_str_resize(dump, strlen(psz)); + return dump; +} + +/* + * Internal method used to provide marshalling support. See the Marshal module. + */ +static VALUE +BigDecimal_load(VALUE self, VALUE str) +{ + ENTER(2); + Real *pv; + unsigned char *pch; + unsigned char ch; + unsigned long m=0; + + pch = (unsigned char *)StringValueCStr(str); + /* First get max prec */ + while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') { + if(!ISDIGIT(ch)) { + rb_raise(rb_eTypeError, "load failed: invalid character in the marshaled string"); + } + m = m*10 + (unsigned long)(ch-'0'); + } + if (m > VpBaseFig()) m -= VpBaseFig(); + GUARD_OBJ(pv, VpNewRbClass(m, (char *)pch, self, true, true)); + m /= VpBaseFig(); + if (m && pv->MaxPrec > m) { + pv->MaxPrec = m+1; + } + return VpCheckGetValue(pv); +} + +static unsigned short +check_rounding_mode_option(VALUE const opts) +{ + VALUE mode; + char const *s; + long l; + + assert(RB_TYPE_P(opts, T_HASH)); + + if (NIL_P(opts)) + goto no_opt; + + mode = rb_hash_lookup2(opts, ID2SYM(id_half), Qundef); + if (mode == Qundef || NIL_P(mode)) + goto no_opt; + + if (SYMBOL_P(mode)) + mode = rb_sym2str(mode); + else if (!RB_TYPE_P(mode, T_STRING)) { + VALUE str_mode = rb_check_string_type(mode); + if (NIL_P(str_mode)) + goto invalid; + mode = str_mode; + } + s = RSTRING_PTR(mode); + l = RSTRING_LEN(mode); + switch (l) { + case 2: + if (strncasecmp(s, "up", 2) == 0) + return VP_ROUND_HALF_UP; + break; + case 4: + if (strncasecmp(s, "even", 4) == 0) + return VP_ROUND_HALF_EVEN; + else if (strncasecmp(s, "down", 4) == 0) + return VP_ROUND_HALF_DOWN; + break; + default: + break; + } + + invalid: + rb_raise(rb_eArgError, "invalid rounding mode (%"PRIsVALUE")", mode); + + no_opt: + return VpGetRoundMode(); +} + +static unsigned short +check_rounding_mode(VALUE const v) +{ + unsigned short sw; + ID id; + if (RB_TYPE_P(v, T_SYMBOL)) { + int i; + id = SYM2ID(v); + for (i = 0; i < RBD_NUM_ROUNDING_MODES; ++i) { + if (rbd_rounding_modes[i].id == id) { + return rbd_rounding_modes[i].mode; + } + } + rb_raise(rb_eArgError, "invalid rounding mode (%"PRIsVALUE")", v); + } + else { + sw = NUM2USHORT(v); + if (!VpIsRoundMode(sw)) { + rb_raise(rb_eArgError, "invalid rounding mode (%"PRIsVALUE")", v); + } + return sw; + } +} + +/* call-seq: + * BigDecimal.mode(mode, setting = nil) -> integer + * + * Returns an integer representing the mode settings + * for exception handling and rounding. + * + * These modes control exception handling: + * + * - \BigDecimal::EXCEPTION_NaN. + * - \BigDecimal::EXCEPTION_INFINITY. + * - \BigDecimal::EXCEPTION_UNDERFLOW. + * - \BigDecimal::EXCEPTION_OVERFLOW. + * - \BigDecimal::EXCEPTION_ZERODIVIDE. + * - \BigDecimal::EXCEPTION_ALL. + * + * Values for +setting+ for exception handling: + * + * - +true+: sets the given +mode+ to +true+. + * - +false+: sets the given +mode+ to +false+. + * - +nil+: does not modify the mode settings. + * + * You can use method BigDecimal.save_exception_mode + * to temporarily change, and then automatically restore, exception modes. + * + * For clarity, some examples below begin by setting all + * exception modes to +false+. + * + * This mode controls the way rounding is to be performed: + * + * - \BigDecimal::ROUND_MODE + * + * You can use method BigDecimal.save_rounding_mode + * to temporarily change, and then automatically restore, the rounding mode. + * + * NaNs + * + * Mode \BigDecimal::EXCEPTION_NaN controls behavior + * when a \BigDecimal NaN is created. + * + * Settings: + * + * - +false+ (default): Returns BigDecimal('NaN'). + * - +true+: Raises FloatDomainError. + * + * Examples: + * + * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 + * BigDecimal('NaN') # => NaN + * BigDecimal.mode(BigDecimal::EXCEPTION_NaN, true) # => 2 + * BigDecimal('NaN') # Raises FloatDomainError + * + * Infinities + * + * Mode \BigDecimal::EXCEPTION_INFINITY controls behavior + * when a \BigDecimal Infinity or -Infinity is created. + * Settings: + * + * - +false+ (default): Returns BigDecimal('Infinity') + * or BigDecimal('-Infinity'). + * - +true+: Raises FloatDomainError. + * + * Examples: + * + * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 + * BigDecimal('Infinity') # => Infinity + * BigDecimal('-Infinity') # => -Infinity + * BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, true) # => 1 + * BigDecimal('Infinity') # Raises FloatDomainError + * BigDecimal('-Infinity') # Raises FloatDomainError + * + * Underflow + * + * Mode \BigDecimal::EXCEPTION_UNDERFLOW controls behavior + * when a \BigDecimal underflow occurs. + * Settings: + * + * - +false+ (default): Returns BigDecimal('0') + * or BigDecimal('-Infinity'). + * - +true+: Raises FloatDomainError. + * + * Examples: + * + * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 + * def flow_under + * x = BigDecimal('0.1') + * 100.times { x *= x } + * end + * flow_under # => 100 + * BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true) # => 4 + * flow_under # Raises FloatDomainError + * + * Overflow + * + * Mode \BigDecimal::EXCEPTION_OVERFLOW controls behavior + * when a \BigDecimal overflow occurs. + * Settings: + * + * - +false+ (default): Returns BigDecimal('Infinity') + * or BigDecimal('-Infinity'). + * - +true+: Raises FloatDomainError. + * + * Examples: + * + * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 + * def flow_over + * x = BigDecimal('10') + * 100.times { x *= x } + * end + * flow_over # => 100 + * BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) # => 1 + * flow_over # Raises FloatDomainError + * + * Zero Division + * + * Mode \BigDecimal::EXCEPTION_ZERODIVIDE controls behavior + * when a zero-division occurs. + * Settings: + * + * - +false+ (default): Returns BigDecimal('Infinity') + * or BigDecimal('-Infinity'). + * - +true+: Raises FloatDomainError. + * + * Examples: + * + * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 + * one = BigDecimal('1') + * zero = BigDecimal('0') + * one / zero # => Infinity + * BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, true) # => 16 + * one / zero # Raises FloatDomainError + * + * All Exceptions + * + * Mode \BigDecimal::EXCEPTION_ALL controls all of the above: + * + * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 + * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true) # => 23 + * + * Rounding + * + * Mode \BigDecimal::ROUND_MODE controls the way rounding is to be performed; + * its +setting+ values are: + * + * - +ROUND_UP+: Round away from zero. + * Aliased as +:up+. + * - +ROUND_DOWN+: Round toward zero. + * Aliased as +:down+ and +:truncate+. + * - +ROUND_HALF_UP+: Round toward the nearest neighbor; + * if the neighbors are equidistant, round away from zero. + * Aliased as +:half_up+ and +:default+. + * - +ROUND_HALF_DOWN+: Round toward the nearest neighbor; + * if the neighbors are equidistant, round toward zero. + * Aliased as +:half_down+. + * - +ROUND_HALF_EVEN+ (Banker's rounding): Round toward the nearest neighbor; + * if the neighbors are equidistant, round toward the even neighbor. + * Aliased as +:half_even+ and +:banker+. + * - +ROUND_CEILING+: Round toward positive infinity. + * Aliased as +:ceiling+ and +:ceil+. + * - +ROUND_FLOOR+: Round toward negative infinity. + * Aliased as +:floor:+. + * + */ +static VALUE +BigDecimal_mode(int argc, VALUE *argv, VALUE self) +{ + VALUE which; + VALUE val; + unsigned long f,fo; + + rb_scan_args(argc, argv, "11", &which, &val); + f = (unsigned long)NUM2INT(which); + + if (f & VP_EXCEPTION_ALL) { + /* Exception mode setting */ + fo = VpGetException(); + if (val == Qnil) return INT2FIX(fo); + if (val != Qfalse && val!=Qtrue) { + rb_raise(rb_eArgError, "second argument must be true or false"); + return Qnil; /* Not reached */ + } + if (f & VP_EXCEPTION_INFINITY) { + VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_INFINITY) : + (fo & (~VP_EXCEPTION_INFINITY)))); + } + fo = VpGetException(); + if (f & VP_EXCEPTION_NaN) { + VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_NaN) : + (fo & (~VP_EXCEPTION_NaN)))); + } + fo = VpGetException(); + if (f & VP_EXCEPTION_UNDERFLOW) { + VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_UNDERFLOW) : + (fo & (~VP_EXCEPTION_UNDERFLOW)))); + } + fo = VpGetException(); + if(f & VP_EXCEPTION_ZERODIVIDE) { + VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_ZERODIVIDE) : + (fo & (~VP_EXCEPTION_ZERODIVIDE)))); + } + fo = VpGetException(); + return INT2FIX(fo); + } + if (VP_ROUND_MODE == f) { + /* Rounding mode setting */ + unsigned short sw; + fo = VpGetRoundMode(); + if (NIL_P(val)) return INT2FIX(fo); + sw = check_rounding_mode(val); + fo = VpSetRoundMode(sw); + return INT2FIX(fo); + } + rb_raise(rb_eTypeError, "first argument for BigDecimal.mode invalid"); + return Qnil; +} + +static size_t +GetAddSubPrec(Real *a, Real *b) +{ + size_t mxs; + size_t mx = a->Prec; + SIGNED_VALUE d; + + if (!VpIsDef(a) || !VpIsDef(b)) return (size_t)-1L; + if (mx < b->Prec) mx = b->Prec; + if (a->exponent != b->exponent) { + mxs = mx; + d = a->exponent - b->exponent; + if (d < 0) d = -d; + mx = mx + (size_t)d; + if (mx < mxs) { + return VpException(VP_EXCEPTION_INFINITY, "Exponent overflow", 0); + } + } + return mx; +} + +static inline SIGNED_VALUE +check_int_precision(VALUE v) +{ + SIGNED_VALUE n; +#if SIZEOF_VALUE <= SIZEOF_LONG + n = (SIGNED_VALUE)NUM2LONG(v); +#elif SIZEOF_VALUE <= SIZEOF_LONG_LONG + n = (SIGNED_VALUE)NUM2LL(v); +#else +# error SIZEOF_VALUE is too large +#endif + if (n < 0) { + rb_raise(rb_eArgError, "negative precision"); + } + return n; +} + +static VALUE +BigDecimal_wrap_struct(VALUE obj, Real *vp) +{ + assert(is_kind_of_BigDecimal(obj)); + assert(vp != NULL); + + if (vp->obj == obj && RTYPEDDATA_DATA(obj) == vp) + return obj; + + assert(RTYPEDDATA_DATA(obj) == NULL); + assert(vp->obj == 0); + + RTYPEDDATA_DATA(obj) = vp; + vp->obj = obj; + RB_OBJ_FREEZE(obj); + return obj; +} + +VP_EXPORT Real * +VpNewRbClass(size_t mx, const char *str, VALUE klass, bool strict_p, bool raise_exception) +{ + VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0); + Real *pv = VpAlloc(mx, str, strict_p, raise_exception); + if (!pv) + return NULL; + BigDecimal_wrap_struct(obj, pv); + return pv; +} + +VP_EXPORT Real * +VpCreateRbObject(size_t mx, const char *str, bool raise_exception) +{ + return VpNewRbClass(mx, str, rb_cBigDecimal, true, raise_exception); +} + +static Real * +VpCopy(Real *pv, Real const* const x) +{ + assert(x != NULL); + + pv = rbd_reallocate_struct(pv, x->MaxPrec); + pv->MaxPrec = x->MaxPrec; + pv->Prec = x->Prec; + pv->exponent = x->exponent; + pv->sign = x->sign; + pv->flag = x->flag; + MEMCPY(pv->frac, x->frac, DECDIG, pv->MaxPrec); + + return pv; +} + +/* Returns True if the value is Not a Number. */ +static VALUE +BigDecimal_IsNaN(VALUE self) +{ + Real *p = GetVpValue(self, 1); + if (VpIsNaN(p)) return Qtrue; + return Qfalse; +} + +/* Returns nil, -1, or +1 depending on whether the value is finite, + * -Infinity, or +Infinity. + */ +static VALUE +BigDecimal_IsInfinite(VALUE self) +{ + Real *p = GetVpValue(self, 1); + if (VpIsPosInf(p)) return INT2FIX(1); + if (VpIsNegInf(p)) return INT2FIX(-1); + return Qnil; +} + +/* Returns True if the value is finite (not NaN or infinite). */ +static VALUE +BigDecimal_IsFinite(VALUE self) +{ + Real *p = GetVpValue(self, 1); + if (VpIsNaN(p)) return Qfalse; + if (VpIsInf(p)) return Qfalse; + return Qtrue; +} + +static void +BigDecimal_check_num(Real *p) +{ + VpCheckException(p, true); +} + +static VALUE BigDecimal_split(VALUE self); + +/* Returns the value as an Integer. + * + * If the BigDecimal is infinity or NaN, raises FloatDomainError. + */ +static VALUE +BigDecimal_to_i(VALUE self) +{ + ENTER(5); + ssize_t e, nf; + Real *p; + + GUARD_OBJ(p, GetVpValue(self, 1)); + BigDecimal_check_num(p); + + e = VpExponent10(p); + if (e <= 0) return INT2FIX(0); + nf = VpBaseFig(); + if (e <= nf) { + return LONG2NUM((long)(VpGetSign(p) * (DECDIG_DBL_SIGNED)p->frac[0])); + } + else { + VALUE a = BigDecimal_split(self); + VALUE digits = RARRAY_AREF(a, 1); + VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0); + VALUE ret; + ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits); + + if (BIGDECIMAL_NEGATIVE_P(p)) { + numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1)); + } + if (dpower < 0) { + ret = rb_funcall(numerator, rb_intern("div"), 1, + rb_funcall(INT2FIX(10), rb_intern("**"), 1, + INT2FIX(-dpower))); + } + else { + ret = rb_funcall(numerator, '*', 1, + rb_funcall(INT2FIX(10), rb_intern("**"), 1, + INT2FIX(dpower))); + } + if (RB_TYPE_P(ret, T_FLOAT)) { + rb_raise(rb_eFloatDomainError, "Infinity"); + } + return ret; + } +} + +/* Returns a new Float object having approximately the same value as the + * BigDecimal number. Normal accuracy limits and built-in errors of binary + * Float arithmetic apply. + */ +static VALUE +BigDecimal_to_f(VALUE self) +{ + ENTER(1); + Real *p; + double d; + SIGNED_VALUE e; + char *buf; + volatile VALUE str; + + GUARD_OBJ(p, GetVpValue(self, 1)); + if (VpVtoD(&d, &e, p) != 1) + return rb_float_new(d); + if (e > (SIGNED_VALUE)(DBL_MAX_10_EXP+BASE_FIG)) + goto overflow; + if (e < (SIGNED_VALUE)(DBL_MIN_10_EXP-BASE_FIG)) + goto underflow; + + str = rb_str_new(0, VpNumOfChars(p, "E")); + buf = RSTRING_PTR(str); + VpToString(p, buf, RSTRING_LEN(str), 0, 0); + errno = 0; + d = strtod(buf, 0); + if (errno == ERANGE) { + if (d == 0.0) goto underflow; + if (fabs(d) >= HUGE_VAL) goto overflow; + } + return rb_float_new(d); + +overflow: + VpException(VP_EXCEPTION_OVERFLOW, "BigDecimal to Float conversion", 0); + if (BIGDECIMAL_NEGATIVE_P(p)) + return rb_float_new(VpGetDoubleNegInf()); + else + return rb_float_new(VpGetDoublePosInf()); + +underflow: + VpException(VP_EXCEPTION_UNDERFLOW, "BigDecimal to Float conversion", 0); + if (BIGDECIMAL_NEGATIVE_P(p)) + return rb_float_new(-0.0); + else + return rb_float_new(0.0); +} + + +/* Converts a BigDecimal to a Rational. + */ +static VALUE +BigDecimal_to_r(VALUE self) +{ + Real *p; + ssize_t sign, power, denomi_power; + VALUE a, digits, numerator; + + p = GetVpValue(self, 1); + BigDecimal_check_num(p); + + sign = VpGetSign(p); + power = VpExponent10(p); + a = BigDecimal_split(self); + digits = RARRAY_AREF(a, 1); + denomi_power = power - RSTRING_LEN(digits); + numerator = rb_funcall(digits, rb_intern("to_i"), 0); + + if (sign < 0) { + numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1)); + } + if (denomi_power < 0) { + return rb_Rational(numerator, + rb_funcall(INT2FIX(10), rb_intern("**"), 1, + INT2FIX(-denomi_power))); + } + else { + return rb_Rational1(rb_funcall(numerator, '*', 1, + rb_funcall(INT2FIX(10), rb_intern("**"), 1, + INT2FIX(denomi_power)))); + } +} + +/* The coerce method provides support for Ruby type coercion. It is not + * enabled by default. + * + * This means that binary operations like + * / or - can often be performed + * on a BigDecimal and an object of another type, if the other object can + * be coerced into a BigDecimal value. + * + * e.g. + * a = BigDecimal("1.0") + * b = a / 2.0 #=> 0.5 + * + * Note that coercing a String to a BigDecimal is not supported by default; + * it requires a special compile-time option when building Ruby. + */ +static VALUE +BigDecimal_coerce(VALUE self, VALUE other) +{ + ENTER(2); + VALUE obj; + Real *b; + + if (RB_TYPE_P(other, T_FLOAT)) { + GUARD_OBJ(b, GetVpValueWithPrec(other, 0, 1)); + obj = rb_assoc_new(VpCheckGetValue(b), self); + } + else { + if (RB_TYPE_P(other, T_RATIONAL)) { + Real* pv = DATA_PTR(self); + GUARD_OBJ(b, GetVpValueWithPrec(other, pv->Prec*VpBaseFig(), 1)); + } + else { + GUARD_OBJ(b, GetVpValue(other, 1)); + } + obj = rb_assoc_new(b->obj, self); + } + + return obj; +} + +/* + * call-seq: + * +big_decimal -> self + * + * Returns +self+: + * + * +BigDecimal(5) # => 0.5e1 + * +BigDecimal(-5) # => -0.5e1 + * + */ + +static VALUE +BigDecimal_uplus(VALUE self) +{ + return self; +} + + /* + * call-seq: + * self + value -> bigdecimal + * + * Returns the \BigDecimal sum of +self+ and +value+: + * + * b = BigDecimal('111111.111') # => 0.111111111e6 + * b + 2 # => 0.111113111e6 + * b + 2.0 # => 0.111113111e6 + * b + Rational(2, 1) # => 0.111113111e6 + * b + Complex(2, 0) # => (0.111113111e6+0i) + * + * See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision]. + * + */ + +static VALUE +BigDecimal_add(VALUE self, VALUE r) +{ + ENTER(5); + Real *c, *a, *b; + size_t mx; + + GUARD_OBJ(a, GetVpValue(self, 1)); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, 0, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r, 0); + } + + if (!b) return DoSomeOne(self,r,'+'); + SAVE(b); + + if (VpIsNaN(b)) return b->obj; + if (VpIsNaN(a)) return a->obj; + + mx = GetAddSubPrec(a, b); + if (mx == (size_t)-1L) { + GUARD_OBJ(c, NewZeroWrapLimited(1, VpBaseFig() + 1)); + VpAddSub(c, a, b, 1); + } + else { + GUARD_OBJ(c, NewZeroWrapLimited(1, mx * (VpBaseFig() + 1))); + if (!mx) { + VpSetInf(c, VpGetSign(a)); + } + else { + VpAddSub(c, a, b, 1); + } + } + return VpCheckGetValue(c); +} + + /* call-seq: + * self - value -> bigdecimal + * + * Returns the \BigDecimal difference of +self+ and +value+: + * + * b = BigDecimal('333333.333') # => 0.333333333e6 + * b - 2 # => 0.333331333e6 + * b - 2.0 # => 0.333331333e6 + * b - Rational(2, 1) # => 0.333331333e6 + * b - Complex(2, 0) # => (0.333331333e6+0i) + * + * See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision]. + * + */ +static VALUE +BigDecimal_sub(VALUE self, VALUE r) +{ + ENTER(5); + Real *c, *a, *b; + size_t mx; + + GUARD_OBJ(a, GetVpValue(self,1)); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, 0, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + + if (!b) return DoSomeOne(self,r,'-'); + SAVE(b); + + if (VpIsNaN(b)) return b->obj; + if (VpIsNaN(a)) return a->obj; + + mx = GetAddSubPrec(a,b); + if (mx == (size_t)-1L) { + GUARD_OBJ(c, NewZeroWrapLimited(1, VpBaseFig() + 1)); + VpAddSub(c, a, b, -1); + } + else { + GUARD_OBJ(c, NewZeroWrapLimited(1, mx *(VpBaseFig() + 1))); + if (!mx) { + VpSetInf(c,VpGetSign(a)); + } + else { + VpAddSub(c, a, b, -1); + } + } + return VpCheckGetValue(c); +} + +static VALUE +BigDecimalCmp(VALUE self, VALUE r,char op) +{ + ENTER(5); + SIGNED_VALUE e; + Real *a, *b=0; + GUARD_OBJ(a, GetVpValue(self, 1)); + switch (TYPE(r)) { + case T_DATA: + if (!is_kind_of_BigDecimal(r)) break; + /* fall through */ + case T_FIXNUM: + /* fall through */ + case T_BIGNUM: + GUARD_OBJ(b, GetVpValue(r, 0)); + break; + + case T_FLOAT: + GUARD_OBJ(b, GetVpValueWithPrec(r, 0, 0)); + break; + + case T_RATIONAL: + GUARD_OBJ(b, GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 0)); + break; + + default: + break; + } + if (b == NULL) { + ID f = 0; + + switch (op) { + case '*': + return rb_num_coerce_cmp(self, r, rb_intern("<=>")); + + case '=': + return RTEST(rb_num_coerce_cmp(self, r, rb_intern("=="))) ? Qtrue : Qfalse; + + case 'G': + f = rb_intern(">="); + break; + + case 'L': + f = rb_intern("<="); + break; + + case '>': + /* fall through */ + case '<': + f = (ID)op; + break; + + default: + break; + } + return rb_num_coerce_relop(self, r, f); + } + SAVE(b); + e = VpComp(a, b); + if (e == 999) + return (op == '*') ? Qnil : Qfalse; + switch (op) { + case '*': + return INT2FIX(e); /* any op */ + + case '=': + if (e == 0) return Qtrue; + return Qfalse; + + case 'G': + if (e >= 0) return Qtrue; + return Qfalse; + + case '>': + if (e > 0) return Qtrue; + return Qfalse; + + case 'L': + if (e <= 0) return Qtrue; + return Qfalse; + + case '<': + if (e < 0) return Qtrue; + return Qfalse; + + default: + break; + } + + rb_bug("Undefined operation in BigDecimalCmp()"); + + UNREACHABLE; +} + +/* Returns True if the value is zero. */ +static VALUE +BigDecimal_zero(VALUE self) +{ + Real *a = GetVpValue(self, 1); + return VpIsZero(a) ? Qtrue : Qfalse; +} + +/* Returns self if the value is non-zero, nil otherwise. */ +static VALUE +BigDecimal_nonzero(VALUE self) +{ + Real *a = GetVpValue(self, 1); + return VpIsZero(a) ? Qnil : self; +} + +/* The comparison operator. + * a <=> b is 0 if a == b, 1 if a > b, -1 if a < b. + */ +static VALUE +BigDecimal_comp(VALUE self, VALUE r) +{ + return BigDecimalCmp(self, r, '*'); +} + +/* + * Tests for value equality; returns true if the values are equal. + * + * The == and === operators and the eql? method have the same implementation + * for BigDecimal. + * + * Values may be coerced to perform the comparison: + * + * BigDecimal('1.0') == 1.0 #=> true + */ +static VALUE +BigDecimal_eq(VALUE self, VALUE r) +{ + return BigDecimalCmp(self, r, '='); +} + +/* call-seq: + * self < other -> true or false + * + * Returns +true+ if +self+ is less than +other+, +false+ otherwise: + * + * b = BigDecimal('1.5') # => 0.15e1 + * b < 2 # => true + * b < 2.0 # => true + * b < Rational(2, 1) # => true + * b < 1.5 # => false + * + * Raises an exception if the comparison cannot be made. + * + */ +static VALUE +BigDecimal_lt(VALUE self, VALUE r) +{ + return BigDecimalCmp(self, r, '<'); +} + +/* call-seq: + * self <= other -> true or false + * + * Returns +true+ if +self+ is less or equal to than +other+, +false+ otherwise: + * + * b = BigDecimal('1.5') # => 0.15e1 + * b <= 2 # => true + * b <= 2.0 # => true + * b <= Rational(2, 1) # => true + * b <= 1.5 # => true + * b < 1 # => false + * + * Raises an exception if the comparison cannot be made. + * + */ +static VALUE +BigDecimal_le(VALUE self, VALUE r) +{ + return BigDecimalCmp(self, r, 'L'); +} + +/* call-seq: + * self > other -> true or false + * + * Returns +true+ if +self+ is greater than +other+, +false+ otherwise: + * + * b = BigDecimal('1.5') + * b > 1 # => true + * b > 1.0 # => true + * b > Rational(1, 1) # => true + * b > 2 # => false + * + * Raises an exception if the comparison cannot be made. + * + */ +static VALUE +BigDecimal_gt(VALUE self, VALUE r) +{ + return BigDecimalCmp(self, r, '>'); +} + +/* call-seq: + * self >= other -> true or false + * + * Returns +true+ if +self+ is greater than or equal to +other+, +false+ otherwise: + * + * b = BigDecimal('1.5') + * b >= 1 # => true + * b >= 1.0 # => true + * b >= Rational(1, 1) # => true + * b >= 1.5 # => true + * b > 2 # => false + * + * Raises an exception if the comparison cannot be made. + * + */ +static VALUE +BigDecimal_ge(VALUE self, VALUE r) +{ + return BigDecimalCmp(self, r, 'G'); +} + +/* + * call-seq: + * -self -> bigdecimal + * + * Returns the \BigDecimal negation of self: + * + * b0 = BigDecimal('1.5') + * b1 = -b0 # => -0.15e1 + * b2 = -b1 # => 0.15e1 + * + */ + +static VALUE +BigDecimal_neg(VALUE self) +{ + ENTER(5); + Real *c, *a; + GUARD_OBJ(a, GetVpValue(self, 1)); + GUARD_OBJ(c, NewZeroWrapLimited(1, a->Prec *(VpBaseFig() + 1))); + VpAsgn(c, a, -1); + return VpCheckGetValue(c); +} + +/* + * call-seq: + * a * b -> bigdecimal + * + * Multiply by the specified value. + * + * The result precision will be the precision of the sum of each precision. + * + * See BigDecimal#mult. + */ + +static VALUE +BigDecimal_mult(VALUE self, VALUE r) +{ + ENTER(5); + Real *c, *a, *b; + size_t mx; + + GUARD_OBJ(a, GetVpValue(self, 1)); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, 0, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + + if (!b) return DoSomeOne(self, r, '*'); + SAVE(b); + + mx = a->Prec + b->Prec; + GUARD_OBJ(c, NewZeroWrapLimited(1, mx * (VpBaseFig() + 1))); + VpMult(c, a, b); + return VpCheckGetValue(c); +} + +static VALUE +BigDecimal_divide(VALUE self, VALUE r, Real **c, Real **res, Real **div) +/* For c = self.div(r): with round operation */ +{ + ENTER(5); + Real *a, *b; + ssize_t a_prec, b_prec; + size_t mx; + + TypedData_Get_Struct(self, Real, &BigDecimal_data_type, a); + SAVE(a); + + VALUE rr = r; + if (is_kind_of_BigDecimal(rr)) { + /* do nothing */ + } + else if (RB_INTEGER_TYPE_P(r)) { + rr = rb_inum_convert_to_BigDecimal(r, 0, true); + } + else if (RB_TYPE_P(r, T_FLOAT)) { + rr = rb_float_convert_to_BigDecimal(r, 0, true); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + rr = rb_rational_convert_to_BigDecimal(r, a->Prec*BASE_FIG, true); + } + + if (!is_kind_of_BigDecimal(rr)) { + return DoSomeOne(self, r, '/'); + } + + TypedData_Get_Struct(rr, Real, &BigDecimal_data_type, b); + SAVE(b); + *div = b; + + BigDecimal_count_precision_and_scale(self, &a_prec, NULL); + BigDecimal_count_precision_and_scale(rr, &b_prec, NULL); + mx = (a_prec > b_prec) ? a_prec : b_prec; + mx *= 2; + + if (2*BIGDECIMAL_DOUBLE_FIGURES > mx) + mx = 2*BIGDECIMAL_DOUBLE_FIGURES; + + GUARD_OBJ((*c), NewZeroWrapNolimit(1, mx + 2*BASE_FIG)); + GUARD_OBJ((*res), NewZeroWrapNolimit(1, (mx + 1)*2 + 2*BASE_FIG)); + VpDivd(*c, *res, a, b); + + return Qnil; +} + +static VALUE BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod); + +/* call-seq: + * a / b -> bigdecimal + * + * Divide by the specified value. + * + * The result precision will be the precision of the larger operand, + * but its minimum is 2*Float::DIG. + * + * See BigDecimal#div. + * See BigDecimal#quo. + */ +static VALUE +BigDecimal_div(VALUE self, VALUE r) +/* For c = self/r: with round operation */ +{ + ENTER(5); + Real *c=NULL, *res=NULL, *div = NULL; + r = BigDecimal_divide(self, r, &c, &res, &div); + if (!NIL_P(r)) return r; /* coerced by other */ + SAVE(c); SAVE(res); SAVE(div); + /* a/b = c + r/b */ + /* c xxxxx + r 00000yyyyy ==> (y/b)*BASE >= HALF_BASE + */ + /* Round */ + if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */ + VpInternalRound(c, 0, c->frac[c->Prec-1], (DECDIG)(VpBaseVal() * (DECDIG_DBL)res->frac[0] / div->frac[0])); + } + return VpCheckGetValue(c); +} + +static VALUE BigDecimal_round(int argc, VALUE *argv, VALUE self); + +/* call-seq: + * quo(value) -> bigdecimal + * quo(value, digits) -> bigdecimal + * + * Divide by the specified value. + * + * digits:: If specified and less than the number of significant digits of + * the result, the result is rounded to the given number of digits, + * according to the rounding mode indicated by BigDecimal.mode. + * + * If digits is 0 or omitted, the result is the same as for the + * / operator. + * + * See BigDecimal#/. + * See BigDecimal#div. + */ +static VALUE +BigDecimal_quo(int argc, VALUE *argv, VALUE self) +{ + VALUE value, digits, result; + SIGNED_VALUE n = -1; + + argc = rb_scan_args(argc, argv, "11", &value, &digits); + if (argc > 1) { + n = check_int_precision(digits); + } + + if (n > 0) { + result = BigDecimal_div2(self, value, digits); + } + else { + result = BigDecimal_div(self, value); + } + + return result; +} + +/* + * %: mod = a%b = a - (a.to_f/b).floor * b + * div = (a.to_f/b).floor + */ +static VALUE +BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod) +{ + ENTER(8); + Real *c=NULL, *d=NULL, *res=NULL; + Real *a, *b; + ssize_t a_prec, b_prec; + size_t mx; + + TypedData_Get_Struct(self, Real, &BigDecimal_data_type, a); + SAVE(a); + + VALUE rr = r; + if (is_kind_of_BigDecimal(rr)) { + /* do nothing */ + } + else if (RB_INTEGER_TYPE_P(r)) { + rr = rb_inum_convert_to_BigDecimal(r, 0, true); + } + else if (RB_TYPE_P(r, T_FLOAT)) { + rr = rb_float_convert_to_BigDecimal(r, 0, true); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + rr = rb_rational_convert_to_BigDecimal(r, a->Prec*BASE_FIG, true); + } + + if (!is_kind_of_BigDecimal(rr)) { + return Qfalse; + } + + TypedData_Get_Struct(rr, Real, &BigDecimal_data_type, b); + SAVE(b); + + if (VpIsNaN(a) || VpIsNaN(b)) goto NaN; + if (VpIsInf(a) && VpIsInf(b)) goto NaN; + if (VpIsZero(b)) { + rb_raise(rb_eZeroDivError, "divided by 0"); + } + if (VpIsInf(a)) { + if (VpGetSign(a) == VpGetSign(b)) { + VALUE inf = BigDecimal_positive_infinity(); + TypedData_Get_Struct(inf, Real, &BigDecimal_data_type, *div); + } + else { + VALUE inf = BigDecimal_negative_infinity(); + TypedData_Get_Struct(inf, Real, &BigDecimal_data_type, *div); + } + VALUE nan = BigDecimal_nan(); + TypedData_Get_Struct(nan, Real, &BigDecimal_data_type, *mod); + return Qtrue; + } + if (VpIsInf(b)) { + VALUE zero = BigDecimal_positive_zero(); + TypedData_Get_Struct(zero, Real, &BigDecimal_data_type, *div); + *mod = a; + return Qtrue; + } + if (VpIsZero(a)) { + VALUE zero = BigDecimal_positive_zero(); + TypedData_Get_Struct(zero, Real, &BigDecimal_data_type, *div); + TypedData_Get_Struct(zero, Real, &BigDecimal_data_type, *mod); + return Qtrue; + } + + BigDecimal_count_precision_and_scale(self, &a_prec, NULL); + BigDecimal_count_precision_and_scale(rr, &b_prec, NULL); + + mx = (a_prec > b_prec) ? a_prec : b_prec; + mx *= 2; + + if (2*BIGDECIMAL_DOUBLE_FIGURES > mx) + mx = 2*BIGDECIMAL_DOUBLE_FIGURES; + + GUARD_OBJ(c, NewZeroWrapLimited(1, mx + 2*BASE_FIG)); + GUARD_OBJ(res, NewZeroWrapNolimit(1, mx*2 + 2*BASE_FIG)); + VpDivd(c, res, a, b); + + mx = c->Prec * BASE_FIG; + GUARD_OBJ(d, NewZeroWrapLimited(1, mx)); + VpActiveRound(d, c, VP_ROUND_DOWN, 0); + + VpMult(res, d, b); + VpAddSub(c, a, res, -1); + + if (!VpIsZero(c) && (VpGetSign(a) * VpGetSign(b) < 0)) { + /* result adjustment for negative case */ + res = rbd_reallocate_struct(res, d->MaxPrec); + res->MaxPrec = d->MaxPrec; + VpAddSub(res, d, VpOne(), -1); + GUARD_OBJ(d, NewZeroWrapLimited(1, GetAddSubPrec(c, b) * 2*BASE_FIG)); + VpAddSub(d, c, b, 1); + *div = res; + *mod = d; + } + else { + *div = d; + *mod = c; + } + return Qtrue; + + NaN: + { + VALUE nan = BigDecimal_nan(); + TypedData_Get_Struct(nan, Real, &BigDecimal_data_type, *div); + TypedData_Get_Struct(nan, Real, &BigDecimal_data_type, *mod); + } + return Qtrue; +} + +/* call-seq: + * a % b + * a.modulo(b) + * + * Returns the modulus from dividing by b. + * + * See BigDecimal#divmod. + */ +static VALUE +BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */ +{ + ENTER(3); + Real *div = NULL, *mod = NULL; + + if (BigDecimal_DoDivmod(self, r, &div, &mod)) { + SAVE(div); SAVE(mod); + return VpCheckGetValue(mod); + } + return DoSomeOne(self, r, '%'); +} + +static VALUE +BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv) +{ + ENTER(10); + size_t mx; + Real *a = NULL, *b = NULL, *c = NULL, *res = NULL, *d = NULL, *rr = NULL, *ff = NULL; + Real *f = NULL; + + GUARD_OBJ(a, GetVpValue(self, 1)); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, 0, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r, 0); + } + + if (!b) return DoSomeOne(self, r, rb_intern("remainder")); + SAVE(b); + + if (VpIsPosInf(b) || VpIsNegInf(b)) { + GUARD_OBJ(*dv, NewZeroWrapLimited(1, 1)); + VpSetZero(*dv, 1); + *rv = a; + return Qnil; + } + + mx = (a->MaxPrec + b->MaxPrec) *VpBaseFig(); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + GUARD_OBJ(res, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1))); + GUARD_OBJ(rr, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1))); + GUARD_OBJ(ff, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1))); + + VpDivd(c, res, a, b); + + mx = c->Prec *(VpBaseFig() + 1); + + GUARD_OBJ(d, NewZeroWrapLimited(1, mx)); + GUARD_OBJ(f, NewZeroWrapLimited(1, mx)); + + VpActiveRound(d, c, VP_ROUND_DOWN, 0); /* 0: round off */ + + VpFrac(f, c); + VpMult(rr, f, b); + VpAddSub(ff, res, rr, 1); + + *dv = d; + *rv = ff; + return Qnil; +} + +/* call-seq: + * remainder(value) + * + * Returns the remainder from dividing by the value. + * + * x.remainder(y) means x-y*(x/y).truncate + */ +static VALUE +BigDecimal_remainder(VALUE self, VALUE r) /* remainder */ +{ + VALUE f; + Real *d, *rv = 0; + f = BigDecimal_divremain(self, r, &d, &rv); + if (!NIL_P(f)) return f; + return VpCheckGetValue(rv); +} + +/* call-seq: + * divmod(value) + * + * Divides by the specified value, and returns the quotient and modulus + * as BigDecimal numbers. The quotient is rounded towards negative infinity. + * + * For example: + * + * require 'bigdecimal' + * + * a = BigDecimal("42") + * b = BigDecimal("9") + * + * q, m = a.divmod(b) + * + * c = q * b + m + * + * a == c #=> true + * + * The quotient q is (a/b).floor, and the modulus is the amount that must be + * added to q * b to get a. + */ +static VALUE +BigDecimal_divmod(VALUE self, VALUE r) +{ + ENTER(5); + Real *div = NULL, *mod = NULL; + + if (BigDecimal_DoDivmod(self, r, &div, &mod)) { + SAVE(div); SAVE(mod); + return rb_assoc_new(VpCheckGetValue(div), VpCheckGetValue(mod)); + } + return DoSomeOne(self,r,rb_intern("divmod")); +} + +/* + * Do the same manner as Float#div when n is nil. + * Do the same manner as BigDecimal#quo when n is 0. + */ +static inline VALUE +BigDecimal_div2(VALUE self, VALUE b, VALUE n) +{ + ENTER(5); + SIGNED_VALUE ix; + + if (NIL_P(n)) { /* div in Float sense */ + Real *div = NULL; + Real *mod; + if (BigDecimal_DoDivmod(self, b, &div, &mod)) { + return BigDecimal_to_i(VpCheckGetValue(div)); + } + return DoSomeOne(self, b, rb_intern("div")); + } + + /* div in BigDecimal sense */ + ix = check_int_precision(n); + if (ix == 0) { + return BigDecimal_div(self, b); + } + else { + Real *res = NULL; + Real *av = NULL, *bv = NULL, *cv = NULL; + size_t mx = ix + VpBaseFig()*2; + size_t b_prec = ix; + size_t pl = VpSetPrecLimit(0); + + GUARD_OBJ(cv, NewZeroWrapLimited(1, mx + VpBaseFig())); + GUARD_OBJ(av, GetVpValue(self, 1)); + /* TODO: I want to refactor this precision control for a float value later + * by introducing an implicit conversion function instead of + * GetVpValueWithPrec. */ + if (RB_FLOAT_TYPE_P(b) && b_prec > BIGDECIMAL_DOUBLE_FIGURES) { + b_prec = BIGDECIMAL_DOUBLE_FIGURES; + } + GUARD_OBJ(bv, GetVpValueWithPrec(b, b_prec, 1)); + mx = av->Prec + bv->Prec + 2; + if (mx <= cv->MaxPrec) mx = cv->MaxPrec + 1; + GUARD_OBJ(res, NewZeroWrapNolimit(1, (mx * 2 + 2)*VpBaseFig())); + VpDivd(cv, res, av, bv); + VpSetPrecLimit(pl); + VpLeftRound(cv, VpGetRoundMode(), ix); + return VpCheckGetValue(cv); + } +} + + /* + * Document-method: BigDecimal#div + * + * call-seq: + * div(value) -> integer + * div(value, digits) -> bigdecimal or integer + * + * Divide by the specified value. + * + * digits:: If specified and less than the number of significant digits of the + * result, the result is rounded to that number of digits, according + * to BigDecimal.mode. + * + * If digits is 0, the result is the same as for the / operator + * or #quo. + * + * If digits is not specified, the result is an integer, + * by analogy with Float#div; see also BigDecimal#divmod. + * + * See BigDecimal#/. + * See BigDecimal#quo. + * + * Examples: + * + * a = BigDecimal("4") + * b = BigDecimal("3") + * + * a.div(b, 3) # => 0.133e1 + * + * a.div(b, 0) # => 0.1333333333333333333e1 + * a / b # => 0.1333333333333333333e1 + * a.quo(b) # => 0.1333333333333333333e1 + * + * a.div(b) # => 1 + */ +static VALUE +BigDecimal_div3(int argc, VALUE *argv, VALUE self) +{ + VALUE b,n; + + rb_scan_args(argc, argv, "11", &b, &n); + + return BigDecimal_div2(self, b, n); +} + + /* + * call-seq: + * add(value, ndigits) -> new_bigdecimal + * + * Returns the \BigDecimal sum of +self+ and +value+ + * with a precision of +ndigits+ decimal digits. + * + * When +ndigits+ is less than the number of significant digits + * in the sum, the sum is rounded to that number of digits, + * according to the current rounding mode; see BigDecimal.mode. + * + * Examples: + * + * # Set the rounding mode. + * BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up) + * b = BigDecimal('111111.111') + * b.add(1, 0) # => 0.111112111e6 + * b.add(1, 3) # => 0.111e6 + * b.add(1, 6) # => 0.111112e6 + * b.add(1, 15) # => 0.111112111e6 + * b.add(1.0, 15) # => 0.111112111e6 + * b.add(Rational(1, 1), 15) # => 0.111112111e6 + * + */ + +static VALUE +BigDecimal_add2(VALUE self, VALUE b, VALUE n) +{ + ENTER(2); + Real *cv; + SIGNED_VALUE mx = check_int_precision(n); + if (mx == 0) return BigDecimal_add(self, b); + else { + size_t pl = VpSetPrecLimit(0); + VALUE c = BigDecimal_add(self, b); + VpSetPrecLimit(pl); + GUARD_OBJ(cv, GetVpValue(c, 1)); + VpLeftRound(cv, VpGetRoundMode(), mx); + return VpCheckGetValue(cv); + } +} + +/* call-seq: + * sub(value, digits) -> bigdecimal + * + * Subtract the specified value. + * + * e.g. + * c = a.sub(b,n) + * + * digits:: If specified and less than the number of significant digits of the + * result, the result is rounded to that number of digits, according + * to BigDecimal.mode. + * + */ +static VALUE +BigDecimal_sub2(VALUE self, VALUE b, VALUE n) +{ + ENTER(2); + Real *cv; + SIGNED_VALUE mx = check_int_precision(n); + if (mx == 0) return BigDecimal_sub(self, b); + else { + size_t pl = VpSetPrecLimit(0); + VALUE c = BigDecimal_sub(self, b); + VpSetPrecLimit(pl); + GUARD_OBJ(cv, GetVpValue(c, 1)); + VpLeftRound(cv, VpGetRoundMode(), mx); + return VpCheckGetValue(cv); + } +} + + /* + * call-seq: + * mult(other, ndigits) -> bigdecimal + * + * Returns the \BigDecimal product of +self+ and +value+ + * with a precision of +ndigits+ decimal digits. + * + * When +ndigits+ is less than the number of significant digits + * in the sum, the sum is rounded to that number of digits, + * according to the current rounding mode; see BigDecimal.mode. + * + * Examples: + * + * # Set the rounding mode. + * BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up) + * b = BigDecimal('555555.555') + * b.mult(3, 0) # => 0.1666666665e7 + * b.mult(3, 3) # => 0.167e7 + * b.mult(3, 6) # => 0.166667e7 + * b.mult(3, 15) # => 0.1666666665e7 + * b.mult(3.0, 0) # => 0.1666666665e7 + * b.mult(Rational(3, 1), 0) # => 0.1666666665e7 + * b.mult(Complex(3, 0), 0) # => (0.1666666665e7+0.0i) + * + */ + +static VALUE +BigDecimal_mult2(VALUE self, VALUE b, VALUE n) +{ + ENTER(2); + Real *cv; + SIGNED_VALUE mx = check_int_precision(n); + if (mx == 0) return BigDecimal_mult(self, b); + else { + size_t pl = VpSetPrecLimit(0); + VALUE c = BigDecimal_mult(self, b); + VpSetPrecLimit(pl); + GUARD_OBJ(cv, GetVpValue(c, 1)); + VpLeftRound(cv, VpGetRoundMode(), mx); + return VpCheckGetValue(cv); + } +} + +/* + * call-seq: + * abs -> bigdecimal + * + * Returns the \BigDecimal absolute value of +self+: + * + * BigDecimal('5').abs # => 0.5e1 + * BigDecimal('-3').abs # => 0.3e1 + * + */ + +static VALUE +BigDecimal_abs(VALUE self) +{ + ENTER(5); + Real *c, *a; + size_t mx; + + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec *(VpBaseFig() + 1); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpAsgn(c, a, 1); + VpChangeSign(c, 1); + return VpCheckGetValue(c); +} + +/* call-seq: + * sqrt(n) + * + * Returns the square root of the value. + * + * Result has at least n significant digits. + */ +static VALUE +BigDecimal_sqrt(VALUE self, VALUE nFig) +{ + ENTER(5); + Real *c, *a; + size_t mx, n; + + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec * (VpBaseFig() + 1); + + n = check_int_precision(nFig); + n += VpDblFig() + VpBaseFig(); + if (mx <= n) mx = n; + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpSqrt(c, a); + return VpCheckGetValue(c); +} + +/* Return the integer part of the number, as a BigDecimal. + */ +static VALUE +BigDecimal_fix(VALUE self) +{ + ENTER(5); + Real *c, *a; + size_t mx; + + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec *(VpBaseFig() + 1); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpActiveRound(c, a, VP_ROUND_DOWN, 0); /* 0: round off */ + return VpCheckGetValue(c); +} + +/* call-seq: + * round(n, mode) + * + * Round to the nearest integer (by default), returning the result as a + * BigDecimal if n is specified, or as an Integer if it isn't. + * + * BigDecimal('3.14159').round #=> 3 + * BigDecimal('8.7').round #=> 9 + * BigDecimal('-9.9').round #=> -10 + * + * BigDecimal('3.14159').round(2).class.name #=> "BigDecimal" + * BigDecimal('3.14159').round.class.name #=> "Integer" + * + * If n is specified and positive, the fractional part of the result has no + * more than that many digits. + * + * If n is specified and negative, at least that many digits to the left of the + * decimal point will be 0 in the result, and return value will be an Integer. + * + * BigDecimal('3.14159').round(3) #=> 3.142 + * BigDecimal('13345.234').round(-2) #=> 13300 + * + * The value of the optional mode argument can be used to determine how + * rounding is performed; see BigDecimal.mode. + */ +static VALUE +BigDecimal_round(int argc, VALUE *argv, VALUE self) +{ + ENTER(5); + Real *c, *a; + int iLoc = 0; + VALUE vLoc; + VALUE vRound; + int round_to_int = 0; + size_t mx, pl; + + unsigned short sw = VpGetRoundMode(); + + switch (rb_scan_args(argc, argv, "02", &vLoc, &vRound)) { + case 0: + iLoc = 0; + round_to_int = 1; + break; + case 1: + if (RB_TYPE_P(vLoc, T_HASH)) { + sw = check_rounding_mode_option(vLoc); + } + else { + iLoc = NUM2INT(vLoc); + if (iLoc < 1) round_to_int = 1; + } + break; + case 2: + iLoc = NUM2INT(vLoc); + if (RB_TYPE_P(vRound, T_HASH)) { + sw = check_rounding_mode_option(vRound); + } + else { + sw = check_rounding_mode(vRound); + } + break; + default: + break; + } + + pl = VpSetPrecLimit(0); + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec * (VpBaseFig() + 1); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpSetPrecLimit(pl); + VpActiveRound(c, a, sw, iLoc); + if (round_to_int) { + return BigDecimal_to_i(VpCheckGetValue(c)); + } + return VpCheckGetValue(c); +} + +/* call-seq: + * truncate(n) + * + * Truncate to the nearest integer (by default), returning the result as a + * BigDecimal. + * + * BigDecimal('3.14159').truncate #=> 3 + * BigDecimal('8.7').truncate #=> 8 + * BigDecimal('-9.9').truncate #=> -9 + * + * If n is specified and positive, the fractional part of the result has no + * more than that many digits. + * + * If n is specified and negative, at least that many digits to the left of the + * decimal point will be 0 in the result. + * + * BigDecimal('3.14159').truncate(3) #=> 3.141 + * BigDecimal('13345.234').truncate(-2) #=> 13300.0 + */ +static VALUE +BigDecimal_truncate(int argc, VALUE *argv, VALUE self) +{ + ENTER(5); + Real *c, *a; + int iLoc; + VALUE vLoc; + size_t mx, pl = VpSetPrecLimit(0); + + if (rb_scan_args(argc, argv, "01", &vLoc) == 0) { + iLoc = 0; + } + else { + iLoc = NUM2INT(vLoc); + } + + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec * (VpBaseFig() + 1); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpSetPrecLimit(pl); + VpActiveRound(c, a, VP_ROUND_DOWN, iLoc); /* 0: truncate */ + if (argc == 0) { + return BigDecimal_to_i(VpCheckGetValue(c)); + } + return VpCheckGetValue(c); +} + +/* Return the fractional part of the number, as a BigDecimal. + */ +static VALUE +BigDecimal_frac(VALUE self) +{ + ENTER(5); + Real *c, *a; + size_t mx; + + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec * (VpBaseFig() + 1); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpFrac(c, a); + return VpCheckGetValue(c); +} + +/* call-seq: + * floor(n) + * + * Return the largest integer less than or equal to the value, as a BigDecimal. + * + * BigDecimal('3.14159').floor #=> 3 + * BigDecimal('-9.1').floor #=> -10 + * + * If n is specified and positive, the fractional part of the result has no + * more than that many digits. + * + * If n is specified and negative, at least that + * many digits to the left of the decimal point will be 0 in the result. + * + * BigDecimal('3.14159').floor(3) #=> 3.141 + * BigDecimal('13345.234').floor(-2) #=> 13300.0 + */ +static VALUE +BigDecimal_floor(int argc, VALUE *argv, VALUE self) +{ + ENTER(5); + Real *c, *a; + int iLoc; + VALUE vLoc; + size_t mx, pl = VpSetPrecLimit(0); + + if (rb_scan_args(argc, argv, "01", &vLoc)==0) { + iLoc = 0; + } + else { + iLoc = NUM2INT(vLoc); + } + + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec * (VpBaseFig() + 1); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpSetPrecLimit(pl); + VpActiveRound(c, a, VP_ROUND_FLOOR, iLoc); +#ifdef BIGDECIMAL_DEBUG + VPrint(stderr, "floor: c=%\n", c); +#endif + if (argc == 0) { + return BigDecimal_to_i(VpCheckGetValue(c)); + } + return VpCheckGetValue(c); +} + +/* call-seq: + * ceil(n) + * + * Return the smallest integer greater than or equal to the value, as a BigDecimal. + * + * BigDecimal('3.14159').ceil #=> 4 + * BigDecimal('-9.1').ceil #=> -9 + * + * If n is specified and positive, the fractional part of the result has no + * more than that many digits. + * + * If n is specified and negative, at least that + * many digits to the left of the decimal point will be 0 in the result. + * + * BigDecimal('3.14159').ceil(3) #=> 3.142 + * BigDecimal('13345.234').ceil(-2) #=> 13400.0 + */ +static VALUE +BigDecimal_ceil(int argc, VALUE *argv, VALUE self) +{ + ENTER(5); + Real *c, *a; + int iLoc; + VALUE vLoc; + size_t mx, pl = VpSetPrecLimit(0); + + if (rb_scan_args(argc, argv, "01", &vLoc) == 0) { + iLoc = 0; + } else { + iLoc = NUM2INT(vLoc); + } + + GUARD_OBJ(a, GetVpValue(self, 1)); + mx = a->Prec * (VpBaseFig() + 1); + GUARD_OBJ(c, NewZeroWrapLimited(1, mx)); + VpSetPrecLimit(pl); + VpActiveRound(c, a, VP_ROUND_CEIL, iLoc); + if (argc == 0) { + return BigDecimal_to_i(VpCheckGetValue(c)); + } + return VpCheckGetValue(c); +} + +/* call-seq: + * to_s(s) + * + * Converts the value to a string. + * + * The default format looks like 0.xxxxEnn. + * + * The optional parameter s consists of either an integer; or an optional '+' + * or ' ', followed by an optional number, followed by an optional 'E' or 'F'. + * + * If there is a '+' at the start of s, positive values are returned with + * a leading '+'. + * + * A space at the start of s returns positive values with a leading space. + * + * If s contains a number, a space is inserted after each group of that many + * digits, starting from '.' and counting outwards. + * + * If s ends with an 'E', engineering notation (0.xxxxEnn) is used. + * + * If s ends with an 'F', conventional floating point notation is used. + * + * Examples: + * + * BigDecimal('-1234567890123.45678901234567890').to_s('5F') + * #=> '-123 45678 90123.45678 90123 45678 9' + * + * BigDecimal('1234567890123.45678901234567890').to_s('+8F') + * #=> '+12345 67890123.45678901 23456789' + * + * BigDecimal('1234567890123.45678901234567890').to_s(' F') + * #=> ' 1234567890123.4567890123456789' + */ +static VALUE +BigDecimal_to_s(int argc, VALUE *argv, VALUE self) +{ + ENTER(5); + int fmt = 0; /* 0: E format, 1: F format */ + int fPlus = 0; /* 0: default, 1: set ' ' before digits, 2: set '+' before digits. */ + Real *vp; + volatile VALUE str; + char *psz; + char ch; + size_t nc, mc = 0; + SIGNED_VALUE m; + VALUE f; + + GUARD_OBJ(vp, GetVpValue(self, 1)); + + if (rb_scan_args(argc, argv, "01", &f) == 1) { + if (RB_TYPE_P(f, T_STRING)) { + psz = StringValueCStr(f); + if (*psz == ' ') { + fPlus = 1; + psz++; + } + else if (*psz == '+') { + fPlus = 2; + psz++; + } + while ((ch = *psz++) != 0) { + if (ISSPACE(ch)) { + continue; + } + if (!ISDIGIT(ch)) { + if (ch == 'F' || ch == 'f') { + fmt = 1; /* F format */ + } + break; + } + mc = mc*10 + ch - '0'; + } + } + else { + m = NUM2INT(f); + if (m <= 0) { + rb_raise(rb_eArgError, "argument must be positive"); + } + mc = (size_t)m; + } + } + if (fmt) { + nc = VpNumOfChars(vp, "F"); + } + else { + nc = VpNumOfChars(vp, "E"); + } + if (mc > 0) { + nc += (nc + mc - 1) / mc + 1; + } + + str = rb_usascii_str_new(0, nc); + psz = RSTRING_PTR(str); + + if (fmt) { + VpToFString(vp, psz, RSTRING_LEN(str), mc, fPlus); + } + else { + VpToString (vp, psz, RSTRING_LEN(str), mc, fPlus); + } + rb_str_resize(str, strlen(psz)); + return str; +} + +/* Splits a BigDecimal number into four parts, returned as an array of values. + * + * The first value represents the sign of the BigDecimal, and is -1 or 1, or 0 + * if the BigDecimal is Not a Number. + * + * The second value is a string representing the significant digits of the + * BigDecimal, with no leading zeros. + * + * The third value is the base used for arithmetic (currently always 10) as an + * Integer. + * + * The fourth value is an Integer exponent. + * + * If the BigDecimal can be represented as 0.xxxxxx*10**n, then xxxxxx is the + * string of significant digits with no leading zeros, and n is the exponent. + * + * From these values, you can translate a BigDecimal to a float as follows: + * + * sign, significant_digits, base, exponent = a.split + * f = sign * "0.#{significant_digits}".to_f * (base ** exponent) + * + * (Note that the to_f method is provided as a more convenient way to translate + * a BigDecimal to a Float.) + */ +static VALUE +BigDecimal_split(VALUE self) +{ + ENTER(5); + Real *vp; + VALUE obj,str; + ssize_t e, s; + char *psz1; + + GUARD_OBJ(vp, GetVpValue(self, 1)); + str = rb_str_new(0, VpNumOfChars(vp, "E")); + psz1 = RSTRING_PTR(str); + VpSzMantissa(vp, psz1, RSTRING_LEN(str)); + s = 1; + if(psz1[0] == '-') { + size_t len = strlen(psz1 + 1); + + memmove(psz1, psz1 + 1, len); + psz1[len] = '\0'; + s = -1; + } + if (psz1[0] == 'N') s = 0; /* NaN */ + e = VpExponent10(vp); + obj = rb_ary_new2(4); + rb_ary_push(obj, INT2FIX(s)); + rb_ary_push(obj, str); + rb_str_resize(str, strlen(psz1)); + rb_ary_push(obj, INT2FIX(10)); + rb_ary_push(obj, SSIZET2NUM(e)); + return obj; +} + +/* Returns the exponent of the BigDecimal number, as an Integer. + * + * If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string + * of digits with no leading zeros, then n is the exponent. + */ +static VALUE +BigDecimal_exponent(VALUE self) +{ + ssize_t e = VpExponent10(GetVpValue(self, 1)); + return SSIZET2NUM(e); +} + +/* Returns a string representation of self. + * + * BigDecimal("1234.5678").inspect + * #=> "0.12345678e4" + */ +static VALUE +BigDecimal_inspect(VALUE self) +{ + ENTER(5); + Real *vp; + volatile VALUE str; + size_t nc; + + GUARD_OBJ(vp, GetVpValue(self, 1)); + nc = VpNumOfChars(vp, "E"); + + str = rb_str_new(0, nc); + VpToString(vp, RSTRING_PTR(str), RSTRING_LEN(str), 0, 0); + rb_str_resize(str, strlen(RSTRING_PTR(str))); + return str; +} + +static VALUE BigMath_s_exp(VALUE, VALUE, VALUE); +static VALUE BigMath_s_log(VALUE, VALUE, VALUE); + +#define BigMath_exp(x, n) BigMath_s_exp(rb_mBigMath, (x), (n)) +#define BigMath_log(x, n) BigMath_s_log(rb_mBigMath, (x), (n)) + +inline static int +is_integer(VALUE x) +{ + return (RB_TYPE_P(x, T_FIXNUM) || RB_TYPE_P(x, T_BIGNUM)); +} + +inline static int +is_negative(VALUE x) +{ + if (FIXNUM_P(x)) { + return FIX2LONG(x) < 0; + } + else if (RB_TYPE_P(x, T_BIGNUM)) { + return FIX2INT(rb_big_cmp(x, INT2FIX(0))) < 0; + } + else if (RB_TYPE_P(x, T_FLOAT)) { + return RFLOAT_VALUE(x) < 0.0; + } + return RTEST(rb_funcall(x, '<', 1, INT2FIX(0))); +} + +#define is_positive(x) (!is_negative(x)) + +inline static int +is_zero(VALUE x) +{ + VALUE num; + + switch (TYPE(x)) { + case T_FIXNUM: + return FIX2LONG(x) == 0; + + case T_BIGNUM: + return Qfalse; + + case T_RATIONAL: + num = rb_rational_num(x); + return FIXNUM_P(num) && FIX2LONG(num) == 0; + + default: + break; + } + + return RTEST(rb_funcall(x, id_eq, 1, INT2FIX(0))); +} + +inline static int +is_one(VALUE x) +{ + VALUE num, den; + + switch (TYPE(x)) { + case T_FIXNUM: + return FIX2LONG(x) == 1; + + case T_BIGNUM: + return Qfalse; + + case T_RATIONAL: + num = rb_rational_num(x); + den = rb_rational_den(x); + return FIXNUM_P(den) && FIX2LONG(den) == 1 && + FIXNUM_P(num) && FIX2LONG(num) == 1; + + default: + break; + } + + return RTEST(rb_funcall(x, id_eq, 1, INT2FIX(1))); +} + +inline static int +is_even(VALUE x) +{ + switch (TYPE(x)) { + case T_FIXNUM: + return (FIX2LONG(x) % 2) == 0; + + case T_BIGNUM: + { + unsigned long l; + rb_big_pack(x, &l, 1); + return l % 2 == 0; + } + + default: + break; + } + + return 0; +} + +static VALUE +bigdecimal_power_by_bigdecimal(Real const* x, Real const* exp, ssize_t const n) +{ + VALUE log_x, multiplied, y; + volatile VALUE obj = exp->obj; + + if (VpIsZero(exp)) { + return VpCheckGetValue(NewOneWrapLimited(1, n)); + } + + log_x = BigMath_log(x->obj, SSIZET2NUM(n+1)); + multiplied = BigDecimal_mult2(exp->obj, log_x, SSIZET2NUM(n+1)); + y = BigMath_exp(multiplied, SSIZET2NUM(n)); + RB_GC_GUARD(obj); + + return y; +} + +/* call-seq: + * power(n) + * power(n, prec) + * + * Returns the value raised to the power of n. + * + * Note that n must be an Integer. + * + * Also available as the operator **. + */ +static VALUE +BigDecimal_power(int argc, VALUE*argv, VALUE self) +{ + ENTER(5); + VALUE vexp, prec; + Real* exp = NULL; + Real *x, *y; + ssize_t mp, ma, n; + SIGNED_VALUE int_exp; + double d; + + rb_scan_args(argc, argv, "11", &vexp, &prec); + + GUARD_OBJ(x, GetVpValue(self, 1)); + n = NIL_P(prec) ? (ssize_t)(x->Prec*VpBaseFig()) : NUM2SSIZET(prec); + + if (VpIsNaN(x)) { + y = NewZeroWrapLimited(1, n); + VpSetNaN(y); + RB_GC_GUARD(y->obj); + return VpCheckGetValue(y); + } + + retry: + switch (TYPE(vexp)) { + case T_FIXNUM: + break; + + case T_BIGNUM: + break; + + case T_FLOAT: + d = RFLOAT_VALUE(vexp); + if (d == round(d)) { + if (FIXABLE(d)) { + vexp = LONG2FIX((long)d); + } + else { + vexp = rb_dbl2big(d); + } + goto retry; + } + if (NIL_P(prec)) { + n += BIGDECIMAL_DOUBLE_FIGURES; + } + exp = GetVpValueWithPrec(vexp, 0, 1); + break; + + case T_RATIONAL: + if (is_zero(rb_rational_num(vexp))) { + if (is_positive(vexp)) { + vexp = INT2FIX(0); + goto retry; + } + } + else if (is_one(rb_rational_den(vexp))) { + vexp = rb_rational_num(vexp); + goto retry; + } + exp = GetVpValueWithPrec(vexp, n, 1); + if (NIL_P(prec)) { + n += n; + } + break; + + case T_DATA: + if (is_kind_of_BigDecimal(vexp)) { + VALUE zero = INT2FIX(0); + VALUE rounded = BigDecimal_round(1, &zero, vexp); + if (RTEST(BigDecimal_eq(vexp, rounded))) { + vexp = BigDecimal_to_i(vexp); + goto retry; + } + if (NIL_P(prec)) { + GUARD_OBJ(y, GetVpValue(vexp, 1)); + n += y->Prec*VpBaseFig(); + } + exp = DATA_PTR(vexp); + break; + } + /* fall through */ + default: + rb_raise(rb_eTypeError, + "wrong argument type %"PRIsVALUE" (expected scalar Numeric)", + RB_OBJ_CLASSNAME(vexp)); + } + + if (VpIsZero(x)) { + if (is_negative(vexp)) { + y = NewZeroWrapNolimit(1, n); + if (BIGDECIMAL_NEGATIVE_P(x)) { + if (is_integer(vexp)) { + if (is_even(vexp)) { + /* (-0) ** (-even_integer) -> Infinity */ + VpSetPosInf(y); + } + else { + /* (-0) ** (-odd_integer) -> -Infinity */ + VpSetNegInf(y); + } + } + else { + /* (-0) ** (-non_integer) -> Infinity */ + VpSetPosInf(y); + } + } + else { + /* (+0) ** (-num) -> Infinity */ + VpSetPosInf(y); + } + RB_GC_GUARD(y->obj); + return VpCheckGetValue(y); + } + else if (is_zero(vexp)) { + return VpCheckGetValue(NewOneWrapLimited(1, n)); + } + else { + return VpCheckGetValue(NewZeroWrapLimited(1, n)); + } + } + + if (is_zero(vexp)) { + return VpCheckGetValue(NewOneWrapLimited(1, n)); + } + else if (is_one(vexp)) { + return self; + } + + if (VpIsInf(x)) { + if (is_negative(vexp)) { + if (BIGDECIMAL_NEGATIVE_P(x)) { + if (is_integer(vexp)) { + if (is_even(vexp)) { + /* (-Infinity) ** (-even_integer) -> +0 */ + return VpCheckGetValue(NewZeroWrapLimited(1, n)); + } + else { + /* (-Infinity) ** (-odd_integer) -> -0 */ + return VpCheckGetValue(NewZeroWrapLimited(-1, n)); + } + } + else { + /* (-Infinity) ** (-non_integer) -> -0 */ + return VpCheckGetValue(NewZeroWrapLimited(-1, n)); + } + } + else { + return VpCheckGetValue(NewZeroWrapLimited(1, n)); + } + } + else { + y = NewZeroWrapLimited(1, n); + if (BIGDECIMAL_NEGATIVE_P(x)) { + if (is_integer(vexp)) { + if (is_even(vexp)) { + VpSetPosInf(y); + } + else { + VpSetNegInf(y); + } + } + else { + /* TODO: support complex */ + rb_raise(rb_eMathDomainError, + "a non-integral exponent for a negative base"); + } + } + else { + VpSetPosInf(y); + } + return VpCheckGetValue(y); + } + } + + if (exp != NULL) { + return bigdecimal_power_by_bigdecimal(x, exp, n); + } + else if (RB_TYPE_P(vexp, T_BIGNUM)) { + VALUE abs_value = BigDecimal_abs(self); + if (is_one(abs_value)) { + return VpCheckGetValue(NewOneWrapLimited(1, n)); + } + else if (RTEST(rb_funcall(abs_value, '<', 1, INT2FIX(1)))) { + if (is_negative(vexp)) { + y = NewZeroWrapLimited(1, n); + VpSetInf(y, (is_even(vexp) ? 1 : -1) * VpGetSign(x)); + return VpCheckGetValue(y); + } + else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) { + return VpCheckGetValue(NewZeroWrapLimited(-1, n)); + } + else { + return VpCheckGetValue(NewZeroWrapLimited(1, n)); + } + } + else { + if (is_positive(vexp)) { + y = NewZeroWrapLimited(1, n); + VpSetInf(y, (is_even(vexp) ? 1 : -1) * VpGetSign(x)); + return VpCheckGetValue(y); + } + else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) { + return VpCheckGetValue(NewZeroWrapLimited(-1, n)); + } + else { + return VpCheckGetValue(NewZeroWrapLimited(1, n)); + } + } + } + + int_exp = FIX2LONG(vexp); + ma = int_exp; + if (ma < 0) ma = -ma; + if (ma == 0) ma = 1; + + if (VpIsDef(x)) { + mp = x->Prec * (VpBaseFig() + 1); + GUARD_OBJ(y, NewZeroWrapLimited(1, mp * (ma + 1))); + } + else { + GUARD_OBJ(y, NewZeroWrapLimited(1, 1)); + } + VpPowerByInt(y, x, int_exp); + if (!NIL_P(prec) && VpIsDef(y)) { + VpMidRound(y, VpGetRoundMode(), n); + } + return VpCheckGetValue(y); +} + +/* call-seq: + * self ** other -> bigdecimal + * + * Returns the \BigDecimal value of +self+ raised to power +other+: + * + * b = BigDecimal('3.14') + * b ** 2 # => 0.98596e1 + * b ** 2.0 # => 0.98596e1 + * b ** Rational(2, 1) # => 0.98596e1 + * + * Related: BigDecimal#power. + * + */ +static VALUE +BigDecimal_power_op(VALUE self, VALUE exp) +{ + return BigDecimal_power(1, &exp, self); +} + +/* :nodoc: + * + * private method for dup and clone the provided BigDecimal +other+ + */ +static VALUE +BigDecimal_initialize_copy(VALUE self, VALUE other) +{ + Real *pv = rb_check_typeddata(self, &BigDecimal_data_type); + Real *x = rb_check_typeddata(other, &BigDecimal_data_type); + + if (self != other) { + DATA_PTR(self) = VpCopy(pv, x); + } + return self; +} + +/* :nodoc: */ +static VALUE +BigDecimal_clone(VALUE self) +{ + return self; +} + +#ifdef HAVE_RB_OPTS_EXCEPTION_P +int rb_opts_exception_p(VALUE opts, int default_value); +#define opts_exception_p(opts) rb_opts_exception_p((opts), 1) +#else +static int +opts_exception_p(VALUE opts) +{ + static ID kwds[1]; + VALUE exception; + if (!kwds[0]) { + kwds[0] = rb_intern_const("exception"); + } + if (!rb_get_kwargs(opts, kwds, 0, 1, &exception)) return 1; + switch (exception) { + case Qtrue: case Qfalse: + break; + default: + rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE, + exception); + } + return exception != Qfalse; +} +#endif + +static VALUE +check_exception(VALUE bd) +{ + assert(is_kind_of_BigDecimal(bd)); + + Real *vp; + TypedData_Get_Struct(bd, Real, &BigDecimal_data_type, vp); + VpCheckGetValue(vp); /* VpCheckGetValue performs exception check */ + + return bd; +} + +static VALUE +rb_uint64_convert_to_BigDecimal(uint64_t uval, RB_UNUSED_VAR(size_t digs), int raise_exception) +{ + VALUE obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0); + + Real *vp; + if (uval == 0) { + vp = rbd_allocate_struct(1); + vp->MaxPrec = 1; + vp->Prec = 1; + vp->exponent = 1; + VpSetZero(vp, 1); + vp->frac[0] = 0; + } + else if (uval < BASE) { + vp = rbd_allocate_struct(1); + vp->MaxPrec = 1; + vp->Prec = 1; + vp->exponent = 1; + VpSetSign(vp, 1); + vp->frac[0] = (DECDIG)uval; + } + else { + DECDIG buf[BIGDECIMAL_INT64_MAX_LENGTH] = {0,}; + DECDIG r = uval % BASE; + size_t len = 0, ntz = 0; + if (r == 0) { + // Count and skip trailing zeros + for (; r == 0 && uval > 0; ++ntz) { + uval /= BASE; + r = uval % BASE; + } + } + for (; uval > 0; ++len) { + // Store digits + buf[BIGDECIMAL_INT64_MAX_LENGTH - len - 1] = r; + uval /= BASE; + r = uval % BASE; + } + + const size_t exp = len + ntz; + vp = rbd_allocate_struct(len); + vp->MaxPrec = len; + vp->Prec = len; + vp->exponent = exp; + VpSetSign(vp, 1); + MEMCPY(vp->frac, buf + BIGDECIMAL_INT64_MAX_LENGTH - len, DECDIG, len); + } + + return BigDecimal_wrap_struct(obj, vp); +} + +static VALUE +rb_int64_convert_to_BigDecimal(int64_t ival, size_t digs, int raise_exception) +{ + const uint64_t uval = (ival < 0) ? (((uint64_t)-(ival+1))+1) : (uint64_t)ival; + VALUE bd = rb_uint64_convert_to_BigDecimal(uval, digs, raise_exception); + if (ival < 0) { + Real *vp; + TypedData_Get_Struct(bd, Real, &BigDecimal_data_type, vp); + VpSetSign(vp, -1); + } + return bd; +} + +static VALUE +rb_big_convert_to_BigDecimal(VALUE val, RB_UNUSED_VAR(size_t digs), int raise_exception) +{ + assert(RB_TYPE_P(val, T_BIGNUM)); + + int leading_zeros; + size_t size = rb_absint_size(val, &leading_zeros); + int sign = FIX2INT(rb_big_cmp(val, INT2FIX(0))); + if (sign < 0 && leading_zeros == 0) { + size += 1; + } + if (size <= sizeof(long)) { + if (sign < 0) { + return rb_int64_convert_to_BigDecimal(NUM2LONG(val), digs, raise_exception); + } + else { + return rb_uint64_convert_to_BigDecimal(NUM2ULONG(val), digs, raise_exception); + } + } +#if defined(SIZEOF_LONG_LONG) && SIZEOF_LONG < SIZEOF_LONG_LONG + else if (size <= sizeof(LONG_LONG)) { + if (sign < 0) { + return rb_int64_convert_to_BigDecimal(NUM2LL(val), digs, raise_exception); + } + else { + return rb_uint64_convert_to_BigDecimal(NUM2ULL(val), digs, raise_exception); + } + } +#endif + else { + VALUE str = rb_big2str(val, 10); + Real *vp = VpCreateRbObject(RSTRING_LEN(str) + BASE_FIG + 1, + RSTRING_PTR(str), true); + RB_GC_GUARD(str); + return check_exception(vp->obj); + } +} + +static VALUE +rb_inum_convert_to_BigDecimal(VALUE val, RB_UNUSED_VAR(size_t digs), int raise_exception) +{ + assert(RB_INTEGER_TYPE_P(val)); + if (FIXNUM_P(val)) { + return rb_int64_convert_to_BigDecimal(FIX2LONG(val), digs, raise_exception); + } + else { + return rb_big_convert_to_BigDecimal(val, digs, raise_exception); + } +} + +static VALUE +rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) +{ + assert(RB_FLOAT_TYPE_P(val)); + + double d = RFLOAT_VALUE(val); + + if (isnan(d)) { + VALUE obj = BigDecimal_nan(); + return check_exception(obj); + } + else if (isinf(d)) { + VALUE obj; + if (d > 0) { + obj = BigDecimal_positive_infinity(); + } + else { + obj = BigDecimal_negative_infinity(); + } + return check_exception(obj); + } + else if (d == 0.0) { + if (1/d < 0.0) { + return BigDecimal_negative_zero(); + } + else { + return BigDecimal_positive_zero(); + } + } + + if (digs == SIZE_MAX) { + if (!raise_exception) + return Qnil; + rb_raise(rb_eArgError, + "can't omit precision for a %"PRIsVALUE".", + CLASS_OF(val)); + } + else if (digs > BIGDECIMAL_DOUBLE_FIGURES) { + if (!raise_exception) + return Qnil; + rb_raise(rb_eArgError, "precision too large."); + } + + /* Use the same logic in flo_to_s to convert a float to a decimal string */ + char buf[BIGDECIMAL_DOUBLE_FIGURES + BASE_FIG + 2 + 1]; /* sizeof(buf) == 28 in the typical case */ + int decpt, negative_p; + char *e; + const int mode = digs == 0 ? 0 : 2; + char *p = BigDecimal_dtoa(d, mode, (int)digs, &decpt, &negative_p, &e); + int len10 = (int)(e - p); + if (len10 > BIGDECIMAL_DOUBLE_FIGURES) { + /* TODO: Presumably, rounding should be done here. */ + len10 = BIGDECIMAL_DOUBLE_FIGURES; + } + memcpy(buf, p, len10); + xfree(p); + + VALUE inum; + size_t RB_UNUSED_VAR(prec) = 0; + SIGNED_VALUE exp = 0; + if (decpt > 0) { + if (decpt < len10) { + /* + * len10 |---------------| + * : |-------| frac_len10 = len10 - decpt + * decpt |-------| |--| ntz10 = BASE_FIG - frac_len10 % BASE_FIG + * : : : + * 00 dd dddd.dddd dd 00 + * prec |-----.----.----.-----| prec = exp + roomof(frac_len, BASE_FIG) + * exp |-----.----| exp = roomof(decpt, BASE_FIG) + */ + const size_t frac_len10 = len10 - decpt; + const size_t ntz10 = BASE_FIG - frac_len10 % BASE_FIG; + memset(buf + len10, '0', ntz10); + buf[len10 + ntz10] = '\0'; + inum = rb_cstr_to_inum(buf, 10, false); + + exp = roomof(decpt, BASE_FIG); + prec = exp + roomof(frac_len10, BASE_FIG); + } + else { + /* + * decpt |-----------------------| + * len10 |----------| : + * : |------------| exp10 + * : : : + * 00 dd dddd dd 00 0000 0000.0 + * : : : : + * : |--| ntz10 = exp10 % BASE_FIG + * prec |-----.----.-----| : + * : |----.----| exp10 / BASE_FIG + * exp |-----.----.-----.----.----| + */ + const size_t exp10 = decpt - len10; + const size_t ntz10 = exp10 % BASE_FIG; + + memset(buf + len10, '0', ntz10); + buf[len10 + ntz10] = '\0'; + inum = rb_cstr_to_inum(buf, 10, false); + + prec = roomof(len10 + ntz10, BASE_FIG); + exp = prec + exp10 / BASE_FIG; + } + } + else if (decpt == 0) { + /* + * len10 |------------| + * : : + * 0.dddd dddd dd 00 + * : : : + * : |--| ntz10 = prec * BASE_FIG - len10 + * prec |----.----.-----| roomof(len10, BASE_FIG) + */ + prec = roomof(len10, BASE_FIG); + const size_t ntz10 = prec * BASE_FIG - len10; + + memset(buf + len10, '0', ntz10); + buf[len10 + ntz10] = '\0'; + inum = rb_cstr_to_inum(buf, 10, false); + } + else { + /* + * len10 |---------------| + * : : + * decpt |-------| |--| ntz10 = prec * BASE_FIG - nlz10 - len10 + * : : : + * 0.0000 00 dd dddd dddd dd 00 + * : : : + * nlz10 |--| : decpt % BASE_FIG + * prec |-----.----.----.-----| roomof(decpt + len10, BASE_FIG) - exp + * exp |----| decpt / BASE_FIG + */ + decpt = -decpt; + + const size_t nlz10 = decpt % BASE_FIG; + exp = decpt / BASE_FIG; + prec = roomof(decpt + len10, BASE_FIG) - exp; + const size_t ntz10 = prec * BASE_FIG - nlz10 - len10; + + if (nlz10 > 0) { + memmove(buf + nlz10, buf, len10); + memset(buf, '0', nlz10); + } + memset(buf + nlz10 + len10, '0', ntz10); + buf[nlz10 + len10 + ntz10] = '\0'; + inum = rb_cstr_to_inum(buf, 10, false); + + exp = -exp; + } + + VALUE bd = rb_inum_convert_to_BigDecimal(inum, SIZE_MAX, raise_exception); + Real *vp; + TypedData_Get_Struct(bd, Real, &BigDecimal_data_type, vp); + assert(vp->Prec == prec); + vp->exponent = exp; + + if (negative_p) VpSetSign(vp, -1); + return bd; +} + +static VALUE +rb_rational_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) +{ + assert(RB_TYPE_P(val, T_RATIONAL)); + + if (digs == SIZE_MAX) { + if (!raise_exception) + return Qnil; + rb_raise(rb_eArgError, + "can't omit precision for a %"PRIsVALUE".", + CLASS_OF(val)); + } + + VALUE num = rb_inum_convert_to_BigDecimal(rb_rational_num(val), 0, raise_exception); + VALUE d = BigDecimal_div2(num, rb_rational_den(val), SIZET2NUM(digs)); + return d; +} + +static VALUE +rb_cstr_convert_to_BigDecimal(const char *c_str, size_t digs, int raise_exception) +{ + if (digs == SIZE_MAX) + digs = 0; + + Real *vp = VpCreateRbObject(digs, c_str, raise_exception); + if (!vp) + return Qnil; + return VpCheckGetValue(vp); +} + +static inline VALUE +rb_str_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) +{ + const char *c_str = StringValueCStr(val); + return rb_cstr_convert_to_BigDecimal(c_str, digs, raise_exception); +} + +static VALUE +rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) +{ + switch (val) { + case Qnil: + case Qtrue: + case Qfalse: + if (raise_exception) { + const char *cname = NIL_P(val) ? "nil" : + val == Qtrue ? "true" : + val == Qfalse ? "false" : + NULL; + rb_raise(rb_eTypeError, + "can't convert %s into BigDecimal", cname); + } + return Qnil; + + default: + break; + } + + if (is_kind_of_BigDecimal(val)) { + if (digs == SIZE_MAX) + return check_exception(val); + + Real *vp; + TypedData_Get_Struct(val, Real, &BigDecimal_data_type, vp); + + VALUE copy = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0); + vp = VpCopy(NULL, vp); + /* TODO: rounding */ + BigDecimal_wrap_struct(copy, vp); + return VpCheckGetValue(vp); + } + else if (RB_INTEGER_TYPE_P(val)) { + return rb_inum_convert_to_BigDecimal(val, digs, raise_exception); + } + else if (RB_FLOAT_TYPE_P(val)) { + return rb_float_convert_to_BigDecimal(val, digs, raise_exception); + } + else if (RB_TYPE_P(val, T_RATIONAL)) { + return rb_rational_convert_to_BigDecimal(val, digs, raise_exception); + } + else if (RB_TYPE_P(val, T_COMPLEX)) { + VALUE im = rb_complex_imag(val); + if (!is_zero(im)) { + /* TODO: handle raise_exception */ + rb_raise(rb_eArgError, + "Unable to make a BigDecimal from non-zero imaginary number"); + } + return rb_convert_to_BigDecimal(rb_complex_real(val), digs, raise_exception); + } + else if (RB_TYPE_P(val, T_STRING)) { + return rb_str_convert_to_BigDecimal(val, digs, raise_exception); + } + + /* TODO: chheck to_d */ + /* TODO: chheck to_int */ + + VALUE str = rb_check_convert_type(val, T_STRING, "String", "to_str"); + if (!RB_TYPE_P(str, T_STRING)) { + if (raise_exception) { + rb_raise(rb_eTypeError, + "can't convert %"PRIsVALUE" into BigDecimal", rb_obj_class(val)); + } + return Qnil; + } + return rb_str_convert_to_BigDecimal(str, digs, raise_exception); +} + +/* call-seq: + * BigDecimal(value, exception: true) -> bigdecimal + * BigDecimal(value, ndigits, exception: true) -> bigdecimal + * + * Returns the \BigDecimal converted from +value+ + * with a precision of +ndigits+ decimal digits. + * + * When +ndigits+ is less than the number of significant digits + * in the value, the result is rounded to that number of digits, + * according to the current rounding mode; see BigDecimal.mode. + * + * When +ndigits+ is 0, the number of digits to correctly represent a float number + * is determined automatically. + * + * Returns +value+ converted to a \BigDecimal, depending on the type of +value+: + * + * - Integer, Float, Rational, Complex, or BigDecimal: converted directly: + * + * # Integer, Complex, or BigDecimal value does not require ndigits; ignored if given. + * BigDecimal(2) # => 0.2e1 + * BigDecimal(Complex(2, 0)) # => 0.2e1 + * BigDecimal(BigDecimal(2)) # => 0.2e1 + * # Float or Rational value requires ndigits. + * BigDecimal(2.0, 0) # => 0.2e1 + * BigDecimal(Rational(2, 1), 0) # => 0.2e1 + * + * - String: converted by parsing if it contains an integer or floating-point literal; + * leading and trailing whitespace is ignored: + * + * # String does not require ndigits; ignored if given. + * BigDecimal('2') # => 0.2e1 + * BigDecimal('2.0') # => 0.2e1 + * BigDecimal('0.2e1') # => 0.2e1 + * BigDecimal(' 2.0 ') # => 0.2e1 + * + * - Other type that responds to method :to_str: + * first converted to a string, then converted to a \BigDecimal, as above. + * + * - Other type: + * + * - Raises an exception if keyword argument +exception+ is +true+. + * - Returns +nil+ if keyword argument +exception+ is +false+. + * + * Raises an exception if +value+ evaluates to a Float + * and +digits+ is larger than Float::DIG + 1. + * + */ +static VALUE +f_BigDecimal(int argc, VALUE *argv, VALUE self) +{ + VALUE val, digs_v, opts = Qnil; + argc = rb_scan_args(argc, argv, "11:", &val, &digs_v, &opts); + int exception = opts_exception_p(opts); + + size_t digs = SIZE_MAX; /* this means digs is omitted */ + if (argc > 1) { + digs_v = rb_to_int(digs_v); + if (FIXNUM_P(digs_v)) { + long n = FIX2LONG(digs_v); + if (n < 0) + goto negative_digs; + digs = (size_t)n; + } + else { + if (RBIGNUM_NEGATIVE_P(digs_v)) { + negative_digs: + if (!exception) + return Qnil; + rb_raise(rb_eArgError, "negative precision"); + } + digs = NUM2SIZET(digs_v); + } + } + + return rb_convert_to_BigDecimal(val, digs, exception); +} + +/* call-seq: + * BigDecimal.interpret_loosely(string) -> bigdecimal + * + * Returns the +BigDecimal+ converted loosely from +string+. + */ + +static VALUE +BigDecimal_s_interpret_loosely(VALUE klass, VALUE str) +{ + char const *c_str = StringValueCStr(str); + Real *vp = VpNewRbClass(0, c_str, klass, false, true); + if (!vp) + return Qnil; + else + return VpCheckGetValue(vp); +} + + /* call-seq: + * BigDecimal.limit(digits) + * + * Limit the number of significant digits in newly created BigDecimal + * numbers to the specified value. Rounding is performed as necessary, + * as specified by BigDecimal.mode. + * + * A limit of 0, the default, means no upper limit. + * + * The limit specified by this method takes less priority over any limit + * specified to instance methods such as ceil, floor, truncate, or round. + */ +static VALUE +BigDecimal_limit(int argc, VALUE *argv, VALUE self) +{ + VALUE nFig; + VALUE nCur = SIZET2NUM(VpGetPrecLimit()); + + if (rb_scan_args(argc, argv, "01", &nFig) == 1) { + int nf; + if (NIL_P(nFig)) return nCur; + nf = NUM2INT(nFig); + if (nf < 0) { + rb_raise(rb_eArgError, "argument must be positive"); + } + VpSetPrecLimit(nf); + } + return nCur; +} + +/* Returns the sign of the value. + * + * Returns a positive value if > 0, a negative value if < 0. + * It behaves the same with zeros - + * it returns a positive value for a positive zero (BigDecimal('0')) and + * a negative value for a negative zero (BigDecimal('-0')). + * + * The specific value returned indicates the type and sign of the BigDecimal, + * as follows: + * + * BigDecimal::SIGN_NaN:: value is Not a Number + * BigDecimal::SIGN_POSITIVE_ZERO:: value is +0 + * BigDecimal::SIGN_NEGATIVE_ZERO:: value is -0 + * BigDecimal::SIGN_POSITIVE_INFINITE:: value is +Infinity + * BigDecimal::SIGN_NEGATIVE_INFINITE:: value is -Infinity + * BigDecimal::SIGN_POSITIVE_FINITE:: value is positive + * BigDecimal::SIGN_NEGATIVE_FINITE:: value is negative + */ +static VALUE +BigDecimal_sign(VALUE self) +{ /* sign */ + int s = GetVpValue(self, 1)->sign; + return INT2FIX(s); +} + +/* + * call-seq: BigDecimal.save_exception_mode { ... } + * + * Execute the provided block, but preserve the exception mode + * + * BigDecimal.save_exception_mode do + * BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) + * BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) + * + * BigDecimal(BigDecimal('Infinity')) + * BigDecimal(BigDecimal('-Infinity')) + * BigDecimal(BigDecimal('NaN')) + * end + * + * For use with the BigDecimal::EXCEPTION_* + * + * See BigDecimal.mode + */ +static VALUE +BigDecimal_save_exception_mode(VALUE self) +{ + unsigned short const exception_mode = VpGetException(); + int state; + VALUE ret = rb_protect(rb_yield, Qnil, &state); + VpSetException(exception_mode); + if (state) rb_jump_tag(state); + return ret; +} + +/* + * call-seq: BigDecimal.save_rounding_mode { ... } + * + * Execute the provided block, but preserve the rounding mode + * + * BigDecimal.save_rounding_mode do + * BigDecimal.mode(BigDecimal::ROUND_MODE, :up) + * puts BigDecimal.mode(BigDecimal::ROUND_MODE) + * end + * + * For use with the BigDecimal::ROUND_* + * + * See BigDecimal.mode + */ +static VALUE +BigDecimal_save_rounding_mode(VALUE self) +{ + unsigned short const round_mode = VpGetRoundMode(); + int state; + VALUE ret = rb_protect(rb_yield, Qnil, &state); + VpSetRoundMode(round_mode); + if (state) rb_jump_tag(state); + return ret; +} + +/* + * call-seq: BigDecimal.save_limit { ... } + * + * Execute the provided block, but preserve the precision limit + * + * BigDecimal.limit(100) + * puts BigDecimal.limit + * BigDecimal.save_limit do + * BigDecimal.limit(200) + * puts BigDecimal.limit + * end + * puts BigDecimal.limit + * + */ +static VALUE +BigDecimal_save_limit(VALUE self) +{ + size_t const limit = VpGetPrecLimit(); + int state; + VALUE ret = rb_protect(rb_yield, Qnil, &state); + VpSetPrecLimit(limit); + if (state) rb_jump_tag(state); + return ret; +} + +/* call-seq: + * BigMath.exp(decimal, numeric) -> BigDecimal + * + * Computes the value of e (the base of natural logarithms) raised to the + * power of +decimal+, to the specified number of digits of precision. + * + * If +decimal+ is infinity, returns Infinity. + * + * If +decimal+ is NaN, returns NaN. + */ +static VALUE +BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec) +{ + ssize_t prec, n, i; + Real* vx = NULL; + VALUE one, d, y; + int negative = 0; + int infinite = 0; + int nan = 0; + double flo; + + prec = NUM2SSIZET(vprec); + if (prec <= 0) { + rb_raise(rb_eArgError, "Zero or negative precision for exp"); + } + + /* TODO: the following switch statement is almost same as one in the + * BigDecimalCmp function. */ + switch (TYPE(x)) { + case T_DATA: + if (!is_kind_of_BigDecimal(x)) break; + vx = DATA_PTR(x); + negative = BIGDECIMAL_NEGATIVE_P(vx); + infinite = VpIsPosInf(vx) || VpIsNegInf(vx); + nan = VpIsNaN(vx); + break; + + case T_FIXNUM: + /* fall through */ + case T_BIGNUM: + vx = GetVpValue(x, 0); + break; + + case T_FLOAT: + flo = RFLOAT_VALUE(x); + negative = flo < 0; + infinite = isinf(flo); + nan = isnan(flo); + if (!infinite && !nan) { + vx = GetVpValueWithPrec(x, 0, 0); + } + break; + + case T_RATIONAL: + vx = GetVpValueWithPrec(x, prec, 0); + break; + + default: + break; + } + if (infinite) { + if (negative) { + return VpCheckGetValue(GetVpValueWithPrec(INT2FIX(0), prec, 1)); + } + else { + Real* vy = NewZeroWrapNolimit(1, prec); + VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE); + RB_GC_GUARD(vy->obj); + return VpCheckGetValue(vy); + } + } + else if (nan) { + Real* vy = NewZeroWrapNolimit(1, prec); + VpSetNaN(vy); + RB_GC_GUARD(vy->obj); + return VpCheckGetValue(vy); + } + else if (vx == NULL) { + cannot_be_coerced_into_BigDecimal(rb_eArgError, x); + } + x = vx->obj; + + n = prec + BIGDECIMAL_DOUBLE_FIGURES; + negative = BIGDECIMAL_NEGATIVE_P(vx); + if (negative) { + VALUE x_zero = INT2NUM(1); + VALUE x_copy = f_BigDecimal(1, &x_zero, klass); + x = BigDecimal_initialize_copy(x_copy, x); + vx = DATA_PTR(x); + VpSetSign(vx, 1); + } + + one = VpCheckGetValue(NewOneWrapLimited(1, 1)); + y = one; + d = y; + i = 1; + + while (!VpIsZero((Real*)DATA_PTR(d))) { + SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y)); + SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d)); + ssize_t m = n - vabs(ey - ed); + + rb_thread_check_ints(); + + if (m <= 0) { + break; + } + else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) { + m = BIGDECIMAL_DOUBLE_FIGURES; + } + + d = BigDecimal_mult(d, x); /* d <- d * x */ + d = BigDecimal_div2(d, SSIZET2NUM(i), SSIZET2NUM(m)); /* d <- d / i */ + y = BigDecimal_add(y, d); /* y <- y + d */ + ++i; /* i <- i + 1 */ + } + + if (negative) { + return BigDecimal_div2(one, y, vprec); + } + else { + vprec = SSIZET2NUM(prec - VpExponent10(DATA_PTR(y))); + return BigDecimal_round(1, &vprec, y); + } + + RB_GC_GUARD(one); + RB_GC_GUARD(x); + RB_GC_GUARD(y); + RB_GC_GUARD(d); +} + +/* call-seq: + * BigMath.log(decimal, numeric) -> BigDecimal + * + * Computes the natural logarithm of +decimal+ to the specified number of + * digits of precision, +numeric+. + * + * If +decimal+ is zero or negative, raises Math::DomainError. + * + * If +decimal+ is positive infinity, returns Infinity. + * + * If +decimal+ is NaN, returns NaN. + */ +static VALUE +BigMath_s_log(VALUE klass, VALUE x, VALUE vprec) +{ + ssize_t prec, n, i; + SIGNED_VALUE expo; + Real* vx = NULL; + VALUE vn, one, two, w, x2, y, d; + int zero = 0; + int negative = 0; + int infinite = 0; + int nan = 0; + double flo; + long fix; + + if (!is_integer(vprec)) { + rb_raise(rb_eArgError, "precision must be an Integer"); + } + + prec = NUM2SSIZET(vprec); + if (prec <= 0) { + rb_raise(rb_eArgError, "Zero or negative precision for exp"); + } + + /* TODO: the following switch statement is almost same as one in the + * BigDecimalCmp function. */ + switch (TYPE(x)) { + case T_DATA: + if (!is_kind_of_BigDecimal(x)) break; + vx = DATA_PTR(x); + zero = VpIsZero(vx); + negative = BIGDECIMAL_NEGATIVE_P(vx); + infinite = VpIsPosInf(vx) || VpIsNegInf(vx); + nan = VpIsNaN(vx); + break; + + case T_FIXNUM: + fix = FIX2LONG(x); + zero = fix == 0; + negative = fix < 0; + goto get_vp_value; + + case T_BIGNUM: + i = FIX2INT(rb_big_cmp(x, INT2FIX(0))); + zero = i == 0; + negative = i < 0; +get_vp_value: + if (zero || negative) break; + vx = GetVpValue(x, 0); + break; + + case T_FLOAT: + flo = RFLOAT_VALUE(x); + zero = flo == 0; + negative = flo < 0; + infinite = isinf(flo); + nan = isnan(flo); + if (!zero && !negative && !infinite && !nan) { + vx = GetVpValueWithPrec(x, 0, 1); + } + break; + + case T_RATIONAL: + zero = RRATIONAL_ZERO_P(x); + negative = RRATIONAL_NEGATIVE_P(x); + if (zero || negative) break; + vx = GetVpValueWithPrec(x, prec, 1); + break; + + case T_COMPLEX: + rb_raise(rb_eMathDomainError, + "Complex argument for BigMath.log"); + + default: + break; + } + if (infinite && !negative) { + Real *vy = NewZeroWrapNolimit(1, prec); + RB_GC_GUARD(vy->obj); + VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE); + return VpCheckGetValue(vy); + } + else if (nan) { + Real* vy = NewZeroWrapNolimit(1, prec); + RB_GC_GUARD(vy->obj); + VpSetNaN(vy); + return VpCheckGetValue(vy); + } + else if (zero || negative) { + rb_raise(rb_eMathDomainError, + "Zero or negative argument for log"); + } + else if (vx == NULL) { + cannot_be_coerced_into_BigDecimal(rb_eArgError, x); + } + x = VpCheckGetValue(vx); + + one = VpCheckGetValue(NewOneWrapLimited(1, 1)); + two = VpCheckGetValue(VpCreateRbObject(1, "2", true)); + + n = prec + BIGDECIMAL_DOUBLE_FIGURES; + vn = SSIZET2NUM(n); + expo = VpExponent10(vx); + if (expo < 0 || expo >= 3) { + char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4]; + snprintf(buf, sizeof(buf), "1E%"PRIdVALUE, -expo); + x = BigDecimal_mult2(x, VpCheckGetValue(VpCreateRbObject(1, buf, true)), vn); + } + else { + expo = 0; + } + w = BigDecimal_sub(x, one); + x = BigDecimal_div2(w, BigDecimal_add(x, one), vn); + x2 = BigDecimal_mult2(x, x, vn); + y = x; + d = y; + i = 1; + while (!VpIsZero((Real*)DATA_PTR(d))) { + SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y)); + SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d)); + ssize_t m = n - vabs(ey - ed); + if (m <= 0) { + break; + } + else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) { + m = BIGDECIMAL_DOUBLE_FIGURES; + } + + x = BigDecimal_mult2(x2, x, vn); + i += 2; + d = BigDecimal_div2(x, SSIZET2NUM(i), SSIZET2NUM(m)); + y = BigDecimal_add(y, d); + } + + y = BigDecimal_mult(y, two); + if (expo != 0) { + VALUE log10, vexpo, dy; + log10 = BigMath_s_log(klass, INT2FIX(10), vprec); + vexpo = VpCheckGetValue(GetVpValue(SSIZET2NUM(expo), 1)); + dy = BigDecimal_mult(log10, vexpo); + y = BigDecimal_add(y, dy); + } + + RB_GC_GUARD(one); + RB_GC_GUARD(two); + RB_GC_GUARD(vn); + RB_GC_GUARD(x2); + RB_GC_GUARD(y); + RB_GC_GUARD(d); + + return y; +} + +static VALUE BIGDECIMAL_NAN = Qnil; + +static VALUE +BigDecimal_nan(void) +{ + return BIGDECIMAL_NAN; +} + +static VALUE BIGDECIMAL_POSITIVE_INFINITY = Qnil; + +static VALUE +BigDecimal_positive_infinity(void) +{ + return BIGDECIMAL_POSITIVE_INFINITY; +} + +static VALUE BIGDECIMAL_NEGATIVE_INFINITY = Qnil; + +static VALUE +BigDecimal_negative_infinity(void) +{ + return BIGDECIMAL_NEGATIVE_INFINITY; +} + +static VALUE BIGDECIMAL_POSITIVE_ZERO = Qnil; + +static VALUE +BigDecimal_positive_zero(void) +{ + return BIGDECIMAL_POSITIVE_ZERO; +} + +static VALUE BIGDECIMAL_NEGATIVE_ZERO = Qnil; + +static VALUE +BigDecimal_negative_zero(void) +{ + return BIGDECIMAL_NEGATIVE_ZERO; +} + +static inline VALUE +BigDecimal_literal(const char *str) +{ + VALUE arg = rb_str_new_cstr(str); + VALUE val = f_BigDecimal(1, &arg, rb_cBigDecimal); + rb_gc_register_mark_object(val); + return val; +} + +#define BIGDECIMAL_LITERAL(var, val) (BIGDECIMAL_ ## var = BigDecimal_literal(#val)) + +/* Document-class: BigDecimal + * BigDecimal provides arbitrary-precision floating point decimal arithmetic. + * + * == Introduction + * + * Ruby provides built-in support for arbitrary precision integer arithmetic. + * + * For example: + * + * 42**13 #=> 1265437718438866624512 + * + * BigDecimal provides similar support for very large or very accurate floating + * point numbers. + * + * Decimal arithmetic is also useful for general calculation, because it + * provides the correct answers people expect--whereas normal binary floating + * point arithmetic often introduces subtle errors because of the conversion + * between base 10 and base 2. + * + * For example, try: + * + * sum = 0 + * 10_000.times do + * sum = sum + 0.0001 + * end + * print sum #=> 0.9999999999999062 + * + * and contrast with the output from: + * + * require 'bigdecimal' + * + * sum = BigDecimal("0") + * 10_000.times do + * sum = sum + BigDecimal("0.0001") + * end + * print sum #=> 0.1E1 + * + * Similarly: + * + * (BigDecimal("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true + * + * (1.2 - 1.0) == 0.2 #=> false + * + * == A Note About Precision + * + * For a calculation using a \BigDecimal and another +value+, + * the precision of the result depends on the type of +value+: + * + * - If +value+ is a \Float, + * the precision is Float::DIG + 1. + * - If +value+ is a \Rational, the precision is larger than Float::DIG + 1. + * - If +value+ is a \BigDecimal, the precision is +value+'s precision in the + * internal representation, which is platform-dependent. + * - If +value+ is other object, the precision is determined by the result of +BigDecimal(value)+. + * + * == Special features of accurate decimal arithmetic + * + * Because BigDecimal is more accurate than normal binary floating point + * arithmetic, it requires some special values. + * + * === Infinity + * + * BigDecimal sometimes needs to return infinity, for example if you divide + * a value by zero. + * + * BigDecimal("1.0") / BigDecimal("0.0") #=> Infinity + * BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity + * + * You can represent infinite numbers to BigDecimal using the strings + * 'Infinity', '+Infinity' and + * '-Infinity' (case-sensitive) + * + * === Not a Number + * + * When a computation results in an undefined value, the special value +NaN+ + * (for 'not a number') is returned. + * + * Example: + * + * BigDecimal("0.0") / BigDecimal("0.0") #=> NaN + * + * You can also create undefined values. + * + * NaN is never considered to be the same as any other value, even NaN itself: + * + * n = BigDecimal('NaN') + * n == 0.0 #=> false + * n == n #=> false + * + * === Positive and negative zero + * + * If a computation results in a value which is too small to be represented as + * a BigDecimal within the currently specified limits of precision, zero must + * be returned. + * + * If the value which is too small to be represented is negative, a BigDecimal + * value of negative zero is returned. + * + * BigDecimal("1.0") / BigDecimal("-Infinity") #=> -0.0 + * + * If the value is positive, a value of positive zero is returned. + * + * BigDecimal("1.0") / BigDecimal("Infinity") #=> 0.0 + * + * (See BigDecimal.mode for how to specify limits of precision.) + * + * Note that +-0.0+ and +0.0+ are considered to be the same for the purposes of + * comparison. + * + * Note also that in mathematics, there is no particular concept of negative + * or positive zero; true mathematical zero has no sign. + * + * == bigdecimal/util + * + * When you require +bigdecimal/util+, the #to_d method will be + * available on BigDecimal and the native Integer, Float, Rational, + * and String classes: + * + * require 'bigdecimal/util' + * + * 42.to_d # => 0.42e2 + * 0.5.to_d # => 0.5e0 + * (2/3r).to_d(3) # => 0.667e0 + * "0.5".to_d # => 0.5e0 + * + * == Methods for Working with \JSON + * + * - {::json_create}[https://docs.ruby-lang.org/en/master/BigDecimal.html#method-c-json_create]: + * Returns a new \BigDecimal object constructed from the given object. + * - {#as_json}[https://docs.ruby-lang.org/en/master/BigDecimal.html#method-i-as_json]: + * Returns a 2-element hash representing +self+. + * - {#to_json}[https://docs.ruby-lang.org/en/master/BigDecimal.html#method-i-to_json]: + * Returns a \JSON string representing +self+. + * + * These methods are provided by the {JSON gem}[https://github.com/flori/json]. To make these methods available: + * + * require 'json/add/bigdecimal' + * + * * == License + * + * Copyright (C) 2002 by Shigeo Kobayashi . + * + * BigDecimal is released under the Ruby and 2-clause BSD licenses. + * See LICENSE.txt for details. + * + * Maintained by mrkn and ruby-core members. + * + * Documented by zzak , mathew , and + * many other contributors. + */ +void +Init_bigdecimal(void) +{ +#ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); +#endif + + id_BigDecimal_exception_mode = rb_intern_const("BigDecimal.exception_mode"); + id_BigDecimal_rounding_mode = rb_intern_const("BigDecimal.rounding_mode"); + id_BigDecimal_precision_limit = rb_intern_const("BigDecimal.precision_limit"); + + /* Initialize VP routines */ + VpInit(0UL); + + /* Class and method registration */ + rb_cBigDecimal = rb_define_class("BigDecimal", rb_cNumeric); + + /* Global function */ + rb_define_global_function("BigDecimal", f_BigDecimal, -1); + + /* Class methods */ + rb_undef_alloc_func(rb_cBigDecimal); + rb_undef_method(CLASS_OF(rb_cBigDecimal), "new"); + rb_define_singleton_method(rb_cBigDecimal, "interpret_loosely", BigDecimal_s_interpret_loosely, 1); + rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1); + rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1); + rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0); + rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1); + + rb_define_singleton_method(rb_cBigDecimal, "save_exception_mode", BigDecimal_save_exception_mode, 0); + rb_define_singleton_method(rb_cBigDecimal, "save_rounding_mode", BigDecimal_save_rounding_mode, 0); + rb_define_singleton_method(rb_cBigDecimal, "save_limit", BigDecimal_save_limit, 0); + + /* Constants definition */ + + /* + * The version of bigdecimal library + */ + rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(BIGDECIMAL_VERSION)); + + /* + * Base value used in internal calculations. On a 32 bit system, BASE + * is 10000, indicating that calculation is done in groups of 4 digits. + * (If it were larger, BASE**2 wouldn't fit in 32 bits, so you couldn't + * guarantee that two groups could always be multiplied together without + * overflow.) + */ + rb_define_const(rb_cBigDecimal, "BASE", INT2FIX((SIGNED_VALUE)VpBaseVal())); + + /* Exceptions */ + + /* + * 0xff: Determines whether overflow, underflow or zero divide result in + * an exception being thrown. See BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "EXCEPTION_ALL", INT2FIX(VP_EXCEPTION_ALL)); + + /* + * 0x02: Determines what happens when the result of a computation is not a + * number (NaN). See BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "EXCEPTION_NaN", INT2FIX(VP_EXCEPTION_NaN)); + + /* + * 0x01: Determines what happens when the result of a computation is + * infinity. See BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "EXCEPTION_INFINITY", INT2FIX(VP_EXCEPTION_INFINITY)); + + /* + * 0x04: Determines what happens when the result of a computation is an + * underflow (a result too small to be represented). See BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "EXCEPTION_UNDERFLOW", INT2FIX(VP_EXCEPTION_UNDERFLOW)); + + /* + * 0x01: Determines what happens when the result of a computation is an + * overflow (a result too large to be represented). See BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "EXCEPTION_OVERFLOW", INT2FIX(VP_EXCEPTION_OVERFLOW)); + + /* + * 0x10: Determines what happens when a division by zero is performed. + * See BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "EXCEPTION_ZERODIVIDE", INT2FIX(VP_EXCEPTION_ZERODIVIDE)); + + /* + * 0x100: Determines what happens when a result must be rounded in order to + * fit in the appropriate number of significant digits. See + * BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "ROUND_MODE", INT2FIX(VP_ROUND_MODE)); + + /* 1: Indicates that values should be rounded away from zero. See + * BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "ROUND_UP", INT2FIX(VP_ROUND_UP)); + + /* 2: Indicates that values should be rounded towards zero. See + * BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "ROUND_DOWN", INT2FIX(VP_ROUND_DOWN)); + + /* 3: Indicates that digits >= 5 should be rounded up, others rounded down. + * See BigDecimal.mode. */ + rb_define_const(rb_cBigDecimal, "ROUND_HALF_UP", INT2FIX(VP_ROUND_HALF_UP)); + + /* 4: Indicates that digits >= 6 should be rounded up, others rounded down. + * See BigDecimal.mode. + */ + rb_define_const(rb_cBigDecimal, "ROUND_HALF_DOWN", INT2FIX(VP_ROUND_HALF_DOWN)); + /* 5: Round towards +Infinity. See BigDecimal.mode. */ + rb_define_const(rb_cBigDecimal, "ROUND_CEILING", INT2FIX(VP_ROUND_CEIL)); + + /* 6: Round towards -Infinity. See BigDecimal.mode. */ + rb_define_const(rb_cBigDecimal, "ROUND_FLOOR", INT2FIX(VP_ROUND_FLOOR)); + + /* 7: Round towards the even neighbor. See BigDecimal.mode. */ + rb_define_const(rb_cBigDecimal, "ROUND_HALF_EVEN", INT2FIX(VP_ROUND_HALF_EVEN)); + + /* 0: Indicates that a value is not a number. See BigDecimal.sign. */ + rb_define_const(rb_cBigDecimal, "SIGN_NaN", INT2FIX(VP_SIGN_NaN)); + + /* 1: Indicates that a value is +0. See BigDecimal.sign. */ + rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_ZERO", INT2FIX(VP_SIGN_POSITIVE_ZERO)); + + /* -1: Indicates that a value is -0. See BigDecimal.sign. */ + rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_ZERO", INT2FIX(VP_SIGN_NEGATIVE_ZERO)); + + /* 2: Indicates that a value is positive and finite. See BigDecimal.sign. */ + rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_FINITE", INT2FIX(VP_SIGN_POSITIVE_FINITE)); + + /* -2: Indicates that a value is negative and finite. See BigDecimal.sign. */ + rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_FINITE", INT2FIX(VP_SIGN_NEGATIVE_FINITE)); + + /* 3: Indicates that a value is positive and infinite. See BigDecimal.sign. */ + rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_INFINITE", INT2FIX(VP_SIGN_POSITIVE_INFINITE)); + + /* -3: Indicates that a value is negative and infinite. See BigDecimal.sign. */ + rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE", INT2FIX(VP_SIGN_NEGATIVE_INFINITE)); + + /* Positive zero value. */ + BIGDECIMAL_LITERAL(POSITIVE_ZERO, +0); + + /* Negative zero value. */ + BIGDECIMAL_LITERAL(NEGATIVE_ZERO, -0); + + /* Positive infinity[rdoc-ref:BigDecimal@Infinity] value. */ + rb_define_const(rb_cBigDecimal, "INFINITY", BIGDECIMAL_LITERAL(POSITIVE_INFINITY, +Infinity)); + + /* Negative infinity value. */ + BIGDECIMAL_LITERAL(NEGATIVE_INFINITY, -Infinity); + + /* '{Not a Number}[rdoc-ref:BigDecimal@Not+a+Number]' value. */ + rb_define_const(rb_cBigDecimal, "NAN", BIGDECIMAL_LITERAL(NAN, NaN)); + + /* instance methods */ + rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0); + rb_define_method(rb_cBigDecimal, "precision", BigDecimal_precision, 0); + rb_define_method(rb_cBigDecimal, "scale", BigDecimal_scale, 0); + rb_define_method(rb_cBigDecimal, "precision_scale", BigDecimal_precision_scale, 0); + rb_define_method(rb_cBigDecimal, "n_significant_digits", BigDecimal_n_significant_digits, 0); + + rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2); + rb_define_method(rb_cBigDecimal, "sub", BigDecimal_sub2, 2); + rb_define_method(rb_cBigDecimal, "mult", BigDecimal_mult2, 2); + rb_define_method(rb_cBigDecimal, "div", BigDecimal_div3, -1); + rb_define_method(rb_cBigDecimal, "hash", BigDecimal_hash, 0); + rb_define_method(rb_cBigDecimal, "to_s", BigDecimal_to_s, -1); + rb_define_method(rb_cBigDecimal, "to_i", BigDecimal_to_i, 0); + rb_define_method(rb_cBigDecimal, "to_int", BigDecimal_to_i, 0); + rb_define_method(rb_cBigDecimal, "to_r", BigDecimal_to_r, 0); + rb_define_method(rb_cBigDecimal, "split", BigDecimal_split, 0); + rb_define_method(rb_cBigDecimal, "+", BigDecimal_add, 1); + rb_define_method(rb_cBigDecimal, "-", BigDecimal_sub, 1); + rb_define_method(rb_cBigDecimal, "+@", BigDecimal_uplus, 0); + rb_define_method(rb_cBigDecimal, "-@", BigDecimal_neg, 0); + rb_define_method(rb_cBigDecimal, "*", BigDecimal_mult, 1); + rb_define_method(rb_cBigDecimal, "/", BigDecimal_div, 1); + rb_define_method(rb_cBigDecimal, "quo", BigDecimal_quo, -1); + rb_define_method(rb_cBigDecimal, "%", BigDecimal_mod, 1); + rb_define_method(rb_cBigDecimal, "modulo", BigDecimal_mod, 1); + rb_define_method(rb_cBigDecimal, "remainder", BigDecimal_remainder, 1); + rb_define_method(rb_cBigDecimal, "divmod", BigDecimal_divmod, 1); + rb_define_method(rb_cBigDecimal, "clone", BigDecimal_clone, 0); + rb_define_method(rb_cBigDecimal, "dup", BigDecimal_clone, 0); + rb_define_method(rb_cBigDecimal, "to_f", BigDecimal_to_f, 0); + rb_define_method(rb_cBigDecimal, "abs", BigDecimal_abs, 0); + rb_define_method(rb_cBigDecimal, "sqrt", BigDecimal_sqrt, 1); + rb_define_method(rb_cBigDecimal, "fix", BigDecimal_fix, 0); + rb_define_method(rb_cBigDecimal, "round", BigDecimal_round, -1); + rb_define_method(rb_cBigDecimal, "frac", BigDecimal_frac, 0); + rb_define_method(rb_cBigDecimal, "floor", BigDecimal_floor, -1); + rb_define_method(rb_cBigDecimal, "ceil", BigDecimal_ceil, -1); + rb_define_method(rb_cBigDecimal, "power", BigDecimal_power, -1); + rb_define_method(rb_cBigDecimal, "**", BigDecimal_power_op, 1); + rb_define_method(rb_cBigDecimal, "<=>", BigDecimal_comp, 1); + rb_define_method(rb_cBigDecimal, "==", BigDecimal_eq, 1); + rb_define_method(rb_cBigDecimal, "===", BigDecimal_eq, 1); + rb_define_method(rb_cBigDecimal, "eql?", BigDecimal_eq, 1); + rb_define_method(rb_cBigDecimal, "<", BigDecimal_lt, 1); + rb_define_method(rb_cBigDecimal, "<=", BigDecimal_le, 1); + rb_define_method(rb_cBigDecimal, ">", BigDecimal_gt, 1); + rb_define_method(rb_cBigDecimal, ">=", BigDecimal_ge, 1); + rb_define_method(rb_cBigDecimal, "zero?", BigDecimal_zero, 0); + rb_define_method(rb_cBigDecimal, "nonzero?", BigDecimal_nonzero, 0); + rb_define_method(rb_cBigDecimal, "coerce", BigDecimal_coerce, 1); + rb_define_method(rb_cBigDecimal, "inspect", BigDecimal_inspect, 0); + rb_define_method(rb_cBigDecimal, "exponent", BigDecimal_exponent, 0); + rb_define_method(rb_cBigDecimal, "sign", BigDecimal_sign, 0); + rb_define_method(rb_cBigDecimal, "nan?", BigDecimal_IsNaN, 0); + rb_define_method(rb_cBigDecimal, "infinite?", BigDecimal_IsInfinite, 0); + rb_define_method(rb_cBigDecimal, "finite?", BigDecimal_IsFinite, 0); + rb_define_method(rb_cBigDecimal, "truncate", BigDecimal_truncate, -1); + rb_define_method(rb_cBigDecimal, "_dump", BigDecimal_dump, -1); + + rb_mBigMath = rb_define_module("BigMath"); + rb_define_singleton_method(rb_mBigMath, "exp", BigMath_s_exp, 2); + rb_define_singleton_method(rb_mBigMath, "log", BigMath_s_log, 2); + +#define ROUNDING_MODE(i, name, value) \ + id_##name = rb_intern_const(#name); \ + rbd_rounding_modes[i].id = id_##name; \ + rbd_rounding_modes[i].mode = value; + + ROUNDING_MODE(0, up, RBD_ROUND_UP); + ROUNDING_MODE(1, down, RBD_ROUND_DOWN); + ROUNDING_MODE(2, half_up, RBD_ROUND_HALF_UP); + ROUNDING_MODE(3, half_down, RBD_ROUND_HALF_DOWN); + ROUNDING_MODE(4, ceil, RBD_ROUND_CEIL); + ROUNDING_MODE(5, floor, RBD_ROUND_FLOOR); + ROUNDING_MODE(6, half_even, RBD_ROUND_HALF_EVEN); + + ROUNDING_MODE(7, default, RBD_ROUND_DEFAULT); + ROUNDING_MODE(8, truncate, RBD_ROUND_TRUNCATE); + ROUNDING_MODE(9, banker, RBD_ROUND_BANKER); + ROUNDING_MODE(10, ceiling, RBD_ROUND_CEILING); + +#undef ROUNDING_MODE + + id_to_r = rb_intern_const("to_r"); + id_eq = rb_intern_const("=="); + id_half = rb_intern_const("half"); + + (void)VPrint; /* suppress unused warning */ +} + +/* + * + * ============================================================================ + * + * vp_ routines begin from here. + * + * ============================================================================ + * + */ +#ifdef BIGDECIMAL_DEBUG +static int gfDebug = 1; /* Debug switch */ +#if 0 +static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */ +#endif +#endif /* BIGDECIMAL_DEBUG */ + +static Real *VpConstOne; /* constant 1.0 */ +static Real *VpConstPt5; /* constant 0.5 */ +#define maxnr 100UL /* Maximum iterations for calculating sqrt. */ + /* used in VpSqrt() */ + +/* ETC */ +#define MemCmp(x,y,z) memcmp(x,y,z) +#define StrCmp(x,y) strcmp(x,y) + +enum op_sw { + OP_SW_ADD = 1, /* + */ + OP_SW_SUB, /* - */ + OP_SW_MULT, /* * */ + OP_SW_DIV /* / */ +}; + +static int VpIsDefOP(Real *c, Real *a, Real *b, enum op_sw sw); +static int AddExponent(Real *a, SIGNED_VALUE n); +static DECDIG VpAddAbs(Real *a,Real *b,Real *c); +static DECDIG VpSubAbs(Real *a,Real *b,Real *c); +static size_t VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, DECDIG *av, DECDIG *bv); +static int VpNmlz(Real *a); +static void VpFormatSt(char *psz, size_t fFmt); +static int VpRdup(Real *m, size_t ind_m); + +#ifdef BIGDECIMAL_DEBUG +# ifdef HAVE_RB_EXT_RACTOR_SAFE +# error Need to make rewiting gnAlloc atomic +# endif +static int gnAlloc = 0; /* Memory allocation counter */ +#endif /* BIGDECIMAL_DEBUG */ + +/* + * EXCEPTION Handling. + */ + +#define bigdecimal_set_thread_local_exception_mode(mode) \ + rb_thread_local_aset( \ + rb_thread_current(), \ + id_BigDecimal_exception_mode, \ + INT2FIX((int)(mode)) \ + ) + +static unsigned short +VpGetException (void) +{ + VALUE const vmode = rb_thread_local_aref( + rb_thread_current(), + id_BigDecimal_exception_mode + ); + + if (NIL_P(vmode)) { + bigdecimal_set_thread_local_exception_mode(BIGDECIMAL_EXCEPTION_MODE_DEFAULT); + return BIGDECIMAL_EXCEPTION_MODE_DEFAULT; + } + + return NUM2USHORT(vmode); +} + +static void +VpSetException(unsigned short f) +{ + bigdecimal_set_thread_local_exception_mode(f); +} + +static void +VpCheckException(Real *p, bool always) +{ + if (VpIsNaN(p)) { + VpException(VP_EXCEPTION_NaN, "Computation results in 'NaN' (Not a Number)", always); + } + else if (VpIsPosInf(p)) { + VpException(VP_EXCEPTION_INFINITY, "Computation results in 'Infinity'", always); + } + else if (VpIsNegInf(p)) { + VpException(VP_EXCEPTION_INFINITY, "Computation results in '-Infinity'", always); + } +} + +static VALUE +VpCheckGetValue(Real *p) +{ + VpCheckException(p, false); + return p->obj; +} + +/* + * Precision limit. + */ + +#define bigdecimal_set_thread_local_precision_limit(limit) \ + rb_thread_local_aset( \ + rb_thread_current(), \ + id_BigDecimal_precision_limit, \ + SIZET2NUM(limit) \ + ) +#define BIGDECIMAL_PRECISION_LIMIT_DEFAULT ((size_t)0) + +/* These 2 functions added at v1.1.7 */ +VP_EXPORT size_t +VpGetPrecLimit(void) +{ + VALUE const vlimit = rb_thread_local_aref( + rb_thread_current(), + id_BigDecimal_precision_limit + ); + + if (NIL_P(vlimit)) { + bigdecimal_set_thread_local_precision_limit(BIGDECIMAL_PRECISION_LIMIT_DEFAULT); + return BIGDECIMAL_PRECISION_LIMIT_DEFAULT; + } + + return NUM2SIZET(vlimit); +} + +VP_EXPORT size_t +VpSetPrecLimit(size_t n) +{ + size_t const s = VpGetPrecLimit(); + bigdecimal_set_thread_local_precision_limit(n); + return s; +} + +/* + * Rounding mode. + */ + +#define bigdecimal_set_thread_local_rounding_mode(mode) \ + rb_thread_local_aset( \ + rb_thread_current(), \ + id_BigDecimal_rounding_mode, \ + INT2FIX((int)(mode)) \ + ) + +VP_EXPORT unsigned short +VpGetRoundMode(void) +{ + VALUE const vmode = rb_thread_local_aref( + rb_thread_current(), + id_BigDecimal_rounding_mode + ); + + if (NIL_P(vmode)) { + bigdecimal_set_thread_local_rounding_mode(BIGDECIMAL_ROUNDING_MODE_DEFAULT); + return BIGDECIMAL_ROUNDING_MODE_DEFAULT; + } + + return NUM2USHORT(vmode); +} + +VP_EXPORT int +VpIsRoundMode(unsigned short n) +{ + switch (n) { + case VP_ROUND_UP: + case VP_ROUND_DOWN: + case VP_ROUND_HALF_UP: + case VP_ROUND_HALF_DOWN: + case VP_ROUND_CEIL: + case VP_ROUND_FLOOR: + case VP_ROUND_HALF_EVEN: + return 1; + + default: + return 0; + } +} + +VP_EXPORT unsigned short +VpSetRoundMode(unsigned short n) +{ + if (VpIsRoundMode(n)) { + bigdecimal_set_thread_local_rounding_mode(n); + return n; + } + + return VpGetRoundMode(); +} + +/* + * 0.0 & 1.0 generator + * These gZero_..... and gOne_..... can be any name + * referenced from nowhere except Zero() and One(). + * gZero_..... and gOne_..... must have global scope + * (to let the compiler know they may be changed in outside + * (... but not actually..)). + */ +volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0; + +static double +One(void) +{ + return gOne_ABCED9B4_CE73__00400511F31D; +} + +/* + ---------------------------------------------------------------- + Value of sign in Real structure is reserved for future use. + short sign; + ==0 : NaN + 1 : Positive zero + -1 : Negative zero + 2 : Positive number + -2 : Negative number + 3 : Positive infinite number + -3 : Negative infinite number + ---------------------------------------------------------------- +*/ + +VP_EXPORT double +VpGetDoubleNaN(void) /* Returns the value of NaN */ +{ + return nan(""); +} + +VP_EXPORT double +VpGetDoublePosInf(void) /* Returns the value of +Infinity */ +{ + return HUGE_VAL; +} + +VP_EXPORT double +VpGetDoubleNegInf(void) /* Returns the value of -Infinity */ +{ + return -HUGE_VAL; +} + +VP_EXPORT double +VpGetDoubleNegZero(void) /* Returns the value of -0 */ +{ + static double nzero = 1000.0; + if (nzero != 0.0) nzero = (One()/VpGetDoubleNegInf()); + return nzero; +} + +#if 0 /* unused */ +VP_EXPORT int +VpIsNegDoubleZero(double v) +{ + double z = VpGetDoubleNegZero(); + return MemCmp(&v,&z,sizeof(v))==0; +} +#endif + +VP_EXPORT int +VpException(unsigned short f, const char *str,int always) +{ + unsigned short const exception_mode = VpGetException(); + + if (f == VP_EXCEPTION_OP) always = 1; + + if (always || (exception_mode & f)) { + switch(f) { + /* case VP_EXCEPTION_OVERFLOW: */ + case VP_EXCEPTION_ZERODIVIDE: + case VP_EXCEPTION_INFINITY: + case VP_EXCEPTION_NaN: + case VP_EXCEPTION_UNDERFLOW: + case VP_EXCEPTION_OP: + rb_raise(rb_eFloatDomainError, "%s", str); + break; + default: + rb_fatal("%s", str); + } + } + return 0; /* 0 Means VpException() raised no exception */ +} + +/* Throw exception or returns 0,when resulting c is Inf or NaN */ +/* sw=1:+ 2:- 3:* 4:/ */ +static int +VpIsDefOP(Real *c, Real *a, Real *b, enum op_sw sw) +{ + if (VpIsNaN(a) || VpIsNaN(b)) { + /* at least a or b is NaN */ + VpSetNaN(c); + goto NaN; + } + + if (VpIsInf(a)) { + if (VpIsInf(b)) { + switch(sw) { + case OP_SW_ADD: /* + */ + if (VpGetSign(a) == VpGetSign(b)) { + VpSetInf(c, VpGetSign(a)); + goto Inf; + } + else { + VpSetNaN(c); + goto NaN; + } + case OP_SW_SUB: /* - */ + if (VpGetSign(a) != VpGetSign(b)) { + VpSetInf(c, VpGetSign(a)); + goto Inf; + } + else { + VpSetNaN(c); + goto NaN; + } + case OP_SW_MULT: /* * */ + VpSetInf(c, VpGetSign(a)*VpGetSign(b)); + goto Inf; + case OP_SW_DIV: /* / */ + VpSetNaN(c); + goto NaN; + } + VpSetNaN(c); + goto NaN; + } + /* Inf op Finite */ + switch(sw) { + case OP_SW_ADD: /* + */ + case OP_SW_SUB: /* - */ + VpSetInf(c, VpGetSign(a)); + break; + case OP_SW_MULT: /* * */ + if (VpIsZero(b)) { + VpSetNaN(c); + goto NaN; + } + VpSetInf(c, VpGetSign(a)*VpGetSign(b)); + break; + case OP_SW_DIV: /* / */ + VpSetInf(c, VpGetSign(a)*VpGetSign(b)); + } + goto Inf; + } + + if (VpIsInf(b)) { + switch(sw) { + case OP_SW_ADD: /* + */ + VpSetInf(c, VpGetSign(b)); + break; + case OP_SW_SUB: /* - */ + VpSetInf(c, -VpGetSign(b)); + break; + case OP_SW_MULT: /* * */ + if (VpIsZero(a)) { + VpSetNaN(c); + goto NaN; + } + VpSetInf(c, VpGetSign(a)*VpGetSign(b)); + break; + case OP_SW_DIV: /* / */ + VpSetZero(c, VpGetSign(a)*VpGetSign(b)); + } + goto Inf; + } + return 1; /* Results OK */ + +Inf: + if (VpIsPosInf(c)) { + return VpException(VP_EXCEPTION_INFINITY, "Computation results to 'Infinity'", 0); + } + else { + return VpException(VP_EXCEPTION_INFINITY, "Computation results to '-Infinity'", 0); + } + +NaN: + return VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'", 0); +} + +/* + ---------------------------------------------------------------- +*/ + +/* + * returns number of chars needed to represent vp in specified format. + */ +VP_EXPORT size_t +VpNumOfChars(Real *vp,const char *pszFmt) +{ + SIGNED_VALUE ex; + size_t nc; + + if (vp == NULL) return BASE_FIG*2+6; + if (!VpIsDef(vp)) return 32; /* not sure,may be OK */ + + switch(*pszFmt) { + case 'F': + nc = BASE_FIG*(vp->Prec + 1)+2; + ex = vp->exponent; + if (ex < 0) { + nc += BASE_FIG*(size_t)(-ex); + } + else { + if ((size_t)ex > vp->Prec) { + nc += BASE_FIG*((size_t)ex - vp->Prec); + } + } + break; + case 'E': + /* fall through */ + default: + nc = BASE_FIG*(vp->Prec + 2)+6; /* 3: sign + exponent chars */ + } + return nc; +} + +/* + * Initializer for Vp routines and constants used. + * [Input] + * BaseVal: Base value(assigned to BASE) for Vp calculation. + * It must be the form BaseVal=10**n.(n=1,2,3,...) + * If Base <= 0L,then the BASE will be calculated so + * that BASE is as large as possible satisfying the + * relation MaxVal <= BASE*(BASE+1). Where the value + * MaxVal is the largest value which can be represented + * by one DECDIG word in the computer used. + * + * [Returns] + * BIGDECIMAL_DOUBLE_FIGURES ... OK + */ +VP_EXPORT size_t +VpInit(DECDIG BaseVal) +{ + /* Setup +/- Inf NaN -0 */ + VpGetDoubleNegZero(); + + /* Const 1.0 */ + VpConstOne = NewOneNolimit(1, 1); + + /* Const 0.5 */ + VpConstPt5 = NewOneNolimit(1, 1); + VpConstPt5->exponent = 0; + VpConstPt5->frac[0] = 5*BASE1; + +#ifdef BIGDECIMAL_DEBUG + gnAlloc = 0; +#endif /* BIGDECIMAL_DEBUG */ + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + printf("VpInit: BaseVal = %"PRIuDECDIG"\n", BaseVal); + printf("\tBASE = %"PRIuDECDIG"\n", BASE); + printf("\tHALF_BASE = %"PRIuDECDIG"\n", HALF_BASE); + printf("\tBASE1 = %"PRIuDECDIG"\n", BASE1); + printf("\tBASE_FIG = %u\n", BASE_FIG); + printf("\tBIGDECIMAL_DOUBLE_FIGURES = %d\n", BIGDECIMAL_DOUBLE_FIGURES); + } +#endif /* BIGDECIMAL_DEBUG */ + + return BIGDECIMAL_DOUBLE_FIGURES; +} + +VP_EXPORT Real * +VpOne(void) +{ + return VpConstOne; +} + +/* If exponent overflows,then raise exception or returns 0 */ +static int +AddExponent(Real *a, SIGNED_VALUE n) +{ + SIGNED_VALUE e = a->exponent; + SIGNED_VALUE m = e+n; + SIGNED_VALUE eb, mb; + if (e > 0) { + if (n > 0) { + if (MUL_OVERFLOW_SIGNED_VALUE_P(m, (SIGNED_VALUE)BASE_FIG) || + MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG)) + goto overflow; + mb = m*(SIGNED_VALUE)BASE_FIG; + eb = e*(SIGNED_VALUE)BASE_FIG; + if (eb - mb > 0) goto overflow; + } + } + else if (n < 0) { + if (MUL_OVERFLOW_SIGNED_VALUE_P(m, (SIGNED_VALUE)BASE_FIG) || + MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG)) + goto underflow; + mb = m*(SIGNED_VALUE)BASE_FIG; + eb = e*(SIGNED_VALUE)BASE_FIG; + if (mb - eb > 0) goto underflow; + } + a->exponent = m; + return 1; + +/* Overflow/Underflow ==> Raise exception or returns 0 */ +underflow: + VpSetZero(a, VpGetSign(a)); + return VpException(VP_EXCEPTION_UNDERFLOW, "Exponent underflow", 0); + +overflow: + VpSetInf(a, VpGetSign(a)); + return VpException(VP_EXCEPTION_OVERFLOW, "Exponent overflow", 0); +} + +Real * +bigdecimal_parse_special_string(const char *str) +{ + static const struct { + const char *str; + size_t len; + int sign; + } table[] = { + { SZ_INF, sizeof(SZ_INF) - 1, VP_SIGN_POSITIVE_INFINITE }, + { SZ_PINF, sizeof(SZ_PINF) - 1, VP_SIGN_POSITIVE_INFINITE }, + { SZ_NINF, sizeof(SZ_NINF) - 1, VP_SIGN_NEGATIVE_INFINITE }, + { SZ_NaN, sizeof(SZ_NaN) - 1, VP_SIGN_NaN } + }; + static const size_t table_length = sizeof(table) / sizeof(table[0]); + size_t i; + + for (i = 0; i < table_length; ++i) { + const char *p; + if (strncmp(str, table[i].str, table[i].len) != 0) { + continue; + } + + p = str + table[i].len; + while (*p && ISSPACE(*p)) ++p; + if (*p == '\0') { + Real *vp = rbd_allocate_struct(1); + vp->MaxPrec = 1; + switch (table[i].sign) { + default: + UNREACHABLE; break; + case VP_SIGN_POSITIVE_INFINITE: + VpSetPosInf(vp); + return vp; + case VP_SIGN_NEGATIVE_INFINITE: + VpSetNegInf(vp); + return vp; + case VP_SIGN_NaN: + VpSetNaN(vp); + return vp; + } + } + } + + return NULL; +} + +struct VpCtoV_args { + Real *a; + const char *int_chr; + size_t ni; + const char *frac; + size_t nf; + const char *exp_chr; + size_t ne; +}; + +static VALUE +call_VpCtoV(VALUE arg) +{ + struct VpCtoV_args *x = (struct VpCtoV_args *)arg; + return (VALUE)VpCtoV(x->a, x->int_chr, x->ni, x->frac, x->nf, x->exp_chr, x->ne); +} + +static int +protected_VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne, int free_on_error) +{ + struct VpCtoV_args args; + int state = 0; + + args.a = a; + args.int_chr = int_chr; + args.ni = ni; + args.frac = frac; + args.nf = nf; + args.exp_chr = exp_chr; + args.ne = ne; + + VALUE result = rb_protect(call_VpCtoV, (VALUE)&args, &state); + if (state) { + if (free_on_error) { + rbd_free_struct(a); + } + rb_jump_tag(state); + } + + return (int)result; +} + +/* + * Allocates variable. + * [Input] + * mx ... The number of decimal digits to be allocated, if zero then mx is determined by szVal. + * The mx will be the number of significant digits can to be stored. + * szVal ... The value assigned(char). If szVal==NULL, then zero is assumed. + * If szVal[0]=='#' then MaxPrec is not affected by the precision limit + * so that the full precision specified by szVal is allocated. + * + * [Returns] + * Pointer to the newly allocated variable, or + * NULL be returned if memory allocation is failed,or any error. + */ +VP_EXPORT Real * +VpAlloc(size_t mx, const char *szVal, int strict_p, int exc) +{ + const char *orig_szVal = szVal; + size_t i, j, ni, ipf, nf, ipe, ne, dot_seen, exp_seen, nalloc; + size_t len; + char v, *psz; + int sign=1; + Real *vp = NULL; + VALUE buf; + + if (szVal == NULL) { + return_zero: + /* necessary to be able to store */ + /* at least mx digits. */ + /* szVal==NULL ==> allocate zero value. */ + vp = rbd_allocate_struct(mx); + vp->MaxPrec = rbd_calculate_internal_digits(mx, false); /* Must false */ + VpSetZero(vp, 1); /* initialize vp to zero. */ + return vp; + } + + /* Skipping leading spaces */ + while (ISSPACE(*szVal)) szVal++; + + /* Check on Inf & NaN */ + if ((vp = bigdecimal_parse_special_string(szVal)) != NULL) { + return vp; + } + + /* Processing the leading one `#` */ + if (*szVal != '#') { + len = rbd_calculate_internal_digits(mx, true); + } + else { + len = rbd_calculate_internal_digits(mx, false); + ++szVal; + } + + /* Scanning digits */ + + /* A buffer for keeping scanned digits */ + buf = rb_str_tmp_new(strlen(szVal) + 1); + psz = RSTRING_PTR(buf); + + /* cursor: i for psz, and j for szVal */ + i = j = 0; + + /* Scanning: sign part */ + v = psz[i] = szVal[j]; + if ((v == '-') || (v == '+')) { + sign = -(v == '-'); + ++i; + ++j; + } + + /* Scanning: integer part */ + ni = 0; /* number of digits in the integer part */ + while ((v = psz[i] = szVal[j]) != '\0') { + if (!strict_p && ISSPACE(v)) { + v = psz[i] = '\0'; + break; + } + if (v == '_') { + if (ni > 0) { + v = szVal[j+1]; + if (v == '\0' || ISSPACE(v) || ISDIGIT(v)) { + ++j; + continue; + } + if (!strict_p) { + v = psz[i] = '\0'; + break; + } + } + goto invalid_value; + } + if (!ISDIGIT(v)) { + break; + } + ++ni; + ++i; + ++j; + } + + /* Scanning: fractional part */ + nf = 0; /* number of digits in the fractional part */ + ne = 0; /* number of digits in the exponential part */ + ipf = 0; /* index of the beginning of the fractional part */ + ipe = 0; /* index of the beginning of the exponential part */ + dot_seen = 0; + exp_seen = 0; + + if (v != '\0') { + /* Scanning fractional part */ + if ((psz[i] = szVal[j]) == '.') { + dot_seen = 1; + ++i; + ++j; + ipf = i; + while ((v = psz[i] = szVal[j]) != '\0') { + if (!strict_p && ISSPACE(v)) { + v = psz[i] = '\0'; + break; + } + if (v == '_') { + if (nf > 0 && ISDIGIT(szVal[j+1])) { + ++j; + continue; + } + if (!strict_p) { + v = psz[i] = '\0'; + if (nf == 0) { + dot_seen = 0; + } + break; + } + goto invalid_value; + } + if (!ISDIGIT(v)) break; + ++i; + ++j; + ++nf; + } + } + + /* Scanning exponential part */ + if (v != '\0') { + switch ((psz[i] = szVal[j])) { + case '\0': + break; + case 'e': case 'E': + case 'd': case 'D': + exp_seen = 1; + ++i; + ++j; + ipe = i; + v = psz[i] = szVal[j]; + if ((v == '-') || (v == '+')) { + ++i; + ++j; + } + while ((v = psz[i] = szVal[j]) != '\0') { + if (!strict_p && ISSPACE(v)) { + v = psz[i] = '\0'; + break; + } + if (v == '_') { + if (ne > 0 && ISDIGIT(szVal[j+1])) { + ++j; + continue; + } + if (!strict_p) { + v = psz[i] = '\0'; + if (ne == 0) { + exp_seen = 0; + } + break; + } + goto invalid_value; + } + if (!ISDIGIT(v)) break; + ++i; + ++j; + ++ne; + } + break; + default: + break; + } + } + + if (v != '\0') { + /* Scanning trailing spaces */ + while (ISSPACE(szVal[j])) ++j; + + /* Invalid character */ + if (szVal[j] && strict_p) { + goto invalid_value; + } + } + } + + psz[i] = '\0'; + + if (strict_p && (((ni == 0 || dot_seen) && nf == 0) || (exp_seen && ne == 0))) { + VALUE str; + invalid_value: + if (!strict_p) { + goto return_zero; + } + if (!exc) { + return NULL; + } + str = rb_str_new2(orig_szVal); + rb_raise(rb_eArgError, "invalid value for BigDecimal(): \"%"PRIsVALUE"\"", str); + } + + nalloc = (ni + nf + BASE_FIG - 1) / BASE_FIG + 1; /* set effective allocation */ + /* units for szVal[] */ + if (len == 0) len = 1; + nalloc = Max(nalloc, len); + len = nalloc; + vp = rbd_allocate_struct(len); + vp->MaxPrec = len; /* set max precision */ + VpSetZero(vp, sign); + protected_VpCtoV(vp, psz, ni, psz + ipf, nf, psz + ipe, ne, true); + rb_str_resize(buf, 0); + return vp; +} + +/* + * Assignment(c=a). + * [Input] + * a ... RHSV + * isw ... switch for assignment. + * c = a when isw > 0 + * c = -a when isw < 0 + * if c->MaxPrec < a->Prec,then round operation + * will be performed. + * [Output] + * c ... LHSV + */ +VP_EXPORT size_t +VpAsgn(Real *c, Real *a, int isw) +{ + size_t n; + if (VpIsNaN(a)) { + VpSetNaN(c); + return 0; + } + if (VpIsInf(a)) { + VpSetInf(c, isw * VpGetSign(a)); + return 0; + } + + /* check if the RHS is zero */ + if (!VpIsZero(a)) { + c->exponent = a->exponent; /* store exponent */ + VpSetSign(c, isw * VpGetSign(a)); /* set sign */ + n = (a->Prec < c->MaxPrec) ? (a->Prec) : (c->MaxPrec); + c->Prec = n; + memcpy(c->frac, a->frac, n * sizeof(DECDIG)); + /* Needs round ? */ + if (isw != 10) { + /* Not in ActiveRound */ + if(c->Prec < a->Prec) { + VpInternalRound(c, n, (n>0) ? a->frac[n-1] : 0, a->frac[n]); + } + else { + VpLimitRound(c,0); + } + } + } + else { + /* The value of 'a' is zero. */ + VpSetZero(c, isw * VpGetSign(a)); + return 1; + } + return c->Prec * BASE_FIG; +} + +/* + * c = a + b when operation = 1 or 2 + * c = a - b when operation = -1 or -2. + * Returns number of significant digits of c + */ +VP_EXPORT size_t +VpAddSub(Real *c, Real *a, Real *b, int operation) +{ + short sw, isw; + Real *a_ptr, *b_ptr; + size_t n, na, nb, i; + DECDIG mrv; + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpAddSub(enter) a=% \n", a); + VPrint(stdout, " b=% \n", b); + printf(" operation=%d\n", operation); + } +#endif /* BIGDECIMAL_DEBUG */ + + if (!VpIsDefOP(c, a, b, (operation > 0) ? OP_SW_ADD : OP_SW_SUB)) return 0; /* No significant digits */ + + /* check if a or b is zero */ + if (VpIsZero(a)) { + /* a is zero,then assign b to c */ + if (!VpIsZero(b)) { + VpAsgn(c, b, operation); + } + else { + /* Both a and b are zero. */ + if (VpGetSign(a) < 0 && operation * VpGetSign(b) < 0) { + /* -0 -0 */ + VpSetZero(c, -1); + } + else { + VpSetZero(c, 1); + } + return 1; /* 0: 1 significant digits */ + } + return c->Prec * BASE_FIG; + } + if (VpIsZero(b)) { + /* b is zero,then assign a to c. */ + VpAsgn(c, a, 1); + return c->Prec*BASE_FIG; + } + + if (operation < 0) sw = -1; + else sw = 1; + + /* compare absolute value. As a result,|a_ptr|>=|b_ptr| */ + if (a->exponent > b->exponent) { + a_ptr = a; + b_ptr = b; + } /* |a|>|b| */ + else if (a->exponent < b->exponent) { + a_ptr = b; + b_ptr = a; + } /* |a|<|b| */ + else { + /* Exponent part of a and b is the same,then compare fraction */ + /* part */ + na = a->Prec; + nb = b->Prec; + n = Min(na, nb); + for (i=0; i < n; ++i) { + if (a->frac[i] > b->frac[i]) { + a_ptr = a; + b_ptr = b; + goto end_if; + } + else if (a->frac[i] < b->frac[i]) { + a_ptr = b; + b_ptr = a; + goto end_if; + } + } + if (na > nb) { + a_ptr = a; + b_ptr = b; + goto end_if; + } + else if (na < nb) { + a_ptr = b; + b_ptr = a; + goto end_if; + } + /* |a| == |b| */ + if (VpGetSign(a) + sw *VpGetSign(b) == 0) { + VpSetZero(c, 1); /* abs(a)=abs(b) and operation = '-' */ + return c->Prec * BASE_FIG; + } + a_ptr = a; + b_ptr = b; + } + +end_if: + isw = VpGetSign(a) + sw *VpGetSign(b); + /* + * isw = 0 ...( 1)+(-1),( 1)-( 1),(-1)+(1),(-1)-(-1) + * = 2 ...( 1)+( 1),( 1)-(-1) + * =-2 ...(-1)+(-1),(-1)-( 1) + * If isw==0, then c =(Sign a_ptr)(|a_ptr|-|b_ptr|) + * else c =(Sign ofisw)(|a_ptr|+|b_ptr|) + */ + if (isw) { /* addition */ + VpSetSign(c, 1); + mrv = VpAddAbs(a_ptr, b_ptr, c); + VpSetSign(c, isw / 2); + } + else { /* subtraction */ + VpSetSign(c, 1); + mrv = VpSubAbs(a_ptr, b_ptr, c); + if (a_ptr == a) { + VpSetSign(c,VpGetSign(a)); + } + else { + VpSetSign(c, VpGetSign(a_ptr) * sw); + } + } + VpInternalRound(c, 0, (c->Prec > 0) ? c->frac[c->Prec-1] : 0, mrv); + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpAddSub(result) c=% \n", c); + VPrint(stdout, " a=% \n", a); + VPrint(stdout, " b=% \n", b); + printf(" operation=%d\n", operation); + } +#endif /* BIGDECIMAL_DEBUG */ + return c->Prec * BASE_FIG; +} + +/* + * Addition of two values with variable precision + * a and b assuming abs(a)>abs(b). + * c = abs(a) + abs(b) ; where |a|>=|b| + */ +static DECDIG +VpAddAbs(Real *a, Real *b, Real *c) +{ + size_t word_shift; + size_t ap; + size_t bp; + size_t cp; + size_t a_pos; + size_t b_pos, b_pos_with_word_shift; + size_t c_pos; + DECDIG av, bv, carry, mrv; + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpAddAbs called: a = %\n", a); + VPrint(stdout, " b = %\n", b); + } +#endif /* BIGDECIMAL_DEBUG */ + + word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv); + a_pos = ap; + b_pos = bp; + c_pos = cp; + + if (word_shift == (size_t)-1L) return 0; /* Overflow */ + if (b_pos == (size_t)-1L) goto Assign_a; + + mrv = av + bv; /* Most right val. Used for round. */ + + /* Just assign the last few digits of b to c because a has no */ + /* corresponding digits to be added. */ + if (b_pos > 0) { + while (b_pos > 0 && b_pos + word_shift > a_pos) { + c->frac[--c_pos] = b->frac[--b_pos]; + } + } + if (b_pos == 0 && word_shift > a_pos) { + while (word_shift-- > a_pos) { + c->frac[--c_pos] = 0; + } + } + + /* Just assign the last few digits of a to c because b has no */ + /* corresponding digits to be added. */ + b_pos_with_word_shift = b_pos + word_shift; + while (a_pos > b_pos_with_word_shift) { + c->frac[--c_pos] = a->frac[--a_pos]; + } + carry = 0; /* set first carry be zero */ + + /* Now perform addition until every digits of b will be */ + /* exhausted. */ + while (b_pos > 0) { + c->frac[--c_pos] = a->frac[--a_pos] + b->frac[--b_pos] + carry; + if (c->frac[c_pos] >= BASE) { + c->frac[c_pos] -= BASE; + carry = 1; + } + else { + carry = 0; + } + } + + /* Just assign the first few digits of a with considering */ + /* the carry obtained so far because b has been exhausted. */ + while (a_pos > 0) { + c->frac[--c_pos] = a->frac[--a_pos] + carry; + if (c->frac[c_pos] >= BASE) { + c->frac[c_pos] -= BASE; + carry = 1; + } + else { + carry = 0; + } + } + if (c_pos) c->frac[c_pos - 1] += carry; + goto Exit; + +Assign_a: + VpAsgn(c, a, 1); + mrv = 0; + +Exit: + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpAddAbs exit: c=% \n", c); + } +#endif /* BIGDECIMAL_DEBUG */ + return mrv; +} + +/* + * c = abs(a) - abs(b) + */ +static DECDIG +VpSubAbs(Real *a, Real *b, Real *c) +{ + size_t word_shift; + size_t ap; + size_t bp; + size_t cp; + size_t a_pos; + size_t b_pos, b_pos_with_word_shift; + size_t c_pos; + DECDIG av, bv, borrow, mrv; + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpSubAbs called: a = %\n", a); + VPrint(stdout, " b = %\n", b); + } +#endif /* BIGDECIMAL_DEBUG */ + + word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv); + a_pos = ap; + b_pos = bp; + c_pos = cp; + if (word_shift == (size_t)-1L) return 0; /* Overflow */ + if (b_pos == (size_t)-1L) goto Assign_a; + + if (av >= bv) { + mrv = av - bv; + borrow = 0; + } + else { + mrv = 0; + borrow = 1; + } + + /* Just assign the values which are the BASE subtracted by */ + /* each of the last few digits of the b because the a has no */ + /* corresponding digits to be subtracted. */ + if (b_pos + word_shift > a_pos) { + while (b_pos > 0 && b_pos + word_shift > a_pos) { + c->frac[--c_pos] = BASE - b->frac[--b_pos] - borrow; + borrow = 1; + } + if (b_pos == 0) { + while (word_shift > a_pos) { + --word_shift; + c->frac[--c_pos] = BASE - borrow; + borrow = 1; + } + } + } + /* Just assign the last few digits of a to c because b has no */ + /* corresponding digits to subtract. */ + + b_pos_with_word_shift = b_pos + word_shift; + while (a_pos > b_pos_with_word_shift) { + c->frac[--c_pos] = a->frac[--a_pos]; + } + + /* Now perform subtraction until every digits of b will be */ + /* exhausted. */ + while (b_pos > 0) { + --c_pos; + if (a->frac[--a_pos] < b->frac[--b_pos] + borrow) { + c->frac[c_pos] = BASE + a->frac[a_pos] - b->frac[b_pos] - borrow; + borrow = 1; + } + else { + c->frac[c_pos] = a->frac[a_pos] - b->frac[b_pos] - borrow; + borrow = 0; + } + } + + /* Just assign the first few digits of a with considering */ + /* the borrow obtained so far because b has been exhausted. */ + while (a_pos > 0) { + --c_pos; + if (a->frac[--a_pos] < borrow) { + c->frac[c_pos] = BASE + a->frac[a_pos] - borrow; + borrow = 1; + } + else { + c->frac[c_pos] = a->frac[a_pos] - borrow; + borrow = 0; + } + } + if (c_pos) c->frac[c_pos - 1] -= borrow; + goto Exit; + +Assign_a: + VpAsgn(c, a, 1); + mrv = 0; + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpSubAbs exit: c=% \n", c); + } +#endif /* BIGDECIMAL_DEBUG */ + return mrv; +} + +/* + * Note: If(av+bv)>= HALF_BASE,then 1 will be added to the least significant + * digit of c(In case of addition). + * ------------------------- figure of output ----------------------------------- + * a = xxxxxxxxxxx + * b = xxxxxxxxxx + * c =xxxxxxxxxxxxxxx + * word_shift = | | + * right_word = | | (Total digits in RHSV) + * left_word = | | (Total digits in LHSV) + * a_pos = | + * b_pos = | + * c_pos = | + */ +static size_t +VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, DECDIG *av, DECDIG *bv) +{ + size_t left_word, right_word, word_shift; + + size_t const round_limit = (VpGetPrecLimit() + BASE_FIG - 1) / BASE_FIG; + + assert(a->exponent >= b->exponent); + + c->frac[0] = 0; + *av = *bv = 0; + + word_shift = (a->exponent - b->exponent); + left_word = b->Prec + word_shift; + right_word = Max(a->Prec, left_word); + left_word = c->MaxPrec - 1; /* -1 ... prepare for round up */ + + /* + * check if 'round' is needed. + */ + if (right_word > left_word) { /* round ? */ + /*--------------------------------- + * Actual size of a = xxxxxxAxx + * Actual size of b = xxxBxxxxx + * Max. size of c = xxxxxx + * Round off = |-----| + * c_pos = | + * right_word = | + * a_pos = | + */ + *c_pos = right_word = left_word + 1; /* Set resulting precision */ + /* be equal to that of c */ + if (a->Prec >= c->MaxPrec) { + /* + * a = xxxxxxAxxx + * c = xxxxxx + * a_pos = | + */ + *a_pos = left_word; + if (*a_pos <= round_limit) { + *av = a->frac[*a_pos]; /* av is 'A' shown in above. */ + } + } + else { + /* + * a = xxxxxxx + * c = xxxxxxxxxx + * a_pos = | + */ + *a_pos = a->Prec; + } + if (b->Prec + word_shift >= c->MaxPrec) { + /* + * a = xxxxxxxxx + * b = xxxxxxxBxxx + * c = xxxxxxxxxxx + * b_pos = | + */ + if (c->MaxPrec >= word_shift + 1) { + *b_pos = c->MaxPrec - word_shift - 1; + if (*b_pos + word_shift <= round_limit) { + *bv = b->frac[*b_pos]; + } + } + else { + *b_pos = -1L; + } + } + else { + /* + * a = xxxxxxxxxxxxxxxx + * b = xxxxxx + * c = xxxxxxxxxxxxx + * b_pos = | + */ + *b_pos = b->Prec; + } + } + else { /* The MaxPrec of c - 1 > The Prec of a + b */ + /* + * a = xxxxxxx + * b = xxxxxx + * c = xxxxxxxxxxx + * c_pos = | + */ + *b_pos = b->Prec; + *a_pos = a->Prec; + *c_pos = right_word + 1; + } + c->Prec = *c_pos; + c->exponent = a->exponent; + if (!AddExponent(c, 1)) return (size_t)-1L; + return word_shift; +} + +/* + * Return number of significant digits + * c = a * b , Where a = a0a1a2 ... an + * b = b0b1b2 ... bm + * c = c0c1c2 ... cl + * a0 a1 ... an * bm + * a0 a1 ... an * bm-1 + * . . . + * . . . + * a0 a1 .... an * b0 + * +_____________________________ + * c0 c1 c2 ...... cl + * nc <---| + * MaxAB |--------------------| + */ +VP_EXPORT size_t +VpMult(Real *c, Real *a, Real *b) +{ + size_t MxIndA, MxIndB, MxIndAB, MxIndC; + size_t ind_c, i, ii, nc; + size_t ind_as, ind_ae, ind_bs; + DECDIG carry; + DECDIG_DBL s; + Real *w; + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpMult(Enter): a=% \n", a); + VPrint(stdout, " b=% \n", b); + } +#endif /* BIGDECIMAL_DEBUG */ + + if (!VpIsDefOP(c, a, b, OP_SW_MULT)) return 0; /* No significant digit */ + + if (VpIsZero(a) || VpIsZero(b)) { + /* at least a or b is zero */ + VpSetZero(c, VpGetSign(a) * VpGetSign(b)); + return 1; /* 0: 1 significant digit */ + } + + if (VpIsOne(a)) { + VpAsgn(c, b, VpGetSign(a)); + goto Exit; + } + if (VpIsOne(b)) { + VpAsgn(c, a, VpGetSign(b)); + goto Exit; + } + if (b->Prec > a->Prec) { + /* Adjust so that digits(a)>digits(b) */ + w = a; + a = b; + b = w; + } + w = NULL; + MxIndA = a->Prec - 1; + MxIndB = b->Prec - 1; + MxIndC = c->MaxPrec - 1; + MxIndAB = a->Prec + b->Prec - 1; + + if (MxIndC < MxIndAB) { /* The Max. prec. of c < Prec(a)+Prec(b) */ + w = c; + c = NewZeroNolimit(1, (size_t)((MxIndAB + 1) * BASE_FIG)); + MxIndC = MxIndAB; + } + + /* set LHSV c info */ + + c->exponent = a->exponent; /* set exponent */ + if (!AddExponent(c, b->exponent)) { + if (w) rbd_free_struct(c); + return 0; + } + VpSetSign(c, VpGetSign(a) * VpGetSign(b)); /* set sign */ + carry = 0; + nc = ind_c = MxIndAB; + memset(c->frac, 0, (nc + 1) * sizeof(DECDIG)); /* Initialize c */ + c->Prec = nc + 1; /* set precision */ + for (nc = 0; nc < MxIndAB; ++nc, --ind_c) { + if (nc < MxIndB) { /* The left triangle of the Fig. */ + ind_as = MxIndA - nc; + ind_ae = MxIndA; + ind_bs = MxIndB; + } + else if (nc <= MxIndA) { /* The middle rectangular of the Fig. */ + ind_as = MxIndA - nc; + ind_ae = MxIndA - (nc - MxIndB); + ind_bs = MxIndB; + } + else /* if (nc > MxIndA) */ { /* The right triangle of the Fig. */ + ind_as = 0; + ind_ae = MxIndAB - nc - 1; + ind_bs = MxIndB - (nc - MxIndA); + } + + for (i = ind_as; i <= ind_ae; ++i) { + s = (DECDIG_DBL)a->frac[i] * b->frac[ind_bs--]; + carry = (DECDIG)(s / BASE); + s -= (DECDIG_DBL)carry * BASE; + c->frac[ind_c] += (DECDIG)s; + if (c->frac[ind_c] >= BASE) { + s = c->frac[ind_c] / BASE; + carry += (DECDIG)s; + c->frac[ind_c] -= (DECDIG)(s * BASE); + } + if (carry) { + ii = ind_c; + while (ii-- > 0) { + c->frac[ii] += carry; + if (c->frac[ii] >= BASE) { + carry = c->frac[ii] / BASE; + c->frac[ii] -= (carry * BASE); + } + else { + break; + } + } + } + } + } + if (w != NULL) { /* free work variable */ + VpNmlz(c); + VpAsgn(w, c, 1); + rbd_free_struct(c); + c = w; + } + else { + VpLimitRound(c,0); + } + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpMult(c=a*b): c=% \n", c); + VPrint(stdout, " a=% \n", a); + VPrint(stdout, " b=% \n", b); + } +#endif /*BIGDECIMAL_DEBUG */ + return c->Prec*BASE_FIG; +} + +/* + * c = a / b, remainder = r + */ +VP_EXPORT size_t +VpDivd(Real *c, Real *r, Real *a, Real *b) +{ + size_t word_a, word_b, word_c, word_r; + size_t i, n, ind_a, ind_b, ind_c, ind_r; + size_t nLoop; + DECDIG_DBL q, b1, b1p1, b1b2, b1b2p1, r1r2; + DECDIG borrow, borrow1, borrow2; + DECDIG_DBL qb; + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, " VpDivd(c=a/b) a=% \n", a); + VPrint(stdout, " b=% \n", b); + } +#endif /*BIGDECIMAL_DEBUG */ + + VpSetNaN(r); + if (!VpIsDefOP(c, a, b, OP_SW_DIV)) goto Exit; + if (VpIsZero(a) && VpIsZero(b)) { + VpSetNaN(c); + return VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'", 0); + } + if (VpIsZero(b)) { + VpSetInf(c, VpGetSign(a) * VpGetSign(b)); + return VpException(VP_EXCEPTION_ZERODIVIDE, "Divide by zero", 0); + } + if (VpIsZero(a)) { + /* numerator a is zero */ + VpSetZero(c, VpGetSign(a) * VpGetSign(b)); + VpSetZero(r, VpGetSign(a) * VpGetSign(b)); + goto Exit; + } + if (VpIsOne(b)) { + /* divide by one */ + VpAsgn(c, a, VpGetSign(b)); + VpSetZero(r, VpGetSign(a)); + goto Exit; + } + + word_a = a->Prec; + word_b = b->Prec; + word_c = c->MaxPrec; + word_r = r->MaxPrec; + + if (word_a >= word_r) goto space_error; + + ind_r = 1; + r->frac[0] = 0; + while (ind_r <= word_a) { + r->frac[ind_r] = a->frac[ind_r - 1]; + ++ind_r; + } + while (ind_r < word_r) r->frac[ind_r++] = 0; + + ind_c = 0; + while (ind_c < word_c) c->frac[ind_c++] = 0; + + /* initial procedure */ + b1 = b1p1 = b->frac[0]; + if (b->Prec <= 1) { + b1b2p1 = b1b2 = b1p1 * BASE; + } + else { + b1p1 = b1 + 1; + b1b2p1 = b1b2 = b1 * BASE + b->frac[1]; + if (b->Prec > 2) ++b1b2p1; + } + + /* */ + /* loop start */ + ind_c = word_r - 1; + nLoop = Min(word_c,ind_c); + ind_c = 1; + while (ind_c < nLoop) { + if (r->frac[ind_c] == 0) { + ++ind_c; + continue; + } + r1r2 = (DECDIG_DBL)r->frac[ind_c] * BASE + r->frac[ind_c + 1]; + if (r1r2 == b1b2) { + /* The first two word digits is the same */ + ind_b = 2; + ind_a = ind_c + 2; + while (ind_b < word_b) { + if (r->frac[ind_a] < b->frac[ind_b]) goto div_b1p1; + if (r->frac[ind_a] > b->frac[ind_b]) break; + ++ind_a; + ++ind_b; + } + /* The first few word digits of r and b is the same and */ + /* the first different word digit of w is greater than that */ + /* of b, so quotient is 1 and just subtract b from r. */ + borrow = 0; /* quotient=1, then just r-b */ + ind_b = b->Prec - 1; + ind_r = ind_c + ind_b; + if (ind_r >= word_r) goto space_error; + n = ind_b; + for (i = 0; i <= n; ++i) { + if (r->frac[ind_r] < b->frac[ind_b] + borrow) { + r->frac[ind_r] += (BASE - (b->frac[ind_b] + borrow)); + borrow = 1; + } + else { + r->frac[ind_r] = r->frac[ind_r] - b->frac[ind_b] - borrow; + borrow = 0; + } + --ind_r; + --ind_b; + } + ++c->frac[ind_c]; + goto carry; + } + /* The first two word digits is not the same, */ + /* then compare magnitude, and divide actually. */ + if (r1r2 >= b1b2p1) { + q = r1r2 / b1b2p1; /* q == (DECDIG)q */ + c->frac[ind_c] += (DECDIG)q; + ind_r = b->Prec + ind_c - 1; + goto sub_mult; + } + +div_b1p1: + if (ind_c + 1 >= word_c) goto out_side; + q = r1r2 / b1p1; /* q == (DECDIG)q */ + c->frac[ind_c + 1] += (DECDIG)q; + ind_r = b->Prec + ind_c; + +sub_mult: + borrow1 = borrow2 = 0; + ind_b = word_b - 1; + if (ind_r >= word_r) goto space_error; + n = ind_b; + for (i = 0; i <= n; ++i) { + /* now, perform r = r - q * b */ + qb = q * b->frac[ind_b]; + if (qb < BASE) borrow1 = 0; + else { + borrow1 = (DECDIG)(qb / BASE); + qb -= (DECDIG_DBL)borrow1 * BASE; /* get qb < BASE */ + } + if(r->frac[ind_r] < qb) { + r->frac[ind_r] += (DECDIG)(BASE - qb); + borrow2 = borrow2 + borrow1 + 1; + } + else { + r->frac[ind_r] -= (DECDIG)qb; + borrow2 += borrow1; + } + if (borrow2) { + if(r->frac[ind_r - 1] < borrow2) { + r->frac[ind_r - 1] += (BASE - borrow2); + borrow2 = 1; + } + else { + r->frac[ind_r - 1] -= borrow2; + borrow2 = 0; + } + } + --ind_r; + --ind_b; + } + + r->frac[ind_r] -= borrow2; +carry: + ind_r = ind_c; + while (c->frac[ind_r] >= BASE) { + c->frac[ind_r] -= BASE; + --ind_r; + ++c->frac[ind_r]; + } + } + /* End of operation, now final arrangement */ +out_side: + c->Prec = word_c; + c->exponent = a->exponent; + if (!AddExponent(c, 2)) return 0; + if (!AddExponent(c, -(b->exponent))) return 0; + + VpSetSign(c, VpGetSign(a) * VpGetSign(b)); + VpNmlz(c); /* normalize c */ + r->Prec = word_r; + r->exponent = a->exponent; + if (!AddExponent(r, 1)) return 0; + VpSetSign(r, VpGetSign(a)); + VpNmlz(r); /* normalize r(remainder) */ + goto Exit; + +space_error: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + printf(" word_a=%"PRIuSIZE"\n", word_a); + printf(" word_b=%"PRIuSIZE"\n", word_b); + printf(" word_c=%"PRIuSIZE"\n", word_c); + printf(" word_r=%"PRIuSIZE"\n", word_r); + printf(" ind_r =%"PRIuSIZE"\n", ind_r); + } +#endif /* BIGDECIMAL_DEBUG */ + rb_bug("ERROR(VpDivd): space for remainder too small."); + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, " VpDivd(c=a/b), c=% \n", c); + VPrint(stdout, " r=% \n", r); + } +#endif /* BIGDECIMAL_DEBUG */ + return c->Prec * BASE_FIG; +} + +/* + * Input a = 00000xxxxxxxx En(5 preceding zeros) + * Output a = xxxxxxxx En-5 + */ +static int +VpNmlz(Real *a) +{ + size_t ind_a, i; + + if (!VpIsDef(a)) goto NoVal; + if (VpIsZero(a)) goto NoVal; + + ind_a = a->Prec; + while (ind_a--) { + if (a->frac[ind_a]) { + a->Prec = ind_a + 1; + i = 0; + while (a->frac[i] == 0) ++i; /* skip the first few zeros */ + if (i) { + a->Prec -= i; + if (!AddExponent(a, -(SIGNED_VALUE)i)) return 0; + memmove(&a->frac[0], &a->frac[i], a->Prec*sizeof(DECDIG)); + } + return 1; + } + } + /* a is zero(no non-zero digit) */ + VpSetZero(a, VpGetSign(a)); + return 0; + +NoVal: + a->frac[0] = 0; + a->Prec = 1; + return 0; +} + +/* + * VpComp = 0 ... if a=b, + * Pos ... a>b, + * Neg ... asign - b->sign; + else e = a->sign; + + if (e > 0) return 1; + else if (e < 0) return -1; + else return 0; + } + if (!VpIsDef(b)) { + e = -b->sign; + if (e > 0) return 1; + else return -1; + } + /* Zero check */ + if (VpIsZero(a)) { + if (VpIsZero(b)) return 0; /* both zero */ + val = -VpGetSign(b); + goto Exit; + } + if (VpIsZero(b)) { + val = VpGetSign(a); + goto Exit; + } + + /* compare sign */ + if (VpGetSign(a) > VpGetSign(b)) { + val = 1; /* a>b */ + goto Exit; + } + if (VpGetSign(a) < VpGetSign(b)) { + val = -1; /* aexponent > b->exponent) { + val = VpGetSign(a); + goto Exit; + } + if (a->exponent < b->exponent) { + val = -VpGetSign(b); + goto Exit; + } + + /* a and b have same exponent, then compare their significand. */ + mx = (a->Prec < b->Prec) ? a->Prec : b->Prec; + ind = 0; + while (ind < mx) { + if (a->frac[ind] > b->frac[ind]) { + val = VpGetSign(a); + goto Exit; + } + if (a->frac[ind] < b->frac[ind]) { + val = -VpGetSign(b); + goto Exit; + } + ++ind; + } + if (a->Prec > b->Prec) { + val = VpGetSign(a); + } + else if (a->Prec < b->Prec) { + val = -VpGetSign(b); + } + +Exit: + if (val > 1) val = 1; + else if (val < -1) val = -1; + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, " VpComp a=%\n", a); + VPrint(stdout, " b=%\n", b); + printf(" ans=%d\n", val); + } +#endif /* BIGDECIMAL_DEBUG */ + return (int)val; +} + +/* + * cntl_chr ... ASCIIZ Character, print control characters + * Available control codes: + * % ... VP variable. To print '%', use '%%'. + * \n ... new line + * \b ... backspace + * \t ... tab + * Note: % must not appear more than once + * a ... VP variable to be printed + */ +static int +VPrint(FILE *fp, const char *cntl_chr, Real *a) +{ + size_t i, j, nc, nd, ZeroSup, sep = 10; + DECDIG m, e, nn; + + j = 0; + nd = nc = 0; /* nd : number of digits in fraction part(every 10 digits, */ + /* nd<=10). */ + /* nc : number of characters printed */ + ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */ + while (*(cntl_chr + j)) { + if (*(cntl_chr + j) == '%' && *(cntl_chr + j + 1) != '%') { + nc = 0; + if (VpIsNaN(a)) { + fprintf(fp, SZ_NaN); + nc += 8; + } + else if (VpIsPosInf(a)) { + fprintf(fp, SZ_INF); + nc += 8; + } + else if (VpIsNegInf(a)) { + fprintf(fp, SZ_NINF); + nc += 9; + } + else if (!VpIsZero(a)) { + if (BIGDECIMAL_NEGATIVE_P(a)) { + fprintf(fp, "-"); + ++nc; + } + nc += fprintf(fp, "0."); + switch (*(cntl_chr + j + 1)) { + default: + break; + + case '0': case 'z': + ZeroSup = 0; + ++j; + sep = cntl_chr[j] == 'z' ? BIGDECIMAL_COMPONENT_FIGURES : 10; + break; + } + for (i = 0; i < a->Prec; ++i) { + m = BASE1; + e = a->frac[i]; + while (m) { + nn = e / m; + if (!ZeroSup || nn) { + nc += fprintf(fp, "%lu", (unsigned long)nn); /* The leading zero(s) */ + /* as 0.00xx will not */ + /* be printed. */ + ++nd; + ZeroSup = 0; /* Set to print succeeding zeros */ + } + if (nd >= sep) { /* print ' ' after every 10 digits */ + nd = 0; + nc += fprintf(fp, " "); + } + e = e - nn * m; + m /= 10; + } + } + nc += fprintf(fp, "E%"PRIdSIZE, VpExponent10(a)); + nc += fprintf(fp, " (%"PRIdVALUE", %"PRIuSIZE", %"PRIuSIZE")", a->exponent, a->Prec, a->MaxPrec); + } + else { + nc += fprintf(fp, "0.0"); + } + } + else { + ++nc; + if (*(cntl_chr + j) == '\\') { + switch (*(cntl_chr + j + 1)) { + case 'n': + fprintf(fp, "\n"); + ++j; + break; + case 't': + fprintf(fp, "\t"); + ++j; + break; + case 'b': + fprintf(fp, "\n"); + ++j; + break; + default: + fprintf(fp, "%c", *(cntl_chr + j)); + break; + } + } + else { + fprintf(fp, "%c", *(cntl_chr + j)); + if (*(cntl_chr + j) == '%') ++j; + } + } + j++; + } + + return (int)nc; +} + +static void +VpFormatSt(char *psz, size_t fFmt) +{ + size_t ie, i, nf = 0; + char ch; + + if (fFmt == 0) return; + + ie = strlen(psz); + for (i = 0; i < ie; ++i) { + ch = psz[i]; + if (!ch) break; + if (ISSPACE(ch) || ch=='-' || ch=='+') continue; + if (ch == '.') { nf = 0; continue; } + if (ch == 'E' || ch == 'e') break; + + if (++nf > fFmt) { + memmove(psz + i + 1, psz + i, ie - i + 1); + ++ie; + nf = 0; + psz[i] = ' '; + } + } +} + +VP_EXPORT ssize_t +VpExponent10(Real *a) +{ + ssize_t ex; + size_t n; + + if (!VpHasVal(a)) return 0; + + ex = a->exponent * (ssize_t)BASE_FIG; + n = BASE1; + while ((a->frac[0] / n) == 0) { + --ex; + n /= 10; + } + return ex; +} + +VP_EXPORT void +VpSzMantissa(Real *a, char *buf, size_t buflen) +{ + size_t i, n, ZeroSup; + DECDIG_DBL m, e, nn; + + if (VpIsNaN(a)) { + snprintf(buf, buflen, SZ_NaN); + return; + } + if (VpIsPosInf(a)) { + snprintf(buf, buflen, SZ_INF); + return; + } + if (VpIsNegInf(a)) { + snprintf(buf, buflen, SZ_NINF); + return; + } + + ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */ + if (!VpIsZero(a)) { + if (BIGDECIMAL_NEGATIVE_P(a)) *buf++ = '-'; + n = a->Prec; + for (i = 0; i < n; ++i) { + m = BASE1; + e = a->frac[i]; + while (m) { + nn = e / m; + if (!ZeroSup || nn) { + snprintf(buf, buflen, "%lu", (unsigned long)nn); /* The leading zero(s) */ + buf += strlen(buf); + /* as 0.00xx will be ignored. */ + ZeroSup = 0; /* Set to print succeeding zeros */ + } + e = e - nn * m; + m /= 10; + } + } + *buf = 0; + while (buf[-1] == '0') *(--buf) = 0; + } + else { + if (VpIsPosZero(a)) snprintf(buf, buflen, "0"); + else snprintf(buf, buflen, "-0"); + } +} + +VP_EXPORT int +VpToSpecialString(Real *a, char *buf, size_t buflen, int fPlus) +/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */ +{ + if (VpIsNaN(a)) { + snprintf(buf, buflen, SZ_NaN); + return 1; + } + + if (VpIsPosInf(a)) { + if (fPlus == 1) { + *buf++ = ' '; + } + else if (fPlus == 2) { + *buf++ = '+'; + } + snprintf(buf, buflen, SZ_INF); + return 1; + } + if (VpIsNegInf(a)) { + snprintf(buf, buflen, SZ_NINF); + return 1; + } + if (VpIsZero(a)) { + if (VpIsPosZero(a)) { + if (fPlus == 1) snprintf(buf, buflen, " 0.0"); + else if (fPlus == 2) snprintf(buf, buflen, "+0.0"); + else snprintf(buf, buflen, "0.0"); + } + else snprintf(buf, buflen, "-0.0"); + return 1; + } + return 0; +} + +VP_EXPORT void +VpToString(Real *a, char *buf, size_t buflen, size_t fFmt, int fPlus) +/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */ +{ + size_t i, n, ZeroSup; + DECDIG shift, m, e, nn; + char *p = buf; + size_t plen = buflen; + ssize_t ex; + + if (VpToSpecialString(a, buf, buflen, fPlus)) return; + + ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */ + +#define ADVANCE(n) do { \ + if (plen < n) goto overflow; \ + p += n; \ + plen -= n; \ +} while (0) + + if (BIGDECIMAL_NEGATIVE_P(a)) { + *p = '-'; + ADVANCE(1); + } + else if (fPlus == 1) { + *p = ' '; + ADVANCE(1); + } + else if (fPlus == 2) { + *p = '+'; + ADVANCE(1); + } + + *p = '0'; ADVANCE(1); + *p = '.'; ADVANCE(1); + + n = a->Prec; + for (i = 0; i < n; ++i) { + m = BASE1; + e = a->frac[i]; + while (m) { + nn = e / m; + if (!ZeroSup || nn) { + /* The reading zero(s) */ + size_t n = (size_t)snprintf(p, plen, "%lu", (unsigned long)nn); + if (n > plen) goto overflow; + ADVANCE(n); + /* as 0.00xx will be ignored. */ + ZeroSup = 0; /* Set to print succeeding zeros */ + } + e = e - nn * m; + m /= 10; + } + } + + ex = a->exponent * (ssize_t)BASE_FIG; + shift = BASE1; + while (a->frac[0] / shift == 0) { + --ex; + shift /= 10; + } + while (p - 1 > buf && p[-1] == '0') { + *(--p) = '\0'; + ++plen; + } + snprintf(p, plen, "e%"PRIdSIZE, ex); + if (fFmt) VpFormatSt(buf, fFmt); + + overflow: + return; +#undef ADVANCE +} + +VP_EXPORT void +VpToFString(Real *a, char *buf, size_t buflen, size_t fFmt, int fPlus) +/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */ +{ + size_t i, n; + DECDIG m, e; + char *p = buf; + size_t plen = buflen, delim = fFmt; + ssize_t ex; + + if (VpToSpecialString(a, buf, buflen, fPlus)) return; + +#define APPEND(c, group) do { \ + if (plen < 1) goto overflow; \ + if (group && delim == 0) { \ + *p = ' '; \ + p += 1; \ + plen -= 1; \ + } \ + if (plen < 1) goto overflow; \ + *p = c; \ + p += 1; \ + plen -= 1; \ + if (group) delim = (delim + 1) % fFmt; \ +} while (0) + + + if (BIGDECIMAL_NEGATIVE_P(a)) { + APPEND('-', false); + } + else if (fPlus == 1) { + APPEND(' ', false); + } + else if (fPlus == 2) { + APPEND('+', false); + } + + n = a->Prec; + ex = a->exponent; + if (ex <= 0) { + APPEND('0', false); + APPEND('.', false); + } + while (ex < 0) { + for (i=0; i < BASE_FIG; ++i) { + APPEND('0', fFmt > 0); + } + ++ex; + } + + for (i = 0; i < n; ++i) { + m = BASE1; + e = a->frac[i]; + if (i == 0 && ex > 0) { + for (delim = 0; e / m == 0; delim++) { + m /= 10; + } + if (fFmt > 0) { + delim = 2*fFmt - (ex * BASE_FIG - delim) % fFmt; + } + } + while (m && (e || (i < n - 1) || ex > 0)) { + APPEND((char)(e / m + '0'), fFmt > 0); + e %= m; + m /= 10; + } + if (--ex == 0) { + APPEND('.', false); + delim = fFmt; + } + } + + while (ex > 0) { + for (i=0; i < BASE_FIG; ++i) { + APPEND('0', fFmt > 0); + } + if (--ex == 0) { + APPEND('.', false); + } + } + + *p = '\0'; + if (p - 1 > buf && p[-1] == '.') { + snprintf(p, plen, "0"); + } + + overflow: + return; +#undef APPEND +} + +/* + * [Output] + * a[] ... variable to be assigned the value. + * [Input] + * int_chr[] ... integer part(may include '+/-'). + * ni ... number of characters in int_chr[],not including '+/-'. + * frac[] ... fraction part. + * nf ... number of characters in frac[]. + * exp_chr[] ... exponent part(including '+/-'). + * ne ... number of characters in exp_chr[],not including '+/-'. + */ +VP_EXPORT int +VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne) +{ + size_t i, j, ind_a, ma, mi, me; + SIGNED_VALUE e, es, eb, ef; + int sign, signe, exponent_overflow; + + /* get exponent part */ + e = 0; + ma = a->MaxPrec; + mi = ni; + me = ne; + signe = 1; + exponent_overflow = 0; + memset(a->frac, 0, ma * sizeof(DECDIG)); + if (ne > 0) { + i = 0; + if (exp_chr[0] == '-') { + signe = -1; + ++i; + ++me; + } + else if (exp_chr[0] == '+') { + ++i; + ++me; + } + while (i < me) { + if (MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG)) { + es = e; + goto exp_overflow; + } + es = e * (SIGNED_VALUE)BASE_FIG; + if (MUL_OVERFLOW_SIGNED_VALUE_P(e, 10) || + SIGNED_VALUE_MAX - (exp_chr[i] - '0') < e * 10) + goto exp_overflow; + e = e * 10 + exp_chr[i] - '0'; + if (MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG)) + goto exp_overflow; + if (es > (SIGNED_VALUE)(e * BASE_FIG)) { + exp_overflow: + exponent_overflow = 1; + e = es; /* keep sign */ + break; + } + ++i; + } + } + + /* get integer part */ + i = 0; + sign = 1; + if (1 /*ni >= 0*/) { + if (int_chr[0] == '-') { + sign = -1; + ++i; + ++mi; + } + else if (int_chr[0] == '+') { + ++i; + ++mi; + } + } + + e = signe * e; /* e: The value of exponent part. */ + e = e + ni; /* set actual exponent size. */ + + if (e > 0) signe = 1; + else signe = -1; + + /* Adjust the exponent so that it is the multiple of BASE_FIG. */ + j = 0; + ef = 1; + while (ef) { + if (e >= 0) eb = e; + else eb = -e; + ef = eb / (SIGNED_VALUE)BASE_FIG; + ef = eb - ef * (SIGNED_VALUE)BASE_FIG; + if (ef) { + ++j; /* Means to add one more preceding zero */ + ++e; + } + } + + eb = e / (SIGNED_VALUE)BASE_FIG; + + if (exponent_overflow) { + int zero = 1; + for ( ; i < mi && zero; i++) zero = int_chr[i] == '0'; + for (i = 0; i < nf && zero; i++) zero = frac[i] == '0'; + if (!zero && signe > 0) { + VpSetInf(a, sign); + VpException(VP_EXCEPTION_INFINITY, "exponent overflow",0); + } + else VpSetZero(a, sign); + return 1; + } + + ind_a = 0; + while (i < mi) { + a->frac[ind_a] = 0; + while (j < BASE_FIG && i < mi) { + a->frac[ind_a] = a->frac[ind_a] * 10 + int_chr[i] - '0'; + ++j; + ++i; + } + if (i < mi) { + ++ind_a; + if (ind_a >= ma) goto over_flow; + j = 0; + } + } + + /* get fraction part */ + + i = 0; + while (i < nf) { + while (j < BASE_FIG && i < nf) { + a->frac[ind_a] = a->frac[ind_a] * 10 + frac[i] - '0'; + ++j; + ++i; + } + if (i < nf) { + ++ind_a; + if (ind_a >= ma) goto over_flow; + j = 0; + } + } + goto Final; + +over_flow: + rb_warn("Conversion from String to BigDecimal overflow (last few digits discarded)."); + +Final: + if (ind_a >= ma) ind_a = ma - 1; + while (j < BASE_FIG) { + a->frac[ind_a] = a->frac[ind_a] * 10; + ++j; + } + a->Prec = ind_a + 1; + a->exponent = eb; + VpSetSign(a, sign); + VpNmlz(a); + return 1; +} + +/* + * [Input] + * *m ... Real + * [Output] + * *d ... fraction part of m(d = 0.xxxxxxx). where # of 'x's is fig. + * *e ... exponent of m. + * BIGDECIMAL_DOUBLE_FIGURES ... Number of digits in a double variable. + * + * m -> d*10**e, 0Prec); + *d = 0.0; + div = 1.; + while (ind_m < mm) { + div /= (double)BASE; + *d = *d + (double)m->frac[ind_m++] * div; + } + *e = m->exponent * (SIGNED_VALUE)BASE_FIG; + *d *= VpGetSign(m); + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, " VpVtoD: m=%\n", m); + printf(" d=%e * 10 **%ld\n", *d, *e); + printf(" BIGDECIMAL_DOUBLE_FIGURES = %d\n", BIGDECIMAL_DOUBLE_FIGURES); + } +#endif /*BIGDECIMAL_DEBUG */ + return f; +} + +/* + * m <- d + */ +VP_EXPORT void +VpDtoV(Real *m, double d) +{ + size_t ind_m, mm; + SIGNED_VALUE ne; + DECDIG i; + double val, val2; + + if (isnan(d)) { + VpSetNaN(m); + goto Exit; + } + if (isinf(d)) { + if (d > 0.0) VpSetPosInf(m); + else VpSetNegInf(m); + goto Exit; + } + + if (d == 0.0) { + VpSetZero(m, 1); + goto Exit; + } + val = (d > 0.) ? d : -d; + ne = 0; + if (val >= 1.0) { + while (val >= 1.0) { + val /= (double)BASE; + ++ne; + } + } + else { + val2 = 1.0 / (double)BASE; + while (val < val2) { + val *= (double)BASE; + --ne; + } + } + /* Now val = 0.xxxxx*BASE**ne */ + + mm = m->MaxPrec; + memset(m->frac, 0, mm * sizeof(DECDIG)); + for (ind_m = 0; val > 0.0 && ind_m < mm; ind_m++) { + val *= (double)BASE; + i = (DECDIG)val; + val -= (double)i; + m->frac[ind_m] = i; + } + if (ind_m >= mm) ind_m = mm - 1; + VpSetSign(m, (d > 0.0) ? 1 : -1); + m->Prec = ind_m + 1; + m->exponent = ne; + + VpInternalRound(m, 0, (m->Prec > 0) ? m->frac[m->Prec-1] : 0, + (DECDIG)(val*(double)BASE)); + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + printf("VpDtoV d=%30.30e\n", d); + VPrint(stdout, " m=%\n", m); + } +#endif /* BIGDECIMAL_DEBUG */ + return; +} + +/* + * m <- ival + */ +#if 0 /* unused */ +VP_EXPORT void +VpItoV(Real *m, SIGNED_VALUE ival) +{ + size_t mm, ind_m; + size_t val, v1, v2, v; + int isign; + SIGNED_VALUE ne; + + if (ival == 0) { + VpSetZero(m, 1); + goto Exit; + } + isign = 1; + val = ival; + if (ival < 0) { + isign = -1; + val =(size_t)(-ival); + } + ne = 0; + ind_m = 0; + mm = m->MaxPrec; + while (ind_m < mm) { + m->frac[ind_m] = 0; + ++ind_m; + } + ind_m = 0; + while (val > 0) { + if (val) { + v1 = val; + v2 = 1; + while (v1 >= BASE) { + v1 /= BASE; + v2 *= BASE; + } + val = val - v2 * v1; + v = v1; + } + else { + v = 0; + } + m->frac[ind_m] = v; + ++ind_m; + ++ne; + } + m->Prec = ind_m - 1; + m->exponent = ne; + VpSetSign(m, isign); + VpNmlz(m); + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + printf(" VpItoV i=%d\n", ival); + VPrint(stdout, " m=%\n", m); + } +#endif /* BIGDECIMAL_DEBUG */ + return; +} +#endif + +/* + * y = SQRT(x), y*y - x =>0 + */ +VP_EXPORT int +VpSqrt(Real *y, Real *x) +{ + Real *f = NULL; + Real *r = NULL; + size_t y_prec; + SIGNED_VALUE n, e; + ssize_t nr; + double val; + + /* Zero or +Infinity ? */ + if (VpIsZero(x) || VpIsPosInf(x)) { + VpAsgn(y,x,1); + goto Exit; + } + + /* Negative ? */ + if (BIGDECIMAL_NEGATIVE_P(x)) { + VpSetNaN(y); + return VpException(VP_EXCEPTION_OP, "sqrt of negative value", 0); + } + + /* NaN ? */ + if (VpIsNaN(x)) { + VpSetNaN(y); + return VpException(VP_EXCEPTION_OP, "sqrt of 'NaN'(Not a Number)", 0); + } + + /* One ? */ + if (VpIsOne(x)) { + VpSetOne(y); + goto Exit; + } + + n = (SIGNED_VALUE)y->MaxPrec; + if (x->MaxPrec > (size_t)n) n = (ssize_t)x->MaxPrec; + + /* allocate temporally variables */ + /* TODO: reconsider MaxPrec of f and r */ + f = NewOneNolimit(1, y->MaxPrec * (BASE_FIG + 2)); + r = NewOneNolimit(1, (n + n) * (BASE_FIG + 2)); + + nr = 0; + y_prec = y->MaxPrec; + + VpVtoD(&val, &e, x); /* val <- x */ + e /= (SIGNED_VALUE)BASE_FIG; + n = e / 2; + if (e - n * 2 != 0) { + val /= BASE; + n = (e + 1) / 2; + } + VpDtoV(y, sqrt(val)); /* y <- sqrt(val) */ + y->exponent += n; + n = (SIGNED_VALUE)roomof(BIGDECIMAL_DOUBLE_FIGURES, BASE_FIG); + y->MaxPrec = Min((size_t)n , y_prec); + f->MaxPrec = y->MaxPrec + 1; + n = (SIGNED_VALUE)(y_prec * BASE_FIG); + if (n > (SIGNED_VALUE)maxnr) n = (SIGNED_VALUE)maxnr; + + /* + * Perform: y_{n+1} = (y_n - x/y_n) / 2 + */ + do { + y->MaxPrec *= 2; + if (y->MaxPrec > y_prec) y->MaxPrec = y_prec; + f->MaxPrec = y->MaxPrec; + VpDivd(f, r, x, y); /* f = x/y */ + VpAddSub(r, f, y, -1); /* r = f - y */ + VpMult(f, VpConstPt5, r); /* f = 0.5*r */ + if (VpIsZero(f)) + goto converge; + VpAddSub(r, f, y, 1); /* r = y + f */ + VpAsgn(y, r, 1); /* y = r */ + } while (++nr < n); + +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + printf("ERROR(VpSqrt): did not converge within %ld iterations.\n", nr); + } +#endif /* BIGDECIMAL_DEBUG */ + y->MaxPrec = y_prec; + +converge: + VpChangeSign(y, 1); +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VpMult(r, y, y); + VpAddSub(f, x, r, -1); + printf("VpSqrt: iterations = %"PRIdSIZE"\n", nr); + VPrint(stdout, " y =% \n", y); + VPrint(stdout, " x =% \n", x); + VPrint(stdout, " x-y*y = % \n", f); + } +#endif /* BIGDECIMAL_DEBUG */ + y->MaxPrec = y_prec; + +Exit: + rbd_free_struct(f); + rbd_free_struct(r); + return 1; +} + +/* + * Round relatively from the decimal point. + * f: rounding mode + * nf: digit location to round from the decimal point. + */ +VP_EXPORT int +VpMidRound(Real *y, unsigned short f, ssize_t nf) +{ + /* fracf: any positive digit under rounding position? */ + /* fracf_1further: any positive digits under one further than the rounding position? */ + /* exptoadd: number of digits needed to compensate negative nf */ + int fracf, fracf_1further; + ssize_t n,i,ix,ioffset, exptoadd; + DECDIG v, shifter; + DECDIG div; + + nf += y->exponent * (ssize_t)BASE_FIG; + exptoadd=0; + if (nf < 0) { + /* rounding position too left(large). */ + if (f != VP_ROUND_CEIL && f != VP_ROUND_FLOOR) { + VpSetZero(y, VpGetSign(y)); /* truncate everything */ + return 0; + } + exptoadd = -nf; + nf = 0; + } + + ix = nf / (ssize_t)BASE_FIG; + if ((size_t)ix >= y->Prec) return 0; /* rounding position too right(small). */ + v = y->frac[ix]; + + ioffset = nf - ix*(ssize_t)BASE_FIG; + n = (ssize_t)BASE_FIG - ioffset - 1; + for (shifter = 1, i = 0; i < n; ++i) shifter *= 10; + + /* so the representation used (in y->frac) is an array of DECDIG, where + each DECDIG contains a value between 0 and BASE-1, consisting of BASE_FIG + decimal places. + + (that numbers of decimal places are typed as ssize_t is somewhat confusing) + + nf is now position (in decimal places) of the digit from the start of + the array. + + ix is the position (in DECDIGs) of the DECDIG containing the decimal digit, + from the start of the array. + + v is the value of this DECDIG + + ioffset is the number of extra decimal places along of this decimal digit + within v. + + n is the number of decimal digits remaining within v after this decimal digit + shifter is 10**n, + + v % shifter are the remaining digits within v + v % (shifter * 10) are the digit together with the remaining digits within v + v / shifter are the digit's predecessors together with the digit + div = v / shifter / 10 is just the digit's precessors + (v / shifter) - div*10 is just the digit, which is what v ends up being reassigned to. + */ + + fracf = (v % (shifter * 10) > 0); + fracf_1further = ((v % shifter) > 0); + + v /= shifter; + div = v / 10; + v = v - div*10; + /* now v is just the digit required. + now fracf is whether the digit or any of the remaining digits within v are non-zero + now fracf_1further is whether any of the remaining digits within v are non-zero + */ + + /* now check all the remaining DECDIGs for zero-ness a whole DECDIG at a time. + if we spot any non-zeroness, that means that we found a positive digit under + rounding position, and we also found a positive digit under one further than + the rounding position, so both searches (to see if any such non-zero digit exists) + can stop */ + + for (i = ix + 1; (size_t)i < y->Prec; i++) { + if (y->frac[i] % BASE) { + fracf = fracf_1further = 1; + break; + } + } + + /* now fracf = does any positive digit exist under the rounding position? + now fracf_1further = does any positive digit exist under one further than the + rounding position? + now v = the first digit under the rounding position */ + + /* drop digits after pointed digit */ + memset(y->frac + ix + 1, 0, (y->Prec - (ix + 1)) * sizeof(DECDIG)); + + switch (f) { + case VP_ROUND_DOWN: /* Truncate */ + break; + case VP_ROUND_UP: /* Roundup */ + if (fracf) ++div; + break; + case VP_ROUND_HALF_UP: + if (v>=5) ++div; + break; + case VP_ROUND_HALF_DOWN: + if (v > 5 || (v == 5 && fracf_1further)) ++div; + break; + case VP_ROUND_CEIL: + if (fracf && BIGDECIMAL_POSITIVE_P(y)) ++div; + break; + case VP_ROUND_FLOOR: + if (fracf && BIGDECIMAL_NEGATIVE_P(y)) ++div; + break; + case VP_ROUND_HALF_EVEN: /* Banker's rounding */ + if (v > 5) ++div; + else if (v == 5) { + if (fracf_1further) { + ++div; + } + else { + if (ioffset == 0) { + /* v is the first decimal digit of its DECDIG; + need to grab the previous DECDIG if present + to check for evenness of the previous decimal + digit (which is same as that of the DECDIG since + base 10 has a factor of 2) */ + if (ix && (y->frac[ix-1] % 2)) ++div; + } + else { + if (div % 2) ++div; + } + } + } + break; + } + for (i = 0; i <= n; ++i) div *= 10; + if (div >= BASE) { + if (ix) { + y->frac[ix] = 0; + VpRdup(y, ix); + } + else { + short s = VpGetSign(y); + SIGNED_VALUE e = y->exponent; + VpSetOne(y); + VpSetSign(y, s); + y->exponent = e + 1; + } + } + else { + y->frac[ix] = div; + VpNmlz(y); + } + if (exptoadd > 0) { + y->exponent += (SIGNED_VALUE)(exptoadd / BASE_FIG); + exptoadd %= (ssize_t)BASE_FIG; + for (i = 0; i < exptoadd; i++) { + y->frac[0] *= 10; + if (y->frac[0] >= BASE) { + y->frac[0] /= BASE; + y->exponent++; + } + } + } + return 1; +} + +VP_EXPORT int +VpLeftRound(Real *y, unsigned short f, ssize_t nf) +/* + * Round from the left hand side of the digits. + */ +{ + DECDIG v; + if (!VpHasVal(y)) return 0; /* Unable to round */ + v = y->frac[0]; + nf -= VpExponent(y) * (ssize_t)BASE_FIG; + while ((v /= 10) != 0) nf--; + nf += (ssize_t)BASE_FIG-1; + return VpMidRound(y, f, nf); +} + +VP_EXPORT int +VpActiveRound(Real *y, Real *x, unsigned short f, ssize_t nf) +{ + /* First,assign whole value in truncation mode */ + if (VpAsgn(y, x, 10) <= 1) return 0; /* Zero,NaN,or Infinity */ + return VpMidRound(y, f, nf); +} + +static int +VpLimitRound(Real *c, size_t ixDigit) +{ + size_t ix = VpGetPrecLimit(); + if (!VpNmlz(c)) return -1; + if (!ix) return 0; + if (!ixDigit) ixDigit = c->Prec-1; + if ((ix + BASE_FIG - 1) / BASE_FIG > ixDigit + 1) return 0; + return VpLeftRound(c, VpGetRoundMode(), (ssize_t)ix); +} + +/* If I understand correctly, this is only ever used to round off the final decimal + digit of precision */ +static void +VpInternalRound(Real *c, size_t ixDigit, DECDIG vPrev, DECDIG v) +{ + int f = 0; + + unsigned short const rounding_mode = VpGetRoundMode(); + + if (VpLimitRound(c, ixDigit)) return; + if (!v) return; + + v /= BASE1; + switch (rounding_mode) { + case VP_ROUND_DOWN: + break; + case VP_ROUND_UP: + if (v) f = 1; + break; + case VP_ROUND_HALF_UP: + if (v >= 5) f = 1; + break; + case VP_ROUND_HALF_DOWN: + /* this is ok - because this is the last digit of precision, + the case where v == 5 and some further digits are nonzero + will never occur */ + if (v >= 6) f = 1; + break; + case VP_ROUND_CEIL: + if (v && BIGDECIMAL_POSITIVE_P(c)) f = 1; + break; + case VP_ROUND_FLOOR: + if (v && BIGDECIMAL_NEGATIVE_P(c)) f = 1; + break; + case VP_ROUND_HALF_EVEN: /* Banker's rounding */ + /* as per VP_ROUND_HALF_DOWN, because this is the last digit of precision, + there is no case to worry about where v == 5 and some further digits are nonzero */ + if (v > 5) f = 1; + else if (v == 5 && vPrev % 2) f = 1; + break; + } + if (f) { + VpRdup(c, ixDigit); + VpNmlz(c); + } +} + +/* + * Rounds up m(plus one to final digit of m). + */ +static int +VpRdup(Real *m, size_t ind_m) +{ + DECDIG carry; + + if (!ind_m) ind_m = m->Prec; + + carry = 1; + while (carry > 0 && ind_m--) { + m->frac[ind_m] += carry; + if (m->frac[ind_m] >= BASE) m->frac[ind_m] -= BASE; + else carry = 0; + } + if (carry > 0) { /* Overflow,count exponent and set fraction part be 1 */ + if (!AddExponent(m, 1)) return 0; + m->Prec = m->frac[0] = 1; + } + else { + VpNmlz(m); + } + return 1; +} + +/* + * y = x - fix(x) + */ +VP_EXPORT void +VpFrac(Real *y, Real *x) +{ + size_t my, ind_y, ind_x; + + if (!VpHasVal(x)) { + VpAsgn(y, x, 1); + goto Exit; + } + + if (x->exponent > 0 && (size_t)x->exponent >= x->Prec) { + VpSetZero(y, VpGetSign(x)); + goto Exit; + } + else if (x->exponent <= 0) { + VpAsgn(y, x, 1); + goto Exit; + } + + /* satisfy: x->exponent > 0 */ + + y->Prec = x->Prec - (size_t)x->exponent; + y->Prec = Min(y->Prec, y->MaxPrec); + y->exponent = 0; + VpSetSign(y, VpGetSign(x)); + ind_y = 0; + my = y->Prec; + ind_x = x->exponent; + while (ind_y < my) { + y->frac[ind_y] = x->frac[ind_x]; + ++ind_y; + ++ind_x; + } + VpNmlz(y); + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpFrac y=%\n", y); + VPrint(stdout, " x=%\n", x); + } +#endif /* BIGDECIMAL_DEBUG */ + return; +} + +/* + * y = x ** n + */ +VP_EXPORT int +VpPowerByInt(Real *y, Real *x, SIGNED_VALUE n) +{ + size_t s, ss; + ssize_t sign; + Real *w1 = NULL; + Real *w2 = NULL; + + if (VpIsZero(x)) { + if (n == 0) { + VpSetOne(y); + goto Exit; + } + sign = VpGetSign(x); + if (n < 0) { + n = -n; + if (sign < 0) sign = (n % 2) ? -1 : 1; + VpSetInf(y, sign); + } + else { + if (sign < 0) sign = (n % 2) ? -1 : 1; + VpSetZero(y,sign); + } + goto Exit; + } + if (VpIsNaN(x)) { + VpSetNaN(y); + goto Exit; + } + if (VpIsInf(x)) { + if (n == 0) { + VpSetOne(y); + goto Exit; + } + if (n > 0) { + VpSetInf(y, (n % 2 == 0 || VpIsPosInf(x)) ? 1 : -1); + goto Exit; + } + VpSetZero(y, (n % 2 == 0 || VpIsPosInf(x)) ? 1 : -1); + goto Exit; + } + + if (x->exponent == 1 && x->Prec == 1 && x->frac[0] == 1) { + /* abs(x) = 1 */ + VpSetOne(y); + if (BIGDECIMAL_POSITIVE_P(x)) goto Exit; + if ((n % 2) == 0) goto Exit; + VpSetSign(y, -1); + goto Exit; + } + + if (n > 0) sign = 1; + else if (n < 0) { + sign = -1; + n = -n; + } + else { + VpSetOne(y); + goto Exit; + } + + /* Allocate working variables */ + /* TODO: reconsider MaxPrec of w1 and w2 */ + w1 = NewZeroNolimit(1, (y->MaxPrec + 2) * BASE_FIG); + w2 = NewZeroNolimit(1, (w1->MaxPrec * 2 + 1) * BASE_FIG); + + /* calculation start */ + + VpAsgn(y, x, 1); + --n; + while (n > 0) { + VpAsgn(w1, x, 1); + s = 1; + while (ss = s, (s += s) <= (size_t)n) { + VpMult(w2, w1, w1); + VpAsgn(w1, w2, 1); + } + n -= (SIGNED_VALUE)ss; + VpMult(w2, y, w1); + VpAsgn(y, w2, 1); + } + if (sign < 0) { + VpDivd(w1, w2, VpConstOne, y); + VpAsgn(y, w1, 1); + } + +Exit: +#ifdef BIGDECIMAL_DEBUG + if (gfDebug) { + VPrint(stdout, "VpPowerByInt y=%\n", y); + VPrint(stdout, "VpPowerByInt x=%\n", x); + printf(" n=%"PRIdVALUE"\n", n); + } +#endif /* BIGDECIMAL_DEBUG */ + rbd_free_struct(w2); + rbd_free_struct(w1); + return 1; +} + +#ifdef BIGDECIMAL_DEBUG +int +VpVarCheck(Real * v) +/* + * Checks the validity of the Real variable v. + * [Input] + * v ... Real *, variable to be checked. + * [Returns] + * 0 ... correct v. + * other ... error + */ +{ + size_t i; + + if (v->MaxPrec == 0) { + printf("ERROR(VpVarCheck): Illegal Max. Precision(=%"PRIuSIZE")\n", + v->MaxPrec); + return 1; + } + if (v->Prec == 0 || v->Prec > v->MaxPrec) { + printf("ERROR(VpVarCheck): Illegal Precision(=%"PRIuSIZE")\n", v->Prec); + printf(" Max. Prec.=%"PRIuSIZE"\n", v->MaxPrec); + return 2; + } + for (i = 0; i < v->Prec; ++i) { + if (v->frac[i] >= BASE) { + printf("ERROR(VpVarCheck): Illegal fraction\n"); + printf(" Frac[%"PRIuSIZE"]=%"PRIuDECDIG"\n", i, v->frac[i]); + printf(" Prec. =%"PRIuSIZE"\n", v->Prec); + printf(" Exp. =%"PRIdVALUE"\n", v->exponent); + printf(" BASE =%"PRIuDECDIG"\n", BASE); + return 3; + } + } + return 0; +} +#endif /* BIGDECIMAL_DEBUG */ diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bigdecimal.h b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bigdecimal.h new file mode 100644 index 0000000..54fed81 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bigdecimal.h @@ -0,0 +1,313 @@ +/* + * + * Ruby BigDecimal(Variable decimal precision) extension library. + * + * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp) + * + */ + +#ifndef RUBY_BIG_DECIMAL_H +#define RUBY_BIG_DECIMAL_H 1 + +#define RUBY_NO_OLD_COMPATIBILITY +#include "ruby/ruby.h" +#include "missing.h" + +#ifdef HAVE_FLOAT_H +# include +#endif + +#ifdef HAVE_INT64_T +# define DECDIG uint32_t +# define DECDIG_DBL uint64_t +# define DECDIG_DBL_SIGNED int64_t +# define SIZEOF_DECDIG 4 +# define PRI_DECDIG_PREFIX "" +# ifdef PRI_LL_PREFIX +# define PRI_DECDIG_DBL_PREFIX PRI_LL_PREFIX +# else +# define PRI_DECDIG_DBL_PREFIX "l" +# endif +#else +# define DECDIG uint16_t +# define DECDIG_DBL uint32_t +# define DECDIG_DBL_SIGNED int32_t +# define SIZEOF_DECDIG 2 +# define PRI_DECDIG_PREFIX "h" +# define PRI_DECDIG_DBL_PREFIX "" +#endif + +#define PRIdDECDIG PRI_DECDIG_PREFIX"d" +#define PRIiDECDIG PRI_DECDIG_PREFIX"i" +#define PRIoDECDIG PRI_DECDIG_PREFIX"o" +#define PRIuDECDIG PRI_DECDIG_PREFIX"u" +#define PRIxDECDIG PRI_DECDIG_PREFIX"x" +#define PRIXDECDIG PRI_DECDIG_PREFIX"X" + +#define PRIdDECDIG_DBL PRI_DECDIG_DBL_PREFIX"d" +#define PRIiDECDIG_DBL PRI_DECDIG_DBL_PREFIX"i" +#define PRIoDECDIG_DBL PRI_DECDIG_DBL_PREFIX"o" +#define PRIuDECDIG_DBL PRI_DECDIG_DBL_PREFIX"u" +#define PRIxDECDIG_DBL PRI_DECDIG_DBL_PREFIX"x" +#define PRIXDECDIG_DBL PRI_DECDIG_DBL_PREFIX"X" + +#if SIZEOF_DECDIG == 4 +# define BIGDECIMAL_BASE ((DECDIG)1000000000U) +# define BIGDECIMAL_COMPONENT_FIGURES 9 +/* + * The number of components required for a 64-bit integer. + * + * INT64_MAX: 9_223372036_854775807 + * UINT64_MAX: 18_446744073_709551615 + */ +# define BIGDECIMAL_INT64_MAX_LENGTH 3 + +#elif SIZEOF_DECDIG == 2 +# define BIGDECIMAL_BASE ((DECDIG)10000U) +# define BIGDECIMAL_COMPONENT_FIGURES 4 +/* + * The number of components required for a 64-bit integer. + * + * INT64_MAX: 922_3372_0368_5477_5807 + * UINT64_MAX: 1844_6744_0737_0955_1615 + */ +# define BIGDECIMAL_INT64_MAX_LENGTH 5 + +#else +# error Unknown size of DECDIG +#endif + +#define BIGDECIMAL_DOUBLE_FIGURES (1+DBL_DIG) + +#if defined(__cplusplus) +extern "C" { +#if 0 +} /* satisfy cc-mode */ +#endif +#endif + +extern VALUE rb_cBigDecimal; + +/* + * NaN & Infinity + */ +#define SZ_NaN "NaN" +#define SZ_INF "Infinity" +#define SZ_PINF "+Infinity" +#define SZ_NINF "-Infinity" + +/* + * #define VP_EXPORT other than static to let VP_ routines + * be called from outside of this module. + */ +#define VP_EXPORT static + +/* Exception mode */ +#define VP_EXCEPTION_ALL ((unsigned short)0x00FF) +#define VP_EXCEPTION_INFINITY ((unsigned short)0x0001) +#define VP_EXCEPTION_NaN ((unsigned short)0x0002) +#define VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004) +#define VP_EXCEPTION_OVERFLOW ((unsigned short)0x0001) /* 0x0008) */ +#define VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0010) + +/* Following 2 exceptions can't controlled by user */ +#define VP_EXCEPTION_OP ((unsigned short)0x0020) + +#define BIGDECIMAL_EXCEPTION_MODE_DEFAULT 0U + +/* This is used in BigDecimal#mode */ +#define VP_ROUND_MODE ((unsigned short)0x0100) + +/* Rounding mode */ +#define VP_ROUND_UP RBD_ROUND_UP +#define VP_ROUND_DOWN RBD_ROUND_DOWN +#define VP_ROUND_HALF_UP RBD_ROUND_HALF_UP +#define VP_ROUND_HALF_DOWN RBD_ROUND_HALF_DOWN +#define VP_ROUND_CEIL RBD_ROUND_CEIL +#define VP_ROUND_FLOOR RBD_ROUND_FLOOR +#define VP_ROUND_HALF_EVEN RBD_ROUND_HALF_EVEN + +enum rbd_rounding_mode { + RBD_ROUND_UP = 1, + RBD_ROUND_DOWN = 2, + RBD_ROUND_HALF_UP = 3, + RBD_ROUND_HALF_DOWN = 4, + RBD_ROUND_CEIL = 5, + RBD_ROUND_FLOOR = 6, + RBD_ROUND_HALF_EVEN = 7, + + RBD_ROUND_DEFAULT = RBD_ROUND_HALF_UP, + RBD_ROUND_TRUNCATE = RBD_ROUND_DOWN, + RBD_ROUND_BANKER = RBD_ROUND_HALF_EVEN, + RBD_ROUND_CEILING = RBD_ROUND_CEIL +}; + +#define BIGDECIMAL_ROUNDING_MODE_DEFAULT VP_ROUND_HALF_UP + +/* Sign flag */ +#define VP_SIGN_NaN 0 /* NaN */ +#define VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */ +#define VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */ +#define VP_SIGN_POSITIVE_FINITE 2 /* Positive finite number */ +#define VP_SIGN_NEGATIVE_FINITE -2 /* Negative finite number */ +#define VP_SIGN_POSITIVE_INFINITE 3 /* Positive infinite number */ +#define VP_SIGN_NEGATIVE_INFINITE -3 /* Negative infinite number */ + +/* The size of fraction part array */ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#define FLEXIBLE_ARRAY_SIZE /* */ +#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) +#define FLEXIBLE_ARRAY_SIZE 0 +#else +#define FLEXIBLE_ARRAY_SIZE 1 +#endif + +/* + * VP representation + * r = 0.xxxxxxxxx *BASE**exponent + */ +typedef struct { + VALUE obj; /* Back pointer(VALUE) for Ruby object. */ + size_t MaxPrec; /* Maximum precision size */ + /* This is the actual size of frac[] */ + /*(frac[0] to frac[MaxPrec] are available). */ + size_t Prec; /* Current precision size. */ + /* This indicates how much the */ + /* array frac[] is actually used. */ + SIGNED_VALUE exponent; /* Exponent part. */ + short sign; /* Attributes of the value. */ + /* + * ==0 : NaN + * 1 : Positive zero + * -1 : Negative zero + * 2 : Positive number + * -2 : Negative number + * 3 : Positive infinite number + * -3 : Negative infinite number + */ + short flag; /* Not used in vp_routines,space for user. */ + DECDIG frac[FLEXIBLE_ARRAY_SIZE]; /* Array of fraction part. */ +} Real; + +/* + * ------------------ + * EXPORTables. + * ------------------ + */ + +VP_EXPORT Real *VpNewRbClass(size_t mx, char const *str, VALUE klass, bool strict_p, bool raise_exception); + +VP_EXPORT Real *VpCreateRbObject(size_t mx, const char *str, bool raise_exception); + +#define VpBaseFig() BIGDECIMAL_COMPONENT_FIGURES +#define VpDblFig() BIGDECIMAL_DOUBLE_FIGURES +#define VpBaseVal() BIGDECIMAL_BASE + +/* Zero,Inf,NaN (isinf(),isnan() used to check) */ +VP_EXPORT double VpGetDoubleNaN(void); +VP_EXPORT double VpGetDoublePosInf(void); +VP_EXPORT double VpGetDoubleNegInf(void); +VP_EXPORT double VpGetDoubleNegZero(void); + +/* These 2 functions added at v1.1.7 */ +VP_EXPORT size_t VpGetPrecLimit(void); +VP_EXPORT size_t VpSetPrecLimit(size_t n); + +/* Round mode */ +VP_EXPORT int VpIsRoundMode(unsigned short n); +VP_EXPORT unsigned short VpGetRoundMode(void); +VP_EXPORT unsigned short VpSetRoundMode(unsigned short n); + +VP_EXPORT int VpException(unsigned short f,const char *str,int always); +#if 0 /* unused */ +VP_EXPORT int VpIsNegDoubleZero(double v); +#endif +VP_EXPORT size_t VpNumOfChars(Real *vp,const char *pszFmt); +VP_EXPORT size_t VpInit(DECDIG BaseVal); +VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal, int strict_p, int exc); +VP_EXPORT size_t VpAsgn(Real *c, Real *a, int isw); +VP_EXPORT size_t VpAddSub(Real *c,Real *a,Real *b,int operation); +VP_EXPORT size_t VpMult(Real *c,Real *a,Real *b); +VP_EXPORT size_t VpDivd(Real *c,Real *r,Real *a,Real *b); +VP_EXPORT int VpComp(Real *a,Real *b); +VP_EXPORT ssize_t VpExponent10(Real *a); +VP_EXPORT void VpSzMantissa(Real *a, char *buf, size_t bufsize); +VP_EXPORT int VpToSpecialString(Real *a, char *buf, size_t bufsize, int fPlus); +VP_EXPORT void VpToString(Real *a, char *buf, size_t bufsize, size_t fFmt, int fPlus); +VP_EXPORT void VpToFString(Real *a, char *buf, size_t bufsize, size_t fFmt, int fPlus); +VP_EXPORT int VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne); +VP_EXPORT int VpVtoD(double *d, SIGNED_VALUE *e, Real *m); +VP_EXPORT void VpDtoV(Real *m,double d); +#if 0 /* unused */ +VP_EXPORT void VpItoV(Real *m,S_INT ival); +#endif +VP_EXPORT int VpSqrt(Real *y,Real *x); +VP_EXPORT int VpActiveRound(Real *y, Real *x, unsigned short f, ssize_t il); +VP_EXPORT int VpMidRound(Real *y, unsigned short f, ssize_t nf); +VP_EXPORT int VpLeftRound(Real *y, unsigned short f, ssize_t nf); +VP_EXPORT void VpFrac(Real *y, Real *x); +VP_EXPORT int VpPowerByInt(Real *y, Real *x, SIGNED_VALUE n); +#define VpPower VpPowerByInt + +/* VP constants */ +VP_EXPORT Real *VpOne(void); + +/* + * ------------------ + * MACRO definitions. + * ------------------ + */ +#define Abs(a) (((a)>= 0)?(a):(-(a))) +#define Max(a, b) (((a)>(b))?(a):(b)) +#define Min(a, b) (((a)>(b))?(b):(a)) + +#define VpMaxPrec(a) ((a)->MaxPrec) +#define VpPrec(a) ((a)->Prec) +#define VpGetFlag(a) ((a)->flag) + +/* Sign */ + +/* VpGetSign(a) returns 1,-1 if a>0,a<0 respectively */ +#define VpGetSign(a) (((a)->sign>0)?1:(-1)) +/* Change sign of a to a>0,a<0 if s = 1,-1 respectively */ +#define VpChangeSign(a,s) {if((s)>0) (a)->sign=(short)Abs((ssize_t)(a)->sign);else (a)->sign=-(short)Abs((ssize_t)(a)->sign);} +/* Sets sign of a to a>0,a<0 if s = 1,-1 respectively */ +#define VpSetSign(a,s) {if((s)>0) (a)->sign=(short)VP_SIGN_POSITIVE_FINITE;else (a)->sign=(short)VP_SIGN_NEGATIVE_FINITE;} + +/* 1 */ +#define VpSetOne(a) {(a)->Prec=(a)->exponent=(a)->frac[0]=1;(a)->sign=VP_SIGN_POSITIVE_FINITE;} + +/* ZEROs */ +#define VpIsPosZero(a) ((a)->sign==VP_SIGN_POSITIVE_ZERO) +#define VpIsNegZero(a) ((a)->sign==VP_SIGN_NEGATIVE_ZERO) +#define VpIsZero(a) (VpIsPosZero(a) || VpIsNegZero(a)) +#define VpSetPosZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_ZERO) +#define VpSetNegZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_ZERO) +#define VpSetZero(a,s) (void)(((s)>0)?VpSetPosZero(a):VpSetNegZero(a)) + +/* NaN */ +#define VpIsNaN(a) ((a)->sign==VP_SIGN_NaN) +#define VpSetNaN(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NaN) + +/* Infinity */ +#define VpIsPosInf(a) ((a)->sign==VP_SIGN_POSITIVE_INFINITE) +#define VpIsNegInf(a) ((a)->sign==VP_SIGN_NEGATIVE_INFINITE) +#define VpIsInf(a) (VpIsPosInf(a) || VpIsNegInf(a)) +#define VpIsDef(a) ( !(VpIsNaN(a)||VpIsInf(a)) ) +#define VpSetPosInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE) +#define VpSetNegInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE) +#define VpSetInf(a,s) (void)(((s)>0)?VpSetPosInf(a):VpSetNegInf(a)) +#define VpHasVal(a) (a->frac[0]) +#define VpIsOne(a) ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1)) +#define VpExponent(a) (a->exponent) +#ifdef BIGDECIMAL_DEBUG +int VpVarCheck(Real * v); +#endif /* BIGDECIMAL_DEBUG */ + +#if defined(__cplusplus) +#if 0 +{ /* satisfy cc-mode */ +#endif +} /* extern "C" { */ +#endif +#endif /* RUBY_BIG_DECIMAL_H */ diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bits.h b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bits.h new file mode 100644 index 0000000..6e1e477 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/bits.h @@ -0,0 +1,141 @@ +#ifndef BIGDECIMAL_BITS_H +#define BIGDECIMAL_BITS_H + +#include "feature.h" +#include "static_assert.h" + +#if defined(__x86_64__) && defined(HAVE_X86INTRIN_H) +# include /* for _lzcnt_u64, etc. */ +#elif defined(_MSC_VER) && defined(HAVE_INTRIN_H) +# include /* for the following intrinsics */ +#endif + +#if defined(_MSC_VER) && defined(__AVX2__) +# pragma intrinsic(__lzcnt) +# pragma intrinsic(__lzcnt64) +#endif + +#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0]))) +#define roomof(x, y) (((x) + (y) - 1) / (y)) +#define type_roomof(x, y) roomof(sizeof(x), sizeof(y)) + +#define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \ + (a) == 0 ? 0 : \ + (a) == -1 ? (b) < -(max) : \ + (a) > 0 ? \ + ((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \ + ((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b))) + +#ifdef HAVE_UINT128_T +# define bit_length(x) \ + (unsigned int) \ + (sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \ + sizeof(x) <= sizeof(int64_t) ? 64 - nlz_int64((uint64_t)(x)) : \ + 128 - nlz_int128((uint128_t)(x))) +#else +# define bit_length(x) \ + (unsigned int) \ + (sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \ + 64 - nlz_int64((uint64_t)(x))) +#endif + +static inline unsigned nlz_int32(uint32_t x); +static inline unsigned nlz_int64(uint64_t x); +#ifdef HAVE_UINT128_T +static inline unsigned nlz_int128(uint128_t x); +#endif + +static inline unsigned int +nlz_int32(uint32_t x) +{ +#if defined(_MSC_VER) && defined(__AVX2__) && defined(HAVE___LZCNT) + /* Note: It seems there is no such thing like __LZCNT__ predefined in MSVC. + * AMD CPUs have had this instruction for decades (since K10) but for + * Intel, Haswell is the oldest one. We need to use __AVX2__ for maximum + * safety. */ + return (unsigned int)__lzcnt(x); + +#elif defined(__x86_64__) && defined(__LZCNT__) && defined(HAVE__LZCNT_U32) + return (unsigned int)_lzcnt_u32(x); + +#elif defined(_MSC_VER) && defined(HAVE__BITSCANREVERSE) + unsigned long r; + return _BitScanReverse(&r, x) ? (31 - (int)r) : 32; + +#elif __has_builtin(__builtin_clz) + STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32); + return x ? (unsigned int)__builtin_clz(x) : 32; + +#else + uint32_t y; + unsigned n = 32; + y = x >> 16; if (y) {n -= 16; x = y;} + y = x >> 8; if (y) {n -= 8; x = y;} + y = x >> 4; if (y) {n -= 4; x = y;} + y = x >> 2; if (y) {n -= 2; x = y;} + y = x >> 1; if (y) {return n - 2;} + return (unsigned int)(n - x); +#endif +} + +static inline unsigned int +nlz_int64(uint64_t x) +{ +#if defined(_MSC_VER) && defined(__AVX2__) && defined(HAVE___LZCNT64) + return (unsigned int)__lzcnt64(x); + +#elif defined(__x86_64__) && defined(__LZCNT__) && defined(HAVE__LZCNT_U64) + return (unsigned int)_lzcnt_u64(x); + +#elif defined(_WIN64) && defined(_MSC_VER) && defined(HAVE__BITSCANREVERSE64) + unsigned long r; + return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64; + +#elif __has_builtin(__builtin_clzl) && __has_builtin(__builtin_clzll) && !(defined(__sun) && defined(__sparc)) + if (x == 0) { + return 64; + } + else if (sizeof(long) * CHAR_BIT == 64) { + return (unsigned int)__builtin_clzl((unsigned long)x); + } + else if (sizeof(long long) * CHAR_BIT == 64) { + return (unsigned int)__builtin_clzll((unsigned long long)x); + } + else { + /* :FIXME: Is there a way to make this branch a compile-time error? */ + __builtin_unreachable(); + } + +#else + uint64_t y; + unsigned int n = 64; + y = x >> 32; if (y) {n -= 32; x = y;} + y = x >> 16; if (y) {n -= 16; x = y;} + y = x >> 8; if (y) {n -= 8; x = y;} + y = x >> 4; if (y) {n -= 4; x = y;} + y = x >> 2; if (y) {n -= 2; x = y;} + y = x >> 1; if (y) {return n - 2;} + return (unsigned int)(n - x); + +#endif +} + +#ifdef HAVE_UINT128_T +static inline unsigned int +nlz_int128(uint128_t x) +{ + uint64_t y = (uint64_t)(x >> 64); + + if (x == 0) { + return 128; + } + else if (y == 0) { + return (unsigned int)nlz_int64(x) + 64; + } + else { + return (unsigned int)nlz_int64(y); + } +} +#endif + +#endif /* BIGDECIMAL_BITS_H */ diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/extconf.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/extconf.rb new file mode 100644 index 0000000..23904ed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/extconf.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: false +require 'mkmf' + +def have_builtin_func(name, check_expr, opt = "", &b) + checking_for checking_message(name.funcall_style, nil, opt) do + if try_compile(< +#endif + +#ifdef RBIMPL_HAS_BUILTIN +# define BIGDECIMAL_HAS_BUILTIN(...) RBIMPL_HAS_BUILTIN(__VA_ARGS__) + +#else +# /* The following section is copied from CRuby's builtin.h */ +# +# ifdef __has_builtin +# if defined(__INTEL_COMPILER) +# /* :TODO: Intel C Compiler has __has_builtin (since 19.1 maybe?), and is +# * reportedly broken. We have to skip them. However the situation can +# * change. They might improve someday. We need to revisit here later. */ +# elif defined(__GNUC__) && ! __has_builtin(__builtin_alloca) +# /* FreeBSD's defines its own *broken* version of +# * __has_builtin. Cygwin copied that content to be a victim of the +# * broken-ness. We don't take them into account. */ +# else +# define HAVE___HAS_BUILTIN 1 +# endif +# endif +# +# if defined(HAVE___HAS_BUILTIN) +# define BIGDECIMAL_HAS_BUILTIN(_) __has_builtin(_) +# +# elif defined(__GNUC__) +# define BIGDECIMAL_HAS_BUILTIN(_) BIGDECIMAL_HAS_BUILTIN_ ## _ +# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 6)) +# define BIGDECIMAL_HAS_BUILTIN___builtin_clz 1 +# define BIGDECIMAL_HAS_BUILTIN___builtin_clzl 1 +# else +# define BIGDECIMAL_HAS_BUILTIN___builtin_clz 0 +# define BIGDECIMAL_HAS_BUILTIN___builtin_clzl 0 +# endif +# elif defined(_MSC_VER) +# define BIGDECIMAL_HAS_BUILTIN(_) 0 +# +# else +# define BIGDECIMAL_HAS_BUILTIN(_) BIGDECIMAL_HAS_BUILTIN_ ## _ +# define BIGDECIMAL_HAS_BUILTIN___builtin_clz HAVE_BUILTIN___BUILTIN_CLZ +# define BIGDECIMAL_HAS_BUILTIN___builtin_clzl HAVE_BUILTIN___BUILTIN_CLZL +# endif +#endif /* RBIMPL_HAS_BUILTIN */ + +#ifndef __has_builtin +# define __has_builtin(...) BIGDECIMAL_HAS_BUILTIN(__VA_ARGS__) +#endif + +#endif /* BIGDECIMAL_HAS_FEATURE_H */ diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing.c b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing.c new file mode 100644 index 0000000..703232d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing.c @@ -0,0 +1,27 @@ +#include + +#ifdef HAVE_RUBY_ATOMIC_H +# include +#endif + +#ifdef RUBY_ATOMIC_PTR_CAS +# define ATOMIC_PTR_CAS(var, old, new) RUBY_ATOMIC_PTR_CAS(var, old, new) +#endif + +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +/* GCC warns about unknown sanitizer, which is annoying. */ +# undef NO_SANITIZE +# define NO_SANITIZE(x, y) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ + __attribute__((__no_sanitize__(x))) y; \ + _Pragma("GCC diagnostic pop") +#endif + +#undef strtod +#define strtod BigDecimal_strtod +#undef dtoa +#define dtoa BigDecimal_dtoa +#undef hdtoa +#define hdtoa BigDecimal_hdtoa +#include "missing/dtoa.c" diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing.h b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing.h new file mode 100644 index 0000000..325554b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing.h @@ -0,0 +1,196 @@ +#ifndef MISSING_H +#define MISSING_H 1 + +#if defined(__cplusplus) +extern "C" { +#if 0 +} /* satisfy cc-mode */ +#endif +#endif + +#ifdef HAVE_STDLIB_H +# include +#endif + +#ifdef HAVE_MATH_H +# include +#endif + +#ifndef RB_UNUSED_VAR +# if defined(_MSC_VER) && _MSC_VER >= 1911 +# define RB_UNUSED_VAR(x) x [[maybe_unused]] + +# elif defined(__has_cpp_attribute) && __has_cpp_attribute(maybe_unused) +# define RB_UNUSED_VAR(x) x [[maybe_unused]] + +# elif defined(__has_c_attribute) && __has_c_attribute(maybe_unused) +# define RB_UNUSED_VAR(x) x [[maybe_unused]] + +# elif defined(__GNUC__) +# define RB_UNUSED_VAR(x) x __attribute__ ((unused)) + +# else +# define RB_UNUSED_VAR(x) x +# endif +#endif /* RB_UNUSED_VAR */ + +#if defined(_MSC_VER) && _MSC_VER >= 1310 +# define HAVE___ASSUME 1 + +#elif defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1300 +# define HAVE___ASSUME 1 +#endif + +#ifndef UNREACHABLE +# if __has_builtin(__builtin_unreachable) +# define UNREACHABLE __builtin_unreachable() + +# elif defined(HAVE___ASSUME) +# define UNREACHABLE __assume(0) + +# else +# define UNREACHABLE /* unreachable */ +# endif +#endif /* UNREACHABLE */ + +/* bool */ + +#if defined(__bool_true_false_are_defined) +# /* Take that. */ + +#elif defined(HAVE_STDBOOL_H) +# include + +#else +typedef unsigned char _Bool; +# define bool _Bool +# define true ((_Bool)+1) +# define false ((_Bool)-1) +# define __bool_true_false_are_defined +#endif + +/* abs */ + +#ifndef HAVE_LABS +static inline long +labs(long const x) +{ + if (x < 0) return -x; + return x; +} +#endif + +#ifndef HAVE_LLABS +static inline LONG_LONG +llabs(LONG_LONG const x) +{ + if (x < 0) return -x; + return x; +} +#endif + +#ifdef vabs +# undef vabs +#endif +#if SIZEOF_VALUE <= SIZEOF_INT +# define vabs abs +#elif SIZEOF_VALUE <= SIZEOF_LONG +# define vabs labs +#elif SIZEOF_VALUE <= SIZEOF_LONG_LONG +# define vabs llabs +#endif + +/* finite */ + +#ifndef HAVE_FINITE +static int +finite(double) +{ + return !isnan(n) && !isinf(n); +} +#endif + +#ifndef isfinite +# ifndef HAVE_ISFINITE +# define HAVE_ISFINITE 1 +# define isfinite(x) finite(x) +# endif +#endif + +/* dtoa */ +char *BigDecimal_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve); + +/* rational */ + +#ifndef HAVE_RB_RATIONAL_NUM +static inline VALUE +rb_rational_num(VALUE rat) +{ +#ifdef RRATIONAL + return RRATIONAL(rat)->num; +#else + return rb_funcall(rat, rb_intern("numerator"), 0); +#endif +} +#endif + +#ifndef HAVE_RB_RATIONAL_DEN +static inline VALUE +rb_rational_den(VALUE rat) +{ +#ifdef RRATIONAL + return RRATIONAL(rat)->den; +#else + return rb_funcall(rat, rb_intern("denominator"), 0); +#endif +} +#endif + +/* complex */ + +#ifndef HAVE_RB_COMPLEX_REAL +static inline VALUE +rb_complex_real(VALUE cmp) +{ +#ifdef RCOMPLEX + return RCOMPLEX(cmp)->real; +#else + return rb_funcall(cmp, rb_intern("real"), 0); +#endif +} +#endif + +#ifndef HAVE_RB_COMPLEX_IMAG +static inline VALUE +rb_complex_imag(VALUE cmp) +{ +# ifdef RCOMPLEX + return RCOMPLEX(cmp)->imag; +# else + return rb_funcall(cmp, rb_intern("imag"), 0); +# endif +} +#endif + +/* st */ + +#ifndef ST2FIX +# undef RB_ST2FIX +# define RB_ST2FIX(h) LONG2FIX((long)(h)) +# define ST2FIX(h) RB_ST2FIX(h) +#endif + +/* warning */ + +#if !defined(HAVE_RB_CATEGORY_WARN) || !defined(HAVE_CONST_RB_WARN_CATEGORY_DEPRECATED) +# define rb_category_warn(category, ...) rb_warn(__VA_ARGS__) +#endif + +#if defined(__cplusplus) +#if 0 +{ /* satisfy cc-mode */ +#endif +} /* extern "C" { */ +#endif + +#endif /* MISSING_H */ diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing/dtoa.c b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing/dtoa.c new file mode 100644 index 0000000..41b0a22 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/missing/dtoa.c @@ -0,0 +1,3462 @@ +/**************************************************************** + * + * The author of this software is David M. Gay. + * + * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + * + ***************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +/* On a machine with IEEE extended-precision registers, it is + * necessary to specify double-precision (53-bit) rounding precision + * before invoking strtod or dtoa. If the machine uses (the equivalent + * of) Intel 80x87 arithmetic, the call + * _control87(PC_53, MCW_PC); + * does this with many compilers. Whether this or another call is + * appropriate depends on the compiler; for this to work, it may be + * necessary to #include "float.h" or another system-dependent header + * file. + */ + +/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. + * + * This strtod returns a nearest machine number to the input decimal + * string (or sets errno to ERANGE). With IEEE arithmetic, ties are + * broken by the IEEE round-even rule. Otherwise ties are broken by + * biased rounding (add half and chop). + * + * Inspired loosely by William D. Clinger's paper "How to Read Floating + * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * + * 1. We only require IEEE, IBM, or VAX double-precision + * arithmetic (not IEEE double-extended). + * 2. We get by with floating-point arithmetic in a case that + * Clinger missed -- when we're computing d * 10^n + * for a small integer d and the integer n is not too + * much larger than 22 (the maximum integer k for which + * we can represent 10^k exactly), we may be able to + * compute (d*10^k) * 10^(e-k) with just one roundoff. + * 3. Rather than a bit-at-a-time adjustment of the binary + * result in the hard case, we use floating-point + * arithmetic to determine the adjustment to within + * one bit; only in really hard cases do we need to + * compute a second residual. + * 4. Because of 3., we don't need a large table of powers of 10 + * for ten-to-e (just some small tables, e.g. of 10^k + * for 0 <= k <= 22). + */ + +/* + * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least + * significant byte has the lowest address. + * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most + * significant byte has the lowest address. + * #define Long int on machines with 32-bit ints and 64-bit longs. + * #define IBM for IBM mainframe-style floating-point arithmetic. + * #define VAX for VAX-style floating-point arithmetic (D_floating). + * #define No_leftright to omit left-right logic in fast floating-point + * computation of dtoa. + * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 + * and strtod and dtoa should round accordingly. + * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 + * and Honor_FLT_ROUNDS is not #defined. + * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines + * that use extended-precision instructions to compute rounded + * products and quotients) with IBM. + * #define ROUND_BIASED for IEEE-format with biased rounding. + * #define Inaccurate_Divide for IEEE-format with correctly rounded + * products but inaccurate quotients, e.g., for Intel i860. + * #define NO_LONG_LONG on machines that do not have a "long long" + * integer type (of >= 64 bits). On such machines, you can + * #define Just_16 to store 16 bits per 32-bit Long when doing + * high-precision integer arithmetic. Whether this speeds things + * up or slows things down depends on the machine and the number + * being converted. If long long is available and the name is + * something other than "long long", #define Llong to be the name, + * and if "unsigned Llong" does not work as an unsigned version of + * Llong, #define #ULLong to be the corresponding unsigned type. + * #define KR_headers for old-style C function headers. + * #define Bad_float_h if your system lacks a float.h or if it does not + * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, + * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. + * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) + * if memory is available and otherwise does something you deem + * appropriate. If MALLOC is undefined, malloc will be invoked + * directly -- and assumed always to succeed. + * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making + * memory allocations from a private pool of memory when possible. + * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, + * unless #defined to be a different length. This default length + * suffices to get rid of MALLOC calls except for unusual cases, + * such as decimal-to-binary conversion of a very long string of + * digits. The longest string dtoa can return is about 751 bytes + * long. For conversions by strtod of strings of 800 digits and + * all dtoa conversions in single-threaded executions with 8-byte + * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte + * pointers, PRIVATE_MEM >= 7112 appears adequate. + * #define INFNAN_CHECK on IEEE systems to cause strtod to check for + * Infinity and NaN (case insensitively). On some systems (e.g., + * some HP systems), it may be necessary to #define NAN_WORD0 + * appropriately -- to the most significant word of a quiet NaN. + * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) + * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, + * strtod also accepts (case insensitively) strings of the form + * NaN(x), where x is a string of hexadecimal digits and spaces; + * if there is only one string of hexadecimal digits, it is taken + * for the 52 fraction bits of the resulting NaN; if there are two + * or more strings of hex digits, the first is for the high 20 bits, + * the second and subsequent for the low 32 bits, with intervening + * white space ignored; but if this results in none of the 52 + * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0 + * and NAN_WORD1 are used instead. + * #define MULTIPLE_THREADS if the system offers preemptively scheduled + * multiple threads. In this case, you must provide (or suitably + * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed + * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed + * in pow5mult, ensures lazy evaluation of only one copy of high + * powers of 5; omitting this lock would introduce a small + * probability of wasting memory, but would otherwise be harmless.) + * You must also invoke freedtoa(s) to free the value s returned by + * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. + * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that + * avoids underflows on inputs whose result does not underflow. + * If you #define NO_IEEE_Scale on a machine that uses IEEE-format + * floating-point numbers and flushes underflows to zero rather + * than implementing gradual underflow, then you must also #define + * Sudden_Underflow. + * #define YES_ALIAS to permit aliasing certain double values with + * arrays of ULongs. This leads to slightly better code with + * some compilers and was always used prior to 19990916, but it + * is not strictly legal and can cause trouble with aggressively + * optimizing compilers (e.g., gcc 2.95.1 under -O2). + * #define USE_LOCALE to use the current locale's decimal_point value. + * #define SET_INEXACT if IEEE arithmetic is being used and extra + * computation should be done to set the inexact flag when the + * result is inexact and avoid setting inexact when the result + * is exact. In this case, dtoa.c must be compiled in + * an environment, perhaps provided by #include "dtoa.c" in a + * suitable wrapper, that defines two functions, + * int get_inexact(void); + * void clear_inexact(void); + * such that get_inexact() returns a nonzero value if the + * inexact bit is already set, and clear_inexact() sets the + * inexact bit to 0. When SET_INEXACT is #defined, strtod + * also does extra computations to set the underflow and overflow + * flags when appropriate (i.e., when the result is tiny and + * inexact or when it is a numeric value rounded to +-infinity). + * #define NO_ERRNO if strtod should not assign errno = ERANGE when + * the result overflows to +-Infinity or underflows to 0. + */ + +#ifdef WORDS_BIGENDIAN +#define IEEE_BIG_ENDIAN +#else +#define IEEE_LITTLE_ENDIAN +#endif + +#ifdef __vax__ +#define VAX +#undef IEEE_BIG_ENDIAN +#undef IEEE_LITTLE_ENDIAN +#endif + +#if defined(__arm__) && !defined(__VFP_FP__) +#define IEEE_BIG_ENDIAN +#undef IEEE_LITTLE_ENDIAN +#endif + +#undef Long +#undef ULong + +#include + +#if (INT_MAX >> 30) && !(INT_MAX >> 31) +#define Long int +#define ULong unsigned int +#elif (LONG_MAX >> 30) && !(LONG_MAX >> 31) +#define Long long int +#define ULong unsigned long int +#else +#error No 32bit integer +#endif + +#if HAVE_LONG_LONG +#define Llong LONG_LONG +#else +#define NO_LONG_LONG +#endif + +#ifdef DEBUG +#include +#define Bug(x) {fprintf(stderr, "%s\n", (x)); exit(EXIT_FAILURE);} +#endif + +#ifndef ISDIGIT +#include +#define ISDIGIT(c) isdigit(c) +#endif +#include +#include +#include + +#ifdef USE_LOCALE +#include +#endif + +#ifdef MALLOC +extern void *MALLOC(size_t); +#else +#define MALLOC xmalloc +#endif +#ifdef FREE +extern void FREE(void*); +#else +#define FREE xfree +#endif +#ifndef NO_SANITIZE +#define NO_SANITIZE(x, y) y +#endif + +#ifndef Omit_Private_Memory +#ifndef PRIVATE_MEM +#define PRIVATE_MEM 2304 +#endif +#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) +static double private_mem[PRIVATE_mem], *pmem_next = private_mem; +#endif + +#undef IEEE_Arith +#undef Avoid_Underflow +#ifdef IEEE_BIG_ENDIAN +#define IEEE_Arith +#endif +#ifdef IEEE_LITTLE_ENDIAN +#define IEEE_Arith +#endif + +#ifdef Bad_float_h + +#ifdef IEEE_Arith +#define DBL_DIG 15 +#define DBL_MAX_10_EXP 308 +#define DBL_MAX_EXP 1024 +#define FLT_RADIX 2 +#endif /*IEEE_Arith*/ + +#ifdef IBM +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 75 +#define DBL_MAX_EXP 63 +#define FLT_RADIX 16 +#define DBL_MAX 7.2370055773322621e+75 +#endif + +#ifdef VAX +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 38 +#define DBL_MAX_EXP 127 +#define FLT_RADIX 2 +#define DBL_MAX 1.7014118346046923e+38 +#endif + +#ifndef LONG_MAX +#define LONG_MAX 2147483647 +#endif + +#else /* ifndef Bad_float_h */ +#include +#endif /* Bad_float_h */ + +#include + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* satisfy cc-mode */ +#endif +#endif + +#ifndef hexdigit +static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF"; +#endif + +#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1 +Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. +#endif + +typedef union { double d; ULong L[2]; } U; + +#ifdef YES_ALIAS +typedef double double_u; +# define dval(x) (x) +# ifdef IEEE_LITTLE_ENDIAN +# define word0(x) (((ULong *)&(x))[1]) +# define word1(x) (((ULong *)&(x))[0]) +# else +# define word0(x) (((ULong *)&(x))[0]) +# define word1(x) (((ULong *)&(x))[1]) +# endif +#else +typedef U double_u; +# ifdef IEEE_LITTLE_ENDIAN +# define word0(x) ((x).L[1]) +# define word1(x) ((x).L[0]) +# else +# define word0(x) ((x).L[0]) +# define word1(x) ((x).L[1]) +# endif +# define dval(x) ((x).d) +#endif + +/* The following definition of Storeinc is appropriate for MIPS processors. + * An alternative that might be better on some machines is + * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) + */ +#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) + defined(__arm__) +#define Storeinc(a,b,c) (((unsigned short *)(a))[1] = (unsigned short)(b), \ +((unsigned short *)(a))[0] = (unsigned short)(c), (a)++) +#else +#define Storeinc(a,b,c) (((unsigned short *)(a))[0] = (unsigned short)(b), \ +((unsigned short *)(a))[1] = (unsigned short)(c), (a)++) +#endif + +/* #define P DBL_MANT_DIG */ +/* Ten_pmax = floor(P*log(2)/log(5)) */ +/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ +/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ +/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ + +#ifdef IEEE_Arith +#define Exp_shift 20 +#define Exp_shift1 20 +#define Exp_msk1 0x100000 +#define Exp_msk11 0x100000 +#define Exp_mask 0x7ff00000 +#define P 53 +#define Bias 1023 +#define Emin (-1022) +#define Exp_1 0x3ff00000 +#define Exp_11 0x3ff00000 +#define Ebits 11 +#define Frac_mask 0xfffff +#define Frac_mask1 0xfffff +#define Ten_pmax 22 +#define Bletch 0x10 +#define Bndry_mask 0xfffff +#define Bndry_mask1 0xfffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 1 +#define Tiny0 0 +#define Tiny1 1 +#define Quick_max 14 +#define Int_max 14 +#ifndef NO_IEEE_Scale +#define Avoid_Underflow +#ifdef Flush_Denorm /* debugging option */ +#undef Sudden_Underflow +#endif +#endif + +#ifndef Flt_Rounds +#ifdef FLT_ROUNDS +#define Flt_Rounds FLT_ROUNDS +#else +#define Flt_Rounds 1 +#endif +#endif /*Flt_Rounds*/ + +#ifdef Honor_FLT_ROUNDS +#define Rounding rounding +#undef Check_FLT_ROUNDS +#define Check_FLT_ROUNDS +#else +#define Rounding Flt_Rounds +#endif + +#else /* ifndef IEEE_Arith */ +#undef Check_FLT_ROUNDS +#undef Honor_FLT_ROUNDS +#undef SET_INEXACT +#undef Sudden_Underflow +#define Sudden_Underflow +#ifdef IBM +#undef Flt_Rounds +#define Flt_Rounds 0 +#define Exp_shift 24 +#define Exp_shift1 24 +#define Exp_msk1 0x1000000 +#define Exp_msk11 0x1000000 +#define Exp_mask 0x7f000000 +#define P 14 +#define Bias 65 +#define Exp_1 0x41000000 +#define Exp_11 0x41000000 +#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ +#define Frac_mask 0xffffff +#define Frac_mask1 0xffffff +#define Bletch 4 +#define Ten_pmax 22 +#define Bndry_mask 0xefffff +#define Bndry_mask1 0xffffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 4 +#define Tiny0 0x100000 +#define Tiny1 0 +#define Quick_max 14 +#define Int_max 15 +#else /* VAX */ +#undef Flt_Rounds +#define Flt_Rounds 1 +#define Exp_shift 23 +#define Exp_shift1 7 +#define Exp_msk1 0x80 +#define Exp_msk11 0x800000 +#define Exp_mask 0x7f80 +#define P 56 +#define Bias 129 +#define Exp_1 0x40800000 +#define Exp_11 0x4080 +#define Ebits 8 +#define Frac_mask 0x7fffff +#define Frac_mask1 0xffff007f +#define Ten_pmax 24 +#define Bletch 2 +#define Bndry_mask 0xffff007f +#define Bndry_mask1 0xffff007f +#define LSB 0x10000 +#define Sign_bit 0x8000 +#define Log2P 1 +#define Tiny0 0x80 +#define Tiny1 0 +#define Quick_max 15 +#define Int_max 15 +#endif /* IBM, VAX */ +#endif /* IEEE_Arith */ + +#ifndef IEEE_Arith +#define ROUND_BIASED +#endif + +#ifdef RND_PRODQUOT +#define rounded_product(a,b) ((a) = rnd_prod((a), (b))) +#define rounded_quotient(a,b) ((a) = rnd_quot((a), (b))) +extern double rnd_prod(double, double), rnd_quot(double, double); +#else +#define rounded_product(a,b) ((a) *= (b)) +#define rounded_quotient(a,b) ((a) /= (b)) +#endif + +#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) +#define Big1 0xffffffff + +#ifndef Pack_32 +#define Pack_32 +#endif + +#define FFFFFFFF 0xffffffffUL + +#ifdef NO_LONG_LONG +#undef ULLong +#ifdef Just_16 +#undef Pack_32 +/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. + * This makes some inner loops simpler and sometimes saves work + * during multiplications, but it often seems to make things slightly + * slower. Hence the default is now to store 32 bits per Long. + */ +#endif +#else /* long long available */ +#ifndef Llong +#define Llong long long +#endif +#ifndef ULLong +#define ULLong unsigned Llong +#endif +#endif /* NO_LONG_LONG */ + +#define MULTIPLE_THREADS 1 + +#ifndef MULTIPLE_THREADS +#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ +#define FREE_DTOA_LOCK(n) /*nothing*/ +#else +#define ACQUIRE_DTOA_LOCK(n) /*unused right now*/ +#define FREE_DTOA_LOCK(n) /*unused right now*/ +#endif + +#ifndef ATOMIC_PTR_CAS +#define ATOMIC_PTR_CAS(var, old, new) ((var) = (new), (old)) +#endif +#ifndef LIKELY +#define LIKELY(x) (x) +#endif +#ifndef UNLIKELY +#define UNLIKELY(x) (x) +#endif +#ifndef ASSUME +#define ASSUME(x) (void)(x) +#endif + +#define Kmax 15 + +struct Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; +}; + +typedef struct Bigint Bigint; + +static Bigint *freelist[Kmax+1]; + +static Bigint * +Balloc(int k) +{ + int x; + Bigint *rv; +#ifndef Omit_Private_Memory + size_t len; +#endif + + rv = 0; + ACQUIRE_DTOA_LOCK(0); + if (k <= Kmax) { + rv = freelist[k]; + while (rv) { + Bigint *rvn = rv; + rv = ATOMIC_PTR_CAS(freelist[k], rv, rv->next); + if (LIKELY(rvn == rv)) { + ASSUME(rv); + break; + } + } + } + if (!rv) { + x = 1 << k; +#ifdef Omit_Private_Memory + rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); +#else + len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) + /sizeof(double); + if (k <= Kmax) { + double *pnext = pmem_next; + while (pnext - private_mem + len <= PRIVATE_mem) { + double *p = pnext; + pnext = ATOMIC_PTR_CAS(pmem_next, pnext, pnext + len); + if (LIKELY(p == pnext)) { + rv = (Bigint*)pnext; + ASSUME(rv); + break; + } + } + } + if (!rv) + rv = (Bigint*)MALLOC(len*sizeof(double)); +#endif + rv->k = k; + rv->maxwds = x; + } + FREE_DTOA_LOCK(0); + rv->sign = rv->wds = 0; + return rv; +} + +static void +Bfree(Bigint *v) +{ + Bigint *vn; + if (v) { + if (v->k > Kmax) { + FREE(v); + return; + } + ACQUIRE_DTOA_LOCK(0); + do { + vn = v->next = freelist[v->k]; + } while (UNLIKELY(ATOMIC_PTR_CAS(freelist[v->k], vn, v) != vn)); + FREE_DTOA_LOCK(0); + } +} + +#define Bcopy(x,y) memcpy((char *)&(x)->sign, (char *)&(y)->sign, \ +(y)->wds*sizeof(Long) + 2*sizeof(int)) + +static Bigint * +multadd(Bigint *b, int m, int a) /* multiply by m and add a */ +{ + int i, wds; + ULong *x; +#ifdef ULLong + ULLong carry, y; +#else + ULong carry, y; +#ifdef Pack_32 + ULong xi, z; +#endif +#endif + Bigint *b1; + + wds = b->wds; + x = b->x; + i = 0; + carry = a; + do { +#ifdef ULLong + y = *x * (ULLong)m + carry; + carry = y >> 32; + *x++ = (ULong)(y & FFFFFFFF); +#else +#ifdef Pack_32 + xi = *x; + y = (xi & 0xffff) * m + carry; + z = (xi >> 16) * m + (y >> 16); + carry = z >> 16; + *x++ = (z << 16) + (y & 0xffff); +#else + y = *x * m + carry; + carry = y >> 16; + *x++ = y & 0xffff; +#endif +#endif + } while (++i < wds); + if (carry) { + if (wds >= b->maxwds) { + b1 = Balloc(b->k+1); + Bcopy(b1, b); + Bfree(b); + b = b1; + } + b->x[wds++] = (ULong)carry; + b->wds = wds; + } + return b; +} + +static Bigint * +s2b(const char *s, int nd0, int nd, ULong y9) +{ + Bigint *b; + int i, k; + Long x, y; + + x = (nd + 8) / 9; + for (k = 0, y = 1; x > y; y <<= 1, k++) ; +#ifdef Pack_32 + b = Balloc(k); + b->x[0] = y9; + b->wds = 1; +#else + b = Balloc(k+1); + b->x[0] = y9 & 0xffff; + b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; +#endif + + i = 9; + if (9 < nd0) { + s += 9; + do { + b = multadd(b, 10, *s++ - '0'); + } while (++i < nd0); + s++; + } + else + s += 10; + for (; i < nd; i++) + b = multadd(b, 10, *s++ - '0'); + return b; +} + +static int +hi0bits(register ULong x) +{ + register int k = 0; + + if (!(x & 0xffff0000)) { + k = 16; + x <<= 16; + } + if (!(x & 0xff000000)) { + k += 8; + x <<= 8; + } + if (!(x & 0xf0000000)) { + k += 4; + x <<= 4; + } + if (!(x & 0xc0000000)) { + k += 2; + x <<= 2; + } + if (!(x & 0x80000000)) { + k++; + if (!(x & 0x40000000)) + return 32; + } + return k; +} + +static int +lo0bits(ULong *y) +{ + register int k; + register ULong x = *y; + + if (x & 7) { + if (x & 1) + return 0; + if (x & 2) { + *y = x >> 1; + return 1; + } + *y = x >> 2; + return 2; + } + k = 0; + if (!(x & 0xffff)) { + k = 16; + x >>= 16; + } + if (!(x & 0xff)) { + k += 8; + x >>= 8; + } + if (!(x & 0xf)) { + k += 4; + x >>= 4; + } + if (!(x & 0x3)) { + k += 2; + x >>= 2; + } + if (!(x & 1)) { + k++; + x >>= 1; + if (!x) + return 32; + } + *y = x; + return k; +} + +static Bigint * +i2b(int i) +{ + Bigint *b; + + b = Balloc(1); + b->x[0] = i; + b->wds = 1; + return b; +} + +static Bigint * +mult(Bigint *a, Bigint *b) +{ + Bigint *c; + int k, wa, wb, wc; + ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; + ULong y; +#ifdef ULLong + ULLong carry, z; +#else + ULong carry, z; +#ifdef Pack_32 + ULong z2; +#endif +#endif + + if (a->wds < b->wds) { + c = a; + a = b; + b = c; + } + k = a->k; + wa = a->wds; + wb = b->wds; + wc = wa + wb; + if (wc > a->maxwds) + k++; + c = Balloc(k); + for (x = c->x, xa = x + wc; x < xa; x++) + *x = 0; + xa = a->x; + xae = xa + wa; + xb = b->x; + xbe = xb + wb; + xc0 = c->x; +#ifdef ULLong + for (; xb < xbe; xc0++) { + if ((y = *xb++) != 0) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * (ULLong)y + *xc + carry; + carry = z >> 32; + *xc++ = (ULong)(z & FFFFFFFF); + } while (x < xae); + *xc = (ULong)carry; + } + } +#else +#ifdef Pack_32 + for (; xb < xbe; xb++, xc0++) { + if ((y = *xb & 0xffff) != 0) { + x = xa; + xc = xc0; + carry = 0; + do { + z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; + carry = z >> 16; + z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; + carry = z2 >> 16; + Storeinc(xc, z2, z); + } while (x < xae); + *xc = (ULong)carry; + } + if ((y = *xb >> 16) != 0) { + x = xa; + xc = xc0; + carry = 0; + z2 = *xc; + do { + z = (*x & 0xffff) * y + (*xc >> 16) + carry; + carry = z >> 16; + Storeinc(xc, z, z2); + z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; + carry = z2 >> 16; + } while (x < xae); + *xc = z2; + } + } +#else + for (; xb < xbe; xc0++) { + if (y = *xb++) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * y + *xc + carry; + carry = z >> 16; + *xc++ = z & 0xffff; + } while (x < xae); + *xc = (ULong)carry; + } + } +#endif +#endif + for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; + c->wds = wc; + return c; +} + +static Bigint *p5s; + +static Bigint * +pow5mult(Bigint *b, int k) +{ + Bigint *b1, *p5, *p51; + Bigint *p5tmp; + int i; + static const int p05[3] = { 5, 25, 125 }; + + if ((i = k & 3) != 0) + b = multadd(b, p05[i-1], 0); + + if (!(k >>= 2)) + return b; + if (!(p5 = p5s)) { + /* first time */ + ACQUIRE_DTOA_LOCK(1); + if (!(p5 = p5s)) { + p5 = i2b(625); + p5->next = 0; + p5tmp = ATOMIC_PTR_CAS(p5s, NULL, p5); + if (UNLIKELY(p5tmp)) { + Bfree(p5); + p5 = p5tmp; + } + } + FREE_DTOA_LOCK(1); + } + for (;;) { + if (k & 1) { + b1 = mult(b, p5); + Bfree(b); + b = b1; + } + if (!(k >>= 1)) + break; + if (!(p51 = p5->next)) { + ACQUIRE_DTOA_LOCK(1); + if (!(p51 = p5->next)) { + p51 = mult(p5,p5); + p51->next = 0; + p5tmp = ATOMIC_PTR_CAS(p5->next, NULL, p51); + if (UNLIKELY(p5tmp)) { + Bfree(p51); + p51 = p5tmp; + } + } + FREE_DTOA_LOCK(1); + } + p5 = p51; + } + return b; +} + +static Bigint * +lshift(Bigint *b, int k) +{ + int i, k1, n, n1; + Bigint *b1; + ULong *x, *x1, *xe, z; + +#ifdef Pack_32 + n = k >> 5; +#else + n = k >> 4; +#endif + k1 = b->k; + n1 = n + b->wds + 1; + for (i = b->maxwds; n1 > i; i <<= 1) + k1++; + b1 = Balloc(k1); + x1 = b1->x; + for (i = 0; i < n; i++) + *x1++ = 0; + x = b->x; + xe = x + b->wds; +#ifdef Pack_32 + if (k &= 0x1f) { + k1 = 32 - k; + z = 0; + do { + *x1++ = *x << k | z; + z = *x++ >> k1; + } while (x < xe); + if ((*x1 = z) != 0) + ++n1; + } +#else + if (k &= 0xf) { + k1 = 16 - k; + z = 0; + do { + *x1++ = *x << k & 0xffff | z; + z = *x++ >> k1; + } while (x < xe); + if (*x1 = z) + ++n1; + } +#endif + else + do { + *x1++ = *x++; + } while (x < xe); + b1->wds = n1 - 1; + Bfree(b); + return b1; +} + +static int +cmp(Bigint *a, Bigint *b) +{ + ULong *xa, *xa0, *xb, *xb0; + int i, j; + + i = a->wds; + j = b->wds; +#ifdef DEBUG + if (i > 1 && !a->x[i-1]) + Bug("cmp called with a->x[a->wds-1] == 0"); + if (j > 1 && !b->x[j-1]) + Bug("cmp called with b->x[b->wds-1] == 0"); +#endif + if (i -= j) + return i; + xa0 = a->x; + xa = xa0 + j; + xb0 = b->x; + xb = xb0 + j; + for (;;) { + if (*--xa != *--xb) + return *xa < *xb ? -1 : 1; + if (xa <= xa0) + break; + } + return 0; +} + +NO_SANITIZE("unsigned-integer-overflow", static Bigint * diff(Bigint *a, Bigint *b)); +static Bigint * +diff(Bigint *a, Bigint *b) +{ + Bigint *c; + int i, wa, wb; + ULong *xa, *xae, *xb, *xbe, *xc; +#ifdef ULLong + ULLong borrow, y; +#else + ULong borrow, y; +#ifdef Pack_32 + ULong z; +#endif +#endif + + i = cmp(a,b); + if (!i) { + c = Balloc(0); + c->wds = 1; + c->x[0] = 0; + return c; + } + if (i < 0) { + c = a; + a = b; + b = c; + i = 1; + } + else + i = 0; + c = Balloc(a->k); + c->sign = i; + wa = a->wds; + xa = a->x; + xae = xa + wa; + wb = b->wds; + xb = b->x; + xbe = xb + wb; + xc = c->x; + borrow = 0; +#ifdef ULLong + do { + y = (ULLong)*xa++ - *xb++ - borrow; + borrow = y >> 32 & (ULong)1; + *xc++ = (ULong)(y & FFFFFFFF); + } while (xb < xbe); + while (xa < xae) { + y = *xa++ - borrow; + borrow = y >> 32 & (ULong)1; + *xc++ = (ULong)(y & FFFFFFFF); + } +#else +#ifdef Pack_32 + do { + y = (*xa & 0xffff) - (*xb & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - (*xb++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } while (xb < xbe); + while (xa < xae) { + y = (*xa & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } +#else + do { + y = *xa++ - *xb++ - borrow; + borrow = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } while (xb < xbe); + while (xa < xae) { + y = *xa++ - borrow; + borrow = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } +#endif +#endif + while (!*--xc) + wa--; + c->wds = wa; + return c; +} + +static double +ulp(double x_) +{ + register Long L; + double_u x, a; + dval(x) = x_; + + L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; +#ifndef Avoid_Underflow +#ifndef Sudden_Underflow + if (L > 0) { +#endif +#endif +#ifdef IBM + L |= Exp_msk1 >> 4; +#endif + word0(a) = L; + word1(a) = 0; +#ifndef Avoid_Underflow +#ifndef Sudden_Underflow + } + else { + L = -L >> Exp_shift; + if (L < Exp_shift) { + word0(a) = 0x80000 >> L; + word1(a) = 0; + } + else { + word0(a) = 0; + L -= Exp_shift; + word1(a) = L >= 31 ? 1 : 1 << 31 - L; + } + } +#endif +#endif + return dval(a); +} + +static double +b2d(Bigint *a, int *e) +{ + ULong *xa, *xa0, w, y, z; + int k; + double_u d; +#ifdef VAX + ULong d0, d1; +#else +#define d0 word0(d) +#define d1 word1(d) +#endif + + xa0 = a->x; + xa = xa0 + a->wds; + y = *--xa; +#ifdef DEBUG + if (!y) Bug("zero y in b2d"); +#endif + k = hi0bits(y); + *e = 32 - k; +#ifdef Pack_32 + if (k < Ebits) { + d0 = Exp_1 | y >> (Ebits - k); + w = xa > xa0 ? *--xa : 0; + d1 = y << ((32-Ebits) + k) | w >> (Ebits - k); + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + d0 = Exp_1 | y << k | z >> (32 - k); + y = xa > xa0 ? *--xa : 0; + d1 = z << k | y >> (32 - k); + } + else { + d0 = Exp_1 | y; + d1 = z; + } +#else + if (k < Ebits + 16) { + z = xa > xa0 ? *--xa : 0; + d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; + w = xa > xa0 ? *--xa : 0; + y = xa > xa0 ? *--xa : 0; + d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + w = xa > xa0 ? *--xa : 0; + k -= Ebits + 16; + d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; + y = xa > xa0 ? *--xa : 0; + d1 = w << k + 16 | y << k; +#endif +ret_d: +#ifdef VAX + word0(d) = d0 >> 16 | d0 << 16; + word1(d) = d1 >> 16 | d1 << 16; +#else +#undef d0 +#undef d1 +#endif + return dval(d); +} + +static Bigint * +d2b(double d_, int *e, int *bits) +{ + double_u d; + Bigint *b; + int de, k; + ULong *x, y, z; +#ifndef Sudden_Underflow + int i; +#endif +#ifdef VAX + ULong d0, d1; +#endif + dval(d) = d_; +#ifdef VAX + d0 = word0(d) >> 16 | word0(d) << 16; + d1 = word1(d) >> 16 | word1(d) << 16; +#else +#define d0 word0(d) +#define d1 word1(d) +#endif + +#ifdef Pack_32 + b = Balloc(1); +#else + b = Balloc(2); +#endif + x = b->x; + + z = d0 & Frac_mask; + d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ +#ifdef Sudden_Underflow + de = (int)(d0 >> Exp_shift); +#ifndef IBM + z |= Exp_msk11; +#endif +#else + if ((de = (int)(d0 >> Exp_shift)) != 0) + z |= Exp_msk1; +#endif +#ifdef Pack_32 + if ((y = d1) != 0) { + if ((k = lo0bits(&y)) != 0) { + x[0] = y | z << (32 - k); + z >>= k; + } + else + x[0] = y; +#ifndef Sudden_Underflow + i = +#endif + b->wds = (x[1] = z) ? 2 : 1; + } + else { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + x[0] = z; +#ifndef Sudden_Underflow + i = +#endif + b->wds = 1; + k += 32; + } +#else + if (y = d1) { + if (k = lo0bits(&y)) + if (k >= 16) { + x[0] = y | z << 32 - k & 0xffff; + x[1] = z >> k - 16 & 0xffff; + x[2] = z >> k; + i = 2; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16 | z << 16 - k & 0xffff; + x[2] = z >> k & 0xffff; + x[3] = z >> k+16; + i = 3; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16; + x[2] = z & 0xffff; + x[3] = z >> 16; + i = 3; + } + } + else { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + if (k >= 16) { + x[0] = z; + i = 0; + } + else { + x[0] = z & 0xffff; + x[1] = z >> 16; + i = 1; + } + k += 32; + } + while (!x[i]) + --i; + b->wds = i + 1; +#endif +#ifndef Sudden_Underflow + if (de) { +#endif +#ifdef IBM + *e = (de - Bias - (P-1) << 2) + k; + *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask); +#else + *e = de - Bias - (P-1) + k; + *bits = P - k; +#endif +#ifndef Sudden_Underflow + } + else { + *e = de - Bias - (P-1) + 1 + k; +#ifdef Pack_32 + *bits = 32*i - hi0bits(x[i-1]); +#else + *bits = (i+2)*16 - hi0bits(x[i]); +#endif + } +#endif + return b; +} +#undef d0 +#undef d1 + +static double +ratio(Bigint *a, Bigint *b) +{ + double_u da, db; + int k, ka, kb; + + dval(da) = b2d(a, &ka); + dval(db) = b2d(b, &kb); +#ifdef Pack_32 + k = ka - kb + 32*(a->wds - b->wds); +#else + k = ka - kb + 16*(a->wds - b->wds); +#endif +#ifdef IBM + if (k > 0) { + word0(da) += (k >> 2)*Exp_msk1; + if (k &= 3) + dval(da) *= 1 << k; + } + else { + k = -k; + word0(db) += (k >> 2)*Exp_msk1; + if (k &= 3) + dval(db) *= 1 << k; + } +#else + if (k > 0) + word0(da) += k*Exp_msk1; + else { + k = -k; + word0(db) += k*Exp_msk1; + } +#endif + return dval(da) / dval(db); +} + +static const double +tens[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22 +#ifdef VAX + , 1e23, 1e24 +#endif +}; + +static const double +#ifdef IEEE_Arith +bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; +static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, +#ifdef Avoid_Underflow + 9007199254740992.*9007199254740992.e-256 + /* = 2^106 * 1e-53 */ +#else + 1e-256 +#endif +}; +/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ +/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ +#define Scale_Bit 0x10 +#define n_bigtens 5 +#else +#ifdef IBM +bigtens[] = { 1e16, 1e32, 1e64 }; +static const double tinytens[] = { 1e-16, 1e-32, 1e-64 }; +#define n_bigtens 3 +#else +bigtens[] = { 1e16, 1e32 }; +static const double tinytens[] = { 1e-16, 1e-32 }; +#define n_bigtens 2 +#endif +#endif + +#ifndef IEEE_Arith +#undef INFNAN_CHECK +#endif + +#ifdef INFNAN_CHECK + +#ifndef NAN_WORD0 +#define NAN_WORD0 0x7ff80000 +#endif + +#ifndef NAN_WORD1 +#define NAN_WORD1 0 +#endif + +static int +match(const char **sp, char *t) +{ + int c, d; + const char *s = *sp; + + while (d = *t++) { + if ((c = *++s) >= 'A' && c <= 'Z') + c += 'a' - 'A'; + if (c != d) + return 0; + } + *sp = s + 1; + return 1; +} + +#ifndef No_Hex_NaN +static void +hexnan(double *rvp, const char **sp) +{ + ULong c, x[2]; + const char *s; + int havedig, udx0, xshift; + + x[0] = x[1] = 0; + havedig = xshift = 0; + udx0 = 1; + s = *sp; + while (c = *(const unsigned char*)++s) { + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'a' && c <= 'f') + c += 10 - 'a'; + else if (c >= 'A' && c <= 'F') + c += 10 - 'A'; + else if (c <= ' ') { + if (udx0 && havedig) { + udx0 = 0; + xshift = 1; + } + continue; + } + else if (/*(*/ c == ')' && havedig) { + *sp = s + 1; + break; + } + else + return; /* invalid form: don't change *sp */ + havedig = 1; + if (xshift) { + xshift = 0; + x[0] = x[1]; + x[1] = 0; + } + if (udx0) + x[0] = (x[0] << 4) | (x[1] >> 28); + x[1] = (x[1] << 4) | c; + } + if ((x[0] &= 0xfffff) || x[1]) { + word0(*rvp) = Exp_mask | x[0]; + word1(*rvp) = x[1]; + } +} +#endif /*No_Hex_NaN*/ +#endif /* INFNAN_CHECK */ + +NO_SANITIZE("unsigned-integer-overflow", double strtod(const char *s00, char **se)); +double +strtod(const char *s00, char **se) +{ +#ifdef Avoid_Underflow + int scale; +#endif + int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, + e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; + const char *s, *s0, *s1; + double aadj, adj; + double_u aadj1, rv, rv0; + Long L; + ULong y, z; + Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; +#ifdef SET_INEXACT + int inexact, oldinexact; +#endif +#ifdef Honor_FLT_ROUNDS + int rounding; +#endif +#ifdef USE_LOCALE + const char *s2; +#endif + + errno = 0; + sign = nz0 = nz = 0; + dval(rv) = 0.; + for (s = s00;;s++) + switch (*s) { + case '-': + sign = 1; + /* no break */ + case '+': + if (*++s) + goto break2; + /* no break */ + case 0: + goto ret0; + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case ' ': + continue; + default: + goto break2; + } +break2: + if (*s == '0') { + if (s[1] == 'x' || s[1] == 'X') { + s0 = ++s; + adj = 0; + aadj = 1.0; + nd0 = -4; + + if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0; + if (*s == '0') { + while (*++s == '0'); + s1 = strchr(hexdigit, *s); + } + if (s1 != NULL) { + do { + adj += aadj * ((s1 - hexdigit) & 15); + nd0 += 4; + aadj /= 16; + } while (*++s && (s1 = strchr(hexdigit, *s))); + } + + if (*s == '.') { + dsign = 1; + if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0; + if (nd0 < 0) { + while (*s == '0') { + s++; + nd0 -= 4; + } + } + for (; *s && (s1 = strchr(hexdigit, *s)); ++s) { + adj += aadj * ((s1 - hexdigit) & 15); + if ((aadj /= 16) == 0.0) { + while (strchr(hexdigit, *++s)); + break; + } + } + } + else { + dsign = 0; + } + + if (*s == 'P' || *s == 'p') { + dsign = 0x2C - *++s; /* +: 2B, -: 2D */ + if (abs(dsign) == 1) s++; + else dsign = 1; + + nd = 0; + c = *s; + if (c < '0' || '9' < c) goto ret0; + do { + nd *= 10; + nd += c; + nd -= '0'; + c = *++s; + /* Float("0x0."+("0"*267)+"1fp2095") */ + if (nd + dsign * nd0 > 2095) { + while ('0' <= c && c <= '9') c = *++s; + break; + } + } while ('0' <= c && c <= '9'); + nd0 += nd * dsign; + } + else { + if (dsign) goto ret0; + } + dval(rv) = ldexp(adj, nd0); + goto ret; + } + nz0 = 1; + while (*++s == '0') ; + if (!*s) + goto ret; + } + s0 = s; + y = z = 0; + for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < DBL_DIG + 2) + z = 10*z + c - '0'; + nd0 = nd; +#ifdef USE_LOCALE + s1 = localeconv()->decimal_point; + if (c == *s1) { + c = '.'; + if (*++s1) { + s2 = s; + for (;;) { + if (*++s2 != *s1) { + c = 0; + break; + } + if (!*++s1) { + s = s2; + break; + } + } + } + } +#endif + if (c == '.') { + if (!ISDIGIT(s[1])) + goto dig_done; + c = *++s; + if (!nd) { + for (; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for (; c >= '0' && c <= '9'; c = *++s) { +have_dig: + nz++; + if (nd > DBL_DIG * 4) { + continue; + } + if (c -= '0') { + nf += nz; + for (i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 2) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 2) + z = 10*z + c; + nz = 0; + } + } + } +dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + goto ret0; + } + s00 = s; + esign = 0; + switch (c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while (c == '0') + c = *++s; + if (c > '0' && c <= '9') { + L = c - '0'; + s1 = s; + while ((c = *++s) >= '0' && c <= '9') + L = 10*L + c - '0'; + if (s - s1 > 8 || L > 19999) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 19999; /* safe for 16 bit ints */ + else + e = (int)L; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) { +#ifdef INFNAN_CHECK + /* Check for Nan and Infinity */ + switch (c) { + case 'i': + case 'I': + if (match(&s,"nf")) { + --s; + if (!match(&s,"inity")) + ++s; + word0(rv) = 0x7ff00000; + word1(rv) = 0; + goto ret; + } + break; + case 'n': + case 'N': + if (match(&s, "an")) { + word0(rv) = NAN_WORD0; + word1(rv) = NAN_WORD1; +#ifndef No_Hex_NaN + if (*s == '(') /*)*/ + hexnan(&rv, &s); +#endif + goto ret; + } + } +#endif /* INFNAN_CHECK */ +ret0: + s = s00; + sign = 0; + } + goto ret; + } + e1 = e -= nf; + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2; + dval(rv) = y; + if (k > 9) { +#ifdef SET_INEXACT + if (k > DBL_DIG) + oldinexact = get_inexact(); +#endif + dval(rv) = tens[k - 9] * dval(rv) + z; + } + bd0 = bb = bd = bs = delta = 0; + if (nd <= DBL_DIG +#ifndef RND_PRODQUOT +#ifndef Honor_FLT_ROUNDS + && Flt_Rounds == 1 +#endif +#endif + ) { + if (!e) + goto ret; + if (e > 0) { + if (e <= Ten_pmax) { +#ifdef VAX + goto vax_ovfl_check; +#else +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + dval(rv) = -dval(rv); + sign = 0; + } +#endif + /* rv = */ rounded_product(dval(rv), tens[e]); + goto ret; +#endif + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + dval(rv) = -dval(rv); + sign = 0; + } +#endif + e -= i; + dval(rv) *= tens[i]; +#ifdef VAX + /* VAX exponent range is so narrow we must + * worry about overflow here... + */ +vax_ovfl_check: + word0(rv) -= P*Exp_msk1; + /* rv = */ rounded_product(dval(rv), tens[e]); + if ((word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) + goto ovfl; + word0(rv) += P*Exp_msk1; +#else + /* rv = */ rounded_product(dval(rv), tens[e]); +#endif + goto ret; + } + } +#ifndef Inaccurate_Divide + else if (e >= -Ten_pmax) { +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + dval(rv) = -dval(rv); + sign = 0; + } +#endif + /* rv = */ rounded_quotient(dval(rv), tens[-e]); + goto ret; + } +#endif + } + e1 += nd - k; + +#ifdef IEEE_Arith +#ifdef SET_INEXACT + inexact = 1; + if (k <= DBL_DIG) + oldinexact = get_inexact(); +#endif +#ifdef Avoid_Underflow + scale = 0; +#endif +#ifdef Honor_FLT_ROUNDS + if ((rounding = Flt_Rounds) >= 2) { + if (sign) + rounding = rounding == 2 ? 0 : 2; + else + if (rounding != 2) + rounding = 0; + } +#endif +#endif /*IEEE_Arith*/ + + /* Get starting approximation = rv * 10**e1 */ + + if (e1 > 0) { + if ((i = e1 & 15) != 0) + dval(rv) *= tens[i]; + if (e1 &= ~15) { + if (e1 > DBL_MAX_10_EXP) { +ovfl: +#ifndef NO_ERRNO + errno = ERANGE; +#endif + /* Can't trust HUGE_VAL */ +#ifdef IEEE_Arith +#ifdef Honor_FLT_ROUNDS + switch (rounding) { + case 0: /* toward 0 */ + case 3: /* toward -infinity */ + word0(rv) = Big0; + word1(rv) = Big1; + break; + default: + word0(rv) = Exp_mask; + word1(rv) = 0; + } +#else /*Honor_FLT_ROUNDS*/ + word0(rv) = Exp_mask; + word1(rv) = 0; +#endif /*Honor_FLT_ROUNDS*/ +#ifdef SET_INEXACT + /* set overflow bit */ + dval(rv0) = 1e300; + dval(rv0) *= dval(rv0); +#endif +#else /*IEEE_Arith*/ + word0(rv) = Big0; + word1(rv) = Big1; +#endif /*IEEE_Arith*/ + if (bd0) + goto retfree; + goto ret; + } + e1 >>= 4; + for (j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + dval(rv) *= bigtens[j]; + /* The last multiplication could overflow. */ + word0(rv) -= P*Exp_msk1; + dval(rv) *= bigtens[j]; + if ((z = word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-P)) + goto ovfl; + if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { + /* set to largest number */ + /* (Can't trust DBL_MAX) */ + word0(rv) = Big0; + word1(rv) = Big1; + } + else + word0(rv) += P*Exp_msk1; + } + } + else if (e1 < 0) { + e1 = -e1; + if ((i = e1 & 15) != 0) + dval(rv) /= tens[i]; + if (e1 >>= 4) { + if (e1 >= 1 << n_bigtens) + goto undfl; +#ifdef Avoid_Underflow + if (e1 & Scale_Bit) + scale = 2*P; + for (j = 0; e1 > 0; j++, e1 >>= 1) + if (e1 & 1) + dval(rv) *= tinytens[j]; + if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask) + >> Exp_shift)) > 0) { + /* scaled rv is denormal; zap j low bits */ + if (j >= 32) { + word1(rv) = 0; + if (j >= 53) + word0(rv) = (P+2)*Exp_msk1; + else + word0(rv) &= 0xffffffff << (j-32); + } + else + word1(rv) &= 0xffffffff << j; + } +#else + for (j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + dval(rv) *= tinytens[j]; + /* The last multiplication could underflow. */ + dval(rv0) = dval(rv); + dval(rv) *= tinytens[j]; + if (!dval(rv)) { + dval(rv) = 2.*dval(rv0); + dval(rv) *= tinytens[j]; +#endif + if (!dval(rv)) { +undfl: + dval(rv) = 0.; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + if (bd0) + goto retfree; + goto ret; + } +#ifndef Avoid_Underflow + word0(rv) = Tiny0; + word1(rv) = Tiny1; + /* The refinement below will clean + * this approximation up. + */ + } +#endif + } + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bd0 = s2b(s0, nd0, nd, y); + + for (;;) { + bd = Balloc(bd0->k); + Bcopy(bd, bd0); + bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ + bs = i2b(1); + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; +#ifdef Honor_FLT_ROUNDS + if (rounding != 1) + bs2++; +#endif +#ifdef Avoid_Underflow + j = bbe - scale; + i = j + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j += P - Emin; + else + j = P + 1 - bbbits; +#else /*Avoid_Underflow*/ +#ifdef Sudden_Underflow +#ifdef IBM + j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); +#else + j = P + 1 - bbbits; +#endif +#else /*Sudden_Underflow*/ + j = bbe; + i = j + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j += P - Emin; + else + j = P + 1 - bbbits; +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + bb2 += j; + bd2 += j; +#ifdef Avoid_Underflow + bd2 += scale; +#endif + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + bs = pow5mult(bs, bb5); + bb1 = mult(bs, bb); + Bfree(bb); + bb = bb1; + } + if (bb2 > 0) + bb = lshift(bb, bb2); + if (bd5 > 0) + bd = pow5mult(bd, bd5); + if (bd2 > 0) + bd = lshift(bd, bd2); + if (bs2 > 0) + bs = lshift(bs, bs2); + delta = diff(bb, bd); + dsign = delta->sign; + delta->sign = 0; + i = cmp(delta, bs); +#ifdef Honor_FLT_ROUNDS + if (rounding != 1) { + if (i < 0) { + /* Error is less than an ulp */ + if (!delta->x[0] && delta->wds <= 1) { + /* exact */ +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + if (rounding) { + if (dsign) { + adj = 1.; + goto apply_adj; + } + } + else if (!dsign) { + adj = -1.; + if (!word1(rv) + && !(word0(rv) & Frac_mask)) { + y = word0(rv) & Exp_mask; +#ifdef Avoid_Underflow + if (!scale || y > 2*P*Exp_msk1) +#else + if (y) +#endif + { + delta = lshift(delta,Log2P); + if (cmp(delta, bs) <= 0) + adj = -0.5; + } + } +apply_adj: +#ifdef Avoid_Underflow + if (scale && (y = word0(rv) & Exp_mask) + <= 2*P*Exp_msk1) + word0(adj) += (2*P+1)*Exp_msk1 - y; +#else +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= + P*Exp_msk1) { + word0(rv) += P*Exp_msk1; + dval(rv) += adj*ulp(dval(rv)); + word0(rv) -= P*Exp_msk1; + } + else +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + dval(rv) += adj*ulp(dval(rv)); + } + break; + } + adj = ratio(delta, bs); + if (adj < 1.) + adj = 1.; + if (adj <= 0x7ffffffe) { + /* adj = rounding ? ceil(adj) : floor(adj); */ + y = adj; + if (y != adj) { + if (!((rounding>>1) ^ dsign)) + y++; + adj = y; + } + } +#ifdef Avoid_Underflow + if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1) + word0(adj) += (2*P+1)*Exp_msk1 - y; +#else +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { + word0(rv) += P*Exp_msk1; + adj *= ulp(dval(rv)); + if (dsign) + dval(rv) += adj; + else + dval(rv) -= adj; + word0(rv) -= P*Exp_msk1; + goto cont; + } +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + adj *= ulp(dval(rv)); + if (dsign) + dval(rv) += adj; + else + dval(rv) -= adj; + goto cont; + } +#endif /*Honor_FLT_ROUNDS*/ + + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask +#ifdef IEEE_Arith +#ifdef Avoid_Underflow + || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1 +#else + || (word0(rv) & Exp_mask) <= Exp_msk1 +#endif +#endif + ) { +#ifdef SET_INEXACT + if (!delta->x[0] && delta->wds <= 1) + inexact = 0; +#endif + break; + } + if (!delta->x[0] && delta->wds <= 1) { + /* exact result */ +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + delta = lshift(delta,Log2P); + if (cmp(delta, bs) > 0) + goto drop_down; + break; + } + if (i == 0) { + /* exactly half-way between */ + if (dsign) { + if ((word0(rv) & Bndry_mask1) == Bndry_mask1 + && word1(rv) == ( +#ifdef Avoid_Underflow + (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1) + ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : +#endif + 0xffffffff)) { + /*boundary case -- increment exponent*/ + word0(rv) = (word0(rv) & Exp_mask) + + Exp_msk1 +#ifdef IBM + | Exp_msk1 >> 4 +#endif + ; + word1(rv) = 0; +#ifdef Avoid_Underflow + dsign = 0; +#endif + break; + } + } + else if (!(word0(rv) & Bndry_mask) && !word1(rv)) { +drop_down: + /* boundary case -- decrement exponent */ +#ifdef Sudden_Underflow /*{{*/ + L = word0(rv) & Exp_mask; +#ifdef IBM + if (L < Exp_msk1) +#else +#ifdef Avoid_Underflow + if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) +#else + if (L <= Exp_msk1) +#endif /*Avoid_Underflow*/ +#endif /*IBM*/ + goto undfl; + L -= Exp_msk1; +#else /*Sudden_Underflow}{*/ +#ifdef Avoid_Underflow + if (scale) { + L = word0(rv) & Exp_mask; + if (L <= (2*P+1)*Exp_msk1) { + if (L > (P+2)*Exp_msk1) + /* round even ==> */ + /* accept rv */ + break; + /* rv = smallest denormal */ + goto undfl; + } + } +#endif /*Avoid_Underflow*/ + L = (word0(rv) & Exp_mask) - Exp_msk1; +#endif /*Sudden_Underflow}}*/ + word0(rv) = L | Bndry_mask1; + word1(rv) = 0xffffffff; +#ifdef IBM + goto cont; +#else + break; +#endif + } +#ifndef ROUND_BIASED + if (!(word1(rv) & LSB)) + break; +#endif + if (dsign) + dval(rv) += ulp(dval(rv)); +#ifndef ROUND_BIASED + else { + dval(rv) -= ulp(dval(rv)); +#ifndef Sudden_Underflow + if (!dval(rv)) + goto undfl; +#endif + } +#ifdef Avoid_Underflow + dsign = 1 - dsign; +#endif +#endif + break; + } + if ((aadj = ratio(delta, bs)) <= 2.) { + if (dsign) + aadj = dval(aadj1) = 1.; + else if (word1(rv) || word0(rv) & Bndry_mask) { +#ifndef Sudden_Underflow + if (word1(rv) == Tiny1 && !word0(rv)) + goto undfl; +#endif + aadj = 1.; + dval(aadj1) = -1.; + } + else { + /* special case -- power of FLT_RADIX to be */ + /* rounded down... */ + + if (aadj < 2./FLT_RADIX) + aadj = 1./FLT_RADIX; + else + aadj *= 0.5; + dval(aadj1) = -aadj; + } + } + else { + aadj *= 0.5; + dval(aadj1) = dsign ? aadj : -aadj; +#ifdef Check_FLT_ROUNDS + switch (Rounding) { + case 2: /* towards +infinity */ + dval(aadj1) -= 0.5; + break; + case 0: /* towards 0 */ + case 3: /* towards -infinity */ + dval(aadj1) += 0.5; + } +#else + if (Flt_Rounds == 0) + dval(aadj1) += 0.5; +#endif /*Check_FLT_ROUNDS*/ + } + y = word0(rv) & Exp_mask; + + /* Check for overflow */ + + if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { + dval(rv0) = dval(rv); + word0(rv) -= P*Exp_msk1; + adj = dval(aadj1) * ulp(dval(rv)); + dval(rv) += adj; + if ((word0(rv) & Exp_mask) >= + Exp_msk1*(DBL_MAX_EXP+Bias-P)) { + if (word0(rv0) == Big0 && word1(rv0) == Big1) + goto ovfl; + word0(rv) = Big0; + word1(rv) = Big1; + goto cont; + } + else + word0(rv) += P*Exp_msk1; + } + else { +#ifdef Avoid_Underflow + if (scale && y <= 2*P*Exp_msk1) { + if (aadj <= 0x7fffffff) { + if ((z = (int)aadj) <= 0) + z = 1; + aadj = z; + dval(aadj1) = dsign ? aadj : -aadj; + } + word0(aadj1) += (2*P+1)*Exp_msk1 - y; + } + adj = dval(aadj1) * ulp(dval(rv)); + dval(rv) += adj; +#else +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { + dval(rv0) = dval(rv); + word0(rv) += P*Exp_msk1; + adj = dval(aadj1) * ulp(dval(rv)); + dval(rv) += adj; +#ifdef IBM + if ((word0(rv) & Exp_mask) < P*Exp_msk1) +#else + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) +#endif + { + if (word0(rv0) == Tiny0 && word1(rv0) == Tiny1) + goto undfl; + word0(rv) = Tiny0; + word1(rv) = Tiny1; + goto cont; + } + else + word0(rv) -= P*Exp_msk1; + } + else { + adj = dval(aadj1) * ulp(dval(rv)); + dval(rv) += adj; + } +#else /*Sudden_Underflow*/ + /* Compute adj so that the IEEE rounding rules will + * correctly round rv + adj in some half-way cases. + * If rv * ulp(rv) is denormalized (i.e., + * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid + * trouble from bits lost to denormalization; + * example: 1.2e-307 . + */ + if (y <= (P-1)*Exp_msk1 && aadj > 1.) { + dval(aadj1) = (double)(int)(aadj + 0.5); + if (!dsign) + dval(aadj1) = -dval(aadj1); + } + adj = dval(aadj1) * ulp(dval(rv)); + dval(rv) += adj; +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + } + z = word0(rv) & Exp_mask; +#ifndef SET_INEXACT +#ifdef Avoid_Underflow + if (!scale) +#endif + if (y == z) { + /* Can we stop now? */ + L = (Long)aadj; + aadj -= L; + /* The tolerances below are conservative. */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask) { + if (aadj < .4999999 || aadj > .5000001) + break; + } + else if (aadj < .4999999/FLT_RADIX) + break; + } +#endif +cont: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(delta); + } +#ifdef SET_INEXACT + if (inexact) { + if (!oldinexact) { + word0(rv0) = Exp_1 + (70 << Exp_shift); + word1(rv0) = 0; + dval(rv0) += 1.; + } + } + else if (!oldinexact) + clear_inexact(); +#endif +#ifdef Avoid_Underflow + if (scale) { + word0(rv0) = Exp_1 - 2*P*Exp_msk1; + word1(rv0) = 0; + dval(rv) *= dval(rv0); +#ifndef NO_ERRNO + /* try to avoid the bug of testing an 8087 register value */ + if (word0(rv) == 0 && word1(rv) == 0) + errno = ERANGE; +#endif + } +#endif /* Avoid_Underflow */ +#ifdef SET_INEXACT + if (inexact && !(word0(rv) & Exp_mask)) { + /* set underflow bit */ + dval(rv0) = 1e-300; + dval(rv0) *= dval(rv0); + } +#endif +retfree: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); +ret: + if (se) + *se = (char *)s; + return sign ? -dval(rv) : dval(rv); +} + +NO_SANITIZE("unsigned-integer-overflow", static int quorem(Bigint *b, Bigint *S)); +static int +quorem(Bigint *b, Bigint *S) +{ + int n; + ULong *bx, *bxe, q, *sx, *sxe; +#ifdef ULLong + ULLong borrow, carry, y, ys; +#else + ULong borrow, carry, y, ys; +#ifdef Pack_32 + ULong si, z, zs; +#endif +#endif + + n = S->wds; +#ifdef DEBUG + /*debug*/ if (b->wds > n) + /*debug*/ Bug("oversize b in quorem"); +#endif + if (b->wds < n) + return 0; + sx = S->x; + sxe = sx + --n; + bx = b->x; + bxe = bx + n; + q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ +#ifdef DEBUG + /*debug*/ if (q > 9) + /*debug*/ Bug("oversized quotient in quorem"); +#endif + if (q) { + borrow = 0; + carry = 0; + do { +#ifdef ULLong + ys = *sx++ * (ULLong)q + carry; + carry = ys >> 32; + y = *bx - (ys & FFFFFFFF) - borrow; + borrow = y >> 32 & (ULong)1; + *bx++ = (ULong)(y & FFFFFFFF); +#else +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) * q + carry; + zs = (si >> 16) * q + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#else + ys = *sx++ * q + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + *bx++ = y & 0xffff; +#endif +#endif + } while (sx <= sxe); + if (!*bxe) { + bx = b->x; + while (--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + if (cmp(b, S) >= 0) { + q++; + borrow = 0; + carry = 0; + bx = b->x; + sx = S->x; + do { +#ifdef ULLong + ys = *sx++ + carry; + carry = ys >> 32; + y = *bx - (ys & FFFFFFFF) - borrow; + borrow = y >> 32 & (ULong)1; + *bx++ = (ULong)(y & FFFFFFFF); +#else +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) + carry; + zs = (si >> 16) + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#else + ys = *sx++ + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + *bx++ = y & 0xffff; +#endif +#endif + } while (sx <= sxe); + bx = b->x; + bxe = bx + n; + if (!*bxe) { + while (--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + return q; +} + +#ifndef MULTIPLE_THREADS +static char *dtoa_result; +#endif + +#ifndef MULTIPLE_THREADS +static char * +rv_alloc(int i) +{ + return dtoa_result = MALLOC(i); +} +#else +#define rv_alloc(i) MALLOC(i) +#endif + +static char * +nrv_alloc(const char *s, char **rve, size_t n) +{ + char *rv, *t; + + t = rv = rv_alloc(n); + while ((*t = *s++) != 0) t++; + if (rve) + *rve = t; + return rv; +} + +#define rv_strdup(s, rve) nrv_alloc((s), (rve), strlen(s)+1) + +#ifndef MULTIPLE_THREADS +/* freedtoa(s) must be used to free values s returned by dtoa + * when MULTIPLE_THREADS is #defined. It should be used in all cases, + * but for consistency with earlier versions of dtoa, it is optional + * when MULTIPLE_THREADS is not defined. + */ + +static void +freedtoa(char *s) +{ + FREE(s); +} +#endif + +static const char INFSTR[] = "Infinity"; +static const char NANSTR[] = "NaN"; +static const char ZEROSTR[] = "0"; + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the Long + * calculation. + */ + +char * +dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve) +{ + /* Arguments ndigits, decpt, sign are similar to those + of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4,5 ==> similar to 2 and 3, respectively, but (in + round-nearest mode) with the tests of mode 0 to + possibly return a shorter string that rounds to d. + With IEEE arithmetic and compilation with + -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same + as modes 2 and 3 when FLT_ROUNDS != 1. + 6-9 ==> Debugging modes similar to mode - 4: don't try + fast floating-point estimate (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, + j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, + spec_case, try_quick, half = 0; + Long L; +#ifndef Sudden_Underflow + int denorm; + ULong x; +#endif + Bigint *b, *b1, *delta, *mlo = 0, *mhi = 0, *S; + double ds; + double_u d, d2, eps; + char *s, *s0; +#ifdef Honor_FLT_ROUNDS + int rounding; +#endif +#ifdef SET_INEXACT + int inexact, oldinexact; +#endif + + dval(d) = d_; + +#ifndef MULTIPLE_THREADS + if (dtoa_result) { + freedtoa(dtoa_result); + dtoa_result = 0; + } +#endif + + if (word0(d) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + word0(d) &= ~Sign_bit; /* clear sign bit */ + } + else + *sign = 0; + +#if defined(IEEE_Arith) + defined(VAX) +#ifdef IEEE_Arith + if ((word0(d) & Exp_mask) == Exp_mask) +#else + if (word0(d) == 0x8000) +#endif + { + /* Infinity or NaN */ + *decpt = 9999; +#ifdef IEEE_Arith + if (!word1(d) && !(word0(d) & 0xfffff)) + return rv_strdup(INFSTR, rve); +#endif + return rv_strdup(NANSTR, rve); + } +#endif +#ifdef IBM + dval(d) += 0; /* normalize */ +#endif + if (!dval(d)) { + *decpt = 1; + return rv_strdup(ZEROSTR, rve); + } + +#ifdef SET_INEXACT + try_quick = oldinexact = get_inexact(); + inexact = 1; +#endif +#ifdef Honor_FLT_ROUNDS + if ((rounding = Flt_Rounds) >= 2) { + if (*sign) + rounding = rounding == 2 ? 0 : 2; + else + if (rounding != 2) + rounding = 0; + } +#endif + + b = d2b(dval(d), &be, &bbits); +#ifdef Sudden_Underflow + i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); +#else + if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) { +#endif + dval(d2) = dval(d); + word0(d2) &= Frac_mask1; + word0(d2) |= Exp_11; +#ifdef IBM + if (j = 11 - hi0bits(word0(d2) & Frac_mask)) + dval(d2) /= 1 << j; +#endif + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) + * + * This suggests computing an approximation k to log10(d) by + * + * k = (i - Bias)*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ + + i -= Bias; +#ifdef IBM + i <<= 2; + i += j; +#endif +#ifndef Sudden_Underflow + denorm = 0; + } + else { + /* d is denormalized */ + + i = bbits + be + (Bias + (P-1) - 1); + x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32) + : word1(d) << (32 - i); + dval(d2) = x; + word0(d2) -= 31*Exp_msk1; /* adjust exponent */ + i -= (Bias + (P-1) - 1) + 1; + denorm = 1; + } +#endif + ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; + if (k >= 0 && k <= Ten_pmax) { + if (dval(d) < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + +#ifndef SET_INEXACT +#ifdef Check_FLT_ROUNDS + try_quick = Rounding == 1; +#else + try_quick = 1; +#endif +#endif /*SET_INEXACT*/ + + if (mode > 5) { + mode -= 4; + try_quick = 0; + } + leftright = 1; + ilim = ilim1 = -1; + switch (mode) { + case 0: + case 1: + i = 18; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + s = s0 = rv_alloc(i+1); + +#ifdef Honor_FLT_ROUNDS + if (mode > 1 && rounding != 1) + leftright = 0; +#endif + + if (ilim >= 0 && ilim <= Quick_max && try_quick) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + dval(d2) = dval(d); + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + dval(d) /= bigtens[n_bigtens-1]; + ieps++; + } + for (; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + dval(d) /= ds; + } + else if ((j1 = -k) != 0) { + dval(d) *= tens[j1 & 0xf]; + for (j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + dval(d) *= bigtens[i]; + } + } + if (k_check && dval(d) < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + dval(d) *= 10.; + ieps++; + } + dval(eps) = ieps*dval(d) + 7.; + word0(eps) -= (P-1)*Exp_msk1; + if (ilim == 0) { + S = mhi = 0; + dval(d) -= 5.; + if (dval(d) > dval(eps)) + goto one_digit; + if (dval(d) < -dval(eps)) + goto no_digits; + goto fast_failed; + } +#ifndef No_leftright + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + dval(eps) = 0.5/tens[ilim-1] - dval(eps); + for (i = 0;;) { + L = (int)dval(d); + dval(d) -= L; + *s++ = '0' + (int)L; + if (dval(d) < dval(eps)) + goto ret1; + if (1. - dval(d) < dval(eps)) + goto bump_up; + if (++i >= ilim) + break; + dval(eps) *= 10.; + dval(d) *= 10.; + } + } + else { +#endif + /* Generate ilim digits, then fix them up. */ + dval(eps) *= tens[ilim-1]; + for (i = 1;; i++, dval(d) *= 10.) { + L = (Long)(dval(d)); + if (!(dval(d) -= L)) + ilim = i; + *s++ = '0' + (int)L; + if (i == ilim) { + if (dval(d) > 0.5 + dval(eps)) + goto bump_up; + else if (dval(d) < 0.5 - dval(eps)) { + while (*--s == '0') ; + s++; + goto ret1; + } + half = 1; + if ((*(s-1) - '0') & 1) { + goto bump_up; + } + break; + } + } +#ifndef No_leftright + } +#endif +fast_failed: + s = s0; + dval(d) = dval(d2); + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + S = mhi = 0; + if (ilim < 0 || dval(d) <= 5*ds) + goto no_digits; + goto one_digit; + } + for (i = 1;; i++, dval(d) *= 10.) { + L = (Long)(dval(d) / ds); + dval(d) -= L*ds; +#ifdef Check_FLT_ROUNDS + /* If FLT_ROUNDS == 2, L will usually be high by 1 */ + if (dval(d) < 0) { + L--; + dval(d) += ds; + } +#endif + *s++ = '0' + (int)L; + if (!dval(d)) { +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + if (i == ilim) { +#ifdef Honor_FLT_ROUNDS + if (mode > 1) + switch (rounding) { + case 0: goto ret1; + case 2: goto bump_up; + } +#endif + dval(d) += dval(d); + if (dval(d) > ds || (dval(d) == ds && (L & 1))) { +bump_up: + while (*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + break; + } + } + goto ret1; + } + + m2 = b2; + m5 = b5; + if (leftright) { + i = +#ifndef Sudden_Underflow + denorm ? be + (Bias + (P-1) - 1 + 1) : +#endif +#ifdef IBM + 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); +#else + 1 + P - bbits; +#endif + b2 += i; + s2 += i; + mhi = i2b(1); + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + mhi = pow5mult(mhi, m5); + b1 = mult(mhi, b); + Bfree(b); + b = b1; + } + if ((j = b5 - m5) != 0) + b = pow5mult(b, j); + } + else + b = pow5mult(b, b5); + } + S = i2b(1); + if (s5 > 0) + S = pow5mult(S, s5); + + /* Check for special case that d is a normalized power of 2. */ + + spec_case = 0; + if ((mode < 2 || leftright) +#ifdef Honor_FLT_ROUNDS + && rounding == 1 +#endif + ) { + if (!word1(d) && !(word0(d) & Bndry_mask) +#ifndef Sudden_Underflow + && word0(d) & (Exp_mask & ~Exp_msk1) +#endif + ) { + /* The special case */ + b2 += Log2P; + s2 += Log2P; + spec_case = 1; + } + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ +#ifdef Pack_32 + if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) != 0) + i = 32 - i; +#else + if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) != 0) + i = 16 - i; +#endif + if (i > 4) { + i -= 4; + b2 += i; + m2 += i; + s2 += i; + } + else if (i < 4) { + i += 28; + b2 += i; + m2 += i; + s2 += i; + } + if (b2 > 0) + b = lshift(b, b2); + if (s2 > 0) + S = lshift(S, s2); + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (leftright) + mhi = multadd(mhi, 10, 0); + ilim = ilim1; + } + } + if (ilim <= 0 && (mode == 3 || mode == 5)) { + if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { + /* no digits, fcvt style */ +no_digits: + k = -1 - ndigits; + goto ret; + } +one_digit: + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) + mhi = lshift(mhi, m2); + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + mlo = mhi; + if (spec_case) { + mhi = Balloc(mhi->k); + Bcopy(mhi, mlo); + mhi = lshift(mhi, Log2P); + } + + for (i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + delta = diff(S, mhi); + j1 = delta->sign ? 1 : cmp(b, delta); + Bfree(delta); +#ifndef ROUND_BIASED + if (j1 == 0 && mode != 1 && !(word1(d) & 1) +#ifdef Honor_FLT_ROUNDS + && rounding >= 1 +#endif + ) { + if (dig == '9') + goto round_9_up; + if (j > 0) + dig++; +#ifdef SET_INEXACT + else if (!b->x[0] && b->wds <= 1) + inexact = 0; +#endif + *s++ = dig; + goto ret; + } +#endif + if (j < 0 || (j == 0 && mode != 1 +#ifndef ROUND_BIASED + && !(word1(d) & 1) +#endif + )) { + if (!b->x[0] && b->wds <= 1) { +#ifdef SET_INEXACT + inexact = 0; +#endif + goto accept_dig; + } +#ifdef Honor_FLT_ROUNDS + if (mode > 1) + switch (rounding) { + case 0: goto accept_dig; + case 2: goto keep_dig; + } +#endif /*Honor_FLT_ROUNDS*/ + if (j1 > 0) { + b = lshift(b, 1); + j1 = cmp(b, S); + if ((j1 > 0 || (j1 == 0 && (dig & 1))) && dig++ == '9') + goto round_9_up; + } +accept_dig: + *s++ = dig; + goto ret; + } + if (j1 > 0) { +#ifdef Honor_FLT_ROUNDS + if (!rounding) + goto accept_dig; +#endif + if (dig == '9') { /* possible if i == 1 */ +round_9_up: + *s++ = '9'; + goto roundoff; + } + *s++ = dig + 1; + goto ret; + } +#ifdef Honor_FLT_ROUNDS +keep_dig: +#endif + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (mlo == mhi) + mlo = mhi = multadd(mhi, 10, 0); + else { + mlo = multadd(mlo, 10, 0); + mhi = multadd(mhi, 10, 0); + } + } + } + else + for (i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (!b->x[0] && b->wds <= 1) { +#ifdef SET_INEXACT + inexact = 0; +#endif + goto ret; + } + if (i >= ilim) + break; + b = multadd(b, 10, 0); + } + + /* Round off last digit */ + +#ifdef Honor_FLT_ROUNDS + switch (rounding) { + case 0: goto trimzeros; + case 2: goto roundoff; + } +#endif + b = lshift(b, 1); + j = cmp(b, S); + if (j > 0 || (j == 0 && (dig & 1))) { + roundoff: + while (*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + if (!half || (*s - '0') & 1) + ++*s; + } + else { + while (*--s == '0') ; + } + s++; +ret: + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } +ret1: +#ifdef SET_INEXACT + if (inexact) { + if (!oldinexact) { + word0(d) = Exp_1 + (70 << Exp_shift); + word1(d) = 0; + dval(d) += 1.; + } + } + else if (!oldinexact) + clear_inexact(); +#endif + Bfree(b); + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + return s0; +} + +/*- + * Copyright (c) 2004-2008 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + */ + +#define DBL_MANH_SIZE 20 +#define DBL_MANL_SIZE 32 +#define DBL_ADJ (DBL_MAX_EXP - 2) +#define SIGFIGS ((DBL_MANT_DIG + 3) / 4 + 1) +#define dexp_get(u) ((int)(word0(u) >> Exp_shift) & ~Exp_msk1) +#define dexp_set(u,v) (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift))) +#define dmanh_get(u) ((uint32_t)(word0(u) & Frac_mask)) +#define dmanl_get(u) ((uint32_t)word1(u)) + + +/* + * This procedure converts a double-precision number in IEEE format + * into a string of hexadecimal digits and an exponent of 2. Its + * behavior is bug-for-bug compatible with dtoa() in mode 2, with the + * following exceptions: + * + * - An ndigits < 0 causes it to use as many digits as necessary to + * represent the number exactly. + * - The additional xdigs argument should point to either the string + * "0123456789ABCDEF" or the string "0123456789abcdef", depending on + * which case is desired. + * - This routine does not repeat dtoa's mistake of setting decpt + * to 9999 in the case of an infinity or NaN. INT_MAX is used + * for this purpose instead. + * + * Note that the C99 standard does not specify what the leading digit + * should be for non-zero numbers. For instance, 0x1.3p3 is the same + * as 0x2.6p2 is the same as 0x4.cp3. This implementation always makes + * the leading digit a 1. This ensures that the exponent printed is the + * actual base-2 exponent, i.e., ilogb(d). + * + * Inputs: d, xdigs, ndigits + * Outputs: decpt, sign, rve + */ +char * +hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve) +{ + U u; + char *s, *s0; + int bufsize; + uint32_t manh, manl; + + u.d = d; + if (word0(u) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + word0(u) &= ~Sign_bit; /* clear sign bit */ + } + else + *sign = 0; + + if (isinf(d)) { /* FP_INFINITE */ + *decpt = INT_MAX; + return rv_strdup(INFSTR, rve); + } + else if (isnan(d)) { /* FP_NAN */ + *decpt = INT_MAX; + return rv_strdup(NANSTR, rve); + } + else if (d == 0.0) { /* FP_ZERO */ + *decpt = 1; + return rv_strdup(ZEROSTR, rve); + } + else if (dexp_get(u)) { /* FP_NORMAL */ + *decpt = dexp_get(u) - DBL_ADJ; + } + else { /* FP_SUBNORMAL */ + u.d *= 5.363123171977039e+154 /* 0x1p514 */; + *decpt = dexp_get(u) - (514 + DBL_ADJ); + } + + if (ndigits == 0) /* dtoa() compatibility */ + ndigits = 1; + + /* + * If ndigits < 0, we are expected to auto-size, so we allocate + * enough space for all the digits. + */ + bufsize = (ndigits > 0) ? ndigits : SIGFIGS; + s0 = rv_alloc(bufsize+1); + + /* Round to the desired number of digits. */ + if (SIGFIGS > ndigits && ndigits > 0) { + float redux = 1.0f; + int offset = 4 * ndigits + DBL_MAX_EXP - 4 - DBL_MANT_DIG; + dexp_set(u, offset); + u.d += redux; + u.d -= redux; + *decpt += dexp_get(u) - offset; + } + + manh = dmanh_get(u); + manl = dmanl_get(u); + *s0 = '1'; + for (s = s0 + 1; s < s0 + bufsize; s++) { + *s = xdigs[(manh >> (DBL_MANH_SIZE - 4)) & 0xf]; + manh = (manh << 4) | (manl >> (DBL_MANL_SIZE - 4)); + manl <<= 4; + } + + /* If ndigits < 0, we are expected to auto-size the precision. */ + if (ndigits < 0) { + for (ndigits = SIGFIGS; s0[ndigits - 1] == '0'; ndigits--) + ; + } + + s = s0 + ndigits; + *s = '\0'; + if (rve != NULL) + *rve = s; + return (s0); +} + +#ifdef __cplusplus +#if 0 +{ /* satisfy cc-mode */ +#endif +} +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/static_assert.h b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/static_assert.h new file mode 100644 index 0000000..9295729 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/ext/bigdecimal/static_assert.h @@ -0,0 +1,54 @@ +#ifndef BIGDECIMAL_STATIC_ASSERT_H +#define BIGDECIMAL_STATIC_ASSERT_H + +#include "feature.h" + +#ifdef HAVE_RUBY_INTERNAL_STATIC_ASSERT_H +# include +#endif + +#ifdef RBIMPL_STATIC_ASSERT +# define STATIC_ASSERT RBIMPL_STATIC_ASSERT +#endif + +#ifndef STATIC_ASSERT +# /* The following section is copied from CRuby's static_assert.h */ + +# if defined(__cplusplus) && defined(__cpp_static_assert) +# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */ +# define BIGDECIMAL_STATIC_ASSERT0 static_assert + +# elif defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER >= 1600 +# define BIGDECIMAL_STATIC_ASSERT0 static_assert + +# elif defined(__INTEL_CXX11_MODE__) +# define BIGDECIMAL_STATIC_ASSERT0 static_assert + +# elif defined(__cplusplus) && __cplusplus >= 201103L +# define BIGDECIMAL_STATIC_ASSERT0 static_assert + +# elif defined(__cplusplus) && __has_extension(cxx_static_assert) +# define BIGDECIMAL_STATIC_ASSERT0 __extension__ static_assert + +# elif defined(__STDC_VERSION__) && __has_extension(c_static_assert) +# define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert + +# elif defined(__STDC_VERSION__) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert +#endif + +# if defined(__DOXYGEN__) +# define STATIC_ASSERT static_assert + +# elif defined(BIGDECIMAL_STATIC_ASSERT0) +# define STATIC_ASSERT(name, expr) \ + BIGDECIMAL_STATIC_ASSERT0(expr, #name ": " #expr) + +# else +# define STATIC_ASSERT(name, expr) \ + typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)] +# endif +#endif /* STATIC_ASSERT */ + + +#endif /* BIGDECIMAL_STATIC_ASSERT_H */ diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal.rb new file mode 100644 index 0000000..82b3e1b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal.rb @@ -0,0 +1,5 @@ +if RUBY_ENGINE == 'jruby' + JRuby::Util.load_ext("org.jruby.ext.bigdecimal.BigDecimalLibrary") +else + require 'bigdecimal.so' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal.so b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal.so new file mode 100755 index 0000000..f483680 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/jacobian.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/jacobian.rb new file mode 100644 index 0000000..4448024 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/jacobian.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: false + +require 'bigdecimal' + +# require 'bigdecimal/jacobian' +# +# Provides methods to compute the Jacobian matrix of a set of equations at a +# point x. In the methods below: +# +# f is an Object which is used to compute the Jacobian matrix of the equations. +# It must provide the following methods: +# +# f.values(x):: returns the values of all functions at x +# +# f.zero:: returns 0.0 +# f.one:: returns 1.0 +# f.two:: returns 2.0 +# f.ten:: returns 10.0 +# +# f.eps:: returns the convergence criterion (epsilon value) used to determine whether two values are considered equal. If |a-b| < epsilon, the two values are considered equal. +# +# x is the point at which to compute the Jacobian. +# +# fx is f.values(x). +# +module Jacobian + module_function + + # Determines the equality of two numbers by comparing to zero, or using the epsilon value + def isEqual(a,b,zero=0.0,e=1.0e-8) + aa = a.abs + bb = b.abs + if aa == zero && bb == zero then + true + else + if ((a-b)/(aa+bb)).abs < e then + true + else + false + end + end + end + + + # Computes the derivative of +f[i]+ at +x[i]+. + # +fx+ is the value of +f+ at +x+. + def dfdxi(f,fx,x,i) + nRetry = 0 + n = x.size + xSave = x[i] + ok = 0 + ratio = f.ten*f.ten*f.ten + dx = x[i].abs/ratio + dx = fx[i].abs/ratio if isEqual(dx,f.zero,f.zero,f.eps) + dx = f.one/f.ten if isEqual(dx,f.zero,f.zero,f.eps) + until ok>0 do + deriv = [] + nRetry += 1 + if nRetry > 100 + raise "Singular Jacobian matrix. No change at x[" + i.to_s + "]" + end + dx = dx*f.two + x[i] += dx + fxNew = f.values(x) + for j in 0...n do + if !isEqual(fxNew[j],fx[j],f.zero,f.eps) then + ok += 1 + deriv <<= (fxNew[j]-fx[j])/dx + else + deriv <<= f.zero + end + end + x[i] = xSave + end + deriv + end + + # Computes the Jacobian of +f+ at +x+. +fx+ is the value of +f+ at +x+. + def jacobian(f,fx,x) + n = x.size + dfdx = Array.new(n*n) + for i in 0...n do + df = dfdxi(f,fx,x,i) + for j in 0...n do + dfdx[j*n+i] = df[j] + end + end + dfdx + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/ludcmp.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/ludcmp.rb new file mode 100644 index 0000000..dd265e4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/ludcmp.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: false +require 'bigdecimal' + +# +# Solves a*x = b for x, using LU decomposition. +# +module LUSolve + module_function + + # Performs LU decomposition of the n by n matrix a. + def ludecomp(a,n,zero=0,one=1) + prec = BigDecimal.limit(nil) + ps = [] + scales = [] + for i in 0...n do # pick up largest(abs. val.) element in each row. + ps <<= i + nrmrow = zero + ixn = i*n + for j in 0...n do + biggst = a[ixn+j].abs + nrmrow = biggst if biggst>nrmrow + end + if nrmrow>zero then + scales <<= one.div(nrmrow,prec) + else + raise "Singular matrix" + end + end + n1 = n - 1 + for k in 0...n1 do # Gaussian elimination with partial pivoting. + biggst = zero; + for i in k...n do + size = a[ps[i]*n+k].abs*scales[ps[i]] + if size>biggst then + biggst = size + pividx = i + end + end + raise "Singular matrix" if biggst<=zero + if pividx!=k then + j = ps[k] + ps[k] = ps[pividx] + ps[pividx] = j + end + pivot = a[ps[k]*n+k] + for i in (k+1)...n do + psin = ps[i]*n + a[psin+k] = mult = a[psin+k].div(pivot,prec) + if mult!=zero then + pskn = ps[k]*n + for j in (k+1)...n do + a[psin+j] -= mult.mult(a[pskn+j],prec) + end + end + end + end + raise "Singular matrix" if a[ps[n1]*n+n1] == zero + ps + end + + # Solves a*x = b for x, using LU decomposition. + # + # a is a matrix, b is a constant vector, x is the solution vector. + # + # ps is the pivot, a vector which indicates the permutation of rows performed + # during LU decomposition. + def lusolve(a,b,ps,zero=0.0) + prec = BigDecimal.limit(nil) + n = ps.size + x = [] + for i in 0...n do + dot = zero + psin = ps[i]*n + for j in 0...i do + dot = a[psin+j].mult(x[j],prec) + dot + end + x <<= b[ps[i]] - dot + end + (n-1).downto(0) do |i| + dot = zero + psin = ps[i]*n + for j in (i+1)...n do + dot = a[psin+j].mult(x[j],prec) + dot + end + x[i] = (x[i]-dot).div(a[psin+i],prec) + end + x + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/math.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/math.rb new file mode 100644 index 0000000..0b9d064 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/math.rb @@ -0,0 +1,232 @@ +# frozen_string_literal: false +require 'bigdecimal' + +# +#-- +# Contents: +# sqrt(x, prec) +# sin (x, prec) +# cos (x, prec) +# atan(x, prec) Note: |x|<1, x=0.9999 may not converge. +# PI (prec) +# E (prec) == exp(1.0,prec) +# +# where: +# x ... BigDecimal number to be computed. +# |x| must be small enough to get convergence. +# prec ... Number of digits to be obtained. +#++ +# +# Provides mathematical functions. +# +# Example: +# +# require "bigdecimal/math" +# +# include BigMath +# +# a = BigDecimal((PI(100)/2).to_s) +# puts sin(a,100) # => 0.99999999999999999999......e0 +# +module BigMath + module_function + + # call-seq: + # sqrt(decimal, numeric) -> BigDecimal + # + # Computes the square root of +decimal+ to the specified number of digits of + # precision, +numeric+. + # + # BigMath.sqrt(BigDecimal('2'), 16).to_s + # #=> "0.1414213562373095048801688724e1" + # + def sqrt(x, prec) + x.sqrt(prec) + end + + # call-seq: + # sin(decimal, numeric) -> BigDecimal + # + # Computes the sine of +decimal+ to the specified number of digits of + # precision, +numeric+. + # + # If +decimal+ is Infinity or NaN, returns NaN. + # + # BigMath.sin(BigMath.PI(5)/4, 5).to_s + # #=> "0.70710678118654752440082036563292800375e0" + # + def sin(x, prec) + raise ArgumentError, "Zero or negative precision for sin" if prec <= 0 + return BigDecimal("NaN") if x.infinite? || x.nan? + n = prec + BigDecimal.double_fig + one = BigDecimal("1") + two = BigDecimal("2") + x = -x if neg = x < 0 + if x > (twopi = two * BigMath.PI(prec)) + if x > 30 + x %= twopi + else + x -= twopi while x > twopi + end + end + x1 = x + x2 = x.mult(x,n) + sign = 1 + y = x + d = y + i = one + z = one + while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0) + m = BigDecimal.double_fig if m < BigDecimal.double_fig + sign = -sign + x1 = x2.mult(x1,n) + i += two + z *= (i-one) * i + d = sign * x1.div(z,m) + y += d + end + neg ? -y : y + end + + # call-seq: + # cos(decimal, numeric) -> BigDecimal + # + # Computes the cosine of +decimal+ to the specified number of digits of + # precision, +numeric+. + # + # If +decimal+ is Infinity or NaN, returns NaN. + # + # BigMath.cos(BigMath.PI(4), 16).to_s + # #=> "-0.999999999999999999999999999999856613163740061349e0" + # + def cos(x, prec) + raise ArgumentError, "Zero or negative precision for cos" if prec <= 0 + return BigDecimal("NaN") if x.infinite? || x.nan? + n = prec + BigDecimal.double_fig + one = BigDecimal("1") + two = BigDecimal("2") + x = -x if x < 0 + if x > (twopi = two * BigMath.PI(prec)) + if x > 30 + x %= twopi + else + x -= twopi while x > twopi + end + end + x1 = one + x2 = x.mult(x,n) + sign = 1 + y = one + d = y + i = BigDecimal("0") + z = one + while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0) + m = BigDecimal.double_fig if m < BigDecimal.double_fig + sign = -sign + x1 = x2.mult(x1,n) + i += two + z *= (i-one) * i + d = sign * x1.div(z,m) + y += d + end + y + end + + # call-seq: + # atan(decimal, numeric) -> BigDecimal + # + # Computes the arctangent of +decimal+ to the specified number of digits of + # precision, +numeric+. + # + # If +decimal+ is NaN, returns NaN. + # + # BigMath.atan(BigDecimal('-1'), 16).to_s + # #=> "-0.785398163397448309615660845819878471907514682065e0" + # + def atan(x, prec) + raise ArgumentError, "Zero or negative precision for atan" if prec <= 0 + return BigDecimal("NaN") if x.nan? + pi = PI(prec) + x = -x if neg = x < 0 + return pi.div(neg ? -2 : 2, prec) if x.infinite? + return pi / (neg ? -4 : 4) if x.round(prec) == 1 + x = BigDecimal("1").div(x, prec) if inv = x > 1 + x = (-1 + sqrt(1 + x**2, prec))/x if dbl = x > 0.5 + n = prec + BigDecimal.double_fig + y = x + d = y + t = x + r = BigDecimal("3") + x2 = x.mult(x,n) + while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0) + m = BigDecimal.double_fig if m < BigDecimal.double_fig + t = -t.mult(x2,n) + d = t.div(r,m) + y += d + r += 2 + end + y *= 2 if dbl + y = pi / 2 - y if inv + y = -y if neg + y + end + + # call-seq: + # PI(numeric) -> BigDecimal + # + # Computes the value of pi to the specified number of digits of precision, + # +numeric+. + # + # BigMath.PI(10).to_s + # #=> "0.3141592653589793238462643388813853786957412e1" + # + def PI(prec) + raise ArgumentError, "Zero or negative precision for PI" if prec <= 0 + n = prec + BigDecimal.double_fig + zero = BigDecimal("0") + one = BigDecimal("1") + two = BigDecimal("2") + + m25 = BigDecimal("-0.04") + m57121 = BigDecimal("-57121") + + pi = zero + + d = one + k = one + t = BigDecimal("-80") + while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0) + m = BigDecimal.double_fig if m < BigDecimal.double_fig + t = t*m25 + d = t.div(k,m) + k = k+two + pi = pi + d + end + + d = one + k = one + t = BigDecimal("956") + while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0) + m = BigDecimal.double_fig if m < BigDecimal.double_fig + t = t.div(m57121,n) + d = t.div(k,m) + pi = pi + d + k = k+two + end + pi + end + + # call-seq: + # E(numeric) -> BigDecimal + # + # Computes e (the base of natural logarithms) to the specified number of + # digits of precision, +numeric+. + # + # BigMath.E(10).to_s + # #=> "0.271828182845904523536028752390026306410273e1" + # + def E(prec) + raise ArgumentError, "Zero or negative precision for E" if prec <= 0 + BigMath.exp(1, prec) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/newton.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/newton.rb new file mode 100644 index 0000000..85bacb7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/newton.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: false +require "bigdecimal/ludcmp" +require "bigdecimal/jacobian" + +# +# newton.rb +# +# Solves the nonlinear algebraic equation system f = 0 by Newton's method. +# This program is not dependent on BigDecimal. +# +# To call: +# n = nlsolve(f,x) +# where n is the number of iterations required, +# x is the initial value vector +# f is an Object which is used to compute the values of the equations to be solved. +# It must provide the following methods: +# +# f.values(x):: returns the values of all functions at x +# +# f.zero:: returns 0.0 +# f.one:: returns 1.0 +# f.two:: returns 2.0 +# f.ten:: returns 10.0 +# +# f.eps:: returns the convergence criterion (epsilon value) used to determine whether two values are considered equal. If |a-b| < epsilon, the two values are considered equal. +# +# On exit, x is the solution vector. +# +module Newton + include LUSolve + include Jacobian + module_function + + def norm(fv,zero=0.0) # :nodoc: + s = zero + n = fv.size + for i in 0...n do + s += fv[i]*fv[i] + end + s + end + + # See also Newton + def nlsolve(f,x) + nRetry = 0 + n = x.size + + f0 = f.values(x) + zero = f.zero + one = f.one + two = f.two + p5 = one/two + d = norm(f0,zero) + minfact = f.ten*f.ten*f.ten + minfact = one/minfact + e = f.eps + while d >= e do + nRetry += 1 + # Not yet converged. => Compute Jacobian matrix + dfdx = jacobian(f,f0,x) + # Solve dfdx*dx = -f0 to estimate dx + dx = lusolve(dfdx,f0,ludecomp(dfdx,n,zero,one),zero) + fact = two + xs = x.dup + begin + fact *= p5 + if fact < minfact then + raise "Failed to reduce function values." + end + for i in 0...n do + x[i] = xs[i] - dx[i]*fact + end + f0 = f.values(x) + dn = norm(f0,zero) + end while(dn>=d) + d = dn + end + nRetry + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/util.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/util.rb new file mode 100644 index 0000000..8bfc0ed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/lib/bigdecimal/util.rb @@ -0,0 +1,185 @@ +# frozen_string_literal: false +# +#-- +# bigdecimal/util extends various native classes to provide the #to_d method, +# and provides BigDecimal#to_d and BigDecimal#to_digits. +#++ + +require 'bigdecimal' + +class Integer < Numeric + # call-seq: + # int.to_d -> bigdecimal + # + # Returns the value of +int+ as a BigDecimal. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # 42.to_d # => 0.42e2 + # + # See also Kernel.BigDecimal. + # + def to_d + BigDecimal(self) + end +end + + +class Float < Numeric + # call-seq: + # float.to_d -> bigdecimal + # float.to_d(precision) -> bigdecimal + # + # Returns the value of +float+ as a BigDecimal. + # The +precision+ parameter is used to determine the number of + # significant digits for the result. When +precision+ is set to +0+, + # the number of digits to represent the float being converted is determined + # automatically. + # The default +precision+ is +0+. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # 0.5.to_d # => 0.5e0 + # 1.234.to_d # => 0.1234e1 + # 1.234.to_d(2) # => 0.12e1 + # + # See also Kernel.BigDecimal. + # + def to_d(precision=0) + BigDecimal(self, precision) + end +end + + +class String + # call-seq: + # str.to_d -> bigdecimal + # + # Returns the result of interpreting leading characters in +str+ + # as a BigDecimal. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # "0.5".to_d # => 0.5e0 + # "123.45e1".to_d # => 0.12345e4 + # "45.67 degrees".to_d # => 0.4567e2 + # + # See also Kernel.BigDecimal. + # + def to_d + BigDecimal.interpret_loosely(self) + end +end + + +class BigDecimal < Numeric + # call-seq: + # a.to_digits -> string + # + # Converts a BigDecimal to a String of the form "nnnnnn.mmm". + # This method is deprecated; use BigDecimal#to_s("F") instead. + # + # require 'bigdecimal/util' + # + # d = BigDecimal("3.14") + # d.to_digits # => "3.14" + # + def to_digits + if self.nan? || self.infinite? || self.zero? + self.to_s + else + i = self.to_i.to_s + _,f,_,z = self.frac.split + i + "." + ("0"*(-z)) + f + end + end + + # call-seq: + # a.to_d -> bigdecimal + # + # Returns self. + # + # require 'bigdecimal/util' + # + # d = BigDecimal("3.14") + # d.to_d # => 0.314e1 + # + def to_d + self + end +end + + +class Rational < Numeric + # call-seq: + # rat.to_d(precision) -> bigdecimal + # + # Returns the value as a BigDecimal. + # + # The required +precision+ parameter is used to determine the number of + # significant digits for the result. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # Rational(22, 7).to_d(3) # => 0.314e1 + # + # See also Kernel.BigDecimal. + # + def to_d(precision) + BigDecimal(self, precision) + end +end + + +class Complex < Numeric + # call-seq: + # cmp.to_d -> bigdecimal + # cmp.to_d(precision) -> bigdecimal + # + # Returns the value as a BigDecimal. + # + # The +precision+ parameter is required for a rational complex number. + # This parameter is used to determine the number of significant digits + # for the result. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # Complex(0.1234567, 0).to_d(4) # => 0.1235e0 + # Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1 + # + # See also Kernel.BigDecimal. + # + def to_d(*args) + BigDecimal(self) unless self.imag.zero? # to raise eerror + + if args.length == 0 + case self.real + when Rational + BigDecimal(self.real) # to raise error + end + end + self.real.to_d(*args) + end +end + + +class NilClass + # call-seq: + # nil.to_d -> bigdecimal + # + # Returns nil represented as a BigDecimal. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # nil.to_d # => 0.0 + # + def to_d + BigDecimal(0) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/linear.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/linear.rb new file mode 100644 index 0000000..516c247 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/linear.rb @@ -0,0 +1,74 @@ +#!/usr/local/bin/ruby +# frozen_string_literal: false + +# +# linear.rb +# +# Solves linear equation system(A*x = b) by LU decomposition method. +# where A is a coefficient matrix,x is an answer vector,b is a constant vector. +# +# USAGE: +# ruby linear.rb [input file solved] +# + +# :stopdoc: +require "bigdecimal" +require "bigdecimal/ludcmp" + +# +# NOTE: +# Change following BigDecimal.limit() if needed. +BigDecimal.limit(100) +# + +include LUSolve +def rd_order(na) + printf("Number of equations ?") if(na <= 0) + n = ARGF.gets().to_i +end + +na = ARGV.size +zero = BigDecimal("0.0") +one = BigDecimal("1.0") + +while (n=rd_order(na))>0 + a = [] + as= [] + b = [] + if na <= 0 + # Read data from console. + printf("\nEnter coefficient matrix element A[i,j]\n") + for i in 0...n do + for j in 0...n do + printf("A[%d,%d]? ",i,j); s = ARGF.gets + a << BigDecimal(s) + as << BigDecimal(s) + end + printf("Contatant vector element b[%d] ? ",i) + b << BigDecimal(ARGF.gets) + end + else + # Read data from specified file. + printf("Coefficient matrix and constant vector.\n") + for i in 0...n do + s = ARGF.gets + printf("%d) %s",i,s) + s = s.split + for j in 0...n do + a << BigDecimal(s[j]) + as << BigDecimal(s[j]) + end + b << BigDecimal(s[n]) + end + end + x = lusolve(a,b,ludecomp(a,n,zero,one),zero) + printf("Answer(x[i] & (A*x-b)[i]) follows\n") + for i in 0...n do + printf("x[%d]=%s ",i,x[i].to_s) + s = zero + for j in 0...n do + s = s + as[i*n+j]*x[j] + end + printf(" & %s\n",(s-b[i]).to_s) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/nlsolve.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/nlsolve.rb new file mode 100644 index 0000000..c2227da --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/nlsolve.rb @@ -0,0 +1,40 @@ +#!/usr/local/bin/ruby +# frozen_string_literal: false + +# +# nlsolve.rb +# An example for solving nonlinear algebraic equation system. +# + +require "bigdecimal" +require "bigdecimal/newton" +include Newton + +class Function # :nodoc: all + def initialize() + @zero = BigDecimal("0.0") + @one = BigDecimal("1.0") + @two = BigDecimal("2.0") + @ten = BigDecimal("10.0") + @eps = BigDecimal("1.0e-16") + end + def zero;@zero;end + def one ;@one ;end + def two ;@two ;end + def ten ;@ten ;end + def eps ;@eps ;end + def values(x) # <= defines functions solved + f = [] + f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0 + f2 = x[0] - x[1] # f2 = x - y => 0 + f <<= f1 + f <<= f2 + f + end +end + +f = BigDecimal.limit(100) +f = Function.new +x = [f.zero,f.zero] # Initial values +n = nlsolve(f,x) +p x diff --git a/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/pi.rb b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/pi.rb new file mode 100644 index 0000000..ea96638 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/bigdecimal-3.1.8/sample/pi.rb @@ -0,0 +1,21 @@ +#!/usr/local/bin/ruby +# frozen_string_literal: false + +# +# pi.rb +# +# Calculates 3.1415.... (the number of times that a circle's diameter +# will fit around the circle) using J. Machin's formula. +# + +require "bigdecimal" +require "bigdecimal/math.rb" + +include BigMath + +if ARGV.size == 1 + print "PI("+ARGV[0]+"):\n" + p PI(ARGV[0].to_i) +else + print "TRY: ruby pi.rb 1000 \n" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/Gemfile b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/Gemfile new file mode 100644 index 0000000..044fba3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/Gemfile @@ -0,0 +1,11 @@ +source "https://rubygems.org" +gemspec + +gem "rake" +group :development do + gem "rspec-helpers", :require => false + gem "luna-rspec-formatters", :require => false + gem "pry", :require => false unless ENV[ + "CI" + ] +end diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/History.markdown b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/History.markdown new file mode 100644 index 0000000..bac4270 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/History.markdown @@ -0,0 +1,25 @@ +## 1.1.0 / 2016-06-28 + +### Minor Enhancements + +* Support jruby (#8) + +## 1.0.0 / 2016-04-28 + +### Major enhancements + +- Merge Simple::ANSI and Colorator. (#7) + +### Minor Enhancements + +- Delete unnecessary `Symbol#to_sym` (#2) +- Change argument name of `Enumerator#each` for better code legibility (#3) + +### Development Fixes + +- Convert to new RSpec expectation syntax (#1) +- Fix `String#blue` result in README (#4) + +## 0.1 / 2013-04-13 + +Birthday! diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/LICENSE b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/LICENSE new file mode 100644 index 0000000..b3b6be9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) Parker Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/README.markdown b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/README.markdown new file mode 100644 index 0000000..9cf886d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/README.markdown @@ -0,0 +1,47 @@ +# colorator + +Colorize your text for the terminal + +[![Build Status](https://travis-ci.org/octopress/colorator.png?branch=master)](https://travis-ci.org/octopress/colorator) + +## Example + +```ruby +"this string".red +# => \e[31mthis string\e[0m +"my string".blue +# => \e[34mmy string\e[0m +# etc... +``` + +## Supported Colors + +- `red` +- `black` +- `green` +- `yellow` +- `magenta` +- `white` +- `blue` +- `cyan` +- `bold` + +## Other supported Ansi methods + +- `clear_line` +- `has_ansi?`, `has_color?` +- `strip_ansi`, `strip_color` +- `reset_ansi`, `reset_color` +- `clear_screen` +- `ansi_jump` + +## Why + +There are a bunch of gems that provide functionality like this, but none have +as simple an API as this. Just call `"string".color` and your text will be +colorized. + +## License + +MIT. Written as a single Ruby file by Brandon Mathis, converted into a gem by +Parker Moore. diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/Rakefile b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/Rakefile new file mode 100644 index 0000000..b7e9ed5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/Rakefile @@ -0,0 +1,6 @@ +require "bundler/gem_tasks" +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/colorator.gemspec b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/colorator.gemspec new file mode 100644 index 0000000..a4bd0cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/colorator.gemspec @@ -0,0 +1,23 @@ +# coding: utf-8 + +require File.expand_path('lib/colorator.rb', __dir__) + +Gem::Specification.new do |spec| + spec.name = "colorator" + spec.summary = "Colorize your text in the terminal." + spec.version = Colorator::VERSION + spec.authors = ["Parker Moore", "Brandon Mathis"] + spec.email = ["parkrmoore@gmail.com", "brandon@imathis.com"] + spec.homepage = "https://github.com/octopress/colorator" + spec.licenses = ["MIT"] + + all = `git ls-files -z`.split("\x0").reject { |f| f.start_with?(".") } + spec.files = all.select { |f| File.basename(f) == f || f =~ %r{^(bin|lib)/} } + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + spec.extra_rdoc_files = ["README.markdown", "LICENSE"] + spec.rdoc_options = ["--charset=UTF-8"] + + spec.add_development_dependency "rspec", "~> 3.1" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/lib/colorator.rb b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/lib/colorator.rb new file mode 100644 index 0000000..107f6e3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/lib/colorator.rb @@ -0,0 +1,111 @@ +$:.unshift File.dirname(__FILE__) + +module Colorator + module_function + VERSION = "1.1.0" + + # -------------------------------------------------------------------------- + + ANSI_MATCHR = /\x1b.*?[jkmsuABGKH]/ + ANSI_COLORS = { + :black => 30, + :red => 31, + :green => 32, + :yellow => 33, + :blue => 34, + :magenta => 35, + :cyan => 36, + :white => 37, + :bold => 1 + } + + # -------------------------------------------------------------------------- + # Allows you to check if a string currently has ansi. + # -------------------------------------------------------------------------- + + def has_ansi?(str) + str.match(ANSI_MATCHR).is_a?( + MatchData + ) + end + + # -------------------------------------------------------------------------- + # Jump the cursor, moving it up and then back down to it's spot, allowing + # you to do fancy things like multiple output (downloads) the way that Docker + # does them in an async way without breaking term. + # -------------------------------------------------------------------------- + + def ansi_jump(str, num) + "\x1b[#{num}A#{clear_line(str)}\x1b[#{ + num + }B" + end + + # -------------------------------------------------------------------------- + + def reset_ansi(str = "") + "\x1b[0m#{ + str + }" + end + + # -------------------------------------------------------------------------- + + def clear_line(str = "") + "\x1b[2K\r#{ + str + }" + end + + # -------------------------------------------------------------------------- + # Strip ANSI from the current string, making it just a normal string. + # -------------------------------------------------------------------------- + + def strip_ansi(str) + str.gsub( + ANSI_MATCHR, "" + ) + end + + # -------------------------------------------------------------------------- + # Clear the screen's current view, so the user gets a clean output. + # -------------------------------------------------------------------------- + + def clear_screen(str = "") + "\x1b[H\x1b[2J#{ + str + }" + end + + # -------------------------------------------------------------------------- + + def colorize(str = "", color) + "\x1b[#{color}m#{str}\x1b[0m" + end + + # -------------------------------------------------------------------------- + + Colorator::ANSI_COLORS.each do |color, code| + define_singleton_method color do |str| + colorize( + str, code + ) + end + end + + # -------------------------------------------------------------------------- + + class << self + alias reset_color reset_ansi + alias strip_color strip_ansi + alias has_color? has_ansi? + end + + # -------------------------------------------------------------------------- + + CORE_METHODS = ( + public_methods - Object.methods + ) +end + +require "colorator/core_ext" diff --git a/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/lib/colorator/core_ext.rb b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/lib/colorator/core_ext.rb new file mode 100644 index 0000000..f2e0bf0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/colorator-1.1.0/lib/colorator/core_ext.rb @@ -0,0 +1,9 @@ +class String + Colorator::CORE_METHODS.each do |method| + define_method method do |*args| + Colorator.public_send(method, + self, *args + ) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/CHANGELOG.md b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/CHANGELOG.md new file mode 100644 index 0000000..2c0375c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/CHANGELOG.md @@ -0,0 +1,593 @@ +## Current + +## Release v1.3.4 (10 August 2024) + +* (#1060) Fix bug with return value of `Concurrent.available_processor_count` when `cpu.cfs_quota_us` is -1. +* (#1058) Add `Concurrent.cpu_shares` that is cgroups aware. + +## Release v1.3.3 (9 June 2024) + +* (#1053) Improve the speed of `Concurrent.physical_processor_count` on Windows. + +## Release v1.3.2, edge v0.7.1 (7 June 2024) + +concurrent-ruby: + +* (#1051) Remove dependency on `win32ole`. + +concurrent-ruby-edge: + +* (#1052) Fix dependency on `concurrent-ruby` to allow the latest release. + +## Release v1.3.1 (29 May 2024) + +* Release 1.3.0 was broken when pushed to RubyGems. 1.3.1 is a packaging fix. + +## Release v1.3.0 (28 May 2024) + +* (#1042) Align Java Executor Service behavior for `shuttingdown?`, `shutdown?` +* (#1038) Add `Concurrent.available_processor_count` that is cgroups aware. + +## Release v1.2.3 (16 Jan 2024) + +* See [the GitHub release](https://github.com/ruby-concurrency/concurrent-ruby/releases/tag/v1.2.3) for details. + +## Release v1.2.2 (24 Feb 2023) + +* (#993) Fix arguments passed to `Concurrent::Map`'s `default_proc`. + +## Release v1.2.1 (24 Feb 2023) + +* (#990) Add missing `require 'fiber'` for `FiberLocalVar`. +* (#989) Optimize `Concurrent::Map#[]` on CRuby by letting the backing Hash handle the `default_proc`. + +## Release v1.2.0 (23 Jan 2023) + +* (#962) Fix ReentrantReadWriteLock to use the same granularity for locals as for Mutex it uses. +* (#983) Add FiberLocalVar +* (#934) concurrent-ruby now supports requiring individual classes (public classes listed in the docs), e.g., `require 'concurrent/map'` +* (#976) Let `Promises.any_fulfilled_future` take an `Event` +* Improve documentation of various classes +* (#975) Set the Ruby compatibility version at 2.3 +* (#972) Remove Rubinius-related code + +## Release v1.1.10 (22 Mar 2022) + +concurrent-ruby: + +* (#951) Set the Ruby compatibility version at 2.2 +* (#939, #933) The `caller_runs` fallback policy no longer blocks reads from the job queue by worker threads +* (#938, #761, #652) You can now explicitly `prune_pool` a thread pool (Sylvain Joyeux) +* (#937, #757, #670) We switched the Yahoo stock API for demos to Alpha Vantage (Gustavo Caso) +* (#932, #931) We changed how `SafeTaskExecutor` handles local jump errors (Aaron Jensen) +* (#927) You can use keyword arguments in your initialize when using `Async` (Matt Larraz) +* (#926, #639) We removed timeout from `TimerTask` because it wasn't sound, and now it's a no-op with a warning (Jacob Atzen) +* (#919) If you double-lock a re-entrant read-write lock, we promote to locked for writing (zp yuan) +* (#915) `monotonic_time` now accepts an optional unit parameter, as Ruby's `clock_gettime` (Jean Boussier) + +## Release v1.1.9 (5 Jun 2021) + +concurrent-ruby: + +* (#866) Child promise state not set to :pending immediately after #execute when parent has completed +* (#905, #872) Fix RubyNonConcurrentPriorityQueue#delete method +* (2df0337d) Make sure locks are not shared on shared when objects are dup/cloned +* (#900, #906, #796, #847, #911) Fix Concurrent::Set tread-safety issues on CRuby +* (#907) Add new ConcurrentMap backend for TruffleRuby + +## Release v1.1.8 (20 January 2021) + +concurrent-ruby: + +* (#885) Fix race condition in TVar for stale reads +* (#884) RubyThreadLocalVar: Do not iterate over hash which might conflict with new pair addition + +## Release v1.1.7 (6 August 2020) + +concurrent-ruby: + +* (#879) Consider falsy value on `Concurrent::Map#compute_if_absent` for fast non-blocking path +* (#876) Reset Async queue on forking, makes Async fork-safe +* (#856) Avoid running problematic code in RubyThreadLocalVar on MRI that occasionally results in segfault +* (#853) Introduce ThreadPoolExecutor without a Queue + +## Release v1.1.6, edge v0.6.0 (10 Feb 2020) + +concurrent-ruby: + +* (#841) Concurrent.disable_at_exit_handlers! is no longer needed and was deprecated. +* (#841) AbstractExecutorService#auto_terminate= was deprecated and has no effect. + Set :auto_terminate option instead when executor is initialized. + +## Release v1.1.6.pre1, edge v0.6.0.pre1 (26 Jan 2020) + +concurrent-ruby: + +* (#828) Allow to name executors, the name is also used to name their threads +* (#838) Implement #dup and #clone for structs +* (#821) Safer finalizers for thread local variables +* Documentation fixes +* (#814) Use Ruby's Etc.nprocessors if available +* (#812) Fix directory structure not to mess with packaging tools +* (#840) Fix termination of pools on JRuby + +concurrent-ruby-edge: + +* Add WrappingExecutor (#830) + +## Release v1.1.5, edge v0.5.0 (10 Mar 2019) + +concurrent-ruby: + +* fix potential leak of context on JRuby and Java 7 + +concurrent-ruby-edge: + +* Add finalized Concurrent::Cancellation +* Add finalized Concurrent::Throttle +* Add finalized Concurrent::Promises::Channel +* Add new Concurrent::ErlangActor + +## Release v1.1.4 (14 Dec 2018) + +* (#780) Remove java_alias of 'submit' method of Runnable to let executor service work on java 11 +* (#776) Fix NameError on defining a struct with a name which is already taken in an ancestor + +## Release v1.1.3 (7 Nov 2018) + +* (#775) fix partial require of the gem (although not officially supported) + +## Release v1.1.2 (6 Nov 2018) + +* (#773) more defensive 1.9.3 support + +## Release v1.1.1, edge v0.4.1 (1 Nov 2018) + +* (#768) add support for 1.9.3 back + +## Release v1.1.0, edge v0.4.0 (31 OCt 2018) (yanked) + +* (#768) yanked because of issues with removed 1.9.3 support + +## Release v1.1.0.pre2, edge v0.4.0.pre2 (18 Sep 2018) + +concurrent-ruby: + +* fixed documentation and README links +* fix Set for TruffleRuby and Rubinius +* use properly supported TruffleRuby APIs + +concurrent-ruby-edge: + +* add Promises.zip_futures_over_on + +## Release v1.1.0.pre1, edge v0.4.0.pre1 (15 Aug 2018) + +concurrent-ruby: + +* requires at least Ruby 2.0 +* [Promises](http://ruby-concurrency.github.io/concurrent-ruby/1.1.0/Concurrent/Promises.html) + are moved from `concurrent-ruby-edge` to `concurrent-ruby` +* Add support for TruffleRuby + * (#734) Fix Array/Hash/Set construction broken on TruffleRuby + * AtomicReference fixed +* CI stabilization +* remove sharp dependency edge -> core +* remove warnings +* documentation updates +* Exchanger is no longer documented as edge since it was already available in + `concurrent-ruby` +* (#644) Fix Map#each and #each_pair not returning enumerator outside of MRI +* (#659) Edge promises fail during error handling +* (#741) Raise on recursive Delay#value call +* (#727) #717 fix global IO executor on JRuby +* (#740) Drop support for CRuby 1.9, JRuby 1.7, Rubinius. +* (#737) Move AtomicMarkableReference out of Edge +* (#708) Prefer platform specific memory barriers +* (#735) Fix wrong expected exception in channel spec assertion +* (#729) Allow executor option in `Promise#then` +* (#725) fix timeout check to use timeout_interval +* (#719) update engine detection +* (#660) Add specs for Promise#zip/Promise.zip ordering +* (#654) Promise.zip execution changes +* (#666) Add thread safe set implementation +* (#651) #699 #to_s, #inspect should not output negative object IDs. +* (#685) Avoid RSpec warnings about raise_error +* (#680) Avoid RSpec monkey patching, persist spec results locally, use RSpec + v3.7.0 +* (#665) Initialize the monitor for new subarrays on Rubinius +* (#661) Fix error handling in edge promises + +concurrent-ruby-edge: + +* (#659) Edge promises fail during error handling +* Edge files clearly separated in `lib-edge` +* added ReInclude + +## Release v1.0.5, edge v0.3.1 (26 Feb 2017) + +concurrent-ruby: + +* Documentation for Event and Semaphore +* Use Unsafe#fullFence and #loadFence directly since the shortcuts were removed in JRuby +* Do not depend on org.jruby.util.unsafe.UnsafeHolder + +concurrent-ruby-edge: + +* (#620) Actors on Pool raise an error +* (#624) Delayed promises did not interact correctly with flatting + * Fix arguments yielded by callback methods +* Overridable default executor in promises factory methods +* Asking actor to terminate will always resolve to `true` + +## Release v1.0.4, edge v0.3.0 (27 Dec 2016) + +concurrent-ruby: + +* Nothing + +concurrent-ruby-edge: + +* New promises' API renamed, lots of improvements, edge bumped to 0.3.0 + * **Incompatible** with previous 0.2.3 version + * see https://github.com/ruby-concurrency/concurrent-ruby/pull/522 + +## Release v1.0.3 (17 Dec 2016) + +* Trigger execution of flattened delayed futures +* Avoid forking for processor_count if possible +* Semaphore Mutex and JRuby parity +* Adds Map#each as alias to Map#each_pair +* Fix uninitialized instance variables +* Make Fixnum, Bignum merger ready +* Allows Promise#then to receive an executor +* TimerSet now survives a fork +* Reject promise on any exception +* Allow ThreadLocalVar to be initialized with a block +* Support Alpha with `Concurrent::processor_count` +* Fixes format-security error when compiling ruby_193_compatible.h +* Concurrent::Atom#swap fixed: reraise the exceptions from block + +## Release v1.0.2 (2 May 2016) + +* Fix bug with `Concurrent::Map` MRI backend `#inspect` method +* Fix bug with `Concurrent::Map` MRI backend using `Hash#value?` +* Improved documentation and examples +* Minor updates to Edge + +## Release v1.0.1 (27 February 2016) + +* Fix "uninitialized constant Concurrent::ReentrantReadWriteLock" error. +* Better handling of `autoload` vs. `require`. +* Improved API for Edge `Future` zipping. +* Fix reference leak in Edge `Future` constructor . +* Fix bug which prevented thread pools from surviving a `fork`. +* Fix bug in which `TimerTask` did not correctly specify all its dependencies. +* Improved support for JRuby+Truffle +* Improved error messages. +* Improved documentation. +* Updated README and CONTRIBUTING. + +## Release v1.0.0 (13 November 2015) + +* Rename `attr_volatile_with_cas` to `attr_atomic` +* Add `clear_each` to `LockFreeStack` +* Update `AtomicReference` documentation +* Further updates and improvements to the synchronization layer. +* Performance and memory usage performance with `Actor` logging. +* Fixed `ThreadPoolExecutor` task count methods. +* Improved `Async` performance for both short and long-lived objects. +* Fixed bug in `LockFreeLinkedSet`. +* Fixed bug in which `Agent#await` triggered a validation failure. +* Further `Channel` updates. +* Adopted a project Code of Conduct +* Cleared interpreter warnings +* Fixed bug in `ThreadPoolExecutor` task count methods +* Fixed bug in 'LockFreeLinkedSet' +* Improved Java extension loading +* Handle Exception children in Edge::Future +* Continued improvements to channel +* Removed interpreter warnings. +* Shared constants now in `lib/concurrent/constants.rb` +* Refactored many tests. +* Improved synchronization layer/memory model documentation. +* Bug fix in Edge `Future#flat` +* Brand new `Channel` implementation in Edge gem. +* Simplification of `RubySingleThreadExecutor` +* `Async` improvements + - Each object uses its own `SingleThreadExecutor` instead of the global thread pool. + - No longers supports executor injection + - Much better documentation +* `Atom` updates + - No longer `Dereferenceable` + - Now `Observable` + - Added a `#reset` method +* Brand new `Agent` API and implementation. Now functionally equivalent to Clojure. +* Continued improvements to the synchronization layer +* Merged in the `thread_safe` gem + - `Concurrent::Array` + - `Concurrent::Hash` + - `Concurrent::Map` (formerly ThreadSafe::Cache) + - `Concurrent::Tuple` +* Minor improvements to Concurrent::Map +* Complete rewrite of `Exchanger` +* Removed all deprecated code (classes, methods, constants, etc.) +* Updated Agent, MutexAtomic, and BufferedChannel to inherit from Synchronization::Object. +* Many improved tests +* Some internal reorganization + +## Release v0.9.1 (09 August 2015) + +* Fixed a Rubiniux bug in synchronization object +* Fixed all interpreter warnings (except circular references) +* Fixed require statements when requiring `Atom` alone +* Significantly improved `ThreadLocalVar` on non-JRuby platforms +* Fixed error handling in Edge `Concurrent.zip` +* `AtomicFixnum` methods `#increment` and `#decrement` now support optional delta +* New `AtomicFixnum#update` method +* Minor optimizations in `ReadWriteLock` +* New `ReentrantReadWriteLock` class +* `ThreadLocalVar#bind` method is now public +* Refactored many tests + +## Release v0.9.0 (10 July 2015) + +* Updated `AtomicReference` + - `AtomicReference#try_update` now simply returns instead of raising exception + - `AtomicReference#try_update!` was added to raise exceptions if an update + fails. Note: this is the same behavior as the old `try_update` +* Pure Java implementations of + - `AtomicBoolean` + - `AtomicFixnum` + - `Semaphore` +* Fixed bug when pruning Ruby thread pools +* Fixed bug in time calculations within `ScheduledTask` +* Default `count` in `CountDownLatch` to 1 +* Use monotonic clock for all timers via `Concurrent.monotonic_time` + - Use `Process.clock_gettime(Process::CLOCK_MONOTONIC)` when available + - Fallback to `java.lang.System.nanoTime()` on unsupported JRuby versions + - Pure Ruby implementation for everything else + - Effects `Concurrent.timer`, `Concurrent.timeout`, `TimerSet`, `TimerTask`, and `ScheduledTask` +* Deprecated all clock-time based timer scheduling + - Only support scheduling by delay + - Effects `Concurrent.timer`, `TimerSet`, and `ScheduledTask` +* Added new `ReadWriteLock` class +* Consistent `at_exit` behavior for Java and Ruby thread pools. +* Added `at_exit` handler to Ruby thread pools (already in Java thread pools) + - Ruby handler stores the object id and retrieves from `ObjectSpace` + - JRuby disables `ObjectSpace` by default so that handler stores the object reference +* Added a `:stop_on_exit` option to thread pools to enable/disable `at_exit` handler +* Updated thread pool docs to better explain shutting down thread pools +* Simpler `:executor` option syntax for all abstractions which support this option +* Added `Executor#auto_terminate?` predicate method (for thread pools) +* Added `at_exit` handler to `TimerSet` +* Simplified auto-termination of the global executors + - Can now disable auto-termination of global executors + - Added shutdown/kill/wait_for_termination variants for global executors +* Can now disable auto-termination for *all* executors (the nuclear option) +* Simplified auto-termination of the global executors +* Deprecated terms "task pool" and "operation pool" + - New terms are "io executor" and "fast executor" + - New functions added with new names + - Deprecation warnings added to functions referencing old names +* Moved all thread pool related functions from `Concurrent::Configuration` to `Concurrent` + - Old functions still exist with deprecation warnings + - New functions have updated names as appropriate +* All high-level abstractions default to the "io executor" +* Fixed bug in `Actor` causing it to prematurely warm global thread pools on gem load + - This also fixed a `RejectedExecutionError` bug when running with minitest/autorun via JRuby +* Moved global logger up to the `Concurrent` namespace and refactored the code +* Optimized the performance of `Delay` + - Fixed a bug in which no executor option on construction caused block execution on a global thread pool +* Numerous improvements and bug fixes to `TimerSet` +* Fixed deadlock of `Future` when the handler raises Exception +* Added shared specs for more classes +* New concurrency abstractions including: + - `Atom` + - `Maybe` + - `ImmutableStruct` + - `MutableStruct` + - `SettableStruct` +* Created an Edge gem for unstable abstractions including + - `Actor` + - `Agent` + - `Channel` + - `Exchanger` + - `LazyRegister` + - **new Future Framework** - unified + implementation of Futures and Promises which combines Features of previous `Future`, + `Promise`, `IVar`, `Event`, `Probe`, `dataflow`, `Delay`, `TimerTask` into single framework. It uses extensively + new synchronization layer to make all the paths **lock-free** with exception of blocking threads on `#wait`. + It offers better performance and does not block threads when not required. +* Actor framework changes: + - fixed reset loop in Pool + - Pool can use any actor as a worker, abstract worker class is no longer needed. + - Actor events not have format `[:event_name, *payload]` instead of just the Symbol. + - Actor now uses new Future/Promise Framework instead of `IVar` for better interoperability + - Behaviour definition array was simplified to `[BehaviourClass1, [BehaviourClass2, *initialization_args]]` + - Linking behavior responds to :linked message by returning array of linked actors + - Supervised behavior is removed in favour of just Linking + - RestartingContext is supervised by default now, `supervise: true` is not required any more + - Events can be private and public, so far only difference is that Linking will + pass to linked actors only public messages. Adding private :restarting and + :resetting events which are send before the actor restarts or resets allowing + to add callbacks to cleanup current child actors. + - Print also object_id in Reference to_s + - Add AbstractContext#default_executor to be able to override executor class wide + - Add basic IO example + - Documentation somewhat improved + - All messages should have same priority. It's now possible to send `actor << job1 << job2 << :terminate!` and + be sure that both jobs are processed first. +* Refactored `Channel` to use newer synchronization objects +* Added `#reset` and `#cancel` methods to `TimerSet` +* Added `#cancel` method to `Future` and `ScheduledTask` +* Refactored `TimerSet` to use `ScheduledTask` +* Updated `Async` with a factory that initializes the object +* Deprecated `Concurrent.timer` and `Concurrent.timeout` +* Reduced max threads on pure-Ruby thread pools (abends around 14751 threads) +* Moved many private/internal classes/modules into "namespace" modules +* Removed brute-force killing of threads in tests +* Fixed a thread pool bug when the operating system cannot allocate more threads + +## Release v0.8.0 (25 January 2015) + +* C extension for MRI have been extracted into the `concurrent-ruby-ext` companion gem. + Please see the README for more detail. +* Better variable isolation in `Promise` and `Future` via an `:args` option +* Continued to update intermittently failing tests + +## Release v0.7.2 (24 January 2015) + +* New `Semaphore` class based on [java.util.concurrent.Semaphore](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Semaphore.html) +* New `Promise.all?` and `Promise.any?` class methods +* Renamed `:overflow_policy` on thread pools to `:fallback_policy` +* Thread pools still accept the `:overflow_policy` option but display a warning +* Thread pools now implement `fallback_policy` behavior when not running (rather than universally rejecting tasks) +* Fixed minor `set_deref_options` constructor bug in `Promise` class +* Fixed minor `require` bug in `ThreadLocalVar` class +* Fixed race condition bug in `TimerSet` class +* Fixed race condition bug in `TimerSet` class +* Fixed signal bug in `TimerSet#post` method +* Numerous non-functional updates to clear warning when running in debug mode +* Fixed more intermittently failing tests +* Tests now run on new Travis build environment +* Multiple documentation updates + +## Release v0.7.1 (4 December 2014) + +Please see the [roadmap](https://github.com/ruby-concurrency/concurrent-ruby/issues/142) for more information on the next planned release. + +* Added `flat_map` method to `Promise` +* Added `zip` method to `Promise` +* Fixed bug with logging in `Actor` +* Improvements to `Promise` tests +* Removed actor-experimental warning +* Added an `IndirectImmediateExecutor` class +* Allow disabling auto termination of global executors +* Fix thread leaking in `ThreadLocalVar` (uses `Ref` gem on non-JRuby systems) +* Fix thread leaking when pruning pure-Ruby thread pools +* Prevent `Actor` from using an `ImmediateExecutor` (causes deadlock) +* Added missing synchronizations to `TimerSet` +* Fixed bug with return value of `Concurrent::Actor::Utils::Pool#ask` +* Fixed timing bug in `TimerTask` +* Fixed bug when creating a `JavaThreadPoolExecutor` with minimum pool size of zero +* Removed confusing warning when not using native extenstions +* Improved documentation + +## Release v0.7.0 (13 August 2014) + +* Merge the [atomic](https://github.com/ruby-concurrency/atomic) gem + - Pure Ruby `MutexAtomic` atomic reference class + - Platform native atomic reference classes `CAtomic`, `JavaAtomic`, and `RbxAtomic` + - Automated [build process](https://github.com/ruby-concurrency/rake-compiler-dev-box) + - Fat binary releases for [multiple platforms](https://rubygems.org/gems/concurrent-ruby/versions) including Windows (32/64), Linux (32/64), OS X (64-bit), Solaris (64-bit), and JRuby +* C native `CAtomicBoolean` +* C native `CAtomicFixnum` +* Refactored intermittently failing tests +* Added `dataflow!` and `dataflow_with!` methods to match `Future#value!` method +* Better handling of timeout in `Agent` +* Actor Improvements + - Fine-grained implementation using chain of behaviors. Each behavior is responsible for single aspect like: `Termination`, `Pausing`, `Linking`, `Supervising`, etc. Users can create custom Actors easily based on their needs. + - Supervision was added. `RestartingContext` will pause on error waiting on its supervisor to decide what to do next ( options are `:terminate!`, `:resume!`, `:reset!`, `:restart!`). Supervising behavior also supports strategies `:one_for_one` and `:one_for_all`. + - Linking was added to be able to monitor actor's events like: `:terminated`, `:paused`, `:restarted`, etc. + - Dead letter routing added. Rejected envelopes are collected in a configurable actor (default: `Concurrent::Actor.root.ask!(:dead_letter_routing)`) + - Old `Actor` class removed and replaced by new implementation previously called `Actress`. `Actress` was kept as an alias for `Actor` to keep compatibility. + - `Utils::Broadcast` actor which allows Publish–subscribe pattern. +* More executors for managing serialized operations + - `SerializedExecution` mixin module + - `SerializedExecutionDelegator` for serializing *any* executor +* Updated `Async` with serialized execution +* Updated `ImmediateExecutor` and `PerThreadExecutor` with full executor service lifecycle +* Added a `Delay` to root `Actress` initialization +* Minor bug fixes to thread pools +* Refactored many intermittently failing specs +* Removed Java interop warning `executor.rb:148 warning: ambiguous Java methods found, using submit(java.lang.Runnable)` +* Fixed minor bug in `RubyCachedThreadPool` overflow policy +* Updated tests to use [RSpec 3.0](http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3) +* Removed deprecated `Actor` class +* Better support for Rubinius + +## Release v0.6.1 (14 June 2014) + +* Many improvements to `Concurrent::Actress` +* Bug fixes to `Concurrent::RubyThreadPoolExecutor` +* Fixed several brittle tests +* Moved documentation to http://ruby-concurrency.github.io/concurrent-ruby/frames.html + +## Release v0.6.0 (25 May 2014) + +* Added `Concurrent::Observable` to encapsulate our thread safe observer sets +* Improvements to new `Channel` +* Major improvements to `CachedThreadPool` and `FixedThreadPool` +* Added `SingleThreadExecutor` +* Added `Current::timer` function +* Added `TimerSet` executor +* Added `AtomicBoolean` +* `ScheduledTask` refactoring +* Pure Ruby and JRuby-optimized `PriorityQueue` classes +* Updated `Agent` behavior to more closely match Clojure +* Observer sets support block callbacks to the `add_observer` method +* New algorithm for thread creation in `RubyThreadPoolExecutor` +* Minor API updates to `Event` +* Rewritten `TimerTask` now an `Executor` instead of a `Runnable` +* Fixed many brittle specs +* Renamed `FixedThreadPool` and `CachedThreadPool` to `RubyFixedThreadPool` and `RubyCachedThreadPool` +* Created JRuby optimized `JavaFixedThreadPool` and `JavaCachedThreadPool` +* Consolidated fixed thread pool tests into `spec/concurrent/fixed_thread_pool_shared.rb` and `spec/concurrent/cached_thread_pool_shared.rb` +* `FixedThreadPool` now subclasses `RubyFixedThreadPool` or `JavaFixedThreadPool` as appropriate +* `CachedThreadPool` now subclasses `RubyCachedThreadPool` or `JavaCachedThreadPool` as appropriate +* New `Delay` class +* `Concurrent::processor_count` helper function +* New `Async` module +* Renamed `NullThreadPool` to `PerThreadExecutor` +* Deprecated `Channel` (we are planning a new implementation based on [Go](http://golangtutorials.blogspot.com/2011/06/channels-in-go.html)) +* Added gem-level [configuration](http://robots.thoughtbot.com/mygem-configure-block) +* Deprecated `$GLOBAL_THREAD_POOL` in lieu of gem-level configuration +* Removed support for Ruby [1.9.2](https://www.ruby-lang.org/en/news/2013/12/17/maintenance-of-1-8-7-and-1-9-2/) +* New `RubyThreadPoolExecutor` and `JavaThreadPoolExecutor` classes +* All thread pools now extend the appropriate thread pool executor classes +* All thread pools now support `:overflow_policy` (based on Java's [reject policies](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html)) +* Deprecated `UsesGlobalThreadPool` in lieu of explicit `:executor` option (dependency injection) on `Future`, `Promise`, and `Agent` +* Added `Concurrent::dataflow_with(executor, *inputs)` method to support executor dependency injection for dataflow +* Software transactional memory with `TVar` and `Concurrent::atomically` +* First implementation of [new, high-performance](https://github.com/ruby-concurrency/concurrent-ruby/pull/49) `Channel` +* `Actor` is deprecated in favor of new experimental actor implementation [#73](https://github.com/ruby-concurrency/concurrent-ruby/pull/73). To avoid namespace collision it is living in `Actress` namespace until `Actor` is removed in next release. + +## Release v0.5.0 + +This is the most significant release of this gem since its inception. This release includes many improvements and optimizations. It also includes several bug fixes. The major areas of focus for this release were: + +* Stability improvements on Ruby versions with thread-level parallelism ([JRuby](http://jruby.org/) and [Rubinius](http://rubini.us/)) +* Creation of new low-level concurrency abstractions +* Internal refactoring to use the new low-level abstractions + +Most of these updates had no effect on the gem API. There are a few notable exceptions which were unavoidable. Please read the [release notes](API-Updates-in-v0.5.0) for more information. + +Specific changes include: + +* New class `IVar` +* New class `MVar` +* New class `ThreadLocalVar` +* New class `AtomicFixnum` +* New class method `dataflow` +* New class `Condition` +* New class `CountDownLatch` +* New class `DependencyCounter` +* New class `SafeTaskExecutor` +* New class `CopyOnNotifyObserverSet` +* New class `CopyOnWriteObserverSet` +* `Future` updated with `execute` API +* `ScheduledTask` updated with `execute` API +* New `Promise` API +* `Future` now extends `IVar` +* `Postable#post?` now returns an `IVar` +* Thread safety fixes to `Dereferenceable` +* Thread safety fixes to `Obligation` +* Thread safety fixes to `Supervisor` +* Thread safety fixes to `Event` +* Various other thread safety (race condition) fixes +* Refactored brittle tests +* Implemented pending tests +* Added JRuby and Rubinius as Travis CI build targets +* Added [CodeClimate](https://codeclimate.com/) code review +* Improved YARD documentation diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/Gemfile b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/Gemfile new file mode 100644 index 0000000..1786c8b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/Gemfile @@ -0,0 +1,36 @@ +source 'https://rubygems.org' + +version = File.read("#{__dir__}/lib/concurrent-ruby/concurrent/version.rb")[/'(.+)'/, 1] or raise +edge_version = File.read("#{__dir__}/lib/concurrent-ruby-edge/concurrent/edge/version.rb")[/'(.+)'/, 1] or raise + +no_path = ENV['NO_PATH'] +options = no_path ? {} : { path: '.' } + +gem 'concurrent-ruby', version, options +gem 'concurrent-ruby-edge', edge_version, options +gem 'concurrent-ruby-ext', version, options.merge(platform: :mri) + +group :development do + gem 'rake', '~> 13.0' + gem 'rake-compiler', '~> 1.0', '>= 1.0.7', '!= 1.2.4' + gem 'rake-compiler-dock', '~> 1.0' + gem 'pry', '~> 0.11', platforms: :mri +end + +group :documentation, optional: true do + gem 'yard', '~> 0.9.0', require: false + gem 'redcarpet', '~> 3.0', platforms: :mri # understands github markdown + gem 'md-ruby-eval', '~> 0.6' +end + +group :testing do + gem 'rspec', '~> 3.7' + gem 'timecop', '~> 0.9' + gem 'sigdump', require: false +end + +# made opt-in since it will not install on jruby 1.7 +group :coverage, optional: !ENV['COVERAGE'] do + gem 'simplecov', '~> 0.16.0', require: false + gem 'coveralls', '~> 0.8.2', require: false +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/LICENSE.txt new file mode 100644 index 0000000..1026f28 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/LICENSE.txt @@ -0,0 +1,21 @@ +Copyright (c) Jerry D'Antonio -- released under the MIT license. + +http://www.opensource.org/licenses/mit-license.php + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/README.md b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/README.md new file mode 100644 index 0000000..66a6983 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/README.md @@ -0,0 +1,407 @@ +# Concurrent Ruby + +[![Gem Version](https://badge.fury.io/rb/concurrent-ruby.svg)](http://badge.fury.io/rb/concurrent-ruby) +[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT) +[![Gitter chat](https://img.shields.io/badge/IRC%20(gitter)-devs%20%26%20users-brightgreen.svg)](https://gitter.im/ruby-concurrency/concurrent-ruby) + +Modern concurrency tools for Ruby. Inspired by +[Erlang](http://www.erlang.org/doc/reference_manual/processes.html), +[Clojure](http://clojure.org/concurrent_programming), +[Scala](http://akka.io/), +[Haskell](http://www.haskell.org/haskellwiki/Applications_and_libraries/Concurrency_and_parallelism#Concurrent_Haskell), +[F#](http://blogs.msdn.com/b/dsyme/archive/2010/02/15/async-and-parallel-design-patterns-in-f-part-3-agents.aspx), +[C#](http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx), +[Java](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html), +and classic concurrency patterns. + + + +The design goals of this gem are: + +* Be an 'unopinionated' toolbox that provides useful utilities without debating which is better + or why +* Remain free of external gem dependencies +* Stay true to the spirit of the languages providing inspiration +* But implement in a way that makes sense for Ruby +* Keep the semantics as idiomatic Ruby as possible +* Support features that make sense in Ruby +* Exclude features that don't make sense in Ruby +* Be small, lean, and loosely coupled +* Thread-safety +* Backward compatibility + +## Contributing + +**This gem depends on +[contributions](https://github.com/ruby-concurrency/concurrent-ruby/graphs/contributors) and we +appreciate your help. Would you like to contribute? Great! Have a look at +[issues with `looking-for-contributor` label](https://github.com/ruby-concurrency/concurrent-ruby/issues?q=is%3Aissue+is%3Aopen+label%3Alooking-for-contributor).** And if you pick something up let us know on the issue. + +You can also get started by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to concurrent-ruby on CodeTriage](https://www.codetriage.com/ruby-concurrency/concurrent-ruby). [![Open Source Helpers](https://www.codetriage.com/ruby-concurrency/concurrent-ruby/badges/users.svg)](https://www.codetriage.com/ruby-concurrency/concurrent-ruby) + +## Thread Safety + +*Concurrent Ruby makes one of the strongest thread safety guarantees of any Ruby concurrency +library, providing consistent behavior and guarantees on all three main Ruby interpreters +(MRI/CRuby, JRuby, TruffleRuby).* + +Every abstraction in this library is thread safe. Specific thread safety guarantees are documented +with each abstraction. + +It is critical to remember, however, that Ruby is a language of mutable references. *No* +concurrency library for Ruby can ever prevent the user from making thread safety mistakes (such as +sharing a mutable object between threads and modifying it on both threads) or from creating +deadlocks through incorrect use of locks. All the library can do is provide safe abstractions which +encourage safe practices. Concurrent Ruby provides more safe concurrency abstractions than any +other Ruby library, many of which support the mantra of +["Do not communicate by sharing memory; instead, share memory by communicating"](https://blog.golang.org/share-memory-by-communicating). +Concurrent Ruby is also the only Ruby library which provides a full suite of thread safe and +immutable variable types and data structures. + +We've also initiated discussion to document the [memory model](docs-source/synchronization.md) of Ruby which +would provide consistent behaviour and guarantees on all three main Ruby interpreters +(MRI/CRuby, JRuby, TruffleRuby). + +## Features & Documentation + +**The primary site for documentation is the automatically generated +[API documentation](http://ruby-concurrency.github.io/concurrent-ruby/index.html) which is up to +date with latest release.** This readme matches the master so may contain new stuff not yet +released. + +We also have a [IRC (gitter)](https://gitter.im/ruby-concurrency/concurrent-ruby). + +### Versioning + +* `concurrent-ruby` uses [Semantic Versioning](http://semver.org/) +* `concurrent-ruby-ext` has always same version as `concurrent-ruby` +* `concurrent-ruby-edge` will always be 0.y.z therefore following + [point 4](http://semver.org/#spec-item-4) applies *"Major version zero + (0.y.z) is for initial development. Anything may change at any time. The + public API should not be considered stable."* However we additionally use + following rules: + * Minor version increment means incompatible changes were made + * Patch version increment means only compatible changes were made + + +#### General-purpose Concurrency Abstractions + +* [Async](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Async.html): + A mixin module that provides simple asynchronous behavior to a class. Loosely based on Erlang's + [gen_server](http://www.erlang.org/doc/man/gen_server.html). +* [ScheduledTask](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ScheduledTask.html): + Like a Future scheduled for a specific future time. +* [TimerTask](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/TimerTask.html): + A Thread that periodically wakes up to perform work at regular intervals. +* [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html): + Unified implementation of futures and promises which combines features of previous `Future`, + `Promise`, `IVar`, `Event`, `dataflow`, `Delay`, and (partially) `TimerTask` into a single + framework. It extensively uses the new synchronization layer to make all the features + **non-blocking** and **lock-free**, with the exception of obviously blocking operations like + `#wait`, `#value`. It also offers better performance. + +#### Thread-safe Value Objects, Structures, and Collections + +Collection classes that were originally part of the (deprecated) `thread_safe` gem: + +* [Array](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Array.html) A thread-safe + subclass of Ruby's standard [Array](http://ruby-doc.org/core/Array.html). +* [Hash](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Hash.html) A thread-safe + subclass of Ruby's standard [Hash](http://ruby-doc.org/core/Hash.html). +* [Set](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Set.html) A thread-safe + subclass of Ruby's standard [Set](http://ruby-doc.org/stdlib-2.4.0/libdoc/set/rdoc/Set.html). +* [Map](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Map.html) A hash-like object + that should have much better performance characteristics, especially under high concurrency, + than `Concurrent::Hash`. +* [Tuple](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Tuple.html) A fixed size + array with volatile (synchronized, thread safe) getters/setters. + +Value objects inspired by other languages: + +* [Maybe](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Maybe.html) A thread-safe, + immutable object representing an optional value, based on + [Haskell Data.Maybe](https://hackage.haskell.org/package/base-4.2.0.1/docs/Data-Maybe.html). + +Structure classes derived from Ruby's [Struct](http://ruby-doc.org/core/Struct.html): + +* [ImmutableStruct](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ImmutableStruct.html) + Immutable struct where values are set at construction and cannot be changed later. +* [MutableStruct](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/MutableStruct.html) + Synchronized, mutable struct where values can be safely changed at any time. +* [SettableStruct](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/SettableStruct.html) + Synchronized, write-once struct where values can be set at most once, either at construction + or any time thereafter. + +Thread-safe variables: + +* [Agent](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Agent.html): A way to + manage shared, mutable, *asynchronous*, independent state. Based on Clojure's + [Agent](http://clojure.org/agents). +* [Atom](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Atom.html): A way to manage + shared, mutable, *synchronous*, independent state. Based on Clojure's + [Atom](http://clojure.org/atoms). +* [AtomicBoolean](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicBoolean.html) + A boolean value that can be updated atomically. +* [AtomicFixnum](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicFixnum.html) + A numeric value that can be updated atomically. +* [AtomicReference](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicReference.html) + An object reference that may be updated atomically. +* [Exchanger](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Exchanger.html) + A synchronization point at which threads can pair and swap elements within pairs. Based on + Java's [Exchanger](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Exchanger.html). +* [MVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/MVar.html) A synchronized + single element container. Based on Haskell's + [MVar](https://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Concurrent-MVar.html) and + Scala's [MVar](http://docs.typelevel.org/api/scalaz/nightly/index.html#scalaz.concurrent.MVar$). +* [ThreadLocalVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ThreadLocalVar.html) + A variable where the value is different for each thread. +* [TVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/TVar.html) A transactional + variable implementing software transactional memory (STM). Based on Clojure's + [Ref](http://clojure.org/refs). + +#### Java-inspired ThreadPools and Other Executors + +* See the [thread pool](http://ruby-concurrency.github.io/concurrent-ruby/master/file.thread_pools.html) + overview, which also contains a list of other Executors available. + +#### Thread Synchronization Classes and Algorithms + +* [CountDownLatch](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/CountDownLatch.html) + A synchronization object that allows one thread to wait on multiple other threads. +* [CyclicBarrier](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/CyclicBarrier.html) + A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. +* [Event](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Event.html) Old school + kernel-style event. +* [ReadWriteLock](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ReadWriteLock.html) + A lock that supports multiple readers but only one writer. +* [ReentrantReadWriteLock](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ReentrantReadWriteLock.html) + A read/write lock with reentrant and upgrade features. +* [Semaphore](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Semaphore.html) + A counting-based locking mechanism that uses permits. +* [AtomicMarkableReference](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicMarkableReference.html) + +#### Deprecated + +Deprecated features are still available and bugs are being fixed, but new features will not be added. + +* ~~[Future](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Future.html): + An asynchronous operation that produces a value.~~ Replaced by + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). + * ~~[.dataflow](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent.html#dataflow-class_method): + Built on Futures, Dataflow allows you to create a task that will be scheduled when all of + its data dependencies are available.~~ Replaced by + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). +* ~~[Promise](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promise.html): Similar + to Futures, with more features.~~ Replaced by + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). +* ~~[Delay](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Delay.html) Lazy evaluation + of a block yielding an immutable result. Based on Clojure's + [delay](https://clojuredocs.org/clojure.core/delay).~~ Replaced by + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). +* ~~[IVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/IVar.html) Similar to a + "future" but can be manually assigned once, after which it becomes immutable.~~ Replaced by + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). + +### Edge Features + +These are available in the `concurrent-ruby-edge` companion gem. + +These features are under active development and may change frequently. They are expected not to +keep backward compatibility (there may also lack tests and documentation). Semantic versions will +be obeyed though. Features developed in `concurrent-ruby-edge` are expected to move to +`concurrent-ruby` when final. + +* [Actor](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Actor.html): Implements + the Actor Model, where concurrent actors exchange messages. + *Status: Partial documentation and tests; depends on new future/promise framework; stability is good.* +* [Channel](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Channel.html): + Communicating Sequential Processes ([CSP](https://en.wikipedia.org/wiki/Communicating_sequential_processes)). + Functionally equivalent to Go [channels](https://tour.golang.org/concurrency/2) with additional + inspiration from Clojure [core.async](https://clojure.github.io/core.async/). + *Status: Partial documentation and tests.* +* [LazyRegister](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/LazyRegister.html) +* [LockFreeLinkedSet](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Edge/LockFreeLinkedSet.html) + *Status: will be moved to core soon.* +* [LockFreeStack](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/LockFreeStack.html) + *Status: missing documentation and tests.* +* [Promises::Channel](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises/Channel.html) + A first in first out channel that accepts messages with push family of methods and returns + messages with pop family of methods. + Pop and push operations can be represented as futures, see `#pop_op` and `#push_op`. + The capacity of the channel can be limited to support back pressure, use capacity option in `#initialize`. + `#pop` method blocks ans `#pop_op` returns pending future if there is no message in the channel. + If the capacity is limited the `#push` method blocks and `#push_op` returns pending future. +* [Cancellation](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Cancellation.html) + The Cancellation abstraction provides cooperative cancellation. + + The standard methods `Thread#raise` of `Thread#kill` available in Ruby + are very dangerous (see linked the blog posts bellow). + Therefore concurrent-ruby provides an alternative. + + * + * + * + + It provides an object which represents a task which can be executed, + the task has to get the reference to the object and periodically cooperatively check that it is not cancelled. + Good practices to make tasks cancellable: + * check cancellation every cycle of a loop which does significant work, + * do all blocking actions in a loop with a timeout then on timeout check cancellation + and if ok block again with the timeout +* [Throttle](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Throttle.html) + A tool managing concurrency level of tasks. +* [ErlangActor](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ErlangActor.html) + Actor implementation which precisely matches Erlang actor behaviour. + Requires at least Ruby 2.1 otherwise it's not loaded. +* [WrappingExecutor](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/WrappingExecutor.html) + A delegating executor which modifies each task before the task is given to + the target executor it delegates to. + +## Supported Ruby versions + +* MRI 2.3 and above +* Latest JRuby 9000 +* Latest TruffleRuby + +## Usage + +Everything within this gem can be loaded simply by requiring it: + +```ruby +require 'concurrent' +``` + +You can also require a specific abstraction [part of the public documentation](https://ruby-concurrency.github.io/concurrent-ruby/master/index.html) since concurrent-ruby 1.2.0, for example: +```ruby +require 'concurrent/map' +require 'concurrent/atomic/atomic_reference' +require 'concurrent/executor/fixed_thread_pool' +``` + +To use the tools in the Edge gem it must be required separately: + +```ruby +require 'concurrent-edge' +``` + +If the library does not behave as expected, `Concurrent.use_stdlib_logger(Logger::DEBUG)` could +help to reveal the problem. + +## Installation + +```shell +gem install concurrent-ruby +``` + +or add the following line to Gemfile: + +```ruby +gem 'concurrent-ruby', require: 'concurrent' +``` + +and run `bundle install` from your shell. + +### Edge Gem Installation + +The Edge gem must be installed separately from the core gem: + +```shell +gem install concurrent-ruby-edge +``` + +or add the following line to Gemfile: + +```ruby +gem 'concurrent-ruby-edge', require: 'concurrent-edge' +``` + +and run `bundle install` from your shell. + + +### C Extensions for MRI + +Potential performance improvements may be achieved under MRI by installing optional C extensions. +To minimise installation errors the C extensions are available in the `concurrent-ruby-ext` +extension gem. `concurrent-ruby` and `concurrent-ruby-ext` are always released together with same +version. Simply install the extension gem too: + +```ruby +gem install concurrent-ruby-ext +``` + +or add the following line to Gemfile: + +```ruby +gem 'concurrent-ruby-ext' +``` + +and run `bundle install` from your shell. + +In code it is only necessary to + +```ruby +require 'concurrent' +``` + +The `concurrent-ruby` gem will automatically detect the presence of the `concurrent-ruby-ext` gem +and load the appropriate C extensions. + +#### Note For gem developers + +No gems should depend on `concurrent-ruby-ext`. Doing so will force C extensions on your users. The +best practice is to depend on `concurrent-ruby` and let users to decide if they want C extensions. + +## Building the gem + +### Requirements + +* Recent CRuby +* JRuby, `rbenv install jruby-9.2.17.0` +* Set env variable `CONCURRENT_JRUBY_HOME` to point to it, e.g. `/usr/local/opt/rbenv/versions/jruby-9.2.17.0` +* Install Docker, required for Windows builds + +### Publishing the Gem + +* Update `version.rb` +* Update the CHANGELOG +* Add the new version to `docs-source/signpost.md`. Needs to be done only if there are visible changes in the documentation. +* Commit (and push) the changes. +* Use `bundle exec rake release` to release the gem. + It consists of `['release:checks', 'release:build', 'release:test', 'release:publish']` steps. + It will ask at the end before publishing anything. Steps can also be executed individually. + +## Maintainers + +* [Benoit Daloze](https://github.com/eregon) +* [Matthew Draper](https://github.com/matthewd) +* [Rafael França](https://github.com/rafaelfranca) +* [Charles Oliver Nutter](https://github.com/headius) +* [Ben Sheldon](https://github.com/bensheldon) +* [Samuel Williams](https://github.com/ioquatix) + +### Special Thanks to + +* [Jerry D'Antonio](https://github.com/jdantonio) for creating the gem +* [Brian Durand](https://github.com/bdurand) for the `ref` gem +* [Charles Oliver Nutter](https://github.com/headius) for the `atomic` and `thread_safe` gems +* [thedarkone](https://github.com/thedarkone) for the `thread_safe` gem + +to the past maintainers + +* [Chris Seaton](https://github.com/chrisseaton) +* [Petr Chalupa](https://github.com/pitr-ch) +* [Michele Della Torre](https://github.com/mighe) +* [Paweł Obrok](https://github.com/obrok) +* [Lucas Allan](https://github.com/lucasallan) + +and to [Ruby Association](https://www.ruby.or.jp/en/) for sponsoring a project +["Enhancing Ruby’s concurrency tooling"](https://www.ruby.or.jp/en/news/20181106) in 2018. + +## License and Copyright + +*Concurrent Ruby* is free software released under the +[MIT License](http://www.opensource.org/licenses/MIT). + +The *Concurrent Ruby* [logo](https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/docs-source/logo/concurrent-ruby-logo-300x300.png) was +designed by [David Jones](https://twitter.com/zombyboy). It is Copyright © 2014 +[Jerry D'Antonio](https://twitter.com/jerrydantonio). All Rights Reserved. diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/Rakefile b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/Rakefile new file mode 100644 index 0000000..c52b564 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/Rakefile @@ -0,0 +1,342 @@ +version = File.read("#{__dir__}/lib/concurrent-ruby/concurrent/version.rb")[/'(.+)'/, 1] or raise +edge_version = File.read("#{__dir__}/lib/concurrent-ruby-edge/concurrent/edge/version.rb")[/'(.+)'/, 1] or raise + +core_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby.gemspec') +ext_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby-ext.gemspec') +edge_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby-edge.gemspec') + +require 'rake/javaextensiontask' + +ENV['JRUBY_HOME'] = ENV['CONCURRENT_JRUBY_HOME'] if ENV['CONCURRENT_JRUBY_HOME'] && RUBY_ENGINE != 'jruby' + +Rake::JavaExtensionTask.new('concurrent_ruby', core_gemspec) do |ext| + ext.ext_dir = 'ext/concurrent-ruby' + ext.lib_dir = 'lib/concurrent-ruby/concurrent' +end + +if RUBY_ENGINE == 'ruby' + require 'rake/extensiontask' + + Rake::ExtensionTask.new('concurrent_ruby_ext', ext_gemspec) do |ext| + ext.ext_dir = 'ext/concurrent-ruby-ext' + ext.lib_dir = 'lib/concurrent-ruby/concurrent' + ext.source_pattern = '*.{c,h}' + + ext.cross_compile = true + ext.cross_platform = ['x86-mingw32', 'x64-mingw32'] + end +end + +def which?(executable) + !`which #{executable} 2>/dev/null`.empty? +end + +require 'rake_compiler_dock' +namespace :repackage do + desc '* with Windows fat distributions' + task :all do + Dir.chdir(__dir__) do + # store gems in vendor cache for docker + Bundler.with_original_env do + sh 'bundle package' + end + + # build only the jar file not the whole gem for java platform, the jar is part the concurrent-ruby-x.y.z.gem + Rake::Task['lib/concurrent-ruby/concurrent/concurrent_ruby.jar'].invoke + + # build all gem files + rack_compiler_dock_kwargs = {} + if which?('podman') and (!which?('docker') || `docker --version`.include?('podman')) + # podman and only podman available, so RakeCompilerDock will use podman, otherwise it uses docker + rack_compiler_dock_kwargs = { + options: ['--privileged'], # otherwise the directory in the image is empty + runas: false + } + end + %w[x86-mingw32 x64-mingw32].each do |plat| + RakeCompilerDock.sh( + "bundle install --local && bundle exec rake native:#{plat} gem --trace", + platform: plat, + **rack_compiler_dock_kwargs) + end + end + end +end + +require 'rubygems' +require 'rubygems/package_task' + +Gem::PackageTask.new(core_gemspec) {} if core_gemspec +Gem::PackageTask.new(ext_gemspec) {} if ext_gemspec && RUBY_ENGINE != 'jruby' +Gem::PackageTask.new(edge_gemspec) {} if edge_gemspec + +CLEAN.include( + 'lib/concurrent-ruby/concurrent/concurrent_ruby_ext.*', + 'lib/concurrent-ruby/concurrent/2.*', + 'lib/concurrent-ruby/concurrent/*.jar') + +begin + require 'rspec' + require 'rspec/core/rake_task' + + RSpec::Core::RakeTask.new(:spec) + + namespace :spec do + desc '* Configured for ci' + RSpec::Core::RakeTask.new(:ci) do |t| + options = %w[ --color + --backtrace + --order defined + --format documentation ] + t.rspec_opts = [*options].join(' ') + end + + desc '* test packaged and installed gems instead of local files' + task :installed do + Bundler.with_original_env do + Dir.chdir(__dir__) do + sh "gem install pkg/concurrent-ruby-#{version}.gem" + sh "gem install pkg/concurrent-ruby-ext-#{version}.gem" if RUBY_ENGINE == 'ruby' + sh "gem install pkg/concurrent-ruby-edge-#{edge_version}.gem" + ENV['NO_PATH'] = 'true' + sh 'bundle update' + sh 'bundle exec rake spec:ci' + end + end + end + end + + desc 'executed in CI' + task :ci => [:compile, 'spec:ci'] + + desc 'run each spec file in a separate process to help find missing requires' + task 'spec:isolated' do + glob = "#{ENV['DIR'] || 'spec'}/**/*_spec.rb" + from = ENV['FROM'] + env = { 'ISOLATED' => 'true' } + Dir[glob].each do |spec| + next if from and from != spec + from = nil if from == spec + + sh env, 'rspec', spec + end + end + + task :default => [:clobber, :compile, :spec] +rescue LoadError => e + puts 'RSpec is not installed, skipping test task definitions: ' + e.message +end + +current_yard_version_name = version + +begin + require 'yard' + require 'md_ruby_eval' + require_relative 'support/yard_full_types' + + common_yard_options = ['--no-yardopts', + '--no-document', + '--no-private', + '--embed-mixins', + '--markup', 'markdown', + '--title', 'Concurrent Ruby', + '--template', 'default', + '--template-path', 'yard-template', + '--default-return', 'undocumented'] + + desc 'Generate YARD Documentation (signpost, master)' + task :yard => ['yard:signpost', 'yard:master'] + + namespace :yard do + + desc '* eval markdown files' + task :eval_md do + Dir.chdir File.join(__dir__, 'docs-source') do + sh 'bundle exec md-ruby-eval --auto' + end + end + + task :update_readme do + Dir.chdir __dir__ do + content = File.read(File.join('README.md')). + gsub(/\[([\w ]+)\]\(http:\/\/ruby-concurrency\.github\.io\/concurrent-ruby\/master\/.*\)/) do |_| + case $1 + when 'LockFreeLinkedSet' + "{Concurrent::Edge::#{$1} #{$1}}" + when '.dataflow' + '{Concurrent.dataflow Concurrent.dataflow}' + when 'thread pool' + '{file:thread_pools.md thread pool}' + else + "{Concurrent::#{$1} #{$1}}" + end + end + FileUtils.mkpath 'tmp' + File.write 'tmp/README.md', content + end + end + + define_yard_task = -> name do + output_dir = "docs/#{name}" + + removal_name = "remove.#{name}" + task removal_name do + Dir.chdir __dir__ do + FileUtils.rm_rf output_dir + end + end + + desc "* of #{name} into subdir #{name}" + YARD::Rake::YardocTask.new(name) do |yard| + yard.options.push( + '--output-dir', output_dir, + '--main', 'tmp/README.md', + *common_yard_options) + yard.files = ['./lib/concurrent-ruby/**/*.rb', + './lib/concurrent-ruby-edge/**/*.rb', + './ext/concurrent_ruby_ext/**/*.c', + '-', + 'docs-source/thread_pools.md', + 'docs-source/promises.out.md', + 'docs-source/medium-example.out.rb', + 'LICENSE.txt', + 'CHANGELOG.md'] + end + Rake::Task[name].prerequisites.push removal_name, + # 'yard:eval_md', + 'yard:update_readme' + end + + define_yard_task.call current_yard_version_name + define_yard_task.call 'master' + + desc "* signpost for versions" + YARD::Rake::YardocTask.new(:signpost) do |yard| + yard.options.push( + '--output-dir', 'docs', + '--main', 'docs-source/signpost.md', + *common_yard_options) + yard.files = ['no-lib'] + end + end + +rescue LoadError => e + puts 'YARD is not installed, skipping documentation task definitions: ' + e.message +end + +desc 'build, test, and publish the gem' +task :release => ['release:checks', 'release:build', 'release:test', 'release:publish'] + +namespace :release do + # Depends on environment of @pitr-ch + + task :checks do + raise '$CONCURRENT_JRUBY_HOME must be set' unless ENV['CONCURRENT_JRUBY_HOME'] + + Dir.chdir(__dir__) do + sh 'test -z "$(git status --porcelain)"' do |ok, res| + unless ok + begin + status = `git status --porcelain` + STDOUT.puts 'There are local changes that you might want to commit.', status, 'Continue? (y/n)' + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + exit 1 if input == 'n' + end + end + sh 'git fetch' + sh 'test $(git show-ref --verify --hash refs/heads/master) = ' + + '$(git show-ref --verify --hash refs/remotes/origin/master)' do |ok, res| + unless ok + begin + STDOUT.puts 'Local master branch is not pushed to origin.', 'Continue? (y/n)' + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + exit 1 if input == 'n' + end + end + end + end + + desc '* build all *.gem files necessary for release' + task :build => [:clobber, 'repackage:all'] + + desc '* test actual installed gems instead of cloned repository on MRI and JRuby' + task :test do + raise '$CONCURRENT_JRUBY_HOME must be set' unless ENV['CONCURRENT_JRUBY_HOME'] + + Dir.chdir(__dir__) do + puts "Testing with the installed gem" + + Bundler.with_original_env do + sh 'ruby -v' + sh 'bundle install' + sh 'bundle exec rake spec:installed' + + env = { "PATH" => "#{ENV.fetch('CONCURRENT_JRUBY_HOME')}/bin:#{ENV['PATH']}" } + sh env, 'ruby -v' + sh env, 'bundle install' + sh env, 'bundle exec rake spec:installed' + end + + puts 'Windows build is untested' + end + end + + desc '* do all nested steps' + task :publish => ['publish:ask', 'publish:tag', 'publish:rubygems', 'publish:post_steps'] + + namespace :publish do + publish_base = nil + publish_edge = nil + + task :ask do + begin + STDOUT.puts 'Do you want to publish anything now? (y/n)' + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + exit 1 if input == 'n' + + begin + STDOUT.puts 'Do you want to publish `concurrent-ruby`? (y/n)' + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + publish_base = input == 'y' + + begin + STDOUT.puts 'Do you want to publish `concurrent-ruby-edge`? (y/n)' + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + publish_edge = input == 'y' + end + + desc '** tag HEAD with current version and push to github' + task :tag => :ask do + Dir.chdir(__dir__) do + sh "git tag v#{version}" if publish_base + sh "git push origin v#{version}" if publish_base + sh "git tag edge-v#{edge_version}" if publish_edge + sh "git push origin edge-v#{edge_version}" if publish_edge + end + end + + desc '** push all *.gem files to rubygems' + task :rubygems => :ask do + Dir.chdir(__dir__) do + sh "gem push pkg/concurrent-ruby-#{version}.gem" if publish_base + sh "gem push pkg/concurrent-ruby-edge-#{edge_version}.gem" if publish_edge + sh "gem push pkg/concurrent-ruby-ext-#{version}.gem" if publish_base + sh "gem push pkg/concurrent-ruby-ext-#{version}-x64-mingw32.gem" if publish_base + sh "gem push pkg/concurrent-ruby-ext-#{version}-x86-mingw32.gem" if publish_base + end + end + + desc '** print post release steps' + task :post_steps do + # TODO: (petr 05-Jun-2021) automate and renew the process + puts 'Manually: create a release on GitHub with relevant changelog part' + puts 'Manually: send email same as release with relevant changelog part' + puts 'Manually: tweet' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/ConcurrentRubyService.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/ConcurrentRubyService.java new file mode 100644 index 0000000..fb6be96 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/ConcurrentRubyService.java @@ -0,0 +1,17 @@ +import org.jruby.Ruby; +import org.jruby.runtime.load.BasicLibraryService; + +import java.io.IOException; + +public class ConcurrentRubyService implements BasicLibraryService { + + public boolean basicLoad(final Ruby runtime) throws IOException { + new com.concurrent_ruby.ext.AtomicReferenceLibrary().load(runtime, false); + new com.concurrent_ruby.ext.JavaAtomicBooleanLibrary().load(runtime, false); + new com.concurrent_ruby.ext.JavaAtomicFixnumLibrary().load(runtime, false); + new com.concurrent_ruby.ext.JavaSemaphoreLibrary().load(runtime, false); + new com.concurrent_ruby.ext.SynchronizationLibrary().load(runtime, false); + new com.concurrent_ruby.ext.JRubyMapBackendLibrary().load(runtime, false); + return true; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/AtomicReferenceLibrary.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/AtomicReferenceLibrary.java new file mode 100644 index 0000000..dfa9e77 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/AtomicReferenceLibrary.java @@ -0,0 +1,175 @@ +package com.concurrent_ruby.ext; + +import java.lang.reflect.Field; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import org.jruby.Ruby; +import org.jruby.RubyClass; +import org.jruby.RubyModule; +import org.jruby.RubyNumeric; +import org.jruby.RubyObject; +import org.jruby.anno.JRubyClass; +import org.jruby.anno.JRubyMethod; +import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.runtime.load.Library; + +/** + * This library adds an atomic reference type to JRuby for use in the atomic + * library. We do a native version to avoid the implicit value coercion that + * normally happens through JI. + * + * @author headius + */ +public class AtomicReferenceLibrary implements Library { + public void load(Ruby runtime, boolean wrap) throws IOException { + RubyModule concurrentMod = runtime.defineModule("Concurrent"); + RubyClass atomicCls = concurrentMod.defineClassUnder("JavaAtomicReference", runtime.getObject(), JRUBYREFERENCE_ALLOCATOR); + try { + sun.misc.Unsafe.class.getMethod("getAndSetObject", Object.class); + atomicCls.setAllocator(JRUBYREFERENCE8_ALLOCATOR); + } catch (Exception e) { + // leave it as Java 6/7 version + } + atomicCls.defineAnnotatedMethods(JRubyReference.class); + } + + private static final ObjectAllocator JRUBYREFERENCE_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JRubyReference(runtime, klazz); + } + }; + + private static final ObjectAllocator JRUBYREFERENCE8_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JRubyReference8(runtime, klazz); + } + }; + + @JRubyClass(name="JRubyReference", parent="Object") + public static class JRubyReference extends RubyObject { + volatile IRubyObject reference; + + static final sun.misc.Unsafe UNSAFE; + static final long referenceOffset; + + static { + try { + UNSAFE = UnsafeHolder.U; + Class k = JRubyReference.class; + referenceOffset = UNSAFE.objectFieldOffset(k.getDeclaredField("reference")); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public JRubyReference(Ruby runtime, RubyClass klass) { + super(runtime, klass); + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context) { + UNSAFE.putObject(this, referenceOffset, context.nil); + return context.nil; + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context, IRubyObject value) { + UNSAFE.putObject(this, referenceOffset, value); + return context.nil; + } + + @JRubyMethod(name = {"get", "value"}) + public IRubyObject get() { + return reference; + } + + @JRubyMethod(name = {"set", "value="}) + public IRubyObject set(IRubyObject newValue) { + UNSAFE.putObjectVolatile(this, referenceOffset, newValue); + return newValue; + } + + @JRubyMethod(name = {"compare_and_set", "compare_and_swap"}) + public IRubyObject compare_and_set(ThreadContext context, IRubyObject expectedValue, IRubyObject newValue) { + Ruby runtime = context.runtime; + + if (expectedValue instanceof RubyNumeric) { + // numerics are not always idempotent in Ruby, so we need to do slower logic + return compareAndSetNumeric(context, expectedValue, newValue); + } + + return runtime.newBoolean(UNSAFE.compareAndSwapObject(this, referenceOffset, expectedValue, newValue)); + } + + @JRubyMethod(name = {"get_and_set", "swap"}) + public IRubyObject get_and_set(ThreadContext context, IRubyObject newValue) { + // less-efficient version for Java 6 and 7 + while (true) { + IRubyObject oldValue = get(); + if (UNSAFE.compareAndSwapObject(this, referenceOffset, oldValue, newValue)) { + return oldValue; + } + } + } + + private IRubyObject compareAndSetNumeric(ThreadContext context, IRubyObject expectedValue, IRubyObject newValue) { + Ruby runtime = context.runtime; + + // loop until: + // * reference CAS would succeed for same-valued objects + // * current and expected have different values as determined by #equals + while (true) { + IRubyObject current = reference; + + if (!(current instanceof RubyNumeric)) { + // old value is not numeric, CAS fails + return runtime.getFalse(); + } + + RubyNumeric currentNumber = (RubyNumeric)current; + if (!currentNumber.equals(expectedValue)) { + // current number does not equal expected, fail CAS + return runtime.getFalse(); + } + + // check that current has not changed, or else allow loop to repeat + boolean success = UNSAFE.compareAndSwapObject(this, referenceOffset, current, newValue); + if (success) { + // value is same and did not change in interim...success + return runtime.getTrue(); + } + } + } + } + + private static final class UnsafeHolder { + private UnsafeHolder(){} + + public static final sun.misc.Unsafe U = loadUnsafe(); + + private static sun.misc.Unsafe loadUnsafe() { + try { + Class unsafeClass = Class.forName("sun.misc.Unsafe"); + Field f = unsafeClass.getDeclaredField("theUnsafe"); + f.setAccessible(true); + return (sun.misc.Unsafe) f.get(null); + } catch (Exception e) { + return null; + } + } + } + + public static class JRubyReference8 extends JRubyReference { + public JRubyReference8(Ruby runtime, RubyClass klass) { + super(runtime, klass); + } + + @Override + public IRubyObject get_and_set(ThreadContext context, IRubyObject newValue) { + // efficient version for Java 8 + return (IRubyObject)UNSAFE.getAndSetObject(this, referenceOffset, newValue); + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JRubyMapBackendLibrary.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JRubyMapBackendLibrary.java new file mode 100644 index 0000000..a09f916 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JRubyMapBackendLibrary.java @@ -0,0 +1,248 @@ +package com.concurrent_ruby.ext; + +import org.jruby.*; +import org.jruby.anno.JRubyClass; +import org.jruby.anno.JRubyMethod; +import com.concurrent_ruby.ext.jsr166e.ConcurrentHashMap; +import com.concurrent_ruby.ext.jsr166e.ConcurrentHashMapV8; +import com.concurrent_ruby.ext.jsr166e.nounsafe.*; +import org.jruby.runtime.Block; +import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.runtime.load.Library; + +import java.io.IOException; +import java.util.Map; + +import static org.jruby.runtime.Visibility.PRIVATE; + +/** + * Native Java implementation to avoid the JI overhead. + * + * @author thedarkone + */ +public class JRubyMapBackendLibrary implements Library { + public void load(Ruby runtime, boolean wrap) throws IOException { + + RubyModule concurrentMod = runtime.defineModule("Concurrent"); + RubyModule thread_safeMod = concurrentMod.defineModuleUnder("Collection"); + RubyClass jrubyRefClass = thread_safeMod.defineClassUnder("JRubyMapBackend", runtime.getObject(), BACKEND_ALLOCATOR); + jrubyRefClass.setAllocator(BACKEND_ALLOCATOR); + jrubyRefClass.defineAnnotatedMethods(JRubyMapBackend.class); + } + + private static final ObjectAllocator BACKEND_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JRubyMapBackend(runtime, klazz); + } + }; + + @JRubyClass(name="JRubyMapBackend", parent="Object") + public static class JRubyMapBackend extends RubyObject { + // Defaults used by the CHM + static final int DEFAULT_INITIAL_CAPACITY = 16; + static final float DEFAULT_LOAD_FACTOR = 0.75f; + + public static final boolean CAN_USE_UNSAFE_CHM = canUseUnsafeCHM(); + + private ConcurrentHashMap map; + + private static ConcurrentHashMap newCHM(int initialCapacity, float loadFactor) { + if (CAN_USE_UNSAFE_CHM) { + return new ConcurrentHashMapV8(initialCapacity, loadFactor); + } else { + return new com.concurrent_ruby.ext.jsr166e.nounsafe.ConcurrentHashMapV8(initialCapacity, loadFactor); + } + } + + private static ConcurrentHashMap newCHM() { + return newCHM(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR); + } + + private static boolean canUseUnsafeCHM() { + try { + new com.concurrent_ruby.ext.jsr166e.ConcurrentHashMapV8(); // force class load and initialization + return true; + } catch (Throwable t) { // ensuring we really do catch everything + // Doug's Unsafe setup errors always have this "Could not ini.." message + if (isCausedBySecurityException(t)) { + return false; + } + throw (t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t)); + } + } + + private static boolean isCausedBySecurityException(Throwable t) { + while (t != null) { + if ((t.getMessage() != null && t.getMessage().contains("Could not initialize intrinsics")) || t instanceof SecurityException) { + return true; + } + t = t.getCause(); + } + return false; + } + + public JRubyMapBackend(Ruby runtime, RubyClass klass) { + super(runtime, klass); + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context) { + map = newCHM(); + return context.getRuntime().getNil(); + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context, IRubyObject options) { + map = toCHM(context, options); + return context.getRuntime().getNil(); + } + + private ConcurrentHashMap toCHM(ThreadContext context, IRubyObject options) { + Ruby runtime = context.getRuntime(); + if (!options.isNil() && options.respondsTo("[]")) { + IRubyObject rInitialCapacity = options.callMethod(context, "[]", runtime.newSymbol("initial_capacity")); + IRubyObject rLoadFactor = options.callMethod(context, "[]", runtime.newSymbol("load_factor")); + int initialCapacity = !rInitialCapacity.isNil() ? RubyNumeric.num2int(rInitialCapacity.convertToInteger()) : DEFAULT_INITIAL_CAPACITY; + float loadFactor = !rLoadFactor.isNil() ? (float)RubyNumeric.num2dbl(rLoadFactor.convertToFloat()) : DEFAULT_LOAD_FACTOR; + return newCHM(initialCapacity, loadFactor); + } else { + return newCHM(); + } + } + + @JRubyMethod(name = "[]", required = 1) + public IRubyObject op_aref(ThreadContext context, IRubyObject key) { + IRubyObject value; + return ((value = map.get(key)) == null) ? context.getRuntime().getNil() : value; + } + + @JRubyMethod(name = {"[]="}, required = 2) + public IRubyObject op_aset(IRubyObject key, IRubyObject value) { + map.put(key, value); + return value; + } + + @JRubyMethod + public IRubyObject put_if_absent(IRubyObject key, IRubyObject value) { + IRubyObject result = map.putIfAbsent(key, value); + return result == null ? getRuntime().getNil() : result; + } + + @JRubyMethod + public IRubyObject compute_if_absent(final ThreadContext context, final IRubyObject key, final Block block) { + return map.computeIfAbsent(key, new ConcurrentHashMap.Fun() { + @Override + public IRubyObject apply(IRubyObject key) { + return block.yieldSpecific(context); + } + }); + } + + @JRubyMethod + public IRubyObject compute_if_present(final ThreadContext context, final IRubyObject key, final Block block) { + IRubyObject result = map.computeIfPresent(key, new ConcurrentHashMap.BiFun() { + @Override + public IRubyObject apply(IRubyObject key, IRubyObject oldValue) { + IRubyObject result = block.yieldSpecific(context, oldValue == null ? context.getRuntime().getNil() : oldValue); + return result.isNil() ? null : result; + } + }); + return result == null ? context.getRuntime().getNil() : result; + } + + @JRubyMethod + public IRubyObject compute(final ThreadContext context, final IRubyObject key, final Block block) { + IRubyObject result = map.compute(key, new ConcurrentHashMap.BiFun() { + @Override + public IRubyObject apply(IRubyObject key, IRubyObject oldValue) { + IRubyObject result = block.yieldSpecific(context, oldValue == null ? context.getRuntime().getNil() : oldValue); + return result.isNil() ? null : result; + } + }); + return result == null ? context.getRuntime().getNil() : result; + } + + @JRubyMethod + public IRubyObject merge_pair(final ThreadContext context, final IRubyObject key, final IRubyObject value, final Block block) { + IRubyObject result = map.merge(key, value, new ConcurrentHashMap.BiFun() { + @Override + public IRubyObject apply(IRubyObject oldValue, IRubyObject newValue) { + IRubyObject result = block.yieldSpecific(context, oldValue == null ? context.getRuntime().getNil() : oldValue); + return result.isNil() ? null : result; + } + }); + return result == null ? context.getRuntime().getNil() : result; + } + + @JRubyMethod + public RubyBoolean replace_pair(IRubyObject key, IRubyObject oldValue, IRubyObject newValue) { + return getRuntime().newBoolean(map.replace(key, oldValue, newValue)); + } + + @JRubyMethod(name = "key?", required = 1) + public RubyBoolean has_key_p(IRubyObject key) { + return map.containsKey(key) ? getRuntime().getTrue() : getRuntime().getFalse(); + } + + @JRubyMethod + public IRubyObject key(IRubyObject value) { + final IRubyObject key = map.findKey(value); + return key == null ? getRuntime().getNil() : key; + } + + @JRubyMethod + public IRubyObject replace_if_exists(IRubyObject key, IRubyObject value) { + IRubyObject result = map.replace(key, value); + return result == null ? getRuntime().getNil() : result; + } + + @JRubyMethod + public IRubyObject get_and_set(IRubyObject key, IRubyObject value) { + IRubyObject result = map.put(key, value); + return result == null ? getRuntime().getNil() : result; + } + + @JRubyMethod + public IRubyObject delete(IRubyObject key) { + IRubyObject result = map.remove(key); + return result == null ? getRuntime().getNil() : result; + } + + @JRubyMethod + public RubyBoolean delete_pair(IRubyObject key, IRubyObject value) { + return getRuntime().newBoolean(map.remove(key, value)); + } + + @JRubyMethod + public IRubyObject clear() { + map.clear(); + return this; + } + + @JRubyMethod + public IRubyObject each_pair(ThreadContext context, Block block) { + for (Map.Entry entry : map.entrySet()) { + block.yieldSpecific(context, entry.getKey(), entry.getValue()); + } + return this; + } + + @JRubyMethod + public RubyFixnum size(ThreadContext context) { + return context.getRuntime().newFixnum(map.size()); + } + + @JRubyMethod + public IRubyObject get_or_default(IRubyObject key, IRubyObject defaultValue) { + return map.getValueOrDefault(key, defaultValue); + } + + @JRubyMethod(visibility = PRIVATE) + public JRubyMapBackend initialize_copy(ThreadContext context, IRubyObject other) { + map = newCHM(); + return this; + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java new file mode 100644 index 0000000..b566076 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java @@ -0,0 +1,93 @@ +package com.concurrent_ruby.ext; + +import org.jruby.Ruby; +import org.jruby.RubyBoolean; +import org.jruby.RubyClass; +import org.jruby.RubyModule; +import org.jruby.RubyNil; +import org.jruby.RubyObject; +import org.jruby.anno.JRubyClass; +import org.jruby.anno.JRubyMethod; +import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.runtime.load.Library; + +import java.io.IOException; +import java.util.concurrent.atomic.AtomicBoolean; + +public class JavaAtomicBooleanLibrary implements Library { + + public void load(Ruby runtime, boolean wrap) throws IOException { + RubyModule concurrentMod = runtime.defineModule("Concurrent"); + RubyClass atomicCls = concurrentMod.defineClassUnder("JavaAtomicBoolean", runtime.getObject(), JRUBYREFERENCE_ALLOCATOR); + atomicCls.defineAnnotatedMethods(JavaAtomicBoolean.class); + } + + private static final ObjectAllocator JRUBYREFERENCE_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JavaAtomicBoolean(runtime, klazz); + } + }; + + @JRubyClass(name = "JavaAtomicBoolean", parent = "Object") + public static class JavaAtomicBoolean extends RubyObject { + + private AtomicBoolean atomicBoolean; + + public JavaAtomicBoolean(Ruby runtime, RubyClass metaClass) { + super(runtime, metaClass); + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context, IRubyObject value) { + atomicBoolean = new AtomicBoolean(convertRubyBooleanToJavaBoolean(value)); + return context.nil; + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context) { + atomicBoolean = new AtomicBoolean(); + return context.nil; + } + + @JRubyMethod(name = "value") + public IRubyObject value() { + return getRuntime().newBoolean(atomicBoolean.get()); + } + + @JRubyMethod(name = "true?") + public IRubyObject isAtomicTrue() { + return getRuntime().newBoolean(atomicBoolean.get()); + } + + @JRubyMethod(name = "false?") + public IRubyObject isAtomicFalse() { + return getRuntime().newBoolean((atomicBoolean.get() == false)); + } + + @JRubyMethod(name = "value=") + public IRubyObject setAtomic(ThreadContext context, IRubyObject newValue) { + atomicBoolean.set(convertRubyBooleanToJavaBoolean(newValue)); + return context.nil; + } + + @JRubyMethod(name = "make_true") + public IRubyObject makeTrue() { + return getRuntime().newBoolean(atomicBoolean.compareAndSet(false, true)); + } + + @JRubyMethod(name = "make_false") + public IRubyObject makeFalse() { + return getRuntime().newBoolean(atomicBoolean.compareAndSet(true, false)); + } + + private boolean convertRubyBooleanToJavaBoolean(IRubyObject newValue) { + if (newValue instanceof RubyBoolean.False || newValue instanceof RubyNil) { + return false; + } else { + return true; + } + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java new file mode 100644 index 0000000..672bfc0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java @@ -0,0 +1,113 @@ +package com.concurrent_ruby.ext; + +import java.io.IOException; +import java.util.concurrent.atomic.AtomicLong; +import org.jruby.Ruby; +import org.jruby.RubyClass; +import org.jruby.RubyFixnum; +import org.jruby.RubyModule; +import org.jruby.RubyObject; +import org.jruby.anno.JRubyClass; +import org.jruby.anno.JRubyMethod; +import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.runtime.load.Library; +import org.jruby.runtime.Block; + +public class JavaAtomicFixnumLibrary implements Library { + + public void load(Ruby runtime, boolean wrap) throws IOException { + RubyModule concurrentMod = runtime.defineModule("Concurrent"); + RubyClass atomicCls = concurrentMod.defineClassUnder("JavaAtomicFixnum", runtime.getObject(), JRUBYREFERENCE_ALLOCATOR); + + atomicCls.defineAnnotatedMethods(JavaAtomicFixnum.class); + } + + private static final ObjectAllocator JRUBYREFERENCE_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JavaAtomicFixnum(runtime, klazz); + } + }; + + @JRubyClass(name = "JavaAtomicFixnum", parent = "Object") + public static class JavaAtomicFixnum extends RubyObject { + + private AtomicLong atomicLong; + + public JavaAtomicFixnum(Ruby runtime, RubyClass metaClass) { + super(runtime, metaClass); + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context) { + this.atomicLong = new AtomicLong(0); + return context.nil; + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context, IRubyObject value) { + this.atomicLong = new AtomicLong(rubyFixnumToLong(value)); + return context.nil; + } + + @JRubyMethod(name = "value") + public IRubyObject getValue() { + return getRuntime().newFixnum(atomicLong.get()); + } + + @JRubyMethod(name = "value=") + public IRubyObject setValue(ThreadContext context, IRubyObject newValue) { + atomicLong.set(rubyFixnumToLong(newValue)); + return context.nil; + } + + @JRubyMethod(name = {"increment", "up"}) + public IRubyObject increment() { + return getRuntime().newFixnum(atomicLong.incrementAndGet()); + } + + @JRubyMethod(name = {"increment", "up"}) + public IRubyObject increment(IRubyObject value) { + long delta = rubyFixnumToLong(value); + return getRuntime().newFixnum(atomicLong.addAndGet(delta)); + } + + @JRubyMethod(name = {"decrement", "down"}) + public IRubyObject decrement() { + return getRuntime().newFixnum(atomicLong.decrementAndGet()); + } + + @JRubyMethod(name = {"decrement", "down"}) + public IRubyObject decrement(IRubyObject value) { + long delta = rubyFixnumToLong(value); + return getRuntime().newFixnum(atomicLong.addAndGet(-delta)); + } + + @JRubyMethod(name = "compare_and_set") + public IRubyObject compareAndSet(ThreadContext context, IRubyObject expect, IRubyObject update) { + return getRuntime().newBoolean(atomicLong.compareAndSet(rubyFixnumToLong(expect), rubyFixnumToLong(update))); + } + + @JRubyMethod + public IRubyObject update(ThreadContext context, Block block) { + for (;;) { + long _oldValue = atomicLong.get(); + IRubyObject oldValue = getRuntime().newFixnum(_oldValue); + IRubyObject newValue = block.yield(context, oldValue); + if (atomicLong.compareAndSet(_oldValue, rubyFixnumToLong(newValue))) { + return newValue; + } + } + } + + private long rubyFixnumToLong(IRubyObject value) { + if (value instanceof RubyFixnum) { + RubyFixnum fixNum = (RubyFixnum) value; + return fixNum.getLongValue(); + } else { + throw getRuntime().newArgumentError("value must be a Fixnum"); + } + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaSemaphoreLibrary.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaSemaphoreLibrary.java new file mode 100644 index 0000000..d887f25 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaSemaphoreLibrary.java @@ -0,0 +1,189 @@ +package com.concurrent_ruby.ext; + +import java.io.IOException; +import java.util.concurrent.Semaphore; +import org.jruby.Ruby; +import org.jruby.RubyClass; +import org.jruby.RubyFixnum; +import org.jruby.RubyModule; +import org.jruby.RubyNumeric; +import org.jruby.RubyObject; +import org.jruby.anno.JRubyClass; +import org.jruby.anno.JRubyMethod; +import org.jruby.runtime.Block; +import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; + +public class JavaSemaphoreLibrary { + + public void load(Ruby runtime, boolean wrap) throws IOException { + RubyModule concurrentMod = runtime.defineModule("Concurrent"); + RubyClass atomicCls = concurrentMod.defineClassUnder("JavaSemaphore", runtime.getObject(), JRUBYREFERENCE_ALLOCATOR); + + atomicCls.defineAnnotatedMethods(JavaSemaphore.class); + } + + private static final ObjectAllocator JRUBYREFERENCE_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JavaSemaphore(runtime, klazz); + } + }; + + @JRubyClass(name = "JavaSemaphore", parent = "Object") + public static class JavaSemaphore extends RubyObject { + + private JRubySemaphore semaphore; + + public JavaSemaphore(Ruby runtime, RubyClass metaClass) { + super(runtime, metaClass); + } + + @JRubyMethod + public IRubyObject initialize(ThreadContext context, IRubyObject value) { + this.semaphore = new JRubySemaphore(rubyFixnumInt(value, "count")); + return context.nil; + } + + @JRubyMethod + public IRubyObject acquire(ThreadContext context, final Block block) throws InterruptedException { + return this.acquire(context, 1, block); + } + + @JRubyMethod + public IRubyObject acquire(ThreadContext context, IRubyObject permits, final Block block) throws InterruptedException { + return this.acquire(context, rubyFixnumToPositiveInt(permits, "permits"), block); + } + + @JRubyMethod(name = "available_permits") + public IRubyObject availablePermits(ThreadContext context) { + return getRuntime().newFixnum(this.semaphore.availablePermits()); + } + + @JRubyMethod(name = "drain_permits") + public IRubyObject drainPermits(ThreadContext context) { + return getRuntime().newFixnum(this.semaphore.drainPermits()); + } + + @JRubyMethod(name = "try_acquire") + public IRubyObject tryAcquire(ThreadContext context, final Block block) throws InterruptedException { + int permitsInt = 1; + boolean acquired = semaphore.tryAcquire(permitsInt); + + return triedAcquire(context, permitsInt, acquired, block); + } + + @JRubyMethod(name = "try_acquire") + public IRubyObject tryAcquire(ThreadContext context, IRubyObject permits, final Block block) throws InterruptedException { + int permitsInt = rubyFixnumToPositiveInt(permits, "permits"); + boolean acquired = semaphore.tryAcquire(permitsInt); + + return triedAcquire(context, permitsInt, acquired, block); + } + + @JRubyMethod(name = "try_acquire") + public IRubyObject tryAcquire(ThreadContext context, IRubyObject permits, IRubyObject timeout, final Block block) throws InterruptedException { + int permitsInt = rubyFixnumToPositiveInt(permits, "permits"); + boolean acquired = semaphore.tryAcquire( + permitsInt, + rubyNumericToLong(timeout, "timeout"), + java.util.concurrent.TimeUnit.SECONDS + ); + + return triedAcquire(context, permitsInt, acquired, block); + } + + @JRubyMethod + public IRubyObject release(ThreadContext context) { + this.semaphore.release(1); + return getRuntime().newBoolean(true); + } + + @JRubyMethod + public IRubyObject release(ThreadContext context, IRubyObject permits) { + this.semaphore.release(rubyFixnumToPositiveInt(permits, "permits")); + return getRuntime().newBoolean(true); + } + + @JRubyMethod(name = "reduce_permits") + public IRubyObject reducePermits(ThreadContext context, IRubyObject reduction) throws InterruptedException { + this.semaphore.publicReducePermits(rubyFixnumToNonNegativeInt(reduction, "reduction")); + return context.nil; + } + + private IRubyObject acquire(ThreadContext context, int permits, final Block block) throws InterruptedException { + this.semaphore.acquire(permits); + + if (!block.isGiven()) return context.nil; + + try { + return block.yieldSpecific(context); + } finally { + this.semaphore.release(permits); + } + } + + private IRubyObject triedAcquire(ThreadContext context, int permits, boolean acquired, final Block block) { + if (!block.isGiven()) return getRuntime().newBoolean(acquired); + if (!acquired) return context.nil; + + try { + return block.yieldSpecific(context); + } finally { + this.semaphore.release(permits); + } + } + + private int rubyFixnumInt(IRubyObject value, String paramName) { + if (value instanceof RubyFixnum) { + RubyFixnum fixNum = (RubyFixnum) value; + return (int) fixNum.getLongValue(); + } else { + throw getRuntime().newArgumentError(paramName + " must be integer"); + } + } + + private int rubyFixnumToNonNegativeInt(IRubyObject value, String paramName) { + if (value instanceof RubyFixnum && ((RubyFixnum) value).getLongValue() >= 0) { + RubyFixnum fixNum = (RubyFixnum) value; + return (int) fixNum.getLongValue(); + } else { + throw getRuntime().newArgumentError(paramName + " must be a non-negative integer"); + } + } + + private int rubyFixnumToPositiveInt(IRubyObject value, String paramName) { + if (value instanceof RubyFixnum && ((RubyFixnum) value).getLongValue() > 0) { + RubyFixnum fixNum = (RubyFixnum) value; + return (int) fixNum.getLongValue(); + } else { + throw getRuntime().newArgumentError(paramName + " must be an integer greater than zero"); + } + } + + private long rubyNumericToLong(IRubyObject value, String paramName) { + if (value instanceof RubyNumeric && ((RubyNumeric) value).getDoubleValue() > 0) { + RubyNumeric fixNum = (RubyNumeric) value; + return fixNum.getLongValue(); + } else { + throw getRuntime().newArgumentError(paramName + " must be a float greater than zero"); + } + } + + class JRubySemaphore extends Semaphore { + + public JRubySemaphore(int permits) { + super(permits); + } + + public JRubySemaphore(int permits, boolean value) { + super(permits, value); + } + + public void publicReducePermits(int i) { + reducePermits(i); + } + + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java new file mode 100644 index 0000000..f0c75ee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java @@ -0,0 +1,292 @@ +package com.concurrent_ruby.ext; + +import org.jruby.Ruby; +import org.jruby.RubyBasicObject; +import org.jruby.RubyClass; +import org.jruby.RubyModule; +import org.jruby.RubyObject; +import org.jruby.RubyThread; +import org.jruby.anno.JRubyClass; +import org.jruby.anno.JRubyMethod; +import org.jruby.runtime.Block; +import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.Visibility; +import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.runtime.load.Library; +import sun.misc.Unsafe; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +public class SynchronizationLibrary implements Library { + + private static final Unsafe UNSAFE = loadUnsafe(); + private static final boolean FULL_FENCE = supportsFences(); + + private static Unsafe loadUnsafe() { + try { + Class ncdfe = Class.forName("sun.misc.Unsafe"); + Field f = ncdfe.getDeclaredField("theUnsafe"); + f.setAccessible(true); + return (Unsafe) f.get((java.lang.Object) null); + } catch (Exception var2) { + return null; + } catch (NoClassDefFoundError var3) { + return null; + } + } + + private static boolean supportsFences() { + if (UNSAFE == null) { + return false; + } else { + try { + Method m = UNSAFE.getClass().getDeclaredMethod("fullFence", new Class[0]); + if (m != null) { + return true; + } + } catch (Exception var1) { + // nothing + } + + return false; + } + } + + private static final ObjectAllocator OBJECT_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new Object(runtime, klazz); + } + }; + + private static final ObjectAllocator ABSTRACT_LOCKABLE_OBJECT_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new AbstractLockableObject(runtime, klazz); + } + }; + + private static final ObjectAllocator JRUBY_LOCKABLE_OBJECT_ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JRubyLockableObject(runtime, klazz); + } + }; + + public void load(Ruby runtime, boolean wrap) throws IOException { + RubyModule synchronizationModule = runtime. + defineModule("Concurrent"). + defineModuleUnder("Synchronization"); + + RubyModule jrubyAttrVolatileModule = synchronizationModule.defineModuleUnder("JRubyAttrVolatile"); + jrubyAttrVolatileModule.defineAnnotatedMethods(JRubyAttrVolatile.class); + + defineClass(runtime, synchronizationModule, "AbstractObject", "Object", + Object.class, OBJECT_ALLOCATOR); + + defineClass(runtime, synchronizationModule, "Object", "AbstractLockableObject", + AbstractLockableObject.class, ABSTRACT_LOCKABLE_OBJECT_ALLOCATOR); + + defineClass(runtime, synchronizationModule, "AbstractLockableObject", "JRubyLockableObject", + JRubyLockableObject.class, JRUBY_LOCKABLE_OBJECT_ALLOCATOR); + + defineClass(runtime, synchronizationModule, "Object", "JRuby", + JRuby.class, new ObjectAllocator() { + @Override + public IRubyObject allocate(Ruby runtime, RubyClass klazz) { + return new JRuby(runtime, klazz); + } + }); + } + + private RubyClass defineClass( + Ruby runtime, + RubyModule namespace, + String parentName, + String name, + Class javaImplementation, + ObjectAllocator allocator) { + final RubyClass parentClass = namespace.getClass(parentName); + + if (parentClass == null) { + System.out.println("not found " + parentName); + throw runtime.newRuntimeError(namespace.toString() + "::" + parentName + " is missing"); + } + + final RubyClass newClass = namespace.defineClassUnder(name, parentClass, allocator); + newClass.defineAnnotatedMethods(javaImplementation); + return newClass; + } + + // Facts: + // - all ivar reads are without any synchronisation of fences see + // https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/runtime/ivars/VariableAccessor.java#L110-110 + // - writes depend on UnsafeHolder.U, null -> SynchronizedVariableAccessor, !null -> StampedVariableAccessor + // SynchronizedVariableAccessor wraps with synchronized block, StampedVariableAccessor uses fullFence or + // volatilePut + // TODO (pitr 16-Sep-2015): what do we do in Java 9 ? + + // module JRubyAttrVolatile + public static class JRubyAttrVolatile { + + // volatile threadContext is used as a memory barrier per the JVM memory model happens-before semantic + // on volatile fields. any volatile field could have been used but using the thread context is an + // attempt to avoid code elimination. + private static volatile int volatileField; + + @JRubyMethod(name = "full_memory_barrier", visibility = Visibility.PUBLIC, module = true) + public static IRubyObject fullMemoryBarrier(ThreadContext context, IRubyObject module) { + // Prevent reordering of ivar writes with publication of this instance + if (!FULL_FENCE) { + // Assuming that following volatile read and write is not eliminated it simulates fullFence. + // If it's eliminated it'll cause problems only on non-x86 platforms. + // http://shipilev.net/blog/2014/jmm-pragmatics/#_happens_before_test_your_understanding + final int volatileRead = volatileField; + volatileField = context.getLine(); + } else { + UNSAFE.fullFence(); + } + return context.nil; + } + + @JRubyMethod(name = "instance_variable_get_volatile", visibility = Visibility.PUBLIC, module = true) + public static IRubyObject instanceVariableGetVolatile( + ThreadContext context, + IRubyObject module, + IRubyObject self, + IRubyObject name) { + // Ensure we ses latest value with loadFence + if (!FULL_FENCE) { + // piggybacking on volatile read, simulating loadFence + final int volatileRead = volatileField; + return ((RubyBasicObject) self).instance_variable_get(context, name); + } else { + UNSAFE.loadFence(); + return ((RubyBasicObject) self).instance_variable_get(context, name); + } + } + + @JRubyMethod(name = "instance_variable_set_volatile", visibility = Visibility.PUBLIC, module = true) + public static IRubyObject InstanceVariableSetVolatile( + ThreadContext context, + IRubyObject module, + IRubyObject self, + IRubyObject name, + IRubyObject value) { + // Ensure we make last update visible + if (!FULL_FENCE) { + // piggybacking on volatile write, simulating storeFence + final IRubyObject result = ((RubyBasicObject) self).instance_variable_set(name, value); + volatileField = context.getLine(); + return result; + } else { + // JRuby uses StampedVariableAccessor which calls fullFence + // so no additional steps needed. + // See https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/runtime/ivars/StampedVariableAccessor.java#L151-L159 + return ((RubyBasicObject) self).instance_variable_set(name, value); + } + } + } + + @JRubyClass(name = "Object", parent = "AbstractObject") + public static class Object extends RubyObject { + + public Object(Ruby runtime, RubyClass metaClass) { + super(runtime, metaClass); + } + } + + @JRubyClass(name = "AbstractLockableObject", parent = "Object") + public static class AbstractLockableObject extends Object { + + public AbstractLockableObject(Ruby runtime, RubyClass metaClass) { + super(runtime, metaClass); + } + } + + @JRubyClass(name = "JRubyLockableObject", parent = "AbstractLockableObject") + public static class JRubyLockableObject extends AbstractLockableObject { + + public JRubyLockableObject(Ruby runtime, RubyClass metaClass) { + super(runtime, metaClass); + } + + @JRubyMethod(name = "synchronize", visibility = Visibility.PROTECTED) + public IRubyObject rubySynchronize(ThreadContext context, Block block) { + synchronized (this) { + return block.yield(context, null); + } + } + + @JRubyMethod(name = "ns_wait", optional = 1, visibility = Visibility.PROTECTED) + public IRubyObject nsWait(ThreadContext context, IRubyObject[] args) { + Ruby runtime = context.runtime; + if (args.length > 1) { + throw runtime.newArgumentError(args.length, 1); + } + Double timeout = null; + if (args.length > 0 && !args[0].isNil()) { + timeout = args[0].convertToFloat().getDoubleValue(); + if (timeout < 0) { + throw runtime.newArgumentError("time interval must be positive"); + } + } + if (Thread.interrupted()) { + throw runtime.newConcurrencyError("thread interrupted"); + } + boolean success = false; + try { + success = context.getThread().wait_timeout(this, timeout); + } catch (InterruptedException ie) { + throw runtime.newConcurrencyError(ie.getLocalizedMessage()); + } finally { + // An interrupt or timeout may have caused us to miss + // a notify that we consumed, so do another notify in + // case someone else is available to pick it up. + if (!success) { + this.notify(); + } + } + return this; + } + + @JRubyMethod(name = "ns_signal", visibility = Visibility.PROTECTED) + public IRubyObject nsSignal(ThreadContext context) { + notify(); + return this; + } + + @JRubyMethod(name = "ns_broadcast", visibility = Visibility.PROTECTED) + public IRubyObject nsBroadcast(ThreadContext context) { + notifyAll(); + return this; + } + } + + @JRubyClass(name = "JRuby") + public static class JRuby extends RubyObject { + public JRuby(Ruby runtime, RubyClass metaClass) { + super(runtime, metaClass); + } + + @JRubyMethod(name = "sleep_interruptibly", visibility = Visibility.PUBLIC, module = true) + public static IRubyObject sleepInterruptibly(final ThreadContext context, IRubyObject receiver, final Block block) { + try { + context.getThread().executeBlockingTask(new RubyThread.BlockingTask() { + @Override + public void run() throws InterruptedException { + block.call(context); + } + + @Override + public void wakeup() { + context.getThread().getNativeThread().interrupt(); + } + }); + } catch (InterruptedException e) { + throw context.runtime.newThreadError("interrupted in Concurrent::Synchronization::JRuby.sleep_interruptibly"); + } + return context.nil; + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMap.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMap.java new file mode 100644 index 0000000..e11e15a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMap.java @@ -0,0 +1,31 @@ +package com.concurrent_ruby.ext.jsr166e; + +import java.util.Map; +import java.util.Set; + +public interface ConcurrentHashMap { + /** Interface describing a function of one argument */ + public interface Fun { T apply(A a); } + /** Interface describing a function of two arguments */ + public interface BiFun { T apply(A a, B b); } + + public V get(K key); + public V put(K key, V value); + public V putIfAbsent(K key, V value); + public V computeIfAbsent(K key, Fun mf); + public V computeIfPresent(K key, BiFun mf); + public V compute(K key, BiFun mf); + public V merge(K key, V value, BiFun mf); + public boolean replace(K key, V oldVal, V newVal); + public V replace(K key, V value); + public boolean containsKey(K key); + public boolean remove(Object key, Object value); + public V remove(K key); + public void clear(); + public Set> entrySet(); + public int size(); + public V getValueOrDefault(Object key, V defaultValue); + + public boolean containsValue(V value); + public K findKey(V value); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java new file mode 100644 index 0000000..86aa4eb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java @@ -0,0 +1,3863 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This is based on the 1.79 version. + +package com.concurrent_ruby.ext.jsr166e; + +import org.jruby.RubyClass; +import org.jruby.RubyNumeric; +import org.jruby.RubyObject; +import org.jruby.exceptions.RaiseException; +import com.concurrent_ruby.ext.jsr166y.ThreadLocalRandom; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; + +import java.util.Arrays; +import java.util.Map; +import java.util.Set; +import java.util.Collection; +import java.util.Hashtable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Enumeration; +import java.util.ConcurrentModificationException; +import java.util.NoSuchElementException; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.locks.AbstractQueuedSynchronizer; + +import java.io.Serializable; + +/** + * A hash table supporting full concurrency of retrievals and + * high expected concurrency for updates. This class obeys the + * same functional specification as {@link java.util.Hashtable}, and + * includes versions of methods corresponding to each method of + * {@code Hashtable}. However, even though all operations are + * thread-safe, retrieval operations do not entail locking, + * and there is not any support for locking the entire table + * in a way that prevents all access. This class is fully + * interoperable with {@code Hashtable} in programs that rely on its + * thread safety but not on its synchronization details. + * + *

Retrieval operations (including {@code get}) generally do not + * block, so may overlap with update operations (including {@code put} + * and {@code remove}). Retrievals reflect the results of the most + * recently completed update operations holding upon their + * onset. (More formally, an update operation for a given key bears a + * happens-before relation with any (non-null) retrieval for + * that key reporting the updated value.) For aggregate operations + * such as {@code putAll} and {@code clear}, concurrent retrievals may + * reflect insertion or removal of only some entries. Similarly, + * Iterators and Enumerations return elements reflecting the state of + * the hash table at some point at or since the creation of the + * iterator/enumeration. They do not throw {@link + * ConcurrentModificationException}. However, iterators are designed + * to be used by only one thread at a time. Bear in mind that the + * results of aggregate status methods including {@code size}, {@code + * isEmpty}, and {@code containsValue} are typically useful only when + * a map is not undergoing concurrent updates in other threads. + * Otherwise the results of these methods reflect transient states + * that may be adequate for monitoring or estimation purposes, but not + * for program control. + * + *

The table is dynamically expanded when there are too many + * collisions (i.e., keys that have distinct hash codes but fall into + * the same slot modulo the table size), with the expected average + * effect of maintaining roughly two bins per mapping (corresponding + * to a 0.75 load factor threshold for resizing). There may be much + * variance around this average as mappings are added and removed, but + * overall, this maintains a commonly accepted time/space tradeoff for + * hash tables. However, resizing this or any other kind of hash + * table may be a relatively slow operation. When possible, it is a + * good idea to provide a size estimate as an optional {@code + * initialCapacity} constructor argument. An additional optional + * {@code loadFactor} constructor argument provides a further means of + * customizing initial table capacity by specifying the table density + * to be used in calculating the amount of space to allocate for the + * given number of elements. Also, for compatibility with previous + * versions of this class, constructors may optionally specify an + * expected {@code concurrencyLevel} as an additional hint for + * internal sizing. Note that using many keys with exactly the same + * {@code hashCode()} is a sure way to slow down performance of any + * hash table. + * + *

A {@link Set} projection of a ConcurrentHashMapV8 may be created + * (using {@link #newKeySet()} or {@link #newKeySet(int)}), or viewed + * (using {@link #keySet(Object)} when only keys are of interest, and the + * mapped values are (perhaps transiently) not used or all take the + * same mapping value. + * + *

A ConcurrentHashMapV8 can be used as scalable frequency map (a + * form of histogram or multiset) by using {@link LongAdder} values + * and initializing via {@link #computeIfAbsent}. For example, to add + * a count to a {@code ConcurrentHashMapV8 freqs}, you + * can use {@code freqs.computeIfAbsent(k -> new + * LongAdder()).increment();} + * + *

This class and its views and iterators implement all of the + * optional methods of the {@link Map} and {@link Iterator} + * interfaces. + * + *

Like {@link Hashtable} but unlike {@link HashMap}, this class + * does not allow {@code null} to be used as a key or value. + * + *

ConcurrentHashMapV8s support parallel operations using the {@link + * ForkJoinPool#commonPool}. (Tasks that may be used in other contexts + * are available in class {@link ForkJoinTasks}). These operations are + * designed to be safely, and often sensibly, applied even with maps + * that are being concurrently updated by other threads; for example, + * when computing a snapshot summary of the values in a shared + * registry. There are three kinds of operation, each with four + * forms, accepting functions with Keys, Values, Entries, and (Key, + * Value) arguments and/or return values. (The first three forms are + * also available via the {@link #keySet()}, {@link #values()} and + * {@link #entrySet()} views). Because the elements of a + * ConcurrentHashMapV8 are not ordered in any particular way, and may be + * processed in different orders in different parallel executions, the + * correctness of supplied functions should not depend on any + * ordering, or on any other objects or values that may transiently + * change while computation is in progress; and except for forEach + * actions, should ideally be side-effect-free. + * + *

    + *
  • forEach: Perform a given action on each element. + * A variant form applies a given transformation on each element + * before performing the action.
  • + * + *
  • search: Return the first available non-null result of + * applying a given function on each element; skipping further + * search when a result is found.
  • + * + *
  • reduce: Accumulate each element. The supplied reduction + * function cannot rely on ordering (more formally, it should be + * both associative and commutative). There are five variants: + * + *
      + * + *
    • Plain reductions. (There is not a form of this method for + * (key, value) function arguments since there is no corresponding + * return type.)
    • + * + *
    • Mapped reductions that accumulate the results of a given + * function applied to each element.
    • + * + *
    • Reductions to scalar doubles, longs, and ints, using a + * given basis value.
    • + * + * + *
    + *
+ * + *

The concurrency properties of bulk operations follow + * from those of ConcurrentHashMapV8: Any non-null result returned + * from {@code get(key)} and related access methods bears a + * happens-before relation with the associated insertion or + * update. The result of any bulk operation reflects the + * composition of these per-element relations (but is not + * necessarily atomic with respect to the map as a whole unless it + * is somehow known to be quiescent). Conversely, because keys + * and values in the map are never null, null serves as a reliable + * atomic indicator of the current lack of any result. To + * maintain this property, null serves as an implicit basis for + * all non-scalar reduction operations. For the double, long, and + * int versions, the basis should be one that, when combined with + * any other value, returns that other value (more formally, it + * should be the identity element for the reduction). Most common + * reductions have these properties; for example, computing a sum + * with basis 0 or a minimum with basis MAX_VALUE. + * + *

Search and transformation functions provided as arguments + * should similarly return null to indicate the lack of any result + * (in which case it is not used). In the case of mapped + * reductions, this also enables transformations to serve as + * filters, returning null (or, in the case of primitive + * specializations, the identity basis) if the element should not + * be combined. You can create compound transformations and + * filterings by composing them yourself under this "null means + * there is nothing there now" rule before using them in search or + * reduce operations. + * + *

Methods accepting and/or returning Entry arguments maintain + * key-value associations. They may be useful for example when + * finding the key for the greatest value. Note that "plain" Entry + * arguments can be supplied using {@code new + * AbstractMap.SimpleEntry(k,v)}. + * + *

Bulk operations may complete abruptly, throwing an + * exception encountered in the application of a supplied + * function. Bear in mind when handling such exceptions that other + * concurrently executing functions could also have thrown + * exceptions, or would have done so if the first exception had + * not occurred. + * + *

Parallel speedups for bulk operations compared to sequential + * processing are common but not guaranteed. Operations involving + * brief functions on small maps may execute more slowly than + * sequential loops if the underlying work to parallelize the + * computation is more expensive than the computation itself. + * Similarly, parallelization may not lead to much actual parallelism + * if all processors are busy performing unrelated tasks. + * + *

All arguments to all task methods must be non-null. + * + *

jsr166e note: During transition, this class + * uses nested functional interfaces with different names but the + * same forms as those expected for JDK8. + * + *

This class is a member of the + * + * Java Collections Framework. + * + * @since 1.5 + * @author Doug Lea + * @param the type of keys maintained by this map + * @param the type of mapped values + */ +public class ConcurrentHashMapV8 + implements ConcurrentMap, Serializable, ConcurrentHashMap { + private static final long serialVersionUID = 7249069246763182397L; + + /** + * A partitionable iterator. A Spliterator can be traversed + * directly, but can also be partitioned (before traversal) by + * creating another Spliterator that covers a non-overlapping + * portion of the elements, and so may be amenable to parallel + * execution. + * + *

This interface exports a subset of expected JDK8 + * functionality. + * + *

Sample usage: Here is one (of the several) ways to compute + * the sum of the values held in a map using the ForkJoin + * framework. As illustrated here, Spliterators are well suited to + * designs in which a task repeatedly splits off half its work + * into forked subtasks until small enough to process directly, + * and then joins these subtasks. Variants of this style can also + * be used in completion-based designs. + * + *

+     * {@code ConcurrentHashMapV8 m = ...
+     * // split as if have 8 * parallelism, for load balance
+     * int n = m.size();
+     * int p = aForkJoinPool.getParallelism() * 8;
+     * int split = (n < p)? n : p;
+     * long sum = aForkJoinPool.invoke(new SumValues(m.valueSpliterator(), split, null));
+     * // ...
+     * static class SumValues extends RecursiveTask {
+     *   final Spliterator s;
+     *   final int split;             // split while > 1
+     *   final SumValues nextJoin;    // records forked subtasks to join
+     *   SumValues(Spliterator s, int depth, SumValues nextJoin) {
+     *     this.s = s; this.depth = depth; this.nextJoin = nextJoin;
+     *   }
+     *   public Long compute() {
+     *     long sum = 0;
+     *     SumValues subtasks = null; // fork subtasks
+     *     for (int s = split >>> 1; s > 0; s >>>= 1)
+     *       (subtasks = new SumValues(s.split(), s, subtasks)).fork();
+     *     while (s.hasNext())        // directly process remaining elements
+     *       sum += s.next();
+     *     for (SumValues t = subtasks; t != null; t = t.nextJoin)
+     *       sum += t.join();         // collect subtask results
+     *     return sum;
+     *   }
+     * }
+     * }
+ */ + public static interface Spliterator extends Iterator { + /** + * Returns a Spliterator covering approximately half of the + * elements, guaranteed not to overlap with those subsequently + * returned by this Spliterator. After invoking this method, + * the current Spliterator will not produce any of + * the elements of the returned Spliterator, but the two + * Spliterators together will produce all of the elements that + * would have been produced by this Spliterator had this + * method not been called. The exact number of elements + * produced by the returned Spliterator is not guaranteed, and + * may be zero (i.e., with {@code hasNext()} reporting {@code + * false}) if this Spliterator cannot be further split. + * + * @return a Spliterator covering approximately half of the + * elements + * @throws IllegalStateException if this Spliterator has + * already commenced traversing elements + */ + Spliterator split(); + } + + + /* + * Overview: + * + * The primary design goal of this hash table is to maintain + * concurrent readability (typically method get(), but also + * iterators and related methods) while minimizing update + * contention. Secondary goals are to keep space consumption about + * the same or better than java.util.HashMap, and to support high + * initial insertion rates on an empty table by many threads. + * + * Each key-value mapping is held in a Node. Because Node fields + * can contain special values, they are defined using plain Object + * types. Similarly in turn, all internal methods that use them + * work off Object types. And similarly, so do the internal + * methods of auxiliary iterator and view classes. All public + * generic typed methods relay in/out of these internal methods, + * supplying null-checks and casts as needed. This also allows + * many of the public methods to be factored into a smaller number + * of internal methods (although sadly not so for the five + * variants of put-related operations). The validation-based + * approach explained below leads to a lot of code sprawl because + * retry-control precludes factoring into smaller methods. + * + * The table is lazily initialized to a power-of-two size upon the + * first insertion. Each bin in the table normally contains a + * list of Nodes (most often, the list has only zero or one Node). + * Table accesses require volatile/atomic reads, writes, and + * CASes. Because there is no other way to arrange this without + * adding further indirections, we use intrinsics + * (sun.misc.Unsafe) operations. The lists of nodes within bins + * are always accurately traversable under volatile reads, so long + * as lookups check hash code and non-nullness of value before + * checking key equality. + * + * We use the top two bits of Node hash fields for control + * purposes -- they are available anyway because of addressing + * constraints. As explained further below, these top bits are + * used as follows: + * 00 - Normal + * 01 - Locked + * 11 - Locked and may have a thread waiting for lock + * 10 - Node is a forwarding node + * + * The lower 30 bits of each Node's hash field contain a + * transformation of the key's hash code, except for forwarding + * nodes, for which the lower bits are zero (and so always have + * hash field == MOVED). + * + * Insertion (via put or its variants) of the first node in an + * empty bin is performed by just CASing it to the bin. This is + * by far the most common case for put operations under most + * key/hash distributions. Other update operations (insert, + * delete, and replace) require locks. We do not want to waste + * the space required to associate a distinct lock object with + * each bin, so instead use the first node of a bin list itself as + * a lock. Blocking support for these locks relies on the builtin + * "synchronized" monitors. However, we also need a tryLock + * construction, so we overlay these by using bits of the Node + * hash field for lock control (see above), and so normally use + * builtin monitors only for blocking and signalling using + * wait/notifyAll constructions. See Node.tryAwaitLock. + * + * Using the first node of a list as a lock does not by itself + * suffice though: When a node is locked, any update must first + * validate that it is still the first node after locking it, and + * retry if not. Because new nodes are always appended to lists, + * once a node is first in a bin, it remains first until deleted + * or the bin becomes invalidated (upon resizing). However, + * operations that only conditionally update may inspect nodes + * until the point of update. This is a converse of sorts to the + * lazy locking technique described by Herlihy & Shavit. + * + * The main disadvantage of per-bin locks is that other update + * operations on other nodes in a bin list protected by the same + * lock can stall, for example when user equals() or mapping + * functions take a long time. However, statistically, under + * random hash codes, this is not a common problem. Ideally, the + * frequency of nodes in bins follows a Poisson distribution + * (http://en.wikipedia.org/wiki/Poisson_distribution) with a + * parameter of about 0.5 on average, given the resizing threshold + * of 0.75, although with a large variance because of resizing + * granularity. Ignoring variance, the expected occurrences of + * list size k are (exp(-0.5) * pow(0.5, k) / factorial(k)). The + * first values are: + * + * 0: 0.60653066 + * 1: 0.30326533 + * 2: 0.07581633 + * 3: 0.01263606 + * 4: 0.00157952 + * 5: 0.00015795 + * 6: 0.00001316 + * 7: 0.00000094 + * 8: 0.00000006 + * more: less than 1 in ten million + * + * Lock contention probability for two threads accessing distinct + * elements is roughly 1 / (8 * #elements) under random hashes. + * + * Actual hash code distributions encountered in practice + * sometimes deviate significantly from uniform randomness. This + * includes the case when N > (1<<30), so some keys MUST collide. + * Similarly for dumb or hostile usages in which multiple keys are + * designed to have identical hash codes. Also, although we guard + * against the worst effects of this (see method spread), sets of + * hashes may differ only in bits that do not impact their bin + * index for a given power-of-two mask. So we use a secondary + * strategy that applies when the number of nodes in a bin exceeds + * a threshold, and at least one of the keys implements + * Comparable. These TreeBins use a balanced tree to hold nodes + * (a specialized form of red-black trees), bounding search time + * to O(log N). Each search step in a TreeBin is around twice as + * slow as in a regular list, but given that N cannot exceed + * (1<<64) (before running out of addresses) this bounds search + * steps, lock hold times, etc, to reasonable constants (roughly + * 100 nodes inspected per operation worst case) so long as keys + * are Comparable (which is very common -- String, Long, etc). + * TreeBin nodes (TreeNodes) also maintain the same "next" + * traversal pointers as regular nodes, so can be traversed in + * iterators in the same way. + * + * The table is resized when occupancy exceeds a percentage + * threshold (nominally, 0.75, but see below). Only a single + * thread performs the resize (using field "sizeCtl", to arrange + * exclusion), but the table otherwise remains usable for reads + * and updates. Resizing proceeds by transferring bins, one by + * one, from the table to the next table. Because we are using + * power-of-two expansion, the elements from each bin must either + * stay at same index, or move with a power of two offset. We + * eliminate unnecessary node creation by catching cases where old + * nodes can be reused because their next fields won't change. On + * average, only about one-sixth of them need cloning when a table + * doubles. The nodes they replace will be garbage collectable as + * soon as they are no longer referenced by any reader thread that + * may be in the midst of concurrently traversing table. Upon + * transfer, the old table bin contains only a special forwarding + * node (with hash field "MOVED") that contains the next table as + * its key. On encountering a forwarding node, access and update + * operations restart, using the new table. + * + * Each bin transfer requires its bin lock. However, unlike other + * cases, a transfer can skip a bin if it fails to acquire its + * lock, and revisit it later (unless it is a TreeBin). Method + * rebuild maintains a buffer of TRANSFER_BUFFER_SIZE bins that + * have been skipped because of failure to acquire a lock, and + * blocks only if none are available (i.e., only very rarely). + * The transfer operation must also ensure that all accessible + * bins in both the old and new table are usable by any traversal. + * When there are no lock acquisition failures, this is arranged + * simply by proceeding from the last bin (table.length - 1) up + * towards the first. Upon seeing a forwarding node, traversals + * (see class Iter) arrange to move to the new table + * without revisiting nodes. However, when any node is skipped + * during a transfer, all earlier table bins may have become + * visible, so are initialized with a reverse-forwarding node back + * to the old table until the new ones are established. (This + * sometimes requires transiently locking a forwarding node, which + * is possible under the above encoding.) These more expensive + * mechanics trigger only when necessary. + * + * The traversal scheme also applies to partial traversals of + * ranges of bins (via an alternate Traverser constructor) + * to support partitioned aggregate operations. Also, read-only + * operations give up if ever forwarded to a null table, which + * provides support for shutdown-style clearing, which is also not + * currently implemented. + * + * Lazy table initialization minimizes footprint until first use, + * and also avoids resizings when the first operation is from a + * putAll, constructor with map argument, or deserialization. + * These cases attempt to override the initial capacity settings, + * but harmlessly fail to take effect in cases of races. + * + * The element count is maintained using a LongAdder, which avoids + * contention on updates but can encounter cache thrashing if read + * too frequently during concurrent access. To avoid reading so + * often, resizing is attempted either when a bin lock is + * contended, or upon adding to a bin already holding two or more + * nodes (checked before adding in the xIfAbsent methods, after + * adding in others). Under uniform hash distributions, the + * probability of this occurring at threshold is around 13%, + * meaning that only about 1 in 8 puts check threshold (and after + * resizing, many fewer do so). But this approximation has high + * variance for small table sizes, so we check on any collision + * for sizes <= 64. The bulk putAll operation further reduces + * contention by only committing count updates upon these size + * checks. + * + * Maintaining API and serialization compatibility with previous + * versions of this class introduces several oddities. Mainly: We + * leave untouched but unused constructor arguments refering to + * concurrencyLevel. We accept a loadFactor constructor argument, + * but apply it only to initial table capacity (which is the only + * time that we can guarantee to honor it.) We also declare an + * unused "Segment" class that is instantiated in minimal form + * only when serializing. + */ + + /* ---------------- Constants -------------- */ + + /** + * The largest possible table capacity. This value must be + * exactly 1<<30 to stay within Java array allocation and indexing + * bounds for power of two table sizes, and is further required + * because the top two bits of 32bit hash fields are used for + * control purposes. + */ + private static final int MAXIMUM_CAPACITY = 1 << 30; + + /** + * The default initial table capacity. Must be a power of 2 + * (i.e., at least 1) and at most MAXIMUM_CAPACITY. + */ + private static final int DEFAULT_CAPACITY = 16; + + /** + * The largest possible (non-power of two) array size. + * Needed by toArray and related methods. + */ + static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + + /** + * The default concurrency level for this table. Unused but + * defined for compatibility with previous versions of this class. + */ + private static final int DEFAULT_CONCURRENCY_LEVEL = 16; + + /** + * The load factor for this table. Overrides of this value in + * constructors affect only the initial table capacity. The + * actual floating point value isn't normally used -- it is + * simpler to use expressions such as {@code n - (n >>> 2)} for + * the associated resizing threshold. + */ + private static final float LOAD_FACTOR = 0.75f; + + /** + * The buffer size for skipped bins during transfers. The + * value is arbitrary but should be large enough to avoid + * most locking stalls during resizes. + */ + private static final int TRANSFER_BUFFER_SIZE = 32; + + /** + * The bin count threshold for using a tree rather than list for a + * bin. The value reflects the approximate break-even point for + * using tree-based operations. + * Note that Doug's version defaults to 8, but when dealing with + * Ruby objects it is actually beneficial to avoid TreeNodes + * as long as possible as it usually means going into Ruby land. + */ + private static final int TREE_THRESHOLD = 16; + + /* + * Encodings for special uses of Node hash fields. See above for + * explanation. + */ + static final int MOVED = 0x80000000; // hash field for forwarding nodes + static final int LOCKED = 0x40000000; // set/tested only as a bit + static final int WAITING = 0xc0000000; // both bits set/tested together + static final int HASH_BITS = 0x3fffffff; // usable bits of normal node hash + + /* ---------------- Fields -------------- */ + + /** + * The array of bins. Lazily initialized upon first insertion. + * Size is always a power of two. Accessed directly by iterators. + */ + transient volatile Node[] table; + + /** + * The counter maintaining number of elements. + */ + private transient final LongAdder counter; + + /** + * Table initialization and resizing control. When negative, the + * table is being initialized or resized. Otherwise, when table is + * null, holds the initial table size to use upon creation, or 0 + * for default. After initialization, holds the next element count + * value upon which to resize the table. + */ + private transient volatile int sizeCtl; + + // views + private transient KeySetView keySet; + private transient ValuesView values; + private transient EntrySetView entrySet; + + /** For serialization compatibility. Null unless serialized; see below */ + private Segment[] segments; + + /* ---------------- Table element access -------------- */ + + /* + * Volatile access methods are used for table elements as well as + * elements of in-progress next table while resizing. Uses are + * null checked by callers, and implicitly bounds-checked, relying + * on the invariants that tab arrays have non-zero size, and all + * indices are masked with (tab.length - 1) which is never + * negative and always less than length. Note that, to be correct + * wrt arbitrary concurrency errors by users, bounds checks must + * operate on local variables, which accounts for some odd-looking + * inline assignments below. + */ + + static final Node tabAt(Node[] tab, int i) { // used by Iter + return (Node)UNSAFE.getObjectVolatile(tab, ((long)i< 1 ? 64 : 1; + + /** + * Spins a while if LOCKED bit set and this node is the first + * of its bin, and then sets WAITING bits on hash field and + * blocks (once) if they are still set. It is OK for this + * method to return even if lock is not available upon exit, + * which enables these simple single-wait mechanics. + * + * The corresponding signalling operation is performed within + * callers: Upon detecting that WAITING has been set when + * unlocking lock (via a failed CAS from non-waiting LOCKED + * state), unlockers acquire the sync lock and perform a + * notifyAll. + * + * The initial sanity check on tab and bounds is not currently + * necessary in the only usages of this method, but enables + * use in other future contexts. + */ + final void tryAwaitLock(Node[] tab, int i) { + if (tab != null && i >= 0 && i < tab.length) { // sanity check + int r = ThreadLocalRandom.current().nextInt(); // randomize spins + int spins = MAX_SPINS, h; + while (tabAt(tab, i) == this && ((h = hash) & LOCKED) != 0) { + if (spins >= 0) { + r ^= r << 1; r ^= r >>> 3; r ^= r << 10; // xorshift + if (r >= 0 && --spins == 0) + Thread.yield(); // yield before block + } + else if (casHash(h, h | WAITING)) { + synchronized (this) { + if (tabAt(tab, i) == this && + (hash & WAITING) == WAITING) { + try { + wait(); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + } + } + else + notifyAll(); // possibly won race vs signaller + } + break; + } + } + } + } + + // Unsafe mechanics for casHash + private static final sun.misc.Unsafe UNSAFE; + private static final long hashOffset; + + static { + try { + UNSAFE = getUnsafe(); + Class k = Node.class; + hashOffset = UNSAFE.objectFieldOffset + (k.getDeclaredField("hash")); + } catch (Exception e) { + throw new Error(e); + } + } + } + + /* ---------------- TreeBins -------------- */ + + /** + * Nodes for use in TreeBins + */ + static final class TreeNode extends Node { + TreeNode parent; // red-black tree links + TreeNode left; + TreeNode right; + TreeNode prev; // needed to unlink next upon deletion + boolean red; + + TreeNode(int hash, Object key, Object val, Node next, TreeNode parent) { + super(hash, key, val, next); + this.parent = parent; + } + } + + /** + * A specialized form of red-black tree for use in bins + * whose size exceeds a threshold. + * + * TreeBins use a special form of comparison for search and + * related operations (which is the main reason we cannot use + * existing collections such as TreeMaps). TreeBins contain + * Comparable elements, but may contain others, as well as + * elements that are Comparable but not necessarily Comparable + * for the same T, so we cannot invoke compareTo among them. To + * handle this, the tree is ordered primarily by hash value, then + * by getClass().getName() order, and then by Comparator order + * among elements of the same class. On lookup at a node, if + * elements are not comparable or compare as 0, both left and + * right children may need to be searched in the case of tied hash + * values. (This corresponds to the full list search that would be + * necessary if all elements were non-Comparable and had tied + * hashes.) The red-black balancing code is updated from + * pre-jdk-collections + * (http://gee.cs.oswego.edu/dl/classes/collections/RBCell.java) + * based in turn on Cormen, Leiserson, and Rivest "Introduction to + * Algorithms" (CLR). + * + * TreeBins also maintain a separate locking discipline than + * regular bins. Because they are forwarded via special MOVED + * nodes at bin heads (which can never change once established), + * we cannot use those nodes as locks. Instead, TreeBin + * extends AbstractQueuedSynchronizer to support a simple form of + * read-write lock. For update operations and table validation, + * the exclusive form of lock behaves in the same way as bin-head + * locks. However, lookups use shared read-lock mechanics to allow + * multiple readers in the absence of writers. Additionally, + * these lookups do not ever block: While the lock is not + * available, they proceed along the slow traversal path (via + * next-pointers) until the lock becomes available or the list is + * exhausted, whichever comes first. (These cases are not fast, + * but maximize aggregate expected throughput.) The AQS mechanics + * for doing this are straightforward. The lock state is held as + * AQS getState(). Read counts are negative; the write count (1) + * is positive. There are no signalling preferences among readers + * and writers. Since we don't need to export full Lock API, we + * just override the minimal AQS methods and use them directly. + */ + static final class TreeBin extends AbstractQueuedSynchronizer { + private static final long serialVersionUID = 2249069246763182397L; + transient TreeNode root; // root of tree + transient TreeNode first; // head of next-pointer list + + /* AQS overrides */ + public final boolean isHeldExclusively() { return getState() > 0; } + public final boolean tryAcquire(int ignore) { + if (compareAndSetState(0, 1)) { + setExclusiveOwnerThread(Thread.currentThread()); + return true; + } + return false; + } + public final boolean tryRelease(int ignore) { + setExclusiveOwnerThread(null); + setState(0); + return true; + } + public final int tryAcquireShared(int ignore) { + for (int c;;) { + if ((c = getState()) > 0) + return -1; + if (compareAndSetState(c, c -1)) + return 1; + } + } + public final boolean tryReleaseShared(int ignore) { + int c; + do {} while (!compareAndSetState(c = getState(), c + 1)); + return c == -1; + } + + /** From CLR */ + private void rotateLeft(TreeNode p) { + if (p != null) { + TreeNode r = p.right, pp, rl; + if ((rl = p.right = r.left) != null) + rl.parent = p; + if ((pp = r.parent = p.parent) == null) + root = r; + else if (pp.left == p) + pp.left = r; + else + pp.right = r; + r.left = p; + p.parent = r; + } + } + + /** From CLR */ + private void rotateRight(TreeNode p) { + if (p != null) { + TreeNode l = p.left, pp, lr; + if ((lr = p.left = l.right) != null) + lr.parent = p; + if ((pp = l.parent = p.parent) == null) + root = l; + else if (pp.right == p) + pp.right = l; + else + pp.left = l; + l.right = p; + p.parent = l; + } + } + + @SuppressWarnings("unchecked") final TreeNode getTreeNode + (int h, Object k, TreeNode p) { + return getTreeNode(h, (RubyObject)k, p); + } + + /** + * Returns the TreeNode (or null if not found) for the given key + * starting at given root. + */ + @SuppressWarnings("unchecked") final TreeNode getTreeNode + (int h, RubyObject k, TreeNode p) { + RubyClass c = k.getMetaClass(); boolean kNotComparable = !k.respondsTo("<=>"); + while (p != null) { + int dir, ph; RubyObject pk; RubyClass pc; + if ((ph = p.hash) == h) { + if ((pk = (RubyObject)p.key) == k || k.equals(pk)) + return p; + if (c != (pc = (RubyClass)pk.getMetaClass()) || + kNotComparable || + (dir = rubyCompare(k, pk)) == 0) { + dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); + if (dir == 0) { // if still stuck, need to check both sides + TreeNode r = null, pl, pr; + // try to recurse on the right + if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null) + return r; + // try to continue iterating on the left side + else if ((pl = p.left) != null && h <= pl.hash) + dir = -1; + else // no matching node found + return null; + } + } + } + else + dir = (h < ph) ? -1 : 1; + p = (dir > 0) ? p.right : p.left; + } + return null; + } + + int rubyCompare(RubyObject l, RubyObject r) { + ThreadContext context = l.getMetaClass().getRuntime().getCurrentContext(); + IRubyObject result; + try { + result = l.callMethod(context, "<=>", r); + } catch (RaiseException e) { + // handle objects "lying" about responding to <=>, ie: an Array containing non-comparable keys + if (context.runtime.getNoMethodError().isInstance(e.getException())) { + return 0; + } + throw e; + } + + return result.isNil() ? 0 : RubyNumeric.num2int(result.convertToInteger()); + } + + /** + * Wrapper for getTreeNode used by CHM.get. Tries to obtain + * read-lock to call getTreeNode, but during failure to get + * lock, searches along next links. + */ + final Object getValue(int h, Object k) { + Node r = null; + int c = getState(); // Must read lock state first + for (Node e = first; e != null; e = e.next) { + if (c <= 0 && compareAndSetState(c, c - 1)) { + try { + r = getTreeNode(h, k, root); + } finally { + releaseShared(0); + } + break; + } + else if ((e.hash & HASH_BITS) == h && k.equals(e.key)) { + r = e; + break; + } + else + c = getState(); + } + return r == null ? null : r.val; + } + + @SuppressWarnings("unchecked") final TreeNode putTreeNode + (int h, Object k, Object v) { + return putTreeNode(h, (RubyObject)k, v); + } + + /** + * Finds or adds a node. + * @return null if added + */ + @SuppressWarnings("unchecked") final TreeNode putTreeNode + (int h, RubyObject k, Object v) { + RubyClass c = k.getMetaClass(); + boolean kNotComparable = !k.respondsTo("<=>"); + TreeNode pp = root, p = null; + int dir = 0; + while (pp != null) { // find existing node or leaf to insert at + int ph; RubyObject pk; RubyClass pc; + p = pp; + if ((ph = p.hash) == h) { + if ((pk = (RubyObject)p.key) == k || k.equals(pk)) + return p; + if (c != (pc = pk.getMetaClass()) || + kNotComparable || + (dir = rubyCompare(k, pk)) == 0) { + dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); + if (dir == 0) { // if still stuck, need to check both sides + TreeNode r = null, pr; + // try to recurse on the right + if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null) + return r; + else // continue descending down the left subtree + dir = -1; + } + } + } + else + dir = (h < ph) ? -1 : 1; + pp = (dir > 0) ? p.right : p.left; + } + + TreeNode f = first; + TreeNode x = first = new TreeNode(h, (Object)k, v, f, p); + if (p == null) + root = x; + else { // attach and rebalance; adapted from CLR + TreeNode xp, xpp; + if (f != null) + f.prev = x; + if (dir <= 0) + p.left = x; + else + p.right = x; + x.red = true; + while (x != null && (xp = x.parent) != null && xp.red && + (xpp = xp.parent) != null) { + TreeNode xppl = xpp.left; + if (xp == xppl) { + TreeNode y = xpp.right; + if (y != null && y.red) { + y.red = false; + xp.red = false; + xpp.red = true; + x = xpp; + } + else { + if (x == xp.right) { + rotateLeft(x = xp); + xpp = (xp = x.parent) == null ? null : xp.parent; + } + if (xp != null) { + xp.red = false; + if (xpp != null) { + xpp.red = true; + rotateRight(xpp); + } + } + } + } + else { + TreeNode y = xppl; + if (y != null && y.red) { + y.red = false; + xp.red = false; + xpp.red = true; + x = xpp; + } + else { + if (x == xp.left) { + rotateRight(x = xp); + xpp = (xp = x.parent) == null ? null : xp.parent; + } + if (xp != null) { + xp.red = false; + if (xpp != null) { + xpp.red = true; + rotateLeft(xpp); + } + } + } + } + } + TreeNode r = root; + if (r != null && r.red) + r.red = false; + } + return null; + } + + /** + * Removes the given node, that must be present before this + * call. This is messier than typical red-black deletion code + * because we cannot swap the contents of an interior node + * with a leaf successor that is pinned by "next" pointers + * that are accessible independently of lock. So instead we + * swap the tree linkages. + */ + final void deleteTreeNode(TreeNode p) { + TreeNode next = (TreeNode)p.next; // unlink traversal pointers + TreeNode pred = p.prev; + if (pred == null) + first = next; + else + pred.next = next; + if (next != null) + next.prev = pred; + TreeNode replacement; + TreeNode pl = p.left; + TreeNode pr = p.right; + if (pl != null && pr != null) { + TreeNode s = pr, sl; + while ((sl = s.left) != null) // find successor + s = sl; + boolean c = s.red; s.red = p.red; p.red = c; // swap colors + TreeNode sr = s.right; + TreeNode pp = p.parent; + if (s == pr) { // p was s's direct parent + p.parent = s; + s.right = p; + } + else { + TreeNode sp = s.parent; + if ((p.parent = sp) != null) { + if (s == sp.left) + sp.left = p; + else + sp.right = p; + } + if ((s.right = pr) != null) + pr.parent = s; + } + p.left = null; + if ((p.right = sr) != null) + sr.parent = p; + if ((s.left = pl) != null) + pl.parent = s; + if ((s.parent = pp) == null) + root = s; + else if (p == pp.left) + pp.left = s; + else + pp.right = s; + replacement = sr; + } + else + replacement = (pl != null) ? pl : pr; + TreeNode pp = p.parent; + if (replacement == null) { + if (pp == null) { + root = null; + return; + } + replacement = p; + } + else { + replacement.parent = pp; + if (pp == null) + root = replacement; + else if (p == pp.left) + pp.left = replacement; + else + pp.right = replacement; + p.left = p.right = p.parent = null; + } + if (!p.red) { // rebalance, from CLR + TreeNode x = replacement; + while (x != null) { + TreeNode xp, xpl; + if (x.red || (xp = x.parent) == null) { + x.red = false; + break; + } + if (x == (xpl = xp.left)) { + TreeNode sib = xp.right; + if (sib != null && sib.red) { + sib.red = false; + xp.red = true; + rotateLeft(xp); + sib = (xp = x.parent) == null ? null : xp.right; + } + if (sib == null) + x = xp; + else { + TreeNode sl = sib.left, sr = sib.right; + if ((sr == null || !sr.red) && + (sl == null || !sl.red)) { + sib.red = true; + x = xp; + } + else { + if (sr == null || !sr.red) { + if (sl != null) + sl.red = false; + sib.red = true; + rotateRight(sib); + sib = (xp = x.parent) == null ? null : xp.right; + } + if (sib != null) { + sib.red = (xp == null) ? false : xp.red; + if ((sr = sib.right) != null) + sr.red = false; + } + if (xp != null) { + xp.red = false; + rotateLeft(xp); + } + x = root; + } + } + } + else { // symmetric + TreeNode sib = xpl; + if (sib != null && sib.red) { + sib.red = false; + xp.red = true; + rotateRight(xp); + sib = (xp = x.parent) == null ? null : xp.left; + } + if (sib == null) + x = xp; + else { + TreeNode sl = sib.left, sr = sib.right; + if ((sl == null || !sl.red) && + (sr == null || !sr.red)) { + sib.red = true; + x = xp; + } + else { + if (sl == null || !sl.red) { + if (sr != null) + sr.red = false; + sib.red = true; + rotateLeft(sib); + sib = (xp = x.parent) == null ? null : xp.left; + } + if (sib != null) { + sib.red = (xp == null) ? false : xp.red; + if ((sl = sib.left) != null) + sl.red = false; + } + if (xp != null) { + xp.red = false; + rotateRight(xp); + } + x = root; + } + } + } + } + } + if (p == replacement && (pp = p.parent) != null) { + if (p == pp.left) // detach pointers + pp.left = null; + else if (p == pp.right) + pp.right = null; + p.parent = null; + } + } + } + + /* ---------------- Collision reduction methods -------------- */ + + /** + * Spreads higher bits to lower, and also forces top 2 bits to 0. + * Because the table uses power-of-two masking, sets of hashes + * that vary only in bits above the current mask will always + * collide. (Among known examples are sets of Float keys holding + * consecutive whole numbers in small tables.) To counter this, + * we apply a transform that spreads the impact of higher bits + * downward. There is a tradeoff between speed, utility, and + * quality of bit-spreading. Because many common sets of hashes + * are already reasonably distributed across bits (so don't benefit + * from spreading), and because we use trees to handle large sets + * of collisions in bins, we don't need excessively high quality. + */ + private static final int spread(int h) { + h ^= (h >>> 18) ^ (h >>> 12); + return (h ^ (h >>> 10)) & HASH_BITS; + } + + /** + * Replaces a list bin with a tree bin. Call only when locked. + * Fails to replace if the given key is non-comparable or table + * is, or needs, resizing. + */ + private final void replaceWithTreeBin(Node[] tab, int index, Object key) { + if ((key instanceof Comparable) && + (tab.length >= MAXIMUM_CAPACITY || counter.sum() < (long)sizeCtl)) { + TreeBin t = new TreeBin(); + for (Node e = tabAt(tab, index); e != null; e = e.next) + t.putTreeNode(e.hash & HASH_BITS, e.key, e.val); + setTabAt(tab, index, new Node(MOVED, t, null, null)); + } + } + + /* ---------------- Internal access and update methods -------------- */ + + /** Implementation for get and containsKey */ + private final Object internalGet(Object k) { + int h = spread(k.hashCode()); + retry: for (Node[] tab = table; tab != null;) { + Node e, p; Object ek, ev; int eh; // locals to read fields once + for (e = tabAt(tab, (tab.length - 1) & h); e != null; e = e.next) { + if ((eh = e.hash) == MOVED) { + if ((ek = e.key) instanceof TreeBin) // search TreeBin + return ((TreeBin)ek).getValue(h, k); + else { // restart with new table + tab = (Node[])ek; + continue retry; + } + } + else if ((eh & HASH_BITS) == h && (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) + return ev; + } + break; + } + return null; + } + + /** + * Implementation for the four public remove/replace methods: + * Replaces node value with v, conditional upon match of cv if + * non-null. If resulting value is null, delete. + */ + private final Object internalReplace(Object k, Object v, Object cv) { + int h = spread(k.hashCode()); + Object oldVal = null; + for (Node[] tab = table;;) { + Node f; int i, fh; Object fk; + if (tab == null || + (f = tabAt(tab, i = (tab.length - 1) & h)) == null) + break; + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean validated = false; + boolean deleted = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + validated = true; + TreeNode p = t.getTreeNode(h, k, t.root); + if (p != null) { + Object pv = p.val; + if (cv == null || cv == pv || cv.equals(pv)) { + oldVal = pv; + if ((p.val = v) == null) { + deleted = true; + t.deleteTreeNode(p); + } + } + } + } + } finally { + t.release(0); + } + if (validated) { + if (deleted) + counter.add(-1L); + break; + } + } + else + tab = (Node[])fk; + } + else if ((fh & HASH_BITS) != h && f.next == null) // precheck + break; // rules out possible existence + else if ((fh & LOCKED) != 0) { + checkForResize(); // try resizing if can't get lock + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + boolean validated = false; + boolean deleted = false; + try { + if (tabAt(tab, i) == f) { + validated = true; + for (Node e = f, pred = null;;) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + ((ev = e.val) != null) && + ((ek = e.key) == k || k.equals(ek))) { + if (cv == null || cv == ev || cv.equals(ev)) { + oldVal = ev; + if ((e.val = v) == null) { + deleted = true; + Node en = e.next; + if (pred != null) + pred.next = en; + else + setTabAt(tab, i, en); + } + } + break; + } + pred = e; + if ((e = e.next) == null) + break; + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (validated) { + if (deleted) + counter.add(-1L); + break; + } + } + } + return oldVal; + } + + /* + * Internal versions of the six insertion methods, each a + * little more complicated than the last. All have + * the same basic structure as the first (internalPut): + * 1. If table uninitialized, create + * 2. If bin empty, try to CAS new node + * 3. If bin stale, use new table + * 4. if bin converted to TreeBin, validate and relay to TreeBin methods + * 5. Lock and validate; if valid, scan and add or update + * + * The others interweave other checks and/or alternative actions: + * * Plain put checks for and performs resize after insertion. + * * putIfAbsent prescans for mapping without lock (and fails to add + * if present), which also makes pre-emptive resize checks worthwhile. + * * computeIfAbsent extends form used in putIfAbsent with additional + * mechanics to deal with, calls, potential exceptions and null + * returns from function call. + * * compute uses the same function-call mechanics, but without + * the prescans + * * merge acts as putIfAbsent in the absent case, but invokes the + * update function if present + * * putAll attempts to pre-allocate enough table space + * and more lazily performs count updates and checks. + * + * Someday when details settle down a bit more, it might be worth + * some factoring to reduce sprawl. + */ + + /** Implementation for put */ + private final Object internalPut(Object k, Object v) { + int h = spread(k.hashCode()); + int count = 0; + for (Node[] tab = table;;) { + int i; Node f; int fh; Object fk; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length - 1) & h)) == null) { + if (casTabAt(tab, i, null, new Node(h, k, v, null))) + break; // no lock when adding to empty bin + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + Object oldVal = null; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 2; + TreeNode p = t.putTreeNode(h, k, v); + if (p != null) { + oldVal = p.val; + p.val = v; + } + } + } finally { + t.release(0); + } + if (count != 0) { + if (oldVal != null) + return oldVal; + break; + } + } + else + tab = (Node[])fk; + } + else if ((fh & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + Object oldVal = null; + try { // needed in case equals() throws + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + oldVal = ev; + e.val = v; + break; + } + Node last = e; + if ((e = e.next) == null) { + last.next = new Node(h, k, v, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { // unlock and signal if needed + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (oldVal != null) + return oldVal; + if (tab.length <= 64) + count = 2; + break; + } + } + } + counter.add(1L); + if (count > 1) + checkForResize(); + return null; + } + + /** Implementation for putIfAbsent */ + private final Object internalPutIfAbsent(Object k, Object v) { + int h = spread(k.hashCode()); + int count = 0; + for (Node[] tab = table;;) { + int i; Node f; int fh; Object fk, fv; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length - 1) & h)) == null) { + if (casTabAt(tab, i, null, new Node(h, k, v, null))) + break; + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + Object oldVal = null; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 2; + TreeNode p = t.putTreeNode(h, k, v); + if (p != null) + oldVal = p.val; + } + } finally { + t.release(0); + } + if (count != 0) { + if (oldVal != null) + return oldVal; + break; + } + } + else + tab = (Node[])fk; + } + else if ((fh & HASH_BITS) == h && (fv = f.val) != null && + ((fk = f.key) == k || k.equals(fk))) + return fv; + else { + Node g = f.next; + if (g != null) { // at least 2 nodes -- search and maybe resize + for (Node e = g;;) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) + return ev; + if ((e = e.next) == null) { + checkForResize(); + break; + } + } + } + if (((fh = f.hash) & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (tabAt(tab, i) == f && f.casHash(fh, fh | LOCKED)) { + Object oldVal = null; + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + oldVal = ev; + break; + } + Node last = e; + if ((e = e.next) == null) { + last.next = new Node(h, k, v, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (oldVal != null) + return oldVal; + if (tab.length <= 64) + count = 2; + break; + } + } + } + } + counter.add(1L); + if (count > 1) + checkForResize(); + return null; + } + + /** Implementation for computeIfAbsent */ + private final Object internalComputeIfAbsent(K k, + Fun mf) { + int h = spread(k.hashCode()); + Object val = null; + int count = 0; + for (Node[] tab = table;;) { + Node f; int i, fh; Object fk, fv; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length - 1) & h)) == null) { + Node node = new Node(fh = h | LOCKED, k, null, null); + if (casTabAt(tab, i, null, node)) { + count = 1; + try { + if ((val = mf.apply(k)) != null) + node.val = val; + } finally { + if (val == null) + setTabAt(tab, i, null); + if (!node.casHash(fh, h)) { + node.hash = h; + synchronized (node) { node.notifyAll(); }; + } + } + } + if (count != 0) + break; + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean added = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 1; + TreeNode p = t.getTreeNode(h, k, t.root); + if (p != null) + val = p.val; + else if ((val = mf.apply(k)) != null) { + added = true; + count = 2; + t.putTreeNode(h, k, val); + } + } + } finally { + t.release(0); + } + if (count != 0) { + if (!added) + return val; + break; + } + } + else + tab = (Node[])fk; + } + else if ((fh & HASH_BITS) == h && (fv = f.val) != null && + ((fk = f.key) == k || k.equals(fk))) + return fv; + else { + Node g = f.next; + if (g != null) { + for (Node e = g;;) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) + return ev; + if ((e = e.next) == null) { + checkForResize(); + break; + } + } + } + if (((fh = f.hash) & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (tabAt(tab, i) == f && f.casHash(fh, fh | LOCKED)) { + boolean added = false; + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + val = ev; + break; + } + Node last = e; + if ((e = e.next) == null) { + if ((val = mf.apply(k)) != null) { + added = true; + last.next = new Node(h, k, val, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + } + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (!added) + return val; + if (tab.length <= 64) + count = 2; + break; + } + } + } + } + if (val != null) { + counter.add(1L); + if (count > 1) + checkForResize(); + } + return val; + } + + /** Implementation for compute */ + @SuppressWarnings("unchecked") private final Object internalCompute + (K k, boolean onlyIfPresent, BiFun mf) { + int h = spread(k.hashCode()); + Object val = null; + int delta = 0; + int count = 0; + for (Node[] tab = table;;) { + Node f; int i, fh; Object fk; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length - 1) & h)) == null) { + if (onlyIfPresent) + break; + Node node = new Node(fh = h | LOCKED, k, null, null); + if (casTabAt(tab, i, null, node)) { + try { + count = 1; + if ((val = mf.apply(k, null)) != null) { + node.val = val; + delta = 1; + } + } finally { + if (delta == 0) + setTabAt(tab, i, null); + if (!node.casHash(fh, h)) { + node.hash = h; + synchronized (node) { node.notifyAll(); }; + } + } + } + if (count != 0) + break; + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 1; + TreeNode p = t.getTreeNode(h, k, t.root); + Object pv; + if (p == null) { + if (onlyIfPresent) + break; + pv = null; + } else + pv = p.val; + if ((val = mf.apply(k, (V)pv)) != null) { + if (p != null) + p.val = val; + else { + count = 2; + delta = 1; + t.putTreeNode(h, k, val); + } + } + else if (p != null) { + delta = -1; + t.deleteTreeNode(p); + } + } + } finally { + t.release(0); + } + if (count != 0) + break; + } + else + tab = (Node[])fk; + } + else if ((fh & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f, pred = null;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + val = mf.apply(k, (V)ev); + if (val != null) + e.val = val; + else { + delta = -1; + Node en = e.next; + if (pred != null) + pred.next = en; + else + setTabAt(tab, i, en); + } + break; + } + pred = e; + if ((e = e.next) == null) { + if (!onlyIfPresent && (val = mf.apply(k, null)) != null) { + pred.next = new Node(h, k, val, null); + delta = 1; + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + } + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (tab.length <= 64) + count = 2; + break; + } + } + } + if (delta != 0) { + counter.add((long)delta); + if (count > 1) + checkForResize(); + } + return val; + } + + /** Implementation for merge */ + @SuppressWarnings("unchecked") private final Object internalMerge + (K k, V v, BiFun mf) { + int h = spread(k.hashCode()); + Object val = null; + int delta = 0; + int count = 0; + for (Node[] tab = table;;) { + int i; Node f; int fh; Object fk, fv; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length - 1) & h)) == null) { + if (casTabAt(tab, i, null, new Node(h, k, v, null))) { + delta = 1; + val = v; + break; + } + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 1; + TreeNode p = t.getTreeNode(h, k, t.root); + val = (p == null) ? v : mf.apply((V)p.val, v); + if (val != null) { + if (p != null) + p.val = val; + else { + count = 2; + delta = 1; + t.putTreeNode(h, k, val); + } + } + else if (p != null) { + delta = -1; + t.deleteTreeNode(p); + } + } + } finally { + t.release(0); + } + if (count != 0) + break; + } + else + tab = (Node[])fk; + } + else if ((fh & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f, pred = null;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + val = mf.apply((V)ev, v); + if (val != null) + e.val = val; + else { + delta = -1; + Node en = e.next; + if (pred != null) + pred.next = en; + else + setTabAt(tab, i, en); + } + break; + } + pred = e; + if ((e = e.next) == null) { + val = v; + pred.next = new Node(h, k, val, null); + delta = 1; + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (tab.length <= 64) + count = 2; + break; + } + } + } + if (delta != 0) { + counter.add((long)delta); + if (count > 1) + checkForResize(); + } + return val; + } + + /** Implementation for putAll */ + private final void internalPutAll(Map m) { + tryPresize(m.size()); + long delta = 0L; // number of uncommitted additions + boolean npe = false; // to throw exception on exit for nulls + try { // to clean up counts on other exceptions + for (Map.Entry entry : m.entrySet()) { + Object k, v; + if (entry == null || (k = entry.getKey()) == null || + (v = entry.getValue()) == null) { + npe = true; + break; + } + int h = spread(k.hashCode()); + for (Node[] tab = table;;) { + int i; Node f; int fh; Object fk; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length - 1) & h)) == null){ + if (casTabAt(tab, i, null, new Node(h, k, v, null))) { + ++delta; + break; + } + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean validated = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + validated = true; + TreeNode p = t.getTreeNode(h, k, t.root); + if (p != null) + p.val = v; + else { + t.putTreeNode(h, k, v); + ++delta; + } + } + } finally { + t.release(0); + } + if (validated) + break; + } + else + tab = (Node[])fk; + } + else if ((fh & LOCKED) != 0) { + counter.add(delta); + delta = 0L; + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + int count = 0; + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + e.val = v; + break; + } + Node last = e; + if ((e = e.next) == null) { + ++delta; + last.next = new Node(h, k, v, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (count > 1) { + counter.add(delta); + delta = 0L; + checkForResize(); + } + break; + } + } + } + } + } finally { + if (delta != 0) + counter.add(delta); + } + if (npe) + throw new NullPointerException(); + } + + /* ---------------- Table Initialization and Resizing -------------- */ + + /** + * Returns a power of two table size for the given desired capacity. + * See Hackers Delight, sec 3.2 + */ + private static final int tableSizeFor(int c) { + int n = c - 1; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1; + } + + /** + * Initializes table, using the size recorded in sizeCtl. + */ + private final Node[] initTable() { + Node[] tab; int sc; + while ((tab = table) == null) { + if ((sc = sizeCtl) < 0) + Thread.yield(); // lost initialization race; just spin + else if (UNSAFE.compareAndSwapInt(this, sizeCtlOffset, sc, -1)) { + try { + if ((tab = table) == null) { + int n = (sc > 0) ? sc : DEFAULT_CAPACITY; + tab = table = new Node[n]; + sc = n - (n >>> 2); + } + } finally { + sizeCtl = sc; + } + break; + } + } + return tab; + } + + /** + * If table is too small and not already resizing, creates next + * table and transfers bins. Rechecks occupancy after a transfer + * to see if another resize is already needed because resizings + * are lagging additions. + */ + private final void checkForResize() { + Node[] tab; int n, sc; + while ((tab = table) != null && + (n = tab.length) < MAXIMUM_CAPACITY && + (sc = sizeCtl) >= 0 && counter.sum() >= (long)sc && + UNSAFE.compareAndSwapInt(this, sizeCtlOffset, sc, -1)) { + try { + if (tab == table) { + table = rebuild(tab); + sc = (n << 1) - (n >>> 1); + } + } finally { + sizeCtl = sc; + } + } + } + + /** + * Tries to presize table to accommodate the given number of elements. + * + * @param size number of elements (doesn't need to be perfectly accurate) + */ + private final void tryPresize(int size) { + int c = (size >= (MAXIMUM_CAPACITY >>> 1)) ? MAXIMUM_CAPACITY : + tableSizeFor(size + (size >>> 1) + 1); + int sc; + while ((sc = sizeCtl) >= 0) { + Node[] tab = table; int n; + if (tab == null || (n = tab.length) == 0) { + n = (sc > c) ? sc : c; + if (UNSAFE.compareAndSwapInt(this, sizeCtlOffset, sc, -1)) { + try { + if (table == tab) { + table = new Node[n]; + sc = n - (n >>> 2); + } + } finally { + sizeCtl = sc; + } + } + } + else if (c <= sc || n >= MAXIMUM_CAPACITY) + break; + else if (UNSAFE.compareAndSwapInt(this, sizeCtlOffset, sc, -1)) { + try { + if (table == tab) { + table = rebuild(tab); + sc = (n << 1) - (n >>> 1); + } + } finally { + sizeCtl = sc; + } + } + } + } + + /* + * Moves and/or copies the nodes in each bin to new table. See + * above for explanation. + * + * @return the new table + */ + private static final Node[] rebuild(Node[] tab) { + int n = tab.length; + Node[] nextTab = new Node[n << 1]; + Node fwd = new Node(MOVED, nextTab, null, null); + int[] buffer = null; // holds bins to revisit; null until needed + Node rev = null; // reverse forwarder; null until needed + int nbuffered = 0; // the number of bins in buffer list + int bufferIndex = 0; // buffer index of current buffered bin + int bin = n - 1; // current non-buffered bin or -1 if none + + for (int i = bin;;) { // start upwards sweep + int fh; Node f; + if ((f = tabAt(tab, i)) == null) { + if (bin >= 0) { // Unbuffered; no lock needed (or available) + if (!casTabAt(tab, i, f, fwd)) + continue; + } + else { // transiently use a locked forwarding node + Node g = new Node(MOVED|LOCKED, nextTab, null, null); + if (!casTabAt(tab, i, f, g)) + continue; + setTabAt(nextTab, i, null); + setTabAt(nextTab, i + n, null); + setTabAt(tab, i, fwd); + if (!g.casHash(MOVED|LOCKED, MOVED)) { + g.hash = MOVED; + synchronized (g) { g.notifyAll(); } + } + } + } + else if ((fh = f.hash) == MOVED) { + Object fk = f.key; + if (fk instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean validated = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + validated = true; + splitTreeBin(nextTab, i, t); + setTabAt(tab, i, fwd); + } + } finally { + t.release(0); + } + if (!validated) + continue; + } + } + else if ((fh & LOCKED) == 0 && f.casHash(fh, fh|LOCKED)) { + boolean validated = false; + try { // split to lo and hi lists; copying as needed + if (tabAt(tab, i) == f) { + validated = true; + splitBin(nextTab, i, f); + setTabAt(tab, i, fwd); + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (!validated) + continue; + } + else { + if (buffer == null) // initialize buffer for revisits + buffer = new int[TRANSFER_BUFFER_SIZE]; + if (bin < 0 && bufferIndex > 0) { + int j = buffer[--bufferIndex]; + buffer[bufferIndex] = i; + i = j; // swap with another bin + continue; + } + if (bin < 0 || nbuffered >= TRANSFER_BUFFER_SIZE) { + f.tryAwaitLock(tab, i); + continue; // no other options -- block + } + if (rev == null) // initialize reverse-forwarder + rev = new Node(MOVED, tab, null, null); + if (tabAt(tab, i) != f || (f.hash & LOCKED) == 0) + continue; // recheck before adding to list + buffer[nbuffered++] = i; + setTabAt(nextTab, i, rev); // install place-holders + setTabAt(nextTab, i + n, rev); + } + + if (bin > 0) + i = --bin; + else if (buffer != null && nbuffered > 0) { + bin = -1; + i = buffer[bufferIndex = --nbuffered]; + } + else + return nextTab; + } + } + + /** + * Splits a normal bin with list headed by e into lo and hi parts; + * installs in given table. + */ + private static void splitBin(Node[] nextTab, int i, Node e) { + int bit = nextTab.length >>> 1; // bit to split on + int runBit = e.hash & bit; + Node lastRun = e, lo = null, hi = null; + for (Node p = e.next; p != null; p = p.next) { + int b = p.hash & bit; + if (b != runBit) { + runBit = b; + lastRun = p; + } + } + if (runBit == 0) + lo = lastRun; + else + hi = lastRun; + for (Node p = e; p != lastRun; p = p.next) { + int ph = p.hash & HASH_BITS; + Object pk = p.key, pv = p.val; + if ((ph & bit) == 0) + lo = new Node(ph, pk, pv, lo); + else + hi = new Node(ph, pk, pv, hi); + } + setTabAt(nextTab, i, lo); + setTabAt(nextTab, i + bit, hi); + } + + /** + * Splits a tree bin into lo and hi parts; installs in given table. + */ + private static void splitTreeBin(Node[] nextTab, int i, TreeBin t) { + int bit = nextTab.length >>> 1; + TreeBin lt = new TreeBin(); + TreeBin ht = new TreeBin(); + int lc = 0, hc = 0; + for (Node e = t.first; e != null; e = e.next) { + int h = e.hash & HASH_BITS; + Object k = e.key, v = e.val; + if ((h & bit) == 0) { + ++lc; + lt.putTreeNode(h, k, v); + } + else { + ++hc; + ht.putTreeNode(h, k, v); + } + } + Node ln, hn; // throw away trees if too small + if (lc <= (TREE_THRESHOLD >>> 1)) { + ln = null; + for (Node p = lt.first; p != null; p = p.next) + ln = new Node(p.hash, p.key, p.val, ln); + } + else + ln = new Node(MOVED, lt, null, null); + setTabAt(nextTab, i, ln); + if (hc <= (TREE_THRESHOLD >>> 1)) { + hn = null; + for (Node p = ht.first; p != null; p = p.next) + hn = new Node(p.hash, p.key, p.val, hn); + } + else + hn = new Node(MOVED, ht, null, null); + setTabAt(nextTab, i + bit, hn); + } + + /** + * Implementation for clear. Steps through each bin, removing all + * nodes. + */ + private final void internalClear() { + long delta = 0L; // negative number of deletions + int i = 0; + Node[] tab = table; + while (tab != null && i < tab.length) { + int fh; Object fk; + Node f = tabAt(tab, i); + if (f == null) + ++i; + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + for (Node p = t.first; p != null; p = p.next) { + if (p.val != null) { // (currently always true) + p.val = null; + --delta; + } + } + t.first = null; + t.root = null; + ++i; + } + } finally { + t.release(0); + } + } + else + tab = (Node[])fk; + } + else if ((fh & LOCKED) != 0) { + counter.add(delta); // opportunistically update count + delta = 0L; + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + try { + if (tabAt(tab, i) == f) { + for (Node e = f; e != null; e = e.next) { + if (e.val != null) { // (currently always true) + e.val = null; + --delta; + } + } + setTabAt(tab, i, null); + ++i; + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + } + } + if (delta != 0) + counter.add(delta); + } + + /* ----------------Table Traversal -------------- */ + + /** + * Encapsulates traversal for methods such as containsValue; also + * serves as a base class for other iterators and bulk tasks. + * + * At each step, the iterator snapshots the key ("nextKey") and + * value ("nextVal") of a valid node (i.e., one that, at point of + * snapshot, has a non-null user value). Because val fields can + * change (including to null, indicating deletion), field nextVal + * might not be accurate at point of use, but still maintains the + * weak consistency property of holding a value that was once + * valid. To support iterator.remove, the nextKey field is not + * updated (nulled out) when the iterator cannot advance. + * + * Internal traversals directly access these fields, as in: + * {@code while (it.advance() != null) { process(it.nextKey); }} + * + * Exported iterators must track whether the iterator has advanced + * (in hasNext vs next) (by setting/checking/nulling field + * nextVal), and then extract key, value, or key-value pairs as + * return values of next(). + * + * The iterator visits once each still-valid node that was + * reachable upon iterator construction. It might miss some that + * were added to a bin after the bin was visited, which is OK wrt + * consistency guarantees. Maintaining this property in the face + * of possible ongoing resizes requires a fair amount of + * bookkeeping state that is difficult to optimize away amidst + * volatile accesses. Even so, traversal maintains reasonable + * throughput. + * + * Normally, iteration proceeds bin-by-bin traversing lists. + * However, if the table has been resized, then all future steps + * must traverse both the bin at the current index as well as at + * (index + baseSize); and so on for further resizings. To + * paranoically cope with potential sharing by users of iterators + * across threads, iteration terminates if a bounds checks fails + * for a table read. + * + * This class extends ForkJoinTask to streamline parallel + * iteration in bulk operations (see BulkTask). This adds only an + * int of space overhead, which is close enough to negligible in + * cases where it is not needed to not worry about it. Because + * ForkJoinTask is Serializable, but iterators need not be, we + * need to add warning suppressions. + */ + @SuppressWarnings("serial") static class Traverser { + final ConcurrentHashMapV8 map; + Node next; // the next entry to use + K nextKey; // cached key field of next + V nextVal; // cached val field of next + Node[] tab; // current table; updated if resized + int index; // index of bin to use next + int baseIndex; // current index of initial table + int baseLimit; // index bound for initial table + int baseSize; // initial table size + + /** Creates iterator for all entries in the table. */ + Traverser(ConcurrentHashMapV8 map) { + this.map = map; + } + + /** Creates iterator for split() methods */ + Traverser(Traverser it) { + ConcurrentHashMapV8 m; Node[] t; + if ((m = this.map = it.map) == null) + t = null; + else if ((t = it.tab) == null && // force parent tab initialization + (t = it.tab = m.table) != null) + it.baseLimit = it.baseSize = t.length; + this.tab = t; + this.baseSize = it.baseSize; + it.baseLimit = this.index = this.baseIndex = + ((this.baseLimit = it.baseLimit) + it.baseIndex + 1) >>> 1; + } + + /** + * Advances next; returns nextVal or null if terminated. + * See above for explanation. + */ + final V advance() { + Node e = next; + V ev = null; + outer: do { + if (e != null) // advance past used/skipped node + e = e.next; + while (e == null) { // get to next non-null bin + ConcurrentHashMapV8 m; + Node[] t; int b, i, n; Object ek; // checks must use locals + if ((t = tab) != null) + n = t.length; + else if ((m = map) != null && (t = tab = m.table) != null) + n = baseLimit = baseSize = t.length; + else + break outer; + if ((b = baseIndex) >= baseLimit || + (i = index) < 0 || i >= n) + break outer; + if ((e = tabAt(t, i)) != null && e.hash == MOVED) { + if ((ek = e.key) instanceof TreeBin) + e = ((TreeBin)ek).first; + else { + tab = (Node[])ek; + continue; // restarts due to null val + } + } // visit upper slots if present + index = (i += baseSize) < n ? i : (baseIndex = b + 1); + } + nextKey = (K) e.key; + } while ((ev = (V) e.val) == null); // skip deleted or special nodes + next = e; + return nextVal = ev; + } + + public final void remove() { + Object k = nextKey; + if (k == null && (advance() == null || (k = nextKey) == null)) + throw new IllegalStateException(); + map.internalReplace(k, null, null); + } + + public final boolean hasNext() { + return nextVal != null || advance() != null; + } + + public final boolean hasMoreElements() { return hasNext(); } + public final void setRawResult(Object x) { } + public R getRawResult() { return null; } + public boolean exec() { return true; } + } + + /* ---------------- Public operations -------------- */ + + /** + * Creates a new, empty map with the default initial table size (16). + */ + public ConcurrentHashMapV8() { + this.counter = new LongAdder(); + } + + /** + * Creates a new, empty map with an initial table size + * accommodating the specified number of elements without the need + * to dynamically resize. + * + * @param initialCapacity The implementation performs internal + * sizing to accommodate this many elements. + * @throws IllegalArgumentException if the initial capacity of + * elements is negative + */ + public ConcurrentHashMapV8(int initialCapacity) { + if (initialCapacity < 0) + throw new IllegalArgumentException(); + int cap = ((initialCapacity >= (MAXIMUM_CAPACITY >>> 1)) ? + MAXIMUM_CAPACITY : + tableSizeFor(initialCapacity + (initialCapacity >>> 1) + 1)); + this.counter = new LongAdder(); + this.sizeCtl = cap; + } + + /** + * Creates a new map with the same mappings as the given map. + * + * @param m the map + */ + public ConcurrentHashMapV8(Map m) { + this.counter = new LongAdder(); + this.sizeCtl = DEFAULT_CAPACITY; + internalPutAll(m); + } + + /** + * Creates a new, empty map with an initial table size based on + * the given number of elements ({@code initialCapacity}) and + * initial table density ({@code loadFactor}). + * + * @param initialCapacity the initial capacity. The implementation + * performs internal sizing to accommodate this many elements, + * given the specified load factor. + * @param loadFactor the load factor (table density) for + * establishing the initial table size + * @throws IllegalArgumentException if the initial capacity of + * elements is negative or the load factor is nonpositive + * + * @since 1.6 + */ + public ConcurrentHashMapV8(int initialCapacity, float loadFactor) { + this(initialCapacity, loadFactor, 1); + } + + /** + * Creates a new, empty map with an initial table size based on + * the given number of elements ({@code initialCapacity}), table + * density ({@code loadFactor}), and number of concurrently + * updating threads ({@code concurrencyLevel}). + * + * @param initialCapacity the initial capacity. The implementation + * performs internal sizing to accommodate this many elements, + * given the specified load factor. + * @param loadFactor the load factor (table density) for + * establishing the initial table size + * @param concurrencyLevel the estimated number of concurrently + * updating threads. The implementation may use this value as + * a sizing hint. + * @throws IllegalArgumentException if the initial capacity is + * negative or the load factor or concurrencyLevel are + * nonpositive + */ + public ConcurrentHashMapV8(int initialCapacity, + float loadFactor, int concurrencyLevel) { + if (!(loadFactor > 0.0f) || initialCapacity < 0 || concurrencyLevel <= 0) + throw new IllegalArgumentException(); + if (initialCapacity < concurrencyLevel) // Use at least as many bins + initialCapacity = concurrencyLevel; // as estimated threads + long size = (long)(1.0 + (long)initialCapacity / loadFactor); + int cap = (size >= (long)MAXIMUM_CAPACITY) ? + MAXIMUM_CAPACITY : tableSizeFor((int)size); + this.counter = new LongAdder(); + this.sizeCtl = cap; + } + + /** + * Creates a new {@link Set} backed by a ConcurrentHashMapV8 + * from the given type to {@code Boolean.TRUE}. + * + * @return the new set + */ + public static KeySetView newKeySet() { + return new KeySetView(new ConcurrentHashMapV8(), + Boolean.TRUE); + } + + /** + * Creates a new {@link Set} backed by a ConcurrentHashMapV8 + * from the given type to {@code Boolean.TRUE}. + * + * @param initialCapacity The implementation performs internal + * sizing to accommodate this many elements. + * @throws IllegalArgumentException if the initial capacity of + * elements is negative + * @return the new set + */ + public static KeySetView newKeySet(int initialCapacity) { + return new KeySetView(new ConcurrentHashMapV8(initialCapacity), + Boolean.TRUE); + } + + /** + * {@inheritDoc} + */ + public boolean isEmpty() { + return counter.sum() <= 0L; // ignore transient negative values + } + + /** + * {@inheritDoc} + */ + public int size() { + long n = counter.sum(); + return ((n < 0L) ? 0 : + (n > (long)Integer.MAX_VALUE) ? Integer.MAX_VALUE : + (int)n); + } + + /** + * Returns the number of mappings. This method should be used + * instead of {@link #size} because a ConcurrentHashMapV8 may + * contain more mappings than can be represented as an int. The + * value returned is a snapshot; the actual count may differ if + * there are ongoing concurrent insertions or removals. + * + * @return the number of mappings + */ + public long mappingCount() { + long n = counter.sum(); + return (n < 0L) ? 0L : n; // ignore transient negative values + } + + /** + * Returns the value to which the specified key is mapped, + * or {@code null} if this map contains no mapping for the key. + * + *

More formally, if this map contains a mapping from a key + * {@code k} to a value {@code v} such that {@code key.equals(k)}, + * then this method returns {@code v}; otherwise it returns + * {@code null}. (There can be at most one such mapping.) + * + * @throws NullPointerException if the specified key is null + */ + @SuppressWarnings("unchecked") public V get(Object key) { + if (key == null) + throw new NullPointerException(); + return (V)internalGet(key); + } + + /** + * Returns the value to which the specified key is mapped, + * or the given defaultValue if this map contains no mapping for the key. + * + * @param key the key + * @param defaultValue the value to return if this map contains + * no mapping for the given key + * @return the mapping for the key, if present; else the defaultValue + * @throws NullPointerException if the specified key is null + */ + @SuppressWarnings("unchecked") public V getValueOrDefault(Object key, V defaultValue) { + if (key == null) + throw new NullPointerException(); + V v = (V) internalGet(key); + return v == null ? defaultValue : v; + } + + /** + * Tests if the specified object is a key in this table. + * + * @param key possible key + * @return {@code true} if and only if the specified object + * is a key in this table, as determined by the + * {@code equals} method; {@code false} otherwise + * @throws NullPointerException if the specified key is null + */ + public boolean containsKey(Object key) { + if (key == null) + throw new NullPointerException(); + return internalGet(key) != null; + } + + /** + * Returns {@code true} if this map maps one or more keys to the + * specified value. Note: This method may require a full traversal + * of the map, and is much slower than method {@code containsKey}. + * + * @param value value whose presence in this map is to be tested + * @return {@code true} if this map maps one or more keys to the + * specified value + * @throws NullPointerException if the specified value is null + */ + public boolean containsValue(Object value) { + if (value == null) + throw new NullPointerException(); + Object v; + Traverser it = new Traverser(this); + while ((v = it.advance()) != null) { + if (v == value || value.equals(v)) + return true; + } + return false; + } + + public K findKey(Object value) { + if (value == null) + throw new NullPointerException(); + Object v; + Traverser it = new Traverser(this); + while ((v = it.advance()) != null) { + if (v == value || value.equals(v)) + return it.nextKey; + } + return null; + } + + /** + * Legacy method testing if some key maps into the specified value + * in this table. This method is identical in functionality to + * {@link #containsValue}, and exists solely to ensure + * full compatibility with class {@link java.util.Hashtable}, + * which supported this method prior to introduction of the + * Java Collections framework. + * + * @param value a value to search for + * @return {@code true} if and only if some key maps to the + * {@code value} argument in this table as + * determined by the {@code equals} method; + * {@code false} otherwise + * @throws NullPointerException if the specified value is null + */ + public boolean contains(Object value) { + return containsValue(value); + } + + /** + * Maps the specified key to the specified value in this table. + * Neither the key nor the value can be null. + * + *

The value can be retrieved by calling the {@code get} method + * with a key that is equal to the original key. + * + * @param key key with which the specified value is to be associated + * @param value value to be associated with the specified key + * @return the previous value associated with {@code key}, or + * {@code null} if there was no mapping for {@code key} + * @throws NullPointerException if the specified key or value is null + */ + @SuppressWarnings("unchecked") public V put(K key, V value) { + if (key == null || value == null) + throw new NullPointerException(); + return (V)internalPut(key, value); + } + + /** + * {@inheritDoc} + * + * @return the previous value associated with the specified key, + * or {@code null} if there was no mapping for the key + * @throws NullPointerException if the specified key or value is null + */ + @SuppressWarnings("unchecked") public V putIfAbsent(K key, V value) { + if (key == null || value == null) + throw new NullPointerException(); + return (V)internalPutIfAbsent(key, value); + } + + /** + * Copies all of the mappings from the specified map to this one. + * These mappings replace any mappings that this map had for any of the + * keys currently in the specified map. + * + * @param m mappings to be stored in this map + */ + public void putAll(Map m) { + internalPutAll(m); + } + + /** + * If the specified key is not already associated with a value, + * computes its value using the given mappingFunction and enters + * it into the map unless null. This is equivalent to + *

 {@code
+     * if (map.containsKey(key))
+     *   return map.get(key);
+     * value = mappingFunction.apply(key);
+     * if (value != null)
+     *   map.put(key, value);
+     * return value;}
+ * + * except that the action is performed atomically. If the + * function returns {@code null} no mapping is recorded. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and no mapping is recorded. Some + * attempted update operations on this map by other threads may be + * blocked while computation is in progress, so the computation + * should be short and simple, and must not attempt to update any + * other mappings of this Map. The most appropriate usage is to + * construct a new object serving as an initial mapped value, or + * memoized result, as in: + * + *
 {@code
+     * map.computeIfAbsent(key, new Fun() {
+     *   public V map(K k) { return new Value(f(k)); }});}
+ * + * @param key key with which the specified value is to be associated + * @param mappingFunction the function to compute a value + * @return the current (existing or computed) value associated with + * the specified key, or null if the computed value is null + * @throws NullPointerException if the specified key or mappingFunction + * is null + * @throws IllegalStateException if the computation detectably + * attempts a recursive update to this map that would + * otherwise never complete + * @throws RuntimeException or Error if the mappingFunction does so, + * in which case the mapping is left unestablished + */ + @SuppressWarnings("unchecked") public V computeIfAbsent + (K key, Fun mappingFunction) { + if (key == null || mappingFunction == null) + throw new NullPointerException(); + return (V)internalComputeIfAbsent(key, mappingFunction); + } + + /** + * If the given key is present, computes a new mapping value given a key and + * its current mapped value. This is equivalent to + *
 {@code
+     *   if (map.containsKey(key)) {
+     *     value = remappingFunction.apply(key, map.get(key));
+     *     if (value != null)
+     *       map.put(key, value);
+     *     else
+     *       map.remove(key);
+     *   }
+     * }
+ * + * except that the action is performed atomically. If the + * function returns {@code null}, the mapping is removed. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and the current mapping is left + * unchanged. Some attempted update operations on this map by + * other threads may be blocked while computation is in progress, + * so the computation should be short and simple, and must not + * attempt to update any other mappings of this Map. For example, + * to either create or append new messages to a value mapping: + * + * @param key key with which the specified value is to be associated + * @param remappingFunction the function to compute a value + * @return the new value associated with the specified key, or null if none + * @throws NullPointerException if the specified key or remappingFunction + * is null + * @throws IllegalStateException if the computation detectably + * attempts a recursive update to this map that would + * otherwise never complete + * @throws RuntimeException or Error if the remappingFunction does so, + * in which case the mapping is unchanged + */ + @SuppressWarnings("unchecked") public V computeIfPresent + (K key, BiFun remappingFunction) { + if (key == null || remappingFunction == null) + throw new NullPointerException(); + return (V)internalCompute(key, true, remappingFunction); + } + + /** + * Computes a new mapping value given a key and + * its current mapped value (or {@code null} if there is no current + * mapping). This is equivalent to + *
 {@code
+     *   value = remappingFunction.apply(key, map.get(key));
+     *   if (value != null)
+     *     map.put(key, value);
+     *   else
+     *     map.remove(key);
+     * }
+ * + * except that the action is performed atomically. If the + * function returns {@code null}, the mapping is removed. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and the current mapping is left + * unchanged. Some attempted update operations on this map by + * other threads may be blocked while computation is in progress, + * so the computation should be short and simple, and must not + * attempt to update any other mappings of this Map. For example, + * to either create or append new messages to a value mapping: + * + *
 {@code
+     * Map map = ...;
+     * final String msg = ...;
+     * map.compute(key, new BiFun() {
+     *   public String apply(Key k, String v) {
+     *    return (v == null) ? msg : v + msg;});}}
+ * + * @param key key with which the specified value is to be associated + * @param remappingFunction the function to compute a value + * @return the new value associated with the specified key, or null if none + * @throws NullPointerException if the specified key or remappingFunction + * is null + * @throws IllegalStateException if the computation detectably + * attempts a recursive update to this map that would + * otherwise never complete + * @throws RuntimeException or Error if the remappingFunction does so, + * in which case the mapping is unchanged + */ + @SuppressWarnings("unchecked") public V compute + (K key, BiFun remappingFunction) { + if (key == null || remappingFunction == null) + throw new NullPointerException(); + return (V)internalCompute(key, false, remappingFunction); + } + + /** + * If the specified key is not already associated + * with a value, associate it with the given value. + * Otherwise, replace the value with the results of + * the given remapping function. This is equivalent to: + *
 {@code
+     *   if (!map.containsKey(key))
+     *     map.put(value);
+     *   else {
+     *     newValue = remappingFunction.apply(map.get(key), value);
+     *     if (value != null)
+     *       map.put(key, value);
+     *     else
+     *       map.remove(key);
+     *   }
+     * }
+ * except that the action is performed atomically. If the + * function returns {@code null}, the mapping is removed. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and the current mapping is left + * unchanged. Some attempted update operations on this map by + * other threads may be blocked while computation is in progress, + * so the computation should be short and simple, and must not + * attempt to update any other mappings of this Map. + */ + @SuppressWarnings("unchecked") public V merge + (K key, V value, BiFun remappingFunction) { + if (key == null || value == null || remappingFunction == null) + throw new NullPointerException(); + return (V)internalMerge(key, value, remappingFunction); + } + + /** + * Removes the key (and its corresponding value) from this map. + * This method does nothing if the key is not in the map. + * + * @param key the key that needs to be removed + * @return the previous value associated with {@code key}, or + * {@code null} if there was no mapping for {@code key} + * @throws NullPointerException if the specified key is null + */ + @SuppressWarnings("unchecked") public V remove(Object key) { + if (key == null) + throw new NullPointerException(); + return (V)internalReplace(key, null, null); + } + + /** + * {@inheritDoc} + * + * @throws NullPointerException if the specified key is null + */ + public boolean remove(Object key, Object value) { + if (key == null) + throw new NullPointerException(); + if (value == null) + return false; + return internalReplace(key, null, value) != null; + } + + /** + * {@inheritDoc} + * + * @throws NullPointerException if any of the arguments are null + */ + public boolean replace(K key, V oldValue, V newValue) { + if (key == null || oldValue == null || newValue == null) + throw new NullPointerException(); + return internalReplace(key, newValue, oldValue) != null; + } + + /** + * {@inheritDoc} + * + * @return the previous value associated with the specified key, + * or {@code null} if there was no mapping for the key + * @throws NullPointerException if the specified key or value is null + */ + @SuppressWarnings("unchecked") public V replace(K key, V value) { + if (key == null || value == null) + throw new NullPointerException(); + return (V)internalReplace(key, value, null); + } + + /** + * Removes all of the mappings from this map. + */ + public void clear() { + internalClear(); + } + + /** + * Returns a {@link Set} view of the keys contained in this map. + * The set is backed by the map, so changes to the map are + * reflected in the set, and vice-versa. + * + * @return the set view + */ + public KeySetView keySet() { + KeySetView ks = keySet; + return (ks != null) ? ks : (keySet = new KeySetView(this, null)); + } + + /** + * Returns a {@link Set} view of the keys in this map, using the + * given common mapped value for any additions (i.e., {@link + * Collection#add} and {@link Collection#addAll}). This is of + * course only appropriate if it is acceptable to use the same + * value for all additions from this view. + * + * @param mappedValue the mapped value to use for any + * additions. + * @return the set view + * @throws NullPointerException if the mappedValue is null + */ + public KeySetView keySet(V mappedValue) { + if (mappedValue == null) + throw new NullPointerException(); + return new KeySetView(this, mappedValue); + } + + /** + * Returns a {@link Collection} view of the values contained in this map. + * The collection is backed by the map, so changes to the map are + * reflected in the collection, and vice-versa. + */ + public ValuesView values() { + ValuesView vs = values; + return (vs != null) ? vs : (values = new ValuesView(this)); + } + + /** + * Returns a {@link Set} view of the mappings contained in this map. + * The set is backed by the map, so changes to the map are + * reflected in the set, and vice-versa. The set supports element + * removal, which removes the corresponding mapping from the map, + * via the {@code Iterator.remove}, {@code Set.remove}, + * {@code removeAll}, {@code retainAll}, and {@code clear} + * operations. It does not support the {@code add} or + * {@code addAll} operations. + * + *

The view's {@code iterator} is a "weakly consistent" iterator + * that will never throw {@link ConcurrentModificationException}, + * and guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not guaranteed to) + * reflect any modifications subsequent to construction. + */ + public Set> entrySet() { + EntrySetView es = entrySet; + return (es != null) ? es : (entrySet = new EntrySetView(this)); + } + + /** + * Returns an enumeration of the keys in this table. + * + * @return an enumeration of the keys in this table + * @see #keySet() + */ + public Enumeration keys() { + return new KeyIterator(this); + } + + /** + * Returns an enumeration of the values in this table. + * + * @return an enumeration of the values in this table + * @see #values() + */ + public Enumeration elements() { + return new ValueIterator(this); + } + + /** + * Returns a partitionable iterator of the keys in this map. + * + * @return a partitionable iterator of the keys in this map + */ + public Spliterator keySpliterator() { + return new KeyIterator(this); + } + + /** + * Returns a partitionable iterator of the values in this map. + * + * @return a partitionable iterator of the values in this map + */ + public Spliterator valueSpliterator() { + return new ValueIterator(this); + } + + /** + * Returns a partitionable iterator of the entries in this map. + * + * @return a partitionable iterator of the entries in this map + */ + public Spliterator> entrySpliterator() { + return new EntryIterator(this); + } + + /** + * Returns the hash code value for this {@link Map}, i.e., + * the sum of, for each key-value pair in the map, + * {@code key.hashCode() ^ value.hashCode()}. + * + * @return the hash code value for this map + */ + public int hashCode() { + int h = 0; + Traverser it = new Traverser(this); + Object v; + while ((v = it.advance()) != null) { + h += it.nextKey.hashCode() ^ v.hashCode(); + } + return h; + } + + /** + * Returns a string representation of this map. The string + * representation consists of a list of key-value mappings (in no + * particular order) enclosed in braces ("{@code {}}"). Adjacent + * mappings are separated by the characters {@code ", "} (comma + * and space). Each key-value mapping is rendered as the key + * followed by an equals sign ("{@code =}") followed by the + * associated value. + * + * @return a string representation of this map + */ + public String toString() { + Traverser it = new Traverser(this); + StringBuilder sb = new StringBuilder(); + sb.append('{'); + Object v; + if ((v = it.advance()) != null) { + for (;;) { + Object k = it.nextKey; + sb.append(k == this ? "(this Map)" : k); + sb.append('='); + sb.append(v == this ? "(this Map)" : v); + if ((v = it.advance()) == null) + break; + sb.append(',').append(' '); + } + } + return sb.append('}').toString(); + } + + /** + * Compares the specified object with this map for equality. + * Returns {@code true} if the given object is a map with the same + * mappings as this map. This operation may return misleading + * results if either map is concurrently modified during execution + * of this method. + * + * @param o object to be compared for equality with this map + * @return {@code true} if the specified object is equal to this map + */ + public boolean equals(Object o) { + if (o != this) { + if (!(o instanceof Map)) + return false; + Map m = (Map) o; + Traverser it = new Traverser(this); + Object val; + while ((val = it.advance()) != null) { + Object v = m.get(it.nextKey); + if (v == null || (v != val && !v.equals(val))) + return false; + } + for (Map.Entry e : m.entrySet()) { + Object mk, mv, v; + if ((mk = e.getKey()) == null || + (mv = e.getValue()) == null || + (v = internalGet(mk)) == null || + (mv != v && !mv.equals(v))) + return false; + } + } + return true; + } + + /* ----------------Iterators -------------- */ + + @SuppressWarnings("serial") static final class KeyIterator extends Traverser + implements Spliterator, Enumeration { + KeyIterator(ConcurrentHashMapV8 map) { super(map); } + KeyIterator(Traverser it) { + super(it); + } + public KeyIterator split() { + if (nextKey != null) + throw new IllegalStateException(); + return new KeyIterator(this); + } + @SuppressWarnings("unchecked") public final K next() { + if (nextVal == null && advance() == null) + throw new NoSuchElementException(); + Object k = nextKey; + nextVal = null; + return (K) k; + } + + public final K nextElement() { return next(); } + } + + @SuppressWarnings("serial") static final class ValueIterator extends Traverser + implements Spliterator, Enumeration { + ValueIterator(ConcurrentHashMapV8 map) { super(map); } + ValueIterator(Traverser it) { + super(it); + } + public ValueIterator split() { + if (nextKey != null) + throw new IllegalStateException(); + return new ValueIterator(this); + } + + @SuppressWarnings("unchecked") public final V next() { + Object v; + if ((v = nextVal) == null && (v = advance()) == null) + throw new NoSuchElementException(); + nextVal = null; + return (V) v; + } + + public final V nextElement() { return next(); } + } + + @SuppressWarnings("serial") static final class EntryIterator extends Traverser + implements Spliterator> { + EntryIterator(ConcurrentHashMapV8 map) { super(map); } + EntryIterator(Traverser it) { + super(it); + } + public EntryIterator split() { + if (nextKey != null) + throw new IllegalStateException(); + return new EntryIterator(this); + } + + @SuppressWarnings("unchecked") public final Map.Entry next() { + Object v; + if ((v = nextVal) == null && (v = advance()) == null) + throw new NoSuchElementException(); + Object k = nextKey; + nextVal = null; + return new MapEntry((K)k, (V)v, map); + } + } + + /** + * Exported Entry for iterators + */ + static final class MapEntry implements Map.Entry { + final K key; // non-null + V val; // non-null + final ConcurrentHashMapV8 map; + MapEntry(K key, V val, ConcurrentHashMapV8 map) { + this.key = key; + this.val = val; + this.map = map; + } + public final K getKey() { return key; } + public final V getValue() { return val; } + public final int hashCode() { return key.hashCode() ^ val.hashCode(); } + public final String toString(){ return key + "=" + val; } + + public final boolean equals(Object o) { + Object k, v; Map.Entry e; + return ((o instanceof Map.Entry) && + (k = (e = (Map.Entry)o).getKey()) != null && + (v = e.getValue()) != null && + (k == key || k.equals(key)) && + (v == val || v.equals(val))); + } + + /** + * Sets our entry's value and writes through to the map. The + * value to return is somewhat arbitrary here. Since we do not + * necessarily track asynchronous changes, the most recent + * "previous" value could be different from what we return (or + * could even have been removed in which case the put will + * re-establish). We do not and cannot guarantee more. + */ + public final V setValue(V value) { + if (value == null) throw new NullPointerException(); + V v = val; + val = value; + map.put(key, value); + return v; + } + } + + /* ---------------- Serialization Support -------------- */ + + /** + * Stripped-down version of helper class used in previous version, + * declared for the sake of serialization compatibility + */ + static class Segment implements Serializable { + private static final long serialVersionUID = 2249069246763182397L; + final float loadFactor; + Segment(float lf) { this.loadFactor = lf; } + } + + /** + * Saves the state of the {@code ConcurrentHashMapV8} instance to a + * stream (i.e., serializes it). + * @param s the stream + * @serialData + * the key (Object) and value (Object) + * for each key-value mapping, followed by a null pair. + * The key-value mappings are emitted in no particular order. + */ + @SuppressWarnings("unchecked") private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + if (segments == null) { // for serialization compatibility + segments = (Segment[]) + new Segment[DEFAULT_CONCURRENCY_LEVEL]; + for (int i = 0; i < segments.length; ++i) + segments[i] = new Segment(LOAD_FACTOR); + } + s.defaultWriteObject(); + Traverser it = new Traverser(this); + Object v; + while ((v = it.advance()) != null) { + s.writeObject(it.nextKey); + s.writeObject(v); + } + s.writeObject(null); + s.writeObject(null); + segments = null; // throw away + } + + /** + * Reconstitutes the instance from a stream (that is, deserializes it). + * @param s the stream + */ + @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + s.defaultReadObject(); + this.segments = null; // unneeded + // initialize transient final field + UNSAFE.putObjectVolatile(this, counterOffset, new LongAdder()); + + // Create all nodes, then place in table once size is known + long size = 0L; + Node p = null; + for (;;) { + K k = (K) s.readObject(); + V v = (V) s.readObject(); + if (k != null && v != null) { + int h = spread(k.hashCode()); + p = new Node(h, k, v, p); + ++size; + } + else + break; + } + if (p != null) { + boolean init = false; + int n; + if (size >= (long)(MAXIMUM_CAPACITY >>> 1)) + n = MAXIMUM_CAPACITY; + else { + int sz = (int)size; + n = tableSizeFor(sz + (sz >>> 1) + 1); + } + int sc = sizeCtl; + boolean collide = false; + if (n > sc && + UNSAFE.compareAndSwapInt(this, sizeCtlOffset, sc, -1)) { + try { + if (table == null) { + init = true; + Node[] tab = new Node[n]; + int mask = n - 1; + while (p != null) { + int j = p.hash & mask; + Node next = p.next; + Node q = p.next = tabAt(tab, j); + setTabAt(tab, j, p); + if (!collide && q != null && q.hash == p.hash) + collide = true; + p = next; + } + table = tab; + counter.add(size); + sc = n - (n >>> 2); + } + } finally { + sizeCtl = sc; + } + if (collide) { // rescan and convert to TreeBins + Node[] tab = table; + for (int i = 0; i < tab.length; ++i) { + int c = 0; + for (Node e = tabAt(tab, i); e != null; e = e.next) { + if (++c > TREE_THRESHOLD && + (e.key instanceof Comparable)) { + replaceWithTreeBin(tab, i, e.key); + break; + } + } + } + } + } + if (!init) { // Can only happen if unsafely published. + while (p != null) { + internalPut(p.key, p.val); + p = p.next; + } + } + } + } + + + // ------------------------------------------------------- + + // Sams + /** Interface describing a void action of one argument */ + public interface Action { void apply(A a); } + /** Interface describing a void action of two arguments */ + public interface BiAction { void apply(A a, B b); } + /** Interface describing a function of one argument */ + public interface Generator { T apply(); } + /** Interface describing a function mapping its argument to a double */ + public interface ObjectToDouble { double apply(A a); } + /** Interface describing a function mapping its argument to a long */ + public interface ObjectToLong { long apply(A a); } + /** Interface describing a function mapping its argument to an int */ + public interface ObjectToInt {int apply(A a); } + /** Interface describing a function mapping two arguments to a double */ + public interface ObjectByObjectToDouble { double apply(A a, B b); } + /** Interface describing a function mapping two arguments to a long */ + public interface ObjectByObjectToLong { long apply(A a, B b); } + /** Interface describing a function mapping two arguments to an int */ + public interface ObjectByObjectToInt {int apply(A a, B b); } + /** Interface describing a function mapping a double to a double */ + public interface DoubleToDouble { double apply(double a); } + /** Interface describing a function mapping a long to a long */ + public interface LongToLong { long apply(long a); } + /** Interface describing a function mapping an int to an int */ + public interface IntToInt { int apply(int a); } + /** Interface describing a function mapping two doubles to a double */ + public interface DoubleByDoubleToDouble { double apply(double a, double b); } + /** Interface describing a function mapping two longs to a long */ + public interface LongByLongToLong { long apply(long a, long b); } + /** Interface describing a function mapping two ints to an int */ + public interface IntByIntToInt { int apply(int a, int b); } + + + /* ----------------Views -------------- */ + + /** + * Base class for views. + */ + static abstract class CHMView { + final ConcurrentHashMapV8 map; + CHMView(ConcurrentHashMapV8 map) { this.map = map; } + + /** + * Returns the map backing this view. + * + * @return the map backing this view + */ + public ConcurrentHashMapV8 getMap() { return map; } + + public final int size() { return map.size(); } + public final boolean isEmpty() { return map.isEmpty(); } + public final void clear() { map.clear(); } + + // implementations below rely on concrete classes supplying these + abstract public Iterator iterator(); + abstract public boolean contains(Object o); + abstract public boolean remove(Object o); + + private static final String oomeMsg = "Required array size too large"; + + public final Object[] toArray() { + long sz = map.mappingCount(); + if (sz > (long)(MAX_ARRAY_SIZE)) + throw new OutOfMemoryError(oomeMsg); + int n = (int)sz; + Object[] r = new Object[n]; + int i = 0; + Iterator it = iterator(); + while (it.hasNext()) { + if (i == n) { + if (n >= MAX_ARRAY_SIZE) + throw new OutOfMemoryError(oomeMsg); + if (n >= MAX_ARRAY_SIZE - (MAX_ARRAY_SIZE >>> 1) - 1) + n = MAX_ARRAY_SIZE; + else + n += (n >>> 1) + 1; + r = Arrays.copyOf(r, n); + } + r[i++] = it.next(); + } + return (i == n) ? r : Arrays.copyOf(r, i); + } + + @SuppressWarnings("unchecked") public final T[] toArray(T[] a) { + long sz = map.mappingCount(); + if (sz > (long)(MAX_ARRAY_SIZE)) + throw new OutOfMemoryError(oomeMsg); + int m = (int)sz; + T[] r = (a.length >= m) ? a : + (T[])java.lang.reflect.Array + .newInstance(a.getClass().getComponentType(), m); + int n = r.length; + int i = 0; + Iterator it = iterator(); + while (it.hasNext()) { + if (i == n) { + if (n >= MAX_ARRAY_SIZE) + throw new OutOfMemoryError(oomeMsg); + if (n >= MAX_ARRAY_SIZE - (MAX_ARRAY_SIZE >>> 1) - 1) + n = MAX_ARRAY_SIZE; + else + n += (n >>> 1) + 1; + r = Arrays.copyOf(r, n); + } + r[i++] = (T)it.next(); + } + if (a == r && i < n) { + r[i] = null; // null-terminate + return r; + } + return (i == n) ? r : Arrays.copyOf(r, i); + } + + public final int hashCode() { + int h = 0; + for (Iterator it = iterator(); it.hasNext();) + h += it.next().hashCode(); + return h; + } + + public final String toString() { + StringBuilder sb = new StringBuilder(); + sb.append('['); + Iterator it = iterator(); + if (it.hasNext()) { + for (;;) { + Object e = it.next(); + sb.append(e == this ? "(this Collection)" : e); + if (!it.hasNext()) + break; + sb.append(',').append(' '); + } + } + return sb.append(']').toString(); + } + + public final boolean containsAll(Collection c) { + if (c != this) { + for (Iterator it = c.iterator(); it.hasNext();) { + Object e = it.next(); + if (e == null || !contains(e)) + return false; + } + } + return true; + } + + public final boolean removeAll(Collection c) { + boolean modified = false; + for (Iterator it = iterator(); it.hasNext();) { + if (c.contains(it.next())) { + it.remove(); + modified = true; + } + } + return modified; + } + + public final boolean retainAll(Collection c) { + boolean modified = false; + for (Iterator it = iterator(); it.hasNext();) { + if (!c.contains(it.next())) { + it.remove(); + modified = true; + } + } + return modified; + } + + } + + /** + * A view of a ConcurrentHashMapV8 as a {@link Set} of keys, in + * which additions may optionally be enabled by mapping to a + * common value. This class cannot be directly instantiated. See + * {@link #keySet}, {@link #keySet(Object)}, {@link #newKeySet()}, + * {@link #newKeySet(int)}. + */ + public static class KeySetView extends CHMView implements Set, java.io.Serializable { + private static final long serialVersionUID = 7249069246763182397L; + private final V value; + KeySetView(ConcurrentHashMapV8 map, V value) { // non-public + super(map); + this.value = value; + } + + /** + * Returns the default mapped value for additions, + * or {@code null} if additions are not supported. + * + * @return the default mapped value for additions, or {@code null} + * if not supported. + */ + public V getMappedValue() { return value; } + + // implement Set API + + public boolean contains(Object o) { return map.containsKey(o); } + public boolean remove(Object o) { return map.remove(o) != null; } + + /** + * Returns a "weakly consistent" iterator that will never + * throw {@link ConcurrentModificationException}, and + * guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not + * guaranteed to) reflect any modifications subsequent to + * construction. + * + * @return an iterator over the keys of this map + */ + public Iterator iterator() { return new KeyIterator(map); } + public boolean add(K e) { + V v; + if ((v = value) == null) + throw new UnsupportedOperationException(); + if (e == null) + throw new NullPointerException(); + return map.internalPutIfAbsent(e, v) == null; + } + public boolean addAll(Collection c) { + boolean added = false; + V v; + if ((v = value) == null) + throw new UnsupportedOperationException(); + for (K e : c) { + if (e == null) + throw new NullPointerException(); + if (map.internalPutIfAbsent(e, v) == null) + added = true; + } + return added; + } + public boolean equals(Object o) { + Set c; + return ((o instanceof Set) && + ((c = (Set)o) == this || + (containsAll(c) && c.containsAll(this)))); + } + } + + /** + * A view of a ConcurrentHashMapV8 as a {@link Collection} of + * values, in which additions are disabled. This class cannot be + * directly instantiated. See {@link #values}, + * + *

The view's {@code iterator} is a "weakly consistent" iterator + * that will never throw {@link ConcurrentModificationException}, + * and guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not guaranteed to) + * reflect any modifications subsequent to construction. + */ + public static final class ValuesView extends CHMView + implements Collection { + ValuesView(ConcurrentHashMapV8 map) { super(map); } + public final boolean contains(Object o) { return map.containsValue(o); } + public final boolean remove(Object o) { + if (o != null) { + Iterator it = new ValueIterator(map); + while (it.hasNext()) { + if (o.equals(it.next())) { + it.remove(); + return true; + } + } + } + return false; + } + + /** + * Returns a "weakly consistent" iterator that will never + * throw {@link ConcurrentModificationException}, and + * guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not + * guaranteed to) reflect any modifications subsequent to + * construction. + * + * @return an iterator over the values of this map + */ + public final Iterator iterator() { + return new ValueIterator(map); + } + public final boolean add(V e) { + throw new UnsupportedOperationException(); + } + public final boolean addAll(Collection c) { + throw new UnsupportedOperationException(); + } + } + + /** + * A view of a ConcurrentHashMapV8 as a {@link Set} of (key, value) + * entries. This class cannot be directly instantiated. See + * {@link #entrySet}. + */ + public static final class EntrySetView extends CHMView + implements Set> { + EntrySetView(ConcurrentHashMapV8 map) { super(map); } + public final boolean contains(Object o) { + Object k, v, r; Map.Entry e; + return ((o instanceof Map.Entry) && + (k = (e = (Map.Entry)o).getKey()) != null && + (r = map.get(k)) != null && + (v = e.getValue()) != null && + (v == r || v.equals(r))); + } + public final boolean remove(Object o) { + Object k, v; Map.Entry e; + return ((o instanceof Map.Entry) && + (k = (e = (Map.Entry)o).getKey()) != null && + (v = e.getValue()) != null && + map.remove(k, v)); + } + + /** + * Returns a "weakly consistent" iterator that will never + * throw {@link ConcurrentModificationException}, and + * guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not + * guaranteed to) reflect any modifications subsequent to + * construction. + * + * @return an iterator over the entries of this map + */ + public final Iterator> iterator() { + return new EntryIterator(map); + } + + public final boolean add(Entry e) { + K key = e.getKey(); + V value = e.getValue(); + if (key == null || value == null) + throw new NullPointerException(); + return map.internalPut(key, value) == null; + } + public final boolean addAll(Collection> c) { + boolean added = false; + for (Entry e : c) { + if (add(e)) + added = true; + } + return added; + } + public boolean equals(Object o) { + Set c; + return ((o instanceof Set) && + ((c = (Set)o) == this || + (containsAll(c) && c.containsAll(this)))); + } + } + + // Unsafe mechanics + private static final sun.misc.Unsafe UNSAFE; + private static final long counterOffset; + private static final long sizeCtlOffset; + private static final long ABASE; + private static final int ASHIFT; + + static { + int ss; + try { + UNSAFE = getUnsafe(); + Class k = ConcurrentHashMapV8.class; + counterOffset = UNSAFE.objectFieldOffset + (k.getDeclaredField("counter")); + sizeCtlOffset = UNSAFE.objectFieldOffset + (k.getDeclaredField("sizeCtl")); + Class sc = Node[].class; + ABASE = UNSAFE.arrayBaseOffset(sc); + ss = UNSAFE.arrayIndexScale(sc); + } catch (Exception e) { + throw new Error(e); + } + if ((ss & (ss-1)) != 0) + throw new Error("data type scale not a power of two"); + ASHIFT = 31 - Integer.numberOfLeadingZeros(ss); + } + + /** + * Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. + * Replace with a simple call to Unsafe.getUnsafe when integrating + * into a jdk. + * + * @return a sun.misc.Unsafe + */ + private static sun.misc.Unsafe getUnsafe() { + try { + return sun.misc.Unsafe.getUnsafe(); + } catch (SecurityException se) { + try { + return java.security.AccessController.doPrivileged + (new java.security + .PrivilegedExceptionAction() { + public sun.misc.Unsafe run() throws Exception { + java.lang.reflect.Field f = sun.misc + .Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + return (sun.misc.Unsafe) f.get(null); + }}); + } catch (java.security.PrivilegedActionException e) { + throw new RuntimeException("Could not initialize intrinsics", + e.getCause()); + } + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/LongAdder.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/LongAdder.java new file mode 100644 index 0000000..47a923c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/LongAdder.java @@ -0,0 +1,203 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This is based on 1.9 version. + +package com.concurrent_ruby.ext.jsr166e; +import java.util.concurrent.atomic.AtomicLong; +import java.io.IOException; +import java.io.Serializable; +import java.io.ObjectInputStream; + +/** + * One or more variables that together maintain an initially zero + * {@code long} sum. When updates (method {@link #add}) are contended + * across threads, the set of variables may grow dynamically to reduce + * contention. Method {@link #sum} (or, equivalently, {@link + * #longValue}) returns the current total combined across the + * variables maintaining the sum. + * + *

This class is usually preferable to {@link AtomicLong} when + * multiple threads update a common sum that is used for purposes such + * as collecting statistics, not for fine-grained synchronization + * control. Under low update contention, the two classes have similar + * characteristics. But under high contention, expected throughput of + * this class is significantly higher, at the expense of higher space + * consumption. + * + *

This class extends {@link Number}, but does not define + * methods such as {@code hashCode} and {@code compareTo} because + * instances are expected to be mutated, and so are not useful as + * collection keys. + * + *

jsr166e note: This class is targeted to be placed in + * java.util.concurrent.atomic. + * + * @since 1.8 + * @author Doug Lea + */ +public class LongAdder extends Striped64 implements Serializable { + private static final long serialVersionUID = 7249069246863182397L; + + /** + * Version of plus for use in retryUpdate + */ + final long fn(long v, long x) { return v + x; } + + /** + * Creates a new adder with initial sum of zero. + */ + public LongAdder() { + } + + /** + * Adds the given value. + * + * @param x the value to add + */ + public void add(long x) { + Cell[] as; long b, v; HashCode hc; Cell a; int n; + if ((as = cells) != null || !casBase(b = base, b + x)) { + boolean uncontended = true; + int h = (hc = threadHashCode.get()).code; + if (as == null || (n = as.length) < 1 || + (a = as[(n - 1) & h]) == null || + !(uncontended = a.cas(v = a.value, v + x))) + retryUpdate(x, hc, uncontended); + } + } + + /** + * Equivalent to {@code add(1)}. + */ + public void increment() { + add(1L); + } + + /** + * Equivalent to {@code add(-1)}. + */ + public void decrement() { + add(-1L); + } + + /** + * Returns the current sum. The returned value is NOT an + * atomic snapshot: Invocation in the absence of concurrent + * updates returns an accurate result, but concurrent updates that + * occur while the sum is being calculated might not be + * incorporated. + * + * @return the sum + */ + public long sum() { + long sum = base; + Cell[] as = cells; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) + sum += a.value; + } + } + return sum; + } + + /** + * Resets variables maintaining the sum to zero. This method may + * be a useful alternative to creating a new adder, but is only + * effective if there are no concurrent updates. Because this + * method is intrinsically racy, it should only be used when it is + * known that no threads are concurrently updating. + */ + public void reset() { + internalReset(0L); + } + + /** + * Equivalent in effect to {@link #sum} followed by {@link + * #reset}. This method may apply for example during quiescent + * points between multithreaded computations. If there are + * updates concurrent with this method, the returned value is + * not guaranteed to be the final value occurring before + * the reset. + * + * @return the sum + */ + public long sumThenReset() { + long sum = base; + Cell[] as = cells; + base = 0L; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) { + sum += a.value; + a.value = 0L; + } + } + } + return sum; + } + + /** + * Returns the String representation of the {@link #sum}. + * @return the String representation of the {@link #sum} + */ + public String toString() { + return Long.toString(sum()); + } + + /** + * Equivalent to {@link #sum}. + * + * @return the sum + */ + public long longValue() { + return sum(); + } + + /** + * Returns the {@link #sum} as an {@code int} after a narrowing + * primitive conversion. + */ + public int intValue() { + return (int)sum(); + } + + /** + * Returns the {@link #sum} as a {@code float} + * after a widening primitive conversion. + */ + public float floatValue() { + return (float)sum(); + } + + /** + * Returns the {@link #sum} as a {@code double} after a widening + * primitive conversion. + */ + public double doubleValue() { + return (double)sum(); + } + + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + s.defaultWriteObject(); + s.writeLong(sum()); + } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + busy = 0; + cells = null; + base = s.readLong(); + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java new file mode 100644 index 0000000..93a277f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java @@ -0,0 +1,342 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This is based on 1.5 version. + +package com.concurrent_ruby.ext.jsr166e; +import java.util.Random; + +/** + * A package-local class holding common representation and mechanics + * for classes supporting dynamic striping on 64bit values. The class + * extends Number so that concrete subclasses must publicly do so. + */ +abstract class Striped64 extends Number { + /* + * This class maintains a lazily-initialized table of atomically + * updated variables, plus an extra "base" field. The table size + * is a power of two. Indexing uses masked per-thread hash codes. + * Nearly all declarations in this class are package-private, + * accessed directly by subclasses. + * + * Table entries are of class Cell; a variant of AtomicLong padded + * to reduce cache contention on most processors. Padding is + * overkill for most Atomics because they are usually irregularly + * scattered in memory and thus don't interfere much with each + * other. But Atomic objects residing in arrays will tend to be + * placed adjacent to each other, and so will most often share + * cache lines (with a huge negative performance impact) without + * this precaution. + * + * In part because Cells are relatively large, we avoid creating + * them until they are needed. When there is no contention, all + * updates are made to the base field. Upon first contention (a + * failed CAS on base update), the table is initialized to size 2. + * The table size is doubled upon further contention until + * reaching the nearest power of two greater than or equal to the + * number of CPUS. Table slots remain empty (null) until they are + * needed. + * + * A single spinlock ("busy") is used for initializing and + * resizing the table, as well as populating slots with new Cells. + * There is no need for a blocking lock: When the lock is not + * available, threads try other slots (or the base). During these + * retries, there is increased contention and reduced locality, + * which is still better than alternatives. + * + * Per-thread hash codes are initialized to random values. + * Contention and/or table collisions are indicated by failed + * CASes when performing an update operation (see method + * retryUpdate). Upon a collision, if the table size is less than + * the capacity, it is doubled in size unless some other thread + * holds the lock. If a hashed slot is empty, and lock is + * available, a new Cell is created. Otherwise, if the slot + * exists, a CAS is tried. Retries proceed by "double hashing", + * using a secondary hash (Marsaglia XorShift) to try to find a + * free slot. + * + * The table size is capped because, when there are more threads + * than CPUs, supposing that each thread were bound to a CPU, + * there would exist a perfect hash function mapping threads to + * slots that eliminates collisions. When we reach capacity, we + * search for this mapping by randomly varying the hash codes of + * colliding threads. Because search is random, and collisions + * only become known via CAS failures, convergence can be slow, + * and because threads are typically not bound to CPUS forever, + * may not occur at all. However, despite these limitations, + * observed contention rates are typically low in these cases. + * + * It is possible for a Cell to become unused when threads that + * once hashed to it terminate, as well as in the case where + * doubling the table causes no thread to hash to it under + * expanded mask. We do not try to detect or remove such cells, + * under the assumption that for long-running instances, observed + * contention levels will recur, so the cells will eventually be + * needed again; and for short-lived ones, it does not matter. + */ + + /** + * Padded variant of AtomicLong supporting only raw accesses plus CAS. + * The value field is placed between pads, hoping that the JVM doesn't + * reorder them. + * + * JVM intrinsics note: It would be possible to use a release-only + * form of CAS here, if it were provided. + */ + static final class Cell { + volatile long p0, p1, p2, p3, p4, p5, p6; + volatile long value; + volatile long q0, q1, q2, q3, q4, q5, q6; + Cell(long x) { value = x; } + + final boolean cas(long cmp, long val) { + return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val); + } + + // Unsafe mechanics + private static final sun.misc.Unsafe UNSAFE; + private static final long valueOffset; + static { + try { + UNSAFE = getUnsafe(); + Class ak = Cell.class; + valueOffset = UNSAFE.objectFieldOffset + (ak.getDeclaredField("value")); + } catch (Exception e) { + throw new Error(e); + } + } + + } + + /** + * Holder for the thread-local hash code. The code is initially + * random, but may be set to a different value upon collisions. + */ + static final class HashCode { + static final Random rng = new Random(); + int code; + HashCode() { + int h = rng.nextInt(); // Avoid zero to allow xorShift rehash + code = (h == 0) ? 1 : h; + } + } + + /** + * The corresponding ThreadLocal class + */ + static final class ThreadHashCode extends ThreadLocal { + public HashCode initialValue() { return new HashCode(); } + } + + /** + * Static per-thread hash codes. Shared across all instances to + * reduce ThreadLocal pollution and because adjustments due to + * collisions in one table are likely to be appropriate for + * others. + */ + static final ThreadHashCode threadHashCode = new ThreadHashCode(); + + /** Number of CPUS, to place bound on table size */ + static final int NCPU = Runtime.getRuntime().availableProcessors(); + + /** + * Table of cells. When non-null, size is a power of 2. + */ + transient volatile Cell[] cells; + + /** + * Base value, used mainly when there is no contention, but also as + * a fallback during table initialization races. Updated via CAS. + */ + transient volatile long base; + + /** + * Spinlock (locked via CAS) used when resizing and/or creating Cells. + */ + transient volatile int busy; + + /** + * Package-private default constructor + */ + Striped64() { + } + + /** + * CASes the base field. + */ + final boolean casBase(long cmp, long val) { + return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val); + } + + /** + * CASes the busy field from 0 to 1 to acquire lock. + */ + final boolean casBusy() { + return UNSAFE.compareAndSwapInt(this, busyOffset, 0, 1); + } + + /** + * Computes the function of current and new value. Subclasses + * should open-code this update function for most uses, but the + * virtualized form is needed within retryUpdate. + * + * @param currentValue the current value (of either base or a cell) + * @param newValue the argument from a user update call + * @return result of the update function + */ + abstract long fn(long currentValue, long newValue); + + /** + * Handles cases of updates involving initialization, resizing, + * creating new Cells, and/or contention. See above for + * explanation. This method suffers the usual non-modularity + * problems of optimistic retry code, relying on rechecked sets of + * reads. + * + * @param x the value + * @param hc the hash code holder + * @param wasUncontended false if CAS failed before call + */ + final void retryUpdate(long x, HashCode hc, boolean wasUncontended) { + int h = hc.code; + boolean collide = false; // True if last slot nonempty + for (;;) { + Cell[] as; Cell a; int n; long v; + if ((as = cells) != null && (n = as.length) > 0) { + if ((a = as[(n - 1) & h]) == null) { + if (busy == 0) { // Try to attach new Cell + Cell r = new Cell(x); // Optimistically create + if (busy == 0 && casBusy()) { + boolean created = false; + try { // Recheck under lock + Cell[] rs; int m, j; + if ((rs = cells) != null && + (m = rs.length) > 0 && + rs[j = (m - 1) & h] == null) { + rs[j] = r; + created = true; + } + } finally { + busy = 0; + } + if (created) + break; + continue; // Slot is now non-empty + } + } + collide = false; + } + else if (!wasUncontended) // CAS already known to fail + wasUncontended = true; // Continue after rehash + else if (a.cas(v = a.value, fn(v, x))) + break; + else if (n >= NCPU || cells != as) + collide = false; // At max size or stale + else if (!collide) + collide = true; + else if (busy == 0 && casBusy()) { + try { + if (cells == as) { // Expand table unless stale + Cell[] rs = new Cell[n << 1]; + for (int i = 0; i < n; ++i) + rs[i] = as[i]; + cells = rs; + } + } finally { + busy = 0; + } + collide = false; + continue; // Retry with expanded table + } + h ^= h << 13; // Rehash + h ^= h >>> 17; + h ^= h << 5; + } + else if (busy == 0 && cells == as && casBusy()) { + boolean init = false; + try { // Initialize table + if (cells == as) { + Cell[] rs = new Cell[2]; + rs[h & 1] = new Cell(x); + cells = rs; + init = true; + } + } finally { + busy = 0; + } + if (init) + break; + } + else if (casBase(v = base, fn(v, x))) + break; // Fall back on using base + } + hc.code = h; // Record index for next time + } + + + /** + * Sets base and all cells to the given value. + */ + final void internalReset(long initialValue) { + Cell[] as = cells; + base = initialValue; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) + a.value = initialValue; + } + } + } + + // Unsafe mechanics + private static final sun.misc.Unsafe UNSAFE; + private static final long baseOffset; + private static final long busyOffset; + static { + try { + UNSAFE = getUnsafe(); + Class sk = Striped64.class; + baseOffset = UNSAFE.objectFieldOffset + (sk.getDeclaredField("base")); + busyOffset = UNSAFE.objectFieldOffset + (sk.getDeclaredField("busy")); + } catch (Exception e) { + throw new Error(e); + } + } + + /** + * Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. + * Replace with a simple call to Unsafe.getUnsafe when integrating + * into a jdk. + * + * @return a sun.misc.Unsafe + */ + private static sun.misc.Unsafe getUnsafe() { + try { + return sun.misc.Unsafe.getUnsafe(); + } catch (SecurityException se) { + try { + return java.security.AccessController.doPrivileged + (new java.security + .PrivilegedExceptionAction() { + public sun.misc.Unsafe run() throws Exception { + java.lang.reflect.Field f = sun.misc + .Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + return (sun.misc.Unsafe) f.get(null); + }}); + } catch (java.security.PrivilegedActionException e) { + throw new RuntimeException("Could not initialize intrinsics", + e.getCause()); + } + } + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java new file mode 100644 index 0000000..b7fc5a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java @@ -0,0 +1,3800 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This is based on the 1.79 version. + +package com.concurrent_ruby.ext.jsr166e.nounsafe; + +import org.jruby.RubyClass; +import org.jruby.RubyNumeric; +import org.jruby.RubyObject; +import org.jruby.exceptions.RaiseException; +import com.concurrent_ruby.ext.jsr166e.ConcurrentHashMap; +import com.concurrent_ruby.ext.jsr166y.ThreadLocalRandom; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; + +import java.util.Arrays; +import java.util.Map; +import java.util.Set; +import java.util.Collection; +import java.util.Hashtable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Enumeration; +import java.util.ConcurrentModificationException; +import java.util.NoSuchElementException; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.atomic.AtomicReferenceArray; +import java.util.concurrent.locks.AbstractQueuedSynchronizer; + +import java.io.Serializable; + +/** + * A hash table supporting full concurrency of retrievals and + * high expected concurrency for updates. This class obeys the + * same functional specification as {@link java.util.Hashtable}, and + * includes versions of methods corresponding to each method of + * {@code Hashtable}. However, even though all operations are + * thread-safe, retrieval operations do not entail locking, + * and there is not any support for locking the entire table + * in a way that prevents all access. This class is fully + * interoperable with {@code Hashtable} in programs that rely on its + * thread safety but not on its synchronization details. + * + *

Retrieval operations (including {@code get}) generally do not + * block, so may overlap with update operations (including {@code put} + * and {@code remove}). Retrievals reflect the results of the most + * recently completed update operations holding upon their + * onset. (More formally, an update operation for a given key bears a + * happens-before relation with any (non-null) retrieval for + * that key reporting the updated value.) For aggregate operations + * such as {@code putAll} and {@code clear}, concurrent retrievals may + * reflect insertion or removal of only some entries. Similarly, + * Iterators and Enumerations return elements reflecting the state of + * the hash table at some point at or since the creation of the + * iterator/enumeration. They do not throw {@link + * ConcurrentModificationException}. However, iterators are designed + * to be used by only one thread at a time. Bear in mind that the + * results of aggregate status methods including {@code size}, {@code + * isEmpty}, and {@code containsValue} are typically useful only when + * a map is not undergoing concurrent updates in other threads. + * Otherwise the results of these methods reflect transient states + * that may be adequate for monitoring or estimation purposes, but not + * for program control. + * + *

The table is dynamically expanded when there are too many + * collisions (i.e., keys that have distinct hash codes but fall into + * the same slot modulo the table size), with the expected average + * effect of maintaining roughly two bins per mapping (corresponding + * to a 0.75 load factor threshold for resizing). There may be much + * variance around this average as mappings are added and removed, but + * overall, this maintains a commonly accepted time/space tradeoff for + * hash tables. However, resizing this or any other kind of hash + * table may be a relatively slow operation. When possible, it is a + * good idea to provide a size estimate as an optional {@code + * initialCapacity} constructor argument. An additional optional + * {@code loadFactor} constructor argument provides a further means of + * customizing initial table capacity by specifying the table density + * to be used in calculating the amount of space to allocate for the + * given number of elements. Also, for compatibility with previous + * versions of this class, constructors may optionally specify an + * expected {@code concurrencyLevel} as an additional hint for + * internal sizing. Note that using many keys with exactly the same + * {@code hashCode()} is a sure way to slow down performance of any + * hash table. + * + *

A {@link Set} projection of a ConcurrentHashMapV8 may be created + * (using {@link #newKeySet()} or {@link #newKeySet(int)}), or viewed + * (using {@link #keySet(Object)} when only keys are of interest, and the + * mapped values are (perhaps transiently) not used or all take the + * same mapping value. + * + *

A ConcurrentHashMapV8 can be used as scalable frequency map (a + * form of histogram or multiset) by using {@link LongAdder} values + * and initializing via {@link #computeIfAbsent}. For example, to add + * a count to a {@code ConcurrentHashMapV8 freqs}, you + * can use {@code freqs.computeIfAbsent(k -> new + * LongAdder()).increment();} + * + *

This class and its views and iterators implement all of the + * optional methods of the {@link Map} and {@link Iterator} + * interfaces. + * + *

Like {@link Hashtable} but unlike {@link HashMap}, this class + * does not allow {@code null} to be used as a key or value. + * + *

ConcurrentHashMapV8s support parallel operations using the {@link + * ForkJoinPool#commonPool}. (Tasks that may be used in other contexts + * are available in class {@link ForkJoinTasks}). These operations are + * designed to be safely, and often sensibly, applied even with maps + * that are being concurrently updated by other threads; for example, + * when computing a snapshot summary of the values in a shared + * registry. There are three kinds of operation, each with four + * forms, accepting functions with Keys, Values, Entries, and (Key, + * Value) arguments and/or return values. (The first three forms are + * also available via the {@link #keySet()}, {@link #values()} and + * {@link #entrySet()} views). Because the elements of a + * ConcurrentHashMapV8 are not ordered in any particular way, and may be + * processed in different orders in different parallel executions, the + * correctness of supplied functions should not depend on any + * ordering, or on any other objects or values that may transiently + * change while computation is in progress; and except for forEach + * actions, should ideally be side-effect-free. + * + *

+ * + *

The concurrency properties of bulk operations follow + * from those of ConcurrentHashMapV8: Any non-null result returned + * from {@code get(key)} and related access methods bears a + * happens-before relation with the associated insertion or + * update. The result of any bulk operation reflects the + * composition of these per-element relations (but is not + * necessarily atomic with respect to the map as a whole unless it + * is somehow known to be quiescent). Conversely, because keys + * and values in the map are never null, null serves as a reliable + * atomic indicator of the current lack of any result. To + * maintain this property, null serves as an implicit basis for + * all non-scalar reduction operations. For the double, long, and + * int versions, the basis should be one that, when combined with + * any other value, returns that other value (more formally, it + * should be the identity element for the reduction). Most common + * reductions have these properties; for example, computing a sum + * with basis 0 or a minimum with basis MAX_VALUE. + * + *

Search and transformation functions provided as arguments + * should similarly return null to indicate the lack of any result + * (in which case it is not used). In the case of mapped + * reductions, this also enables transformations to serve as + * filters, returning null (or, in the case of primitive + * specializations, the identity basis) if the element should not + * be combined. You can create compound transformations and + * filterings by composing them yourself under this "null means + * there is nothing there now" rule before using them in search or + * reduce operations. + * + *

Methods accepting and/or returning Entry arguments maintain + * key-value associations. They may be useful for example when + * finding the key for the greatest value. Note that "plain" Entry + * arguments can be supplied using {@code new + * AbstractMap.SimpleEntry(k,v)}. + * + *

Bulk operations may complete abruptly, throwing an + * exception encountered in the application of a supplied + * function. Bear in mind when handling such exceptions that other + * concurrently executing functions could also have thrown + * exceptions, or would have done so if the first exception had + * not occurred. + * + *

Parallel speedups for bulk operations compared to sequential + * processing are common but not guaranteed. Operations involving + * brief functions on small maps may execute more slowly than + * sequential loops if the underlying work to parallelize the + * computation is more expensive than the computation itself. + * Similarly, parallelization may not lead to much actual parallelism + * if all processors are busy performing unrelated tasks. + * + *

All arguments to all task methods must be non-null. + * + *

jsr166e note: During transition, this class + * uses nested functional interfaces with different names but the + * same forms as those expected for JDK8. + * + *

This class is a member of the + * + * Java Collections Framework. + * + * @since 1.5 + * @author Doug Lea + * @param the type of keys maintained by this map + * @param the type of mapped values + */ +public class ConcurrentHashMapV8 + implements ConcurrentMap, Serializable, ConcurrentHashMap { + private static final long serialVersionUID = 7249069246763182397L; + + /** + * A partitionable iterator. A Spliterator can be traversed + * directly, but can also be partitioned (before traversal) by + * creating another Spliterator that covers a non-overlapping + * portion of the elements, and so may be amenable to parallel + * execution. + * + *

This interface exports a subset of expected JDK8 + * functionality. + * + *

Sample usage: Here is one (of the several) ways to compute + * the sum of the values held in a map using the ForkJoin + * framework. As illustrated here, Spliterators are well suited to + * designs in which a task repeatedly splits off half its work + * into forked subtasks until small enough to process directly, + * and then joins these subtasks. Variants of this style can also + * be used in completion-based designs. + * + *

+     * {@code ConcurrentHashMapV8 m = ...
+     * // split as if have 8 * parallelism, for load balance
+     * int n = m.size();
+     * int p = aForkJoinPool.getParallelism() * 8;
+     * int split = (n < p)? n : p;
+     * long sum = aForkJoinPool.invoke(new SumValues(m.valueSpliterator(), split, null));
+     * // ...
+     * static class SumValues extends RecursiveTask {
+     *   final Spliterator s;
+     *   final int split;             // split while > 1
+     *   final SumValues nextJoin;    // records forked subtasks to join
+     *   SumValues(Spliterator s, int depth, SumValues nextJoin) {
+     *     this.s = s; this.depth = depth; this.nextJoin = nextJoin;
+     *   }
+     *   public Long compute() {
+     *     long sum = 0;
+     *     SumValues subtasks = null; // fork subtasks
+     *     for (int s = split >>> 1; s > 0; s >>>= 1)
+     *       (subtasks = new SumValues(s.split(), s, subtasks)).fork();
+     *     while (s.hasNext())        // directly process remaining elements
+     *       sum += s.next();
+     *     for (SumValues t = subtasks; t != null; t = t.nextJoin)
+     *       sum += t.join();         // collect subtask results
+     *     return sum;
+     *   }
+     * }
+     * }
+ */ + public static interface Spliterator extends Iterator { + /** + * Returns a Spliterator covering approximately half of the + * elements, guaranteed not to overlap with those subsequently + * returned by this Spliterator. After invoking this method, + * the current Spliterator will not produce any of + * the elements of the returned Spliterator, but the two + * Spliterators together will produce all of the elements that + * would have been produced by this Spliterator had this + * method not been called. The exact number of elements + * produced by the returned Spliterator is not guaranteed, and + * may be zero (i.e., with {@code hasNext()} reporting {@code + * false}) if this Spliterator cannot be further split. + * + * @return a Spliterator covering approximately half of the + * elements + * @throws IllegalStateException if this Spliterator has + * already commenced traversing elements + */ + Spliterator split(); + } + + + /* + * Overview: + * + * The primary design goal of this hash table is to maintain + * concurrent readability (typically method get(), but also + * iterators and related methods) while minimizing update + * contention. Secondary goals are to keep space consumption about + * the same or better than java.util.HashMap, and to support high + * initial insertion rates on an empty table by many threads. + * + * Each key-value mapping is held in a Node. Because Node fields + * can contain special values, they are defined using plain Object + * types. Similarly in turn, all internal methods that use them + * work off Object types. And similarly, so do the internal + * methods of auxiliary iterator and view classes. All public + * generic typed methods relay in/out of these internal methods, + * supplying null-checks and casts as needed. This also allows + * many of the public methods to be factored into a smaller number + * of internal methods (although sadly not so for the five + * variants of put-related operations). The validation-based + * approach explained below leads to a lot of code sprawl because + * retry-control precludes factoring into smaller methods. + * + * The table is lazily initialized to a power-of-two size upon the + * first insertion. Each bin in the table normally contains a + * list of Nodes (most often, the list has only zero or one Node). + * Table accesses require volatile/atomic reads, writes, and + * CASes. Because there is no other way to arrange this without + * adding further indirections, we use intrinsics + * (sun.misc.Unsafe) operations. The lists of nodes within bins + * are always accurately traversable under volatile reads, so long + * as lookups check hash code and non-nullness of value before + * checking key equality. + * + * We use the top two bits of Node hash fields for control + * purposes -- they are available anyway because of addressing + * constraints. As explained further below, these top bits are + * used as follows: + * 00 - Normal + * 01 - Locked + * 11 - Locked and may have a thread waiting for lock + * 10 - Node is a forwarding node + * + * The lower 30 bits of each Node's hash field contain a + * transformation of the key's hash code, except for forwarding + * nodes, for which the lower bits are zero (and so always have + * hash field == MOVED). + * + * Insertion (via put or its variants) of the first node in an + * empty bin is performed by just CASing it to the bin. This is + * by far the most common case for put operations under most + * key/hash distributions. Other update operations (insert, + * delete, and replace) require locks. We do not want to waste + * the space required to associate a distinct lock object with + * each bin, so instead use the first node of a bin list itself as + * a lock. Blocking support for these locks relies on the builtin + * "synchronized" monitors. However, we also need a tryLock + * construction, so we overlay these by using bits of the Node + * hash field for lock control (see above), and so normally use + * builtin monitors only for blocking and signalling using + * wait/notifyAll constructions. See Node.tryAwaitLock. + * + * Using the first node of a list as a lock does not by itself + * suffice though: When a node is locked, any update must first + * validate that it is still the first node after locking it, and + * retry if not. Because new nodes are always appended to lists, + * once a node is first in a bin, it remains first until deleted + * or the bin becomes invalidated (upon resizing). However, + * operations that only conditionally update may inspect nodes + * until the point of update. This is a converse of sorts to the + * lazy locking technique described by Herlihy & Shavit. + * + * The main disadvantage of per-bin locks is that other update + * operations on other nodes in a bin list protected by the same + * lock can stall, for example when user equals() or mapping + * functions take a long time. However, statistically, under + * random hash codes, this is not a common problem. Ideally, the + * frequency of nodes in bins follows a Poisson distribution + * (http://en.wikipedia.org/wiki/Poisson_distribution) with a + * parameter of about 0.5 on average, given the resizing threshold + * of 0.75, although with a large variance because of resizing + * granularity. Ignoring variance, the expected occurrences of + * list size k are (exp(-0.5) * pow(0.5, k) / factorial(k)). The + * first values are: + * + * 0: 0.60653066 + * 1: 0.30326533 + * 2: 0.07581633 + * 3: 0.01263606 + * 4: 0.00157952 + * 5: 0.00015795 + * 6: 0.00001316 + * 7: 0.00000094 + * 8: 0.00000006 + * more: less than 1 in ten million + * + * Lock contention probability for two threads accessing distinct + * elements is roughly 1 / (8 * #elements) under random hashes. + * + * Actual hash code distributions encountered in practice + * sometimes deviate significantly from uniform randomness. This + * includes the case when N > (1<<30), so some keys MUST collide. + * Similarly for dumb or hostile usages in which multiple keys are + * designed to have identical hash codes. Also, although we guard + * against the worst effects of this (see method spread), sets of + * hashes may differ only in bits that do not impact their bin + * index for a given power-of-two mask. So we use a secondary + * strategy that applies when the number of nodes in a bin exceeds + * a threshold, and at least one of the keys implements + * Comparable. These TreeBins use a balanced tree to hold nodes + * (a specialized form of red-black trees), bounding search time + * to O(log N). Each search step in a TreeBin is around twice as + * slow as in a regular list, but given that N cannot exceed + * (1<<64) (before running out of addresses) this bounds search + * steps, lock hold times, etc, to reasonable constants (roughly + * 100 nodes inspected per operation worst case) so long as keys + * are Comparable (which is very common -- String, Long, etc). + * TreeBin nodes (TreeNodes) also maintain the same "next" + * traversal pointers as regular nodes, so can be traversed in + * iterators in the same way. + * + * The table is resized when occupancy exceeds a percentage + * threshold (nominally, 0.75, but see below). Only a single + * thread performs the resize (using field "sizeCtl", to arrange + * exclusion), but the table otherwise remains usable for reads + * and updates. Resizing proceeds by transferring bins, one by + * one, from the table to the next table. Because we are using + * power-of-two expansion, the elements from each bin must either + * stay at same index, or move with a power of two offset. We + * eliminate unnecessary node creation by catching cases where old + * nodes can be reused because their next fields won't change. On + * average, only about one-sixth of them need cloning when a table + * doubles. The nodes they replace will be garbage collectable as + * soon as they are no longer referenced by any reader thread that + * may be in the midst of concurrently traversing table. Upon + * transfer, the old table bin contains only a special forwarding + * node (with hash field "MOVED") that contains the next table as + * its key. On encountering a forwarding node, access and update + * operations restart, using the new table. + * + * Each bin transfer requires its bin lock. However, unlike other + * cases, a transfer can skip a bin if it fails to acquire its + * lock, and revisit it later (unless it is a TreeBin). Method + * rebuild maintains a buffer of TRANSFER_BUFFER_SIZE bins that + * have been skipped because of failure to acquire a lock, and + * blocks only if none are available (i.e., only very rarely). + * The transfer operation must also ensure that all accessible + * bins in both the old and new table are usable by any traversal. + * When there are no lock acquisition failures, this is arranged + * simply by proceeding from the last bin (table.length - 1) up + * towards the first. Upon seeing a forwarding node, traversals + * (see class Iter) arrange to move to the new table + * without revisiting nodes. However, when any node is skipped + * during a transfer, all earlier table bins may have become + * visible, so are initialized with a reverse-forwarding node back + * to the old table until the new ones are established. (This + * sometimes requires transiently locking a forwarding node, which + * is possible under the above encoding.) These more expensive + * mechanics trigger only when necessary. + * + * The traversal scheme also applies to partial traversals of + * ranges of bins (via an alternate Traverser constructor) + * to support partitioned aggregate operations. Also, read-only + * operations give up if ever forwarded to a null table, which + * provides support for shutdown-style clearing, which is also not + * currently implemented. + * + * Lazy table initialization minimizes footprint until first use, + * and also avoids resizings when the first operation is from a + * putAll, constructor with map argument, or deserialization. + * These cases attempt to override the initial capacity settings, + * but harmlessly fail to take effect in cases of races. + * + * The element count is maintained using a LongAdder, which avoids + * contention on updates but can encounter cache thrashing if read + * too frequently during concurrent access. To avoid reading so + * often, resizing is attempted either when a bin lock is + * contended, or upon adding to a bin already holding two or more + * nodes (checked before adding in the xIfAbsent methods, after + * adding in others). Under uniform hash distributions, the + * probability of this occurring at threshold is around 13%, + * meaning that only about 1 in 8 puts check threshold (and after + * resizing, many fewer do so). But this approximation has high + * variance for small table sizes, so we check on any collision + * for sizes <= 64. The bulk putAll operation further reduces + * contention by only committing count updates upon these size + * checks. + * + * Maintaining API and serialization compatibility with previous + * versions of this class introduces several oddities. Mainly: We + * leave untouched but unused constructor arguments refering to + * concurrencyLevel. We accept a loadFactor constructor argument, + * but apply it only to initial table capacity (which is the only + * time that we can guarantee to honor it.) We also declare an + * unused "Segment" class that is instantiated in minimal form + * only when serializing. + */ + + /* ---------------- Constants -------------- */ + + /** + * The largest possible table capacity. This value must be + * exactly 1<<30 to stay within Java array allocation and indexing + * bounds for power of two table sizes, and is further required + * because the top two bits of 32bit hash fields are used for + * control purposes. + */ + private static final int MAXIMUM_CAPACITY = 1 << 30; + + /** + * The default initial table capacity. Must be a power of 2 + * (i.e., at least 1) and at most MAXIMUM_CAPACITY. + */ + private static final int DEFAULT_CAPACITY = 16; + + /** + * The largest possible (non-power of two) array size. + * Needed by toArray and related methods. + */ + static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + + /** + * The default concurrency level for this table. Unused but + * defined for compatibility with previous versions of this class. + */ + private static final int DEFAULT_CONCURRENCY_LEVEL = 16; + + /** + * The load factor for this table. Overrides of this value in + * constructors affect only the initial table capacity. The + * actual floating point value isn't normally used -- it is + * simpler to use expressions such as {@code n - (n >>> 2)} for + * the associated resizing threshold. + */ + private static final float LOAD_FACTOR = 0.75f; + + /** + * The buffer size for skipped bins during transfers. The + * value is arbitrary but should be large enough to avoid + * most locking stalls during resizes. + */ + private static final int TRANSFER_BUFFER_SIZE = 32; + + /** + * The bin count threshold for using a tree rather than list for a + * bin. The value reflects the approximate break-even point for + * using tree-based operations. + * Note that Doug's version defaults to 8, but when dealing with + * Ruby objects it is actually beneficial to avoid TreeNodes + * as long as possible as it usually means going into Ruby land. + */ + private static final int TREE_THRESHOLD = 16; + + /* + * Encodings for special uses of Node hash fields. See above for + * explanation. + */ + static final int MOVED = 0x80000000; // hash field for forwarding nodes + static final int LOCKED = 0x40000000; // set/tested only as a bit + static final int WAITING = 0xc0000000; // both bits set/tested together + static final int HASH_BITS = 0x3fffffff; // usable bits of normal node hash + + /* ---------------- Fields -------------- */ + + /** + * The array of bins. Lazily initialized upon first insertion. + * Size is always a power of two. Accessed directly by iterators. + */ + transient volatile AtomicReferenceArray table; + + /** + * The counter maintaining number of elements. + */ + private transient LongAdder counter; + + /** + * Table initialization and resizing control. When negative, the + * table is being initialized or resized. Otherwise, when table is + * null, holds the initial table size to use upon creation, or 0 + * for default. After initialization, holds the next element count + * value upon which to resize the table. + */ + private transient volatile int sizeCtl; + + // views + private transient KeySetView keySet; + private transient ValuesView values; + private transient EntrySetView entrySet; + + /** For serialization compatibility. Null unless serialized; see below */ + private Segment[] segments; + + static AtomicIntegerFieldUpdater SIZE_CTRL_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ConcurrentHashMapV8.class, "sizeCtl"); + + /* ---------------- Table element access -------------- */ + + /* + * Volatile access methods are used for table elements as well as + * elements of in-progress next table while resizing. Uses are + * null checked by callers, and implicitly bounds-checked, relying + * on the invariants that tab arrays have non-zero size, and all + * indices are masked with (tab.length - 1) which is never + * negative and always less than length. Note that, to be correct + * wrt arbitrary concurrency errors by users, bounds checks must + * operate on local variables, which accounts for some odd-looking + * inline assignments below. + */ + + static final Node tabAt(AtomicReferenceArray tab, int i) { // used by Iter + return tab.get(i); + } + + private static final boolean casTabAt(AtomicReferenceArray tab, int i, Node c, Node v) { + return tab.compareAndSet(i, c, v); + } + + private static final void setTabAt(AtomicReferenceArray tab, int i, Node v) { + tab.set(i, v); + } + + /* ---------------- Nodes -------------- */ + + /** + * Key-value entry. Note that this is never exported out as a + * user-visible Map.Entry (see MapEntry below). Nodes with a hash + * field of MOVED are special, and do not contain user keys or + * values. Otherwise, keys are never null, and null val fields + * indicate that a node is in the process of being deleted or + * created. For purposes of read-only access, a key may be read + * before a val, but can only be used after checking val to be + * non-null. + */ + static class Node { + volatile int hash; + final Object key; + volatile Object val; + volatile Node next; + + static AtomicIntegerFieldUpdater HASH_UPDATER = AtomicIntegerFieldUpdater.newUpdater(Node.class, "hash"); + + Node(int hash, Object key, Object val, Node next) { + this.hash = hash; + this.key = key; + this.val = val; + this.next = next; + } + + /** CompareAndSet the hash field */ + final boolean casHash(int cmp, int val) { + return HASH_UPDATER.compareAndSet(this, cmp, val); + } + + /** The number of spins before blocking for a lock */ + static final int MAX_SPINS = + Runtime.getRuntime().availableProcessors() > 1 ? 64 : 1; + + /** + * Spins a while if LOCKED bit set and this node is the first + * of its bin, and then sets WAITING bits on hash field and + * blocks (once) if they are still set. It is OK for this + * method to return even if lock is not available upon exit, + * which enables these simple single-wait mechanics. + * + * The corresponding signalling operation is performed within + * callers: Upon detecting that WAITING has been set when + * unlocking lock (via a failed CAS from non-waiting LOCKED + * state), unlockers acquire the sync lock and perform a + * notifyAll. + * + * The initial sanity check on tab and bounds is not currently + * necessary in the only usages of this method, but enables + * use in other future contexts. + */ + final void tryAwaitLock(AtomicReferenceArray tab, int i) { + if (tab != null && i >= 0 && i < tab.length()) { // sanity check + int r = ThreadLocalRandom.current().nextInt(); // randomize spins + int spins = MAX_SPINS, h; + while (tabAt(tab, i) == this && ((h = hash) & LOCKED) != 0) { + if (spins >= 0) { + r ^= r << 1; r ^= r >>> 3; r ^= r << 10; // xorshift + if (r >= 0 && --spins == 0) + Thread.yield(); // yield before block + } + else if (casHash(h, h | WAITING)) { + synchronized (this) { + if (tabAt(tab, i) == this && + (hash & WAITING) == WAITING) { + try { + wait(); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + } + } + else + notifyAll(); // possibly won race vs signaller + } + break; + } + } + } + } + } + + /* ---------------- TreeBins -------------- */ + + /** + * Nodes for use in TreeBins + */ + static final class TreeNode extends Node { + TreeNode parent; // red-black tree links + TreeNode left; + TreeNode right; + TreeNode prev; // needed to unlink next upon deletion + boolean red; + + TreeNode(int hash, Object key, Object val, Node next, TreeNode parent) { + super(hash, key, val, next); + this.parent = parent; + } + } + + /** + * A specialized form of red-black tree for use in bins + * whose size exceeds a threshold. + * + * TreeBins use a special form of comparison for search and + * related operations (which is the main reason we cannot use + * existing collections such as TreeMaps). TreeBins contain + * Comparable elements, but may contain others, as well as + * elements that are Comparable but not necessarily Comparable + * for the same T, so we cannot invoke compareTo among them. To + * handle this, the tree is ordered primarily by hash value, then + * by getClass().getName() order, and then by Comparator order + * among elements of the same class. On lookup at a node, if + * elements are not comparable or compare as 0, both left and + * right children may need to be searched in the case of tied hash + * values. (This corresponds to the full list search that would be + * necessary if all elements were non-Comparable and had tied + * hashes.) The red-black balancing code is updated from + * pre-jdk-collections + * (http://gee.cs.oswego.edu/dl/classes/collections/RBCell.java) + * based in turn on Cormen, Leiserson, and Rivest "Introduction to + * Algorithms" (CLR). + * + * TreeBins also maintain a separate locking discipline than + * regular bins. Because they are forwarded via special MOVED + * nodes at bin heads (which can never change once established), + * we cannot use those nodes as locks. Instead, TreeBin + * extends AbstractQueuedSynchronizer to support a simple form of + * read-write lock. For update operations and table validation, + * the exclusive form of lock behaves in the same way as bin-head + * locks. However, lookups use shared read-lock mechanics to allow + * multiple readers in the absence of writers. Additionally, + * these lookups do not ever block: While the lock is not + * available, they proceed along the slow traversal path (via + * next-pointers) until the lock becomes available or the list is + * exhausted, whichever comes first. (These cases are not fast, + * but maximize aggregate expected throughput.) The AQS mechanics + * for doing this are straightforward. The lock state is held as + * AQS getState(). Read counts are negative; the write count (1) + * is positive. There are no signalling preferences among readers + * and writers. Since we don't need to export full Lock API, we + * just override the minimal AQS methods and use them directly. + */ + static final class TreeBin extends AbstractQueuedSynchronizer { + private static final long serialVersionUID = 2249069246763182397L; + transient TreeNode root; // root of tree + transient TreeNode first; // head of next-pointer list + + /* AQS overrides */ + public final boolean isHeldExclusively() { return getState() > 0; } + public final boolean tryAcquire(int ignore) { + if (compareAndSetState(0, 1)) { + setExclusiveOwnerThread(Thread.currentThread()); + return true; + } + return false; + } + public final boolean tryRelease(int ignore) { + setExclusiveOwnerThread(null); + setState(0); + return true; + } + public final int tryAcquireShared(int ignore) { + for (int c;;) { + if ((c = getState()) > 0) + return -1; + if (compareAndSetState(c, c -1)) + return 1; + } + } + public final boolean tryReleaseShared(int ignore) { + int c; + do {} while (!compareAndSetState(c = getState(), c + 1)); + return c == -1; + } + + /** From CLR */ + private void rotateLeft(TreeNode p) { + if (p != null) { + TreeNode r = p.right, pp, rl; + if ((rl = p.right = r.left) != null) + rl.parent = p; + if ((pp = r.parent = p.parent) == null) + root = r; + else if (pp.left == p) + pp.left = r; + else + pp.right = r; + r.left = p; + p.parent = r; + } + } + + /** From CLR */ + private void rotateRight(TreeNode p) { + if (p != null) { + TreeNode l = p.left, pp, lr; + if ((lr = p.left = l.right) != null) + lr.parent = p; + if ((pp = l.parent = p.parent) == null) + root = l; + else if (pp.right == p) + pp.right = l; + else + pp.left = l; + l.right = p; + p.parent = l; + } + } + + @SuppressWarnings("unchecked") final TreeNode getTreeNode + (int h, Object k, TreeNode p) { + return getTreeNode(h, (RubyObject)k, p); + } + + /** + * Returns the TreeNode (or null if not found) for the given key + * starting at given root. + */ + @SuppressWarnings("unchecked") final TreeNode getTreeNode + (int h, RubyObject k, TreeNode p) { + RubyClass c = k.getMetaClass(); boolean kNotComparable = !k.respondsTo("<=>"); + while (p != null) { + int dir, ph; RubyObject pk; RubyClass pc; + if ((ph = p.hash) == h) { + if ((pk = (RubyObject)p.key) == k || k.equals(pk)) + return p; + if (c != (pc = (RubyClass)pk.getMetaClass()) || + kNotComparable || + (dir = rubyCompare(k, pk)) == 0) { + dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); + if (dir == 0) { // if still stuck, need to check both sides + TreeNode r = null, pl, pr; + // try to recurse on the right + if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null) + return r; + // try to continue iterating on the left side + else if ((pl = p.left) != null && h <= pl.hash) + dir = -1; + else // no matching node found + return null; + } + } + } + else + dir = (h < ph) ? -1 : 1; + p = (dir > 0) ? p.right : p.left; + } + return null; + } + + int rubyCompare(RubyObject l, RubyObject r) { + ThreadContext context = l.getMetaClass().getRuntime().getCurrentContext(); + IRubyObject result; + try { + result = l.callMethod(context, "<=>", r); + } catch (RaiseException e) { + // handle objects "lying" about responding to <=>, ie: an Array containing non-comparable keys + if (context.runtime.getNoMethodError().isInstance(e.getException())) { + return 0; + } + throw e; + } + + return result.isNil() ? 0 : RubyNumeric.num2int(result.convertToInteger()); + } + + /** + * Wrapper for getTreeNode used by CHM.get. Tries to obtain + * read-lock to call getTreeNode, but during failure to get + * lock, searches along next links. + */ + final Object getValue(int h, Object k) { + Node r = null; + int c = getState(); // Must read lock state first + for (Node e = first; e != null; e = e.next) { + if (c <= 0 && compareAndSetState(c, c - 1)) { + try { + r = getTreeNode(h, k, root); + } finally { + releaseShared(0); + } + break; + } + else if ((e.hash & HASH_BITS) == h && k.equals(e.key)) { + r = e; + break; + } + else + c = getState(); + } + return r == null ? null : r.val; + } + + @SuppressWarnings("unchecked") final TreeNode putTreeNode + (int h, Object k, Object v) { + return putTreeNode(h, (RubyObject)k, v); + } + + /** + * Finds or adds a node. + * @return null if added + */ + @SuppressWarnings("unchecked") final TreeNode putTreeNode + (int h, RubyObject k, Object v) { + RubyClass c = k.getMetaClass(); + boolean kNotComparable = !k.respondsTo("<=>"); + TreeNode pp = root, p = null; + int dir = 0; + while (pp != null) { // find existing node or leaf to insert at + int ph; RubyObject pk; RubyClass pc; + p = pp; + if ((ph = p.hash) == h) { + if ((pk = (RubyObject)p.key) == k || k.equals(pk)) + return p; + if (c != (pc = pk.getMetaClass()) || + kNotComparable || + (dir = rubyCompare(k, pk)) == 0) { + dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); + if (dir == 0) { // if still stuck, need to check both sides + TreeNode r = null, pr; + // try to recurse on the right + if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null) + return r; + else // continue descending down the left subtree + dir = -1; + } + } + } + else + dir = (h < ph) ? -1 : 1; + pp = (dir > 0) ? p.right : p.left; + } + + TreeNode f = first; + TreeNode x = first = new TreeNode(h, (Object)k, v, f, p); + if (p == null) + root = x; + else { // attach and rebalance; adapted from CLR + TreeNode xp, xpp; + if (f != null) + f.prev = x; + if (dir <= 0) + p.left = x; + else + p.right = x; + x.red = true; + while (x != null && (xp = x.parent) != null && xp.red && + (xpp = xp.parent) != null) { + TreeNode xppl = xpp.left; + if (xp == xppl) { + TreeNode y = xpp.right; + if (y != null && y.red) { + y.red = false; + xp.red = false; + xpp.red = true; + x = xpp; + } + else { + if (x == xp.right) { + rotateLeft(x = xp); + xpp = (xp = x.parent) == null ? null : xp.parent; + } + if (xp != null) { + xp.red = false; + if (xpp != null) { + xpp.red = true; + rotateRight(xpp); + } + } + } + } + else { + TreeNode y = xppl; + if (y != null && y.red) { + y.red = false; + xp.red = false; + xpp.red = true; + x = xpp; + } + else { + if (x == xp.left) { + rotateRight(x = xp); + xpp = (xp = x.parent) == null ? null : xp.parent; + } + if (xp != null) { + xp.red = false; + if (xpp != null) { + xpp.red = true; + rotateLeft(xpp); + } + } + } + } + } + TreeNode r = root; + if (r != null && r.red) + r.red = false; + } + return null; + } + + /** + * Removes the given node, that must be present before this + * call. This is messier than typical red-black deletion code + * because we cannot swap the contents of an interior node + * with a leaf successor that is pinned by "next" pointers + * that are accessible independently of lock. So instead we + * swap the tree linkages. + */ + final void deleteTreeNode(TreeNode p) { + TreeNode next = (TreeNode)p.next; // unlink traversal pointers + TreeNode pred = p.prev; + if (pred == null) + first = next; + else + pred.next = next; + if (next != null) + next.prev = pred; + TreeNode replacement; + TreeNode pl = p.left; + TreeNode pr = p.right; + if (pl != null && pr != null) { + TreeNode s = pr, sl; + while ((sl = s.left) != null) // find successor + s = sl; + boolean c = s.red; s.red = p.red; p.red = c; // swap colors + TreeNode sr = s.right; + TreeNode pp = p.parent; + if (s == pr) { // p was s's direct parent + p.parent = s; + s.right = p; + } + else { + TreeNode sp = s.parent; + if ((p.parent = sp) != null) { + if (s == sp.left) + sp.left = p; + else + sp.right = p; + } + if ((s.right = pr) != null) + pr.parent = s; + } + p.left = null; + if ((p.right = sr) != null) + sr.parent = p; + if ((s.left = pl) != null) + pl.parent = s; + if ((s.parent = pp) == null) + root = s; + else if (p == pp.left) + pp.left = s; + else + pp.right = s; + replacement = sr; + } + else + replacement = (pl != null) ? pl : pr; + TreeNode pp = p.parent; + if (replacement == null) { + if (pp == null) { + root = null; + return; + } + replacement = p; + } + else { + replacement.parent = pp; + if (pp == null) + root = replacement; + else if (p == pp.left) + pp.left = replacement; + else + pp.right = replacement; + p.left = p.right = p.parent = null; + } + if (!p.red) { // rebalance, from CLR + TreeNode x = replacement; + while (x != null) { + TreeNode xp, xpl; + if (x.red || (xp = x.parent) == null) { + x.red = false; + break; + } + if (x == (xpl = xp.left)) { + TreeNode sib = xp.right; + if (sib != null && sib.red) { + sib.red = false; + xp.red = true; + rotateLeft(xp); + sib = (xp = x.parent) == null ? null : xp.right; + } + if (sib == null) + x = xp; + else { + TreeNode sl = sib.left, sr = sib.right; + if ((sr == null || !sr.red) && + (sl == null || !sl.red)) { + sib.red = true; + x = xp; + } + else { + if (sr == null || !sr.red) { + if (sl != null) + sl.red = false; + sib.red = true; + rotateRight(sib); + sib = (xp = x.parent) == null ? null : xp.right; + } + if (sib != null) { + sib.red = (xp == null) ? false : xp.red; + if ((sr = sib.right) != null) + sr.red = false; + } + if (xp != null) { + xp.red = false; + rotateLeft(xp); + } + x = root; + } + } + } + else { // symmetric + TreeNode sib = xpl; + if (sib != null && sib.red) { + sib.red = false; + xp.red = true; + rotateRight(xp); + sib = (xp = x.parent) == null ? null : xp.left; + } + if (sib == null) + x = xp; + else { + TreeNode sl = sib.left, sr = sib.right; + if ((sl == null || !sl.red) && + (sr == null || !sr.red)) { + sib.red = true; + x = xp; + } + else { + if (sl == null || !sl.red) { + if (sr != null) + sr.red = false; + sib.red = true; + rotateLeft(sib); + sib = (xp = x.parent) == null ? null : xp.left; + } + if (sib != null) { + sib.red = (xp == null) ? false : xp.red; + if ((sl = sib.left) != null) + sl.red = false; + } + if (xp != null) { + xp.red = false; + rotateRight(xp); + } + x = root; + } + } + } + } + } + if (p == replacement && (pp = p.parent) != null) { + if (p == pp.left) // detach pointers + pp.left = null; + else if (p == pp.right) + pp.right = null; + p.parent = null; + } + } + } + + /* ---------------- Collision reduction methods -------------- */ + + /** + * Spreads higher bits to lower, and also forces top 2 bits to 0. + * Because the table uses power-of-two masking, sets of hashes + * that vary only in bits above the current mask will always + * collide. (Among known examples are sets of Float keys holding + * consecutive whole numbers in small tables.) To counter this, + * we apply a transform that spreads the impact of higher bits + * downward. There is a tradeoff between speed, utility, and + * quality of bit-spreading. Because many common sets of hashes + * are already reasonably distributed across bits (so don't benefit + * from spreading), and because we use trees to handle large sets + * of collisions in bins, we don't need excessively high quality. + */ + private static final int spread(int h) { + h ^= (h >>> 18) ^ (h >>> 12); + return (h ^ (h >>> 10)) & HASH_BITS; + } + + /** + * Replaces a list bin with a tree bin. Call only when locked. + * Fails to replace if the given key is non-comparable or table + * is, or needs, resizing. + */ + private final void replaceWithTreeBin(AtomicReferenceArray tab, int index, Object key) { + if ((key instanceof Comparable) && + (tab.length() >= MAXIMUM_CAPACITY || counter.sum() < (long)sizeCtl)) { + TreeBin t = new TreeBin(); + for (Node e = tabAt(tab, index); e != null; e = e.next) + t.putTreeNode(e.hash & HASH_BITS, e.key, e.val); + setTabAt(tab, index, new Node(MOVED, t, null, null)); + } + } + + /* ---------------- Internal access and update methods -------------- */ + + /** Implementation for get and containsKey */ + private final Object internalGet(Object k) { + int h = spread(k.hashCode()); + retry: for (AtomicReferenceArray tab = table; tab != null;) { + Node e, p; Object ek, ev; int eh; // locals to read fields once + for (e = tabAt(tab, (tab.length() - 1) & h); e != null; e = e.next) { + if ((eh = e.hash) == MOVED) { + if ((ek = e.key) instanceof TreeBin) // search TreeBin + return ((TreeBin)ek).getValue(h, k); + else { // restart with new table + tab = (AtomicReferenceArray)ek; + continue retry; + } + } + else if ((eh & HASH_BITS) == h && (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) + return ev; + } + break; + } + return null; + } + + /** + * Implementation for the four public remove/replace methods: + * Replaces node value with v, conditional upon match of cv if + * non-null. If resulting value is null, delete. + */ + private final Object internalReplace(Object k, Object v, Object cv) { + int h = spread(k.hashCode()); + Object oldVal = null; + for (AtomicReferenceArray tab = table;;) { + Node f; int i, fh; Object fk; + if (tab == null || + (f = tabAt(tab, i = (tab.length() - 1) & h)) == null) + break; + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean validated = false; + boolean deleted = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + validated = true; + TreeNode p = t.getTreeNode(h, k, t.root); + if (p != null) { + Object pv = p.val; + if (cv == null || cv == pv || cv.equals(pv)) { + oldVal = pv; + if ((p.val = v) == null) { + deleted = true; + t.deleteTreeNode(p); + } + } + } + } + } finally { + t.release(0); + } + if (validated) { + if (deleted) + counter.add(-1L); + break; + } + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & HASH_BITS) != h && f.next == null) // precheck + break; // rules out possible existence + else if ((fh & LOCKED) != 0) { + checkForResize(); // try resizing if can't get lock + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + boolean validated = false; + boolean deleted = false; + try { + if (tabAt(tab, i) == f) { + validated = true; + for (Node e = f, pred = null;;) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + ((ev = e.val) != null) && + ((ek = e.key) == k || k.equals(ek))) { + if (cv == null || cv == ev || cv.equals(ev)) { + oldVal = ev; + if ((e.val = v) == null) { + deleted = true; + Node en = e.next; + if (pred != null) + pred.next = en; + else + setTabAt(tab, i, en); + } + } + break; + } + pred = e; + if ((e = e.next) == null) + break; + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (validated) { + if (deleted) + counter.add(-1L); + break; + } + } + } + return oldVal; + } + + /* + * Internal versions of the six insertion methods, each a + * little more complicated than the last. All have + * the same basic structure as the first (internalPut): + * 1. If table uninitialized, create + * 2. If bin empty, try to CAS new node + * 3. If bin stale, use new table + * 4. if bin converted to TreeBin, validate and relay to TreeBin methods + * 5. Lock and validate; if valid, scan and add or update + * + * The others interweave other checks and/or alternative actions: + * * Plain put checks for and performs resize after insertion. + * * putIfAbsent prescans for mapping without lock (and fails to add + * if present), which also makes pre-emptive resize checks worthwhile. + * * computeIfAbsent extends form used in putIfAbsent with additional + * mechanics to deal with, calls, potential exceptions and null + * returns from function call. + * * compute uses the same function-call mechanics, but without + * the prescans + * * merge acts as putIfAbsent in the absent case, but invokes the + * update function if present + * * putAll attempts to pre-allocate enough table space + * and more lazily performs count updates and checks. + * + * Someday when details settle down a bit more, it might be worth + * some factoring to reduce sprawl. + */ + + /** Implementation for put */ + private final Object internalPut(Object k, Object v) { + int h = spread(k.hashCode()); + int count = 0; + for (AtomicReferenceArray tab = table;;) { + int i; Node f; int fh; Object fk; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length() - 1) & h)) == null) { + if (casTabAt(tab, i, null, new Node(h, k, v, null))) + break; // no lock when adding to empty bin + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + Object oldVal = null; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 2; + TreeNode p = t.putTreeNode(h, k, v); + if (p != null) { + oldVal = p.val; + p.val = v; + } + } + } finally { + t.release(0); + } + if (count != 0) { + if (oldVal != null) + return oldVal; + break; + } + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + Object oldVal = null; + try { // needed in case equals() throws + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + oldVal = ev; + e.val = v; + break; + } + Node last = e; + if ((e = e.next) == null) { + last.next = new Node(h, k, v, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { // unlock and signal if needed + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (oldVal != null) + return oldVal; + if (tab.length() <= 64) + count = 2; + break; + } + } + } + counter.add(1L); + if (count > 1) + checkForResize(); + return null; + } + + /** Implementation for putIfAbsent */ + private final Object internalPutIfAbsent(Object k, Object v) { + int h = spread(k.hashCode()); + int count = 0; + for (AtomicReferenceArray tab = table;;) { + int i; Node f; int fh; Object fk, fv; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length() - 1) & h)) == null) { + if (casTabAt(tab, i, null, new Node(h, k, v, null))) + break; + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + Object oldVal = null; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 2; + TreeNode p = t.putTreeNode(h, k, v); + if (p != null) + oldVal = p.val; + } + } finally { + t.release(0); + } + if (count != 0) { + if (oldVal != null) + return oldVal; + break; + } + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & HASH_BITS) == h && (fv = f.val) != null && + ((fk = f.key) == k || k.equals(fk))) + return fv; + else { + Node g = f.next; + if (g != null) { // at least 2 nodes -- search and maybe resize + for (Node e = g;;) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) + return ev; + if ((e = e.next) == null) { + checkForResize(); + break; + } + } + } + if (((fh = f.hash) & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (tabAt(tab, i) == f && f.casHash(fh, fh | LOCKED)) { + Object oldVal = null; + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + oldVal = ev; + break; + } + Node last = e; + if ((e = e.next) == null) { + last.next = new Node(h, k, v, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (oldVal != null) + return oldVal; + if (tab.length() <= 64) + count = 2; + break; + } + } + } + } + counter.add(1L); + if (count > 1) + checkForResize(); + return null; + } + + /** Implementation for computeIfAbsent */ + private final Object internalComputeIfAbsent(K k, + Fun mf) { + int h = spread(k.hashCode()); + Object val = null; + int count = 0; + for (AtomicReferenceArray tab = table;;) { + Node f; int i, fh; Object fk, fv; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length() - 1) & h)) == null) { + Node node = new Node(fh = h | LOCKED, k, null, null); + if (casTabAt(tab, i, null, node)) { + count = 1; + try { + if ((val = mf.apply(k)) != null) + node.val = val; + } finally { + if (val == null) + setTabAt(tab, i, null); + if (!node.casHash(fh, h)) { + node.hash = h; + synchronized (node) { node.notifyAll(); }; + } + } + } + if (count != 0) + break; + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean added = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 1; + TreeNode p = t.getTreeNode(h, k, t.root); + if (p != null) + val = p.val; + else if ((val = mf.apply(k)) != null) { + added = true; + count = 2; + t.putTreeNode(h, k, val); + } + } + } finally { + t.release(0); + } + if (count != 0) { + if (!added) + return val; + break; + } + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & HASH_BITS) == h && (fv = f.val) != null && + ((fk = f.key) == k || k.equals(fk))) + return fv; + else { + Node g = f.next; + if (g != null) { + for (Node e = g;;) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) + return ev; + if ((e = e.next) == null) { + checkForResize(); + break; + } + } + } + if (((fh = f.hash) & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (tabAt(tab, i) == f && f.casHash(fh, fh | LOCKED)) { + boolean added = false; + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + val = ev; + break; + } + Node last = e; + if ((e = e.next) == null) { + if ((val = mf.apply(k)) != null) { + added = true; + last.next = new Node(h, k, val, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + } + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (!added) + return val; + if (tab.length() <= 64) + count = 2; + break; + } + } + } + } + if (val != null) { + counter.add(1L); + if (count > 1) + checkForResize(); + } + return val; + } + + /** Implementation for compute */ + @SuppressWarnings("unchecked") private final Object internalCompute + (K k, boolean onlyIfPresent, BiFun mf) { + int h = spread(k.hashCode()); + Object val = null; + int delta = 0; + int count = 0; + for (AtomicReferenceArray tab = table;;) { + Node f; int i, fh; Object fk; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length() - 1) & h)) == null) { + if (onlyIfPresent) + break; + Node node = new Node(fh = h | LOCKED, k, null, null); + if (casTabAt(tab, i, null, node)) { + try { + count = 1; + if ((val = mf.apply(k, null)) != null) { + node.val = val; + delta = 1; + } + } finally { + if (delta == 0) + setTabAt(tab, i, null); + if (!node.casHash(fh, h)) { + node.hash = h; + synchronized (node) { node.notifyAll(); }; + } + } + } + if (count != 0) + break; + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 1; + TreeNode p = t.getTreeNode(h, k, t.root); + Object pv; + if (p == null) { + if (onlyIfPresent) + break; + pv = null; + } else + pv = p.val; + if ((val = mf.apply(k, (V)pv)) != null) { + if (p != null) + p.val = val; + else { + count = 2; + delta = 1; + t.putTreeNode(h, k, val); + } + } + else if (p != null) { + delta = -1; + t.deleteTreeNode(p); + } + } + } finally { + t.release(0); + } + if (count != 0) + break; + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f, pred = null;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + val = mf.apply(k, (V)ev); + if (val != null) + e.val = val; + else { + delta = -1; + Node en = e.next; + if (pred != null) + pred.next = en; + else + setTabAt(tab, i, en); + } + break; + } + pred = e; + if ((e = e.next) == null) { + if (!onlyIfPresent && (val = mf.apply(k, null)) != null) { + pred.next = new Node(h, k, val, null); + delta = 1; + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + } + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (tab.length() <= 64) + count = 2; + break; + } + } + } + if (delta != 0) { + counter.add((long)delta); + if (count > 1) + checkForResize(); + } + return val; + } + + /** Implementation for merge */ + @SuppressWarnings("unchecked") private final Object internalMerge + (K k, V v, BiFun mf) { + int h = spread(k.hashCode()); + Object val = null; + int delta = 0; + int count = 0; + for (AtomicReferenceArray tab = table;;) { + int i; Node f; int fh; Object fk, fv; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length() - 1) & h)) == null) { + if (casTabAt(tab, i, null, new Node(h, k, v, null))) { + delta = 1; + val = v; + break; + } + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + count = 1; + TreeNode p = t.getTreeNode(h, k, t.root); + val = (p == null) ? v : mf.apply((V)p.val, v); + if (val != null) { + if (p != null) + p.val = val; + else { + count = 2; + delta = 1; + t.putTreeNode(h, k, val); + } + } + else if (p != null) { + delta = -1; + t.deleteTreeNode(p); + } + } + } finally { + t.release(0); + } + if (count != 0) + break; + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & LOCKED) != 0) { + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f, pred = null;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + val = mf.apply((V)ev, v); + if (val != null) + e.val = val; + else { + delta = -1; + Node en = e.next; + if (pred != null) + pred.next = en; + else + setTabAt(tab, i, en); + } + break; + } + pred = e; + if ((e = e.next) == null) { + val = v; + pred.next = new Node(h, k, val, null); + delta = 1; + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (tab.length() <= 64) + count = 2; + break; + } + } + } + if (delta != 0) { + counter.add((long)delta); + if (count > 1) + checkForResize(); + } + return val; + } + + /** Implementation for putAll */ + private final void internalPutAll(Map m) { + tryPresize(m.size()); + long delta = 0L; // number of uncommitted additions + boolean npe = false; // to throw exception on exit for nulls + try { // to clean up counts on other exceptions + for (Map.Entry entry : m.entrySet()) { + Object k, v; + if (entry == null || (k = entry.getKey()) == null || + (v = entry.getValue()) == null) { + npe = true; + break; + } + int h = spread(k.hashCode()); + for (AtomicReferenceArray tab = table;;) { + int i; Node f; int fh; Object fk; + if (tab == null) + tab = initTable(); + else if ((f = tabAt(tab, i = (tab.length() - 1) & h)) == null){ + if (casTabAt(tab, i, null, new Node(h, k, v, null))) { + ++delta; + break; + } + } + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean validated = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + validated = true; + TreeNode p = t.getTreeNode(h, k, t.root); + if (p != null) + p.val = v; + else { + t.putTreeNode(h, k, v); + ++delta; + } + } + } finally { + t.release(0); + } + if (validated) + break; + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & LOCKED) != 0) { + counter.add(delta); + delta = 0L; + checkForResize(); + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + int count = 0; + try { + if (tabAt(tab, i) == f) { + count = 1; + for (Node e = f;; ++count) { + Object ek, ev; + if ((e.hash & HASH_BITS) == h && + (ev = e.val) != null && + ((ek = e.key) == k || k.equals(ek))) { + e.val = v; + break; + } + Node last = e; + if ((e = e.next) == null) { + ++delta; + last.next = new Node(h, k, v, null); + if (count >= TREE_THRESHOLD) + replaceWithTreeBin(tab, i, k); + break; + } + } + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (count != 0) { + if (count > 1) { + counter.add(delta); + delta = 0L; + checkForResize(); + } + break; + } + } + } + } + } finally { + if (delta != 0) + counter.add(delta); + } + if (npe) + throw new NullPointerException(); + } + + /* ---------------- Table Initialization and Resizing -------------- */ + + /** + * Returns a power of two table size for the given desired capacity. + * See Hackers Delight, sec 3.2 + */ + private static final int tableSizeFor(int c) { + int n = c - 1; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1; + } + + /** + * Initializes table, using the size recorded in sizeCtl. + */ + private final AtomicReferenceArray initTable() { + AtomicReferenceArray tab; int sc; + while ((tab = table) == null) { + if ((sc = sizeCtl) < 0) + Thread.yield(); // lost initialization race; just spin + else if (SIZE_CTRL_UPDATER.compareAndSet(this, sc, -1)) { + try { + if ((tab = table) == null) { + int n = (sc > 0) ? sc : DEFAULT_CAPACITY; + tab = table = new AtomicReferenceArray(n); + sc = n - (n >>> 2); + } + } finally { + sizeCtl = sc; + } + break; + } + } + return tab; + } + + /** + * If table is too small and not already resizing, creates next + * table and transfers bins. Rechecks occupancy after a transfer + * to see if another resize is already needed because resizings + * are lagging additions. + */ + private final void checkForResize() { + AtomicReferenceArray tab; int n, sc; + while ((tab = table) != null && + (n = tab.length()) < MAXIMUM_CAPACITY && + (sc = sizeCtl) >= 0 && counter.sum() >= (long)sc && + SIZE_CTRL_UPDATER.compareAndSet(this, sc, -1)) { + try { + if (tab == table) { + table = rebuild(tab); + sc = (n << 1) - (n >>> 1); + } + } finally { + sizeCtl = sc; + } + } + } + + /** + * Tries to presize table to accommodate the given number of elements. + * + * @param size number of elements (doesn't need to be perfectly accurate) + */ + private final void tryPresize(int size) { + int c = (size >= (MAXIMUM_CAPACITY >>> 1)) ? MAXIMUM_CAPACITY : + tableSizeFor(size + (size >>> 1) + 1); + int sc; + while ((sc = sizeCtl) >= 0) { + AtomicReferenceArray tab = table; int n; + if (tab == null || (n = tab.length()) == 0) { + n = (sc > c) ? sc : c; + if (SIZE_CTRL_UPDATER.compareAndSet(this, sc, -1)) { + try { + if (table == tab) { + table = new AtomicReferenceArray(n); + sc = n - (n >>> 2); + } + } finally { + sizeCtl = sc; + } + } + } + else if (c <= sc || n >= MAXIMUM_CAPACITY) + break; + else if (SIZE_CTRL_UPDATER.compareAndSet(this, sc, -1)) { + try { + if (table == tab) { + table = rebuild(tab); + sc = (n << 1) - (n >>> 1); + } + } finally { + sizeCtl = sc; + } + } + } + } + + /* + * Moves and/or copies the nodes in each bin to new table. See + * above for explanation. + * + * @return the new table + */ + private static final AtomicReferenceArray rebuild(AtomicReferenceArray tab) { + int n = tab.length(); + AtomicReferenceArray nextTab = new AtomicReferenceArray(n << 1); + Node fwd = new Node(MOVED, nextTab, null, null); + int[] buffer = null; // holds bins to revisit; null until needed + Node rev = null; // reverse forwarder; null until needed + int nbuffered = 0; // the number of bins in buffer list + int bufferIndex = 0; // buffer index of current buffered bin + int bin = n - 1; // current non-buffered bin or -1 if none + + for (int i = bin;;) { // start upwards sweep + int fh; Node f; + if ((f = tabAt(tab, i)) == null) { + if (bin >= 0) { // Unbuffered; no lock needed (or available) + if (!casTabAt(tab, i, f, fwd)) + continue; + } + else { // transiently use a locked forwarding node + Node g = new Node(MOVED|LOCKED, nextTab, null, null); + if (!casTabAt(tab, i, f, g)) + continue; + setTabAt(nextTab, i, null); + setTabAt(nextTab, i + n, null); + setTabAt(tab, i, fwd); + if (!g.casHash(MOVED|LOCKED, MOVED)) { + g.hash = MOVED; + synchronized (g) { g.notifyAll(); } + } + } + } + else if ((fh = f.hash) == MOVED) { + Object fk = f.key; + if (fk instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + boolean validated = false; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + validated = true; + splitTreeBin(nextTab, i, t); + setTabAt(tab, i, fwd); + } + } finally { + t.release(0); + } + if (!validated) + continue; + } + } + else if ((fh & LOCKED) == 0 && f.casHash(fh, fh|LOCKED)) { + boolean validated = false; + try { // split to lo and hi lists; copying as needed + if (tabAt(tab, i) == f) { + validated = true; + splitBin(nextTab, i, f); + setTabAt(tab, i, fwd); + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + if (!validated) + continue; + } + else { + if (buffer == null) // initialize buffer for revisits + buffer = new int[TRANSFER_BUFFER_SIZE]; + if (bin < 0 && bufferIndex > 0) { + int j = buffer[--bufferIndex]; + buffer[bufferIndex] = i; + i = j; // swap with another bin + continue; + } + if (bin < 0 || nbuffered >= TRANSFER_BUFFER_SIZE) { + f.tryAwaitLock(tab, i); + continue; // no other options -- block + } + if (rev == null) // initialize reverse-forwarder + rev = new Node(MOVED, tab, null, null); + if (tabAt(tab, i) != f || (f.hash & LOCKED) == 0) + continue; // recheck before adding to list + buffer[nbuffered++] = i; + setTabAt(nextTab, i, rev); // install place-holders + setTabAt(nextTab, i + n, rev); + } + + if (bin > 0) + i = --bin; + else if (buffer != null && nbuffered > 0) { + bin = -1; + i = buffer[bufferIndex = --nbuffered]; + } + else + return nextTab; + } + } + + /** + * Splits a normal bin with list headed by e into lo and hi parts; + * installs in given table. + */ + private static void splitBin(AtomicReferenceArray nextTab, int i, Node e) { + int bit = nextTab.length() >>> 1; // bit to split on + int runBit = e.hash & bit; + Node lastRun = e, lo = null, hi = null; + for (Node p = e.next; p != null; p = p.next) { + int b = p.hash & bit; + if (b != runBit) { + runBit = b; + lastRun = p; + } + } + if (runBit == 0) + lo = lastRun; + else + hi = lastRun; + for (Node p = e; p != lastRun; p = p.next) { + int ph = p.hash & HASH_BITS; + Object pk = p.key, pv = p.val; + if ((ph & bit) == 0) + lo = new Node(ph, pk, pv, lo); + else + hi = new Node(ph, pk, pv, hi); + } + setTabAt(nextTab, i, lo); + setTabAt(nextTab, i + bit, hi); + } + + /** + * Splits a tree bin into lo and hi parts; installs in given table. + */ + private static void splitTreeBin(AtomicReferenceArray nextTab, int i, TreeBin t) { + int bit = nextTab.length() >>> 1; + TreeBin lt = new TreeBin(); + TreeBin ht = new TreeBin(); + int lc = 0, hc = 0; + for (Node e = t.first; e != null; e = e.next) { + int h = e.hash & HASH_BITS; + Object k = e.key, v = e.val; + if ((h & bit) == 0) { + ++lc; + lt.putTreeNode(h, k, v); + } + else { + ++hc; + ht.putTreeNode(h, k, v); + } + } + Node ln, hn; // throw away trees if too small + if (lc <= (TREE_THRESHOLD >>> 1)) { + ln = null; + for (Node p = lt.first; p != null; p = p.next) + ln = new Node(p.hash, p.key, p.val, ln); + } + else + ln = new Node(MOVED, lt, null, null); + setTabAt(nextTab, i, ln); + if (hc <= (TREE_THRESHOLD >>> 1)) { + hn = null; + for (Node p = ht.first; p != null; p = p.next) + hn = new Node(p.hash, p.key, p.val, hn); + } + else + hn = new Node(MOVED, ht, null, null); + setTabAt(nextTab, i + bit, hn); + } + + /** + * Implementation for clear. Steps through each bin, removing all + * nodes. + */ + private final void internalClear() { + long delta = 0L; // negative number of deletions + int i = 0; + AtomicReferenceArray tab = table; + while (tab != null && i < tab.length()) { + int fh; Object fk; + Node f = tabAt(tab, i); + if (f == null) + ++i; + else if ((fh = f.hash) == MOVED) { + if ((fk = f.key) instanceof TreeBin) { + TreeBin t = (TreeBin)fk; + t.acquire(0); + try { + if (tabAt(tab, i) == f) { + for (Node p = t.first; p != null; p = p.next) { + if (p.val != null) { // (currently always true) + p.val = null; + --delta; + } + } + t.first = null; + t.root = null; + ++i; + } + } finally { + t.release(0); + } + } + else + tab = (AtomicReferenceArray)fk; + } + else if ((fh & LOCKED) != 0) { + counter.add(delta); // opportunistically update count + delta = 0L; + f.tryAwaitLock(tab, i); + } + else if (f.casHash(fh, fh | LOCKED)) { + try { + if (tabAt(tab, i) == f) { + for (Node e = f; e != null; e = e.next) { + if (e.val != null) { // (currently always true) + e.val = null; + --delta; + } + } + setTabAt(tab, i, null); + ++i; + } + } finally { + if (!f.casHash(fh | LOCKED, fh)) { + f.hash = fh; + synchronized (f) { f.notifyAll(); }; + } + } + } + } + if (delta != 0) + counter.add(delta); + } + + /* ----------------Table Traversal -------------- */ + + /** + * Encapsulates traversal for methods such as containsValue; also + * serves as a base class for other iterators and bulk tasks. + * + * At each step, the iterator snapshots the key ("nextKey") and + * value ("nextVal") of a valid node (i.e., one that, at point of + * snapshot, has a non-null user value). Because val fields can + * change (including to null, indicating deletion), field nextVal + * might not be accurate at point of use, but still maintains the + * weak consistency property of holding a value that was once + * valid. To support iterator.remove, the nextKey field is not + * updated (nulled out) when the iterator cannot advance. + * + * Internal traversals directly access these fields, as in: + * {@code while (it.advance() != null) { process(it.nextKey); }} + * + * Exported iterators must track whether the iterator has advanced + * (in hasNext vs next) (by setting/checking/nulling field + * nextVal), and then extract key, value, or key-value pairs as + * return values of next(). + * + * The iterator visits once each still-valid node that was + * reachable upon iterator construction. It might miss some that + * were added to a bin after the bin was visited, which is OK wrt + * consistency guarantees. Maintaining this property in the face + * of possible ongoing resizes requires a fair amount of + * bookkeeping state that is difficult to optimize away amidst + * volatile accesses. Even so, traversal maintains reasonable + * throughput. + * + * Normally, iteration proceeds bin-by-bin traversing lists. + * However, if the table has been resized, then all future steps + * must traverse both the bin at the current index as well as at + * (index + baseSize); and so on for further resizings. To + * paranoically cope with potential sharing by users of iterators + * across threads, iteration terminates if a bounds checks fails + * for a table read. + * + * This class extends ForkJoinTask to streamline parallel + * iteration in bulk operations (see BulkTask). This adds only an + * int of space overhead, which is close enough to negligible in + * cases where it is not needed to not worry about it. Because + * ForkJoinTask is Serializable, but iterators need not be, we + * need to add warning suppressions. + */ + @SuppressWarnings("serial") static class Traverser { + final ConcurrentHashMapV8 map; + Node next; // the next entry to use + K nextKey; // cached key field of next + V nextVal; // cached val field of next + AtomicReferenceArray tab; // current table; updated if resized + int index; // index of bin to use next + int baseIndex; // current index of initial table + int baseLimit; // index bound for initial table + int baseSize; // initial table size + + /** Creates iterator for all entries in the table. */ + Traverser(ConcurrentHashMapV8 map) { + this.map = map; + } + + /** Creates iterator for split() methods */ + Traverser(Traverser it) { + ConcurrentHashMapV8 m; AtomicReferenceArray t; + if ((m = this.map = it.map) == null) + t = null; + else if ((t = it.tab) == null && // force parent tab initialization + (t = it.tab = m.table) != null) + it.baseLimit = it.baseSize = t.length(); + this.tab = t; + this.baseSize = it.baseSize; + it.baseLimit = this.index = this.baseIndex = + ((this.baseLimit = it.baseLimit) + it.baseIndex + 1) >>> 1; + } + + /** + * Advances next; returns nextVal or null if terminated. + * See above for explanation. + */ + final V advance() { + Node e = next; + V ev = null; + outer: do { + if (e != null) // advance past used/skipped node + e = e.next; + while (e == null) { // get to next non-null bin + ConcurrentHashMapV8 m; + AtomicReferenceArray t; int b, i, n; Object ek; // checks must use locals + if ((t = tab) != null) + n = t.length(); + else if ((m = map) != null && (t = tab = m.table) != null) + n = baseLimit = baseSize = t.length(); + else + break outer; + if ((b = baseIndex) >= baseLimit || + (i = index) < 0 || i >= n) + break outer; + if ((e = tabAt(t, i)) != null && e.hash == MOVED) { + if ((ek = e.key) instanceof TreeBin) + e = ((TreeBin)ek).first; + else { + tab = (AtomicReferenceArray)ek; + continue; // restarts due to null val + } + } // visit upper slots if present + index = (i += baseSize) < n ? i : (baseIndex = b + 1); + } + nextKey = (K) e.key; + } while ((ev = (V) e.val) == null); // skip deleted or special nodes + next = e; + return nextVal = ev; + } + + public final void remove() { + Object k = nextKey; + if (k == null && (advance() == null || (k = nextKey) == null)) + throw new IllegalStateException(); + map.internalReplace(k, null, null); + } + + public final boolean hasNext() { + return nextVal != null || advance() != null; + } + + public final boolean hasMoreElements() { return hasNext(); } + public final void setRawResult(Object x) { } + public R getRawResult() { return null; } + public boolean exec() { return true; } + } + + /* ---------------- Public operations -------------- */ + + /** + * Creates a new, empty map with the default initial table size (16). + */ + public ConcurrentHashMapV8() { + this.counter = new LongAdder(); + } + + /** + * Creates a new, empty map with an initial table size + * accommodating the specified number of elements without the need + * to dynamically resize. + * + * @param initialCapacity The implementation performs internal + * sizing to accommodate this many elements. + * @throws IllegalArgumentException if the initial capacity of + * elements is negative + */ + public ConcurrentHashMapV8(int initialCapacity) { + if (initialCapacity < 0) + throw new IllegalArgumentException(); + int cap = ((initialCapacity >= (MAXIMUM_CAPACITY >>> 1)) ? + MAXIMUM_CAPACITY : + tableSizeFor(initialCapacity + (initialCapacity >>> 1) + 1)); + this.counter = new LongAdder(); + this.sizeCtl = cap; + } + + /** + * Creates a new map with the same mappings as the given map. + * + * @param m the map + */ + public ConcurrentHashMapV8(Map m) { + this.counter = new LongAdder(); + this.sizeCtl = DEFAULT_CAPACITY; + internalPutAll(m); + } + + /** + * Creates a new, empty map with an initial table size based on + * the given number of elements ({@code initialCapacity}) and + * initial table density ({@code loadFactor}). + * + * @param initialCapacity the initial capacity. The implementation + * performs internal sizing to accommodate this many elements, + * given the specified load factor. + * @param loadFactor the load factor (table density) for + * establishing the initial table size + * @throws IllegalArgumentException if the initial capacity of + * elements is negative or the load factor is nonpositive + * + * @since 1.6 + */ + public ConcurrentHashMapV8(int initialCapacity, float loadFactor) { + this(initialCapacity, loadFactor, 1); + } + + /** + * Creates a new, empty map with an initial table size based on + * the given number of elements ({@code initialCapacity}), table + * density ({@code loadFactor}), and number of concurrently + * updating threads ({@code concurrencyLevel}). + * + * @param initialCapacity the initial capacity. The implementation + * performs internal sizing to accommodate this many elements, + * given the specified load factor. + * @param loadFactor the load factor (table density) for + * establishing the initial table size + * @param concurrencyLevel the estimated number of concurrently + * updating threads. The implementation may use this value as + * a sizing hint. + * @throws IllegalArgumentException if the initial capacity is + * negative or the load factor or concurrencyLevel are + * nonpositive + */ + public ConcurrentHashMapV8(int initialCapacity, + float loadFactor, int concurrencyLevel) { + if (!(loadFactor > 0.0f) || initialCapacity < 0 || concurrencyLevel <= 0) + throw new IllegalArgumentException(); + if (initialCapacity < concurrencyLevel) // Use at least as many bins + initialCapacity = concurrencyLevel; // as estimated threads + long size = (long)(1.0 + (long)initialCapacity / loadFactor); + int cap = (size >= (long)MAXIMUM_CAPACITY) ? + MAXIMUM_CAPACITY : tableSizeFor((int)size); + this.counter = new LongAdder(); + this.sizeCtl = cap; + } + + /** + * Creates a new {@link Set} backed by a ConcurrentHashMapV8 + * from the given type to {@code Boolean.TRUE}. + * + * @return the new set + */ + public static KeySetView newKeySet() { + return new KeySetView(new ConcurrentHashMapV8(), + Boolean.TRUE); + } + + /** + * Creates a new {@link Set} backed by a ConcurrentHashMapV8 + * from the given type to {@code Boolean.TRUE}. + * + * @param initialCapacity The implementation performs internal + * sizing to accommodate this many elements. + * @throws IllegalArgumentException if the initial capacity of + * elements is negative + * @return the new set + */ + public static KeySetView newKeySet(int initialCapacity) { + return new KeySetView(new ConcurrentHashMapV8(initialCapacity), + Boolean.TRUE); + } + + /** + * {@inheritDoc} + */ + public boolean isEmpty() { + return counter.sum() <= 0L; // ignore transient negative values + } + + /** + * {@inheritDoc} + */ + public int size() { + long n = counter.sum(); + return ((n < 0L) ? 0 : + (n > (long)Integer.MAX_VALUE) ? Integer.MAX_VALUE : + (int)n); + } + + /** + * Returns the number of mappings. This method should be used + * instead of {@link #size} because a ConcurrentHashMapV8 may + * contain more mappings than can be represented as an int. The + * value returned is a snapshot; the actual count may differ if + * there are ongoing concurrent insertions or removals. + * + * @return the number of mappings + */ + public long mappingCount() { + long n = counter.sum(); + return (n < 0L) ? 0L : n; // ignore transient negative values + } + + /** + * Returns the value to which the specified key is mapped, + * or {@code null} if this map contains no mapping for the key. + * + *

More formally, if this map contains a mapping from a key + * {@code k} to a value {@code v} such that {@code key.equals(k)}, + * then this method returns {@code v}; otherwise it returns + * {@code null}. (There can be at most one such mapping.) + * + * @throws NullPointerException if the specified key is null + */ + @SuppressWarnings("unchecked") public V get(Object key) { + if (key == null) + throw new NullPointerException(); + return (V)internalGet(key); + } + + /** + * Returns the value to which the specified key is mapped, + * or the given defaultValue if this map contains no mapping for the key. + * + * @param key the key + * @param defaultValue the value to return if this map contains + * no mapping for the given key + * @return the mapping for the key, if present; else the defaultValue + * @throws NullPointerException if the specified key is null + */ + @SuppressWarnings("unchecked") public V getValueOrDefault(Object key, V defaultValue) { + if (key == null) + throw new NullPointerException(); + V v = (V) internalGet(key); + return v == null ? defaultValue : v; + } + + /** + * Tests if the specified object is a key in this table. + * + * @param key possible key + * @return {@code true} if and only if the specified object + * is a key in this table, as determined by the + * {@code equals} method; {@code false} otherwise + * @throws NullPointerException if the specified key is null + */ + public boolean containsKey(Object key) { + if (key == null) + throw new NullPointerException(); + return internalGet(key) != null; + } + + /** + * Returns {@code true} if this map maps one or more keys to the + * specified value. Note: This method may require a full traversal + * of the map, and is much slower than method {@code containsKey}. + * + * @param value value whose presence in this map is to be tested + * @return {@code true} if this map maps one or more keys to the + * specified value + * @throws NullPointerException if the specified value is null + */ + public boolean containsValue(Object value) { + if (value == null) + throw new NullPointerException(); + Object v; + Traverser it = new Traverser(this); + while ((v = it.advance()) != null) { + if (v == value || value.equals(v)) + return true; + } + return false; + } + + public K findKey(Object value) { + if (value == null) + throw new NullPointerException(); + Object v; + Traverser it = new Traverser(this); + while ((v = it.advance()) != null) { + if (v == value || value.equals(v)) + return it.nextKey; + } + return null; + } + + /** + * Legacy method testing if some key maps into the specified value + * in this table. This method is identical in functionality to + * {@link #containsValue}, and exists solely to ensure + * full compatibility with class {@link java.util.Hashtable}, + * which supported this method prior to introduction of the + * Java Collections framework. + * + * @param value a value to search for + * @return {@code true} if and only if some key maps to the + * {@code value} argument in this table as + * determined by the {@code equals} method; + * {@code false} otherwise + * @throws NullPointerException if the specified value is null + */ + public boolean contains(Object value) { + return containsValue(value); + } + + /** + * Maps the specified key to the specified value in this table. + * Neither the key nor the value can be null. + * + *

The value can be retrieved by calling the {@code get} method + * with a key that is equal to the original key. + * + * @param key key with which the specified value is to be associated + * @param value value to be associated with the specified key + * @return the previous value associated with {@code key}, or + * {@code null} if there was no mapping for {@code key} + * @throws NullPointerException if the specified key or value is null + */ + @SuppressWarnings("unchecked") public V put(K key, V value) { + if (key == null || value == null) + throw new NullPointerException(); + return (V)internalPut(key, value); + } + + /** + * {@inheritDoc} + * + * @return the previous value associated with the specified key, + * or {@code null} if there was no mapping for the key + * @throws NullPointerException if the specified key or value is null + */ + @SuppressWarnings("unchecked") public V putIfAbsent(K key, V value) { + if (key == null || value == null) + throw new NullPointerException(); + return (V)internalPutIfAbsent(key, value); + } + + /** + * Copies all of the mappings from the specified map to this one. + * These mappings replace any mappings that this map had for any of the + * keys currently in the specified map. + * + * @param m mappings to be stored in this map + */ + public void putAll(Map m) { + internalPutAll(m); + } + + /** + * If the specified key is not already associated with a value, + * computes its value using the given mappingFunction and enters + * it into the map unless null. This is equivalent to + *

 {@code
+     * if (map.containsKey(key))
+     *   return map.get(key);
+     * value = mappingFunction.apply(key);
+     * if (value != null)
+     *   map.put(key, value);
+     * return value;}
+ * + * except that the action is performed atomically. If the + * function returns {@code null} no mapping is recorded. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and no mapping is recorded. Some + * attempted update operations on this map by other threads may be + * blocked while computation is in progress, so the computation + * should be short and simple, and must not attempt to update any + * other mappings of this Map. The most appropriate usage is to + * construct a new object serving as an initial mapped value, or + * memoized result, as in: + * + *
 {@code
+     * map.computeIfAbsent(key, new Fun() {
+     *   public V map(K k) { return new Value(f(k)); }});}
+ * + * @param key key with which the specified value is to be associated + * @param mappingFunction the function to compute a value + * @return the current (existing or computed) value associated with + * the specified key, or null if the computed value is null + * @throws NullPointerException if the specified key or mappingFunction + * is null + * @throws IllegalStateException if the computation detectably + * attempts a recursive update to this map that would + * otherwise never complete + * @throws RuntimeException or Error if the mappingFunction does so, + * in which case the mapping is left unestablished + */ + @SuppressWarnings("unchecked") public V computeIfAbsent + (K key, Fun mappingFunction) { + if (key == null || mappingFunction == null) + throw new NullPointerException(); + return (V)internalComputeIfAbsent(key, mappingFunction); + } + + /** + * If the given key is present, computes a new mapping value given a key and + * its current mapped value. This is equivalent to + *
 {@code
+     *   if (map.containsKey(key)) {
+     *     value = remappingFunction.apply(key, map.get(key));
+     *     if (value != null)
+     *       map.put(key, value);
+     *     else
+     *       map.remove(key);
+     *   }
+     * }
+ * + * except that the action is performed atomically. If the + * function returns {@code null}, the mapping is removed. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and the current mapping is left + * unchanged. Some attempted update operations on this map by + * other threads may be blocked while computation is in progress, + * so the computation should be short and simple, and must not + * attempt to update any other mappings of this Map. For example, + * to either create or append new messages to a value mapping: + * + * @param key key with which the specified value is to be associated + * @param remappingFunction the function to compute a value + * @return the new value associated with the specified key, or null if none + * @throws NullPointerException if the specified key or remappingFunction + * is null + * @throws IllegalStateException if the computation detectably + * attempts a recursive update to this map that would + * otherwise never complete + * @throws RuntimeException or Error if the remappingFunction does so, + * in which case the mapping is unchanged + */ + @SuppressWarnings("unchecked") public V computeIfPresent + (K key, BiFun remappingFunction) { + if (key == null || remappingFunction == null) + throw new NullPointerException(); + return (V)internalCompute(key, true, remappingFunction); + } + + /** + * Computes a new mapping value given a key and + * its current mapped value (or {@code null} if there is no current + * mapping). This is equivalent to + *
 {@code
+     *   value = remappingFunction.apply(key, map.get(key));
+     *   if (value != null)
+     *     map.put(key, value);
+     *   else
+     *     map.remove(key);
+     * }
+ * + * except that the action is performed atomically. If the + * function returns {@code null}, the mapping is removed. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and the current mapping is left + * unchanged. Some attempted update operations on this map by + * other threads may be blocked while computation is in progress, + * so the computation should be short and simple, and must not + * attempt to update any other mappings of this Map. For example, + * to either create or append new messages to a value mapping: + * + *
 {@code
+     * Map map = ...;
+     * final String msg = ...;
+     * map.compute(key, new BiFun() {
+     *   public String apply(Key k, String v) {
+     *    return (v == null) ? msg : v + msg;});}}
+ * + * @param key key with which the specified value is to be associated + * @param remappingFunction the function to compute a value + * @return the new value associated with the specified key, or null if none + * @throws NullPointerException if the specified key or remappingFunction + * is null + * @throws IllegalStateException if the computation detectably + * attempts a recursive update to this map that would + * otherwise never complete + * @throws RuntimeException or Error if the remappingFunction does so, + * in which case the mapping is unchanged + */ + @SuppressWarnings("unchecked") public V compute + (K key, BiFun remappingFunction) { + if (key == null || remappingFunction == null) + throw new NullPointerException(); + return (V)internalCompute(key, false, remappingFunction); + } + + /** + * If the specified key is not already associated + * with a value, associate it with the given value. + * Otherwise, replace the value with the results of + * the given remapping function. This is equivalent to: + *
 {@code
+     *   if (!map.containsKey(key))
+     *     map.put(value);
+     *   else {
+     *     newValue = remappingFunction.apply(map.get(key), value);
+     *     if (value != null)
+     *       map.put(key, value);
+     *     else
+     *       map.remove(key);
+     *   }
+     * }
+ * except that the action is performed atomically. If the + * function returns {@code null}, the mapping is removed. If the + * function itself throws an (unchecked) exception, the exception + * is rethrown to its caller, and the current mapping is left + * unchanged. Some attempted update operations on this map by + * other threads may be blocked while computation is in progress, + * so the computation should be short and simple, and must not + * attempt to update any other mappings of this Map. + */ + @SuppressWarnings("unchecked") public V merge + (K key, V value, BiFun remappingFunction) { + if (key == null || value == null || remappingFunction == null) + throw new NullPointerException(); + return (V)internalMerge(key, value, remappingFunction); + } + + /** + * Removes the key (and its corresponding value) from this map. + * This method does nothing if the key is not in the map. + * + * @param key the key that needs to be removed + * @return the previous value associated with {@code key}, or + * {@code null} if there was no mapping for {@code key} + * @throws NullPointerException if the specified key is null + */ + @SuppressWarnings("unchecked") public V remove(Object key) { + if (key == null) + throw new NullPointerException(); + return (V)internalReplace(key, null, null); + } + + /** + * {@inheritDoc} + * + * @throws NullPointerException if the specified key is null + */ + public boolean remove(Object key, Object value) { + if (key == null) + throw new NullPointerException(); + if (value == null) + return false; + return internalReplace(key, null, value) != null; + } + + /** + * {@inheritDoc} + * + * @throws NullPointerException if any of the arguments are null + */ + public boolean replace(K key, V oldValue, V newValue) { + if (key == null || oldValue == null || newValue == null) + throw new NullPointerException(); + return internalReplace(key, newValue, oldValue) != null; + } + + /** + * {@inheritDoc} + * + * @return the previous value associated with the specified key, + * or {@code null} if there was no mapping for the key + * @throws NullPointerException if the specified key or value is null + */ + @SuppressWarnings("unchecked") public V replace(K key, V value) { + if (key == null || value == null) + throw new NullPointerException(); + return (V)internalReplace(key, value, null); + } + + /** + * Removes all of the mappings from this map. + */ + public void clear() { + internalClear(); + } + + /** + * Returns a {@link Set} view of the keys contained in this map. + * The set is backed by the map, so changes to the map are + * reflected in the set, and vice-versa. + * + * @return the set view + */ + public KeySetView keySet() { + KeySetView ks = keySet; + return (ks != null) ? ks : (keySet = new KeySetView(this, null)); + } + + /** + * Returns a {@link Set} view of the keys in this map, using the + * given common mapped value for any additions (i.e., {@link + * Collection#add} and {@link Collection#addAll}). This is of + * course only appropriate if it is acceptable to use the same + * value for all additions from this view. + * + * @param mappedValue the mapped value to use for any + * additions. + * @return the set view + * @throws NullPointerException if the mappedValue is null + */ + public KeySetView keySet(V mappedValue) { + if (mappedValue == null) + throw new NullPointerException(); + return new KeySetView(this, mappedValue); + } + + /** + * Returns a {@link Collection} view of the values contained in this map. + * The collection is backed by the map, so changes to the map are + * reflected in the collection, and vice-versa. + */ + public ValuesView values() { + ValuesView vs = values; + return (vs != null) ? vs : (values = new ValuesView(this)); + } + + /** + * Returns a {@link Set} view of the mappings contained in this map. + * The set is backed by the map, so changes to the map are + * reflected in the set, and vice-versa. The set supports element + * removal, which removes the corresponding mapping from the map, + * via the {@code Iterator.remove}, {@code Set.remove}, + * {@code removeAll}, {@code retainAll}, and {@code clear} + * operations. It does not support the {@code add} or + * {@code addAll} operations. + * + *

The view's {@code iterator} is a "weakly consistent" iterator + * that will never throw {@link ConcurrentModificationException}, + * and guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not guaranteed to) + * reflect any modifications subsequent to construction. + */ + public Set> entrySet() { + EntrySetView es = entrySet; + return (es != null) ? es : (entrySet = new EntrySetView(this)); + } + + /** + * Returns an enumeration of the keys in this table. + * + * @return an enumeration of the keys in this table + * @see #keySet() + */ + public Enumeration keys() { + return new KeyIterator(this); + } + + /** + * Returns an enumeration of the values in this table. + * + * @return an enumeration of the values in this table + * @see #values() + */ + public Enumeration elements() { + return new ValueIterator(this); + } + + /** + * Returns a partitionable iterator of the keys in this map. + * + * @return a partitionable iterator of the keys in this map + */ + public Spliterator keySpliterator() { + return new KeyIterator(this); + } + + /** + * Returns a partitionable iterator of the values in this map. + * + * @return a partitionable iterator of the values in this map + */ + public Spliterator valueSpliterator() { + return new ValueIterator(this); + } + + /** + * Returns a partitionable iterator of the entries in this map. + * + * @return a partitionable iterator of the entries in this map + */ + public Spliterator> entrySpliterator() { + return new EntryIterator(this); + } + + /** + * Returns the hash code value for this {@link Map}, i.e., + * the sum of, for each key-value pair in the map, + * {@code key.hashCode() ^ value.hashCode()}. + * + * @return the hash code value for this map + */ + public int hashCode() { + int h = 0; + Traverser it = new Traverser(this); + Object v; + while ((v = it.advance()) != null) { + h += it.nextKey.hashCode() ^ v.hashCode(); + } + return h; + } + + /** + * Returns a string representation of this map. The string + * representation consists of a list of key-value mappings (in no + * particular order) enclosed in braces ("{@code {}}"). Adjacent + * mappings are separated by the characters {@code ", "} (comma + * and space). Each key-value mapping is rendered as the key + * followed by an equals sign ("{@code =}") followed by the + * associated value. + * + * @return a string representation of this map + */ + public String toString() { + Traverser it = new Traverser(this); + StringBuilder sb = new StringBuilder(); + sb.append('{'); + Object v; + if ((v = it.advance()) != null) { + for (;;) { + Object k = it.nextKey; + sb.append(k == this ? "(this Map)" : k); + sb.append('='); + sb.append(v == this ? "(this Map)" : v); + if ((v = it.advance()) == null) + break; + sb.append(',').append(' '); + } + } + return sb.append('}').toString(); + } + + /** + * Compares the specified object with this map for equality. + * Returns {@code true} if the given object is a map with the same + * mappings as this map. This operation may return misleading + * results if either map is concurrently modified during execution + * of this method. + * + * @param o object to be compared for equality with this map + * @return {@code true} if the specified object is equal to this map + */ + public boolean equals(Object o) { + if (o != this) { + if (!(o instanceof Map)) + return false; + Map m = (Map) o; + Traverser it = new Traverser(this); + Object val; + while ((val = it.advance()) != null) { + Object v = m.get(it.nextKey); + if (v == null || (v != val && !v.equals(val))) + return false; + } + for (Map.Entry e : m.entrySet()) { + Object mk, mv, v; + if ((mk = e.getKey()) == null || + (mv = e.getValue()) == null || + (v = internalGet(mk)) == null || + (mv != v && !mv.equals(v))) + return false; + } + } + return true; + } + + /* ----------------Iterators -------------- */ + + @SuppressWarnings("serial") static final class KeyIterator extends Traverser + implements Spliterator, Enumeration { + KeyIterator(ConcurrentHashMapV8 map) { super(map); } + KeyIterator(Traverser it) { + super(it); + } + public KeyIterator split() { + if (nextKey != null) + throw new IllegalStateException(); + return new KeyIterator(this); + } + @SuppressWarnings("unchecked") public final K next() { + if (nextVal == null && advance() == null) + throw new NoSuchElementException(); + Object k = nextKey; + nextVal = null; + return (K) k; + } + + public final K nextElement() { return next(); } + } + + @SuppressWarnings("serial") static final class ValueIterator extends Traverser + implements Spliterator, Enumeration { + ValueIterator(ConcurrentHashMapV8 map) { super(map); } + ValueIterator(Traverser it) { + super(it); + } + public ValueIterator split() { + if (nextKey != null) + throw new IllegalStateException(); + return new ValueIterator(this); + } + + @SuppressWarnings("unchecked") public final V next() { + Object v; + if ((v = nextVal) == null && (v = advance()) == null) + throw new NoSuchElementException(); + nextVal = null; + return (V) v; + } + + public final V nextElement() { return next(); } + } + + @SuppressWarnings("serial") static final class EntryIterator extends Traverser + implements Spliterator> { + EntryIterator(ConcurrentHashMapV8 map) { super(map); } + EntryIterator(Traverser it) { + super(it); + } + public EntryIterator split() { + if (nextKey != null) + throw new IllegalStateException(); + return new EntryIterator(this); + } + + @SuppressWarnings("unchecked") public final Map.Entry next() { + Object v; + if ((v = nextVal) == null && (v = advance()) == null) + throw new NoSuchElementException(); + Object k = nextKey; + nextVal = null; + return new MapEntry((K)k, (V)v, map); + } + } + + /** + * Exported Entry for iterators + */ + static final class MapEntry implements Map.Entry { + final K key; // non-null + V val; // non-null + final ConcurrentHashMapV8 map; + MapEntry(K key, V val, ConcurrentHashMapV8 map) { + this.key = key; + this.val = val; + this.map = map; + } + public final K getKey() { return key; } + public final V getValue() { return val; } + public final int hashCode() { return key.hashCode() ^ val.hashCode(); } + public final String toString(){ return key + "=" + val; } + + public final boolean equals(Object o) { + Object k, v; Map.Entry e; + return ((o instanceof Map.Entry) && + (k = (e = (Map.Entry)o).getKey()) != null && + (v = e.getValue()) != null && + (k == key || k.equals(key)) && + (v == val || v.equals(val))); + } + + /** + * Sets our entry's value and writes through to the map. The + * value to return is somewhat arbitrary here. Since we do not + * necessarily track asynchronous changes, the most recent + * "previous" value could be different from what we return (or + * could even have been removed in which case the put will + * re-establish). We do not and cannot guarantee more. + */ + public final V setValue(V value) { + if (value == null) throw new NullPointerException(); + V v = val; + val = value; + map.put(key, value); + return v; + } + } + + /* ---------------- Serialization Support -------------- */ + + /** + * Stripped-down version of helper class used in previous version, + * declared for the sake of serialization compatibility + */ + static class Segment implements Serializable { + private static final long serialVersionUID = 2249069246763182397L; + final float loadFactor; + Segment(float lf) { this.loadFactor = lf; } + } + + /** + * Saves the state of the {@code ConcurrentHashMapV8} instance to a + * stream (i.e., serializes it). + * @param s the stream + * @serialData + * the key (Object) and value (Object) + * for each key-value mapping, followed by a null pair. + * The key-value mappings are emitted in no particular order. + */ + @SuppressWarnings("unchecked") private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + if (segments == null) { // for serialization compatibility + segments = (Segment[]) + new Segment[DEFAULT_CONCURRENCY_LEVEL]; + for (int i = 0; i < segments.length; ++i) + segments[i] = new Segment(LOAD_FACTOR); + } + s.defaultWriteObject(); + Traverser it = new Traverser(this); + Object v; + while ((v = it.advance()) != null) { + s.writeObject(it.nextKey); + s.writeObject(v); + } + s.writeObject(null); + s.writeObject(null); + segments = null; // throw away + } + + /** + * Reconstitutes the instance from a stream (that is, deserializes it). + * @param s the stream + */ + @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + s.defaultReadObject(); + this.segments = null; // unneeded + // initialize transient final field + this.counter = new LongAdder(); + + // Create all nodes, then place in table once size is known + long size = 0L; + Node p = null; + for (;;) { + K k = (K) s.readObject(); + V v = (V) s.readObject(); + if (k != null && v != null) { + int h = spread(k.hashCode()); + p = new Node(h, k, v, p); + ++size; + } + else + break; + } + if (p != null) { + boolean init = false; + int n; + if (size >= (long)(MAXIMUM_CAPACITY >>> 1)) + n = MAXIMUM_CAPACITY; + else { + int sz = (int)size; + n = tableSizeFor(sz + (sz >>> 1) + 1); + } + int sc = sizeCtl; + boolean collide = false; + if (n > sc && + SIZE_CTRL_UPDATER.compareAndSet(this, sc, -1)) { + try { + if (table == null) { + init = true; + AtomicReferenceArray tab = new AtomicReferenceArray(n); + int mask = n - 1; + while (p != null) { + int j = p.hash & mask; + Node next = p.next; + Node q = p.next = tabAt(tab, j); + setTabAt(tab, j, p); + if (!collide && q != null && q.hash == p.hash) + collide = true; + p = next; + } + table = tab; + counter.add(size); + sc = n - (n >>> 2); + } + } finally { + sizeCtl = sc; + } + if (collide) { // rescan and convert to TreeBins + AtomicReferenceArray tab = table; + for (int i = 0; i < tab.length(); ++i) { + int c = 0; + for (Node e = tabAt(tab, i); e != null; e = e.next) { + if (++c > TREE_THRESHOLD && + (e.key instanceof Comparable)) { + replaceWithTreeBin(tab, i, e.key); + break; + } + } + } + } + } + if (!init) { // Can only happen if unsafely published. + while (p != null) { + internalPut(p.key, p.val); + p = p.next; + } + } + } + } + + + // ------------------------------------------------------- + + // Sams + /** Interface describing a void action of one argument */ + public interface Action { void apply(A a); } + /** Interface describing a void action of two arguments */ + public interface BiAction { void apply(A a, B b); } + /** Interface describing a function of one argument */ + public interface Generator { T apply(); } + /** Interface describing a function mapping its argument to a double */ + public interface ObjectToDouble { double apply(A a); } + /** Interface describing a function mapping its argument to a long */ + public interface ObjectToLong { long apply(A a); } + /** Interface describing a function mapping its argument to an int */ + public interface ObjectToInt {int apply(A a); } + /** Interface describing a function mapping two arguments to a double */ + public interface ObjectByObjectToDouble { double apply(A a, B b); } + /** Interface describing a function mapping two arguments to a long */ + public interface ObjectByObjectToLong { long apply(A a, B b); } + /** Interface describing a function mapping two arguments to an int */ + public interface ObjectByObjectToInt {int apply(A a, B b); } + /** Interface describing a function mapping a double to a double */ + public interface DoubleToDouble { double apply(double a); } + /** Interface describing a function mapping a long to a long */ + public interface LongToLong { long apply(long a); } + /** Interface describing a function mapping an int to an int */ + public interface IntToInt { int apply(int a); } + /** Interface describing a function mapping two doubles to a double */ + public interface DoubleByDoubleToDouble { double apply(double a, double b); } + /** Interface describing a function mapping two longs to a long */ + public interface LongByLongToLong { long apply(long a, long b); } + /** Interface describing a function mapping two ints to an int */ + public interface IntByIntToInt { int apply(int a, int b); } + + + /* ----------------Views -------------- */ + + /** + * Base class for views. + */ + static abstract class CHMView { + final ConcurrentHashMapV8 map; + CHMView(ConcurrentHashMapV8 map) { this.map = map; } + + /** + * Returns the map backing this view. + * + * @return the map backing this view + */ + public ConcurrentHashMapV8 getMap() { return map; } + + public final int size() { return map.size(); } + public final boolean isEmpty() { return map.isEmpty(); } + public final void clear() { map.clear(); } + + // implementations below rely on concrete classes supplying these + abstract public Iterator iterator(); + abstract public boolean contains(Object o); + abstract public boolean remove(Object o); + + private static final String oomeMsg = "Required array size too large"; + + public final Object[] toArray() { + long sz = map.mappingCount(); + if (sz > (long)(MAX_ARRAY_SIZE)) + throw new OutOfMemoryError(oomeMsg); + int n = (int)sz; + Object[] r = new Object[n]; + int i = 0; + Iterator it = iterator(); + while (it.hasNext()) { + if (i == n) { + if (n >= MAX_ARRAY_SIZE) + throw new OutOfMemoryError(oomeMsg); + if (n >= MAX_ARRAY_SIZE - (MAX_ARRAY_SIZE >>> 1) - 1) + n = MAX_ARRAY_SIZE; + else + n += (n >>> 1) + 1; + r = Arrays.copyOf(r, n); + } + r[i++] = it.next(); + } + return (i == n) ? r : Arrays.copyOf(r, i); + } + + @SuppressWarnings("unchecked") public final T[] toArray(T[] a) { + long sz = map.mappingCount(); + if (sz > (long)(MAX_ARRAY_SIZE)) + throw new OutOfMemoryError(oomeMsg); + int m = (int)sz; + T[] r = (a.length >= m) ? a : + (T[])java.lang.reflect.Array + .newInstance(a.getClass().getComponentType(), m); + int n = r.length; + int i = 0; + Iterator it = iterator(); + while (it.hasNext()) { + if (i == n) { + if (n >= MAX_ARRAY_SIZE) + throw new OutOfMemoryError(oomeMsg); + if (n >= MAX_ARRAY_SIZE - (MAX_ARRAY_SIZE >>> 1) - 1) + n = MAX_ARRAY_SIZE; + else + n += (n >>> 1) + 1; + r = Arrays.copyOf(r, n); + } + r[i++] = (T)it.next(); + } + if (a == r && i < n) { + r[i] = null; // null-terminate + return r; + } + return (i == n) ? r : Arrays.copyOf(r, i); + } + + public final int hashCode() { + int h = 0; + for (Iterator it = iterator(); it.hasNext();) + h += it.next().hashCode(); + return h; + } + + public final String toString() { + StringBuilder sb = new StringBuilder(); + sb.append('['); + Iterator it = iterator(); + if (it.hasNext()) { + for (;;) { + Object e = it.next(); + sb.append(e == this ? "(this Collection)" : e); + if (!it.hasNext()) + break; + sb.append(',').append(' '); + } + } + return sb.append(']').toString(); + } + + public final boolean containsAll(Collection c) { + if (c != this) { + for (Iterator it = c.iterator(); it.hasNext();) { + Object e = it.next(); + if (e == null || !contains(e)) + return false; + } + } + return true; + } + + public final boolean removeAll(Collection c) { + boolean modified = false; + for (Iterator it = iterator(); it.hasNext();) { + if (c.contains(it.next())) { + it.remove(); + modified = true; + } + } + return modified; + } + + public final boolean retainAll(Collection c) { + boolean modified = false; + for (Iterator it = iterator(); it.hasNext();) { + if (!c.contains(it.next())) { + it.remove(); + modified = true; + } + } + return modified; + } + + } + + /** + * A view of a ConcurrentHashMapV8 as a {@link Set} of keys, in + * which additions may optionally be enabled by mapping to a + * common value. This class cannot be directly instantiated. See + * {@link #keySet}, {@link #keySet(Object)}, {@link #newKeySet()}, + * {@link #newKeySet(int)}. + */ + public static class KeySetView extends CHMView implements Set, java.io.Serializable { + private static final long serialVersionUID = 7249069246763182397L; + private final V value; + KeySetView(ConcurrentHashMapV8 map, V value) { // non-public + super(map); + this.value = value; + } + + /** + * Returns the default mapped value for additions, + * or {@code null} if additions are not supported. + * + * @return the default mapped value for additions, or {@code null} + * if not supported. + */ + public V getMappedValue() { return value; } + + // implement Set API + + public boolean contains(Object o) { return map.containsKey(o); } + public boolean remove(Object o) { return map.remove(o) != null; } + + /** + * Returns a "weakly consistent" iterator that will never + * throw {@link ConcurrentModificationException}, and + * guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not + * guaranteed to) reflect any modifications subsequent to + * construction. + * + * @return an iterator over the keys of this map + */ + public Iterator iterator() { return new KeyIterator(map); } + public boolean add(K e) { + V v; + if ((v = value) == null) + throw new UnsupportedOperationException(); + if (e == null) + throw new NullPointerException(); + return map.internalPutIfAbsent(e, v) == null; + } + public boolean addAll(Collection c) { + boolean added = false; + V v; + if ((v = value) == null) + throw new UnsupportedOperationException(); + for (K e : c) { + if (e == null) + throw new NullPointerException(); + if (map.internalPutIfAbsent(e, v) == null) + added = true; + } + return added; + } + public boolean equals(Object o) { + Set c; + return ((o instanceof Set) && + ((c = (Set)o) == this || + (containsAll(c) && c.containsAll(this)))); + } + } + + /** + * A view of a ConcurrentHashMapV8 as a {@link Collection} of + * values, in which additions are disabled. This class cannot be + * directly instantiated. See {@link #values}, + * + *

The view's {@code iterator} is a "weakly consistent" iterator + * that will never throw {@link ConcurrentModificationException}, + * and guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not guaranteed to) + * reflect any modifications subsequent to construction. + */ + public static final class ValuesView extends CHMView + implements Collection { + ValuesView(ConcurrentHashMapV8 map) { super(map); } + public final boolean contains(Object o) { return map.containsValue(o); } + public final boolean remove(Object o) { + if (o != null) { + Iterator it = new ValueIterator(map); + while (it.hasNext()) { + if (o.equals(it.next())) { + it.remove(); + return true; + } + } + } + return false; + } + + /** + * Returns a "weakly consistent" iterator that will never + * throw {@link ConcurrentModificationException}, and + * guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not + * guaranteed to) reflect any modifications subsequent to + * construction. + * + * @return an iterator over the values of this map + */ + public final Iterator iterator() { + return new ValueIterator(map); + } + public final boolean add(V e) { + throw new UnsupportedOperationException(); + } + public final boolean addAll(Collection c) { + throw new UnsupportedOperationException(); + } + } + + /** + * A view of a ConcurrentHashMapV8 as a {@link Set} of (key, value) + * entries. This class cannot be directly instantiated. See + * {@link #entrySet}. + */ + public static final class EntrySetView extends CHMView + implements Set> { + EntrySetView(ConcurrentHashMapV8 map) { super(map); } + public final boolean contains(Object o) { + Object k, v, r; Map.Entry e; + return ((o instanceof Map.Entry) && + (k = (e = (Map.Entry)o).getKey()) != null && + (r = map.get(k)) != null && + (v = e.getValue()) != null && + (v == r || v.equals(r))); + } + public final boolean remove(Object o) { + Object k, v; Map.Entry e; + return ((o instanceof Map.Entry) && + (k = (e = (Map.Entry)o).getKey()) != null && + (v = e.getValue()) != null && + map.remove(k, v)); + } + + /** + * Returns a "weakly consistent" iterator that will never + * throw {@link ConcurrentModificationException}, and + * guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not + * guaranteed to) reflect any modifications subsequent to + * construction. + * + * @return an iterator over the entries of this map + */ + public final Iterator> iterator() { + return new EntryIterator(map); + } + + public final boolean add(Entry e) { + K key = e.getKey(); + V value = e.getValue(); + if (key == null || value == null) + throw new NullPointerException(); + return map.internalPut(key, value) == null; + } + public final boolean addAll(Collection> c) { + boolean added = false; + for (Entry e : c) { + if (add(e)) + added = true; + } + return added; + } + public boolean equals(Object o) { + Set c; + return ((o instanceof Set) && + ((c = (Set)o) == this || + (containsAll(c) && c.containsAll(this)))); + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java new file mode 100644 index 0000000..ecf552a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java @@ -0,0 +1,204 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This is based on 1.9 version. + +package com.concurrent_ruby.ext.jsr166e.nounsafe; + +import java.util.concurrent.atomic.AtomicLong; +import java.io.IOException; +import java.io.Serializable; +import java.io.ObjectInputStream; + +/** + * One or more variables that together maintain an initially zero + * {@code long} sum. When updates (method {@link #add}) are contended + * across threads, the set of variables may grow dynamically to reduce + * contention. Method {@link #sum} (or, equivalently, {@link + * #longValue}) returns the current total combined across the + * variables maintaining the sum. + * + *

This class is usually preferable to {@link AtomicLong} when + * multiple threads update a common sum that is used for purposes such + * as collecting statistics, not for fine-grained synchronization + * control. Under low update contention, the two classes have similar + * characteristics. But under high contention, expected throughput of + * this class is significantly higher, at the expense of higher space + * consumption. + * + *

This class extends {@link Number}, but does not define + * methods such as {@code hashCode} and {@code compareTo} because + * instances are expected to be mutated, and so are not useful as + * collection keys. + * + *

jsr166e note: This class is targeted to be placed in + * java.util.concurrent.atomic. + * + * @since 1.8 + * @author Doug Lea + */ +public class LongAdder extends Striped64 implements Serializable { + private static final long serialVersionUID = 7249069246863182397L; + + /** + * Version of plus for use in retryUpdate + */ + final long fn(long v, long x) { return v + x; } + + /** + * Creates a new adder with initial sum of zero. + */ + public LongAdder() { + } + + /** + * Adds the given value. + * + * @param x the value to add + */ + public void add(long x) { + Cell[] as; long b, v; HashCode hc; Cell a; int n; + if ((as = cells) != null || !casBase(b = base, b + x)) { + boolean uncontended = true; + int h = (hc = threadHashCode.get()).code; + if (as == null || (n = as.length) < 1 || + (a = as[(n - 1) & h]) == null || + !(uncontended = a.cas(v = a.value, v + x))) + retryUpdate(x, hc, uncontended); + } + } + + /** + * Equivalent to {@code add(1)}. + */ + public void increment() { + add(1L); + } + + /** + * Equivalent to {@code add(-1)}. + */ + public void decrement() { + add(-1L); + } + + /** + * Returns the current sum. The returned value is NOT an + * atomic snapshot: Invocation in the absence of concurrent + * updates returns an accurate result, but concurrent updates that + * occur while the sum is being calculated might not be + * incorporated. + * + * @return the sum + */ + public long sum() { + long sum = base; + Cell[] as = cells; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) + sum += a.value; + } + } + return sum; + } + + /** + * Resets variables maintaining the sum to zero. This method may + * be a useful alternative to creating a new adder, but is only + * effective if there are no concurrent updates. Because this + * method is intrinsically racy, it should only be used when it is + * known that no threads are concurrently updating. + */ + public void reset() { + internalReset(0L); + } + + /** + * Equivalent in effect to {@link #sum} followed by {@link + * #reset}. This method may apply for example during quiescent + * points between multithreaded computations. If there are + * updates concurrent with this method, the returned value is + * not guaranteed to be the final value occurring before + * the reset. + * + * @return the sum + */ + public long sumThenReset() { + long sum = base; + Cell[] as = cells; + base = 0L; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) { + sum += a.value; + a.value = 0L; + } + } + } + return sum; + } + + /** + * Returns the String representation of the {@link #sum}. + * @return the String representation of the {@link #sum} + */ + public String toString() { + return Long.toString(sum()); + } + + /** + * Equivalent to {@link #sum}. + * + * @return the sum + */ + public long longValue() { + return sum(); + } + + /** + * Returns the {@link #sum} as an {@code int} after a narrowing + * primitive conversion. + */ + public int intValue() { + return (int)sum(); + } + + /** + * Returns the {@link #sum} as a {@code float} + * after a widening primitive conversion. + */ + public float floatValue() { + return (float)sum(); + } + + /** + * Returns the {@link #sum} as a {@code double} after a widening + * primitive conversion. + */ + public double doubleValue() { + return (double)sum(); + } + + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + s.defaultWriteObject(); + s.writeLong(sum()); + } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + busy = 0; + cells = null; + base = s.readLong(); + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java new file mode 100644 index 0000000..f521642 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java @@ -0,0 +1,291 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This is based on 1.5 version. + +package com.concurrent_ruby.ext.jsr166e.nounsafe; + +import java.util.Random; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.atomic.AtomicLongFieldUpdater; + +/** + * A package-local class holding common representation and mechanics + * for classes supporting dynamic striping on 64bit values. The class + * extends Number so that concrete subclasses must publicly do so. + */ +abstract class Striped64 extends Number { + /* + * This class maintains a lazily-initialized table of atomically + * updated variables, plus an extra "base" field. The table size + * is a power of two. Indexing uses masked per-thread hash codes. + * Nearly all declarations in this class are package-private, + * accessed directly by subclasses. + * + * Table entries are of class Cell; a variant of AtomicLong padded + * to reduce cache contention on most processors. Padding is + * overkill for most Atomics because they are usually irregularly + * scattered in memory and thus don't interfere much with each + * other. But Atomic objects residing in arrays will tend to be + * placed adjacent to each other, and so will most often share + * cache lines (with a huge negative performance impact) without + * this precaution. + * + * In part because Cells are relatively large, we avoid creating + * them until they are needed. When there is no contention, all + * updates are made to the base field. Upon first contention (a + * failed CAS on base update), the table is initialized to size 2. + * The table size is doubled upon further contention until + * reaching the nearest power of two greater than or equal to the + * number of CPUS. Table slots remain empty (null) until they are + * needed. + * + * A single spinlock ("busy") is used for initializing and + * resizing the table, as well as populating slots with new Cells. + * There is no need for a blocking lock: When the lock is not + * available, threads try other slots (or the base). During these + * retries, there is increased contention and reduced locality, + * which is still better than alternatives. + * + * Per-thread hash codes are initialized to random values. + * Contention and/or table collisions are indicated by failed + * CASes when performing an update operation (see method + * retryUpdate). Upon a collision, if the table size is less than + * the capacity, it is doubled in size unless some other thread + * holds the lock. If a hashed slot is empty, and lock is + * available, a new Cell is created. Otherwise, if the slot + * exists, a CAS is tried. Retries proceed by "double hashing", + * using a secondary hash (Marsaglia XorShift) to try to find a + * free slot. + * + * The table size is capped because, when there are more threads + * than CPUs, supposing that each thread were bound to a CPU, + * there would exist a perfect hash function mapping threads to + * slots that eliminates collisions. When we reach capacity, we + * search for this mapping by randomly varying the hash codes of + * colliding threads. Because search is random, and collisions + * only become known via CAS failures, convergence can be slow, + * and because threads are typically not bound to CPUS forever, + * may not occur at all. However, despite these limitations, + * observed contention rates are typically low in these cases. + * + * It is possible for a Cell to become unused when threads that + * once hashed to it terminate, as well as in the case where + * doubling the table causes no thread to hash to it under + * expanded mask. We do not try to detect or remove such cells, + * under the assumption that for long-running instances, observed + * contention levels will recur, so the cells will eventually be + * needed again; and for short-lived ones, it does not matter. + */ + + /** + * Padded variant of AtomicLong supporting only raw accesses plus CAS. + * The value field is placed between pads, hoping that the JVM doesn't + * reorder them. + * + * JVM intrinsics note: It would be possible to use a release-only + * form of CAS here, if it were provided. + */ + static final class Cell { + volatile long p0, p1, p2, p3, p4, p5, p6; + volatile long value; + volatile long q0, q1, q2, q3, q4, q5, q6; + + static AtomicLongFieldUpdater VALUE_UPDATER = AtomicLongFieldUpdater.newUpdater(Cell.class, "value"); + + Cell(long x) { value = x; } + + final boolean cas(long cmp, long val) { + return VALUE_UPDATER.compareAndSet(this, cmp, val); + } + + } + + /** + * Holder for the thread-local hash code. The code is initially + * random, but may be set to a different value upon collisions. + */ + static final class HashCode { + static final Random rng = new Random(); + int code; + HashCode() { + int h = rng.nextInt(); // Avoid zero to allow xorShift rehash + code = (h == 0) ? 1 : h; + } + } + + /** + * The corresponding ThreadLocal class + */ + static final class ThreadHashCode extends ThreadLocal { + public HashCode initialValue() { return new HashCode(); } + } + + /** + * Static per-thread hash codes. Shared across all instances to + * reduce ThreadLocal pollution and because adjustments due to + * collisions in one table are likely to be appropriate for + * others. + */ + static final ThreadHashCode threadHashCode = new ThreadHashCode(); + + /** Number of CPUS, to place bound on table size */ + static final int NCPU = Runtime.getRuntime().availableProcessors(); + + /** + * Table of cells. When non-null, size is a power of 2. + */ + transient volatile Cell[] cells; + + /** + * Base value, used mainly when there is no contention, but also as + * a fallback during table initialization races. Updated via CAS. + */ + transient volatile long base; + + /** + * Spinlock (locked via CAS) used when resizing and/or creating Cells. + */ + transient volatile int busy; + + AtomicLongFieldUpdater BASE_UPDATER = AtomicLongFieldUpdater.newUpdater(Striped64.class, "base"); + AtomicIntegerFieldUpdater BUSY_UPDATER = AtomicIntegerFieldUpdater.newUpdater(Striped64.class, "busy"); + + /** + * Package-private default constructor + */ + Striped64() { + } + + /** + * CASes the base field. + */ + final boolean casBase(long cmp, long val) { + return BASE_UPDATER.compareAndSet(this, cmp, val); + } + + /** + * CASes the busy field from 0 to 1 to acquire lock. + */ + final boolean casBusy() { + return BUSY_UPDATER.compareAndSet(this, 0, 1); + } + + /** + * Computes the function of current and new value. Subclasses + * should open-code this update function for most uses, but the + * virtualized form is needed within retryUpdate. + * + * @param currentValue the current value (of either base or a cell) + * @param newValue the argument from a user update call + * @return result of the update function + */ + abstract long fn(long currentValue, long newValue); + + /** + * Handles cases of updates involving initialization, resizing, + * creating new Cells, and/or contention. See above for + * explanation. This method suffers the usual non-modularity + * problems of optimistic retry code, relying on rechecked sets of + * reads. + * + * @param x the value + * @param hc the hash code holder + * @param wasUncontended false if CAS failed before call + */ + final void retryUpdate(long x, HashCode hc, boolean wasUncontended) { + int h = hc.code; + boolean collide = false; // True if last slot nonempty + for (;;) { + Cell[] as; Cell a; int n; long v; + if ((as = cells) != null && (n = as.length) > 0) { + if ((a = as[(n - 1) & h]) == null) { + if (busy == 0) { // Try to attach new Cell + Cell r = new Cell(x); // Optimistically create + if (busy == 0 && casBusy()) { + boolean created = false; + try { // Recheck under lock + Cell[] rs; int m, j; + if ((rs = cells) != null && + (m = rs.length) > 0 && + rs[j = (m - 1) & h] == null) { + rs[j] = r; + created = true; + } + } finally { + busy = 0; + } + if (created) + break; + continue; // Slot is now non-empty + } + } + collide = false; + } + else if (!wasUncontended) // CAS already known to fail + wasUncontended = true; // Continue after rehash + else if (a.cas(v = a.value, fn(v, x))) + break; + else if (n >= NCPU || cells != as) + collide = false; // At max size or stale + else if (!collide) + collide = true; + else if (busy == 0 && casBusy()) { + try { + if (cells == as) { // Expand table unless stale + Cell[] rs = new Cell[n << 1]; + for (int i = 0; i < n; ++i) + rs[i] = as[i]; + cells = rs; + } + } finally { + busy = 0; + } + collide = false; + continue; // Retry with expanded table + } + h ^= h << 13; // Rehash + h ^= h >>> 17; + h ^= h << 5; + } + else if (busy == 0 && cells == as && casBusy()) { + boolean init = false; + try { // Initialize table + if (cells == as) { + Cell[] rs = new Cell[2]; + rs[h & 1] = new Cell(x); + cells = rs; + init = true; + } + } finally { + busy = 0; + } + if (init) + break; + } + else if (casBase(v = base, fn(v, x))) + break; // Fall back on using base + } + hc.code = h; // Record index for next time + } + + + /** + * Sets base and all cells to the given value. + */ + final void internalReset(long initialValue) { + Cell[] as = cells; + base = initialValue; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) + a.value = initialValue; + } + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166y/ThreadLocalRandom.java b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166y/ThreadLocalRandom.java new file mode 100644 index 0000000..3ea409f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166y/ThreadLocalRandom.java @@ -0,0 +1,199 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This is based on 1.16 version + +package com.concurrent_ruby.ext.jsr166y; + +import java.util.Random; + +/** + * A random number generator isolated to the current thread. Like the + * global {@link java.util.Random} generator used by the {@link + * java.lang.Math} class, a {@code ThreadLocalRandom} is initialized + * with an internally generated seed that may not otherwise be + * modified. When applicable, use of {@code ThreadLocalRandom} rather + * than shared {@code Random} objects in concurrent programs will + * typically encounter much less overhead and contention. Use of + * {@code ThreadLocalRandom} is particularly appropriate when multiple + * tasks (for example, each a {@link ForkJoinTask}) use random numbers + * in parallel in thread pools. + * + *

Usages of this class should typically be of the form: + * {@code ThreadLocalRandom.current().nextX(...)} (where + * {@code X} is {@code Int}, {@code Long}, etc). + * When all usages are of this form, it is never possible to + * accidently share a {@code ThreadLocalRandom} across multiple threads. + * + *

This class also provides additional commonly used bounded random + * generation methods. + * + * @since 1.7 + * @author Doug Lea + */ +public class ThreadLocalRandom extends Random { + // same constants as Random, but must be redeclared because private + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; + + /** + * The random seed. We can't use super.seed. + */ + private long rnd; + + /** + * Initialization flag to permit calls to setSeed to succeed only + * while executing the Random constructor. We can't allow others + * since it would cause setting seed in one part of a program to + * unintentionally impact other usages by the thread. + */ + boolean initialized; + + // Padding to help avoid memory contention among seed updates in + // different TLRs in the common case that they are located near + // each other. + private long pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7; + + /** + * The actual ThreadLocal + */ + private static final ThreadLocal localRandom = + new ThreadLocal() { + protected ThreadLocalRandom initialValue() { + return new ThreadLocalRandom(); + } + }; + + + /** + * Constructor called only by localRandom.initialValue. + */ + ThreadLocalRandom() { + super(); + initialized = true; + } + + /** + * Returns the current thread's {@code ThreadLocalRandom}. + * + * @return the current thread's {@code ThreadLocalRandom} + */ + public static ThreadLocalRandom current() { + return localRandom.get(); + } + + /** + * Throws {@code UnsupportedOperationException}. Setting seeds in + * this generator is not supported. + * + * @throws UnsupportedOperationException always + */ + public void setSeed(long seed) { + if (initialized) + throw new UnsupportedOperationException(); + rnd = (seed ^ multiplier) & mask; + } + + protected int next(int bits) { + rnd = (rnd * multiplier + addend) & mask; + return (int) (rnd >>> (48-bits)); + } + + /** + * Returns a pseudorandom, uniformly distributed value between the + * given least value (inclusive) and bound (exclusive). + * + * @param least the least value returned + * @param bound the upper bound (exclusive) + * @throws IllegalArgumentException if least greater than or equal + * to bound + * @return the next value + */ + public int nextInt(int least, int bound) { + if (least >= bound) + throw new IllegalArgumentException(); + return nextInt(bound - least) + least; + } + + /** + * Returns a pseudorandom, uniformly distributed value + * between 0 (inclusive) and the specified value (exclusive). + * + * @param n the bound on the random number to be returned. Must be + * positive. + * @return the next value + * @throws IllegalArgumentException if n is not positive + */ + public long nextLong(long n) { + if (n <= 0) + throw new IllegalArgumentException("n must be positive"); + // Divide n by two until small enough for nextInt. On each + // iteration (at most 31 of them but usually much less), + // randomly choose both whether to include high bit in result + // (offset) and whether to continue with the lower vs upper + // half (which makes a difference only if odd). + long offset = 0; + while (n >= Integer.MAX_VALUE) { + int bits = next(2); + long half = n >>> 1; + long nextn = ((bits & 2) == 0) ? half : n - half; + if ((bits & 1) == 0) + offset += n - nextn; + n = nextn; + } + return offset + nextInt((int) n); + } + + /** + * Returns a pseudorandom, uniformly distributed value between the + * given least value (inclusive) and bound (exclusive). + * + * @param least the least value returned + * @param bound the upper bound (exclusive) + * @return the next value + * @throws IllegalArgumentException if least greater than or equal + * to bound + */ + public long nextLong(long least, long bound) { + if (least >= bound) + throw new IllegalArgumentException(); + return nextLong(bound - least) + least; + } + + /** + * Returns a pseudorandom, uniformly distributed {@code double} value + * between 0 (inclusive) and the specified value (exclusive). + * + * @param n the bound on the random number to be returned. Must be + * positive. + * @return the next value + * @throws IllegalArgumentException if n is not positive + */ + public double nextDouble(double n) { + if (n <= 0) + throw new IllegalArgumentException("n must be positive"); + return nextDouble() * n; + } + + /** + * Returns a pseudorandom, uniformly distributed value between the + * given least value (inclusive) and bound (exclusive). + * + * @param least the least value returned + * @param bound the upper bound (exclusive) + * @return the next value + * @throws IllegalArgumentException if least greater than or equal + * to bound + */ + public double nextDouble(double least, double bound) { + if (least >= bound) + throw new IllegalArgumentException(); + return nextDouble() * (bound - least) + least; + } + + private static final long serialVersionUID = -5851777807851030925L; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent-ruby.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent-ruby.rb new file mode 100644 index 0000000..e9a3dea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent-ruby.rb @@ -0,0 +1,5 @@ +# This file is here so that there is a file with the same name as the gem that +# can be required by Bundler.require. Applications should normally +# require 'concurrent'. + +require_relative "concurrent" diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent.rb new file mode 100644 index 0000000..87de46f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent.rb @@ -0,0 +1,134 @@ +require 'concurrent/version' +require 'concurrent/constants' +require 'concurrent/errors' +require 'concurrent/configuration' + +require 'concurrent/atomics' +require 'concurrent/executors' +require 'concurrent/synchronization' + +require 'concurrent/atomic/atomic_markable_reference' +require 'concurrent/atomic/atomic_reference' +require 'concurrent/agent' +require 'concurrent/atom' +require 'concurrent/array' +require 'concurrent/hash' +require 'concurrent/set' +require 'concurrent/map' +require 'concurrent/tuple' +require 'concurrent/async' +require 'concurrent/dataflow' +require 'concurrent/delay' +require 'concurrent/exchanger' +require 'concurrent/future' +require 'concurrent/immutable_struct' +require 'concurrent/ivar' +require 'concurrent/maybe' +require 'concurrent/mutable_struct' +require 'concurrent/mvar' +require 'concurrent/promise' +require 'concurrent/scheduled_task' +require 'concurrent/settable_struct' +require 'concurrent/timer_task' +require 'concurrent/tvar' +require 'concurrent/promises' + +require 'concurrent/thread_safe/synchronized_delegator' +require 'concurrent/thread_safe/util' + +require 'concurrent/options' + +# @!macro internal_implementation_note +# +# @note **Private Implementation:** This abstraction is a private, internal +# implementation detail. It should never be used directly. + +# @!macro monotonic_clock_warning +# +# @note Time calculations on all platforms and languages are sensitive to +# changes to the system clock. To alleviate the potential problems +# associated with changing the system clock while an application is running, +# most modern operating systems provide a monotonic clock that operates +# independently of the system clock. A monotonic clock cannot be used to +# determine human-friendly clock times. A monotonic clock is used exclusively +# for calculating time intervals. Not all Ruby platforms provide access to an +# operating system monotonic clock. On these platforms a pure-Ruby monotonic +# clock will be used as a fallback. An operating system monotonic clock is both +# faster and more reliable than the pure-Ruby implementation. The pure-Ruby +# implementation should be fast and reliable enough for most non-realtime +# operations. At this time the common Ruby platforms that provide access to an +# operating system monotonic clock are MRI 2.1 and above and JRuby (all versions). +# +# @see http://linux.die.net/man/3/clock_gettime Linux clock_gettime(3) + +# @!macro copy_options +# +# ## Copy Options +# +# Object references in Ruby are mutable. This can lead to serious +# problems when the {#value} of an object is a mutable reference. Which +# is always the case unless the value is a `Fixnum`, `Symbol`, or similar +# "primitive" data type. Each instance can be configured with a few +# options that can help protect the program from potentially dangerous +# operations. Each of these options can be optionally set when the object +# instance is created: +# +# * `:dup_on_deref` When true the object will call the `#dup` method on +# the `value` object every time the `#value` method is called +# (default: false) +# * `:freeze_on_deref` When true the object will call the `#freeze` +# method on the `value` object every time the `#value` method is called +# (default: false) +# * `:copy_on_deref` When given a `Proc` object the `Proc` will be run +# every time the `#value` method is called. The `Proc` will be given +# the current `value` as its only argument and the result returned by +# the block will be the return value of the `#value` call. When `nil` +# this option will be ignored (default: nil) +# +# When multiple deref options are set the order of operations is strictly defined. +# The order of deref operations is: +# * `:copy_on_deref` +# * `:dup_on_deref` +# * `:freeze_on_deref` +# +# Because of this ordering there is no need to `#freeze` an object created by a +# provided `:copy_on_deref` block. Simply set `:freeze_on_deref` to `true`. +# Setting both `:dup_on_deref` to `true` and `:freeze_on_deref` to `true` is +# as close to the behavior of a "pure" functional language (like Erlang, Clojure, +# or Haskell) as we are likely to get in Ruby. + +# @!macro deref_options +# +# @option opts [Boolean] :dup_on_deref (false) Call `#dup` before +# returning the data from {#value} +# @option opts [Boolean] :freeze_on_deref (false) Call `#freeze` before +# returning the data from {#value} +# @option opts [Proc] :copy_on_deref (nil) When calling the {#value} +# method, call the given proc passing the internal value as the sole +# argument then return the new value returned from the proc. + +# @!macro executor_and_deref_options +# +# @param [Hash] opts the options used to define the behavior at update and deref +# and to specify the executor on which to perform actions +# @option opts [Executor] :executor when set use the given `Executor` instance. +# Three special values are also supported: `:io` returns the global pool for +# long, blocking (IO) tasks, `:fast` returns the global pool for short, fast +# operations, and `:immediate` returns the global `ImmediateExecutor` object. +# @!macro deref_options + +# @!macro warn.edge +# @api Edge +# @note **Edge Features** are under active development and may change frequently. +# +# - Deprecations are not added before incompatible changes. +# - Edge version: _major_ is always 0, _minor_ bump means incompatible change, +# _patch_ bump means compatible change. +# - Edge features may also lack tests and documentation. +# - Features developed in `concurrent-ruby-edge` are expected to move +# to `concurrent-ruby` when finalised. + + +# {include:file:README.md} +module Concurrent +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/agent.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/agent.rb new file mode 100644 index 0000000..2d32926 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/agent.rb @@ -0,0 +1,588 @@ +require 'concurrent/configuration' +require 'concurrent/atomic/atomic_reference' +require 'concurrent/atomic/count_down_latch' +require 'concurrent/atomic/thread_local_var' +require 'concurrent/collection/copy_on_write_observer_set' +require 'concurrent/concern/observable' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # `Agent` is inspired by Clojure's [agent](http://clojure.org/agents) + # function. An agent is a shared, mutable variable providing independent, + # uncoordinated, *asynchronous* change of individual values. Best used when + # the value will undergo frequent, complex updates. Suitable when the result + # of an update does not need to be known immediately. `Agent` is (mostly) + # functionally equivalent to Clojure's agent, except where the runtime + # prevents parity. + # + # Agents are reactive, not autonomous - there is no imperative message loop + # and no blocking receive. The state of an Agent should be itself immutable + # and the `#value` of an Agent is always immediately available for reading by + # any thread without any messages, i.e. observation does not require + # cooperation or coordination. + # + # Agent action dispatches are made using the various `#send` methods. These + # methods always return immediately. At some point later, in another thread, + # the following will happen: + # + # 1. The given `action` will be applied to the state of the Agent and the + # `args`, if any were supplied. + # 2. The return value of `action` will be passed to the validator lambda, + # if one has been set on the Agent. + # 3. If the validator succeeds or if no validator was given, the return value + # of the given `action` will become the new `#value` of the Agent. See + # `#initialize` for details. + # 4. If any observers were added to the Agent, they will be notified. See + # `#add_observer` for details. + # 5. If during the `action` execution any other dispatches are made (directly + # or indirectly), they will be held until after the `#value` of the Agent + # has been changed. + # + # If any exceptions are thrown by an action function, no nested dispatches + # will occur, and the exception will be cached in the Agent itself. When an + # Agent has errors cached, any subsequent interactions will immediately throw + # an exception, until the agent's errors are cleared. Agent errors can be + # examined with `#error` and the agent restarted with `#restart`. + # + # The actions of all Agents get interleaved amongst threads in a thread pool. + # At any point in time, at most one action for each Agent is being executed. + # Actions dispatched to an agent from another single agent or thread will + # occur in the order they were sent, potentially interleaved with actions + # dispatched to the same agent from other sources. The `#send` method should + # be used for actions that are CPU limited, while the `#send_off` method is + # appropriate for actions that may block on IO. + # + # Unlike in Clojure, `Agent` cannot participate in `Concurrent::TVar` transactions. + # + # ## Example + # + # ``` + # def next_fibonacci(set = nil) + # return [0, 1] if set.nil? + # set + [set[-2..-1].reduce{|sum,x| sum + x }] + # end + # + # # create an agent with an initial value + # agent = Concurrent::Agent.new(next_fibonacci) + # + # # send a few update requests + # 5.times do + # agent.send{|set| next_fibonacci(set) } + # end + # + # # wait for them to complete + # agent.await + # + # # get the current value + # agent.value #=> [0, 1, 1, 2, 3, 5, 8] + # ``` + # + # ## Observation + # + # Agents support observers through the {Concurrent::Observable} mixin module. + # Notification of observers occurs every time an action dispatch returns and + # the new value is successfully validated. Observation will *not* occur if the + # action raises an exception, if validation fails, or when a {#restart} occurs. + # + # When notified the observer will receive three arguments: `time`, `old_value`, + # and `new_value`. The `time` argument is the time at which the value change + # occurred. The `old_value` is the value of the Agent when the action began + # processing. The `new_value` is the value to which the Agent was set when the + # action completed. Note that `old_value` and `new_value` may be the same. + # This is not an error. It simply means that the action returned the same + # value. + # + # ## Nested Actions + # + # It is possible for an Agent action to post further actions back to itself. + # The nested actions will be enqueued normally then processed *after* the + # outer action completes, in the order they were sent, possibly interleaved + # with action dispatches from other threads. Nested actions never deadlock + # with one another and a failure in a nested action will never affect the + # outer action. + # + # Nested actions can be called using the Agent reference from the enclosing + # scope or by passing the reference in as a "send" argument. Nested actions + # cannot be post using `self` from within the action block/proc/lambda; `self` + # in this context will not reference the Agent. The preferred method for + # dispatching nested actions is to pass the Agent as an argument. This allows + # Ruby to more effectively manage the closing scope. + # + # Prefer this: + # + # ``` + # agent = Concurrent::Agent.new(0) + # agent.send(agent) do |value, this| + # this.send {|v| v + 42 } + # 3.14 + # end + # agent.value #=> 45.14 + # ``` + # + # Over this: + # + # ``` + # agent = Concurrent::Agent.new(0) + # agent.send do |value| + # agent.send {|v| v + 42 } + # 3.14 + # end + # ``` + # + # @!macro agent_await_warning + # + # **NOTE** Never, *under any circumstances*, call any of the "await" methods + # ({#await}, {#await_for}, {#await_for!}, and {#wait}) from within an action + # block/proc/lambda. The call will block the Agent and will always fail. + # Calling either {#await} or {#wait} (with a timeout of `nil`) will + # hopelessly deadlock the Agent with no possibility of recovery. + # + # @!macro thread_safe_variable_comparison + # + # @see http://clojure.org/Agents Clojure Agents + # @see http://clojure.org/state Values and Change - Clojure's approach to Identity and State + class Agent < Synchronization::LockableObject + include Concern::Observable + + ERROR_MODES = [:continue, :fail].freeze + private_constant :ERROR_MODES + + AWAIT_FLAG = ::Object.new + private_constant :AWAIT_FLAG + + AWAIT_ACTION = ->(value, latch) { latch.count_down; AWAIT_FLAG } + private_constant :AWAIT_ACTION + + DEFAULT_ERROR_HANDLER = ->(agent, error) { nil } + private_constant :DEFAULT_ERROR_HANDLER + + DEFAULT_VALIDATOR = ->(value) { true } + private_constant :DEFAULT_VALIDATOR + + Job = Struct.new(:action, :args, :executor, :caller) + private_constant :Job + + # Raised during action processing or any other time in an Agent's lifecycle. + class Error < StandardError + def initialize(message = nil) + message ||= 'agent must be restarted before jobs can post' + super(message) + end + end + + # Raised when a new value obtained during action processing or at `#restart` + # fails validation. + class ValidationError < Error + def initialize(message = nil) + message ||= 'invalid value' + super(message) + end + end + + # The error mode this Agent is operating in. See {#initialize} for details. + attr_reader :error_mode + + # Create a new `Agent` with the given initial value and options. + # + # The `:validator` option must be `nil` or a side-effect free proc/lambda + # which takes one argument. On any intended value change the validator, if + # provided, will be called. If the new value is invalid the validator should + # return `false` or raise an error. + # + # The `:error_handler` option must be `nil` or a proc/lambda which takes two + # arguments. When an action raises an error or validation fails, either by + # returning false or raising an error, the error handler will be called. The + # arguments to the error handler will be a reference to the agent itself and + # the error object which was raised. + # + # The `:error_mode` may be either `:continue` (the default if an error + # handler is given) or `:fail` (the default if error handler nil or not + # given). + # + # If an action being run by the agent throws an error or doesn't pass + # validation the error handler, if present, will be called. After the + # handler executes if the error mode is `:continue` the Agent will continue + # as if neither the action that caused the error nor the error itself ever + # happened. + # + # If the mode is `:fail` the Agent will become {#failed?} and will stop + # accepting new action dispatches. Any previously queued actions will be + # held until {#restart} is called. The {#value} method will still work, + # returning the value of the Agent before the error. + # + # @param [Object] initial the initial value + # @param [Hash] opts the configuration options + # + # @option opts [Symbol] :error_mode either `:continue` or `:fail` + # @option opts [nil, Proc] :error_handler the (optional) error handler + # @option opts [nil, Proc] :validator the (optional) validation procedure + def initialize(initial, opts = {}) + super() + synchronize { ns_initialize(initial, opts) } + end + + # The current value (state) of the Agent, irrespective of any pending or + # in-progress actions. The value is always available and is non-blocking. + # + # @return [Object] the current value + def value + @current.value # TODO (pitr 12-Sep-2015): broken unsafe read? + end + + alias_method :deref, :value + + # When {#failed?} and {#error_mode} is `:fail`, returns the error object + # which caused the failure, else `nil`. When {#error_mode} is `:continue` + # will *always* return `nil`. + # + # @return [nil, Error] the error which caused the failure when {#failed?} + def error + @error.value + end + + alias_method :reason, :error + + # @!macro agent_send + # + # Dispatches an action to the Agent and returns immediately. Subsequently, + # in a thread from a thread pool, the {#value} will be set to the return + # value of the action. Action dispatches are only allowed when the Agent + # is not {#failed?}. + # + # The action must be a block/proc/lambda which takes 1 or more arguments. + # The first argument is the current {#value} of the Agent. Any arguments + # passed to the send method via the `args` parameter will be passed to the + # action as the remaining arguments. The action must return the new value + # of the Agent. + # + # * {#send} and {#send!} should be used for actions that are CPU limited + # * {#send_off}, {#send_off!}, and {#<<} are appropriate for actions that + # may block on IO + # * {#send_via} and {#send_via!} are used when a specific executor is to + # be used for the action + # + # @param [Array] args zero or more arguments to be passed to + # the action + # @param [Proc] action the action dispatch to be enqueued + # + # @yield [agent, value, *args] process the old value and return the new + # @yieldparam [Object] value the current {#value} of the Agent + # @yieldparam [Array] args zero or more arguments to pass to the + # action + # @yieldreturn [Object] the new value of the Agent + # + # @!macro send_return + # @return [Boolean] true if the action is successfully enqueued, false if + # the Agent is {#failed?} + def send(*args, &action) + enqueue_action_job(action, args, Concurrent.global_fast_executor) + end + + # @!macro agent_send + # + # @!macro send_bang_return_and_raise + # @return [Boolean] true if the action is successfully enqueued + # @raise [Concurrent::Agent::Error] if the Agent is {#failed?} + def send!(*args, &action) + raise Error.new unless send(*args, &action) + true + end + + # @!macro agent_send + # @!macro send_return + def send_off(*args, &action) + enqueue_action_job(action, args, Concurrent.global_io_executor) + end + + alias_method :post, :send_off + + # @!macro agent_send + # @!macro send_bang_return_and_raise + def send_off!(*args, &action) + raise Error.new unless send_off(*args, &action) + true + end + + # @!macro agent_send + # @!macro send_return + # @param [Concurrent::ExecutorService] executor the executor on which the + # action is to be dispatched + def send_via(executor, *args, &action) + enqueue_action_job(action, args, executor) + end + + # @!macro agent_send + # @!macro send_bang_return_and_raise + # @param [Concurrent::ExecutorService] executor the executor on which the + # action is to be dispatched + def send_via!(executor, *args, &action) + raise Error.new unless send_via(executor, *args, &action) + true + end + + # Dispatches an action to the Agent and returns immediately. Subsequently, + # in a thread from a thread pool, the {#value} will be set to the return + # value of the action. Appropriate for actions that may block on IO. + # + # @param [Proc] action the action dispatch to be enqueued + # @return [Concurrent::Agent] self + # @see #send_off + def <<(action) + send_off(&action) + self + end + + # Blocks the current thread (indefinitely!) until all actions dispatched + # thus far, from this thread or nested by the Agent, have occurred. Will + # block when {#failed?}. Will never return if a failed Agent is {#restart} + # with `:clear_actions` true. + # + # Returns a reference to `self` to support method chaining: + # + # ``` + # current_value = agent.await.value + # ``` + # + # @return [Boolean] self + # + # @!macro agent_await_warning + def await + wait(nil) + self + end + + # Blocks the current thread until all actions dispatched thus far, from this + # thread or nested by the Agent, have occurred, or the timeout (in seconds) + # has elapsed. + # + # @param [Float] timeout the maximum number of seconds to wait + # @return [Boolean] true if all actions complete before timeout else false + # + # @!macro agent_await_warning + def await_for(timeout) + wait(timeout.to_f) + end + + # Blocks the current thread until all actions dispatched thus far, from this + # thread or nested by the Agent, have occurred, or the timeout (in seconds) + # has elapsed. + # + # @param [Float] timeout the maximum number of seconds to wait + # @return [Boolean] true if all actions complete before timeout + # + # @raise [Concurrent::TimeoutError] when timout is reached + # + # @!macro agent_await_warning + def await_for!(timeout) + raise Concurrent::TimeoutError unless wait(timeout.to_f) + true + end + + # Blocks the current thread until all actions dispatched thus far, from this + # thread or nested by the Agent, have occurred, or the timeout (in seconds) + # has elapsed. Will block indefinitely when timeout is nil or not given. + # + # Provided mainly for consistency with other classes in this library. Prefer + # the various `await` methods instead. + # + # @param [Float] timeout the maximum number of seconds to wait + # @return [Boolean] true if all actions complete before timeout else false + # + # @!macro agent_await_warning + def wait(timeout = nil) + latch = Concurrent::CountDownLatch.new(1) + enqueue_await_job(latch) + latch.wait(timeout) + end + + # Is the Agent in a failed state? + # + # @see #restart + def failed? + !@error.value.nil? + end + + alias_method :stopped?, :failed? + + # When an Agent is {#failed?}, changes the Agent {#value} to `new_value` + # then un-fails the Agent so that action dispatches are allowed again. If + # the `:clear_actions` option is give and true, any actions queued on the + # Agent that were being held while it was failed will be discarded, + # otherwise those held actions will proceed. The `new_value` must pass the + # validator if any, or `restart` will raise an exception and the Agent will + # remain failed with its old {#value} and {#error}. Observers, if any, will + # not be notified of the new state. + # + # @param [Object] new_value the new value for the Agent once restarted + # @param [Hash] opts the configuration options + # @option opts [Symbol] :clear_actions true if all enqueued but unprocessed + # actions should be discarded on restart, else false (default: false) + # @return [Boolean] true + # + # @raise [Concurrent:AgentError] when not failed + def restart(new_value, opts = {}) + clear_actions = opts.fetch(:clear_actions, false) + synchronize do + raise Error.new('agent is not failed') unless failed? + raise ValidationError unless ns_validate(new_value) + @current.value = new_value + @error.value = nil + @queue.clear if clear_actions + ns_post_next_job unless @queue.empty? + end + true + end + + class << self + + # Blocks the current thread (indefinitely!) until all actions dispatched + # thus far to all the given Agents, from this thread or nested by the + # given Agents, have occurred. Will block when any of the agents are + # failed. Will never return if a failed Agent is restart with + # `:clear_actions` true. + # + # @param [Array] agents the Agents on which to wait + # @return [Boolean] true + # + # @!macro agent_await_warning + def await(*agents) + agents.each { |agent| agent.await } + true + end + + # Blocks the current thread until all actions dispatched thus far to all + # the given Agents, from this thread or nested by the given Agents, have + # occurred, or the timeout (in seconds) has elapsed. + # + # @param [Float] timeout the maximum number of seconds to wait + # @param [Array] agents the Agents on which to wait + # @return [Boolean] true if all actions complete before timeout else false + # + # @!macro agent_await_warning + def await_for(timeout, *agents) + end_at = Concurrent.monotonic_time + timeout.to_f + ok = agents.length.times do |i| + break false if (delay = end_at - Concurrent.monotonic_time) < 0 + break false unless agents[i].await_for(delay) + end + !!ok + end + + # Blocks the current thread until all actions dispatched thus far to all + # the given Agents, from this thread or nested by the given Agents, have + # occurred, or the timeout (in seconds) has elapsed. + # + # @param [Float] timeout the maximum number of seconds to wait + # @param [Array] agents the Agents on which to wait + # @return [Boolean] true if all actions complete before timeout + # + # @raise [Concurrent::TimeoutError] when timout is reached + # @!macro agent_await_warning + def await_for!(timeout, *agents) + raise Concurrent::TimeoutError unless await_for(timeout, *agents) + true + end + end + + private + + def ns_initialize(initial, opts) + @error_mode = opts[:error_mode] + @error_handler = opts[:error_handler] + + if @error_mode && !ERROR_MODES.include?(@error_mode) + raise ArgumentError.new('unrecognized error mode') + elsif @error_mode.nil? + @error_mode = @error_handler ? :continue : :fail + end + + @error_handler ||= DEFAULT_ERROR_HANDLER + @validator = opts.fetch(:validator, DEFAULT_VALIDATOR) + @current = Concurrent::AtomicReference.new(initial) + @error = Concurrent::AtomicReference.new(nil) + @caller = Concurrent::ThreadLocalVar.new(nil) + @queue = [] + + self.observers = Collection::CopyOnNotifyObserverSet.new + end + + def enqueue_action_job(action, args, executor) + raise ArgumentError.new('no action given') unless action + job = Job.new(action, args, executor, @caller.value || Thread.current.object_id) + synchronize { ns_enqueue_job(job) } + end + + def enqueue_await_job(latch) + synchronize do + if (index = ns_find_last_job_for_thread) + job = Job.new(AWAIT_ACTION, [latch], Concurrent.global_immediate_executor, + Thread.current.object_id) + ns_enqueue_job(job, index+1) + else + latch.count_down + true + end + end + end + + def ns_enqueue_job(job, index = nil) + # a non-nil index means this is an await job + return false if index.nil? && failed? + index ||= @queue.length + @queue.insert(index, job) + # if this is the only job, post to executor + ns_post_next_job if @queue.length == 1 + true + end + + def ns_post_next_job + @queue.first.executor.post { execute_next_job } + end + + def execute_next_job + job = synchronize { @queue.first } + old_value = @current.value + + @caller.value = job.caller # for nested actions + new_value = job.action.call(old_value, *job.args) + @caller.value = nil + + return if new_value == AWAIT_FLAG + + if ns_validate(new_value) + @current.value = new_value + observers.notify_observers(Time.now, old_value, new_value) + else + handle_error(ValidationError.new) + end + rescue => error + handle_error(error) + ensure + synchronize do + @queue.shift + unless failed? || @queue.empty? + ns_post_next_job + end + end + end + + def ns_validate(value) + @validator.call(value) + rescue + false + end + + def handle_error(error) + # stop new jobs from posting + @error.value = error if @error_mode == :fail + @error_handler.call(self, error) + rescue + # do nothing + end + + def ns_find_last_job_for_thread + @queue.rindex { |job| job.caller == Thread.current.object_id } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/array.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/array.rb new file mode 100644 index 0000000..c8761af --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/array.rb @@ -0,0 +1,56 @@ +require 'concurrent/utility/engine' +require 'concurrent/thread_safe/util' + +module Concurrent + + # @!macro concurrent_array + # + # A thread-safe subclass of Array. This version locks against the object + # itself for every method call, ensuring only one thread can be reading + # or writing at a time. This includes iteration methods like `#each`. + # + # @note `a += b` is **not** a **thread-safe** operation on + # `Concurrent::Array`. It reads array `a`, then it creates new `Concurrent::Array` + # which is concatenation of `a` and `b`, then it writes the concatenation to `a`. + # The read and write are independent operations they do not form a single atomic + # operation therefore when two `+=` operations are executed concurrently updates + # may be lost. Use `#concat` instead. + # + # @see http://ruby-doc.org/core/Array.html Ruby standard library `Array` + + # @!macro internal_implementation_note + ArrayImplementation = case + when Concurrent.on_cruby? + # Array is not fully thread-safe on CRuby, see + # https://github.com/ruby-concurrency/concurrent-ruby/issues/929 + # So we will need to add synchronization here + ::Array + + when Concurrent.on_jruby? + require 'jruby/synchronized' + + class JRubyArray < ::Array + include JRuby::Synchronized + end + JRubyArray + + when Concurrent.on_truffleruby? + require 'concurrent/thread_safe/util/data_structures' + + class TruffleRubyArray < ::Array + end + + ThreadSafe::Util.make_synchronized_on_truffleruby TruffleRubyArray + TruffleRubyArray + + else + warn 'Possibly unsupported Ruby implementation' + ::Array + end + private_constant :ArrayImplementation + + # @!macro concurrent_array + class Array < ArrayImplementation + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/async.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/async.rb new file mode 100644 index 0000000..f9f8adf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/async.rb @@ -0,0 +1,449 @@ +require 'concurrent/configuration' +require 'concurrent/ivar' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # A mixin module that provides simple asynchronous behavior to a class, + # turning it into a simple actor. Loosely based on Erlang's + # [gen_server](http://www.erlang.org/doc/man/gen_server.html), but without + # supervision or linking. + # + # A more feature-rich {Concurrent::Actor} is also available when the + # capabilities of `Async` are too limited. + # + # ```cucumber + # Feature: + # As a stateful, plain old Ruby class + # I want safe, asynchronous behavior + # So my long-running methods don't block the main thread + # ``` + # + # The `Async` module is a way to mix simple yet powerful asynchronous + # capabilities into any plain old Ruby object or class, turning each object + # into a simple Actor. Method calls are processed on a background thread. The + # caller is free to perform other actions while processing occurs in the + # background. + # + # Method calls to the asynchronous object are made via two proxy methods: + # `async` (alias `cast`) and `await` (alias `call`). These proxy methods post + # the method call to the object's background thread and return a "future" + # which will eventually contain the result of the method call. + # + # This behavior is loosely patterned after Erlang's `gen_server` behavior. + # When an Erlang module implements the `gen_server` behavior it becomes + # inherently asynchronous. The `start` or `start_link` function spawns a + # process (similar to a thread but much more lightweight and efficient) and + # returns the ID of the process. Using the process ID, other processes can + # send messages to the `gen_server` via the `cast` and `call` methods. Unlike + # Erlang's `gen_server`, however, `Async` classes do not support linking or + # supervision trees. + # + # ## Basic Usage + # + # When this module is mixed into a class, objects of the class become inherently + # asynchronous. Each object gets its own background thread on which to post + # asynchronous method calls. Asynchronous method calls are executed in the + # background one at a time in the order they are received. + # + # To create an asynchronous class, simply mix in the `Concurrent::Async` module: + # + # ``` + # class Hello + # include Concurrent::Async + # + # def hello(name) + # "Hello, #{name}!" + # end + # end + # ``` + # + # Mixing this module into a class provides each object two proxy methods: + # `async` and `await`. These methods are thread safe with respect to the + # enclosing object. The former proxy allows methods to be called + # asynchronously by posting to the object's internal thread. The latter proxy + # allows a method to be called synchronously but does so safely with respect + # to any pending asynchronous method calls and ensures proper ordering. Both + # methods return a {Concurrent::IVar} which can be inspected for the result + # of the proxied method call. Calling a method with `async` will return a + # `:pending` `IVar` whereas `await` will return a `:complete` `IVar`. + # + # ``` + # class Echo + # include Concurrent::Async + # + # def echo(msg) + # print "#{msg}\n" + # end + # end + # + # horn = Echo.new + # horn.echo('zero') # synchronous, not thread-safe + # # returns the actual return value of the method + # + # horn.async.echo('one') # asynchronous, non-blocking, thread-safe + # # returns an IVar in the :pending state + # + # horn.await.echo('two') # synchronous, blocking, thread-safe + # # returns an IVar in the :complete state + # ``` + # + # ## Let It Fail + # + # The `async` and `await` proxy methods have built-in error protection based + # on Erlang's famous "let it fail" philosophy. Instance methods should not be + # programmed defensively. When an exception is raised by a delegated method + # the proxy will rescue the exception, expose it to the caller as the `reason` + # attribute of the returned future, then process the next method call. + # + # ## Calling Methods Internally + # + # External method calls should *always* use the `async` and `await` proxy + # methods. When one method calls another method, the `async` proxy should + # rarely be used and the `await` proxy should *never* be used. + # + # When an object calls one of its own methods using the `await` proxy the + # second call will be enqueued *behind* the currently running method call. + # Any attempt to wait on the result will fail as the second call will never + # run until after the current call completes. + # + # Calling a method using the `await` proxy from within a method that was + # itself called using `async` or `await` will irreversibly deadlock the + # object. Do *not* do this, ever. + # + # ## Instance Variables and Attribute Accessors + # + # Instance variables do not need to be thread-safe so long as they are private. + # Asynchronous method calls are processed in the order they are received and + # are processed one at a time. Therefore private instance variables can only + # be accessed by one thread at a time. This is inherently thread-safe. + # + # When using private instance variables within asynchronous methods, the best + # practice is to read the instance variable into a local variable at the start + # of the method then update the instance variable at the *end* of the method. + # This way, should an exception be raised during method execution the internal + # state of the object will not have been changed. + # + # ### Reader Attributes + # + # The use of `attr_reader` is discouraged. Internal state exposed externally, + # when necessary, should be done through accessor methods. The instance + # variables exposed by these methods *must* be thread-safe, or they must be + # called using the `async` and `await` proxy methods. These two approaches are + # subtly different. + # + # When internal state is accessed via the `async` and `await` proxy methods, + # the returned value represents the object's state *at the time the call is + # processed*, which may *not* be the state of the object at the time the call + # is made. + # + # To get the state *at the current* time, irrespective of an enqueued method + # calls, a reader method must be called directly. This is inherently unsafe + # unless the instance variable is itself thread-safe, preferably using one + # of the thread-safe classes within this library. Because the thread-safe + # classes within this library are internally-locking or non-locking, they can + # be safely used from within asynchronous methods without causing deadlocks. + # + # Generally speaking, the best practice is to *not* expose internal state via + # reader methods. The best practice is to simply use the method's return value. + # + # ### Writer Attributes + # + # Writer attributes should never be used with asynchronous classes. Changing + # the state externally, even when done in the thread-safe way, is not logically + # consistent. Changes to state need to be timed with respect to all asynchronous + # method calls which my be in-process or enqueued. The only safe practice is to + # pass all necessary data to each method as arguments and let the method update + # the internal state as necessary. + # + # ## Class Constants, Variables, and Methods + # + # ### Class Constants + # + # Class constants do not need to be thread-safe. Since they are read-only and + # immutable they may be safely read both externally and from within + # asynchronous methods. + # + # ### Class Variables + # + # Class variables should be avoided. Class variables represent shared state. + # Shared state is anathema to concurrency. Should there be a need to share + # state using class variables they *must* be thread-safe, preferably + # using the thread-safe classes within this library. When updating class + # variables, never assign a new value/object to the variable itself. Assignment + # is not thread-safe in Ruby. Instead, use the thread-safe update functions + # of the variable itself to change the value. + # + # The best practice is to *never* use class variables with `Async` classes. + # + # ### Class Methods + # + # Class methods which are pure functions are safe. Class methods which modify + # class variables should be avoided, for all the reasons listed above. + # + # ## An Important Note About Thread Safe Guarantees + # + # > Thread safe guarantees can only be made when asynchronous method calls + # > are not mixed with direct method calls. Use only direct method calls + # > when the object is used exclusively on a single thread. Use only + # > `async` and `await` when the object is shared between threads. Once you + # > call a method using `async` or `await`, you should no longer call methods + # > directly on the object. Use `async` and `await` exclusively from then on. + # + # @example + # + # class Echo + # include Concurrent::Async + # + # def echo(msg) + # print "#{msg}\n" + # end + # end + # + # horn = Echo.new + # horn.echo('zero') # synchronous, not thread-safe + # # returns the actual return value of the method + # + # horn.async.echo('one') # asynchronous, non-blocking, thread-safe + # # returns an IVar in the :pending state + # + # horn.await.echo('two') # synchronous, blocking, thread-safe + # # returns an IVar in the :complete state + # + # @see Concurrent::Actor + # @see https://en.wikipedia.org/wiki/Actor_model "Actor Model" at Wikipedia + # @see http://www.erlang.org/doc/man/gen_server.html Erlang gen_server + # @see http://c2.com/cgi/wiki?LetItCrash "Let It Crash" at http://c2.com/ + module Async + + # @!method self.new(*args, &block) + # + # Instanciate a new object and ensure proper initialization of the + # synchronization mechanisms. + # + # @param [Array] args Zero or more arguments to be passed to the + # object's initializer. + # @param [Proc] block Optional block to pass to the object's initializer. + # @return [Object] A properly initialized object of the asynchronous class. + + # Check for the presence of a method on an object and determine if a given + # set of arguments matches the required arity. + # + # @param [Object] obj the object to check against + # @param [Symbol] method the method to check the object for + # @param [Array] args zero or more arguments for the arity check + # + # @raise [NameError] the object does not respond to `method` method + # @raise [ArgumentError] the given `args` do not match the arity of `method` + # + # @note This check is imperfect because of the way Ruby reports the arity of + # methods with a variable number of arguments. It is possible to determine + # if too few arguments are given but impossible to determine if too many + # arguments are given. This check may also fail to recognize dynamic behavior + # of the object, such as methods simulated with `method_missing`. + # + # @see http://www.ruby-doc.org/core-2.1.1/Method.html#method-i-arity Method#arity + # @see http://ruby-doc.org/core-2.1.0/Object.html#method-i-respond_to-3F Object#respond_to? + # @see http://www.ruby-doc.org/core-2.1.0/BasicObject.html#method-i-method_missing BasicObject#method_missing + # + # @!visibility private + def self.validate_argc(obj, method, *args) + argc = args.length + arity = obj.method(method).arity + + if arity >= 0 && argc != arity + raise ArgumentError.new("wrong number of arguments (#{argc} for #{arity})") + elsif arity < 0 && (arity = (arity + 1).abs) > argc + raise ArgumentError.new("wrong number of arguments (#{argc} for #{arity}..*)") + end + end + + # @!visibility private + def self.included(base) + base.singleton_class.send(:alias_method, :original_new, :new) + base.extend(ClassMethods) + super(base) + end + + # @!visibility private + module ClassMethods + def new(*args, &block) + obj = original_new(*args, &block) + obj.send(:init_synchronization) + obj + end + ruby2_keywords :new if respond_to?(:ruby2_keywords, true) + end + private_constant :ClassMethods + + # Delegates asynchronous, thread-safe method calls to the wrapped object. + # + # @!visibility private + class AsyncDelegator < Synchronization::LockableObject + safe_initialization! + + # Create a new delegator object wrapping the given delegate. + # + # @param [Object] delegate the object to wrap and delegate method calls to + def initialize(delegate) + super() + @delegate = delegate + @queue = [] + @executor = Concurrent.global_io_executor + @ruby_pid = $$ + end + + # Delegates method calls to the wrapped object. + # + # @param [Symbol] method the method being called + # @param [Array] args zero or more arguments to the method + # + # @return [IVar] the result of the method call + # + # @raise [NameError] the object does not respond to `method` method + # @raise [ArgumentError] the given `args` do not match the arity of `method` + def method_missing(method, *args, &block) + super unless @delegate.respond_to?(method) + Async::validate_argc(@delegate, method, *args) + + ivar = Concurrent::IVar.new + synchronize do + reset_if_forked + @queue.push [ivar, method, args, block] + @executor.post { perform } if @queue.length == 1 + end + + ivar + end + + # Check whether the method is responsive + # + # @param [Symbol] method the method being called + def respond_to_missing?(method, include_private = false) + @delegate.respond_to?(method) || super + end + + # Perform all enqueued tasks. + # + # This method must be called from within the executor. It must not be + # called while already running. It will loop until the queue is empty. + def perform + loop do + ivar, method, args, block = synchronize { @queue.first } + break unless ivar # queue is empty + + begin + ivar.set(@delegate.send(method, *args, &block)) + rescue => error + ivar.fail(error) + end + + synchronize do + @queue.shift + return if @queue.empty? + end + end + end + + def reset_if_forked + if $$ != @ruby_pid + @queue.clear + @ruby_pid = $$ + end + end + end + private_constant :AsyncDelegator + + # Delegates synchronous, thread-safe method calls to the wrapped object. + # + # @!visibility private + class AwaitDelegator + + # Create a new delegator object wrapping the given delegate. + # + # @param [AsyncDelegator] delegate the object to wrap and delegate method calls to + def initialize(delegate) + @delegate = delegate + end + + # Delegates method calls to the wrapped object. + # + # @param [Symbol] method the method being called + # @param [Array] args zero or more arguments to the method + # + # @return [IVar] the result of the method call + # + # @raise [NameError] the object does not respond to `method` method + # @raise [ArgumentError] the given `args` do not match the arity of `method` + def method_missing(method, *args, &block) + ivar = @delegate.send(method, *args, &block) + ivar.wait + ivar + end + + # Check whether the method is responsive + # + # @param [Symbol] method the method being called + def respond_to_missing?(method, include_private = false) + @delegate.respond_to?(method) || super + end + end + private_constant :AwaitDelegator + + # Causes the chained method call to be performed asynchronously on the + # object's thread. The delegated method will return a future in the + # `:pending` state and the method call will have been scheduled on the + # object's thread. The final disposition of the method call can be obtained + # by inspecting the returned future. + # + # @!macro async_thread_safety_warning + # @note The method call is guaranteed to be thread safe with respect to + # all other method calls against the same object that are called with + # either `async` or `await`. The mutable nature of Ruby references + # (and object orientation in general) prevent any other thread safety + # guarantees. Do NOT mix direct method calls with delegated method calls. + # Use *only* delegated method calls when sharing the object between threads. + # + # @return [Concurrent::IVar] the pending result of the asynchronous operation + # + # @raise [NameError] the object does not respond to the requested method + # @raise [ArgumentError] the given `args` do not match the arity of + # the requested method + def async + @__async_delegator__ + end + alias_method :cast, :async + + # Causes the chained method call to be performed synchronously on the + # current thread. The delegated will return a future in either the + # `:fulfilled` or `:rejected` state and the delegated method will have + # completed. The final disposition of the delegated method can be obtained + # by inspecting the returned future. + # + # @!macro async_thread_safety_warning + # + # @return [Concurrent::IVar] the completed result of the synchronous operation + # + # @raise [NameError] the object does not respond to the requested method + # @raise [ArgumentError] the given `args` do not match the arity of the + # requested method + def await + @__await_delegator__ + end + alias_method :call, :await + + # Initialize the internal serializer and other stnchronization mechanisms. + # + # @note This method *must* be called immediately upon object construction. + # This is the only way thread-safe initialization can be guaranteed. + # + # @!visibility private + def init_synchronization + return self if defined?(@__async_initialized__) && @__async_initialized__ + @__async_initialized__ = true + @__async_delegator__ = AsyncDelegator.new(self) + @__await_delegator__ = AwaitDelegator.new(@__async_delegator__) + self + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atom.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atom.rb new file mode 100644 index 0000000..1074006 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atom.rb @@ -0,0 +1,222 @@ +require 'concurrent/atomic/atomic_reference' +require 'concurrent/collection/copy_on_notify_observer_set' +require 'concurrent/concern/observable' +require 'concurrent/synchronization/object' + +# @!macro thread_safe_variable_comparison +# +# ## Thread-safe Variable Classes +# +# Each of the thread-safe variable classes is designed to solve a different +# problem. In general: +# +# * *{Concurrent::Agent}:* Shared, mutable variable providing independent, +# uncoordinated, *asynchronous* change of individual values. Best used when +# the value will undergo frequent, complex updates. Suitable when the result +# of an update does not need to be known immediately. +# * *{Concurrent::Atom}:* Shared, mutable variable providing independent, +# uncoordinated, *synchronous* change of individual values. Best used when +# the value will undergo frequent reads but only occasional, though complex, +# updates. Suitable when the result of an update must be known immediately. +# * *{Concurrent::AtomicReference}:* A simple object reference that can be updated +# atomically. Updates are synchronous but fast. Best used when updates a +# simple set operations. Not suitable when updates are complex. +# {Concurrent::AtomicBoolean} and {Concurrent::AtomicFixnum} are similar +# but optimized for the given data type. +# * *{Concurrent::Exchanger}:* Shared, stateless synchronization point. Used +# when two or more threads need to exchange data. The threads will pair then +# block on each other until the exchange is complete. +# * *{Concurrent::MVar}:* Shared synchronization point. Used when one thread +# must give a value to another, which must take the value. The threads will +# block on each other until the exchange is complete. +# * *{Concurrent::ThreadLocalVar}:* Shared, mutable, isolated variable which +# holds a different value for each thread which has access. Often used as +# an instance variable in objects which must maintain different state +# for different threads. +# * *{Concurrent::TVar}:* Shared, mutable variables which provide +# *coordinated*, *synchronous*, change of *many* stated. Used when multiple +# value must change together, in an all-or-nothing transaction. + + +module Concurrent + + # Atoms provide a way to manage shared, synchronous, independent state. + # + # An atom is initialized with an initial value and an optional validation + # proc. At any time the value of the atom can be synchronously and safely + # changed. If a validator is given at construction then any new value + # will be checked against the validator and will be rejected if the + # validator returns false or raises an exception. + # + # There are two ways to change the value of an atom: {#compare_and_set} and + # {#swap}. The former will set the new value if and only if it validates and + # the current value matches the new value. The latter will atomically set the + # new value to the result of running the given block if and only if that + # value validates. + # + # ## Example + # + # ``` + # def next_fibonacci(set = nil) + # return [0, 1] if set.nil? + # set + [set[-2..-1].reduce{|sum,x| sum + x }] + # end + # + # # create an atom with an initial value + # atom = Concurrent::Atom.new(next_fibonacci) + # + # # send a few update requests + # 5.times do + # atom.swap{|set| next_fibonacci(set) } + # end + # + # # get the current value + # atom.value #=> [0, 1, 1, 2, 3, 5, 8] + # ``` + # + # ## Observation + # + # Atoms support observers through the {Concurrent::Observable} mixin module. + # Notification of observers occurs every time the value of the Atom changes. + # When notified the observer will receive three arguments: `time`, `old_value`, + # and `new_value`. The `time` argument is the time at which the value change + # occurred. The `old_value` is the value of the Atom when the change began + # The `new_value` is the value to which the Atom was set when the change + # completed. Note that `old_value` and `new_value` may be the same. This is + # not an error. It simply means that the change operation returned the same + # value. + # + # Unlike in Clojure, `Atom` cannot participate in {Concurrent::TVar} transactions. + # + # @!macro thread_safe_variable_comparison + # + # @see http://clojure.org/atoms Clojure Atoms + # @see http://clojure.org/state Values and Change - Clojure's approach to Identity and State + class Atom < Synchronization::Object + include Concern::Observable + + safe_initialization! + attr_atomic(:value) + private :value=, :swap_value, :compare_and_set_value, :update_value + public :value + alias_method :deref, :value + + # @!method value + # The current value of the atom. + # + # @return [Object] The current value. + + # Create a new atom with the given initial value. + # + # @param [Object] value The initial value + # @param [Hash] opts The options used to configure the atom + # @option opts [Proc] :validator (nil) Optional proc used to validate new + # values. It must accept one and only one argument which will be the + # intended new value. The validator will return true if the new value + # is acceptable else return false (preferrably) or raise an exception. + # + # @!macro deref_options + # + # @raise [ArgumentError] if the validator is not a `Proc` (when given) + def initialize(value, opts = {}) + super() + @Validator = opts.fetch(:validator, -> v { true }) + self.observers = Collection::CopyOnNotifyObserverSet.new + self.value = value + end + + # Atomically swaps the value of atom using the given block. The current + # value will be passed to the block, as will any arguments passed as + # arguments to the function. The new value will be validated against the + # (optional) validator proc given at construction. If validation fails the + # value will not be changed. + # + # Internally, {#swap} reads the current value, applies the block to it, and + # attempts to compare-and-set it in. Since another thread may have changed + # the value in the intervening time, it may have to retry, and does so in a + # spin loop. The net effect is that the value will always be the result of + # the application of the supplied block to a current value, atomically. + # However, because the block might be called multiple times, it must be free + # of side effects. + # + # @note The given block may be called multiple times, and thus should be free + # of side effects. + # + # @param [Object] args Zero or more arguments passed to the block. + # + # @yield [value, args] Calculates a new value for the atom based on the + # current value and any supplied arguments. + # @yieldparam value [Object] The current value of the atom. + # @yieldparam args [Object] All arguments passed to the function, in order. + # @yieldreturn [Object] The intended new value of the atom. + # + # @return [Object] The final value of the atom after all operations and + # validations are complete. + # + # @raise [ArgumentError] When no block is given. + def swap(*args) + raise ArgumentError.new('no block given') unless block_given? + + loop do + old_value = value + new_value = yield(old_value, *args) + begin + break old_value unless valid?(new_value) + break new_value if compare_and_set(old_value, new_value) + rescue + break old_value + end + end + end + + # Atomically sets the value of atom to the new value if and only if the + # current value of the atom is identical to the old value and the new + # value successfully validates against the (optional) validator given + # at construction. + # + # @param [Object] old_value The expected current value. + # @param [Object] new_value The intended new value. + # + # @return [Boolean] True if the value is changed else false. + def compare_and_set(old_value, new_value) + if valid?(new_value) && compare_and_set_value(old_value, new_value) + observers.notify_observers(Time.now, old_value, new_value) + true + else + false + end + end + + # Atomically sets the value of atom to the new value without regard for the + # current value so long as the new value successfully validates against the + # (optional) validator given at construction. + # + # @param [Object] new_value The intended new value. + # + # @return [Object] The final value of the atom after all operations and + # validations are complete. + def reset(new_value) + old_value = value + if valid?(new_value) + self.value = new_value + observers.notify_observers(Time.now, old_value, new_value) + new_value + else + old_value + end + end + + private + + # Is the new value valid? + # + # @param [Object] new_value The intended new value. + # @return [Boolean] false if the validator function returns false or raises + # an exception else true + def valid?(new_value) + @Validator.call(new_value) + rescue + false + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_boolean.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_boolean.rb new file mode 100644 index 0000000..f775691 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_boolean.rb @@ -0,0 +1,127 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first + +require 'concurrent/atomic/mutex_atomic_boolean' + +module Concurrent + + ################################################################### + + # @!macro atomic_boolean_method_initialize + # + # Creates a new `AtomicBoolean` with the given initial value. + # + # @param [Boolean] initial the initial value + + # @!macro atomic_boolean_method_value_get + # + # Retrieves the current `Boolean` value. + # + # @return [Boolean] the current value + + # @!macro atomic_boolean_method_value_set + # + # Explicitly sets the value. + # + # @param [Boolean] value the new value to be set + # + # @return [Boolean] the current value + + # @!macro atomic_boolean_method_true_question + # + # Is the current value `true` + # + # @return [Boolean] true if the current value is `true`, else false + + # @!macro atomic_boolean_method_false_question + # + # Is the current value `false` + # + # @return [Boolean] true if the current value is `false`, else false + + # @!macro atomic_boolean_method_make_true + # + # Explicitly sets the value to true. + # + # @return [Boolean] true if value has changed, otherwise false + + # @!macro atomic_boolean_method_make_false + # + # Explicitly sets the value to false. + # + # @return [Boolean] true if value has changed, otherwise false + + ################################################################### + + # @!macro atomic_boolean_public_api + # + # @!method initialize(initial = false) + # @!macro atomic_boolean_method_initialize + # + # @!method value + # @!macro atomic_boolean_method_value_get + # + # @!method value=(value) + # @!macro atomic_boolean_method_value_set + # + # @!method true? + # @!macro atomic_boolean_method_true_question + # + # @!method false? + # @!macro atomic_boolean_method_false_question + # + # @!method make_true + # @!macro atomic_boolean_method_make_true + # + # @!method make_false + # @!macro atomic_boolean_method_make_false + + ################################################################### + + # @!visibility private + # @!macro internal_implementation_note + AtomicBooleanImplementation = case + when Concurrent.on_cruby? && Concurrent.c_extensions_loaded? + CAtomicBoolean + when Concurrent.on_jruby? + JavaAtomicBoolean + else + MutexAtomicBoolean + end + private_constant :AtomicBooleanImplementation + + # @!macro atomic_boolean + # + # A boolean value that can be updated atomically. Reads and writes to an atomic + # boolean and thread-safe and guaranteed to succeed. Reads and writes may block + # briefly but no explicit locking is required. + # + # @!macro thread_safe_variable_comparison + # + # Performance: + # + # ``` + # Testing with ruby 2.1.2 + # Testing with Concurrent::MutexAtomicBoolean... + # 2.790000 0.000000 2.790000 ( 2.791454) + # Testing with Concurrent::CAtomicBoolean... + # 0.740000 0.000000 0.740000 ( 0.740206) + # + # Testing with jruby 1.9.3 + # Testing with Concurrent::MutexAtomicBoolean... + # 5.240000 2.520000 7.760000 ( 3.683000) + # Testing with Concurrent::JavaAtomicBoolean... + # 3.340000 0.010000 3.350000 ( 0.855000) + # ``` + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicBoolean.html java.util.concurrent.atomic.AtomicBoolean + # + # @!macro atomic_boolean_public_api + class AtomicBoolean < AtomicBooleanImplementation + # @return [String] Short string representation. + def to_s + format '%s value:%s>', super[0..-2], value + end + + alias_method :inspect, :to_s + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_fixnum.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_fixnum.rb new file mode 100644 index 0000000..26cd05d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_fixnum.rb @@ -0,0 +1,144 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first + +require 'concurrent/atomic/mutex_atomic_fixnum' + +module Concurrent + + ################################################################### + + # @!macro atomic_fixnum_method_initialize + # + # Creates a new `AtomicFixnum` with the given initial value. + # + # @param [Fixnum] initial the initial value + # @raise [ArgumentError] if the initial value is not a `Fixnum` + + # @!macro atomic_fixnum_method_value_get + # + # Retrieves the current `Fixnum` value. + # + # @return [Fixnum] the current value + + # @!macro atomic_fixnum_method_value_set + # + # Explicitly sets the value. + # + # @param [Fixnum] value the new value to be set + # + # @return [Fixnum] the current value + # + # @raise [ArgumentError] if the new value is not a `Fixnum` + + # @!macro atomic_fixnum_method_increment + # + # Increases the current value by the given amount (defaults to 1). + # + # @param [Fixnum] delta the amount by which to increase the current value + # + # @return [Fixnum] the current value after incrementation + + # @!macro atomic_fixnum_method_decrement + # + # Decreases the current value by the given amount (defaults to 1). + # + # @param [Fixnum] delta the amount by which to decrease the current value + # + # @return [Fixnum] the current value after decrementation + + # @!macro atomic_fixnum_method_compare_and_set + # + # Atomically sets the value to the given updated value if the current + # value == the expected value. + # + # @param [Fixnum] expect the expected value + # @param [Fixnum] update the new value + # + # @return [Boolean] true if the value was updated else false + + # @!macro atomic_fixnum_method_update + # + # Pass the current value to the given block, replacing it + # with the block's result. May retry if the value changes + # during the block's execution. + # + # @yield [Object] Calculate a new value for the atomic reference using + # given (old) value + # @yieldparam [Object] old_value the starting value of the atomic reference + # + # @return [Object] the new value + + ################################################################### + + # @!macro atomic_fixnum_public_api + # + # @!method initialize(initial = 0) + # @!macro atomic_fixnum_method_initialize + # + # @!method value + # @!macro atomic_fixnum_method_value_get + # + # @!method value=(value) + # @!macro atomic_fixnum_method_value_set + # + # @!method increment(delta = 1) + # @!macro atomic_fixnum_method_increment + # + # @!method decrement(delta = 1) + # @!macro atomic_fixnum_method_decrement + # + # @!method compare_and_set(expect, update) + # @!macro atomic_fixnum_method_compare_and_set + # + # @!method update + # @!macro atomic_fixnum_method_update + + ################################################################### + + # @!visibility private + # @!macro internal_implementation_note + AtomicFixnumImplementation = case + when Concurrent.on_cruby? && Concurrent.c_extensions_loaded? + CAtomicFixnum + when Concurrent.on_jruby? + JavaAtomicFixnum + else + MutexAtomicFixnum + end + private_constant :AtomicFixnumImplementation + + # @!macro atomic_fixnum + # + # A numeric value that can be updated atomically. Reads and writes to an atomic + # fixnum and thread-safe and guaranteed to succeed. Reads and writes may block + # briefly but no explicit locking is required. + # + # @!macro thread_safe_variable_comparison + # + # Performance: + # + # ``` + # Testing with ruby 2.1.2 + # Testing with Concurrent::MutexAtomicFixnum... + # 3.130000 0.000000 3.130000 ( 3.136505) + # Testing with Concurrent::CAtomicFixnum... + # 0.790000 0.000000 0.790000 ( 0.785550) + # + # Testing with jruby 1.9.3 + # Testing with Concurrent::MutexAtomicFixnum... + # 5.460000 2.460000 7.920000 ( 3.715000) + # Testing with Concurrent::JavaAtomicFixnum... + # 4.520000 0.030000 4.550000 ( 1.187000) + # ``` + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicLong.html java.util.concurrent.atomic.AtomicLong + # + # @!macro atomic_fixnum_public_api + class AtomicFixnum < AtomicFixnumImplementation + # @return [String] Short string representation. + def to_s + format '%s value:%s>', super[0..-2], value + end + + alias_method :inspect, :to_s + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_markable_reference.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_markable_reference.rb new file mode 100644 index 0000000..e16be65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_markable_reference.rb @@ -0,0 +1,167 @@ +require 'concurrent/errors' +require 'concurrent/synchronization/object' + +module Concurrent + # An atomic reference which maintains an object reference along with a mark bit + # that can be updated atomically. + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicMarkableReference.html + # java.util.concurrent.atomic.AtomicMarkableReference + class AtomicMarkableReference < ::Concurrent::Synchronization::Object + + attr_atomic(:reference) + private :reference, :reference=, :swap_reference, :compare_and_set_reference, :update_reference + + def initialize(value = nil, mark = false) + super() + self.reference = immutable_array(value, mark) + end + + # Atomically sets the value and mark to the given updated value and + # mark given both: + # - the current value == the expected value && + # - the current mark == the expected mark + # + # @param [Object] expected_val the expected value + # @param [Object] new_val the new value + # @param [Boolean] expected_mark the expected mark + # @param [Boolean] new_mark the new mark + # + # @return [Boolean] `true` if successful. A `false` return indicates + # that the actual value was not equal to the expected value or the + # actual mark was not equal to the expected mark + def compare_and_set(expected_val, new_val, expected_mark, new_mark) + # Memoize a valid reference to the current AtomicReference for + # later comparison. + current = reference + curr_val, curr_mark = current + + # Ensure that that the expected marks match. + return false unless expected_mark == curr_mark + + if expected_val.is_a? Numeric + # If the object is a numeric, we need to ensure we are comparing + # the numerical values + return false unless expected_val == curr_val + else + # Otherwise, we need to ensure we are comparing the object identity. + # Theoretically, this could be incorrect if a user monkey-patched + # `Object#equal?`, but they should know that they are playing with + # fire at that point. + return false unless expected_val.equal? curr_val + end + + prospect = immutable_array(new_val, new_mark) + + compare_and_set_reference current, prospect + end + + alias_method :compare_and_swap, :compare_and_set + + # Gets the current reference and marked values. + # + # @return [Array] the current reference and marked values + def get + reference + end + + # Gets the current value of the reference + # + # @return [Object] the current value of the reference + def value + reference[0] + end + + # Gets the current marked value + # + # @return [Boolean] the current marked value + def mark + reference[1] + end + + alias_method :marked?, :mark + + # _Unconditionally_ sets to the given value of both the reference and + # the mark. + # + # @param [Object] new_val the new value + # @param [Boolean] new_mark the new mark + # + # @return [Array] both the new value and the new mark + def set(new_val, new_mark) + self.reference = immutable_array(new_val, new_mark) + end + + # Pass the current value and marked state to the given block, replacing it + # with the block's results. May retry if the value changes during the + # block's execution. + # + # @yield [Object] Calculate a new value and marked state for the atomic + # reference using given (old) value and (old) marked + # @yieldparam [Object] old_val the starting value of the atomic reference + # @yieldparam [Boolean] old_mark the starting state of marked + # + # @return [Array] the new value and new mark + def update + loop do + old_val, old_mark = reference + new_val, new_mark = yield old_val, old_mark + + if compare_and_set old_val, new_val, old_mark, new_mark + return immutable_array(new_val, new_mark) + end + end + end + + # Pass the current value to the given block, replacing it + # with the block's result. Raise an exception if the update + # fails. + # + # @yield [Object] Calculate a new value and marked state for the atomic + # reference using given (old) value and (old) marked + # @yieldparam [Object] old_val the starting value of the atomic reference + # @yieldparam [Boolean] old_mark the starting state of marked + # + # @return [Array] the new value and marked state + # + # @raise [Concurrent::ConcurrentUpdateError] if the update fails + def try_update! + old_val, old_mark = reference + new_val, new_mark = yield old_val, old_mark + + unless compare_and_set old_val, new_val, old_mark, new_mark + fail ::Concurrent::ConcurrentUpdateError, + 'AtomicMarkableReference: Update failed due to race condition.', + 'Note: If you would like to guarantee an update, please use ' + + 'the `AtomicMarkableReference#update` method.' + end + + immutable_array(new_val, new_mark) + end + + # Pass the current value to the given block, replacing it with the + # block's result. Simply return nil if update fails. + # + # @yield [Object] Calculate a new value and marked state for the atomic + # reference using given (old) value and (old) marked + # @yieldparam [Object] old_val the starting value of the atomic reference + # @yieldparam [Boolean] old_mark the starting state of marked + # + # @return [Array] the new value and marked state, or nil if + # the update failed + def try_update + old_val, old_mark = reference + new_val, new_mark = yield old_val, old_mark + + return unless compare_and_set old_val, new_val, old_mark, new_mark + + immutable_array(new_val, new_mark) + end + + private + + def immutable_array(*args) + args.freeze + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb new file mode 100644 index 0000000..bb5fb77 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb @@ -0,0 +1,135 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first + +require 'concurrent/atomic_reference/atomic_direct_update' +require 'concurrent/atomic_reference/numeric_cas_wrapper' +require 'concurrent/atomic_reference/mutex_atomic' + +# Shim for TruffleRuby::AtomicReference +if Concurrent.on_truffleruby? && !defined?(TruffleRuby::AtomicReference) + # @!visibility private + module TruffleRuby + AtomicReference = Truffle::AtomicReference + end +end + +module Concurrent + + # @!macro internal_implementation_note + AtomicReferenceImplementation = case + when Concurrent.on_cruby? && Concurrent.c_extensions_loaded? + # @!visibility private + # @!macro internal_implementation_note + class CAtomicReference + include AtomicDirectUpdate + include AtomicNumericCompareAndSetWrapper + alias_method :compare_and_swap, :compare_and_set + end + CAtomicReference + when Concurrent.on_jruby? + # @!visibility private + # @!macro internal_implementation_note + class JavaAtomicReference + include AtomicDirectUpdate + end + JavaAtomicReference + when Concurrent.on_truffleruby? + class TruffleRubyAtomicReference < TruffleRuby::AtomicReference + include AtomicDirectUpdate + alias_method :value, :get + alias_method :value=, :set + alias_method :compare_and_swap, :compare_and_set + alias_method :swap, :get_and_set + end + TruffleRubyAtomicReference + else + MutexAtomicReference + end + private_constant :AtomicReferenceImplementation + + # An object reference that may be updated atomically. All read and write + # operations have java volatile semantic. + # + # @!macro thread_safe_variable_comparison + # + # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html + # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/package-summary.html + # + # @!method initialize(value = nil) + # @!macro atomic_reference_method_initialize + # @param [Object] value The initial value. + # + # @!method get + # @!macro atomic_reference_method_get + # Gets the current value. + # @return [Object] the current value + # + # @!method set(new_value) + # @!macro atomic_reference_method_set + # Sets to the given value. + # @param [Object] new_value the new value + # @return [Object] the new value + # + # @!method get_and_set(new_value) + # @!macro atomic_reference_method_get_and_set + # Atomically sets to the given value and returns the old value. + # @param [Object] new_value the new value + # @return [Object] the old value + # + # @!method compare_and_set(old_value, new_value) + # @!macro atomic_reference_method_compare_and_set + # + # Atomically sets the value to the given updated value if + # the current value == the expected value. + # + # @param [Object] old_value the expected value + # @param [Object] new_value the new value + # + # @return [Boolean] `true` if successful. A `false` return indicates + # that the actual value was not equal to the expected value. + # + # @!method update + # Pass the current value to the given block, replacing it + # with the block's result. May retry if the value changes + # during the block's execution. + # + # @yield [Object] Calculate a new value for the atomic reference using + # given (old) value + # @yieldparam [Object] old_value the starting value of the atomic reference + # @return [Object] the new value + # + # @!method try_update + # Pass the current value to the given block, replacing it + # with the block's result. Return nil if the update fails. + # + # @yield [Object] Calculate a new value for the atomic reference using + # given (old) value + # @yieldparam [Object] old_value the starting value of the atomic reference + # @note This method was altered to avoid raising an exception by default. + # Instead, this method now returns `nil` in case of failure. For more info, + # please see: https://github.com/ruby-concurrency/concurrent-ruby/pull/336 + # @return [Object] the new value, or nil if update failed + # + # @!method try_update! + # Pass the current value to the given block, replacing it + # with the block's result. Raise an exception if the update + # fails. + # + # @yield [Object] Calculate a new value for the atomic reference using + # given (old) value + # @yieldparam [Object] old_value the starting value of the atomic reference + # @note This behavior mimics the behavior of the original + # `AtomicReference#try_update` API. The reason this was changed was to + # avoid raising exceptions (which are inherently slow) by default. For more + # info: https://github.com/ruby-concurrency/concurrent-ruby/pull/336 + # @return [Object] the new value + # @raise [Concurrent::ConcurrentUpdateError] if the update fails + class AtomicReference < AtomicReferenceImplementation + + # @return [String] Short string representation. + def to_s + format '%s value:%s>', super[0..-2], get + end + + alias_method :inspect, :to_s + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/count_down_latch.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/count_down_latch.rb new file mode 100644 index 0000000..d883aed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/count_down_latch.rb @@ -0,0 +1,100 @@ +require 'concurrent/utility/engine' +require 'concurrent/atomic/mutex_count_down_latch' +require 'concurrent/atomic/java_count_down_latch' + +module Concurrent + + ################################################################### + + # @!macro count_down_latch_method_initialize + # + # Create a new `CountDownLatch` with the initial `count`. + # + # @param [new] count the initial count + # + # @raise [ArgumentError] if `count` is not an integer or is less than zero + + # @!macro count_down_latch_method_wait + # + # Block on the latch until the counter reaches zero or until `timeout` is reached. + # + # @param [Fixnum] timeout the number of seconds to wait for the counter or `nil` + # to block indefinitely + # @return [Boolean] `true` if the `count` reaches zero else false on `timeout` + + # @!macro count_down_latch_method_count_down + # + # Signal the latch to decrement the counter. Will signal all blocked threads when + # the `count` reaches zero. + + # @!macro count_down_latch_method_count + # + # The current value of the counter. + # + # @return [Fixnum] the current value of the counter + + ################################################################### + + # @!macro count_down_latch_public_api + # + # @!method initialize(count = 1) + # @!macro count_down_latch_method_initialize + # + # @!method wait(timeout = nil) + # @!macro count_down_latch_method_wait + # + # @!method count_down + # @!macro count_down_latch_method_count_down + # + # @!method count + # @!macro count_down_latch_method_count + + ################################################################### + + # @!visibility private + # @!macro internal_implementation_note + CountDownLatchImplementation = case + when Concurrent.on_jruby? + JavaCountDownLatch + else + MutexCountDownLatch + end + private_constant :CountDownLatchImplementation + + # @!macro count_down_latch + # + # A synchronization object that allows one thread to wait on multiple other threads. + # The thread that will wait creates a `CountDownLatch` and sets the initial value + # (normally equal to the number of other threads). The initiating thread passes the + # latch to the other threads then waits for the other threads by calling the `#wait` + # method. Each of the other threads calls `#count_down` when done with its work. + # When the latch counter reaches zero the waiting thread is unblocked and continues + # with its work. A `CountDownLatch` can be used only once. Its value cannot be reset. + # + # @!macro count_down_latch_public_api + # @example Waiter and Decrementer + # latch = Concurrent::CountDownLatch.new(3) + # + # waiter = Thread.new do + # latch.wait() + # puts ("Waiter released") + # end + # + # decrementer = Thread.new do + # sleep(1) + # latch.count_down + # puts latch.count + # + # sleep(1) + # latch.count_down + # puts latch.count + # + # sleep(1) + # latch.count_down + # puts latch.count + # end + # + # [waiter, decrementer].each(&:join) + class CountDownLatch < CountDownLatchImplementation + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/cyclic_barrier.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/cyclic_barrier.rb new file mode 100644 index 0000000..9ebe29d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/cyclic_barrier.rb @@ -0,0 +1,128 @@ +require 'concurrent/synchronization/lockable_object' +require 'concurrent/utility/native_integer' + +module Concurrent + + # A synchronization aid that allows a set of threads to all wait for each + # other to reach a common barrier point. + # @example + # barrier = Concurrent::CyclicBarrier.new(3) + # jobs = Array.new(3) { |i| -> { sleep i; p done: i } } + # process = -> (i) do + # # waiting to start at the same time + # barrier.wait + # # execute job + # jobs[i].call + # # wait for others to finish + # barrier.wait + # end + # threads = 2.times.map do |i| + # Thread.new(i, &process) + # end + # + # # use main as well + # process.call 2 + # + # # here we can be sure that all jobs are processed + class CyclicBarrier < Synchronization::LockableObject + + # @!visibility private + Generation = Struct.new(:status) + private_constant :Generation + + # Create a new `CyclicBarrier` that waits for `parties` threads + # + # @param [Fixnum] parties the number of parties + # @yield an optional block that will be executed that will be executed after + # the last thread arrives and before the others are released + # + # @raise [ArgumentError] if `parties` is not an integer or is less than zero + def initialize(parties, &block) + Utility::NativeInteger.ensure_integer_and_bounds parties + Utility::NativeInteger.ensure_positive_and_no_zero parties + + super(&nil) + synchronize { ns_initialize parties, &block } + end + + # @return [Fixnum] the number of threads needed to pass the barrier + def parties + synchronize { @parties } + end + + # @return [Fixnum] the number of threads currently waiting on the barrier + def number_waiting + synchronize { @number_waiting } + end + + # Blocks on the barrier until the number of waiting threads is equal to + # `parties` or until `timeout` is reached or `reset` is called + # If a block has been passed to the constructor, it will be executed once by + # the last arrived thread before releasing the others + # @param [Fixnum] timeout the number of seconds to wait for the counter or + # `nil` to block indefinitely + # @return [Boolean] `true` if the `count` reaches zero else false on + # `timeout` or on `reset` or if the barrier is broken + def wait(timeout = nil) + synchronize do + + return false unless @generation.status == :waiting + + @number_waiting += 1 + + if @number_waiting == @parties + @action.call if @action + ns_generation_done @generation, :fulfilled + true + else + generation = @generation + if ns_wait_until(timeout) { generation.status != :waiting } + generation.status == :fulfilled + else + ns_generation_done generation, :broken, false + false + end + end + end + end + + # resets the barrier to its initial state + # If there is at least one waiting thread, it will be woken up, the `wait` + # method will return false and the barrier will be broken + # If the barrier is broken, this method restores it to the original state + # + # @return [nil] + def reset + synchronize { ns_generation_done @generation, :reset } + end + + # A barrier can be broken when: + # - a thread called the `reset` method while at least one other thread was waiting + # - at least one thread timed out on `wait` method + # + # A broken barrier can be restored using `reset` it's safer to create a new one + # @return [Boolean] true if the barrier is broken otherwise false + def broken? + synchronize { @generation.status != :waiting } + end + + protected + + def ns_generation_done(generation, status, continue = true) + generation.status = status + ns_next_generation if continue + ns_broadcast + end + + def ns_next_generation + @generation = Generation.new(:waiting) + @number_waiting = 0 + end + + def ns_initialize(parties, &block) + @parties = parties + @action = block + ns_next_generation + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/event.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/event.rb new file mode 100644 index 0000000..ccf84c9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/event.rb @@ -0,0 +1,109 @@ +require 'thread' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # Old school kernel-style event reminiscent of Win32 programming in C++. + # + # When an `Event` is created it is in the `unset` state. Threads can choose to + # `#wait` on the event, blocking until released by another thread. When one + # thread wants to alert all blocking threads it calls the `#set` method which + # will then wake up all listeners. Once an `Event` has been set it remains set. + # New threads calling `#wait` will return immediately. An `Event` may be + # `#reset` at any time once it has been set. + # + # @see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682655.aspx + # @example + # event = Concurrent::Event.new + # + # t1 = Thread.new do + # puts "t1 is waiting" + # event.wait(1) + # puts "event occurred" + # end + # + # t2 = Thread.new do + # puts "t2 calling set" + # event.set + # end + # + # [t1, t2].each(&:join) + # + # # prints: + # # t1 is waiting + # # t2 calling set + # # event occurred + class Event < Synchronization::LockableObject + + # Creates a new `Event` in the unset state. Threads calling `#wait` on the + # `Event` will block. + def initialize + super + synchronize { ns_initialize } + end + + # Is the object in the set state? + # + # @return [Boolean] indicating whether or not the `Event` has been set + def set? + synchronize { @set } + end + + # Trigger the event, setting the state to `set` and releasing all threads + # waiting on the event. Has no effect if the `Event` has already been set. + # + # @return [Boolean] should always return `true` + def set + synchronize { ns_set } + end + + def try? + synchronize { @set ? false : ns_set } + end + + # Reset a previously set event back to the `unset` state. + # Has no effect if the `Event` has not yet been set. + # + # @return [Boolean] should always return `true` + def reset + synchronize do + if @set + @set = false + @iteration +=1 + end + true + end + end + + # Wait a given number of seconds for the `Event` to be set by another + # thread. Will wait forever when no `timeout` value is given. Returns + # immediately if the `Event` has already been set. + # + # @return [Boolean] true if the `Event` was set before timeout else false + def wait(timeout = nil) + synchronize do + unless @set + iteration = @iteration + ns_wait_until(timeout) { iteration < @iteration || @set } + else + true + end + end + end + + protected + + def ns_set + unless @set + @set = true + ns_broadcast + end + true + end + + def ns_initialize + @set = false + @iteration = 0 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/fiber_local_var.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/fiber_local_var.rb new file mode 100644 index 0000000..e90fc24 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/fiber_local_var.rb @@ -0,0 +1,109 @@ +require 'concurrent/constants' +require_relative 'locals' + +module Concurrent + + # A `FiberLocalVar` is a variable where the value is different for each fiber. + # Each variable may have a default value, but when you modify the variable only + # the current fiber will ever see that change. + # + # This is similar to Ruby's built-in fiber-local variables (`Thread.current[:name]`), + # but with these major advantages: + # * `FiberLocalVar` has its own identity, it doesn't need a Symbol. + # * Each Ruby's built-in fiber-local variable leaks some memory forever (it's a Symbol held forever on the fiber), + # so it's only OK to create a small amount of them. + # `FiberLocalVar` has no such issue and it is fine to create many of them. + # * Ruby's built-in fiber-local variables leak forever the value set on each fiber (unless set to nil explicitly). + # `FiberLocalVar` automatically removes the mapping for each fiber once the `FiberLocalVar` instance is GC'd. + # + # @example + # v = FiberLocalVar.new(14) + # v.value #=> 14 + # v.value = 2 + # v.value #=> 2 + # + # @example + # v = FiberLocalVar.new(14) + # + # Fiber.new do + # v.value #=> 14 + # v.value = 1 + # v.value #=> 1 + # end.resume + # + # Fiber.new do + # v.value #=> 14 + # v.value = 2 + # v.value #=> 2 + # end.resume + # + # v.value #=> 14 + class FiberLocalVar + LOCALS = FiberLocals.new + + # Creates a fiber local variable. + # + # @param [Object] default the default value when otherwise unset + # @param [Proc] default_block Optional block that gets called to obtain the + # default value for each fiber + def initialize(default = nil, &default_block) + if default && block_given? + raise ArgumentError, "Cannot use both value and block as default value" + end + + if block_given? + @default_block = default_block + @default = nil + else + @default_block = nil + @default = default + end + + @index = LOCALS.next_index(self) + end + + # Returns the value in the current fiber's copy of this fiber-local variable. + # + # @return [Object] the current value + def value + LOCALS.fetch(@index) { default } + end + + # Sets the current fiber's copy of this fiber-local variable to the specified value. + # + # @param [Object] value the value to set + # @return [Object] the new value + def value=(value) + LOCALS.set(@index, value) + end + + # Bind the given value to fiber local storage during + # execution of the given block. + # + # @param [Object] value the value to bind + # @yield the operation to be performed with the bound variable + # @return [Object] the value + def bind(value) + if block_given? + old_value = self.value + self.value = value + begin + yield + ensure + self.value = old_value + end + end + end + + protected + + # @!visibility private + def default + if @default_block + self.value = @default_block.call + else + @default + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb new file mode 100644 index 0000000..3c119bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb @@ -0,0 +1,43 @@ +if Concurrent.on_jruby? + require 'concurrent/utility/native_extension_loader' + + module Concurrent + + # @!macro count_down_latch + # @!visibility private + # @!macro internal_implementation_note + class JavaCountDownLatch + + # @!macro count_down_latch_method_initialize + def initialize(count = 1) + Utility::NativeInteger.ensure_integer_and_bounds(count) + Utility::NativeInteger.ensure_positive(count) + @latch = java.util.concurrent.CountDownLatch.new(count) + end + + # @!macro count_down_latch_method_wait + def wait(timeout = nil) + result = nil + if timeout.nil? + Synchronization::JRuby.sleep_interruptibly { @latch.await } + result = true + else + Synchronization::JRuby.sleep_interruptibly do + result = @latch.await(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS) + end + end + result + end + + # @!macro count_down_latch_method_count_down + def count_down + @latch.countDown + end + + # @!macro count_down_latch_method_count + def count + @latch.getCount + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/locals.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/locals.rb new file mode 100644 index 0000000..0a276ae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/locals.rb @@ -0,0 +1,189 @@ +require 'fiber' +require 'concurrent/utility/engine' +require 'concurrent/constants' + +module Concurrent + # @!visibility private + # @!macro internal_implementation_note + # + # An abstract implementation of local storage, with sub-classes for + # per-thread and per-fiber locals. + # + # Each execution context (EC, thread or fiber) has a lazily initialized array + # of local variable values. Each time a new local variable is created, we + # allocate an "index" for it. + # + # For example, if the allocated index is 1, that means slot #1 in EVERY EC's + # locals array will be used for the value of that variable. + # + # The good thing about using a per-EC structure to hold values, rather than + # a global, is that no synchronization is needed when reading and writing + # those values (since the structure is only ever accessed by a single + # thread). + # + # Of course, when a local variable is GC'd, 1) we need to recover its index + # for use by other new local variables (otherwise the locals arrays could + # get bigger and bigger with time), and 2) we need to null out all the + # references held in the now-unused slots (both to avoid blocking GC of those + # objects, and also to prevent "stale" values from being passed on to a new + # local when the index is reused). + # + # Because we need to null out freed slots, we need to keep references to + # ALL the locals arrays, so we can null out the appropriate slots in all of + # them. This is why we need to use a finalizer to clean up the locals array + # when the EC goes out of scope. + class AbstractLocals + def initialize + @free = [] + @lock = Mutex.new + @all_arrays = {} + @next = 0 + end + + def synchronize + @lock.synchronize { yield } + end + + if Concurrent.on_cruby? + def weak_synchronize + yield + end + else + alias_method :weak_synchronize, :synchronize + end + + def next_index(local) + index = synchronize do + if @free.empty? + @next += 1 + else + @free.pop + end + end + + # When the local goes out of scope, we should free the associated index + # and all values stored into it. + ObjectSpace.define_finalizer(local, local_finalizer(index)) + + index + end + + def free_index(index) + weak_synchronize do + # The cost of GC'ing a TLV is linear in the number of ECs using local + # variables. But that is natural! More ECs means more storage is used + # per local variable. So naturally more CPU time is required to free + # more storage. + # + # DO NOT use each_value which might conflict with new pair assignment + # into the hash in #set method. + @all_arrays.values.each do |locals| + locals[index] = nil + end + + # free index has to be published after the arrays are cleared: + @free << index + end + end + + def fetch(index) + locals = self.locals + value = locals ? locals[index] : nil + + if nil == value + yield + elsif NULL.equal?(value) + nil + else + value + end + end + + def set(index, value) + locals = self.locals! + locals[index] = (nil == value ? NULL : value) + + value + end + + private + + # When the local goes out of scope, clean up that slot across all locals currently assigned. + def local_finalizer(index) + proc do + free_index(index) + end + end + + # When a thread/fiber goes out of scope, remove the array from @all_arrays. + def thread_fiber_finalizer(array_object_id) + proc do + weak_synchronize do + @all_arrays.delete(array_object_id) + end + end + end + + # Returns the locals for the current scope, or nil if none exist. + def locals + raise NotImplementedError + end + + # Returns the locals for the current scope, creating them if necessary. + def locals! + raise NotImplementedError + end + end + + # @!visibility private + # @!macro internal_implementation_note + # An array-backed storage of indexed variables per thread. + class ThreadLocals < AbstractLocals + def locals + Thread.current.thread_variable_get(:concurrent_thread_locals) + end + + def locals! + thread = Thread.current + locals = thread.thread_variable_get(:concurrent_thread_locals) + + unless locals + locals = thread.thread_variable_set(:concurrent_thread_locals, []) + weak_synchronize do + @all_arrays[locals.object_id] = locals + end + # When the thread goes out of scope, we should delete the associated locals: + ObjectSpace.define_finalizer(thread, thread_fiber_finalizer(locals.object_id)) + end + + locals + end + end + + # @!visibility private + # @!macro internal_implementation_note + # An array-backed storage of indexed variables per fiber. + class FiberLocals < AbstractLocals + def locals + Thread.current[:concurrent_fiber_locals] + end + + def locals! + thread = Thread.current + locals = thread[:concurrent_fiber_locals] + + unless locals + locals = thread[:concurrent_fiber_locals] = [] + weak_synchronize do + @all_arrays[locals.object_id] = locals + end + # When the fiber goes out of scope, we should delete the associated locals: + ObjectSpace.define_finalizer(Fiber.current, thread_fiber_finalizer(locals.object_id)) + end + + locals + end + end + + private_constant :AbstractLocals, :ThreadLocals, :FiberLocals +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb new file mode 100644 index 0000000..ebf23a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb @@ -0,0 +1,28 @@ +require 'concurrent/utility/engine' +require_relative 'fiber_local_var' +require_relative 'thread_local_var' + +module Concurrent + # @!visibility private + def self.mutex_owned_per_thread? + return false if Concurrent.on_jruby? || Concurrent.on_truffleruby? + + mutex = Mutex.new + # Lock the mutex: + mutex.synchronize do + # Check if the mutex is still owned in a child fiber: + Fiber.new { mutex.owned? }.resume + end + end + + if mutex_owned_per_thread? + LockLocalVar = ThreadLocalVar + else + LockLocalVar = FiberLocalVar + end + + # Either {FiberLocalVar} or {ThreadLocalVar} depending on whether Mutex (and Monitor) + # are held, respectively, per Fiber or per Thread. + class LockLocalVar + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_atomic_boolean.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_atomic_boolean.rb new file mode 100644 index 0000000..015996b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_atomic_boolean.rb @@ -0,0 +1,68 @@ +require 'concurrent/synchronization/safe_initialization' + +module Concurrent + + # @!macro atomic_boolean + # @!visibility private + # @!macro internal_implementation_note + class MutexAtomicBoolean + extend Concurrent::Synchronization::SafeInitialization + + # @!macro atomic_boolean_method_initialize + def initialize(initial = false) + super() + @Lock = ::Mutex.new + @value = !!initial + end + + # @!macro atomic_boolean_method_value_get + def value + synchronize { @value } + end + + # @!macro atomic_boolean_method_value_set + def value=(value) + synchronize { @value = !!value } + end + + # @!macro atomic_boolean_method_true_question + def true? + synchronize { @value } + end + + # @!macro atomic_boolean_method_false_question + def false? + synchronize { !@value } + end + + # @!macro atomic_boolean_method_make_true + def make_true + synchronize { ns_make_value(true) } + end + + # @!macro atomic_boolean_method_make_false + def make_false + synchronize { ns_make_value(false) } + end + + protected + + # @!visibility private + def synchronize + if @Lock.owned? + yield + else + @Lock.synchronize { yield } + end + end + + private + + # @!visibility private + def ns_make_value(value) + old = @value + @value = value + old != @value + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_atomic_fixnum.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_atomic_fixnum.rb new file mode 100644 index 0000000..0ca3955 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_atomic_fixnum.rb @@ -0,0 +1,81 @@ +require 'concurrent/synchronization/safe_initialization' +require 'concurrent/utility/native_integer' + +module Concurrent + + # @!macro atomic_fixnum + # @!visibility private + # @!macro internal_implementation_note + class MutexAtomicFixnum + extend Concurrent::Synchronization::SafeInitialization + + # @!macro atomic_fixnum_method_initialize + def initialize(initial = 0) + super() + @Lock = ::Mutex.new + ns_set(initial) + end + + # @!macro atomic_fixnum_method_value_get + def value + synchronize { @value } + end + + # @!macro atomic_fixnum_method_value_set + def value=(value) + synchronize { ns_set(value) } + end + + # @!macro atomic_fixnum_method_increment + def increment(delta = 1) + synchronize { ns_set(@value + delta.to_i) } + end + + alias_method :up, :increment + + # @!macro atomic_fixnum_method_decrement + def decrement(delta = 1) + synchronize { ns_set(@value - delta.to_i) } + end + + alias_method :down, :decrement + + # @!macro atomic_fixnum_method_compare_and_set + def compare_and_set(expect, update) + synchronize do + if @value == expect.to_i + @value = update.to_i + true + else + false + end + end + end + + # @!macro atomic_fixnum_method_update + def update + synchronize do + @value = yield @value + end + end + + protected + + # @!visibility private + def synchronize + if @Lock.owned? + yield + else + @Lock.synchronize { yield } + end + end + + private + + # @!visibility private + def ns_set(value) + Utility::NativeInteger.ensure_integer_and_bounds value + @value = value + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb new file mode 100644 index 0000000..29aa1ca --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb @@ -0,0 +1,44 @@ +require 'concurrent/synchronization/lockable_object' +require 'concurrent/utility/native_integer' + +module Concurrent + + # @!macro count_down_latch + # @!visibility private + # @!macro internal_implementation_note + class MutexCountDownLatch < Synchronization::LockableObject + + # @!macro count_down_latch_method_initialize + def initialize(count = 1) + Utility::NativeInteger.ensure_integer_and_bounds count + Utility::NativeInteger.ensure_positive count + + super() + synchronize { ns_initialize count } + end + + # @!macro count_down_latch_method_wait + def wait(timeout = nil) + synchronize { ns_wait_until(timeout) { @count == 0 } } + end + + # @!macro count_down_latch_method_count_down + def count_down + synchronize do + @count -= 1 if @count > 0 + ns_broadcast if @count == 0 + end + end + + # @!macro count_down_latch_method_count + def count + synchronize { @count } + end + + protected + + def ns_initialize(count) + @count = count + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_semaphore.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_semaphore.rb new file mode 100644 index 0000000..4347289 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/mutex_semaphore.rb @@ -0,0 +1,131 @@ +require 'concurrent/synchronization/lockable_object' +require 'concurrent/utility/native_integer' + +module Concurrent + + # @!macro semaphore + # @!visibility private + # @!macro internal_implementation_note + class MutexSemaphore < Synchronization::LockableObject + + # @!macro semaphore_method_initialize + def initialize(count) + Utility::NativeInteger.ensure_integer_and_bounds count + + super() + synchronize { ns_initialize count } + end + + # @!macro semaphore_method_acquire + def acquire(permits = 1) + Utility::NativeInteger.ensure_integer_and_bounds permits + Utility::NativeInteger.ensure_positive permits + + synchronize do + try_acquire_timed(permits, nil) + end + + return unless block_given? + + begin + yield + ensure + release(permits) + end + end + + # @!macro semaphore_method_available_permits + def available_permits + synchronize { @free } + end + + # @!macro semaphore_method_drain_permits + # + # Acquires and returns all permits that are immediately available. + # + # @return [Integer] + def drain_permits + synchronize do + @free.tap { |_| @free = 0 } + end + end + + # @!macro semaphore_method_try_acquire + def try_acquire(permits = 1, timeout = nil) + Utility::NativeInteger.ensure_integer_and_bounds permits + Utility::NativeInteger.ensure_positive permits + + acquired = synchronize do + if timeout.nil? + try_acquire_now(permits) + else + try_acquire_timed(permits, timeout) + end + end + + return acquired unless block_given? + return unless acquired + + begin + yield + ensure + release(permits) + end + end + + # @!macro semaphore_method_release + def release(permits = 1) + Utility::NativeInteger.ensure_integer_and_bounds permits + Utility::NativeInteger.ensure_positive permits + + synchronize do + @free += permits + permits.times { ns_signal } + end + nil + end + + # Shrinks the number of available permits by the indicated reduction. + # + # @param [Fixnum] reduction Number of permits to remove. + # + # @raise [ArgumentError] if `reduction` is not an integer or is negative + # + # @raise [ArgumentError] if `@free` - `@reduction` is less than zero + # + # @return [nil] + # + # @!visibility private + def reduce_permits(reduction) + Utility::NativeInteger.ensure_integer_and_bounds reduction + Utility::NativeInteger.ensure_positive reduction + + synchronize { @free -= reduction } + nil + end + + protected + + # @!visibility private + def ns_initialize(count) + @free = count + end + + private + + # @!visibility private + def try_acquire_now(permits) + if @free >= permits + @free -= permits + true + else + false + end + end + + # @!visibility private + def try_acquire_timed(permits, timeout) + ns_wait_until(timeout) { try_acquire_now(permits) } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb new file mode 100644 index 0000000..b26bd17 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb @@ -0,0 +1,255 @@ +require 'thread' +require 'concurrent/atomic/atomic_fixnum' +require 'concurrent/errors' +require 'concurrent/synchronization/object' +require 'concurrent/synchronization/lock' + +module Concurrent + + # Ruby read-write lock implementation + # + # Allows any number of concurrent readers, but only one concurrent writer + # (And if the "write" lock is taken, any readers who come along will have to wait) + # + # If readers are already active when a writer comes along, the writer will wait for + # all the readers to finish before going ahead. + # Any additional readers that come when the writer is already waiting, will also + # wait (so writers are not starved). + # + # This implementation is based on `java.util.concurrent.ReentrantReadWriteLock`. + # + # @example + # lock = Concurrent::ReadWriteLock.new + # lock.with_read_lock { data.retrieve } + # lock.with_write_lock { data.modify! } + # + # @note Do **not** try to acquire the write lock while already holding a read lock + # **or** try to acquire the write lock while you already have it. + # This will lead to deadlock + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html java.util.concurrent.ReentrantReadWriteLock + class ReadWriteLock < Synchronization::Object + + # @!visibility private + WAITING_WRITER = 1 << 15 + + # @!visibility private + RUNNING_WRITER = 1 << 29 + + # @!visibility private + MAX_READERS = WAITING_WRITER - 1 + + # @!visibility private + MAX_WRITERS = RUNNING_WRITER - MAX_READERS - 1 + + safe_initialization! + + # Implementation notes: + # A goal is to make the uncontended path for both readers/writers lock-free + # Only if there is reader-writer or writer-writer contention, should locks be used + # Internal state is represented by a single integer ("counter"), and updated + # using atomic compare-and-swap operations + # When the counter is 0, the lock is free + # Each reader increments the counter by 1 when acquiring a read lock + # (and decrements by 1 when releasing the read lock) + # The counter is increased by (1 << 15) for each writer waiting to acquire the + # write lock, and by (1 << 29) if the write lock is taken + + # Create a new `ReadWriteLock` in the unlocked state. + def initialize + super() + @Counter = AtomicFixnum.new(0) # single integer which represents lock state + @ReadLock = Synchronization::Lock.new + @WriteLock = Synchronization::Lock.new + end + + # Execute a block operation within a read lock. + # + # @yield the task to be performed within the lock. + # + # @return [Object] the result of the block operation. + # + # @raise [ArgumentError] when no block is given. + # @raise [Concurrent::ResourceLimitError] if the maximum number of readers + # is exceeded. + def with_read_lock + raise ArgumentError.new('no block given') unless block_given? + acquire_read_lock + begin + yield + ensure + release_read_lock + end + end + + # Execute a block operation within a write lock. + # + # @yield the task to be performed within the lock. + # + # @return [Object] the result of the block operation. + # + # @raise [ArgumentError] when no block is given. + # @raise [Concurrent::ResourceLimitError] if the maximum number of readers + # is exceeded. + def with_write_lock + raise ArgumentError.new('no block given') unless block_given? + acquire_write_lock + begin + yield + ensure + release_write_lock + end + end + + # Acquire a read lock. If a write lock has been acquired will block until + # it is released. Will not block if other read locks have been acquired. + # + # @return [Boolean] true if the lock is successfully acquired + # + # @raise [Concurrent::ResourceLimitError] if the maximum number of readers + # is exceeded. + def acquire_read_lock + while true + c = @Counter.value + raise ResourceLimitError.new('Too many reader threads') if max_readers?(c) + + # If a writer is waiting when we first queue up, we need to wait + if waiting_writer?(c) + @ReadLock.wait_until { !waiting_writer? } + + # after a reader has waited once, they are allowed to "barge" ahead of waiting writers + # but if a writer is *running*, the reader still needs to wait (naturally) + while true + c = @Counter.value + if running_writer?(c) + @ReadLock.wait_until { !running_writer? } + else + return if @Counter.compare_and_set(c, c+1) + end + end + else + break if @Counter.compare_and_set(c, c+1) + end + end + true + end + + # Release a previously acquired read lock. + # + # @return [Boolean] true if the lock is successfully released + def release_read_lock + while true + c = @Counter.value + if @Counter.compare_and_set(c, c-1) + # If one or more writers were waiting, and we were the last reader, wake a writer up + if waiting_writer?(c) && running_readers(c) == 1 + @WriteLock.signal + end + break + end + end + true + end + + # Acquire a write lock. Will block and wait for all active readers and writers. + # + # @return [Boolean] true if the lock is successfully acquired + # + # @raise [Concurrent::ResourceLimitError] if the maximum number of writers + # is exceeded. + def acquire_write_lock + while true + c = @Counter.value + raise ResourceLimitError.new('Too many writer threads') if max_writers?(c) + + if c == 0 # no readers OR writers running + # if we successfully swap the RUNNING_WRITER bit on, then we can go ahead + break if @Counter.compare_and_set(0, RUNNING_WRITER) + elsif @Counter.compare_and_set(c, c+WAITING_WRITER) + while true + # Now we have successfully incremented, so no more readers will be able to increment + # (they will wait instead) + # However, readers OR writers could decrement right here, OR another writer could increment + @WriteLock.wait_until do + # So we have to do another check inside the synchronized section + # If a writer OR reader is running, then go to sleep + c = @Counter.value + !running_writer?(c) && !running_readers?(c) + end + + # We just came out of a wait + # If we successfully turn the RUNNING_WRITER bit on with an atomic swap, + # Then we are OK to stop waiting and go ahead + # Otherwise go back and wait again + c = @Counter.value + break if !running_writer?(c) && !running_readers?(c) && @Counter.compare_and_set(c, c+RUNNING_WRITER-WAITING_WRITER) + end + break + end + end + true + end + + # Release a previously acquired write lock. + # + # @return [Boolean] true if the lock is successfully released + def release_write_lock + return true unless running_writer? + c = @Counter.update { |counter| counter - RUNNING_WRITER } + @ReadLock.broadcast + @WriteLock.signal if waiting_writers(c) > 0 + true + end + + # Queries if the write lock is held by any thread. + # + # @return [Boolean] true if the write lock is held else false` + def write_locked? + @Counter.value >= RUNNING_WRITER + end + + # Queries whether any threads are waiting to acquire the read or write lock. + # + # @return [Boolean] true if any threads are waiting for a lock else false + def has_waiters? + waiting_writer?(@Counter.value) + end + + private + + # @!visibility private + def running_readers(c = @Counter.value) + c & MAX_READERS + end + + # @!visibility private + def running_readers?(c = @Counter.value) + (c & MAX_READERS) > 0 + end + + # @!visibility private + def running_writer?(c = @Counter.value) + c >= RUNNING_WRITER + end + + # @!visibility private + def waiting_writers(c = @Counter.value) + (c & MAX_WRITERS) / WAITING_WRITER + end + + # @!visibility private + def waiting_writer?(c = @Counter.value) + c >= WAITING_WRITER + end + + # @!visibility private + def max_readers?(c = @Counter.value) + (c & MAX_READERS) == MAX_READERS + end + + # @!visibility private + def max_writers?(c = @Counter.value) + (c & MAX_WRITERS) == MAX_WRITERS + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb new file mode 100644 index 0000000..6d72a3a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb @@ -0,0 +1,379 @@ +require 'thread' +require 'concurrent/atomic/atomic_reference' +require 'concurrent/atomic/atomic_fixnum' +require 'concurrent/errors' +require 'concurrent/synchronization/object' +require 'concurrent/synchronization/lock' +require 'concurrent/atomic/lock_local_var' + +module Concurrent + + # Re-entrant read-write lock implementation + # + # Allows any number of concurrent readers, but only one concurrent writer + # (And while the "write" lock is taken, no read locks can be obtained either. + # Hence, the write lock can also be called an "exclusive" lock.) + # + # If another thread has taken a read lock, any thread which wants a write lock + # will block until all the readers release their locks. However, once a thread + # starts waiting to obtain a write lock, any additional readers that come along + # will also wait (so writers are not starved). + # + # A thread can acquire both a read and write lock at the same time. A thread can + # also acquire a read lock OR a write lock more than once. Only when the read (or + # write) lock is released as many times as it was acquired, will the thread + # actually let it go, allowing other threads which might have been waiting + # to proceed. Therefore the lock can be upgraded by first acquiring + # read lock and then write lock and that the lock can be downgraded by first + # having both read and write lock a releasing just the write lock. + # + # If both read and write locks are acquired by the same thread, it is not strictly + # necessary to release them in the same order they were acquired. In other words, + # the following code is legal: + # + # @example + # lock = Concurrent::ReentrantReadWriteLock.new + # lock.acquire_write_lock + # lock.acquire_read_lock + # lock.release_write_lock + # # At this point, the current thread is holding only a read lock, not a write + # # lock. So other threads can take read locks, but not a write lock. + # lock.release_read_lock + # # Now the current thread is not holding either a read or write lock, so + # # another thread could potentially acquire a write lock. + # + # This implementation was inspired by `java.util.concurrent.ReentrantReadWriteLock`. + # + # @example + # lock = Concurrent::ReentrantReadWriteLock.new + # lock.with_read_lock { data.retrieve } + # lock.with_write_lock { data.modify! } + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html java.util.concurrent.ReentrantReadWriteLock + class ReentrantReadWriteLock < Synchronization::Object + + # Implementation notes: + # + # A goal is to make the uncontended path for both readers/writers mutex-free + # Only if there is reader-writer or writer-writer contention, should mutexes be used + # Otherwise, a single CAS operation is all we need to acquire/release a lock + # + # Internal state is represented by a single integer ("counter"), and updated + # using atomic compare-and-swap operations + # When the counter is 0, the lock is free + # Each thread which has one OR MORE read locks increments the counter by 1 + # (and decrements by 1 when releasing the read lock) + # The counter is increased by (1 << 15) for each writer waiting to acquire the + # write lock, and by (1 << 29) if the write lock is taken + # + # Additionally, each thread uses a thread-local variable to count how many times + # it has acquired a read lock, AND how many times it has acquired a write lock. + # It uses a similar trick; an increment of 1 means a read lock was taken, and + # an increment of (1 << 15) means a write lock was taken + # This is what makes re-entrancy possible + # + # 2 rules are followed to ensure good liveness properties: + # 1) Once a writer has queued up and is waiting for a write lock, no other thread + # can take a lock without waiting + # 2) When a write lock is released, readers are given the "first chance" to wake + # up and acquire a read lock + # Following these rules means readers and writers tend to "take turns", so neither + # can starve the other, even under heavy contention + + # @!visibility private + READER_BITS = 15 + # @!visibility private + WRITER_BITS = 14 + + # Used with @Counter: + # @!visibility private + WAITING_WRITER = 1 << READER_BITS + # @!visibility private + RUNNING_WRITER = 1 << (READER_BITS + WRITER_BITS) + # @!visibility private + MAX_READERS = WAITING_WRITER - 1 + # @!visibility private + MAX_WRITERS = RUNNING_WRITER - MAX_READERS - 1 + + # Used with @HeldCount: + # @!visibility private + WRITE_LOCK_HELD = 1 << READER_BITS + # @!visibility private + READ_LOCK_MASK = WRITE_LOCK_HELD - 1 + # @!visibility private + WRITE_LOCK_MASK = MAX_WRITERS + + safe_initialization! + + # Create a new `ReentrantReadWriteLock` in the unlocked state. + def initialize + super() + @Counter = AtomicFixnum.new(0) # single integer which represents lock state + @ReadQueue = Synchronization::Lock.new # used to queue waiting readers + @WriteQueue = Synchronization::Lock.new # used to queue waiting writers + @HeldCount = LockLocalVar.new(0) # indicates # of R & W locks held by this thread + end + + # Execute a block operation within a read lock. + # + # @yield the task to be performed within the lock. + # + # @return [Object] the result of the block operation. + # + # @raise [ArgumentError] when no block is given. + # @raise [Concurrent::ResourceLimitError] if the maximum number of readers + # is exceeded. + def with_read_lock + raise ArgumentError.new('no block given') unless block_given? + acquire_read_lock + begin + yield + ensure + release_read_lock + end + end + + # Execute a block operation within a write lock. + # + # @yield the task to be performed within the lock. + # + # @return [Object] the result of the block operation. + # + # @raise [ArgumentError] when no block is given. + # @raise [Concurrent::ResourceLimitError] if the maximum number of readers + # is exceeded. + def with_write_lock + raise ArgumentError.new('no block given') unless block_given? + acquire_write_lock + begin + yield + ensure + release_write_lock + end + end + + # Acquire a read lock. If a write lock is held by another thread, will block + # until it is released. + # + # @return [Boolean] true if the lock is successfully acquired + # + # @raise [Concurrent::ResourceLimitError] if the maximum number of readers + # is exceeded. + def acquire_read_lock + if (held = @HeldCount.value) > 0 + # If we already have a lock, there's no need to wait + if held & READ_LOCK_MASK == 0 + # But we do need to update the counter, if we were holding a write + # lock but not a read lock + @Counter.update { |c| c + 1 } + end + @HeldCount.value = held + 1 + return true + end + + while true + c = @Counter.value + raise ResourceLimitError.new('Too many reader threads') if max_readers?(c) + + # If a writer is waiting OR running when we first queue up, we need to wait + if waiting_or_running_writer?(c) + # Before going to sleep, check again with the ReadQueue mutex held + @ReadQueue.synchronize do + @ReadQueue.ns_wait if waiting_or_running_writer? + end + # Note: the above 'synchronize' block could have used #wait_until, + # but that waits repeatedly in a loop, checking the wait condition + # each time it wakes up (to protect against spurious wakeups) + # But we are already in a loop, which is only broken when we successfully + # acquire the lock! So we don't care about spurious wakeups, and would + # rather not pay the extra overhead of using #wait_until + + # After a reader has waited once, they are allowed to "barge" ahead of waiting writers + # But if a writer is *running*, the reader still needs to wait (naturally) + while true + c = @Counter.value + if running_writer?(c) + @ReadQueue.synchronize do + @ReadQueue.ns_wait if running_writer? + end + elsif @Counter.compare_and_set(c, c+1) + @HeldCount.value = held + 1 + return true + end + end + elsif @Counter.compare_and_set(c, c+1) + @HeldCount.value = held + 1 + return true + end + end + end + + # Try to acquire a read lock and return true if we succeed. If it cannot be + # acquired immediately, return false. + # + # @return [Boolean] true if the lock is successfully acquired + def try_read_lock + if (held = @HeldCount.value) > 0 + if held & READ_LOCK_MASK == 0 + # If we hold a write lock, but not a read lock... + @Counter.update { |c| c + 1 } + end + @HeldCount.value = held + 1 + return true + else + c = @Counter.value + if !waiting_or_running_writer?(c) && @Counter.compare_and_set(c, c+1) + @HeldCount.value = held + 1 + return true + end + end + false + end + + # Release a previously acquired read lock. + # + # @return [Boolean] true if the lock is successfully released + def release_read_lock + held = @HeldCount.value = @HeldCount.value - 1 + rlocks_held = held & READ_LOCK_MASK + if rlocks_held == 0 + c = @Counter.update { |counter| counter - 1 } + # If one or more writers were waiting, and we were the last reader, wake a writer up + if waiting_or_running_writer?(c) && running_readers(c) == 0 + @WriteQueue.signal + end + elsif rlocks_held == READ_LOCK_MASK + raise IllegalOperationError, "Cannot release a read lock which is not held" + end + true + end + + # Acquire a write lock. Will block and wait for all active readers and writers. + # + # @return [Boolean] true if the lock is successfully acquired + # + # @raise [Concurrent::ResourceLimitError] if the maximum number of writers + # is exceeded. + def acquire_write_lock + if (held = @HeldCount.value) >= WRITE_LOCK_HELD + # if we already have a write (exclusive) lock, there's no need to wait + @HeldCount.value = held + WRITE_LOCK_HELD + return true + end + + while true + c = @Counter.value + raise ResourceLimitError.new('Too many writer threads') if max_writers?(c) + + # To go ahead and take the lock without waiting, there must be no writer + # running right now, AND no writers who came before us still waiting to + # acquire the lock + # Additionally, if any read locks have been taken, we must hold all of them + if held > 0 && @Counter.compare_and_set(1, c+RUNNING_WRITER) + # If we are the only one reader and successfully swap the RUNNING_WRITER bit on, then we can go ahead + @HeldCount.value = held + WRITE_LOCK_HELD + return true + elsif @Counter.compare_and_set(c, c+WAITING_WRITER) + while true + # Now we have successfully incremented, so no more readers will be able to increment + # (they will wait instead) + # However, readers OR writers could decrement right here + @WriteQueue.synchronize do + # So we have to do another check inside the synchronized section + # If a writer OR another reader is running, then go to sleep + c = @Counter.value + @WriteQueue.ns_wait if running_writer?(c) || running_readers(c) != held + end + # Note: if you are thinking of replacing the above 'synchronize' block + # with #wait_until, read the comment in #acquire_read_lock first! + + # We just came out of a wait + # If we successfully turn the RUNNING_WRITER bit on with an atomic swap, + # then we are OK to stop waiting and go ahead + # Otherwise go back and wait again + c = @Counter.value + if !running_writer?(c) && + running_readers(c) == held && + @Counter.compare_and_set(c, c+RUNNING_WRITER-WAITING_WRITER) + @HeldCount.value = held + WRITE_LOCK_HELD + return true + end + end + end + end + end + + # Try to acquire a write lock and return true if we succeed. If it cannot be + # acquired immediately, return false. + # + # @return [Boolean] true if the lock is successfully acquired + def try_write_lock + if (held = @HeldCount.value) >= WRITE_LOCK_HELD + @HeldCount.value = held + WRITE_LOCK_HELD + return true + else + c = @Counter.value + if !waiting_or_running_writer?(c) && + running_readers(c) == held && + @Counter.compare_and_set(c, c+RUNNING_WRITER) + @HeldCount.value = held + WRITE_LOCK_HELD + return true + end + end + false + end + + # Release a previously acquired write lock. + # + # @return [Boolean] true if the lock is successfully released + def release_write_lock + held = @HeldCount.value = @HeldCount.value - WRITE_LOCK_HELD + wlocks_held = held & WRITE_LOCK_MASK + if wlocks_held == 0 + c = @Counter.update { |counter| counter - RUNNING_WRITER } + @ReadQueue.broadcast + @WriteQueue.signal if waiting_writers(c) > 0 + elsif wlocks_held == WRITE_LOCK_MASK + raise IllegalOperationError, "Cannot release a write lock which is not held" + end + true + end + + private + + # @!visibility private + def running_readers(c = @Counter.value) + c & MAX_READERS + end + + # @!visibility private + def running_readers?(c = @Counter.value) + (c & MAX_READERS) > 0 + end + + # @!visibility private + def running_writer?(c = @Counter.value) + c >= RUNNING_WRITER + end + + # @!visibility private + def waiting_writers(c = @Counter.value) + (c & MAX_WRITERS) >> READER_BITS + end + + # @!visibility private + def waiting_or_running_writer?(c = @Counter.value) + c >= WAITING_WRITER + end + + # @!visibility private + def max_readers?(c = @Counter.value) + (c & MAX_READERS) == MAX_READERS + end + + # @!visibility private + def max_writers?(c = @Counter.value) + (c & MAX_WRITERS) == MAX_WRITERS + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/semaphore.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/semaphore.rb new file mode 100644 index 0000000..f0799f0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/semaphore.rb @@ -0,0 +1,163 @@ +require 'concurrent/atomic/mutex_semaphore' + +module Concurrent + + ################################################################### + + # @!macro semaphore_method_initialize + # + # Create a new `Semaphore` with the initial `count`. + # + # @param [Fixnum] count the initial count + # + # @raise [ArgumentError] if `count` is not an integer + + # @!macro semaphore_method_acquire + # + # Acquires the given number of permits from this semaphore, + # blocking until all are available. If a block is given, + # yields to it and releases the permits afterwards. + # + # @param [Fixnum] permits Number of permits to acquire + # + # @raise [ArgumentError] if `permits` is not an integer or is less than zero + # + # @return [nil, BasicObject] Without a block, `nil` is returned. If a block + # is given, its return value is returned. + + # @!macro semaphore_method_available_permits + # + # Returns the current number of permits available in this semaphore. + # + # @return [Integer] + + # @!macro semaphore_method_drain_permits + # + # Acquires and returns all permits that are immediately available. + # + # @return [Integer] + + # @!macro semaphore_method_try_acquire + # + # Acquires the given number of permits from this semaphore, + # only if all are available at the time of invocation or within + # `timeout` interval. If a block is given, yields to it if the permits + # were successfully acquired, and releases them afterward, returning the + # block's return value. + # + # @param [Fixnum] permits the number of permits to acquire + # + # @param [Fixnum] timeout the number of seconds to wait for the counter + # or `nil` to return immediately + # + # @raise [ArgumentError] if `permits` is not an integer or is less than zero + # + # @return [true, false, nil, BasicObject] `false` if no permits are + # available, `true` when acquired a permit. If a block is given, the + # block's return value is returned if the permits were acquired; if not, + # `nil` is returned. + + # @!macro semaphore_method_release + # + # Releases the given number of permits, returning them to the semaphore. + # + # @param [Fixnum] permits Number of permits to return to the semaphore. + # + # @raise [ArgumentError] if `permits` is not a number or is less than zero + # + # @return [nil] + + ################################################################### + + # @!macro semaphore_public_api + # + # @!method initialize(count) + # @!macro semaphore_method_initialize + # + # @!method acquire(permits = 1) + # @!macro semaphore_method_acquire + # + # @!method available_permits + # @!macro semaphore_method_available_permits + # + # @!method drain_permits + # @!macro semaphore_method_drain_permits + # + # @!method try_acquire(permits = 1, timeout = nil) + # @!macro semaphore_method_try_acquire + # + # @!method release(permits = 1) + # @!macro semaphore_method_release + + ################################################################### + + # @!visibility private + # @!macro internal_implementation_note + SemaphoreImplementation = if Concurrent.on_jruby? + require 'concurrent/utility/native_extension_loader' + JavaSemaphore + else + MutexSemaphore + end + private_constant :SemaphoreImplementation + + # @!macro semaphore + # + # A counting semaphore. Conceptually, a semaphore maintains a set of + # permits. Each {#acquire} blocks if necessary until a permit is + # available, and then takes it. Each {#release} adds a permit, potentially + # releasing a blocking acquirer. + # However, no actual permit objects are used; the Semaphore just keeps a + # count of the number available and acts accordingly. + # Alternatively, permits may be acquired within a block, and automatically + # released after the block finishes executing. + # + # @!macro semaphore_public_api + # @example + # semaphore = Concurrent::Semaphore.new(2) + # + # t1 = Thread.new do + # semaphore.acquire + # puts "Thread 1 acquired semaphore" + # end + # + # t2 = Thread.new do + # semaphore.acquire + # puts "Thread 2 acquired semaphore" + # end + # + # t3 = Thread.new do + # semaphore.acquire + # puts "Thread 3 acquired semaphore" + # end + # + # t4 = Thread.new do + # sleep(2) + # puts "Thread 4 releasing semaphore" + # semaphore.release + # end + # + # [t1, t2, t3, t4].each(&:join) + # + # # prints: + # # Thread 3 acquired semaphore + # # Thread 2 acquired semaphore + # # Thread 4 releasing semaphore + # # Thread 1 acquired semaphore + # + # @example + # semaphore = Concurrent::Semaphore.new(1) + # + # puts semaphore.available_permits + # semaphore.acquire do + # puts semaphore.available_permits + # end + # puts semaphore.available_permits + # + # # prints: + # # 1 + # # 0 + # # 1 + class Semaphore < SemaphoreImplementation + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/thread_local_var.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/thread_local_var.rb new file mode 100644 index 0000000..3b7e12b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic/thread_local_var.rb @@ -0,0 +1,111 @@ +require 'concurrent/constants' +require_relative 'locals' + +module Concurrent + + # A `ThreadLocalVar` is a variable where the value is different for each thread. + # Each variable may have a default value, but when you modify the variable only + # the current thread will ever see that change. + # + # This is similar to Ruby's built-in thread-local variables (`Thread#thread_variable_get`), + # but with these major advantages: + # * `ThreadLocalVar` has its own identity, it doesn't need a Symbol. + # * Each Ruby's built-in thread-local variable leaks some memory forever (it's a Symbol held forever on the thread), + # so it's only OK to create a small amount of them. + # `ThreadLocalVar` has no such issue and it is fine to create many of them. + # * Ruby's built-in thread-local variables leak forever the value set on each thread (unless set to nil explicitly). + # `ThreadLocalVar` automatically removes the mapping for each thread once the `ThreadLocalVar` instance is GC'd. + # + # @!macro thread_safe_variable_comparison + # + # @example + # v = ThreadLocalVar.new(14) + # v.value #=> 14 + # v.value = 2 + # v.value #=> 2 + # + # @example + # v = ThreadLocalVar.new(14) + # + # t1 = Thread.new do + # v.value #=> 14 + # v.value = 1 + # v.value #=> 1 + # end + # + # t2 = Thread.new do + # v.value #=> 14 + # v.value = 2 + # v.value #=> 2 + # end + # + # v.value #=> 14 + class ThreadLocalVar + LOCALS = ThreadLocals.new + + # Creates a thread local variable. + # + # @param [Object] default the default value when otherwise unset + # @param [Proc] default_block Optional block that gets called to obtain the + # default value for each thread + def initialize(default = nil, &default_block) + if default && block_given? + raise ArgumentError, "Cannot use both value and block as default value" + end + + if block_given? + @default_block = default_block + @default = nil + else + @default_block = nil + @default = default + end + + @index = LOCALS.next_index(self) + end + + # Returns the value in the current thread's copy of this thread-local variable. + # + # @return [Object] the current value + def value + LOCALS.fetch(@index) { default } + end + + # Sets the current thread's copy of this thread-local variable to the specified value. + # + # @param [Object] value the value to set + # @return [Object] the new value + def value=(value) + LOCALS.set(@index, value) + end + + # Bind the given value to thread local storage during + # execution of the given block. + # + # @param [Object] value the value to bind + # @yield the operation to be performed with the bound variable + # @return [Object] the value + def bind(value) + if block_given? + old_value = self.value + self.value = value + begin + yield + ensure + self.value = old_value + end + end + end + + protected + + # @!visibility private + def default + if @default_block + self.value = @default_block.call + else + @default + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb new file mode 100644 index 0000000..5d2d7ed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb @@ -0,0 +1,37 @@ +require 'concurrent/errors' + +module Concurrent + + # Define update methods that use direct paths + # + # @!visibility private + # @!macro internal_implementation_note + module AtomicDirectUpdate + def update + true until compare_and_set(old_value = get, new_value = yield(old_value)) + new_value + end + + def try_update + old_value = get + new_value = yield old_value + + return unless compare_and_set old_value, new_value + + new_value + end + + def try_update! + old_value = get + new_value = yield old_value + unless compare_and_set(old_value, new_value) + if $VERBOSE + raise ConcurrentUpdateError, "Update failed" + else + raise ConcurrentUpdateError, "Update failed", ConcurrentUpdateError::CONC_UP_ERR_BACKTRACE + end + end + new_value + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb new file mode 100644 index 0000000..e5e2a63 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb @@ -0,0 +1,67 @@ +require 'concurrent/atomic_reference/atomic_direct_update' +require 'concurrent/atomic_reference/numeric_cas_wrapper' +require 'concurrent/synchronization/safe_initialization' + +module Concurrent + + # @!visibility private + # @!macro internal_implementation_note + class MutexAtomicReference + extend Concurrent::Synchronization::SafeInitialization + include AtomicDirectUpdate + include AtomicNumericCompareAndSetWrapper + alias_method :compare_and_swap, :compare_and_set + + # @!macro atomic_reference_method_initialize + def initialize(value = nil) + super() + @Lock = ::Mutex.new + @value = value + end + + # @!macro atomic_reference_method_get + def get + synchronize { @value } + end + alias_method :value, :get + + # @!macro atomic_reference_method_set + def set(new_value) + synchronize { @value = new_value } + end + alias_method :value=, :set + + # @!macro atomic_reference_method_get_and_set + def get_and_set(new_value) + synchronize do + old_value = @value + @value = new_value + old_value + end + end + alias_method :swap, :get_and_set + + # @!macro atomic_reference_method_compare_and_set + def _compare_and_set(old_value, new_value) + synchronize do + if @value.equal? old_value + @value = new_value + true + else + false + end + end + end + + protected + + # @!visibility private + def synchronize + if @Lock.owned? + yield + else + @Lock.synchronize { yield } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/numeric_cas_wrapper.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/numeric_cas_wrapper.rb new file mode 100644 index 0000000..709a382 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/numeric_cas_wrapper.rb @@ -0,0 +1,28 @@ +module Concurrent + + # Special "compare and set" handling of numeric values. + # + # @!visibility private + # @!macro internal_implementation_note + module AtomicNumericCompareAndSetWrapper + + # @!macro atomic_reference_method_compare_and_set + def compare_and_set(old_value, new_value) + if old_value.kind_of? Numeric + while true + old = get + + return false unless old.kind_of? Numeric + + return false unless old == old_value + + result = _compare_and_set(old, new_value) + return result if result + end + else + _compare_and_set(old_value, new_value) + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomics.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomics.rb new file mode 100644 index 0000000..16cbe66 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomics.rb @@ -0,0 +1,10 @@ +require 'concurrent/atomic/atomic_reference' +require 'concurrent/atomic/atomic_boolean' +require 'concurrent/atomic/atomic_fixnum' +require 'concurrent/atomic/cyclic_barrier' +require 'concurrent/atomic/count_down_latch' +require 'concurrent/atomic/event' +require 'concurrent/atomic/read_write_lock' +require 'concurrent/atomic/reentrant_read_write_lock' +require 'concurrent/atomic/semaphore' +require 'concurrent/atomic/thread_local_var' diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/copy_on_notify_observer_set.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/copy_on_notify_observer_set.rb new file mode 100644 index 0000000..7c700bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/copy_on_notify_observer_set.rb @@ -0,0 +1,107 @@ +require 'concurrent/synchronization/lockable_object' + +module Concurrent + module Collection + + # A thread safe observer set implemented using copy-on-read approach: + # observers are added and removed from a thread safe collection; every time + # a notification is required the internal data structure is copied to + # prevent concurrency issues + # + # @api private + class CopyOnNotifyObserverSet < Synchronization::LockableObject + + def initialize + super() + synchronize { ns_initialize } + end + + # @!macro observable_add_observer + def add_observer(observer = nil, func = :update, &block) + if observer.nil? && block.nil? + raise ArgumentError, 'should pass observer as a first argument or block' + elsif observer && block + raise ArgumentError.new('cannot provide both an observer and a block') + end + + if block + observer = block + func = :call + end + + synchronize do + @observers[observer] = func + observer + end + end + + # @!macro observable_delete_observer + def delete_observer(observer) + synchronize do + @observers.delete(observer) + observer + end + end + + # @!macro observable_delete_observers + def delete_observers + synchronize do + @observers.clear + self + end + end + + # @!macro observable_count_observers + def count_observers + synchronize { @observers.count } + end + + # Notifies all registered observers with optional args + # @param [Object] args arguments to be passed to each observer + # @return [CopyOnWriteObserverSet] self + def notify_observers(*args, &block) + observers = duplicate_observers + notify_to(observers, *args, &block) + self + end + + # Notifies all registered observers with optional args and deletes them. + # + # @param [Object] args arguments to be passed to each observer + # @return [CopyOnWriteObserverSet] self + def notify_and_delete_observers(*args, &block) + observers = duplicate_and_clear_observers + notify_to(observers, *args, &block) + self + end + + protected + + def ns_initialize + @observers = {} + end + + private + + def duplicate_and_clear_observers + synchronize do + observers = @observers.dup + @observers.clear + observers + end + end + + def duplicate_observers + synchronize { @observers.dup } + end + + def notify_to(observers, *args) + raise ArgumentError.new('cannot give arguments and a block') if block_given? && !args.empty? + observers.each do |observer, function| + args = yield if block_given? + observer.send(function, *args) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/copy_on_write_observer_set.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/copy_on_write_observer_set.rb new file mode 100644 index 0000000..bcb6750 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/copy_on_write_observer_set.rb @@ -0,0 +1,111 @@ +require 'concurrent/synchronization/lockable_object' + +module Concurrent + module Collection + + # A thread safe observer set implemented using copy-on-write approach: + # every time an observer is added or removed the whole internal data structure is + # duplicated and replaced with a new one. + # + # @api private + class CopyOnWriteObserverSet < Synchronization::LockableObject + + def initialize + super() + synchronize { ns_initialize } + end + + # @!macro observable_add_observer + def add_observer(observer = nil, func = :update, &block) + if observer.nil? && block.nil? + raise ArgumentError, 'should pass observer as a first argument or block' + elsif observer && block + raise ArgumentError.new('cannot provide both an observer and a block') + end + + if block + observer = block + func = :call + end + + synchronize do + new_observers = @observers.dup + new_observers[observer] = func + @observers = new_observers + observer + end + end + + # @!macro observable_delete_observer + def delete_observer(observer) + synchronize do + new_observers = @observers.dup + new_observers.delete(observer) + @observers = new_observers + observer + end + end + + # @!macro observable_delete_observers + def delete_observers + self.observers = {} + self + end + + # @!macro observable_count_observers + def count_observers + observers.count + end + + # Notifies all registered observers with optional args + # @param [Object] args arguments to be passed to each observer + # @return [CopyOnWriteObserverSet] self + def notify_observers(*args, &block) + notify_to(observers, *args, &block) + self + end + + # Notifies all registered observers with optional args and deletes them. + # + # @param [Object] args arguments to be passed to each observer + # @return [CopyOnWriteObserverSet] self + def notify_and_delete_observers(*args, &block) + old = clear_observers_and_return_old + notify_to(old, *args, &block) + self + end + + protected + + def ns_initialize + @observers = {} + end + + private + + def notify_to(observers, *args) + raise ArgumentError.new('cannot give arguments and a block') if block_given? && !args.empty? + observers.each do |observer, function| + args = yield if block_given? + observer.send(function, *args) + end + end + + def observers + synchronize { @observers } + end + + def observers=(new_set) + synchronize { @observers = new_set } + end + + def clear_observers_and_return_old + synchronize do + old_observers = @observers + @observers = {} + old_observers + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/java_non_concurrent_priority_queue.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/java_non_concurrent_priority_queue.rb new file mode 100644 index 0000000..2be9e43 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/java_non_concurrent_priority_queue.rb @@ -0,0 +1,84 @@ +if Concurrent.on_jruby? + + module Concurrent + module Collection + + + # @!macro priority_queue + # + # @!visibility private + # @!macro internal_implementation_note + class JavaNonConcurrentPriorityQueue + + # @!macro priority_queue_method_initialize + def initialize(opts = {}) + order = opts.fetch(:order, :max) + if [:min, :low].include?(order) + @queue = java.util.PriorityQueue.new(11) # 11 is the default initial capacity + else + @queue = java.util.PriorityQueue.new(11, java.util.Collections.reverseOrder()) + end + end + + # @!macro priority_queue_method_clear + def clear + @queue.clear + true + end + + # @!macro priority_queue_method_delete + def delete(item) + found = false + while @queue.remove(item) do + found = true + end + found + end + + # @!macro priority_queue_method_empty + def empty? + @queue.size == 0 + end + + # @!macro priority_queue_method_include + def include?(item) + @queue.contains(item) + end + alias_method :has_priority?, :include? + + # @!macro priority_queue_method_length + def length + @queue.size + end + alias_method :size, :length + + # @!macro priority_queue_method_peek + def peek + @queue.peek + end + + # @!macro priority_queue_method_pop + def pop + @queue.poll + end + alias_method :deq, :pop + alias_method :shift, :pop + + # @!macro priority_queue_method_push + def push(item) + raise ArgumentError.new('cannot enqueue nil') if item.nil? + @queue.add(item) + end + alias_method :<<, :push + alias_method :enq, :push + + # @!macro priority_queue_method_from_list + def self.from_list(list, opts = {}) + queue = new(opts) + list.each{|item| queue << item } + queue + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/lock_free_stack.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/lock_free_stack.rb new file mode 100644 index 0000000..3704410 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/lock_free_stack.rb @@ -0,0 +1,160 @@ +require 'concurrent/synchronization/object' + +module Concurrent + + # @!macro warn.edge + class LockFreeStack < Synchronization::Object + + safe_initialization! + + class Node + # TODO (pitr-ch 20-Dec-2016): Could be unified with Stack class? + + # @return [Node] + attr_reader :next_node + + # @return [Object] + attr_reader :value + + # @!visibility private + # allow to nil-ify to free GC when the entry is no longer relevant, not synchronised + attr_writer :value + + def initialize(value, next_node) + @value = value + @next_node = next_node + end + + singleton_class.send :alias_method, :[], :new + end + + # The singleton for empty node + EMPTY = Node[nil, nil] + def EMPTY.next_node + self + end + + attr_atomic(:head) + private :head, :head=, :swap_head, :compare_and_set_head, :update_head + + # @!visibility private + def self.of1(value) + new Node[value, EMPTY] + end + + # @!visibility private + def self.of2(value1, value2) + new Node[value1, Node[value2, EMPTY]] + end + + # @param [Node] head + def initialize(head = EMPTY) + super() + self.head = head + end + + # @param [Node] head + # @return [true, false] + def empty?(head = head()) + head.equal? EMPTY + end + + # @param [Node] head + # @param [Object] value + # @return [true, false] + def compare_and_push(head, value) + compare_and_set_head head, Node[value, head] + end + + # @param [Object] value + # @return [self] + def push(value) + while true + current_head = head + return self if compare_and_set_head current_head, Node[value, current_head] + end + end + + # @return [Node] + def peek + head + end + + # @param [Node] head + # @return [true, false] + def compare_and_pop(head) + compare_and_set_head head, head.next_node + end + + # @return [Object] + def pop + while true + current_head = head + return current_head.value if compare_and_set_head current_head, current_head.next_node + end + end + + # @param [Node] head + # @return [true, false] + def compare_and_clear(head) + compare_and_set_head head, EMPTY + end + + include Enumerable + + # @param [Node] head + # @return [self] + def each(head = nil) + return to_enum(:each, head) unless block_given? + it = head || peek + until it.equal?(EMPTY) + yield it.value + it = it.next_node + end + self + end + + # @return [true, false] + def clear + while true + current_head = head + return false if current_head == EMPTY + return true if compare_and_set_head current_head, EMPTY + end + end + + # @param [Node] head + # @return [true, false] + def clear_if(head) + compare_and_set_head head, EMPTY + end + + # @param [Node] head + # @param [Node] new_head + # @return [true, false] + def replace_if(head, new_head) + compare_and_set_head head, new_head + end + + # @return [self] + # @yield over the cleared stack + # @yieldparam [Object] value + def clear_each(&block) + while true + current_head = head + return self if current_head == EMPTY + if compare_and_set_head current_head, EMPTY + each current_head, &block + return self + end + end + end + + # @return [String] Short string representation. + def to_s + format '%s %s>', super[0..-2], to_a.to_s + end + + alias_method :inspect, :to_s + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb new file mode 100644 index 0000000..e0cf999 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb @@ -0,0 +1,66 @@ +require 'thread' +require 'concurrent/collection/map/non_concurrent_map_backend' + +module Concurrent + + # @!visibility private + module Collection + + # @!visibility private + class MriMapBackend < NonConcurrentMapBackend + + def initialize(options = nil, &default_proc) + super(options, &default_proc) + @write_lock = Mutex.new + end + + def []=(key, value) + @write_lock.synchronize { super } + end + + def compute_if_absent(key) + if NULL != (stored_value = @backend.fetch(key, NULL)) # fast non-blocking path for the most likely case + stored_value + else + @write_lock.synchronize { super } + end + end + + def compute_if_present(key) + @write_lock.synchronize { super } + end + + def compute(key) + @write_lock.synchronize { super } + end + + def merge_pair(key, value) + @write_lock.synchronize { super } + end + + def replace_pair(key, old_value, new_value) + @write_lock.synchronize { super } + end + + def replace_if_exists(key, new_value) + @write_lock.synchronize { super } + end + + def get_and_set(key, value) + @write_lock.synchronize { super } + end + + def delete(key) + @write_lock.synchronize { super } + end + + def delete_pair(key, value) + @write_lock.synchronize { super } + end + + def clear + @write_lock.synchronize { super } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/non_concurrent_map_backend.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/non_concurrent_map_backend.rb new file mode 100644 index 0000000..ca5fd9b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/non_concurrent_map_backend.rb @@ -0,0 +1,148 @@ +require 'concurrent/constants' + +module Concurrent + + # @!visibility private + module Collection + + # @!visibility private + class NonConcurrentMapBackend + + # WARNING: all public methods of the class must operate on the @backend + # directly without calling each other. This is important because of the + # SynchronizedMapBackend which uses a non-reentrant mutex for performance + # reasons. + def initialize(options = nil, &default_proc) + validate_options_hash!(options) if options.kind_of?(::Hash) + set_backend(default_proc) + @default_proc = default_proc + end + + def [](key) + @backend[key] + end + + def []=(key, value) + @backend[key] = value + end + + def compute_if_absent(key) + if NULL != (stored_value = @backend.fetch(key, NULL)) + stored_value + else + @backend[key] = yield + end + end + + def replace_pair(key, old_value, new_value) + if pair?(key, old_value) + @backend[key] = new_value + true + else + false + end + end + + def replace_if_exists(key, new_value) + if NULL != (stored_value = @backend.fetch(key, NULL)) + @backend[key] = new_value + stored_value + end + end + + def compute_if_present(key) + if NULL != (stored_value = @backend.fetch(key, NULL)) + store_computed_value(key, yield(stored_value)) + end + end + + def compute(key) + store_computed_value(key, yield(get_or_default(key, nil))) + end + + def merge_pair(key, value) + if NULL == (stored_value = @backend.fetch(key, NULL)) + @backend[key] = value + else + store_computed_value(key, yield(stored_value)) + end + end + + def get_and_set(key, value) + stored_value = get_or_default(key, nil) + @backend[key] = value + stored_value + end + + def key?(key) + @backend.key?(key) + end + + def delete(key) + @backend.delete(key) + end + + def delete_pair(key, value) + if pair?(key, value) + @backend.delete(key) + true + else + false + end + end + + def clear + @backend.clear + self + end + + def each_pair + dupped_backend.each_pair do |k, v| + yield k, v + end + self + end + + def size + @backend.size + end + + def get_or_default(key, default_value) + @backend.fetch(key, default_value) + end + + private + + def set_backend(default_proc) + if default_proc + @backend = ::Hash.new { |_h, key| default_proc.call(self, key) } + else + @backend = {} + end + end + + def initialize_copy(other) + super + set_backend(@default_proc) + self + end + + def dupped_backend + @backend.dup + end + + def pair?(key, expected_value) + NULL != (stored_value = @backend.fetch(key, NULL)) && expected_value.equal?(stored_value) + end + + def store_computed_value(key, new_value) + if new_value.nil? + @backend.delete(key) + nil + else + @backend[key] = new_value + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/synchronized_map_backend.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/synchronized_map_backend.rb new file mode 100644 index 0000000..efa161e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/synchronized_map_backend.rb @@ -0,0 +1,85 @@ +require 'concurrent/collection/map/non_concurrent_map_backend' + +module Concurrent + + # @!visibility private + module Collection + + # @!visibility private + class SynchronizedMapBackend < NonConcurrentMapBackend + + def initialize(*args, &block) + super + + # WARNING: Mutex is a non-reentrant lock, so the synchronized methods are + # not allowed to call each other. + @mutex = Mutex.new + end + + def [](key) + @mutex.synchronize { super } + end + + def []=(key, value) + @mutex.synchronize { super } + end + + def compute_if_absent(key) + @mutex.synchronize { super } + end + + def compute_if_present(key) + @mutex.synchronize { super } + end + + def compute(key) + @mutex.synchronize { super } + end + + def merge_pair(key, value) + @mutex.synchronize { super } + end + + def replace_pair(key, old_value, new_value) + @mutex.synchronize { super } + end + + def replace_if_exists(key, new_value) + @mutex.synchronize { super } + end + + def get_and_set(key, value) + @mutex.synchronize { super } + end + + def key?(key) + @mutex.synchronize { super } + end + + def delete(key) + @mutex.synchronize { super } + end + + def delete_pair(key, value) + @mutex.synchronize { super } + end + + def clear + @mutex.synchronize { super } + end + + def size + @mutex.synchronize { super } + end + + def get_or_default(key, default_value) + @mutex.synchronize { super } + end + + private + def dupped_backend + @mutex.synchronize { super } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/truffleruby_map_backend.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/truffleruby_map_backend.rb new file mode 100644 index 0000000..68a1b38 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/map/truffleruby_map_backend.rb @@ -0,0 +1,14 @@ +module Concurrent + + # @!visibility private + module Collection + + # @!visibility private + class TruffleRubyMapBackend < TruffleRuby::ConcurrentMap + def initialize(options = nil) + options ||= {} + super(initial_capacity: options[:initial_capacity], load_factor: options[:load_factor]) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb new file mode 100644 index 0000000..694cd7a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb @@ -0,0 +1,143 @@ +require 'concurrent/utility/engine' +require 'concurrent/collection/java_non_concurrent_priority_queue' +require 'concurrent/collection/ruby_non_concurrent_priority_queue' + +module Concurrent + module Collection + + # @!visibility private + # @!macro internal_implementation_note + NonConcurrentPriorityQueueImplementation = case + when Concurrent.on_jruby? + JavaNonConcurrentPriorityQueue + else + RubyNonConcurrentPriorityQueue + end + private_constant :NonConcurrentPriorityQueueImplementation + + # @!macro priority_queue + # + # A queue collection in which the elements are sorted based on their + # comparison (spaceship) operator `<=>`. Items are added to the queue + # at a position relative to their priority. On removal the element + # with the "highest" priority is removed. By default the sort order is + # from highest to lowest, but a lowest-to-highest sort order can be + # set on construction. + # + # The API is based on the `Queue` class from the Ruby standard library. + # + # The pure Ruby implementation, `RubyNonConcurrentPriorityQueue` uses a heap algorithm + # stored in an array. The algorithm is based on the work of Robert Sedgewick + # and Kevin Wayne. + # + # The JRuby native implementation is a thin wrapper around the standard + # library `java.util.NonConcurrentPriorityQueue`. + # + # When running under JRuby the class `NonConcurrentPriorityQueue` extends `JavaNonConcurrentPriorityQueue`. + # When running under all other interpreters it extends `RubyNonConcurrentPriorityQueue`. + # + # @note This implementation is *not* thread safe. + # + # @see http://en.wikipedia.org/wiki/Priority_queue + # @see http://ruby-doc.org/stdlib-2.0.0/libdoc/thread/rdoc/Queue.html + # + # @see http://algs4.cs.princeton.edu/24pq/index.php#2.6 + # @see http://algs4.cs.princeton.edu/24pq/MaxPQ.java.html + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html + # + # @!visibility private + class NonConcurrentPriorityQueue < NonConcurrentPriorityQueueImplementation + + alias_method :has_priority?, :include? + + alias_method :size, :length + + alias_method :deq, :pop + alias_method :shift, :pop + + alias_method :<<, :push + alias_method :enq, :push + + # @!method initialize(opts = {}) + # @!macro priority_queue_method_initialize + # + # Create a new priority queue with no items. + # + # @param [Hash] opts the options for creating the queue + # @option opts [Symbol] :order (:max) dictates the order in which items are + # stored: from highest to lowest when `:max` or `:high`; from lowest to + # highest when `:min` or `:low` + + # @!method clear + # @!macro priority_queue_method_clear + # + # Removes all of the elements from this priority queue. + + # @!method delete(item) + # @!macro priority_queue_method_delete + # + # Deletes all items from `self` that are equal to `item`. + # + # @param [Object] item the item to be removed from the queue + # @return [Object] true if the item is found else false + + # @!method empty? + # @!macro priority_queue_method_empty + # + # Returns `true` if `self` contains no elements. + # + # @return [Boolean] true if there are no items in the queue else false + + # @!method include?(item) + # @!macro priority_queue_method_include + # + # Returns `true` if the given item is present in `self` (that is, if any + # element == `item`), otherwise returns false. + # + # @param [Object] item the item to search for + # + # @return [Boolean] true if the item is found else false + + # @!method length + # @!macro priority_queue_method_length + # + # The current length of the queue. + # + # @return [Fixnum] the number of items in the queue + + # @!method peek + # @!macro priority_queue_method_peek + # + # Retrieves, but does not remove, the head of this queue, or returns `nil` + # if this queue is empty. + # + # @return [Object] the head of the queue or `nil` when empty + + # @!method pop + # @!macro priority_queue_method_pop + # + # Retrieves and removes the head of this queue, or returns `nil` if this + # queue is empty. + # + # @return [Object] the head of the queue or `nil` when empty + + # @!method push(item) + # @!macro priority_queue_method_push + # + # Inserts the specified element into this priority queue. + # + # @param [Object] item the item to insert onto the queue + + # @!method self.from_list(list, opts = {}) + # @!macro priority_queue_method_from_list + # + # Create a new priority queue from the given list. + # + # @param [Enumerable] list the list to build the queue from + # @param [Hash] opts the options for creating the queue + # + # @return [NonConcurrentPriorityQueue] the newly created and populated queue + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/ruby_non_concurrent_priority_queue.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/ruby_non_concurrent_priority_queue.rb new file mode 100644 index 0000000..322b4ac --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/collection/ruby_non_concurrent_priority_queue.rb @@ -0,0 +1,160 @@ +module Concurrent + module Collection + + # @!macro priority_queue + # + # @!visibility private + # @!macro internal_implementation_note + class RubyNonConcurrentPriorityQueue + + # @!macro priority_queue_method_initialize + def initialize(opts = {}) + order = opts.fetch(:order, :max) + @comparator = [:min, :low].include?(order) ? -1 : 1 + clear + end + + # @!macro priority_queue_method_clear + def clear + @queue = [nil] + @length = 0 + true + end + + # @!macro priority_queue_method_delete + def delete(item) + return false if empty? + original_length = @length + k = 1 + while k <= @length + if @queue[k] == item + swap(k, @length) + @length -= 1 + sink(k) || swim(k) + @queue.pop + else + k += 1 + end + end + @length != original_length + end + + # @!macro priority_queue_method_empty + def empty? + size == 0 + end + + # @!macro priority_queue_method_include + def include?(item) + @queue.include?(item) + end + alias_method :has_priority?, :include? + + # @!macro priority_queue_method_length + def length + @length + end + alias_method :size, :length + + # @!macro priority_queue_method_peek + def peek + empty? ? nil : @queue[1] + end + + # @!macro priority_queue_method_pop + def pop + return nil if empty? + max = @queue[1] + swap(1, @length) + @length -= 1 + sink(1) + @queue.pop + max + end + alias_method :deq, :pop + alias_method :shift, :pop + + # @!macro priority_queue_method_push + def push(item) + raise ArgumentError.new('cannot enqueue nil') if item.nil? + @length += 1 + @queue << item + swim(@length) + true + end + alias_method :<<, :push + alias_method :enq, :push + + # @!macro priority_queue_method_from_list + def self.from_list(list, opts = {}) + queue = new(opts) + list.each{|item| queue << item } + queue + end + + private + + # Exchange the values at the given indexes within the internal array. + # + # @param [Integer] x the first index to swap + # @param [Integer] y the second index to swap + # + # @!visibility private + def swap(x, y) + temp = @queue[x] + @queue[x] = @queue[y] + @queue[y] = temp + end + + # Are the items at the given indexes ordered based on the priority + # order specified at construction? + # + # @param [Integer] x the first index from which to retrieve a comparable value + # @param [Integer] y the second index from which to retrieve a comparable value + # + # @return [Boolean] true if the two elements are in the correct priority order + # else false + # + # @!visibility private + def ordered?(x, y) + (@queue[x] <=> @queue[y]) == @comparator + end + + # Percolate down to maintain heap invariant. + # + # @param [Integer] k the index at which to start the percolation + # + # @!visibility private + def sink(k) + success = false + + while (j = (2 * k)) <= @length do + j += 1 if j < @length && ! ordered?(j, j+1) + break if ordered?(k, j) + swap(k, j) + success = true + k = j + end + + success + end + + # Percolate up to maintain heap invariant. + # + # @param [Integer] k the index at which to start the percolation + # + # @!visibility private + def swim(k) + success = false + + while k > 1 && ! ordered?(k/2, k) do + swap(k, k/2) + k = k/2 + success = true + end + + success + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/deprecation.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/deprecation.rb new file mode 100644 index 0000000..35ae4b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/deprecation.rb @@ -0,0 +1,34 @@ +require 'concurrent/concern/logging' + +module Concurrent + module Concern + + # @!visibility private + # @!macro internal_implementation_note + module Deprecation + # TODO require additional parameter: a version. Display when it'll be removed based on that. Error if not removed. + include Concern::Logging + + def deprecated(message, strip = 2) + caller_line = caller(strip).first if strip > 0 + klass = if Module === self + self + else + self.class + end + message = if strip > 0 + format("[DEPRECATED] %s\ncalled on: %s", message, caller_line) + else + format('[DEPRECATED] %s', message) + end + log WARN, klass.to_s, message + end + + def deprecated_method(old_name, new_name) + deprecated "`#{old_name}` is deprecated and it'll removed in next release, use `#{new_name}` instead", 3 + end + + extend self + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/dereferenceable.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/dereferenceable.rb new file mode 100644 index 0000000..dc172ba --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/dereferenceable.rb @@ -0,0 +1,73 @@ +module Concurrent + module Concern + + # Object references in Ruby are mutable. This can lead to serious problems when + # the `#value` of a concurrent object is a mutable reference. Which is always the + # case unless the value is a `Fixnum`, `Symbol`, or similar "primitive" data type. + # Most classes in this library that expose a `#value` getter method do so using the + # `Dereferenceable` mixin module. + # + # @!macro copy_options + module Dereferenceable + # NOTE: This module is going away in 2.0. In the mean time we need it to + # play nicely with the synchronization layer. This means that the + # including class SHOULD be synchronized and it MUST implement a + # `#synchronize` method. Not doing so will lead to runtime errors. + + # Return the value this object represents after applying the options specified + # by the `#set_deref_options` method. + # + # @return [Object] the current value of the object + def value + synchronize { apply_deref_options(@value) } + end + alias_method :deref, :value + + protected + + # Set the internal value of this object + # + # @param [Object] value the new value + def value=(value) + synchronize{ @value = value } + end + + # @!macro dereferenceable_set_deref_options + # Set the options which define the operations #value performs before + # returning data to the caller (dereferencing). + # + # @note Most classes that include this module will call `#set_deref_options` + # from within the constructor, thus allowing these options to be set at + # object creation. + # + # @param [Hash] opts the options defining dereference behavior. + # @option opts [String] :dup_on_deref (false) call `#dup` before returning the data + # @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data + # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing + # the internal value and returning the value returned from the proc + def set_deref_options(opts = {}) + synchronize{ ns_set_deref_options(opts) } + end + + # @!macro dereferenceable_set_deref_options + # @!visibility private + def ns_set_deref_options(opts) + @dup_on_deref = opts[:dup_on_deref] || opts[:dup] + @freeze_on_deref = opts[:freeze_on_deref] || opts[:freeze] + @copy_on_deref = opts[:copy_on_deref] || opts[:copy] + @do_nothing_on_deref = !(@dup_on_deref || @freeze_on_deref || @copy_on_deref) + nil + end + + # @!visibility private + def apply_deref_options(value) + return nil if value.nil? + return value if @do_nothing_on_deref + value = @copy_on_deref.call(value) if @copy_on_deref + value = value.dup if @dup_on_deref + value = value.freeze if @freeze_on_deref + value + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/logging.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/logging.rb new file mode 100644 index 0000000..568a539 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/logging.rb @@ -0,0 +1,116 @@ +require 'logger' +require 'concurrent/atomic/atomic_reference' + +module Concurrent + module Concern + + # Include where logging is needed + # + # @!visibility private + module Logging + include Logger::Severity + + # Logs through {Concurrent.global_logger}, it can be overridden by setting @logger + # @param [Integer] level one of Logger::Severity constants + # @param [String] progname e.g. a path of an Actor + # @param [String, nil] message when nil block is used to generate the message + # @yieldreturn [String] a message + def log(level, progname, message = nil, &block) + logger = if defined?(@logger) && @logger + @logger + else + Concurrent.global_logger + end + logger.call level, progname, message, &block + rescue => error + $stderr.puts "`Concurrent.configuration.logger` failed to log #{[level, progname, message, block]}\n" + + "#{error.message} (#{error.class})\n#{error.backtrace.join "\n"}" + end + end + end +end + +module Concurrent + extend Concern::Logging + + # @return [Logger] Logger with provided level and output. + def self.create_simple_logger(level = Logger::FATAL, output = $stderr) + # TODO (pitr-ch 24-Dec-2016): figure out why it had to be replaced, stdlogger was deadlocking + lambda do |severity, progname, message = nil, &block| + return false if severity < level + + message = block ? block.call : message + formatted_message = case message + when String + message + when Exception + format "%s (%s)\n%s", + message.message, message.class, (message.backtrace || []).join("\n") + else + message.inspect + end + + output.print format "[%s] %5s -- %s: %s\n", + Time.now.strftime('%Y-%m-%d %H:%M:%S.%L'), + Logger::SEV_LABEL[severity], + progname, + formatted_message + true + end + end + + # Use logger created by #create_simple_logger to log concurrent-ruby messages. + def self.use_simple_logger(level = Logger::FATAL, output = $stderr) + Concurrent.global_logger = create_simple_logger level, output + end + + # @return [Logger] Logger with provided level and output. + # @deprecated + def self.create_stdlib_logger(level = Logger::FATAL, output = $stderr) + logger = Logger.new(output) + logger.level = level + logger.formatter = lambda do |severity, datetime, progname, msg| + formatted_message = case msg + when String + msg + when Exception + format "%s (%s)\n%s", + msg.message, msg.class, (msg.backtrace || []).join("\n") + else + msg.inspect + end + format "[%s] %5s -- %s: %s\n", + datetime.strftime('%Y-%m-%d %H:%M:%S.%L'), + severity, + progname, + formatted_message + end + + lambda do |loglevel, progname, message = nil, &block| + logger.add loglevel, message, progname, &block + end + end + + # Use logger created by #create_stdlib_logger to log concurrent-ruby messages. + # @deprecated + def self.use_stdlib_logger(level = Logger::FATAL, output = $stderr) + Concurrent.global_logger = create_stdlib_logger level, output + end + + # TODO (pitr-ch 27-Dec-2016): remove deadlocking stdlib_logger methods + + # Suppresses all output when used for logging. + NULL_LOGGER = lambda { |level, progname, message = nil, &block| } + + # @!visibility private + GLOBAL_LOGGER = AtomicReference.new(create_simple_logger(Logger::WARN)) + private_constant :GLOBAL_LOGGER + + def self.global_logger + GLOBAL_LOGGER.value + end + + def self.global_logger=(value) + GLOBAL_LOGGER.value = value + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/obligation.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/obligation.rb new file mode 100644 index 0000000..2c9ac12 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/obligation.rb @@ -0,0 +1,220 @@ +require 'thread' +require 'timeout' + +require 'concurrent/atomic/event' +require 'concurrent/concern/dereferenceable' + +module Concurrent + module Concern + + module Obligation + include Concern::Dereferenceable + # NOTE: The Dereferenceable module is going away in 2.0. In the mean time + # we need it to place nicely with the synchronization layer. This means + # that the including class SHOULD be synchronized and it MUST implement a + # `#synchronize` method. Not doing so will lead to runtime errors. + + # Has the obligation been fulfilled? + # + # @return [Boolean] + def fulfilled? + state == :fulfilled + end + alias_method :realized?, :fulfilled? + + # Has the obligation been rejected? + # + # @return [Boolean] + def rejected? + state == :rejected + end + + # Is obligation completion still pending? + # + # @return [Boolean] + def pending? + state == :pending + end + + # Is the obligation still unscheduled? + # + # @return [Boolean] + def unscheduled? + state == :unscheduled + end + + # Has the obligation completed processing? + # + # @return [Boolean] + def complete? + [:fulfilled, :rejected].include? state + end + + # Is the obligation still awaiting completion of processing? + # + # @return [Boolean] + def incomplete? + ! complete? + end + + # The current value of the obligation. Will be `nil` while the state is + # pending or the operation has been rejected. + # + # @param [Numeric] timeout the maximum time in seconds to wait. + # @return [Object] see Dereferenceable#deref + def value(timeout = nil) + wait timeout + deref + end + + # Wait until obligation is complete or the timeout has been reached. + # + # @param [Numeric] timeout the maximum time in seconds to wait. + # @return [Obligation] self + def wait(timeout = nil) + event.wait(timeout) if timeout != 0 && incomplete? + self + end + + # Wait until obligation is complete or the timeout is reached. Will re-raise + # any exceptions raised during processing (but will not raise an exception + # on timeout). + # + # @param [Numeric] timeout the maximum time in seconds to wait. + # @return [Obligation] self + # @raise [Exception] raises the reason when rejected + def wait!(timeout = nil) + wait(timeout).tap { raise self if rejected? } + end + alias_method :no_error!, :wait! + + # The current value of the obligation. Will be `nil` while the state is + # pending or the operation has been rejected. Will re-raise any exceptions + # raised during processing (but will not raise an exception on timeout). + # + # @param [Numeric] timeout the maximum time in seconds to wait. + # @return [Object] see Dereferenceable#deref + # @raise [Exception] raises the reason when rejected + def value!(timeout = nil) + wait(timeout) + if rejected? + raise self + else + deref + end + end + + # The current state of the obligation. + # + # @return [Symbol] the current state + def state + synchronize { @state } + end + + # If an exception was raised during processing this will return the + # exception object. Will return `nil` when the state is pending or if + # the obligation has been successfully fulfilled. + # + # @return [Exception] the exception raised during processing or `nil` + def reason + synchronize { @reason } + end + + # @example allows Obligation to be risen + # rejected_ivar = Ivar.new.fail + # raise rejected_ivar + def exception(*args) + raise 'obligation is not rejected' unless rejected? + reason.exception(*args) + end + + protected + + # @!visibility private + def get_arguments_from(opts = {}) + [*opts.fetch(:args, [])] + end + + # @!visibility private + def init_obligation + @event = Event.new + @value = @reason = nil + end + + # @!visibility private + def event + @event + end + + # @!visibility private + def set_state(success, value, reason) + if success + @value = value + @state = :fulfilled + else + @reason = reason + @state = :rejected + end + end + + # @!visibility private + def state=(value) + synchronize { ns_set_state(value) } + end + + # Atomic compare and set operation + # State is set to `next_state` only if `current state == expected_current`. + # + # @param [Symbol] next_state + # @param [Symbol] expected_current + # + # @return [Boolean] true is state is changed, false otherwise + # + # @!visibility private + def compare_and_set_state(next_state, *expected_current) + synchronize do + if expected_current.include? @state + @state = next_state + true + else + false + end + end + end + + # Executes the block within mutex if current state is included in expected_states + # + # @return block value if executed, false otherwise + # + # @!visibility private + def if_state(*expected_states) + synchronize do + raise ArgumentError.new('no block given') unless block_given? + + if expected_states.include? @state + yield + else + false + end + end + end + + protected + + # Am I in the current state? + # + # @param [Symbol] expected The state to check against + # @return [Boolean] true if in the expected state else false + # + # @!visibility private + def ns_check_state?(expected) + @state == expected + end + + # @!visibility private + def ns_set_state(value) + @state = value + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/observable.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/observable.rb new file mode 100644 index 0000000..b513271 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/observable.rb @@ -0,0 +1,110 @@ +require 'concurrent/collection/copy_on_notify_observer_set' +require 'concurrent/collection/copy_on_write_observer_set' + +module Concurrent + module Concern + + # The [observer pattern](http://en.wikipedia.org/wiki/Observer_pattern) is one + # of the most useful design patterns. + # + # The workflow is very simple: + # - an `observer` can register itself to a `subject` via a callback + # - many `observers` can be registered to the same `subject` + # - the `subject` notifies all registered observers when its status changes + # - an `observer` can deregister itself when is no more interested to receive + # event notifications + # + # In a single threaded environment the whole pattern is very easy: the + # `subject` can use a simple data structure to manage all its subscribed + # `observer`s and every `observer` can react directly to every event without + # caring about synchronization. + # + # In a multi threaded environment things are more complex. The `subject` must + # synchronize the access to its data structure and to do so currently we're + # using two specialized ObserverSet: {Concurrent::Concern::CopyOnWriteObserverSet} + # and {Concurrent::Concern::CopyOnNotifyObserverSet}. + # + # When implementing and `observer` there's a very important rule to remember: + # **there are no guarantees about the thread that will execute the callback** + # + # Let's take this example + # ``` + # class Observer + # def initialize + # @count = 0 + # end + # + # def update + # @count += 1 + # end + # end + # + # obs = Observer.new + # [obj1, obj2, obj3, obj4].each { |o| o.add_observer(obs) } + # # execute [obj1, obj2, obj3, obj4] + # ``` + # + # `obs` is wrong because the variable `@count` can be accessed by different + # threads at the same time, so it should be synchronized (using either a Mutex + # or an AtomicFixum) + module Observable + + # @!macro observable_add_observer + # + # Adds an observer to this set. If a block is passed, the observer will be + # created by this method and no other params should be passed. + # + # @param [Object] observer the observer to add + # @param [Symbol] func the function to call on the observer during notification. + # Default is :update + # @return [Object] the added observer + def add_observer(observer = nil, func = :update, &block) + observers.add_observer(observer, func, &block) + end + + # As `#add_observer` but can be used for chaining. + # + # @param [Object] observer the observer to add + # @param [Symbol] func the function to call on the observer during notification. + # @return [Observable] self + def with_observer(observer = nil, func = :update, &block) + add_observer(observer, func, &block) + self + end + + # @!macro observable_delete_observer + # + # Remove `observer` as an observer on this object so that it will no + # longer receive notifications. + # + # @param [Object] observer the observer to remove + # @return [Object] the deleted observer + def delete_observer(observer) + observers.delete_observer(observer) + end + + # @!macro observable_delete_observers + # + # Remove all observers associated with this object. + # + # @return [Observable] self + def delete_observers + observers.delete_observers + self + end + + # @!macro observable_count_observers + # + # Return the number of observers associated with this object. + # + # @return [Integer] the observers count + def count_observers + observers.count_observers + end + + protected + + attr_accessor :observers + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concurrent_ruby.jar b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concurrent_ruby.jar new file mode 100644 index 0000000..c0d7b15 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concurrent_ruby.jar differ diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/configuration.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/configuration.rb new file mode 100644 index 0000000..5571d39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/configuration.rb @@ -0,0 +1,105 @@ +require 'thread' +require 'concurrent/delay' +require 'concurrent/errors' +require 'concurrent/concern/deprecation' +require 'concurrent/executor/immediate_executor' +require 'concurrent/executor/fixed_thread_pool' +require 'concurrent/executor/cached_thread_pool' +require 'concurrent/utility/processor_counter' + +module Concurrent + extend Concern::Deprecation + + autoload :Options, 'concurrent/options' + autoload :TimerSet, 'concurrent/executor/timer_set' + autoload :ThreadPoolExecutor, 'concurrent/executor/thread_pool_executor' + + # @!visibility private + GLOBAL_FAST_EXECUTOR = Delay.new { Concurrent.new_fast_executor } + private_constant :GLOBAL_FAST_EXECUTOR + + # @!visibility private + GLOBAL_IO_EXECUTOR = Delay.new { Concurrent.new_io_executor } + private_constant :GLOBAL_IO_EXECUTOR + + # @!visibility private + GLOBAL_TIMER_SET = Delay.new { TimerSet.new } + private_constant :GLOBAL_TIMER_SET + + # @!visibility private + GLOBAL_IMMEDIATE_EXECUTOR = ImmediateExecutor.new + private_constant :GLOBAL_IMMEDIATE_EXECUTOR + + # Disables AtExit handlers including pool auto-termination handlers. + # When disabled it will be the application programmer's responsibility + # to ensure that the handlers are shutdown properly prior to application + # exit by calling `AtExit.run` method. + # + # @note this option should be needed only because of `at_exit` ordering + # issues which may arise when running some of the testing frameworks. + # E.g. Minitest's test-suite runs itself in `at_exit` callback which + # executes after the pools are already terminated. Then auto termination + # needs to be disabled and called manually after test-suite ends. + # @note This method should *never* be called + # from within a gem. It should *only* be used from within the main + # application and even then it should be used only when necessary. + # @deprecated Has no effect since it is no longer needed, see https://github.com/ruby-concurrency/concurrent-ruby/pull/841. + # + def self.disable_at_exit_handlers! + deprecated "Method #disable_at_exit_handlers! has no effect since it is no longer needed, see https://github.com/ruby-concurrency/concurrent-ruby/pull/841." + end + + # Global thread pool optimized for short, fast *operations*. + # + # @return [ThreadPoolExecutor] the thread pool + def self.global_fast_executor + GLOBAL_FAST_EXECUTOR.value! + end + + # Global thread pool optimized for long, blocking (IO) *tasks*. + # + # @return [ThreadPoolExecutor] the thread pool + def self.global_io_executor + GLOBAL_IO_EXECUTOR.value! + end + + def self.global_immediate_executor + GLOBAL_IMMEDIATE_EXECUTOR + end + + # Global thread pool user for global *timers*. + # + # @return [Concurrent::TimerSet] the thread pool + def self.global_timer_set + GLOBAL_TIMER_SET.value! + end + + # General access point to global executors. + # @param [Symbol, Executor] executor_identifier symbols: + # - :fast - {Concurrent.global_fast_executor} + # - :io - {Concurrent.global_io_executor} + # - :immediate - {Concurrent.global_immediate_executor} + # @return [Executor] + def self.executor(executor_identifier) + Options.executor(executor_identifier) + end + + def self.new_fast_executor(opts = {}) + FixedThreadPool.new( + [2, Concurrent.processor_count].max, + auto_terminate: opts.fetch(:auto_terminate, true), + idletime: 60, # 1 minute + max_queue: 0, # unlimited + fallback_policy: :abort, # shouldn't matter -- 0 max queue + name: "fast" + ) + end + + def self.new_io_executor(opts = {}) + CachedThreadPool.new( + auto_terminate: opts.fetch(:auto_terminate, true), + fallback_policy: :abort, # shouldn't matter -- 0 max queue + name: "io" + ) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/constants.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/constants.rb new file mode 100644 index 0000000..676c2af --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/constants.rb @@ -0,0 +1,8 @@ +module Concurrent + + # Various classes within allows for +nil+ values to be stored, + # so a special +NULL+ token is required to indicate the "nil-ness". + # @!visibility private + NULL = ::Object.new + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/dataflow.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/dataflow.rb new file mode 100644 index 0000000..d55f19d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/dataflow.rb @@ -0,0 +1,81 @@ +require 'concurrent/future' +require 'concurrent/atomic/atomic_fixnum' + +module Concurrent + + # @!visibility private + class DependencyCounter # :nodoc: + + def initialize(count, &block) + @counter = AtomicFixnum.new(count) + @block = block + end + + def update(time, value, reason) + if @counter.decrement == 0 + @block.call + end + end + end + + # Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available. + # {include:file:docs-source/dataflow.md} + # + # @param [Future] inputs zero or more `Future` operations that this dataflow depends upon + # + # @yield The operation to perform once all the dependencies are met + # @yieldparam [Future] inputs each of the `Future` inputs to the dataflow + # @yieldreturn [Object] the result of the block operation + # + # @return [Object] the result of all the operations + # + # @raise [ArgumentError] if no block is given + # @raise [ArgumentError] if any of the inputs are not `IVar`s + def dataflow(*inputs, &block) + dataflow_with(Concurrent.global_io_executor, *inputs, &block) + end + module_function :dataflow + + def dataflow_with(executor, *inputs, &block) + call_dataflow(:value, executor, *inputs, &block) + end + module_function :dataflow_with + + def dataflow!(*inputs, &block) + dataflow_with!(Concurrent.global_io_executor, *inputs, &block) + end + module_function :dataflow! + + def dataflow_with!(executor, *inputs, &block) + call_dataflow(:value!, executor, *inputs, &block) + end + module_function :dataflow_with! + + private + + def call_dataflow(method, executor, *inputs, &block) + raise ArgumentError.new('an executor must be provided') if executor.nil? + raise ArgumentError.new('no block given') unless block_given? + unless inputs.all? { |input| input.is_a? IVar } + raise ArgumentError.new("Not all dependencies are IVars.\nDependencies: #{ inputs.inspect }") + end + + result = Future.new(executor: executor) do + values = inputs.map { |input| input.send(method) } + block.call(*values) + end + + if inputs.empty? + result.execute + else + counter = DependencyCounter.new(inputs.size) { result.execute } + + inputs.each do |input| + input.add_observer counter + end + end + + result + end + module_function :call_dataflow +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/delay.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/delay.rb new file mode 100644 index 0000000..923773c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/delay.rb @@ -0,0 +1,199 @@ +require 'thread' +require 'concurrent/concern/obligation' +require 'concurrent/executor/immediate_executor' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # This file has circular require issues. It must be autoloaded here. + autoload :Options, 'concurrent/options' + + # Lazy evaluation of a block yielding an immutable result. Useful for + # expensive operations that may never be needed. It may be non-blocking, + # supports the `Concern::Obligation` interface, and accepts the injection of + # custom executor upon which to execute the block. Processing of + # block will be deferred until the first time `#value` is called. + # At that time the caller can choose to return immediately and let + # the block execute asynchronously, block indefinitely, or block + # with a timeout. + # + # When a `Delay` is created its state is set to `pending`. The value and + # reason are both `nil`. The first time the `#value` method is called the + # enclosed opration will be run and the calling thread will block. Other + # threads attempting to call `#value` will block as well. Once the operation + # is complete the *value* will be set to the result of the operation or the + # *reason* will be set to the raised exception, as appropriate. All threads + # blocked on `#value` will return. Subsequent calls to `#value` will immediately + # return the cached value. The operation will only be run once. This means that + # any side effects created by the operation will only happen once as well. + # + # `Delay` includes the `Concurrent::Concern::Dereferenceable` mixin to support thread + # safety of the reference returned by `#value`. + # + # @!macro copy_options + # + # @!macro delay_note_regarding_blocking + # @note The default behavior of `Delay` is to block indefinitely when + # calling either `value` or `wait`, executing the delayed operation on + # the current thread. This makes the `timeout` value completely + # irrelevant. To enable non-blocking behavior, use the `executor` + # constructor option. This will cause the delayed operation to be + # execute on the given executor, allowing the call to timeout. + # + # @see Concurrent::Concern::Dereferenceable + class Delay < Synchronization::LockableObject + include Concern::Obligation + + # NOTE: Because the global thread pools are lazy-loaded with these objects + # there is a performance hit every time we post a new task to one of these + # thread pools. Subsequently it is critical that `Delay` perform as fast + # as possible post-completion. This class has been highly optimized using + # the benchmark script `examples/lazy_and_delay.rb`. Do NOT attempt to + # DRY-up this class or perform other refactoring with running the + # benchmarks and ensuring that performance is not negatively impacted. + + # Create a new `Delay` in the `:pending` state. + # + # @!macro executor_and_deref_options + # + # @yield the delayed operation to perform + # + # @raise [ArgumentError] if no block is given + def initialize(opts = {}, &block) + raise ArgumentError.new('no block given') unless block_given? + super(&nil) + synchronize { ns_initialize(opts, &block) } + end + + # Return the value this object represents after applying the options + # specified by the `#set_deref_options` method. If the delayed operation + # raised an exception this method will return nil. The exception object + # can be accessed via the `#reason` method. + # + # @param [Numeric] timeout the maximum number of seconds to wait + # @return [Object] the current value of the object + # + # @!macro delay_note_regarding_blocking + def value(timeout = nil) + if @executor # TODO (pitr 12-Sep-2015): broken unsafe read? + super + else + # this function has been optimized for performance and + # should not be modified without running new benchmarks + synchronize do + execute = @evaluation_started = true unless @evaluation_started + if execute + begin + set_state(true, @task.call, nil) + rescue => ex + set_state(false, nil, ex) + end + elsif incomplete? + raise IllegalOperationError, 'Recursive call to #value during evaluation of the Delay' + end + end + if @do_nothing_on_deref + @value + else + apply_deref_options(@value) + end + end + end + + # Return the value this object represents after applying the options + # specified by the `#set_deref_options` method. If the delayed operation + # raised an exception, this method will raise that exception (even when) + # the operation has already been executed). + # + # @param [Numeric] timeout the maximum number of seconds to wait + # @return [Object] the current value of the object + # @raise [Exception] when `#rejected?` raises `#reason` + # + # @!macro delay_note_regarding_blocking + def value!(timeout = nil) + if @executor + super + else + result = value + raise @reason if @reason + result + end + end + + # Return the value this object represents after applying the options + # specified by the `#set_deref_options` method. + # + # @param [Integer] timeout (nil) the maximum number of seconds to wait for + # the value to be computed. When `nil` the caller will block indefinitely. + # + # @return [Object] self + # + # @!macro delay_note_regarding_blocking + def wait(timeout = nil) + if @executor + execute_task_once + super(timeout) + else + value + end + self + end + + # Reconfigures the block returning the value if still `#incomplete?` + # + # @yield the delayed operation to perform + # @return [true, false] if success + def reconfigure(&block) + synchronize do + raise ArgumentError.new('no block given') unless block_given? + unless @evaluation_started + @task = block + true + else + false + end + end + end + + protected + + def ns_initialize(opts, &block) + init_obligation + set_deref_options(opts) + @executor = opts[:executor] + + @task = block + @state = :pending + @evaluation_started = false + end + + private + + # @!visibility private + def execute_task_once # :nodoc: + # this function has been optimized for performance and + # should not be modified without running new benchmarks + execute = task = nil + synchronize do + execute = @evaluation_started = true unless @evaluation_started + task = @task + end + + if execute + executor = Options.executor_from_options(executor: @executor) + executor.post do + begin + result = task.call + success = true + rescue => ex + reason = ex + end + synchronize do + set_state(success, result, reason) + event.set + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/errors.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/errors.rb new file mode 100644 index 0000000..74f1fc3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/errors.rb @@ -0,0 +1,74 @@ +module Concurrent + + Error = Class.new(StandardError) + + # Raised when errors occur during configuration. + ConfigurationError = Class.new(Error) + + # Raised when an asynchronous operation is cancelled before execution. + CancelledOperationError = Class.new(Error) + + # Raised when a lifecycle method (such as `stop`) is called in an improper + # sequence or when the object is in an inappropriate state. + LifecycleError = Class.new(Error) + + # Raised when an attempt is made to violate an immutability guarantee. + ImmutabilityError = Class.new(Error) + + # Raised when an operation is attempted which is not legal given the + # receiver's current state + IllegalOperationError = Class.new(Error) + + # Raised when an object's methods are called when it has not been + # properly initialized. + InitializationError = Class.new(Error) + + # Raised when an object with a start/stop lifecycle has been started an + # excessive number of times. Often used in conjunction with a restart + # policy or strategy. + MaxRestartFrequencyError = Class.new(Error) + + # Raised when an attempt is made to modify an immutable object + # (such as an `IVar`) after its final state has been set. + class MultipleAssignmentError < Error + attr_reader :inspection_data + + def initialize(message = nil, inspection_data = nil) + @inspection_data = inspection_data + super message + end + + def inspect + format '%s %s>', super[0..-2], @inspection_data.inspect + end + end + + # Raised by an `Executor` when it is unable to process a given task, + # possibly because of a reject policy or other internal error. + RejectedExecutionError = Class.new(Error) + + # Raised when any finite resource, such as a lock counter, exceeds its + # maximum limit/threshold. + ResourceLimitError = Class.new(Error) + + # Raised when an operation times out. + TimeoutError = Class.new(Error) + + # Aggregates multiple exceptions. + class MultipleErrors < Error + attr_reader :errors + + def initialize(errors, message = "#{errors.size} errors") + @errors = errors + super [*message, + *errors.map { |e| [format('%s (%s)', e.message, e.class), *e.backtrace] }.flatten(1) + ].join("\n") + end + end + + # @!macro internal_implementation_note + class ConcurrentUpdateError < ThreadError + # frozen pre-allocated backtrace to speed ConcurrentUpdateError + CONC_UP_ERR_BACKTRACE = ['backtrace elided; set verbose to enable'].freeze + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/exchanger.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/exchanger.rb new file mode 100644 index 0000000..a5405d2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/exchanger.rb @@ -0,0 +1,353 @@ +require 'concurrent/constants' +require 'concurrent/errors' +require 'concurrent/maybe' +require 'concurrent/atomic/atomic_reference' +require 'concurrent/atomic/count_down_latch' +require 'concurrent/utility/engine' +require 'concurrent/utility/monotonic_time' + +module Concurrent + + # @!macro exchanger + # + # A synchronization point at which threads can pair and swap elements within + # pairs. Each thread presents some object on entry to the exchange method, + # matches with a partner thread, and receives its partner's object on return. + # + # @!macro thread_safe_variable_comparison + # + # This implementation is very simple, using only a single slot for each + # exchanger (unlike more advanced implementations which use an "arena"). + # This approach will work perfectly fine when there are only a few threads + # accessing a single `Exchanger`. Beyond a handful of threads the performance + # will degrade rapidly due to contention on the single slot, but the algorithm + # will remain correct. + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Exchanger.html java.util.concurrent.Exchanger + # @example + # + # exchanger = Concurrent::Exchanger.new + # + # threads = [ + # Thread.new { puts "first: " << exchanger.exchange('foo', 1) }, #=> "first: bar" + # Thread.new { puts "second: " << exchanger.exchange('bar', 1) } #=> "second: foo" + # ] + # threads.each {|t| t.join(2) } + + # @!visibility private + class AbstractExchanger < Synchronization::Object + + # @!visibility private + CANCEL = ::Object.new + private_constant :CANCEL + + def initialize + super + end + + # @!macro exchanger_method_do_exchange + # + # Waits for another thread to arrive at this exchange point (unless the + # current thread is interrupted), and then transfers the given object to + # it, receiving its object in return. The timeout value indicates the + # approximate number of seconds the method should block while waiting + # for the exchange. When the timeout value is `nil` the method will + # block indefinitely. + # + # @param [Object] value the value to exchange with another thread + # @param [Numeric, nil] timeout in seconds, `nil` blocks indefinitely + # + # @!macro exchanger_method_exchange + # + # In some edge cases when a `timeout` is given a return value of `nil` may be + # ambiguous. Specifically, if `nil` is a valid value in the exchange it will + # be impossible to tell whether `nil` is the actual return value or if it + # signifies timeout. When `nil` is a valid value in the exchange consider + # using {#exchange!} or {#try_exchange} instead. + # + # @return [Object] the value exchanged by the other thread or `nil` on timeout + def exchange(value, timeout = nil) + (value = do_exchange(value, timeout)) == CANCEL ? nil : value + end + + # @!macro exchanger_method_do_exchange + # @!macro exchanger_method_exchange_bang + # + # On timeout a {Concurrent::TimeoutError} exception will be raised. + # + # @return [Object] the value exchanged by the other thread + # @raise [Concurrent::TimeoutError] on timeout + def exchange!(value, timeout = nil) + if (value = do_exchange(value, timeout)) == CANCEL + raise Concurrent::TimeoutError + else + value + end + end + + # @!macro exchanger_method_do_exchange + # @!macro exchanger_method_try_exchange + # + # The return value will be a {Concurrent::Maybe} set to `Just` on success or + # `Nothing` on timeout. + # + # @return [Concurrent::Maybe] on success a `Just` maybe will be returned with + # the item exchanged by the other thread as `#value`; on timeout a + # `Nothing` maybe will be returned with {Concurrent::TimeoutError} as `#reason` + # + # @example + # + # exchanger = Concurrent::Exchanger.new + # + # result = exchanger.exchange(:foo, 0.5) + # + # if result.just? + # puts result.value #=> :bar + # else + # puts 'timeout' + # end + def try_exchange(value, timeout = nil) + if (value = do_exchange(value, timeout)) == CANCEL + Concurrent::Maybe.nothing(Concurrent::TimeoutError) + else + Concurrent::Maybe.just(value) + end + end + + private + + # @!macro exchanger_method_do_exchange + # + # @return [Object, CANCEL] the value exchanged by the other thread; {CANCEL} on timeout + def do_exchange(value, timeout) + raise NotImplementedError + end + end + + # @!macro internal_implementation_note + # @!visibility private + class RubyExchanger < AbstractExchanger + # A simplified version of java.util.concurrent.Exchanger written by + # Doug Lea, Bill Scherer, and Michael Scott with assistance from members + # of JCP JSR-166 Expert Group and released to the public domain. It does + # not include the arena or the multi-processor spin loops. + # http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/concurrent/Exchanger.java + + safe_initialization! + + class Node < Concurrent::Synchronization::Object + attr_atomic :value + safe_initialization! + + def initialize(item) + super() + @Item = item + @Latch = Concurrent::CountDownLatch.new + self.value = nil + end + + def latch + @Latch + end + + def item + @Item + end + end + private_constant :Node + + def initialize + super + end + + private + + attr_atomic(:slot) + + # @!macro exchanger_method_do_exchange + # + # @return [Object, CANCEL] the value exchanged by the other thread; {CANCEL} on timeout + def do_exchange(value, timeout) + + # ALGORITHM + # + # From the original Java version: + # + # > The basic idea is to maintain a "slot", which is a reference to + # > a Node containing both an Item to offer and a "hole" waiting to + # > get filled in. If an incoming "occupying" thread sees that the + # > slot is null, it CAS'es (compareAndSets) a Node there and waits + # > for another to invoke exchange. That second "fulfilling" thread + # > sees that the slot is non-null, and so CASes it back to null, + # > also exchanging items by CASing the hole, plus waking up the + # > occupying thread if it is blocked. In each case CAS'es may + # > fail because a slot at first appears non-null but is null upon + # > CAS, or vice-versa. So threads may need to retry these + # > actions. + # + # This version: + # + # An exchange occurs between an "occupier" thread and a "fulfiller" thread. + # The "slot" is used to setup this interaction. The first thread in the + # exchange puts itself into the slot (occupies) and waits for a fulfiller. + # The second thread removes the occupier from the slot and attempts to + # perform the exchange. Removing the occupier also frees the slot for + # another occupier/fulfiller pair. + # + # Because the occupier and the fulfiller are operating independently and + # because there may be contention with other threads, any failed operation + # indicates contention. Both the occupier and the fulfiller operate within + # spin loops. Any failed actions along the happy path will cause the thread + # to repeat the loop and try again. + # + # When a timeout value is given the thread must be cognizant of time spent + # in the spin loop. The remaining time is checked every loop. When the time + # runs out the thread will exit. + # + # A "node" is the data structure used to perform the exchange. Only the + # occupier's node is necessary. It's the node used for the exchange. + # Each node has an "item," a "hole" (self), and a "latch." The item is the + # node's initial value. It never changes. It's what the fulfiller returns on + # success. The occupier's hole is where the fulfiller put its item. It's the + # item that the occupier returns on success. The latch is used for synchronization. + # Because a thread may act as either an occupier or fulfiller (or possibly + # both in periods of high contention) every thread creates a node when + # the exchange method is first called. + # + # The following steps occur within the spin loop. If any actions fail + # the thread will loop and try again, so long as there is time remaining. + # If time runs out the thread will return CANCEL. + # + # Check the slot for an occupier: + # + # * If the slot is empty try to occupy + # * If the slot is full try to fulfill + # + # Attempt to occupy: + # + # * Attempt to CAS myself into the slot + # * Go to sleep and wait to be woken by a fulfiller + # * If the sleep is successful then the fulfiller completed its happy path + # - Return the value from my hole (the value given by the fulfiller) + # * When the sleep fails (time ran out) attempt to cancel the operation + # - Attempt to CAS myself out of the hole + # - If successful there is no contention + # - Return CANCEL + # - On failure, I am competing with a fulfiller + # - Attempt to CAS my hole to CANCEL + # - On success + # - Let the fulfiller deal with my cancel + # - Return CANCEL + # - On failure the fulfiller has completed its happy path + # - Return th value from my hole (the fulfiller's value) + # + # Attempt to fulfill: + # + # * Attempt to CAS the occupier out of the slot + # - On failure loop again + # * Attempt to CAS my item into the occupier's hole + # - On failure the occupier is trying to cancel + # - Loop again + # - On success we are on the happy path + # - Wake the sleeping occupier + # - Return the occupier's item + + value = NULL if value.nil? # The sentinel allows nil to be a valid value + me = Node.new(value) # create my node in case I need to occupy + end_at = Concurrent.monotonic_time + timeout.to_f # The time to give up + + result = loop do + other = slot + if other && compare_and_set_slot(other, nil) + # try to fulfill + if other.compare_and_set_value(nil, value) + # happy path + other.latch.count_down + break other.item + end + elsif other.nil? && compare_and_set_slot(nil, me) + # try to occupy + timeout = end_at - Concurrent.monotonic_time if timeout + if me.latch.wait(timeout) + # happy path + break me.value + else + # attempt to remove myself from the slot + if compare_and_set_slot(me, nil) + break CANCEL + elsif !me.compare_and_set_value(nil, CANCEL) + # I've failed to block the fulfiller + break me.value + end + end + end + break CANCEL if timeout && Concurrent.monotonic_time >= end_at + end + + result == NULL ? nil : result + end + end + + if Concurrent.on_jruby? + require 'concurrent/utility/native_extension_loader' + + # @!macro internal_implementation_note + # @!visibility private + class JavaExchanger < AbstractExchanger + + def initialize + @exchanger = java.util.concurrent.Exchanger.new + end + + private + + # @!macro exchanger_method_do_exchange + # + # @return [Object, CANCEL] the value exchanged by the other thread; {CANCEL} on timeout + def do_exchange(value, timeout) + result = nil + if timeout.nil? + Synchronization::JRuby.sleep_interruptibly do + result = @exchanger.exchange(value) + end + else + Synchronization::JRuby.sleep_interruptibly do + result = @exchanger.exchange(value, 1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS) + end + end + result + rescue java.util.concurrent.TimeoutException + CANCEL + end + end + end + + # @!visibility private + # @!macro internal_implementation_note + ExchangerImplementation = case + when Concurrent.on_jruby? + JavaExchanger + else + RubyExchanger + end + private_constant :ExchangerImplementation + + # @!macro exchanger + class Exchanger < ExchangerImplementation + + # @!method initialize + # Creates exchanger instance + + # @!method exchange(value, timeout = nil) + # @!macro exchanger_method_do_exchange + # @!macro exchanger_method_exchange + + # @!method exchange!(value, timeout = nil) + # @!macro exchanger_method_do_exchange + # @!macro exchanger_method_exchange_bang + + # @!method try_exchange(value, timeout = nil) + # @!macro exchanger_method_do_exchange + # @!macro exchanger_method_try_exchange + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/abstract_executor_service.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/abstract_executor_service.rb new file mode 100644 index 0000000..ac42953 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/abstract_executor_service.rb @@ -0,0 +1,131 @@ +require 'concurrent/errors' +require 'concurrent/concern/deprecation' +require 'concurrent/executor/executor_service' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # @!macro abstract_executor_service_public_api + # @!visibility private + class AbstractExecutorService < Synchronization::LockableObject + include ExecutorService + include Concern::Deprecation + + # The set of possible fallback policies that may be set at thread pool creation. + FALLBACK_POLICIES = [:abort, :discard, :caller_runs].freeze + + # @!macro executor_service_attr_reader_fallback_policy + attr_reader :fallback_policy + + attr_reader :name + + # Create a new thread pool. + def initialize(opts = {}, &block) + super(&nil) + synchronize do + @auto_terminate = opts.fetch(:auto_terminate, true) + @name = opts.fetch(:name) if opts.key?(:name) + ns_initialize(opts, &block) + end + end + + def to_s + name ? "#{super[0..-2]} name: #{name}>" : super + end + + # @!macro executor_service_method_shutdown + def shutdown + raise NotImplementedError + end + + # @!macro executor_service_method_kill + def kill + raise NotImplementedError + end + + # @!macro executor_service_method_wait_for_termination + def wait_for_termination(timeout = nil) + raise NotImplementedError + end + + # @!macro executor_service_method_running_question + def running? + synchronize { ns_running? } + end + + # @!macro executor_service_method_shuttingdown_question + def shuttingdown? + synchronize { ns_shuttingdown? } + end + + # @!macro executor_service_method_shutdown_question + def shutdown? + synchronize { ns_shutdown? } + end + + # @!macro executor_service_method_auto_terminate_question + def auto_terminate? + synchronize { @auto_terminate } + end + + # @!macro executor_service_method_auto_terminate_setter + def auto_terminate=(value) + deprecated "Method #auto_terminate= has no effect. Set :auto_terminate option when executor is initialized." + end + + private + + # Returns an action which executes the `fallback_policy` once the queue + # size reaches `max_queue`. The reason for the indirection of an action + # is so that the work can be deferred outside of synchronization. + # + # @param [Array] args the arguments to the task which is being handled. + # + # @!visibility private + def fallback_action(*args) + case fallback_policy + when :abort + lambda { raise RejectedExecutionError } + when :discard + lambda { false } + when :caller_runs + lambda { + begin + yield(*args) + rescue => ex + # let it fail + log DEBUG, ex + end + true + } + else + lambda { fail "Unknown fallback policy #{fallback_policy}" } + end + end + + def ns_execute(*args, &task) + raise NotImplementedError + end + + # @!macro executor_service_method_ns_shutdown_execution + # + # Callback method called when an orderly shutdown has completed. + # The default behavior is to signal all waiting threads. + def ns_shutdown_execution + # do nothing + end + + # @!macro executor_service_method_ns_kill_execution + # + # Callback method called when the executor has been killed. + # The default behavior is to do nothing. + def ns_kill_execution + # do nothing + end + + def ns_auto_terminate? + @auto_terminate + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/cached_thread_pool.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/cached_thread_pool.rb new file mode 100644 index 0000000..de50ed1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/cached_thread_pool.rb @@ -0,0 +1,62 @@ +require 'concurrent/utility/engine' +require 'concurrent/executor/thread_pool_executor' + +module Concurrent + + # A thread pool that dynamically grows and shrinks to fit the current workload. + # New threads are created as needed, existing threads are reused, and threads + # that remain idle for too long are killed and removed from the pool. These + # pools are particularly suited to applications that perform a high volume of + # short-lived tasks. + # + # On creation a `CachedThreadPool` has zero running threads. New threads are + # created on the pool as new operations are `#post`. The size of the pool + # will grow until `#max_length` threads are in the pool or until the number + # of threads exceeds the number of running and pending operations. When a new + # operation is post to the pool the first available idle thread will be tasked + # with the new operation. + # + # Should a thread crash for any reason the thread will immediately be removed + # from the pool. Similarly, threads which remain idle for an extended period + # of time will be killed and reclaimed. Thus these thread pools are very + # efficient at reclaiming unused resources. + # + # The API and behavior of this class are based on Java's `CachedThreadPool` + # + # @!macro thread_pool_options + class CachedThreadPool < ThreadPoolExecutor + + # @!macro cached_thread_pool_method_initialize + # + # Create a new thread pool. + # + # @param [Hash] opts the options defining pool behavior. + # @option opts [Symbol] :fallback_policy (`:abort`) the fallback policy + # + # @raise [ArgumentError] if `fallback_policy` is not a known policy + # + # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool-- + def initialize(opts = {}) + defaults = { idletime: DEFAULT_THREAD_IDLETIMEOUT } + overrides = { min_threads: 0, + max_threads: DEFAULT_MAX_POOL_SIZE, + max_queue: DEFAULT_MAX_QUEUE_SIZE } + super(defaults.merge(opts).merge(overrides)) + end + + private + + # @!macro cached_thread_pool_method_initialize + # @!visibility private + def ns_initialize(opts) + super(opts) + if Concurrent.on_jruby? + @max_queue = 0 + @executor = java.util.concurrent.Executors.newCachedThreadPool( + DaemonThreadFactory.new(ns_auto_terminate?)) + @executor.setRejectedExecutionHandler(FALLBACK_POLICY_CLASSES[@fallback_policy].new) + @executor.setKeepAliveTime(opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT), java.util.concurrent.TimeUnit::SECONDS) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/executor_service.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/executor_service.rb new file mode 100644 index 0000000..7e34491 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/executor_service.rb @@ -0,0 +1,185 @@ +require 'concurrent/concern/logging' + +module Concurrent + + ################################################################### + + # @!macro executor_service_method_post + # + # Submit a task to the executor for asynchronous processing. + # + # @param [Array] args zero or more arguments to be passed to the task + # + # @yield the asynchronous task to perform + # + # @return [Boolean] `true` if the task is queued, `false` if the executor + # is not running + # + # @raise [ArgumentError] if no task is given + + # @!macro executor_service_method_left_shift + # + # Submit a task to the executor for asynchronous processing. + # + # @param [Proc] task the asynchronous task to perform + # + # @return [self] returns itself + + # @!macro executor_service_method_can_overflow_question + # + # Does the task queue have a maximum size? + # + # @return [Boolean] True if the task queue has a maximum size else false. + + # @!macro executor_service_method_serialized_question + # + # Does this executor guarantee serialization of its operations? + # + # @return [Boolean] True if the executor guarantees that all operations + # will be post in the order they are received and no two operations may + # occur simultaneously. Else false. + + ################################################################### + + # @!macro executor_service_public_api + # + # @!method post(*args, &task) + # @!macro executor_service_method_post + # + # @!method <<(task) + # @!macro executor_service_method_left_shift + # + # @!method can_overflow? + # @!macro executor_service_method_can_overflow_question + # + # @!method serialized? + # @!macro executor_service_method_serialized_question + + ################################################################### + + # @!macro executor_service_attr_reader_fallback_policy + # @return [Symbol] The fallback policy in effect. Either `:abort`, `:discard`, or `:caller_runs`. + + # @!macro executor_service_method_shutdown + # + # Begin an orderly shutdown. Tasks already in the queue will be executed, + # but no new tasks will be accepted. Has no additional effect if the + # thread pool is not running. + + # @!macro executor_service_method_kill + # + # Begin an immediate shutdown. In-progress tasks will be allowed to + # complete but enqueued tasks will be dismissed and no new tasks + # will be accepted. Has no additional effect if the thread pool is + # not running. + + # @!macro executor_service_method_wait_for_termination + # + # Block until executor shutdown is complete or until `timeout` seconds have + # passed. + # + # @note Does not initiate shutdown or termination. Either `shutdown` or `kill` + # must be called before this method (or on another thread). + # + # @param [Integer] timeout the maximum number of seconds to wait for shutdown to complete + # + # @return [Boolean] `true` if shutdown complete or false on `timeout` + + # @!macro executor_service_method_running_question + # + # Is the executor running? + # + # @return [Boolean] `true` when running, `false` when shutting down or shutdown + + # @!macro executor_service_method_shuttingdown_question + # + # Is the executor shuttingdown? + # + # @return [Boolean] `true` when not running and not shutdown, else `false` + + # @!macro executor_service_method_shutdown_question + # + # Is the executor shutdown? + # + # @return [Boolean] `true` when shutdown, `false` when shutting down or running + + # @!macro executor_service_method_auto_terminate_question + # + # Is the executor auto-terminate when the application exits? + # + # @return [Boolean] `true` when auto-termination is enabled else `false`. + + # @!macro executor_service_method_auto_terminate_setter + # + # + # Set the auto-terminate behavior for this executor. + # @deprecated Has no effect + # @param [Boolean] value The new auto-terminate value to set for this executor. + # @return [Boolean] `true` when auto-termination is enabled else `false`. + + ################################################################### + + # @!macro abstract_executor_service_public_api + # + # @!macro executor_service_public_api + # + # @!attribute [r] fallback_policy + # @!macro executor_service_attr_reader_fallback_policy + # + # @!method shutdown + # @!macro executor_service_method_shutdown + # + # @!method kill + # @!macro executor_service_method_kill + # + # @!method wait_for_termination(timeout = nil) + # @!macro executor_service_method_wait_for_termination + # + # @!method running? + # @!macro executor_service_method_running_question + # + # @!method shuttingdown? + # @!macro executor_service_method_shuttingdown_question + # + # @!method shutdown? + # @!macro executor_service_method_shutdown_question + # + # @!method auto_terminate? + # @!macro executor_service_method_auto_terminate_question + # + # @!method auto_terminate=(value) + # @!macro executor_service_method_auto_terminate_setter + + ################################################################### + + # @!macro executor_service_public_api + # @!visibility private + module ExecutorService + include Concern::Logging + + # @!macro executor_service_method_post + def post(*args, &task) + raise NotImplementedError + end + + # @!macro executor_service_method_left_shift + def <<(task) + post(&task) + self + end + + # @!macro executor_service_method_can_overflow_question + # + # @note Always returns `false` + def can_overflow? + false + end + + # @!macro executor_service_method_serialized_question + # + # @note Always returns `false` + def serialized? + false + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/fixed_thread_pool.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/fixed_thread_pool.rb new file mode 100644 index 0000000..993c3f1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/fixed_thread_pool.rb @@ -0,0 +1,224 @@ +require 'concurrent/utility/engine' +require 'concurrent/executor/thread_pool_executor' + +module Concurrent + + # @!macro thread_pool_executor_constant_default_max_pool_size + # Default maximum number of threads that will be created in the pool. + + # @!macro thread_pool_executor_constant_default_min_pool_size + # Default minimum number of threads that will be retained in the pool. + + # @!macro thread_pool_executor_constant_default_max_queue_size + # Default maximum number of tasks that may be added to the task queue. + + # @!macro thread_pool_executor_constant_default_thread_timeout + # Default maximum number of seconds a thread in the pool may remain idle + # before being reclaimed. + + # @!macro thread_pool_executor_constant_default_synchronous + # Default value of the :synchronous option. + + # @!macro thread_pool_executor_attr_reader_max_length + # The maximum number of threads that may be created in the pool. + # @return [Integer] The maximum number of threads that may be created in the pool. + + # @!macro thread_pool_executor_attr_reader_min_length + # The minimum number of threads that may be retained in the pool. + # @return [Integer] The minimum number of threads that may be retained in the pool. + + # @!macro thread_pool_executor_attr_reader_largest_length + # The largest number of threads that have been created in the pool since construction. + # @return [Integer] The largest number of threads that have been created in the pool since construction. + + # @!macro thread_pool_executor_attr_reader_scheduled_task_count + # The number of tasks that have been scheduled for execution on the pool since construction. + # @return [Integer] The number of tasks that have been scheduled for execution on the pool since construction. + + # @!macro thread_pool_executor_attr_reader_completed_task_count + # The number of tasks that have been completed by the pool since construction. + # @return [Integer] The number of tasks that have been completed by the pool since construction. + + # @!macro thread_pool_executor_method_active_count + # The number of threads that are actively executing tasks. + # @return [Integer] The number of threads that are actively executing tasks. + + # @!macro thread_pool_executor_attr_reader_idletime + # The number of seconds that a thread may be idle before being reclaimed. + # @return [Integer] The number of seconds that a thread may be idle before being reclaimed. + + # @!macro thread_pool_executor_attr_reader_synchronous + # Whether or not a value of 0 for :max_queue option means the queue must perform direct hand-off or rather unbounded queue. + # @return [true, false] + + # @!macro thread_pool_executor_attr_reader_max_queue + # The maximum number of tasks that may be waiting in the work queue at any one time. + # When the queue size reaches `max_queue` subsequent tasks will be rejected in + # accordance with the configured `fallback_policy`. + # + # @return [Integer] The maximum number of tasks that may be waiting in the work queue at any one time. + # When the queue size reaches `max_queue` subsequent tasks will be rejected in + # accordance with the configured `fallback_policy`. + + # @!macro thread_pool_executor_attr_reader_length + # The number of threads currently in the pool. + # @return [Integer] The number of threads currently in the pool. + + # @!macro thread_pool_executor_attr_reader_queue_length + # The number of tasks in the queue awaiting execution. + # @return [Integer] The number of tasks in the queue awaiting execution. + + # @!macro thread_pool_executor_attr_reader_remaining_capacity + # Number of tasks that may be enqueued before reaching `max_queue` and rejecting + # new tasks. A value of -1 indicates that the queue may grow without bound. + # + # @return [Integer] Number of tasks that may be enqueued before reaching `max_queue` and rejecting + # new tasks. A value of -1 indicates that the queue may grow without bound. + + # @!macro thread_pool_executor_method_prune_pool + # Prune the thread pool of unneeded threads + # + # What is being pruned is controlled by the min_threads and idletime + # parameters passed at pool creation time + # + # This is a no-op on some pool implementation (e.g. the Java one). The Ruby + # pool will auto-prune each time a new job is posted. You will need to call + # this method explicitely in case your application post jobs in bursts (a + # lot of jobs and then nothing for long periods) + + # @!macro thread_pool_executor_public_api + # + # @!macro abstract_executor_service_public_api + # + # @!attribute [r] max_length + # @!macro thread_pool_executor_attr_reader_max_length + # + # @!attribute [r] min_length + # @!macro thread_pool_executor_attr_reader_min_length + # + # @!attribute [r] largest_length + # @!macro thread_pool_executor_attr_reader_largest_length + # + # @!attribute [r] scheduled_task_count + # @!macro thread_pool_executor_attr_reader_scheduled_task_count + # + # @!attribute [r] completed_task_count + # @!macro thread_pool_executor_attr_reader_completed_task_count + # + # @!attribute [r] idletime + # @!macro thread_pool_executor_attr_reader_idletime + # + # @!attribute [r] max_queue + # @!macro thread_pool_executor_attr_reader_max_queue + # + # @!attribute [r] length + # @!macro thread_pool_executor_attr_reader_length + # + # @!attribute [r] queue_length + # @!macro thread_pool_executor_attr_reader_queue_length + # + # @!attribute [r] remaining_capacity + # @!macro thread_pool_executor_attr_reader_remaining_capacity + # + # @!method can_overflow? + # @!macro executor_service_method_can_overflow_question + # + # @!method prune_pool + # @!macro thread_pool_executor_method_prune_pool + + + + + # @!macro thread_pool_options + # + # **Thread Pool Options** + # + # Thread pools support several configuration options: + # + # * `idletime`: The number of seconds that a thread may be idle before being reclaimed. + # * `name`: The name of the executor (optional). Printed in the executor's `#to_s` output and + # a `-worker-` name is given to its threads if supported by used Ruby + # implementation. `` is uniq for each thread. + # * `max_queue`: The maximum number of tasks that may be waiting in the work queue at + # any one time. When the queue size reaches `max_queue` and no new threads can be created, + # subsequent tasks will be rejected in accordance with the configured `fallback_policy`. + # * `auto_terminate`: When true (default), the threads started will be marked as daemon. + # * `fallback_policy`: The policy defining how rejected tasks are handled. + # + # Three fallback policies are supported: + # + # * `:abort`: Raise a `RejectedExecutionError` exception and discard the task. + # * `:discard`: Discard the task and return false. + # * `:caller_runs`: Execute the task on the calling thread. + # + # **Shutting Down Thread Pools** + # + # Killing a thread pool while tasks are still being processed, either by calling + # the `#kill` method or at application exit, will have unpredictable results. There + # is no way for the thread pool to know what resources are being used by the + # in-progress tasks. When those tasks are killed the impact on those resources + # cannot be predicted. The *best* practice is to explicitly shutdown all thread + # pools using the provided methods: + # + # * Call `#shutdown` to initiate an orderly termination of all in-progress tasks + # * Call `#wait_for_termination` with an appropriate timeout interval an allow + # the orderly shutdown to complete + # * Call `#kill` *only when* the thread pool fails to shutdown in the allotted time + # + # On some runtime platforms (most notably the JVM) the application will not + # exit until all thread pools have been shutdown. To prevent applications from + # "hanging" on exit, all threads can be marked as daemon according to the + # `:auto_terminate` option. + # + # ```ruby + # pool1 = Concurrent::FixedThreadPool.new(5) # threads will be marked as daemon + # pool2 = Concurrent::FixedThreadPool.new(5, auto_terminate: false) # mark threads as non-daemon + # ``` + # + # @note Failure to properly shutdown a thread pool can lead to unpredictable results. + # Please read *Shutting Down Thread Pools* for more information. + # + # @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html Java Tutorials: Thread Pools + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html Java Executors class + # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html Java ExecutorService interface + # @see https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#setDaemon-boolean- + + + + + + # @!macro fixed_thread_pool + # + # A thread pool that reuses a fixed number of threads operating off an unbounded queue. + # At any point, at most `num_threads` will be active processing tasks. When all threads are busy new + # tasks `#post` to the thread pool are enqueued until a thread becomes available. + # Should a thread crash for any reason the thread will immediately be removed + # from the pool and replaced. + # + # The API and behavior of this class are based on Java's `FixedThreadPool` + # + # @!macro thread_pool_options + class FixedThreadPool < ThreadPoolExecutor + + # @!macro fixed_thread_pool_method_initialize + # + # Create a new thread pool. + # + # @param [Integer] num_threads the number of threads to allocate + # @param [Hash] opts the options defining pool behavior. + # @option opts [Symbol] :fallback_policy (`:abort`) the fallback policy + # + # @raise [ArgumentError] if `num_threads` is less than or equal to zero + # @raise [ArgumentError] if `fallback_policy` is not a known policy + # + # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool-int- + def initialize(num_threads, opts = {}) + raise ArgumentError.new('number of threads must be greater than zero') if num_threads.to_i < 1 + defaults = { max_queue: DEFAULT_MAX_QUEUE_SIZE, + idletime: DEFAULT_THREAD_IDLETIMEOUT } + overrides = { min_threads: num_threads, + max_threads: num_threads } + super(defaults.merge(opts).merge(overrides)) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/immediate_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/immediate_executor.rb new file mode 100644 index 0000000..282df7a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/immediate_executor.rb @@ -0,0 +1,66 @@ +require 'concurrent/atomic/event' +require 'concurrent/executor/abstract_executor_service' +require 'concurrent/executor/serial_executor_service' + +module Concurrent + + # An executor service which runs all operations on the current thread, + # blocking as necessary. Operations are performed in the order they are + # received and no two operations can be performed simultaneously. + # + # This executor service exists mainly for testing an debugging. When used + # it immediately runs every `#post` operation on the current thread, blocking + # that thread until the operation is complete. This can be very beneficial + # during testing because it makes all operations deterministic. + # + # @note Intended for use primarily in testing and debugging. + class ImmediateExecutor < AbstractExecutorService + include SerialExecutorService + + # Creates a new executor + def initialize + @stopped = Concurrent::Event.new + end + + # @!macro executor_service_method_post + def post(*args, &task) + raise ArgumentError.new('no block given') unless block_given? + return false unless running? + task.call(*args) + true + end + + # @!macro executor_service_method_left_shift + def <<(task) + post(&task) + self + end + + # @!macro executor_service_method_running_question + def running? + ! shutdown? + end + + # @!macro executor_service_method_shuttingdown_question + def shuttingdown? + false + end + + # @!macro executor_service_method_shutdown_question + def shutdown? + @stopped.set? + end + + # @!macro executor_service_method_shutdown + def shutdown + @stopped.set + true + end + alias_method :kill, :shutdown + + # @!macro executor_service_method_wait_for_termination + def wait_for_termination(timeout = nil) + @stopped.wait(timeout) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/indirect_immediate_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/indirect_immediate_executor.rb new file mode 100644 index 0000000..4f9769f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/indirect_immediate_executor.rb @@ -0,0 +1,44 @@ +require 'concurrent/executor/immediate_executor' +require 'concurrent/executor/simple_executor_service' + +module Concurrent + # An executor service which runs all operations on a new thread, blocking + # until it completes. Operations are performed in the order they are received + # and no two operations can be performed simultaneously. + # + # This executor service exists mainly for testing an debugging. When used it + # immediately runs every `#post` operation on a new thread, blocking the + # current thread until the operation is complete. This is similar to how the + # ImmediateExecutor works, but the operation has the full stack of the new + # thread at its disposal. This can be helpful when the operations will spawn + # more operations on the same executor and so on - such a situation might + # overflow the single stack in case of an ImmediateExecutor, which is + # inconsistent with how it would behave for a threaded executor. + # + # @note Intended for use primarily in testing and debugging. + class IndirectImmediateExecutor < ImmediateExecutor + # Creates a new executor + def initialize + super + @internal_executor = SimpleExecutorService.new + end + + # @!macro executor_service_method_post + def post(*args, &task) + raise ArgumentError.new("no block given") unless block_given? + return false unless running? + + event = Concurrent::Event.new + @internal_executor.post do + begin + task.call(*args) + ensure + event.set + end + end + event.wait + + true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_executor_service.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_executor_service.rb new file mode 100644 index 0000000..b2bc69a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_executor_service.rb @@ -0,0 +1,100 @@ +require 'concurrent/utility/engine' + +if Concurrent.on_jruby? + require 'concurrent/errors' + require 'concurrent/executor/abstract_executor_service' + + module Concurrent + + # @!macro abstract_executor_service_public_api + # @!visibility private + class JavaExecutorService < AbstractExecutorService + java_import 'java.lang.Runnable' + + FALLBACK_POLICY_CLASSES = { + abort: java.util.concurrent.ThreadPoolExecutor::AbortPolicy, + discard: java.util.concurrent.ThreadPoolExecutor::DiscardPolicy, + caller_runs: java.util.concurrent.ThreadPoolExecutor::CallerRunsPolicy + }.freeze + private_constant :FALLBACK_POLICY_CLASSES + + def post(*args, &task) + raise ArgumentError.new('no block given') unless block_given? + return fallback_action(*args, &task).call unless running? + @executor.submit Job.new(args, task) + true + rescue Java::JavaUtilConcurrent::RejectedExecutionException + raise RejectedExecutionError + end + + def wait_for_termination(timeout = nil) + if timeout.nil? + ok = @executor.awaitTermination(60, java.util.concurrent.TimeUnit::SECONDS) until ok + true + else + @executor.awaitTermination(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS) + end + end + + def shutdown + synchronize do + @executor.shutdown + nil + end + end + + def kill + synchronize do + @executor.shutdownNow + nil + end + end + + private + + def ns_running? + !(ns_shuttingdown? || ns_shutdown?) + end + + def ns_shuttingdown? + @executor.isShutdown && !@executor.isTerminated + end + + def ns_shutdown? + @executor.isTerminated + end + + class Job + include Runnable + def initialize(args, block) + @args = args + @block = block + end + + def run + @block.call(*@args) + end + end + private_constant :Job + end + + class DaemonThreadFactory + # hide include from YARD + send :include, java.util.concurrent.ThreadFactory + + def initialize(daemonize = true) + @daemonize = daemonize + @java_thread_factory = java.util.concurrent.Executors.defaultThreadFactory + end + + def newThread(runnable) + thread = @java_thread_factory.newThread(runnable) + thread.setDaemon(@daemonize) + return thread + end + end + + private_constant :DaemonThreadFactory + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_single_thread_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_single_thread_executor.rb new file mode 100644 index 0000000..7aa24f2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_single_thread_executor.rb @@ -0,0 +1,30 @@ +if Concurrent.on_jruby? + + require 'concurrent/executor/java_executor_service' + require 'concurrent/executor/serial_executor_service' + + module Concurrent + + # @!macro single_thread_executor + # @!macro abstract_executor_service_public_api + # @!visibility private + class JavaSingleThreadExecutor < JavaExecutorService + include SerialExecutorService + + # @!macro single_thread_executor_method_initialize + def initialize(opts = {}) + super(opts) + end + + private + + def ns_initialize(opts) + @executor = java.util.concurrent.Executors.newSingleThreadExecutor( + DaemonThreadFactory.new(ns_auto_terminate?) + ) + @fallback_policy = opts.fetch(:fallback_policy, :discard) + raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICY_CLASSES.keys.include?(@fallback_policy) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb new file mode 100644 index 0000000..598a5f9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb @@ -0,0 +1,145 @@ +if Concurrent.on_jruby? + + require 'concurrent/executor/java_executor_service' + + module Concurrent + + # @!macro thread_pool_executor + # @!macro thread_pool_options + # @!visibility private + class JavaThreadPoolExecutor < JavaExecutorService + + # @!macro thread_pool_executor_constant_default_max_pool_size + DEFAULT_MAX_POOL_SIZE = java.lang.Integer::MAX_VALUE # 2147483647 + + # @!macro thread_pool_executor_constant_default_min_pool_size + DEFAULT_MIN_POOL_SIZE = 0 + + # @!macro thread_pool_executor_constant_default_max_queue_size + DEFAULT_MAX_QUEUE_SIZE = 0 + + # @!macro thread_pool_executor_constant_default_thread_timeout + DEFAULT_THREAD_IDLETIMEOUT = 60 + + # @!macro thread_pool_executor_constant_default_synchronous + DEFAULT_SYNCHRONOUS = false + + # @!macro thread_pool_executor_attr_reader_max_length + attr_reader :max_length + + # @!macro thread_pool_executor_attr_reader_max_queue + attr_reader :max_queue + + # @!macro thread_pool_executor_attr_reader_synchronous + attr_reader :synchronous + + # @!macro thread_pool_executor_method_initialize + def initialize(opts = {}) + super(opts) + end + + # @!macro executor_service_method_can_overflow_question + def can_overflow? + @max_queue != 0 + end + + # @!macro thread_pool_executor_attr_reader_min_length + def min_length + @executor.getCorePoolSize + end + + # @!macro thread_pool_executor_attr_reader_max_length + def max_length + @executor.getMaximumPoolSize + end + + # @!macro thread_pool_executor_attr_reader_length + def length + @executor.getPoolSize + end + + # @!macro thread_pool_executor_attr_reader_largest_length + def largest_length + @executor.getLargestPoolSize + end + + # @!macro thread_pool_executor_attr_reader_scheduled_task_count + def scheduled_task_count + @executor.getTaskCount + end + + # @!macro thread_pool_executor_attr_reader_completed_task_count + def completed_task_count + @executor.getCompletedTaskCount + end + + # @!macro thread_pool_executor_method_active_count + def active_count + @executor.getActiveCount + end + + # @!macro thread_pool_executor_attr_reader_idletime + def idletime + @executor.getKeepAliveTime(java.util.concurrent.TimeUnit::SECONDS) + end + + # @!macro thread_pool_executor_attr_reader_queue_length + def queue_length + @executor.getQueue.size + end + + # @!macro thread_pool_executor_attr_reader_remaining_capacity + def remaining_capacity + @max_queue == 0 ? -1 : @executor.getQueue.remainingCapacity + end + + # @!macro executor_service_method_running_question + def running? + super && !@executor.isTerminating + end + + # @!macro thread_pool_executor_method_prune_pool + def prune_pool + end + + private + + def ns_initialize(opts) + min_length = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i + max_length = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i + idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i + @max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i + @synchronous = opts.fetch(:synchronous, DEFAULT_SYNCHRONOUS) + @fallback_policy = opts.fetch(:fallback_policy, :abort) + + raise ArgumentError.new("`synchronous` cannot be set unless `max_queue` is 0") if @synchronous && @max_queue > 0 + raise ArgumentError.new("`max_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if max_length < DEFAULT_MIN_POOL_SIZE + raise ArgumentError.new("`max_threads` cannot be greater than #{DEFAULT_MAX_POOL_SIZE}") if max_length > DEFAULT_MAX_POOL_SIZE + raise ArgumentError.new("`min_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if min_length < DEFAULT_MIN_POOL_SIZE + raise ArgumentError.new("`min_threads` cannot be more than `max_threads`") if min_length > max_length + raise ArgumentError.new("#{fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICY_CLASSES.include?(@fallback_policy) + + if @max_queue == 0 + if @synchronous + queue = java.util.concurrent.SynchronousQueue.new + else + queue = java.util.concurrent.LinkedBlockingQueue.new + end + else + queue = java.util.concurrent.LinkedBlockingQueue.new(@max_queue) + end + + @executor = java.util.concurrent.ThreadPoolExecutor.new( + min_length, + max_length, + idletime, + java.util.concurrent.TimeUnit::SECONDS, + queue, + DaemonThreadFactory.new(ns_auto_terminate?), + FALLBACK_POLICY_CLASSES[@fallback_policy].new) + + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb new file mode 100644 index 0000000..1f7301b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb @@ -0,0 +1,82 @@ +require 'concurrent/executor/abstract_executor_service' +require 'concurrent/atomic/event' + +module Concurrent + + # @!macro abstract_executor_service_public_api + # @!visibility private + class RubyExecutorService < AbstractExecutorService + safe_initialization! + + def initialize(*args, &block) + super + @StopEvent = Event.new + @StoppedEvent = Event.new + end + + def post(*args, &task) + raise ArgumentError.new('no block given') unless block_given? + deferred_action = synchronize { + if running? + ns_execute(*args, &task) + else + fallback_action(*args, &task) + end + } + if deferred_action + deferred_action.call + else + true + end + end + + def shutdown + synchronize do + break unless running? + stop_event.set + ns_shutdown_execution + end + true + end + + def kill + synchronize do + break if shutdown? + stop_event.set + ns_kill_execution + stopped_event.set + end + true + end + + def wait_for_termination(timeout = nil) + stopped_event.wait(timeout) + end + + private + + def stop_event + @StopEvent + end + + def stopped_event + @StoppedEvent + end + + def ns_shutdown_execution + stopped_event.set + end + + def ns_running? + !stop_event.set? + end + + def ns_shuttingdown? + !(ns_running? || ns_shutdown?) + end + + def ns_shutdown? + stopped_event.set? + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_single_thread_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_single_thread_executor.rb new file mode 100644 index 0000000..916337d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_single_thread_executor.rb @@ -0,0 +1,21 @@ +require 'concurrent/executor/ruby_thread_pool_executor' + +module Concurrent + + # @!macro single_thread_executor + # @!macro abstract_executor_service_public_api + # @!visibility private + class RubySingleThreadExecutor < RubyThreadPoolExecutor + + # @!macro single_thread_executor_method_initialize + def initialize(opts = {}) + super( + min_threads: 1, + max_threads: 1, + max_queue: 0, + idletime: DEFAULT_THREAD_IDLETIMEOUT, + fallback_policy: opts.fetch(:fallback_policy, :discard), + ) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb new file mode 100644 index 0000000..9375acf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb @@ -0,0 +1,373 @@ +require 'thread' +require 'concurrent/atomic/event' +require 'concurrent/concern/logging' +require 'concurrent/executor/ruby_executor_service' +require 'concurrent/utility/monotonic_time' + +module Concurrent + + # @!macro thread_pool_executor + # @!macro thread_pool_options + # @!visibility private + class RubyThreadPoolExecutor < RubyExecutorService + + # @!macro thread_pool_executor_constant_default_max_pool_size + DEFAULT_MAX_POOL_SIZE = 2_147_483_647 # java.lang.Integer::MAX_VALUE + + # @!macro thread_pool_executor_constant_default_min_pool_size + DEFAULT_MIN_POOL_SIZE = 0 + + # @!macro thread_pool_executor_constant_default_max_queue_size + DEFAULT_MAX_QUEUE_SIZE = 0 + + # @!macro thread_pool_executor_constant_default_thread_timeout + DEFAULT_THREAD_IDLETIMEOUT = 60 + + # @!macro thread_pool_executor_constant_default_synchronous + DEFAULT_SYNCHRONOUS = false + + # @!macro thread_pool_executor_attr_reader_max_length + attr_reader :max_length + + # @!macro thread_pool_executor_attr_reader_min_length + attr_reader :min_length + + # @!macro thread_pool_executor_attr_reader_idletime + attr_reader :idletime + + # @!macro thread_pool_executor_attr_reader_max_queue + attr_reader :max_queue + + # @!macro thread_pool_executor_attr_reader_synchronous + attr_reader :synchronous + + # @!macro thread_pool_executor_method_initialize + def initialize(opts = {}) + super(opts) + end + + # @!macro thread_pool_executor_attr_reader_largest_length + def largest_length + synchronize { @largest_length } + end + + # @!macro thread_pool_executor_attr_reader_scheduled_task_count + def scheduled_task_count + synchronize { @scheduled_task_count } + end + + # @!macro thread_pool_executor_attr_reader_completed_task_count + def completed_task_count + synchronize { @completed_task_count } + end + + # @!macro thread_pool_executor_method_active_count + def active_count + synchronize do + @pool.length - @ready.length + end + end + + # @!macro executor_service_method_can_overflow_question + def can_overflow? + synchronize { ns_limited_queue? } + end + + # @!macro thread_pool_executor_attr_reader_length + def length + synchronize { @pool.length } + end + + # @!macro thread_pool_executor_attr_reader_queue_length + def queue_length + synchronize { @queue.length } + end + + # @!macro thread_pool_executor_attr_reader_remaining_capacity + def remaining_capacity + synchronize do + if ns_limited_queue? + @max_queue - @queue.length + else + -1 + end + end + end + + # @!visibility private + def remove_busy_worker(worker) + synchronize { ns_remove_busy_worker worker } + end + + # @!visibility private + def ready_worker(worker, last_message) + synchronize { ns_ready_worker worker, last_message } + end + + # @!visibility private + def worker_died(worker) + synchronize { ns_worker_died worker } + end + + # @!visibility private + def worker_task_completed + synchronize { @completed_task_count += 1 } + end + + # @!macro thread_pool_executor_method_prune_pool + def prune_pool + synchronize { ns_prune_pool } + end + + private + + # @!visibility private + def ns_initialize(opts) + @min_length = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i + @max_length = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i + @idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i + @max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i + @synchronous = opts.fetch(:synchronous, DEFAULT_SYNCHRONOUS) + @fallback_policy = opts.fetch(:fallback_policy, :abort) + + raise ArgumentError.new("`synchronous` cannot be set unless `max_queue` is 0") if @synchronous && @max_queue > 0 + raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.include?(@fallback_policy) + raise ArgumentError.new("`max_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if @max_length < DEFAULT_MIN_POOL_SIZE + raise ArgumentError.new("`max_threads` cannot be greater than #{DEFAULT_MAX_POOL_SIZE}") if @max_length > DEFAULT_MAX_POOL_SIZE + raise ArgumentError.new("`min_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if @min_length < DEFAULT_MIN_POOL_SIZE + raise ArgumentError.new("`min_threads` cannot be more than `max_threads`") if min_length > max_length + + @pool = [] # all workers + @ready = [] # used as a stash (most idle worker is at the start) + @queue = [] # used as queue + # @ready or @queue is empty at all times + @scheduled_task_count = 0 + @completed_task_count = 0 + @largest_length = 0 + @workers_counter = 0 + @ruby_pid = $$ # detects if Ruby has forked + + @gc_interval = opts.fetch(:gc_interval, @idletime / 2.0).to_i # undocumented + @next_gc_time = Concurrent.monotonic_time + @gc_interval + end + + # @!visibility private + def ns_limited_queue? + @max_queue != 0 + end + + # @!visibility private + def ns_execute(*args, &task) + ns_reset_if_forked + + if ns_assign_worker(*args, &task) || ns_enqueue(*args, &task) + @scheduled_task_count += 1 + else + return fallback_action(*args, &task) + end + + ns_prune_pool if @next_gc_time < Concurrent.monotonic_time + nil + end + + # @!visibility private + def ns_shutdown_execution + ns_reset_if_forked + + if @pool.empty? + # nothing to do + stopped_event.set + end + + if @queue.empty? + # no more tasks will be accepted, just stop all workers + @pool.each(&:stop) + end + end + + # @!visibility private + def ns_kill_execution + # TODO log out unprocessed tasks in queue + # TODO try to shutdown first? + @pool.each(&:kill) + @pool.clear + @ready.clear + end + + # tries to assign task to a worker, tries to get one from @ready or to create new one + # @return [true, false] if task is assigned to a worker + # + # @!visibility private + def ns_assign_worker(*args, &task) + # keep growing if the pool is not at the minimum yet + worker, _ = (@ready.pop if @pool.size >= @min_length) || ns_add_busy_worker + if worker + worker << [task, args] + true + else + false + end + rescue ThreadError + # Raised when the operating system refuses to create the new thread + return false + end + + # tries to enqueue task + # @return [true, false] if enqueued + # + # @!visibility private + def ns_enqueue(*args, &task) + return false if @synchronous + + if !ns_limited_queue? || @queue.size < @max_queue + @queue << [task, args] + true + else + false + end + end + + # @!visibility private + def ns_worker_died(worker) + ns_remove_busy_worker worker + replacement_worker = ns_add_busy_worker + ns_ready_worker replacement_worker, Concurrent.monotonic_time, false if replacement_worker + end + + # creates new worker which has to receive work to do after it's added + # @return [nil, Worker] nil of max capacity is reached + # + # @!visibility private + def ns_add_busy_worker + return if @pool.size >= @max_length + + @workers_counter += 1 + @pool << (worker = Worker.new(self, @workers_counter)) + @largest_length = @pool.length if @pool.length > @largest_length + worker + end + + # handle ready worker, giving it new job or assigning back to @ready + # + # @!visibility private + def ns_ready_worker(worker, last_message, success = true) + task_and_args = @queue.shift + if task_and_args + worker << task_and_args + else + # stop workers when !running?, do not return them to @ready + if running? + raise unless last_message + @ready.push([worker, last_message]) + else + worker.stop + end + end + end + + # removes a worker which is not in not tracked in @ready + # + # @!visibility private + def ns_remove_busy_worker(worker) + @pool.delete(worker) + stopped_event.set if @pool.empty? && !running? + true + end + + # try oldest worker if it is idle for enough time, it's returned back at the start + # + # @!visibility private + def ns_prune_pool + now = Concurrent.monotonic_time + stopped_workers = 0 + while !@ready.empty? && (@pool.size - stopped_workers > @min_length) + worker, last_message = @ready.first + if now - last_message > self.idletime + stopped_workers += 1 + @ready.shift + worker << :stop + else break + end + end + + @next_gc_time = Concurrent.monotonic_time + @gc_interval + end + + def ns_reset_if_forked + if $$ != @ruby_pid + @queue.clear + @ready.clear + @pool.clear + @scheduled_task_count = 0 + @completed_task_count = 0 + @largest_length = 0 + @workers_counter = 0 + @ruby_pid = $$ + end + end + + # @!visibility private + class Worker + include Concern::Logging + + def initialize(pool, id) + # instance variables accessed only under pool's lock so no need to sync here again + @queue = Queue.new + @pool = pool + @thread = create_worker @queue, pool, pool.idletime + + if @thread.respond_to?(:name=) + @thread.name = [pool.name, 'worker', id].compact.join('-') + end + end + + def <<(message) + @queue << message + end + + def stop + @queue << :stop + end + + def kill + @thread.kill + end + + private + + def create_worker(queue, pool, idletime) + Thread.new(queue, pool, idletime) do |my_queue, my_pool, my_idletime| + catch(:stop) do + loop do + + case message = my_queue.pop + when :stop + my_pool.remove_busy_worker(self) + throw :stop + + else + task, args = message + run_task my_pool, task, args + my_pool.ready_worker(self, Concurrent.monotonic_time) + end + end + end + end + end + + def run_task(pool, task, args) + task.call(*args) + pool.worker_task_completed + rescue => ex + # let it fail + log DEBUG, ex + rescue Exception => ex + log ERROR, ex + pool.worker_died(self) + throw :stop + end + end + + private_constant :Worker + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb new file mode 100644 index 0000000..f796b85 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb @@ -0,0 +1,35 @@ +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # A simple utility class that executes a callable and returns and array of three elements: + # success - indicating if the callable has been executed without errors + # value - filled by the callable result if it has been executed without errors, nil otherwise + # reason - the error risen by the callable if it has been executed with errors, nil otherwise + class SafeTaskExecutor < Synchronization::LockableObject + + def initialize(task, opts = {}) + @task = task + @exception_class = opts.fetch(:rescue_exception, false) ? Exception : StandardError + super() # ensures visibility + end + + # @return [Array] + def execute(*args) + success = true + value = reason = nil + + synchronize do + begin + value = @task.call(*args) + success = true + rescue @exception_class => ex + reason = ex + success = false + end + end + + [success, value, reason] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serial_executor_service.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serial_executor_service.rb new file mode 100644 index 0000000..f1c38ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serial_executor_service.rb @@ -0,0 +1,34 @@ +require 'concurrent/executor/executor_service' + +module Concurrent + + # Indicates that the including `ExecutorService` guarantees + # that all operations will occur in the order they are post and that no + # two operations may occur simultaneously. This module provides no + # functionality and provides no guarantees. That is the responsibility + # of the including class. This module exists solely to allow the including + # object to be interrogated for its serialization status. + # + # @example + # class Foo + # include Concurrent::SerialExecutor + # end + # + # foo = Foo.new + # + # foo.is_a? Concurrent::ExecutorService #=> true + # foo.is_a? Concurrent::SerialExecutor #=> true + # foo.serialized? #=> true + # + # @!visibility private + module SerialExecutorService + include ExecutorService + + # @!macro executor_service_method_serialized_question + # + # @note Always returns `true` + def serialized? + true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serialized_execution.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serialized_execution.rb new file mode 100644 index 0000000..4db7c7f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serialized_execution.rb @@ -0,0 +1,107 @@ +require 'concurrent/errors' +require 'concurrent/concern/logging' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # Ensures passed jobs in a serialized order never running at the same time. + class SerializedExecution < Synchronization::LockableObject + include Concern::Logging + + def initialize() + super() + synchronize { ns_initialize } + end + + Job = Struct.new(:executor, :args, :block) do + def call + block.call(*args) + end + end + + # Submit a task to the executor for asynchronous processing. + # + # @param [Executor] executor to be used for this job + # + # @param [Array] args zero or more arguments to be passed to the task + # + # @yield the asynchronous task to perform + # + # @return [Boolean] `true` if the task is queued, `false` if the executor + # is not running + # + # @raise [ArgumentError] if no task is given + def post(executor, *args, &task) + posts [[executor, args, task]] + true + end + + # As {#post} but allows to submit multiple tasks at once, it's guaranteed that they will not + # be interleaved by other tasks. + # + # @param [Array, Proc)>] posts array of triplets where + # first is a {ExecutorService}, second is array of args for task, third is a task (Proc) + def posts(posts) + # if can_overflow? + # raise ArgumentError, 'SerializedExecution does not support thread-pools which can overflow' + # end + + return nil if posts.empty? + + jobs = posts.map { |executor, args, task| Job.new executor, args, task } + + job_to_post = synchronize do + if @being_executed + @stash.push(*jobs) + nil + else + @being_executed = true + @stash.push(*jobs[1..-1]) + jobs.first + end + end + + call_job job_to_post if job_to_post + true + end + + private + + def ns_initialize + @being_executed = false + @stash = [] + end + + def call_job(job) + did_it_run = begin + job.executor.post { work(job) } + true + rescue RejectedExecutionError => ex + false + end + + # TODO not the best idea to run it myself + unless did_it_run + begin + work job + rescue => ex + # let it fail + log DEBUG, ex + end + end + end + + # ensures next job is executed if any is stashed + def work(job) + job.call + ensure + synchronize do + job = @stash.shift || (@being_executed = false) + end + + # TODO maybe be able to tell caching pool to just enqueue this job, because the current one end at the end + # of this block + call_job job if job + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb new file mode 100644 index 0000000..8197781 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb @@ -0,0 +1,28 @@ +require 'delegate' +require 'concurrent/executor/serial_executor_service' +require 'concurrent/executor/serialized_execution' + +module Concurrent + + # A wrapper/delegator for any `ExecutorService` that + # guarantees serialized execution of tasks. + # + # @see [SimpleDelegator](http://www.ruby-doc.org/stdlib-2.1.2/libdoc/delegate/rdoc/SimpleDelegator.html) + # @see Concurrent::SerializedExecution + class SerializedExecutionDelegator < SimpleDelegator + include SerialExecutorService + + def initialize(executor) + @executor = executor + @serializer = SerializedExecution.new + super(executor) + end + + # @!macro executor_service_method_post + def post(*args, &task) + raise ArgumentError.new('no block given') unless block_given? + return false unless running? + @serializer.post(@executor, *args, &task) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/simple_executor_service.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/simple_executor_service.rb new file mode 100644 index 0000000..0bc62af --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/simple_executor_service.rb @@ -0,0 +1,103 @@ +require 'concurrent/atomic/atomic_boolean' +require 'concurrent/atomic/atomic_fixnum' +require 'concurrent/atomic/event' +require 'concurrent/executor/executor_service' +require 'concurrent/executor/ruby_executor_service' + +module Concurrent + + # An executor service in which every operation spawns a new, + # independently operating thread. + # + # This is perhaps the most inefficient executor service in this + # library. It exists mainly for testing an debugging. Thread creation + # and management is expensive in Ruby and this executor performs no + # resource pooling. This can be very beneficial during testing and + # debugging because it decouples the using code from the underlying + # executor implementation. In production this executor will likely + # lead to suboptimal performance. + # + # @note Intended for use primarily in testing and debugging. + class SimpleExecutorService < RubyExecutorService + + # @!macro executor_service_method_post + def self.post(*args) + raise ArgumentError.new('no block given') unless block_given? + Thread.new(*args) do + Thread.current.abort_on_exception = false + yield(*args) + end + true + end + + # @!macro executor_service_method_left_shift + def self.<<(task) + post(&task) + self + end + + # @!macro executor_service_method_post + def post(*args, &task) + raise ArgumentError.new('no block given') unless block_given? + return false unless running? + @count.increment + Thread.new(*args) do + Thread.current.abort_on_exception = false + begin + yield(*args) + ensure + @count.decrement + @stopped.set if @running.false? && @count.value == 0 + end + end + end + + # @!macro executor_service_method_left_shift + def <<(task) + post(&task) + self + end + + # @!macro executor_service_method_running_question + def running? + @running.true? + end + + # @!macro executor_service_method_shuttingdown_question + def shuttingdown? + @running.false? && ! @stopped.set? + end + + # @!macro executor_service_method_shutdown_question + def shutdown? + @stopped.set? + end + + # @!macro executor_service_method_shutdown + def shutdown + @running.make_false + @stopped.set if @count.value == 0 + true + end + + # @!macro executor_service_method_kill + def kill + @running.make_false + @stopped.set + true + end + + # @!macro executor_service_method_wait_for_termination + def wait_for_termination(timeout = nil) + @stopped.wait(timeout) + end + + private + + def ns_initialize(*args) + @running = Concurrent::AtomicBoolean.new(true) + @stopped = Concurrent::Event.new + @count = Concurrent::AtomicFixnum.new(0) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/single_thread_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/single_thread_executor.rb new file mode 100644 index 0000000..f1474ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/single_thread_executor.rb @@ -0,0 +1,57 @@ +require 'concurrent/utility/engine' +require 'concurrent/executor/ruby_single_thread_executor' + +module Concurrent + + if Concurrent.on_jruby? + require 'concurrent/executor/java_single_thread_executor' + end + + SingleThreadExecutorImplementation = case + when Concurrent.on_jruby? + JavaSingleThreadExecutor + else + RubySingleThreadExecutor + end + private_constant :SingleThreadExecutorImplementation + + # @!macro single_thread_executor + # + # A thread pool with a single thread an unlimited queue. Should the thread + # die for any reason it will be removed and replaced, thus ensuring that + # the executor will always remain viable and available to process jobs. + # + # A common pattern for background processing is to create a single thread + # on which an infinite loop is run. The thread's loop blocks on an input + # source (perhaps blocking I/O or a queue) and processes each input as it + # is received. This pattern has several issues. The thread itself is highly + # susceptible to errors during processing. Also, the thread itself must be + # constantly monitored and restarted should it die. `SingleThreadExecutor` + # encapsulates all these bahaviors. The task processor is highly resilient + # to errors from within tasks. Also, should the thread die it will + # automatically be restarted. + # + # The API and behavior of this class are based on Java's `SingleThreadExecutor`. + # + # @!macro abstract_executor_service_public_api + class SingleThreadExecutor < SingleThreadExecutorImplementation + + # @!macro single_thread_executor_method_initialize + # + # Create a new thread pool. + # + # @option opts [Symbol] :fallback_policy (:discard) the policy for handling new + # tasks that are received when the queue size has reached + # `max_queue` or the executor has shut down + # + # @raise [ArgumentError] if `:fallback_policy` is not one of the values specified + # in `FALLBACK_POLICIES` + # + # @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html + # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html + + # @!method initialize(opts = {}) + # @!macro single_thread_executor_method_initialize + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/thread_pool_executor.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/thread_pool_executor.rb new file mode 100644 index 0000000..253d46a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/thread_pool_executor.rb @@ -0,0 +1,88 @@ +require 'concurrent/utility/engine' +require 'concurrent/executor/ruby_thread_pool_executor' + +module Concurrent + + if Concurrent.on_jruby? + require 'concurrent/executor/java_thread_pool_executor' + end + + ThreadPoolExecutorImplementation = case + when Concurrent.on_jruby? + JavaThreadPoolExecutor + else + RubyThreadPoolExecutor + end + private_constant :ThreadPoolExecutorImplementation + + # @!macro thread_pool_executor + # + # An abstraction composed of one or more threads and a task queue. Tasks + # (blocks or `proc` objects) are submitted to the pool and added to the queue. + # The threads in the pool remove the tasks and execute them in the order + # they were received. + # + # A `ThreadPoolExecutor` will automatically adjust the pool size according + # to the bounds set by `min-threads` and `max-threads`. When a new task is + # submitted and fewer than `min-threads` threads are running, a new thread + # is created to handle the request, even if other worker threads are idle. + # If there are more than `min-threads` but less than `max-threads` threads + # running, a new thread will be created only if the queue is full. + # + # Threads that are idle for too long will be garbage collected, down to the + # configured minimum options. Should a thread crash it, too, will be garbage collected. + # + # `ThreadPoolExecutor` is based on the Java class of the same name. From + # the official Java documentation; + # + # > Thread pools address two different problems: they usually provide + # > improved performance when executing large numbers of asynchronous tasks, + # > due to reduced per-task invocation overhead, and they provide a means + # > of bounding and managing the resources, including threads, consumed + # > when executing a collection of tasks. Each ThreadPoolExecutor also + # > maintains some basic statistics, such as the number of completed tasks. + # > + # > To be useful across a wide range of contexts, this class provides many + # > adjustable parameters and extensibility hooks. However, programmers are + # > urged to use the more convenient Executors factory methods + # > [CachedThreadPool] (unbounded thread pool, with automatic thread reclamation), + # > [FixedThreadPool] (fixed size thread pool) and [SingleThreadExecutor] (single + # > background thread), that preconfigure settings for the most common usage + # > scenarios. + # + # @!macro thread_pool_options + # + # @!macro thread_pool_executor_public_api + class ThreadPoolExecutor < ThreadPoolExecutorImplementation + + # @!macro thread_pool_executor_method_initialize + # + # Create a new thread pool. + # + # @param [Hash] opts the options which configure the thread pool. + # + # @option opts [Integer] :max_threads (DEFAULT_MAX_POOL_SIZE) the maximum + # number of threads to be created + # @option opts [Integer] :min_threads (DEFAULT_MIN_POOL_SIZE) When a new task is submitted + # and fewer than `min_threads` are running, a new thread is created + # @option opts [Integer] :idletime (DEFAULT_THREAD_IDLETIMEOUT) the maximum + # number of seconds a thread may be idle before being reclaimed + # @option opts [Integer] :max_queue (DEFAULT_MAX_QUEUE_SIZE) the maximum + # number of tasks allowed in the work queue at any one time; a value of + # zero means the queue may grow without bound + # @option opts [Symbol] :fallback_policy (:abort) the policy for handling new + # tasks that are received when the queue size has reached + # `max_queue` or the executor has shut down + # @option opts [Boolean] :synchronous (DEFAULT_SYNCHRONOUS) whether or not a value of 0 + # for :max_queue means the queue must perform direct hand-off rather than unbounded. + # @raise [ArgumentError] if `:max_threads` is less than one + # @raise [ArgumentError] if `:min_threads` is less than zero + # @raise [ArgumentError] if `:fallback_policy` is not one of the values specified + # in `FALLBACK_POLICIES` + # + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html + + # @!method initialize(opts = {}) + # @!macro thread_pool_executor_method_initialize + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/timer_set.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/timer_set.rb new file mode 100644 index 0000000..759dce0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/timer_set.rb @@ -0,0 +1,176 @@ +require 'concurrent/scheduled_task' +require 'concurrent/atomic/event' +require 'concurrent/collection/non_concurrent_priority_queue' +require 'concurrent/executor/executor_service' +require 'concurrent/executor/single_thread_executor' +require 'concurrent/errors' +require 'concurrent/options' + +module Concurrent + + # Executes a collection of tasks, each after a given delay. A master task + # monitors the set and schedules each task for execution at the appropriate + # time. Tasks are run on the global thread pool or on the supplied executor. + # Each task is represented as a `ScheduledTask`. + # + # @see Concurrent::ScheduledTask + # + # @!macro monotonic_clock_warning + class TimerSet < RubyExecutorService + + # Create a new set of timed tasks. + # + # @!macro executor_options + # + # @param [Hash] opts the options used to specify the executor on which to perform actions + # @option opts [Executor] :executor when set use the given `Executor` instance. + # Three special values are also supported: `:task` returns the global task pool, + # `:operation` returns the global operation pool, and `:immediate` returns a new + # `ImmediateExecutor` object. + def initialize(opts = {}) + super(opts) + end + + # Post a task to be execute run after a given delay (in seconds). If the + # delay is less than 1/100th of a second the task will be immediately post + # to the executor. + # + # @param [Float] delay the number of seconds to wait for before executing the task. + # @param [Array] args the arguments passed to the task on execution. + # + # @yield the task to be performed. + # + # @return [Concurrent::ScheduledTask, false] IVar representing the task if the post + # is successful; false after shutdown. + # + # @raise [ArgumentError] if the intended execution time is not in the future. + # @raise [ArgumentError] if no block is given. + def post(delay, *args, &task) + raise ArgumentError.new('no block given') unless block_given? + return false unless running? + opts = { executor: @task_executor, + args: args, + timer_set: self } + task = ScheduledTask.execute(delay, opts, &task) # may raise exception + task.unscheduled? ? false : task + end + + # Begin an immediate shutdown. In-progress tasks will be allowed to + # complete but enqueued tasks will be dismissed and no new tasks + # will be accepted. Has no additional effect if the thread pool is + # not running. + def kill + shutdown + end + + private :<< + + private + + # Initialize the object. + # + # @param [Hash] opts the options to create the object with. + # @!visibility private + def ns_initialize(opts) + @queue = Collection::NonConcurrentPriorityQueue.new(order: :min) + @task_executor = Options.executor_from_options(opts) || Concurrent.global_io_executor + @timer_executor = SingleThreadExecutor.new + @condition = Event.new + @ruby_pid = $$ # detects if Ruby has forked + end + + # Post the task to the internal queue. + # + # @note This is intended as a callback method from ScheduledTask + # only. It is not intended to be used directly. Post a task + # by using the `SchedulesTask#execute` method. + # + # @!visibility private + def post_task(task) + synchronize { ns_post_task(task) } + end + + # @!visibility private + def ns_post_task(task) + return false unless ns_running? + ns_reset_if_forked + if (task.initial_delay) <= 0.01 + task.executor.post { task.process_task } + else + @queue.push(task) + # only post the process method when the queue is empty + @timer_executor.post(&method(:process_tasks)) if @queue.length == 1 + @condition.set + end + true + end + + # Remove the given task from the queue. + # + # @note This is intended as a callback method from `ScheduledTask` + # only. It is not intended to be used directly. Cancel a task + # by using the `ScheduledTask#cancel` method. + # + # @!visibility private + def remove_task(task) + synchronize { @queue.delete(task) } + end + + # `ExecutorService` callback called during shutdown. + # + # @!visibility private + def ns_shutdown_execution + ns_reset_if_forked + @queue.clear + @timer_executor.kill + stopped_event.set + end + + def ns_reset_if_forked + if $$ != @ruby_pid + @queue.clear + @condition.reset + @ruby_pid = $$ + end + end + + # Run a loop and execute tasks in the scheduled order and at the approximate + # scheduled time. If no tasks remain the thread will exit gracefully so that + # garbage collection can occur. If there are no ready tasks it will sleep + # for up to 60 seconds waiting for the next scheduled task. + # + # @!visibility private + def process_tasks + loop do + task = synchronize { @condition.reset; @queue.peek } + break unless task + + now = Concurrent.monotonic_time + diff = task.schedule_time - now + + if diff <= 0 + # We need to remove the task from the queue before passing + # it to the executor, to avoid race conditions where we pass + # the peek'ed task to the executor and then pop a different + # one that's been added in the meantime. + # + # Note that there's no race condition between the peek and + # this pop - this pop could retrieve a different task from + # the peek, but that task would be due to fire now anyway + # (because @queue is a priority queue, and this thread is + # the only reader, so whatever timer is at the head of the + # queue now must have the same pop time, or a closer one, as + # when we peeked). + task = synchronize { @queue.pop } + begin + task.executor.post { task.process_task } + rescue RejectedExecutionError + # ignore and continue + end + else + @condition.wait([diff, 60].min) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executors.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executors.rb new file mode 100644 index 0000000..eb1972c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executors.rb @@ -0,0 +1,20 @@ +require 'concurrent/executor/abstract_executor_service' +require 'concurrent/executor/cached_thread_pool' +require 'concurrent/executor/executor_service' +require 'concurrent/executor/fixed_thread_pool' +require 'concurrent/executor/immediate_executor' +require 'concurrent/executor/indirect_immediate_executor' +require 'concurrent/executor/java_executor_service' +require 'concurrent/executor/java_single_thread_executor' +require 'concurrent/executor/java_thread_pool_executor' +require 'concurrent/executor/ruby_executor_service' +require 'concurrent/executor/ruby_single_thread_executor' +require 'concurrent/executor/ruby_thread_pool_executor' +require 'concurrent/executor/cached_thread_pool' +require 'concurrent/executor/safe_task_executor' +require 'concurrent/executor/serial_executor_service' +require 'concurrent/executor/serialized_execution' +require 'concurrent/executor/serialized_execution_delegator' +require 'concurrent/executor/single_thread_executor' +require 'concurrent/executor/thread_pool_executor' +require 'concurrent/executor/timer_set' diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/future.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/future.rb new file mode 100644 index 0000000..1af182e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/future.rb @@ -0,0 +1,141 @@ +require 'thread' +require 'concurrent/constants' +require 'concurrent/errors' +require 'concurrent/ivar' +require 'concurrent/executor/safe_task_executor' + +require 'concurrent/options' + +# TODO (pitr-ch 14-Mar-2017): deprecate, Future, Promise, etc. + + +module Concurrent + + # {include:file:docs-source/future.md} + # + # @!macro copy_options + # + # @see http://ruby-doc.org/stdlib-2.1.1/libdoc/observer/rdoc/Observable.html Ruby Observable module + # @see http://clojuredocs.org/clojure_core/clojure.core/future Clojure's future function + # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html java.util.concurrent.Future + class Future < IVar + + # Create a new `Future` in the `:unscheduled` state. + # + # @yield the asynchronous operation to perform + # + # @!macro executor_and_deref_options + # + # @option opts [object, Array] :args zero or more arguments to be passed the task + # block on execution + # + # @raise [ArgumentError] if no block is given + def initialize(opts = {}, &block) + raise ArgumentError.new('no block given') unless block_given? + super(NULL, opts.merge(__task_from_block__: block), &nil) + end + + # Execute an `:unscheduled` `Future`. Immediately sets the state to `:pending` and + # passes the block to a new thread/thread pool for eventual execution. + # Does nothing if the `Future` is in any state other than `:unscheduled`. + # + # @return [Future] a reference to `self` + # + # @example Instance and execute in separate steps + # future = Concurrent::Future.new{ sleep(1); 42 } + # future.state #=> :unscheduled + # future.execute + # future.state #=> :pending + # + # @example Instance and execute in one line + # future = Concurrent::Future.new{ sleep(1); 42 }.execute + # future.state #=> :pending + def execute + if compare_and_set_state(:pending, :unscheduled) + @executor.post{ safe_execute(@task, @args) } + self + end + end + + # Create a new `Future` object with the given block, execute it, and return the + # `:pending` object. + # + # @yield the asynchronous operation to perform + # + # @!macro executor_and_deref_options + # + # @option opts [object, Array] :args zero or more arguments to be passed the task + # block on execution + # + # @raise [ArgumentError] if no block is given + # + # @return [Future] the newly created `Future` in the `:pending` state + # + # @example + # future = Concurrent::Future.execute{ sleep(1); 42 } + # future.state #=> :pending + def self.execute(opts = {}, &block) + Future.new(opts, &block).execute + end + + # @!macro ivar_set_method + def set(value = NULL, &block) + check_for_block_or_value!(block_given?, value) + synchronize do + if @state != :unscheduled + raise MultipleAssignmentError + else + @task = block || Proc.new { value } + end + end + execute + end + + # Attempt to cancel the operation if it has not already processed. + # The operation can only be cancelled while still `pending`. It cannot + # be cancelled once it has begun processing or has completed. + # + # @return [Boolean] was the operation successfully cancelled. + def cancel + if compare_and_set_state(:cancelled, :pending) + complete(false, nil, CancelledOperationError.new) + true + else + false + end + end + + # Has the operation been successfully cancelled? + # + # @return [Boolean] + def cancelled? + state == :cancelled + end + + # Wait the given number of seconds for the operation to complete. + # On timeout attempt to cancel the operation. + # + # @param [Numeric] timeout the maximum time in seconds to wait. + # @return [Boolean] true if the operation completed before the timeout + # else false + def wait_or_cancel(timeout) + wait(timeout) + if complete? + true + else + cancel + false + end + end + + protected + + def ns_initialize(value, opts) + super + @state = :unscheduled + @task = opts[:__task_from_block__] + @executor = Options.executor_from_options(opts) || Concurrent.global_io_executor + @args = get_arguments_from(opts) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/hash.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/hash.rb new file mode 100644 index 0000000..db0208e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/hash.rb @@ -0,0 +1,52 @@ +require 'concurrent/utility/engine' +require 'concurrent/thread_safe/util' + +module Concurrent + + # @!macro concurrent_hash + # + # A thread-safe subclass of Hash. This version locks against the object + # itself for every method call, ensuring only one thread can be reading + # or writing at a time. This includes iteration methods like `#each`, + # which takes the lock repeatedly when reading an item. + # + # @see http://ruby-doc.org/core/Hash.html Ruby standard library `Hash` + + # @!macro internal_implementation_note + HashImplementation = case + when Concurrent.on_cruby? + # Hash is not fully thread-safe on CRuby, see + # https://bugs.ruby-lang.org/issues/19237 + # https://github.com/ruby/ruby/commit/ffd52412ab + # https://github.com/ruby-concurrency/concurrent-ruby/issues/929 + # So we will need to add synchronization here (similar to Concurrent::Map). + ::Hash + + when Concurrent.on_jruby? + require 'jruby/synchronized' + + class JRubyHash < ::Hash + include JRuby::Synchronized + end + JRubyHash + + when Concurrent.on_truffleruby? + require 'concurrent/thread_safe/util/data_structures' + + class TruffleRubyHash < ::Hash + end + + ThreadSafe::Util.make_synchronized_on_truffleruby TruffleRubyHash + TruffleRubyHash + + else + warn 'Possibly unsupported Ruby implementation' + ::Hash + end + private_constant :HashImplementation + + # @!macro concurrent_hash + class Hash < HashImplementation + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/immutable_struct.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/immutable_struct.rb new file mode 100644 index 0000000..48462e8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/immutable_struct.rb @@ -0,0 +1,101 @@ +require 'concurrent/synchronization/abstract_struct' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # A thread-safe, immutable variation of Ruby's standard `Struct`. + # + # @see http://ruby-doc.org/core/Struct.html Ruby standard library `Struct` + module ImmutableStruct + include Synchronization::AbstractStruct + + def self.included(base) + base.safe_initialization! + end + + # @!macro struct_values + def values + ns_values + end + + alias_method :to_a, :values + + # @!macro struct_values_at + def values_at(*indexes) + ns_values_at(indexes) + end + + # @!macro struct_inspect + def inspect + ns_inspect + end + + alias_method :to_s, :inspect + + # @!macro struct_merge + def merge(other, &block) + ns_merge(other, &block) + end + + # @!macro struct_to_h + def to_h + ns_to_h + end + + # @!macro struct_get + def [](member) + ns_get(member) + end + + # @!macro struct_equality + def ==(other) + ns_equality(other) + end + + # @!macro struct_each + def each(&block) + return enum_for(:each) unless block_given? + ns_each(&block) + end + + # @!macro struct_each_pair + def each_pair(&block) + return enum_for(:each_pair) unless block_given? + ns_each_pair(&block) + end + + # @!macro struct_select + def select(&block) + return enum_for(:select) unless block_given? + ns_select(&block) + end + + private + + # @!visibility private + def initialize_copy(original) + super(original) + ns_initialize_copy + end + + # @!macro struct_new + def self.new(*args, &block) + clazz_name = nil + if args.length == 0 + raise ArgumentError.new('wrong number of arguments (0 for 1+)') + elsif args.length > 0 && args.first.is_a?(String) + clazz_name = args.shift + end + FACTORY.define_struct(clazz_name, args, &block) + end + + FACTORY = Class.new(Synchronization::LockableObject) do + def define_struct(name, members, &block) + synchronize do + Synchronization::AbstractStruct.define_struct_class(ImmutableStruct, Synchronization::Object, name, members, &block) + end + end + end.new + private_constant :FACTORY + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/ivar.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/ivar.rb new file mode 100644 index 0000000..4165038 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/ivar.rb @@ -0,0 +1,208 @@ +require 'concurrent/constants' +require 'concurrent/errors' +require 'concurrent/collection/copy_on_write_observer_set' +require 'concurrent/concern/obligation' +require 'concurrent/concern/observable' +require 'concurrent/executor/safe_task_executor' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # An `IVar` is like a future that you can assign. As a future is a value that + # is being computed that you can wait on, an `IVar` is a value that is waiting + # to be assigned, that you can wait on. `IVars` are single assignment and + # deterministic. + # + # Then, express futures as an asynchronous computation that assigns an `IVar`. + # The `IVar` becomes the primitive on which [futures](Future) and + # [dataflow](Dataflow) are built. + # + # An `IVar` is a single-element container that is normally created empty, and + # can only be set once. The I in `IVar` stands for immutable. Reading an + # `IVar` normally blocks until it is set. It is safe to set and read an `IVar` + # from different threads. + # + # If you want to have some parallel task set the value in an `IVar`, you want + # a `Future`. If you want to create a graph of parallel tasks all executed + # when the values they depend on are ready you want `dataflow`. `IVar` is + # generally a low-level primitive. + # + # ## Examples + # + # Create, set and get an `IVar` + # + # ```ruby + # ivar = Concurrent::IVar.new + # ivar.set 14 + # ivar.value #=> 14 + # ivar.set 2 # would now be an error + # ``` + # + # ## See Also + # + # 1. For the theory: Arvind, R. Nikhil, and K. Pingali. + # [I-Structures: Data structures for parallel computing](http://dl.acm.org/citation.cfm?id=69562). + # In Proceedings of Workshop on Graph Reduction, 1986. + # 2. For recent application: + # [DataDrivenFuture in Habanero Java from Rice](http://www.cs.rice.edu/~vs3/hjlib/doc/edu/rice/hj/api/HjDataDrivenFuture.html). + class IVar < Synchronization::LockableObject + include Concern::Obligation + include Concern::Observable + + # Create a new `IVar` in the `:pending` state with the (optional) initial value. + # + # @param [Object] value the initial value + # @param [Hash] opts the options to create a message with + # @option opts [String] :dup_on_deref (false) call `#dup` before returning + # the data + # @option opts [String] :freeze_on_deref (false) call `#freeze` before + # returning the data + # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing + # the internal value and returning the value returned from the proc + def initialize(value = NULL, opts = {}, &block) + if value != NULL && block_given? + raise ArgumentError.new('provide only a value or a block') + end + super(&nil) + synchronize { ns_initialize(value, opts, &block) } + end + + # Add an observer on this object that will receive notification on update. + # + # Upon completion the `IVar` will notify all observers in a thread-safe way. + # The `func` method of the observer will be called with three arguments: the + # `Time` at which the `Future` completed the asynchronous operation, the + # final `value` (or `nil` on rejection), and the final `reason` (or `nil` on + # fulfillment). + # + # @param [Object] observer the object that will be notified of changes + # @param [Symbol] func symbol naming the method to call when this + # `Observable` has changes` + def add_observer(observer = nil, func = :update, &block) + raise ArgumentError.new('cannot provide both an observer and a block') if observer && block + direct_notification = false + + if block + observer = block + func = :call + end + + synchronize do + if event.set? + direct_notification = true + else + observers.add_observer(observer, func) + end + end + + observer.send(func, Time.now, self.value, reason) if direct_notification + observer + end + + # @!macro ivar_set_method + # Set the `IVar` to a value and wake or notify all threads waiting on it. + # + # @!macro ivar_set_parameters_and_exceptions + # @param [Object] value the value to store in the `IVar` + # @yield A block operation to use for setting the value + # @raise [ArgumentError] if both a value and a block are given + # @raise [Concurrent::MultipleAssignmentError] if the `IVar` has already + # been set or otherwise completed + # + # @return [IVar] self + def set(value = NULL) + check_for_block_or_value!(block_given?, value) + raise MultipleAssignmentError unless compare_and_set_state(:processing, :pending) + + begin + value = yield if block_given? + complete_without_notification(true, value, nil) + rescue => ex + complete_without_notification(false, nil, ex) + end + + notify_observers(self.value, reason) + self + end + + # @!macro ivar_fail_method + # Set the `IVar` to failed due to some error and wake or notify all threads waiting on it. + # + # @param [Object] reason for the failure + # @raise [Concurrent::MultipleAssignmentError] if the `IVar` has already + # been set or otherwise completed + # @return [IVar] self + def fail(reason = StandardError.new) + complete(false, nil, reason) + end + + # Attempt to set the `IVar` with the given value or block. Return a + # boolean indicating the success or failure of the set operation. + # + # @!macro ivar_set_parameters_and_exceptions + # + # @return [Boolean] true if the value was set else false + def try_set(value = NULL, &block) + set(value, &block) + true + rescue MultipleAssignmentError + false + end + + protected + + # @!visibility private + def ns_initialize(value, opts) + value = yield if block_given? + init_obligation + self.observers = Collection::CopyOnWriteObserverSet.new + set_deref_options(opts) + + @state = :pending + if value != NULL + ns_complete_without_notification(true, value, nil) + end + end + + # @!visibility private + def safe_execute(task, args = []) + if compare_and_set_state(:processing, :pending) + success, val, reason = SafeTaskExecutor.new(task, rescue_exception: true).execute(*@args) + complete(success, val, reason) + yield(success, val, reason) if block_given? + end + end + + # @!visibility private + def complete(success, value, reason) + complete_without_notification(success, value, reason) + notify_observers(self.value, reason) + self + end + + # @!visibility private + def complete_without_notification(success, value, reason) + synchronize { ns_complete_without_notification(success, value, reason) } + self + end + + # @!visibility private + def notify_observers(value, reason) + observers.notify_and_delete_observers{ [Time.now, value, reason] } + end + + # @!visibility private + def ns_complete_without_notification(success, value, reason) + raise MultipleAssignmentError if [:fulfilled, :rejected].include? @state + set_state(success, value, reason) + event.set + end + + # @!visibility private + def check_for_block_or_value!(block_given, value) # :nodoc: + if (block_given && value != NULL) || (! block_given && value == NULL) + raise ArgumentError.new('must set with either a value or a block') + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/map.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/map.rb new file mode 100644 index 0000000..601e365 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/map.rb @@ -0,0 +1,350 @@ +require 'thread' +require 'concurrent/constants' +require 'concurrent/utility/engine' + +module Concurrent + # @!visibility private + module Collection + + # @!visibility private + MapImplementation = case + when Concurrent.on_jruby? + require 'concurrent/utility/native_extension_loader' + # noinspection RubyResolve + JRubyMapBackend + when Concurrent.on_cruby? + require 'concurrent/collection/map/mri_map_backend' + MriMapBackend + when Concurrent.on_truffleruby? + if defined?(::TruffleRuby::ConcurrentMap) + require 'concurrent/collection/map/truffleruby_map_backend' + TruffleRubyMapBackend + else + require 'concurrent/collection/map/synchronized_map_backend' + SynchronizedMapBackend + end + else + warn 'Concurrent::Map: unsupported Ruby engine, using a fully synchronized Concurrent::Map implementation' + require 'concurrent/collection/map/synchronized_map_backend' + SynchronizedMapBackend + end + end + + # `Concurrent::Map` is a hash-like object and should have much better performance + # characteristics, especially under high concurrency, than `Concurrent::Hash`. + # However, `Concurrent::Map `is not strictly semantically equivalent to a ruby `Hash` + # -- for instance, it does not necessarily retain ordering by insertion time as `Hash` + # does. For most uses it should do fine though, and we recommend you consider + # `Concurrent::Map` instead of `Concurrent::Hash` for your concurrency-safe hash needs. + class Map < Collection::MapImplementation + + # @!macro map.atomic_method + # This method is atomic. + + # @!macro map.atomic_method_with_block + # This method is atomic. + # @note Atomic methods taking a block do not allow the `self` instance + # to be used within the block. Doing so will cause a deadlock. + + # @!method []=(key, value) + # Set a value with key + # @param [Object] key + # @param [Object] value + # @return [Object] the new value + + # @!method compute_if_absent(key) + # Compute and store new value for key if the key is absent. + # @param [Object] key + # @yield new value + # @yieldreturn [Object] new value + # @return [Object] new value or current value + # @!macro map.atomic_method_with_block + + # @!method compute_if_present(key) + # Compute and store new value for key if the key is present. + # @param [Object] key + # @yield new value + # @yieldparam old_value [Object] + # @yieldreturn [Object, nil] new value, when nil the key is removed + # @return [Object, nil] new value or nil + # @!macro map.atomic_method_with_block + + # @!method compute(key) + # Compute and store new value for key. + # @param [Object] key + # @yield compute new value from old one + # @yieldparam old_value [Object, nil] old_value, or nil when key is absent + # @yieldreturn [Object, nil] new value, when nil the key is removed + # @return [Object, nil] new value or nil + # @!macro map.atomic_method_with_block + + # @!method merge_pair(key, value) + # If the key is absent, the value is stored, otherwise new value is + # computed with a block. + # @param [Object] key + # @param [Object] value + # @yield compute new value from old one + # @yieldparam old_value [Object] old value + # @yieldreturn [Object, nil] new value, when nil the key is removed + # @return [Object, nil] new value or nil + # @!macro map.atomic_method_with_block + + # @!method replace_pair(key, old_value, new_value) + # Replaces old_value with new_value if key exists and current value + # matches old_value + # @param [Object] key + # @param [Object] old_value + # @param [Object] new_value + # @return [true, false] true if replaced + # @!macro map.atomic_method + + # @!method replace_if_exists(key, new_value) + # Replaces current value with new_value if key exists + # @param [Object] key + # @param [Object] new_value + # @return [Object, nil] old value or nil + # @!macro map.atomic_method + + # @!method get_and_set(key, value) + # Get the current value under key and set new value. + # @param [Object] key + # @param [Object] value + # @return [Object, nil] old value or nil when the key was absent + # @!macro map.atomic_method + + # @!method delete(key) + # Delete key and its value. + # @param [Object] key + # @return [Object, nil] old value or nil when the key was absent + # @!macro map.atomic_method + + # @!method delete_pair(key, value) + # Delete pair and its value if current value equals the provided value. + # @param [Object] key + # @param [Object] value + # @return [true, false] true if deleted + # @!macro map.atomic_method + + # NonConcurrentMapBackend handles default_proc natively + unless defined?(Collection::NonConcurrentMapBackend) and self < Collection::NonConcurrentMapBackend + + # @param [Hash, nil] options options to set the :initial_capacity or :load_factor. Ignored on some Rubies. + # @param [Proc] default_proc Optional block to compute the default value if the key is not set, like `Hash#default_proc` + def initialize(options = nil, &default_proc) + if options.kind_of?(::Hash) + validate_options_hash!(options) + else + options = nil + end + + super(options) + @default_proc = default_proc + end + + # Get a value with key + # @param [Object] key + # @return [Object] the value + def [](key) + if value = super # non-falsy value is an existing mapping, return it right away + value + # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call + # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value + # would be returned) + # note: nil == value check is not technically necessary + elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL)) + @default_proc.call(self, key) + else + value + end + end + end + + alias_method :get, :[] + alias_method :put, :[]= + + # Get a value with key, or default_value when key is absent, + # or fail when no default_value is given. + # @param [Object] key + # @param [Object] default_value + # @yield default value for a key + # @yieldparam key [Object] + # @yieldreturn [Object] default value + # @return [Object] the value or default value + # @raise [KeyError] when key is missing and no default_value is provided + # @!macro map_method_not_atomic + # @note The "fetch-then-act" methods of `Map` are not atomic. `Map` is intended + # to be use as a concurrency primitive with strong happens-before + # guarantees. It is not intended to be used as a high-level abstraction + # supporting complex operations. All read and write operations are + # thread safe, but no guarantees are made regarding race conditions + # between the fetch operation and yielding to the block. Additionally, + # this method does not support recursion. This is due to internal + # constraints that are very unlikely to change in the near future. + def fetch(key, default_value = NULL) + if NULL != (value = get_or_default(key, NULL)) + value + elsif block_given? + yield key + elsif NULL != default_value + default_value + else + raise_fetch_no_key + end + end + + # Fetch value with key, or store default value when key is absent, + # or fail when no default_value is given. This is a two step operation, + # therefore not atomic. The store can overwrite other concurrently + # stored value. + # @param [Object] key + # @param [Object] default_value + # @yield default value for a key + # @yieldparam key [Object] + # @yieldreturn [Object] default value + # @return [Object] the value or default value + def fetch_or_store(key, default_value = NULL) + fetch(key) do + put(key, block_given? ? yield(key) : (NULL == default_value ? raise_fetch_no_key : default_value)) + end + end + + # Insert value into map with key if key is absent in one atomic step. + # @param [Object] key + # @param [Object] value + # @return [Object, nil] the previous value when key was present or nil when there was no key + def put_if_absent(key, value) + computed = false + result = compute_if_absent(key) do + computed = true + value + end + computed ? nil : result + end unless method_defined?(:put_if_absent) + + # Is the value stored in the map. Iterates over all values. + # @param [Object] value + # @return [true, false] + def value?(value) + each_value do |v| + return true if value.equal?(v) + end + false + end + + # All keys + # @return [::Array] keys + def keys + arr = [] + each_pair { |k, v| arr << k } + arr + end unless method_defined?(:keys) + + # All values + # @return [::Array] values + def values + arr = [] + each_pair { |k, v| arr << v } + arr + end unless method_defined?(:values) + + # Iterates over each key. + # @yield for each key in the map + # @yieldparam key [Object] + # @return [self] + # @!macro map.atomic_method_with_block + def each_key + each_pair { |k, v| yield k } + end unless method_defined?(:each_key) + + # Iterates over each value. + # @yield for each value in the map + # @yieldparam value [Object] + # @return [self] + # @!macro map.atomic_method_with_block + def each_value + each_pair { |k, v| yield v } + end unless method_defined?(:each_value) + + # Iterates over each key value pair. + # @yield for each key value pair in the map + # @yieldparam key [Object] + # @yieldparam value [Object] + # @return [self] + # @!macro map.atomic_method_with_block + def each_pair + return enum_for :each_pair unless block_given? + super + end + + alias_method :each, :each_pair unless method_defined?(:each) + + # Find key of a value. + # @param [Object] value + # @return [Object, nil] key or nil when not found + def key(value) + each_pair { |k, v| return k if v == value } + nil + end unless method_defined?(:key) + + # Is map empty? + # @return [true, false] + def empty? + each_pair { |k, v| return false } + true + end unless method_defined?(:empty?) + + # The size of map. + # @return [Integer] size + def size + count = 0 + each_pair { |k, v| count += 1 } + count + end unless method_defined?(:size) + + # @!visibility private + def marshal_dump + raise TypeError, "can't dump hash with default proc" if @default_proc + h = {} + each_pair { |k, v| h[k] = v } + h + end + + # @!visibility private + def marshal_load(hash) + initialize + populate_from(hash) + end + + undef :freeze + + # @!visibility private + def inspect + format '%s entries=%d default_proc=%s>', to_s[0..-2], size.to_s, @default_proc.inspect + end + + private + + def raise_fetch_no_key + raise KeyError, 'key not found' + end + + def initialize_copy(other) + super + populate_from(other) + end + + def populate_from(hash) + hash.each_pair { |k, v| self[k] = v } + self + end + + def validate_options_hash!(options) + if (initial_capacity = options[:initial_capacity]) && (!initial_capacity.kind_of?(Integer) || initial_capacity < 0) + raise ArgumentError, ":initial_capacity must be a positive Integer" + end + if (load_factor = options[:load_factor]) && (!load_factor.kind_of?(Numeric) || load_factor <= 0 || load_factor > 1) + raise ArgumentError, ":load_factor must be a number between 0 and 1" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/maybe.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/maybe.rb new file mode 100644 index 0000000..317c82b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/maybe.rb @@ -0,0 +1,229 @@ +require 'concurrent/synchronization/object' + +module Concurrent + + # A `Maybe` encapsulates an optional value. A `Maybe` either contains a value + # of (represented as `Just`), or it is empty (represented as `Nothing`). Using + # `Maybe` is a good way to deal with errors or exceptional cases without + # resorting to drastic measures such as exceptions. + # + # `Maybe` is a replacement for the use of `nil` with better type checking. + # + # For compatibility with {Concurrent::Concern::Obligation} the predicate and + # accessor methods are aliased as `fulfilled?`, `rejected?`, `value`, and + # `reason`. + # + # ## Motivation + # + # A common pattern in languages with pattern matching, such as Erlang and + # Haskell, is to return *either* a value *or* an error from a function + # Consider this Erlang code: + # + # ```erlang + # case file:consult("data.dat") of + # {ok, Terms} -> do_something_useful(Terms); + # {error, Reason} -> lager:error(Reason) + # end. + # ``` + # + # In this example the standard library function `file:consult` returns a + # [tuple](http://erlang.org/doc/reference_manual/data_types.html#id69044) + # with two elements: an [atom](http://erlang.org/doc/reference_manual/data_types.html#id64134) + # (similar to a ruby symbol) and a variable containing ancillary data. On + # success it returns the atom `ok` and the data from the file. On failure it + # returns `error` and a string with an explanation of the problem. With this + # pattern there is no ambiguity regarding success or failure. If the file is + # empty the return value cannot be misinterpreted as an error. And when an + # error occurs the return value provides useful information. + # + # In Ruby we tend to return `nil` when an error occurs or else we raise an + # exception. Both of these idioms are problematic. Returning `nil` is + # ambiguous because `nil` may also be a valid value. It also lacks + # information pertaining to the nature of the error. Raising an exception + # is both expensive and usurps the normal flow of control. All of these + # problems can be solved with the use of a `Maybe`. + # + # A `Maybe` is unambiguous with regard to whether or not it contains a value. + # When `Just` it contains a value, when `Nothing` it does not. When `Just` + # the value it contains may be `nil`, which is perfectly valid. When + # `Nothing` the reason for the lack of a value is contained as well. The + # previous Erlang example can be duplicated in Ruby in a principled way by + # having functions return `Maybe` objects: + # + # ```ruby + # result = MyFileUtils.consult("data.dat") # returns a Maybe + # if result.just? + # do_something_useful(result.value) # or result.just + # else + # logger.error(result.reason) # or result.nothing + # end + # ``` + # + # @example Returning a Maybe from a Function + # module MyFileUtils + # def self.consult(path) + # file = File.open(path, 'r') + # Concurrent::Maybe.just(file.read) + # rescue => ex + # return Concurrent::Maybe.nothing(ex) + # ensure + # file.close if file + # end + # end + # + # maybe = MyFileUtils.consult('bogus.file') + # maybe.just? #=> false + # maybe.nothing? #=> true + # maybe.reason #=> # + # + # maybe = MyFileUtils.consult('README.md') + # maybe.just? #=> true + # maybe.nothing? #=> false + # maybe.value #=> "# Concurrent Ruby\n[![Gem Version..." + # + # @example Using Maybe with a Block + # result = Concurrent::Maybe.from do + # Client.find(10) # Client is an ActiveRecord model + # end + # + # # -- if the record was found + # result.just? #=> true + # result.value #=> # + # + # # -- if the record was not found + # result.just? #=> false + # result.reason #=> ActiveRecord::RecordNotFound + # + # @example Using Maybe with the Null Object Pattern + # # In a Rails controller... + # result = ClientService.new(10).find # returns a Maybe + # render json: result.or(NullClient.new) + # + # @see https://hackage.haskell.org/package/base-4.2.0.1/docs/Data-Maybe.html Haskell Data.Maybe + # @see https://github.com/purescript/purescript-maybe/blob/master/docs/Data.Maybe.md PureScript Data.Maybe + class Maybe < Synchronization::Object + include Comparable + safe_initialization! + + # Indicates that the given attribute has not been set. + # When `Just` the {#nothing} getter will return `NONE`. + # When `Nothing` the {#just} getter will return `NONE`. + NONE = ::Object.new.freeze + + # The value of a `Maybe` when `Just`. Will be `NONE` when `Nothing`. + attr_reader :just + + # The reason for the `Maybe` when `Nothing`. Will be `NONE` when `Just`. + attr_reader :nothing + + private_class_method :new + + # Create a new `Maybe` using the given block. + # + # Runs the given block passing all function arguments to the block as block + # arguments. If the block runs to completion without raising an exception + # a new `Just` is created with the value set to the return value of the + # block. If the block raises an exception a new `Nothing` is created with + # the reason being set to the raised exception. + # + # @param [Array] args Zero or more arguments to pass to the block. + # @yield The block from which to create a new `Maybe`. + # @yieldparam [Array] args Zero or more block arguments passed as + # arguments to the function. + # + # @return [Maybe] The newly created object. + # + # @raise [ArgumentError] when no block given. + def self.from(*args) + raise ArgumentError.new('no block given') unless block_given? + begin + value = yield(*args) + return new(value, NONE) + rescue => ex + return new(NONE, ex) + end + end + + # Create a new `Just` with the given value. + # + # @param [Object] value The value to set for the new `Maybe` object. + # + # @return [Maybe] The newly created object. + def self.just(value) + return new(value, NONE) + end + + # Create a new `Nothing` with the given (optional) reason. + # + # @param [Exception] error The reason to set for the new `Maybe` object. + # When given a string a new `StandardError` will be created with the + # argument as the message. When no argument is given a new + # `StandardError` with an empty message will be created. + # + # @return [Maybe] The newly created object. + def self.nothing(error = '') + if error.is_a?(Exception) + nothing = error + else + nothing = StandardError.new(error.to_s) + end + return new(NONE, nothing) + end + + # Is this `Maybe` a `Just` (successfully fulfilled with a value)? + # + # @return [Boolean] True if `Just` or false if `Nothing`. + def just? + ! nothing? + end + alias :fulfilled? :just? + + # Is this `Maybe` a `nothing` (rejected with an exception upon fulfillment)? + # + # @return [Boolean] True if `Nothing` or false if `Just`. + def nothing? + @nothing != NONE + end + alias :rejected? :nothing? + + alias :value :just + + alias :reason :nothing + + # Comparison operator. + # + # @return [Integer] 0 if self and other are both `Nothing`; + # -1 if self is `Nothing` and other is `Just`; + # 1 if self is `Just` and other is nothing; + # `self.just <=> other.just` if both self and other are `Just`. + def <=>(other) + if nothing? + other.nothing? ? 0 : -1 + else + other.nothing? ? 1 : just <=> other.just + end + end + + # Return either the value of self or the given default value. + # + # @return [Object] The value of self when `Just`; else the given default. + def or(other) + just? ? just : other + end + + private + + # Create a new `Maybe` with the given attributes. + # + # @param [Object] just The value when `Just` else `NONE`. + # @param [Exception, Object] nothing The exception when `Nothing` else `NONE`. + # + # @return [Maybe] The new `Maybe`. + # + # @!visibility private + def initialize(just, nothing) + @just = just + @nothing = nothing + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mutable_struct.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mutable_struct.rb new file mode 100644 index 0000000..5d0e9b9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mutable_struct.rb @@ -0,0 +1,239 @@ +require 'concurrent/synchronization/abstract_struct' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # An thread-safe variation of Ruby's standard `Struct`. Values can be set at + # construction or safely changed at any time during the object's lifecycle. + # + # @see http://ruby-doc.org/core/Struct.html Ruby standard library `Struct` + module MutableStruct + include Synchronization::AbstractStruct + + # @!macro struct_new + # + # Factory for creating new struct classes. + # + # ``` + # new([class_name] [, member_name]+>) -> StructClass click to toggle source + # new([class_name] [, member_name]+>) {|StructClass| block } -> StructClass + # new(value, ...) -> obj + # StructClass[value, ...] -> obj + # ``` + # + # The first two forms are used to create a new struct subclass `class_name` + # that can contain a value for each member_name . This subclass can be + # used to create instances of the structure like any other Class . + # + # If the `class_name` is omitted an anonymous struct class will be created. + # Otherwise, the name of this struct will appear as a constant in the struct class, + # so it must be unique for all structs under this base class and must start with a + # capital letter. Assigning a struct class to a constant also gives the class + # the name of the constant. + # + # If a block is given it will be evaluated in the context of `StructClass`, passing + # the created class as a parameter. This is the recommended way to customize a struct. + # Subclassing an anonymous struct creates an extra anonymous class that will never be used. + # + # The last two forms create a new instance of a struct subclass. The number of value + # parameters must be less than or equal to the number of attributes defined for the + # struct. Unset parameters default to nil. Passing more parameters than number of attributes + # will raise an `ArgumentError`. + # + # @see http://ruby-doc.org/core/Struct.html#method-c-new Ruby standard library `Struct#new` + + # @!macro struct_values + # + # Returns the values for this struct as an Array. + # + # @return [Array] the values for this struct + # + def values + synchronize { ns_values } + end + alias_method :to_a, :values + + # @!macro struct_values_at + # + # Returns the struct member values for each selector as an Array. + # + # A selector may be either an Integer offset or a Range of offsets (as in `Array#values_at`). + # + # @param [Fixnum, Range] indexes the index(es) from which to obatin the values (in order) + def values_at(*indexes) + synchronize { ns_values_at(indexes) } + end + + # @!macro struct_inspect + # + # Describe the contents of this struct in a string. + # + # @return [String] the contents of this struct in a string + def inspect + synchronize { ns_inspect } + end + alias_method :to_s, :inspect + + # @!macro struct_merge + # + # Returns a new struct containing the contents of `other` and the contents + # of `self`. If no block is specified, the value for entries with duplicate + # keys will be that of `other`. Otherwise the value for each duplicate key + # is determined by calling the block with the key, its value in `self` and + # its value in `other`. + # + # @param [Hash] other the hash from which to set the new values + # @yield an options block for resolving duplicate keys + # @yieldparam [String, Symbol] member the name of the member which is duplicated + # @yieldparam [Object] selfvalue the value of the member in `self` + # @yieldparam [Object] othervalue the value of the member in `other` + # + # @return [Synchronization::AbstractStruct] a new struct with the new values + # + # @raise [ArgumentError] of given a member that is not defined in the struct + def merge(other, &block) + synchronize { ns_merge(other, &block) } + end + + # @!macro struct_to_h + # + # Returns a hash containing the names and values for the struct’s members. + # + # @return [Hash] the names and values for the struct’s members + def to_h + synchronize { ns_to_h } + end + + # @!macro struct_get + # + # Attribute Reference + # + # @param [Symbol, String, Integer] member the string or symbol name of the member + # for which to obtain the value or the member's index + # + # @return [Object] the value of the given struct member or the member at the given index. + # + # @raise [NameError] if the member does not exist + # @raise [IndexError] if the index is out of range. + def [](member) + synchronize { ns_get(member) } + end + + # @!macro struct_equality + # + # Equality + # + # @return [Boolean] true if other has the same struct subclass and has + # equal member values (according to `Object#==`) + def ==(other) + synchronize { ns_equality(other) } + end + + # @!macro struct_each + # + # Yields the value of each struct member in order. If no block is given + # an enumerator is returned. + # + # @yield the operation to be performed on each struct member + # @yieldparam [Object] value each struct value (in order) + def each(&block) + return enum_for(:each) unless block_given? + synchronize { ns_each(&block) } + end + + # @!macro struct_each_pair + # + # Yields the name and value of each struct member in order. If no block is + # given an enumerator is returned. + # + # @yield the operation to be performed on each struct member/value pair + # @yieldparam [Object] member each struct member (in order) + # @yieldparam [Object] value each struct value (in order) + def each_pair(&block) + return enum_for(:each_pair) unless block_given? + synchronize { ns_each_pair(&block) } + end + + # @!macro struct_select + # + # Yields each member value from the struct to the block and returns an Array + # containing the member values from the struct for which the given block + # returns a true value (equivalent to `Enumerable#select`). + # + # @yield the operation to be performed on each struct member + # @yieldparam [Object] value each struct value (in order) + # + # @return [Array] an array containing each value for which the block returns true + def select(&block) + return enum_for(:select) unless block_given? + synchronize { ns_select(&block) } + end + + # @!macro struct_set + # + # Attribute Assignment + # + # Sets the value of the given struct member or the member at the given index. + # + # @param [Symbol, String, Integer] member the string or symbol name of the member + # for which to obtain the value or the member's index + # + # @return [Object] the value of the given struct member or the member at the given index. + # + # @raise [NameError] if the name does not exist + # @raise [IndexError] if the index is out of range. + def []=(member, value) + if member.is_a? Integer + length = synchronize { @values.length } + if member >= length + raise IndexError.new("offset #{member} too large for struct(size:#{length})") + end + synchronize { @values[member] = value } + else + send("#{member}=", value) + end + rescue NoMethodError + raise NameError.new("no member '#{member}' in struct") + end + + private + + # @!visibility private + def initialize_copy(original) + synchronize do + super(original) + ns_initialize_copy + end + end + + # @!macro struct_new + def self.new(*args, &block) + clazz_name = nil + if args.length == 0 + raise ArgumentError.new('wrong number of arguments (0 for 1+)') + elsif args.length > 0 && args.first.is_a?(String) + clazz_name = args.shift + end + FACTORY.define_struct(clazz_name, args, &block) + end + + FACTORY = Class.new(Synchronization::LockableObject) do + def define_struct(name, members, &block) + synchronize do + clazz = Synchronization::AbstractStruct.define_struct_class(MutableStruct, Synchronization::LockableObject, name, members, &block) + members.each_with_index do |member, index| + clazz.send :remove_method, member + clazz.send(:define_method, member) do + synchronize { @values[index] } + end + clazz.send(:define_method, "#{member}=") do |value| + synchronize { @values[index] = value } + end + end + clazz + end + end + end.new + private_constant :FACTORY + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mvar.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mvar.rb new file mode 100644 index 0000000..dfc4195 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mvar.rb @@ -0,0 +1,242 @@ +require 'concurrent/concern/dereferenceable' +require 'concurrent/synchronization/object' + +module Concurrent + + # An `MVar` is a synchronized single element container. They are empty or + # contain one item. Taking a value from an empty `MVar` blocks, as does + # putting a value into a full one. You can either think of them as blocking + # queue of length one, or a special kind of mutable variable. + # + # On top of the fundamental `#put` and `#take` operations, we also provide a + # `#mutate` that is atomic with respect to operations on the same instance. + # These operations all support timeouts. + # + # We also support non-blocking operations `#try_put!` and `#try_take!`, a + # `#set!` that ignores existing values, a `#value` that returns the value + # without removing it or returns `MVar::EMPTY`, and a `#modify!` that yields + # `MVar::EMPTY` if the `MVar` is empty and can be used to set `MVar::EMPTY`. + # You shouldn't use these operations in the first instance. + # + # `MVar` is a [Dereferenceable](Dereferenceable). + # + # `MVar` is related to M-structures in Id, `MVar` in Haskell and `SyncVar` in Scala. + # + # Note that unlike the original Haskell paper, our `#take` is blocking. This is how + # Haskell and Scala do it today. + # + # @!macro copy_options + # + # ## See Also + # + # 1. P. Barth, R. Nikhil, and Arvind. [M-Structures: Extending a parallel, non- strict, functional language with state](http://dl.acm.org/citation.cfm?id=652538). In Proceedings of the 5th + # ACM Conference on Functional Programming Languages and Computer Architecture (FPCA), 1991. + # + # 2. S. Peyton Jones, A. Gordon, and S. Finne. [Concurrent Haskell](http://dl.acm.org/citation.cfm?id=237794). + # In Proceedings of the 23rd Symposium on Principles of Programming Languages + # (PoPL), 1996. + class MVar < Synchronization::Object + include Concern::Dereferenceable + safe_initialization! + + # Unique value that represents that an `MVar` was empty + EMPTY = ::Object.new + + # Unique value that represents that an `MVar` timed out before it was able + # to produce a value. + TIMEOUT = ::Object.new + + # Create a new `MVar`, either empty or with an initial value. + # + # @param [Hash] opts the options controlling how the future will be processed + # + # @!macro deref_options + def initialize(value = EMPTY, opts = {}) + @value = value + @mutex = Mutex.new + @empty_condition = ConditionVariable.new + @full_condition = ConditionVariable.new + set_deref_options(opts) + end + + # Remove the value from an `MVar`, leaving it empty, and blocking if there + # isn't a value. A timeout can be set to limit the time spent blocked, in + # which case it returns `TIMEOUT` if the time is exceeded. + # @return [Object] the value that was taken, or `TIMEOUT` + def take(timeout = nil) + @mutex.synchronize do + wait_for_full(timeout) + + # If we timed out we'll still be empty + if unlocked_full? + value = @value + @value = EMPTY + @empty_condition.signal + apply_deref_options(value) + else + TIMEOUT + end + end + end + + # acquires lock on the from an `MVAR`, yields the value to provided block, + # and release lock. A timeout can be set to limit the time spent blocked, + # in which case it returns `TIMEOUT` if the time is exceeded. + # @return [Object] the value returned by the block, or `TIMEOUT` + def borrow(timeout = nil) + @mutex.synchronize do + wait_for_full(timeout) + + # if we timeoud out we'll still be empty + if unlocked_full? + yield @value + else + TIMEOUT + end + end + end + + # Put a value into an `MVar`, blocking if there is already a value until + # it is empty. A timeout can be set to limit the time spent blocked, in + # which case it returns `TIMEOUT` if the time is exceeded. + # @return [Object] the value that was put, or `TIMEOUT` + def put(value, timeout = nil) + @mutex.synchronize do + wait_for_empty(timeout) + + # If we timed out we won't be empty + if unlocked_empty? + @value = value + @full_condition.signal + apply_deref_options(value) + else + TIMEOUT + end + end + end + + # Atomically `take`, yield the value to a block for transformation, and then + # `put` the transformed value. Returns the transformed value. A timeout can + # be set to limit the time spent blocked, in which case it returns `TIMEOUT` + # if the time is exceeded. + # @return [Object] the transformed value, or `TIMEOUT` + def modify(timeout = nil) + raise ArgumentError.new('no block given') unless block_given? + + @mutex.synchronize do + wait_for_full(timeout) + + # If we timed out we'll still be empty + if unlocked_full? + value = @value + @value = yield value + @full_condition.signal + apply_deref_options(value) + else + TIMEOUT + end + end + end + + # Non-blocking version of `take`, that returns `EMPTY` instead of blocking. + def try_take! + @mutex.synchronize do + if unlocked_full? + value = @value + @value = EMPTY + @empty_condition.signal + apply_deref_options(value) + else + EMPTY + end + end + end + + # Non-blocking version of `put`, that returns whether or not it was successful. + def try_put!(value) + @mutex.synchronize do + if unlocked_empty? + @value = value + @full_condition.signal + true + else + false + end + end + end + + # Non-blocking version of `put` that will overwrite an existing value. + def set!(value) + @mutex.synchronize do + old_value = @value + @value = value + @full_condition.signal + apply_deref_options(old_value) + end + end + + # Non-blocking version of `modify` that will yield with `EMPTY` if there is no value yet. + def modify! + raise ArgumentError.new('no block given') unless block_given? + + @mutex.synchronize do + value = @value + @value = yield value + if unlocked_empty? + @empty_condition.signal + else + @full_condition.signal + end + apply_deref_options(value) + end + end + + # Returns if the `MVar` is currently empty. + def empty? + @mutex.synchronize { @value == EMPTY } + end + + # Returns if the `MVar` currently contains a value. + def full? + !empty? + end + + protected + + def synchronize(&block) + @mutex.synchronize(&block) + end + + private + + def unlocked_empty? + @value == EMPTY + end + + def unlocked_full? + ! unlocked_empty? + end + + def wait_for_full(timeout) + wait_while(@full_condition, timeout) { unlocked_empty? } + end + + def wait_for_empty(timeout) + wait_while(@empty_condition, timeout) { unlocked_full? } + end + + def wait_while(condition, timeout) + if timeout.nil? + while yield + condition.wait(@mutex) + end + else + stop = Concurrent.monotonic_time + timeout + while yield && timeout > 0.0 + condition.wait(@mutex, timeout) + timeout = stop - Concurrent.monotonic_time + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/options.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/options.rb new file mode 100644 index 0000000..bdd22a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/options.rb @@ -0,0 +1,42 @@ +require 'concurrent/configuration' + +module Concurrent + + # @!visibility private + module Options + + # Get the requested `Executor` based on the values set in the options hash. + # + # @param [Hash] opts the options defining the requested executor + # @option opts [Executor] :executor when set use the given `Executor` instance. + # Three special values are also supported: `:fast` returns the global fast executor, + # `:io` returns the global io executor, and `:immediate` returns a new + # `ImmediateExecutor` object. + # + # @return [Executor, nil] the requested thread pool, or nil when no option specified + # + # @!visibility private + def self.executor_from_options(opts = {}) # :nodoc: + if identifier = opts.fetch(:executor, nil) + executor(identifier) + else + nil + end + end + + def self.executor(executor_identifier) + case executor_identifier + when :fast + Concurrent.global_fast_executor + when :io + Concurrent.global_io_executor + when :immediate + Concurrent.global_immediate_executor + when Concurrent::ExecutorService + executor_identifier + else + raise ArgumentError, "executor not recognized by '#{executor_identifier}'" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promise.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promise.rb new file mode 100644 index 0000000..ccc47dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promise.rb @@ -0,0 +1,580 @@ +require 'thread' +require 'concurrent/constants' +require 'concurrent/errors' +require 'concurrent/ivar' +require 'concurrent/executor/safe_task_executor' + +require 'concurrent/options' + +module Concurrent + + PromiseExecutionError = Class.new(StandardError) + + # Promises are inspired by the JavaScript [Promises/A](http://wiki.commonjs.org/wiki/Promises/A) + # and [Promises/A+](http://promises-aplus.github.io/promises-spec/) specifications. + # + # > A promise represents the eventual value returned from the single + # > completion of an operation. + # + # Promises are similar to futures and share many of the same behaviours. + # Promises are far more robust, however. Promises can be chained in a tree + # structure where each promise may have zero or more children. Promises are + # chained using the `then` method. The result of a call to `then` is always + # another promise. Promises are resolved asynchronously (with respect to the + # main thread) but in a strict order: parents are guaranteed to be resolved + # before their children, children before their younger siblings. The `then` + # method takes two parameters: an optional block to be executed upon parent + # resolution and an optional callable to be executed upon parent failure. The + # result of each promise is passed to each of its children upon resolution. + # When a promise is rejected all its children will be summarily rejected and + # will receive the reason. + # + # Promises have several possible states: *:unscheduled*, *:pending*, + # *:processing*, *:rejected*, or *:fulfilled*. These are also aggregated as + # `#incomplete?` and `#complete?`. When a Promise is created it is set to + # *:unscheduled*. Once the `#execute` method is called the state becomes + # *:pending*. Once a job is pulled from the thread pool's queue and is given + # to a thread for processing (often immediately upon `#post`) the state + # becomes *:processing*. The future will remain in this state until processing + # is complete. A future that is in the *:unscheduled*, *:pending*, or + # *:processing* is considered `#incomplete?`. A `#complete?` Promise is either + # *:rejected*, indicating that an exception was thrown during processing, or + # *:fulfilled*, indicating success. If a Promise is *:fulfilled* its `#value` + # will be updated to reflect the result of the operation. If *:rejected* the + # `reason` will be updated with a reference to the thrown exception. The + # predicate methods `#unscheduled?`, `#pending?`, `#rejected?`, and + # `#fulfilled?` can be called at any time to obtain the state of the Promise, + # as can the `#state` method, which returns a symbol. + # + # Retrieving the value of a promise is done through the `value` (alias: + # `deref`) method. Obtaining the value of a promise is a potentially blocking + # operation. When a promise is *rejected* a call to `value` will return `nil` + # immediately. When a promise is *fulfilled* a call to `value` will + # immediately return the current value. When a promise is *pending* a call to + # `value` will block until the promise is either *rejected* or *fulfilled*. A + # *timeout* value can be passed to `value` to limit how long the call will + # block. If `nil` the call will block indefinitely. If `0` the call will not + # block. Any other integer or float value will indicate the maximum number of + # seconds to block. + # + # Promises run on the global thread pool. + # + # @!macro copy_options + # + # ### Examples + # + # Start by requiring promises + # + # ```ruby + # require 'concurrent/promise' + # ``` + # + # Then create one + # + # ```ruby + # p = Concurrent::Promise.execute do + # # do something + # 42 + # end + # ``` + # + # Promises can be chained using the `then` method. The `then` method accepts a + # block and an executor, to be executed on fulfillment, and a callable argument to be executed + # on rejection. The result of the each promise is passed as the block argument + # to chained promises. + # + # ```ruby + # p = Concurrent::Promise.new{10}.then{|x| x * 2}.then{|result| result - 10 }.execute + # ``` + # + # And so on, and so on, and so on... + # + # ```ruby + # p = Concurrent::Promise.fulfill(20). + # then{|result| result - 10 }. + # then{|result| result * 3 }. + # then(executor: different_executor){|result| result % 5 }.execute + # ``` + # + # The initial state of a newly created Promise depends on the state of its parent: + # - if parent is *unscheduled* the child will be *unscheduled* + # - if parent is *pending* the child will be *pending* + # - if parent is *fulfilled* the child will be *pending* + # - if parent is *rejected* the child will be *pending* (but will ultimately be *rejected*) + # + # Promises are executed asynchronously from the main thread. By the time a + # child Promise finishes intialization it may be in a different state than its + # parent (by the time a child is created its parent may have completed + # execution and changed state). Despite being asynchronous, however, the order + # of execution of Promise objects in a chain (or tree) is strictly defined. + # + # There are multiple ways to create and execute a new `Promise`. Both ways + # provide identical behavior: + # + # ```ruby + # # create, operate, then execute + # p1 = Concurrent::Promise.new{ "Hello World!" } + # p1.state #=> :unscheduled + # p1.execute + # + # # create and immediately execute + # p2 = Concurrent::Promise.new{ "Hello World!" }.execute + # + # # execute during creation + # p3 = Concurrent::Promise.execute{ "Hello World!" } + # ``` + # + # Once the `execute` method is called a `Promise` becomes `pending`: + # + # ```ruby + # p = Concurrent::Promise.execute{ "Hello, world!" } + # p.state #=> :pending + # p.pending? #=> true + # ``` + # + # Wait a little bit, and the promise will resolve and provide a value: + # + # ```ruby + # p = Concurrent::Promise.execute{ "Hello, world!" } + # sleep(0.1) + # + # p.state #=> :fulfilled + # p.fulfilled? #=> true + # p.value #=> "Hello, world!" + # ``` + # + # If an exception occurs, the promise will be rejected and will provide + # a reason for the rejection: + # + # ```ruby + # p = Concurrent::Promise.execute{ raise StandardError.new("Here comes the Boom!") } + # sleep(0.1) + # + # p.state #=> :rejected + # p.rejected? #=> true + # p.reason #=> "#" + # ``` + # + # #### Rejection + # + # When a promise is rejected all its children will be rejected and will + # receive the rejection `reason` as the rejection callable parameter: + # + # ```ruby + # p = Concurrent::Promise.execute { Thread.pass; raise StandardError } + # + # c1 = p.then(-> reason { 42 }) + # c2 = p.then(-> reason { raise 'Boom!' }) + # + # c1.wait.state #=> :fulfilled + # c1.value #=> 45 + # c2.wait.state #=> :rejected + # c2.reason #=> # + # ``` + # + # Once a promise is rejected it will continue to accept children that will + # receive immediately rejection (they will be executed asynchronously). + # + # #### Aliases + # + # The `then` method is the most generic alias: it accepts a block to be + # executed upon parent fulfillment and a callable to be executed upon parent + # rejection. At least one of them should be passed. The default block is `{ + # |result| result }` that fulfills the child with the parent value. The + # default callable is `{ |reason| raise reason }` that rejects the child with + # the parent reason. + # + # - `on_success { |result| ... }` is the same as `then {|result| ... }` + # - `rescue { |reason| ... }` is the same as `then(Proc.new { |reason| ... } )` + # - `rescue` is aliased by `catch` and `on_error` + class Promise < IVar + + # Initialize a new Promise with the provided options. + # + # @!macro executor_and_deref_options + # + # @!macro promise_init_options + # + # @option opts [Promise] :parent the parent `Promise` when building a chain/tree + # @option opts [Proc] :on_fulfill fulfillment handler + # @option opts [Proc] :on_reject rejection handler + # @option opts [object, Array] :args zero or more arguments to be passed + # the task block on execution + # + # @yield The block operation to be performed asynchronously. + # + # @raise [ArgumentError] if no block is given + # + # @see http://wiki.commonjs.org/wiki/Promises/A + # @see http://promises-aplus.github.io/promises-spec/ + def initialize(opts = {}, &block) + opts.delete_if { |k, v| v.nil? } + super(NULL, opts.merge(__promise_body_from_block__: block), &nil) + end + + # Create a new `Promise` and fulfill it immediately. + # + # @!macro executor_and_deref_options + # + # @!macro promise_init_options + # + # @raise [ArgumentError] if no block is given + # + # @return [Promise] the newly created `Promise` + def self.fulfill(value, opts = {}) + Promise.new(opts).tap { |p| p.send(:synchronized_set_state!, true, value, nil) } + end + + # Create a new `Promise` and reject it immediately. + # + # @!macro executor_and_deref_options + # + # @!macro promise_init_options + # + # @raise [ArgumentError] if no block is given + # + # @return [Promise] the newly created `Promise` + def self.reject(reason, opts = {}) + Promise.new(opts).tap { |p| p.send(:synchronized_set_state!, false, nil, reason) } + end + + # Execute an `:unscheduled` `Promise`. Immediately sets the state to `:pending` and + # passes the block to a new thread/thread pool for eventual execution. + # Does nothing if the `Promise` is in any state other than `:unscheduled`. + # + # @return [Promise] a reference to `self` + def execute + if root? + if compare_and_set_state(:pending, :unscheduled) + set_pending + realize(@promise_body) + end + else + compare_and_set_state(:pending, :unscheduled) + @parent.execute + end + self + end + + # @!macro ivar_set_method + # + # @raise [Concurrent::PromiseExecutionError] if not the root promise + def set(value = NULL, &block) + raise PromiseExecutionError.new('supported only on root promise') unless root? + check_for_block_or_value!(block_given?, value) + synchronize do + if @state != :unscheduled + raise MultipleAssignmentError + else + @promise_body = block || Proc.new { |result| value } + end + end + execute + end + + # @!macro ivar_fail_method + # + # @raise [Concurrent::PromiseExecutionError] if not the root promise + def fail(reason = StandardError.new) + set { raise reason } + end + + # Create a new `Promise` object with the given block, execute it, and return the + # `:pending` object. + # + # @!macro executor_and_deref_options + # + # @!macro promise_init_options + # + # @return [Promise] the newly created `Promise` in the `:pending` state + # + # @raise [ArgumentError] if no block is given + # + # @example + # promise = Concurrent::Promise.execute{ sleep(1); 42 } + # promise.state #=> :pending + def self.execute(opts = {}, &block) + new(opts, &block).execute + end + + # Chain a new promise off the current promise. + # + # @return [Promise] the new promise + # @yield The block operation to be performed asynchronously. + # @overload then(rescuer, executor, &block) + # @param [Proc] rescuer An optional rescue block to be executed if the + # promise is rejected. + # @param [ThreadPool] executor An optional thread pool executor to be used + # in the new Promise + # @overload then(rescuer, executor: executor, &block) + # @param [Proc] rescuer An optional rescue block to be executed if the + # promise is rejected. + # @param [ThreadPool] executor An optional thread pool executor to be used + # in the new Promise + def then(*args, &block) + if args.last.is_a?(::Hash) + executor = args.pop[:executor] + rescuer = args.first + else + rescuer, executor = args + end + + executor ||= @executor + + raise ArgumentError.new('rescuers and block are both missing') if rescuer.nil? && !block_given? + block = Proc.new { |result| result } unless block_given? + child = Promise.new( + parent: self, + executor: executor, + on_fulfill: block, + on_reject: rescuer + ) + + synchronize do + child.state = :pending if @state == :pending + child.on_fulfill(apply_deref_options(@value)) if @state == :fulfilled + child.on_reject(@reason) if @state == :rejected + @children << child + end + + child + end + + # Chain onto this promise an action to be undertaken on success + # (fulfillment). + # + # @yield The block to execute + # + # @return [Promise] self + def on_success(&block) + raise ArgumentError.new('no block given') unless block_given? + self.then(&block) + end + + # Chain onto this promise an action to be undertaken on failure + # (rejection). + # + # @yield The block to execute + # + # @return [Promise] self + def rescue(&block) + self.then(block) + end + + alias_method :catch, :rescue + alias_method :on_error, :rescue + + # Yield the successful result to the block that returns a promise. If that + # promise is also successful the result is the result of the yielded promise. + # If either part fails the whole also fails. + # + # @example + # Promise.execute { 1 }.flat_map { |v| Promise.execute { v + 2 } }.value! #=> 3 + # + # @return [Promise] + def flat_map(&block) + child = Promise.new( + parent: self, + executor: ImmediateExecutor.new, + ) + + on_error { |e| child.on_reject(e) } + on_success do |result1| + begin + inner = block.call(result1) + inner.execute + inner.on_success { |result2| child.on_fulfill(result2) } + inner.on_error { |e| child.on_reject(e) } + rescue => e + child.on_reject(e) + end + end + + child + end + + # Builds a promise that produces the result of promises in an Array + # and fails if any of them fails. + # + # @overload zip(*promises) + # @param [Array] promises + # + # @overload zip(*promises, opts) + # @param [Array] promises + # @param [Hash] opts the configuration options + # @option opts [Executor] :executor (ImmediateExecutor.new) when set use the given `Executor` instance. + # @option opts [Boolean] :execute (true) execute promise before returning + # + # @return [Promise] + def self.zip(*promises) + opts = promises.last.is_a?(::Hash) ? promises.pop.dup : {} + opts[:executor] ||= ImmediateExecutor.new + zero = if !opts.key?(:execute) || opts.delete(:execute) + fulfill([], opts) + else + Promise.new(opts) { [] } + end + + promises.reduce(zero) do |p1, p2| + p1.flat_map do |results| + p2.then do |next_result| + results << next_result + end + end + end + end + + # Builds a promise that produces the result of self and others in an Array + # and fails if any of them fails. + # + # @overload zip(*promises) + # @param [Array] others + # + # @overload zip(*promises, opts) + # @param [Array] others + # @param [Hash] opts the configuration options + # @option opts [Executor] :executor (ImmediateExecutor.new) when set use the given `Executor` instance. + # @option opts [Boolean] :execute (true) execute promise before returning + # + # @return [Promise] + def zip(*others) + self.class.zip(self, *others) + end + + # Aggregates a collection of promises and executes the `then` condition + # if all aggregated promises succeed. Executes the `rescue` handler with + # a `Concurrent::PromiseExecutionError` if any of the aggregated promises + # fail. Upon execution will execute any of the aggregate promises that + # were not already executed. + # + # @!macro promise_self_aggregate + # + # The returned promise will not yet have been executed. Additional `#then` + # and `#rescue` handlers may still be provided. Once the returned promise + # is execute the aggregate promises will be also be executed (if they have + # not been executed already). The results of the aggregate promises will + # be checked upon completion. The necessary `#then` and `#rescue` blocks + # on the aggregating promise will then be executed as appropriate. If the + # `#rescue` handlers are executed the raises exception will be + # `Concurrent::PromiseExecutionError`. + # + # @param [Array] promises Zero or more promises to aggregate + # @return [Promise] an unscheduled (not executed) promise that aggregates + # the promises given as arguments + def self.all?(*promises) + aggregate(:all?, *promises) + end + + # Aggregates a collection of promises and executes the `then` condition + # if any aggregated promises succeed. Executes the `rescue` handler with + # a `Concurrent::PromiseExecutionError` if any of the aggregated promises + # fail. Upon execution will execute any of the aggregate promises that + # were not already executed. + # + # @!macro promise_self_aggregate + def self.any?(*promises) + aggregate(:any?, *promises) + end + + protected + + def ns_initialize(value, opts) + super + + @executor = Options.executor_from_options(opts) || Concurrent.global_io_executor + @args = get_arguments_from(opts) + + @parent = opts.fetch(:parent) { nil } + @on_fulfill = opts.fetch(:on_fulfill) { Proc.new { |result| result } } + @on_reject = opts.fetch(:on_reject) { Proc.new { |reason| raise reason } } + + @promise_body = opts[:__promise_body_from_block__] || Proc.new { |result| result } + @state = :unscheduled + @children = [] + end + + # Aggregate a collection of zero or more promises under a composite promise, + # execute the aggregated promises and collect them into a standard Ruby array, + # call the given Ruby `Ennnumerable` predicate (such as `any?`, `all?`, `none?`, + # or `one?`) on the collection checking for the success or failure of each, + # then executing the composite's `#then` handlers if the predicate returns + # `true` or executing the composite's `#rescue` handlers if the predicate + # returns false. + # + # @!macro promise_self_aggregate + def self.aggregate(method, *promises) + composite = Promise.new do + completed = promises.collect do |promise| + promise.execute if promise.unscheduled? + promise.wait + promise + end + unless completed.empty? || completed.send(method){|promise| promise.fulfilled? } + raise PromiseExecutionError + end + end + composite + end + + # @!visibility private + def set_pending + synchronize do + @state = :pending + @children.each { |c| c.set_pending } + end + end + + # @!visibility private + def root? # :nodoc: + @parent.nil? + end + + # @!visibility private + def on_fulfill(result) + realize Proc.new { @on_fulfill.call(result) } + nil + end + + # @!visibility private + def on_reject(reason) + realize Proc.new { @on_reject.call(reason) } + nil + end + + # @!visibility private + def notify_child(child) + if_state(:fulfilled) { child.on_fulfill(apply_deref_options(@value)) } + if_state(:rejected) { child.on_reject(@reason) } + end + + # @!visibility private + def complete(success, value, reason) + children_to_notify = synchronize do + set_state!(success, value, reason) + @children.dup + end + + children_to_notify.each { |child| notify_child(child) } + observers.notify_and_delete_observers{ [Time.now, self.value, reason] } + end + + # @!visibility private + def realize(task) + @executor.post do + success, value, reason = SafeTaskExecutor.new(task, rescue_exception: true).execute(*@args) + complete(success, value, reason) + end + end + + # @!visibility private + def set_state!(success, value, reason) + set_state(success, value, reason) + event.set + end + + # @!visibility private + def synchronized_set_state!(success, value, reason) + synchronize { set_state!(success, value, reason) } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb new file mode 100644 index 0000000..c5df8fe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb @@ -0,0 +1,2178 @@ +require 'concurrent/synchronization/object' +require 'concurrent/atomic/atomic_boolean' +require 'concurrent/atomic/atomic_fixnum' +require 'concurrent/collection/lock_free_stack' +require 'concurrent/configuration' +require 'concurrent/errors' +require 'concurrent/re_include' +require 'concurrent/utility/monotonic_time' + +module Concurrent + + # {include:file:docs-source/promises-main.md} + module Promises + + # @!macro promises.param.default_executor + # @param [Executor, :io, :fast] default_executor Instance of an executor or a name of the + # global executor. Default executor propagates to chained futures unless overridden with + # executor parameter or changed with {AbstractEventFuture#with_default_executor}. + # + # @!macro promises.param.executor + # @param [Executor, :io, :fast] executor Instance of an executor or a name of the + # global executor. The task is executed on it, default executor remains unchanged. + # + # @!macro promises.param.args + # @param [Object] args arguments which are passed to the task when it's executed. + # (It might be prepended with other arguments, see the @yield section). + # + # @!macro promises.shortcut.on + # Shortcut of {#$0_on} with default `:io` executor supplied. + # @see #$0_on + # + # @!macro promises.shortcut.using + # Shortcut of {#$0_using} with default `:io` executor supplied. + # @see #$0_using + # + # @!macro promise.param.task-future + # @yieldreturn will become result of the returned Future. + # Its returned value becomes {Future#value} fulfilling it, + # raised exception becomes {Future#reason} rejecting it. + # + # @!macro promise.param.callback + # @yieldreturn is forgotten. + + # Container of all {Future}, {Event} factory methods. They are never constructed directly with + # new. + module FactoryMethods + extend ReInclude + extend self + + module Configuration + # @return [Executor, :io, :fast] the executor which is used when none is supplied + # to a factory method. The method can be overridden in the receivers of + # `include FactoryMethod` + def default_executor + :io + end + end + + include Configuration + + # @!macro promises.shortcut.on + # @return [ResolvableEvent] + def resolvable_event + resolvable_event_on default_executor + end + + # Creates a resolvable event, user is responsible for resolving the event once + # by calling {Promises::ResolvableEvent#resolve}. + # + # @!macro promises.param.default_executor + # @return [ResolvableEvent] + def resolvable_event_on(default_executor = self.default_executor) + ResolvableEventPromise.new(default_executor).future + end + + # @!macro promises.shortcut.on + # @return [ResolvableFuture] + def resolvable_future + resolvable_future_on default_executor + end + + # Creates resolvable future, user is responsible for resolving the future once by + # {Promises::ResolvableFuture#resolve}, {Promises::ResolvableFuture#fulfill}, + # or {Promises::ResolvableFuture#reject} + # + # @!macro promises.param.default_executor + # @return [ResolvableFuture] + def resolvable_future_on(default_executor = self.default_executor) + ResolvableFuturePromise.new(default_executor).future + end + + # @!macro promises.shortcut.on + # @return [Future] + def future(*args, &task) + future_on(default_executor, *args, &task) + end + + # Constructs a new Future which will be resolved after block is evaluated on default executor. + # Evaluation begins immediately. + # + # @!macro promises.param.default_executor + # @!macro promises.param.args + # @yield [*args] to the task. + # @!macro promise.param.task-future + # @return [Future] + def future_on(default_executor, *args, &task) + ImmediateEventPromise.new(default_executor).future.then(*args, &task) + end + + # Creates a resolved future with will be either fulfilled with the given value or rejected with + # the given reason. + # + # @param [true, false] fulfilled + # @param [Object] value + # @param [Object] reason + # @!macro promises.param.default_executor + # @return [Future] + def resolved_future(fulfilled, value, reason, default_executor = self.default_executor) + ImmediateFuturePromise.new(default_executor, fulfilled, value, reason).future + end + + # Creates a resolved future which will be fulfilled with the given value. + # + # @!macro promises.param.default_executor + # @param [Object] value + # @return [Future] + def fulfilled_future(value, default_executor = self.default_executor) + resolved_future true, value, nil, default_executor + end + + # Creates a resolved future which will be rejected with the given reason. + # + # @!macro promises.param.default_executor + # @param [Object] reason + # @return [Future] + def rejected_future(reason, default_executor = self.default_executor) + resolved_future false, nil, reason, default_executor + end + + # Creates resolved event. + # + # @!macro promises.param.default_executor + # @return [Event] + def resolved_event(default_executor = self.default_executor) + ImmediateEventPromise.new(default_executor).event + end + + # General constructor. Behaves differently based on the argument's type. It's provided for convenience + # but it's better to be explicit. + # + # @see rejected_future, resolved_event, fulfilled_future + # @!macro promises.param.default_executor + # @return [Event, Future] + # + # @overload make_future(nil, default_executor = self.default_executor) + # @param [nil] nil + # @return [Event] resolved event. + # + # @overload make_future(a_future, default_executor = self.default_executor) + # @param [Future] a_future + # @return [Future] a future which will be resolved when a_future is. + # + # @overload make_future(an_event, default_executor = self.default_executor) + # @param [Event] an_event + # @return [Event] an event which will be resolved when an_event is. + # + # @overload make_future(exception, default_executor = self.default_executor) + # @param [Exception] exception + # @return [Future] a rejected future with the exception as its reason. + # + # @overload make_future(value, default_executor = self.default_executor) + # @param [Object] value when none of the above overloads fits + # @return [Future] a fulfilled future with the value. + def make_future(argument = nil, default_executor = self.default_executor) + case argument + when AbstractEventFuture + # returning wrapper would change nothing + argument + when Exception + rejected_future argument, default_executor + when nil + resolved_event default_executor + else + fulfilled_future argument, default_executor + end + end + + # @!macro promises.shortcut.on + # @return [Future, Event] + def delay(*args, &task) + delay_on default_executor, *args, &task + end + + # Creates a new event or future which is resolved only after it is touched, + # see {Concurrent::AbstractEventFuture#touch}. + # + # @!macro promises.param.default_executor + # @overload delay_on(default_executor, *args, &task) + # If task is provided it returns a {Future} representing the result of the task. + # @!macro promises.param.args + # @yield [*args] to the task. + # @!macro promise.param.task-future + # @return [Future] + # @overload delay_on(default_executor) + # If no task is provided, it returns an {Event} + # @return [Event] + def delay_on(default_executor, *args, &task) + event = DelayPromise.new(default_executor).event + task ? event.chain(*args, &task) : event + end + + # @!macro promises.shortcut.on + # @return [Future, Event] + def schedule(intended_time, *args, &task) + schedule_on default_executor, intended_time, *args, &task + end + + # Creates a new event or future which is resolved in intended_time. + # + # @!macro promises.param.default_executor + # @!macro promises.param.intended_time + # @param [Numeric, Time] intended_time `Numeric` means to run in `intended_time` seconds. + # `Time` means to run on `intended_time`. + # @overload schedule_on(default_executor, intended_time, *args, &task) + # If task is provided it returns a {Future} representing the result of the task. + # @!macro promises.param.args + # @yield [*args] to the task. + # @!macro promise.param.task-future + # @return [Future] + # @overload schedule_on(default_executor, intended_time) + # If no task is provided, it returns an {Event} + # @return [Event] + def schedule_on(default_executor, intended_time, *args, &task) + event = ScheduledPromise.new(default_executor, intended_time).event + task ? event.chain(*args, &task) : event + end + + # @!macro promises.shortcut.on + # @return [Future] + def zip_futures(*futures_and_or_events) + zip_futures_on default_executor, *futures_and_or_events + end + + # Creates a new future which is resolved after all futures_and_or_events are resolved. + # Its value is an array of zipped future values. Its reason is an array of reasons for rejection. + # If there is an error it rejects. + # @!macro promises.event-conversion + # If event is supplied, which does not have value and can be only resolved, it's + # represented as `:fulfilled` with value `nil`. + # + # @!macro promises.param.default_executor + # @param [AbstractEventFuture] futures_and_or_events + # @return [Future] + def zip_futures_on(default_executor, *futures_and_or_events) + ZipFuturesPromise.new_blocked_by(futures_and_or_events, default_executor).future + end + + alias_method :zip, :zip_futures + + # @!macro promises.shortcut.on + # @return [Event] + def zip_events(*futures_and_or_events) + zip_events_on default_executor, *futures_and_or_events + end + + # Creates a new event which is resolved after all futures_and_or_events are resolved. + # (Future is resolved when fulfilled or rejected.) + # + # @!macro promises.param.default_executor + # @param [AbstractEventFuture] futures_and_or_events + # @return [Event] + def zip_events_on(default_executor, *futures_and_or_events) + ZipEventsPromise.new_blocked_by(futures_and_or_events, default_executor).event + end + + # @!macro promises.shortcut.on + # @return [Future] + def any_resolved_future(*futures_and_or_events) + any_resolved_future_on default_executor, *futures_and_or_events + end + + alias_method :any, :any_resolved_future + + # Creates a new future which is resolved after the first futures_and_or_events is resolved. + # Its result equals the result of the first resolved future. + # @!macro promises.any-touch + # If resolved it does not propagate {Concurrent::AbstractEventFuture#touch}, leaving delayed + # futures un-executed if they are not required any more. + # @!macro promises.event-conversion + # + # @!macro promises.param.default_executor + # @param [AbstractEventFuture] futures_and_or_events + # @return [Future] + def any_resolved_future_on(default_executor, *futures_and_or_events) + AnyResolvedFuturePromise.new_blocked_by(futures_and_or_events, default_executor).future + end + + # @!macro promises.shortcut.on + # @return [Future] + def any_fulfilled_future(*futures_and_or_events) + any_fulfilled_future_on default_executor, *futures_and_or_events + end + + # Creates a new future which is resolved after the first futures_and_or_events is fulfilled. + # Its result equals the result of the first resolved future or if all futures_and_or_events reject, + # it has reason of the last rejected future. + # @!macro promises.any-touch + # @!macro promises.event-conversion + # + # @!macro promises.param.default_executor + # @param [AbstractEventFuture] futures_and_or_events + # @return [Future] + def any_fulfilled_future_on(default_executor, *futures_and_or_events) + AnyFulfilledFuturePromise.new_blocked_by(futures_and_or_events, default_executor).future + end + + # @!macro promises.shortcut.on + # @return [Event] + def any_event(*futures_and_or_events) + any_event_on default_executor, *futures_and_or_events + end + + # Creates a new event which becomes resolved after the first futures_and_or_events resolves. + # @!macro promises.any-touch + # + # @!macro promises.param.default_executor + # @param [AbstractEventFuture] futures_and_or_events + # @return [Event] + def any_event_on(default_executor, *futures_and_or_events) + AnyResolvedEventPromise.new_blocked_by(futures_and_or_events, default_executor).event + end + + # TODO consider adding first(count, *futures) + # TODO consider adding zip_by(slice, *futures) processing futures in slices + # TODO or rather a generic aggregator taking a function + end + + module InternalStates + # @!visibility private + class State + def resolved? + raise NotImplementedError + end + + def to_sym + raise NotImplementedError + end + end + + # @!visibility private + class Pending < State + def resolved? + false + end + + def to_sym + :pending + end + end + + # @!visibility private + class Reserved < Pending + end + + # @!visibility private + class ResolvedWithResult < State + def resolved? + true + end + + def to_sym + :resolved + end + + def result + [fulfilled?, value, reason] + end + + def fulfilled? + raise NotImplementedError + end + + def value + raise NotImplementedError + end + + def reason + raise NotImplementedError + end + + def apply + raise NotImplementedError + end + end + + # @!visibility private + class Fulfilled < ResolvedWithResult + + def initialize(value) + @Value = value + end + + def fulfilled? + true + end + + def apply(args, block) + block.call value, *args + end + + def value + @Value + end + + def reason + nil + end + + def to_sym + :fulfilled + end + end + + # @!visibility private + class FulfilledArray < Fulfilled + def apply(args, block) + block.call(*value, *args) + end + end + + # @!visibility private + class Rejected < ResolvedWithResult + def initialize(reason) + @Reason = reason + end + + def fulfilled? + false + end + + def value + nil + end + + def reason + @Reason + end + + def to_sym + :rejected + end + + def apply(args, block) + block.call reason, *args + end + end + + # @!visibility private + class PartiallyRejected < ResolvedWithResult + def initialize(value, reason) + super() + @Value = value + @Reason = reason + end + + def fulfilled? + false + end + + def to_sym + :rejected + end + + def value + @Value + end + + def reason + @Reason + end + + def apply(args, block) + block.call(*reason, *args) + end + end + + # @!visibility private + PENDING = Pending.new + # @!visibility private + RESERVED = Reserved.new + # @!visibility private + RESOLVED = Fulfilled.new(nil) + + def RESOLVED.to_sym + :resolved + end + end + + private_constant :InternalStates + + # @!macro promises.shortcut.event-future + # @see Event#$0 + # @see Future#$0 + + # @!macro promises.param.timeout + # @param [Numeric] timeout the maximum time in second to wait. + + # @!macro promises.warn.blocks + # @note This function potentially blocks current thread until the Future is resolved. + # Be careful it can deadlock. Try to chain instead. + + # Common ancestor of {Event} and {Future} classes, many shared methods are defined here. + class AbstractEventFuture < Synchronization::Object + safe_initialization! + attr_atomic(:internal_state) + private :internal_state=, :swap_internal_state, :compare_and_set_internal_state, :update_internal_state + # @!method internal_state + # @!visibility private + + include InternalStates + + def initialize(promise, default_executor) + super() + @Lock = Mutex.new + @Condition = ConditionVariable.new + @Promise = promise + @DefaultExecutor = default_executor + @Callbacks = LockFreeStack.new + @Waiters = AtomicFixnum.new 0 + self.internal_state = PENDING + end + + private :initialize + + # Returns its state. + # @return [Symbol] + # + # @overload an_event.state + # @return [:pending, :resolved] + # @overload a_future.state + # Both :fulfilled, :rejected implies :resolved. + # @return [:pending, :fulfilled, :rejected] + def state + internal_state.to_sym + end + + # Is it in pending state? + # @return [Boolean] + def pending? + !internal_state.resolved? + end + + # Is it in resolved state? + # @return [Boolean] + def resolved? + internal_state.resolved? + end + + # Propagates touch. Requests all the delayed futures, which it depends on, to be + # executed. This method is called by any other method requiring resolved state, like {#wait}. + # @return [self] + def touch + @Promise.touch + self + end + + # @!macro promises.touches + # Calls {Concurrent::AbstractEventFuture#touch}. + + # @!macro promises.method.wait + # Wait (block the Thread) until receiver is {#resolved?}. + # @!macro promises.touches + # + # @!macro promises.warn.blocks + # @!macro promises.param.timeout + # @return [self, true, false] self implies timeout was not used, true implies timeout was used + # and it was resolved, false implies it was not resolved within timeout. + def wait(timeout = nil) + result = wait_until_resolved(timeout) + timeout ? result : self + end + + # Returns default executor. + # @return [Executor] default executor + # @see #with_default_executor + # @see FactoryMethods#future_on + # @see FactoryMethods#resolvable_future + # @see FactoryMethods#any_fulfilled_future_on + # @see similar + def default_executor + @DefaultExecutor + end + + # @!macro promises.shortcut.on + # @return [Future] + def chain(*args, &task) + chain_on @DefaultExecutor, *args, &task + end + + # Chains the task to be executed asynchronously on executor after it is resolved. + # + # @!macro promises.param.executor + # @!macro promises.param.args + # @return [Future] + # @!macro promise.param.task-future + # + # @overload an_event.chain_on(executor, *args, &task) + # @yield [*args] to the task. + # @overload a_future.chain_on(executor, *args, &task) + # @yield [fulfilled, value, reason, *args] to the task. + # @yieldparam [true, false] fulfilled + # @yieldparam [Object] value + # @yieldparam [Object] reason + def chain_on(executor, *args, &task) + ChainPromise.new_blocked_by1(self, executor, executor, args, &task).future + end + + # @return [String] Short string representation. + def to_s + format '%s %s>', super[0..-2], state + end + + alias_method :inspect, :to_s + + # Resolves the resolvable when receiver is resolved. + # + # @param [Resolvable] resolvable + # @return [self] + def chain_resolvable(resolvable) + on_resolution! { resolvable.resolve_with internal_state } + end + + alias_method :tangle, :chain_resolvable + + # @!macro promises.shortcut.using + # @return [self] + def on_resolution(*args, &callback) + on_resolution_using @DefaultExecutor, *args, &callback + end + + # Stores the callback to be executed synchronously on resolving thread after it is + # resolved. + # + # @!macro promises.param.args + # @!macro promise.param.callback + # @return [self] + # + # @overload an_event.on_resolution!(*args, &callback) + # @yield [*args] to the callback. + # @overload a_future.on_resolution!(*args, &callback) + # @yield [fulfilled, value, reason, *args] to the callback. + # @yieldparam [true, false] fulfilled + # @yieldparam [Object] value + # @yieldparam [Object] reason + def on_resolution!(*args, &callback) + add_callback :callback_on_resolution, args, callback + end + + # Stores the callback to be executed asynchronously on executor after it is resolved. + # + # @!macro promises.param.executor + # @!macro promises.param.args + # @!macro promise.param.callback + # @return [self] + # + # @overload an_event.on_resolution_using(executor, *args, &callback) + # @yield [*args] to the callback. + # @overload a_future.on_resolution_using(executor, *args, &callback) + # @yield [fulfilled, value, reason, *args] to the callback. + # @yieldparam [true, false] fulfilled + # @yieldparam [Object] value + # @yieldparam [Object] reason + def on_resolution_using(executor, *args, &callback) + add_callback :async_callback_on_resolution, executor, args, callback + end + + # @!macro promises.method.with_default_executor + # Crates new object with same class with the executor set as its new default executor. + # Any futures depending on it will use the new default executor. + # @!macro promises.shortcut.event-future + # @abstract + # @return [AbstractEventFuture] + def with_default_executor(executor) + raise NotImplementedError + end + + # @!visibility private + def resolve_with(state, raise_on_reassign = true, reserved = false) + if compare_and_set_internal_state(reserved ? RESERVED : PENDING, state) + # go to synchronized block only if there were waiting threads + @Lock.synchronize { @Condition.broadcast } unless @Waiters.value == 0 + call_callbacks state + else + return rejected_resolution(raise_on_reassign, state) + end + self + end + + # For inspection. + # @!visibility private + # @return [Array] + def blocks + @Callbacks.each_with_object([]) do |(method, args), promises| + promises.push(args[0]) if method == :callback_notify_blocked + end + end + + # For inspection. + # @!visibility private + def callbacks + @Callbacks.each.to_a + end + + # For inspection. + # @!visibility private + def promise + @Promise + end + + # For inspection. + # @!visibility private + def touched? + promise.touched? + end + + # For inspection. + # @!visibility private + def waiting_threads + @Waiters.each.to_a + end + + # @!visibility private + def add_callback_notify_blocked(promise, index) + add_callback :callback_notify_blocked, promise, index + end + + # @!visibility private + def add_callback_clear_delayed_node(node) + add_callback(:callback_clear_delayed_node, node) + end + + # @!visibility private + def with_hidden_resolvable + # TODO (pitr-ch 10-Dec-2018): documentation, better name if in edge + self + end + + private + + def add_callback(method, *args) + state = internal_state + if state.resolved? + call_callback method, state, args + else + @Callbacks.push [method, args] + state = internal_state + # take back if it was resolved in the meanwhile + call_callbacks state if state.resolved? + end + self + end + + def callback_clear_delayed_node(state, node) + node.value = nil + end + + # @return [Boolean] + def wait_until_resolved(timeout) + return true if resolved? + + touch + + @Lock.synchronize do + @Waiters.increment + begin + if timeout + start = Concurrent.monotonic_time + until resolved? + break if @Condition.wait(@Lock, timeout) == nil # nil means timeout + timeout -= (Concurrent.monotonic_time - start) + break if timeout <= 0 + end + else + until resolved? + @Condition.wait(@Lock, timeout) + end + end + ensure + # JRuby may raise ConcurrencyError + @Waiters.decrement + end + end + resolved? + end + + def call_callback(method, state, args) + self.send method, state, *args + end + + def call_callbacks(state) + method, args = @Callbacks.pop + while method + call_callback method, state, args + method, args = @Callbacks.pop + end + end + + def with_async(executor, *args, &block) + Concurrent.executor(executor).post(*args, &block) + end + + def async_callback_on_resolution(state, executor, args, callback) + with_async(executor, state, args, callback) do |st, ar, cb| + callback_on_resolution st, ar, cb + end + end + + def callback_notify_blocked(state, promise, index) + promise.on_blocker_resolution self, index + end + end + + # Represents an event which will happen in future (will be resolved). The event is either + # pending or resolved. It should be always resolved. Use {Future} to communicate rejections and + # cancellation. + class Event < AbstractEventFuture + + alias_method :then, :chain + + + # @!macro promises.method.zip + # Creates a new event or a future which will be resolved when receiver and other are. + # Returns an event if receiver and other are events, otherwise returns a future. + # If just one of the parties is Future then the result + # of the returned future is equal to the result of the supplied future. If both are futures + # then the result is as described in {FactoryMethods#zip_futures_on}. + # + # @return [Future, Event] + def zip(other) + if other.is_a?(Future) + ZipFutureEventPromise.new_blocked_by2(other, self, @DefaultExecutor).future + else + ZipEventEventPromise.new_blocked_by2(self, other, @DefaultExecutor).event + end + end + + alias_method :&, :zip + + # Creates a new event which will be resolved when the first of receiver, `event_or_future` + # resolves. + # + # @return [Event] + def any(event_or_future) + AnyResolvedEventPromise.new_blocked_by2(self, event_or_future, @DefaultExecutor).event + end + + alias_method :|, :any + + # Creates new event dependent on receiver which will not evaluate until touched, see {#touch}. + # In other words, it inserts delay into the chain of Futures making rest of it lazy evaluated. + # + # @return [Event] + def delay + event = DelayPromise.new(@DefaultExecutor).event + ZipEventEventPromise.new_blocked_by2(self, event, @DefaultExecutor).event + end + + # @!macro promise.method.schedule + # Creates new event dependent on receiver scheduled to execute on/in intended_time. + # In time is interpreted from the moment the receiver is resolved, therefore it inserts + # delay into the chain. + # + # @!macro promises.param.intended_time + # @return [Event] + def schedule(intended_time) + chain do + event = ScheduledPromise.new(@DefaultExecutor, intended_time).event + ZipEventEventPromise.new_blocked_by2(self, event, @DefaultExecutor).event + end.flat_event + end + + # Converts event to a future. The future is fulfilled when the event is resolved, the future may never fail. + # + # @return [Future] + def to_future + future = Promises.resolvable_future + ensure + chain_resolvable(future) + end + + # Returns self, since this is event + # @return [Event] + def to_event + self + end + + # @!macro promises.method.with_default_executor + # @return [Event] + def with_default_executor(executor) + EventWrapperPromise.new_blocked_by1(self, executor).event + end + + private + + def rejected_resolution(raise_on_reassign, state) + raise Concurrent::MultipleAssignmentError.new('Event can be resolved only once') if raise_on_reassign + return false + end + + def callback_on_resolution(state, args, callback) + callback.call(*args) + end + end + + # Represents a value which will become available in future. May reject with a reason instead, + # e.g. when the tasks raises an exception. + class Future < AbstractEventFuture + + # Is it in fulfilled state? + # @return [Boolean] + def fulfilled? + state = internal_state + state.resolved? && state.fulfilled? + end + + # Is it in rejected state? + # @return [Boolean] + def rejected? + state = internal_state + state.resolved? && !state.fulfilled? + end + + # @!macro promises.warn.nil + # @note Make sure returned `nil` is not confused with timeout, no value when rejected, + # no reason when fulfilled, etc. + # Use more exact methods if needed, like {#wait}, {#value!}, {#result}, etc. + + # @!macro promises.method.value + # Return value of the future. + # @!macro promises.touches + # + # @!macro promises.warn.blocks + # @!macro promises.warn.nil + # @!macro promises.param.timeout + # @!macro promises.param.timeout_value + # @param [Object] timeout_value a value returned by the method when it times out + # @return [Object, nil, timeout_value] the value of the Future when fulfilled, + # timeout_value on timeout, + # nil on rejection. + def value(timeout = nil, timeout_value = nil) + if wait_until_resolved timeout + internal_state.value + else + timeout_value + end + end + + # Returns reason of future's rejection. + # @!macro promises.touches + # + # @!macro promises.warn.blocks + # @!macro promises.warn.nil + # @!macro promises.param.timeout + # @!macro promises.param.timeout_value + # @return [Object, timeout_value] the reason, or timeout_value on timeout, or nil on fulfillment. + def reason(timeout = nil, timeout_value = nil) + if wait_until_resolved timeout + internal_state.reason + else + timeout_value + end + end + + # Returns triplet fulfilled?, value, reason. + # @!macro promises.touches + # + # @!macro promises.warn.blocks + # @!macro promises.param.timeout + # @return [Array(Boolean, Object, Object), nil] triplet of fulfilled?, value, reason, or nil + # on timeout. + def result(timeout = nil) + internal_state.result if wait_until_resolved timeout + end + + # @!macro promises.method.wait + # @raise [Exception] {#reason} on rejection + def wait!(timeout = nil) + result = wait_until_resolved!(timeout) + timeout ? result : self + end + + # @!macro promises.method.value + # @return [Object, nil, timeout_value] the value of the Future when fulfilled, + # or nil on rejection, + # or timeout_value on timeout. + # @raise [Exception] {#reason} on rejection + def value!(timeout = nil, timeout_value = nil) + if wait_until_resolved! timeout + internal_state.value + else + timeout_value + end + end + + # Allows rejected Future to be risen with `raise` method. + # If the reason is not an exception `Runtime.new(reason)` is returned. + # + # @example + # raise Promises.rejected_future(StandardError.new("boom")) + # raise Promises.rejected_future("or just boom") + # @raise [Concurrent::Error] when raising not rejected future + # @return [Exception] + def exception(*args) + raise Concurrent::Error, 'it is not rejected' unless rejected? + raise ArgumentError unless args.size <= 1 + reason = Array(internal_state.reason).flatten.compact + if reason.size > 1 + ex = Concurrent::MultipleErrors.new reason + ex.set_backtrace(caller) + ex + else + ex = if reason[0].respond_to? :exception + reason[0].exception(*args) + else + RuntimeError.new(reason[0]).exception(*args) + end + ex.set_backtrace Array(ex.backtrace) + caller + ex + end + end + + # @!macro promises.shortcut.on + # @return [Future] + def then(*args, &task) + then_on @DefaultExecutor, *args, &task + end + + # Chains the task to be executed asynchronously on executor after it fulfills. Does not run + # the task if it rejects. It will resolve though, triggering any dependent futures. + # + # @!macro promises.param.executor + # @!macro promises.param.args + # @!macro promise.param.task-future + # @return [Future] + # @yield [value, *args] to the task. + def then_on(executor, *args, &task) + ThenPromise.new_blocked_by1(self, executor, executor, args, &task).future + end + + # @!macro promises.shortcut.on + # @return [Future] + def rescue(*args, &task) + rescue_on @DefaultExecutor, *args, &task + end + + # Chains the task to be executed asynchronously on executor after it rejects. Does not run + # the task if it fulfills. It will resolve though, triggering any dependent futures. + # + # @!macro promises.param.executor + # @!macro promises.param.args + # @!macro promise.param.task-future + # @return [Future] + # @yield [reason, *args] to the task. + def rescue_on(executor, *args, &task) + RescuePromise.new_blocked_by1(self, executor, executor, args, &task).future + end + + # @!macro promises.method.zip + # @return [Future] + def zip(other) + if other.is_a?(Future) + ZipFuturesPromise.new_blocked_by2(self, other, @DefaultExecutor).future + else + ZipFutureEventPromise.new_blocked_by2(self, other, @DefaultExecutor).future + end + end + + alias_method :&, :zip + + # Creates a new event which will be resolved when the first of receiver, `event_or_future` + # resolves. Returning future will have value nil if event_or_future is event and resolves + # first. + # + # @return [Future] + def any(event_or_future) + AnyResolvedFuturePromise.new_blocked_by2(self, event_or_future, @DefaultExecutor).future + end + + alias_method :|, :any + + # Creates new future dependent on receiver which will not evaluate until touched, see {#touch}. + # In other words, it inserts delay into the chain of Futures making rest of it lazy evaluated. + # + # @return [Future] + def delay + event = DelayPromise.new(@DefaultExecutor).event + ZipFutureEventPromise.new_blocked_by2(self, event, @DefaultExecutor).future + end + + # @!macro promise.method.schedule + # @return [Future] + def schedule(intended_time) + chain do + event = ScheduledPromise.new(@DefaultExecutor, intended_time).event + ZipFutureEventPromise.new_blocked_by2(self, event, @DefaultExecutor).future + end.flat + end + + # @!macro promises.method.with_default_executor + # @return [Future] + def with_default_executor(executor) + FutureWrapperPromise.new_blocked_by1(self, executor).future + end + + # Creates new future which will have result of the future returned by receiver. If receiver + # rejects it will have its rejection. + # + # @param [Integer] level how many levels of futures should flatten + # @return [Future] + def flat_future(level = 1) + FlatFuturePromise.new_blocked_by1(self, level, @DefaultExecutor).future + end + + alias_method :flat, :flat_future + + # Creates new event which will be resolved when the returned event by receiver is. + # Be careful if the receiver rejects it will just resolve since Event does not hold reason. + # + # @return [Event] + def flat_event + FlatEventPromise.new_blocked_by1(self, @DefaultExecutor).event + end + + # @!macro promises.shortcut.using + # @return [self] + def on_fulfillment(*args, &callback) + on_fulfillment_using @DefaultExecutor, *args, &callback + end + + # Stores the callback to be executed synchronously on resolving thread after it is + # fulfilled. Does nothing on rejection. + # + # @!macro promises.param.args + # @!macro promise.param.callback + # @return [self] + # @yield [value, *args] to the callback. + def on_fulfillment!(*args, &callback) + add_callback :callback_on_fulfillment, args, callback + end + + # Stores the callback to be executed asynchronously on executor after it is + # fulfilled. Does nothing on rejection. + # + # @!macro promises.param.executor + # @!macro promises.param.args + # @!macro promise.param.callback + # @return [self] + # @yield [value, *args] to the callback. + def on_fulfillment_using(executor, *args, &callback) + add_callback :async_callback_on_fulfillment, executor, args, callback + end + + # @!macro promises.shortcut.using + # @return [self] + def on_rejection(*args, &callback) + on_rejection_using @DefaultExecutor, *args, &callback + end + + # Stores the callback to be executed synchronously on resolving thread after it is + # rejected. Does nothing on fulfillment. + # + # @!macro promises.param.args + # @!macro promise.param.callback + # @return [self] + # @yield [reason, *args] to the callback. + def on_rejection!(*args, &callback) + add_callback :callback_on_rejection, args, callback + end + + # Stores the callback to be executed asynchronously on executor after it is + # rejected. Does nothing on fulfillment. + # + # @!macro promises.param.executor + # @!macro promises.param.args + # @!macro promise.param.callback + # @return [self] + # @yield [reason, *args] to the callback. + def on_rejection_using(executor, *args, &callback) + add_callback :async_callback_on_rejection, executor, args, callback + end + + # Allows to use futures as green threads. The receiver has to evaluate to a future which + # represents what should be done next. It basically flattens indefinitely until non Future + # values is returned which becomes result of the returned future. Any encountered exception + # will become reason of the returned future. + # + # @return [Future] + # @param [#call(value)] run_test + # an object which when called returns either Future to keep running with + # or nil, then the run completes with the value. + # The run_test can be used to extract the Future from deeper structure, + # or to distinguish Future which is a resulting value from a future + # which is suppose to continue running. + # @example + # body = lambda do |v| + # v += 1 + # v < 5 ? Promises.future(v, &body) : v + # end + # Promises.future(0, &body).run.value! # => 5 + def run(run_test = method(:run_test)) + RunFuturePromise.new_blocked_by1(self, @DefaultExecutor, run_test).future + end + + # @!visibility private + def apply(args, block) + internal_state.apply args, block + end + + # Converts future to event which is resolved when future is resolved by fulfillment or rejection. + # + # @return [Event] + def to_event + event = Promises.resolvable_event + ensure + chain_resolvable(event) + end + + # Returns self, since this is a future + # @return [Future] + def to_future + self + end + + # @return [String] Short string representation. + def to_s + if resolved? + format '%s with %s>', super[0..-2], (fulfilled? ? value : reason).inspect + else + super + end + end + + alias_method :inspect, :to_s + + private + + def run_test(v) + v if v.is_a?(Future) + end + + def rejected_resolution(raise_on_reassign, state) + if raise_on_reassign + if internal_state == RESERVED + raise Concurrent::MultipleAssignmentError.new( + "Future can be resolved only once. It is already reserved.") + else + raise Concurrent::MultipleAssignmentError.new( + "Future can be resolved only once. It's #{result}, trying to set #{state.result}.", + current_result: result, + new_result: state.result) + end + end + return false + end + + def wait_until_resolved!(timeout = nil) + result = wait_until_resolved(timeout) + raise self if rejected? + result + end + + def async_callback_on_fulfillment(state, executor, args, callback) + with_async(executor, state, args, callback) do |st, ar, cb| + callback_on_fulfillment st, ar, cb + end + end + + def async_callback_on_rejection(state, executor, args, callback) + with_async(executor, state, args, callback) do |st, ar, cb| + callback_on_rejection st, ar, cb + end + end + + def callback_on_fulfillment(state, args, callback) + state.apply args, callback if state.fulfilled? + end + + def callback_on_rejection(state, args, callback) + state.apply args, callback unless state.fulfilled? + end + + def callback_on_resolution(state, args, callback) + callback.call(*state.result, *args) + end + + end + + # Marker module of Future, Event resolved manually. + module Resolvable + include InternalStates + end + + # A Event which can be resolved by user. + class ResolvableEvent < Event + include Resolvable + + # @!macro raise_on_reassign + # @raise [MultipleAssignmentError] when already resolved and raise_on_reassign is true. + + # @!macro promise.param.raise_on_reassign + # @param [Boolean] raise_on_reassign should method raise exception if already resolved + # @return [self, false] false is returned when raise_on_reassign is false and the receiver + # is already resolved. + # + + # Makes the event resolved, which triggers all dependent futures. + # + # @!macro promise.param.raise_on_reassign + # @!macro promise.param.reserved + # @param [true, false] reserved + # Set to true if the resolvable is {#reserve}d by you, + # marks resolution of reserved resolvable events and futures explicitly. + # Advanced feature, ignore unless you use {Resolvable#reserve} from edge. + def resolve(raise_on_reassign = true, reserved = false) + resolve_with RESOLVED, raise_on_reassign, reserved + end + + # Creates new event wrapping receiver, effectively hiding the resolve method. + # + # @return [Event] + def with_hidden_resolvable + @with_hidden_resolvable ||= EventWrapperPromise.new_blocked_by1(self, @DefaultExecutor).event + end + + # Behaves as {AbstractEventFuture#wait} but has one additional optional argument + # resolve_on_timeout. + # + # @param [true, false] resolve_on_timeout + # If it times out and the argument is true it will also resolve the event. + # @return [self, true, false] + # @see AbstractEventFuture#wait + def wait(timeout = nil, resolve_on_timeout = false) + super(timeout) or if resolve_on_timeout + # if it fails to resolve it was resolved in the meantime + # so return true as if there was no timeout + !resolve(false) + else + false + end + end + end + + # A Future which can be resolved by user. + class ResolvableFuture < Future + include Resolvable + + # Makes the future resolved with result of triplet `fulfilled?`, `value`, `reason`, + # which triggers all dependent futures. + # + # @param [true, false] fulfilled + # @param [Object] value + # @param [Object] reason + # @!macro promise.param.raise_on_reassign + # @!macro promise.param.reserved + def resolve(fulfilled = true, value = nil, reason = nil, raise_on_reassign = true, reserved = false) + resolve_with(fulfilled ? Fulfilled.new(value) : Rejected.new(reason), raise_on_reassign, reserved) + end + + # Makes the future fulfilled with `value`, + # which triggers all dependent futures. + # + # @param [Object] value + # @!macro promise.param.raise_on_reassign + # @!macro promise.param.reserved + def fulfill(value, raise_on_reassign = true, reserved = false) + resolve_with Fulfilled.new(value), raise_on_reassign, reserved + end + + # Makes the future rejected with `reason`, + # which triggers all dependent futures. + # + # @param [Object] reason + # @!macro promise.param.raise_on_reassign + # @!macro promise.param.reserved + def reject(reason, raise_on_reassign = true, reserved = false) + resolve_with Rejected.new(reason), raise_on_reassign, reserved + end + + # Evaluates the block and sets its result as future's value fulfilling, if the block raises + # an exception the future rejects with it. + # + # @yield [*args] to the block. + # @yieldreturn [Object] value + # @return [self] + def evaluate_to(*args, &block) + promise.evaluate_to(*args, block) + end + + # Evaluates the block and sets its result as future's value fulfilling, if the block raises + # an exception the future rejects with it. + # + # @yield [*args] to the block. + # @yieldreturn [Object] value + # @return [self] + # @raise [Exception] also raise reason on rejection. + def evaluate_to!(*args, &block) + promise.evaluate_to(*args, block).wait! + end + + # @!macro promises.resolvable.resolve_on_timeout + # @param [::Array(true, Object, nil), ::Array(false, nil, Exception), nil] resolve_on_timeout + # If it times out and the argument is not nil it will also resolve the future + # to the provided resolution. + + # Behaves as {AbstractEventFuture#wait} but has one additional optional argument + # resolve_on_timeout. + # + # @!macro promises.resolvable.resolve_on_timeout + # @return [self, true, false] + # @see AbstractEventFuture#wait + def wait(timeout = nil, resolve_on_timeout = nil) + super(timeout) or if resolve_on_timeout + # if it fails to resolve it was resolved in the meantime + # so return true as if there was no timeout + !resolve(*resolve_on_timeout, false) + else + false + end + end + + # Behaves as {Future#wait!} but has one additional optional argument + # resolve_on_timeout. + # + # @!macro promises.resolvable.resolve_on_timeout + # @return [self, true, false] + # @raise [Exception] {#reason} on rejection + # @see Future#wait! + def wait!(timeout = nil, resolve_on_timeout = nil) + super(timeout) or if resolve_on_timeout + if resolve(*resolve_on_timeout, false) + false + else + # if it fails to resolve it was resolved in the meantime + # so return true as if there was no timeout + raise self if rejected? + true + end + else + false + end + end + + # Behaves as {Future#value} but has one additional optional argument + # resolve_on_timeout. + # + # @!macro promises.resolvable.resolve_on_timeout + # @return [Object, timeout_value, nil] + # @see Future#value + def value(timeout = nil, timeout_value = nil, resolve_on_timeout = nil) + if wait_until_resolved timeout + internal_state.value + else + if resolve_on_timeout + unless resolve(*resolve_on_timeout, false) + # if it fails to resolve it was resolved in the meantime + # so return value as if there was no timeout + return internal_state.value + end + end + timeout_value + end + end + + # Behaves as {Future#value!} but has one additional optional argument + # resolve_on_timeout. + # + # @!macro promises.resolvable.resolve_on_timeout + # @return [Object, timeout_value, nil] + # @raise [Exception] {#reason} on rejection + # @see Future#value! + def value!(timeout = nil, timeout_value = nil, resolve_on_timeout = nil) + if wait_until_resolved! timeout + internal_state.value + else + if resolve_on_timeout + unless resolve(*resolve_on_timeout, false) + # if it fails to resolve it was resolved in the meantime + # so return value as if there was no timeout + raise self if rejected? + return internal_state.value + end + end + timeout_value + end + end + + # Behaves as {Future#reason} but has one additional optional argument + # resolve_on_timeout. + # + # @!macro promises.resolvable.resolve_on_timeout + # @return [Exception, timeout_value, nil] + # @see Future#reason + def reason(timeout = nil, timeout_value = nil, resolve_on_timeout = nil) + if wait_until_resolved timeout + internal_state.reason + else + if resolve_on_timeout + unless resolve(*resolve_on_timeout, false) + # if it fails to resolve it was resolved in the meantime + # so return value as if there was no timeout + return internal_state.reason + end + end + timeout_value + end + end + + # Behaves as {Future#result} but has one additional optional argument + # resolve_on_timeout. + # + # @!macro promises.resolvable.resolve_on_timeout + # @return [::Array(Boolean, Object, Exception), nil] + # @see Future#result + def result(timeout = nil, resolve_on_timeout = nil) + if wait_until_resolved timeout + internal_state.result + else + if resolve_on_timeout + unless resolve(*resolve_on_timeout, false) + # if it fails to resolve it was resolved in the meantime + # so return value as if there was no timeout + internal_state.result + end + end + # otherwise returns nil + end + end + + # Creates new future wrapping receiver, effectively hiding the resolve method and similar. + # + # @return [Future] + def with_hidden_resolvable + @with_hidden_resolvable ||= FutureWrapperPromise.new_blocked_by1(self, @DefaultExecutor).future + end + end + + # @abstract + # @private + class AbstractPromise < Synchronization::Object + safe_initialization! + include InternalStates + + def initialize(future) + super() + @Future = future + end + + def future + @Future + end + + alias_method :event, :future + + def default_executor + future.default_executor + end + + def state + future.state + end + + def touch + end + + def to_s + format '%s %s>', super[0..-2], @Future + end + + alias_method :inspect, :to_s + + def delayed_because + nil + end + + private + + def resolve_with(new_state, raise_on_reassign = true) + @Future.resolve_with(new_state, raise_on_reassign) + end + + # @return [Future] + def evaluate_to(*args, block) + resolve_with Fulfilled.new(block.call(*args)) + rescue Exception => error + resolve_with Rejected.new(error) + raise error unless error.is_a?(StandardError) + end + end + + class ResolvableEventPromise < AbstractPromise + def initialize(default_executor) + super ResolvableEvent.new(self, default_executor) + end + end + + class ResolvableFuturePromise < AbstractPromise + def initialize(default_executor) + super ResolvableFuture.new(self, default_executor) + end + + public :evaluate_to + end + + # @abstract + class InnerPromise < AbstractPromise + end + + # @abstract + class BlockedPromise < InnerPromise + + private_class_method :new + + def self.new_blocked_by1(blocker, *args, &block) + blocker_delayed = blocker.promise.delayed_because + promise = new(blocker_delayed, 1, *args, &block) + blocker.add_callback_notify_blocked promise, 0 + promise + end + + def self.new_blocked_by2(blocker1, blocker2, *args, &block) + blocker_delayed1 = blocker1.promise.delayed_because + blocker_delayed2 = blocker2.promise.delayed_because + delayed = if blocker_delayed1 && blocker_delayed2 + # TODO (pitr-ch 23-Dec-2016): use arrays when we know it will not grow (only flat adds delay) + LockFreeStack.of2(blocker_delayed1, blocker_delayed2) + else + blocker_delayed1 || blocker_delayed2 + end + promise = new(delayed, 2, *args, &block) + blocker1.add_callback_notify_blocked promise, 0 + blocker2.add_callback_notify_blocked promise, 1 + promise + end + + def self.new_blocked_by(blockers, *args, &block) + delayed = blockers.reduce(nil) { |d, f| add_delayed d, f.promise.delayed_because } + promise = new(delayed, blockers.size, *args, &block) + blockers.each_with_index { |f, i| f.add_callback_notify_blocked promise, i } + promise + end + + def self.add_delayed(delayed1, delayed2) + if delayed1 && delayed2 + delayed1.push delayed2 + delayed1 + else + delayed1 || delayed2 + end + end + + def initialize(delayed, blockers_count, future) + super(future) + @Delayed = delayed + @Countdown = AtomicFixnum.new blockers_count + end + + def on_blocker_resolution(future, index) + countdown = process_on_blocker_resolution(future, index) + resolvable = resolvable?(countdown, future, index) + + on_resolvable(future, index) if resolvable + end + + def delayed_because + @Delayed + end + + def touch + clear_and_propagate_touch + end + + # for inspection only + def blocked_by + blocked_by = [] + ObjectSpace.each_object(AbstractEventFuture) { |o| blocked_by.push o if o.blocks.include? self } + blocked_by + end + + private + + def clear_and_propagate_touch(stack_or_element = @Delayed) + return if stack_or_element.nil? + + if stack_or_element.is_a? LockFreeStack + stack_or_element.clear_each { |element| clear_and_propagate_touch element } + else + stack_or_element.touch unless stack_or_element.nil? # if still present + end + end + + # @return [true,false] if resolvable + def resolvable?(countdown, future, index) + countdown.zero? + end + + def process_on_blocker_resolution(future, index) + @Countdown.decrement + end + + def on_resolvable(resolved_future, index) + raise NotImplementedError + end + end + + # @abstract + class BlockedTaskPromise < BlockedPromise + def initialize(delayed, blockers_count, default_executor, executor, args, &task) + raise ArgumentError, 'no block given' unless block_given? + super delayed, 1, Future.new(self, default_executor) + @Executor = executor + @Task = task + @Args = args + end + + def executor + @Executor + end + end + + class ThenPromise < BlockedTaskPromise + private + + def initialize(delayed, blockers_count, default_executor, executor, args, &task) + super delayed, blockers_count, default_executor, executor, args, &task + end + + def on_resolvable(resolved_future, index) + if resolved_future.fulfilled? + Concurrent.executor(@Executor).post(resolved_future, @Args, @Task) do |future, args, task| + evaluate_to lambda { future.apply args, task } + end + else + resolve_with resolved_future.internal_state + end + end + end + + class RescuePromise < BlockedTaskPromise + private + + def initialize(delayed, blockers_count, default_executor, executor, args, &task) + super delayed, blockers_count, default_executor, executor, args, &task + end + + def on_resolvable(resolved_future, index) + if resolved_future.rejected? + Concurrent.executor(@Executor).post(resolved_future, @Args, @Task) do |future, args, task| + evaluate_to lambda { future.apply args, task } + end + else + resolve_with resolved_future.internal_state + end + end + end + + class ChainPromise < BlockedTaskPromise + private + + def on_resolvable(resolved_future, index) + if Future === resolved_future + Concurrent.executor(@Executor).post(resolved_future, @Args, @Task) do |future, args, task| + evaluate_to(*future.result, *args, task) + end + else + Concurrent.executor(@Executor).post(@Args, @Task) do |args, task| + evaluate_to(*args, task) + end + end + end + end + + # will be immediately resolved + class ImmediateEventPromise < InnerPromise + def initialize(default_executor) + super Event.new(self, default_executor).resolve_with(RESOLVED) + end + end + + class ImmediateFuturePromise < InnerPromise + def initialize(default_executor, fulfilled, value, reason) + super Future.new(self, default_executor). + resolve_with(fulfilled ? Fulfilled.new(value) : Rejected.new(reason)) + end + end + + class AbstractFlatPromise < BlockedPromise + + def initialize(delayed_because, blockers_count, event_or_future) + delayed = LockFreeStack.of1(self) + super(delayed, blockers_count, event_or_future) + # noinspection RubyArgCount + @Touched = AtomicBoolean.new false + @DelayedBecause = delayed_because || LockFreeStack.new + + event_or_future.add_callback_clear_delayed_node delayed.peek + end + + def touch + if @Touched.make_true + clear_and_propagate_touch @DelayedBecause + end + end + + private + + def touched? + @Touched.value + end + + def on_resolvable(resolved_future, index) + resolve_with resolved_future.internal_state + end + + def resolvable?(countdown, future, index) + !@Future.internal_state.resolved? && super(countdown, future, index) + end + + def add_delayed_of(future) + delayed = future.promise.delayed_because + if touched? + clear_and_propagate_touch delayed + else + BlockedPromise.add_delayed @DelayedBecause, delayed + clear_and_propagate_touch @DelayedBecause if touched? + end + end + + end + + class FlatEventPromise < AbstractFlatPromise + + private + + def initialize(delayed, blockers_count, default_executor) + super delayed, 2, Event.new(self, default_executor) + end + + def process_on_blocker_resolution(future, index) + countdown = super(future, index) + if countdown.nonzero? + internal_state = future.internal_state + + unless internal_state.fulfilled? + resolve_with RESOLVED + return countdown + end + + value = internal_state.value + case value + when AbstractEventFuture + add_delayed_of value + value.add_callback_notify_blocked self, nil + countdown + else + resolve_with RESOLVED + end + end + countdown + end + + end + + class FlatFuturePromise < AbstractFlatPromise + + private + + def initialize(delayed, blockers_count, levels, default_executor) + raise ArgumentError, 'levels has to be higher than 0' if levels < 1 + # flat promise may result to a future having delayed futures, therefore we have to have empty stack + # to be able to add new delayed futures + super delayed || LockFreeStack.new, 1 + levels, Future.new(self, default_executor) + end + + def process_on_blocker_resolution(future, index) + countdown = super(future, index) + if countdown.nonzero? + internal_state = future.internal_state + + unless internal_state.fulfilled? + resolve_with internal_state + return countdown + end + + value = internal_state.value + case value + when AbstractEventFuture + add_delayed_of value + value.add_callback_notify_blocked self, nil + countdown + else + evaluate_to(lambda { raise TypeError, "returned value #{value.inspect} is not a Future" }) + end + end + countdown + end + + end + + class RunFuturePromise < AbstractFlatPromise + + private + + def initialize(delayed, blockers_count, default_executor, run_test) + super delayed, 1, Future.new(self, default_executor) + @RunTest = run_test + end + + def process_on_blocker_resolution(future, index) + internal_state = future.internal_state + + unless internal_state.fulfilled? + resolve_with internal_state + return 0 + end + + value = internal_state.value + continuation_future = @RunTest.call value + + if continuation_future + add_delayed_of continuation_future + continuation_future.add_callback_notify_blocked self, nil + else + resolve_with internal_state + end + + 1 + end + end + + class ZipEventEventPromise < BlockedPromise + def initialize(delayed, blockers_count, default_executor) + super delayed, 2, Event.new(self, default_executor) + end + + private + + def on_resolvable(resolved_future, index) + resolve_with RESOLVED + end + end + + class ZipFutureEventPromise < BlockedPromise + def initialize(delayed, blockers_count, default_executor) + super delayed, 2, Future.new(self, default_executor) + @result = nil + end + + private + + def process_on_blocker_resolution(future, index) + # first blocking is future, take its result + @result = future.internal_state if index == 0 + # super has to be called after above to piggyback on volatile @Countdown + super future, index + end + + def on_resolvable(resolved_future, index) + resolve_with @result + end + end + + class EventWrapperPromise < BlockedPromise + def initialize(delayed, blockers_count, default_executor) + super delayed, 1, Event.new(self, default_executor) + end + + private + + def on_resolvable(resolved_future, index) + resolve_with RESOLVED + end + end + + class FutureWrapperPromise < BlockedPromise + def initialize(delayed, blockers_count, default_executor) + super delayed, 1, Future.new(self, default_executor) + end + + private + + def on_resolvable(resolved_future, index) + resolve_with resolved_future.internal_state + end + end + + class ZipFuturesPromise < BlockedPromise + + private + + def initialize(delayed, blockers_count, default_executor) + super(delayed, blockers_count, Future.new(self, default_executor)) + @Resolutions = ::Array.new(blockers_count, nil) + + on_resolvable nil, nil if blockers_count == 0 + end + + def process_on_blocker_resolution(future, index) + # TODO (pitr-ch 18-Dec-2016): Can we assume that array will never break under parallel access when never re-sized? + @Resolutions[index] = future.internal_state # has to be set before countdown in super + super future, index + end + + def on_resolvable(resolved_future, index) + all_fulfilled = true + values = ::Array.new(@Resolutions.size) + reasons = ::Array.new(@Resolutions.size) + + @Resolutions.each_with_index do |internal_state, i| + fulfilled, values[i], reasons[i] = internal_state.result + all_fulfilled &&= fulfilled + end + + if all_fulfilled + resolve_with FulfilledArray.new(values) + else + resolve_with PartiallyRejected.new(values, reasons) + end + end + end + + class ZipEventsPromise < BlockedPromise + + private + + def initialize(delayed, blockers_count, default_executor) + super delayed, blockers_count, Event.new(self, default_executor) + + on_resolvable nil, nil if blockers_count == 0 + end + + def on_resolvable(resolved_future, index) + resolve_with RESOLVED + end + end + + # @abstract + class AbstractAnyPromise < BlockedPromise + end + + class AnyResolvedEventPromise < AbstractAnyPromise + + private + + def initialize(delayed, blockers_count, default_executor) + super delayed, blockers_count, Event.new(self, default_executor) + end + + def resolvable?(countdown, future, index) + true + end + + def on_resolvable(resolved_future, index) + resolve_with RESOLVED, false + end + end + + class AnyResolvedFuturePromise < AbstractAnyPromise + + private + + def initialize(delayed, blockers_count, default_executor) + super delayed, blockers_count, Future.new(self, default_executor) + end + + def resolvable?(countdown, future, index) + true + end + + def on_resolvable(resolved_future, index) + resolve_with resolved_future.internal_state, false + end + end + + class AnyFulfilledFuturePromise < AnyResolvedFuturePromise + + private + + def resolvable?(countdown, event_or_future, index) + (event_or_future.is_a?(Event) ? event_or_future.resolved? : event_or_future.fulfilled?) || + # inlined super from BlockedPromise + countdown.zero? + end + end + + class DelayPromise < InnerPromise + + def initialize(default_executor) + event = Event.new(self, default_executor) + @Delayed = LockFreeStack.of1(self) + super event + event.add_callback_clear_delayed_node @Delayed.peek + end + + def touch + @Future.resolve_with RESOLVED + end + + def delayed_because + @Delayed + end + + end + + class ScheduledPromise < InnerPromise + def intended_time + @IntendedTime + end + + def inspect + "#{to_s[0..-2]} intended_time: #{@IntendedTime}>" + end + + private + + def initialize(default_executor, intended_time) + super Event.new(self, default_executor) + + @IntendedTime = intended_time + + in_seconds = begin + now = Time.now + schedule_time = if @IntendedTime.is_a? Time + @IntendedTime + else + now + @IntendedTime + end + [0, schedule_time.to_f - now.to_f].max + end + + Concurrent.global_timer_set.post(in_seconds) do + @Future.resolve_with RESOLVED + end + end + end + + extend FactoryMethods + + private_constant :AbstractPromise, + :ResolvableEventPromise, + :ResolvableFuturePromise, + :InnerPromise, + :BlockedPromise, + :BlockedTaskPromise, + :ThenPromise, + :RescuePromise, + :ChainPromise, + :ImmediateEventPromise, + :ImmediateFuturePromise, + :AbstractFlatPromise, + :FlatFuturePromise, + :FlatEventPromise, + :RunFuturePromise, + :ZipEventEventPromise, + :ZipFutureEventPromise, + :EventWrapperPromise, + :FutureWrapperPromise, + :ZipFuturesPromise, + :ZipEventsPromise, + :AbstractAnyPromise, + :AnyResolvedFuturePromise, + :AnyFulfilledFuturePromise, + :AnyResolvedEventPromise, + :DelayPromise, + :ScheduledPromise + + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/re_include.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/re_include.rb new file mode 100644 index 0000000..600bc6a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/re_include.rb @@ -0,0 +1,60 @@ +module Concurrent + + # Methods form module A included to a module B, which is already included into class C, + # will not be visible in the C class. If this module is extended to B then A's methods + # are correctly made visible to C. + # + # @example + # module A + # def a + # :a + # end + # end + # + # module B1 + # end + # + # class C1 + # include B1 + # end + # + # module B2 + # extend Concurrent::ReInclude + # end + # + # class C2 + # include B2 + # end + # + # B1.send :include, A + # B2.send :include, A + # + # C1.new.respond_to? :a # => false + # C2.new.respond_to? :a # => true + # + # @!visibility private + module ReInclude + # @!visibility private + def included(base) + (@re_include_to_bases ||= []) << [:include, base] + super(base) + end + + # @!visibility private + def extended(base) + (@re_include_to_bases ||= []) << [:extend, base] + super(base) + end + + # @!visibility private + def include(*modules) + result = super(*modules) + modules.reverse.each do |module_being_included| + (@re_include_to_bases ||= []).each do |method, mod| + mod.send method, module_being_included + end + end + result + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/scheduled_task.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/scheduled_task.rb new file mode 100644 index 0000000..429fc06 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/scheduled_task.rb @@ -0,0 +1,331 @@ +require 'concurrent/constants' +require 'concurrent/errors' +require 'concurrent/configuration' +require 'concurrent/ivar' +require 'concurrent/collection/copy_on_notify_observer_set' +require 'concurrent/utility/monotonic_time' + +require 'concurrent/options' + +module Concurrent + + # `ScheduledTask` is a close relative of `Concurrent::Future` but with one + # important difference: A `Future` is set to execute as soon as possible + # whereas a `ScheduledTask` is set to execute after a specified delay. This + # implementation is loosely based on Java's + # [ScheduledExecutorService](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html). + # It is a more feature-rich variant of {Concurrent.timer}. + # + # The *intended* schedule time of task execution is set on object construction + # with the `delay` argument. The delay is a numeric (floating point or integer) + # representing a number of seconds in the future. Any other value or a numeric + # equal to or less than zero will result in an exception. The *actual* schedule + # time of task execution is set when the `execute` method is called. + # + # The constructor can also be given zero or more processing options. Currently + # the only supported options are those recognized by the + # [Dereferenceable](Dereferenceable) module. + # + # The final constructor argument is a block representing the task to be performed. + # If no block is given an `ArgumentError` will be raised. + # + # **States** + # + # `ScheduledTask` mixes in the [Obligation](Obligation) module thus giving it + # "future" behavior. This includes the expected lifecycle states. `ScheduledTask` + # has one additional state, however. While the task (block) is being executed the + # state of the object will be `:processing`. This additional state is necessary + # because it has implications for task cancellation. + # + # **Cancellation** + # + # A `:pending` task can be cancelled using the `#cancel` method. A task in any + # other state, including `:processing`, cannot be cancelled. The `#cancel` + # method returns a boolean indicating the success of the cancellation attempt. + # A cancelled `ScheduledTask` cannot be restarted. It is immutable. + # + # **Obligation and Observation** + # + # The result of a `ScheduledTask` can be obtained either synchronously or + # asynchronously. `ScheduledTask` mixes in both the [Obligation](Obligation) + # module and the + # [Observable](http://ruby-doc.org/stdlib-2.0/libdoc/observer/rdoc/Observable.html) + # module from the Ruby standard library. With one exception `ScheduledTask` + # behaves identically to [Future](Observable) with regard to these modules. + # + # @!macro copy_options + # + # @example Basic usage + # + # require 'concurrent/scheduled_task' + # require 'csv' + # require 'open-uri' + # + # class Ticker + # def get_year_end_closing(symbol, year, api_key) + # uri = "https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=#{symbol}&apikey=#{api_key}&datatype=csv" + # data = [] + # csv = URI.parse(uri).read + # if csv.include?('call frequency') + # return :rate_limit_exceeded + # end + # CSV.parse(csv, headers: true) do |row| + # data << row['close'].to_f if row['timestamp'].include?(year.to_s) + # end + # year_end = data.first + # year_end + # rescue => e + # p e + # end + # end + # + # api_key = ENV['ALPHAVANTAGE_KEY'] + # abort(error_message) unless api_key + # + # # Future + # price = Concurrent::Future.execute{ Ticker.new.get_year_end_closing('TWTR', 2013, api_key) } + # price.state #=> :pending + # price.pending? #=> true + # price.value(0) #=> nil (does not block) + # + # sleep(1) # do other stuff + # + # price.value #=> 63.65 (after blocking if necessary) + # price.state #=> :fulfilled + # price.fulfilled? #=> true + # price.value #=> 63.65 + # + # @example Successful task execution + # + # task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' } + # task.state #=> :unscheduled + # task.execute + # task.state #=> pending + # + # # wait for it... + # sleep(3) + # + # task.unscheduled? #=> false + # task.pending? #=> false + # task.fulfilled? #=> true + # task.rejected? #=> false + # task.value #=> 'What does the fox say?' + # + # @example One line creation and execution + # + # task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' }.execute + # task.state #=> pending + # + # task = Concurrent::ScheduledTask.execute(2){ 'What do you get when you multiply 6 by 9?' } + # task.state #=> pending + # + # @example Failed task execution + # + # task = Concurrent::ScheduledTask.execute(2){ raise StandardError.new('Call me maybe?') } + # task.pending? #=> true + # + # # wait for it... + # sleep(3) + # + # task.unscheduled? #=> false + # task.pending? #=> false + # task.fulfilled? #=> false + # task.rejected? #=> true + # task.value #=> nil + # task.reason #=> # + # + # @example Task execution with observation + # + # observer = Class.new{ + # def update(time, value, reason) + # puts "The task completed at #{time} with value '#{value}'" + # end + # }.new + # + # task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' } + # task.add_observer(observer) + # task.execute + # task.pending? #=> true + # + # # wait for it... + # sleep(3) + # + # #>> The task completed at 2013-11-07 12:26:09 -0500 with value 'What does the fox say?' + # + # @!macro monotonic_clock_warning + # + # @see Concurrent.timer + class ScheduledTask < IVar + include Comparable + + # The executor on which to execute the task. + # @!visibility private + attr_reader :executor + + # Schedule a task for execution at a specified future time. + # + # @param [Float] delay the number of seconds to wait for before executing the task + # + # @yield the task to be performed + # + # @!macro executor_and_deref_options + # + # @option opts [object, Array] :args zero or more arguments to be passed the task + # block on execution + # + # @raise [ArgumentError] When no block is given + # @raise [ArgumentError] When given a time that is in the past + def initialize(delay, opts = {}, &task) + raise ArgumentError.new('no block given') unless block_given? + raise ArgumentError.new('seconds must be greater than zero') if delay.to_f < 0.0 + + super(NULL, opts, &nil) + + synchronize do + ns_set_state(:unscheduled) + @parent = opts.fetch(:timer_set, Concurrent.global_timer_set) + @args = get_arguments_from(opts) + @delay = delay.to_f + @task = task + @time = nil + @executor = Options.executor_from_options(opts) || Concurrent.global_io_executor + self.observers = Collection::CopyOnNotifyObserverSet.new + end + end + + # The `delay` value given at instanciation. + # + # @return [Float] the initial delay. + def initial_delay + synchronize { @delay } + end + + # The monotonic time at which the the task is scheduled to be executed. + # + # @return [Float] the schedule time or nil if `unscheduled` + def schedule_time + synchronize { @time } + end + + # Comparator which orders by schedule time. + # + # @!visibility private + def <=>(other) + schedule_time <=> other.schedule_time + end + + # Has the task been cancelled? + # + # @return [Boolean] true if the task is in the given state else false + def cancelled? + synchronize { ns_check_state?(:cancelled) } + end + + # In the task execution in progress? + # + # @return [Boolean] true if the task is in the given state else false + def processing? + synchronize { ns_check_state?(:processing) } + end + + # Cancel this task and prevent it from executing. A task can only be + # cancelled if it is pending or unscheduled. + # + # @return [Boolean] true if successfully cancelled else false + def cancel + if compare_and_set_state(:cancelled, :pending, :unscheduled) + complete(false, nil, CancelledOperationError.new) + # To avoid deadlocks this call must occur outside of #synchronize + # Changing the state above should prevent redundant calls + @parent.send(:remove_task, self) + else + false + end + end + + # Reschedule the task using the original delay and the current time. + # A task can only be reset while it is `:pending`. + # + # @return [Boolean] true if successfully rescheduled else false + def reset + synchronize{ ns_reschedule(@delay) } + end + + # Reschedule the task using the given delay and the current time. + # A task can only be reset while it is `:pending`. + # + # @param [Float] delay the number of seconds to wait for before executing the task + # + # @return [Boolean] true if successfully rescheduled else false + # + # @raise [ArgumentError] When given a time that is in the past + def reschedule(delay) + delay = delay.to_f + raise ArgumentError.new('seconds must be greater than zero') if delay < 0.0 + synchronize{ ns_reschedule(delay) } + end + + # Execute an `:unscheduled` `ScheduledTask`. Immediately sets the state to `:pending` + # and starts counting down toward execution. Does nothing if the `ScheduledTask` is + # in any state other than `:unscheduled`. + # + # @return [ScheduledTask] a reference to `self` + def execute + if compare_and_set_state(:pending, :unscheduled) + synchronize{ ns_schedule(@delay) } + end + self + end + + # Create a new `ScheduledTask` object with the given block, execute it, and return the + # `:pending` object. + # + # @param [Float] delay the number of seconds to wait for before executing the task + # + # @!macro executor_and_deref_options + # + # @return [ScheduledTask] the newly created `ScheduledTask` in the `:pending` state + # + # @raise [ArgumentError] if no block is given + def self.execute(delay, opts = {}, &task) + new(delay, opts, &task).execute + end + + # Execute the task. + # + # @!visibility private + def process_task + safe_execute(@task, @args) + end + + protected :set, :try_set, :fail, :complete + + protected + + # Schedule the task using the given delay and the current time. + # + # @param [Float] delay the number of seconds to wait for before executing the task + # + # @return [Boolean] true if successfully rescheduled else false + # + # @!visibility private + def ns_schedule(delay) + @delay = delay + @time = Concurrent.monotonic_time + @delay + @parent.send(:post_task, self) + end + + # Reschedule the task using the given delay and the current time. + # A task can only be reset while it is `:pending`. + # + # @param [Float] delay the number of seconds to wait for before executing the task + # + # @return [Boolean] true if successfully rescheduled else false + # + # @!visibility private + def ns_reschedule(delay) + return false unless ns_check_state?(:pending) + @parent.send(:remove_task, self) && ns_schedule(delay) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/set.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/set.rb new file mode 100644 index 0000000..eee4eff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/set.rb @@ -0,0 +1,64 @@ +require 'concurrent/utility/engine' +require 'concurrent/thread_safe/util' +require 'set' + +module Concurrent + + # @!macro concurrent_set + # + # A thread-safe subclass of Set. This version locks against the object + # itself for every method call, ensuring only one thread can be reading + # or writing at a time. This includes iteration methods like `#each`. + # + # @note `a += b` is **not** a **thread-safe** operation on + # `Concurrent::Set`. It reads Set `a`, then it creates new `Concurrent::Set` + # which is union of `a` and `b`, then it writes the union to `a`. + # The read and write are independent operations they do not form a single atomic + # operation therefore when two `+=` operations are executed concurrently updates + # may be lost. Use `#merge` instead. + # + # @see http://ruby-doc.org/stdlib-2.4.0/libdoc/set/rdoc/Set.html Ruby standard library `Set` + + # @!macro internal_implementation_note + SetImplementation = case + when Concurrent.on_cruby? + # The CRuby implementation of Set is written in Ruby itself and is + # not thread safe for certain methods. + require 'monitor' + require 'concurrent/thread_safe/util/data_structures' + + class CRubySet < ::Set + end + + ThreadSafe::Util.make_synchronized_on_cruby CRubySet + CRubySet + + when Concurrent.on_jruby? + require 'jruby/synchronized' + + class JRubySet < ::Set + include JRuby::Synchronized + end + + JRubySet + + when Concurrent.on_truffleruby? + require 'concurrent/thread_safe/util/data_structures' + + class TruffleRubySet < ::Set + end + + ThreadSafe::Util.make_synchronized_on_truffleruby TruffleRubySet + TruffleRubySet + + else + warn 'Possibly unsupported Ruby implementation' + ::Set + end + private_constant :SetImplementation + + # @!macro concurrent_set + class Set < SetImplementation + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/settable_struct.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/settable_struct.rb new file mode 100644 index 0000000..99b8561 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/settable_struct.rb @@ -0,0 +1,139 @@ +require 'concurrent/errors' +require 'concurrent/synchronization/abstract_struct' +require 'concurrent/synchronization/lockable_object' + +module Concurrent + + # An thread-safe, write-once variation of Ruby's standard `Struct`. + # Each member can have its value set at most once, either at construction + # or any time thereafter. Attempting to assign a value to a member + # that has already been set will result in a `Concurrent::ImmutabilityError`. + # + # @see http://ruby-doc.org/core/Struct.html Ruby standard library `Struct` + # @see http://en.wikipedia.org/wiki/Final_(Java) Java `final` keyword + module SettableStruct + include Synchronization::AbstractStruct + + # @!macro struct_values + def values + synchronize { ns_values } + end + alias_method :to_a, :values + + # @!macro struct_values_at + def values_at(*indexes) + synchronize { ns_values_at(indexes) } + end + + # @!macro struct_inspect + def inspect + synchronize { ns_inspect } + end + alias_method :to_s, :inspect + + # @!macro struct_merge + def merge(other, &block) + synchronize { ns_merge(other, &block) } + end + + # @!macro struct_to_h + def to_h + synchronize { ns_to_h } + end + + # @!macro struct_get + def [](member) + synchronize { ns_get(member) } + end + + # @!macro struct_equality + def ==(other) + synchronize { ns_equality(other) } + end + + # @!macro struct_each + def each(&block) + return enum_for(:each) unless block_given? + synchronize { ns_each(&block) } + end + + # @!macro struct_each_pair + def each_pair(&block) + return enum_for(:each_pair) unless block_given? + synchronize { ns_each_pair(&block) } + end + + # @!macro struct_select + def select(&block) + return enum_for(:select) unless block_given? + synchronize { ns_select(&block) } + end + + # @!macro struct_set + # + # @raise [Concurrent::ImmutabilityError] if the given member has already been set + def []=(member, value) + if member.is_a? Integer + length = synchronize { @values.length } + if member >= length + raise IndexError.new("offset #{member} too large for struct(size:#{length})") + end + synchronize do + unless @values[member].nil? + raise Concurrent::ImmutabilityError.new('struct member has already been set') + end + @values[member] = value + end + else + send("#{member}=", value) + end + rescue NoMethodError + raise NameError.new("no member '#{member}' in struct") + end + + private + + # @!visibility private + def initialize_copy(original) + synchronize do + super(original) + ns_initialize_copy + end + end + + # @!macro struct_new + def self.new(*args, &block) + clazz_name = nil + if args.length == 0 + raise ArgumentError.new('wrong number of arguments (0 for 1+)') + elsif args.length > 0 && args.first.is_a?(String) + clazz_name = args.shift + end + FACTORY.define_struct(clazz_name, args, &block) + end + + FACTORY = Class.new(Synchronization::LockableObject) do + def define_struct(name, members, &block) + synchronize do + clazz = Synchronization::AbstractStruct.define_struct_class(SettableStruct, Synchronization::LockableObject, name, members, &block) + members.each_with_index do |member, index| + clazz.send :remove_method, member if clazz.instance_methods.include? member + clazz.send(:define_method, member) do + synchronize { @values[index] } + end + clazz.send(:define_method, "#{member}=") do |value| + synchronize do + unless @values[index].nil? + raise Concurrent::ImmutabilityError.new('struct member has already been set') + end + @values[index] = value + end + end + end + clazz + end + end + end.new + private_constant :FACTORY + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization.rb new file mode 100644 index 0000000..6d8cf4b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization.rb @@ -0,0 +1,13 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first + +require 'concurrent/synchronization/object' +require 'concurrent/synchronization/lockable_object' +require 'concurrent/synchronization/condition' +require 'concurrent/synchronization/lock' + +module Concurrent + # @!visibility private + module Synchronization + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_lockable_object.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_lockable_object.rb new file mode 100644 index 0000000..d9050b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_lockable_object.rb @@ -0,0 +1,102 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first +require 'concurrent/utility/monotonic_time' +require 'concurrent/synchronization/object' + +module Concurrent + module Synchronization + + # @!visibility private + class AbstractLockableObject < Synchronization::Object + + protected + + # @!macro synchronization_object_method_synchronize + # + # @yield runs the block synchronized against this object, + # equivalent of java's `synchronize(this) {}` + # @note can by made public in descendants if required by `public :synchronize` + def synchronize + raise NotImplementedError + end + + # @!macro synchronization_object_method_ns_wait_until + # + # Wait until condition is met or timeout passes, + # protects against spurious wake-ups. + # @param [Numeric, nil] timeout in seconds, `nil` means no timeout + # @yield condition to be met + # @yieldreturn [true, false] + # @return [true, false] if condition met + # @note only to be used inside synchronized block + # @note to provide direct access to this method in a descendant add method + # ``` + # def wait_until(timeout = nil, &condition) + # synchronize { ns_wait_until(timeout, &condition) } + # end + # ``` + def ns_wait_until(timeout = nil, &condition) + if timeout + wait_until = Concurrent.monotonic_time + timeout + loop do + now = Concurrent.monotonic_time + condition_result = condition.call + return condition_result if now >= wait_until || condition_result + ns_wait wait_until - now + end + else + ns_wait timeout until condition.call + true + end + end + + # @!macro synchronization_object_method_ns_wait + # + # Wait until another thread calls #signal or #broadcast, + # spurious wake-ups can happen. + # + # @param [Numeric, nil] timeout in seconds, `nil` means no timeout + # @return [self] + # @note only to be used inside synchronized block + # @note to provide direct access to this method in a descendant add method + # ``` + # def wait(timeout = nil) + # synchronize { ns_wait(timeout) } + # end + # ``` + def ns_wait(timeout = nil) + raise NotImplementedError + end + + # @!macro synchronization_object_method_ns_signal + # + # Signal one waiting thread. + # @return [self] + # @note only to be used inside synchronized block + # @note to provide direct access to this method in a descendant add method + # ``` + # def signal + # synchronize { ns_signal } + # end + # ``` + def ns_signal + raise NotImplementedError + end + + # @!macro synchronization_object_method_ns_broadcast + # + # Broadcast to all waiting threads. + # @return [self] + # @note only to be used inside synchronized block + # @note to provide direct access to this method in a descendant add method + # ``` + # def broadcast + # synchronize { ns_broadcast } + # end + # ``` + def ns_broadcast + raise NotImplementedError + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_object.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_object.rb new file mode 100644 index 0000000..7cd2dec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_object.rb @@ -0,0 +1,22 @@ +module Concurrent + module Synchronization + + # @!visibility private + # @!macro internal_implementation_note + class AbstractObject + def initialize + # nothing to do + end + + # @!visibility private + # @abstract + def full_memory_barrier + raise NotImplementedError + end + + def self.attr_volatile(*names) + raise NotImplementedError + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb new file mode 100644 index 0000000..1fe90c1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb @@ -0,0 +1,171 @@ +module Concurrent + module Synchronization + + # @!visibility private + # @!macro internal_implementation_note + module AbstractStruct + + # @!visibility private + def initialize(*values) + super() + ns_initialize(*values) + end + + # @!macro struct_length + # + # Returns the number of struct members. + # + # @return [Fixnum] the number of struct members + def length + self.class::MEMBERS.length + end + alias_method :size, :length + + # @!macro struct_members + # + # Returns the struct members as an array of symbols. + # + # @return [Array] the struct members as an array of symbols + def members + self.class::MEMBERS.dup + end + + protected + + # @!macro struct_values + # + # @!visibility private + def ns_values + @values.dup + end + + # @!macro struct_values_at + # + # @!visibility private + def ns_values_at(indexes) + @values.values_at(*indexes) + end + + # @!macro struct_to_h + # + # @!visibility private + def ns_to_h + length.times.reduce({}){|memo, i| memo[self.class::MEMBERS[i]] = @values[i]; memo} + end + + # @!macro struct_get + # + # @!visibility private + def ns_get(member) + if member.is_a? Integer + if member >= @values.length + raise IndexError.new("offset #{member} too large for struct(size:#{@values.length})") + end + @values[member] + else + send(member) + end + rescue NoMethodError + raise NameError.new("no member '#{member}' in struct") + end + + # @!macro struct_equality + # + # @!visibility private + def ns_equality(other) + self.class == other.class && self.values == other.values + end + + # @!macro struct_each + # + # @!visibility private + def ns_each + values.each{|value| yield value } + end + + # @!macro struct_each_pair + # + # @!visibility private + def ns_each_pair + @values.length.times do |index| + yield self.class::MEMBERS[index], @values[index] + end + end + + # @!macro struct_select + # + # @!visibility private + def ns_select + values.select{|value| yield value } + end + + # @!macro struct_inspect + # + # @!visibility private + def ns_inspect + struct = pr_underscore(self.class.ancestors[1]) + clazz = ((self.class.to_s =~ /^#" + end + + # @!macro struct_merge + # + # @!visibility private + def ns_merge(other, &block) + self.class.new(*self.to_h.merge(other, &block).values) + end + + # @!visibility private + def ns_initialize_copy + @values = @values.map do |val| + begin + val.clone + rescue TypeError + val + end + end + end + + # @!visibility private + def pr_underscore(clazz) + word = clazz.to_s.dup # dup string to workaround JRuby 9.2.0.0 bug https://github.com/jruby/jruby/issues/5229 + word.gsub!(/::/, '/') + word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') + word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') + word.tr!("-", "_") + word.downcase! + word + end + + # @!visibility private + def self.define_struct_class(parent, base, name, members, &block) + clazz = Class.new(base || Object) do + include parent + self.const_set(:MEMBERS, members.collect{|member| member.to_s.to_sym}.freeze) + def ns_initialize(*values) + raise ArgumentError.new('struct size differs') if values.length > length + @values = values.fill(nil, values.length..length-1) + end + end + unless name.nil? + begin + parent.send :remove_const, name if parent.const_defined?(name, false) + parent.const_set(name, clazz) + clazz + rescue NameError + raise NameError.new("identifier #{name} needs to be constant") + end + end + members.each_with_index do |member, index| + clazz.send :remove_method, member if clazz.instance_methods.include? member + clazz.send(:define_method, member) do + @values[index] + end + end + clazz.class_exec(&block) unless block.nil? + clazz.singleton_class.send :alias_method, :[], :new + clazz + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/condition.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/condition.rb new file mode 100644 index 0000000..5daa68b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/condition.rb @@ -0,0 +1,62 @@ +require 'concurrent/synchronization/lockable_object' + +module Concurrent + module Synchronization + + # @!visibility private + # TODO (pitr-ch 04-Dec-2016): should be in edge + class Condition < LockableObject + safe_initialization! + + # TODO (pitr 12-Sep-2015): locks two objects, improve + # TODO (pitr 26-Sep-2015): study + # http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/util/concurrent/locks/AbstractQueuedSynchronizer.java#AbstractQueuedSynchronizer.Node + + singleton_class.send :alias_method, :private_new, :new + private_class_method :new + + def initialize(lock) + super() + @Lock = lock + end + + def wait(timeout = nil) + @Lock.synchronize { ns_wait(timeout) } + end + + def ns_wait(timeout = nil) + synchronize { super(timeout) } + end + + def wait_until(timeout = nil, &condition) + @Lock.synchronize { ns_wait_until(timeout, &condition) } + end + + def ns_wait_until(timeout = nil, &condition) + synchronize { super(timeout, &condition) } + end + + def signal + @Lock.synchronize { ns_signal } + end + + def ns_signal + synchronize { super } + end + + def broadcast + @Lock.synchronize { ns_broadcast } + end + + def ns_broadcast + synchronize { super } + end + end + + class LockableObject < LockableObjectImplementation + def new_condition + Condition.private_new(self) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/full_memory_barrier.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/full_memory_barrier.rb new file mode 100644 index 0000000..139e08d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/full_memory_barrier.rb @@ -0,0 +1,29 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first + +module Concurrent + module Synchronization + case + when Concurrent.on_cruby? + def self.full_memory_barrier + # relying on undocumented behavior of CRuby, GVL acquire has lock which ensures visibility of ivars + # https://github.com/ruby/ruby/blob/ruby_2_2/thread_pthread.c#L204-L211 + end + + when Concurrent.on_jruby? + require 'concurrent/utility/native_extension_loader' + def self.full_memory_barrier + JRubyAttrVolatile.full_memory_barrier + end + + when Concurrent.on_truffleruby? + def self.full_memory_barrier + TruffleRuby.full_memory_barrier + end + + else + warn 'Possibly unsupported Ruby implementation' + def self.full_memory_barrier + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/jruby_lockable_object.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/jruby_lockable_object.rb new file mode 100644 index 0000000..7693046 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/jruby_lockable_object.rb @@ -0,0 +1,15 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first + +module Concurrent + module Synchronization + + if Concurrent.on_jruby? + + # @!visibility private + # @!macro internal_implementation_note + class JRubyLockableObject < AbstractLockableObject + + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/lock.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/lock.rb new file mode 100644 index 0000000..f90e0b5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/lock.rb @@ -0,0 +1,38 @@ +require 'concurrent/synchronization/lockable_object' + +module Concurrent + module Synchronization + + # @!visibility private + # TODO (pitr-ch 04-Dec-2016): should be in edge + class Lock < LockableObject + # TODO use JavaReentrantLock on JRuby + + public :synchronize + + def wait(timeout = nil) + synchronize { ns_wait(timeout) } + end + + public :ns_wait + + def wait_until(timeout = nil, &condition) + synchronize { ns_wait_until(timeout, &condition) } + end + + public :ns_wait_until + + def signal + synchronize { ns_signal } + end + + public :ns_signal + + def broadcast + synchronize { ns_broadcast } + end + + public :ns_broadcast + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/lockable_object.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/lockable_object.rb new file mode 100644 index 0000000..08d2ff6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/lockable_object.rb @@ -0,0 +1,75 @@ +require 'concurrent/utility/engine' +require 'concurrent/synchronization/abstract_lockable_object' +require 'concurrent/synchronization/mutex_lockable_object' +require 'concurrent/synchronization/jruby_lockable_object' + +module Concurrent + module Synchronization + + # @!visibility private + # @!macro internal_implementation_note + LockableObjectImplementation = case + when Concurrent.on_cruby? + MutexLockableObject + when Concurrent.on_jruby? + JRubyLockableObject + when Concurrent.on_truffleruby? + MutexLockableObject + else + warn 'Possibly unsupported Ruby implementation' + MonitorLockableObject + end + private_constant :LockableObjectImplementation + + # Safe synchronization under any Ruby implementation. + # It provides methods like {#synchronize}, {#wait}, {#signal} and {#broadcast}. + # Provides a single layer which can improve its implementation over time without changes needed to + # the classes using it. Use {Synchronization::Object} not this abstract class. + # + # @note this object does not support usage together with + # [`Thread#wakeup`](http://ruby-doc.org/core/Thread.html#method-i-wakeup) + # and [`Thread#raise`](http://ruby-doc.org/core/Thread.html#method-i-raise). + # `Thread#sleep` and `Thread#wakeup` will work as expected but mixing `Synchronization::Object#wait` and + # `Thread#wakeup` will not work on all platforms. + # + # @see Event implementation as an example of this class use + # + # @example simple + # class AnClass < Synchronization::Object + # def initialize + # super + # synchronize { @value = 'asd' } + # end + # + # def value + # synchronize { @value } + # end + # end + # + # @!visibility private + class LockableObject < LockableObjectImplementation + + # TODO (pitr 12-Sep-2015): make private for c-r, prohibit subclassing + # TODO (pitr 12-Sep-2015): we inherit too much ourselves :/ + + # @!method initialize(*args, &block) + # @!macro synchronization_object_method_initialize + + # @!method synchronize + # @!macro synchronization_object_method_synchronize + + # @!method wait_until(timeout = nil, &condition) + # @!macro synchronization_object_method_ns_wait_until + + # @!method wait(timeout = nil) + # @!macro synchronization_object_method_ns_wait + + # @!method signal + # @!macro synchronization_object_method_ns_signal + + # @!method broadcast + # @!macro synchronization_object_method_ns_broadcast + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb new file mode 100644 index 0000000..acc9745 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb @@ -0,0 +1,89 @@ +require 'concurrent/synchronization/abstract_lockable_object' + +module Concurrent + module Synchronization + + # @!visibility private + # @!macro internal_implementation_note + module ConditionSignalling + protected + + def ns_signal + @__Condition__.signal + self + end + + def ns_broadcast + @__Condition__.broadcast + self + end + end + + + # @!visibility private + # @!macro internal_implementation_note + class MutexLockableObject < AbstractLockableObject + include ConditionSignalling + + safe_initialization! + + def initialize + super() + @__Lock__ = ::Mutex.new + @__Condition__ = ::ConditionVariable.new + end + + def initialize_copy(other) + super + @__Lock__ = ::Mutex.new + @__Condition__ = ::ConditionVariable.new + end + + protected + + def synchronize + if @__Lock__.owned? + yield + else + @__Lock__.synchronize { yield } + end + end + + def ns_wait(timeout = nil) + @__Condition__.wait @__Lock__, timeout + self + end + end + + # @!visibility private + # @!macro internal_implementation_note + class MonitorLockableObject < AbstractLockableObject + include ConditionSignalling + + safe_initialization! + + def initialize + super() + @__Lock__ = ::Monitor.new + @__Condition__ = @__Lock__.new_cond + end + + def initialize_copy(other) + super + @__Lock__ = ::Monitor.new + @__Condition__ = @__Lock__.new_cond + end + + protected + + def synchronize # TODO may be a problem with lock.synchronize { lock.wait } + @__Lock__.synchronize { yield } + end + + def ns_wait(timeout = nil) + @__Condition__.wait timeout + self + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/object.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/object.rb new file mode 100644 index 0000000..e839c9f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/object.rb @@ -0,0 +1,151 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first + +require 'concurrent/synchronization/safe_initialization' +require 'concurrent/synchronization/volatile' +require 'concurrent/atomic/atomic_reference' + +module Concurrent + module Synchronization + + # Abstract object providing final, volatile, ans CAS extensions to build other concurrent abstractions. + # - final instance variables see {Object.safe_initialization!} + # - volatile instance variables see {Object.attr_volatile} + # - volatile instance variables see {Object.attr_atomic} + # @!visibility private + class Object < AbstractObject + include Volatile + + # TODO make it a module if possible + + # @!method self.attr_volatile(*names) + # Creates methods for reading and writing (as `attr_accessor` does) to a instance variable with + # volatile (Java) semantic. The instance variable should be accessed only through generated methods. + # + # @param [::Array] names of the instance variables to be volatile + # @return [::Array] names of defined method names + + # Has to be called by children. + def initialize + super + __initialize_atomic_fields__ + end + + def self.safe_initialization! + extend SafeInitialization unless safe_initialization? + end + + def self.safe_initialization? + self.singleton_class < SafeInitialization + end + + # For testing purposes, quite slow. Injects assert code to new method which will raise if class instance contains + # any instance variables with CamelCase names and isn't {.safe_initialization?}. + # @raise when offend found + # @return [true] + def self.ensure_safe_initialization_when_final_fields_are_present + Object.class_eval do + def self.new(*args, &block) + object = super(*args, &block) + ensure + has_final_field = object.instance_variables.any? { |v| v.to_s =~ /^@[A-Z]/ } + if has_final_field && !safe_initialization? + raise "there was an instance of #{object.class} with final field but not marked with safe_initialization!" + end + end + end + true + end + + # Creates methods for reading and writing to a instance variable with + # volatile (Java) semantic as {.attr_volatile} does. + # The instance variable should be accessed oly through generated methods. + # This method generates following methods: `value`, `value=(new_value) #=> new_value`, + # `swap_value(new_value) #=> old_value`, + # `compare_and_set_value(expected, value) #=> true || false`, `update_value(&block)`. + # @param [::Array] names of the instance variables to be volatile with CAS. + # @return [::Array] names of defined method names. + # @!macro attr_atomic + # @!method $1 + # @return [Object] The $1. + # @!method $1=(new_$1) + # Set the $1. + # @return [Object] new_$1. + # @!method swap_$1(new_$1) + # Set the $1 to new_$1 and return the old $1. + # @return [Object] old $1 + # @!method compare_and_set_$1(expected_$1, new_$1) + # Sets the $1 to new_$1 if the current $1 is expected_$1 + # @return [true, false] + # @!method update_$1(&block) + # Updates the $1 using the block. + # @yield [Object] Calculate a new $1 using given (old) $1 + # @yieldparam [Object] old $1 + # @return [Object] new $1 + def self.attr_atomic(*names) + @__atomic_fields__ ||= [] + @__atomic_fields__ += names + safe_initialization! + define_initialize_atomic_fields + + names.each do |name| + ivar = :"@Atomic#{name.to_s.gsub(/(?:^|_)(.)/) { $1.upcase }}" + class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{name} + #{ivar}.get + end + + def #{name}=(value) + #{ivar}.set value + end + + def swap_#{name}(value) + #{ivar}.swap value + end + + def compare_and_set_#{name}(expected, value) + #{ivar}.compare_and_set expected, value + end + + def update_#{name}(&block) + #{ivar}.update(&block) + end + RUBY + end + names.flat_map { |n| [n, :"#{n}=", :"swap_#{n}", :"compare_and_set_#{n}", :"update_#{n}"] } + end + + # @param [true, false] inherited should inherited volatile with CAS fields be returned? + # @return [::Array] Returns defined volatile with CAS fields on this class. + def self.atomic_attributes(inherited = true) + @__atomic_fields__ ||= [] + ((superclass.atomic_attributes if superclass.respond_to?(:atomic_attributes) && inherited) || []) + @__atomic_fields__ + end + + # @return [true, false] is the attribute with name atomic? + def self.atomic_attribute?(name) + atomic_attributes.include? name + end + + private + + def self.define_initialize_atomic_fields + assignments = @__atomic_fields__.map do |name| + "@Atomic#{name.to_s.gsub(/(?:^|_)(.)/) { $1.upcase }} = Concurrent::AtomicReference.new(nil)" + end.join("\n") + + class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def __initialize_atomic_fields__ + super + #{assignments} + end + RUBY + end + + private_class_method :define_initialize_atomic_fields + + def __initialize_atomic_fields__ + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/safe_initialization.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/safe_initialization.rb new file mode 100644 index 0000000..f785e35 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/safe_initialization.rb @@ -0,0 +1,36 @@ +require 'concurrent/synchronization/full_memory_barrier' + +module Concurrent + module Synchronization + + # @!visibility private + # @!macro internal_implementation_note + # + # By extending this module, a class and all its children are marked to be constructed safely. Meaning that + # all writes (ivar initializations) are made visible to all readers of newly constructed object. It ensures + # same behaviour as Java's final fields. + # + # Due to using Kernel#extend, the module is not included again if already present in the ancestors, + # which avoids extra overhead. + # + # @example + # class AClass < Concurrent::Synchronization::Object + # extend Concurrent::Synchronization::SafeInitialization + # + # def initialize + # @AFinalValue = 'value' # published safely, #foo will never return nil + # end + # + # def foo + # @AFinalValue + # end + # end + module SafeInitialization + def new(*args, &block) + super(*args, &block) + ensure + Concurrent::Synchronization.full_memory_barrier + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/volatile.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/volatile.rb new file mode 100644 index 0000000..46e8ba6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/volatile.rb @@ -0,0 +1,101 @@ +require 'concurrent/utility/native_extension_loader' # load native parts first +require 'concurrent/utility/engine' +require 'concurrent/synchronization/full_memory_barrier' + +module Concurrent + module Synchronization + + # Volatile adds the attr_volatile class method when included. + # + # @example + # class Foo + # include Concurrent::Synchronization::Volatile + # + # attr_volatile :bar + # + # def initialize + # self.bar = 1 + # end + # end + # + # foo = Foo.new + # foo.bar + # => 1 + # foo.bar = 2 + # => 2 + # + # @!visibility private + module Volatile + def self.included(base) + base.extend(ClassMethods) + end + + def full_memory_barrier + Synchronization.full_memory_barrier + end + + module ClassMethods + if Concurrent.on_cruby? + def attr_volatile(*names) + names.each do |name| + ivar = :"@volatile_#{name}" + class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{name} + #{ivar} + end + + def #{name}=(value) + #{ivar} = value + end + RUBY + end + names.map { |n| [n, :"#{n}="] }.flatten + end + + elsif Concurrent.on_jruby? + def attr_volatile(*names) + names.each do |name| + ivar = :"@volatile_#{name}" + + class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{name} + ::Concurrent::Synchronization::JRubyAttrVolatile.instance_variable_get_volatile(self, :#{ivar}) + end + + def #{name}=(value) + ::Concurrent::Synchronization::JRubyAttrVolatile.instance_variable_set_volatile(self, :#{ivar}, value) + end + RUBY + + end + names.map { |n| [n, :"#{n}="] }.flatten + end + + else + warn 'Possibly unsupported Ruby implementation' unless Concurrent.on_truffleruby? + + def attr_volatile(*names) + names.each do |name| + ivar = :"@volatile_#{name}" + + class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{name} + ::Concurrent::Synchronization.full_memory_barrier + #{ivar} + end + + def #{name}=(value) + #{ivar} = value + ::Concurrent::Synchronization.full_memory_barrier + end + RUBY + end + + names.map { |n| [n, :"#{n}="] }.flatten + end + end + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/synchronized_delegator.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/synchronized_delegator.rb new file mode 100644 index 0000000..019d843 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/synchronized_delegator.rb @@ -0,0 +1,47 @@ +require 'delegate' +require 'monitor' + +module Concurrent + # This class provides a trivial way to synchronize all calls to a given object + # by wrapping it with a `Delegator` that performs `Monitor#enter/exit` calls + # around the delegated `#send`. Example: + # + # array = [] # not thread-safe on many impls + # array = SynchronizedDelegator.new([]) # thread-safe + # + # A simple `Monitor` provides a very coarse-grained way to synchronize a given + # object, in that it will cause synchronization for methods that have no need + # for it, but this is a trivial way to get thread-safety where none may exist + # currently on some implementations. + # + # This class is currently being considered for inclusion into stdlib, via + # https://bugs.ruby-lang.org/issues/8556 + # + # @!visibility private + class SynchronizedDelegator < SimpleDelegator + def setup + @old_abort = Thread.abort_on_exception + Thread.abort_on_exception = true + end + + def teardown + Thread.abort_on_exception = @old_abort + end + + def initialize(obj) + __setobj__(obj) + @monitor = Monitor.new + end + + def method_missing(method, *args, &block) + monitor = @monitor + begin + monitor.enter + super + ensure + monitor.exit + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util.rb new file mode 100644 index 0000000..c67084a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util.rb @@ -0,0 +1,16 @@ +module Concurrent + + # @!visibility private + module ThreadSafe + + # @!visibility private + module Util + + # TODO (pitr-ch 15-Oct-2016): migrate to Utility::NativeInteger + FIXNUM_BIT_SIZE = (0.size * 8) - 2 + MAX_INT = (2 ** FIXNUM_BIT_SIZE) - 1 + # TODO (pitr-ch 15-Oct-2016): migrate to Utility::ProcessorCounter + CPU_COUNT = 16 # is there a way to determine this? + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/adder.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/adder.rb new file mode 100644 index 0000000..7a6e8d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/adder.rb @@ -0,0 +1,74 @@ +require 'concurrent/thread_safe/util' +require 'concurrent/thread_safe/util/striped64' + +module Concurrent + + # @!visibility private + module ThreadSafe + + # @!visibility private + module Util + + # A Ruby port of the Doug Lea's jsr166e.LondAdder class version 1.8 + # available in public domain. + # + # Original source code available here: + # http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166e/LongAdder.java?revision=1.8 + # + # One or more variables that together maintain an initially zero + # sum. When updates (method +add+) are contended across threads, + # the set of variables may grow dynamically to reduce contention. + # Method +sum+ returns the current total combined across the + # variables maintaining the sum. + # + # This class is usually preferable to single +Atomic+ reference when + # multiple threads update a common sum that is used for purposes such + # as collecting statistics, not for fine-grained synchronization + # control. Under low update contention, the two classes have similar + # characteristics. But under high contention, expected throughput of + # this class is significantly higher, at the expense of higher space + # consumption. + # + # @!visibility private + class Adder < Striped64 + # Adds the given value. + def add(x) + if (current_cells = cells) || !cas_base_computed {|current_base| current_base + x} + was_uncontended = true + hash = hash_code + unless current_cells && (cell = current_cells.volatile_get_by_hash(hash)) && (was_uncontended = cell.cas_computed {|current_value| current_value + x}) + retry_update(x, hash, was_uncontended) {|current_value| current_value + x} + end + end + end + + def increment + add(1) + end + + def decrement + add(-1) + end + + # Returns the current sum. The returned value is _NOT_ an + # atomic snapshot: Invocation in the absence of concurrent + # updates returns an accurate result, but concurrent updates that + # occur while the sum is being calculated might not be + # incorporated. + def sum + x = base + if current_cells = cells + current_cells.each do |cell| + x += cell.value if cell + end + end + x + end + + def reset + internal_reset(0) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb new file mode 100644 index 0000000..01eb98f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb @@ -0,0 +1,52 @@ +require 'concurrent/thread_safe/util' +require 'concurrent/utility/engine' + +# Shim for TruffleRuby.synchronized +if Concurrent.on_truffleruby? && !TruffleRuby.respond_to?(:synchronized) + module TruffleRuby + def self.synchronized(object, &block) + Truffle::System.synchronized(object, &block) + end + end +end + +module Concurrent + module ThreadSafe + module Util + def self.make_synchronized_on_cruby(klass) + klass.class_eval do + def initialize(*args, &block) + @_monitor = Monitor.new + super + end + + def initialize_copy(other) + # make sure a copy is not sharing a monitor with the original object! + @_monitor = Monitor.new + super + end + end + + klass.superclass.instance_methods(false).each do |method| + klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{method}(*args) + monitor = @_monitor + monitor or raise("BUG: Internal monitor was not properly initialized. Please report this to the concurrent-ruby developers.") + monitor.synchronize { super } + end + RUBY + end + end + + def self.make_synchronized_on_truffleruby(klass) + klass.superclass.instance_methods(false).each do |method| + klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{method}(*args, &block) + TruffleRuby.synchronized(self) { super(*args, &block) } + end + RUBY + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb new file mode 100644 index 0000000..b54be39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb @@ -0,0 +1,38 @@ +require 'concurrent/thread_safe/util' +require 'concurrent/tuple' + +module Concurrent + + # @!visibility private + module ThreadSafe + + # @!visibility private + module Util + + # @!visibility private + class PowerOfTwoTuple < Concurrent::Tuple + + def initialize(size) + raise ArgumentError, "size must be a power of 2 (#{size.inspect} provided)" unless size > 0 && size & (size - 1) == 0 + super(size) + end + + def hash_to_index(hash) + (size - 1) & hash + end + + def volatile_get_by_hash(hash) + volatile_get(hash_to_index(hash)) + end + + def volatile_set_by_hash(hash, value) + volatile_set(hash_to_index(hash), value) + end + + def next_in_size_table + self.class.new(size << 1) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb new file mode 100644 index 0000000..4169c3d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb @@ -0,0 +1,246 @@ +require 'concurrent/thread_safe/util' +require 'concurrent/thread_safe/util/power_of_two_tuple' +require 'concurrent/thread_safe/util/volatile' +require 'concurrent/thread_safe/util/xor_shift_random' + +module Concurrent + + # @!visibility private + module ThreadSafe + + # @!visibility private + module Util + + # A Ruby port of the Doug Lea's jsr166e.Striped64 class version 1.6 + # available in public domain. + # + # Original source code available here: + # http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166e/Striped64.java?revision=1.6 + # + # Class holding common representation and mechanics for classes supporting + # dynamic striping on 64bit values. + # + # This class maintains a lazily-initialized table of atomically updated + # variables, plus an extra +base+ field. The table size is a power of two. + # Indexing uses masked per-thread hash codes. Nearly all methods on this + # class are private, accessed directly by subclasses. + # + # Table entries are of class +Cell+; a variant of AtomicLong padded to + # reduce cache contention on most processors. Padding is overkill for most + # Atomics because they are usually irregularly scattered in memory and thus + # don't interfere much with each other. But Atomic objects residing in + # arrays will tend to be placed adjacent to each other, and so will most + # often share cache lines (with a huge negative performance impact) without + # this precaution. + # + # In part because +Cell+s are relatively large, we avoid creating them until + # they are needed. When there is no contention, all updates are made to the + # +base+ field. Upon first contention (a failed CAS on +base+ update), the + # table is initialized to size 2. The table size is doubled upon further + # contention until reaching the nearest power of two greater than or equal + # to the number of CPUS. Table slots remain empty (+nil+) until they are + # needed. + # + # A single spinlock (+busy+) is used for initializing and resizing the + # table, as well as populating slots with new +Cell+s. There is no need for + # a blocking lock: When the lock is not available, threads try other slots + # (or the base). During these retries, there is increased contention and + # reduced locality, which is still better than alternatives. + # + # Per-thread hash codes are initialized to random values. Contention and/or + # table collisions are indicated by failed CASes when performing an update + # operation (see method +retry_update+). Upon a collision, if the table size + # is less than the capacity, it is doubled in size unless some other thread + # holds the lock. If a hashed slot is empty, and lock is available, a new + # +Cell+ is created. Otherwise, if the slot exists, a CAS is tried. Retries + # proceed by "double hashing", using a secondary hash (XorShift) to try to + # find a free slot. + # + # The table size is capped because, when there are more threads than CPUs, + # supposing that each thread were bound to a CPU, there would exist a + # perfect hash function mapping threads to slots that eliminates collisions. + # When we reach capacity, we search for this mapping by randomly varying the + # hash codes of colliding threads. Because search is random, and collisions + # only become known via CAS failures, convergence can be slow, and because + # threads are typically not bound to CPUS forever, may not occur at all. + # However, despite these limitations, observed contention rates are + # typically low in these cases. + # + # It is possible for a +Cell+ to become unused when threads that once hashed + # to it terminate, as well as in the case where doubling the table causes no + # thread to hash to it under expanded mask. We do not try to detect or + # remove such cells, under the assumption that for long-running instances, + # observed contention levels will recur, so the cells will eventually be + # needed again; and for short-lived ones, it does not matter. + # + # @!visibility private + class Striped64 + + # Padded variant of AtomicLong supporting only raw accesses plus CAS. + # The +value+ field is placed between pads, hoping that the JVM doesn't + # reorder them. + # + # Optimisation note: It would be possible to use a release-only + # form of CAS here, if it were provided. + # + # @!visibility private + class Cell < Concurrent::AtomicReference + + alias_method :cas, :compare_and_set + + def cas_computed + cas(current_value = value, yield(current_value)) + end + + # @!visibility private + def self.padding + # TODO: this only adds padding after the :value slot, need to find a way to add padding before the slot + # TODO (pitr-ch 28-Jul-2018): the padding instance vars may not be created + # hide from yardoc in a method + attr_reader :padding_0, :padding_1, :padding_2, :padding_3, :padding_4, :padding_5, :padding_6, :padding_7, :padding_8, :padding_9, :padding_10, :padding_11 + end + padding + end + + extend Volatile + attr_volatile :cells, # Table of cells. When non-null, size is a power of 2. + :base, # Base value, used mainly when there is no contention, but also as a fallback during table initialization races. Updated via CAS. + :busy # Spinlock (locked via CAS) used when resizing and/or creating Cells. + + alias_method :busy?, :busy + + def initialize + super() + self.busy = false + self.base = 0 + end + + # Handles cases of updates involving initialization, resizing, + # creating new Cells, and/or contention. See above for + # explanation. This method suffers the usual non-modularity + # problems of optimistic retry code, relying on rechecked sets of + # reads. + # + # Arguments: + # [+x+] + # the value + # [+hash_code+] + # hash code used + # [+x+] + # false if CAS failed before call + def retry_update(x, hash_code, was_uncontended) # :yields: current_value + hash = hash_code + collided = false # True if last slot nonempty + while true + if current_cells = cells + if !(cell = current_cells.volatile_get_by_hash(hash)) + if busy? + collided = false + else # Try to attach new Cell + if try_to_install_new_cell(Cell.new(x), hash) # Optimistically create and try to insert new cell + break + else + redo # Slot is now non-empty + end + end + elsif !was_uncontended # CAS already known to fail + was_uncontended = true # Continue after rehash + elsif cell.cas_computed {|current_value| yield current_value} + break + elsif current_cells.size >= CPU_COUNT || cells != current_cells # At max size or stale + collided = false + elsif collided && expand_table_unless_stale(current_cells) + collided = false + redo # Retry with expanded table + else + collided = true + end + hash = XorShiftRandom.xorshift(hash) + + elsif try_initialize_cells(x, hash) || cas_base_computed {|current_base| yield current_base} + break + end + end + self.hash_code = hash + end + + private + # Static per-thread hash code key. Shared across all instances to + # reduce Thread locals pollution and because adjustments due to + # collisions in one table are likely to be appropriate for + # others. + THREAD_LOCAL_KEY = "#{name}.hash_code".to_sym + + # A thread-local hash code accessor. The code is initially + # random, but may be set to a different value upon collisions. + def hash_code + Thread.current[THREAD_LOCAL_KEY] ||= XorShiftRandom.get + end + + def hash_code=(hash) + Thread.current[THREAD_LOCAL_KEY] = hash + end + + # Sets base and all +cells+ to the given value. + def internal_reset(initial_value) + current_cells = cells + self.base = initial_value + if current_cells + current_cells.each do |cell| + cell.value = initial_value if cell + end + end + end + + def cas_base_computed + cas_base(current_base = base, yield(current_base)) + end + + def free? + !busy? + end + + def try_initialize_cells(x, hash) + if free? && !cells + try_in_busy do + unless cells # Recheck under lock + new_cells = PowerOfTwoTuple.new(2) + new_cells.volatile_set_by_hash(hash, Cell.new(x)) + self.cells = new_cells + end + end + end + end + + def expand_table_unless_stale(current_cells) + try_in_busy do + if current_cells == cells # Recheck under lock + new_cells = current_cells.next_in_size_table + current_cells.each_with_index {|x, i| new_cells.volatile_set(i, x)} + self.cells = new_cells + end + end + end + + def try_to_install_new_cell(new_cell, hash) + try_in_busy do + # Recheck under lock + if (current_cells = cells) && !current_cells.volatile_get(i = current_cells.hash_to_index(hash)) + current_cells.volatile_set(i, new_cell) + end + end + end + + def try_in_busy + if cas_busy(false, true) + begin + yield + ensure + self.busy = false + end + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/volatile.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/volatile.rb new file mode 100644 index 0000000..cdac2a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/volatile.rb @@ -0,0 +1,75 @@ +require 'concurrent/thread_safe/util' + +module Concurrent + + # @!visibility private + module ThreadSafe + + # @!visibility private + module Util + + # @!visibility private + module Volatile + + # Provides +volatile+ (in the JVM's sense) attribute accessors implemented + # atop of +Concurrent::AtomicReference+. + # + # Usage: + # class Foo + # extend Concurrent::ThreadSafe::Util::Volatile + # attr_volatile :foo, :bar + # + # def initialize(bar) + # super() # must super() into parent initializers before using the volatile attribute accessors + # self.bar = bar + # end + # + # def hello + # my_foo = foo # volatile read + # self.foo = 1 # volatile write + # cas_foo(1, 2) # => true | a strong CAS + # end + # end + def attr_volatile(*attr_names) + return if attr_names.empty? + include(Module.new do + atomic_ref_setup = attr_names.map {|attr_name| "@__#{attr_name} = Concurrent::AtomicReference.new"} + initialize_copy_setup = attr_names.zip(atomic_ref_setup).map do |attr_name, ref_setup| + "#{ref_setup}(other.instance_variable_get(:@__#{attr_name}).get)" + end + class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def initialize(*) + super + #{atomic_ref_setup.join('; ')} + end + + def initialize_copy(other) + super + #{initialize_copy_setup.join('; ')} + end + RUBY_EVAL + + attr_names.each do |attr_name| + class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def #{attr_name} + @__#{attr_name}.get + end + + def #{attr_name}=(value) + @__#{attr_name}.set(value) + end + + def compare_and_set_#{attr_name}(old_value, new_value) + @__#{attr_name}.compare_and_set(old_value, new_value) + end + RUBY_EVAL + + alias_method :"cas_#{attr_name}", :"compare_and_set_#{attr_name}" + alias_method :"lazy_set_#{attr_name}", :"#{attr_name}=" + end + end) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/xor_shift_random.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/xor_shift_random.rb new file mode 100644 index 0000000..bdde2dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/thread_safe/util/xor_shift_random.rb @@ -0,0 +1,50 @@ +require 'concurrent/thread_safe/util' + +module Concurrent + + # @!visibility private + module ThreadSafe + + # @!visibility private + module Util + + # A xorshift random number (positive +Fixnum+s) generator, provides + # reasonably cheap way to generate thread local random numbers without + # contending for the global +Kernel.rand+. + # + # Usage: + # x = XorShiftRandom.get # uses Kernel.rand to generate an initial seed + # while true + # if (x = XorShiftRandom.xorshift).odd? # thread-localy generate a next random number + # do_something_at_random + # end + # end + module XorShiftRandom + extend self + MAX_XOR_SHIFTABLE_INT = MAX_INT - 1 + + # Generates an initial non-zero positive +Fixnum+ via +Kernel.rand+. + def get + Kernel.rand(MAX_XOR_SHIFTABLE_INT) + 1 # 0 can't be xorshifted + end + + # xorshift based on: http://www.jstatsoft.org/v08/i14/paper + if 0.size == 4 + # using the "yˆ=y>>a; yˆ=y<>c;" transform with the (a,b,c) tuple with values (3,1,14) to minimise Bignum overflows + def xorshift(x) + x ^= x >> 3 + x ^= (x << 1) & MAX_INT # cut-off Bignum overflow + x ^= x >> 14 + end + else + # using the "yˆ=y>>a; yˆ=y<>c;" transform with the (a,b,c) tuple with values (1,1,54) to minimise Bignum overflows + def xorshift(x) + x ^= x >> 1 + x ^= (x << 1) & MAX_INT # cut-off Bignum overflow + x ^= x >> 54 + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/timer_task.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/timer_task.rb new file mode 100644 index 0000000..dd2037f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/timer_task.rb @@ -0,0 +1,361 @@ +require 'concurrent/collection/copy_on_notify_observer_set' +require 'concurrent/concern/dereferenceable' +require 'concurrent/concern/observable' +require 'concurrent/atomic/atomic_boolean' +require 'concurrent/executor/executor_service' +require 'concurrent/executor/ruby_executor_service' +require 'concurrent/executor/safe_task_executor' +require 'concurrent/scheduled_task' + +module Concurrent + + # A very common concurrency pattern is to run a thread that performs a task at + # regular intervals. The thread that performs the task sleeps for the given + # interval then wakes up and performs the task. Lather, rinse, repeat... This + # pattern causes two problems. First, it is difficult to test the business + # logic of the task because the task itself is tightly coupled with the + # concurrency logic. Second, an exception raised while performing the task can + # cause the entire thread to abend. In a long-running application where the + # task thread is intended to run for days/weeks/years a crashed task thread + # can pose a significant problem. `TimerTask` alleviates both problems. + # + # When a `TimerTask` is launched it starts a thread for monitoring the + # execution interval. The `TimerTask` thread does not perform the task, + # however. Instead, the TimerTask launches the task on a separate thread. + # Should the task experience an unrecoverable crash only the task thread will + # crash. This makes the `TimerTask` very fault tolerant. Additionally, the + # `TimerTask` thread can respond to the success or failure of the task, + # performing logging or ancillary operations. + # + # One other advantage of `TimerTask` is that it forces the business logic to + # be completely decoupled from the concurrency logic. The business logic can + # be tested separately then passed to the `TimerTask` for scheduling and + # running. + # + # A `TimerTask` supports two different types of interval calculations. + # A fixed delay will always wait the same amount of time between the + # completion of one task and the start of the next. A fixed rate will + # attempt to maintain a constant rate of execution regardless of the + # duration of the task. For example, if a fixed rate task is scheduled + # to run every 60 seconds but the task itself takes 10 seconds to + # complete, the next task will be scheduled to run 50 seconds after + # the start of the previous task. If the task takes 70 seconds to + # complete, the next task will be start immediately after the previous + # task completes. Tasks will not be executed concurrently. + # + # In some cases it may be necessary for a `TimerTask` to affect its own + # execution cycle. To facilitate this, a reference to the TimerTask instance + # is passed as an argument to the provided block every time the task is + # executed. + # + # The `TimerTask` class includes the `Dereferenceable` mixin module so the + # result of the last execution is always available via the `#value` method. + # Dereferencing options can be passed to the `TimerTask` during construction or + # at any later time using the `#set_deref_options` method. + # + # `TimerTask` supports notification through the Ruby standard library + # {http://ruby-doc.org/stdlib-2.0/libdoc/observer/rdoc/Observable.html + # Observable} module. On execution the `TimerTask` will notify the observers + # with three arguments: time of execution, the result of the block (or nil on + # failure), and any raised exceptions (or nil on success). + # + # @!macro copy_options + # + # @example Basic usage + # task = Concurrent::TimerTask.new{ puts 'Boom!' } + # task.execute + # + # task.execution_interval #=> 60 (default) + # + # # wait 60 seconds... + # #=> 'Boom!' + # + # task.shutdown #=> true + # + # @example Configuring `:execution_interval` + # task = Concurrent::TimerTask.new(execution_interval: 5) do + # puts 'Boom!' + # end + # + # task.execution_interval #=> 5 + # + # @example Immediate execution with `:run_now` + # task = Concurrent::TimerTask.new(run_now: true){ puts 'Boom!' } + # task.execute + # + # #=> 'Boom!' + # + # @example Configuring `:interval_type` with either :fixed_delay or :fixed_rate, default is :fixed_delay + # task = Concurrent::TimerTask.new(execution_interval: 5, interval_type: :fixed_rate) do + # puts 'Boom!' + # end + # task.interval_type #=> :fixed_rate + # + # @example Last `#value` and `Dereferenceable` mixin + # task = Concurrent::TimerTask.new( + # dup_on_deref: true, + # execution_interval: 5 + # ){ Time.now } + # + # task.execute + # Time.now #=> 2013-11-07 18:06:50 -0500 + # sleep(10) + # task.value #=> 2013-11-07 18:06:55 -0500 + # + # @example Controlling execution from within the block + # timer_task = Concurrent::TimerTask.new(execution_interval: 1) do |task| + # task.execution_interval.to_i.times{ print 'Boom! ' } + # print "\n" + # task.execution_interval += 1 + # if task.execution_interval > 5 + # puts 'Stopping...' + # task.shutdown + # end + # end + # + # timer_task.execute + # #=> Boom! + # #=> Boom! Boom! + # #=> Boom! Boom! Boom! + # #=> Boom! Boom! Boom! Boom! + # #=> Boom! Boom! Boom! Boom! Boom! + # #=> Stopping... + # + # @example Observation + # class TaskObserver + # def update(time, result, ex) + # if result + # print "(#{time}) Execution successfully returned #{result}\n" + # else + # print "(#{time}) Execution failed with error #{ex}\n" + # end + # end + # end + # + # task = Concurrent::TimerTask.new(execution_interval: 1){ 42 } + # task.add_observer(TaskObserver.new) + # task.execute + # sleep 4 + # + # #=> (2013-10-13 19:08:58 -0400) Execution successfully returned 42 + # #=> (2013-10-13 19:08:59 -0400) Execution successfully returned 42 + # #=> (2013-10-13 19:09:00 -0400) Execution successfully returned 42 + # task.shutdown + # + # task = Concurrent::TimerTask.new(execution_interval: 1){ sleep } + # task.add_observer(TaskObserver.new) + # task.execute + # + # #=> (2013-10-13 19:07:25 -0400) Execution timed out + # #=> (2013-10-13 19:07:27 -0400) Execution timed out + # #=> (2013-10-13 19:07:29 -0400) Execution timed out + # task.shutdown + # + # task = Concurrent::TimerTask.new(execution_interval: 1){ raise StandardError } + # task.add_observer(TaskObserver.new) + # task.execute + # + # #=> (2013-10-13 19:09:37 -0400) Execution failed with error StandardError + # #=> (2013-10-13 19:09:38 -0400) Execution failed with error StandardError + # #=> (2013-10-13 19:09:39 -0400) Execution failed with error StandardError + # task.shutdown + # + # @see http://ruby-doc.org/stdlib-2.0/libdoc/observer/rdoc/Observable.html + # @see http://docs.oracle.com/javase/7/docs/api/java/util/TimerTask.html + class TimerTask < RubyExecutorService + include Concern::Dereferenceable + include Concern::Observable + + # Default `:execution_interval` in seconds. + EXECUTION_INTERVAL = 60 + + # Maintain the interval between the end of one execution and the start of the next execution. + FIXED_DELAY = :fixed_delay + + # Maintain the interval between the start of one execution and the start of the next. + # If execution time exceeds the interval, the next execution will start immediately + # after the previous execution finishes. Executions will not run concurrently. + FIXED_RATE = :fixed_rate + + # Default `:interval_type` + DEFAULT_INTERVAL_TYPE = FIXED_DELAY + + # Create a new TimerTask with the given task and configuration. + # + # @!macro timer_task_initialize + # @param [Hash] opts the options defining task execution. + # @option opts [Float] :execution_interval number of seconds between + # task executions (default: EXECUTION_INTERVAL) + # @option opts [Boolean] :run_now Whether to run the task immediately + # upon instantiation or to wait until the first # execution_interval + # has passed (default: false) + # @options opts [Symbol] :interval_type method to calculate the interval + # between executions, can be either :fixed_rate or :fixed_delay. + # (default: :fixed_delay) + # @option opts [Executor] executor, default is `global_io_executor` + # + # @!macro deref_options + # + # @raise ArgumentError when no block is given. + # + # @yield to the block after :execution_interval seconds have passed since + # the last yield + # @yieldparam task a reference to the `TimerTask` instance so that the + # block can control its own lifecycle. Necessary since `self` will + # refer to the execution context of the block rather than the running + # `TimerTask`. + # + # @return [TimerTask] the new `TimerTask` + def initialize(opts = {}, &task) + raise ArgumentError.new('no block given') unless block_given? + super + set_deref_options opts + end + + # Is the executor running? + # + # @return [Boolean] `true` when running, `false` when shutting down or shutdown + def running? + @running.true? + end + + # Execute a previously created `TimerTask`. + # + # @return [TimerTask] a reference to `self` + # + # @example Instance and execute in separate steps + # task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" } + # task.running? #=> false + # task.execute + # task.running? #=> true + # + # @example Instance and execute in one line + # task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" }.execute + # task.running? #=> true + def execute + synchronize do + if @running.false? + @running.make_true + schedule_next_task(@run_now ? 0 : @execution_interval) + end + end + self + end + + # Create and execute a new `TimerTask`. + # + # @!macro timer_task_initialize + # + # @example + # task = Concurrent::TimerTask.execute(execution_interval: 10){ print "Hello World\n" } + # task.running? #=> true + def self.execute(opts = {}, &task) + TimerTask.new(opts, &task).execute + end + + # @!attribute [rw] execution_interval + # @return [Fixnum] Number of seconds after the task completes before the + # task is performed again. + def execution_interval + synchronize { @execution_interval } + end + + # @!attribute [rw] execution_interval + # @return [Fixnum] Number of seconds after the task completes before the + # task is performed again. + def execution_interval=(value) + if (value = value.to_f) <= 0.0 + raise ArgumentError.new('must be greater than zero') + else + synchronize { @execution_interval = value } + end + end + + # @!attribute [r] interval_type + # @return [Symbol] method to calculate the interval between executions + attr_reader :interval_type + + # @!attribute [rw] timeout_interval + # @return [Fixnum] Number of seconds the task can run before it is + # considered to have failed. + def timeout_interval + warn 'TimerTask timeouts are now ignored as these were not able to be implemented correctly' + end + + # @!attribute [rw] timeout_interval + # @return [Fixnum] Number of seconds the task can run before it is + # considered to have failed. + def timeout_interval=(value) + warn 'TimerTask timeouts are now ignored as these were not able to be implemented correctly' + end + + private :post, :<< + + private + + def ns_initialize(opts, &task) + set_deref_options(opts) + + self.execution_interval = opts[:execution] || opts[:execution_interval] || EXECUTION_INTERVAL + if opts[:interval_type] && ![FIXED_DELAY, FIXED_RATE].include?(opts[:interval_type]) + raise ArgumentError.new('interval_type must be either :fixed_delay or :fixed_rate') + end + if opts[:timeout] || opts[:timeout_interval] + warn 'TimeTask timeouts are now ignored as these were not able to be implemented correctly' + end + + @run_now = opts[:now] || opts[:run_now] + @interval_type = opts[:interval_type] || DEFAULT_INTERVAL_TYPE + @task = Concurrent::SafeTaskExecutor.new(task) + @executor = opts[:executor] || Concurrent.global_io_executor + @running = Concurrent::AtomicBoolean.new(false) + @value = nil + + self.observers = Collection::CopyOnNotifyObserverSet.new + end + + # @!visibility private + def ns_shutdown_execution + @running.make_false + super + end + + # @!visibility private + def ns_kill_execution + @running.make_false + super + end + + # @!visibility private + def schedule_next_task(interval = execution_interval) + ScheduledTask.execute(interval, executor: @executor, args: [Concurrent::Event.new], &method(:execute_task)) + nil + end + + # @!visibility private + def execute_task(completion) + return nil unless @running.true? + start_time = Concurrent.monotonic_time + _success, value, reason = @task.execute(self) + if completion.try? + self.value = value + schedule_next_task(calculate_next_interval(start_time)) + time = Time.now + observers.notify_observers do + [time, self.value, reason] + end + end + nil + end + + # @!visibility private + def calculate_next_interval(start_time) + if @interval_type == FIXED_RATE + run_time = Concurrent.monotonic_time - start_time + [execution_interval - run_time, 0].max + else # FIXED_DELAY + execution_interval + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/tuple.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/tuple.rb new file mode 100644 index 0000000..56212cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/tuple.rb @@ -0,0 +1,82 @@ +require 'concurrent/atomic/atomic_reference' + +module Concurrent + + # A fixed size array with volatile (synchronized, thread safe) getters/setters. + # Mixes in Ruby's `Enumerable` module for enhanced search, sort, and traversal. + # + # @example + # tuple = Concurrent::Tuple.new(16) + # + # tuple.set(0, :foo) #=> :foo | volatile write + # tuple.get(0) #=> :foo | volatile read + # tuple.compare_and_set(0, :foo, :bar) #=> true | strong CAS + # tuple.cas(0, :foo, :baz) #=> false | strong CAS + # tuple.get(0) #=> :bar | volatile read + # + # @see https://en.wikipedia.org/wiki/Tuple Tuple entry at Wikipedia + # @see http://www.erlang.org/doc/reference_manual/data_types.html#id70396 Erlang Tuple + # @see http://ruby-doc.org/core-2.2.2/Enumerable.html Enumerable + class Tuple + include Enumerable + + # The (fixed) size of the tuple. + attr_reader :size + + # Create a new tuple of the given size. + # + # @param [Integer] size the number of elements in the tuple + def initialize(size) + @size = size + @tuple = tuple = ::Array.new(size) + i = 0 + while i < size + tuple[i] = Concurrent::AtomicReference.new + i += 1 + end + end + + # Get the value of the element at the given index. + # + # @param [Integer] i the index from which to retrieve the value + # @return [Object] the value at the given index or nil if the index is out of bounds + def get(i) + return nil if i >= @size || i < 0 + @tuple[i].get + end + alias_method :volatile_get, :get + + # Set the element at the given index to the given value + # + # @param [Integer] i the index for the element to set + # @param [Object] value the value to set at the given index + # + # @return [Object] the new value of the element at the given index or nil if the index is out of bounds + def set(i, value) + return nil if i >= @size || i < 0 + @tuple[i].set(value) + end + alias_method :volatile_set, :set + + # Set the value at the given index to the new value if and only if the current + # value matches the given old value. + # + # @param [Integer] i the index for the element to set + # @param [Object] old_value the value to compare against the current value + # @param [Object] new_value the value to set at the given index + # + # @return [Boolean] true if the value at the given element was set else false + def compare_and_set(i, old_value, new_value) + return false if i >= @size || i < 0 + @tuple[i].compare_and_set(old_value, new_value) + end + alias_method :cas, :compare_and_set + + # Calls the given block once for each element in self, passing that element as a parameter. + # + # @yieldparam [Object] ref the `Concurrent::AtomicReference` object at the current index + def each + @tuple.each {|ref| yield ref.get} + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/tvar.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/tvar.rb new file mode 100644 index 0000000..5d02ef0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/tvar.rb @@ -0,0 +1,222 @@ +require 'set' +require 'concurrent/synchronization/object' + +module Concurrent + + # A `TVar` is a transactional variable - a single-element container that + # is used as part of a transaction - see `Concurrent::atomically`. + # + # @!macro thread_safe_variable_comparison + # + # {include:file:docs-source/tvar.md} + class TVar < Synchronization::Object + safe_initialization! + + # Create a new `TVar` with an initial value. + def initialize(value) + @value = value + @lock = Mutex.new + end + + # Get the value of a `TVar`. + def value + Concurrent::atomically do + Transaction::current.read(self) + end + end + + # Set the value of a `TVar`. + def value=(value) + Concurrent::atomically do + Transaction::current.write(self, value) + end + end + + # @!visibility private + def unsafe_value # :nodoc: + @value + end + + # @!visibility private + def unsafe_value=(value) # :nodoc: + @value = value + end + + # @!visibility private + def unsafe_lock # :nodoc: + @lock + end + + end + + # Run a block that reads and writes `TVar`s as a single atomic transaction. + # With respect to the value of `TVar` objects, the transaction is atomic, in + # that it either happens or it does not, consistent, in that the `TVar` + # objects involved will never enter an illegal state, and isolated, in that + # transactions never interfere with each other. You may recognise these + # properties from database transactions. + # + # There are some very important and unusual semantics that you must be aware of: + # + # * Most importantly, the block that you pass to atomically may be executed + # more than once. In most cases your code should be free of + # side-effects, except for via TVar. + # + # * If an exception escapes an atomically block it will abort the transaction. + # + # * It is undefined behaviour to use callcc or Fiber with atomically. + # + # * If you create a new thread within an atomically, it will not be part of + # the transaction. Creating a thread counts as a side-effect. + # + # Transactions within transactions are flattened to a single transaction. + # + # @example + # a = new TVar(100_000) + # b = new TVar(100) + # + # Concurrent::atomically do + # a.value -= 10 + # b.value += 10 + # end + def atomically + raise ArgumentError.new('no block given') unless block_given? + + # Get the current transaction + + transaction = Transaction::current + + # Are we not already in a transaction (not nested)? + + if transaction.nil? + # New transaction + + begin + # Retry loop + + loop do + + # Create a new transaction + + transaction = Transaction.new + Transaction::current = transaction + + # Run the block, aborting on exceptions + + begin + result = yield + rescue Transaction::AbortError => e + transaction.abort + result = Transaction::ABORTED + rescue Transaction::LeaveError => e + transaction.abort + break result + rescue => e + transaction.abort + raise e + end + # If we can commit, break out of the loop + + if result != Transaction::ABORTED + if transaction.commit + break result + end + end + end + ensure + # Clear the current transaction + + Transaction::current = nil + end + else + # Nested transaction - flatten it and just run the block + + yield + end + end + + # Abort a currently running transaction - see `Concurrent::atomically`. + def abort_transaction + raise Transaction::AbortError.new + end + + # Leave a transaction without committing or aborting - see `Concurrent::atomically`. + def leave_transaction + raise Transaction::LeaveError.new + end + + module_function :atomically, :abort_transaction, :leave_transaction + + private + + # @!visibility private + class Transaction + + ABORTED = ::Object.new + + OpenEntry = Struct.new(:value, :modified) + + AbortError = Class.new(StandardError) + LeaveError = Class.new(StandardError) + + def initialize + @open_tvars = {} + end + + def read(tvar) + entry = open(tvar) + entry.value + end + + def write(tvar, value) + entry = open(tvar) + entry.modified = true + entry.value = value + end + + def open(tvar) + entry = @open_tvars[tvar] + + unless entry + unless tvar.unsafe_lock.try_lock + Concurrent::abort_transaction + end + + entry = OpenEntry.new(tvar.unsafe_value, false) + @open_tvars[tvar] = entry + end + + entry + end + + def abort + unlock + end + + def commit + @open_tvars.each do |tvar, entry| + if entry.modified + tvar.unsafe_value = entry.value + end + end + + unlock + end + + def unlock + @open_tvars.each_key do |tvar| + tvar.unsafe_lock.unlock + end + end + + def self.current + Thread.current[:current_tvar_transaction] + end + + def self.current=(transaction) + Thread.current[:current_tvar_transaction] = transaction + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/engine.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/engine.rb new file mode 100644 index 0000000..0c574b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/engine.rb @@ -0,0 +1,45 @@ +module Concurrent + # @!visibility private + module Utility + + # @!visibility private + module EngineDetector + def on_cruby? + RUBY_ENGINE == 'ruby' + end + + def on_jruby? + RUBY_ENGINE == 'jruby' + end + + def on_truffleruby? + RUBY_ENGINE == 'truffleruby' + end + + def on_windows? + !(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/).nil? + end + + def on_osx? + !(RbConfig::CONFIG['host_os'] =~ /darwin|mac os/).nil? + end + + def on_linux? + !(RbConfig::CONFIG['host_os'] =~ /linux/).nil? + end + + def ruby_version(version = RUBY_VERSION, comparison, major, minor, patch) + result = (version.split('.').map(&:to_i) <=> [major, minor, patch]) + comparisons = { :== => [0], + :>= => [1, 0], + :<= => [-1, 0], + :> => [1], + :< => [-1] } + comparisons.fetch(comparison).include? result + end + end + end + + # @!visibility private + extend Utility::EngineDetector +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/monotonic_time.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/monotonic_time.rb new file mode 100644 index 0000000..1c987d8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/monotonic_time.rb @@ -0,0 +1,19 @@ +module Concurrent + + # @!macro monotonic_get_time + # + # Returns the current time as tracked by the application monotonic clock. + # + # @param [Symbol] unit the time unit to be returned, can be either + # :float_second, :float_millisecond, :float_microsecond, :second, + # :millisecond, :microsecond, or :nanosecond default to :float_second. + # + # @return [Float] The current monotonic time since some unspecified + # starting point + # + # @!macro monotonic_clock_warning + def monotonic_time(unit = :float_second) + Process.clock_gettime(Process::CLOCK_MONOTONIC, unit) + end + module_function :monotonic_time +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb new file mode 100644 index 0000000..bf7bab3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb @@ -0,0 +1,77 @@ +require 'concurrent/utility/engine' +# Synchronization::AbstractObject must be defined before loading the extension +require 'concurrent/synchronization/abstract_object' + +module Concurrent + # @!visibility private + module Utility + # @!visibility private + module NativeExtensionLoader + + def allow_c_extensions? + Concurrent.on_cruby? + end + + def c_extensions_loaded? + defined?(@c_extensions_loaded) && @c_extensions_loaded + end + + def load_native_extensions + if Concurrent.on_cruby? && !c_extensions_loaded? + ['concurrent/concurrent_ruby_ext', + "concurrent/#{RUBY_VERSION[0..2]}/concurrent_ruby_ext" + ].each { |p| try_load_c_extension p } + end + + if Concurrent.on_jruby? && !java_extensions_loaded? + begin + require 'concurrent/concurrent_ruby.jar' + set_java_extensions_loaded + rescue LoadError => e + raise e, "Java extensions are required for JRuby.\n" + e.message, e.backtrace + end + end + end + + private + + def load_error_path(error) + if error.respond_to? :path + error.path + else + error.message.split(' -- ').last + end + end + + def set_c_extensions_loaded + @c_extensions_loaded = true + end + + def java_extensions_loaded? + defined?(@java_extensions_loaded) && @java_extensions_loaded + end + + def set_java_extensions_loaded + @java_extensions_loaded = true + end + + def try_load_c_extension(path) + require path + set_c_extensions_loaded + rescue LoadError => e + if load_error_path(e) == path + # move on with pure-Ruby implementations + # TODO (pitr-ch 12-Jul-2018): warning on verbose? + else + raise e + end + end + + end + end + + # @!visibility private + extend Utility::NativeExtensionLoader +end + +Concurrent.load_native_extensions diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_integer.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_integer.rb new file mode 100644 index 0000000..de1cdc3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_integer.rb @@ -0,0 +1,54 @@ +module Concurrent + # @!visibility private + module Utility + # @private + module NativeInteger + # http://stackoverflow.com/questions/535721/ruby-max-integer + MIN_VALUE = -(2**(0.size * 8 - 2)) + MAX_VALUE = (2**(0.size * 8 - 2) - 1) + + def ensure_upper_bound(value) + if value > MAX_VALUE + raise RangeError.new("#{value} is greater than the maximum value of #{MAX_VALUE}") + end + value + end + + def ensure_lower_bound(value) + if value < MIN_VALUE + raise RangeError.new("#{value} is less than the maximum value of #{MIN_VALUE}") + end + value + end + + def ensure_integer(value) + unless value.is_a?(Integer) + raise ArgumentError.new("#{value} is not an Integer") + end + value + end + + def ensure_integer_and_bounds(value) + ensure_integer value + ensure_upper_bound value + ensure_lower_bound value + end + + def ensure_positive(value) + if value < 0 + raise ArgumentError.new("#{value} cannot be negative") + end + value + end + + def ensure_positive_and_no_zero(value) + if value < 1 + raise ArgumentError.new("#{value} cannot be negative or zero") + end + value + end + + extend self + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/processor_counter.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/processor_counter.rb new file mode 100644 index 0000000..2489cbd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/processor_counter.rb @@ -0,0 +1,220 @@ +require 'etc' +require 'rbconfig' +require 'concurrent/delay' + +module Concurrent + # @!visibility private + module Utility + + # @!visibility private + class ProcessorCounter + def initialize + @processor_count = Delay.new { compute_processor_count } + @physical_processor_count = Delay.new { compute_physical_processor_count } + @cpu_quota = Delay.new { compute_cpu_quota } + @cpu_shares = Delay.new { compute_cpu_shares } + end + + def processor_count + @processor_count.value + end + + def physical_processor_count + @physical_processor_count.value + end + + def available_processor_count + cpu_count = processor_count.to_f + quota = cpu_quota + + return cpu_count if quota.nil? + + # cgroup cpus quotas have no limits, so they can be set to higher than the + # real count of cores. + if quota > cpu_count + cpu_count + else + quota + end + end + + def cpu_quota + @cpu_quota.value + end + + def cpu_shares + @cpu_shares.value + end + + private + + def compute_processor_count + if Concurrent.on_jruby? + java.lang.Runtime.getRuntime.availableProcessors + else + Etc.nprocessors + end + end + + def compute_physical_processor_count + ppc = case RbConfig::CONFIG["target_os"] + when /darwin\d\d/ + IO.popen("/usr/sbin/sysctl -n hw.physicalcpu", &:read).to_i + when /linux/ + cores = {} # unique physical ID / core ID combinations + phy = 0 + IO.read("/proc/cpuinfo").scan(/^physical id.*|^core id.*/) do |ln| + if ln.start_with?("physical") + phy = ln[/\d+/] + elsif ln.start_with?("core") + cid = phy + ":" + ln[/\d+/] + cores[cid] = true if not cores[cid] + end + end + cores.count + when /mswin|mingw/ + # Get-CimInstance introduced in PowerShell 3 or earlier: https://learn.microsoft.com/en-us/previous-versions/powershell/module/cimcmdlets/get-ciminstance?view=powershell-3.0 + result = run('powershell -command "Get-CimInstance -ClassName Win32_Processor -Property NumberOfCores | Select-Object -Property NumberOfCores"') + if !result || $?.exitstatus != 0 + # fallback to deprecated wmic for older systems + result = run("wmic cpu get NumberOfCores") + end + if !result || $?.exitstatus != 0 + # Bail out if both commands returned something unexpected + processor_count + else + # powershell: "\nNumberOfCores\n-------------\n 4\n\n\n" + # wmic: "NumberOfCores \n\n4 \n\n\n\n" + result.scan(/\d+/).map(&:to_i).reduce(:+) + end + else + processor_count + end + # fall back to logical count if physical info is invalid + ppc > 0 ? ppc : processor_count + rescue + return 1 + end + + def run(command) + IO.popen(command, &:read) + rescue Errno::ENOENT + end + + def compute_cpu_quota + if RbConfig::CONFIG["target_os"].include?("linux") + if File.exist?("/sys/fs/cgroup/cpu.max") + # cgroups v2: https://docs.kernel.org/admin-guide/cgroup-v2.html#cpu-interface-files + cpu_max = File.read("/sys/fs/cgroup/cpu.max") + return nil if cpu_max.start_with?("max ") # no limit + max, period = cpu_max.split.map(&:to_f) + max / period + elsif File.exist?("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us") + # cgroups v1: https://kernel.googlesource.com/pub/scm/linux/kernel/git/glommer/memcg/+/cpu_stat/Documentation/cgroups/cpu.txt + max = File.read("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us").to_i + # If the cpu.cfs_quota_us is -1, cgroup does not adhere to any CPU time restrictions + # https://docs.kernel.org/scheduler/sched-bwc.html#management + return nil if max <= 0 + period = File.read("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us").to_f + max / period + end + end + end + + def compute_cpu_shares + if RbConfig::CONFIG["target_os"].include?("linux") + if File.exist?("/sys/fs/cgroup/cpu.weight") + # cgroups v2: https://docs.kernel.org/admin-guide/cgroup-v2.html#cpu-interface-files + # Ref: https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2254-cgroup-v2#phase-1-convert-from-cgroups-v1-settings-to-v2 + weight = File.read("/sys/fs/cgroup/cpu.weight").to_f + ((((weight - 1) * 262142) / 9999) + 2) / 1024 + elsif File.exist?("/sys/fs/cgroup/cpu/cpu.shares") + # cgroups v1: https://kernel.googlesource.com/pub/scm/linux/kernel/git/glommer/memcg/+/cpu_stat/Documentation/cgroups/cpu.txt + File.read("/sys/fs/cgroup/cpu/cpu.shares").to_f / 1024 + end + end + end + end + end + + # create the default ProcessorCounter on load + @processor_counter = Utility::ProcessorCounter.new + singleton_class.send :attr_reader, :processor_counter + + # Number of processors seen by the OS and used for process scheduling. For + # performance reasons the calculated value will be memoized on the first + # call. + # + # When running under JRuby the Java runtime call + # `java.lang.Runtime.getRuntime.availableProcessors` will be used. According + # to the Java documentation this "value may change during a particular + # invocation of the virtual machine... [applications] should therefore + # occasionally poll this property." We still memoize this value once under + # JRuby. + # + # Otherwise Ruby's Etc.nprocessors will be used. + # + # @return [Integer] number of processors seen by the OS or Java runtime + # + # @see http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#availableProcessors() + def self.processor_count + processor_counter.processor_count + end + + # Number of physical processor cores on the current system. For performance + # reasons the calculated value will be memoized on the first call. + # + # On Windows the Win32 API will be queried for the `NumberOfCores from + # Win32_Processor`. This will return the total number "of cores for the + # current instance of the processor." On Unix-like operating systems either + # the `hwprefs` or `sysctl` utility will be called in a subshell and the + # returned value will be used. In the rare case where none of these methods + # work or an exception is raised the function will simply return 1. + # + # @return [Integer] number physical processor cores on the current system + # + # @see https://github.com/grosser/parallel/blob/4fc8b89d08c7091fe0419ca8fba1ec3ce5a8d185/lib/parallel.rb + # + # @see http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx + # @see http://www.unix.com/man-page/osx/1/HWPREFS/ + # @see http://linux.die.net/man/8/sysctl + def self.physical_processor_count + processor_counter.physical_processor_count + end + + # Number of processors cores available for process scheduling. + # This method takes in account the CPU quota if the process is inside a cgroup with a + # dedicated CPU quota (typically Docker). + # Otherwise it returns the same value as #processor_count but as a Float. + # + # For performance reasons the calculated value will be memoized on the first + # call. + # + # @return [Float] number of available processors + def self.available_processor_count + processor_counter.available_processor_count + end + + # The maximum number of processors cores available for process scheduling. + # Returns `nil` if there is no enforced limit, or a `Float` if the + # process is inside a cgroup with a dedicated CPU quota (typically Docker). + # + # Note that nothing prevents setting a CPU quota higher than the actual number of + # cores on the system. + # + # For performance reasons the calculated value will be memoized on the first + # call. + # + # @return [nil, Float] Maximum number of available processors as set by a cgroup CPU quota, or nil if none set + def self.cpu_quota + processor_counter.cpu_quota + end + + # The CPU shares requested by the process. For performance reasons the calculated + # value will be memoized on the first call. + # + # @return [Float, nil] CPU shares requested by the process, or nil if not set + def self.cpu_shares + processor_counter.cpu_shares + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/version.rb b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/version.rb new file mode 100644 index 0000000..1b0c4c2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/version.rb @@ -0,0 +1,3 @@ +module Concurrent + VERSION = '1.3.4' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/.gitignore b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/.gitignore new file mode 100644 index 0000000..616915c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/.gitignore @@ -0,0 +1,3 @@ +*.gemspec +pkg +Gemfile.lock diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/CHANGELOG.rdoc b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/CHANGELOG.rdoc new file mode 100644 index 0000000..f7dd9fb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/CHANGELOG.rdoc @@ -0,0 +1,149 @@ += Changelog + +== 0.5.1 / 2014-04-23 + +- new features: + - Support for receiving binary messages + +- changed: + - Allow additional close codes to be sent by apps + - Raise better errors on missing Sec-WebSocket-Key2 + - Updated http_parser.rb dependency to 0.6.0 + +- bug fixes: + - Abort if HTTP request URI is invalid + - Force close connections that have been sent a close handshake after a timeout + +- improved spec compliance on: + - Missing continuation frames + - Fragmented control frames + - Close behaviour after protocol errors + +== 0.5.0 / 2013-03-05 + +- new features: + - onclose handler is now passed a hash containing was_clean (set to true in drafts 03 and above when a connection is closed with a closing handshake, either by the server or the client), the close code, and reason (drafts 06 and above). Close code 1005 indicates that no code was supplied, and 1006 that the connection was closed abnormally. + - use Connection#support_close_codes? to easily check whether close codes are supported by the WebSocket protocol (drafts 06 and above) + - closes connection with 1007 close code if text frame contains invalid UTF8 + - added Handshake#secure? for checking whether the connection is secure (either ssl or behind an ssl proxy) + +- changed: + - Defaults to sending no close code rather than 1000 (consistent with browsers) + - Allows sending a 3xxx close code + - Renamed Connection#close_websocket to Connection#close (again for consistency with browsers). Old method is available till 0.6. + - Sends reasons with internally generated closure (previously only sent code) + - Echos close code when replying to close handshake + +== 0.4.0 / 2013-01-22 + +- new features: + - on_open handler is now passed a handshake object which exposes the request headers, path, and query parameters + - Easily access the protocol version via Handshake#protocol_version + - Easily access the origin via Handshake#origin + +- changed: + - Removed Connection#request - change to using handshake passed to on_open + +- internals: + - Uses the http_parser.rb gem + +== 0.3.8 / 2012-07-12 + +- bug fixes: + - Fixed support for Ruby 1.8.7 which was broken in 0.3.7 + +== 0.3.7 / 2012-07-11 + +- new features: + - Supports sending 1009 error code when incoming frame is too large to handle, and added associated exception class WSMessageTooBigError [Martyn Loughran] + - Supports overriding the maximum frame size by setting the max_frame_size accessor on the connection object (in bytes). Default unchanged at 10MB. [Martyn Loughran] + +- bug fixes: + - Fixes some encoding issues on Ruby 1.9 [Dingding Ye] + - Raises a HandshakeError if WS header is empty [Markus Fenske] + - Connection#send would mutate passed string to BINARY encoding. The fix still mutates the string by forcing the encoding back to UTF-8 before returning, but if the passed string was encoded as UTF-8 this is equivalent [Martyn Loughran] + +== 0.3.6 / 2011-12-23 + +- new features: + - Supports sending ping & pong messages + - Supports binding to received ping & pong messages + +== 0.3.5 / 2011-10-24 + +- new features: + - Support WebSocket draft 13 + +== 0.3.2 / 2011-10-09 + +- bugfixes: + - Handling of messages with > 2 frames + - Encode string passed to onmessage handler as UTF-8 on Ruby 1.9 + - Add 10MB frame length limit to all draft versions + +== 0.3.1 / 2011-07-28 + +- new features: + - Support WebSocket drafts 07 & 08 + +== 0.3.0 / 2011-05-06 + +- new features: + - Support WebSocket drafts 05 & 06 +- changes: + - Accept request headers in a case insensitive manner + - Change handling of errors. Previously some application errors were caught + internally and were invisible unless an onerror callback was supplied. See + readme for details + +== 0.2.1 / 2011-03-01 + +- bugfixes: + - Performance improvements to draft 76 framing + - Limit frame lengths for draft 76 + - Better error handling for draft 76 handshake + - Ruby 1.9 support + +== 0.2.0 / 2010-11-23 + +- new features: + - Support for WebSocket draft 03 +- bugfixes: + - Handle case when handshake split into two receive_data calls + - Stricter regexp matching of frames + +== 0.1.4 / 2010-08-23 + +- new features: + - Allow custom ssl certificate to be used by passing :tls_options + - Protect against errors caused by non limited frame lengths + - Use custom exceptions rather than RuntimeError +- bugfixes: + - Handle invalid HTTP request with HandshakeError + +== 0.1.3 / 2010-07-18 + +- new features: + - onerror callback +- bugfixes: + - proper handling of zero spaces in key1 or key2(prevent ZeroDivisionError) + - convert received data to utf-8 to prevent ruby 1.9 errors + - fix handling of null bytes within a frame + +== 0.1.2 / 2010-06-16 + +- new features: + - none +- bugfixes: + - allow $ character inside header key + +== 0.1.1 / 2010-06-13 + +- new features: + - wss/ssl support +- bugfixes: + - can't & strings + +== 0.1.0 / 2010-06-12 + +- initial release \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/Gemfile b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/Gemfile new file mode 100644 index 0000000..633ac0c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/Gemfile @@ -0,0 +1,9 @@ +source "http://rubygems.org" + +gemspec + +gem "em-websocket-client", git: "git@github.com:movitto/em-websocket-client.git", branch: "expose-websocket-api" +gem "em-spec", "~> 0.2.6" +gem "em-http-request", "~> 1.1.1" +gem "rspec", "~> 3.5.0" +gem "rake" diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/LICENCE b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/LICENCE new file mode 100644 index 0000000..d4df7ad --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/LICENCE @@ -0,0 +1,7 @@ +Copyright (c) 2009-2014 Ilya Grigorik, Martyn Loughran + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/README.md b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/README.md new file mode 100644 index 0000000..d112716 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/README.md @@ -0,0 +1,146 @@ +# EM-WebSocket + +[![Gem Version](https://badge.fury.io/rb/em-websocket.png)](http://rubygems.org/gems/em-websocket) +[![Analytics](https://ga-beacon.appspot.com/UA-71196-10/em-websocket/readme)](https://github.com/igrigorik/ga-beacon) + +EventMachine based, async, Ruby WebSocket server. Take a look at examples directory, or check out the blog post: [Ruby & Websockets: TCP for the Web](http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/). + +## Simple server example + +```ruby +require 'em-websocket' + +EM.run { + EM::WebSocket.run(:host => "0.0.0.0", :port => 8080) do |ws| + ws.onopen { |handshake| + puts "WebSocket connection open" + + # Access properties on the EM::WebSocket::Handshake object, e.g. + # path, query_string, origin, headers + + # Publish message to the client + ws.send "Hello Client, you connected to #{handshake.path}" + } + + ws.onclose { puts "Connection closed" } + + ws.onmessage { |msg| + puts "Recieved message: #{msg}" + ws.send "Pong: #{msg}" + } + end +} +``` + +## Protocols supported, and protocol specific functionality + +Supports all WebSocket protocols in use in the wild (and a few that are not): drafts 75, 76, 1-17, rfc. + +While some of the changes between protocols are unimportant from the point of view of application developers, a few drafts did introduce new functionality. It's possible to easily test for this functionality by using + +### Ping & pong supported + +Call `ws.pingable?` to check whether ping & pong is supported by the protocol in use. + +It's possible to send a ping frame (`ws.ping(body = '')`), which the client must respond to with a pong, or the server can send an unsolicited pong frame (`ws.pong(body = '')`) which the client should not respond to. These methods can be used regardless of protocol version; they return true if the protocol supports ping&pong or false otherwise. + +When receiving a ping, the server will automatically respond with a pong as the spec requires (so you should _not_ write an onping handler that replies with a pong), however it is possible to bind to ping & pong events if desired by using the `onping` and `onpong` methods. + +### Healthchecks + +It's possible to send a regular `HTTP GET` request to the `/healthcheck` endpoint and receive a `200` response from the server. + +### Close codes and reasons + +A WebSocket connection can be closed cleanly, regardless of protocol, by calling `ws.close(code = nil, body = nil)`. + +Early protocols just close the TCP connection, draft 3 introduced a close handshake, and draft 6 added close codes and reasons to the close handshake. Call `ws.supports_close_codes?` to check whether close codes are supported (i.e. the protocol version is 6 or above). + +The `onclose` callback is passed a hash which may contain following keys (depending on the protocol version): + +* `was_clean`: boolean indicating whether the connection was closed via the close handshake. +* `code`: the close code. There are two special close codes which the server may set (as defined in the WebSocket spec): + * 1005: no code was supplied + * 1006: abnormal closure (the same as `was_clean: false`) +* `reason`: the close reason + +Acceptable close codes are defined in the WebSocket rfc (). The following codes can be supplies when calling `ws.close(code)`: + +* 1000: a generic normal close +* range 3xxx: reserved for libraries, frameworks, and applications (and can be registered with IANA) +* range 4xxx: for private use + +If unsure use a code in the 4xxx range. em-websocket may also close a connection with one of the following close codes: + +* 1002: WebSocket protocol error. +* 1009: Message too big to process. By default em-websocket will accept frames up to 10MB in size. If a frame is larger than this the connection will be closed without reading the frame data. The limit can be overriden globally (`EM::WebSocket.max_frame_size = bytes`) or on a specific connection (`ws.max_frame_size = bytes`). + +## Secure server + +It is possible to accept secure `wss://` connections by passing `:secure => true` when opening the connection. Pass a `:tls_options` hash containing keys as described in http://www.rubydoc.info/github/eventmachine/eventmachine/EventMachine/Connection:start_tls + +**Warning**: Safari 5 does not currently support prompting on untrusted SSL certificates therefore using a self signed certificate may leave you scratching your head. + +```ruby +EM::WebSocket.start({ + :host => "0.0.0.0", + :port => 443, + :secure => true, + :tls_options => { + :private_key_file => "/private/key", + :cert_chain_file => "/ssl/certificate" + } +}) do |ws| + # ... +end +``` + +It's possible to check whether an incoming connection is secure by reading `handshake.secure?` in the onopen callback. + +## Running behind an SSL Proxy/Terminator, like Stunnel + +The `:secure_proxy => true` option makes it possible to use em-websocket behind a secure SSL proxy/terminator like [Stunnel](http://www.stunnel.org/) which does the actual encryption & decryption. + +Note that this option is only required to support drafts 75 & 76 correctly (e.g. Safari 5.1.x & earlier, and Safari on iOS 5.x & earlier). + +```ruby +EM::WebSocket.start({ + :host => "0.0.0.0", + :port => 8080, + :secure_proxy => true +}) do |ws| + # ... +end +``` + +## Handling errors + +There are two kinds of errors that need to be handled -- WebSocket protocol errors and errors in application code. + +WebSocket protocol errors (for example invalid data in the handshake or invalid message frames) raise errors which descend from `EM::WebSocket::WebSocketError`. Such errors are rescued internally and the WebSocket connection will be closed immediately or an error code sent to the browser in accordance to the WebSocket specification. It is possible to be notified in application code of such errors by including an `onerror` callback. + +```ruby +ws.onerror { |error| + if error.kind_of?(EM::WebSocket::WebSocketError) + # ... + end +} +``` + +Application errors are treated differently. If no `onerror` callback has been defined these errors will propagate to the EventMachine reactor, typically causing your program to terminate. If you wish to handle exceptions, simply supply an `onerror callback` and check for exceptions which are not descendant from `EM::WebSocket::WebSocketError`. + +It is also possible to log all errors when developing by including the `:debug => true` option when initialising the WebSocket server. + +## Emulating WebSockets in older browsers + +It is possible to emulate WebSockets in older browsers using flash emulation. For example take a look at the [web-socket-js](https://github.com/gimite/web-socket-js) project. + +Using flash emulation does require some minimal support from em-websocket which is enabled by default. If flash connects to the WebSocket port and requests a policy file (which it will do if it fails to receive a policy file on port 843 after a timeout), em-websocket will return one. Also see for an example policy file server which you can run on port 843. + +## Examples & Projects using em-websocket + +* [Pusher](http://pusher.com) - Realtime Messaging Service +* [Livereload](https://github.com/mockko/livereload) - LiveReload applies CSS/JS changes to Safari or Chrome w/o reloading +* [Twitter AMQP WebSocket Example](http://github.com/rubenfonseca/twitter-amqp-websocket-example) +* examples/multicast.rb - broadcast all ruby tweets to all subscribers +* examples/echo.rb - server <> client exchange via a websocket diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/Rakefile b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/Rakefile new file mode 100644 index 0000000..0bd2718 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/Rakefile @@ -0,0 +1,11 @@ +require 'bundler' +Bundler::GemHelper.install_tasks + +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new do |t| + t.rspec_opts = ["-c", "-f progress", "-r ./spec/helper.rb"] + t.pattern = 'spec/**/*_spec.rb' +end + +task :default => :spec diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/echo.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/echo.rb new file mode 100644 index 0000000..4e64886 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/echo.rb @@ -0,0 +1,24 @@ +require File.expand_path('../../lib/em-websocket', __FILE__) + +EM.run { + EM::WebSocket.run(:host => "0.0.0.0", :port => 8080, :debug => false) do |ws| + ws.onopen { |handshake| + puts "WebSocket opened #{{ + :path => handshake.path, + :query => handshake.query, + :origin => handshake.origin, + }}" + + ws.send "Hello Client!" + } + ws.onmessage { |msg| + ws.send "Pong: #{msg}" + } + ws.onclose { + puts "WebSocket closed" + } + ws.onerror { |e| + puts "Error: #{e.message}" + } + end +} diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/multicast.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/multicast.rb new file mode 100644 index 0000000..b1692d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/multicast.rb @@ -0,0 +1,47 @@ +require 'em-websocket' +# requires the twitter-stream gem +require 'twitter/json_stream' +require 'json' + +# +# broadcast all ruby related tweets to all connected users! +# + +username = ARGV.shift +password = ARGV.shift +raise "need username and password" if !username or !password + +EventMachine.run { + @channel = EM::Channel.new + + @twitter = Twitter::JSONStream.connect( + :path => '/1/statuses/filter.json?track=ruby', + :auth => "#{username}:#{password}", + :ssl => true + ) + + @twitter.each_item do |status| + status = JSON.parse(status) + @channel.push "#{status['user']['screen_name']}: #{status['text']}" + end + + + EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => true) do |ws| + + ws.onopen { + sid = @channel.subscribe { |msg| ws.send msg } + @channel.push "#{sid} connected!" + + ws.onmessage { |msg| + @channel.push "<#{sid}>: #{msg}" + } + + ws.onclose { + @channel.unsubscribe(sid) + } + } + + end + + puts "Server started" +} diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/ping.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/ping.rb new file mode 100644 index 0000000..fe569c3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/ping.rb @@ -0,0 +1,24 @@ +require File.expand_path('../../lib/em-websocket', __FILE__) + +EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => false) do |ws| + timer = nil + ws.onopen { + puts "Ping supported: #{ws.pingable?}" + timer = EM.add_periodic_timer(1) { + p ["Sent ping", ws.ping('hello')] + } + } + ws.onpong { |value| + puts "Received pong: #{value}" + } + ws.onping { |value| + puts "Received ping: #{value}" + } + ws.onclose { + EM.cancel_timer(timer) + puts "WebSocket closed" + } + ws.onerror { |e| + puts "Error: #{e.message}" + } +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/test.html b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/test.html new file mode 100644 index 0000000..07d4636 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/examples/test.html @@ -0,0 +1,29 @@ + + + + + +
+ + diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket.rb new file mode 100644 index 0000000..3eaa105 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket.rb @@ -0,0 +1,24 @@ +$:.unshift(File.dirname(__FILE__) + '/../lib') + +require "eventmachine" + +%w[ + debugger websocket connection + handshake + handshake75 handshake76 handshake04 + framing76 framing03 framing04 framing05 framing07 + close75 close03 close05 close06 + masking04 + message_processor_03 message_processor_06 + handler handler75 handler76 handler03 handler05 handler06 handler07 handler08 handler13 +].each do |file| + require "em-websocket/#{file}" +end + +unless ''.respond_to?(:getbyte) + class String + def getbyte(i) + self[i] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close03.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close03.rb new file mode 100644 index 0000000..8981776 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close03.rb @@ -0,0 +1,14 @@ +module EventMachine + module WebSocket + module Close03 + def close_websocket(code, body) + # TODO: Ideally send body data and check that it matches in ack + send_frame(:close, '') + @state = :closing + start_close_timeout + end + + def supports_close_codes?; false; end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close05.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close05.rb new file mode 100644 index 0000000..8f8c150 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close05.rb @@ -0,0 +1,14 @@ +module EventMachine + module WebSocket + module Close05 + def close_websocket(code, body) + # TODO: Ideally send body data and check that it matches in ack + send_frame(:close, "\x53") + @state = :closing + start_close_timeout + end + + def supports_close_codes?; false; end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close06.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close06.rb new file mode 100644 index 0000000..14cc80e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close06.rb @@ -0,0 +1,19 @@ +module EventMachine + module WebSocket + module Close06 + def close_websocket(code, body) + if code + close_data = [code].pack('n') + close_data << body if body + send_frame(:close, close_data) + else + send_frame(:close, '') + end + @state = :closing + start_close_timeout + end + + def supports_close_codes?; true; end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close75.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close75.rb new file mode 100644 index 0000000..9d6ba02 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/close75.rb @@ -0,0 +1,11 @@ +module EventMachine + module WebSocket + module Close75 + def close_websocket(code, body) + @connection.close_connection_after_writing + end + + def supports_close_codes?; false; end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/connection.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/connection.rb new file mode 100644 index 0000000..a55881d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/connection.rb @@ -0,0 +1,349 @@ +module EventMachine + module WebSocket + class Connection < EventMachine::Connection + include Debugger + + attr_writer :max_frame_size + + # define WebSocket callbacks + def onopen(&blk); @onopen = blk; end + def onclose(&blk); @onclose = blk; end + def onerror(&blk); @onerror = blk; end + def onmessage(&blk); @onmessage = blk; end + def onbinary(&blk); @onbinary = blk; end + def onping(&blk); @onping = blk; end + def onpong(&blk); @onpong = blk; end + + def trigger_on_message(msg) + @onmessage.call(msg) if defined? @onmessage + end + def trigger_on_binary(msg) + @onbinary.call(msg) if defined? @onbinary + end + def trigger_on_open(handshake) + @onopen.call(handshake) if defined? @onopen + end + def trigger_on_close(event = {}) + @onclose.call(event) if defined? @onclose + end + def trigger_on_ping(data) + @onping.call(data) if defined? @onping + end + def trigger_on_pong(data) + @onpong.call(data) if defined? @onpong + end + def trigger_on_error(reason) + return false unless defined? @onerror + @onerror.call(reason) + true + end + + def initialize(options) + @options = options + @debug = options[:debug] || false + @secure = options[:secure] || false + @secure_proxy = options[:secure_proxy] || false + @tls_options = options[:tls_options] || {} + @close_timeout = options[:close_timeout] + @outbound_limit = options[:outbound_limit] || 0 + + @handler = nil + + debug [:initialize] + end + + # Use this method to close the websocket connection cleanly + # This sends a close frame and waits for acknowlegement before closing + # the connection + def close(code = nil, body = nil) + if code && !acceptable_close_code?(code) + raise "Application code may only use codes from 1000, 3000-4999" + end + + close_websocket_private(code, body) + end + + # Deprecated, to be removed in version 0.6 + alias :close_websocket :close + + def post_init + start_tls(@tls_options) if @secure + end + + def receive_data(data) + debug [:receive_data, data] + + if @handler + @handler.receive_data(data) + else + dispatch(data) + end + rescue => e + debug [:error, e] + + # There is no code defined for application errors, so use 3000 + # (which is reserved for frameworks) + close_websocket_private(3000, "Application error") + + # These are application errors - raise unless onerror defined + trigger_on_error(e) || raise(e) + end + + def send_data(data) + if @outbound_limit > 0 && + get_outbound_data_size + data.bytesize > @outbound_limit + abort(:outbound_limit_reached) + return 0 + end + + super(data) + end + + def unbind + debug [:unbind, :connection] + + @handler.unbind if @handler + rescue => e + debug [:error, e] + # These are application errors - raise unless onerror defined + trigger_on_error(e) || raise(e) + end + + def dispatch(data) + if data.match(%r|^GET /healthcheck|) + send_healthcheck_response + elsif data.match(/\A/) + send_flash_cross_domain_file + else + @handshake ||= begin + handshake = Handshake.new(@secure || @secure_proxy) + + handshake.callback { |upgrade_response, handler_klass| + debug [:accepting_ws_version, handshake.protocol_version] + debug [:upgrade_response, upgrade_response] + self.send_data(upgrade_response) + @handler = handler_klass.new(self, @debug) + @handshake = nil + trigger_on_open(handshake) + } + + handshake.errback { |e| + debug [:error, e] + trigger_on_error(e) + # Handshake errors require the connection to be aborted + abort(:handshake_error) + } + + handshake + end + + @handshake.receive_data(data) + end + end + + def send_healthcheck_response + debug [:healthcheck, 'OK'] + + healthcheck_res = ["HTTP/1.1 200 OK"] + healthcheck_res << "Content-Type: text/plain" + healthcheck_res << "Content-Length: 2" + + healthcheck_res = healthcheck_res.join("\r\n") + "\r\n\r\nOK" + + send_data healthcheck_res + + # handle the healthcheck request transparently + # no need to notify the user about this connection + @onclose = nil + close_connection_after_writing + end + + def send_flash_cross_domain_file + file = '' + debug [:cross_domain, file] + send_data file + + # handle the cross-domain request transparently + # no need to notify the user about this connection + @onclose = nil + close_connection_after_writing + end + + # Cache encodings since it's moderately expensive to look them up each time + ENCODING_SUPPORTED = "string".respond_to?(:force_encoding) + UTF8 = Encoding.find("UTF-8") if ENCODING_SUPPORTED + BINARY = Encoding.find("BINARY") if ENCODING_SUPPORTED + + # Send a WebSocket text frame. + # + # A WebSocketError may be raised if the connection is in an opening or a + # closing state, or if the passed in data is not valid UTF-8 + # + def send_text(data) + # If we're using Ruby 1.9, be pedantic about encodings + if ENCODING_SUPPORTED + # Also accept ascii only data in other encodings for convenience + unless (data.encoding == UTF8 && data.valid_encoding?) || data.ascii_only? + raise WebSocketError, "Data sent to WebSocket must be valid UTF-8 but was #{data.encoding} (valid: #{data.valid_encoding?})" + end + # This labels the encoding as binary so that it can be combined with + # the BINARY framing + data.force_encoding(BINARY) + else + # TODO: Check that data is valid UTF-8 + end + + if @handler + @handler.send_text_frame(data) + else + raise WebSocketError, "Cannot send data before onopen callback" + end + + # Revert data back to the original encoding (which we assume is UTF-8) + # Doing this to avoid duping the string - there may be a better way + data.force_encoding(UTF8) if ENCODING_SUPPORTED + return nil + end + + alias :send :send_text + + # Send a WebSocket binary frame. + # + def send_binary(data) + if @handler + @handler.send_frame(:binary, data) + else + raise WebSocketError, "Cannot send binary before onopen callback" + end + end + + # Send a ping to the client. The client must respond with a pong. + # + # In the case that the client is running a WebSocket draft < 01, false + # is returned since ping & pong are not supported + # + def ping(body = '') + if @handler + @handler.pingable? ? @handler.send_frame(:ping, body) && true : false + else + raise WebSocketError, "Cannot ping before onopen callback" + end + end + + # Send an unsolicited pong message, as allowed by the protocol. The + # client is not expected to respond to this message. + # + # em-websocket automatically takes care of sending pong replies to + # incoming ping messages, as the protocol demands. + # + def pong(body = '') + if @handler + @handler.pingable? ? @handler.send_frame(:pong, body) && true : false + else + raise WebSocketError, "Cannot ping before onopen callback" + end + end + + # Test whether the connection is pingable (i.e. the WebSocket draft in + # use is >= 01) + def pingable? + if @handler + @handler.pingable? + else + raise WebSocketError, "Cannot test whether pingable before onopen callback" + end + end + + def supports_close_codes? + if @handler + @handler.supports_close_codes? + else + raise WebSocketError, "Cannot test before onopen callback" + end + end + + def state + @handler ? @handler.state : :handshake + end + + # Returns the IP address for the remote peer + def remote_ip + get_peername[2,6].unpack('nC4')[1..4].join('.') + end + + # Returns the maximum frame size which this connection is configured to + # accept. This can be set globally or on a per connection basis, and + # defaults to a value of 10MB if not set. + # + # The behaviour when a too large frame is received varies by protocol, + # but in the newest protocols the connection will be closed with the + # correct close code (1009) immediately after receiving the frame header + # + def max_frame_size + defined?(@max_frame_size) ? @max_frame_size : WebSocket.max_frame_size + end + + def close_timeout + @close_timeout || WebSocket.close_timeout + end + + private + + # As definited in draft 06 7.2.2, some failures require that the server + # abort the websocket connection rather than close cleanly + def abort(reason) + debug [:abort, reason] + close_connection + end + + def close_websocket_private(code, body) + if @handler + debug [:closing, code] + @handler.close_websocket(code, body) + else + # The handshake hasn't completed - should be safe to terminate + abort(:handshake_incomplete) + end + end + + # Allow applications to close with 1000, 1003, 1008, 1011, 3xxx or 4xxx. + # + # em-websocket uses a few other codes internally which should not be + # used by applications + # + # Browsers generally allow connections to be closed with code 1000, + # 3xxx, and 4xxx. em-websocket allows closing with a few other codes + # which seem reasonable (for discussion see + # https://github.com/igrigorik/em-websocket/issues/98) + # + # Usage from the rfc: + # + # 1000 indicates a normal closure + # + # 1003 indicates that an endpoint is terminating the connection + # because it has received a type of data it cannot accept + # + # 1008 indicates that an endpoint is terminating the connection because + # it has received a message that violates its policy + # + # 1011 indicates that a server is terminating the connection because it + # encountered an unexpected condition that prevented it from fulfilling + # the request + # + # Status codes in the range 3000-3999 are reserved for use by libraries, + # frameworks, and applications + # + # Status codes in the range 4000-4999 are reserved for private use and + # thus can't be registered + # + def acceptable_close_code?(code) + case code + when 1000, 1003, 1008, 1011, (3000..4999) + true + else + false + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/debugger.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/debugger.rb new file mode 100644 index 0000000..a5b3266 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/debugger.rb @@ -0,0 +1,17 @@ +module EventMachine + module WebSocket + module Debugger + + private + + def debug(*data) + if @debug + require 'pp' + pp data + puts + end + end + + end + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing03.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing03.rb new file mode 100644 index 0000000..61e6ab8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing03.rb @@ -0,0 +1,162 @@ +# encoding: BINARY + +module EventMachine + module WebSocket + module Framing03 + def initialize_framing + @data = '' + @application_data_buffer = '' # Used for MORE frames + @frame_type = nil + end + + def process_data + error = false + + while !error && @data.size > 1 + pointer = 0 + + more = ((@data.getbyte(pointer) & 0b10000000) == 0b10000000) ^ fin + # Ignoring rsv1-3 for now + opcode = @data.getbyte(0) & 0b00001111 + pointer += 1 + + # Ignoring rsv4 + length = @data.getbyte(pointer) & 0b01111111 + pointer += 1 + + payload_length = case length + when 127 # Length defined by 8 bytes + # Check buffer size + if @data.getbyte(pointer+8-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + # Only using the last 4 bytes for now, till I work out how to + # unpack 8 bytes. I'm sure 4GB frames will do for now :) + l = @data[(pointer+4)..(pointer+7)].unpack('N').first + pointer += 8 + l + when 126 # Length defined by 2 bytes + # Check buffer size + if @data.getbyte(pointer+2-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + l = @data[pointer..(pointer+1)].unpack('n').first + pointer += 2 + l + else + length + end + + if payload_length > @connection.max_frame_size + raise WSMessageTooBigError, "Frame length too long (#{payload_length} bytes)" + end + + # Check buffer size + if @data.getbyte(pointer+payload_length-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + # Throw away data up to pointer + @data.slice!(0...pointer) + + # Read application data + application_data = @data.slice!(0...payload_length) + + frame_type = opcode_to_type(opcode) + + if frame_type == :continuation && !@frame_type + raise WSProtocolError, 'Continuation frame not expected' + end + + if more + debug [:moreframe, frame_type, application_data] + @application_data_buffer << application_data + # The message type is passed in the first frame + @frame_type ||= frame_type + else + # Message is complete + if frame_type == :continuation + @application_data_buffer << application_data + message(@frame_type, '', @application_data_buffer) + @application_data_buffer = '' + @frame_type = nil + else + message(frame_type, '', application_data) + end + end + end # end while + end + + def send_frame(frame_type, application_data) + debug [:sending_frame, frame_type, application_data] + + if @state == :closing && data_frame?(frame_type) + raise WebSocketError, "Cannot send data frame since connection is closing" + end + + frame = '' + + opcode = type_to_opcode(frame_type) + byte1 = opcode # since more, rsv1-3 are 0 + frame << byte1 + + length = application_data.size + if length <= 125 + byte2 = length # since rsv4 is 0 + frame << byte2 + elsif length < 65536 # write 2 byte length + frame << 126 + frame << [length].pack('n') + else # write 8 byte length + frame << 127 + frame << [length >> 32, length & 0xFFFFFFFF].pack("NN") + end + + frame << application_data + + @connection.send_data(frame) + end + + def send_text_frame(data) + send_frame(:text, data) + end + + private + + # This allows flipping the more bit to fin for draft 04 + def fin; false; end + + FRAME_TYPES = { + :continuation => 0, + :close => 1, + :ping => 2, + :pong => 3, + :text => 4, + :binary => 5 + } + FRAME_TYPES_INVERSE = FRAME_TYPES.invert + # Frames are either data frames or control frames + DATA_FRAMES = [:text, :binary, :continuation] + + def type_to_opcode(frame_type) + FRAME_TYPES[frame_type] || raise("Unknown frame type") + end + + def opcode_to_type(opcode) + FRAME_TYPES_INVERSE[opcode] || raise(WSProtocolError, "Unknown opcode #{opcode}") + end + + def data_frame?(type) + DATA_FRAMES.include?(type) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing04.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing04.rb new file mode 100644 index 0000000..41352e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing04.rb @@ -0,0 +1,15 @@ +# encoding: BINARY + +module EventMachine + module WebSocket + # The only difference between draft 03 framing and draft 04 framing is + # that the MORE bit has been changed to a FIN bit + module Framing04 + include Framing03 + + private + + def fin; true; end + end + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing05.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing05.rb new file mode 100644 index 0000000..636336a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing05.rb @@ -0,0 +1,163 @@ +# encoding: BINARY + +module EventMachine + module WebSocket + module Framing05 + def initialize_framing + @data = MaskedString.new + @application_data_buffer = '' # Used for MORE frames + @frame_type = nil + end + + def process_data + error = false + + while !error && @data.size > 5 # mask plus first byte present + pointer = 0 + + @data.read_mask + pointer += 4 + + fin = (@data.getbyte(pointer) & 0b10000000) == 0b10000000 + # Ignoring rsv1-3 for now + opcode = @data.getbyte(pointer) & 0b00001111 + pointer += 1 + + # Ignoring rsv4 + length = @data.getbyte(pointer) & 0b01111111 + pointer += 1 + + payload_length = case length + when 127 # Length defined by 8 bytes + # Check buffer size + if @data.getbyte(pointer+8-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + # Only using the last 4 bytes for now, till I work out how to + # unpack 8 bytes. I'm sure 4GB frames will do for now :) + l = @data.getbytes(pointer+4, 4).unpack('N').first + pointer += 8 + l + when 126 # Length defined by 2 bytes + # Check buffer size + if @data.getbyte(pointer+2-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + l = @data.getbytes(pointer, 2).unpack('n').first + pointer += 2 + l + else + length + end + + if payload_length > @connection.max_frame_size + raise WSMessageTooBigError, "Frame length too long (#{payload_length} bytes)" + end + + # Check buffer size + if @data.getbyte(pointer+payload_length-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + # Read application data + application_data = @data.getbytes(pointer, payload_length) + pointer += payload_length + + # Throw away data up to pointer + @data.unset_mask + @data.slice!(0...pointer) + + frame_type = opcode_to_type(opcode) + + if frame_type == :continuation && !@frame_type + raise WSProtocolError, 'Continuation frame not expected' + end + + if !fin + debug [:moreframe, frame_type, application_data] + @application_data_buffer << application_data + @frame_type = frame_type + else + # Message is complete + if frame_type == :continuation + @application_data_buffer << application_data + message(@frame_type, '', @application_data_buffer) + @application_data_buffer = '' + @frame_type = nil + else + message(frame_type, '', application_data) + end + end + end # end while + end + + def send_frame(frame_type, application_data) + debug [:sending_frame, frame_type, application_data] + + if @state == :closing && data_frame?(frame_type) + raise WebSocketError, "Cannot send data frame since connection is closing" + end + + frame = '' + + opcode = type_to_opcode(frame_type) + byte1 = opcode | 0b10000000 # fin bit set, rsv1-3 are 0 + frame << byte1 + + length = application_data.size + if length <= 125 + byte2 = length # since rsv4 is 0 + frame << byte2 + elsif length < 65536 # write 2 byte length + frame << 126 + frame << [length].pack('n') + else # write 8 byte length + frame << 127 + frame << [length >> 32, length & 0xFFFFFFFF].pack("NN") + end + + frame << application_data + + @connection.send_data(frame) + end + + def send_text_frame(data) + send_frame(:text, data) + end + + private + + FRAME_TYPES = { + :continuation => 0, + :close => 1, + :ping => 2, + :pong => 3, + :text => 4, + :binary => 5 + } + FRAME_TYPES_INVERSE = FRAME_TYPES.invert + # Frames are either data frames or control frames + DATA_FRAMES = [:text, :binary, :continuation] + + def type_to_opcode(frame_type) + FRAME_TYPES[frame_type] || raise("Unknown frame type") + end + + def opcode_to_type(opcode) + FRAME_TYPES_INVERSE[opcode] || raise(WSProtocolError, "Unknown opcode #{opcode}") + end + + def data_frame?(type) + DATA_FRAMES.include?(type) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing07.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing07.rb new file mode 100644 index 0000000..58318e4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing07.rb @@ -0,0 +1,185 @@ +# encoding: BINARY + +module EventMachine + module WebSocket + module Framing07 + + def initialize_framing + @data = MaskedString.new + @application_data_buffer = '' # Used for MORE frames + @frame_type = nil + end + + def process_data + error = false + + while !error && @data.size >= 2 + pointer = 0 + + fin = (@data.getbyte(pointer) & 0b10000000) == 0b10000000 + # Ignoring rsv1-3 for now + opcode = @data.getbyte(pointer) & 0b00001111 + pointer += 1 + + mask = (@data.getbyte(pointer) & 0b10000000) == 0b10000000 + length = @data.getbyte(pointer) & 0b01111111 + pointer += 1 + + # raise WebSocketError, 'Data from client must be masked' unless mask + + payload_length = case length + when 127 # Length defined by 8 bytes + # Check buffer size + if @data.getbyte(pointer+8-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + # Only using the last 4 bytes for now, till I work out how to + # unpack 8 bytes. I'm sure 4GB frames will do for now :) + l = @data.getbytes(pointer+4, 4).unpack('N').first + pointer += 8 + l + when 126 # Length defined by 2 bytes + # Check buffer size + if @data.getbyte(pointer+2-1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + l = @data.getbytes(pointer, 2).unpack('n').first + pointer += 2 + l + else + length + end + + # Compute the expected frame length + frame_length = pointer + payload_length + frame_length += 4 if mask + + if frame_length > @connection.max_frame_size + raise WSMessageTooBigError, "Frame length too long (#{frame_length} bytes)" + end + + # Check buffer size + if @data.getbyte(frame_length - 1) == nil + debug [:buffer_incomplete, @data] + error = true + next + end + + # Remove frame header + @data.slice!(0...pointer) + pointer = 0 + + # Read application data (unmasked if required) + @data.read_mask if mask + pointer += 4 if mask + application_data = @data.getbytes(pointer, payload_length) + pointer += payload_length + @data.unset_mask if mask + + # Throw away data up to pointer + @data.slice!(0...pointer) + + frame_type = opcode_to_type(opcode) + + if frame_type == :continuation + if !@frame_type + raise WSProtocolError, 'Continuation frame not expected' + end + else # Not a continuation frame + if @frame_type && data_frame?(frame_type) + raise WSProtocolError, "Continuation frame expected" + end + end + + # Validate that control frames are not fragmented + if !fin && !data_frame?(frame_type) + raise WSProtocolError, 'Control frames must not be fragmented' + end + + if !fin + debug [:moreframe, frame_type, application_data] + @application_data_buffer << application_data + # The message type is passed in the first frame + @frame_type ||= frame_type + else + # Message is complete + if frame_type == :continuation + @application_data_buffer << application_data + message(@frame_type, '', @application_data_buffer) + @application_data_buffer = '' + @frame_type = nil + else + message(frame_type, '', application_data) + end + end + end # end while + end + + def send_frame(frame_type, application_data) + debug [:sending_frame, frame_type, application_data] + + if @state == :closing && data_frame?(frame_type) + raise WebSocketError, "Cannot send data frame since connection is closing" + end + + frame = '' + + opcode = type_to_opcode(frame_type) + byte1 = opcode | 0b10000000 # fin bit set, rsv1-3 are 0 + frame << byte1 + + length = application_data.size + if length <= 125 + byte2 = length # since rsv4 is 0 + frame << byte2 + elsif length < 65536 # write 2 byte length + frame << 126 + frame << [length].pack('n') + else # write 8 byte length + frame << 127 + frame << [length >> 32, length & 0xFFFFFFFF].pack("NN") + end + + frame << application_data + + @connection.send_data(frame) + end + + def send_text_frame(data) + send_frame(:text, data) + end + + private + + FRAME_TYPES = { + :continuation => 0, + :text => 1, + :binary => 2, + :close => 8, + :ping => 9, + :pong => 10, + } + FRAME_TYPES_INVERSE = FRAME_TYPES.invert + # Frames are either data frames or control frames + DATA_FRAMES = [:text, :binary, :continuation] + + def type_to_opcode(frame_type) + FRAME_TYPES[frame_type] || raise("Unknown frame type") + end + + def opcode_to_type(opcode) + FRAME_TYPES_INVERSE[opcode] || raise(WSProtocolError, "Unknown opcode #{opcode}") + end + + def data_frame?(type) + DATA_FRAMES.include?(type) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing76.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing76.rb new file mode 100644 index 0000000..55982ff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/framing76.rb @@ -0,0 +1,105 @@ +# encoding: BINARY + +module EventMachine + module WebSocket + module Framing76 + def initialize_framing + @data = '' + end + + def process_data + debug [:message, @data] + + # This algorithm comes straight from the spec + # http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76#section-5.3 + + error = false + + while !error + return if @data.size == 0 + + pointer = 0 + frame_type = @data.getbyte(pointer) + pointer += 1 + + if (frame_type & 0x80) == 0x80 + # If the high-order bit of the /frame type/ byte is set + length = 0 + + loop do + return false if !@data.getbyte(pointer) + b = @data.getbyte(pointer) + pointer += 1 + b_v = b & 0x7F + length = length * 128 + b_v + break unless (b & 0x80) == 0x80 + end + + if length > @connection.max_frame_size + raise WSMessageTooBigError, "Frame length too long (#{length} bytes)" + end + + if @data.getbyte(pointer+length-1) == nil + debug [:buffer_incomplete, @data] + # Incomplete data - leave @data to accumulate + error = true + else + # Straight from spec - I'm sure this isn't crazy... + # 6. Read /length/ bytes. + # 7. Discard the read bytes. + @data = @data[(pointer+length)..-1] + + # If the /frame type/ is 0xFF and the /length/ was 0, then close + if length == 0 + @connection.send_data("\xff\x00") + @state = :closing + @connection.close_connection_after_writing + else + error = true + end + end + else + # If the high-order bit of the /frame type/ byte is _not_ set + + if @data.getbyte(0) != 0x00 + # Close the connection since this buffer can never match + raise WSProtocolError, "Invalid frame received" + end + + # Addition to the spec to protect against malicious requests + if @data.size > @connection.max_frame_size + raise WSMessageTooBigError, "Frame length too long (#{@data.size} bytes)" + end + + msg = @data.slice!(/\A\x00[^\xff]*\xff/) + if msg + msg.gsub!(/\A\x00|\xff\z/, '') + if @state == :closing + debug [:ignored_message, msg] + else + msg.force_encoding('UTF-8') if msg.respond_to?(:force_encoding) + @connection.trigger_on_message(msg) + end + else + error = true + end + end + end + + false + end + + # frames need to start with 0x00-0x7f byte and end with + # an 0xFF byte. Per spec, we can also set the first + # byte to a value betweent 0x80 and 0xFF, followed by + # a leading length indicator + def send_text_frame(data) + debug [:sending_text_frame, data] + ary = ["\x00", data, "\xff"] + ary.collect{ |s| s.force_encoding('UTF-8') if s.respond_to?(:force_encoding) } + @connection.send_data(ary.join) + end + + end + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler.rb new file mode 100644 index 0000000..98cdd4e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler.rb @@ -0,0 +1,97 @@ +module EventMachine + module WebSocket + class Handler + def self.klass_factory(version) + case version + when 75 + Handler75 + when 76 + Handler76 + when 1..3 + # We'll use handler03 - I believe they're all compatible + Handler03 + when 5 + Handler05 + when 6 + Handler06 + when 7 + Handler07 + when 8 + # drafts 9, 10, 11 and 12 should never change the version + # number as they are all the same as version 08. + Handler08 + when 13 + # drafts 13 to 17 all identify as version 13 as they are + # only minor changes or text changes. + Handler13 + else + # According to spec should abort the connection + raise HandshakeError, "Protocol version #{version} not supported" + end + end + + include Debugger + + attr_reader :request, :state + + def initialize(connection, debug = false) + @connection = connection + @debug = debug + @state = :connected + @close_timer = nil + initialize_framing + end + + def receive_data(data) + @data << data + process_data + rescue WSProtocolError => e + fail_websocket(e) + end + + def close_websocket(code, body) + # Implemented in subclass + end + + # Used to avoid un-acked and unclosed remaining open indefinitely + def start_close_timeout + @close_timer = EM::Timer.new(@connection.close_timeout) { + @connection.close_connection + e = WSProtocolError.new("Close handshake un-acked after #{@connection.close_timeout}s, closing tcp connection") + @connection.trigger_on_error(e) + } + end + + # This corresponds to "Fail the WebSocket Connection" in the spec. + def fail_websocket(e) + debug [:error, e] + close_websocket(e.code, e.message) + @connection.close_connection_after_writing + @connection.trigger_on_error(e) + end + + def unbind + @state = :closed + + @close_timer.cancel if @close_timer + + @close_info = defined?(@close_info) ? @close_info : { + :code => 1006, + :was_clean => false, + } + + @connection.trigger_on_close(@close_info) + end + + def ping + # Overridden in subclass + false + end + + def pingable? + # Also Overridden + false + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler03.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler03.rb new file mode 100644 index 0000000..ac4b3ac --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler03.rb @@ -0,0 +1,9 @@ +module EventMachine + module WebSocket + class Handler03 < Handler + include Framing03 + include MessageProcessor03 + include Close03 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler05.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler05.rb new file mode 100644 index 0000000..4e48e15 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler05.rb @@ -0,0 +1,9 @@ +module EventMachine + module WebSocket + class Handler05 < Handler + include Framing05 + include MessageProcessor03 + include Close05 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler06.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler06.rb new file mode 100644 index 0000000..ad55ef7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler06.rb @@ -0,0 +1,9 @@ +module EventMachine + module WebSocket + class Handler06 < Handler + include Framing05 + include MessageProcessor06 + include Close06 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler07.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler07.rb new file mode 100644 index 0000000..d080cf5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler07.rb @@ -0,0 +1,9 @@ +module EventMachine + module WebSocket + class Handler07 < Handler + include Framing07 + include MessageProcessor06 + include Close06 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler08.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler08.rb new file mode 100644 index 0000000..632057f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler08.rb @@ -0,0 +1,9 @@ +module EventMachine + module WebSocket + class Handler08 < Handler + include Framing07 + include MessageProcessor06 + include Close06 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler13.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler13.rb new file mode 100644 index 0000000..1dc465d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler13.rb @@ -0,0 +1,9 @@ +module EventMachine + module WebSocket + class Handler13 < Handler + include Framing07 + include MessageProcessor06 + include Close06 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler75.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler75.rb new file mode 100644 index 0000000..d9a90d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler75.rb @@ -0,0 +1,9 @@ +module EventMachine + module WebSocket + class Handler75 < Handler + include Handshake75 + include Framing76 + include Close75 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler76.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler76.rb new file mode 100644 index 0000000..c4aaa37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handler76.rb @@ -0,0 +1,14 @@ +# encoding: BINARY + +module EventMachine + module WebSocket + class Handler76 < Handler + include Handshake76 + include Framing76 + include Close75 + + # "\377\000" is octet version and "\xff\x00" is hex version + TERMINATE_STRING = "\xff\x00" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake.rb new file mode 100644 index 0000000..12b7904 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake.rb @@ -0,0 +1,156 @@ +require "http/parser" +require "uri" + +module EventMachine + module WebSocket + + # Resposible for creating the server handshake response + class Handshake + include EM::Deferrable + + attr_reader :parser, :protocol_version + + # Unfortunately drafts 75 & 76 require knowledge of whether the + # connection is being terminated as ws/wss in order to generate the + # correct handshake response + def initialize(secure) + @parser = Http::Parser.new + @secure = secure + + @parser.on_headers_complete = proc { |headers| + @headers = Hash[headers.map { |k,v| [k.downcase, v] }] + } + end + + def receive_data(data) + @parser << data + + if defined? @headers + process(@headers, @parser.upgrade_data) + end + rescue HTTP::Parser::Error => e + fail(HandshakeError.new("Invalid HTTP header: #{e.message}")) + end + + # Returns the WebSocket upgrade headers as a hash. + # + # Keys are strings, unmodified from the request. + # + def headers + @parser.headers + end + + # The same as headers, except that the hash keys are downcased + # + def headers_downcased + @headers + end + + # Returns the request path (excluding any query params) + # + def path + @path + end + + # Returns the query params as a string foo=bar&baz=... + def query_string + @query_string + end + + def query + Hash[query_string.split('&').map { |c| c.split('=', 2) }] + end + + # Returns the WebSocket origin header if provided + # + def origin + @headers["origin"] || @headers["sec-websocket-origin"] || nil + end + + def secure? + @secure + end + + private + + def process(headers, remains) + unless @parser.http_method == "GET" + raise HandshakeError, "Must be GET request" + end + + # Validate request path + # + # According to http://tools.ietf.org/search/rfc2616#section-5.1.2, an + # invalid Request-URI should result in a 400 status code, but + # HandshakeError's currently result in a WebSocket abort. It's not + # clear which should take precedence, but an abort will do just fine. + begin + uri = URI.parse(@parser.request_url) + @path = uri.path + @query_string = uri.query || "" + rescue URI::InvalidURIError + raise HandshakeError, "Invalid request URI: #{@parser.request_url}" + end + + # Validate Upgrade + unless @parser.upgrade? + raise HandshakeError, "Not an upgrade request" + end + upgrade = @headers['upgrade'] + unless upgrade.kind_of?(String) && upgrade.downcase == 'websocket' + raise HandshakeError, "Invalid upgrade header: #{upgrade.inspect}" + end + + # Determine version heuristically + version = if @headers['sec-websocket-version'] + # Used from drafts 04 onwards + @headers['sec-websocket-version'].to_i + elsif @headers['sec-websocket-draft'] + # Used in drafts 01 - 03 + @headers['sec-websocket-draft'].to_i + elsif @headers['sec-websocket-key1'] + 76 + else + 75 + end + + # Additional handling of bytes after the header if required + case version + when 75 + if !remains.empty? + raise HandshakeError, "Extra bytes after header" + end + when 76, 1..3 + if remains.length < 8 + # The whole third-key has not been received yet. + return nil + elsif remains.length > 8 + raise HandshakeError, "Extra bytes after third key" + end + @headers['third-key'] = remains + end + + handshake_klass = case version + when 75 + Handshake75 + when 76, 1..3 + Handshake76 + when 5, 6, 7, 8, 13 + Handshake04 + else + # According to spec should abort the connection + raise HandshakeError, "Protocol version #{version} not supported" + end + + upgrade_response = handshake_klass.handshake(@headers, @parser.request_url, @secure) + + handler_klass = Handler.klass_factory(version) + + @protocol_version = version + succeed(upgrade_response, handler_klass) + rescue HandshakeError => e + fail(e) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake04.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake04.rb new file mode 100644 index 0000000..7600787 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake04.rb @@ -0,0 +1,37 @@ +require 'digest/sha1' +require 'base64' + +module EventMachine + module WebSocket + module Handshake04 + def self.handshake(headers, _, __) + # Required + unless key = headers['sec-websocket-key'] + raise HandshakeError, "sec-websocket-key header is required" + end + + string_to_sign = "#{key}258EAFA5-E914-47DA-95CA-C5AB0DC85B11" + signature = Base64.encode64(Digest::SHA1.digest(string_to_sign)).chomp + + upgrade = ["HTTP/1.1 101 Switching Protocols"] + upgrade << "Upgrade: websocket" + upgrade << "Connection: Upgrade" + upgrade << "Sec-WebSocket-Accept: #{signature}" + if protocol = headers['sec-websocket-protocol'] + validate_protocol!(protocol) + upgrade << "Sec-WebSocket-Protocol: #{protocol}" + end + + # TODO: Support sec-websocket-protocol selection + # TODO: sec-websocket-extensions + + return upgrade.join("\r\n") + "\r\n\r\n" + end + + def self.validate_protocol!(protocol) + raise HandshakeError, "Invalid WebSocket-Protocol: empty" if protocol.empty? + # TODO: Validate characters + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake75.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake75.rb new file mode 100644 index 0000000..65b744f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake75.rb @@ -0,0 +1,28 @@ +module EventMachine + module WebSocket + module Handshake75 + def self.handshake(headers, path, secure) + scheme = (secure ? "wss" : "ws") + location = "#{scheme}://#{headers['host']}#{path}" + + upgrade = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" + upgrade << "Upgrade: WebSocket\r\n" + upgrade << "Connection: Upgrade\r\n" + upgrade << "WebSocket-Origin: #{headers['origin']}\r\n" + upgrade << "WebSocket-Location: #{location}\r\n" + if protocol = headers['sec-websocket-protocol'] + validate_protocol!(protocol) + upgrade << "Sec-WebSocket-Protocol: #{protocol}\r\n" + end + upgrade << "\r\n" + + return upgrade + end + + def self.validate_protocol!(protocol) + raise HandshakeError, "Invalid WebSocket-Protocol: empty" if protocol.empty? + # TODO: Validate characters + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake76.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake76.rb new file mode 100644 index 0000000..c18260d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/handshake76.rb @@ -0,0 +1,72 @@ +require 'digest/md5' + +module EventMachine::WebSocket + module Handshake76 + class << self + def handshake(headers, path, secure) + challenge_response = solve_challenge( + headers['sec-websocket-key1'], + headers['sec-websocket-key2'], + headers['third-key'] + ) + + scheme = (secure ? "wss" : "ws") + location = "#{scheme}://#{headers['host']}#{path}" + + upgrade = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" + upgrade << "Upgrade: WebSocket\r\n" + upgrade << "Connection: Upgrade\r\n" + upgrade << "Sec-WebSocket-Location: #{location}\r\n" + upgrade << "Sec-WebSocket-Origin: #{headers['origin']}\r\n" + if protocol = headers['sec-websocket-protocol'] + validate_protocol!(protocol) + upgrade << "Sec-WebSocket-Protocol: #{protocol}\r\n" + end + upgrade << "\r\n" + upgrade << challenge_response + + return upgrade + end + + private + + def solve_challenge(first, second, third) + # Refer to 5.2 4-9 of the draft 76 + sum = [numbers_over_spaces(first)].pack("N*") + + [numbers_over_spaces(second)].pack("N*") + + third + Digest::MD5.digest(sum) + end + + def numbers_over_spaces(string) + unless string + raise HandshakeError, "WebSocket key1 or key2 is missing" + end + + numbers = string.scan(/[0-9]/).join.to_i + + spaces = string.scan(/ /).size + # As per 5.2.5, abort the connection if spaces are zero. + raise HandshakeError, "Websocket Key1 or Key2 does not contain spaces - this is a symptom of a cross-protocol attack" if spaces == 0 + + # As per 5.2.6, abort if numbers is not an integral multiple of spaces + if numbers % spaces != 0 + raise HandshakeError, "Invalid Key #{string.inspect}" + end + + quotient = numbers / spaces + + if quotient > 2**32-1 + raise HandshakeError, "Challenge computation out of range for key #{string.inspect}" + end + + return quotient + end + + def validate_protocol!(protocol) + raise HandshakeError, "Invalid WebSocket-Protocol: empty" if protocol.empty? + # TODO: Validate characters + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/masking04.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/masking04.rb new file mode 100644 index 0000000..ad050e9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/masking04.rb @@ -0,0 +1,37 @@ +module EventMachine + module WebSocket + class MaskedString < String + # Read a 4 bit XOR mask - further requested bytes will be unmasked + def read_mask + if respond_to?(:encoding) && encoding.name != "ASCII-8BIT" + raise "MaskedString only operates on BINARY strings" + end + raise "Too short" if bytesize < 4 # TODO - change + @masking_key = String.new(self[0..3]) + end + + # Removes the mask, behaves like a normal string again + def unset_mask + @masking_key = nil + end + + def getbyte(index) + if defined?(@masking_key) && @masking_key + masked_char = super + masked_char ? masked_char ^ @masking_key.getbyte(index % 4) : nil + else + super + end + end + + def getbytes(start_index, count) + data = '' + data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding) + count.times do |i| + data << getbyte(start_index + i) + end + data + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/message_processor_03.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/message_processor_03.rb new file mode 100644 index 0000000..c5dec70 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/message_processor_03.rb @@ -0,0 +1,47 @@ +# encoding: BINARY + +module EventMachine + module WebSocket + module MessageProcessor03 + def message(message_type, extension_data, application_data) + case message_type + when :close + @close_info = { + :code => 1005, + :reason => "", + :was_clean => true, + } + if @state == :closing + # TODO: Check that message body matches sent data + # We can close connection immediately since there is no more data + # is allowed to be sent or received on this connection + @connection.close_connection + else + # Acknowlege close + # The connection is considered closed + send_frame(:close, application_data) + @connection.close_connection_after_writing + end + when :ping + # Pong back the same data + send_frame(:pong, application_data) + @connection.trigger_on_ping(application_data) + when :pong + @connection.trigger_on_pong(application_data) + when :text + if application_data.respond_to?(:force_encoding) + application_data.force_encoding("UTF-8") + end + @connection.trigger_on_message(application_data) + when :binary + @connection.trigger_on_binary(application_data) + end + end + + # Ping & Pong supported + def pingable? + true + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/message_processor_06.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/message_processor_06.rb new file mode 100644 index 0000000..25ca5d2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/message_processor_06.rb @@ -0,0 +1,78 @@ +module EventMachine + module WebSocket + module MessageProcessor06 + def message(message_type, extension_data, application_data) + debug [:message_received, message_type, application_data] + + case message_type + when :close + status_code = case application_data.length + when 0 + # close messages MAY contain a body + nil + when 1 + # Illegal close frame + raise WSProtocolError, "Close frames with a body must contain a 2 byte status code" + else + application_data.slice!(0, 2).unpack('n').first + end + + debug [:close_frame_received, status_code, application_data] + + @close_info = { + :code => status_code || 1005, + :reason => application_data, + :was_clean => true, + } + + if @state == :closing + # We can close connection immediately since no more data may be + # sent or received on this connection + @connection.close_connection + elsif @state == :connected + # Acknowlege close & echo status back to client + # The connection is considered closed + close_data = [status_code || 1000].pack('n') + send_frame(:close, close_data) + @connection.close_connection_after_writing + end + when :ping + # There are a couple of protections here against malicious/broken WebSocket abusing ping frames. + # + # 1. Delay 200ms before replying. This reduces the number of pings from WebSocket clients behaving as + # `for (;;) { send_ping(conn); rcv_pong(conn); }`. The spec says we "SHOULD respond with Pong frame as soon + # as is practical". + # 2. Reply at most every 200ms. This reduces the number of pong frames sent to WebSocket clients behaving as + # `for (;;) { send_ping(conn); }`. The spec says "If an endpoint receives a Ping frame and has not yet sent + # Pong frame(s) in response to previous Ping frame(s), the endpoint MAY elect to send a Pong frame for only + # the most recently processed Ping frame." + @most_recent_pong_application_data = application_data + if @pong_timer == nil then + @pong_timer = EventMachine.add_timer(0.2) do + @pong_timer = nil + send_frame(:pong, @most_recent_pong_application_data) + end + end + @connection.trigger_on_ping(application_data) + when :pong + @connection.trigger_on_pong(application_data) + when :text + if application_data.respond_to?(:force_encoding) + application_data.force_encoding("UTF-8") + unless application_data.valid_encoding? + raise InvalidDataError, "Invalid UTF8 data" + end + end + @connection.trigger_on_message(application_data) + when :binary + @connection.trigger_on_binary(application_data) + end + end + + # Ping & Pong supported + def pingable? + true + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/version.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/version.rb new file mode 100644 index 0000000..ecdedbe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/version.rb @@ -0,0 +1,5 @@ +module EventMachine + module Websocket + VERSION = "0.5.3" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/websocket.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/websocket.rb new file mode 100644 index 0000000..02e4d86 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/lib/em-websocket/websocket.rb @@ -0,0 +1,56 @@ +module EventMachine + module WebSocket + class << self + attr_accessor :max_frame_size + attr_accessor :close_timeout + end + @max_frame_size = 10 * 1024 * 1024 # 10MB + # Connections are given 60s to close after being sent a close handshake + @close_timeout = 60 + + # All errors raised by em-websocket should descend from this class + class WebSocketError < RuntimeError; end + + # Used for errors that occur during WebSocket handshake + class HandshakeError < WebSocketError; end + + # Used for errors which should cause the connection to close. + # See RFC6455 §7.4.1 for a full description of meanings + class WSProtocolError < WebSocketError + def code; 1002; end + end + + class InvalidDataError < WSProtocolError + def code; 1007; end + end + + # 1009: Message too big to process + class WSMessageTooBigError < WSProtocolError + def code; 1009; end + end + + # Start WebSocket server, including starting eventmachine run loop + def self.start(options, &blk) + EM.epoll + EM.run { + trap("TERM") { stop } + trap("INT") { stop } + + run(options, &blk) + } + end + + # Start WebSocket server inside eventmachine run loop + def self.run(options) + host, port = options.values_at(:host, :port) + EM.start_server(host, port, Connection, options) do |c| + yield c + end + end + + def self.stop + puts "Terminating WebSocket Server" + EM.stop + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/helper.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/helper.rb new file mode 100644 index 0000000..76e45b5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/helper.rb @@ -0,0 +1,173 @@ +# encoding: BINARY + +require 'rubygems' +require 'rspec' +require 'em-spec/rspec' +require 'em-http' + +require 'em-websocket' +require 'em-websocket-client' + +require 'integration/shared_examples' +require 'integration/gte_03_examples' + +RSpec.configure do |c| + c.mock_with :rspec +end + +class FakeWebSocketClient < EM::Connection + attr_reader :handshake_response, :packets + + def onopen(&blk); @onopen = blk; end + def onclose(&blk); @onclose = blk; end + def onerror(&blk); @onerror = blk; end + def onmessage(&blk); @onmessage = blk; end + + def initialize + @state = :new + @packets = [] + end + + def receive_data(data) + # puts "RECEIVE DATA #{data}" + if @state == :new + @handshake_response = data + @onopen.call if defined? @onopen + @state = :open + else + @onmessage.call(data) if defined? @onmessage + @packets << data + end + end + + def send(application_data) + send_frame(:text, application_data) + end + + def send_frame(type, application_data) + send_data construct_frame(type, application_data) + end + + def unbind + @onclose.call if defined? @onclose + end + + private + + def construct_frame(type, data) + "\x00#{data}\xff" + end +end + +class Draft03FakeWebSocketClient < FakeWebSocketClient + private + + def construct_frame(type, data) + frame = "" + frame << EM::WebSocket::Framing03::FRAME_TYPES[type] + frame << encoded_length(data.size) + frame << data + end + + def encoded_length(length) + if length <= 125 + [length].pack('C') # since rsv4 is 0 + elsif length < 65536 # write 2 byte length + "\126#{[length].pack('n')}" + else # write 8 byte length + "\127#{[length >> 32, length & 0xFFFFFFFF].pack("NN")}" + end + end +end + +class Draft05FakeWebSocketClient < Draft03FakeWebSocketClient + private + + def construct_frame(type, data) + frame = "" + frame << "\x00\x00\x00\x00" # Mask with nothing for simplicity + frame << (EM::WebSocket::Framing05::FRAME_TYPES[type] | 0b10000000) + frame << encoded_length(data.size) + frame << data + end +end + +class Draft07FakeWebSocketClient < Draft05FakeWebSocketClient + private + + def construct_frame(type, data) + frame = "" + frame << (EM::WebSocket::Framing07::FRAME_TYPES[type] | 0b10000000) + # Should probably mask the data, but I get away without bothering since + # the server doesn't enforce that incoming frames are masked + frame << encoded_length(data.size) + frame << data + end +end + +# Wrapper around em-websocket-client +class Draft75WebSocketClient + def onopen(&blk); @onopen = blk; end + def onclose(&blk); @onclose = blk; end + def onerror(&blk); @onerror = blk; end + def onmessage(&blk); @onmessage = blk; end + + def initialize + @ws = EventMachine::WebSocketClient.connect('ws://127.0.0.1:12345/', + :version => 75, + :origin => 'http://example.com') + @ws.errback { |err| @onerror.call if defined? @onerror } + @ws.callback { @onopen.call if defined? @onopen } + @ws.stream { |msg| @onmessage.call(msg) if defined? @onmessage } + @ws.disconnect { @onclose.call if defined? @onclose } + end + + def send(message) + @ws.send_msg(message) + end + + def close_connection + @ws.close_connection + end +end + +def start_server(opts = {}) + EM::WebSocket.run({:host => "0.0.0.0", :port => 12345}.merge(opts)) { |ws| + yield ws if block_given? + } +end + +def format_request(r) + data = "#{r[:method]} #{r[:path]} HTTP/1.1\r\n" + header_lines = r[:headers].map { |k,v| "#{k}: #{v}" } + data << [header_lines, '', r[:body]].join("\r\n") + data +end + +def format_response(r) + data = r[:protocol] || "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" + header_lines = r[:headers].map { |k,v| "#{k}: #{v}" } + data << [header_lines, '', r[:body]].join("\r\n") + data +end + +RSpec::Matchers.define :succeed_with_upgrade do |response| + match do |actual| + success = nil + actual.callback { |upgrade_response, handler_klass| + success = (upgrade_response.lines.sort == format_response(response).lines.sort) + } + success + end +end + +RSpec::Matchers.define :fail_with_error do |error_klass, error_message| + match do |actual| + success = nil + actual.errback { |e| + success = (e.class == error_klass) + success &= (e.message == error_message) if error_message + } + success + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/common_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/common_spec.rb new file mode 100644 index 0000000..c89f871 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/common_spec.rb @@ -0,0 +1,138 @@ +require 'helper' + +# These tests are not specific to any particular draft of the specification +# +describe "WebSocket server" do + include EM::SpecHelper + default_timeout 1 + + it "should fail on non WebSocket requests" do + em { + EM.add_timer(0.1) do + http = EM::HttpRequest.new('http://127.0.0.1:12345/').get :timeout => 0 + http.errback { done } + http.callback { fail } + end + + start_server + } + end + + it "should expose the WebSocket request headers, path and query params" do + em { + EM.add_timer(0.1) do + ws = EventMachine::WebSocketClient.connect('ws://127.0.0.1:12345/', + :origin => 'http://example.com') + ws.errback { fail } + ws.callback { ws.close_connection } + ws.stream { |msg| } + end + + start_server do |ws| + ws.onopen { |handshake| + headers = handshake.headers + headers["Connection"].should == "Upgrade" + headers["Upgrade"].should == "websocket" + headers["Host"].to_s.should == "127.0.0.1:12345" + handshake.path.should == "/" + handshake.query.should == {} + handshake.origin.should == 'http://example.com' + } + ws.onclose { + ws.state.should == :closed + done + } + end + } + end + + it "should expose the WebSocket path and query params when nonempty" do + em { + EM.add_timer(0.1) do + ws = EventMachine::WebSocketClient.connect('ws://127.0.0.1:12345/hello?foo=bar&baz=qux') + ws.errback { fail } + ws.callback { + ws.close_connection + } + ws.stream { |msg| } + end + + start_server do |ws| + ws.onopen { |handshake| + handshake.path.should == '/hello' + handshake.query_string.split('&').sort. + should == ["baz=qux", "foo=bar"] + handshake.query.should == {"foo"=>"bar", "baz"=>"qux"} + } + ws.onclose { + ws.state.should == :closed + done + } + end + } + end + + it "should raise an exception if frame sent before handshake complete" do + em { + # 1. Start WebSocket server + start_server { |ws| + # 3. Try to send a message to the socket + lambda { + ws.send('early message') + }.should raise_error('Cannot send data before onopen callback') + done + } + + # 2. Connect a dumb TCP connection (will not send handshake) + EM.connect('0.0.0.0', 12345, EM::Connection) + } + end + + it "should allow the server to be started inside an existing EM" do + em { + EM.add_timer(0.1) do + http = EM::HttpRequest.new('http://127.0.0.1:12345/').get :timeout => 0 + http.errback { |e| done } + http.callback { fail } + end + + start_server do |ws| + ws.onopen { |handshake| + headers = handshake.headers + headers["Host"].to_s.should == "127.0.0.1:12345" + } + ws.onclose { + ws.state.should == :closed + done + } + end + } + end + + context "outbound limit set" do + it "should close the connection if the limit is reached" do + em { + start_server(:outbound_limit => 150) do |ws| + # Increase the message size by one on each loop + ws.onmessage{|msg| ws.send(msg + "x") } + ws.onclose{|status| + status[:code].should == 1006 # Unclean + status[:was_clean].should be false + } + end + + EM.add_timer(0.1) do + ws = EventMachine::WebSocketClient.connect('ws://127.0.0.1:12345/') + ws.callback { ws.send_msg "hello" } + ws.disconnect { done } # Server closed the connection + ws.stream { |msg| + # minus frame size ? (getting 146 max here) + msg.data.size.should <= 150 + # Return back the message + ws.send_msg(msg.data) + } + end + } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft03_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft03_spec.rb new file mode 100644 index 0000000..f299ab6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft03_spec.rb @@ -0,0 +1,298 @@ +require 'helper' + +describe "draft03" do + include EM::SpecHelper + default_timeout 1 + + before :each do + @request = { + :port => 80, + :method => "GET", + :path => "/demo", + :headers => { + 'Host' => 'example.com', + 'Connection' => 'Upgrade', + 'Sec-WebSocket-Key2' => '12998 5 Y3 1 .P00', + 'Sec-WebSocket-Protocol' => 'sample', + 'Upgrade' => 'WebSocket', + 'Sec-WebSocket-Key1' => '4 @1 46546xW%0l 1 5', + 'Origin' => 'http://example.com', + 'Sec-WebSocket-Draft' => '3' + }, + :body => '^n:ds[4U' + } + + @response = { + :headers => { + "Upgrade" => "WebSocket", + "Connection" => "Upgrade", + "Sec-WebSocket-Location" => "ws://example.com/demo", + "Sec-WebSocket-Origin" => "http://example.com", + "Sec-WebSocket-Protocol" => "sample" + }, + :body => "8jKS\'y:G*Co,Wxa-" + } + end + + def start_client + client = EM.connect('0.0.0.0', 12345, Draft03FakeWebSocketClient) + client.send_data(format_request(@request)) + yield client if block_given? + return client + end + + it_behaves_like "a websocket server" do + let(:version) { 3 } + end + + it_behaves_like "a WebSocket server drafts 3 and above" do + let(:version) { 3 } + end + + # These examples are straight from the spec + # http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-03#section-4.6 + describe "examples from the spec" do + it "should accept a single-frame text message" do + em { + start_server { |ws| + ws.onmessage { |msg| + msg.should == 'Hello' + done + } + } + start_client { |client| + client.onopen { + client.send_data("\x04\x05Hello") + } + } + } + end + + it "should accept a fragmented text message" do + em { + start_server { |ws| + ws.onmessage { |msg| + msg.should == 'Hello' + done + } + } + + connection = start_client + + # Send frame + connection.onopen { + connection.send_data("\x84\x03Hel") + connection.send_data("\x00\x02lo") + } + } + end + + it "should accept a ping request and respond with the same body" do + em { + start_server + + connection = start_client + + # Send frame + connection.onopen { + connection.send_data("\x02\x05Hello") + } + + connection.onmessage { |frame| + next if frame.nil? + frame.should == "\x03\x05Hello" + done + } + } + end + + it "should accept a 256 bytes binary message in a single frame" do + em { + data = "a" * 256 + + start_server { |ws| + ws.onbinary { |msg| + msg.encoding.should == Encoding.find("BINARY") if defined?(Encoding) + msg.should == data + done + } + } + + connection = start_client + + # Send frame + connection.onopen { + connection.send_data("\x05\x7E\x01\x00" + data) + } + } + end + + it "should accept a 64KiB binary message in a single frame" do + em { + data = "a" * 65536 + + start_server { |ws| + ws.onbinary { |msg| + msg.encoding.should == Encoding.find("BINARY") if defined?(Encoding) + msg.should == data + done + } + } + + connection = start_client + + # Send frame + connection.onopen { + connection.send_data("\x05\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + data) + } + } + end + end + + describe "close handling" do + it "should respond to a new close frame with a close frame" do + em { + start_server + + connection = start_client + + # Send close frame + connection.onopen { + connection.send_data("\x01\x00") + } + + # Check that close ack received + connection.onmessage { |frame| + frame.should == "\x01\x00" + done + } + } + end + + it "should close the connection on receiving a close acknowlegement and call onclose with close code 1005 and was_clean=true (initiated by server)" do + em { + ack_received = false + + start_server { |ws| + ws.onopen { + # 2. Send a close frame + EM.next_tick { + ws.close + } + } + + # 5. Onclose event on server + ws.onclose { |event| + event.should == { + :code => 1005, + :reason => "", + :was_clean => true, + } + done + } + } + + # 1. Create a fake client which sends draft 76 handshake + connection = start_client + + # 3. Check that close frame recieved and acknowlege it + connection.onmessage { |frame| + frame.should == "\x01\x00" + ack_received = true + connection.send_data("\x01\x00") + } + + # 4. Check that connection is closed _after_ the ack + connection.onclose { + ack_received.should == true + } + } + end + + # it "should repur" + # + it "should return close code 1005 and was_clean=true after closing handshake (initiated by client)" do + em { + start_server { |ws| + ws.onclose { |event| + event.should == { + :code => 1005, + :reason => "", + :was_clean => true, + } + done + } + } + start_client { |client| + client.onopen { + client.send_data("\x01\x00") + } + } + } + end + + it "should not allow data frame to be sent after close frame sent" do + em { + start_server { |ws| + ws.onopen { + # 2. Send a close frame + EM.next_tick { + ws.close + } + + # 3. Check that exception raised if I attempt to send more data + EM.add_timer(0.1) { + lambda { + ws.send('hello world') + }.should raise_error(EM::WebSocket::WebSocketError, 'Cannot send data frame since connection is closing') + done + } + } + } + + # 1. Create a fake client which sends draft 76 handshake + start_client + } + end + + it "should still respond to control frames after close frame sent" do + em { + start_server { |ws| + ws.onopen { + # 2. Send a close frame + EM.next_tick { + ws.close + } + } + } + + # 1. Create a fake client which sends draft 76 handshake + connection = start_client + + connection.onmessage { |frame| + if frame == "\x01\x00" + # 3. After the close frame is received send a ping frame, but + # don't respond with a close ack + connection.send_data("\x02\x05Hello") + else + # 4. Check that the pong is received + frame.should == "\x03\x05Hello" + done + end + } + } + end + + it "should report that close codes are not supported" do + em { + start_server { |ws| + ws.onopen { + ws.supports_close_codes?.should == false + done + } + } + start_client + } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft05_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft05_spec.rb new file mode 100644 index 0000000..e07ea28 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft05_spec.rb @@ -0,0 +1,50 @@ +require 'helper' + +describe "draft05" do + include EM::SpecHelper + default_timeout 1 + + before :each do + @request = { + :port => 80, + :method => "GET", + :path => "/demo", + :headers => { + 'Host' => 'example.com', + 'Upgrade' => 'websocket', + 'Connection' => 'Upgrade', + 'Sec-WebSocket-Key' => 'dGhlIHNhbXBsZSBub25jZQ==', + 'Sec-WebSocket-Protocol' => 'sample', + 'Sec-WebSocket-Origin' => 'http://example.com', + 'Sec-WebSocket-Version' => '5' + } + } + end + + def start_client + client = EM.connect('0.0.0.0', 12345, Draft05FakeWebSocketClient) + client.send_data(format_request(@request)) + yield client if block_given? + return client + end + + it_behaves_like "a websocket server" do + let(:version) { 5 } + end + + it_behaves_like "a WebSocket server drafts 3 and above" do + let(:version) { 5 } + end + + it "should report that close codes are not supported" do + em { + start_server { |ws| + ws.onopen { + ws.supports_close_codes?.should == false + done + } + } + start_client + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft06_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft06_spec.rb new file mode 100644 index 0000000..ae213cb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft06_spec.rb @@ -0,0 +1,145 @@ +require 'helper' + +describe "draft06" do + include EM::SpecHelper + default_timeout 1 + + before :each do + @request = { + :port => 80, + :method => "GET", + :path => "/demo", + :headers => { + 'Host' => 'example.com', + 'Upgrade' => 'websocket', + 'Connection' => 'Upgrade', + 'Sec-WebSocket-Key' => 'dGhlIHNhbXBsZSBub25jZQ==', + 'Sec-WebSocket-Protocol' => 'sample', + 'Sec-WebSocket-Origin' => 'http://example.com', + 'Sec-WebSocket-Version' => '6' + } + } + + @response = { + :protocol => "HTTP/1.1 101 Switching Protocols\r\n", + :headers => { + "Upgrade" => "websocket", + "Connection" => "Upgrade", + "Sec-WebSocket-Accept" => "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", + "Sec-WebSocket-Protocol" => "sample", + } + } + end + + def start_client + client = EM.connect('0.0.0.0', 12345, Draft05FakeWebSocketClient) + client.send_data(format_request(@request)) + yield client if block_given? + return client + end + + it_behaves_like "a websocket server" do + let(:version) { 6 } + end + + it_behaves_like "a WebSocket server drafts 3 and above" do + let(:version) { 6 } + end + + it "should open connection" do + em { + start_server { |server| + server.onopen { + server.instance_variable_get(:@handler).class.should == EventMachine::WebSocket::Handler06 + } + } + + start_client { |client| + client.onopen { + client.handshake_response.lines.sort. + should == format_response(@response).lines.sort + done + } + } + } + end + + it "should accept a single-frame text message (masked)" do + em { + start_server { |server| + server.onmessage { |msg| + msg.should == 'Hello' + if msg.respond_to?(:encoding) + msg.encoding.should == Encoding.find("UTF-8") + end + done + } + server.onerror { + fail + } + } + + start_client { |client| + client.onopen { + client.send_data("\x00\x00\x01\x00\x84\x05Ielln") + } + } + } + end + + it "should return close code and reason if closed via handshake" do + em { + start_server { |ws| + ws.onclose { |event| + # 2. Receive close event in server + event.should == { + :code => 4004, + :reason => "close reason", + :was_clean => true, + } + done + } + } + start_client { |client| + client.onopen { + # 1: Send close handshake + close_data = [4004].pack('n') + close_data << "close reason" + client.send_frame(:close, close_data) + } + } + } + end + + it "should return close code 1005 if no code was specified" do + em { + start_server { |ws| + ws.onclose { |event| + event.should == { + :code => 1005, + :reason => "", + :was_clean => true, + } + done + } + } + start_client { |client| + client.onopen { + client.send_frame(:close, '') + } + } + } + end + + it "should report that close codes are supported" do + em { + start_server { |ws| + ws.onopen { + ws.supports_close_codes?.should == true + done + } + } + start_client + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft13_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft13_spec.rb new file mode 100644 index 0000000..10dc2a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft13_spec.rb @@ -0,0 +1,105 @@ +# encoding: BINARY + +require 'helper' + +describe "draft13" do + include EM::SpecHelper + default_timeout 1 + + before :each do + @request = { + :port => 80, + :method => "GET", + :path => "/demo", + :headers => { + 'Host' => 'example.com', + 'Upgrade' => 'websocket', + 'Connection' => 'Upgrade', + 'Sec-WebSocket-Key' => 'dGhlIHNhbXBsZSBub25jZQ==', + 'Sec-WebSocket-Protocol' => 'sample', + 'Sec-WebSocket-Origin' => 'http://example.com', + 'Sec-WebSocket-Version' => '13' + } + } + + @response = { + :protocol => "HTTP/1.1 101 Switching Protocols\r\n", + :headers => { + "Upgrade" => "websocket", + "Connection" => "Upgrade", + "Sec-WebSocket-Accept" => "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", + "Sec-WebSocket-Protocol" => "sample", + } + } + end + + def start_client + client = EM.connect('0.0.0.0', 12345, Draft07FakeWebSocketClient) + client.send_data(format_request(@request)) + yield client if block_given? + return client + end + + it_behaves_like "a websocket server" do + let(:version) { 13 } + end + + it_behaves_like "a WebSocket server drafts 3 and above" do + let(:version) { 13 } + end + + it "should send back the correct handshake response" do + em { + start_server + + connection = start_client + + connection.onopen { + connection.handshake_response.lines.sort. + should == format_response(@response).lines.sort + done + } + } + end + + # TODO: This test would be much nicer with a real websocket client... + it "should support sending pings and binding to onpong" do + em { + start_server { |ws| + ws.onopen { + ws.should be_pingable + EM.next_tick { + ws.ping('hello').should == true + } + + } + ws.onpong { |data| + data.should == 'hello' + done + } + } + + connection = start_client + + # Confusing, fake onmessage means any data after the handshake + connection.onmessage { |data| + # This is what a ping looks like + data.should == "\x89\x05hello" + # This is what a pong looks like + connection.send_data("\x8a\x05hello") + } + } + end + + it "should report that close codes are supported" do + em { + start_server { |ws| + ws.onopen { + ws.supports_close_codes?.should == true + done + } + } + start_client + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft75_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft75_spec.rb new file mode 100644 index 0000000..8d9faec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft75_spec.rb @@ -0,0 +1,123 @@ +require 'helper' + +# These integration tests are older and use a different testing style to the +# integration tests for newer drafts. They use EM::HttpRequest which happens +# to currently estabish a websocket connection using the draft75 protocol. +# +describe "WebSocket server draft75" do + include EM::SpecHelper + default_timeout 1 + + def start_client + client = Draft75WebSocketClient.new + yield client if block_given? + return client + end + + it_behaves_like "a websocket server" do + let(:version) { 75 } + end + + it "should automatically complete WebSocket handshake" do + em { + MSG = "Hello World!" + EventMachine.add_timer(0.1) do + ws = EventMachine::WebSocketClient.connect('ws://127.0.0.1:12345/') + ws.errback { fail } + ws.callback { } + + ws.stream { |msg| + msg.data.should == MSG + EventMachine.stop + } + end + + start_server { |ws| + ws.onopen { + ws.send MSG + } + } + } + end + + it "should split multiple messages into separate callbacks" do + em { + messages = %w[1 2] + received = [] + + EventMachine.add_timer(0.1) do + ws = EventMachine::WebSocketClient.connect('ws://127.0.0.1:12345/') + ws.errback { fail } + ws.stream {|msg|} + ws.callback { + ws.send_msg messages[0] + ws.send_msg messages[1] + } + end + + start_server { |ws| + ws.onopen {} + ws.onclose {} + ws.onmessage {|msg| + msg.should == messages[received.size] + received.push msg + + EventMachine.stop if received.size == messages.size + } + } + } + end + + it "should call onclose callback when client closes connection" do + em { + EventMachine.add_timer(0.1) do + ws = EventMachine::WebSocketClient.connect('ws://127.0.0.1:12345/') + ws.errback { fail } + ws.callback { + ws.close_connection + } + ws.stream{|msg|} + end + + start_server { |ws| + ws.onopen {} + ws.onclose { + ws.state.should == :closed + EventMachine.stop + } + } + } + end + + it "should call onerror callback with raised exception and close connection on bad handshake" do + em { + EventMachine.add_timer(0.1) do + http = EM::HttpRequest.new('http://127.0.0.1:12345/').get + http.errback { } + http.callback { fail } + end + + start_server { |ws| + ws.onopen { fail } + ws.onclose { EventMachine.stop } + ws.onerror {|e| + e.should be_an_instance_of EventMachine::WebSocket::HandshakeError + e.message.should match('Not an upgrade request') + EventMachine.stop + } + } + } + end + + it "should report that close codes are not supported" do + em { + start_server { |ws| + ws.onopen { + ws.supports_close_codes?.should == false + done + } + } + start_client + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft76_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft76_spec.rb new file mode 100644 index 0000000..f1a14e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/draft76_spec.rb @@ -0,0 +1,234 @@ +# encoding: BINARY + +require 'helper' + +describe "WebSocket server draft76" do + include EM::SpecHelper + default_timeout 1 + + before :each do + @request = { + :port => 80, + :method => "GET", + :path => "/demo", + :headers => { + 'Host' => 'example.com', + 'Connection' => 'Upgrade', + 'Sec-WebSocket-Key2' => '12998 5 Y3 1 .P00', + 'Sec-WebSocket-Protocol' => 'sample', + 'Upgrade' => 'WebSocket', + 'Sec-WebSocket-Key1' => '4 @1 46546xW%0l 1 5', + 'Origin' => 'http://example.com' + }, + :body => '^n:ds[4U' + } + + @response = { + :headers => { + "Upgrade" => "WebSocket", + "Connection" => "Upgrade", + "Sec-WebSocket-Location" => "ws://example.com/demo", + "Sec-WebSocket-Origin" => "http://example.com", + "Sec-WebSocket-Protocol" => "sample" + }, + :body => "8jKS\'y:G*Co,Wxa-" + } + end + + def start_client + client = EM.connect('0.0.0.0', 12345, FakeWebSocketClient) + client.send_data(format_request(@request)) + yield client if block_given? + return client + end + + it_behaves_like "a websocket server" do + let(:version) { 76 } + end + + it "should send back the correct handshake response" do + em { + start_server + + start_client { |connection| + connection.onopen { + connection.handshake_response.lines.sort. + should == format_response(@response).lines.sort + done + } + } + } + end + + it "should send closing frame back and close the connection after recieving closing frame" do + em { + start_server + + connection = start_client + + # Send closing frame after handshake complete + connection.onopen { + connection.send_data(EM::WebSocket::Handler76::TERMINATE_STRING) + } + + # Check that this causes a termination string to be returned and the + # connection close + connection.onclose { + connection.packets[0].should == + EM::WebSocket::Handler76::TERMINATE_STRING + done + } + } + end + + it "should ignore any data received after the closing frame" do + em { + start_server { |ws| + # Fail if foobar message is received + ws.onmessage { |msg| + fail + } + } + + connection = start_client + + # Send closing frame after handshake complete, followed by another msg + connection.onopen { + connection.send_data(EM::WebSocket::Handler76::TERMINATE_STRING) + connection.send('foobar') + } + + connection.onclose { + done + } + } + end + + it "should accept null bytes within the frame after a line return" do + em { + start_server { |ws| + ws.onmessage { |msg| + msg.should == "\n\000" + } + } + + connection = start_client + + # Send closing frame after handshake complete + connection.onopen { + connection.send_data("\000\n\000\377") + connection.send_data(EM::WebSocket::Handler76::TERMINATE_STRING) + } + + connection.onclose { + done + } + } + end + + it "should handle unreasonable frame lengths by calling onerror callback" do + em { + start_server { |server| + server.onerror { |error| + error.should be_an_instance_of EM::WebSocket::WSMessageTooBigError + error.message.should == "Frame length too long (1180591620717411303296 bytes)" + done + } + } + + client = start_client + + # This particular frame indicates a message length of + # 1180591620717411303296 bytes. Such a message would previously cause + # a "bignum too big to convert into `long'" error. + # However it is clearly unreasonable and should be rejected. + client.onopen { + client.send_data("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00") + } + } + end + + it "should handle impossible frames by calling onerror callback" do + em { + start_server { |server| + server.onerror { |error| + error.should be_an_instance_of EM::WebSocket::WSProtocolError + error.message.should == "Invalid frame received" + done + } + } + + client = start_client + + client.onopen { + client.send_data("foobar") # Does not start with \x00 or \xff + } + } + end + + it "should handle invalid http requests by raising HandshakeError passed to onerror callback" do + em { + start_server { |server| + server.onerror { |error| + error.should be_an_instance_of EM::WebSocket::HandshakeError + error.message.should == "Invalid HTTP header: Could not parse data entirely (1 != 29)" + done + } + } + + client = EM.connect('0.0.0.0', 12345, FakeWebSocketClient) + client.send_data("This is not a HTTP header\r\n\r\n") + } + end + + it "should handle handshake request split into two TCP packets" do + em { + start_server + + # Create a fake client which sends draft 76 handshake + connection = EM.connect('0.0.0.0', 12345, FakeWebSocketClient) + data = format_request(@request) + # Sends first half of the request + connection.send_data(data[0...(data.length / 2)]) + + connection.onopen { + connection.handshake_response.lines.sort. + should == format_response(@response).lines.sort + done + } + + EM.add_timer(0.1) do + # Sends second half of the request + connection.send_data(data[(data.length / 2)..-1]) + end + } + end + + it "should report that close codes are not supported" do + em { + start_server { |ws| + ws.onopen { + ws.supports_close_codes?.should == false + done + } + } + start_client + } + end + + it "should call onclose when the server closes the connection [antiregression]" do + em { + start_server { |ws| + ws.onopen { + EM.add_timer(0.1) { + ws.close() + } + } + ws.onclose { + done + } + } + start_client + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/gte_03_examples.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/gte_03_examples.rb new file mode 100644 index 0000000..f841618 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/gte_03_examples.rb @@ -0,0 +1,42 @@ +shared_examples_for "a WebSocket server drafts 3 and above" do + it "should force close connections after a timeout if close handshake is not sent by the client" do + em { + server_onerror_fired = false + server_onclose_fired = false + client_got_close_handshake = false + + start_server(:close_timeout => 0.1) { |ws| + ws.onopen { + # 1: Send close handshake to client + EM.next_tick { ws.close(4999, "Close message") } + } + + ws.onerror { |e| + # 3: Client should receive onerror + e.class.should == EM::WebSocket::WSProtocolError + e.message.should == "Close handshake un-acked after 0.1s, closing tcp connection" + server_onerror_fired = true + } + + ws.onclose { + server_onclose_fired = true + } + } + start_client { |client| + client.onmessage { |msg| + # 2: Client does not respond to close handshake (the fake client + # doesn't understand them at all hence this is in onmessage) + msg.should =~ /Close message/ if version >= 6 + client_got_close_handshake = true + } + + client.onclose { + server_onerror_fired.should == true + server_onclose_fired.should == true + client_got_close_handshake.should == true + done + } + } + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/shared_examples.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/shared_examples.rb new file mode 100644 index 0000000..0cd6b42 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/integration/shared_examples.rb @@ -0,0 +1,265 @@ +# encoding: UTF-8 + +# These tests are run against all draft versions +# +shared_examples_for "a websocket server" do + it "should expose the protocol version" do + em { + start_server { |ws| + ws.onopen { |handshake| + handshake.protocol_version.should == version + done + } + } + + start_client + } + end + + it "should expose the origin header" do + em { + start_server { |ws| + ws.onopen { |handshake| + handshake.origin.should == 'http://example.com' + done + } + } + + start_client + } + end + + it "should expose the remote IP address" do + em { + start_server { |ws| + ws.onopen { + ws.remote_ip.should == "127.0.0.1" + done + } + } + + start_client + } + end + + it "should send messages successfully" do + em { + start_server { |ws| + ws.onmessage { |message| + message.should == "hello server" + done + } + } + + start_client { |client| + client.onopen { + client.send("hello server") + } + } + } + end + + it "should allow connection to be closed with valid close code" do + em { + start_server { |ws| + ws.onopen { + ws.close(4004, "Bye bye") + done + } + } + + start_client + # TODO: Use a real client which understands how to respond to closing + # handshakes, sending the handshake currently untested + } + end + + it "should raise error if if invalid close code is used" do + em { + start_server { |ws| + ws.onopen { + lambda { + ws.close(2000) + }.should raise_error("Application code may only use codes from 1000, 3000-4999") + done + } + } + + start_client + } + end + + it "should call onclose with was_clean set to false if connection closed without closing handshake by server" do + em { + start_server { |ws| + ws.onopen { + # Close tcp connection (no close handshake) + ws.close_connection + } + ws.onclose { |event| + event.should == {:code => 1006, :was_clean => false} + done + } + } + start_client + } + end + + it "should call onclose with was_clean set to false if connection closed without closing handshake by client" do + em { + start_server { |ws| + ws.onclose { |event| + event.should == {:code => 1006, :was_clean => false} + done + } + } + start_client { |client| + client.onopen { + # Close tcp connection (no close handshake) + client.close_connection + } + } + } + end + + it "should call onerror if an application error raised in onopen" do + em { + start_server { |ws| + ws.onopen { + raise "application error" + } + + ws.onerror { |e| + e.message.should == "application error" + done + } + } + + start_client + } + end + + it "should call onerror if an application error raised in onmessage" do + em { + start_server { |server| + server.onmessage { + raise "application error" + } + + server.onerror { |e| + e.message.should == "application error" + done + } + } + + start_client { |client| + client.onopen { + client.send('a message') + } + } + } + end + + it "should call onerror in an application error raised in onclose" do + em { + start_server { |server| + server.onclose { + raise "application error" + } + + server.onerror { |e| + e.message.should == "application error" + done + } + } + + start_client { |client| + client.onopen { + EM.add_timer(0.1) { + client.close_connection + } + } + } + } + end + + it "should close the connection when a too long frame is sent" do + em { + start_server { |server| + server.max_frame_size = 20 + + server.onerror { |e| + # 3: Error should be reported to server + e.class.should == EventMachine::WebSocket::WSMessageTooBigError + e.message.should =~ /Frame length too long/ + } + } + + start_client { |client| + client.onopen { + EM.next_tick { + client.send("This message is longer than 20 characters") + } + + } + + client.onmessage { |msg| + # 4: This is actually the close message. Really need to use a real + # WebSocket client in these tests... + done + } + + client.onclose { + # 4: Drafts 75 & 76 don't send a close message, they just close the + # connection + done + } + } + } + end + + # Only run these tests on ruby 1.9 + if "a".respond_to?(:force_encoding) + it "should raise error if you try to send non utf8 text data to ws" do + em { + start_server { |server| + server.onopen { + # Create a string which claims to be UTF-8 but which is not + s = "ê" # utf-8 string + s.encode!("ISO-8859-1") + s.force_encoding("UTF-8") + s.valid_encoding?.should == false # now invalid utf8 + + # Send non utf8 encoded data + server.send(s) + } + server.onerror { |error| + error.class.should == EventMachine::WebSocket::WebSocketError + error.message.should == "Data sent to WebSocket must be valid UTF-8 but was UTF-8 (valid: false)" + done + } + } + + start_client { } + } + end + + it "should not change the encoding of strings sent to send [antiregression]" do + em { + start_server { |server| + server.onopen { + s = "example string" + s.force_encoding("UTF-8") + + server.send(s) + + s.encoding.should == Encoding.find("UTF-8") + done + } + } + + start_client { } + } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/framing_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/framing_spec.rb new file mode 100644 index 0000000..b2a8d33 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/framing_spec.rb @@ -0,0 +1,298 @@ +# encoding: BINARY + +require 'helper' + +describe EM::WebSocket::Framing03 do + class FramingContainer + include EM::WebSocket::Framing03 + + def initialize + @connection = Object.new + def @connection.max_frame_size + 1000000 + end + end + + def <<(data) + @data << data + process_data + end + + def debug(*args); end + end + + before :each do + @f = FramingContainer.new + @f.initialize_framing + end + + describe "basic examples" do + it "connection close" do + @f.should_receive(:message).with(:close, '', '') + @f << 0b00000001 + @f << 0b00000000 + end + + it "ping" do + @f.should_receive(:message).with(:ping, '', '') + @f << 0b00000010 + @f << 0b00000000 + end + + it "pong" do + @f.should_receive(:message).with(:pong, '', '') + @f << 0b00000011 + @f << 0b00000000 + end + + it "text" do + @f.should_receive(:message).with(:text, '', 'foo') + @f << 0b00000100 + @f << 0b00000011 + @f << 'foo' + end + + it "Text in two frames" do + @f.should_receive(:message).with(:text, '', 'hello world') + @f << 0b10000100 + @f << 0b00000110 + @f << "hello " + @f << 0b00000000 + @f << 0b00000101 + @f << "world" + end + + it "2 byte extended payload length text frame" do + data = 'a' * 256 + @f.should_receive(:message).with(:text, '', data) + @f << 0b00000100 # Single frame, text + @f << 0b01111110 # Length 126 (so read 2 bytes) + @f << 0b00000001 # Two bytes in network byte order (256) + @f << 0b00000000 + @f << data + end + end + + # These examples are straight from the spec + # http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-03#section-4.6 + describe "examples from the spec" do + it "a single-frame text message" do + @f.should_receive(:message).with(:text, '', 'Hello') + @f << "\x04\x05Hello" + end + + it "a fragmented text message" do + @f.should_receive(:message).with(:text, '', 'Hello') + @f << "\x84\x03Hel" + @f << "\x00\x02lo" + end + + it "Ping request and response" do + @f.should_receive(:message).with(:ping, '', 'Hello') + @f << "\x02\x05Hello" + end + + it "256 bytes binary message in a single frame" do + data = "a"*256 + @f.should_receive(:message).with(:binary, '', data) + @f << "\x05\x7E\x01\x00" + data + end + + it "64KiB binary message in a single frame" do + data = "a"*65536 + @f.should_receive(:message).with(:binary, '', data) + @f << "\x05\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + data + end + end + + describe "other tests" do + it "should accept a fragmented unmasked text message in 3 frames" do + @f.should_receive(:message).with(:text, '', 'Hello world') + @f << "\x84\x03Hel" + @f << "\x80\x02lo" + @f << "\x00\x06 world" + end + end + + describe "error cases" do + it "should raise an exception on continuation frame without preceeding more frame" do + lambda { + @f << 0b00000000 # Single frame, continuation + @f << 0b00000001 # Length 1 + @f << 'f' + }.should raise_error(EM::WebSocket::WebSocketError, 'Continuation frame not expected') + end + end +end + +# These examples are straight from the spec +# http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-03#section-4.6 +describe EM::WebSocket::Framing04 do + class FramingContainer04 + include EM::WebSocket::Framing04 + + def initialize + @connection = Object.new + def @connection.max_frame_size + 1000000 + end + end + + def <<(data) + @data << data + process_data + end + + def debug(*args); end + end + + before :each do + @f = FramingContainer04.new + @f.initialize_framing + end + + describe "examples from the spec" do + it "a single-frame text message" do + @f.should_receive(:message).with(:text, '', 'Hello') + @f << "\x84\x05\x48\x65\x6c\x6c\x6f" # "\x84\x05Hello" + end + + it "a fragmented text message" do + @f.should_receive(:message).with(:text, '', 'Hello') + @f << "\x04\x03Hel" + @f << "\x80\x02lo" + end + + it "Ping request" do + @f.should_receive(:message).with(:ping, '', 'Hello') + @f << "\x82\x05Hello" + end + + it "a pong response" do + @f.should_receive(:message).with(:pong, '', 'Hello') + @f << "\x83\x05Hello" + end + + it "256 bytes binary message in a single frame" do + data = "a"*256 + @f.should_receive(:message).with(:binary, '', data) + @f << "\x85\x7E\x01\x00" + data + end + + it "64KiB binary message in a single frame" do + data = "a"*65536 + @f.should_receive(:message).with(:binary, '', data) + @f << "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + data + end + end + + describe "other tests" do + it "should accept a fragmented unmasked text message in 3 frames" do + @f.should_receive(:message).with(:text, '', 'Hello world') + @f << "\x04\x03Hel" + @f << "\x00\x02lo" + @f << "\x80\x06 world" + end + end +end + +describe EM::WebSocket::Framing07 do + class FramingContainer07 + include EM::WebSocket::Framing07 + + def initialize + @connection = Object.new + def @connection.max_frame_size + 1000000 + end + end + + def <<(data) + @data << data + process_data + end + + def debug(*args); end + end + + before :each do + @f = FramingContainer07.new + @f.initialize_framing + end + + # These examples are straight from the spec + # http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07#section-4.6 + describe "examples from the spec" do + it "a single-frame unmakedtext message" do + @f.should_receive(:message).with(:text, '', 'Hello') + @f << "\x81\x05\x48\x65\x6c\x6c\x6f" # "\x84\x05Hello" + end + + it "a single-frame masked text message" do + @f.should_receive(:message).with(:text, '', 'Hello') + @f << "\x81\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58" # "\x84\x05Hello" + end + + it "a fragmented unmasked text message" do + @f.should_receive(:message).with(:text, '', 'Hello') + @f << "\x01\x03Hel" + @f << "\x80\x02lo" + end + + it "Ping request" do + @f.should_receive(:message).with(:ping, '', 'Hello') + @f << "\x89\x05Hello" + end + + it "a pong response" do + @f.should_receive(:message).with(:pong, '', 'Hello') + @f << "\x8a\x05Hello" + end + + it "256 bytes binary message in a single unmasked frame" do + data = "a"*256 + @f.should_receive(:message).with(:binary, '', data) + @f << "\x82\x7E\x01\x00" + data + end + + it "64KiB binary message in a single unmasked frame" do + data = "a"*65536 + @f.should_receive(:message).with(:binary, '', data) + @f << "\x82\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + data + end + end + + describe "other tests" do + it "should raise a WSProtocolError if an invalid frame type is requested" do + lambda { + # Opcode 3 is not supported by this draft + @f << "\x83\x05Hello" + }.should raise_error(EventMachine::WebSocket::WSProtocolError, "Unknown opcode 3") + end + + it "should accept a fragmented unmasked text message in 3 frames" do + @f.should_receive(:message).with(:text, '', 'Hello world') + @f << "\x01\x03Hel" + @f << "\x00\x02lo" + @f << "\x80\x06 world" + end + + it "should raise if non-fin frame is followed by a non-continuation data frame (continuation frame would be expected)" do + lambda { + @f << 0b00000001 # Not fin, text + @f << 0b00000001 # Length 1 + @f << 'f' + @f << 0b10000001 # fin, text (continutation expected) + @f << 0b00000001 # Length 1 + @f << 'b' + }.should raise_error(EM::WebSocket::WebSocketError, 'Continuation frame expected') + end + + it "should raise on non-fin control frames (control frames must not be fragmented)" do + lambda { + @f << 0b00001010 # Not fin, pong (opcode 10) + @f << 0b00000000 # Length 1 + }.should raise_error(EM::WebSocket::WebSocketError, 'Control frames must not be fragmented') + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/handshake_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/handshake_spec.rb new file mode 100644 index 0000000..2754ba7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/handshake_spec.rb @@ -0,0 +1,216 @@ +require 'helper' + +describe EM::WebSocket::Handshake do + def handshake(request, secure = false) + handshake = EM::WebSocket::Handshake.new(secure) + handshake.receive_data(format_request(request)) + handshake + end + + before :each do + @request = { + :port => 80, + :method => "GET", + :path => "/demo", + :headers => { + 'Host' => 'example.com', + 'Connection' => 'Upgrade', + 'Sec-WebSocket-Key2' => '12998 5 Y3 1 .P00', + 'Sec-WebSocket-Protocol' => 'sample', + 'Upgrade' => 'WebSocket', + 'Sec-WebSocket-Key1' => '4 @1 46546xW%0l 1 5', + 'Origin' => 'http://example.com' + }, + :body => '^n:ds[4U' + } + @secure_request = @request.merge(:port => 443) + + @response = { + :headers => { + "Upgrade" => "WebSocket", + "Connection" => "Upgrade", + "Sec-WebSocket-Location" => "ws://example.com/demo", + "Sec-WebSocket-Origin" => "http://example.com", + "Sec-WebSocket-Protocol" => "sample" + }, + :body => "8jKS\'y:G*Co,Wxa-" + } + @secure_response = @response.merge(:headers => @response[:headers].merge('Sec-WebSocket-Location' => "wss://example.com/demo")) + end + + it "should handle good request" do + handshake(@request).should succeed_with_upgrade(@response) + end + + it "should handle good request to secure default port if secure mode is enabled" do + handshake(@secure_request, true). + should succeed_with_upgrade(@secure_response) + end + + it "should not handle good request to secure default port if secure mode is disabled" do + handshake(@secure_request, false). + should_not succeed_with_upgrade(@secure_response) + end + + it "should handle good request on nondefault port" do + @request[:port] = 8081 + @request[:headers]['Host'] = 'example.com:8081' + @response[:headers]['Sec-WebSocket-Location'] = + 'ws://example.com:8081/demo' + + handshake(@request).should succeed_with_upgrade(@response) + end + + it "should handle good request to secure nondefault port" do + @secure_request[:port] = 8081 + @secure_request[:headers]['Host'] = 'example.com:8081' + @secure_response[:headers]['Sec-WebSocket-Location'] = 'wss://example.com:8081/demo' + + handshake(@secure_request, true). + should succeed_with_upgrade(@secure_response) + end + + it "should handle good request with no protocol" do + @request[:headers].delete('Sec-WebSocket-Protocol') + @response[:headers].delete("Sec-WebSocket-Protocol") + + handshake(@request).should succeed_with_upgrade(@response) + end + + it "should handle extra headers by simply ignoring them" do + @request[:headers]['EmptyValue'] = "" + @request[:headers]['AKey'] = "AValue" + + handshake(@request).should succeed_with_upgrade(@response) + end + + it "should raise error on HTTP request" do + @request[:headers] = { + 'Host' => 'www.google.com', + 'User-Agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB6 GTBA', + 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Language' => 'en-us,en;q=0.5', + 'Accept-Encoding' => 'gzip,deflate', + 'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', + 'Keep-Alive' => '300', + 'Connection' => 'keep-alive', + } + + handshake(@request).should fail_with_error(EM::WebSocket::HandshakeError) + end + + it "should raise error on wrong method" do + @request[:method] = 'POST' + + handshake(@request).should fail_with_error(EM::WebSocket::HandshakeError) + end + + it "should raise error if upgrade header incorrect" do + @request[:headers]['Upgrade'] = 'NonWebSocket' + + handshake(@request).should fail_with_error(EM::WebSocket::HandshakeError) + end + + it "should raise error if Sec-WebSocket-Protocol is empty" do + @request[:headers]['Sec-WebSocket-Protocol'] = '' + + handshake(@request).should fail_with_error(EM::WebSocket::HandshakeError) + end + + %w[Sec-WebSocket-Key1 Sec-WebSocket-Key2].each do |header| + it "should raise error if #{header} has zero spaces" do + @request[:headers][header] = 'nospaces' + + handshake(@request). + should fail_with_error(EM::WebSocket::HandshakeError, 'Websocket Key1 or Key2 does not contain spaces - this is a symptom of a cross-protocol attack') + end + end + + it "should raise error if Sec-WebSocket-Key1 is missing" do + @request[:headers].delete("Sec-WebSocket-Key1") + + # The error message isn't correct since key1 is used to heuristically + # determine the protocol version in use, however this test at least checks + # that the handshake does correctly fail + handshake(@request). + should fail_with_error(EM::WebSocket::HandshakeError, 'Extra bytes after header') + end + + it "should raise error if Sec-WebSocket-Key2 is missing" do + @request[:headers].delete("Sec-WebSocket-Key2") + + handshake(@request). + should fail_with_error(EM::WebSocket::HandshakeError, 'WebSocket key1 or key2 is missing') + end + + it "should raise error if spaces do not divide numbers in Sec-WebSocket-Key* " do + @request[:headers]['Sec-WebSocket-Key2'] = '12998 5 Y3 1.P00' + + handshake(@request). + should fail_with_error(EM::WebSocket::HandshakeError, 'Invalid Key "12998 5 Y3 1.P00"') + end + + it "should raise error if the HTTP header is empty" do + handshake = EM::WebSocket::Handshake.new(false) + handshake.receive_data("\r\n\r\nfoobar") + + handshake. + should fail_with_error(EM::WebSocket::HandshakeError, 'Invalid HTTP header: Could not parse data entirely (4 != 10)') + end + + # This might seems crazy, but very occasionally we saw multiple "Upgrade: + # WebSocket" headers in the wild. RFC 4.2.1 isn't particularly clear on this + # point, so for now I have decided not to accept --@mloughran + it "should raise error on multiple upgrade headers" do + handshake = EM::WebSocket::Handshake.new(false) + + # Add a duplicate upgrade header + headers = format_request(@request) + upgrade_header = "Upgrade: WebSocket\r\n" + headers.gsub!(upgrade_header, "#{upgrade_header}#{upgrade_header}") + + handshake.receive_data(headers) + + handshake.errback { |e| + e.class.should == EM::WebSocket::HandshakeError + e.message.should == 'Invalid upgrade header: ["WebSocket", "WebSocket"]' + } + end + + it "should cope with requests where the header is split" do + request = format_request(@request) + incomplete_request = request[0...(request.length / 2)] + rest = request[(request.length / 2)..-1] + handshake = EM::WebSocket::Handshake.new(false) + handshake.receive_data(incomplete_request) + + handshake.instance_variable_get(:@deferred_status).should == nil + + # Send the remaining header + handshake.receive_data(rest) + + handshake(@request).should succeed_with_upgrade(@response) + end + + it "should cope with requests where the third key is split" do + request = format_request(@request) + # Removes last two bytes of the third key + incomplete_request = request[0..-3] + rest = request[-2..-1] + handshake = EM::WebSocket::Handshake.new(false) + handshake.receive_data(incomplete_request) + + handshake.instance_variable_get(:@deferred_status).should == nil + + # Send the remaining third key + handshake.receive_data(rest) + + handshake(@request).should succeed_with_upgrade(@response) + end + + it "should fail if the request URI is invalid" do + @request[:path] = "/%" + handshake(@request).should \ + fail_with_error(EM::WebSocket::HandshakeError, 'Invalid request URI: /%') + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/masking_spec.rb b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/masking_spec.rb new file mode 100644 index 0000000..065aa95 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/em-websocket-0.5.3/spec/unit/masking_spec.rb @@ -0,0 +1,29 @@ +# encoding: BINARY + +require 'helper' + +describe EM::WebSocket::MaskedString do + it "should allow reading 4 byte mask and unmasking byte / bytes" do + t = EM::WebSocket::MaskedString.new("\x00\x00\x00\x01\x00\x01\x00\x01") + t.read_mask + t.getbyte(3).should == 0x00 + t.getbytes(4, 4).should == "\x00\x01\x00\x00" + t.getbytes(5, 3).should == "\x01\x00\x00" + end + + it "should return nil from getbyte if index requested is out of range" do + t = EM::WebSocket::MaskedString.new("\x00\x00\x00\x00\x53") + t.read_mask + t.getbyte(4).should == 0x53 + t.getbyte(5).should == nil + end + + it "should allow switching masking on and off" do + t = EM::WebSocket::MaskedString.new("\x02\x00\x00\x00\x03") + t.getbyte(4).should == 0x03 + t.read_mask + t.getbyte(4).should == 0x01 + t.unset_mask + t.getbyte(4).should == 0x03 + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/CHANGELOG.md b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/CHANGELOG.md new file mode 100644 index 0000000..cd42c39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/CHANGELOG.md @@ -0,0 +1,179 @@ +# Changelog + +## 1.2.7 (May 12, 2018) +* Fix segfault on large numbers of connections [#843] + +## 1.2.6 (April 30, 2018) +* *Fix segfault when an Exception is raised from unbind callback (for real this time!)* +* Fix race condition while initializing the machine [#756] +* Fix for newer compilers where bind() and std::bind() conflict [#830, #831] +* Be verbose about SSL connection errors [#807] +* Avoid explicitly calling class methods when in class scope +* Java: Add EM_PROTO_SSL/TLS definitions [#773, #791] +* Java: return zero when sending data to a closed connection [#475, #804] +* Pure Ruby: Connection::error? calls report_connection_error_status [#801] + +## 1.2.5 (July 27, 2017) +* Java: Use long for larger values in oneshot timer intervals [#784, #794] + +## 1.2.4 (July 27, 2017) +* Java: Add EM_PROTO_SSL/TLS definitions [#773, #791] +* Fix IPv6 UDP get_peername [#788] +* Allow for larger values in oneshot timer intervals [#784, #793] +* Update extconf.rb to allow MinGW builds with OpenSSL 1.1.0 [#785] + +## 1.2.3 (February 22, 2017) +* Pure Ruby: Add get_sockname [#308, #772] +* Fix segfault when an Exception is raised from unbind callback [#765, #766] +* Allow destructors to throw when compiling in >= C++11 [#767] + +## 1.2.2 (January 23, 2017) +* Java: Fix Fixnum deprecated warning in Ruby 2.4+ [#759] +* Fix uncaught C++ exception in file watcher and raise InvalidSignature [#512, #757] +* Fix connection count off-by-one for epoll and kqueue [#750] +* Fix uninitialized variable warning in EM::P::HttpClient [#749] +* Fix missing initial value for EventableDescriptor NextHeartbeat [#748] +* Fix hostname resolution on Solaris, Ilumos, SmartOS, et al [#745, #746] +* Improve reliability of tests, reduce public Internet accesses in tests [#656, #666, #749] + +## 1.2.1 (November 15, 2016) +* Throw strerror(errno) when getsockname or getpeername fail [#683] +* Use a single concrete implementation of getpeername/getsockname, the rest pure virtuals [#683] +* Use gai_strerror to get the failure string from getaddrinfo [#744] +* Fix deregistering descriptor when using KQUEUE [#728] +* Fix to enable to work an example code in EM::Pool [#731] +* LineText2: Add regular expression delimiter support [#706] +* Pure Ruby: EM rescue ECONNREFUSED on initial TCP connect [#741] +* Pure Ruby: EM SSL (working start_tls) [#712] +* Pure Ruby: EM fixes [#707] +* Java: Use Acceptors to get peer and sock names if not present in Connections [#743] + +## 1.2.0.1 (March 15, 2016) +* Fix crash when accepting IPv6 connections due to struct sockaddr_in [#698, #699] + +## 1.2.0 (March 15, 2016) +* Integrate work from the EventMachine-LE 1.1.x versions [#570] +* Add start_tls options :ecdh_curve, :dhparam, :fail_if_no_peer_cert [#195, #275, #399, #665] +* Add start_tls option :ssl_version for choosing SSL/TLS versions and ciphers [#359, #348, #603, #654] +* Add start_tls option :sni_hostname to be passed to TLS params [#593] +* Add method EM::Channel#num_subscribers to get the number of subscribers to a channel [#640] +* Add support for proc-sources in EM::Iterator [#639] +* Factor out method cleanup_machine to cleanup code from EM.run [#650] +* Replace Exception class with StandardError [#637] +* Close socket on close_connection even after close_connection_after_writing [#694] +* Allow reusing of datagram socket/setting bind device [#662] +* Handle deferred exceptions in reactor thread [#486] +* Reimplement Queue to avoid shift/push performance problem [#311] +* Windows: Switch from gethostbyname to getaddrinfo, support IPv6 addresses [#303, #630] +* Windows: Use rake-compiler-dock to cross-compile gems [#627] +* Windows: Add AppVeyor configuration for Windows CI testing [#578] +* Windows: Bump rake-compiler to version 0.9.x [#542] +* Fix compilation on AIX (w/ XLC) [#693] +* Fix build on OpenBSD [#690] +* Fix OpenSSL compile issue on AIX 7.1 [#678] +* Fix EventMachine.fork_reactor keeps the threadpool of the original process [#425] +* Fix to prevent event machine from stopping when a raise is done in an unbind [#327] + +## 1.0.9.1 (January 14, 2016) +* Fix EPROTO not defined on Windows [#676] +* Fix missing cast to struct sockaddr * [#671] +* Fix bug in OpenSSL path detection [#675] + +## 1.0.9 (January 13, 2016) +* Try more ways to detect OpenSSL [#602, #643, #661, #663, #668, #669] +* Use WSAGetLastError in pipe.cpp same as ed.cpp [#659] +* Test compiler flags with the C++ compiler and add them to CXXFLAGS [#634, #651] +* Restore silent-fail on unsupported EM.epoll and EM.kqueue [#638, #649] +* getDescriptorByFileno deprecated in JRuby 1.7.x, removed in JRuby 9000 [#642, #648] +* Add -Wno-address always-true because on Windows rb_fd_select [#578] +* Remove the WITHOUT_SSL constant [#578] +* Fix SSL error when the server replies a TLS Alert to our ClientHello [#544, #653] +* Use WSAStringToAddress in lieu of inet_pton for IPv6 address detection on Windows [#595, #632] +* Fix nasty TCP/IPv6 bug [#595, #632] +* Use select_large_fdset on Solaris [#611, #625] +* Detect the Solaris Studio compiler [#611, #625] +* Throw a message with strerror included [#136, #621] + +## 1.0.8 (August 6, 2015) +* fix kqueue assertion failed, postpone ArmKqueueWriter until all events are processed [#51, #176, #372, #401, #619] +* fix Rubinius GC, crank the machine from Ruby space when running Rubinius [#201, #202, #617] +* test to show that LineText2 preserves whitespace and newlines [#32, #622] +* bump up compiler warnings and resolve them [#616] +* fix Windows x64 use uintptr_t instead of unsigned long for binding pointers [#612, #615] +* fix linetext2 unroll tail recursion to avoid stack level too deep [#609] +* fix for compilation with SSL on windows [#601] +* open file descriptors and sockets with O_CLOEXEC where possible [#298, #488, #591] +* fix SmtpClient: send second EHLO after STARTTLS. [#589] +* fix nul-terminated strings in C, use StringValueCStr instead of StringValuePtr + +## 1.0.7 (February 10, 2015) +* fix delay in kqueue/epoll reactor shutdown when timers exist [#587] +* fix memory leak introduced in v1.0.5 [#586] +* expose EM.set_simultaneous_accept_count [#420] +* fix busy loop when EM.run and EM.next_tick are invoked from exception handler [#452] + +## 1.0.6 (February 3, 2015) +* add support for Rubinius Process::Status [#568] +* small bugfixes for SmtpServer [#449] +* update buftok.rb [#547] +* fix assertion on Write() [#525] +* work around mkmf.rb bug preventing gem installation [#574] +* add pause/resume support to jruby reactor [#556] +* fix pure ruby reactor to use 127.0.0.1 instead of localhost [#439] +* fix compilation under macruby [#243] +* add chunked encoding to http client [#111] +* fix errors on win32 when dealing with pipes [1ea45498] [#105] + +## 1.0.5 (February 2, 2015) +* use monotonic clocks on Linux, OS X, Solaris, and Windows [#563] +* use the rb_fd_* API to get autosized fd_sets [#502] +* add basic tests that the DNS resolver isn't leaking timers [#571] +* update to test-unit 2.x and improve various unit tests [#551] +* remove EventMachine_t::Popen code marked by ifdef OBSOLETE [#551] +* ruby 2.0 may fail at Queue.pop, so rescue and complain to $stderr [#551] +* set file handle to INVALID_HANDLE_VALUE after closing the file [#565] +* use `defined?` instead of rescuing NameError for flow control [#535] +* fix closing files and sockets on Windows [#564] +* fix file uploads in Windows [#562] +* catch failure to fork [#539] +* use chunks for SSL write [#545] + +## 1.0.4 (December 19, 2014) +* add starttls_options to smtp server [#552] +* fix closesocket on windows [#497] +* fix build on ruby 2.2 [#503] +* fix build error on ruby 1.9 [#508] +* fix timer leak during dns resolution [#489] +* add concurrency validation to EM::Iterator [#468] +* add get_file_descriptor to get fd for a signature [#467] +* add EM.attach_server and EM.attach_socket_server [#465, #466] +* calling pause from receive_data takes effect immediately [#464] +* reactor_running? returns false after fork [#455] +* fix infinite loop on double close [edc4d0e6, #441, #445] +* fix compilation issue on llvm [#433] +* fix socket error codes on win32 [ff811a81] +* fix EM.stop latency when timers exist [8b613d05, #426] +* fix infinite loop when system time changes [1427a2c80, #428] +* fix crash when callin attach/detach in the same tick [#427] +* fix compilation issue on solaris [#416] + +## 1.0.3 (March 8, 2013) +* EM.system was broken in 1.0.2 release [#413] + +## 1.0.2 (March 8, 2013) +* binary win32 gems now include fastfilereader shim [#222] +* fix long-standing connection timeout issues [27fdd5b, igrigorik/em-http-request#222] +* http and line protocol cleanups [#193, #151] +* reactor return value cleanup [#225] +* fix double require from gemspec [#284] +* fix smtp server reset behavior [#351] +* fix EM.system argument handling [#322] +* ruby 1.9 compat in smtp server and stomp protocols [#349, #315] +* fix pause from post_init [#380] + +## 1.0.1 (February 27, 2013) +* use rb_wait_for_single_fd() on ruby 2.0 to fix rb_thread_select() deprecation [#363] +* fix epoll/kqueue mode in ruby 2.0 by removing calls to rb_enable_interrupt() [#248, #389] +* fix memory leak when verifying ssl cerificates [#403] +* fix initial connection delay [#393, #374] +* fix build on windows [#371] diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/GNU b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/GNU new file mode 100644 index 0000000..3b70c5b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/GNU @@ -0,0 +1,281 @@ +. + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public + License is intended to guarantee your freedom to share and change free + software--to make sure the software is free for all its users. This + General Public License applies to most of the Free Software + Foundation's software and to any other program whose authors commit to + using it. (Some other Free Software Foundation software is covered by + the GNU Lesser General Public License instead.) You can apply it to + your programs, too. + + When we speak of free software, we are referring to freedom, not + price. Our General Public Licenses are designed to make sure that you + have the freedom to distribute copies of free software (and charge for + this service if you wish), that you receive source code or can get it + if you want it, that you can change the software or use pieces of it + in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid + anyone to deny you these rights or to ask you to surrender the rights. + These restrictions translate to certain responsibilities for you if you + distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether + gratis or for a fee, you must give the recipients all the rights that + you have. You must make sure that they, too, receive or can get the + source code. And you must show them these terms so they know their + rights. + + We protect your rights with two steps: (1) copyright the software, and + (2) offer you this license which gives you legal permission to copy, + distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain + that everyone understands that there is no warranty for this free + software. If the software is modified by someone else and passed on, we + want its recipients to know that what they have is not the original, so + that any problems introduced by others will not reflect on the original + authors' reputations. + + Finally, any free program is threatened constantly by software + patents. We wish to avoid the danger that redistributors of a free + program will individually obtain patent licenses, in effect making the + program proprietary. To prevent this, we have made it clear that any + patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains + a notice placed by the copyright holder saying it may be distributed + under the terms of this General Public License. The "Program", below, + refers to any such program or work, and a "work based on the Program" + means either the Program or any derivative work under copyright law: + that is to say, a work containing the Program or a portion of it, + either verbatim or with modifications and/or translated into another + language. (Hereinafter, translation is included without limitation in + the term "modification".) Each licensee is addressed as "you". + + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of + running the Program is not restricted, and the output from the Program + is covered only if its contents constitute a work based on the + Program (independent of having been made by running the Program). + Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the + notices that refer to this License and to the absence of any warranty; + and give any other recipients of the Program a copy of this License + along with the Program. + + You may charge a fee for the physical act of transferring a copy, and + you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, + and can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based + on the Program, the distribution of the whole must be on the terms of + this License, whose permissions for other licensees extend to the + entire whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Program. + + In addition, mere aggregation of another work not based on the Program + with the Program (or with a work based on the Program) on a volume of + a storage or distribution medium does not bring the other work under + the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms of + Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete source + code means all the source code for all modules it contains, plus any + associated interface definition files, plus the scripts used to + control compilation and installation of the executable. However, as a + special exception, the source code distributed need not include + anything that is normally distributed (in either source or binary + form) with the major components (compiler, kernel, and so on) of the + operating system on which the executable runs, unless that component + itself accompanies the executable. + + If distribution of executable or object code is made by offering + access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this License. + However, parties who have received copies, or rights, from you under + this License will not have their licenses terminated so long as such + parties remain in full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Program or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Program (or any work based on the + Program), you indicate your acceptance of this License to do so, and + all its terms and conditions for copying, distributing or modifying + the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program subject to + these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted herein. + You are not responsible for enforcing compliance by third parties to + this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Program at all. For example, if a patent + license would not permit royalty-free redistribution of the Program by + all those who receive copies directly or indirectly through you, then + the only way you could satisfy both it and this License would be to + refrain entirely from distribution of the Program. + + If any portion of this section is held invalid or unenforceable under + any particular circumstance, the balance of the section is intended to + apply and the section as a whole is intended to apply in other + circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system, which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system; it is up to the author/donor to decide if he or she is willing + to distribute software through any other system and a licensee cannot + impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License + may add an explicit geographical distribution limitation excluding + those countries, so that distribution is permitted only in or among + countries not thus excluded. In such case, this License incorporates + the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions + of the General Public License from time to time. Such new versions will + be similar in spirit to the present version, but may differ in detail to + address new problems or concerns. + + Each version is given a distinguishing version number. If the Program + specifies a version number of this License which applies to it and "any + later version", you have the option of following the terms and conditions + either of that version or of any later version published by the Free + Software Foundation. If the Program does not specify a version number of + this License, you may choose any version ever published by the Free Software + Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the author + to ask for permission. For software which is copyrighted by the Free + Software Foundation, write to the Free Software Foundation; we sometimes + make exceptions for this. Our decision will be guided by the two goals + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN + OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES + PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED + OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS + TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, + REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR + REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, + INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING + OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED + TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY + YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/LICENSE b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/LICENSE new file mode 100644 index 0000000..fbe8c83 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/LICENSE @@ -0,0 +1,60 @@ +EventMachine is copyrighted free software owned by Francis Cianfrocca +(blackhedd ... gmail.com). The Owner of this software permits you to +redistribute and/or modify the software under either the terms of the GPL +version 2 (see the file GPL), or the conditions below ("Ruby License"): + + 1. You may make and give away verbatim copies of the source form of this + software without restriction, provided that you retain ALL of the + original copyright notices and associated disclaimers. + + 2. You may modify your copy of the software in any way, provided that + you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said + modifications to Usenet or an equivalent medium, or by allowing + the author to include your modifications in the software. + + b) use the modified software only within your corporation or + organization. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the Owner. + + 3. You may distribute the software in object code or binary form, + provided that you do at least ONE of the following: + + a) distribute the binaries and library files of the software, + together with instructions (in a manual page or equivalent) + on where to get the original distribution. + + b) accompany the distribution with the machine-readable source of + the software. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the Owner. + + 4. You may modify and include parts of the software into any other + software (possibly commercial), provided you comply with the terms in + Sections 1, 2, and 3 above. But some files in the distribution + are not written by the Owner, so they may be made available to you + under different terms. + + For the list of those files and their copying conditions, see the + file LEGAL. + + 5. The scripts and library files supplied as input to or produced as + output from the software do not automatically fall under the + copyright of the software, but belong to whoever generated them, + and may be sold commercially, and may be aggregated with this + software. + + 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/README.md b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/README.md new file mode 100644 index 0000000..4b17cb4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/README.md @@ -0,0 +1,110 @@ +# About EventMachine [![Build Status](https://travis-ci.org/eventmachine/eventmachine.svg?branch=master)](https://travis-ci.org/eventmachine/eventmachine) [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/e9b0603462905d5b9118/maintainability)](https://codeclimate.com/github/eventmachine/eventmachine/maintainability) + + +## What is EventMachine ## + +EventMachine is an event-driven I/O and lightweight concurrency library for Ruby. +It provides event-driven I/O using the [Reactor pattern](http://en.wikipedia.org/wiki/Reactor_pattern), +much like [JBoss Netty](http://www.jboss.org/netty), [Apache MINA](http://mina.apache.org/), +Python's [Twisted](http://twistedmatrix.com), [Node.js](http://nodejs.org), libevent and libev. + +EventMachine is designed to simultaneously meet two key needs: + + * Extremely high scalability, performance and stability for the most demanding production environments. + * An API that eliminates the complexities of high-performance threaded network programming, + allowing engineers to concentrate on their application logic. + +This unique combination makes EventMachine a premier choice for designers of critical networked +applications, including Web servers and proxies, email and IM production systems, authentication/authorization +processors, and many more. + +EventMachine has been around since the early 2000s and is a mature and battle-tested library. + + +## What EventMachine is good for? ## + + * Scalable event-driven servers. Examples: [Thin](http://code.macournoyer.com/thin/) or [Goliath](https://github.com/postrank-labs/goliath/). + * Scalable asynchronous clients for various protocols, RESTful APIs and so on. Examples: [em-http-request](https://github.com/igrigorik/em-http-request) or [amqp gem](https://github.com/ruby-amqp/amqp). + * Efficient network proxies with custom logic. Examples: [Proxymachine](https://github.com/mojombo/proxymachine/). + * File and network monitoring tools. Examples: [eventmachine-tail](https://github.com/jordansissel/eventmachine-tail) and [logstash](https://github.com/logstash/logstash). + + + +## What platforms are supported by EventMachine? ## + +EventMachine supports Ruby 1.8.7 through 2.6, REE, JRuby and **works well on Windows** as well +as many operating systems from the Unix family (Linux, Mac OS X, BSD flavors). + + + +## Install the gem ## + +Install it with [RubyGems](https://rubygems.org/) + + gem install eventmachine + +or add this to your Gemfile if you use [Bundler](http://gembundler.com/): + + gem "eventmachine" + + + +## Getting started ## + +For an introduction to EventMachine, check out: + + * [blog post about EventMachine by Ilya Grigorik](http://www.igvita.com/2008/05/27/ruby-eventmachine-the-speed-demon/). + * [EventMachine Introductions by Dan Sinclair](http://everburning.com/news/eventmachine-introductions.html). + + +### Server example: Echo server ### + +Here's a fully-functional echo server written with EventMachine: + +```ruby + require 'eventmachine' + + module EchoServer + def post_init + puts "-- someone connected to the echo server!" + end + + def receive_data data + send_data ">>>you sent: #{data}" + close_connection if data =~ /quit/i + end + + def unbind + puts "-- someone disconnected from the echo server!" + end +end + +# Note that this will block current thread. +EventMachine.run { + EventMachine.start_server "127.0.0.1", 8081, EchoServer +} +``` + + +## EventMachine documentation ## + +Currently we only have [reference documentation](http://rdoc.info/github/eventmachine/eventmachine/frames) and a [wiki](https://github.com/eventmachine/eventmachine/wiki). + + +## Community and where to get help ## + + * Join the [mailing list](http://groups.google.com/group/eventmachine) (Google Group) + * Join IRC channel #eventmachine on irc.freenode.net + + +## License and copyright ## + +EventMachine is copyrighted free software made available under the terms +of either the GPL or Ruby's License. + +Copyright: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. + + +## Alternatives ## + +If you are unhappy with EventMachine and want to use Ruby, check out [Celluloid](https://celluloid.io/). diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/DocumentationGuidesIndex.md b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/DocumentationGuidesIndex.md new file mode 100644 index 0000000..b8ce5a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/DocumentationGuidesIndex.md @@ -0,0 +1,27 @@ +# EventMachine documentation guides # + +Welcome to the documentation guides for [EventMachine](http://github.com/eventmachine/eventmachine), +a fast and simple event-processing library for Ruby programs (à la JBoss Netty, Twisted, Node.js +and so on). + +## Guide list ## + + * {file:docs/GettingStarted.md Getting started with EventMachine} + * {file:docs/EventDrivenServers.md Writing event-driven servers} + * {file:docs/EventDrivenClients.md Writing event-driven clients} + * {file:docs/ConnectionFailureAndRecovery.md Connection Failure and Recovery} + * {file:docs/TLS.md TLS (aka SSL)} + * {file:docs/Ecosystem.md EventMachine ecosystem}: Thin, Goliath, em-http-request, em-websockets, Proxymachine and beyond + * {file:docs/BlockingEventLoop.md On blocking the event loop: why it is harmful for performance and how to avoid it} + * {file:docs/LightweightConcurrency.md Lightweight concurrency with EventMachine} + * {file:docs/Deferrables.md Deferrables} + * {file:docs/ModernKernelInputOutputAPIs.md Brief introduction to epoll, kqueue, select} + * {file:docs/WorkingWithOtherIOSources.md Working with other IO sources such as the keyboard} + + +## Tell us what you think! ## + +Please take a moment and tell us what you think about this guide on the [EventMachine mailing list](http://bit.ly/jW3cR3) +or in the #eventmachine channel on irc.freenode.net: what was unclear? What wasn't covered? +Maybe you don't like the guide style or the grammar and spelling are incorrect? Reader feedback is +key to making documentation better. diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/GettingStarted.md b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/GettingStarted.md new file mode 100644 index 0000000..63acbb7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/GettingStarted.md @@ -0,0 +1,521 @@ +# @title Getting Started with Ruby EventMachine +# @markup markdown +# @author Michael S. Klishin, Dan Sinclair + +# Getting started with Ruby EventMachine # + + +## About this guide ## + +This guide is a quick tutorial that helps you to get started with EventMachine for writing event-driven +servers, clients and using it as a lightweight concurrency library. +It should take about 20 minutes to read and study the provided code examples. This guide covers + + * Installing EventMachine via [Rubygems](http://rubygems.org) and [Bundler](http://gembundler.com). + * Building an Echo server, the "Hello, world"-like code example of network servers. + * Building a simple chat, both server and client. + * Building a very small asynchronous Websockets client. + + +## Covered versions ## + +This guide covers EventMachine v0.12.10 and 1.0 (including betas). + + +## Level ## + +This guide assumes you are comfortable (but not necessary a guru) with the command line. On Microsoft Windows™, +we recommend you to use [JRuby](http://jruby.org) when running these examples. + + +## Installing EventMachine ## + +### Make sure you have Ruby installed ### + +This guide assumes you have one of the supported Ruby implementations installed: + + * Ruby 1.8.7 + * Ruby 1.9.2 + * [JRuby](http://jruby.org) (we recommend 1.6) + * [Rubinius](http://rubini.us) 1.2 or higher + * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com) + +EventMachine works on Microsoft Windows™. + + +### With Rubygems ### + +To install the EventMachine gem do + + gem install eventmachine + + +### With Bundler ### + + gem "eventmachine" + + +### Verifying your installation ### + +Lets verify your installation with this quick IRB session: + + irb -rubygems + + ruby-1.9.2-p180 :001 > require "eventmachine" + => true + ruby-1.9.2-p180 :002 > EventMachine::VERSION + => "1.0.0.beta.3" + + +## An Echo Server Example ## + +Lets begin with the classic "Hello, world"-like example, an echo server. The echo server responds clients with the +same data that was provided. First, here's the code: + +{include:file:examples/guides/getting\_started/01\_eventmachine\_echo_server.rb} + + +When run, the server binds to port 10000. We can connect using Telnet and verify it's working: + + telnet localhost 10000 + +On my machine the output looks like: + + ~ telnet localhost 10000 + Trying 127.0.0.1... + Connected to localhost. + Escape character is '^]'. + +Let's send something to our server. Type in "Hello, EventMachine" and hit Enter. The server will respond with +the same string: + + ~ telnet localhost 10000 + Trying 127.0.0.1... + Connected to localhost. + Escape character is '^]'. + Hello, EventMachine + # (here we hit Enter) + Hello, EventMachine + # (this ^^^ is our echo server reply) + +It works! Congratulations, you now can tell your Node.js-loving friends that you "have done some event-driven programming, too". +Oh, and to stop Telnet, hit Control + Shift + ] and then Control + C. + +Lets walk this example line by line and see what's going on. These lines + + require 'rubygems' # or use Bundler.setup + require 'eventmachine' + +probably look familiar: you use [RubyGems](http://rubygems.org) (or [Bundler](http://gembundler.com/)) for dependencies and then require EventMachine gem. Boring. + +Next: + + class EchoServer < EventMachine::Connection + def receive_data(data) + send_data(data) + end + end + +Is the implementation of our echo server. We define a class that inherits from {EventMachine::Connection} +and a handler (aka callback) for one event: when we receive data from a client. + +EventMachine handles the connection setup, receiving data and passing it to our handler, {EventMachine::Connection#receive_data}. + +Then we implement our protocol logic, which in the case of Echo is pretty trivial: we send back whatever we receive. +To do so, we're using {EventMachine::Connection#send_data}. + +Lets modify the example to recognize `exit` command: + +{include:file:examples/guides/getting\_started/02\_eventmachine\_echo_server\_that\_recognizes\_exit\_command.rb} + +Our `receive\_data` changed slightly and now looks like this: + + def receive_data(data) + if data.strip =~ /exit$/i + EventMachine.stop_event_loop + else + send_data(data) + end + end + +Because incoming data has trailing newline character, we strip it off before matching it against a simple regular +expression. If the data ends in `exit`, we stop EventMachine event loop with {EventMachine.stop_event_loop}. This unblocks +main thread and it finishes execution, and our little program exits as the result. + +To summarize this first example: + + * Subclass {EventMachine::Connection} and override {EventMachine::Connection#send_data} to handle incoming data. + * Use {EventMachine.run} to start EventMachine event loop and then bind echo server with {EventMachine.start_server}. + * To stop the event loop, use {EventMachine.stop_event_loop} (aliased as {EventMachine.stop}) + +Lets move on to a slightly more sophisticated example that will introduce several more features and methods +EventMachine has to offer. + + +## A Simple Chat Server Example ## + +Next we will write a simple chat. Initially clients will still use telnet to connect, but then we will add little +client application that will serve as a proxy between telnet and the chat server. This example is certainly longer +(~ 150 lines with whitespace and comments) so instead of looking at the final version and going through it line by line, +we will instead begin with a very simple version that only keeps track of connected clients and then add features +as we go. + +To set some expectations about our example: + + * It will keep track of connected clients + * It will support a couple of commands, à la IRC + * It will support direct messages using Twitter-like @usernames + * It won't use MongoDB, fibers or distributed map/reduce for anything but will be totally [Web Scale™](http://bit.ly/webscaletm) nonetheless. Maybe even [ROFLscale](http://bit.ly/roflscalevideo). + +### Step one: detecting connections and disconnectons ### + +First step looks like this: + +{include:file:examples/guides/getting\_started/04\_simple\_chat\_server\_step\_one.rb} + +We see familiar {EventMachine.run} and {EventMachine.start_server}, but also {EventMachine::Connection#post_init} and {EventMachine::Connection#unbind} we haven't +met yet. We don't use them in this code, so when are they run? Like {EventMachine::Connection#receive_data}, these methods are callbacks. EventMachine calls them +when certain events happen: + + * {EventMachine#post_init} is called by the event loop immediately after the network connection has been established. + In the chat server example case, this is when a new client connects. + * {EventMachine#unbind} is called when client disconnects, connection is closed or is lost (because of a network issue, for example). + +All our chat server does so far is logging connections or disconnections. What we want it to do next is to keep track of connected clients. + + +### Step two: keep track of connected clients ### + +Next iteration of the code looks like this: + +{include:file:examples/guides/getting\_started/05\_simple\_chat\_server\_step\_two.rb} + +While the code we added is very straightforward, we have to clarify one this first: subclasses of {EventMachine::Connection} are instantiated by +EventMachine for every new connected peer. So for 10 connected chat clients, there will be 10 separate `SimpleChatServer` instances in our +server process. Like any other objects, they can be stored in a collection, can provide public API other objects use, can instantiate or inject +dependencies and in general live a happy life all Ruby objects live until garbage collection happens. + +In the example above we use a @@class_variable to keep track of connected clients. In Ruby, @@class variables are accessible from instance +methods so we can add new connections to the list from `SimpleChatServer#post_init` and remove them in `SimpleChatServer#unbind`. We can also +filter connections by some criteria, as `SimpleChatServer#other_peers demonstrates`. + +So, we keep track of connections but how do we identify them? For a chat app, it's pretty common to use usernames for that. Lets ask our clients +to enter usernames when they connect. + + +### Step three: adding usernames ## + +To add usernames, we need to add a few things: + + * We need to invite newly connected clients to enter their username. + * A reader (getter) method on our {EventMachine::Connection} subclass. + * An idea of connection state (keeping track of whether a particular participant had entered username before). + +Here is one way to do it: + +{include:file:examples/guides/getting\_started/06\_simple\_chat\_server\_step\_three.rb} + +This is quite an update so lets take a look at each method individually. First, `SimpleChatServer#post_init`: + + def post_init + @username = nil + puts "A client has connected..." + ask_username + end + +To keep track of username we ask chat participants for, we add @username instance variable to our connection class. Connection +instances are just Ruby objects associated with a particular connected peer, so using @ivars is very natural. To make username +value accessible to other objects, we added a reader method that was not shown on the snippet above. + +Lets dig into `SimpleChatServer#ask_username`: + + def ask_username + self.send_line("[info] Enter your username:") + end # ask_username + + # ... + + def send_line(line) + self.send_data("#{line}\n") + end # send_line(line) + +Nothing new here, we are using {EventMachine::Connection#send_data} which we have seen before. + + +In `SimpleChatServer#receive_data` we now have to check if the username was entered or we need +to ask for it: + + def receive_data(data) + if entered_username? + handle_chat_message(data.strip) + else + handle_username(data.strip) + end + end + + # ... + + def entered_username? + !@username.nil? && !@username.empty? + end # entered_username? + +Finally, handler of chat messages is not yet implemented: + + def handle_chat_message(msg) + raise NotImplementedError + end + +Lets try this example out using Telnet: + + ~ telnet localhost 10000 + Trying 127.0.0.1... + Connected to localhost. + Escape character is '^]'. + [info] Enter your username: + antares_ + [info] Ohai, antares_ + +and the server output: + + A client has connected... + antares_ has joined + +This version requires you to remember how to terminate your Telnet session (Ctrl + Shift + ], then Ctrl + C). +It is annoying, so why don't we add the same `exit` command to our chat server? + + +### Step four: adding exit command and delivering chat messages #### + +{include:file:examples/guides/getting\_started/07\_simple\_chat\_server\_step\_four.rb} + +TBD + +Lets test-drive this version. Client A: + + ~ telnet localhost 10000 + Trying 127.0.0.1... + Connected to localhost. + Escape character is '^]'. + [info] Enter your username: + michael + [info] Ohai, michael + Hi everyone + michael: Hi everyone + joe has joined the room + # here ^^^ client B connects, lets greet him + hi joe + michael: hi joe + joe: hey michael + # ^^^ client B replies + exit + # ^^^ out command in action + Connection closed by foreign host. + +Client B: + + ~ telnet localhost 10000 + Trying 127.0.0.1... + Connected to localhost. + Escape character is '^]'. + [info] Enter your username: + joe + [info] Ohai, joe + michael: hi joe + # ^^^ client A greets us, lets reply + hey michael + joe: hey michael + exit + # ^^^ out command in action + Connection closed by foreign host. + +And finally, the server output: + + A client has connected... + michael has joined + A client has connected... + _antares has joined + [info] _antares has left + [info] michael has left + +Our little char server now supports usernames, sending messages and the `exit` command. Next up, private (aka direct) messages. + + +### Step five: adding direct messages and one more command ### + +To add direct messages, we come up with a simple convention: private messages begin with @username and may have optional colon before +message text, like this: + + @joe: hey, how do you like eventmachine? + +This convention makes parsing of messages simple so that we can concentrate on delivering them to a particular client connection. +Remember when we added `username` reader on our connection class? That tiny change makes this step possible: when a new direct +message comes in, we extract username and message text and then find then connection for @username in question: + + # + # Message handling + # + + def handle_chat_message(msg) + if command?(msg) + self.handle_command(msg) + else + if direct_message?(msg) + self.handle_direct_message(msg) + else + self.announce(msg, "#{@username}:") + end + end + end # handle_chat_message(msg) + + def direct_message?(input) + input =~ DM_REGEXP + end # direct_message?(input) + + def handle_direct_message(input) + username, message = parse_direct_message(input) + + if connection = @@connected_clients.find { |c| c.username == username } + puts "[dm] @#{@username} => @#{username}" + connection.send_line("[dm] @#{@username}: #{message}") + else + send_line "@#{username} is not in the room. Here's who is: #{usernames.join(', ')}" + end + end # handle_direct_message(input) + + def parse_direct_message(input) + return [$1, $2] if input =~ DM_REGEXP + end # parse_direct_message(input) + +This snippet demonstrates how one connection instance can obtain another connection instance and send data to it. +This is a very powerful feature, consider just a few use cases: + + * Peer-to-peer protocols + * Content-aware routing + * Efficient streaming with optional filtering + +Less common use cases include extending C++ core of EventMachine to provide access to hardware that streams events that +can be re-broadcasted to any interested parties connected via TCP, UDP or something like AMQP or WebSockets. With this, +sky is the limit. Actually, EventMachine has several features for efficient proxying data between connections. +We will not cover them in this guide. + +One last feature that we are going to add to our chat server is the `status` command that tells you current server time and how many people +are there in the chat room: + + # + # Commands handling + # + + def command?(input) + input =~ /(exit|status)$/i + end # command?(input) + + def handle_command(cmd) + case cmd + when /exit$/i then self.close_connection + when /status$/i then self.send_line("[chat server] It's #{Time.now.strftime('%H:%M')} and there are #{self.number_of_connected_clients} people in the room") + end + end # handle_command(cmd) + +Hopefully this piece of code is easy to follow. Try adding a few more commands, for example, the `whoishere` command that lists people +currently in the chat room. + +In the end, our chat server looks like this: + +{include:file:examples/guides/getting\_started/08\_simple\_chat\_server\_step\_five.rb} + +We are almost done with the server but there are some closing thoughts. + + +### Step six: final version ### + +Just in case, here is the final version of the chat server code we have built: + +{include:file:examples/guides/getting\_started/03\_simple\_chat\_server.rb} + + +### Step seven: future directions and some closing thoughts ### + +The chat server is just about 150 lines of Ruby including empty lines and comments, yet it has a few features most of chat server +examples never add. We did not, however, implement many other features that popular IRC clients like [Colloquy](http://colloquy.info) have: + + * Chat moderation + * Multiple rooms + * Connection timeout detection + +How would one go about implementing them? We thought it is worth discussing what else EventMachine has to offer and what ecosystem projects +one can use to build a really feature-rich Web-based IRC chat client. + +With multiple rooms it's more or less straightforward, just add one more hash and a bunch of commands and use the information about which rooms participant +is in when you are delivering messages. There is nothing in EventMachine itself that can make the job much easier for developer. + +To implement chat moderation feature you may want to do a few things: + + * Work with client IP addresses. Maybe we want to consider everyone who connects from certain IPs a moderator. + * Access persistent data about usernames of moderators and their credentials. + +Does EventMachine have anything to offer here? It does. To obtain peer IP address, take a look at {EventMachine::Connection#get_peername}. The name of this method is +a little bit misleading and originates from low-level socket programming APIs. + +#### A whirlwind tour of the EventMachine ecosystem #### + +To work with data stores you can use several database drivers that ship with EventMachine itself, however, quite often there are some 3rd party projects in +the EventMachine ecosystem that have more features, are faster or just better maintained. So we figured it will be helpful to provide a few pointers +to some of those projects: + + * For MySQL, check out [em-mysql](https://github.com/eventmachine/em-mysql) project. + * For PostgreSQL, have a look at Mike Perham's [EventMachine-based PostgreSQL driver](https://github.com/mperham/em_postgresql). + * For Redis, there is a young but already popular [em-hiredis](https://github.com/mloughran/em-hiredis) library that combines EventMachine's non-blocking I/O with + extreme performance of the official Redis C client, [hiredis](https://github.com/antirez/hiredis). + * For MongoDB, see [em-mongo](https://github.com/bcg/em-mongo) + * For Cassandra, Mike Perham [added transport agnosticism feature](http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/) to the [cassandra gem](https://rubygems.org/gems/cassandra). + +[Riak](http://www.basho.com/products_riak_overview.php) and CouchDB talk HTTP so it's possible to use [em-http-request](https://github.com/igrigorik/em-http-request). +If you are aware of EventMachine-based non-blocking drivers for these databases, as well as for HBase, let us know on the [EventMachine mailing list](http://groups.google.com/group/eventmachine). +Also, EventMachine supports TLS (aka SSL) and works well on [JRuby](http://jruby.org) and Windows. + +Learn more in our {file:docs/Ecosystem.md EventMachine ecosystem} and {file:docs/TLS.md TLS (aka SSL)} guides. + + +#### Connection loss detection #### + +Finally, connection loss detection. When our chat participant closes her laptop lid, how do we know that she is no longer active? The answer is, when EventMachine +detects TCP connectin closure, it calls {EventMachine::Connection#unbind}. Version 1.0.beta3 and later also pass an optional argument to that method. The argument +indicates what error (if any) caused the connection to be closed. + +Learn more in our {file:docs/ConnectionFailureAndRecovery.md Connection Failure and Recovery} guide. + + +#### What the Chat Server Example doesn't demonstrate #### + +This chat server also leaves out something production quality clients and servers must take care of: buffering. We intentionally did not include any buffering in +our chat server example: it would only distract you from learning what you really came here to learn: how to use EventMachine to build blazing fast asynchronous +networking programs quickly. However, {EventMachine::Connection#receive_data} does not offer any guarantees that you will be receiving "whole messages" all the time, +largely because the underlying transport (UDP or TCP) does not offer such guarantees. Many protocols, for example, AMQP, mandate that large content chunks are +split into smaller _frames_ of certain size. This means that [amq-client](https://github.com/ruby-amqp/amq-client) library, for instance, that has EventMachine-based driver, +has to deal with figuring out when exactly we received "the whole message". To do so, it uses buffering and employs various checks to detect _frame boundaries_. +So **don't be deceived by the simplicity of this chat example**: it intentionally leaves framing out, but real world protocols usually require it. + + + +## A (Proxying) Chat Client Example ## + +TBD + + +## Wrapping up ## + +This tutorial ends here. Congratulations! You have learned quite a bit about EventMachine. + + +## What to read next ## + +The documentation is organized as a {file:docs/DocumentationGuidesIndex.md number of guides}, covering all kinds of +topics. TBD + + +## Tell us what you think! ## + +Please take a moment and tell us what you think about this guide on the [EventMachine mailing list](http://bit.ly/jW3cR3) +or in the #eventmachine channel on irc.freenode.net: what was unclear? What wasn't covered? +Maybe you don't like the guide style or the grammar and spelling are incorrect? Reader feedback is +key to making documentation better. diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/ChangeLog b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/ChangeLog new file mode 100644 index 0000000..c7a6c48 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/ChangeLog @@ -0,0 +1,211 @@ +01Oct06: Replaced EventMachine#open_datagram_server with a version that can + take a Class or a Module, instead of just a Module. Thanks to Tobias + Gustafsson for pointing out the missing case. +04Oct06: Supported subsecond timer resolutions, per request by Jason Roelofs. +05Oct06: Added EventMachine#set_quantum, which sets the timer resolution. +15Nov06: Added Connection#set_comm_inactivity_timeout. +15Nov06: Checked in a Line-and-Text Protocol Handler. +18Nov06: Checked in a Header-and-Body Protocol Handler. +22Nov06: Changed EventMachine#reconnect: no longer excepts when called on an + already-connected handler. +28Nov06: Supported a binary-unix gem. +19Dec06: Added EventMachine#set_effective_user. +05Jan07: Upped max outstanding timers to 1000. +15May07: Applied Solaris patches from Brett Eisenberg +22May07: Cleaned up the license text in all the source files. +22May07: Released version 0.7.2 + +23May07: Per suggestion from Bill Kelly, fixed a bug with the initialization + of the network libraries under Windows. The goal is to enable EM to + be used without Ruby. +28May07: Applied patch from Bill Kelly, refactors the declarations of + event names to make EM easier to use from C programs without Ruby. +31May07: Added a preliminary implementation of EventMachine#popen. +01Jun07: Added EM, a "pseudo-alias" for EventMachine. +01Jun07: Added EM#next_tick. +01Jun07: Added EM::Connection#get_outbound_data_size +05Jun07: Removed the code which loads a pure-Ruby EM library in case the + compiled extension is unavailable. Suggested by Moshe Litvin. +06Jun07: Preliminary epoll implementation. +12Jun07: Added an evented popen implementation that, like Ruby's, is + full-duplex and makes the subprocess PID available to the caller. +06Jul07: Performance-tweaked the callback dispatcher in eventmachine.rb. +10Jul07: Released version 0.8.0. +12Jul07: Applied patches from Tim Pease to fix Solaris build problems. +15Jul07: Created a new provisional source branch, experiments/jruby-1. + This is a preliminary implementation of the EM reactor in Java, + suitable for use with JRuby. +17Jul07: Added EventMachine#stop_server, per request from Kirk Haines, + and associated unit tests. +22Jul07: Added EventMachine#stream_file_data. This is a very fast and scalable + way of sending data from static files over network connections. It + has separate implementations for small files and large file, and + has tunings to minimize memory consumption. +26Jul07: Added some patches by Kirk Haines to improve the behavior of + EM::Connection#send_file_data_to_connection. +26Jul07: Added a C++ module for directly integrating EM into C++ programs + with no Ruby dependencies. Needs example code. +29Jul07: Added EventMachine::Protocols::LineText2. +29Jul07: Added EventMachine::Protocols::Stomp. +30Jul07: Added sys/stat.h to project.h to fix compilation bug on Darwin. +13Aug07: Added EventMachine#reactor_running? +15Aug07: Added parameters for EventMachine::Connection:start_tls that can be + used to specify client-side private keys and certificates. +17Aug07: Added EventMachine#run_block, a sugaring for a common use case. +24Aug07: Added a preliminary keyboard handler. Needs docs and testing on + windows. +26Aug07: Created EventMachine::Spawnable, an implementation of Erlang-like + processes. +27Aug07: Silenced some -w warnings, requested by James Edward Gray II. +30Aug07: Added cookies to EM::HttpClient#request. +04Sep07: Added an initial implementation of an evented SMTP client. +04Sep07: Added an initial implementation of an evented SMTP server. +10Sep07: Changed EM#spawn to run spawned blocks in the context of the + SpawnedProcess object, not of whatever was the active object at the + time of the spawn. +14Sep07: Heartbeats weren't working with EPOLL. Noticed by Brian Candler. +15Sep07: Added some features, tests and documents to Deferrable. +16Sep07: Added [:content] parameter to EM::Protocols::SmtpClient#send. +16Sep07: Bumped version to 0.9.0 in anticipation of a release. +18Sep07: Released version 0.9.0. +19Sep07: Added #receive_reset to EM::Protocols::SmtpServer. +19Sep07: User overrides of EM::Protocols::SmtpServer#receive_recipient can now + return a Deferrable. Also fixed bug: SmtpClient now raises a protocol + error if none of its RCPT TO: commands are accepted by the server. +26Sep07: Fixed missing keyboard support for Windows. +03Oct07: Added a default handler for RuntimeErrors emitted from user-written + code. Suggested by Brian Candler. +19Oct07: Set the SO_BROADCAST option automatically on all UDP sockets. +10Nov07: Forced integer conversion of send_datagram's port parameter. +Suggested by Matthieu Riou. +12Nov07: Added saslauth.rb, a protocol module to replace the Cyrus SASL +daemons saslauthd and pwcheck. +15Nov07: Fixed bug reported by Mark Zvillius. We were failing to dispatch + zero-length datagrams under certain conditions. +19Nov07: Added EventMachine#set_max_timers. Requested by Matthieu Riou and + others. +19Nov07: Fixed bug with EM::Connection#start_tls. Was not working with server + connections. Reported by Michael S. Fischer. +26Nov07: Supported a hack for EventMachine#popen so it can return an exit + status from subprocesses. Requested by Michael S. Fischer. +30Nov07: Changed Pipe descriptors so that the child-side of the socketpair is + NOT set nonblocking. Suggested by Duane Johnson. +05Dec07: Re-enabled the pure-Ruby implementation. +06Dec07: Released Version 0.10.0. +13Dec07: Added EM::DeferrableChildProcess +24Dec07: Added a SASL client for simple password authentication. +27Dec07: Removed the hookable error handler. No one was using it and it significantly + degraded performance. +30Dec07: Implemented Kqueue support for OSX and BSD. +04Jan08: Fixed bug in epoll ("Bad file descriptor"), patch supplied by Chris + Heath. +04Jan08: Fixed bug reported by Michael S. Fischer. We were terminating + SSL connections that sent data before the handshake was complete. +08Jan08: Added an OpenBSD branch for extconf.rb, contributed by Guillaume + Sellier. +19Jan08: Added EM::Connection::get_sockname per request by Michael Fischer. +19Jan08: Supported IPv6 addresses. +30Apr08: Set the NODELAY option on sockets that we connect to other servers. + Omission noted by Roger Pack. +14May08: Generated a 0.12 release. +15May08: Supported EM#get_sockname for acceptors (TCP server sockets). + Requested by Roger Pack. +15May08; Accepted a patch from Dan Aquino that allows the interval of a + PeriodicTimer to be changed on the fly. +15Jun08: Supported nested calls to EM#run. Many people contributed ideas to + this, notably raggi and tmm1. +20Jul08: Accepted patch from tmm1 for EM#fork_reactor. +28Jul08: Added a Postgres3 implementation, written by FCianfrocca. +14Aug08: Added a patch by Mike Murphy to support basic auth in the http +client. +28Aug08: Added a patch by tmm1 to fix a longstanding problem with Java +data-sends. +13Sep08: Added LineText2#set_binary_mode, a back-compatibility alias. +13Sep08: Modified the load order of protocol libraries in eventmachine.rb + to permit a modification of HeaderAndContentProtocol. +13Sep08: Modified HeaderAndContent to use LineText2, which is less buggy + than LineAndTextProtocol. This change may be reversed if we can fix + the bugs in buftok. +13Sep08: Improved the password handling in the Postgres protocol handler. +15Sep08: Added attach/detach, contributed by Aman Gupta (tmm1) and Riham Aldakkak, + to support working with file descriptors not created in the reactor. +16Sep08: Added an optional version string to the HTTP client. This is a hack + that allows a client to specify a version 1.0 request, which + keeps the server from sending a chunked response. The right way to + solve this, of course, is to support chunked responses. +23Sep08: ChangeLog Summary for Merge of branches/raggi +Most notable work and patches by Aman Gupta, Roger Pack, and James Tucker. +Patches / Tickets also submitted by: Jeremy Evans, aanand, darix, mmmurf, +danielaquino, macournoyer. + - Moved docs into docs/ dir + - Major refactor of rakefile, added generic rakefile helpers in tasks + - Added example CPP build rakefile in tasks/cpp.rake + - Moved rake tests out to tasks/tests.rake + - Added svn ignores where appropriate + - Fixed jruby build on older java platforms + - Gem now builds from Rakefile rather than directly via extconf + - Gem unified for jruby, C++ and pure ruby. + - Correction for pure C++ build, removing ruby dependency + - Fix for CYGWIN builds on ipv6 + - Major refactor for extconf.rb + - Working mingw builds + - extconf optionally uses pkg_config over manual configuration + - extconf builds for 1.9 on any system that has 1.9 + - extconf no longer links pthread explicitly + - looks for kqueue on all *nix systems + - better error output on std::runtime_error, now says where it came from + - Fixed some tests on jruby + - Added test for general send_data flaw, required for a bugfix in jruby build + - Added timeout to epoll tests + - Added fixes for java reactor ruby api + - Small addition of some docs in httpclient.rb and httpcli2.rb + - Some refactor and fixes in smtpserver.rb + - Added parenthesis where possible to avoid excess ruby warnings + - Refactor of $eventmachine_library logic for accuracy and maintenance, jruby + - EM::start_server now supports unix sockets + - EM::connect now supports unix sockets + - EM::defer @threadqueue now handled more gracefully + - Added better messages on exceptions raised + - Fix edge case in timer fires + - Explicitly require buftok.rb + - Add protocols to autoload, rather than require them all immediately + - Fix a bug in pr_eventmachine for outbound_q + - Refactors to take some of the use of defer out of tests. + - Fixes in EM.defer under start/stop conditions. Reduced scope of threads. +23Sep08: Added patch from tmm1 to avoid popen errors on exit. +30Sep08: Added File.exists? checks in the args for start_tls, as suggested by + Brian Lopez (brianmario). +10Nov08: ruby 1.9 compatibility enhancements +28Nov08: Allow for older ruby builds where RARRAY_LEN is not defined +03Dec08: allow passing arguments to popen handlers +13Jan09: SSL support for httpclient2 (David Smalley) +22Jan09: Fixed errors on OSX with the kqueue reactor, fixed errors in the pure + ruby reactor. Added EM.current_time. Added EM.epoll? and EM.kqueue? +27Jan09: Reactor errors are now raised as ruby RuntimeErrors. +28Jan09: Documentation patch from alloy +29Jan09: (Late sign-off) Use a longer timeout for connect_server (Ilya + Grigorik) +07Feb09: Fix signal handling issues with threads+epoll +07Feb09: Use rb_thread_schedule in the epoll reactor +07Feb09: Use TRAP_BEG/END and rb_thread_schedule in kqueue reactor +08Feb09: Added fastfilereader from swiftiply +08Feb09: 1.9 fix for rb_trap_immediate +08Feb09: Enable rb_thread_blocking_region for 1.9.0 and 1.9.1 +10Feb09: Support win32 builds for fastfilereader +10Feb09: Added a new event to indicate completion of SSL handshake on TCP + connections +10Feb09: Working get_peer_cert method. Returns the certificate as a Ruby + String in PEM format. (Jake Douglas) +10Feb09: Added EM.get_max_timers +11Feb09: Fix compile options for sun compiler (Alasdairrr) +11Feb09: get_status returns a Process::Status object +12Feb09: Add EM::Protocols::Memcache with simple get/set functionality +19Feb09: Add catch-all EM.error_handler +20Feb09: Support miniunit (1.9) +20Feb09: Return success on content-length = 0 instead of start waiting forever + (Ugo Riboni) +25Feb09: Allow next_tick to be used to pre-schedule reactor operations before + EM.run +26Feb09: Added EM.get_connection_count +01Mar09: Switch back to extconf for compiling gem extensions +01Mar09: fixed a small bug with basic auth (mmmurf) diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/DEFERRABLES b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/DEFERRABLES new file mode 100644 index 0000000..6e8856c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/DEFERRABLES @@ -0,0 +1,246 @@ +EventMachine (EM) adds two different formalisms for lightweight concurrency +to the Ruby programmer's toolbox: spawned processes and deferrables. This +note will show you how to use deferrables. For more information, see the +separate document LIGHTWEIGHT_CONCURRENCY. + +=== What are Deferrables? + +EventMachine's Deferrable borrows heavily from the "deferred" object in +Python's "Twisted" event-handling framework. Here's a minimal example that +illustrates Deferrable: + + require 'eventmachine' + + class MyClass + include EM::Deferrable + + def print_value x + puts "MyClass instance received #{x}" + end + end + + EM.run { + df = MyClass.new + df.callback {|x| + df.print_value(x) + EM.stop + } + + EM::Timer.new(2) { + df.set_deferred_status :succeeded, 100 + } + } + + +This program will spin for two seconds, print out the string "MyClass +instance received 100" and then exit. The Deferrable pattern relies on +an unusual metaphor that may be unfamiliar to you, unless you've used +Python's Twisted. You may need to read the following material through +more than once before you get the idea. + +EventMachine::Deferrable is simply a Ruby Module that you can include +in your own classes. (There also is a class named +EventMachine::DefaultDeferrable for when you want to create one without +including it in code of your own.) + +An object that includes EventMachine::Deferrable is like any other Ruby +object: it can be created whenever you want, returned from your functions, +or passed as an argument to other functions. + +The Deferrable pattern allows you to specify any number of Ruby code +blocks (callbacks or errbacks) that will be executed at some future time +when the status of the Deferrable object changes. + +How might that be useful? Well, imagine that you're implementing an HTTP +server, but you need to make a call to some other server in order to fulfill +a client request. + +When you receive a request from one of your clients, you can create and +return a Deferrable object. Some other section of your program can add a +callback to the Deferrable that will cause the client's request to be +fulfilled. Simultaneously, you initiate an event-driven or threaded client +request to some different server. And then your EM program will continue to +process other events and service other client requests. + +When your client request to the other server completes some time later, you +will call the #set_deferred_status method on the Deferrable object, passing +either a success or failure status, and an arbitrary number of parameters +(which might include the data you received from the other server). + +At that point, the status of the Deferrable object becomes known, and its +callback or errback methods are immediately executed. Callbacks and errbacks +are code blocks that are attached to Deferrable objects at any time through +the methods #callback and #errback. + +The deep beauty of this pattern is that it decouples the disposition of one +operation (such as a client request to an outboard server) from the +subsequent operations that depend on that disposition (which may include +responding to a different client or any other operation). + +The code which invokes the deferred operation (that will eventually result +in a success or failure status together with associated data) is completely +separate from the code which depends on that status and data. This achieves +one of the primary goals for which threading is typically used in +sophisticated applications, with none of the nondeterminacy or debugging +difficulties of threads. + +As soon as the deferred status of a Deferrable becomes known by way of a call +to #set_deferred_status, the Deferrable will IMMEDIATELY execute all of its +callbacks or errbacks in the order in which they were added to the Deferrable. + +Callbacks and errbacks can be added to a Deferrable object at any time, not +just when the object is created. They can even be added after the status of +the object has been determined! (In this case, they will be executed +immediately when they are added.) + +A call to Deferrable#set_deferred_status takes :succeeded or :failed as its +first argument. (This determines whether the object will call its callbacks +or its errbacks.) #set_deferred_status also takes zero or more additional +parameters, that will in turn be passed as parameters to the callbacks or +errbacks. + +In general, you can only call #set_deferred_status ONCE on a Deferrable +object. A call to #set_deferred_status will not return until all of the +associated callbacks or errbacks have been called. If you add callbacks or +errbacks AFTER making a call to #set_deferred_status, those additional +callbacks or errbacks will execute IMMEDIATELY. Any given callback or +errback will be executed AT MOST once. + +It's possible to call #set_deferred_status AGAIN, during the execution a +callback or errback. This makes it possible to change the parameters which +will be sent to the callbacks or errbacks farther down the chain, enabling +some extremely elegant use-cases. You can transform the data returned from +a deferred operation in arbitrary ways as needed by subsequent users, without +changing any of the code that generated the original data. + +A call to #set_deferred_status will not return until all of the associated +callbacks or errbacks have been called. If you add callbacks or errbacks +AFTER making a call to #set_deferred_status, those additional callbacks or +errbacks will execute IMMEDIATELY. + +Let's look at some more sample code. It turns out that many of the internal +protocol implementations in the EventMachine package rely on Deferrable. One +of these is EM::Protocols::HttpClient. + +To make an evented HTTP request, use the module function +EM::Protocols::HttpClient#request, which returns a Deferrable object. +Here's how: + + require 'eventmachine' + + EM.run { + df = EM::Protocols::HttpClient.request( :host=>"www.example.com", + :request=>"/index.html" ) + + df.callback {|response| + puts "Succeeded: #{response[:content]}" + EM.stop + } + + df.errback {|response| + puts "ERROR: #{response[:status]}" + EM.stop + } + } + +(See the documentation of EventMachine::Protocols::HttpClient for information +on the object returned by #request.) + +In this code, we make a call to HttpClient#request, which immediately returns +a Deferrable object. In the background, an HTTP client request is being made +to www.example.com, although your code will continue to run concurrently. + +At some future point, the HTTP client request will complete, and the code in +EM::Protocols::HttpClient will process either a valid HTTP response (including +returned content), or an error. + +At that point, EM::Protocols::HttpClient will call +EM::Deferrable#set_deferred_status on the Deferrable object that was returned +to your program, as the return value from EM::Protocols::HttpClient.request. +You don't have to do anything to make this happen. All you have to do is tell +the Deferrable what to do in case of either success, failure, or both. + +In our code sample, we set one callback and one errback. The former will be +called if the HTTP call succeeds, and the latter if it fails. (For +simplicity, we have both of them calling EM#stop to end the program, although +real programs would be very unlikely to do this.) + +Setting callbacks and errbacks is optional. They are handlers to defined +events in the lifecycle of the Deferrable event. It's not an error if you +fail to set either a callback, an errback, or both. But of course your +program will then fail to receive those notifications. + +If through some bug it turns out that #set_deferred_status is never called +on a Deferrable object, then that object's callbacks or errbacks will NEVER +be called. It's also possible to set a timeout on a Deferrable. If the +timeout elapses before any other call to #set_deferred_status, the Deferrable +object will behave as is you had called set_deferred_status(:failed) on it. + + +Now let's modify the example to illustrate some additional points: + + require 'eventmachine' + + EM.run { + df = EM::Protocols::HttpClient.request( :host=>"www.example.com", + :request=>"/index.html" ) + + df.callback {|response| + df.set_deferred_status :succeeded, response[:content] + } + + df.callback {|string| + puts "Succeeded: #{string}" + EM.stop + } + + df.errback {|response| + puts "ERROR: #{response[:status]}" + EM.stop + } + } + + +Just for the sake of illustration, we've now set two callbacks instead of +one. If the deferrable operation (the HTTP client-request) succeeds, then +both of the callbacks will be executed in order. + +But notice that we've also made our own call to #set_deferred_status in the +first callback. This isn't required, because the HttpClient implementation +already made a call to #set_deferred_status. (Otherwise, of course, the +callback would not be executing.) + +But we used #set_deferred_status in the first callback in order to change the +parameters that will be sent to subsequent callbacks in the chain. In this +way, you can construct powerful sequences of layered functionality. If you +want, you can even change the status of the Deferrable from :succeeded to +:failed, which would abort the chain of callback calls, and invoke the chain +of errbacks instead. + +Now of course it's somewhat trivial to define two callbacks in the same +method, even with the parameter-changing effect we just described. It would +be much more interesting to pass the Deferrable to some other function (for +example, a function defined in another module or a different gem), that would +in turn add callbacks and/or errbacks of its own. That would illustrate the +true power of the Deferrable pattern: to isolate the HTTP client-request +from other functions that use the data that it returns without caring where +those data came from. + +Remember that you can add a callback or an errback to a Deferrable at any +point in time, regardless of whether the status of the deferred operation is +known (more precisely, regardless of when #set_deferred_status is called on +the object). Even hours or days later. + +When you add a callback or errback to a Deferrable object on which +#set_deferred_status has not yet been called, the callback/errback is queued +up for future execution, inside the Deferrable object. When you add a +callback or errback to a Deferrable on which #set_deferred_status has +already been called, the callback/errback will be executed immediately. +Your code doesn't have to worry about the ordering, and there are no timing +issues, as there would be with a threaded approach. + +For more information on Deferrables and their typical usage patterns, look +in the EM unit tests. There are also quite a few sugarings (including +EM::Deferrable#future) that make typical Deferrable usages syntactically +easier to work with. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/EPOLL b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/EPOLL new file mode 100644 index 0000000..13cea8f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/EPOLL @@ -0,0 +1,141 @@ +EventMachine now supports epoll, bringing large increases in performance and scalability to Ruby programs. + +Epoll(7) is a alternative mechanism for multiplexed I/O that is available in Linux 2.6 kernels. +It features significantly greater performance than the standard select(2) mechanism, when used in +applications that require very large numbers of open I/O descriptors. + +EventMachine has always used select(2) because its behavior is well standardized and broadly supported. +But select becomes unreasonably slow when a program has a +very large number of file descriptors or sockets. Ruby's version of select hardcodes a limit +of 1024 descriptors per process, but heavily loaded processes will start to show performance +degradation even after only a few hundred descriptors are in use. + +Epoll is an extended version of the poll(2) call, and it solves the problems with select. Programs +based on epoll can easily scale past Ruby's 1024-descriptor limit, potentially to tens of thousands +of connectors, with no significant impact on performance. + +(Another alternative which is very similar to epoll in principle is kqueue, supplied on BSD and its +variants.) + + + +This note shows you how to use epoll in your programs. + +=== Compiling EventMachine to use epoll. + +You don't have to do anything to get epoll support in EventMachine. +When you compile EventMachine on a platform that supports epoll, EM will +automatically generate a Makefile that includes epoll. (At this writing, this will only work +on Linux 2.6 kernels.) If you compile EM on a platform without epoll, then epoll support will +be omitted from the Makefile, and EM will work just as it always has. + +=== Using epoll in your programs. + +First, you need to tell EventMachine to use epoll instead of select (but see below, as this requirement +will be removed in a future EventMachine version). Second, you need to prepare your program to use +more than 1024 descriptors, an operation that generally requires superuser privileges. Third, you will probably +want your process to drop the superuser privileges after you increase your process's descriptor limit. + +=== Using EventMachine#epoll + +Call the method EventMachine#epoll anytime before you call EventMachine#run, and your program will +automatically use epoll, if available. It's safe to call EventMachine#epoll on any platform because +it compiles to a no-op on platforms that don't support epoll. + + require 'rubygems' + require 'eventmachine' + + EM.epoll + EM.run { + ... + } + + +EventMachine#epoll was included in this initial release only to avoid changing the behavior of existing +programs. However, it's expected that a future release of EM will convert EventMachine#epoll to a no-op, +and run epoll by default on platforms that support it. + +=== Using EventMachine#set_descriptor_table_size + +In Linux (as in every Unix-like platform), every process has a internal table that determines the maximum +number of file and socket descriptors you may have open at any given time. The size of this table is +generally fixed at 1024, although it may be increased within certain system-defined hard and soft limits. + +If you want your EventMachine program to support more than 1024 total descriptors, you must use +EventMachine#set_descriptor_table_size, as follows: + + require 'rubygems' + require 'eventmachine' + + new_size = EM.set_descriptor_table_size( 60000 ) + $>.puts "New descriptor-table size is #{new_size}" + + EM.run { + ... + } + +If successful, this example will increase the maximum number of descriptors that epoll can use to 60,000. +Call EventMachine#set_descriptor_table_size without an argument at any time to find out the current +size of the descriptor table. + +Using EventMachine#set_descriptor_table_size ONLY affects the number of descriptors that can be used +by epoll. It has no useful effect on platforms that don't support epoll, and it does NOT increase the +number of descriptors that Ruby's own I/O functions can use. + +#set_descriptor_table_size can fail if your process is not running as superuser, or if you try to set a +table size that exceeds the hard limits imposed by your system. In the latter case, try a smaller number. + + +=== Using EventMachine#set_effective_user + +In general, you must run your program with elevated or superuser privileges if you want to increase +your descriptor-table size beyond 1024 descriptors. This is easy enough to verify. Try running the +sample program given above, that increases the descriptor limit to 60,000. You will probably find that +the table size will not be increased if you don't run your program as root or with elevated privileges. + +But of course network servers, especially long-running ones, should not run with elevated privileges. +You will want to drop superuser privileges as soon as possible after initialization. To do this, +use EventMachine#set_effective_user: + + require 'rubygems' + require 'eventmachine' + + # (Here, program is running as superuser) + + EM.set_descriptor_table_size( 60000 ) + EM.set_effective_user( "nobody" ) + # (Here, program is running as nobody) + + EM.run { + ... + } + +Of course, you will need to replace "nobody" in the example with the name of an unprivileged user +that is valid on your system. What if you want to drop privileges after opening a server socket +on a privileged (low-numbered) port? Easy, just call #set_effective_user after opening your sockets: + + require 'rubygems' + require 'eventmachine' + + # (Here, program is running as superuser) + + EM.set_descriptor_table_size( 60000 ) + + EM.run { + EM.start_server( "0.0.0.0", 80, MyHttpServer ) + EM.start_server( "0.0.0.0", 443, MyEncryptedHttpServer ) + + EM.set_effective_user( "nobody" ) + # (Here, program is running as nobody) + + ... + } + + +Because EventMachine#set_effective_user is used to enforce security +requirements, it has no nonfatal errors. If you try to set a nonexistent or invalid effective user, +#set_effective_user will abort your program, rather than continue to run with elevated privileges. + +EventMachine#set_effective_user is a silent no-op on platforms that don't support it, such as Windows. + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/INSTALL b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/INSTALL new file mode 100644 index 0000000..dee2e42 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/INSTALL @@ -0,0 +1,13 @@ +If you have obtained an EventMachine source-tarball (.tar.gz): +unzip and untar the tarball, and enter the directory that is +created. In that directory, say: +ruby setup.rb +(You may need to be root to execute this command.) + +To create documentation for EventMachine, simply type: +rake rdoc +in the distro directory. Rdocs will be created in subdirectory rdoc. + +If you have obtained a gem version of EventMachine, install it in the +usual way (gem install eventmachine). You may need superuser privileges +to execute this command. diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/KEYBOARD b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/KEYBOARD new file mode 100644 index 0000000..6c699e4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/KEYBOARD @@ -0,0 +1,42 @@ +EventMachine (EM) can respond to keyboard events. This gives your event-driven +programs the ability to respond to input from local users. + +Programming EM to handle keyboard input in Ruby is simplicity itself. Just use +EventMachine#open_keyboard, and supply the name of a Ruby module or class that +will receive the input: + + require 'rubygems' + require 'eventmachine' + + module MyKeyboardHandler + def receive_data keystrokes + puts "I received the following data from the keyboard: #{keystrokes}" + end + end + + EM.run { + EM.open_keyboard(MyKeyboardHandler) + } + +If you want EM to send line-buffered keyboard input to your program, just +include the LineText2 protocol module in your handler class or module: + + require 'rubygems' + require 'eventmachine' + + module MyKeyboardHandler + include EM::Protocols::LineText2 + def receive_line data + puts "I received the following line from the keyboard: #{data}" + end + end + + EM.run { + EM.open_keyboard(MyKeyboardHandler) + } + +As we said, simplicity itself. You can call EventMachine#open_keyboard at any +time while the EM reactor loop is running. In other words, the method +invocation may appear anywhere in an EventMachine#run block, or in any code +invoked in the #run block. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/LEGAL b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/LEGAL new file mode 100644 index 0000000..ee01825 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/LEGAL @@ -0,0 +1,25 @@ +LEGAL NOTICE INFORMATION +------------------------ + +EventMachine is Copyright (C) 2006-07 by Francis Cianfrocca. + +EventMachine is copyrighted software owned by Francis Cianfrocca +(blackhedd ... gmail.com). You may redistribute and/or modify this +software as long as you comply with either the terms of the GPL +(see the file GPL), or Ruby's license (see the file COPYING). + +Your use of all the files in this distribution is controlled by these +license terms, except for those files specifically mentioned below: + + + +setup.rb + This file is Copyright (C) 2000-2005 by Minero Aoki + You can distribute/modify this file under the terms of + the GNU LGPL, Lesser General Public License version 2.1. + + +lib/em/buftok.rb + This file is Copyright (C) 2007 by Tony Arcieri. This file is + covered by the terms of Ruby's License (see the file COPYING). + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/LIGHTWEIGHT_CONCURRENCY b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/LIGHTWEIGHT_CONCURRENCY new file mode 100644 index 0000000..3c2cfa0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/LIGHTWEIGHT_CONCURRENCY @@ -0,0 +1,130 @@ +EventMachine (EM) adds two different formalisms for lightweight concurrency to +the Ruby programmer's toolbox: spawned processes and deferrables. This note +will show you how to use them. + + +=== What is Lightweight Concurrency? + +We use the term "Lightweight Concurrency" (LC) to refer to concurrency +mechanisms that are lighter than Ruby threads. By "lighter," we mean: less +resource-intensive in one or more dimensions, usually including memory and +CPU usage. In general, you turn to LC in the hope of improving the +performance and scalability of your programs. + +In addition to the two EventMachine mechanisms we will discuss here, Ruby +has at least one other LC construct: Fibers, which are currently under +development in Ruby 1.9. + +The technical feature that makes all of these LC mechanisms different from +standard Ruby threads is that they are not scheduled automatically. + +When you create and run Ruby threads, you can assume (within certain +constraints) that your threads will all be scheduled fairly by Ruby's runtime. +Ruby itself is responsible for giving each of your threads its own share of +the total runtime. + +But with LC, your program is responsible for causing different execution +paths to run. In effect, your program has to act as a "thread scheduler." +Scheduled entities in LC run to completion and are never preempted. The +runtime system has far less work to do since it has no need to interrupt +threads or to schedule them fairly. This is what makes LC lighter and faster. + +You'll learn exactly how LC scheduling works in practice as we work through +specific examples. + + +=== EventMachine Lightweight Concurrency + +Recall that EM provides a reactor loop that must be running in order for +your programs to perform event-driven logic. An EM program typically has a +structure like this: + + require 'eventmachine' + + # your initializations + + EM.run { + # perform event-driven I/O here, including network clients, + # servers, timers, and thread-pool operations. + } + + # your cleanup + # end of the program + + +EventMachine#run executes the reactor loop, which causes your code to be +called as events of interest to your program occur. The block you pass to +EventMachine#run is executed right after the reactor loop starts, and is +the right place to start socket acceptors, etc. + +Because the reactor loop runs constantly in an EM program (until it is +stopped by a call to EventMachine#stop), it has the ability to schedule +blocks of code for asynchronous execution. Unlike a pre-emptive thread +scheduler, it's NOT able to interrupt code blocks while they execute. But +the scheduling capability it does have is enough to enable lightweight +concurrency. + + +For information on Spawned Processes, see the separate document +SPAWNED_PROCESSES. + +For information on Deferrables, see the separate document DEFERRABLES. + + +=== [SIDEBAR]: I Heard That EventMachine Doesn't Work With Ruby Threads. + +This is incorrect. EM is fully interoperable with all versions of Ruby +threads, and has been since its earliest releases. + +It's very true that EM encourages an "evented" (non-threaded) programming +style. The specific benefits of event-driven programming are far better +performance and scalability for well-written programs, and far easier +debugging. + +The benefit of using threads for similar applications is a possibly more +intuitive programming model, as well as the fact that threads are already +familiar to most programmers. Also, bugs in threaded programs often fail +to show up until programs go into production. These factors create the +illusion that threaded programs are easier to write. + +However, some operations that occur frequently in professional-caliber +applications simply can't be done without threads. (The classic example +is making calls to database client-libraries that block on network I/O +until they complete.) + +EventMachine not only allows the use of Ruby threads in these cases, but +it even provides a built-in thread-pool object to make them easier to +work with. + +You may have heard a persistent criticism that evented I/O is fundamentally +incompatible with Ruby threads. It is true that some well-publicized attempts +to incorporate event-handling libraries into Ruby were not successful. But +EventMachine was designed from the ground up with Ruby compatibility in mind, +so EM never suffered from the problems that defeated the earlier attempts. + + +=== [SIDEBAR]: I Heard That EventMachine Doesn't Work Very Well On Windows. + +This too is incorrect. EventMachine is an extension written in C++ and Java, +and therefore it requires compilation. Many Windows computers (and some Unix +computers, especially in production environments) don't have a build stack. +Attempting to install EventMachine on a machine without a compiler usually +produces a confusing error. + +In addition, Ruby has a much-debated issue with Windows compiler versions. +Ruby on Windows works best with Visual Studio 6, a compiler version that is +long out-of-print, no longer supported by Microsoft, and difficult to obtain. +(This problem is not specific to EventMachine.) + +Shortly after EventMachine was first released, the compiler issues led to +criticism that EM was incompatible with Windows. Since that time, every +EventMachine release has been supplied in a precompiled binary form for +Windows users, that does not require you to compile the code yourself. EM +binary Gems for Windows are compiled using Visual Studio 6. + +EventMachine does supply some advanced features (such as Linux EPOLL support, +reduced-privilege operation, UNIX-domain sockets, etc.) that have no +meaningful implementation on Windows. Apart from these special cases, all EM +functionality (including lightweight concurrency) works perfectly well on +Windows. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/PURE_RUBY b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/PURE_RUBY new file mode 100644 index 0000000..157d59e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/PURE_RUBY @@ -0,0 +1,75 @@ +EventMachine is supplied in three alternative versions. + +1) A version that includes a Ruby extension written in C++. This version requires compilation; +2) A version for JRuby that contains a precompiled JAR file written in Java; +3) A pure Ruby version that has no external dependencies and can run in any Ruby environment. + +The Java version of EventMachine is packaged in a distinct manner and must be installed using a +special procedure. This version is described fully in a different document, and not considered +further here. + +The C++ and pure-Ruby versions, however, are shipped in the same distribution. You use the same +files (either tarball or Ruby gem) to install both of these versions. + +If you intend to use the C++ version, you must successfully compile EventMachine after you install it. +(The gem installation attempts to perform this step automatically.) + +If you choose not to compile the EventMachine C++ extension, or if your compilation fails for any +reason, you still have a fully-functional installation of the pure-Ruby version of EM. + +However, for technical reasons, a default EM installation (whether or not the compilation succeeds) +will always assume that the compiled ("extension") implementation should be used. + +If you want your EM program to use the pure Ruby version, you must specifically request it. There +are two ways to do this: by setting either a Ruby global variable, or an environment string. + +The following code will invoke the pure-Ruby implementation of EM: + + $eventmachine_library = :pure_ruby + require 'eventmachine' + + EM.library_type #=> "pure_ruby" + +Notice that this requires a code change and is not the preferred way to select pure Ruby, unless +for some reason you are absolutely sure you will never want the compiled implementation. + +Setting the following environment string has the same effect: + + export EVENTMACHINE_LIBRARY="pure_ruby" + +This technique gives you the flexibility to select either version at runtime with no code changes. + +Support + +The EventMachine development team has committed to support precisely the same APIs for all the +various implementations of EM. + +This means that you can expect any EM program to behave identically, whether you use pure Ruby, +the compiled C++ extension, or JRuby. Deviations from this behavior are to be considered bugs +and should be reported as such. + +There is a small number of exceptions to this rule, which arise from underlying platform +distinctions. Notably, EM#epoll is a silent no-op in the pure Ruby implementation. + + +When Should You Use the Pure-Ruby Implementation of EM? + + +Use the pure Ruby implementation of EM when you must support a platform for which no C++ compiler +is available, or on which the standard EM C++ code can't be compiled. + +Keep in mind that you don't need a C++ compiler in order to deploy EM applications that rely on +the compiled version, so long as appropriate C++ runtime libraries are available on the target platform. + +In extreme cases, you may find that you can develop software with the compiled EM version, but are +not allowed to install required runtime libraries on the deployment system(s). This would be another +case in which the pure Ruby implementation can be useful. + +In general you should avoid the pure Ruby version of EM when performance and scalability are important. +EM in pure Ruby will necessarily run slower than the compiled version. Depending on your application +this may or may not be a key issue. + +Also, since EPOLL is not supported in pure Ruby, your applications will be affected by Ruby's built-in +limit of 1024 file and socket descriptors that may be open in a single process. For maximum scalability +and performance, always use EPOLL if possible. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/RELEASE_NOTES b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/RELEASE_NOTES new file mode 100644 index 0000000..6110820 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/RELEASE_NOTES @@ -0,0 +1,94 @@ +RUBY/EventMachine RELEASE NOTES + +-------------------------------------------------- +Version: 0.9.0, released xxXXX07 +Added Erlang-like distributed-computing features + +-------------------------------------------------- +Version: 0.8.0, released 23Jun07 +Added an epoll implementation for Linux 2.6 kernels. +Added evented #popen. + +-------------------------------------------------- +Version: 0.7.3, released 22May07 +Added a large variety of small features. See the ChangeLog. + +-------------------------------------------------- +Version: 0.7.1, released xxNov06 +Added protocol handlers for line-oriented protocols. +Various bug fixes. + +-------------------------------------------------- +Version: 0.7.0, released 20Nov06 +Added a fix in em.cpp/ConnectToServer to fix a fatal exception that +occurred in FreeBSD when connecting successfully to a remote server. + +-------------------------------------------------- +Version: 0.6.0, released xxJul06 +Added deferred operations, suggested by Don Stocks, amillionhitpoints@yahoo.com. + +-------------------------------------------------- +Version: 0.5.4, released xxJun06 +Added get_peername support for streams and datagrams. + +-------------------------------------------------- +Version: 0.5.3, released 17May06 +Fixed bugs in extconf.rb, thanks to Daniel Harple, dharple@generalconsumption.org. +Added proper setup.rb and rake tasks, thanks to Austin Ziegler. +Fixed a handful of reported problems with builds on various platforms. + +-------------------------------------------------- +Version: 0.5.2, released 05May06 +Made several nonvisible improvements to the Windows +implementation. +Added an exception-handling patch contributed by Jeff Rose, jeff@rosejn.net. +Added a dir-config patch contributed anonymously. +Supported builds on Solaris. + +-------------------------------------------------- +Version: 0.5.1, released 05May06 +Made it possible to pass a Class rather than a Module +to a protocol handler. +Added Windows port. + +-------------------------------------------------- +Version: 0.5.0, released 30Apr06 +Added a preliminary SSL/TLS extension. This will probably +change over the next few releases. + +-------------------------------------------------- +Version: 0.4.5, released 29Apr06 +Changed ext files so the ruby.h is installed after unistd.h +otherwise it doesn't compile on gcc 4.1 + +-------------------------------------------------- +Version: 0.4.2, released 19Apr06 +Changed the Ruby-glue so the extension will play nicer +in the sandbox with Ruby threads. +Added an EventMachine::run_without_threads API to +switch off the thread-awareness for better performance +in programs that do not spin any Ruby threads. + +-------------------------------------------------- +Version: 0.4.1, released 15Apr06 +Reworked the shared-object interface to make it easier to +use EventMachine from languages other than Ruby. + +-------------------------------------------------- +Version: 0.3.2, released 12Apr06 +Added support for a user-supplied block in EventMachine#connect. + +-------------------------------------------------- +Version: 0.3.1, released 11Apr06 +Fixed bug that prevented EventMachine from being run multiple +times in a single process. + +-------------------------------------------------- +Version: 0.3.0, released 10Apr06 +Added method EventHandler::Connection::post_init + +-------------------------------------------------- +Version: 0.2.0, released 10Apr06 +Added method EventHandler::stop + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/SMTP b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/SMTP new file mode 100644 index 0000000..92bf311 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/SMTP @@ -0,0 +1,4 @@ +This note details the usage of EventMachine's built-in support for SMTP. EM +supports both client and server connections, which will be described in +separate sections. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/SPAWNED_PROCESSES b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/SPAWNED_PROCESSES new file mode 100644 index 0000000..ee68e3e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/SPAWNED_PROCESSES @@ -0,0 +1,148 @@ +EventMachine (EM) adds two different formalisms for lightweight concurrency +to the Ruby programmer's toolbox: spawned processes and deferrables. This +note will show you how to use spawned processes. For more information, see +the separate document LIGHTWEIGHT_CONCURRENCY. + + +=== What are Spawned Processes? + +Spawned Processes in EventMachine are inspired directly by the "processes" +found in the Erlang programming language. EM deliberately borrows much (but +not all) of Erlang's terminology. However, EM's spawned processes differ from +Erlang's in ways that reflect not only Ruby style, but also the fact that +Ruby is not a functional language like Erlang. + +Let's proceed with a complete, working code sample that we will analyze line +by line. Here's an EM implementation of the "ping-pong" program that also +appears in the Erlang tutorial: + + + require 'eventmachine' + + EM.run { + pong = EM.spawn {|x, ping| + puts "Pong received #{x}" + ping.notify( x-1 ) + } + + ping = EM.spawn {|x| + if x > 0 + puts "Pinging #{x}" + pong.notify x, self + else + EM.stop + end + } + + ping.notify 3 + } + +If you run this program, you'll see the following output: + + Pinging 3 + Pong received 3 + Pinging 2 + Pong received 2 + Pinging 1 + Pong received 1 + +Let's take it step by step. + +EventMachine#spawn works very much like the built-in function spawn in +Erlang. It returns a reference to a Ruby object of class +EventMachine::SpawnedProcess, which is actually a schedulable entity. In +Erlang, the value returned from spawn is called a "process identifier" or +"pid." But we'll refer to the Ruby object returned from EM#spawn simply as a +"spawned process." + +You pass a Ruby block with zero or more parameters to EventMachine#spawn. +Like all Ruby blocks, this one is a closure, so it can refer to variables +defined in the local context when you call EM#spawn. + +However, the code block passed to EM#spawn does NOT execute immediately by +default. Rather, it will execute only when the Spawned Object is "notified." +In Erlang, this process is called "message passing," and is done with the +operator !, but in Ruby it's done simply by calling the #notify method of a +spawned-process object. The parameters you pass to #notify must match those +defined in the block that was originally passed to EM#spawn. + +When you call the #notify method of a spawned-process object, EM's reactor +core will execute the code block originally passed to EM#spawn, at some point +in the future. (#notify itself merely adds a notification to the object's +message queue and ALWAYS returns immediately.) + +When a SpawnedProcess object executes a notification, it does so in the +context of the SpawnedProcess object itself. The notified code block can see +local context from the point at which EM#spawn was called. However, the value +of "self" inside the notified code block is a reference to the SpawnedProcesss +object itself. + +An EM spawned process is nothing more than a Ruby object with a message +queue attached to it. You can have any number of spawned processes in your +program without compromising scalability. You can notify a spawned process +any number of times, and each notification will cause a "message" to be +placed in the queue of the spawned process. Spawned processes with non-empty +message queues are scheduled for execution automatically by the EM reactor. +Spawned processes with no visible references are garbage-collected like any +other Ruby object. + +Back to our code sample: + + pong = EM.spawn {|x, ping| + puts "Pong received #{x}" + ping.notify( x-1 ) + } + +This simply creates a spawned process and assigns it to the local variable +pong. You can see that the spawned code block takes a numeric parameter and a +reference to another spawned process. When pong is notified, it expects to +receive arguments corresponding to these two parameters. It simply prints out +the number it receives as the first argument. Then it notifies the spawned +process referenced by the second argument, passing it the first argument +minus 1. + +And then the block ends, which is crucial because otherwise nothing else +can run. (Remember that in LC, scheduled entities run to completion and are +never preempted.) + +On to the next bit of the code sample: + + ping = EM.spawn {|x| + if x > 0 + puts "Pinging #{x}" + pong.notify x, self + else + EM.stop + end + } + +Here, we're spawning a process that takes a single (numeric) parameter. If +the parameter is greater than zero, the block writes it to the console. It +then notifies the spawned process referenced by the pong local variable, +passing as arguments its number argument, and a reference to itself. The +latter reference, as you saw above, is used by pong to send a return +notification. + +If the ping process receives a zero value, it will stop the reactor loop and +end the program. + +Now we've created a pair of spawned processes, but nothing else has happened. +If we stop now, the program will spin in the EM reactor loop, doing nothing +at all. Our spawned processes will never be scheduled for execution. + +But look at the next line in the code sample: + + ping.notify 3 + +This line gets the ping-pong ball rolling. We call ping's #notify method, +passing the argument 3. This causes a message to be sent to the ping spawned +process. The message contains the single argument, and it causes the EM +reactor to schedule the ping process. And this in turn results in the +execution of the Ruby code block passed to EM#spawn when ping was created. +Everything else proceeds as a result of the messages that are subsequently +passed to each other by the spawned processes. + +[TODO, present the outbound network i/o use case, and clarify that spawned +processes are interleaved with normal i/o operations and don't interfere +with them at all. Also, blame Erlang for the confusing term "process"] + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/TODO b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/TODO new file mode 100644 index 0000000..686a0d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/docs/old/TODO @@ -0,0 +1,8 @@ +TODO List: + +12Aug06: Noticed by Don Stocks. A TCP connect-request that results +in a failed DNS resolution fires a fatal error back to user code. +Uuuuuugly. We should probably cause an unbind event to get fired +instead, and add some parameterization so the caller can detect +the nature of the failure. + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/01_eventmachine_echo_server.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/01_eventmachine_echo_server.rb new file mode 100644 index 0000000..51c5c7d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/01_eventmachine_echo_server.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class EchoServer < EM::Connection + def receive_data(data) + send_data(data) + end +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, EchoServer) +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb new file mode 100644 index 0000000..4cfff19 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class EchoServer < EM::Connection + def receive_data(data) + if data.strip =~ /exit$/i + EventMachine.stop + else + send_data(data) + end + end +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, EchoServer) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/03_simple_chat_server.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/03_simple_chat_server.rb new file mode 100644 index 0000000..3352551 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/03_simple_chat_server.rb @@ -0,0 +1,149 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class SimpleChatServer < EM::Connection + + @@connected_clients = Array.new + DM_REGEXP = /^@([a-zA-Z0-9]+)\s*:?\s*(.+)/.freeze + + attr_reader :username + + + # + # EventMachine handlers + # + + def post_init + @username = nil + + puts "A client has connected..." + ask_username + end + + def unbind + @@connected_clients.delete(self) + puts "[info] #{@username} has left" if entered_username? + end + + def receive_data(data) + if entered_username? + handle_chat_message(data.strip) + else + handle_username(data.strip) + end + end + + + # + # Username handling + # + + def entered_username? + !@username.nil? && !@username.empty? + end # entered_username? + + def handle_username(input) + if input.empty? + send_line("Blank usernames are not allowed. Try again.") + ask_username + else + @username = input + @@connected_clients.push(self) + self.other_peers.each { |c| c.send_data("#{@username} has joined the room\n") } + puts "#{@username} has joined" + + self.send_line("[info] Ohai, #{@username}") + end + end # handle_username(input) + + def ask_username + self.send_line("[info] Enter your username:") + end # ask_username + + + # + # Message handling + # + + def handle_chat_message(msg) + if command?(msg) + self.handle_command(msg) + else + if direct_message?(msg) + self.handle_direct_message(msg) + else + self.announce(msg, "#{@username}:") + end + end + end # handle_chat_message(msg) + + def direct_message?(input) + input =~ DM_REGEXP + end # direct_message?(input) + + def handle_direct_message(input) + username, message = parse_direct_message(input) + + if connection = @@connected_clients.find { |c| c.username == username } + puts "[dm] @#{@username} => @#{username}" + connection.send_line("[dm] @#{@username}: #{message}") + else + send_line "@#{username} is not in the room. Here's who is: #{usernames.join(', ')}" + end + end # handle_direct_message(input) + + def parse_direct_message(input) + return [$1, $2] if input =~ DM_REGEXP + end # parse_direct_message(input) + + + # + # Commands handling + # + + def command?(input) + input =~ /(exit|status)$/i + end # command?(input) + + def handle_command(cmd) + case cmd + when /exit$/i then self.close_connection + when /status$/i then self.send_line("[chat server] It's #{Time.now.strftime('%H:%M')} and there are #{self.number_of_connected_clients} people in the room") + end + end # handle_command(cmd) + + + # + # Helpers + # + + def announce(msg = nil, prefix = "[chat server]") + @@connected_clients.each { |c| c.send_line("#{prefix} #{msg}") } unless msg.empty? + end # announce(msg) + + def number_of_connected_clients + @@connected_clients.size + end # number_of_connected_clients + + def other_peers + @@connected_clients.reject { |c| self == c } + end # other_peers + + def send_line(line) + self.send_data("#{line}\n") + end # send_line(line) + + def usernames + @@connected_clients.map { |c| c.username } + end # usernames +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, SimpleChatServer) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/04_simple_chat_server_step_one.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/04_simple_chat_server_step_one.rb new file mode 100644 index 0000000..bb283a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/04_simple_chat_server_step_one.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class SimpleChatServer < EM::Connection + + # + # EventMachine handlers + # + + def post_init + puts "A client has connected..." + end + + def unbind + puts "A client has left..." + end +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, SimpleChatServer) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/05_simple_chat_server_step_two.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/05_simple_chat_server_step_two.rb new file mode 100644 index 0000000..1361c5d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/05_simple_chat_server_step_two.rb @@ -0,0 +1,43 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class SimpleChatServer < EM::Connection + + @@connected_clients = Array.new + + + # + # EventMachine handlers + # + + def post_init + @@connected_clients.push(self) + puts "A client has connected..." + end + + def unbind + @@connected_clients.delete(self) + puts "A client has left..." + end + + + + + # + # Helpers + # + + def other_peers + @@connected_clients.reject { |c| self == c } + end # other_peers +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, SimpleChatServer) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/06_simple_chat_server_step_three.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/06_simple_chat_server_step_three.rb new file mode 100644 index 0000000..d9b85e2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/06_simple_chat_server_step_three.rb @@ -0,0 +1,98 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class SimpleChatServer < EM::Connection + + @@connected_clients = Array.new + + + attr_reader :username + + + # + # EventMachine handlers + # + + def post_init + @username = nil + + puts "A client has connected..." + ask_username + end + + def unbind + @@connected_clients.delete(self) + puts "A client has left..." + end + + def receive_data(data) + if entered_username? + handle_chat_message(data.strip) + else + handle_username(data.strip) + end + end + + + + + # + # Username handling + # + + def entered_username? + !@username.nil? && !@username.empty? + end # entered_username? + + def handle_username(input) + if input.empty? + send_line("Blank usernames are not allowed. Try again.") + ask_username + else + @username = input + @@connected_clients.push(self) + self.other_peers.each { |c| c.send_data("#{@username} has joined the room\n") } + puts "#{@username} has joined" + + self.send_line("[info] Ohai, #{@username}") + end + end # handle_username(input) + + def ask_username + self.send_line("[info] Enter your username:") + end # ask_username + + + + # + # Message handling + # + + def handle_chat_message(msg) + raise NotImplementedError + end + + + + # + # Helpers + # + + def other_peers + @@connected_clients.reject { |c| self == c } + end # other_peers + + def send_line(line) + self.send_data("#{line}\n") + end # send_line(line) +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, SimpleChatServer) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/07_simple_chat_server_step_four.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/07_simple_chat_server_step_four.rb new file mode 100644 index 0000000..d4948af --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/07_simple_chat_server_step_four.rb @@ -0,0 +1,121 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class SimpleChatServer < EM::Connection + + @@connected_clients = Array.new + + + attr_reader :username + + + # + # EventMachine handlers + # + + def post_init + @username = nil + + puts "A client has connected..." + ask_username + end + + def unbind + @@connected_clients.delete(self) + puts "[info] #{@username} has left" if entered_username? + end + + def receive_data(data) + if entered_username? + handle_chat_message(data.strip) + else + handle_username(data.strip) + end + end + + + + + # + # Username handling + # + + def entered_username? + !@username.nil? && !@username.empty? + end # entered_username? + + def handle_username(input) + if input.empty? + send_line("Blank usernames are not allowed. Try again.") + ask_username + else + @username = input + @@connected_clients.push(self) + self.other_peers.each { |c| c.send_data("#{@username} has joined the room\n") } + puts "#{@username} has joined" + + self.send_line("[info] Ohai, #{@username}") + end + end # handle_username(input) + + def ask_username + self.send_line("[info] Enter your username:") + end # ask_username + + + + # + # Message handling + # + + def handle_chat_message(msg) + if command?(msg) + self.handle_command(msg) + else + self.announce(msg, "#{@username}:") + end + end + + + # + # Commands handling + # + + def command?(input) + input =~ /exit$/i + end # command?(input) + + def handle_command(cmd) + case cmd + when /exit$/i then self.close_connection + end + end # handle_command(cmd) + + + + # + # Helpers + # + + def announce(msg = nil, prefix = "[chat server]") + @@connected_clients.each { |c| c.send_line("#{prefix} #{msg}") } unless msg.empty? + end # announce(msg) + + def other_peers + @@connected_clients.reject { |c| self == c } + end # other_peers + + def send_line(line) + self.send_data("#{line}\n") + end # send_line(line) +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, SimpleChatServer) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/08_simple_chat_server_step_five.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/08_simple_chat_server_step_five.rb new file mode 100644 index 0000000..03da66b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/guides/getting_started/08_simple_chat_server_step_five.rb @@ -0,0 +1,141 @@ +#!/usr/bin/env ruby + +require 'rubygems' # or use Bundler.setup +require 'eventmachine' + +class SimpleChatServer < EM::Connection + + @@connected_clients = Array.new + DM_REGEXP = /^@([a-zA-Z0-9]+)\s*:?\s+(.+)/.freeze + + attr_reader :username + + + # + # EventMachine handlers + # + + def post_init + @username = nil + + puts "A client has connected..." + ask_username + end + + def unbind + @@connected_clients.delete(self) + puts "[info] #{@username} has left" if entered_username? + end + + def receive_data(data) + if entered_username? + handle_chat_message(data.strip) + else + handle_username(data.strip) + end + end + + + # + # Username handling + # + + def entered_username? + !@username.nil? && !@username.empty? + end # entered_username? + + def handle_username(input) + if input.empty? + send_line("Blank usernames are not allowed. Try again.") + ask_username + else + @username = input + @@connected_clients.push(self) + self.other_peers.each { |c| c.send_data("#{@username} has joined the room\n") } + puts "#{@username} has joined" + + self.send_line("[info] Ohai, #{@username}") + end + end # handle_username(input) + + def ask_username + self.send_line("[info] Enter your username:") + end # ask_username + + + # + # Message handling + # + + def handle_chat_message(msg) + if command?(msg) + self.handle_command(msg) + else + if direct_message?(msg) + self.handle_direct_message(msg) + else + self.announce(msg, "#{@username}:") + end + end + end # handle_chat_message(msg) + + def direct_message?(input) + input =~ DM_REGEXP + end # direct_message?(input) + + def handle_direct_message(input) + username, message = parse_direct_message(input) + + if connection = @@connected_clients.find { |c| c.username == username } + puts "[dm] @#{@username} => @#{username}" + connection.send_line("[dm] @#{@username}: #{message}") + else + send_line "@#{username} is not in the room. Here's who is: #{usernames.join(', ')}" + end + end # handle_direct_message(input) + + def parse_direct_message(input) + return [$1, $2] if input =~ DM_REGEXP + end # parse_direct_message(input) + + + # + # Commands handling + # + + def command?(input) + input =~ /(exit|status)$/i + end # command?(input) + + def handle_command(cmd) + case cmd + when /exit$/i then self.close_connection + when /status$/i then self.send_line("[chat server] It's #{Time.now.strftime('%H:%M')} and there are #{self.number_of_connected_clients} people in the room") + end + end # handle_command(cmd) + + + # + # Helpers + # + + def announce(msg = nil, prefix = "[chat server]") + @@connected_clients.each { |c| c.send_line("#{prefix} #{msg}") } unless msg.empty? + end # announce(msg) + + def other_peers + @@connected_clients.reject { |c| self == c } + end # other_peers + + def send_line(line) + self.send_data("#{line}\n") + end # send_line(line) +end + +EventMachine.run do + # hit Control + C to stop + Signal.trap("INT") { EventMachine.stop } + Signal.trap("TERM") { EventMachine.stop } + + EventMachine.start_server("0.0.0.0", 10000, SimpleChatServer) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_channel.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_channel.rb new file mode 100644 index 0000000..16e8d08 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_channel.rb @@ -0,0 +1,43 @@ +require File.dirname(__FILE__) + '/helper' + +EM.run do + + # Create a channel to push data to, this could be stocks... + RandChannel = EM::Channel.new + + # The server simply subscribes client connections to the channel on connect, + # and unsubscribes them on disconnect. + class Server < EM::Connection + def self.start(host = '127.0.0.1', port = 8000) + EM.start_server(host, port, self) + end + + def post_init + @sid = RandChannel.subscribe { |m| send_data "#{m.inspect}\n" } + end + + def unbind + RandChannel.unsubscribe @sid + end + end + Server.start + + # Two client connections, that just print what they receive. + 2.times do + EM.connect('127.0.0.1', 8000) do |c| + c.extend EM::P::LineText2 + def c.receive_line(line) + puts "Subscriber: #{signature} got #{line}" + end + EM.add_timer(2) { c.close_connection } + end + end + + # This part of the example is more fake, but imagine sleep was in fact a + # long running calculation to achieve the value. + 40.times do + EM.defer lambda { v = sleep(rand * 2); RandChannel << [Time.now, v] } + end + + EM.add_timer(5) { EM.stop } +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_queue.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_queue.rb new file mode 100644 index 0000000..761ea76 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_queue.rb @@ -0,0 +1,2 @@ +require File.dirname(__FILE__) + '/helper' + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_tick_loop_array.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_tick_loop_array.rb new file mode 100644 index 0000000..81b0ae3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_tick_loop_array.rb @@ -0,0 +1,15 @@ +require File.dirname(__FILE__) + '/helper' + +EM.run do + array = (1..100).to_a + + tickloop = EM.tick_loop do + if array.empty? + :stop + else + puts array.shift + end + end + + tickloop.on_stop { EM.stop } +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_tick_loop_counter.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_tick_loop_counter.rb new file mode 100644 index 0000000..58e51ff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/ex_tick_loop_counter.rb @@ -0,0 +1,32 @@ +require File.dirname(__FILE__) + '/helper' + +class TickCounter + attr_reader :start_time, :count + + def initialize + reset + @tick_loop = EM.tick_loop(method(:tick)) + end + + def reset + @count = 0 + @start_time = EM.current_time + end + + def tick + @count += 1 + end + + def rate + @count / (EM.current_time - @start_time) + end +end + +period = 5 +EM.run do + counter = TickCounter.new + EM.add_periodic_timer(period) do + puts "Ticks per second: #{counter.rate} (mean of last #{period}s)" + counter.reset + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/helper.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/helper.rb new file mode 100644 index 0000000..835ded2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/examples/old/helper.rb @@ -0,0 +1,2 @@ +$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +require 'eventmachine' \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/Makefile b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/Makefile new file mode 100644 index 0000000..275ee53 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/Makefile @@ -0,0 +1,269 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +V0 = $(V:0=) +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@ :) +ECHO = $(ECHO1:0=@ echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /usr/include/ruby-3.2.0 +hdrdir = $(topdir) +arch_hdrdir = /usr/include/ruby-3.2.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/usr +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(DESTDIR)/usr +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(sitelibdir)/$(sitearch) +sitelibdir = $(sitedir)/$(ruby_version) +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(DESTDIR)/usr/share/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib/x86_64-linux-gnu +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(DESTDIR)/usr/share/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(exec_prefix)/include +runstatedir = $(localstatedir)/run +localstatedir = $(DESTDIR)/var +sharedstatedir = $(DESTDIR)/usr/com +sysconfdir = $(DESTDIR)/etc +datadir = $(DESTDIR)/usr/share +datarootdir = $(prefix)/share +libexecdir = $(DESTDIR)/usr/libexec +sbindir = $(DESTDIR)/usr/bin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC_WRAPPER = +CC = x86_64-unknown-linux-gnu-gcc +CXX = x86_64-unknown-linux-gnu-g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static $(MAINLIBS) +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) +CSRCFLAG = $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = +optflags = -O3 -fno-fast-math +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef +cppflags = +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -DHAVE_OPENSSL_SSL_H -DHAVE_OPENSSL_ERR_H -DWITH_SSL -DBUILD_FOR_RUBY -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_FD_SELECT -DHAVE_TYPE_RB_FDSET_T -DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_TIME_NEW -DHAVE_INOTIFY_INIT -DHAVE_INOTIFY -DHAVE_WRITEV -DHAVE_PIPE2 -DHAVE_ACCEPT4 -DHAVE_CONST_SOCK_CLOEXEC -DOS_UNIX -DHAVE_EPOLL_CREATE -DHAVE_EPOLL -DHAVE_CLOCK_GETTIME -DHAVE_CONST_CLOCK_MONOTONIC_RAW -DHAVE_CONST_CLOCK_MONOTONIC -DHAVE_MAKE_PAIR $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer $(ARCH_FLAG) +ldflags = -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed +dldflags = -Wl,-z,relro,-z,now -Wl,--as-needed +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CXX) -shared +LDSHAREDXX = $(CXX) -shared +AR = x86_64-unknown-linux-gnu-gcc-ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 3.2.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = rm -fr +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lssl -lcrypto -lcrypto -lssl -lm -lpthread -lc +ORIG_SRCS = binder.cpp cmain.cpp ed.cpp em.cpp kb.cpp page.cpp pipe.cpp rubymain.cpp ssl.cpp +SRCS = $(ORIG_SRCS) +OBJS = binder.o cmain.o ed.o em.o kb.o page.o pipe.o rubymain.o ssl.o +HDRS = $(srcdir)/binder.h $(srcdir)/ed.h $(srcdir)/em.h $(srcdir)/eventmachine.h $(srcdir)/page.h $(srcdir)/project.h $(srcdir)/ssl.h +LOCAL_HDRS = +TARGET = rubyeventmachine +TARGET_NAME = rubyeventmachine +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = $(TARGET).so +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(sitehdrdir)$(target_prefix) +ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix) +TARGET_SO_DIR = +TARGET_SO = $(TARGET_SO_DIR)$(DLLIB) +CLEANLIBS = $(TARGET_SO) false +CLEANOBJS = $(OBJS) *.bak +TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time + +all: $(DLLIB) +static: $(STATIC_LIB) +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP) + $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) +clean-static:: + -$(Q)$(RM) $(STATIC_LIB) +install-rb: pre-install-rb do-install-rb install-rb-default +install-rb-default: pre-install-rb-default do-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +do-install-rb: +do-install-rb-default: +pre-install-rb-default: + @$(NULLCMD) +$(TARGET_SO_DIR_TIMESTAMP): + $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) + $(Q) $(TOUCH) $@ + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + +.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S + +.cc.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cc.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.mm.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.mm.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cxx.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cxx.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cpp.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cpp.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.c.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.c.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.m.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.m.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +$(TARGET_SO): $(OBJS) Makefile + $(ECHO) linking shared-object $(DLLIB) + -$(Q)$(RM) $(@) + $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) + + + +$(OBJS): $(HDRS) $(ruby_headers) diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/binder.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/binder.cpp new file mode 100644 index 0000000..5b90876 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/binder.cpp @@ -0,0 +1,124 @@ +/***************************************************************************** + +$Id$ + +File: binder.cpp +Date: 07Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#include "project.h" + +#define DEV_URANDOM "/dev/urandom" + + +std::map Bindable_t::BindingBag; + + +/******************************** +STATIC Bindable_t::CreateBinding +********************************/ + +uintptr_t Bindable_t::CreateBinding() +{ + static uintptr_t num = 0; + while(BindingBag[++num]) {} + return num; +} + +#if 0 +string Bindable_t::CreateBinding() +{ + static int index = 0; + static string seed; + + if ((index >= 1000000) || (seed.length() == 0)) { + #ifdef OS_UNIX + int fd = open (DEV_URANDOM, O_RDONLY); + if (fd < 0) + throw std::runtime_error ("No entropy device"); + + unsigned char u[16]; + size_t r = read (fd, u, sizeof(u)); + if (r < sizeof(u)) + throw std::runtime_error ("Unable to read entropy device"); + + unsigned char *u1 = (unsigned char*)u; + char u2 [sizeof(u) * 2 + 1]; + + for (size_t i=0; i < sizeof(u); i++) + sprintf (u2 + (i * 2), "%02x", u1[i]); + + seed = string (u2); + #endif + + + #ifdef OS_WIN32 + UUID uuid; + UuidCreate (&uuid); + unsigned char *uuidstring = NULL; + UuidToString (&uuid, &uuidstring); + if (!uuidstring) + throw std::runtime_error ("Unable to read uuid"); + seed = string ((const char*)uuidstring); + + RpcStringFree (&uuidstring); + #endif + + index = 0; + + + } + + stringstream ss; + ss << seed << (++index); + return ss.str(); +} +#endif + +/***************************** +STATIC: Bindable_t::GetObject +*****************************/ + +Bindable_t *Bindable_t::GetObject (const uintptr_t binding) +{ + std::map::const_iterator i = BindingBag.find (binding); + if (i != BindingBag.end()) + return i->second; + else + return NULL; +} + + +/********************** +Bindable_t::Bindable_t +**********************/ + +Bindable_t::Bindable_t() +{ + Binding = Bindable_t::CreateBinding(); + BindingBag [Binding] = this; +} + + + +/*********************** +Bindable_t::~Bindable_t +***********************/ + +Bindable_t::~Bindable_t() NO_EXCEPT_FALSE +{ + BindingBag.erase (Binding); +} + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/binder.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/binder.h new file mode 100644 index 0000000..dd32c8d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/binder.h @@ -0,0 +1,52 @@ +/***************************************************************************** + +$Id$ + +File: binder.h +Date: 07Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#ifndef __ObjectBindings__H_ +#define __ObjectBindings__H_ + + +#if __cplusplus >= 201103L +#define NO_EXCEPT_FALSE noexcept(false) +#else +#define NO_EXCEPT_FALSE +#endif + +class Bindable_t +{ + public: + static uintptr_t CreateBinding(); + static Bindable_t *GetObject (const uintptr_t); + static std::map BindingBag; + + public: + Bindable_t(); + virtual ~Bindable_t() NO_EXCEPT_FALSE; + + const uintptr_t GetBinding() {return Binding;} + + private: + uintptr_t Binding; +}; + + + + + +#endif // __ObjectBindings__H_ + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/cmain.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/cmain.cpp new file mode 100644 index 0000000..f58c2cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/cmain.cpp @@ -0,0 +1,988 @@ +/***************************************************************************** + +$Id$ + +File: cmain.cpp +Date: 06Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#include "project.h" + +/* 21Sep09: ruby 1.9 defines macros for common i/o functions that point to rb_w32_* implementations. + We need to undef the stat to fix a build failure in evma_send_file_data_to_connection. + See http://groups.google.com/group/eventmachine/browse_thread/thread/fc60d9bb738ffc71 +*/ +#if defined(BUILD_FOR_RUBY) && defined(OS_WIN32) +#undef stat +#undef fstat +#endif + +static EventMachine_t *EventMachine; +static Poller_t Poller = Poller_Default; + +extern "C" void ensure_eventmachine (const char *caller = "unknown caller") +{ + if (!EventMachine) { + const int err_size = 128; + char err_string[err_size]; + snprintf (err_string, err_size, "eventmachine not initialized: %s", caller); + #ifdef BUILD_FOR_RUBY + rb_raise(rb_eRuntimeError, "%s", err_string); + #else + throw std::runtime_error (err_string); + #endif + } +} + +/*********************** +evma_initialize_library +***********************/ + +extern "C" void evma_initialize_library (EMCallback cb) +{ + if (EventMachine) + #ifdef BUILD_FOR_RUBY + rb_raise(rb_eRuntimeError, "eventmachine already initialized: evma_initialize_library"); + #else + throw std::runtime_error ("eventmachine already initialized: evma_initialize_library"); + #endif + + EventMachine = new EventMachine_t (cb, Poller); +} + + +/******************** +evma_release_library +********************/ + +extern "C" void evma_release_library() +{ + ensure_eventmachine("evma_release_library"); + delete EventMachine; + EventMachine = NULL; +} + + +/********************* +evma_run_machine_once +*********************/ + +extern "C" bool evma_run_machine_once() +{ + ensure_eventmachine("evma_run_machine_once"); + return EventMachine->RunOnce(); +} + + +/**************** +evma_run_machine +****************/ + +extern "C" void evma_run_machine() +{ + ensure_eventmachine("evma_run_machine"); + EventMachine->Run(); +} + + +/************************** +evma_install_oneshot_timer +**************************/ + +extern "C" const uintptr_t evma_install_oneshot_timer (uint64_t milliseconds) +{ + ensure_eventmachine("evma_install_oneshot_timer"); + return EventMachine->InstallOneshotTimer (milliseconds); +} + + +/********************** +evma_connect_to_server +**********************/ + +extern "C" const uintptr_t evma_connect_to_server (const char *bind_addr, int bind_port, const char *server, int port) +{ + ensure_eventmachine("evma_connect_to_server"); + return EventMachine->ConnectToServer (bind_addr, bind_port, server, port); +} + +/*************************** +evma_connect_to_unix_server +***************************/ + +extern "C" const uintptr_t evma_connect_to_unix_server (const char *server) +{ + ensure_eventmachine("evma_connect_to_unix_server"); + return EventMachine->ConnectToUnixServer (server); +} + +/************** +evma_attach_fd +**************/ + +extern "C" const uintptr_t evma_attach_fd (int file_descriptor, int watch_mode) +{ + ensure_eventmachine("evma_attach_fd"); + return EventMachine->AttachFD (file_descriptor, watch_mode ? true : false); +} + +/************** +evma_detach_fd +**************/ + +extern "C" int evma_detach_fd (const uintptr_t binding) +{ + ensure_eventmachine("evma_detach_fd"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return EventMachine->DetachFD (ed); + else + #ifdef BUILD_FOR_RUBY + rb_raise(rb_eRuntimeError, "invalid binding to detach"); + #else + throw std::runtime_error ("invalid binding to detach"); + #endif + return -1; +} + +/************************ +evma_get_file_descriptor +************************/ + +extern "C" int evma_get_file_descriptor (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_file_descriptor"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->GetSocket(); + else + #ifdef BUILD_FOR_RUBY + rb_raise(rb_eRuntimeError, "invalid binding to get_fd"); + #else + throw std::runtime_error ("invalid binding to get_fd"); + #endif + return -1; +} + +/*********************** +evma_is_notify_readable +***********************/ + +extern "C" int evma_is_notify_readable (const uintptr_t binding) +{ + ConnectionDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + return cd->IsNotifyReadable() ? 1 : 0; + return -1; +} + +/************************ +evma_set_notify_readable +************************/ + +extern "C" void evma_set_notify_readable (const uintptr_t binding, int mode) +{ + ConnectionDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + cd->SetNotifyReadable (mode ? true : false); +} + +/*********************** +evma_is_notify_writable +***********************/ + +extern "C" int evma_is_notify_writable (const uintptr_t binding) +{ + ConnectionDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + return cd->IsNotifyWritable() ? 1 : 0; + return -1; +} + +/************************ +evma_set_notify_writable +************************/ + +extern "C" void evma_set_notify_writable (const uintptr_t binding, int mode) +{ + ConnectionDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + cd->SetNotifyWritable (mode ? true : false); +} + +/********** +evma_pause +**********/ + +extern "C" int evma_pause (const uintptr_t binding) +{ + EventableDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + return cd->Pause() ? 1 : 0; + + return 0; +} + +/*********** +evma_resume +***********/ + +extern "C" int evma_resume (const uintptr_t binding) +{ + EventableDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + return cd->Resume() ? 1 : 0; + + return 0; +} + +/************** +evma_is_paused +**************/ + +extern "C" int evma_is_paused (const uintptr_t binding) +{ + EventableDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + return cd->IsPaused() ? 1 : 0; + + return 0; +} + +/************************ +evma_num_close_scheduled +************************/ + +extern "C" int evma_num_close_scheduled () +{ + ensure_eventmachine("evma_num_close_scheduled"); + return EventMachine->NumCloseScheduled; +} + +/********************** +evma_create_tcp_server +**********************/ + +extern "C" const uintptr_t evma_create_tcp_server (const char *address, int port) +{ + ensure_eventmachine("evma_create_tcp_server"); + return EventMachine->CreateTcpServer (address, port); +} + +/****************************** +evma_create_unix_domain_server +******************************/ + +extern "C" const uintptr_t evma_create_unix_domain_server (const char *filename) +{ + ensure_eventmachine("evma_create_unix_domain_server"); + return EventMachine->CreateUnixDomainServer (filename); +} + +/*********************** +evma_attach_sd +************************/ + +extern "C" const uintptr_t evma_attach_sd (int sd) +{ + ensure_eventmachine("evma_attach_sd"); + return EventMachine->AttachSD (sd); +} + +/************************* +evma_open_datagram_socket +*************************/ + +extern "C" const uintptr_t evma_open_datagram_socket (const char *address, int port) +{ + ensure_eventmachine("evma_open_datagram_socket"); + return EventMachine->OpenDatagramSocket (address, port); +} + +/****************** +evma_open_keyboard +******************/ + +extern "C" const uintptr_t evma_open_keyboard() +{ + ensure_eventmachine("evma_open_keyboard"); + return EventMachine->OpenKeyboard(); +} + +/******************* +evma_watch_filename +*******************/ + +extern "C" const uintptr_t evma_watch_filename (const char *fname) +{ + ensure_eventmachine("evma_watch_filename"); + return EventMachine->WatchFile(fname); +} + +/********************* +evma_unwatch_filename +*********************/ + +extern "C" void evma_unwatch_filename (const uintptr_t sig) +{ + ensure_eventmachine("evma_unwatch_file"); + EventMachine->UnwatchFile(sig); +} + +/************** +evma_watch_pid +**************/ + +extern "C" const uintptr_t evma_watch_pid (int pid) +{ + ensure_eventmachine("evma_watch_pid"); + return EventMachine->WatchPid(pid); +} + +/**************** +evma_unwatch_pid +****************/ + +extern "C" void evma_unwatch_pid (const uintptr_t sig) +{ + ensure_eventmachine("evma_unwatch_pid"); + EventMachine->UnwatchPid(sig); +} + +/**************************** +evma_send_data_to_connection +****************************/ + +extern "C" int evma_send_data_to_connection (const uintptr_t binding, const char *data, int data_length) +{ + ensure_eventmachine("evma_send_data_to_connection"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->SendOutboundData(data, data_length); + return -1; +} + +/****************** +evma_send_datagram +******************/ + +extern "C" int evma_send_datagram (const uintptr_t binding, const char *data, int data_length, const char *address, int port) +{ + ensure_eventmachine("evma_send_datagram"); + DatagramDescriptor *dd = dynamic_cast (Bindable_t::GetObject (binding)); + if (dd) + return dd->SendOutboundDatagram(data, data_length, address, port); + return -1; +} + + +/********************* +evma_close_connection +*********************/ + +extern "C" void evma_close_connection (const uintptr_t binding, int after_writing) +{ + ensure_eventmachine("evma_close_connection"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + ed->ScheduleClose (after_writing ? true : false); +} + +/*********************************** +evma_report_connection_error_status +***********************************/ + +extern "C" int evma_report_connection_error_status (const uintptr_t binding) +{ + ensure_eventmachine("evma_report_connection_error_status"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->ReportErrorStatus(); + return -1; +} + +/******************** +evma_stop_tcp_server +********************/ + +extern "C" void evma_stop_tcp_server (const uintptr_t binding) +{ + ensure_eventmachine("evma_stop_tcp_server"); + AcceptorDescriptor::StopAcceptor (binding); +} + + +/***************** +evma_stop_machine +*****************/ + +extern "C" void evma_stop_machine() +{ + ensure_eventmachine("evma_stop_machine"); + EventMachine->ScheduleHalt(); +} + +/***************** +evma_stopping +*****************/ + +extern "C" bool evma_stopping() +{ + ensure_eventmachine("evma_stopping"); + return EventMachine->Stopping(); +} + +/************** +evma_start_tls +**************/ + +extern "C" void evma_start_tls (const uintptr_t binding) +{ + ensure_eventmachine("evma_start_tls"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + ed->StartTls(); +} + +/****************** +evma_set_tls_parms +******************/ + +extern "C" void evma_set_tls_parms (const uintptr_t binding, const char *privatekey_filename, const char *certchain_filename, int verify_peer, int fail_if_no_peer_cert, const char *sni_hostname, const char *cipherlist, const char *ecdh_curve, const char *dhparam, int ssl_version) +{ + ensure_eventmachine("evma_set_tls_parms"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + ed->SetTlsParms (privatekey_filename, certchain_filename, (verify_peer == 1 ? true : false), (fail_if_no_peer_cert == 1 ? true : false), sni_hostname, cipherlist, ecdh_curve, dhparam, ssl_version); +} + +/****************** +evma_get_peer_cert +******************/ + +#ifdef WITH_SSL +extern "C" X509 *evma_get_peer_cert (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_peer_cert"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->GetPeerCert(); + return NULL; +} +#endif + +/****************** +evma_get_cipher_bits +******************/ + +#ifdef WITH_SSL +extern "C" int evma_get_cipher_bits (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_cipher_bits"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->GetCipherBits(); + return -1; +} +#endif + +/****************** +evma_get_cipher_name +******************/ + +#ifdef WITH_SSL +extern "C" const char *evma_get_cipher_name (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_cipher_name"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->GetCipherName(); + return NULL; +} +#endif + +/****************** +evma_get_cipher_protocol +******************/ + +#ifdef WITH_SSL +extern "C" const char *evma_get_cipher_protocol (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_cipher_protocol"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->GetCipherProtocol(); + return NULL; +} +#endif + +/****************** +evma_get_sni_hostname +******************/ + +#ifdef WITH_SSL +extern "C" const char *evma_get_sni_hostname (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_sni_hostname"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) + return ed->GetSNIHostname(); + return NULL; +} +#endif + +/******************** +evma_accept_ssl_peer +********************/ + +#ifdef WITH_SSL +extern "C" void evma_accept_ssl_peer (const uintptr_t binding) +{ + ensure_eventmachine("evma_accept_ssl_peer"); + ConnectionDescriptor *cd = dynamic_cast (Bindable_t::GetObject (binding)); + if (cd) + cd->AcceptSslPeer(); +} +#endif + +/***************** +evma_get_peername +*****************/ + +extern "C" int evma_get_peername (const uintptr_t binding, struct sockaddr *sa, socklen_t *len) +{ + ensure_eventmachine("evma_get_peername"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) { + return ed->GetPeername (sa, len) ? 1 : 0; + } + else + return 0; +} + +/***************** +evma_get_sockname +*****************/ + +extern "C" int evma_get_sockname (const uintptr_t binding, struct sockaddr *sa, socklen_t *len) +{ + ensure_eventmachine("evma_get_sockname"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) { + return ed->GetSockname (sa, len) ? 1 : 0; + } + else + return 0; +} + +/*********************** +evma_get_subprocess_pid +***********************/ + +#ifdef OS_UNIX +extern "C" int evma_get_subprocess_pid (const uintptr_t binding, pid_t *pid) +{ + ensure_eventmachine("evma_get_subprocess_pid"); + PipeDescriptor *pd = dynamic_cast (Bindable_t::GetObject (binding)); + if (pd) { + return pd->GetSubprocessPid (pid) ? 1 : 0; + } + else if (pid && EventMachine->SubprocessPid) { + *pid = EventMachine->SubprocessPid; + return 1; + } + else + return 0; +} +#else +extern "C" int evma_get_subprocess_pid (const uintptr_t binding UNUSED, pid_t *pid UNUSED) +{ + return 0; +} +#endif + +/************************** +evma_get_subprocess_status +**************************/ + +extern "C" int evma_get_subprocess_status (const uintptr_t binding UNUSED, int *status) +{ + ensure_eventmachine("evma_get_subprocess_status"); + if (status) { + *status = EventMachine->SubprocessExitStatus; + return 1; + } + else + return 0; +} + +/************************* +evma_get_connection_count +*************************/ + +extern "C" int evma_get_connection_count() +{ + ensure_eventmachine("evma_get_connection_count"); + return EventMachine->GetConnectionCount(); +} + +/********************* +evma_signal_loopbreak +*********************/ + +extern "C" void evma_signal_loopbreak() +{ + ensure_eventmachine("evma_signal_loopbreak"); + EventMachine->SignalLoopBreaker(); +} + + + +/******************************** +evma_get_comm_inactivity_timeout +********************************/ + +extern "C" float evma_get_comm_inactivity_timeout (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_comm_inactivity_timeout"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) { + return ((float)ed->GetCommInactivityTimeout() / 1000); + } + else + return 0.0; //Perhaps this should be an exception. Access to an unknown binding. +} + +/******************************** +evma_set_comm_inactivity_timeout +********************************/ + +extern "C" int evma_set_comm_inactivity_timeout (const uintptr_t binding, float value) +{ + ensure_eventmachine("evma_set_comm_inactivity_timeout"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) { + return ed->SetCommInactivityTimeout ((uint64_t)(value * 1000)); + } + else + return 0; //Perhaps this should be an exception. Access to an unknown binding. +} + + +/******************************** +evma_get_pending_connect_timeout +********************************/ + +extern "C" float evma_get_pending_connect_timeout (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_pending_connect_timeout"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) { + return ((float)ed->GetPendingConnectTimeout() / 1000); + } + else + return 0.0; +} + + +/******************************** +evma_set_pending_connect_timeout +********************************/ + +extern "C" int evma_set_pending_connect_timeout (const uintptr_t binding, float value) +{ + ensure_eventmachine("evma_set_pending_connect_timeout"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + if (ed) { + return ed->SetPendingConnectTimeout ((uint64_t)(value * 1000)); + } + else + return 0; +} + + +/********************** +evma_set_timer_quantum +**********************/ + +extern "C" void evma_set_timer_quantum (int interval) +{ + ensure_eventmachine("evma_set_timer_quantum"); + EventMachine->SetTimerQuantum (interval); +} + + +/************************ +evma_get_max_timer_count +************************/ + +extern "C" int evma_get_max_timer_count() +{ + return EventMachine_t::GetMaxTimerCount(); +} + +/************************ +evma_set_max_timer_count +************************/ + +extern "C" void evma_set_max_timer_count (int ct) +{ + // This may only be called if the reactor is not running. + + if (EventMachine) + #ifdef BUILD_FOR_RUBY + rb_raise(rb_eRuntimeError, "eventmachine already initialized: evma_set_max_timer_count"); + #else + throw std::runtime_error ("eventmachine already initialized: evma_set_max_timer_count"); + #endif + EventMachine_t::SetMaxTimerCount (ct); +} + +/****************** +evma_get/set_simultaneous_accept_count +******************/ + +extern "C" void evma_set_simultaneous_accept_count (int count) +{ + EventMachine_t::SetSimultaneousAcceptCount(count); +} + +extern "C" int evma_get_simultaneous_accept_count() +{ + return EventMachine_t::GetSimultaneousAcceptCount(); +} + + +/****************** +evma_setuid_string +******************/ + +extern "C" void evma_setuid_string (const char *username) +{ + // We do NOT need to be running an EM instance because this method is static. + EventMachine_t::SetuidString (username); +} + + +/********** +evma_popen +**********/ + +extern "C" const uintptr_t evma_popen (char * const*cmd_strings) +{ + ensure_eventmachine("evma_popen"); + return EventMachine->Socketpair (cmd_strings); +} + + +/*************************** +evma_get_outbound_data_size +***************************/ + +extern "C" int evma_get_outbound_data_size (const uintptr_t binding) +{ + ensure_eventmachine("evma_get_outbound_data_size"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (binding)); + return ed ? ed->GetOutboundDataSize() : 0; +} + + +/************** +evma_set_epoll +**************/ + +extern "C" void evma_set_epoll (int use) +{ + if (use) + Poller = Poller_Epoll; + else + Poller = Poller_Default; +} + +/*************** +evma_set_kqueue +***************/ + +extern "C" void evma_set_kqueue (int use) +{ + if (use) + Poller = Poller_Kqueue; + else + Poller = Poller_Default; +} + + +/********************** +evma_set_rlimit_nofile +**********************/ + +extern "C" int evma_set_rlimit_nofile (int nofiles) +{ + return EventMachine_t::SetRlimitNofile (nofiles); +} + + +/********************************* +evma_send_file_data_to_connection +*********************************/ + +extern "C" int evma_send_file_data_to_connection (const uintptr_t binding, const char *filename) +{ + /* This is a sugaring over send_data_to_connection that reads a file into a + * locally-allocated buffer, and sends the file data to the remote peer. + * Return the number of bytes written to the caller. + * TODO, needs to impose a limit on the file size. This is intended only for + * small files. (I don't know, maybe 8K or less.) For larger files, use interleaved + * I/O to avoid slowing the rest of the system down. + * TODO: we should return a code rather than barf, in case of file-not-found. + * TODO, does this compile on Windows? + * TODO, given that we want this to work only with small files, how about allocating + * the buffer on the stack rather than the heap? + * + * Modified 25Jul07. This now returns -1 on file-too-large; 0 for success, and a positive + * errno in case of other errors. + * + * Contributed by Kirk Haines. + */ + + char data[32*1024]; + int r; + + ensure_eventmachine("evma_send_file_data_to_connection"); + +#if defined(OS_WIN32) + int Fd = open (filename, O_RDONLY|O_BINARY); +#else + int Fd = open (filename, O_RDONLY); +#endif + if (Fd < 0) + return errno; + // From here on, all early returns MUST close Fd. + + struct stat st; + if (fstat (Fd, &st)) { + int e = errno; + close (Fd); + return e; + } + + off_t filesize = st.st_size; + if (filesize <= 0) { + close (Fd); + return 0; + } + else if (filesize > (off_t) sizeof(data)) { + close (Fd); + return -1; + } + + r = read (Fd, data, filesize); + if (r != filesize) { + int e = errno; + close (Fd); + return e; + } + evma_send_data_to_connection (binding, data, r); + close (Fd); + + return 0; +} + + +/**************** +evma_start_proxy +*****************/ + +extern "C" void evma_start_proxy (const uintptr_t from, const uintptr_t to, const unsigned long bufsize, const unsigned long length) +{ + ensure_eventmachine("evma_start_proxy"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (from)); + if (ed) + ed->StartProxy(to, bufsize, length); +} + + +/*************** +evma_stop_proxy +****************/ + +extern "C" void evma_stop_proxy (const uintptr_t from) +{ + ensure_eventmachine("evma_stop_proxy"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (from)); + if (ed) + ed->StopProxy(); +} + +/****************** +evma_proxied_bytes +*******************/ + +extern "C" unsigned long evma_proxied_bytes (const uintptr_t from) +{ + ensure_eventmachine("evma_proxied_bytes"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (from)); + if (ed) + return ed->GetProxiedBytes(); + else + return 0; +} + + +/*************************** +evma_get_last_activity_time +****************************/ + +extern "C" uint64_t evma_get_last_activity_time(const uintptr_t from) +{ + ensure_eventmachine("evma_get_last_activity_time"); + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (from)); + if (ed) + return ed->GetLastActivity(); + else + return 0; +} + + +/*************************** +evma_get_heartbeat_interval +****************************/ + +extern "C" float evma_get_heartbeat_interval() +{ + ensure_eventmachine("evma_get_heartbeat_interval"); + return EventMachine->GetHeartbeatInterval(); +} + + +/*************************** +evma_set_heartbeat_interval +****************************/ + +extern "C" int evma_set_heartbeat_interval(float interval) +{ + ensure_eventmachine("evma_set_heartbeat_interval"); + return EventMachine->SetHeartbeatInterval(interval); +} + + +/************************** +evma_get_current_loop_time +***************************/ + +extern "C" uint64_t evma_get_current_loop_time() +{ + ensure_eventmachine("evma_get_current_loop_time"); + return EventMachine->GetCurrentLoopTime(); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ed.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ed.cpp new file mode 100644 index 0000000..a469dff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ed.cpp @@ -0,0 +1,2096 @@ +/***************************************************************************** + +$Id$ + +File: ed.cpp +Date: 06Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#include "project.h" + + + +/******************** +SetSocketNonblocking +********************/ + +bool SetSocketNonblocking (SOCKET sd) +{ + #ifdef OS_UNIX + int val = fcntl (sd, F_GETFL, 0); + return (fcntl (sd, F_SETFL, val | O_NONBLOCK) != SOCKET_ERROR) ? true : false; + #endif + + #ifdef OS_WIN32 + #ifdef BUILD_FOR_RUBY + // 14Jun09 Ruby provides its own wrappers for ioctlsocket. On 1.8 this is a simple wrapper, + // however, 1.9 keeps its own state about the socket. + // NOTE: F_GETFL is not supported + return (fcntl (sd, F_SETFL, O_NONBLOCK) == 0) ? true : false; + #else + unsigned long one = 1; + return (ioctlsocket (sd, FIONBIO, &one) == 0) ? true : false; + #endif + #endif +} + +/************ +SetFdCloexec +************/ + +#ifdef OS_UNIX +bool SetFdCloexec (int fd) +{ + int flags = fcntl(fd, F_GETFD, 0); + assert (flags >= 0); + flags |= FD_CLOEXEC; + return (fcntl(fd, F_SETFD, FD_CLOEXEC) == 0) ? true : false; +} +#else +bool SetFdCloexec (int fd UNUSED) +{ + return true; +} +#endif + +/**************************************** +EventableDescriptor::EventableDescriptor +****************************************/ + +EventableDescriptor::EventableDescriptor (SOCKET sd, EventMachine_t *em): + bCloseNow (false), + bCloseAfterWriting (false), + MySocket (sd), + bAttached (false), + bWatchOnly (false), + EventCallback (NULL), + bCallbackUnbind (true), + UnbindReasonCode (0), + ProxyTarget(NULL), + ProxiedFrom(NULL), + ProxiedBytes(0), + MaxOutboundBufSize(0), + MyEventMachine (em), + PendingConnectTimeout(20000000), + InactivityTimeout (0), + NextHeartbeat (0), + bPaused (false) +{ + /* There are three ways to close a socket, all of which should + * automatically signal to the event machine that this object + * should be removed from the polling scheduler. + * First is a hard close, intended for bad errors or possible + * security violations. It immediately closes the connection + * and puts this object into an error state. + * Second is to set bCloseNow, which will cause the event machine + * to delete this object (and thus close the connection in our + * destructor) the next chance it gets. bCloseNow also inhibits + * the writing of new data on the socket (but not necessarily + * the reading of new data). + * The third way is to set bCloseAfterWriting, which inhibits + * the writing of new data and converts to bCloseNow as soon + * as everything in the outbound queue has been written. + * bCloseAfterWriting is really for use only by protocol handlers + * (for example, HTTP writes an HTML page and then closes the + * connection). All of the error states we generate internally + * cause an immediate close to be scheduled, which may have the + * effect of discarding outbound data. + */ + + if (sd == INVALID_SOCKET) + throw std::runtime_error ("bad eventable descriptor"); + if (MyEventMachine == NULL) + throw std::runtime_error ("bad em in eventable descriptor"); + CreatedAt = MyEventMachine->GetCurrentLoopTime(); + LastActivity = MyEventMachine->GetCurrentLoopTime(); + + #ifdef HAVE_EPOLL + EpollEvent.events = 0; + EpollEvent.data.ptr = this; + #endif +} + + +/***************************************** +EventableDescriptor::~EventableDescriptor +*****************************************/ + +EventableDescriptor::~EventableDescriptor() NO_EXCEPT_FALSE +{ + if (NextHeartbeat) + MyEventMachine->ClearHeartbeat(NextHeartbeat, this); + if (EventCallback && bCallbackUnbind) + (*EventCallback)(GetBinding(), EM_CONNECTION_UNBOUND, NULL, UnbindReasonCode); + if (ProxiedFrom) { + (*EventCallback)(ProxiedFrom->GetBinding(), EM_PROXY_TARGET_UNBOUND, NULL, 0); + ProxiedFrom->StopProxy(); + } + MyEventMachine->NumCloseScheduled--; + StopProxy(); + Close(); +} + + +/************************************* +EventableDescriptor::SetEventCallback +*************************************/ + +void EventableDescriptor::SetEventCallback (EMCallback cb) +{ + EventCallback = cb; +} + + +/************************** +EventableDescriptor::Close +**************************/ + +void EventableDescriptor::Close() +{ + /* EventMachine relies on the fact that when close(fd) + * is called that the fd is removed from any + * epoll event queues. + * + * However, this is not *always* the behavior of close(fd) + * + * See man 4 epoll Q6/A6 and then consider what happens + * when using pipes with eventmachine. + * (As is often done when communicating with a subprocess) + * + * The pipes end up looking like: + * + * ls -l /proc//fd + * ... + * lr-x------ 1 root root 64 2011-08-19 21:31 3 -> pipe:[940970] + * l-wx------ 1 root root 64 2011-08-19 21:31 4 -> pipe:[940970] + * + * This meets the critera from man 4 epoll Q6/A4 for not + * removing fds from epoll event queues until all fds + * that reference the underlying file have been removed. + * + * If the EventableDescriptor associated with fd 3 is deleted, + * its dtor will call EventableDescriptor::Close(), + * which will call ::close(int fd). + * + * However, unless the EventableDescriptor associated with fd 4 is + * also deleted before the next call to epoll_wait, events may fire + * for fd 3 that were registered with an already deleted + * EventableDescriptor. + * + * Therefore, it is necessary to notify EventMachine that + * the fd associated with this EventableDescriptor is + * closing. + * + * EventMachine also never closes fds for STDIN, STDOUT and + * STDERR (0, 1 & 2) + */ + + // Close the socket right now. Intended for emergencies. + if (MySocket != INVALID_SOCKET) { + MyEventMachine->Deregister (this); + + // Do not close STDIN, STDOUT, STDERR + if (MySocket > 2 && !bAttached) { + shutdown (MySocket, 1); + close (MySocket); + } + + MySocket = INVALID_SOCKET; + } +} + + +/********************************* +EventableDescriptor::ShouldDelete +*********************************/ + +bool EventableDescriptor::ShouldDelete() +{ + /* For use by a socket manager, which needs to know if this object + * should be removed from scheduling events and deleted. + * Has an immediate close been scheduled, or are we already closed? + * If either of these are the case, return true. In theory, the manager will + * then delete us, which in turn will make sure the socket is closed. + * Note, if bCloseAfterWriting is true, we check a virtual method to see + * if there is outbound data to write, and only request a close if there is none. + */ + + return ((MySocket == INVALID_SOCKET) || bCloseNow || (bCloseAfterWriting && (GetOutboundDataSize() <= 0))); +} + + +/********************************** +EventableDescriptor::ScheduleClose +**********************************/ + +void EventableDescriptor::ScheduleClose (bool after_writing) +{ + if (IsCloseScheduled()) { + if (!after_writing) { + // If closing has become more urgent, then upgrade the scheduled + // after_writing close to one NOW. + bCloseNow = true; + } + return; + } + MyEventMachine->NumCloseScheduled++; + // KEEP THIS SYNCHRONIZED WITH ::IsCloseScheduled. + if (after_writing) + bCloseAfterWriting = true; + else + bCloseNow = true; +} + + +/************************************* +EventableDescriptor::IsCloseScheduled +*************************************/ + +bool EventableDescriptor::IsCloseScheduled() +{ + // KEEP THIS SYNCHRONIZED WITH ::ScheduleClose. + return (bCloseNow || bCloseAfterWriting); +} + + +/******************************* +EventableDescriptor::StartProxy +*******************************/ + +void EventableDescriptor::StartProxy(const uintptr_t to, const unsigned long bufsize, const unsigned long length) +{ + EventableDescriptor *ed = dynamic_cast (Bindable_t::GetObject (to)); + if (ed) { + StopProxy(); + ProxyTarget = ed; + BytesToProxy = length; + ProxiedBytes = 0; + ed->SetProxiedFrom(this, bufsize); + return; + } + throw std::runtime_error ("Tried to proxy to an invalid descriptor"); +} + + +/****************************** +EventableDescriptor::StopProxy +******************************/ + +void EventableDescriptor::StopProxy() +{ + if (ProxyTarget) { + ProxyTarget->SetProxiedFrom(NULL, 0); + ProxyTarget = NULL; + } +} + + +/*********************************** +EventableDescriptor::SetProxiedFrom +***********************************/ + +void EventableDescriptor::SetProxiedFrom(EventableDescriptor *from, const unsigned long bufsize) +{ + if (from != NULL && ProxiedFrom != NULL) + throw std::runtime_error ("Tried to proxy to a busy target"); + + ProxiedFrom = from; + MaxOutboundBufSize = bufsize; +} + + +/******************************************** +EventableDescriptor::_GenericInboundDispatch +********************************************/ + +void EventableDescriptor::_GenericInboundDispatch(const char *buf, unsigned long size) +{ + assert(EventCallback); + + if (ProxyTarget) { + if (BytesToProxy > 0) { + unsigned long proxied = std::min(BytesToProxy, size); + ProxyTarget->SendOutboundData(buf, proxied); + ProxiedBytes += (unsigned long) proxied; + BytesToProxy -= proxied; + if (BytesToProxy == 0) { + StopProxy(); + (*EventCallback)(GetBinding(), EM_PROXY_COMPLETED, NULL, 0); + if (proxied < size) { + (*EventCallback)(GetBinding(), EM_CONNECTION_READ, buf + proxied, size - proxied); + } + } + } else { + ProxyTarget->SendOutboundData(buf, size); + ProxiedBytes += size; + } + } else { + (*EventCallback)(GetBinding(), EM_CONNECTION_READ, buf, size); + } +} + + +/********************************* +EventableDescriptor::_GenericGetPeername +*********************************/ + +bool EventableDescriptor::_GenericGetPeername (struct sockaddr *s, socklen_t *len) +{ + if (!s) + return false; + + int gp = getpeername (GetSocket(), s, len); + if (gp == -1) { + char buf[200]; + snprintf (buf, sizeof(buf)-1, "unable to get peer name: %s", strerror(errno)); + throw std::runtime_error (buf); + } + + return true; +} + +/********************************* +EventableDescriptor::_GenericGetSockname +*********************************/ + +bool EventableDescriptor::_GenericGetSockname (struct sockaddr *s, socklen_t *len) +{ + if (!s) + return false; + + int gp = getsockname (GetSocket(), s, len); + if (gp == -1) { + char buf[200]; + snprintf (buf, sizeof(buf)-1, "unable to get sock name: %s", strerror(errno)); + throw std::runtime_error (buf); + } + + return true; +} + + +/********************************************* +EventableDescriptor::GetPendingConnectTimeout +*********************************************/ + +uint64_t EventableDescriptor::GetPendingConnectTimeout() +{ + return PendingConnectTimeout / 1000; +} + + +/********************************************* +EventableDescriptor::SetPendingConnectTimeout +*********************************************/ + +int EventableDescriptor::SetPendingConnectTimeout (uint64_t value) +{ + if (value > 0) { + PendingConnectTimeout = value * 1000; + MyEventMachine->QueueHeartbeat(this); + return 1; + } + return 0; +} + + +/************************************* +EventableDescriptor::GetNextHeartbeat +*************************************/ + +uint64_t EventableDescriptor::GetNextHeartbeat() +{ + if (NextHeartbeat) + MyEventMachine->ClearHeartbeat(NextHeartbeat, this); + + NextHeartbeat = 0; + + if (!ShouldDelete()) { + uint64_t time_til_next = InactivityTimeout; + if (IsConnectPending()) { + if (time_til_next == 0 || PendingConnectTimeout < time_til_next) + time_til_next = PendingConnectTimeout; + } + if (time_til_next == 0) + return 0; + NextHeartbeat = time_til_next + MyEventMachine->GetRealTime(); + } + + return NextHeartbeat; +} + + +/****************************************** +ConnectionDescriptor::ConnectionDescriptor +******************************************/ + +ConnectionDescriptor::ConnectionDescriptor (SOCKET sd, EventMachine_t *em): + EventableDescriptor (sd, em), + bConnectPending (false), + bNotifyReadable (false), + bNotifyWritable (false), + bReadAttemptedAfterClose (false), + bWriteAttemptedAfterClose (false), + OutboundDataSize (0), + #ifdef WITH_SSL + SslBox (NULL), + bHandshakeSignaled (false), + bSslVerifyPeer (false), + bSslPeerAccepted(false), + #endif + #ifdef HAVE_KQUEUE + bGotExtraKqueueEvent(false), + #endif + bIsServer (false) +{ + // 22Jan09: Moved ArmKqueueWriter into SetConnectPending() to fix assertion failure in _WriteOutboundData() + // 5May09: Moved EPOLLOUT into SetConnectPending() so it doesn't happen for attached read pipes +} + + +/******************************************* +ConnectionDescriptor::~ConnectionDescriptor +*******************************************/ + +ConnectionDescriptor::~ConnectionDescriptor() +{ + // Run down any stranded outbound data. + for (size_t i=0; i < OutboundPages.size(); i++) + OutboundPages[i].Free(); + + #ifdef WITH_SSL + if (SslBox) + delete SslBox; + #endif +} + + +/*********************************** +ConnectionDescriptor::_UpdateEvents +************************************/ + +void ConnectionDescriptor::_UpdateEvents() +{ + _UpdateEvents(true, true); +} + +void ConnectionDescriptor::_UpdateEvents(bool read, bool write) +{ + if (MySocket == INVALID_SOCKET) + return; + + if (!read && !write) + return; + + #ifdef HAVE_EPOLL + unsigned int old = EpollEvent.events; + + if (read) { + if (SelectForRead()) + EpollEvent.events |= EPOLLIN; + else + EpollEvent.events &= ~EPOLLIN; + } + + if (write) { + if (SelectForWrite()) + EpollEvent.events |= EPOLLOUT; + else + EpollEvent.events &= ~EPOLLOUT; + } + + if (old != EpollEvent.events) + MyEventMachine->Modify (this); + #endif + + #ifdef HAVE_KQUEUE + if (read && SelectForRead()) + MyEventMachine->ArmKqueueReader (this); + bKqueueArmWrite = SelectForWrite(); + if (write && bKqueueArmWrite) + MyEventMachine->Modify (this); + #endif +} + +/*************************************** +ConnectionDescriptor::SetConnectPending +****************************************/ + +void ConnectionDescriptor::SetConnectPending(bool f) +{ + bConnectPending = f; + MyEventMachine->QueueHeartbeat(this); + _UpdateEvents(); +} + + +/********************************** +ConnectionDescriptor::SetAttached +***********************************/ + +void ConnectionDescriptor::SetAttached(bool state) +{ + bAttached = state; +} + + +/********************************** +ConnectionDescriptor::SetWatchOnly +***********************************/ + +void ConnectionDescriptor::SetWatchOnly(bool watching) +{ + bWatchOnly = watching; + _UpdateEvents(); +} + + +/********************************* +ConnectionDescriptor::HandleError +*********************************/ + +void ConnectionDescriptor::HandleError() +{ + if (bWatchOnly) { + // An EPOLLHUP | EPOLLIN condition will call Read() before HandleError(), in which case the + // socket is already detached and invalid, so we don't need to do anything. + if (MySocket == INVALID_SOCKET) return; + + // HandleError() is called on WatchOnly descriptors by the epoll reactor + // when it gets a EPOLLERR | EPOLLHUP. Usually this would show up as a readable and + // writable event on other reactors, so we have to fire those events ourselves. + if (bNotifyReadable) Read(); + if (bNotifyWritable) Write(); + } else { + ScheduleClose (false); + } +} + + +/*********************************** +ConnectionDescriptor::ScheduleClose +***********************************/ + +void ConnectionDescriptor::ScheduleClose (bool after_writing) +{ + if (bWatchOnly) + throw std::runtime_error ("cannot close 'watch only' connections"); + + EventableDescriptor::ScheduleClose(after_writing); +} + + +/*************************************** +ConnectionDescriptor::SetNotifyReadable +****************************************/ + +void ConnectionDescriptor::SetNotifyReadable(bool readable) +{ + if (!bWatchOnly) + throw std::runtime_error ("notify_readable must be on 'watch only' connections"); + + bNotifyReadable = readable; + _UpdateEvents(true, false); +} + + +/*************************************** +ConnectionDescriptor::SetNotifyWritable +****************************************/ + +void ConnectionDescriptor::SetNotifyWritable(bool writable) +{ + if (!bWatchOnly) + throw std::runtime_error ("notify_writable must be on 'watch only' connections"); + + bNotifyWritable = writable; + _UpdateEvents(false, true); +} + + +/************************************** +ConnectionDescriptor::SendOutboundData +**************************************/ + +int ConnectionDescriptor::SendOutboundData (const char *data, unsigned long length) +{ + if (bWatchOnly) + throw std::runtime_error ("cannot send data on a 'watch only' connection"); + + if (ProxiedFrom && MaxOutboundBufSize && (unsigned int)(GetOutboundDataSize() + length) > MaxOutboundBufSize) + ProxiedFrom->Pause(); + + #ifdef WITH_SSL + if (SslBox) { + if (length > 0) { + unsigned long writed = 0; + char *p = (char*)data; + + while (writed < length) { + int to_write = SSLBOX_INPUT_CHUNKSIZE; + int remaining = length - writed; + + if (remaining < SSLBOX_INPUT_CHUNKSIZE) + to_write = remaining; + + int w = SslBox->PutPlaintext (p, to_write); + if (w < 0) { + ScheduleClose (false); + }else + _DispatchCiphertext(); + + p += to_write; + writed += to_write; + } + } + // TODO: What's the correct return value? + return 1; // That's a wild guess, almost certainly wrong. + } + else + #endif + return _SendRawOutboundData (data, length); +} + + + +/****************************************** +ConnectionDescriptor::_SendRawOutboundData +******************************************/ + +int ConnectionDescriptor::_SendRawOutboundData (const char *data, unsigned long length) +{ + /* This internal method is called to schedule bytes that + * will be sent out to the remote peer. + * It's not directly accessed by the caller, who hits ::SendOutboundData, + * which may or may not filter or encrypt the caller's data before + * sending it here. + */ + + // Highly naive and incomplete implementation. + // There's no throttle for runaways (which should abort only this connection + // and not the whole process), and no coalescing of small pages. + // (Well, not so bad, small pages are coalesced in ::Write) + + if (IsCloseScheduled()) + return 0; + // 25Mar10: Ignore 0 length packets as they are not meaningful in TCP (as opposed to UDP) + // and can cause the assert(nbytes>0) to fail when OutboundPages has a bunch of 0 length pages. + if (length == 0) + return 0; + + if (!data && (length > 0)) + throw std::runtime_error ("bad outbound data"); + char *buffer = (char *) malloc (length + 1); + if (!buffer) + throw std::runtime_error ("no allocation for outbound data"); + + memcpy (buffer, data, length); + buffer [length] = 0; + OutboundPages.push_back (OutboundPage (buffer, length)); + OutboundDataSize += length; + + _UpdateEvents(false, true); + + return length; +} + + + +/*********************************** +ConnectionDescriptor::SelectForRead +***********************************/ + +bool ConnectionDescriptor::SelectForRead() +{ + /* A connection descriptor is always scheduled for read, + * UNLESS it's in a pending-connect state. + * On Linux, unlike Unix, a nonblocking socket on which + * connect has been called, does NOT necessarily select + * both readable and writable in case of error. + * The socket will select writable when the disposition + * of the connect is known. On the other hand, a socket + * which successfully connects and selects writable may + * indeed have some data available on it, so it will + * select readable in that case, violating expectations! + * So we will not poll for readability until the socket + * is known to be in a connected state. + */ + + if (bPaused) + return false; + else if (bConnectPending) + return false; + else if (bWatchOnly) + return bNotifyReadable ? true : false; + else + return true; +} + + +/************************************ +ConnectionDescriptor::SelectForWrite +************************************/ + +bool ConnectionDescriptor::SelectForWrite() +{ + /* Cf the notes under SelectForRead. + * In a pending-connect state, we ALWAYS select for writable. + * In a normal state, we only select for writable when we + * have outgoing data to send. + */ + + if (bPaused) + return false; + else if (bConnectPending) + return true; + else if (bWatchOnly) + return bNotifyWritable ? true : false; + else + return (GetOutboundDataSize() > 0); +} + +/*************************** +ConnectionDescriptor::Pause +***************************/ + +bool ConnectionDescriptor::Pause() +{ + if (bWatchOnly) + throw std::runtime_error ("cannot pause/resume 'watch only' connections, set notify readable/writable instead"); + + bool old = bPaused; + bPaused = true; + _UpdateEvents(); + return old == false; +} + +/**************************** +ConnectionDescriptor::Resume +****************************/ + +bool ConnectionDescriptor::Resume() +{ + if (bWatchOnly) + throw std::runtime_error ("cannot pause/resume 'watch only' connections, set notify readable/writable instead"); + + bool old = bPaused; + bPaused = false; + _UpdateEvents(); + return old == true; +} + +/************************** +ConnectionDescriptor::Read +**************************/ + +void ConnectionDescriptor::Read() +{ + /* Read and dispatch data on a socket that has selected readable. + * It's theoretically possible to get and dispatch incoming data on + * a socket that has already been scheduled for closing or close-after-writing. + * In those cases, we'll leave it up the to protocol handler to "do the + * right thing" (which probably means to ignore the incoming data). + * + * 22Aug06: Chris Ochs reports that on FreeBSD, it's possible to come + * here with the socket already closed, after the process receives + * a ctrl-C signal (not sure if that's TERM or INT on BSD). The application + * was one in which network connections were doing a lot of interleaved reads + * and writes. + * Since we always write before reading (in order to keep the outbound queues + * as light as possible), I think what happened is that an interrupt caused + * the socket to be closed in ConnectionDescriptor::Write. We'll then + * come here in the same pass through the main event loop, and won't get + * cleaned up until immediately after. + * We originally asserted that the socket was valid when we got here. + * To deal properly with the possibility that we are closed when we get here, + * I removed the assert. HOWEVER, the potential for an infinite loop scares me, + * so even though this is really clunky, I added a flag to assert that we never + * come here more than once after being closed. (FCianfrocca) + */ + + SOCKET sd = GetSocket(); + //assert (sd != INVALID_SOCKET); (original, removed 22Aug06) + if (sd == INVALID_SOCKET) { + assert (!bReadAttemptedAfterClose); + bReadAttemptedAfterClose = true; + return; + } + + if (bWatchOnly) { + if (bNotifyReadable && EventCallback) + (*EventCallback)(GetBinding(), EM_CONNECTION_NOTIFY_READABLE, NULL, 0); + return; + } + + LastActivity = MyEventMachine->GetCurrentLoopTime(); + + int total_bytes_read = 0; + char readbuffer [16 * 1024 + 1]; + + for (int i=0; i < 10; i++) { + // Don't read just one buffer and then move on. This is faster + // if there is a lot of incoming. + // But don't read indefinitely. Give other sockets a chance to run. + // NOTICE, we're reading one less than the buffer size. + // That's so we can put a guard byte at the end of what we send + // to user code. + + + int r = read (sd, readbuffer, sizeof(readbuffer) - 1); +#ifdef OS_WIN32 + int e = WSAGetLastError(); +#else + int e = errno; +#endif + //cerr << ""; + + if (r > 0) { + total_bytes_read += r; + + // Add a null-terminator at the the end of the buffer + // that we will send to the callback. + // DO NOT EVER CHANGE THIS. We want to explicitly allow users + // to be able to depend on this behavior, so they will have + // the option to do some things faster. Additionally it's + // a security guard against buffer overflows. + readbuffer [r] = 0; + _DispatchInboundData (readbuffer, r); + if (bPaused) + break; + } + else if (r == 0) { + break; + } + else { + #ifdef OS_UNIX + if ((e != EINPROGRESS) && (e != EWOULDBLOCK) && (e != EAGAIN) && (e != EINTR)) { + #endif + #ifdef OS_WIN32 + if ((e != WSAEINPROGRESS) && (e != WSAEWOULDBLOCK)) { + #endif + // 26Mar11: Previously, all read errors were assumed to be EWOULDBLOCK and ignored. + // Now, instead, we call Close() on errors like ECONNRESET and ENOTCONN. + UnbindReasonCode = e; + Close(); + break; + } else { + // Basically a would-block, meaning we've read everything there is to read. + break; + } + } + + } + + + if (total_bytes_read == 0) { + // If we read no data on a socket that selected readable, + // it generally means the other end closed the connection gracefully. + ScheduleClose (false); + //bCloseNow = true; + } + +} + + + +/****************************************** +ConnectionDescriptor::_DispatchInboundData +******************************************/ + +#ifdef WITH_SSL +void ConnectionDescriptor::_DispatchInboundData (const char *buffer, unsigned long size) +{ + if (SslBox) { + SslBox->PutCiphertext (buffer, size); + + int s; + char B [2048]; + while ((s = SslBox->GetPlaintext (B, sizeof(B) - 1)) > 0) { + _CheckHandshakeStatus(); + B [s] = 0; + _GenericInboundDispatch(B, s); + } + + // If our SSL handshake had a problem, shut down the connection. + if (s == -2) { + #ifndef EPROTO // OpenBSD does not have EPROTO + #define EPROTO EINTR + #endif + #ifdef OS_UNIX + UnbindReasonCode = EPROTO; + #endif + #ifdef OS_WIN32 + UnbindReasonCode = WSAECONNABORTED; + #endif + ScheduleClose(false); + return; + } + + _CheckHandshakeStatus(); + _DispatchCiphertext(); + } + else { + _GenericInboundDispatch(buffer, size); + } +} +#else +void ConnectionDescriptor::_DispatchInboundData (const char *buffer, unsigned long size) +{ + _GenericInboundDispatch(buffer, size); +} +#endif + + + +/******************************************* +ConnectionDescriptor::_CheckHandshakeStatus +*******************************************/ + +void ConnectionDescriptor::_CheckHandshakeStatus() +{ + #ifdef WITH_SSL + if (SslBox && (!bHandshakeSignaled) && SslBox->IsHandshakeCompleted()) { + bHandshakeSignaled = true; + if (EventCallback) + (*EventCallback)(GetBinding(), EM_SSL_HANDSHAKE_COMPLETED, NULL, 0); + } + #endif +} + + + +/*************************** +ConnectionDescriptor::Write +***************************/ + +void ConnectionDescriptor::Write() +{ + /* A socket which is in a pending-connect state will select + * writable when the disposition of the connect is known. + * At that point, check to be sure there are no errors, + * and if none, then promote the socket out of the pending + * state. + * TODO: I haven't figured out how Windows signals errors on + * unconnected sockets. Maybe it does the untraditional but + * logical thing and makes the socket selectable for error. + * If so, it's unsupported here for the time being, and connect + * errors will have to be caught by the timeout mechanism. + */ + + if (bConnectPending) { + int error; + socklen_t len; + len = sizeof(error); + #ifdef OS_UNIX + int o = getsockopt (GetSocket(), SOL_SOCKET, SO_ERROR, &error, &len); + #endif + #ifdef OS_WIN32 + int o = getsockopt (GetSocket(), SOL_SOCKET, SO_ERROR, (char*)&error, &len); + #endif + if ((o == 0) && (error == 0)) { + if (EventCallback) + (*EventCallback)(GetBinding(), EM_CONNECTION_COMPLETED, "", 0); + + // 5May09: Moved epoll/kqueue read/write arming into SetConnectPending, so it can be called + // from EventMachine_t::AttachFD as well. + SetConnectPending (false); + } + else { + if (o == 0) + UnbindReasonCode = error; + ScheduleClose (false); + //bCloseNow = true; + } + } + else { + + if (bNotifyWritable) { + if (EventCallback) + (*EventCallback)(GetBinding(), EM_CONNECTION_NOTIFY_WRITABLE, NULL, 0); + + _UpdateEvents(false, true); + return; + } + + assert(!bWatchOnly); + + /* 5May09: Kqueue bugs on OSX cause one extra writable event to fire even though we're using + EV_ONESHOT. We ignore this extra event once, but only the first time. If it happens again, + we should fall through to the assert(nbytes>0) failure to catch any EM bugs which might cause + ::Write to be called in a busy-loop. + */ + #ifdef HAVE_KQUEUE + if (MyEventMachine->GetPoller() == Poller_Kqueue) { + if (OutboundDataSize == 0 && !bGotExtraKqueueEvent) { + bGotExtraKqueueEvent = true; + return; + } else if (OutboundDataSize > 0) { + bGotExtraKqueueEvent = false; + } + } + #endif + + _WriteOutboundData(); + } +} + + +/**************************************** +ConnectionDescriptor::_WriteOutboundData +****************************************/ + +void ConnectionDescriptor::_WriteOutboundData() +{ + /* This is a helper function called by ::Write. + * It's possible for a socket to select writable and then no longer + * be writable by the time we get around to writing. The kernel might + * have used up its available output buffers between the select call + * and when we get here. So this condition is not an error. + * + * 20Jul07, added the same kind of protection against an invalid socket + * that is at the top of ::Read. Not entirely how this could happen in + * real life (connection-reset from the remote peer, perhaps?), but I'm + * doing it to address some reports of crashing under heavy loads. + */ + + SOCKET sd = GetSocket(); + //assert (sd != INVALID_SOCKET); + if (sd == INVALID_SOCKET) { + assert (!bWriteAttemptedAfterClose); + bWriteAttemptedAfterClose = true; + return; + } + + LastActivity = MyEventMachine->GetCurrentLoopTime(); + size_t nbytes = 0; + + #ifdef HAVE_WRITEV + int iovcnt = OutboundPages.size(); + // Max of 16 outbound pages at a time + if (iovcnt > 16) iovcnt = 16; + + iovec iov[16]; + + for(int i = 0; i < iovcnt; i++){ + OutboundPage *op = &(OutboundPages[i]); + #ifdef CC_SUNWspro + // TODO: The void * cast works fine on Solaris 11, but + // I don't know at what point that changed from older Solaris. + iov[i].iov_base = (char *)(op->Buffer + op->Offset); + #else + iov[i].iov_base = (void *)(op->Buffer + op->Offset); + #endif + iov[i].iov_len = op->Length - op->Offset; + + nbytes += iov[i].iov_len; + } + #else + char output_buffer [16 * 1024]; + + while ((OutboundPages.size() > 0) && (nbytes < sizeof(output_buffer))) { + OutboundPage *op = &(OutboundPages[0]); + if ((nbytes + op->Length - op->Offset) < sizeof (output_buffer)) { + memcpy (output_buffer + nbytes, op->Buffer + op->Offset, op->Length - op->Offset); + nbytes += (op->Length - op->Offset); + op->Free(); + OutboundPages.pop_front(); + } + else { + int len = sizeof(output_buffer) - nbytes; + memcpy (output_buffer + nbytes, op->Buffer + op->Offset, len); + op->Offset += len; + nbytes += len; + } + } + #endif + + // We should never have gotten here if there were no data to write, + // so assert that as a sanity check. + // Don't bother to make sure nbytes is less than output_buffer because + // if it were we probably would have crashed already. + assert (nbytes > 0); + + assert (GetSocket() != INVALID_SOCKET); + #ifdef HAVE_WRITEV + int bytes_written = writev (GetSocket(), iov, iovcnt); + #else + int bytes_written = write (GetSocket(), output_buffer, nbytes); + #endif + + bool err = false; +#ifdef OS_WIN32 + int e = WSAGetLastError(); +#else + int e = errno; +#endif + if (bytes_written < 0) { + err = true; + bytes_written = 0; + } + + assert (bytes_written >= 0); + OutboundDataSize -= bytes_written; + + if (ProxiedFrom && MaxOutboundBufSize && (unsigned int)GetOutboundDataSize() < MaxOutboundBufSize && ProxiedFrom->IsPaused()) + ProxiedFrom->Resume(); + + #ifdef HAVE_WRITEV + if (!err) { + unsigned int sent = bytes_written; + std::deque::iterator op = OutboundPages.begin(); + + for (int i = 0; i < iovcnt; i++) { + if (iov[i].iov_len <= sent) { + // Sent this page in full, free it. + op->Free(); + OutboundPages.pop_front(); + + sent -= iov[i].iov_len; + } else { + // Sent part (or none) of this page, increment offset to send the remainder + op->Offset += sent; + break; + } + + // Shouldn't be possible run out of pages before the loop ends + assert(op != OutboundPages.end()); + *op++; + } + } + #else + if ((size_t)bytes_written < nbytes) { + int len = nbytes - bytes_written; + char *buffer = (char*) malloc (len + 1); + if (!buffer) + throw std::runtime_error ("bad alloc throwing back data"); + memcpy (buffer, output_buffer + bytes_written, len); + buffer [len] = 0; + OutboundPages.push_front (OutboundPage (buffer, len)); + } + #endif + + _UpdateEvents(false, true); + + if (err) { + #ifdef OS_UNIX + if ((e != EINPROGRESS) && (e != EWOULDBLOCK) && (e != EINTR)) { + #endif + #ifdef OS_WIN32 + if ((e != WSAEINPROGRESS) && (e != WSAEWOULDBLOCK)) { + #endif + UnbindReasonCode = e; + Close(); + } + } +} + + +/*************************************** +ConnectionDescriptor::ReportErrorStatus +***************************************/ + +int ConnectionDescriptor::ReportErrorStatus() +{ + if (MySocket == INVALID_SOCKET) { + return -1; + } + + int error; + socklen_t len; + len = sizeof(error); + #ifdef OS_UNIX + int o = getsockopt (GetSocket(), SOL_SOCKET, SO_ERROR, &error, &len); + #endif + #ifdef OS_WIN32 + int o = getsockopt (GetSocket(), SOL_SOCKET, SO_ERROR, (char*)&error, &len); + #endif + if ((o == 0) && (error == 0)) + return 0; + else if (o == 0) + return error; + else + return -1; +} + + +/****************************** +ConnectionDescriptor::StartTls +******************************/ + +#ifdef WITH_SSL +void ConnectionDescriptor::StartTls() +{ + if (SslBox) + throw std::runtime_error ("SSL/TLS already running on connection"); + + SslBox = new SslBox_t (bIsServer, PrivateKeyFilename, CertChainFilename, bSslVerifyPeer, bSslFailIfNoPeerCert, SniHostName, CipherList, EcdhCurve, DhParam, Protocols, GetBinding()); + _DispatchCiphertext(); + +} +#else +void ConnectionDescriptor::StartTls() +{ + throw std::runtime_error ("Encryption not available on this event-machine"); +} +#endif + + +/********************************* +ConnectionDescriptor::SetTlsParms +*********************************/ + +#ifdef WITH_SSL +void ConnectionDescriptor::SetTlsParms (const char *privkey_filename, const char *certchain_filename, bool verify_peer, bool fail_if_no_peer_cert, const char *sni_hostname, const char *cipherlist, const char *ecdh_curve, const char *dhparam, int protocols) +{ + if (SslBox) + throw std::runtime_error ("call SetTlsParms before calling StartTls"); + if (privkey_filename && *privkey_filename) + PrivateKeyFilename = privkey_filename; + if (certchain_filename && *certchain_filename) + CertChainFilename = certchain_filename; + bSslVerifyPeer = verify_peer; + bSslFailIfNoPeerCert = fail_if_no_peer_cert; + + if (sni_hostname && *sni_hostname) + SniHostName = sni_hostname; + if (cipherlist && *cipherlist) + CipherList = cipherlist; + if (ecdh_curve && *ecdh_curve) + EcdhCurve = ecdh_curve; + if (dhparam && *dhparam) + DhParam = dhparam; + + Protocols = protocols; +} +#else +void ConnectionDescriptor::SetTlsParms (const char *privkey_filename UNUSED, const char *certchain_filename UNUSED, bool verify_peer UNUSED, bool fail_if_no_peer_cert UNUSED, const char *sni_hostname UNUSED, const char *cipherlist UNUSED, const char *ecdh_curve UNUSED, const char *dhparam UNUSED, int protocols UNUSED) +{ + throw std::runtime_error ("Encryption not available on this event-machine"); +} +#endif + + +/********************************* +ConnectionDescriptor::GetPeerCert +*********************************/ + +#ifdef WITH_SSL +X509 *ConnectionDescriptor::GetPeerCert() +{ + if (!SslBox) + throw std::runtime_error ("SSL/TLS not running on this connection"); + return SslBox->GetPeerCert(); +} +#endif + + +/********************************* +ConnectionDescriptor::GetCipherBits +*********************************/ + +#ifdef WITH_SSL +int ConnectionDescriptor::GetCipherBits() +{ + if (!SslBox) + throw std::runtime_error ("SSL/TLS not running on this connection"); + return SslBox->GetCipherBits(); +} +#endif + + +/********************************* +ConnectionDescriptor::GetCipherName +*********************************/ + +#ifdef WITH_SSL +const char *ConnectionDescriptor::GetCipherName() +{ + if (!SslBox) + throw std::runtime_error ("SSL/TLS not running on this connection"); + return SslBox->GetCipherName(); +} +#endif + + +/********************************* +ConnectionDescriptor::GetCipherProtocol +*********************************/ + +#ifdef WITH_SSL +const char *ConnectionDescriptor::GetCipherProtocol() +{ + if (!SslBox) + throw std::runtime_error ("SSL/TLS not running on this connection"); + return SslBox->GetCipherProtocol(); +} +#endif + + +/********************************* +ConnectionDescriptor::GetSNIHostname +*********************************/ + +#ifdef WITH_SSL +const char *ConnectionDescriptor::GetSNIHostname() +{ + if (!SslBox) + throw std::runtime_error ("SSL/TLS not running on this connection"); + return SslBox->GetSNIHostname(); +} +#endif + + +/*********************************** +ConnectionDescriptor::VerifySslPeer +***********************************/ + +#ifdef WITH_SSL +bool ConnectionDescriptor::VerifySslPeer(const char *cert) +{ + bSslPeerAccepted = false; + + if (EventCallback) + (*EventCallback)(GetBinding(), EM_SSL_VERIFY, cert, strlen(cert)); + + return bSslPeerAccepted; +} +#endif + + +/*********************************** +ConnectionDescriptor::AcceptSslPeer +***********************************/ + +#ifdef WITH_SSL +void ConnectionDescriptor::AcceptSslPeer() +{ + bSslPeerAccepted = true; +} +#endif + + +/***************************************** +ConnectionDescriptor::_DispatchCiphertext +*****************************************/ + +#ifdef WITH_SSL +void ConnectionDescriptor::_DispatchCiphertext() +{ + assert (SslBox); + + + char BigBuf [SSLBOX_OUTPUT_CHUNKSIZE]; + bool did_work; + + do { + did_work = false; + + // try to drain ciphertext + while (SslBox->CanGetCiphertext()) { + int r = SslBox->GetCiphertext (BigBuf, sizeof(BigBuf)); + assert (r > 0); + _SendRawOutboundData (BigBuf, r); + did_work = true; + } + + // Pump the SslBox, in case it has queued outgoing plaintext + // This will return >0 if data was written, + // 0 if no data was written, and <0 if there was a fatal error. + bool pump; + do { + pump = false; + int w = SslBox->PutPlaintext (NULL, 0); + if (w > 0) { + did_work = true; + pump = true; + } + else if (w < 0) + ScheduleClose (false); + } while (pump); + + // try to put plaintext. INCOMPLETE, doesn't belong here? + // In SendOutboundData, we're spooling plaintext directly + // into SslBox. That may be wrong, we may need to buffer it + // up here! + /* + const char *ptr; + int ptr_length; + while (OutboundPlaintext.GetPage (&ptr, &ptr_length)) { + assert (ptr && (ptr_length > 0)); + int w = SslMachine.PutPlaintext (ptr, ptr_length); + if (w > 0) { + OutboundPlaintext.DiscardBytes (w); + did_work = true; + } + else + break; + } + */ + + } while (did_work); + +} +#endif + + + +/******************************* +ConnectionDescriptor::Heartbeat +*******************************/ + +void ConnectionDescriptor::Heartbeat() +{ + /* Only allow a certain amount of time to go by while waiting + * for a pending connect. If it expires, then kill the socket. + * For a connected socket, close it if its inactivity timer + * has expired. + */ + + if (bConnectPending) { + if ((MyEventMachine->GetCurrentLoopTime() - CreatedAt) >= PendingConnectTimeout) { + UnbindReasonCode = ETIMEDOUT; + ScheduleClose (false); + //bCloseNow = true; + } + } + else { + if (InactivityTimeout && ((MyEventMachine->GetCurrentLoopTime() - LastActivity) >= InactivityTimeout)) { + UnbindReasonCode = ETIMEDOUT; + ScheduleClose (false); + //bCloseNow = true; + } + } +} + + +/**************************************** +LoopbreakDescriptor::LoopbreakDescriptor +****************************************/ + +LoopbreakDescriptor::LoopbreakDescriptor (SOCKET sd, EventMachine_t *parent_em): + EventableDescriptor (sd, parent_em) +{ + /* This is really bad and ugly. Change someday if possible. + * We have to know about an event-machine (probably the one that owns us), + * so we can pass newly-created connections to it. + */ + + bCallbackUnbind = false; + + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + #endif + #ifdef HAVE_KQUEUE + MyEventMachine->ArmKqueueReader (this); + #endif +} + + + + +/************************* +LoopbreakDescriptor::Read +*************************/ + +void LoopbreakDescriptor::Read() +{ + // TODO, refactor, this code is probably in the wrong place. + assert (MyEventMachine); + MyEventMachine->_ReadLoopBreaker(); +} + + +/************************** +LoopbreakDescriptor::Write +**************************/ + +void LoopbreakDescriptor::Write() +{ + // Why are we here? + throw std::runtime_error ("bad code path in loopbreak"); +} + +/************************************** +AcceptorDescriptor::AcceptorDescriptor +**************************************/ + +AcceptorDescriptor::AcceptorDescriptor (SOCKET sd, EventMachine_t *parent_em): + EventableDescriptor (sd, parent_em) +{ + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + #endif + #ifdef HAVE_KQUEUE + MyEventMachine->ArmKqueueReader (this); + #endif +} + + +/*************************************** +AcceptorDescriptor::~AcceptorDescriptor +***************************************/ + +AcceptorDescriptor::~AcceptorDescriptor() +{ +} + +/**************************************** +STATIC: AcceptorDescriptor::StopAcceptor +****************************************/ + +void AcceptorDescriptor::StopAcceptor (const uintptr_t binding) +{ + // TODO: This is something of a hack, or at least it's a static method of the wrong class. + AcceptorDescriptor *ad = dynamic_cast (Bindable_t::GetObject (binding)); + if (ad) + ad->ScheduleClose (false); + else + throw std::runtime_error ("failed to close nonexistent acceptor"); +} + + +/************************ +AcceptorDescriptor::Read +************************/ + +void AcceptorDescriptor::Read() +{ + /* Accept up to a certain number of sockets on the listening connection. + * Don't try to accept all that are present, because this would allow a DoS attack + * in which no data were ever read or written. We should accept more than one, + * if available, to keep the partially accepted sockets from backing up in the kernel. + */ + + /* Make sure we use non-blocking i/o on the acceptor socket, since we're selecting it + * for readability. According to Stevens UNP, it's possible for an acceptor to select readable + * and then block when we call accept. For example, the other end resets the connection after + * the socket selects readable and before we call accept. The kernel will remove the dead + * socket from the accept queue. If the accept queue is now empty, accept will block. + */ + + + struct sockaddr_in6 pin; + socklen_t addrlen = sizeof (pin); + int accept_count = EventMachine_t::GetSimultaneousAcceptCount(); + + for (int i=0; i < accept_count; i++) { +#if defined(HAVE_CONST_SOCK_CLOEXEC) && defined(HAVE_ACCEPT4) + SOCKET sd = accept4 (GetSocket(), (struct sockaddr*)&pin, &addrlen, SOCK_CLOEXEC); + if (sd == INVALID_SOCKET) { + // We may be running in a kernel where + // SOCK_CLOEXEC is not supported - fall back: + sd = accept (GetSocket(), (struct sockaddr*)&pin, &addrlen); + } +#else + SOCKET sd = accept (GetSocket(), (struct sockaddr*)&pin, &addrlen); +#endif + if (sd == INVALID_SOCKET) { + // This breaks the loop when we've accepted everything on the kernel queue, + // up to 10 new connections. But what if the *first* accept fails? + // Does that mean anything serious is happening, beyond the situation + // described in the note above? + break; + } + + // Set the newly-accepted socket non-blocking and to close on exec. + // On Windows, this may fail because, weirdly, Windows inherits the non-blocking + // attribute that we applied to the acceptor socket into the accepted one. + if (!SetFdCloexec(sd) || !SetSocketNonblocking (sd)) { + //int val = fcntl (sd, F_GETFL, 0); + //if (fcntl (sd, F_SETFL, val | O_NONBLOCK) == -1) { + shutdown (sd, 1); + close (sd); + continue; + } + + // Disable slow-start (Nagle algorithm). Eventually make this configurable. + int one = 1; + setsockopt (sd, IPPROTO_TCP, TCP_NODELAY, (char*) &one, sizeof(one)); + + + ConnectionDescriptor *cd = new ConnectionDescriptor (sd, MyEventMachine); + if (!cd) + throw std::runtime_error ("no newly accepted connection"); + cd->SetServerMode(); + if (EventCallback) { + (*EventCallback) (GetBinding(), EM_CONNECTION_ACCEPTED, NULL, cd->GetBinding()); + } + #ifdef HAVE_EPOLL + cd->GetEpollEvent()->events = 0; + if (cd->SelectForRead()) + cd->GetEpollEvent()->events |= EPOLLIN; + if (cd->SelectForWrite()) + cd->GetEpollEvent()->events |= EPOLLOUT; + #endif + assert (MyEventMachine); + MyEventMachine->Add (cd); + #ifdef HAVE_KQUEUE + bKqueueArmWrite = cd->SelectForWrite(); + if (bKqueueArmWrite) + MyEventMachine->Modify (cd); + if (cd->SelectForRead()) + MyEventMachine->ArmKqueueReader (cd); + #endif + } + +} + + +/************************* +AcceptorDescriptor::Write +*************************/ + +void AcceptorDescriptor::Write() +{ + // Why are we here? + throw std::runtime_error ("bad code path in acceptor"); +} + + +/***************************** +AcceptorDescriptor::Heartbeat +*****************************/ + +void AcceptorDescriptor::Heartbeat() +{ + // No-op +} + + +/************************************** +DatagramDescriptor::DatagramDescriptor +**************************************/ + +DatagramDescriptor::DatagramDescriptor (SOCKET sd, EventMachine_t *parent_em): + EventableDescriptor (sd, parent_em), + OutboundDataSize (0) +{ + memset (&ReturnAddress, 0, sizeof(ReturnAddress)); + + /* Provisionally added 19Oct07. All datagram sockets support broadcasting. + * Until now, sending to a broadcast address would give EACCES (permission denied) + * on systems like Linux and BSD that require the SO_BROADCAST socket-option in order + * to accept a packet to a broadcast address. Solaris doesn't require it. I think + * Windows DOES require it but I'm not sure. + * + * Ruby does NOT do what we're doing here. In Ruby, you have to explicitly set SO_BROADCAST + * on a UDP socket in order to enable broadcasting. The reason for requiring the option + * in the first place is so that applications don't send broadcast datagrams by mistake. + * I imagine that could happen if a user of an application typed in an address that happened + * to be a broadcast address on that particular subnet. + * + * This is provisional because someone may eventually come up with a good reason not to + * do it for all UDP sockets. If that happens, then we'll need to add a usercode-level API + * to set the socket option, just like Ruby does. AND WE'LL ALSO BREAK CODE THAT DOESN'T + * EXPLICITLY SET THE OPTION. + */ + + int oval = 1; + setsockopt (GetSocket(), SOL_SOCKET, SO_BROADCAST, (char*)&oval, sizeof(oval)); + + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + #endif + #ifdef HAVE_KQUEUE + MyEventMachine->ArmKqueueReader (this); + #endif +} + + +/*************************************** +DatagramDescriptor::~DatagramDescriptor +***************************************/ + +DatagramDescriptor::~DatagramDescriptor() +{ + // Run down any stranded outbound data. + for (size_t i=0; i < OutboundPages.size(); i++) + OutboundPages[i].Free(); +} + + +/***************************** +DatagramDescriptor::Heartbeat +*****************************/ + +void DatagramDescriptor::Heartbeat() +{ + // Close it if its inactivity timer has expired. + + if (InactivityTimeout && ((MyEventMachine->GetCurrentLoopTime() - LastActivity) >= InactivityTimeout)) + ScheduleClose (false); + //bCloseNow = true; +} + + +/************************ +DatagramDescriptor::Read +************************/ + +void DatagramDescriptor::Read() +{ + SOCKET sd = GetSocket(); + assert (sd != INVALID_SOCKET); + LastActivity = MyEventMachine->GetCurrentLoopTime(); + + // This is an extremely large read buffer. + // In many cases you wouldn't expect to get any more than 4K. + char readbuffer [16 * 1024]; + + for (int i=0; i < 10; i++) { + // Don't read just one buffer and then move on. This is faster + // if there is a lot of incoming. + // But don't read indefinitely. Give other sockets a chance to run. + // NOTICE, we're reading one less than the buffer size. + // That's so we can put a guard byte at the end of what we send + // to user code. + + struct sockaddr_in6 sin; + socklen_t slen = sizeof (sin); + memset (&sin, 0, slen); + + int r = recvfrom (sd, readbuffer, sizeof(readbuffer) - 1, 0, (struct sockaddr*)&sin, &slen); + //cerr << ""; + + // In UDP, a zero-length packet is perfectly legal. + if (r >= 0) { + + // Add a null-terminator at the the end of the buffer + // that we will send to the callback. + // DO NOT EVER CHANGE THIS. We want to explicitly allow users + // to be able to depend on this behavior, so they will have + // the option to do some things faster. Additionally it's + // a security guard against buffer overflows. + readbuffer [r] = 0; + + + // Set up a "temporary" return address so that callers can "reply" to us + // from within the callback we are about to invoke. That means that ordinary + // calls to "send_data_to_connection" (which is of course misnamed in this + // case) will result in packets being sent back to the same place that sent + // us this one. + // There is a different call (evma_send_datagram) for cases where the caller + // actually wants to send a packet somewhere else. + + memset (&ReturnAddress, 0, sizeof(ReturnAddress)); + memcpy (&ReturnAddress, &sin, slen); + + _GenericInboundDispatch(readbuffer, r); + + } + else { + // Basically a would-block, meaning we've read everything there is to read. + break; + } + + } + + +} + + +/************************* +DatagramDescriptor::Write +*************************/ + +void DatagramDescriptor::Write() +{ + /* It's possible for a socket to select writable and then no longer + * be writable by the time we get around to writing. The kernel might + * have used up its available output buffers between the select call + * and when we get here. So this condition is not an error. + * This code is very reminiscent of ConnectionDescriptor::_WriteOutboundData, + * but differs in the that the outbound data pages (received from the + * user) are _message-structured._ That is, we send each of them out + * one message at a time. + * TODO, we are currently suppressing the EMSGSIZE error!!! + */ + + SOCKET sd = GetSocket(); + assert (sd != INVALID_SOCKET); + LastActivity = MyEventMachine->GetCurrentLoopTime(); + + assert (OutboundPages.size() > 0); + + // Send out up to 10 packets, then cycle the machine. + for (int i = 0; i < 10; i++) { + if (OutboundPages.size() <= 0) + break; + OutboundPage *op = &(OutboundPages[0]); + + // The nasty cast to (char*) is needed because Windows is brain-dead. + int s = sendto (sd, (char*)op->Buffer, op->Length, 0, (struct sockaddr*)&(op->From), + (op->From.sin6_family == AF_INET6 ? sizeof (struct sockaddr_in6) : sizeof (struct sockaddr_in))); +#ifdef OS_WIN32 + int e = WSAGetLastError(); +#else + int e = errno; +#endif + + OutboundDataSize -= op->Length; + op->Free(); + OutboundPages.pop_front(); + + if (s == SOCKET_ERROR) { + #ifdef OS_UNIX + if ((e != EINPROGRESS) && (e != EWOULDBLOCK) && (e != EINTR)) { + #endif + #ifdef OS_WIN32 + if ((e != WSAEINPROGRESS) && (e != WSAEWOULDBLOCK)) { + #endif + UnbindReasonCode = e; + Close(); + break; + } + } + } + + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + if (SelectForWrite()) + EpollEvent.events |= EPOLLOUT; + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif + #ifdef HAVE_KQUEUE + bKqueueArmWrite = SelectForWrite(); + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif +} + + +/********************************** +DatagramDescriptor::SelectForWrite +**********************************/ + +bool DatagramDescriptor::SelectForWrite() +{ + /* Changed 15Nov07, per bug report by Mark Zvillius. + * The outbound data size will be zero if there are zero-length outbound packets, + * so we now select writable in case the outbound page buffer is not empty. + * Note that the superclass ShouldDelete method still checks for outbound data size, + * which may be wrong. + */ + //return (GetOutboundDataSize() > 0); (Original) + return (OutboundPages.size() > 0); +} + + +/************************************ +DatagramDescriptor::SendOutboundData +************************************/ + +int DatagramDescriptor::SendOutboundData (const char *data, unsigned long length) +{ + // This is almost an exact clone of ConnectionDescriptor::_SendRawOutboundData. + // That means most of it could be factored to a common ancestor. Note that + // empty datagrams are meaningful, which isn't the case for TCP streams. + + if (IsCloseScheduled()) + return 0; + + if (!data && (length > 0)) + throw std::runtime_error ("bad outbound data"); + char *buffer = (char *) malloc (length + 1); + if (!buffer) + throw std::runtime_error ("no allocation for outbound data"); + memcpy (buffer, data, length); + buffer [length] = 0; + OutboundPages.push_back (OutboundPage (buffer, length, ReturnAddress)); + OutboundDataSize += length; + + #ifdef HAVE_EPOLL + EpollEvent.events = (EPOLLIN | EPOLLOUT); + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif + #ifdef HAVE_KQUEUE + bKqueueArmWrite = true; + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif + + return length; +} + + +/**************************************** +DatagramDescriptor::SendOutboundDatagram +****************************************/ + +int DatagramDescriptor::SendOutboundDatagram (const char *data, unsigned long length, const char *address, int port) +{ + // This is an exact clone of ConnectionDescriptor::SendOutboundData. + // That means it needs to move to a common ancestor. + // TODO: Refactor this so there's no overlap with SendOutboundData. + + if (IsCloseScheduled()) + //if (bCloseNow || bCloseAfterWriting) + return 0; + + if (!address || !*address || !port) + return 0; + + struct sockaddr_in6 addr_here; + size_t addr_here_len = sizeof addr_here; + if (0 != EventMachine_t::name2address (address, port, SOCK_DGRAM, (struct sockaddr *)&addr_here, &addr_here_len)) + return -1; + + if (!data && (length > 0)) + throw std::runtime_error ("bad outbound data"); + char *buffer = (char *) malloc (length + 1); + if (!buffer) + throw std::runtime_error ("no allocation for outbound data"); + memcpy (buffer, data, length); + buffer [length] = 0; + OutboundPages.push_back (OutboundPage (buffer, length, addr_here)); + OutboundDataSize += length; + + #ifdef HAVE_EPOLL + EpollEvent.events = (EPOLLIN | EPOLLOUT); + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif + #ifdef HAVE_KQUEUE + bKqueueArmWrite = true; + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif + + return length; +} + + +/********************************************** +ConnectionDescriptor::GetCommInactivityTimeout +**********************************************/ + +uint64_t ConnectionDescriptor::GetCommInactivityTimeout() +{ + return InactivityTimeout / 1000; +} + + +/********************************************** +ConnectionDescriptor::SetCommInactivityTimeout +**********************************************/ + +int ConnectionDescriptor::SetCommInactivityTimeout (uint64_t value) +{ + InactivityTimeout = value * 1000; + MyEventMachine->QueueHeartbeat(this); + return 1; +} + +/******************************* +DatagramDescriptor::GetPeername +*******************************/ + +bool DatagramDescriptor::GetPeername (struct sockaddr *s, socklen_t *len) +{ + bool ok = false; + if (s) { + *len = sizeof(ReturnAddress); + memset (s, 0, sizeof(ReturnAddress)); + memcpy (s, &ReturnAddress, sizeof(ReturnAddress)); + ok = true; + } + return ok; +} + + +/******************************************** +DatagramDescriptor::GetCommInactivityTimeout +********************************************/ + +uint64_t DatagramDescriptor::GetCommInactivityTimeout() +{ + return InactivityTimeout / 1000; +} + +/******************************************** +DatagramDescriptor::SetCommInactivityTimeout +********************************************/ + +int DatagramDescriptor::SetCommInactivityTimeout (uint64_t value) +{ + if (value > 0) { + InactivityTimeout = value * 1000; + MyEventMachine->QueueHeartbeat(this); + return 1; + } + return 0; +} + + +/************************************ +InotifyDescriptor::InotifyDescriptor +*************************************/ + +InotifyDescriptor::InotifyDescriptor (EventMachine_t *em): + EventableDescriptor(0, em) +{ + bCallbackUnbind = false; + + #ifndef HAVE_INOTIFY + throw std::runtime_error("no inotify support on this system"); + #else + + int fd = inotify_init(); + if (fd == -1) { + char buf[200]; + snprintf (buf, sizeof(buf)-1, "unable to create inotify descriptor: %s", strerror(errno)); + throw std::runtime_error (buf); + } + + MySocket = fd; + SetSocketNonblocking(MySocket); + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + #endif + + #endif +} + + +/************************************* +InotifyDescriptor::~InotifyDescriptor +**************************************/ + +InotifyDescriptor::~InotifyDescriptor() +{ + close(MySocket); + MySocket = INVALID_SOCKET; +} + +/*********************** +InotifyDescriptor::Read +************************/ + +void InotifyDescriptor::Read() +{ + assert (MyEventMachine); + MyEventMachine->_ReadInotifyEvents(); +} + + +/************************ +InotifyDescriptor::Write +*************************/ + +void InotifyDescriptor::Write() +{ + throw std::runtime_error("bad code path in inotify"); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ed.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ed.h new file mode 100644 index 0000000..4d7f7d4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ed.h @@ -0,0 +1,457 @@ +/***************************************************************************** + +$Id$ + +File: ed.h +Date: 06Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#ifndef __EventableDescriptor__H_ +#define __EventableDescriptor__H_ + + +class EventMachine_t; // forward reference +#ifdef WITH_SSL +class SslBox_t; // forward reference +#endif + +bool SetSocketNonblocking (SOCKET); +bool SetFdCloexec (int); + +/************************* +class EventableDescriptor +*************************/ + +class EventableDescriptor: public Bindable_t +{ + public: + EventableDescriptor (SOCKET, EventMachine_t*); + virtual ~EventableDescriptor() NO_EXCEPT_FALSE; + + SOCKET GetSocket() {return MySocket;} + void SetSocketInvalid() { MySocket = INVALID_SOCKET; } + void Close(); + + virtual void Read() = 0; + virtual void Write() = 0; + virtual void Heartbeat() = 0; + + // These methods tell us whether the descriptor + // should be selected or polled for read/write. + virtual bool SelectForRead() = 0; + virtual bool SelectForWrite() = 0; + + // are we scheduled for a close, or in an error state, or already closed? + bool ShouldDelete(); + // Do we have any data to write? This is used by ShouldDelete. + virtual int GetOutboundDataSize() {return 0;} + virtual bool IsWatchOnly(){ return bWatchOnly; } + + virtual void ScheduleClose (bool after_writing); + bool IsCloseScheduled(); + virtual void HandleError(){ ScheduleClose (false); } + + void SetEventCallback (EMCallback); + + virtual bool GetPeername (struct sockaddr*, socklen_t*) = 0; + virtual bool GetSockname (struct sockaddr*, socklen_t*) = 0; + virtual bool GetSubprocessPid (pid_t*) {return false;} + + virtual void StartTls() {} + virtual void SetTlsParms (const char *, const char *, bool, bool, const char *, const char *, const char *, const char *, int) {} + + #ifdef WITH_SSL + virtual X509 *GetPeerCert() {return NULL;} + virtual int GetCipherBits() {return -1;} + virtual const char *GetCipherName() {return NULL;} + virtual const char *GetCipherProtocol() {return NULL;} + virtual const char *GetSNIHostname() {return NULL;} + #endif + + virtual uint64_t GetCommInactivityTimeout() {return 0;} + virtual int SetCommInactivityTimeout (uint64_t) {return 0;} + uint64_t GetPendingConnectTimeout(); + int SetPendingConnectTimeout (uint64_t value); + uint64_t GetLastActivity() { return LastActivity; } + + #ifdef HAVE_EPOLL + struct epoll_event *GetEpollEvent() { return &EpollEvent; } + #endif + + #ifdef HAVE_KQUEUE + bool GetKqueueArmWrite() { return bKqueueArmWrite; } + #endif + + virtual void StartProxy(const uintptr_t, const unsigned long, const unsigned long); + virtual void StopProxy(); + virtual unsigned long GetProxiedBytes(){ return ProxiedBytes; }; + virtual void SetProxiedFrom(EventableDescriptor*, const unsigned long); + virtual int SendOutboundData(const char*,unsigned long){ return -1; } + virtual bool IsPaused(){ return bPaused; } + virtual bool Pause(){ bPaused = true; return bPaused; } + virtual bool Resume(){ bPaused = false; return bPaused; } + + void SetUnbindReasonCode(int code){ UnbindReasonCode = code; } + virtual int ReportErrorStatus(){ return 0; } + virtual bool IsConnectPending(){ return false; } + virtual uint64_t GetNextHeartbeat(); + + private: + bool bCloseNow; + bool bCloseAfterWriting; + + protected: + SOCKET MySocket; + bool bAttached; + bool bWatchOnly; + + EMCallback EventCallback; + void _GenericInboundDispatch (const char *buffer, unsigned long size); + bool _GenericGetPeername (struct sockaddr*, socklen_t*); + bool _GenericGetSockname (struct sockaddr*, socklen_t*); + + uint64_t CreatedAt; + bool bCallbackUnbind; + int UnbindReasonCode; + + unsigned long BytesToProxy; + EventableDescriptor *ProxyTarget; + EventableDescriptor *ProxiedFrom; + unsigned long ProxiedBytes; + + unsigned long MaxOutboundBufSize; + + #ifdef HAVE_EPOLL + struct epoll_event EpollEvent; + #endif + + #ifdef HAVE_KQUEUE + bool bKqueueArmWrite; + #endif + + EventMachine_t *MyEventMachine; + uint64_t PendingConnectTimeout; + uint64_t InactivityTimeout; + uint64_t LastActivity; + uint64_t NextHeartbeat; + bool bPaused; +}; + + + +/************************* +class LoopbreakDescriptor +*************************/ + +class LoopbreakDescriptor: public EventableDescriptor +{ + public: + LoopbreakDescriptor (SOCKET, EventMachine_t*); + virtual ~LoopbreakDescriptor() {} + + virtual void Read(); + virtual void Write(); + virtual void Heartbeat() {} + + virtual bool SelectForRead() {return true;} + virtual bool SelectForWrite() {return false;} + + virtual bool GetPeername (struct sockaddr* s, socklen_t* len) { return _GenericGetPeername (s, len); } + virtual bool GetSockname (struct sockaddr* s, socklen_t* len) { return _GenericGetSockname (s, len); } +}; + + +/************************** +class ConnectionDescriptor +**************************/ + +class ConnectionDescriptor: public EventableDescriptor +{ + public: + ConnectionDescriptor (SOCKET, EventMachine_t*); + virtual ~ConnectionDescriptor(); + + int SendOutboundData (const char*, unsigned long); + + void SetConnectPending (bool f); + virtual void ScheduleClose (bool after_writing); + virtual void HandleError(); + + void SetNotifyReadable (bool); + void SetNotifyWritable (bool); + void SetAttached (bool); + void SetWatchOnly (bool); + + bool Pause(); + bool Resume(); + + bool IsNotifyReadable(){ return bNotifyReadable; } + bool IsNotifyWritable(){ return bNotifyWritable; } + + virtual void Read(); + virtual void Write(); + virtual void Heartbeat(); + + virtual bool SelectForRead(); + virtual bool SelectForWrite(); + + // Do we have any data to write? This is used by ShouldDelete. + virtual int GetOutboundDataSize() {return OutboundDataSize;} + + virtual void StartTls(); + virtual void SetTlsParms (const char *, const char *, bool, bool, const char *, const char *, const char *, const char *, int); + + #ifdef WITH_SSL + virtual X509 *GetPeerCert(); + virtual int GetCipherBits(); + virtual const char *GetCipherName(); + virtual const char *GetCipherProtocol(); + virtual const char *GetSNIHostname(); + virtual bool VerifySslPeer(const char*); + virtual void AcceptSslPeer(); + #endif + + void SetServerMode() {bIsServer = true;} + + virtual bool GetPeername (struct sockaddr* s, socklen_t* len) { return _GenericGetPeername (s, len); } + virtual bool GetSockname (struct sockaddr* s, socklen_t* len) { return _GenericGetSockname (s, len); } + + virtual uint64_t GetCommInactivityTimeout(); + virtual int SetCommInactivityTimeout (uint64_t value); + + virtual int ReportErrorStatus(); + virtual bool IsConnectPending(){ return bConnectPending; } + + protected: + struct OutboundPage { + OutboundPage (const char *b, int l, int o=0): Buffer(b), Length(l), Offset(o) {} + void Free() {if (Buffer) free (const_cast(Buffer)); } + const char *Buffer; + int Length; + int Offset; + }; + + protected: + bool bConnectPending; + + bool bNotifyReadable; + bool bNotifyWritable; + + bool bReadAttemptedAfterClose; + bool bWriteAttemptedAfterClose; + + std::deque OutboundPages; + int OutboundDataSize; + + #ifdef WITH_SSL + SslBox_t *SslBox; + std::string CertChainFilename; + std::string PrivateKeyFilename; + std::string CipherList; + std::string EcdhCurve; + std::string DhParam; + int Protocols; + bool bHandshakeSignaled; + bool bSslVerifyPeer; + bool bSslFailIfNoPeerCert; + std::string SniHostName; + bool bSslPeerAccepted; + #endif + + #ifdef HAVE_KQUEUE + bool bGotExtraKqueueEvent; + #endif + + bool bIsServer; + + private: + void _UpdateEvents(); + void _UpdateEvents(bool, bool); + void _WriteOutboundData(); + void _DispatchInboundData (const char *buffer, unsigned long size); + void _DispatchCiphertext(); + int _SendRawOutboundData (const char *buffer, unsigned long size); + void _CheckHandshakeStatus(); + +}; + + +/************************ +class DatagramDescriptor +************************/ + +class DatagramDescriptor: public EventableDescriptor +{ + public: + DatagramDescriptor (SOCKET, EventMachine_t*); + virtual ~DatagramDescriptor(); + + virtual void Read(); + virtual void Write(); + virtual void Heartbeat(); + + virtual bool SelectForRead() {return true;} + virtual bool SelectForWrite(); + + int SendOutboundData (const char*, unsigned long); + int SendOutboundDatagram (const char*, unsigned long, const char*, int); + + // Do we have any data to write? This is used by ShouldDelete. + virtual int GetOutboundDataSize() {return OutboundDataSize;} + + virtual bool GetPeername (struct sockaddr* s, socklen_t* len); + virtual bool GetSockname (struct sockaddr* s, socklen_t* len) { return _GenericGetSockname (s, len); }; + + virtual uint64_t GetCommInactivityTimeout(); + virtual int SetCommInactivityTimeout (uint64_t value); + + protected: + struct OutboundPage { + OutboundPage (const char *b, int l, struct sockaddr_in6 f, int o=0): Buffer(b), Length(l), Offset(o), From(f) {} + void Free() {if (Buffer) free (const_cast(Buffer)); } + const char *Buffer; + int Length; + int Offset; + struct sockaddr_in6 From; + }; + + std::deque OutboundPages; + int OutboundDataSize; + + struct sockaddr_in6 ReturnAddress; +}; + + +/************************ +class AcceptorDescriptor +************************/ + +class AcceptorDescriptor: public EventableDescriptor +{ + public: + AcceptorDescriptor (SOCKET, EventMachine_t*); + virtual ~AcceptorDescriptor(); + + virtual void Read(); + virtual void Write(); + virtual void Heartbeat(); + + virtual bool SelectForRead() {return true;} + virtual bool SelectForWrite() {return false;} + + virtual bool GetPeername (struct sockaddr* s, socklen_t* len) { return _GenericGetPeername (s, len); } + virtual bool GetSockname (struct sockaddr* s, socklen_t* len) { return _GenericGetSockname (s, len); }; + + static void StopAcceptor (const uintptr_t binding); +}; + +/******************** +class PipeDescriptor +********************/ + +#ifdef OS_UNIX +class PipeDescriptor: public EventableDescriptor +{ + public: + PipeDescriptor (SOCKET, pid_t, EventMachine_t*); + virtual ~PipeDescriptor() NO_EXCEPT_FALSE; + + virtual void Read(); + virtual void Write(); + virtual void Heartbeat(); + + virtual bool SelectForRead(); + virtual bool SelectForWrite(); + + int SendOutboundData (const char*, unsigned long); + virtual int GetOutboundDataSize() {return OutboundDataSize;} + + virtual bool GetPeername (struct sockaddr* s, socklen_t* len) { return _GenericGetPeername (s, len); } + virtual bool GetSockname (struct sockaddr* s, socklen_t* len) { return _GenericGetSockname (s, len); } + + virtual bool GetSubprocessPid (pid_t*); + + protected: + struct OutboundPage { + OutboundPage (const char *b, int l, int o=0): Buffer(b), Length(l), Offset(o) {} + void Free() {if (Buffer) free (const_cast(Buffer)); } + const char *Buffer; + int Length; + int Offset; + }; + + protected: + bool bReadAttemptedAfterClose; + + std::deque OutboundPages; + int OutboundDataSize; + + pid_t SubprocessPid; + + private: + void _DispatchInboundData (const char *buffer, int size); +}; +#endif // OS_UNIX + + +/************************ +class KeyboardDescriptor +************************/ + +class KeyboardDescriptor: public EventableDescriptor +{ + public: + KeyboardDescriptor (EventMachine_t*); + virtual ~KeyboardDescriptor(); + + virtual void Read(); + virtual void Write(); + virtual void Heartbeat(); + + virtual bool SelectForRead() {return true;} + virtual bool SelectForWrite() {return false;} + + virtual bool GetPeername (struct sockaddr* s, socklen_t* len) { return _GenericGetPeername (s, len); } + virtual bool GetSockname (struct sockaddr* s, socklen_t* len) { return _GenericGetSockname (s, len); } + + protected: + bool bReadAttemptedAfterClose; + + private: + void _DispatchInboundData (const char *buffer, int size); +}; + + +/*********************** +class InotifyDescriptor +************************/ + +class InotifyDescriptor: public EventableDescriptor +{ + public: + InotifyDescriptor (EventMachine_t*); + virtual ~InotifyDescriptor(); + + void Read(); + void Write(); + + virtual void Heartbeat() {} + virtual bool SelectForRead() {return true;} + virtual bool SelectForWrite() {return false;} + + virtual bool GetPeername (struct sockaddr* s, socklen_t* len) { return false; } + virtual bool GetSockname (struct sockaddr* s, socklen_t* len) { return false; } +}; + +#endif // __EventableDescriptor__H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/em.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/em.cpp new file mode 100644 index 0000000..2907485 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/em.cpp @@ -0,0 +1,2396 @@ +/***************************************************************************** + +$Id$ + +File: em.cpp +Date: 06Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +// THIS ENTIRE FILE WILL EVENTUALLY BE FOR UNIX BUILDS ONLY. +//#ifdef OS_UNIX + +#include "project.h" + +/* The numer of max outstanding timers was once a const enum defined in em.h. + * Now we define it here so that users can change its value if necessary. + */ +static unsigned int MaxOutstandingTimers = 100000; + +/* The number of accept() done at once in a single tick when the acceptor + * socket becomes readable. + */ +static unsigned int SimultaneousAcceptCount = 10; + +/* Internal helper to create a socket with SOCK_CLOEXEC set, and fall + * back to fcntl'ing it if the headers/runtime don't support it. + */ +SOCKET EmSocket (int domain, int type, int protocol) +{ + SOCKET sd; +#ifdef HAVE_SOCKET_CLOEXEC + sd = socket (domain, type | SOCK_CLOEXEC, protocol); + if (sd == INVALID_SOCKET) { + sd = socket (domain, type, protocol); + if (sd < 0) { + return sd; + } + SetFdCloexec(sd); + } +#else + sd = socket (domain, type, protocol); + if (sd == INVALID_SOCKET) { + return sd; + } + SetFdCloexec(sd); +#endif + return sd; +} + + +/*************************************** +STATIC EventMachine_t::GetMaxTimerCount +***************************************/ + +int EventMachine_t::GetMaxTimerCount() +{ + return MaxOutstandingTimers; +} + + +/*************************************** +STATIC EventMachine_t::SetMaxTimerCount +***************************************/ + +void EventMachine_t::SetMaxTimerCount (int count) +{ + /* Allow a user to increase the maximum number of outstanding timers. + * If this gets "too high" (a metric that is of course platform dependent), + * bad things will happen like performance problems and possible overuse + * of memory. + * The actual timer mechanism is very efficient so it's hard to know what + * the practical max, but 100,000 shouldn't be too problematical. + */ + if (count < 100) + count = 100; + MaxOutstandingTimers = count; +} + +int EventMachine_t::GetSimultaneousAcceptCount() +{ + return SimultaneousAcceptCount; +} + +void EventMachine_t::SetSimultaneousAcceptCount (int count) +{ + if (count < 1) + count = 1; + SimultaneousAcceptCount = count; +} + + +/****************************** +EventMachine_t::EventMachine_t +******************************/ + +EventMachine_t::EventMachine_t (EMCallback event_callback, Poller_t poller): + NumCloseScheduled (0), + HeartbeatInterval(2000000), + EventCallback (event_callback), + LoopBreakerReader (INVALID_SOCKET), + LoopBreakerWriter (INVALID_SOCKET), + bTerminateSignalReceived (false), + Poller (poller), + epfd (-1), + kqfd (-1) + #ifdef HAVE_INOTIFY + , inotify (NULL) + #endif +{ + // Default time-slice is just smaller than one hundred mills. + Quantum.tv_sec = 0; + Quantum.tv_usec = 90000; + + // Override the requested poller back to default if needed. + #if !defined(HAVE_EPOLL) && !defined(HAVE_KQUEUE) + Poller = Poller_Default; + #endif + + /* Initialize monotonic timekeeping on OS X before the first call to GetRealTime */ + #ifdef OS_DARWIN + (void) mach_timebase_info(&mach_timebase); + #endif + + #ifdef OS_WIN32 + TickCountTickover = 0; + LastTickCount = 0; + #endif + + // Make sure the current loop time is sane, in case we do any initializations of + // objects before we start running. + _UpdateTime(); + + /* We initialize the network library here (only on Windows of course) + * and initialize "loop breakers." Our destructor also does some network-level + * cleanup. There's thus an implicit assumption that any given instance of EventMachine_t + * will only call ::Run once. Is that a good assumption? Should we move some of these + * inits and de-inits into ::Run? + */ + #ifdef OS_WIN32 + WSADATA w; + WSAStartup (MAKEWORD (1, 1), &w); + #endif + + _InitializeLoopBreaker(); + SelectData = new SelectData_t(); +} + + +/******************************* +EventMachine_t::~EventMachine_t +*******************************/ + +EventMachine_t::~EventMachine_t() +{ + // Run down descriptors + size_t i; + for (i = 0; i < NewDescriptors.size(); i++) + delete NewDescriptors[i]; + for (i = 0; i < Descriptors.size(); i++) + delete Descriptors[i]; + + close (LoopBreakerReader); + close (LoopBreakerWriter); + + // Remove any file watch descriptors + while(!Files.empty()) { + std::map::iterator f = Files.begin(); + UnwatchFile (f->first); + } + + if (epfd != -1) + close (epfd); + if (kqfd != -1) + close (kqfd); + + delete SelectData; +} + + +/**************************** +EventMachine_t::ScheduleHalt +****************************/ + +void EventMachine_t::ScheduleHalt() +{ + /* This is how we stop the machine. + * This can be called by clients. Signal handlers will probably + * set the global flag. + * For now this means there can only be one EventMachine ever running at a time. + * + * IMPORTANT: keep this light, fast, and async-safe. Don't do anything frisky in here, + * because it may be called from signal handlers invoked from code that we don't + * control. At this writing (20Sep06), EM does NOT install any signal handlers of + * its own. + * + * We need a FAQ. And one of the questions is: how do I stop EM when Ctrl-C happens? + * The answer is to call evma_stop_machine, which calls here, from a SIGINT handler. + */ + bTerminateSignalReceived = true; + + /* Signal the loopbreaker so we break out of long-running select/epoll/kqueue and + * notice the halt boolean is set. Signalling the loopbreaker also uses a single + * signal-safe syscall. + */ + SignalLoopBreaker(); +} + +bool EventMachine_t::Stopping() +{ + return bTerminateSignalReceived; +} + +/******************************* +EventMachine_t::SetTimerQuantum +*******************************/ + +void EventMachine_t::SetTimerQuantum (int interval) +{ + /* We get a timer-quantum expressed in milliseconds. + */ + + if ((interval < 5) || (interval > 5*60*1000)) + throw std::runtime_error ("invalid timer-quantum"); + + Quantum.tv_sec = interval / 1000; + Quantum.tv_usec = (interval % 1000) * 1000; +} + + +/************************************* +(STATIC) EventMachine_t::SetuidString +*************************************/ + +#ifdef OS_UNIX +void EventMachine_t::SetuidString (const char *username) +{ + /* This method takes a caller-supplied username and tries to setuid + * to that user. There is no meaningful implementation (and no error) + * on Windows. On Unix, a failure to setuid the caller-supplied string + * causes a fatal abort, because presumably the program is calling here + * in order to fulfill a security requirement. If we fail silently, + * the user may continue to run with too much privilege. + * + * TODO, we need to decide on and document a way of generating C++ level errors + * that can be wrapped in documented Ruby exceptions, so users can catch + * and handle them. And distinguish it from errors that we WON'T let the Ruby + * user catch (like security-violations and resource-overallocation). + * A setuid failure here would be in the latter category. + */ + + if (!username || !*username) + throw std::runtime_error ("setuid_string failed: no username specified"); + + errno = 0; + struct passwd *p = getpwnam (username); + if (!p) { + if (errno) { + char buf[200]; + snprintf (buf, sizeof(buf)-1, "setuid_string failed: %s", strerror(errno)); + throw std::runtime_error (buf); + } else { + throw std::runtime_error ("setuid_string failed: unknown username"); + } + } + + if (setuid (p->pw_uid) != 0) + throw std::runtime_error ("setuid_string failed: no setuid"); + + // Success. +} +#else +void EventMachine_t::SetuidString (const char *username UNUSED) { } +#endif + +/**************************************** +(STATIC) EventMachine_t::SetRlimitNofile +****************************************/ + +#ifdef OS_UNIX +int EventMachine_t::SetRlimitNofile (int nofiles) +{ + struct rlimit rlim; + getrlimit (RLIMIT_NOFILE, &rlim); + if (nofiles >= 0) { + rlim.rlim_cur = nofiles; + if ((unsigned int)nofiles > rlim.rlim_max) + rlim.rlim_max = nofiles; + setrlimit (RLIMIT_NOFILE, &rlim); + // ignore the error return, for now at least. + // TODO, emit an error message someday when we have proper debug levels. + } + getrlimit (RLIMIT_NOFILE, &rlim); + return rlim.rlim_cur; +} +#else +int EventMachine_t::SetRlimitNofile (int nofiles UNUSED) { return 0; } +#endif + +/********************************* +EventMachine_t::SignalLoopBreaker +*********************************/ + +void EventMachine_t::SignalLoopBreaker() +{ + #ifdef OS_UNIX + (void)write (LoopBreakerWriter, "", 1); + #endif + #ifdef OS_WIN32 + sendto (LoopBreakerReader, "", 0, 0, (struct sockaddr*)&(LoopBreakerTarget), sizeof(LoopBreakerTarget)); + #endif +} + + +/************************************** +EventMachine_t::_InitializeLoopBreaker +**************************************/ + +void EventMachine_t::_InitializeLoopBreaker() +{ + /* A "loop-breaker" is a socket-descriptor that we can write to in order + * to break the main select loop. Primarily useful for things running on + * threads other than the main EM thread, so they can trigger processing + * of events that arise exogenously to the EM. + * Keep the loop-breaker pipe out of the main descriptor set, otherwise + * its events will get passed on to user code. + */ + + #ifdef OS_UNIX + int fd[2]; +#if defined (HAVE_CLOEXEC) && defined (HAVE_PIPE2) + int pipestatus = pipe2(fd, O_CLOEXEC); + if (pipestatus < 0) { + if (pipe(fd)) + throw std::runtime_error (strerror(errno)); + } +#else + if (pipe (fd)) + throw std::runtime_error (strerror(errno)); +#endif + if (!SetFdCloexec(fd[0]) || !SetFdCloexec(fd[1])) + throw std::runtime_error (strerror(errno)); + + LoopBreakerWriter = fd[1]; + LoopBreakerReader = fd[0]; + + /* 16Jan11: Make sure the pipe is non-blocking, so more than 65k loopbreaks + * in one tick do not fill up the pipe and block the process on write() */ + SetSocketNonblocking (LoopBreakerWriter); + #endif + + #ifdef OS_WIN32 + SOCKET sd = EmSocket (AF_INET, SOCK_DGRAM, 0); + if (sd == INVALID_SOCKET) + throw std::runtime_error ("no loop breaker socket"); + SetSocketNonblocking (sd); + + memset (&LoopBreakerTarget, 0, sizeof(LoopBreakerTarget)); + LoopBreakerTarget.sin_family = AF_INET; + LoopBreakerTarget.sin_addr.s_addr = inet_addr ("127.0.0.1"); + + srand ((int)time(NULL)); + int i; + for (i=0; i < 100; i++) { + int r = (rand() % 10000) + 20000; + LoopBreakerTarget.sin_port = htons (r); + if (bind (sd, (struct sockaddr*)&LoopBreakerTarget, sizeof(LoopBreakerTarget)) == 0) + break; + } + + if (i == 100) + throw std::runtime_error ("no loop breaker"); + LoopBreakerReader = sd; + #endif + + #ifdef HAVE_EPOLL + if (Poller == Poller_Epoll) { + epfd = epoll_create (MaxEpollDescriptors); + if (epfd == -1) { + char buf[200]; + snprintf (buf, sizeof(buf)-1, "unable to create epoll descriptor: %s", strerror(errno)); + throw std::runtime_error (buf); + } + int cloexec = fcntl (epfd, F_GETFD, 0); + assert (cloexec >= 0); + cloexec |= FD_CLOEXEC; + fcntl (epfd, F_SETFD, cloexec); + + assert (LoopBreakerReader >= 0); + LoopbreakDescriptor *ld = new LoopbreakDescriptor (LoopBreakerReader, this); + assert (ld); + Add (ld); + } + #endif + + #ifdef HAVE_KQUEUE + if (Poller == Poller_Kqueue) { + kqfd = kqueue(); + if (kqfd == -1) { + char buf[200]; + snprintf (buf, sizeof(buf)-1, "unable to create kqueue descriptor: %s", strerror(errno)); + throw std::runtime_error (buf); + } + // cloexec not needed. By definition, kqueues are not carried across forks. + + assert (LoopBreakerReader >= 0); + LoopbreakDescriptor *ld = new LoopbreakDescriptor (LoopBreakerReader, this); + assert (ld); + Add (ld); + } + #endif +} + +/*************************** +EventMachine_t::_UpdateTime +***************************/ + +void EventMachine_t::_UpdateTime() +{ + MyCurrentLoopTime = GetRealTime(); +} + +/*************************** +EventMachine_t::GetRealTime +***************************/ + +// Two great writeups of cross-platform monotonic time are at: +// http://www.python.org/dev/peps/pep-0418 +// http://nadeausoftware.com/articles/2012/04/c_c_tip_how_measure_elapsed_real_time_benchmarking +// Uncomment the #pragma messages to confirm which compile-time option was used +uint64_t EventMachine_t::GetRealTime() +{ + uint64_t current_time; + + #if defined(HAVE_CONST_CLOCK_MONOTONIC_RAW) + // #pragma message "GetRealTime: clock_gettime CLOCK_MONOTONIC_RAW" + // Linux 2.6.28 and above + struct timespec tv; + clock_gettime (CLOCK_MONOTONIC_RAW, &tv); + current_time = (((uint64_t)(tv.tv_sec)) * 1000000LL) + ((uint64_t)((tv.tv_nsec)/1000)); + + #elif defined(HAVE_CONST_CLOCK_MONOTONIC) + // #pragma message "GetRealTime: clock_gettime CLOCK_MONOTONIC" + // Linux, FreeBSD 5.0 and above, Solaris 8 and above, OpenBSD, NetBSD, DragonflyBSD + struct timespec tv; + clock_gettime (CLOCK_MONOTONIC, &tv); + current_time = (((uint64_t)(tv.tv_sec)) * 1000000LL) + ((uint64_t)((tv.tv_nsec)/1000)); + + #elif defined(HAVE_GETHRTIME) + // #pragma message "GetRealTime: gethrtime" + // Solaris and HP-UX + current_time = (uint64_t)gethrtime() / 1000; + + #elif defined(OS_DARWIN) + // #pragma message "GetRealTime: mach_absolute_time" + // Mac OS X + // https://developer.apple.com/library/mac/qa/qa1398/_index.html + current_time = mach_absolute_time() * mach_timebase.numer / mach_timebase.denom / 1000; + + #elif defined(OS_UNIX) + // #pragma message "GetRealTime: gettimeofday" + // Unix fallback + struct timeval tv; + gettimeofday (&tv, NULL); + current_time = (((uint64_t)(tv.tv_sec)) * 1000000LL) + ((uint64_t)(tv.tv_usec)); + + #elif defined(OS_WIN32) + // #pragma message "GetRealTime: GetTickCount" + // Future improvement: use GetTickCount64 in Windows Vista / Server 2008 + unsigned tick = GetTickCount(); + if (tick < LastTickCount) + TickCountTickover += 1; + LastTickCount = tick; + current_time = ((uint64_t)TickCountTickover << 32) + (uint64_t)tick; + current_time *= 1000; // convert to microseconds + + #else + // #pragma message "GetRealTime: time" + // Universal fallback + current_time = (uint64_t)time(NULL) * 1000000LL; + #endif + + return current_time; +} + +/*********************************** +EventMachine_t::_DispatchHeartbeats +***********************************/ + +void EventMachine_t::_DispatchHeartbeats() +{ + // Store the first processed heartbeat descriptor and bail out if + // we see it again. This fixes an infinite loop in case the system time + // is changed out from underneath MyCurrentLoopTime. + const EventableDescriptor *head = NULL; + + while (true) { + std::multimap::iterator i = Heartbeats.begin(); + if (i == Heartbeats.end()) + break; + if (i->first > MyCurrentLoopTime) + break; + + EventableDescriptor *ed = i->second; + if (ed == head) + break; + + ed->Heartbeat(); + QueueHeartbeat(ed); + + if (head == NULL) + head = ed; + } +} + +/****************************** +EventMachine_t::QueueHeartbeat +******************************/ + +void EventMachine_t::QueueHeartbeat(EventableDescriptor *ed) +{ + uint64_t heartbeat = ed->GetNextHeartbeat(); + + if (heartbeat) { + #ifndef HAVE_MAKE_PAIR + Heartbeats.insert (std::multimap::value_type (heartbeat, ed)); + #else + Heartbeats.insert (std::make_pair (heartbeat, ed)); + #endif + } +} + +/****************************** +EventMachine_t::ClearHeartbeat +******************************/ + +void EventMachine_t::ClearHeartbeat(uint64_t key, EventableDescriptor* ed) +{ + std::multimap::iterator it; + std::pair::iterator,std::multimap::iterator> ret; + ret = Heartbeats.equal_range (key); + for (it = ret.first; it != ret.second; ++it) { + if (it->second == ed) { + Heartbeats.erase (it); + break; + } + } +} + +/******************* +EventMachine_t::Run +*******************/ + +void EventMachine_t::Run() +{ + while (RunOnce()) ; +} + +/*********************** +EventMachine_t::RunOnce +***********************/ + +bool EventMachine_t::RunOnce() +{ + _UpdateTime(); + _RunTimers(); + + /* _Add must precede _Modify because the same descriptor might + * be on both lists during the same pass through the machine, + * and to modify a descriptor before adding it would fail. + */ + _AddNewDescriptors(); + _ModifyDescriptors(); + + switch (Poller) { + case Poller_Epoll: + _RunEpollOnce(); + break; + case Poller_Kqueue: + _RunKqueueOnce(); + break; + case Poller_Default: + _RunSelectOnce(); + break; + } + + _DispatchHeartbeats(); + _CleanupSockets(); + + if (bTerminateSignalReceived) + return false; + + return true; +} + + +/***************************** +EventMachine_t::_RunEpollOnce +*****************************/ + +void EventMachine_t::_RunEpollOnce() +{ + #ifdef HAVE_EPOLL + assert (epfd != -1); + int s; + + timeval tv = _TimeTilNextEvent(); + + #ifdef BUILD_FOR_RUBY + int ret = 0; + + #ifdef HAVE_RB_WAIT_FOR_SINGLE_FD + if ((ret = rb_wait_for_single_fd(epfd, RB_WAITFD_IN|RB_WAITFD_PRI, &tv)) < 1) { + #else + fd_set fdreads; + + FD_ZERO(&fdreads); + FD_SET(epfd, &fdreads); + + if ((ret = rb_thread_select(epfd + 1, &fdreads, NULL, NULL, &tv)) < 1) { + #endif + if (ret == -1) { + assert(errno != EINVAL); + assert(errno != EBADF); + } + return; + } + + TRAP_BEG; + s = epoll_wait (epfd, epoll_events, MaxEvents, 0); + TRAP_END; + #else + int duration = 0; + duration = duration + (tv.tv_sec * 1000); + duration = duration + (tv.tv_usec / 1000); + s = epoll_wait (epfd, epoll_events, MaxEvents, duration); + #endif + + if (s > 0) { + for (int i=0; i < s; i++) { + EventableDescriptor *ed = (EventableDescriptor*) epoll_events[i].data.ptr; + + if (ed->IsWatchOnly() && ed->GetSocket() == INVALID_SOCKET) + continue; + + assert(ed->GetSocket() != INVALID_SOCKET); + + if (epoll_events[i].events & EPOLLIN) + ed->Read(); + if (epoll_events[i].events & EPOLLOUT) + ed->Write(); + if (epoll_events[i].events & (EPOLLERR | EPOLLHUP)) + ed->HandleError(); + } + } + else if (s < 0) { + // epoll_wait can fail on error in a handful of ways. + // If this happens, then wait for a little while to avoid busy-looping. + // If the error was EINTR, we probably caught SIGCHLD or something, + // so keep the wait short. + timeval tv = {0, ((errno == EINTR) ? 5 : 50) * 1000}; + EmSelect (0, NULL, NULL, NULL, &tv); + } + #else + throw std::runtime_error ("epoll is not implemented on this platform"); + #endif +} + + +/****************************** +EventMachine_t::_RunKqueueOnce +******************************/ + +#ifdef HAVE_KQUEUE +void EventMachine_t::_RunKqueueOnce() +{ + assert (kqfd != -1); + int k; + + timeval tv = _TimeTilNextEvent(); + + struct timespec ts; + ts.tv_sec = tv.tv_sec; + ts.tv_nsec = tv.tv_usec * 1000; + + #ifdef BUILD_FOR_RUBY + int ret = 0; + + #ifdef HAVE_RB_WAIT_FOR_SINGLE_FD + if ((ret = rb_wait_for_single_fd(kqfd, RB_WAITFD_IN|RB_WAITFD_PRI, &tv)) < 1) { + #else + fd_set fdreads; + + FD_ZERO(&fdreads); + FD_SET(kqfd, &fdreads); + + if ((ret = rb_thread_select(kqfd + 1, &fdreads, NULL, NULL, &tv)) < 1) { + #endif + if (ret == -1) { + assert(errno != EINVAL); + assert(errno != EBADF); + } + return; + } + + TRAP_BEG; + ts.tv_sec = ts.tv_nsec = 0; + k = kevent (kqfd, NULL, 0, Karray, MaxEvents, &ts); + TRAP_END; + #else + k = kevent (kqfd, NULL, 0, Karray, MaxEvents, &ts); + #endif + + struct kevent *ke = Karray; + while (k > 0) { + switch (ke->filter) + { + case EVFILT_VNODE: + _HandleKqueueFileEvent (ke); + break; + + case EVFILT_PROC: + _HandleKqueuePidEvent (ke); + break; + + case EVFILT_READ: + case EVFILT_WRITE: + EventableDescriptor *ed = (EventableDescriptor*) (ke->udata); + assert (ed); + + if (ed->IsWatchOnly() && ed->GetSocket() == INVALID_SOCKET) + break; + + if (ke->filter == EVFILT_READ) + ed->Read(); + else if (ke->filter == EVFILT_WRITE) + ed->Write(); + else + std::cerr << "Discarding unknown kqueue event " << ke->filter << std::endl; + + break; + } + + --k; + ++ke; + } + + // TODO, replace this with rb_thread_blocking_region for 1.9 builds. + #ifdef BUILD_FOR_RUBY + if (!rb_thread_alone()) { + rb_thread_schedule(); + } + #endif +} +#else +void EventMachine_t::_RunKqueueOnce() +{ + throw std::runtime_error ("kqueue is not implemented on this platform"); +} +#endif + + +/********************************* +EventMachine_t::_TimeTilNextEvent +*********************************/ + +timeval EventMachine_t::_TimeTilNextEvent() +{ + // 29jul11: Changed calculation base from MyCurrentLoopTime to the + // real time. As MyCurrentLoopTime is set at the beginning of an + // iteration and this calculation is done at the end, evenmachine + // will potentially oversleep by the amount of time the iteration + // took to execute. + uint64_t next_event = 0; + uint64_t current_time = GetRealTime(); + + if (!Heartbeats.empty()) { + std::multimap::iterator heartbeats = Heartbeats.begin(); + next_event = heartbeats->first; + } + + if (!Timers.empty()) { + std::multimap::iterator timers = Timers.begin(); + if (next_event == 0 || timers->first < next_event) + next_event = timers->first; + } + + if (!NewDescriptors.empty() || !ModifiedDescriptors.empty()) { + next_event = current_time; + } + + timeval tv; + + if (NumCloseScheduled > 0 || bTerminateSignalReceived) { + tv.tv_sec = tv.tv_usec = 0; + } else if (next_event == 0) { + tv = Quantum; + } else { + if (next_event > current_time) { + uint64_t duration = next_event - current_time; + tv.tv_sec = duration / 1000000; + tv.tv_usec = duration % 1000000; + } else { + tv.tv_sec = tv.tv_usec = 0; + } + } + + return tv; +} + +/******************************* +EventMachine_t::_CleanupSockets +*******************************/ + +void EventMachine_t::_CleanupSockets() +{ + // TODO, rip this out and only delete the descriptors we know have died, + // rather than traversing the whole list. + // Modified 05Jan08 per suggestions by Chris Heath. It's possible that + // an EventableDescriptor will have a descriptor value of -1. That will + // happen if EventableDescriptor::Close was called on it. In that case, + // don't call epoll_ctl to remove the socket's filters from the epoll set. + // According to the epoll docs, this happens automatically when the + // descriptor is closed anyway. This is different from the case where + // the socket has already been closed but the descriptor in the ED object + // hasn't yet been set to INVALID_SOCKET. + // In kqueue, closing a descriptor automatically removes its event filters. + int i, j; + int nSockets = Descriptors.size(); + for (i=0, j=0; i < nSockets; i++) { + EventableDescriptor *ed = Descriptors[i]; + assert (ed); + if (ed->ShouldDelete()) { + #ifdef HAVE_EPOLL + if (Poller == Poller_Epoll) { + assert (epfd != -1); + if (ed->GetSocket() != INVALID_SOCKET) { + int e = epoll_ctl (epfd, EPOLL_CTL_DEL, ed->GetSocket(), ed->GetEpollEvent()); + // ENOENT or EBADF are not errors because the socket may be already closed when we get here. + if (e && (errno != ENOENT) && (errno != EBADF) && (errno != EPERM)) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to delete epoll event: %s", strerror(errno)); + throw std::runtime_error (buf); + } + } + ModifiedDescriptors.erase(ed); + } + #endif + delete ed; + } + else + Descriptors [j++] = ed; + } + while ((size_t)j < Descriptors.size()) + Descriptors.pop_back(); +} + +/********************************* +EventMachine_t::_ModifyEpollEvent +*********************************/ + +#ifdef HAVE_EPOLL +void EventMachine_t::_ModifyEpollEvent (EventableDescriptor *ed) +{ + if (Poller == Poller_Epoll) { + assert (epfd != -1); + assert (ed); + assert (ed->GetSocket() != INVALID_SOCKET); + int e = epoll_ctl (epfd, EPOLL_CTL_MOD, ed->GetSocket(), ed->GetEpollEvent()); + if (e) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to modify epoll event: %s", strerror(errno)); + throw std::runtime_error (buf); + } + } +} +#else +void EventMachine_t::_ModifyEpollEvent (EventableDescriptor *ed UNUSED) { } +#endif + + +/************************** +SelectData_t::SelectData_t +**************************/ + +SelectData_t::SelectData_t() +{ + maxsocket = 0; + rb_fd_init (&fdreads); + rb_fd_init (&fdwrites); + rb_fd_init (&fderrors); +} + +SelectData_t::~SelectData_t() +{ + rb_fd_term (&fdreads); + rb_fd_term (&fdwrites); + rb_fd_term (&fderrors); +} + +#ifdef BUILD_FOR_RUBY +/***************** +_SelectDataSelect +*****************/ + +#if defined(HAVE_RB_THREAD_BLOCKING_REGION) || defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) +static VALUE _SelectDataSelect (void *v) +{ + SelectData_t *sd = (SelectData_t*)v; + sd->nSockets = rb_fd_select (sd->maxsocket+1, &(sd->fdreads), &(sd->fdwrites), &(sd->fderrors), &(sd->tv)); + return Qnil; +} +#endif + +/********************* +SelectData_t::_Select +*********************/ + +int SelectData_t::_Select() +{ + #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) + // added in ruby 1.9.3 + rb_thread_call_without_gvl ((void *(*)(void *))_SelectDataSelect, (void*)this, RUBY_UBF_IO, 0); + return nSockets; + #elif defined(HAVE_TBR) + // added in ruby 1.9.1, deprecated in ruby 2.0.0 + rb_thread_blocking_region (_SelectDataSelect, (void*)this, RUBY_UBF_IO, 0); + return nSockets; + #else + return EmSelect (maxsocket+1, &fdreads, &fdwrites, &fderrors, &tv); + #endif +} +#endif + +void SelectData_t::_Clear() +{ + maxsocket = 0; + rb_fd_zero (&fdreads); + rb_fd_zero (&fdwrites); + rb_fd_zero (&fderrors); +} + +/****************************** +EventMachine_t::_RunSelectOnce +******************************/ + +void EventMachine_t::_RunSelectOnce() +{ + // Crank the event machine once. + // If there are no descriptors to process, then sleep + // for a few hundred mills to avoid busy-looping. + // This is based on a select loop. Alternately provide epoll + // if we know we're running on a 2.6 kernel. + // epoll will be effective if we provide it as an alternative, + // however it has the same problem interoperating with Ruby + // threads that select does. + + // Get ready for select() + SelectData->_Clear(); + + // Always read the loop-breaker reader. + // Changed 23Aug06, provisionally implemented for Windows with a UDP socket + // running on localhost with a randomly-chosen port. (*Puke*) + // Windows has a version of the Unix pipe() library function, but it doesn't + // give you back descriptors that are selectable. + rb_fd_set (LoopBreakerReader, &(SelectData->fdreads)); + if (SelectData->maxsocket < LoopBreakerReader) + SelectData->maxsocket = LoopBreakerReader; + + // prepare the sockets for reading and writing + size_t i; + for (i = 0; i < Descriptors.size(); i++) { + EventableDescriptor *ed = Descriptors[i]; + assert (ed); + SOCKET sd = ed->GetSocket(); + if (ed->IsWatchOnly() && sd == INVALID_SOCKET) + continue; + assert (sd != INVALID_SOCKET); + + if (ed->SelectForRead()) + rb_fd_set (sd, &(SelectData->fdreads)); + if (ed->SelectForWrite()) + rb_fd_set (sd, &(SelectData->fdwrites)); + + #ifdef OS_WIN32 + /* 21Sep09: on windows, a non-blocking connect() that fails does not come up as writable. + Instead, it is added to the error set. See http://www.mail-archive.com/openssl-users@openssl.org/msg58500.html + */ + if (ed->IsConnectPending()) + rb_fd_set (sd, &(SelectData->fderrors)); + #endif + + if (SelectData->maxsocket < sd) + SelectData->maxsocket = sd; + } + + + { // read and write the sockets + //timeval tv = {1, 0}; // Solaris fails if the microseconds member is >= 1000000. + //timeval tv = Quantum; + SelectData->tv = _TimeTilNextEvent(); + int s = SelectData->_Select(); + //rb_thread_blocking_region(xxx,(void*)&SelectData,RUBY_UBF_IO,0); + //int s = EmSelect (SelectData.maxsocket+1, &(SelectData.fdreads), &(SelectData.fdwrites), NULL, &(SelectData.tv)); + //int s = SelectData.nSockets; + if (s > 0) { + /* Changed 01Jun07. We used to handle the Loop-breaker right here. + * Now we do it AFTER all the regular descriptors. There's an + * incredibly important and subtle reason for this. Code on + * loop breakers is sometimes used to cause the reactor core to + * cycle (for example, to allow outbound network buffers to drain). + * If a loop-breaker handler reschedules itself (say, after determining + * that the write buffers are still too full), then it will execute + * IMMEDIATELY if _ReadLoopBreaker is done here instead of after + * the other descriptors are processed. That defeats the whole purpose. + */ + for (i=0; i < Descriptors.size(); i++) { + EventableDescriptor *ed = Descriptors[i]; + assert (ed); + SOCKET sd = ed->GetSocket(); + if (ed->IsWatchOnly() && sd == INVALID_SOCKET) + continue; + assert (sd != INVALID_SOCKET); + + if (rb_fd_isset (sd, &(SelectData->fdwrites))) { + // Double-check SelectForWrite() still returns true. If not, one of the callbacks must have + // modified some value since we checked SelectForWrite() earlier in this method. + if (ed->SelectForWrite()) + ed->Write(); + } + if (rb_fd_isset (sd, &(SelectData->fdreads))) + ed->Read(); + if (rb_fd_isset (sd, &(SelectData->fderrors))) + ed->HandleError(); + } + + if (rb_fd_isset (LoopBreakerReader, &(SelectData->fdreads))) + _ReadLoopBreaker(); + } + else if (s < 0) { + switch (errno) { + case EBADF: + _CleanBadDescriptors(); + break; + case EINVAL: + throw std::runtime_error ("Somehow EM passed an invalid nfds or invalid timeout to select(2), please report this!"); + break; + default: + // select can fail on error in a handful of ways. + // If this happens, then wait for a little while to avoid busy-looping. + // If the error was EINTR, we probably caught SIGCHLD or something, + // so keep the wait short. + timeval tv = {0, ((errno == EINTR) ? 5 : 50) * 1000}; + EmSelect (0, NULL, NULL, NULL, &tv); + } + } + } +} + +void EventMachine_t::_CleanBadDescriptors() +{ + size_t i; + + for (i = 0; i < Descriptors.size(); i++) { + EventableDescriptor *ed = Descriptors[i]; + if (ed->ShouldDelete()) + continue; + + SOCKET sd = ed->GetSocket(); + + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + + rb_fdset_t fds; + rb_fd_init(&fds); + rb_fd_set(sd, &fds); + + int ret = rb_fd_select(sd + 1, &fds, NULL, NULL, &tv); + rb_fd_term(&fds); + + if (ret == -1) { + if (errno == EBADF) + ed->ScheduleClose(false); + } + } +} + +/******************************** +EventMachine_t::_ReadLoopBreaker +********************************/ + +void EventMachine_t::_ReadLoopBreaker() +{ + /* The loop breaker has selected readable. + * Read it ONCE (it may block if we try to read it twice) + * and send a loop-break event back to user code. + */ + char buffer [1024]; + (void)read (LoopBreakerReader, buffer, sizeof(buffer)); + if (EventCallback) + (*EventCallback)(0, EM_LOOPBREAK_SIGNAL, "", 0); +} + + +/************************** +EventMachine_t::_RunTimers +**************************/ + +void EventMachine_t::_RunTimers() +{ + // These are caller-defined timer handlers. + // We rely on the fact that multimaps sort by their keys to avoid + // inspecting the whole list every time we come here. + // Just keep inspecting and processing the list head until we hit + // one that hasn't expired yet. + + while (true) { + std::multimap::iterator i = Timers.begin(); + if (i == Timers.end()) + break; + if (i->first > MyCurrentLoopTime) + break; + if (EventCallback) + (*EventCallback) (0, EM_TIMER_FIRED, NULL, i->second.GetBinding()); + Timers.erase (i); + } +} + + + +/*********************************** +EventMachine_t::InstallOneshotTimer +***********************************/ + +const uintptr_t EventMachine_t::InstallOneshotTimer (uint64_t milliseconds) +{ + if (Timers.size() > MaxOutstandingTimers) + return false; + + uint64_t fire_at = GetRealTime(); + fire_at += ((uint64_t)milliseconds) * 1000LL; + + Timer_t t; + #ifndef HAVE_MAKE_PAIR + std::multimap::iterator i = Timers.insert (std::multimap::value_type (fire_at, t)); + #else + std::multimap::iterator i = Timers.insert (std::make_pair (fire_at, t)); + #endif + return i->second.GetBinding(); +} + + +/******************************* +EventMachine_t::ConnectToServer +*******************************/ + +const uintptr_t EventMachine_t::ConnectToServer (const char *bind_addr, int bind_port, const char *server, int port) +{ + /* We want to spend no more than a few seconds waiting for a connection + * to a remote host. So we use a nonblocking connect. + * Linux disobeys the usual rules for nonblocking connects. + * Per Stevens (UNP p.410), you expect a nonblocking connect to select + * both readable and writable on error, and not to return EINPROGRESS + * if the connect can be fulfilled immediately. Linux violates both + * of these expectations. + * Any kind of nonblocking connect on Linux returns EINPROGRESS. + * The socket will then return writable when the disposition of the + * connect is known, but it will not also be readable in case of + * error! Weirdly, it will be readable in case there is data to read!!! + * (Which can happen with protocols like SSH and SMTP.) + * I suppose if you were so inclined you could consider this logical, + * but it's not the way Unix has historically done it. + * So we ignore the readable flag and read getsockopt to see if there + * was an error connecting. A select timeout works as expected. + * In regard to getsockopt: Linux does the Berkeley-style thing, + * not the Solaris-style, and returns zero with the error code in + * the error parameter. + * Return the binding-text of the newly-created pending connection, + * or NULL if there was a problem. + */ + + if (!server || !*server || !port) + throw std::runtime_error ("invalid server or port"); + + struct sockaddr_storage bind_as; + size_t bind_as_len = sizeof bind_as; + int gai = name2address (server, port, SOCK_STREAM, (struct sockaddr *)&bind_as, &bind_as_len); + if (gai != 0) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to resolve address: %s", gai_strerror(gai)); + throw std::runtime_error (buf); + } + + SOCKET sd = EmSocket (bind_as.ss_family, SOCK_STREAM, 0); + if (sd == INVALID_SOCKET) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to create new socket: %s", strerror(errno)); + throw std::runtime_error (buf); + } + + // From here on, ALL error returns must close the socket. + // Set the new socket nonblocking. + if (!SetSocketNonblocking (sd)) { + close (sd); + throw std::runtime_error ("unable to set socket as non-blocking"); + } + // Disable slow-start (Nagle algorithm). + int one = 1; + setsockopt (sd, IPPROTO_TCP, TCP_NODELAY, (char*) &one, sizeof(one)); + // Set reuseaddr to improve performance on restarts + setsockopt (sd, SOL_SOCKET, SO_REUSEADDR, (char*) &one, sizeof(one)); + + if (bind_addr) { + struct sockaddr_storage bind_to; + size_t bind_to_len = sizeof bind_to; + gai = name2address (bind_addr, bind_port, SOCK_STREAM, (struct sockaddr *)&bind_to, &bind_to_len); + if (gai != 0) { + close (sd); + char buf [200]; + snprintf (buf, sizeof(buf)-1, "invalid bind address: %s", gai_strerror(gai)); + throw std::runtime_error (buf); + } + if (bind (sd, (struct sockaddr *)&bind_to, bind_to_len) < 0) { + close (sd); + throw std::runtime_error ("couldn't bind to address"); + } + } + + uintptr_t out = 0; + + #ifdef OS_UNIX + int e_reason = 0; + if (connect (sd, (struct sockaddr *)&bind_as, bind_as_len) == 0) { + // This is a connect success, which Linux appears + // never to give when the socket is nonblocking, + // even if the connection is intramachine or to + // localhost. + + /* Changed this branch 08Aug06. Evidently some kernels + * (FreeBSD for example) will actually return success from + * a nonblocking connect. This is a pretty simple case, + * just set up the new connection and clear the pending flag. + * Thanks to Chris Ochs for helping track this down. + * This branch never gets taken on Linux or (oddly) OSX. + * The original behavior was to throw an unimplemented, + * which the user saw as a fatal exception. Very unfriendly. + * + * Tweaked 10Aug06. Even though the connect disposition is + * known, we still set the connect-pending flag. That way + * some needed initialization will happen in the ConnectionDescriptor. + * (To wit, the ConnectionCompleted event gets sent to the client.) + */ + ConnectionDescriptor *cd = new ConnectionDescriptor (sd, this); + if (!cd) + throw std::runtime_error ("no connection allocated"); + cd->SetConnectPending (true); + Add (cd); + out = cd->GetBinding(); + } + else if (errno == EINPROGRESS) { + // Errno will generally always be EINPROGRESS, but on Linux + // we have to look at getsockopt to be sure what really happened. + int error = 0; + socklen_t len; + len = sizeof(error); + int o = getsockopt (sd, SOL_SOCKET, SO_ERROR, &error, &len); + if ((o == 0) && (error == 0)) { + // Here, there's no disposition. + // Put the connection on the stack and wait for it to complete + // or time out. + ConnectionDescriptor *cd = new ConnectionDescriptor (sd, this); + if (!cd) + throw std::runtime_error ("no connection allocated"); + cd->SetConnectPending (true); + Add (cd); + out = cd->GetBinding(); + } else { + // Fall through to the !out case below. + e_reason = error; + } + } + else { + // The error from connect was something other then EINPROGRESS (EHOSTDOWN, etc). + // Fall through to the !out case below + e_reason = errno; + } + + if (!out) { + /* This could be connection refused or some such thing. + * We will come here on Linux if a localhost connection fails. + * Changed 16Jul06: Originally this branch was a no-op, and + * we'd drop down to the end of the method, close the socket, + * and return NULL, which would cause the caller to GET A + * FATAL EXCEPTION. Now we keep the socket around but schedule an + * immediate close on it, so the caller will get a close-event + * scheduled on it. This was only an issue for localhost connections + * to non-listening ports. We may eventually need to revise this + * revised behavior, in case it causes problems like making it hard + * for people to know that a failure occurred. + */ + ConnectionDescriptor *cd = new ConnectionDescriptor (sd, this); + if (!cd) + throw std::runtime_error ("no connection allocated"); + cd->SetUnbindReasonCode (e_reason); + cd->ScheduleClose (false); + Add (cd); + out = cd->GetBinding(); + } + #endif + + #ifdef OS_WIN32 + if (connect (sd, (struct sockaddr *)&bind_as, bind_as_len) == 0) { + // This is a connect success, which Windows appears + // never to give when the socket is nonblocking, + // even if the connection is intramachine or to + // localhost. + throw std::runtime_error ("unimplemented"); + } + else if (WSAGetLastError() == WSAEWOULDBLOCK) { + // Here, there's no disposition. + // Windows appears not to surface refused connections or + // such stuff at this point. + // Put the connection on the stack and wait for it to complete + // or time out. + ConnectionDescriptor *cd = new ConnectionDescriptor (sd, this); + if (!cd) + throw std::runtime_error ("no connection allocated"); + cd->SetConnectPending (true); + Add (cd); + out = cd->GetBinding(); + } + else { + // The error from connect was something other then WSAEWOULDBLOCK. + } + + #endif + + if (!out) + close (sd); + return out; +} + +/*********************************** +EventMachine_t::ConnectToUnixServer +***********************************/ + +#ifdef OS_UNIX +const uintptr_t EventMachine_t::ConnectToUnixServer (const char *server) +{ + /* Connect to a Unix-domain server, which by definition is running + * on the same host. + * There is no meaningful implementation on Windows. + * There's no need to do a nonblocking connect, since the connection + * is always local and can always be fulfilled immediately. + */ + + uintptr_t out = 0; + + if (!server || !*server) + return 0; + + sockaddr_un pun; + memset (&pun, 0, sizeof(pun)); + pun.sun_family = AF_LOCAL; + + // You ordinarily expect the server name field to be at least 1024 bytes long, + // but on Linux it can be MUCH shorter. + if (strlen(server) >= sizeof(pun.sun_path)) + throw std::runtime_error ("unix-domain server name is too long"); + + + strcpy (pun.sun_path, server); + + SOCKET fd = EmSocket (AF_LOCAL, SOCK_STREAM, 0); + if (fd == INVALID_SOCKET) + return 0; + + // From here on, ALL error returns must close the socket. + // NOTE: At this point, the socket is still a blocking socket. + if (connect (fd, (struct sockaddr*)&pun, sizeof(pun)) != 0) { + close (fd); + return 0; + } + + // Set the newly-connected socket nonblocking. + if (!SetSocketNonblocking (fd)) { + close (fd); + return 0; + } + + // Set up a connection descriptor and add it to the event-machine. + // Observe, even though we know the connection status is connect-success, + // we still set the "pending" flag, so some needed initializations take + // place. + ConnectionDescriptor *cd = new ConnectionDescriptor (fd, this); + if (!cd) + throw std::runtime_error ("no connection allocated"); + cd->SetConnectPending (true); + Add (cd); + out = cd->GetBinding(); + + if (!out) + close (fd); + + return out; +} +#else +const uintptr_t EventMachine_t::ConnectToUnixServer (const char *server UNUSED) +{ + throw std::runtime_error ("unix-domain connection unavailable on this platform"); +} +#endif + +/************************ +EventMachine_t::AttachFD +************************/ + +const uintptr_t EventMachine_t::AttachFD (SOCKET fd, bool watch_mode) +{ + #ifdef OS_UNIX + if (fcntl(fd, F_GETFL, 0) < 0) { + if (errno) { + throw std::runtime_error (strerror(errno)); + } else { + throw std::runtime_error ("invalid file descriptor"); + } + } + #endif + + #ifdef OS_WIN32 + // TODO: add better check for invalid file descriptors (see ioctlsocket or getsockopt) + if (fd == INVALID_SOCKET) + throw std::runtime_error ("invalid file descriptor"); + #endif + + {// Check for duplicate descriptors + size_t i; + for (i = 0; i < Descriptors.size(); i++) { + EventableDescriptor *ed = Descriptors[i]; + assert (ed); + if (ed->GetSocket() == fd) + throw std::runtime_error ("adding existing descriptor"); + } + + for (i = 0; i < NewDescriptors.size(); i++) { + EventableDescriptor *ed = NewDescriptors[i]; + assert (ed); + if (ed->GetSocket() == fd) + throw std::runtime_error ("adding existing new descriptor"); + } + } + + if (!watch_mode) + SetSocketNonblocking(fd); + + ConnectionDescriptor *cd = new ConnectionDescriptor (fd, this); + if (!cd) + throw std::runtime_error ("no connection allocated"); + + cd->SetAttached(true); + cd->SetWatchOnly(watch_mode); + cd->SetConnectPending (false); + + Add (cd); + + const uintptr_t out = cd->GetBinding(); + return out; +} + +/************************ +EventMachine_t::DetachFD +************************/ + +int EventMachine_t::DetachFD (EventableDescriptor *ed) +{ + if (!ed) + throw std::runtime_error ("detaching bad descriptor"); + + SOCKET fd = ed->GetSocket(); + + #ifdef HAVE_EPOLL + if (Poller == Poller_Epoll) { + if (ed->GetSocket() != INVALID_SOCKET) { + assert (epfd != -1); + int e = epoll_ctl (epfd, EPOLL_CTL_DEL, ed->GetSocket(), ed->GetEpollEvent()); + // ENOENT or EBADF are not errors because the socket may be already closed when we get here. + if (e && (errno != ENOENT) && (errno != EBADF)) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to delete epoll event: %s", strerror(errno)); + throw std::runtime_error (buf); + } + } + } + #endif + + #ifdef HAVE_KQUEUE + if (Poller == Poller_Kqueue) { + // remove any read/write events for this fd + struct kevent k; +#ifdef __NetBSD__ + EV_SET (&k, ed->GetSocket(), EVFILT_READ | EVFILT_WRITE, EV_DELETE, 0, 0, (intptr_t)ed); +#else + EV_SET (&k, ed->GetSocket(), EVFILT_READ | EVFILT_WRITE, EV_DELETE, 0, 0, ed); +#endif + int t = kevent (kqfd, &k, 1, NULL, 0, NULL); + if (t < 0 && (errno != ENOENT) && (errno != EBADF)) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to delete kqueue event: %s", strerror(errno)); + throw std::runtime_error (buf); + } + } + #endif + + // Prevent the descriptor from being modified, in case DetachFD was called from a timer or next_tick + ModifiedDescriptors.erase (ed); + + // Prevent the descriptor from being added, in case DetachFD was called in the same tick as AttachFD + for (size_t i = 0; i < NewDescriptors.size(); i++) { + if (ed == NewDescriptors[i]) { + NewDescriptors.erase(NewDescriptors.begin() + i); + break; + } + } + + // Set MySocket = INVALID_SOCKET so ShouldDelete() is true (and the descriptor gets deleted and removed), + // and also to prevent anyone from calling close() on the detached fd + ed->SetSocketInvalid(); + + return fd; +} + +/************ +name2address +************/ + +int EventMachine_t::name2address (const char *server, int port, int socktype, struct sockaddr *addr, size_t *addr_len) +{ + if (!server || !*server) + server = "0.0.0.0"; + + struct addrinfo *ai; + struct addrinfo hints; + memset (&hints, 0, sizeof(hints)); + hints.ai_socktype = socktype; + hints.ai_family = AF_UNSPEC; + hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG; + + char portstr[12]; + snprintf(portstr, sizeof(portstr), "%u", port); + + int gai = getaddrinfo (server, portstr, &hints, &ai); + if (gai == 0) { + assert (ai->ai_addrlen <= *addr_len); + memcpy (addr, ai->ai_addr, ai->ai_addrlen); + *addr_len = ai->ai_addrlen; + freeaddrinfo(ai); + } + + return gai; +} + + +/******************************* +EventMachine_t::CreateTcpServer +*******************************/ + +const uintptr_t EventMachine_t::CreateTcpServer (const char *server, int port) +{ + /* Create a TCP-acceptor (server) socket and add it to the event machine. + * Return the binding of the new acceptor to the caller. + * This binding will be referenced when the new acceptor sends events + * to indicate accepted connections. + */ + + + struct sockaddr_storage bind_here; + size_t bind_here_len = sizeof bind_here; + if (0 != name2address (server, port, SOCK_STREAM, (struct sockaddr *)&bind_here, &bind_here_len)) + return 0; + + SOCKET sd_accept = EmSocket (bind_here.ss_family, SOCK_STREAM, 0); + if (sd_accept == INVALID_SOCKET) { + goto fail; + } + + { // set reuseaddr to improve performance on restarts. + int oval = 1; + if (setsockopt (sd_accept, SOL_SOCKET, SO_REUSEADDR, (char*)&oval, sizeof(oval)) < 0) { + //__warning ("setsockopt failed while creating listener",""); + goto fail; + } + } + + { // set CLOEXEC. Only makes sense on Unix + #ifdef OS_UNIX + int cloexec = fcntl (sd_accept, F_GETFD, 0); + assert (cloexec >= 0); + cloexec |= FD_CLOEXEC; + fcntl (sd_accept, F_SETFD, cloexec); + #endif + } + + + if (bind (sd_accept, (struct sockaddr *)&bind_here, bind_here_len)) { + //__warning ("binding failed"); + goto fail; + } + + if (listen (sd_accept, 100)) { + //__warning ("listen failed"); + goto fail; + } + + return AttachSD(sd_accept); + + fail: + if (sd_accept != INVALID_SOCKET) + close (sd_accept); + return 0; +} + + +/********************************** +EventMachine_t::OpenDatagramSocket +**********************************/ + +const uintptr_t EventMachine_t::OpenDatagramSocket (const char *address, int port) +{ + uintptr_t output_binding = 0; + + struct sockaddr_storage bind_here; + size_t bind_here_len = sizeof bind_here; + if (0 != name2address (address, port, SOCK_DGRAM, (struct sockaddr *)&bind_here, &bind_here_len)) + return 0; + + // from here on, early returns must close the socket! + SOCKET sd = EmSocket (bind_here.ss_family, SOCK_DGRAM, 0); + if (sd == INVALID_SOCKET) + goto fail; + + { // set the SO_REUSEADDR on the socket before we bind, otherwise it won't work for a second one + int oval = 1; + if (setsockopt (sd, SOL_SOCKET, SO_REUSEADDR, (char*)&oval, sizeof(oval)) < 0) + goto fail; + } + + // Set the new socket nonblocking. + if (!SetSocketNonblocking (sd)) + goto fail; + + if (bind (sd, (struct sockaddr *)&bind_here, bind_here_len) != 0) + goto fail; + + { // Looking good. + DatagramDescriptor *ds = new DatagramDescriptor (sd, this); + if (!ds) + throw std::runtime_error ("unable to allocate datagram-socket"); + Add (ds); + output_binding = ds->GetBinding(); + } + + return output_binding; + + fail: + if (sd != INVALID_SOCKET) + close (sd); + return 0; +} + + + +/******************* +EventMachine_t::Add +*******************/ + +void EventMachine_t::Add (EventableDescriptor *ed) +{ + if (!ed) + throw std::runtime_error ("added bad descriptor"); + ed->SetEventCallback (EventCallback); + NewDescriptors.push_back (ed); +} + + +/******************************* +EventMachine_t::ArmKqueueWriter +*******************************/ + +#ifdef HAVE_KQUEUE +void EventMachine_t::ArmKqueueWriter (EventableDescriptor *ed) +{ + if (Poller == Poller_Kqueue) { + if (!ed) + throw std::runtime_error ("added bad descriptor"); + struct kevent k; +#ifdef __NetBSD__ + EV_SET (&k, ed->GetSocket(), EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, (intptr_t)ed); +#else + EV_SET (&k, ed->GetSocket(), EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, ed); +#endif + int t = kevent (kqfd, &k, 1, NULL, 0, NULL); + if (t < 0) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "arm kqueue writer failed on %d: %s", ed->GetSocket(), strerror(errno)); + throw std::runtime_error (buf); + } + } +} +#else +void EventMachine_t::ArmKqueueWriter (EventableDescriptor *ed UNUSED) { } +#endif + +/******************************* +EventMachine_t::ArmKqueueReader +*******************************/ + +#ifdef HAVE_KQUEUE +void EventMachine_t::ArmKqueueReader (EventableDescriptor *ed) +{ + if (Poller == Poller_Kqueue) { + if (!ed) + throw std::runtime_error ("added bad descriptor"); + struct kevent k; +#ifdef __NetBSD__ + EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, (intptr_t)ed); +#else + EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, ed); +#endif + int t = kevent (kqfd, &k, 1, NULL, 0, NULL); + if (t < 0) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "arm kqueue reader failed on %d: %s", ed->GetSocket(), strerror(errno)); + throw std::runtime_error (buf); + } + } +} +#else +void EventMachine_t::ArmKqueueReader (EventableDescriptor *ed UNUSED) { } +#endif + +/********************************** +EventMachine_t::_AddNewDescriptors +**********************************/ + +void EventMachine_t::_AddNewDescriptors() +{ + /* Avoid adding descriptors to the main descriptor list + * while we're actually traversing the list. + * Any descriptors that are added as a result of processing timers + * or acceptors should go on a temporary queue and then added + * while we're not traversing the main list. + * Also, it (rarely) happens that a newly-created descriptor + * is immediately scheduled to close. It might be a good + * idea not to bother scheduling these for I/O but if + * we do that, we might bypass some important processing. + */ + + for (size_t i = 0; i < NewDescriptors.size(); i++) { + EventableDescriptor *ed = NewDescriptors[i]; + if (ed == NULL) + throw std::runtime_error ("adding bad descriptor"); + + #if HAVE_EPOLL + if (Poller == Poller_Epoll) { + assert (epfd != -1); + int e = epoll_ctl (epfd, EPOLL_CTL_ADD, ed->GetSocket(), ed->GetEpollEvent()); + if (e) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to add new descriptor: %s", strerror(errno)); + throw std::runtime_error (buf); + } + } + #endif + + #if HAVE_KQUEUE + /* + if (Poller == Poller_Kqueue) { + // INCOMPLETE. Some descriptors don't want to be readable. + assert (kqfd != -1); + struct kevent k; +#ifdef __NetBSD__ + EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, (intptr_t)ed); +#else + EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, ed); +#endif + int t = kevent (kqfd, &k, 1, NULL, 0, NULL); + assert (t == 0); + } + */ + #endif + + QueueHeartbeat(ed); + Descriptors.push_back (ed); + } + NewDescriptors.clear(); +} + + +/********************************** +EventMachine_t::_ModifyDescriptors +**********************************/ + +void EventMachine_t::_ModifyDescriptors() +{ + /* For implementations which don't level check every descriptor on + * every pass through the machine, as select does. + * If we're not selecting, then descriptors need a way to signal to the + * machine that their readable or writable status has changed. + * That's what the ::Modify call is for. We do it this way to avoid + * modifying descriptors during the loop traversal, where it can easily + * happen that an object (like a UDP socket) gets data written on it by + * the application during #post_init. That would take place BEFORE the + * descriptor even gets added to the epoll descriptor, so the modify + * operation will crash messily. + * Another really messy possibility is for a descriptor to put itself + * on the Modified list, and then get deleted before we get here. + * Remember, deletes happen after the I/O traversal and before the + * next pass through here. So we have to make sure when we delete a + * descriptor to remove it from the Modified list. + */ + + #ifdef HAVE_EPOLL + if (Poller == Poller_Epoll) { + std::set::iterator i = ModifiedDescriptors.begin(); + while (i != ModifiedDescriptors.end()) { + assert (*i); + _ModifyEpollEvent (*i); + ++i; + } + } + #endif + + #ifdef HAVE_KQUEUE + if (Poller == Poller_Kqueue) { + std::set::iterator i = ModifiedDescriptors.begin(); + while (i != ModifiedDescriptors.end()) { + assert (*i); + if ((*i)->GetKqueueArmWrite()) + ArmKqueueWriter (*i); + ++i; + } + } + #endif + + ModifiedDescriptors.clear(); +} + + +/********************** +EventMachine_t::Modify +**********************/ + +void EventMachine_t::Modify (EventableDescriptor *ed) +{ + if (!ed) + throw std::runtime_error ("modified bad descriptor"); + ModifiedDescriptors.insert (ed); +} + + +/*********************** +EventMachine_t::Deregister +***********************/ + +void EventMachine_t::Deregister (EventableDescriptor *ed) +{ + if (!ed) + throw std::runtime_error ("modified bad descriptor"); + #ifdef HAVE_EPOLL + // cut/paste from _CleanupSockets(). The error handling could be + // refactored out of there, but it is cut/paste all over the + // file already. + if (Poller == Poller_Epoll) { + assert (epfd != -1); + assert (ed->GetSocket() != INVALID_SOCKET); + int e = epoll_ctl (epfd, EPOLL_CTL_DEL, ed->GetSocket(), ed->GetEpollEvent()); + // ENOENT or EBADF are not errors because the socket may be already closed when we get here. + if (e && (errno != ENOENT) && (errno != EBADF) && (errno != EPERM)) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "unable to delete epoll event: %s", strerror(errno)); + throw std::runtime_error (buf); + } + ModifiedDescriptors.erase(ed); + } + #endif + + #ifdef HAVE_KQUEUE + if (Poller == Poller_Kqueue) { + assert (ed->GetSocket() != INVALID_SOCKET); + + ModifiedDescriptors.erase(ed); + } + #endif +} + + +/************************************** +EventMachine_t::CreateUnixDomainServer +**************************************/ + +#ifdef OS_UNIX +const uintptr_t EventMachine_t::CreateUnixDomainServer (const char *filename) +{ + /* Create a UNIX-domain acceptor (server) socket and add it to the event machine. + * Return the binding of the new acceptor to the caller. + * This binding will be referenced when the new acceptor sends events + * to indicate accepted connections. + * THERE IS NO MEANINGFUL IMPLEMENTATION ON WINDOWS. + */ + + struct sockaddr_un s_sun; + + SOCKET sd_accept = EmSocket (AF_LOCAL, SOCK_STREAM, 0); + if (sd_accept == INVALID_SOCKET) { + goto fail; + } + + if (!filename || !*filename) + goto fail; + unlink (filename); + + bzero (&s_sun, sizeof(s_sun)); + s_sun.sun_family = AF_LOCAL; + strncpy (s_sun.sun_path, filename, sizeof(s_sun.sun_path)-1); + + // don't bother with reuseaddr for a local socket. + + { // set CLOEXEC. Only makes sense on Unix + #ifdef OS_UNIX + int cloexec = fcntl (sd_accept, F_GETFD, 0); + assert (cloexec >= 0); + cloexec |= FD_CLOEXEC; + fcntl (sd_accept, F_SETFD, cloexec); + #endif + } + + if (bind (sd_accept, (struct sockaddr*)&s_sun, sizeof(s_sun))) { + //__warning ("binding failed"); + goto fail; + } + + if (listen (sd_accept, 100)) { + //__warning ("listen failed"); + goto fail; + } + + return AttachSD(sd_accept); + + fail: + if (sd_accept != INVALID_SOCKET) + close (sd_accept); + return 0; +} +#else +const uintptr_t EventMachine_t::CreateUnixDomainServer (const char *filename UNUSED) +{ + throw std::runtime_error ("unix-domain server unavailable on this platform"); +} +#endif + + +/************************************** +EventMachine_t::AttachSD +**************************************/ + +const uintptr_t EventMachine_t::AttachSD (SOCKET sd_accept) +{ + uintptr_t output_binding = 0; + + { + // Set the acceptor non-blocking. + // THIS IS CRUCIALLY IMPORTANT because we read it in a select loop. + if (!SetSocketNonblocking (sd_accept)) { + //int val = fcntl (sd_accept, F_GETFL, 0); + //if (fcntl (sd_accept, F_SETFL, val | O_NONBLOCK) == -1) { + goto fail; + } + } + + { // Looking good. + AcceptorDescriptor *ad = new AcceptorDescriptor (sd_accept, this); + if (!ad) + throw std::runtime_error ("unable to allocate acceptor"); + Add (ad); + output_binding = ad->GetBinding(); + } + + return output_binding; + + fail: + if (sd_accept != INVALID_SOCKET) + close (sd_accept); + return 0; +} + + +/************************** +EventMachine_t::Socketpair +**************************/ + +#ifdef OS_UNIX +const uintptr_t EventMachine_t::Socketpair (char * const * cmd_strings) +{ + // Make sure the incoming array of command strings is sane. + if (!cmd_strings) + return 0; + int j; + for (j=0; j < 2048 && cmd_strings[j]; j++) + ; + if ((j==0) || (j==2048)) + return 0; + + uintptr_t output_binding = 0; + + int sv[2]; + if (socketpair (AF_LOCAL, SOCK_STREAM, 0, sv) < 0) + return 0; + // from here, all early returns must close the pair of sockets. + + // Set the parent side of the socketpair nonblocking. + // We don't care about the child side, and most child processes will expect their + // stdout to be blocking. Thanks to Duane Johnson and Bill Kelly for pointing this out. + // Obviously DON'T set CLOEXEC. + if (!SetSocketNonblocking (sv[0])) { + close (sv[0]); + close (sv[1]); + return 0; + } + + pid_t f = fork(); + if (f > 0) { + close (sv[1]); + PipeDescriptor *pd = new PipeDescriptor (sv[0], f, this); + if (!pd) + throw std::runtime_error ("unable to allocate pipe"); + Add (pd); + output_binding = pd->GetBinding(); + } + else if (f == 0) { + close (sv[0]); + dup2 (sv[1], STDIN_FILENO); + close (sv[1]); + dup2 (STDIN_FILENO, STDOUT_FILENO); + execvp (cmd_strings[0], cmd_strings+1); + exit (-1); // end the child process if the exec doesn't work. + } + else + throw std::runtime_error ("no fork"); + + return output_binding; +} +#else +const uintptr_t EventMachine_t::Socketpair (char * const * cmd_strings UNUSED) +{ + throw std::runtime_error ("socketpair is currently unavailable on this platform"); +} +#endif + + + +/**************************** +EventMachine_t::OpenKeyboard +****************************/ + +const uintptr_t EventMachine_t::OpenKeyboard() +{ + KeyboardDescriptor *kd = new KeyboardDescriptor (this); + if (!kd) + throw std::runtime_error ("no keyboard-object allocated"); + Add (kd); + return kd->GetBinding(); +} + + +/********************************** +EventMachine_t::GetConnectionCount +**********************************/ + +int EventMachine_t::GetConnectionCount () +{ + int i = 0; + // Subtract one for epoll or kqueue because of the LoopbreakDescriptor + if (Poller == Poller_Epoll || Poller == Poller_Kqueue) + i = 1; + + return Descriptors.size() + NewDescriptors.size() - i; +} + + +/************************ +EventMachine_t::WatchPid +************************/ + +#ifdef HAVE_KQUEUE +const uintptr_t EventMachine_t::WatchPid (int pid) +{ + if (Poller != Poller_Kqueue) + throw std::runtime_error("must enable kqueue (EM.kqueue=true) for pid watching support"); + + struct kevent event; + int kqres; + + EV_SET(&event, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT | NOTE_FORK, 0, 0); + + // Attempt to register the event + kqres = kevent(kqfd, &event, 1, NULL, 0, NULL); + if (kqres == -1) { + char errbuf[200]; + sprintf(errbuf, "failed to register file watch descriptor with kqueue: %s", strerror(errno)); + throw std::runtime_error(errbuf); + } + Bindable_t* b = new Bindable_t(); + Pids.insert(std::make_pair (pid, b)); + + return b->GetBinding(); +} +#else +const uintptr_t EventMachine_t::WatchPid (int pid UNUSED) +{ + throw std::runtime_error("no pid watching support on this system"); +} +#endif + +/************************** +EventMachine_t::UnwatchPid +**************************/ + +void EventMachine_t::UnwatchPid (int pid) +{ + Bindable_t *b = Pids[pid]; + assert(b); + Pids.erase(pid); + + #ifdef HAVE_KQUEUE + struct kevent k; + + EV_SET(&k, pid, EVFILT_PROC, EV_DELETE, 0, 0, 0); + /*int t =*/ kevent (kqfd, &k, 1, NULL, 0, NULL); + // t==-1 if the process already exited; ignore this for now + #endif + + if (EventCallback) + (*EventCallback)(b->GetBinding(), EM_CONNECTION_UNBOUND, NULL, 0); + + delete b; +} + +void EventMachine_t::UnwatchPid (const uintptr_t sig) +{ + for(std::map::iterator i=Pids.begin(); i != Pids.end(); i++) + { + if (i->second->GetBinding() == sig) { + UnwatchPid (i->first); + return; + } + } + + throw std::runtime_error("attempted to remove invalid pid signature"); +} + + +/************************* +EventMachine_t::WatchFile +*************************/ + +const uintptr_t EventMachine_t::WatchFile (const char *fpath) +{ + struct stat sb; + int sres; + int wd = -1; + + sres = stat(fpath, &sb); + + if (sres == -1) { + char errbuf[300]; + sprintf(errbuf, "error registering file %s for watching: %s", fpath, strerror(errno)); + throw std::runtime_error(errbuf); + } + + #ifdef HAVE_INOTIFY + if (!inotify) { + inotify = new InotifyDescriptor(this); + assert (inotify); + Add(inotify); + } + + wd = inotify_add_watch(inotify->GetSocket(), fpath, + IN_MODIFY | IN_DELETE_SELF | IN_MOVE_SELF | IN_CREATE | IN_DELETE | IN_MOVE) ; + if (wd == -1) { + char errbuf[300]; + sprintf(errbuf, "failed to open file %s for registering with inotify: %s", fpath, strerror(errno)); + throw std::runtime_error(errbuf); + } + #endif + + #ifdef HAVE_KQUEUE + if (Poller != Poller_Kqueue) + throw std::runtime_error("must enable kqueue (EM.kqueue=true) for file watching support"); + + // With kqueue we have to open the file first and use the resulting fd to register for events + wd = open(fpath, O_RDONLY); + if (wd == -1) { + char errbuf[300]; + sprintf(errbuf, "failed to open file %s for registering with kqueue: %s", fpath, strerror(errno)); + throw std::runtime_error(errbuf); + } + _RegisterKqueueFileEvent(wd); + #endif + + if (wd != -1) { + Bindable_t* b = new Bindable_t(); + Files.insert(std::make_pair (wd, b)); + + return b->GetBinding(); + } + + throw std::runtime_error("no file watching support on this system"); // is this the right thing to do? +} + + +/*************************** +EventMachine_t::UnwatchFile +***************************/ + +void EventMachine_t::UnwatchFile (int wd) +{ + Bindable_t *b = Files[wd]; + assert(b); + Files.erase(wd); + + #ifdef HAVE_INOTIFY + inotify_rm_watch(inotify->GetSocket(), wd); + #elif HAVE_KQUEUE + // With kqueue, closing the monitored fd automatically clears all registered events for it + close(wd); + #endif + + if (EventCallback) + (*EventCallback)(b->GetBinding(), EM_CONNECTION_UNBOUND, NULL, 0); + + delete b; +} + +void EventMachine_t::UnwatchFile (const uintptr_t sig) +{ + for(std::map::iterator i=Files.begin(); i != Files.end(); i++) + { + if (i->second->GetBinding() == sig) { + UnwatchFile (i->first); + return; + } + } + throw std::runtime_error("attempted to remove invalid watch signature"); +} + + +/*********************************** +EventMachine_t::_ReadInotify_Events +************************************/ + +void EventMachine_t::_ReadInotifyEvents() +{ + #ifdef HAVE_INOTIFY + char buffer[1024]; + + assert(EventCallback); + + for (;;) { + int returned = read(inotify->GetSocket(), buffer, sizeof(buffer)); + assert(!(returned == 0 || (returned == -1 && errno == EINVAL))); + if (returned <= 0) { + break; + } + int current = 0; + while (current < returned) { + struct inotify_event* event = (struct inotify_event*)(buffer+current); + std::map::const_iterator bindable = Files.find(event->wd); + if (bindable != Files.end()) { + if (event->mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE)){ + (*EventCallback)(bindable->second->GetBinding(), EM_CONNECTION_READ, "modified", 8); + } + if (event->mask & IN_MOVE_SELF){ + (*EventCallback)(bindable->second->GetBinding(), EM_CONNECTION_READ, "moved", 5); + } + if (event->mask & IN_DELETE_SELF) { + (*EventCallback)(bindable->second->GetBinding(), EM_CONNECTION_READ, "deleted", 7); + UnwatchFile ((int)event->wd); + } + } + current += sizeof(struct inotify_event) + event->len; + } + } + #endif +} + + +/************************************* +EventMachine_t::_HandleKqueuePidEvent +*************************************/ + +#ifdef HAVE_KQUEUE +void EventMachine_t::_HandleKqueuePidEvent(struct kevent *event) +{ + assert(EventCallback); + + if (event->fflags & NOTE_FORK) + (*EventCallback)(Pids [(int) event->ident]->GetBinding(), EM_CONNECTION_READ, "fork", 4); + if (event->fflags & NOTE_EXIT) { + (*EventCallback)(Pids [(int) event->ident]->GetBinding(), EM_CONNECTION_READ, "exit", 4); + // stop watching the pid if it died + UnwatchPid ((int)event->ident); + } +} +#endif + + +/************************************** +EventMachine_t::_HandleKqueueFileEvent +***************************************/ + +#ifdef HAVE_KQUEUE +void EventMachine_t::_HandleKqueueFileEvent(struct kevent *event) +{ + assert(EventCallback); + + if (event->fflags & NOTE_WRITE) + (*EventCallback)(Files [(int) event->ident]->GetBinding(), EM_CONNECTION_READ, "modified", 8); + if (event->fflags & NOTE_RENAME) + (*EventCallback)(Files [(int) event->ident]->GetBinding(), EM_CONNECTION_READ, "moved", 5); + if (event->fflags & NOTE_DELETE) { + (*EventCallback)(Files [(int) event->ident]->GetBinding(), EM_CONNECTION_READ, "deleted", 7); + UnwatchFile ((int)event->ident); + } +} +#endif + + +/**************************************** +EventMachine_t::_RegisterKqueueFileEvent +*****************************************/ + +#ifdef HAVE_KQUEUE +void EventMachine_t::_RegisterKqueueFileEvent(int fd) +{ + struct kevent newevent; + int kqres; + + // Setup the event with our fd and proper flags + EV_SET(&newevent, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_DELETE | NOTE_RENAME | NOTE_WRITE, 0, 0); + + // Attempt to register the event + kqres = kevent(kqfd, &newevent, 1, NULL, 0, NULL); + if (kqres == -1) { + char errbuf[200]; + sprintf(errbuf, "failed to register file watch descriptor with kqueue: %s", strerror(errno)); + close(fd); + throw std::runtime_error(errbuf); + } +} +#endif + + +/************************************ +EventMachine_t::GetHeartbeatInterval +*************************************/ + +float EventMachine_t::GetHeartbeatInterval() +{ + return ((float)HeartbeatInterval / 1000000); +} + + +/************************************ +EventMachine_t::SetHeartbeatInterval +*************************************/ + +int EventMachine_t::SetHeartbeatInterval(float interval) +{ + int iv = (int)(interval * 1000000); + if (iv > 0) { + HeartbeatInterval = iv; + return 1; + } + return 0; +} +//#endif // OS_UNIX diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/em.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/em.h new file mode 100644 index 0000000..874a127 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/em.h @@ -0,0 +1,308 @@ +/***************************************************************************** + +$Id$ + +File: em.h +Date: 06Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#ifndef __EventMachine__H_ +#define __EventMachine__H_ + +#ifdef BUILD_FOR_RUBY + #include + #ifdef HAVE_RB_THREAD_FD_SELECT + #define EmSelect rb_thread_fd_select + #else + // ruby 1.9.1 and below + #define EmSelect rb_thread_select + #endif + + #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL + #include + #endif + + #ifdef HAVE_RB_WAIT_FOR_SINGLE_FD + #include + #endif + + #if defined(HAVE_RB_TRAP_IMMEDIATE) + #include + #elif defined(HAVE_RB_ENABLE_INTERRUPT) + extern "C" { + void rb_enable_interrupt(void); + void rb_disable_interrupt(void); + } + + #define TRAP_BEG rb_enable_interrupt() + #define TRAP_END do { rb_disable_interrupt(); rb_thread_check_ints(); } while(0) + #else + #define TRAP_BEG + #define TRAP_END + #endif + + // 1.9.0 compat + #ifndef RUBY_UBF_IO + #define RUBY_UBF_IO RB_UBF_DFL + #endif + #ifndef RSTRING_PTR + #define RSTRING_PTR(str) RSTRING(str)->ptr + #endif + #ifndef RSTRING_LEN + #define RSTRING_LEN(str) RSTRING(str)->len + #endif + #ifndef RSTRING_LENINT + #define RSTRING_LENINT(str) RSTRING_LEN(str) + #endif +#else + #define EmSelect select +#endif + +#if !defined(HAVE_TYPE_RB_FDSET_T) +#define fd_check(n) (((n) < FD_SETSIZE) ? 1 : 0*fprintf(stderr, "fd %d too large for select\n", (n))) +// These definitions are cribbed from include/ruby/intern.h in Ruby 1.9.3, +// with this change: any macros that read or write the nth element of an +// fdset first call fd_check to make sure n is in bounds. +typedef fd_set rb_fdset_t; +#define rb_fd_zero(f) FD_ZERO(f) +#define rb_fd_set(n, f) do { if (fd_check(n)) FD_SET((n), (f)); } while(0) +#define rb_fd_clr(n, f) do { if (fd_check(n)) FD_CLR((n), (f)); } while(0) +#define rb_fd_isset(n, f) (fd_check(n) ? FD_ISSET((n), (f)) : 0) +#define rb_fd_copy(d, s, n) (*(d) = *(s)) +#define rb_fd_dup(d, s) (*(d) = *(s)) +#define rb_fd_resize(n, f) ((void)(f)) +#define rb_fd_ptr(f) (f) +#define rb_fd_init(f) FD_ZERO(f) +#define rb_fd_init_copy(d, s) (*(d) = *(s)) +#define rb_fd_term(f) ((void)(f)) +#define rb_fd_max(f) FD_SETSIZE +#define rb_fd_select(n, rfds, wfds, efds, timeout) \ + select(fd_check((n)-1) ? (n) : FD_SETSIZE, (rfds), (wfds), (efds), (timeout)) +#define rb_thread_fd_select(n, rfds, wfds, efds, timeout) \ + rb_thread_select(fd_check((n)-1) ? (n) : FD_SETSIZE, (rfds), (wfds), (efds), (timeout)) +#endif + + +// This Solaris fix is adapted from eval_intern.h in Ruby 1.9.3: +// Solaris sys/select.h switches select to select_large_fdset to support larger +// file descriptors if FD_SETSIZE is larger than 1024 on 32bit environment. +// But Ruby doesn't change FD_SETSIZE because fd_set is allocated dynamically. +// So following definition is required to use select_large_fdset. +#ifdef HAVE_SELECT_LARGE_FDSET +#define select(n, r, w, e, t) select_large_fdset((n), (r), (w), (e), (t)) +extern "C" { + int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval *); +} +#endif + +class EventableDescriptor; +class InotifyDescriptor; +struct SelectData_t; + +/************* +enum Poller_t +*************/ +enum Poller_t { + Poller_Default, // typically Select + Poller_Epoll, + Poller_Kqueue +}; + + +/******************** +class EventMachine_t +********************/ + +class EventMachine_t +{ + public: + static int GetMaxTimerCount(); + static void SetMaxTimerCount (int); + + static int GetSimultaneousAcceptCount(); + static void SetSimultaneousAcceptCount (int); + + public: + EventMachine_t (EMCallback, Poller_t); + virtual ~EventMachine_t(); + + bool RunOnce(); + void Run(); + void ScheduleHalt(); + bool Stopping(); + void SignalLoopBreaker(); + const uintptr_t InstallOneshotTimer (uint64_t); + const uintptr_t ConnectToServer (const char *, int, const char *, int); + const uintptr_t ConnectToUnixServer (const char *); + + const uintptr_t CreateTcpServer (const char *, int); + const uintptr_t OpenDatagramSocket (const char *, int); + const uintptr_t CreateUnixDomainServer (const char*); + const uintptr_t AttachSD (SOCKET); + const uintptr_t OpenKeyboard(); + //const char *Popen (const char*, const char*); + const uintptr_t Socketpair (char* const*); + + void Add (EventableDescriptor*); + void Modify (EventableDescriptor*); + void Deregister (EventableDescriptor*); + + const uintptr_t AttachFD (SOCKET, bool); + int DetachFD (EventableDescriptor*); + + void ArmKqueueWriter (EventableDescriptor*); + void ArmKqueueReader (EventableDescriptor*); + + void SetTimerQuantum (int); + static void SetuidString (const char*); + static int SetRlimitNofile (int); + + pid_t SubprocessPid; + int SubprocessExitStatus; + + int GetConnectionCount(); + float GetHeartbeatInterval(); + int SetHeartbeatInterval(float); + + const uintptr_t WatchFile (const char*); + void UnwatchFile (int); + void UnwatchFile (const uintptr_t); + + #ifdef HAVE_KQUEUE + void _HandleKqueueFileEvent (struct kevent*); + void _RegisterKqueueFileEvent(int); + #endif + + const uintptr_t WatchPid (int); + void UnwatchPid (int); + void UnwatchPid (const uintptr_t); + + #ifdef HAVE_KQUEUE + void _HandleKqueuePidEvent (struct kevent*); + #endif + + uint64_t GetCurrentLoopTime() { return MyCurrentLoopTime; } + + void QueueHeartbeat(EventableDescriptor*); + void ClearHeartbeat(uint64_t, EventableDescriptor*); + + uint64_t GetRealTime(); + + Poller_t GetPoller() { return Poller; } + + static int name2address (const char *server, int port, int socktype, struct sockaddr *addr, size_t *addr_len); + + private: + void _RunTimers(); + void _UpdateTime(); + void _AddNewDescriptors(); + void _ModifyDescriptors(); + void _InitializeLoopBreaker(); + void _CleanupSockets(); + + void _RunSelectOnce(); + void _RunEpollOnce(); + void _RunKqueueOnce(); + + void _ModifyEpollEvent (EventableDescriptor*); + void _DispatchHeartbeats(); + timeval _TimeTilNextEvent(); + void _CleanBadDescriptors(); + + public: + void _ReadLoopBreaker(); + void _ReadInotifyEvents(); + int NumCloseScheduled; + + private: + enum { + MaxEpollDescriptors = 64*1024, + MaxEvents = 4096 + }; + int HeartbeatInterval; + EMCallback EventCallback; + + class Timer_t: public Bindable_t { + }; + + std::multimap Timers; + std::multimap Heartbeats; + std::map Files; + std::map Pids; + std::vector Descriptors; + std::vector NewDescriptors; + std::set ModifiedDescriptors; + + SOCKET LoopBreakerReader; + SOCKET LoopBreakerWriter; + #ifdef OS_WIN32 + struct sockaddr_in LoopBreakerTarget; + #endif + + timeval Quantum; + + uint64_t MyCurrentLoopTime; + + #ifdef OS_WIN32 + unsigned TickCountTickover; + unsigned LastTickCount; + #endif + + #ifdef OS_DARWIN + mach_timebase_info_data_t mach_timebase; + #endif + + private: + bool bTerminateSignalReceived; + SelectData_t *SelectData; + + Poller_t Poller; + + int epfd; // Epoll file-descriptor + #ifdef HAVE_EPOLL + struct epoll_event epoll_events [MaxEvents]; + #endif + + int kqfd; // Kqueue file-descriptor + #ifdef HAVE_KQUEUE + struct kevent Karray [MaxEvents]; + #endif + + #ifdef HAVE_INOTIFY + InotifyDescriptor *inotify; // pollable descriptor for our inotify instance + #endif +}; + + +/******************* +struct SelectData_t +*******************/ + +struct SelectData_t +{ + SelectData_t(); + ~SelectData_t(); + + int _Select(); + void _Clear(); + + SOCKET maxsocket; + rb_fdset_t fdreads; + rb_fdset_t fdwrites; + rb_fdset_t fderrors; + timeval tv; + int nSockets; +}; + +#endif // __EventMachine__H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/eventmachine.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/eventmachine.h new file mode 100644 index 0000000..5100e20 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/eventmachine.h @@ -0,0 +1,143 @@ +/***************************************************************************** + +$Id$ + +File: eventmachine.h +Date: 15Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#ifndef __EVMA_EventMachine__H_ +#define __EVMA_EventMachine__H_ + +#if __cplusplus +extern "C" { +#endif + + enum { // Event names + EM_TIMER_FIRED = 100, + EM_CONNECTION_READ = 101, + EM_CONNECTION_UNBOUND = 102, + EM_CONNECTION_ACCEPTED = 103, + EM_CONNECTION_COMPLETED = 104, + EM_LOOPBREAK_SIGNAL = 105, + EM_CONNECTION_NOTIFY_READABLE = 106, + EM_CONNECTION_NOTIFY_WRITABLE = 107, + EM_SSL_HANDSHAKE_COMPLETED = 108, + EM_SSL_VERIFY = 109, + EM_PROXY_TARGET_UNBOUND = 110, + EM_PROXY_COMPLETED = 111 + }; + + enum { // SSL/TLS Protocols + EM_PROTO_SSLv2 = 2, + EM_PROTO_SSLv3 = 4, + EM_PROTO_TLSv1 = 8, + EM_PROTO_TLSv1_1 = 16, + EM_PROTO_TLSv1_2 = 32 + }; + + void evma_initialize_library (EMCallback); + bool evma_run_machine_once(); + void evma_run_machine(); + void evma_release_library(); + const uintptr_t evma_install_oneshot_timer (uint64_t milliseconds); + const uintptr_t evma_connect_to_server (const char *bind_addr, int bind_port, const char *server, int port); + const uintptr_t evma_connect_to_unix_server (const char *server); + + const uintptr_t evma_attach_fd (int file_descriptor, int watch_mode); + int evma_detach_fd (const uintptr_t binding); + int evma_get_file_descriptor (const uintptr_t binding); + int evma_is_notify_readable (const uintptr_t binding); + void evma_set_notify_readable (const uintptr_t binding, int mode); + int evma_is_notify_writable (const uintptr_t binding); + void evma_set_notify_writable (const uintptr_t binding, int mode); + + int evma_pause(const uintptr_t binding); + int evma_is_paused(const uintptr_t binding); + int evma_resume(const uintptr_t binding); + + int evma_num_close_scheduled(); + + void evma_stop_tcp_server (const uintptr_t binding); + const uintptr_t evma_create_tcp_server (const char *address, int port); + const uintptr_t evma_create_unix_domain_server (const char *filename); + const uintptr_t evma_attach_sd (int sd); + const uintptr_t evma_open_datagram_socket (const char *server, int port); + const uintptr_t evma_open_keyboard(); + void evma_set_tls_parms (const uintptr_t binding, const char *privatekey_filename, const char *certchain_filenane, int verify_peer, int fail_if_no_peer_cert, const char *sni_hostname, const char *cipherlist, const char *ecdh_curve, const char *dhparam, int protocols); + void evma_start_tls (const uintptr_t binding); + + #ifdef WITH_SSL + X509 *evma_get_peer_cert (const uintptr_t binding); + int evma_get_cipher_bits (const uintptr_t binding); + const char *evma_get_cipher_name (const uintptr_t binding); + const char *evma_get_cipher_protocol (const uintptr_t binding); + const char *evma_get_sni_hostname (const uintptr_t binding); + void evma_accept_ssl_peer (const uintptr_t binding); + #endif + + int evma_get_peername (const uintptr_t binding, struct sockaddr*, socklen_t*); + int evma_get_sockname (const uintptr_t binding, struct sockaddr*, socklen_t*); + int evma_get_subprocess_pid (const uintptr_t binding, pid_t*); + int evma_get_subprocess_status (const uintptr_t binding, int*); + int evma_get_connection_count(); + int evma_send_data_to_connection (const uintptr_t binding, const char *data, int data_length); + int evma_send_datagram (const uintptr_t binding, const char *data, int data_length, const char *address, int port); + float evma_get_comm_inactivity_timeout (const uintptr_t binding); + int evma_set_comm_inactivity_timeout (const uintptr_t binding, float value); + float evma_get_pending_connect_timeout (const uintptr_t binding); + int evma_set_pending_connect_timeout (const uintptr_t binding, float value); + int evma_get_outbound_data_size (const uintptr_t binding); + uint64_t evma_get_last_activity_time (const uintptr_t binding); + int evma_send_file_data_to_connection (const uintptr_t binding, const char *filename); + + void evma_close_connection (const uintptr_t binding, int after_writing); + int evma_report_connection_error_status (const uintptr_t binding); + void evma_signal_loopbreak(); + void evma_set_timer_quantum (int); + int evma_get_max_timer_count(); + void evma_set_max_timer_count (int); + int evma_get_simultaneous_accept_count(); + void evma_set_simultaneous_accept_count (int); + void evma_setuid_string (const char *username); + void evma_stop_machine(); + bool evma_stopping(); + float evma_get_heartbeat_interval(); + int evma_set_heartbeat_interval(float); + + const uintptr_t evma_popen (char * const*cmd_strings); + + const uintptr_t evma_watch_filename (const char *fname); + void evma_unwatch_filename (const uintptr_t binding); + + const uintptr_t evma_watch_pid (int); + void evma_unwatch_pid (const uintptr_t binding); + + void evma_start_proxy(const uintptr_t from, const uintptr_t to, const unsigned long bufsize, const unsigned long length); + void evma_stop_proxy(const uintptr_t from); + unsigned long evma_proxied_bytes(const uintptr_t from); + + int evma_set_rlimit_nofile (int n_files); + + void evma_set_epoll (int use); + void evma_set_kqueue (int use); + + uint64_t evma_get_current_loop_time(); +#if __cplusplus +} +#endif + + +#endif // __EventMachine__H_ + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/extconf.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/extconf.rb new file mode 100644 index 0000000..676b4c4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/extconf.rb @@ -0,0 +1,270 @@ +require 'fileutils' +require 'mkmf' + +# Eager check devs tools +have_devel? if respond_to?(:have_devel?) + +def check_libs libs = [], fatal = false + libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) } +end + +def check_heads heads = [], fatal = false + heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)} +end + +def add_define(name) + $defs.push("-D#{name}") +end + +## +# OpenSSL: + +# override append_library, so it actually appends (instead of prepending) +# this fixes issues with linking ssl, since libcrypto depends on symbols in libssl +def append_library(libs, lib) + libs + " " + format(LIBARG, lib) +end + +SSL_HEADS = %w(openssl/ssl.h openssl/err.h) +SSL_LIBS = %w(crypto ssl) +# OpenSSL 1.1.0 and above for Windows use the Unix library names +# OpenSSL 0.9.8 and 1.0.x for Windows use the *eay32 library names +SSL_LIBS_WIN = RUBY_PLATFORM =~ /mswin|mingw|bccwin/ ? %w(ssleay32 libeay32) : [] + +def dir_config_wrapper(pretty_name, name, idefault=nil, ldefault=nil) + inc, lib = dir_config(name, idefault, ldefault) + if inc && lib + # TODO: Remove when 2.0.0 is the minimum supported version + # Ruby versions not incorporating the mkmf fix at + # https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39717 + # do not properly search for lib directories, and must be corrected + unless lib && lib[-3, 3] == 'lib' + @libdir_basename = 'lib' + inc, lib = dir_config(name, idefault, ldefault) + end + unless idefault && ldefault + abort "-----\nCannot find #{pretty_name} include path #{inc}\n-----" unless inc && inc.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) } + abort "-----\nCannot find #{pretty_name} library path #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) } + warn "-----\nUsing #{pretty_name} in path #{File.dirname inc}\n-----" + end + true + end +end + +def dir_config_search(pretty_name, name, paths, &b) + paths.each do |p| + if dir_config_wrapper('OpenSSL', 'ssl', p + '/include', p + '/lib') && yield + warn "-----\nFound #{pretty_name} in path #{p}\n-----" + return true + end + end + false +end + +def pkg_config_wrapper(pretty_name, name) + cflags, ldflags, libs = pkg_config(name) + unless [cflags, ldflags, libs].any?(&:nil?) || [cflags, ldflags, libs].any?(&:empty?) + warn "-----\nUsing #{pretty_name} from pkg-config #{cflags} && #{ldflags} && #{libs}\n-----" + true + end +end + +if ENV['CROSS_COMPILING'] + openssl_version = ENV.fetch("OPENSSL_VERSION", "1.0.2e") + openssl_dir = File.expand_path("~/.rake-compiler/builds/openssl-#{openssl_version}/") + if File.exist?(openssl_dir) + FileUtils.mkdir_p Dir.pwd+"/openssl/" + FileUtils.cp Dir[openssl_dir+"/include/openssl/*.h"], Dir.pwd+"/openssl/", :verbose => true + FileUtils.cp Dir[openssl_dir+"/lib*.a"], Dir.pwd, :verbose => true + $INCFLAGS << " -I#{Dir.pwd}" # for the openssl headers + add_define "WITH_SSL" + else + STDERR.puts + STDERR.puts "**************************************************************************************" + STDERR.puts "**** Cross-compiled OpenSSL not found" + STDERR.puts "**** Run: hg clone http://bitbucket.org/ged/ruby-pg && cd ruby-pg && rake openssl_libs" + STDERR.puts "**************************************************************************************" + STDERR.puts + end +elsif dir_config_wrapper('OpenSSL', 'ssl') + # If the user has provided a --with-ssl-dir argument, we must respect it or fail. + add_define 'WITH_SSL' if (check_libs(SSL_LIBS) || check_libs(SSL_LIBS_WIN)) && check_heads(SSL_HEADS) +elsif pkg_config_wrapper('OpenSSL', 'openssl') + # If we can detect OpenSSL by pkg-config, use it as the next-best option + add_define 'WITH_SSL' if (check_libs(SSL_LIBS) || check_libs(SSL_LIBS_WIN)) && check_heads(SSL_HEADS) +elsif (check_libs(SSL_LIBS) || check_libs(SSL_LIBS_WIN)) && check_heads(SSL_HEADS) + # If we don't even need any options to find a usable OpenSSL, go with it + add_define 'WITH_SSL' +elsif dir_config_search('OpenSSL', 'ssl', ['/usr/local', '/opt/local', '/usr/local/opt/openssl']) do + (check_libs(SSL_LIBS) || check_libs(SSL_LIBS_WIN)) && check_heads(SSL_HEADS) + end + # Finally, look for OpenSSL in alternate locations including MacPorts and HomeBrew + add_define 'WITH_SSL' +end + +add_define 'BUILD_FOR_RUBY' + +# Ruby features: + +have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h']) +have_func('rb_thread_blocking_region') +have_func('rb_thread_call_without_gvl', 'ruby/thread.h') +have_func('rb_thread_fd_select') +have_type('rb_fdset_t', 'ruby/intern.h') +have_func('rb_wait_for_single_fd') +have_func('rb_enable_interrupt') +have_func('rb_time_new') + +# System features: + +add_define('HAVE_INOTIFY') if inotify = have_func('inotify_init', 'sys/inotify.h') +add_define('HAVE_OLD_INOTIFY') if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h') +have_func('writev', 'sys/uio.h') +have_func('pipe2', 'unistd.h') +have_func('accept4', 'sys/socket.h') +have_const('SOCK_CLOEXEC', 'sys/socket.h') + +# Minor platform details between *nix and Windows: + +if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/ + GNU_CHAIN = ENV['CROSS_COMPILING'] || $1 == 'mingw' + OS_WIN32 = true + add_define "OS_WIN32" +else + GNU_CHAIN = true + OS_UNIX = true + add_define 'OS_UNIX' + + add_define "HAVE_KQUEUE" if have_header("sys/event.h") && have_header("sys/queue.h") +end + +# Adjust number of file descriptors (FD) on Windows + +if RbConfig::CONFIG["host_os"] =~ /mingw/ + found = RbConfig::CONFIG.values_at("CFLAGS", "CPPFLAGS"). + any? { |v| v.include?("FD_SETSIZE") } + + add_define "FD_SETSIZE=32767" unless found +end + +# Main platform invariances: + +case RUBY_PLATFORM +when /mswin32/, /mingw32/, /bccwin32/ + check_heads(%w[windows.h winsock.h], true) + check_libs(%w[kernel32 rpcrt4 gdi32], true) + + if GNU_CHAIN + CONFIG['LDSHAREDXX'] = "$(CXX) -shared -static-libgcc -static-libstdc++" + else + $defs.push "-EHs" + $defs.push "-GR" + end + + # Newer versions of Ruby already define _WIN32_WINNT, which is needed + # to get access to newer POSIX networking functions (e.g. getaddrinfo) + add_define '_WIN32_WINNT=0x0501' unless have_func('getaddrinfo') + +when /solaris/ + add_define 'OS_SOLARIS8' + check_libs(%w[nsl socket], true) + + # If Ruby was compiled for 32-bits, then select() can only handle 1024 fds + # There is an alternate function, select_large_fdset, that supports more. + have_func('select_large_fdset', 'sys/select.h') + + if CONFIG['CC'] == 'cc' && ( + `cc -flags 2>&1` =~ /Sun/ || # detect SUNWspro compiler + `cc -V 2>&1` =~ /Sun/ # detect Solaris Studio compiler + ) + # SUN CHAIN + add_define 'CC_SUNWspro' + $preload = ["\nCXX = CC"] # hack a CXX= line into the makefile + $CFLAGS = CONFIG['CFLAGS'] = "-KPIC" + CONFIG['CCDLFLAGS'] = "-KPIC" + CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd" + CONFIG['LDSHAREDXX'] = "$(CXX) -G -KPIC -lCstd" + else + # GNU CHAIN + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" + end + +when /openbsd/ + # OpenBSD branch contributed by Guillaume Sellier. + + # on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs + CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC" + CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC" + +when /darwin/ + add_define 'OS_DARWIN' + + # on Unix we need a g++ link, not gcc. + # Ff line contributed by Daniel Harple. + CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ') + +when /linux/ + add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h') + + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" + +when /aix/ + CONFIG['LDSHARED'] = "$(CXX) -Wl,-bstatic -Wl,-bdynamic -Wl,-G -Wl,-brtl" + +when /cygwin/ + # For rubies built with Cygwin, CXX may be set to CC, which is just + # a wrapper for gcc. + # This will compile, but it will not link to the C++ std library. + # Explicitly set CXX to use g++. + CONFIG['CXX'] = "g++" + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" + +else + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" +end + +# Platform-specific time functions +if have_func('clock_gettime') + # clock_gettime is POSIX, but the monotonic clocks are not + have_const('CLOCK_MONOTONIC_RAW', 'time.h') # Linux + have_const('CLOCK_MONOTONIC', 'time.h') # Linux, Solaris, BSDs +else + have_func('gethrtime') # Older Solaris and HP-UX +end + +# Hack so that try_link will test with a C++ compiler instead of a C compiler +TRY_LINK.sub!('$(CC)', '$(CXX)') + +# This is our wishlist. We use whichever flags work on the host. +# In the future, add -Werror to make sure all warnings are resolved. +# deprecated-declarations are used in OS X OpenSSL +# ignored-qualifiers are used by the Bindings (would-be void *) +# unused-result because GCC 4.6 no longer silences (void) ignore_this(function) +# address because on Windows, rb_fd_select checks if &fds is non-NULL, which it cannot be +%w( + -Wall + -Wextra + -Wno-deprecated-declarations + -Wno-ignored-qualifiers + -Wno-unused-result + -Wno-address +).select do |flag| + try_link('int main() {return 0;}', flag) +end.each do |flag| + CONFIG['CXXFLAGS'] << ' ' << flag +end +puts "CXXFLAGS=#{CONFIG['CXXFLAGS']}" + +# Solaris C++ compiler doesn't have make_pair() +add_define 'HAVE_MAKE_PAIR' if try_link(< + using namespace std; + int main(){ pair tuple = make_pair(1,2); } +SRC +TRY_LINK.sub!('$(CXX)', '$(CC)') + +create_makefile "rubyeventmachine" diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/Makefile b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/Makefile new file mode 100644 index 0000000..2d077c7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/Makefile @@ -0,0 +1,269 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +V0 = $(V:0=) +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@ :) +ECHO = $(ECHO1:0=@ echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /usr/include/ruby-3.2.0 +hdrdir = $(topdir) +arch_hdrdir = /usr/include/ruby-3.2.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/usr +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(DESTDIR)/usr +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(sitelibdir)/$(sitearch) +sitelibdir = $(sitedir)/$(ruby_version) +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(DESTDIR)/usr/share/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib/x86_64-linux-gnu +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(DESTDIR)/usr/share/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(exec_prefix)/include +runstatedir = $(localstatedir)/run +localstatedir = $(DESTDIR)/var +sharedstatedir = $(DESTDIR)/usr/com +sysconfdir = $(DESTDIR)/etc +datadir = $(DESTDIR)/usr/share +datarootdir = $(prefix)/share +libexecdir = $(DESTDIR)/usr/libexec +sbindir = $(DESTDIR)/usr/bin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC_WRAPPER = +CC = x86_64-unknown-linux-gnu-gcc +CXX = x86_64-unknown-linux-gnu-g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static $(MAINLIBS) +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) +CSRCFLAG = $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = +optflags = -O3 -fno-fast-math +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef +cppflags = +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -DBUILD_FOR_RUBY -DOS_UNIX $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer $(ARCH_FLAG) +ldflags = -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed +dldflags = -Wl,-z,relro,-z,now -Wl,--as-needed +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CXX) -shared +LDSHAREDXX = $(CXX) -shared +AR = x86_64-unknown-linux-gnu-gcc-ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 3.2.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = rm -fr +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lm -lpthread -lc +ORIG_SRCS = mapper.cpp rubymain.cpp +SRCS = $(ORIG_SRCS) +OBJS = mapper.o rubymain.o +HDRS = $(srcdir)/mapper.h +LOCAL_HDRS = +TARGET = fastfilereaderext +TARGET_NAME = fastfilereaderext +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = $(TARGET).so +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(sitehdrdir)$(target_prefix) +ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix) +TARGET_SO_DIR = +TARGET_SO = $(TARGET_SO_DIR)$(DLLIB) +CLEANLIBS = $(TARGET_SO) false +CLEANOBJS = $(OBJS) *.bak +TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time + +all: $(DLLIB) +static: $(STATIC_LIB) +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP) + $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) +clean-static:: + -$(Q)$(RM) $(STATIC_LIB) +install-rb: pre-install-rb do-install-rb install-rb-default +install-rb-default: pre-install-rb-default do-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +do-install-rb: +do-install-rb-default: +pre-install-rb-default: + @$(NULLCMD) +$(TARGET_SO_DIR_TIMESTAMP): + $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) + $(Q) $(TOUCH) $@ + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + +.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S + +.cc.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cc.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.mm.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.mm.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cxx.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cxx.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cpp.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cpp.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.c.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.c.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.m.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.m.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +$(TARGET_SO): $(OBJS) Makefile + $(ECHO) linking shared-object $(DLLIB) + -$(Q)$(RM) $(@) + $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) + + + +$(OBJS): $(HDRS) $(ruby_headers) diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/extconf.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/extconf.rb new file mode 100644 index 0000000..e4d64e4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/extconf.rb @@ -0,0 +1,109 @@ +require 'mkmf' + +def check_libs libs = [], fatal = false + libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) } +end + +def check_heads heads = [], fatal = false + heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)} +end + +def add_define(name) + $defs.push("-D#{name}") +end + +# Eager check devs tools +have_devel? if respond_to?(:have_devel?) + +add_define 'BUILD_FOR_RUBY' + +# Minor platform details between *nix and Windows: + +if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/ + GNU_CHAIN = ENV['CROSS_COMPILING'] || $1 == 'mingw' + OS_WIN32 = true + add_define "OS_WIN32" +else + GNU_CHAIN = true + OS_UNIX = true + add_define 'OS_UNIX' +end + +# Adjust number of file descriptors (FD) on Windows + +if RbConfig::CONFIG["host_os"] =~ /mingw/ + found = RbConfig::CONFIG.values_at("CFLAGS", "CPPFLAGS"). + any? { |v| v.include?("FD_SETSIZE") } + + add_define "FD_SETSIZE=32767" unless found +end + +# Main platform invariances: + +case RUBY_PLATFORM +when /mswin32/, /mingw32/, /bccwin32/ + check_heads(%w[windows.h winsock.h], true) + check_libs(%w[kernel32 rpcrt4 gdi32], true) + + if GNU_CHAIN + CONFIG['LDSHAREDXX'] = "$(CXX) -shared -static-libgcc -static-libstdc++" + else + $defs.push "-EHs" + $defs.push "-GR" + end + +when /solaris/ + add_define 'OS_SOLARIS8' + check_libs(%w[nsl socket], true) + + if CONFIG['CC'] == 'cc' && ( + `cc -flags 2>&1` =~ /Sun/ || # detect SUNWspro compiler + `cc -V 2>&1` =~ /Sun/ # detect Solaris Studio compiler + ) + # SUN CHAIN + add_define 'CC_SUNWspro' + $preload = ["\nCXX = CC"] # hack a CXX= line into the makefile + $CFLAGS = CONFIG['CFLAGS'] = "-KPIC" + CONFIG['CCDLFLAGS'] = "-KPIC" + CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd" + CONFIG['LDSHAREDXX'] = "$(CXX) -G -KPIC -lCstd" + else + # GNU CHAIN + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" + end + +when /openbsd/ + # OpenBSD branch contributed by Guillaume Sellier. + + # on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs + CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC" + CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC" + +when /darwin/ + # on Unix we need a g++ link, not gcc. + # Ff line contributed by Daniel Harple. + CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ') + +when /linux/ + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" + +when /aix/ + CONFIG['LDSHARED'] = "$(CXX) -Wl,-bstatic -Wl,-bdynamic -Wl,-G -Wl,-brtl" + +when /cygwin/ + # For rubies built with Cygwin, CXX may be set to CC, which is just + # a wrapper for gcc. + # This will compile, but it will not link to the C++ std library. + # Explicitly set CXX to use g++. + CONFIG['CXX'] = "g++" + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" + +else + # on Unix we need a g++ link, not gcc. + CONFIG['LDSHARED'] = "$(CXX) -shared" +end + +create_makefile "fastfilereaderext" diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/mapper.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/mapper.cpp new file mode 100644 index 0000000..f226f2d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/mapper.cpp @@ -0,0 +1,214 @@ +/***************************************************************************** + +$Id: mapper.cpp 4527 2007-07-04 10:21:34Z francis $ + +File: mapper.cpp +Date: 02Jul07 + +Copyright (C) 2007 by Francis Cianfrocca. All Rights Reserved. +Gmail: garbagecat10 + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + +////////////////////////////////////////////////////////////////////// +// UNIX implementation +////////////////////////////////////////////////////////////////////// + + +#ifdef OS_UNIX + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "mapper.h" + +/****************** +Mapper_t::Mapper_t +******************/ + +Mapper_t::Mapper_t (const std::string &filename) +{ + /* We ASSUME we can open the file. + * (More precisely, we assume someone else checked before we got here.) + */ + + Fd = open (filename.c_str(), O_RDONLY); + if (Fd < 0) + throw std::runtime_error (strerror (errno)); + + struct stat st; + if (fstat (Fd, &st)) + throw std::runtime_error (strerror (errno)); + FileSize = st.st_size; + + #ifdef OS_WIN32 + MapPoint = (char*) mmap (0, FileSize, PROT_READ, MAP_SHARED, Fd, 0); + #else + MapPoint = (const char*) mmap (0, FileSize, PROT_READ, MAP_SHARED, Fd, 0); + #endif + if (MapPoint == MAP_FAILED) + throw std::runtime_error (strerror (errno)); +} + + +/******************* +Mapper_t::~Mapper_t +*******************/ + +Mapper_t::~Mapper_t() +{ + Close(); +} + + +/*************** +Mapper_t::Close +***************/ + +void Mapper_t::Close() +{ + // Can be called multiple times. + // Calls to GetChunk are invalid after a call to Close. + if (MapPoint) { + #ifdef CC_SUNWspro + // TODO: The void * cast works fine on Solaris 11, but + // I don't know at what point that changed from older Solaris. + munmap ((char*)MapPoint, FileSize); + #else + munmap ((void*)MapPoint, FileSize); + #endif + MapPoint = NULL; + } + if (Fd >= 0) { + close (Fd); + Fd = -1; + } +} + +/****************** +Mapper_t::GetChunk +******************/ + +const char *Mapper_t::GetChunk (unsigned start) +{ + return MapPoint + start; +} + + + +#endif // OS_UNIX + + +////////////////////////////////////////////////////////////////////// +// WINDOWS implementation +////////////////////////////////////////////////////////////////////// + +#ifdef OS_WIN32 + +#include + +#include +#include +#include + +#include "mapper.h" + +/****************** +Mapper_t::Mapper_t +******************/ + +Mapper_t::Mapper_t (const std::string &filename) +{ + /* We ASSUME we can open the file. + * (More precisely, we assume someone else checked before we got here.) + */ + + hFile = INVALID_HANDLE_VALUE; + hMapping = NULL; + MapPoint = NULL; + FileSize = 0; + + hFile = CreateFile (filename.c_str(), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hFile == INVALID_HANDLE_VALUE) + throw std::runtime_error ("File not found"); + + BY_HANDLE_FILE_INFORMATION i; + if (GetFileInformationByHandle (hFile, &i)) + FileSize = i.nFileSizeLow; + + hMapping = CreateFileMapping (hFile, NULL, PAGE_READWRITE, 0, 0, NULL); + if (!hMapping) + throw std::runtime_error ("File not mapped"); + + #ifdef OS_WIN32 + MapPoint = (char*) MapViewOfFile (hMapping, FILE_MAP_WRITE, 0, 0, 0); + #else + MapPoint = (const char*) MapViewOfFile (hMapping, FILE_MAP_WRITE, 0, 0, 0); + #endif + if (!MapPoint) + throw std::runtime_error ("Mappoint not read"); +} + + +/******************* +Mapper_t::~Mapper_t +*******************/ + +Mapper_t::~Mapper_t() +{ + Close(); +} + +/*************** +Mapper_t::Close +***************/ + +void Mapper_t::Close() +{ + // Can be called multiple times. + // Calls to GetChunk are invalid after a call to Close. + if (MapPoint) { + UnmapViewOfFile (MapPoint); + MapPoint = NULL; + } + if (hMapping != NULL) { + CloseHandle (hMapping); + hMapping = NULL; + } + if (hFile != INVALID_HANDLE_VALUE) { + CloseHandle (hFile); + hFile = INVALID_HANDLE_VALUE; + } +} + + +/****************** +Mapper_t::GetChunk +******************/ + +const char *Mapper_t::GetChunk (unsigned start) +{ + return MapPoint + start; +} + + + +#endif // OS_WINDOWS diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/mapper.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/mapper.h new file mode 100644 index 0000000..3db0eea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/mapper.h @@ -0,0 +1,59 @@ +/***************************************************************************** + +$Id: mapper.h 4529 2007-07-04 11:32:22Z francis $ + +File: mapper.h +Date: 02Jul07 + +Copyright (C) 2007 by Francis Cianfrocca. All Rights Reserved. +Gmail: garbagecat10 + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + +#ifndef __Mapper__H_ +#define __Mapper__H_ + + +/************** +class Mapper_t +**************/ + +class Mapper_t +{ + public: + Mapper_t (const std::string&); + virtual ~Mapper_t(); + + const char *GetChunk (unsigned); + void Close(); + size_t GetFileSize() {return FileSize;} + + private: + size_t FileSize; + + #ifdef OS_UNIX + private: + int Fd; + const char *MapPoint; + #endif // OS_UNIX + + #ifdef OS_WIN32 + private: + HANDLE hFile; + HANDLE hMapping; + char *MapPoint; + #endif // OS_WIN32 + +}; + + +#endif // __Mapper__H_ + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/rubymain.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/rubymain.cpp new file mode 100644 index 0000000..b962bf0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/fastfilereader/rubymain.cpp @@ -0,0 +1,126 @@ +/***************************************************************************** + +$Id: rubymain.cpp 4529 2007-07-04 11:32:22Z francis $ + +File: rubymain.cpp +Date: 02Jul07 + +Copyright (C) 2007 by Francis Cianfrocca. All Rights Reserved. +Gmail: garbagecat10 + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + + +#include +#include + +#include +#include "mapper.h" + +static VALUE EmModule; +static VALUE FastFileReader; +static VALUE Mapper; + + + +/********* +mapper_dt +*********/ + +static void mapper_dt (void *ptr) +{ + if (ptr) + delete (Mapper_t*) ptr; +} + +/********** +mapper_new +**********/ + +static VALUE mapper_new (VALUE self, VALUE filename) +{ + Mapper_t *m = new Mapper_t (StringValueCStr (filename)); + if (!m) + rb_raise (rb_eStandardError, "No Mapper Object"); + VALUE v = Data_Wrap_Struct (Mapper, 0, mapper_dt, (void*)m); + return v; +} + + +/**************** +mapper_get_chunk +****************/ + +static VALUE mapper_get_chunk (VALUE self, VALUE start, VALUE length) +{ + Mapper_t *m = NULL; + Data_Get_Struct (self, Mapper_t, m); + if (!m) + rb_raise (rb_eStandardError, "No Mapper Object"); + + // TODO, what if some moron sends us a negative start value? + unsigned _start = NUM2INT (start); + unsigned _length = NUM2INT (length); + if ((_start + _length) > m->GetFileSize()) + rb_raise (rb_eStandardError, "Mapper Range Error"); + + const char *chunk = m->GetChunk (_start); + if (!chunk) + rb_raise (rb_eStandardError, "No Mapper Chunk"); + return rb_str_new (chunk, _length); +} + +/************ +mapper_close +************/ + +static VALUE mapper_close (VALUE self) +{ + Mapper_t *m = NULL; + Data_Get_Struct (self, Mapper_t, m); + if (!m) + rb_raise (rb_eStandardError, "No Mapper Object"); + m->Close(); + return Qnil; +} + +/*********** +mapper_size +***********/ + +static VALUE mapper_size (VALUE self) +{ + Mapper_t *m = NULL; + Data_Get_Struct (self, Mapper_t, m); + if (!m) + rb_raise (rb_eStandardError, "No Mapper Object"); + return INT2NUM (m->GetFileSize()); +} + + +/********************** +Init_fastfilereaderext +**********************/ + +extern "C" void Init_fastfilereaderext() +{ + EmModule = rb_define_module ("EventMachine"); + FastFileReader = rb_define_class_under (EmModule, "FastFileReader", rb_cObject); + Mapper = rb_define_class_under (FastFileReader, "Mapper", rb_cObject); + + rb_define_module_function (Mapper, "new", (VALUE(*)(...))mapper_new, 1); + rb_define_method (Mapper, "size", (VALUE(*)(...))mapper_size, 0); + rb_define_method (Mapper, "close", (VALUE(*)(...))mapper_close, 0); + rb_define_method (Mapper, "get_chunk", (VALUE(*)(...))mapper_get_chunk, 2); +} + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/kb.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/kb.cpp new file mode 100644 index 0000000..2187ae2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/kb.cpp @@ -0,0 +1,79 @@ +/***************************************************************************** + +$Id$ + +File: kb.cpp +Date: 24Aug07 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#include "project.h" + + +/************************************** +KeyboardDescriptor::KeyboardDescriptor +**************************************/ + +KeyboardDescriptor::KeyboardDescriptor (EventMachine_t *parent_em): + EventableDescriptor (0, parent_em), + bReadAttemptedAfterClose (false) +{ + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + #endif + #ifdef HAVE_KQUEUE + MyEventMachine->ArmKqueueReader (this); + #endif +} + + +/*************************************** +KeyboardDescriptor::~KeyboardDescriptor +***************************************/ + +KeyboardDescriptor::~KeyboardDescriptor() +{ +} + + +/************************* +KeyboardDescriptor::Write +*************************/ + +void KeyboardDescriptor::Write() +{ + // Why are we here? + throw std::runtime_error ("bad code path in keyboard handler"); +} + + +/***************************** +KeyboardDescriptor::Heartbeat +*****************************/ + +void KeyboardDescriptor::Heartbeat() +{ + // no-op +} + + +/************************ +KeyboardDescriptor::Read +************************/ + +void KeyboardDescriptor::Read() +{ + char c; + (void)read (GetSocket(), &c, 1); + _GenericInboundDispatch(&c, 1); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/page.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/page.cpp new file mode 100644 index 0000000..a3a2340 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/page.cpp @@ -0,0 +1,107 @@ +/***************************************************************************** + +$Id$ + +File: page.cpp +Date: 30Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + +#include "project.h" + + +/****************** +PageList::PageList +******************/ + +PageList::PageList() +{ +} + + +/******************* +PageList::~PageList +*******************/ + +PageList::~PageList() +{ + while (HasPages()) + PopFront(); +} + + +/*************** +PageList::Front +***************/ + +void PageList::Front (const char **page, int *length) +{ + assert (page && length); + + if (HasPages()) { + Page p = Pages.front(); + *page = p.Buffer; + *length = p.Size; + } + else { + *page = NULL; + *length = 0; + } +} + + +/****************** +PageList::PopFront +******************/ + +void PageList::PopFront() +{ + if (HasPages()) { + Page p = Pages.front(); + Pages.pop_front(); + if (p.Buffer) + free ((void*)p.Buffer); + } +} + + +/****************** +PageList::HasPages +******************/ + +bool PageList::HasPages() +{ + return (Pages.size() > 0) ? true : false; +} + + +/************** +PageList::Push +**************/ + +void PageList::Push (const char *buf, int size) +{ + if (buf && (size > 0)) { + char *copy = (char*) malloc (size); + if (!copy) + throw std::runtime_error ("no memory in pagelist"); + memcpy (copy, buf, size); + Pages.push_back (Page (copy, size)); + } +} + + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/page.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/page.h new file mode 100644 index 0000000..969fc91 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/page.h @@ -0,0 +1,51 @@ +/***************************************************************************** + +$Id$ + +File: page.h +Date: 30Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + +#ifndef __PageManager__H_ +#define __PageManager__H_ + + +/************** +class PageList +**************/ + +class PageList +{ + struct Page { + Page (const char *b, size_t s): Buffer(b), Size(s) {} + const char *Buffer; + size_t Size; + }; + + public: + PageList(); + virtual ~PageList(); + + void Push (const char*, int); + bool HasPages(); + void Front (const char**, int*); + void PopFront(); + + private: + std::deque Pages; +}; + + +#endif // __PageManager__H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/pipe.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/pipe.cpp new file mode 100644 index 0000000..a5f0d9f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/pipe.cpp @@ -0,0 +1,354 @@ +/***************************************************************************** + +$Id$ + +File: pipe.cpp +Date: 30May07 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#include "project.h" + + +#ifdef OS_UNIX +// THIS ENTIRE FILE IS ONLY COMPILED ON UNIX-LIKE SYSTEMS. + +/****************************** +PipeDescriptor::PipeDescriptor +******************************/ + +PipeDescriptor::PipeDescriptor (int fd, pid_t subpid, EventMachine_t *parent_em): + EventableDescriptor (fd, parent_em), + bReadAttemptedAfterClose (false), + OutboundDataSize (0), + SubprocessPid (subpid) +{ + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + #endif + #ifdef HAVE_KQUEUE + MyEventMachine->ArmKqueueReader (this); + #endif +} + + +/******************************* +PipeDescriptor::~PipeDescriptor +*******************************/ + +PipeDescriptor::~PipeDescriptor() NO_EXCEPT_FALSE +{ + // Run down any stranded outbound data. + for (size_t i=0; i < OutboundPages.size(); i++) + OutboundPages[i].Free(); + + /* As a virtual destructor, we come here before the base-class + * destructor that closes our file-descriptor. + * We have to make sure the subprocess goes down (if it's not + * already down) and we have to reap the zombie. + * + * This implementation is PROVISIONAL and will surely be improved. + * The intention here is that we never block, hence the highly + * undesirable sleeps. But if we can't reap the subprocess even + * after sending it SIGKILL, then something is wrong and we + * throw a fatal exception, which is also not something we should + * be doing. + * + * Eventually the right thing to do will be to have the reactor + * core respond to SIGCHLD by chaining a handler on top of the + * one Ruby may have installed, and dealing with a list of dead + * children that are pending cleanup. + * + * Since we want to have a signal processor integrated into the + * client-visible API, let's wait until that is done before cleaning + * this up. + * + * Added a very ugly hack to support passing the subprocess's exit + * status to the user. It only makes logical sense for user code to access + * the subprocess exit status in the unbind callback. But unbind is called + * back during the EventableDescriptor destructor. So by that time there's + * no way to call back this object through an object binding, because it's + * already been cleaned up. We might have added a parameter to the unbind + * callback, but that would probably break a huge amount of existing code. + * So the hack-solution is to define an instance variable in the EventMachine + * object and stick the exit status in there, where it can easily be accessed + * with an accessor visible to user code. + * User code should ONLY access the exit status from within the unbind callback. + * Otherwise there's no guarantee it'll be valid. + * This hack won't make it impossible to run multiple EventMachines in a single + * process, but it will make it impossible to reliably nest unbind calls + * within other unbind calls. (Not sure if that's even possible.) + */ + + assert (MyEventMachine); + + /* Another hack to make the SubprocessPid available to get_subprocess_status */ + MyEventMachine->SubprocessPid = SubprocessPid; + + /* 01Mar09: Updated to use a small nanosleep in a loop. When nanosleep is interrupted by SIGCHLD, + * it resumes the system call after processing the signal (resulting in unnecessary latency). + * Calling nanosleep in a loop avoids this problem. + */ + struct timespec req = {0, 50000000}; // 0.05s + int n; + + // wait 0.5s for the process to die + for (n=0; n<10; n++) { + if (waitpid (SubprocessPid, &(MyEventMachine->SubprocessExitStatus), WNOHANG) != 0) return; + nanosleep (&req, NULL); + } + + // send SIGTERM and wait another 1s + kill (SubprocessPid, SIGTERM); + for (n=0; n<20; n++) { + nanosleep (&req, NULL); + if (waitpid (SubprocessPid, &(MyEventMachine->SubprocessExitStatus), WNOHANG) != 0) return; + } + + // send SIGKILL and wait another 5s + kill (SubprocessPid, SIGKILL); + for (n=0; n<100; n++) { + nanosleep (&req, NULL); + if (waitpid (SubprocessPid, &(MyEventMachine->SubprocessExitStatus), WNOHANG) != 0) return; + } + + // still not dead, give up! + throw std::runtime_error ("unable to reap subprocess"); +} + + + +/******************** +PipeDescriptor::Read +********************/ + +void PipeDescriptor::Read() +{ + int sd = GetSocket(); + if (sd == INVALID_SOCKET) { + assert (!bReadAttemptedAfterClose); + bReadAttemptedAfterClose = true; + return; + } + + LastActivity = MyEventMachine->GetCurrentLoopTime(); + + int total_bytes_read = 0; + char readbuffer [16 * 1024]; + + for (int i=0; i < 10; i++) { + // Don't read just one buffer and then move on. This is faster + // if there is a lot of incoming. + // But don't read indefinitely. Give other sockets a chance to run. + // NOTICE, we're reading one less than the buffer size. + // That's so we can put a guard byte at the end of what we send + // to user code. + // Use read instead of recv, which on Linux gives a "socket operation + // on nonsocket" error. + + + int r = read (sd, readbuffer, sizeof(readbuffer) - 1); + //cerr << ""; + + if (r > 0) { + total_bytes_read += r; + + // Add a null-terminator at the the end of the buffer + // that we will send to the callback. + // DO NOT EVER CHANGE THIS. We want to explicitly allow users + // to be able to depend on this behavior, so they will have + // the option to do some things faster. Additionally it's + // a security guard against buffer overflows. + readbuffer [r] = 0; + _GenericInboundDispatch(readbuffer, r); + } + else if (r == 0) { + break; + } + else { + // Basically a would-block, meaning we've read everything there is to read. + break; + } + + } + + + if (total_bytes_read == 0) { + // If we read no data on a socket that selected readable, + // it generally means the other end closed the connection gracefully. + ScheduleClose (false); + //bCloseNow = true; + } + +} + +/********************* +PipeDescriptor::Write +*********************/ + +void PipeDescriptor::Write() +{ + int sd = GetSocket(); + assert (sd != INVALID_SOCKET); + + LastActivity = MyEventMachine->GetCurrentLoopTime(); + char output_buffer [16 * 1024]; + size_t nbytes = 0; + + while ((OutboundPages.size() > 0) && (nbytes < sizeof(output_buffer))) { + OutboundPage *op = &(OutboundPages[0]); + if ((nbytes + op->Length - op->Offset) < sizeof (output_buffer)) { + memcpy (output_buffer + nbytes, op->Buffer + op->Offset, op->Length - op->Offset); + nbytes += (op->Length - op->Offset); + op->Free(); + OutboundPages.pop_front(); + } + else { + int len = sizeof(output_buffer) - nbytes; + memcpy (output_buffer + nbytes, op->Buffer + op->Offset, len); + op->Offset += len; + nbytes += len; + } + } + + // We should never have gotten here if there were no data to write, + // so assert that as a sanity check. + // Don't bother to make sure nbytes is less than output_buffer because + // if it were we probably would have crashed already. + assert (nbytes > 0); + + assert (GetSocket() != INVALID_SOCKET); + int bytes_written = write (GetSocket(), output_buffer, nbytes); +#ifdef OS_WIN32 + int e = WSAGetLastError(); +#else + int e = errno; +#endif + + if (bytes_written > 0) { + OutboundDataSize -= bytes_written; + if ((size_t)bytes_written < nbytes) { + int len = nbytes - bytes_written; + char *buffer = (char*) malloc (len + 1); + if (!buffer) + throw std::runtime_error ("bad alloc throwing back data"); + memcpy (buffer, output_buffer + bytes_written, len); + buffer [len] = 0; + OutboundPages.push_front (OutboundPage (buffer, len)); + } + #ifdef HAVE_EPOLL + EpollEvent.events = EPOLLIN; + if (SelectForWrite()) + EpollEvent.events |= EPOLLOUT; + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif + } + else { + #ifdef OS_UNIX + if ((e != EINPROGRESS) && (e != EWOULDBLOCK) && (e != EINTR)) + #endif + #ifdef OS_WIN32 + if ((e != WSAEINPROGRESS) && (e != WSAEWOULDBLOCK)) + #endif + Close(); + } +} + + +/************************* +PipeDescriptor::Heartbeat +*************************/ + +void PipeDescriptor::Heartbeat() +{ + // If an inactivity timeout is defined, then check for it. + if (InactivityTimeout && ((MyEventMachine->GetCurrentLoopTime() - LastActivity) >= InactivityTimeout)) + ScheduleClose (false); + //bCloseNow = true; +} + + +/***************************** +PipeDescriptor::SelectForRead +*****************************/ + +bool PipeDescriptor::SelectForRead() +{ + /* Pipe descriptors, being local by definition, don't have + * a pending state, so this is simpler than for the + * ConnectionDescriptor object. + */ + return bPaused ? false : true; +} + +/****************************** +PipeDescriptor::SelectForWrite +******************************/ + +bool PipeDescriptor::SelectForWrite() +{ + /* Pipe descriptors, being local by definition, don't have + * a pending state, so this is simpler than for the + * ConnectionDescriptor object. + */ + return (GetOutboundDataSize() > 0) && !bPaused ? true : false; +} + + + + +/******************************** +PipeDescriptor::SendOutboundData +********************************/ + +int PipeDescriptor::SendOutboundData (const char *data, unsigned long length) +{ + //if (bCloseNow || bCloseAfterWriting) + if (IsCloseScheduled()) + return 0; + + if (!data && (length > 0)) + throw std::runtime_error ("bad outbound data"); + char *buffer = (char *) malloc (length + 1); + if (!buffer) + throw std::runtime_error ("no allocation for outbound data"); + memcpy (buffer, data, length); + buffer [length] = 0; + OutboundPages.push_back (OutboundPage (buffer, length)); + OutboundDataSize += length; + #ifdef HAVE_EPOLL + EpollEvent.events = (EPOLLIN | EPOLLOUT); + assert (MyEventMachine); + MyEventMachine->Modify (this); + #endif + return length; +} + +/******************************** +PipeDescriptor::GetSubprocessPid +********************************/ + +bool PipeDescriptor::GetSubprocessPid (pid_t *pid) +{ + bool ok = false; + if (pid && (SubprocessPid > 0)) { + *pid = SubprocessPid; + ok = true; + } + return ok; +} + + +#endif // OS_UNIX + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/project.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/project.h new file mode 100644 index 0000000..757f701 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/project.h @@ -0,0 +1,174 @@ +/***************************************************************************** + +$Id$ + +File: project.h +Date: 06Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + +#ifndef __Project__H_ +#define __Project__H_ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifdef OS_UNIX +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef int SOCKET; +#define INVALID_SOCKET -1 +#define SOCKET_ERROR -1 +#ifdef OS_SOLARIS8 +#include +#include +#ifndef AF_LOCAL +#define AF_LOCAL AF_UNIX +#endif +// INADDR_NONE is undefined on Solaris < 8. Thanks to Brett Eisenberg and Tim Pease. +#ifndef INADDR_NONE +#define INADDR_NONE ((unsigned long)-1) +#endif +#endif /* OS_SOLARIS8 */ + +#ifdef _AIX +#include +#ifndef AF_LOCAL +#define AF_LOCAL AF_UNIX +#endif +#endif /* _AIX */ + +#ifdef OS_DARWIN +#include +#include +#endif /* OS_DARWIN */ + +#endif /* OS_UNIX */ + +#ifdef OS_WIN32 +// 21Sep09: windows limits select() to 64 sockets by default, we increase it to 1024 here (before including winsock2.h) +// 18Jun12: fd_setsize must be changed in the ruby binary (not in this extension). redefining it also causes segvs, see eventmachine/eventmachine#333 +//#define FD_SETSIZE 1024 + +// WIN32_LEAN_AND_MEAN excludes APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets. +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include +#include +#include + +// Older versions of MinGW in the Ruby Dev Kit do not provide the getaddrinfo hint flags +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0x0400 +#endif + +#ifndef AI_NUMERICSERV +#define AI_NUMERICSERV 0x0008 +#endif + +// Use the Win32 wrapper library that Ruby owns to be able to close sockets with the close() function +#define RUBY_EXPORT +#include +#include +#endif /* OS_WIN32 */ + +#if !defined(_MSC_VER) || _MSC_VER > 1500 +#include +#endif + +#ifdef WITH_SSL +#include +#include +#endif + +#ifdef HAVE_EPOLL +#include +#endif + +#ifdef HAVE_KQUEUE +#include +#include +#endif + +#ifdef HAVE_INOTIFY +#include +#endif + +#ifdef HAVE_OLD_INOTIFY +#include +#include +static inline int inotify_init (void) { return syscall (__NR_inotify_init); } +static inline int inotify_add_watch (int fd, const char *name, __u32 mask) { return syscall (__NR_inotify_add_watch, fd, name, mask); } +static inline int inotify_rm_watch (int fd, __u32 wd) { return syscall (__NR_inotify_rm_watch, fd, wd); } +#define HAVE_INOTIFY 1 +#endif + +#ifdef HAVE_INOTIFY +#define INOTIFY_EVENT_SIZE (sizeof(struct inotify_event)) +#endif + +#ifdef HAVE_WRITEV +#include +#endif + +#if __cplusplus +extern "C" { +#endif + typedef void (*EMCallback)(const unsigned long, int, const char*, const unsigned long); +#if __cplusplus +} +#endif + +#if defined(__GNUC__) && (__GNUC__ >= 3) +#define UNUSED __attribute__ ((unused)) +#else +#define UNUSED +#endif + +#include "binder.h" +#include "em.h" +#include "ed.h" +#include "page.h" +#include "ssl.h" +#include "eventmachine.h" + +#endif // __Project__H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/rubymain.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/rubymain.cpp new file mode 100644 index 0000000..305f9cb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/rubymain.cpp @@ -0,0 +1,1515 @@ +/***************************************************************************** + +$Id$ + +File: rubymain.cpp +Date: 06Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + +#include "project.h" +#include "eventmachine.h" +#include + +#ifndef RFLOAT_VALUE +#define RFLOAT_VALUE(arg) RFLOAT(arg)->value +#endif + +/* Adapted from NUM2BSIG / BSIG2NUM in ext/fiddle/conversions.h, + * we'll call it a BSIG for Binding Signature here. */ +#if SIZEOF_VOIDP == SIZEOF_LONG +# define BSIG2NUM(x) (ULONG2NUM((unsigned long)(x))) +# define NUM2BSIG(x) (NUM2ULONG(x)) +# ifdef OS_WIN32 +# define PRIFBSIG "I32u" +# else +# define PRIFBSIG "lu" +# endif +#else +# define BSIG2NUM(x) (ULL2NUM((unsigned long long)(x))) +# define NUM2BSIG(x) (NUM2ULL(x)) +# ifdef OS_WIN32 +# define PRIFBSIG "I64u" +# else +# define PRIFBSIG "llu" +# endif +#endif + +/******* +Statics +*******/ + +static VALUE EmModule; +static VALUE EmConnection; +static VALUE EmConnsHash; +static VALUE EmTimersHash; + +static VALUE EM_eConnectionError; +static VALUE EM_eUnknownTimerFired; +static VALUE EM_eConnectionNotBound; +static VALUE EM_eUnsupported; +static VALUE EM_eInvalidSignature; + +static VALUE Intern_at_signature; +static VALUE Intern_at_timers; +static VALUE Intern_at_conns; +static VALUE Intern_at_error_handler; +static VALUE Intern_event_callback; +static VALUE Intern_run_deferred_callbacks; +static VALUE Intern_delete; +static VALUE Intern_call; +static VALUE Intern_at; +static VALUE Intern_receive_data; +static VALUE Intern_ssl_handshake_completed; +static VALUE Intern_ssl_verify_peer; +static VALUE Intern_notify_readable; +static VALUE Intern_notify_writable; +static VALUE Intern_proxy_target_unbound; +static VALUE Intern_proxy_completed; +static VALUE Intern_connection_completed; + +static VALUE rb_cProcStatus; + +struct em_event { + uintptr_t signature; + int event; + const char *data_str; + unsigned long data_num; +}; + +static inline VALUE ensure_conn(const uintptr_t signature) +{ + VALUE conn = rb_hash_aref (EmConnsHash, BSIG2NUM (signature)); + if (conn == Qnil) + rb_raise (EM_eConnectionNotBound, "unknown connection: %" PRIFBSIG, signature); + return conn; +} + + +/**************** +t_event_callback +****************/ + +static inline void event_callback (struct em_event* e) +{ + const uintptr_t signature = e->signature; + int event = e->event; + const char *data_str = e->data_str; + const unsigned long data_num = e->data_num; + + switch (event) { + case EM_CONNECTION_READ: + { + VALUE conn = rb_hash_aref (EmConnsHash, BSIG2NUM (signature)); + if (conn == Qnil) + rb_raise (EM_eConnectionNotBound, "received %lu bytes of data for unknown signature: %" PRIFBSIG, data_num, signature); + rb_funcall (conn, Intern_receive_data, 1, rb_str_new (data_str, data_num)); + return; + } + case EM_CONNECTION_ACCEPTED: + { + rb_funcall (EmModule, Intern_event_callback, 3, BSIG2NUM(signature), INT2FIX(event), ULONG2NUM(data_num)); + return; + } + case EM_CONNECTION_UNBOUND: + { + rb_funcall (EmModule, Intern_event_callback, 3, BSIG2NUM(signature), INT2FIX(event), ULONG2NUM(data_num)); + return; + } + case EM_CONNECTION_COMPLETED: + { + VALUE conn = ensure_conn(signature); + rb_funcall (conn, Intern_connection_completed, 0); + return; + } + case EM_CONNECTION_NOTIFY_READABLE: + { + VALUE conn = ensure_conn(signature); + rb_funcall (conn, Intern_notify_readable, 0); + return; + } + case EM_CONNECTION_NOTIFY_WRITABLE: + { + VALUE conn = ensure_conn(signature); + rb_funcall (conn, Intern_notify_writable, 0); + return; + } + case EM_LOOPBREAK_SIGNAL: + { + rb_funcall (EmModule, Intern_run_deferred_callbacks, 0); + return; + } + case EM_TIMER_FIRED: + { + VALUE timer = rb_funcall (EmTimersHash, Intern_delete, 1, ULONG2NUM (data_num)); + if (timer == Qnil) { + rb_raise (EM_eUnknownTimerFired, "no such timer: %lu", data_num); + } else if (timer == Qfalse) { + /* Timer Canceled */ + } else { + rb_funcall (timer, Intern_call, 0); + } + return; + } + #ifdef WITH_SSL + case EM_SSL_HANDSHAKE_COMPLETED: + { + VALUE conn = ensure_conn(signature); + rb_funcall (conn, Intern_ssl_handshake_completed, 0); + return; + } + case EM_SSL_VERIFY: + { + VALUE conn = ensure_conn(signature); + VALUE should_accept = rb_funcall (conn, Intern_ssl_verify_peer, 1, rb_str_new(data_str, data_num)); + if (RTEST(should_accept)) + evma_accept_ssl_peer (signature); + return; + } + #endif + case EM_PROXY_TARGET_UNBOUND: + { + VALUE conn = ensure_conn(signature); + rb_funcall (conn, Intern_proxy_target_unbound, 0); + return; + } + case EM_PROXY_COMPLETED: + { + VALUE conn = ensure_conn(signature); + rb_funcall (conn, Intern_proxy_completed, 0); + return; + } + } +} + +/******************* +event_error_handler +*******************/ + +static void event_error_handler(VALUE self UNUSED, VALUE err) +{ + VALUE error_handler = rb_ivar_get(EmModule, Intern_at_error_handler); + rb_funcall (error_handler, Intern_call, 1, err); +} + +/********************** +event_callback_wrapper +**********************/ + +static void event_callback_wrapper (const uintptr_t signature, int event, const char *data_str, const unsigned long data_num) +{ + struct em_event e; + e.signature = signature; + e.event = event; + e.data_str = data_str; + e.data_num = data_num; + + if (!rb_ivar_defined(EmModule, Intern_at_error_handler)) + event_callback(&e); + else + rb_rescue((VALUE (*)(ANYARGS))event_callback, (VALUE)&e, (VALUE (*)(ANYARGS))event_error_handler, Qnil); +} + +/************************** +t_initialize_event_machine +**************************/ + +static VALUE t_initialize_event_machine (VALUE self UNUSED) +{ + EmConnsHash = rb_ivar_get (EmModule, Intern_at_conns); + EmTimersHash = rb_ivar_get (EmModule, Intern_at_timers); + assert(EmConnsHash != Qnil); + assert(EmTimersHash != Qnil); + evma_initialize_library ((EMCallback)event_callback_wrapper); + return Qnil; +} + + +/****************** +t_run_machine_once +******************/ + +static VALUE t_run_machine_once (VALUE self UNUSED) +{ + return evma_run_machine_once () ? Qtrue : Qfalse; +} + + +/************* +t_run_machine +*************/ + +static VALUE t_run_machine (VALUE self UNUSED) +{ + evma_run_machine(); + return Qnil; +} + + +/******************* +t_add_oneshot_timer +*******************/ + +static VALUE t_add_oneshot_timer (VALUE self UNUSED, VALUE interval) +{ + const uintptr_t f = evma_install_oneshot_timer (FIX2LONG (interval)); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "ran out of timers; use #set_max_timers to increase limit"); + return BSIG2NUM (f); +} + + +/************** +t_start_server +**************/ + +static VALUE t_start_server (VALUE self UNUSED, VALUE server, VALUE port) +{ + const uintptr_t f = evma_create_tcp_server (StringValueCStr(server), FIX2INT(port)); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "no acceptor (port is in use or requires root privileges)"); + return BSIG2NUM (f); +} + +/************* +t_stop_server +*************/ + +static VALUE t_stop_server (VALUE self UNUSED, VALUE signature) +{ + evma_stop_tcp_server (NUM2BSIG (signature)); + return Qnil; +} + + +/******************* +t_start_unix_server +*******************/ + +static VALUE t_start_unix_server (VALUE self UNUSED, VALUE filename) +{ + const uintptr_t f = evma_create_unix_domain_server (StringValueCStr(filename)); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "no unix-domain acceptor"); + return BSIG2NUM (f); +} + +/******************** +t_attach_sd +********************/ + +static VALUE t_attach_sd(VALUE self UNUSED, VALUE sd) +{ + const uintptr_t f = evma_attach_sd(FIX2INT(sd)); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "no socket descriptor acceptor"); + return BSIG2NUM (f); +} + + +/*********** +t_send_data +***********/ + +static VALUE t_send_data (VALUE self UNUSED, VALUE signature, VALUE data, VALUE data_length) +{ + int b = evma_send_data_to_connection (NUM2BSIG (signature), StringValuePtr (data), FIX2INT (data_length)); + return INT2NUM (b); +} + + +/*********** +t_start_tls +***********/ + +static VALUE t_start_tls (VALUE self UNUSED, VALUE signature) +{ + evma_start_tls (NUM2BSIG (signature)); + return Qnil; +} + +/*************** +t_set_tls_parms +***************/ + +static VALUE t_set_tls_parms (VALUE self UNUSED, VALUE signature, VALUE privkeyfile, VALUE certchainfile, VALUE verify_peer, VALUE fail_if_no_peer_cert, VALUE snihostname, VALUE cipherlist, VALUE ecdh_curve, VALUE dhparam, VALUE ssl_version) +{ + /* set_tls_parms takes a series of positional arguments for specifying such things + * as private keys and certificate chains. + * It's expected that the parameter list will grow as we add more supported features. + * ALL of these parameters are optional, and can be specified as empty or NULL strings. + */ + evma_set_tls_parms (NUM2BSIG (signature), StringValueCStr (privkeyfile), StringValueCStr (certchainfile), (verify_peer == Qtrue ? 1 : 0), (fail_if_no_peer_cert == Qtrue ? 1 : 0), StringValueCStr (snihostname), StringValueCStr (cipherlist), StringValueCStr (ecdh_curve), StringValueCStr (dhparam), NUM2INT (ssl_version)); + return Qnil; +} + +/*************** +t_get_peer_cert +***************/ + +#ifdef WITH_SSL +static VALUE t_get_peer_cert (VALUE self UNUSED, VALUE signature) +{ + VALUE ret = Qnil; + + X509 *cert = NULL; + BUF_MEM *buf; + BIO *out; + + cert = evma_get_peer_cert (NUM2BSIG (signature)); + + if (cert != NULL) { + out = BIO_new(BIO_s_mem()); + PEM_write_bio_X509(out, cert); + BIO_get_mem_ptr(out, &buf); + ret = rb_str_new(buf->data, buf->length); + X509_free(cert); + BIO_free(out); + } + + return ret; +} +#else +static VALUE t_get_peer_cert (VALUE self UNUSED, VALUE signature UNUSED) +{ + return Qnil; +} +#endif + +/*************** +t_get_cipher_bits +***************/ + +#ifdef WITH_SSL +static VALUE t_get_cipher_bits (VALUE self UNUSED, VALUE signature) +{ + int bits = evma_get_cipher_bits (NUM2BSIG (signature)); + if (bits == -1) + return Qnil; + return INT2NUM (bits); +} +#else +static VALUE t_get_cipher_bits (VALUE self UNUSED, VALUE signature UNUSED) +{ + return Qnil; +} +#endif + +/*************** +t_get_cipher_name +***************/ + +#ifdef WITH_SSL +static VALUE t_get_cipher_name (VALUE self UNUSED, VALUE signature) +{ + const char *protocol = evma_get_cipher_name (NUM2BSIG (signature)); + if (protocol) + return rb_str_new2 (protocol); + + return Qnil; +} +#else +static VALUE t_get_cipher_name (VALUE self UNUSED, VALUE signature UNUSED) +{ + return Qnil; +} +#endif + +/*************** +t_get_cipher_protocol +***************/ + +#ifdef WITH_SSL +static VALUE t_get_cipher_protocol (VALUE self UNUSED, VALUE signature) +{ + const char *cipher = evma_get_cipher_protocol (NUM2BSIG (signature)); + if (cipher) + return rb_str_new2 (cipher); + + return Qnil; +} +#else +static VALUE t_get_cipher_protocol (VALUE self UNUSED, VALUE signature UNUSED) +{ + return Qnil; +} +#endif + +/*************** +t_get_sni_hostname +***************/ + +#ifdef WITH_SSL +static VALUE t_get_sni_hostname (VALUE self UNUSED, VALUE signature) +{ + const char *sni_hostname = evma_get_sni_hostname (NUM2BSIG (signature)); + if (sni_hostname) + return rb_str_new2 (sni_hostname); + + return Qnil; +} +#else +static VALUE t_get_sni_hostname (VALUE self UNUSED, VALUE signature UNUSED) +{ + return Qnil; +} +#endif + +/************** +t_get_peername +**************/ + +static VALUE t_get_peername (VALUE self UNUSED, VALUE signature) +{ + char buf[1024]; + socklen_t len = sizeof buf; + try { + if (evma_get_peername (NUM2BSIG (signature), (struct sockaddr*)buf, &len)) { + return rb_str_new (buf, len); + } + } catch (std::runtime_error e) { + rb_raise (rb_eRuntimeError, "%s", e.what()); + } + + return Qnil; +} + +/************** +t_get_sockname +**************/ + +static VALUE t_get_sockname (VALUE self UNUSED, VALUE signature) +{ + char buf[1024]; + socklen_t len = sizeof buf; + try { + if (evma_get_sockname (NUM2BSIG (signature), (struct sockaddr*)buf, &len)) { + return rb_str_new (buf, len); + } + } catch (std::runtime_error e) { + rb_raise (rb_eRuntimeError, "%s", e.what()); + } + + return Qnil; +} + +/******************** +t_get_subprocess_pid +********************/ + +static VALUE t_get_subprocess_pid (VALUE self UNUSED, VALUE signature) +{ + pid_t pid; + if (evma_get_subprocess_pid (NUM2BSIG (signature), &pid)) { + return INT2NUM (pid); + } + + return Qnil; +} + +/*********************** +t_get_subprocess_status +***********************/ + +static VALUE t_get_subprocess_status (VALUE self UNUSED, VALUE signature) +{ + VALUE proc_status = Qnil; + + int status; + pid_t pid; + + if (evma_get_subprocess_status (NUM2BSIG (signature), &status)) { + if (evma_get_subprocess_pid (NUM2BSIG (signature), &pid)) { + proc_status = rb_obj_alloc(rb_cProcStatus); + + /* MRI Ruby uses hidden instance vars */ + rb_iv_set(proc_status, "status", INT2FIX(status)); + rb_iv_set(proc_status, "pid", INT2FIX(pid)); + +#ifdef RUBINIUS + /* Rubinius uses standard instance vars */ + rb_iv_set(proc_status, "@pid", INT2FIX(pid)); + if (WIFEXITED(status)) { + rb_iv_set(proc_status, "@status", INT2FIX(WEXITSTATUS(status))); + } else if (WIFSIGNALED(status)) { + rb_iv_set(proc_status, "@termsig", INT2FIX(WTERMSIG(status))); + } else if (WIFSTOPPED(status)) { + rb_iv_set(proc_status, "@stopsig", INT2FIX(WSTOPSIG(status))); + } +#endif + } + } + + return proc_status; +} + +/********************** +t_get_connection_count +**********************/ + +static VALUE t_get_connection_count (VALUE self UNUSED) +{ + return INT2NUM(evma_get_connection_count()); +} + +/***************************** +t_get_comm_inactivity_timeout +*****************************/ + +static VALUE t_get_comm_inactivity_timeout (VALUE self UNUSED, VALUE signature) +{ + return rb_float_new(evma_get_comm_inactivity_timeout(NUM2BSIG (signature))); +} + +/***************************** +t_set_comm_inactivity_timeout +*****************************/ + +static VALUE t_set_comm_inactivity_timeout (VALUE self UNUSED, VALUE signature, VALUE timeout) +{ + float ti = RFLOAT_VALUE(timeout); + if (evma_set_comm_inactivity_timeout(NUM2BSIG(signature), ti)) { + return Qtrue; + } + return Qfalse; +} + +/***************************** +t_get_pending_connect_timeout +*****************************/ + +static VALUE t_get_pending_connect_timeout (VALUE self UNUSED, VALUE signature) +{ + return rb_float_new(evma_get_pending_connect_timeout(NUM2BSIG (signature))); +} + +/***************************** +t_set_pending_connect_timeout +*****************************/ + +static VALUE t_set_pending_connect_timeout (VALUE self UNUSED, VALUE signature, VALUE timeout) +{ + float ti = RFLOAT_VALUE(timeout); + if (evma_set_pending_connect_timeout(NUM2BSIG(signature), ti)) { + return Qtrue; + } + return Qfalse; +} + +/*************** +t_send_datagram +***************/ + +static VALUE t_send_datagram (VALUE self UNUSED, VALUE signature, VALUE data, VALUE data_length, VALUE address, VALUE port) +{ + int b = evma_send_datagram (NUM2BSIG (signature), StringValuePtr (data), FIX2INT (data_length), StringValueCStr(address), FIX2INT(port)); + if (b < 0) + rb_raise (EM_eConnectionError, "%s", "error in sending datagram"); // FIXME: this could be more specific. + return INT2NUM (b); +} + + +/****************** +t_close_connection +******************/ + +static VALUE t_close_connection (VALUE self UNUSED, VALUE signature, VALUE after_writing) +{ + evma_close_connection (NUM2BSIG (signature), ((after_writing == Qtrue) ? 1 : 0)); + return Qnil; +} + +/******************************** +t_report_connection_error_status +********************************/ + +static VALUE t_report_connection_error_status (VALUE self UNUSED, VALUE signature) +{ + int b = evma_report_connection_error_status (NUM2BSIG (signature)); + return INT2NUM (b); +} + + + +/**************** +t_connect_server +****************/ + +static VALUE t_connect_server (VALUE self UNUSED, VALUE server, VALUE port) +{ + // Avoid FIX2INT in this case, because it doesn't deal with type errors properly. + // Specifically, if the value of port comes in as a string rather than an integer, + // NUM2INT will throw a type error, but FIX2INT will generate garbage. + + try { + const uintptr_t f = evma_connect_to_server (NULL, 0, StringValueCStr(server), NUM2INT(port)); + if (!f) + rb_raise (EM_eConnectionError, "%s", "no connection"); + return BSIG2NUM (f); + } catch (std::runtime_error e) { + rb_raise (EM_eConnectionError, "%s", e.what()); + } + return Qnil; +} + +/********************* +t_bind_connect_server +*********************/ + +static VALUE t_bind_connect_server (VALUE self UNUSED, VALUE bind_addr, VALUE bind_port, VALUE server, VALUE port) +{ + // Avoid FIX2INT in this case, because it doesn't deal with type errors properly. + // Specifically, if the value of port comes in as a string rather than an integer, + // NUM2INT will throw a type error, but FIX2INT will generate garbage. + + try { + const uintptr_t f = evma_connect_to_server (StringValueCStr(bind_addr), NUM2INT(bind_port), StringValueCStr(server), NUM2INT(port)); + if (!f) + rb_raise (EM_eConnectionError, "%s", "no connection"); + return BSIG2NUM (f); + } catch (std::runtime_error e) { + rb_raise (EM_eConnectionError, "%s", e.what()); + } + return Qnil; +} + +/********************* +t_connect_unix_server +*********************/ + +static VALUE t_connect_unix_server (VALUE self UNUSED, VALUE serversocket) +{ + const uintptr_t f = evma_connect_to_unix_server (StringValueCStr(serversocket)); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "no connection"); + return BSIG2NUM (f); +} + +/*********** +t_attach_fd +***********/ + +static VALUE t_attach_fd (VALUE self UNUSED, VALUE file_descriptor, VALUE watch_mode) +{ + const uintptr_t f = evma_attach_fd (NUM2INT(file_descriptor), watch_mode == Qtrue); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "no connection"); + return BSIG2NUM (f); +} + +/*********** +t_detach_fd +***********/ + +static VALUE t_detach_fd (VALUE self UNUSED, VALUE signature) +{ + return INT2NUM(evma_detach_fd (NUM2BSIG (signature))); +} + +/********************* +t_get_file_descriptor +*********************/ +static VALUE t_get_file_descriptor (VALUE self UNUSED, VALUE signature) +{ + return INT2NUM(evma_get_file_descriptor (NUM2BSIG (signature))); +} + +/************** +t_get_sock_opt +**************/ + +static VALUE t_get_sock_opt (VALUE self UNUSED, VALUE signature, VALUE lev, VALUE optname) +{ + int fd = evma_get_file_descriptor (NUM2BSIG (signature)); + int level = NUM2INT(lev), option = NUM2INT(optname); + socklen_t len = 128; + char buf[128]; + + if (getsockopt(fd, level, option, buf, &len) < 0) + rb_sys_fail("getsockopt"); + + return rb_str_new(buf, len); +} + +/************** +t_set_sock_opt +**************/ + +static VALUE t_set_sock_opt (VALUE self UNUSED, VALUE signature, VALUE lev, VALUE optname, VALUE optval) +{ + int fd = evma_get_file_descriptor (NUM2BSIG (signature)); + int level = NUM2INT(lev), option = NUM2INT(optname); + int i; + const void *v; + socklen_t len; + + switch (TYPE(optval)) { + case T_FIXNUM: + i = FIX2INT(optval); + goto numval; + case T_FALSE: + i = 0; + goto numval; + case T_TRUE: + i = 1; + numval: + v = (void*)&i; len = sizeof(i); + break; + default: + StringValue(optval); + v = RSTRING_PTR(optval); + len = RSTRING_LENINT(optval); + break; + } + + + if (setsockopt(fd, level, option, (char *)v, len) < 0) + rb_sys_fail("setsockopt"); + + return INT2FIX(0); +} + +/******************** +t_is_notify_readable +********************/ + +static VALUE t_is_notify_readable (VALUE self UNUSED, VALUE signature) +{ + return evma_is_notify_readable(NUM2BSIG (signature)) ? Qtrue : Qfalse; +} + +/********************* +t_set_notify_readable +*********************/ + +static VALUE t_set_notify_readable (VALUE self UNUSED, VALUE signature, VALUE mode) +{ + evma_set_notify_readable(NUM2BSIG(signature), mode == Qtrue); + return Qnil; +} + +/******************** +t_is_notify_readable +********************/ + +static VALUE t_is_notify_writable (VALUE self UNUSED, VALUE signature) +{ + return evma_is_notify_writable(NUM2BSIG (signature)) ? Qtrue : Qfalse; +} + +/********************* +t_set_notify_writable +*********************/ + +static VALUE t_set_notify_writable (VALUE self UNUSED, VALUE signature, VALUE mode) +{ + evma_set_notify_writable(NUM2BSIG (signature), mode == Qtrue); + return Qnil; +} + +/******* +t_pause +*******/ + +static VALUE t_pause (VALUE self UNUSED, VALUE signature) +{ + return evma_pause(NUM2BSIG (signature)) ? Qtrue : Qfalse; +} + +/******** +t_resume +********/ + +static VALUE t_resume (VALUE self UNUSED, VALUE signature) +{ + return evma_resume(NUM2BSIG (signature)) ? Qtrue : Qfalse; +} + +/********** +t_paused_p +**********/ + +static VALUE t_paused_p (VALUE self UNUSED, VALUE signature) +{ + return evma_is_paused(NUM2BSIG (signature)) ? Qtrue : Qfalse; +} + +/********************* +t_num_close_scheduled +*********************/ + +static VALUE t_num_close_scheduled (VALUE self UNUSED) +{ + return INT2FIX(evma_num_close_scheduled()); +} + +/***************** +t_open_udp_socket +*****************/ + +static VALUE t_open_udp_socket (VALUE self UNUSED, VALUE server, VALUE port) +{ + const uintptr_t f = evma_open_datagram_socket (StringValueCStr(server), FIX2INT(port)); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "no datagram socket"); + return BSIG2NUM(f); +} + + + +/***************** +t_release_machine +*****************/ + +static VALUE t_release_machine (VALUE self UNUSED) +{ + evma_release_library(); + return Qnil; +} + + +/****** +t_stop +******/ + +static VALUE t_stop (VALUE self UNUSED) +{ + evma_stop_machine(); + return Qnil; +} + +/****************** +t_signal_loopbreak +******************/ + +static VALUE t_signal_loopbreak (VALUE self UNUSED) +{ + evma_signal_loopbreak(); + return Qnil; +} + +/************** +t_library_type +**************/ + +static VALUE t_library_type (VALUE self UNUSED) +{ + return rb_eval_string (":extension"); +} + + + +/******************* +t_set_timer_quantum +*******************/ + +static VALUE t_set_timer_quantum (VALUE self UNUSED, VALUE interval) +{ + evma_set_timer_quantum (FIX2INT (interval)); + return Qnil; +} + +/******************** +t_get_max_timer_count +********************/ + +static VALUE t_get_max_timer_count (VALUE self UNUSED) +{ + return INT2FIX (evma_get_max_timer_count()); +} + +/******************** +t_set_max_timer_count +********************/ + +static VALUE t_set_max_timer_count (VALUE self UNUSED, VALUE ct) +{ + evma_set_max_timer_count (FIX2INT (ct)); + return Qnil; +} + +/******************** +t_get/set_simultaneous_accept_count +********************/ + +static VALUE t_get_simultaneous_accept_count (VALUE self UNUSED) +{ + return INT2FIX (evma_get_simultaneous_accept_count()); +} + +static VALUE t_set_simultaneous_accept_count (VALUE self UNUSED, VALUE ct) +{ + evma_set_simultaneous_accept_count (FIX2INT (ct)); + return Qnil; +} + +/*************** +t_setuid_string +***************/ + +static VALUE t_setuid_string (VALUE self UNUSED, VALUE username) +{ + evma_setuid_string (StringValueCStr (username)); + return Qnil; +} + + + +/************** +t_invoke_popen +**************/ + +static VALUE t_invoke_popen (VALUE self UNUSED, VALUE cmd) +{ + #ifdef OS_WIN32 + rb_raise (EM_eUnsupported, "popen is not available on this platform"); + #endif + + int len = RARRAY_LEN(cmd); + if (len >= 2048) + rb_raise (rb_eRuntimeError, "%s", "too many arguments to popen"); + char *strings [2048]; + for (int i=0; i < len; i++) { + VALUE ix = INT2FIX (i); + VALUE s = rb_ary_aref (1, &ix, cmd); + strings[i] = StringValueCStr (s); + } + strings[len] = NULL; + + uintptr_t f = 0; + try { + f = evma_popen (strings); + } catch (std::runtime_error e) { + rb_raise (rb_eRuntimeError, "%s", e.what()); + } + if (!f) { + char *err = strerror (errno); + char buf[100]; + memset (buf, 0, sizeof(buf)); + snprintf (buf, sizeof(buf)-1, "no popen: %s", (err?err:"???")); + rb_raise (rb_eRuntimeError, "%s", buf); + } + return BSIG2NUM (f); +} + + +/*************** +t_read_keyboard +***************/ + +static VALUE t_read_keyboard (VALUE self UNUSED) +{ + const uintptr_t f = evma_open_keyboard(); + if (!f) + rb_raise (rb_eRuntimeError, "%s", "no keyboard reader"); + return BSIG2NUM (f); +} + + +/**************** +t_watch_filename +****************/ + +static VALUE t_watch_filename (VALUE self UNUSED, VALUE fname) +{ + try { + return BSIG2NUM(evma_watch_filename(StringValueCStr(fname))); + } catch (std::runtime_error e) { + rb_raise (EM_eUnsupported, "%s", e.what()); + } + return Qnil; +} + + +/****************** +t_unwatch_filename +******************/ + +static VALUE t_unwatch_filename (VALUE self UNUSED, VALUE sig) +{ + try { + evma_unwatch_filename(NUM2BSIG (sig)); + } catch (std::runtime_error e) { + rb_raise (EM_eInvalidSignature, "%s", e.what()); + } + + return Qnil; +} + + +/*********** +t_watch_pid +***********/ + +static VALUE t_watch_pid (VALUE self UNUSED, VALUE pid) +{ + try { + return BSIG2NUM(evma_watch_pid(NUM2INT(pid))); + } catch (std::runtime_error e) { + rb_raise (EM_eUnsupported, "%s", e.what()); + } + return Qnil; +} + + +/************* +t_unwatch_pid +*************/ + +static VALUE t_unwatch_pid (VALUE self UNUSED, VALUE sig) +{ + evma_unwatch_pid(NUM2BSIG (sig)); + return Qnil; +} + + +/********** +t__epoll_p +**********/ + +static VALUE t__epoll_p (VALUE self UNUSED) +{ + #ifdef HAVE_EPOLL + return Qtrue; + #else + return Qfalse; + #endif +} + +/******** +t__epoll +********/ + +static VALUE t__epoll (VALUE self UNUSED) +{ + if (t__epoll_p(self) == Qfalse) + return Qfalse; + + evma_set_epoll (1); + return Qtrue; +} + +/*********** +t__epoll_set +***********/ + +static VALUE t__epoll_set (VALUE self, VALUE val) +{ + if (t__epoll_p(self) == Qfalse && val == Qtrue) + rb_raise (EM_eUnsupported, "%s", "epoll is not supported on this platform"); + + evma_set_epoll (val == Qtrue ? 1 : 0); + return val; +} + + +/*********** +t__kqueue_p +***********/ + +static VALUE t__kqueue_p (VALUE self UNUSED) +{ + #ifdef HAVE_KQUEUE + return Qtrue; + #else + return Qfalse; + #endif +} + +/********* +t__kqueue +*********/ + +static VALUE t__kqueue (VALUE self UNUSED) +{ + if (t__kqueue_p(self) == Qfalse) + return Qfalse; + + evma_set_kqueue (1); + return Qtrue; +} + +/************* +t__kqueue_set +*************/ + +static VALUE t__kqueue_set (VALUE self, VALUE val) +{ + if (t__kqueue_p(self) == Qfalse && val == Qtrue) + rb_raise (EM_eUnsupported, "%s", "kqueue is not supported on this platform"); + + evma_set_kqueue (val == Qtrue ? 1 : 0); + return val; +} + + +/******** +t__ssl_p +********/ + +static VALUE t__ssl_p (VALUE self UNUSED) +{ + #ifdef WITH_SSL + return Qtrue; + #else + return Qfalse; + #endif +} + +/******** +t_stopping +********/ + +static VALUE t_stopping () +{ + if (evma_stopping()) { + return Qtrue; + } else { + return Qfalse; + } +} + + +/**************** +t_send_file_data +****************/ + +static VALUE t_send_file_data (VALUE self UNUSED, VALUE signature, VALUE filename) +{ + + /* The current implementation of evma_send_file_data_to_connection enforces a strict + * upper limit on the file size it will transmit (currently 32K). The function returns + * zero on success, -1 if the requested file exceeds its size limit, and a positive + * number for other errors. + * TODO: Positive return values are actually errno's, which is probably the wrong way to + * do this. For one thing it's ugly. For another, we can't be sure zero is never a real errno. + */ + + int b = evma_send_file_data_to_connection (NUM2BSIG (signature), StringValueCStr(filename)); + if (b == -1) + rb_raise(rb_eRuntimeError, "%s", "File too large. send_file_data() supports files under 32k."); + if (b > 0) { + char *err = strerror (b); + char buf[1024]; + memset (buf, 0, sizeof(buf)); + snprintf (buf, sizeof(buf)-1, ": %s %s", StringValueCStr(filename),(err?err:"???")); + + rb_raise (rb_eIOError, "%s", buf); + } + + return INT2NUM (0); +} + + +/******************* +t_set_rlimit_nofile +*******************/ + +static VALUE t_set_rlimit_nofile (VALUE self UNUSED, VALUE arg) +{ + arg = (NIL_P(arg)) ? -1 : NUM2INT (arg); + return INT2NUM (evma_set_rlimit_nofile (arg)); +} + +/*************************** +conn_get_outbound_data_size +***************************/ + +static VALUE conn_get_outbound_data_size (VALUE self) +{ + VALUE sig = rb_ivar_get (self, Intern_at_signature); + return INT2NUM (evma_get_outbound_data_size (NUM2BSIG (sig))); +} + + +/****************************** +conn_associate_callback_target +******************************/ + +static VALUE conn_associate_callback_target (VALUE self UNUSED, VALUE sig UNUSED) +{ + // No-op for the time being. + return Qnil; +} + + +/*************** +t_get_loop_time +****************/ + +static VALUE t_get_loop_time (VALUE self UNUSED) +{ + uint64_t current_time = evma_get_current_loop_time(); + if (current_time == 0) { + return Qnil; + } + + // Generally the industry has moved to 64-bit time_t, this is just in case we're 32-bit time_t. + if (sizeof(time_t) < 8 && current_time > INT_MAX) { + return rb_funcall(rb_cTime, Intern_at, 2, INT2NUM(current_time / 1000000), INT2NUM(current_time % 1000000)); + } else { + return rb_time_new(current_time / 1000000, current_time % 1000000); + } +} + + +/************* +t_start_proxy +**************/ + +static VALUE t_start_proxy (VALUE self UNUSED, VALUE from, VALUE to, VALUE bufsize, VALUE length) +{ + try { + evma_start_proxy(NUM2BSIG (from), NUM2BSIG (to), NUM2ULONG(bufsize), NUM2ULONG(length)); + } catch (std::runtime_error e) { + rb_raise (EM_eConnectionError, "%s", e.what()); + } + return Qnil; +} + + +/************ +t_stop_proxy +*************/ + +static VALUE t_stop_proxy (VALUE self UNUSED, VALUE from) +{ + try{ + evma_stop_proxy(NUM2BSIG (from)); + } catch (std::runtime_error e) { + rb_raise (EM_eConnectionError, "%s", e.what()); + } + return Qnil; +} + +/*************** +t_proxied_bytes +****************/ + +static VALUE t_proxied_bytes (VALUE self UNUSED, VALUE from) +{ + try{ + return BSIG2NUM(evma_proxied_bytes(NUM2BSIG (from))); + } catch (std::runtime_error e) { + rb_raise (EM_eConnectionError, "%s", e.what()); + } + return Qnil; +} + +/*************** +t_get_idle_time +****************/ + +static VALUE t_get_idle_time (VALUE self UNUSED, VALUE from) +{ + try{ + uint64_t current_time = evma_get_current_loop_time(); + uint64_t time = evma_get_last_activity_time(NUM2BSIG (from)); + if (current_time != 0 && time != 0) { + if (time >= current_time) + return BSIG2NUM(0); + else { + uint64_t diff = current_time - time; + float seconds = diff / (1000.0*1000.0); + return rb_float_new(seconds); + } + return Qnil; + } + } catch (std::runtime_error e) { + rb_raise (EM_eConnectionError, "%s", e.what()); + } + return Qnil; +} + +/************************ +t_get_heartbeat_interval +*************************/ + +static VALUE t_get_heartbeat_interval (VALUE self UNUSED) +{ + return rb_float_new(evma_get_heartbeat_interval()); +} + + +/************************ +t_set_heartbeat_interval +*************************/ + +static VALUE t_set_heartbeat_interval (VALUE self UNUSED, VALUE interval) +{ + float iv = RFLOAT_VALUE(interval); + if (evma_set_heartbeat_interval(iv)) + return Qtrue; + return Qfalse; +} + + +/********************* +Init_rubyeventmachine +*********************/ + +extern "C" void Init_rubyeventmachine() +{ + // Lookup Process::Status for get_subprocess_status + VALUE rb_mProcess = rb_const_get(rb_cObject, rb_intern("Process")); + rb_cProcStatus = rb_const_get(rb_mProcess, rb_intern("Status")); + + // Tuck away some symbol values so we don't have to look 'em up every time we need 'em. + Intern_at_signature = rb_intern ("@signature"); + Intern_at_timers = rb_intern ("@timers"); + Intern_at_conns = rb_intern ("@conns"); + Intern_at_error_handler = rb_intern("@error_handler"); + + Intern_event_callback = rb_intern ("event_callback"); + Intern_run_deferred_callbacks = rb_intern ("run_deferred_callbacks"); + Intern_delete = rb_intern ("delete"); + Intern_call = rb_intern ("call"); + Intern_at = rb_intern("at"); + Intern_receive_data = rb_intern ("receive_data"); + Intern_ssl_handshake_completed = rb_intern ("ssl_handshake_completed"); + Intern_ssl_verify_peer = rb_intern ("ssl_verify_peer"); + Intern_notify_readable = rb_intern ("notify_readable"); + Intern_notify_writable = rb_intern ("notify_writable"); + Intern_proxy_target_unbound = rb_intern ("proxy_target_unbound"); + Intern_proxy_completed = rb_intern ("proxy_completed"); + Intern_connection_completed = rb_intern ("connection_completed"); + + // INCOMPLETE, we need to define class Connections inside module EventMachine + // run_machine and run_machine_without_threads are now identical. + // Must deprecate the without_threads variant. + EmModule = rb_define_module ("EventMachine"); + EmConnection = rb_define_class_under (EmModule, "Connection", rb_cObject); + + rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eRuntimeError); + EM_eConnectionError = rb_define_class_under (EmModule, "ConnectionError", rb_eRuntimeError); + EM_eConnectionNotBound = rb_define_class_under (EmModule, "ConnectionNotBound", rb_eRuntimeError); + EM_eUnknownTimerFired = rb_define_class_under (EmModule, "UnknownTimerFired", rb_eRuntimeError); + EM_eUnsupported = rb_define_class_under (EmModule, "Unsupported", rb_eRuntimeError); + EM_eInvalidSignature = rb_define_class_under (EmModule, "InvalidSignature", rb_eRuntimeError); + + rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0); + rb_define_module_function (EmModule, "run_machine_once", (VALUE(*)(...))t_run_machine_once, 0); + rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))t_run_machine, 0); + rb_define_module_function (EmModule, "run_machine_without_threads", (VALUE(*)(...))t_run_machine, 0); + rb_define_module_function (EmModule, "add_oneshot_timer", (VALUE(*)(...))t_add_oneshot_timer, 1); + rb_define_module_function (EmModule, "start_tcp_server", (VALUE(*)(...))t_start_server, 2); + rb_define_module_function (EmModule, "stop_tcp_server", (VALUE(*)(...))t_stop_server, 1); + rb_define_module_function (EmModule, "start_unix_server", (VALUE(*)(...))t_start_unix_server, 1); + rb_define_module_function (EmModule, "attach_sd", (VALUE(*)(...))t_attach_sd, 1); + rb_define_module_function (EmModule, "set_tls_parms", (VALUE(*)(...))t_set_tls_parms, 10); + rb_define_module_function (EmModule, "start_tls", (VALUE(*)(...))t_start_tls, 1); + rb_define_module_function (EmModule, "get_peer_cert", (VALUE(*)(...))t_get_peer_cert, 1); + rb_define_module_function (EmModule, "get_cipher_bits", (VALUE(*)(...))t_get_cipher_bits, 1); + rb_define_module_function (EmModule, "get_cipher_name", (VALUE(*)(...))t_get_cipher_name, 1); + rb_define_module_function (EmModule, "get_cipher_protocol", (VALUE(*)(...))t_get_cipher_protocol, 1); + rb_define_module_function (EmModule, "get_sni_hostname", (VALUE(*)(...))t_get_sni_hostname, 1); + rb_define_module_function (EmModule, "send_data", (VALUE(*)(...))t_send_data, 3); + rb_define_module_function (EmModule, "send_datagram", (VALUE(*)(...))t_send_datagram, 5); + rb_define_module_function (EmModule, "close_connection", (VALUE(*)(...))t_close_connection, 2); + rb_define_module_function (EmModule, "report_connection_error_status", (VALUE(*)(...))t_report_connection_error_status, 1); + rb_define_module_function (EmModule, "connect_server", (VALUE(*)(...))t_connect_server, 2); + rb_define_module_function (EmModule, "bind_connect_server", (VALUE(*)(...))t_bind_connect_server, 4); + rb_define_module_function (EmModule, "connect_unix_server", (VALUE(*)(...))t_connect_unix_server, 1); + + rb_define_module_function (EmModule, "attach_fd", (VALUE (*)(...))t_attach_fd, 2); + rb_define_module_function (EmModule, "detach_fd", (VALUE (*)(...))t_detach_fd, 1); + rb_define_module_function (EmModule, "get_file_descriptor", (VALUE (*)(...))t_get_file_descriptor, 1); + rb_define_module_function (EmModule, "get_sock_opt", (VALUE (*)(...))t_get_sock_opt, 3); + rb_define_module_function (EmModule, "set_sock_opt", (VALUE (*)(...))t_set_sock_opt, 4); + rb_define_module_function (EmModule, "set_notify_readable", (VALUE (*)(...))t_set_notify_readable, 2); + rb_define_module_function (EmModule, "set_notify_writable", (VALUE (*)(...))t_set_notify_writable, 2); + rb_define_module_function (EmModule, "is_notify_readable", (VALUE (*)(...))t_is_notify_readable, 1); + rb_define_module_function (EmModule, "is_notify_writable", (VALUE (*)(...))t_is_notify_writable, 1); + + rb_define_module_function (EmModule, "pause_connection", (VALUE (*)(...))t_pause, 1); + rb_define_module_function (EmModule, "resume_connection", (VALUE (*)(...))t_resume, 1); + rb_define_module_function (EmModule, "connection_paused?", (VALUE (*)(...))t_paused_p, 1); + rb_define_module_function (EmModule, "num_close_scheduled", (VALUE (*)(...))t_num_close_scheduled, 0); + + rb_define_module_function (EmModule, "start_proxy", (VALUE (*)(...))t_start_proxy, 4); + rb_define_module_function (EmModule, "stop_proxy", (VALUE (*)(...))t_stop_proxy, 1); + rb_define_module_function (EmModule, "get_proxied_bytes", (VALUE (*)(...))t_proxied_bytes, 1); + + rb_define_module_function (EmModule, "watch_filename", (VALUE (*)(...))t_watch_filename, 1); + rb_define_module_function (EmModule, "unwatch_filename", (VALUE (*)(...))t_unwatch_filename, 1); + + rb_define_module_function (EmModule, "watch_pid", (VALUE (*)(...))t_watch_pid, 1); + rb_define_module_function (EmModule, "unwatch_pid", (VALUE (*)(...))t_unwatch_pid, 1); + + rb_define_module_function (EmModule, "current_time", (VALUE(*)(...))t_get_loop_time, 0); + + rb_define_module_function (EmModule, "open_udp_socket", (VALUE(*)(...))t_open_udp_socket, 2); + rb_define_module_function (EmModule, "read_keyboard", (VALUE(*)(...))t_read_keyboard, 0); + rb_define_module_function (EmModule, "release_machine", (VALUE(*)(...))t_release_machine, 0); + rb_define_module_function (EmModule, "stop", (VALUE(*)(...))t_stop, 0); + rb_define_module_function (EmModule, "signal_loopbreak", (VALUE(*)(...))t_signal_loopbreak, 0); + rb_define_module_function (EmModule, "library_type", (VALUE(*)(...))t_library_type, 0); + rb_define_module_function (EmModule, "set_timer_quantum", (VALUE(*)(...))t_set_timer_quantum, 1); + rb_define_module_function (EmModule, "get_max_timer_count", (VALUE(*)(...))t_get_max_timer_count, 0); + rb_define_module_function (EmModule, "set_max_timer_count", (VALUE(*)(...))t_set_max_timer_count, 1); + rb_define_module_function (EmModule, "get_simultaneous_accept_count", (VALUE(*)(...))t_get_simultaneous_accept_count, 0); + rb_define_module_function (EmModule, "set_simultaneous_accept_count", (VALUE(*)(...))t_set_simultaneous_accept_count, 1); + rb_define_module_function (EmModule, "setuid_string", (VALUE(*)(...))t_setuid_string, 1); + rb_define_module_function (EmModule, "invoke_popen", (VALUE(*)(...))t_invoke_popen, 1); + rb_define_module_function (EmModule, "send_file_data", (VALUE(*)(...))t_send_file_data, 2); + rb_define_module_function (EmModule, "get_heartbeat_interval", (VALUE(*)(...))t_get_heartbeat_interval, 0); + rb_define_module_function (EmModule, "set_heartbeat_interval", (VALUE(*)(...))t_set_heartbeat_interval, 1); + rb_define_module_function (EmModule, "get_idle_time", (VALUE(*)(...))t_get_idle_time, 1); + + rb_define_module_function (EmModule, "get_peername", (VALUE(*)(...))t_get_peername, 1); + rb_define_module_function (EmModule, "get_sockname", (VALUE(*)(...))t_get_sockname, 1); + rb_define_module_function (EmModule, "get_subprocess_pid", (VALUE(*)(...))t_get_subprocess_pid, 1); + rb_define_module_function (EmModule, "get_subprocess_status", (VALUE(*)(...))t_get_subprocess_status, 1); + rb_define_module_function (EmModule, "get_comm_inactivity_timeout", (VALUE(*)(...))t_get_comm_inactivity_timeout, 1); + rb_define_module_function (EmModule, "set_comm_inactivity_timeout", (VALUE(*)(...))t_set_comm_inactivity_timeout, 2); + rb_define_module_function (EmModule, "get_pending_connect_timeout", (VALUE(*)(...))t_get_pending_connect_timeout, 1); + rb_define_module_function (EmModule, "set_pending_connect_timeout", (VALUE(*)(...))t_set_pending_connect_timeout, 2); + rb_define_module_function (EmModule, "set_rlimit_nofile", (VALUE(*)(...))t_set_rlimit_nofile, 1); + rb_define_module_function (EmModule, "get_connection_count", (VALUE(*)(...))t_get_connection_count, 0); + + rb_define_module_function (EmModule, "epoll", (VALUE(*)(...))t__epoll, 0); + rb_define_module_function (EmModule, "epoll=", (VALUE(*)(...))t__epoll_set, 1); + rb_define_module_function (EmModule, "epoll?", (VALUE(*)(...))t__epoll_p, 0); + + rb_define_module_function (EmModule, "kqueue", (VALUE(*)(...))t__kqueue, 0); + rb_define_module_function (EmModule, "kqueue=", (VALUE(*)(...))t__kqueue_set, 1); + rb_define_module_function (EmModule, "kqueue?", (VALUE(*)(...))t__kqueue_p, 0); + + rb_define_module_function (EmModule, "ssl?", (VALUE(*)(...))t__ssl_p, 0); + rb_define_module_function(EmModule, "stopping?",(VALUE(*)(...))t_stopping, 0); + + rb_define_method (EmConnection, "get_outbound_data_size", (VALUE(*)(...))conn_get_outbound_data_size, 0); + rb_define_method (EmConnection, "associate_callback_target", (VALUE(*)(...))conn_associate_callback_target, 1); + + // Connection states + rb_define_const (EmModule, "TimerFired", INT2NUM(EM_TIMER_FIRED )); + rb_define_const (EmModule, "ConnectionData", INT2NUM(EM_CONNECTION_READ )); + rb_define_const (EmModule, "ConnectionUnbound", INT2NUM(EM_CONNECTION_UNBOUND )); + rb_define_const (EmModule, "ConnectionAccepted", INT2NUM(EM_CONNECTION_ACCEPTED )); + rb_define_const (EmModule, "ConnectionCompleted", INT2NUM(EM_CONNECTION_COMPLETED )); + rb_define_const (EmModule, "LoopbreakSignalled", INT2NUM(EM_LOOPBREAK_SIGNAL )); + rb_define_const (EmModule, "ConnectionNotifyReadable", INT2NUM(EM_CONNECTION_NOTIFY_READABLE)); + rb_define_const (EmModule, "ConnectionNotifyWritable", INT2NUM(EM_CONNECTION_NOTIFY_WRITABLE)); + rb_define_const (EmModule, "SslHandshakeCompleted", INT2NUM(EM_SSL_HANDSHAKE_COMPLETED )); + rb_define_const (EmModule, "SslVerify", INT2NUM(EM_SSL_VERIFY )); + // EM_PROXY_TARGET_UNBOUND = 110, + // EM_PROXY_COMPLETED = 111 + + // SSL Protocols + rb_define_const (EmModule, "EM_PROTO_SSLv2", INT2NUM(EM_PROTO_SSLv2 )); + rb_define_const (EmModule, "EM_PROTO_SSLv3", INT2NUM(EM_PROTO_SSLv3 )); + rb_define_const (EmModule, "EM_PROTO_TLSv1", INT2NUM(EM_PROTO_TLSv1 )); + rb_define_const (EmModule, "EM_PROTO_TLSv1_1", INT2NUM(EM_PROTO_TLSv1_1)); + rb_define_const (EmModule, "EM_PROTO_TLSv1_2", INT2NUM(EM_PROTO_TLSv1_2)); +} + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ssl.cpp b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ssl.cpp new file mode 100644 index 0000000..8d5e038 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ssl.cpp @@ -0,0 +1,619 @@ +/***************************************************************************** + +$Id$ + +File: ssl.cpp +Date: 30Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + +#ifdef WITH_SSL + +#include "project.h" + + +bool SslContext_t::bLibraryInitialized = false; + + + +static void InitializeDefaultCredentials(); +static EVP_PKEY *DefaultPrivateKey = NULL; +static X509 *DefaultCertificate = NULL; + +static char PrivateMaterials[] = { +"-----BEGIN RSA PRIVATE KEY-----\n" +"MIICXAIBAAKBgQDCYYhcw6cGRbhBVShKmbWm7UVsEoBnUf0cCh8AX+MKhMxwVDWV\n" +"Igdskntn3cSJjRtmgVJHIK0lpb/FYHQB93Ohpd9/Z18pDmovfFF9nDbFF0t39hJ/\n" +"AqSzFB3GiVPoFFZJEE1vJqh+3jzsSF5K56bZ6azz38VlZgXeSozNW5bXkQIDAQAB\n" +"AoGALA89gIFcr6BIBo8N5fL3aNHpZXjAICtGav+kTUpuxSiaym9cAeTHuAVv8Xgk\n" +"H2Wbq11uz+6JMLpkQJH/WZ7EV59DPOicXrp0Imr73F3EXBfR7t2EQDYHPMthOA1D\n" +"I9EtCzvV608Ze90hiJ7E3guGrGppZfJ+eUWCPgy8CZH1vRECQQDv67rwV/oU1aDo\n" +"6/+d5nqjeW6mWkGqTnUU96jXap8EIw6B+0cUKskwx6mHJv+tEMM2748ZY7b0yBlg\n" +"w4KDghbFAkEAz2h8PjSJG55LwqmXih1RONSgdN9hjB12LwXL1CaDh7/lkEhq0PlK\n" +"PCAUwQSdM17Sl0Xxm2CZiekTSlwmHrtqXQJAF3+8QJwtV2sRJp8u2zVe37IeH1cJ\n" +"xXeHyjTzqZ2803fnjN2iuZvzNr7noOA1/Kp+pFvUZUU5/0G2Ep8zolPUjQJAFA7k\n" +"xRdLkzIx3XeNQjwnmLlncyYPRv+qaE3FMpUu7zftuZBnVCJnvXzUxP3vPgKTlzGa\n" +"dg5XivDRfsV+okY5uQJBAMV4FesUuLQVEKb6lMs7rzZwpeGQhFDRfywJzfom2TLn\n" +"2RdJQQ3dcgnhdVDgt5o1qkmsqQh8uJrJ9SdyLIaZQIc=\n" +"-----END RSA PRIVATE KEY-----\n" +"-----BEGIN CERTIFICATE-----\n" +"MIID6TCCA1KgAwIBAgIJANm4W/Tzs+s+MA0GCSqGSIb3DQEBBQUAMIGqMQswCQYD\n" +"VQQGEwJVUzERMA8GA1UECBMITmV3IFlvcmsxETAPBgNVBAcTCE5ldyBZb3JrMRYw\n" +"FAYDVQQKEw1TdGVhbWhlYXQubmV0MRQwEgYDVQQLEwtFbmdpbmVlcmluZzEdMBsG\n" +"A1UEAxMUb3BlbmNhLnN0ZWFtaGVhdC5uZXQxKDAmBgkqhkiG9w0BCQEWGWVuZ2lu\n" +"ZWVyaW5nQHN0ZWFtaGVhdC5uZXQwHhcNMDYwNTA1MTcwNjAzWhcNMjQwMjIwMTcw\n" +"NjAzWjCBqjELMAkGA1UEBhMCVVMxETAPBgNVBAgTCE5ldyBZb3JrMREwDwYDVQQH\n" +"EwhOZXcgWW9yazEWMBQGA1UEChMNU3RlYW1oZWF0Lm5ldDEUMBIGA1UECxMLRW5n\n" +"aW5lZXJpbmcxHTAbBgNVBAMTFG9wZW5jYS5zdGVhbWhlYXQubmV0MSgwJgYJKoZI\n" +"hvcNAQkBFhllbmdpbmVlcmluZ0BzdGVhbWhlYXQubmV0MIGfMA0GCSqGSIb3DQEB\n" +"AQUAA4GNADCBiQKBgQDCYYhcw6cGRbhBVShKmbWm7UVsEoBnUf0cCh8AX+MKhMxw\n" +"VDWVIgdskntn3cSJjRtmgVJHIK0lpb/FYHQB93Ohpd9/Z18pDmovfFF9nDbFF0t3\n" +"9hJ/AqSzFB3GiVPoFFZJEE1vJqh+3jzsSF5K56bZ6azz38VlZgXeSozNW5bXkQID\n" +"AQABo4IBEzCCAQ8wHQYDVR0OBBYEFPJvPd1Fcmd8o/Tm88r+NjYPICCkMIHfBgNV\n" +"HSMEgdcwgdSAFPJvPd1Fcmd8o/Tm88r+NjYPICCkoYGwpIGtMIGqMQswCQYDVQQG\n" +"EwJVUzERMA8GA1UECBMITmV3IFlvcmsxETAPBgNVBAcTCE5ldyBZb3JrMRYwFAYD\n" +"VQQKEw1TdGVhbWhlYXQubmV0MRQwEgYDVQQLEwtFbmdpbmVlcmluZzEdMBsGA1UE\n" +"AxMUb3BlbmNhLnN0ZWFtaGVhdC5uZXQxKDAmBgkqhkiG9w0BCQEWGWVuZ2luZWVy\n" +"aW5nQHN0ZWFtaGVhdC5uZXSCCQDZuFv087PrPjAMBgNVHRMEBTADAQH/MA0GCSqG\n" +"SIb3DQEBBQUAA4GBAC1CXey/4UoLgJiwcEMDxOvW74plks23090iziFIlGgcIhk0\n" +"Df6hTAs7H3MWww62ddvR8l07AWfSzSP5L6mDsbvq7EmQsmPODwb6C+i2aF3EDL8j\n" +"uw73m4YIGI0Zw2XdBpiOGkx2H56Kya6mJJe/5XORZedh1wpI7zki01tHYbcy\n" +"-----END CERTIFICATE-----\n"}; + +/* These private materials were made with: + * openssl req -new -x509 -keyout cakey.pem -out cacert.pem -nodes -days 6500 + * TODO: We need a full-blown capability to work with user-supplied + * keypairs and properly-signed certificates. + */ + + +/***************** +builtin_passwd_cb +*****************/ + +extern "C" int builtin_passwd_cb (char *buf UNUSED, int bufsize UNUSED, int rwflag UNUSED, void *userdata UNUSED) +{ + strcpy (buf, "kittycat"); + return 8; +} + +/**************************** +InitializeDefaultCredentials +****************************/ + +static void InitializeDefaultCredentials() +{ + BIO *bio = BIO_new_mem_buf (PrivateMaterials, -1); + assert (bio); + + if (DefaultPrivateKey) { + // we may come here in a restart. + EVP_PKEY_free (DefaultPrivateKey); + DefaultPrivateKey = NULL; + } + PEM_read_bio_PrivateKey (bio, &DefaultPrivateKey, builtin_passwd_cb, 0); + + if (DefaultCertificate) { + // we may come here in a restart. + X509_free (DefaultCertificate); + DefaultCertificate = NULL; + } + PEM_read_bio_X509 (bio, &DefaultCertificate, NULL, 0); + + BIO_free (bio); +} + + + +/************************** +SslContext_t::SslContext_t +**************************/ + +SslContext_t::SslContext_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version) : + bIsServer (is_server), + pCtx (NULL), + PrivateKey (NULL), + Certificate (NULL) +{ + /* TODO: the usage of the specified private-key and cert-chain filenames only applies to + * client-side connections at this point. Server connections currently use the default materials. + * That needs to be fixed asap. + * Also, in this implementation, server-side connections use statically defined X-509 defaults. + * One thing I'm really not clear on is whether or not you have to explicitly free X509 and EVP_PKEY + * objects when we call our destructor, or whether just calling SSL_CTX_free is enough. + */ + + if (!bLibraryInitialized) { + bLibraryInitialized = true; + SSL_library_init(); + OpenSSL_add_ssl_algorithms(); + OpenSSL_add_all_algorithms(); + SSL_load_error_strings(); + ERR_load_crypto_strings(); + + InitializeDefaultCredentials(); + } + + pCtx = SSL_CTX_new (bIsServer ? SSLv23_server_method() : SSLv23_client_method()); + if (!pCtx) + throw std::runtime_error ("no SSL context"); + + SSL_CTX_set_options (pCtx, SSL_OP_ALL); + + #ifdef SSL_CTRL_CLEAR_OPTIONS + SSL_CTX_clear_options (pCtx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); + # ifdef SSL_OP_NO_TLSv1_1 + SSL_CTX_clear_options (pCtx, SSL_OP_NO_TLSv1_1); + # endif + # ifdef SSL_OP_NO_TLSv1_2 + SSL_CTX_clear_options (pCtx, SSL_OP_NO_TLSv1_2); + # endif + #endif + + if (!(ssl_version & EM_PROTO_SSLv2)) + SSL_CTX_set_options (pCtx, SSL_OP_NO_SSLv2); + + if (!(ssl_version & EM_PROTO_SSLv3)) + SSL_CTX_set_options (pCtx, SSL_OP_NO_SSLv3); + + if (!(ssl_version & EM_PROTO_TLSv1)) + SSL_CTX_set_options (pCtx, SSL_OP_NO_TLSv1); + + #ifdef SSL_OP_NO_TLSv1_1 + if (!(ssl_version & EM_PROTO_TLSv1_1)) + SSL_CTX_set_options (pCtx, SSL_OP_NO_TLSv1_1); + #endif + + #ifdef SSL_OP_NO_TLSv1_2 + if (!(ssl_version & EM_PROTO_TLSv1_2)) + SSL_CTX_set_options (pCtx, SSL_OP_NO_TLSv1_2); + #endif + + #ifdef SSL_MODE_RELEASE_BUFFERS + SSL_CTX_set_mode (pCtx, SSL_MODE_RELEASE_BUFFERS); + #endif + + if (bIsServer) { + + // The SSL_CTX calls here do NOT allocate memory. + int e; + if (privkeyfile.length() > 0) + e = SSL_CTX_use_PrivateKey_file (pCtx, privkeyfile.c_str(), SSL_FILETYPE_PEM); + else + e = SSL_CTX_use_PrivateKey (pCtx, DefaultPrivateKey); + if (e <= 0) ERR_print_errors_fp(stderr); + assert (e > 0); + + if (certchainfile.length() > 0) + e = SSL_CTX_use_certificate_chain_file (pCtx, certchainfile.c_str()); + else + e = SSL_CTX_use_certificate (pCtx, DefaultCertificate); + if (e <= 0) ERR_print_errors_fp(stderr); + assert (e > 0); + + if (dhparam.length() > 0) { + DH *dh; + BIO *bio; + + bio = BIO_new_file(dhparam.c_str(), "r"); + if (bio == NULL) { + char buf [500]; + snprintf (buf, sizeof(buf)-1, "dhparam: BIO_new_file(%s) failed", dhparam.c_str()); + throw std::runtime_error (buf); + } + + dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); + + if (dh == NULL) { + BIO_free(bio); + char buf [500]; + snprintf (buf, sizeof(buf)-1, "dhparam: PEM_read_bio_DHparams(%s) failed", dhparam.c_str()); + throw std::runtime_error (buf); + } + + SSL_CTX_set_tmp_dh(pCtx, dh); + + DH_free(dh); + BIO_free(bio); + } + + if (ecdh_curve.length() > 0) { + #if OPENSSL_VERSION_NUMBER >= 0x0090800fL && !defined(OPENSSL_NO_ECDH) + int nid; + EC_KEY *ecdh; + + nid = OBJ_sn2nid((const char *) ecdh_curve.c_str()); + if (nid == 0) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "ecdh_curve: Unknown curve name: %s", ecdh_curve.c_str()); + throw std::runtime_error (buf); + } + + ecdh = EC_KEY_new_by_curve_name(nid); + if (ecdh == NULL) { + char buf [200]; + snprintf (buf, sizeof(buf)-1, "ecdh_curve: Unable to create: %s", ecdh_curve.c_str()); + throw std::runtime_error (buf); + } + + SSL_CTX_set_options(pCtx, SSL_OP_SINGLE_ECDH_USE); + + SSL_CTX_set_tmp_ecdh(pCtx, ecdh); + + EC_KEY_free(ecdh); + #else + throw std::runtime_error ("No openssl ECDH support"); + #endif + } + } + + if (cipherlist.length() > 0) + SSL_CTX_set_cipher_list (pCtx, cipherlist.c_str()); + else + SSL_CTX_set_cipher_list (pCtx, "ALL:!ADH:!LOW:!EXP:!DES-CBC3-SHA:@STRENGTH"); + + if (bIsServer) { + SSL_CTX_sess_set_cache_size (pCtx, 128); + SSL_CTX_set_session_id_context (pCtx, (unsigned char*)"eventmachine", 12); + } + else { + int e; + if (privkeyfile.length() > 0) { + e = SSL_CTX_use_PrivateKey_file (pCtx, privkeyfile.c_str(), SSL_FILETYPE_PEM); + if (e <= 0) ERR_print_errors_fp(stderr); + assert (e > 0); + } + if (certchainfile.length() > 0) { + e = SSL_CTX_use_certificate_chain_file (pCtx, certchainfile.c_str()); + if (e <= 0) ERR_print_errors_fp(stderr); + assert (e > 0); + } + } +} + + + +/*************************** +SslContext_t::~SslContext_t +***************************/ + +SslContext_t::~SslContext_t() +{ + if (pCtx) + SSL_CTX_free (pCtx); + if (PrivateKey) + EVP_PKEY_free (PrivateKey); + if (Certificate) + X509_free (Certificate); +} + + + +/****************** +SslBox_t::SslBox_t +******************/ + +SslBox_t::SslBox_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, bool verify_peer, bool fail_if_no_peer_cert, const std::string &snihostname, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version, const uintptr_t binding): + bIsServer (is_server), + bHandshakeCompleted (false), + bVerifyPeer (verify_peer), + bFailIfNoPeerCert (fail_if_no_peer_cert), + pSSL (NULL), + pbioRead (NULL), + pbioWrite (NULL) +{ + /* TODO someday: make it possible to re-use SSL contexts so we don't have to create + * a new one every time we come here. + */ + + Context = new SslContext_t (bIsServer, privkeyfile, certchainfile, cipherlist, ecdh_curve, dhparam, ssl_version); + assert (Context); + + pbioRead = BIO_new (BIO_s_mem()); + assert (pbioRead); + + pbioWrite = BIO_new (BIO_s_mem()); + assert (pbioWrite); + + pSSL = SSL_new (Context->pCtx); + assert (pSSL); + + if (snihostname.length() > 0) { + SSL_set_tlsext_host_name (pSSL, snihostname.c_str()); + } + + SSL_set_bio (pSSL, pbioRead, pbioWrite); + + // Store a pointer to the binding signature in the SSL object so we can retrieve it later + SSL_set_ex_data(pSSL, 0, (void*) binding); + + if (bVerifyPeer) { + int mode = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; + if (bFailIfNoPeerCert) + mode = mode | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; + SSL_set_verify(pSSL, mode, ssl_verify_wrapper); + } + + if (!bIsServer) { + int e = SSL_connect (pSSL); + if (e != 1) + ERR_print_errors_fp(stderr); + } +} + + + +/******************* +SslBox_t::~SslBox_t +*******************/ + +SslBox_t::~SslBox_t() +{ + // Freeing pSSL will also free the associated BIOs, so DON'T free them separately. + if (pSSL) { + if (SSL_get_shutdown (pSSL) & SSL_RECEIVED_SHUTDOWN) + SSL_shutdown (pSSL); + else + SSL_clear (pSSL); + SSL_free (pSSL); + } + + delete Context; +} + + + +/*********************** +SslBox_t::PutCiphertext +***********************/ + +bool SslBox_t::PutCiphertext (const char *buf, int bufsize) +{ + assert (buf && (bufsize > 0)); + + assert (pbioRead); + int n = BIO_write (pbioRead, buf, bufsize); + + return (n == bufsize) ? true : false; +} + + +/********************** +SslBox_t::GetPlaintext +**********************/ + +int SslBox_t::GetPlaintext (char *buf, int bufsize) +{ + if (!SSL_is_init_finished (pSSL)) { + int e = bIsServer ? SSL_accept (pSSL) : SSL_connect (pSSL); + if (e != 1) { + int er = SSL_get_error (pSSL, e); + if (er != SSL_ERROR_WANT_READ) { + ERR_print_errors_fp(stderr); + // Return -1 for a nonfatal error, -2 for an error that should force the connection down. + return (er == SSL_ERROR_SSL) ? (-2) : (-1); + } + else + return 0; + } + bHandshakeCompleted = true; + // If handshake finished, FALL THROUGH and return the available plaintext. + } + + if (!SSL_is_init_finished (pSSL)) { + // We can get here if a browser abandons a handshake. + // The user can see a warning dialog and abort the connection. + //cerr << ""; + return 0; + } + + //cerr << "CIPH: " << SSL_get_cipher (pSSL) << endl; + + int n = SSL_read (pSSL, buf, bufsize); + if (n >= 0) { + return n; + } + else { + if (SSL_get_error (pSSL, n) == SSL_ERROR_WANT_READ) { + return 0; + } + else { + return -1; + } + } + + return 0; +} + + + +/************************** +SslBox_t::CanGetCiphertext +**************************/ + +bool SslBox_t::CanGetCiphertext() +{ + assert (pbioWrite); + return BIO_pending (pbioWrite) ? true : false; +} + + + +/*********************** +SslBox_t::GetCiphertext +***********************/ + +int SslBox_t::GetCiphertext (char *buf, int bufsize) +{ + assert (pbioWrite); + assert (buf && (bufsize > 0)); + + return BIO_read (pbioWrite, buf, bufsize); +} + + + +/********************** +SslBox_t::PutPlaintext +**********************/ + +int SslBox_t::PutPlaintext (const char *buf, int bufsize) +{ + // The caller will interpret the return value as the number of bytes written. + // WARNING WARNING WARNING, are there any situations in which a 0 or -1 return + // from SSL_write means we should immediately retry? The socket-machine loop + // will probably wait for a time-out cycle (perhaps a second) before re-trying. + // THIS WOULD CAUSE A PERCEPTIBLE DELAY! + + /* We internally queue any outbound plaintext that can't be dispatched + * because we're in the middle of a handshake or something. + * When we get called, try to send any queued data first, and then + * send the caller's data (or queue it). We may get called with no outbound + * data, which means we try to send the outbound queue and that's all. + * + * Return >0 if we wrote any data, 0 if we didn't, and <0 for a fatal error. + * Note that if we return 0, the connection is still considered live + * and we are signalling that we have accepted the outbound data (if any). + */ + + OutboundQ.Push (buf, bufsize); + + if (!SSL_is_init_finished (pSSL)) + return 0; + + bool fatal = false; + bool did_work = false; + int pending = BIO_pending(pbioWrite); + + while (OutboundQ.HasPages() && pending < SSLBOX_WRITE_BUFFER_SIZE) { + const char *page; + int length; + OutboundQ.Front (&page, &length); + assert (page && (length > 0)); + int n = SSL_write (pSSL, page, length); + pending = BIO_pending(pbioWrite); + + if (n > 0) { + did_work = true; + OutboundQ.PopFront(); + } + else { + int er = SSL_get_error (pSSL, n); + if ((er != SSL_ERROR_WANT_READ) && (er != SSL_ERROR_WANT_WRITE)) + fatal = true; + break; + } + } + + + if (did_work) + return 1; + else if (fatal) + return -1; + else + return 0; +} + +/********************** +SslBox_t::GetPeerCert +**********************/ + +X509 *SslBox_t::GetPeerCert() +{ + X509 *cert = NULL; + + if (pSSL) + cert = SSL_get_peer_certificate(pSSL); + + return cert; +} + +/********************** +SslBox_t::GetCipherBits +**********************/ + +int SslBox_t::GetCipherBits() +{ + int bits = -1; + if (pSSL) + SSL_get_cipher_bits(pSSL, &bits); + return bits; +} + +/********************** +SslBox_t::GetCipherName +**********************/ + +const char *SslBox_t::GetCipherName() +{ + if (pSSL) + return SSL_get_cipher_name(pSSL); + return NULL; +} + +/********************** +SslBox_t::GetCipherProtocol +**********************/ + +const char *SslBox_t::GetCipherProtocol() +{ + if (pSSL) + return SSL_get_cipher_version(pSSL); + return NULL; +} + +/********************** +SslBox_t::GetSNIHostname +**********************/ + +const char *SslBox_t::GetSNIHostname() +{ + #ifdef TLSEXT_NAMETYPE_host_name + if (pSSL) + return SSL_get_servername (pSSL, TLSEXT_NAMETYPE_host_name); + #endif + return NULL; +} + +/****************** +ssl_verify_wrapper +*******************/ + +extern "C" int ssl_verify_wrapper(int preverify_ok UNUSED, X509_STORE_CTX *ctx) +{ + uintptr_t binding; + X509 *cert; + SSL *ssl; + BUF_MEM *buf; + BIO *out; + int result; + + cert = X509_STORE_CTX_get_current_cert(ctx); + ssl = (SSL*) X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); + binding = (uintptr_t) SSL_get_ex_data(ssl, 0); + + out = BIO_new(BIO_s_mem()); + PEM_write_bio_X509(out, cert); + BIO_write(out, "\0", 1); + BIO_get_mem_ptr(out, &buf); + + ConnectionDescriptor *cd = dynamic_cast (Bindable_t::GetObject(binding)); + result = (cd->VerifySslPeer(buf->data) == true ? 1 : 0); + BIO_free(out); + + return result; +} + +#endif // WITH_SSL + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ssl.h b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ssl.h new file mode 100644 index 0000000..64ff6e1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/ext/ssl.h @@ -0,0 +1,103 @@ +/***************************************************************************** + +$Id$ + +File: ssl.h +Date: 30Apr06 + +Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +Gmail: blackhedd + +This program is free software; you can redistribute it and/or modify +it under the terms of either: 1) the GNU General Public License +as published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version; or 2) Ruby's License. + +See the file COPYING for complete licensing information. + +*****************************************************************************/ + + +#ifndef __SslBox__H_ +#define __SslBox__H_ + + + + +#ifdef WITH_SSL + +/****************** +class SslContext_t +******************/ + +class SslContext_t +{ + public: + SslContext_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version); + virtual ~SslContext_t(); + + private: + static bool bLibraryInitialized; + + private: + bool bIsServer; + SSL_CTX *pCtx; + + EVP_PKEY *PrivateKey; + X509 *Certificate; + + friend class SslBox_t; +}; + + +/************** +class SslBox_t +**************/ + +#define SSLBOX_INPUT_CHUNKSIZE 2019 +#define SSLBOX_OUTPUT_CHUNKSIZE 2048 +#define SSLBOX_WRITE_BUFFER_SIZE 8192 // (SSLBOX_OUTPUT_CHUNKSIZE * 4) + +class SslBox_t +{ + public: + SslBox_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, bool verify_peer, bool fail_if_no_peer_cert, const std::string &snihostname, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version, const uintptr_t binding); + virtual ~SslBox_t(); + + int PutPlaintext (const char*, int); + int GetPlaintext (char*, int); + + bool PutCiphertext (const char*, int); + bool CanGetCiphertext(); + int GetCiphertext (char*, int); + bool IsHandshakeCompleted() {return bHandshakeCompleted;} + + X509 *GetPeerCert(); + int GetCipherBits(); + const char *GetCipherName(); + const char *GetCipherProtocol(); + const char *GetSNIHostname(); + + void Shutdown(); + + protected: + SslContext_t *Context; + + bool bIsServer; + bool bHandshakeCompleted; + bool bVerifyPeer; + bool bFailIfNoPeerCert; + SSL *pSSL; + BIO *pbioRead; + BIO *pbioWrite; + + PageList OutboundQ; +}; + +extern "C" int ssl_verify_wrapper(int, X509_STORE_CTX*); + +#endif // WITH_SSL + + +#endif // __SslBox__H_ + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/.classpath b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/.classpath new file mode 100644 index 0000000..11672dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/.project b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/.project new file mode 100644 index 0000000..c7766db --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/.project @@ -0,0 +1,17 @@ + + + em_reactor + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EmReactor.java b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EmReactor.java new file mode 100644 index 0000000..31642f3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EmReactor.java @@ -0,0 +1,613 @@ +/** + * $Id$ + * + * Author:: Francis Cianfrocca (gmail: blackhedd) + * Homepage:: http://rubyeventmachine.com + * Date:: 15 Jul 2007 + * + * See EventMachine and EventMachine::Connection for documentation and + * usage examples. + * + * + *---------------------------------------------------------------------------- + * + * Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. + * Gmail: blackhedd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of either: 1) the GNU General Public License + * as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version; or 2) Ruby's License. + * + * See the file COPYING for complete licensing information. + * + *--------------------------------------------------------------------------- + * + * + */ + +package com.rubyeventmachine; + +import java.io.*; +import java.nio.channels.*; +import java.util.*; +import java.nio.*; +import java.net.*; +import java.util.concurrent.atomic.*; +import java.security.*; + +public class EmReactor { + public final int EM_TIMER_FIRED = 100; + public final int EM_CONNECTION_READ = 101; + public final int EM_CONNECTION_UNBOUND = 102; + public final int EM_CONNECTION_ACCEPTED = 103; + public final int EM_CONNECTION_COMPLETED = 104; + public final int EM_LOOPBREAK_SIGNAL = 105; + public final int EM_CONNECTION_NOTIFY_READABLE = 106; + public final int EM_CONNECTION_NOTIFY_WRITABLE = 107; + public final int EM_SSL_HANDSHAKE_COMPLETED = 108; + public final int EM_SSL_VERIFY = 109; + public final int EM_PROXY_TARGET_UNBOUND = 110; + public final int EM_PROXY_COMPLETED = 111; + + public final int EM_PROTO_SSLv2 = 2; + public final int EM_PROTO_SSLv3 = 4; + public final int EM_PROTO_TLSv1 = 8; + public final int EM_PROTO_TLSv1_1 = 16; + public final int EM_PROTO_TLSv1_2 = 32; + + private Selector mySelector; + private TreeMap> Timers; + private HashMap Connections; + private HashMap Acceptors; + private ArrayList NewConnections; + private ArrayList UnboundConnections; + private ArrayList DetachedConnections; + + private boolean bRunReactor; + private long BindingIndex; + private AtomicBoolean loopBreaker; + private ByteBuffer myReadBuffer; + private int timerQuantum; + + public EmReactor() { + Timers = new TreeMap>(); + Connections = new HashMap(); + Acceptors = new HashMap(); + NewConnections = new ArrayList(); + UnboundConnections = new ArrayList(); + DetachedConnections = new ArrayList(); + + BindingIndex = 0; + loopBreaker = new AtomicBoolean(); + loopBreaker.set(false); + myReadBuffer = ByteBuffer.allocate(32*1024); // don't use a direct buffer. Ruby doesn't seem to like them. + timerQuantum = 98; + } + + /** + * This is a no-op stub, intended to be overridden in user code. + */ + public void eventCallback (long sig, int eventType, ByteBuffer data, long data2) { + System.out.println ("Default callback: "+sig+" "+eventType+" "+data+" "+data2); + } + public void eventCallback (long sig, int eventType, ByteBuffer data) { + eventCallback (sig, eventType, data, 0); + } + + + public void run() { + try { + mySelector = Selector.open(); + bRunReactor = true; + } catch (IOException e) { + throw new RuntimeException ("Could not open selector", e); + } + + while (bRunReactor) { + runLoopbreaks(); + if (!bRunReactor) break; + + runTimers(); + if (!bRunReactor) break; + + removeUnboundConnections(); + checkIO(); + addNewConnections(); + processIO(); + } + + close(); + } + + void addNewConnections() { + ListIterator iter = DetachedConnections.listIterator(0); + while (iter.hasNext()) { + EventableSocketChannel ec = iter.next(); + ec.cleanup(); + } + DetachedConnections.clear(); + + ListIterator iter2 = NewConnections.listIterator(0); + while (iter2.hasNext()) { + long b = iter2.next(); + + EventableChannel ec = Connections.get(b); + if (ec != null) { + try { + ec.register(); + } catch (ClosedChannelException e) { + UnboundConnections.add (ec.getBinding()); + } + } + } + NewConnections.clear(); + } + + void removeUnboundConnections() { + ListIterator iter = UnboundConnections.listIterator(0); + while (iter.hasNext()) { + long b = iter.next(); + + EventableChannel ec = Connections.remove(b); + if (ec != null) { + eventCallback (b, EM_CONNECTION_UNBOUND, null); + ec.close(); + + EventableSocketChannel sc = (EventableSocketChannel) ec; + if (sc != null && sc.isAttached()) + DetachedConnections.add (sc); + } + } + UnboundConnections.clear(); + } + + void checkIO() { + long timeout; + + if (NewConnections.size() > 0) { + timeout = -1; + } else if (!Timers.isEmpty()) { + long now = new Date().getTime(); + long k = Timers.firstKey(); + long diff = k-now; + + if (diff <= 0) + timeout = -1; // don't wait, just poll once + else + timeout = diff; + } else { + timeout = 0; // wait indefinitely + } + + try { + if (timeout == -1) + mySelector.selectNow(); + else + mySelector.select(timeout); + } catch (IOException e) { + e.printStackTrace(); + } + } + + void processIO() { + Iterator it = mySelector.selectedKeys().iterator(); + while (it.hasNext()) { + SelectionKey k = it.next(); + it.remove(); + + if (k.isConnectable()) + isConnectable(k); + + else if (k.isAcceptable()) + isAcceptable(k); + + else { + if (k.isWritable()) + isWritable(k); + + if (k.isReadable()) + isReadable(k); + } + } + } + + void isAcceptable (SelectionKey k) { + ServerSocketChannel ss = (ServerSocketChannel) k.channel(); + SocketChannel sn; + long b; + + for (int n = 0; n < 10; n++) { + try { + sn = ss.accept(); + if (sn == null) + break; + } catch (IOException e) { + e.printStackTrace(); + k.cancel(); + + ServerSocketChannel server = Acceptors.remove(k.attachment()); + if (server != null) + try{ server.close(); } catch (IOException ex) {}; + break; + } + + try { + sn.configureBlocking(false); + } catch (IOException e) { + e.printStackTrace(); + continue; + } + + b = createBinding(); + EventableSocketChannel ec = new EventableSocketChannel (sn, b, mySelector); + Connections.put (b, ec); + NewConnections.add (b); + + eventCallback (((Long)k.attachment()).longValue(), EM_CONNECTION_ACCEPTED, null, b); + } + } + + void isReadable (SelectionKey k) { + EventableChannel ec = (EventableChannel) k.attachment(); + long b = ec.getBinding(); + + if (ec.isWatchOnly()) { + if (ec.isNotifyReadable()) + eventCallback (b, EM_CONNECTION_NOTIFY_READABLE, null); + } else { + myReadBuffer.clear(); + + try { + ec.readInboundData (myReadBuffer); + myReadBuffer.flip(); + if (myReadBuffer.limit() > 0) + eventCallback (b, EM_CONNECTION_READ, myReadBuffer); + } catch (IOException e) { + UnboundConnections.add (b); + } + } + } + + void isWritable (SelectionKey k) { + EventableChannel ec = (EventableChannel) k.attachment(); + long b = ec.getBinding(); + + if (ec.isWatchOnly()) { + if (ec.isNotifyWritable()) + eventCallback (b, EM_CONNECTION_NOTIFY_WRITABLE, null); + } + else { + try { + if (!ec.writeOutboundData()) + UnboundConnections.add (b); + } catch (IOException e) { + UnboundConnections.add (b); + } + } + } + + void isConnectable (SelectionKey k) { + EventableSocketChannel ec = (EventableSocketChannel) k.attachment(); + long b = ec.getBinding(); + + try { + if (ec.finishConnecting()) + eventCallback (b, EM_CONNECTION_COMPLETED, null); + else + UnboundConnections.add (b); + } catch (IOException e) { + UnboundConnections.add (b); + } + } + + void close() { + try { + if (mySelector != null) + mySelector.close(); + } catch (IOException e) {} + mySelector = null; + + // run down open connections and sockets. + Iterator i = Acceptors.values().iterator(); + while (i.hasNext()) { + try { + i.next().close(); + } catch (IOException e) {} + } + + // 29Sep09: We create an ArrayList of the existing connections, then iterate over + // that to call unbind on them. This is because an unbind can trigger a reconnect, + // which will add to the Connections HashMap, causing a ConcurrentModificationException. + // XXX: The correct behavior here would be to latch the various reactor methods to return + // immediately if the reactor is shutting down. + ArrayList conns = new ArrayList(); + Iterator i2 = Connections.values().iterator(); + while (i2.hasNext()) { + EventableChannel ec = i2.next(); + if (ec != null) { + conns.add (ec); + } + } + Connections.clear(); + + ListIterator i3 = conns.listIterator(0); + while (i3.hasNext()) { + EventableChannel ec = i3.next(); + eventCallback (ec.getBinding(), EM_CONNECTION_UNBOUND, null); + ec.close(); + + EventableSocketChannel sc = (EventableSocketChannel) ec; + if (sc != null && sc.isAttached()) + DetachedConnections.add (sc); + } + + ListIterator i4 = DetachedConnections.listIterator(0); + while (i4.hasNext()) { + EventableSocketChannel ec = i4.next(); + ec.cleanup(); + } + DetachedConnections.clear(); + } + + void runLoopbreaks() { + if (loopBreaker.getAndSet(false)) { + eventCallback (0, EM_LOOPBREAK_SIGNAL, null); + } + } + + public void stop() { + bRunReactor = false; + signalLoopbreak(); + } + + void runTimers() { + long now = new Date().getTime(); + while (!Timers.isEmpty()) { + long k = Timers.firstKey(); + if (k > now) + break; + + ArrayList callbacks = Timers.get(k); + Timers.remove(k); + + // Fire all timers at this timestamp + ListIterator iter = callbacks.listIterator(0); + while (iter.hasNext()) { + eventCallback (0, EM_TIMER_FIRED, null, iter.next().longValue()); + } + } + } + + public long installOneshotTimer (long milliseconds) { + long s = createBinding(); + long deadline = new Date().getTime() + milliseconds; + + if (Timers.containsKey(deadline)) { + Timers.get(deadline).add(s); + } else { + ArrayList callbacks = new ArrayList(); + callbacks.add(s); + Timers.put(deadline, callbacks); + } + + return s; + } + + public long startTcpServer (SocketAddress sa) throws EmReactorException { + try { + ServerSocketChannel server = ServerSocketChannel.open(); + server.configureBlocking(false); + server.socket().bind (sa); + long s = createBinding(); + Acceptors.put(s, server); + server.register(mySelector, SelectionKey.OP_ACCEPT, s); + return s; + } catch (IOException e) { + throw new EmReactorException ("unable to open socket acceptor: " + e.toString()); + } + } + + public long startTcpServer (String address, int port) throws EmReactorException { + return startTcpServer (new InetSocketAddress (address, port)); + } + + public void stopTcpServer (long signature) throws IOException { + ServerSocketChannel server = Acceptors.remove(signature); + if (server != null) + server.close(); + else + throw new RuntimeException ("failed to close unknown acceptor"); + } + + public long openUdpSocket (InetSocketAddress address) throws IOException { + // TODO, don't throw an exception out of here. + DatagramChannel dg = DatagramChannel.open(); + dg.configureBlocking(false); + dg.socket().bind(address); + long b = createBinding(); + EventableChannel ec = new EventableDatagramChannel (dg, b, mySelector); + dg.register(mySelector, SelectionKey.OP_READ, ec); + Connections.put(b, ec); + return b; + } + + public long openUdpSocket (String address, int port) throws IOException { + return openUdpSocket (new InetSocketAddress (address, port)); + } + + public void sendData (long sig, ByteBuffer bb) throws IOException { + Connections.get(sig).scheduleOutboundData( bb ); + } + + public void sendData (long sig, byte[] data) throws IOException { + sendData (sig, ByteBuffer.wrap(data)); + } + + public void setCommInactivityTimeout (long sig, long mills) { + Connections.get(sig).setCommInactivityTimeout (mills); + } + + public void sendDatagram (long sig, byte[] data, int length, String recipAddress, int recipPort) { + sendDatagram (sig, ByteBuffer.wrap(data), recipAddress, recipPort); + } + + public void sendDatagram (long sig, ByteBuffer bb, String recipAddress, int recipPort) { + (Connections.get(sig)).scheduleOutboundDatagram( bb, recipAddress, recipPort); + } + + public long connectTcpServer (String address, int port) { + return connectTcpServer(null, 0, address, port); + } + + public long connectTcpServer (String bindAddr, int bindPort, String address, int port) { + long b = createBinding(); + + try { + SocketChannel sc = SocketChannel.open(); + sc.configureBlocking(false); + if (bindAddr != null) + sc.socket().bind(new InetSocketAddress (bindAddr, bindPort)); + + EventableSocketChannel ec = new EventableSocketChannel (sc, b, mySelector); + + if (sc.connect (new InetSocketAddress (address, port))) { + // Connection returned immediately. Can happen with localhost connections. + // WARNING, this code is untested due to lack of available test conditions. + // Ought to be be able to come here from a localhost connection, but that + // doesn't happen on Linux. (Maybe on FreeBSD?) + // The reason for not handling this until we can test it is that we + // really need to return from this function WITHOUT triggering any EM events. + // That's because until the user code has seen the signature we generated here, + // it won't be able to properly dispatch them. The C++ EM deals with this + // by setting pending mode as a flag in ALL eventable descriptors and making + // the descriptor select for writable. Then, it can send UNBOUND and + // CONNECTION_COMPLETED on the next pass through the loop, because writable will + // fire. + throw new RuntimeException ("immediate-connect unimplemented"); + } + else { + ec.setConnectPending(); + Connections.put (b, ec); + NewConnections.add (b); + } + } catch (IOException e) { + // Can theoretically come here if a connect failure can be determined immediately. + // I don't know how to make that happen for testing purposes. + throw new RuntimeException ("immediate-connect unimplemented: " + e.toString()); + } + return b; + } + + public void closeConnection (long sig, boolean afterWriting) { + EventableChannel ec = Connections.get(sig); + if (ec != null) + if (ec.scheduleClose (afterWriting)) + UnboundConnections.add (sig); + } + + long createBinding() { + return ++BindingIndex; + } + + public void signalLoopbreak() { + loopBreaker.set(true); + if (mySelector != null) + mySelector.wakeup(); + } + + public void startTls (long sig) throws NoSuchAlgorithmException, KeyManagementException { + Connections.get(sig).startTls(); + } + + public void setTimerQuantum (int mills) { + if (mills < 5 || mills > 2500) + throw new RuntimeException ("attempt to set invalid timer-quantum value: "+mills); + timerQuantum = mills; + } + + public Object[] getPeerName (long sig) { + EventableChannel channel = Connections.get(sig); + if (channel != null) { + return Connections.get(sig).getPeerName(); + } + else { + ServerSocketChannel acceptor = Acceptors.get(sig); + return new Object[] { acceptor.socket().getLocalPort(), + acceptor.socket().getInetAddress().getHostAddress() }; + } + } + + public Object[] getSockName (long sig) { + EventableChannel channel = Connections.get(sig); + if (channel != null) { + return Connections.get(sig).getSockName(); + } + else { + ServerSocketChannel acceptor = Acceptors.get(sig); + return new Object[] { acceptor.socket().getLocalPort(), + acceptor.socket().getInetAddress().getHostAddress() }; + } + } + + public long attachChannel (SocketChannel sc, boolean watch_mode) { + long b = createBinding(); + + EventableSocketChannel ec = new EventableSocketChannel (sc, b, mySelector); + + ec.setAttached(); + if (watch_mode) + ec.setWatchOnly(); + + Connections.put (b, ec); + NewConnections.add (b); + + return b; + } + + public SocketChannel detachChannel (long sig) { + EventableSocketChannel ec = (EventableSocketChannel) Connections.get (sig); + if (ec != null) { + UnboundConnections.add (sig); + return ec.getChannel(); + } else { + return null; + } + } + + public void setNotifyReadable (long sig, boolean mode) { + ((EventableSocketChannel) Connections.get(sig)).setNotifyReadable(mode); + } + + public void setNotifyWritable (long sig, boolean mode) { + ((EventableSocketChannel) Connections.get(sig)).setNotifyWritable(mode); + } + + public boolean isNotifyReadable (long sig) { + return Connections.get(sig).isNotifyReadable(); + } + + public boolean isNotifyWritable (long sig) { + return Connections.get(sig).isNotifyWritable(); + } + + public boolean pauseConnection (long sig) { + return ((EventableSocketChannel) Connections.get(sig)).pause(); + } + + public boolean resumeConnection (long sig) { + return ((EventableSocketChannel) Connections.get(sig)).resume(); + } + + public boolean isConnectionPaused (long sig) { + return ((EventableSocketChannel) Connections.get(sig)).isPaused(); + } + + public long getOutboundDataSize (long sig) { + return Connections.get(sig).getOutboundDataSize(); + } + + public int getConnectionCount() { + return Connections.size() + Acceptors.size(); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EmReactorException.java b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EmReactorException.java new file mode 100644 index 0000000..69efaa3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EmReactorException.java @@ -0,0 +1,40 @@ +/** + * $Id$ + * + * Author:: Francis Cianfrocca (gmail: blackhedd) + * Homepage:: http://rubyeventmachine.com + * Date:: 15 Jul 2007 + * + * See EventMachine and EventMachine::Connection for documentation and + * usage examples. + * + * + *---------------------------------------------------------------------------- + * + * Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. + * Gmail: blackhedd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of either: 1) the GNU General Public License + * as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version; or 2) Ruby's License. + * + * See the file COPYING for complete licensing information. + * + *--------------------------------------------------------------------------- + * + * + */ + +package com.rubyeventmachine; + +/** + * @author francis + * + */ +public class EmReactorException extends Exception { + static final long serialVersionUID = 0; + public EmReactorException (String msg) { + super (msg); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableChannel.java b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableChannel.java new file mode 100644 index 0000000..3d4f5fd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableChannel.java @@ -0,0 +1,72 @@ +/** + * $Id$ + * + * Author:: Francis Cianfrocca (gmail: blackhedd) + * Homepage:: http://rubyeventmachine.com + * Date:: 15 Jul 2007 + * + * See EventMachine and EventMachine::Connection for documentation and + * usage examples. + * + * + *---------------------------------------------------------------------------- + * + * Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. + * Gmail: blackhedd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of either: 1) the GNU General Public License + * as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version; or 2) Ruby's License. + * + * See the file COPYING for complete licensing information. + * + *--------------------------------------------------------------------------- + * + * + */ + + +package com.rubyeventmachine; + +import java.nio.ByteBuffer; +import java.io.IOException; +import java.nio.channels.ClosedChannelException; + +public interface EventableChannel { + + public void scheduleOutboundData (ByteBuffer bb); + + public void scheduleOutboundDatagram (ByteBuffer bb, String recipAddress, int recipPort); + + public boolean scheduleClose (boolean afterWriting); + + public void startTls(); + + public long getBinding(); + + public void readInboundData (ByteBuffer dst) throws IOException; + + public void register() throws ClosedChannelException; + + /** + * This is called by the reactor after it finishes running. + * The idea is to free network resources. + */ + public void close(); + + public boolean writeOutboundData() throws IOException; + + public long getOutboundDataSize(); + + public void setCommInactivityTimeout (long seconds); + + public Object[] getPeerName(); + public Object[] getSockName(); + + public boolean isWatchOnly(); + + public boolean isNotifyReadable(); + public boolean isNotifyWritable(); + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableDatagramChannel.java b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableDatagramChannel.java new file mode 100644 index 0000000..df1c9fd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableDatagramChannel.java @@ -0,0 +1,201 @@ +/** + * $Id$ + * + * Author:: Francis Cianfrocca (gmail: blackhedd) + * Homepage:: http://rubyeventmachine.com + * Date:: 15 Jul 2007 + * + * See EventMachine and EventMachine::Connection for documentation and + * usage examples. + * + * + *---------------------------------------------------------------------------- + * + * Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. + * Gmail: blackhedd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of either: 1) the GNU General Public License + * as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version; or 2) Ruby's License. + * + * See the file COPYING for complete licensing information. + * + *--------------------------------------------------------------------------- + * + * + */ + + +package com.rubyeventmachine; + +import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.DatagramChannel; +import java.util.LinkedList; +import java.io.*; +import java.net.*; + +public class EventableDatagramChannel implements EventableChannel { + + class Packet { + public ByteBuffer bb; + public SocketAddress recipient; + public Packet (ByteBuffer _bb, SocketAddress _recipient) { + bb = _bb; + recipient = _recipient; + } + } + + DatagramChannel channel; + long binding; + Selector selector; + boolean bCloseScheduled; + LinkedList outboundQ; + long outboundS; + SocketAddress returnAddress; + + + public EventableDatagramChannel (DatagramChannel dc, long _binding, Selector sel) throws ClosedChannelException { + channel = dc; + binding = _binding; + selector = sel; + bCloseScheduled = false; + outboundQ = new LinkedList(); + outboundS = 0; + + dc.register(selector, SelectionKey.OP_READ, this); + } + + public void scheduleOutboundData (ByteBuffer bb) { + try { + if ((!bCloseScheduled) && (bb.remaining() > 0)) { + outboundQ.addLast(new Packet(bb, returnAddress)); + outboundS += bb.remaining(); + channel.register(selector, SelectionKey.OP_WRITE | SelectionKey.OP_READ, this); + } + } catch (ClosedChannelException e) { + throw new RuntimeException ("no outbound data"); + } + } + + public void scheduleOutboundDatagram (ByteBuffer bb, String recipAddress, int recipPort) { + try { + if ((!bCloseScheduled) && (bb.remaining() > 0)) { + outboundQ.addLast(new Packet (bb, new InetSocketAddress (recipAddress, recipPort))); + outboundS += bb.remaining(); + channel.register(selector, SelectionKey.OP_WRITE | SelectionKey.OP_READ, this); + } + } catch (ClosedChannelException e) { + throw new RuntimeException ("no outbound data"); + } + } + + public boolean scheduleClose (boolean afterWriting) { + System.out.println ("NOT SCHEDULING CLOSE ON DATAGRAM"); + return false; + } + + public void startTls() { + throw new RuntimeException ("TLS is unimplemented on this Channel"); + } + + public long getBinding() { + return binding; + } + + public void register() throws ClosedChannelException { + // TODO + } + + /** + * Terminate with extreme prejudice. Don't assume there will be another pass through + * the reactor core. + */ + public void close() { + try { + channel.close(); + } catch (IOException e) { + } + } + + public void readInboundData (ByteBuffer dst) { + returnAddress = null; + try { + // If there is no datagram available (we're nonblocking after all), + // then channel.receive returns null. + returnAddress = channel.receive(dst); + } catch (IOException e) { + // probably a no-op. The caller will see the empty (or even partial) buffer + // and presumably do the right thing. + } + } + + public boolean writeOutboundData() { + while (!outboundQ.isEmpty()) { + Packet p = outboundQ.getFirst(); + int written = 0; + try { + // With a datagram socket, it's ok to send an empty buffer. + written = channel.send(p.bb, p.recipient); + outboundS -= written; + } + catch (IOException e) { + return false; + } + + /* Did we consume the whole outbound buffer? If yes, pop it off and + * keep looping. If no, the outbound network buffers are full, so break + * out of here. There's a flaw that affects outbound buffers that are intentionally + * empty. We can tell whether they got sent or not. So we assume they were. + * TODO: As implemented, this ALWAYS discards packets if they were at least + * partially written. This matches the behavior of the C++ EM. My judgment + * is that this is less surprising than fragmenting the data and sending multiple + * packets would be. I could be wrong, so this is subject to change. + */ + + if ((written > 0) || (p.bb.remaining() == 0)) + outboundQ.removeFirst(); + else + break; + } + + if (outboundQ.isEmpty()) { + try { + channel.register(selector, SelectionKey.OP_READ, this); + } catch (ClosedChannelException e) {} + } + + // ALWAYS drain the outbound queue before triggering a connection close. + // If anyone wants to close immediately, they're responsible for clearing + // the outbound queue. + return (bCloseScheduled && outboundQ.isEmpty()) ? false : true; + } + + public void setCommInactivityTimeout (long seconds) { + // TODO + System.out.println ("DATAGRAM: SET COMM INACTIVITY UNIMPLEMENTED " + seconds); + } + + public Object[] getPeerName () { + if (returnAddress != null) { + InetSocketAddress inetAddr = (InetSocketAddress) returnAddress; + return new Object[]{ inetAddr.getPort(), inetAddr.getHostName() }; + } else { + return null; + } + } + + public Object[] getSockName () { + DatagramSocket socket = channel.socket(); + return new Object[]{ socket.getLocalPort(), + socket.getLocalAddress().getHostAddress() }; + } + + public boolean isWatchOnly() { return false; } + public boolean isNotifyReadable() { return false; } + public boolean isNotifyWritable() { return false; } + public long getOutboundDataSize() { return outboundS; } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableSocketChannel.java b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableSocketChannel.java new file mode 100644 index 0000000..2905ec6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/java/src/com/rubyeventmachine/EventableSocketChannel.java @@ -0,0 +1,415 @@ +/** + * $Id$ + * + * Author:: Francis Cianfrocca (gmail: blackhedd) + * Homepage:: http://rubyeventmachine.com + * Date:: 15 Jul 2007 + * + * See EventMachine and EventMachine::Connection for documentation and + * usage examples. + * + * + *---------------------------------------------------------------------------- + * + * Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. + * Gmail: blackhedd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of either: 1) the GNU General Public License + * as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version; or 2) Ruby's License. + * + * See the file COPYING for complete licensing information. + * + *--------------------------------------------------------------------------- + * + * + */ + +/** + * + */ +package com.rubyeventmachine; + +/** + * @author francis + * + */ + +import java.nio.channels.*; +import java.nio.*; +import java.util.*; +import java.io.*; +import java.net.Socket; +import javax.net.ssl.*; +import javax.net.ssl.SSLEngineResult.*; +import java.lang.reflect.Field; + +import java.security.*; + +public class EventableSocketChannel implements EventableChannel { + Selector selector; + SelectionKey channelKey; + SocketChannel channel; + + long binding; + LinkedList outboundQ; + long outboundS; + + boolean bCloseScheduled; + boolean bConnectPending; + boolean bWatchOnly; + boolean bAttached; + boolean bNotifyReadable; + boolean bNotifyWritable; + boolean bPaused; + + SSLEngine sslEngine; + SSLContext sslContext; + + public EventableSocketChannel (SocketChannel sc, long _binding, Selector sel) { + channel = sc; + binding = _binding; + selector = sel; + bCloseScheduled = false; + bConnectPending = false; + bWatchOnly = false; + bAttached = false; + bNotifyReadable = false; + bNotifyWritable = false; + outboundQ = new LinkedList(); + outboundS = 0; + } + + public long getBinding() { + return binding; + } + + public SocketChannel getChannel() { + return channel; + } + + public void register() throws ClosedChannelException { + if (channelKey == null) { + int events = currentEvents(); + channelKey = channel.register(selector, events, this); + } + } + + /** + * Terminate with extreme prejudice. Don't assume there will be another pass through + * the reactor core. + */ + public void close() { + if (channelKey != null) { + channelKey.cancel(); + channelKey = null; + } + + if (bAttached) { + // attached channels are copies, so reset the file descriptor to prevent java from close()ing it + Field f; + FileDescriptor fd; + + try { + /* do _NOT_ clobber fdVal here, it will break epoll/kqueue on jdk6! + * channelKey.cancel() above does not occur until the next call to select + * and if fdVal is gone, we will continue to get events for this fd. + * + * instead, remove fdVal in cleanup(), which is processed via DetachedConnections, + * after UnboundConnections but before NewConnections. + */ + + f = channel.getClass().getDeclaredField("fd"); + f.setAccessible(true); + fd = (FileDescriptor) f.get(channel); + + f = fd.getClass().getDeclaredField("fd"); + f.setAccessible(true); + f.set(fd, -1); + } catch (java.lang.NoSuchFieldException e) { + e.printStackTrace(); + } catch (java.lang.IllegalAccessException e) { + e.printStackTrace(); + } + + return; + } + + try { + channel.close(); + } catch (IOException e) { + } + } + + public void cleanup() { + if (bAttached) { + Field f; + try { + f = channel.getClass().getDeclaredField("fdVal"); + f.setAccessible(true); + f.set(channel, -1); + } catch (java.lang.NoSuchFieldException e) { + e.printStackTrace(); + } catch (java.lang.IllegalAccessException e) { + e.printStackTrace(); + } + } + + channel = null; + } + + public void scheduleOutboundData (ByteBuffer bb) { + if (!bCloseScheduled && bb.remaining() > 0) { + if (sslEngine != null) { + try { + ByteBuffer b = ByteBuffer.allocate(32*1024); // TODO, preallocate this buffer. + sslEngine.wrap(bb, b); + b.flip(); + outboundQ.addLast(b); + outboundS += b.remaining(); + } catch (SSLException e) { + throw new RuntimeException ("ssl error"); + } + } + else { + outboundQ.addLast(bb); + outboundS += bb.remaining(); + } + + updateEvents(); + } + } + + public void scheduleOutboundDatagram (ByteBuffer bb, String recipAddress, int recipPort) { + throw new RuntimeException ("datagram sends not supported on this channel"); + } + + /** + * Called by the reactor when we have selected readable. + */ + public void readInboundData (ByteBuffer bb) throws IOException { + if (channel.read(bb) == -1) + throw new IOException ("eof"); + } + + public long getOutboundDataSize() { return outboundS; } + + /** + * Called by the reactor when we have selected writable. + * Return false to indicate an error that should cause the connection to close. + * TODO, VERY IMPORTANT: we're here because we selected writable, but it's always + * possible to become unwritable between the poll and when we get here. The way + * this code is written, we're depending on a nonblocking write NOT TO CONSUME + * the whole outbound buffer in this case, rather than firing an exception. + * We should somehow verify that this is indeed Java's defined behavior. + * @return + */ + public boolean writeOutboundData() throws IOException { + ByteBuffer[] bufs = new ByteBuffer[64]; + int i; + long written, toWrite; + while (!outboundQ.isEmpty()) { + i = 0; + toWrite = 0; + written = 0; + while (i < 64 && !outboundQ.isEmpty()) { + bufs[i] = outboundQ.removeFirst(); + toWrite += bufs[i].remaining(); + i++; + } + if (toWrite > 0) + written = channel.write(bufs, 0, i); + + outboundS -= written; + // Did we consume the whole outbound buffer? If yes, + // pop it off and keep looping. If no, the outbound network + // buffers are full, so break out of here. + if (written < toWrite) { + while (i > 0 && bufs[i-1].remaining() > 0) { + outboundQ.addFirst(bufs[i-1]); + i--; + } + break; + } + } + + if (outboundQ.isEmpty() && !bCloseScheduled) { + updateEvents(); + } + + // ALWAYS drain the outbound queue before triggering a connection close. + // If anyone wants to close immediately, they're responsible for clearing + // the outbound queue. + return (bCloseScheduled && outboundQ.isEmpty()) ? false : true; + } + + public void setConnectPending() { + bConnectPending = true; + updateEvents(); + } + + /** + * Called by the reactor when we have selected connectable. + * Return false to indicate an error that should cause the connection to close. + */ + public boolean finishConnecting() throws IOException { + channel.finishConnect(); + + bConnectPending = false; + updateEvents(); + return true; + } + + public boolean scheduleClose (boolean afterWriting) { + // TODO: What the hell happens here if bConnectPending is set? + if (!afterWriting) { + outboundQ.clear(); + outboundS = 0; + } + + if (outboundQ.isEmpty()) + return true; + else { + updateEvents(); + bCloseScheduled = true; + return false; + } + } + + public void startTls() { + if (sslEngine == null) { + try { + sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, null, null); // TODO, fill in the parameters. + sslEngine = sslContext.createSSLEngine(); // TODO, should use the parameterized version, to get Kerb stuff and session re-use. + sslEngine.setUseClientMode(false); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException ("unable to start TLS"); // TODO, get rid of this. + } catch (KeyManagementException e) { + throw new RuntimeException ("unable to start TLS"); // TODO, get rid of this. + } + } + System.out.println ("Starting TLS"); + } + + public ByteBuffer dispatchInboundData (ByteBuffer bb) throws SSLException { + if (sslEngine != null) { + if (true) throw new RuntimeException ("TLS currently unimplemented"); + System.setProperty("javax.net.debug", "all"); + ByteBuffer w = ByteBuffer.allocate(32*1024); // TODO, WRONG, preallocate this buffer. + SSLEngineResult res = sslEngine.unwrap(bb, w); + if (res.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable r; + while ((r = sslEngine.getDelegatedTask()) != null) { + r.run(); + } + } + System.out.println (bb); + w.flip(); + return w; + } + else + return bb; + } + + public void setCommInactivityTimeout (long seconds) { + // TODO + System.out.println ("SOCKET: SET COMM INACTIVITY UNIMPLEMENTED " + seconds); + } + + public Object[] getPeerName () { + Socket sock = channel.socket(); + return new Object[]{ sock.getPort(), sock.getInetAddress().getHostAddress() }; + } + + public Object[] getSockName () { + Socket sock = channel.socket(); + return new Object[]{ sock.getLocalPort(), + sock.getLocalAddress().getHostAddress() }; + } + + public void setWatchOnly() { + bWatchOnly = true; + updateEvents(); + } + public boolean isWatchOnly() { return bWatchOnly; } + + public void setAttached() { + bAttached = true; + } + public boolean isAttached() { return bAttached; } + + public void setNotifyReadable (boolean mode) { + bNotifyReadable = mode; + updateEvents(); + } + public boolean isNotifyReadable() { return bNotifyReadable; } + + public void setNotifyWritable (boolean mode) { + bNotifyWritable = mode; + updateEvents(); + } + public boolean isNotifyWritable() { return bNotifyWritable; } + + public boolean pause() { + if (bWatchOnly) { + throw new RuntimeException ("cannot pause/resume 'watch only' connections, set notify readable/writable instead"); + } + boolean old = bPaused; + bPaused = true; + updateEvents(); + return !old; + } + + public boolean resume() { + if (bWatchOnly) { + throw new RuntimeException ("cannot pause/resume 'watch only' connections, set notify readable/writable instead"); + } + boolean old = bPaused; + bPaused = false; + updateEvents(); + return old; + } + + public boolean isPaused() { + return bPaused; + } + + private void updateEvents() { + if (channelKey == null) + return; + + int events = currentEvents(); + + if (channelKey.interestOps() != events) { + channelKey.interestOps(events); + } + } + + private int currentEvents() { + int events = 0; + + if (bWatchOnly) + { + if (bNotifyReadable) + events |= SelectionKey.OP_READ; + + if (bNotifyWritable) + events |= SelectionKey.OP_WRITE; + } + else if (!bPaused) + { + if (bConnectPending) + events |= SelectionKey.OP_CONNECT; + else { + events |= SelectionKey.OP_READ; + + if (!outboundQ.isEmpty()) + events |= SelectionKey.OP_WRITE; + } + } + + return events; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/buftok.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/buftok.rb new file mode 100644 index 0000000..caf4f77 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/buftok.rb @@ -0,0 +1,59 @@ +# BufferedTokenizer takes a delimiter upon instantiation, or acts line-based +# by default. It allows input to be spoon-fed from some outside source which +# receives arbitrary length datagrams which may-or-may-not contain the token +# by which entities are delimited. In this respect it's ideally paired with +# something like EventMachine (http://rubyeventmachine.com/). +class BufferedTokenizer + # New BufferedTokenizers will operate on lines delimited by a delimiter, + # which is by default the global input delimiter $/ ("\n"). + # + # The input buffer is stored as an array. This is by far the most efficient + # approach given language constraints (in C a linked list would be a more + # appropriate data structure). Segments of input data are stored in a list + # which is only joined when a token is reached, substantially reducing the + # number of objects required for the operation. + def initialize(delimiter = $/) + @delimiter = delimiter + @input = [] + @tail = '' + @trim = @delimiter.length - 1 + end + + # Extract takes an arbitrary string of input data and returns an array of + # tokenized entities, provided there were any available to extract. This + # makes for easy processing of datagrams using a pattern like: + # + # tokenizer.extract(data).map { |entity| Decode(entity) }.each do ... + # + # Using -1 makes split to return "" if the token is at the end of + # the string, meaning the last element is the start of the next chunk. + def extract(data) + if @trim > 0 + tail_end = @tail.slice!(-@trim, @trim) # returns nil if string is too short + data = tail_end + data if tail_end + end + + @input << @tail + entities = data.split(@delimiter, -1) + @tail = entities.shift + + unless entities.empty? + @input << @tail + entities.unshift @input.join + @input.clear + @tail = entities.pop + end + + entities + end + + # Flush the contents of the input buffer, i.e. return the input buffer even though + # a token has not yet been encountered + def flush + @input << @tail + buffer = @input.join + @input.clear + @tail = "" # @tail.clear is slightly faster, but not supported on 1.8.7 + buffer + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/callback.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/callback.rb new file mode 100644 index 0000000..4928feb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/callback.rb @@ -0,0 +1,58 @@ +module EventMachine + # Utility method for coercing arguments to an object that responds to :call. + # Accepts an object and a method name to send to, or a block, or an object + # that responds to :call. + # + # @example EventMachine.Callback used with a block. Returns that block. + # + # cb = EventMachine.Callback do |msg| + # puts(msg) + # end + # # returned object is a callable + # cb.call('hello world') + # + # + # @example EventMachine.Callback used with an object (to be more specific, class object) and a method name, returns an object that responds to #call + # + # cb = EventMachine.Callback(Object, :puts) + # # returned object is a callable that delegates to Kernel#puts (in this case Object.puts) + # cb.call('hello world') + # + # + # @example EventMachine.Callback used with an object that responds to #call. Returns the argument. + # + # cb = EventMachine.Callback(proc{ |msg| puts(msg) }) + # # returned object is a callable + # cb.call('hello world') + # + # + # @overload Callback(object, method) + # Wraps `method` invocation on `object` into an object that responds to #call that proxies all the arguments to that method + # @param [Object] Object to invoke method on + # @param [Symbol] Method name + # @return [<#call>] An object that responds to #call that takes any number of arguments and invokes method on object with those arguments + # + # @overload Callback(object) + # Returns callable object as is, without any coercion + # @param [<#call>] An object that responds to #call + # @return [<#call>] Its argument + # + # @overload Callback(&block) + # Returns block passed to it without any coercion + # @return [<#call>] Block passed to this method + # + # @raise [ArgumentError] When argument doesn't respond to #call, method name is missing or when invoked without arguments and block isn't given + # + # @return [<#call>] + def self.Callback(object = nil, method = nil, &blk) + if object && method + lambda { |*args| object.__send__ method, *args } + else + if object.respond_to? :call + object + else + blk || raise(ArgumentError) + end # if + end # if + end # self.Callback +end # EventMachine diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/channel.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/channel.rb new file mode 100644 index 0000000..a919adf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/channel.rb @@ -0,0 +1,69 @@ +module EventMachine + # Provides a simple thread-safe way to transfer data between (typically) long running + # tasks in {EventMachine.defer} and event loop thread. + # + # @example + # + # channel = EventMachine::Channel.new + # sid = channel.subscribe { |msg| p [:got, msg] } + # + # channel.push('hello world') + # channel.unsubscribe(sid) + # + # + class Channel + def initialize + @subs = {} + @uid = 0 + end + + # Return the number of current subscribers. + def num_subscribers + return @subs.size + end + + # Takes any arguments suitable for EM::Callback() and returns a subscriber + # id for use when unsubscribing. + # + # @return [Integer] Subscribe identifier + # @see #unsubscribe + def subscribe(*a, &b) + name = gen_id + EM.schedule { @subs[name] = EM::Callback(*a, &b) } + + name + end + + # Removes subscriber from the list. + # + # @param [Integer] Subscriber identifier + # @see #subscribe + def unsubscribe(name) + EM.schedule { @subs.delete name } + end + + # Add items to the channel, which are pushed out to all subscribers. + def push(*items) + items = items.dup + EM.schedule { items.each { |i| @subs.values.each { |s| s.call i } } } + end + alias << push + + # Fetches one message from the channel. + def pop(*a, &b) + EM.schedule { + name = subscribe do |*args| + unsubscribe(name) + EM::Callback(*a, &b).call(*args) + end + } + end + + private + + # @private + def gen_id + @uid += 1 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/completion.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/completion.rb new file mode 100644 index 0000000..926535f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/completion.rb @@ -0,0 +1,304 @@ +# = EM::Completion +# +# A completion is a callback container for various states of completion. In +# its most basic form it has a start state and a finish state. +# +# This implementation includes some hold-back from the EM::Deferrable +# interface in order to be compatible - but it has a much cleaner +# implementation. +# +# In general it is preferred that this implementation be used as a state +# callback container than EM::DefaultDeferrable or other classes including +# EM::Deferrable. This is because it is generally more sane to keep this level +# of state in a dedicated state-back container. This generally leads to more +# malleable interfaces and software designs, as well as eradicating nasty bugs +# that result from abstraction leakage. +# +# == Basic Usage +# +# As already mentioned, the basic usage of a Completion is simply for its two +# final states, :succeeded and :failed. +# +# An asynchronous operation will complete at some future point in time, and +# users often want to react to this event. API authors will want to expose +# some common interface to react to these events. +# +# In the following example, the user wants to know when a short lived +# connection has completed its exchange with the remote server. The simple +# protocol just waits for an ack to its message. +# +# class Protocol < EM::Connection +# include EM::P::LineText2 +# +# def initialize(message, completion) +# @message, @completion = message, completion +# @completion.completion { close_connection } +# @completion.timeout(1, :timeout) +# end +# +# def post_init +# send_data(@message) +# end +# +# def receive_line(line) +# case line +# when /ACK/i +# @completion.succeed line +# when /ERR/i +# @completion.fail :error, line +# else +# @completion.fail :unknown, line +# end +# end +# +# def unbind +# @completion.fail :disconnected unless @completion.completed? +# end +# end +# +# class API +# attr_reader :host, :port +# +# def initialize(host = 'example.org', port = 8000) +# @host, @port = host, port +# end +# +# def request(message) +# completion = EM::Deferrable::Completion.new +# EM.connect(host, port, Protocol, message, completion) +# completion +# end +# end +# +# api = API.new +# completion = api.request('stuff') +# completion.callback do |line| +# puts "API responded with: #{line}" +# end +# completion.errback do |type, line| +# case type +# when :error +# puts "API error: #{line}" +# when :unknown +# puts "API returned unknown response: #{line}" +# when :disconnected +# puts "API server disconnected prematurely" +# when :timeout +# puts "API server did not respond in a timely fashion" +# end +# end +# +# == Advanced Usage +# +# This completion implementation also supports more state callbacks and +# arbitrary states (unlike the original Deferrable API). This allows for basic +# stateful process encapsulation. One might use this to setup state callbacks +# for various states in an exchange like in the basic usage example, except +# where the applicaiton could be made to react to "connected" and +# "disconnected" states additionally. +# +# class Protocol < EM::Connection +# def initialize(completion) +# @response = [] +# @completion = completion +# @completion.stateback(:disconnected) do +# @completion.succeed @response.join +# end +# end +# +# def connection_completed +# @host, @port = Socket.unpack_sockaddr_in get_peername +# @completion.change_state(:connected, @host, @port) +# send_data("GET http://example.org/ HTTP/1.0\r\n\r\n") +# end +# +# def receive_data(data) +# @response << data +# end +# +# def unbind +# @completion.change_state(:disconnected, @host, @port) +# end +# end +# +# completion = EM::Deferrable::Completion.new +# completion.stateback(:connected) do |host, port| +# puts "Connected to #{host}:#{port}" +# end +# completion.stateback(:disconnected) do |host, port| +# puts "Disconnected from #{host}:#{port}" +# end +# completion.callback do |response| +# puts response +# end +# +# EM.connect('example.org', 80, Protocol, completion) +# +# == Timeout +# +# The Completion also has a timeout. The timeout is global and is not aware of +# states apart from completion states. The timeout is only engaged if #timeout +# is called, and it will call fail if it is reached. +# +# == Completion states +# +# By default there are two completion states, :succeeded and :failed. These +# states can be modified by subclassing and overrding the #completion_states +# method. Completion states are special, in that callbacks for all completion +# states are explcitly cleared when a completion state is entered. This +# prevents errors that could arise from accidental unterminated timeouts, and +# other such user errors. +# +# == Other notes +# +# Several APIs have been carried over from EM::Deferrable for compatibility +# reasons during a transitionary period. Specifically cancel_errback and +# cancel_callback are implemented, but their usage is to be strongly +# discouraged. Due to the already complex nature of reaction systems, dynamic +# callback deletion only makes the problem much worse. It is always better to +# add correct conditionals to the callback code, or use more states, than to +# address such implementaiton issues with conditional callbacks. + +module EventMachine + + class Completion + # This is totally not used (re-implemented), it's here in case people check + # for kind_of? + include EventMachine::Deferrable + + attr_reader :state, :value + + def initialize + @state = :unknown + @callbacks = Hash.new { |h,k| h[k] = [] } + @value = [] + @timeout_timer = nil + end + + # Enter the :succeeded state, setting the result value if given. + def succeed(*args) + change_state(:succeeded, *args) + end + # The old EM method: + alias set_deferred_success succeed + + # Enter the :failed state, setting the result value if given. + def fail(*args) + change_state(:failed, *args) + end + # The old EM method: + alias set_deferred_failure fail + + # Statebacks are called when you enter (or are in) the named state. + def stateback(state, *a, &b) + # The following is quite unfortunate special casing for :completed + # statebacks, but it's a necessary evil for latent completion + # definitions. + + if :completed == state || !completed? || @state == state + @callbacks[state] << EM::Callback(*a, &b) + end + execute_callbacks + self + end + + # Callbacks are called when you enter (or are in) a :succeeded state. + def callback(*a, &b) + stateback(:succeeded, *a, &b) + end + + # Errbacks are called when you enter (or are in) a :failed state. + def errback(*a, &b) + stateback(:failed, *a, &b) + end + + # Completions are called when you enter (or are in) either a :failed or a + # :succeeded state. They are stored as a special (reserved) state called + # :completed. + def completion(*a, &b) + stateback(:completed, *a, &b) + end + + # Enter a new state, setting the result value if given. If the state is one + # of :succeeded or :failed, then :completed callbacks will also be called. + def change_state(state, *args) + @value = args + @state = state + + EM.schedule { execute_callbacks } + end + + # The old EM method: + alias set_deferred_status change_state + + # Indicates that we've reached some kind of completion state, by default + # this is :succeeded or :failed. Due to these semantics, the :completed + # state is reserved for internal use. + def completed? + completion_states.any? { |s| state == s } + end + + # Completion states simply returns a list of completion states, by default + # this is :succeeded and :failed. + def completion_states + [:succeeded, :failed] + end + + # Schedule a time which if passes before we enter a completion state, this + # deferrable will be failed with the given arguments. + def timeout(time, *args) + cancel_timeout + @timeout_timer = EM::Timer.new(time) do + fail(*args) unless completed? + end + end + + # Disable the timeout + def cancel_timeout + if @timeout_timer + @timeout_timer.cancel + @timeout_timer = nil + end + end + + # Remove an errback. N.B. Some errbacks cannot be deleted. Usage is NOT + # recommended, this is an anti-pattern. + def cancel_errback(*a, &b) + @callbacks[:failed].delete(EM::Callback(*a, &b)) + end + + # Remove a callback. N.B. Some callbacks cannot be deleted. Usage is NOT + # recommended, this is an anti-pattern. + def cancel_callback(*a, &b) + @callbacks[:succeeded].delete(EM::Callback(*a, &b)) + end + + private + # Execute all callbacks for the current state. If in a completed state, then + # call any statebacks associated with the completed state. + def execute_callbacks + execute_state_callbacks(state) + if completed? + execute_state_callbacks(:completed) + clear_dead_callbacks + cancel_timeout + end + end + + # Iterate all callbacks for a given state, and remove then call them. + def execute_state_callbacks(state) + while callback = @callbacks[state].shift + callback.call(*value) + end + end + + # If we enter a completion state, clear other completion states after all + # callback chains are completed. This means that operation specific + # callbacks can't be dual-called, which is most common user error. + def clear_dead_callbacks + completion_states.each do |state| + @callbacks[state].clear + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/connection.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/connection.rb new file mode 100644 index 0000000..267aec2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/connection.rb @@ -0,0 +1,770 @@ +module EventMachine + class FileNotFoundException < Exception + end + + # EventMachine::Connection is a class that is instantiated + # by EventMachine's processing loop whenever a new connection + # is created. (New connections can be either initiated locally + # to a remote server or accepted locally from a remote client.) + # When a Connection object is instantiated, it mixes in + # the functionality contained in the user-defined module + # specified in calls to {EventMachine.connect} or {EventMachine.start_server}. + # User-defined handler modules may redefine any or all of the standard + # methods defined here, as well as add arbitrary additional code + # that will also be mixed in. + # + # EventMachine manages one object inherited from EventMachine::Connection + # (and containing the mixed-in user code) for every network connection + # that is active at any given time. + # The event loop will automatically call methods on EventMachine::Connection + # objects whenever specific events occur on the corresponding connections, + # as described below. + # + # This class is never instantiated by user code, and does not publish an + # initialize method. The instance methods of EventMachine::Connection + # which may be called by the event loop are: + # + # * {#post_init} + # * {#connection_completed} + # * {#receive_data} + # * {#unbind} + # * {#ssl_verify_peer} (if TLS is used) + # * {#ssl_handshake_completed} + # + # All of the other instance methods defined here are called only by user code. + # + # @see file:docs/GettingStarted.md EventMachine tutorial + class Connection + # @private + attr_accessor :signature + + # @private + alias original_method method + + # Override .new so subclasses don't have to call super and can ignore + # connection-specific arguments + # + # @private + def self.new(sig, *args) + allocate.instance_eval do + # Store signature + @signature = sig + # associate_callback_target sig + + # Call a superclass's #initialize if it has one + initialize(*args) + + # post initialize callback + post_init + + self + end + end + + # Stubbed initialize so legacy superclasses can safely call super + # + # @private + def initialize(*args) + end + + # Called by the event loop immediately after the network connection has been established, + # and before resumption of the network loop. + # This method is generally not called by user code, but is called automatically + # by the event loop. The base-class implementation is a no-op. + # This is a very good place to initialize instance variables that will + # be used throughout the lifetime of the network connection. + # + # @see #connection_completed + # @see #unbind + # @see #send_data + # @see #receive_data + def post_init + end + + # Called by the event loop whenever data has been received by the network connection. + # It is never called by user code. {#receive_data} is called with a single parameter, a String containing + # the network protocol data, which may of course be binary. You will + # generally redefine this method to perform your own processing of the incoming data. + # + # Here's a key point which is essential to understanding the event-driven + # programming model: EventMachine knows absolutely nothing about the protocol + # which your code implements. You must not make any assumptions about + # the size of the incoming data packets, or about their alignment on any + # particular intra-message or PDU boundaries (such as line breaks). + # receive_data can and will send you arbitrary chunks of data, with the + # only guarantee being that the data is presented to your code in the order + # it was collected from the network. Don't even assume that the chunks of + # data will correspond to network packets, as EventMachine can and will coalesce + # several incoming packets into one, to improve performance. The implication for your + # code is that you generally will need to implement some kind of a state machine + # in your redefined implementation of receive_data. For a better understanding + # of this, read through the examples of specific protocol handlers in EventMachine::Protocols + # + # The base-class implementation (which will be invoked only if you didn't override it in your protocol handler) + # simply prints incoming data packet size to stdout. + # + # @param [String] data Opaque incoming data. + # @note Depending on the protocol, buffer sizes and OS networking stack configuration, incoming data may or may not be "a complete message". + # It is up to this handler to detect content boundaries to determine whether all the content (for example, full HTTP request) + # has been received and can be processed. + # + # @see #post_init + # @see #connection_completed + # @see #unbind + # @see #send_data + # @see file:docs/GettingStarted.md EventMachine tutorial + def receive_data data + puts "............>>>#{data.length}" + end + + # Called by EventMachine when the SSL/TLS handshake has + # been completed, as a result of calling #start_tls to initiate SSL/TLS on the connection. + # + # This callback exists because {#post_init} and {#connection_completed} are **not** reliable + # for indicating when an SSL/TLS connection is ready to have its certificate queried for. + # + # @see #get_peer_cert + def ssl_handshake_completed + end + + # Called by EventMachine when :verify_peer => true has been passed to {#start_tls}. + # It will be called with each certificate in the certificate chain provided by the remote peer. + # + # The cert will be passed as a String in PEM format, the same as in {#get_peer_cert}. It is up to user defined + # code to perform a check on the certificates. The return value from this callback is used to accept or deny the peer. + # A return value that is not nil or false triggers acceptance. If the peer is not accepted, the connection + # will be subsequently closed. + # + # @example This server always accepts all peers + # + # module AcceptServer + # def post_init + # start_tls(:verify_peer => true) + # end + # + # def ssl_verify_peer(cert) + # true + # end + # + # def ssl_handshake_completed + # $server_handshake_completed = true + # end + # end + # + # + # @example This server never accepts any peers + # + # module DenyServer + # def post_init + # start_tls(:verify_peer => true) + # end + # + # def ssl_verify_peer(cert) + # # Do not accept the peer. This should now cause the connection to shut down + # # without the SSL handshake being completed. + # false + # end + # + # def ssl_handshake_completed + # $server_handshake_completed = true + # end + # end + # + # @see #start_tls + def ssl_verify_peer(cert) + end + + # called by the framework whenever a connection (either a server or client connection) is closed. + # The close can occur because your code intentionally closes it (using {#close_connection} and {#close_connection_after_writing}), + # because the remote peer closed the connection, or because of a network error. + # You may not assume that the network connection is still open and able to send or + # receive data when the callback to unbind is made. This is intended only to give + # you a chance to clean up associations your code may have made to the connection + # object while it was open. + # + # If you want to detect which peer has closed the connection, you can override {#close_connection} in your protocol handler + # and set an @ivar. + # + # @example Overriding Connection#close_connection to distinguish connections closed on our side + # + # class MyProtocolHandler < EventMachine::Connection + # + # # ... + # + # def close_connection(*args) + # @intentionally_closed_connection = true + # super(*args) + # end + # + # def unbind + # if @intentionally_closed_connection + # # ... + # end + # end + # + # # ... + # + # end + # + # @see #post_init + # @see #connection_completed + # @see file:docs/GettingStarted.md EventMachine tutorial + def unbind + end + + # Called by the reactor after attempting to relay incoming data to a descriptor (set as a proxy target descriptor with + # {EventMachine.enable_proxy}) that has already been closed. + # + # @see EventMachine.enable_proxy + def proxy_target_unbound + end + + # called when the reactor finished proxying all + # of the requested bytes. + def proxy_completed + end + + # EventMachine::Connection#proxy_incoming_to is called only by user code. It sets up + # a low-level proxy relay for all data inbound for this connection, to the connection given + # as the argument. This is essentially just a helper method for enable_proxy. + # + # @see EventMachine.enable_proxy + def proxy_incoming_to(conn,bufsize=0) + EventMachine::enable_proxy(self, conn, bufsize) + end + + # A helper method for {EventMachine.disable_proxy} + def stop_proxying + EventMachine::disable_proxy(self) + end + + # The number of bytes proxied to another connection. Reset to zero when + # EventMachine::Connection#proxy_incoming_to is called, and incremented whenever data is proxied. + def get_proxied_bytes + EventMachine::get_proxied_bytes(@signature) + end + + # EventMachine::Connection#close_connection is called only by user code, and never + # by the event loop. You may call this method against a connection object in any + # callback handler, whether or not the callback was made against the connection + # you want to close. close_connection schedules the connection to be closed + # at the next available opportunity within the event loop. You may not assume that + # the connection is closed when close_connection returns. In particular, the framework + # will callback the unbind method for the particular connection at a point shortly + # after you call close_connection. You may assume that the unbind callback will + # take place sometime after your call to close_connection completes. In other words, + # the unbind callback will not re-enter your code "inside" of your call to close_connection. + # However, it's not guaranteed that a future version of EventMachine will not change + # this behavior. + # + # {#close_connection} will *silently discard* any outbound data which you have + # sent to the connection using {EventMachine::Connection#send_data} but which has not + # yet been sent across the network. If you want to avoid this behavior, use + # {EventMachine::Connection#close_connection_after_writing}. + # + def close_connection after_writing = false + EventMachine::close_connection @signature, after_writing + end + + # Removes given connection from the event loop. + # The connection's socket remains open and its file descriptor number is returned. + def detach + EventMachine::detach_fd @signature + end + + def get_sock_opt level, option + EventMachine::get_sock_opt @signature, level, option + end + + def set_sock_opt level, optname, optval + EventMachine::set_sock_opt @signature, level, optname, optval + end + + # A variant of {#close_connection}. + # All of the descriptive comments given for close_connection also apply to + # close_connection_after_writing, *with one exception*: if the connection has + # outbound data sent using send_dat but which has not yet been sent across the network, + # close_connection_after_writing will schedule the connection to be closed *after* + # all of the outbound data has been safely written to the remote peer. + # + # Depending on the amount of outgoing data and the speed of the network, + # considerable time may elapse between your call to close_connection_after_writing + # and the actual closing of the socket (at which time the unbind callback will be called + # by the event loop). During this time, you *may not* call send_data to transmit + # additional data (that is, the connection is closed for further writes). In very + # rare cases, you may experience a receive_data callback after your call to {#close_connection_after_writing}, + # depending on whether incoming data was in the process of being received on the connection + # at the moment when you called {#close_connection_after_writing}. Your protocol handler must + # be prepared to properly deal with such data (probably by ignoring it). + # + # @see #close_connection + # @see #send_data + def close_connection_after_writing + close_connection true + end + + # Call this method to send data to the remote end of the network connection. It takes a single String argument, + # which may contain binary data. Data is buffered to be sent at the end of this event loop tick (cycle). + # + # When used in a method that is event handler (for example, {#post_init} or {#connection_completed}, it will send + # data to the other end of the connection that generated the event. + # You can also call {#send_data} to write to other connections. For more information see The Chat Server Example in the + # {file:docs/GettingStarted.md EventMachine tutorial}. + # + # If you want to send some data and then immediately close the connection, make sure to use {#close_connection_after_writing} + # instead of {#close_connection}. + # + # + # @param [String] data Data to send asynchronously + # + # @see file:docs/GettingStarted.md EventMachine tutorial + # @see Connection#receive_data + # @see Connection#post_init + # @see Connection#unbind + def send_data data + data = data.to_s + size = data.bytesize if data.respond_to?(:bytesize) + size ||= data.size + EventMachine::send_data @signature, data, size + end + + # Returns true if the connection is in an error state, false otherwise. + # + # In general, you can detect the occurrence of communication errors or unexpected + # disconnection by the remote peer by handing the {#unbind} method. In some cases, however, + # it's useful to check the status of the connection using {#error?} before attempting to send data. + # This function is synchronous but it will return immediately without blocking. + # + # @return [Boolean] true if the connection is in an error state, false otherwise + def error? + errno = EventMachine::report_connection_error_status(@signature) + case errno + when 0 + false + when -1 + true + else + EventMachine::ERRNOS[errno] + end + end + + # Called by the event loop when a remote TCP connection attempt completes successfully. + # You can expect to get this notification after calls to {EventMachine.connect}. Remember that EventMachine makes remote connections + # asynchronously, just as with any other kind of network event. This method + # is intended primarily to assist with network diagnostics. For normal protocol + # handling, use #post_init to perform initial work on a new connection (such as sending initial set of data). + # {Connection#post_init} will always be called. This method will only be called in case of a successful completion. + # A connection attempt which fails will result a call to {Connection#unbind} after the failure. + # + # @see Connection#post_init + # @see Connection#unbind + # @see file:docs/GettingStarted.md EventMachine tutorial + def connection_completed + end + + # Call {#start_tls} at any point to initiate TLS encryption on connected streams. + # The method is smart enough to know whether it should perform a server-side + # or a client-side handshake. An appropriate place to call {#start_tls} is in + # your redefined {#post_init} method, or in the {#connection_completed} handler for + # an outbound connection. + # + # + # @option args [String] :cert_chain_file (nil) local path of a readable file that contants a chain of X509 certificates in + # the [PEM format](http://en.wikipedia.org/wiki/Privacy_Enhanced_Mail), + # with the most-resolved certificate at the top of the file, successive intermediate + # certs in the middle, and the root (or CA) cert at the bottom. + # + # @option args [String] :private_key_file (nil) local path of a readable file that must contain a private key in the [PEM format](http://en.wikipedia.org/wiki/Privacy_Enhanced_Mail). + # + # @option args [Boolean] :verify_peer (false) indicates whether a server should request a certificate from a peer, to be verified by user code. + # If true, the {#ssl_verify_peer} callback on the {EventMachine::Connection} object is called with each certificate + # in the certificate chain provided by the peer. See documentation on {#ssl_verify_peer} for how to use this. + # + # @option args [Boolean] :fail_if_no_peer_cert (false) Used in conjunction with verify_peer. If set the SSL handshake will be terminated if the peer does not provide a certificate. + # + # + # @option args [String] :cipher_list ("ALL:!ADH:!LOW:!EXP:!DES-CBC3-SHA:@STRENGTH") indicates the available SSL cipher values. Default value is "ALL:!ADH:!LOW:!EXP:!DES-CBC3-SHA:@STRENGTH". Check the format of the OpenSSL cipher string at http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT. + # + # @option args [String] :ecdh_curve (nil) The curve for ECDHE ciphers. See available ciphers with 'openssl ecparam -list_curves' + # + # @option args [String] :dhparam (nil) The local path of a file containing DH parameters for EDH ciphers in [PEM format](http://en.wikipedia.org/wiki/Privacy_Enhanced_Mail) See: 'openssl dhparam' + # + # @option args [Array] :ssl_version (TLSv1 TLSv1_1 TLSv1_2) indicates the allowed SSL/TLS versions. Possible values are: {SSLv2}, {SSLv3}, {TLSv1}, {TLSv1_1}, {TLSv1_2}. + # + # @example Using TLS with EventMachine + # + # require 'rubygems' + # require 'eventmachine' + # + # module Handler + # def post_init + # start_tls(:private_key_file => '/tmp/server.key', :cert_chain_file => '/tmp/server.crt', :verify_peer => false) + # end + # end + # + # EventMachine.run do + # EventMachine.start_server("127.0.0.1", 9999, Handler) + # end + # + # @param [Hash] args + # + # @todo support passing an encryption parameter, which can be string or Proc, to get a passphrase + # for encrypted private keys. + # @todo support passing key material via raw strings or Procs that return strings instead of + # just filenames. + # + # @see #ssl_verify_peer + def start_tls args={} + priv_key = args[:private_key_file] + cert_chain = args[:cert_chain_file] + verify_peer = args[:verify_peer] + sni_hostname = args[:sni_hostname] + cipher_list = args[:cipher_list] + ssl_version = args[:ssl_version] + ecdh_curve = args[:ecdh_curve] + dhparam = args[:dhparam] + fail_if_no_peer_cert = args[:fail_if_no_peer_cert] + + [priv_key, cert_chain].each do |file| + next if file.nil? or file.empty? + raise FileNotFoundException, + "Could not find #{file} for start_tls" unless File.exist? file + end + + protocols_bitmask = 0 + if ssl_version.nil? + protocols_bitmask |= EventMachine::EM_PROTO_TLSv1 + protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_1 + protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_2 + else + [ssl_version].flatten.each do |p| + case p.to_s.downcase + when 'sslv2' + protocols_bitmask |= EventMachine::EM_PROTO_SSLv2 + when 'sslv3' + protocols_bitmask |= EventMachine::EM_PROTO_SSLv3 + when 'tlsv1' + protocols_bitmask |= EventMachine::EM_PROTO_TLSv1 + when 'tlsv1_1' + protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_1 + when 'tlsv1_2' + protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_2 + else + raise("Unrecognized SSL/TLS Protocol: #{p}") + end + end + end + + EventMachine::set_tls_parms(@signature, priv_key || '', cert_chain || '', verify_peer, fail_if_no_peer_cert, sni_hostname || '', cipher_list || '', ecdh_curve || '', dhparam || '', protocols_bitmask) + EventMachine::start_tls @signature + end + + # If [TLS](http://en.wikipedia.org/wiki/Transport_Layer_Security) is active on the connection, returns the remote [X509 certificate](http://en.wikipedia.org/wiki/X.509) + # as a string, in the popular [PEM format](http://en.wikipedia.org/wiki/Privacy_Enhanced_Mail). This can then be used for arbitrary validation + # of a peer's certificate in your code. + # + # This should be called in/after the {#ssl_handshake_completed} callback, which indicates + # that SSL/TLS is active. Using this callback is important, because the certificate may not + # be available until the time it is executed. Using #post_init or #connection_completed is + # not adequate, because the SSL handshake may still be taking place. + # + # This method will return `nil` if: + # + # * EventMachine is not built with [OpenSSL](http://www.openssl.org) support + # * [TLS](http://en.wikipedia.org/wiki/Transport_Layer_Security) is not active on the connection + # * TLS handshake is not yet complete + # * Remote peer for any other reason has not presented a certificate + # + # + # @example Getting peer TLS certificate information in EventMachine + # + # module Handler + # def post_init + # puts "Starting TLS" + # start_tls + # end + # + # def ssl_handshake_completed + # puts get_peer_cert + # close_connection + # end + # + # def unbind + # EventMachine::stop_event_loop + # end + # end + # + # EventMachine.run do + # EventMachine.connect "mail.google.com", 443, Handler + # end + # + # # Will output: + # # -----BEGIN CERTIFICATE----- + # # MIIDIjCCAougAwIBAgIQbldpChBPqv+BdPg4iwgN8TANBgkqhkiG9w0BAQUFADBM + # # MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg + # # THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wODA1MDIxNjMyNTRaFw0w + # # OTA1MDIxNjMyNTRaMGkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh + # # MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMRgw + # # FgYDVQQDEw9tYWlsLmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ + # # AoGBALlkxdh2QXegdElukCSOV2+8PKiONIS+8Tu9K7MQsYpqtLNC860zwOPQ2NLI + # # 3Zp4jwuXVTrtzGuiqf5Jioh35Ig3CqDXtLyZoypjZUQcq4mlLzHlhIQ4EhSjDmA7 + # # Ffw9y3ckSOQgdBQWNLbquHh9AbEUjmhkrYxIqKXeCnRKhv6nAgMBAAGjgecwgeQw + # # KAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUFBwMCBglghkgBhvhCBAEwNgYDVR0f + # # BC8wLTAroCmgJ4YlaHR0cDovL2NybC50aGF3dGUuY29tL1RoYXd0ZVNHQ0NBLmNy + # # bDByBggrBgEFBQcBAQRmMGQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9vY3NwLnRoYXd0 + # # ZS5jb20wPgYIKwYBBQUHMAKGMmh0dHA6Ly93d3cudGhhd3RlLmNvbS9yZXBvc2l0 + # # b3J5L1RoYXd0ZV9TR0NfQ0EuY3J0MAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEF + # # BQADgYEAsRwpLg1dgCR1gYDK185MFGukXMeQFUvhGqF8eT/CjpdvezyKVuz84gSu + # # 6ccMXgcPQZGQN/F4Xug+Q01eccJjRSVfdvR5qwpqCj+6BFl5oiKDBsveSkrmL5dz + # # s2bn7TdTSYKcLeBkjXxDLHGBqLJ6TNCJ3c4/cbbG5JhGvoema94= + # # -----END CERTIFICATE----- + # + # You can do whatever you want with the certificate String, such as load it + # as a certificate object using the OpenSSL library, and check its fields. + # + # @return [String] the remote [X509 certificate](http://en.wikipedia.org/wiki/X.509), in the popular [PEM format](http://en.wikipedia.org/wiki/Privacy_Enhanced_Mail), + # if TLS is active on the connection + # + # @see Connection#start_tls + # @see Connection#ssl_handshake_completed + def get_peer_cert + EventMachine::get_peer_cert @signature + end + + def get_cipher_bits + EventMachine::get_cipher_bits @signature + end + + def get_cipher_name + EventMachine::get_cipher_name @signature + end + + def get_cipher_protocol + EventMachine::get_cipher_protocol @signature + end + + def get_sni_hostname + EventMachine::get_sni_hostname @signature + end + + # Sends UDP messages. + # + # This method may be called from any Connection object that refers + # to an open datagram socket (see EventMachine#open_datagram_socket). + # The method sends a UDP (datagram) packet containing the data you specify, + # to a remote peer specified by the IP address and port that you give + # as parameters to the method. + # Observe that you may send a zero-length packet (empty string). + # However, you may not send an arbitrarily-large data packet because + # your operating system will enforce a platform-specific limit on + # the size of the outbound packet. (Your kernel + # will respond in a platform-specific way if you send an overlarge + # packet: some will send a truncated packet, some will complain, and + # some will silently drop your request). + # On LANs, it's usually OK to send datagrams up to about 4000 bytes in length, + # but to be really safe, send messages smaller than the Ethernet-packet + # size (typically about 1400 bytes). Some very restrictive WANs + # will either drop or truncate packets larger than about 500 bytes. + # + # @param [String] data Data to send asynchronously + # @param [String] recipient_address IP address of the recipient + # @param [String] recipient_port Port of the recipient + def send_datagram data, recipient_address, recipient_port + data = data.to_s + size = data.bytesize if data.respond_to?(:bytesize) + size ||= data.size + EventMachine::send_datagram @signature, data, size, recipient_address, Integer(recipient_port) + end + + + # This method is used with stream-connections to obtain the identity + # of the remotely-connected peer. If a peername is available, this method + # returns a sockaddr structure. The method returns nil if no peername is available. + # You can use Socket.unpack_sockaddr_in and its variants to obtain the + # values contained in the peername structure returned from #get_peername. + # + # @example How to get peer IP address and port with EventMachine + # + # require 'socket' + # + # module Handler + # def receive_data data + # port, ip = Socket.unpack_sockaddr_in(get_peername) + # puts "got #{data.inspect} from #{ip}:#{port}" + # end + # end + def get_peername + EventMachine::get_peername @signature + end + + # Used with stream-connections to obtain the identity + # of the local side of the connection. If a local name is available, this method + # returns a sockaddr structure. The method returns nil if no local name is available. + # You can use {Socket.unpack_sockaddr_in} and its variants to obtain the + # values contained in the local-name structure returned from this method. + # + # @example + # + # require 'socket' + # + # module Handler + # def receive_data data + # port, ip = Socket.unpack_sockaddr_in(get_sockname) + # puts "got #{data.inspect}" + # end + # end + def get_sockname + EventMachine::get_sockname @signature + end + + # Returns the PID (kernel process identifier) of a subprocess + # associated with this Connection object. For use with {EventMachine.popen} + # and similar methods. Returns nil when there is no meaningful subprocess. + # + # @return [Integer] + def get_pid + EventMachine::get_subprocess_pid @signature + end + + # Returns a subprocess exit status. Only useful for {EventMachine.popen}. Call it in your + # {#unbind} handler. + # + # @return [Integer] + def get_status + EventMachine::get_subprocess_status @signature + end + + # The number of seconds since the last send/receive activity on this connection. + def get_idle_time + EventMachine::get_idle_time @signature + end + + # comm_inactivity_timeout returns the current value (float in seconds) of the inactivity-timeout + # property of network-connection and datagram-socket objects. A nonzero value + # indicates that the connection or socket will automatically be closed if no read or write + # activity takes place for at least that number of seconds. + # A zero value (the default) specifies that no automatic timeout will take place. + def comm_inactivity_timeout + EventMachine::get_comm_inactivity_timeout @signature + end + + # Allows you to set the inactivity-timeout property for + # a network connection or datagram socket. Specify a non-negative float value in seconds. + # If the value is greater than zero, the connection or socket will automatically be closed + # if no read or write activity takes place for at least that number of seconds. + # Specify a value of zero to indicate that no automatic timeout should take place. + # Zero is the default value. + def comm_inactivity_timeout= value + EventMachine::set_comm_inactivity_timeout @signature, value.to_f + end + alias set_comm_inactivity_timeout comm_inactivity_timeout= + + # The duration after which a TCP connection in the connecting state will fail. + # It is important to distinguish this value from {EventMachine::Connection#comm_inactivity_timeout}, + # which looks at how long since data was passed on an already established connection. + # The value is a float in seconds. + # + # @return [Float] The duration after which a TCP connection in the connecting state will fail, in seconds. + def pending_connect_timeout + EventMachine::get_pending_connect_timeout @signature + end + + # Sets the duration after which a TCP connection in a + # connecting state will fail. + # + # @param [Float, #to_f] value Connection timeout in seconds + def pending_connect_timeout= value + EventMachine::set_pending_connect_timeout @signature, value.to_f + end + alias set_pending_connect_timeout pending_connect_timeout= + + # Reconnect to a given host/port with the current instance + # + # @param [String] server Hostname or IP address + # @param [Integer] port Port to reconnect to + def reconnect server, port + EventMachine::reconnect server, port, self + end + + + # Like {EventMachine::Connection#send_data}, this sends data to the remote end of + # the network connection. {EventMachine::Connection#send_file_data} takes a + # filename as an argument, though, and sends the contents of the file, in one + # chunk. + # + # @param [String] filename Local path of the file to send + # + # @see #send_data + # @author Kirk Haines + def send_file_data filename + EventMachine::send_file_data @signature, filename + end + + # Open a file on the filesystem and send it to the remote peer. This returns an + # object of type {EventMachine::Deferrable}. The object's callbacks will be executed + # on the reactor main thread when the file has been completely scheduled for + # transmission to the remote peer. Its errbacks will be called in case of an error (such as file-not-found). + # This method employs various strategies to achieve the fastest possible performance, + # balanced against minimum consumption of memory. + # + # Warning: this feature has an implicit dependency on an outboard extension, + # evma_fastfilereader. You must install this extension in order to use {#stream_file_data} + # with files larger than a certain size (currently 8192 bytes). + # + # @option args [Boolean] :http_chunks (false) If true, this method will stream the file data in a format + # compatible with the HTTP chunked-transfer encoding + # + # @param [String] filename Local path of the file to stream + # @param [Hash] args Options + # + # @return [EventMachine::Deferrable] + def stream_file_data filename, args={} + EventMachine::FileStreamer.new( self, filename, args ) + end + + # Watches connection for readability. Only possible if the connection was created + # using {EventMachine.attach} and had {EventMachine.notify_readable}/{EventMachine.notify_writable} defined on the handler. + # + # @see #notify_readable? + def notify_readable= mode + EventMachine::set_notify_readable @signature, mode + end + + # @return [Boolean] true if the connection is being watched for readability. + def notify_readable? + EventMachine::is_notify_readable @signature + end + + # Watches connection for writeability. Only possible if the connection was created + # using {EventMachine.attach} and had {EventMachine.notify_readable}/{EventMachine.notify_writable} defined on the handler. + # + # @see #notify_writable? + def notify_writable= mode + EventMachine::set_notify_writable @signature, mode + end + + # Returns true if the connection is being watched for writability. + def notify_writable? + EventMachine::is_notify_writable @signature + end + + # Pause a connection so that {#send_data} and {#receive_data} events are not fired until {#resume} is called. + # @see #resume + def pause + EventMachine::pause_connection @signature + end + + # Resume a connection's {#send_data} and {#receive_data} events. + # @see #pause + def resume + EventMachine::resume_connection @signature + end + + # @return [Boolean] true if the connect was paused using {EventMachine::Connection#pause}. + # @see #pause + # @see #resume + def paused? + EventMachine::connection_paused? @signature + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/deferrable.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/deferrable.rb new file mode 100644 index 0000000..18a6d31 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/deferrable.rb @@ -0,0 +1,210 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 Jul 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +module EventMachine + module Deferrable + autoload :Pool, 'em/deferrable/pool' + + # Specify a block to be executed if and when the Deferrable object receives + # a status of :succeeded. See #set_deferred_status for more information. + # + # Calling this method on a Deferrable object whose status is not yet known + # will cause the callback block to be stored on an internal list. + # If you call this method on a Deferrable whose status is :succeeded, the + # block will be executed immediately, receiving the parameters given to the + # prior #set_deferred_status call. + # + #-- + # If there is no status, add a callback to an internal list. + # If status is succeeded, execute the callback immediately. + # If status is failed, do nothing. + # + def callback &block + return unless block + @deferred_status ||= :unknown + if @deferred_status == :succeeded + block.call(*@deferred_args) + elsif @deferred_status != :failed + @callbacks ||= [] + @callbacks.unshift block # << block + end + self + end + + # Cancels an outstanding callback to &block if any. Undoes the action of #callback. + # + def cancel_callback block + @callbacks ||= [] + @callbacks.delete block + end + + # Specify a block to be executed if and when the Deferrable object receives + # a status of :failed. See #set_deferred_status for more information. + #-- + # If there is no status, add an errback to an internal list. + # If status is failed, execute the errback immediately. + # If status is succeeded, do nothing. + # + def errback &block + return unless block + @deferred_status ||= :unknown + if @deferred_status == :failed + block.call(*@deferred_args) + elsif @deferred_status != :succeeded + @errbacks ||= [] + @errbacks.unshift block # << block + end + self + end + + # Cancels an outstanding errback to &block if any. Undoes the action of #errback. + # + def cancel_errback block + @errbacks ||= [] + @errbacks.delete block + end + + # Sets the "disposition" (status) of the Deferrable object. See also the large set of + # sugarings for this method. + # Note that if you call this method without arguments, + # no arguments will be passed to the callback/errback. + # If the user has coded these with arguments, then the + # user code will throw an argument exception. + # Implementors of deferrable classes must + # document the arguments they will supply to user callbacks. + # + # OBSERVE SOMETHING VERY SPECIAL here: you may call this method even + # on the INSIDE of a callback. This is very useful when a previously-registered + # callback wants to change the parameters that will be passed to subsequently-registered + # ones. + # + # You may give either :succeeded or :failed as the status argument. + # + # If you pass :succeeded, then all of the blocks passed to the object using the #callback + # method (if any) will be executed BEFORE the #set_deferred_status method returns. All of the blocks + # passed to the object using #errback will be discarded. + # + # If you pass :failed, then all of the blocks passed to the object using the #errback + # method (if any) will be executed BEFORE the #set_deferred_status method returns. All of the blocks + # passed to the object using # callback will be discarded. + # + # If you pass any arguments to #set_deferred_status in addition to the status argument, + # they will be passed as arguments to any callbacks or errbacks that are executed. + # It's your responsibility to ensure that the argument lists specified in your callbacks and + # errbacks match the arguments given in calls to #set_deferred_status, otherwise Ruby will raise + # an ArgumentError. + # + #-- + # We're shifting callbacks off and discarding them as we execute them. + # This is valid because by definition callbacks are executed no more than + # once. It also has the magic effect of permitting recursive calls, which + # means that a callback can call #set_deferred_status and change the parameters + # that will be sent to subsequent callbacks down the chain. + # + # Changed @callbacks and @errbacks from push/shift to unshift/pop, per suggestion + # by Kirk Haines, to work around the memory leak bug that still exists in many Ruby + # versions. + # + # Changed 15Sep07: after processing callbacks or errbacks, CLEAR the other set of + # handlers. This gets us a little closer to the behavior of Twisted's "deferred," + # which only allows status to be set once. Prior to making this change, it was possible + # to "succeed" a Deferrable (triggering its callbacks), and then immediately "fail" it, + # triggering its errbacks! That is clearly undesirable, but it's just as undesirable + # to raise an exception is status is set more than once on a Deferrable. The latter + # behavior would invalidate the idiom of resetting arguments by setting status from + # within a callback or errback, but more seriously it would cause spurious errors + # if a Deferrable was timed out and then an attempt was made to succeed it. See the + # comments under the new method #timeout. + # + def set_deferred_status status, *args + cancel_timeout + @errbacks ||= nil + @callbacks ||= nil + @deferred_status = status + @deferred_args = args + case @deferred_status + when :succeeded + if @callbacks + while cb = @callbacks.pop + cb.call(*@deferred_args) + end + end + @errbacks.clear if @errbacks + when :failed + if @errbacks + while eb = @errbacks.pop + eb.call(*@deferred_args) + end + end + @callbacks.clear if @callbacks + end + end + + + # Setting a timeout on a Deferrable causes it to go into the failed state after + # the Timeout expires (passing no arguments to the object's errbacks). + # Setting the status at any time prior to a call to the expiration of the timeout + # will cause the timer to be cancelled. + def timeout seconds, *args + cancel_timeout + me = self + @deferred_timeout = EventMachine::Timer.new(seconds) {me.fail(*args)} + self + end + + # Cancels an outstanding timeout if any. Undoes the action of #timeout. + # + def cancel_timeout + @deferred_timeout ||= nil + if @deferred_timeout + @deferred_timeout.cancel + @deferred_timeout = nil + end + end + + + # Sugar for set_deferred_status(:succeeded, ...) + # + def succeed *args + set_deferred_status :succeeded, *args + end + alias set_deferred_success succeed + + # Sugar for set_deferred_status(:failed, ...) + # + def fail *args + set_deferred_status :failed, *args + end + alias set_deferred_failure fail + end + + + # DefaultDeferrable is an otherwise empty class that includes Deferrable. + # This is very useful when you just need to return a Deferrable object + # as a way of communicating deferred status to some other part of a program. + class DefaultDeferrable + include Deferrable + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/deferrable/pool.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/deferrable/pool.rb new file mode 100644 index 0000000..3c278ee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/deferrable/pool.rb @@ -0,0 +1,2 @@ +warn "EM::Deferrable::Pool is deprecated, please use EM::Pool" +EM::Deferrable::Pool = EM::Pool \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/file_watch.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/file_watch.rb new file mode 100644 index 0000000..074ffed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/file_watch.rb @@ -0,0 +1,73 @@ +module EventMachine + # Utility class that is useful for file monitoring. Supported events are + # + # * File is modified + # * File is deleted + # * File is moved + # + # @note On Mac OS X, file watching only works when kqueue is enabled + # + # @see EventMachine.watch_file + class FileWatch < Connection + # @private + Cmodified = 'modified'.freeze + # @private + Cdeleted = 'deleted'.freeze + # @private + Cmoved = 'moved'.freeze + + + # @private + def receive_data(data) + case data + when Cmodified + file_modified + when Cdeleted + file_deleted + when Cmoved + file_moved + end + end + + # Returns the path that is being monitored. + # + # @note Current implementation does not pick up on the new filename after a rename occurs. + # + # @return [String] + # @see EventMachine.watch_file + def path + @path + end + + # Will be called when the file is modified. Supposed to be redefined by subclasses. + # + # @abstract + def file_modified + end + + # Will be called when the file is deleted. Supposed to be redefined by subclasses. + # When the file is deleted, stop_watching will be called after this to make sure everything is + # cleaned up correctly. + # + # @note On Linux (with {http://en.wikipedia.org/wiki/Inotify inotify}), this method will not be called until *all* open file descriptors to + # the file have been closed. + # + # @abstract + def file_deleted + end + + # Will be called when the file is moved or renamed. Supposed to be redefined by subclasses. + # + # @abstract + def file_moved + end + + # Discontinue monitoring of the file. + # + # This involves cleaning up the underlying monitoring details with kqueue/inotify, and in turn firing {EventMachine::Connection#unbind}. + # This will be called automatically when a file is deleted. User code may call it as well. + def stop_watching + EventMachine::unwatch_filename(@signature) + end # stop_watching + end # FileWatch +end # EventMachine diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/future.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/future.rb new file mode 100644 index 0000000..4affbf5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/future.rb @@ -0,0 +1,61 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 Jul 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +#-- +# This defines EventMachine::Deferrable#future, which requires +# that the rest of EventMachine::Deferrable has already been seen. +# (It's in deferrable.rb.) + +module EventMachine + module Deferrable + + # A future is a sugaring of a typical deferrable usage. + #-- + # Evaluate arg (which may be an expression or a block). + # What's the class of arg? + # If arg is an ordinary expression, then return it. + # If arg is deferrable (responds to :set_deferred_status), + # then look at the arguments. If either callback or errback + # are defined, then use them. If neither are defined, then + # use the supplied block (if any) as the callback. + # Then return arg. + def self.future arg, cb=nil, eb=nil, &blk + arg = arg.call if arg.respond_to?(:call) + + if arg.respond_to?(:set_deferred_status) + if cb || eb + arg.callback(&cb) if cb + arg.errback(&eb) if eb + else + arg.callback(&blk) if blk + end + end + + arg + end + + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/iterator.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/iterator.rb new file mode 100644 index 0000000..a30b9dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/iterator.rb @@ -0,0 +1,252 @@ +module EventMachine + # A simple iterator for concurrent asynchronous work. + # + # Unlike ruby's built-in iterators, the end of the current iteration cycle is signaled manually, + # instead of happening automatically after the yielded block finishes executing. For example: + # + # (0..10).each{ |num| } + # + # becomes: + # + # EM::Iterator.new(0..10).each{ |num,iter| iter.next } + # + # This is especially useful when doing asynchronous work via reactor libraries and + # functions. For example, given a sync and async http api: + # + # response = sync_http_get(url); ... + # async_http_get(url){ |response| ... } + # + # a synchronous iterator such as: + # + # responses = urls.map{ |url| sync_http_get(url) } + # ... + # puts 'all done!' + # + # could be written as: + # + # EM::Iterator.new(urls).map(proc{ |url,iter| + # async_http_get(url){ |res| + # iter.return(res) + # } + # }, proc{ |responses| + # ... + # puts 'all done!' + # }) + # + # Now, you can take advantage of the asynchronous api to issue requests in parallel. For example, + # to fetch 10 urls at a time, simply pass in a concurrency of 10: + # + # EM::Iterator.new(urls, 10).each do |url,iter| + # async_http_get(url){ iter.next } + # end + # + class Iterator + Stop = "EM::Stop" + # Create a new parallel async iterator with specified concurrency. + # + # i = EM::Iterator.new(1..100, 10) + # + # will create an iterator over the range that processes 10 items at a time. Iteration + # is started via #each, #map or #inject + # + # The list may either be an array-like object, or a proc that returns a new object + # to be processed each time it is called. If a proc is used, it must return + # EventMachine::Iterator::Stop to signal the end of the iterations. + # + def initialize(list, concurrency = 1) + raise ArgumentError, 'concurrency must be bigger than zero' unless (concurrency > 0) + if list.respond_to?(:call) + @list = nil + @list_proc = list + elsif list.respond_to?(:to_a) + @list = list.to_a.dup + @list_proc = nil + else + raise ArgumentError, 'argument must be a proc or an array' + end + @concurrency = concurrency + + @started = false + @ended = false + end + + # Change the concurrency of this iterator. Workers will automatically be spawned or destroyed + # to accomodate the new concurrency level. + # + def concurrency=(val) + old = @concurrency + @concurrency = val + + spawn_workers if val > old and @started and !@ended + end + attr_reader :concurrency + + # Iterate over a set of items using the specified block or proc. + # + # EM::Iterator.new(1..100).each do |num, iter| + # puts num + # iter.next + # end + # + # An optional second proc is invoked after the iteration is complete. + # + # EM::Iterator.new(1..100).each( + # proc{ |num,iter| iter.next }, + # proc{ puts 'all done' } + # ) + # + def each(foreach=nil, after=nil, &blk) + raise ArgumentError, 'proc or block required for iteration' unless foreach ||= blk + raise RuntimeError, 'cannot iterate over an iterator more than once' if @started or @ended + + @started = true + @pending = 0 + @workers = 0 + + all_done = proc{ + after.call if after and @ended and @pending == 0 + } + + @process_next = proc{ + # p [:process_next, :pending=, @pending, :workers=, @workers, :ended=, @ended, :concurrency=, @concurrency, :list=, @list] + unless @ended or @workers > @concurrency + item = next_item() + if item.equal?(Stop) + @ended = true + @workers -= 1 + all_done.call + else + @pending += 1 + + is_done = false + on_done = proc{ + raise RuntimeError, 'already completed this iteration' if is_done + is_done = true + + @pending -= 1 + + if @ended + all_done.call + else + EM.next_tick(@process_next) + end + } + class << on_done + alias :next :call + end + + foreach.call(item, on_done) + end + else + @workers -= 1 + end + } + + spawn_workers + + self + end + + # Collect the results of an asynchronous iteration into an array. + # + # EM::Iterator.new(%w[ pwd uptime uname date ], 2).map(proc{ |cmd,iter| + # EM.system(cmd){ |output,status| + # iter.return(output) + # } + # }, proc{ |results| + # p results + # }) + # + def map(foreach, after) + index = 0 + + inject([], proc{ |results,item,iter| + i = index + index += 1 + + is_done = false + on_done = proc{ |res| + raise RuntimeError, 'already returned a value for this iteration' if is_done + is_done = true + + results[i] = res + iter.return(results) + } + class << on_done + alias :return :call + def next + raise NoMethodError, 'must call #return on a map iterator' + end + end + + foreach.call(item, on_done) + }, proc{ |results| + after.call(results) + }) + end + + # Inject the results of an asynchronous iteration onto a given object. + # + # EM::Iterator.new(%w[ pwd uptime uname date ], 2).inject({}, proc{ |hash,cmd,iter| + # EM.system(cmd){ |output,status| + # hash[cmd] = status.exitstatus == 0 ? output.strip : nil + # iter.return(hash) + # } + # }, proc{ |results| + # p results + # }) + # + def inject(obj, foreach, after) + each(proc{ |item,iter| + is_done = false + on_done = proc{ |res| + raise RuntimeError, 'already returned a value for this iteration' if is_done + is_done = true + + obj = res + iter.next + } + class << on_done + alias :return :call + def next + raise NoMethodError, 'must call #return on an inject iterator' + end + end + + foreach.call(obj, item, on_done) + }, proc{ + after.call(obj) + }) + end + + private + + # Spawn workers to consume items from the iterator's enumerator based on the current concurrency level. + # + def spawn_workers + EM.next_tick(start_worker = proc{ + if @workers < @concurrency and !@ended + # p [:spawning_worker, :workers=, @workers, :concurrency=, @concurrency, :ended=, @ended] + @workers += 1 + @process_next.call + EM.next_tick(start_worker) + end + }) + nil + end + + # Return the next item from @list or @list_proc. + # Once items have run out, will return EM::Iterator::Stop. Procs must supply this themselves + def next_item + if @list_proc + @list_proc.call + else + @list.empty? ? Stop : @list.shift + end + end + end +end + +# TODO: pass in one object instead of two? .each{ |iter| puts iter.current; iter.next } +# TODO: support iter.pause/resume/stop/break/continue? +# TODO: create some exceptions instead of using RuntimeError diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/messages.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/messages.rb new file mode 100644 index 0000000..9a51c39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/messages.rb @@ -0,0 +1,66 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 Jul 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +=begin + +Message Routing in EventMachine. + +The goal here is to enable "routing points," objects that can send and receive +"messages," which are delimited streams of bytes. The boundaries of a message +are preserved as it passes through the reactor system. + +There will be several module methods defined in EventMachine to create route-point +objects (which will probably have a base class of EventMachine::MessageRouter +until someone suggests a better name). + +As with I/O objects, routing objects will receive events by having the router +core call methods on them. And of course user code can and will define handlers +to deal with events of interest. + +The message router base class only really needs a receive_message method. There will +be an EM module-method to send messages, in addition to the module methods to create +the various kinds of message receivers. + +The simplest kind of message receiver object can receive messages by being named +explicitly in a parameter to EM#send_message. More sophisticated receivers can define +pub-sub selectors and message-queue names. And they can also define channels for +route-points in other processes or even on other machines. + +A message is NOT a marshallable entity. Rather, it's a chunk of flat content more like +an Erlang message. Initially, all content submitted for transmission as a message will +have the to_s method called on it. Eventually, we'll be able to transmit certain structured +data types (XML and YAML documents, Structs within limits) and have them reconstructed +on the other end. + +A fundamental goal of the message-routing capability is to interoperate seamlessly with +external systems, including non-Ruby systems like ActiveMQ. We will define various protocol +handlers for things like Stomp and possibly AMQP, but these will be wrapped up and hidden +from the users of the basic routing capability. + +As with Erlang, a critical goal is for programs that are built to use message-passing to work +WITHOUT CHANGE when the code is re-based on a multi-process system. + +=end + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/pool.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/pool.rb new file mode 100644 index 0000000..2cb3662 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/pool.rb @@ -0,0 +1,151 @@ +module EventMachine + # A simple async resource pool based on a resource and work queue. Resources + # are enqueued and work waits for resources to become available. + # + # @example + # require 'em-http-request' + # + # EM.run do + # pool = EM::Pool.new + # spawn = lambda { pool.add EM::HttpRequest.new('http://example.org') } + # 10.times { spawn[] } + # done, scheduled = 0, 0 + # + # check = lambda do + # done += 1 + # if done >= scheduled + # EM.stop + # end + # end + # + # pool.on_error { |conn| spawn[] } + # + # 100.times do |i| + # scheduled += 1 + # pool.perform do |conn| + # req = conn.get :path => '/', :keepalive => true + # + # req.callback do + # p [:success, conn.object_id, i, req.response.size] + # check[] + # end + # + # req.errback { check[] } + # + # req + # end + # end + # end + # + # Resources are expected to be controlled by an object responding to a + # deferrable/completion style API with callback and errback blocks. + # + class Pool + + def initialize + @resources = EM::Queue.new + @removed = [] + @contents = [] + @on_error = nil + end + + def add resource + @contents << resource + requeue resource + end + + def remove resource + @contents.delete resource + @removed << resource + end + + # Returns a list for introspection purposes only. You should *NEVER* call + # modification or work oriented methods on objects in this list. A good + # example use case is periodic statistics collection against a set of + # connection resources. + # + # @example + # pool.contents.inject(0) { |sum, connection| connection.num_bytes } + def contents + @contents.dup + end + + # Define a default catch-all for when the deferrables returned by work + # blocks enter a failed state. By default all that happens is that the + # resource is returned to the pool. If on_error is defined, this block is + # responsible for re-adding the resource to the pool if it is still usable. + # In other words, it is generally assumed that on_error blocks explicitly + # handle the rest of the lifetime of the resource. + def on_error *a, &b + @on_error = EM::Callback(*a, &b) + end + + # Perform a given #call-able object or block. The callable object will be + # called with a resource from the pool as soon as one is available, and is + # expected to return a deferrable. + # + # The deferrable will have callback and errback added such that when the + # deferrable enters a finished state, the object is returned to the pool. + # + # If on_error is defined, then objects are not automatically returned to the + # pool. + def perform(*a, &b) + work = EM::Callback(*a, &b) + + @resources.pop do |resource| + if removed? resource + @removed.delete resource + reschedule work + else + process work, resource + end + end + end + alias reschedule perform + + # A peek at the number of enqueued jobs waiting for resources + def num_waiting + @resources.num_waiting + end + + # Removed will show resources in a partial pruned state. Resources in the + # removed list may not appear in the contents list if they are currently in + # use. + def removed? resource + @removed.include? resource + end + + protected + def requeue resource + @resources.push resource + end + + def failure resource + if @on_error + @contents.delete resource + @on_error.call resource + # Prevent users from calling a leak. + @removed.delete resource + else + requeue resource + end + end + + def completion deferrable, resource + deferrable.callback { requeue resource } + deferrable.errback { failure resource } + end + + def process work, resource + deferrable = work.call resource + if deferrable.kind_of?(EM::Deferrable) + completion deferrable, resource + else + raise ArgumentError, "deferrable expected from work" + end + rescue + failure resource + raise + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/process_watch.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/process_watch.rb new file mode 100644 index 0000000..66e8943 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/process_watch.rb @@ -0,0 +1,45 @@ +module EventMachine + + # This is subclassed from EventMachine::Connection for use with the process monitoring API. Read the + # documentation on the instance methods of this class, and for a full explanation see EventMachine.watch_process. + class ProcessWatch < Connection + # @private + Cfork = 'fork'.freeze + # @private + Cexit = 'exit'.freeze + + # @private + def receive_data(data) + case data + when Cfork + process_forked + when Cexit + process_exited + end + end + + # Returns the pid that EventMachine::watch_process was originally called with. + def pid + @pid + end + + # Should be redefined with the user's custom callback that will be fired when the prcess is forked. + # + # There is currently not an easy way to get the pid of the forked child. + def process_forked + end + + # Should be redefined with the user's custom callback that will be fired when the process exits. + # + # stop_watching is called automatically after this callback + def process_exited + end + + # Discontinue monitoring of the process. + # This will be called automatically when a process dies. User code may call it as well. + def stop_watching + EventMachine::unwatch_pid(@signature) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/processes.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/processes.rb new file mode 100644 index 0000000..4bbc14f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/processes.rb @@ -0,0 +1,123 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 13 Dec 07 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-08 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + + +module EventMachine + + # EM::DeferrableChildProcess is a sugaring of a common use-case + # involving EM::popen. + # Call the #open method on EM::DeferrableChildProcess, passing + # a command-string. #open immediately returns an EM::Deferrable + # object. It also schedules the forking of a child process, which + # will execute the command passed to #open. + # When the forked child terminates, the Deferrable will be signalled + # and execute its callbacks, passing the data that the child process + # wrote to stdout. + # + class DeferrableChildProcess < EventMachine::Connection + include EventMachine::Deferrable + + # @private + def initialize + super + @data = [] + end + + # Sugars a common use-case involving forked child processes. + # #open takes a String argument containing an shell command + # string (including arguments if desired). #open immediately + # returns an EventMachine::Deferrable object, without blocking. + # + # It also invokes EventMachine#popen to run the passed-in + # command in a forked child process. + # + # When the forked child terminates, the Deferrable that + # #open calls its callbacks, passing the data returned + # from the child process. + # + def self.open cmd + EventMachine.popen( cmd, DeferrableChildProcess ) + end + + # @private + def receive_data data + @data << data + end + + # @private + def unbind + succeed( @data.join ) + end + end + + # @private + class SystemCmd < EventMachine::Connection + def initialize cb + @cb = cb + @output = [] + end + def receive_data data + @output << data + end + def unbind + @cb.call @output.join(''), get_status if @cb + end + end + + # EM::system is a simple wrapper for EM::popen. It is similar to Kernel::system, but requires a + # single string argument for the command and performs no shell expansion. + # + # The block or proc passed to EM::system is called with two arguments: the output generated by the command, + # and a Process::Status that contains information about the command's execution. + # + # EM.run{ + # EM.system('ls'){ |output,status| puts output if status.exitstatus == 0 } + # } + # + # You can also supply an additional proc to send some data to the process: + # + # EM.run{ + # EM.system('sh', proc{ |process| + # process.send_data("echo hello\n") + # process.send_data("exit\n") + # }, proc{ |out,status| + # puts(out) + # }) + # } + # + # Like EventMachine.popen, EventMachine.system currently does not work on windows. + # It returns the pid of the spawned process. + def EventMachine::system cmd, *args, &cb + cb ||= args.pop if args.last.is_a? Proc + init = args.pop if args.last.is_a? Proc + + # merge remaining arguments into the command + cmd = [cmd, *args] if args.any? + + EM.get_subprocess_pid(EM.popen(cmd, SystemCmd, cb) do |c| + init[c] if init + end.signature) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols.rb new file mode 100644 index 0000000..0c17906 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols.rb @@ -0,0 +1,37 @@ +module EventMachine + # This module contains various protocol implementations, including: + # - HttpClient and HttpClient2 + # - Stomp + # - Memcache + # - SmtpClient and SmtpServer + # - SASLauth and SASLauthclient + # - LineProtocol, LineAndTextProtocol and LineText2 + # - HeaderAndContentProtocol + # - Postgres3 + # - ObjectProtocol + # + # The protocol implementations live in separate files in the protocols/ subdirectory, + # but are auto-loaded when they are first referenced in your application. + # + # EventMachine::Protocols is also aliased to EM::P for easier usage. + # + module Protocols + # TODO : various autotools are completely useless with the lack of naming + # convention, we need to correct that! + autoload :TcpConnectTester, 'em/protocols/tcptest' + autoload :HttpClient, 'em/protocols/httpclient' + autoload :HttpClient2, 'em/protocols/httpclient2' + autoload :LineAndTextProtocol, 'em/protocols/line_and_text' + autoload :HeaderAndContentProtocol, 'em/protocols/header_and_content' + autoload :LineText2, 'em/protocols/linetext2' + autoload :Stomp, 'em/protocols/stomp' + autoload :SmtpClient, 'em/protocols/smtpclient' + autoload :SmtpServer, 'em/protocols/smtpserver' + autoload :SASLauth, 'em/protocols/saslauth' + autoload :Memcache, 'em/protocols/memcache' + autoload :Postgres3, 'em/protocols/postgres3' + autoload :ObjectProtocol, 'em/protocols/object_protocol' + autoload :Socks4, 'em/protocols/socks4' + autoload :LineProtocol, 'em/protocols/line_protocol' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/header_and_content.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/header_and_content.rb new file mode 100644 index 0000000..b5a465a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/header_and_content.rb @@ -0,0 +1,138 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 15 Nov 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +module EventMachine + module Protocols + + # === Usage + # + # class RequestHandler < EM::P::HeaderAndContentProtocol + # def receive_request headers, content + # p [:request, headers, content] + # end + # end + # + # EM.run{ + # EM.start_server 'localhost', 80, RequestHandler + # } + # + #-- + # Originally, this subclassed LineAndTextProtocol, which in + # turn relies on BufferedTokenizer, which doesn't gracefully + # handle the transitions between lines and binary text. + # Changed 13Sep08 by FCianfrocca. + class HeaderAndContentProtocol < Connection + include LineText2 + + ContentLengthPattern = /Content-length:\s*(\d+)/i + + def initialize *args + super + init_for_request + end + + def receive_line line + case @hc_mode + when :discard_blanks + unless line == "" + @hc_mode = :headers + receive_line line + end + when :headers + if line == "" + raise "unrecognized state" unless @hc_headers.length > 0 + if respond_to?(:receive_headers) + receive_headers @hc_headers + end + # @hc_content_length will be nil, not 0, if there was no content-length header. + if @hc_content_length.to_i > 0 + set_binary_mode @hc_content_length + else + dispatch_request + end + else + @hc_headers << line + if ContentLengthPattern =~ line + # There are some attacks that rely on sending multiple content-length + # headers. This is a crude protection, but needs to become tunable. + raise "extraneous content-length header" if @hc_content_length + @hc_content_length = $1.to_i + end + if @hc_headers.length == 1 and respond_to?(:receive_first_header_line) + receive_first_header_line line + end + end + else + raise "internal error, unsupported mode" + end + end + + def receive_binary_data text + @hc_content = text + dispatch_request + end + + def dispatch_request + if respond_to?(:receive_request) + receive_request @hc_headers, @hc_content + end + init_for_request + end + private :dispatch_request + + def init_for_request + @hc_mode = :discard_blanks + @hc_headers = [] + # originally was @hc_headers ||= []; @hc_headers.clear to get a performance + # boost, but it's counterproductive because a subclassed handler will have to + # call dup to use the header array we pass in receive_headers. + + @hc_content_length = nil + @hc_content = "" + end + private :init_for_request + + # Basically a convenience method. We might create a subclass that does this + # automatically. But it's such a performance killer. + def headers_2_hash hdrs + self.class.headers_2_hash hdrs + end + + class << self + def headers_2_hash hdrs + hash = {} + hdrs.each {|h| + if /\A([^\s:]+)\s*:\s*/ =~ h + tail = $'.dup + hash[ $1.downcase.gsub(/-/,"_").intern ] = tail + end + } + hash + end + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/httpclient.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/httpclient.rb new file mode 100644 index 0000000..38b175c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/httpclient.rb @@ -0,0 +1,300 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 July 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +module EventMachine + module Protocols + + # Note: This class is deprecated and will be removed. Please use EM-HTTP-Request instead. + # + # @example + # EventMachine.run { + # http = EventMachine::Protocols::HttpClient.request( + # :host => server, + # :port => 80, + # :request => "/index.html", + # :query_string => "parm1=value1&parm2=value2" + # ) + # http.callback {|response| + # puts response[:status] + # puts response[:headers] + # puts response[:content] + # } + # } + #-- + # TODO: + # Add streaming so we can support enormous POSTs. Current max is 20meg. + # Timeout for connections that run too long or hang somewhere in the middle. + # Persistent connections (HTTP/1.1), may need a associated delegate object. + # DNS: Some way to cache DNS lookups for hostnames we connect to. Ruby's + # DNS lookups are unbelievably slow. + # HEAD requests. + # Convenience methods for requests. get, post, url, etc. + # SSL. + # Handle status codes like 304, 100, etc. + # Refactor this code so that protocol errors all get handled one way (an exception?), + # instead of sprinkling set_deferred_status :failed calls everywhere. + class HttpClient < Connection + include EventMachine::Deferrable + + MaxPostContentLength = 20 * 1024 * 1024 + + def initialize + warn "HttpClient is deprecated and will be removed. EM-Http-Request should be used instead." + @connected = false + end + + # @param args [Hash] The request arguments + # @option args [String] :host The host IP/DNS name + # @option args [Integer] :port The port to connect too + # @option args [String] :verb The request type [GET | POST | DELETE | PUT] + # @option args [String] :request The request path + # @option args [Hash] :basic_auth The basic auth credentials (:username and :password) + # @option args [String] :content The request content + # @option args [String] :contenttype The content type (e.g. text/plain) + # @option args [String] :query_string The query string + # @option args [String] :host_header The host header to set + # @option args [String] :cookie Cookies to set + def self.request( args = {} ) + args[:port] ||= 80 + EventMachine.connect( args[:host], args[:port], self ) {|c| + # According to the docs, we will get here AFTER post_init is called. + c.instance_eval {@args = args} + } + end + + def post_init + @start_time = Time.now + @data = "" + @read_state = :base + end + + # We send the request when we get a connection. + # AND, we set an instance variable to indicate we passed through here. + # That allows #unbind to know whether there was a successful connection. + # NB: This naive technique won't work when we have to support multiple + # requests on a single connection. + def connection_completed + @connected = true + send_request @args + end + + def send_request args + args[:verb] ||= args[:method] # Support :method as an alternative to :verb. + args[:verb] ||= :get # IS THIS A GOOD IDEA, to default to GET if nothing was specified? + + verb = args[:verb].to_s.upcase + unless ["GET", "POST", "PUT", "DELETE", "HEAD"].include?(verb) + set_deferred_status :failed, {:status => 0} # TODO, not signalling the error type + return # NOTE THE EARLY RETURN, we're not sending any data. + end + + request = args[:request] || "/" + unless request[0,1] == "/" + request = "/" + request + end + + qs = args[:query_string] || "" + if qs.length > 0 and qs[0,1] != '?' + qs = "?" + qs + end + + version = args[:version] || "1.1" + + # Allow an override for the host header if it's not the connect-string. + host = args[:host_header] || args[:host] || "_" + # For now, ALWAYS tuck in the port string, although we may want to omit it if it's the default. + port = args[:port].to_i != 80 ? ":#{args[:port]}" : "" + + # POST items. + postcontenttype = args[:contenttype] || "application/octet-stream" + postcontent = args[:content] || "" + raise "oversized content in HTTP POST" if postcontent.length > MaxPostContentLength + + # ESSENTIAL for the request's line-endings to be CRLF, not LF. Some servers misbehave otherwise. + # TODO: We ASSUME the caller wants to send a 1.1 request. May not be a good assumption. + req = [ + "#{verb} #{request}#{qs} HTTP/#{version}", + "Host: #{host}#{port}", + "User-agent: Ruby EventMachine", + ] + + if verb == "POST" || verb == "PUT" + req << "Content-type: #{postcontenttype}" + req << "Content-length: #{postcontent.length}" + end + + # TODO, this cookie handler assumes it's getting a single, semicolon-delimited string. + # Eventually we will want to deal intelligently with arrays and hashes. + if args[:cookie] + req << "Cookie: #{args[:cookie]}" + end + + # Allow custom HTTP headers, e.g. SOAPAction + args[:custom_headers].each do |k,v| + req << "#{k}: #{v}" + end if args[:custom_headers] + + # Basic-auth stanza contributed by Matt Murphy. + if args[:basic_auth] + basic_auth_string = ["#{args[:basic_auth][:username]}:#{args[:basic_auth][:password]}"].pack('m').strip.gsub(/\n/,'') + req << "Authorization: Basic #{basic_auth_string}" + end + + req << "" + reqstring = req.map {|l| "#{l}\r\n"}.join + send_data reqstring + + if verb == "POST" || verb == "PUT" + send_data postcontent + end + end + + + def receive_data data + while data and data.length > 0 + case @read_state + when :base + # Perform any per-request initialization here and don't consume any data. + @data = "" + @headers = [] + @content_length = nil # not zero + @content = "" + @status = nil + @chunked = false + @chunk_length = nil + @read_state = :header + @connection_close = nil + when :header + ary = data.split( /\r?\n/m, 2 ) + if ary.length == 2 + data = ary.last + if ary.first == "" + if (@content_length and @content_length > 0) || @chunked || @connection_close + @read_state = :content + else + dispatch_response + @read_state = :base + end + else + @headers << ary.first + if @headers.length == 1 + parse_response_line + elsif ary.first =~ /\Acontent-length:\s*/i + # Only take the FIRST content-length header that appears, + # which we can distinguish because @content_length is nil. + # TODO, it's actually a fatal error if there is more than one + # content-length header, because the caller is presumptively + # a bad guy. (There is an exploit that depends on multiple + # content-length headers.) + @content_length ||= $'.to_i + elsif ary.first =~ /\Aconnection:\s*close/i + @connection_close = true + elsif ary.first =~ /\Atransfer-encoding:\s*chunked/i + @chunked = true + end + end + else + @data << data + data = "" + end + when :content + if @chunked && @chunk_length + bytes_needed = @chunk_length - @chunk_read + new_data = data[0, bytes_needed] + @chunk_read += new_data.length + @content += new_data + data = data[bytes_needed..-1] || "" + if @chunk_length == @chunk_read && data[0,2] == "\r\n" + @chunk_length = nil + data = data[2..-1] + end + elsif @chunked + if (m = data.match(/\A(\S*)\r\n/m)) + data = data[m[0].length..-1] + @chunk_length = m[1].to_i(16) + @chunk_read = 0 + if @chunk_length == 0 + dispatch_response + @read_state = :base + end + end + elsif @content_length + # If there was no content-length header, we have to wait until the connection + # closes. Everything we get until that point is content. + # TODO: Must impose a content-size limit, and also must implement chunking. + # Also, must support either temporary files for large content, or calling + # a content-consumer block supplied by the user. + bytes_needed = @content_length - @content.length + @content += data[0, bytes_needed] + data = data[bytes_needed..-1] || "" + if @content_length == @content.length + dispatch_response + @read_state = :base + end + else + @content << data + data = "" + end + end + end + end + + + # We get called here when we have received an HTTP response line. + # It's an opportunity to throw an exception or trigger other exceptional + # handling. + def parse_response_line + if @headers.first =~ /\AHTTP\/1\.[01] ([\d]{3})/ + @status = $1.to_i + else + set_deferred_status :failed, { + :status => 0 # crappy way of signifying an unrecognized response. TODO, find a better way to do this. + } + close_connection + end + end + private :parse_response_line + + def dispatch_response + @read_state = :base + set_deferred_status :succeeded, { + :content => @content, + :headers => @headers, + :status => @status + } + # TODO, we close the connection for now, but this is wrong for persistent clients. + close_connection + end + + def unbind + if !@connected + set_deferred_status :failed, {:status => 0} # YECCCCH. Find a better way to signal no-connect/network error. + elsif (@read_state == :content and @content_length == nil) + dispatch_response + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/httpclient2.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/httpclient2.rb new file mode 100644 index 0000000..0fb64e8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/httpclient2.rb @@ -0,0 +1,600 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 July 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +module EventMachine + module Protocols + + # Note: This class is deprecated and will be removed. Please use EM-HTTP-Request instead. + # + # === Usage + # + # EM.run{ + # conn = EM::Protocols::HttpClient2.connect 'google.com', 80 + # + # req = conn.get('/') + # req.callback{ |response| + # p(response.status) + # p(response.headers) + # p(response.content) + # } + # } + class HttpClient2 < Connection + include LineText2 + + def initialize + warn "HttpClient2 is deprecated and will be removed. EM-Http-Request should be used instead." + + @authorization = nil + @closed = nil + @requests = nil + end + + # @private + class Request + include Deferrable + + attr_reader :version + attr_reader :status + attr_reader :header_lines + attr_reader :headers + attr_reader :content + attr_reader :internal_error + + def initialize conn, args + @conn = conn + @args = args + @header_lines = [] + @headers = {} + @blanks = 0 + @chunk_trailer = nil + @chunking = nil + end + + def send_request + az = @args[:authorization] and az = "Authorization: #{az}\r\n" + + r = [ + "#{@args[:verb]} #{@args[:uri]} HTTP/#{@args[:version] || "1.1"}\r\n", + "Host: #{@args[:host_header] || "_"}\r\n", + az || "", + "\r\n" + ] + @conn.send_data r.join + end + + + #-- + # + def receive_line ln + if @chunk_trailer + receive_chunk_trailer(ln) + elsif @chunking + receive_chunk_header(ln) + else + receive_header_line(ln) + end + end + + #-- + # + def receive_chunk_trailer ln + if ln.length == 0 + @conn.pop_request + succeed(self) + else + p "Received chunk trailer line" + end + end + + #-- + # Allow up to ten blank lines before we get a real response line. + # Allow no more than 100 lines in the header. + # + def receive_header_line ln + if ln.length == 0 + if @header_lines.length > 0 + process_header + else + @blanks += 1 + if @blanks > 10 + @conn.close_connection + end + end + else + @header_lines << ln + if @header_lines.length > 100 + @internal_error = :bad_header + @conn.close_connection + end + end + end + + #-- + # Cf RFC 2616 pgh 3.6.1 for the format of HTTP chunks. + # + def receive_chunk_header ln + if ln.length > 0 + chunksize = ln.to_i(16) + if chunksize > 0 + @conn.set_text_mode(ln.to_i(16)) + else + @content = @content ? @content.join : '' + @chunk_trailer = true + end + else + # We correctly come here after each chunk gets read. + # p "Got A BLANK chunk line" + end + + end + + + #-- + # We get a single chunk. Append it to the incoming content and switch back to line mode. + # + def receive_chunked_text text + # p "RECEIVED #{text.length} CHUNK" + (@content ||= []) << text + end + + + #-- + # TODO, inefficient how we're handling this. Part of it is done so as to + # make sure we don't have problems in detecting chunked-encoding, content-length, + # etc. + # + HttpResponseRE = /\AHTTP\/(1.[01]) ([\d]{3})/i + ClenRE = /\AContent-length:\s*(\d+)/i + ChunkedRE = /\ATransfer-encoding:\s*chunked/i + ColonRE = /\:\s*/ + + def process_header + unless @header_lines.first =~ HttpResponseRE + @conn.close_connection + @internal_error = :bad_request + end + @version = $1.dup + @status = $2.dup.to_i + + clen = nil + chunks = nil + @header_lines.each_with_index do |e,ix| + if ix > 0 + hdr,val = e.split(ColonRE,2) + (@headers[hdr.downcase] ||= []) << val + end + + if clen == nil and e =~ ClenRE + clen = $1.dup.to_i + end + if e =~ ChunkedRE + chunks = true + end + end + + if clen + # If the content length is zero we should not call set_text_mode, + # because a value of zero will make it wait forever, hanging the + # connection. Just return success instead, with empty content. + if clen == 0 then + @content = "" + @conn.pop_request + succeed(self) + else + @conn.set_text_mode clen + end + elsif chunks + @chunking = true + else + # Chunked transfer, multipart, or end-of-connection. + # For end-of-connection, we need to go the unbind + # method and suppress its desire to fail us. + p "NO CLEN" + p @args[:uri] + p @header_lines + @internal_error = :unsupported_clen + @conn.close_connection + end + end + private :process_header + + + def receive_text text + @chunking ? receive_chunked_text(text) : receive_sized_text(text) + end + + #-- + # At the present time, we only handle contents that have a length + # specified by the content-length header. + # + def receive_sized_text text + @content = text + @conn.pop_request + succeed(self) + end + end + + # Make a connection to a remote HTTP server. + # Can take either a pair of arguments (which will be interpreted as + # a hostname/ip-address and a port), or a hash. + # If the arguments are a hash, then supported values include: + # :host => a hostname or ip-address + # :port => a port number + # :ssl => true to enable ssl + def self.connect *args + if args.length == 2 + args = {:host=>args[0], :port=>args[1]} + else + args = args.first + end + + h,prt,ssl = args[:host], Integer(args[:port]), (args[:tls] || args[:ssl]) + conn = EM.connect( h, prt, self ) + conn.start_tls if ssl + conn.set_default_host_header( h, prt, ssl ) + conn + end + + # Get a url + # + # req = conn.get(:uri => '/') + # req.callback{|response| puts response.content } + # + def get args + if args.is_a?(String) + args = {:uri=>args} + end + args[:verb] = "GET" + request args + end + + # Post to a url + # + # req = conn.post('/data') + # req.callback{|response| puts response.content } + #-- + # XXX there's no way to supply a POST body.. wtf? + def post args + if args.is_a?(String) + args = {:uri=>args} + end + args[:verb] = "POST" + request args + end + + + #-- + # Compute and remember a string to be used as the host header in HTTP requests + # unless the user overrides it with an argument to #request. + # + # @private + def set_default_host_header host, port, ssl + if (ssl and port != 443) or (!ssl and port != 80) + @host_header = "#{host}:#{port}" + else + @host_header = host + end + end + + + # @private + def post_init + super + @connected = EM::DefaultDeferrable.new + end + + # @private + def connection_completed + super + @connected.succeed + end + + #-- + # All pending requests, if any, must fail. + # We might come here without ever passing through connection_completed + # in case we can't connect to the server. We'll also get here when the + # connection closes (either because the server closes it, or we close it + # due to detecting an internal error or security violation). + # In either case, run down all pending requests, if any, and signal failure + # on them. + # + # Set and remember a flag (@closed) so we can immediately fail any + # subsequent requests. + # + # @private + def unbind + super + @closed = true + (@requests || []).each {|r| r.fail} + end + + # @private + def request args + args[:host_header] = @host_header unless args.has_key?(:host_header) + args[:authorization] = @authorization unless args.has_key?(:authorization) + r = Request.new self, args + if @closed + r.fail + else + (@requests ||= []).unshift r + @connected.callback {r.send_request} + end + r + end + + # @private + def receive_line ln + if req = @requests.last + req.receive_line ln + else + p "??????????" + p ln + end + end + + # @private + def receive_binary_data text + @requests.last.receive_text text + end + + #-- + # Called by a Request object when it completes. + # + # @private + def pop_request + @requests.pop + end + end + + +=begin + class HttpClient2x < Connection + include LineText2 + + # TODO: Make this behave appropriate in case a #connect fails. + # Currently, this produces no errors. + + # Make a connection to a remote HTTP server. + # Can take either a pair of arguments (which will be interpreted as + # a hostname/ip-address and a port), or a hash. + # If the arguments are a hash, then supported values include: + # :host => a hostname or ip-address; + # :port => a port number + #-- + # TODO, support optional encryption arguments like :ssl + def self.connect *args + if args.length == 2 + args = {:host=>args[0], :port=>args[1]} + else + args = args.first + end + + h,prt = args[:host],Integer(args[:port]) + EM.connect( h, prt, self, h, prt ) + end + + + #-- + # Sugars a connection that makes a single request and then + # closes the connection. Matches the behavior and the arguments + # of the original implementation of class HttpClient. + # + # Intended primarily for back compatibility, but the idiom + # is probably useful so it's not deprecated. + # We return a Deferrable, as did the original implementation. + # + # Because we're improving the way we deal with errors and exceptions + # (specifically, HTTP response codes other than 2xx will trigger the + # errback rather than the callback), this may break some existing code. + # + def self.request args + c = connect args + end + + #-- + # Requests can be pipelined. When we get a request, add it to the + # front of a queue as an array. The last element of the @requests + # array is always the oldest request received. Each element of the + # @requests array is a two-element array consisting of a hash with + # the original caller's arguments, and an initially-empty Ostruct + # containing the data we retrieve from the server's response. + # Maintain the instance variable @current_response, which is the response + # of the oldest pending request. That's just to make other code a little + # easier. If the variable doesn't exist when we come here, we're + # obviously the first request being made on the connection. + # + # The reason for keeping this method private (and requiring use of the + # convenience methods #get, #post, #head, etc) is to avoid the small + # performance penalty of canonicalizing the verb. + # + def request args + d = EventMachine::DefaultDeferrable.new + + if @closed + d.fail + return d + end + + o = OpenStruct.new + o.deferrable = d + (@requests ||= []).unshift [args, o] + @current_response ||= @requests.last.last + @connected.callback { + az = args[:authorization] and az = "Authorization: #{az}\r\n" + + r = [ + "#{args[:verb]} #{args[:uri]} HTTP/#{args[:version] || "1.1"}\r\n", + "Host: #{args[:host_header] || @host_header}\r\n", + az || "", + "\r\n" + ] + p r + send_data r.join + } + o.deferrable + end + private :request + + def get args + if args.is_a?(String) + args = {:uri=>args} + end + args[:verb] = "GET" + request args + end + + def initialize host, port + super + @host_header = "#{host}:#{port}" + end + def post_init + super + @connected = EM::DefaultDeferrable.new + end + + + def connection_completed + super + @connected.succeed + end + + #-- + # Make sure to throw away any leftover incoming data if we've + # been closed due to recognizing an error. + # + # Generate an internal error if we get an unreasonable number of + # header lines. It could be malicious. + # + def receive_line ln + p ln + return if @closed + + if ln.length > 0 + (@current_response.headers ||= []).push ln + abort_connection if @current_response.headers.length > 100 + else + process_received_headers + end + end + + #-- + # We come here when we've seen all the headers for a particular request. + # What we do next depends on the response line (which should be the + # first line in the header set), and whether there is content to read. + # We may transition into a text-reading state to read content, or + # we may abort the connection, or we may go right back into parsing + # responses for the next response in the chain. + # + # We make an ASSUMPTION that the first line is an HTTP response. + # Anything else produces an error that aborts the connection. + # This may not be enough, because it may be that responses to pipelined + # requests will come with a blank-line delimiter. + # + # Any non-2xx response will be treated as a fatal error, and abort the + # connection. We will set up the status and other response parameters. + # TODO: we will want to properly support 1xx responses, which some versions + # of IIS copiously generate. + # TODO: We need to give the option of not aborting the connection with certain + # non-200 responses, in order to work with NTLM and other authentication + # schemes that work at the level of individual connections. + # + # Some error responses will get sugarings. For example, we'll return the + # Location header in the response in case of a 301/302 response. + # + # Possible dispositions here: + # 1) No content to read (either content-length is zero or it's a HEAD request); + # 2) Switch to text mode to read a specific number of bytes; + # 3) Read a chunked or multipart response; + # 4) Read till the server closes the connection. + # + # Our reponse to the client can be either to wait till all the content + # has been read and then to signal caller's deferrable, or else to signal + # it when we finish the processing the headers and then expect the caller + # to have given us a block to call as the content comes in. And of course + # the latter gets stickier with chunks and multiparts. + # + HttpResponseRE = /\AHTTP\/(1.[01]) ([\d]{3})/i + ClenRE = /\AContent-length:\s*(\d+)/i + def process_received_headers + abort_connection unless @current_response.headers.first =~ HttpResponseRE + @current_response.version = $1.dup + st = $2.dup + @current_response.status = st.to_i + abort_connection unless st[0,1] == "2" + + clen = nil + @current_response.headers.each do |e| + if clen == nil and e =~ ClenRE + clen = $1.dup.to_i + end + end + + if clen + set_text_mode clen + end + end + private :process_received_headers + + + def receive_binary_data text + @current_response.content = text + @current_response.deferrable.succeed @current_response + @requests.pop + @current_response = (@requests.last || []).last + set_line_mode + end + + + + # We've received either a server error or an internal error. + # Close the connection and abort any pending requests. + #-- + # When should we call close_connection? It will cause #unbind + # to be fired. Should the user expect to see #unbind before + # we call #receive_http_error, or the other way around? + # + # Set instance variable @closed. That's used to inhibit further + # processing of any inbound data after an error has been recognized. + # + # We shouldn't have to worry about any leftover outbound data, + # because we call close_connection (not close_connection_after_writing). + # That ensures that any pipelined requests received after an error + # DO NOT get streamed out to the server on this connection. + # Very important. TODO, write a unit-test to establish that behavior. + # + def abort_connection + close_connection + @closed = true + @current_response.deferrable.fail( @current_response ) + end + + + #------------------------ + # Below here are user-overridable methods. + + end +=end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/line_and_text.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/line_and_text.rb new file mode 100644 index 0000000..784daf2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/line_and_text.rb @@ -0,0 +1,125 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 15 November 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# +# + +module EventMachine + module Protocols + # A protocol that handles line-oriented data with interspersed binary text. + # + # This version is optimized for performance. See EventMachine::Protocols::LineText2 + # for a version which is optimized for correctness with regard to binary text blocks + # that can switch back to line mode. + class LineAndTextProtocol < Connection + MaxBinaryLength = 32*1024*1024 + + def initialize *args + super + lbp_init_line_state + end + + def receive_data data + if @lbp_mode == :lines + begin + @lpb_buffer.extract(data).each do |line| + receive_line(line.chomp) if respond_to?(:receive_line) + end + rescue + receive_error('overlength line') if respond_to?(:receive_error) + close_connection + return + end + else + if @lbp_binary_limit > 0 + wanted = @lbp_binary_limit - @lbp_binary_bytes_received + chunk = nil + if data.length > wanted + chunk = data.slice!(0...wanted) + else + chunk = data + data = "" + end + @lbp_binary_buffer[@lbp_binary_bytes_received...(@lbp_binary_bytes_received+chunk.length)] = chunk + @lbp_binary_bytes_received += chunk.length + if @lbp_binary_bytes_received == @lbp_binary_limit + receive_binary_data(@lbp_binary_buffer) if respond_to?(:receive_binary_data) + lbp_init_line_state + end + receive_data(data) if data.length > 0 + else + receive_binary_data(data) if respond_to?(:receive_binary_data) + data = "" + end + end + end + + def unbind + if @lbp_mode == :binary and @lbp_binary_limit > 0 + if respond_to?(:receive_binary_data) + receive_binary_data( @lbp_binary_buffer[0...@lbp_binary_bytes_received] ) + end + end + end + + # Set up to read the supplied number of binary bytes. + # This recycles all the data currently waiting in the line buffer, if any. + # If the limit is nil, then ALL subsequent data will be treated as binary + # data and passed to the upstream protocol handler as we receive it. + # If a limit is given, we'll hold the incoming binary data and not + # pass it upstream until we've seen it all, or until there is an unbind + # (in which case we'll pass up a partial). + # Specifying nil for the limit (the default) means there is no limit. + # Specifiyng zero for the limit will cause an immediate transition back to line mode. + # + def set_binary_mode size = nil + if @lbp_mode == :lines + if size == 0 + receive_binary_data("") if respond_to?(:receive_binary_data) + # Do no more work here. Stay in line mode and keep consuming data. + else + @lbp_binary_limit = size.to_i # (nil will be stored as zero) + if @lbp_binary_limit > 0 + raise "Overlength" if @lbp_binary_limit > MaxBinaryLength # arbitrary sanity check + @lbp_binary_buffer = "\0" * @lbp_binary_limit + @lbp_binary_bytes_received = 0 + end + + @lbp_mode = :binary + receive_data @lpb_buffer.flush + end + else + raise "invalid operation" + end + end + + #-- + # For internal use, establish protocol baseline for handling lines. + def lbp_init_line_state + @lpb_buffer = BufferedTokenizer.new("\n") + @lbp_mode = :lines + end + private :lbp_init_line_state + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/line_protocol.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/line_protocol.rb new file mode 100644 index 0000000..dfddae8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/line_protocol.rb @@ -0,0 +1,29 @@ +module EventMachine + module Protocols + # LineProtocol will parse out newline terminated strings from a receive_data stream + # + # module Server + # include EM::P::LineProtocol + # + # def receive_line(line) + # send_data("you said: #{line}") + # end + # end + # + module LineProtocol + # @private + def receive_data data + (@buf ||= '') << data + + while @buf.slice!(/(.*?)\r?\n/) + receive_line($1) + end + end + + # Invoked with lines received over the network + def receive_line(line) + # stub + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/linetext2.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/linetext2.rb new file mode 100644 index 0000000..9fdf28b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/linetext2.rb @@ -0,0 +1,179 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 15 November 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +module EventMachine + module Protocols + # In the grand, time-honored tradition of re-inventing the wheel, we offer + # here YET ANOTHER protocol that handles line-oriented data with interspersed + # binary text. This one trades away some of the performance optimizations of + # EventMachine::Protocols::LineAndTextProtocol in order to get better correctness + # with regard to binary text blocks that can switch back to line mode. It also + # permits the line-delimiter to change in midstream. + # This was originally written to support Stomp. + module LineText2 + # TODO! We're not enforcing the limits on header lengths and text-lengths. + # When we get around to that, call #receive_error if the user defined it, otherwise + # throw exceptions. + + MaxBinaryLength = 32*1024*1024 + + #-- + # Will loop internally until there's no data left to read. + # That way the user-defined handlers we call can modify the + # handling characteristics on a per-token basis. + # + def receive_data data + return unless (data and data.length > 0) + + # Do this stuff in lieu of a constructor. + @lt2_mode ||= :lines + @lt2_delimiter ||= "\n" + @lt2_linebuffer ||= [] + + remaining_data = data + + while remaining_data.length > 0 + if @lt2_mode == :lines + delimiter_string = case @lt2_delimiter + when Regexp + remaining_data.slice(@lt2_delimiter) + else + @lt2_delimiter + end + ix = remaining_data.index(delimiter_string) if delimiter_string + if ix + @lt2_linebuffer << remaining_data[0...ix] + ln = @lt2_linebuffer.join + @lt2_linebuffer.clear + if @lt2_delimiter == "\n" + ln.chomp! + end + receive_line ln + remaining_data = remaining_data[(ix+delimiter_string.length)..-1] + else + @lt2_linebuffer << remaining_data + remaining_data = "" + end + elsif @lt2_mode == :text + if @lt2_textsize + needed = @lt2_textsize - @lt2_textpos + will_take = if remaining_data.length > needed + needed + else + remaining_data.length + end + + @lt2_textbuffer << remaining_data[0...will_take] + tail = remaining_data[will_take..-1] + + @lt2_textpos += will_take + if @lt2_textpos >= @lt2_textsize + # Reset line mode (the default behavior) BEFORE calling the + # receive_binary_data. This makes it possible for user code + # to call set_text_mode, enabling chains of text blocks + # (which can possibly be of different sizes). + set_line_mode + receive_binary_data @lt2_textbuffer.join + receive_end_of_binary_data + end + + remaining_data = tail + else + receive_binary_data remaining_data + remaining_data = "" + end + end + end + end + + # The line delimiter may be a regular expression or a string. Anything + # passed to set_delimiter other than a regular expression will be + # converted to a string. + def set_delimiter delim + @lt2_delimiter = case delim + when Regexp + delim + else + delim.to_s + end + end + + # Called internally but also exposed to user code, for the case in which + # processing of binary data creates a need to transition back to line mode. + # We support an optional parameter to "throw back" some data, which might + # be an umprocessed chunk of the transmitted binary data, or something else + # entirely. + def set_line_mode data="" + @lt2_mode = :lines + (@lt2_linebuffer ||= []).clear + receive_data data.to_s + end + + def set_text_mode size=nil + if size == 0 + set_line_mode + else + @lt2_mode = :text + (@lt2_textbuffer ||= []).clear + @lt2_textsize = size # which can be nil, signifying no limit + @lt2_textpos = 0 + end + end + + # Alias for #set_text_mode, added for back-compatibility with LineAndTextProtocol. + def set_binary_mode size=nil + set_text_mode size + end + + # In case of a dropped connection, we'll send a partial buffer to user code + # when in sized text mode. User overrides of #receive_binary_data need to + # be aware that they may get a short buffer. + def unbind + @lt2_mode ||= nil + if @lt2_mode == :text and @lt2_textpos > 0 + receive_binary_data @lt2_textbuffer.join + end + end + + # Stub. Should be subclassed by user code. + def receive_line ln + # no-op + end + + # Stub. Should be subclassed by user code. + def receive_binary_data data + # no-op + end + + # Stub. Should be subclassed by user code. + # This is called when transitioning internally from text mode + # back to line mode. Useful when client code doesn't want + # to keep track of how much data it's received. + def receive_end_of_binary_data + # no-op + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/memcache.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/memcache.rb new file mode 100644 index 0000000..1f81aaf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/memcache.rb @@ -0,0 +1,331 @@ +module EventMachine + module Protocols + # Implements the Memcache protocol (http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt). + # Requires memcached >= 1.2.4 w/ noreply support + # + # == Usage example + # + # EM.run{ + # cache = EM::P::Memcache.connect 'localhost', 11211 + # + # cache.set :a, 'hello' + # cache.set :b, 'hi' + # cache.set :c, 'how are you?' + # cache.set :d, '' + # + # cache.get(:a){ |v| p v } + # cache.get_hash(:a, :b, :c, :d){ |v| p v } + # cache.get(:a,:b,:c,:d){ |a,b,c,d| p [a,b,c,d] } + # + # cache.get(:a,:z,:b,:y,:d){ |a,z,b,y,d| p [a,z,b,y,d] } + # + # cache.get(:missing){ |m| p [:missing=, m] } + # cache.set(:missing, 'abc'){ p :stored } + # cache.get(:missing){ |m| p [:missing=, m] } + # cache.del(:missing){ p :deleted } + # cache.get(:missing){ |m| p [:missing=, m] } + # } + # + module Memcache + include EM::Deferrable + + ## + # constants + + unless defined? Cempty + # @private + Cstored = 'STORED'.freeze + # @private + Cend = 'END'.freeze + # @private + Cdeleted = 'DELETED'.freeze + # @private + Cunknown = 'NOT_FOUND'.freeze + # @private + Cerror = 'ERROR'.freeze + + # @private + Cempty = ''.freeze + # @private + Cdelimiter = "\r\n".freeze + end + + ## + # commands + + # Get the value associated with one or multiple keys + # + # cache.get(:a){ |v| p v } + # cache.get(:a,:b,:c,:d){ |a,b,c,d| p [a,b,c,d] } + # + def get *keys + raise ArgumentError unless block_given? + + callback{ + keys = keys.map{|k| k.to_s.gsub(/\s/,'_') } + send_data "get #{keys.join(' ')}\r\n" + @get_cbs << [keys, proc{ |values| + yield *keys.map{ |k| values[k] } + }] + } + end + + # Set the value for a given key + # + # cache.set :a, 'hello' + # cache.set(:missing, 'abc'){ puts "stored the value!" } + # + def set key, val, exptime = 0, &cb + callback{ + val = val.to_s + send_cmd :set, key, 0, exptime, val.respond_to?(:bytesize) ? val.bytesize : val.size, !block_given? + send_data val + send_data Cdelimiter + @set_cbs << cb if cb + } + end + + # Gets multiple values as a hash + # + # cache.get_hash(:a, :b, :c, :d){ |h| puts h[:a] } + # + def get_hash *keys + raise ArgumentError unless block_given? + + get *keys do |*values| + yield keys.inject({}){ |hash, k| hash.update k => values[keys.index(k)] } + end + end + + # Delete the value associated with a key + # + # cache.del :a + # cache.del(:b){ puts "deleted the value!" } + # + def delete key, expires = 0, &cb + callback{ + send_data "delete #{key} #{expires}#{cb ? '' : ' noreply'}\r\n" + @del_cbs << cb if cb + } + end + alias del delete + + # Connect to a memcached server (must support NOREPLY, memcached >= 1.2.4) + def self.connect host = 'localhost', port = 11211 + EM.connect host, port, self, host, port + end + + def send_cmd cmd, key, flags = 0, exptime = 0, bytes = 0, noreply = false + send_data "#{cmd} #{key} #{flags} #{exptime} #{bytes}#{noreply ? ' noreply' : ''}\r\n" + end + private :send_cmd + + ## + # errors + + # @private + class ParserError < StandardError + end + + ## + # em hooks + + # @private + def initialize host, port = 11211 + @host, @port = host, port + end + + # @private + def connection_completed + @get_cbs = [] + @set_cbs = [] + @del_cbs = [] + + @values = {} + + @reconnecting = false + @connected = true + succeed + # set_delimiter "\r\n" + # set_line_mode + end + + #-- + # 19Feb09 Switched to a custom parser, LineText2 is recursive and can cause + # stack overflows when there is too much data. + # include EM::P::LineText2 + # @private + def receive_data data + (@buffer||='') << data + + while index = @buffer.index(Cdelimiter) + begin + line = @buffer.slice!(0,index+2) + process_cmd line + rescue ParserError + @buffer[0...0] = line + break + end + end + end + + #-- + # def receive_line line + # @private + def process_cmd line + case line.strip + when /^VALUE\s+(.+?)\s+(\d+)\s+(\d+)/ # VALUE + bytes = Integer($3) + # set_binary_mode bytes+2 + # @cur_key = $1 + if @buffer.size >= bytes + 2 + @values[$1] = @buffer.slice!(0,bytes) + @buffer.slice!(0,2) # \r\n + else + raise ParserError + end + + when Cend # END + if entry = @get_cbs.shift + keys, cb = entry + cb.call(@values) + end + @values = {} + + when Cstored # STORED + if cb = @set_cbs.shift + cb.call(true) + end + + when Cdeleted # DELETED + if cb = @del_cbs.shift + cb.call(true) + end + + when Cunknown # NOT_FOUND + if cb = @del_cbs.shift + cb.call(false) + end + + else + p [:MEMCACHE_UNKNOWN, line] + end + end + + #-- + # def receive_binary_data data + # @values[@cur_key] = data[0..-3] + # end + + # @private + def unbind + if @connected or @reconnecting + EM.add_timer(1){ reconnect @host, @port } + @connected = false + @reconnecting = true + @deferred_status = nil + else + raise 'Unable to connect to memcached server' + end + end + end + end +end + +if __FILE__ == $0 + # ruby -I ext:lib -r eventmachine -rubygems lib/protocols/memcache.rb + require 'em/spec' + + # @private + class TestConnection + include EM::P::Memcache + def send_data data + sent_data << data + end + def sent_data + @sent_data ||= '' + end + + def initialize + connection_completed + end + end + + EM.describe EM::Protocols::Memcache do + + before{ + @c = TestConnection.new + } + + should 'send get requests' do + @c.get('a'){} + @c.sent_data.should == "get a\r\n" + done + end + + should 'send set requests' do + @c.set('a', 1){} + @c.sent_data.should == "set a 0 0 1\r\n1\r\n" + done + end + + should 'use noreply on set without block' do + @c.set('a', 1) + @c.sent_data.should == "set a 0 0 1 noreply\r\n1\r\n" + done + end + + should 'send delete requests' do + @c.del('a') + @c.sent_data.should == "delete a 0 noreply\r\n" + done + end + + should 'work when get returns no values' do + @c.get('a'){ |a| + a.should.be.nil + done + } + + @c.receive_data "END\r\n" + end + + should 'invoke block on set' do + @c.set('a', 1){ + done + } + + @c.receive_data "STORED\r\n" + end + + should 'invoke block on delete' do + @c.delete('a'){ |found| + found.should.be.false + } + @c.delete('b'){ |found| + found.should.be.true + done + } + + @c.receive_data "NOT_FOUND\r\n" + @c.receive_data "DELETED\r\n" + end + + should 'parse split responses' do + @c.get('a'){ |a| + a.should == 'abc' + done + } + + @c.receive_data "VAL" + @c.receive_data "UE a 0 " + @c.receive_data "3\r\n" + @c.receive_data "ab" + @c.receive_data "c" + @c.receive_data "\r\n" + @c.receive_data "EN" + @c.receive_data "D\r\n" + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/object_protocol.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/object_protocol.rb new file mode 100644 index 0000000..ec79cb4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/object_protocol.rb @@ -0,0 +1,46 @@ +module EventMachine + module Protocols + # ObjectProtocol allows for easy communication using marshaled ruby objects + # + # module RubyServer + # include EM::P::ObjectProtocol + # + # def receive_object obj + # send_object({'you said' => obj}) + # end + # end + # + module ObjectProtocol + # By default returns Marshal, override to return JSON or YAML, or any + # other serializer/deserializer responding to #dump and #load. + def serializer + Marshal + end + + # @private + def receive_data data + (@buf ||= '') << data + + while @buf.size >= 4 + if @buf.size >= 4+(size=@buf.unpack('N').first) + @buf.slice!(0,4) + receive_object serializer.load(@buf.slice!(0,size)) + else + break + end + end + end + + # Invoked with ruby objects received over the network + def receive_object obj + # stub + end + + # Sends a ruby object over the network + def send_object obj + data = serializer.dump(obj) + send_data [data.respond_to?(:bytesize) ? data.bytesize : data.size, data].pack('Na*') + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/postgres3.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/postgres3.rb new file mode 100644 index 0000000..7d87505 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/postgres3.rb @@ -0,0 +1,246 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 15 November 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-08 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# +# + +require 'postgres-pr/message' +require 'postgres-pr/connection' +require 'stringio' + +# @private +class StringIO + # Reads exactly +n+ bytes. + # + # If the data read is nil an EOFError is raised. + # + # If the data read is too short an IOError is raised + def readbytes(n) + str = read(n) + if str == nil + raise EOFError, "End of file reached" + end + if str.size < n + raise IOError, "data truncated" + end + str + end + alias read_exactly_n_bytes readbytes +end + + +module EventMachine + module Protocols + # PROVISIONAL IMPLEMENTATION of an evented Postgres client. + # This implements version 3 of the Postgres wire protocol, which will work + # with any Postgres version from roughly 7.4 onward. + # + # Objective: we want to access Postgres databases without requiring threads. + # Until now this has been a problem because the Postgres client implementations + # have all made use of blocking I/O calls, which is incompatible with a + # thread-free evented model. + # + # But rather than re-implement the Postgres Wire3 protocol, we're taking advantage + # of the existing postgres-pr library, which was originally written by Michael + # Neumann but (at this writing) appears to be no longer maintained. Still, it's + # in basically a production-ready state, and the wire protocol isn't that complicated + # anyway. + # + # We're tucking in a bunch of require statements that may not be present in garden-variety + # EM installations. Until we find a good way to only require these if a program + # requires postgres, this file will need to be required explicitly. + # + # We need to monkeypatch StringIO because it lacks the #readbytes method needed + # by postgres-pr. + # The StringIO monkeypatch is lifted from the standard library readbytes.rb, + # which adds method #readbytes directly to class IO. But StringIO is not a subclass of IO. + # It is modified to raise an IOError instead of TruncatedDataException since the exception is unused. + # + # We cloned the handling of postgres messages from lib/postgres-pr/connection.rb + # in the postgres-pr library, and modified it for event-handling. + # + # TODO: The password handling in dispatch_conn_message is totally incomplete. + # + # + # We return Deferrables from the user-level operations surfaced by this interface. + # Experimentally, we're using the pattern of always returning a boolean value as the + # first argument of a deferrable callback to indicate success or failure. This is + # instead of the traditional pattern of calling Deferrable#succeed or #fail, and + # requiring the user to define both a callback and an errback function. + # + # === Usage + # EM.run { + # db = EM.connect_unix_domain( "/tmp/.s.PGSQL.5432", EM::P::Postgres3 ) + # db.connect( dbname, username, psw ).callback do |status| + # if status + # db.query( "select * from some_table" ).callback do |status, result, errors| + # if status + # result.rows.each do |row| + # p row + # end + # end + # end + # end + # end + # } + class Postgres3 < EventMachine::Connection + include PostgresPR + + def initialize + @data = "" + @params = {} + end + + def connect db, user, psw=nil + d = EM::DefaultDeferrable.new + d.timeout 15 + + if @pending_query || @pending_conn + d.succeed false, "Operation already in progress" + else + @pending_conn = d + prms = {"user"=>user, "database"=>db} + @user = user + if psw + @password = psw + #prms["password"] = psw + end + send_data PostgresPR::StartupMessage.new( 3 << 16, prms ).dump + end + + d + end + + def query sql + d = EM::DefaultDeferrable.new + d.timeout 15 + + if @pending_query || @pending_conn + d.succeed false, "Operation already in progress" + else + @r = PostgresPR::Connection::Result.new + @e = [] + @pending_query = d + send_data PostgresPR::Query.dump(sql) + end + + d + end + + + def receive_data data + @data << data + while @data.length >= 5 + pktlen = @data[1...5].unpack("N").first + if @data.length >= (1 + pktlen) + pkt = @data.slice!(0...(1+pktlen)) + m = StringIO.open( pkt, "r" ) {|io| PostgresPR::Message.read( io ) } + if @pending_conn + dispatch_conn_message m + elsif @pending_query + dispatch_query_message m + else + raise "Unexpected message from database" + end + else + break # very important, break out of the while + end + end + end + + + def unbind + if o = (@pending_query || @pending_conn) + o.succeed false, "lost connection" + end + end + + # Cloned and modified from the postgres-pr. + def dispatch_conn_message msg + case msg + when AuthentificationClearTextPassword + raise ArgumentError, "no password specified" if @password.nil? + send_data PasswordMessage.new(@password).dump + + when AuthentificationCryptPassword + raise ArgumentError, "no password specified" if @password.nil? + send_data PasswordMessage.new(@password.crypt(msg.salt)).dump + + when AuthentificationMD5Password + raise ArgumentError, "no password specified" if @password.nil? + require 'digest/md5' + + m = Digest::MD5.hexdigest(@password + @user) + m = Digest::MD5.hexdigest(m + msg.salt) + m = 'md5' + m + send_data PasswordMessage.new(m).dump + + when AuthentificationKerberosV4, AuthentificationKerberosV5, AuthentificationSCMCredential + raise "unsupported authentification" + + when AuthentificationOk + when ErrorResponse + raise msg.field_values.join("\t") + when NoticeResponse + @notice_processor.call(msg) if @notice_processor + when ParameterStatus + @params[msg.key] = msg.value + when BackendKeyData + # TODO + #p msg + when ReadyForQuery + # TODO: use transaction status + pc,@pending_conn = @pending_conn,nil + pc.succeed true + else + raise "unhandled message type" + end + end + + # Cloned and modified from the postgres-pr. + def dispatch_query_message msg + case msg + when DataRow + @r.rows << msg.columns + when CommandComplete + @r.cmd_tag = msg.cmd_tag + when ReadyForQuery + pq,@pending_query = @pending_query,nil + pq.succeed true, @r, @e + when RowDescription + @r.fields = msg.fields + when CopyInResponse + when CopyOutResponse + when EmptyQueryResponse + when ErrorResponse + # TODO + @e << msg + when NoticeResponse + @notice_processor.call(msg) if @notice_processor + else + # TODO + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/saslauth.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/saslauth.rb new file mode 100644 index 0000000..9cabc51 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/saslauth.rb @@ -0,0 +1,175 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 15 November 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# +# + +module EventMachine + module Protocols + + # Implements SASL authd. + # This is a very, very simple protocol that mimics the one used + # by saslauthd and pwcheck, two outboard daemons included in the + # standard SASL library distro. + # The only thing this is really suitable for is SASL PLAIN + # (user+password) authentication, but the SASL libs that are + # linked into standard servers (like imapd and sendmail) implement + # the other ones. + # + # SASL-auth is intended for reasonably fast operation inside a + # single machine, so it has no transport-security (although there + # have been multi-machine extensions incorporating transport-layer + # encryption). + # + # The standard saslauthd module generally runs privileged and does + # its work by referring to the system-account files. + # + # This feature was added to EventMachine to enable the development + # of custom authentication/authorization engines for standard servers. + # + # To use SASLauth, include it in a class that subclasses EM::Connection, + # and reimplement the validate method. + # + # The typical way to incorporate this module into an authentication + # daemon would be to set it as the handler for a UNIX-domain socket. + # The code might look like this: + # + # EM.start_unix_domain_server( "/var/run/saslauthd/mux", MyHandler ) + # File.chmod( 0777, "/var/run/saslauthd/mux") + # + # The chmod is probably needed to ensure that unprivileged clients can + # access the UNIX-domain socket. + # + # It's also a very good idea to drop superuser privileges (if any), after + # the UNIX-domain socket has been opened. + #-- + # Implementation details: assume the client can send us pipelined requests, + # and that the client will close the connection. + # + # The client sends us four values, each encoded as a two-byte length field in + # network order followed by the specified number of octets. + # The fields specify the username, password, service name (such as imap), + # and the "realm" name. We send back the barest minimum reply, a single + # field also encoded as a two-octet length in network order, followed by + # either "NO" or "OK" - simplicity itself. + # + # We enforce a maximum field size just as a sanity check. + # We do NOT automatically time out the connection. + # + # The code we use to parse out the values is ugly and probably slow. + # Improvements welcome. + # + module SASLauth + + MaxFieldSize = 128*1024 + def post_init + super + @sasl_data = "" + @sasl_values = [] + end + + def receive_data data + @sasl_data << data + while @sasl_data.length >= 2 + len = (@sasl_data[0,2].unpack("n")).first + raise "SASL Max Field Length exceeded" if len > MaxFieldSize + if @sasl_data.length >= (len + 2) + @sasl_values << @sasl_data[2,len] + @sasl_data.slice!(0...(2+len)) + if @sasl_values.length == 4 + send_data( validate(*@sasl_values) ? "\0\002OK" : "\0\002NO" ) + @sasl_values.clear + end + else + break + end + end + end + + def validate username, psw, sysname, realm + p username + p psw + p sysname + p realm + true + end + end + + # Implements the SASL authd client protocol. + # This is a very, very simple protocol that mimics the one used + # by saslauthd and pwcheck, two outboard daemons included in the + # standard SASL library distro. + # The only thing this is really suitable for is SASL PLAIN + # (user+password) authentication, but the SASL libs that are + # linked into standard servers (like imapd and sendmail) implement + # the other ones. + # + # You can use this module directly as a handler for EM Connections, + # or include it in a module or handler class of your own. + # + # First connect to a SASL server (it's probably a TCP server, or more + # likely a Unix-domain socket). Then call the #validate? method, + # passing at least a username and a password. #validate? returns + # a Deferrable which will either succeed or fail, depending + # on the status of the authentication operation. + # + module SASLauthclient + MaxFieldSize = 128*1024 + + def validate? username, psw, sysname=nil, realm=nil + + str = [username, psw, sysname, realm].map {|m| + [(m || "").length, (m || "")] + }.flatten.pack( "nA*" * 4 ) + send_data str + + d = EM::DefaultDeferrable.new + @queries.unshift d + d + end + + def post_init + @sasl_data = "" + @queries = [] + end + + def receive_data data + @sasl_data << data + + while @sasl_data.length > 2 + len = (@sasl_data[0,2].unpack("n")).first + raise "SASL Max Field Length exceeded" if len > MaxFieldSize + if @sasl_data.length >= (len + 2) + val = @sasl_data[2,len] + @sasl_data.slice!(0...(2+len)) + q = @queries.pop + (val == "NO") ? q.fail : q.succeed + else + break + end + end + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/smtpclient.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/smtpclient.rb new file mode 100644 index 0000000..25ad17a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/smtpclient.rb @@ -0,0 +1,394 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 July 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +require 'ostruct' + +module EventMachine + module Protocols + + # Simple SMTP client + # + # @example + # email = EM::Protocols::SmtpClient.send( + # :domain=>"example.com", + # :host=>'localhost', + # :port=>25, # optional, defaults 25 + # :starttls=>true, # use ssl + # :from=>"sender@example.com", + # :to=> ["to_1@example.com", "to_2@example.com"], + # :header=> {"Subject" => "This is a subject line"}, + # :body=> "This is the body of the email" + # ) + # email.callback{ + # puts 'Email sent!' + # } + # email.errback{ |e| + # puts 'Email failed!' + # } + # + # Sending generated emails (using Mail) + # + # mail = Mail.new do + # from 'alice@example.com' + # to 'bob@example.com' + # subject 'This is a test email' + # body 'Hello, world!' + # end + # + # email = EM::P::SmtpClient.send( + # :domain=>'example.com', + # :from=>mail.from.first, + # :to=>mail.to, + # :message=>mail.to_s + # ) + # + class SmtpClient < Connection + include EventMachine::Deferrable + include EventMachine::Protocols::LineText2 + + def initialize + @succeeded = nil + @responder = nil + @code = nil + @msg = nil + end + + # :host => required String + # a string containing the IP address or host name of the SMTP server to connect to. + # :port => optional + # defaults to 25. + # :domain => required String + # This is passed as the argument to the EHLO command. + # :starttls => optional Boolean + # If it evaluates true, then the client will initiate STARTTLS with + # the server, and abort the connection if the negotiation doesn't succeed. + # TODO, need to be able to pass certificate parameters with this option. + # :auth => optional Hash of auth parameters + # If not given, then no auth will be attempted. + # (In that case, the connection will be aborted if the server requires auth.) + # Specify the hash value :type to determine the auth type, along with additional parameters + # depending on the type. + # Currently only :type => :plain is supported. Pass additional parameters :username (String), + # and :password (either a String or a Proc that will be called at auth-time). + # + # @example + # :auth => {:type=>:plain, :username=>"mickey@disney.com", :password=>"mouse"} + # + # :from => required String + # Specifies the sender of the message. Will be passed as the argument + # to the MAIL FROM. Do NOT enclose the argument in angle-bracket (<>) characters. + # The connection will abort if the server rejects the value. + # :to => required String or Array of Strings + # The recipient(s) of the message. Do NOT enclose + # any of the values in angle-brackets (<>) characters. It's NOT a fatal error if one or more + # recipients are rejected by the server. (Of course, if ALL of them are, the server will most + # likely trigger an error when we try to send data.) An array of codes containing the status + # of each requested recipient is available after the call completes. TODO, we should define + # an overridable stub that will be called on rejection of a recipient or a sender, giving + # user code the chance to try again or abort the connection. + # + # One of either :message, :content, or :header and :body is required: + # + # :message => String + # A valid RFC2822 Internet Message. + # :content => String + # Raw data which MUST be in correct SMTP body format, with escaped leading dots and a trailing + # dot line. + # :header => String or Hash of values to be transmitted in the header of the message. + # The hash keys are the names of the headers (do NOT append a trailing colon), and the values + # are strings containing the header values. TODO, support Arrays of header values, which would + # cause us to send that specific header line more than once. + # + # @example + # :header => {"Subject" => "Bogus", "CC" => "myboss@example.com"} + # + # :body => Optional String or Array of Strings, defaults blank. + # This will be passed as the body of the email message. + # TODO, this needs to be significantly beefed up. As currently written, this requires the caller + # to properly format the input into CRLF-delimited lines of 7-bit characters in the standard + # SMTP transmission format. We need to be able to automatically convert binary data, and add + # correct line-breaks to text data. + # + # :verbose => Optional. + # If true, will cause a lot of information (including the server-side of the + # conversation) to be dumped to $>. + # + def self.send args={} + args[:port] ||= 25 + args[:body] ||= "" + +=begin + (I don't think it's possible for EM#connect to throw an exception under normal + circumstances, so this original code is stubbed out. A connect-failure will result + in the #unbind method being called without calling #connection_completed.) + begin + EventMachine.connect( args[:host], args[:port], self) {|c| + # According to the EM docs, we will get here AFTER post_init is called. + c.args = args + c.set_comm_inactivity_timeout 60 + } + rescue + # We'll get here on a connect error. This code mimics the effect + # of a call to invoke_internal_error. Would be great to DRY this up. + # (Actually, it may be that we never get here, if EM#connect catches + # its errors internally.) + d = EM::DefaultDeferrable.new + d.set_deferred_status(:failed, {:error=>[:connect, 500, "unable to connect to server"]}) + d + end +=end + EventMachine.connect( args[:host], args[:port], self) {|c| + # According to the EM docs, we will get here AFTER post_init is called. + c.args = args + c.set_comm_inactivity_timeout 60 + } + end + + attr_writer :args + + # @private + def post_init + @return_values = OpenStruct.new + @return_values.start_time = Time.now + end + + # @private + def connection_completed + @responder = :receive_signon + @msg = [] + end + + # We can get here in a variety of ways, all of them being failures unless + # the @succeeded flag is set. If a protocol success was recorded, then don't + # set a deferred success because the caller will already have done it + # (no need to wait until the connection closes to invoke the callbacks). + # + # @private + def unbind + unless @succeeded + @return_values.elapsed_time = Time.now - @return_values.start_time + @return_values.responder = @responder + @return_values.code = @code + @return_values.message = @msg + set_deferred_status(:failed, @return_values) + end + end + + # @private + def receive_line ln + $>.puts ln if @args[:verbose] + @range = ln[0...1].to_i + @code = ln[0...3].to_i + @msg << ln[4..-1] + unless ln[3...4] == '-' + $>.puts @responder if @args[:verbose] + send @responder + @msg.clear + end + end + + private + + # We encountered an error from the server and will close the connection. + # Use the error and message the server returned. + # + def invoke_error + @return_values.elapsed_time = Time.now - @return_values.start_time + @return_values.responder = @responder + @return_values.code = @code + @return_values.message = @msg + set_deferred_status :failed, @return_values + send_data "QUIT\r\n" + close_connection_after_writing + end + + # We encountered an error on our side of the protocol and will close the connection. + # Use an extra-protocol error code (900) and use the message from the caller. + # + def invoke_internal_error msg = "???" + @return_values.elapsed_time = Time.now - @return_values.start_time + @return_values.responder = @responder + @return_values.code = 900 + @return_values.message = msg + set_deferred_status :failed, @return_values + send_data "QUIT\r\n" + close_connection_after_writing + end + + def send_ehlo + send_data "EHLO #{@args[:domain]}\r\n" + end + + def receive_signon + return invoke_error unless @range == 2 + send_ehlo + @responder = :receive_ehlo_response + end + def receive_ehlo_response + return invoke_error unless @range == 2 + @server_caps = @msg + invoke_starttls + end + + def invoke_starttls + if @args[:starttls] + # It would be more sociable to first ask if @server_caps contains + # the string "STARTTLS" before we invoke it, but hey, life's too short. + send_data "STARTTLS\r\n" + @responder = :receive_starttls_response + else + invoke_auth + end + end + def receive_starttls_response + return invoke_error unless @range == 2 + start_tls + invoke_ehlo_over_tls + end + + def invoke_ehlo_over_tls + send_ehlo + @responder = :receive_ehlo_over_tls_response + end + def receive_ehlo_over_tls_response + return invoke_error unless @range == 2 + invoke_auth + end + + # Perform an authentication. If the caller didn't request one, then fall through + # to the mail-from state. + def invoke_auth + if @args[:auth] + if @args[:auth][:type] == :plain + psw = @args[:auth][:password] + if psw.respond_to?(:call) + psw = psw.call + end + #str = Base64::encode64("\0#{@args[:auth][:username]}\0#{psw}").chomp + str = ["\0#{@args[:auth][:username]}\0#{psw}"].pack("m").gsub(/\n/, '') + send_data "AUTH PLAIN #{str}\r\n" + @responder = :receive_auth_response + else + return invoke_internal_error("unsupported auth type") + end + else + invoke_mail_from + end + end + def receive_auth_response + return invoke_error unless @range == 2 + invoke_mail_from + end + + def invoke_mail_from + send_data "MAIL FROM: <#{@args[:from]}>\r\n" + @responder = :receive_mail_from_response + end + def receive_mail_from_response + return invoke_error unless @range == 2 + invoke_rcpt_to + end + + def invoke_rcpt_to + @rcpt_responses ||= [] + l = @rcpt_responses.length + to = @args[:to].is_a?(Array) ? @args[:to] : [@args[:to].to_s] + if l < to.length + send_data "RCPT TO: <#{to[l]}>\r\n" + @responder = :receive_rcpt_to_response + else + e = @rcpt_responses.select {|rr| rr.last == 2} + if e and e.length > 0 + invoke_data + else + invoke_error + end + end + end + def receive_rcpt_to_response + @rcpt_responses << [@code, @msg, @range] + invoke_rcpt_to + end + + def escape_leading_dots(s) + s.gsub(/^\./, '..') + end + + def invoke_data + send_data "DATA\r\n" + @responder = :receive_data_response + end + def receive_data_response + return invoke_error unless @range == 3 + + # The data to send can be given in either @args[:message], @args[:content], or the + # combination of @args[:header] and @args[:body]. + # + # - @args[:message] (String) MUST be a valid RFC2822 Internet Message + # + # - @args[:content] (String) MUST be in correct SMTP body format, with escaped + # leading dots and a trailing dot line + # + # - @args[:header] (Hash or String) + # - @args[:body] (Array or String) + if @args[:message] + send_data escape_leading_dots(@args[:message].to_s) + send_data "\r\n.\r\n" + elsif @args[:content] + send_data @args[:content].to_s + else + # The header can be a hash or an array. + if @args[:header].is_a?(Hash) + (@args[:header] || {}).each {|k,v| send_data escape_leading_dots("#{k}: #{v}\r\n") } + else + send_data escape_leading_dots(@args[:header].to_s) + end + send_data "\r\n" + + if @args[:body].is_a?(Array) + @args[:body].each {|e| send_data escape_leading_dots(e)} + else + send_data escape_leading_dots(@args[:body].to_s) + end + + send_data "\r\n.\r\n" + end + + @responder = :receive_message_response + end + def receive_message_response + return invoke_error unless @range == 2 + send_data "QUIT\r\n" + close_connection_after_writing + @succeeded = true + @return_values.elapsed_time = Time.now - @return_values.start_time + @return_values.responder = @responder + @return_values.code = @code + @return_values.message = @msg + set_deferred_status :succeeded, @return_values + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/smtpserver.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/smtpserver.rb new file mode 100644 index 0000000..e0f1f05 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/smtpserver.rb @@ -0,0 +1,666 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 July 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +module EventMachine + module Protocols + + # This is a protocol handler for the server side of SMTP. + # It's NOT a complete SMTP server obeying all the semantics of servers conforming to + # RFC2821. Rather, it uses overridable method stubs to communicate protocol states + # and data to user code. User code is responsible for doing the right things with the + # data in order to get complete and correct SMTP server behavior. + # + # Simple SMTP server example: + # + # class EmailServer < EM::P::SmtpServer + # def receive_plain_auth(user, pass) + # true + # end + # + # def get_server_domain + # "mock.smtp.server.local" + # end + # + # def get_server_greeting + # "mock smtp server greets you with impunity" + # end + # + # def receive_sender(sender) + # current.sender = sender + # true + # end + # + # def receive_recipient(recipient) + # current.recipient = recipient + # true + # end + # + # def receive_message + # current.received = true + # current.completed_at = Time.now + # + # p [:received_email, current] + # @current = OpenStruct.new + # true + # end + # + # def receive_ehlo_domain(domain) + # @ehlo_domain = domain + # true + # end + # + # def receive_data_command + # current.data = "" + # true + # end + # + # def receive_data_chunk(data) + # current.data << data.join("\n") + # true + # end + # + # def receive_transaction + # if @ehlo_domain + # current.ehlo_domain = @ehlo_domain + # @ehlo_domain = nil + # end + # true + # end + # + # def current + # @current ||= OpenStruct.new + # end + # + # def self.start(host = 'localhost', port = 1025) + # require 'ostruct' + # @server = EM.start_server host, port, self + # end + # + # def self.stop + # if @server + # EM.stop_server @server + # @server = nil + # end + # end + # + # def self.running? + # !!@server + # end + # end + # + # EM.run{ EmailServer.start } + # + #-- + # Useful paragraphs in RFC-2821: + # 4.3.2: Concise list of command-reply sequences, in essence a text representation + # of the command state-machine. + # + # STARTTLS is defined in RFC2487. + # Observe that there are important rules governing whether a publicly-referenced server + # (meaning one whose Internet address appears in public MX records) may require the + # non-optional use of TLS. + # Non-optional TLS does not apply to EHLO, NOOP, QUIT or STARTTLS. + class SmtpServer < EventMachine::Connection + include Protocols::LineText2 + + HeloRegex = /\AHELO\s*/i + EhloRegex = /\AEHLO\s*/i + QuitRegex = /\AQUIT/i + MailFromRegex = /\AMAIL FROM:\s*/i + RcptToRegex = /\ARCPT TO:\s*/i + DataRegex = /\ADATA/i + NoopRegex = /\ANOOP/i + RsetRegex = /\ARSET/i + VrfyRegex = /\AVRFY\s+/i + ExpnRegex = /\AEXPN\s+/i + HelpRegex = /\AHELP/i + StarttlsRegex = /\ASTARTTLS/i + AuthRegex = /\AAUTH\s+/i + + + # Class variable containing default parameters that can be overridden + # in application code. + # Individual objects of this class will make an instance-local copy of + # the class variable, so that they can be reconfigured on a per-instance + # basis. + # + # Chunksize is the number of data lines we'll buffer before + # sending them to the application. TODO, make this user-configurable. + # + @@parms = { + :chunksize => 4000, + :verbose => false + } + def self.parms= parms={} + @@parms.merge!(parms) + end + + + + def initialize *args + super + @parms = @@parms + init_protocol_state + end + + def parms= parms={} + @parms.merge!(parms) + end + + # In SMTP, the server talks first. But by a (perhaps flawed) axiom in EM, + # #post_init will execute BEFORE the block passed to #start_server, for any + # given accepted connection. Since in this class we'll probably be getting + # a lot of initialization parameters, we want the guts of post_init to + # run AFTER the application has initialized the connection object. So we + # use a spawn to schedule the post_init to run later. + # It's a little weird, I admit. A reasonable alternative would be to set + # parameters as a class variable and to do that before accepting any connections. + # + # OBSOLETE, now we have @@parms. But the spawn is nice to keep as an illustration. + # + def post_init + #send_data "220 #{get_server_greeting}\r\n" (ORIGINAL) + #(EM.spawn {|x| x.send_data "220 #{x.get_server_greeting}\r\n"}).notify(self) + (EM.spawn {|x| x.send_server_greeting}).notify(self) + end + + def send_server_greeting + send_data "220 #{get_server_greeting}\r\n" + end + + def receive_line ln + @@parms[:verbose] and $>.puts ">>> #{ln}" + + return process_data_line(ln) if @state.include?(:data) + return process_auth_line(ln) if @state.include?(:auth_incomplete) + + case ln + when EhloRegex + process_ehlo $'.dup + when HeloRegex + process_helo $'.dup + when MailFromRegex + process_mail_from $'.dup + when RcptToRegex + process_rcpt_to $'.dup + when DataRegex + process_data + when RsetRegex + process_rset + when VrfyRegex + process_vrfy + when ExpnRegex + process_expn + when HelpRegex + process_help + when NoopRegex + process_noop + when QuitRegex + process_quit + when StarttlsRegex + process_starttls + when AuthRegex + process_auth $'.dup + else + process_unknown + end + end + + # TODO - implement this properly, the implementation is a stub! + def process_help + send_data "250 Ok, but unimplemented\r\n" + end + + # RFC2821, 3.5.3 Meaning of VRFY or EXPN Success Response: + # A server MUST NOT return a 250 code in response to a VRFY or EXPN + # command unless it has actually verified the address. In particular, + # a server MUST NOT return 250 if all it has done is to verify that the + # syntax given is valid. In that case, 502 (Command not implemented) + # or 500 (Syntax error, command unrecognized) SHOULD be returned. + # + # TODO - implement this properly, the implementation is a stub! + def process_vrfy + send_data "502 Command not implemented\r\n" + end + # TODO - implement this properly, the implementation is a stub! + def process_expn + send_data "502 Command not implemented\r\n" + end + + #-- + # This is called at several points to restore the protocol state + # to a pre-transaction state. In essence, we "forget" having seen + # any valid command except EHLO and STARTTLS. + # We also have to callback user code, in case they're keeping track + # of senders, recipients, and whatnot. + # + # We try to follow the convention of avoiding the verb "receive" for + # internal method names except receive_line (which we inherit), and + # using only receive_xxx for user-overridable stubs. + # + # init_protocol_state is called when we initialize the connection as + # well as during reset_protocol_state. It does NOT call the user + # override method. This enables us to promise the users that they + # won't see the overridable fire except after EHLO and RSET, and + # after a message has been received. Although the latter may be wrong. + # The standard may allow multiple DATA segments with the same set of + # senders and recipients. + # + def reset_protocol_state + init_protocol_state + s,@state = @state,[] + @state << :starttls if s.include?(:starttls) + @state << :ehlo if s.include?(:ehlo) + receive_transaction + end + def init_protocol_state + @state ||= [] + end + + + #-- + # EHLO/HELO is always legal, per the standard. On success + # it always clears buffers and initiates a mail "transaction." + # Which means that a MAIL FROM must follow. + # + # Per the standard, an EHLO/HELO or a RSET "initiates" an email + # transaction. Thereafter, MAIL FROM must be received before + # RCPT TO, before DATA. Not sure what this specific ordering + # achieves semantically, but it does make it easier to + # implement. We also support user-specified requirements for + # STARTTLS and AUTH. We make it impossible to proceed to MAIL FROM + # without fulfilling tls and/or auth, if the user specified either + # or both as required. We need to check the extension standard + # for auth to see if a credential is discarded after a RSET along + # with all the rest of the state. We'll behave as if it is. + # Now clearly, we can't discard tls after its been negotiated + # without dropping the connection, so that flag doesn't get cleared. + # + def process_ehlo domain + if receive_ehlo_domain domain + send_data "250-#{get_server_domain}\r\n" + if @@parms[:starttls] + send_data "250-STARTTLS\r\n" + end + if @@parms[:auth] + send_data "250-AUTH PLAIN\r\n" + end + send_data "250-NO-SOLICITING\r\n" + # TODO, size needs to be configurable. + send_data "250 SIZE 20000000\r\n" + reset_protocol_state + @state << :ehlo + else + send_data "550 Requested action not taken\r\n" + end + end + + def process_helo domain + if receive_ehlo_domain domain.dup + send_data "250 #{get_server_domain}\r\n" + reset_protocol_state + @state << :ehlo + else + send_data "550 Requested action not taken\r\n" + end + end + + def process_quit + send_data "221 Ok\r\n" + close_connection_after_writing + end + + def process_noop + send_data "250 Ok\r\n" + end + + def process_unknown + send_data "500 Unknown command\r\n" + end + + #-- + # So far, only AUTH PLAIN is supported but we should do at least LOGIN as well. + # TODO, support clients that send AUTH PLAIN with no parameter, expecting a 3xx + # response and a continuation of the auth conversation. + # + def process_auth str + if @state.include?(:auth) + send_data "503 auth already issued\r\n" + elsif str =~ /\APLAIN\s?/i + if $'.length == 0 + # we got a partial response, so let the client know to send the rest + @state << :auth_incomplete + send_data("334 \r\n") + else + # we got the initial response, so go ahead & process it + process_auth_line($') + end + #elsif str =~ /\ALOGIN\s+/i + else + send_data "504 auth mechanism not available\r\n" + end + end + + def process_auth_line(line) + plain = line.unpack("m").first + _,user,psw = plain.split("\000") + + succeeded = proc { + send_data "235 authentication ok\r\n" + @state << :auth + } + failed = proc { + send_data "535 invalid authentication\r\n" + } + auth = receive_plain_auth user,psw + + if auth.respond_to?(:callback) + auth.callback(&succeeded) + auth.errback(&failed) + else + (auth ? succeeded : failed).call + end + + @state.delete :auth_incomplete + end + + #-- + # Unusually, we can deal with a Deferrable returned from the user application. + # This was added to deal with a special case in a particular application, but + # it would be a nice idea to add it to the other user-code callbacks. + # + def process_data + unless @state.include?(:rcpt) + send_data "503 Operation sequence error\r\n" + else + succeeded = proc { + send_data "354 Send it\r\n" + @state << :data + @databuffer = [] + } + failed = proc { + send_data "550 Operation failed\r\n" + } + + d = receive_data_command + + if d.respond_to?(:callback) + d.callback(&succeeded) + d.errback(&failed) + else + (d ? succeeded : failed).call + end + end + end + + def process_rset + reset_protocol_state + receive_reset + send_data "250 Ok\r\n" + end + + def unbind + connection_ended + end + + #-- + # STARTTLS may not be issued before EHLO, or unless the user has chosen + # to support it. + # + # If :starttls_options is present and :starttls is set in the parms + # pass the options in :starttls_options to start_tls. Do this if you want to use + # your own certificate + # e.g. {:cert_chain_file => "/etc/ssl/cert.pem", :private_key_file => "/etc/ssl/private/cert.key"} + + def process_starttls + if @@parms[:starttls] + if @state.include?(:starttls) + send_data "503 TLS Already negotiated\r\n" + elsif ! @state.include?(:ehlo) + send_data "503 EHLO required before STARTTLS\r\n" + else + send_data "220 Start TLS negotiation\r\n" + start_tls(@@parms[:starttls_options] || {}) + @state << :starttls + end + else + process_unknown + end + end + + + #-- + # Requiring TLS is touchy, cf RFC2784. + # Requiring AUTH seems to be much more reasonable. + # We don't currently support any notion of deriving an authentication from the TLS + # negotiation, although that would certainly be reasonable. + # We DON'T allow MAIL FROM to be given twice. + # We DON'T enforce all the various rules for validating the sender or + # the reverse-path (like whether it should be null), and notifying the reverse + # path in case of delivery problems. All of that is left to the calling application. + # + def process_mail_from sender + if (@@parms[:starttls]==:required and !@state.include?(:starttls)) + send_data "550 This server requires STARTTLS before MAIL FROM\r\n" + elsif (@@parms[:auth]==:required and !@state.include?(:auth)) + send_data "550 This server requires authentication before MAIL FROM\r\n" + elsif @state.include?(:mail_from) + send_data "503 MAIL already given\r\n" + else + unless receive_sender sender + send_data "550 sender is unacceptable\r\n" + else + send_data "250 Ok\r\n" + @state << :mail_from + end + end + end + + #-- + # Since we require :mail_from to have been seen before we process RCPT TO, + # we don't need to repeat the tests for TLS and AUTH. + # Note that we don't remember or do anything else with the recipients. + # All of that is on the user code. + # TODO: we should enforce user-definable limits on the total number of + # recipients per transaction. + # We might want to make sure that a given recipient is only seen once, but + # for now we'll let that be the user's problem. + # + # User-written code can return a deferrable from receive_recipient. + # + def process_rcpt_to rcpt + unless @state.include?(:mail_from) + send_data "503 MAIL is required before RCPT\r\n" + else + succeeded = proc { + send_data "250 Ok\r\n" + @state << :rcpt unless @state.include?(:rcpt) + } + failed = proc { + send_data "550 recipient is unacceptable\r\n" + } + + d = receive_recipient rcpt + + if d.respond_to?(:set_deferred_status) + d.callback(&succeeded) + d.errback(&failed) + else + (d ? succeeded : failed).call + end + +=begin + unless receive_recipient rcpt + send_data "550 recipient is unacceptable\r\n" + else + send_data "250 Ok\r\n" + @state << :rcpt unless @state.include?(:rcpt) + end +=end + end + end + + + # Send the incoming data to the application one chunk at a time, rather than + # one line at a time. That lets the application be a little more flexible about + # storing to disk, etc. + # Since we clear the chunk array every time we submit it, the caller needs to be + # aware to do things like dup it if he wants to keep it around across calls. + # + # Resets the transaction upon disposition of the incoming message. + # RFC5321 says this about the MAIL FROM command: + # "This command tells the SMTP-receiver that a new mail transaction is + # starting and to reset all its state tables and buffers, including any + # recipients or mail data." + # + # Equivalent behaviour is implemented by resetting after a completed transaction. + # + # User-written code can return a Deferrable as a response from receive_message. + # + def process_data_line ln + if ln == "." + if @databuffer.length > 0 + receive_data_chunk @databuffer + @databuffer.clear + end + + + succeeded = proc { + send_data "250 Message accepted\r\n" + reset_protocol_state + } + failed = proc { + send_data "550 Message rejected\r\n" + reset_protocol_state + } + d = receive_message + + if d.respond_to?(:set_deferred_status) + d.callback(&succeeded) + d.errback(&failed) + else + (d ? succeeded : failed).call + end + + @state.delete :data + else + # slice off leading . if any + ln.slice!(0...1) if ln[0] == ?. + @databuffer << ln + if @databuffer.length > @@parms[:chunksize] + receive_data_chunk @databuffer + @databuffer.clear + end + end + end + + + #------------------------------------------ + # Everything from here on can be overridden in user code. + + # The greeting returned in the initial connection message to the client. + def get_server_greeting + "EventMachine SMTP Server" + end + # The domain name returned in the first line of the response to a + # successful EHLO or HELO command. + def get_server_domain + "Ok EventMachine SMTP Server" + end + + # A false response from this user-overridable method will cause a + # 550 error to be returned to the remote client. + # + def receive_ehlo_domain domain + true + end + + # Return true or false to indicate that the authentication is acceptable. + def receive_plain_auth user, password + true + end + + # Receives the argument of the MAIL FROM command. Return false to + # indicate to the remote client that the sender is not accepted. + # This can only be successfully called once per transaction. + # + def receive_sender sender + true + end + + # Receives the argument of a RCPT TO command. Can be given multiple + # times per transaction. Return false to reject the recipient. + # + def receive_recipient rcpt + true + end + + # Sent when the remote peer issues the RSET command. + # Since RSET is not allowed to fail (according to the protocol), + # we ignore any return value from user overrides of this method. + # + def receive_reset + end + + # Sent when the remote peer has ended the connection. + # + def connection_ended + end + + # Called when the remote peer sends the DATA command. + # Returning false will cause us to send a 550 error to the peer. + # This can be useful for dealing with problems that arise from processing + # the whole set of sender and recipients. + # + def receive_data_command + true + end + + # Sent when data from the remote peer is available. The size can be controlled + # by setting the :chunksize parameter. This call can be made multiple times. + # The goal is to strike a balance between sending the data to the application one + # line at a time, and holding all of a very large message in memory. + # + def receive_data_chunk data + @smtps_msg_size ||= 0 + @smtps_msg_size += data.join.length + STDERR.write "<#{@smtps_msg_size}>" + end + + # Sent after a message has been completely received. User code + # must return true or false to indicate whether the message has + # been accepted for delivery. + def receive_message + @@parms[:verbose] and $>.puts "Received complete message" + true + end + + # This is called when the protocol state is reset. It happens + # when the remote client calls EHLO/HELO or RSET. + def receive_transaction + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/socks4.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/socks4.rb new file mode 100644 index 0000000..132f320 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/socks4.rb @@ -0,0 +1,66 @@ +module EventMachine + module Protocols + # Basic SOCKS v4 client implementation + # + # Use as you would any regular connection: + # + # class MyConn < EM::P::Socks4 + # def post_init + # send_data("sup") + # end + # + # def receive_data(data) + # send_data("you said: #{data}") + # end + # end + # + # EM.connect socks_host, socks_port, MyConn, host, port + # + class Socks4 < Connection + def initialize(host, port) + @host = Socket.gethostbyname(host).last + @port = port + @socks_error_code = nil + @buffer = '' + setup_methods + end + + def setup_methods + class << self + def post_init; socks_post_init; end + def receive_data(*a); socks_receive_data(*a); end + end + end + + def restore_methods + class << self + remove_method :post_init + remove_method :receive_data + end + end + + def socks_post_init + header = [4, 1, @port, @host, 0].flatten.pack("CCnA4C") + send_data(header) + end + + def socks_receive_data(data) + @buffer << data + return if @buffer.size < 8 + + header_resp = @buffer.slice! 0, 8 + _, r = header_resp.unpack("cc") + if r != 90 + @socks_error_code = r + close_connection + return + end + + restore_methods + + post_init + receive_data(@buffer) unless @buffer.empty? + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/stomp.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/stomp.rb new file mode 100644 index 0000000..ca6f078 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/stomp.rb @@ -0,0 +1,205 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 15 November 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# +# + +module EventMachine + module Protocols + + # Implements Stomp (http://docs.codehaus.org/display/STOMP/Protocol). + # + # == Usage example + # + # module StompClient + # include EM::Protocols::Stomp + # + # def connection_completed + # connect :login => 'guest', :passcode => 'guest' + # end + # + # def receive_msg msg + # if msg.command == "CONNECTED" + # subscribe '/some/topic' + # else + # p ['got a message', msg] + # puts msg.body + # end + # end + # end + # + # EM.run{ + # EM.connect 'localhost', 61613, StompClient + # } + # + module Stomp + include LineText2 + + class Message + # The command associated with the message, usually 'CONNECTED' or 'MESSAGE' + attr_accessor :command + # Hash containing headers such as destination and message-id + attr_accessor :header + alias :headers :header + # Body of the message + attr_accessor :body + + # @private + def initialize + @header = {} + @state = :precommand + @content_length = nil + end + # @private + def consume_line line + if @state == :precommand + unless line =~ /\A\s*\Z/ + @command = line + @state = :headers + end + elsif @state == :headers + if line == "" + if @content_length + yield( [:sized_text, @content_length+1] ) + else + @state = :body + yield( [:unsized_text] ) + end + elsif line =~ /\A([^:]+):(.+)\Z/ + k = $1.dup.strip + v = $2.dup.strip + @header[k] = v + if k == "content-length" + @content_length = v.to_i + end + else + # This is a protocol error. How to signal it? + end + elsif @state == :body + @body = line + yield( [:dispatch] ) + end + end + end + + # @private + def send_frame verb, headers={}, body="" + body = body.to_s + ary = [verb, "\n"] + body_bytesize = body.bytesize if body.respond_to? :bytesize + body_bytesize ||= body.size + headers.each {|k,v| ary << "#{k}:#{v}\n" } + ary << "content-length: #{body_bytesize}\n" + ary << "content-type: text/plain; charset=UTF-8\n" unless headers.has_key? 'content-type' + ary << "\n" + ary << body + ary << "\0" + send_data ary.join + end + + # @private + def receive_line line + @stomp_initialized || init_message_reader + @stomp_message.consume_line(line) {|outcome| + if outcome.first == :sized_text + set_text_mode outcome[1] + elsif outcome.first == :unsized_text + set_delimiter "\0" + elsif outcome.first == :dispatch + receive_msg(@stomp_message) if respond_to?(:receive_msg) + init_message_reader + end + } + end + + # @private + def receive_binary_data data + @stomp_message.body = data[0..-2] + receive_msg(@stomp_message) if respond_to?(:receive_msg) + init_message_reader + end + + # @private + def init_message_reader + @stomp_initialized = true + set_delimiter "\n" + set_line_mode + @stomp_message = Message.new + end + + # Invoked with an incoming Stomp::Message received from the STOMP server + def receive_msg msg + # stub, overwrite this in your handler + end + + # CONNECT command, for authentication + # + # connect :login => 'guest', :passcode => 'guest' + # + def connect parms={} + send_frame "CONNECT", parms + end + + # SEND command, for publishing messages to a topic + # + # send '/topic/name', 'some message here' + # + def send destination, body, parms={} + send_frame "SEND", parms.merge( :destination=>destination ), body.to_s + end + + # SUBSCRIBE command, for subscribing to topics + # + # subscribe '/topic/name', false + # + def subscribe dest, ack=false + send_frame "SUBSCRIBE", {:destination=>dest, :ack=>(ack ? "client" : "auto")} + end + + # ACK command, for acknowledging receipt of messages + # + # module StompClient + # include EM::P::Stomp + # + # def connection_completed + # connect :login => 'guest', :passcode => 'guest' + # # subscribe with ack mode + # subscribe '/some/topic', true + # end + # + # def receive_msg msg + # if msg.command == "MESSAGE" + # ack msg.headers['message-id'] + # puts msg.body + # end + # end + # end + # + def ack msgid + send_frame "ACK", 'message-id'=> msgid + end + + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/tcptest.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/tcptest.rb new file mode 100644 index 0000000..3187893 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/protocols/tcptest.rb @@ -0,0 +1,54 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 16 July 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# +# + +module EventMachine + module Protocols + + # @private + class TcpConnectTester < Connection + include EventMachine::Deferrable + + def self.test( host, port ) + EventMachine.connect( host, port, self ) + end + + def post_init + @start_time = Time.now + end + + def connection_completed + @completed = true + set_deferred_status :succeeded, (Time.now - @start_time) + close_connection + end + + def unbind + set_deferred_status :failed, (Time.now - @start_time) unless @completed + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb new file mode 100644 index 0000000..94fd175 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb @@ -0,0 +1,1284 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 8 Apr 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#------------------------------------------------------------------- +# +# + +# TODO List: +# TCP-connects currently assume non-blocking connect is available- need to +# degrade automatically on versions of Ruby prior to June 2006. +# + +require 'singleton' +require 'forwardable' +require 'socket' +require 'fcntl' +require 'set' +require 'openssl' + +module EventMachine + # @private + class Error < Exception; end + # @private + class UnknownTimerFired < RuntimeError; end + # @private + class Unsupported < RuntimeError; end + # @private + class ConnectionError < RuntimeError; end + # @private + class ConnectionNotBound < RuntimeError; end + + # Older versions of Ruby may not provide the SSLErrorWaitReadable + # OpenSSL class. Create an error class to act as a "proxy". + if defined?(OpenSSL::SSL::SSLErrorWaitReadable) + SSLConnectionWaitReadable = OpenSSL::SSL::SSLErrorWaitReadable + else + SSLConnectionWaitReadable = IO::WaitReadable + end + + # Older versions of Ruby may not provide the SSLErrorWaitWritable + # OpenSSL class. Create an error class to act as a "proxy". + if defined?(OpenSSL::SSL::SSLErrorWaitWritable) + SSLConnectionWaitWritable = OpenSSL::SSL::SSLErrorWaitWritable + else + SSLConnectionWaitWritable = IO::WaitWritable + end +end + +module EventMachine + class CertificateCreator + attr_reader :cert, :key + + def initialize + @key = OpenSSL::PKey::RSA.new(1024) + public_key = @key.public_key + subject = "/C=EventMachine/O=EventMachine/OU=EventMachine/CN=EventMachine" + @cert = OpenSSL::X509::Certificate.new + @cert.subject = @cert.issuer = OpenSSL::X509::Name.parse(subject) + @cert.not_before = Time.now + @cert.not_after = Time.now + 365 * 24 * 60 * 60 + @cert.public_key = public_key + @cert.serial = 0x0 + @cert.version = 2 + factory = OpenSSL::X509::ExtensionFactory.new + factory.subject_certificate = @cert + factory.issuer_certificate = @cert + @cert.extensions = [ + factory.create_extension("basicConstraints","CA:TRUE", true), + factory.create_extension("subjectKeyIdentifier", "hash") + ] + @cert.add_extension factory.create_extension("authorityKeyIdentifier", "keyid:always,issuer:always") + @cert.sign(@key, OpenSSL::Digest::SHA1.new) + end + end + + # @private + DefaultCertificate = CertificateCreator.new + + # @private + DefaultDHKey1024 = OpenSSL::PKey::DH.new <<-_end_of_pem_ +-----BEGIN DH PARAMETERS----- +MIGHAoGBAJ0lOVy0VIr/JebWn0zDwY2h+rqITFOpdNr6ugsgvkDXuucdcChhYExJ +AV/ZD2AWPbrTqV76mGRgJg4EddgT1zG0jq3rnFdMj2XzkBYx3BVvfR0Arnby0RHR +T4h7KZ/2zmjvV+eF8kBUHBJAojUlzxKj4QeO2x20FP9X5xmNUXeDAgEC +-----END DH PARAMETERS----- + _end_of_pem_ + + # @private + DefaultDHKey2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_ +-----BEGIN DH PARAMETERS----- +MIIBCAKCAQEA7E6kBrYiyvmKAMzQ7i8WvwVk9Y/+f8S7sCTN712KkK3cqd1jhJDY +JbrYeNV3kUIKhPxWHhObHKpD1R84UpL+s2b55+iMd6GmL7OYmNIT/FccKhTcveab +VBmZT86BZKYyf45hUF9FOuUM9xPzuK3Vd8oJQvfYMCd7LPC0taAEljQLR4Edf8E6 +YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3 +1bNveX5wInh5GDx1FGhKBZ+s1H+aedudCm7sCgRwv8lKWYGiHzObSma8A86KG+MD +7Lo5JquQ3DlBodj3IDyPrxIv96lvRPFtAwIBAg== +-----END DH PARAMETERS----- + _end_of_pem_ +end + +# @private +module EventMachine + class << self + # This is mostly useful for automated tests. + # Return a distinctive symbol so the caller knows whether he's dealing + # with an extension or with a pure-Ruby library. + # @private + def library_type + :pure_ruby + end + + # @private + def initialize_event_machine + Reactor.instance.initialize_for_run + end + + # Changed 04Oct06: intervals from the caller are now in milliseconds, but our native-ruby + # processor still wants them in seconds. + # @private + def add_oneshot_timer interval + Reactor.instance.install_oneshot_timer(interval / 1000) + end + + # @private + def run_machine + Reactor.instance.run + end + + # @private + def release_machine + end + + + def stopping? + return Reactor.instance.stop_scheduled + end + + # @private + def stop + Reactor.instance.stop + end + + # @private + def connect_server host, port + bind_connect_server nil, nil, host, port + end + + # @private + def bind_connect_server bind_addr, bind_port, host, port + EvmaTCPClient.connect(bind_addr, bind_port, host, port).uuid + end + + # @private + def send_data target, data, datalength + selectable = Reactor.instance.get_selectable( target ) or raise "unknown send_data target" + selectable.send_data data + end + + # @private + def close_connection target, after_writing + selectable = Reactor.instance.get_selectable( target ) + selectable.schedule_close after_writing if selectable + end + + # @private + def start_tcp_server host, port + (s = EvmaTCPServer.start_server host, port) or raise "no acceptor" + s.uuid + end + + # @private + def stop_tcp_server sig + s = Reactor.instance.get_selectable(sig) + s.schedule_close + end + + # @private + def start_unix_server chain + (s = EvmaUNIXServer.start_server chain) or raise "no acceptor" + s.uuid + end + + # @private + def connect_unix_server chain + EvmaUNIXClient.connect(chain).uuid + end + + # @private + def signal_loopbreak + Reactor.instance.signal_loopbreak + end + + # @private + def get_peername sig + selectable = Reactor.instance.get_selectable( sig ) or raise "unknown get_peername target" + selectable.get_peername + end + + # @private + def get_sockname sig + selectable = Reactor.instance.get_selectable( sig ) or raise "unknown get_sockname target" + selectable.get_sockname + end + + # @private + def open_udp_socket host, port + EvmaUDPSocket.create(host, port).uuid + end + + # This is currently only for UDP! + # We need to make it work with unix-domain sockets as well. + # @private + def send_datagram target, data, datalength, host, port + selectable = Reactor.instance.get_selectable( target ) or raise "unknown send_data target" + selectable.send_datagram data, Socket::pack_sockaddr_in(port, host) + end + + + # Sets reactor quantum in milliseconds. The underlying Reactor function wants a (possibly + # fractional) number of seconds. + # @private + def set_timer_quantum interval + Reactor.instance.set_timer_quantum(( 1.0 * interval) / 1000.0) + end + + # This method is a harmless no-op in the pure-Ruby implementation. This is intended to ensure + # that user code behaves properly across different EM implementations. + # @private + def epoll + end + + # @private + def ssl? + true + end + + def tls_parm_set?(parm) + !(parm.nil? || parm.empty?) + end + + # This method takes a series of positional arguments for specifying such + # things as private keys and certificate chains. It's expected that the + # parameter list will grow as we add more supported features. ALL of these + # parameters are optional, and can be specified as empty or nil strings. + # @private + def set_tls_parms signature, priv_key, cert_chain, verify_peer, fail_if_no_peer_cert, sni_hostname, cipher_list, ecdh_curve, dhparam, protocols_bitmask + bitmask = protocols_bitmask + ssl_options = OpenSSL::SSL::OP_ALL + ssl_options |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2) && EM_PROTO_SSLv2 & bitmask == 0 + ssl_options |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3) && EM_PROTO_SSLv3 & bitmask == 0 + ssl_options |= OpenSSL::SSL::OP_NO_TLSv1 if defined?(OpenSSL::SSL::OP_NO_TLSv1) && EM_PROTO_TLSv1 & bitmask == 0 + ssl_options |= OpenSSL::SSL::OP_NO_TLSv1_1 if defined?(OpenSSL::SSL::OP_NO_TLSv1_1) && EM_PROTO_TLSv1_1 & bitmask == 0 + ssl_options |= OpenSSL::SSL::OP_NO_TLSv1_2 if defined?(OpenSSL::SSL::OP_NO_TLSv1_2) && EM_PROTO_TLSv1_2 & bitmask == 0 + @tls_parms ||= {} + @tls_parms[signature] = { + :verify_peer => verify_peer, + :fail_if_no_peer_cert => fail_if_no_peer_cert, + :ssl_options => ssl_options + } + @tls_parms[signature][:priv_key] = File.read(priv_key) if tls_parm_set?(priv_key) + @tls_parms[signature][:cert_chain] = File.read(cert_chain) if tls_parm_set?(cert_chain) + @tls_parms[signature][:sni_hostname] = sni_hostname if tls_parm_set?(sni_hostname) + @tls_parms[signature][:cipher_list] = cipher_list.gsub(/,\s*/, ':') if tls_parm_set?(cipher_list) + @tls_parms[signature][:dhparam] = File.read(dhparam) if tls_parm_set?(dhparam) + @tls_parms[signature][:ecdh_curve] = ecdh_curve if tls_parm_set?(ecdh_curve) + end + + def start_tls signature + selectable = Reactor.instance.get_selectable(signature) or raise "unknown io selectable for start_tls" + tls_parms = @tls_parms[signature] + ctx = OpenSSL::SSL::SSLContext.new + ctx.options = tls_parms[:ssl_options] + ctx.cert = DefaultCertificate.cert + ctx.key = DefaultCertificate.key + ctx.cert_store = OpenSSL::X509::Store.new + ctx.cert_store.set_default_paths + ctx.cert = OpenSSL::X509::Certificate.new(tls_parms[:cert_chain]) if tls_parms[:cert_chain] + ctx.key = OpenSSL::PKey::RSA.new(tls_parms[:priv_key]) if tls_parms[:priv_key] + verify_mode = OpenSSL::SSL::VERIFY_NONE + if tls_parms[:verify_peer] + verify_mode |= OpenSSL::SSL::VERIFY_PEER + end + if tls_parms[:fail_if_no_peer_cert] + verify_mode |= OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT + end + ctx.verify_mode = verify_mode + ctx.servername_cb = Proc.new do |_, server_name| + tls_parms[:server_name] = server_name + nil + end + ctx.ciphers = tls_parms[:cipher_list] if tls_parms[:cipher_list] + if selectable.is_server + ctx.tmp_dh_callback = Proc.new do |_, _, key_length| + if tls_parms[:dhparam] + OpenSSL::PKey::DH.new(tls_parms[:dhparam]) + else + case key_length + when 1024 then DefaultDHKey1024 + when 2048 then DefaultDHKey2048 + else + nil + end + end + end + if tls_parms[:ecdh_curve] && ctx.respond_to?(:tmp_ecdh_callback) + ctx.tmp_ecdh_callback = Proc.new do + OpenSSL::PKey::EC.new(tls_parms[:ecdh_curve]) + end + end + end + ssl_io = OpenSSL::SSL::SSLSocket.new(selectable, ctx) + ssl_io.sync_close = true + if tls_parms[:sni_hostname] + ssl_io.hostname = tls_parms[:sni_hostname] if ssl_io.respond_to?(:hostname=) + end + begin + selectable.is_server ? ssl_io.accept_nonblock : ssl_io.connect_nonblock + rescue; end + selectable.io = ssl_io + end + + def get_peer_cert signature + selectable = Reactor.instance.get_selectable(signature) or raise "unknown get_peer_cert target" + if selectable.io.respond_to?(:peer_cert) && selectable.io.peer_cert + selectable.io.peer_cert.to_pem + else + nil + end + end + + def get_cipher_name signature + selectable = Reactor.instance.get_selectable(signature) or raise "unknown get_cipher_name target" + selectable.io.respond_to?(:cipher) ? selectable.io.cipher[0] : nil + end + + def get_cipher_protocol signature + selectable = Reactor.instance.get_selectable(signature) or raise "unknown get_cipher_protocol target" + selectable.io.respond_to?(:cipher) ? selectable.io.cipher[1] : nil + end + + def get_cipher_bits signature + selectable = Reactor.instance.get_selectable(signature) or raise "unknown get_cipher_bits target" + selectable.io.respond_to?(:cipher) ? selectable.io.cipher[2] : nil + end + + def get_sni_hostname signature + @tls_parms ||= {} + if @tls_parms[signature] + @tls_parms[signature][:server_name] + else + nil + end + end + + # This method is a no-op in the pure-Ruby implementation. We simply return Ruby's built-in + # per-process file-descriptor limit. + # @private + def set_rlimit_nofile n + 1024 + end + + # This method is a harmless no-op in pure Ruby, which doesn't have a built-in limit + # on the number of available timers. + # @private + def set_max_timer_count n + end + + # @private + def get_sock_opt signature, level, optname + selectable = Reactor.instance.get_selectable( signature ) or raise "unknown get_sock_opt target" + selectable.getsockopt level, optname + end + + # @private + def set_sock_opt signature, level, optname, optval + selectable = Reactor.instance.get_selectable( signature ) or raise "unknown set_sock_opt target" + selectable.setsockopt level, optname, optval + end + + # @private + def send_file_data sig, filename + sz = File.size(filename) + raise "file too large" if sz > 32*1024 + data = + begin + File.read filename + rescue + "" + end + send_data sig, data, data.length + end + + # @private + def get_outbound_data_size sig + r = Reactor.instance.get_selectable( sig ) or raise "unknown get_outbound_data_size target" + r.get_outbound_data_size + end + + # @private + def read_keyboard + EvmaKeyboard.open.uuid + end + + # @private + def set_comm_inactivity_timeout sig, tm + r = Reactor.instance.get_selectable( sig ) or raise "unknown set_comm_inactivity_timeout target" + r.set_inactivity_timeout tm + end + + # @private + def set_pending_connect_timeout sig, tm + # Needs to be implemented. Currently a no-op stub to allow + # certain software to operate with the EM pure-ruby. + end + + # @private + def report_connection_error_status signature + get_sock_opt(signature, Socket::SOL_SOCKET, Socket::SO_ERROR).int + end + end +end + +module EventMachine + # @private + class Connection + # @private + def get_outbound_data_size + EventMachine::get_outbound_data_size @signature + end + end +end + +module EventMachine + + # Factored out so we can substitute other implementations + # here if desired, such as the one in ActiveRBAC. + # @private + module UuidGenerator + def self.generate + @ix ||= 0 + @ix += 1 + end + end +end + + +module EventMachine + # @private + TimerFired = 100 + # @private + ConnectionData = 101 + # @private + ConnectionUnbound = 102 + # @private + ConnectionAccepted = 103 + # @private + ConnectionCompleted = 104 + # @private + LoopbreakSignalled = 105 + # @private + ConnectionNotifyReadable = 106 + # @private + ConnectionNotifyWritable = 107 + # @private + SslHandshakeCompleted = 108 + # @private + SslVerify = 109 + # @private + EM_PROTO_SSLv2 = 2 + # @private + EM_PROTO_SSLv3 = 4 + # @private + EM_PROTO_TLSv1 = 8 + # @private + EM_PROTO_TLSv1_1 = 16 + # @private + EM_PROTO_TLSv1_2 = 32 +end + +module EventMachine + # @private + class Reactor + include Singleton + + HeartbeatInterval = 2 + + attr_reader :current_loop_time, :stop_scheduled + + def initialize + initialize_for_run + end + + def install_oneshot_timer interval + uuid = UuidGenerator::generate + #@timers << [Time.now + interval, uuid] + #@timers.sort! {|a,b| a.first <=> b.first} + @timers.add([Time.now + interval, uuid]) + uuid + end + + # Called before run, this is a good place to clear out arrays + # with cruft that may be left over from a previous run. + # @private + def initialize_for_run + @running = false + @stop_scheduled = false + @selectables ||= {}; @selectables.clear + @timers = SortedSet.new # [] + set_timer_quantum(0.1) + @current_loop_time = Time.now + @next_heartbeat = @current_loop_time + HeartbeatInterval + end + + def add_selectable io + @selectables[io.uuid] = io + end + + def get_selectable uuid + @selectables[uuid] + end + + def run + raise Error.new( "already running" ) if @running + @running = true + + begin + open_loopbreaker + + loop { + @current_loop_time = Time.now + + break if @stop_scheduled + run_timers + break if @stop_scheduled + crank_selectables + break if @stop_scheduled + run_heartbeats + } + ensure + close_loopbreaker + @selectables.each {|k, io| io.close} + @selectables.clear + + @running = false + end + + end + + def run_timers + @timers.each {|t| + if t.first <= @current_loop_time + @timers.delete t + EventMachine::event_callback "", TimerFired, t.last + else + break + end + } + #while @timers.length > 0 and @timers.first.first <= now + # t = @timers.shift + # EventMachine::event_callback "", TimerFired, t.last + #end + end + + def run_heartbeats + if @next_heartbeat <= @current_loop_time + @next_heartbeat = @current_loop_time + HeartbeatInterval + @selectables.each {|k,io| io.heartbeat} + end + end + + def crank_selectables + #$stderr.write 'R' + + readers = @selectables.values.select {|io| io.select_for_reading?} + writers = @selectables.values.select {|io| io.select_for_writing?} + + s = select( readers, writers, nil, @timer_quantum) + + s and s[1] and s[1].each {|w| w.eventable_write } + s and s[0] and s[0].each {|r| r.eventable_read } + + @selectables.delete_if {|k,io| + if io.close_scheduled? + io.close + begin + EventMachine::event_callback io.uuid, ConnectionUnbound, nil + rescue ConnectionNotBound; end + true + end + } + end + + # #stop + def stop + raise Error.new( "not running") unless @running + @stop_scheduled = true + end + + def open_loopbreaker + # Can't use an IO.pipe because they can't be set nonselectable in Windows. + # Pick a random localhost UDP port. + #@loopbreak_writer.close if @loopbreak_writer + #rd,@loopbreak_writer = IO.pipe + @loopbreak_reader = UDPSocket.new + @loopbreak_writer = UDPSocket.new + bound = false + 100.times { + @loopbreak_port = rand(10000) + 40000 + begin + @loopbreak_reader.bind "127.0.0.1", @loopbreak_port + bound = true + break + rescue + end + } + raise "Unable to bind Loopbreaker" unless bound + LoopbreakReader.new(@loopbreak_reader) + end + + def close_loopbreaker + @loopbreak_writer.close + @loopbreak_writer = nil + end + + def signal_loopbreak + begin + @loopbreak_writer.send('+',0,"127.0.0.1",@loopbreak_port) if @loopbreak_writer + rescue IOError; end + end + + def set_timer_quantum interval_in_seconds + @timer_quantum = interval_in_seconds + end + + end + +end + +# @private +class IO + extend Forwardable + def_delegator :@my_selectable, :close_scheduled? + def_delegator :@my_selectable, :select_for_reading? + def_delegator :@my_selectable, :select_for_writing? + def_delegator :@my_selectable, :eventable_read + def_delegator :@my_selectable, :eventable_write + def_delegator :@my_selectable, :uuid + def_delegator :@my_selectable, :is_server + def_delegator :@my_selectable, :is_server= + def_delegator :@my_selectable, :send_data + def_delegator :@my_selectable, :schedule_close + def_delegator :@my_selectable, :get_peername + def_delegator :@my_selectable, :get_sockname + def_delegator :@my_selectable, :send_datagram + def_delegator :@my_selectable, :get_outbound_data_size + def_delegator :@my_selectable, :set_inactivity_timeout + def_delegator :@my_selectable, :heartbeat + def_delegator :@my_selectable, :io + def_delegator :@my_selectable, :io= +end + +module EventMachine + # @private + class Selectable + + attr_accessor :io, :is_server + attr_reader :uuid + + def initialize io + @io = io + @uuid = UuidGenerator.generate + @is_server = false + @last_activity = Reactor.instance.current_loop_time + + if defined?(Fcntl::F_GETFL) + m = @io.fcntl(Fcntl::F_GETFL, 0) + @io.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK | m) + else + # Windows doesn't define F_GETFL. + # It's not very reliable about setting descriptors nonblocking either. + begin + s = Socket.for_fd(@io.fileno) + s.fcntl( Fcntl::F_SETFL, Fcntl::O_NONBLOCK ) + rescue Errno::EINVAL, Errno::EBADF + warn "Serious error: unable to set descriptor non-blocking" + end + end + # TODO, should set CLOEXEC on Unix? + + @close_scheduled = false + @close_requested = false + + se = self; @io.instance_eval { @my_selectable = se } + Reactor.instance.add_selectable @io + end + + def close_scheduled? + @close_scheduled + end + + def select_for_reading? + false + end + + def select_for_writing? + false + end + + def get_peername + nil + end + + def get_sockname + nil + end + + def set_inactivity_timeout tm + @inactivity_timeout = tm + end + + def heartbeat + end + + def schedule_close(after_writing=false) + if after_writing + @close_requested = true + else + @close_scheduled = true + end + end + end + +end + +module EventMachine + # @private + class StreamObject < Selectable + def initialize io + super io + @outbound_q = [] + end + + # If we have to close, or a close-after-writing has been requested, + # then don't read any more data. + def select_for_reading? + true unless (@close_scheduled || @close_requested) + end + + # If we have to close, don't select for writing. + # Otherwise, see if the protocol is ready to close. + # If not, see if he has data to send. + # If a close-after-writing has been requested and the outbound queue + # is empty, convert the status to close_scheduled. + def select_for_writing? + unless @close_scheduled + if @outbound_q.empty? + @close_scheduled = true if @close_requested + false + else + true + end + end + end + + # Proper nonblocking I/O was added to Ruby 1.8.4 in May 2006. + # If we have it, then we can read multiple times safely to improve + # performance. + # The last-activity clock ASSUMES that we only come here when we + # have selected readable. + # TODO, coalesce multiple reads into a single event. + # TODO, do the function check somewhere else and cache it. + def eventable_read + @last_activity = Reactor.instance.current_loop_time + begin + if io.respond_to?(:read_nonblock) + 10.times { + data = io.read_nonblock(4096) + EventMachine::event_callback uuid, ConnectionData, data + } + else + data = io.sysread(4096) + EventMachine::event_callback uuid, ConnectionData, data + end + rescue Errno::EAGAIN, Errno::EWOULDBLOCK, SSLConnectionWaitReadable + # no-op + rescue Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Errno::EPIPE, OpenSSL::SSL::SSLError + @close_scheduled = true + EventMachine::event_callback uuid, ConnectionUnbound, nil + end + + end + + # Provisional implementation. Will be re-implemented in subclasses. + # TODO: Complete this implementation. As it stands, this only writes + # a single packet per cycle. Highly inefficient, but required unless + # we're running on a Ruby with proper nonblocking I/O (Ruby 1.8.4 + # built from sources from May 25, 2006 or newer). + # We need to improve the loop so it writes multiple times, however + # not more than a certain number of bytes per cycle, otherwise + # one busy connection could hog output buffers and slow down other + # connections. Also we should coalesce small writes. + # URGENT TODO: Coalesce small writes. They are a performance killer. + # The last-activity recorder ASSUMES we'll only come here if we've + # selected writable. + def eventable_write + # coalesce the outbound array here, perhaps + @last_activity = Reactor.instance.current_loop_time + while data = @outbound_q.shift do + begin + data = data.to_s + w = if io.respond_to?(:write_nonblock) + io.write_nonblock data + else + io.syswrite data + end + + if w < data.length + @outbound_q.unshift data[w..-1] + break + end + rescue Errno::EAGAIN, SSLConnectionWaitReadable, SSLConnectionWaitWritable + @outbound_q.unshift data + break + rescue EOFError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EPIPE, OpenSSL::SSL::SSLError + @close_scheduled = true + @outbound_q.clear + end + end + + end + + # #send_data + def send_data data + # TODO, coalesce here perhaps by being smarter about appending to @outbound_q.last? + unless @close_scheduled or @close_requested or !data or data.length <= 0 + @outbound_q << data.to_s + end + end + + # #get_peername + # This is defined in the normal way on connected stream objects. + # Return an object that is suitable for passing to Socket#unpack_sockaddr_in or variants. + # We could also use a convenience method that did the unpacking automatically. + def get_peername + io.getpeername + end + + # #get_sockname + # This is defined in the normal way on connected stream objects. + # Return an object that is suitable for passing to Socket#unpack_sockaddr_in or variants. + # We could also use a convenience method that did the unpacking automatically. + def get_sockname + io.getsockname + end + + # #get_outbound_data_size + def get_outbound_data_size + @outbound_q.inject(0) {|memo,obj| memo += (obj || "").length} + end + + def heartbeat + if @inactivity_timeout and @inactivity_timeout > 0 and (@last_activity + @inactivity_timeout) < Reactor.instance.current_loop_time + schedule_close true + end + end + end + + +end + + +#-------------------------------------------------------------- + + + +module EventMachine + # @private + class EvmaTCPClient < StreamObject + + def self.connect bind_addr, bind_port, host, port + sd = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 ) + sd.bind( Socket.pack_sockaddr_in( bind_port, bind_addr )) if bind_addr + + begin + # TODO, this assumes a current Ruby snapshot. + # We need to degrade to a nonblocking connect otherwise. + sd.connect_nonblock( Socket.pack_sockaddr_in( port, host )) + rescue Errno::ECONNREFUSED, Errno::EINPROGRESS + end + EvmaTCPClient.new sd + end + + def initialize io + super + @pending = true + @handshake_complete = false + end + + def ready? + if RUBY_PLATFORM =~ /linux/ + io.getsockopt(Socket::SOL_TCP, Socket::TCP_INFO).unpack("i").first == 1 # TCP_ESTABLISHED + else + io.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR).unpack("i").first == 0 # NO ERROR + end + end + + def handshake_complete? + if !@handshake_complete && io.respond_to?(:state) + if io.state =~ /^SSLOK/ + @handshake_complete = true + EventMachine::event_callback uuid, SslHandshakeCompleted, "" + EventMachine::event_callback uuid, SslVerify, io.peer_cert.to_pem if io.peer_cert + end + else + @handshake_complete = true + end + @handshake_complete + end + + def pending? + handshake_complete? + if @pending + if ready? + @pending = false + EventMachine::event_callback uuid, ConnectionCompleted, "" + end + end + @pending + end + + def select_for_writing? + pending? + super + end + + def select_for_reading? + pending? + super + end + end +end + + + +module EventMachine + # @private + class EvmaKeyboard < StreamObject + + def self.open + EvmaKeyboard.new STDIN + end + + + def initialize io + super + end + + + def select_for_writing? + false + end + + def select_for_reading? + true + end + + + end +end + + + +module EventMachine + # @private + class EvmaUNIXClient < StreamObject + + def self.connect chain + sd = Socket.new( Socket::AF_LOCAL, Socket::SOCK_STREAM, 0 ) + begin + # TODO, this assumes a current Ruby snapshot. + # We need to degrade to a nonblocking connect otherwise. + sd.connect_nonblock( Socket.pack_sockaddr_un( chain )) + rescue Errno::EINPROGRESS + end + EvmaUNIXClient.new sd + end + + + def initialize io + super + @pending = true + end + + + def select_for_writing? + @pending ? true : super + end + + def select_for_reading? + @pending ? false : super + end + + def eventable_write + if @pending + @pending = false + if 0 == io.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR).unpack("i").first + EventMachine::event_callback uuid, ConnectionCompleted, "" + end + else + super + end + end + + + + end +end + + +#-------------------------------------------------------------- + +module EventMachine + # @private + class EvmaTCPServer < Selectable + + # TODO, refactor and unify with EvmaUNIXServer. + + class << self + # Versions of ruby 1.8.4 later than May 26 2006 will work properly + # with an object of type TCPServer. Prior versions won't so we + # play it safe and just build a socket. + # + def start_server host, port + sd = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 ) + sd.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true ) + sd.bind( Socket.pack_sockaddr_in( port, host )) + sd.listen( 50 ) # 5 is what you see in all the books. Ain't enough. + EvmaTCPServer.new sd + end + end + + def initialize io + super io + end + + + def select_for_reading? + true + end + + #-- + # accept_nonblock returns an array consisting of the accepted + # socket and a sockaddr_in which names the peer. + # Don't accept more than 10 at a time. + def eventable_read + begin + 10.times { + descriptor,peername = io.accept_nonblock + sd = EvmaTCPClient.new descriptor + sd.is_server = true + EventMachine::event_callback uuid, ConnectionAccepted, sd.uuid + } + rescue Errno::EWOULDBLOCK, Errno::EAGAIN + end + end + + #-- + # + def schedule_close + @close_scheduled = true + end + + end +end + + +#-------------------------------------------------------------- + +module EventMachine + # @private + class EvmaUNIXServer < Selectable + + # TODO, refactor and unify with EvmaTCPServer. + + class << self + # Versions of ruby 1.8.4 later than May 26 2006 will work properly + # with an object of type TCPServer. Prior versions won't so we + # play it safe and just build a socket. + # + def start_server chain + sd = Socket.new( Socket::AF_LOCAL, Socket::SOCK_STREAM, 0 ) + sd.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true ) + sd.bind( Socket.pack_sockaddr_un( chain )) + sd.listen( 50 ) # 5 is what you see in all the books. Ain't enough. + EvmaUNIXServer.new sd + end + end + + def initialize io + super io + end + + + def select_for_reading? + true + end + + #-- + # accept_nonblock returns an array consisting of the accepted + # socket and a sockaddr_in which names the peer. + # Don't accept more than 10 at a time. + def eventable_read + begin + 10.times { + descriptor,peername = io.accept_nonblock + sd = StreamObject.new descriptor + EventMachine::event_callback uuid, ConnectionAccepted, sd.uuid + } + rescue Errno::EWOULDBLOCK, Errno::EAGAIN + end + end + + #-- + # + def schedule_close + @close_scheduled = true + end + + end +end + + + +#-------------------------------------------------------------- + +module EventMachine + # @private + class LoopbreakReader < Selectable + + def select_for_reading? + true + end + + def eventable_read + io.sysread(128) + EventMachine::event_callback "", LoopbreakSignalled, "" + end + + end +end + + + +# @private +module EventMachine + # @private + class DatagramObject < Selectable + def initialize io + super io + @outbound_q = [] + end + + # #send_datagram + def send_datagram data, target + # TODO, coalesce here perhaps by being smarter about appending to @outbound_q.last? + unless @close_scheduled or @close_requested + @outbound_q << [data.to_s, target] + end + end + + # #select_for_writing? + def select_for_writing? + unless @close_scheduled + if @outbound_q.empty? + @close_scheduled = true if @close_requested + false + else + true + end + end + end + + # #select_for_reading? + def select_for_reading? + true + end + + # #get_outbound_data_size + def get_outbound_data_size + @outbound_q.inject(0) {|memo,obj| memo += (obj || "").length} + end + + + end + + +end + + +module EventMachine + # @private + class EvmaUDPSocket < DatagramObject + + class << self + def create host, port + sd = Socket.new( Socket::AF_INET, Socket::SOCK_DGRAM, 0 ) + sd.bind Socket::pack_sockaddr_in( port, host ) + EvmaUDPSocket.new sd + end + end + + # #eventable_write + # This really belongs in DatagramObject, but there is some UDP-specific stuff. + def eventable_write + 40.times { + break if @outbound_q.empty? + begin + data,target = @outbound_q.first + + # This damn better be nonblocking. + io.send data.to_s, 0, target + + @outbound_q.shift + rescue Errno::EAGAIN + # It's not been observed in testing that we ever get here. + # True to the definition, packets will be accepted and quietly dropped + # if the system is under pressure. + break + rescue EOFError, Errno::ECONNRESET + @close_scheduled = true + @outbound_q.clear + end + } + end + + # Proper nonblocking I/O was added to Ruby 1.8.4 in May 2006. + # If we have it, then we can read multiple times safely to improve + # performance. + def eventable_read + begin + if io.respond_to?(:recvfrom_nonblock) + 40.times { + data,@return_address = io.recvfrom_nonblock(16384) + EventMachine::event_callback uuid, ConnectionData, data + @return_address = nil + } + else + raise "unimplemented datagram-read operation on this Ruby" + end + rescue Errno::EAGAIN + # no-op + rescue Errno::ECONNRESET, EOFError + @close_scheduled = true + EventMachine::event_callback uuid, ConnectionUnbound, nil + end + end + + def send_data data + send_datagram data, @return_address + end + end +end + +# load base EM api on top, now that we have the underlying pure ruby +# implementation defined +require 'eventmachine' diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/queue.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/queue.rb new file mode 100644 index 0000000..9096ed0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/queue.rb @@ -0,0 +1,80 @@ +module EventMachine + # A cross thread, reactor scheduled, linear queue. + # + # This class provides a simple queue abstraction on top of the reactor + # scheduler. It services two primary purposes: + # + # * API sugar for stateful protocols + # * Pushing processing onto the reactor thread + # + # @example + # + # q = EM::Queue.new + # q.push('one', 'two', 'three') + # 3.times do + # q.pop { |msg| puts(msg) } + # end + # + class Queue + def initialize + @sink = [] + @drain = [] + @popq = [] + end + + # Pop items off the queue, running the block on the reactor thread. The pop + # will not happen immediately, but at some point in the future, either in + # the next tick, if the queue has data, or when the queue is populated. + # + # @return [NilClass] nil + def pop(*a, &b) + cb = EM::Callback(*a, &b) + EM.schedule do + if @drain.empty? + @drain = @sink + @sink = [] + end + if @drain.empty? + @popq << cb + else + cb.call @drain.shift + end + end + nil # Always returns nil + end + + # Push items onto the queue in the reactor thread. The items will not appear + # in the queue immediately, but will be scheduled for addition during the + # next reactor tick. + def push(*items) + EM.schedule do + @sink.push(*items) + unless @popq.empty? + @drain = @sink + @sink = [] + @popq.shift.call @drain.shift until @drain.empty? || @popq.empty? + end + end + end + alias :<< :push + + # @return [Boolean] + # @note This is a peek, it's not thread safe, and may only tend toward accuracy. + def empty? + @drain.empty? && @sink.empty? + end + + # @return [Integer] Queue size + # @note This is a peek, it's not thread safe, and may only tend toward accuracy. + def size + @drain.size + @sink.size + end + + # @return [Integer] Waiting size + # @note This is a peek at the number of jobs that are currently waiting on the Queue + def num_waiting + @popq.size + end + + end # Queue +end # EventMachine diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/resolver.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/resolver.rb new file mode 100644 index 0000000..1d2d7aa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/resolver.rb @@ -0,0 +1,232 @@ +module EventMachine + module DNS + class Resolver + + def self.windows? + if RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/ + require 'win32/resolv' + true + else + false + end + end + + HOSTS_FILE = windows? ? Win32::Resolv.get_hosts_path : '/etc/hosts' + + @hosts = nil + @nameservers = nil + @socket = nil + + def self.resolve(hostname) + Request.new(socket, hostname) + end + + def self.socket + if @socket && @socket.error? + @socket = Socket.open + else + @socket ||= Socket.open + end + end + + def self.nameservers=(ns) + @nameservers = ns + end + + def self.nameservers + return @nameservers if @nameservers + + if windows? + _, ns = Win32::Resolv.get_resolv_info + return @nameservers = ns || [] + end + + @nameservers = [] + IO.readlines('/etc/resolv.conf').each do |line| + if line =~ /^nameserver (.+)$/ + @nameservers << $1.split(/\s+/).first + end + end + + @nameservers + rescue + @nameservers = [] + end + + def self.nameserver + nameservers.shuffle.first + end + + def self.hosts + return @hosts if @hosts + + @hosts = {} + IO.readlines(HOSTS_FILE).each do |line| + next if line =~ /^#/ + addr, host = line.split(/\s+/) + + next unless addr && host + @hosts[host] ||= [] + @hosts[host] << addr + end + + @hosts + rescue + @hosts = {} + end + end + + class RequestIdAlreadyUsed < RuntimeError; end + + class Socket < EventMachine::Connection + def self.open + EventMachine::open_datagram_socket('0.0.0.0', 0, self) + end + + def initialize + @nameserver = nil + end + + def post_init + @requests = {} + end + + def start_timer + @timer ||= EM.add_periodic_timer(0.1, &method(:tick)) + end + + def stop_timer + EM.cancel_timer(@timer) + @timer = nil + end + + def unbind + end + + def tick + @requests.each do |id,req| + req.tick + end + end + + def register_request(id, req) + if @requests.has_key?(id) + raise RequestIdAlreadyUsed + else + @requests[id] = req + end + + start_timer + end + + def deregister_request(id, req) + @requests.delete(id) + stop_timer if @requests.length == 0 + end + + def send_packet(pkt) + send_datagram(pkt, nameserver, 53) + end + + def nameserver=(ns) + @nameserver = ns + end + + def nameserver + @nameserver || Resolver.nameserver + end + + # Decodes the packet, looks for the request and passes the + # response over to the requester + def receive_data(data) + msg = nil + begin + msg = Resolv::DNS::Message.decode data + rescue + else + req = @requests[msg.id] + if req + @requests.delete(msg.id) + stop_timer if @requests.length == 0 + req.receive_answer(msg) + end + end + end + end + + class Request + include Deferrable + attr_accessor :retry_interval, :max_tries + + def initialize(socket, hostname) + @socket = socket + @hostname = hostname + @tries = 0 + @last_send = Time.at(0) + @retry_interval = 3 + @max_tries = 5 + + if addrs = Resolver.hosts[hostname] + succeed addrs + else + EM.next_tick { tick } + end + end + + def tick + # Break early if nothing to do + return if @last_send + @retry_interval > Time.now + if @tries < @max_tries + send + else + @socket.deregister_request(@id, self) + fail 'retries exceeded' + end + end + + def receive_answer(msg) + addrs = [] + msg.each_answer do |name,ttl,data| + if data.kind_of?(Resolv::DNS::Resource::IN::A) || + data.kind_of?(Resolv::DNS::Resource::IN::AAAA) + addrs << data.address.to_s + end + end + + if addrs.empty? + fail "rcode=#{msg.rcode}" + else + succeed addrs + end + end + + private + + def send + @tries += 1 + @last_send = Time.now + @socket.send_packet(packet.encode) + end + + def id + begin + @id = rand(65535) + @socket.register_request(@id, self) + rescue RequestIdAlreadyUsed + retry + end unless defined?(@id) + + @id + end + + def packet + msg = Resolv::DNS::Message.new + msg.id = id + msg.rd = 1 + msg.add_question @hostname, Resolv::DNS::Resource::IN::A + msg + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/spawnable.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/spawnable.rb new file mode 100644 index 0000000..35c087d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/spawnable.rb @@ -0,0 +1,84 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 25 Aug 2007 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +module EventMachine + # Support for Erlang-style processes. + # + class SpawnedProcess + # Send a message to the spawned process + def notify *x + me = self + EM.next_tick { + # A notification executes in the context of this + # SpawnedProcess object. That makes self and notify + # work as one would expect. + # + y = me.call(*x) + if y and y.respond_to?(:pull_out_yield_block) + a,b = y.pull_out_yield_block + set_receiver a + self.notify if b + end + } + end + alias_method :resume, :notify + alias_method :run, :notify # for formulations like (EM.spawn {xxx}).run + + def set_receiver blk + (class << self ; self ; end).class_eval do + remove_method :call if method_defined? :call + define_method :call, blk + end + end + + end + + # @private + class YieldBlockFromSpawnedProcess + def initialize block, notify + @block = [block,notify] + end + def pull_out_yield_block + @block + end + end + + # Spawn an erlang-style process + def self.spawn &block + s = SpawnedProcess.new + s.set_receiver block + s + end + + # @private + def self.yield &block + return YieldBlockFromSpawnedProcess.new( block, false ) + end + + # @private + def self.yield_and_notify &block + return YieldBlockFromSpawnedProcess.new( block, true ) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/streamer.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/streamer.rb new file mode 100644 index 0000000..cf49c88 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/streamer.rb @@ -0,0 +1,118 @@ +module EventMachine + # Streams a file over a given connection. Streaming begins once the object is + # instantiated. Typically FileStreamer instances are not reused. + # + # Streaming uses buffering for files larger than 16K and uses so-called fast file reader (a C++ extension) + # if available (it is part of eventmachine gem itself). + # + # @example + # + # module FileSender + # def post_init + # streamer = EventMachine::FileStreamer.new(self, '/tmp/bigfile.tar') + # streamer.callback{ + # # file was sent successfully + # close_connection_after_writing + # } + # end + # end + # + # + # @author Francis Cianfrocca + class FileStreamer + include Deferrable + + # Use mapped streamer for files bigger than 16k + MappingThreshold = 16384 + # Wait until next tick to send more data when 50k is still in the outgoing buffer + BackpressureLevel = 50000 + # Send 16k chunks at a time + ChunkSize = 16384 + + # @param [EventMachine::Connection] connection + # @param [String] filename File path + # + # @option args [Boolean] :http_chunks (false) Use HTTP 1.1 style chunked-encoding semantics. + def initialize connection, filename, args = {} + @connection = connection + @http_chunks = args[:http_chunks] + + if File.exist?(filename) + @size = File.size(filename) + if @size <= MappingThreshold + stream_without_mapping filename + else + stream_with_mapping filename + end + else + fail "file not found" + end + end + + # @private + def stream_without_mapping filename + if @http_chunks + @connection.send_data "#{@size.to_s(16)}\r\n" + @connection.send_file_data filename + @connection.send_data "\r\n0\r\n\r\n" + else + @connection.send_file_data filename + end + succeed + end + private :stream_without_mapping + + # @private + def stream_with_mapping filename + ensure_mapping_extension_is_present + + @position = 0 + @mapping = EventMachine::FastFileReader::Mapper.new filename + stream_one_chunk + end + private :stream_with_mapping + + # Used internally to stream one chunk at a time over multiple reactor ticks + # @private + def stream_one_chunk + loop { + if @position < @size + if @connection.get_outbound_data_size > BackpressureLevel + EventMachine::next_tick {stream_one_chunk} + break + else + len = @size - @position + len = ChunkSize if (len > ChunkSize) + + @connection.send_data( "#{len.to_s(16)}\r\n" ) if @http_chunks + @connection.send_data( @mapping.get_chunk( @position, len )) + @connection.send_data("\r\n") if @http_chunks + + @position += len + end + else + @connection.send_data "0\r\n\r\n" if @http_chunks + @mapping.close + succeed + break + end + } + end + + # + # We use an outboard extension class to get memory-mapped files. + # It's outboard to avoid polluting the core distro, but that means + # there's a "hidden" dependency on it. The first time we get here in + # any run, try to load up the dependency extension. User code will see + # a LoadError if it's not available, but code that doesn't require + # mapped files will work fine without it. This is a somewhat difficult + # compromise between usability and proper modularization. + # + # @private + def ensure_mapping_extension_is_present + @@fastfilereader ||= (require 'fastfilereaderext') + end + private :ensure_mapping_extension_is_present + + end # FileStreamer +end # EventMachine diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/threaded_resource.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/threaded_resource.rb new file mode 100644 index 0000000..87704d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/threaded_resource.rb @@ -0,0 +1,90 @@ +module EventMachine + # = EventMachine::ThreadedResource + # + # A threaded resource is a "quick and dirty" wrapper around the concept of + # wiring up synchronous code into a standard EM::Pool. This is useful to keep + # interfaces coherent and provide a simple approach at "making an interface + # async-ish". + # + # General usage is to wrap libraries that do not support EventMachine, or to + # have a specific number of dedicated high-cpu worker resources. + # + # == Basic Usage example + # + # This example requires the cassandra gem. The cassandra gem contains an + # EventMachine interface, but it's sadly Fiber based and thus only works on + # 1.9. It also requires (potentially) complex stack switching logic to reach + # completion of nested operations. By contrast this approach provides a block + # in which normal synchronous code can occur, but makes no attempt to wire the + # IO into EventMachines C++ IO implementations, instead relying on the reactor + # pattern in rb_thread_select. + # + # cassandra_dispatcher = ThreadedResource.new do + # Cassandra.new('allthethings', '127.0.0.1:9160') + # end + # + # pool = EM::Pool.new + # + # pool.add cassandra_dispatcher + # + # # If we don't care about the result: + # pool.perform do |dispatcher| + # # The following block executes inside a dedicated thread, and should not + # # access EventMachine things: + # dispatcher.dispatch do |cassandra| + # cassandra.insert(:Things, '10', 'stuff' => 'things') + # end + # end + # + # # Example where we care about the result: + # pool.perform do |dispatcher| + # # The dispatch block is executed in the resources thread. + # completion = dispatcher.dispatch do |cassandra| + # cassandra.get(:Things, '10', 'stuff') + # end + # + # # This block will be yielded on the EM thread: + # completion.callback do |result| + # EM.do_something_with(result) + # end + # + # completion + # end + class ThreadedResource + + # The block should return the resource that will be yielded in a dispatch. + def initialize + @resource = yield + + @running = true + @queue = ::Queue.new + @thread = Thread.new do + @queue.pop.call while @running + end + end + + # Called on the EM thread, generally in a perform block to return a + # completion for the work. + def dispatch + completion = EM::Completion.new + @queue << lambda do + begin + result = yield @resource + completion.succeed result + rescue => e + completion.fail e + end + end + completion + end + + # Kill the internal thread. should only be used to cleanup - generally + # only required for tests. + def shutdown + @running = false + @queue << lambda {} + @thread.join + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/tick_loop.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/tick_loop.rb new file mode 100644 index 0000000..a95d516 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/tick_loop.rb @@ -0,0 +1,85 @@ +module EventMachine + # Creates and immediately starts an EventMachine::TickLoop + def self.tick_loop(*a, &b) + TickLoop.new(*a, &b).start + end + + # A TickLoop is useful when one needs to distribute amounts of work + # throughout ticks in order to maintain response times. It is also useful for + # simple repeated checks and metrics. + # @example + # # Here we run through an array one item per tick until it is empty, + # # printing each element. + # # When the array is empty, we return :stop from the callback, and the + # # loop will terminate. + # # When the loop terminates, the on_stop callbacks will be called. + # EM.run do + # array = (1..100).to_a + # + # tickloop = EM.tick_loop do + # if array.empty? + # :stop + # else + # puts array.shift + # end + # end + # + # tickloop.on_stop { EM.stop } + # end + # + class TickLoop + + # Arguments: A callback (EM::Callback) to call each tick. If the call + # returns +:stop+ then the loop will be stopped. Any other value is + # ignored. + def initialize(*a, &b) + @work = EM::Callback(*a, &b) + @stops = [] + @stopped = true + end + + # Arguments: A callback (EM::Callback) to call once on the next stop (or + # immediately if already stopped). + def on_stop(*a, &b) + if @stopped + EM::Callback(*a, &b).call + else + @stops << EM::Callback(*a, &b) + end + end + + # Stop the tick loop immediately, and call it's on_stop callbacks. + def stop + @stopped = true + until @stops.empty? + @stops.shift.call + end + end + + # Query if the loop is stopped. + def stopped? + @stopped + end + + # Start the tick loop, will raise argument error if the loop is already + # running. + def start + raise ArgumentError, "double start" unless @stopped + @stopped = false + schedule + end + + private + def schedule + EM.next_tick do + next if @stopped + if @work.call == :stop + stop + else + schedule + end + end + self + end + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/timers.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/timers.rb new file mode 100644 index 0000000..41cd959 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/timers.rb @@ -0,0 +1,61 @@ +module EventMachine + # Creates a one-time timer + # + # timer = EventMachine::Timer.new(5) do + # # this will never fire because we cancel it + # end + # timer.cancel + # + class Timer + # Create a new timer that fires after a given number of seconds + def initialize interval, callback=nil, &block + @signature = EventMachine::add_timer(interval, callback || block) + end + + # Cancel the timer + def cancel + EventMachine.send :cancel_timer, @signature + end + end + + # Creates a periodic timer + # + # @example + # n = 0 + # timer = EventMachine::PeriodicTimer.new(5) do + # puts "the time is #{Time.now}" + # timer.cancel if (n+=1) > 5 + # end + # + class PeriodicTimer + # Create a new periodic timer that executes every interval seconds + def initialize interval, callback=nil, &block + @interval = interval + @code = callback || block + @cancelled = false + @work = method(:fire) + schedule + end + + # Cancel the periodic timer + def cancel + @cancelled = true + end + + # Fire the timer every interval seconds + attr_accessor :interval + + # @private + def schedule + EventMachine::add_timer @interval, @work + end + + # @private + def fire + unless @cancelled + @code.call + schedule + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/version.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/version.rb new file mode 100644 index 0000000..ffc4310 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/em/version.rb @@ -0,0 +1,3 @@ +module EventMachine + VERSION = "1.2.7" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/eventmachine.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/eventmachine.rb new file mode 100644 index 0000000..0873747 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/eventmachine.rb @@ -0,0 +1,1601 @@ +if defined?(EventMachine.library_type) and EventMachine.library_type == :pure_ruby + # assume 'em/pure_ruby' was loaded already +elsif RUBY_PLATFORM =~ /java/ + require 'java' + require 'jeventmachine' +else + begin + require 'rubyeventmachine' + rescue LoadError + warn "Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'" + raise + end +end + +require 'em/version' +require 'em/pool' +require 'em/deferrable' +require 'em/future' +require 'em/streamer' +require 'em/spawnable' +require 'em/processes' +require 'em/iterator' +require 'em/buftok' +require 'em/timers' +require 'em/protocols' +require 'em/connection' +require 'em/callback' +require 'em/queue' +require 'em/channel' +require 'em/file_watch' +require 'em/process_watch' +require 'em/tick_loop' +require 'em/resolver' +require 'em/completion' +require 'em/threaded_resource' + +require 'shellwords' +require 'thread' +require 'resolv' + +# Top-level EventMachine namespace. If you are looking for EventMachine examples, see {file:docs/GettingStarted.md EventMachine tutorial}. +# +# ## Key methods ## +# ### Starting and stopping the event loop ### +# +# * {EventMachine.run} +# * {EventMachine.stop_event_loop} +# +# ### Implementing clients ### +# +# * {EventMachine.connect} +# +# ### Implementing servers ### +# +# * {EventMachine.start_server} +# +# ### Working with timers ### +# +# * {EventMachine.add_timer} +# * {EventMachine.add_periodic_timer} +# * {EventMachine.cancel_timer} +# +# ### Working with blocking tasks ### +# +# * {EventMachine.defer} +# * {EventMachine.next_tick} +# +# ### Efficient proxying ### +# +# * {EventMachine.enable_proxy} +# * {EventMachine.disable_proxy} +module EventMachine + class << self + # Exposed to allow joining on the thread, when run in a multithreaded + # environment. Performing other actions on the thread has undefined + # semantics (read: a dangerous endevor). + # + # @return [Thread] + attr_reader :reactor_thread + end + @next_tick_mutex = Mutex.new + @reactor_running = false + @next_tick_queue = [] + @tails = [] + @threadpool = @threadqueue = @resultqueue = nil + @all_threads_spawned = false + + # System errnos + # @private + ERRNOS = Errno::constants.grep(/^E/).inject(Hash.new(:unknown)) { |hash, name| + errno = Errno.__send__(:const_get, name) + hash[errno::Errno] = errno + hash + } + + # Initializes and runs an event loop. This method only returns if code inside the block passed to this method + # calls {EventMachine.stop_event_loop}. The block is executed after initializing its internal event loop but *before* running the loop, + # therefore this block is the right place to call any code that needs event loop to run, for example, {EventMachine.start_server}, + # {EventMachine.connect} or similar methods of libraries that use EventMachine under the hood + # (like `EventMachine::HttpRequest.new` or `AMQP.start`). + # + # Programs that are run for long periods of time (e.g. servers) usually start event loop by calling {EventMachine.run}, and let it + # run "forever". It's also possible to use {EventMachine.run} to make a single client-connection to a remote server, + # process the data flow from that single connection, and then call {EventMachine.stop_event_loop} to stop, in other words, + # to run event loop for a short period of time (necessary to complete some operation) and then shut it down. + # + # Once event loop is running, it is perfectly possible to start multiple servers and clients simultaneously: content-aware + # proxies like [Proxymachine](https://github.com/mojombo/proxymachine) do just that. + # + # ## Using EventMachine with Ruby on Rails and other Web application frameworks ## + # + # Standalone applications often run event loop on the main thread, thus blocking for their entire lifespan. In case of Web applications, + # if you are running an EventMachine-based app server such as [Thin](http://code.macournoyer.com/thin/) or [Goliath](https://github.com/postrank-labs/goliath/), + # they start event loop for you. Servers like Unicorn, Apache Passenger or Mongrel occupy main Ruby thread to serve HTTP(S) requests. This means + # that calling {EventMachine.run} on the same thread is not an option (it will result in Web server never binding to the socket). + # In that case, start event loop in a separate thread as demonstrated below. + # + # + # @example Starting EventMachine event loop in the current thread to run the "Hello, world"-like Echo server example + # + # #!/usr/bin/env ruby + # + # require 'rubygems' # or use Bundler.setup + # require 'eventmachine' + # + # class EchoServer < EM::Connection + # def receive_data(data) + # send_data(data) + # end + # end + # + # EventMachine.run do + # EventMachine.start_server("0.0.0.0", 10000, EchoServer) + # end + # + # + # @example Starting EventMachine event loop in a separate thread + # + # # doesn't block current thread, can be used with Ruby on Rails, Sinatra, Merb, Rack + # # and any other application server that occupies main Ruby thread. + # Thread.new { EventMachine.run } + # + # + # @note This method blocks calling thread. If you need to start EventMachine event loop from a Web app + # running on a non event-driven server (Unicorn, Apache Passenger, Mongrel), do it in a separate thread like demonstrated + # in one of the examples. + # @see file:docs/GettingStarted.md Getting started with EventMachine + # @see EventMachine.stop_event_loop + def self.run blk=nil, tail=nil, &block + # Obsoleted the use_threads mechanism. + # 25Nov06: Added the begin/ensure block. We need to be sure that release_machine + # gets called even if an exception gets thrown within any of the user code + # that the event loop runs. The best way to see this is to run a unit + # test with two functions, each of which calls {EventMachine.run} and each of + # which throws something inside of #run. Without the ensure, the second test + # will start without release_machine being called and will immediately throw + + # + if @reactor_running and @reactor_pid != Process.pid + # Reactor was started in a different parent, meaning we have forked. + # Clean up reactor state so a new reactor boots up in this child. + stop_event_loop + release_machine + cleanup_machine + @reactor_running = false + end + + tail and @tails.unshift(tail) + + if reactor_running? + (b = blk || block) and b.call # next_tick(b) + else + @conns = {} + @acceptors = {} + @timers = {} + @wrapped_exception = nil + @next_tick_queue ||= [] + @tails ||= [] + begin + initialize_event_machine + @reactor_pid = Process.pid + @reactor_thread = Thread.current + @reactor_running = true + + (b = blk || block) and add_timer(0, b) + if @next_tick_queue && !@next_tick_queue.empty? + add_timer(0) { signal_loopbreak } + end + + # Rubinius needs to come back into "Ruby space" for GC to work, + # so we'll crank the machine here. + if defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx" + while run_machine_once; end + else + run_machine + end + + ensure + until @tails.empty? + @tails.pop.call + end + + release_machine + cleanup_machine + @reactor_running = false + @reactor_thread = nil + end + + raise @wrapped_exception if @wrapped_exception + end + end + + # Sugars a common use case. Will pass the given block to #run, but will terminate + # the reactor loop and exit the function as soon as the code in the block completes. + # (Normally, {EventMachine.run} keeps running indefinitely, even after the block supplied to it + # finishes running, until user code calls {EventMachine.stop}) + # + def self.run_block &block + pr = proc { + block.call + EventMachine::stop + } + run(&pr) + end + + # @return [Boolean] true if the calling thread is the same thread as the reactor. + def self.reactor_thread? + Thread.current == @reactor_thread + end + + # Runs the given callback on the reactor thread, or immediately if called + # from the reactor thread. Accepts the same arguments as {EventMachine::Callback} + def self.schedule(*a, &b) + cb = Callback(*a, &b) + if reactor_running? && reactor_thread? + cb.call + else + next_tick { cb.call } + end + end + + # Forks a new process, properly stops the reactor and then calls {EventMachine.run} inside of it again, passing your block. + def self.fork_reactor &block + # This implementation is subject to change, especially if we clean up the relationship + # of EM#run to @reactor_running. + # Original patch by Aman Gupta. + # + Kernel.fork do + if reactor_running? + stop_event_loop + release_machine + cleanup_machine + @reactor_running = false + @reactor_thread = nil + end + run block + end + end + + # Clean up Ruby space following a release_machine + def self.cleanup_machine + if @threadpool && !@threadpool.empty? + # Tell the threads to stop + @threadpool.each { |t| t.exit } + # Join the threads or bump the stragglers one more time + @threadpool.each { |t| t.join 0.01 || t.exit } + end + @threadpool = nil + @threadqueue = nil + @resultqueue = nil + @all_threads_spawned = false + @next_tick_queue = [] + end + + # Adds a block to call as the reactor is shutting down. + # + # These callbacks are called in the _reverse_ order to which they are added. + # + # @example Scheduling operations to be run when EventMachine event loop is stopped + # + # EventMachine.run do + # EventMachine.add_shutdown_hook { puts "b" } + # EventMachine.add_shutdown_hook { puts "a" } + # EventMachine.stop + # end + # + # # Outputs: + # # a + # # b + # + def self.add_shutdown_hook &block + @tails << block + end + + # Adds a one-shot timer to the event loop. + # Call it with one or two parameters. The first parameters is a delay-time + # expressed in *seconds* (not milliseconds). The second parameter, if + # present, must be an object that responds to :call. If 2nd parameter is not given, then you + # can also simply pass a block to the method call. + # + # This method may be called from the block passed to {EventMachine.run} + # or from any callback method. It schedules execution of the proc or block + # passed to it, after the passage of an interval of time equal to + # *at least* the number of seconds specified in the first parameter to + # the call. + # + # {EventMachine.add_timer} is a non-blocking method. Callbacks can and will + # be called during the interval of time that the timer is in effect. + # There is no built-in limit to the number of timers that can be outstanding at + # any given time. + # + # @example Setting a one-shot timer with EventMachine + # + # EventMachine.run { + # puts "Starting the run now: #{Time.now}" + # EventMachine.add_timer 5, proc { puts "Executing timer event: #{Time.now}" } + # EventMachine.add_timer(10) { puts "Executing timer event: #{Time.now}" } + # } + # + # @param [Integer] delay Delay in seconds + # @see EventMachine::Timer + # @see EventMachine.add_periodic_timer + def self.add_timer *args, &block + interval = args.shift + code = args.shift || block + if code + # check too many timers! + s = add_oneshot_timer((interval.to_f * 1000).to_i) + @timers[s] = code + s + end + end + + # Adds a periodic timer to the event loop. + # It takes the same parameters as the one-shot timer method, {EventMachine.add_timer}. + # This method schedules execution of the given block repeatedly, at intervals + # of time *at least* as great as the number of seconds given in the first + # parameter to the call. + # + # @example Write a dollar-sign to stderr every five seconds, without blocking + # + # EventMachine.run { + # EventMachine.add_periodic_timer( 5 ) { $stderr.write "$" } + # } + # + # @param [Integer] delay Delay in seconds + # + # @see EventMachine::PeriodicTimer + # @see EventMachine.add_timer + # + def self.add_periodic_timer *args, &block + interval = args.shift + code = args.shift || block + + EventMachine::PeriodicTimer.new(interval, code) + end + + + # Cancel a timer (can be a callback or an {EventMachine::Timer} instance). + # + # @param [#cancel, #call] timer_or_sig A timer to cancel + # @see EventMachine::Timer#cancel + def self.cancel_timer timer_or_sig + if timer_or_sig.respond_to? :cancel + timer_or_sig.cancel + else + @timers[timer_or_sig] = false if @timers.has_key?(timer_or_sig) + end + end + + + # Causes the processing loop to stop executing, which will cause all open connections and accepting servers + # to be run down and closed. Connection termination callbacks added using {EventMachine.add_shutdown_hook} + # will be called as part of running this method. + # + # When all of this processing is complete, the call to {EventMachine.run} which started the processing loop + # will return and program flow will resume from the statement following {EventMachine.run} call. + # + # @example Stopping a running EventMachine event loop + # + # require 'rubygems' + # require 'eventmachine' + # + # module Redmond + # def post_init + # puts "We're sending a dumb HTTP request to the remote peer." + # send_data "GET / HTTP/1.1\r\nHost: www.microsoft.com\r\n\r\n" + # end + # + # def receive_data data + # puts "We received #{data.length} bytes from the remote peer." + # puts "We're going to stop the event loop now." + # EventMachine::stop_event_loop + # end + # + # def unbind + # puts "A connection has terminated." + # end + # end + # + # puts "We're starting the event loop now." + # EventMachine.run { + # EventMachine.connect "www.microsoft.com", 80, Redmond + # } + # puts "The event loop has stopped." + # + # # This program will produce approximately the following output: + # # + # # We're starting the event loop now. + # # We're sending a dumb HTTP request to the remote peer. + # # We received 1440 bytes from the remote peer. + # # We're going to stop the event loop now. + # # A connection has terminated. + # # The event loop has stopped. + # + # + def self.stop_event_loop + EventMachine::stop + end + + # Initiates a TCP server (socket acceptor) on the specified IP address and port. + # + # The IP address must be valid on the machine where the program + # runs, and the process must be privileged enough to listen + # on the specified port (on Unix-like systems, superuser privileges + # are usually required to listen on any port lower than 1024). + # Only one listener may be running on any given address/port + # combination. start_server will fail if the given address and port + # are already listening on the machine, either because of a prior call + # to {.start_server} or some unrelated process running on the machine. + # If {.start_server} succeeds, the new network listener becomes active + # immediately and starts accepting connections from remote peers, + # and these connections generate callback events that are processed + # by the code specified in the handler parameter to {.start_server}. + # + # The optional handler which is passed to this method is the key + # to EventMachine's ability to handle particular network protocols. + # The handler parameter passed to start_server must be a Ruby Module + # that you must define. When the network server that is started by + # start_server accepts a new connection, it instantiates a new + # object of an anonymous class that is inherited from {EventMachine::Connection}, + # *into which your handler module have been included*. Arguments passed into start_server + # after the class name are passed into the constructor during the instantiation. + # + # Your handler module may override any of the methods in {EventMachine::Connection}, + # such as {EventMachine::Connection#receive_data}, in order to implement the specific behavior + # of the network protocol. + # + # Callbacks invoked in response to network events *always* take place + # within the execution context of the object derived from {EventMachine::Connection} + # extended by your handler module. There is one object per connection, and + # all of the callbacks invoked for a particular connection take the form + # of instance methods called against the corresponding {EventMachine::Connection} + # object. Therefore, you are free to define whatever instance variables you + # wish, in order to contain the per-connection state required by the network protocol you are + # implementing. + # + # {EventMachine.start_server} is usually called inside the block passed to {EventMachine.run}, + # but it can be called from any EventMachine callback. {EventMachine.start_server} will fail + # unless the EventMachine event loop is currently running (which is why + # it's often called in the block suppled to {EventMachine.run}). + # + # You may call start_server any number of times to start up network + # listeners on different address/port combinations. The servers will + # all run simultaneously. More interestingly, each individual call to start_server + # can specify a different handler module and thus implement a different + # network protocol from all the others. + # + # @example + # + # require 'rubygems' + # require 'eventmachine' + # + # # Here is an example of a server that counts lines of input from the remote + # # peer and sends back the total number of lines received, after each line. + # # Try the example with more than one client connection opened via telnet, + # # and you will see that the line count increments independently on each + # # of the client connections. Also very important to note, is that the + # # handler for the receive_data function, which our handler redefines, may + # # not assume that the data it receives observes any kind of message boundaries. + # # Also, to use this example, be sure to change the server and port parameters + # # to the start_server call to values appropriate for your environment. + # module LineCounter + # MaxLinesPerConnection = 10 + # + # def post_init + # puts "Received a new connection" + # @data_received = "" + # @line_count = 0 + # end + # + # def receive_data data + # @data_received << data + # while @data_received.slice!( /^[^\n]*[\n]/m ) + # @line_count += 1 + # send_data "received #{@line_count} lines so far\r\n" + # @line_count == MaxLinesPerConnection and close_connection_after_writing + # end + # end + # end + # + # EventMachine.run { + # host, port = "192.168.0.100", 8090 + # EventMachine.start_server host, port, LineCounter + # puts "Now accepting connections on address #{host}, port #{port}..." + # EventMachine.add_periodic_timer(10) { $stderr.write "*" } + # } + # + # @param [String] server Host to bind to. + # @param [Integer] port Port to bind to. + # @param [Module, Class] handler A module or class that implements connection callbacks + # + # @note Don't forget that in order to bind to ports < 1024 on Linux, *BSD and Mac OS X your process must have superuser privileges. + # + # @see file:docs/GettingStarted.md EventMachine tutorial + # @see EventMachine.stop_server + def self.start_server server, port=nil, handler=nil, *args, &block + begin + port = Integer(port) + rescue ArgumentError, TypeError + # there was no port, so server must be a unix domain socket + # the port argument is actually the handler, and the handler is one of the args + args.unshift handler if handler + handler = port + port = nil + end if port + + klass = klass_from_handler(Connection, handler, *args) + + s = if port + start_tcp_server server, port + else + start_unix_server server + end + @acceptors[s] = [klass,args,block] + s + end + + # Attach to an existing socket's file descriptor. The socket may have been + # started with {EventMachine.start_server}. + def self.attach_server sock, handler=nil, *args, &block + klass = klass_from_handler(Connection, handler, *args) + sd = sock.respond_to?(:fileno) ? sock.fileno : sock + s = attach_sd(sd) + @acceptors[s] = [klass,args,block,sock] + s + end + + # Stop a TCP server socket that was started with {EventMachine.start_server}. + # @see EventMachine.start_server + def self.stop_server signature + EventMachine::stop_tcp_server signature + end + + # Start a Unix-domain server. + # + # Note that this is an alias for {EventMachine.start_server}, which can be used to start both + # TCP and Unix-domain servers. + # + # @see EventMachine.start_server + def self.start_unix_domain_server filename, *args, &block + start_server filename, *args, &block + end + + # Initiates a TCP connection to a remote server and sets up event handling for the connection. + # {EventMachine.connect} requires event loop to be running (see {EventMachine.run}). + # + # {EventMachine.connect} takes the IP address (or hostname) and + # port of the remote server you want to connect to. + # It also takes an optional handler (a module or a subclass of {EventMachine::Connection}) which you must define, that + # contains the callbacks that will be invoked by the event loop on behalf of the connection. + # + # Learn more about connection lifecycle callbacks in the {file:docs/GettingStarted.md EventMachine tutorial} and + # {file:docs/ConnectionLifecycleCallbacks.md Connection lifecycle guide}. + # + # + # @example + # + # # Here's a program which connects to a web server, sends a naive + # # request, parses the HTTP header of the response, and then + # # (antisocially) ends the event loop, which automatically drops the connection + # # (and incidentally calls the connection's unbind method). + # module DumbHttpClient + # def post_init + # send_data "GET / HTTP/1.1\r\nHost: _\r\n\r\n" + # @data = "" + # @parsed = false + # end + # + # def receive_data data + # @data << data + # if !@parsed and @data =~ /[\n][\r]*[\n]/m + # @parsed = true + # puts "RECEIVED HTTP HEADER:" + # $`.each {|line| puts ">>> #{line}" } + # + # puts "Now we'll terminate the loop, which will also close the connection" + # EventMachine::stop_event_loop + # end + # end + # + # def unbind + # puts "A connection has terminated" + # end + # end + # + # EventMachine.run { + # EventMachine.connect "www.bayshorenetworks.com", 80, DumbHttpClient + # } + # puts "The event loop has ended" + # + # + # @example Defining protocol handler as a class + # + # class MyProtocolHandler < EventMachine::Connection + # def initialize *args + # super + # # whatever else you want to do here + # end + # + # # ... + # end + # + # + # @param [String] server Host to connect to + # @param [Integer] port Port to connect to + # @param [Module, Class] handler A module or class that implements connection lifecycle callbacks + # + # @see EventMachine.start_server + # @see file:docs/GettingStarted.md EventMachine tutorial + def self.connect server, port=nil, handler=nil, *args, &blk + # EventMachine::connect initiates a TCP connection to a remote + # server and sets up event-handling for the connection. + # It internally creates an object that should not be handled + # by the caller. HOWEVER, it's often convenient to get the + # object to set up interfacing to other objects in the system. + # We return the newly-created anonymous-class object to the caller. + # It's expected that a considerable amount of code will depend + # on this behavior, so don't change it. + # + # Ok, added support for a user-defined block, 13Apr06. + # This leads us to an interesting choice because of the + # presence of the post_init call, which happens in the + # initialize method of the new object. We call the user's + # block and pass the new object to it. This is a great + # way to do protocol-specific initiation. It happens + # AFTER post_init has been called on the object, which I + # certainly hope is the right choice. + # Don't change this lightly, because accepted connections + # are different from connected ones and we don't want + # to have them behave differently with respect to post_init + # if at all possible. + + bind_connect nil, nil, server, port, handler, *args, &blk + end + + # This method is like {EventMachine.connect}, but allows for a local address/port + # to bind the connection to. + # + # @see EventMachine.connect + def self.bind_connect bind_addr, bind_port, server, port=nil, handler=nil, *args + begin + port = Integer(port) + rescue ArgumentError, TypeError + # there was no port, so server must be a unix domain socket + # the port argument is actually the handler, and the handler is one of the args + args.unshift handler if handler + handler = port + port = nil + end if port + + klass = klass_from_handler(Connection, handler, *args) + + s = if port + if bind_addr + bind_connect_server bind_addr, bind_port.to_i, server, port + else + connect_server server, port + end + else + connect_unix_server server + end + + c = klass.new s, *args + @conns[s] = c + block_given? and yield c + c + end + + # {EventMachine.watch} registers a given file descriptor or IO object with the eventloop. The + # file descriptor will not be modified (it will remain blocking or non-blocking). + # + # The eventloop can be used to process readable and writable events on the file descriptor, using + # {EventMachine::Connection#notify_readable=} and {EventMachine::Connection#notify_writable=} + # + # {EventMachine::Connection#notify_readable?} and {EventMachine::Connection#notify_writable?} can be used + # to check what events are enabled on the connection. + # + # To detach the file descriptor, use {EventMachine::Connection#detach} + # + # @example + # + # module SimpleHttpClient + # def notify_readable + # header = @io.readline + # + # if header == "\r\n" + # # detach returns the file descriptor number (fd == @io.fileno) + # fd = detach + # end + # rescue EOFError + # detach + # end + # + # def unbind + # EM.next_tick do + # # socket is detached from the eventloop, but still open + # data = @io.read + # end + # end + # end + # + # EventMachine.run { + # sock = TCPSocket.new('site.com', 80) + # sock.write("GET / HTTP/1.0\r\n\r\n") + # conn = EventMachine.watch(sock, SimpleHttpClient) + # conn.notify_readable = true + # } + # + # @author Riham Aldakkak (eSpace Technologies) + def EventMachine::watch io, handler=nil, *args, &blk + attach_io io, true, handler, *args, &blk + end + + # Attaches an IO object or file descriptor to the eventloop as a regular connection. + # The file descriptor will be set as non-blocking, and EventMachine will process + # receive_data and send_data events on it as it would for any other connection. + # + # To watch a fd instead, use {EventMachine.watch}, which will not alter the state of the socket + # and fire notify_readable and notify_writable events instead. + def EventMachine::attach io, handler=nil, *args, &blk + attach_io io, false, handler, *args, &blk + end + + # @private + def EventMachine::attach_io io, watch_mode, handler=nil, *args + klass = klass_from_handler(Connection, handler, *args) + + if !watch_mode and klass.public_instance_methods.any?{|m| [:notify_readable, :notify_writable].include? m.to_sym } + raise ArgumentError, "notify_readable/writable with EM.attach is not supported. Use EM.watch(io){ |c| c.notify_readable = true }" + end + + if io.respond_to?(:fileno) + # getDescriptorByFileno deprecated in JRuby 1.7.x, removed in JRuby 9000 + if defined?(JRuby) && JRuby.runtime.respond_to?(:getDescriptorByFileno) + fd = JRuby.runtime.getDescriptorByFileno(io.fileno).getChannel + else + fd = io.fileno + end + else + fd = io + end + + s = attach_fd fd, watch_mode + c = klass.new s, *args + + c.instance_variable_set(:@io, io) + c.instance_variable_set(:@watch_mode, watch_mode) + c.instance_variable_set(:@fd, fd) + + @conns[s] = c + block_given? and yield c + c + end + + + # Connect to a given host/port and re-use the provided {EventMachine::Connection} instance. + # Consider also {EventMachine::Connection#reconnect}. + # + # @see EventMachine::Connection#reconnect + def self.reconnect server, port, handler + # Observe, the test for already-connected FAILS if we call a reconnect inside post_init, + # because we haven't set up the connection in @conns by that point. + # RESIST THE TEMPTATION to "fix" this problem by redefining the behavior of post_init. + # + # Changed 22Nov06: if called on an already-connected handler, just return the + # handler and do nothing more. Originally this condition raised an exception. + # We may want to change it yet again and call the block, if any. + + raise "invalid handler" unless handler.respond_to?(:connection_completed) + #raise "still connected" if @conns.has_key?(handler.signature) + return handler if @conns.has_key?(handler.signature) + + s = if port + connect_server server, port + else + connect_unix_server server + end + handler.signature = s + @conns[s] = handler + block_given? and yield handler + handler + end + + + # Make a connection to a Unix-domain socket. This method is simply an alias for {.connect}, + # which can connect to both TCP and Unix-domain sockets. Make sure that your process has sufficient + # permissions to open the socket it is given. + # + # @param [String] socketname Unix domain socket (local fully-qualified path) you want to connect to. + # + # @note UNIX sockets, as the name suggests, are not available on Microsoft Windows. + def self.connect_unix_domain socketname, *args, &blk + connect socketname, *args, &blk + end + + + # Used for UDP-based protocols. Its usage is similar to that of {EventMachine.start_server}. + # + # This method will create a new UDP (datagram) socket and + # bind it to the address and port that you specify. + # The normal callbacks (see {EventMachine.start_server}) will + # be called as events of interest occur on the newly-created + # socket, but there are some differences in how they behave. + # + # {Connection#receive_data} will be called when a datagram packet + # is received on the socket, but unlike TCP sockets, the message + # boundaries of the received data will be respected. In other words, + # if the remote peer sent you a datagram of a particular size, + # you may rely on {Connection#receive_data} to give you the + # exact data in the packet, with the original data length. + # Also observe that Connection#receive_data may be called with a + # *zero-length* data payload, since empty datagrams are permitted in UDP. + # + # {Connection#send_data} is available with UDP packets as with TCP, + # but there is an important difference. Because UDP communications + # are *connectionless*, there is no implicit recipient for the packets you + # send. Ordinarily you must specify the recipient for each packet you send. + # However, EventMachine provides for the typical pattern of receiving a UDP datagram + # from a remote peer, performing some operation, and then sending + # one or more packets in response to the same remote peer. + # To support this model easily, just use {Connection#send_data} + # in the code that you supply for {Connection#receive_data}. + # + # EventMachine will provide an implicit return address for any messages sent to + # {Connection#send_data} within the context of a {Connection#receive_data} callback, + # and your response will automatically go to the correct remote peer. + # + # Observe that the port number that you supply to {EventMachine.open_datagram_socket} + # may be zero. In this case, EventMachine will create a UDP socket + # that is bound to an [ephemeral port](http://en.wikipedia.org/wiki/Ephemeral_port). + # This is not appropriate for servers that must publish a well-known + # port to which remote peers may send datagrams. But it can be useful + # for clients that send datagrams to other servers. + # If you do this, you will receive any responses from the remote + # servers through the normal {Connection#receive_data} callback. + # Observe that you will probably have issues with firewalls blocking + # the ephemeral port numbers, so this technique is most appropriate for LANs. + # + # If you wish to send datagrams to arbitrary remote peers (not + # necessarily ones that have sent data to which you are responding), + # then see {Connection#send_datagram}. + # + # DO NOT call send_data from a datagram socket outside of a {Connection#receive_data} method. Use {Connection#send_datagram}. + # If you do use {Connection#send_data} outside of a {Connection#receive_data} method, you'll get a confusing error + # because there is no "peer," as #send_data requires (inside of {EventMachine::Connection#receive_data}, + # {EventMachine::Connection#send_data} "fakes" the peer as described above). + # + # @param [String] address IP address + # @param [String] port Port + # @param [Class, Module] handler A class or a module that implements connection lifecycle callbacks. + def self.open_datagram_socket address, port, handler=nil, *args + # Replaced the implementation on 01Oct06. Thanks to Tobias Gustafsson for pointing + # out that this originally did not take a class but only a module. + + + klass = klass_from_handler(Connection, handler, *args) + s = open_udp_socket address, port.to_i + c = klass.new s, *args + @conns[s] = c + block_given? and yield c + c + end + + + # For advanced users. This function sets the default timer granularity, which by default is + # slightly smaller than 100 milliseconds. Call this function to set a higher or lower granularity. + # The function affects the behavior of {EventMachine.add_timer} and {EventMachine.add_periodic_timer}. + # Most applications will not need to call this function. + # + # Avoid setting the quantum to very low values because that may reduce performance under some extreme conditions. + # We recommend that you not use values lower than 10. + # + # This method only can be used if event loop is running. + # + # @param [Integer] mills New timer granularity, in milliseconds + # + # @see EventMachine.add_timer + # @see EventMachine.add_periodic_timer + # @see EventMachine::Timer + # @see EventMachine.run + def self.set_quantum mills + set_timer_quantum mills.to_i + end + + # Sets the maximum number of timers and periodic timers that may be outstanding at any + # given time. You only need to call {.set_max_timers} if you need more than the default + # number of timers, which on most platforms is 1000. + # + # @note This method has to be used *before* event loop is started. + # + # @param [Integer] ct Maximum number of timers that may be outstanding at any given time + # + # @see EventMachine.add_timer + # @see EventMachine.add_periodic_timer + # @see EventMachine::Timer + def self.set_max_timers ct + set_max_timer_count ct + end + + # Gets the current maximum number of allowed timers + # + # @return [Integer] Maximum number of timers that may be outstanding at any given time + def self.get_max_timers + get_max_timer_count + end + + # Returns the total number of connections (file descriptors) currently held by the reactor. + # Note that a tick must pass after the 'initiation' of a connection for this number to increment. + # It's usually accurate, but don't rely on the exact precision of this number unless you really know EM internals. + # + # @example + # + # EventMachine.run { + # EventMachine.connect("rubyeventmachine.com", 80) + # # count will be 0 in this case, because connection is not + # # established yet + # count = EventMachine.connection_count + # } + # + # + # @example + # + # EventMachine.run { + # EventMachine.connect("rubyeventmachine.com", 80) + # + # EventMachine.next_tick { + # # In this example, count will be 1 since the connection has been established in + # # the next loop of the reactor. + # count = EventMachine.connection_count + # } + # } + # + # @return [Integer] Number of connections currently held by the reactor. + def self.connection_count + self.get_connection_count + end + + # The is the responder for the loopback-signalled event. + # It can be fired either by code running on a separate thread ({EventMachine.defer}) or on + # the main thread ({EventMachine.next_tick}). + # It will often happen that a next_tick handler will reschedule itself. We + # consume a copy of the tick queue so that tick events scheduled by tick events + # have to wait for the next pass through the reactor core. + # + # @private + def self.run_deferred_callbacks + until (@resultqueue ||= []).empty? + result,cback = @resultqueue.pop + cback.call result if cback + end + + # Capture the size at the start of this tick... + size = @next_tick_mutex.synchronize { @next_tick_queue.size } + size.times do |i| + callback = @next_tick_mutex.synchronize { @next_tick_queue.shift } + begin + callback.call + rescue + exception_raised = true + raise + ensure + # This is a little nasty. The problem is, if an exception occurs during + # the callback, then we need to send a signal to the reactor to actually + # do some work during the next_tick. The only mechanism we have from the + # ruby side is next_tick itself, although ideally, we'd just drop a byte + # on the loopback descriptor. + next_tick {} if exception_raised + end + end + end + + + # EventMachine.defer is used for integrating blocking operations into EventMachine's control flow. + # The action of {.defer} is to take the block specified in the first parameter (the "operation") + # and schedule it for asynchronous execution on an internal thread pool maintained by EventMachine. + # When the operation completes, it will pass the result computed by the block (if any) back to the + # EventMachine reactor. Then, EventMachine calls the block specified in the second parameter to + # {.defer} (the "callback"), as part of its normal event handling loop. The result computed by the + # operation block is passed as a parameter to the callback. You may omit the callback parameter if + # you don't need to execute any code after the operation completes. If the operation raises an + # unhandled exception, the exception will be passed to the third parameter to {.defer} (the + # "errback"), as part of its normal event handling loop. If no errback is provided, the exception + # will be allowed to blow through to the main thread immediately. + # + # ## Caveats ## + # + # Note carefully that the code in your deferred operation will be executed on a separate + # thread from the main EventMachine processing and all other Ruby threads that may exist in + # your program. Also, multiple deferred operations may be running at once! Therefore, you + # are responsible for ensuring that your operation code is threadsafe. + # + # Don't write a deferred operation that will block forever. If so, the current implementation will + # not detect the problem, and the thread will never be returned to the pool. EventMachine limits + # the number of threads in its pool, so if you do this enough times, your subsequent deferred + # operations won't get a chance to run. + # + # The threads within the EventMachine's thread pool have abort_on_exception set to true. As a result, + # if an unhandled exception is raised by the deferred operation and an errback is not provided, it + # will blow through to the main thread immediately. If the main thread is within an indiscriminate + # rescue block at that time, the exception could be handled improperly by the main thread. + # + # @example + # + # operation = proc { + # # perform a long-running operation here, such as a database query. + # "result" # as usual, the last expression evaluated in the block will be the return value. + # } + # callback = proc {|result| + # # do something with result here, such as send it back to a network client. + # } + # errback = proc {|error| + # # do something with error here, such as re-raising or logging. + # } + # + # EventMachine.defer(operation, callback, errback) + # + # @param [#call] op An operation you want to offload to EventMachine thread pool + # @param [#call] callback A callback that will be run on the event loop thread after `operation` finishes. + # @param [#call] errback An errback that will be run on the event loop thread after `operation` raises an exception. + # + # @see EventMachine.threadpool_size + def self.defer op = nil, callback = nil, errback = nil, &blk + # OBSERVE that #next_tick hacks into this mechanism, so don't make any changes here + # without syncing there. + # + # Running with $VERBOSE set to true gives a warning unless all ivars are defined when + # they appear in rvalues. But we DON'T ever want to initialize @threadqueue unless we + # need it, because the Ruby threads are so heavyweight. We end up with this bizarre + # way of initializing @threadqueue because EventMachine is a Module, not a Class, and + # has no constructor. + + unless @threadpool + @threadpool = [] + @threadqueue = ::Queue.new + @resultqueue = ::Queue.new + spawn_threadpool + end + + @threadqueue << [op||blk,callback,errback] + end + + + # @private + def self.spawn_threadpool + until @threadpool.size == @threadpool_size.to_i + thread = Thread.new do + Thread.current.abort_on_exception = true + while true + begin + op, cback, eback = *@threadqueue.pop + rescue ThreadError + $stderr.puts $!.message + break # Ruby 2.0 may fail at Queue.pop + end + begin + result = op.call + @resultqueue << [result, cback] + rescue Exception => error + raise error unless eback + @resultqueue << [error, eback] + end + signal_loopbreak + end + end + @threadpool << thread + end + @all_threads_spawned = true + end + + ## + # Returns +true+ if all deferred actions are done executing and their + # callbacks have been fired. + # + def self.defers_finished? + return false if @threadpool and !@all_threads_spawned + return false if @threadqueue and not @threadqueue.empty? + return false if @resultqueue and not @resultqueue.empty? + return false if @threadpool and @threadqueue.num_waiting != @threadpool.size + return true + end + + class << self + # @private + attr_reader :threadpool + + # Size of the EventMachine.defer threadpool (defaults to 20) + # @return [Number] + attr_accessor :threadpool_size + EventMachine.threadpool_size = 20 + end + + # Schedules a proc for execution immediately after the next "turn" through the reactor + # core. An advanced technique, this can be useful for improving memory management and/or + # application responsiveness, especially when scheduling large amounts of data for + # writing to a network connection. + # + # This method takes either a single argument (which must be a callable object) or a block. + # + # @param [#call] pr A callable object to run + def self.next_tick pr=nil, &block + # This works by adding to the @resultqueue that's used for #defer. + # The general idea is that next_tick is used when we want to give the reactor a chance + # to let other operations run, either to balance the load out more evenly, or to let + # outbound network buffers drain, or both. So we probably do NOT want to block, and + # we probably do NOT want to be spinning any threads. A program that uses next_tick + # but not #defer shouldn't suffer the penalty of having Ruby threads running. They're + # extremely expensive even if they're just sleeping. + + raise ArgumentError, "no proc or block given" unless ((pr && pr.respond_to?(:call)) or block) + @next_tick_mutex.synchronize do + @next_tick_queue << ( pr || block ) + end + signal_loopbreak if reactor_running? + end + + # A wrapper over the setuid system call. Particularly useful when opening a network + # server on a privileged port because you can use this call to drop privileges + # after opening the port. Also very useful after a call to {.set_descriptor_table_size}, + # which generally requires that you start your process with root privileges. + # + # This method is intended for use in enforcing security requirements, consequently + # it will throw a fatal error and end your program if it fails. + # + # @param [String] username The effective name of the user whose privilege-level your process should attain. + # + # @note This method has no effective implementation on Windows or in the pure-Ruby + # implementation of EventMachine + def self.set_effective_user username + EventMachine::setuid_string username + end + + + # Sets the maximum number of file or socket descriptors that your process may open. + # If you call this method with no arguments, it will simply return + # the current size of the descriptor table without attempting to change it. + # + # The new limit on open descriptors **only** applies to sockets and other descriptors + # that belong to EventMachine. It has **no effect** on the number of descriptors + # you can create in ordinary Ruby code. + # + # Not available on all platforms. Increasing the number of descriptors beyond its + # default limit usually requires superuser privileges. (See {.set_effective_user} + # for a way to drop superuser privileges while your program is running.) + # + # @param [Integer] n_descriptors The maximum number of file or socket descriptors that your process may open + # @return [Integer] The new descriptor table size. + def self.set_descriptor_table_size n_descriptors=nil + EventMachine::set_rlimit_nofile n_descriptors + end + + + + # Runs an external process. + # + # @example + # + # module RubyCounter + # def post_init + # # count up to 5 + # send_data "5\n" + # end + # def receive_data data + # puts "ruby sent me: #{data}" + # end + # def unbind + # puts "ruby died with exit status: #{get_status.exitstatus}" + # end + # end + # + # EventMachine.run { + # EventMachine.popen("ruby -e' $stdout.sync = true; gets.to_i.times{ |i| puts i+1; sleep 1 } '", RubyCounter) + # } + # + # @note This method is not supported on Microsoft Windows + # @see EventMachine::DeferrableChildProcess + # @see EventMachine.system + def self.popen cmd, handler=nil, *args + # At this moment, it's only available on Unix. + # Perhaps misnamed since the underlying function uses socketpair and is full-duplex. + + klass = klass_from_handler(Connection, handler, *args) + w = case cmd + when Array + cmd + when String + Shellwords::shellwords( cmd ) + end + w.unshift( w.first ) if w.first + s = invoke_popen( w ) + c = klass.new s, *args + @conns[s] = c + yield(c) if block_given? + c + end + + + # Tells you whether the EventMachine reactor loop is currently running. + # + # Useful when writing libraries that want to run event-driven code, but may + # be running in programs that are already event-driven. In such cases, if {EventMachine.reactor_running?} + # returns false, your code can invoke {EventMachine.run} and run your application code inside + # the block passed to that method. If this method returns true, just + # execute your event-aware code. + # + # @return [Boolean] true if the EventMachine reactor loop is currently running + def self.reactor_running? + @reactor_running && Process.pid == @reactor_pid + end + + + # (Experimental) + # + # @private + def self.open_keyboard handler=nil, *args + klass = klass_from_handler(Connection, handler, *args) + + s = read_keyboard + c = klass.new s, *args + @conns[s] = c + block_given? and yield c + c + end + + # EventMachine's file monitoring API. Currently supported are the following events + # on individual files, using inotify on Linux systems, and kqueue for *BSD and Mac OS X: + # + # * File modified (written to) + # * File moved/renamed + # * File deleted + # + # EventMachine::watch_file takes a filename and a handler Module containing your custom callback methods. + # This will setup the low level monitoring on the specified file, and create a new EventMachine::FileWatch + # object with your Module mixed in. FileWatch is a subclass of {EventMachine::Connection}, so callbacks on this object + # work in the familiar way. The callbacks that will be fired by EventMachine are: + # + # * file_modified + # * file_moved + # * file_deleted + # + # You can access the filename being monitored from within this object using {FileWatch#path}. + # + # When a file is deleted, {FileWatch#stop_watching} will be called after your file_deleted callback, + # to clean up the underlying monitoring and remove EventMachine's reference to the now-useless {FileWatch} instance. + # This will in turn call unbind, if you wish to use it. + # + # The corresponding system-level Errno will be raised when attempting to monitor non-existent files, + # files with wrong permissions, or if an error occurs dealing with inotify/kqueue. + # + # @example + # + # # Before running this example, make sure we have a file to monitor: + # # $ echo "bar" > /tmp/foo + # + # module Handler + # def file_modified + # puts "#{path} modified" + # end + # + # def file_moved + # puts "#{path} moved" + # end + # + # def file_deleted + # puts "#{path} deleted" + # end + # + # def unbind + # puts "#{path} monitoring ceased" + # end + # end + # + # # for efficient file watching, use kqueue on Mac OS X + # EventMachine.kqueue = true if EventMachine.kqueue? + # + # EventMachine.run { + # EventMachine.watch_file("/tmp/foo", Handler) + # } + # + # # $ echo "baz" >> /tmp/foo => "/tmp/foo modified" + # # $ mv /tmp/foo /tmp/oof => "/tmp/foo moved" + # # $ rm /tmp/oof => "/tmp/foo deleted" + # + # @note The ability to pick up on the new filename after a rename is not yet supported. + # Calling #path will always return the filename you originally used. + # + # @param [String] filename Local path to the file to watch. + # @param [Class, Module] handler A class or module that implements event handlers associated with the file. + def self.watch_file(filename, handler=nil, *args) + klass = klass_from_handler(FileWatch, handler, *args) + + s = EM::watch_filename(filename) + c = klass.new s, *args + # we have to set the path like this because of how Connection.new works + c.instance_variable_set("@path", filename) + @conns[s] = c + block_given? and yield c + c + end + + # EventMachine's process monitoring API. On Mac OS X and *BSD this method is implemented using kqueue. + # + # @example + # + # module ProcessWatcher + # def process_exited + # put 'the forked child died!' + # end + # end + # + # pid = fork{ sleep } + # + # EventMachine.run { + # EventMachine.watch_process(pid, ProcessWatcher) + # EventMachine.add_timer(1){ Process.kill('TERM', pid) } + # } + # + # @param [Integer] pid PID of the process to watch. + # @param [Class, Module] handler A class or module that implements event handlers associated with the file. + def self.watch_process(pid, handler=nil, *args) + pid = pid.to_i + + klass = klass_from_handler(ProcessWatch, handler, *args) + + s = EM::watch_pid(pid) + c = klass.new s, *args + # we have to set the path like this because of how Connection.new works + c.instance_variable_set("@pid", pid) + @conns[s] = c + block_given? and yield c + c + end + + # Catch-all for errors raised during event loop callbacks. + # + # @example + # + # EventMachine.error_handler{ |e| + # puts "Error raised during event loop: #{e.message}" + # } + # + # @param [#call] cb Global catch-all errback + def self.error_handler cb = nil, &blk + if cb or blk + @error_handler = cb || blk + elsif instance_variable_defined? :@error_handler + remove_instance_variable :@error_handler + end + end + + # This method allows for direct writing of incoming data back out to another descriptor, at the C++ level in the reactor. + # This is very efficient and especially useful for proxies where high performance is required. Propogating data from a server response + # all the way up to Ruby, and then back down to the reactor to be sent back to the client, is often unnecessary and + # incurs a significant performance decrease. + # + # The two arguments are instance of {EventMachine::Connection} subclasses, 'from' and 'to'. 'from' is the connection whose inbound data you want + # relayed back out. 'to' is the connection to write it to. + # + # Once you call this method, the 'from' connection will no longer get receive_data callbacks from the reactor, + # except in the case that 'to' connection has already closed when attempting to write to it. You can see + # in the example, that proxy_target_unbound will be called when this occurs. After that, further incoming + # data will be passed into receive_data as normal. + # + # Note also that this feature supports different types of descriptors: TCP, UDP, and pipes. You can relay + # data from one kind to another, for example, feed a pipe from a UDP stream. + # + # @example + # + # module ProxyConnection + # def initialize(client, request) + # @client, @request = client, request + # end + # + # def post_init + # EM::enable_proxy(self, @client) + # end + # + # def connection_completed + # send_data @request + # end + # + # def proxy_target_unbound + # close_connection + # end + # + # def unbind + # @client.close_connection_after_writing + # end + # end + # + # module ProxyServer + # def receive_data(data) + # (@buf ||= "") << data + # if @buf =~ /\r\n\r\n/ # all http headers received + # EventMachine.connect("10.0.0.15", 80, ProxyConnection, self, data) + # end + # end + # end + # + # EventMachine.run { + # EventMachine.start_server("127.0.0.1", 8080, ProxyServer) + # } + # + # @param [EventMachine::Connection] from Source of data to be proxies/streamed. + # @param [EventMachine::Connection] to Destination of data to be proxies/streamed. + # @param [Integer] bufsize Buffer size to use + # @param [Integer] length Maximum number of bytes to proxy. + # + # @see EventMachine.disable_proxy + def self.enable_proxy(from, to, bufsize=0, length=0) + EM::start_proxy(from.signature, to.signature, bufsize, length) + end + + # Takes just one argument, a {Connection} that has proxying enabled via {EventMachine.enable_proxy}. + # Calling this method will remove that functionality and your connection will begin receiving + # data via {Connection#receive_data} again. + # + # @param [EventMachine::Connection] from Source of data that is being proxied + # @see EventMachine.enable_proxy + def self.disable_proxy(from) + EM::stop_proxy(from.signature) + end + + # Retrieve the heartbeat interval. This is how often EventMachine will check for dead connections + # that have had an inactivity timeout set via {Connection#set_comm_inactivity_timeout}. + # Default is 2 seconds. + # + # @return [Integer] Heartbeat interval, in seconds + def self.heartbeat_interval + EM::get_heartbeat_interval + end + + # Set the heartbeat interval. This is how often EventMachine will check for dead connections + # that have had an inactivity timeout set via {Connection#set_comm_inactivity_timeout}. + # Takes a Numeric number of seconds. Default is 2. + # + # @param [Integer] time Heartbeat interval, in seconds + def self.heartbeat_interval=(time) + EM::set_heartbeat_interval time.to_f + end + + # @private + def self.event_callback conn_binding, opcode, data + # + # Changed 27Dec07: Eliminated the hookable error handling. + # No one was using it, and it degraded performance significantly. + # It's in original_event_callback, which is dead code. + # + # Changed 25Jul08: Added a partial solution to the problem of exceptions + # raised in user-written event-handlers. If such exceptions are not caught, + # we must cause the reactor to stop, and then re-raise the exception. + # Otherwise, the reactor doesn't stop and it's left on the call stack. + # This is partial because we only added it to #unbind, where it's critical + # (to keep unbind handlers from being re-entered when a stopping reactor + # runs down open connections). It should go on the other calls to user + # code, but the performance impact may be too large. + # + if opcode == ConnectionUnbound + if c = @conns.delete( conn_binding ) + begin + if c.original_method(:unbind).arity != 0 + c.unbind(data == 0 ? nil : EventMachine::ERRNOS[data]) + else + c.unbind + end + # If this is an attached (but not watched) connection, close the underlying io object. + if c.instance_variable_defined?(:@io) and !c.instance_variable_get(:@watch_mode) + io = c.instance_variable_get(:@io) + begin + io.close + rescue Errno::EBADF, IOError + end + end + # As noted above, unbind absolutely must not raise an exception or the reactor will crash. + # If there is no EM.error_handler, or if the error_handler retrows, then stop the reactor, + # stash the exception in $wrapped_exception, and the exception will be raised after the + # reactor is cleaned up (see the last line of self.run). + rescue Exception => error + if instance_variable_defined? :@error_handler + begin + @error_handler.call error + # No need to stop unless error_handler rethrows + rescue Exception => error + @wrapped_exception = error + stop + end + else + @wrapped_exception = error + stop + end + end + elsif c = @acceptors.delete( conn_binding ) + # no-op + else + if $! # Bubble user generated errors. + @wrapped_exception = $! + stop + else + raise ConnectionNotBound, "received ConnectionUnbound for an unknown signature: #{conn_binding}" + end + end + elsif opcode == ConnectionAccepted + accep,args,blk = @acceptors[conn_binding] + raise NoHandlerForAcceptedConnection unless accep + c = accep.new data, *args + @conns[data] = c + blk and blk.call(c) + c # (needed?) + ## + # The remaining code is a fallback for the pure ruby and java reactors. + # In the C++ reactor, these events are handled in the C event_callback() in rubymain.cpp + elsif opcode == ConnectionCompleted + c = @conns[conn_binding] or raise ConnectionNotBound, "received ConnectionCompleted for unknown signature: #{conn_binding}" + c.connection_completed + elsif opcode == SslHandshakeCompleted + c = @conns[conn_binding] or raise ConnectionNotBound, "received SslHandshakeCompleted for unknown signature: #{conn_binding}" + c.ssl_handshake_completed + elsif opcode == SslVerify + c = @conns[conn_binding] or raise ConnectionNotBound, "received SslVerify for unknown signature: #{conn_binding}" + c.close_connection if c.ssl_verify_peer(data) == false + elsif opcode == TimerFired + t = @timers.delete( data ) + return if t == false # timer cancelled + t or raise UnknownTimerFired, "timer data: #{data}" + t.call + elsif opcode == ConnectionData + c = @conns[conn_binding] or raise ConnectionNotBound, "received data #{data} for unknown signature: #{conn_binding}" + c.receive_data data + elsif opcode == LoopbreakSignalled + run_deferred_callbacks + elsif opcode == ConnectionNotifyReadable + c = @conns[conn_binding] or raise ConnectionNotBound + c.notify_readable + elsif opcode == ConnectionNotifyWritable + c = @conns[conn_binding] or raise ConnectionNotBound + c.notify_writable + end + end + + # + # + # @private + def self._open_file_for_writing filename, handler=nil + klass = klass_from_handler(Connection, handler) + + s = _write_file filename + c = klass.new s + @conns[s] = c + block_given? and yield c + c + end + + # @private + def self.klass_from_handler(klass = Connection, handler = nil, *args) + klass = if handler and handler.is_a?(Class) + raise ArgumentError, "must provide module or subclass of #{klass.name}" unless klass >= handler + handler + elsif handler + if defined?(handler::EM_CONNECTION_CLASS) + handler::EM_CONNECTION_CLASS + else + handler::const_set(:EM_CONNECTION_CLASS, Class.new(klass) {include handler}) + end + else + klass + end + + arity = klass.instance_method(:initialize).arity + expected = arity >= 0 ? arity : -(arity + 1) + if (arity >= 0 and args.size != expected) or (arity < 0 and args.size < expected) + raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size} for #{expected})" + end + + klass + end +end # module EventMachine + +# Alias for {EventMachine} +EM = EventMachine +# Alias for {EventMachine::Protocols} +EM::P = EventMachine::Protocols diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/fastfilereaderext.so b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/fastfilereaderext.so new file mode 100755 index 0000000..fe89b4c Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/fastfilereaderext.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/jeventmachine.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/jeventmachine.rb new file mode 100644 index 0000000..21a267d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/jeventmachine.rb @@ -0,0 +1,316 @@ +#-- +# +# Author:: Francis Cianfrocca (gmail: blackhedd) +# Homepage:: http://rubyeventmachine.com +# Date:: 8 Apr 2006 +# +# See EventMachine and EventMachine::Connection for documentation and +# usage examples. +# +#---------------------------------------------------------------------------- +# +# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. +# Gmail: blackhedd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: 1) the GNU General Public License +# as published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version; or 2) Ruby's License. +# +# See the file COPYING for complete licensing information. +# +#--------------------------------------------------------------------------- +# +# + +# This module provides "glue" for the Java version of the EventMachine reactor core. +# For C++ EventMachines, the analogous functionality is found in ext/rubymain.cpp, +# which is a garden-variety Ruby-extension glue module. + +require 'java' +require 'rubyeventmachine' +require 'socket' + +java_import java.io.FileDescriptor +java_import java.nio.channels.SocketChannel +java_import java.lang.reflect.Field + +module JavaFields + def set_field(key, value) + field = getClass.getDeclaredField(key) + field.setAccessible(true) + if field.getType.toString == 'int' + field.setInt(self, value) + else + field.set(self, value) + end + end + + def get_field(key) + field = getClass.getDeclaredField(key) + field.setAccessible(true) + field.get(self) + end +end + +FileDescriptor.send :include, JavaFields +SocketChannel.send :include, JavaFields + +module EventMachine + # TODO: These event numbers are defined in way too many places. + # DRY them up. + # @private + TimerFired = 100 + # @private + ConnectionData = 101 + # @private + ConnectionUnbound = 102 + # @private + ConnectionAccepted = 103 + # @private + ConnectionCompleted = 104 + # @private + LoopbreakSignalled = 105 + # @private + ConnectionNotifyReadable = 106 + # @private + ConnectionNotifyWritable = 107 + # @private + SslHandshakeCompleted = 108 + # @private + SslVerify = 109 + + # @private + EM_PROTO_SSLv2 = 2 + # @private + EM_PROTO_SSLv3 = 4 + # @private + EM_PROTO_TLSv1 = 8 + # @private + EM_PROTO_TLSv1_1 = 16 + # @private + EM_PROTO_TLSv1_2 = 32 + + # Exceptions that are defined in rubymain.cpp + class ConnectionError < RuntimeError; end + class ConnectionNotBound < RuntimeError; end + class UnknownTimerFired < RuntimeError; end + class Unsupported < RuntimeError; end + + # This thunk class used to be called EM, but that caused conflicts with + # the alias "EM" for module EventMachine. (FC, 20Jun08) + class JEM < com.rubyeventmachine.EmReactor + def eventCallback a1, a2, a3, a4 + s = String.from_java_bytes(a3.array[a3.position...a3.limit]) if a3 + EventMachine::event_callback a1, a2, s || a4 + nil + end + end + # class Connection < com.rubyeventmachine.Connection + # def associate_callback_target sig + # # No-op for the time being. + # end + # end + def self.initialize_event_machine + @em = JEM.new + end + def self.release_machine + @em = nil + end + def self.add_oneshot_timer interval + @em.installOneshotTimer interval + end + def self.run_machine + @em.run + end + def self.stop + @em.stop + end + def self.start_tcp_server server, port + @em.startTcpServer server, port + end + def self.stop_tcp_server sig + @em.stopTcpServer sig + end + def self.start_unix_server filename + # TEMPORARILY unsupported until someone figures out how to do it. + raise "unsupported on this platform" + end + def self.send_data sig, data, length + @em.sendData sig, data.to_java_bytes + rescue java.lang.NullPointerException + 0 + end + def self.send_datagram sig, data, length, address, port + @em.sendDatagram sig, data.to_java_bytes, length, address, port + end + def self.connect_server server, port + bind_connect_server nil, nil, server, port + end + def self.bind_connect_server bind_addr, bind_port, server, port + @em.connectTcpServer bind_addr, bind_port.to_i, server, port + end + def self.close_connection sig, after_writing + @em.closeConnection sig, after_writing + end + def self.set_comm_inactivity_timeout sig, interval + @em.setCommInactivityTimeout sig, interval + end + def self.set_pending_connect_timeout sig, val + end + def self.set_heartbeat_interval val + end + def self.start_tls sig + @em.startTls sig + end + def self.ssl? + false + end + def self.signal_loopbreak + @em.signalLoopbreak + end + def self.set_timer_quantum q + @em.setTimerQuantum q + end + def self.epoll + # Epoll is a no-op for Java. + # The latest Java versions run epoll when possible in NIO. + end + def self.epoll= val + end + def self.kqueue + end + def self.kqueue= val + end + def self.epoll? + false + end + def self.kqueue? + false + end + def self.set_rlimit_nofile n_descriptors + # Currently a no-op for Java. + end + def self.open_udp_socket server, port + @em.openUdpSocket server, port + end + def self.invoke_popen cmd + # TEMPORARILY unsupported until someone figures out how to do it. + raise "unsupported on this platform" + end + def self.read_keyboard + # TEMPORARILY unsupported until someone figures out how to do it. + raise "temporarily unsupported on this platform" + end + def self.set_max_timer_count num + # harmless no-op in Java. There's no built-in timer limit. + @max_timer_count = num + end + def self.get_max_timer_count + # harmless no-op in Java. There's no built-in timer limit. + @max_timer_count || 100_000 + end + def self.library_type + :java + end + def self.get_peername sig + if peer = @em.getPeerName(sig) + Socket.pack_sockaddr_in(*peer) + end + end + def self.get_sockname sig + if sockName = @em.getSockName(sig) + Socket.pack_sockaddr_in(*sockName) + end + end + # @private + def self.attach_fd fileno, watch_mode + # 3Aug09: We could pass in the actual SocketChannel, but then it would be modified (set as non-blocking), and + # we would need some logic to make sure detach_fd below didn't clobber it. For now, we just always make a new + # SocketChannel for the underlying file descriptor + # if fileno.java_kind_of? SocketChannel + # ch = fileno + # ch.configureBlocking(false) + # fileno = nil + # elsif fileno.java_kind_of? java.nio.channels.Channel + + if fileno.java_kind_of? java.nio.channels.Channel + field = fileno.getClass.getDeclaredField('fdVal') + field.setAccessible(true) + fileno = field.get(fileno) + else + raise ArgumentError, 'attach_fd requires Java Channel or POSIX fileno' unless fileno.is_a? Integer + end + + if fileno == 0 + raise "can't open STDIN as selectable in Java =(" + elsif fileno.is_a? Integer + # 8Aug09: The following code is specific to the sun jvm's SocketChannelImpl. Is there a cross-platform + # way of implementing this? If so, also remember to update EventableSocketChannel#close and #cleanup + fd = FileDescriptor.new + fd.set_field 'fd', fileno + + ch = SocketChannel.open + ch.configureBlocking(false) + ch.kill + ch.set_field 'fd', fd + ch.set_field 'fdVal', fileno + ch.set_field 'state', ch.get_field('ST_CONNECTED') + end + + @em.attachChannel(ch,watch_mode) + end + def self.detach_fd sig + if ch = @em.detachChannel(sig) + ch.get_field 'fdVal' + end + end + + def self.set_notify_readable sig, mode + @em.setNotifyReadable(sig, mode) + end + def self.set_notify_writable sig, mode + @em.setNotifyWritable(sig, mode) + end + + def self.is_notify_readable sig + @em.isNotifyReadable(sig) + end + def self.is_notify_writable sig + @em.isNotifyWritable(sig) + end + def self.get_connection_count + @em.getConnectionCount + end + + def self.pause_connection(sig) + @em.pauseConnection(sig) + end + def self.resume_connection(sig) + @em.resumeConnection(sig) + end + def self.connection_paused?(sig) + @em.isConnectionPaused(sig) + end + def self._get_outbound_data_size(sig) + @em.getOutboundDataSize(sig) + end + + + def self.set_tls_parms(sig, params) + end + def self.start_tls(sig) + end + def self.send_file_data(sig, filename) + end + + class Connection + def associate_callback_target sig + # No-op for the time being + end + def get_outbound_data_size + EM._get_outbound_data_size @signature + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.so b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.so new file mode 100755 index 0000000..1aced66 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/package.rake b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/package.rake new file mode 100644 index 0000000..00419d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/package.rake @@ -0,0 +1,120 @@ +require 'rubygems' +require 'rubygems/package_task' + +begin + require 'rake/extensiontask' + require 'rake/javaextensiontask' +rescue LoadError => e + puts <<-MSG +rake-compiler gem seems to be missing. Please install it with + + gem install rake-compiler + +(add sudo if necessary). + MSG +end + +Gem::PackageTask.new(GEMSPEC) do |pkg| +end + +if RUBY_PLATFORM =~ /java/ + Rake::JavaExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext| + ext.ext_dir = 'java/src' + end +else + def setup_cross_compilation(ext) + unless RUBY_PLATFORM =~ /mswin|mingw/ + ext.cross_compile = true + ext.cross_platform = ['x86-mingw32', 'x64-mingw32'] + end + end + def hack_cross_compilation(ext) + # inject 1.8/1.9 pure-ruby entry point + # HACK: add these dependencies to the task instead of using cross_compiling + if ext.cross_platform.is_a?(Array) + ext.cross_platform.each do |platform| + task = "native:#{GEMSPEC.name}:#{platform}" + if Rake::Task.task_defined?(task) + Rake::Task[task].prerequisites.unshift "lib/#{ext.name}.rb" + end + end + end + end + + em = Rake::ExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext| + ext.ext_dir = 'ext' + ext.source_pattern = '*.{h,c,cpp}' + setup_cross_compilation(ext) + end + hack_cross_compilation em + + ff = Rake::ExtensionTask.new("fastfilereaderext", GEMSPEC) do |ext| + ext.ext_dir = 'ext/fastfilereader' + ext.source_pattern = '*.{h,c,cpp}' + setup_cross_compilation(ext) + end + hack_cross_compilation ff +end + +# Setup shim files that require 1.8 vs 1.9 extensions in win32 bin gems +%w[ rubyeventmachine fastfilereaderext ].each do |filename| + file("lib/#{filename}.rb") do |t| + File.open(t.name, 'wb') do |f| + f.write <<-eoruby + RUBY_VERSION =~ /(\\d+.\\d+)/ + require "\#{$1}/#{File.basename(t.name, '.rb')}" + eoruby + end + at_exit{ FileUtils.rm t.name if File.exist?(t.name) } + end +end + +task :cross_cxx do + ENV['CROSS_COMPILING'] = 'yes' + require 'rake/extensioncompiler' + ENV['CXX'] = "#{Rake::ExtensionCompiler.mingw_host}-g++" +end + +if Rake::Task.task_defined?(:cross) + task :cross => 'lib/rubyeventmachine.rb' + task :cross => 'lib/fastfilereaderext.rb' + task :cross => :cross_cxx +end + +def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end +def sudo(cmd) + if windows? || (require 'etc'; Etc.getpwuid.uid == 0) + sh cmd + else + sh "sudo #{cmd}" + end +end +def gem_cmd(action, name, *args) + rb = Gem.ruby rescue nil + rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])) + sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'" +end + +Rake::Task[:clean].enhance [:clobber_package] + +# DevKit task following the example of Luis Lavena's test-ruby-c-extension +task :devkit do + begin + require "devkit" + rescue LoadError => e + abort "Failed to activate RubyInstaller's DevKit required for compilation." + end +end + +if RUBY_PLATFORM =~ /mingw|mswin/ + Rake::Task['compile'].prerequisites.unshift 'devkit' +end + +desc "Build binary gems for Windows with rake-compiler-dock" +task 'gem:windows' do + require 'rake_compiler_dock' + RakeCompilerDock.sh <<-EOT + RUBY_CC_VERSION="${RUBY_CC_VERSION//1.8.7/}" + bundle && rake cross native gem + EOT +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/test.rake b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/test.rake new file mode 100644 index 0000000..1185ac7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/test.rake @@ -0,0 +1,8 @@ +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << "tests" + t.libs << "lib" + t.pattern = 'tests/**/test_*.rb' + t.warning = true +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/test_pure.rake b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/test_pure.rake new file mode 100644 index 0000000..5a84ded --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/rakelib/test_pure.rake @@ -0,0 +1,13 @@ +require 'rake/testtask' + +Rake::TestTask.new(:test_pure) do |t| + t.libs << 'tests' + t.libs << 'lib' + t.test_files = Dir.glob('tests/**/test_pure*.rb') + Dir.glob('tests/**/test_ssl*.rb') + t.warning = true +end + +task :test_em_pure_ruby do + ENV['EM_PURE_RUBY'] = 'true' + Rake::Task['test_pure'].execute +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/client.crt b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/client.crt new file mode 100644 index 0000000..1919d97 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/client.crt @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFRDCCAywCAQEwDQYJKoZIhvcNAQEFBQAwaDELMAkGA1UEBhMCRU0xFTATBgNV +BAgTDEV2ZW50TWFjaGluZTEVMBMGA1UEChMMRXZlbnRNYWNoaW5lMRQwEgYDVQQL +EwtEZXZlbG9wbWVudDEVMBMGA1UEAxMMRXZlbnRNYWNoaW5lMB4XDTA5MDMyOTAy +MzE0NloXDTEwMDMyOTAyMzE0NlowaDELMAkGA1UEBhMCRU0xFTATBgNVBAgTDEV2 +ZW50TWFjaGluZTEVMBMGA1UEChMMRXZlbnRNYWNoaW5lMRQwEgYDVQQLEwtEZXZl +bG9wbWVudDEVMBMGA1UEAxMMRXZlbnRNYWNoaW5lMIICIjANBgkqhkiG9w0BAQEF +AAOCAg8AMIICCgKCAgEAv1FSOIX1z7CQtVBFlrB0A3/V29T+22STKKmiRWYkKL5b ++hkrp9IZ5J4phZHgUVM2VDPOO2Oc2PU6dlGGZISg+UPERunTogxQKezCV0vcE9cK +OwzxCFDRvv5rK8aKMscfBLbNKocAXywuRRQmdxPiVRzbyPrl+qCr/EDLXAX3D77l +S8n2AwDg19VyI+IgFUE+Dy5e1eLoY6nV+Mq+vNXdn3ttF3t+ngac5pj5Q9h+pD5p +67baDHSnf/7cy2fa/LKrLolVHQR9G2K6cEfeM99NtcsMbkoPs4iI3FA05OVTQHXg +C8C8cRxrb9APl95I/ep65OIaCJgcdYxJ3QD3qOtQo6/NQsGnjbyiUxaEpjfqyT1N +uzWD81Q8uXGNS8yD6dDynt/lseBjyp2nfC3uQ5fY18VdIcu0MJ9pezBUKrNuhlsy +XXEZ2DXj4sY8QOvIcBqSB/zmS1nGEK55xrtkaiaNrY8fe8wRVpcPLxy+P225NFw+ +B69FJRA0Lj6Jt9BM4hV/3MSIEWwTVhuw4E02ywDYTzz1wq3ITf0tsbIPn0hXQMxD +ohhAoKioM6u+yHtqsxD0eYaAWmHTVn5oDvOSGpvCpBfWHyA7FP5UQak0fKABEAgK +iQYEnb294AXwXymJttfGTIV/Ne4tLN5dIpNma8UO8rlThlcr6xnTQDbR3gkTDRsC +AwEAATANBgkqhkiG9w0BAQUFAAOCAgEAj7J8fy1LUWoVWnrXDAC9jwJ1nI/YjoSU +6ywke3o04+nZC5S+dPnuVy+HAwsU940CoNvP6RStI/bH6JL+NIqEFmwM3M8xIEWV +MYVPkfvQUxxGvDnaY7vv93u+6Q77HV3qlhAQBHChyuXyO7TG3+WzsiT9AnBNtAP0 +4jClt5kCAQXLO/p0SFEZQ8Ru9SM8d1i73Z0VDVzs8jYWlBhiherSgbw1xK4wBOpJ +43XmjZsBSrDpiAXd07Ak3UL2GjfT7eStgebL3UIe39ThE/s/+l43bh0M6WbOBvyQ +i/rZ50kd1GvN0xnZhtv07hIJWO85FGWi7Oet8AzdUZJ17v1Md/f2vdhPVTFN9q+w +mQ6LxjackqCvaJaQfBEbqsn2Tklxk4tZuDioiQbOElT2e6vljQVJWIfNx38Ny2LM +aiXQPQu+4CI7meAh5gXM5nyJGbZvRPsxj89CqYzyHCYs5HBP3AsviBvn26ziOF+c +544VmHd9HkIv8UTC29hh+R64RlgMQQQdaXFaUrFPTs/do0k8n/c2bPc0iTdfi5Q2 +gq6Vi8q6Ay5wGgTtRRbn/mWKuCFjEh94z6pF9Xr06NX0PuEOdf+Ls9vI5vz6G0w6 +0Li7devEN7EKBY+7Mcjg918yq9i5tEiMkUgT68788t3fTC+4iUQ5fDtdrHsaOlIR +8bs/XQVNE/s= +-----END CERTIFICATE----- diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/client.key b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/client.key new file mode 100644 index 0000000..87a2531 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/client.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAv1FSOIX1z7CQtVBFlrB0A3/V29T+22STKKmiRWYkKL5b+hkr +p9IZ5J4phZHgUVM2VDPOO2Oc2PU6dlGGZISg+UPERunTogxQKezCV0vcE9cKOwzx +CFDRvv5rK8aKMscfBLbNKocAXywuRRQmdxPiVRzbyPrl+qCr/EDLXAX3D77lS8n2 +AwDg19VyI+IgFUE+Dy5e1eLoY6nV+Mq+vNXdn3ttF3t+ngac5pj5Q9h+pD5p67ba +DHSnf/7cy2fa/LKrLolVHQR9G2K6cEfeM99NtcsMbkoPs4iI3FA05OVTQHXgC8C8 +cRxrb9APl95I/ep65OIaCJgcdYxJ3QD3qOtQo6/NQsGnjbyiUxaEpjfqyT1NuzWD +81Q8uXGNS8yD6dDynt/lseBjyp2nfC3uQ5fY18VdIcu0MJ9pezBUKrNuhlsyXXEZ +2DXj4sY8QOvIcBqSB/zmS1nGEK55xrtkaiaNrY8fe8wRVpcPLxy+P225NFw+B69F +JRA0Lj6Jt9BM4hV/3MSIEWwTVhuw4E02ywDYTzz1wq3ITf0tsbIPn0hXQMxDohhA +oKioM6u+yHtqsxD0eYaAWmHTVn5oDvOSGpvCpBfWHyA7FP5UQak0fKABEAgKiQYE +nb294AXwXymJttfGTIV/Ne4tLN5dIpNma8UO8rlThlcr6xnTQDbR3gkTDRsCAwEA +AQKCAgB495RDRQB9x6hX3F+DviI8rDGug+h5FAiwJ0IBG2o1kNdbNVsTC5dvpEmg +uPHaugCaEP+PMZbU34mNklKlb+7QbPbH18UGqz5so9TlmYOXz9oaKD6nAWL9nqRo +02pCXQDR3DuxbhbgFnFTIECJ/jqXkl2toGaVp83W+6kZkHP8srkMyLASihWgosc+ +xRWAGvaAZtNz7br+eT5fxuH/SEKPOl1qAZ23kXrXm1XQfizk8MnMTptkUMYv+hfl +TM98BASUsiTs6g+opy43HFn09naOQcqkWZO/8s6Gbvhi2lVfZqi5Ba6g3lVYJ3gU +kGoako4N9qB7WqJz+LYjVR9C4TbkkJ9OD6ArwGAx5IIzC3XKSxCyY/pUn4YumPhY +fjvY/km54TBtx/isS1TAgjSgDUxbzrfbkh7afOXSOniy9bWJMgNqHF61dqxWxmUg +F5Tch9zH3qFFVkXpYzDU/R8ZV+CRouCvhn0eZYDh8IqIAwjH0VjkxjPyQtrdrMd3 +gDKMVKoY31EOMLZzv8a0prjpr15A+uw30tT336qb3fofks4pZKUJw8ru9jJVir2p ++RML6iUHCmIeceF7/N1meooSMLPJe0xgKeMb9M4Wtd/et2UNVtP8nCDG622rf2a0 +F/EudXuFgc3FB8nXRw9TCkw9xKQff38edG5xPFUEgqObbVl5YQKCAQEA5DDKGOmp +EO5Zuf/kZfG6/AMMYwAuv1HrYTV2w/HnI3tyQ34Xkeqo+I/OqmRk68Ztxw4Kx1So +SRavkotrlWhhDpl2+Yn1BjkHktSoOdf9gJ9z9llkLmbOkBjmupig1NUB7fq/4y2k +MdqJXDy3uVKHJ97gxdIheMTyHiKuMJPnuT5lZtlT210Ig82P7sLQb/sgCfKVFTr0 +Z3haQ5/tBNKjq+igT4nMBWupOTD1q2GeZLIZACnmnUIhvu+3/bm0l+wiCB0DqF0T +Wy9tlL3fqQSCqzevL7/k5Lg6tJTaP/XYePB73TsOtAXgIaoltXgRBsBUeE1eaODx +kMT6E1PPtn7EqQKCAQEA1qImmTWGqhKICrwje40awPufFtZ/qXKVCN/V+zYsrJV1 +EnZpUDM+zfitlQCugnrQVHSpgfekI6mmVkmogO3fkNjUFTq+neg7IHOUHnqotx+3 +NMqIsyFInGstu9mfPd26fzZjUtx5wKF38LDTIJJAEJ83U3UpPBfpwKmiOGDXOa54 +2i4em/bb/hrQR6JySruZYLi0fXnGI5ZOfpkHgC/KOFkKNKAg2oh4B9qo7ACyiSNk +yojb2mmn6g1OLPxi7wGUSrkS1HQq4an6RZ+eUO0HXVWag0QStdQ91M9IrIHgSBBG +0e86Ar6jtD579gqsbz4ySpI/FqEI9obTC+E1/b0aIwKCAQAGz334qGCnZLXA22ZR +tJlEFEM2YTcD9snzqMjWqE2hvXl3kjfZ3wsUABbG9yAb+VwlaMHhmSE8rTSoRwj6 ++JaM/P+UCw4JFYKoWzh6IXwrbpbjb1+SEvdvTY71WsDSGVlpZOZ9PUt9QWyAGD/T +hCcMhZZn0RG2rQoc5CQWxxNPcBFOtIXQMkKizGvTUHUwImqeYWMZsxzASdNH2WoV +jsPbyaGfPhmcv83ZKyDp8IvtrXMZkiaT4vlm3Xi8VeKR9jY9z7/gMob1XcEDg3c9 +cCkGOy87WZrXSLhX02mAJzJCycqom66gqNw7pPxjIiY/8VWUEZsTvkL3cymTkhjM +9ZOhAoIBAGUaNqJe01NTrV+ZJgGyAxM6s8LXQYV5IvjuL2bJKxwUvvP2cT9FFGWD +qYiRrKJr5ayS07IUC+58oIzu33/0DSa27JgfduD9HrT3nKMK1mSEfRFSAjiXChQc +bIubRGapBoub/AdxMazqoovvT1R9b84kobQfcVAMV6DYh0CVZWyXYfgsV2DSVOiK +iufjfoDzg5lLCEI+1XW3/LunrB/W4yPN1X/amf8234ublYyt+2ucD4NUGnP05xLa +N6P7M0MwdEEKkvMe0YBBSFH5kWK/dIOjqkgBDes20fVnuuz/tL1dZW7IiIP4dzaV +ZGEOwBEatCfqYetv6b/u3IUxDfS7Wg8CggEBALoOwkn5LGdQg+bpdZAKJspGnJWL +Kyr9Al2tvgc69rxfpZqS5eDLkYYCzWPpspSt0Axm1O7xOUDQDt42luaLNGJzHZ2Q +Hn0ZNMhyHpe8d8mIQngRjD+nuLI/uFUglPzabDOCOln2aycjg1mA6ecXP1XMEVbu +0RB/0IE36XTMfZ+u9+TRjkBLpmUaX1FdIQQWfwUou/LfaXotoQlhSGAcprLrncuJ +T44UATYEgO/q9pMM33bdE3eBYZHoT9mSvqoLCN4s0LuwOYItIxLKUj0GulL0VQOI +SZi+0A1c8cVDXgApkBrWPDQIR9JS4de0gW4hnDoUvHtUc2TYPRnz6N9MtFY= +-----END RSA PRIVATE KEY----- diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/dhparam.pem b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/dhparam.pem new file mode 100644 index 0000000..b6464ab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/dhparam.pem @@ -0,0 +1,13 @@ +-----BEGIN DH PARAMETERS----- +MIICCAKCAgEAikiatXa5aAteOtd6hOO33npjCvJByD3dwuM8rWzz0DFZdUH9nFJi +b0VvTVweVECb6XZBsrDNLqGQykCrm43swSk5D9XQCGJLxFERD6yk3b90xaeCm3/a +b0Ek5ZVvV73Cc/YbVmpBiOHoTFpUFJLZ7pLMQUSn8y3qUlNcY9/88HuwFi1s1lRM +ovihSRyZMYAuYWOD4yuOuIcroKVjD6gWFrsW9XrALWny6vUXQrhk8Q3rj+wM6ZtE +5afcB0b6ZJtphrDfk3dFjOVG/zVT37VWgrY8GABrpo2ey0W0WIQJ7rDKLaPaI4kc +voOgC2K8Z3kSARZK+jULnwmBeYECz4EH/FF6FEp3GOKtkL4mqEkvh1n5EAesDOGl +iiX+RZXcUrZliSeifSXBTMJWWFVC0fkGIMb9PTZfZHyAC54lpuxzVki0HIyQG9Fs +41zBJ5e8eEoXXlfUYtduUC35YGy2IxSzYLAJE76rctAZSWghha9xLOCDFoLjMr8h +FosKeHKJcBQ0bc8ymOpRIfrYLWhc0Pz2zkpJ/4eYw9t7NYg7S+jP19IE0gUnuM9v +SpoYMtS28tP9nEdokdwuBKD0D3bJEBBefDlHgfXoMgvy9Hivc9PBGGNTNpyFPpwF +sWVAkfhoNMJMC5V7LZsze+lftiDtzVoLSPDa9bO4BK7b/MgwCxfOhGsCAQI= +-----END DH PARAMETERS----- diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/em_test_helper.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/em_test_helper.rb new file mode 100644 index 0000000..20a3e59 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/em_test_helper.rb @@ -0,0 +1,154 @@ +require 'em/pure_ruby' if ENV['EM_PURE_RUBY'] +require 'eventmachine' +require 'test/unit' +require 'rbconfig' +require 'socket' + +puts "EM Library Type: #{EM.library_type}" + +class Test::Unit::TestCase + class EMTestTimeout < StandardError ; end + + def setup_timeout(timeout = TIMEOUT_INTERVAL) + EM.schedule { + EM.add_timer(timeout) { + raise EMTestTimeout, "Test was cancelled after #{timeout} seconds." + } + } + end + + def port_in_use?(port, host="127.0.0.1") + s = TCPSocket.new(host, port) + s.close + s + rescue Errno::ECONNREFUSED + false + end + + def next_port + @@port ||= 9000 + begin + @@port += 1 + end while port_in_use?(@@port) + + @@port + end + + # Returns true if the host have a localhost 127.0.0.1 IPv4. + def self.local_ipv4? + return @@has_local_ipv4 if defined?(@@has_local_ipv4) + begin + get_my_ipv4_address "127.0.0.1" + @@has_local_ipv4 = true + rescue + @@has_local_ipv4 = false + end + end + + # Returns true if the host have a public IPv4 and stores it in + # @@public_ipv4. + def self.public_ipv4? + return @@has_public_ipv4 if defined?(@@has_public_ipv4) + begin + @@public_ipv4 = get_my_ipv4_address "1.2.3.4" + @@has_public_ipv4 = true + rescue + @@has_public_ipv4 = false + end + end + + # Returns true if the host have a localhost ::1 IPv6. + def self.local_ipv6? + return @@has_local_ipv6 if defined?(@@has_local_ipv6) + begin + get_my_ipv6_address "::1" + @@has_local_ipv6 = true + rescue + @@has_local_ipv6 = false + end + end + + # Returns true if the host have a public IPv6 and stores it in + # @@public_ipv6. + def self.public_ipv6? + return @@has_public_ipv6 if defined?(@@has_public_ipv6) + begin + @@public_ipv6 = get_my_ipv6_address "2001::1" + @@has_public_ipv6 = true + rescue + @@has_public_ipv6 = false + end + end + + # Returns an array with the localhost addresses (IPv4 and/or IPv6). + def local_ips + return @@local_ips if defined?(@@local_ips) + @@local_ips = [] + @@local_ips << "127.0.0.1" if self.class.local_ipv4? + @@local_ips << "::1" if self.class.local_ipv6? + @@local_ips + end + + def exception_class + jruby? ? NativeException : RuntimeError + end + + module PlatformHelper + # http://blog.emptyway.com/2009/11/03/proper-way-to-detect-windows-platform-in-ruby/ + def windows? + RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ + end + + def solaris? + RUBY_PLATFORM =~ /solaris/ + end + + # http://stackoverflow.com/questions/1342535/how-can-i-tell-if-im-running-from-jruby-vs-ruby/1685970#1685970 + def jruby? + defined? JRUBY_VERSION + end + + def rbx? + defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' + end + end + + include PlatformHelper + extend PlatformHelper + + # Tests run significantly slower on windows. YMMV + TIMEOUT_INTERVAL = windows? ? 1 : 0.25 + + def silent + backup, $VERBOSE = $VERBOSE, nil + begin + yield + ensure + $VERBOSE = backup + end + end + + + private + + def self.get_my_ipv4_address ip + orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily + UDPSocket.open(Socket::AF_INET) do |s| + s.connect ip, 1 + s.addr.last + end + ensure + Socket.do_not_reverse_lookup = orig + end + + def self.get_my_ipv6_address ip + orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily + UDPSocket.open(Socket::AF_INET6) do |s| + s.connect ip, 1 + s.addr.last + end + ensure + Socket.do_not_reverse_lookup = orig + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_attach.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_attach.rb new file mode 100644 index 0000000..4a55017 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_attach.rb @@ -0,0 +1,151 @@ +require 'em_test_helper' +require 'socket' + +class TestAttach < Test::Unit::TestCase + class EchoServer < EM::Connection + def receive_data data + $received_data << data + send_data data + end + end + + class EchoClient < EM::Connection + def initialize socket + self.notify_readable = true + @socket = socket + @socket.write("abc\n") + end + + def notify_readable + $read = @socket.readline + $fd = detach + end + + def unbind + EM.next_tick do + @socket.write("def\n") + EM.add_timer(0.1) { EM.stop } + end + end + end + + def setup + @port = next_port + $read, $r, $w, $fd = nil + $received_data = "" + end + + def teardown + [$r, $w].each do |io| + io.close rescue nil + end + $received_data = nil + end + + def test_attach + socket = nil + + EM.run { + EM.start_server "127.0.0.1", @port, EchoServer + socket = TCPSocket.new "127.0.0.1", @port + EM.watch socket, EchoClient, socket + } + + assert_equal $read, "abc\n" + unless jruby? # jruby filenos are not real + assert_equal $fd, socket.fileno + end + assert_equal false, socket.closed? + assert_equal socket.readline, "def\n" + end + + module PipeWatch + def notify_readable + $read = $r.readline + EM.stop + end + end + + def test_attach_server + omit_if(jruby?) + $before = TCPServer.new("127.0.0.1", @port) + sig = nil + EM.run { + sig = EM.attach_server $before, EchoServer + + handler = Class.new(EM::Connection) do + def initialize + send_data "hello world" + close_connection_after_writing + EM.add_timer(0.1) { EM.stop } + end + end + EM.connect("127.0.0.1", @port, handler) + } + + assert_equal false, $before.closed? + assert_equal "hello world", $received_data + assert sig.is_a?(Integer) + end + + def test_attach_pipe + EM.run{ + $r, $w = IO.pipe + EM.watch $r, PipeWatch do |c| + c.notify_readable = true + end + $w.write("ghi\n") + } + + assert_equal $read, "ghi\n" + end + + def test_set_readable + before, after = nil + + EM.run{ + $r, $w = IO.pipe + c = EM.watch $r, PipeWatch do |con| + con.notify_readable = false + end + + EM.next_tick{ + before = c.notify_readable? + c.notify_readable = true + after = c.notify_readable? + } + + $w.write("jkl\n") + } + + assert !before + assert after + assert_equal $read, "jkl\n" + end + + def test_read_write_pipe + result = nil + + pipe_reader = Module.new do + define_method :receive_data do |data| + result = data + EM.stop + end + end + + r,w = IO.pipe + + EM.run { + EM.attach r, pipe_reader + writer = EM.attach(w) + writer.send_data 'ghi' + + # XXX: Process will hang in Windows without this line + writer.close_connection_after_writing + } + + assert_equal "ghi", result + ensure + [r,w].each {|io| io.close rescue nil } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_basic.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_basic.rb new file mode 100644 index 0000000..4d72524 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_basic.rb @@ -0,0 +1,321 @@ +require 'em_test_helper' +require 'socket' + +class TestBasic < Test::Unit::TestCase + def setup + @port = next_port + end + + def test_connection_class_cache + mod = Module.new + a, b = nil, nil + EM.run { + EM.start_server '127.0.0.1', @port, mod + a = EM.connect '127.0.0.1', @port, mod + b = EM.connect '127.0.0.1', @port, mod + EM.stop + } + assert_equal a.class, b.class + assert_kind_of EM::Connection, a + end + + #------------------------------------- + + + def test_em + assert_nothing_raised do + EM.run { + setup_timeout + EM.add_timer 0 do + EM.stop + end + } + end + end + + #------------------------------------- + + def test_timer + assert_nothing_raised do + EM.run { + setup_timeout + n = 0 + EM.add_periodic_timer(0.1) { + n += 1 + EM.stop if n == 2 + } + } + end + end + + #------------------------------------- + + # This test once threw an already-running exception. + module Trivial + def post_init + EM.stop + end + end + + def test_server + assert_nothing_raised do + EM.run { + setup_timeout + EM.start_server "127.0.0.1", @port, Trivial + EM.connect "127.0.0.1", @port + } + end + end + + #-------------------------------------- + + # EM#run_block starts the reactor loop, runs the supplied block, and then STOPS + # the loop automatically. Contrast with EM#run, which keeps running the reactor + # even after the supplied block completes. + def test_run_block + assert !EM.reactor_running? + a = nil + EM.run_block { a = "Worked" } + assert a + assert !EM.reactor_running? + end + + class UnbindError < EM::Connection + ERR = Class.new(StandardError) + def initialize *args + super + end + def connection_completed + close_connection_after_writing + end + def unbind + raise ERR + end + end + + def test_unbind_error_during_stop + assert_raises( UnbindError::ERR ) { + EM.run { + EM.start_server "127.0.0.1", @port + EM.connect "127.0.0.1", @port, UnbindError do + EM.stop + end + } + } + end + + def test_unbind_error + EM.run { + EM.error_handler do |e| + assert(e.is_a?(UnbindError::ERR)) + EM.stop + end + EM.start_server "127.0.0.1", @port + EM.connect "127.0.0.1", @port, UnbindError + } + + # Remove the error handler before the next test + EM.error_handler(nil) + end + + module BrsTestSrv + def receive_data data + $received << data + end + def unbind + EM.stop + end + end + module BrsTestCli + def post_init + send_data $sent + close_connection_after_writing + end + end + + # From ticket #50 + def test_byte_range_send + $received = '' + $sent = (0..255).to_a.pack('C*') + EM::run { + EM::start_server "127.0.0.1", @port, BrsTestSrv + EM::connect "127.0.0.1", @port, BrsTestCli + + setup_timeout + } + assert_equal($sent, $received) + end + + def test_bind_connect + pend('FIXME: this test is broken on Windows') if windows? + + local_ip = UDPSocket.open {|s| s.connect('localhost', 80); s.addr.last } + + bind_port = next_port + + port, ip = nil + bound_server = Module.new do + define_method :post_init do + begin + port, ip = Socket.unpack_sockaddr_in(get_peername) + ensure + EM.stop + end + end + end + + EM.run do + setup_timeout + EM.start_server "127.0.0.1", @port, bound_server + EM.bind_connect local_ip, bind_port, "127.0.0.1", @port + end + + assert_equal bind_port, port + assert_equal local_ip, ip + end + + def test_invalid_address_bind_connect_dst + e = nil + EM.run do + begin + EM.bind_connect('localhost', nil, 'invalid.invalid', 80) + rescue Exception => e + # capture the exception + ensure + EM.stop + end + end + + assert_kind_of(EventMachine::ConnectionError, e) + assert_match(/unable to resolve address:.*not known/, e.message) + end + + def test_invalid_address_bind_connect_src + e = nil + EM.run do + begin + EM.bind_connect('invalid.invalid', nil, 'localhost', 80) + rescue Exception => e + # capture the exception + ensure + EM.stop + end + end + + assert_kind_of(EventMachine::ConnectionError, e) + assert_match(/invalid bind address:.*not known/, e.message) + end + + def test_reactor_thread? + assert !EM.reactor_thread? + EM.run { assert EM.reactor_thread?; EM.stop } + assert !EM.reactor_thread? + end + + def test_schedule_on_reactor_thread + x = false + EM.run do + EM.schedule { x = true } + EM.stop + end + assert x + end + + def test_schedule_from_thread + x = false + EM.run do + Thread.new { EM.schedule { x = true; EM.stop } }.join + end + assert x + end + + def test_set_heartbeat_interval + omit_if(jruby?) + interval = 0.5 + EM.run { + EM.set_heartbeat_interval interval + $interval = EM.get_heartbeat_interval + EM.stop + } + assert_equal(interval, $interval) + end + + module PostInitRaiser + ERR = Class.new(StandardError) + def post_init + raise ERR + end + end + + def test_bubble_errors_from_post_init + assert_raises(PostInitRaiser::ERR) do + EM.run do + EM.start_server "127.0.0.1", @port + EM.connect "127.0.0.1", @port, PostInitRaiser + end + end + end + + module InitializeRaiser + ERR = Class.new(StandardError) + def initialize + raise ERR + end + end + + def test_bubble_errors_from_initialize + assert_raises(InitializeRaiser::ERR) do + EM.run do + EM.start_server "127.0.0.1", @port + EM.connect "127.0.0.1", @port, InitializeRaiser + end + end + end + + def test_schedule_close + omit_if(jruby?) + localhost, port = '127.0.0.1', 9000 + timer_ran = false + num_close_scheduled = nil + EM.run do + assert_equal 0, EM.num_close_scheduled + EM.add_timer(1) { timer_ran = true; EM.stop } + EM.start_server localhost, port do |s| + s.close_connection + num_close_scheduled = EM.num_close_scheduled + end + EM.connect localhost, port do |c| + def c.unbind + EM.stop + end + end + end + assert !timer_ran + assert_equal 1, num_close_scheduled + end + + def test_error_handler_idempotent # issue 185 + errors = [] + ticks = [] + EM.error_handler do |e| + errors << e + end + + EM.run do + EM.next_tick do + ticks << :first + raise + end + EM.next_tick do + ticks << :second + end + EM.add_timer(0.001) { EM.stop } + end + + # Remove the error handler before the next test + EM.error_handler(nil) + + assert_equal 1, errors.size + assert_equal [:first, :second], ticks + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_channel.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_channel.rb new file mode 100644 index 0000000..c54bf1d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_channel.rb @@ -0,0 +1,75 @@ +require 'em_test_helper' + +class TestEMChannel < Test::Unit::TestCase + def test_channel_subscribe + s = 0 + EM.run do + c = EM::Channel.new + c.subscribe { |v| s = v; EM.stop } + c << 1 + end + assert_equal 1, s + end + + def test_channel_unsubscribe + s = 0 + EM.run do + c = EM::Channel.new + subscription = c.subscribe { |v| s = v } + c.unsubscribe(subscription) + c << 1 + EM.next_tick { EM.stop } + end + assert_not_equal 1, s + end + + def test_channel_pop + s = 0 + EM.run do + c = EM::Channel.new + c.pop{ |v| s = v } + c.push(1,2,3) + c << 4 + c << 5 + EM.next_tick { EM.stop } + end + assert_equal 1, s + end + + def test_channel_reactor_thread_push + out = [] + c = EM::Channel.new + c.subscribe { |v| out << v } + Thread.new { c.push(1,2,3) }.join + assert out.empty? + + EM.run { EM.next_tick { EM.stop } } + + assert_equal [1,2,3], out + end + + def test_channel_reactor_thread_callback + out = [] + c = EM::Channel.new + Thread.new { c.subscribe { |v| out << v } }.join + c.push(1,2,3) + assert out.empty? + + EM.run { EM.next_tick { EM.stop } } + + assert_equal [1,2,3], out + end + + def test_channel_num_subscribers + subs = 0 + EM.run do + c = EM::Channel.new + c.subscribe { |v| s = v } + c.subscribe { |v| s = v } + EM.next_tick { EM.stop } + subs = c.num_subscribers + end + + assert_equal subs, 2 + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_completion.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_completion.rb new file mode 100644 index 0000000..1bd9a8f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_completion.rb @@ -0,0 +1,178 @@ +require 'em_test_helper' +require 'em/completion' + +class TestCompletion < Test::Unit::TestCase + def completion + @completion ||= EM::Completion.new + end + + def crank + # This is a slow solution, but this just executes the next tick queue + # once. It's the easiest way for now. + EM.run { EM.stop } + end + + def results + @results ||= [] + end + + def test_state + assert_equal :unknown, completion.state + end + + def test_succeed + completion.callback { |val| results << val } + completion.succeed :object + crank + assert_equal :succeeded, completion.state + assert_equal [:object], results + end + + def test_fail + completion.errback { |val| results << val } + completion.fail :object + crank + assert_equal :failed, completion.state + assert_equal [:object], results + end + + def test_callback + completion.callback { results << :callback } + completion.errback { results << :errback } + completion.succeed + crank + assert_equal [:callback], results + end + + def test_errback + completion.callback { results << :callback } + completion.errback { results << :errback } + completion.fail + crank + assert_equal [:errback], results + end + + def test_stateback + completion.stateback(:magic) { results << :stateback } + completion.change_state(:magic) + crank + assert_equal [:stateback], results + end + + def test_does_not_enqueue_when_completed + completion.callback { results << :callback } + completion.succeed + completion.errback { results << :errback } + completion.fail + crank + assert_equal [:callback], results + end + + def test_completed + assert_equal false, completion.completed? + completion.succeed + assert_equal true, completion.completed? + completion.fail + assert_equal true, completion.completed? + completion.change_state :magic + assert_equal false, completion.completed? + end + + def test_recursive_callbacks + completion.callback do |val| + results << val + completion.succeed :two + end + completion.callback do |val| + results << val + completion.succeed :three + end + completion.callback do |val| + results << val + end + completion.succeed :one + crank + assert_equal [:one, :two, :three], results + end + + def test_late_defined_callbacks + completion.callback { results << :one } + completion.succeed + crank + assert_equal [:one], results + completion.callback { results << :two } + crank + assert_equal [:one, :two], results + end + + def test_cleared_completions + completion.callback { results << :callback } + completion.errback { results << :errback } + + completion.succeed + crank + completion.fail + crank + completion.succeed + crank + + assert_equal [:callback], results + end + + def test_skip_completed_callbacks + completion.callback { results << :callback } + completion.succeed + crank + + completion.errback { results << :errback } + completion.fail + crank + + assert_equal [:callback], results + end + + def test_completions + completion.completion { results << :completion } + completion.succeed + crank + assert_equal [:completion], results + + completion.change_state(:unknown) + results.clear + + completion.completion { results << :completion } + completion.fail + crank + assert_equal [:completion], results + end + + def test_latent_completion + completion.completion { results << :completion } + completion.succeed + crank + completion.completion { results << :completion } + crank + assert_equal [:completion, :completion], results + end + + def test_timeout + args = [1, 2, 3] + EM.run do + completion.timeout(0.0001, *args) + completion.errback { |*errargs| results << errargs } + completion.completion { EM.stop } + EM.add_timer(0.1) { flunk 'test timed out' } + end + assert_equal [[1,2,3]], results + end + + def test_timeout_gets_cancelled + EM.run do + completion.timeout(0.0001, :timeout) + completion.errback { results << :errback } + completion.succeed + EM.add_timer(0.0002) { EM.stop } + end + assert_equal [], results + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_connection_count.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_connection_count.rb new file mode 100644 index 0000000..350c417 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_connection_count.rb @@ -0,0 +1,83 @@ +require 'em_test_helper' + +class TestConnectionCount < Test::Unit::TestCase + def teardown + EM.epoll = false + EM.kqueue = false + end + + def test_idle_connection_count + count = nil + EM.run { + count = EM.connection_count + EM.stop_event_loop + } + assert_equal(0, count) + end + + # Run this again with epoll enabled (if available) + def test_idle_connection_count_epoll + EM.epoll if EM.epoll? + + count = nil + EM.run { + count = EM.connection_count + EM.stop_event_loop + } + assert_equal(0, count) + end + + # Run this again with kqueue enabled (if available) + def test_idle_connection_count_kqueue + EM.kqueue if EM.kqueue? + + count = nil + EM.run { + count = EM.connection_count + EM.stop_event_loop + } + assert_equal(0, count) + end + + module Client + def connection_completed + $client_conns += 1 + EM.stop if $client_conns == 3 + end + end + + def test_with_some_connections + EM.run { + $client_conns = 0 + $initial_conns = EM.connection_count + EM.start_server("127.0.0.1", 9999) + $server_conns = EM.connection_count + 3.times { EM.connect("127.0.0.1", 9999, Client) } + } + + assert_equal(0, $initial_conns) + assert_equal(1, $server_conns) + assert_equal(4, $client_conns + $server_conns) + end + + module DoubleCloseClient + def unbind + close_connection + $num_close_scheduled_1 = EM.num_close_scheduled + EM.next_tick do + $num_close_scheduled_2 = EM.num_close_scheduled + EM.stop + end + end + end + + def test_num_close_scheduled + omit_if(jruby?) + EM.run { + assert_equal(0, EM.num_close_scheduled) + EM.connect("127.0.0.1", 9999, DoubleCloseClient) # nothing listening on 9999 + } + assert_equal(1, $num_close_scheduled_1) + assert_equal(0, $num_close_scheduled_2) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_connection_write.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_connection_write.rb new file mode 100644 index 0000000..35533b5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_connection_write.rb @@ -0,0 +1,35 @@ +require 'em_test_helper' + +class TestConnectionWrite < Test::Unit::TestCase + + # This test takes advantage of the fact that EM::_RunSelectOnce iterates over the connections twice: + # - once to determine which ones to call Write() on + # - and once to call Write() on each of them. + # + # But state may change in the meantime before Write() is finally called. + # And that is what we try to exploit to get Write() to be called when bWatchOnly is true, and bNotifyWritable is false, + # to cause an assertion failure. + + module SimpleClient + def notify_writable + $conn2.notify_writable = false # Being naughty in callback + # If this doesn't crash anything, the test passed! + end + end + + def test_with_naughty_callback + EM.run do + r1, _ = IO.pipe + r2, _ = IO.pipe + + # Adding EM.watches + $conn1 = EM.watch(r1, SimpleClient) + $conn2 = EM.watch(r2, SimpleClient) + + $conn1.notify_writable = true + $conn2.notify_writable = true + + EM.stop + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_defer.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_defer.rb new file mode 100644 index 0000000..aeca127 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_defer.rb @@ -0,0 +1,35 @@ +require 'em_test_helper' + +class TestDefer < Test::Unit::TestCase + + def test_defers + n = 0 + n_times = 20 + EM.run { + n_times.times { + work_proc = proc { n += 1 } + callback = proc { EM.stop if n == n_times } + EM.defer work_proc, callback + } + } + assert_equal( n, n_times ) + end + + def test_errbacks + iterations = 20 + callback_parameter = rand(100) + callback_parameters = [] + callback_op = proc { callback_parameter } + callback = proc { |result| callback_parameters << result } + errback_parameter = Exception.new + errback_parameters = [] + errback_op = proc { raise errback_parameter } + errback = proc { |error| errback_parameters << error } + EventMachine.run do + (1..iterations).each { |index| EventMachine.defer(index.even? ? callback_op : errback_op, callback, errback) } + EventMachine.add_periodic_timer(0.1) { EventMachine.stop if EventMachine.defers_finished? } + end + assert_equal(callback_parameters.select { |parameter| parameter == callback_parameter }.length, iterations * 0.5) + assert_equal(errback_parameters.select{ |parameter| parameter == errback_parameter }.length, iterations * 0.5) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_deferrable.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_deferrable.rb new file mode 100644 index 0000000..5f286a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_deferrable.rb @@ -0,0 +1,35 @@ +require 'em_test_helper' + +class TestDeferrable < Test::Unit::TestCase + class Later + include EM::Deferrable + end + + def test_timeout_without_args + assert_nothing_raised do + EM.run { + df = Later.new + df.timeout(0) + df.errback { EM.stop } + EM.add_timer(0.01) { flunk "Deferrable was not timed out." } + } + end + end + + def test_timeout_with_args + args = nil + + EM.run { + df = Later.new + df.timeout(0, :timeout, :foo) + df.errback do |type, name| + args = [type, name] + EM.stop + end + + EM.add_timer(0.01) { flunk "Deferrable was not timed out." } + } + + assert_equal [:timeout, :foo], args + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_epoll.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_epoll.rb new file mode 100644 index 0000000..36f5609 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_epoll.rb @@ -0,0 +1,142 @@ +require 'em_test_helper' + + +class TestEpoll < Test::Unit::TestCase + + module TestEchoServer + def receive_data data + send_data data + close_connection_after_writing + end + end + + module TestEchoClient + def connection_completed + send_data "ABCDE" + $max += 1 + end + def receive_data data + raise "bad response" unless data == "ABCDE" + end + def unbind + $n -= 1 + EM.stop if $n == 0 + end + end + + + # We can set the rlimit/nofile of a process but we can only set it + # higher if we're running as root. + # On most systems, the default value is 1024. + def test_rlimit + omit_if(windows? || jruby?) + unless EM.set_descriptor_table_size >= 1024 + a = EM.set_descriptor_table_size + assert( a <= 1024 ) + a = EM.set_descriptor_table_size( 1024 ) + assert( a == 1024 ) + end + end + + # Run a high-volume version of this test by kicking the number of connections + # up past 512. (Each connection uses two sockets, a client and a server.) + # (Will require running the test as root) + # This test exercises TCP clients and servers. + # + # XXX this test causes all sort of weird issues on OSX (when run as part of the suite) + def _test_descriptors + EM.epoll + EM.set_descriptor_table_size 60000 + EM.run { + EM.start_server "127.0.0.1", 9800, TestEchoServer + $n = 0 + $max = 0 + 100.times { + EM.connect("127.0.0.1", 9800, TestEchoClient) {$n += 1} + } + } + assert_equal(0, $n) + assert_equal(100, $max) + end + + def setup + @port = next_port + end + + module TestDatagramServer + def receive_data dgm + $in = dgm + send_data "abcdefghij" + end + end + module TestDatagramClient + def initialize port + @port = port + end + + def post_init + send_datagram "1234567890", "127.0.0.1", @port + end + + def receive_data dgm + $out = dgm + EM.stop + end + end + + def test_datagrams + $in = $out = "" + EM.run { + EM.open_datagram_socket "127.0.0.1", @port, TestDatagramServer + EM.open_datagram_socket "127.0.0.1", 0, TestDatagramClient, @port + } + assert_equal( "1234567890", $in ) + assert_equal( "abcdefghij", $out ) + end + + # XXX this test fails randomly... + def _test_unix_domain + fn = "/tmp/xxx.chain" + EM.epoll + EM.set_descriptor_table_size 60000 + EM.run { + # The pure-Ruby version won't let us open the socket if the node already exists. + # Not sure, that actually may be correct and the compiled version is wrong. + # Pure Ruby also oddly won't let us make that many connections. This test used + # to run 100 times. Not sure where that lower connection-limit is coming from in + # pure Ruby. + # Let's not sweat the Unix-ness of the filename, since this test can't possibly + # work on Windows anyway. + # + File.unlink(fn) if File.exist?(fn) + EM.start_unix_domain_server fn, TestEchoServer + $n = 0 + $max = 0 + 50.times { + EM.connect_unix_domain(fn, TestEchoClient) {$n += 1} + } + EM::add_timer(1) { $stderr.puts("test_unix_domain timed out!"); EM::stop } + } + assert_equal(0, $n) + assert_equal(50, $max) + ensure + File.unlink(fn) if File.exist?(fn) + end + + def test_attach_detach + EM.epoll + EM.run { + EM.add_timer(0.01) { EM.stop } + + r, _ = IO.pipe + + # This tests a regression where detach in the same tick as attach crashes EM + EM.watch(r) do |connection| + connection.detach + end + } + + assert true + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_error_handler.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_error_handler.rb new file mode 100644 index 0000000..23c23f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_error_handler.rb @@ -0,0 +1,38 @@ +require 'em_test_helper' + +class TestErrorHandler < Test::Unit::TestCase + def setup + @exception = Class.new(StandardError) + end + + def test_error_handler + error = nil + + EM.error_handler{ |e| + error = e + EM.error_handler(nil) + EM.stop + } + + assert_nothing_raised do + EM.run{ + EM.add_timer(0){ + raise @exception, 'test' + } + } + end + + assert_equal error.class, @exception + assert_equal error.message, 'test' + end + + def test_without_error_handler + assert_raise @exception do + EM.run{ + EM.add_timer(0){ + raise @exception, 'test' + } + } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_exc.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_exc.rb new file mode 100644 index 0000000..d9c860a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_exc.rb @@ -0,0 +1,43 @@ +require 'em_test_helper' + +class TestSomeExceptions < Test::Unit::TestCase + class DoomedConnectionError < StandardError + end + class DoomedConnection < EventMachine::Connection + def unbind + raise DoomedConnectionError + end + end + + # Read the commentary in EM#run. + # This test exercises the ensure block in #run that makes sure + # EM#release_machine gets called even if an exception is + # thrown within the user code. Without the ensured call to release_machine, + # the second call to EM#run will fail with a C++ exception + # because the machine wasn't cleaned up properly. + + def test_a + assert_raises(RuntimeError) { + EM.run { + raise "some exception" + } + } + end + + def test_b + assert_raises(RuntimeError) { + EM.run { + raise "some exception" + } + } + end + + def test_exception_on_unbind + assert_raises(DoomedConnectionError) { + EM.run { + EM.connect("localhost", 8888, DoomedConnection) + } + } + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_file_watch.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_file_watch.rb new file mode 100644 index 0000000..5602071 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_file_watch.rb @@ -0,0 +1,85 @@ +require 'em_test_helper' +require 'tempfile' + +class TestFileWatch < Test::Unit::TestCase + if windows? + def test_watch_file_raises_unsupported_error + assert_raises(EM::Unsupported) do + EM.run do + file = Tempfile.new("fake_file") + EM.watch_file(file.path) + end + end + end + elsif EM.respond_to? :watch_filename + module FileWatcher + def file_modified + $modified = true + end + def file_deleted + $deleted = true + end + def unbind + $unbind = true + EM.stop + end + end + + def setup + EM.kqueue = true if EM.kqueue? + end + + def teardown + EM.kqueue = false if EM.kqueue? + end + + def test_events + omit_if(solaris?) + EM.run{ + file = Tempfile.new('em-watch') + $tmp_path = file.path + + # watch it + watch = EM.watch_file(file.path, FileWatcher) + $path = watch.path + + # modify it + File.open(file.path, 'w'){ |f| f.puts 'hi' } + + # delete it + EM.add_timer(0.01){ file.close; file.delete } + } + + assert_equal($path, $tmp_path) + assert($modified) + assert($deleted) + assert($unbind) + end + + # Refer: https://github.com/eventmachine/eventmachine/issues/512 + def test_invalid_signature + # This works fine with kqueue, only fails with linux inotify. + omit_if(EM.kqueue?) + + EM.run { + file = Tempfile.new('foo') + + w1 = EventMachine.watch_file(file.path) + w2 = EventMachine.watch_file(file.path) + + assert_raise EventMachine::InvalidSignature do + w2.stop_watching + end + + EM.stop + } + end + else + warn "EM.watch_file not implemented, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests + def test_em_watch_file_unsupported + assert true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_fork.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_fork.rb new file mode 100644 index 0000000..8b15bb5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_fork.rb @@ -0,0 +1,75 @@ +require 'em_test_helper' + +class TestFork < Test::Unit::TestCase + + def test_fork_safe + omit_if(jruby?) + omit_if(windows?) + + fork_pid = nil + read, write = IO.pipe + EM.run do + fork_pid = fork do + write.puts "forked" + EM.run do + EM.next_tick do + write.puts "EM ran" + EM.stop + end + end + end + EM.stop + end + + sleep 0.1 + begin + Timeout::timeout 1 do + assert_equal "forked\n", read.readline + assert_equal "EM ran\n", read.readline + end + rescue Timeout::Error + Process.kill 'TERM', fork_pid + flunk "Timeout waiting for next_tick in new fork reactor" + end + ensure + read.close rescue nil + write.close rescue nil + end + + def test_fork_reactor + omit_if(jruby?) + omit_if(windows?) + + fork_pid = nil + read, write = IO.pipe + EM.run do + EM.defer do + write.puts Process.pid + EM.defer do + EM.stop + end + end + fork_pid = EM.fork_reactor do + EM.defer do + write.puts Process.pid + EM.stop + end + end + end + + sleep 0.1 + begin + Timeout::timeout 1 do + assert_equal Process.pid.to_s, read.readline.chomp + assert_equal fork_pid.to_s, read.readline.chomp + end + rescue Timeout::Error + Process.kill 'TERM', fork_pid + flunk "Timeout waiting for deferred block in fork_reactor" + end + ensure + read.close rescue nil + write.close rescue nil + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_futures.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_futures.rb new file mode 100644 index 0000000..b494856 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_futures.rb @@ -0,0 +1,170 @@ +require 'em_test_helper' + +class TestFutures < Test::Unit::TestCase + + def setup + end + + def teardown + end + + def test_future + assert_equal(100, EM::Deferrable.future(100) ) + + p1 = proc { 100 + 1 } + assert_equal(101, EM::Deferrable.future(p1) ) + end + + class MyFuture + include EM::Deferrable + def initialize *args + super + set_deferred_status :succeeded, 40 + end + end + + class MyErrorFuture + include EM::Deferrable + def initialize *args + super + set_deferred_status :failed, 41 + end + end + + + def test_future_1 + # Call future with one additional argument and it will be treated as a callback. + def my_future + MyFuture.new + end + + value = nil + EM::Deferrable.future my_future, proc {|v| value=v} + assert_equal( 40, value ) + end + + + def test_future_2 + # Call future with two additional arguments and they will be treated as a callback + # and an errback. + value = nil + EM::Deferrable.future MyErrorFuture.new, nil, proc {|v| value=v} + assert_equal( 41, value ) + end + + + def test_future_3 + # Call future with no additional arguments but with a block, and the block will be + # treated as a callback. + value = nil + EM::Deferrable.future MyFuture.new do |v| + value=v + end + assert_equal( 40, value ) + end + + + class RecursiveCallback + include EM::Deferrable + end + + # A Deferrable callback can call #set_deferred_status to change the values + # passed to subsequent callbacks. + # + def test_recursive_callbacks + n = 0 # counter assures that all the tests actually run. + rc = RecursiveCallback.new + rc.callback {|a| + assert_equal(100, a) + n += 1 + rc.set_deferred_status :succeeded, 101, 101 + } + rc.callback {|a,b| + assert_equal(101, a) + assert_equal(101, b) + n += 1 + rc.set_deferred_status :succeeded, 102, 102, 102 + } + rc.callback {|a,b,c| + assert_equal(102, a) + assert_equal(102, b) + assert_equal(102, c) + n += 1 + } + rc.set_deferred_status :succeeded, 100 + assert_equal(3, n) + end + + def test_syntactic_sugar + rc = RecursiveCallback.new + rc.set_deferred_success 100 + rc.set_deferred_failure 200 + end + + # It doesn't raise an error to set deferred status more than once. + # In fact, this is a desired and useful idiom when it happens INSIDE + # a callback or errback. + # However, it's less useful otherwise, and in fact would generally be + # indicative of a programming error. However, we would like to be resistant + # to such errors. So whenever we set deferred status, we also clear BOTH + # stacks of handlers. + # + def test_double_calls + s = 0 + e = 0 + + d = EM::DefaultDeferrable.new + d.callback {s += 1} + d.errback {e += 1} + + d.succeed # We expect the callback to be called, and the errback to be DISCARDED. + d.fail # Presumably an error. We expect the errback NOT to be called. + d.succeed # We expect the callback to have been discarded and NOT to be called again. + + assert_equal(1, s) + assert_equal(0, e) + end + + # Adding a callback to a Deferrable that is already in a success state executes the callback + # immediately. The same applies to a an errback added to an already-failed Deferrable. + # HOWEVER, we expect NOT to be able to add errbacks to succeeded Deferrables, or callbacks + # to failed ones. + # + # We illustrate this with a rather contrived test. The test calls #fail after #succeed, + # which ordinarily would not happen in a real program. + # + # What we're NOT attempting to specify is what happens if a Deferrable is succeeded and then + # failed (or vice-versa). Should we then be able to add callbacks/errbacks of the appropriate + # type for immediate execution? For now at least, the official answer is "don't do that." + # + def test_delayed_callbacks + s1 = 0 + s2 = 0 + e = 0 + + d = EM::DefaultDeferrable.new + d.callback {s1 += 1} + + d.succeed # Triggers and discards the callback. + + d.callback {s2 += 1} # This callback is executed immediately and discarded. + + d.errback {e += 1} # This errback should be DISCARDED and never execute. + d.fail # To prove it, fail and assert e is 0 + + assert_equal( [1,1], [s1,s2] ) + assert_equal( 0, e ) + end + + def test_timeout + n = 0 + EM.run { + d = EM::DefaultDeferrable.new + d.callback {n = 1; EM.stop} + d.errback {n = 2; EM.stop} + d.timeout(0.01) + } + assert_equal( 2, n ) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_handler_check.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_handler_check.rb new file mode 100644 index 0000000..c417694 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_handler_check.rb @@ -0,0 +1,35 @@ +require 'em_test_helper' + +class TestHandlerCheck < Test::Unit::TestCase + + class Foo < EM::Connection; end; + module TestModule; end; + + def test_with_correct_class + assert_nothing_raised do + EM.run { + EM.connect("127.0.0.1", 80, Foo) + EM.stop_event_loop + } + end + end + + def test_with_incorrect_class + assert_raise(ArgumentError) do + EM.run { + EM.connect("127.0.0.1", 80, String) + EM.stop_event_loop + } + end + end + + def test_with_module + assert_nothing_raised do + EM.run { + EM.connect("127.0.0.1", 80, TestModule) + EM.stop_event_loop + } + end + end + +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_hc.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_hc.rb new file mode 100644 index 0000000..28e32c9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_hc.rb @@ -0,0 +1,155 @@ +require 'em_test_helper' + +class TestHeaderAndContentProtocol < Test::Unit::TestCase + + class SimpleTest < EM::P::HeaderAndContentProtocol + attr_reader :first_header, :my_headers, :request + + def receive_first_header_line hdr + @first_header ||= [] + @first_header << hdr + end + def receive_headers hdrs + @my_headers ||= [] + @my_headers << hdrs + end + def receive_request hdrs, content + @request ||= [] + @request << [hdrs, content] + end + end + + class StopOnUnbind < EM::Connection + def unbind + EM.add_timer(0.01) { EM.stop } + end + end + + def setup + @port = next_port + end + + def test_no_content + the_connection = nil + EM.run { + EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn| + the_connection = conn + end + setup_timeout + + EM.connect "127.0.0.1", @port, StopOnUnbind do |c| + c.send_data [ "aaa\n", "bbb\r\n", "ccc\n", "\n" ].join + c.close_connection_after_writing + end + } + assert_equal( ["aaa"], the_connection.first_header ) + assert_equal( [%w(aaa bbb ccc)], the_connection.my_headers ) + assert_equal( [[%w(aaa bbb ccc), ""]], the_connection.request ) + end + + def test_content + the_connection = nil + content = "A" * 50 + headers = ["aaa", "bbb", "Content-length: #{content.length}", "ccc"] + EM.run { + EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn| + the_connection = conn + end + setup_timeout + + EM.connect "127.0.0.1", @port, StopOnUnbind do |c| + headers.each { |h| c.send_data "#{h}\r\n" } + c.send_data "\n" + c.send_data content + c.close_connection_after_writing + end + } + assert_equal( ["aaa"], the_connection.first_header ) + assert_equal( [headers], the_connection.my_headers ) + assert_equal( [[headers, content]], the_connection.request ) + end + + def test_several_requests + the_connection = nil + content = "A" * 50 + headers = ["aaa", "bbb", "Content-length: #{content.length}", "ccc"] + EM.run { + EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn| + the_connection = conn + end + setup_timeout + + EM.connect( "127.0.0.1", @port, StopOnUnbind ) do |c| + 5.times do + headers.each { |h| c.send_data "#{h}\r\n" } + c.send_data "\n" + c.send_data content + end + c.close_connection_after_writing + end + } + assert_equal( ["aaa"] * 5, the_connection.first_header ) + assert_equal( [headers] * 5, the_connection.my_headers ) + assert_equal( [[headers, content]] * 5, the_connection.request ) + end + + + # def x_test_multiple_content_length_headers + # # This is supposed to throw a RuntimeError but it throws a C++ exception instead. + # the_connection = nil + # content = "A" * 50 + # headers = ["aaa", "bbb", ["Content-length: #{content.length}"]*2, "ccc"].flatten + # EM.run { + # EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn| + # the_connection = conn + # end + # EM.add_timer(4) {raise "test timed out"} + # test_proc = proc { + # t = TCPSocket.new "127.0.0.1", @port + # headers.each {|h| t.write "#{h}\r\n" } + # t.write "\n" + # t.write content + # t.close + # } + # EM.defer test_proc, proc { + # EM.stop + # } + # } + # end + + def test_interpret_headers + the_connection = nil + content = "A" * 50 + headers = [ + "GET / HTTP/1.0", + "Accept: aaa", + "User-Agent: bbb", + "Host: ccc", + "x-tempest-header:ddd" + ] + + EM.run { + EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn| + the_connection = conn + end + setup_timeout + + EM.connect( "127.0.0.1", @port, StopOnUnbind ) do |c| + headers.each { |h| c.send_data "#{h}\r\n" } + c.send_data "\n" + c.send_data content + c.close_connection_after_writing + end + } + + hsh = the_connection.headers_2_hash( the_connection.my_headers.shift ) + expect = { + :accept => "aaa", + :user_agent => "bbb", + :host => "ccc", + :x_tempest_header => "ddd" + } + assert_equal(expect, hsh) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_httpclient.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_httpclient.rb new file mode 100644 index 0000000..572a802 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_httpclient.rb @@ -0,0 +1,238 @@ +require 'em_test_helper' + +class TestHttpClient < Test::Unit::TestCase + + def setup + @port = next_port + end + + #------------------------------------- + + def test_http_client + ok = false + EM.run { + c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 } + c.callback { + ok = true + c.close_connection + EM.stop + } + c.errback {EM.stop} # necessary, otherwise a failure blocks the test suite forever. + } + assert ok + end + + #------------------------------------- + + def test_http_client_1 + ok = false + EM.run { + c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 } + c.callback { + ok = true + c.close_connection + EM.stop + } + c.errback {EM.stop} + } + assert ok + end + + #------------------------------------- + + def test_http_client_2 + ok = false + EM.run { + c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 } + c.callback { + ok = true + c.close_connection + EM.stop + } + c.errback {EM.stop} + } + assert ok + end + + + #----------------------------------------- + + # Test a server that returns a page with a zero content-length. + # This caused an early version of the HTTP client not to generate a response, + # causing this test to hang. Observe, there was no problem with responses + # lacking a content-length, just when the content-length was zero. + # + class EmptyContent < EM::Connection + def initialize *args + super + end + def receive_data data + send_data "HTTP/1.0 404 ...\r\nContent-length: 0\r\n\r\n" + close_connection_after_writing + end + end + + def test_http_empty_content + ok = false + EM.run { + EM.start_server "127.0.0.1", @port, EmptyContent + c = silent { EM::P::HttpClient.send :request, :host => "127.0.0.1", :port => @port } + c.callback { + ok = true + c.close_connection + EM.stop + } + } + assert ok + end + + + #--------------------------------------- + + class PostContent < EM::P::LineAndTextProtocol + def initialize *args + super + @lines = [] + end + def receive_line line + if line.length > 0 + @lines << line + else + process_headers + end + end + def receive_binary_data data + @post_content = data + send_response + end + def process_headers + if @lines.first =~ /\APOST ([^\s]+) HTTP\/1.1\Z/ + @uri = $1.dup + else + raise "bad request" + end + + @lines.each {|line| + if line =~ /\AContent-length:\s*(\d+)\Z/i + @content_length = $1.dup.to_i + elsif line =~ /\AContent-type:\s*(\d+)\Z/i + @content_type = $1.dup + end + } + + raise "invalid content length" unless @content_length + set_binary_mode @content_length + end + def send_response + send_data "HTTP/1.1 200 ...\r\nConnection: close\r\nContent-length: 10\r\nContent-type: text/html\r\n\r\n0123456789" + close_connection_after_writing + end + end + + # TODO, this is WRONG. The handler is asserting an HTTP 1.1 request, but the client + # is sending a 1.0 request. Gotta fix the client + def test_post + response = nil + EM.run { + EM.start_server '127.0.0.1', @port, PostContent + setup_timeout(2) + c = silent { EM::P::HttpClient.request( + :host => '127.0.0.1', + :port => @port, + :method => :post, + :request => "/aaa", + :content => "XYZ", + :content_type => "text/plain" + )} + c.callback {|r| + response = r + EM.stop + } + } + + assert_equal( 200, response[:status] ) + assert_equal( "0123456789", response[:content] ) + end + + + # TODO, need a more intelligent cookie tester. + # In fact, this whole test-harness needs a beefier server implementation. + def test_cookie + ok = false + EM.run { + c = silent { EM::Protocols::HttpClient.send :request, :host => "www.google.com", :port => 80, :cookie=>"aaa=bbb" } + c.callback { + ok = true + c.close_connection + EM.stop + } + c.errback {EM.stop} + } + assert ok + end + + # We can tell the client to send an HTTP/1.0 request (default is 1.1). + # This is useful for suppressing chunked responses until those are working. + def test_version_1_0 + ok = false + EM.run { + c = silent { EM::P::HttpClient.request( + :host => "www.google.com", + :port => 80, + :version => "1.0" + )} + c.callback { + ok = true + c.close_connection + EM.stop + } + c.errback {EM.stop} + } + assert ok + end + + #----------------------------------------- + + # Test a server that returns chunked encoding + # + class ChunkedEncodingContent < EventMachine::Connection + def initialize *args + super + end + def receive_data data + send_data ["HTTP/1.1 200 OK", + "Server: nginx/0.7.67", + "Date: Sat, 23 Oct 2010 16:41:32 GMT", + "Content-Type: application/json", + "Transfer-Encoding: chunked", + "Connection: keep-alive", + "", + "1800", + "chunk1" * 1024, + "5a", + "chunk2" * 15, + "0", + ""].join("\r\n") + close_connection_after_writing + end + end + + def test_http_chunked_encoding_content + ok = false + EM.run { + EM.start_server "127.0.0.1", @port, ChunkedEncodingContent + c = silent { EM::P::HttpClient.send :request, :host => "127.0.0.1", :port => @port } + c.callback { |result| + if result[:content] == "chunk1" * 1024 + "chunk2" * 15 + ok = true + end + c.close_connection + EM.stop + } + } + assert ok + end + +end + + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_httpclient2.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_httpclient2.rb new file mode 100644 index 0000000..a00fcbc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_httpclient2.rb @@ -0,0 +1,128 @@ +require 'em_test_helper' + +class TestHttpClient2 < Test::Unit::TestCase + class TestServer < EM::Connection + end + + def setup + @port = next_port + end + + # #connect returns an object which has made a connection to an HTTP server + # and exposes methods for making HTTP requests on that connection. + # #connect can take either a pair of parameters (a host and a port), + # or a single parameter which is a Hash. + # + def test_connect + EM.run { + setup_timeout(1) + EM.start_server '127.0.0.1', @port, TestServer + silent do + EM::P::HttpClient2.connect '127.0.0.1', @port + EM::P::HttpClient2.connect( :host=>'127.0.0.1', :port=>@port ) + end + EM.stop + } + end + + def test_bad_port + EM.run { + setup_timeout(1) + EM.start_server '127.0.0.1', @port, TestServer + assert_raises( ArgumentError ) { + silent { EM::P::HttpClient2.connect '127.0.0.1', "xxx" } + } + EM.stop + } + end + + def test_bad_server + err = nil + EM.run { + setup_timeout(1) + http = silent { EM::P::HttpClient2.connect '127.0.0.1', 9999 } + d = http.get "/" + d.errback { err = true; d.internal_error; EM.stop } + } + assert(err) + end + + def test_get + content = nil + EM.run { + setup_timeout(1) + http = silent { EM::P::HttpClient2.connect :host => "google.com", :port => 80, :version => '1.0' } + d = http.get "/" + d.callback { + content = d.content + EM.stop + } + } + assert(content) + end + + # Not a pipelined request because we wait for one response before we request the next. + # XXX this test is broken because it sends the second request to the first connection + # XXX right before the connection closes + def _test_get_multiple + content = nil + EM.run { + setup_timeout(1) + http = silent { EM::P::HttpClient2.connect "google.com", :version => '1.0' } + d = http.get "/" + d.callback { + e = http.get "/" + e.callback { + content = e.content + EM.stop + } + } + } + assert(content) + end + + def test_get_pipeline + headers, headers2 = nil, nil + EM.run { + setup_timeout(1) + http = silent { EM::P::HttpClient2.connect "google.com", 80 } + d = http.get("/") + d.callback { + headers = d.headers + } + e = http.get("/") + e.callback { + headers2 = e.headers + } + EM.tick_loop { EM.stop if headers && headers2 } + EM.add_timer(1) { EM.stop } + } + assert(headers) + assert(headers2) + end + + def test_authheader + EM.run { + setup_timeout(1) + EM.start_server '127.0.0.1', @port, TestServer + http = silent { EM::P::HttpClient2.connect '127.0.0.1', 18842 } + d = http.get :url=>"/", :authorization=>"Basic xxx" + d.callback {EM.stop} + d.errback {EM.stop} + } + end + + def test_https_get + omit_unless(EM.ssl?) + d = nil + EM.run { + setup_timeout(1) + http = silent { EM::P::HttpClient2.connect :host => 'www.google.com', :port => 443, :ssl => true, :version => '1.0' } + d = http.get "/" + d.callback {EM.stop} + d.errback {EM.stop} + } + assert_equal(200, d.status) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_idle_connection.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_idle_connection.rb new file mode 100644 index 0000000..bfc57cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_idle_connection.rb @@ -0,0 +1,31 @@ +require 'em_test_helper' + +class TestIdleConnection < Test::Unit::TestCase + def setup + @port = next_port + end + + def test_idle_time + omit_if(!EM.respond_to?(:get_idle_time)) + + a, b = nil, nil + EM.run do + EM.start_server '127.0.0.1', @port, Module.new + conn = EM.connect '127.0.0.1', @port + EM.add_timer(0.3) do + a = conn.get_idle_time + conn.send_data 'a' + EM.next_tick do + EM.next_tick do + b = conn.get_idle_time + conn.close_connection + EM.stop + end + end + end + end + + assert_in_delta 0.3, a, 0.1 + assert_in_delta 0, b, 0.1 + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_inactivity_timeout.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_inactivity_timeout.rb new file mode 100644 index 0000000..15e39a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_inactivity_timeout.rb @@ -0,0 +1,54 @@ +require 'em_test_helper' + +class TestInactivityTimeout < Test::Unit::TestCase + + if EM.respond_to? :get_comm_inactivity_timeout + def test_default + EM.run { + c = EM.connect("127.0.0.1", 54321) + assert_equal 0.0, c.comm_inactivity_timeout + EM.stop + } + end + + def test_set_and_get + EM.run { + c = EM.connect("127.0.0.1", 54321) + c.comm_inactivity_timeout = 2.5 + assert_equal 2.5, c.comm_inactivity_timeout + EM.stop + } + end + + def test_for_real + start, finish = nil + + timeout_handler = Module.new do + define_method :unbind do + finish = Time.now + EM.stop + end + end + + EM.run { + setup_timeout + EM.heartbeat_interval = 0.01 + EM.start_server("127.0.0.1", 12345) + EM.add_timer(0.01) { + start = Time.now + c = EM.connect("127.0.0.1", 12345, timeout_handler) + c.comm_inactivity_timeout = 0.02 + } + } + + assert_in_delta(0.02, (finish - start), 0.02) + end + else + warn "EM.comm_inactivity_timeout not implemented, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests + def test_em_comm_inactivity_timeout_not_implemented + assert true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ipv4.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ipv4.rb new file mode 100644 index 0000000..bd11bbf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ipv4.rb @@ -0,0 +1,95 @@ +require 'em_test_helper' + +class TestIPv4 < Test::Unit::TestCase + # Runs a TCP server in the local IPv4 address, connects to it and sends a specific data. + # Timeout in 2 seconds. + def test_ipv4_tcp_local_server + omit_if(!Test::Unit::TestCase.public_ipv4?) + + @@received_data = nil + @local_port = next_port + setup_timeout(2) + + EM.run do + EM::start_server(@@public_ipv4, @local_port) do |s| + def s.receive_data data + @@received_data = data + EM.stop + end + end + + EM::connect(@@public_ipv4, @local_port) do |c| + c.send_data "ipv4/tcp" + end + end + + assert_equal "ipv4/tcp", @@received_data + end + + # Runs a UDP server in the local IPv4 address, connects to it and sends a specific data. + # Timeout in 2 seconds. + def test_ipv4_udp_local_server + omit_if(!Test::Unit::TestCase.public_ipv4?) + + @@received_data = nil + @local_port = next_port + setup_timeout(2) + + EM.run do + EM::open_datagram_socket(@@public_ipv4, @local_port) do |s| + def s.receive_data data + @@received_data = data + EM.stop + end + end + + EM::open_datagram_socket(@@public_ipv4, next_port) do |c| + c.send_datagram "ipv4/udp", @@public_ipv4, @local_port + end + end + + assert_equal "ipv4/udp", @@received_data + end + + # Try to connect via TCP to an invalid IPv4. EM.connect should raise + # EM::ConnectionError. + def test_tcp_connect_to_invalid_ipv4 + omit_if(!Test::Unit::TestCase.public_ipv4?) + + invalid_ipv4 = "9.9:9" + + EM.run do + begin + error = nil + EM.connect(invalid_ipv4, 1234) + rescue => e + error = e + ensure + EM.stop + assert_equal EM::ConnectionError, (error && error.class) + end + end + end + + # Try to send a UDP datagram to an invalid IPv4. EM.send_datagram should raise + # EM::ConnectionError. + def test_udp_send_datagram_to_invalid_ipv4 + omit_if(!Test::Unit::TestCase.public_ipv4?) + + invalid_ipv4 = "9.9:9" + + EM.run do + begin + error = nil + EM.open_datagram_socket(@@public_ipv4, next_port) do |c| + c.send_datagram "hello", invalid_ipv4, 1234 + end + rescue => e + error = e + ensure + EM.stop + assert_equal EM::ConnectionError, (error && error.class) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ipv6.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ipv6.rb new file mode 100644 index 0000000..b52fef1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ipv6.rb @@ -0,0 +1,107 @@ +require 'em_test_helper' + +class TestIPv6 < Test::Unit::TestCase + + if Test::Unit::TestCase.public_ipv6? + + # Runs a TCP server in the local IPv6 address, connects to it and sends a specific data. + # Timeout in 2 seconds. + def test_ipv6_tcp_local_server + @@received_data = nil + @local_port = next_port + setup_timeout(2) + + EM.run do + EM.start_server(@@public_ipv6, @local_port) do |s| + def s.receive_data data + @@received_data = data + EM.stop + end + end + + EM::connect(@@public_ipv6, @local_port) do |c| + def c.unbind(reason) + warn "unbind: #{reason.inspect}" if reason # XXX at least find out why it failed + end + c.send_data "ipv6/tcp" + end + end + + assert_equal "ipv6/tcp", @@received_data + end + + # Runs a UDP server in the local IPv6 address, connects to it and sends a specific data. + # Timeout in 2 seconds. + def test_ipv6_udp_local_server + @@received_data = nil + @local_port = next_port + @@remote_ip = nil + setup_timeout(2) + + EM.run do + EM.open_datagram_socket(@@public_ipv6, @local_port) do |s| + def s.receive_data data + _port, @@remote_ip = Socket.unpack_sockaddr_in(get_peername) + @@received_data = data + EM.stop + end + end + + EM.open_datagram_socket(@@public_ipv6, next_port) do |c| + c.send_datagram "ipv6/udp", @@public_ipv6, @local_port + end + end + assert_equal @@remote_ip, @@public_ipv6 + assert_equal "ipv6/udp", @@received_data + end + + # Try to connect via TCP to an invalid IPv6. EM.connect should raise + # EM::ConnectionError. + def test_tcp_connect_to_invalid_ipv6 + invalid_ipv6 = "1:A" + + EM.run do + begin + error = nil + EM.connect(invalid_ipv6, 1234) + rescue => e + error = e + ensure + EM.stop + assert_equal EM::ConnectionError, (error && error.class) + end + end + end + + # Try to send a UDP datagram to an invalid IPv6. EM.send_datagram should raise + # EM::ConnectionError. + def test_udp_send_datagram_to_invalid_ipv6 + invalid_ipv6 = "1:A" + + EM.run do + begin + error = nil + EM.open_datagram_socket(@@public_ipv6, next_port) do |c| + c.send_datagram "hello", invalid_ipv6, 1234 + end + rescue => e + error = e + ensure + EM.stop + assert_equal EM::ConnectionError, (error && error.class) + end + end + end + + + else + warn "no IPv6 in this host, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests. + def test_ipv6_unavailable + assert true + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_iterator.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_iterator.rb new file mode 100644 index 0000000..6ec4e46 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_iterator.rb @@ -0,0 +1,118 @@ +require 'em_test_helper' + +class TestIterator < Test::Unit::TestCase + + # By default, format the time with tenths-of-seconds. + # Some tests should ask for extra decimal places to ensure + # that delays between iterations will receive a changed time. + def get_time(n=1) + time = EM.current_time + time.strftime('%H:%M:%S.') + time.tv_usec.to_s[0, n] + end + + def test_default_concurrency + items = {} + list = 1..10 + EM.run { + EM::Iterator.new(list).each( proc {|num,iter| + time = get_time(3) + items[time] ||= [] + items[time] << num + EM::Timer.new(0.02) {iter.next} + }, proc {EM.stop}) + } + assert_equal(10, items.keys.size) + assert_equal(list.to_a.sort, items.values.flatten.sort) + end + + def test_default_concurrency_with_a_proc + items = {} + list = (1..10).to_a + original_list = list.dup + EM.run { + EM::Iterator.new(proc{list.pop || EM::Iterator::Stop}).each( proc {|num,iter| + time = get_time(3) + items[time] ||= [] + items[time] << num + EM::Timer.new(0.02) {iter.next} + }, proc {EM.stop}) + } + assert_equal(10, items.keys.size) + assert_equal(original_list.to_a.sort, items.values.flatten.sort) + end + + def test_concurrency_bigger_than_list_size + items = {} + list = [1,2,3] + EM.run { + EM::Iterator.new(list,10).each(proc {|num,iter| + time = get_time + items[time] ||= [] + items[time] << num + EM::Timer.new(1) {iter.next} + }, proc {EM.stop}) + } + assert_equal(1, items.keys.size) + assert_equal(list.to_a.sort, items.values.flatten.sort) + end + + def test_changing_concurrency_affects_active_iteration + items = {} + list = 1..25 + seen = 0 + EM.run { + i = EM::Iterator.new(list,1) + i.each(proc {|num,iter| + time = get_time + items[time] ||= [] + items[time] << num + if (seen += 1) == 5 + # The first 5 items will be distinct times + # The next 20 items will happen in 2 bursts + i.concurrency = 10 + end + EM::Timer.new(0.2) {iter.next} + }, proc {EM.stop}) + } + assert_in_delta(7, items.keys.size, 1) + assert_equal(list.to_a.sort, items.values.flatten.sort) + end + + def test_map + list = 100..150 + EM.run { + EM::Iterator.new(list).map(proc{ |num,iter| + EM.add_timer(0.01){ iter.return(num) } + }, proc{ |results| + assert_equal(list.to_a.size, results.size) + EM.stop + }) + } + end + + def test_inject + omit_if(windows?) + + list = %w[ pwd uptime uname date ] + EM.run { + EM::Iterator.new(list, 2).inject({}, proc{ |hash,cmd,iter| + EM.system(cmd){ |output,status| + hash[cmd] = status.exitstatus == 0 ? output.strip : nil + iter.return(hash) + } + }, proc{ |results| + assert_equal(results.keys.sort, list.sort) + EM.stop + }) + } + end + + def test_concurrency_is_0 + EM.run { + assert_raise ArgumentError do + EM::Iterator.new(1..5,0) + end + EM.stop + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_kb.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_kb.rb new file mode 100644 index 0000000..9c31f5f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_kb.rb @@ -0,0 +1,28 @@ +require 'em_test_helper' + +class TestKeyboardEvents < Test::Unit::TestCase + + module KbHandler + include EM::Protocols::LineText2 + def receive_line d + EM::stop if d == "STOP" + end + end + + # This test doesn't actually do anything useful but is here to + # illustrate the usage. If you removed the timer and ran this test + # by itself on a console, and then typed into the console, it would + # work. + # I don't know how to get the test harness to simulate actual keystrokes. + # When someone figures that out, then we can make this a real test. + # + def test_kb + omit_if(jruby?) + omit_if(!$stdout.tty?) # don't run the test unless it stands a chance of validity. + EM.run do + EM.open_keyboard KbHandler + EM::Timer.new(1) { EM.stop } + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_line_protocol.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_line_protocol.rb new file mode 100644 index 0000000..2067a72 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_line_protocol.rb @@ -0,0 +1,33 @@ +require 'em_test_helper' + +class TestLineProtocol < Test::Unit::TestCase + class LineProtocolTestClass + include EM::Protocols::LineProtocol + + def lines + @lines ||= [] + end + + def receive_line(line) + lines << line + end + end + + def setup + @proto = LineProtocolTestClass.new + end + + def test_simple_split_line + @proto.receive_data("this is") + assert_equal([], @proto.lines) + + @proto.receive_data(" a test\n") + assert_equal(["this is a test"], @proto.lines) + end + + def test_simple_lines + @proto.receive_data("aaa\nbbb\r\nccc\nddd") + assert_equal(%w(aaa bbb ccc), @proto.lines) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ltp.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ltp.rb new file mode 100644 index 0000000..06c2685 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ltp.rb @@ -0,0 +1,155 @@ +require 'em_test_helper' + +class TestLineAndTextProtocol < Test::Unit::TestCase + + class TLP_LineBuffer < EM::P::LineAndTextProtocol + attr_reader :line_buffer + + def initialize + super + @line_buffer = [] + end + + def receive_line line + @line_buffer << line + end + end + + module StopClient + def set_receive_data(&blk) + @rdb = blk + end + + def receive_data data + @rdb.call(data) if @rdb + end + + def unbind + EM.add_timer(0.1) { EM.stop } + end + end + + def setup + @port = next_port + end + + def test_simple_lines + conn = nil + EM.run { + EM.start_server( "127.0.0.1", @port, TLP_LineBuffer ) do |c| + conn = c + end + setup_timeout + + EM.connect "127.0.0.1", @port, StopClient do |c| + c.send_data "aaa\nbbb\r\nccc\n" + c.close_connection_after_writing + end + } + assert_equal( %w(aaa bbb ccc), conn.line_buffer) + end + + #-------------------------------------------------------------------- + + class TLP_ErrorMessage < EM::P::LineAndTextProtocol + attr_reader :error_message + + def initialize + super + @error_message = [] + end + + def receive_line text + raise + end + + def receive_error text + @error_message << text + end + end + + def test_overlength_lines + conn = nil + EM.run { + EM.start_server( "127.0.0.1", @port, TLP_ErrorMessage ) do |c| + conn = c + end + setup_timeout + EM.connect "127.0.0.1", @port, StopClient do |c| + c.send_data "a" * (16*1024 + 1) + c.send_data "\n" + c.close_connection_after_writing + end + + } + assert_equal( ["overlength line"], conn.error_message ) + end + + + #-------------------------------------------------------------------- + + class LineAndTextTest < EM::P::LineAndTextProtocol + def receive_line line + if line =~ /content-length:\s*(\d+)/i + @content_length = $1.to_i + elsif line.length == 0 + set_binary_mode @content_length + end + end + def receive_binary_data text + send_data "received #{text.length} bytes" + close_connection_after_writing + end + end + + def test_lines_and_text + output = '' + EM.run { + EM.start_server( "127.0.0.1", @port, LineAndTextTest ) + setup_timeout + + EM.connect "127.0.0.1", @port, StopClient do |c| + c.set_receive_data { |data| output << data } + c.send_data "Content-length: 400\n" + c.send_data "\n" + c.send_data "A" * 400 + EM.add_timer(0.1) { c.close_connection_after_writing } + end + } + assert_equal( "received 400 bytes", output ) + end + + #-------------------------------------------------------------------- + + + class BinaryTextTest < EM::P::LineAndTextProtocol + def receive_line line + if line =~ /content-length:\s*(\d+)/i + set_binary_mode $1.to_i + else + raise "protocol error" + end + end + def receive_binary_data text + send_data "received #{text.length} bytes" + close_connection_after_writing + end + end + + def test_binary_text + output = '' + EM.run { + EM.start_server( "127.0.0.1", @port, BinaryTextTest ) + setup_timeout + + EM.connect "127.0.0.1", @port, StopClient do |c| + c.set_receive_data { |data| output << data } + c.send_data "Content-length: 10000\n" + c.send_data "A" * 10000 + EM.add_timer(0.1) { c.close_connection_after_writing } + end + } + assert_equal( "received 10000 bytes", output ) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ltp2.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ltp2.rb new file mode 100644 index 0000000..220fcbe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ltp2.rb @@ -0,0 +1,332 @@ +require 'em_test_helper' + +# TODO!!! Need tests for overlength headers and text bodies. + +class TestLineText2 < Test::Unit::TestCase + + # Run each of these tests two ways: passing in the whole test-dataset in one chunk, + # and passing it in one character at a time. + + class Basic + include EM::Protocols::LineText2 + attr_reader :lines + def receive_line line + (@lines ||= []) << line + end + end + def test_basic + testdata = "Line 1\nLine 2\r\nLine 3\n" + + a = Basic.new + a.receive_data testdata + assert_equal( ["Line 1", "Line 2", "Line 3"], a.lines ) + + a = Basic.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + assert_equal( ["Line 1", "Line 2", "Line 3"], a.lines ) + end + + # The basic test above shows that extra newlines are chomped + # This test shows that newlines are preserved if the delimiter isn't \n + class PreserveNewlines + include EM::Protocols::LineText2 + attr_reader :lines + def initialize *args + super + @delim = "|" + set_delimiter @delim + end + def receive_line line + (@lines ||= []) << line + end + end + def test_preserve_newlines + a = PreserveNewlines.new + a.receive_data "aaa|bbb|ccc|\n|\r\n| \t ||" + assert_equal( ["aaa", "bbb", "ccc", "\n", "\r\n", " \t ", ""], a.lines ) + end + + class ChangeDelimiter + include EM::Protocols::LineText2 + attr_reader :lines + def initialize *args + super + @delim = "A" + set_delimiter @delim + end + def receive_line line + (@lines ||= []) << line + set_delimiter( @delim.succ! ) + end + end + + def test_change_delimiter + testdata = %Q(LineaALinebBLinecCLinedD) + + a = ChangeDelimiter.new + a.receive_data testdata + assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines ) + + a = ChangeDelimiter.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines ) + end + + class RegexDelimiter + include EM::Protocols::LineText2 + attr_reader :lines + def initialize *args + super + @delim = /[A-D]/ + set_delimiter @delim + end + def receive_line line + (@lines ||= []) << line + end + end + + def test_regex_delimiter + testdata = %Q(LineaALinebBLinecCLinedD) + + a = RegexDelimiter.new + a.receive_data testdata + assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines ) + + a = RegexDelimiter.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines ) + end + + #-- + # Test two lines followed by an empty line, ten bytes of binary data, then + # two more lines. + + class Binary + include EM::Protocols::LineText2 + attr_reader :lines, :body + def initialize *args + super + @lines = [] + @body = nil + end + def receive_line ln + if ln == "" + set_text_mode 10 + else + @lines << ln + end + end + def receive_binary_data data + @body = data + end + end + + def test_binary + testdata = %Q(Line 1 +Line 2 + +0000000000Line 3 +Line 4 +) + + a = Binary.new + a.receive_data testdata + assert_equal( ["Line 1", "Line 2", "Line 3", "Line 4"], a.lines) + assert_equal( "0000000000", a.body ) + + a = Binary.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + assert_equal( ["Line 1", "Line 2", "Line 3", "Line 4"], a.lines) + assert_equal( "0000000000", a.body ) + end + + + # Test unsized binary data. The expectation is that each chunk of it + # will be passed to us as it it received. + class UnsizedBinary + include EM::Protocols::LineText2 + attr_reader :n_calls, :body + def initialize *args + super + set_text_mode + end + def receive_binary_data data + @n_calls ||= 0 + @n_calls += 1 + (@body ||= "") << data + end + end + + def test_unsized_binary + testdata = "X\0" * 1000 + + a = UnsizedBinary.new + a.receive_data testdata + assert_equal( 1, a.n_calls ) + assert_equal( testdata, a.body ) + + a = UnsizedBinary.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + assert_equal( 2000, a.n_calls ) + assert_equal( testdata, a.body ) + end + + + # Test binary data with a "throw back" into line-mode. + class ThrowBack + include EM::Protocols::LineText2 + attr_reader :headers + def initialize *args + super + @headers = [] + @n_bytes = 0 + set_text_mode + end + def receive_binary_data data + wanted = 25 - @n_bytes + will_take = if data.length > wanted + data.length - wanted + else + data.length + end + @n_bytes += will_take + + if @n_bytes == 25 + set_line_mode( data[will_take..-1] ) + end + end + def receive_line ln + @headers << ln + end + end + def test_throw_back + testdata = "Line\n" * 10 + + a = ThrowBack.new + a.receive_data testdata + assert_equal( ["Line"] * 5, a.headers ) + + a = ThrowBack.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + assert_equal( ["Line"] * 5, a.headers ) + end + + # Test multi-character line delimiters. + # Also note that the test data has a "tail" with no delimiter, that will be + # discarded, but cf. the BinaryTail test. + # TODO!!! This test doesn't work in the byte-by-byte case. + class Multichar + include EM::Protocols::LineText2 + attr_reader :lines + def initialize *args + super + @lines = [] + set_delimiter "012" + end + def receive_line ln + @lines << ln + end + end + def test_multichar + testdata = "Line012Line012Line012Line" + + a = Multichar.new + a.receive_data testdata + assert_equal( ["Line"]*3, a.lines ) + + a = Multichar.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + # DOESN'T WORK in this case. Multi-character delimiters are broken. + #assert_equal( ["Line"]*3, a.lines ) + end + + # Test a binary "tail," when a sized binary transfer doesn't complete because + # of an unbind. We get a partial result. + class BinaryTail + include EM::Protocols::LineText2 + attr_reader :data + def initialize *args + super + @data = "" + set_text_mode 1000 + end + def receive_binary_data data + # we expect to get all the data in one chunk, even in the byte-by-byte case, + # because sized transfers by definition give us exactly one call to + # #receive_binary_data. + @data = data + end + end + def test_binary_tail + testdata = "0" * 500 + + a = BinaryTail.new + a.receive_data testdata + a.unbind + assert_equal( "0" * 500, a.data ) + + a = BinaryTail.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + a.unbind + assert_equal( "0" * 500, a.data ) + end + + + # Test an end-of-binary call. Arrange to receive binary data but don't bother counting it + # as it comes. Rely on getting receive_end_of_binary_data to signal the transition back to + # line mode. + # At the present time, this isn't strictly necessary with sized binary chunks because by + # definition we accumulate them and make exactly one call to receive_binary_data, but + # we may want to support a mode in the future that would break up large chunks into multiple + # calls. + class LazyBinary + include EM::Protocols::LineText2 + attr_reader :data, :end + def initialize *args + super + @data = "" + set_text_mode 1000 + end + def receive_binary_data data + # we expect to get all the data in one chunk, even in the byte-by-byte case, + # because sized transfers by definition give us exactly one call to + # #receive_binary_data. + @data = data + end + def receive_end_of_binary_data + @end = true + end + end + def test_receive_end_of_binary_data + testdata = "_" * 1000 + a = LazyBinary.new + testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) } + assert_equal( "_" * 1000, a.data ) + assert( a.end ) + end + + + # This tests a bug fix in which calling set_text_mode failed when called + # inside receive_binary_data. + # + class BinaryPair + include EM::Protocols::LineText2 + attr_reader :sizes + def initialize *args + super + set_text_mode 1 + @sizes = [] + end + def receive_binary_data dt + @sizes << dt.length + set_text_mode( (dt.length == 1) ? 2 : 1 ) + end + end + def test_binary_pairs + test_data = "123" * 5 + a = BinaryPair.new + a.receive_data test_data + assert_equal( [1,2,1,2,1,2,1,2,1,2], a.sizes ) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_many_fds.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_many_fds.rb new file mode 100644 index 0000000..7c126dc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_many_fds.rb @@ -0,0 +1,22 @@ +require 'em_test_helper' +require 'socket' + +class TestManyFDs < Test::Unit::TestCase + def setup + @port = next_port + end + + def test_connection_class_cache + mod = Module.new + a = nil + Process.setrlimit(Process::RLIMIT_NOFILE, 4096) rescue nil + EM.run { + EM.start_server '127.0.0.1', @port, mod + 1100.times do + a = EM.connect '127.0.0.1', @port, mod + assert_kind_of EM::Connection, a + end + EM.stop + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_next_tick.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_next_tick.rb new file mode 100644 index 0000000..9b60359 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_next_tick.rb @@ -0,0 +1,104 @@ +require 'em_test_helper' + +class TestNextTick < Test::Unit::TestCase + + def test_tick_arg + pr = proc {EM.stop} + EM.run { + EM.next_tick pr + } + assert true + end + + def test_tick_block + EM.run { + EM.next_tick {EM.stop} + } + assert true + end + + # This illustrates the solution to a long-standing problem. + # It's now possible to correctly nest calls to EM#run. + # See the source code commentary for EM#run for more info. + # + def test_run_run + EM.run { + EM.run { + EM.next_tick {EM.stop} + } + } + end + + def test_pre_run_queue + x = false + EM.next_tick { EM.stop; x = true } + EM.run { EM.add_timer(0.01) { EM.stop } } + assert x + end + + def test_cleanup_after_stop + x = true + EM.run{ + EM.next_tick{ + EM.stop + EM.next_tick{ x=false } + } + } + EM.run{ + EM.next_tick{ EM.stop } + } + assert x + end + + # We now support an additional parameter for EM#run. + # You can pass two procs to EM#run now. The first is executed as the normal + # run block. The second (if given) is scheduled for execution after the + # reactor loop completes. + # The reason for supporting this is subtle. There has always been an expectation + # that EM#run doesn't return until after the reactor loop ends. But now it's + # possible to nest calls to EM#run, which means that a nested call WILL + # RETURN. In order to write code that will run correctly either way, it's + # recommended to put any code which must execute after the reactor completes + # in the second parameter. + # + def test_run_run_2 + a = proc {EM.stop} + b = proc {assert true} + EM.run a, b + end + + + # This illustrates that EM#run returns when it's called nested. + # This isn't a feature, rather it's something to be wary of when writing code + # that must run correctly even if EM#run is called while a reactor is already + # running. + def test_run_run_3 + a = [] + EM.run { + EM.run proc {EM.stop}, proc {a << 2} + a << 1 + } + assert_equal( [1,2], a ) + end + + + def test_schedule_on_reactor_thread + x = false + EM.run do + EM.schedule { x = true } + EM.stop + end + assert x + end + + def test_schedule_from_thread + x = false + EM.run do + Thread.new { EM.schedule { x = true } }.join + assert !x + EM.next_tick { EM.stop } + end + assert x + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_object_protocol.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_object_protocol.rb new file mode 100644 index 0000000..b1287ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_object_protocol.rb @@ -0,0 +1,36 @@ +require 'em_test_helper' + +class TestObjectProtocol < Test::Unit::TestCase + module Server + include EM::P::ObjectProtocol + def post_init + send_object :hello=>'world' + end + def receive_object obj + $server = obj + EM.stop + end + end + + module Client + include EM::P::ObjectProtocol + def receive_object obj + $client = obj + send_object 'you_said'=>obj + end + end + + def setup + @port = next_port + end + + def test_send_receive + EM.run{ + EM.start_server "127.0.0.1", @port, Server + EM.connect "127.0.0.1", @port, Client + } + + assert($client == {:hello=>'world'}) + assert($server == {'you_said'=>{:hello=>'world'}}) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pause.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pause.rb new file mode 100644 index 0000000..d078a77 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pause.rb @@ -0,0 +1,107 @@ +require 'em_test_helper' + +class TestPause < Test::Unit::TestCase + if EM.respond_to? :pause_connection + def setup + @port = next_port + end + + def teardown + assert(!EM.reactor_running?) + end + + def test_pause_resume + server = nil + + s_rx = c_rx = 0 + + test_server = Module.new do + define_method :post_init do + server = self + end + + define_method :receive_data do |data| + s_rx += 1 + + EM.add_periodic_timer(0.01) { send_data 'hi' } + send_data 'hi' + + # pause server, now no outgoing data will actually + # be sent and no more incoming data will be received + pause + end + end + + test_client = Module.new do + def post_init + EM.add_periodic_timer(0.01) do + send_data 'hello' + end + end + + define_method :receive_data do |data| + c_rx += 1 + end + end + + EM.run do + EM.start_server "127.0.0.1", @port, test_server + EM.connect "127.0.0.1", @port, test_client + + EM.add_timer(0.05) do + assert_equal 1, s_rx + assert_equal 0, c_rx + assert server.paused? + + # resume server, queued outgoing and incoming data will be flushed + server.resume + + assert !server.paused? + + EM.add_timer(0.05) do + assert server.paused? + assert s_rx > 1 + assert c_rx > 0 + EM.stop + end + end + end + end + + def test_pause_in_receive_data + incoming = [] + + test_server = Module.new do + define_method(:receive_data) do |data| + incoming << data + pause + EM.add_timer(0.5){ close_connection } + end + define_method(:unbind) do + EM.stop + end + end + + buf = 'a' * 1024 + + EM.run do + EM.start_server "127.0.0.1", @port, test_server + cli = EM.connect "127.0.0.1", @port + 128.times do + cli.send_data buf + end + end + + assert_equal 1, incoming.size + assert incoming[0].bytesize > buf.bytesize + assert incoming[0].bytesize < buf.bytesize * 128 + end + else + warn "EM.pause_connection not implemented, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests + def test_em_pause_connection_not_implemented + assert true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pending_connect_timeout.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pending_connect_timeout.rb new file mode 100644 index 0000000..a3f7fa4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pending_connect_timeout.rb @@ -0,0 +1,52 @@ +require 'em_test_helper' + +class TestPendingConnectTimeout < Test::Unit::TestCase + + if EM.respond_to? :get_pending_connect_timeout + def test_default + EM.run { + c = EM.connect("127.0.0.1", 54321) + assert_equal 20.0, c.pending_connect_timeout + EM.stop + } + end + + def test_set_and_get + EM.run { + c = EM.connect("127.0.0.1", 54321) + c.pending_connect_timeout = 2.5 + assert_equal 2.5, c.pending_connect_timeout + EM.stop + } + end + + def test_for_real + start, finish = nil + + timeout_handler = Module.new do + define_method :unbind do + finish = EM.current_time + EM.stop + end + end + + EM.run { + setup_timeout + EM.heartbeat_interval = 0.1 + start = EM.current_time + c = EM.connect('192.0.2.0', 54321, timeout_handler) + c.pending_connect_timeout = 0.2 + } + + assert_in_delta(0.2, (finish - start), 0.1) + end + else + warn "EM.pending_connect_timeout not implemented, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests + def test_em_pending_connect_timeout_not_implemented + assert true + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pool.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pool.rb new file mode 100644 index 0000000..f859a9d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pool.rb @@ -0,0 +1,196 @@ +require 'em_test_helper' + +class TestPool < Test::Unit::TestCase + def pool + @pool ||= EM::Pool.new + end + + def go + EM.run { yield } + end + + def stop + EM.stop + end + + def deferrable + @deferrable ||= EM::DefaultDeferrable.new + end + + def test_supports_more_work_than_resources + ran = false + go do + pool.perform do + ran = true + deferrable + end + stop + end + assert_equal false, ran + go do + pool.add :resource + stop + end + assert_equal true, ran + end + + def test_reques_resources_on_error + pooled_res, pooled_res2 = nil + pool.add :res + go do + pool.perform do |res| + pooled_res = res + deferrable + end + stop + end + deferrable.fail + go do + pool.perform do |res| + pooled_res2 = res + deferrable + end + stop + end + assert_equal :res, pooled_res + assert_equal pooled_res, pooled_res2 + end + + def test_supports_custom_on_error + eres = nil + pool.on_error do |res| + eres = res + end + performs = [] + pool.add :res + go do + pool.perform do |res| + performs << res + deferrable + end + pool.perform do |res| + performs << res + deferrable + end + deferrable.fail + stop + end + assert_equal :res, eres + # manual requeues required when error handler is installed: + assert_equal 1, performs.size + assert_equal :res, performs.first + end + + def test_catches_successful_deferrables + performs = [] + pool.add :res + go do + pool.perform { |res| performs << res; deferrable } + pool.perform { |res| performs << res; deferrable } + stop + end + assert_equal [:res], performs + deferrable.succeed + go { stop } + assert_equal [:res, :res], performs + end + + def test_prunes_locked_and_removed_resources + performs = [] + pool.add :res + deferrable.succeed + go do + pool.perform { |res| performs << res; pool.remove res; deferrable } + pool.perform { |res| performs << res; pool.remove res; deferrable } + stop + end + assert_equal [:res], performs + end + + # Contents is only to be used for inspection of the pool! + def test_contents + pool.add :res + assert_equal [:res], pool.contents + # Assert that modifying the contents list does not affect the pools + # contents. + pool.contents.delete(:res) + assert_equal [:res], pool.contents + end + + def test_contents_when_perform_errors_and_on_error_is_not_set + pool.add :res + assert_equal [:res], pool.contents + + pool.perform do |r| + d = EM::DefaultDeferrable.new + d.fail + d + end + + EM.run { EM.next_tick { EM.stop } } + + assert_equal [:res], pool.contents + end + + def test_contents_when_perform_errors_and_on_error_is_set + pool.add :res + res = nil + pool.on_error do |r| + res = r + end + assert_equal [:res], pool.contents + + pool.perform do |r| + d = EM::DefaultDeferrable.new + d.fail 'foo' + d + end + + EM.run { EM.next_tick { EM.stop } } + + assert_equal :res, res + assert_equal [], pool.contents + end + + def test_num_waiting + pool.add :res + assert_equal 0, pool.num_waiting + pool.perform { |r| EM::DefaultDeferrable.new } + assert_equal 0, pool.num_waiting + 10.times { pool.perform { |r| EM::DefaultDeferrable.new } } + EM.run { EM.next_tick { EM.stop } } + assert_equal 10, pool.num_waiting + end + + def test_exceptions_in_the_work_block_bubble_up_raise_and_fail_the_resource + pool.add :res + + res = nil + pool.on_error { |r| res = r } + pool.perform { raise 'boom' } + + assert_raises(RuntimeError) do + EM.run { EM.next_tick { EM.stop } } + end + + assert_equal [], pool.contents + assert_equal :res, res + end + + def test_removed_list_does_not_leak_on_errors + pool.add :res + + pool.on_error do |r| + # This is actually the wrong thing to do, and not required, but some users + # might do it. When they do, they would find that @removed would cause a + # slow leak. + pool.remove r + end + + pool.perform { d = EM::DefaultDeferrable.new; d.fail; d } + + EM.run { EM.next_tick { EM.stop } } + assert_equal [], pool.instance_variable_get(:@removed) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_process_watch.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_process_watch.rb new file mode 100644 index 0000000..6e0c49a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_process_watch.rb @@ -0,0 +1,50 @@ +require 'em_test_helper' + +if EM.kqueue? + class TestProcessWatch < Test::Unit::TestCase + module ParentProcessWatcher + def process_forked + $forked = true + end + end + + module ChildProcessWatcher + def process_exited + $exited = true + end + def unbind + $unbind = true + EM.stop + end + end + + def setup + EM.kqueue = true + end + + def teardown + EM.kqueue = false + end + + def test_events + omit_if(rbx?) + omit_if(jruby?) + EM.run{ + # watch ourselves for a fork notification + EM.watch_process(Process.pid, ParentProcessWatcher) + $fork_pid = fork{ sleep } + child = EM.watch_process($fork_pid, ChildProcessWatcher) + $pid = child.pid + + EM.add_timer(0.2){ + Process.kill('TERM', $fork_pid) + } + } + + assert_equal($pid, $fork_pid) + assert($forked) + assert($exited) + assert($unbind) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_processes.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_processes.rb new file mode 100644 index 0000000..dd03cf0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_processes.rb @@ -0,0 +1,128 @@ +require 'em_test_helper' + +class TestProcesses < Test::Unit::TestCase + + if !windows? && !jruby? + + # EM::DeferrableChildProcess is a sugaring of a common use-case + # involving EM::popen. + # Call the #open method on EM::DeferrableChildProcess, passing + # a command-string. #open immediately returns an EM::Deferrable + # object. It also schedules the forking of a child process, which + # will execute the command passed to #open. + # When the forked child terminates, the Deferrable will be signalled + # and execute its callbacks, passing the data that the child process + # wrote to stdout. + # + def test_deferrable_child_process + ls = "" + EM.run { + d = EM::DeferrableChildProcess.open( "ls -ltr" ) + d.callback {|data_from_child| + ls = data_from_child + EM.stop + } + } + assert( ls.length > 0) + end + + def setup + $out = nil + $status = nil + end + + def test_em_system + EM.run{ + EM.system('ls'){ |out,status| $out, $status = out, status; EM.stop } + } + + assert( $out.length > 0 ) + assert_equal(0, $status.exitstatus) + assert_kind_of(Process::Status, $status) + end + + def test_em_system_pid + $pids = [] + + EM.run{ + $pids << EM.system('echo hi', proc{ |out,status|$pids << status.pid; EM.stop }) + } + + assert_equal $pids[0], $pids[1] + end + + def test_em_system_with_proc + EM.run{ + EM.system('ls', proc{ |out,status| $out, $status = out, status; EM.stop }) + } + + assert( $out.length > 0 ) + assert_equal(0, $status.exitstatus) + assert_kind_of(Process::Status, $status) + end + + def test_em_system_with_two_procs + EM.run{ + EM.system('sh', proc{ |process| + process.send_data("echo hello\n") + process.send_data("exit\n") + }, proc{ |out,status| + $out = out + $status = status + EM.stop + }) + } + + assert_equal("hello\n", $out) + end + + def test_em_system_cmd_arguments + EM.run{ + EM.system('echo', '1', '2', 'version', proc{ |process| + }, proc{ |out,status| + $out = out + $status = status + EM.stop + }) + } + + assert_match(/1 2 version/i, $out) + end + + def test_em_system_spaced_arguments + EM.run{ + EM.system('ruby', '-e', 'puts "hello"', proc{ |out,status| + $out = out + EM.stop + }) + } + + assert_equal("hello\n", $out) + end + + def test_em_popen_pause_resume + c_rx = 0 + + test_client = Module.new do + define_method :receive_data do |data| + c_rx += 1 + pause + EM.add_timer(0.5) { EM.stop } + end + end + + EM.run do + EM.popen('echo 1', test_client) + end + + assert_equal 1, c_rx + end + else + warn "EM.popen not implemented, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests + def test_em_popen_unsupported + assert true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_proxy_connection.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_proxy_connection.rb new file mode 100644 index 0000000..11c0fb4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_proxy_connection.rb @@ -0,0 +1,180 @@ +require 'em_test_helper' + +class TestProxyConnection < Test::Unit::TestCase + + if EM.respond_to?(:start_proxy) + module ProxyConnection + def initialize(client, request) + @client, @request = client, request + end + + def post_init + EM::enable_proxy(self, @client) + end + + def connection_completed + EM.next_tick { + send_data @request + } + end + + def proxy_target_unbound + $unbound_early = true + EM.stop + end + + def unbind + $proxied_bytes = self.get_proxied_bytes + @client.close_connection_after_writing + end + end + + module PartialProxyConnection + def initialize(client, request, length) + @client, @request, @length = client, request, length + end + + def post_init + EM::enable_proxy(self, @client, 0, @length) + end + + def receive_data(data) + $unproxied_data = data + @client.send_data(data) + end + + def connection_completed + EM.next_tick { + send_data @request + } + end + + def proxy_target_unbound + $unbound_early = true + EM.stop + end + + def proxy_completed + $proxy_completed = true + end + + def unbind + @client.close_connection_after_writing + end + end + + module Client + def connection_completed + send_data "EM rocks!" + end + + def receive_data(data) + $client_data = data + end + + def unbind + EM.stop + end + end + + module Client2 + include Client + def unbind; end + end + + module Server + def receive_data(data) + send_data "I know!" if data == "EM rocks!" + close_connection_after_writing + end + end + + module ProxyServer + def initialize port + @port = port + end + + def receive_data(data) + @proxy = EM.connect("127.0.0.1", @port, ProxyConnection, self, data) + end + end + + module PartialProxyServer + def initialize port + @port = port + end + + def receive_data(data) + EM.connect("127.0.0.1", @port, PartialProxyConnection, self, data, 1) + end + end + + module EarlyClosingProxy + def initialize port + @port = port + end + + def receive_data(data) + EM.connect("127.0.0.1", @port, ProxyConnection, self, data) + close_connection + end + end + + def setup + @port = next_port + @proxy_port = next_port + end + + def test_proxy_connection + EM.run { + EM.start_server("127.0.0.1", @port, Server) + EM.start_server("127.0.0.1", @proxy_port, ProxyServer, @port) + EM.connect("127.0.0.1", @proxy_port, Client) + } + + assert_equal("I know!", $client_data) + end + + def test_proxied_bytes + EM.run { + EM.start_server("127.0.0.1", @port, Server) + EM.start_server("127.0.0.1", @proxy_port, ProxyServer, @port) + EM.connect("127.0.0.1", @proxy_port, Client) + } + + assert_equal("I know!", $client_data) + assert_equal("I know!".bytesize, $proxied_bytes) + end + + def test_partial_proxy_connection + EM.run { + EM.start_server("127.0.0.1", @port, Server) + EM.start_server("127.0.0.1", @proxy_port, PartialProxyServer, @port) + EM.connect("127.0.0.1", @proxy_port, Client) + } + + assert_equal("I know!", $client_data) + assert_equal(" know!", $unproxied_data) + assert($proxy_completed) + end + + def test_early_close + $client_data = nil + EM.run { + EM.start_server("127.0.0.1", @port, Server) + EM.start_server("127.0.0.1", @proxy_port, EarlyClosingProxy, @port) + EM.connect("127.0.0.1", @proxy_port, Client2) + } + + assert($unbound_early) + end + else + warn "EM.start_proxy not implemented, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests + def test_em_start_proxy_not_implemented + assert !EM.respond_to?(:start_proxy) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pure.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pure.rb new file mode 100644 index 0000000..8863a8d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_pure.rb @@ -0,0 +1,139 @@ +require 'em_test_helper' + +class TestPure < Test::Unit::TestCase + + def setup + @port = next_port + end + + # These tests are intended to exercise problems that come up in the + # pure-Ruby implementation. However, we DON'T constrain them such that + # they only run in pure-Ruby. These tests need to work identically in + # any implementation. + + #------------------------------------- + + # The EM reactor needs to run down open connections and release other resources + # when it stops running. Make sure this happens even if user code throws a Ruby + # exception. + # If exception handling is incorrect, the second test will fail with a no-bind error + # because the TCP server opened in the first test will not have been closed. + + def test_exception_handling_releases_resources + exception = Class.new(StandardError) + + 2.times do + assert_raises(exception) do + EM.run do + EM.start_server "127.0.0.1", @port + raise exception + end + end + end + end + + # Under some circumstances, the pure Ruby library would emit an Errno::ECONNREFUSED + # exception on certain kinds of TCP connect-errors. + # It's always been something of an open question whether EM should throw an exception + # in these cases but the defined answer has always been to catch it the unbind method. + # With a connect failure, the latter will always fire, but connection_completed will + # never fire. So even though the point is arguable, it's incorrect for the pure Ruby + # version to throw an exception. + module TestConnrefused + def unbind + EM.stop + end + def connection_completed + raise "should never get here" + end + end + + def test_connrefused + assert_nothing_raised do + EM.run { + setup_timeout(2) + EM.connect "127.0.0.1", @port, TestConnrefused + } + end + end + + # Make sure connection_completed gets called as expected with TCP clients. This is the + # opposite of test_connrefused. + # If the test fails, it will hang because EM.stop never gets called. + # + module TestConnaccepted + def connection_completed + EM.stop + end + end + def test_connaccepted + assert_nothing_raised do + EM.run { + EM.start_server "127.0.0.1", @port + EM.connect "127.0.0.1", @port, TestConnaccepted + setup_timeout(1) + } + end + end + + def test_reactor_running + a = false + EM.run { + a = EM.reactor_running? + EM.next_tick {EM.stop} + } + assert a + end + + module TLSServer + def post_init + start_tls + end + + def ssl_handshake_completed + $server_handshake_completed = true + end + + def receive_data(data) + $server_received_data = data + send_data(data) + end + end + + module TLSClient + def post_init + start_tls + end + + def ssl_handshake_completed + $client_handshake_completed = true + end + + def connection_completed + send_data('Hello World!') + end + + def receive_data(data) + $client_received_data = data + close_connection + end + + def unbind + EM.stop_event_loop + end + end + + def test_start_tls + $client_handshake_completed, $server_handshake_completed = false, false + $client_received_data, $server_received_data = nil, nil + EM.run do + EM.start_server("127.0.0.1", 16789, TLSServer) + EM.connect("127.0.0.1", 16789, TLSClient) + end + + assert($client_handshake_completed) + assert($server_handshake_completed) + assert($client_received_data == "Hello World!") + assert($server_received_data == "Hello World!") + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_queue.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_queue.rb new file mode 100644 index 0000000..34278c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_queue.rb @@ -0,0 +1,64 @@ +require 'em_test_helper' + +class TestEMQueue < Test::Unit::TestCase + def test_queue_push + s = 0 + EM.run do + q = EM::Queue.new + q.push(1) + EM.next_tick { s = q.size; EM.stop } + end + assert_equal 1, s + end + + def test_queue_pop + x,y,z = nil + EM.run do + q = EM::Queue.new + q.push(1,2,3) + q.pop { |v| x = v } + q.pop { |v| y = v } + q.pop { |v| z = v; EM.stop } + end + assert_equal 1, x + assert_equal 2, y + assert_equal 3, z + end + + def test_queue_reactor_thread + q = EM::Queue.new + + Thread.new { q.push(1,2,3) }.join + assert q.empty? + EM.run { EM.next_tick { EM.stop } } + assert_equal 3, q.size + + x = nil + Thread.new { q.pop { |v| x = v } }.join + assert_equal nil, x + EM.run { EM.next_tick { EM.stop } } + assert_equal 1, x + end + + def test_num_waiting + q = EM::Queue.new + many = 3 + many.times { q.pop {} } + EM.run { EM.next_tick { EM.stop } } + assert_equal many, q.num_waiting + end + + def test_big_queue + EM.run do + q = EM::Queue.new + 2000.times do |i| + q.push(*0..1000) + q.pop { |v| assert_equal v, i % 1001 } + end + q.pop do + assert_equal 1_999_999, q.size + EM.stop + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_resolver.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_resolver.rb new file mode 100644 index 0000000..58ed5f5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_resolver.rb @@ -0,0 +1,105 @@ +require 'em_test_helper' + +class TestResolver < Test::Unit::TestCase + def test_nameserver + assert_kind_of(String, EM::DNS::Resolver.nameserver) + end + + def test_nameservers + assert_kind_of(Array, EM::DNS::Resolver.nameservers) + end + + def test_hosts + assert_kind_of(Hash, EM::DNS::Resolver.hosts) + + # Make sure that blank or comment lines are skipped + refute(EM::DNS::Resolver.hosts.include? nil) + end + + def test_a + pend('FIXME: this test is broken on Windows') if windows? + + EM.run { + d = EM::DNS::Resolver.resolve "example.com" + d.errback { assert false } + d.callback { |r| + assert r + EM.stop + } + } + end + + def test_bad_host + EM.run { + d = EM::DNS::Resolver.resolve "asdfasasdf" + d.callback { assert false } + d.errback { assert true; EM.stop } + } + end + + def test_garbage + assert_raises( ArgumentError ) { + EM.run { + EM::DNS::Resolver.resolve 123 + } + } + end + + # There isn't a public DNS entry like 'example.com' with an A rrset + def test_a_pair + pend('FIXME: this test is broken on Windows') if windows? + + EM.run { + d = EM::DNS::Resolver.resolve "yahoo.com" + d.errback { |err| assert false, "failed to resolve yahoo.com: #{err}" } + d.callback { |r| + assert_kind_of(Array, r) + assert r.size > 1, "returned #{r.size} results: #{r.inspect}" + EM.stop + } + } + end + + def test_localhost + pend('FIXME: this test is broken on Windows') if windows? + + EM.run { + d = EM::DNS::Resolver.resolve "localhost" + d.errback { assert false } + d.callback { |r| + assert_include(["127.0.0.1", "::1"], r.first) + assert_kind_of(Array, r) + + EM.stop + } + } + end + + def test_timer_cleanup + pend('FIXME: this test is broken on Windows') if windows? + + EM.run { + d = EM::DNS::Resolver.resolve "example.com" + d.errback { |err| assert false, "failed to resolve example.com: #{err}" } + d.callback { |r| + # This isn't a great test, but it's hard to get more canonical + # confirmation that the timer is cancelled + assert_nil(EM::DNS::Resolver.socket.instance_variable_get(:@timer)) + + EM.stop + } + } + end + + def test_failure_timer_cleanup + EM.run { + d = EM::DNS::Resolver.resolve "asdfasdf" + d.callback { assert false } + d.errback { + assert_nil(EM::DNS::Resolver.socket.instance_variable_get(:@timer)) + + EM.stop + } + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_running.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_running.rb new file mode 100644 index 0000000..693b390 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_running.rb @@ -0,0 +1,14 @@ +require 'em_test_helper' + +class TestRunning < Test::Unit::TestCase + def test_running + assert_equal( false, EM::reactor_running? ) + r = false + EM.run { + r = EM::reactor_running? + EM.stop + } + assert_equal( true, r ) + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_sasl.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_sasl.rb new file mode 100644 index 0000000..e80f657 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_sasl.rb @@ -0,0 +1,47 @@ +require 'em_test_helper' + + +class TestSASL < Test::Unit::TestCase + + # SASL authentication is usually done with UNIX-domain sockets, but + # we'll use TCP so this test will work on Windows. As far as the + # protocol handlers are concerned, there's no difference. + + TestUser,TestPsw = "someone", "password" + + class SaslServer < EM::Connection + include EM::Protocols::SASLauth + def validate usr, psw, sys, realm + usr == TestUser and psw == TestPsw + end + end + + class SaslClient < EM::Connection + include EM::Protocols::SASLauthclient + end + + def setup + @port = next_port + end + + def test_sasl + resp = nil + EM.run { + EM.start_server( "127.0.0.1", @port, SaslServer ) + + c = EM.connect( "127.0.0.1", @port, SaslClient ) + d = c.validate?( TestUser, TestPsw ) + d.timeout 1 + d.callback { + resp = true + EM.stop + } + d.errback { + resp = false + EM.stop + } + } + assert_equal( true, resp ) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_send_file.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_send_file.rb new file mode 100644 index 0000000..a784b50 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_send_file.rb @@ -0,0 +1,217 @@ +require 'em_test_helper' +require 'tempfile' + +class TestSendFile < Test::Unit::TestCase + + if EM.respond_to?(:send_file_data) + module TestModule + def initialize filename + @filename = filename + end + + def post_init + send_file_data @filename + close_connection_after_writing + end + end + + module TestClient + def data_to(&blk) + @data_to = blk + end + + def receive_data(data) + @data_to.call(data) if @data_to + end + + def unbind + EM.stop + end + end + + def setup + @file = Tempfile.new("em_test_file") + @filename = @file.path + @port = next_port + end + + def test_send_file + File.open( @filename, "w" ) {|f| + f << ("A" * 5000) + } + + data = '' + + EM.run { + EM.start_server "127.0.0.1", @port, TestModule, @filename + setup_timeout + + EM.connect "127.0.0.1", @port, TestClient do |c| + c.data_to { |d| data << d } + end + } + + assert_equal( "A" * 5000, data ) + end + + # EM::Connection#send_file_data has a strict upper limit on the filesize it will work with. + def test_send_large_file + File.open( @filename, "w" ) {|f| + f << ("A" * 1000000) + } + + data = '' + + assert_raises(RuntimeError) { + EM.run { + EM.start_server "127.0.0.1", @port, TestModule, @filename + setup_timeout + EM.connect "127.0.0.1", @port, TestClient do |c| + c.data_to { |d| data << d } + end + } + } + end + + module StreamTestModule + def initialize filename + @filename = filename + end + + def post_init + EM::Deferrable.future( stream_file_data(@filename)) { + close_connection_after_writing + } + end + end + + module ChunkStreamTestModule + def initialize filename + @filename = filename + end + + def post_init + EM::Deferrable.future( stream_file_data(@filename, :http_chunks=>true)) { + close_connection_after_writing + } + end + end + + def test_stream_file_data + File.open( @filename, "w" ) {|f| + f << ("A" * 1000) + } + + data = '' + + EM.run { + EM.start_server "127.0.0.1", @port, StreamTestModule, @filename + setup_timeout + EM.connect "127.0.0.1", @port, TestClient do |c| + c.data_to { |d| data << d } + end + } + + assert_equal( "A" * 1000, data ) + end + + def test_stream_chunked_file_data + File.open( @filename, "w" ) {|f| + f << ("A" * 1000) + } + + data = '' + + EM.run { + EM.start_server "127.0.0.1", @port, ChunkStreamTestModule, @filename + setup_timeout + EM.connect "127.0.0.1", @port, TestClient do |c| + c.data_to { |d| data << d } + end + } + + assert_equal( "3e8\r\n#{"A" * 1000}\r\n0\r\n\r\n", data ) + end + + module BadFileTestModule + def initialize filename + @filename = filename + end + + def post_init + de = stream_file_data( @filename+".wrong" ) + de.errback {|msg| + send_data msg + close_connection_after_writing + } + end + end + def test_stream_bad_file + data = '' + EM.run { + EM.start_server "127.0.0.1", @port, BadFileTestModule, @filename + setup_timeout(5) + EM.connect "127.0.0.1", @port, TestClient do |c| + c.data_to { |d| data << d } + end + } + + assert_equal( "file not found", data ) + end + else + warn "EM.send_file_data not implemented, skipping tests in #{__FILE__}" + + # Because some rubies will complain if a TestCase class has no tests + def test_em_send_file_data_not_implemented + assert !EM.respond_to?(:send_file_data) + end + end + + begin + require 'fastfilereaderext' + + def test_stream_large_file_data + File.open( @filename, "w" ) {|f| + f << ("A" * 10000) + } + + data = '' + + EM.run { + EM.start_server "127.0.0.1", @port, StreamTestModule, @filename + setup_timeout + EM.connect "127.0.0.1", @port, TestClient do |c| + c.data_to { |d| data << d } + end + } + + assert_equal( "A" * 10000, data ) + end + + def test_stream_large_chunked_file_data + File.open( @filename, "w" ) {|f| + f << ("A" * 100000) + } + + data = '' + + EM.run { + EM.start_server "127.0.0.1", @port, ChunkStreamTestModule, @filename + setup_timeout + EM.connect "127.0.0.1", @port, TestClient do |c| + c.data_to { |d| data << d } + end + } + + expected = [ + "4000\r\n#{"A" * 16384}\r\n" * 6, + "6a0\r\n#{"A" * 0x6a0}\r\n", + "0\r\n\r\n" + ].join + assert_equal( expected, data ) + end + rescue LoadError + warn "require 'fastfilereaderext' failed, skipping tests in #{__FILE__}" + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_servers.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_servers.rb new file mode 100644 index 0000000..2a17050 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_servers.rb @@ -0,0 +1,33 @@ +require 'em_test_helper' +require 'socket' + +class TestServers < Test::Unit::TestCase + + def setup + @port = next_port + end + + def server_alive? + port_in_use?(@port) + end + + def run_test_stop_server + EM.run { + sig = EM.start_server("127.0.0.1", @port) + assert server_alive?, "Server didn't start" + EM.stop_server sig + # Give the server some time to shutdown. + EM.add_timer(0.1) { + assert !server_alive?, "Server didn't stop" + EM.stop + } + } + end + + def test_stop_server + assert !server_alive?, "Port already in use" + 2.times { run_test_stop_server } + assert !server_alive?, "Servers didn't stop" + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_shutdown_hooks.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_shutdown_hooks.rb new file mode 100644 index 0000000..b0e0c5c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_shutdown_hooks.rb @@ -0,0 +1,23 @@ +require 'em_test_helper' + +class TestShutdownHooks < Test::Unit::TestCase + def test_shutdown_hooks + r = false + EM.run { + EM.add_shutdown_hook { r = true } + EM.stop + } + assert_equal( true, r ) + end + + def test_hook_order + r = [] + EM.run { + EM.add_shutdown_hook { r << 2 } + EM.add_shutdown_hook { r << 1 } + EM.stop + } + assert_equal( [1, 2], r ) + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_smtpclient.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_smtpclient.rb new file mode 100644 index 0000000..71ed584 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_smtpclient.rb @@ -0,0 +1,75 @@ +require 'em_test_helper' + +class TestSmtpClient < Test::Unit::TestCase + + Localhost = "127.0.0.1" + Localport = 9801 + + def setup + end + + def teardown + end + + def test_a + # No real tests until we have a server implementation to test against. + # This is what the call looks like, though: + err = nil + EM.run { + d = EM::Protocols::SmtpClient.send :domain=>"example.com", + :host=>Localhost, + :port=>Localport, # optional, defaults 25 + :starttls=>true, + :from=>"sender@example.com", + :to=> ["to_1@example.com", "to_2@example.com"], + :header=> {"Subject" => "This is a subject line"}, + :body=> "This is the body of the email", + :verbose=>true + d.errback {|e| + err = e + EM.stop + } + } + assert(err) + end + + def test_content + err = nil + EM.run { + d = EM::Protocols::SmtpClient.send :domain=>"example.com", + :host=>Localhost, + :port=>Localport, # optional, defaults 25 + :starttls=>true, + :from=>"sender@example.com", + :to=> ["to_1@example.com", "to_2@example.com"], + :content => ["Subject: xxx\r\n\r\ndata\r\n.\r\n"], + :verbose=>true + d.errback {|e| + err = e + EM.stop + } + } + assert(err) + end + + + EM::Protocols::SmtpClient.__send__(:public, :escape_leading_dots) + + def test_escaping + smtp = EM::Protocols::SmtpClient.new :domain => "example.com" + + expectations = { + "Hello\r\n" => "Hello\r\n", + "\r\n.whatever\r\n" => "\r\n..whatever\r\n", + "\r\n.\r\n" => "\r\n..\r\n", + "\r\n.\r\n." => "\r\n..\r\n..", + ".\r\n.\r\n" => "..\r\n..\r\n", + "..\r\n" => "...\r\n" + } + + expectations.each do |input, output| + assert_equal output, smtp.escape_leading_dots(input) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_smtpserver.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_smtpserver.rb new file mode 100644 index 0000000..18c50fe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_smtpserver.rb @@ -0,0 +1,57 @@ +require 'em_test_helper' + +class TestSmtpServer < Test::Unit::TestCase + + # Don't test on port 25. It requires superuser and there's probably + # a mail server already running there anyway. + Localhost = "127.0.0.1" + Localport = 25001 + + # This class is an example of what you need to write in order + # to implement a mail server. You override the methods you are + # interested in. Some, but not all, of these are illustrated here. + # + class Mailserver < EM::Protocols::SmtpServer + + attr_reader :my_msg_body, :my_sender, :my_recipients + + def initialize *args + super + end + def receive_sender sender + @my_sender = sender + #p sender + true + end + def receive_recipient rcpt + @my_recipients ||= [] + @my_recipients << rcpt + true + end + def receive_data_chunk c + @my_msg_body = c.last + end + def connection_ended + EM.stop + end + end + + def test_mail + c = nil + EM.run { + EM.start_server( Localhost, Localport, Mailserver ) {|conn| c = conn} + EM::Timer.new(2) {EM.stop} # prevent hanging the test suite in case of error + EM::Protocols::SmtpClient.send :host=>Localhost, + :port=>Localport, + :domain=>"bogus", + :from=>"me@example.com", + :to=>"you@example.com", + :header=> {"Subject"=>"Email subject line", "Reply-to"=>"me@example.com"}, + :body=>"Not much of interest here." + + } + assert_equal( "Not much of interest here.", c.my_msg_body ) + assert_equal( "", c.my_sender ) + assert_equal( [""], c.my_recipients ) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_sock_opt.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_sock_opt.rb new file mode 100644 index 0000000..60fba35 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_sock_opt.rb @@ -0,0 +1,54 @@ +require 'em_test_helper' +require 'socket' + +class TestSockOpt < Test::Unit::TestCase + def setup + assert(!EM.reactor_running?) + @port = next_port + end + + def teardown + assert(!EM.reactor_running?) + end + + def test_set_sock_opt + omit_if(windows?) + omit_if(!EM.respond_to?(:set_sock_opt)) + + val = nil + test_module = Module.new do + define_method :post_init do + val = set_sock_opt Socket::SOL_SOCKET, Socket::SO_BROADCAST, true + EM.stop + end + end + + EM.run do + EM.start_server '127.0.0.1', @port + EM.connect '127.0.0.1', @port, test_module + end + + assert_equal 0, val + end + + def test_get_sock_opt + omit_if(windows?) + omit_if(!EM.respond_to?(:set_sock_opt)) + + val = nil + test_module = Module.new do + define_method :connection_completed do + val = get_sock_opt Socket::SOL_SOCKET, Socket::SO_ERROR + EM.stop + end + end + + EM.run do + EM.start_server '127.0.0.1', @port + EM.connect '127.0.0.1', @port, test_module + end + + assert_equal "\0\0\0\0", val + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_spawn.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_spawn.rb new file mode 100644 index 0000000..ab0a92f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_spawn.rb @@ -0,0 +1,293 @@ + +require 'em_test_helper' + + + +class TestSpawn < Test::Unit::TestCase + + # Spawn a process that simply stops the reactor. + # Assert that the notification runs after the block that calls it. + # + def test_stop + x = nil + EM.run { + s = EM.spawn {EM.stop} + s.notify + x = true + } + assert x + end + + + # Pass a parameter to a spawned process. + # + def test_parms + val = 5 + EM.run { + s = EM.spawn {|v| val *= v; EM.stop} + s.notify 3 + } + assert_equal( 15, val ) + end + + # Pass multiple parameters to a spawned process. + # + def test_multiparms + val = 5 + EM.run { + s = EM.spawn {|v1,v2| val *= (v1 + v2); EM.stop} + s.notify 3,4 + } + assert_equal( 35, val ) + end + + + # This test demonstrates that a notification does not happen immediately, + # but rather is scheduled sometime after the current code path completes. + # + def test_race + x = 0 + EM.run { + s = EM.spawn {x *= 2; EM.stop} + s.notify + x = 2 + } + assert_equal( 4, x) + end + + + # Spawn a process and notify it 25 times to run fibonacci + # on a pair of global variables. + # + def test_fibonacci + x = 1 + y = 1 + EM.run { + s = EM.spawn {x,y = y,x+y} + 25.times {s.notify} + + t = EM.spawn {EM.stop} + t.notify + } + assert_equal( 121393, x) + assert_equal( 196418, y) + end + + # This one spawns 25 distinct processes, and notifies each one once, + # rather than notifying a single process 25 times. + # + def test_another_fibonacci + x = 1 + y = 1 + EM.run { + 25.times { + s = EM.spawn {x,y = y,x+y} + s.notify + } + + t = EM.spawn {EM.stop} + t.notify + } + assert_equal( 121393, x) + assert_equal( 196418, y) + end + + + # Make a chain of processes that notify each other in turn + # with intermediate fibonacci results. The final process in + # the chain stops the loop and returns the result. + # + def test_fibonacci_chain + a,b = nil + + EM.run { + nextpid = EM.spawn {|x,y| + a,b = x,y + EM.stop + } + + 25.times { + n = nextpid + nextpid = EM.spawn {|x,y| n.notify( y, x+y )} + } + + nextpid.notify( 1, 1 ) + } + + assert_equal( 121393, a) + assert_equal( 196418, b) + end + + + # EM#yield gives a spawed process to yield control to other processes + # (in other words, to stop running), and to specify a different code block + # that will run on its next notification. + # + def test_yield + a = 0 + EM.run { + n = EM.spawn { + a += 10 + EM.yield { + a += 20 + EM.yield { + a += 30 + EM.stop + } + } + } + n.notify + n.notify + n.notify + } + assert_equal( 60, a ) + end + + # EM#yield_and_notify behaves like EM#yield, except that it also notifies the + # yielding process. This may sound trivial, since the yield block will run very + # shortly after with no action by the program, but this actually can be very useful, + # because it causes the reactor core to execute once before the yielding process + # gets control back. So it can be used to allow heavily-used network connections + # to clear buffers, or allow other processes to process their notifications. + # + # Notice in this test code that only a simple notify is needed at the bottom + # of the initial block. Even so, all of the yielded blocks will execute. + # + def test_yield_and_notify + a = 0 + EM.run { + n = EM.spawn { + a += 10 + EM.yield_and_notify { + a += 20 + EM.yield_and_notify { + a += 30 + EM.stop + } + } + } + n.notify + } + assert_equal( 60, a ) + end + + # resume is an alias for notify. + # + def test_resume + EM.run { + n = EM.spawn {EM.stop} + n.resume + } + assert true + end + + # run is an idiomatic alias for notify. + # + def test_run + EM.run { + (EM.spawn {EM.stop}).run + } + assert true + end + + + # Clones the ping-pong example from the Erlang tutorial, in much less code. + # Illustrates that a spawned block executes in the context of a SpawnableObject. + # (Meaning, we can pass self as a parameter to another process that can then + # notify us.) + # + def test_ping_pong + n_pongs = 0 + EM.run { + pong = EM.spawn {|x, ping| + n_pongs += 1 + ping.notify( x-1 ) + } + ping = EM.spawn {|x| + if x > 0 + pong.notify x, self + else + EM.stop + end + } + ping.notify 3 + } + assert_equal( 3, n_pongs ) + end + + # Illustrates that you can call notify inside a notification, and it will cause + # the currently-executing process to be re-notified. Of course, the new notification + # won't run until sometime after the current one completes. + # + def test_self_notify + n = 0 + EM.run { + pid = EM.spawn {|x| + if x > 0 + n += x + notify( x-1 ) + else + EM.stop + end + } + pid.notify 3 + } + assert_equal( 6, n ) + end + + + # Illustrates that the block passed to #spawn executes in the context of a + # SpawnedProcess object, NOT in the local context. This can often be deceptive. + # + class BlockScopeTest + attr_reader :var + def run + # The following line correctly raises a NameError. + # The problem is that the programmer expected the spawned block to + # execute in the local context, but it doesn't. + # + # (EM.spawn { do_something }).notify ### NO! BAD! + + + + # The following line correctly passes self as a parameter to the + # notified process. + # + (EM.spawn {|obj| obj.do_something }).notify(self) + + + + # Here's another way to do it. This works because "myself" is bound + # in the local scope, unlike "self," so the spawned block sees it. + # + myself = self + (EM.spawn { myself.do_something }).notify + + + + # And we end the loop. + # This is a tangential point, but observe that #notify never blocks. + # It merely appends a message to the internal queue of a spawned process + # and returns. As it turns out, the reactor processes notifications for ALL + # spawned processes in the order that #notify is called. So there is a + # reasonable expectation that the process which stops the reactor will + # execute after the previous ones in this method. HOWEVER, this is NOT + # a documented behavior and is subject to change. + # + (EM.spawn {EM.stop}).notify + end + def do_something + @var ||= 0 + @var += 100 + end + end + + def test_block_scope + bs = BlockScopeTest.new + EM.run { + bs.run + } + assert_equal( 200, bs.var ) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_args.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_args.rb new file mode 100644 index 0000000..d337628 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_args.rb @@ -0,0 +1,78 @@ +require "test/unit" +require 'tempfile' + +require 'em_test_helper' + +module EM + def self._set_mocks + class < priv_file) + end + assert_raises(EM::FileNotFoundException) do + conn.start_tls(:cert_chain_file => cert_file) + end + assert_raises(EM::FileNotFoundException) do + conn.start_tls(:private_key_file => priv_file, :cert_chain_file => cert_file) + end + end + + def test_tls_params_file_does_exist + priv_file = Tempfile.new('em_test') + cert_file = Tempfile.new('em_test') + priv_file_path = priv_file.path + cert_file_path = cert_file.path + conn = EM::Connection.new('foo') + params = {:private_key_file => priv_file_path, :cert_chain_file => cert_file_path} + begin + conn.start_tls params + rescue Object + assert(false, 'should not have raised an exception') + end + end +end if EM.ssl? diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_dhparam.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_dhparam.rb new file mode 100644 index 0000000..85f52d2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_dhparam.rb @@ -0,0 +1,84 @@ +require 'em_test_helper' + +class TestSslDhParam < Test::Unit::TestCase + def setup + $dir = File.dirname(File.expand_path(__FILE__)) + '/' + $dhparam_file = File.join($dir, 'dhparam.pem') + end + + module Client + def post_init + start_tls + end + + def ssl_handshake_completed + $client_handshake_completed = true + $client_cipher_name = get_cipher_name + close_connection + end + + def unbind + EM.stop_event_loop + end + end + + module Server + def post_init + start_tls(:dhparam => $dhparam_file, :cipher_list => "DHE,EDH") + end + + def ssl_handshake_completed + $server_handshake_completed = true + $server_cipher_name = get_cipher_name + end + end + + module NoDhServer + def post_init + start_tls(:cipher_list => "DHE,EDH") + end + + def ssl_handshake_completed + $server_handshake_completed = true + $server_cipher_name = get_cipher_name + end + end + + def test_no_dhparam + omit_unless(EM.ssl?) + omit_if(EM.library_type == :pure_ruby) # DH will work with defaults + omit_if(rbx?) + + $client_handshake_completed, $server_handshake_completed = false, false + $server_cipher_name, $client_cipher_name = nil, nil + + EM.run { + EM.start_server("127.0.0.1", 16784, NoDhServer) + EM.connect("127.0.0.1", 16784, Client) + } + + assert(!$client_handshake_completed) + assert(!$server_handshake_completed) + end + + def test_dhparam + omit_unless(EM.ssl?) + omit_if(rbx?) + + $client_handshake_completed, $server_handshake_completed = false, false + $server_cipher_name, $client_cipher_name = nil, nil + + EM.run { + EM.start_server("127.0.0.1", 16784, Server) + EM.connect("127.0.0.1", 16784, Client) + } + + assert($client_handshake_completed) + assert($server_handshake_completed) + + assert($client_cipher_name.length > 0) + assert_equal($client_cipher_name, $server_cipher_name) + + assert_match(/^(DHE|EDH)/, $client_cipher_name) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_ecdh_curve.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_ecdh_curve.rb new file mode 100644 index 0000000..8dc167b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_ecdh_curve.rb @@ -0,0 +1,80 @@ +require 'em_test_helper' + +class TestSslEcdhCurve < Test::Unit::TestCase + module Client + def post_init + start_tls + end + + def ssl_handshake_completed + $client_handshake_completed = true + $client_cipher_name = get_cipher_name + close_connection + end + + def unbind + EM.stop_event_loop + end + end + + module Server + def post_init + start_tls(:ecdh_curve => "prime256v1", :cipher_list => "ECDH") + end + + def ssl_handshake_completed + $server_handshake_completed = true + $server_cipher_name = get_cipher_name + end + end + + module NoCurveServer + def post_init + start_tls(:cipher_list => "ECDH") + end + + def ssl_handshake_completed + $server_handshake_completed = true + $server_cipher_name = get_cipher_name + end + end + + def test_no_ecdh_curve + omit_unless(EM.ssl?) + omit_if(rbx?) + + $client_handshake_completed, $server_handshake_completed = false, false + + EM.run { + EM.start_server("127.0.0.1", 16784, NoCurveServer) + EM.connect("127.0.0.1", 16784, Client) + } + + assert(!$client_handshake_completed) + assert(!$server_handshake_completed) + end + + def test_ecdh_curve + omit_unless(EM.ssl?) + omit_if(EM.library_type == :pure_ruby && RUBY_VERSION < "2.3.0") + omit_if(rbx?) + + $client_handshake_completed, $server_handshake_completed = false, false + $server_cipher_name, $client_cipher_name = nil, nil + + EM.run { + EM.start_server("127.0.0.1", 16784, Server) + EM.connect("127.0.0.1", 16784, Client) + } + + assert($client_handshake_completed) + assert($server_handshake_completed) + + assert($client_cipher_name.length > 0) + assert_equal($client_cipher_name, $server_cipher_name) + + assert_match(/^(AECDH|ECDHE)/, $client_cipher_name) + end + + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_extensions.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_extensions.rb new file mode 100644 index 0000000..0610ba8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_extensions.rb @@ -0,0 +1,49 @@ +require 'em_test_helper' + +require 'socket' +require 'openssl' + +if EM.ssl? + class TestSslExtensions < Test::Unit::TestCase + + module Client + def ssl_handshake_completed + $client_handshake_completed = true + close_connection + end + + def unbind + EM.stop_event_loop + end + + def post_init + start_tls(:ssl_version => :tlsv1, :sni_hostname => 'example.com') + end + end + + module Server + def ssl_handshake_completed + $server_handshake_completed = true + $server_sni_hostname = get_sni_hostname + end + + def post_init + start_tls(:ssl_version => :TLSv1) + end + end + + def test_tlsext_sni_hostname + $server_handshake_completed = false + + EM.run do + EM.start_server("127.0.0.1", 16784, Server) + EM.connect("127.0.0.1", 16784, Client) + end + + assert($server_handshake_completed) + assert_equal('example.com', $server_sni_hostname) + end + end +else + warn "EM built without SSL support, skipping tests in #{__FILE__}" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_methods.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_methods.rb new file mode 100644 index 0000000..c2e5744 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_methods.rb @@ -0,0 +1,65 @@ +require 'em_test_helper' + +class TestSSLMethods < Test::Unit::TestCase + + module ServerHandler + def post_init + start_tls + end + + def ssl_handshake_completed + $server_called_back = true + $server_cert_value = get_peer_cert + $server_cipher_bits = get_cipher_bits + $server_cipher_name = get_cipher_name + $server_cipher_protocol = get_cipher_protocol + end + end + + module ClientHandler + def post_init + start_tls + end + + def ssl_handshake_completed + $client_called_back = true + $client_cert_value = get_peer_cert + $client_cipher_bits = get_cipher_bits + $client_cipher_name = get_cipher_name + $client_cipher_protocol = get_cipher_protocol + EM.stop_event_loop + end + end + + def test_ssl_methods + omit_unless(EM.ssl?) + omit_if(rbx?) + $server_called_back, $client_called_back = false, false + $server_cert_value, $client_cert_value = nil, nil + $server_cipher_bits, $client_cipher_bits = nil, nil + $server_cipher_name, $client_cipher_name = nil, nil + $server_cipher_protocol, $client_cipher_protocol = nil, nil + + EM.run { + EM.start_server("127.0.0.1", 9999, ServerHandler) + EM.connect("127.0.0.1", 9999, ClientHandler) + } + + assert($server_called_back) + assert($client_called_back) + + assert($server_cert_value.is_a?(NilClass)) + assert($client_cert_value.is_a?(String)) + + assert($client_cipher_bits > 0) + assert_equal($client_cipher_bits, $server_cipher_bits) + + assert($client_cipher_name.length > 0) + assert_match(/AES/, $client_cipher_name) + assert_equal($client_cipher_name, $server_cipher_name) + + assert_match(/TLS/, $client_cipher_protocol) + assert_equal($client_cipher_protocol, $server_cipher_protocol) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_protocols.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_protocols.rb new file mode 100644 index 0000000..bcb6824 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_protocols.rb @@ -0,0 +1,246 @@ +require 'em_test_helper' + +require 'socket' +require 'openssl' + +if EM.ssl? + class TestSslProtocols < Test::Unit::TestCase + + module Client + def ssl_handshake_completed + $client_handshake_completed = true + close_connection + end + + def unbind + EM.stop_event_loop + end + end + + module Server + def ssl_handshake_completed + $server_handshake_completed = true + end + end + + module ClientAny + include Client + def post_init + start_tls(:ssl_version => %w(sslv2 sslv3 tlsv1 tlsv1_1 tlsv1_2)) + end + end + + module ClientDefault + include Client + def post_init + start_tls + end + end + + module ClientSSLv3 + include Client + def post_init + start_tls(:ssl_version => %w(SSLv3)) + end + end + + module ServerSSLv3 + include Server + def post_init + start_tls(:ssl_version => %w(SSLv3)) + end + end + + module ServerTLSv1CaseInsensitive + include Server + def post_init + start_tls(:ssl_version => %w(tlsv1)) + end + end + + module ServerAny + include Server + def post_init + start_tls(:ssl_version => %w(sslv2 sslv3 tlsv1 tlsv1_1 tlsv1_2)) + end + end + + module ServerDefault + include Server + def post_init + start_tls + end + end + + module InvalidProtocol + include Client + def post_init + start_tls(:ssl_version => %w(tlsv1 badinput)) + end + end + + def test_invalid_ssl_version + assert_raises(RuntimeError, "Unrecognized SSL/TLS Version: badinput") do + EM.run do + EM.start_server("127.0.0.1", 16784, InvalidProtocol) + EM.connect("127.0.0.1", 16784, InvalidProtocol) + end + end + end + + def test_any_to_v3 + $client_handshake_completed, $server_handshake_completed = false, false + EM.run do + EM.start_server("127.0.0.1", 16784, ServerSSLv3) + EM.connect("127.0.0.1", 16784, ClientAny) + end + + assert($client_handshake_completed) + assert($server_handshake_completed) + end + + def test_case_insensitivity + $client_handshake_completed, $server_handshake_completed = false, false + EM.run do + EM.start_server("127.0.0.1", 16784, ServerTLSv1CaseInsensitive) + EM.connect("127.0.0.1", 16784, ClientAny) + end + + assert($client_handshake_completed) + assert($server_handshake_completed) + end + + def test_v3_to_any + $client_handshake_completed, $server_handshake_completed = false, false + EM.run do + EM.start_server("127.0.0.1", 16784, ServerAny) + EM.connect("127.0.0.1", 16784, ClientSSLv3) + end + + assert($client_handshake_completed) + assert($server_handshake_completed) + end + + def test_v3_to_v3 + $client_handshake_completed, $server_handshake_completed = false, false + EM.run do + EM.start_server("127.0.0.1", 16784, ServerSSLv3) + EM.connect("127.0.0.1", 16784, ClientSSLv3) + end + + assert($client_handshake_completed) + assert($server_handshake_completed) + end + + def test_any_to_any + $client_handshake_completed, $server_handshake_completed = false, false + EM.run do + EM.start_server("127.0.0.1", 16784, ServerAny) + EM.connect("127.0.0.1", 16784, ClientAny) + end + + assert($client_handshake_completed) + assert($server_handshake_completed) + end + + def test_default_to_default + $client_handshake_completed, $server_handshake_completed = false, false + EM.run do + EM.start_server("127.0.0.1", 16784, ServerDefault) + EM.connect("127.0.0.1", 16784, ClientDefault) + end + + assert($client_handshake_completed) + assert($server_handshake_completed) + end + + module ServerV3StopAfterHandshake + def post_init + start_tls(:ssl_version => %w(SSLv3)) + end + + def ssl_handshake_completed + $server_handshake_completed = true + EM.stop_event_loop + end + end + + module ServerTLSv1StopAfterHandshake + def post_init + start_tls(:ssl_version => %w(TLSv1)) + end + + def ssl_handshake_completed + $server_handshake_completed = true + EM.stop_event_loop + end + end + + def test_v3_with_external_client + $server_handshake_completed = false + EM.run do + setup_timeout(2) + EM.start_server("127.0.0.1", 16784, ServerV3StopAfterHandshake) + EM.defer do + sock = TCPSocket.new("127.0.0.1", 16784) + ctx = OpenSSL::SSL::SSLContext.new + ctx.ssl_version = :SSLv3_client + ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) + ssl.connect + ssl.close rescue nil + sock.close rescue nil + end + end + + assert($server_handshake_completed) + end + + def test_tlsv1_with_external_client + $server_handshake_completed = false + EM.run do + setup_timeout(2) + EM.start_server("127.0.0.1", 16784, ServerTLSv1StopAfterHandshake) + EM.defer do + sock = TCPSocket.new("127.0.0.1", 16784) + ctx = OpenSSL::SSL::SSLContext.new + ctx.ssl_version = :TLSv1_client + ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) + ssl.connect + ssl.close rescue nil + sock.close rescue nil + end + end + + assert($server_handshake_completed) + end + + def test_tlsv1_required_with_external_client + $server_handshake_completed = false + + EM.run do + n = 0 + EM.add_periodic_timer(0.5) do + n += 1 + (EM.stop rescue nil) if n == 2 + end + EM.start_server("127.0.0.1", 16784, ServerTLSv1StopAfterHandshake) + EM.defer do + sock = TCPSocket.new("127.0.0.1", 16784) + ctx = OpenSSL::SSL::SSLContext.new + ctx.ssl_version = :SSLv3_client + ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) + assert_raise OpenSSL::SSL::SSLError do + ssl.connect + end + ssl.close rescue nil + sock.close rescue nil + EM.stop rescue nil + end + end + + assert(!$server_handshake_completed) + end + end +else + warn "EM built without SSL support, skipping tests in #{__FILE__}" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_verify.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_verify.rb new file mode 100644 index 0000000..a6d8fca --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ssl_verify.rb @@ -0,0 +1,128 @@ +require 'em_test_helper' + +class TestSslVerify < Test::Unit::TestCase + def setup + $dir = File.dirname(File.expand_path(__FILE__)) + '/' + $cert_from_file = File.read($dir+'client.crt') + end + + module ClientNoCert + def connection_completed + start_tls() + end + + def ssl_handshake_completed + $client_handshake_completed = true + close_connection + end + + def unbind + EM.stop_event_loop + end + end + + module Client + def connection_completed + start_tls(:private_key_file => $dir+'client.key', :cert_chain_file => $dir+'client.crt') + end + + def ssl_handshake_completed + $client_handshake_completed = true + close_connection + end + + def unbind + EM.stop_event_loop + end + end + + module AcceptServer + def post_init + start_tls(:verify_peer => true) + end + + def ssl_verify_peer(cert) + $cert_from_server = cert + true + end + + def ssl_handshake_completed + $server_handshake_completed = true + end + end + + module DenyServer + def post_init + start_tls(:verify_peer => true) + end + + def ssl_verify_peer(cert) + $cert_from_server = cert + # Do not accept the peer. This should now cause the connection to shut down without the SSL handshake being completed. + false + end + + def ssl_handshake_completed + $server_handshake_completed = true + end + end + + module FailServerNoPeerCert + def post_init + start_tls(:verify_peer => true, :fail_if_no_peer_cert => true) + end + + def ssl_verify_peer(cert) + raise "Verify peer should not get called for a client without a certificate" + end + + def ssl_handshake_completed + $server_handshake_completed = true + end + end + + def test_fail_no_peer_cert + omit_unless(EM.ssl?) + omit_if(rbx?) + + $client_handshake_completed, $server_handshake_completed = false, false + + EM.run { + EM.start_server("127.0.0.1", 16784, FailServerNoPeerCert) + EM.connect("127.0.0.1", 16784, ClientNoCert) + } + + assert(!$client_handshake_completed) + assert(!$server_handshake_completed) + end + + def test_accept_server + omit_unless(EM.ssl?) + omit_if(EM.library_type == :pure_ruby) # Server has a default cert chain + omit_if(rbx?) + $client_handshake_completed, $server_handshake_completed = false, false + EM.run { + EM.start_server("127.0.0.1", 16784, AcceptServer) + EM.connect("127.0.0.1", 16784, Client).instance_variable_get("@signature") + } + + assert_equal($cert_from_file, $cert_from_server) + assert($client_handshake_completed) + assert($server_handshake_completed) + end + + def test_deny_server + omit_unless(EM.ssl?) + omit_if(EM.library_type == :pure_ruby) # Server has a default cert chain + omit_if(rbx?) + $client_handshake_completed, $server_handshake_completed = false, false + EM.run { + EM.start_server("127.0.0.1", 16784, DenyServer) + EM.connect("127.0.0.1", 16784, Client) + } + + assert_equal($cert_from_file, $cert_from_server) + assert(!$client_handshake_completed) + assert(!$server_handshake_completed) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_stomp.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_stomp.rb new file mode 100644 index 0000000..53c0502 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_stomp.rb @@ -0,0 +1,38 @@ +require 'em_test_helper' + +class TestStomp < Test::Unit::TestCase + CONTENT_LENGTH_REGEX = /^content-length: (\d+)$/ + + def bytesize(str) + str = str.to_s + size = str.bytesize if str.respond_to?(:bytesize) # bytesize added in 1.9 + size || str.size + end + + class TStomp + include EM::P::Stomp + + def last_sent_content_length + @sent && Integer(@sent[CONTENT_LENGTH_REGEX, 1]) + end + + def send_data(string) + @sent = string + end + end + + def test_content_length_in_bytes + connection = TStomp.new + + queue = "queue" + failure_message = "header content-length is not the byte size of last sent body" + + body = "test" + connection.send queue, body + assert_equal bytesize(body), connection.last_sent_content_length, failure_message + + body = "test\u221A" + connection.send queue, body + assert_equal bytesize(body), connection.last_sent_content_length, failure_message + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_system.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_system.rb new file mode 100644 index 0000000..fbbe2c9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_system.rb @@ -0,0 +1,46 @@ +# coding: utf-8 +require 'em_test_helper' + +class TestSystem < Test::Unit::TestCase + def setup + @filename = File.expand_path("../я манал dump.txt", __FILE__) + @test_data = 'a' * 100 + File.open(@filename, 'w'){|f| f.write(@test_data)} + end + + def test_system + omit_if(windows?) + + result = nil + status = nil + EM.run { + EM.system('cat', @filename){|out, state| + result = out + status = state.exitstatus + EM.stop + } + } + assert_equal(0, status) + assert_equal(@test_data, result) + end + + def test_system_with_string + omit_if(windows?) + + result = nil + status = nil + EM.run { + EM.system("cat '#@filename'"){|out, state| + result = out + status = state.exitstatus + EM.stop + } + } + assert_equal(0, status) + assert_equal(@test_data, result) + end + + def teardown + File.unlink(@filename) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_threaded_resource.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_threaded_resource.rb new file mode 100644 index 0000000..9bb39c6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_threaded_resource.rb @@ -0,0 +1,63 @@ +require 'em_test_helper' + +class TestThreadedResource < Test::Unit::TestCase + def object + @object ||= {} + end + + def resource + @resource = EM::ThreadedResource.new do + object + end + end + + def teardown + resource.shutdown + end + + def test_dispatch_completion + EM.run do + EM.add_timer(3) do + EM.stop + fail 'Resource dispatch timed out' + end + completion = resource.dispatch do |o| + o[:foo] = :bar + :foo + end + completion.callback do |result| + assert_equal :foo, result + EM.stop + end + completion.errback do |error| + EM.stop + fail "Unexpected error: #{error.message}" + end + end + assert_equal :bar, object[:foo] + end + + def test_dispatch_failure + completion = resource.dispatch do |o| + raise 'boom' + end + completion.errback do |error| + assert_kind_of RuntimeError, error + assert_equal 'boom', error.message + end + end + + def test_dispatch_threading + main = Thread.current + resource.dispatch do |o| + o[:dispatch_thread] = Thread.current + end + assert_not_equal main, object[:dispatch_thread] + end + + def test_shutdown + # This test should get improved sometime. The method returning thread is + # NOT an api that will be maintained. + assert !resource.shutdown.alive? + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_tick_loop.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_tick_loop.rb new file mode 100644 index 0000000..39d86b5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_tick_loop.rb @@ -0,0 +1,59 @@ +require "test/unit" +require 'em_test_helper' + +class TestEmTickLoop < Test::Unit::TestCase + def test_em_tick_loop + i = 0 + EM.tick_loop { i += 1; EM.stop if i == 10 } + EM.run { EM.add_timer(1) { EM.stop } } + assert_equal i, 10 + end + + def test_tick_loop_on_stop + t = nil + tick_loop = EM.tick_loop { :stop } + tick_loop.on_stop { t = true } + EM.run { EM.next_tick { EM.stop } } + assert t + end + + def test_start_twice + i = 0 + s = 0 + tick_loop = EM.tick_loop { i += 1; :stop } + tick_loop.on_stop { s += 1; EM.stop } + EM.run { EM.next_tick { EM.stop } } + assert_equal 1, i + assert_equal 1, s + tick_loop.start + EM.run { EM.next_tick { EM.stop } } + assert_equal 2, i + assert_equal 1, s # stop callbacks are only called once + end + + def test_stop + i, s = 0, 0 + tick_loop = EM.tick_loop { i += 1 } + tick_loop.on_stop { s += 1 } + EM.run { EM.next_tick { tick_loop.stop; EM.next_tick { EM.stop } } } + assert tick_loop.stopped? + assert_equal 1, i + assert_equal 1, s + end + + def test_immediate_stops + s = 0 + tick_loop = EM::TickLoop.new { } + tick_loop.on_stop { s += 1 } + tick_loop.on_stop { s += 1 } + assert_equal 2, s + end + + def test_stopped + tick_loop = EM::TickLoop.new { } + assert tick_loop.stopped? + tick_loop.start + assert !tick_loop.stopped? + end + +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_timers.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_timers.rb new file mode 100644 index 0000000..88b3b78 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_timers.rb @@ -0,0 +1,130 @@ +require 'em_test_helper' + +class TestTimers < Test::Unit::TestCase + + def test_timer_with_block + x = false + EM.run { + EM::Timer.new(0) { + x = true + EM.stop + } + } + assert x + end + + def test_timer_with_proc + x = false + EM.run { + EM::Timer.new(0, proc { + x = true + EM.stop + }) + } + assert x + end + + def test_timer_cancel + assert_nothing_raised do + EM.run { + timer = EM::Timer.new(0.01) { flunk "Timer was not cancelled." } + timer.cancel + + EM.add_timer(0.02) { EM.stop } + } + end + end + + def test_periodic_timer + x = 0 + EM.run { + EM::PeriodicTimer.new(0.01) do + x += 1 + EM.stop if x == 4 + end + } + + assert_equal 4, x + end + + def test_add_periodic_timer + x = 0 + EM.run { + t = EM.add_periodic_timer(0.01) do + x += 1 + EM.stop if x == 4 + end + assert t.respond_to?(:cancel) + } + assert_equal 4, x + end + + def test_periodic_timer_cancel + x = 0 + EM.run { + pt = EM::PeriodicTimer.new(0.01) { x += 1 } + pt.cancel + EM::Timer.new(0.02) { EM.stop } + } + assert_equal 0, x + end + + def test_add_periodic_timer_cancel + x = 0 + EM.run { + pt = EM.add_periodic_timer(0.01) { x += 1 } + EM.cancel_timer(pt) + EM.add_timer(0.02) { EM.stop } + } + assert_equal 0, x + end + + def test_periodic_timer_self_cancel + x = 0 + EM.run { + pt = EM::PeriodicTimer.new(0) { + x += 1 + if x == 4 + pt.cancel + EM.stop + end + } + } + assert_equal 4, x + end + + def test_oneshot_timer_large_future_value + large_value = 11948602000 + EM.run { + EM.add_timer(large_value) { EM.stop } + EM.add_timer(0.02) { EM.stop } + } + end + + # This test is only applicable to compiled versions of the reactor. + # Pure ruby and java versions have no built-in limit on the number of outstanding timers. + unless [:pure_ruby, :java].include? EM.library_type + def test_timer_change_max_outstanding + defaults = EM.get_max_timers + EM.set_max_timers(100) + + one_hundred_one_timers = lambda do + 101.times { EM.add_timer(0.01) {} } + EM.stop + end + + assert_raises(RuntimeError) do + EM.run( &one_hundred_one_timers ) + end + + EM.set_max_timers( 101 ) + + assert_nothing_raised do + EM.run( &one_hundred_one_timers ) + end + ensure + EM.set_max_timers(defaults) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ud.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ud.rb new file mode 100644 index 0000000..3559756 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_ud.rb @@ -0,0 +1,8 @@ +require 'em_test_helper' + +class TestUserDefinedEvents < Test::Unit::TestCase + + def test_a + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_unbind_reason.rb b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_unbind_reason.rb new file mode 100644 index 0000000..ff9193e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/eventmachine-1.2.7/tests/test_unbind_reason.rb @@ -0,0 +1,40 @@ +require 'em_test_helper' + +class TestUnbindReason < Test::Unit::TestCase + + class StubConnection < EM::Connection + attr_reader :error + def unbind(reason = nil) + @error = reason + EM.stop + end + end + + # RFC 5737 Address Blocks Reserved for Documentation + def test_connect_timeout + conn = nil + EM.run do + conn = EM.connect '192.0.2.0', 80, StubConnection + conn.pending_connect_timeout = 1 + end + assert_equal Errno::ETIMEDOUT, conn.error + end + + def test_connect_refused + pend('FIXME: this test is broken on Windows') if windows? + conn = nil + EM.run do + conn = EM.connect '127.0.0.1', 12388, StubConnection + end + assert_equal Errno::ECONNREFUSED, conn.error + end + + def test_optional_argument + pend('FIXME: this test is broken on Windows') if windows? + conn = nil + EM.run do + conn = EM.connect '127.0.0.1', 12388, StubConnection + end + assert_equal Errno::ECONNREFUSED, conn.error + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/CHANGELOG.md b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/CHANGELOG.md new file mode 100644 index 0000000..3297e8b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/CHANGELOG.md @@ -0,0 +1,456 @@ +1.17.0 / 2024-06-02 +------------------- + +Fixed: +* Add FFI::AbstractMemory#read_array_of_string . It was defined but not exposed to Ruby nor tested. #1070 + + +1.17.0.rc2 / 2024-04-22 +------------------- + +Fixed: +* Add missing write barriers to StructLayout#initialize causing a segfault with GC.stress. #1079 + + +1.17.0.rc1 / 2024-04-08 +------------------- + +Fixed: +* Fix type definitions on `aarch64-linux`. #1067, #1066 +* Use RB_TEST for `Pointer.autorelease=` . #1065 + So that `false` and `nil` are treated as falsey and anything else as truthy. +* Replace Fixnum by Integer. #1064 + Fixnum is no longer present in the ruby language. +* Update `FFI::NativeType` doc. #1061 +* Store FFI::Type::Mapped of FFI::StrPtrConverter in global instead of custom type map +* Various documentation fixes. #1042 +* Update `FFI::Pointer#==` to return `false` if a pointer is compared to a non-pointer object, which is the expected behavior. #1083 +* Avoid warning about undefined wariable `@ffi_functions` #1085 +* Fix a very unlikely GC bug when using a callback block. # 1089 + +Added: +* Provide binary gems for many platforms. #990 +* Add Windows fat binary gem for Ruby-3.3 +* Add RBS type definitions for many user facing parts of the FFI API. #1042 +* Improve fallback search path logic. #1088 + Respect LD_LIBRARY_PATH and DYLD_LIBRARY_PATH on Macos. +* Update libffi to current git master branch. + +Removed: +* Remove `enum CHAR_ARRAY` which is no longer used. #1063 + + +1.16.3 / 2023-10-04 +------------------- + +Fixed: +* Fix gcc error when building on CentOS 7. #1052 +* Avoid trying to store new DataConverter type in frozen TypeDefs hash. #1057 + + +1.16.2 / 2023-09-25 +------------------- + +Fixed: +* Handle null pointer crash after fork. #1051 + + +1.16.1 / 2023-09-24 +------------------- + +Fixed: +* Fix compiling the builtin libffi. #1049 + + +1.16.0 / 2023-09-23 +------------------- + +Fixed: +* Fix an issue with signed bitmasks when using flags on the most significant bit. #949 +* Fix FFI::Pointer#initialize using NUM2LL instead of NUM2ULL. +* Fix FFI::Type#inspect to properly display the constant name. #1002 +* Use libffi closure allocations on hppa-Linux. #1017 + Previously they would segfault. +* Fix class name of Symbol#inspect. +* Fix MSVC support of libtest. #1028 +* Fix attach_function of functions ending in ? or ! #971 + +Added: +* Convert all C-based classes to TypedData and use write barriers. #994, #995, #996, #997, #998, #999, #1000, #1001, #1003, #1004, #1005, #1006, #1007, #1008, #1009, #1010, #1011, #1012 + This results in less pressure on the garbage collector, since the objects can be promoted to the old generation, which means they only get marked on major GC. +* Implement `ObjectSpace.memsize_of()` of all C-based classes. +* Make FFI Ractor compatible. #1023 + Modules extended per `extend FFI::Library` need to be frozen in order to be used by non-main Ractors. + This can be done by calling `freeze` below of all C interface definitions. + * In a Ractor it's possible to: + * load DLLs and call its functions, access its global variables + * use builtin typedefs + * use and modify ractor local typedefs + * define callbacks + * receive async callbacks from non-ruby threads + * use frozen FFI::Library based modules with all attributes (enums, structs, typedefs, functions, callbacks) + * invoke frozen functions and callbacks defined in the main Ractor + * use FFI::Struct definitions from the main Ractor + * In a Ractor it's impossible to: + * create new FFI::Library based modules + * create new FFI::Struct definitions + * use custom global typedefs + * use non-frozen FFI::Library based modules +* Allow type retrieval of attached functions+variables. #1023 +* Make FFI classes `GC.compact` friendly. #1021 +* Update libffi and disable custom trampoline when using libffi closure allocation. #1020 + This is because libffi changed the way how closures are allocated to static trampolines. +* Add types.conf for loongarch64-linux. #943 +* Add types.conf for sw_64-linux (Shen Wei 64-bit, based on Alpha). #1018 +* Add support for aarch64-windows. #1035 +* Windows: Update LoadLibrary error message to include error code. #1026 +* Allow private release method for FFI::ManagedStruct and FFI::AutoPointer. #1029 +* Add support for passing ABI version to FFI.map_library_name. #963 + This adds the new class FFI::LibraryPath . +* Add support for ruby-3.2 to windows binary gem. #1047 +* Enable debug symbols for `rake compile` builds to ease debugging. #1048 + +Removed: +* Remove allocator of AbstractMemory. #1013 + This disables AbstractMemory.new, which has no practical use. +* Remove unused FFI::SizeTypes. #1022 + + +1.15.5 / 2022-01-10 +------------------- + +Fixed: +* Fix long double argument or return values on 32bit i686. #849 +* FFI::ConstGenerator: avoid usage of the same binary file simultaneously. #929 + +Added: +* Add Windows fat binary gem for Ruby-3.1 + +Removed: +* Remove Windows fat binary gem for Ruby < 2.4 + + +1.15.4 / 2021-09-01 +------------------- + +Fixed: +* Fix build for uClibc. #913 +* Correct module lookup when including `ffi-module` gem. #912 + +Changed: +* Use ruby code of the ffi gem in JRuby-9.2.20+. #915 + + +1.15.3 / 2021-06-16 +------------------- + +Fixed: +* Fix temporary packaging issue with libffi. #904 + + +1.15.2 / 2021-06-16 +------------------- + +Added: +* Add support for Windows MINGW-UCRT build. #903 +* Add `/opt/homebrew/lib/` to fallback search paths to improve homebrew support. #880 #882 + +Changed: +* Regenerate `types.conf` for FreeBSD12 aarch64. #902 + + +1.15.1 / 2021-05-22 +------------------- + +Fixed: +* Append -pthread to linker options. #893 +* Use arm or aarch64 to identify Apple ARM CPU arch. #899 +* Allow overriding `gcc` with the `CC` env var in `const_generator.rb` and `struct_generator.rb`. #897 + + +1.15.0 / 2021-03-05 +------------------- + +Fixed: +* Fix MSVC build +* Fix async callbacks in conjunction with fork(). #884 + +Added: +* Allow to pass callbacks in varargs. #885 +* Name the threads for FFI callback dispatcher and async thread calls for easier debugging. #883 + The name can be retrieved by Thread.name and is shown by Thread.list.inspect etc. + Even gdb shows the thread name on supported operating systems. +* Add types.conf for powerpc64le-linux +* Add types.conf for riscv64-linux +* More release automation of ffi gems + +Changed: +* Switch from rubygems-tasks to bundler/gem_helper + +Removed: +* Remove unused VariadicInvoker#init + + +1.14.2 / 2020-12-21 +------------------- + +Fixed: +* Fix builtin libffi on newer Ubuntu caused by an outdated Makefile.in . #863 + + +1.14.1 / 2020-12-19 +------------------- + +Changed: +* Revert changes to FFI::Pointer#write_string made in ffi-1.14.0. + It breaks compatibilty in a way that can cause hard to find errors. #857 + + +1.14.0 / 2020-12-18 +------------------- + +Added: +* Add types.conf for x86_64-msys, x86_64-haiku, aarch64-openbsd and aarch64-darwin (alias arm64-darwin) +* Add method AbstractMemory#size_limit? . #829 +* Add new extconf option --enable-libffi-alloc which is enabled per default on Apple M1 (arm64-darwin). + +Changed: +* Do NULL pointer check only when array length > 0 . #305 +* Raise an error on an unknown order argument. #830 +* Change FFI::Pointer#write_string to terminate with a NUL byte like other string methods. #805 +* Update bundled libffi to latest master. + +Removed: +* Remove win32/stdint.h and stdbool.h because of copyright issue. #693 + +Fixed: +* Fix possible UTF-8 load error in loader script interpretation. #792 +* Fix segfault on non-array argument to #write_array_of_* +* Fix memory leak in MethodHandle . #815 +* Fix possible segfault in combination with fiddle or other libffi using gems . #835 +* Fix possibility to use ffi ruby gem with JRuby-9.3 . #763 +* Fix a GC issue, when a callback Proc is used on more than 2 callback signatures. #820 + + +1.13.1 / 2020-06-09 +------------------- + +Changed: +* Revert use of `ucrtbase.dll` as default C library on Windows-MINGW. + `ucrtbase.dll` is still used on MSWIN target. #790 +* Test for `ffi_prep_closure_loc()` to make sure we can use this function. + This fixes incorrect use of system libffi on MacOS Mojave (10.14). #787 +* Update types.conf on x86_64-dragonflybsd + + +1.13.0 / 2020-06-01 +------------------- + +Added: +* Add TruffleRuby support. Almost all specs are running on TruffleRuby and succeed. #768 +* Add ruby source files to the java gem. This allows to ship the Ruby library code per platform java gem and add it as a default gem to JRuby. #763 +* Add FFI::Platform::LONG_DOUBLE_SIZE +* Add bounds checks for writing to an inline char[] . #756 +* Add long double as callback return value. #771 +* Update type definitions and add types from stdint.h and stddef.h on i386-windows, x86_64-windows, x86_64-darwin, x86_64-linux, arm-linux, powerpc-linux. #749 +* Add new type definitions for powerpc-openbsd and sparcv9-openbsd. #775, #778 + +Changed: +* Raise required ruby version to >= 2.3. +* Lots of cleanups and improvements in library, specs and benchmarks. +* Fix a lot of compiler warnings at the C-extension +* Fix several install issues on MacOS: + * Look for libffi in SDK paths, since recent versions of macOS removed it from `/usr/include` . #757 + * Fix error `ld: library not found for -lgcc_s.10.4` + * Don't built for i386 architecture as it is deprecated +* Several fixes for MSVC build on Windows. #779 +* Use `ucrtbase.dll` as default C library on Windows instead of old `msvcrt.dll`. #779 +* Update builtin libffi to fix a Powerpc issue with parameters of type long +* Allow unmodified sourcing of (the ruby code of) this gem in JRuby and TruffleRuby as a default gem. #747 +* Improve check to detect if a module has a #find_type method suitable for FFI. This fixes compatibility with stdlib `mkmf` . #776 + +Removed: +* Reject callback with `:string` return type at definition, because it didn't work so far and is not save to use. #751, #782 + + +1.12.2 / 2020-02-01 +------------------- + +* Fix possible segfault at FFI::Struct#[] and []= after GC.compact . #742 + + +1.12.1 / 2020-01-14 +------------------- + +Added: +* Add binary gem support for ruby-2.7 on Windows + + +1.12.0 / 2020-01-14 +------------------- + +Added: +* FFI::VERSION is defined as part of `require 'ffi'` now. + It is no longer necessary to `require 'ffi/version'` . + +Changed: +* Update libffi to latest master. + +Deprecated: +* Overwriting struct layouts is now warned and will be disallowed in ffi-2.0. #734, #735 + + +1.11.3 / 2019-11-25 +------------------- + +Removed: +* Remove support for tainted objects which cause deprecation warnings in ruby-2.7. #730 + + +1.11.2 / 2019-11-11 +------------------- + +Added: +* Add DragonFlyBSD as a platform. #724 + +Changed: +* Sort all types.conf files, so that files and changes are easier to compare. +* Regenerated type conf for freebsd12 and x86_64-linux targets. #722 +* Remove MACOSX_DEPLOYMENT_TARGET that was targeting very old version 10.4. #647 +* Fix library name mangling for non glibc Linux/UNIX. #727 +* Fix compiler warnings raised by ruby-2.7 +* Update libffi to latest master. + + +1.11.1 / 2019-05-20 +------------------- + +Changed: +* Raise required ruby version to >=2.0. #699, #700 +* Fix a possible linker error on ruby < 2.3 on Linux. + + +1.11.0 / 2019-05-17 +------------------- +This version was yanked on 2019-05-20 to fix an install issue on ruby-1.9.3. #700 + +Added: +* Add ability to disable or force use of system libffi. #669 + Use like `gem inst ffi -- --enable-system-libffi` . +* Add ability to call FFI callbacks from outside of FFI call frame. #584 +* Add proper documentation to FFI::Generator and ::Task +* Add gemspec metadata. #696, #698 + +Changed: +* Fix stdcall on Win32. #649, #669 +* Fix load paths for FFI::Generator::Task +* Fix FFI::Pointer#read_string(0) to return a binary String. #692 +* Fix benchmark suite so that it runs on ruby-2.x +* Move FFI::Platform::CPU from C to Ruby. #663 +* Move FFI::StructByReference to Ruby. #681 +* Move FFI::DataConverter to Ruby (#661) +* Various cleanups and improvements of specs and benchmarks + +Removed: +* Remove ruby-1.8 and 1.9 compatibility code. #683 +* Remove unused spec files. #684 + + +1.10.0 / 2019-01-06 +------------------- + +Added: +* Add /opt/local/lib/ to ffi's fallback library search path. #638 +* Add binary gem support for ruby-2.6 on Windows +* Add FreeBSD on AArch64 and ARM support. #644 +* Add FFI::LastError.winapi_error on Windows native or Cygwin. #633 + +Changed: +* Update to rake-compiler-dock-0.7.0 +* Use 64-bit inodes on FreeBSD >= 12. #644 +* Switch time_t and suseconds_t types to long on FreeBSD. #627 +* Make register_t long_long on 64-bit FreeBSD. #644 +* Fix Pointer#write_array_of_type #637 + +Removed: +* Drop binary gem support for ruby-2.0 and 2.1 on Windows + + +1.9.25 / 2018-06-03 +------------------- + +Changed: +* Revert closures via libffi. + This re-adds ClosurePool and fixes compat with SELinux enabled systems. #621 + + +1.9.24 / 2018-06-02 +------------------- + +Security Note: + +This update addresses vulnerability CVE-2018-1000201: DLL loading issue which can be hijacked on Windows OS, when a Symbol is used as DLL name instead of a String. Found by Matthew Bush. + +Added: +* Added a CHANGELOG file +* Add mips64(eb) support, and mips r6 support. (#601) + +Changed: +* Update libffi to latest changes on master. +* Don't search in hardcoded /usr paths on Windows. +* Don't treat Symbol args different to Strings in ffi_lib. +* Make sure size_t is defined in Thread.c. Fixes #609 + + +1.9.23 / 2018-02-25 +------------------- + +Changed: +* Fix unnecessary rebuild of configure in darwin multi arch. Fixes #605 + + +1.9.22 / 2018-02-22 +------------------- + +Changed: +* Update libffi to latest changes on master. +* Update detection of system libffi to match new requirements. Fixes #617 +* Prefer bundled libffi over system libffi on Mac OS. +* Do closures via libffi. This removes ClosurePool and fixes compat with PaX. #540 +* Use a more deterministic gem packaging. +* Fix unnecessary update of autoconf files at gem install. + + +1.9.21 / 2018-02-06 +------------------- + +Added: +* Ruby-2.5 support by Windows binary gems. Fixes #598 +* Add missing win64 types. +* Added support for Bitmask. (#573) +* Add support for MSYS2 (#572) and Sparc64 Linux. (#574) + +Changed: +* Fix read_string to not throw an error on length 0. +* Don't use absolute paths for sh and env. Fixes usage on Adroid #528 +* Use Ruby implementation for `which` for better compat with Windows. Fixes #315 +* Fix compatibility with PPC64LE platform. (#577) +* Normalize sparc64 to sparcv9. (#575) + +Removed: +* Drop Ruby 1.8.7 support (#480) + + +1.9.18 / 2017-03-03 +------------------- + +Added: +* Add compatibility with Ruby-2.4. + +Changed: +* Add missing shlwapi.h include to fix Windows build. +* Avoid undefined behaviour of LoadLibrary() on Windows. #553 + + +1.9.17 / 2017-01-13 +------------------- diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/COPYING b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/COPYING new file mode 100644 index 0000000..7622318 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/COPYING @@ -0,0 +1,49 @@ +Copyright (c) 2008-2013, Ruby FFI project contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of the Ruby FFI project nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +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 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. + +libffi, used by this project, is licensed under the MIT license: + +libffi - Copyright (c) 1996-2011 Anthony Green, Red Hat, Inc and others. +See source files for details. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +``Software''), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/Gemfile b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/Gemfile new file mode 100644 index 0000000..797c34a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/Gemfile @@ -0,0 +1,21 @@ +source 'https://rubygems.org' + +group :development do + gem 'bigdecimal' # necessary on ruby-3.3+ + gem 'bundler', '>= 1.16', '< 3' + gem 'rake', '~> 13.0' + gem 'rake-compiler', '~> 1.1' + gem 'rake-compiler-dock', '~> 1.0.pre' + gem 'rspec', '~> 3.0' +end + +group :doc do + gem 'kramdown' + gem 'yard', '~> 0.9' +end + +group :type_check do + if RUBY_VERSION >= "2.6" && %w[ ruby truffleruby ].include?(RUBY_ENGINE) + gem 'rbs', '~> 3.0' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/LICENSE b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/LICENSE new file mode 100644 index 0000000..20185fd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2008-2016, Ruby FFI project contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of the Ruby FFI project nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +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 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. diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/LICENSE.SPECS b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/LICENSE.SPECS new file mode 100644 index 0000000..5c9ffce --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/LICENSE.SPECS @@ -0,0 +1,22 @@ +Copyright (c) 2008-2012 Ruby-FFI contributors + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/README.md b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/README.md new file mode 100644 index 0000000..0605c81 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/README.md @@ -0,0 +1,137 @@ +# Ruby-FFI https://github.com/ffi/ffi/wiki + +## Description + +Ruby-FFI is a gem for programmatically loading dynamically-linked native +libraries, binding functions within them, and calling those functions +from Ruby code. Moreover, a Ruby-FFI extension works without changes +on CRuby (MRI), JRuby, Rubinius and TruffleRuby. [Discover why you should write your next extension +using Ruby-FFI](https://github.com/ffi/ffi/wiki/why-use-ffi). + +## Features + +* Intuitive DSL +* Supports all C native types +* C structs (also nested), enums and global variables +* Callbacks from C to Ruby +* Automatic garbage collection of native memory +* Usable in Ractor: [How-to-use-FFI-in-Ruby-Ractors](https://github.com/ffi/ffi/wiki/Ractors) + +## Synopsis + +```ruby +require 'ffi' + +module MyLib + extend FFI::Library + ffi_lib 'c' + attach_function :puts, [ :string ], :int +end + +MyLib.puts 'Hello, World using libc!' +``` + +For less minimalistic and more examples you may look at: + +* the `samples/` folder +* the examples on the [wiki](https://github.com/ffi/ffi/wiki) +* the projects using FFI listed on the wiki: https://github.com/ffi/ffi/wiki/projects-using-ffi + +## Requirements + +When installing the gem on CRuby (MRI), you will need: +* A C compiler (e.g., Xcode on macOS, `gcc` or `clang` on everything else) +Optionally (speeds up installation): +* The `libffi` library and development headers - this is commonly in the `libffi-dev` or `libffi-devel` packages + +The ffi gem comes with a builtin libffi version, which is used, when the system libffi library is not available or too old. +Use of the system libffi can be enforced by: +``` +gem install ffi -- --enable-system-libffi # to install the gem manually +bundle config build.ffi --enable-system-libffi # for bundle install +``` +or prevented by `--disable-system-libffi`. + +On Linux systems running with [PaX](https://en.wikipedia.org/wiki/PaX) (Gentoo, Alpine, etc.), FFI may trigger `mprotect` errors. You may need to disable [mprotect](https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Restrict_mprotect.28.29) for ruby (`paxctl -m [/path/to/ruby]`) for the time being until a solution is found. + +On FreeBSD systems pkgconf must be installed for the gem to be able to compile using clang. Install either via packages `pkg install pkgconf` or from ports via `devel/pkgconf`. + +On JRuby and TruffleRuby, there are no requirements to install the FFI gem, and `require 'ffi'` works even without installing the gem (i.e., the gem is preinstalled on these implementations). + +## Installation + +From rubygems: + + [sudo] gem install ffi + +From a Gemfile using git or GitHub + + gem 'ffi', github: 'ffi/ffi', submodules: true + +or from the git repository on github: + + git clone git://github.com/ffi/ffi.git + cd ffi + git submodule update --init --recursive + bundle install + rake install + +### Install options: + +* `--enable-system-libffi` : Force usage of system libffi +* `--disable-system-libffi` : Force usage of builtin libffi +* `--enable-libffi-alloc` : Force closure allocation by libffi +* `--disable-libffi-alloc` : Force closure allocation by builtin method + +## License + +The ffi library is covered by the BSD license, also see the LICENSE file. +The specs are covered by the same license as [ruby/spec](https://github.com/ruby/spec), the MIT license. + +## Credits + +The following people have submitted code, bug reports, or otherwise contributed to the success of this project: + +* Alban Peignier +* Aman Gupta +* Andrea Fazzi +* Andreas Niederl +* Andrew Cholakian +* Antonio Terceiro +* Benoit Daloze +* Brian Candler +* Brian D. Burns +* Bryan Kearney +* Charlie Savage +* Chikanaga Tomoyuki +* Hongli Lai +* Ian MacLeod +* Jake Douglas +* Jean-Dominique Morani +* Jeremy Hinegardner +* Jesús García Sáez +* Joe Khoobyar +* Jurij Smakov +* KISHIMOTO, Makoto +* Kim Burgestrand +* Lars Kanis +* Luc Heinrich +* Luis Lavena +* Matijs van Zuijlen +* Matthew King +* Mike Dalessio +* NARUSE, Yui +* Park Heesob +* Shin Yee +* Stephen Bannasch +* Suraj N. Kurapati +* Sylvain Daubert +* Victor Costan +* beoran@gmail.com +* ctide +* emboss +* hobophobe +* meh +* postmodern +* wycats@gmail.com +* Wayne Meissner diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/Rakefile b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/Rakefile new file mode 100644 index 0000000..376132d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/Rakefile @@ -0,0 +1,206 @@ +require 'rbconfig' +require 'date' +require 'fileutils' +require 'yaml' +require 'rspec/core/rake_task' +require 'rubygems/package_task' +require 'rake/extensiontask' +require_relative "lib/ffi/version" +require_relative "rakelib/ffi_gem_helper" + +BUILD_DIR = "build" +BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION) + +gem_spec = Bundler.load_gemspec('ffi.gemspec') + +RSpec::Core::RakeTask.new(:spec) do |config| + config.rspec_opts = YAML.load_file 'spec/spec.opts' +end + +desc "Build all packages" +task :package => %w[ gem:java gem:native ] + +CLOBBER.include 'lib/ffi/types.conf' +CLOBBER.include 'pkg' +CLOBBER.include 'log' + +CLEAN.include 'build' +CLEAN.include 'conftest.dSYM' +CLEAN.include 'spec/ffi/fixtures/libtest.{dylib,so,dll}' +CLEAN.include 'spec/ffi/fixtures/*.o' +CLEAN.include 'spec/ffi/embed-test/ext/*.{o,def}' +CLEAN.include 'spec/ffi/embed-test/ext/Makefile' +CLEAN.include "pkg/ffi-*-*/" +CLEAN.include 'lib/{2,3}.*' + +# clean all shipped files, that are not in git +CLEAN.include( + gem_spec.files - + `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0").map { |f| File.join("ext/ffi_c/libffi", f) } - + `git ls-files -z`.split("\x0") +) + +task :distclean => :clobber + +desc "Test the extension" +task :test => [ :spec ] + + +namespace :bench do + ITER = ENV['ITER'] ? ENV['ITER'].to_i : 100000 + bench_files = Dir["bench/bench_*.rb"].sort.reject { |f| f == "bench/bench_helper.rb" } + bench_files.each do |bench| + task File.basename(bench, ".rb")[6..-1] => :compile do + sh %{#{Gem.ruby} #{bench} #{ITER}} + end + end + task :all => :compile do + bench_files.each do |bench| + sh %{#{Gem.ruby} #{bench}} + end + end +end + +task 'spec:run' => :compile +task 'spec:specdoc' => :compile + +task :default => :spec + +namespace 'java' do + + java_gem_spec = gem_spec.dup.tap do |s| + s.files.reject! { |f| File.fnmatch?("ext/*", f) } + s.extensions = [] + s.platform = 'java' + end + + Gem::PackageTask.new(java_gem_spec) do |pkg| + pkg.need_zip = true + pkg.need_tar = true + pkg.package_dir = 'pkg' + end +end + +task 'gem:java' => 'java:gem' + +FfiGemHelper.install_tasks +# Register binary gems to be pushed to rubygems.org +Bundler::GemHelper.instance.cross_platforms = %w[ + x86-mingw32 + x64-mingw-ucrt + x64-mingw32 + x86-linux-gnu + x86-linux-musl + x86_64-linux-gnu + x86_64-linux-musl + arm-linux-gnu + arm-linux-musl + aarch64-linux-gnu + aarch64-linux-musl + x86_64-darwin + arm64-darwin +] + +if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx' + require 'rake/extensiontask' + Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext| + ext.name = 'ffi_c' # indicate the name of the extension. + # ext.lib_dir = BUILD_DIR # put binaries into this folder. + ext.tmp_dir = BUILD_DIR # temporary folder used during compilation. + ext.cross_compile = true # enable cross compilation (requires cross compile toolchain) + ext.cross_platform = Bundler::GemHelper.instance.cross_platforms + ext.cross_compiling do |spec| + spec.files.reject! { |path| File.fnmatch?('ext/*', path) } + end + # Enable debug info for 'rake compile' but not for 'gem install' + ext.config_options << "--enable-debug" + + end +else + task :compile do + STDERR.puts "Nothing to compile on #{RUBY_ENGINE}" + end +end + + +namespace "gem" do + task 'prepare' do + require 'rake_compiler_dock' + sh "bundle package --all" + end + + Bundler::GemHelper.instance.cross_platforms.each do |plat| + desc "Build all native binary gems in parallel" + multitask 'native' => plat + + desc "Build the native gem for #{plat}" + task plat => ['prepare', 'build'] do + RakeCompilerDock.sh <<-EOT, platform: plat + #{ "sudo apt-get update && sudo apt-get install -y libltdl-dev &&" if plat !~ /linux/ } + bundle --local && + rake native:#{plat} pkg/#{gem_spec.full_name}-#{plat}.gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=${RUBY_CC_VERSION/:2.4.0/} + EOT + end + end +end + +directory "ext/ffi_c/libffi" +file "ext/ffi_c/libffi/autogen.sh" => "ext/ffi_c/libffi" do + warn "Downloading libffi ..." + sh "git submodule update --init --recursive" +end +task :libffi => "ext/ffi_c/libffi/autogen.sh" + +LIBFFI_GIT_FILES = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0") + +# Generate files which are in the gemspec but not in libffi's git repo by running autogen.sh +gem_spec.files.select do |f| + f =~ /ext\/ffi_c\/libffi\/(.*)/ && !LIBFFI_GIT_FILES.include?($1) +end.each do |f| + file f => "ext/ffi_c/libffi/autogen.sh" do + chdir "ext/ffi_c/libffi" do + sh "sh ./autogen.sh" + end + touch f + if gem_spec.files != Gem::Specification.load('./ffi.gemspec').files + warn "gemspec files have changed -> Please restart rake!" + exit 1 + end + end +end + +# Make sure we have all gemspec files before packaging +task :build => gem_spec.files +task :gem => :build + + +require_relative "lib/ffi/platform" +types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf')) +logfile = File.join(File.dirname(__FILE__), 'types_log') + +task types_conf do |task| + require 'fileutils' + require_relative "lib/ffi/tools/types_generator" + options = {} + FileUtils.mkdir_p(File.dirname(task.name), mode: 0755 ) + File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f| + f.puts FFI::TypesGenerator.generate(options) + end + File.open(logfile, 'w') do |log| + log.puts(types_conf) + end +end + +desc "Create or update type information for platform #{FFI::Platform::NAME}" +task :types_conf => types_conf + +begin + require 'yard' + + namespace :doc do + YARD::Rake::YardocTask.new do |yard| + end + end +rescue LoadError + warn "[warn] YARD unavailable" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/ffi.gemspec b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/ffi.gemspec new file mode 100644 index 0000000..07d549f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/ffi.gemspec @@ -0,0 +1,42 @@ +require File.expand_path("../lib/#{File.basename(__FILE__, '.gemspec')}/version", __FILE__) + +Gem::Specification.new do |s| + s.name = 'ffi' + s.version = FFI::VERSION + s.author = 'Wayne Meissner' + s.email = 'wmeissner@gmail.com' + s.homepage = 'https://github.com/ffi/ffi/wiki' + s.summary = 'Ruby FFI' + s.description = 'Ruby FFI library' + if s.respond_to?(:metadata) + s.metadata['bug_tracker_uri'] = 'https://github.com/ffi/ffi/issues' + s.metadata['changelog_uri'] = 'https://github.com/ffi/ffi/blob/master/CHANGELOG.md' + s.metadata['documentation_uri'] = 'https://github.com/ffi/ffi/wiki' + s.metadata['wiki_uri'] = 'https://github.com/ffi/ffi/wiki' + s.metadata['source_code_uri'] = 'https://github.com/ffi/ffi/' + s.metadata['mailing_list_uri'] = 'http://groups.google.com/group/ruby-ffi' + end + s.files = `git ls-files -z`.split("\x0").reject do |f| + f =~ /^(\.|bench|gen|libtest|nbproject|spec)/ + end + + # Add libffi git files + lfs = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0") + # Add autoconf generated files of libffi + lfs += %w[ compile configure config.guess config.sub install-sh ltmain.sh missing fficonfig.h.in ] + # Add automake generated files of libffi + lfs += `git --git-dir ext/ffi_c/libffi/.git ls-files -z *.am */*.am`.gsub(".am\0", ".in\0").split("\x0") + s.files += lfs.map do |f| + File.join("ext/ffi_c/libffi", f) + end + + s.extensions << 'ext/ffi_c/extconf.rb' + s.rdoc_options = %w[--exclude=ext/ffi_c/.*\.o$ --exclude=ffi_c\.(bundle|so)$] + s.license = 'BSD-3-Clause' + s.require_paths << 'ext/ffi_c' + s.required_ruby_version = '>= 2.5' + s.add_development_dependency 'rake', '~> 13.0' + s.add_development_dependency 'rake-compiler', '~> 1.1' + s.add_development_dependency 'rake-compiler-dock', '~> 1.0' + s.add_development_dependency 'rspec', '~> 2.14.1' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.5/ffi_c.so b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.5/ffi_c.so new file mode 100755 index 0000000..4eb13c5 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.5/ffi_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.6/ffi_c.so b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.6/ffi_c.so new file mode 100755 index 0000000..2903d46 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.6/ffi_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.7/ffi_c.so b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.7/ffi_c.so new file mode 100755 index 0000000..63c884c Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/2.7/ffi_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.0/ffi_c.so b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.0/ffi_c.so new file mode 100755 index 0000000..d63e80e Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.0/ffi_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.1/ffi_c.so b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.1/ffi_c.so new file mode 100755 index 0000000..fe8d250 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.1/ffi_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.2/ffi_c.so b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.2/ffi_c.so new file mode 100755 index 0000000..2f9a924 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.2/ffi_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.3/ffi_c.so b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.3/ffi_c.so new file mode 100755 index 0000000..2b57477 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/3.3/ffi_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi.rb new file mode 100644 index 0000000..3fb20a8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi.rb @@ -0,0 +1,27 @@ +if RUBY_ENGINE == 'ruby' + begin + require RUBY_VERSION.split('.')[0, 2].join('.') + '/ffi_c' + rescue Exception + require 'ffi_c' + end + + require 'ffi/ffi' + +elsif RUBY_ENGINE == 'jruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [9, 2, 20]) >= 0 + JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService") + require 'ffi/ffi' + +elsif RUBY_ENGINE == 'truffleruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [20, 1, 0]) >= 0 + require 'truffleruby/ffi_backend' + require 'ffi/ffi' + +else + # Remove the ffi gem dir from the load path, then reload the internal ffi implementation + $LOAD_PATH.delete(File.dirname(__FILE__)) + $LOAD_PATH.delete(File.join(File.dirname(__FILE__), 'ffi')) + unless $LOADED_FEATURES.nil? + $LOADED_FEATURES.delete(__FILE__) + $LOADED_FEATURES.delete('ffi.rb') + end + require 'ffi.rb' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/abstract_memory.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/abstract_memory.rb new file mode 100644 index 0000000..e0aa221 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/abstract_memory.rb @@ -0,0 +1,44 @@ +# +# Copyright (C) 2020 Lars Kanis +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + + +module FFI + class AbstractMemory + LONG_MAX = FFI::Pointer.new(1).size + private_constant :LONG_MAX + + # Return +true+ if +self+ has a size limit. + # + # @return [Boolean] + def size_limit? + size != LONG_MAX + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/autopointer.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/autopointer.rb new file mode 100644 index 0000000..d93bc45 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/autopointer.rb @@ -0,0 +1,180 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# Copyright (C) 2008 Mike Dalessio +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. + +module FFI + class AutoPointer < Pointer + extend DataConverter + + # @overload initialize(pointer, method) + # @param pointer [Pointer] + # @param method [Method] + # @return [self] + # The passed Method will be invoked at GC time. + # @overload initialize(pointer, proc) + # @param pointer [Pointer] + # @return [self] + # The passed Proc will be invoked at GC time (SEE WARNING BELOW!) + # @note WARNING: passing a proc _may_ cause your pointer to never be + # GC'd, unless you're careful to avoid trapping a reference to the + # pointer in the proc. See the test specs for examples. + # @overload initialize(pointer) + # @param pointer [Pointer] + # @return [self] + # The pointer's release() class method will be invoked at GC time. + # + # @note The safest, and therefore preferred, calling + # idiom is to pass a Method as the second parameter. Example usage: + # + # class PointerHelper + # def self.release(pointer) + # ... + # end + # end + # + # p = AutoPointer.new(other_pointer, PointerHelper.method(:release)) + # + # The above code will cause PointerHelper#release to be invoked at GC time. + # + # @note + # The last calling idiom (only one parameter) is generally only + # going to be useful if you subclass {AutoPointer}, and override + # #release, which by default does nothing. + def initialize(ptr, proc=nil) + raise TypeError, "Invalid pointer" if ptr.nil? || !ptr.kind_of?(Pointer) || + ptr.kind_of?(MemoryPointer) || ptr.kind_of?(AutoPointer) + super(ptr.type_size, ptr) + + @releaser = if proc + if not proc.respond_to?(:call) + raise RuntimeError.new("proc must be callable") + end + Releaser.new(ptr, proc) + + else + if not self.class.respond_to?(:release, true) + raise RuntimeError.new("no release method defined") + end + Releaser.new(ptr, self.class.method(:release)) + end + + ObjectSpace.define_finalizer(self, @releaser) + self + end + + # @return [nil] + # Free the pointer. + def free + @releaser.free + end + + # @param [Boolean] autorelease + # @return [Boolean] +autorelease+ + # Set +autorelease+ property. See {Pointer Autorelease section at Pointer}. + def autorelease=(autorelease) + raise FrozenError.new("can't modify frozen #{self.class}") if frozen? + @releaser.autorelease=(autorelease) + end + + # @return [Boolean] +autorelease+ + # Get +autorelease+ property. See {Pointer Autorelease section at Pointer}. + def autorelease? + @releaser.autorelease + end + + # @abstract Base class for {AutoPointer}'s releasers. + # + # All subclasses of Releaser should define a +#release(ptr)+ method. + # A releaser is an object in charge of release an {AutoPointer}. + class Releaser + attr_accessor :autorelease + + # @param [Pointer] ptr + # @param [#call] proc + # @return [nil] + # A new instance of Releaser. + def initialize(ptr, proc) + @ptr = ptr + @proc = proc + @autorelease = true + end + + # @return [nil] + # Free pointer. + def free + if @ptr + release(@ptr) + @autorelease = false + @ptr = nil + @proc = nil + end + end + + # @param args + # Release pointer if +autorelease+ is set. + def call(*args) + release(@ptr) if @autorelease && @ptr + end + + # Release +ptr+ by using Proc or Method defined at +ptr+ + # {AutoPointer#initialize initialization}. + # + # @param [Pointer] ptr + # @return [nil] + def release(ptr) + @proc.call(ptr) + end + end + + # Return native type of AutoPointer. + # + # Override {DataConverter#native_type}. + # @return [Type::POINTER] + # @raise {RuntimeError} if class does not implement a +#release+ method + def self.native_type + if not self.respond_to?(:release, true) + raise RuntimeError.new("no release method defined for #{self.inspect}") + end + Type::POINTER + end + + # Create a new AutoPointer. + # + # Override {DataConverter#from_native}. + # @overload self.from_native(ptr, ctx) + # @param [Pointer] ptr + # @param ctx not used. Please set +nil+. + # @return [AutoPointer] + def self.from_native(val, ctx) + self.new(val) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/buffer.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/buffer.rb new file mode 100644 index 0000000..449e45b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/buffer.rb @@ -0,0 +1,4 @@ +# +# All the code from this file is now implemented in C. This file remains +# to satisfy any leftover require 'ffi/buffer' in user code +# diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/callback.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/callback.rb new file mode 100644 index 0000000..32d52f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/callback.rb @@ -0,0 +1,4 @@ +# +# All the code from this file is now implemented in C. This file remains +# to satisfy any leftover require 'ffi/callback' in user code +# diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/compat.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/compat.rb new file mode 100644 index 0000000..7569013 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/compat.rb @@ -0,0 +1,43 @@ +# +# Copyright (C) 2023-2023 Lars Kanis +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +module FFI + if defined?(Ractor.make_shareable) + # This is for FFI internal use only. + def self.make_shareable(obj) + Ractor.make_shareable(obj) + end + else + def self.make_shareable(obj) + obj.freeze + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/data_converter.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/data_converter.rb new file mode 100644 index 0000000..7852e7e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/data_converter.rb @@ -0,0 +1,67 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +module FFI + # This module is used to extend somes classes and give then a common API. + # + # Most of methods defined here must be overridden. + module DataConverter + # Get native type. + # + # @overload native_type(type) + # @param [String, Symbol, Type] type + # @return [Type] + # Get native type from +type+. + # + # @overload native_type + # @raise {NotImplementedError} This method must be overridden. + def native_type(type = nil) + if type + @native_type = FFI.find_type(type) + else + native_type = @native_type + unless native_type + raise NotImplementedError, 'native_type method not overridden and no native_type set' + end + native_type + end + end + + # Convert to a native type. + def to_native(value, ctx) + value + end + + # Convert from a native type. + def from_native(value, ctx) + value + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/dynamic_library.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/dynamic_library.rb new file mode 100644 index 0000000..468ce04 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/dynamic_library.rb @@ -0,0 +1,118 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +module FFI + class DynamicLibrary + SEARCH_PATH = [] + + # The following search paths are tried, if the library could not be loaded in the first attempt. + # They are only executed on Macos in the following order: + if FFI::Platform.mac? + + # 1. Try library paths possibly defined in LD_LIBRARY_PATH DYLD_LIBRARY_PATH first. + # This is because dlopen doesn't respect LD_LIBRARY_PATH and DYLD_LIBRARY_PATH is deleted by SIP-protected binaries. + # See here for details: https://github.com/ffi/ffi/issues/923#issuecomment-1872565313 + %w[LD_LIBRARY_PATH DYLD_LIBRARY_PATH].each do |custom_path| + SEARCH_PATH.concat ENV.fetch(custom_path,"").split(File::PATH_SEPARATOR) + end + + # 2. Then on macos/arm64 try /opt/homebrew/lib, since this is a typical standard directory. + # FFI is often used together with homebrew, so that we hardcode the path for arm64 here. + if FFI::Platform::ARCH == 'aarch64' + SEARCH_PATH << '/opt/homebrew/lib' + end + + # 3. Then try typical system directories starting with the /local/ directory first. + # + # /usr/local/lib is used by homebrow on x86_64. + # /opt/local/lib is used by MacPorts and Fink. + # /usr/lib is there, because it was always there. + SEARCH_PATH.concat %w[/opt/local/lib /usr/local/lib /usr/lib] + end + + # On Linux the library lookup paths are usually defined through /etc/ld.so.conf, which can be changed at will with root permissions. + # Also LD_LIBRARY_PATH is respected by the dynamic loader, so that there's usually no need and no advantage to do a fallback handling. + # + # Windows has it's own library lookup logic, very different to what we do here. + # See: https://github.com/oneclick/rubyinstaller2/wiki/For-gem-developers#user-content-dll-loading + + FFI.make_shareable(SEARCH_PATH) + SEARCH_PATH_MESSAGE = "Searched in #{ SEARCH_PATH.map{|a| ', ' + a}.join }".freeze + + def self.load_library(name, flags) + if name == FFI::CURRENT_PROCESS + FFI::DynamicLibrary.open(nil, RTLD_LAZY | RTLD_LOCAL) + else + flags ||= RTLD_LAZY | RTLD_LOCAL + + libnames = (name.is_a?(::Array) ? name : [name]) + libnames = libnames.map(&:to_s).map { |n| [n, FFI.map_library_name(n)].uniq }.flatten.compact + errors = [] + + libnames.each do |libname| + lib = try_load(libname, flags, errors) + return lib if lib + + unless libname.start_with?("/") + SEARCH_PATH.each do |prefix| + path = "#{prefix}/#{libname}" + if File.exist?(path) + lib = try_load(path, flags, errors) + return lib if lib + end + end + end + end + + raise LoadError, [*errors, SEARCH_PATH_MESSAGE].join(".\n") + end + end + private_class_method :load_library + + def self.try_load(libname, flags, errors) + begin + lib = FFI::DynamicLibrary.open(libname, flags) + return lib if lib + + # LoadError for C ext & JRuby, RuntimeError for TruffleRuby + rescue LoadError, RuntimeError => ex + if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/ + if File.binread($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/ + return try_load($1, flags, errors) + end + end + + errors << ex + nil + end + end + private_class_method :try_load + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/enum.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/enum.rb new file mode 100644 index 0000000..af78331 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/enum.rb @@ -0,0 +1,302 @@ +# +# Copyright (C) 2009, 2010 Wayne Meissner +# Copyright (C) 2009 Luc Heinrich +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +module FFI + + # An instance of this class permits to manage {Enum}s. In fact, Enums is a collection of {Enum}s. + class Enums + + def initialize + @all_enums = Array.new + @tagged_enums = Hash.new + @symbol_map = Hash.new + end + + # @param [Enum] enum + # Add an {Enum} to the collection. + def <<(enum) + @all_enums << enum + @tagged_enums[enum.tag] = enum unless enum.tag.nil? + @symbol_map.merge!(enum.symbol_map) + end + + # @param query enum tag or part of an enum name + # @return [Enum] + # Find a {Enum} in collection. + def find(query) + if @tagged_enums.has_key?(query) + @tagged_enums[query] + else + @all_enums.detect { |enum| enum.symbols.include?(query) } + end + end + + # @param symbol a symbol to find in merge symbol maps of all enums. + # @return a symbol + def __map_symbol(symbol) + @symbol_map[symbol] + end + + end + + # Represents a C enum. + # + # For a C enum: + # enum fruits { + # apple, + # banana, + # orange, + # pineapple + # }; + # are defined this vocabulary: + # * a _symbol_ is a word from the enumeration (ie. _apple_, by example); + # * a _value_ is the value of a symbol in the enumeration (by example, apple has value _0_ and banana _1_). + class Enum + include DataConverter + + attr_reader :tag + attr_reader :native_type + + # @overload initialize(info, tag=nil) + # @param [nil, Enumerable] info + # @param [nil, Symbol] tag enum tag + # @overload initialize(native_type, info, tag=nil) + # @param [FFI::Type] native_type Native type for new Enum + # @param [nil, Enumerable] info symbols and values for new Enum + # @param [nil, Symbol] tag name of new Enum + def initialize(*args) + @native_type = args.first.kind_of?(FFI::Type) ? args.shift : Type::INT + info, @tag = *args + @kv_map = Hash.new + unless info.nil? + last_cst = nil + value = 0 + info.each do |i| + case i + when Symbol + raise ArgumentError, "duplicate enum key" if @kv_map.has_key?(i) + @kv_map[i] = value + last_cst = i + value += 1 + when Integer + @kv_map[last_cst] = i + value = i+1 + end + end + end + @vk_map = @kv_map.invert + end + + # @return [Array] enum symbol names + def symbols + @kv_map.keys + end + + # Get a symbol or a value from the enum. + # @overload [](query) + # Get enum value from symbol. + # @param [Symbol] query + # @return [Integer] + # @overload [](query) + # Get enum symbol from value. + # @param [Integer] query + # @return [Symbol] + def [](query) + case query + when Symbol + @kv_map[query] + when Integer + @vk_map[query] + end + end + alias find [] + + # Get the symbol map. + # @return [Hash] + def symbol_map + @kv_map + end + + alias to_h symbol_map + alias to_hash symbol_map + + # @param [Symbol, Integer, #to_int] val + # @param ctx unused + # @return [Integer] value of a enum symbol + def to_native(val, ctx) + @kv_map[val] || if val.is_a?(Integer) + val + elsif val.respond_to?(:to_int) + val.to_int + else + raise ArgumentError, "invalid enum value, #{val.inspect}" + end + end + + # @param val + # @return symbol name if it exists for +val+. + def from_native(val, ctx) + @vk_map[val] || val + end + end + + # Represents a C enum whose values are power of 2 + # + # @example + # enum { + # red = (1<<0), + # green = (1<<1), + # blue = (1<<2) + # } + # + # Contrary to classical enums, bitmask values are usually combined + # when used. + class Bitmask < Enum + + # @overload initialize(info, tag=nil) + # @param [nil, Enumerable] info symbols and bit rank for new Bitmask + # @param [nil, Symbol] tag name of new Bitmask + # @overload initialize(native_type, info, tag=nil) + # @param [FFI::Type] native_type Native type for new Bitmask + # @param [nil, Enumerable] info symbols and bit rank for new Bitmask + # @param [nil, Symbol] tag name of new Bitmask + def initialize(*args) + @native_type = args.first.kind_of?(FFI::Type) ? args.shift : Type::INT + @signed = [Type::INT8, Type::INT16, Type::INT32, Type::INT64].include?(@native_type) + info, @tag = *args + @kv_map = Hash.new + unless info.nil? + last_cst = nil + value = 0 + info.each do |i| + case i + when Symbol + raise ArgumentError, "duplicate bitmask key" if @kv_map.has_key?(i) + @kv_map[i] = 1 << value + last_cst = i + value += 1 + when Integer + raise ArgumentError, "bitmask index should be positive" if i<0 + @kv_map[last_cst] = 1 << i + value = i+1 + end + end + end + @vk_map = @kv_map.invert + end + + # Get a symbol list or a value from the bitmask + # @overload [](*query) + # Get bitmask value from symbol list + # @param [Symbol] query + # @return [Integer] + # @overload [](query) + # Get bitmask value from symbol array + # @param [Array] query + # @return [Integer] + # @overload [](*query) + # Get a list of bitmask symbols corresponding to + # the or reduction of a list of integer + # @param [Integer] query + # @return [Array] + # @overload [](query) + # Get a list of bitmask symbols corresponding to + # the or reduction of a list of integer + # @param [Array] query + # @return [Array] + def [](*query) + flat_query = query.flatten + raise ArgumentError, "query should be homogeneous, #{query.inspect}" unless flat_query.all? { |o| o.is_a?(Symbol) } || flat_query.all? { |o| o.is_a?(Integer) || o.respond_to?(:to_int) } + case flat_query[0] + when Symbol + flat_query.inject(0) do |val, o| + v = @kv_map[o] + if v then val | v else val end + end + when Integer, ->(o) { o.respond_to?(:to_int) } + val = flat_query.inject(0) { |mask, o| mask |= o.to_int } + @kv_map.select { |_, v| v & val != 0 }.keys + end + end + + # Get the native value of a bitmask + # @overload to_native(query, ctx) + # @param [Symbol, Integer, #to_int] query + # @param ctx unused + # @return [Integer] value of a bitmask + # @overload to_native(query, ctx) + # @param [Array] query + # @param ctx unused + # @return [Integer] value of a bitmask + def to_native(query, ctx) + return 0 if query.nil? + flat_query = [query].flatten + res = flat_query.inject(0) do |val, o| + case o + when Symbol + v = @kv_map[o] + raise ArgumentError, "invalid bitmask value, #{o.inspect}" unless v + val | v + when Integer + val | o + when ->(obj) { obj.respond_to?(:to_int) } + val | o.to_int + else + raise ArgumentError, "invalid bitmask value, #{o.inspect}" + end + end + # Take two's complement of positive values bigger than the max value + # for the type when native type is signed. + if @signed && res >= (1 << (@native_type.size * 8 - 1)) + res = -(-res & ((1 << (@native_type.size * 8)) - 1)) + end + res + end + + # @param [Integer] val + # @param ctx unused + # @return [Array] list of symbol names corresponding to val, plus an optional remainder if some bits don't match any constant + def from_native(val, ctx) + flags = @kv_map.select { |_, v| v & val != 0 } + list = flags.keys + # force an unsigned value of the correct size + val &= (1 << (@native_type.size * 8)) - 1 if @signed + # If there are unmatch flags, + # return them in an integer, + # else information can be lost. + # Similar to Enum behavior. + remainder = val ^ flags.values.reduce(0, :|) + list.push remainder unless remainder == 0 + return list + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/errno.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/errno.rb new file mode 100644 index 0000000..de82d89 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/errno.rb @@ -0,0 +1,43 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +module FFI + # @return (see FFI::LastError.error) + # @see FFI::LastError.error + def self.errno + FFI::LastError.error + end + # @param error (see FFI::LastError.error=) + # @return (see FFI::LastError.error=) + # @see FFI::LastError.error= + def self.errno=(error) + FFI::LastError.error = error + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/ffi.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/ffi.rb new file mode 100644 index 0000000..2c5ea20 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/ffi.rb @@ -0,0 +1,50 @@ +# +# Copyright (C) 2008-2010 JRuby project +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. + +require 'ffi/compat' +require 'ffi/platform' +require 'ffi/data_converter' +require 'ffi/types' +require 'ffi/library_path' +require 'ffi/library' +require 'ffi/errno' +require 'ffi/abstract_memory' +require 'ffi/pointer' +require 'ffi/memorypointer' +require 'ffi/struct' +require 'ffi/union' +require 'ffi/managedstruct' +require 'ffi/callback' +require 'ffi/io' +require 'ffi/autopointer' +require 'ffi/variadic' +require 'ffi/enum' +require 'ffi/version' +require 'ffi/function' diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/function.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/function.rb new file mode 100644 index 0000000..eb2ae00 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/function.rb @@ -0,0 +1,71 @@ +# +# Copyright (C) 2008-2010 JRuby project +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. + +module FFI + class Function + # Only MRI allows function type queries + if private_method_defined?(:type) + # Retrieve the return type of the function + # + # This method returns FFI type returned by the function. + # + # @return [FFI::Type] + def return_type + type.return_type + end + + # Retrieve Array of parameter types + # + # This method returns an Array of FFI types accepted as function parameters. + # + # @return [Array] + def param_types + type.param_types + end + end + + # Stash the Function in a module variable so it can be inspected by attached_functions. + # On CRuby it also ensures that it does not get garbage collected. + module RegisterAttach + def attach(mod, name) + funcs = mod.instance_variable_defined?("@ffi_functions") && mod.instance_variable_get("@ffi_functions") + unless funcs + funcs = {} + mod.instance_variable_set("@ffi_functions", funcs) + end + funcs[name.to_sym] = self + # Jump to the native attach method of CRuby, JRuby or Tuffleruby + super + end + end + private_constant :RegisterAttach + prepend RegisterAttach + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/io.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/io.rb new file mode 100644 index 0000000..7fb2857 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/io.rb @@ -0,0 +1,62 @@ +# +# Copyright (C) 2008, 2009 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +module FFI + + # This module implements a couple of class methods to play with IO. + module IO + # @param [Integer] fd file decriptor + # @param [String] mode mode string + # @return [::IO] + # Synonym for IO::for_fd. + def self.for_fd(fd, mode = "r") + ::IO.for_fd(fd, mode) + end + + # @param [#read] io io to read from + # @param [AbstractMemory] buf destination for data read from +io+ + # @param [nil, Integer] len maximul number of bytes to read from +io+. If +nil+, + # read until end of file. + # @return [Integer] length really read, in bytes + # + # A version of IO#read that reads data from an IO and put then into a native buffer. + # + # This will be optimized at some future time to eliminate the double copy. + # + def self.native_read(io, buf, len) + tmp = io.read(len) + return -1 unless tmp + buf.put_bytes(0, tmp) + tmp.length + end + + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/library.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/library.rb new file mode 100644 index 0000000..e47da16 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/library.rb @@ -0,0 +1,576 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +require 'ffi/dynamic_library' + +module FFI + CURRENT_PROCESS = USE_THIS_PROCESS_AS_LIBRARY = FFI.make_shareable(Object.new) + + # @param [String, FFI::LibraryPath] lib library name or LibraryPath object + # @return [String] library name formatted for current platform + # Transform a generic library name to a platform library name + # @example + # # Linux + # FFI.map_library_name 'c' # -> "libc.so.6" + # FFI.map_library_name 'jpeg' # -> "libjpeg.so" + # # Windows + # FFI.map_library_name 'c' # -> "msvcrt.dll" + # FFI.map_library_name 'jpeg' # -> "jpeg.dll" + def self.map_library_name(lib) + # Mangle the library name to reflect the native library naming conventions + LibraryPath.wrap(lib).to_s + end + + # Exception raised when a function is not found in libraries + class NotFoundError < LoadError + def initialize(function, *libraries) + super("Function '#{function}' not found in [#{libraries[0].nil? ? 'current process' : libraries.join(", ")}]") + end + end + + # This module is the base to use native functions. + # + # A basic usage may be: + # require 'ffi' + # + # module Hello + # extend FFI::Library + # ffi_lib FFI::Library::LIBC + # attach_function 'puts', [ :string ], :int + # end + # + # Hello.puts("Hello, World") + # + # + module Library + CURRENT_PROCESS = FFI::CURRENT_PROCESS + LIBC = FFI::Platform::LIBC + + # @param mod extended object + # @return [nil] + # @raise {RuntimeError} if +mod+ is not a Module + # Test if extended object is a Module. If not, raise RuntimeError. + def self.extended(mod) + raise RuntimeError.new("must only be extended by module") unless mod.kind_of?(::Module) + end + + + # @param [Array] names names of libraries to load + # @return [Array] + # @raise {LoadError} if a library cannot be opened + # Load native libraries. + def ffi_lib(*names) + raise LoadError.new("library names list must not be empty") if names.empty? + + lib_flags = defined?(@ffi_lib_flags) && @ffi_lib_flags + + @ffi_libs = names.map do |name| + FFI::DynamicLibrary.send(:load_library, name, lib_flags) + end + end + + # Set the calling convention for {#attach_function} and {#callback} + # + # @see http://en.wikipedia.org/wiki/Stdcall#stdcall + # @note +:stdcall+ is typically used for attaching Windows API functions + # + # @param [Symbol] convention one of +:default+, +:stdcall+ + # @return [Symbol] the new calling convention + def ffi_convention(convention = nil) + @ffi_convention ||= :default + @ffi_convention = convention if convention + @ffi_convention + end + + # @see #ffi_lib + # @return [Array] array of currently loaded FFI libraries + # @raise [LoadError] if no libraries have been loaded (using {#ffi_lib}) + # Get FFI libraries loaded using {#ffi_lib}. + def ffi_libraries + raise LoadError.new("no library specified") if !defined?(@ffi_libs) || @ffi_libs.empty? + @ffi_libs + end + + # Flags used in {#ffi_lib}. + # + # This map allows you to supply symbols to {#ffi_lib_flags} instead of + # the actual constants. + FlagsMap = { + :global => DynamicLibrary::RTLD_GLOBAL, + :local => DynamicLibrary::RTLD_LOCAL, + :lazy => DynamicLibrary::RTLD_LAZY, + :now => DynamicLibrary::RTLD_NOW + } + + # Sets library flags for {#ffi_lib}. + # + # @example + # ffi_lib_flags(:lazy, :local) # => 5 + # + # @param [Symbol, …] flags (see {FlagsMap}) + # @return [Integer] the new value + def ffi_lib_flags(*flags) + @ffi_lib_flags = flags.inject(0) { |result, f| result | FlagsMap[f] } + end + + + ## + # @overload attach_function(func, args, returns, options = {}) + # @example attach function without an explicit name + # module Foo + # extend FFI::Library + # ffi_lib FFI::Library::LIBC + # attach_function :malloc, [:size_t], :pointer + # end + # # now callable via Foo.malloc + # @overload attach_function(name, func, args, returns, options = {}) + # @example attach function with an explicit name + # module Bar + # extend FFI::Library + # ffi_lib FFI::Library::LIBC + # attach_function :c_malloc, :malloc, [:size_t], :pointer + # end + # # now callable via Bar.c_malloc + # + # Attach C function +func+ to this module. + # + # + # @param [#to_s] name name of ruby method to attach as + # @param [#to_s] func name of C function to attach + # @param [Array] args an array of types + # @param [Symbol] returns type of return value + # @option options [Boolean] :blocking (@blocking) set to true if the C function is a blocking call + # @option options [Symbol] :convention (:default) calling convention (see {#ffi_convention}) + # @option options [FFI::Enums] :enums + # @option options [Hash] :type_map + # + # @return [FFI::VariadicInvoker] + # + # @raise [FFI::NotFoundError] if +func+ cannot be found in the attached libraries (see {#ffi_lib}) + def attach_function(name, func, args, returns = nil, options = nil) + mname, a2, a3, a4, a5 = name, func, args, returns, options + cname, arg_types, ret_type, opts = (a4 && (a2.is_a?(String) || a2.is_a?(Symbol))) ? [ a2, a3, a4, a5 ] : [ mname.to_s, a2, a3, a4 ] + + # Convert :foo to the native type + arg_types = arg_types.map { |e| find_type(e) } + options = { + :convention => ffi_convention, + :type_map => defined?(@ffi_typedefs) ? @ffi_typedefs : nil, + :blocking => defined?(@blocking) && @blocking, + :enums => defined?(@ffi_enums) ? @ffi_enums : nil, + } + + @blocking = false + options.merge!(opts) if opts && opts.is_a?(Hash) + + # Try to locate the function in any of the libraries + invokers = [] + ffi_libraries.each do |lib| + if invokers.empty? + begin + function = nil + function_names(cname, arg_types).find do |fname| + function = lib.find_function(fname) + end + raise LoadError unless function + + invokers << if arg_types[-1] == FFI::NativeType::VARARGS + VariadicInvoker.new(function, arg_types, find_type(ret_type), options) + + else + Function.new(find_type(ret_type), arg_types, function, options) + end + + rescue LoadError + end + end + end + invoker = invokers.compact.shift + raise FFI::NotFoundError.new(cname.to_s, ffi_libraries.map { |lib| lib.name }) unless invoker + + invoker.attach(self, mname.to_s) + invoker + end + + # @param [#to_s] name function name + # @param [Array] arg_types function's argument types + # @return [Array] + # This function returns a list of possible names to lookup. + # @note Function names on windows may be decorated if they are using stdcall. See + # * http://en.wikipedia.org/wiki/Name_mangling#C_name_decoration_in_Microsoft_Windows + # * http://msdn.microsoft.com/en-us/library/zxk0tw93%28v=VS.100%29.aspx + # * http://en.wikibooks.org/wiki/X86_Disassembly/Calling_Conventions#STDCALL + # Note that decorated names can be overridden via def files. Also note that the + # windows api, although using, doesn't have decorated names. + def function_names(name, arg_types) + result = [name.to_s] + if ffi_convention == :stdcall + # Get the size of each parameter + size = arg_types.inject(0) do |mem, arg| + size = arg.size + # The size must be a multiple of 4 + size += (4 - size) % 4 + mem + size + end + + result << "_#{name.to_s}@#{size}" # win32 + result << "#{name.to_s}@#{size}" # win64 + end + result + end + + # @overload attach_variable(mname, cname, type) + # @param [#to_s] mname name of ruby method to attach as + # @param [#to_s] cname name of C variable to attach + # @param [DataConverter, Struct, Symbol, Type] type C variable's type + # @example + # module Bar + # extend FFI::Library + # ffi_lib 'my_lib' + # attach_variable :c_myvar, :myvar, :long + # end + # # now callable via Bar.c_myvar + # @overload attach_variable(cname, type) + # @param [#to_s] mname name of ruby method to attach as + # @param [DataConverter, Struct, Symbol, Type] type C variable's type + # @example + # module Bar + # extend FFI::Library + # ffi_lib 'my_lib' + # attach_variable :myvar, :long + # end + # # now callable via Bar.myvar + # @return [DynamicLibrary::Symbol] + # @raise {FFI::NotFoundError} if +cname+ cannot be found in libraries + # + # Attach C variable +cname+ to this module. + def attach_variable(mname, a1, a2 = nil) + cname, type = a2 ? [ a1, a2 ] : [ mname.to_s, a1 ] + mname = mname.to_sym + address = nil + ffi_libraries.each do |lib| + begin + address = lib.find_variable(cname.to_s) + break unless address.nil? + rescue LoadError + end + end + + raise FFI::NotFoundError.new(cname, ffi_libraries) if address.nil? || address.null? + if type.is_a?(Class) && type < FFI::Struct + # If it is a global struct, just attach directly to the pointer + s = s = type.new(address) # Assigning twice to suppress unused variable warning + self.module_eval <<-code, __FILE__, __LINE__ + @ffi_gsvars = {} unless defined?(@ffi_gsvars) + @ffi_gsvars[#{mname.inspect}] = s + def self.#{mname} + @ffi_gsvars[#{mname.inspect}] + end + code + + else + sc = Class.new(FFI::Struct) + sc.layout :gvar, find_type(type) + s = sc.new(address) + # + # Attach to this module as mname/mname= + # + self.module_eval <<-code, __FILE__, __LINE__ + @ffi_gvars = {} unless defined?(@ffi_gvars) + @ffi_gvars[#{mname.inspect}] = s + def self.#{mname} + @ffi_gvars[#{mname.inspect}][:gvar] + end + def self.#{mname}=(value) + @ffi_gvars[#{mname.inspect}][:gvar] = value + end + code + + end + + address + end + + + # @overload callback(name, params, ret) + # @param name callback name to add to type map + # @param [Array] params array of parameters' types + # @param [DataConverter, Struct, Symbol, Type] ret callback return type + # @overload callback(params, ret) + # @param [Array] params array of parameters' types + # @param [DataConverter, Struct, Symbol, Type] ret callback return type + # @return [FFI::CallbackInfo] + def callback(*args) + raise ArgumentError, "wrong number of arguments" if args.length < 2 || args.length > 3 + name, params, ret = if args.length == 3 + args + else + [ nil, args[0], args[1] ] + end + + native_params = params.map { |e| find_type(e) } + raise ArgumentError, "callbacks cannot have variadic parameters" if native_params.include?(FFI::Type::VARARGS) + options = Hash.new + options[:convention] = ffi_convention + options[:enums] = @ffi_enums if defined?(@ffi_enums) + ret_type = find_type(ret) + if ret_type == Type::STRING + raise TypeError, ":string is not allowed as return type of callbacks" + end + cb = FFI::CallbackInfo.new(ret_type, native_params, options) + + # Add to the symbol -> type map (unless there was no name) + unless name.nil? + typedef cb, name + end + + cb + end + + # Register or get an already registered type definition. + # + # To register a new type definition, +old+ should be a {FFI::Type}. +add+ + # is in this case the type definition. + # + # If +old+ is a {DataConverter}, a {Type::Mapped} is returned. + # + # If +old+ is +:enum+ + # * and +add+ is an +Array+, a call to {#enum} is made with +add+ as single parameter; + # * in others cases, +info+ is used to create a named enum. + # + # If +old+ is a key for type map, #typedef get +old+ type definition. + # + # @param [DataConverter, Symbol, Type] old + # @param [Symbol] add + # @param [Symbol] info + # @return [FFI::Enum, FFI::Type] + def typedef(old, add, info=nil) + @ffi_typedefs = Hash.new unless defined?(@ffi_typedefs) + + @ffi_typedefs[add] = if old.kind_of?(FFI::Type) + old + + elsif @ffi_typedefs.has_key?(old) + @ffi_typedefs[old] + + elsif old.is_a?(DataConverter) + FFI::Type::Mapped.new(old) + + elsif old == :enum + if add.kind_of?(Array) + self.enum(add) + else + self.enum(info, add) + end + + else + FFI.find_type(old) + end + end + + # @param [DataConverter, Type, Struct, Symbol] t type to find + # @return [Type] + # Find a type definition. + def find_type(t) + if t.kind_of?(Type) + t + + elsif defined?(@ffi_typedefs) && @ffi_typedefs.has_key?(t) + @ffi_typedefs[t] + + elsif t.is_a?(Class) && t < Struct + Type::POINTER + + elsif t.is_a?(DataConverter) + # Add a typedef so next time the converter is used, it hits the cache + typedef Type::Mapped.new(t), t + + end || FFI.find_type(t) + end + + private + # Generic enum builder + # @param [Class] klass can be one of FFI::Enum or FFI::Bitmask + # @param args (see #enum or #bitmask) + def generic_enum(klass, *args) + native_type = args.first.kind_of?(FFI::Type) ? args.shift : nil + name, values = if args[0].kind_of?(Symbol) && args[1].kind_of?(Array) + [ args[0], args[1] ] + elsif args[0].kind_of?(Array) + [ nil, args[0] ] + else + [ nil, args ] + end + @ffi_enums = FFI::Enums.new unless defined?(@ffi_enums) + @ffi_enums << (e = native_type ? klass.new(native_type, values, name) : klass.new(values, name)) + + # If called with a name, add a typedef alias + typedef(e, name) if name + e + end + + public + # @overload enum(name, values) + # Create a named enum. + # @example + # enum :foo, [:zero, :one, :two] # named enum + # @param [Symbol] name name for new enum + # @param [Array] values values for enum + # @overload enum(*args) + # Create an unnamed enum. + # @example + # enum :zero, :one, :two # unnamed enum + # @param args values for enum + # @overload enum(values) + # Create an unnamed enum. + # @example + # enum [:zero, :one, :two] # unnamed enum, equivalent to above example + # @param [Array] values values for enum + # @overload enum(native_type, name, values) + # Create a named enum and specify the native type. + # @example + # enum FFI::Type::UINT64, :foo, [:zero, :one, :two] # named enum + # @param [FFI::Type] native_type native type for new enum + # @param [Symbol] name name for new enum + # @param [Array] values values for enum + # @overload enum(native_type, *args) + # Create an unnamed enum and specify the native type. + # @example + # enum FFI::Type::UINT64, :zero, :one, :two # unnamed enum + # @param [FFI::Type] native_type native type for new enum + # @param args values for enum + # @overload enum(native_type, values) + # Create an unnamed enum and specify the native type. + # @example + # enum Type::UINT64, [:zero, :one, :two] # unnamed enum, equivalent to above example + # @param [FFI::Type] native_type native type for new enum + # @param [Array] values values for enum + # @return [FFI::Enum] + # Create a new {FFI::Enum}. + def enum(*args) + generic_enum(FFI::Enum, *args) + end + + # @overload bitmask(name, values) + # Create a named bitmask + # @example + # bitmask :foo, [:red, :green, :blue] # bits 0,1,2 are used + # bitmask :foo, [:red, :green, 5, :blue] # bits 0,5,6 are used + # @param [Symbol] name for new bitmask + # @param [Array] values for new bitmask + # @overload bitmask(*args) + # Create an unamed bitmask + # @example + # bm = bitmask :red, :green, :blue # bits 0,1,2 are used + # bm = bitmask :red, :green, 5, blue # bits 0,5,6 are used + # @param [Symbol, Integer] args values for new bitmask + # @overload bitmask(values) + # Create an unamed bitmask + # @example + # bm = bitmask [:red, :green, :blue] # bits 0,1,2 are used + # bm = bitmask [:red, :green, 5, blue] # bits 0,5,6 are used + # @param [Array] values for new bitmask + # @overload bitmask(native_type, name, values) + # Create a named enum and specify the native type. + # @example + # bitmask FFI::Type::UINT64, :foo, [:red, :green, :blue] + # @param [FFI::Type] native_type native type for new bitmask + # @param [Symbol] name for new bitmask + # @param [Array] values for new bitmask + # @overload bitmask(native_type, *args) + # @example + # bitmask FFI::Type::UINT64, :red, :green, :blue + # @param [FFI::Type] native_type native type for new bitmask + # @param [Symbol, Integer] args values for new bitmask + # @overload bitmask(native_type, values) + # Create a named enum and specify the native type. + # @example + # bitmask FFI::Type::UINT64, [:red, :green, :blue] + # @param [FFI::Type] native_type native type for new bitmask + # @param [Array] values for new bitmask + # @return [FFI::Bitmask] + # Create a new FFI::Bitmask + def bitmask(*args) + generic_enum(FFI::Bitmask, *args) + end + + # @param name + # @return [FFI::Enum] + # Find an enum by name. + def enum_type(name) + @ffi_enums.find(name) if defined?(@ffi_enums) + end + + # @param symbol + # @return [FFI::Enum] + # Find an enum by a symbol it contains. + def enum_value(symbol) + @ffi_enums.__map_symbol(symbol) + end + + # Retrieve all attached functions and their function signature + # + # This method returns a Hash of method names of attached functions connected by #attach_function and the corresponding function type. + # The function type responds to #return_type and #param_types which return the FFI types of the function signature. + # + # @return [Hash< Symbol => [FFI::Function, FFI::VariadicInvoker] >] + def attached_functions + @ffi_functions || {} + end + + # Retrieve all attached variables and their type + # + # This method returns a Hash of variable names and the corresponding type or variables connected by #attach_variable . + # + # @return [Hash< Symbol => ffi_type >] + def attached_variables + ( + (defined?(@ffi_gsvars) ? @ffi_gsvars : {}).map do |name, gvar| + [name, gvar.class] + end + + (defined?(@ffi_gvars) ? @ffi_gvars : {}).map do |name, gvar| + [name, gvar.layout[:gvar].type] + end + ).to_h + end + + # Freeze all definitions of the module + # + # This freezes the module's definitions, so that it can be used in a Ractor. + # No further methods or variables can be attached and no further enums or typedefs can be created in this module afterwards. + def freeze + instance_variables.each do |name| + var = instance_variable_get(name) + FFI.make_shareable(var) + end + nil + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/library_path.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/library_path.rb new file mode 100644 index 0000000..5575a5f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/library_path.rb @@ -0,0 +1,109 @@ +# +# Copyright (C) 2023 Lars Kanis +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +module FFI + # Transform a generic library name and ABI number to a platform library name + # + # Example: + # module LibVips + # extend FFI::Library + # ffi_lib LibraryPath.new("vips", abi_number: 42) + # end + # + # This translates to the following library file names: + # libvips-42.dll on Windows + # libvips.so.42 on Linux + # libvips.42.dylib on Macos + # + # See https://packaging.ubuntu.com/html/libraries.html for more information about library naming. + class LibraryPath + attr_reader :name + attr_reader :abi_number + attr_reader :root + + # Build a new library path + # + # * name : The name of the library without file prefix or suffix. + # * abi_number : The ABI number of the library. + # * root : An optional base path prepended to the library name. + def initialize(name, abi_number: nil, root: nil) + @name = name + @abi_number = abi_number + @root = root + end + + def self.wrap(value) + # We allow instances of LibraryPath to pass through transparently: + return value if value.is_a?(self) + + # We special case a library named 'c' to be the standard C library: + return Library::LIBC if value == 'c' + + # If provided a relative file name we convert it into a library path: + if value && File.basename(value) == value + return self.new(value) + end + + # Otherwise, we assume it's a full path to a library: + return value + end + + def full_name + # If the abi_number is given, we format it specifically according to platform rules: + if abi_number + if Platform.windows? + "#{Platform::LIBPREFIX}#{name}-#{abi_number}.#{Platform::LIBSUFFIX}" + elsif Platform.mac? + "#{Platform::LIBPREFIX}#{name}.#{abi_number}.#{Platform::LIBSUFFIX}" + else # Linux? BSD? etc. + "#{Platform::LIBPREFIX}#{name}.#{Platform::LIBSUFFIX}.#{abi_number}" + end + else + # Otherwise we just add prefix and suffix: + lib = name + # Add library prefix if missing + lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/ + # Add library extension if missing + r = Platform.windows? || Platform.mac? ? "\\.#{Platform::LIBSUFFIX}$" : "\\.so($|\\.[1234567890]+)" + lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/ + lib + end + end + + def to_s + if root + # If the root path is given, we generate the full path: + File.join(root, full_name) + else + full_name + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/managedstruct.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/managedstruct.rb new file mode 100644 index 0000000..5d243e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/managedstruct.rb @@ -0,0 +1,84 @@ +# Copyright (C) 2008 Mike Dalessio +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. + +module FFI + # + # FFI::ManagedStruct allows custom garbage-collection of your FFI::Structs. + # + # The typical use case would be when interacting with a library + # that has a nontrivial memory management design, such as a linked + # list or a binary tree. + # + # When the {Struct} instance is garbage collected, FFI::ManagedStruct will + # invoke the class's release() method during object finalization. + # + # @example Example usage: + # module MyLibrary + # ffi_lib "libmylibrary" + # attach_function :new_dlist, [], :pointer + # attach_function :destroy_dlist, [:pointer], :void + # end + # + # class DoublyLinkedList < FFI::ManagedStruct + # @@@ + # struct do |s| + # s.name 'struct dlist' + # s.include 'dlist.h' + # s.field :head, :pointer + # s.field :tail, :pointer + # end + # @@@ + # + # def self.release ptr + # MyLibrary.destroy_dlist(ptr) + # end + # end + # + # begin + # ptr = DoublyLinkedList.new(MyLibrary.new_dlist) + # # do something with the list + # end + # # struct is out of scope, and will be GC'd using DoublyLinkedList#release + # + # + class ManagedStruct < FFI::Struct + + # @overload initialize(pointer) + # @param [Pointer] pointer + # Create a new ManagedStruct which will invoke the class method #release on + # @overload initialize + # A new instance of FFI::ManagedStruct. + def initialize(pointer=nil) + raise NoMethodError, "release() not implemented for class #{self}" unless self.class.respond_to?(:release, true) + raise ArgumentError, "Must supply a pointer to memory for the Struct" unless pointer + super AutoPointer.new(pointer, self.class.method(:release)) + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/memorypointer.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/memorypointer.rb new file mode 100644 index 0000000..9f07bc6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/memorypointer.rb @@ -0,0 +1 @@ +# This class is now implemented in C diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform.rb new file mode 100644 index 0000000..5ac4dd7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform.rb @@ -0,0 +1,187 @@ +# +# Copyright (C) 2008, 2009 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +require 'rbconfig' +require_relative 'compat' + +module FFI + class PlatformError < LoadError; end + + # This module defines different constants and class methods to play with + # various platforms. + module Platform + OS = FFI.make_shareable(case RbConfig::CONFIG['host_os'].downcase + when /linux/ + "linux" + when /darwin/ + "darwin" + when /freebsd/ + "freebsd" + when /netbsd/ + "netbsd" + when /openbsd/ + "openbsd" + when /dragonfly/ + "dragonflybsd" + when /sunos|solaris/ + "solaris" + when /mingw|mswin/ + "windows" + else + RbConfig::CONFIG['host_os'].downcase + end) + + OSVERSION = RbConfig::CONFIG['host_os'].gsub(/[^\d]/, '').to_i + + CPU = FFI.make_shareable(RbConfig::CONFIG['host_cpu']) + + ARCH = FFI.make_shareable(case CPU.downcase + when /amd64|x86_64|x64/ + "x86_64" + when /i\d86|x86|i86pc/ + "i386" + when /ppc64|powerpc64/ + "powerpc64" + when /ppc|powerpc/ + "powerpc" + when /sparcv9|sparc64/ + "sparcv9" + when /arm64|aarch64/ # MacOS calls it "arm64", other operating systems "aarch64" + "aarch64" + when /^arm/ + if OS == "darwin" # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin + "aarch64" + else + "arm" + end + else + RbConfig::CONFIG['host_cpu'] + end) + + private + # @param [String) os + # @return [Boolean] + # Test if current OS is +os+. + def self.is_os(os) + OS == os + end + + IS_GNU = defined?(GNU_LIBC) + IS_LINUX = is_os("linux") + IS_MAC = is_os("darwin") + IS_FREEBSD = is_os("freebsd") + IS_NETBSD = is_os("netbsd") + IS_OPENBSD = is_os("openbsd") + IS_DRAGONFLYBSD = is_os("dragonfly") + IS_SOLARIS = is_os("solaris") + IS_WINDOWS = is_os("windows") + IS_BSD = IS_MAC || IS_FREEBSD || IS_NETBSD || IS_OPENBSD || IS_DRAGONFLYBSD + + # Add the version for known ABI breaks + name_version = "12" if IS_FREEBSD && OSVERSION >= 12 # 64-bit inodes + + NAME = FFI.make_shareable("#{ARCH}-#{OS}#{name_version}") + CONF_DIR = FFI.make_shareable(File.join(File.dirname(__FILE__), 'platform', NAME)) + + public + + LIBPREFIX = FFI.make_shareable(case OS + when /windows|msys/ + '' + when /cygwin/ + 'cyg' + else + 'lib' + end) + + LIBSUFFIX = FFI.make_shareable(case OS + when /darwin/ + 'dylib' + when /linux|bsd|solaris/ + 'so' + when /windows|cygwin|msys/ + 'dll' + else + # Punt and just assume a sane unix (i.e. anything but AIX) + 'so' + end) + + LIBC = FFI.make_shareable(if IS_WINDOWS + crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase' + "#{crtname}.dll" + elsif IS_GNU + GNU_LIBC + elsif OS == 'cygwin' + "cygwin1.dll" + elsif OS == 'msys' + # Not sure how msys 1.0 behaves, tested on MSYS2. + "msys-2.0.dll" + else + "#{LIBPREFIX}c.#{LIBSUFFIX}" + end) + + LITTLE_ENDIAN = 1234 unless defined?(LITTLE_ENDIAN) + BIG_ENDIAN = 4321 unless defined?(BIG_ENDIAN) + unless defined?(BYTE_ORDER) + BYTE_ORDER = [0x12345678].pack("I") == [0x12345678].pack("N") ? BIG_ENDIAN : LITTLE_ENDIAN + end + + # Test if current OS is a *BSD (include MAC) + # @return [Boolean] + def self.bsd? + IS_BSD + end + + # Test if current OS is Windows + # @return [Boolean] + def self.windows? + IS_WINDOWS + end + + # Test if current OS is Mac OS + # @return [Boolean] + def self.mac? + IS_MAC + end + + # Test if current OS is Solaris (Sun OS) + # @return [Boolean] + def self.solaris? + IS_SOLARIS + end + + # Test if current OS is a unix OS + # @return [Boolean] + def self.unix? + !IS_WINDOWS + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-darwin/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-darwin/types.conf new file mode 100644 index 0000000..68841bb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-darwin/types.conf @@ -0,0 +1,130 @@ +rbx.platform.typedef.__darwin_blkcnt_t = long_long +rbx.platform.typedef.__darwin_blksize_t = int +rbx.platform.typedef.__darwin_clock_t = ulong +rbx.platform.typedef.__darwin_ct_rune_t = int +rbx.platform.typedef.__darwin_dev_t = int +rbx.platform.typedef.__darwin_fsblkcnt_t = uint +rbx.platform.typedef.__darwin_fsfilcnt_t = uint +rbx.platform.typedef.__darwin_gid_t = uint +rbx.platform.typedef.__darwin_id_t = uint +rbx.platform.typedef.__darwin_ino64_t = ulong_long +rbx.platform.typedef.__darwin_ino_t = ulong_long +rbx.platform.typedef.__darwin_intptr_t = long +rbx.platform.typedef.__darwin_mach_port_name_t = uint +rbx.platform.typedef.__darwin_mach_port_t = uint +rbx.platform.typedef.__darwin_mode_t = ushort +rbx.platform.typedef.__darwin_natural_t = uint +rbx.platform.typedef.__darwin_off_t = long_long +rbx.platform.typedef.__darwin_pid_t = int +rbx.platform.typedef.__darwin_pthread_key_t = ulong +rbx.platform.typedef.__darwin_ptrdiff_t = long +rbx.platform.typedef.__darwin_rune_t = int +rbx.platform.typedef.__darwin_sigset_t = uint +rbx.platform.typedef.__darwin_size_t = ulong +rbx.platform.typedef.__darwin_socklen_t = uint +rbx.platform.typedef.__darwin_ssize_t = long +rbx.platform.typedef.__darwin_suseconds_t = int +rbx.platform.typedef.__darwin_time_t = long +rbx.platform.typedef.__darwin_uid_t = uint +rbx.platform.typedef.__darwin_useconds_t = uint +rbx.platform.typedef.__darwin_uuid_string_t[37] = char +rbx.platform.typedef.__darwin_uuid_t[16] = uchar +rbx.platform.typedef.__darwin_wchar_t = int +rbx.platform.typedef.__darwin_wint_t = int +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.errno_t = int +rbx.platform.typedef.fd_mask = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = uint +rbx.platform.typedef.fsfilcnt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = short +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.rsize_t = ulong +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.sae_associd_t = uint +rbx.platform.typedef.sae_connid_t = uint +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.syscall_arg_t = ulong_long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ushort +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.user_addr_t = ulong_long +rbx.platform.typedef.user_long_t = long_long +rbx.platform.typedef.user_off_t = long_long +rbx.platform.typedef.user_size_t = ulong_long +rbx.platform.typedef.user_ssize_t = long_long +rbx.platform.typedef.user_time_t = long_long +rbx.platform.typedef.user_ulong_t = ulong_long +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-freebsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-freebsd/types.conf new file mode 100644 index 0000000..8d111e0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-freebsd/types.conf @@ -0,0 +1,128 @@ +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long_long +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = int +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-freebsd12/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-freebsd12/types.conf new file mode 100644 index 0000000..3ccb8f6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-freebsd12/types.conf @@ -0,0 +1,181 @@ +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.___wchar_t = uint +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__char16_t = ushort +rbx.platform.typedef.__char32_t = uint +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int +rbx.platform.typedef.__critical_t = long +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__daddr_t = long +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = long +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = long +rbx.platform.typedef.__rman_res_t = ulong +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = long +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__u_register_t = ulong +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = ulong +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vm_offset_t = ulong +rbx.platform.typedef.__vm_paddr_t = ulong +rbx.platform.typedef.__vm_size_t = ulong +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.accmode_t = int +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.cap_ioctl_t = ulong +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int +rbx.platform.typedef.critical_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fflags_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = int +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.kpaddr_t = ulong +rbx.platform.typedef.ksize_t = ulong +rbx.platform.typedef.kssize_t = long +rbx.platform.typedef.kvaddr_t = ulong +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off64_t = long +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = long +rbx.platform.typedef.rman_res_t = ulong +rbx.platform.typedef.rsize_t = ulong +rbx.platform.typedef.rune_t = int +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.sbintime_t = long +rbx.platform.typedef.segsz_t = long +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_register_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uint +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = ulong +rbx.platform.typedef.vm_ooffset_t = ulong +rbx.platform.typedef.vm_paddr_t = ulong +rbx.platform.typedef.vm_pindex_t = ulong +rbx.platform.typedef.vm_size_t = ulong +rbx.platform.typedef.wchar_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-linux/types.conf new file mode 100644 index 0000000..c56206e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-linux/types.conf @@ -0,0 +1,175 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__kernel_caddr_t = string +rbx.platform.typedef.__kernel_clock_t = long +rbx.platform.typedef.__kernel_clockid_t = int +rbx.platform.typedef.__kernel_daddr_t = int +rbx.platform.typedef.__kernel_gid16_t = ushort +rbx.platform.typedef.__kernel_gid32_t = uint +rbx.platform.typedef.__kernel_gid_t = uint +rbx.platform.typedef.__kernel_ino_t = ulong +rbx.platform.typedef.__kernel_ipc_pid_t = int +rbx.platform.typedef.__kernel_key_t = int +rbx.platform.typedef.__kernel_loff_t = long_long +rbx.platform.typedef.__kernel_long_t = long +rbx.platform.typedef.__kernel_mode_t = uint +rbx.platform.typedef.__kernel_mqd_t = int +rbx.platform.typedef.__kernel_off_t = long +rbx.platform.typedef.__kernel_old_dev_t = uint +rbx.platform.typedef.__kernel_old_gid_t = ushort +rbx.platform.typedef.__kernel_old_time_t = long +rbx.platform.typedef.__kernel_old_uid_t = ushort +rbx.platform.typedef.__kernel_pid_t = int +rbx.platform.typedef.__kernel_ptrdiff_t = long +rbx.platform.typedef.__kernel_size_t = ulong +rbx.platform.typedef.__kernel_ssize_t = long +rbx.platform.typedef.__kernel_suseconds_t = long +rbx.platform.typedef.__kernel_time64_t = long_long +rbx.platform.typedef.__kernel_time_t = long +rbx.platform.typedef.__kernel_timer_t = int +rbx.platform.typedef.__kernel_uid16_t = ushort +rbx.platform.typedef.__kernel_uid32_t = uint +rbx.platform.typedef.__kernel_uid_t = uint +rbx.platform.typedef.__kernel_ulong_t = ulong +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds64_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__thrd_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__tss_t = uint +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = long +rbx.platform.typedef.int_fast32_t = long +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ulong +rbx.platform.typedef.uint_fast32_t = ulong +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-openbsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-openbsd/types.conf new file mode 100644 index 0000000..6abc9c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-openbsd/types.conf @@ -0,0 +1,134 @@ +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long_long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = long_long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = long_long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.sigset_t = uint +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-windows/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-windows/types.conf new file mode 100644 index 0000000..5bdbbde --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/aarch64-windows/types.conf @@ -0,0 +1,52 @@ +rbx.platform.typedef.__time32_t = long +rbx.platform.typedef.__time64_t = long_long +rbx.platform.typedef._dev_t = uint +rbx.platform.typedef._ino_t = ushort +rbx.platform.typedef._mode_t = ushort +rbx.platform.typedef._off64_t = long_long +rbx.platform.typedef._off_t = long +rbx.platform.typedef._pid_t = long_long +rbx.platform.typedef._sigset_t = ulong_long +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.errno_t = int +rbx.platform.typedef.ino_t = ushort +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = short +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long_long +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.off32_t = long +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = long_long +rbx.platform.typedef.ptrdiff_t = long_long +rbx.platform.typedef.rsize_t = ulong_long +rbx.platform.typedef.size_t = ulong_long +rbx.platform.typedef.ssize_t = long_long +rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ushort +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = ulong_long +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.wchar_t = ushort +rbx.platform.typedef.wctype_t = ushort +rbx.platform.typedef.wint_t = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-freebsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-freebsd/types.conf new file mode 100644 index 0000000..cfbb90f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-freebsd/types.conf @@ -0,0 +1,152 @@ + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint +rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int +rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int +rbx.platform.typedef.__critical_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = uint +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ushort +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = int +rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vm_offset_t = uint +rbx.platform.typedef.__vm_ooffset_t = long_long +rbx.platform.typedef.__vm_paddr_t = uint +rbx.platform.typedef.__vm_pindex_t = ulong_long +rbx.platform.typedef.__vm_size_t = uint +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.accmode_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int +rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int +rbx.platform.typedef.critical_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fflags_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = long +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = uint +rbx.platform.typedef.vm_ooffset_t = long_long +rbx.platform.typedef.vm_paddr_t = uint +rbx.platform.typedef.vm_pindex_t = ulong_long +rbx.platform.typedef.vm_size_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-freebsd12/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-freebsd12/types.conf new file mode 100644 index 0000000..523370d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-freebsd12/types.conf @@ -0,0 +1,152 @@ + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint +rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int +rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int +rbx.platform.typedef.__critical_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ulong_long +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = int +rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vm_offset_t = uint +rbx.platform.typedef.__vm_ooffset_t = long_long +rbx.platform.typedef.__vm_paddr_t = uint +rbx.platform.typedef.__vm_pindex_t = ulong_long +rbx.platform.typedef.__vm_size_t = uint +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.accmode_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int +rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int +rbx.platform.typedef.critical_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fflags_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = long +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ulong_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = uint +rbx.platform.typedef.vm_ooffset_t = long_long +rbx.platform.typedef.vm_paddr_t = uint +rbx.platform.typedef.vm_pindex_t = ulong_long +rbx.platform.typedef.vm_size_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-linux/types.conf new file mode 100644 index 0000000..a070d39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/arm-linux/types.conf @@ -0,0 +1,132 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = int +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/hppa1.1-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/hppa1.1-linux/types.conf new file mode 100644 index 0000000..c8a8141 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/hppa1.1-linux/types.conf @@ -0,0 +1,178 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = int +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__kernel_caddr_t = string +rbx.platform.typedef.__kernel_clock_t = long +rbx.platform.typedef.__kernel_clockid_t = int +rbx.platform.typedef.__kernel_daddr_t = int +rbx.platform.typedef.__kernel_gid16_t = ushort +rbx.platform.typedef.__kernel_gid32_t = uint +rbx.platform.typedef.__kernel_gid_t = uint +rbx.platform.typedef.__kernel_ino64_t = ulong_long +rbx.platform.typedef.__kernel_ino_t = ulong +rbx.platform.typedef.__kernel_ipc_pid_t = ushort +rbx.platform.typedef.__kernel_key_t = int +rbx.platform.typedef.__kernel_loff_t = long_long +rbx.platform.typedef.__kernel_long_t = long +rbx.platform.typedef.__kernel_mode_t = ushort +rbx.platform.typedef.__kernel_mqd_t = int +rbx.platform.typedef.__kernel_off64_t = long_long +rbx.platform.typedef.__kernel_off_t = long +rbx.platform.typedef.__kernel_old_dev_t = uint +rbx.platform.typedef.__kernel_old_gid_t = uint +rbx.platform.typedef.__kernel_old_time_t = long +rbx.platform.typedef.__kernel_old_uid_t = uint +rbx.platform.typedef.__kernel_pid_t = int +rbx.platform.typedef.__kernel_ptrdiff_t = int +rbx.platform.typedef.__kernel_size_t = uint +rbx.platform.typedef.__kernel_ssize_t = int +rbx.platform.typedef.__kernel_suseconds_t = long +rbx.platform.typedef.__kernel_time64_t = long_long +rbx.platform.typedef.__kernel_time_t = long +rbx.platform.typedef.__kernel_timer_t = int +rbx.platform.typedef.__kernel_uid16_t = ushort +rbx.platform.typedef.__kernel_uid32_t = uint +rbx.platform.typedef.__kernel_uid_t = uint +rbx.platform.typedef.__kernel_ulong_t = ulong +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds64_t = long_long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__thrd_t = ulong +rbx.platform.typedef.__time64_t = long_long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__tss_t = uint +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = long diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/hppa2.0-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/hppa2.0-linux/types.conf new file mode 100644 index 0000000..c8a8141 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/hppa2.0-linux/types.conf @@ -0,0 +1,178 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = int +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__kernel_caddr_t = string +rbx.platform.typedef.__kernel_clock_t = long +rbx.platform.typedef.__kernel_clockid_t = int +rbx.platform.typedef.__kernel_daddr_t = int +rbx.platform.typedef.__kernel_gid16_t = ushort +rbx.platform.typedef.__kernel_gid32_t = uint +rbx.platform.typedef.__kernel_gid_t = uint +rbx.platform.typedef.__kernel_ino64_t = ulong_long +rbx.platform.typedef.__kernel_ino_t = ulong +rbx.platform.typedef.__kernel_ipc_pid_t = ushort +rbx.platform.typedef.__kernel_key_t = int +rbx.platform.typedef.__kernel_loff_t = long_long +rbx.platform.typedef.__kernel_long_t = long +rbx.platform.typedef.__kernel_mode_t = ushort +rbx.platform.typedef.__kernel_mqd_t = int +rbx.platform.typedef.__kernel_off64_t = long_long +rbx.platform.typedef.__kernel_off_t = long +rbx.platform.typedef.__kernel_old_dev_t = uint +rbx.platform.typedef.__kernel_old_gid_t = uint +rbx.platform.typedef.__kernel_old_time_t = long +rbx.platform.typedef.__kernel_old_uid_t = uint +rbx.platform.typedef.__kernel_pid_t = int +rbx.platform.typedef.__kernel_ptrdiff_t = int +rbx.platform.typedef.__kernel_size_t = uint +rbx.platform.typedef.__kernel_ssize_t = int +rbx.platform.typedef.__kernel_suseconds_t = long +rbx.platform.typedef.__kernel_time64_t = long_long +rbx.platform.typedef.__kernel_time_t = long +rbx.platform.typedef.__kernel_timer_t = int +rbx.platform.typedef.__kernel_uid16_t = ushort +rbx.platform.typedef.__kernel_uid32_t = uint +rbx.platform.typedef.__kernel_uid_t = uint +rbx.platform.typedef.__kernel_ulong_t = ulong +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds64_t = long_long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__thrd_t = ulong +rbx.platform.typedef.__time64_t = long_long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__tss_t = uint +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = long diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-cygwin/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-cygwin/types.conf new file mode 100644 index 0000000..93f6b86 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-cygwin/types.conf @@ -0,0 +1,3 @@ +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.ssize_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-darwin/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-darwin/types.conf new file mode 100644 index 0000000..ae100f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-darwin/types.conf @@ -0,0 +1,100 @@ +rbx.platform.typedef.__darwin_blkcnt_t = long_long +rbx.platform.typedef.__darwin_blksize_t = int +rbx.platform.typedef.__darwin_clock_t = ulong +rbx.platform.typedef.__darwin_ct_rune_t = int +rbx.platform.typedef.__darwin_dev_t = int +rbx.platform.typedef.__darwin_fsblkcnt_t = uint +rbx.platform.typedef.__darwin_fsfilcnt_t = uint +rbx.platform.typedef.__darwin_gid_t = uint +rbx.platform.typedef.__darwin_id_t = uint +rbx.platform.typedef.__darwin_ino64_t = ulong_long +rbx.platform.typedef.__darwin_ino_t = ulong_long +rbx.platform.typedef.__darwin_intptr_t = long +rbx.platform.typedef.__darwin_mach_port_name_t = uint +rbx.platform.typedef.__darwin_mach_port_t = uint +rbx.platform.typedef.__darwin_mode_t = ushort +rbx.platform.typedef.__darwin_natural_t = uint +rbx.platform.typedef.__darwin_off_t = long_long +rbx.platform.typedef.__darwin_pid_t = int +rbx.platform.typedef.__darwin_pthread_key_t = ulong +rbx.platform.typedef.__darwin_ptrdiff_t = int +rbx.platform.typedef.__darwin_rune_t = int +rbx.platform.typedef.__darwin_sigset_t = uint +rbx.platform.typedef.__darwin_size_t = ulong +rbx.platform.typedef.__darwin_socklen_t = uint +rbx.platform.typedef.__darwin_ssize_t = long +rbx.platform.typedef.__darwin_suseconds_t = int +rbx.platform.typedef.__darwin_time_t = long +rbx.platform.typedef.__darwin_uid_t = uint +rbx.platform.typedef.__darwin_useconds_t = uint +rbx.platform.typedef.__darwin_uuid_t[16] = uchar +rbx.platform.typedef.__darwin_wchar_t = int +rbx.platform.typedef.__darwin_wint_t = int +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fd_mask = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = uint +rbx.platform.typedef.fsfilcnt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.syscall_arg_t = ulong_long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.user_addr_t = ulong_long +rbx.platform.typedef.user_long_t = long_long +rbx.platform.typedef.user_size_t = ulong_long +rbx.platform.typedef.user_ssize_t = long_long +rbx.platform.typedef.user_time_t = long_long +rbx.platform.typedef.user_ulong_t = ulong_long +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-freebsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-freebsd/types.conf new file mode 100644 index 0000000..6c882d4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-freebsd/types.conf @@ -0,0 +1,152 @@ + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint +rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int +rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int +rbx.platform.typedef.__critical_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = uint +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ushort +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = int +rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vm_offset_t = uint +rbx.platform.typedef.__vm_ooffset_t = long_long +rbx.platform.typedef.__vm_paddr_t = uint +rbx.platform.typedef.__vm_pindex_t = ulong_long +rbx.platform.typedef.__vm_size_t = uint +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.accmode_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int +rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int +rbx.platform.typedef.critical_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fflags_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = long +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = uint +rbx.platform.typedef.vm_ooffset_t = long_long +rbx.platform.typedef.vm_paddr_t = uint +rbx.platform.typedef.vm_pindex_t = ulong_long +rbx.platform.typedef.vm_size_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-freebsd12/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-freebsd12/types.conf new file mode 100644 index 0000000..523370d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-freebsd12/types.conf @@ -0,0 +1,152 @@ + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint +rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int +rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int +rbx.platform.typedef.__critical_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ulong_long +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = int +rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vm_offset_t = uint +rbx.platform.typedef.__vm_ooffset_t = long_long +rbx.platform.typedef.__vm_paddr_t = uint +rbx.platform.typedef.__vm_pindex_t = ulong_long +rbx.platform.typedef.__vm_size_t = uint +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.accmode_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int +rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int +rbx.platform.typedef.critical_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fflags_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = long +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ulong_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = uint +rbx.platform.typedef.vm_ooffset_t = long_long +rbx.platform.typedef.vm_paddr_t = uint +rbx.platform.typedef.vm_pindex_t = ulong_long +rbx.platform.typedef.vm_size_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-gnu/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-gnu/types.conf new file mode 100644 index 0000000..fa2fa8c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-gnu/types.conf @@ -0,0 +1,107 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsid_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__pthread_key = int +rbx.platform.typedef.__pthread_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__sigset_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.fsid_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.pthread_t = int +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.sigset_t = ulong +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-linux/types.conf new file mode 100644 index 0000000..feb6bc4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-linux/types.conf @@ -0,0 +1,103 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-netbsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-netbsd/types.conf new file mode 100644 index 0000000..a5aba89 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-netbsd/types.conf @@ -0,0 +1,126 @@ +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = int +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-openbsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-openbsd/types.conf new file mode 100644 index 0000000..15a0d61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-openbsd/types.conf @@ -0,0 +1,128 @@ +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = int +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-solaris/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-solaris/types.conf new file mode 100644 index 0000000..22a2414 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-solaris/types.conf @@ -0,0 +1,122 @@ +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.blkcnt64_t = long_long +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.datalink_id_t = uint +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong_long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt64_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.ipaddr_t = uint +rbx.platform.typedef.k_fltset_t = uint +rbx.platform.typedef.key_t = int +rbx.platform.typedef.len_t = ulong_long +rbx.platform.typedef.lgrp_id_t = long +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long +rbx.platform.typedef.major_t = ulong +rbx.platform.typedef.minor_t = ulong +rbx.platform.typedef.mode_t = ulong +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.o_dev_t = short +rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.o_nlink_t = short +rbx.platform.typedef.o_pid_t = short +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long_long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = long +rbx.platform.typedef.poolid_t = long +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = long +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = long +rbx.platform.typedef.t_uscalar_t = ulong +rbx.platform.typedef.taskid_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong_long +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = long diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-windows/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-windows/types.conf new file mode 100644 index 0000000..a5d0b05 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/i386-windows/types.conf @@ -0,0 +1,52 @@ +rbx.platform.typedef.__time32_t = long +rbx.platform.typedef.__time64_t = long_long +rbx.platform.typedef._dev_t = uint +rbx.platform.typedef._ino_t = ushort +rbx.platform.typedef._mode_t = ushort +rbx.platform.typedef._off64_t = long_long +rbx.platform.typedef._off_t = long +rbx.platform.typedef._pid_t = int +rbx.platform.typedef._sigset_t = ulong +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.errno_t = int +rbx.platform.typedef.ino_t = ushort +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = short +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.off32_t = long +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.rsize_t = uint +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.time_t = long +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ushort +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.wchar_t = ushort +rbx.platform.typedef.wctype_t = ushort +rbx.platform.typedef.wint_t = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/ia64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/ia64-linux/types.conf new file mode 100644 index 0000000..e0eeecc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/ia64-linux/types.conf @@ -0,0 +1,104 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/loongarch64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/loongarch64-linux/types.conf new file mode 100644 index 0000000..aa8716d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/loongarch64-linux/types.conf @@ -0,0 +1,141 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = long +rbx.platform.typedef.int_fast32_t = long +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ulong +rbx.platform.typedef.uint_fast32_t = ulong +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips-linux/types.conf new file mode 100644 index 0000000..24e8202 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips64-linux/types.conf new file mode 100644 index 0000000..b61f4f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips64-linux/types.conf @@ -0,0 +1,104 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips64el-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips64el-linux/types.conf new file mode 100644 index 0000000..b61f4f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mips64el-linux/types.conf @@ -0,0 +1,104 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsel-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsel-linux/types.conf new file mode 100644 index 0000000..24e8202 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsel-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa32r6-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa32r6-linux/types.conf new file mode 100644 index 0000000..24e8202 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa32r6-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa32r6el-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa32r6el-linux/types.conf new file mode 100644 index 0000000..24e8202 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa32r6el-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa64r6-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa64r6-linux/types.conf new file mode 100644 index 0000000..b61f4f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa64r6-linux/types.conf @@ -0,0 +1,104 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa64r6el-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa64r6el-linux/types.conf new file mode 100644 index 0000000..b61f4f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/mipsisa64r6el-linux/types.conf @@ -0,0 +1,104 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-aix/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-aix/types.conf new file mode 100644 index 0000000..cbd20e7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-aix/types.conf @@ -0,0 +1,180 @@ +rbx.platform.typedef.UTF32Char = uint +rbx.platform.typedef.UniChar = ushort +rbx.platform.typedef.__cptr32 = string +rbx.platform.typedef.__cptr64 = ulong_long +rbx.platform.typedef.__long32_t = long +rbx.platform.typedef.__long64_t = int +rbx.platform.typedef.__ptr32 = pointer +rbx.platform.typedef.__ptr64 = ulong_long +rbx.platform.typedef.__ulong32_t = ulong +rbx.platform.typedef.__ulong64_t = uint +rbx.platform.typedef.aptx_t = ushort +rbx.platform.typedef.blkcnt32_t = int +rbx.platform.typedef.blkcnt64_t = ulong_long +rbx.platform.typedef.blkcnt_t = int +rbx.platform.typedef.blksize32_t = int +rbx.platform.typedef.blksize64_t = ulong_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.boolean_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.chan_t = int +rbx.platform.typedef.class_id_t = uint +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = long_long +rbx.platform.typedef.cnt64_t = long_long +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.crid_t = int +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev32_t = uint +rbx.platform.typedef.dev64_t = ulong_long +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.esid_t = uint +rbx.platform.typedef.ext_t = int +rbx.platform.typedef.fpos64_t = long_long +rbx.platform.typedef.fpos_t = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino32_t = uint +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16 = short +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32 = int +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int32long64_t = int +rbx.platform.typedef.int64 = long_long +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8 = char +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = short +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intfast_t = int +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.krpn_t = int +rbx.platform.typedef.kvmhandle_t = ulong +rbx.platform.typedef.kvmid_t = long +rbx.platform.typedef.kvpn_t = int +rbx.platform.typedef.level_t = int +rbx.platform.typedef.liobn_t = uint +rbx.platform.typedef.long32int64_t = long +rbx.platform.typedef.longlong_t = long_long +rbx.platform.typedef.mid_t = pointer +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.mtyp_t = long +rbx.platform.typedef.nlink_t = short +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.paddr_t = long +rbx.platform.typedef.pdtx_t = int +rbx.platform.typedef.pid32_t = int +rbx.platform.typedef.pid64_t = ulong_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pshift_t = ushort +rbx.platform.typedef.psize_t = long_long +rbx.platform.typedef.psx_t = short +rbx.platform.typedef.ptex_t = ulong +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.rpn64_t = long_long +rbx.platform.typedef.rpn_t = int +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.signal_t = int +rbx.platform.typedef.size64_t = ulong_long +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.slab_t[12] = char +rbx.platform.typedef.snidx_t = int +rbx.platform.typedef.socklen_t = ulong +rbx.platform.typedef.soff_t = int +rbx.platform.typedef.sshift_t = ushort +rbx.platform.typedef.ssize64_t = long_long +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.swhatx_t = ulong +rbx.platform.typedef.tid32_t = int +rbx.platform.typedef.tid64_t = ulong_long +rbx.platform.typedef.tid_t = int +rbx.platform.typedef.time32_t = int +rbx.platform.typedef.time64_t = long_long +rbx.platform.typedef.time_t = int +rbx.platform.typedef.timer32_t = int +rbx.platform.typedef.timer64_t = long_long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16 = ushort +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32 = uint +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64 = ulong_long +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8 = uchar +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar = uchar +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint32long64_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ushort +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintfast_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong32int64_t = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unidx_t = int +rbx.platform.typedef.unit_addr_t = ulong_long +rbx.platform.typedef.ureg_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.va_list = string +rbx.platform.typedef.vmfkey_t = uint +rbx.platform.typedef.vmhandle32_t = uint +rbx.platform.typedef.vmhandle_t = ulong +rbx.platform.typedef.vmhwkey_t = int +rbx.platform.typedef.vmid32_t = int +rbx.platform.typedef.vmid64_t = long_long +rbx.platform.typedef.vmid_t = long +rbx.platform.typedef.vmidx_t = int +rbx.platform.typedef.vmkey_t = int +rbx.platform.typedef.vmlpghandle_t = ulong +rbx.platform.typedef.vmm_lock_t = int +rbx.platform.typedef.vmnodeidx_t = int +rbx.platform.typedef.vmprkey_t = uint +rbx.platform.typedef.vmsize_t = int +rbx.platform.typedef.vpn_t = int +rbx.platform.typedef.wchar_t = ushort +rbx.platform.typedef.wctype_t = uint +rbx.platform.typedef.wint_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-darwin/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-darwin/types.conf new file mode 100644 index 0000000..ae100f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-darwin/types.conf @@ -0,0 +1,100 @@ +rbx.platform.typedef.__darwin_blkcnt_t = long_long +rbx.platform.typedef.__darwin_blksize_t = int +rbx.platform.typedef.__darwin_clock_t = ulong +rbx.platform.typedef.__darwin_ct_rune_t = int +rbx.platform.typedef.__darwin_dev_t = int +rbx.platform.typedef.__darwin_fsblkcnt_t = uint +rbx.platform.typedef.__darwin_fsfilcnt_t = uint +rbx.platform.typedef.__darwin_gid_t = uint +rbx.platform.typedef.__darwin_id_t = uint +rbx.platform.typedef.__darwin_ino64_t = ulong_long +rbx.platform.typedef.__darwin_ino_t = ulong_long +rbx.platform.typedef.__darwin_intptr_t = long +rbx.platform.typedef.__darwin_mach_port_name_t = uint +rbx.platform.typedef.__darwin_mach_port_t = uint +rbx.platform.typedef.__darwin_mode_t = ushort +rbx.platform.typedef.__darwin_natural_t = uint +rbx.platform.typedef.__darwin_off_t = long_long +rbx.platform.typedef.__darwin_pid_t = int +rbx.platform.typedef.__darwin_pthread_key_t = ulong +rbx.platform.typedef.__darwin_ptrdiff_t = int +rbx.platform.typedef.__darwin_rune_t = int +rbx.platform.typedef.__darwin_sigset_t = uint +rbx.platform.typedef.__darwin_size_t = ulong +rbx.platform.typedef.__darwin_socklen_t = uint +rbx.platform.typedef.__darwin_ssize_t = long +rbx.platform.typedef.__darwin_suseconds_t = int +rbx.platform.typedef.__darwin_time_t = long +rbx.platform.typedef.__darwin_uid_t = uint +rbx.platform.typedef.__darwin_useconds_t = uint +rbx.platform.typedef.__darwin_uuid_t[16] = uchar +rbx.platform.typedef.__darwin_wchar_t = int +rbx.platform.typedef.__darwin_wint_t = int +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fd_mask = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = uint +rbx.platform.typedef.fsfilcnt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.syscall_arg_t = ulong_long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.user_addr_t = ulong_long +rbx.platform.typedef.user_long_t = long_long +rbx.platform.typedef.user_size_t = ulong_long +rbx.platform.typedef.user_ssize_t = long_long +rbx.platform.typedef.user_time_t = long_long +rbx.platform.typedef.user_ulong_t = ulong_long +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-linux/types.conf new file mode 100644 index 0000000..42eec13 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-linux/types.conf @@ -0,0 +1,130 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = int +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = long diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-openbsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-openbsd/types.conf new file mode 100644 index 0000000..aea7955 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc-openbsd/types.conf @@ -0,0 +1,156 @@ +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long_long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = long_long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = long_long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = int +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.sigset_t = uint +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uint +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong +rbx.platform.typedef.wchar_t = int +rbx.platform.typedef.wint_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc64-linux/types.conf new file mode 100644 index 0000000..b61f4f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc64-linux/types.conf @@ -0,0 +1,104 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc64le-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc64le-linux/types.conf new file mode 100644 index 0000000..9ac9c2e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/powerpc64le-linux/types.conf @@ -0,0 +1,100 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/riscv64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/riscv64-linux/types.conf new file mode 100644 index 0000000..ede0f98 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/riscv64-linux/types.conf @@ -0,0 +1,104 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/s390-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/s390-linux/types.conf new file mode 100644 index 0000000..291b032 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/s390-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/s390x-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/s390x-linux/types.conf new file mode 100644 index 0000000..32a7feb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/s390x-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparc-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparc-linux/types.conf new file mode 100644 index 0000000..aea09d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparc-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long +rbx.platform.typedef.__rlim64_t = ulong_long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = int +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparc-solaris/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparc-solaris/types.conf new file mode 100644 index 0000000..a1548e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparc-solaris/types.conf @@ -0,0 +1,128 @@ +rbx.platform.typedef.() = pointer +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.Psocklen_t = pointer +rbx.platform.typedef.avl_index_t = uint +rbx.platform.typedef.blkcnt64_t = long_long +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong_long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt64_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = long +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int) = pointer +rbx.platform.typedef.int) = pointer +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.ipaddr_t = uint +rbx.platform.typedef.k_fltset_t = uint +rbx.platform.typedef.key_t = int +rbx.platform.typedef.kid_t = int +rbx.platform.typedef.len_t = ulong_long +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long +rbx.platform.typedef.major_t = ulong +rbx.platform.typedef.minor_t = ulong +rbx.platform.typedef.mode_t = ulong +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.o_dev_t = short +rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.o_nlink_t = short +rbx.platform.typedef.o_pid_t = short +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long_long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = long +rbx.platform.typedef.poolid_t = long +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = long +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.size_t) = pointer +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = long +rbx.platform.typedef.t_uscalar_t = ulong +rbx.platform.typedef.taskid_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.ts_t = long_long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = long +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong_long +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = long diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-linux/types.conf new file mode 100644 index 0000000..7626bfc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-linux/types.conf @@ -0,0 +1,102 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int +rbx.platform.typedef.__swblk_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-openbsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-openbsd/types.conf new file mode 100644 index 0000000..aea7955 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-openbsd/types.conf @@ -0,0 +1,156 @@ +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long_long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = long_long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = long_long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = int +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.sigset_t = uint +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uint +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong +rbx.platform.typedef.wchar_t = int +rbx.platform.typedef.wint_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-solaris/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-solaris/types.conf new file mode 100644 index 0000000..a1548e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sparcv9-solaris/types.conf @@ -0,0 +1,128 @@ +rbx.platform.typedef.() = pointer +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.Psocklen_t = pointer +rbx.platform.typedef.avl_index_t = uint +rbx.platform.typedef.blkcnt64_t = long_long +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong_long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt64_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = long +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int) = pointer +rbx.platform.typedef.int) = pointer +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.ipaddr_t = uint +rbx.platform.typedef.k_fltset_t = uint +rbx.platform.typedef.key_t = int +rbx.platform.typedef.kid_t = int +rbx.platform.typedef.len_t = ulong_long +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long +rbx.platform.typedef.major_t = ulong +rbx.platform.typedef.minor_t = ulong +rbx.platform.typedef.mode_t = ulong +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.o_dev_t = short +rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.o_nlink_t = short +rbx.platform.typedef.o_pid_t = short +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long_long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = long +rbx.platform.typedef.poolid_t = long +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = long +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.size_t) = pointer +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = long +rbx.platform.typedef.t_uscalar_t = ulong +rbx.platform.typedef.taskid_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.ts_t = long_long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = long +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong_long +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = long diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sw_64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sw_64-linux/types.conf new file mode 100644 index 0000000..aa8716d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/sw_64-linux/types.conf @@ -0,0 +1,141 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = long +rbx.platform.typedef.int_fast32_t = long +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ulong +rbx.platform.typedef.uint_fast32_t = ulong +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-cygwin/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-cygwin/types.conf new file mode 100644 index 0000000..5bef6d7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-cygwin/types.conf @@ -0,0 +1,3 @@ +rbx.platform.typedef.ptrdiff_t = int64 +rbx.platform.typedef.size_t = uint64 +rbx.platform.typedef.ssize_t = int64 diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-darwin/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-darwin/types.conf new file mode 100644 index 0000000..68841bb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-darwin/types.conf @@ -0,0 +1,130 @@ +rbx.platform.typedef.__darwin_blkcnt_t = long_long +rbx.platform.typedef.__darwin_blksize_t = int +rbx.platform.typedef.__darwin_clock_t = ulong +rbx.platform.typedef.__darwin_ct_rune_t = int +rbx.platform.typedef.__darwin_dev_t = int +rbx.platform.typedef.__darwin_fsblkcnt_t = uint +rbx.platform.typedef.__darwin_fsfilcnt_t = uint +rbx.platform.typedef.__darwin_gid_t = uint +rbx.platform.typedef.__darwin_id_t = uint +rbx.platform.typedef.__darwin_ino64_t = ulong_long +rbx.platform.typedef.__darwin_ino_t = ulong_long +rbx.platform.typedef.__darwin_intptr_t = long +rbx.platform.typedef.__darwin_mach_port_name_t = uint +rbx.platform.typedef.__darwin_mach_port_t = uint +rbx.platform.typedef.__darwin_mode_t = ushort +rbx.platform.typedef.__darwin_natural_t = uint +rbx.platform.typedef.__darwin_off_t = long_long +rbx.platform.typedef.__darwin_pid_t = int +rbx.platform.typedef.__darwin_pthread_key_t = ulong +rbx.platform.typedef.__darwin_ptrdiff_t = long +rbx.platform.typedef.__darwin_rune_t = int +rbx.platform.typedef.__darwin_sigset_t = uint +rbx.platform.typedef.__darwin_size_t = ulong +rbx.platform.typedef.__darwin_socklen_t = uint +rbx.platform.typedef.__darwin_ssize_t = long +rbx.platform.typedef.__darwin_suseconds_t = int +rbx.platform.typedef.__darwin_time_t = long +rbx.platform.typedef.__darwin_uid_t = uint +rbx.platform.typedef.__darwin_useconds_t = uint +rbx.platform.typedef.__darwin_uuid_string_t[37] = char +rbx.platform.typedef.__darwin_uuid_t[16] = uchar +rbx.platform.typedef.__darwin_wchar_t = int +rbx.platform.typedef.__darwin_wint_t = int +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.errno_t = int +rbx.platform.typedef.fd_mask = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = uint +rbx.platform.typedef.fsfilcnt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = short +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.rsize_t = ulong +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.sae_associd_t = uint +rbx.platform.typedef.sae_connid_t = uint +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.syscall_arg_t = ulong_long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ushort +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.user_addr_t = ulong_long +rbx.platform.typedef.user_long_t = long_long +rbx.platform.typedef.user_off_t = long_long +rbx.platform.typedef.user_size_t = ulong_long +rbx.platform.typedef.user_ssize_t = long_long +rbx.platform.typedef.user_time_t = long_long +rbx.platform.typedef.user_ulong_t = ulong_long +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-dragonflybsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-dragonflybsd/types.conf new file mode 100644 index 0000000..889f6a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-dragonflybsd/types.conf @@ -0,0 +1,130 @@ +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.___wchar_t = int +rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = ulong +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intlp_t = long +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = long +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintlp_t = ulong +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.clockid_t = ulong +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = int +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = long +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_daddr_t = uint +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uint +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.v_caddr_t = pointer +rbx.platform.typedef.wchar_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-freebsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-freebsd/types.conf new file mode 100644 index 0000000..8dbe370 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-freebsd/types.conf @@ -0,0 +1,128 @@ +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long_long +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-freebsd12/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-freebsd12/types.conf new file mode 100644 index 0000000..31b1073 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-freebsd12/types.conf @@ -0,0 +1,158 @@ +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.___wchar_t = int +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__char16_t = ushort +rbx.platform.typedef.__char32_t = uint +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int +rbx.platform.typedef.__critical_t = long +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = long +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = long +rbx.platform.typedef.__rman_res_t = ulong +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = long +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__u_register_t = ulong +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = ulong +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vm_offset_t = ulong +rbx.platform.typedef.__vm_paddr_t = ulong +rbx.platform.typedef.__vm_size_t = ulong +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.accmode_t = int +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.cap_ioctl_t = ulong +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int +rbx.platform.typedef.critical_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fflags_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.ksize_t = ulong +rbx.platform.typedef.kvaddr_t = ulong +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off64_t = long +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = long +rbx.platform.typedef.rman_res_t = ulong +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.sbintime_t = long +rbx.platform.typedef.segsz_t = long +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_register_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = ulong +rbx.platform.typedef.vm_ooffset_t = long +rbx.platform.typedef.vm_paddr_t = ulong +rbx.platform.typedef.vm_pindex_t = ulong +rbx.platform.typedef.vm_size_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-haiku/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-haiku/types.conf new file mode 100644 index 0000000..d5ddfa7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-haiku/types.conf @@ -0,0 +1,117 @@ +rbx.platform.typedef.__haiku_addr_t = ulong +rbx.platform.typedef.__haiku_generic_addr_t = ulong +rbx.platform.typedef.__haiku_int16 = short +rbx.platform.typedef.__haiku_int32 = int +rbx.platform.typedef.__haiku_int64 = long +rbx.platform.typedef.__haiku_int8 = char +rbx.platform.typedef.__haiku_phys_addr_t = ulong +rbx.platform.typedef.__haiku_phys_saddr_t = long +rbx.platform.typedef.__haiku_saddr_t = long +rbx.platform.typedef.__haiku_std_int16 = short +rbx.platform.typedef.__haiku_std_int32 = int +rbx.platform.typedef.__haiku_std_int64 = long +rbx.platform.typedef.__haiku_std_int8 = char +rbx.platform.typedef.__haiku_std_uint16 = ushort +rbx.platform.typedef.__haiku_std_uint32 = uint +rbx.platform.typedef.__haiku_std_uint64 = ulong +rbx.platform.typedef.__haiku_std_uint8 = uchar +rbx.platform.typedef.__haiku_uint16 = ushort +rbx.platform.typedef.__haiku_uint32 = uint +rbx.platform.typedef.__haiku_uint64 = ulong +rbx.platform.typedef.__haiku_uint8 = uchar +rbx.platform.typedef.addr_t = ulong +rbx.platform.typedef.bigtime_t = long +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = pointer +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = int +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fd_mask = uint +rbx.platform.typedef.fsblkcnt_t = long +rbx.platform.typedef.fsfilcnt_t = long +rbx.platform.typedef.generic_addr_t = ulong +rbx.platform.typedef.generic_size_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = int +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = long +rbx.platform.typedef.int16 = short +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32 = int +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64 = long +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8 = char +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = int +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nanotime_t = long +rbx.platform.typedef.nlink_t = int +rbx.platform.typedef.off_t = long +rbx.platform.typedef.perform_code = uint +rbx.platform.typedef.phys_addr_t = ulong +rbx.platform.typedef.phys_size_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.sig_atomic_t = int +rbx.platform.typedef.sigset_t = ulong +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.status_t = int +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.time_t = long +rbx.platform.typedef.type_code = uint +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar = uchar +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16 = ushort +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32 = uint +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64 = ulong +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8 = uchar +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uint +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.umode_t = uint +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.unichar = ushort +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.void*) = pointer +rbx.platform.typedef.wchar_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-linux/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-linux/types.conf new file mode 100644 index 0000000..060f161 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-linux/types.conf @@ -0,0 +1,132 @@ +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long +rbx.platform.typedef.__rlim64_t = ulong +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = long +rbx.platform.typedef.int_fast32_t = long +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = pointer +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ulong +rbx.platform.typedef.uint_fast32_t = ulong +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.wchar_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-msys/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-msys/types.conf new file mode 100644 index 0000000..aa827c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-msys/types.conf @@ -0,0 +1,119 @@ +rbx.platform.typedef.*addr_t = char +rbx.platform.typedef.__ULong = uint +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = ulong +rbx.platform.typedef.__cpu_mask = ulong +rbx.platform.typedef.__dev_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long_long +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ushort +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__sigset_t = ulong +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = int +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = ulong +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = ulong +rbx.platform.typedef._fpos64_t = long_long +rbx.platform.typedef._fpos_t = long +rbx.platform.typedef._off64_t = long_long +rbx.platform.typedef._off_t = long +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.clockid_t = ulong +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = long +rbx.platform.typedef.int_fast32_t = long +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long_long +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sbintime_t = long +rbx.platform.typedef.sig_atomic_t = int +rbx.platform.typedef.sigset_t = ulong +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = ulong +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_register_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ulong +rbx.platform.typedef.uint_fast32_t = ulong +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.useconds_t = ulong +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = ulong +rbx.platform.typedef.vm_size_t = ulong +rbx.platform.typedef.wint_t = uint diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-netbsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-netbsd/types.conf new file mode 100644 index 0000000..15a0d61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-netbsd/types.conf @@ -0,0 +1,128 @@ +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = int +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-openbsd/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-openbsd/types.conf new file mode 100644 index 0000000..6abc9c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-openbsd/types.conf @@ -0,0 +1,134 @@ +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long_long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpuid_t = ulong +rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint +rbx.platform.typedef.__in_addr_t = uint +rbx.platform.typedef.__in_port_t = ushort +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__mode_t = uint +rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar +rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = long_long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = long_long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr_t = long_long +rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = long +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = int +rbx.platform.typedef.sigset_t = uint +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-solaris/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-solaris/types.conf new file mode 100644 index 0000000..a7890d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-solaris/types.conf @@ -0,0 +1,122 @@ +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.blkcnt64_t = long +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = int +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.datalink_id_t = uint +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt64_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = int +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.ipaddr_t = uint +rbx.platform.typedef.k_fltset_t = uint +rbx.platform.typedef.key_t = int +rbx.platform.typedef.len_t = ulong_long +rbx.platform.typedef.lgrp_id_t = int +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long +rbx.platform.typedef.major_t = uint +rbx.platform.typedef.minor_t = uint +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.o_dev_t = short +rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.o_nlink_t = short +rbx.platform.typedef.o_pid_t = short +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long +rbx.platform.typedef.off_t = long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.poolid_t = int +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = int +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = int +rbx.platform.typedef.t_uscalar_t = uint +rbx.platform.typedef.taskid_t = int +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = int diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-windows/types.conf b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-windows/types.conf new file mode 100644 index 0000000..5bdbbde --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/platform/x86_64-windows/types.conf @@ -0,0 +1,52 @@ +rbx.platform.typedef.__time32_t = long +rbx.platform.typedef.__time64_t = long_long +rbx.platform.typedef._dev_t = uint +rbx.platform.typedef._ino_t = ushort +rbx.platform.typedef._mode_t = ushort +rbx.platform.typedef._off64_t = long_long +rbx.platform.typedef._off_t = long +rbx.platform.typedef._pid_t = long_long +rbx.platform.typedef._sigset_t = ulong_long +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.errno_t = int +rbx.platform.typedef.ino_t = ushort +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = short +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long_long +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.off32_t = long +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = long_long +rbx.platform.typedef.ptrdiff_t = long_long +rbx.platform.typedef.rsize_t = ulong_long +rbx.platform.typedef.size_t = ulong_long +rbx.platform.typedef.ssize_t = long_long +rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ushort +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = ulong_long +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.wchar_t = ushort +rbx.platform.typedef.wctype_t = ushort +rbx.platform.typedef.wint_t = ushort diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/pointer.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/pointer.rb new file mode 100644 index 0000000..e65835f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/pointer.rb @@ -0,0 +1,167 @@ +# +# Copyright (C) 2008, 2009 Wayne Meissner +# Copyright (c) 2007, 2008 Evan Phoenix +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +require 'ffi/platform' + +# NOTE: all method definitions in this file are conditional on +# whether they are not already defined. This is needed because +# some Ruby implementations (e.g., TruffleRuby) might already +# provide these methods due to using FFI internally, and we +# should not override them to avoid warnings. + +module FFI + class Pointer + + # Pointer size + SIZE = Platform::ADDRESS_SIZE / 8 unless const_defined?(:SIZE) + + # Return the size of a pointer on the current platform, in bytes + # @return [Integer] + def self.size + SIZE + end unless respond_to?(:size) + + # @param [nil,Integer] len length of string to return + # @return [String] + # Read pointer's contents as a string, or the first +len+ bytes of the + # equivalent string if +len+ is not +nil+. + def read_string(len=nil) + if len + return ''.b if len == 0 + get_bytes(0, len) + else + get_string(0) + end + end unless method_defined?(:read_string) + + # @param [Integer] len length of string to return + # @return [String] + # Read the first +len+ bytes of pointer's contents as a string. + # + # Same as: + # ptr.read_string(len) # with len not nil + def read_string_length(len) + get_bytes(0, len) + end unless method_defined?(:read_string_length) + + # @return [String] + # Read pointer's contents as a string. + # + # Same as: + # ptr.read_string # with no len + def read_string_to_null + get_string(0) + end unless method_defined?(:read_string_to_null) + + # @param [String] str string to write + # @param [Integer] len length of string to return + # @return [self] + # Write +len+ first bytes of +str+ in pointer's contents. + # + # Same as: + # ptr.write_string(str, len) # with len not nil + def write_string_length(str, len) + put_bytes(0, str, 0, len) + end unless method_defined?(:write_string_length) + + # @param [String] str string to write + # @param [Integer] len length of string to return + # @return [self] + # Write +str+ in pointer's contents, or first +len+ bytes if + # +len+ is not +nil+. + def write_string(str, len=nil) + len = str.bytesize unless len + # Write the string data without NUL termination + put_bytes(0, str, 0, len) + end unless method_defined?(:write_string) + + # @param [Type] type type of data to read from pointer's contents + # @param [Symbol] reader method to send to +self+ to read +type+ + # @param [Integer] length + # @return [Array] + # Read an array of +type+ of length +length+. + # @example + # ptr.read_array_of_type(TYPE_UINT8, :read_uint8, 4) # -> [1, 2, 3, 4] + def read_array_of_type(type, reader, length) + ary = [] + size = FFI.type_size(type) + tmp = self + length.times { |j| + ary << tmp.send(reader) + tmp += size unless j == length-1 # avoid OOB + } + ary + end unless method_defined?(:read_array_of_type) + + # @param [Type] type type of data to write to pointer's contents + # @param [Symbol] writer method to send to +self+ to write +type+ + # @param [Array] ary + # @return [self] + # Write +ary+ in pointer's contents as +type+. + # @example + # ptr.write_array_of_type(TYPE_UINT8, :put_uint8, [1, 2, 3 ,4]) + def write_array_of_type(type, writer, ary) + size = FFI.type_size(type) + ary.each_with_index { |val, i| + break unless i < self.size + self.send(writer, i * size, val) + } + self + end unless method_defined?(:write_array_of_type) + + # @return [self] + def to_ptr + self + end unless method_defined?(:to_ptr) + + # @param [Symbol,Type] type of data to read + # @return [Object] + # Read pointer's contents as +type+ + # + # Same as: + # ptr.get(type, 0) + def read(type) + get(type, 0) + end unless method_defined?(:read) + + # @param [Symbol,Type] type of data to read + # @param [Object] value to write + # @return [nil] + # Write +value+ of type +type+ to pointer's content + # + # Same as: + # ptr.put(type, 0) + def write(type, value) + put(type, 0, value) + end unless method_defined?(:write) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct.rb new file mode 100644 index 0000000..bf6228a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct.rb @@ -0,0 +1,317 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# Copyright (C) 2008, 2009 Andrea Fazzi +# Copyright (C) 2008, 2009 Luc Heinrich +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +require 'ffi/platform' +require 'ffi/struct_layout' +require 'ffi/struct_layout_builder' +require 'ffi/struct_by_reference' + +module FFI + + class Struct + + # Get struct size + # @return [Integer] + def size + self.class.size + end + + # @return [Integer] Struct alignment + def alignment + self.class.alignment + end + alias_method :align, :alignment + + # (see FFI::StructLayout#offset_of) + def offset_of(name) + self.class.offset_of(name) + end + + # (see FFI::StructLayout#members) + def members + self.class.members + end + + # @return [Array] + # Get array of values from Struct fields. + def values + members.map { |m| self[m] } + end + + # (see FFI::StructLayout#offsets) + def offsets + self.class.offsets + end + + # Clear the struct content. + # @return [self] + def clear + pointer.clear + self + end + + # Get {Pointer} to struct content. + # @return [AbstractMemory] + def to_ptr + pointer + end + + # Get struct size + # @return [Integer] + def self.size + defined?(@layout) ? @layout.size : defined?(@size) ? @size : 0 + end + + # set struct size + # @param [Integer] size + # @return [size] + def self.size=(size) + raise ArgumentError, "Size already set" if defined?(@size) || defined?(@layout) + @size = size + end + + # @return (see Struct#alignment) + def self.alignment + @layout.alignment + end + + # (see FFI::Type#members) + def self.members + @layout.members + end + + # (see FFI::StructLayout#offsets) + def self.offsets + @layout.offsets + end + + # (see FFI::StructLayout#offset_of) + def self.offset_of(name) + @layout.offset_of(name) + end + + def self.in + ptr(:in) + end + + def self.out + ptr(:out) + end + + def self.ptr(flags = :inout) + @ref_data_type ||= Type::Mapped.new(StructByReference.new(self)) + end + + def self.val + @val_data_type ||= StructByValue.new(self) + end + + def self.by_value + self.val + end + + def self.by_ref(flags = :inout) + self.ptr(flags) + end + + class ManagedStructConverter < StructByReference + + # @param [Struct] struct_class + def initialize(struct_class) + super(struct_class) + + raise NoMethodError, "release() not implemented for class #{struct_class}" unless struct_class.respond_to? :release + @method = struct_class.method(:release) + end + + # @param [Pointer] ptr + # @param [nil] ctx + # @return [Struct] + def from_native(ptr, ctx) + struct_class.new(AutoPointer.new(ptr, @method)) + end + end + + def self.auto_ptr + @managed_type ||= Type::Mapped.new(ManagedStructConverter.new(self)) + end + + + class << self + public + + # @return [StructLayout] + # @overload layout + # @return [StructLayout] + # Get struct layout. + # @overload layout(*spec) + # @param [Array,Array(Hash)] spec + # @return [StructLayout] + # Create struct layout from +spec+. + # @example Creating a layout from an array +spec+ + # class MyStruct < Struct + # layout :field1, :int, + # :field2, :pointer, + # :field3, :string + # end + # @example Creating a layout from an array +spec+ with offset + # class MyStructWithOffset < Struct + # layout :field1, :int, + # :field2, :pointer, 6, # set offset to 6 for this field + # :field3, :string + # end + # @example Creating a layout from a hash +spec+ + # class MyStructFromHash < Struct + # layout :field1 => :int, + # :field2 => :pointer, + # :field3 => :string + # end + # @example Creating a layout with pointers to functions + # class MyFunctionTable < Struct + # layout :function1, callback([:int, :int], :int), + # :function2, callback([:pointer], :void), + # :field3, :string + # end + def layout(*spec) + return @layout if spec.size == 0 + + warn "[DEPRECATION] Struct layout is already defined for class #{self.inspect}. Redefinition as in #{caller[0]} will be disallowed in ffi-2.0." if defined?(@layout) + + builder = StructLayoutBuilder.new + builder.union = self < Union + builder.packed = @packed if defined?(@packed) + builder.alignment = @min_alignment if defined?(@min_alignment) + + if spec[0].kind_of?(Hash) + hash_layout(builder, spec) + else + array_layout(builder, spec) + end + builder.size = @size if defined?(@size) && @size > builder.size + cspec = builder.build + @layout = cspec unless self == Struct + @size = cspec.size + return cspec + end + + + protected + + def callback(params, ret) + mod = enclosing_module + ret_type = find_type(ret, mod) + if ret_type == Type::STRING + raise TypeError, ":string is not allowed as return type of callbacks" + end + FFI::CallbackInfo.new(ret_type, params.map { |e| find_type(e, mod) }) + end + + def packed(packed = 1) + @packed = packed + end + alias :pack :packed + + def aligned(alignment = 1) + @min_alignment = alignment + end + alias :align :aligned + + def enclosing_module + begin + mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) } + if mod.respond_to?(:find_type) && (mod.is_a?(FFI::Library) || mod < FFI::Struct) + mod + end + rescue Exception + nil + end + end + + + def find_field_type(type, mod = enclosing_module) + if type.kind_of?(Class) && type < Struct + FFI::Type::Struct.new(type) + + elsif type.kind_of?(Class) && type < FFI::StructLayout::Field + type + + elsif type.kind_of?(::Array) + FFI::Type::Array.new(find_field_type(type[0]), type[1]) + + else + find_type(type, mod) + end + end + + def find_type(type, mod = enclosing_module) + if mod + mod.find_type(type) + end || FFI.find_type(type) + end + + private + + # @param [StructLayoutBuilder] builder + # @param [Hash] spec + # @return [builder] + # Add hash +spec+ to +builder+. + def hash_layout(builder, spec) + spec[0].each do |name, type| + builder.add name, find_field_type(type), nil + end + end + + # @param [StructLayoutBuilder] builder + # @param [Array] spec + # @return [builder] + # Add array +spec+ to +builder+. + def array_layout(builder, spec) + i = 0 + while i < spec.size + name, type = spec[i, 2] + i += 2 + + # If the next param is a Integer, it specifies the offset + if spec[i].kind_of?(Integer) + offset = spec[i] + i += 1 + else + offset = nil + end + + builder.add name, find_field_type(type), offset + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_by_reference.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_by_reference.rb new file mode 100644 index 0000000..27f25ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_by_reference.rb @@ -0,0 +1,72 @@ +# +# Copyright (C) 2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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.# + +module FFI + # This class includes the {FFI::DataConverter} module. + class StructByReference + include DataConverter + + attr_reader :struct_class + + # @param [Struct] struct_class + def initialize(struct_class) + unless Class === struct_class and struct_class < FFI::Struct + raise TypeError, 'wrong type (expected subclass of FFI::Struct)' + end + @struct_class = struct_class + end + + # Always get {FFI::Type}::POINTER. + def native_type + FFI::Type::POINTER + end + + # @param [nil, Struct] value + # @param [nil] ctx + # @return [AbstractMemory] Pointer on +value+. + def to_native(value, ctx) + return Pointer::NULL if value.nil? + + unless @struct_class === value + raise TypeError, "wrong argument type #{value.class} (expected #{@struct_class})" + end + + value.pointer + end + + # @param [AbstractMemory] value + # @param [nil] ctx + # @return [Struct] + # Create a struct from content of memory +value+. + def from_native(value, ctx) + @struct_class.new(value) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_layout.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_layout.rb new file mode 100644 index 0000000..fb84202 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_layout.rb @@ -0,0 +1,96 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# Copyright (C) 2008, 2009 Andrea Fazzi +# Copyright (C) 2008, 2009 Luc Heinrich +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +module FFI + + class StructLayout + + # @return [Array + # Get an array of tuples (field name, offset of the field). + def offsets + members.map { |m| [ m, self[m].offset ] } + end + + # @return [Integer] + # Get the offset of a field. + def offset_of(field_name) + self[field_name].offset + end + + # An enum {Field} in a {StructLayout}. + class Enum < Field + + # @param [AbstractMemory] ptr pointer on a {Struct} + # @return [Object] + # Get an object of type {#type} from memory pointed by +ptr+. + def get(ptr) + type.find(ptr.get_int(offset)) + end + + # @param [AbstractMemory] ptr pointer on a {Struct} + # @param value + # @return [nil] + # Set +value+ into memory pointed by +ptr+. + def put(ptr, value) + ptr.put_int(offset, type.find(value)) + end + + end + + class InnerStruct < Field + def get(ptr) + type.struct_class.new(ptr.slice(self.offset, self.size)) + end + + def put(ptr, value) + raise TypeError, "wrong value type (expected #{type.struct_class})" unless value.is_a?(type.struct_class) + ptr.slice(self.offset, self.size).__copy_from__(value.pointer, self.size) + end + end + + class Mapped < Field + def initialize(name, offset, type, orig_field) + @orig_field = orig_field + super(name, offset, type) + end + + def get(ptr) + type.from_native(@orig_field.get(ptr), nil) + end + + def put(ptr, value) + @orig_field.put(ptr, type.to_native(value, nil)) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_layout_builder.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_layout_builder.rb new file mode 100644 index 0000000..2221a60 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/struct_layout_builder.rb @@ -0,0 +1,227 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +module FFI + + # Build a {StructLayout struct layout}. + class StructLayoutBuilder + attr_reader :size + attr_reader :alignment + + def initialize + @size = 0 + @alignment = 1 + @min_alignment = 1 + @packed = false + @union = false + @fields = Array.new + end + + # Set size attribute with +size+ only if +size+ is greater than attribute value. + # @param [Integer] size + def size=(size) + @size = size if size > @size + end + + # Set alignment attribute with +align+ only if it is greater than attribute value. + # @param [Integer] align + def alignment=(align) + @alignment = align if align > @alignment + @min_alignment = align + end + + # Set union attribute. + # Set to +true+ to build a {Union} instead of a {Struct}. + # @param [Boolean] is_union + # @return [is_union] + def union=(is_union) + @union = is_union + end + + # Building a {Union} or a {Struct} ? + # + # @return [Boolean] + # + def union? + @union + end + + # Set packed attribute + # @overload packed=(packed) Set alignment and packed attributes to + # +packed+. + # + # @param [Integer] packed + # + # @return [packed] + # @overload packed=(packed) Set packed attribute. + # @param packed + # + # @return [0,1] + # + def packed=(packed) + if packed.is_a?(0.class) + @alignment = packed + @packed = packed + else + @packed = packed ? 1 : 0 + end + end + + + # List of number types + NUMBER_TYPES = [ + Type::INT8, + Type::UINT8, + Type::INT16, + Type::UINT16, + Type::INT32, + Type::UINT32, + Type::LONG, + Type::ULONG, + Type::INT64, + Type::UINT64, + Type::FLOAT32, + Type::FLOAT64, + Type::LONGDOUBLE, + Type::BOOL, + ].freeze + + # @param [String, Symbol] name name of the field + # @param [Array, DataConverter, Struct, StructLayout::Field, Symbol, Type] type type of the field + # @param [Integer, nil] offset + # @return [self] + # Add a field to the builder. + # @note Setting +offset+ to +nil+ or +-1+ is equivalent to +0+. + def add(name, type, offset = nil) + + if offset.nil? || offset == -1 + offset = @union ? 0 : align(@size, @packed ? [ @packed, type.alignment ].min : [ @min_alignment, type.alignment ].max) + end + + # + # If a FFI::Type type was passed in as the field arg, try and convert to a StructLayout::Field instance + # + field = type.is_a?(StructLayout::Field) ? type : field_for_type(name, offset, type) + @fields << field + @alignment = [ @alignment, field.alignment ].max unless @packed + @size = [ @size, field.size + (@union ? 0 : field.offset) ].max + + return self + end + + # @param (see #add) + # @return (see #add) + # Same as {#add}. + # @see #add + def add_field(name, type, offset = nil) + add(name, type, offset) + end + + # @param (see #add) + # @return (see #add) + # Add a struct as a field to the builder. + def add_struct(name, type, offset = nil) + add(name, Type::Struct.new(type), offset) + end + + # @param name (see #add) + # @param type (see #add) + # @param [Integer] count array length + # @param offset (see #add) + # @return (see #add) + # Add an array as a field to the builder. + def add_array(name, type, count, offset = nil) + add(name, Type::Array.new(type, count), offset) + end + + # @return [StructLayout] + # Build and return the struct layout. + def build + # Add tail padding if the struct is not packed + size = @packed ? @size : align(@size, @alignment) + + layout = StructLayout.new(@fields, size, @alignment) + layout.__union! if @union + layout + end + + private + + # @param [Integer] offset + # @param [Integer] align + # @return [Integer] + def align(offset, align) + align + ((offset - 1) & ~(align - 1)); + end + + # @param (see #add) + # @return [StructLayout::Field] + def field_for_type(name, offset, type) + field_class = case + when type.is_a?(Type::Function) + StructLayout::Function + + when type.is_a?(Type::Struct) + StructLayout::InnerStruct + + when type.is_a?(Type::Array) + StructLayout::Array + + when type.is_a?(FFI::Enum) + StructLayout::Enum + + when NUMBER_TYPES.include?(type) + StructLayout::Number + + when type == Type::POINTER + StructLayout::Pointer + + when type == Type::STRING + StructLayout::String + + when type.is_a?(Class) && type < StructLayout::Field + type + + when type.is_a?(DataConverter) + return StructLayout::Mapped.new(name, offset, Type::Mapped.new(type), field_for_type(name, offset, type.native_type)) + + when type.is_a?(Type::Mapped) + return StructLayout::Mapped.new(name, offset, type, field_for_type(name, offset, type.native_type)) + + else + raise TypeError, "invalid struct field type #{type.inspect}" + end + + field_class.new(name, offset, type) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/const_generator.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/const_generator.rb new file mode 100644 index 0000000..70ba9c2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/const_generator.rb @@ -0,0 +1,232 @@ +require 'tempfile' +require 'open3' + +module FFI + + # ConstGenerator turns C constants into ruby values. + # + # @example a simple example for stdio + # require 'ffi/tools/const_generator' + # cg = FFI::ConstGenerator.new('stdio') do |gen| + # gen.const(:SEEK_SET) + # gen.const('SEEK_CUR') + # gen.const('seek_end') # this constant does not exist + # end # #calculate called automatically at the end of the block + # + # cg['SEEK_SET'] # => 0 + # cg['SEEK_CUR'] # => 1 + # cg['seek_end'] # => nil + # cg.to_ruby # => "SEEK_SET = 0\nSEEK_CUR = 1\n# seek_end not available" + class ConstGenerator + @options = {} + attr_reader :constants + + # Creates a new constant generator that uses +prefix+ as a name, and an + # options hash. + # + # The only option is +:required+, which if set to +true+ raises an error if a + # constant you have requested was not found. + # + # @param [#to_s] prefix + # @param [Hash] options + # @return + # @option options [Boolean] :required + # @overload initialize(prefix, options) + # @overload initialize(prefix, options) { |gen| ... } + # @yieldparam [ConstGenerator] gen new generator is passed to the block + # When passed a block, {#calculate} is automatically called at the end of + # the block, otherwise you must call it yourself. + def initialize(prefix = nil, options = {}) + @includes = ['stdio.h', 'stddef.h'] + @constants = {} + @prefix = prefix + + @required = options[:required] + @options = options + + if block_given? then + yield self + calculate self.class.options.merge(options) + end + end + # Set class options + # These options are merged with {#initialize} options when it is called with a block. + # @param [Hash] options + # @return [Hash] class options + def self.options=(options) + @options = options + end + # Get class options. + # @return [Hash] class options + def self.options + @options + end + # @param [String] name + # @return constant value (converted if a +converter+ was defined). + # Access a constant by name. + def [](name) + @constants[name].converted_value + end + + # Request the value for C constant +name+. + # + # @param [#to_s] name C constant name + # @param [String] format a printf format string to print the value out + # @param [String] cast a C cast for the value + # @param ruby_name alternate ruby name for {#to_ruby} + # + # @overload const(name, format=nil, cast='', ruby_name=nil, converter=nil) + # +converter+ is a Method or a Proc. + # @param [#call] converter convert the value from a string to the appropriate + # type for {#to_ruby}. + # @overload const(name, format=nil, cast='', ruby_name=nil) { |value| ... } + # Use a converter block. This block convert the value from a string to the + # appropriate type for {#to_ruby}. + # @yieldparam value constant value + def const(name, format = nil, cast = '', ruby_name = nil, converter = nil, + &converter_proc) + format ||= '%d' + cast ||= '' + + if converter_proc and converter then + raise ArgumentError, "Supply only converter or converter block" + end + + converter = converter_proc if converter.nil? + + const = Constant.new name, format, cast, ruby_name, converter + @constants[name.to_s] = const + return const + end + + # Calculate constants values. + # @param [Hash] options + # @option options [String] :cppflags flags for C compiler + # @return [nil] + # @raise if a constant is missing and +:required+ was set to +true+ (see {#initialize}) + def calculate(options = {}) + binary_path = nil + + Tempfile.open("#{@prefix}.const_generator") do |f| + binary_path = f.path + ".bin" + @includes.each do |inc| + f.puts "#include <#{inc}>" + end + f.puts "\nint main(int argc, char **argv)\n{" + + @constants.each_value do |const| + f.puts <<-EOF + #ifdef #{const.name} + printf("#{const.name} #{const.format}\\n", #{const.cast}#{const.name}); + #endif + EOF + end + + f.puts "\n\treturn 0;\n}" + f.flush + + cc = ENV['CC'] || 'gcc' + output = `#{cc} #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary_path} 2>&1` + + unless $?.success? then + output = output.split("\n").map { |l| "\t#{l}" }.join "\n" + raise "Compilation error generating constants #{@prefix}:\n#{output}" + end + end + + output = `#{binary_path}` + File.unlink(binary_path + (FFI::Platform.windows? ? ".exe" : "")) + output.each_line do |line| + line =~ /^(\S+)\s(.*)$/ + const = @constants[$1] + const.value = $2 + end + + missing_constants = @constants.select do |name, constant| + constant.value.nil? + end.map { |name,| name } + + if @required and not missing_constants.empty? then + raise "Missing required constants for #{@prefix}: #{missing_constants.join ', '}" + end + end + + # Dump constants to +io+. + # @param [#puts] io + # @return [nil] + def dump_constants(io) + @constants.each do |name, constant| + name = [@prefix, name].join '.' if @prefix + io.puts "#{name} = #{constant.converted_value}" + end + end + + # Outputs values for discovered constants. If the constant's value was + # not discovered it is not omitted. + # @return [String] + def to_ruby + @constants.sort_by { |name,| name }.map do |name, constant| + if constant.value.nil? then + "# #{name} not available" + else + constant.to_ruby + end + end.join "\n" + end + + # Add additional C include file(s) to calculate constants from. + # @note +stdio.h+ and +stddef.h+ automatically included + # @param [List, Array] i include file(s) + # @return [Array] array of include files + def include(*i) + @includes |= i.flatten + end + + end + + # This class hold constants for {ConstGenerator} + class ConstGenerator::Constant + + attr_reader :name, :format, :cast + attr_accessor :value + + # @param [#to_s] name + # @param [String] format a printf format string to print the value out + # @param [String] cast a C cast for the value + # @param ruby_name alternate ruby name for {#to_ruby} + # @param [#call] converter convert the value from a string to the appropriate + # type for {#to_ruby}. + def initialize(name, format, cast, ruby_name = nil, converter=nil) + @name = name + @format = format + @cast = cast + @ruby_name = ruby_name + @converter = converter + @value = nil + end + + # Return constant value (converted if a +converter+ was defined). + # @return constant value. + def converted_value + if @converter + @converter.call(@value) + else + @value + end + end + + # get constant ruby name + # @return [String] + def ruby_name + @ruby_name || @name + end + + # Get an evaluable string from constant. + # @return [String] + def to_ruby + "#{ruby_name} = #{converted_value}" + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/generator.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/generator.rb new file mode 100644 index 0000000..5552ea5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/generator.rb @@ -0,0 +1,105 @@ +require 'ffi/tools/struct_generator' +require 'ffi/tools/const_generator' + +module FFI + + ## + # Generate files with C structs for FFI::Struct and C constants. + # + # == A simple example + # + # In file +zlib.rb.ffi+: + # module Zlib + # @@@ + # constants do |c| + # c.include "zlib.h" + # c.const :ZLIB_VERNUM + # end + # @@@ + # + # class ZStream < FFI::Struct + # + # struct do |s| + # s.name "struct z_stream_s" + # s.include "zlib.h" + # + # s.field :next_in, :pointer + # s.field :avail_in, :uint + # s.field :total_in, :ulong + # end + # @@@ + # end + # end + # + # Translate the file: + # require "ffi/tools/generator" + # FFI::Generator.new "zlib.rb.ffi", "zlib.rb" + # + # Generates the file +zlib.rb+ with constant values and offsets: + # module Zlib + # ZLIB_VERNUM = 4784 + # + # class ZStream < FFI::Struct + # layout :next_in, :pointer, 0, + # :avail_in, :uint, 8, + # :total_in, :ulong, 16 + # end + # + # @see FFI::Generator::Task for easy integration in a Rakefile + class Generator + + def initialize(ffi_name, rb_name, options = {}) + @ffi_name = ffi_name + @rb_name = rb_name + @options = options + @name = File.basename rb_name, '.rb' + + file = File.read @ffi_name + + new_file = file.gsub(/^( *)@@@(.*?)@@@/m) do + @constants = [] + @structs = [] + + indent = $1 + original_lines = $2.count "\n" + + instance_eval $2, @ffi_name, $`.count("\n") + + new_lines = [] + @constants.each { |c| new_lines << c.to_ruby } + @structs.each { |s| new_lines << s.generate_layout } + + new_lines = new_lines.join("\n").split "\n" # expand multiline blocks + new_lines = new_lines.map { |line| indent + line } + + padding = original_lines - new_lines.length + new_lines += [nil] * padding if padding >= 0 + + new_lines.join "\n" + end + + open @rb_name, 'w' do |f| + f.puts "# This file is generated from `#{@ffi_name}'. Do not edit." + f.puts + f.puts new_file + end + end + + def constants(options = {}, &block) + @constants << FFI::ConstGenerator.new(@name, @options.merge(options), &block) + end + + def struct(options = {}, &block) + @structs << FFI::StructGenerator.new(@name, @options.merge(options), &block) + end + + ## + # Utility converter for constants + + def to_s + proc { |obj| obj.to_s.inspect } + end + + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/generator_task.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/generator_task.rb new file mode 100644 index 0000000..da72968 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/generator_task.rb @@ -0,0 +1,32 @@ +require 'ffi/tools/generator' +require 'rake' +require 'rake/tasklib' + +## +# Add Rake tasks that generate files with C structs for FFI::Struct and C constants. +# +# @example a simple example for your Rakefile +# require "ffi/tools/generator_task" +# # Add a task to generate my_object.rb out of my_object.rb.ffi +# FFI::Generator::Task.new ["my_object.rb"], cflags: "-I/usr/local/mylibrary" +# +# The generated files are also added to the 'clear' task. +# +# @see FFI::Generator for a description of the file content +class FFI::Generator::Task < Rake::TaskLib + + def initialize(rb_names, options={}) + task :clean do rm_f rb_names end + + rb_names.each do |rb_name| + ffi_name = "#{rb_name}.ffi" + + file rb_name => ffi_name do |t| + puts "Generating #{rb_name}..." if Rake.application.options.trace + + FFI::Generator.new ffi_name, rb_name, options + end + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/struct_generator.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/struct_generator.rb new file mode 100644 index 0000000..3a951c3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/struct_generator.rb @@ -0,0 +1,195 @@ +require 'tempfile' + +module FFI + + ## + # Generates an FFI Struct layout. + # + # Given the @@@ portion in: + # + # class Zlib::ZStream < FFI::Struct + # @@@ + # name "struct z_stream_s" + # include "zlib.h" + # + # field :next_in, :pointer + # field :avail_in, :uint + # field :total_in, :ulong + # + # # ... + # @@@ + # end + # + # StructGenerator will create the layout: + # + # layout :next_in, :pointer, 0, + # :avail_in, :uint, 4, + # :total_in, :ulong, 8, + # # ... + # + # StructGenerator does its best to pad the layout it produces to preserve + # line numbers. Place the struct definition as close to the top of the file + # for best results. + + class StructGenerator + @options = {} + attr_accessor :size + attr_reader :fields + + def initialize(name, options = {}) + @name = name + @struct_name = nil + @includes = [] + @fields = [] + @found = false + @size = nil + + if block_given? then + yield self + calculate self.class.options.merge(options) + end + end + def self.options=(options) + @options = options + end + def self.options + @options + end + def calculate(options = {}) + binary = File.join Dir.tmpdir, "rb_struct_gen_bin_#{Process.pid}" + + raise "struct name not set" if @struct_name.nil? + + Tempfile.open("#{@name}.struct_generator") do |f| + f.puts "#include " + + @includes.each do |inc| + f.puts "#include <#{inc}>" + end + + f.puts "#include \n\n" + f.puts "int main(int argc, char **argv)\n{" + f.puts " #{@struct_name} s;" + f.puts %[ printf("sizeof(#{@struct_name}) %u\\n", (unsigned int) sizeof(#{@struct_name}));] + + @fields.each do |field| + f.puts <<-EOF + printf("#{field.name} %u %u\\n", (unsigned int) offsetof(#{@struct_name}, #{field.name}), + (unsigned int) sizeof(s.#{field.name})); + EOF + end + + f.puts "\n return 0;\n}" + f.flush + + cc = ENV['CC'] || 'gcc' + output = `#{cc} #{options[:cppflags]} #{options[:cflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary} 2>&1` + + unless $?.success? then + @found = false + output = output.split("\n").map { |l| "\t#{l}" }.join "\n" + raise "Compilation error generating struct #{@name} (#{@struct_name}):\n#{output}" + end + end + + output = `#{binary}`.split "\n" + File.unlink(binary + (FFI::Platform.windows? ? ".exe" : "")) + sizeof = output.shift + unless @size + m = /\s*sizeof\([^)]+\) (\d+)/.match sizeof + @size = m[1] + end + + line_no = 0 + output.each do |line| + md = line.match(/.+ (\d+) (\d+)/) + @fields[line_no].offset = md[1].to_i + @fields[line_no].size = md[2].to_i + + line_no += 1 + end + + @found = true + end + + def field(name, type=nil) + field = Field.new(name, type) + @fields << field + return field + end + + def found? + @found + end + + def dump_config(io) + io.puts "rbx.platform.#{@name}.sizeof = #{@size}" + + @fields.each { |field| io.puts field.to_config(@name) } + end + + def generate_layout + buf = "" + + @fields.each_with_index do |field, i| + if buf.empty? + buf << "layout :#{field.name}, :#{field.type}, #{field.offset}" + else + buf << " :#{field.name}, :#{field.type}, #{field.offset}" + end + + if i < @fields.length - 1 + buf << ",\n" + end + end + + buf + end + + def get_field(name) + @fields.find { |f| name == f.name } + end + + def include(i) + @includes << i + end + + def name(n) + @struct_name = n + end + + end + + ## + # A field in a Struct. + + class StructGenerator::Field + + attr_reader :name + attr_reader :type + attr_reader :offset + attr_accessor :size + + def initialize(name, type) + @name = name + @type = type + @offset = nil + @size = nil + end + + def offset=(o) + @offset = o + end + + def to_config(name) + buf = [] + buf << "rbx.platform.#{name}.#{@name}.offset = #{@offset}" + buf << "rbx.platform.#{name}.#{@name}.size = #{@size}" + buf << "rbx.platform.#{name}.#{@name}.type = #{@type}" if @type + buf + end + + end + +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/types_generator.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/types_generator.rb new file mode 100644 index 0000000..ba2d8c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/tools/types_generator.rb @@ -0,0 +1,137 @@ +require 'tempfile' + +module FFI + + # @private + class TypesGenerator + + ## + # Maps different C types to the C type representations we use + + TYPE_MAP = { + "char" => :char, + "signed char" => :char, + "__signed char" => :char, + "unsigned char" => :uchar, + + "short" => :short, + "signed short" => :short, + "signed short int" => :short, + "unsigned short" => :ushort, + "unsigned short int" => :ushort, + + "int" => :int, + "signed int" => :int, + "unsigned int" => :uint, + + "long" => :long, + "long int" => :long, + "signed long" => :long, + "signed long int" => :long, + "unsigned long" => :ulong, + "unsigned long int" => :ulong, + "long unsigned int" => :ulong, + + "long long" => :long_long, + "long long int" => :long_long, + "signed long long" => :long_long, + "signed long long int" => :long_long, + "unsigned long long" => :ulong_long, + "unsigned long long int" => :ulong_long, + + "char *" => :string, + "void *" => :pointer, + } + + def self.generate(options = {}) + typedefs = nil + Tempfile.open 'ffi_types_generator' do |io| + io.puts <<-C +#include +#include +#include +#if !(defined(WIN32)) +#include +#include +#include +#endif + C + + io.close + cc = ENV['CC'] || 'gcc' + cmd = "#{cc} -E -x c #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c" + if options[:input] + typedefs = File.read(options[:input]) + elsif options[:remote] + typedefs = `ssh #{options[:remote]} #{cmd} - < #{io.path}` + else + typedefs = `#{cmd} #{io.path}` + end + end + + code = [] + + typedefs.each_line do |type| + # We only care about single line typedef + next unless type =~ /typedef/ + # Ignore unions or structs + next if type =~ /union|struct/ + + # strip off the starting typedef and ending ; + type.gsub!(/^(.*typedef\s*)/, "") + type.gsub!(/\s*;\s*$/, "") + + parts = type.split(/\s+/) + def_type = parts.join(" ") + + # GCC does mapping with __attribute__ stuf, also see + # http://hal.cs.berkeley.edu/cil/cil016.html section 16.2.7. Problem + # with this is that the __attribute__ stuff can either occur before or + # after the new type that is defined... + if type =~ /__attribute__/ + if parts.last =~ /__QI__|__HI__|__SI__|__DI__|__word__/ + + # In this case, the new type is BEFORE __attribute__ we need to + # find the final_type as the type before the part that starts with + # __attribute__ + final_type = "" + parts.each do |p| + break if p =~ /__attribute__/ + final_type = p + end + else + final_type = parts.pop + end + + def_type = case type + when /__QI__/ then "char" + when /__HI__/ then "short" + when /__SI__/ then "int" + when /__DI__/ then "long long" + when /__word__/ then "long" + else "int" + end + + def_type = "unsigned #{def_type}" if type =~ /unsigned/ + else + final_type = parts.pop + def_type = parts.join(" ") + end + + if type = TYPE_MAP[def_type] + code << "rbx.platform.typedef.#{final_type} = #{type}" + TYPE_MAP[final_type] = TYPE_MAP[def_type] + else + # Fallback to an ordinary pointer if we don't know the type + if def_type =~ /\*/ + code << "rbx.platform.typedef.#{final_type} = pointer" + TYPE_MAP[final_type] = :pointer + end + end + end + + code.sort.join("\n") + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/types.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/types.rb new file mode 100644 index 0000000..6f3ee4b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/types.rb @@ -0,0 +1,222 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# Copyright (c) 2007, 2008 Evan Phoenix +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +# see {file:README} +module FFI + + # Unless custom_typedefs already defined in the C-ext? + unless defined?(custom_typedefs) + # Truffleruby and JRuby don't support Ractor so far. + # So they don't need separation between builtin and custom types. + def self.custom_typedefs + TypeDefs + end + writable_typemap = true + end + + class << self + + private :custom_typedefs + + # @param [Type, DataConverter, Symbol] old type definition used by {FFI.find_type} + # @param [Symbol] add new type definition's name to add + # @return [Type] + # Add a definition type to type definitions. + # + # The type definition is local per Ractor. + def typedef(old, add) + tm = custom_typedefs + tm[add] = find_type(old) + end + + # (see FFI.typedef) + def add_typedef(old, add) + typedef old, add + end + + private def __typedef(old, add) + TypeDefs[add] = find_type(old, TypeDefs) + end + + # @param [Type, DataConverter, Symbol] name + # @param [Hash] type_map if nil, {FFI::TypeDefs} is used + # @return [Type] + # Find a type in +type_map+ ({FFI::TypeDefs}, by default) from + # a type objet, a type name (symbol). If +name+ is a {DataConverter}, + # a new {Type::Mapped} is created. + def find_type(name, type_map = nil) + if name.is_a?(Type) + name + + elsif type_map&.has_key?(name) + type_map[name] + + elsif (tm=custom_typedefs).has_key?(name) + tm[name] + + elsif TypeDefs.has_key?(name) + TypeDefs[name] + + elsif name.is_a?(DataConverter) + # Add a typedef so next time the converter is used, it hits the cache + tm = (type_map || custom_typedefs) + tm[name] = Type::Mapped.new(name) + else + raise TypeError, "unable to resolve type '#{name}'" + end + end + + # @param type +type+ is an instance of class accepted by {FFI.find_type} + # @return [Integer] + # Get +type+ size, in bytes. + def type_size(type) + find_type(type).size + end + end + + # List of type definitions + TypeDefs.merge!({ + # The C void type; only useful for function return types + :void => Type::VOID, + + # C boolean type + :bool => Type::BOOL, + + # C nul-terminated string + :string => Type::STRING, + + # C signed char + :char => Type::CHAR, + # C unsigned char + :uchar => Type::UCHAR, + + # C signed short + :short => Type::SHORT, + # C unsigned short + :ushort => Type::USHORT, + + # C signed int + :int => Type::INT, + # C unsigned int + :uint => Type::UINT, + + # C signed long + :long => Type::LONG, + + # C unsigned long + :ulong => Type::ULONG, + + # C signed long long integer + :long_long => Type::LONG_LONG, + + # C unsigned long long integer + :ulong_long => Type::ULONG_LONG, + + # C single precision float + :float => Type::FLOAT, + + # C double precision float + :double => Type::DOUBLE, + + # C long double + :long_double => Type::LONGDOUBLE, + + # Native memory address + :pointer => Type::POINTER, + + # 8 bit signed integer + :int8 => Type::INT8, + # 8 bit unsigned integer + :uint8 => Type::UINT8, + + # 16 bit signed integer + :int16 => Type::INT16, + # 16 bit unsigned integer + :uint16 => Type::UINT16, + + # 32 bit signed integer + :int32 => Type::INT32, + # 32 bit unsigned integer + :uint32 => Type::UINT32, + + # 64 bit signed integer + :int64 => Type::INT64, + # 64 bit unsigned integer + :uint64 => Type::UINT64, + + :buffer_in => Type::BUFFER_IN, + :buffer_out => Type::BUFFER_OUT, + :buffer_inout => Type::BUFFER_INOUT, + + # Used in function prototypes to indicate the arguments are variadic + :varargs => Type::VARARGS, + }) + + # This will convert a pointer to a Ruby string (just like `:string`), but + # also allow to work with the pointer itself. This is useful when you want + # a Ruby string already containing a copy of the data, but also the pointer + # to the data for you to do something with it, like freeing it, in case the + # library handed the memory off to the caller (Ruby-FFI). + # + # It's {typedef}'d as +:strptr+. + class StrPtrConverter + extend DataConverter + native_type Type::POINTER + + # @param [Pointer] val + # @param ctx not used + # @return [Array(String, Pointer)] + # Returns a [ String, Pointer ] tuple so the C memory for the string can be freed + def self.from_native(val, ctx) + [ val.null? ? nil : val.get_string(0), val ] + end + end + + __typedef(StrPtrConverter, :strptr) + + # Load all the platform dependent types + begin + File.open(File.join(Platform::CONF_DIR, 'types.conf'), "r") do |f| + prefix = "rbx.platform.typedef." + f.each_line { |line| + if line.index(prefix) == 0 + new_type, orig_type = line.chomp.slice(prefix.length..-1).split(/\s*=\s*/) + __typedef(orig_type.to_sym, new_type.to_sym) + end + } + end + __typedef :pointer, :caddr_t + rescue Errno::ENOENT + end + + FFI.make_shareable(TypeDefs) unless writable_typemap +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/union.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/union.rb new file mode 100644 index 0000000..38414ab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/union.rb @@ -0,0 +1,43 @@ +# +# Copyright (C) 2009 Andrea Fazzi +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +require 'ffi/struct' + +module FFI + + class Union < FFI::Struct + def self.builder + b = StructLayoutBuilder.new + b.union = true + b + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/variadic.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/variadic.rb new file mode 100644 index 0000000..ee33409 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/variadic.rb @@ -0,0 +1,80 @@ +# +# Copyright (C) 2008, 2009 Wayne Meissner +# Copyright (C) 2009 Luc Heinrich +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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 OWNER 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. +# + +module FFI + class VariadicInvoker + def call(*args, &block) + param_types = Array.new(@fixed) + param_values = Array.new + @fixed.each_with_index do |t, i| + param_values << args[i] + end + i = @fixed.length + while i < args.length + param_types << FFI.find_type(args[i], @type_map) + param_values << args[i + 1] + i += 2 + end + invoke(param_types, param_values, &block) + end + + # + # Attach the invoker to module +mod+ as +mname+ + # + def attach(mod, mname) + invoker = self + params = "*args" + call = "call" + mname = mname.to_sym + mod.module_eval <<-code, __FILE__, __LINE__ + @ffi_functions = {} unless defined?(@ffi_functions) + @ffi_functions[#{mname.inspect}] = invoker + + def self.#{mname}(#{params}) + @ffi_functions[#{mname.inspect}].#{call}(#{params}) + end + + define_method(#{mname.inspect}, &method(#{mname.inspect})) + code + invoker + end + + # Retrieve Array of parameter types + # + # This method returns an Array of FFI types accepted as function parameters. + # + # @return [Array] + def param_types + [*@fixed, Type::Builtin::VARARGS] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/version.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/version.rb new file mode 100644 index 0000000..c661ffb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/lib/ffi/version.rb @@ -0,0 +1,3 @@ +module FFI + VERSION = '1.17.0' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/rakelib/ffi_gem_helper.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/rakelib/ffi_gem_helper.rb new file mode 100644 index 0000000..74be131 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/rakelib/ffi_gem_helper.rb @@ -0,0 +1,65 @@ +require 'bundler' +require 'bundler/gem_helper' + +class FfiGemHelper < Bundler::GemHelper + attr_accessor :cross_platforms + + def install + super + + task "release:guard_clean" => ["release:update_history"] + + task "release:update_history" do + update_history + end + + task "release:rubygem_push" => ["gem:native", "gem:java"] + end + + def hfile + "CHANGELOG.md" + end + + def headline + '([^\w]*)(\d+\.\d+\.\d+(?:\.\w+)?)([^\w]+)([2Y][0Y][0-9Y][0-9Y]-[0-1M][0-9M]-[0-3D][0-9D])([^\w]*|$)' + end + + def reldate + Time.now.strftime("%Y-%m-%d") + end + + def update_history + hin = File.read(hfile) + hout = hin.sub(/#{headline}/) do + raise "#{hfile} isn't up-to-date for version #{version}" unless $2==version.to_s + $1 + $2 + $3 + reldate + $5 + end + if hout != hin + Bundler.ui.confirm "Updating #{hfile} for release." + File.write(hfile, hout) + Rake::FileUtilsExt.sh "git", "commit", hfile, "-m", "Update release date in #{hfile}" + end + end + + def tag_version + Bundler.ui.confirm "Tag release with annotation:" + m = File.read(hfile).match(/(?#{headline}.*?)#{headline}/m) || raise("Unable to find release notes in #{hfile}") + Bundler.ui.info(m[:annotation].gsub(/^/, " ")) + IO.popen(["git", "tag", "--file=-", version_tag], "w") do |fd| + fd.write m[:annotation] + end + yield if block_given? + rescue + Bundler.ui.error "Untagging #{version_tag} due to error." + sh_with_code "git tag -d #{version_tag}" + raise + end + + def rubygem_push(path) + cross_platforms.each do |ruby_platform| + super(path.gsub(/\.gem\z/, "-#{ruby_platform}.gem")) + end + super(path.gsub(/\.gem\z/, "-java.gem")) + super(path) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/getlogin.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/getlogin.rb new file mode 100644 index 0000000..6713021 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/getlogin.rb @@ -0,0 +1,8 @@ +require 'ffi' + +module Foo + extend FFI::Library + ffi_lib FFI::Library::LIBC + attach_function :getlogin, [ ], :string +end +puts "getlogin=#{Foo.getlogin}" diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/getpid.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/getpid.rb new file mode 100644 index 0000000..1720635 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/getpid.rb @@ -0,0 +1,8 @@ +require 'ffi' + +module Foo + extend FFI::Library + ffi_lib FFI::Library::LIBC + attach_function :getpid, [ ], :int +end +puts "My pid=#{Foo.getpid}" diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/gettimeofday.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/gettimeofday.rb new file mode 100644 index 0000000..864bbb6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/gettimeofday.rb @@ -0,0 +1,18 @@ +require 'ffi' +require 'rbconfig' + +class Timeval < FFI::Struct + layout tv_sec: :ulong, tv_usec: :ulong +end +module LibC + extend FFI::Library + if FFI::Platform.windows? + ffi_lib RbConfig::CONFIG["LIBRUBY_SO"] + else + ffi_lib FFI::Library::LIBC + end + attach_function :gettimeofday, [ :pointer, :pointer ], :int +end +t = Timeval.new +LibC.gettimeofday(t.pointer, nil) +puts "t.tv_sec=#{t[:tv_sec]} t.tv_usec=#{t[:tv_usec]}" diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/hello.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/hello.rb new file mode 100644 index 0000000..f2ccf37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/hello.rb @@ -0,0 +1,8 @@ +require 'ffi' + +module Foo + extend FFI::Library + ffi_lib FFI::Library::LIBC + attach_function("cputs", "puts", [ :string ], :int) +end +Foo.cputs("Hello, World via libc puts using FFI on MRI ruby") diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/hello_ractor.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/hello_ractor.rb new file mode 100644 index 0000000..904fe85 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/hello_ractor.rb @@ -0,0 +1,11 @@ +require 'ffi' + +module Foo + extend FFI::Library + ffi_lib FFI::Library::LIBC + attach_function("cputs", "puts", [ :string ], :int) + freeze +end +Ractor.new do + Foo.cputs("Hello, World via libc puts using FFI in a Ractor") +end.take diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/inotify.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/inotify.rb new file mode 100644 index 0000000..018d78c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/inotify.rb @@ -0,0 +1,60 @@ +require 'ffi' + +module Inotify + extend FFI::Library + ffi_lib FFI::Library::LIBC + class Event < FFI::Struct + layout \ + :wd, :int, + :mask, :uint, + :cookie, :uint, + :len, :uint + end + attach_function :init, :inotify_init, [ ], :int + attach_function :add_watch, :inotify_add_watch, [ :int, :string, :uint ], :int + attach_function :rm_watch, :inotify_rm_watch, [ :int, :uint ], :int + attach_function :read, [ :int, :buffer_out, :uint ], :int + IN_ACCESS=0x00000001 + IN_MODIFY=0x00000002 + IN_ATTRIB=0x00000004 + IN_CLOSE_WRITE=0x00000008 + IN_CLOSE_NOWRITE=0x00000010 + IN_CLOSE=(IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) + IN_OPEN=0x00000020 + IN_MOVED_FROM=0x00000040 + IN_MOVED_TO=0x00000080 + IN_MOVE= (IN_MOVED_FROM | IN_MOVED_TO) + IN_CREATE=0x00000100 + IN_DELETE=0x00000200 + IN_DELETE_SELF=0x00000400 + IN_MOVE_SELF=0x00000800 + # Events sent by the kernel. + IN_UNMOUNT=0x00002000 + IN_Q_OVERFLOW=0x00004000 + IN_IGNORED=0x00008000 + IN_ONLYDIR=0x01000000 + IN_DONT_FOLLOW=0x02000000 + IN_MASK_ADD=0x20000000 + IN_ISDIR=0x40000000 + IN_ONESHOT=0x80000000 + IN_ALL_EVENTS=(IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE \ + | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM \ + | IN_MOVED_TO | IN_CREATE | IN_DELETE \ + | IN_DELETE_SELF | IN_MOVE_SELF) + +end +if $0 == __FILE__ + fd = Inotify.init + puts "fd=#{fd}" + wd = Inotify.add_watch(fd, "/tmp/", Inotify::IN_ALL_EVENTS) + fp = FFI::IO.for_fd(fd) + puts "wfp=#{fp}" + while true + buf = FFI::Buffer.alloc_out(Inotify::Event.size + 4096, 1, false) + ev = Inotify::Event.new buf + ready = IO.select([ fp ], nil, nil, nil) + n = Inotify.read(fd, buf, buf.total) + puts "Read #{n} bytes from inotify fd" + puts "event.wd=#{ev[:wd]} mask=#{ev[:mask]} len=#{ev[:len]} name=#{ev[:len] > 0 ? buf.get_string(16) : 'unknown'}" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/pty.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/pty.rb new file mode 100644 index 0000000..8b6b885 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/pty.rb @@ -0,0 +1,75 @@ +require 'ffi' + +module PTY + private + module LibC + extend FFI::Library + ffi_lib FFI::Library::LIBC + attach_function :forkpty, [ :buffer_out, :buffer_out, :buffer_in, :buffer_in ], :int + attach_function :openpty, [ :buffer_out, :buffer_out, :buffer_out, :buffer_in, :buffer_in ], :int + attach_function :login_tty, [ :int ], :int + attach_function :close, [ :int ], :int + attach_function :strerror, [ :int ], :string + attach_function :fork, [], :int + attach_function :execv, [ :string, :buffer_in ], :int + attach_function :execvp, [ :string, :buffer_in ], :int + attach_function :dup2, [ :int, :int ], :int + attach_function :dup, [ :int ], :int + end + Buffer = FFI::Buffer + def self.build_args(args) + cmd = args.shift + cmd_args = args.map do |arg| + MemoryPointer.from_string(arg) + end + exec_args = MemoryPointer.new(:pointer, 1 + cmd_args.length + 1) + exec_cmd = MemoryPointer.from_string(cmd) + exec_args[0].put_pointer(0, exec_cmd) + cmd_args.each_with_index do |arg, i| + exec_args[i + 1].put_pointer(0, arg) + end + [ cmd, exec_args ] + end + public + def self.getpty(*args) + mfdp = Buffer.new :int + name = Buffer.new 1024 + # + # All the execv setup is done in the parent, since doing anything other than + # execv in the child after fork is really flakey + # + exec_cmd, exec_args = build_args(args) + pid = LibC.forkpty(mfdp, name, nil, nil) + raise "forkpty failed: #{LibC.strerror(FFI.errno)}" if pid < 0 + if pid == 0 + LibC.execvp(exec_cmd, exec_args) + exit 1 + end + masterfd = mfdp.get_int(0) + rfp = FFI::IO.for_fd(masterfd, "r") + wfp = FFI::IO.for_fd(LibC.dup(masterfd), "w") + if block_given? + yield rfp, wfp, pid + rfp.close unless rfp.closed? + wfp.close unless wfp.closed? + else + [ rfp, wfp, pid ] + end + end + def self.spawn(*args, &block) + self.getpty("/bin/sh", "-c", args[0], &block) + end +end +module LibC + extend FFI::Library + attach_function :close, [ :int ], :int + attach_function :write, [ :int, :buffer_in, :ulong ], :long + attach_function :read, [ :int, :buffer_out, :ulong ], :long +end +PTY.getpty("/bin/ls", "-alR", "/") { |rfd, wfd, pid| +#PTY.spawn("ls -laR /") { |rfd, wfd, pid| + puts "child pid=#{pid}" + while !rfd.eof? && (buf = rfd.gets) + puts "child: '#{buf.strip}'" + end +} diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/qsort.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/qsort.rb new file mode 100644 index 0000000..58622c1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/qsort.rb @@ -0,0 +1,20 @@ +require 'ffi' + +module LibC + extend FFI::Library + ffi_lib FFI::Library::LIBC + callback :qsort_cmp, [ :pointer, :pointer ], :int + attach_function :qsort, [ :pointer, :ulong, :ulong, :qsort_cmp ], :int +end + +p = FFI::MemoryPointer.new(:int, 2) +p.put_array_of_int32(0, [ 2, 1 ]) +puts "ptr=#{p.inspect}" +puts "Before qsort #{p.get_array_of_int32(0, 2).join(', ')}" +LibC.qsort(p, 2, 4) do |p1, p2| + i1 = p1.get_int32(0) + i2 = p2.get_int32(0) + puts "In block: comparing #{i1} and #{i2}" + i1 < i2 ? -1 : i1 > i2 ? 1 : 0 +end +puts "After qsort #{p.get_array_of_int32(0, 2).join(', ')}" diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/qsort_ractor.rb b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/qsort_ractor.rb new file mode 100644 index 0000000..db085de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/samples/qsort_ractor.rb @@ -0,0 +1,28 @@ +require 'ffi' + +module LibC + extend FFI::Library + ffi_lib FFI::Library::LIBC + callback :qsort_cmp, [ :pointer, :pointer ], :int + attach_function :qsort, [ :pointer, :ulong, :ulong, :qsort_cmp ], :int + + freeze # Freeze the module variables, so that it can be shared across ractors. +end + +p = FFI::MemoryPointer.new(:int, 3) +p.put_array_of_int32(0, [ 2, 3, 1 ]) # Write some unsorted data into the memory +# Ractor.make_shareable(p) # freeze the pointer to be shared between ractors instead of copied +puts "main -ptr=#{p.inspect}" +res = Ractor.new(p) do |p| + puts "ractor-ptr=#{p.inspect}" + puts "Before qsort #{p.get_array_of_int32(0, 3).join(', ')}" + LibC.qsort(p, 3, 4) do |p1, p2| + i1 = p1.get_int32(0) + i2 = p2.get_int32(0) + puts "In block: comparing #{i1} and #{i2}" + i1 < i2 ? -1 : i1 > i2 ? 1 : 0 + end + puts "After qsort #{p.get_array_of_int32(0, 3).join(', ')}" +end.take + +puts "After ractor termination #{p.get_array_of_int32(0, 3).join(', ')}" diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi.rbs new file mode 100644 index 0000000..c40ad6f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi.rbs @@ -0,0 +1,26 @@ +module FFI + type ffi_type = Type | Symbol + type ffi_auto_type = ffi_type | DataConverter[untyped, untyped, untyped] + type type_map = Hash[Symbol | DataConverter[untyped, untyped, untyped], Type] + + class CallbackInfo = FunctionType + class FunctionInfo = FunctionType + class NativeLibrary = DynamicLibrary + + VERSION: String + TypeDefs: type_map + + type current_process = Object + CURRENT_PROCESS: current_process + USE_THIS_PROCESS_AS_LIBRARY: current_process + + private def self.custom_typedefs: () -> type_map + def self.errno: () -> Integer + def self.errno=: (Integer) -> nil + def self.find_type: (ffi_auto_type name, ?type_map? type_map) -> Type + def self.make_shareable: [T] (T obj) -> T + def self.map_library_name: (_ToS lib) -> String + def self.type_size: (ffi_auto_type type) -> Integer + def self.typedef: (ffi_auto_type old, Symbol add) -> Type + alias self.add_typedef self.typedef +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/abstract_memory.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/abstract_memory.rbs new file mode 100644 index 0000000..9678ad0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/abstract_memory.rbs @@ -0,0 +1,165 @@ +module FFI + class AbstractMemory + interface _Size + def size: () -> Integer + end + include _Size + type type_size = Integer | _Size | Symbol + + type order_out = :big | :little + type order_in = order_out | :network + + def []: (Integer idx) -> instance + def clear: () -> self + def freeze: ... + def get: (ffi_type type, Integer offset) -> top + def put: (ffi_type type, Integer offset, top value) -> nil + def size_limit?: () -> bool + def type_size: () -> Integer + alias total size + + def get_int8: (Integer offset) -> Integer + def get_int16: (Integer offset) -> Integer + def get_int32: (Integer offset) -> Integer + def get_int64: (Integer offset) -> Integer + def get_uint8: (Integer offset) -> Integer + def get_uint16: (Integer offset) -> Integer + def get_uint32: (Integer offset) -> Integer + def get_uint64: (Integer offset) -> Integer + def get_char: (Integer offset) -> Integer + def get_short: (Integer offset) -> Integer + def get_int: (Integer offset) -> Integer + def get_long_long: (Integer offset) -> Integer + def get_float32: (Integer offset) -> Float + def get_float64: (Integer offset) -> Float + def get_pointer: (Integer offset) -> Pointer + def get_bytes: (Integer offset, Integer length) -> String + def get_string: (Integer offset, ?Integer? length) -> String + alias get_float get_float32 + alias get_double get_float64 + + def put_int8: (Integer offset, int value) -> self + def put_int16: (Integer offset, int value) -> self + def put_int32: (Integer offset, int value) -> self + def put_int64: (Integer offset, int value) -> self + def put_uint8: (Integer offset, int value) -> self + def put_uint16: (Integer offset, int value) -> self + def put_uint32: (Integer offset, int value) -> self + def put_uint64: (Integer offset, int value) -> self + def put_char: (Integer offset, int value) -> self + def put_short: (Integer offset, int value) -> self + def put_int: (Integer offset, int value) -> self + def put_long_long: (Integer offset, int value) -> self + def put_float32: (Integer offset, Numeric value) -> self + def put_float64: (Integer offset, Numeric value) -> self + def put_pointer: (Integer offset, pointer value) -> self + def put_bytes: (Integer offset, String str, ?Integer index, ?Integer? length) -> self + def put_string: (Integer offset, String value) -> self + alias put_float put_float32 + alias put_double put_float64 + + def read_int8: () -> Integer + def read_int16: () -> Integer + def read_int32: () -> Integer + def read_int64: () -> Integer + def read_uint8: () -> Integer + def read_uint16: () -> Integer + def read_uint32: () -> Integer + def read_uint64: () -> Integer + def read_char: () -> Integer + def read_short: () -> Integer + def read_int: () -> Integer + def read_long_long: () -> Integer + def read_float: () -> Float + def read_double: () -> Float + def read_pointer: () -> Pointer + def read_bytes: (Integer length) -> String + + def write_int8: (int value) -> self + def write_int16: (int value) -> self + def write_int32: (int value) -> self + def write_int64: (int value) -> self + def write_uint8: (int value) -> self + def write_uint16: (int value) -> self + def write_uint32: (int value) -> self + def write_uint64: (int value) -> self + def write_char: (int value) -> self + def write_short: (int value) -> self + def write_int: (int value) -> self + def write_long_long: (int value) -> self + def write_float: (Numeric value) -> self + def write_double: (Numeric value) -> self + def write_pointer: (pointer value) -> self + def write_bytes: (String str, ?Integer index, ?Integer? length) -> self + + def get_array_of_int8: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_int16: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_int32: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_int64: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_uint8: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_uint16: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_uint32: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_uint64: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_char: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_short: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_int: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_long_long: (Integer offset, Integer length) -> Array[Integer] + def get_array_of_float32: (Integer offset, Integer length) -> Array[Float] + def get_array_of_float64: (Integer offset, Integer length) -> Array[Float] + def get_array_of_pointer: (Integer offset, Integer length) -> Array[Pointer] + def get_array_of_string: (Integer offset, ?Integer? count) -> Array[String?] + alias get_array_of_float get_array_of_float32 + alias get_array_of_double get_array_of_float64 + + def put_array_of_int8: (Integer offset, Array[int] ary) -> self + def put_array_of_int16: (Integer offset, Array[int] ary) -> self + def put_array_of_int32: (Integer offset, Array[int] ary) -> self + def put_array_of_int64: (Integer offset, Array[int] ary) -> self + def put_array_of_uint8: (Integer offset, Array[int] ary) -> self + def put_array_of_uint16: (Integer offset, Array[int] ary) -> self + def put_array_of_uint32: (Integer offset, Array[int] ary) -> self + def put_array_of_uint64: (Integer offset, Array[int] ary) -> self + def put_array_of_char: (Integer offset, Array[int] ary) -> self + def put_array_of_short: (Integer offset, Array[int] ary) -> self + def put_array_of_int: (Integer offset, Array[int] ary) -> self + def put_array_of_long_long: (Integer offset, Array[int] ary) -> self + def put_array_of_float32: (Integer offset, Array[Numeric] ary) -> self + def put_array_of_float64: (Integer offset, Array[Numeric] ary) -> self + def put_array_of_pointer: (Integer offset, Array[pointer] ary) -> self + alias put_array_of_float put_array_of_float32 + alias put_array_of_double put_array_of_float64 + + def read_array_of_int8: (Integer length) -> Array[Integer] + def read_array_of_int16: (Integer length) -> Array[Integer] + def read_array_of_int32: (Integer length) -> Array[Integer] + def read_array_of_int64: (Integer length) -> Array[Integer] + def read_array_of_uint8: (Integer length) -> Array[Integer] + def read_array_of_uint16: (Integer length) -> Array[Integer] + def read_array_of_uint32: (Integer length) -> Array[Integer] + def read_array_of_uint64: (Integer length) -> Array[Integer] + def read_array_of_char: (Integer length) -> Array[Integer] + def read_array_of_short: (Integer length) -> Array[Integer] + def read_array_of_int: (Integer length) -> Array[Integer] + def read_array_of_long_long: (Integer length) -> Array[Integer] + def read_array_of_float: (Integer length) -> Array[Float] + def read_array_of_double: (Integer length) -> Array[Float] + def read_array_of_pointer: (Integer length) -> Array[Pointer] + def read_array_of_string: (?Integer? count) -> Array[String?] + + def write_array_of_int8: (Array[int] ary) -> self + def write_array_of_int16: (Array[int] ary) -> self + def write_array_of_int32: (Array[int] ary) -> self + def write_array_of_int64: (Array[int] ary) -> self + def write_array_of_uint8: (Array[int] ary) -> self + def write_array_of_uint16: (Array[int] ary) -> self + def write_array_of_uint32: (Array[int] ary) -> self + def write_array_of_uint64: (Array[int] ary) -> self + def write_array_of_char: (Array[int] ary) -> self + def write_array_of_short: (Array[int] ary) -> self + def write_array_of_int: (Array[int] ary) -> self + def write_array_of_long_long: (Array[int] ary) -> self + def write_array_of_float: (Array[Numeric] ary) -> self + def write_array_of_double: (Array[Numeric] ary) -> self + def write_array_of_pointer: (Array[pointer] ary) -> self + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/auto_pointer.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/auto_pointer.rbs new file mode 100644 index 0000000..e3a131e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/auto_pointer.rbs @@ -0,0 +1,27 @@ +module FFI + class AutoPointer < Pointer + class Releaser + attr_accessor autorelease: boolish + interface _Proc[P < Pointer] + def call: (P) -> void + end + def initialize: [P < Pointer] (P ptr, _Proc[P] proc) -> void + + def call: (*untyped) -> void + def free: () -> nil + def release: (Pointer ptr) -> void + end + + def initialize: (Pointer pointer, Method | ^(self) -> void | Releaser::_Proc[self] callable) -> self + # | (Pointer pointer) { (self) -> void } -> self # https://github.com/ffi/ffi/issues/1071 + | (Pointer pointer) -> self # where class < `def self.release: (instance pointer) -> void` + + extend DataConverter[Pointer, instance, nil] + def self.from_native: ... + def self.native_type: () -> Type::Builtin + + def autorelease?: ... + def autorelease=: ... + def free: () -> nil + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/buffer.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/buffer.rbs new file mode 100644 index 0000000..68cde6b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/buffer.rbs @@ -0,0 +1,18 @@ +module FFI + class Buffer < AbstractMemory + def initialize: (AbstractMemory::type_size, ?Integer count, boolish clear) -> self + alias self.alloc_inout self.new + alias self.new_inout self.alloc_inout + alias self.alloc_in self.alloc_inout + alias self.new_in self.alloc_in + alias self.alloc_out self.alloc_inout + alias self.new_out self.alloc_out + + def +: (Integer) -> Buffer + def inspect: ... + def order: () -> AbstractMemory::order_out + | (AbstractMemory::order_in order) -> Buffer + | (untyped order) -> (self | Buffer) + def slice: (Integer offset, Integer length) -> Buffer + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/data_converter.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/data_converter.rbs new file mode 100644 index 0000000..a0e2e39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/data_converter.rbs @@ -0,0 +1,10 @@ +module FFI + interface _DataConverter[N, R, in C] + def from_native: (N value, C ctx) -> R + def native_type: (?ffi_auto_type? type) -> Type + def to_native: (R value, C ctx) -> N + end + module DataConverter[N, R, in C] + include _DataConverter[N, R, C] + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/dynamic_library.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/dynamic_library.rbs new file mode 100644 index 0000000..48031bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/dynamic_library.rbs @@ -0,0 +1,9 @@ +module FFI + class DynamicLibrary + # TODO + + class Symbol < Pointer + # TODO + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/enum.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/enum.rbs new file mode 100644 index 0000000..3cae0b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/enum.rbs @@ -0,0 +1,38 @@ +module FFI + class Enums + def initialize: () -> void + + def <<: (Enum enum) -> void + def __map_symbol: (Symbol symbol) -> Integer? + def find: (Symbol query) -> Enum + end + + class Enum + include DataConverter[Integer, Symbol | Integer, untyped] + + attr_reader native_type: Type + attr_reader tag: Symbol? + def initialize: (Enumerable[Symbol | Integer], ?Symbol? tag, *untyped) -> void + | (Type native_type, Enumerable[Symbol | Integer], ?Symbol? tag, *untyped) -> void + + def []: (Symbol query) -> Integer? + | (Integer query) -> Symbol? + def symbol_map: () -> Hash[Symbol, Integer] + alias to_h symbol_map + alias to_hash symbol_map + def symbols: () -> Array[Symbol] + def to_native: (Symbol | int value, untyped ctx) -> Integer + end + + class Bitmask < Enum + def initialize: ... + + def []: (*Symbol query) -> Integer + | (Array[Symbol] query) -> Integer + | (*Integer query) -> Array[Symbol] + | (Array[Integer] query) -> Array[Symbol] + def from_native: (Integer, untyped ctx) -> Array[Symbol | Integer] + def to_native: (Array[Symbol | int] value, untyped ctx) -> Integer + | ... + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/function.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/function.rbs new file mode 100644 index 0000000..94a23c2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/function.rbs @@ -0,0 +1,39 @@ +module FFI + interface _Function + # TODO: leads to a endless recursion when used with -rrbs/test/setup + # def attach: (Module mod, String name) -> self + def call: (*untyped args) -> untyped + def param_types: () -> Array[Type] + def return_type: () -> Type + end + + class Function < Pointer + include _Function + # ?blocking: boolish?, ?convention: Library::convention?, ?enums: Enums? + def initialize: + ( + ffi_type return_type, Array[ffi_type] param_types, + ?Hash[Symbol, untyped] options + ) { (*untyped) -> untyped } -> self + | ( + ffi_type return_type, Array[ffi_type] param_types, Proc | Pointer proc, + ?Hash[Symbol, untyped] options + ) -> self + + def autorelease?: ... + alias autorelease autorelease? + def autorelease=: ... + def free: () -> self + end + + class VariadicInvoker + include _Function + def initialize: + ( + Pointer function, Array[ffi_type] parameter_types, ffi_type return_type, + Hash[Symbol, untyped] options #TODO + ) -> void + + def invoke: (Array[Type] parameter_types, Array[untyped] parameter_values) -> untyped + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/library.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/library.rbs new file mode 100644 index 0000000..413d31a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/library.rbs @@ -0,0 +1,42 @@ +module FFI + module Library + type convention = :default | :stdcall + type ffi_lib_flag = :global | :local | :lazy | :now + type ffi_lib_type = ffi_auto_type | singleton(Struct) + + CURRENT_PROCESS: current_process + LIBC: String + FlagsMap: Hash[ffi_lib_flag, Integer] + + def self.extended: ... + + def attach_function: ( _ToS func, Array[ffi_lib_type] args, ffi_lib_type? returns, ?blocking: boolish, ?convention: convention, ?enums: Enums, ?type_map: type_map) -> (Function | VariadicInvoker) + | (_ToS name, _ToS func, Array[ffi_lib_type] args, ?ffi_lib_type? returns, ?blocking: boolish, ?convention: convention, ?enums: Enums, ?type_map: type_map) -> (Function | VariadicInvoker) + def attach_variable: (?_ToS mname, _ToS cname, ffi_lib_type type) -> DynamicLibrary::Symbol + def attached_functions: () -> Hash[Symbol, Function | VariadicInvoker] + def attached_variables: () -> Hash[Symbol, Type | singleton(Struct)] + + def bitmask: (?Type native_type, Symbol name, Array[Symbol | Integer] values) -> Bitmask + | (?Type native_type, *Symbol | Integer args) -> Bitmask + | (?Type native_type, Array[Symbol | Integer] values) -> Bitmask + def enum: (?Type native_type, Symbol name, Array[Symbol | Integer] values) -> Enum + | (?Type native_type, *Symbol | Integer args) -> Enum + | (?Type native_type, Array[Symbol | Integer] values) -> Enum + def enum_type: (Symbol name) -> Enum? + def enum_for: (Symbol name) -> Integer? + + def callback: (?Symbol name, Array[ffi_lib_type] params, ffi_lib_type ret) -> CallbackInfo + def ffi_convention: (?convention? convention) -> convention + def ffi_lib: (*_ToS names) -> Array[DynamicLibrary] + def ffi_lib_flags: (*ffi_lib_flag flags) -> Integer + def ffi_libraries: () -> Array[DynamicLibrary] + def find_type: (ffi_lib_type t) -> Type + def freeze: () -> void + def function_names: (_ToS name, Array[Type | singleton(Struct)] arg_types) -> Array[String] + def typedef: [T < Type] (T old, Symbol | DataConverter add, ?untyped) -> T + | (Symbol old, Symbol add, ?untyped) -> (Type | Enum) + | [X < DataConverter[N, R, C], N, R, C] (X old, Symbol add, ?untyped) -> Type::Mapped[X, N, R, C] + | (:enum old, Array[Symbol | Integer] add, ?untyped) -> Enum + | (:enum old, Symbol | Type add, Array[Symbol | Integer] info) -> Enum + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/native_type.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/native_type.rbs new file mode 100644 index 0000000..c9617a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/native_type.rbs @@ -0,0 +1,86 @@ +module FFI + class Type + INT8: Builtin + SCHAR: Builtin + CHAR: Builtin + UINT8: Builtin + UCHAR: Builtin + INT16: Builtin + SHORT: Builtin + SSHORT: Builtin + UINT16: Builtin + USHORT: Builtin + INT32: Builtin + INT: Builtin + SINT: Builtin + UINT32: Builtin + UINT: Builtin + INT64: Builtin + LONG_LONG: Builtin + SLONG_LONG: Builtin + UINT64: Builtin + ULONG_LONG: Builtin + LONG: Builtin + SLONG: Builtin + ULONG: Builtin + FLOAT32: Builtin + FLOAT: Builtin + FLOAT64: Builtin + DOUBLE: Builtin + LONGDOUBLE: Builtin + POINTER: Builtin + BOOL: Builtin + STRING: Builtin + BUFFER_IN: Builtin + BUFFER_OUT: Builtin + BUFFER_INOUT: Builtin + VARARGS: Builtin + VOID: Builtin + end + + module NativeType + INT8: Type::Builtin + UINT8: Type::Builtin + INT16: Type::Builtin + UINT16: Type::Builtin + INT32: Type::Builtin + UINT32: Type::Builtin + INT64: Type::Builtin + UINT64: Type::Builtin + LONG: Type::Builtin + ULONG: Type::Builtin + FLOAT32: Type::Builtin + FLOAT64: Type::Builtin + LONGDOUBLE: Type::Builtin + POINTER: Type::Builtin + BOOL: Type::Builtin + STRING: Type::Builtin + BUFFER_IN: Type::Builtin + BUFFER_OUT: Type::Builtin + BUFFER_INOUT: Type::Builtin + VARARGS: Type::Builtin + VOID: Type::Builtin + end + + TYPE_INT8: Type::Builtin + TYPE_UINT8: Type::Builtin + TYPE_INT16: Type::Builtin + TYPE_UINT16: Type::Builtin + TYPE_INT32: Type::Builtin + TYPE_UINT32: Type::Builtin + TYPE_INT64: Type::Builtin + TYPE_UINT64: Type::Builtin + TYPE_LONG: Type::Builtin + TYPE_ULONG: Type::Builtin + TYPE_FLOAT32: Type::Builtin + TYPE_FLOAT64: Type::Builtin + TYPE_LONGDOUBLE: Type::Builtin + TYPE_POINTER: Type::Builtin + TYPE_BOOL: Type::Builtin + TYPE_STRING: Type::Builtin + TYPE_BUFFER_IN: Type::Builtin + TYPE_BUFFER_OUT: Type::Builtin + TYPE_BUFFER_INOUT: Type::Builtin + TYPE_VARARGS: Type::Builtin + TYPE_VOID: Type::Builtin +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/pointer.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/pointer.rbs new file mode 100644 index 0000000..fd4e9b8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/pointer.rbs @@ -0,0 +1,42 @@ +module FFI + type pointer = Pointer::_ToPtr? | Integer + class Pointer < AbstractMemory + interface _ToPtr + def to_ptr: () -> Pointer + end + include _ToPtr + + SIZE: Integer + NULL: Pointer + def self.size: () -> Integer + + def initialize: (?AbstractMemory::type_size type, (Pointer | Integer) address) -> void + def +: (Integer offset) -> Pointer + def ==: (Pointer? other) -> bool + def address: () -> Integer + alias to_i address + def autorelease?: () -> bool + def autorelease=: (boolish autorelease) -> boolish + def free: () -> self + def inspect: ... + def null?: () -> bool + def order: () -> AbstractMemory::order_out + | (AbstractMemory::order_in) -> Pointer + def read: (ffi_type type) -> top + def read_array_of_type: (ffi_auto_type type, Symbol reader, Integer length) -> Array[top] + def read_string: (?Integer? len) -> String + def read_string_length: (Integer len) -> String + def read_string_to_null: () -> String + def slice: (Integer offset, Integer length) -> Pointer + def type_size: () -> Integer + def write: (ffi_type type, top value) -> nil + def write_array_of_type: (ffi_auto_type type, Symbol writer, Array[top]) -> self + def write_string: (String str, ?Integer? len) -> self + def write_string_length: (String str, Integer len) -> self + end + + class MemoryPointer < Pointer + def initialize: (AbstractMemory::type_size size, ?Integer count, ?boolish clear) -> self + def self.from_string: (String s) -> instance + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct.rbs new file mode 100644 index 0000000..5b349bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct.rbs @@ -0,0 +1,76 @@ +module FFI + class Struct[out P < AbstractMemory, unchecked out E] + type layout = Library::ffi_lib_type | singleton(StructLayout::Field) | [layout, Integer] + + type ptr = Type::Mapped[ + StructByReference[Struct[AbstractMemory, untyped], AbstractMemory], + AbstractMemory, instance, untyped + ] + def self.ptr: (?untyped flags) -> ptr # https://github.com/ffi/ffi/issues/1073 + alias self.by_ref self.ptr + def self.in: () -> ptr + def self.out: () -> ptr + def self.val: () -> StructByValue[singleton(Struct)] + alias self.by_value self.val + + alias self.alloc_inout self.new + alias self.alloc_in self.new + alias self.alloc_out self.new + alias self.new_inout self.new + alias self.new_in self.new + alias self.new_out self.new + + def self.auto_ptr: () -> Type::Mapped[ + ManagedStructConverter[ManagedStruct[AutoPointer, untyped], AutoPointer], + Pointer, instance, untyped + ] + def self.layout: (*layout | Integer) -> StructLayout + | (Hash[Symbol, layout]) -> StructLayout + def self.size=: (Integer size) -> Integer + + def self?.alignment: () -> Integer + def self?.members: () -> Array[Symbol] + def self?.offset_of: (Symbol name) -> Integer + def self?.offsets: () -> Array[[Symbol, Integer]] + def self?.size: -> Integer + + def initialize: (?P pointer, *layout args) -> void + def []: (Symbol field_name) -> E + def []=: (Symbol field_name, E value) -> E + alias align alignment + def clear: () -> self + def layout: () -> StructLayout + def null?: () -> bool + def order: (AbstractMemory::order_in order) -> Struct[P, E] + | () -> AbstractMemory::order_out + def pointer: () -> P + alias to_ptr pointer + def values: () -> Array[E] + + class InlineArray[out P < AbstractMemory, unchecked out E] + include Enumerable[E] + include AbstractMemory::_Size + + def initialize: (P memory, StructLayout::Field field) -> self + def []: (Integer index) -> E + def []=: (Integer index, E value) -> E + def each: () { (E) -> void } -> self + def to_a: () -> Array[E] + def to_ptr: () -> P + end + + class ManagedStructConverter[S < ManagedStruct[P, untyped], P < AutoPointer] < StructByReference[S, P] + def initialize: ... + def from_native: (Pointer ptr, untyped ctx) -> S + end + end + + class ManagedStruct[out P < AutoPointer, unchecked out E] < Struct[P, E] + def self.release: (AbstractMemory ptr) -> void + def initialize: (Pointer pointer) -> self + end + + class Union[out P < AbstractMemory, unchecked out E] < Struct[P, E] + def self.builder: () -> StructLayoutBuilder + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_by_reference.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_by_reference.rbs new file mode 100644 index 0000000..475b483 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_by_reference.rbs @@ -0,0 +1,11 @@ +module FFI + class StructByReference[S < Struct[P, untyped], P < AbstractMemory] + include DataConverter[P, S, untyped] + attr_reader struct_class: Struct[P, untyped] + + def initialize: (S struct_class) -> void + def from_native: (P value, untyped ctx) -> S + def native_type: () -> Type::Builtin + def to_native: (S? value, untyped ctx) -> P + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_by_value.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_by_value.rbs new file mode 100644 index 0000000..902bcc6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_by_value.rbs @@ -0,0 +1,7 @@ +module FFI + class StructByValue[C < singleton(Struct)] < Type + def initialize: (C) -> self + def layout: () -> StructLayout + def struct_class: () -> C + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_layout.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_layout.rbs new file mode 100644 index 0000000..12b05ae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_layout.rbs @@ -0,0 +1,9 @@ +module FFI + class StructLayout + #TODO + + class Field + #TODO + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_layout_builder.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_layout_builder.rbs new file mode 100644 index 0000000..291a669 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/struct_layout_builder.rbs @@ -0,0 +1,5 @@ +module FFI + class StructLayoutBuilder + #TODO + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/type.rbs b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/type.rbs new file mode 100644 index 0000000..66186d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/ffi-1.17.0-x86_64-linux-gnu/sig/ffi/type.rbs @@ -0,0 +1,39 @@ +module FFI + class Type + class Array = ArrayType + class Function = FunctionType + class Struct = StructByValue + + include AbstractMemory::_Size + def initialize: (Integer | Type value) -> self + def alignment: () -> Integer + def inspect: ... + + class Builtin < Type + def inspect: ... + end + + class Mapped[X < _DataConverter[N, R, C], N, R, C] + include _DataConverter[N, R, C] + + def initialize: (X converter) -> self + def converter: () -> X + end + end + + class ArrayType + def initialize: (Type component_type, Integer length) -> self + def element_type: -> Type + def length: -> Integer + end + + class FunctionType < Type + def initialize: + ( + ffi_type return_type, Array[ffi_type] param_types, + ?blocking: boolish, ?convention: Library::convention, ?enums: Enums + ) -> self + def param_types: () -> Array[Type] + def return_type: () -> Type + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/Gemfile b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/Gemfile new file mode 100644 index 0000000..ea587c7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/Gemfile @@ -0,0 +1,24 @@ +# ---------------------------------------------------------------------------- +# Frozen-string-literal: true +# Copyright: 2015-2016 Jordon Bedwell - MIT License +# Encoding: utf-8 +# ---------------------------------------------------------------------------- + +source "https://rubygems.org" +gem "rake", :require => false +gemspec + +group :test do + gem "rspec-helpers", :require => false + gem "codeclimate-test-reporter", :require => false + gem "luna-rspec-formatters", :require => false + gem "rspec", :require => false +end + +group :development do + gem "luna-rubocop-formatters", :require => false + gem "rubocop", :github => "bbatsov/rubocop", :require => false + gem "pry", { + :require => false + } +end diff --git a/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/LICENSE b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/LICENSE new file mode 100644 index 0000000..e603a78 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015-2016 Jordon Bedwell + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/Rakefile b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/Rakefile new file mode 100644 index 0000000..1c929e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/Rakefile @@ -0,0 +1,13 @@ +# ---------------------------------------------------------------------------- +# Frozen-string-literal: true +# Copyright: 2015-2016 Jordon Bedwell - MIT License +# Encoding: utf-8 +# ---------------------------------------------------------------------------- + +$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__)) +require "luna/rubocop/rake/task" +require "rspec/core/rake_task" + +task :default => [:spec] +RSpec::Core::RakeTask.new :spec +task :test => :spec diff --git a/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb new file mode 100644 index 0000000..fc694cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb @@ -0,0 +1,202 @@ +# ---------------------------------------------------------------------------- +# Frozen-string-literal: true +# Copyright: 2015-2016 Jordon Bedwell - MIT License +# Encoding: utf-8 +# ---------------------------------------------------------------------------- + +require "forwardable/extended/version" +require "forwardable" + +module Forwardable + module Extended + + # ------------------------------------------------------------------------ + # Make our methods private on the class, there is no reason for public. + # ------------------------------------------------------------------------ + + def self.extended(klass) + instance_methods.each do |method| + klass.private_class_method( + method + ) + end + end + + # ------------------------------------------------------------------------ + # Delegate using a Rails-like interface. + # ------------------------------------------------------------------------ + + def rb_delegate(method, to: nil, alias_of: method, **kwd) + raise ArgumentError, "to must be provided" unless to + def_delegator( + to, alias_of, method, **kwd + ) + end + + # ------------------------------------------------------------------------ + # Delegate a method to a hash and key. + # ------------------------------------------------------------------------ + + def def_hash_delegator(hash, method, key: method, **kwd) + prefix, suffix, wrap = prepare_delegate(**kwd) + + if suffix + method = method.to_s.gsub( + /\?$/, "" + ) + end + + class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9 + def #{method}#{suffix}(*args) + #{wrap}( + #{prefix}#{hash}[#{key.inspect}] + ) + + rescue Exception + if !Forwardable.debug && $@ && $@.respond_to?(:delete_if) + $@.delete_if do |source| + source =~ %r"#{Regexp.escape(__FILE__)}"o + end + end + + raise + end + STR + end + + # ------------------------------------------------------------------------ + # Delegate a method to an instance variable. + # ------------------------------------------------------------------------ + + def def_ivar_delegator(ivar, alias_ = ivar, **kwd) + prefix, suffix, wrap = prepare_delegate(**kwd) + + if suffix + alias_ = alias_.to_s.gsub( + /\?$/, "" + ) + end + + class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9 + def #{alias_.to_s.gsub(/\A@/, "")}#{suffix} + #{wrap}( + #{prefix}#{ivar} + ) + + rescue Exception + if !Forwardable.debug && $@ && $@.respond_to?(:delete_if) + $@.delete_if do |source| + source =~ %r"#{Regexp.escape(__FILE__)}"o + end + end + + raise + end + STR + end + + # ------------------------------------------------------------------------ + # Like def_delegator but allows you to send args and do other stuff. + # ------------------------------------------------------------------------ + + def def_modern_delegator(accessor, method, alias_ = method, args: \ + { :before => [], :after => [] }, **kwd) + + prefix, suffix, wrap = prepare_delegate(**kwd) + args = { :before => args } unless args.is_a?(Hash) + b = [args[:before]].flatten.compact.map(&:to_s).join(", ") + a = [args[ :after]].flatten.compact.map(&:to_s).join(", ") + b = b + ", " unless args[:before].nil? || args[:before].empty? + a = ", " + a unless args[ :after].nil? || args[ :after].empty? + alias_ = alias_.to_s.gsub(/\?$/, "") if suffix + + class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 10 + def #{alias_}#{suffix}(*args, &block) + #{wrap}(#{prefix}#{accessor}.send( + #{method.inspect}, #{b}*args#{a}, &block + )) + + rescue Exception + if !Forwardable.debug && $@ && $@.respond_to?(:delete_if) + $@.delete_if do |source| + source =~ %r"#{Regexp.escape(__FILE__)}"o + end + end + + raise + end + STR + end + + # ------------------------------------------------------------------------ + # Wraps around traditional delegation and modern delegation. + # ------------------------------------------------------------------------ + + def def_delegator(accessor, method, alias_ = method, **kwd) + kwd, alias_ = alias_, method if alias_.is_a?(Hash) && !kwd.any? + + if alias_.is_a?(Hash) || !kwd.any? + Forwardable.instance_method(:def_delegator).bind(self) \ + .call(accessor, method, alias_) + + elsif !kwd[:type] + def_modern_delegator( + accessor, method, alias_, **kwd + ) + + else + raise ArgumentError, "Alias not supported." if alias_ != method + send("def_#{kwd[:type]}_delegator", accessor, method, **kwd.tap do |obj| + obj.delete(:type) + end) + end + end + + # ------------------------------------------------------------------------ + # Create multiple delegates at once. + # ------------------------------------------------------------------------ + + def def_delegators(accessor, *methods) + kwd = methods.shift if methods.first.is_a?(Hash) + kwd = methods.pop if methods. last.is_a?(Hash) + kwd = {} unless kwd + + methods.each do |method| + def_delegator accessor, method, **kwd + end + end + + # ------------------------------------------------------------------------ + # Prepares a delegate and it's few arguments. + # ------------------------------------------------------------------------ + + private + def prepare_delegate(wrap: nil, bool: false) + prefix = (bool == :reverse ? "!!!" : "!!") if bool + wrap = "self.class.new" if wrap.is_a?(TrueClass) + suffix = "?" if bool + + return [ + prefix, suffix, wrap + ] + end + + # ------------------------------------------------------------------------ + + private + def delegate_debug(str) + if Forwardable.debug && !Forwardable.debug.is_a?(TrueClass) + then Forwardable.debug.debug( + str + ) + + elsif Forwardable.debug + $stdout.puts( + "\n# ------\n\n", str + ) + end + + str + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended/version.rb b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended/version.rb new file mode 100644 index 0000000..0639375 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended/version.rb @@ -0,0 +1,9 @@ +# Frozen-string-literal: true +# Copyright: 2015-2016 Jordon Bedwell - MIT License +# Encoding: utf-8 + +module Forwardable + module Extended + VERSION = "2.6.0" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/Rakefile b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/Rakefile new file mode 100755 index 0000000..0d4f84e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/Rakefile @@ -0,0 +1,3 @@ +import '../../../lib/google/tasks/ffi.rake' + +task default: ['ffi-protobuf:default'] \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/convert.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/convert.c new file mode 100755 index 0000000..1fae524 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/convert.c @@ -0,0 +1,317 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// ----------------------------------------------------------------------------- +// Ruby <-> upb data conversion functions. +// +// This file Also contains a few other assorted algorithms on upb_MessageValue. +// +// None of the algorithms in this file require any access to the internal +// representation of Ruby or upb objects. +// ----------------------------------------------------------------------------- + +#include "convert.h" + +#include "message.h" +#include "protobuf.h" +#include "shared_convert.h" + +static upb_StringView Convert_StringData(VALUE str, upb_Arena* arena) { + upb_StringView ret; + if (arena) { + char* ptr = upb_Arena_Malloc(arena, RSTRING_LEN(str)); + memcpy(ptr, RSTRING_PTR(str), RSTRING_LEN(str)); + ret.data = ptr; + } else { + // Data is only needed temporarily (within map lookup). + ret.data = RSTRING_PTR(str); + } + ret.size = RSTRING_LEN(str); + return ret; +} + +static bool is_ruby_num(VALUE value) { + return (TYPE(value) == T_FLOAT || TYPE(value) == T_FIXNUM || + TYPE(value) == T_BIGNUM); +} + +static void Convert_CheckInt(const char* name, upb_CType type, VALUE val) { + if (!is_ruby_num(val)) { + rb_raise(cTypeError, + "Expected number type for integral field '%s' (given %s).", name, + rb_class2name(CLASS_OF(val))); + } + + // NUM2{INT,UINT,LL,ULL} macros do the appropriate range checks on upper + // bound; we just need to do precision checks (i.e., disallow rounding) and + // check for < 0 on unsigned types. + if (TYPE(val) == T_FLOAT) { + double dbl_val = NUM2DBL(val); + if (floor(dbl_val) != dbl_val) { + rb_raise(rb_eRangeError, + "Non-integral floating point value assigned to integer field " + "'%s' (given %s).", + name, rb_class2name(CLASS_OF(val))); + } + } + if (type == kUpb_CType_UInt32 || type == kUpb_CType_UInt64) { + if (NUM2DBL(val) < 0) { + rb_raise( + rb_eRangeError, + "Assigning negative value to unsigned integer field '%s' (given %s).", + name, rb_class2name(CLASS_OF(val))); + } + } +} + +static int32_t Convert_ToEnum(VALUE value, const char* name, + const upb_EnumDef* e) { + int32_t val; + + switch (TYPE(value)) { + case T_FLOAT: + case T_FIXNUM: + case T_BIGNUM: + Convert_CheckInt(name, kUpb_CType_Int32, value); + val = NUM2INT(value); + break; + case T_STRING: { + const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNameWithSize( + e, RSTRING_PTR(value), RSTRING_LEN(value)); + if (!ev) goto unknownval; + val = upb_EnumValueDef_Number(ev); + break; + } + case T_SYMBOL: { + const upb_EnumValueDef* ev = + upb_EnumDef_FindValueByName(e, rb_id2name(SYM2ID(value))); + if (!ev) goto unknownval; + val = upb_EnumValueDef_Number(ev); + break; + } + default: + rb_raise(cTypeError, + "Expected number or symbol type for enum field '%s'.", name); + } + + return val; + +unknownval: + rb_raise(rb_eRangeError, "Unknown symbol value for enum field '%s'.", name); +} + +upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name, + TypeInfo type_info, upb_Arena* arena) { + upb_MessageValue ret; + + switch (type_info.type) { + case kUpb_CType_Float: + if (!is_ruby_num(value)) { + rb_raise(cTypeError, + "Expected number type for float field '%s' (given %s).", name, + rb_class2name(CLASS_OF(value))); + } + ret.float_val = NUM2DBL(value); + break; + case kUpb_CType_Double: + if (!is_ruby_num(value)) { + rb_raise(cTypeError, + "Expected number type for double field '%s' (given %s).", name, + rb_class2name(CLASS_OF(value))); + } + ret.double_val = NUM2DBL(value); + break; + case kUpb_CType_Bool: { + if (value == Qtrue) { + ret.bool_val = 1; + } else if (value == Qfalse) { + ret.bool_val = 0; + } else { + rb_raise(cTypeError, + "Invalid argument for boolean field '%s' (given %s).", name, + rb_class2name(CLASS_OF(value))); + } + break; + } + case kUpb_CType_String: { + VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding()); + if (rb_obj_class(value) == rb_cSymbol) { + value = rb_funcall(value, rb_intern("to_s"), 0); + } else if (!rb_obj_is_kind_of(value, rb_cString)) { + rb_raise(cTypeError, + "Invalid argument for string field '%s' (given %s).", name, + rb_class2name(CLASS_OF(value))); + } + + if (rb_obj_encoding(value) != utf8) { + // Note: this will not duplicate underlying string data unless + // necessary. + value = rb_str_encode(value, utf8, 0, Qnil); + + if (rb_enc_str_coderange(value) == ENC_CODERANGE_BROKEN) { + rb_raise(rb_eEncodingError, "String is invalid UTF-8"); + } + } + + ret.str_val = Convert_StringData(value, arena); + break; + } + case kUpb_CType_Bytes: { + VALUE bytes = rb_enc_from_encoding(rb_ascii8bit_encoding()); + if (rb_obj_class(value) != rb_cString) { + rb_raise(cTypeError, + "Invalid argument for bytes field '%s' (given %s).", name, + rb_class2name(CLASS_OF(value))); + } + + if (rb_obj_encoding(value) != bytes) { + // Note: this will not duplicate underlying string data unless + // necessary. + // TODO: is this really necessary to get raw bytes? + value = rb_str_encode(value, bytes, 0, Qnil); + } + + ret.str_val = Convert_StringData(value, arena); + break; + } + case kUpb_CType_Message: + ret.msg_val = + Message_GetUpbMessage(value, type_info.def.msgdef, name, arena); + break; + case kUpb_CType_Enum: + ret.int32_val = Convert_ToEnum(value, name, type_info.def.enumdef); + break; + case kUpb_CType_Int32: + case kUpb_CType_Int64: + case kUpb_CType_UInt32: + case kUpb_CType_UInt64: + Convert_CheckInt(name, type_info.type, value); + switch (type_info.type) { + case kUpb_CType_Int32: + ret.int32_val = NUM2INT(value); + break; + case kUpb_CType_Int64: + ret.int64_val = NUM2LL(value); + break; + case kUpb_CType_UInt32: + ret.uint32_val = NUM2UINT(value); + break; + case kUpb_CType_UInt64: + ret.uint64_val = NUM2ULL(value); + break; + default: + break; + } + break; + default: + rb_raise(cTypeError, + "Convert_RubyToUpb(): Unexpected type %d", (int)type_info.type); + } + + return ret; +} + +VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info, + VALUE arena) { + switch (type_info.type) { + case kUpb_CType_Float: + return DBL2NUM(upb_val.float_val); + case kUpb_CType_Double: + return DBL2NUM(upb_val.double_val); + case kUpb_CType_Bool: + return upb_val.bool_val ? Qtrue : Qfalse; + case kUpb_CType_Int32: + return INT2NUM(upb_val.int32_val); + case kUpb_CType_Int64: + return LL2NUM(upb_val.int64_val); + case kUpb_CType_UInt32: + return UINT2NUM(upb_val.uint32_val); + case kUpb_CType_UInt64: + return ULL2NUM(upb_val.int64_val); + case kUpb_CType_Enum: { + const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNumber( + type_info.def.enumdef, upb_val.int32_val); + if (ev) { + return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev))); + } else { + return INT2NUM(upb_val.int32_val); + } + } + case kUpb_CType_String: { + VALUE str_rb = rb_str_new(upb_val.str_val.data, upb_val.str_val.size); + rb_enc_associate(str_rb, rb_utf8_encoding()); + rb_obj_freeze(str_rb); + return str_rb; + } + case kUpb_CType_Bytes: { + VALUE str_rb = rb_str_new(upb_val.str_val.data, upb_val.str_val.size); + rb_enc_associate(str_rb, rb_ascii8bit_encoding()); + rb_obj_freeze(str_rb); + return str_rb; + } + case kUpb_CType_Message: + return Message_GetRubyWrapper((upb_Message*)upb_val.msg_val, + type_info.def.msgdef, arena); + default: + rb_raise(rb_eRuntimeError, "Convert_UpbToRuby(): Unexpected type %d", + (int)type_info.type); + } +} + +upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info, + upb_Arena* arena) { + upb_MessageValue new_msgval; + + switch (type_info.type) { + default: + memcpy(&new_msgval, &msgval, sizeof(msgval)); + break; + case kUpb_CType_String: + case kUpb_CType_Bytes: { + size_t n = msgval.str_val.size; + char* mem = upb_Arena_Malloc(arena, n); + new_msgval.str_val.data = mem; + new_msgval.str_val.size = n; + memcpy(mem, msgval.str_val.data, n); + break; + } + case kUpb_CType_Message: + new_msgval.msg_val = + Message_deep_copy(msgval.msg_val, type_info.def.msgdef, arena); + break; + } + + return new_msgval; +} + +bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2, + TypeInfo type_info) { + upb_Status status; + upb_Status_Clear(&status); + bool return_value = shared_Msgval_IsEqual(val1, val2, type_info.type, + type_info.def.msgdef, &status); + if (upb_Status_IsOk(&status)) { + return return_value; + } else { + rb_raise(rb_eRuntimeError, "Msgval_IsEqual(): %s", + upb_Status_ErrorMessage(&status)); + } +} + +uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info, + uint64_t seed) { + upb_Status status; + upb_Status_Clear(&status); + uint64_t return_value = shared_Msgval_GetHash( + val, type_info.type, type_info.def.msgdef, seed, &status); + if (upb_Status_IsOk(&status)) { + return return_value; + } else { + rb_raise(rb_eRuntimeError, "Msgval_GetHash(): %s", + upb_Status_ErrorMessage(&status)); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/convert.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/convert.h new file mode 100755 index 0000000..ac3eaab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/convert.h @@ -0,0 +1,50 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef RUBY_PROTOBUF_CONVERT_H_ +#define RUBY_PROTOBUF_CONVERT_H_ + +#include "protobuf.h" +#include "ruby-upb.h" + +// Converts |ruby_val| to a upb_MessageValue according to |type_info|. +// +// The |arena| parameter indicates the lifetime of the container where this +// value will be assigned. It is used as follows: +// - If type is string or bytes, the string data will be copied into |arena|. +// - If type is message, and we need to auto-construct a message due to implicit +// conversions (eg. Time -> Google::Protobuf::Timestamp), the new message +// will be created in |arena|. +// - If type is message and the Ruby value is a message instance, we will fuse +// the message's arena into |arena|, to ensure that this message outlives the +// container. +upb_MessageValue Convert_RubyToUpb(VALUE ruby_val, const char *name, + TypeInfo type_info, upb_Arena *arena); + +// Converts |upb_val| to a Ruby VALUE according to |type_info|. This may involve +// creating a Ruby wrapper object. +// +// The |arena| parameter indicates the arena that owns the lifetime of +// |upb_val|. Any Ruby wrapper object that is created will reference |arena| +// and ensure it outlives the wrapper. +VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info, + VALUE arena); + +// Creates a deep copy of |msgval| in |arena|. +upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info, + upb_Arena *arena); + +// Returns true if |val1| and |val2| are equal. Their type is given by +// |type_info|. +bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2, + TypeInfo type_info); + +// Returns a hash value for the given upb_MessageValue. +uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info, + uint64_t seed); + +#endif // RUBY_PROTOBUF_CONVERT_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/defs.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/defs.c new file mode 100755 index 0000000..7fd834a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/defs.c @@ -0,0 +1,1742 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2014 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#include +#include +#include + +#include "convert.h" +#include "message.h" +#include "protobuf.h" + +// ----------------------------------------------------------------------------- +// Global map from upb {msg,enum}defs to wrapper Descriptor/EnumDescriptor +// instances. +// ----------------------------------------------------------------------------- + +static VALUE get_msgdef_obj(VALUE descriptor_pool, const upb_MessageDef* def); +static VALUE get_enumdef_obj(VALUE descriptor_pool, const upb_EnumDef* def); +static VALUE get_fielddef_obj(VALUE descriptor_pool, const upb_FieldDef* def); +static VALUE get_filedef_obj(VALUE descriptor_pool, const upb_FileDef* def); +static VALUE get_oneofdef_obj(VALUE descriptor_pool, const upb_OneofDef* def); +static VALUE get_servicedef_obj(VALUE descriptor_pool, + const upb_ServiceDef* def); +static VALUE get_methoddef_obj(VALUE descriptor_pool, const upb_MethodDef* def); + +// A distinct object that is not accessible from Ruby. We use this as a +// constructor argument to enforce that certain objects cannot be created from +// Ruby. +VALUE c_only_cookie = Qnil; + +// ----------------------------------------------------------------------------- +// Common utilities. +// ----------------------------------------------------------------------------- + +static const char* get_str(VALUE str) { + Check_Type(str, T_STRING); + return RSTRING_PTR(str); +} + +static VALUE rb_str_maybe_null(const char* s) { + if (s == NULL) { + s = ""; + } + return rb_str_new2(s); +} +static ID options_instancevar_interned; +// ----------------------------------------------------------------------------- +// DescriptorPool. +// ----------------------------------------------------------------------------- + +typedef struct { + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE def_to_descriptor; // Hash table of def* -> Ruby descriptor. + upb_DefPool* symtab; +} DescriptorPool; + +VALUE cDescriptorPool = Qnil; + +// Global singleton DescriptorPool. The user is free to create others, but this +// is used by generated code. +VALUE generated_pool = Qnil; + +static void DescriptorPool_mark(void* _self) { + DescriptorPool* self = _self; + rb_gc_mark(self->def_to_descriptor); +} + +static void DescriptorPool_free(void* _self) { + DescriptorPool* self = _self; + upb_DefPool_Free(self->symtab); + xfree(self); +} + +static const rb_data_type_t DescriptorPool_type = { + "Google::Protobuf::DescriptorPool", + {DescriptorPool_mark, DescriptorPool_free, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static DescriptorPool* ruby_to_DescriptorPool(VALUE val) { + DescriptorPool* ret; + TypedData_Get_Struct(val, DescriptorPool, &DescriptorPool_type, ret); + return ret; +} + +// Exposed to other modules in defs.h. +const upb_DefPool* DescriptorPool_GetSymtab(VALUE desc_pool_rb) { + DescriptorPool* pool = ruby_to_DescriptorPool(desc_pool_rb); + return pool->symtab; +} + +/* + * call-seq: + * DescriptorPool.new => pool + * + * Creates a new, empty, descriptor pool. + */ +static VALUE DescriptorPool_alloc(VALUE klass) { + DescriptorPool* self = ALLOC(DescriptorPool); + VALUE ret; + + self->def_to_descriptor = Qnil; + ret = TypedData_Wrap_Struct(klass, &DescriptorPool_type, self); + + RB_OBJ_WRITE(ret, &self->def_to_descriptor, rb_hash_new()); + self->symtab = upb_DefPool_New(); + return ObjectCache_TryAdd(self->symtab, ret); +} + +/* + * call-seq: + * DescriptorPool.add_serialized_file(serialized_file_proto) + * + * Adds the given serialized FileDescriptorProto to the pool. + */ +VALUE DescriptorPool_add_serialized_file(VALUE _self, + VALUE serialized_file_proto) { + DescriptorPool* self = ruby_to_DescriptorPool(_self); + Check_Type(serialized_file_proto, T_STRING); + VALUE arena_rb = Arena_new(); + upb_Arena* arena = Arena_get(arena_rb); + google_protobuf_FileDescriptorProto* file_proto = + google_protobuf_FileDescriptorProto_parse( + RSTRING_PTR(serialized_file_proto), + RSTRING_LEN(serialized_file_proto), arena); + if (!file_proto) { + rb_raise(rb_eArgError, "Unable to parse FileDescriptorProto"); + } + upb_Status status; + upb_Status_Clear(&status); + const upb_FileDef* filedef = + upb_DefPool_AddFile(self->symtab, file_proto, &status); + if (!filedef) { + rb_raise(cTypeError, "Unable to build file to DescriptorPool: %s", + upb_Status_ErrorMessage(&status)); + } + RB_GC_GUARD(arena_rb); + return get_filedef_obj(_self, filedef); +} + +/* + * call-seq: + * DescriptorPool.lookup(name) => descriptor + * + * Finds a Descriptor, EnumDescriptor or FieldDescriptor by name and returns it, + * or nil if none exists with the given name. + */ +static VALUE DescriptorPool_lookup(VALUE _self, VALUE name) { + DescriptorPool* self = ruby_to_DescriptorPool(_self); + const char* name_str = get_str(name); + const upb_MessageDef* msgdef; + const upb_EnumDef* enumdef; + const upb_FieldDef* fielddef; + const upb_ServiceDef* servicedef; + + msgdef = upb_DefPool_FindMessageByName(self->symtab, name_str); + if (msgdef) { + return get_msgdef_obj(_self, msgdef); + } + + fielddef = upb_DefPool_FindExtensionByName(self->symtab, name_str); + if (fielddef) { + return get_fielddef_obj(_self, fielddef); + } + + enumdef = upb_DefPool_FindEnumByName(self->symtab, name_str); + if (enumdef) { + return get_enumdef_obj(_self, enumdef); + } + + servicedef = upb_DefPool_FindServiceByName(self->symtab, name_str); + if (servicedef) { + return get_servicedef_obj(_self, servicedef); + } + + return Qnil; +} + +/* + * call-seq: + * DescriptorPool.generated_pool => descriptor_pool + * + * Class method that returns the global DescriptorPool. This is a singleton into + * which generated-code message and enum types are registered. The user may also + * register types in this pool for convenience so that they do not have to hold + * a reference to a private pool instance. + */ +static VALUE DescriptorPool_generated_pool(VALUE _self) { + return generated_pool; +} + +static void DescriptorPool_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "DescriptorPool", rb_cObject); + rb_define_alloc_func(klass, DescriptorPool_alloc); + rb_define_method(klass, "add_serialized_file", + DescriptorPool_add_serialized_file, 1); + rb_define_method(klass, "lookup", DescriptorPool_lookup, 1); + rb_define_singleton_method(klass, "generated_pool", + DescriptorPool_generated_pool, 0); + rb_gc_register_address(&cDescriptorPool); + cDescriptorPool = klass; + + rb_gc_register_address(&generated_pool); + generated_pool = rb_class_new_instance(0, NULL, klass); + options_instancevar_interned = rb_intern("options"); +} + +// ----------------------------------------------------------------------------- +// Descriptor. +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_MessageDef* msgdef; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE klass; + VALUE descriptor_pool; +} Descriptor; + +VALUE cDescriptor = Qnil; + +static void Descriptor_mark(void* _self) { + Descriptor* self = _self; + rb_gc_mark(self->klass); + rb_gc_mark(self->descriptor_pool); +} + +static const rb_data_type_t Descriptor_type = { + "Google::Protobuf::Descriptor", + {Descriptor_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static Descriptor* ruby_to_Descriptor(VALUE val) { + Descriptor* ret; + TypedData_Get_Struct(val, Descriptor, &Descriptor_type, ret); + return ret; +} + +// Decode and return a frozen instance of a Descriptor Option for the given pool +static VALUE decode_options(VALUE self, const char* option_type, int size, + const char* bytes, VALUE descriptor_pool) { + VALUE options_rb = rb_ivar_get(self, options_instancevar_interned); + if (options_rb != Qnil) { + return options_rb; + } + + static const char* prefix = "google.protobuf."; + char fullname + [/*strlen(prefix)*/ 16 + + /*strln(longest option type supported e.g. "MessageOptions")*/ 14 + + /*null terminator*/ 1]; + + snprintf(fullname, sizeof(fullname), "%s%s", prefix, option_type); + const upb_MessageDef* msgdef = upb_DefPool_FindMessageByName( + ruby_to_DescriptorPool(descriptor_pool)->symtab, fullname); + if (!msgdef) { + rb_raise(rb_eRuntimeError, "Cannot find %s in DescriptorPool", option_type); + } + + VALUE desc_rb = get_msgdef_obj(descriptor_pool, msgdef); + const Descriptor* desc = ruby_to_Descriptor(desc_rb); + + options_rb = Message_decode_bytes(size, bytes, 0, desc->klass, false); + + // Strip features from the options proto to keep it internal. + const upb_MessageDef* decoded_desc = NULL; + upb_Message* options = Message_GetMutable(options_rb, &decoded_desc); + PBRUBY_ASSERT(options != NULL); + PBRUBY_ASSERT(decoded_desc == msgdef); + const upb_FieldDef* field = + upb_MessageDef_FindFieldByName(decoded_desc, "features"); + PBRUBY_ASSERT(field != NULL); + upb_Message_ClearFieldByDef(options, field); + + Message_freeze(options_rb); + + rb_ivar_set(self, options_instancevar_interned, options_rb); + return options_rb; +} + +/* + * call-seq: + * Descriptor.new => descriptor + * + * Creates a new, empty, message type descriptor. At a minimum, its name must be + * set before it is added to a pool. It cannot be used to create messages until + * it is added to a pool, after which it becomes immutable (as part of a + * finalization process). + */ +static VALUE Descriptor_alloc(VALUE klass) { + Descriptor* self = ALLOC(Descriptor); + VALUE ret = TypedData_Wrap_Struct(klass, &Descriptor_type, self); + self->msgdef = NULL; + self->klass = Qnil; + self->descriptor_pool = Qnil; + return ret; +} + +/* + * call-seq: + * Descriptor.new(c_only_cookie, ptr) => Descriptor + * + * Creates a descriptor wrapper object. May only be called from C. + */ +static VALUE Descriptor_initialize(VALUE _self, VALUE cookie, + VALUE descriptor_pool, VALUE ptr) { + Descriptor* self = ruby_to_Descriptor(_self); + + if (cookie != c_only_cookie) { + rb_raise(rb_eRuntimeError, + "Descriptor objects may not be created from Ruby."); + } + + RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool); + self->msgdef = (const upb_MessageDef*)NUM2ULL(ptr); + + return Qnil; +} + +/* + * call-seq: + * Descriptor.file_descriptor + * + * Returns the FileDescriptor object this message belongs to. + */ +static VALUE Descriptor_file_descriptor(VALUE _self) { + Descriptor* self = ruby_to_Descriptor(_self); + return get_filedef_obj(self->descriptor_pool, + upb_MessageDef_File(self->msgdef)); +} + +/* + * call-seq: + * Descriptor.name => name + * + * Returns the name of this message type as a fully-qualified string (e.g., + * My.Package.MessageType). + */ +static VALUE Descriptor_name(VALUE _self) { + Descriptor* self = ruby_to_Descriptor(_self); + return rb_str_maybe_null(upb_MessageDef_FullName(self->msgdef)); +} + +/* + * call-seq: + * Descriptor.each(&block) + * + * Iterates over fields in this message type, yielding to the block on each one. + */ +static VALUE Descriptor_each(VALUE _self) { + Descriptor* self = ruby_to_Descriptor(_self); + + int n = upb_MessageDef_FieldCount(self->msgdef); + for (int i = 0; i < n; i++) { + const upb_FieldDef* field = upb_MessageDef_Field(self->msgdef, i); + VALUE obj = get_fielddef_obj(self->descriptor_pool, field); + rb_yield(obj); + } + return Qnil; +} + +/* + * call-seq: + * Descriptor.lookup(name) => FieldDescriptor + * + * Returns the field descriptor for the field with the given name, if present, + * or nil if none. + */ +static VALUE Descriptor_lookup(VALUE _self, VALUE name) { + Descriptor* self = ruby_to_Descriptor(_self); + const char* s = get_str(name); + const upb_FieldDef* field = upb_MessageDef_FindFieldByName(self->msgdef, s); + if (field == NULL) { + return Qnil; + } + return get_fielddef_obj(self->descriptor_pool, field); +} + +/* + * call-seq: + * Descriptor.each_oneof(&block) => nil + * + * Invokes the given block for each oneof in this message type, passing the + * corresponding OneofDescriptor. + */ +static VALUE Descriptor_each_oneof(VALUE _self) { + Descriptor* self = ruby_to_Descriptor(_self); + + int n = upb_MessageDef_OneofCount(self->msgdef); + for (int i = 0; i < n; i++) { + const upb_OneofDef* oneof = upb_MessageDef_Oneof(self->msgdef, i); + VALUE obj = get_oneofdef_obj(self->descriptor_pool, oneof); + rb_yield(obj); + } + return Qnil; +} + +/* + * call-seq: + * Descriptor.lookup_oneof(name) => OneofDescriptor + * + * Returns the oneof descriptor for the oneof with the given name, if present, + * or nil if none. + */ +static VALUE Descriptor_lookup_oneof(VALUE _self, VALUE name) { + Descriptor* self = ruby_to_Descriptor(_self); + const char* s = get_str(name); + const upb_OneofDef* oneof = upb_MessageDef_FindOneofByName(self->msgdef, s); + if (oneof == NULL) { + return Qnil; + } + return get_oneofdef_obj(self->descriptor_pool, oneof); +} + +/* + * call-seq: + * Descriptor.msgclass => message_klass + * + * Returns the Ruby class created for this message type. + */ +static VALUE Descriptor_msgclass(VALUE _self) { + Descriptor* self = ruby_to_Descriptor(_self); + if (self->klass == Qnil) { + RB_OBJ_WRITE(_self, &self->klass, build_class_from_descriptor(_self)); + } + return self->klass; +} + +/* + * call-seq: + * Descriptor.options => options + * + * Returns the `MessageOptions` for this `Descriptor`. + */ +static VALUE Descriptor_options(VALUE _self) { + Descriptor* self = ruby_to_Descriptor(_self); + const google_protobuf_MessageOptions* opts = + upb_MessageDef_Options(self->msgdef); + upb_Arena* arena = upb_Arena_New(); + size_t size; + char* serialized = + google_protobuf_MessageOptions_serialize(opts, arena, &size); + VALUE message_options = decode_options(_self, "MessageOptions", size, + serialized, self->descriptor_pool); + upb_Arena_Free(arena); + return message_options; +} + +static void Descriptor_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "Descriptor", rb_cObject); + rb_define_alloc_func(klass, Descriptor_alloc); + rb_define_method(klass, "initialize", Descriptor_initialize, 3); + rb_define_method(klass, "each", Descriptor_each, 0); + rb_define_method(klass, "lookup", Descriptor_lookup, 1); + rb_define_method(klass, "each_oneof", Descriptor_each_oneof, 0); + rb_define_method(klass, "lookup_oneof", Descriptor_lookup_oneof, 1); + rb_define_method(klass, "msgclass", Descriptor_msgclass, 0); + rb_define_method(klass, "name", Descriptor_name, 0); + rb_define_method(klass, "file_descriptor", Descriptor_file_descriptor, 0); + rb_define_method(klass, "options", Descriptor_options, 0); + rb_include_module(klass, rb_mEnumerable); + rb_gc_register_address(&cDescriptor); + cDescriptor = klass; +} + +// ----------------------------------------------------------------------------- +// FileDescriptor. +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_FileDef* filedef; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE descriptor_pool; // Owns the upb_FileDef. +} FileDescriptor; + +static VALUE cFileDescriptor = Qnil; + +static void FileDescriptor_mark(void* _self) { + FileDescriptor* self = _self; + rb_gc_mark(self->descriptor_pool); +} + +static const rb_data_type_t FileDescriptor_type = { + "Google::Protobuf::FileDescriptor", + {FileDescriptor_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static FileDescriptor* ruby_to_FileDescriptor(VALUE val) { + FileDescriptor* ret; + TypedData_Get_Struct(val, FileDescriptor, &FileDescriptor_type, ret); + return ret; +} + +static VALUE FileDescriptor_alloc(VALUE klass) { + FileDescriptor* self = ALLOC(FileDescriptor); + VALUE ret = TypedData_Wrap_Struct(klass, &FileDescriptor_type, self); + self->descriptor_pool = Qnil; + self->filedef = NULL; + return ret; +} + +/* + * call-seq: + * FileDescriptor.new => file + * + * Returns a new file descriptor. May + * to a builder. + */ +static VALUE FileDescriptor_initialize(VALUE _self, VALUE cookie, + VALUE descriptor_pool, VALUE ptr) { + FileDescriptor* self = ruby_to_FileDescriptor(_self); + + if (cookie != c_only_cookie) { + rb_raise(rb_eRuntimeError, + "Descriptor objects may not be created from Ruby."); + } + + RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool); + self->filedef = (const upb_FileDef*)NUM2ULL(ptr); + + return Qnil; +} + +/* + * call-seq: + * FileDescriptor.name => name + * + * Returns the name of the file. + */ +static VALUE FileDescriptor_name(VALUE _self) { + FileDescriptor* self = ruby_to_FileDescriptor(_self); + const char* name = upb_FileDef_Name(self->filedef); + return name == NULL ? Qnil : rb_str_new2(name); +} + +/* + * call-seq: + * FileDescriptor.options => options + * + * Returns the `FileOptions` for this `FileDescriptor`. + */ +static VALUE FileDescriptor_options(VALUE _self) { + FileDescriptor* self = ruby_to_FileDescriptor(_self); + const google_protobuf_FileOptions* opts = upb_FileDef_Options(self->filedef); + upb_Arena* arena = upb_Arena_New(); + size_t size; + char* serialized = google_protobuf_FileOptions_serialize(opts, arena, &size); + VALUE file_options = decode_options(_self, "FileOptions", size, serialized, + self->descriptor_pool); + upb_Arena_Free(arena); + return file_options; +} + +static void FileDescriptor_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "FileDescriptor", rb_cObject); + rb_define_alloc_func(klass, FileDescriptor_alloc); + rb_define_method(klass, "initialize", FileDescriptor_initialize, 3); + rb_define_method(klass, "name", FileDescriptor_name, 0); + rb_define_method(klass, "options", FileDescriptor_options, 0); + rb_gc_register_address(&cFileDescriptor); + cFileDescriptor = klass; +} + +// ----------------------------------------------------------------------------- +// FieldDescriptor. +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_FieldDef* fielddef; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE descriptor_pool; // Owns the upb_FieldDef. +} FieldDescriptor; + +static VALUE cFieldDescriptor = Qnil; + +static void FieldDescriptor_mark(void* _self) { + FieldDescriptor* self = _self; + rb_gc_mark(self->descriptor_pool); +} + +static const rb_data_type_t FieldDescriptor_type = { + "Google::Protobuf::FieldDescriptor", + {FieldDescriptor_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static FieldDescriptor* ruby_to_FieldDescriptor(VALUE val) { + FieldDescriptor* ret; + TypedData_Get_Struct(val, FieldDescriptor, &FieldDescriptor_type, ret); + return ret; +} + +/* + * call-seq: + * FieldDescriptor.new => field + * + * Returns a new field descriptor. Its name, type, etc. must be set before it is + * added to a message type. + */ +static VALUE FieldDescriptor_alloc(VALUE klass) { + FieldDescriptor* self = ALLOC(FieldDescriptor); + VALUE ret = TypedData_Wrap_Struct(klass, &FieldDescriptor_type, self); + self->fielddef = NULL; + return ret; +} + +/* + * call-seq: + * FieldDescriptor.new(c_only_cookie, pool, ptr) => FieldDescriptor + * + * Creates a descriptor wrapper object. May only be called from C. + */ +static VALUE FieldDescriptor_initialize(VALUE _self, VALUE cookie, + VALUE descriptor_pool, VALUE ptr) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + + if (cookie != c_only_cookie) { + rb_raise(rb_eRuntimeError, + "Descriptor objects may not be created from Ruby."); + } + + RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool); + self->fielddef = (const upb_FieldDef*)NUM2ULL(ptr); + + return Qnil; +} + +/* + * call-seq: + * FieldDescriptor.name => name + * + * Returns the name of this field. + */ +static VALUE FieldDescriptor_name(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + return rb_str_maybe_null(upb_FieldDef_Name(self->fielddef)); +} + +// Non-static, exposed to other .c files. +upb_CType ruby_to_fieldtype(VALUE type) { + if (TYPE(type) != T_SYMBOL) { + rb_raise(rb_eArgError, "Expected symbol for field type."); + } + +#define CONVERT(upb, ruby) \ + if (SYM2ID(type) == rb_intern(#ruby)) { \ + return kUpb_CType_##upb; \ + } + + CONVERT(Float, float); + CONVERT(Double, double); + CONVERT(Bool, bool); + CONVERT(String, string); + CONVERT(Bytes, bytes); + CONVERT(Message, message); + CONVERT(Enum, enum); + CONVERT(Int32, int32); + CONVERT(Int64, int64); + CONVERT(UInt32, uint32); + CONVERT(UInt64, uint64); + +#undef CONVERT + + rb_raise(rb_eArgError, "Unknown field type."); + return 0; +} + +static VALUE descriptortype_to_ruby(upb_FieldType type) { + switch (type) { +#define CONVERT(upb, ruby) \ + case kUpb_FieldType_##upb: \ + return ID2SYM(rb_intern(#ruby)); + CONVERT(Float, float); + CONVERT(Double, double); + CONVERT(Bool, bool); + CONVERT(String, string); + CONVERT(Bytes, bytes); + CONVERT(Message, message); + CONVERT(Group, group); + CONVERT(Enum, enum); + CONVERT(Int32, int32); + CONVERT(Int64, int64); + CONVERT(UInt32, uint32); + CONVERT(UInt64, uint64); + CONVERT(SInt32, sint32); + CONVERT(SInt64, sint64); + CONVERT(Fixed32, fixed32); + CONVERT(Fixed64, fixed64); + CONVERT(SFixed32, sfixed32); + CONVERT(SFixed64, sfixed64); +#undef CONVERT + } + return Qnil; +} + +/* + * call-seq: + * FieldDescriptor.type => type + * + * Returns this field's type, as a Ruby symbol, or nil if not yet set. + * + * Valid field types are: + * :int32, :int64, :uint32, :uint64, :float, :double, :bool, :string, + * :bytes, :message. + */ +static VALUE FieldDescriptor__type(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + return descriptortype_to_ruby(upb_FieldDef_Type(self->fielddef)); +} + +/* + * call-seq: + * FieldDescriptor.default => default + * + * Returns this field's default, as a Ruby object, or nil if not yet set. + */ +static VALUE FieldDescriptor_default(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + const upb_FieldDef* f = self->fielddef; + upb_MessageValue default_val = {0}; + if (upb_FieldDef_IsSubMessage(f)) { + return Qnil; + } else if (!upb_FieldDef_IsRepeated(f)) { + default_val = upb_FieldDef_Default(f); + } + return Convert_UpbToRuby(default_val, TypeInfo_get(self->fielddef), Qnil); +} + +/* + * call-seq: + * FieldDescriptor.has_presence? => bool + * + * Returns whether this field tracks presence. + */ +static VALUE FieldDescriptor_has_presence(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + return upb_FieldDef_HasPresence(self->fielddef) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * FieldDescriptor.is_packed? => bool + * + * Returns whether this is a repeated field that uses packed encoding. + */ +static VALUE FieldDescriptor_is_packed(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + return upb_FieldDef_IsPacked(self->fielddef) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * FieldDescriptor.json_name => json_name + * + * Returns this field's json_name, as a Ruby string, or nil if not yet set. + */ +static VALUE FieldDescriptor_json_name(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + const upb_FieldDef* f = self->fielddef; + const char* json_name = upb_FieldDef_JsonName(f); + return rb_str_new2(json_name); +} + +/* + * call-seq: + * FieldDescriptor.label => label + * + * Returns this field's label (i.e., plurality), as a Ruby symbol. + * + * Valid field labels are: + * :optional, :repeated + */ +static VALUE FieldDescriptor_label(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + switch (upb_FieldDef_Label(self->fielddef)) { +#define CONVERT(upb, ruby) \ + case kUpb_Label_##upb: \ + return ID2SYM(rb_intern(#ruby)); + + CONVERT(Optional, optional); + CONVERT(Required, required); + CONVERT(Repeated, repeated); + +#undef CONVERT + } + + return Qnil; +} + +/* + * call-seq: + * FieldDescriptor.number => number + * + * Returns the tag number for this field. + */ +static VALUE FieldDescriptor_number(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + return INT2NUM(upb_FieldDef_Number(self->fielddef)); +} + +/* + * call-seq: + * FieldDescriptor.submsg_name => submsg_name + * + * Returns the name of the message or enum type corresponding to this field, if + * it is a message or enum field (respectively), or nil otherwise. This type + * name will be resolved within the context of the pool to which the containing + * message type is added. + */ +static VALUE FieldDescriptor_submsg_name(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + switch (upb_FieldDef_CType(self->fielddef)) { + case kUpb_CType_Enum: + return rb_str_new2( + upb_EnumDef_FullName(upb_FieldDef_EnumSubDef(self->fielddef))); + case kUpb_CType_Message: + return rb_str_new2( + upb_MessageDef_FullName(upb_FieldDef_MessageSubDef(self->fielddef))); + default: + return Qnil; + } +} + +/* + * call-seq: + * FieldDescriptor.subtype => message_or_enum_descriptor + * + * Returns the message or enum descriptor corresponding to this field's type if + * it is a message or enum field, respectively, or nil otherwise. Cannot be + * called *until* the containing message type is added to a pool (and thus + * resolved). + */ +static VALUE FieldDescriptor_subtype(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + switch (upb_FieldDef_CType(self->fielddef)) { + case kUpb_CType_Enum: + return get_enumdef_obj(self->descriptor_pool, + upb_FieldDef_EnumSubDef(self->fielddef)); + case kUpb_CType_Message: + return get_msgdef_obj(self->descriptor_pool, + upb_FieldDef_MessageSubDef(self->fielddef)); + default: + return Qnil; + } +} + +/* + * call-seq: + * FieldDescriptor.get(message) => value + * + * Returns the value set for this field on the given message. Raises an + * exception if message is of the wrong type. + */ +static VALUE FieldDescriptor_get(VALUE _self, VALUE msg_rb) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + const upb_MessageDef* m; + + Message_Get(msg_rb, &m); + + if (m != upb_FieldDef_ContainingType(self->fielddef)) { + rb_raise(cTypeError, "get method called on wrong message type"); + } + + return Message_getfield(msg_rb, self->fielddef); +} + +/* + * call-seq: + * FieldDescriptor.has?(message) => boolean + * + * Returns whether the value is set on the given message. Raises an + * exception when calling for fields that do not have presence. + */ +static VALUE FieldDescriptor_has(VALUE _self, VALUE msg_rb) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + const upb_MessageDef* m; + const upb_Message* msg = Message_Get(msg_rb, &m); + + if (m != upb_FieldDef_ContainingType(self->fielddef)) { + rb_raise(cTypeError, "has method called on wrong message type"); + } else if (!upb_FieldDef_HasPresence(self->fielddef)) { + rb_raise(rb_eArgError, "does not track presence"); + } + + return upb_Message_HasFieldByDef(msg, self->fielddef) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * FieldDescriptor.clear(message) + * + * Clears the field from the message if it's set. + */ +static VALUE FieldDescriptor_clear(VALUE _self, VALUE msg_rb) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + const upb_MessageDef* m; + upb_Message* msg = Message_GetMutable(msg_rb, &m); + + if (m != upb_FieldDef_ContainingType(self->fielddef)) { + rb_raise(cTypeError, "has method called on wrong message type"); + } + + upb_Message_ClearFieldByDef(msg, self->fielddef); + return Qnil; +} + +/* + * call-seq: + * FieldDescriptor.set(message, value) + * + * Sets the value corresponding to this field to the given value on the given + * message. Raises an exception if message is of the wrong type. Performs the + * ordinary type-checks for field setting. + */ +static VALUE FieldDescriptor_set(VALUE _self, VALUE msg_rb, VALUE value) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + const upb_MessageDef* m; + upb_Message* msg = Message_GetMutable(msg_rb, &m); + upb_Arena* arena = Arena_get(Message_GetArena(msg_rb)); + upb_MessageValue msgval; + + if (m != upb_FieldDef_ContainingType(self->fielddef)) { + rb_raise(cTypeError, "set method called on wrong message type"); + } + + msgval = Convert_RubyToUpb(value, upb_FieldDef_Name(self->fielddef), + TypeInfo_get(self->fielddef), arena); + upb_Message_SetFieldByDef(msg, self->fielddef, msgval, arena); + return Qnil; +} + +/* + * call-seq: + * FieldDescriptor.options => options + * + * Returns the `FieldOptions` for this `FieldDescriptor`. + */ +static VALUE FieldDescriptor_options(VALUE _self) { + FieldDescriptor* self = ruby_to_FieldDescriptor(_self); + const google_protobuf_FieldOptions* opts = + upb_FieldDef_Options(self->fielddef); + upb_Arena* arena = upb_Arena_New(); + size_t size; + char* serialized = google_protobuf_FieldOptions_serialize(opts, arena, &size); + VALUE field_options = decode_options(_self, "FieldOptions", size, serialized, + self->descriptor_pool); + upb_Arena_Free(arena); + return field_options; +} + +static void FieldDescriptor_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "FieldDescriptor", rb_cObject); + rb_define_alloc_func(klass, FieldDescriptor_alloc); + rb_define_method(klass, "initialize", FieldDescriptor_initialize, 3); + rb_define_method(klass, "name", FieldDescriptor_name, 0); + rb_define_method(klass, "type", FieldDescriptor__type, 0); + rb_define_method(klass, "default", FieldDescriptor_default, 0); + rb_define_method(klass, "has_presence?", FieldDescriptor_has_presence, 0); + rb_define_method(klass, "is_packed?", FieldDescriptor_is_packed, 0); + rb_define_method(klass, "json_name", FieldDescriptor_json_name, 0); + rb_define_method(klass, "label", FieldDescriptor_label, 0); + rb_define_method(klass, "number", FieldDescriptor_number, 0); + rb_define_method(klass, "submsg_name", FieldDescriptor_submsg_name, 0); + rb_define_method(klass, "subtype", FieldDescriptor_subtype, 0); + rb_define_method(klass, "has?", FieldDescriptor_has, 1); + rb_define_method(klass, "clear", FieldDescriptor_clear, 1); + rb_define_method(klass, "get", FieldDescriptor_get, 1); + rb_define_method(klass, "set", FieldDescriptor_set, 2); + rb_define_method(klass, "options", FieldDescriptor_options, 0); + rb_gc_register_address(&cFieldDescriptor); + cFieldDescriptor = klass; +} + +// ----------------------------------------------------------------------------- +// OneofDescriptor. +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_OneofDef* oneofdef; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE descriptor_pool; // Owns the upb_OneofDef. +} OneofDescriptor; + +static VALUE cOneofDescriptor = Qnil; + +static void OneofDescriptor_mark(void* _self) { + OneofDescriptor* self = _self; + rb_gc_mark(self->descriptor_pool); +} + +static const rb_data_type_t OneofDescriptor_type = { + "Google::Protobuf::OneofDescriptor", + {OneofDescriptor_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static OneofDescriptor* ruby_to_OneofDescriptor(VALUE val) { + OneofDescriptor* ret; + TypedData_Get_Struct(val, OneofDescriptor, &OneofDescriptor_type, ret); + return ret; +} + +/* + * call-seq: + * OneofDescriptor.new => oneof_descriptor + * + * Creates a new, empty, oneof descriptor. The oneof may only be modified prior + * to being added to a message descriptor which is subsequently added to a pool. + */ +static VALUE OneofDescriptor_alloc(VALUE klass) { + OneofDescriptor* self = ALLOC(OneofDescriptor); + VALUE ret = TypedData_Wrap_Struct(klass, &OneofDescriptor_type, self); + self->oneofdef = NULL; + self->descriptor_pool = Qnil; + return ret; +} + +/* + * call-seq: + * OneofDescriptor.new(c_only_cookie, pool, ptr) => OneofDescriptor + * + * Creates a descriptor wrapper object. May only be called from C. + */ +static VALUE OneofDescriptor_initialize(VALUE _self, VALUE cookie, + VALUE descriptor_pool, VALUE ptr) { + OneofDescriptor* self = ruby_to_OneofDescriptor(_self); + + if (cookie != c_only_cookie) { + rb_raise(rb_eRuntimeError, + "Descriptor objects may not be created from Ruby."); + } + + RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool); + self->oneofdef = (const upb_OneofDef*)NUM2ULL(ptr); + + return Qnil; +} + +/* + * call-seq: + * OneofDescriptor.name => name + * + * Returns the name of this oneof. + */ +static VALUE OneofDescriptor_name(VALUE _self) { + OneofDescriptor* self = ruby_to_OneofDescriptor(_self); + return rb_str_maybe_null(upb_OneofDef_Name(self->oneofdef)); +} + +/* + * call-seq: + * OneofDescriptor.each(&block) => nil + * + * Iterates through fields in this oneof, yielding to the block on each one. + */ +static VALUE OneofDescriptor_each(VALUE _self) { + OneofDescriptor* self = ruby_to_OneofDescriptor(_self); + + int n = upb_OneofDef_FieldCount(self->oneofdef); + for (int i = 0; i < n; i++) { + const upb_FieldDef* f = upb_OneofDef_Field(self->oneofdef, i); + VALUE obj = get_fielddef_obj(self->descriptor_pool, f); + rb_yield(obj); + } + return Qnil; +} + +/* + * call-seq: + * OneofDescriptor.options => options + * + * Returns the `OneofOptions` for this `OneofDescriptor`. + */ +static VALUE OneOfDescriptor_options(VALUE _self) { + OneofDescriptor* self = ruby_to_OneofDescriptor(_self); + const google_protobuf_OneofOptions* opts = + upb_OneofDef_Options(self->oneofdef); + upb_Arena* arena = upb_Arena_New(); + size_t size; + char* serialized = google_protobuf_OneofOptions_serialize(opts, arena, &size); + VALUE oneof_options = decode_options(_self, "OneofOptions", size, serialized, + self->descriptor_pool); + upb_Arena_Free(arena); + return oneof_options; +} + +static void OneofDescriptor_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "OneofDescriptor", rb_cObject); + rb_define_alloc_func(klass, OneofDescriptor_alloc); + rb_define_method(klass, "initialize", OneofDescriptor_initialize, 3); + rb_define_method(klass, "name", OneofDescriptor_name, 0); + rb_define_method(klass, "each", OneofDescriptor_each, 0); + rb_define_method(klass, "options", OneOfDescriptor_options, 0); + rb_include_module(klass, rb_mEnumerable); + rb_gc_register_address(&cOneofDescriptor); + cOneofDescriptor = klass; +} + +// ----------------------------------------------------------------------------- +// EnumDescriptor. +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_EnumDef* enumdef; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE module; // begins as nil + VALUE descriptor_pool; // Owns the upb_EnumDef. +} EnumDescriptor; + +static VALUE cEnumDescriptor = Qnil; + +static void EnumDescriptor_mark(void* _self) { + EnumDescriptor* self = _self; + rb_gc_mark(self->module); + rb_gc_mark(self->descriptor_pool); +} + +static const rb_data_type_t EnumDescriptor_type = { + "Google::Protobuf::EnumDescriptor", + {EnumDescriptor_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static EnumDescriptor* ruby_to_EnumDescriptor(VALUE val) { + EnumDescriptor* ret; + TypedData_Get_Struct(val, EnumDescriptor, &EnumDescriptor_type, ret); + return ret; +} + +static VALUE EnumDescriptor_alloc(VALUE klass) { + EnumDescriptor* self = ALLOC(EnumDescriptor); + VALUE ret = TypedData_Wrap_Struct(klass, &EnumDescriptor_type, self); + self->enumdef = NULL; + self->module = Qnil; + self->descriptor_pool = Qnil; + return ret; +} + +// Exposed to other modules in defs.h. +const upb_EnumDef* EnumDescriptor_GetEnumDef(VALUE enum_desc_rb) { + EnumDescriptor* desc = ruby_to_EnumDescriptor(enum_desc_rb); + return desc->enumdef; +} + +/* + * call-seq: + * EnumDescriptor.new(c_only_cookie, ptr) => EnumDescriptor + * + * Creates a descriptor wrapper object. May only be called from C. + */ +static VALUE EnumDescriptor_initialize(VALUE _self, VALUE cookie, + VALUE descriptor_pool, VALUE ptr) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + + if (cookie != c_only_cookie) { + rb_raise(rb_eRuntimeError, + "Descriptor objects may not be created from Ruby."); + } + + RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool); + self->enumdef = (const upb_EnumDef*)NUM2ULL(ptr); + + return Qnil; +} + +/* + * call-seq: + * EnumDescriptor.file_descriptor + * + * Returns the FileDescriptor object this enum belongs to. + */ +static VALUE EnumDescriptor_file_descriptor(VALUE _self) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + return get_filedef_obj(self->descriptor_pool, + upb_EnumDef_File(self->enumdef)); +} + +/* + * call-seq: + * EnumDescriptor.is_closed? => bool + * + * Returns whether this enum is open or closed. + */ +static VALUE EnumDescriptor_is_closed(VALUE _self) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + return upb_EnumDef_IsClosed(self->enumdef) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * EnumDescriptor.name => name + * + * Returns the name of this enum type. + */ +static VALUE EnumDescriptor_name(VALUE _self) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + return rb_str_maybe_null(upb_EnumDef_FullName(self->enumdef)); +} + +/* + * call-seq: + * EnumDescriptor.lookup_name(name) => value + * + * Returns the numeric value corresponding to the given key name (as a Ruby + * symbol), or nil if none. + */ +static VALUE EnumDescriptor_lookup_name(VALUE _self, VALUE name) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + const char* name_str = rb_id2name(SYM2ID(name)); + const upb_EnumValueDef* ev = + upb_EnumDef_FindValueByName(self->enumdef, name_str); + if (ev) { + return INT2NUM(upb_EnumValueDef_Number(ev)); + } else { + return Qnil; + } +} + +/* + * call-seq: + * EnumDescriptor.lookup_value(name) => value + * + * Returns the key name (as a Ruby symbol) corresponding to the integer value, + * or nil if none. + */ +static VALUE EnumDescriptor_lookup_value(VALUE _self, VALUE number) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + int32_t val = NUM2INT(number); + const upb_EnumValueDef* ev = + upb_EnumDef_FindValueByNumber(self->enumdef, val); + if (ev) { + return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev))); + } else { + return Qnil; + } +} + +/* + * call-seq: + * EnumDescriptor.each(&block) + * + * Iterates over key => value mappings in this enum's definition, yielding to + * the block with (key, value) arguments for each one. + */ +static VALUE EnumDescriptor_each(VALUE _self) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + + int n = upb_EnumDef_ValueCount(self->enumdef); + for (int i = 0; i < n; i++) { + const upb_EnumValueDef* ev = upb_EnumDef_Value(self->enumdef, i); + VALUE key = ID2SYM(rb_intern(upb_EnumValueDef_Name(ev))); + VALUE number = INT2NUM(upb_EnumValueDef_Number(ev)); + rb_yield_values(2, key, number); + } + + return Qnil; +} + +/* + * call-seq: + * EnumDescriptor.enummodule => module + * + * Returns the Ruby module corresponding to this enum type. + */ +static VALUE EnumDescriptor_enummodule(VALUE _self) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + if (self->module == Qnil) { + RB_OBJ_WRITE(_self, &self->module, build_module_from_enumdesc(_self)); + } + return self->module; +} + +/* + * call-seq: + * EnumDescriptor.options => options + * + * Returns the `EnumOptions` for this `EnumDescriptor`. + */ +static VALUE EnumDescriptor_options(VALUE _self) { + EnumDescriptor* self = ruby_to_EnumDescriptor(_self); + const google_protobuf_EnumOptions* opts = upb_EnumDef_Options(self->enumdef); + upb_Arena* arena = upb_Arena_New(); + size_t size; + char* serialized = google_protobuf_EnumOptions_serialize(opts, arena, &size); + VALUE enum_options = decode_options(_self, "EnumOptions", size, serialized, + self->descriptor_pool); + upb_Arena_Free(arena); + return enum_options; +} + +static void EnumDescriptor_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "EnumDescriptor", rb_cObject); + rb_define_alloc_func(klass, EnumDescriptor_alloc); + rb_define_method(klass, "initialize", EnumDescriptor_initialize, 3); + rb_define_method(klass, "name", EnumDescriptor_name, 0); + rb_define_method(klass, "lookup_name", EnumDescriptor_lookup_name, 1); + rb_define_method(klass, "lookup_value", EnumDescriptor_lookup_value, 1); + rb_define_method(klass, "each", EnumDescriptor_each, 0); + rb_define_method(klass, "enummodule", EnumDescriptor_enummodule, 0); + rb_define_method(klass, "file_descriptor", EnumDescriptor_file_descriptor, 0); + rb_define_method(klass, "is_closed?", EnumDescriptor_is_closed, 0); + rb_define_method(klass, "options", EnumDescriptor_options, 0); + rb_include_module(klass, rb_mEnumerable); + rb_gc_register_address(&cEnumDescriptor); + cEnumDescriptor = klass; +} + +// ----------------------------------------------------------------------------- +// ServiceDescriptor +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_ServiceDef* servicedef; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE module; // begins as nil + VALUE descriptor_pool; // Owns the upb_ServiceDef. +} ServiceDescriptor; + +static VALUE cServiceDescriptor = Qnil; + +static void ServiceDescriptor_mark(void* _self) { + ServiceDescriptor* self = _self; + rb_gc_mark(self->module); + rb_gc_mark(self->descriptor_pool); +} + +static const rb_data_type_t ServiceDescriptor_type = { + "Google::Protobuf::ServicDescriptor", + {ServiceDescriptor_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static ServiceDescriptor* ruby_to_ServiceDescriptor(VALUE val) { + ServiceDescriptor* ret; + TypedData_Get_Struct(val, ServiceDescriptor, &ServiceDescriptor_type, ret); + return ret; +} + +static VALUE ServiceDescriptor_alloc(VALUE klass) { + ServiceDescriptor* self = ALLOC(ServiceDescriptor); + VALUE ret = TypedData_Wrap_Struct(klass, &ServiceDescriptor_type, self); + self->servicedef = NULL; + self->module = Qnil; + self->descriptor_pool = Qnil; + return ret; +} + +/* + * call-seq: + * ServiceDescriptor.new(c_only_cookie, ptr) => ServiceDescriptor + * + * Creates a descriptor wrapper object. May only be called from C. + */ +static VALUE ServiceDescriptor_initialize(VALUE _self, VALUE cookie, + VALUE descriptor_pool, VALUE ptr) { + ServiceDescriptor* self = ruby_to_ServiceDescriptor(_self); + + if (cookie != c_only_cookie) { + rb_raise(rb_eRuntimeError, + "Descriptor objects may not be created from Ruby."); + } + + RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool); + self->servicedef = (const upb_ServiceDef*)NUM2ULL(ptr); + + return Qnil; +} + +/* + * call-seq: + * ServiceDescriptor.name => name + * + * Returns the name of this service. + */ +static VALUE ServiceDescriptor_name(VALUE _self) { + ServiceDescriptor* self = ruby_to_ServiceDescriptor(_self); + return rb_str_maybe_null(upb_ServiceDef_FullName(self->servicedef)); +} + +/* + * call-seq: + * ServiceDescriptor.file_descriptor + * + * Returns the FileDescriptor object this service belongs to. + */ +static VALUE ServiceDescriptor_file_descriptor(VALUE _self) { + ServiceDescriptor* self = ruby_to_ServiceDescriptor(_self); + return get_filedef_obj(self->descriptor_pool, + upb_ServiceDef_File(self->servicedef)); +} + +/* + * call-seq: + * ServiceDescriptor.each(&block) + * + * Iterates over methods in this service, yielding to the block on each one. + */ +static VALUE ServiceDescriptor_each(VALUE _self) { + ServiceDescriptor* self = ruby_to_ServiceDescriptor(_self); + + int n = upb_ServiceDef_MethodCount(self->servicedef); + for (int i = 0; i < n; i++) { + const upb_MethodDef* method = upb_ServiceDef_Method(self->servicedef, i); + VALUE obj = get_methoddef_obj(self->descriptor_pool, method); + rb_yield(obj); + } + return Qnil; +} + +/* + * call-seq: + * ServiceDescriptor.options => options + * + * Returns the `ServiceOptions` for this `ServiceDescriptor`. + */ +static VALUE ServiceDescriptor_options(VALUE _self) { + ServiceDescriptor* self = ruby_to_ServiceDescriptor(_self); + const google_protobuf_ServiceOptions* opts = + upb_ServiceDef_Options(self->servicedef); + upb_Arena* arena = upb_Arena_New(); + size_t size; + char* serialized = + google_protobuf_ServiceOptions_serialize(opts, arena, &size); + VALUE service_options = decode_options(_self, "ServiceOptions", size, + serialized, self->descriptor_pool); + upb_Arena_Free(arena); + return service_options; +} + +static void ServiceDescriptor_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "ServiceDescriptor", rb_cObject); + rb_define_alloc_func(klass, ServiceDescriptor_alloc); + rb_define_method(klass, "initialize", ServiceDescriptor_initialize, 3); + rb_define_method(klass, "name", ServiceDescriptor_name, 0); + rb_define_method(klass, "each", ServiceDescriptor_each, 0); + rb_define_method(klass, "file_descriptor", ServiceDescriptor_file_descriptor, + 0); + rb_define_method(klass, "options", ServiceDescriptor_options, 0); + rb_include_module(klass, rb_mEnumerable); + rb_gc_register_address(&cServiceDescriptor); + cServiceDescriptor = klass; +} + +// ----------------------------------------------------------------------------- +// MethodDescriptor +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_MethodDef* methoddef; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE module; // begins as nil + VALUE descriptor_pool; // Owns the upb_MethodDef. +} MethodDescriptor; + +static VALUE cMethodDescriptor = Qnil; + +static void MethodDescriptor_mark(void* _self) { + MethodDescriptor* self = _self; + rb_gc_mark(self->module); + rb_gc_mark(self->descriptor_pool); +} + +static const rb_data_type_t MethodDescriptor_type = { + "Google::Protobuf::MethodDescriptor", + {MethodDescriptor_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static MethodDescriptor* ruby_to_MethodDescriptor(VALUE val) { + MethodDescriptor* ret; + TypedData_Get_Struct(val, MethodDescriptor, &MethodDescriptor_type, ret); + return ret; +} + +static VALUE MethodDescriptor_alloc(VALUE klass) { + MethodDescriptor* self = ALLOC(MethodDescriptor); + VALUE ret = TypedData_Wrap_Struct(klass, &MethodDescriptor_type, self); + self->methoddef = NULL; + self->module = Qnil; + self->descriptor_pool = Qnil; + return ret; +} + +/* + * call-seq: + * MethodDescriptor.new(c_only_cookie, ptr) => MethodDescriptor + * + * Creates a descriptor wrapper object. May only be called from C. + */ +static VALUE MethodDescriptor_initialize(VALUE _self, VALUE cookie, + VALUE descriptor_pool, VALUE ptr) { + MethodDescriptor* self = ruby_to_MethodDescriptor(_self); + + if (cookie != c_only_cookie) { + rb_raise(rb_eRuntimeError, + "Descriptor objects may not be created from Ruby."); + } + + RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool); + self->methoddef = (const upb_MethodDef*)NUM2ULL(ptr); + + return Qnil; +} + +/* + * call-seq: + * MethodDescriptor.name => name + * + * Returns the name of this method + */ +static VALUE MethodDescriptor_name(VALUE _self) { + MethodDescriptor* self = ruby_to_MethodDescriptor(_self); + return rb_str_maybe_null(upb_MethodDef_Name(self->methoddef)); +} + +/* + * call-seq: + * MethodDescriptor.options => options + * + * Returns the `MethodOptions` for this `MethodDescriptor`. + */ +static VALUE MethodDescriptor_options(VALUE _self) { + MethodDescriptor* self = ruby_to_MethodDescriptor(_self); + const google_protobuf_MethodOptions* opts = + upb_MethodDef_Options(self->methoddef); + upb_Arena* arena = upb_Arena_New(); + size_t size; + char* serialized = + google_protobuf_MethodOptions_serialize(opts, arena, &size); + VALUE method_options = decode_options(_self, "MethodOptions", size, + serialized, self->descriptor_pool); + upb_Arena_Free(arena); + return method_options; +} + +/* + * call-seq: + * MethodDescriptor.input_type => Descriptor + * + * Returns the `Descriptor` for the request message type of this method + */ +static VALUE MethodDescriptor_input_type(VALUE _self) { + MethodDescriptor* self = ruby_to_MethodDescriptor(_self); + const upb_MessageDef* type = upb_MethodDef_InputType(self->methoddef); + return get_msgdef_obj(self->descriptor_pool, type); +} + +/* + * call-seq: + * MethodDescriptor.output_type => Descriptor + * + * Returns the `Descriptor` for the response message type of this method + */ +static VALUE MethodDescriptor_output_type(VALUE _self) { + MethodDescriptor* self = ruby_to_MethodDescriptor(_self); + const upb_MessageDef* type = upb_MethodDef_OutputType(self->methoddef); + return get_msgdef_obj(self->descriptor_pool, type); +} + +/* + * call-seq: + * MethodDescriptor.client_streaming => bool + * + * Returns whether or not this is a streaming request method + */ +static VALUE MethodDescriptor_client_streaming(VALUE _self) { + MethodDescriptor* self = ruby_to_MethodDescriptor(_self); + return upb_MethodDef_ClientStreaming(self->methoddef) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * MethodDescriptor.server_streaming => bool + * + * Returns whether or not this is a streaming response method + */ +static VALUE MethodDescriptor_server_streaming(VALUE _self) { + MethodDescriptor* self = ruby_to_MethodDescriptor(_self); + return upb_MethodDef_ServerStreaming(self->methoddef) ? Qtrue : Qfalse; +} + +static void MethodDescriptor_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "MethodDescriptor", rb_cObject); + rb_define_alloc_func(klass, MethodDescriptor_alloc); + rb_define_method(klass, "initialize", MethodDescriptor_initialize, 3); + rb_define_method(klass, "name", MethodDescriptor_name, 0); + rb_define_method(klass, "options", MethodDescriptor_options, 0); + rb_define_method(klass, "input_type", MethodDescriptor_input_type, 0); + rb_define_method(klass, "output_type", MethodDescriptor_output_type, 0); + rb_define_method(klass, "client_streaming", MethodDescriptor_client_streaming, + 0); + rb_define_method(klass, "server_streaming", MethodDescriptor_server_streaming, + 0); + rb_gc_register_address(&cMethodDescriptor); + cMethodDescriptor = klass; +} + +static VALUE get_def_obj(VALUE _descriptor_pool, const void* ptr, VALUE klass) { + DescriptorPool* descriptor_pool = ruby_to_DescriptorPool(_descriptor_pool); + VALUE key = ULL2NUM((intptr_t)ptr); + VALUE def; + + def = rb_hash_aref(descriptor_pool->def_to_descriptor, key); + + if (ptr == NULL) { + return Qnil; + } + + if (def == Qnil) { + // Lazily create wrapper object. + VALUE args[3] = {c_only_cookie, _descriptor_pool, key}; + def = rb_class_new_instance(3, args, klass); + rb_hash_aset(descriptor_pool->def_to_descriptor, key, def); + } + + return def; +} + +static VALUE get_msgdef_obj(VALUE descriptor_pool, const upb_MessageDef* def) { + return get_def_obj(descriptor_pool, def, cDescriptor); +} + +static VALUE get_enumdef_obj(VALUE descriptor_pool, const upb_EnumDef* def) { + return get_def_obj(descriptor_pool, def, cEnumDescriptor); +} + +static VALUE get_fielddef_obj(VALUE descriptor_pool, const upb_FieldDef* def) { + return get_def_obj(descriptor_pool, def, cFieldDescriptor); +} + +static VALUE get_filedef_obj(VALUE descriptor_pool, const upb_FileDef* def) { + return get_def_obj(descriptor_pool, def, cFileDescriptor); +} + +static VALUE get_oneofdef_obj(VALUE descriptor_pool, const upb_OneofDef* def) { + return get_def_obj(descriptor_pool, def, cOneofDescriptor); +} + +static VALUE get_servicedef_obj(VALUE descriptor_pool, + const upb_ServiceDef* def) { + return get_def_obj(descriptor_pool, def, cServiceDescriptor); +} + +static VALUE get_methoddef_obj(VALUE descriptor_pool, + const upb_MethodDef* def) { + return get_def_obj(descriptor_pool, def, cMethodDescriptor); +} + +// ----------------------------------------------------------------------------- +// Shared functions +// ----------------------------------------------------------------------------- + +// Functions exposed to other modules in defs.h. + +VALUE Descriptor_DefToClass(const upb_MessageDef* m) { + const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(m)); + VALUE pool = ObjectCache_Get(symtab); + PBRUBY_ASSERT(pool != Qnil); + VALUE desc_rb = get_msgdef_obj(pool, m); + const Descriptor* desc = ruby_to_Descriptor(desc_rb); + return desc->klass; +} + +const upb_MessageDef* Descriptor_GetMsgDef(VALUE desc_rb) { + const Descriptor* desc = ruby_to_Descriptor(desc_rb); + return desc->msgdef; +} + +VALUE TypeInfo_InitArg(int argc, VALUE* argv, int skip_arg) { + if (argc > skip_arg) { + if (argc > 1 + skip_arg) { + rb_raise(rb_eArgError, "Expected a maximum of %d arguments.", + skip_arg + 1); + } + return argv[skip_arg]; + } else { + return Qnil; + } +} + +TypeInfo TypeInfo_FromClass(int argc, VALUE* argv, int skip_arg, + VALUE* type_class, VALUE* init_arg) { + TypeInfo ret = {ruby_to_fieldtype(argv[skip_arg])}; + + if (ret.type == kUpb_CType_Message || ret.type == kUpb_CType_Enum) { + *init_arg = TypeInfo_InitArg(argc, argv, skip_arg + 2); + + if (argc < 2 + skip_arg) { + rb_raise(rb_eArgError, "Expected at least %d arguments for message/enum.", + 2 + skip_arg); + } + + VALUE klass = argv[1 + skip_arg]; + VALUE desc = MessageOrEnum_GetDescriptor(klass); + *type_class = klass; + + if (desc == Qnil) { + rb_raise(rb_eArgError, + "Type class has no descriptor. Please pass a " + "class or enum as returned by the DescriptorPool."); + } + + if (ret.type == kUpb_CType_Message) { + ret.def.msgdef = ruby_to_Descriptor(desc)->msgdef; + Message_CheckClass(klass); + } else { + PBRUBY_ASSERT(ret.type == kUpb_CType_Enum); + ret.def.enumdef = ruby_to_EnumDescriptor(desc)->enumdef; + } + } else { + *init_arg = TypeInfo_InitArg(argc, argv, skip_arg + 1); + } + + return ret; +} + +void Defs_register(VALUE module) { + DescriptorPool_register(module); + Descriptor_register(module); + FileDescriptor_register(module); + FieldDescriptor_register(module); + OneofDescriptor_register(module); + EnumDescriptor_register(module); + ServiceDescriptor_register(module); + MethodDescriptor_register(module); + + rb_gc_register_address(&c_only_cookie); + c_only_cookie = rb_class_new_instance(0, NULL, rb_cObject); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/defs.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/defs.h new file mode 100755 index 0000000..931dd6e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/defs.h @@ -0,0 +1,82 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef RUBY_PROTOBUF_DEFS_H_ +#define RUBY_PROTOBUF_DEFS_H_ + +#include "protobuf.h" +#include "ruby-upb.h" + +// ----------------------------------------------------------------------------- +// TypeInfo +// ----------------------------------------------------------------------------- + +// This bundles a upb_CType and msgdef/enumdef when appropriate. This is +// convenient for functions that need type information but cannot necessarily +// assume a upb_FieldDef will be available. +// +// For example, Google::Protobuf::Map and Google::Protobuf::RepeatedField can +// be constructed with type information alone: +// +// # RepeatedField will internally store the type information in a TypeInfo. +// Google::Protobuf::RepeatedField.new(:message, FooMessage) + +typedef struct { + upb_CType type; + union { + const upb_MessageDef* msgdef; // When type == kUpb_CType_Message + const upb_EnumDef* enumdef; // When type == kUpb_CType_Enum + } def; +} TypeInfo; + +static inline TypeInfo TypeInfo_get(const upb_FieldDef* f) { + TypeInfo ret = {upb_FieldDef_CType(f), {NULL}}; + switch (ret.type) { + case kUpb_CType_Message: + ret.def.msgdef = upb_FieldDef_MessageSubDef(f); + break; + case kUpb_CType_Enum: + ret.def.enumdef = upb_FieldDef_EnumSubDef(f); + break; + default: + break; + } + return ret; +} + +TypeInfo TypeInfo_FromClass(int argc, VALUE* argv, int skip_arg, + VALUE* type_class, VALUE* init_arg); + +static inline TypeInfo TypeInfo_from_type(upb_CType type) { + TypeInfo ret = {type}; + assert(type != kUpb_CType_Message && type != kUpb_CType_Enum); + return ret; +} + +// ----------------------------------------------------------------------------- +// Other utilities +// ----------------------------------------------------------------------------- + +VALUE Descriptor_DefToClass(const upb_MessageDef* m); + +// Returns the underlying msgdef, enumdef, or symtab (respectively) for the +// given Descriptor, EnumDescriptor, or DescriptorPool Ruby object. +const upb_EnumDef* EnumDescriptor_GetEnumDef(VALUE enum_desc_rb); +const upb_DefPool* DescriptorPool_GetSymtab(VALUE desc_pool_rb); +const upb_MessageDef* Descriptor_GetMsgDef(VALUE desc_rb); + +// Returns a upb field type for the given Ruby symbol +// (eg. :float => kUpb_CType_Float). +upb_CType ruby_to_fieldtype(VALUE type); + +// The singleton generated pool (a DescriptorPool object). +extern VALUE generated_pool; + +// Call at startup to register all types in this module. +void Defs_register(VALUE module); + +#endif // RUBY_PROTOBUF_DEFS_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/extconf.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/extconf.rb new file mode 100755 index 0000000..ed812c9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/extconf.rb @@ -0,0 +1,28 @@ +#!/usr/bin/ruby + +require 'mkmf' + +ext_name = "google/protobuf_c" + +dir_config(ext_name) + +if RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /freebsd/ + $CFLAGS += " -std=gnu99 -O3 -DNDEBUG -fvisibility=hidden -Wall -Wsign-compare -Wno-declaration-after-statement" +else + $CFLAGS += " -std=gnu99 -O3 -DNDEBUG" +end + +if RUBY_PLATFORM =~ /linux/ + # Instruct the linker to point memcpy calls at our __wrap_memcpy wrapper. + $LDFLAGS += " -Wl,-wrap,memcpy" +end + +$VPATH << "$(srcdir)/third_party/utf8_range" +$INCFLAGS += " -I$(srcdir)/third_party/utf8_range" + +$srcs = ["protobuf.c", "convert.c", "defs.c", "message.c", + "repeated_field.c", "map.c", "ruby-upb.c", "wrap_memcpy.c", + "utf8_range.c", "shared_convert.c", + "shared_message.c"] + +create_makefile(ext_name) diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/glue.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/glue.c new file mode 100755 index 0000000..3c84d7f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/glue.c @@ -0,0 +1,72 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// ----------------------------------------------------------------------------- +// Exposing inlined UPB functions. Strictly free of dependencies on +// Ruby interpreter internals. + +#include "ruby-upb.h" + +upb_Arena* Arena_create() { return upb_Arena_Init(NULL, 0, &upb_alloc_global); } + +google_protobuf_FileDescriptorProto* FileDescriptorProto_parse( + const char* serialized_file_proto, size_t length, upb_Arena* arena) { + return google_protobuf_FileDescriptorProto_parse(serialized_file_proto, + length, arena); +} + +char* EnumDescriptor_serialized_options(const upb_EnumDef* enumdef, + size_t* size, upb_Arena* arena) { + const google_protobuf_EnumOptions* opts = upb_EnumDef_Options(enumdef); + char* serialized = google_protobuf_EnumOptions_serialize(opts, arena, size); + return serialized; +} + +char* FileDescriptor_serialized_options(const upb_FileDef* filedef, + size_t* size, upb_Arena* arena) { + const google_protobuf_FileOptions* opts = upb_FileDef_Options(filedef); + char* serialized = google_protobuf_FileOptions_serialize(opts, arena, size); + return serialized; +} + +char* Descriptor_serialized_options(const upb_MessageDef* msgdef, size_t* size, + upb_Arena* arena) { + const google_protobuf_MessageOptions* opts = upb_MessageDef_Options(msgdef); + char* serialized = + google_protobuf_MessageOptions_serialize(opts, arena, size); + return serialized; +} + +char* OneOfDescriptor_serialized_options(const upb_OneofDef* oneofdef, + size_t* size, upb_Arena* arena) { + const google_protobuf_OneofOptions* opts = upb_OneofDef_Options(oneofdef); + char* serialized = google_protobuf_OneofOptions_serialize(opts, arena, size); + return serialized; +} + +char* FieldDescriptor_serialized_options(const upb_FieldDef* fielddef, + size_t* size, upb_Arena* arena) { + const google_protobuf_FieldOptions* opts = upb_FieldDef_Options(fielddef); + char* serialized = google_protobuf_FieldOptions_serialize(opts, arena, size); + return serialized; +} + +char* ServiceDescriptor_serialized_options(const upb_ServiceDef* servicedef, + size_t* size, upb_Arena* arena) { + const google_protobuf_ServiceOptions* opts = + upb_ServiceDef_Options(servicedef); + char* serialized = + google_protobuf_ServiceOptions_serialize(opts, arena, size); + return serialized; +} + +char* MethodDescriptor_serialized_options(const upb_MethodDef* methoddef, + size_t* size, upb_Arena* arena) { + const google_protobuf_MethodOptions* opts = upb_MethodDef_Options(methoddef); + char* serialized = google_protobuf_MethodOptions_serialize(opts, arena, size); + return serialized; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/map.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/map.c new file mode 100755 index 0000000..318ee13 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/map.c @@ -0,0 +1,679 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2014 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#include "convert.h" +#include "defs.h" +#include "message.h" +#include "protobuf.h" + +// ----------------------------------------------------------------------------- +// Basic map operations on top of upb_Map. +// +// Note that we roll our own `Map` container here because, as for +// `RepeatedField`, we want a strongly-typed container. This is so that any user +// errors due to incorrect map key or value types are raised as close as +// possible to the error site, rather than at some deferred point (e.g., +// serialization). +// ----------------------------------------------------------------------------- + +// ----------------------------------------------------------------------------- +// Map container type. +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_Map* map; // Can convert to mutable when non-frozen. + upb_CType key_type; + TypeInfo value_type_info; + VALUE value_type_class; + VALUE arena; +} Map; + +static void Map_mark(void* _self) { + Map* self = _self; + rb_gc_mark(self->value_type_class); + rb_gc_mark(self->arena); +} + +static size_t Map_memsize(const void* _self) { return sizeof(Map); } + +const rb_data_type_t Map_type = { + "Google::Protobuf::Map", + {Map_mark, RUBY_DEFAULT_FREE, Map_memsize}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY, +}; + +VALUE cMap; + +static Map* ruby_to_Map(VALUE _self) { + Map* self; + TypedData_Get_Struct(_self, Map, &Map_type, self); + return self; +} + +static VALUE Map_alloc(VALUE klass) { + Map* self = ALLOC(Map); + self->map = NULL; + self->value_type_class = Qnil; + self->value_type_info.def.msgdef = NULL; + self->arena = Qnil; + return TypedData_Wrap_Struct(klass, &Map_type, self); +} + +VALUE Map_GetRubyWrapper(upb_Map* map, upb_CType key_type, TypeInfo value_type, + VALUE arena) { + PBRUBY_ASSERT(map); + + VALUE val = ObjectCache_Get(map); + + if (val == Qnil) { + val = Map_alloc(cMap); + Map* self; + TypedData_Get_Struct(val, Map, &Map_type, self); + self->map = map; + self->arena = arena; + self->key_type = key_type; + self->value_type_info = value_type; + if (self->value_type_info.type == kUpb_CType_Message) { + const upb_MessageDef* val_m = self->value_type_info.def.msgdef; + self->value_type_class = Descriptor_DefToClass(val_m); + } + return ObjectCache_TryAdd(map, val); + } + + return val; +} + +static VALUE Map_new_this_type(Map* from) { + VALUE arena_rb = Arena_new(); + upb_Map* map = upb_Map_New(Arena_get(arena_rb), from->key_type, + from->value_type_info.type); + VALUE ret = + Map_GetRubyWrapper(map, from->key_type, from->value_type_info, arena_rb); + PBRUBY_ASSERT(ruby_to_Map(ret)->value_type_class == from->value_type_class); + return ret; +} + +static TypeInfo Map_keyinfo(Map* self) { + TypeInfo ret; + ret.type = self->key_type; + ret.def.msgdef = NULL; + return ret; +} + +static upb_Map* Map_GetMutable(VALUE _self) { + rb_check_frozen(_self); + return (upb_Map*)ruby_to_Map(_self)->map; +} + +VALUE Map_CreateHash(const upb_Map* map, upb_CType key_type, + TypeInfo val_info) { + VALUE hash = rb_hash_new(); + TypeInfo key_info = TypeInfo_from_type(key_type); + + if (!map) return hash; + + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + while (upb_Map_Next(map, &key, &val, &iter)) { + VALUE key_val = Convert_UpbToRuby(key, key_info, Qnil); + VALUE val_val = Scalar_CreateHash(val, val_info); + rb_hash_aset(hash, key_val, val_val); + } + + return hash; +} + +VALUE Map_deep_copy(VALUE obj) { + Map* self = ruby_to_Map(obj); + VALUE new_arena_rb = Arena_new(); + upb_Arena* arena = Arena_get(new_arena_rb); + upb_Map* new_map = + upb_Map_New(arena, self->key_type, self->value_type_info.type); + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + while (upb_Map_Next(self->map, &key, &val, &iter)) { + upb_MessageValue val_copy = + Msgval_DeepCopy(val, self->value_type_info, arena); + upb_Map_Set(new_map, key, val_copy, arena); + } + + return Map_GetRubyWrapper(new_map, self->key_type, self->value_type_info, + new_arena_rb); +} + +const upb_Map* Map_GetUpbMap(VALUE val, const upb_FieldDef* field, + upb_Arena* arena) { + const upb_FieldDef* key_field = map_field_key(field); + const upb_FieldDef* value_field = map_field_value(field); + TypeInfo value_type_info = TypeInfo_get(value_field); + Map* self; + + if (!RB_TYPE_P(val, T_DATA) || !RTYPEDDATA_P(val) || + RTYPEDDATA_TYPE(val) != &Map_type) { + rb_raise(cTypeError, "Expected Map instance"); + } + + self = ruby_to_Map(val); + if (self->key_type != upb_FieldDef_CType(key_field)) { + rb_raise(cTypeError, "Map key type does not match field's key type"); + } + if (self->value_type_info.type != value_type_info.type) { + rb_raise(cTypeError, "Map value type does not match field's value type"); + } + if (self->value_type_info.def.msgdef != value_type_info.def.msgdef) { + rb_raise(cTypeError, "Map value type has wrong message/enum class"); + } + + Arena_fuse(self->arena, arena); + return self->map; +} + +void Map_Inspect(StringBuilder* b, const upb_Map* map, upb_CType key_type, + TypeInfo val_type) { + bool first = true; + TypeInfo key_type_info = {key_type}; + StringBuilder_Printf(b, "{"); + if (map) { + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + while (upb_Map_Next(map, &key, &val, &iter)) { + if (first) { + first = false; + } else { + StringBuilder_Printf(b, ", "); + } + StringBuilder_PrintMsgval(b, key, key_type_info); + StringBuilder_Printf(b, "=>"); + StringBuilder_PrintMsgval(b, val, val_type); + } + } + StringBuilder_Printf(b, "}"); +} + +static int merge_into_self_callback(VALUE key, VALUE val, VALUE _self) { + Map* self = ruby_to_Map(_self); + upb_Arena* arena = Arena_get(self->arena); + upb_MessageValue key_val = + Convert_RubyToUpb(key, "", Map_keyinfo(self), arena); + upb_MessageValue val_val = + Convert_RubyToUpb(val, "", self->value_type_info, arena); + upb_Map_Set(Map_GetMutable(_self), key_val, val_val, arena); + return ST_CONTINUE; +} + +// Used only internally -- shared by #merge and #initialize. +static VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) { + if (TYPE(hashmap) == T_HASH) { + rb_hash_foreach(hashmap, merge_into_self_callback, _self); + } else if (RB_TYPE_P(hashmap, T_DATA) && RTYPEDDATA_P(hashmap) && + RTYPEDDATA_TYPE(hashmap) == &Map_type) { + Map* self = ruby_to_Map(_self); + Map* other = ruby_to_Map(hashmap); + upb_Arena* arena = Arena_get(self->arena); + upb_Map* self_map = Map_GetMutable(_self); + + Arena_fuse(other->arena, arena); + + if (self->key_type != other->key_type || + self->value_type_info.type != other->value_type_info.type || + self->value_type_class != other->value_type_class) { + rb_raise(rb_eArgError, "Attempt to merge Map with mismatching types"); + } + + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + while (upb_Map_Next(other->map, &key, &val, &iter)) { + upb_Map_Set(self_map, key, val, arena); + } + } else { + rb_raise(rb_eArgError, "Unknown type merging into Map"); + } + return _self; +} + +/* + * call-seq: + * Map.new(key_type, value_type, value_typeclass = nil, init_hashmap = {}) + * => new map + * + * Allocates a new Map container. This constructor may be called with 2, 3, or 4 + * arguments. The first two arguments are always present and are symbols (taking + * on the same values as field-type symbols in message descriptors) that + * indicate the type of the map key and value fields. + * + * The supported key types are: :int32, :int64, :uint32, :uint64, :bool, + * :string, :bytes. + * + * The supported value types are: :int32, :int64, :uint32, :uint64, :bool, + * :string, :bytes, :enum, :message. + * + * The third argument, value_typeclass, must be present if value_type is :enum + * or :message. As in RepeatedField#new, this argument must be a message class + * (for :message) or enum module (for :enum). + * + * The last argument, if present, provides initial content for map. Note that + * this may be an ordinary Ruby hashmap or another Map instance with identical + * key and value types. Also note that this argument may be present whether or + * not value_typeclass is present (and it is unambiguously separate from + * value_typeclass because value_typeclass's presence is strictly determined by + * value_type). The contents of this initial hashmap or Map instance are + * shallow-copied into the new Map: the original map is unmodified, but + * references to underlying objects will be shared if the value type is a + * message type. + */ +static VALUE Map_init(int argc, VALUE* argv, VALUE _self) { + Map* self = ruby_to_Map(_self); + VALUE init_arg; + + // We take either two args (:key_type, :value_type), three args (:key_type, + // :value_type, "ValueMessageType"), or four args (the above plus an initial + // hashmap). + if (argc < 2 || argc > 4) { + rb_raise(rb_eArgError, "Map constructor expects 2, 3 or 4 arguments."); + } + + self->key_type = ruby_to_fieldtype(argv[0]); + self->value_type_info = + TypeInfo_FromClass(argc, argv, 1, &self->value_type_class, &init_arg); + self->arena = Arena_new(); + + // Check that the key type is an allowed type. + switch (self->key_type) { + case kUpb_CType_Int32: + case kUpb_CType_Int64: + case kUpb_CType_UInt32: + case kUpb_CType_UInt64: + case kUpb_CType_Bool: + case kUpb_CType_String: + case kUpb_CType_Bytes: + // These are OK. + break; + default: + rb_raise(rb_eArgError, "Invalid key type for map."); + } + + self->map = upb_Map_New(Arena_get(self->arena), self->key_type, + self->value_type_info.type); + VALUE stored = ObjectCache_TryAdd(self->map, _self); + (void)stored; + PBRUBY_ASSERT(stored == _self); + + if (init_arg != Qnil) { + Map_merge_into_self(_self, init_arg); + } + + return Qnil; +} + +/* + * call-seq: + * Map.each(&block) + * + * Invokes &block on each |key, value| pair in the map, in unspecified order. + * Note that Map also includes Enumerable; map thus acts like a normal Ruby + * sequence. + */ +static VALUE Map_each(VALUE _self) { + Map* self = ruby_to_Map(_self); + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + + while (upb_Map_Next(self->map, &key, &val, &iter)) { + VALUE key_val = Convert_UpbToRuby(key, Map_keyinfo(self), self->arena); + VALUE val_val = Convert_UpbToRuby(val, self->value_type_info, self->arena); + rb_yield_values(2, key_val, val_val); + } + + return Qnil; +} + +/* + * call-seq: + * Map.keys => [list_of_keys] + * + * Returns the list of keys contained in the map, in unspecified order. + */ +static VALUE Map_keys(VALUE _self) { + Map* self = ruby_to_Map(_self); + size_t iter = kUpb_Map_Begin; + VALUE ret = rb_ary_new(); + upb_MessageValue key, val; + + while (upb_Map_Next(self->map, &key, &val, &iter)) { + VALUE key_val = Convert_UpbToRuby(key, Map_keyinfo(self), self->arena); + rb_ary_push(ret, key_val); + } + + return ret; +} + +/* + * call-seq: + * Map.values => [list_of_values] + * + * Returns the list of values contained in the map, in unspecified order. + */ +static VALUE Map_values(VALUE _self) { + Map* self = ruby_to_Map(_self); + size_t iter = kUpb_Map_Begin; + VALUE ret = rb_ary_new(); + upb_MessageValue key, val; + + while (upb_Map_Next(self->map, &key, &val, &iter)) { + VALUE val_val = Convert_UpbToRuby(val, self->value_type_info, self->arena); + rb_ary_push(ret, val_val); + } + + return ret; +} + +/* + * call-seq: + * Map.[](key) => value + * + * Accesses the element at the given key. Throws an exception if the key type is + * incorrect. Returns nil when the key is not present in the map. + */ +static VALUE Map_index(VALUE _self, VALUE key) { + Map* self = ruby_to_Map(_self); + upb_MessageValue key_upb = + Convert_RubyToUpb(key, "", Map_keyinfo(self), NULL); + upb_MessageValue val; + + if (upb_Map_Get(self->map, key_upb, &val)) { + return Convert_UpbToRuby(val, self->value_type_info, self->arena); + } else { + return Qnil; + } +} + +/* + * call-seq: + * Map.[]=(key, value) => value + * + * Inserts or overwrites the value at the given key with the given new value. + * Throws an exception if the key type is incorrect. Returns the new value that + * was just inserted. + */ +static VALUE Map_index_set(VALUE _self, VALUE key, VALUE val) { + Map* self = ruby_to_Map(_self); + upb_Arena* arena = Arena_get(self->arena); + upb_MessageValue key_upb = + Convert_RubyToUpb(key, "", Map_keyinfo(self), NULL); + upb_MessageValue val_upb = + Convert_RubyToUpb(val, "", self->value_type_info, arena); + + upb_Map_Set(Map_GetMutable(_self), key_upb, val_upb, arena); + + return val; +} + +/* + * call-seq: + * Map.has_key?(key) => bool + * + * Returns true if the given key is present in the map. Throws an exception if + * the key has the wrong type. + */ +static VALUE Map_has_key(VALUE _self, VALUE key) { + Map* self = ruby_to_Map(_self); + upb_MessageValue key_upb = + Convert_RubyToUpb(key, "", Map_keyinfo(self), NULL); + + if (upb_Map_Get(self->map, key_upb, NULL)) { + return Qtrue; + } else { + return Qfalse; + } +} + +/* + * call-seq: + * Map.delete(key) => old_value + * + * Deletes the value at the given key, if any, returning either the old value or + * nil if none was present. Throws an exception if the key is of the wrong type. + */ +static VALUE Map_delete(VALUE _self, VALUE key) { + Map* self = ruby_to_Map(_self); + rb_check_frozen(_self); + + upb_MessageValue key_upb = + Convert_RubyToUpb(key, "", Map_keyinfo(self), NULL); + upb_MessageValue val_upb; + + if (upb_Map_Delete(Map_GetMutable(_self), key_upb, &val_upb)) { + return Convert_UpbToRuby(val_upb, self->value_type_info, self->arena); + } else { + return Qnil; + } +} + +/* + * call-seq: + * Map.clear + * + * Removes all entries from the map. + */ +static VALUE Map_clear(VALUE _self) { + upb_Map_Clear(Map_GetMutable(_self)); + return Qnil; +} + +/* + * call-seq: + * Map.length + * + * Returns the number of entries (key-value pairs) in the map. + */ +static VALUE Map_length(VALUE _self) { + Map* self = ruby_to_Map(_self); + return ULL2NUM(upb_Map_Size(self->map)); +} + +/* + * call-seq: + * Map.dup => new_map + * + * Duplicates this map with a shallow copy. References to all non-primitive + * element objects (e.g., submessages) are shared. + */ +static VALUE Map_dup(VALUE _self) { + Map* self = ruby_to_Map(_self); + VALUE new_map_rb = Map_new_this_type(self); + Map* new_self = ruby_to_Map(new_map_rb); + size_t iter = kUpb_Map_Begin; + upb_Arena* arena = Arena_get(new_self->arena); + upb_Map* new_map = Map_GetMutable(new_map_rb); + + Arena_fuse(self->arena, arena); + + upb_MessageValue key, val; + while (upb_Map_Next(self->map, &key, &val, &iter)) { + upb_Map_Set(new_map, key, val, arena); + } + + return new_map_rb; +} + +/* + * call-seq: + * Map.==(other) => boolean + * + * Compares this map to another. Maps are equal if they have identical key sets, + * and for each key, the values in both maps compare equal. Elements are + * compared as per normal Ruby semantics, by calling their :== methods (or + * performing a more efficient comparison for primitive types). + * + * Maps with dissimilar key types or value types/typeclasses are never equal, + * even if value comparison (for example, between integers and floats) would + * have otherwise indicated that every element has equal value. + */ +VALUE Map_eq(VALUE _self, VALUE _other) { + Map* self = ruby_to_Map(_self); + Map* other; + + // Allow comparisons to Ruby hashmaps by converting to a temporary Map + // instance. Slow, but workable. + if (TYPE(_other) == T_HASH) { + VALUE other_map = Map_new_this_type(self); + Map_merge_into_self(other_map, _other); + _other = other_map; + } + + other = ruby_to_Map(_other); + + if (self == other) { + return Qtrue; + } + if (self->key_type != other->key_type || + self->value_type_info.type != other->value_type_info.type || + self->value_type_class != other->value_type_class) { + return Qfalse; + } + if (upb_Map_Size(self->map) != upb_Map_Size(other->map)) { + return Qfalse; + } + + // For each member of self, check that an equal member exists at the same key + // in other. + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + while (upb_Map_Next(self->map, &key, &val, &iter)) { + upb_MessageValue other_val; + if (!upb_Map_Get(other->map, key, &other_val)) { + // Not present in other map. + return Qfalse; + } + if (!Msgval_IsEqual(val, other_val, self->value_type_info)) { + // Present but different value. + return Qfalse; + } + } + + return Qtrue; +} + +/* + * call-seq: + * Message.freeze => self + * + * Freezes the message object. We have to intercept this so we can pin the + * Ruby object into memory so we don't forget it's frozen. + */ +VALUE Map_freeze(VALUE _self) { + Map* self = ruby_to_Map(_self); + + if (RB_OBJ_FROZEN(_self)) return _self; + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + + if (self->value_type_info.type == kUpb_CType_Message) { + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + + while (upb_Map_Next(self->map, &key, &val, &iter)) { + VALUE val_val = + Convert_UpbToRuby(val, self->value_type_info, self->arena); + Message_freeze(val_val); + } + } + return _self; +} + +/* + * call-seq: + * Map.hash => hash_value + * + * Returns a hash value based on this map's contents. + */ +VALUE Map_hash(VALUE _self) { + Map* self = ruby_to_Map(_self); + uint64_t hash = 0; + + size_t iter = kUpb_Map_Begin; + TypeInfo key_info = {self->key_type}; + upb_MessageValue key, val; + while (upb_Map_Next(self->map, &key, &val, &iter)) { + hash = Msgval_GetHash(key, key_info, hash); + hash = Msgval_GetHash(val, self->value_type_info, hash); + } + + return LL2NUM(hash); +} + +/* + * call-seq: + * Map.to_h => {} + * + * Returns a Ruby Hash object containing all the values within the map + */ +VALUE Map_to_h(VALUE _self) { + Map* self = ruby_to_Map(_self); + return Map_CreateHash(self->map, self->key_type, self->value_type_info); +} + +/* + * call-seq: + * Map.inspect => string + * + * Returns a string representing this map's elements. It will be formatted as + * "{key => value, key => value, ...}", with each key and value string + * representation computed by its own #inspect method. + */ +VALUE Map_inspect(VALUE _self) { + Map* self = ruby_to_Map(_self); + + StringBuilder* builder = StringBuilder_New(); + Map_Inspect(builder, self->map, self->key_type, self->value_type_info); + VALUE ret = StringBuilder_ToRubyString(builder); + StringBuilder_Free(builder); + return ret; +} + +/* + * call-seq: + * Map.merge(other_map) => map + * + * Copies key/value pairs from other_map into a copy of this map. If a key is + * set in other_map and this map, the value from other_map overwrites the value + * in the new copy of this map. Returns the new copy of this map with merged + * contents. + */ +static VALUE Map_merge(VALUE _self, VALUE hashmap) { + VALUE dupped = Map_dup(_self); + return Map_merge_into_self(dupped, hashmap); +} + +void Map_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "Map", rb_cObject); + rb_define_alloc_func(klass, Map_alloc); + rb_gc_register_address(&cMap); + cMap = klass; + + rb_define_method(klass, "initialize", Map_init, -1); + rb_define_method(klass, "each", Map_each, 0); + rb_define_method(klass, "keys", Map_keys, 0); + rb_define_method(klass, "values", Map_values, 0); + rb_define_method(klass, "[]", Map_index, 1); + rb_define_method(klass, "[]=", Map_index_set, 2); + rb_define_method(klass, "has_key?", Map_has_key, 1); + rb_define_method(klass, "delete", Map_delete, 1); + rb_define_method(klass, "clear", Map_clear, 0); + rb_define_method(klass, "length", Map_length, 0); + rb_define_method(klass, "size", Map_length, 0); + rb_define_method(klass, "dup", Map_dup, 0); + // Also define #clone so that we don't inherit Object#clone. + rb_define_method(klass, "clone", Map_dup, 0); + rb_define_method(klass, "==", Map_eq, 1); + rb_define_method(klass, "freeze", Map_freeze, 0); + rb_define_method(klass, "hash", Map_hash, 0); + rb_define_method(klass, "to_h", Map_to_h, 0); + rb_define_method(klass, "inspect", Map_inspect, 0); + rb_define_method(klass, "merge", Map_merge, 1); + rb_include_module(klass, rb_mEnumerable); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/map.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/map.h new file mode 100755 index 0000000..cb4041d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/map.h @@ -0,0 +1,44 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef RUBY_PROTOBUF_MAP_H_ +#define RUBY_PROTOBUF_MAP_H_ + +#include "protobuf.h" +#include "ruby-upb.h" + +// Returns a Ruby wrapper object for the given map, which will be created if +// one does not exist already. +VALUE Map_GetRubyWrapper(upb_Map *map, upb_CType key_type, TypeInfo value_type, + VALUE arena); + +// Gets the underlying upb_Map for this Ruby map object, which must have +// key/value type that match |field|. If this is not a map or the type doesn't +// match, raises an exception. +const upb_Map *Map_GetUpbMap(VALUE val, const upb_FieldDef *field, + upb_Arena *arena); + +// Implements #inspect for this map by appending its contents to |b|. +void Map_Inspect(StringBuilder *b, const upb_Map *map, upb_CType key_type, + TypeInfo val_type); + +// Returns a new Hash object containing the contents of this Map. +VALUE Map_CreateHash(const upb_Map *map, upb_CType key_type, TypeInfo val_info); + +// Returns a deep copy of this Map object. +VALUE Map_deep_copy(VALUE obj); + +// Ruby class of Google::Protobuf::Map. +extern VALUE cMap; + +// Call at startup to register all types in this module. +void Map_register(VALUE module); + +// Recursively freeze map +VALUE Map_freeze(VALUE _self); + +#endif // RUBY_PROTOBUF_MAP_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/message.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/message.c new file mode 100755 index 0000000..706e3df --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/message.c @@ -0,0 +1,1379 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2014 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#include "message.h" + +#include "convert.h" +#include "defs.h" +#include "map.h" +#include "protobuf.h" +#include "repeated_field.h" +#include "shared_message.h" + +static VALUE cParseError = Qnil; +static VALUE cAbstractMessage = Qnil; +static ID descriptor_instancevar_interned; + +static VALUE initialize_rb_class_with_no_args(VALUE klass) { + return rb_funcall(klass, rb_intern("new"), 0); +} + +VALUE MessageOrEnum_GetDescriptor(VALUE klass) { + return rb_ivar_get(klass, descriptor_instancevar_interned); +} + +// ----------------------------------------------------------------------------- +// Class/module creation from msgdefs and enumdefs, respectively. +// ----------------------------------------------------------------------------- + +typedef struct { + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE arena; + const upb_Message* msg; // Can get as mutable when non-frozen. + const upb_MessageDef* + msgdef; // kept alive by self.class.descriptor reference. +} Message; + +static void Message_mark(void* _self) { + Message* self = (Message*)_self; + rb_gc_mark(self->arena); +} + +static size_t Message_memsize(const void* _self) { return sizeof(Message); } + +static rb_data_type_t Message_type = { + "Google::Protobuf::Message", + {Message_mark, RUBY_DEFAULT_FREE, Message_memsize}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static Message* ruby_to_Message(VALUE msg_rb) { + Message* msg; + TypedData_Get_Struct(msg_rb, Message, &Message_type, msg); + return msg; +} + +static VALUE Message_alloc(VALUE klass) { + VALUE descriptor = rb_ivar_get(klass, descriptor_instancevar_interned); + Message* msg = ALLOC(Message); + VALUE ret; + + msg->msgdef = Descriptor_GetMsgDef(descriptor); + msg->arena = Qnil; + msg->msg = NULL; + + ret = TypedData_Wrap_Struct(klass, &Message_type, msg); + rb_ivar_set(ret, descriptor_instancevar_interned, descriptor); + + return ret; +} + +const upb_Message* Message_Get(VALUE msg_rb, const upb_MessageDef** m) { + Message* msg = ruby_to_Message(msg_rb); + if (m) *m = msg->msgdef; + return msg->msg; +} + +upb_Message* Message_GetMutable(VALUE msg_rb, const upb_MessageDef** m) { + rb_check_frozen(msg_rb); + return (upb_Message*)Message_Get(msg_rb, m); +} + +void Message_InitPtr(VALUE self_, upb_Message* msg, VALUE arena) { + Message* self = ruby_to_Message(self_); + self->msg = msg; + RB_OBJ_WRITE(self_, &self->arena, arena); + VALUE stored = ObjectCache_TryAdd(msg, self_); + (void)stored; + PBRUBY_ASSERT(stored == self_); +} + +VALUE Message_GetArena(VALUE msg_rb) { + Message* msg = ruby_to_Message(msg_rb); + return msg->arena; +} + +void Message_CheckClass(VALUE klass) { + if (rb_get_alloc_func(klass) != &Message_alloc) { + rb_raise(rb_eArgError, + "Message class was not returned by the DescriptorPool."); + } +} + +VALUE Message_GetRubyWrapper(upb_Message* msg, const upb_MessageDef* m, + VALUE arena) { + if (msg == NULL) return Qnil; + + VALUE val = ObjectCache_Get(msg); + + if (val == Qnil) { + VALUE klass = Descriptor_DefToClass(m); + val = Message_alloc(klass); + Message_InitPtr(val, msg, arena); + } + + return val; +} + +void Message_PrintMessage(StringBuilder* b, const upb_Message* msg, + const upb_MessageDef* m) { + bool first = true; + int n = upb_MessageDef_FieldCount(m); + VALUE klass = Descriptor_DefToClass(m); + StringBuilder_Printf(b, "<%s: ", rb_class2name(klass)); + + for (int i = 0; i < n; i++) { + const upb_FieldDef* field = upb_MessageDef_Field(m, i); + + if (upb_FieldDef_HasPresence(field) && + !upb_Message_HasFieldByDef(msg, field)) { + continue; + } + + if (!first) { + StringBuilder_Printf(b, ", "); + } else { + first = false; + } + + upb_MessageValue msgval = upb_Message_GetFieldByDef(msg, field); + + StringBuilder_Printf(b, "%s: ", upb_FieldDef_Name(field)); + + if (upb_FieldDef_IsMap(field)) { + const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field); + const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1); + const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2); + TypeInfo val_info = TypeInfo_get(val_f); + Map_Inspect(b, msgval.map_val, upb_FieldDef_CType(key_f), val_info); + } else if (upb_FieldDef_IsRepeated(field)) { + RepeatedField_Inspect(b, msgval.array_val, TypeInfo_get(field)); + } else { + StringBuilder_PrintMsgval(b, msgval, TypeInfo_get(field)); + } + } + + StringBuilder_Printf(b, ">"); +} + +// Helper functions for #method_missing //////////////////////////////////////// + +enum { + METHOD_UNKNOWN = 0, + METHOD_GETTER = 1, + METHOD_SETTER = 2, + METHOD_CLEAR = 3, + METHOD_PRESENCE = 4, + METHOD_ENUM_GETTER = 5, + METHOD_WRAPPER_GETTER = 6, + METHOD_WRAPPER_SETTER = 7 +}; + +// Check if the field is a well known wrapper type +static bool IsWrapper(const upb_MessageDef* m) { + if (!m) return false; + switch (upb_MessageDef_WellKnownType(m)) { + case kUpb_WellKnown_DoubleValue: + case kUpb_WellKnown_FloatValue: + case kUpb_WellKnown_Int64Value: + case kUpb_WellKnown_UInt64Value: + case kUpb_WellKnown_Int32Value: + case kUpb_WellKnown_UInt32Value: + case kUpb_WellKnown_StringValue: + case kUpb_WellKnown_BytesValue: + case kUpb_WellKnown_BoolValue: + return true; + default: + return false; + } +} + +static bool IsFieldWrapper(const upb_FieldDef* f) { + return IsWrapper(upb_FieldDef_MessageSubDef(f)); +} + +static bool Match(const upb_MessageDef* m, const char* name, + const upb_FieldDef** f, const upb_OneofDef** o, + const char* prefix, const char* suffix) { + size_t sp = strlen(prefix); + size_t ss = strlen(suffix); + size_t sn = strlen(name); + + if (sn <= sp + ss) return false; + + if (memcmp(name, prefix, sp) != 0 || + memcmp(name + sn - ss, suffix, ss) != 0) { + return false; + } + + return upb_MessageDef_FindByNameWithSize(m, name + sp, sn - sp - ss, f, o); +} + +static int extract_method_call(VALUE method_name, Message* self, + const upb_FieldDef** f, const upb_OneofDef** o) { + const upb_MessageDef* m = self->msgdef; + const char* name; + + Check_Type(method_name, T_SYMBOL); + name = rb_id2name(SYM2ID(method_name)); + + if (Match(m, name, f, o, "", "")) return METHOD_GETTER; + if (Match(m, name, f, o, "", "=")) return METHOD_SETTER; + if (Match(m, name, f, o, "clear_", "")) return METHOD_CLEAR; + if (Match(m, name, f, o, "has_", "?") && + (*o || (*f && upb_FieldDef_HasPresence(*f)))) { + return METHOD_PRESENCE; + } + if (Match(m, name, f, o, "", "_as_value") && *f && + !upb_FieldDef_IsRepeated(*f) && IsFieldWrapper(*f)) { + return METHOD_WRAPPER_GETTER; + } + if (Match(m, name, f, o, "", "_as_value=") && *f && + !upb_FieldDef_IsRepeated(*f) && IsFieldWrapper(*f)) { + return METHOD_WRAPPER_SETTER; + } + if (Match(m, name, f, o, "", "_const") && *f && + upb_FieldDef_CType(*f) == kUpb_CType_Enum) { + return METHOD_ENUM_GETTER; + } + + return METHOD_UNKNOWN; +} + +static VALUE Message_oneof_accessor(VALUE _self, const upb_OneofDef* o, + int accessor_type) { + Message* self = ruby_to_Message(_self); + const upb_FieldDef* oneof_field = upb_Message_WhichOneof(self->msg, o); + + switch (accessor_type) { + case METHOD_PRESENCE: + return oneof_field == NULL ? Qfalse : Qtrue; + case METHOD_CLEAR: + if (oneof_field != NULL) { + upb_Message_ClearFieldByDef(Message_GetMutable(_self, NULL), + oneof_field); + } + return Qnil; + case METHOD_GETTER: + return oneof_field == NULL + ? Qnil + : ID2SYM(rb_intern(upb_FieldDef_Name(oneof_field))); + case METHOD_SETTER: + rb_raise(rb_eRuntimeError, "Oneof accessors are read-only."); + } + rb_raise(rb_eRuntimeError, "Invalid access of oneof field."); +} + +static void Message_setfield(upb_Message* msg, const upb_FieldDef* f, VALUE val, + upb_Arena* arena) { + upb_MessageValue msgval; + if (upb_FieldDef_IsMap(f)) { + msgval.map_val = Map_GetUpbMap(val, f, arena); + } else if (upb_FieldDef_IsRepeated(f)) { + msgval.array_val = RepeatedField_GetUpbArray(val, f, arena); + } else { + if (val == Qnil && + (upb_FieldDef_IsSubMessage(f) || upb_FieldDef_RealContainingOneof(f))) { + upb_Message_ClearFieldByDef(msg, f); + return; + } + msgval = + Convert_RubyToUpb(val, upb_FieldDef_Name(f), TypeInfo_get(f), arena); + } + upb_Message_SetFieldByDef(msg, f, msgval, arena); +} + +VALUE Message_getfield(VALUE _self, const upb_FieldDef* f) { + Message* self = ruby_to_Message(_self); + // This is a special-case: upb_Message_Mutable() for map & array are logically + // const (they will not change what is serialized) but physically + // non-const, as they do allocate a repeated field or map. The logical + // constness means it's ok to do even if the message is frozen. + upb_Message* msg = (upb_Message*)self->msg; + upb_Arena* arena = Arena_get(self->arena); + if (upb_FieldDef_IsMap(f)) { + upb_Map* map = upb_Message_Mutable(msg, f, arena).map; + const upb_FieldDef* key_f = map_field_key(f); + const upb_FieldDef* val_f = map_field_value(f); + upb_CType key_type = upb_FieldDef_CType(key_f); + TypeInfo value_type_info = TypeInfo_get(val_f); + return Map_GetRubyWrapper(map, key_type, value_type_info, self->arena); + } else if (upb_FieldDef_IsRepeated(f)) { + upb_Array* arr = upb_Message_Mutable(msg, f, arena).array; + return RepeatedField_GetRubyWrapper(arr, TypeInfo_get(f), self->arena); + } else if (upb_FieldDef_IsSubMessage(f)) { + if (!upb_Message_HasFieldByDef(self->msg, f)) return Qnil; + upb_Message* submsg = upb_Message_Mutable(msg, f, arena).msg; + const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f); + return Message_GetRubyWrapper(submsg, m, self->arena); + } else { + upb_MessageValue msgval = upb_Message_GetFieldByDef(self->msg, f); + return Convert_UpbToRuby(msgval, TypeInfo_get(f), self->arena); + } +} + +static VALUE Message_field_accessor(VALUE _self, const upb_FieldDef* f, + int accessor_type, int argc, VALUE* argv) { + upb_Arena* arena = Arena_get(Message_GetArena(_self)); + + switch (accessor_type) { + case METHOD_SETTER: + Message_setfield(Message_GetMutable(_self, NULL), f, argv[1], arena); + return Qnil; + case METHOD_CLEAR: + upb_Message_ClearFieldByDef(Message_GetMutable(_self, NULL), f); + return Qnil; + case METHOD_PRESENCE: + if (!upb_FieldDef_HasPresence(f)) { + rb_raise(rb_eRuntimeError, "Field does not have presence."); + } + return upb_Message_HasFieldByDef(Message_Get(_self, NULL), f); + case METHOD_WRAPPER_GETTER: { + Message* self = ruby_to_Message(_self); + if (upb_Message_HasFieldByDef(self->msg, f)) { + PBRUBY_ASSERT(upb_FieldDef_IsSubMessage(f) && + !upb_FieldDef_IsRepeated(f)); + upb_MessageValue wrapper = upb_Message_GetFieldByDef(self->msg, f); + const upb_MessageDef* wrapper_m = upb_FieldDef_MessageSubDef(f); + const upb_FieldDef* value_f = + upb_MessageDef_FindFieldByNumber(wrapper_m, 1); + upb_MessageValue value = + upb_Message_GetFieldByDef(wrapper.msg_val, value_f); + return Convert_UpbToRuby(value, TypeInfo_get(value_f), self->arena); + } else { + return Qnil; + } + } + case METHOD_WRAPPER_SETTER: { + upb_Message* msg = Message_GetMutable(_self, NULL); + if (argv[1] == Qnil) { + upb_Message_ClearFieldByDef(msg, f); + } else { + const upb_FieldDef* val_f = + upb_MessageDef_FindFieldByNumber(upb_FieldDef_MessageSubDef(f), 1); + upb_MessageValue msgval = Convert_RubyToUpb( + argv[1], upb_FieldDef_Name(f), TypeInfo_get(val_f), arena); + upb_Message* wrapper = upb_Message_Mutable(msg, f, arena).msg; + upb_Message_SetFieldByDef(wrapper, val_f, msgval, arena); + } + return Qnil; + } + case METHOD_ENUM_GETTER: { + upb_MessageValue msgval = + upb_Message_GetFieldByDef(Message_Get(_self, NULL), f); + + if (upb_FieldDef_Label(f) == kUpb_Label_Repeated) { + // Map repeated fields to a new type with ints + VALUE arr = rb_ary_new(); + size_t i, n = upb_Array_Size(msgval.array_val); + for (i = 0; i < n; i++) { + upb_MessageValue elem = upb_Array_Get(msgval.array_val, i); + rb_ary_push(arr, INT2NUM(elem.int32_val)); + } + return arr; + } else { + return INT2NUM(msgval.int32_val); + } + } + case METHOD_GETTER: + return Message_getfield(_self, f); + default: + rb_raise(rb_eRuntimeError, "Internal error, no such accessor: %d", + accessor_type); + } +} + +/* + * call-seq: + * Message.method_missing(*args) + * + * Provides accessors and setters and methods to clear and check for presence of + * message fields according to their field names. + * + * For any field whose name does not conflict with a built-in method, an + * accessor is provided with the same name as the field, and a setter is + * provided with the name of the field plus the '=' suffix. Thus, given a + * message instance 'msg' with field 'foo', the following code is valid: + * + * msg.foo = 42 + * puts msg.foo + * + * This method also provides read-only accessors for oneofs. If a oneof exists + * with name 'my_oneof', then msg.my_oneof will return a Ruby symbol equal to + * the name of the field in that oneof that is currently set, or nil if none. + * + * It also provides methods of the form 'clear_fieldname' to clear the value + * of the field 'fieldname'. For basic data types, this will set the default + * value of the field. + * + * Additionally, it provides methods of the form 'has_fieldname?', which returns + * true if the field 'fieldname' is set in the message object, else false. For + * 'proto3' syntax, calling this for a basic type field will result in an error. + */ +static VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) { + Message* self = ruby_to_Message(_self); + const upb_OneofDef* o; + const upb_FieldDef* f; + int accessor_type; + + if (argc < 1) { + rb_raise(rb_eArgError, "Expected method name as first argument."); + } + + accessor_type = extract_method_call(argv[0], self, &f, &o); + + if (accessor_type == METHOD_UNKNOWN) return rb_call_super(argc, argv); + + // Validate argument count. + switch (accessor_type) { + case METHOD_SETTER: + case METHOD_WRAPPER_SETTER: + if (argc != 2) { + rb_raise(rb_eArgError, "Expected 2 arguments, received %d", argc); + } + rb_check_frozen(_self); + break; + default: + if (argc != 1) { + rb_raise(rb_eArgError, "Expected 1 argument, received %d", argc); + } + break; + } + + // Dispatch accessor. + if (o != NULL) { + return Message_oneof_accessor(_self, o, accessor_type); + } else { + return Message_field_accessor(_self, f, accessor_type, argc, argv); + } +} + +static VALUE Message_respond_to_missing(int argc, VALUE* argv, VALUE _self) { + Message* self = ruby_to_Message(_self); + const upb_OneofDef* o; + const upb_FieldDef* f; + int accessor_type; + + if (argc < 1) { + rb_raise(rb_eArgError, "Expected method name as first argument."); + } + + accessor_type = extract_method_call(argv[0], self, &f, &o); + + if (accessor_type == METHOD_UNKNOWN) { + return rb_call_super(argc, argv); + } else if (o != NULL) { + return accessor_type == METHOD_SETTER ? Qfalse : Qtrue; + } else { + return Qtrue; + } +} + +void Message_InitFromValue(upb_Message* msg, const upb_MessageDef* m, VALUE val, + upb_Arena* arena); + +typedef struct { + upb_Map* map; + TypeInfo key_type; + TypeInfo val_type; + upb_Arena* arena; +} MapInit; + +static int Map_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { + MapInit* map_init = (MapInit*)_self; + upb_MessageValue k, v; + k = Convert_RubyToUpb(key, "", map_init->key_type, NULL); + + if (map_init->val_type.type == kUpb_CType_Message && TYPE(val) == T_HASH) { + const upb_MiniTable* t = + upb_MessageDef_MiniTable(map_init->val_type.def.msgdef); + upb_Message* msg = upb_Message_New(t, map_init->arena); + Message_InitFromValue(msg, map_init->val_type.def.msgdef, val, + map_init->arena); + v.msg_val = msg; + } else { + v = Convert_RubyToUpb(val, "", map_init->val_type, map_init->arena); + } + upb_Map_Set(map_init->map, k, v, map_init->arena); + return ST_CONTINUE; +} + +static void Map_InitFromValue(upb_Map* map, const upb_FieldDef* f, VALUE val, + upb_Arena* arena) { + const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f); + const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1); + const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2); + if (TYPE(val) != T_HASH) { + rb_raise(rb_eArgError, + "Expected Hash object as initializer value for map field '%s' " + "(given %s).", + upb_FieldDef_Name(f), rb_class2name(CLASS_OF(val))); + } + MapInit map_init = {map, TypeInfo_get(key_f), TypeInfo_get(val_f), arena}; + rb_hash_foreach(val, Map_initialize_kwarg, (VALUE)&map_init); +} + +static upb_MessageValue MessageValue_FromValue(VALUE val, TypeInfo info, + upb_Arena* arena) { + if (info.type == kUpb_CType_Message) { + upb_MessageValue msgval; + const upb_MiniTable* t = upb_MessageDef_MiniTable(info.def.msgdef); + upb_Message* msg = upb_Message_New(t, arena); + Message_InitFromValue(msg, info.def.msgdef, val, arena); + msgval.msg_val = msg; + return msgval; + } else { + return Convert_RubyToUpb(val, "", info, arena); + } +} + +static void RepeatedField_InitFromValue(upb_Array* arr, const upb_FieldDef* f, + VALUE val, upb_Arena* arena) { + TypeInfo type_info = TypeInfo_get(f); + + if (TYPE(val) != T_ARRAY) { + rb_raise(rb_eArgError, + "Expected array as initializer value for repeated field '%s' " + "(given %s).", + upb_FieldDef_Name(f), rb_class2name(CLASS_OF(val))); + } + + for (int i = 0; i < RARRAY_LEN(val); i++) { + VALUE entry = rb_ary_entry(val, i); + upb_MessageValue msgval; + if (upb_FieldDef_IsSubMessage(f) && TYPE(entry) == T_HASH) { + msgval = MessageValue_FromValue(entry, type_info, arena); + } else { + msgval = Convert_RubyToUpb(entry, upb_FieldDef_Name(f), type_info, arena); + } + upb_Array_Append(arr, msgval, arena); + } +} + +static void Message_InitFieldFromValue(upb_Message* msg, const upb_FieldDef* f, + VALUE val, upb_Arena* arena) { + if (TYPE(val) == T_NIL) return; + + if (upb_FieldDef_IsMap(f)) { + upb_Map* map = upb_Message_Mutable(msg, f, arena).map; + Map_InitFromValue(map, f, val, arena); + } else if (upb_FieldDef_Label(f) == kUpb_Label_Repeated) { + upb_Array* arr = upb_Message_Mutable(msg, f, arena).array; + RepeatedField_InitFromValue(arr, f, val, arena); + } else if (upb_FieldDef_IsSubMessage(f)) { + if (TYPE(val) == T_HASH) { + upb_Message* submsg = upb_Message_Mutable(msg, f, arena).msg; + Message_InitFromValue(submsg, upb_FieldDef_MessageSubDef(f), val, arena); + } else { + Message_setfield(msg, f, val, arena); + } + } else { + upb_MessageValue msgval = + Convert_RubyToUpb(val, upb_FieldDef_Name(f), TypeInfo_get(f), arena); + upb_Message_SetFieldByDef(msg, f, msgval, arena); + } +} + +typedef struct { + upb_Message* msg; + const upb_MessageDef* msgdef; + upb_Arena* arena; +} MsgInit; + +static int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { + MsgInit* msg_init = (MsgInit*)_self; + const char* name; + + if (TYPE(key) == T_STRING) { + name = RSTRING_PTR(key); + } else if (TYPE(key) == T_SYMBOL) { + name = RSTRING_PTR(rb_id2str(SYM2ID(key))); + } else { + rb_raise(rb_eArgError, + "Expected string or symbols as hash keys when initializing proto " + "from hash."); + } + + const upb_FieldDef* f = + upb_MessageDef_FindFieldByName(msg_init->msgdef, name); + + if (f == NULL) { + rb_raise(rb_eArgError, + "Unknown field name '%s' in initialization map entry.", name); + } + + Message_InitFieldFromValue(msg_init->msg, f, val, msg_init->arena); + return ST_CONTINUE; +} + +void Message_InitFromValue(upb_Message* msg, const upb_MessageDef* m, VALUE val, + upb_Arena* arena) { + MsgInit msg_init = {msg, m, arena}; + if (TYPE(val) == T_HASH) { + rb_hash_foreach(val, Message_initialize_kwarg, (VALUE)&msg_init); + } else { + rb_raise(rb_eArgError, "Expected hash arguments or message, not %s", + rb_class2name(CLASS_OF(val))); + } +} + +/* + * call-seq: + * Message.new(kwargs) => new_message + * + * Creates a new instance of the given message class. Keyword arguments may be + * provided with keywords corresponding to field names. + * + * Note that no literal Message class exists. Only concrete classes per message + * type exist, as provided by the #msgclass method on Descriptors after they + * have been added to a pool. The method definitions described here on the + * Message class are provided on each concrete message class. + */ +static VALUE Message_initialize(int argc, VALUE* argv, VALUE _self) { + Message* self = ruby_to_Message(_self); + VALUE arena_rb = Arena_new(); + upb_Arena* arena = Arena_get(arena_rb); + const upb_MiniTable* t = upb_MessageDef_MiniTable(self->msgdef); + upb_Message* msg = upb_Message_New(t, arena); + + Message_InitPtr(_self, msg, arena_rb); + + if (argc == 0) { + return Qnil; + } + if (argc != 1) { + rb_raise(rb_eArgError, "Expected 0 or 1 arguments."); + } + Message_InitFromValue((upb_Message*)self->msg, self->msgdef, argv[0], arena); + return Qnil; +} + +/* + * call-seq: + * Message.dup => new_message + * + * Performs a shallow copy of this message and returns the new copy. + */ +static VALUE Message_dup(VALUE _self) { + Message* self = ruby_to_Message(_self); + VALUE new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self)); + Message* new_msg_self = ruby_to_Message(new_msg); + const upb_MiniTable* m = upb_MessageDef_MiniTable(self->msgdef); + upb_Message_ShallowCopy((upb_Message*)new_msg_self->msg, self->msg, m); + Arena_fuse(self->arena, Arena_get(new_msg_self->arena)); + return new_msg; +} + +/* + * call-seq: + * Message.==(other) => boolean + * + * Performs a deep comparison of this message with another. Messages are equal + * if they have the same type and if each field is equal according to the :== + * method's semantics (a more efficient comparison may actually be done if the + * field is of a primitive type). + */ +static VALUE Message_eq(VALUE _self, VALUE _other) { + if (CLASS_OF(_self) != CLASS_OF(_other)) return Qfalse; + + Message* self = ruby_to_Message(_self); + Message* other = ruby_to_Message(_other); + assert(self->msgdef == other->msgdef); + + const upb_MiniTable* m = upb_MessageDef_MiniTable(self->msgdef); + const int options = 0; + return upb_Message_IsEqual(self->msg, other->msg, m, options) ? Qtrue + : Qfalse; +} + +uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m, + uint64_t seed) { + upb_Status status; + upb_Status_Clear(&status); + uint64_t return_value = shared_Message_Hash(msg, m, seed, &status); + if (upb_Status_IsOk(&status)) { + return return_value; + } else { + rb_raise(cParseError, "Message_Hash(): %s", + upb_Status_ErrorMessage(&status)); + } +} + +/* + * call-seq: + * Message.hash => hash_value + * + * Returns a hash value that represents this message's field values. + */ +static VALUE Message_hash(VALUE _self) { + Message* self = ruby_to_Message(_self); + uint64_t hash_value = Message_Hash(self->msg, self->msgdef, 0); + // RUBY_FIXNUM_MAX should be one less than a power of 2. + assert((RUBY_FIXNUM_MAX & (RUBY_FIXNUM_MAX + 1)) == 0); + return INT2FIX(hash_value & RUBY_FIXNUM_MAX); +} + +/* + * call-seq: + * Message.inspect => string + * + * Returns a human-readable string representing this message. It will be + * formatted as "". Each + * field's value is represented according to its own #inspect method. + */ +static VALUE Message_inspect(VALUE _self) { + Message* self = ruby_to_Message(_self); + + StringBuilder* builder = StringBuilder_New(); + Message_PrintMessage(builder, self->msg, self->msgdef); + VALUE ret = StringBuilder_ToRubyString(builder); + StringBuilder_Free(builder); + return ret; +} + +// Support functions for Message_to_h ////////////////////////////////////////// + +static VALUE RepeatedField_CreateArray(const upb_Array* arr, + TypeInfo type_info) { + int size = arr ? upb_Array_Size(arr) : 0; + VALUE ary = rb_ary_new2(size); + + for (int i = 0; i < size; i++) { + upb_MessageValue msgval = upb_Array_Get(arr, i); + VALUE val = Scalar_CreateHash(msgval, type_info); + rb_ary_push(ary, val); + } + + return ary; +} + +static VALUE Message_CreateHash(const upb_Message* msg, + const upb_MessageDef* m) { + if (!msg) return Qnil; + + VALUE hash = rb_hash_new(); + size_t iter = kUpb_Message_Begin; + const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(m)); + const upb_FieldDef* field; + upb_MessageValue val; + + while (upb_Message_Next(msg, m, pool, &field, &val, &iter)) { + if (upb_FieldDef_IsExtension(field)) { + // TODO: allow extensions once we have decided what naming scheme the + // symbol should use. eg. :"[pkg.ext]" + continue; + } + + TypeInfo type_info = TypeInfo_get(field); + VALUE msg_value; + + if (upb_FieldDef_IsMap(field)) { + const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field); + const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1); + const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2); + upb_CType key_type = upb_FieldDef_CType(key_f); + msg_value = Map_CreateHash(val.map_val, key_type, TypeInfo_get(val_f)); + } else if (upb_FieldDef_IsRepeated(field)) { + msg_value = RepeatedField_CreateArray(val.array_val, type_info); + } else { + msg_value = Scalar_CreateHash(val, type_info); + } + + VALUE msg_key = ID2SYM(rb_intern(upb_FieldDef_Name(field))); + rb_hash_aset(hash, msg_key, msg_value); + } + + return hash; +} + +VALUE Scalar_CreateHash(upb_MessageValue msgval, TypeInfo type_info) { + if (type_info.type == kUpb_CType_Message) { + return Message_CreateHash(msgval.msg_val, type_info.def.msgdef); + } else { + return Convert_UpbToRuby(msgval, type_info, Qnil); + } +} + +/* + * call-seq: + * Message.to_h => {} + * + * Returns the message as a Ruby Hash object, with keys as symbols. + */ +static VALUE Message_to_h(VALUE _self) { + Message* self = ruby_to_Message(_self); + return Message_CreateHash(self->msg, self->msgdef); +} + +/* + * call-seq: + * Message.freeze => self + * + * Freezes the message object. We have to intercept this so we can pin the + * Ruby object into memory so we don't forget it's frozen. + */ +VALUE Message_freeze(VALUE _self) { + Message* self = ruby_to_Message(_self); + + if (RB_OBJ_FROZEN(_self)) return _self; + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + + int n = upb_MessageDef_FieldCount(self->msgdef); + for (int i = 0; i < n; i++) { + const upb_FieldDef* f = upb_MessageDef_Field(self->msgdef, i); + VALUE field = Message_getfield(_self, f); + + if (field != Qnil) { + if (upb_FieldDef_IsMap(f)) { + Map_freeze(field); + } else if (upb_FieldDef_IsRepeated(f)) { + RepeatedField_freeze(field); + } else if (upb_FieldDef_IsSubMessage(f)) { + Message_freeze(field); + } + } + } + return _self; +} + +/* + * call-seq: + * Message.[](index) => value + * + * Accesses a field's value by field name. The provided field name should be a + * string. + */ +static VALUE Message_index(VALUE _self, VALUE field_name) { + Message* self = ruby_to_Message(_self); + const upb_FieldDef* field; + + Check_Type(field_name, T_STRING); + field = upb_MessageDef_FindFieldByName(self->msgdef, RSTRING_PTR(field_name)); + + if (field == NULL) { + return Qnil; + } + + return Message_getfield(_self, field); +} + +/* + * call-seq: + * Message.[]=(index, value) + * + * Sets a field's value by field name. The provided field name should be a + * string. + */ +static VALUE Message_index_set(VALUE _self, VALUE field_name, VALUE value) { + Message* self = ruby_to_Message(_self); + const upb_FieldDef* f; + upb_MessageValue val; + upb_Arena* arena = Arena_get(self->arena); + + Check_Type(field_name, T_STRING); + f = upb_MessageDef_FindFieldByName(self->msgdef, RSTRING_PTR(field_name)); + + if (f == NULL) { + rb_raise(rb_eArgError, "Unknown field: %s", RSTRING_PTR(field_name)); + } + + val = Convert_RubyToUpb(value, upb_FieldDef_Name(f), TypeInfo_get(f), arena); + upb_Message_SetFieldByDef(Message_GetMutable(_self, NULL), f, val, arena); + + return Qnil; +} + +/* + * call-seq: + * MessageClass.decode(data, options) => message + * + * Decodes the given data (as a string containing bytes in protocol buffers wire + * format) under the interpretation given by this message class's definition + * and returns a message object with the corresponding field values. + * @param options [Hash] options for the decoder + * recursion_limit: set to maximum decoding depth for message (default is 64) + */ +static VALUE Message_decode(int argc, VALUE* argv, VALUE klass) { + VALUE data = argv[0]; + int options = 0; + + if (argc < 1 || argc > 2) { + rb_raise(rb_eArgError, "Expected 1 or 2 arguments."); + } + + if (argc == 2) { + VALUE hash_args = argv[1]; + if (TYPE(hash_args) != T_HASH) { + rb_raise(rb_eArgError, "Expected hash arguments."); + } + + VALUE depth = + rb_hash_lookup(hash_args, ID2SYM(rb_intern("recursion_limit"))); + + if (depth != Qnil && TYPE(depth) == T_FIXNUM) { + options |= upb_DecodeOptions_MaxDepth(FIX2INT(depth)); + } + } + + if (TYPE(data) != T_STRING) { + rb_raise(rb_eArgError, "Expected string for binary protobuf data."); + } + + return Message_decode_bytes(RSTRING_LEN(data), RSTRING_PTR(data), options, + klass, /*freeze*/ false); +} + +VALUE Message_decode_bytes(int size, const char* bytes, int options, + VALUE klass, bool freeze) { + VALUE msg_rb = initialize_rb_class_with_no_args(klass); + Message* msg = ruby_to_Message(msg_rb); + + const upb_FileDef* file = upb_MessageDef_File(msg->msgdef); + const upb_ExtensionRegistry* extreg = + upb_DefPool_ExtensionRegistry(upb_FileDef_Pool(file)); + upb_DecodeStatus status = upb_Decode(bytes, size, (upb_Message*)msg->msg, + upb_MessageDef_MiniTable(msg->msgdef), + extreg, options, Arena_get(msg->arena)); + if (status != kUpb_DecodeStatus_Ok) { + rb_raise(cParseError, "Error occurred during parsing"); + } + if (freeze) { + Message_freeze(msg_rb); + } + return msg_rb; +} + +/* + * call-seq: + * MessageClass.decode_json(data, options = {}) => message + * + * Decodes the given data (as a string containing bytes in protocol buffers wire + * format) under the interpretration given by this message class's definition + * and returns a message object with the corresponding field values. + * + * @param options [Hash] options for the decoder + * ignore_unknown_fields: set true to ignore unknown fields (default is to + * raise an error) + */ +static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) { + VALUE data = argv[0]; + int options = 0; + upb_Status status; + + if (argc < 1 || argc > 2) { + rb_raise(rb_eArgError, "Expected 1 or 2 arguments."); + } + + if (argc == 2) { + VALUE hash_args = argv[1]; + if (TYPE(hash_args) != T_HASH) { + rb_raise(rb_eArgError, "Expected hash arguments."); + } + + if (RTEST(rb_hash_lookup2( + hash_args, ID2SYM(rb_intern("ignore_unknown_fields")), Qfalse))) { + options |= upb_JsonDecode_IgnoreUnknown; + } + } + + if (TYPE(data) != T_STRING) { + rb_raise(rb_eArgError, "Expected string for JSON data."); + } + + // TODO: Check and respect string encoding. If not UTF-8, we need to + // convert, because string handlers pass data directly to message string + // fields. + + VALUE msg_rb = initialize_rb_class_with_no_args(klass); + Message* msg = ruby_to_Message(msg_rb); + + // We don't allow users to decode a wrapper type directly. + if (IsWrapper(msg->msgdef)) { + rb_raise(rb_eRuntimeError, "Cannot parse a wrapper directly."); + } + + upb_Status_Clear(&status); + const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(msg->msgdef)); + if (!upb_JsonDecode(RSTRING_PTR(data), RSTRING_LEN(data), + (upb_Message*)msg->msg, msg->msgdef, pool, options, + Arena_get(msg->arena), &status)) { + rb_raise(cParseError, "Error occurred during parsing: %s", + upb_Status_ErrorMessage(&status)); + } + + return msg_rb; +} + +/* + * call-seq: + * MessageClass.encode(msg, options) => bytes + * + * Encodes the given message object to its serialized form in protocol buffers + * wire format. + * @param options [Hash] options for the encoder + * recursion_limit: set to maximum encoding depth for message (default is 64) + */ +static VALUE Message_encode(int argc, VALUE* argv, VALUE klass) { + Message* msg = ruby_to_Message(argv[0]); + int options = 0; + char* data; + size_t size; + + if (CLASS_OF(argv[0]) != klass) { + rb_raise(rb_eArgError, "Message of wrong type."); + } + + if (argc < 1 || argc > 2) { + rb_raise(rb_eArgError, "Expected 1 or 2 arguments."); + } + + if (argc == 2) { + VALUE hash_args = argv[1]; + if (TYPE(hash_args) != T_HASH) { + rb_raise(rb_eArgError, "Expected hash arguments."); + } + VALUE depth = + rb_hash_lookup(hash_args, ID2SYM(rb_intern("recursion_limit"))); + + if (depth != Qnil && TYPE(depth) == T_FIXNUM) { + options |= upb_DecodeOptions_MaxDepth(FIX2INT(depth)); + } + } + + upb_Arena* arena = upb_Arena_New(); + + upb_EncodeStatus status = + upb_Encode(msg->msg, upb_MessageDef_MiniTable(msg->msgdef), options, + arena, &data, &size); + + if (status == kUpb_EncodeStatus_Ok) { + VALUE ret = rb_str_new(data, size); + rb_enc_associate(ret, rb_ascii8bit_encoding()); + upb_Arena_Free(arena); + return ret; + } else { + upb_Arena_Free(arena); + rb_raise(rb_eRuntimeError, "Exceeded maximum depth (possibly cycle)"); + } +} + +/* + * call-seq: + * MessageClass.encode_json(msg, options = {}) => json_string + * + * Encodes the given message object into its serialized JSON representation. + * @param options [Hash] options for the decoder + * preserve_proto_fieldnames: set true to use original fieldnames (default is + * to camelCase) emit_defaults: set true to emit 0/false values (default is to + * omit them) + */ +static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) { + Message* msg = ruby_to_Message(argv[0]); + int options = 0; + char buf[1024]; + size_t size; + upb_Status status; + + if (argc < 1 || argc > 2) { + rb_raise(rb_eArgError, "Expected 1 or 2 arguments."); + } + + if (argc == 2) { + VALUE hash_args = argv[1]; + if (TYPE(hash_args) != T_HASH) { + if (RTEST(rb_funcall(hash_args, rb_intern("respond_to?"), 1, + rb_str_new2("to_h")))) { + hash_args = rb_funcall(hash_args, rb_intern("to_h"), 0); + } else { + rb_raise(rb_eArgError, "Expected hash arguments."); + } + } + + if (RTEST(rb_hash_lookup2(hash_args, + ID2SYM(rb_intern("preserve_proto_fieldnames")), + Qfalse))) { + options |= upb_JsonEncode_UseProtoNames; + } + + if (RTEST(rb_hash_lookup2(hash_args, ID2SYM(rb_intern("emit_defaults")), + Qfalse))) { + options |= upb_JsonEncode_EmitDefaults; + } + + if (RTEST(rb_hash_lookup2(hash_args, + ID2SYM(rb_intern("format_enums_as_integers")), + Qfalse))) { + options |= upb_JsonEncode_FormatEnumsAsIntegers; + } + } + + upb_Status_Clear(&status); + const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(msg->msgdef)); + size = upb_JsonEncode(msg->msg, msg->msgdef, pool, options, buf, sizeof(buf), + &status); + + if (!upb_Status_IsOk(&status)) { + rb_raise(cParseError, "Error occurred during encoding: %s", + upb_Status_ErrorMessage(&status)); + } + + VALUE ret; + if (size >= sizeof(buf)) { + char* buf2 = malloc(size + 1); + upb_JsonEncode(msg->msg, msg->msgdef, pool, options, buf2, size + 1, + &status); + ret = rb_str_new(buf2, size); + free(buf2); + } else { + ret = rb_str_new(buf, size); + } + + rb_enc_associate(ret, rb_utf8_encoding()); + return ret; +} + +/* + * call-seq: + * Message.descriptor => descriptor + * + * Class method that returns the Descriptor instance corresponding to this + * message class's type. + */ +static VALUE Message_descriptor(VALUE klass) { + return rb_ivar_get(klass, descriptor_instancevar_interned); +} + +VALUE build_class_from_descriptor(VALUE descriptor) { + const char* name; + VALUE klass; + + name = upb_MessageDef_FullName(Descriptor_GetMsgDef(descriptor)); + if (name == NULL) { + rb_raise(rb_eRuntimeError, "Descriptor does not have assigned name."); + } + + klass = rb_define_class_id( + // Docs say this parameter is ignored. User will assign return value to + // their own toplevel constant class name. + rb_intern("Message"), cAbstractMessage); + rb_ivar_set(klass, descriptor_instancevar_interned, descriptor); + return klass; +} + +/* + * call-seq: + * Enum.lookup(number) => name + * + * This module method, provided on each generated enum module, looks up an enum + * value by number and returns its name as a Ruby symbol, or nil if not found. + */ +static VALUE enum_lookup(VALUE self, VALUE number) { + int32_t num = NUM2INT(number); + VALUE desc = rb_ivar_get(self, descriptor_instancevar_interned); + const upb_EnumDef* e = EnumDescriptor_GetEnumDef(desc); + const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNumber(e, num); + if (ev) { + return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev))); + } else { + return Qnil; + } +} + +/* + * call-seq: + * Enum.resolve(name) => number + * + * This module method, provided on each generated enum module, looks up an enum + * value by name (as a Ruby symbol) and returns its name, or nil if not found. + */ +static VALUE enum_resolve(VALUE self, VALUE sym) { + const char* name = rb_id2name(SYM2ID(sym)); + VALUE desc = rb_ivar_get(self, descriptor_instancevar_interned); + const upb_EnumDef* e = EnumDescriptor_GetEnumDef(desc); + const upb_EnumValueDef* ev = upb_EnumDef_FindValueByName(e, name); + if (ev) { + return INT2NUM(upb_EnumValueDef_Number(ev)); + } else { + return Qnil; + } +} + +/* + * call-seq: + * Enum.descriptor + * + * This module method, provided on each generated enum module, returns the + * EnumDescriptor corresponding to this enum type. + */ +static VALUE enum_descriptor(VALUE self) { + return rb_ivar_get(self, descriptor_instancevar_interned); +} + +VALUE build_module_from_enumdesc(VALUE _enumdesc) { + const upb_EnumDef* e = EnumDescriptor_GetEnumDef(_enumdesc); + VALUE mod = rb_define_module_id(rb_intern(upb_EnumDef_FullName(e))); + + int n = upb_EnumDef_ValueCount(e); + for (int i = 0; i < n; i++) { + const upb_EnumValueDef* ev = upb_EnumDef_Value(e, i); + upb_Arena* arena = upb_Arena_New(); + const char* src_name = upb_EnumValueDef_Name(ev); + char* name = upb_strdup2(src_name, strlen(src_name), arena); + int32_t value = upb_EnumValueDef_Number(ev); + if (name[0] < 'A' || name[0] > 'Z') { + if (name[0] >= 'a' && name[0] <= 'z') { + name[0] -= 32; // auto capitalize + } else { + rb_warn( + "Enum value '%s' does not start with an uppercase letter " + "as is required for Ruby constants.", + name); + } + } + rb_define_const(mod, name, INT2NUM(value)); + upb_Arena_Free(arena); + } + + rb_define_singleton_method(mod, "lookup", enum_lookup, 1); + rb_define_singleton_method(mod, "resolve", enum_resolve, 1); + rb_define_singleton_method(mod, "descriptor", enum_descriptor, 0); + rb_ivar_set(mod, descriptor_instancevar_interned, _enumdesc); + + return mod; +} + +// Internal to the library; used by Google::Protobuf.deep_copy. +upb_Message* Message_deep_copy(const upb_Message* msg, const upb_MessageDef* m, + upb_Arena* arena) { + // Serialize and parse. + upb_Arena* tmp_arena = upb_Arena_New(); + const upb_MiniTable* layout = upb_MessageDef_MiniTable(m); + size_t size; + + upb_Message* new_msg = upb_Message_New(layout, arena); + char* data; + + const upb_FileDef* file = upb_MessageDef_File(m); + const upb_ExtensionRegistry* extreg = + upb_DefPool_ExtensionRegistry(upb_FileDef_Pool(file)); + if (upb_Encode(msg, layout, 0, tmp_arena, &data, &size) != + kUpb_EncodeStatus_Ok || + upb_Decode(data, size, new_msg, layout, extreg, 0, arena) != + kUpb_DecodeStatus_Ok) { + upb_Arena_Free(tmp_arena); + rb_raise(cParseError, "Error occurred copying proto"); + } + + upb_Arena_Free(tmp_arena); + return new_msg; +} + +const upb_Message* Message_GetUpbMessage(VALUE value, const upb_MessageDef* m, + const char* name, upb_Arena* arena) { + if (value == Qnil) { + rb_raise(cTypeError, "nil message not allowed here."); + } + + VALUE klass = CLASS_OF(value); + VALUE desc_rb = rb_ivar_get(klass, descriptor_instancevar_interned); + const upb_MessageDef* val_m = + desc_rb == Qnil ? NULL : Descriptor_GetMsgDef(desc_rb); + + if (val_m != m) { + // Check for possible implicit conversions + // TODO: hash conversion? + + switch (upb_MessageDef_WellKnownType(m)) { + case kUpb_WellKnown_Timestamp: { + // Time -> Google::Protobuf::Timestamp + const upb_MiniTable* t = upb_MessageDef_MiniTable(m); + upb_Message* msg = upb_Message_New(t, arena); + upb_MessageValue sec, nsec; + struct timespec time; + const upb_FieldDef* sec_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_FieldDef* nsec_f = upb_MessageDef_FindFieldByNumber(m, 2); + + if (!rb_obj_is_kind_of(value, rb_cTime)) goto badtype; + + time = rb_time_timespec(value); + sec.int64_val = time.tv_sec; + nsec.int32_val = time.tv_nsec; + upb_Message_SetFieldByDef(msg, sec_f, sec, arena); + upb_Message_SetFieldByDef(msg, nsec_f, nsec, arena); + return msg; + } + case kUpb_WellKnown_Duration: { + // Numeric -> Google::Protobuf::Duration + const upb_MiniTable* t = upb_MessageDef_MiniTable(m); + upb_Message* msg = upb_Message_New(t, arena); + upb_MessageValue sec, nsec; + const upb_FieldDef* sec_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_FieldDef* nsec_f = upb_MessageDef_FindFieldByNumber(m, 2); + + if (!rb_obj_is_kind_of(value, rb_cNumeric)) goto badtype; + + sec.int64_val = NUM2LL(value); + nsec.int32_val = round((NUM2DBL(value) - NUM2LL(value)) * 1000000000); + upb_Message_SetFieldByDef(msg, sec_f, sec, arena); + upb_Message_SetFieldByDef(msg, nsec_f, nsec, arena); + return msg; + } + default: + badtype: + rb_raise(cTypeError, + "Invalid type %s to assign to submessage field '%s'.", + rb_class2name(CLASS_OF(value)), name); + } + } + + Message* self = ruby_to_Message(value); + Arena_fuse(self->arena, arena); + + return self->msg; +} + +static void Message_define_class(VALUE klass) { + rb_define_alloc_func(klass, Message_alloc); + + rb_require("google/protobuf/message_exts"); + rb_define_method(klass, "method_missing", Message_method_missing, -1); + rb_define_method(klass, "respond_to_missing?", Message_respond_to_missing, + -1); + rb_define_method(klass, "initialize", Message_initialize, -1); + rb_define_method(klass, "dup", Message_dup, 0); + // Also define #clone so that we don't inherit Object#clone. + rb_define_method(klass, "clone", Message_dup, 0); + rb_define_method(klass, "==", Message_eq, 1); + rb_define_method(klass, "eql?", Message_eq, 1); + rb_define_method(klass, "freeze", Message_freeze, 0); + rb_define_method(klass, "hash", Message_hash, 0); + rb_define_method(klass, "to_h", Message_to_h, 0); + rb_define_method(klass, "inspect", Message_inspect, 0); + rb_define_method(klass, "to_s", Message_inspect, 0); + rb_define_method(klass, "[]", Message_index, 1); + rb_define_method(klass, "[]=", Message_index_set, 2); + rb_define_singleton_method(klass, "decode", Message_decode, -1); + rb_define_singleton_method(klass, "encode", Message_encode, -1); + rb_define_singleton_method(klass, "decode_json", Message_decode_json, -1); + rb_define_singleton_method(klass, "encode_json", Message_encode_json, -1); + rb_define_singleton_method(klass, "descriptor", Message_descriptor, 0); +} + +void Message_register(VALUE protobuf) { + cParseError = rb_const_get(protobuf, rb_intern("ParseError")); + cAbstractMessage = + rb_define_class_under(protobuf, "AbstractMessage", rb_cObject); + Message_define_class(cAbstractMessage); + rb_gc_register_address(&cAbstractMessage); + + // Ruby-interned string: "descriptor". We use this identifier to store an + // instance variable on message classes we create in order to link them back + // to their descriptors. + descriptor_instancevar_interned = rb_intern("@descriptor"); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/message.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/message.h new file mode 100755 index 0000000..5d43a88 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/message.h @@ -0,0 +1,82 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef RUBY_PROTOBUF_MESSAGE_H_ +#define RUBY_PROTOBUF_MESSAGE_H_ + +#include "protobuf.h" +#include "ruby-upb.h" + +// Gets the underlying upb_Message* and upb_MessageDef for the given Ruby +// message wrapper. Requires that |value| is indeed a message object. +const upb_Message* Message_Get(VALUE value, const upb_MessageDef** m); + +// Like Message_Get(), but checks that the object is not frozen and returns a +// mutable pointer. +upb_Message* Message_GetMutable(VALUE value, const upb_MessageDef** m); + +// Returns the Arena object for this message. +VALUE Message_GetArena(VALUE value); + +// Converts |value| into a upb_Message value of the expected upb_MessageDef +// type, raising an error if this is not possible. Used when assigning |value| +// to a field of another message, which means the message must be of a +// particular type. +// +// This will perform automatic conversions in some cases (for example, Time -> +// Google::Protobuf::Timestamp). If any new message is created, it will be +// created on |arena|, and any existing message will have its arena fused with +// |arena|. +const upb_Message* Message_GetUpbMessage(VALUE value, const upb_MessageDef* m, + const char* name, upb_Arena* arena); + +// Gets or constructs a Ruby wrapper object for the given message. The wrapper +// object will reference |arena| and ensure that it outlives this object. +VALUE Message_GetRubyWrapper(upb_Message* msg, const upb_MessageDef* m, + VALUE arena); + +// Gets the given field from this message. +VALUE Message_getfield(VALUE _self, const upb_FieldDef* f); + +// Implements #inspect for this message, printing the text to |b|. +void Message_PrintMessage(StringBuilder* b, const upb_Message* msg, + const upb_MessageDef* m); + +// Returns a hash value for the given message. +uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m, + uint64_t seed); + +// Returns a deep copy of the given message. +upb_Message* Message_deep_copy(const upb_Message* msg, const upb_MessageDef* m, + upb_Arena* arena); + +// Checks that this Ruby object is a message, and raises an exception if not. +void Message_CheckClass(VALUE klass); + +// Returns a new Hash object containing the contents of this message. +VALUE Scalar_CreateHash(upb_MessageValue val, TypeInfo type_info); + +// Creates a message class or enum module for this descriptor, respectively. +VALUE build_class_from_descriptor(VALUE descriptor); +VALUE build_module_from_enumdesc(VALUE _enumdesc); + +// Returns the Descriptor/EnumDescriptor for the given message class or enum +// module, respectively. Returns nil if this is not a message class or enum +// module. +VALUE MessageOrEnum_GetDescriptor(VALUE klass); + +// Decodes a Message from a byte sequence. +VALUE Message_decode_bytes(int size, const char* bytes, int options, + VALUE klass, bool freeze); + +// Recursively freeze message +VALUE Message_freeze(VALUE _self); + +// Call at startup to register all types in this module. +void Message_register(VALUE protobuf); + +#endif // RUBY_PROTOBUF_MESSAGE_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/protobuf.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/protobuf.c new file mode 100755 index 0000000..444870c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/protobuf.c @@ -0,0 +1,356 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2014 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#include "protobuf.h" + +#include + +#include "defs.h" +#include "map.h" +#include "message.h" +#include "repeated_field.h" + +VALUE cParseError; +VALUE cTypeError; + +const upb_FieldDef *map_field_key(const upb_FieldDef *field) { + const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field); + return upb_MessageDef_FindFieldByNumber(entry, 1); +} + +const upb_FieldDef *map_field_value(const upb_FieldDef *field) { + const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field); + return upb_MessageDef_FindFieldByNumber(entry, 2); +} + +// ----------------------------------------------------------------------------- +// StringBuilder, for inspect +// ----------------------------------------------------------------------------- + +struct StringBuilder { + size_t size; + size_t cap; + char *data; +}; + +typedef struct StringBuilder StringBuilder; + +static size_t StringBuilder_SizeOf(size_t cap) { + return sizeof(StringBuilder) + cap; +} + +StringBuilder *StringBuilder_New() { + const size_t cap = 128; + StringBuilder *builder = malloc(sizeof(*builder)); + builder->size = 0; + builder->cap = cap; + builder->data = malloc(builder->cap); + return builder; +} + +void StringBuilder_Free(StringBuilder *b) { + free(b->data); + free(b); +} + +void StringBuilder_Printf(StringBuilder *b, const char *fmt, ...) { + size_t have = b->cap - b->size; + size_t n; + va_list args; + + va_start(args, fmt); + n = vsnprintf(&b->data[b->size], have, fmt, args); + va_end(args); + + if (have <= n) { + while (have <= n) { + b->cap *= 2; + have = b->cap - b->size; + } + b->data = realloc(b->data, StringBuilder_SizeOf(b->cap)); + va_start(args, fmt); + n = vsnprintf(&b->data[b->size], have, fmt, args); + va_end(args); + PBRUBY_ASSERT(n < have); + } + + b->size += n; +} + +VALUE StringBuilder_ToRubyString(StringBuilder *b) { + VALUE ret = rb_str_new(b->data, b->size); + rb_enc_associate(ret, rb_utf8_encoding()); + return ret; +} + +static void StringBuilder_PrintEnum(StringBuilder *b, int32_t val, + const upb_EnumDef *e) { + const upb_EnumValueDef *ev = upb_EnumDef_FindValueByNumber(e, val); + if (ev) { + StringBuilder_Printf(b, ":%s", upb_EnumValueDef_Name(ev)); + } else { + StringBuilder_Printf(b, "%" PRId32, val); + } +} + +void StringBuilder_PrintMsgval(StringBuilder *b, upb_MessageValue val, + TypeInfo info) { + switch (info.type) { + case kUpb_CType_Bool: + StringBuilder_Printf(b, "%s", val.bool_val ? "true" : "false"); + break; + case kUpb_CType_Float: { + VALUE str = rb_inspect(DBL2NUM(val.float_val)); + StringBuilder_Printf(b, "%s", RSTRING_PTR(str)); + break; + } + case kUpb_CType_Double: { + VALUE str = rb_inspect(DBL2NUM(val.double_val)); + StringBuilder_Printf(b, "%s", RSTRING_PTR(str)); + break; + } + case kUpb_CType_Int32: + StringBuilder_Printf(b, "%" PRId32, val.int32_val); + break; + case kUpb_CType_UInt32: + StringBuilder_Printf(b, "%" PRIu32, val.uint32_val); + break; + case kUpb_CType_Int64: + StringBuilder_Printf(b, "%" PRId64, val.int64_val); + break; + case kUpb_CType_UInt64: + StringBuilder_Printf(b, "%" PRIu64, val.uint64_val); + break; + case kUpb_CType_String: + StringBuilder_Printf(b, "\"%.*s\"", (int)val.str_val.size, + val.str_val.data); + break; + case kUpb_CType_Bytes: + StringBuilder_Printf(b, "\"%.*s\"", (int)val.str_val.size, + val.str_val.data); + break; + case kUpb_CType_Enum: + StringBuilder_PrintEnum(b, val.int32_val, info.def.enumdef); + break; + case kUpb_CType_Message: + Message_PrintMessage(b, val.msg_val, info.def.msgdef); + break; + } +} + +// ----------------------------------------------------------------------------- +// Arena +// ----------------------------------------------------------------------------- + +typedef struct { + upb_Arena *arena; + // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE() + // macro to update VALUE references, as to trigger write barriers. + VALUE pinned_objs; +} Arena; + +static void Arena_mark(void *data) { + Arena *arena = data; + rb_gc_mark(arena->pinned_objs); +} + +static void Arena_free(void *data) { + Arena *arena = data; + upb_Arena_Free(arena->arena); + xfree(arena); +} + +static size_t Arena_memsize(const void *data) { + const Arena *arena = data; + size_t fused_count; + size_t memsize = upb_Arena_SpaceAllocated(arena->arena, &fused_count); + if (fused_count > 1) { + // If other arena were fused we attribute an equal + // share of memory usage to each one. + memsize /= fused_count; + } + return memsize + sizeof(Arena); +} + +static VALUE cArena; + +const rb_data_type_t Arena_type = { + "Google::Protobuf::Internal::Arena", + {Arena_mark, Arena_free, Arena_memsize}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, +}; + +static void *ruby_upb_allocfunc(upb_alloc *alloc, void *ptr, size_t oldsize, + size_t size) { + if (size == 0) { + xfree(ptr); + return NULL; + } else { + return xrealloc(ptr, size); + } +} + +upb_alloc ruby_upb_alloc = {&ruby_upb_allocfunc}; + +static VALUE Arena_alloc(VALUE klass) { + Arena *arena = ALLOC(Arena); + arena->arena = upb_Arena_Init(NULL, 0, &ruby_upb_alloc); + arena->pinned_objs = Qnil; + return TypedData_Wrap_Struct(klass, &Arena_type, arena); +} + +upb_Arena *Arena_get(VALUE _arena) { + Arena *arena; + TypedData_Get_Struct(_arena, Arena, &Arena_type, arena); + return arena->arena; +} + +void Arena_fuse(VALUE _arena, upb_Arena *other) { + Arena *arena; + TypedData_Get_Struct(_arena, Arena, &Arena_type, arena); + if (!upb_Arena_Fuse(arena->arena, other)) { + rb_raise(rb_eRuntimeError, + "Unable to fuse arenas. This should never happen since Ruby does " + "not use initial blocks"); + } +} + +VALUE Arena_new() { return Arena_alloc(cArena); } + +void Arena_Pin(VALUE _arena, VALUE obj) { + Arena *arena; + TypedData_Get_Struct(_arena, Arena, &Arena_type, arena); + if (arena->pinned_objs == Qnil) { + RB_OBJ_WRITE(_arena, &arena->pinned_objs, rb_ary_new()); + } + rb_ary_push(arena->pinned_objs, obj); +} + +void Arena_register(VALUE module) { + VALUE internal = rb_define_module_under(module, "Internal"); + VALUE klass = rb_define_class_under(internal, "Arena", rb_cObject); + rb_define_alloc_func(klass, Arena_alloc); + rb_gc_register_address(&cArena); + cArena = klass; +} + +// ----------------------------------------------------------------------------- +// Object Cache +// ----------------------------------------------------------------------------- + +// Public ObjectCache API. + +VALUE weak_obj_cache = Qnil; +ID item_get; +ID item_try_add; + +static void ObjectCache_Init(VALUE protobuf) { + item_get = rb_intern("get"); + item_try_add = rb_intern("try_add"); + + rb_gc_register_address(&weak_obj_cache); + VALUE internal = rb_const_get(protobuf, rb_intern("Internal")); +#if SIZEOF_LONG >= SIZEOF_VALUE + VALUE cache_class = rb_const_get(internal, rb_intern("ObjectCache")); +#else + VALUE cache_class = rb_const_get(internal, rb_intern("LegacyObjectCache")); +#endif + + weak_obj_cache = rb_class_new_instance(0, NULL, cache_class); + rb_const_set(internal, rb_intern("OBJECT_CACHE"), weak_obj_cache); + rb_const_set(internal, rb_intern("SIZEOF_LONG"), INT2NUM(SIZEOF_LONG)); + rb_const_set(internal, rb_intern("SIZEOF_VALUE"), INT2NUM(SIZEOF_VALUE)); +} + +static VALUE ObjectCache_GetKey(const void *key) { + VALUE key_val = (VALUE)key; + PBRUBY_ASSERT((key_val & 3) == 0); + // Ensure the key can be stored as a Fixnum since 1 bit is needed for + // FIXNUM_FLAG and 1 bit is needed for the sign bit. + VALUE new_key = LL2NUM(key_val >> 2); + PBRUBY_ASSERT(FIXNUM_P(new_key)); + return new_key; +} + +VALUE ObjectCache_TryAdd(const void *key, VALUE val) { + VALUE key_val = ObjectCache_GetKey(key); + return rb_funcall(weak_obj_cache, item_try_add, 2, key_val, val); +} + +// Returns the cached object for this key, if any. Otherwise returns Qnil. +VALUE ObjectCache_Get(const void *key) { + VALUE key_val = ObjectCache_GetKey(key); + return rb_funcall(weak_obj_cache, item_get, 1, key_val); +} + +/* + * call-seq: + * Google::Protobuf.discard_unknown(msg) + * + * Discard unknown fields in the given message object and recursively discard + * unknown fields in submessages. + */ +static VALUE Google_Protobuf_discard_unknown(VALUE self, VALUE msg_rb) { + const upb_MessageDef *m; + upb_Message *msg = Message_GetMutable(msg_rb, &m); + if (!upb_Message_DiscardUnknown(msg, m, 128)) { + rb_raise(rb_eRuntimeError, "Messages nested too deeply."); + } + + return Qnil; +} + +/* + * call-seq: + * Google::Protobuf.deep_copy(obj) => copy_of_obj + * + * Performs a deep copy of a RepeatedField instance, a Map instance, or a + * message object, recursively copying its members. + */ +VALUE Google_Protobuf_deep_copy(VALUE self, VALUE obj) { + VALUE klass = CLASS_OF(obj); + if (klass == cRepeatedField) { + return RepeatedField_deep_copy(obj); + } else if (klass == cMap) { + return Map_deep_copy(obj); + } else { + VALUE new_arena_rb = Arena_new(); + upb_Arena *new_arena = Arena_get(new_arena_rb); + const upb_MessageDef *m; + const upb_Message *msg = Message_Get(obj, &m); + upb_Message *new_msg = Message_deep_copy(msg, m, new_arena); + return Message_GetRubyWrapper(new_msg, m, new_arena_rb); + } +} + +// ----------------------------------------------------------------------------- +// Initialization/entry point. +// ----------------------------------------------------------------------------- + +// This must be named "Init_protobuf_c" because the Ruby module is named +// "protobuf_c" -- the VM looks for this symbol in our .so. +__attribute__((visibility("default"))) void Init_protobuf_c() { + VALUE google = rb_define_module("Google"); + VALUE protobuf = rb_define_module_under(google, "Protobuf"); + + ObjectCache_Init(protobuf); + Arena_register(protobuf); + Defs_register(protobuf); + RepeatedField_register(protobuf); + Map_register(protobuf); + Message_register(protobuf); + + cParseError = rb_const_get(protobuf, rb_intern("ParseError")); + rb_gc_register_mark_object(cParseError); + cTypeError = rb_const_get(protobuf, rb_intern("TypeError")); + rb_gc_register_mark_object(cTypeError); + + rb_define_singleton_method(protobuf, "discard_unknown", + Google_Protobuf_discard_unknown, 1); + rb_define_singleton_method(protobuf, "deep_copy", Google_Protobuf_deep_copy, + 1); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/protobuf.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/protobuf.h new file mode 100755 index 0000000..4551322 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/protobuf.h @@ -0,0 +1,112 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2014 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef __GOOGLE_PROTOBUF_RUBY_PROTOBUF_H__ +#define __GOOGLE_PROTOBUF_RUBY_PROTOBUF_H__ + +// Ruby 3+ defines NDEBUG itself, see: https://bugs.ruby-lang.org/issues/18777 +#ifdef NDEBUG +#include +#else +#include +#undef NDEBUG +#endif + +#include + +#if RUBY_API_VERSION_CODE < 20700 +#error Protobuf requires Ruby >= 2.7 +#endif + +#include // Must be included after the NDEBUG logic above. +#include +#include + +#include "defs.h" +#include "ruby-upb.h" + +// These operate on a map field (i.e., a repeated field of submessages whose +// submessage type is a map-entry msgdef). +const upb_FieldDef* map_field_key(const upb_FieldDef* field); +const upb_FieldDef* map_field_value(const upb_FieldDef* field); + +// ----------------------------------------------------------------------------- +// Arena +// ----------------------------------------------------------------------------- + +// A Ruby object that wraps an underlying upb_Arena. Any objects that are +// allocated from this arena should reference the Arena in rb_gc_mark(), to +// ensure that the object's underlying memory outlives any Ruby object that can +// reach it. + +VALUE Arena_new(); +upb_Arena* Arena_get(VALUE arena); + +// Fuses this arena to another, throwing a Ruby exception if this is not +// possible. +void Arena_fuse(VALUE arena, upb_Arena* other); + +// Pins this Ruby object to the lifetime of this arena, so that as long as the +// arena is alive this object will not be collected. +// +// We use this to guarantee that the "frozen" bit on the object will be +// remembered, even if the user drops their reference to this precise object. +void Arena_Pin(VALUE arena, VALUE obj); + +// ----------------------------------------------------------------------------- +// ObjectCache +// ----------------------------------------------------------------------------- + +// Global object cache from upb array/map/message/symtab to wrapper object. +// +// This is a conceptually "weak" cache, in that it does not prevent "val" from +// being collected (though in Ruby <2.7 is it effectively strong, due to +// implementation limitations). + +// Tries to add a new entry to the cache, returning the newly installed value or +// the pre-existing entry. +VALUE ObjectCache_TryAdd(const void* key, VALUE val); + +// Returns the cached object for this key, if any. Otherwise returns Qnil. +VALUE ObjectCache_Get(const void* key); + +// ----------------------------------------------------------------------------- +// StringBuilder, for inspect +// ----------------------------------------------------------------------------- + +struct StringBuilder; +typedef struct StringBuilder StringBuilder; + +StringBuilder* StringBuilder_New(); +void StringBuilder_Free(StringBuilder* b); +void StringBuilder_Printf(StringBuilder* b, const char* fmt, ...); +VALUE StringBuilder_ToRubyString(StringBuilder* b); + +void StringBuilder_PrintMsgval(StringBuilder* b, upb_MessageValue val, + TypeInfo info); + +// ----------------------------------------------------------------------------- +// Utilities. +// ----------------------------------------------------------------------------- + +extern VALUE cTypeError; + +#ifdef NDEBUG +#define PBRUBY_ASSERT(expr) \ + do { \ + } while (false && (expr)) +#else +#define PBRUBY_ASSERT(expr) \ + if (!(expr)) \ + rb_bug("Assertion failed at %s:%d, expr: %s", __FILE__, __LINE__, #expr) +#endif + +#define PBRUBY_MAX(x, y) (((x) > (y)) ? (x) : (y)) + +#define UPB_UNUSED(var) (void)var + +#endif // __GOOGLE_PROTOBUF_RUBY_PROTOBUF_H__ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/repeated_field.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/repeated_field.c new file mode 100755 index 0000000..15b8abf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/repeated_field.c @@ -0,0 +1,647 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2014 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#include "repeated_field.h" + +#include "convert.h" +#include "defs.h" +#include "message.h" +#include "protobuf.h" + +// ----------------------------------------------------------------------------- +// Repeated field container type. +// ----------------------------------------------------------------------------- + +typedef struct { + const upb_Array* array; // Can get as mutable when non-frozen. + TypeInfo type_info; + VALUE type_class; // To GC-root the msgdef/enumdef in type_info. + VALUE arena; // To GC-root the upb_Array. +} RepeatedField; + +VALUE cRepeatedField; + +static void RepeatedField_mark(void* _self) { + RepeatedField* self = (RepeatedField*)_self; + rb_gc_mark(self->type_class); + rb_gc_mark(self->arena); +} + +const rb_data_type_t RepeatedField_type = { + "Google::Protobuf::RepeatedField", + {RepeatedField_mark, RUBY_DEFAULT_FREE, NULL}, + .flags = RUBY_TYPED_FREE_IMMEDIATELY, +}; + +static RepeatedField* ruby_to_RepeatedField(VALUE _self) { + RepeatedField* self; + TypedData_Get_Struct(_self, RepeatedField, &RepeatedField_type, self); + return self; +} + +static upb_Array* RepeatedField_GetMutable(VALUE _self) { + rb_check_frozen(_self); + return (upb_Array*)ruby_to_RepeatedField(_self)->array; +} + +VALUE RepeatedField_alloc(VALUE klass) { + RepeatedField* self = ALLOC(RepeatedField); + self->arena = Qnil; + self->type_class = Qnil; + self->array = NULL; + return TypedData_Wrap_Struct(klass, &RepeatedField_type, self); +} + +VALUE RepeatedField_GetRubyWrapper(upb_Array* array, TypeInfo type_info, + VALUE arena) { + PBRUBY_ASSERT(array); + VALUE val = ObjectCache_Get(array); + + if (val == Qnil) { + val = RepeatedField_alloc(cRepeatedField); + RepeatedField* self; + TypedData_Get_Struct(val, RepeatedField, &RepeatedField_type, self); + self->array = array; + self->arena = arena; + self->type_info = type_info; + if (self->type_info.type == kUpb_CType_Message) { + self->type_class = Descriptor_DefToClass(type_info.def.msgdef); + } + val = ObjectCache_TryAdd(array, val); + } + + PBRUBY_ASSERT(ruby_to_RepeatedField(val)->type_info.type == type_info.type); + PBRUBY_ASSERT(ruby_to_RepeatedField(val)->type_info.def.msgdef == + type_info.def.msgdef); + PBRUBY_ASSERT(ruby_to_RepeatedField(val)->array == array); + + return val; +} + +static VALUE RepeatedField_new_this_type(RepeatedField* from) { + VALUE arena_rb = Arena_new(); + upb_Array* array = upb_Array_New(Arena_get(arena_rb), from->type_info.type); + VALUE ret = RepeatedField_GetRubyWrapper(array, from->type_info, arena_rb); + PBRUBY_ASSERT(ruby_to_RepeatedField(ret)->type_class == from->type_class); + return ret; +} + +void RepeatedField_Inspect(StringBuilder* b, const upb_Array* array, + TypeInfo info) { + bool first = true; + StringBuilder_Printf(b, "["); + size_t n = array ? upb_Array_Size(array) : 0; + for (size_t i = 0; i < n; i++) { + if (first) { + first = false; + } else { + StringBuilder_Printf(b, ", "); + } + StringBuilder_PrintMsgval(b, upb_Array_Get(array, i), info); + } + StringBuilder_Printf(b, "]"); +} + +VALUE RepeatedField_deep_copy(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + VALUE new_rptfield = RepeatedField_new_this_type(self); + RepeatedField* new_self = ruby_to_RepeatedField(new_rptfield); + VALUE arena_rb = new_self->arena; + upb_Array* new_array = RepeatedField_GetMutable(new_rptfield); + upb_Arena* arena = Arena_get(arena_rb); + size_t elements = upb_Array_Size(self->array); + + upb_Array_Resize(new_array, elements, arena); + + size_t size = upb_Array_Size(self->array); + for (size_t i = 0; i < size; i++) { + upb_MessageValue msgval = upb_Array_Get(self->array, i); + upb_MessageValue copy = Msgval_DeepCopy(msgval, self->type_info, arena); + upb_Array_Set(new_array, i, copy); + } + + return new_rptfield; +} + +const upb_Array* RepeatedField_GetUpbArray(VALUE val, const upb_FieldDef* field, + upb_Arena* arena) { + RepeatedField* self; + TypeInfo type_info = TypeInfo_get(field); + + if (!RB_TYPE_P(val, T_DATA) || !RTYPEDDATA_P(val) || + RTYPEDDATA_TYPE(val) != &RepeatedField_type) { + rb_raise(cTypeError, "Expected repeated field array"); + } + + self = ruby_to_RepeatedField(val); + if (self->type_info.type != type_info.type) { + rb_raise(cTypeError, "Repeated field array has wrong element type"); + } + + if (self->type_info.def.msgdef != type_info.def.msgdef) { + rb_raise(cTypeError, "Repeated field array has wrong message/enum class"); + } + + Arena_fuse(self->arena, arena); + return self->array; +} + +static int index_position(VALUE _index, RepeatedField* repeated_field) { + int index = NUM2INT(_index); + if (index < 0) index += upb_Array_Size(repeated_field->array); + return index; +} + +static VALUE RepeatedField_subarray(RepeatedField* self, long beg, long len) { + size_t size = upb_Array_Size(self->array); + VALUE ary = rb_ary_new2(size); + long i; + + for (i = beg; i < beg + len; i++) { + upb_MessageValue msgval = upb_Array_Get(self->array, i); + VALUE elem = Convert_UpbToRuby(msgval, self->type_info, self->arena); + rb_ary_push(ary, elem); + } + return ary; +} + +/* + * call-seq: + * RepeatedField.each(&block) + * + * Invokes the block once for each element of the repeated field. RepeatedField + * also includes Enumerable; combined with this method, the repeated field thus + * acts like an ordinary Ruby sequence. + */ +static VALUE RepeatedField_each(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + int size = upb_Array_Size(self->array); + int i; + + for (i = 0; i < size; i++) { + upb_MessageValue msgval = upb_Array_Get(self->array, i); + VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena); + rb_yield(val); + } + return _self; +} + +/* + * call-seq: + * RepeatedField.[](index) => value + * + * Accesses the element at the given index. Returns nil on out-of-bounds + */ +static VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + long size = upb_Array_Size(self->array); + + VALUE arg = argv[0]; + long beg, len; + + if (argc == 1) { + if (FIXNUM_P(arg)) { + /* standard case */ + upb_MessageValue msgval; + int index = index_position(argv[0], self); + if (index < 0 || (size_t)index >= upb_Array_Size(self->array)) { + return Qnil; + } + msgval = upb_Array_Get(self->array, index); + return Convert_UpbToRuby(msgval, self->type_info, self->arena); + } else { + /* check if idx is Range */ + switch (rb_range_beg_len(arg, &beg, &len, size, 0)) { + case Qfalse: + break; + case Qnil: + return Qnil; + default: + return RepeatedField_subarray(self, beg, len); + } + } + } + + /* assume 2 arguments */ + beg = NUM2LONG(argv[0]); + len = NUM2LONG(argv[1]); + if (beg < 0) { + beg += size; + } + if (beg >= size) { + return Qnil; + } + return RepeatedField_subarray(self, beg, len); +} + +/* + * call-seq: + * RepeatedField.[]=(index, value) + * + * Sets the element at the given index. On out-of-bounds assignments, extends + * the array and fills the hole (if any) with default values. + */ +static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) { + RepeatedField* self = ruby_to_RepeatedField(_self); + int size = upb_Array_Size(self->array); + upb_Array* array = RepeatedField_GetMutable(_self); + upb_Arena* arena = Arena_get(self->arena); + upb_MessageValue msgval = Convert_RubyToUpb(val, "", self->type_info, arena); + + int index = index_position(_index, self); + if (index < 0 || index >= (INT_MAX - 1)) { + return Qnil; + } + + if (index >= size) { + upb_Array_Resize(array, index + 1, arena); + upb_MessageValue fill; + memset(&fill, 0, sizeof(fill)); + for (int i = size; i < index; i++) { + // Fill default values. + // TODO: should this happen at the upb level? + upb_Array_Set(array, i, fill); + } + } + + upb_Array_Set(array, index, msgval); + return Qnil; +} + +/* + * call-seq: + * RepeatedField.push(value, ...) + * + * Adds a new element to the repeated field. + */ +static VALUE RepeatedField_push_vararg(int argc, VALUE* argv, VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + upb_Arena* arena = Arena_get(self->arena); + upb_Array* array = RepeatedField_GetMutable(_self); + int i; + + for (i = 0; i < argc; i++) { + upb_MessageValue msgval = + Convert_RubyToUpb(argv[i], "", self->type_info, arena); + upb_Array_Append(array, msgval, arena); + } + + return _self; +} + +/* + * call-seq: + * RepeatedField.<<(value) + * + * Adds a new element to the repeated field. + */ +static VALUE RepeatedField_push(VALUE _self, VALUE val) { + RepeatedField* self = ruby_to_RepeatedField(_self); + upb_Arena* arena = Arena_get(self->arena); + upb_Array* array = RepeatedField_GetMutable(_self); + + upb_MessageValue msgval = Convert_RubyToUpb(val, "", self->type_info, arena); + upb_Array_Append(array, msgval, arena); + + return _self; +} + +/* + * Private ruby method, used by RepeatedField.pop + */ +static VALUE RepeatedField_pop_one(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + size_t size = upb_Array_Size(self->array); + upb_Array* array = RepeatedField_GetMutable(_self); + upb_MessageValue last; + VALUE ret; + + if (size == 0) { + return Qnil; + } + + last = upb_Array_Get(self->array, size - 1); + ret = Convert_UpbToRuby(last, self->type_info, self->arena); + + upb_Array_Resize(array, size - 1, Arena_get(self->arena)); + return ret; +} + +/* + * call-seq: + * RepeatedField.replace(list) + * + * Replaces the contents of the repeated field with the given list of elements. + */ +static VALUE RepeatedField_replace(VALUE _self, VALUE list) { + RepeatedField* self = ruby_to_RepeatedField(_self); + upb_Array* array = RepeatedField_GetMutable(_self); + int i; + + Check_Type(list, T_ARRAY); + upb_Array_Resize(array, 0, Arena_get(self->arena)); + + for (i = 0; i < RARRAY_LEN(list); i++) { + RepeatedField_push(_self, rb_ary_entry(list, i)); + } + + return list; +} + +/* + * call-seq: + * RepeatedField.clear + * + * Clears (removes all elements from) this repeated field. + */ +static VALUE RepeatedField_clear(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + upb_Array* array = RepeatedField_GetMutable(_self); + upb_Array_Resize(array, 0, Arena_get(self->arena)); + return _self; +} + +/* + * call-seq: + * RepeatedField.length + * + * Returns the length of this repeated field. + */ +static VALUE RepeatedField_length(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + return INT2NUM(upb_Array_Size(self->array)); +} + +/* + * call-seq: + * RepeatedField.dup => repeated_field + * + * Duplicates this repeated field with a shallow copy. References to all + * non-primitive element objects (e.g., submessages) are shared. + */ +static VALUE RepeatedField_dup(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + VALUE new_rptfield = RepeatedField_new_this_type(self); + RepeatedField* new_rptfield_self = ruby_to_RepeatedField(new_rptfield); + upb_Array* new_array = RepeatedField_GetMutable(new_rptfield); + upb_Arena* arena = Arena_get(new_rptfield_self->arena); + int size = upb_Array_Size(self->array); + int i; + + Arena_fuse(self->arena, arena); + + for (i = 0; i < size; i++) { + upb_MessageValue msgval = upb_Array_Get(self->array, i); + upb_Array_Append(new_array, msgval, arena); + } + + return new_rptfield; +} + +/* + * call-seq: + * RepeatedField.to_ary => array + * + * Used when converted implicitly into array, e.g. compared to an Array. + * Also called as a fallback of Object#to_a + */ +VALUE RepeatedField_to_ary(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + int size = upb_Array_Size(self->array); + VALUE ary = rb_ary_new2(size); + int i; + + for (i = 0; i < size; i++) { + upb_MessageValue msgval = upb_Array_Get(self->array, i); + VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena); + rb_ary_push(ary, val); + } + + return ary; +} + +/* + * call-seq: + * RepeatedField.==(other) => boolean + * + * Compares this repeated field to another. Repeated fields are equal if their + * element types are equal, their lengths are equal, and each element is equal. + * Elements are compared as per normal Ruby semantics, by calling their :== + * methods (or performing a more efficient comparison for primitive types). + * + * Repeated fields with dissimilar element types are never equal, even if value + * comparison (for example, between integers and floats) would have otherwise + * indicated that every element has equal value. + */ +VALUE RepeatedField_eq(VALUE _self, VALUE _other) { + RepeatedField* self; + RepeatedField* other; + + if (_self == _other) { + return Qtrue; + } + + if (TYPE(_other) == T_ARRAY) { + VALUE self_ary = RepeatedField_to_ary(_self); + return rb_equal(self_ary, _other); + } + + self = ruby_to_RepeatedField(_self); + other = ruby_to_RepeatedField(_other); + size_t n = upb_Array_Size(self->array); + + if (self->type_info.type != other->type_info.type || + self->type_class != other->type_class || + upb_Array_Size(other->array) != n) { + return Qfalse; + } + + for (size_t i = 0; i < n; i++) { + upb_MessageValue val1 = upb_Array_Get(self->array, i); + upb_MessageValue val2 = upb_Array_Get(other->array, i); + if (!Msgval_IsEqual(val1, val2, self->type_info)) { + return Qfalse; + } + } + + return Qtrue; +} + +/* + * call-seq: + * RepeatedField.freeze => self + * + * Freezes the repeated field. We have to intercept this so we can pin the Ruby + * object into memory so we don't forget it's frozen. + */ +VALUE RepeatedField_freeze(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + + if (RB_OBJ_FROZEN(_self)) return _self; + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + + if (self->type_info.type == kUpb_CType_Message) { + int size = upb_Array_Size(self->array); + int i; + for (i = 0; i < size; i++) { + upb_MessageValue msgval = upb_Array_Get(self->array, i); + VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena); + Message_freeze(val); + } + } + return _self; +} + +/* + * call-seq: + * RepeatedField.hash => hash_value + * + * Returns a hash value computed from this repeated field's elements. + */ +VALUE RepeatedField_hash(VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + uint64_t hash = 0; + size_t n = upb_Array_Size(self->array); + + for (size_t i = 0; i < n; i++) { + upb_MessageValue val = upb_Array_Get(self->array, i); + hash = Msgval_GetHash(val, self->type_info, hash); + } + + return LL2NUM(hash); +} + +/* + * call-seq: + * RepeatedField.+(other) => repeated field + * + * Returns a new repeated field that contains the concatenated list of this + * repeated field's elements and other's elements. The other (second) list may + * be either another repeated field or a Ruby array. + */ +VALUE RepeatedField_plus(VALUE _self, VALUE list) { + VALUE dupped_ = RepeatedField_dup(_self); + + if (TYPE(list) == T_ARRAY) { + int i; + for (i = 0; i < RARRAY_LEN(list); i++) { + VALUE elem = rb_ary_entry(list, i); + RepeatedField_push(dupped_, elem); + } + } else if (RB_TYPE_P(list, T_DATA) && RTYPEDDATA_P(list) && + RTYPEDDATA_TYPE(list) == &RepeatedField_type) { + RepeatedField* self = ruby_to_RepeatedField(_self); + RepeatedField* list_rptfield = ruby_to_RepeatedField(list); + RepeatedField* dupped = ruby_to_RepeatedField(dupped_); + upb_Array* dupped_array = RepeatedField_GetMutable(dupped_); + upb_Arena* arena = Arena_get(dupped->arena); + Arena_fuse(list_rptfield->arena, arena); + int size = upb_Array_Size(list_rptfield->array); + int i; + + if (self->type_info.type != list_rptfield->type_info.type || + self->type_class != list_rptfield->type_class) { + rb_raise(rb_eArgError, + "Attempt to append RepeatedField with different element type."); + } + + for (i = 0; i < size; i++) { + upb_MessageValue msgval = upb_Array_Get(list_rptfield->array, i); + upb_Array_Append(dupped_array, msgval, arena); + } + } else { + rb_raise(rb_eArgError, "Unknown type appending to RepeatedField"); + } + + return dupped_; +} + +/* + * call-seq: + * RepeatedField.concat(other) => self + * + * concats the passed in array to self. Returns a Ruby array. + */ +VALUE RepeatedField_concat(VALUE _self, VALUE list) { + int i; + + Check_Type(list, T_ARRAY); + for (i = 0; i < RARRAY_LEN(list); i++) { + RepeatedField_push(_self, rb_ary_entry(list, i)); + } + return _self; +} + +/* + * call-seq: + * RepeatedField.new(type, type_class = nil, initial_elems = []) + * + * Creates a new repeated field. The provided type must be a Ruby symbol, and + * can take on the same values as those accepted by FieldDescriptor#type=. If + * the type is :message or :enum, type_class must be non-nil, and must be the + * Ruby class or module returned by Descriptor#msgclass or + * EnumDescriptor#enummodule, respectively. An initial list of elements may also + * be provided. + */ +VALUE RepeatedField_init(int argc, VALUE* argv, VALUE _self) { + RepeatedField* self = ruby_to_RepeatedField(_self); + upb_Arena* arena; + VALUE ary = Qnil; + + self->arena = Arena_new(); + arena = Arena_get(self->arena); + + if (argc < 1) { + rb_raise(rb_eArgError, "Expected at least 1 argument."); + } + + self->type_info = TypeInfo_FromClass(argc, argv, 0, &self->type_class, &ary); + self->array = upb_Array_New(arena, self->type_info.type); + VALUE stored_val = ObjectCache_TryAdd(self->array, _self); + PBRUBY_ASSERT(stored_val == _self); + + if (ary != Qnil) { + if (!RB_TYPE_P(ary, T_ARRAY)) { + rb_raise(rb_eArgError, "Expected array as initialize argument"); + } + for (int i = 0; i < RARRAY_LEN(ary); i++) { + RepeatedField_push(_self, rb_ary_entry(ary, i)); + } + } + return Qnil; +} + +void RepeatedField_register(VALUE module) { + VALUE klass = rb_define_class_under(module, "RepeatedField", rb_cObject); + rb_define_alloc_func(klass, RepeatedField_alloc); + rb_gc_register_address(&cRepeatedField); + cRepeatedField = klass; + + rb_define_method(klass, "initialize", RepeatedField_init, -1); + rb_define_method(klass, "each", RepeatedField_each, 0); + rb_define_method(klass, "[]", RepeatedField_index, -1); + rb_define_method(klass, "at", RepeatedField_index, -1); + rb_define_method(klass, "[]=", RepeatedField_index_set, 2); + rb_define_method(klass, "push", RepeatedField_push_vararg, -1); + rb_define_method(klass, "<<", RepeatedField_push, 1); + rb_define_private_method(klass, "pop_one", RepeatedField_pop_one, 0); + rb_define_method(klass, "replace", RepeatedField_replace, 1); + rb_define_method(klass, "clear", RepeatedField_clear, 0); + rb_define_method(klass, "length", RepeatedField_length, 0); + rb_define_method(klass, "size", RepeatedField_length, 0); + rb_define_method(klass, "dup", RepeatedField_dup, 0); + // Also define #clone so that we don't inherit Object#clone. + rb_define_method(klass, "clone", RepeatedField_dup, 0); + rb_define_method(klass, "==", RepeatedField_eq, 1); + rb_define_method(klass, "to_ary", RepeatedField_to_ary, 0); + rb_define_method(klass, "freeze", RepeatedField_freeze, 0); + rb_define_method(klass, "hash", RepeatedField_hash, 0); + rb_define_method(klass, "+", RepeatedField_plus, 1); + rb_define_method(klass, "concat", RepeatedField_concat, 1); + rb_include_module(klass, rb_mEnumerable); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/repeated_field.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/repeated_field.h new file mode 100755 index 0000000..f5d5e22 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/repeated_field.h @@ -0,0 +1,41 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef RUBY_PROTOBUF_REPEATED_FIELD_H_ +#define RUBY_PROTOBUF_REPEATED_FIELD_H_ + +#include "protobuf.h" +#include "ruby-upb.h" + +// Returns a Ruby wrapper object for the given upb_Array, which will be created +// if one does not exist already. +VALUE RepeatedField_GetRubyWrapper(upb_Array* msg, TypeInfo type_info, + VALUE arena); + +// Gets the underlying upb_Array for this Ruby RepeatedField object, which must +// have a type that matches |f|. If this is not a repeated field or the type +// doesn't match, raises an exception. +const upb_Array* RepeatedField_GetUpbArray(VALUE value, const upb_FieldDef* f, + upb_Arena* arena); + +// Implements #inspect for this repeated field by appending its contents to |b|. +void RepeatedField_Inspect(StringBuilder* b, const upb_Array* array, + TypeInfo info); + +// Returns a deep copy of this RepeatedField object. +VALUE RepeatedField_deep_copy(VALUE obj); + +// Ruby class of Google::Protobuf::RepeatedField. +extern VALUE cRepeatedField; + +// Call at startup to register all types in this module. +void RepeatedField_register(VALUE module); + +// Recursively freeze RepeatedField. +VALUE RepeatedField_freeze(VALUE _self); + +#endif // RUBY_PROTOBUF_REPEATED_FIELD_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/ruby-upb.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/ruby-upb.c new file mode 100755 index 0000000..21d6df7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/ruby-upb.c @@ -0,0 +1,16330 @@ +/* Amalgamated source file */ +#include "ruby-upb.h" + +/* + * This is where we define internal portability macros used across upb. + * + * All of these macros are undef'd in undef.inc to avoid leaking them to users. + * + * The correct usage is: + * + * #include "upb/foobar.h" + * #include "upb/baz.h" + * + * // MUST be last included header. + * #include "upb/port/def.inc" + * + * // Code for this file. + * // <...> + * + * // Can be omitted for .c files, required for .h. + * #include "upb/port/undef.inc" + * + * This file is private and must not be included by users! + */ + +#if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201402L) || \ + (defined(_MSC_VER) && _MSC_VER >= 1900)) +#error upb requires C99 or C++14 or MSVC >= 2015. +#endif + +// Portable check for GCC minimum version: +// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +#define UPB_GNUC_MIN(x, y) \ + (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y)) +#else +#define UPB_GNUC_MIN(x, y) 0 +#endif + +#include +#include +#include +#include +#include + +#ifndef UINTPTR_MAX +Error, UINTPTR_MAX is undefined +#endif + +#if UINTPTR_MAX == 0xffffffff +#define UPB_SIZE(size32, size64) size32 +#else +#define UPB_SIZE(size32, size64) size64 +#endif + +/* If we always read/write as a consistent type to each address, this shouldn't + * violate aliasing. + */ +#define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs))) + +#define UPB_MAPTYPE_STRING 0 + +// UPB_EXPORT: always generate a public symbol. +#if defined(__GNUC__) || defined(__clang__) +#define UPB_EXPORT __attribute__((visibility("default"))) __attribute__((used)) +#else +#define UPB_EXPORT +#endif + +// UPB_INLINE: inline if possible, emit standalone code if required. +#ifdef __cplusplus +#define UPB_INLINE inline +#elif defined (__GNUC__) || defined(__clang__) +#define UPB_INLINE static __inline__ +#else +#define UPB_INLINE static +#endif + +#ifdef UPB_BUILD_API +#define UPB_API UPB_EXPORT +#define UPB_API_INLINE UPB_EXPORT +#else +#define UPB_API +#define UPB_API_INLINE UPB_INLINE +#endif + +#define UPB_MALLOC_ALIGN 8 +#define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align)) +#define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align)) +#define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, UPB_MALLOC_ALIGN) +#ifdef __clang__ +#define UPB_ALIGN_OF(type) _Alignof(type) +#else +#define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member) +#endif + +#ifdef _MSC_VER +// Some versions of our Windows compiler don't support the C11 syntax. +#define UPB_ALIGN_AS(x) __declspec(align(x)) +#else +#define UPB_ALIGN_AS(x) _Alignas(x) +#endif + +// Hints to the compiler about likely/unlikely branches. +#if defined (__GNUC__) || defined(__clang__) +#define UPB_LIKELY(x) __builtin_expect((bool)(x), 1) +#define UPB_UNLIKELY(x) __builtin_expect((bool)(x), 0) +#else +#define UPB_LIKELY(x) (x) +#define UPB_UNLIKELY(x) (x) +#endif + +// Macros for function attributes on compilers that support them. +#ifdef __GNUC__ +#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static +#define UPB_NOINLINE __attribute__((noinline)) +#define UPB_NORETURN __attribute__((__noreturn__)) +#define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg))) +#elif defined(_MSC_VER) +#define UPB_NOINLINE +#define UPB_FORCEINLINE static +#define UPB_NORETURN __declspec(noreturn) +#define UPB_PRINTF(str, first_vararg) +#else /* !defined(__GNUC__) */ +#define UPB_FORCEINLINE static +#define UPB_NOINLINE +#define UPB_NORETURN +#define UPB_PRINTF(str, first_vararg) +#endif + +#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y)) +#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y)) + +#define UPB_UNUSED(var) (void)var + +// UPB_ASSUME(): in release mode, we tell the compiler to assume this is true. +#ifdef NDEBUG +#ifdef __GNUC__ +#define UPB_ASSUME(expr) if (!(expr)) __builtin_unreachable() +#elif defined _MSC_VER +#define UPB_ASSUME(expr) if (!(expr)) __assume(0) +#else +#define UPB_ASSUME(expr) do {} while (false && (expr)) +#endif +#else +#define UPB_ASSUME(expr) assert(expr) +#endif + +/* UPB_ASSERT(): in release mode, we use the expression without letting it be + * evaluated. This prevents "unused variable" warnings. */ +#ifdef NDEBUG +#define UPB_ASSERT(expr) do {} while (false && (expr)) +#else +#define UPB_ASSERT(expr) assert(expr) +#endif + +#if defined(__GNUC__) || defined(__clang__) +#define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0) +#elif defined(_MSC_VER) +#define UPB_UNREACHABLE() \ + do { \ + assert(0); \ + __assume(0); \ + } while (0) +#else +#define UPB_UNREACHABLE() do { assert(0); } while(0) +#endif + +/* UPB_SETJMP() / UPB_LONGJMP(): avoid setting/restoring signal mask. */ +#ifdef __APPLE__ +#define UPB_SETJMP(buf) _setjmp(buf) +#define UPB_LONGJMP(buf, val) _longjmp(buf, val) +#else +#define UPB_SETJMP(buf) setjmp(buf) +#define UPB_LONGJMP(buf, val) longjmp(buf, val) +#endif + +#ifdef __GNUC__ +#define UPB_USE_C11_ATOMICS +#define UPB_ATOMIC(T) _Atomic(T) +#else +#define UPB_ATOMIC(T) T +#endif + +/* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */ +#define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr)) + +#define UPB_PRIVATE(x) x##_dont_copy_me__upb_internal_use_only + +#ifdef UPB_ALLOW_PRIVATE_ACCESS__FOR_BITS_ONLY +#define UPB_ONLYBITS(x) x +#else +#define UPB_ONLYBITS(x) UPB_PRIVATE(x) +#endif + +/* Configure whether fasttable is switched on or not. *************************/ + +#ifdef __has_attribute +#define UPB_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +#define UPB_HAS_ATTRIBUTE(x) 0 +#endif + +#if UPB_HAS_ATTRIBUTE(musttail) +#define UPB_MUSTTAIL __attribute__((musttail)) +#else +#define UPB_MUSTTAIL +#endif + +#undef UPB_HAS_ATTRIBUTE + +/* This check is not fully robust: it does not require that we have "musttail" + * support available. We need tail calls to avoid consuming arbitrary amounts + * of stack space. + * + * GCC/Clang can mostly be trusted to generate tail calls as long as + * optimization is enabled, but, debug builds will not generate tail calls + * unless "musttail" is available. + * + * We should probably either: + * 1. require that the compiler supports musttail. + * 2. add some fallback code for when musttail isn't available (ie. return + * instead of tail calling). This is safe and portable, but this comes at + * a CPU cost. + */ +#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__) +#define UPB_FASTTABLE_SUPPORTED 1 +#else +#define UPB_FASTTABLE_SUPPORTED 0 +#endif + +/* define UPB_ENABLE_FASTTABLE to force fast table support. + * This is useful when we want to ensure we are really getting fasttable, + * for example for testing or benchmarking. */ +#if defined(UPB_ENABLE_FASTTABLE) +#if !UPB_FASTTABLE_SUPPORTED +#error fasttable is x86-64/ARM64 only and requires GCC or Clang. +#endif +#define UPB_FASTTABLE 1 +/* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible. + * This is useful for releasing code that might be used on multiple platforms, + * for example the PHP or Ruby C extensions. */ +#elif defined(UPB_TRY_ENABLE_FASTTABLE) +#define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED +#else +#define UPB_FASTTABLE 0 +#endif + +/* UPB_FASTTABLE_INIT() allows protos compiled for fasttable to gracefully + * degrade to non-fasttable if the runtime or platform do not support it. */ +#if !UPB_FASTTABLE +#define UPB_FASTTABLE_INIT(...) +#define UPB_FASTTABLE_MASK(mask) -1 +#else +#define UPB_FASTTABLE_INIT(...) __VA_ARGS__ +#define UPB_FASTTABLE_MASK(mask) mask +#endif + +#undef UPB_FASTTABLE_SUPPORTED + +/* ASAN poisoning (for arena). + * If using UPB from an interpreted language like Ruby, a build of the + * interpreter compiled with ASAN enabled must be used in order to get sane and + * expected behavior. + */ + +/* Due to preprocessor limitations, the conditional logic for setting + * UPN_CLANG_ASAN below cannot be consolidated into a portable one-liner. + * See https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html. + */ +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define UPB_CLANG_ASAN 1 +#else +#define UPB_CLANG_ASAN 0 +#endif +#else +#define UPB_CLANG_ASAN 0 +#endif + +#if defined(__SANITIZE_ADDRESS__) || UPB_CLANG_ASAN +#define UPB_ASAN 1 +#define UPB_ASAN_GUARD_SIZE 32 +#ifdef __cplusplus + extern "C" { +#endif +void __asan_poison_memory_region(void const volatile *addr, size_t size); +void __asan_unpoison_memory_region(void const volatile *addr, size_t size); +#ifdef __cplusplus +} /* extern "C" */ +#endif +#define UPB_POISON_MEMORY_REGION(addr, size) \ + __asan_poison_memory_region((addr), (size)) +#define UPB_UNPOISON_MEMORY_REGION(addr, size) \ + __asan_unpoison_memory_region((addr), (size)) +#else +#define UPB_ASAN 0 +#define UPB_ASAN_GUARD_SIZE 0 +#define UPB_POISON_MEMORY_REGION(addr, size) \ + ((void)(addr), (void)(size)) +#define UPB_UNPOISON_MEMORY_REGION(addr, size) \ + ((void)(addr), (void)(size)) +#endif + +/* Disable proto2 arena behavior (TEMPORARY) **********************************/ + +#ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING +#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1 +#else +#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0 +#endif + +#if defined(__cplusplus) +#if defined(__clang__) || UPB_GNUC_MIN(6, 0) +// https://gcc.gnu.org/gcc-6/changes.html +#if __cplusplus >= 201402L +#define UPB_DEPRECATED [[deprecated]] +#else +#define UPB_DEPRECATED __attribute__((deprecated)) +#endif +#else +#define UPB_DEPRECATED +#endif +#else +#define UPB_DEPRECATED +#endif + +// begin:google_only +// #define UPB_IS_GOOGLE3 +// end:google_only + +#if defined(UPB_IS_GOOGLE3) && !defined(UPB_BOOTSTRAP_STAGE0) +#define UPB_DESC(sym) proto2_##sym +#define UPB_DESC_MINITABLE(sym) &proto2__##sym##_msg_init +#elif defined(UPB_BOOTSTRAP_STAGE0) +#define UPB_DESC(sym) google_protobuf_##sym +#define UPB_DESC_MINITABLE(sym) google__protobuf__##sym##_msg_init() +#else +#define UPB_DESC(sym) google_protobuf_##sym +#define UPB_DESC_MINITABLE(sym) &google__protobuf__##sym##_msg_init +#endif + +#ifdef UPB_TRACING_ENABLED +#ifdef NDEBUG +error UPB_TRACING_ENABLED Tracing should be disabled in production builds +#endif +#endif + + +#include +#include +#include +#include +#include + +// Must be last. + +void upb_Status_Clear(upb_Status* status) { + if (!status) return; + status->ok = true; + status->msg[0] = '\0'; +} + +bool upb_Status_IsOk(const upb_Status* status) { return status->ok; } + +const char* upb_Status_ErrorMessage(const upb_Status* status) { + return status->msg; +} + +void upb_Status_SetErrorMessage(upb_Status* status, const char* msg) { + if (!status) return; + status->ok = false; + strncpy(status->msg, msg, _kUpb_Status_MaxMessage - 1); + status->msg[_kUpb_Status_MaxMessage - 1] = '\0'; +} + +void upb_Status_SetErrorFormat(upb_Status* status, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + upb_Status_VSetErrorFormat(status, fmt, args); + va_end(args); +} + +void upb_Status_VSetErrorFormat(upb_Status* status, const char* fmt, + va_list args) { + if (!status) return; + status->ok = false; + vsnprintf(status->msg, sizeof(status->msg), fmt, args); + status->msg[_kUpb_Status_MaxMessage - 1] = '\0'; +} + +void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt, + va_list args) { + size_t len; + if (!status) return; + status->ok = false; + len = strlen(status->msg); + vsnprintf(status->msg + len, sizeof(status->msg) - len, fmt, args); + status->msg[_kUpb_Status_MaxMessage - 1] = '\0'; +} +/* This file was generated by upb_generator from the input file: + * + * google/protobuf/descriptor.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include + +// Must be last. + +static const upb_MiniTableSub google_protobuf_FileDescriptorSet_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FileDescriptorProto_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_FileDescriptorSet__fields[1] = { + {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FileDescriptorSet_msg_init = { + &google_protobuf_FileDescriptorSet_submsgs[0], + &google_protobuf_FileDescriptorSet__fields[0], + 16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FileDescriptorSet", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800003f00000a, &upb_prm_1bt_max192b}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FileDescriptorProto_submsgs[7] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__EnumDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__ServiceDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FieldDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FileOptions_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__SourceCodeInfo_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FileDescriptorProto__fields[13] = { + {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FileDescriptorProto_msg_init = { + &google_protobuf_FileDescriptorProto_submsgs[0], + &google_protobuf_FileDescriptorProto__fields[0], + UPB_SIZE(80, 136), 13, kUpb_ExtMode_NonExtendable, 12, UPB_FASTTABLE_MASK(120), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FileDescriptorProto", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x003000003f00001a, &upb_prs_1bt}, + {0x003800003f000022, &upb_prm_1bt_max128b}, + {0x004000003f01002a, &upb_prm_1bt_max128b}, + {0x004800003f020032, &upb_prm_1bt_max64b}, + {0x005000003f03003a, &upb_prm_1bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x006800003f000050, &upb_prv4_1bt}, + {0x007000003f000058, &upb_prv4_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_DescriptorProto_submsgs[8] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FieldDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__EnumDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto__ExtensionRange_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FieldDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__MessageOptions_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__OneofDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto__ReservedRange_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_DescriptorProto__fields[10] = { + {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__DescriptorProto_msg_init = { + &google_protobuf_DescriptorProto_submsgs[0], + &google_protobuf_DescriptorProto__fields[0], + UPB_SIZE(56, 104), 10, kUpb_ExtMode_NonExtendable, 10, UPB_FASTTABLE_MASK(120), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.DescriptorProto", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x002000003f000012, &upb_prm_1bt_max128b}, + {0x002800003f01001a, &upb_prm_1bt_max128b}, + {0x003000003f020022, &upb_prm_1bt_max128b}, + {0x003800003f03002a, &upb_prm_1bt_max64b}, + {0x004000003f040032, &upb_prm_1bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x005000003f060042, &upb_prm_1bt_max64b}, + {0x005800003f07004a, &upb_prm_1bt_max64b}, + {0x006000003f000052, &upb_prs_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_DescriptorProto_ExtensionRange_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__ExtensionRangeOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_DescriptorProto_ExtensionRange__fields[3] = { + {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__DescriptorProto__ExtensionRange_msg_init = { + &google_protobuf_DescriptorProto_ExtensionRange_submsgs[0], + &google_protobuf_DescriptorProto_ExtensionRange__fields[0], + UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.DescriptorProto.ExtensionRange", +#endif +}; + +static const upb_MiniTableField google_protobuf_DescriptorProto_ReservedRange__fields[2] = { + {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__DescriptorProto__ReservedRange_msg_init = { + NULL, + &google_protobuf_DescriptorProto_ReservedRange__fields[0], + 24, 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.DescriptorProto.ReservedRange", +#endif +}; + +static const upb_MiniTableSub google_protobuf_ExtensionRangeOptions_submsgs[4] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__ExtensionRangeOptions__Declaration_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_ExtensionRangeOptions_VerificationState_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_ExtensionRangeOptions__fields[4] = { + {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__ExtensionRangeOptions_msg_init = { + &google_protobuf_ExtensionRangeOptions_submsgs[0], + &google_protobuf_ExtensionRangeOptions__fields[0], + UPB_SIZE(32, 40), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.ExtensionRangeOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f000012, &upb_prm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x002000003f023eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableField google_protobuf_ExtensionRangeOptions_Declaration__fields[5] = { + {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__ExtensionRangeOptions__Declaration_msg_init = { + NULL, + &google_protobuf_ExtensionRangeOptions_Declaration__fields[0], + UPB_SIZE(40, 56), 5, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.ExtensionRangeOptions.Declaration", +#endif +}; + +static const upb_MiniTableSub google_protobuf_FieldDescriptorProto_submsgs[3] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FieldDescriptorProto_Label_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FieldDescriptorProto_Type_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FieldDescriptorProto__fields[11] = { + {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {5, 20, 68, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(52, 64), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(60, 80), 70, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(24, 96), 71, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {9, UPB_SIZE(28, 24), 72, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {10, UPB_SIZE(68, 104), 73, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {17, UPB_SIZE(32, 28), 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FieldDescriptorProto_msg_init = { + &google_protobuf_FieldDescriptorProto_submsgs[0], + &google_protobuf_FieldDescriptorProto__fields[0], + UPB_SIZE(80, 120), 11, kUpb_ExtMode_NonExtendable, 10, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FieldDescriptorProto", +#endif +}; + +static const upb_MiniTableSub google_protobuf_OneofDescriptorProto_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__OneofOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_OneofDescriptorProto__fields[2] = { + {1, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(12, 32), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__OneofDescriptorProto_msg_init = { + &google_protobuf_OneofDescriptorProto_submsgs[0], + &google_protobuf_OneofDescriptorProto__fields[0], + UPB_SIZE(24, 40), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.OneofDescriptorProto", +#endif +}; + +static const upb_MiniTableSub google_protobuf_EnumDescriptorProto_submsgs[3] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__EnumValueDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__EnumOptions_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumDescriptorProto__fields[5] = { + {1, UPB_SIZE(28, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__EnumDescriptorProto_msg_init = { + &google_protobuf_EnumDescriptorProto_submsgs[0], + &google_protobuf_EnumDescriptorProto__fields[0], + UPB_SIZE(40, 64), 5, kUpb_ExtMode_NonExtendable, 5, UPB_FASTTABLE_MASK(56), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.EnumDescriptorProto", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x002000003f000012, &upb_prm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x003000003f020022, &upb_prm_1bt_max64b}, + {0x003800003f00002a, &upb_prs_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableField google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[2] = { + {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init = { + NULL, + &google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[0], + 24, 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.EnumDescriptorProto.EnumReservedRange", +#endif +}; + +static const upb_MiniTableSub google_protobuf_EnumValueDescriptorProto_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__EnumValueOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumValueDescriptorProto__fields[3] = { + {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, 12, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 32), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__EnumValueDescriptorProto_msg_init = { + &google_protobuf_EnumValueDescriptorProto_submsgs[0], + &google_protobuf_EnumValueDescriptorProto__fields[0], + UPB_SIZE(32, 40), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.EnumValueDescriptorProto", +#endif +}; + +static const upb_MiniTableSub google_protobuf_ServiceDescriptorProto_submsgs[2] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__MethodDescriptorProto_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__ServiceOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_ServiceDescriptorProto__fields[3] = { + {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__ServiceDescriptorProto_msg_init = { + &google_protobuf_ServiceDescriptorProto_submsgs[0], + &google_protobuf_ServiceDescriptorProto__fields[0], + UPB_SIZE(32, 48), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(24), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.ServiceDescriptorProto", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x002000003f000012, &upb_prm_1bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_MethodDescriptorProto_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__MethodOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_MethodDescriptorProto__fields[6] = { + {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(28, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(36, 48), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(12, 64), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(16, 9), 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(17, 10), 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__MethodDescriptorProto_msg_init = { + &google_protobuf_MethodDescriptorProto_submsgs[0], + &google_protobuf_MethodDescriptorProto__fields[0], + UPB_SIZE(48, 72), 6, kUpb_ExtMode_NonExtendable, 6, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.MethodDescriptorProto", +#endif +}; + +static const upb_MiniTableSub google_protobuf_FileOptions_submsgs[3] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FileOptions_OptimizeMode_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FileOptions__fields[21] = { + {1, UPB_SIZE(32, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {8, 40, 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {9, 12, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {10, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {11, UPB_SIZE(48, 56), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {16, 17, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {17, 18, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {18, 19, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {20, 20, 72, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {23, 21, 73, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {27, 22, 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {31, 23, 75, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {36, UPB_SIZE(56, 72), 76, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {37, UPB_SIZE(64, 88), 77, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {39, UPB_SIZE(72, 104), 78, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {40, UPB_SIZE(80, 120), 79, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {41, UPB_SIZE(88, 136), 80, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {44, UPB_SIZE(96, 152), 81, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {45, UPB_SIZE(104, 168), 82, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {50, UPB_SIZE(24, 184), 83, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FileOptions_msg_init = { + &google_protobuf_FileOptions_submsgs[0], + &google_protobuf_FileOptions__fields[0], + UPB_SIZE(112, 200), 21, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FileOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x00c000003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_MessageOptions_submsgs[2] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_MessageOptions__fields[7] = { + {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {2, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {3, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {7, 12, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {11, 13, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {12, 16, 69, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__MessageOptions_msg_init = { + &google_protobuf_MessageOptions_submsgs[0], + &google_protobuf_MessageOptions__fields[0], + UPB_SIZE(24, 32), 7, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.MessageOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FieldOptions_submsgs[8] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions__EditionDefault_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions__FeatureSupport_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_CType_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_JSType_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_OptionRetention_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_OptionTargetType_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FieldOptions__fields[14] = { + {1, 12, 64, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 16, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {3, 17, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {5, 18, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, 20, 68, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {10, 24, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {15, 25, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {16, 26, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {17, 28, 72, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {21, UPB_SIZE(40, 48), 73, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {22, UPB_SIZE(44, 56), 74, 2, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FieldOptions_msg_init = { + &google_protobuf_FieldOptions_submsgs[0], + &google_protobuf_FieldOptions__fields[0], + UPB_SIZE(56, 72), 14, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FieldOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x002800003f0001a2, &upb_prm_2bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x004000003f033eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FieldOptions_EditionDefault_submsgs[1] = { + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FieldOptions_EditionDefault__fields[2] = { + {2, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, 12, 65, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FieldOptions__EditionDefault_msg_init = { + &google_protobuf_FieldOptions_EditionDefault_submsgs[0], + &google_protobuf_FieldOptions_EditionDefault__fields[0], + UPB_SIZE(24, 32), 2, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FieldOptions.EditionDefault", +#endif +}; + +static const upb_MiniTableSub google_protobuf_FieldOptions_FeatureSupport_submsgs[3] = { + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FieldOptions_FeatureSupport__fields[4] = { + {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {3, 24, 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {4, 20, 67, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FieldOptions__FeatureSupport_msg_init = { + &google_protobuf_FieldOptions_FeatureSupport_submsgs[0], + &google_protobuf_FieldOptions_FeatureSupport__fields[0], + UPB_SIZE(32, 40), 4, kUpb_ExtMode_NonExtendable, 4, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FieldOptions.FeatureSupport", +#endif +}; + +static const upb_MiniTableSub google_protobuf_OneofOptions_submsgs[2] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_OneofOptions__fields[2] = { + {1, UPB_SIZE(12, 16), 64, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__OneofOptions_msg_init = { + &google_protobuf_OneofOptions_submsgs[0], + &google_protobuf_OneofOptions__fields[0], + UPB_SIZE(24, 32), 2, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.OneofOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_EnumOptions_submsgs[2] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumOptions__fields[5] = { + {2, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {3, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(12, 16), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__EnumOptions_msg_init = { + &google_protobuf_EnumOptions_submsgs[0], + &google_protobuf_EnumOptions__fields[0], + UPB_SIZE(24, 32), 5, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.EnumOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_EnumValueOptions_submsgs[3] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions__FeatureSupport_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumValueOptions__fields[5] = { + {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 10), 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(20, 24), 67, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__EnumValueOptions_msg_init = { + &google_protobuf_EnumValueOptions_submsgs[0], + &google_protobuf_EnumValueOptions__fields[0], + UPB_SIZE(32, 40), 5, kUpb_ExtMode_Extendable, 4, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.EnumValueOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x002000003f023eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_ServiceOptions_submsgs[2] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_ServiceOptions__fields[3] = { + {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {34, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__ServiceOptions_msg_init = { + &google_protobuf_ServiceOptions_submsgs[0], + &google_protobuf_ServiceOptions__fields[0], + UPB_SIZE(24, 32), 3, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.ServiceOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_MethodOptions_submsgs[3] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_MethodOptions_IdempotencyLevel_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_MethodOptions__fields[4] = { + {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {34, 12, 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {35, 16, 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__MethodOptions_msg_init = { + &google_protobuf_MethodOptions_submsgs[0], + &google_protobuf_MethodOptions__fields[0], + UPB_SIZE(24, 32), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.MethodOptions", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_UninterpretedOption_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption__NamePart_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_UninterpretedOption__fields[7] = { + {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(24, 40), 65, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(32, 48), 66, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(40, 56), 67, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(48, 64), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(56, 80), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__UninterpretedOption_msg_init = { + &google_protobuf_UninterpretedOption_submsgs[0], + &google_protobuf_UninterpretedOption__fields[0], + UPB_SIZE(64, 96), 7, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(24), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.UninterpretedOption", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f000012, &upb_prm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableField google_protobuf_UninterpretedOption_NamePart__fields[2] = { + {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, 9, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__UninterpretedOption__NamePart_msg_init = { + NULL, + &google_protobuf_UninterpretedOption_NamePart__fields[0], + UPB_SIZE(24, 32), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 2, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.UninterpretedOption.NamePart", +#endif +}; + +static const upb_MiniTableSub google_protobuf_FeatureSet_submsgs[6] = { + {.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_FieldPresence_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_EnumType_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_Utf8Validation_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_MessageEncoding_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_JsonFormat_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FeatureSet__fields[6] = { + {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {3, 20, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {4, 24, 67, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {5, 28, 68, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {6, 32, 69, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FeatureSet_msg_init = { + &google_protobuf_FeatureSet_submsgs[0], + &google_protobuf_FeatureSet__fields[0], + 40, 6, kUpb_ExtMode_Extendable, 6, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FeatureSet", +#endif +}; + +static const upb_MiniTableSub google_protobuf_FeatureSetDefaults_submsgs[3] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FeatureSetDefaults__fields[3] = { + {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(16, 12), 64, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(20, 16), 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FeatureSetDefaults_msg_init = { + &google_protobuf_FeatureSetDefaults_submsgs[0], + &google_protobuf_FeatureSetDefaults__fields[0], + UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FeatureSetDefaults", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f00000a, &upb_prm_1bt_max64b}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_submsgs[3] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init}, + {.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault__fields[3] = { + {3, 12, 64, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {4, 16, 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(20, 24), 66, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init = { + &google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_submsgs[0], + &google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault__fields[0], + UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(255), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault", +#endif +}; + +static const upb_MiniTableSub google_protobuf_SourceCodeInfo_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__SourceCodeInfo__Location_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_SourceCodeInfo__fields[1] = { + {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__SourceCodeInfo_msg_init = { + &google_protobuf_SourceCodeInfo_submsgs[0], + &google_protobuf_SourceCodeInfo__fields[0], + 16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.SourceCodeInfo", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800003f00000a, &upb_prm_1bt_max128b}, + }) +}; + +static const upb_MiniTableField google_protobuf_SourceCodeInfo_Location__fields[5] = { + {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(24, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(32, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__SourceCodeInfo__Location_msg_init = { + NULL, + &google_protobuf_SourceCodeInfo_Location__fields[0], + UPB_SIZE(40, 72), 5, kUpb_ExtMode_NonExtendable, 4, UPB_FASTTABLE_MASK(56), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.SourceCodeInfo.Location", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f00000a, &upb_ppv4_1bt}, + {0x001800003f000012, &upb_ppv4_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x004000003f000032, &upb_prs_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_GeneratedCodeInfo_submsgs[1] = { + {.UPB_PRIVATE(submsg) = &google__protobuf__GeneratedCodeInfo__Annotation_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_GeneratedCodeInfo__fields[1] = { + {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__GeneratedCodeInfo_msg_init = { + &google_protobuf_GeneratedCodeInfo_submsgs[0], + &google_protobuf_GeneratedCodeInfo__fields[0], + 16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.GeneratedCodeInfo", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800003f00000a, &upb_prm_1bt_max64b}, + }) +}; + +static const upb_MiniTableSub google_protobuf_GeneratedCodeInfo_Annotation_submsgs[1] = { + {.UPB_PRIVATE(subenum) = &google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_GeneratedCodeInfo_Annotation__fields[5] = { + {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(28, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 12), 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(20, 16), 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(24, 20), 67, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google__protobuf__GeneratedCodeInfo__Annotation_msg_init = { + &google_protobuf_GeneratedCodeInfo_Annotation_submsgs[0], + &google_protobuf_GeneratedCodeInfo_Annotation__fields[0], + UPB_SIZE(40, 48), 5, kUpb_ExtMode_NonExtendable, 5, UPB_FASTTABLE_MASK(8), 0, +#ifdef UPB_TRACING_ENABLED + "google.protobuf.GeneratedCodeInfo.Annotation", +#endif + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f00000a, &upb_ppv4_1bt}, + }) +}; + +static const upb_MiniTable *messages_layout[33] = { + &google__protobuf__FileDescriptorSet_msg_init, + &google__protobuf__FileDescriptorProto_msg_init, + &google__protobuf__DescriptorProto_msg_init, + &google__protobuf__DescriptorProto__ExtensionRange_msg_init, + &google__protobuf__DescriptorProto__ReservedRange_msg_init, + &google__protobuf__ExtensionRangeOptions_msg_init, + &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, + &google__protobuf__FieldDescriptorProto_msg_init, + &google__protobuf__OneofDescriptorProto_msg_init, + &google__protobuf__EnumDescriptorProto_msg_init, + &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init, + &google__protobuf__EnumValueDescriptorProto_msg_init, + &google__protobuf__ServiceDescriptorProto_msg_init, + &google__protobuf__MethodDescriptorProto_msg_init, + &google__protobuf__FileOptions_msg_init, + &google__protobuf__MessageOptions_msg_init, + &google__protobuf__FieldOptions_msg_init, + &google__protobuf__FieldOptions__EditionDefault_msg_init, + &google__protobuf__FieldOptions__FeatureSupport_msg_init, + &google__protobuf__OneofOptions_msg_init, + &google__protobuf__EnumOptions_msg_init, + &google__protobuf__EnumValueOptions_msg_init, + &google__protobuf__ServiceOptions_msg_init, + &google__protobuf__MethodOptions_msg_init, + &google__protobuf__UninterpretedOption_msg_init, + &google__protobuf__UninterpretedOption__NamePart_msg_init, + &google__protobuf__FeatureSet_msg_init, + &google__protobuf__FeatureSetDefaults_msg_init, + &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init, + &google__protobuf__SourceCodeInfo_msg_init, + &google__protobuf__SourceCodeInfo__Location_msg_init, + &google__protobuf__GeneratedCodeInfo_msg_init, + &google__protobuf__GeneratedCodeInfo__Annotation_msg_init, +}; + +const upb_MiniTableEnum google_protobuf_Edition_enum_init = { + 64, + 9, + { + 0x7, + 0x0, + 0x384, + 0x3e6, + 0x3e7, + 0x3e8, + 0x3e9, + 0x1869d, + 0x1869e, + 0x1869f, + 0x7fffffff, + }, +}; + +const upb_MiniTableEnum google_protobuf_ExtensionRangeOptions_VerificationState_enum_init = { + 64, + 0, + { + 0x3, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_EnumType_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_FieldPresence_enum_init = { + 64, + 0, + { + 0xf, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_JsonFormat_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_MessageEncoding_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_Utf8Validation_enum_init = { + 64, + 0, + { + 0xd, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Label_enum_init = { + 64, + 0, + { + 0xe, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Type_enum_init = { + 64, + 0, + { + 0x7fffe, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_CType_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_JSType_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_OptionRetention_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_OptionTargetType_enum_init = { + 64, + 0, + { + 0x3ff, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FileOptions_OptimizeMode_enum_init = { + 64, + 0, + { + 0xe, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_MethodOptions_IdempotencyLevel_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +static const upb_MiniTableEnum *enums_layout[17] = { + &google_protobuf_Edition_enum_init, + &google_protobuf_ExtensionRangeOptions_VerificationState_enum_init, + &google_protobuf_FeatureSet_EnumType_enum_init, + &google_protobuf_FeatureSet_FieldPresence_enum_init, + &google_protobuf_FeatureSet_JsonFormat_enum_init, + &google_protobuf_FeatureSet_MessageEncoding_enum_init, + &google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init, + &google_protobuf_FeatureSet_Utf8Validation_enum_init, + &google_protobuf_FieldDescriptorProto_Label_enum_init, + &google_protobuf_FieldDescriptorProto_Type_enum_init, + &google_protobuf_FieldOptions_CType_enum_init, + &google_protobuf_FieldOptions_JSType_enum_init, + &google_protobuf_FieldOptions_OptionRetention_enum_init, + &google_protobuf_FieldOptions_OptionTargetType_enum_init, + &google_protobuf_FileOptions_OptimizeMode_enum_init, + &google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init, + &google_protobuf_MethodOptions_IdempotencyLevel_enum_init, +}; + +const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout = { + messages_layout, + enums_layout, + NULL, + 33, + 17, + 0, +}; + + + + + +static const char* _upb_EpsCopyInputStream_NoOpCallback( + upb_EpsCopyInputStream* e, const char* old_end, const char* new_start) { + return new_start; +} + +const char* _upb_EpsCopyInputStream_IsDoneFallbackNoCallback( + upb_EpsCopyInputStream* e, const char* ptr, int overrun) { + return _upb_EpsCopyInputStream_IsDoneFallbackInline( + e, ptr, overrun, _upb_EpsCopyInputStream_NoOpCallback); +} + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// Must be last. + +typedef struct { + const char *ptr, *end; + upb_Arena* arena; /* TODO: should we have a tmp arena for tmp data? */ + const upb_DefPool* symtab; + int depth; + upb_Status* status; + jmp_buf err; + int line; + const char* line_begin; + bool is_first; + int options; + const upb_FieldDef* debug_field; +} jsondec; + +typedef struct { + upb_MessageValue value; + bool ignore; +} upb_JsonMessageValue; + +enum { JD_OBJECT, JD_ARRAY, JD_STRING, JD_NUMBER, JD_TRUE, JD_FALSE, JD_NULL }; + +/* Forward declarations of mutually-recursive functions. */ +static void jsondec_wellknown(jsondec* d, upb_Message* msg, + const upb_MessageDef* m); +static upb_JsonMessageValue jsondec_value(jsondec* d, const upb_FieldDef* f); +static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg, + const upb_MessageDef* m); +static void jsondec_object(jsondec* d, upb_Message* msg, + const upb_MessageDef* m); + +static bool jsondec_streql(upb_StringView str, const char* lit) { + return str.size == strlen(lit) && memcmp(str.data, lit, str.size) == 0; +} + +static bool jsondec_isnullvalue(const upb_FieldDef* f) { + return upb_FieldDef_CType(f) == kUpb_CType_Enum && + strcmp(upb_EnumDef_FullName(upb_FieldDef_EnumSubDef(f)), + "google.protobuf.NullValue") == 0; +} + +static bool jsondec_isvalue(const upb_FieldDef* f) { + return (upb_FieldDef_CType(f) == kUpb_CType_Message && + upb_MessageDef_WellKnownType(upb_FieldDef_MessageSubDef(f)) == + kUpb_WellKnown_Value) || + jsondec_isnullvalue(f); +} + +static void jsondec_seterrmsg(jsondec* d, const char* msg) { + upb_Status_SetErrorFormat(d->status, "Error parsing JSON @%d:%d: %s", d->line, + (int)(d->ptr - d->line_begin), msg); +} + +UPB_NORETURN static void jsondec_err(jsondec* d, const char* msg) { + jsondec_seterrmsg(d, msg); + UPB_LONGJMP(d->err, 1); +} + +UPB_PRINTF(2, 3) +UPB_NORETURN static void jsondec_errf(jsondec* d, const char* fmt, ...) { + va_list argp; + upb_Status_SetErrorFormat(d->status, "Error parsing JSON @%d:%d: ", d->line, + (int)(d->ptr - d->line_begin)); + va_start(argp, fmt); + upb_Status_VAppendErrorFormat(d->status, fmt, argp); + va_end(argp); + UPB_LONGJMP(d->err, 1); +} + +// Advances d->ptr until the next non-whitespace character or to the end of +// the buffer. +static void jsondec_consumews(jsondec* d) { + while (d->ptr != d->end) { + switch (*d->ptr) { + case '\n': + d->line++; + d->line_begin = d->ptr; + /* Fallthrough. */ + case '\r': + case '\t': + case ' ': + d->ptr++; + break; + default: + return; + } + } +} + +// Advances d->ptr until the next non-whitespace character. Postcondition that +// d->ptr is pointing at a valid non-whitespace character (will err if end of +// buffer is reached). +static void jsondec_skipws(jsondec* d) { + jsondec_consumews(d); + if (d->ptr == d->end) { + jsondec_err(d, "Unexpected EOF"); + } +} + +static bool jsondec_tryparsech(jsondec* d, char ch) { + if (d->ptr == d->end || *d->ptr != ch) return false; + d->ptr++; + return true; +} + +static void jsondec_parselit(jsondec* d, const char* lit) { + size_t avail = d->end - d->ptr; + size_t len = strlen(lit); + if (avail < len || memcmp(d->ptr, lit, len) != 0) { + jsondec_errf(d, "Expected: '%s'", lit); + } + d->ptr += len; +} + +static void jsondec_wsch(jsondec* d, char ch) { + jsondec_skipws(d); + if (!jsondec_tryparsech(d, ch)) { + jsondec_errf(d, "Expected: '%c'", ch); + } +} + +static void jsondec_true(jsondec* d) { jsondec_parselit(d, "true"); } +static void jsondec_false(jsondec* d) { jsondec_parselit(d, "false"); } +static void jsondec_null(jsondec* d) { jsondec_parselit(d, "null"); } + +static void jsondec_entrysep(jsondec* d) { + jsondec_skipws(d); + jsondec_parselit(d, ":"); +} + +static int jsondec_rawpeek(jsondec* d) { + if (d->ptr == d->end) { + jsondec_err(d, "Unexpected EOF"); + } + + switch (*d->ptr) { + case '{': + return JD_OBJECT; + case '[': + return JD_ARRAY; + case '"': + return JD_STRING; + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return JD_NUMBER; + case 't': + return JD_TRUE; + case 'f': + return JD_FALSE; + case 'n': + return JD_NULL; + default: + jsondec_errf(d, "Unexpected character: '%c'", *d->ptr); + } +} + +/* JSON object/array **********************************************************/ + +/* These are used like so: + * + * jsondec_objstart(d); + * while (jsondec_objnext(d)) { + * ... + * } + * jsondec_objend(d) */ + +static int jsondec_peek(jsondec* d) { + jsondec_skipws(d); + return jsondec_rawpeek(d); +} + +static void jsondec_push(jsondec* d) { + if (--d->depth < 0) { + jsondec_err(d, "Recursion limit exceeded"); + } + d->is_first = true; +} + +static bool jsondec_seqnext(jsondec* d, char end_ch) { + bool is_first = d->is_first; + d->is_first = false; + jsondec_skipws(d); + if (*d->ptr == end_ch) return false; + if (!is_first) jsondec_parselit(d, ","); + return true; +} + +static void jsondec_arrstart(jsondec* d) { + jsondec_push(d); + jsondec_wsch(d, '['); +} + +static void jsondec_arrend(jsondec* d) { + d->depth++; + jsondec_wsch(d, ']'); +} + +static bool jsondec_arrnext(jsondec* d) { return jsondec_seqnext(d, ']'); } + +static void jsondec_objstart(jsondec* d) { + jsondec_push(d); + jsondec_wsch(d, '{'); +} + +static void jsondec_objend(jsondec* d) { + d->depth++; + jsondec_wsch(d, '}'); +} + +static bool jsondec_objnext(jsondec* d) { + if (!jsondec_seqnext(d, '}')) return false; + if (jsondec_peek(d) != JD_STRING) { + jsondec_err(d, "Object must start with string"); + } + return true; +} + +/* JSON number ****************************************************************/ + +static bool jsondec_tryskipdigits(jsondec* d) { + const char* start = d->ptr; + + while (d->ptr < d->end) { + if (*d->ptr < '0' || *d->ptr > '9') { + break; + } + d->ptr++; + } + + return d->ptr != start; +} + +static void jsondec_skipdigits(jsondec* d) { + if (!jsondec_tryskipdigits(d)) { + jsondec_err(d, "Expected one or more digits"); + } +} + +static double jsondec_number(jsondec* d) { + const char* start = d->ptr; + + UPB_ASSERT(jsondec_rawpeek(d) == JD_NUMBER); + + /* Skip over the syntax of a number, as specified by JSON. */ + if (*d->ptr == '-') d->ptr++; + + if (jsondec_tryparsech(d, '0')) { + if (jsondec_tryskipdigits(d)) { + jsondec_err(d, "number cannot have leading zero"); + } + } else { + jsondec_skipdigits(d); + } + + if (d->ptr == d->end) goto parse; + if (jsondec_tryparsech(d, '.')) { + jsondec_skipdigits(d); + } + if (d->ptr == d->end) goto parse; + + if (*d->ptr == 'e' || *d->ptr == 'E') { + d->ptr++; + if (d->ptr == d->end) { + jsondec_err(d, "Unexpected EOF in number"); + } + if (*d->ptr == '+' || *d->ptr == '-') { + d->ptr++; + } + jsondec_skipdigits(d); + } + +parse: + /* Having verified the syntax of a JSON number, use strtod() to parse + * (strtod() accepts a superset of JSON syntax). */ + errno = 0; + { + // Copy the number into a null-terminated scratch buffer since strtod + // expects a null-terminated string. + char nullz[64]; + ptrdiff_t len = d->ptr - start; + if (len > (ptrdiff_t)(sizeof(nullz) - 1)) { + jsondec_err(d, "excessively long number"); + } + memcpy(nullz, start, len); + nullz[len] = '\0'; + + char* end; + double val = strtod(nullz, &end); + UPB_ASSERT(end - nullz == len); + + /* Currently the min/max-val conformance tests fail if we check this. Does + * this mean the conformance tests are wrong or strtod() is wrong, or + * something else? Investigate further. */ + /* + if (errno == ERANGE) { + jsondec_err(d, "Number out of range"); + } + */ + + if (val > DBL_MAX || val < -DBL_MAX) { + jsondec_err(d, "Number out of range"); + } + + return val; + } +} + +/* JSON string ****************************************************************/ + +static char jsondec_escape(jsondec* d) { + switch (*d->ptr++) { + case '"': + return '\"'; + case '\\': + return '\\'; + case '/': + return '/'; + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + default: + jsondec_err(d, "Invalid escape char"); + } +} + +static uint32_t jsondec_codepoint(jsondec* d) { + uint32_t cp = 0; + const char* end; + + if (d->end - d->ptr < 4) { + jsondec_err(d, "EOF inside string"); + } + + end = d->ptr + 4; + while (d->ptr < end) { + char ch = *d->ptr++; + if (ch >= '0' && ch <= '9') { + ch -= '0'; + } else if (ch >= 'a' && ch <= 'f') { + ch = ch - 'a' + 10; + } else if (ch >= 'A' && ch <= 'F') { + ch = ch - 'A' + 10; + } else { + jsondec_err(d, "Invalid hex digit"); + } + cp = (cp << 4) | ch; + } + + return cp; +} + +/* Parses a \uXXXX unicode escape (possibly a surrogate pair). */ +static size_t jsondec_unicode(jsondec* d, char* out) { + uint32_t cp = jsondec_codepoint(d); + if (upb_Unicode_IsHigh(cp)) { + /* Surrogate pair: two 16-bit codepoints become a 32-bit codepoint. */ + jsondec_parselit(d, "\\u"); + uint32_t low = jsondec_codepoint(d); + if (!upb_Unicode_IsLow(low)) jsondec_err(d, "Invalid low surrogate"); + cp = upb_Unicode_FromPair(cp, low); + } else if (upb_Unicode_IsLow(cp)) { + jsondec_err(d, "Unpaired low surrogate"); + } + + /* Write to UTF-8 */ + int bytes = upb_Unicode_ToUTF8(cp, out); + if (bytes == 0) jsondec_err(d, "Invalid codepoint"); + return bytes; +} + +static void jsondec_resize(jsondec* d, char** buf, char** end, char** buf_end) { + size_t oldsize = *buf_end - *buf; + size_t len = *end - *buf; + size_t size = UPB_MAX(8, 2 * oldsize); + + *buf = upb_Arena_Realloc(d->arena, *buf, len, size); + if (!*buf) jsondec_err(d, "Out of memory"); + + *end = *buf + len; + *buf_end = *buf + size; +} + +static upb_StringView jsondec_string(jsondec* d) { + char* buf = NULL; + char* end = NULL; + char* buf_end = NULL; + + jsondec_skipws(d); + + if (*d->ptr++ != '"') { + jsondec_err(d, "Expected string"); + } + + while (d->ptr < d->end) { + char ch = *d->ptr++; + + if (end == buf_end) { + jsondec_resize(d, &buf, &end, &buf_end); + } + + switch (ch) { + case '"': { + upb_StringView ret; + ret.data = buf; + ret.size = end - buf; + *end = '\0'; /* Needed for possible strtod(). */ + return ret; + } + case '\\': + if (d->ptr == d->end) goto eof; + if (*d->ptr == 'u') { + d->ptr++; + if (buf_end - end < 4) { + /* Allow space for maximum-sized codepoint (4 bytes). */ + jsondec_resize(d, &buf, &end, &buf_end); + } + end += jsondec_unicode(d, end); + } else { + *end++ = jsondec_escape(d); + } + break; + default: + if ((unsigned char)ch < 0x20) { + jsondec_err(d, "Invalid char in JSON string"); + } + *end++ = ch; + break; + } + } + +eof: + jsondec_err(d, "EOF inside string"); +} + +static void jsondec_skipval(jsondec* d) { + switch (jsondec_peek(d)) { + case JD_OBJECT: + jsondec_objstart(d); + while (jsondec_objnext(d)) { + jsondec_string(d); + jsondec_entrysep(d); + jsondec_skipval(d); + } + jsondec_objend(d); + break; + case JD_ARRAY: + jsondec_arrstart(d); + while (jsondec_arrnext(d)) { + jsondec_skipval(d); + } + jsondec_arrend(d); + break; + case JD_TRUE: + jsondec_true(d); + break; + case JD_FALSE: + jsondec_false(d); + break; + case JD_NULL: + jsondec_null(d); + break; + case JD_STRING: + jsondec_string(d); + break; + case JD_NUMBER: + jsondec_number(d); + break; + } +} + +/* Base64 decoding for bytes fields. ******************************************/ + +static unsigned int jsondec_base64_tablelookup(const char ch) { + /* Table includes the normal base64 chars plus the URL-safe variant. */ + const signed char table[256] = { + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, 62 /*+*/, -1, 62 /*-*/, -1, 63 /*/ */, 52 /*0*/, + 53 /*1*/, 54 /*2*/, 55 /*3*/, 56 /*4*/, 57 /*5*/, 58 /*6*/, 59 /*7*/, + 60 /*8*/, 61 /*9*/, -1, -1, -1, -1, -1, + -1, -1, 0 /*A*/, 1 /*B*/, 2 /*C*/, 3 /*D*/, 4 /*E*/, + 5 /*F*/, 6 /*G*/, 07 /*H*/, 8 /*I*/, 9 /*J*/, 10 /*K*/, 11 /*L*/, + 12 /*M*/, 13 /*N*/, 14 /*O*/, 15 /*P*/, 16 /*Q*/, 17 /*R*/, 18 /*S*/, + 19 /*T*/, 20 /*U*/, 21 /*V*/, 22 /*W*/, 23 /*X*/, 24 /*Y*/, 25 /*Z*/, + -1, -1, -1, -1, 63 /*_*/, -1, 26 /*a*/, + 27 /*b*/, 28 /*c*/, 29 /*d*/, 30 /*e*/, 31 /*f*/, 32 /*g*/, 33 /*h*/, + 34 /*i*/, 35 /*j*/, 36 /*k*/, 37 /*l*/, 38 /*m*/, 39 /*n*/, 40 /*o*/, + 41 /*p*/, 42 /*q*/, 43 /*r*/, 44 /*s*/, 45 /*t*/, 46 /*u*/, 47 /*v*/, + 48 /*w*/, 49 /*x*/, 50 /*y*/, 51 /*z*/, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1}; + + /* Sign-extend return value so high bit will be set on any unexpected char. */ + return table[(unsigned)ch]; +} + +static char* jsondec_partialbase64(jsondec* d, const char* ptr, const char* end, + char* out) { + int32_t val = -1; + + switch (end - ptr) { + case 2: + val = jsondec_base64_tablelookup(ptr[0]) << 18 | + jsondec_base64_tablelookup(ptr[1]) << 12; + out[0] = val >> 16; + out += 1; + break; + case 3: + val = jsondec_base64_tablelookup(ptr[0]) << 18 | + jsondec_base64_tablelookup(ptr[1]) << 12 | + jsondec_base64_tablelookup(ptr[2]) << 6; + out[0] = val >> 16; + out[1] = (val >> 8) & 0xff; + out += 2; + break; + } + + if (val < 0) { + jsondec_err(d, "Corrupt base64"); + } + + return out; +} + +static size_t jsondec_base64(jsondec* d, upb_StringView str) { + /* We decode in place. This is safe because this is a new buffer (not + * aliasing the input) and because base64 decoding shrinks 4 bytes into 3. */ + char* out = (char*)str.data; + const char* ptr = str.data; + const char* end = ptr + str.size; + const char* end4 = ptr + (str.size & -4); /* Round down to multiple of 4. */ + + for (; ptr < end4; ptr += 4, out += 3) { + int val = jsondec_base64_tablelookup(ptr[0]) << 18 | + jsondec_base64_tablelookup(ptr[1]) << 12 | + jsondec_base64_tablelookup(ptr[2]) << 6 | + jsondec_base64_tablelookup(ptr[3]) << 0; + + if (val < 0) { + /* Junk chars or padding. Remove trailing padding, if any. */ + if (end - ptr == 4 && ptr[3] == '=') { + if (ptr[2] == '=') { + end -= 2; + } else { + end -= 1; + } + } + break; + } + + out[0] = val >> 16; + out[1] = (val >> 8) & 0xff; + out[2] = val & 0xff; + } + + if (ptr < end) { + /* Process remaining chars. We do not require padding. */ + out = jsondec_partialbase64(d, ptr, end, out); + } + + return out - str.data; +} + +/* Low-level integer parsing **************************************************/ + +static const char* jsondec_buftouint64(jsondec* d, const char* ptr, + const char* end, uint64_t* val) { + const char* out = upb_BufToUint64(ptr, end, val); + if (!out) jsondec_err(d, "Integer overflow"); + return out; +} + +static const char* jsondec_buftoint64(jsondec* d, const char* ptr, + const char* end, int64_t* val, + bool* is_neg) { + const char* out = upb_BufToInt64(ptr, end, val, is_neg); + if (!out) jsondec_err(d, "Integer overflow"); + return out; +} + +static uint64_t jsondec_strtouint64(jsondec* d, upb_StringView str) { + const char* end = str.data + str.size; + uint64_t ret; + if (jsondec_buftouint64(d, str.data, end, &ret) != end) { + jsondec_err(d, "Non-number characters in quoted integer"); + } + return ret; +} + +static int64_t jsondec_strtoint64(jsondec* d, upb_StringView str) { + const char* end = str.data + str.size; + int64_t ret; + if (jsondec_buftoint64(d, str.data, end, &ret, NULL) != end) { + jsondec_err(d, "Non-number characters in quoted integer"); + } + return ret; +} + +/* Primitive value types ******************************************************/ + +/* Parse INT32 or INT64 value. */ +static upb_MessageValue jsondec_int(jsondec* d, const upb_FieldDef* f) { + upb_MessageValue val; + + switch (jsondec_peek(d)) { + case JD_NUMBER: { + double dbl = jsondec_number(d); + if (dbl > 9223372036854774784.0 || dbl < -9223372036854775808.0) { + jsondec_err(d, "JSON number is out of range."); + } + val.int64_val = dbl; /* must be guarded, overflow here is UB */ + if (val.int64_val != dbl) { + jsondec_errf(d, "JSON number was not integral (%f != %" PRId64 ")", dbl, + val.int64_val); + } + break; + } + case JD_STRING: { + upb_StringView str = jsondec_string(d); + val.int64_val = jsondec_strtoint64(d, str); + break; + } + default: + jsondec_err(d, "Expected number or string"); + } + + if (upb_FieldDef_CType(f) == kUpb_CType_Int32 || + upb_FieldDef_CType(f) == kUpb_CType_Enum) { + if (val.int64_val > INT32_MAX || val.int64_val < INT32_MIN) { + jsondec_err(d, "Integer out of range."); + } + val.int32_val = (int32_t)val.int64_val; + } + + return val; +} + +/* Parse UINT32 or UINT64 value. */ +static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) { + upb_MessageValue val = {0}; + + switch (jsondec_peek(d)) { + case JD_NUMBER: { + double dbl = jsondec_number(d); + if (dbl > 18446744073709549568.0 || dbl < 0) { + jsondec_err(d, "JSON number is out of range."); + } + val.uint64_val = dbl; /* must be guarded, overflow here is UB */ + if (val.uint64_val != dbl) { + jsondec_errf(d, "JSON number was not integral (%f != %" PRIu64 ")", dbl, + val.uint64_val); + } + break; + } + case JD_STRING: { + upb_StringView str = jsondec_string(d); + val.uint64_val = jsondec_strtouint64(d, str); + break; + } + default: + jsondec_err(d, "Expected number or string"); + } + + if (upb_FieldDef_CType(f) == kUpb_CType_UInt32) { + if (val.uint64_val > UINT32_MAX) { + jsondec_err(d, "Integer out of range."); + } + val.uint32_val = (uint32_t)val.uint64_val; + } + + return val; +} + +/* Parse DOUBLE or FLOAT value. */ +static upb_MessageValue jsondec_double(jsondec* d, const upb_FieldDef* f) { + upb_StringView str; + upb_MessageValue val = {0}; + + switch (jsondec_peek(d)) { + case JD_NUMBER: + val.double_val = jsondec_number(d); + break; + case JD_STRING: + str = jsondec_string(d); + if (jsondec_streql(str, "NaN")) { + val.double_val = NAN; + } else if (jsondec_streql(str, "Infinity")) { + val.double_val = INFINITY; + } else if (jsondec_streql(str, "-Infinity")) { + val.double_val = -INFINITY; + } else { + val.double_val = strtod(str.data, NULL); + } + break; + default: + jsondec_err(d, "Expected number or string"); + } + + if (upb_FieldDef_CType(f) == kUpb_CType_Float) { + float f = val.double_val; + if (val.double_val != INFINITY && val.double_val != -INFINITY) { + if (f == INFINITY || f == -INFINITY) jsondec_err(d, "Float out of range"); + } + val.float_val = f; + } + + return val; +} + +/* Parse STRING or BYTES value. */ +static upb_MessageValue jsondec_strfield(jsondec* d, const upb_FieldDef* f) { + upb_MessageValue val; + val.str_val = jsondec_string(d); + if (upb_FieldDef_CType(f) == kUpb_CType_Bytes) { + val.str_val.size = jsondec_base64(d, val.str_val); + } + return val; +} + +static upb_JsonMessageValue jsondec_enum(jsondec* d, const upb_FieldDef* f) { + switch (jsondec_peek(d)) { + case JD_STRING: { + upb_StringView str = jsondec_string(d); + const upb_EnumDef* e = upb_FieldDef_EnumSubDef(f); + const upb_EnumValueDef* ev = + upb_EnumDef_FindValueByNameWithSize(e, str.data, str.size); + upb_JsonMessageValue val = {.ignore = false}; + if (ev) { + val.value.int32_val = upb_EnumValueDef_Number(ev); + } else { + if (d->options & upb_JsonDecode_IgnoreUnknown) { + val.ignore = true; + } else { + jsondec_errf(d, "Unknown enumerator: '" UPB_STRINGVIEW_FORMAT "'", + UPB_STRINGVIEW_ARGS(str)); + } + } + return val; + } + case JD_NULL: { + if (jsondec_isnullvalue(f)) { + upb_JsonMessageValue val = {.ignore = false}; + jsondec_null(d); + val.value.int32_val = 0; + return val; + } + } + /* Fallthrough. */ + default: + return (upb_JsonMessageValue){.value = jsondec_int(d, f), + .ignore = false}; + } +} + +static upb_MessageValue jsondec_bool(jsondec* d, const upb_FieldDef* f) { + bool is_map_key = upb_FieldDef_Number(f) == 1 && + upb_MessageDef_IsMapEntry(upb_FieldDef_ContainingType(f)); + upb_MessageValue val; + + if (is_map_key) { + upb_StringView str = jsondec_string(d); + if (jsondec_streql(str, "true")) { + val.bool_val = true; + } else if (jsondec_streql(str, "false")) { + val.bool_val = false; + } else { + jsondec_err(d, "Invalid boolean map key"); + } + } else { + switch (jsondec_peek(d)) { + case JD_TRUE: + val.bool_val = true; + jsondec_true(d); + break; + case JD_FALSE: + val.bool_val = false; + jsondec_false(d); + break; + default: + jsondec_err(d, "Expected true or false"); + } + } + + return val; +} + +/* Composite types (array/message/map) ****************************************/ + +static void jsondec_array(jsondec* d, upb_Message* msg, const upb_FieldDef* f) { + upb_Array* arr = upb_Message_Mutable(msg, f, d->arena).array; + + jsondec_arrstart(d); + while (jsondec_arrnext(d)) { + upb_JsonMessageValue elem = jsondec_value(d, f); + if (!elem.ignore) { + upb_Array_Append(arr, elem.value, d->arena); + } + } + jsondec_arrend(d); +} + +static void jsondec_map(jsondec* d, upb_Message* msg, const upb_FieldDef* f) { + upb_Map* map = upb_Message_Mutable(msg, f, d->arena).map; + const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f); + const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry, 1); + const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry, 2); + + jsondec_objstart(d); + while (jsondec_objnext(d)) { + upb_JsonMessageValue key, val; + key = jsondec_value(d, key_f); + UPB_ASSUME(!key.ignore); // Map key cannot be enum. + jsondec_entrysep(d); + val = jsondec_value(d, val_f); + if (!val.ignore) { + upb_Map_Set(map, key.value, val.value, d->arena); + } + } + jsondec_objend(d); +} + +static void jsondec_tomsg(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + if (upb_MessageDef_WellKnownType(m) == kUpb_WellKnown_Unspecified) { + jsondec_object(d, msg, m); + } else { + jsondec_wellknown(d, msg, m); + } +} + +static upb_MessageValue jsondec_msg(jsondec* d, const upb_FieldDef* f) { + const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f); + const upb_MiniTable* layout = upb_MessageDef_MiniTable(m); + upb_Message* msg = upb_Message_New(layout, d->arena); + upb_MessageValue val; + + jsondec_tomsg(d, msg, m); + val.msg_val = msg; + return val; +} + +static void jsondec_field(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + upb_StringView name; + const upb_FieldDef* f; + const upb_FieldDef* preserved; + + name = jsondec_string(d); + jsondec_entrysep(d); + + if (name.size >= 2 && name.data[0] == '[' && + name.data[name.size - 1] == ']') { + f = upb_DefPool_FindExtensionByNameWithSize(d->symtab, name.data + 1, + name.size - 2); + if (f && upb_FieldDef_ContainingType(f) != m) { + jsondec_errf( + d, "Extension %s extends message %s, but was seen in message %s", + upb_FieldDef_FullName(f), + upb_MessageDef_FullName(upb_FieldDef_ContainingType(f)), + upb_MessageDef_FullName(m)); + } + } else { + f = upb_MessageDef_FindByJsonNameWithSize(m, name.data, name.size); + } + + if (!f) { + if ((d->options & upb_JsonDecode_IgnoreUnknown) == 0) { + jsondec_errf(d, "No such field: " UPB_STRINGVIEW_FORMAT, + UPB_STRINGVIEW_ARGS(name)); + } + jsondec_skipval(d); + return; + } + + if (jsondec_peek(d) == JD_NULL && !jsondec_isvalue(f)) { + /* JSON "null" indicates a default value, so no need to set anything. */ + jsondec_null(d); + return; + } + + if (upb_FieldDef_RealContainingOneof(f) && + upb_Message_WhichOneof(msg, upb_FieldDef_ContainingOneof(f))) { + jsondec_err(d, "More than one field for this oneof."); + } + + preserved = d->debug_field; + d->debug_field = f; + + if (upb_FieldDef_IsMap(f)) { + jsondec_map(d, msg, f); + } else if (upb_FieldDef_IsRepeated(f)) { + jsondec_array(d, msg, f); + } else if (upb_FieldDef_IsSubMessage(f)) { + upb_Message* submsg = upb_Message_Mutable(msg, f, d->arena).msg; + const upb_MessageDef* subm = upb_FieldDef_MessageSubDef(f); + jsondec_tomsg(d, submsg, subm); + } else { + upb_JsonMessageValue val = jsondec_value(d, f); + if (!val.ignore) { + upb_Message_SetFieldByDef(msg, f, val.value, d->arena); + } + } + + d->debug_field = preserved; +} + +static void jsondec_object(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + jsondec_objstart(d); + while (jsondec_objnext(d)) { + jsondec_field(d, msg, m); + } + jsondec_objend(d); +} + +static upb_MessageValue jsondec_nonenum(jsondec* d, const upb_FieldDef* f) { + switch (upb_FieldDef_CType(f)) { + case kUpb_CType_Bool: + return jsondec_bool(d, f); + case kUpb_CType_Float: + case kUpb_CType_Double: + return jsondec_double(d, f); + case kUpb_CType_UInt32: + case kUpb_CType_UInt64: + return jsondec_uint(d, f); + case kUpb_CType_Int32: + case kUpb_CType_Int64: + return jsondec_int(d, f); + case kUpb_CType_String: + case kUpb_CType_Bytes: + return jsondec_strfield(d, f); + case kUpb_CType_Message: + return jsondec_msg(d, f); + case kUpb_CType_Enum: + default: + UPB_UNREACHABLE(); + } +} + +static upb_JsonMessageValue jsondec_value(jsondec* d, const upb_FieldDef* f) { + if (upb_FieldDef_CType(f) == kUpb_CType_Enum) { + return jsondec_enum(d, f); + } else { + return (upb_JsonMessageValue){.value = jsondec_nonenum(d, f), + .ignore = false}; + } +} + +/* Well-known types ***********************************************************/ + +static int jsondec_tsdigits(jsondec* d, const char** ptr, size_t digits, + const char* after) { + uint64_t val; + const char* p = *ptr; + const char* end = p + digits; + size_t after_len = after ? strlen(after) : 0; + + UPB_ASSERT(digits <= 9); /* int can't overflow. */ + + if (jsondec_buftouint64(d, p, end, &val) != end || + (after_len && memcmp(end, after, after_len) != 0)) { + jsondec_err(d, "Malformed timestamp"); + } + + UPB_ASSERT(val < INT_MAX); + + *ptr = end + after_len; + return (int)val; +} + +static int jsondec_nanos(jsondec* d, const char** ptr, const char* end) { + uint64_t nanos = 0; + const char* p = *ptr; + + if (p != end && *p == '.') { + const char* nano_end = jsondec_buftouint64(d, p + 1, end, &nanos); + int digits = (int)(nano_end - p - 1); + int exp_lg10 = 9 - digits; + if (digits > 9) { + jsondec_err(d, "Too many digits for partial seconds"); + } + while (exp_lg10--) nanos *= 10; + *ptr = nano_end; + } + + UPB_ASSERT(nanos < INT_MAX); + + return (int)nanos; +} + +/* jsondec_epochdays(1970, 1, 1) == 1970-01-01 == 0. */ +int jsondec_epochdays(int y, int m, int d) { + const uint32_t year_base = 4800; /* Before min year, multiple of 400. */ + const uint32_t m_adj = m - 3; /* March-based month. */ + const uint32_t carry = m_adj > (uint32_t)m ? 1 : 0; + const uint32_t adjust = carry ? 12 : 0; + const uint32_t y_adj = y + year_base - carry; + const uint32_t month_days = ((m_adj + adjust) * 62719 + 769) / 2048; + const uint32_t leap_days = y_adj / 4 - y_adj / 100 + y_adj / 400; + return y_adj * 365 + leap_days + month_days + (d - 1) - 2472632; +} + +static int64_t jsondec_unixtime(int y, int m, int d, int h, int min, int s) { + return (int64_t)jsondec_epochdays(y, m, d) * 86400 + h * 3600 + min * 60 + s; +} + +static void jsondec_timestamp(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + upb_MessageValue seconds; + upb_MessageValue nanos; + upb_StringView str = jsondec_string(d); + const char* ptr = str.data; + const char* end = ptr + str.size; + + if (str.size < 20) goto malformed; + + { + /* 1972-01-01T01:00:00 */ + int year = jsondec_tsdigits(d, &ptr, 4, "-"); + int mon = jsondec_tsdigits(d, &ptr, 2, "-"); + int day = jsondec_tsdigits(d, &ptr, 2, "T"); + int hour = jsondec_tsdigits(d, &ptr, 2, ":"); + int min = jsondec_tsdigits(d, &ptr, 2, ":"); + int sec = jsondec_tsdigits(d, &ptr, 2, NULL); + + seconds.int64_val = jsondec_unixtime(year, mon, day, hour, min, sec); + } + + nanos.int32_val = jsondec_nanos(d, &ptr, end); + + { + /* [+-]08:00 or Z */ + int ofs_hour = 0; + int ofs_min = 0; + bool neg = false; + + if (ptr == end) goto malformed; + + switch (*ptr++) { + case '-': + neg = true; + /* fallthrough */ + case '+': + if ((end - ptr) != 5) goto malformed; + ofs_hour = jsondec_tsdigits(d, &ptr, 2, ":"); + ofs_min = jsondec_tsdigits(d, &ptr, 2, NULL); + ofs_min = ((ofs_hour * 60) + ofs_min) * 60; + seconds.int64_val += (neg ? ofs_min : -ofs_min); + break; + case 'Z': + if (ptr != end) goto malformed; + break; + default: + goto malformed; + } + } + + if (seconds.int64_val < -62135596800) { + jsondec_err(d, "Timestamp out of range"); + } + + upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 1), + seconds, d->arena); + upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 2), nanos, + d->arena); + return; + +malformed: + jsondec_err(d, "Malformed timestamp"); +} + +static void jsondec_duration(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + upb_MessageValue seconds; + upb_MessageValue nanos; + upb_StringView str = jsondec_string(d); + const char* ptr = str.data; + const char* end = ptr + str.size; + const int64_t max = (uint64_t)3652500 * 86400; + bool neg = false; + + /* "3.000000001s", "3s", etc. */ + ptr = jsondec_buftoint64(d, ptr, end, &seconds.int64_val, &neg); + nanos.int32_val = jsondec_nanos(d, &ptr, end); + + if (end - ptr != 1 || *ptr != 's') { + jsondec_err(d, "Malformed duration"); + } + + if (seconds.int64_val < -max || seconds.int64_val > max) { + jsondec_err(d, "Duration out of range"); + } + + if (neg) { + nanos.int32_val = -nanos.int32_val; + } + + upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 1), + seconds, d->arena); + upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 2), nanos, + d->arena); +} + +static void jsondec_listvalue(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* values_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_MessageDef* value_m = upb_FieldDef_MessageSubDef(values_f); + const upb_MiniTable* value_layout = upb_MessageDef_MiniTable(value_m); + upb_Array* values = upb_Message_Mutable(msg, values_f, d->arena).array; + + jsondec_arrstart(d); + while (jsondec_arrnext(d)) { + upb_Message* value_msg = upb_Message_New(value_layout, d->arena); + upb_MessageValue value; + value.msg_val = value_msg; + upb_Array_Append(values, value, d->arena); + jsondec_wellknownvalue(d, value_msg, value_m); + } + jsondec_arrend(d); +} + +static void jsondec_struct(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* fields_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(fields_f); + const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(entry_m, 2); + const upb_MessageDef* value_m = upb_FieldDef_MessageSubDef(value_f); + const upb_MiniTable* value_layout = upb_MessageDef_MiniTable(value_m); + upb_Map* fields = upb_Message_Mutable(msg, fields_f, d->arena).map; + + jsondec_objstart(d); + while (jsondec_objnext(d)) { + upb_MessageValue key, value; + upb_Message* value_msg = upb_Message_New(value_layout, d->arena); + key.str_val = jsondec_string(d); + value.msg_val = value_msg; + upb_Map_Set(fields, key, value, d->arena); + jsondec_entrysep(d); + jsondec_wellknownvalue(d, value_msg, value_m); + } + jsondec_objend(d); +} + +static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + upb_MessageValue val; + const upb_FieldDef* f; + upb_Message* submsg; + + switch (jsondec_peek(d)) { + case JD_NUMBER: + /* double number_value = 2; */ + f = upb_MessageDef_FindFieldByNumber(m, 2); + val.double_val = jsondec_number(d); + break; + case JD_STRING: + /* string string_value = 3; */ + f = upb_MessageDef_FindFieldByNumber(m, 3); + val.str_val = jsondec_string(d); + break; + case JD_FALSE: + /* bool bool_value = 4; */ + f = upb_MessageDef_FindFieldByNumber(m, 4); + val.bool_val = false; + jsondec_false(d); + break; + case JD_TRUE: + /* bool bool_value = 4; */ + f = upb_MessageDef_FindFieldByNumber(m, 4); + val.bool_val = true; + jsondec_true(d); + break; + case JD_NULL: + /* NullValue null_value = 1; */ + f = upb_MessageDef_FindFieldByNumber(m, 1); + val.int32_val = 0; + jsondec_null(d); + break; + /* Note: these cases return, because upb_Message_Mutable() is enough. */ + case JD_OBJECT: + /* Struct struct_value = 5; */ + f = upb_MessageDef_FindFieldByNumber(m, 5); + submsg = upb_Message_Mutable(msg, f, d->arena).msg; + jsondec_struct(d, submsg, upb_FieldDef_MessageSubDef(f)); + return; + case JD_ARRAY: + /* ListValue list_value = 6; */ + f = upb_MessageDef_FindFieldByNumber(m, 6); + submsg = upb_Message_Mutable(msg, f, d->arena).msg; + jsondec_listvalue(d, submsg, upb_FieldDef_MessageSubDef(f)); + return; + default: + UPB_UNREACHABLE(); + } + + upb_Message_SetFieldByDef(msg, f, val, d->arena); +} + +static upb_StringView jsondec_mask(jsondec* d, const char* buf, + const char* end) { + /* FieldMask fields grow due to inserted '_' characters, so we can't do the + * transform in place. */ + const char* ptr = buf; + upb_StringView ret; + char* out; + + ret.size = end - ptr; + while (ptr < end) { + ret.size += (*ptr >= 'A' && *ptr <= 'Z'); + ptr++; + } + + out = upb_Arena_Malloc(d->arena, ret.size); + ptr = buf; + ret.data = out; + + while (ptr < end) { + char ch = *ptr++; + if (ch >= 'A' && ch <= 'Z') { + *out++ = '_'; + *out++ = ch + 32; + } else if (ch == '_') { + jsondec_err(d, "field mask may not contain '_'"); + } else { + *out++ = ch; + } + } + + return ret; +} + +static void jsondec_fieldmask(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + /* repeated string paths = 1; */ + const upb_FieldDef* paths_f = upb_MessageDef_FindFieldByNumber(m, 1); + upb_Array* arr = upb_Message_Mutable(msg, paths_f, d->arena).array; + upb_StringView str = jsondec_string(d); + const char* ptr = str.data; + const char* end = ptr + str.size; + upb_MessageValue val; + + while (ptr < end) { + const char* elem_end = memchr(ptr, ',', end - ptr); + if (elem_end) { + val.str_val = jsondec_mask(d, ptr, elem_end); + ptr = elem_end + 1; + } else { + val.str_val = jsondec_mask(d, ptr, end); + ptr = end; + } + upb_Array_Append(arr, val, d->arena); + } +} + +static void jsondec_anyfield(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + if (upb_MessageDef_WellKnownType(m) == kUpb_WellKnown_Unspecified) { + /* For regular types: {"@type": "[user type]", "f1": , "f2": } + * where f1, f2, etc. are the normal fields of this type. */ + jsondec_field(d, msg, m); + } else { + /* For well-known types: {"@type": "[well-known type]", "value": } + * where is whatever encoding the WKT normally uses. */ + upb_StringView str = jsondec_string(d); + jsondec_entrysep(d); + if (!jsondec_streql(str, "value")) { + jsondec_err(d, "Key for well-known type must be 'value'"); + } + jsondec_wellknown(d, msg, m); + } +} + +static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* type_url_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_MessageDef* type_m; + upb_StringView type_url = jsondec_string(d); + const char* end = type_url.data + type_url.size; + const char* ptr = end; + upb_MessageValue val; + + val.str_val = type_url; + upb_Message_SetFieldByDef(msg, type_url_f, val, d->arena); + + /* Find message name after the last '/' */ + while (ptr > type_url.data && *--ptr != '/') { + } + + if (ptr == type_url.data || ptr == end) { + jsondec_err(d, "Type url must have at least one '/' and non-empty host"); + } + + ptr++; + type_m = upb_DefPool_FindMessageByNameWithSize(d->symtab, ptr, end - ptr); + + if (!type_m) { + jsondec_err(d, "Type was not found"); + } + + return type_m; +} + +static void jsondec_any(jsondec* d, upb_Message* msg, const upb_MessageDef* m) { + /* string type_url = 1; + * bytes value = 2; */ + const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(m, 2); + upb_Message* any_msg; + const upb_MessageDef* any_m = NULL; + const char* pre_type_data = NULL; + const char* pre_type_end = NULL; + upb_MessageValue encoded; + + jsondec_objstart(d); + + /* Scan looking for "@type", which is not necessarily first. */ + while (!any_m && jsondec_objnext(d)) { + const char* start = d->ptr; + upb_StringView name = jsondec_string(d); + jsondec_entrysep(d); + if (jsondec_streql(name, "@type")) { + any_m = jsondec_typeurl(d, msg, m); + if (pre_type_data) { + pre_type_end = start; + while (*pre_type_end != ',') pre_type_end--; + } + } else { + if (!pre_type_data) pre_type_data = start; + jsondec_skipval(d); + } + } + + if (!any_m) { + jsondec_err(d, "Any object didn't contain a '@type' field"); + } + + const upb_MiniTable* any_layout = upb_MessageDef_MiniTable(any_m); + any_msg = upb_Message_New(any_layout, d->arena); + + if (pre_type_data) { + size_t len = pre_type_end - pre_type_data + 1; + char* tmp = upb_Arena_Malloc(d->arena, len); + const char* saved_ptr = d->ptr; + const char* saved_end = d->end; + memcpy(tmp, pre_type_data, len - 1); + tmp[len - 1] = '}'; + d->ptr = tmp; + d->end = tmp + len; + d->is_first = true; + while (jsondec_objnext(d)) { + jsondec_anyfield(d, any_msg, any_m); + } + d->ptr = saved_ptr; + d->end = saved_end; + } + + while (jsondec_objnext(d)) { + jsondec_anyfield(d, any_msg, any_m); + } + + jsondec_objend(d); + + upb_EncodeStatus status = + upb_Encode(any_msg, upb_MessageDef_MiniTable(any_m), 0, d->arena, + (char**)&encoded.str_val.data, &encoded.str_val.size); + // TODO: We should fail gracefully here on a bad return status. + UPB_ASSERT(status == kUpb_EncodeStatus_Ok); + upb_Message_SetFieldByDef(msg, value_f, encoded, d->arena); +} + +static void jsondec_wrapper(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(m, 1); + upb_JsonMessageValue val = jsondec_value(d, value_f); + UPB_ASSUME(val.ignore == false); // Wrapper cannot be an enum. + upb_Message_SetFieldByDef(msg, value_f, val.value, d->arena); +} + +static void jsondec_wellknown(jsondec* d, upb_Message* msg, + const upb_MessageDef* m) { + switch (upb_MessageDef_WellKnownType(m)) { + case kUpb_WellKnown_Any: + jsondec_any(d, msg, m); + break; + case kUpb_WellKnown_FieldMask: + jsondec_fieldmask(d, msg, m); + break; + case kUpb_WellKnown_Duration: + jsondec_duration(d, msg, m); + break; + case kUpb_WellKnown_Timestamp: + jsondec_timestamp(d, msg, m); + break; + case kUpb_WellKnown_Value: + jsondec_wellknownvalue(d, msg, m); + break; + case kUpb_WellKnown_ListValue: + jsondec_listvalue(d, msg, m); + break; + case kUpb_WellKnown_Struct: + jsondec_struct(d, msg, m); + break; + case kUpb_WellKnown_DoubleValue: + case kUpb_WellKnown_FloatValue: + case kUpb_WellKnown_Int64Value: + case kUpb_WellKnown_UInt64Value: + case kUpb_WellKnown_Int32Value: + case kUpb_WellKnown_UInt32Value: + case kUpb_WellKnown_StringValue: + case kUpb_WellKnown_BytesValue: + case kUpb_WellKnown_BoolValue: + jsondec_wrapper(d, msg, m); + break; + default: + UPB_UNREACHABLE(); + } +} + +static bool upb_JsonDecoder_Decode(jsondec* const d, upb_Message* const msg, + const upb_MessageDef* const m) { + if (UPB_SETJMP(d->err)) return false; + + jsondec_tomsg(d, msg, m); + + // Consume any trailing whitespace before checking if we read the entire + // input. + jsondec_consumews(d); + + if (d->ptr == d->end) { + return true; + } else { + jsondec_seterrmsg(d, "unexpected trailing characters"); + return false; + } +} + +bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg, + const upb_MessageDef* m, const upb_DefPool* symtab, + int options, upb_Arena* arena, upb_Status* status) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + jsondec d; + + if (size == 0) return true; + + d.ptr = buf; + d.end = buf + size; + d.arena = arena; + d.symtab = symtab; + d.status = status; + d.options = options; + d.depth = 64; + d.line = 1; + d.line_begin = d.ptr; + d.debug_field = NULL; + d.is_first = false; + + return upb_JsonDecoder_Decode(&d, msg, m); +} + + +#include +#include +#include +#include +#include +#include + + +// Must be last. + +typedef struct { + char *buf, *ptr, *end; + size_t overflow; + int indent_depth; + int options; + const upb_DefPool* ext_pool; + jmp_buf err; + upb_Status* status; + upb_Arena* arena; +} jsonenc; + +static void jsonenc_msg(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m); +static void jsonenc_scalar(jsonenc* e, upb_MessageValue val, + const upb_FieldDef* f); +static void jsonenc_msgfield(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m); +static void jsonenc_msgfields(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m, bool first); +static void jsonenc_value(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m); + +UPB_NORETURN static void jsonenc_err(jsonenc* e, const char* msg) { + upb_Status_SetErrorMessage(e->status, msg); + longjmp(e->err, 1); +} + +UPB_PRINTF(2, 3) +UPB_NORETURN static void jsonenc_errf(jsonenc* e, const char* fmt, ...) { + va_list argp; + va_start(argp, fmt); + upb_Status_VSetErrorFormat(e->status, fmt, argp); + va_end(argp); + longjmp(e->err, 1); +} + +static upb_Arena* jsonenc_arena(jsonenc* e) { + /* Create lazily, since it's only needed for Any */ + if (!e->arena) { + e->arena = upb_Arena_New(); + } + return e->arena; +} + +static void jsonenc_putbytes(jsonenc* e, const void* data, size_t len) { + size_t have = e->end - e->ptr; + if (UPB_LIKELY(have >= len)) { + memcpy(e->ptr, data, len); + e->ptr += len; + } else { + if (have) { + memcpy(e->ptr, data, have); + e->ptr += have; + } + e->overflow += (len - have); + } +} + +static void jsonenc_putstr(jsonenc* e, const char* str) { + jsonenc_putbytes(e, str, strlen(str)); +} + +UPB_PRINTF(2, 3) +static void jsonenc_printf(jsonenc* e, const char* fmt, ...) { + size_t n; + size_t have = e->end - e->ptr; + va_list args; + + va_start(args, fmt); + n = _upb_vsnprintf(e->ptr, have, fmt, args); + va_end(args); + + if (UPB_LIKELY(have > n)) { + e->ptr += n; + } else { + e->ptr = UPB_PTRADD(e->ptr, have); + e->overflow += (n - have); + } +} + +static void jsonenc_nanos(jsonenc* e, int32_t nanos) { + int digits = 9; + + if (nanos == 0) return; + if (nanos < 0 || nanos >= 1000000000) { + jsonenc_err(e, "error formatting timestamp as JSON: invalid nanos"); + } + + while (nanos % 1000 == 0) { + nanos /= 1000; + digits -= 3; + } + + jsonenc_printf(e, ".%.*" PRId32, digits, nanos); +} + +static void jsonenc_timestamp(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* seconds_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_FieldDef* nanos_f = upb_MessageDef_FindFieldByNumber(m, 2); + int64_t seconds = upb_Message_GetFieldByDef(msg, seconds_f).int64_val; + int32_t nanos = upb_Message_GetFieldByDef(msg, nanos_f).int32_val; + int L, N, I, J, K, hour, min, sec; + + if (seconds < -62135596800) { + jsonenc_err(e, + "error formatting timestamp as JSON: minimum acceptable value " + "is 0001-01-01T00:00:00Z"); + } else if (seconds > 253402300799) { + jsonenc_err(e, + "error formatting timestamp as JSON: maximum acceptable value " + "is 9999-12-31T23:59:59Z"); + } + + /* Julian Day -> Y/M/D, Algorithm from: + * Fliegel, H. F., and Van Flandern, T. C., "A Machine Algorithm for + * Processing Calendar Dates," Communications of the Association of + * Computing Machines, vol. 11 (1968), p. 657. */ + seconds += 62135596800; // Ensure seconds is positive. + L = (int)(seconds / 86400) - 719162 + 68569 + 2440588; + N = 4 * L / 146097; + L = L - (146097 * N + 3) / 4; + I = 4000 * (L + 1) / 1461001; + L = L - 1461 * I / 4 + 31; + J = 80 * L / 2447; + K = L - 2447 * J / 80; + L = J / 11; + J = J + 2 - 12 * L; + I = 100 * (N - 49) + I + L; + + sec = seconds % 60; + min = (seconds / 60) % 60; + hour = (seconds / 3600) % 24; + + jsonenc_printf(e, "\"%04d-%02d-%02dT%02d:%02d:%02d", I, J, K, hour, min, sec); + jsonenc_nanos(e, nanos); + jsonenc_putstr(e, "Z\""); +} + +static void jsonenc_duration(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* seconds_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_FieldDef* nanos_f = upb_MessageDef_FindFieldByNumber(m, 2); + int64_t seconds = upb_Message_GetFieldByDef(msg, seconds_f).int64_val; + int32_t nanos = upb_Message_GetFieldByDef(msg, nanos_f).int32_val; + bool negative = false; + + if (seconds > 315576000000 || seconds < -315576000000 || + (seconds != 0 && nanos != 0 && (seconds < 0) != (nanos < 0))) { + jsonenc_err(e, "bad duration"); + } + + if (seconds < 0) { + negative = true; + seconds = -seconds; + } + if (nanos < 0) { + negative = true; + nanos = -nanos; + } + + jsonenc_putstr(e, "\""); + if (negative) { + jsonenc_putstr(e, "-"); + } + jsonenc_printf(e, "%" PRId64, seconds); + jsonenc_nanos(e, nanos); + jsonenc_putstr(e, "s\""); +} + +static void jsonenc_enum(int32_t val, const upb_FieldDef* f, jsonenc* e) { + const upb_EnumDef* e_def = upb_FieldDef_EnumSubDef(f); + + if (strcmp(upb_EnumDef_FullName(e_def), "google.protobuf.NullValue") == 0) { + jsonenc_putstr(e, "null"); + } else { + const upb_EnumValueDef* ev = + (e->options & upb_JsonEncode_FormatEnumsAsIntegers) + ? NULL + : upb_EnumDef_FindValueByNumber(e_def, val); + + if (ev) { + jsonenc_printf(e, "\"%s\"", upb_EnumValueDef_Name(ev)); + } else { + jsonenc_printf(e, "%" PRId32, val); + } + } +} + +static void jsonenc_bytes(jsonenc* e, upb_StringView str) { + /* This is the regular base64, not the "web-safe" version. */ + static const char base64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + const unsigned char* ptr = (unsigned char*)str.data; + const unsigned char* end = UPB_PTRADD(ptr, str.size); + char buf[4]; + + jsonenc_putstr(e, "\""); + + while (end - ptr >= 3) { + buf[0] = base64[ptr[0] >> 2]; + buf[1] = base64[((ptr[0] & 0x3) << 4) | (ptr[1] >> 4)]; + buf[2] = base64[((ptr[1] & 0xf) << 2) | (ptr[2] >> 6)]; + buf[3] = base64[ptr[2] & 0x3f]; + jsonenc_putbytes(e, buf, 4); + ptr += 3; + } + + switch (end - ptr) { + case 2: + buf[0] = base64[ptr[0] >> 2]; + buf[1] = base64[((ptr[0] & 0x3) << 4) | (ptr[1] >> 4)]; + buf[2] = base64[(ptr[1] & 0xf) << 2]; + buf[3] = '='; + jsonenc_putbytes(e, buf, 4); + break; + case 1: + buf[0] = base64[ptr[0] >> 2]; + buf[1] = base64[((ptr[0] & 0x3) << 4)]; + buf[2] = '='; + buf[3] = '='; + jsonenc_putbytes(e, buf, 4); + break; + } + + jsonenc_putstr(e, "\""); +} + +static void jsonenc_stringbody(jsonenc* e, upb_StringView str) { + const char* ptr = str.data; + const char* end = UPB_PTRADD(ptr, str.size); + + while (ptr < end) { + switch (*ptr) { + case '\n': + jsonenc_putstr(e, "\\n"); + break; + case '\r': + jsonenc_putstr(e, "\\r"); + break; + case '\t': + jsonenc_putstr(e, "\\t"); + break; + case '\"': + jsonenc_putstr(e, "\\\""); + break; + case '\f': + jsonenc_putstr(e, "\\f"); + break; + case '\b': + jsonenc_putstr(e, "\\b"); + break; + case '\\': + jsonenc_putstr(e, "\\\\"); + break; + default: + if ((uint8_t)*ptr < 0x20) { + jsonenc_printf(e, "\\u%04x", (int)(uint8_t)*ptr); + } else { + /* This could be a non-ASCII byte. We rely on the string being valid + * UTF-8. */ + jsonenc_putbytes(e, ptr, 1); + } + break; + } + ptr++; + } +} + +static void jsonenc_string(jsonenc* e, upb_StringView str) { + jsonenc_putstr(e, "\""); + jsonenc_stringbody(e, str); + jsonenc_putstr(e, "\""); +} + +static bool upb_JsonEncode_HandleSpecialDoubles(jsonenc* e, double val) { + if (val == INFINITY) { + jsonenc_putstr(e, "\"Infinity\""); + } else if (val == -INFINITY) { + jsonenc_putstr(e, "\"-Infinity\""); + } else if (val != val) { + jsonenc_putstr(e, "\"NaN\""); + } else { + return false; + } + return true; +} + +static void upb_JsonEncode_Double(jsonenc* e, double val) { + if (upb_JsonEncode_HandleSpecialDoubles(e, val)) return; + char buf[32]; + _upb_EncodeRoundTripDouble(val, buf, sizeof(buf)); + jsonenc_putstr(e, buf); +} + +static void upb_JsonEncode_Float(jsonenc* e, float val) { + if (upb_JsonEncode_HandleSpecialDoubles(e, val)) return; + char buf[32]; + _upb_EncodeRoundTripFloat(val, buf, sizeof(buf)); + jsonenc_putstr(e, buf); +} + +static void jsonenc_wrapper(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(m, 1); + upb_MessageValue val = upb_Message_GetFieldByDef(msg, val_f); + jsonenc_scalar(e, val, val_f); +} + +static const upb_MessageDef* jsonenc_getanymsg(jsonenc* e, + upb_StringView type_url) { + /* Find last '/', if any. */ + const char* end = type_url.data + type_url.size; + const char* ptr = end; + const upb_MessageDef* ret; + + if (!e->ext_pool) { + jsonenc_err(e, "Tried to encode Any, but no symtab was provided"); + } + + if (type_url.size == 0) goto badurl; + + while (true) { + if (--ptr == type_url.data) { + /* Type URL must contain at least one '/', with host before. */ + goto badurl; + } + if (*ptr == '/') { + ptr++; + break; + } + } + + ret = upb_DefPool_FindMessageByNameWithSize(e->ext_pool, ptr, end - ptr); + + if (!ret) { + jsonenc_errf(e, "Couldn't find Any type: %.*s", (int)(end - ptr), ptr); + } + + return ret; + +badurl: + jsonenc_errf(e, "Bad type URL: " UPB_STRINGVIEW_FORMAT, + UPB_STRINGVIEW_ARGS(type_url)); +} + +static void jsonenc_any(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* type_url_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(m, 2); + upb_StringView type_url = upb_Message_GetFieldByDef(msg, type_url_f).str_val; + upb_StringView value = upb_Message_GetFieldByDef(msg, value_f).str_val; + const upb_MessageDef* any_m = jsonenc_getanymsg(e, type_url); + const upb_MiniTable* any_layout = upb_MessageDef_MiniTable(any_m); + upb_Arena* arena = jsonenc_arena(e); + upb_Message* any = upb_Message_New(any_layout, arena); + + if (upb_Decode(value.data, value.size, any, any_layout, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + jsonenc_err(e, "Error decoding message in Any"); + } + + jsonenc_putstr(e, "{\"@type\":"); + jsonenc_string(e, type_url); + + if (upb_MessageDef_WellKnownType(any_m) == kUpb_WellKnown_Unspecified) { + /* Regular messages: {"@type": "...","foo": 1, "bar": 2} */ + jsonenc_msgfields(e, any, any_m, false); + } else { + /* Well-known type: {"@type": "...","value": } */ + jsonenc_putstr(e, ",\"value\":"); + jsonenc_msgfield(e, any, any_m); + } + + jsonenc_putstr(e, "}"); +} + +static void jsonenc_putsep(jsonenc* e, const char* str, bool* first) { + if (*first) { + *first = false; + } else { + jsonenc_putstr(e, str); + } +} + +static void jsonenc_fieldpath(jsonenc* e, upb_StringView path) { + const char* ptr = path.data; + const char* end = ptr + path.size; + + while (ptr < end) { + char ch = *ptr; + + if (ch >= 'A' && ch <= 'Z') { + jsonenc_err(e, "Field mask element may not have upper-case letter."); + } else if (ch == '_') { + if (ptr == end - 1 || *(ptr + 1) < 'a' || *(ptr + 1) > 'z') { + jsonenc_err(e, "Underscore must be followed by a lowercase letter."); + } + ch = *++ptr - 32; + } + + jsonenc_putbytes(e, &ch, 1); + ptr++; + } +} + +static void jsonenc_fieldmask(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* paths_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_Array* paths = upb_Message_GetFieldByDef(msg, paths_f).array_val; + bool first = true; + size_t i, n = 0; + + if (paths) n = upb_Array_Size(paths); + + jsonenc_putstr(e, "\""); + + for (i = 0; i < n; i++) { + jsonenc_putsep(e, ",", &first); + jsonenc_fieldpath(e, upb_Array_Get(paths, i).str_val); + } + + jsonenc_putstr(e, "\""); +} + +static void jsonenc_struct(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + jsonenc_putstr(e, "{"); + + const upb_FieldDef* fields_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_Map* fields = upb_Message_GetFieldByDef(msg, fields_f).map_val; + + if (fields) { + const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(fields_f); + const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(entry_m, 2); + + size_t iter = kUpb_Map_Begin; + bool first = true; + + upb_MessageValue key, val; + while (upb_Map_Next(fields, &key, &val, &iter)) { + jsonenc_putsep(e, ",", &first); + jsonenc_string(e, key.str_val); + jsonenc_putstr(e, ":"); + jsonenc_value(e, val.msg_val, upb_FieldDef_MessageSubDef(value_f)); + } + } + + jsonenc_putstr(e, "}"); +} + +static void jsonenc_listvalue(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + const upb_FieldDef* values_f = upb_MessageDef_FindFieldByNumber(m, 1); + const upb_MessageDef* values_m = upb_FieldDef_MessageSubDef(values_f); + const upb_Array* values = upb_Message_GetFieldByDef(msg, values_f).array_val; + size_t i; + bool first = true; + + jsonenc_putstr(e, "["); + + if (values) { + const size_t size = upb_Array_Size(values); + for (i = 0; i < size; i++) { + upb_MessageValue elem = upb_Array_Get(values, i); + + jsonenc_putsep(e, ",", &first); + jsonenc_value(e, elem.msg_val, values_m); + } + } + + jsonenc_putstr(e, "]"); +} + +static void jsonenc_value(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + /* TODO: do we want a reflection method to get oneof case? */ + size_t iter = kUpb_Message_Begin; + const upb_FieldDef* f; + upb_MessageValue val; + + if (!upb_Message_Next(msg, m, NULL, &f, &val, &iter)) { + jsonenc_err(e, "No value set in Value proto"); + } + + switch (upb_FieldDef_Number(f)) { + case 1: + jsonenc_putstr(e, "null"); + break; + case 2: + if (upb_JsonEncode_HandleSpecialDoubles(e, val.double_val)) { + jsonenc_err( + e, + "google.protobuf.Value cannot encode double values for " + "infinity or nan, because they would be parsed as a string"); + } + upb_JsonEncode_Double(e, val.double_val); + break; + case 3: + jsonenc_string(e, val.str_val); + break; + case 4: + jsonenc_putstr(e, val.bool_val ? "true" : "false"); + break; + case 5: + jsonenc_struct(e, val.msg_val, upb_FieldDef_MessageSubDef(f)); + break; + case 6: + jsonenc_listvalue(e, val.msg_val, upb_FieldDef_MessageSubDef(f)); + break; + } +} + +static void jsonenc_msgfield(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + switch (upb_MessageDef_WellKnownType(m)) { + case kUpb_WellKnown_Unspecified: + jsonenc_msg(e, msg, m); + break; + case kUpb_WellKnown_Any: + jsonenc_any(e, msg, m); + break; + case kUpb_WellKnown_FieldMask: + jsonenc_fieldmask(e, msg, m); + break; + case kUpb_WellKnown_Duration: + jsonenc_duration(e, msg, m); + break; + case kUpb_WellKnown_Timestamp: + jsonenc_timestamp(e, msg, m); + break; + case kUpb_WellKnown_DoubleValue: + case kUpb_WellKnown_FloatValue: + case kUpb_WellKnown_Int64Value: + case kUpb_WellKnown_UInt64Value: + case kUpb_WellKnown_Int32Value: + case kUpb_WellKnown_UInt32Value: + case kUpb_WellKnown_StringValue: + case kUpb_WellKnown_BytesValue: + case kUpb_WellKnown_BoolValue: + jsonenc_wrapper(e, msg, m); + break; + case kUpb_WellKnown_Value: + jsonenc_value(e, msg, m); + break; + case kUpb_WellKnown_ListValue: + jsonenc_listvalue(e, msg, m); + break; + case kUpb_WellKnown_Struct: + jsonenc_struct(e, msg, m); + break; + } +} + +static void jsonenc_scalar(jsonenc* e, upb_MessageValue val, + const upb_FieldDef* f) { + switch (upb_FieldDef_CType(f)) { + case kUpb_CType_Bool: + jsonenc_putstr(e, val.bool_val ? "true" : "false"); + break; + case kUpb_CType_Float: + upb_JsonEncode_Float(e, val.float_val); + break; + case kUpb_CType_Double: + upb_JsonEncode_Double(e, val.double_val); + break; + case kUpb_CType_Int32: + jsonenc_printf(e, "%" PRId32, val.int32_val); + break; + case kUpb_CType_UInt32: + jsonenc_printf(e, "%" PRIu32, val.uint32_val); + break; + case kUpb_CType_Int64: + jsonenc_printf(e, "\"%" PRId64 "\"", val.int64_val); + break; + case kUpb_CType_UInt64: + jsonenc_printf(e, "\"%" PRIu64 "\"", val.uint64_val); + break; + case kUpb_CType_String: + jsonenc_string(e, val.str_val); + break; + case kUpb_CType_Bytes: + jsonenc_bytes(e, val.str_val); + break; + case kUpb_CType_Enum: + jsonenc_enum(val.int32_val, f, e); + break; + case kUpb_CType_Message: + jsonenc_msgfield(e, val.msg_val, upb_FieldDef_MessageSubDef(f)); + break; + } +} + +static void jsonenc_mapkey(jsonenc* e, upb_MessageValue val, + const upb_FieldDef* f) { + jsonenc_putstr(e, "\""); + + switch (upb_FieldDef_CType(f)) { + case kUpb_CType_Bool: + jsonenc_putstr(e, val.bool_val ? "true" : "false"); + break; + case kUpb_CType_Int32: + jsonenc_printf(e, "%" PRId32, val.int32_val); + break; + case kUpb_CType_UInt32: + jsonenc_printf(e, "%" PRIu32, val.uint32_val); + break; + case kUpb_CType_Int64: + jsonenc_printf(e, "%" PRId64, val.int64_val); + break; + case kUpb_CType_UInt64: + jsonenc_printf(e, "%" PRIu64, val.uint64_val); + break; + case kUpb_CType_String: + jsonenc_stringbody(e, val.str_val); + break; + default: + UPB_UNREACHABLE(); + } + + jsonenc_putstr(e, "\":"); +} + +static void jsonenc_array(jsonenc* e, const upb_Array* arr, + const upb_FieldDef* f) { + size_t i; + size_t size = arr ? upb_Array_Size(arr) : 0; + bool first = true; + + jsonenc_putstr(e, "["); + + for (i = 0; i < size; i++) { + jsonenc_putsep(e, ",", &first); + jsonenc_scalar(e, upb_Array_Get(arr, i), f); + } + + jsonenc_putstr(e, "]"); +} + +static void jsonenc_map(jsonenc* e, const upb_Map* map, const upb_FieldDef* f) { + jsonenc_putstr(e, "{"); + + const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f); + const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry, 1); + const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry, 2); + + if (map) { + size_t iter = kUpb_Map_Begin; + bool first = true; + + upb_MessageValue key, val; + while (upb_Map_Next(map, &key, &val, &iter)) { + jsonenc_putsep(e, ",", &first); + jsonenc_mapkey(e, key, key_f); + jsonenc_scalar(e, val, val_f); + } + } + + jsonenc_putstr(e, "}"); +} + +static void jsonenc_fieldval(jsonenc* e, const upb_FieldDef* f, + upb_MessageValue val, bool* first) { + const char* name; + + jsonenc_putsep(e, ",", first); + + if (upb_FieldDef_IsExtension(f)) { + // TODO: For MessageSet, I would have expected this to print the message + // name here, but Python doesn't appear to do this. We should do more + // research here about what various implementations do. + jsonenc_printf(e, "\"[%s]\":", upb_FieldDef_FullName(f)); + } else { + if (e->options & upb_JsonEncode_UseProtoNames) { + name = upb_FieldDef_Name(f); + } else { + name = upb_FieldDef_JsonName(f); + } + jsonenc_printf(e, "\"%s\":", name); + } + + if (upb_FieldDef_IsMap(f)) { + jsonenc_map(e, val.map_val, f); + } else if (upb_FieldDef_IsRepeated(f)) { + jsonenc_array(e, val.array_val, f); + } else { + jsonenc_scalar(e, val, f); + } +} + +static void jsonenc_msgfields(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m, bool first) { + upb_MessageValue val; + const upb_FieldDef* f; + + if (e->options & upb_JsonEncode_EmitDefaults) { + /* Iterate over all fields. */ + int i = 0; + int n = upb_MessageDef_FieldCount(m); + for (i = 0; i < n; i++) { + f = upb_MessageDef_Field(m, i); + if (!upb_FieldDef_HasPresence(f) || upb_Message_HasFieldByDef(msg, f)) { + jsonenc_fieldval(e, f, upb_Message_GetFieldByDef(msg, f), &first); + } + } + } else { + /* Iterate over non-empty fields. */ + size_t iter = kUpb_Message_Begin; + while (upb_Message_Next(msg, m, e->ext_pool, &f, &val, &iter)) { + jsonenc_fieldval(e, f, val, &first); + } + } +} + +static void jsonenc_msg(jsonenc* e, const upb_Message* msg, + const upb_MessageDef* m) { + jsonenc_putstr(e, "{"); + jsonenc_msgfields(e, msg, m, true); + jsonenc_putstr(e, "}"); +} + +static size_t jsonenc_nullz(jsonenc* e, size_t size) { + size_t ret = e->ptr - e->buf + e->overflow; + + if (size > 0) { + if (e->ptr == e->end) e->ptr--; + *e->ptr = '\0'; + } + + return ret; +} + +static size_t upb_JsonEncoder_Encode(jsonenc* const e, + const upb_Message* const msg, + const upb_MessageDef* const m, + const size_t size) { + if (UPB_SETJMP(e->err) != 0) return -1; + + jsonenc_msgfield(e, msg, m); + if (e->arena) upb_Arena_Free(e->arena); + return jsonenc_nullz(e, size); +} + +size_t upb_JsonEncode(const upb_Message* msg, const upb_MessageDef* m, + const upb_DefPool* ext_pool, int options, char* buf, + size_t size, upb_Status* status) { + jsonenc e; + + e.buf = buf; + e.ptr = buf; + e.end = UPB_PTRADD(buf, size); + e.overflow = 0; + e.options = options; + e.ext_pool = ext_pool; + e.status = status; + e.arena = NULL; + + return upb_JsonEncoder_Encode(&e, msg, m, size); +} + + +#include + +// Must be last. + +static void* upb_global_allocfunc(upb_alloc* alloc, void* ptr, size_t oldsize, + size_t size) { + UPB_UNUSED(alloc); + UPB_UNUSED(oldsize); + if (size == 0) { + free(ptr); + return NULL; + } else { + return realloc(ptr, size); + } +} + +upb_alloc upb_alloc_global = {&upb_global_allocfunc}; + + +#ifdef UPB_TRACING_ENABLED +#include +#endif + +#include +#include + + +// Must be last. + +typedef struct upb_MemBlock { + // Atomic only for the benefit of SpaceAllocated(). + UPB_ATOMIC(struct upb_MemBlock*) next; + uint32_t size; + // Data follows. +} upb_MemBlock; + +typedef struct upb_ArenaInternal { + // upb_alloc* together with a low bit which signals if there is an initial + // block. + uintptr_t block_alloc; + + // When multiple arenas are fused together, each arena points to a parent + // arena (root points to itself). The root tracks how many live arenas + // reference it. + + // The low bit is tagged: + // 0: pointer to parent + // 1: count, left shifted by one + UPB_ATOMIC(uintptr_t) parent_or_count; + + // All nodes that are fused together are in a singly-linked list. + // == NULL at end of list. + UPB_ATOMIC(struct upb_ArenaInternal*) next; + + // The last element of the linked list. This is present only as an + // optimization, so that we do not have to iterate over all members for every + // fuse. Only significant for an arena root. In other cases it is ignored. + // == self when no other list members. + UPB_ATOMIC(struct upb_ArenaInternal*) tail; + + // Linked list of blocks to free/cleanup. Atomic only for the benefit of + // upb_Arena_SpaceAllocated(). + UPB_ATOMIC(upb_MemBlock*) blocks; +} upb_ArenaInternal; + +// All public + private state for an arena. +typedef struct { + upb_Arena head; + upb_ArenaInternal body; +} upb_ArenaState; + +typedef struct { + upb_ArenaInternal* root; + uintptr_t tagged_count; +} upb_ArenaRoot; + +static const size_t kUpb_MemblockReserve = + UPB_ALIGN_UP(sizeof(upb_MemBlock), UPB_MALLOC_ALIGN); + +// Extracts the (upb_ArenaInternal*) from a (upb_Arena*) +static upb_ArenaInternal* upb_Arena_Internal(const upb_Arena* a) { + return &((upb_ArenaState*)a)->body; +} + +static bool _upb_Arena_IsTaggedRefcount(uintptr_t parent_or_count) { + return (parent_or_count & 1) == 1; +} + +static bool _upb_Arena_IsTaggedPointer(uintptr_t parent_or_count) { + return (parent_or_count & 1) == 0; +} + +static uintptr_t _upb_Arena_RefCountFromTagged(uintptr_t parent_or_count) { + UPB_ASSERT(_upb_Arena_IsTaggedRefcount(parent_or_count)); + return parent_or_count >> 1; +} + +static uintptr_t _upb_Arena_TaggedFromRefcount(uintptr_t refcount) { + uintptr_t parent_or_count = (refcount << 1) | 1; + UPB_ASSERT(_upb_Arena_IsTaggedRefcount(parent_or_count)); + return parent_or_count; +} + +static upb_ArenaInternal* _upb_Arena_PointerFromTagged( + uintptr_t parent_or_count) { + UPB_ASSERT(_upb_Arena_IsTaggedPointer(parent_or_count)); + return (upb_ArenaInternal*)parent_or_count; +} + +static uintptr_t _upb_Arena_TaggedFromPointer(upb_ArenaInternal* ai) { + uintptr_t parent_or_count = (uintptr_t)ai; + UPB_ASSERT(_upb_Arena_IsTaggedPointer(parent_or_count)); + return parent_or_count; +} + +static upb_alloc* _upb_ArenaInternal_BlockAlloc(upb_ArenaInternal* ai) { + return (upb_alloc*)(ai->block_alloc & ~0x1); +} + +static uintptr_t _upb_Arena_MakeBlockAlloc(upb_alloc* alloc, bool has_initial) { + uintptr_t alloc_uint = (uintptr_t)alloc; + UPB_ASSERT((alloc_uint & 1) == 0); + return alloc_uint | (has_initial ? 1 : 0); +} + +static bool _upb_ArenaInternal_HasInitialBlock(upb_ArenaInternal* ai) { + return ai->block_alloc & 0x1; +} + +#ifdef UPB_TRACING_ENABLED +static void (*_init_arena_trace_handler)(const upb_Arena*, size_t size) = NULL; +static void (*_fuse_arena_trace_handler)(const upb_Arena*, + const upb_Arena*) = NULL; +static void (*_free_arena_trace_handler)(const upb_Arena*) = NULL; + +void upb_Arena_SetTraceHandler( + void (*initArenaTraceHandler)(const upb_Arena*, size_t size), + void (*fuseArenaTraceHandler)(const upb_Arena*, const upb_Arena*), + void (*freeArenaTraceHandler)(const upb_Arena*)) { + _init_arena_trace_handler = initArenaTraceHandler; + _fuse_arena_trace_handler = fuseArenaTraceHandler; + _free_arena_trace_handler = freeArenaTraceHandler; +} + +void upb_Arena_LogInit(const upb_Arena* arena, size_t size) { + if (_init_arena_trace_handler) { + _init_arena_trace_handler(arena, size); + } +} +void upb_Arena_LogFuse(const upb_Arena* arena1, const upb_Arena* arena2) { + if (_fuse_arena_trace_handler) { + _fuse_arena_trace_handler(arena1, arena2); + } +} +void upb_Arena_LogFree(const upb_Arena* arena) { + if (_free_arena_trace_handler) { + _free_arena_trace_handler(arena); + } +} +#endif // UPB_TRACING_ENABLED + +static upb_ArenaRoot _upb_Arena_FindRoot(upb_Arena* a) { + upb_ArenaInternal* ai = upb_Arena_Internal(a); + uintptr_t poc = upb_Atomic_Load(&ai->parent_or_count, memory_order_acquire); + while (_upb_Arena_IsTaggedPointer(poc)) { + upb_ArenaInternal* next = _upb_Arena_PointerFromTagged(poc); + UPB_ASSERT(ai != next); + uintptr_t next_poc = + upb_Atomic_Load(&next->parent_or_count, memory_order_acquire); + + if (_upb_Arena_IsTaggedPointer(next_poc)) { + // To keep complexity down, we lazily collapse levels of the tree. This + // keeps it flat in the final case, but doesn't cost much incrementally. + // + // Path splitting keeps time complexity down, see: + // https://en.wikipedia.org/wiki/Disjoint-set_data_structure + // + // We can safely use a relaxed atomic here because all threads doing this + // will converge on the same value and we don't need memory orderings to + // be visible. + // + // This is true because: + // - If no fuses occur, this will eventually become the root. + // - If fuses are actively occurring, the root may change, but the + // invariant is that `parent_or_count` merely points to *a* parent. + // + // In other words, it is moving towards "the" root, and that root may move + // further away over time, but the path towards that root will continue to + // be valid and the creation of the path carries all the memory orderings + // required. + UPB_ASSERT(ai != _upb_Arena_PointerFromTagged(next_poc)); + upb_Atomic_Store(&ai->parent_or_count, next_poc, memory_order_relaxed); + } + ai = next; + poc = next_poc; + } + return (upb_ArenaRoot){.root = ai, .tagged_count = poc}; +} + +size_t upb_Arena_SpaceAllocated(upb_Arena* arena, size_t* fused_count) { + upb_ArenaInternal* ai = _upb_Arena_FindRoot(arena).root; + size_t memsize = 0; + size_t local_fused_count = 0; + + while (ai != NULL) { + upb_MemBlock* block = upb_Atomic_Load(&ai->blocks, memory_order_relaxed); + while (block != NULL) { + memsize += sizeof(upb_MemBlock) + block->size; + block = upb_Atomic_Load(&block->next, memory_order_relaxed); + } + ai = upb_Atomic_Load(&ai->next, memory_order_relaxed); + local_fused_count++; + } + + if (fused_count) *fused_count = local_fused_count; + return memsize; +} + +bool UPB_PRIVATE(_upb_Arena_Contains)(const upb_Arena* a, void* ptr) { + upb_ArenaInternal* ai = upb_Arena_Internal(a); + UPB_ASSERT(ai); + + upb_MemBlock* block = upb_Atomic_Load(&ai->blocks, memory_order_relaxed); + while (block) { + uintptr_t beg = (uintptr_t)block; + uintptr_t end = beg + block->size; + if ((uintptr_t)ptr >= beg && (uintptr_t)ptr < end) return true; + block = upb_Atomic_Load(&block->next, memory_order_relaxed); + } + + return false; +} + +uint32_t upb_Arena_DebugRefCount(upb_Arena* a) { + upb_ArenaInternal* ai = upb_Arena_Internal(a); + // These loads could probably be relaxed, but given that this is debug-only, + // it's not worth introducing a new variant for it. + uintptr_t poc = upb_Atomic_Load(&ai->parent_or_count, memory_order_acquire); + while (_upb_Arena_IsTaggedPointer(poc)) { + ai = _upb_Arena_PointerFromTagged(poc); + poc = upb_Atomic_Load(&ai->parent_or_count, memory_order_acquire); + } + return _upb_Arena_RefCountFromTagged(poc); +} + +static void _upb_Arena_AddBlock(upb_Arena* a, void* ptr, size_t size) { + upb_ArenaInternal* ai = upb_Arena_Internal(a); + upb_MemBlock* block = ptr; + + // Insert into linked list. + block->size = (uint32_t)size; + upb_Atomic_Init(&block->next, ai->blocks); + upb_Atomic_Store(&ai->blocks, block, memory_order_release); + + a->UPB_PRIVATE(ptr) = UPB_PTR_AT(block, kUpb_MemblockReserve, char); + a->UPB_PRIVATE(end) = UPB_PTR_AT(block, size, char); + + UPB_POISON_MEMORY_REGION(a->UPB_PRIVATE(ptr), + a->UPB_PRIVATE(end) - a->UPB_PRIVATE(ptr)); +} + +static bool _upb_Arena_AllocBlock(upb_Arena* a, size_t size) { + upb_ArenaInternal* ai = upb_Arena_Internal(a); + if (!ai->block_alloc) return false; + upb_MemBlock* last_block = upb_Atomic_Load(&ai->blocks, memory_order_acquire); + size_t last_size = last_block != NULL ? last_block->size : 128; + size_t block_size = UPB_MAX(size, last_size * 2) + kUpb_MemblockReserve; + upb_MemBlock* block = + upb_malloc(_upb_ArenaInternal_BlockAlloc(ai), block_size); + + if (!block) return false; + _upb_Arena_AddBlock(a, block, block_size); + UPB_ASSERT(UPB_PRIVATE(_upb_ArenaHas)(a) >= size); + return true; +} + +void* UPB_PRIVATE(_upb_Arena_SlowMalloc)(upb_Arena* a, size_t size) { + if (!_upb_Arena_AllocBlock(a, size)) return NULL; // OOM + return upb_Arena_Malloc(a, size - UPB_ASAN_GUARD_SIZE); +} + +static upb_Arena* _upb_Arena_InitSlow(upb_alloc* alloc) { + const size_t first_block_overhead = + sizeof(upb_ArenaState) + kUpb_MemblockReserve; + upb_ArenaState* a; + + // We need to malloc the initial block. + char* mem; + size_t n = first_block_overhead + 256; + if (!alloc || !(mem = upb_malloc(alloc, n))) { + return NULL; + } + + a = UPB_PTR_AT(mem, n - sizeof(upb_ArenaState), upb_ArenaState); + n -= sizeof(upb_ArenaState); + + a->body.block_alloc = _upb_Arena_MakeBlockAlloc(alloc, 0); + upb_Atomic_Init(&a->body.parent_or_count, _upb_Arena_TaggedFromRefcount(1)); + upb_Atomic_Init(&a->body.next, NULL); + upb_Atomic_Init(&a->body.tail, &a->body); + upb_Atomic_Init(&a->body.blocks, NULL); + + _upb_Arena_AddBlock(&a->head, mem, n); + + return &a->head; +} + +upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc) { + UPB_ASSERT(sizeof(void*) * UPB_ARENA_SIZE_HACK >= sizeof(upb_ArenaState)); + upb_ArenaState* a; + + if (n) { + /* Align initial pointer up so that we return properly-aligned pointers. */ + void* aligned = (void*)UPB_ALIGN_UP((uintptr_t)mem, UPB_MALLOC_ALIGN); + size_t delta = (uintptr_t)aligned - (uintptr_t)mem; + n = delta <= n ? n - delta : 0; + mem = aligned; + } + + /* Round block size down to alignof(*a) since we will allocate the arena + * itself at the end. */ + n = UPB_ALIGN_DOWN(n, UPB_ALIGN_OF(upb_ArenaState)); + + if (UPB_UNLIKELY(n < sizeof(upb_ArenaState))) { +#ifdef UPB_TRACING_ENABLED + upb_Arena* ret = _upb_Arena_InitSlow(alloc); + upb_Arena_LogInit(ret, n); + return ret; +#else + return _upb_Arena_InitSlow(alloc); +#endif + } + + a = UPB_PTR_AT(mem, n - sizeof(upb_ArenaState), upb_ArenaState); + + upb_Atomic_Init(&a->body.parent_or_count, _upb_Arena_TaggedFromRefcount(1)); + upb_Atomic_Init(&a->body.next, NULL); + upb_Atomic_Init(&a->body.tail, &a->body); + upb_Atomic_Init(&a->body.blocks, NULL); + + a->body.block_alloc = _upb_Arena_MakeBlockAlloc(alloc, 1); + a->head.UPB_PRIVATE(ptr) = mem; + a->head.UPB_PRIVATE(end) = UPB_PTR_AT(mem, n - sizeof(upb_ArenaState), char); +#ifdef UPB_TRACING_ENABLED + upb_Arena_LogInit(&a->head, n); +#endif + return &a->head; +} + +static void _upb_Arena_DoFree(upb_ArenaInternal* ai) { + UPB_ASSERT(_upb_Arena_RefCountFromTagged(ai->parent_or_count) == 1); + while (ai != NULL) { + // Load first since arena itself is likely from one of its blocks. + upb_ArenaInternal* next_arena = + (upb_ArenaInternal*)upb_Atomic_Load(&ai->next, memory_order_acquire); + upb_alloc* block_alloc = _upb_ArenaInternal_BlockAlloc(ai); + upb_MemBlock* block = upb_Atomic_Load(&ai->blocks, memory_order_acquire); + while (block != NULL) { + // Load first since we are deleting block. + upb_MemBlock* next_block = + upb_Atomic_Load(&block->next, memory_order_acquire); + upb_free(block_alloc, block); + block = next_block; + } + ai = next_arena; + } +} + +void upb_Arena_Free(upb_Arena* a) { + upb_ArenaInternal* ai = upb_Arena_Internal(a); + uintptr_t poc = upb_Atomic_Load(&ai->parent_or_count, memory_order_acquire); +retry: + while (_upb_Arena_IsTaggedPointer(poc)) { + ai = _upb_Arena_PointerFromTagged(poc); + poc = upb_Atomic_Load(&ai->parent_or_count, memory_order_acquire); + } + + // compare_exchange or fetch_sub are RMW operations, which are more + // expensive then direct loads. As an optimization, we only do RMW ops + // when we need to update things for other threads to see. + if (poc == _upb_Arena_TaggedFromRefcount(1)) { +#ifdef UPB_TRACING_ENABLED + upb_Arena_LogFree(a); +#endif + _upb_Arena_DoFree(ai); + return; + } + + if (upb_Atomic_CompareExchangeWeak( + &ai->parent_or_count, &poc, + _upb_Arena_TaggedFromRefcount(_upb_Arena_RefCountFromTagged(poc) - 1), + memory_order_release, memory_order_acquire)) { + // We were >1 and we decremented it successfully, so we are done. + return; + } + + // We failed our update, so someone has done something, retry the whole + // process, but the failed exchange reloaded `poc` for us. + goto retry; +} + +static void _upb_Arena_DoFuseArenaLists(upb_ArenaInternal* const parent, + upb_ArenaInternal* child) { + upb_ArenaInternal* parent_tail = + upb_Atomic_Load(&parent->tail, memory_order_relaxed); + + do { + // Our tail might be stale, but it will always converge to the true tail. + upb_ArenaInternal* parent_tail_next = + upb_Atomic_Load(&parent_tail->next, memory_order_relaxed); + while (parent_tail_next != NULL) { + parent_tail = parent_tail_next; + parent_tail_next = + upb_Atomic_Load(&parent_tail->next, memory_order_relaxed); + } + + upb_ArenaInternal* displaced = + upb_Atomic_Exchange(&parent_tail->next, child, memory_order_relaxed); + parent_tail = upb_Atomic_Load(&child->tail, memory_order_relaxed); + + // If we displaced something that got installed racily, we can simply + // reinstall it on our new tail. + child = displaced; + } while (child != NULL); + + upb_Atomic_Store(&parent->tail, parent_tail, memory_order_relaxed); +} + +static upb_ArenaInternal* _upb_Arena_DoFuse(upb_Arena* a1, upb_Arena* a2, + uintptr_t* ref_delta) { + // `parent_or_count` has two disctint modes + // - parent pointer mode + // - refcount mode + // + // In parent pointer mode, it may change what pointer it refers to in the + // tree, but it will always approach a root. Any operation that walks the + // tree to the root may collapse levels of the tree concurrently. + upb_ArenaRoot r1 = _upb_Arena_FindRoot(a1); + upb_ArenaRoot r2 = _upb_Arena_FindRoot(a2); + + if (r1.root == r2.root) return r1.root; // Already fused. + + // Avoid cycles by always fusing into the root with the lower address. + if ((uintptr_t)r1.root > (uintptr_t)r2.root) { + upb_ArenaRoot tmp = r1; + r1 = r2; + r2 = tmp; + } + + // The moment we install `r1` as the parent for `r2` all racing frees may + // immediately begin decrementing `r1`'s refcount (including pending + // increments to that refcount and their frees!). We need to add `r2`'s refs + // now, so that `r1` can withstand any unrefs that come from r2. + // + // Note that while it is possible for `r2`'s refcount to increase + // asynchronously, we will not actually do the reparenting operation below + // unless `r2`'s refcount is unchanged from when we read it. + // + // Note that we may have done this previously, either to this node or a + // different node, during a previous and failed DoFuse() attempt. But we will + // not lose track of these refs because we always add them to our overall + // delta. + uintptr_t r2_untagged_count = r2.tagged_count & ~1; + uintptr_t with_r2_refs = r1.tagged_count + r2_untagged_count; + if (!upb_Atomic_CompareExchangeStrong( + &r1.root->parent_or_count, &r1.tagged_count, with_r2_refs, + memory_order_release, memory_order_acquire)) { + return NULL; + } + + // Perform the actual fuse by removing the refs from `r2` and swapping in the + // parent pointer. + if (!upb_Atomic_CompareExchangeStrong( + &r2.root->parent_or_count, &r2.tagged_count, + _upb_Arena_TaggedFromPointer(r1.root), memory_order_release, + memory_order_acquire)) { + // We'll need to remove the excess refs we added to r1 previously. + *ref_delta += r2_untagged_count; + return NULL; + } + + // Now that the fuse has been performed (and can no longer fail) we need to + // append `r2` to `r1`'s linked list. + _upb_Arena_DoFuseArenaLists(r1.root, r2.root); + return r1.root; +} + +static bool _upb_Arena_FixupRefs(upb_ArenaInternal* new_root, + uintptr_t ref_delta) { + if (ref_delta == 0) return true; // No fixup required. + uintptr_t poc = + upb_Atomic_Load(&new_root->parent_or_count, memory_order_relaxed); + if (_upb_Arena_IsTaggedPointer(poc)) return false; + uintptr_t with_refs = poc - ref_delta; + UPB_ASSERT(!_upb_Arena_IsTaggedPointer(with_refs)); + return upb_Atomic_CompareExchangeStrong(&new_root->parent_or_count, &poc, + with_refs, memory_order_relaxed, + memory_order_relaxed); +} + +bool upb_Arena_Fuse(upb_Arena* a1, upb_Arena* a2) { + if (a1 == a2) return true; // trivial fuse + +#ifdef UPB_TRACING_ENABLED + upb_Arena_LogFuse(a1, a2); +#endif + + upb_ArenaInternal* ai1 = upb_Arena_Internal(a1); + upb_ArenaInternal* ai2 = upb_Arena_Internal(a2); + + // Do not fuse initial blocks since we cannot lifetime extend them. + // Any other fuse scenario is allowed. + if (_upb_ArenaInternal_HasInitialBlock(ai1) || + _upb_ArenaInternal_HasInitialBlock(ai2)) { + return false; + } + + // The number of refs we ultimately need to transfer to the new root. + uintptr_t ref_delta = 0; + while (true) { + upb_ArenaInternal* new_root = _upb_Arena_DoFuse(a1, a2, &ref_delta); + if (new_root != NULL && _upb_Arena_FixupRefs(new_root, ref_delta)) { + return true; + } + } +} + +bool upb_Arena_IncRefFor(upb_Arena* a, const void* owner) { + upb_ArenaInternal* ai = upb_Arena_Internal(a); + if (_upb_ArenaInternal_HasInitialBlock(ai)) return false; + upb_ArenaRoot r; + +retry: + r = _upb_Arena_FindRoot(a); + if (upb_Atomic_CompareExchangeWeak( + &r.root->parent_or_count, &r.tagged_count, + _upb_Arena_TaggedFromRefcount( + _upb_Arena_RefCountFromTagged(r.tagged_count) + 1), + memory_order_release, memory_order_acquire)) { + // We incremented it successfully, so we are done. + return true; + } + // We failed update due to parent switching on the arena. + goto retry; +} + +void upb_Arena_DecRefFor(upb_Arena* a, const void* owner) { upb_Arena_Free(a); } + +void UPB_PRIVATE(_upb_Arena_SwapIn)(upb_Arena* des, const upb_Arena* src) { + upb_ArenaInternal* desi = upb_Arena_Internal(des); + upb_ArenaInternal* srci = upb_Arena_Internal(src); + + *des = *src; + desi->block_alloc = srci->block_alloc; + upb_MemBlock* blocks = upb_Atomic_Load(&srci->blocks, memory_order_relaxed); + upb_Atomic_Init(&desi->blocks, blocks); +} + +void UPB_PRIVATE(_upb_Arena_SwapOut)(upb_Arena* des, const upb_Arena* src) { + upb_ArenaInternal* desi = upb_Arena_Internal(des); + upb_ArenaInternal* srci = upb_Arena_Internal(src); + + *des = *src; + upb_MemBlock* blocks = upb_Atomic_Load(&srci->blocks, memory_order_relaxed); + upb_Atomic_Store(&desi->blocks, blocks, memory_order_relaxed); +} + + +#include + + +// Must be last. + +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* m, + const upb_MiniTableField* f, + upb_Message* map_entry_message, upb_Arena* arena) { + UPB_ASSERT(!upb_Message_IsFrozen(map_entry_message)); + + // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. + const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( + m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); + UPB_ASSERT(map_entry_mini_table); + const upb_MiniTableField* map_entry_key_field = + upb_MiniTable_MapKey(map_entry_mini_table); + const upb_MiniTableField* map_entry_value_field = + upb_MiniTable_MapValue(map_entry_mini_table); + // Map key/value cannot have explicit defaults, + // hence assuming a zero default is valid. + upb_MessageValue default_val; + memset(&default_val, 0, sizeof(upb_MessageValue)); + upb_MessageValue map_entry_key = + upb_Message_GetField(map_entry_message, map_entry_key_field, default_val); + upb_MessageValue map_entry_value = upb_Message_GetField( + map_entry_message, map_entry_value_field, default_val); + return upb_Map_Set(map, map_entry_key, map_entry_value, arena); +} + + +#include +#include + + +// Must be last. + +upb_Array* upb_Array_New(upb_Arena* a, upb_CType type) { + const int lg2 = UPB_PRIVATE(_upb_CType_SizeLg2)(type); + return UPB_PRIVATE(_upb_Array_New)(a, 4, lg2); +} + +upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i) { + UPB_ASSERT(i < upb_Array_Size(arr)); + upb_MessageValue ret; + const char* data = upb_Array_DataPtr(arr); + const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); + memcpy(&ret, data + (i << lg2), 1 << lg2); + return ret; +} + +upb_MutableMessageValue upb_Array_GetMutable(upb_Array* arr, size_t i) { + UPB_ASSERT(i < upb_Array_Size(arr)); + upb_MutableMessageValue ret; + char* data = upb_Array_MutableDataPtr(arr); + const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); + memcpy(&ret, data + (i << lg2), 1 << lg2); + return ret; +} + +void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val) { + UPB_ASSERT(!upb_Array_IsFrozen(arr)); + UPB_ASSERT(i < upb_Array_Size(arr)); + char* data = upb_Array_MutableDataPtr(arr); + const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); + memcpy(data + (i << lg2), &val, 1 << lg2); +} + +bool upb_Array_Append(upb_Array* arr, upb_MessageValue val, upb_Arena* arena) { + UPB_ASSERT(!upb_Array_IsFrozen(arr)); + UPB_ASSERT(arena); + if (!UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + upb_Array_Set(arr, arr->UPB_PRIVATE(size) - 1, val); + return true; +} + +void upb_Array_Move(upb_Array* arr, size_t dst_idx, size_t src_idx, + size_t count) { + UPB_ASSERT(!upb_Array_IsFrozen(arr)); + const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); + char* data = upb_Array_MutableDataPtr(arr); + memmove(&data[dst_idx << lg2], &data[src_idx << lg2], count << lg2); +} + +bool upb_Array_Insert(upb_Array* arr, size_t i, size_t count, + upb_Arena* arena) { + UPB_ASSERT(!upb_Array_IsFrozen(arr)); + UPB_ASSERT(arena); + UPB_ASSERT(i <= arr->UPB_PRIVATE(size)); + UPB_ASSERT(count + arr->UPB_PRIVATE(size) >= count); + const size_t oldsize = arr->UPB_PRIVATE(size); + if (!UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + count, arena)) { + return false; + } + upb_Array_Move(arr, i + count, i, oldsize - i); + return true; +} + +/* + * i end arr->size + * |------------|XXXXXXXX|--------| + */ +void upb_Array_Delete(upb_Array* arr, size_t i, size_t count) { + UPB_ASSERT(!upb_Array_IsFrozen(arr)); + const size_t end = i + count; + UPB_ASSERT(i <= end); + UPB_ASSERT(end <= arr->UPB_PRIVATE(size)); + upb_Array_Move(arr, i, end, arr->UPB_PRIVATE(size) - end); + arr->UPB_PRIVATE(size) -= count; +} + +bool upb_Array_Resize(upb_Array* arr, size_t size, upb_Arena* arena) { + UPB_ASSERT(!upb_Array_IsFrozen(arr)); + const size_t oldsize = arr->UPB_PRIVATE(size); + if (UPB_UNLIKELY( + !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(arr, size, arena))) { + return false; + } + const size_t newsize = arr->UPB_PRIVATE(size); + if (newsize > oldsize) { + const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); + char* data = upb_Array_MutableDataPtr(arr); + memset(data + (oldsize << lg2), 0, (newsize - oldsize) << lg2); + } + return true; +} + +bool UPB_PRIVATE(_upb_Array_Realloc)(upb_Array* array, size_t min_capacity, + upb_Arena* arena) { + size_t new_capacity = UPB_MAX(array->UPB_PRIVATE(capacity), 4); + const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(array); + size_t old_bytes = array->UPB_PRIVATE(capacity) << lg2; + void* ptr = upb_Array_MutableDataPtr(array); + + // Log2 ceiling of size. + while (new_capacity < min_capacity) new_capacity *= 2; + + const size_t new_bytes = new_capacity << lg2; + ptr = upb_Arena_Realloc(arena, ptr, old_bytes, new_bytes); + if (!ptr) return false; + + UPB_PRIVATE(_upb_Array_SetTaggedPtr)(array, ptr, lg2); + array->UPB_PRIVATE(capacity) = new_capacity; + return true; +} + +void upb_Array_Freeze(upb_Array* arr, const upb_MiniTable* m) { + if (upb_Array_IsFrozen(arr)) return; + UPB_PRIVATE(_upb_Array_ShallowFreeze)(arr); + + if (m) { + const size_t size = upb_Array_Size(arr); + + for (size_t i = 0; i < size; i++) { + upb_MessageValue val = upb_Array_Get(arr, i); + upb_Message_Freeze((upb_Message*)val.msg_val, m); + } + } +} + + +#include +#include + + +// Must be last. + +const upb_MiniTableExtension* upb_Message_ExtensionByIndex( + const upb_Message* msg, size_t index) { + size_t count; + const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &count); + + UPB_ASSERT(index < count); + return ext[index].ext; +} + +const upb_MiniTableExtension* upb_Message_FindExtensionByNumber( + const upb_Message* msg, uint32_t field_number) { + size_t count; + const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &count); + + for (; count--; ext++) { + const upb_MiniTableExtension* e = ext->ext; + if (upb_MiniTableExtension_Number(e) == field_number) return e; + } + return NULL; +} + + +#include +#include + + +// Must be last. + +// Strings/bytes are special-cased in maps. +char _upb_Map_CTypeSizeTable[12] = { + [kUpb_CType_Bool] = 1, + [kUpb_CType_Float] = 4, + [kUpb_CType_Int32] = 4, + [kUpb_CType_UInt32] = 4, + [kUpb_CType_Enum] = 4, + [kUpb_CType_Message] = sizeof(void*), + [kUpb_CType_Double] = 8, + [kUpb_CType_Int64] = 8, + [kUpb_CType_UInt64] = 8, + [kUpb_CType_String] = UPB_MAPTYPE_STRING, + [kUpb_CType_Bytes] = UPB_MAPTYPE_STRING, +}; + +upb_Map* upb_Map_New(upb_Arena* a, upb_CType key_type, upb_CType value_type) { + return _upb_Map_New(a, _upb_Map_CTypeSize(key_type), + _upb_Map_CTypeSize(value_type)); +} + +size_t upb_Map_Size(const upb_Map* map) { return _upb_Map_Size(map); } + +bool upb_Map_Get(const upb_Map* map, upb_MessageValue key, + upb_MessageValue* val) { + return _upb_Map_Get(map, &key, map->key_size, val, map->val_size); +} + +void upb_Map_Clear(upb_Map* map) { _upb_Map_Clear(map); } + +upb_MapInsertStatus upb_Map_Insert(upb_Map* map, upb_MessageValue key, + upb_MessageValue val, upb_Arena* arena) { + UPB_ASSERT(arena); + return (upb_MapInsertStatus)_upb_Map_Insert(map, &key, map->key_size, &val, + map->val_size, arena); +} + +bool upb_Map_Delete(upb_Map* map, upb_MessageValue key, upb_MessageValue* val) { + upb_value v; + const bool removed = _upb_Map_Delete(map, &key, map->key_size, &v); + if (val) _upb_map_fromvalue(v, val, map->val_size); + return removed; +} + +bool upb_Map_Next(const upb_Map* map, upb_MessageValue* key, + upb_MessageValue* val, size_t* iter) { + upb_StringView k; + upb_value v; + const bool ok = upb_strtable_next2(&map->table, &k, &v, (intptr_t*)iter); + if (ok) { + _upb_map_fromkey(k, key, map->key_size); + _upb_map_fromvalue(v, val, map->val_size); + } + return ok; +} + +UPB_API void upb_Map_SetEntryValue(upb_Map* map, size_t iter, + upb_MessageValue val) { + upb_value v; + _upb_map_tovalue(&val, map->val_size, &v, NULL); + upb_strtable_setentryvalue(&map->table, iter, v); +} + +bool upb_MapIterator_Next(const upb_Map* map, size_t* iter) { + return _upb_map_next(map, iter); +} + +bool upb_MapIterator_Done(const upb_Map* map, size_t iter) { + upb_strtable_iter i; + UPB_ASSERT(iter != kUpb_Map_Begin); + i.t = &map->table; + i.index = iter; + return upb_strtable_done(&i); +} + +// Returns the key and value for this entry of the map. +upb_MessageValue upb_MapIterator_Key(const upb_Map* map, size_t iter) { + upb_strtable_iter i; + upb_MessageValue ret; + i.t = &map->table; + i.index = iter; + _upb_map_fromkey(upb_strtable_iter_key(&i), &ret, map->key_size); + return ret; +} + +upb_MessageValue upb_MapIterator_Value(const upb_Map* map, size_t iter) { + upb_strtable_iter i; + upb_MessageValue ret; + i.t = &map->table; + i.index = iter; + _upb_map_fromvalue(upb_strtable_iter_value(&i), &ret, map->val_size); + return ret; +} + +void upb_Map_Freeze(upb_Map* map, const upb_MiniTable* m) { + if (upb_Map_IsFrozen(map)) return; + UPB_PRIVATE(_upb_Map_ShallowFreeze)(map); + + if (m) { + size_t iter = kUpb_Map_Begin; + upb_MessageValue key, val; + + while (upb_Map_Next(map, &key, &val, &iter)) { + upb_Message_Freeze((upb_Message*)val.msg_val, m); + } + } +} + +// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// + +upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size) { + upb_Map* map = upb_Arena_Malloc(a, sizeof(upb_Map)); + if (!map) return NULL; + + upb_strtable_init(&map->table, 4, a); + map->key_size = key_size; + map->val_size = value_size; + map->UPB_PRIVATE(is_frozen) = false; + + return map; +} + + +#include +#include + + +// Must be last. + +static void _upb_mapsorter_getkeys(const void* _a, const void* _b, void* a_key, + void* b_key, size_t size) { + const upb_tabent* const* a = _a; + const upb_tabent* const* b = _b; + upb_StringView a_tabkey = upb_tabstrview((*a)->key); + upb_StringView b_tabkey = upb_tabstrview((*b)->key); + _upb_map_fromkey(a_tabkey, a_key, size); + _upb_map_fromkey(b_tabkey, b_key, size); +} + +static int _upb_mapsorter_cmpi64(const void* _a, const void* _b) { + int64_t a, b; + _upb_mapsorter_getkeys(_a, _b, &a, &b, 8); + return a < b ? -1 : a > b; +} + +static int _upb_mapsorter_cmpu64(const void* _a, const void* _b) { + uint64_t a, b; + _upb_mapsorter_getkeys(_a, _b, &a, &b, 8); + return a < b ? -1 : a > b; +} + +static int _upb_mapsorter_cmpi32(const void* _a, const void* _b) { + int32_t a, b; + _upb_mapsorter_getkeys(_a, _b, &a, &b, 4); + return a < b ? -1 : a > b; +} + +static int _upb_mapsorter_cmpu32(const void* _a, const void* _b) { + uint32_t a, b; + _upb_mapsorter_getkeys(_a, _b, &a, &b, 4); + return a < b ? -1 : a > b; +} + +static int _upb_mapsorter_cmpbool(const void* _a, const void* _b) { + bool a, b; + _upb_mapsorter_getkeys(_a, _b, &a, &b, 1); + return a < b ? -1 : a > b; +} + +static int _upb_mapsorter_cmpstr(const void* _a, const void* _b) { + upb_StringView a, b; + _upb_mapsorter_getkeys(_a, _b, &a, &b, UPB_MAPTYPE_STRING); + size_t common_size = UPB_MIN(a.size, b.size); + int cmp = memcmp(a.data, b.data, common_size); + if (cmp) return -cmp; + return a.size < b.size ? -1 : a.size > b.size; +} + +static int (*const compar[kUpb_FieldType_SizeOf])(const void*, const void*) = { + [kUpb_FieldType_Int64] = _upb_mapsorter_cmpi64, + [kUpb_FieldType_SFixed64] = _upb_mapsorter_cmpi64, + [kUpb_FieldType_SInt64] = _upb_mapsorter_cmpi64, + + [kUpb_FieldType_UInt64] = _upb_mapsorter_cmpu64, + [kUpb_FieldType_Fixed64] = _upb_mapsorter_cmpu64, + + [kUpb_FieldType_Int32] = _upb_mapsorter_cmpi32, + [kUpb_FieldType_SInt32] = _upb_mapsorter_cmpi32, + [kUpb_FieldType_SFixed32] = _upb_mapsorter_cmpi32, + [kUpb_FieldType_Enum] = _upb_mapsorter_cmpi32, + + [kUpb_FieldType_UInt32] = _upb_mapsorter_cmpu32, + [kUpb_FieldType_Fixed32] = _upb_mapsorter_cmpu32, + + [kUpb_FieldType_Bool] = _upb_mapsorter_cmpbool, + + [kUpb_FieldType_String] = _upb_mapsorter_cmpstr, + [kUpb_FieldType_Bytes] = _upb_mapsorter_cmpstr, +}; + +static bool _upb_mapsorter_resize(_upb_mapsorter* s, _upb_sortedmap* sorted, + int size) { + sorted->start = s->size; + sorted->pos = sorted->start; + sorted->end = sorted->start + size; + + if (sorted->end > s->cap) { + const int oldsize = s->cap * sizeof(*s->entries); + s->cap = upb_Log2CeilingSize(sorted->end); + const int newsize = s->cap * sizeof(*s->entries); + s->entries = upb_grealloc(s->entries, oldsize, newsize); + if (!s->entries) return false; + } + + s->size = sorted->end; + return true; +} + +bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type, + const upb_Map* map, _upb_sortedmap* sorted) { + int map_size = _upb_Map_Size(map); + UPB_ASSERT(map_size); + + if (!_upb_mapsorter_resize(s, sorted, map_size)) return false; + + // Copy non-empty entries from the table to s->entries. + const void** dst = &s->entries[sorted->start]; + const upb_tabent* src = map->table.t.entries; + const upb_tabent* end = src + upb_table_size(&map->table.t); + for (; src < end; src++) { + if (!upb_tabent_isempty(src)) { + *dst = src; + dst++; + } + } + UPB_ASSERT(dst == &s->entries[sorted->end]); + + // Sort entries according to the key type. + qsort(&s->entries[sorted->start], map_size, sizeof(*s->entries), + compar[key_type]); + return true; +} + +static int _upb_mapsorter_cmpext(const void* _a, const void* _b) { + const upb_Extension* const* a = _a; + const upb_Extension* const* b = _b; + uint32_t a_num = upb_MiniTableExtension_Number((*a)->ext); + uint32_t b_num = upb_MiniTableExtension_Number((*b)->ext); + assert(a_num != b_num); + return a_num < b_num ? -1 : 1; +} + +bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts, + size_t count, _upb_sortedmap* sorted) { + if (!_upb_mapsorter_resize(s, sorted, count)) return false; + + for (size_t i = 0; i < count; i++) { + s->entries[sorted->start + i] = &exts[i]; + } + + qsort(&s->entries[sorted->start], count, sizeof(*s->entries), + _upb_mapsorter_cmpext); + return true; +} + + +#include +#include +#include + + +// Must be last. + +static const size_t message_overhead = sizeof(upb_Message_Internal); + +upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* a) { + return _upb_Message_New(m, a); +} + +bool UPB_PRIVATE(_upb_Message_AddUnknown)(upb_Message* msg, const char* data, + size_t len, upb_Arena* arena) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, len, arena)) return false; + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + memcpy(UPB_PTR_AT(in, in->unknown_end, char), data, len); + in->unknown_end += len; + return true; +} + +void _upb_Message_DiscardUnknown_shallow(upb_Message* msg) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + if (in) { + in->unknown_end = message_overhead; + } +} + +const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) { + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + if (in) { + *len = in->unknown_end - message_overhead; + return (char*)(in + 1); + } else { + *len = 0; + return NULL; + } +} + +void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + const char* internal_unknown_end = UPB_PTR_AT(in, in->unknown_end, char); + +#ifndef NDEBUG + size_t full_unknown_size; + const char* full_unknown = upb_Message_GetUnknown(msg, &full_unknown_size); + UPB_ASSERT((uintptr_t)data >= (uintptr_t)full_unknown); + UPB_ASSERT((uintptr_t)data < (uintptr_t)(full_unknown + full_unknown_size)); + UPB_ASSERT((uintptr_t)(data + len) > (uintptr_t)data); + UPB_ASSERT((uintptr_t)(data + len) <= (uintptr_t)internal_unknown_end); +#endif + + if ((data + len) != internal_unknown_end) { + memmove((char*)data, data + len, internal_unknown_end - data - len); + } + in->unknown_end -= len; +} + +size_t upb_Message_ExtensionCount(const upb_Message* msg) { + size_t count; + UPB_PRIVATE(_upb_Message_Getexts)(msg, &count); + return count; +} + +void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m) { + if (upb_Message_IsFrozen(msg)) return; + UPB_PRIVATE(_upb_Message_ShallowFreeze)(msg); + + // Base Fields. + const size_t field_count = upb_MiniTable_FieldCount(m); + + for (size_t i = 0; i < field_count; i++) { + const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i); + const upb_MiniTable* m2 = upb_MiniTable_SubMessage(m, f); + + switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f)) { + case kUpb_FieldMode_Array: { + upb_Array* arr = upb_Message_GetMutableArray(msg, f); + if (arr) upb_Array_Freeze(arr, m2); + break; + } + case kUpb_FieldMode_Map: { + upb_Map* map = upb_Message_GetMutableMap(msg, f); + if (map) { + const upb_MiniTableField* f2 = upb_MiniTable_MapValue(m2); + const upb_MiniTable* m3 = upb_MiniTable_SubMessage(m2, f2); + upb_Map_Freeze(map, m3); + } + break; + } + case kUpb_FieldMode_Scalar: { + if (m2) { + upb_Message* msg2 = upb_Message_GetMutableMessage(msg, f); + if (msg2) upb_Message_Freeze(msg2, m2); + } + break; + } + } + } + + // Extensions. + size_t ext_count; + const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &ext_count); + + for (size_t i = 0; i < ext_count; i++) { + const upb_MiniTableExtension* e = ext[i].ext; + const upb_MiniTableField* f = &e->UPB_PRIVATE(field); + const upb_MiniTable* m2 = upb_MiniTableExtension_GetSubMessage(e); + + upb_MessageValue val; + memcpy(&val, &ext[i].data, sizeof(upb_MessageValue)); + + switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f)) { + case kUpb_FieldMode_Array: { + upb_Array* arr = (upb_Array*)val.array_val; + if (arr) upb_Array_Freeze(arr, m2); + break; + } + case kUpb_FieldMode_Map: + UPB_UNREACHABLE(); // Maps cannot be extensions. + break; + case kUpb_FieldMode_Scalar: + if (upb_MiniTableField_IsSubMessage(f)) { + upb_Message* msg2 = (upb_Message*)val.msg_val; + if (msg2) upb_Message_Freeze(msg2, m2); + } + break; + } + } +} + + +#include + + +// Must be last. + +#define kUpb_BaseField_Begin ((size_t)-1) +#define kUpb_Extension_Begin ((size_t)-1) + +#ifdef __cplusplus +extern "C" { +#endif + +static bool _upb_Message_NextBaseField(const upb_Message* msg, + const upb_MiniTable* m, + const upb_MiniTableField** out_f, + upb_MessageValue* out_v, size_t* iter) { + const size_t count = upb_MiniTable_FieldCount(m); + size_t i = *iter; + + while (++i < count) { + const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i); + const void* src = UPB_PRIVATE(_upb_Message_DataPtr)(msg, f); + + upb_MessageValue val; + UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, &val, src); + + // Skip field if unset or empty. + if (upb_MiniTableField_HasPresence(f)) { + if (!upb_Message_HasBaseField(msg, f)) continue; + } else { + if (UPB_PRIVATE(_upb_MiniTableField_DataIsZero)(f, src)) continue; + + if (upb_MiniTableField_IsArray(f)) { + if (upb_Array_Size(val.array_val) == 0) continue; + } else if (upb_MiniTableField_IsMap(f)) { + if (upb_Map_Size(val.map_val) == 0) continue; + } + } + + *out_f = f; + *out_v = val; + *iter = i; + return true; + } + + return false; +} + +static bool _upb_Message_NextExtension(const upb_Message* msg, + const upb_MiniTable* m, + const upb_MiniTableExtension** out_e, + upb_MessageValue* out_v, size_t* iter) { + size_t count; + const upb_Extension* exts = UPB_PRIVATE(_upb_Message_Getexts)(msg, &count); + size_t i = *iter; + + if (++i < count) { + *out_e = exts[i].ext; + *out_v = exts[i].data; + *iter = i; + return true; + } + + return false; +} + +bool upb_Message_IsEmpty(const upb_Message* msg, const upb_MiniTable* m) { + if (upb_Message_ExtensionCount(msg)) return false; + + const upb_MiniTableField* f; + upb_MessageValue v; + size_t iter = kUpb_BaseField_Begin; + return !_upb_Message_NextBaseField(msg, m, &f, &v, &iter); +} + +static bool _upb_Array_IsEqual(const upb_Array* arr1, const upb_Array* arr2, + upb_CType ctype, const upb_MiniTable* m, + int options) { + // Check for trivial equality. + if (arr1 == arr2) return true; + + // Must have identical element counts. + const size_t size1 = arr1 ? upb_Array_Size(arr1) : 0; + const size_t size2 = arr2 ? upb_Array_Size(arr2) : 0; + if (size1 != size2) return false; + + for (size_t i = 0; i < size1; i++) { + const upb_MessageValue val1 = upb_Array_Get(arr1, i); + const upb_MessageValue val2 = upb_Array_Get(arr2, i); + + if (!upb_MessageValue_IsEqual(val1, val2, ctype, m, options)) return false; + } + + return true; +} + +static bool _upb_Map_IsEqual(const upb_Map* map1, const upb_Map* map2, + const upb_MiniTable* m, int options) { + // Check for trivial equality. + if (map1 == map2) return true; + + // Must have identical element counts. + size_t size1 = map1 ? upb_Map_Size(map1) : 0; + size_t size2 = map2 ? upb_Map_Size(map2) : 0; + if (size1 != size2) return false; + + const upb_MiniTableField* f = upb_MiniTable_MapValue(m); + const upb_MiniTable* m2_value = upb_MiniTable_SubMessage(m, f); + const upb_CType ctype = upb_MiniTableField_CType(f); + + upb_MessageValue key, val1, val2; + size_t iter = kUpb_Map_Begin; + while (upb_Map_Next(map1, &key, &val1, &iter)) { + if (!upb_Map_Get(map2, key, &val2)) return false; + if (!upb_MessageValue_IsEqual(val1, val2, ctype, m2_value, options)) + return false; + } + + return true; +} + +static bool _upb_Message_BaseFieldsAreEqual(const upb_Message* msg1, + const upb_Message* msg2, + const upb_MiniTable* m, + int options) { + // Iterate over all base fields for each message. + // The order will always match if the messages are equal. + size_t iter1 = kUpb_BaseField_Begin; + size_t iter2 = kUpb_BaseField_Begin; + + for (;;) { + const upb_MiniTableField *f1, *f2; + upb_MessageValue val1, val2; + + const bool got1 = _upb_Message_NextBaseField(msg1, m, &f1, &val1, &iter1); + const bool got2 = _upb_Message_NextBaseField(msg2, m, &f2, &val2, &iter2); + + if (got1 != got2) return false; // Must have identical field counts. + if (!got1) return true; // Loop termination condition. + if (f1 != f2) return false; // Must have identical fields set. + + const upb_MiniTable* subm = upb_MiniTable_SubMessage(m, f1); + const upb_CType ctype = upb_MiniTableField_CType(f1); + + bool eq; + switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f1)) { + case kUpb_FieldMode_Array: + eq = _upb_Array_IsEqual(val1.array_val, val2.array_val, ctype, subm, + options); + break; + case kUpb_FieldMode_Map: + eq = _upb_Map_IsEqual(val1.map_val, val2.map_val, subm, options); + break; + case kUpb_FieldMode_Scalar: + eq = upb_MessageValue_IsEqual(val1, val2, ctype, subm, options); + break; + } + if (!eq) return false; + } +} + +static bool _upb_Message_ExtensionsAreEqual(const upb_Message* msg1, + const upb_Message* msg2, + const upb_MiniTable* m, + int options) { + // Must have identical extension counts. + if (upb_Message_ExtensionCount(msg1) != upb_Message_ExtensionCount(msg2)) { + return false; + } + + const upb_MiniTableExtension* e; + upb_MessageValue val1; + + // Iterate over all extensions for msg1, and search msg2 for each extension. + size_t iter1 = kUpb_Extension_Begin; + while (_upb_Message_NextExtension(msg1, m, &e, &val1, &iter1)) { + const upb_Extension* ext2 = UPB_PRIVATE(_upb_Message_Getext)(msg2, e); + if (!ext2) return false; + + const upb_MessageValue val2 = ext2->data; + const upb_MiniTableField* f = &e->UPB_PRIVATE(field); + const upb_MiniTable* subm = upb_MiniTableField_IsSubMessage(f) + ? upb_MiniTableExtension_GetSubMessage(e) + : NULL; + const upb_CType ctype = upb_MiniTableField_CType(f); + + bool eq; + switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f)) { + case kUpb_FieldMode_Array: + eq = _upb_Array_IsEqual(val1.array_val, val2.array_val, ctype, subm, + options); + break; + case kUpb_FieldMode_Map: + UPB_UNREACHABLE(); // Maps cannot be extensions. + break; + case kUpb_FieldMode_Scalar: { + eq = upb_MessageValue_IsEqual(val1, val2, ctype, subm, options); + break; + } + } + if (!eq) return false; + } + return true; +} + +bool upb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, + const upb_MiniTable* m, int options) { + if (UPB_UNLIKELY(msg1 == msg2)) return true; + + if (!_upb_Message_BaseFieldsAreEqual(msg1, msg2, m, options)) return false; + if (!_upb_Message_ExtensionsAreEqual(msg1, msg2, m, options)) return false; + + if (!(options & kUpb_CompareOption_IncludeUnknownFields)) return true; + + // Check the unknown fields. + size_t usize1, usize2; + const char* uf1 = upb_Message_GetUnknown(msg1, &usize1); + const char* uf2 = upb_Message_GetUnknown(msg2, &usize2); + + // The wire encoder enforces a maximum depth of 100 so we match that here. + return UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( + uf1, usize1, uf2, usize2, 100) == kUpb_UnknownCompareResult_Equal; +} + + +#include +#include + + +// Must be last. + +static upb_StringView upb_Clone_StringView(upb_StringView str, + upb_Arena* arena) { + if (str.size == 0) { + return upb_StringView_FromDataAndSize(NULL, 0); + } + void* cloned_data = upb_Arena_Malloc(arena, str.size); + upb_StringView cloned_str = + upb_StringView_FromDataAndSize(cloned_data, str.size); + memcpy(cloned_data, str.data, str.size); + return cloned_str; +} + +static bool upb_Clone_MessageValue(void* value, upb_CType value_type, + const upb_MiniTable* sub, upb_Arena* arena) { + switch (value_type) { + case kUpb_CType_Bool: + case kUpb_CType_Float: + case kUpb_CType_Int32: + case kUpb_CType_UInt32: + case kUpb_CType_Enum: + case kUpb_CType_Double: + case kUpb_CType_Int64: + case kUpb_CType_UInt64: + return true; + case kUpb_CType_String: + case kUpb_CType_Bytes: { + upb_StringView source = *(upb_StringView*)value; + int size = source.size; + void* cloned_data = upb_Arena_Malloc(arena, size); + if (cloned_data == NULL) { + return false; + } + *(upb_StringView*)value = + upb_StringView_FromDataAndSize(cloned_data, size); + memcpy(cloned_data, source.data, size); + return true; + } break; + case kUpb_CType_Message: { + const upb_TaggedMessagePtr source = *(upb_TaggedMessagePtr*)value; + bool is_empty = upb_TaggedMessagePtr_IsEmpty(source); + if (is_empty) sub = UPB_PRIVATE(_upb_MiniTable_Empty)(); + UPB_ASSERT(source); + upb_Message* clone = upb_Message_DeepClone( + UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(source), sub, arena); + *(upb_TaggedMessagePtr*)value = + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(clone, is_empty); + return clone != NULL; + } break; + } + UPB_UNREACHABLE(); +} + +upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type, + upb_CType value_type, + const upb_MiniTable* map_entry_table, + upb_Arena* arena) { + upb_Map* cloned_map = _upb_Map_New(arena, map->key_size, map->val_size); + if (cloned_map == NULL) { + return NULL; + } + upb_MessageValue key, val; + size_t iter = kUpb_Map_Begin; + while (upb_Map_Next(map, &key, &val, &iter)) { + const upb_MiniTableField* value_field = + upb_MiniTable_MapValue(map_entry_table); + const upb_MiniTable* value_sub = + upb_MiniTableField_CType(value_field) == kUpb_CType_Message + ? upb_MiniTable_GetSubMessageTable(map_entry_table, value_field) + : NULL; + upb_CType value_field_type = upb_MiniTableField_CType(value_field); + if (!upb_Clone_MessageValue(&val, value_field_type, value_sub, arena)) { + return NULL; + } + if (!upb_Map_Set(cloned_map, key, val, arena)) { + return NULL; + } + } + return cloned_map; +} + +static upb_Map* upb_Message_Map_DeepClone(const upb_Map* map, + const upb_MiniTable* mini_table, + const upb_MiniTableField* f, + upb_Message* clone, + upb_Arena* arena) { + // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. + const upb_MiniTable* map_entry_table = upb_MiniTableSub_Message( + mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); + UPB_ASSERT(map_entry_table); + + const upb_MiniTableField* key_field = upb_MiniTable_MapKey(map_entry_table); + const upb_MiniTableField* value_field = + upb_MiniTable_MapValue(map_entry_table); + + upb_Map* cloned_map = upb_Map_DeepClone( + map, upb_MiniTableField_CType(key_field), + upb_MiniTableField_CType(value_field), map_entry_table, arena); + if (!cloned_map) { + return NULL; + } + upb_Message_SetBaseField(clone, f, &cloned_map); + return cloned_map; +} + +upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, + const upb_MiniTable* sub, upb_Arena* arena) { + const size_t size = upb_Array_Size(array); + const int lg2 = UPB_PRIVATE(_upb_CType_SizeLg2)(value_type); + upb_Array* cloned_array = UPB_PRIVATE(_upb_Array_New)(arena, size, lg2); + if (!cloned_array) { + return NULL; + } + if (!UPB_PRIVATE(_upb_Array_ResizeUninitialized)(cloned_array, size, arena)) { + return NULL; + } + for (size_t i = 0; i < size; ++i) { + upb_MessageValue val = upb_Array_Get(array, i); + if (!upb_Clone_MessageValue(&val, value_type, sub, arena)) { + return false; + } + upb_Array_Set(cloned_array, i, val); + } + return cloned_array; +} + +static bool upb_Message_Array_DeepClone(const upb_Array* array, + const upb_MiniTable* mini_table, + const upb_MiniTableField* field, + upb_Message* clone, upb_Arena* arena) { + UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(field); + upb_Array* cloned_array = upb_Array_DeepClone( + array, upb_MiniTableField_CType(field), + upb_MiniTableField_CType(field) == kUpb_CType_Message + ? upb_MiniTable_GetSubMessageTable(mini_table, field) + : NULL, + arena); + + // Clear out upb_Array* due to parent memcpy. + upb_Message_SetBaseField(clone, field, &cloned_array); + return true; +} + +static bool upb_Clone_ExtensionValue( + const upb_MiniTableExtension* mini_table_ext, const upb_Extension* source, + upb_Extension* dest, upb_Arena* arena) { + dest->data = source->data; + return upb_Clone_MessageValue( + &dest->data, upb_MiniTableExtension_CType(mini_table_ext), + upb_MiniTableExtension_GetSubMessage(mini_table_ext), arena); +} + +upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, + const upb_MiniTable* mini_table, + upb_Arena* arena) { + upb_StringView empty_string = upb_StringView_FromDataAndSize(NULL, 0); + // Only copy message area skipping upb_Message_Internal. + memcpy(dst + 1, src + 1, mini_table->UPB_PRIVATE(size) - sizeof(upb_Message)); + for (int i = 0; i < upb_MiniTable_FieldCount(mini_table); ++i) { + const upb_MiniTableField* field = + upb_MiniTable_GetFieldByIndex(mini_table, i); + if (upb_MiniTableField_IsScalar(field)) { + switch (upb_MiniTableField_CType(field)) { + case kUpb_CType_Message: { + upb_TaggedMessagePtr tagged = + upb_Message_GetTaggedMessagePtr(src, field, NULL); + const upb_Message* sub_message = + UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(tagged); + if (sub_message != NULL) { + // If the message is currently in an unlinked, "empty" state we keep + // it that way, because we don't want to deal with decode options, + // decode status, or possible parse failure here. + bool is_empty = upb_TaggedMessagePtr_IsEmpty(tagged); + const upb_MiniTable* sub_message_table = + is_empty ? UPB_PRIVATE(_upb_MiniTable_Empty)() + : upb_MiniTable_GetSubMessageTable(mini_table, field); + upb_Message* dst_sub_message = + upb_Message_DeepClone(sub_message, sub_message_table, arena); + if (dst_sub_message == NULL) { + return NULL; + } + _upb_Message_SetTaggedMessagePtr( + dst, mini_table, field, + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(dst_sub_message, + is_empty)); + } + } break; + case kUpb_CType_String: + case kUpb_CType_Bytes: { + upb_StringView str = upb_Message_GetString(src, field, empty_string); + if (str.size != 0) { + if (!upb_Message_SetString( + dst, field, upb_Clone_StringView(str, arena), arena)) { + return NULL; + } + } + } break; + default: + // Scalar, already copied. + break; + } + } else { + if (upb_MiniTableField_IsMap(field)) { + const upb_Map* map = upb_Message_GetMap(src, field); + if (map != NULL) { + if (!upb_Message_Map_DeepClone(map, mini_table, field, dst, arena)) { + return NULL; + } + } + } else { + const upb_Array* array = upb_Message_GetArray(src, field); + if (array != NULL) { + if (!upb_Message_Array_DeepClone(array, mini_table, field, dst, + arena)) { + return NULL; + } + } + } + } + } + // Clone extensions. + size_t ext_count; + const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(src, &ext_count); + for (size_t i = 0; i < ext_count; ++i) { + const upb_Extension* msg_ext = &ext[i]; + const upb_MiniTableField* field = &msg_ext->ext->UPB_PRIVATE(field); + upb_Extension* dst_ext = UPB_PRIVATE(_upb_Message_GetOrCreateExtension)( + dst, msg_ext->ext, arena); + if (!dst_ext) return NULL; + if (upb_MiniTableField_IsScalar(field)) { + if (!upb_Clone_ExtensionValue(msg_ext->ext, msg_ext, dst_ext, arena)) { + return NULL; + } + } else { + upb_Array* msg_array = (upb_Array*)msg_ext->data.array_val; + UPB_ASSERT(msg_array); + upb_Array* cloned_array = upb_Array_DeepClone( + msg_array, upb_MiniTableField_CType(field), + upb_MiniTableExtension_GetSubMessage(msg_ext->ext), arena); + if (!cloned_array) { + return NULL; + } + dst_ext->data.array_val = cloned_array; + } + } + + // Clone unknowns. + size_t unknown_size = 0; + const char* ptr = upb_Message_GetUnknown(src, &unknown_size); + if (unknown_size != 0) { + UPB_ASSERT(ptr); + // Make a copy into destination arena. + if (!UPB_PRIVATE(_upb_Message_AddUnknown)(dst, ptr, unknown_size, arena)) { + return NULL; + } + } + return dst; +} + +bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src, + const upb_MiniTable* mini_table, upb_Arena* arena) { + upb_Message_Clear(dst, mini_table); + return _upb_Message_Copy(dst, src, mini_table, arena) != NULL; +} + +// Deep clones a message using the provided target arena. +// +// Returns NULL on failure. +upb_Message* upb_Message_DeepClone(const upb_Message* msg, + const upb_MiniTable* m, upb_Arena* arena) { + upb_Message* clone = upb_Message_New(m, arena); + return _upb_Message_Copy(clone, msg, m, arena); +} + +// Performs a shallow copy. TODO: Extend to handle unknown fields. +void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src, + const upb_MiniTable* m) { + memcpy(dst, src, m->UPB_PRIVATE(size)); +} + +// Performs a shallow clone. Ignores unknown fields. +upb_Message* upb_Message_ShallowClone(const upb_Message* msg, + const upb_MiniTable* m, + upb_Arena* arena) { + upb_Message* clone = upb_Message_New(m, arena); + upb_Message_ShallowCopy(clone, msg, m); + return clone; +} + + +#include +#include + + +// Must be last. + +typedef struct { + upb_MdDecoder base; + upb_Arena* arena; + upb_MiniTableEnum* enum_table; + uint32_t enum_value_count; + uint32_t enum_data_count; + uint32_t enum_data_capacity; +} upb_MdEnumDecoder; + +static size_t upb_MiniTableEnum_Size(size_t count) { + return sizeof(upb_MiniTableEnum) + count * sizeof(uint32_t); +} + +static upb_MiniTableEnum* _upb_MiniTable_AddEnumDataMember(upb_MdEnumDecoder* d, + uint32_t val) { + if (d->enum_data_count == d->enum_data_capacity) { + size_t old_sz = upb_MiniTableEnum_Size(d->enum_data_capacity); + d->enum_data_capacity = UPB_MAX(2, d->enum_data_capacity * 2); + size_t new_sz = upb_MiniTableEnum_Size(d->enum_data_capacity); + d->enum_table = upb_Arena_Realloc(d->arena, d->enum_table, old_sz, new_sz); + upb_MdDecoder_CheckOutOfMemory(&d->base, d->enum_table); + } + d->enum_table->UPB_PRIVATE(data)[d->enum_data_count++] = val; + return d->enum_table; +} + +static void upb_MiniTableEnum_BuildValue(upb_MdEnumDecoder* d, uint32_t val) { + upb_MiniTableEnum* table = d->enum_table; + d->enum_value_count++; + if (table->UPB_PRIVATE(value_count) || + (val > 512 && d->enum_value_count < val / 32)) { + if (table->UPB_PRIVATE(value_count) == 0) { + UPB_ASSERT(d->enum_data_count == table->UPB_PRIVATE(mask_limit) / 32); + } + table = _upb_MiniTable_AddEnumDataMember(d, val); + table->UPB_PRIVATE(value_count)++; + } else { + uint32_t new_mask_limit = ((val / 32) + 1) * 32; + while (table->UPB_PRIVATE(mask_limit) < new_mask_limit) { + table = _upb_MiniTable_AddEnumDataMember(d, 0); + table->UPB_PRIVATE(mask_limit) += 32; + } + table->UPB_PRIVATE(data)[val / 32] |= 1ULL << (val % 32); + } +} + +static upb_MiniTableEnum* upb_MtDecoder_DoBuildMiniTableEnum( + upb_MdEnumDecoder* d, const char* data, size_t len) { + // If the string is non-empty then it must begin with a version tag. + if (len) { + if (*data != kUpb_EncodedVersion_EnumV1) { + upb_MdDecoder_ErrorJmp(&d->base, "Invalid enum version: %c", *data); + } + data++; + len--; + } + + upb_MdDecoder_CheckOutOfMemory(&d->base, d->enum_table); + + // Guarantee at least 64 bits of mask without checking mask size. + d->enum_table->UPB_PRIVATE(mask_limit) = 64; + d->enum_table = _upb_MiniTable_AddEnumDataMember(d, 0); + d->enum_table = _upb_MiniTable_AddEnumDataMember(d, 0); + + d->enum_table->UPB_PRIVATE(value_count) = 0; + + const char* ptr = data; + uint32_t base = 0; + + while (ptr < d->base.end) { + char ch = *ptr++; + if (ch <= kUpb_EncodedValue_MaxEnumMask) { + uint32_t mask = _upb_FromBase92(ch); + for (int i = 0; i < 5; i++, base++, mask >>= 1) { + if (mask & 1) upb_MiniTableEnum_BuildValue(d, base); + } + } else if (kUpb_EncodedValue_MinSkip <= ch && + ch <= kUpb_EncodedValue_MaxSkip) { + uint32_t skip; + ptr = upb_MdDecoder_DecodeBase92Varint(&d->base, ptr, ch, + kUpb_EncodedValue_MinSkip, + kUpb_EncodedValue_MaxSkip, &skip); + base += skip; + } else { + upb_MdDecoder_ErrorJmp(&d->base, "Unexpected character: %c", ch); + } + } + + return d->enum_table; +} + +static upb_MiniTableEnum* upb_MtDecoder_BuildMiniTableEnum( + upb_MdEnumDecoder* const decoder, const char* const data, + size_t const len) { + if (UPB_SETJMP(decoder->base.err) != 0) return NULL; + return upb_MtDecoder_DoBuildMiniTableEnum(decoder, data, len); +} + +upb_MiniTableEnum* upb_MiniTableEnum_Build(const char* data, size_t len, + upb_Arena* arena, + upb_Status* status) { + upb_MdEnumDecoder decoder = { + .base = + { + .end = UPB_PTRADD(data, len), + .status = status, + }, + .arena = arena, + .enum_table = upb_Arena_Malloc(arena, upb_MiniTableEnum_Size(2)), + .enum_value_count = 0, + .enum_data_count = 0, + .enum_data_capacity = 1, + }; + + return upb_MtDecoder_BuildMiniTableEnum(&decoder, data, len); +} + + +#include +#include +#include +#include + + +// Must be last. + +// We reserve unused hasbits to make room for upb_Message fields. +#define kUpb_Reserved_Hasbytes sizeof(struct upb_Message) + +// 64 is the first hasbit that we currently use. +#define kUpb_Reserved_Hasbits (kUpb_Reserved_Hasbytes * 8) + +// Note: we sort by this number when calculating layout order. +typedef enum { + kUpb_LayoutItemType_OneofCase, // Oneof case. + kUpb_LayoutItemType_OneofField, // Oneof field data. + kUpb_LayoutItemType_Field, // Non-oneof field data. + + kUpb_LayoutItemType_Max = kUpb_LayoutItemType_Field, +} upb_LayoutItemType; + +#define kUpb_LayoutItem_IndexSentinel ((uint16_t) - 1) + +typedef struct { + // Index of the corresponding field. When this is a oneof field, the field's + // offset will be the index of the next field in a linked list. + uint16_t field_index; + uint16_t offset; + upb_FieldRep rep; + upb_LayoutItemType type; +} upb_LayoutItem; + +typedef struct { + upb_LayoutItem* data; + size_t size; + size_t capacity; +} upb_LayoutItemVector; + +typedef struct { + upb_MdDecoder base; + upb_MiniTable* table; + upb_MiniTableField* fields; + upb_MiniTablePlatform platform; + upb_LayoutItemVector vec; + upb_Arena* arena; +} upb_MtDecoder; + +// In each field's offset, we temporarily store a presence classifier: +enum PresenceClass { + kNoPresence = 0, + kHasbitPresence = 1, + kRequiredPresence = 2, + kOneofBase = 3, + // Negative values refer to a specific oneof with that number. Positive + // values >= kOneofBase indicate that this field is in a oneof, and specify + // the next field in this oneof's linked list. +}; + +static bool upb_MtDecoder_FieldIsPackable(upb_MiniTableField* field) { + return (field->UPB_PRIVATE(mode) & kUpb_FieldMode_Array) && + upb_FieldType_IsPackable(field->UPB_PRIVATE(descriptortype)); +} + +typedef struct { + uint16_t submsg_count; + uint16_t subenum_count; +} upb_SubCounts; + +static void upb_MiniTable_SetTypeAndSub(upb_MiniTableField* field, + upb_FieldType type, + upb_SubCounts* sub_counts, + uint64_t msg_modifiers, + bool is_proto3_enum) { + if (is_proto3_enum) { + UPB_ASSERT(type == kUpb_FieldType_Enum); + type = kUpb_FieldType_Int32; + field->UPB_PRIVATE(mode) |= kUpb_LabelFlags_IsAlternate; + } else if (type == kUpb_FieldType_String && + !(msg_modifiers & kUpb_MessageModifier_ValidateUtf8)) { + type = kUpb_FieldType_Bytes; + field->UPB_PRIVATE(mode) |= kUpb_LabelFlags_IsAlternate; + } + + field->UPB_PRIVATE(descriptortype) = type; + + if (upb_MtDecoder_FieldIsPackable(field) && + (msg_modifiers & kUpb_MessageModifier_DefaultIsPacked)) { + field->UPB_PRIVATE(mode) |= kUpb_LabelFlags_IsPacked; + } + + if (type == kUpb_FieldType_Message || type == kUpb_FieldType_Group) { + field->UPB_PRIVATE(submsg_index) = sub_counts->submsg_count++; + } else if (type == kUpb_FieldType_Enum) { + // We will need to update this later once we know the total number of + // submsg fields. + field->UPB_PRIVATE(submsg_index) = sub_counts->subenum_count++; + } else { + field->UPB_PRIVATE(submsg_index) = kUpb_NoSub; + } +} + +static const char kUpb_EncodedToType[] = { + [kUpb_EncodedType_Double] = kUpb_FieldType_Double, + [kUpb_EncodedType_Float] = kUpb_FieldType_Float, + [kUpb_EncodedType_Int64] = kUpb_FieldType_Int64, + [kUpb_EncodedType_UInt64] = kUpb_FieldType_UInt64, + [kUpb_EncodedType_Int32] = kUpb_FieldType_Int32, + [kUpb_EncodedType_Fixed64] = kUpb_FieldType_Fixed64, + [kUpb_EncodedType_Fixed32] = kUpb_FieldType_Fixed32, + [kUpb_EncodedType_Bool] = kUpb_FieldType_Bool, + [kUpb_EncodedType_String] = kUpb_FieldType_String, + [kUpb_EncodedType_Group] = kUpb_FieldType_Group, + [kUpb_EncodedType_Message] = kUpb_FieldType_Message, + [kUpb_EncodedType_Bytes] = kUpb_FieldType_Bytes, + [kUpb_EncodedType_UInt32] = kUpb_FieldType_UInt32, + [kUpb_EncodedType_OpenEnum] = kUpb_FieldType_Enum, + [kUpb_EncodedType_SFixed32] = kUpb_FieldType_SFixed32, + [kUpb_EncodedType_SFixed64] = kUpb_FieldType_SFixed64, + [kUpb_EncodedType_SInt32] = kUpb_FieldType_SInt32, + [kUpb_EncodedType_SInt64] = kUpb_FieldType_SInt64, + [kUpb_EncodedType_ClosedEnum] = kUpb_FieldType_Enum, +}; + +static void upb_MiniTable_SetField(upb_MtDecoder* d, uint8_t ch, + upb_MiniTableField* field, + uint64_t msg_modifiers, + upb_SubCounts* sub_counts) { + static const char kUpb_EncodedToFieldRep[] = { + [kUpb_EncodedType_Double] = kUpb_FieldRep_8Byte, + [kUpb_EncodedType_Float] = kUpb_FieldRep_4Byte, + [kUpb_EncodedType_Int64] = kUpb_FieldRep_8Byte, + [kUpb_EncodedType_UInt64] = kUpb_FieldRep_8Byte, + [kUpb_EncodedType_Int32] = kUpb_FieldRep_4Byte, + [kUpb_EncodedType_Fixed64] = kUpb_FieldRep_8Byte, + [kUpb_EncodedType_Fixed32] = kUpb_FieldRep_4Byte, + [kUpb_EncodedType_Bool] = kUpb_FieldRep_1Byte, + [kUpb_EncodedType_String] = kUpb_FieldRep_StringView, + [kUpb_EncodedType_Bytes] = kUpb_FieldRep_StringView, + [kUpb_EncodedType_UInt32] = kUpb_FieldRep_4Byte, + [kUpb_EncodedType_OpenEnum] = kUpb_FieldRep_4Byte, + [kUpb_EncodedType_SFixed32] = kUpb_FieldRep_4Byte, + [kUpb_EncodedType_SFixed64] = kUpb_FieldRep_8Byte, + [kUpb_EncodedType_SInt32] = kUpb_FieldRep_4Byte, + [kUpb_EncodedType_SInt64] = kUpb_FieldRep_8Byte, + [kUpb_EncodedType_ClosedEnum] = kUpb_FieldRep_4Byte, + }; + + char pointer_rep = d->platform == kUpb_MiniTablePlatform_32Bit + ? kUpb_FieldRep_4Byte + : kUpb_FieldRep_8Byte; + + int8_t type = _upb_FromBase92(ch); + if (ch >= _upb_ToBase92(kUpb_EncodedType_RepeatedBase)) { + type -= kUpb_EncodedType_RepeatedBase; + field->UPB_PRIVATE(mode) = kUpb_FieldMode_Array; + field->UPB_PRIVATE(mode) |= pointer_rep << kUpb_FieldRep_Shift; + field->UPB_PRIVATE(offset) = kNoPresence; + } else { + field->UPB_PRIVATE(mode) = kUpb_FieldMode_Scalar; + field->UPB_PRIVATE(offset) = kHasbitPresence; + if (type == kUpb_EncodedType_Group || type == kUpb_EncodedType_Message) { + field->UPB_PRIVATE(mode) |= pointer_rep << kUpb_FieldRep_Shift; + } else if ((unsigned long)type >= sizeof(kUpb_EncodedToFieldRep)) { + upb_MdDecoder_ErrorJmp(&d->base, "Invalid field type: %d", (int)type); + } else { + field->UPB_PRIVATE(mode) |= kUpb_EncodedToFieldRep[type] + << kUpb_FieldRep_Shift; + } + } + if ((unsigned long)type >= sizeof(kUpb_EncodedToType)) { + upb_MdDecoder_ErrorJmp(&d->base, "Invalid field type: %d", (int)type); + } + upb_MiniTable_SetTypeAndSub(field, kUpb_EncodedToType[type], sub_counts, + msg_modifiers, type == kUpb_EncodedType_OpenEnum); +} + +static void upb_MtDecoder_ModifyField(upb_MtDecoder* d, + uint32_t message_modifiers, + uint32_t field_modifiers, + upb_MiniTableField* field) { + if (field_modifiers & kUpb_EncodedFieldModifier_FlipPacked) { + if (!upb_MtDecoder_FieldIsPackable(field)) { + upb_MdDecoder_ErrorJmp(&d->base, + "Cannot flip packed on unpackable field %" PRIu32, + upb_MiniTableField_Number(field)); + } + field->UPB_PRIVATE(mode) ^= kUpb_LabelFlags_IsPacked; + } + + if (field_modifiers & kUpb_EncodedFieldModifier_FlipValidateUtf8) { + if (field->UPB_PRIVATE(descriptortype) != kUpb_FieldType_Bytes || + !(field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsAlternate)) { + upb_MdDecoder_ErrorJmp(&d->base, + "Cannot flip ValidateUtf8 on field %" PRIu32 + ", type=%d, mode=%d", + upb_MiniTableField_Number(field), + (int)field->UPB_PRIVATE(descriptortype), + (int)field->UPB_PRIVATE(mode)); + } + field->UPB_PRIVATE(descriptortype) = kUpb_FieldType_String; + field->UPB_PRIVATE(mode) &= ~kUpb_LabelFlags_IsAlternate; + } + + bool singular = field_modifiers & kUpb_EncodedFieldModifier_IsProto3Singular; + bool required = field_modifiers & kUpb_EncodedFieldModifier_IsRequired; + + // Validate. + if ((singular || required) && field->UPB_PRIVATE(offset) != kHasbitPresence) { + upb_MdDecoder_ErrorJmp(&d->base, + "Invalid modifier(s) for repeated field %" PRIu32, + upb_MiniTableField_Number(field)); + } + if (singular && required) { + upb_MdDecoder_ErrorJmp( + &d->base, "Field %" PRIu32 " cannot be both singular and required", + upb_MiniTableField_Number(field)); + } + + if (singular && upb_MiniTableField_IsSubMessage(field)) { + upb_MdDecoder_ErrorJmp(&d->base, + "Field %" PRIu32 " cannot be a singular submessage", + upb_MiniTableField_Number(field)); + } + + if (singular) field->UPB_PRIVATE(offset) = kNoPresence; + if (required) { + field->UPB_PRIVATE(offset) = kRequiredPresence; + } +} + +static void upb_MtDecoder_PushItem(upb_MtDecoder* d, upb_LayoutItem item) { + if (d->vec.size == d->vec.capacity) { + size_t new_cap = UPB_MAX(8, d->vec.size * 2); + d->vec.data = realloc(d->vec.data, new_cap * sizeof(*d->vec.data)); + upb_MdDecoder_CheckOutOfMemory(&d->base, d->vec.data); + d->vec.capacity = new_cap; + } + d->vec.data[d->vec.size++] = item; +} + +static void upb_MtDecoder_PushOneof(upb_MtDecoder* d, upb_LayoutItem item) { + if (item.field_index == kUpb_LayoutItem_IndexSentinel) { + upb_MdDecoder_ErrorJmp(&d->base, "Empty oneof"); + } + item.field_index -= kOneofBase; + + // Push oneof data. + item.type = kUpb_LayoutItemType_OneofField; + upb_MtDecoder_PushItem(d, item); + + // Push oneof case. + item.rep = kUpb_FieldRep_4Byte; // Field Number. + item.type = kUpb_LayoutItemType_OneofCase; + upb_MtDecoder_PushItem(d, item); +} + +static size_t upb_MtDecoder_SizeOfRep(upb_FieldRep rep, + upb_MiniTablePlatform platform) { + static const uint8_t kRepToSize32[] = { + [kUpb_FieldRep_1Byte] = 1, + [kUpb_FieldRep_4Byte] = 4, + [kUpb_FieldRep_StringView] = 8, + [kUpb_FieldRep_8Byte] = 8, + }; + static const uint8_t kRepToSize64[] = { + [kUpb_FieldRep_1Byte] = 1, + [kUpb_FieldRep_4Byte] = 4, + [kUpb_FieldRep_StringView] = 16, + [kUpb_FieldRep_8Byte] = 8, + }; + UPB_ASSERT(sizeof(upb_StringView) == + UPB_SIZE(kRepToSize32, kRepToSize64)[kUpb_FieldRep_StringView]); + return platform == kUpb_MiniTablePlatform_32Bit ? kRepToSize32[rep] + : kRepToSize64[rep]; +} + +static size_t upb_MtDecoder_AlignOfRep(upb_FieldRep rep, + upb_MiniTablePlatform platform) { + static const uint8_t kRepToAlign32[] = { + [kUpb_FieldRep_1Byte] = 1, + [kUpb_FieldRep_4Byte] = 4, + [kUpb_FieldRep_StringView] = 4, + [kUpb_FieldRep_8Byte] = 8, + }; + static const uint8_t kRepToAlign64[] = { + [kUpb_FieldRep_1Byte] = 1, + [kUpb_FieldRep_4Byte] = 4, + [kUpb_FieldRep_StringView] = 8, + [kUpb_FieldRep_8Byte] = 8, + }; + UPB_ASSERT(UPB_ALIGN_OF(upb_StringView) == + UPB_SIZE(kRepToAlign32, kRepToAlign64)[kUpb_FieldRep_StringView]); + return platform == kUpb_MiniTablePlatform_32Bit ? kRepToAlign32[rep] + : kRepToAlign64[rep]; +} + +static const char* upb_MtDecoder_DecodeOneofField(upb_MtDecoder* d, + const char* ptr, + char first_ch, + upb_LayoutItem* item) { + uint32_t field_num; + ptr = upb_MdDecoder_DecodeBase92Varint( + &d->base, ptr, first_ch, kUpb_EncodedValue_MinOneofField, + kUpb_EncodedValue_MaxOneofField, &field_num); + upb_MiniTableField* f = + (void*)upb_MiniTable_FindFieldByNumber(d->table, field_num); + + if (!f) { + upb_MdDecoder_ErrorJmp(&d->base, + "Couldn't add field number %" PRIu32 + " to oneof, no such field number.", + field_num); + } + if (f->UPB_PRIVATE(offset) != kHasbitPresence) { + upb_MdDecoder_ErrorJmp( + &d->base, + "Cannot add repeated, required, or singular field %" PRIu32 + " to oneof.", + field_num); + } + + // Oneof storage must be large enough to accommodate the largest member. + int rep = f->UPB_PRIVATE(mode) >> kUpb_FieldRep_Shift; + if (upb_MtDecoder_SizeOfRep(rep, d->platform) > + upb_MtDecoder_SizeOfRep(item->rep, d->platform)) { + item->rep = rep; + } + // Prepend this field to the linked list. + f->UPB_PRIVATE(offset) = item->field_index; + item->field_index = (f - d->fields) + kOneofBase; + return ptr; +} + +static const char* upb_MtDecoder_DecodeOneofs(upb_MtDecoder* d, + const char* ptr) { + upb_LayoutItem item = {.rep = 0, + .field_index = kUpb_LayoutItem_IndexSentinel}; + while (ptr < d->base.end) { + char ch = *ptr++; + if (ch == kUpb_EncodedValue_FieldSeparator) { + // Field separator, no action needed. + } else if (ch == kUpb_EncodedValue_OneofSeparator) { + // End of oneof. + upb_MtDecoder_PushOneof(d, item); + item.field_index = kUpb_LayoutItem_IndexSentinel; // Move to next oneof. + } else { + ptr = upb_MtDecoder_DecodeOneofField(d, ptr, ch, &item); + } + } + + // Push final oneof. + upb_MtDecoder_PushOneof(d, item); + return ptr; +} + +static const char* upb_MtDecoder_ParseModifier(upb_MtDecoder* d, + const char* ptr, char first_ch, + upb_MiniTableField* last_field, + uint64_t* msg_modifiers) { + uint32_t mod; + ptr = upb_MdDecoder_DecodeBase92Varint(&d->base, ptr, first_ch, + kUpb_EncodedValue_MinModifier, + kUpb_EncodedValue_MaxModifier, &mod); + if (last_field) { + upb_MtDecoder_ModifyField(d, *msg_modifiers, mod, last_field); + } else { + if (!d->table) { + upb_MdDecoder_ErrorJmp(&d->base, + "Extensions cannot have message modifiers"); + } + *msg_modifiers = mod; + } + + return ptr; +} + +static void upb_MtDecoder_AllocateSubs(upb_MtDecoder* d, + upb_SubCounts sub_counts) { + uint32_t total_count = sub_counts.submsg_count + sub_counts.subenum_count; + size_t subs_bytes = sizeof(*d->table->UPB_PRIVATE(subs)) * total_count; + upb_MiniTableSub* subs = upb_Arena_Malloc(d->arena, subs_bytes); + upb_MdDecoder_CheckOutOfMemory(&d->base, subs); + uint32_t i = 0; + for (; i < sub_counts.submsg_count; i++) { + subs[i].UPB_PRIVATE(submsg) = UPB_PRIVATE(_upb_MiniTable_Empty)(); + } + if (sub_counts.subenum_count) { + upb_MiniTableField* f = d->fields; + upb_MiniTableField* end_f = f + d->table->UPB_PRIVATE(field_count); + for (; f < end_f; f++) { + if (f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Enum) { + f->UPB_PRIVATE(submsg_index) += sub_counts.submsg_count; + } + } + for (; i < sub_counts.submsg_count + sub_counts.subenum_count; i++) { + subs[i].UPB_PRIVATE(subenum) = NULL; + } + } + d->table->UPB_PRIVATE(subs) = subs; +} + +static const char* upb_MtDecoder_Parse(upb_MtDecoder* d, const char* ptr, + size_t len, void* fields, + size_t field_size, uint16_t* field_count, + upb_SubCounts* sub_counts) { + uint64_t msg_modifiers = 0; + uint32_t last_field_number = 0; + upb_MiniTableField* last_field = NULL; + bool need_dense_below = d->table != NULL; + + d->base.end = UPB_PTRADD(ptr, len); + + while (ptr < d->base.end) { + char ch = *ptr++; + if (ch <= kUpb_EncodedValue_MaxField) { + if (!d->table && last_field) { + // For extensions, consume only a single field and then return. + return --ptr; + } + upb_MiniTableField* field = fields; + *field_count += 1; + fields = (char*)fields + field_size; + field->UPB_PRIVATE(number) = ++last_field_number; + last_field = field; + upb_MiniTable_SetField(d, ch, field, msg_modifiers, sub_counts); + } else if (kUpb_EncodedValue_MinModifier <= ch && + ch <= kUpb_EncodedValue_MaxModifier) { + ptr = upb_MtDecoder_ParseModifier(d, ptr, ch, last_field, &msg_modifiers); + if (msg_modifiers & kUpb_MessageModifier_IsExtendable) { + d->table->UPB_PRIVATE(ext) |= kUpb_ExtMode_Extendable; + } + } else if (ch == kUpb_EncodedValue_End) { + if (!d->table) { + upb_MdDecoder_ErrorJmp(&d->base, "Extensions cannot have oneofs."); + } + ptr = upb_MtDecoder_DecodeOneofs(d, ptr); + } else if (kUpb_EncodedValue_MinSkip <= ch && + ch <= kUpb_EncodedValue_MaxSkip) { + if (need_dense_below) { + d->table->UPB_PRIVATE(dense_below) = d->table->UPB_PRIVATE(field_count); + need_dense_below = false; + } + uint32_t skip; + ptr = upb_MdDecoder_DecodeBase92Varint(&d->base, ptr, ch, + kUpb_EncodedValue_MinSkip, + kUpb_EncodedValue_MaxSkip, &skip); + last_field_number += skip; + last_field_number--; // Next field seen will increment. + } else { + upb_MdDecoder_ErrorJmp(&d->base, "Invalid char: %c", ch); + } + } + + if (need_dense_below) { + d->table->UPB_PRIVATE(dense_below) = d->table->UPB_PRIVATE(field_count); + } + + return ptr; +} + +static void upb_MtDecoder_ParseMessage(upb_MtDecoder* d, const char* data, + size_t len) { + // Buffer length is an upper bound on the number of fields. We will return + // what we don't use. + d->fields = upb_Arena_Malloc(d->arena, sizeof(*d->fields) * len); + upb_MdDecoder_CheckOutOfMemory(&d->base, d->fields); + + upb_SubCounts sub_counts = {0, 0}; + d->table->UPB_PRIVATE(field_count) = 0; + d->table->UPB_PRIVATE(fields) = d->fields; + upb_MtDecoder_Parse(d, data, len, d->fields, sizeof(*d->fields), + &d->table->UPB_PRIVATE(field_count), &sub_counts); + + upb_Arena_ShrinkLast(d->arena, d->fields, sizeof(*d->fields) * len, + sizeof(*d->fields) * d->table->UPB_PRIVATE(field_count)); + d->table->UPB_PRIVATE(fields) = d->fields; + upb_MtDecoder_AllocateSubs(d, sub_counts); +} + +static int upb_MtDecoder_CompareFields(const void* _a, const void* _b) { + const upb_LayoutItem* a = _a; + const upb_LayoutItem* b = _b; + // Currently we just sort by: + // 1. rep (smallest fields first) + // 2. type (oneof cases first) + // 2. field_index (smallest numbers first) + // The main goal of this is to reduce space lost to padding. + // Later we may have more subtle reasons to prefer a different ordering. + const int rep_bits = upb_Log2Ceiling(kUpb_FieldRep_Max); + const int type_bits = upb_Log2Ceiling(kUpb_LayoutItemType_Max); + const int idx_bits = (sizeof(a->field_index) * 8); + UPB_ASSERT(idx_bits + rep_bits + type_bits < 32); +#define UPB_COMBINE(rep, ty, idx) (((rep << type_bits) | ty) << idx_bits) | idx + uint32_t a_packed = UPB_COMBINE(a->rep, a->type, a->field_index); + uint32_t b_packed = UPB_COMBINE(b->rep, b->type, b->field_index); + UPB_ASSERT(a_packed != b_packed); +#undef UPB_COMBINE + return a_packed < b_packed ? -1 : 1; +} + +static bool upb_MtDecoder_SortLayoutItems(upb_MtDecoder* d) { + // Add items for all non-oneof fields (oneofs were already added). + int n = d->table->UPB_PRIVATE(field_count); + for (int i = 0; i < n; i++) { + upb_MiniTableField* f = &d->fields[i]; + if (f->UPB_PRIVATE(offset) >= kOneofBase) continue; + upb_LayoutItem item = {.field_index = i, + .rep = f->UPB_PRIVATE(mode) >> kUpb_FieldRep_Shift, + .type = kUpb_LayoutItemType_Field}; + upb_MtDecoder_PushItem(d, item); + } + + if (d->vec.size) { + qsort(d->vec.data, d->vec.size, sizeof(*d->vec.data), + upb_MtDecoder_CompareFields); + } + + return true; +} + +static size_t upb_MiniTable_DivideRoundUp(size_t n, size_t d) { + return (n + d - 1) / d; +} + +static void upb_MtDecoder_AssignHasbits(upb_MtDecoder* d) { + upb_MiniTable* ret = d->table; + int n = ret->UPB_PRIVATE(field_count); + size_t last_hasbit = kUpb_Reserved_Hasbits - 1; + + // First assign required fields, which must have the lowest hasbits. + for (int i = 0; i < n; i++) { + upb_MiniTableField* field = + (upb_MiniTableField*)&ret->UPB_PRIVATE(fields)[i]; + if (field->UPB_PRIVATE(offset) == kRequiredPresence) { + field->presence = ++last_hasbit; + } else if (field->UPB_PRIVATE(offset) == kNoPresence) { + field->presence = 0; + } + } + if (last_hasbit > kUpb_Reserved_Hasbits + 63) { + upb_MdDecoder_ErrorJmp(&d->base, "Too many required fields"); + } + + ret->UPB_PRIVATE(required_count) = last_hasbit - (kUpb_Reserved_Hasbits - 1); + + // Next assign non-required hasbit fields. + for (int i = 0; i < n; i++) { + upb_MiniTableField* field = + (upb_MiniTableField*)&ret->UPB_PRIVATE(fields)[i]; + if (field->UPB_PRIVATE(offset) == kHasbitPresence) { + field->presence = ++last_hasbit; + } + } + + ret->UPB_PRIVATE(size) = + last_hasbit ? upb_MiniTable_DivideRoundUp(last_hasbit + 1, 8) : 0; +} + +static size_t upb_MtDecoder_Place(upb_MtDecoder* d, upb_FieldRep rep) { + size_t size = upb_MtDecoder_SizeOfRep(rep, d->platform); + size_t align = upb_MtDecoder_AlignOfRep(rep, d->platform); + size_t ret = UPB_ALIGN_UP(d->table->UPB_PRIVATE(size), align); + static const size_t max = UINT16_MAX; + size_t new_size = ret + size; + if (new_size > max) { + upb_MdDecoder_ErrorJmp( + &d->base, "Message size exceeded maximum size of %zu bytes", max); + } + d->table->UPB_PRIVATE(size) = new_size; + return ret; +} + +static void upb_MtDecoder_AssignOffsets(upb_MtDecoder* d) { + upb_LayoutItem* end = UPB_PTRADD(d->vec.data, d->vec.size); + + // Compute offsets. + for (upb_LayoutItem* item = d->vec.data; item < end; item++) { + item->offset = upb_MtDecoder_Place(d, item->rep); + } + + // Assign oneof case offsets. We must do these first, since assigning + // actual offsets will overwrite the links of the linked list. + for (upb_LayoutItem* item = d->vec.data; item < end; item++) { + if (item->type != kUpb_LayoutItemType_OneofCase) continue; + upb_MiniTableField* f = &d->fields[item->field_index]; + while (true) { + f->presence = ~item->offset; + if (f->UPB_PRIVATE(offset) == kUpb_LayoutItem_IndexSentinel) break; + UPB_ASSERT(f->UPB_PRIVATE(offset) - kOneofBase < + d->table->UPB_PRIVATE(field_count)); + f = &d->fields[f->UPB_PRIVATE(offset) - kOneofBase]; + } + } + + // Assign offsets. + for (upb_LayoutItem* item = d->vec.data; item < end; item++) { + upb_MiniTableField* f = &d->fields[item->field_index]; + switch (item->type) { + case kUpb_LayoutItemType_OneofField: + while (true) { + uint16_t next_offset = f->UPB_PRIVATE(offset); + f->UPB_PRIVATE(offset) = item->offset; + if (next_offset == kUpb_LayoutItem_IndexSentinel) break; + f = &d->fields[next_offset - kOneofBase]; + } + break; + case kUpb_LayoutItemType_Field: + f->UPB_PRIVATE(offset) = item->offset; + break; + default: + break; + } + } + + // The fasttable parser (supported on 64-bit only) depends on this being a + // multiple of 8 in order to satisfy UPB_MALLOC_ALIGN, which is also 8. + // + // On 32-bit we could potentially make this smaller, but there is no + // compelling reason to optimize this right now. + d->table->UPB_PRIVATE(size) = UPB_ALIGN_UP(d->table->UPB_PRIVATE(size), 8); +} + +static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d, + const upb_MiniTableField* f, + uint32_t expected_num) { + const char* name = expected_num == 1 ? "key" : "val"; + const uint32_t f_number = upb_MiniTableField_Number(f); + if (f_number != expected_num) { + upb_MdDecoder_ErrorJmp(&d->base, + "map %s did not have expected number (%d vs %d)", + name, expected_num, f_number); + } + + if (!upb_MiniTableField_IsScalar(f)) { + upb_MdDecoder_ErrorJmp( + &d->base, "map %s cannot be repeated or map, or be in oneof", name); + } + + uint32_t not_ok_types; + if (expected_num == 1) { + not_ok_types = (1 << kUpb_FieldType_Float) | (1 << kUpb_FieldType_Double) | + (1 << kUpb_FieldType_Message) | (1 << kUpb_FieldType_Group) | + (1 << kUpb_FieldType_Bytes) | (1 << kUpb_FieldType_Enum); + } else { + not_ok_types = 1 << kUpb_FieldType_Group; + } + + if ((1 << upb_MiniTableField_Type(f)) & not_ok_types) { + upb_MdDecoder_ErrorJmp(&d->base, "map %s cannot have type %d", name, + (int)f->UPB_PRIVATE(descriptortype)); + } +} + +static void upb_MtDecoder_ParseMap(upb_MtDecoder* d, const char* data, + size_t len) { + upb_MtDecoder_ParseMessage(d, data, len); + upb_MtDecoder_AssignHasbits(d); + + if (UPB_UNLIKELY(d->table->UPB_PRIVATE(field_count) != 2)) { + upb_MdDecoder_ErrorJmp(&d->base, "%hu fields in map", + d->table->UPB_PRIVATE(field_count)); + UPB_UNREACHABLE(); + } + + upb_LayoutItem* end = UPB_PTRADD(d->vec.data, d->vec.size); + for (upb_LayoutItem* item = d->vec.data; item < end; item++) { + if (item->type == kUpb_LayoutItemType_OneofCase) { + upb_MdDecoder_ErrorJmp(&d->base, "Map entry cannot have oneof"); + } + } + + upb_MtDecoder_ValidateEntryField(d, &d->table->UPB_PRIVATE(fields)[0], 1); + upb_MtDecoder_ValidateEntryField(d, &d->table->UPB_PRIVATE(fields)[1], 2); + + d->fields[0].UPB_PRIVATE(offset) = offsetof(upb_MapEntry, k); + d->fields[1].UPB_PRIVATE(offset) = offsetof(upb_MapEntry, v); + d->table->UPB_PRIVATE(size) = sizeof(upb_MapEntry); + + // Map entries have a special bit set to signal it's a map entry, used in + // upb_MiniTable_SetSubMessage() below. + d->table->UPB_PRIVATE(ext) |= kUpb_ExtMode_IsMapEntry; +} + +static void upb_MtDecoder_ParseMessageSet(upb_MtDecoder* d, const char* data, + size_t len) { + if (len > 0) { + upb_MdDecoder_ErrorJmp(&d->base, "Invalid message set encode length: %zu", + len); + } + + upb_MiniTable* ret = d->table; + ret->UPB_PRIVATE(size) = kUpb_Reserved_Hasbytes; + ret->UPB_PRIVATE(field_count) = 0; + ret->UPB_PRIVATE(ext) = kUpb_ExtMode_IsMessageSet; + ret->UPB_PRIVATE(dense_below) = 0; + ret->UPB_PRIVATE(table_mask) = -1; + ret->UPB_PRIVATE(required_count) = 0; +} + +static upb_MiniTable* upb_MtDecoder_DoBuildMiniTableWithBuf( + upb_MtDecoder* decoder, const char* data, size_t len, void** buf, + size_t* buf_size) { + upb_MdDecoder_CheckOutOfMemory(&decoder->base, decoder->table); + + decoder->table->UPB_PRIVATE(size) = kUpb_Reserved_Hasbytes; + decoder->table->UPB_PRIVATE(field_count) = 0; + decoder->table->UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable; + decoder->table->UPB_PRIVATE(dense_below) = 0; + decoder->table->UPB_PRIVATE(table_mask) = -1; + decoder->table->UPB_PRIVATE(required_count) = 0; +#if UPB_TRACING_ENABLED + // MiniTables built from MiniDescriptors will not be able to vend the message + // name unless it is explicitly set with upb_MiniTable_SetFullName(). + decoder->table->UPB_PRIVATE(full_name) = 0; +#endif + + // Strip off and verify the version tag. + if (!len--) goto done; + const char vers = *data++; + + switch (vers) { + case kUpb_EncodedVersion_MapV1: + upb_MtDecoder_ParseMap(decoder, data, len); + break; + + case kUpb_EncodedVersion_MessageV1: + upb_MtDecoder_ParseMessage(decoder, data, len); + upb_MtDecoder_AssignHasbits(decoder); + upb_MtDecoder_SortLayoutItems(decoder); + upb_MtDecoder_AssignOffsets(decoder); + break; + + case kUpb_EncodedVersion_MessageSetV1: + upb_MtDecoder_ParseMessageSet(decoder, data, len); + break; + + default: + upb_MdDecoder_ErrorJmp(&decoder->base, "Invalid message version: %c", + vers); + } + +done: + *buf = decoder->vec.data; + *buf_size = decoder->vec.capacity * sizeof(*decoder->vec.data); + return decoder->table; +} + +static upb_MiniTable* upb_MtDecoder_BuildMiniTableWithBuf( + upb_MtDecoder* const decoder, const char* const data, const size_t len, + void** const buf, size_t* const buf_size) { + if (UPB_SETJMP(decoder->base.err) != 0) { + *buf = decoder->vec.data; + *buf_size = decoder->vec.capacity * sizeof(*decoder->vec.data); + return NULL; + } + + return upb_MtDecoder_DoBuildMiniTableWithBuf(decoder, data, len, buf, + buf_size); +} + +upb_MiniTable* upb_MiniTable_BuildWithBuf(const char* data, size_t len, + upb_MiniTablePlatform platform, + upb_Arena* arena, void** buf, + size_t* buf_size, + upb_Status* status) { + upb_MtDecoder decoder = { + .base = {.status = status}, + .platform = platform, + .vec = + { + .data = *buf, + .capacity = *buf_size / sizeof(*decoder.vec.data), + .size = 0, + }, + .arena = arena, + .table = upb_Arena_Malloc(arena, sizeof(*decoder.table)), + }; + + return upb_MtDecoder_BuildMiniTableWithBuf(&decoder, data, len, buf, + buf_size); +} + +static const char* upb_MtDecoder_DoBuildMiniTableExtension( + upb_MtDecoder* decoder, const char* data, size_t len, + upb_MiniTableExtension* ext, const upb_MiniTable* extendee, + upb_MiniTableSub sub) { + // If the string is non-empty then it must begin with a version tag. + if (len) { + if (*data != kUpb_EncodedVersion_ExtensionV1) { + upb_MdDecoder_ErrorJmp(&decoder->base, "Invalid ext version: %c", *data); + } + data++; + len--; + } + + uint16_t count = 0; + upb_SubCounts sub_counts = {0, 0}; + const char* ret = upb_MtDecoder_Parse(decoder, data, len, ext, sizeof(*ext), + &count, &sub_counts); + if (!ret || count != 1) return NULL; + + upb_MiniTableField* f = &ext->UPB_PRIVATE(field); + + f->UPB_PRIVATE(mode) |= kUpb_LabelFlags_IsExtension; + f->UPB_PRIVATE(offset) = 0; + f->presence = 0; + + if (extendee->UPB_PRIVATE(ext) & kUpb_ExtMode_IsMessageSet) { + // Extensions of MessageSet must be messages. + if (!upb_MiniTableField_IsSubMessage(f)) return NULL; + + // Extensions of MessageSet must be non-repeating. + if (upb_MiniTableField_IsArray(f)) return NULL; + } + + ext->UPB_PRIVATE(extendee) = extendee; + ext->UPB_PRIVATE(sub) = sub; + + return ret; +} + +static const char* upb_MtDecoder_BuildMiniTableExtension( + upb_MtDecoder* const decoder, const char* const data, const size_t len, + upb_MiniTableExtension* const ext, const upb_MiniTable* const extendee, + const upb_MiniTableSub sub) { + if (UPB_SETJMP(decoder->base.err) != 0) return NULL; + return upb_MtDecoder_DoBuildMiniTableExtension(decoder, data, len, ext, + extendee, sub); +} + +const char* _upb_MiniTableExtension_Init(const char* data, size_t len, + upb_MiniTableExtension* ext, + const upb_MiniTable* extendee, + upb_MiniTableSub sub, + upb_MiniTablePlatform platform, + upb_Status* status) { + upb_MtDecoder decoder = { + .base = {.status = status}, + .arena = NULL, + .table = NULL, + .platform = platform, + }; + + return upb_MtDecoder_BuildMiniTableExtension(&decoder, data, len, ext, + extendee, sub); +} + +upb_MiniTableExtension* _upb_MiniTableExtension_Build( + const char* data, size_t len, const upb_MiniTable* extendee, + upb_MiniTableSub sub, upb_MiniTablePlatform platform, upb_Arena* arena, + upb_Status* status) { + upb_MiniTableExtension* ext = + upb_Arena_Malloc(arena, sizeof(upb_MiniTableExtension)); + if (UPB_UNLIKELY(!ext)) return NULL; + + const char* ptr = _upb_MiniTableExtension_Init(data, len, ext, extendee, sub, + platform, status); + if (UPB_UNLIKELY(!ptr)) return NULL; + + return ext; +} + +upb_MiniTable* _upb_MiniTable_Build(const char* data, size_t len, + upb_MiniTablePlatform platform, + upb_Arena* arena, upb_Status* status) { + void* buf = NULL; + size_t size = 0; + upb_MiniTable* ret = upb_MiniTable_BuildWithBuf(data, len, platform, arena, + &buf, &size, status); + free(buf); + return ret; +} + + +#include +#include + + +// Must be last. + +bool upb_MiniTable_SetSubMessage(upb_MiniTable* table, + upb_MiniTableField* field, + const upb_MiniTable* sub) { + UPB_ASSERT((uintptr_t)table->UPB_PRIVATE(fields) <= (uintptr_t)field && + (uintptr_t)field < (uintptr_t)(table->UPB_PRIVATE(fields) + + table->UPB_PRIVATE(field_count))); + UPB_ASSERT(sub); + + const bool sub_is_map = sub->UPB_PRIVATE(ext) & kUpb_ExtMode_IsMapEntry; + + switch (field->UPB_PRIVATE(descriptortype)) { + case kUpb_FieldType_Message: + if (sub_is_map) { + const bool table_is_map = + table->UPB_PRIVATE(ext) & kUpb_ExtMode_IsMapEntry; + if (UPB_UNLIKELY(table_is_map)) return false; + + field->UPB_PRIVATE(mode) = + (field->UPB_PRIVATE(mode) & ~kUpb_FieldMode_Mask) | + kUpb_FieldMode_Map; + } + break; + + case kUpb_FieldType_Group: + if (UPB_UNLIKELY(sub_is_map)) return false; + break; + + default: + return false; + } + + upb_MiniTableSub* table_sub = + (void*)&table->UPB_PRIVATE(subs)[field->UPB_PRIVATE(submsg_index)]; + // TODO: Add this assert back once YouTube is updated to not call + // this function repeatedly. + // UPB_ASSERT(UPB_PRIVATE(_upb_MiniTable_IsEmpty)(table_sub->submsg)); + *table_sub = upb_MiniTableSub_FromMessage(sub); + return true; +} + +bool upb_MiniTable_SetSubEnum(upb_MiniTable* table, upb_MiniTableField* field, + const upb_MiniTableEnum* sub) { + UPB_ASSERT((uintptr_t)table->UPB_PRIVATE(fields) <= (uintptr_t)field && + (uintptr_t)field < (uintptr_t)(table->UPB_PRIVATE(fields) + + table->UPB_PRIVATE(field_count))); + UPB_ASSERT(sub); + + upb_MiniTableSub* table_sub = + (void*)&table->UPB_PRIVATE(subs)[field->UPB_PRIVATE(submsg_index)]; + *table_sub = upb_MiniTableSub_FromEnum(sub); + return true; +} + +uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* m, + const upb_MiniTableField** subs) { + uint32_t msg_count = 0; + uint32_t enum_count = 0; + + for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { + const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i); + if (upb_MiniTableField_CType(f) == kUpb_CType_Message) { + *subs = f; + ++subs; + msg_count++; + } + } + + for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { + const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i); + if (upb_MiniTableField_IsClosedEnum(f)) { + *subs = f; + ++subs; + enum_count++; + } + } + + return (msg_count << 16) | enum_count; +} + +// The list of sub_tables and sub_enums must exactly match the number and order +// of sub-message fields and sub-enum fields given by upb_MiniTable_GetSubList() +// above. +bool upb_MiniTable_Link(upb_MiniTable* m, const upb_MiniTable** sub_tables, + size_t sub_table_count, + const upb_MiniTableEnum** sub_enums, + size_t sub_enum_count) { + uint32_t msg_count = 0; + uint32_t enum_count = 0; + + for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { + upb_MiniTableField* f = + (upb_MiniTableField*)upb_MiniTable_GetFieldByIndex(m, i); + if (upb_MiniTableField_CType(f) == kUpb_CType_Message) { + const upb_MiniTable* sub = sub_tables[msg_count++]; + if (msg_count > sub_table_count) return false; + if (sub && !upb_MiniTable_SetSubMessage(m, f, sub)) return false; + } + } + + for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { + upb_MiniTableField* f = + (upb_MiniTableField*)upb_MiniTable_GetFieldByIndex(m, i); + if (upb_MiniTableField_IsClosedEnum(f)) { + const upb_MiniTableEnum* sub = sub_enums[enum_count++]; + if (enum_count > sub_enum_count) return false; + if (sub && !upb_MiniTable_SetSubEnum(m, f, sub)) return false; + } + } + + return (msg_count == sub_table_count) && (enum_count == sub_enum_count); +} + + +#include +#include +#include + + +// Must be last. + +#define EXTREG_KEY_SIZE (sizeof(upb_MiniTable*) + sizeof(uint32_t)) + +struct upb_ExtensionRegistry { + upb_Arena* arena; + upb_strtable exts; // Key is upb_MiniTable* concatenated with fieldnum. +}; + +static void extreg_key(char* buf, const upb_MiniTable* l, uint32_t fieldnum) { + memcpy(buf, &l, sizeof(l)); + memcpy(buf + sizeof(l), &fieldnum, sizeof(fieldnum)); +} + +upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena) { + upb_ExtensionRegistry* r = upb_Arena_Malloc(arena, sizeof(*r)); + if (!r) return NULL; + r->arena = arena; + if (!upb_strtable_init(&r->exts, 8, arena)) return NULL; + return r; +} + +UPB_API bool upb_ExtensionRegistry_Add(upb_ExtensionRegistry* r, + const upb_MiniTableExtension* e) { + char buf[EXTREG_KEY_SIZE]; + extreg_key(buf, e->UPB_PRIVATE(extendee), upb_MiniTableExtension_Number(e)); + if (upb_strtable_lookup2(&r->exts, buf, EXTREG_KEY_SIZE, NULL)) return false; + return upb_strtable_insert(&r->exts, buf, EXTREG_KEY_SIZE, + upb_value_constptr(e), r->arena); +} + +bool upb_ExtensionRegistry_AddArray(upb_ExtensionRegistry* r, + const upb_MiniTableExtension** e, + size_t count) { + const upb_MiniTableExtension** start = e; + const upb_MiniTableExtension** end = UPB_PTRADD(e, count); + for (; e < end; e++) { + if (!upb_ExtensionRegistry_Add(r, *e)) goto failure; + } + return true; + +failure: + // Back out the entries previously added. + for (end = e, e = start; e < end; e++) { + const upb_MiniTableExtension* ext = *e; + char buf[EXTREG_KEY_SIZE]; + extreg_key(buf, ext->UPB_PRIVATE(extendee), + upb_MiniTableExtension_Number(ext)); + upb_strtable_remove2(&r->exts, buf, EXTREG_KEY_SIZE, NULL); + } + return false; +} + +const upb_MiniTableExtension* upb_ExtensionRegistry_Lookup( + const upb_ExtensionRegistry* r, const upb_MiniTable* t, uint32_t num) { + char buf[EXTREG_KEY_SIZE]; + upb_value v; + extreg_key(buf, t, num); + if (upb_strtable_lookup2(&r->exts, buf, EXTREG_KEY_SIZE, &v)) { + return upb_value_getconstptr(v); + } else { + return NULL; + } +} + + +#include +#include +#include + + +// Must be last. + +const upb_MiniTableField* upb_MiniTable_FindFieldByNumber( + const upb_MiniTable* m, uint32_t number) { + const size_t i = ((size_t)number) - 1; // 0 wraps to SIZE_MAX + + // Ideal case: index into dense fields + if (i < m->UPB_PRIVATE(dense_below)) { + UPB_ASSERT(m->UPB_PRIVATE(fields)[i].UPB_PRIVATE(number) == number); + return &m->UPB_PRIVATE(fields)[i]; + } + + // Slow case: binary search + int lo = m->UPB_PRIVATE(dense_below); + int hi = m->UPB_PRIVATE(field_count) - 1; + while (lo <= hi) { + int mid = (lo + hi) / 2; + uint32_t num = m->UPB_PRIVATE(fields)[mid].UPB_PRIVATE(number); + if (num < number) { + lo = mid + 1; + continue; + } + if (num > number) { + hi = mid - 1; + continue; + } + return &m->UPB_PRIVATE(fields)[mid]; + } + return NULL; +} + +const upb_MiniTableField* upb_MiniTable_GetOneof(const upb_MiniTable* m, + const upb_MiniTableField* f) { + if (UPB_UNLIKELY(!upb_MiniTableField_IsInOneof(f))) { + return NULL; + } + const upb_MiniTableField* ptr = &m->UPB_PRIVATE(fields)[0]; + const upb_MiniTableField* end = + &m->UPB_PRIVATE(fields)[m->UPB_PRIVATE(field_count)]; + for (; ptr < end; ptr++) { + if (ptr->presence == (*f).presence) { + return ptr; + } + } + return NULL; +} + +bool upb_MiniTable_NextOneofField(const upb_MiniTable* m, + const upb_MiniTableField** f) { + const upb_MiniTableField* ptr = *f; + const upb_MiniTableField* end = + &m->UPB_PRIVATE(fields)[m->UPB_PRIVATE(field_count)]; + while (++ptr < end) { + if (ptr->presence == (*f)->presence) { + *f = ptr; + return true; + } + } + return false; +} + + +#include +#include + + +// Must be last. + +// Checks if source and target mini table fields are identical. +// +// If the field is a sub message and sub messages are identical we record +// the association in table. +// +// Hashing the source sub message mini table and it's equivalent in the table +// stops recursing when a cycle is detected and instead just checks if the +// destination table is equal. +static upb_MiniTableEquals_Status upb_deep_check(const upb_MiniTable* src, + const upb_MiniTable* dst, + upb_inttable* table, + upb_Arena** arena) { + if (src->UPB_PRIVATE(field_count) != dst->UPB_PRIVATE(field_count)) + return kUpb_MiniTableEquals_NotEqual; + bool marked_src = false; + for (int i = 0; i < upb_MiniTable_FieldCount(src); i++) { + const upb_MiniTableField* src_field = upb_MiniTable_GetFieldByIndex(src, i); + const upb_MiniTableField* dst_field = upb_MiniTable_FindFieldByNumber( + dst, upb_MiniTableField_Number(src_field)); + + if (upb_MiniTableField_CType(src_field) != + upb_MiniTableField_CType(dst_field)) + return false; + if (src_field->UPB_PRIVATE(mode) != dst_field->UPB_PRIVATE(mode)) + return false; + if (src_field->UPB_PRIVATE(offset) != dst_field->UPB_PRIVATE(offset)) + return false; + if (src_field->presence != dst_field->presence) return false; + if (src_field->UPB_PRIVATE(submsg_index) != + dst_field->UPB_PRIVATE(submsg_index)) + return kUpb_MiniTableEquals_NotEqual; + + // Go no further if we are only checking for compatibility. + if (!table) continue; + + if (upb_MiniTableField_CType(src_field) == kUpb_CType_Message) { + if (!*arena) { + *arena = upb_Arena_New(); + if (!upb_inttable_init(table, *arena)) { + return kUpb_MiniTableEquals_OutOfMemory; + } + } + if (!marked_src) { + marked_src = true; + upb_value val; + val.val = (uint64_t)dst; + if (!upb_inttable_insert(table, (uintptr_t)src, val, *arena)) { + return kUpb_MiniTableEquals_OutOfMemory; + } + } + const upb_MiniTable* sub_src = + upb_MiniTable_GetSubMessageTable(src, src_field); + const upb_MiniTable* sub_dst = + upb_MiniTable_GetSubMessageTable(dst, dst_field); + if (sub_src != NULL) { + upb_value cmp; + if (upb_inttable_lookup(table, (uintptr_t)sub_src, &cmp)) { + // We already compared this src before. Check if same dst. + if (cmp.val != (uint64_t)sub_dst) { + return kUpb_MiniTableEquals_NotEqual; + } + } else { + // Recurse if not already visited. + upb_MiniTableEquals_Status s = + upb_deep_check(sub_src, sub_dst, table, arena); + if (s != kUpb_MiniTableEquals_Equal) { + return s; + } + } + } + } + } + return kUpb_MiniTableEquals_Equal; +} + +bool upb_MiniTable_Compatible(const upb_MiniTable* src, + const upb_MiniTable* dst) { + return upb_deep_check(src, dst, NULL, NULL); +} + +upb_MiniTableEquals_Status upb_MiniTable_Equals(const upb_MiniTable* src, + const upb_MiniTable* dst) { + // Arena allocated on demand for hash table. + upb_Arena* arena = NULL; + // Table to keep track of visited mini tables to guard against cycles. + upb_inttable table; + upb_MiniTableEquals_Status status = upb_deep_check(src, dst, &table, &arena); + if (arena) { + upb_Arena_Free(arena); + } + return status; +} + + +#include +#include +#include +#include +#include + + +// Must be last. + +// A few fake field types for our tables. +enum { + kUpb_FakeFieldType_FieldNotFound = 0, + kUpb_FakeFieldType_MessageSetItem = 19, +}; + +// DecodeOp: an action to be performed for a wire-type/field-type combination. +enum { + // Special ops: we don't write data to regular fields for these. + kUpb_DecodeOp_UnknownField = -1, + kUpb_DecodeOp_MessageSetItem = -2, + + // Scalar-only ops. + kUpb_DecodeOp_Scalar1Byte = 0, + kUpb_DecodeOp_Scalar4Byte = 2, + kUpb_DecodeOp_Scalar8Byte = 3, + kUpb_DecodeOp_Enum = 1, + + // Scalar/repeated ops. + kUpb_DecodeOp_String = 4, + kUpb_DecodeOp_Bytes = 5, + kUpb_DecodeOp_SubMessage = 6, + + // Repeated-only ops (also see macros below). + kUpb_DecodeOp_PackedEnum = 13, +}; + +// For packed fields it is helpful to be able to recover the lg2 of the data +// size from the op. +#define OP_FIXPCK_LG2(n) (n + 5) /* n in [2, 3] => op in [7, 8] */ +#define OP_VARPCK_LG2(n) (n + 9) /* n in [0, 2, 3] => op in [9, 11, 12] */ + +typedef union { + bool bool_val; + uint32_t uint32_val; + uint64_t uint64_val; + uint32_t size; +} wireval; + +// Ideally these two functions should take the owning MiniTable pointer as a +// first argument, then we could just put them in mini_table/message.h as nice +// clean getters. But we don't have that so instead we gotta write these +// Frankenfunctions that take an array of subtables. +// TODO: Move these to mini_table/ anyway since there are other places +// that could use them. + +// Returns the MiniTable corresponding to a given MiniTableField +// from an array of MiniTableSubs. +static const upb_MiniTable* _upb_MiniTableSubs_MessageByField( + const upb_MiniTableSub* subs, const upb_MiniTableField* field) { + return upb_MiniTableSub_Message(subs[field->UPB_PRIVATE(submsg_index)]); +} + +// Returns the MiniTableEnum corresponding to a given MiniTableField +// from an array of MiniTableSub. +static const upb_MiniTableEnum* _upb_MiniTableSubs_EnumByField( + const upb_MiniTableSub* subs, const upb_MiniTableField* field) { + return upb_MiniTableSub_Enum(subs[field->UPB_PRIVATE(submsg_index)]); +} + +static const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr, + upb_Message* msg, + const upb_MiniTable* layout); + +UPB_NORETURN static void* _upb_Decoder_ErrorJmp(upb_Decoder* d, + upb_DecodeStatus status) { + UPB_ASSERT(status != kUpb_DecodeStatus_Ok); + d->status = status; + UPB_LONGJMP(d->err, 1); +} + +const char* _upb_FastDecoder_ErrorJmp(upb_Decoder* d, int status) { + UPB_ASSERT(status != kUpb_DecodeStatus_Ok); + d->status = status; + UPB_LONGJMP(d->err, 1); + return NULL; +} + +static void _upb_Decoder_VerifyUtf8(upb_Decoder* d, const char* buf, int len) { + if (!_upb_Decoder_VerifyUtf8Inline(buf, len)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_BadUtf8); + } +} + +static bool _upb_Decoder_Reserve(upb_Decoder* d, upb_Array* arr, size_t elem) { + bool need_realloc = + arr->UPB_PRIVATE(capacity) - arr->UPB_PRIVATE(size) < elem; + if (need_realloc && !UPB_PRIVATE(_upb_Array_Realloc)( + arr, arr->UPB_PRIVATE(size) + elem, &d->arena)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + return need_realloc; +} + +typedef struct { + const char* ptr; + uint64_t val; +} _upb_DecodeLongVarintReturn; + +UPB_NOINLINE +static _upb_DecodeLongVarintReturn _upb_Decoder_DecodeLongVarint( + const char* ptr, uint64_t val) { + _upb_DecodeLongVarintReturn ret = {NULL, 0}; + uint64_t byte; + for (int i = 1; i < 10; i++) { + byte = (uint8_t)ptr[i]; + val += (byte - 1) << (i * 7); + if (!(byte & 0x80)) { + ret.ptr = ptr + i + 1; + ret.val = val; + return ret; + } + } + return ret; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr, + uint64_t* val) { + uint64_t byte = (uint8_t)*ptr; + if (UPB_LIKELY((byte & 0x80) == 0)) { + *val = byte; + return ptr + 1; + } else { + _upb_DecodeLongVarintReturn res = _upb_Decoder_DecodeLongVarint(ptr, byte); + if (!res.ptr) _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + *val = res.val; + return res.ptr; + } +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr, + uint32_t* val) { + uint64_t byte = (uint8_t)*ptr; + if (UPB_LIKELY((byte & 0x80) == 0)) { + *val = byte; + return ptr + 1; + } else { + const char* start = ptr; + _upb_DecodeLongVarintReturn res = _upb_Decoder_DecodeLongVarint(ptr, byte); + if (!res.ptr || res.ptr - start > 5 || res.val > UINT32_MAX) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + } + *val = res.val; + return res.ptr; + } +} + +UPB_FORCEINLINE +const char* upb_Decoder_DecodeSize(upb_Decoder* d, const char* ptr, + uint32_t* size) { + uint64_t size64; + ptr = _upb_Decoder_DecodeVarint(d, ptr, &size64); + if (size64 >= INT32_MAX || + !upb_EpsCopyInputStream_CheckSize(&d->input, ptr, (int)size64)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + } + *size = size64; + return ptr; +} + +static void _upb_Decoder_MungeInt32(wireval* val) { + if (!upb_IsLittleEndian()) { + /* The next stage will memcpy(dst, &val, 4) */ + val->uint32_val = val->uint64_val; + } +} + +static void _upb_Decoder_Munge(int type, wireval* val) { + switch (type) { + case kUpb_FieldType_Bool: + val->bool_val = val->uint64_val != 0; + break; + case kUpb_FieldType_SInt32: { + uint32_t n = val->uint64_val; + val->uint32_val = (n >> 1) ^ -(int32_t)(n & 1); + break; + } + case kUpb_FieldType_SInt64: { + uint64_t n = val->uint64_val; + val->uint64_val = (n >> 1) ^ -(int64_t)(n & 1); + break; + } + case kUpb_FieldType_Int32: + case kUpb_FieldType_UInt32: + case kUpb_FieldType_Enum: + _upb_Decoder_MungeInt32(val); + break; + } +} + +static upb_Message* _upb_Decoder_NewSubMessage(upb_Decoder* d, + const upb_MiniTableSub* subs, + const upb_MiniTableField* field, + upb_TaggedMessagePtr* target) { + const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field); + UPB_ASSERT(subl); + upb_Message* msg = _upb_Message_New(subl, &d->arena); + if (!msg) _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + + // Extensions should not be unlinked. A message extension should not be + // registered until its sub-message type is available to be linked. + bool is_empty = UPB_PRIVATE(_upb_MiniTable_IsEmpty)(subl); + bool is_extension = field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension; + UPB_ASSERT(!(is_empty && is_extension)); + + if (is_empty && !(d->options & kUpb_DecodeOption_ExperimentalAllowUnlinked)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_UnlinkedSubMessage); + } + + upb_TaggedMessagePtr tagged = + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(msg, is_empty); + memcpy(target, &tagged, sizeof(tagged)); + return msg; +} + +static upb_Message* _upb_Decoder_ReuseSubMessage( + upb_Decoder* d, const upb_MiniTableSub* subs, + const upb_MiniTableField* field, upb_TaggedMessagePtr* target) { + upb_TaggedMessagePtr tagged = *target; + const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field); + UPB_ASSERT(subl); + if (!upb_TaggedMessagePtr_IsEmpty(tagged) || + UPB_PRIVATE(_upb_MiniTable_IsEmpty)(subl)) { + return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(tagged); + } + + // We found an empty message from a previous parse that was performed before + // this field was linked. But it is linked now, so we want to allocate a new + // message of the correct type and promote data into it before continuing. + upb_Message* existing = + UPB_PRIVATE(_upb_TaggedMessagePtr_GetEmptyMessage)(tagged); + upb_Message* promoted = _upb_Decoder_NewSubMessage(d, subs, field, target); + size_t size; + const char* unknown = upb_Message_GetUnknown(existing, &size); + upb_DecodeStatus status = upb_Decode(unknown, size, promoted, subl, d->extreg, + d->options, &d->arena); + if (status != kUpb_DecodeStatus_Ok) _upb_Decoder_ErrorJmp(d, status); + return promoted; +} + +static const char* _upb_Decoder_ReadString(upb_Decoder* d, const char* ptr, + int size, upb_StringView* str) { + const char* str_ptr = ptr; + ptr = upb_EpsCopyInputStream_ReadString(&d->input, &str_ptr, size, &d->arena); + if (!ptr) _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + str->data = str_ptr; + str->size = size; + return ptr; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d, const char* ptr, + upb_Message* submsg, + const upb_MiniTable* subl, + uint32_t expected_end_group) { + if (--d->depth < 0) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_MaxDepthExceeded); + } + ptr = _upb_Decoder_DecodeMessage(d, ptr, submsg, subl); + d->depth++; + if (d->end_group != expected_end_group) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + } + return ptr; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeSubMessage(upb_Decoder* d, const char* ptr, + upb_Message* submsg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* field, + int size) { + int saved_delta = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, size); + const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field); + UPB_ASSERT(subl); + ptr = _upb_Decoder_RecurseSubMessage(d, ptr, submsg, subl, DECODE_NOGROUP); + upb_EpsCopyInputStream_PopLimit(&d->input, ptr, saved_delta); + return ptr; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr, + upb_Message* submsg, + const upb_MiniTable* subl, + uint32_t number) { + if (_upb_Decoder_IsDone(d, &ptr)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + } + ptr = _upb_Decoder_RecurseSubMessage(d, ptr, submsg, subl, number); + d->end_group = DECODE_NOGROUP; + return ptr; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeUnknownGroup(upb_Decoder* d, const char* ptr, + uint32_t number) { + return _upb_Decoder_DecodeGroup(d, ptr, NULL, NULL, number); +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeKnownGroup(upb_Decoder* d, const char* ptr, + upb_Message* submsg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* field) { + const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field); + UPB_ASSERT(subl); + return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl, + field->UPB_PRIVATE(number)); +} + +static char* upb_Decoder_EncodeVarint32(uint32_t val, char* ptr) { + do { + uint8_t byte = val & 0x7fU; + val >>= 7; + if (val) byte |= 0x80U; + *(ptr++) = byte; + } while (val); + return ptr; +} + +static void _upb_Decoder_AddUnknownVarints(upb_Decoder* d, upb_Message* msg, + uint32_t val1, uint32_t val2) { + char buf[20]; + char* end = buf; + end = upb_Decoder_EncodeVarint32(val1, end); + end = upb_Decoder_EncodeVarint32(val2, end); + + if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, buf, end - buf, &d->arena)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } +} + +UPB_FORCEINLINE +bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr, upb_Message* msg, + const upb_MiniTableEnum* e, + const upb_MiniTableField* field, wireval* val) { + const uint32_t v = val->uint32_val; + + if (UPB_LIKELY(upb_MiniTableEnum_CheckValue(e, v))) return true; + + // Unrecognized enum goes into unknown fields. + // For packed fields the tag could be arbitrarily far in the past, + // so we just re-encode the tag and value here. + const uint32_t tag = + ((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint; + upb_Message* unknown_msg = + field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension ? d->unknown_msg + : msg; + _upb_Decoder_AddUnknownVarints(d, unknown_msg, tag, v); + return false; +} + +UPB_NOINLINE +static const char* _upb_Decoder_DecodeEnumArray(upb_Decoder* d, const char* ptr, + upb_Message* msg, + upb_Array* arr, + const upb_MiniTableSub* subs, + const upb_MiniTableField* field, + wireval* val) { + const upb_MiniTableEnum* e = _upb_MiniTableSubs_EnumByField(subs, field); + if (!_upb_Decoder_CheckEnum(d, ptr, msg, e, field, val)) return ptr; + void* mem = UPB_PTR_AT(upb_Array_MutableDataPtr(arr), + arr->UPB_PRIVATE(size) * 4, void); + arr->UPB_PRIVATE(size)++; + memcpy(mem, val, 4); + return ptr; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeFixedPacked(upb_Decoder* d, const char* ptr, + upb_Array* arr, wireval* val, + const upb_MiniTableField* field, + int lg2) { + int mask = (1 << lg2) - 1; + size_t count = val->size >> lg2; + if ((val->size & mask) != 0) { + // Length isn't a round multiple of elem size. + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + } + _upb_Decoder_Reserve(d, arr, count); + void* mem = UPB_PTR_AT(upb_Array_MutableDataPtr(arr), + arr->UPB_PRIVATE(size) << lg2, void); + arr->UPB_PRIVATE(size) += count; + // Note: if/when the decoder supports multi-buffer input, we will need to + // handle buffer seams here. + if (upb_IsLittleEndian()) { + ptr = upb_EpsCopyInputStream_Copy(&d->input, ptr, mem, val->size); + } else { + int delta = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size); + char* dst = mem; + while (!_upb_Decoder_IsDone(d, &ptr)) { + if (lg2 == 2) { + ptr = upb_WireReader_ReadFixed32(ptr, dst); + dst += 4; + } else { + UPB_ASSERT(lg2 == 3); + ptr = upb_WireReader_ReadFixed64(ptr, dst); + dst += 8; + } + } + upb_EpsCopyInputStream_PopLimit(&d->input, ptr, delta); + } + + return ptr; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeVarintPacked(upb_Decoder* d, const char* ptr, + upb_Array* arr, wireval* val, + const upb_MiniTableField* field, + int lg2) { + int scale = 1 << lg2; + int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size); + char* out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr), + arr->UPB_PRIVATE(size) << lg2, void); + while (!_upb_Decoder_IsDone(d, &ptr)) { + wireval elem; + ptr = _upb_Decoder_DecodeVarint(d, ptr, &elem.uint64_val); + _upb_Decoder_Munge(field->UPB_PRIVATE(descriptortype), &elem); + if (_upb_Decoder_Reserve(d, arr, 1)) { + out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr), + arr->UPB_PRIVATE(size) << lg2, void); + } + arr->UPB_PRIVATE(size)++; + memcpy(out, &elem, scale); + out += scale; + } + upb_EpsCopyInputStream_PopLimit(&d->input, ptr, saved_limit); + return ptr; +} + +UPB_NOINLINE +static const char* _upb_Decoder_DecodeEnumPacked( + upb_Decoder* d, const char* ptr, upb_Message* msg, upb_Array* arr, + const upb_MiniTableSub* subs, const upb_MiniTableField* field, + wireval* val) { + const upb_MiniTableEnum* e = _upb_MiniTableSubs_EnumByField(subs, field); + int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size); + char* out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr), + arr->UPB_PRIVATE(size) * 4, void); + while (!_upb_Decoder_IsDone(d, &ptr)) { + wireval elem; + ptr = _upb_Decoder_DecodeVarint(d, ptr, &elem.uint64_val); + _upb_Decoder_MungeInt32(&elem); + if (!_upb_Decoder_CheckEnum(d, ptr, msg, e, field, &elem)) { + continue; + } + if (_upb_Decoder_Reserve(d, arr, 1)) { + out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr), + arr->UPB_PRIVATE(size) * 4, void); + } + arr->UPB_PRIVATE(size)++; + memcpy(out, &elem, 4); + out += 4; + } + upb_EpsCopyInputStream_PopLimit(&d->input, ptr, saved_limit); + return ptr; +} + +static upb_Array* _upb_Decoder_CreateArray(upb_Decoder* d, + const upb_MiniTableField* field) { + const upb_FieldType field_type = field->UPB_PRIVATE(descriptortype); + const size_t lg2 = UPB_PRIVATE(_upb_FieldType_SizeLg2)(field_type); + upb_Array* ret = UPB_PRIVATE(_upb_Array_New)(&d->arena, 4, lg2); + if (!ret) _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + return ret; +} + +static const char* _upb_Decoder_DecodeToArray(upb_Decoder* d, const char* ptr, + upb_Message* msg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* field, + wireval* val, int op) { + upb_Array** arrp = UPB_PTR_AT(msg, field->UPB_PRIVATE(offset), void); + upb_Array* arr = *arrp; + void* mem; + + if (arr) { + _upb_Decoder_Reserve(d, arr, 1); + } else { + arr = _upb_Decoder_CreateArray(d, field); + *arrp = arr; + } + + switch (op) { + case kUpb_DecodeOp_Scalar1Byte: + case kUpb_DecodeOp_Scalar4Byte: + case kUpb_DecodeOp_Scalar8Byte: + /* Append scalar value. */ + mem = UPB_PTR_AT(upb_Array_MutableDataPtr(arr), + arr->UPB_PRIVATE(size) << op, void); + arr->UPB_PRIVATE(size)++; + memcpy(mem, val, 1 << op); + return ptr; + case kUpb_DecodeOp_String: + _upb_Decoder_VerifyUtf8(d, ptr, val->size); + /* Fallthrough. */ + case kUpb_DecodeOp_Bytes: { + /* Append bytes. */ + upb_StringView* str = (upb_StringView*)upb_Array_MutableDataPtr(arr) + + arr->UPB_PRIVATE(size); + arr->UPB_PRIVATE(size)++; + return _upb_Decoder_ReadString(d, ptr, val->size, str); + } + case kUpb_DecodeOp_SubMessage: { + /* Append submessage / group. */ + upb_TaggedMessagePtr* target = UPB_PTR_AT( + upb_Array_MutableDataPtr(arr), arr->UPB_PRIVATE(size) * sizeof(void*), + upb_TaggedMessagePtr); + upb_Message* submsg = _upb_Decoder_NewSubMessage(d, subs, field, target); + arr->UPB_PRIVATE(size)++; + if (UPB_UNLIKELY(field->UPB_PRIVATE(descriptortype) == + kUpb_FieldType_Group)) { + return _upb_Decoder_DecodeKnownGroup(d, ptr, submsg, subs, field); + } else { + return _upb_Decoder_DecodeSubMessage(d, ptr, submsg, subs, field, + val->size); + } + } + case OP_FIXPCK_LG2(2): + case OP_FIXPCK_LG2(3): + return _upb_Decoder_DecodeFixedPacked(d, ptr, arr, val, field, + op - OP_FIXPCK_LG2(0)); + case OP_VARPCK_LG2(0): + case OP_VARPCK_LG2(2): + case OP_VARPCK_LG2(3): + return _upb_Decoder_DecodeVarintPacked(d, ptr, arr, val, field, + op - OP_VARPCK_LG2(0)); + case kUpb_DecodeOp_Enum: + return _upb_Decoder_DecodeEnumArray(d, ptr, msg, arr, subs, field, val); + case kUpb_DecodeOp_PackedEnum: + return _upb_Decoder_DecodeEnumPacked(d, ptr, msg, arr, subs, field, val); + default: + UPB_UNREACHABLE(); + } +} + +static upb_Map* _upb_Decoder_CreateMap(upb_Decoder* d, + const upb_MiniTable* entry) { + // Maps descriptor type -> upb map size + static const uint8_t kSizeInMap[] = { + [0] = -1, // invalid descriptor type + [kUpb_FieldType_Double] = 8, + [kUpb_FieldType_Float] = 4, + [kUpb_FieldType_Int64] = 8, + [kUpb_FieldType_UInt64] = 8, + [kUpb_FieldType_Int32] = 4, + [kUpb_FieldType_Fixed64] = 8, + [kUpb_FieldType_Fixed32] = 4, + [kUpb_FieldType_Bool] = 1, + [kUpb_FieldType_String] = UPB_MAPTYPE_STRING, + [kUpb_FieldType_Group] = sizeof(void*), + [kUpb_FieldType_Message] = sizeof(void*), + [kUpb_FieldType_Bytes] = UPB_MAPTYPE_STRING, + [kUpb_FieldType_UInt32] = 4, + [kUpb_FieldType_Enum] = 4, + [kUpb_FieldType_SFixed32] = 4, + [kUpb_FieldType_SFixed64] = 8, + [kUpb_FieldType_SInt32] = 4, + [kUpb_FieldType_SInt64] = 8, + }; + + const upb_MiniTableField* key_field = &entry->UPB_PRIVATE(fields)[0]; + const upb_MiniTableField* val_field = &entry->UPB_PRIVATE(fields)[1]; + char key_size = kSizeInMap[key_field->UPB_PRIVATE(descriptortype)]; + char val_size = kSizeInMap[val_field->UPB_PRIVATE(descriptortype)]; + UPB_ASSERT(key_field->UPB_PRIVATE(offset) == offsetof(upb_MapEntry, k)); + UPB_ASSERT(val_field->UPB_PRIVATE(offset) == offsetof(upb_MapEntry, v)); + upb_Map* ret = _upb_Map_New(&d->arena, key_size, val_size); + if (!ret) _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + return ret; +} + +static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr, + upb_Message* msg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* field, + wireval* val) { + upb_Map** map_p = UPB_PTR_AT(msg, field->UPB_PRIVATE(offset), upb_Map*); + upb_Map* map = *map_p; + upb_MapEntry ent; + UPB_ASSERT(upb_MiniTableField_Type(field) == kUpb_FieldType_Message); + const upb_MiniTable* entry = _upb_MiniTableSubs_MessageByField(subs, field); + + UPB_ASSERT(entry); + UPB_ASSERT(entry->UPB_PRIVATE(field_count) == 2); + UPB_ASSERT(upb_MiniTableField_IsScalar(&entry->UPB_PRIVATE(fields)[0])); + UPB_ASSERT(upb_MiniTableField_IsScalar(&entry->UPB_PRIVATE(fields)[1])); + + if (!map) { + map = _upb_Decoder_CreateMap(d, entry); + *map_p = map; + } + + // Parse map entry. + memset(&ent, 0, sizeof(ent)); + + if (entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) == + kUpb_FieldType_Message || + entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) == + kUpb_FieldType_Group) { + // Create proactively to handle the case where it doesn't appear. + upb_TaggedMessagePtr msg; + _upb_Decoder_NewSubMessage(d, entry->UPB_PRIVATE(subs), + &entry->UPB_PRIVATE(fields)[1], &msg); + ent.v.val = upb_value_uintptr(msg); + } + + ptr = _upb_Decoder_DecodeSubMessage(d, ptr, &ent.message, subs, field, + val->size); + // check if ent had any unknown fields + size_t size; + upb_Message_GetUnknown(&ent.message, &size); + if (size != 0) { + char* buf; + size_t size; + uint32_t tag = + ((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Delimited; + upb_EncodeStatus status = + upb_Encode(&ent.message, entry, 0, &d->arena, &buf, &size); + if (status != kUpb_EncodeStatus_Ok) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + _upb_Decoder_AddUnknownVarints(d, msg, tag, size); + if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, buf, size, &d->arena)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + } else { + if (_upb_Map_Insert(map, &ent.k, map->key_size, &ent.v, map->val_size, + &d->arena) == kUpb_MapInsertStatus_OutOfMemory) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + } + return ptr; +} + +static const char* _upb_Decoder_DecodeToSubMessage( + upb_Decoder* d, const char* ptr, upb_Message* msg, + const upb_MiniTableSub* subs, const upb_MiniTableField* field, wireval* val, + int op) { + void* mem = UPB_PTR_AT(msg, field->UPB_PRIVATE(offset), void); + int type = field->UPB_PRIVATE(descriptortype); + + if (UPB_UNLIKELY(op == kUpb_DecodeOp_Enum) && + !_upb_Decoder_CheckEnum(d, ptr, msg, + _upb_MiniTableSubs_EnumByField(subs, field), + field, val)) { + return ptr; + } + + // Set presence if necessary. + if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(field)) { + UPB_PRIVATE(_upb_Message_SetHasbit)(msg, field); + } else if (upb_MiniTableField_IsInOneof(field)) { + // Oneof case + uint32_t* oneof_case = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, field); + if (op == kUpb_DecodeOp_SubMessage && + *oneof_case != field->UPB_PRIVATE(number)) { + memset(mem, 0, sizeof(void*)); + } + *oneof_case = field->UPB_PRIVATE(number); + } + + // Store into message. + switch (op) { + case kUpb_DecodeOp_SubMessage: { + upb_TaggedMessagePtr* submsgp = mem; + upb_Message* submsg; + if (*submsgp) { + submsg = _upb_Decoder_ReuseSubMessage(d, subs, field, submsgp); + } else { + submsg = _upb_Decoder_NewSubMessage(d, subs, field, submsgp); + } + if (UPB_UNLIKELY(type == kUpb_FieldType_Group)) { + ptr = _upb_Decoder_DecodeKnownGroup(d, ptr, submsg, subs, field); + } else { + ptr = _upb_Decoder_DecodeSubMessage(d, ptr, submsg, subs, field, + val->size); + } + break; + } + case kUpb_DecodeOp_String: + _upb_Decoder_VerifyUtf8(d, ptr, val->size); + /* Fallthrough. */ + case kUpb_DecodeOp_Bytes: + return _upb_Decoder_ReadString(d, ptr, val->size, mem); + case kUpb_DecodeOp_Scalar8Byte: + memcpy(mem, val, 8); + break; + case kUpb_DecodeOp_Enum: + case kUpb_DecodeOp_Scalar4Byte: + memcpy(mem, val, 4); + break; + case kUpb_DecodeOp_Scalar1Byte: + memcpy(mem, val, 1); + break; + default: + UPB_UNREACHABLE(); + } + + return ptr; +} + +UPB_NOINLINE +const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr, + const upb_Message* msg, + const upb_MiniTable* m) { + UPB_ASSERT(m->UPB_PRIVATE(required_count)); + if (UPB_UNLIKELY(d->options & kUpb_DecodeOption_CheckRequired)) { + d->missing_required = + !UPB_PRIVATE(_upb_Message_IsInitializedShallow)(msg, m); + } + return ptr; +} + +UPB_FORCEINLINE +bool _upb_Decoder_TryFastDispatch(upb_Decoder* d, const char** ptr, + upb_Message* msg, const upb_MiniTable* m) { +#if UPB_FASTTABLE + if (m && m->UPB_PRIVATE(table_mask) != (unsigned char)-1) { + uint16_t tag = _upb_FastDecoder_LoadTag(*ptr); + intptr_t table = decode_totable(m); + *ptr = _upb_FastDecoder_TagDispatch(d, *ptr, msg, table, 0, tag); + return true; + } +#endif + return false; +} + +static const char* upb_Decoder_SkipField(upb_Decoder* d, const char* ptr, + uint32_t tag) { + int field_number = tag >> 3; + int wire_type = tag & 7; + switch (wire_type) { + case kUpb_WireType_Varint: { + uint64_t val; + return _upb_Decoder_DecodeVarint(d, ptr, &val); + } + case kUpb_WireType_64Bit: + return ptr + 8; + case kUpb_WireType_32Bit: + return ptr + 4; + case kUpb_WireType_Delimited: { + uint32_t size; + ptr = upb_Decoder_DecodeSize(d, ptr, &size); + return ptr + size; + } + case kUpb_WireType_StartGroup: + return _upb_Decoder_DecodeUnknownGroup(d, ptr, field_number); + default: + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + } +} + +enum { + kStartItemTag = ((kUpb_MsgSet_Item << 3) | kUpb_WireType_StartGroup), + kEndItemTag = ((kUpb_MsgSet_Item << 3) | kUpb_WireType_EndGroup), + kTypeIdTag = ((kUpb_MsgSet_TypeId << 3) | kUpb_WireType_Varint), + kMessageTag = ((kUpb_MsgSet_Message << 3) | kUpb_WireType_Delimited), +}; + +static void upb_Decoder_AddKnownMessageSetItem( + upb_Decoder* d, upb_Message* msg, const upb_MiniTableExtension* item_mt, + const char* data, uint32_t size) { + upb_Extension* ext = + UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(msg, item_mt, &d->arena); + if (UPB_UNLIKELY(!ext)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + upb_Message* submsg = _upb_Decoder_NewSubMessage( + d, &ext->ext->UPB_PRIVATE(sub), &ext->ext->UPB_PRIVATE(field), + (upb_TaggedMessagePtr*)&ext->data); + upb_DecodeStatus status = upb_Decode( + data, size, submsg, upb_MiniTableExtension_GetSubMessage(item_mt), + d->extreg, d->options, &d->arena); + if (status != kUpb_DecodeStatus_Ok) _upb_Decoder_ErrorJmp(d, status); +} + +static void upb_Decoder_AddUnknownMessageSetItem(upb_Decoder* d, + upb_Message* msg, + uint32_t type_id, + const char* message_data, + uint32_t message_size) { + char buf[60]; + char* ptr = buf; + ptr = upb_Decoder_EncodeVarint32(kStartItemTag, ptr); + ptr = upb_Decoder_EncodeVarint32(kTypeIdTag, ptr); + ptr = upb_Decoder_EncodeVarint32(type_id, ptr); + ptr = upb_Decoder_EncodeVarint32(kMessageTag, ptr); + ptr = upb_Decoder_EncodeVarint32(message_size, ptr); + char* split = ptr; + + ptr = upb_Decoder_EncodeVarint32(kEndItemTag, ptr); + char* end = ptr; + + if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, buf, split - buf, &d->arena) || + !UPB_PRIVATE(_upb_Message_AddUnknown)(msg, message_data, message_size, + &d->arena) || + !UPB_PRIVATE(_upb_Message_AddUnknown)(msg, split, end - split, + &d->arena)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } +} + +static void upb_Decoder_AddMessageSetItem(upb_Decoder* d, upb_Message* msg, + const upb_MiniTable* t, + uint32_t type_id, const char* data, + uint32_t size) { + const upb_MiniTableExtension* item_mt = + upb_ExtensionRegistry_Lookup(d->extreg, t, type_id); + if (item_mt) { + upb_Decoder_AddKnownMessageSetItem(d, msg, item_mt, data, size); + } else { + upb_Decoder_AddUnknownMessageSetItem(d, msg, type_id, data, size); + } +} + +static const char* upb_Decoder_DecodeMessageSetItem( + upb_Decoder* d, const char* ptr, upb_Message* msg, + const upb_MiniTable* layout) { + uint32_t type_id = 0; + upb_StringView preserved = {NULL, 0}; + typedef enum { + kUpb_HaveId = 1 << 0, + kUpb_HavePayload = 1 << 1, + } StateMask; + StateMask state_mask = 0; + while (!_upb_Decoder_IsDone(d, &ptr)) { + uint32_t tag; + ptr = _upb_Decoder_DecodeTag(d, ptr, &tag); + switch (tag) { + case kEndItemTag: + return ptr; + case kTypeIdTag: { + uint64_t tmp; + ptr = _upb_Decoder_DecodeVarint(d, ptr, &tmp); + if (state_mask & kUpb_HaveId) break; // Ignore dup. + state_mask |= kUpb_HaveId; + type_id = tmp; + if (state_mask & kUpb_HavePayload) { + upb_Decoder_AddMessageSetItem(d, msg, layout, type_id, preserved.data, + preserved.size); + } + break; + } + case kMessageTag: { + uint32_t size; + ptr = upb_Decoder_DecodeSize(d, ptr, &size); + const char* data = ptr; + ptr += size; + if (state_mask & kUpb_HavePayload) break; // Ignore dup. + state_mask |= kUpb_HavePayload; + if (state_mask & kUpb_HaveId) { + upb_Decoder_AddMessageSetItem(d, msg, layout, type_id, data, size); + } else { + // Out of order, we must preserve the payload. + preserved.data = data; + preserved.size = size; + } + break; + } + default: + // We do not preserve unexpected fields inside a message set item. + ptr = upb_Decoder_SkipField(d, ptr, tag); + break; + } + } + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); +} + +static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d, + const upb_MiniTable* t, + uint32_t field_number, + int* last_field_index) { + static upb_MiniTableField none = { + 0, 0, 0, 0, kUpb_FakeFieldType_FieldNotFound, 0}; + if (t == NULL) return &none; + + size_t idx = ((size_t)field_number) - 1; // 0 wraps to SIZE_MAX + if (idx < t->UPB_PRIVATE(dense_below)) { + // Fastest case: index into dense fields. + goto found; + } + + if (t->UPB_PRIVATE(dense_below) < t->UPB_PRIVATE(field_count)) { + // Linear search non-dense fields. Resume scanning from last_field_index + // since fields are usually in order. + size_t last = *last_field_index; + for (idx = last; idx < t->UPB_PRIVATE(field_count); idx++) { + if (t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number) { + goto found; + } + } + + for (idx = t->UPB_PRIVATE(dense_below); idx < last; idx++) { + if (t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number) { + goto found; + } + } + } + + if (d->extreg) { + switch (t->UPB_PRIVATE(ext)) { + case kUpb_ExtMode_Extendable: { + const upb_MiniTableExtension* ext = + upb_ExtensionRegistry_Lookup(d->extreg, t, field_number); + if (ext) return &ext->UPB_PRIVATE(field); + break; + } + case kUpb_ExtMode_IsMessageSet: + if (field_number == kUpb_MsgSet_Item) { + static upb_MiniTableField item = { + 0, 0, 0, 0, kUpb_FakeFieldType_MessageSetItem, 0}; + return &item; + } + break; + } + } + + return &none; // Unknown field. + +found: + UPB_ASSERT(t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number); + *last_field_index = idx; + return &t->UPB_PRIVATE(fields)[idx]; +} + +static int _upb_Decoder_GetVarintOp(const upb_MiniTableField* field) { + static const int8_t kVarintOps[] = { + [kUpb_FakeFieldType_FieldNotFound] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Double] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Float] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Int64] = kUpb_DecodeOp_Scalar8Byte, + [kUpb_FieldType_UInt64] = kUpb_DecodeOp_Scalar8Byte, + [kUpb_FieldType_Int32] = kUpb_DecodeOp_Scalar4Byte, + [kUpb_FieldType_Fixed64] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Fixed32] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Bool] = kUpb_DecodeOp_Scalar1Byte, + [kUpb_FieldType_String] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Group] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Message] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Bytes] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_UInt32] = kUpb_DecodeOp_Scalar4Byte, + [kUpb_FieldType_Enum] = kUpb_DecodeOp_Enum, + [kUpb_FieldType_SFixed32] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_SFixed64] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_SInt32] = kUpb_DecodeOp_Scalar4Byte, + [kUpb_FieldType_SInt64] = kUpb_DecodeOp_Scalar8Byte, + [kUpb_FakeFieldType_MessageSetItem] = kUpb_DecodeOp_UnknownField, + }; + + return kVarintOps[field->UPB_PRIVATE(descriptortype)]; +} + +UPB_FORCEINLINE +void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt, + const upb_MiniTableField* field, int* op) { + // If sub-message is not linked, treat as unknown. + if (field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension) return; + const upb_MiniTable* mt_sub = + _upb_MiniTableSubs_MessageByField(mt->UPB_PRIVATE(subs), field); + if ((d->options & kUpb_DecodeOption_ExperimentalAllowUnlinked) || + !UPB_PRIVATE(_upb_MiniTable_IsEmpty)(mt_sub)) { + return; + } +#ifndef NDEBUG + const upb_MiniTableField* oneof = upb_MiniTable_GetOneof(mt, field); + if (oneof) { + // All other members of the oneof must be message fields that are also + // unlinked. + do { + UPB_ASSERT(upb_MiniTableField_CType(oneof) == kUpb_CType_Message); + const upb_MiniTableSub* oneof_sub = + &mt->UPB_PRIVATE(subs)[oneof->UPB_PRIVATE(submsg_index)]; + UPB_ASSERT(!oneof_sub); + } while (upb_MiniTable_NextOneofField(mt, &oneof)); + } +#endif // NDEBUG + *op = kUpb_DecodeOp_UnknownField; +} + +UPB_FORCEINLINE +void _upb_Decoder_MaybeVerifyUtf8(upb_Decoder* d, + const upb_MiniTableField* field, int* op) { + if ((field->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsAlternate) && + UPB_UNLIKELY(d->options & kUpb_DecodeOption_AlwaysValidateUtf8)) + *op = kUpb_DecodeOp_String; +} + +static int _upb_Decoder_GetDelimitedOp(upb_Decoder* d, const upb_MiniTable* mt, + const upb_MiniTableField* field) { + enum { kRepeatedBase = 19 }; + + static const int8_t kDelimitedOps[] = { + // For non-repeated field type. + [kUpb_FakeFieldType_FieldNotFound] = + kUpb_DecodeOp_UnknownField, // Field not found. + [kUpb_FieldType_Double] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Float] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Int64] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_UInt64] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Int32] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Fixed64] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Fixed32] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Bool] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_String] = kUpb_DecodeOp_String, + [kUpb_FieldType_Group] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Message] = kUpb_DecodeOp_SubMessage, + [kUpb_FieldType_Bytes] = kUpb_DecodeOp_Bytes, + [kUpb_FieldType_UInt32] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_Enum] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_SFixed32] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_SFixed64] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_SInt32] = kUpb_DecodeOp_UnknownField, + [kUpb_FieldType_SInt64] = kUpb_DecodeOp_UnknownField, + [kUpb_FakeFieldType_MessageSetItem] = kUpb_DecodeOp_UnknownField, + // For repeated field type. + [kRepeatedBase + kUpb_FieldType_Double] = OP_FIXPCK_LG2(3), + [kRepeatedBase + kUpb_FieldType_Float] = OP_FIXPCK_LG2(2), + [kRepeatedBase + kUpb_FieldType_Int64] = OP_VARPCK_LG2(3), + [kRepeatedBase + kUpb_FieldType_UInt64] = OP_VARPCK_LG2(3), + [kRepeatedBase + kUpb_FieldType_Int32] = OP_VARPCK_LG2(2), + [kRepeatedBase + kUpb_FieldType_Fixed64] = OP_FIXPCK_LG2(3), + [kRepeatedBase + kUpb_FieldType_Fixed32] = OP_FIXPCK_LG2(2), + [kRepeatedBase + kUpb_FieldType_Bool] = OP_VARPCK_LG2(0), + [kRepeatedBase + kUpb_FieldType_String] = kUpb_DecodeOp_String, + [kRepeatedBase + kUpb_FieldType_Group] = kUpb_DecodeOp_SubMessage, + [kRepeatedBase + kUpb_FieldType_Message] = kUpb_DecodeOp_SubMessage, + [kRepeatedBase + kUpb_FieldType_Bytes] = kUpb_DecodeOp_Bytes, + [kRepeatedBase + kUpb_FieldType_UInt32] = OP_VARPCK_LG2(2), + [kRepeatedBase + kUpb_FieldType_Enum] = kUpb_DecodeOp_PackedEnum, + [kRepeatedBase + kUpb_FieldType_SFixed32] = OP_FIXPCK_LG2(2), + [kRepeatedBase + kUpb_FieldType_SFixed64] = OP_FIXPCK_LG2(3), + [kRepeatedBase + kUpb_FieldType_SInt32] = OP_VARPCK_LG2(2), + [kRepeatedBase + kUpb_FieldType_SInt64] = OP_VARPCK_LG2(3), + // Omitting kUpb_FakeFieldType_MessageSetItem, because we never emit a + // repeated msgset type + }; + + int ndx = field->UPB_PRIVATE(descriptortype); + if (upb_MiniTableField_IsArray(field)) ndx += kRepeatedBase; + int op = kDelimitedOps[ndx]; + + if (op == kUpb_DecodeOp_SubMessage) { + _upb_Decoder_CheckUnlinked(d, mt, field, &op); + } else if (op == kUpb_DecodeOp_Bytes) { + _upb_Decoder_MaybeVerifyUtf8(d, field, &op); + } + + return op; +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr, + const upb_MiniTable* mt, + const upb_MiniTableField* field, + int wire_type, wireval* val, int* op) { + static const unsigned kFixed32OkMask = (1 << kUpb_FieldType_Float) | + (1 << kUpb_FieldType_Fixed32) | + (1 << kUpb_FieldType_SFixed32); + + static const unsigned kFixed64OkMask = (1 << kUpb_FieldType_Double) | + (1 << kUpb_FieldType_Fixed64) | + (1 << kUpb_FieldType_SFixed64); + + switch (wire_type) { + case kUpb_WireType_Varint: + ptr = _upb_Decoder_DecodeVarint(d, ptr, &val->uint64_val); + *op = _upb_Decoder_GetVarintOp(field); + _upb_Decoder_Munge(field->UPB_PRIVATE(descriptortype), val); + return ptr; + case kUpb_WireType_32Bit: + *op = kUpb_DecodeOp_Scalar4Byte; + if (((1 << field->UPB_PRIVATE(descriptortype)) & kFixed32OkMask) == 0) { + *op = kUpb_DecodeOp_UnknownField; + } + return upb_WireReader_ReadFixed32(ptr, &val->uint32_val); + case kUpb_WireType_64Bit: + *op = kUpb_DecodeOp_Scalar8Byte; + if (((1 << field->UPB_PRIVATE(descriptortype)) & kFixed64OkMask) == 0) { + *op = kUpb_DecodeOp_UnknownField; + } + return upb_WireReader_ReadFixed64(ptr, &val->uint64_val); + case kUpb_WireType_Delimited: + ptr = upb_Decoder_DecodeSize(d, ptr, &val->size); + *op = _upb_Decoder_GetDelimitedOp(d, mt, field); + return ptr; + case kUpb_WireType_StartGroup: + val->uint32_val = field->UPB_PRIVATE(number); + if (field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group) { + *op = kUpb_DecodeOp_SubMessage; + _upb_Decoder_CheckUnlinked(d, mt, field, op); + } else if (field->UPB_PRIVATE(descriptortype) == + kUpb_FakeFieldType_MessageSetItem) { + *op = kUpb_DecodeOp_MessageSetItem; + } else { + *op = kUpb_DecodeOp_UnknownField; + } + return ptr; + default: + break; + } + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); +} + +UPB_FORCEINLINE +const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr, + upb_Message* msg, + const upb_MiniTable* layout, + const upb_MiniTableField* field, + int op, wireval* val) { + const upb_MiniTableSub* subs = layout->UPB_PRIVATE(subs); + uint8_t mode = field->UPB_PRIVATE(mode); + + if (UPB_UNLIKELY(mode & kUpb_LabelFlags_IsExtension)) { + const upb_MiniTableExtension* ext_layout = + (const upb_MiniTableExtension*)field; + upb_Extension* ext = UPB_PRIVATE(_upb_Message_GetOrCreateExtension)( + msg, ext_layout, &d->arena); + if (UPB_UNLIKELY(!ext)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + d->unknown_msg = msg; + msg = (upb_Message*)&ext->data; + subs = &ext->ext->UPB_PRIVATE(sub); + } + + switch (mode & kUpb_FieldMode_Mask) { + case kUpb_FieldMode_Array: + return _upb_Decoder_DecodeToArray(d, ptr, msg, subs, field, val, op); + case kUpb_FieldMode_Map: + return _upb_Decoder_DecodeToMap(d, ptr, msg, subs, field, val); + case kUpb_FieldMode_Scalar: + return _upb_Decoder_DecodeToSubMessage(d, ptr, msg, subs, field, val, op); + default: + UPB_UNREACHABLE(); + } +} + +static const char* _upb_Decoder_ReverseSkipVarint(const char* ptr, + uint32_t val) { + uint32_t seen = 0; + do { + ptr--; + seen <<= 7; + seen |= *ptr & 0x7f; + } while (seen != val); + return ptr; +} + +static const char* _upb_Decoder_DecodeUnknownField(upb_Decoder* d, + const char* ptr, + upb_Message* msg, + int field_number, + int wire_type, wireval val) { + if (field_number == 0) _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + + // Since unknown fields are the uncommon case, we do a little extra work here + // to walk backwards through the buffer to find the field start. This frees + // up a register in the fast paths (when the field is known), which leads to + // significant speedups in benchmarks. + const char* start = ptr; + + if (wire_type == kUpb_WireType_Delimited) ptr += val.size; + if (msg) { + switch (wire_type) { + case kUpb_WireType_Varint: + case kUpb_WireType_Delimited: + start--; + while (start[-1] & 0x80) start--; + break; + case kUpb_WireType_32Bit: + start -= 4; + break; + case kUpb_WireType_64Bit: + start -= 8; + break; + default: + break; + } + + assert(start == d->debug_valstart); + uint32_t tag = ((uint32_t)field_number << 3) | wire_type; + start = _upb_Decoder_ReverseSkipVarint(start, tag); + assert(start == d->debug_tagstart); + + if (wire_type == kUpb_WireType_StartGroup) { + d->unknown = start; + d->unknown_msg = msg; + ptr = _upb_Decoder_DecodeUnknownGroup(d, ptr, field_number); + start = d->unknown; + d->unknown = NULL; + } + if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, start, ptr - start, + &d->arena)) { + _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + } else if (wire_type == kUpb_WireType_StartGroup) { + ptr = _upb_Decoder_DecodeUnknownGroup(d, ptr, field_number); + } + return ptr; +} + +UPB_NOINLINE +static const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr, + upb_Message* msg, + const upb_MiniTable* layout) { + int last_field_index = 0; + +#if UPB_FASTTABLE + // The first time we want to skip fast dispatch, because we may have just been + // invoked by the fast parser to handle a case that it bailed on. + if (!_upb_Decoder_IsDone(d, &ptr)) goto nofast; +#endif + + while (!_upb_Decoder_IsDone(d, &ptr)) { + uint32_t tag; + const upb_MiniTableField* field; + int field_number; + int wire_type; + wireval val; + int op; + + if (_upb_Decoder_TryFastDispatch(d, &ptr, msg, layout)) break; + +#if UPB_FASTTABLE + nofast: +#endif + +#ifndef NDEBUG + d->debug_tagstart = ptr; +#endif + + UPB_ASSERT(ptr < d->input.limit_ptr); + ptr = _upb_Decoder_DecodeTag(d, ptr, &tag); + field_number = tag >> 3; + wire_type = tag & 7; + +#ifndef NDEBUG + d->debug_valstart = ptr; +#endif + + if (wire_type == kUpb_WireType_EndGroup) { + d->end_group = field_number; + return ptr; + } + + field = _upb_Decoder_FindField(d, layout, field_number, &last_field_index); + ptr = _upb_Decoder_DecodeWireValue(d, ptr, layout, field, wire_type, &val, + &op); + + if (op >= 0) { + ptr = _upb_Decoder_DecodeKnownField(d, ptr, msg, layout, field, op, &val); + } else { + switch (op) { + case kUpb_DecodeOp_UnknownField: + ptr = _upb_Decoder_DecodeUnknownField(d, ptr, msg, field_number, + wire_type, val); + break; + case kUpb_DecodeOp_MessageSetItem: + ptr = upb_Decoder_DecodeMessageSetItem(d, ptr, msg, layout); + break; + } + } + } + + return UPB_UNLIKELY(layout && layout->UPB_PRIVATE(required_count)) + ? _upb_Decoder_CheckRequired(d, ptr, msg, layout) + : ptr; +} + +const char* _upb_FastDecoder_DecodeGeneric(struct upb_Decoder* d, + const char* ptr, upb_Message* msg, + intptr_t table, uint64_t hasbits, + uint64_t data) { + (void)data; + *(uint32_t*)msg |= hasbits; + return _upb_Decoder_DecodeMessage(d, ptr, msg, decode_totablep(table)); +} + +static upb_DecodeStatus _upb_Decoder_DecodeTop(struct upb_Decoder* d, + const char* buf, + upb_Message* msg, + const upb_MiniTable* m) { + if (!_upb_Decoder_TryFastDispatch(d, &buf, msg, m)) { + _upb_Decoder_DecodeMessage(d, buf, msg, m); + } + if (d->end_group != DECODE_NOGROUP) return kUpb_DecodeStatus_Malformed; + if (d->missing_required) return kUpb_DecodeStatus_MissingRequired; + return kUpb_DecodeStatus_Ok; +} + +UPB_NOINLINE +const char* _upb_Decoder_IsDoneFallback(upb_EpsCopyInputStream* e, + const char* ptr, int overrun) { + return _upb_EpsCopyInputStream_IsDoneFallbackInline( + e, ptr, overrun, _upb_Decoder_BufferFlipCallback); +} + +static upb_DecodeStatus upb_Decoder_Decode(upb_Decoder* const decoder, + const char* const buf, + upb_Message* const msg, + const upb_MiniTable* const m, + upb_Arena* const arena) { + if (UPB_SETJMP(decoder->err) == 0) { + decoder->status = _upb_Decoder_DecodeTop(decoder, buf, msg, m); + } else { + UPB_ASSERT(decoder->status != kUpb_DecodeStatus_Ok); + } + + UPB_PRIVATE(_upb_Arena_SwapOut)(arena, &decoder->arena); + + return decoder->status; +} + +upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg, + const upb_MiniTable* mt, + const upb_ExtensionRegistry* extreg, int options, + upb_Arena* arena) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + upb_Decoder decoder; + unsigned depth = (unsigned)options >> 16; + + upb_EpsCopyInputStream_Init(&decoder.input, &buf, size, + options & kUpb_DecodeOption_AliasString); + + decoder.extreg = extreg; + decoder.unknown = NULL; + decoder.depth = depth ? depth : kUpb_WireFormat_DefaultDepthLimit; + decoder.end_group = DECODE_NOGROUP; + decoder.options = (uint16_t)options; + decoder.missing_required = false; + decoder.status = kUpb_DecodeStatus_Ok; + + // Violating the encapsulation of the arena for performance reasons. + // This is a temporary arena that we swap into and swap out of when we are + // done. The temporary arena only needs to be able to handle allocation, + // not fuse or free, so it does not need many of the members to be initialized + // (particularly parent_or_count). + UPB_PRIVATE(_upb_Arena_SwapIn)(&decoder.arena, arena); + + return upb_Decoder_Decode(&decoder, buf, msg, mt, arena); +} + +upb_DecodeStatus upb_DecodeLengthPrefixed(const char* buf, size_t size, + upb_Message* msg, + size_t* num_bytes_read, + const upb_MiniTable* mt, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + // To avoid needing to make a Decoder just to decode the initial length, + // hand-decode the leading varint for the message length here. + uint64_t msg_len = 0; + for (size_t i = 0;; ++i) { + if (i >= size || i > 9) { + return kUpb_DecodeStatus_Malformed; + } + uint64_t b = *buf; + buf++; + msg_len += (b & 0x7f) << (i * 7); + if ((b & 0x80) == 0) { + *num_bytes_read = i + 1 + msg_len; + break; + } + } + + // If the total number of bytes we would read (= the bytes from the varint + // plus however many bytes that varint says we should read) is larger then the + // input buffer then error as malformed. + if (*num_bytes_read > size) { + return kUpb_DecodeStatus_Malformed; + } + if (msg_len > INT32_MAX) { + return kUpb_DecodeStatus_Malformed; + } + + return upb_Decode(buf, msg_len, msg, mt, extreg, options, arena); +} + +#undef OP_FIXPCK_LG2 +#undef OP_VARPCK_LG2 + +// We encode backwards, to avoid pre-computing lengths (one-pass encode). + + +#include +#include +#include +#include + + +// Must be last. + +#define UPB_PB_VARINT_MAX_LEN 10 + +UPB_NOINLINE +static size_t encode_varint64(uint64_t val, char* buf) { + size_t i = 0; + do { + uint8_t byte = val & 0x7fU; + val >>= 7; + if (val) byte |= 0x80U; + buf[i++] = byte; + } while (val); + return i; +} + +static uint32_t encode_zz32(int32_t n) { + return ((uint32_t)n << 1) ^ (n >> 31); +} +static uint64_t encode_zz64(int64_t n) { + return ((uint64_t)n << 1) ^ (n >> 63); +} + +typedef struct { + upb_EncodeStatus status; + jmp_buf err; + upb_Arena* arena; + char *buf, *ptr, *limit; + int options; + int depth; + _upb_mapsorter sorter; +} upb_encstate; + +static size_t upb_roundup_pow2(size_t bytes) { + size_t ret = 128; + while (ret < bytes) { + ret *= 2; + } + return ret; +} + +UPB_NORETURN static void encode_err(upb_encstate* e, upb_EncodeStatus s) { + UPB_ASSERT(s != kUpb_EncodeStatus_Ok); + e->status = s; + UPB_LONGJMP(e->err, 1); +} + +UPB_NOINLINE +static void encode_growbuffer(upb_encstate* e, size_t bytes) { + size_t old_size = e->limit - e->buf; + size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr)); + char* new_buf = upb_Arena_Realloc(e->arena, e->buf, old_size, new_size); + + if (!new_buf) encode_err(e, kUpb_EncodeStatus_OutOfMemory); + + // We want previous data at the end, realloc() put it at the beginning. + // TODO: This is somewhat inefficient since we are copying twice. + // Maybe create a realloc() that copies to the end of the new buffer? + if (old_size > 0) { + memmove(new_buf + new_size - old_size, e->buf, old_size); + } + + e->ptr = new_buf + new_size - (e->limit - e->ptr); + e->limit = new_buf + new_size; + e->buf = new_buf; + + e->ptr -= bytes; +} + +/* Call to ensure that at least "bytes" bytes are available for writing at + * e->ptr. Returns false if the bytes could not be allocated. */ +UPB_FORCEINLINE +void encode_reserve(upb_encstate* e, size_t bytes) { + if ((size_t)(e->ptr - e->buf) < bytes) { + encode_growbuffer(e, bytes); + return; + } + + e->ptr -= bytes; +} + +/* Writes the given bytes to the buffer, handling reserve/advance. */ +static void encode_bytes(upb_encstate* e, const void* data, size_t len) { + if (len == 0) return; /* memcpy() with zero size is UB */ + encode_reserve(e, len); + memcpy(e->ptr, data, len); +} + +static void encode_fixed64(upb_encstate* e, uint64_t val) { + val = upb_BigEndian64(val); + encode_bytes(e, &val, sizeof(uint64_t)); +} + +static void encode_fixed32(upb_encstate* e, uint32_t val) { + val = upb_BigEndian32(val); + encode_bytes(e, &val, sizeof(uint32_t)); +} + +UPB_NOINLINE +static void encode_longvarint(upb_encstate* e, uint64_t val) { + size_t len; + char* start; + + encode_reserve(e, UPB_PB_VARINT_MAX_LEN); + len = encode_varint64(val, e->ptr); + start = e->ptr + UPB_PB_VARINT_MAX_LEN - len; + memmove(start, e->ptr, len); + e->ptr = start; +} + +UPB_FORCEINLINE +void encode_varint(upb_encstate* e, uint64_t val) { + if (val < 128 && e->ptr != e->buf) { + --e->ptr; + *e->ptr = val; + } else { + encode_longvarint(e, val); + } +} + +static void encode_double(upb_encstate* e, double d) { + uint64_t u64; + UPB_ASSERT(sizeof(double) == sizeof(uint64_t)); + memcpy(&u64, &d, sizeof(uint64_t)); + encode_fixed64(e, u64); +} + +static void encode_float(upb_encstate* e, float d) { + uint32_t u32; + UPB_ASSERT(sizeof(float) == sizeof(uint32_t)); + memcpy(&u32, &d, sizeof(uint32_t)); + encode_fixed32(e, u32); +} + +static void encode_tag(upb_encstate* e, uint32_t field_number, + uint8_t wire_type) { + encode_varint(e, (field_number << 3) | wire_type); +} + +static void encode_fixedarray(upb_encstate* e, const upb_Array* arr, + size_t elem_size, uint32_t tag) { + size_t bytes = upb_Array_Size(arr) * elem_size; + const char* data = upb_Array_DataPtr(arr); + const char* ptr = data + bytes - elem_size; + + if (tag || !upb_IsLittleEndian()) { + while (true) { + if (elem_size == 4) { + uint32_t val; + memcpy(&val, ptr, sizeof(val)); + val = upb_BigEndian32(val); + encode_bytes(e, &val, elem_size); + } else { + UPB_ASSERT(elem_size == 8); + uint64_t val; + memcpy(&val, ptr, sizeof(val)); + val = upb_BigEndian64(val); + encode_bytes(e, &val, elem_size); + } + + if (tag) encode_varint(e, tag); + if (ptr == data) break; + ptr -= elem_size; + } + } else { + encode_bytes(e, data, bytes); + } +} + +static void encode_message(upb_encstate* e, const upb_Message* msg, + const upb_MiniTable* m, size_t* size); + +static void encode_TaggedMessagePtr(upb_encstate* e, + upb_TaggedMessagePtr tagged, + const upb_MiniTable* m, size_t* size) { + if (upb_TaggedMessagePtr_IsEmpty(tagged)) { + m = UPB_PRIVATE(_upb_MiniTable_Empty)(); + } + encode_message(e, UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(tagged), m, + size); +} + +static void encode_scalar(upb_encstate* e, const void* _field_mem, + const upb_MiniTableSub* subs, + const upb_MiniTableField* f) { + const char* field_mem = _field_mem; + int wire_type; + +#define CASE(ctype, type, wtype, encodeval) \ + { \ + ctype val = *(ctype*)field_mem; \ + encode_##type(e, encodeval); \ + wire_type = wtype; \ + break; \ + } + + switch (f->UPB_PRIVATE(descriptortype)) { + case kUpb_FieldType_Double: + CASE(double, double, kUpb_WireType_64Bit, val); + case kUpb_FieldType_Float: + CASE(float, float, kUpb_WireType_32Bit, val); + case kUpb_FieldType_Int64: + case kUpb_FieldType_UInt64: + CASE(uint64_t, varint, kUpb_WireType_Varint, val); + case kUpb_FieldType_UInt32: + CASE(uint32_t, varint, kUpb_WireType_Varint, val); + case kUpb_FieldType_Int32: + case kUpb_FieldType_Enum: + CASE(int32_t, varint, kUpb_WireType_Varint, (int64_t)val); + case kUpb_FieldType_SFixed64: + case kUpb_FieldType_Fixed64: + CASE(uint64_t, fixed64, kUpb_WireType_64Bit, val); + case kUpb_FieldType_Fixed32: + case kUpb_FieldType_SFixed32: + CASE(uint32_t, fixed32, kUpb_WireType_32Bit, val); + case kUpb_FieldType_Bool: + CASE(bool, varint, kUpb_WireType_Varint, val); + case kUpb_FieldType_SInt32: + CASE(int32_t, varint, kUpb_WireType_Varint, encode_zz32(val)); + case kUpb_FieldType_SInt64: + CASE(int64_t, varint, kUpb_WireType_Varint, encode_zz64(val)); + case kUpb_FieldType_String: + case kUpb_FieldType_Bytes: { + upb_StringView view = *(upb_StringView*)field_mem; + encode_bytes(e, view.data, view.size); + encode_varint(e, view.size); + wire_type = kUpb_WireType_Delimited; + break; + } + case kUpb_FieldType_Group: { + size_t size; + upb_TaggedMessagePtr submsg = *(upb_TaggedMessagePtr*)field_mem; + const upb_MiniTable* subm = + upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); + if (submsg == 0) { + return; + } + if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded); + encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_EndGroup); + encode_TaggedMessagePtr(e, submsg, subm, &size); + wire_type = kUpb_WireType_StartGroup; + e->depth++; + break; + } + case kUpb_FieldType_Message: { + size_t size; + upb_TaggedMessagePtr submsg = *(upb_TaggedMessagePtr*)field_mem; + const upb_MiniTable* subm = + upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); + if (submsg == 0) { + return; + } + if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded); + encode_TaggedMessagePtr(e, submsg, subm, &size); + encode_varint(e, size); + wire_type = kUpb_WireType_Delimited; + e->depth++; + break; + } + default: + UPB_UNREACHABLE(); + } +#undef CASE + + encode_tag(e, upb_MiniTableField_Number(f), wire_type); +} + +static void encode_array(upb_encstate* e, const upb_Message* msg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* f) { + const upb_Array* arr = *UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), upb_Array*); + bool packed = upb_MiniTableField_IsPacked(f); + size_t pre_len = e->limit - e->ptr; + + if (arr == NULL || upb_Array_Size(arr) == 0) { + return; + } + +#define VARINT_CASE(ctype, encode) \ + { \ + const ctype* start = upb_Array_DataPtr(arr); \ + const ctype* ptr = start + upb_Array_Size(arr); \ + uint32_t tag = \ + packed ? 0 : (f->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint; \ + do { \ + ptr--; \ + encode_varint(e, encode); \ + if (tag) encode_varint(e, tag); \ + } while (ptr != start); \ + } \ + break; + +#define TAG(wire_type) (packed ? 0 : (f->UPB_PRIVATE(number) << 3 | wire_type)) + + switch (f->UPB_PRIVATE(descriptortype)) { + case kUpb_FieldType_Double: + encode_fixedarray(e, arr, sizeof(double), TAG(kUpb_WireType_64Bit)); + break; + case kUpb_FieldType_Float: + encode_fixedarray(e, arr, sizeof(float), TAG(kUpb_WireType_32Bit)); + break; + case kUpb_FieldType_SFixed64: + case kUpb_FieldType_Fixed64: + encode_fixedarray(e, arr, sizeof(uint64_t), TAG(kUpb_WireType_64Bit)); + break; + case kUpb_FieldType_Fixed32: + case kUpb_FieldType_SFixed32: + encode_fixedarray(e, arr, sizeof(uint32_t), TAG(kUpb_WireType_32Bit)); + break; + case kUpb_FieldType_Int64: + case kUpb_FieldType_UInt64: + VARINT_CASE(uint64_t, *ptr); + case kUpb_FieldType_UInt32: + VARINT_CASE(uint32_t, *ptr); + case kUpb_FieldType_Int32: + case kUpb_FieldType_Enum: + VARINT_CASE(int32_t, (int64_t)*ptr); + case kUpb_FieldType_Bool: + VARINT_CASE(bool, *ptr); + case kUpb_FieldType_SInt32: + VARINT_CASE(int32_t, encode_zz32(*ptr)); + case kUpb_FieldType_SInt64: + VARINT_CASE(int64_t, encode_zz64(*ptr)); + case kUpb_FieldType_String: + case kUpb_FieldType_Bytes: { + const upb_StringView* start = upb_Array_DataPtr(arr); + const upb_StringView* ptr = start + upb_Array_Size(arr); + do { + ptr--; + encode_bytes(e, ptr->data, ptr->size); + encode_varint(e, ptr->size); + encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited); + } while (ptr != start); + return; + } + case kUpb_FieldType_Group: { + const upb_TaggedMessagePtr* start = upb_Array_DataPtr(arr); + const upb_TaggedMessagePtr* ptr = start + upb_Array_Size(arr); + const upb_MiniTable* subm = + upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); + if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded); + do { + size_t size; + ptr--; + encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_EndGroup); + encode_TaggedMessagePtr(e, *ptr, subm, &size); + encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_StartGroup); + } while (ptr != start); + e->depth++; + return; + } + case kUpb_FieldType_Message: { + const upb_TaggedMessagePtr* start = upb_Array_DataPtr(arr); + const upb_TaggedMessagePtr* ptr = start + upb_Array_Size(arr); + const upb_MiniTable* subm = + upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); + if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded); + do { + size_t size; + ptr--; + encode_TaggedMessagePtr(e, *ptr, subm, &size); + encode_varint(e, size); + encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited); + } while (ptr != start); + e->depth++; + return; + } + } +#undef VARINT_CASE + + if (packed) { + encode_varint(e, e->limit - e->ptr - pre_len); + encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited); + } +} + +static void encode_mapentry(upb_encstate* e, uint32_t number, + const upb_MiniTable* layout, + const upb_MapEntry* ent) { + const upb_MiniTableField* key_field = upb_MiniTable_MapKey(layout); + const upb_MiniTableField* val_field = upb_MiniTable_MapValue(layout); + size_t pre_len = e->limit - e->ptr; + size_t size; + encode_scalar(e, &ent->v, layout->UPB_PRIVATE(subs), val_field); + encode_scalar(e, &ent->k, layout->UPB_PRIVATE(subs), key_field); + size = (e->limit - e->ptr) - pre_len; + encode_varint(e, size); + encode_tag(e, number, kUpb_WireType_Delimited); +} + +static void encode_map(upb_encstate* e, const upb_Message* msg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* f) { + const upb_Map* map = *UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), const upb_Map*); + const upb_MiniTable* layout = + upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); + UPB_ASSERT(upb_MiniTable_FieldCount(layout) == 2); + + if (!map || !upb_Map_Size(map)) return; + + if (e->options & kUpb_EncodeOption_Deterministic) { + _upb_sortedmap sorted; + _upb_mapsorter_pushmap( + &e->sorter, layout->UPB_PRIVATE(fields)[0].UPB_PRIVATE(descriptortype), + map, &sorted); + upb_MapEntry ent; + while (_upb_sortedmap_next(&e->sorter, map, &sorted, &ent)) { + encode_mapentry(e, upb_MiniTableField_Number(f), layout, &ent); + } + _upb_mapsorter_popmap(&e->sorter, &sorted); + } else { + intptr_t iter = UPB_STRTABLE_BEGIN; + upb_StringView key; + upb_value val; + while (upb_strtable_next2(&map->table, &key, &val, &iter)) { + upb_MapEntry ent; + _upb_map_fromkey(key, &ent.k, map->key_size); + _upb_map_fromvalue(val, &ent.v, map->val_size); + encode_mapentry(e, upb_MiniTableField_Number(f), layout, &ent); + } + } +} + +static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* f) { + if (f->presence == 0) { + // Proto3 presence or map/array. + const void* mem = UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), void); + switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) { + case kUpb_FieldRep_1Byte: { + char ch; + memcpy(&ch, mem, 1); + return ch != 0; + } + case kUpb_FieldRep_4Byte: { + uint32_t u32; + memcpy(&u32, mem, 4); + return u32 != 0; + } + case kUpb_FieldRep_8Byte: { + uint64_t u64; + memcpy(&u64, mem, 8); + return u64 != 0; + } + case kUpb_FieldRep_StringView: { + const upb_StringView* str = (const upb_StringView*)mem; + return str->size != 0; + } + default: + UPB_UNREACHABLE(); + } + } else if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) { + // Proto2 presence: hasbit. + return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, f); + } else { + // Field is in a oneof. + return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, f) == + upb_MiniTableField_Number(f); + } +} + +static void encode_field(upb_encstate* e, const upb_Message* msg, + const upb_MiniTableSub* subs, + const upb_MiniTableField* field) { + switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(field)) { + case kUpb_FieldMode_Array: + encode_array(e, msg, subs, field); + break; + case kUpb_FieldMode_Map: + encode_map(e, msg, subs, field); + break; + case kUpb_FieldMode_Scalar: + encode_scalar(e, UPB_PTR_AT(msg, field->UPB_PRIVATE(offset), void), subs, + field); + break; + default: + UPB_UNREACHABLE(); + } +} + +static void encode_msgset_item(upb_encstate* e, const upb_Extension* ext) { + size_t size; + encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_EndGroup); + encode_message(e, ext->data.msg_val, + upb_MiniTableExtension_GetSubMessage(ext->ext), &size); + encode_varint(e, size); + encode_tag(e, kUpb_MsgSet_Message, kUpb_WireType_Delimited); + encode_varint(e, upb_MiniTableExtension_Number(ext->ext)); + encode_tag(e, kUpb_MsgSet_TypeId, kUpb_WireType_Varint); + encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_StartGroup); +} + +static void encode_ext(upb_encstate* e, const upb_Extension* ext, + bool is_message_set) { + if (UPB_UNLIKELY(is_message_set)) { + encode_msgset_item(e, ext); + } else { + encode_field(e, (upb_Message*)&ext->data, &ext->ext->UPB_PRIVATE(sub), + &ext->ext->UPB_PRIVATE(field)); + } +} + +static void encode_message(upb_encstate* e, const upb_Message* msg, + const upb_MiniTable* m, size_t* size) { + size_t pre_len = e->limit - e->ptr; + + if (e->options & kUpb_EncodeOption_CheckRequired) { + if (m->UPB_PRIVATE(required_count)) { + if (!UPB_PRIVATE(_upb_Message_IsInitializedShallow)(msg, m)) { + encode_err(e, kUpb_EncodeStatus_MissingRequired); + } + } + } + + if ((e->options & kUpb_EncodeOption_SkipUnknown) == 0) { + size_t unknown_size; + const char* unknown = upb_Message_GetUnknown(msg, &unknown_size); + + if (unknown) { + encode_bytes(e, unknown, unknown_size); + } + } + + if (m->UPB_PRIVATE(ext) != kUpb_ExtMode_NonExtendable) { + /* Encode all extensions together. Unlike C++, we do not attempt to keep + * these in field number order relative to normal fields or even to each + * other. */ + size_t ext_count; + const upb_Extension* ext = + UPB_PRIVATE(_upb_Message_Getexts)(msg, &ext_count); + if (ext_count) { + if (e->options & kUpb_EncodeOption_Deterministic) { + _upb_sortedmap sorted; + _upb_mapsorter_pushexts(&e->sorter, ext, ext_count, &sorted); + while (_upb_sortedmap_nextext(&e->sorter, &sorted, &ext)) { + encode_ext(e, ext, m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet); + } + _upb_mapsorter_popmap(&e->sorter, &sorted); + } else { + const upb_Extension* end = ext + ext_count; + for (; ext != end; ext++) { + encode_ext(e, ext, m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet); + } + } + } + } + + if (upb_MiniTable_FieldCount(m)) { + const upb_MiniTableField* f = + &m->UPB_PRIVATE(fields)[m->UPB_PRIVATE(field_count)]; + const upb_MiniTableField* first = &m->UPB_PRIVATE(fields)[0]; + while (f != first) { + f--; + if (encode_shouldencode(e, msg, m->UPB_PRIVATE(subs), f)) { + encode_field(e, msg, m->UPB_PRIVATE(subs), f); + } + } + } + + *size = (e->limit - e->ptr) - pre_len; +} + +static upb_EncodeStatus upb_Encoder_Encode(upb_encstate* const encoder, + const upb_Message* const msg, + const upb_MiniTable* const l, + char** const buf, size_t* const size, + bool prepend_len) { + // Unfortunately we must continue to perform hackery here because there are + // code paths which blindly copy the returned pointer without bothering to + // check for errors until much later (b/235839510). So we still set *buf to + // NULL on error and we still set it to non-NULL on a successful empty result. + if (UPB_SETJMP(encoder->err) == 0) { + size_t encoded_msg_size; + encode_message(encoder, msg, l, &encoded_msg_size); + if (prepend_len) { + encode_varint(encoder, encoded_msg_size); + } + *size = encoder->limit - encoder->ptr; + if (*size == 0) { + static char ch; + *buf = &ch; + } else { + UPB_ASSERT(encoder->ptr); + *buf = encoder->ptr; + } + } else { + UPB_ASSERT(encoder->status != kUpb_EncodeStatus_Ok); + *buf = NULL; + *size = 0; + } + + _upb_mapsorter_destroy(&encoder->sorter); + return encoder->status; +} + +static upb_EncodeStatus _upb_Encode(const upb_Message* msg, + const upb_MiniTable* l, int options, + upb_Arena* arena, char** buf, size_t* size, + bool prepend_len) { + upb_encstate e; + unsigned depth = (unsigned)options >> 16; + + e.status = kUpb_EncodeStatus_Ok; + e.arena = arena; + e.buf = NULL; + e.limit = NULL; + e.ptr = NULL; + e.depth = depth ? depth : kUpb_WireFormat_DefaultDepthLimit; + e.options = options; + _upb_mapsorter_init(&e.sorter); + + return upb_Encoder_Encode(&e, msg, l, buf, size, prepend_len); +} + +upb_EncodeStatus upb_Encode(const upb_Message* msg, const upb_MiniTable* l, + int options, upb_Arena* arena, char** buf, + size_t* size) { + return _upb_Encode(msg, l, options, arena, buf, size, false); +} + +upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg, + const upb_MiniTable* l, int options, + upb_Arena* arena, char** buf, + size_t* size) { + return _upb_Encode(msg, l, options, arena, buf, size, true); +} + +// Fast decoder: ~3x the speed of decode.c, but requires x86-64/ARM64. +// Also the table size grows by 2x. +// +// Could potentially be ported to other 64-bit archs that pass at least six +// arguments in registers and have 8 unused high bits in pointers. +// +// The overall design is to create specialized functions for every possible +// field type (eg. oneof boolean field with a 1 byte tag) and then dispatch +// to the specialized function as quickly as possible. + + + +// Must be last. + +#if UPB_FASTTABLE + +// The standard set of arguments passed to each parsing function. +// Thanks to x86-64 calling conventions, these will stay in registers. +#define UPB_PARSE_PARAMS \ + upb_Decoder *d, const char *ptr, upb_Message *msg, intptr_t table, \ + uint64_t hasbits, uint64_t data + +#define UPB_PARSE_ARGS d, ptr, msg, table, hasbits, data + +#define RETURN_GENERIC(m) \ + /* Uncomment either of these for debugging purposes. */ \ + /* fprintf(stderr, m); */ \ + /*__builtin_trap(); */ \ + return _upb_FastDecoder_DecodeGeneric(d, ptr, msg, table, hasbits, 0); + +typedef enum { + CARD_s = 0, /* Singular (optional, non-repeated) */ + CARD_o = 1, /* Oneof */ + CARD_r = 2, /* Repeated */ + CARD_p = 3 /* Packed Repeated */ +} upb_card; + +UPB_NOINLINE +static const char* fastdecode_isdonefallback(UPB_PARSE_PARAMS) { + int overrun = data; + ptr = _upb_EpsCopyInputStream_IsDoneFallbackInline( + &d->input, ptr, overrun, _upb_Decoder_BufferFlipCallback); + data = _upb_FastDecoder_LoadTag(ptr); + UPB_MUSTTAIL return _upb_FastDecoder_TagDispatch(UPB_PARSE_ARGS); +} + +UPB_FORCEINLINE +const char* fastdecode_dispatch(UPB_PARSE_PARAMS) { + int overrun; + switch (upb_EpsCopyInputStream_IsDoneStatus(&d->input, ptr, &overrun)) { + case kUpb_IsDoneStatus_Done: + ((uint32_t*)msg)[2] |= hasbits; // Sync hasbits. + const upb_MiniTable* m = decode_totablep(table); + return UPB_UNLIKELY(m->UPB_PRIVATE(required_count)) + ? _upb_Decoder_CheckRequired(d, ptr, msg, m) + : ptr; + case kUpb_IsDoneStatus_NotDone: + break; + case kUpb_IsDoneStatus_NeedFallback: + data = overrun; + UPB_MUSTTAIL return fastdecode_isdonefallback(UPB_PARSE_ARGS); + } + + // Read two bytes of tag data (for a one-byte tag, the high byte is junk). + data = _upb_FastDecoder_LoadTag(ptr); + UPB_MUSTTAIL return _upb_FastDecoder_TagDispatch(UPB_PARSE_ARGS); +} + +UPB_FORCEINLINE +bool fastdecode_checktag(uint16_t data, int tagbytes) { + if (tagbytes == 1) { + return (data & 0xff) == 0; + } else { + return data == 0; + } +} + +UPB_FORCEINLINE +const char* fastdecode_longsize(const char* ptr, int* size) { + int i; + UPB_ASSERT(*size & 0x80); + *size &= 0xff; + for (i = 0; i < 3; i++) { + ptr++; + size_t byte = (uint8_t)ptr[-1]; + *size += (byte - 1) << (7 + 7 * i); + if (UPB_LIKELY((byte & 0x80) == 0)) return ptr; + } + ptr++; + size_t byte = (uint8_t)ptr[-1]; + // len is limited by 2gb not 4gb, hence 8 and not 16 as normally expected + // for a 32 bit varint. + if (UPB_UNLIKELY(byte >= 8)) return NULL; + *size += (byte - 1) << 28; + return ptr; +} + +UPB_FORCEINLINE +const char* fastdecode_delimited( + upb_Decoder* d, const char* ptr, + upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) { + ptr++; + + // Sign-extend so varint greater than one byte becomes negative, causing + // fast delimited parse to fail. + int len = (int8_t)ptr[-1]; + + if (!upb_EpsCopyInputStream_TryParseDelimitedFast(&d->input, &ptr, len, func, + ctx)) { + // Slow case: Sub-message is >=128 bytes and/or exceeds the current buffer. + // If it exceeds the buffer limit, limit/limit_ptr will change during + // sub-message parsing, so we need to preserve delta, not limit. + if (UPB_UNLIKELY(len & 0x80)) { + // Size varint >1 byte (length >= 128). + ptr = fastdecode_longsize(ptr, &len); + if (!ptr) { + // Corrupt wire format: size exceeded INT_MAX. + return NULL; + } + } + if (!upb_EpsCopyInputStream_CheckSize(&d->input, ptr, len)) { + // Corrupt wire format: invalid limit. + return NULL; + } + int delta = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, len); + ptr = func(&d->input, ptr, ctx); + upb_EpsCopyInputStream_PopLimit(&d->input, ptr, delta); + } + return ptr; +} + +/* singular, oneof, repeated field handling ***********************************/ + +typedef struct { + upb_Array* arr; + void* end; +} fastdecode_arr; + +typedef enum { + FD_NEXT_ATLIMIT, + FD_NEXT_SAMEFIELD, + FD_NEXT_OTHERFIELD +} fastdecode_next; + +typedef struct { + void* dst; + fastdecode_next next; + uint32_t tag; +} fastdecode_nextret; + +UPB_FORCEINLINE +void* fastdecode_resizearr(upb_Decoder* d, void* dst, fastdecode_arr* farr, + int valbytes) { + if (UPB_UNLIKELY(dst == farr->end)) { + size_t old_capacity = farr->arr->UPB_PRIVATE(capacity); + size_t old_bytes = old_capacity * valbytes; + size_t new_capacity = old_capacity * 2; + size_t new_bytes = new_capacity * valbytes; + char* old_ptr = upb_Array_MutableDataPtr(farr->arr); + char* new_ptr = upb_Arena_Realloc(&d->arena, old_ptr, old_bytes, new_bytes); + uint8_t elem_size_lg2 = __builtin_ctz(valbytes); + UPB_PRIVATE(_upb_Array_SetTaggedPtr)(farr->arr, new_ptr, elem_size_lg2); + farr->arr->UPB_PRIVATE(capacity) = new_capacity; + dst = (void*)(new_ptr + (old_capacity * valbytes)); + farr->end = (void*)(new_ptr + (new_capacity * valbytes)); + } + return dst; +} + +UPB_FORCEINLINE +bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) { + if (tagbytes == 1) { + return (uint8_t)tag == (uint8_t)data; + } else { + return (uint16_t)tag == (uint16_t)data; + } +} + +UPB_FORCEINLINE +void fastdecode_commitarr(void* dst, fastdecode_arr* farr, int valbytes) { + farr->arr->UPB_PRIVATE(size) = + (size_t)((char*)dst - (char*)upb_Array_MutableDataPtr(farr->arr)) / + valbytes; +} + +UPB_FORCEINLINE +fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst, + const char** ptr, + fastdecode_arr* farr, uint64_t data, + int tagbytes, int valbytes) { + fastdecode_nextret ret; + dst = (char*)dst + valbytes; + + if (UPB_LIKELY(!_upb_Decoder_IsDone(d, ptr))) { + ret.tag = _upb_FastDecoder_LoadTag(*ptr); + if (fastdecode_tagmatch(ret.tag, data, tagbytes)) { + ret.next = FD_NEXT_SAMEFIELD; + } else { + fastdecode_commitarr(dst, farr, valbytes); + ret.next = FD_NEXT_OTHERFIELD; + } + } else { + fastdecode_commitarr(dst, farr, valbytes); + ret.next = FD_NEXT_ATLIMIT; + } + + ret.dst = dst; + return ret; +} + +UPB_FORCEINLINE +void* fastdecode_fieldmem(upb_Message* msg, uint64_t data) { + size_t ofs = data >> 48; + return (char*)msg + ofs; +} + +UPB_FORCEINLINE +void* fastdecode_getfield(upb_Decoder* d, const char* ptr, upb_Message* msg, + uint64_t* data, uint64_t* hasbits, + fastdecode_arr* farr, int valbytes, upb_card card) { + switch (card) { + case CARD_s: { + uint8_t hasbit_index = *data >> 24; + // Set hasbit and return pointer to scalar field. + *hasbits |= 1ull << hasbit_index; + return fastdecode_fieldmem(msg, *data); + } + case CARD_o: { + uint16_t case_ofs = *data >> 32; + uint32_t* oneof_case = UPB_PTR_AT(msg, case_ofs, uint32_t); + uint8_t field_number = *data >> 24; + *oneof_case = field_number; + return fastdecode_fieldmem(msg, *data); + } + case CARD_r: { + // Get pointer to upb_Array and allocate/expand if necessary. + uint8_t elem_size_lg2 = __builtin_ctz(valbytes); + upb_Array** arr_p = fastdecode_fieldmem(msg, *data); + char* begin; + ((uint32_t*)msg)[2] |= *hasbits; + *hasbits = 0; + if (UPB_LIKELY(!*arr_p)) { + farr->arr = UPB_PRIVATE(_upb_Array_New)(&d->arena, 8, elem_size_lg2); + *arr_p = farr->arr; + } else { + farr->arr = *arr_p; + } + begin = upb_Array_MutableDataPtr(farr->arr); + farr->end = begin + (farr->arr->UPB_PRIVATE(capacity) * valbytes); + *data = _upb_FastDecoder_LoadTag(ptr); + return begin + (farr->arr->UPB_PRIVATE(size) * valbytes); + } + default: + UPB_UNREACHABLE(); + } +} + +UPB_FORCEINLINE +bool fastdecode_flippacked(uint64_t* data, int tagbytes) { + *data ^= (0x2 ^ 0x0); // Patch data to match packed wiretype. + return fastdecode_checktag(*data, tagbytes); +} + +#define FASTDECODE_CHECKPACKED(tagbytes, card, func) \ + if (UPB_UNLIKELY(!fastdecode_checktag(data, tagbytes))) { \ + if (card == CARD_r && fastdecode_flippacked(&data, tagbytes)) { \ + UPB_MUSTTAIL return func(UPB_PARSE_ARGS); \ + } \ + RETURN_GENERIC("packed check tag mismatch\n"); \ + } + +/* varint fields **************************************************************/ + +UPB_FORCEINLINE +uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) { + if (valbytes == 1) { + return val != 0; + } else if (zigzag) { + if (valbytes == 4) { + uint32_t n = val; + return (n >> 1) ^ -(int32_t)(n & 1); + } else if (valbytes == 8) { + return (val >> 1) ^ -(int64_t)(val & 1); + } + UPB_UNREACHABLE(); + } + return val; +} + +UPB_FORCEINLINE +const char* fastdecode_varint64(const char* ptr, uint64_t* val) { + ptr++; + *val = (uint8_t)ptr[-1]; + if (UPB_UNLIKELY(*val & 0x80)) { + int i; + for (i = 0; i < 8; i++) { + ptr++; + uint64_t byte = (uint8_t)ptr[-1]; + *val += (byte - 1) << (7 + 7 * i); + if (UPB_LIKELY((byte & 0x80) == 0)) goto done; + } + ptr++; + uint64_t byte = (uint8_t)ptr[-1]; + if (byte > 1) { + return NULL; + } + *val += (byte - 1) << 63; + } +done: + UPB_ASSUME(ptr != NULL); + return ptr; +} + +#define FASTDECODE_UNPACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, card, zigzag, packed) \ + uint64_t val; \ + void* dst; \ + fastdecode_arr farr; \ + \ + FASTDECODE_CHECKPACKED(tagbytes, card, packed); \ + \ + dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, valbytes, \ + card); \ + if (card == CARD_r) { \ + if (UPB_UNLIKELY(!dst)) { \ + RETURN_GENERIC("need array resize\n"); \ + } \ + } \ + \ + again: \ + if (card == CARD_r) { \ + dst = fastdecode_resizearr(d, dst, &farr, valbytes); \ + } \ + \ + ptr += tagbytes; \ + ptr = fastdecode_varint64(ptr, &val); \ + if (ptr == NULL) _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); \ + val = fastdecode_munge(val, valbytes, zigzag); \ + memcpy(dst, &val, valbytes); \ + \ + if (card == CARD_r) { \ + fastdecode_nextret ret = fastdecode_nextrepeated( \ + d, dst, &ptr, &farr, data, tagbytes, valbytes); \ + switch (ret.next) { \ + case FD_NEXT_SAMEFIELD: \ + dst = ret.dst; \ + goto again; \ + case FD_NEXT_OTHERFIELD: \ + data = ret.tag; \ + UPB_MUSTTAIL return _upb_FastDecoder_TagDispatch(UPB_PARSE_ARGS); \ + case FD_NEXT_ATLIMIT: \ + return ptr; \ + } \ + } \ + \ + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); + +typedef struct { + uint8_t valbytes; + bool zigzag; + void* dst; + fastdecode_arr farr; +} fastdecode_varintdata; + +UPB_FORCEINLINE +const char* fastdecode_topackedvarint(upb_EpsCopyInputStream* e, + const char* ptr, void* ctx) { + upb_Decoder* d = (upb_Decoder*)e; + fastdecode_varintdata* data = ctx; + void* dst = data->dst; + uint64_t val; + + while (!_upb_Decoder_IsDone(d, &ptr)) { + dst = fastdecode_resizearr(d, dst, &data->farr, data->valbytes); + ptr = fastdecode_varint64(ptr, &val); + if (ptr == NULL) return NULL; + val = fastdecode_munge(val, data->valbytes, data->zigzag); + memcpy(dst, &val, data->valbytes); + dst = (char*)dst + data->valbytes; + } + + fastdecode_commitarr(dst, &data->farr, data->valbytes); + return ptr; +} + +#define FASTDECODE_PACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, zigzag, unpacked) \ + fastdecode_varintdata ctx = {valbytes, zigzag}; \ + \ + FASTDECODE_CHECKPACKED(tagbytes, CARD_r, unpacked); \ + \ + ctx.dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &ctx.farr, \ + valbytes, CARD_r); \ + if (UPB_UNLIKELY(!ctx.dst)) { \ + RETURN_GENERIC("need array resize\n"); \ + } \ + \ + ptr += tagbytes; \ + ptr = fastdecode_delimited(d, ptr, &fastdecode_topackedvarint, &ctx); \ + \ + if (UPB_UNLIKELY(ptr == NULL)) { \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); \ + } \ + \ + UPB_MUSTTAIL return fastdecode_dispatch(d, ptr, msg, table, hasbits, 0); + +#define FASTDECODE_VARINT(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, card, zigzag, unpacked, packed) \ + if (card == CARD_p) { \ + FASTDECODE_PACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, zigzag, unpacked); \ + } else { \ + FASTDECODE_UNPACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, card, zigzag, packed); \ + } + +#define z_ZZ true +#define b_ZZ false +#define v_ZZ false + +/* Generate all combinations: + * {s,o,r,p} x {b1,v4,z4,v8,z8} x {1bt,2bt} */ + +#define F(card, type, valbytes, tagbytes) \ + UPB_NOINLINE \ + const char* upb_p##card##type##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS) { \ + FASTDECODE_VARINT(d, ptr, msg, table, hasbits, data, tagbytes, valbytes, \ + CARD_##card, type##_ZZ, \ + upb_pr##type##valbytes##_##tagbytes##bt, \ + upb_pp##type##valbytes##_##tagbytes##bt); \ + } + +#define TYPES(card, tagbytes) \ + F(card, b, 1, tagbytes) \ + F(card, v, 4, tagbytes) \ + F(card, v, 8, tagbytes) \ + F(card, z, 4, tagbytes) \ + F(card, z, 8, tagbytes) + +#define TAGBYTES(card) \ + TYPES(card, 1) \ + TYPES(card, 2) + +TAGBYTES(s) +TAGBYTES(o) +TAGBYTES(r) +TAGBYTES(p) + +#undef z_ZZ +#undef b_ZZ +#undef v_ZZ +#undef o_ONEOF +#undef s_ONEOF +#undef r_ONEOF +#undef F +#undef TYPES +#undef TAGBYTES +#undef FASTDECODE_UNPACKEDVARINT +#undef FASTDECODE_PACKEDVARINT +#undef FASTDECODE_VARINT + +/* fixed fields ***************************************************************/ + +#define FASTDECODE_UNPACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, card, packed) \ + void* dst; \ + fastdecode_arr farr; \ + \ + FASTDECODE_CHECKPACKED(tagbytes, card, packed) \ + \ + dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, valbytes, \ + card); \ + if (card == CARD_r) { \ + if (UPB_UNLIKELY(!dst)) { \ + RETURN_GENERIC("couldn't allocate array in arena\n"); \ + } \ + } \ + \ + again: \ + if (card == CARD_r) { \ + dst = fastdecode_resizearr(d, dst, &farr, valbytes); \ + } \ + \ + ptr += tagbytes; \ + memcpy(dst, ptr, valbytes); \ + ptr += valbytes; \ + \ + if (card == CARD_r) { \ + fastdecode_nextret ret = fastdecode_nextrepeated( \ + d, dst, &ptr, &farr, data, tagbytes, valbytes); \ + switch (ret.next) { \ + case FD_NEXT_SAMEFIELD: \ + dst = ret.dst; \ + goto again; \ + case FD_NEXT_OTHERFIELD: \ + data = ret.tag; \ + UPB_MUSTTAIL return _upb_FastDecoder_TagDispatch(UPB_PARSE_ARGS); \ + case FD_NEXT_ATLIMIT: \ + return ptr; \ + } \ + } \ + \ + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); + +#define FASTDECODE_PACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, unpacked) \ + FASTDECODE_CHECKPACKED(tagbytes, CARD_r, unpacked) \ + \ + ptr += tagbytes; \ + int size = (uint8_t)ptr[0]; \ + ptr++; \ + if (size & 0x80) { \ + ptr = fastdecode_longsize(ptr, &size); \ + } \ + \ + if (UPB_UNLIKELY(!upb_EpsCopyInputStream_CheckDataSizeAvailable( \ + &d->input, ptr, size) || \ + (size % valbytes) != 0)) { \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); \ + } \ + \ + upb_Array** arr_p = fastdecode_fieldmem(msg, data); \ + upb_Array* arr = *arr_p; \ + uint8_t elem_size_lg2 = __builtin_ctz(valbytes); \ + int elems = size / valbytes; \ + \ + if (UPB_LIKELY(!arr)) { \ + *arr_p = arr = \ + UPB_PRIVATE(_upb_Array_New)(&d->arena, elems, elem_size_lg2); \ + if (!arr) { \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); \ + } \ + } else { \ + UPB_PRIVATE(_upb_Array_ResizeUninitialized)(arr, elems, &d->arena); \ + } \ + \ + char* dst = upb_Array_MutableDataPtr(arr); \ + memcpy(dst, ptr, size); \ + arr->UPB_PRIVATE(size) = elems; \ + \ + ptr += size; \ + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); + +#define FASTDECODE_FIXED(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, card, unpacked, packed) \ + if (card == CARD_p) { \ + FASTDECODE_PACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, unpacked); \ + } else { \ + FASTDECODE_UNPACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \ + valbytes, card, packed); \ + } + +/* Generate all combinations: + * {s,o,r,p} x {f4,f8} x {1bt,2bt} */ + +#define F(card, valbytes, tagbytes) \ + UPB_NOINLINE \ + const char* upb_p##card##f##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS) { \ + FASTDECODE_FIXED(d, ptr, msg, table, hasbits, data, tagbytes, valbytes, \ + CARD_##card, upb_ppf##valbytes##_##tagbytes##bt, \ + upb_prf##valbytes##_##tagbytes##bt); \ + } + +#define TYPES(card, tagbytes) \ + F(card, 4, tagbytes) \ + F(card, 8, tagbytes) + +#define TAGBYTES(card) \ + TYPES(card, 1) \ + TYPES(card, 2) + +TAGBYTES(s) +TAGBYTES(o) +TAGBYTES(r) +TAGBYTES(p) + +#undef F +#undef TYPES +#undef TAGBYTES +#undef FASTDECODE_UNPACKEDFIXED +#undef FASTDECODE_PACKEDFIXED + +/* string fields **************************************************************/ + +typedef const char* fastdecode_copystr_func(struct upb_Decoder* d, + const char* ptr, upb_Message* msg, + const upb_MiniTable* table, + uint64_t hasbits, + upb_StringView* dst); + +UPB_NOINLINE +static const char* fastdecode_verifyutf8(upb_Decoder* d, const char* ptr, + upb_Message* msg, intptr_t table, + uint64_t hasbits, uint64_t data) { + upb_StringView* dst = (upb_StringView*)data; + if (!_upb_Decoder_VerifyUtf8Inline(dst->data, dst->size)) { + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_BadUtf8); + } + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); +} + +#define FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, validate_utf8) \ + int size = (uint8_t)ptr[0]; /* Could plumb through hasbits. */ \ + ptr++; \ + if (size & 0x80) { \ + ptr = fastdecode_longsize(ptr, &size); \ + } \ + \ + if (UPB_UNLIKELY(!upb_EpsCopyInputStream_CheckSize(&d->input, ptr, size))) { \ + dst->size = 0; \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); \ + } \ + \ + const char* s_ptr = ptr; \ + ptr = upb_EpsCopyInputStream_ReadString(&d->input, &s_ptr, size, &d->arena); \ + if (!ptr) _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); \ + dst->data = s_ptr; \ + dst->size = size; \ + \ + if (validate_utf8) { \ + data = (uint64_t)dst; \ + UPB_MUSTTAIL return fastdecode_verifyutf8(UPB_PARSE_ARGS); \ + } else { \ + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); \ + } + +UPB_NOINLINE +static const char* fastdecode_longstring_utf8(struct upb_Decoder* d, + const char* ptr, upb_Message* msg, + intptr_t table, uint64_t hasbits, + uint64_t data) { + upb_StringView* dst = (upb_StringView*)data; + FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, true); +} + +UPB_NOINLINE +static const char* fastdecode_longstring_noutf8( + struct upb_Decoder* d, const char* ptr, upb_Message* msg, intptr_t table, + uint64_t hasbits, uint64_t data) { + upb_StringView* dst = (upb_StringView*)data; + FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, false); +} + +UPB_FORCEINLINE +void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size, int copy, + char* data, size_t data_offset, upb_StringView* dst) { + d->arena.UPB_PRIVATE(ptr) += copy; + dst->data = data + data_offset; + UPB_UNPOISON_MEMORY_REGION(data, copy); + memcpy(data, ptr, copy); + UPB_POISON_MEMORY_REGION(data + data_offset + size, + copy - data_offset - size); +} + +#define FASTDECODE_COPYSTRING(d, ptr, msg, table, hasbits, data, tagbytes, \ + card, validate_utf8) \ + upb_StringView* dst; \ + fastdecode_arr farr; \ + int64_t size; \ + size_t arena_has; \ + size_t common_has; \ + char* buf; \ + \ + UPB_ASSERT(!upb_EpsCopyInputStream_AliasingAvailable(&d->input, ptr, 0)); \ + UPB_ASSERT(fastdecode_checktag(data, tagbytes)); \ + \ + dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, \ + sizeof(upb_StringView), card); \ + \ + again: \ + if (card == CARD_r) { \ + dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_StringView)); \ + } \ + \ + size = (uint8_t)ptr[tagbytes]; \ + ptr += tagbytes + 1; \ + dst->size = size; \ + \ + buf = d->arena.UPB_PRIVATE(ptr); \ + arena_has = UPB_PRIVATE(_upb_ArenaHas)(&d->arena); \ + common_has = UPB_MIN(arena_has, \ + upb_EpsCopyInputStream_BytesAvailable(&d->input, ptr)); \ + \ + if (UPB_LIKELY(size <= 15 - tagbytes)) { \ + if (arena_has < 16) goto longstr; \ + fastdecode_docopy(d, ptr - tagbytes - 1, size, 16, buf, tagbytes + 1, \ + dst); \ + } else if (UPB_LIKELY(size <= 32)) { \ + if (UPB_UNLIKELY(common_has < 32)) goto longstr; \ + fastdecode_docopy(d, ptr, size, 32, buf, 0, dst); \ + } else if (UPB_LIKELY(size <= 64)) { \ + if (UPB_UNLIKELY(common_has < 64)) goto longstr; \ + fastdecode_docopy(d, ptr, size, 64, buf, 0, dst); \ + } else if (UPB_LIKELY(size < 128)) { \ + if (UPB_UNLIKELY(common_has < 128)) goto longstr; \ + fastdecode_docopy(d, ptr, size, 128, buf, 0, dst); \ + } else { \ + goto longstr; \ + } \ + \ + ptr += size; \ + \ + if (card == CARD_r) { \ + if (validate_utf8 && \ + !_upb_Decoder_VerifyUtf8Inline(dst->data, dst->size)) { \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_BadUtf8); \ + } \ + fastdecode_nextret ret = fastdecode_nextrepeated( \ + d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_StringView)); \ + switch (ret.next) { \ + case FD_NEXT_SAMEFIELD: \ + dst = ret.dst; \ + goto again; \ + case FD_NEXT_OTHERFIELD: \ + data = ret.tag; \ + UPB_MUSTTAIL return _upb_FastDecoder_TagDispatch(UPB_PARSE_ARGS); \ + case FD_NEXT_ATLIMIT: \ + return ptr; \ + } \ + } \ + \ + if (card != CARD_r && validate_utf8) { \ + data = (uint64_t)dst; \ + UPB_MUSTTAIL return fastdecode_verifyutf8(UPB_PARSE_ARGS); \ + } \ + \ + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); \ + \ + longstr: \ + if (card == CARD_r) { \ + fastdecode_commitarr(dst + 1, &farr, sizeof(upb_StringView)); \ + } \ + ptr--; \ + if (validate_utf8) { \ + UPB_MUSTTAIL return fastdecode_longstring_utf8(d, ptr, msg, table, \ + hasbits, (uint64_t)dst); \ + } else { \ + UPB_MUSTTAIL return fastdecode_longstring_noutf8(d, ptr, msg, table, \ + hasbits, (uint64_t)dst); \ + } + +#define FASTDECODE_STRING(d, ptr, msg, table, hasbits, data, tagbytes, card, \ + copyfunc, validate_utf8) \ + upb_StringView* dst; \ + fastdecode_arr farr; \ + int64_t size; \ + \ + if (UPB_UNLIKELY(!fastdecode_checktag(data, tagbytes))) { \ + RETURN_GENERIC("string field tag mismatch\n"); \ + } \ + \ + if (UPB_UNLIKELY( \ + !upb_EpsCopyInputStream_AliasingAvailable(&d->input, ptr, 0))) { \ + UPB_MUSTTAIL return copyfunc(UPB_PARSE_ARGS); \ + } \ + \ + dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, \ + sizeof(upb_StringView), card); \ + \ + again: \ + if (card == CARD_r) { \ + dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_StringView)); \ + } \ + \ + size = (int8_t)ptr[tagbytes]; \ + ptr += tagbytes + 1; \ + \ + if (UPB_UNLIKELY( \ + !upb_EpsCopyInputStream_AliasingAvailable(&d->input, ptr, size))) { \ + ptr--; \ + if (validate_utf8) { \ + return fastdecode_longstring_utf8(d, ptr, msg, table, hasbits, \ + (uint64_t)dst); \ + } else { \ + return fastdecode_longstring_noutf8(d, ptr, msg, table, hasbits, \ + (uint64_t)dst); \ + } \ + } \ + \ + dst->data = ptr; \ + dst->size = size; \ + ptr = upb_EpsCopyInputStream_ReadStringAliased(&d->input, &dst->data, \ + dst->size); \ + \ + if (card == CARD_r) { \ + if (validate_utf8 && \ + !_upb_Decoder_VerifyUtf8Inline(dst->data, dst->size)) { \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_BadUtf8); \ + } \ + fastdecode_nextret ret = fastdecode_nextrepeated( \ + d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_StringView)); \ + switch (ret.next) { \ + case FD_NEXT_SAMEFIELD: \ + dst = ret.dst; \ + goto again; \ + case FD_NEXT_OTHERFIELD: \ + data = ret.tag; \ + UPB_MUSTTAIL return _upb_FastDecoder_TagDispatch(UPB_PARSE_ARGS); \ + case FD_NEXT_ATLIMIT: \ + return ptr; \ + } \ + } \ + \ + if (card != CARD_r && validate_utf8) { \ + data = (uint64_t)dst; \ + UPB_MUSTTAIL return fastdecode_verifyutf8(UPB_PARSE_ARGS); \ + } \ + \ + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); + +/* Generate all combinations: + * {p,c} x {s,o,r} x {s, b} x {1bt,2bt} */ + +#define s_VALIDATE true +#define b_VALIDATE false + +#define F(card, tagbytes, type) \ + UPB_NOINLINE \ + const char* upb_c##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS) { \ + FASTDECODE_COPYSTRING(d, ptr, msg, table, hasbits, data, tagbytes, \ + CARD_##card, type##_VALIDATE); \ + } \ + const char* upb_p##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS) { \ + FASTDECODE_STRING(d, ptr, msg, table, hasbits, data, tagbytes, \ + CARD_##card, upb_c##card##type##_##tagbytes##bt, \ + type##_VALIDATE); \ + } + +#define UTF8(card, tagbytes) \ + F(card, tagbytes, s) \ + F(card, tagbytes, b) + +#define TAGBYTES(card) \ + UTF8(card, 1) \ + UTF8(card, 2) + +TAGBYTES(s) +TAGBYTES(o) +TAGBYTES(r) + +#undef s_VALIDATE +#undef b_VALIDATE +#undef F +#undef TAGBYTES +#undef FASTDECODE_LONGSTRING +#undef FASTDECODE_COPYSTRING +#undef FASTDECODE_STRING + +/* message fields *************************************************************/ + +UPB_INLINE +upb_Message* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* m, + int msg_ceil_bytes) { + size_t size = m->UPB_PRIVATE(size); + char* msg_data; + if (UPB_LIKELY(msg_ceil_bytes > 0 && + UPB_PRIVATE(_upb_ArenaHas)(&d->arena) >= msg_ceil_bytes)) { + UPB_ASSERT(size <= (size_t)msg_ceil_bytes); + msg_data = d->arena.UPB_PRIVATE(ptr); + d->arena.UPB_PRIVATE(ptr) += size; + UPB_UNPOISON_MEMORY_REGION(msg_data, msg_ceil_bytes); + memset(msg_data, 0, msg_ceil_bytes); + UPB_POISON_MEMORY_REGION(msg_data + size, msg_ceil_bytes - size); + } else { + msg_data = (char*)upb_Arena_Malloc(&d->arena, size); + memset(msg_data, 0, size); + } + return (upb_Message*)msg_data; +} + +typedef struct { + intptr_t table; + upb_Message* msg; +} fastdecode_submsgdata; + +UPB_FORCEINLINE +const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e, const char* ptr, + void* ctx) { + upb_Decoder* d = (upb_Decoder*)e; + fastdecode_submsgdata* submsg = ctx; + ptr = fastdecode_dispatch(d, ptr, submsg->msg, submsg->table, 0, 0); + UPB_ASSUME(ptr != NULL); + return ptr; +} + +#define FASTDECODE_SUBMSG(d, ptr, msg, table, hasbits, data, tagbytes, \ + msg_ceil_bytes, card) \ + \ + if (UPB_UNLIKELY(!fastdecode_checktag(data, tagbytes))) { \ + RETURN_GENERIC("submessage field tag mismatch\n"); \ + } \ + \ + if (--d->depth == 0) { \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_MaxDepthExceeded); \ + } \ + \ + upb_Message** dst; \ + uint32_t submsg_idx = (data >> 16) & 0xff; \ + const upb_MiniTable* tablep = decode_totablep(table); \ + const upb_MiniTable* subtablep = upb_MiniTableSub_Message( \ + *UPB_PRIVATE(_upb_MiniTable_GetSubByIndex)(tablep, submsg_idx)); \ + fastdecode_submsgdata submsg = {decode_totable(subtablep)}; \ + fastdecode_arr farr; \ + \ + if (subtablep->UPB_PRIVATE(table_mask) == (uint8_t)-1) { \ + d->depth++; \ + RETURN_GENERIC("submessage doesn't have fast tables."); \ + } \ + \ + dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, \ + sizeof(upb_Message*), card); \ + \ + if (card == CARD_s) { \ + ((uint32_t*)msg)[2] |= hasbits; \ + hasbits = 0; \ + } \ + \ + again: \ + if (card == CARD_r) { \ + dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_Message*)); \ + } \ + \ + submsg.msg = *dst; \ + \ + if (card == CARD_r || UPB_LIKELY(!submsg.msg)) { \ + *dst = submsg.msg = decode_newmsg_ceil(d, subtablep, msg_ceil_bytes); \ + } \ + \ + ptr += tagbytes; \ + ptr = fastdecode_delimited(d, ptr, fastdecode_tosubmsg, &submsg); \ + \ + if (UPB_UNLIKELY(ptr == NULL || d->end_group != DECODE_NOGROUP)) { \ + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); \ + } \ + \ + if (card == CARD_r) { \ + fastdecode_nextret ret = fastdecode_nextrepeated( \ + d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_Message*)); \ + switch (ret.next) { \ + case FD_NEXT_SAMEFIELD: \ + dst = ret.dst; \ + goto again; \ + case FD_NEXT_OTHERFIELD: \ + d->depth++; \ + data = ret.tag; \ + UPB_MUSTTAIL return _upb_FastDecoder_TagDispatch(UPB_PARSE_ARGS); \ + case FD_NEXT_ATLIMIT: \ + d->depth++; \ + return ptr; \ + } \ + } \ + \ + d->depth++; \ + UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); + +#define F(card, tagbytes, size_ceil, ceil_arg) \ + const char* upb_p##card##m_##tagbytes##bt_max##size_ceil##b( \ + UPB_PARSE_PARAMS) { \ + FASTDECODE_SUBMSG(d, ptr, msg, table, hasbits, data, tagbytes, ceil_arg, \ + CARD_##card); \ + } + +#define SIZES(card, tagbytes) \ + F(card, tagbytes, 64, 64) \ + F(card, tagbytes, 128, 128) \ + F(card, tagbytes, 192, 192) \ + F(card, tagbytes, 256, 256) \ + F(card, tagbytes, max, -1) + +#define TAGBYTES(card) \ + SIZES(card, 1) \ + SIZES(card, 2) + +TAGBYTES(s) +TAGBYTES(o) +TAGBYTES(r) + +#undef TAGBYTES +#undef SIZES +#undef F +#undef FASTDECODE_SUBMSG + +#endif /* UPB_FASTTABLE */ + + +#include +#include + + +// Must be last. + +UPB_NOINLINE UPB_PRIVATE(_upb_WireReader_LongVarint) + UPB_PRIVATE(_upb_WireReader_ReadLongVarint)(const char* ptr, uint64_t val) { + UPB_PRIVATE(_upb_WireReader_LongVarint) ret = {NULL, 0}; + uint64_t byte; + for (int i = 1; i < 10; i++) { + byte = (uint8_t)ptr[i]; + val += (byte - 1) << (i * 7); + if (!(byte & 0x80)) { + ret.ptr = ptr + i + 1; + ret.val = val; + return ret; + } + } + return ret; +} + +const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)( + const char* ptr, uint32_t tag, int depth_limit, + upb_EpsCopyInputStream* stream) { + if (--depth_limit == 0) return NULL; + uint32_t end_group_tag = (tag & ~7ULL) | kUpb_WireType_EndGroup; + while (!upb_EpsCopyInputStream_IsDone(stream, &ptr)) { + uint32_t tag; + ptr = upb_WireReader_ReadTag(ptr, &tag); + if (!ptr) return NULL; + if (tag == end_group_tag) return ptr; + ptr = _upb_WireReader_SkipValue(ptr, tag, depth_limit, stream); + if (!ptr) return NULL; + } + return ptr; +} + +/* + * upb_table Implementation + * + * Implementation is heavily inspired by Lua's ltable.c. + */ + +#include + + +// Must be last. + +#define UPB_MAXARRSIZE 16 // 2**16 = 64k. + +// From Chromium. +#define ARRAY_SIZE(x) \ + ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x]))))) + +static const double MAX_LOAD = 0.85; + +/* The minimum utilization of the array part of a mixed hash/array table. This + * is a speed/memory-usage tradeoff (though it's not straightforward because of + * cache effects). The lower this is, the more memory we'll use. */ +static const double MIN_DENSITY = 0.1; + +static bool is_pow2(uint64_t v) { return v == 0 || (v & (v - 1)) == 0; } + +static upb_value _upb_value_val(uint64_t val) { + upb_value ret; + _upb_value_setval(&ret, val); + return ret; +} + +static int log2ceil(uint64_t v) { + int ret = 0; + bool pow2 = is_pow2(v); + while (v >>= 1) ret++; + ret = pow2 ? ret : ret + 1; // Ceiling. + return UPB_MIN(UPB_MAXARRSIZE, ret); +} + +/* A type to represent the lookup key of either a strtable or an inttable. */ +typedef union { + uintptr_t num; + struct { + const char* str; + size_t len; + } str; +} lookupkey_t; + +static lookupkey_t strkey2(const char* str, size_t len) { + lookupkey_t k; + k.str.str = str; + k.str.len = len; + return k; +} + +static lookupkey_t intkey(uintptr_t key) { + lookupkey_t k; + k.num = key; + return k; +} + +typedef uint32_t hashfunc_t(upb_tabkey key); +typedef bool eqlfunc_t(upb_tabkey k1, lookupkey_t k2); + +/* Base table (shared code) ***************************************************/ + +static uint32_t upb_inthash(uintptr_t key) { return (uint32_t)key; } + +static const upb_tabent* upb_getentry(const upb_table* t, uint32_t hash) { + return t->entries + (hash & t->mask); +} + +static bool upb_arrhas(upb_tabval key) { return key.val != (uint64_t)-1; } + +static bool isfull(upb_table* t) { return t->count == t->max_count; } + +static bool init(upb_table* t, uint8_t size_lg2, upb_Arena* a) { + size_t bytes; + + t->count = 0; + t->size_lg2 = size_lg2; + t->mask = upb_table_size(t) ? upb_table_size(t) - 1 : 0; + t->max_count = upb_table_size(t) * MAX_LOAD; + bytes = upb_table_size(t) * sizeof(upb_tabent); + if (bytes > 0) { + t->entries = upb_Arena_Malloc(a, bytes); + if (!t->entries) return false; + memset(t->entries, 0, bytes); + } else { + t->entries = NULL; + } + return true; +} + +static upb_tabent* emptyent(upb_table* t, upb_tabent* e) { + upb_tabent* begin = t->entries; + upb_tabent* end = begin + upb_table_size(t); + for (e = e + 1; e < end; e++) { + if (upb_tabent_isempty(e)) return e; + } + for (e = begin; e < end; e++) { + if (upb_tabent_isempty(e)) return e; + } + UPB_ASSERT(false); + return NULL; +} + +static upb_tabent* getentry_mutable(upb_table* t, uint32_t hash) { + return (upb_tabent*)upb_getentry(t, hash); +} + +static const upb_tabent* findentry(const upb_table* t, lookupkey_t key, + uint32_t hash, eqlfunc_t* eql) { + const upb_tabent* e; + + if (t->size_lg2 == 0) return NULL; + e = upb_getentry(t, hash); + if (upb_tabent_isempty(e)) return NULL; + while (1) { + if (eql(e->key, key)) return e; + if ((e = e->next) == NULL) return NULL; + } +} + +static upb_tabent* findentry_mutable(upb_table* t, lookupkey_t key, + uint32_t hash, eqlfunc_t* eql) { + return (upb_tabent*)findentry(t, key, hash, eql); +} + +static bool lookup(const upb_table* t, lookupkey_t key, upb_value* v, + uint32_t hash, eqlfunc_t* eql) { + const upb_tabent* e = findentry(t, key, hash, eql); + if (e) { + if (v) { + _upb_value_setval(v, e->val.val); + } + return true; + } else { + return false; + } +} + +/* The given key must not already exist in the table. */ +static void insert(upb_table* t, lookupkey_t key, upb_tabkey tabkey, + upb_value val, uint32_t hash, hashfunc_t* hashfunc, + eqlfunc_t* eql) { + upb_tabent* mainpos_e; + upb_tabent* our_e; + + UPB_ASSERT(findentry(t, key, hash, eql) == NULL); + + t->count++; + mainpos_e = getentry_mutable(t, hash); + our_e = mainpos_e; + + if (upb_tabent_isempty(mainpos_e)) { + /* Our main position is empty; use it. */ + our_e->next = NULL; + } else { + /* Collision. */ + upb_tabent* new_e = emptyent(t, mainpos_e); + /* Head of collider's chain. */ + upb_tabent* chain = getentry_mutable(t, hashfunc(mainpos_e->key)); + if (chain == mainpos_e) { + /* Existing ent is in its main position (it has the same hash as us, and + * is the head of our chain). Insert to new ent and append to this chain. + */ + new_e->next = mainpos_e->next; + mainpos_e->next = new_e; + our_e = new_e; + } else { + /* Existing ent is not in its main position (it is a node in some other + * chain). This implies that no existing ent in the table has our hash. + * Evict it (updating its chain) and use its ent for head of our chain. */ + *new_e = *mainpos_e; /* copies next. */ + while (chain->next != mainpos_e) { + chain = (upb_tabent*)chain->next; + UPB_ASSERT(chain); + } + chain->next = new_e; + our_e = mainpos_e; + our_e->next = NULL; + } + } + our_e->key = tabkey; + our_e->val.val = val.val; + UPB_ASSERT(findentry(t, key, hash, eql) == our_e); +} + +static bool rm(upb_table* t, lookupkey_t key, upb_value* val, + upb_tabkey* removed, uint32_t hash, eqlfunc_t* eql) { + upb_tabent* chain = getentry_mutable(t, hash); + if (upb_tabent_isempty(chain)) return false; + if (eql(chain->key, key)) { + /* Element to remove is at the head of its chain. */ + t->count--; + if (val) _upb_value_setval(val, chain->val.val); + if (removed) *removed = chain->key; + if (chain->next) { + upb_tabent* move = (upb_tabent*)chain->next; + *chain = *move; + move->key = 0; /* Make the slot empty. */ + } else { + chain->key = 0; /* Make the slot empty. */ + } + return true; + } else { + /* Element to remove is either in a non-head position or not in the + * table. */ + while (chain->next && !eql(chain->next->key, key)) { + chain = (upb_tabent*)chain->next; + } + if (chain->next) { + /* Found element to remove. */ + upb_tabent* rm = (upb_tabent*)chain->next; + t->count--; + if (val) _upb_value_setval(val, chain->next->val.val); + if (removed) *removed = rm->key; + rm->key = 0; /* Make the slot empty. */ + chain->next = rm->next; + return true; + } else { + /* Element to remove is not in the table. */ + return false; + } + } +} + +static size_t next(const upb_table* t, size_t i) { + do { + if (++i >= upb_table_size(t)) return SIZE_MAX - 1; /* Distinct from -1. */ + } while (upb_tabent_isempty(&t->entries[i])); + + return i; +} + +static size_t begin(const upb_table* t) { return next(t, -1); } + +/* upb_strtable ***************************************************************/ + +/* A simple "subclass" of upb_table that only adds a hash function for strings. + */ + +static upb_tabkey strcopy(lookupkey_t k2, upb_Arena* a) { + uint32_t len = (uint32_t)k2.str.len; + char* str = upb_Arena_Malloc(a, k2.str.len + sizeof(uint32_t) + 1); + if (str == NULL) return 0; + memcpy(str, &len, sizeof(uint32_t)); + if (k2.str.len) memcpy(str + sizeof(uint32_t), k2.str.str, k2.str.len); + str[sizeof(uint32_t) + k2.str.len] = '\0'; + return (uintptr_t)str; +} + +/* Adapted from ABSL's wyhash. */ + +static uint64_t UnalignedLoad64(const void* p) { + uint64_t val; + memcpy(&val, p, 8); + return val; +} + +static uint32_t UnalignedLoad32(const void* p) { + uint32_t val; + memcpy(&val, p, 4); + return val; +} + +#if defined(_MSC_VER) && defined(_M_X64) +#include +#endif + +/* Computes a * b, returning the low 64 bits of the result and storing the high + * 64 bits in |*high|. */ +static uint64_t upb_umul128(uint64_t v0, uint64_t v1, uint64_t* out_high) { +#ifdef __SIZEOF_INT128__ + __uint128_t p = v0; + p *= v1; + *out_high = (uint64_t)(p >> 64); + return (uint64_t)p; +#elif defined(_MSC_VER) && defined(_M_X64) + return _umul128(v0, v1, out_high); +#else + uint64_t a32 = v0 >> 32; + uint64_t a00 = v0 & 0xffffffff; + uint64_t b32 = v1 >> 32; + uint64_t b00 = v1 & 0xffffffff; + uint64_t high = a32 * b32; + uint64_t low = a00 * b00; + uint64_t mid1 = a32 * b00; + uint64_t mid2 = a00 * b32; + low += (mid1 << 32) + (mid2 << 32); + // Omit carry bit, for mixing we do not care about exact numerical precision. + high += (mid1 >> 32) + (mid2 >> 32); + *out_high = high; + return low; +#endif +} + +static uint64_t WyhashMix(uint64_t v0, uint64_t v1) { + uint64_t high; + uint64_t low = upb_umul128(v0, v1, &high); + return low ^ high; +} + +static uint64_t Wyhash(const void* data, size_t len, uint64_t seed, + const uint64_t salt[]) { + const uint8_t* ptr = (const uint8_t*)data; + uint64_t starting_length = (uint64_t)len; + uint64_t current_state = seed ^ salt[0]; + + if (len > 64) { + // If we have more than 64 bytes, we're going to handle chunks of 64 + // bytes at a time. We're going to build up two separate hash states + // which we will then hash together. + uint64_t duplicated_state = current_state; + + do { + uint64_t a = UnalignedLoad64(ptr); + uint64_t b = UnalignedLoad64(ptr + 8); + uint64_t c = UnalignedLoad64(ptr + 16); + uint64_t d = UnalignedLoad64(ptr + 24); + uint64_t e = UnalignedLoad64(ptr + 32); + uint64_t f = UnalignedLoad64(ptr + 40); + uint64_t g = UnalignedLoad64(ptr + 48); + uint64_t h = UnalignedLoad64(ptr + 56); + + uint64_t cs0 = WyhashMix(a ^ salt[1], b ^ current_state); + uint64_t cs1 = WyhashMix(c ^ salt[2], d ^ current_state); + current_state = (cs0 ^ cs1); + + uint64_t ds0 = WyhashMix(e ^ salt[3], f ^ duplicated_state); + uint64_t ds1 = WyhashMix(g ^ salt[4], h ^ duplicated_state); + duplicated_state = (ds0 ^ ds1); + + ptr += 64; + len -= 64; + } while (len > 64); + + current_state = current_state ^ duplicated_state; + } + + // We now have a data `ptr` with at most 64 bytes and the current state + // of the hashing state machine stored in current_state. + while (len > 16) { + uint64_t a = UnalignedLoad64(ptr); + uint64_t b = UnalignedLoad64(ptr + 8); + + current_state = WyhashMix(a ^ salt[1], b ^ current_state); + + ptr += 16; + len -= 16; + } + + // We now have a data `ptr` with at most 16 bytes. + uint64_t a = 0; + uint64_t b = 0; + if (len > 8) { + // When we have at least 9 and at most 16 bytes, set A to the first 64 + // bits of the input and B to the last 64 bits of the input. Yes, they will + // overlap in the middle if we are working with less than the full 16 + // bytes. + a = UnalignedLoad64(ptr); + b = UnalignedLoad64(ptr + len - 8); + } else if (len > 3) { + // If we have at least 4 and at most 8 bytes, set A to the first 32 + // bits and B to the last 32 bits. + a = UnalignedLoad32(ptr); + b = UnalignedLoad32(ptr + len - 4); + } else if (len > 0) { + // If we have at least 1 and at most 3 bytes, read all of the provided + // bits into A, with some adjustments. + a = ((ptr[0] << 16) | (ptr[len >> 1] << 8) | ptr[len - 1]); + b = 0; + } else { + a = 0; + b = 0; + } + + uint64_t w = WyhashMix(a ^ salt[1], b ^ current_state); + uint64_t z = salt[1] ^ starting_length; + return WyhashMix(w, z); +} + +const uint64_t kWyhashSalt[5] = { + 0x243F6A8885A308D3ULL, 0x13198A2E03707344ULL, 0xA4093822299F31D0ULL, + 0x082EFA98EC4E6C89ULL, 0x452821E638D01377ULL, +}; + +uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed) { + return Wyhash(p, n, seed, kWyhashSalt); +} + +static uint32_t _upb_Hash_NoSeed(const char* p, size_t n) { + return _upb_Hash(p, n, 0); +} + +static uint32_t strhash(upb_tabkey key) { + uint32_t len; + char* str = upb_tabstr(key, &len); + return _upb_Hash_NoSeed(str, len); +} + +static bool streql(upb_tabkey k1, lookupkey_t k2) { + uint32_t len; + char* str = upb_tabstr(k1, &len); + return len == k2.str.len && (len == 0 || memcmp(str, k2.str.str, len) == 0); +} + +bool upb_strtable_init(upb_strtable* t, size_t expected_size, upb_Arena* a) { + // Multiply by approximate reciprocal of MAX_LOAD (0.85), with pow2 + // denominator. + size_t need_entries = (expected_size + 1) * 1204 / 1024; + UPB_ASSERT(need_entries >= expected_size * 0.85); + int size_lg2 = upb_Log2Ceiling(need_entries); + return init(&t->t, size_lg2, a); +} + +void upb_strtable_clear(upb_strtable* t) { + size_t bytes = upb_table_size(&t->t) * sizeof(upb_tabent); + t->t.count = 0; + memset((char*)t->t.entries, 0, bytes); +} + +bool upb_strtable_resize(upb_strtable* t, size_t size_lg2, upb_Arena* a) { + upb_strtable new_table; + if (!init(&new_table.t, size_lg2, a)) return false; + + intptr_t iter = UPB_STRTABLE_BEGIN; + upb_StringView key; + upb_value val; + while (upb_strtable_next2(t, &key, &val, &iter)) { + upb_strtable_insert(&new_table, key.data, key.size, val, a); + } + *t = new_table; + return true; +} + +bool upb_strtable_insert(upb_strtable* t, const char* k, size_t len, + upb_value v, upb_Arena* a) { + lookupkey_t key; + upb_tabkey tabkey; + uint32_t hash; + + if (isfull(&t->t)) { + /* Need to resize. New table of double the size, add old elements to it. */ + if (!upb_strtable_resize(t, t->t.size_lg2 + 1, a)) { + return false; + } + } + + key = strkey2(k, len); + tabkey = strcopy(key, a); + if (tabkey == 0) return false; + + hash = _upb_Hash_NoSeed(key.str.str, key.str.len); + insert(&t->t, key, tabkey, v, hash, &strhash, &streql); + return true; +} + +bool upb_strtable_lookup2(const upb_strtable* t, const char* key, size_t len, + upb_value* v) { + uint32_t hash = _upb_Hash_NoSeed(key, len); + return lookup(&t->t, strkey2(key, len), v, hash, &streql); +} + +bool upb_strtable_remove2(upb_strtable* t, const char* key, size_t len, + upb_value* val) { + uint32_t hash = _upb_Hash_NoSeed(key, len); + upb_tabkey tabkey; + return rm(&t->t, strkey2(key, len), val, &tabkey, hash, &streql); +} + +/* Iteration */ + +void upb_strtable_begin(upb_strtable_iter* i, const upb_strtable* t) { + i->t = t; + i->index = begin(&t->t); +} + +void upb_strtable_next(upb_strtable_iter* i) { + i->index = next(&i->t->t, i->index); +} + +bool upb_strtable_done(const upb_strtable_iter* i) { + if (!i->t) return true; + return i->index >= upb_table_size(&i->t->t) || + upb_tabent_isempty(str_tabent(i)); +} + +upb_StringView upb_strtable_iter_key(const upb_strtable_iter* i) { + upb_StringView key; + uint32_t len; + UPB_ASSERT(!upb_strtable_done(i)); + key.data = upb_tabstr(str_tabent(i)->key, &len); + key.size = len; + return key; +} + +upb_value upb_strtable_iter_value(const upb_strtable_iter* i) { + UPB_ASSERT(!upb_strtable_done(i)); + return _upb_value_val(str_tabent(i)->val.val); +} + +void upb_strtable_iter_setdone(upb_strtable_iter* i) { + i->t = NULL; + i->index = SIZE_MAX; +} + +bool upb_strtable_iter_isequal(const upb_strtable_iter* i1, + const upb_strtable_iter* i2) { + if (upb_strtable_done(i1) && upb_strtable_done(i2)) return true; + return i1->t == i2->t && i1->index == i2->index; +} + +/* upb_inttable ***************************************************************/ + +/* For inttables we use a hybrid structure where small keys are kept in an + * array and large keys are put in the hash table. */ + +static uint32_t inthash(upb_tabkey key) { return upb_inthash(key); } + +static bool inteql(upb_tabkey k1, lookupkey_t k2) { return k1 == k2.num; } + +static upb_tabval* mutable_array(upb_inttable* t) { + return (upb_tabval*)t->array; +} + +static upb_tabval* inttable_val(upb_inttable* t, uintptr_t key) { + if (key < t->array_size) { + return upb_arrhas(t->array[key]) ? &(mutable_array(t)[key]) : NULL; + } else { + upb_tabent* e = + findentry_mutable(&t->t, intkey(key), upb_inthash(key), &inteql); + return e ? &e->val : NULL; + } +} + +static const upb_tabval* inttable_val_const(const upb_inttable* t, + uintptr_t key) { + return inttable_val((upb_inttable*)t, key); +} + +size_t upb_inttable_count(const upb_inttable* t) { + return t->t.count + t->array_count; +} + +static void check(upb_inttable* t) { + UPB_UNUSED(t); +#if defined(UPB_DEBUG_TABLE) && !defined(NDEBUG) + { + // This check is very expensive (makes inserts/deletes O(N)). + size_t count = 0; + intptr_t iter = UPB_INTTABLE_BEGIN; + uintptr_t key; + upb_value val; + while (upb_inttable_next(t, &key, &val, &iter)) { + UPB_ASSERT(upb_inttable_lookup(t, key, NULL)); + } + UPB_ASSERT(count == upb_inttable_count(t)); + } +#endif +} + +bool upb_inttable_sizedinit(upb_inttable* t, size_t asize, int hsize_lg2, + upb_Arena* a) { + size_t array_bytes; + + if (!init(&t->t, hsize_lg2, a)) return false; + /* Always make the array part at least 1 long, so that we know key 0 + * won't be in the hash part, which simplifies things. */ + t->array_size = UPB_MAX(1, asize); + t->array_count = 0; + array_bytes = t->array_size * sizeof(upb_value); + t->array = upb_Arena_Malloc(a, array_bytes); + if (!t->array) { + return false; + } + memset(mutable_array(t), 0xff, array_bytes); + check(t); + return true; +} + +bool upb_inttable_init(upb_inttable* t, upb_Arena* a) { + return upb_inttable_sizedinit(t, 0, 4, a); +} + +bool upb_inttable_insert(upb_inttable* t, uintptr_t key, upb_value val, + upb_Arena* a) { + upb_tabval tabval; + tabval.val = val.val; + UPB_ASSERT( + upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */ + + if (key < t->array_size) { + UPB_ASSERT(!upb_arrhas(t->array[key])); + t->array_count++; + mutable_array(t)[key].val = val.val; + } else { + if (isfull(&t->t)) { + /* Need to resize the hash part, but we re-use the array part. */ + size_t i; + upb_table new_table; + + if (!init(&new_table, t->t.size_lg2 + 1, a)) { + return false; + } + + for (i = begin(&t->t); i < upb_table_size(&t->t); i = next(&t->t, i)) { + const upb_tabent* e = &t->t.entries[i]; + uint32_t hash; + upb_value v; + + _upb_value_setval(&v, e->val.val); + hash = upb_inthash(e->key); + insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql); + } + + UPB_ASSERT(t->t.count == new_table.count); + + t->t = new_table; + } + insert(&t->t, intkey(key), key, val, upb_inthash(key), &inthash, &inteql); + } + check(t); + return true; +} + +bool upb_inttable_lookup(const upb_inttable* t, uintptr_t key, upb_value* v) { + const upb_tabval* table_v = inttable_val_const(t, key); + if (!table_v) return false; + if (v) _upb_value_setval(v, table_v->val); + return true; +} + +bool upb_inttable_replace(upb_inttable* t, uintptr_t key, upb_value val) { + upb_tabval* table_v = inttable_val(t, key); + if (!table_v) return false; + table_v->val = val.val; + return true; +} + +bool upb_inttable_remove(upb_inttable* t, uintptr_t key, upb_value* val) { + bool success; + if (key < t->array_size) { + if (upb_arrhas(t->array[key])) { + upb_tabval empty = UPB_TABVALUE_EMPTY_INIT; + t->array_count--; + if (val) { + _upb_value_setval(val, t->array[key].val); + } + mutable_array(t)[key] = empty; + success = true; + } else { + success = false; + } + } else { + success = rm(&t->t, intkey(key), val, NULL, upb_inthash(key), &inteql); + } + check(t); + return success; +} + +void upb_inttable_compact(upb_inttable* t, upb_Arena* a) { + /* A power-of-two histogram of the table keys. */ + size_t counts[UPB_MAXARRSIZE + 1] = {0}; + + /* The max key in each bucket. */ + uintptr_t max[UPB_MAXARRSIZE + 1] = {0}; + + { + intptr_t iter = UPB_INTTABLE_BEGIN; + uintptr_t key; + upb_value val; + while (upb_inttable_next(t, &key, &val, &iter)) { + int bucket = log2ceil(key); + max[bucket] = UPB_MAX(max[bucket], key); + counts[bucket]++; + } + } + + /* Find the largest power of two that satisfies the MIN_DENSITY + * definition (while actually having some keys). */ + size_t arr_count = upb_inttable_count(t); + int size_lg2; + upb_inttable new_t; + + for (size_lg2 = ARRAY_SIZE(counts) - 1; size_lg2 > 0; size_lg2--) { + if (counts[size_lg2] == 0) { + /* We can halve again without losing any entries. */ + continue; + } else if (arr_count >= (1 << size_lg2) * MIN_DENSITY) { + break; + } + + arr_count -= counts[size_lg2]; + } + + UPB_ASSERT(arr_count <= upb_inttable_count(t)); + + { + /* Insert all elements into new, perfectly-sized table. */ + size_t arr_size = max[size_lg2] + 1; /* +1 so arr[max] will fit. */ + size_t hash_count = upb_inttable_count(t) - arr_count; + size_t hash_size = hash_count ? (hash_count / MAX_LOAD) + 1 : 0; + int hashsize_lg2 = log2ceil(hash_size); + + upb_inttable_sizedinit(&new_t, arr_size, hashsize_lg2, a); + + { + intptr_t iter = UPB_INTTABLE_BEGIN; + uintptr_t key; + upb_value val; + while (upb_inttable_next(t, &key, &val, &iter)) { + upb_inttable_insert(&new_t, key, val, a); + } + } + + UPB_ASSERT(new_t.array_size == arr_size); + UPB_ASSERT(new_t.t.size_lg2 == hashsize_lg2); + } + *t = new_t; +} + +// Iteration. + +bool upb_inttable_next(const upb_inttable* t, uintptr_t* key, upb_value* val, + intptr_t* iter) { + intptr_t i = *iter; + if ((size_t)(i + 1) <= t->array_size) { + while ((size_t)++i < t->array_size) { + upb_tabval ent = t->array[i]; + if (upb_arrhas(ent)) { + *key = i; + *val = _upb_value_val(ent.val); + *iter = i; + return true; + } + } + i--; // Back up to exactly one position before the start of the table. + } + + size_t tab_idx = next(&t->t, i - t->array_size); + if (tab_idx < upb_table_size(&t->t)) { + upb_tabent* ent = &t->t.entries[tab_idx]; + *key = ent->key; + *val = _upb_value_val(ent->val.val); + *iter = tab_idx + t->array_size; + return true; + } + + return false; +} + +void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter) { + intptr_t i = *iter; + if ((size_t)i < t->array_size) { + t->array_count--; + mutable_array(t)[i].val = -1; + } else { + upb_tabent* ent = &t->t.entries[i - t->array_size]; + upb_tabent* prev = NULL; + + // Linear search, not great. + upb_tabent* end = &t->t.entries[upb_table_size(&t->t)]; + for (upb_tabent* e = t->t.entries; e != end; e++) { + if (e->next == ent) { + prev = e; + break; + } + } + + if (prev) { + prev->next = ent->next; + } + + t->t.count--; + ent->key = 0; + ent->next = NULL; + } +} + +bool upb_strtable_next2(const upb_strtable* t, upb_StringView* key, + upb_value* val, intptr_t* iter) { + size_t tab_idx = next(&t->t, *iter); + if (tab_idx < upb_table_size(&t->t)) { + upb_tabent* ent = &t->t.entries[tab_idx]; + uint32_t len; + key->data = upb_tabstr(ent->key, &len); + key->size = len; + *val = _upb_value_val(ent->val.val); + *iter = tab_idx; + return true; + } + + return false; +} + +void upb_strtable_removeiter(upb_strtable* t, intptr_t* iter) { + intptr_t i = *iter; + upb_tabent* ent = &t->t.entries[i]; + upb_tabent* prev = NULL; + + // Linear search, not great. + upb_tabent* end = &t->t.entries[upb_table_size(&t->t)]; + for (upb_tabent* e = t->t.entries; e != end; e++) { + if (e->next == ent) { + prev = e; + break; + } + } + + if (prev) { + prev->next = ent->next; + } + + t->t.count--; + ent->key = 0; + ent->next = NULL; +} + +void upb_strtable_setentryvalue(upb_strtable* t, intptr_t iter, upb_value v) { + upb_tabent* ent = &t->t.entries[iter]; + ent->val.val = v.val; +} + + +// Must be last. + +const char* upb_BufToUint64(const char* ptr, const char* end, uint64_t* val) { + uint64_t u64 = 0; + while (ptr < end) { + unsigned ch = *ptr - '0'; + if (ch >= 10) break; + if (u64 > UINT64_MAX / 10 || u64 * 10 > UINT64_MAX - ch) { + return NULL; // integer overflow + } + u64 *= 10; + u64 += ch; + ptr++; + } + + *val = u64; + return ptr; +} + +const char* upb_BufToInt64(const char* ptr, const char* end, int64_t* val, + bool* is_neg) { + bool neg = false; + uint64_t u64; + + if (ptr != end && *ptr == '-') { + ptr++; + neg = true; + } + + ptr = upb_BufToUint64(ptr, end, &u64); + if (!ptr || u64 > (uint64_t)INT64_MAX + neg) { + return NULL; // integer overflow + } + + *val = neg ? -u64 : u64; + if (is_neg) *is_neg = neg; + return ptr; +} + + +#include +#include + +// Must be last. + +/* Miscellaneous utilities ****************************************************/ + +static void upb_FixLocale(char* p) { + /* printf() is dependent on locales; sadly there is no easy and portable way + * to avoid this. This little post-processing step will translate 1,2 -> 1.2 + * since JSON needs the latter. Arguably a hack, but it is simple and the + * alternatives are far more complicated, platform-dependent, and/or larger + * in code size. */ + for (; *p; p++) { + if (*p == ',') *p = '.'; + } +} + +void _upb_EncodeRoundTripDouble(double val, char* buf, size_t size) { + assert(size >= kUpb_RoundTripBufferSize); + snprintf(buf, size, "%.*g", DBL_DIG, val); + if (strtod(buf, NULL) != val) { + snprintf(buf, size, "%.*g", DBL_DIG + 2, val); + assert(strtod(buf, NULL) == val); + } + upb_FixLocale(buf); +} + +void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size) { + assert(size >= kUpb_RoundTripBufferSize); + snprintf(buf, size, "%.*g", FLT_DIG, val); + if (strtof(buf, NULL) != val) { + snprintf(buf, size, "%.*g", FLT_DIG + 3, val); + assert(strtof(buf, NULL) == val); + } + upb_FixLocale(buf); +} + + +#include +#include + +// Must be last. + +// Determine the locale-specific radix character by calling sprintf() to print +// the number 1.5, then stripping off the digits. As far as I can tell, this +// is the only portable, thread-safe way to get the C library to divulge the +// locale's radix character. No, localeconv() is NOT thread-safe. + +static int GetLocaleRadix(char *data, size_t capacity) { + char temp[16]; + const int size = snprintf(temp, sizeof(temp), "%.1f", 1.5); + UPB_ASSERT(temp[0] == '1'); + UPB_ASSERT(temp[size - 1] == '5'); + UPB_ASSERT(size < capacity); + temp[size - 1] = '\0'; + strcpy(data, temp + 1); + return size - 2; +} + +// Populates a string identical to *input except that the character pointed to +// by pos (which should be '.') is replaced with the locale-specific radix. + +static void LocalizeRadix(const char *input, const char *pos, char *output) { + const int len1 = pos - input; + + char radix[8]; + const int len2 = GetLocaleRadix(radix, sizeof(radix)); + + memcpy(output, input, len1); + memcpy(output + len1, radix, len2); + strcpy(output + len1 + len2, input + len1 + 1); +} + +double _upb_NoLocaleStrtod(const char *str, char **endptr) { + // We cannot simply set the locale to "C" temporarily with setlocale() + // as this is not thread-safe. Instead, we try to parse in the current + // locale first. If parsing stops at a '.' character, then this is a + // pretty good hint that we're actually in some other locale in which + // '.' is not the radix character. + + char *temp_endptr; + double result = strtod(str, &temp_endptr); + if (endptr != NULL) *endptr = temp_endptr; + if (*temp_endptr != '.') return result; + + // Parsing halted on a '.'. Perhaps we're in a different locale? Let's + // try to replace the '.' with a locale-specific radix character and + // try again. + + char localized[80]; + LocalizeRadix(str, temp_endptr, localized); + char *localized_endptr; + result = strtod(localized, &localized_endptr); + if ((localized_endptr - &localized[0]) > (temp_endptr - str)) { + // This attempt got further, so replacing the decimal must have helped. + // Update endptr to point at the right location. + if (endptr != NULL) { + // size_diff is non-zero if the localized radix has multiple bytes. + int size_diff = strlen(localized) - strlen(str); + *endptr = (char *)str + (localized_endptr - &localized[0] - size_diff); + } + } + + return result; +} + + +// Must be last. + +int upb_Unicode_ToUTF8(uint32_t cp, char* out) { + if (cp <= 0x7f) { + out[0] = cp; + return 1; + } + if (cp <= 0x07ff) { + out[0] = (cp >> 6) | 0xc0; + out[1] = (cp & 0x3f) | 0x80; + return 2; + } + if (cp <= 0xffff) { + out[0] = (cp >> 12) | 0xe0; + out[1] = ((cp >> 6) & 0x3f) | 0x80; + out[2] = (cp & 0x3f) | 0x80; + return 3; + } + if (cp <= 0x10ffff) { + out[0] = (cp >> 18) | 0xf0; + out[1] = ((cp >> 12) & 0x3f) | 0x80; + out[2] = ((cp >> 6) & 0x3f) | 0x80; + out[3] = (cp & 0x3f) | 0x80; + return 4; + } + return 0; +} + + +#include + + +// Must be last. + +typedef struct upb_UnknownFields upb_UnknownFields; + +typedef struct { + uint32_t tag; + union { + uint64_t varint; + uint64_t uint64; + uint32_t uint32; + upb_StringView delimited; + upb_UnknownFields* group; + } data; +} upb_UnknownField; + +struct upb_UnknownFields { + size_t size; + size_t capacity; + upb_UnknownField* fields; +}; + +typedef struct { + upb_EpsCopyInputStream stream; + upb_Arena* arena; + upb_UnknownField* tmp; + size_t tmp_size; + int depth; + upb_UnknownCompareResult status; + jmp_buf err; +} upb_UnknownField_Context; + +UPB_NORETURN static void upb_UnknownFields_OutOfMemory( + upb_UnknownField_Context* ctx) { + ctx->status = kUpb_UnknownCompareResult_OutOfMemory; + UPB_LONGJMP(ctx->err, 1); +} + +static void upb_UnknownFields_Grow(upb_UnknownField_Context* ctx, + upb_UnknownField** base, + upb_UnknownField** ptr, + upb_UnknownField** end) { + size_t old = (*ptr - *base); + size_t new = UPB_MAX(4, old * 2); + + *base = upb_Arena_Realloc(ctx->arena, *base, old * sizeof(**base), + new * sizeof(**base)); + if (!*base) upb_UnknownFields_OutOfMemory(ctx); + + *ptr = *base + old; + *end = *base + new; +} + +// We have to implement our own sort here, since qsort() is not an in-order +// sort. Here we use merge sort, the simplest in-order sort. +static void upb_UnknownFields_Merge(upb_UnknownField* arr, size_t start, + size_t mid, size_t end, + upb_UnknownField* tmp) { + memcpy(tmp, &arr[start], (end - start) * sizeof(*tmp)); + + upb_UnknownField* ptr1 = tmp; + upb_UnknownField* end1 = &tmp[mid - start]; + upb_UnknownField* ptr2 = &tmp[mid - start]; + upb_UnknownField* end2 = &tmp[end - start]; + upb_UnknownField* out = &arr[start]; + + while (ptr1 < end1 && ptr2 < end2) { + if (ptr1->tag <= ptr2->tag) { + *out++ = *ptr1++; + } else { + *out++ = *ptr2++; + } + } + + if (ptr1 < end1) { + memcpy(out, ptr1, (end1 - ptr1) * sizeof(*out)); + } else if (ptr2 < end2) { + memcpy(out, ptr1, (end2 - ptr2) * sizeof(*out)); + } +} + +static void upb_UnknownFields_SortRecursive(upb_UnknownField* arr, size_t start, + size_t end, upb_UnknownField* tmp) { + if (end - start > 1) { + size_t mid = start + ((end - start) / 2); + upb_UnknownFields_SortRecursive(arr, start, mid, tmp); + upb_UnknownFields_SortRecursive(arr, mid, end, tmp); + upb_UnknownFields_Merge(arr, start, mid, end, tmp); + } +} + +static void upb_UnknownFields_Sort(upb_UnknownField_Context* ctx, + upb_UnknownFields* fields) { + if (ctx->tmp_size < fields->size) { + const int oldsize = ctx->tmp_size * sizeof(*ctx->tmp); + ctx->tmp_size = UPB_MAX(8, ctx->tmp_size); + while (ctx->tmp_size < fields->size) ctx->tmp_size *= 2; + const int newsize = ctx->tmp_size * sizeof(*ctx->tmp); + ctx->tmp = upb_grealloc(ctx->tmp, oldsize, newsize); + } + upb_UnknownFields_SortRecursive(fields->fields, 0, fields->size, ctx->tmp); +} + +static upb_UnknownFields* upb_UnknownFields_DoBuild( + upb_UnknownField_Context* ctx, const char** buf) { + upb_UnknownField* arr_base = NULL; + upb_UnknownField* arr_ptr = NULL; + upb_UnknownField* arr_end = NULL; + const char* ptr = *buf; + uint32_t last_tag = 0; + bool sorted = true; + while (!upb_EpsCopyInputStream_IsDone(&ctx->stream, &ptr)) { + uint32_t tag; + ptr = upb_WireReader_ReadTag(ptr, &tag); + UPB_ASSERT(tag <= UINT32_MAX); + int wire_type = upb_WireReader_GetWireType(tag); + if (wire_type == kUpb_WireType_EndGroup) break; + if (tag < last_tag) sorted = false; + last_tag = tag; + + if (arr_ptr == arr_end) { + upb_UnknownFields_Grow(ctx, &arr_base, &arr_ptr, &arr_end); + } + upb_UnknownField* field = arr_ptr; + field->tag = tag; + arr_ptr++; + + switch (wire_type) { + case kUpb_WireType_Varint: + ptr = upb_WireReader_ReadVarint(ptr, &field->data.varint); + break; + case kUpb_WireType_64Bit: + ptr = upb_WireReader_ReadFixed64(ptr, &field->data.uint64); + break; + case kUpb_WireType_32Bit: + ptr = upb_WireReader_ReadFixed32(ptr, &field->data.uint32); + break; + case kUpb_WireType_Delimited: { + int size; + ptr = upb_WireReader_ReadSize(ptr, &size); + const char* s_ptr = ptr; + ptr = upb_EpsCopyInputStream_ReadStringAliased(&ctx->stream, &s_ptr, + size); + field->data.delimited.data = s_ptr; + field->data.delimited.size = size; + break; + } + case kUpb_WireType_StartGroup: + if (--ctx->depth == 0) { + ctx->status = kUpb_UnknownCompareResult_MaxDepthExceeded; + UPB_LONGJMP(ctx->err, 1); + } + field->data.group = upb_UnknownFields_DoBuild(ctx, &ptr); + ctx->depth++; + break; + default: + UPB_UNREACHABLE(); + } + } + + *buf = ptr; + upb_UnknownFields* ret = upb_Arena_Malloc(ctx->arena, sizeof(*ret)); + if (!ret) upb_UnknownFields_OutOfMemory(ctx); + ret->fields = arr_base; + ret->size = arr_ptr - arr_base; + ret->capacity = arr_end - arr_base; + if (!sorted) { + upb_UnknownFields_Sort(ctx, ret); + } + return ret; +} + +// Builds a upb_UnknownFields data structure from the binary data in buf. +static upb_UnknownFields* upb_UnknownFields_Build(upb_UnknownField_Context* ctx, + const char* ptr, + size_t size) { + upb_EpsCopyInputStream_Init(&ctx->stream, &ptr, size, true); + upb_UnknownFields* fields = upb_UnknownFields_DoBuild(ctx, &ptr); + UPB_ASSERT(upb_EpsCopyInputStream_IsDone(&ctx->stream, &ptr) && + !upb_EpsCopyInputStream_IsError(&ctx->stream)); + return fields; +} + +// Compares two sorted upb_UnknownFields structures for equality. +static bool upb_UnknownFields_IsEqual(const upb_UnknownFields* uf1, + const upb_UnknownFields* uf2) { + if (uf1->size != uf2->size) return false; + for (size_t i = 0, n = uf1->size; i < n; i++) { + upb_UnknownField* f1 = &uf1->fields[i]; + upb_UnknownField* f2 = &uf2->fields[i]; + if (f1->tag != f2->tag) return false; + int wire_type = f1->tag & 7; + switch (wire_type) { + case kUpb_WireType_Varint: + if (f1->data.varint != f2->data.varint) return false; + break; + case kUpb_WireType_64Bit: + if (f1->data.uint64 != f2->data.uint64) return false; + break; + case kUpb_WireType_32Bit: + if (f1->data.uint32 != f2->data.uint32) return false; + break; + case kUpb_WireType_Delimited: + if (!upb_StringView_IsEqual(f1->data.delimited, f2->data.delimited)) { + return false; + } + break; + case kUpb_WireType_StartGroup: + if (!upb_UnknownFields_IsEqual(f1->data.group, f2->data.group)) { + return false; + } + break; + default: + UPB_UNREACHABLE(); + } + } + return true; +} + +static upb_UnknownCompareResult upb_UnknownField_DoCompare( + upb_UnknownField_Context* ctx, const char* buf1, size_t size1, + const char* buf2, size_t size2) { + upb_UnknownCompareResult ret; + // First build both unknown fields into a sorted data structure (similar + // to the UnknownFieldSet in C++). + upb_UnknownFields* uf1 = upb_UnknownFields_Build(ctx, buf1, size1); + upb_UnknownFields* uf2 = upb_UnknownFields_Build(ctx, buf2, size2); + + // Now perform the equality check on the sorted structures. + if (upb_UnknownFields_IsEqual(uf1, uf2)) { + ret = kUpb_UnknownCompareResult_Equal; + } else { + ret = kUpb_UnknownCompareResult_NotEqual; + } + return ret; +} + +static upb_UnknownCompareResult upb_UnknownField_Compare( + upb_UnknownField_Context* const ctx, const char* const buf1, + const size_t size1, const char* const buf2, const size_t size2) { + upb_UnknownCompareResult ret; + if (UPB_SETJMP(ctx->err) == 0) { + ret = upb_UnknownField_DoCompare(ctx, buf1, size1, buf2, size2); + } else { + ret = ctx->status; + UPB_ASSERT(ret != kUpb_UnknownCompareResult_Equal); + } + + upb_Arena_Free(ctx->arena); + upb_gfree(ctx->tmp); + return ret; +} + +upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( + const char* buf1, size_t size1, const char* buf2, size_t size2, + int max_depth) { + if (size1 == 0 && size2 == 0) return kUpb_UnknownCompareResult_Equal; + if (size1 == 0 || size2 == 0) return kUpb_UnknownCompareResult_NotEqual; + if (memcmp(buf1, buf2, size1) == 0) return kUpb_UnknownCompareResult_Equal; + + upb_UnknownField_Context ctx = { + .arena = upb_Arena_New(), + .depth = max_depth, + .tmp = NULL, + .tmp_size = 0, + .status = kUpb_UnknownCompareResult_Equal, + }; + + if (!ctx.arena) return kUpb_UnknownCompareResult_OutOfMemory; + + return upb_UnknownField_Compare(&ctx, buf1, size1, buf2, size2); +} + + +#include + + +// Must be last. + +const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)( + const struct upb_Message* msg, const upb_MiniTableExtension* e) { + size_t n; + const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &n); + + // For now we use linear search exclusively to find extensions. + // If this becomes an issue due to messages with lots of extensions, + // we can introduce a table of some sort. + for (size_t i = 0; i < n; i++) { + if (ext[i].ext == e) { + return &ext[i]; + } + } + + return NULL; +} + +const upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)( + const struct upb_Message* msg, size_t* count) { + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + if (in) { + *count = (in->size - in->ext_begin) / sizeof(upb_Extension); + return UPB_PTR_AT(in, in->ext_begin, void); + } else { + *count = 0; + return NULL; + } +} + +upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)( + struct upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* a) { + upb_Extension* ext = (upb_Extension*)UPB_PRIVATE(_upb_Message_Getext)(msg, e); + if (ext) return ext; + if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, sizeof(upb_Extension), a)) + return NULL; + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + in->ext_begin -= sizeof(upb_Extension); + ext = UPB_PTR_AT(in, in->ext_begin, void); + memset(ext, 0, sizeof(upb_Extension)); + ext->ext = e; + return ext; +} + + +#include +#include + + +// Must be last. + +const float kUpb_FltInfinity = INFINITY; +const double kUpb_Infinity = INFINITY; +const double kUpb_NaN = NAN; + +bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, + upb_Arena* a) { + const size_t overhead = sizeof(upb_Message_Internal); + + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + if (!in) { + // No internal data, allocate from scratch. + size_t size = UPB_MAX(128, upb_Log2CeilingSize(need + overhead)); + in = upb_Arena_Malloc(a, size); + if (!in) return false; + + in->size = size; + in->unknown_end = overhead; + in->ext_begin = size; + UPB_PRIVATE(_upb_Message_SetInternal)(msg, in); + } else if (in->ext_begin - in->unknown_end < need) { + // Internal data is too small, reallocate. + size_t new_size = upb_Log2CeilingSize(in->size + need); + size_t ext_bytes = in->size - in->ext_begin; + size_t new_ext_begin = new_size - ext_bytes; + in = upb_Arena_Realloc(a, in, in->size, new_size); + if (!in) return false; + + if (ext_bytes) { + // Need to move extension data to the end. + char* ptr = (char*)in; + memmove(ptr + new_ext_begin, ptr + in->ext_begin, ext_bytes); + } + in->ext_begin = new_ext_begin; + in->size = new_size; + UPB_PRIVATE(_upb_Message_SetInternal)(msg, in); + } + + UPB_ASSERT(in->ext_begin - in->unknown_end >= need); + return true; +} + +#if UPB_TRACING_ENABLED +static void (*_new_message_trace_handler)(const upb_MiniTable*, + const upb_Arena*); + +void UPB_PRIVATE(upb_Message_SetNewMessageTraceHandler)( + void (*new_message_trace_handler)(const upb_MiniTable*, const upb_Arena*)) { + _new_message_trace_handler = new_message_trace_handler; +} + +void UPB_PRIVATE(upb_Message_LogNewMessage)(const upb_MiniTable* mini_table, + const upb_Arena* arena) { + if (_new_message_trace_handler) { + _new_message_trace_handler(mini_table, arena); + } +} +#endif + + +const char _kUpb_ToBase92[] = { + ' ', '!', '#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', + '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', + 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', + 'Z', '[', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', + 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '{', '|', '}', '~', +}; + +const int8_t _kUpb_FromBase92[] = { + 0, 1, -1, 2, 3, 4, 5, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, -1, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, +}; + + +#include +#include +#include + + +// Must be last. + +typedef struct { + uint64_t present_values_mask; + uint32_t last_written_value; +} upb_MtDataEncoderInternal_EnumState; + +typedef struct { + uint64_t msg_modifiers; + uint32_t last_field_num; + enum { + kUpb_OneofState_NotStarted, + kUpb_OneofState_StartedOneof, + kUpb_OneofState_EmittedOneofField, + } oneof_state; +} upb_MtDataEncoderInternal_MsgState; + +typedef struct { + char* buf_start; // Only for checking kUpb_MtDataEncoder_MinSize. + union { + upb_MtDataEncoderInternal_EnumState enum_state; + upb_MtDataEncoderInternal_MsgState msg_state; + } state; +} upb_MtDataEncoderInternal; + +static upb_MtDataEncoderInternal* upb_MtDataEncoder_GetInternal( + upb_MtDataEncoder* e, char* buf_start) { + UPB_ASSERT(sizeof(upb_MtDataEncoderInternal) <= sizeof(e->internal)); + upb_MtDataEncoderInternal* ret = (upb_MtDataEncoderInternal*)e->internal; + ret->buf_start = buf_start; + return ret; +} + +static char* upb_MtDataEncoder_PutRaw(upb_MtDataEncoder* e, char* ptr, + char ch) { + upb_MtDataEncoderInternal* in = (upb_MtDataEncoderInternal*)e->internal; + UPB_ASSERT(ptr - in->buf_start < kUpb_MtDataEncoder_MinSize); + if (ptr == e->end) return NULL; + *ptr++ = ch; + return ptr; +} + +static char* upb_MtDataEncoder_Put(upb_MtDataEncoder* e, char* ptr, char ch) { + return upb_MtDataEncoder_PutRaw(e, ptr, _upb_ToBase92(ch)); +} + +static char* upb_MtDataEncoder_PutBase92Varint(upb_MtDataEncoder* e, char* ptr, + uint32_t val, int min, int max) { + int shift = upb_Log2Ceiling(_upb_FromBase92(max) - _upb_FromBase92(min) + 1); + UPB_ASSERT(shift <= 6); + uint32_t mask = (1 << shift) - 1; + do { + uint32_t bits = val & mask; + ptr = upb_MtDataEncoder_Put(e, ptr, bits + _upb_FromBase92(min)); + if (!ptr) return NULL; + val >>= shift; + } while (val); + return ptr; +} + +char* upb_MtDataEncoder_PutModifier(upb_MtDataEncoder* e, char* ptr, + uint64_t mod) { + if (mod) { + ptr = upb_MtDataEncoder_PutBase92Varint(e, ptr, mod, + kUpb_EncodedValue_MinModifier, + kUpb_EncodedValue_MaxModifier); + } + return ptr; +} + +char* upb_MtDataEncoder_EncodeExtension(upb_MtDataEncoder* e, char* ptr, + upb_FieldType type, uint32_t field_num, + uint64_t field_mod) { + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + in->state.msg_state.msg_modifiers = 0; + in->state.msg_state.last_field_num = 0; + in->state.msg_state.oneof_state = kUpb_OneofState_NotStarted; + + ptr = upb_MtDataEncoder_PutRaw(e, ptr, kUpb_EncodedVersion_ExtensionV1); + if (!ptr) return NULL; + + return upb_MtDataEncoder_PutField(e, ptr, type, field_num, field_mod); +} + +char* upb_MtDataEncoder_EncodeMap(upb_MtDataEncoder* e, char* ptr, + upb_FieldType key_type, + upb_FieldType value_type, uint64_t key_mod, + uint64_t value_mod) { + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + in->state.msg_state.msg_modifiers = 0; + in->state.msg_state.last_field_num = 0; + in->state.msg_state.oneof_state = kUpb_OneofState_NotStarted; + + ptr = upb_MtDataEncoder_PutRaw(e, ptr, kUpb_EncodedVersion_MapV1); + if (!ptr) return NULL; + + ptr = upb_MtDataEncoder_PutField(e, ptr, key_type, 1, key_mod); + if (!ptr) return NULL; + + return upb_MtDataEncoder_PutField(e, ptr, value_type, 2, value_mod); +} + +char* upb_MtDataEncoder_EncodeMessageSet(upb_MtDataEncoder* e, char* ptr) { + (void)upb_MtDataEncoder_GetInternal(e, ptr); + return upb_MtDataEncoder_PutRaw(e, ptr, kUpb_EncodedVersion_MessageSetV1); +} + +char* upb_MtDataEncoder_StartMessage(upb_MtDataEncoder* e, char* ptr, + uint64_t msg_mod) { + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + in->state.msg_state.msg_modifiers = msg_mod; + in->state.msg_state.last_field_num = 0; + in->state.msg_state.oneof_state = kUpb_OneofState_NotStarted; + + ptr = upb_MtDataEncoder_PutRaw(e, ptr, kUpb_EncodedVersion_MessageV1); + if (!ptr) return NULL; + + return upb_MtDataEncoder_PutModifier(e, ptr, msg_mod); +} + +static char* _upb_MtDataEncoder_MaybePutFieldSkip(upb_MtDataEncoder* e, + char* ptr, + uint32_t field_num) { + upb_MtDataEncoderInternal* in = (upb_MtDataEncoderInternal*)e->internal; + if (field_num <= in->state.msg_state.last_field_num) return NULL; + if (in->state.msg_state.last_field_num + 1 != field_num) { + // Put skip. + UPB_ASSERT(field_num > in->state.msg_state.last_field_num); + uint32_t skip = field_num - in->state.msg_state.last_field_num; + ptr = upb_MtDataEncoder_PutBase92Varint( + e, ptr, skip, kUpb_EncodedValue_MinSkip, kUpb_EncodedValue_MaxSkip); + if (!ptr) return NULL; + } + in->state.msg_state.last_field_num = field_num; + return ptr; +} + +static char* _upb_MtDataEncoder_PutFieldType(upb_MtDataEncoder* e, char* ptr, + upb_FieldType type, + uint64_t field_mod) { + static const char kUpb_TypeToEncoded[] = { + [kUpb_FieldType_Double] = kUpb_EncodedType_Double, + [kUpb_FieldType_Float] = kUpb_EncodedType_Float, + [kUpb_FieldType_Int64] = kUpb_EncodedType_Int64, + [kUpb_FieldType_UInt64] = kUpb_EncodedType_UInt64, + [kUpb_FieldType_Int32] = kUpb_EncodedType_Int32, + [kUpb_FieldType_Fixed64] = kUpb_EncodedType_Fixed64, + [kUpb_FieldType_Fixed32] = kUpb_EncodedType_Fixed32, + [kUpb_FieldType_Bool] = kUpb_EncodedType_Bool, + [kUpb_FieldType_String] = kUpb_EncodedType_String, + [kUpb_FieldType_Group] = kUpb_EncodedType_Group, + [kUpb_FieldType_Message] = kUpb_EncodedType_Message, + [kUpb_FieldType_Bytes] = kUpb_EncodedType_Bytes, + [kUpb_FieldType_UInt32] = kUpb_EncodedType_UInt32, + [kUpb_FieldType_Enum] = kUpb_EncodedType_OpenEnum, + [kUpb_FieldType_SFixed32] = kUpb_EncodedType_SFixed32, + [kUpb_FieldType_SFixed64] = kUpb_EncodedType_SFixed64, + [kUpb_FieldType_SInt32] = kUpb_EncodedType_SInt32, + [kUpb_FieldType_SInt64] = kUpb_EncodedType_SInt64, + }; + + int encoded_type = kUpb_TypeToEncoded[type]; + + if (field_mod & kUpb_FieldModifier_IsClosedEnum) { + UPB_ASSERT(type == kUpb_FieldType_Enum); + encoded_type = kUpb_EncodedType_ClosedEnum; + } + + if (field_mod & kUpb_FieldModifier_IsRepeated) { + // Repeated fields shift the type number up (unlike other modifiers which + // are bit flags). + encoded_type += kUpb_EncodedType_RepeatedBase; + } + + return upb_MtDataEncoder_Put(e, ptr, encoded_type); +} + +static char* _upb_MtDataEncoder_MaybePutModifiers(upb_MtDataEncoder* e, + char* ptr, upb_FieldType type, + uint64_t field_mod) { + upb_MtDataEncoderInternal* in = (upb_MtDataEncoderInternal*)e->internal; + uint32_t encoded_modifiers = 0; + if ((field_mod & kUpb_FieldModifier_IsRepeated) && + upb_FieldType_IsPackable(type)) { + bool field_is_packed = field_mod & kUpb_FieldModifier_IsPacked; + bool default_is_packed = in->state.msg_state.msg_modifiers & + kUpb_MessageModifier_DefaultIsPacked; + if (field_is_packed != default_is_packed) { + encoded_modifiers |= kUpb_EncodedFieldModifier_FlipPacked; + } + } + + if (type == kUpb_FieldType_String) { + bool field_validates_utf8 = field_mod & kUpb_FieldModifier_ValidateUtf8; + bool message_validates_utf8 = + in->state.msg_state.msg_modifiers & kUpb_MessageModifier_ValidateUtf8; + if (field_validates_utf8 != message_validates_utf8) { + // Old binaries do not recognize the field modifier. We need the failure + // mode to be too lax rather than too strict. Our caller should have + // handled this (see _upb_MessageDef_ValidateUtf8()). + assert(!message_validates_utf8); + encoded_modifiers |= kUpb_EncodedFieldModifier_FlipValidateUtf8; + } + } + + if (field_mod & kUpb_FieldModifier_IsProto3Singular) { + encoded_modifiers |= kUpb_EncodedFieldModifier_IsProto3Singular; + } + + if (field_mod & kUpb_FieldModifier_IsRequired) { + encoded_modifiers |= kUpb_EncodedFieldModifier_IsRequired; + } + + return upb_MtDataEncoder_PutModifier(e, ptr, encoded_modifiers); +} + +char* upb_MtDataEncoder_PutField(upb_MtDataEncoder* e, char* ptr, + upb_FieldType type, uint32_t field_num, + uint64_t field_mod) { + upb_MtDataEncoder_GetInternal(e, ptr); + + ptr = _upb_MtDataEncoder_MaybePutFieldSkip(e, ptr, field_num); + if (!ptr) return NULL; + + ptr = _upb_MtDataEncoder_PutFieldType(e, ptr, type, field_mod); + if (!ptr) return NULL; + + return _upb_MtDataEncoder_MaybePutModifiers(e, ptr, type, field_mod); +} + +char* upb_MtDataEncoder_StartOneof(upb_MtDataEncoder* e, char* ptr) { + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + if (in->state.msg_state.oneof_state == kUpb_OneofState_NotStarted) { + ptr = upb_MtDataEncoder_Put(e, ptr, _upb_FromBase92(kUpb_EncodedValue_End)); + } else { + ptr = upb_MtDataEncoder_Put( + e, ptr, _upb_FromBase92(kUpb_EncodedValue_OneofSeparator)); + } + in->state.msg_state.oneof_state = kUpb_OneofState_StartedOneof; + return ptr; +} + +char* upb_MtDataEncoder_PutOneofField(upb_MtDataEncoder* e, char* ptr, + uint32_t field_num) { + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + if (in->state.msg_state.oneof_state == kUpb_OneofState_EmittedOneofField) { + ptr = upb_MtDataEncoder_Put( + e, ptr, _upb_FromBase92(kUpb_EncodedValue_FieldSeparator)); + if (!ptr) return NULL; + } + ptr = upb_MtDataEncoder_PutBase92Varint(e, ptr, field_num, _upb_ToBase92(0), + _upb_ToBase92(63)); + in->state.msg_state.oneof_state = kUpb_OneofState_EmittedOneofField; + return ptr; +} + +char* upb_MtDataEncoder_StartEnum(upb_MtDataEncoder* e, char* ptr) { + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + in->state.enum_state.present_values_mask = 0; + in->state.enum_state.last_written_value = 0; + + return upb_MtDataEncoder_PutRaw(e, ptr, kUpb_EncodedVersion_EnumV1); +} + +static char* upb_MtDataEncoder_FlushDenseEnumMask(upb_MtDataEncoder* e, + char* ptr) { + upb_MtDataEncoderInternal* in = (upb_MtDataEncoderInternal*)e->internal; + ptr = upb_MtDataEncoder_Put(e, ptr, in->state.enum_state.present_values_mask); + in->state.enum_state.present_values_mask = 0; + in->state.enum_state.last_written_value += 5; + return ptr; +} + +char* upb_MtDataEncoder_PutEnumValue(upb_MtDataEncoder* e, char* ptr, + uint32_t val) { + // TODO: optimize this encoding. + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + UPB_ASSERT(val >= in->state.enum_state.last_written_value); + uint32_t delta = val - in->state.enum_state.last_written_value; + if (delta >= 5 && in->state.enum_state.present_values_mask) { + ptr = upb_MtDataEncoder_FlushDenseEnumMask(e, ptr); + if (!ptr) { + return NULL; + } + delta -= 5; + } + + if (delta >= 5) { + ptr = upb_MtDataEncoder_PutBase92Varint( + e, ptr, delta, kUpb_EncodedValue_MinSkip, kUpb_EncodedValue_MaxSkip); + in->state.enum_state.last_written_value += delta; + delta = 0; + } + + UPB_ASSERT((in->state.enum_state.present_values_mask >> delta) == 0); + in->state.enum_state.present_values_mask |= 1ULL << delta; + return ptr; +} + +char* upb_MtDataEncoder_EndEnum(upb_MtDataEncoder* e, char* ptr) { + upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr); + if (!in->state.enum_state.present_values_mask) return ptr; + return upb_MtDataEncoder_FlushDenseEnumMask(e, ptr); +} + + +#include + + +// Must be last. + +// A MiniTable for an empty message, used for unlinked sub-messages. +const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty) = { + .UPB_PRIVATE(subs) = NULL, + .UPB_PRIVATE(fields) = NULL, + .UPB_PRIVATE(size) = sizeof(struct upb_Message), + .UPB_PRIVATE(field_count) = 0, + .UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable, + .UPB_PRIVATE(dense_below) = 0, + .UPB_PRIVATE(table_mask) = -1, + .UPB_PRIVATE(required_count) = 0, +}; + + + +// Must be last. + +struct upb_DefPool { + upb_Arena* arena; + upb_strtable syms; // full_name -> packed def ptr + upb_strtable files; // file_name -> (upb_FileDef*) + upb_inttable exts; // (upb_MiniTableExtension*) -> (upb_FieldDef*) + upb_ExtensionRegistry* extreg; + const UPB_DESC(FeatureSetDefaults) * feature_set_defaults; + upb_MiniTablePlatform platform; + void* scratch_data; + size_t scratch_size; + size_t bytes_loaded; +}; + +void upb_DefPool_Free(upb_DefPool* s) { + upb_Arena_Free(s->arena); + upb_gfree(s->scratch_data); + upb_gfree(s); +} + +static const char serialized_defaults[] = UPB_INTERNAL_UPB_EDITION_DEFAULTS; + +upb_DefPool* upb_DefPool_New(void) { + upb_DefPool* s = upb_gmalloc(sizeof(*s)); + if (!s) return NULL; + + s->arena = upb_Arena_New(); + s->bytes_loaded = 0; + + s->scratch_size = 240; + s->scratch_data = upb_gmalloc(s->scratch_size); + if (!s->scratch_data) goto err; + + if (!upb_strtable_init(&s->syms, 32, s->arena)) goto err; + if (!upb_strtable_init(&s->files, 4, s->arena)) goto err; + if (!upb_inttable_init(&s->exts, s->arena)) goto err; + + s->extreg = upb_ExtensionRegistry_New(s->arena); + if (!s->extreg) goto err; + + s->platform = kUpb_MiniTablePlatform_Native; + + upb_Status status; + if (!upb_DefPool_SetFeatureSetDefaults( + s, serialized_defaults, sizeof(serialized_defaults) - 1, &status)) { + goto err; + } + + if (!s->feature_set_defaults) goto err; + + return s; + +err: + upb_DefPool_Free(s); + return NULL; +} + +const UPB_DESC(FeatureSetDefaults) * + upb_DefPool_FeatureSetDefaults(const upb_DefPool* s) { + return s->feature_set_defaults; +} + +bool upb_DefPool_SetFeatureSetDefaults(upb_DefPool* s, + const char* serialized_defaults, + size_t serialized_len, + upb_Status* status) { + const UPB_DESC(FeatureSetDefaults)* defaults = UPB_DESC( + FeatureSetDefaults_parse)(serialized_defaults, serialized_len, s->arena); + if (!defaults) { + upb_Status_SetErrorFormat(status, "Failed to parse defaults"); + return false; + } + if (upb_strtable_count(&s->files) > 0) { + upb_Status_SetErrorFormat(status, + "Feature set defaults can't be changed once the " + "pool has started building"); + return false; + } + int min_edition = UPB_DESC(FeatureSetDefaults_minimum_edition(defaults)); + int max_edition = UPB_DESC(FeatureSetDefaults_maximum_edition(defaults)); + if (min_edition > max_edition) { + upb_Status_SetErrorFormat(status, "Invalid edition range %s to %s", + upb_FileDef_EditionName(min_edition), + upb_FileDef_EditionName(max_edition)); + return false; + } + size_t size; + const UPB_DESC( + FeatureSetDefaults_FeatureSetEditionDefault)* const* default_list = + UPB_DESC(FeatureSetDefaults_defaults(defaults, &size)); + int prev_edition = UPB_DESC(EDITION_UNKNOWN); + for (size_t i = 0; i < size; ++i) { + int edition = UPB_DESC( + FeatureSetDefaults_FeatureSetEditionDefault_edition(default_list[i])); + if (edition == UPB_DESC(EDITION_UNKNOWN)) { + upb_Status_SetErrorFormat(status, "Invalid edition UNKNOWN specified"); + return false; + } + if (edition <= prev_edition) { + upb_Status_SetErrorFormat(status, + "Feature set defaults are not strictly " + "increasing, %s is greater than or equal to %s", + upb_FileDef_EditionName(prev_edition), + upb_FileDef_EditionName(edition)); + return false; + } + prev_edition = edition; + } + + // Copy the defaults into the pool. + s->feature_set_defaults = defaults; + return true; +} + +bool _upb_DefPool_InsertExt(upb_DefPool* s, const upb_MiniTableExtension* ext, + const upb_FieldDef* f) { + return upb_inttable_insert(&s->exts, (uintptr_t)ext, upb_value_constptr(f), + s->arena); +} + +bool _upb_DefPool_InsertSym(upb_DefPool* s, upb_StringView sym, upb_value v, + upb_Status* status) { + // TODO: table should support an operation "tryinsert" to avoid the double + // lookup. + if (upb_strtable_lookup2(&s->syms, sym.data, sym.size, NULL)) { + upb_Status_SetErrorFormat(status, "duplicate symbol '%s'", sym.data); + return false; + } + if (!upb_strtable_insert(&s->syms, sym.data, sym.size, v, s->arena)) { + upb_Status_SetErrorMessage(status, "out of memory"); + return false; + } + return true; +} + +static const void* _upb_DefPool_Unpack(const upb_DefPool* s, const char* sym, + size_t size, upb_deftype_t type) { + upb_value v; + return upb_strtable_lookup2(&s->syms, sym, size, &v) + ? _upb_DefType_Unpack(v, type) + : NULL; +} + +bool _upb_DefPool_LookupSym(const upb_DefPool* s, const char* sym, size_t size, + upb_value* v) { + return upb_strtable_lookup2(&s->syms, sym, size, v); +} + +upb_ExtensionRegistry* _upb_DefPool_ExtReg(const upb_DefPool* s) { + return s->extreg; +} + +void** _upb_DefPool_ScratchData(const upb_DefPool* s) { + return (void**)&s->scratch_data; +} + +size_t* _upb_DefPool_ScratchSize(const upb_DefPool* s) { + return (size_t*)&s->scratch_size; +} + +void _upb_DefPool_SetPlatform(upb_DefPool* s, upb_MiniTablePlatform platform) { + assert(upb_strtable_count(&s->files) == 0); + s->platform = platform; +} + +const upb_MessageDef* upb_DefPool_FindMessageByName(const upb_DefPool* s, + const char* sym) { + return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_MSG); +} + +const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len) { + return _upb_DefPool_Unpack(s, sym, len, UPB_DEFTYPE_MSG); +} + +const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s, + const char* sym) { + return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_ENUM); +} + +const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s, + const char* sym) { + return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_ENUMVAL); +} + +const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s, + const char* name) { + upb_value v; + return upb_strtable_lookup(&s->files, name, &v) ? upb_value_getconstptr(v) + : NULL; +} + +const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s, + const char* name, + size_t len) { + upb_value v; + return upb_strtable_lookup2(&s->files, name, len, &v) + ? upb_value_getconstptr(v) + : NULL; +} + +const upb_FieldDef* upb_DefPool_FindExtensionByNameWithSize( + const upb_DefPool* s, const char* name, size_t size) { + upb_value v; + if (!upb_strtable_lookup2(&s->syms, name, size, &v)) return NULL; + + switch (_upb_DefType_Type(v)) { + case UPB_DEFTYPE_FIELD: + return _upb_DefType_Unpack(v, UPB_DEFTYPE_FIELD); + case UPB_DEFTYPE_MSG: { + const upb_MessageDef* m = _upb_DefType_Unpack(v, UPB_DEFTYPE_MSG); + return _upb_MessageDef_InMessageSet(m) + ? upb_MessageDef_NestedExtension(m, 0) + : NULL; + } + default: + break; + } + + return NULL; +} + +const upb_FieldDef* upb_DefPool_FindExtensionByName(const upb_DefPool* s, + const char* sym) { + return upb_DefPool_FindExtensionByNameWithSize(s, sym, strlen(sym)); +} + +const upb_ServiceDef* upb_DefPool_FindServiceByName(const upb_DefPool* s, + const char* name) { + return _upb_DefPool_Unpack(s, name, strlen(name), UPB_DEFTYPE_SERVICE); +} + +const upb_ServiceDef* upb_DefPool_FindServiceByNameWithSize( + const upb_DefPool* s, const char* name, size_t size) { + return _upb_DefPool_Unpack(s, name, size, UPB_DEFTYPE_SERVICE); +} + +const upb_FileDef* upb_DefPool_FindFileContainingSymbol(const upb_DefPool* s, + const char* name) { + upb_value v; + // TODO: non-extension fields and oneofs. + if (upb_strtable_lookup(&s->syms, name, &v)) { + switch (_upb_DefType_Type(v)) { + case UPB_DEFTYPE_EXT: { + const upb_FieldDef* f = _upb_DefType_Unpack(v, UPB_DEFTYPE_EXT); + return upb_FieldDef_File(f); + } + case UPB_DEFTYPE_MSG: { + const upb_MessageDef* m = _upb_DefType_Unpack(v, UPB_DEFTYPE_MSG); + return upb_MessageDef_File(m); + } + case UPB_DEFTYPE_ENUM: { + const upb_EnumDef* e = _upb_DefType_Unpack(v, UPB_DEFTYPE_ENUM); + return upb_EnumDef_File(e); + } + case UPB_DEFTYPE_ENUMVAL: { + const upb_EnumValueDef* ev = + _upb_DefType_Unpack(v, UPB_DEFTYPE_ENUMVAL); + return upb_EnumDef_File(upb_EnumValueDef_Enum(ev)); + } + case UPB_DEFTYPE_SERVICE: { + const upb_ServiceDef* service = + _upb_DefType_Unpack(v, UPB_DEFTYPE_SERVICE); + return upb_ServiceDef_File(service); + } + default: + UPB_UNREACHABLE(); + } + } + + const char* last_dot = strrchr(name, '.'); + if (last_dot) { + const upb_MessageDef* parent = + upb_DefPool_FindMessageByNameWithSize(s, name, last_dot - name); + if (parent) { + const char* shortname = last_dot + 1; + if (upb_MessageDef_FindByNameWithSize(parent, shortname, + strlen(shortname), NULL, NULL)) { + return upb_MessageDef_File(parent); + } + } + } + + return NULL; +} + +static void remove_filedef(upb_DefPool* s, upb_FileDef* file) { + intptr_t iter = UPB_INTTABLE_BEGIN; + upb_StringView key; + upb_value val; + while (upb_strtable_next2(&s->syms, &key, &val, &iter)) { + const upb_FileDef* f; + switch (_upb_DefType_Type(val)) { + case UPB_DEFTYPE_EXT: + f = upb_FieldDef_File(_upb_DefType_Unpack(val, UPB_DEFTYPE_EXT)); + break; + case UPB_DEFTYPE_MSG: + f = upb_MessageDef_File(_upb_DefType_Unpack(val, UPB_DEFTYPE_MSG)); + break; + case UPB_DEFTYPE_ENUM: + f = upb_EnumDef_File(_upb_DefType_Unpack(val, UPB_DEFTYPE_ENUM)); + break; + case UPB_DEFTYPE_ENUMVAL: + f = upb_EnumDef_File(upb_EnumValueDef_Enum( + _upb_DefType_Unpack(val, UPB_DEFTYPE_ENUMVAL))); + break; + case UPB_DEFTYPE_SERVICE: + f = upb_ServiceDef_File(_upb_DefType_Unpack(val, UPB_DEFTYPE_SERVICE)); + break; + default: + UPB_UNREACHABLE(); + } + + if (f == file) upb_strtable_removeiter(&s->syms, &iter); + } +} + +static const upb_FileDef* upb_DefBuilder_AddFileToPool( + upb_DefBuilder* const builder, upb_DefPool* const s, + const UPB_DESC(FileDescriptorProto) * const file_proto, + const upb_StringView name, upb_Status* const status) { + if (UPB_SETJMP(builder->err) != 0) { + UPB_ASSERT(!upb_Status_IsOk(status)); + if (builder->file) { + remove_filedef(s, builder->file); + builder->file = NULL; + } + } else if (!builder->arena || !builder->tmp_arena || + !upb_strtable_init(&builder->feature_cache, 16, + builder->tmp_arena) || + !(builder->legacy_features = + UPB_DESC(FeatureSet_new)(builder->tmp_arena))) { + _upb_DefBuilder_OomErr(builder); + } else { + _upb_FileDef_Create(builder, file_proto); + upb_strtable_insert(&s->files, name.data, name.size, + upb_value_constptr(builder->file), builder->arena); + UPB_ASSERT(upb_Status_IsOk(status)); + upb_Arena_Fuse(s->arena, builder->arena); + } + + if (builder->arena) upb_Arena_Free(builder->arena); + if (builder->tmp_arena) upb_Arena_Free(builder->tmp_arena); + return builder->file; +} + +static const upb_FileDef* _upb_DefPool_AddFile( + upb_DefPool* s, const UPB_DESC(FileDescriptorProto) * file_proto, + const upb_MiniTableFile* layout, upb_Status* status) { + const upb_StringView name = UPB_DESC(FileDescriptorProto_name)(file_proto); + + // Determine whether we already know about this file. + { + upb_value v; + if (upb_strtable_lookup2(&s->files, name.data, name.size, &v)) { + upb_Status_SetErrorFormat(status, + "duplicate file name " UPB_STRINGVIEW_FORMAT, + UPB_STRINGVIEW_ARGS(name)); + return NULL; + } + } + + upb_DefBuilder ctx = { + .symtab = s, + .tmp_buf = NULL, + .tmp_buf_size = 0, + .layout = layout, + .platform = s->platform, + .msg_count = 0, + .enum_count = 0, + .ext_count = 0, + .status = status, + .file = NULL, + .arena = upb_Arena_New(), + .tmp_arena = upb_Arena_New(), + }; + + return upb_DefBuilder_AddFileToPool(&ctx, s, file_proto, name, status); +} + +const upb_FileDef* upb_DefPool_AddFile(upb_DefPool* s, + const UPB_DESC(FileDescriptorProto) * + file_proto, + upb_Status* status) { + return _upb_DefPool_AddFile(s, file_proto, NULL, status); +} + +bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init, + bool rebuild_minitable) { + /* Since this function should never fail (it would indicate a bug in upb) we + * print errors to stderr instead of returning error status to the user. */ + _upb_DefPool_Init** deps = init->deps; + UPB_DESC(FileDescriptorProto) * file; + upb_Arena* arena; + upb_Status status; + + upb_Status_Clear(&status); + + if (upb_DefPool_FindFileByName(s, init->filename)) { + return true; + } + + arena = upb_Arena_New(); + + for (; *deps; deps++) { + if (!_upb_DefPool_LoadDefInitEx(s, *deps, rebuild_minitable)) goto err; + } + + file = UPB_DESC(FileDescriptorProto_parse_ex)( + init->descriptor.data, init->descriptor.size, NULL, + kUpb_DecodeOption_AliasString, arena); + s->bytes_loaded += init->descriptor.size; + + if (!file) { + upb_Status_SetErrorFormat( + &status, + "Failed to parse compiled-in descriptor for file '%s'. This should " + "never happen.", + init->filename); + goto err; + } + + const upb_MiniTableFile* mt = rebuild_minitable ? NULL : init->layout; + if (!_upb_DefPool_AddFile(s, file, mt, &status)) { + goto err; + } + + upb_Arena_Free(arena); + return true; + +err: + fprintf(stderr, + "Error loading compiled-in descriptor for file '%s' (this should " + "never happen): %s\n", + init->filename, upb_Status_ErrorMessage(&status)); + upb_Arena_Free(arena); + return false; +} + +size_t _upb_DefPool_BytesLoaded(const upb_DefPool* s) { + return s->bytes_loaded; +} + +upb_Arena* _upb_DefPool_Arena(const upb_DefPool* s) { return s->arena; } + +const upb_FieldDef* upb_DefPool_FindExtensionByMiniTable( + const upb_DefPool* s, const upb_MiniTableExtension* ext) { + upb_value v; + bool ok = upb_inttable_lookup(&s->exts, (uintptr_t)ext, &v); + UPB_ASSERT(ok); + return upb_value_getconstptr(v); +} + +const upb_FieldDef* upb_DefPool_FindExtensionByNumber(const upb_DefPool* s, + const upb_MessageDef* m, + int32_t fieldnum) { + const upb_MiniTable* t = upb_MessageDef_MiniTable(m); + const upb_MiniTableExtension* ext = + upb_ExtensionRegistry_Lookup(s->extreg, t, fieldnum); + return ext ? upb_DefPool_FindExtensionByMiniTable(s, ext) : NULL; +} + +const upb_ExtensionRegistry* upb_DefPool_ExtensionRegistry( + const upb_DefPool* s) { + return s->extreg; +} + +const upb_FieldDef** upb_DefPool_GetAllExtensions(const upb_DefPool* s, + const upb_MessageDef* m, + size_t* count) { + size_t n = 0; + intptr_t iter = UPB_INTTABLE_BEGIN; + uintptr_t key; + upb_value val; + // This is O(all exts) instead of O(exts for m). If we need this to be + // efficient we may need to make extreg into a two-level table, or have a + // second per-message index. + while (upb_inttable_next(&s->exts, &key, &val, &iter)) { + const upb_FieldDef* f = upb_value_getconstptr(val); + if (upb_FieldDef_ContainingType(f) == m) n++; + } + const upb_FieldDef** exts = upb_gmalloc(n * sizeof(*exts)); + iter = UPB_INTTABLE_BEGIN; + size_t i = 0; + while (upb_inttable_next(&s->exts, &key, &val, &iter)) { + const upb_FieldDef* f = upb_value_getconstptr(val); + if (upb_FieldDef_ContainingType(f) == m) exts[i++] = f; + } + *count = n; + return exts; +} + +bool _upb_DefPool_LoadDefInit(upb_DefPool* s, const _upb_DefPool_Init* init) { + return _upb_DefPool_LoadDefInitEx(s, init, false); +} + + +// Must be last. + +upb_deftype_t _upb_DefType_Type(upb_value v) { + const uintptr_t num = (uintptr_t)upb_value_getconstptr(v); + return num & UPB_DEFTYPE_MASK; +} + +upb_value _upb_DefType_Pack(const void* ptr, upb_deftype_t type) { + uintptr_t num = (uintptr_t)ptr; + UPB_ASSERT((num & UPB_DEFTYPE_MASK) == 0); + num |= type; + return upb_value_constptr((const void*)num); +} + +const void* _upb_DefType_Unpack(upb_value v, upb_deftype_t type) { + uintptr_t num = (uintptr_t)upb_value_getconstptr(v); + return (num & UPB_DEFTYPE_MASK) == type + ? (const void*)(num & ~UPB_DEFTYPE_MASK) + : NULL; +} + + +// Must be last. + +bool _upb_DescState_Grow(upb_DescState* d, upb_Arena* a) { + const size_t oldbufsize = d->bufsize; + const int used = d->ptr - d->buf; + + if (!d->buf) { + d->buf = upb_Arena_Malloc(a, d->bufsize); + if (!d->buf) return false; + d->ptr = d->buf; + d->e.end = d->buf + d->bufsize; + } + + if (oldbufsize - used < kUpb_MtDataEncoder_MinSize) { + d->bufsize *= 2; + d->buf = upb_Arena_Realloc(a, d->buf, oldbufsize, d->bufsize); + if (!d->buf) return false; + d->ptr = d->buf + used; + d->e.end = d->buf + d->bufsize; + } + + return true; +} + + +#include +#include +#include + + +// Must be last. + +struct upb_EnumDef { + const UPB_DESC(EnumOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + const upb_MiniTableEnum* layout; // Only for proto2. + const upb_FileDef* file; + const upb_MessageDef* containing_type; // Could be merged with "file". + const char* full_name; + upb_strtable ntoi; + upb_inttable iton; + const upb_EnumValueDef* values; + const upb_EnumReservedRange* res_ranges; + const upb_StringView* res_names; + int value_count; + int res_range_count; + int res_name_count; + int32_t defaultval; + bool is_sorted; // Whether all of the values are defined in ascending order. +#if UINTPTR_MAX == 0xffffffff + uint32_t padding; // Increase size to a multiple of 8. +#endif +}; + +upb_EnumDef* _upb_EnumDef_At(const upb_EnumDef* e, int i) { + return (upb_EnumDef*)&e[i]; +} + +const upb_MiniTableEnum* _upb_EnumDef_MiniTable(const upb_EnumDef* e) { + return e->layout; +} + +bool _upb_EnumDef_Insert(upb_EnumDef* e, upb_EnumValueDef* v, upb_Arena* a) { + const char* name = upb_EnumValueDef_Name(v); + const upb_value val = upb_value_constptr(v); + bool ok = upb_strtable_insert(&e->ntoi, name, strlen(name), val, a); + if (!ok) return false; + + // Multiple enumerators can have the same number, first one wins. + const int number = upb_EnumValueDef_Number(v); + if (!upb_inttable_lookup(&e->iton, number, NULL)) { + return upb_inttable_insert(&e->iton, number, val, a); + } + return true; +} + +const UPB_DESC(EnumOptions) * upb_EnumDef_Options(const upb_EnumDef* e) { + return e->opts; +} + +bool upb_EnumDef_HasOptions(const upb_EnumDef* e) { + return e->opts != (void*)kUpbDefOptDefault; +} + +const UPB_DESC(FeatureSet) * + upb_EnumDef_ResolvedFeatures(const upb_EnumDef* e) { + return e->resolved_features; +} + +const char* upb_EnumDef_FullName(const upb_EnumDef* e) { return e->full_name; } + +const char* upb_EnumDef_Name(const upb_EnumDef* e) { + return _upb_DefBuilder_FullToShort(e->full_name); +} + +const upb_FileDef* upb_EnumDef_File(const upb_EnumDef* e) { return e->file; } + +const upb_MessageDef* upb_EnumDef_ContainingType(const upb_EnumDef* e) { + return e->containing_type; +} + +int32_t upb_EnumDef_Default(const upb_EnumDef* e) { + UPB_ASSERT(upb_EnumDef_FindValueByNumber(e, e->defaultval)); + return e->defaultval; +} + +int upb_EnumDef_ReservedRangeCount(const upb_EnumDef* e) { + return e->res_range_count; +} + +const upb_EnumReservedRange* upb_EnumDef_ReservedRange(const upb_EnumDef* e, + int i) { + UPB_ASSERT(0 <= i && i < e->res_range_count); + return _upb_EnumReservedRange_At(e->res_ranges, i); +} + +int upb_EnumDef_ReservedNameCount(const upb_EnumDef* e) { + return e->res_name_count; +} + +upb_StringView upb_EnumDef_ReservedName(const upb_EnumDef* e, int i) { + UPB_ASSERT(0 <= i && i < e->res_name_count); + return e->res_names[i]; +} + +int upb_EnumDef_ValueCount(const upb_EnumDef* e) { return e->value_count; } + +const upb_EnumValueDef* upb_EnumDef_FindValueByName(const upb_EnumDef* e, + const char* name) { + return upb_EnumDef_FindValueByNameWithSize(e, name, strlen(name)); +} + +const upb_EnumValueDef* upb_EnumDef_FindValueByNameWithSize( + const upb_EnumDef* e, const char* name, size_t size) { + upb_value v; + return upb_strtable_lookup2(&e->ntoi, name, size, &v) + ? upb_value_getconstptr(v) + : NULL; +} + +const upb_EnumValueDef* upb_EnumDef_FindValueByNumber(const upb_EnumDef* e, + int32_t num) { + upb_value v; + return upb_inttable_lookup(&e->iton, num, &v) ? upb_value_getconstptr(v) + : NULL; +} + +bool upb_EnumDef_CheckNumber(const upb_EnumDef* e, int32_t num) { + // We could use upb_EnumDef_FindValueByNumber(e, num) != NULL, but we expect + // this to be faster (especially for small numbers). + return upb_MiniTableEnum_CheckValue(e->layout, num); +} + +const upb_EnumValueDef* upb_EnumDef_Value(const upb_EnumDef* e, int i) { + UPB_ASSERT(0 <= i && i < e->value_count); + return _upb_EnumValueDef_At(e->values, i); +} + +bool upb_EnumDef_IsClosed(const upb_EnumDef* e) { + if (UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN) return false; + return upb_EnumDef_IsSpecifiedAsClosed(e); +} + +bool upb_EnumDef_IsSpecifiedAsClosed(const upb_EnumDef* e) { + return UPB_DESC(FeatureSet_enum_type)(e->resolved_features) == + UPB_DESC(FeatureSet_CLOSED); +} + +bool upb_EnumDef_MiniDescriptorEncode(const upb_EnumDef* e, upb_Arena* a, + upb_StringView* out) { + upb_DescState s; + _upb_DescState_Init(&s); + + const upb_EnumValueDef** sorted = NULL; + if (!e->is_sorted) { + sorted = _upb_EnumValueDefs_Sorted(e->values, e->value_count, a); + if (!sorted) return false; + } + + if (!_upb_DescState_Grow(&s, a)) return false; + s.ptr = upb_MtDataEncoder_StartEnum(&s.e, s.ptr); + + // Duplicate values are allowed but we only encode each value once. + uint32_t previous = 0; + + for (int i = 0; i < e->value_count; i++) { + const uint32_t current = + upb_EnumValueDef_Number(sorted ? sorted[i] : upb_EnumDef_Value(e, i)); + if (i != 0 && previous == current) continue; + + if (!_upb_DescState_Grow(&s, a)) return false; + s.ptr = upb_MtDataEncoder_PutEnumValue(&s.e, s.ptr, current); + previous = current; + } + + if (!_upb_DescState_Grow(&s, a)) return false; + s.ptr = upb_MtDataEncoder_EndEnum(&s.e, s.ptr); + + // There will always be room for this '\0' in the encoder buffer because + // kUpb_MtDataEncoder_MinSize is overkill for upb_MtDataEncoder_EndEnum(). + UPB_ASSERT(s.ptr < s.buf + s.bufsize); + *s.ptr = '\0'; + + out->data = s.buf; + out->size = s.ptr - s.buf; + return true; +} + +static upb_MiniTableEnum* create_enumlayout(upb_DefBuilder* ctx, + const upb_EnumDef* e) { + upb_StringView sv; + bool ok = upb_EnumDef_MiniDescriptorEncode(e, ctx->tmp_arena, &sv); + if (!ok) _upb_DefBuilder_Errf(ctx, "OOM while building enum MiniDescriptor"); + + upb_Status status; + upb_MiniTableEnum* layout = + upb_MiniTableEnum_Build(sv.data, sv.size, ctx->arena, &status); + if (!layout) + _upb_DefBuilder_Errf(ctx, "Error building enum MiniTable: %s", status.msg); + return layout; +} + +static upb_StringView* _upb_EnumReservedNames_New( + upb_DefBuilder* ctx, int n, const upb_StringView* protos) { + upb_StringView* sv = _upb_DefBuilder_Alloc(ctx, sizeof(upb_StringView) * n); + for (int i = 0; i < n; i++) { + sv[i].data = + upb_strdup2(protos[i].data, protos[i].size, _upb_DefBuilder_Arena(ctx)); + sv[i].size = protos[i].size; + } + return sv; +} + +static void create_enumdef(upb_DefBuilder* ctx, const char* prefix, + const UPB_DESC(EnumDescriptorProto) * enum_proto, + const UPB_DESC(FeatureSet*) parent_features, + upb_EnumDef* e) { + const UPB_DESC(EnumValueDescriptorProto)* const* values; + const UPB_DESC(EnumDescriptorProto_EnumReservedRange)* const* res_ranges; + const upb_StringView* res_names; + upb_StringView name; + size_t n_value, n_res_range, n_res_name; + + UPB_DEF_SET_OPTIONS(e->opts, EnumDescriptorProto, EnumOptions, enum_proto); + e->resolved_features = _upb_DefBuilder_ResolveFeatures( + ctx, parent_features, UPB_DESC(EnumOptions_features)(e->opts)); + + // Must happen before _upb_DefBuilder_Add() + e->file = _upb_DefBuilder_File(ctx); + + name = UPB_DESC(EnumDescriptorProto_name)(enum_proto); + + e->full_name = _upb_DefBuilder_MakeFullName(ctx, prefix, name); + _upb_DefBuilder_Add(ctx, e->full_name, + _upb_DefType_Pack(e, UPB_DEFTYPE_ENUM)); + + values = UPB_DESC(EnumDescriptorProto_value)(enum_proto, &n_value); + + bool ok = upb_strtable_init(&e->ntoi, n_value, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + ok = upb_inttable_init(&e->iton, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + e->defaultval = 0; + e->value_count = n_value; + e->values = _upb_EnumValueDefs_New(ctx, prefix, n_value, values, + e->resolved_features, e, &e->is_sorted); + + if (n_value == 0) { + _upb_DefBuilder_Errf(ctx, "enums must contain at least one value (%s)", + e->full_name); + } + + res_ranges = + UPB_DESC(EnumDescriptorProto_reserved_range)(enum_proto, &n_res_range); + e->res_range_count = n_res_range; + e->res_ranges = _upb_EnumReservedRanges_New(ctx, n_res_range, res_ranges, e); + + res_names = + UPB_DESC(EnumDescriptorProto_reserved_name)(enum_proto, &n_res_name); + e->res_name_count = n_res_name; + e->res_names = _upb_EnumReservedNames_New(ctx, n_res_name, res_names); + + upb_inttable_compact(&e->iton, ctx->arena); + + if (upb_EnumDef_IsClosed(e)) { + if (ctx->layout) { + e->layout = upb_MiniTableFile_Enum(ctx->layout, ctx->enum_count++); + } else { + e->layout = create_enumlayout(ctx, e); + } + } else { + e->layout = NULL; + } +} + +upb_EnumDef* _upb_EnumDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(EnumDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + const upb_MessageDef* containing_type) { + _upb_DefType_CheckPadding(sizeof(upb_EnumDef)); + + // If a containing type is defined then get the full name from that. + // Otherwise use the package name from the file def. + const char* name = containing_type ? upb_MessageDef_FullName(containing_type) + : _upb_FileDef_RawPackage(ctx->file); + + upb_EnumDef* e = _upb_DefBuilder_Alloc(ctx, sizeof(upb_EnumDef) * n); + for (int i = 0; i < n; i++) { + create_enumdef(ctx, name, protos[i], parent_features, &e[i]); + e[i].containing_type = containing_type; + } + return e; +} + + + +// Must be last. + +struct upb_EnumReservedRange { + int32_t start; + int32_t end; +}; + +upb_EnumReservedRange* _upb_EnumReservedRange_At(const upb_EnumReservedRange* r, + int i) { + return (upb_EnumReservedRange*)&r[i]; +} + +int32_t upb_EnumReservedRange_Start(const upb_EnumReservedRange* r) { + return r->start; +} +int32_t upb_EnumReservedRange_End(const upb_EnumReservedRange* r) { + return r->end; +} + +upb_EnumReservedRange* _upb_EnumReservedRanges_New( + upb_DefBuilder* ctx, int n, + const UPB_DESC(EnumDescriptorProto_EnumReservedRange) * const* protos, + const upb_EnumDef* e) { + upb_EnumReservedRange* r = + _upb_DefBuilder_Alloc(ctx, sizeof(upb_EnumReservedRange) * n); + + for (int i = 0; i < n; i++) { + const int32_t start = + UPB_DESC(EnumDescriptorProto_EnumReservedRange_start)(protos[i]); + const int32_t end = + UPB_DESC(EnumDescriptorProto_EnumReservedRange_end)(protos[i]); + + // A full validation would also check that each range is disjoint, and that + // none of the fields overlap with the extension ranges, but we are just + // sanity checking here. + + // Note: Not a typo! Unlike extension ranges and message reserved ranges, + // the end value of an enum reserved range is *inclusive*! + if (end < start) { + _upb_DefBuilder_Errf(ctx, "Reserved range (%d, %d) is invalid, enum=%s\n", + (int)start, (int)end, upb_EnumDef_FullName(e)); + } + + r[i].start = start; + r[i].end = end; + } + + return r; +} + + +#include + + +// Must be last. + +struct upb_EnumValueDef { + const UPB_DESC(EnumValueOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + const upb_EnumDef* parent; + const char* full_name; + int32_t number; +#if UINTPTR_MAX == 0xffffffff + uint32_t padding; // Increase size to a multiple of 8. +#endif +}; + +upb_EnumValueDef* _upb_EnumValueDef_At(const upb_EnumValueDef* v, int i) { + return (upb_EnumValueDef*)&v[i]; +} + +static int _upb_EnumValueDef_Compare(const void* p1, const void* p2) { + const uint32_t v1 = (*(const upb_EnumValueDef**)p1)->number; + const uint32_t v2 = (*(const upb_EnumValueDef**)p2)->number; + return (v1 < v2) ? -1 : (v1 > v2); +} + +const upb_EnumValueDef** _upb_EnumValueDefs_Sorted(const upb_EnumValueDef* v, + int n, upb_Arena* a) { + // TODO: Try to replace this arena alloc with a persistent scratch buffer. + upb_EnumValueDef** out = + (upb_EnumValueDef**)upb_Arena_Malloc(a, n * sizeof(void*)); + if (!out) return NULL; + + for (int i = 0; i < n; i++) { + out[i] = (upb_EnumValueDef*)&v[i]; + } + qsort(out, n, sizeof(void*), _upb_EnumValueDef_Compare); + + return (const upb_EnumValueDef**)out; +} + +const UPB_DESC(EnumValueOptions) * + upb_EnumValueDef_Options(const upb_EnumValueDef* v) { + return v->opts; +} + +bool upb_EnumValueDef_HasOptions(const upb_EnumValueDef* v) { + return v->opts != (void*)kUpbDefOptDefault; +} + +const UPB_DESC(FeatureSet) * + upb_EnumValueDef_ResolvedFeatures(const upb_EnumValueDef* e) { + return e->resolved_features; +} + +const upb_EnumDef* upb_EnumValueDef_Enum(const upb_EnumValueDef* v) { + return v->parent; +} + +const char* upb_EnumValueDef_FullName(const upb_EnumValueDef* v) { + return v->full_name; +} + +const char* upb_EnumValueDef_Name(const upb_EnumValueDef* v) { + return _upb_DefBuilder_FullToShort(v->full_name); +} + +int32_t upb_EnumValueDef_Number(const upb_EnumValueDef* v) { return v->number; } + +uint32_t upb_EnumValueDef_Index(const upb_EnumValueDef* v) { + // Compute index in our parent's array. + return v - upb_EnumDef_Value(v->parent, 0); +} + +static void create_enumvaldef(upb_DefBuilder* ctx, const char* prefix, + const UPB_DESC(EnumValueDescriptorProto*) + val_proto, + const UPB_DESC(FeatureSet*) parent_features, + upb_EnumDef* e, upb_EnumValueDef* v) { + UPB_DEF_SET_OPTIONS(v->opts, EnumValueDescriptorProto, EnumValueOptions, + val_proto); + v->resolved_features = _upb_DefBuilder_ResolveFeatures( + ctx, parent_features, UPB_DESC(EnumValueOptions_features)(v->opts)); + + upb_StringView name = UPB_DESC(EnumValueDescriptorProto_name)(val_proto); + + v->parent = e; // Must happen prior to _upb_DefBuilder_Add() + v->full_name = _upb_DefBuilder_MakeFullName(ctx, prefix, name); + v->number = UPB_DESC(EnumValueDescriptorProto_number)(val_proto); + _upb_DefBuilder_Add(ctx, v->full_name, + _upb_DefType_Pack(v, UPB_DEFTYPE_ENUMVAL)); + + bool ok = _upb_EnumDef_Insert(e, v, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); +} + +static void _upb_EnumValueDef_CheckZeroValue(upb_DefBuilder* ctx, + const upb_EnumDef* e, + const upb_EnumValueDef* v, int n) { + // When the special UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN is enabled, we have to + // exempt closed enums from this check, even when we are treating them as + // open. + if (upb_EnumDef_IsSpecifiedAsClosed(e) || n == 0 || v[0].number == 0) return; + + _upb_DefBuilder_Errf(ctx, "for open enums, the first value must be zero (%s)", + upb_EnumDef_FullName(e)); +} + +// Allocate and initialize an array of |n| enum value defs owned by |e|. +upb_EnumValueDef* _upb_EnumValueDefs_New( + upb_DefBuilder* ctx, const char* prefix, int n, + const UPB_DESC(EnumValueDescriptorProto*) const* protos, + const UPB_DESC(FeatureSet*) parent_features, upb_EnumDef* e, + bool* is_sorted) { + _upb_DefType_CheckPadding(sizeof(upb_EnumValueDef)); + + upb_EnumValueDef* v = + _upb_DefBuilder_Alloc(ctx, sizeof(upb_EnumValueDef) * n); + + *is_sorted = true; + uint32_t previous = 0; + for (int i = 0; i < n; i++) { + create_enumvaldef(ctx, prefix, protos[i], parent_features, e, &v[i]); + + const uint32_t current = v[i].number; + if (previous > current) *is_sorted = false; + previous = current; + } + + _upb_EnumValueDef_CheckZeroValue(ctx, e, v, n); + + return v; +} + + +#include + + +// Must be last. + +struct upb_ExtensionRange { + const UPB_DESC(ExtensionRangeOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + int32_t start; + int32_t end; +}; + +upb_ExtensionRange* _upb_ExtensionRange_At(const upb_ExtensionRange* r, int i) { + return (upb_ExtensionRange*)&r[i]; +} + +const UPB_DESC(ExtensionRangeOptions) * + upb_ExtensionRange_Options(const upb_ExtensionRange* r) { + return r->opts; +} + +bool upb_ExtensionRange_HasOptions(const upb_ExtensionRange* r) { + return r->opts != (void*)kUpbDefOptDefault; +} + +int32_t upb_ExtensionRange_Start(const upb_ExtensionRange* r) { + return r->start; +} + +int32_t upb_ExtensionRange_End(const upb_ExtensionRange* r) { return r->end; } + +upb_ExtensionRange* _upb_ExtensionRanges_New( + upb_DefBuilder* ctx, int n, + const UPB_DESC(DescriptorProto_ExtensionRange*) const* protos, + const UPB_DESC(FeatureSet*) parent_features, const upb_MessageDef* m) { + upb_ExtensionRange* r = + _upb_DefBuilder_Alloc(ctx, sizeof(upb_ExtensionRange) * n); + + for (int i = 0; i < n; i++) { + UPB_DEF_SET_OPTIONS(r[i].opts, DescriptorProto_ExtensionRange, + ExtensionRangeOptions, protos[i]); + r[i].resolved_features = _upb_DefBuilder_ResolveFeatures( + ctx, parent_features, + UPB_DESC(ExtensionRangeOptions_features)(r[i].opts)); + + const int32_t start = + UPB_DESC(DescriptorProto_ExtensionRange_start)(protos[i]); + const int32_t end = UPB_DESC(DescriptorProto_ExtensionRange_end)(protos[i]); + const int32_t max = UPB_DESC(MessageOptions_message_set_wire_format)( + upb_MessageDef_Options(m)) + ? INT32_MAX + : kUpb_MaxFieldNumber + 1; + + // A full validation would also check that each range is disjoint, and that + // none of the fields overlap with the extension ranges, but we are just + // sanity checking here. + if (start < 1 || end <= start || end > max) { + _upb_DefBuilder_Errf(ctx, + "Extension range (%d, %d) is invalid, message=%s\n", + (int)start, (int)end, upb_MessageDef_FullName(m)); + } + + r[i].start = start; + r[i].end = end; + } + + return r; +} + + +#include +#include +#include +#include +#include +#include + + +// Must be last. + +#define UPB_FIELD_TYPE_UNSPECIFIED 0 + +typedef struct { + size_t len; + char str[1]; // Null-terminated string data follows. +} str_t; + +struct upb_FieldDef { + const UPB_DESC(FieldOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + const upb_FileDef* file; + const upb_MessageDef* msgdef; + const char* full_name; + const char* json_name; + union { + int64_t sint; + uint64_t uint; + double dbl; + float flt; + bool boolean; + str_t* str; + void* msg; // Always NULL. + } defaultval; + union { + const upb_OneofDef* oneof; + const upb_MessageDef* extension_scope; + } scope; + union { + const upb_MessageDef* msgdef; + const upb_EnumDef* enumdef; + const UPB_DESC(FieldDescriptorProto) * unresolved; + } sub; + uint32_t number_; + uint16_t index_; + uint16_t layout_index; // Index into msgdef->layout->fields or file->exts + bool has_default; + bool has_json_name; + bool has_presence; + bool is_extension; + bool is_proto3_optional; + upb_FieldType type_; + upb_Label label_; +}; + +upb_FieldDef* _upb_FieldDef_At(const upb_FieldDef* f, int i) { + return (upb_FieldDef*)&f[i]; +} + +const UPB_DESC(FieldOptions) * upb_FieldDef_Options(const upb_FieldDef* f) { + return f->opts; +} + +bool upb_FieldDef_HasOptions(const upb_FieldDef* f) { + return f->opts != (void*)kUpbDefOptDefault; +} + +const UPB_DESC(FeatureSet) * + upb_FieldDef_ResolvedFeatures(const upb_FieldDef* f) { + return f->resolved_features; +} + +const char* upb_FieldDef_FullName(const upb_FieldDef* f) { + return f->full_name; +} + +upb_CType upb_FieldDef_CType(const upb_FieldDef* f) { + return upb_FieldType_CType(f->type_); +} + +upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f) { return f->type_; } + +uint32_t upb_FieldDef_Index(const upb_FieldDef* f) { return f->index_; } + +uint32_t upb_FieldDef_LayoutIndex(const upb_FieldDef* f) { + return f->layout_index; +} + +upb_Label upb_FieldDef_Label(const upb_FieldDef* f) { return f->label_; } + +uint32_t upb_FieldDef_Number(const upb_FieldDef* f) { return f->number_; } + +bool upb_FieldDef_IsExtension(const upb_FieldDef* f) { return f->is_extension; } + +bool _upb_FieldDef_IsPackable(const upb_FieldDef* f) { + return upb_FieldDef_IsRepeated(f) && upb_FieldDef_IsPrimitive(f); +} + +bool upb_FieldDef_IsPacked(const upb_FieldDef* f) { + return _upb_FieldDef_IsPackable(f) && + UPB_DESC(FeatureSet_repeated_field_encoding(f->resolved_features)) == + UPB_DESC(FeatureSet_PACKED); +} + +const char* upb_FieldDef_Name(const upb_FieldDef* f) { + return _upb_DefBuilder_FullToShort(f->full_name); +} + +const char* upb_FieldDef_JsonName(const upb_FieldDef* f) { + return f->json_name; +} + +bool upb_FieldDef_HasJsonName(const upb_FieldDef* f) { + return f->has_json_name; +} + +const upb_FileDef* upb_FieldDef_File(const upb_FieldDef* f) { return f->file; } + +const upb_MessageDef* upb_FieldDef_ContainingType(const upb_FieldDef* f) { + return f->msgdef; +} + +const upb_MessageDef* upb_FieldDef_ExtensionScope(const upb_FieldDef* f) { + return f->is_extension ? f->scope.extension_scope : NULL; +} + +const upb_OneofDef* upb_FieldDef_ContainingOneof(const upb_FieldDef* f) { + return f->is_extension ? NULL : f->scope.oneof; +} + +const upb_OneofDef* upb_FieldDef_RealContainingOneof(const upb_FieldDef* f) { + const upb_OneofDef* oneof = upb_FieldDef_ContainingOneof(f); + if (!oneof || upb_OneofDef_IsSynthetic(oneof)) return NULL; + return oneof; +} + +upb_MessageValue upb_FieldDef_Default(const upb_FieldDef* f) { + upb_MessageValue ret; + + if (upb_FieldDef_IsRepeated(f) || upb_FieldDef_IsSubMessage(f)) { + return (upb_MessageValue){.msg_val = NULL}; + } + + switch (upb_FieldDef_CType(f)) { + case kUpb_CType_Bool: + return (upb_MessageValue){.bool_val = f->defaultval.boolean}; + case kUpb_CType_Int64: + return (upb_MessageValue){.int64_val = f->defaultval.sint}; + case kUpb_CType_UInt64: + return (upb_MessageValue){.uint64_val = f->defaultval.uint}; + case kUpb_CType_Enum: + case kUpb_CType_Int32: + return (upb_MessageValue){.int32_val = (int32_t)f->defaultval.sint}; + case kUpb_CType_UInt32: + return (upb_MessageValue){.uint32_val = (uint32_t)f->defaultval.uint}; + case kUpb_CType_Float: + return (upb_MessageValue){.float_val = f->defaultval.flt}; + case kUpb_CType_Double: + return (upb_MessageValue){.double_val = f->defaultval.dbl}; + case kUpb_CType_String: + case kUpb_CType_Bytes: { + str_t* str = f->defaultval.str; + if (str) { + return (upb_MessageValue){ + .str_val = (upb_StringView){.data = str->str, .size = str->len}}; + } else { + return (upb_MessageValue){ + .str_val = (upb_StringView){.data = NULL, .size = 0}}; + } + } + default: + UPB_UNREACHABLE(); + } + + return ret; +} + +const upb_MessageDef* upb_FieldDef_MessageSubDef(const upb_FieldDef* f) { + return upb_FieldDef_CType(f) == kUpb_CType_Message ? f->sub.msgdef : NULL; +} + +const upb_EnumDef* upb_FieldDef_EnumSubDef(const upb_FieldDef* f) { + return upb_FieldDef_CType(f) == kUpb_CType_Enum ? f->sub.enumdef : NULL; +} + +const upb_MiniTableField* upb_FieldDef_MiniTable(const upb_FieldDef* f) { + if (upb_FieldDef_IsExtension(f)) { + const upb_FileDef* file = upb_FieldDef_File(f); + return (upb_MiniTableField*)_upb_FileDef_ExtensionMiniTable( + file, f->layout_index); + } else { + const upb_MiniTable* layout = upb_MessageDef_MiniTable(f->msgdef); + return &layout->UPB_PRIVATE(fields)[f->layout_index]; + } +} + +const upb_MiniTableExtension* upb_FieldDef_MiniTableExtension( + const upb_FieldDef* f) { + UPB_ASSERT(upb_FieldDef_IsExtension(f)); + const upb_FileDef* file = upb_FieldDef_File(f); + return _upb_FileDef_ExtensionMiniTable(file, f->layout_index); +} + +bool _upb_FieldDef_IsClosedEnum(const upb_FieldDef* f) { + if (f->type_ != kUpb_FieldType_Enum) return false; + return upb_EnumDef_IsClosed(f->sub.enumdef); +} + +bool _upb_FieldDef_IsProto3Optional(const upb_FieldDef* f) { + return f->is_proto3_optional; +} + +int _upb_FieldDef_LayoutIndex(const upb_FieldDef* f) { return f->layout_index; } + +bool _upb_FieldDef_ValidateUtf8(const upb_FieldDef* f) { + if (upb_FieldDef_Type(f) != kUpb_FieldType_String) return false; + return UPB_DESC(FeatureSet_utf8_validation(f->resolved_features)) == + UPB_DESC(FeatureSet_VERIFY); +} + +bool _upb_FieldDef_IsGroupLike(const upb_FieldDef* f) { + // Groups are always tag-delimited. + if (f->type_ != kUpb_FieldType_Group) { + return false; + } + + const upb_MessageDef* msg = upb_FieldDef_MessageSubDef(f); + + // Group fields always are always the lowercase type name. + const char* mname = upb_MessageDef_Name(msg); + const char* fname = upb_FieldDef_Name(f); + size_t name_size = strlen(fname); + if (name_size != strlen(mname)) return false; + for (size_t i = 0; i < name_size; ++i) { + if ((mname[i] | 0x20) != fname[i]) { + // Case-insensitive ascii comparison. + return false; + } + } + + if (upb_MessageDef_File(msg) != upb_FieldDef_File(f)) { + return false; + } + + // Group messages are always defined in the same scope as the field. File + // level extensions will compare NULL == NULL here, which is why the file + // comparison above is necessary to ensure both come from the same file. + return upb_FieldDef_IsExtension(f) ? upb_FieldDef_ExtensionScope(f) == + upb_MessageDef_ContainingType(msg) + : upb_FieldDef_ContainingType(f) == + upb_MessageDef_ContainingType(msg); +} + +uint64_t _upb_FieldDef_Modifiers(const upb_FieldDef* f) { + uint64_t out = upb_FieldDef_IsPacked(f) ? kUpb_FieldModifier_IsPacked : 0; + + if (upb_FieldDef_IsRepeated(f)) { + out |= kUpb_FieldModifier_IsRepeated; + } else if (upb_FieldDef_IsRequired(f)) { + out |= kUpb_FieldModifier_IsRequired; + } else if (!upb_FieldDef_HasPresence(f)) { + out |= kUpb_FieldModifier_IsProto3Singular; + } + + if (_upb_FieldDef_IsClosedEnum(f)) { + out |= kUpb_FieldModifier_IsClosedEnum; + } + + if (_upb_FieldDef_ValidateUtf8(f)) { + out |= kUpb_FieldModifier_ValidateUtf8; + } + + return out; +} + +bool upb_FieldDef_HasDefault(const upb_FieldDef* f) { return f->has_default; } +bool upb_FieldDef_HasPresence(const upb_FieldDef* f) { return f->has_presence; } + +bool upb_FieldDef_HasSubDef(const upb_FieldDef* f) { + return upb_FieldDef_IsSubMessage(f) || + upb_FieldDef_CType(f) == kUpb_CType_Enum; +} + +bool upb_FieldDef_IsMap(const upb_FieldDef* f) { + return upb_FieldDef_IsRepeated(f) && upb_FieldDef_IsSubMessage(f) && + upb_MessageDef_IsMapEntry(upb_FieldDef_MessageSubDef(f)); +} + +bool upb_FieldDef_IsOptional(const upb_FieldDef* f) { + return upb_FieldDef_Label(f) == kUpb_Label_Optional; +} + +bool upb_FieldDef_IsPrimitive(const upb_FieldDef* f) { + return !upb_FieldDef_IsString(f) && !upb_FieldDef_IsSubMessage(f); +} + +bool upb_FieldDef_IsRepeated(const upb_FieldDef* f) { + return upb_FieldDef_Label(f) == kUpb_Label_Repeated; +} + +bool upb_FieldDef_IsRequired(const upb_FieldDef* f) { + return UPB_DESC(FeatureSet_field_presence)(f->resolved_features) == + UPB_DESC(FeatureSet_LEGACY_REQUIRED); +} + +bool upb_FieldDef_IsString(const upb_FieldDef* f) { + return upb_FieldDef_CType(f) == kUpb_CType_String || + upb_FieldDef_CType(f) == kUpb_CType_Bytes; +} + +bool upb_FieldDef_IsSubMessage(const upb_FieldDef* f) { + return upb_FieldDef_CType(f) == kUpb_CType_Message; +} + +static bool between(int32_t x, int32_t low, int32_t high) { + return x >= low && x <= high; +} + +bool upb_FieldDef_checklabel(int32_t label) { return between(label, 1, 3); } +bool upb_FieldDef_checktype(int32_t type) { return between(type, 1, 11); } +bool upb_FieldDef_checkintfmt(int32_t fmt) { return between(fmt, 1, 3); } + +bool upb_FieldDef_checkdescriptortype(int32_t type) { + return between(type, 1, 18); +} + +static bool streql2(const char* a, size_t n, const char* b) { + return n == strlen(b) && memcmp(a, b, n) == 0; +} + +// Implement the transformation as described in the spec: +// 1. upper case all letters after an underscore. +// 2. remove all underscores. +static char* make_json_name(const char* name, size_t size, upb_Arena* a) { + char* out = upb_Arena_Malloc(a, size + 1); // +1 is to add a trailing '\0' + if (out == NULL) return NULL; + + bool ucase_next = false; + char* des = out; + for (size_t i = 0; i < size; i++) { + if (name[i] == '_') { + ucase_next = true; + } else { + *des++ = ucase_next ? toupper(name[i]) : name[i]; + ucase_next = false; + } + } + *des++ = '\0'; + return out; +} + +static str_t* newstr(upb_DefBuilder* ctx, const char* data, size_t len) { + str_t* ret = _upb_DefBuilder_Alloc(ctx, sizeof(*ret) + len); + if (!ret) _upb_DefBuilder_OomErr(ctx); + ret->len = len; + if (len) memcpy(ret->str, data, len); + ret->str[len] = '\0'; + return ret; +} + +static str_t* unescape(upb_DefBuilder* ctx, const upb_FieldDef* f, + const char* data, size_t len) { + // Size here is an upper bound; escape sequences could ultimately shrink it. + str_t* ret = _upb_DefBuilder_Alloc(ctx, sizeof(*ret) + len); + char* dst = &ret->str[0]; + const char* src = data; + const char* end = data + len; + + while (src < end) { + if (*src == '\\') { + src++; + *dst++ = _upb_DefBuilder_ParseEscape(ctx, f, &src, end); + } else { + *dst++ = *src++; + } + } + + ret->len = dst - &ret->str[0]; + return ret; +} + +static void parse_default(upb_DefBuilder* ctx, const char* str, size_t len, + upb_FieldDef* f) { + char* end; + char nullz[64]; + errno = 0; + + switch (upb_FieldDef_CType(f)) { + case kUpb_CType_Int32: + case kUpb_CType_Int64: + case kUpb_CType_UInt32: + case kUpb_CType_UInt64: + case kUpb_CType_Double: + case kUpb_CType_Float: + // Standard C number parsing functions expect null-terminated strings. + if (len >= sizeof(nullz) - 1) { + _upb_DefBuilder_Errf(ctx, "Default too long: %.*s", (int)len, str); + } + memcpy(nullz, str, len); + nullz[len] = '\0'; + str = nullz; + break; + default: + break; + } + + switch (upb_FieldDef_CType(f)) { + case kUpb_CType_Int32: { + long val = strtol(str, &end, 0); + if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || *end) { + goto invalid; + } + f->defaultval.sint = val; + break; + } + case kUpb_CType_Enum: { + const upb_EnumDef* e = f->sub.enumdef; + const upb_EnumValueDef* ev = + upb_EnumDef_FindValueByNameWithSize(e, str, len); + if (!ev) { + goto invalid; + } + f->defaultval.sint = upb_EnumValueDef_Number(ev); + break; + } + case kUpb_CType_Int64: { + long long val = strtoll(str, &end, 0); + if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || *end) { + goto invalid; + } + f->defaultval.sint = val; + break; + } + case kUpb_CType_UInt32: { + unsigned long val = strtoul(str, &end, 0); + if (val > UINT32_MAX || errno == ERANGE || *end) { + goto invalid; + } + f->defaultval.uint = val; + break; + } + case kUpb_CType_UInt64: { + unsigned long long val = strtoull(str, &end, 0); + if (val > UINT64_MAX || errno == ERANGE || *end) { + goto invalid; + } + f->defaultval.uint = val; + break; + } + case kUpb_CType_Double: { + double val = strtod(str, &end); + if (errno == ERANGE || *end) { + goto invalid; + } + f->defaultval.dbl = val; + break; + } + case kUpb_CType_Float: { + float val = strtof(str, &end); + if (errno == ERANGE || *end) { + goto invalid; + } + f->defaultval.flt = val; + break; + } + case kUpb_CType_Bool: { + if (streql2(str, len, "false")) { + f->defaultval.boolean = false; + } else if (streql2(str, len, "true")) { + f->defaultval.boolean = true; + } else { + goto invalid; + } + break; + } + case kUpb_CType_String: + f->defaultval.str = newstr(ctx, str, len); + break; + case kUpb_CType_Bytes: + f->defaultval.str = unescape(ctx, f, str, len); + break; + case kUpb_CType_Message: + /* Should not have a default value. */ + _upb_DefBuilder_Errf(ctx, "Message should not have a default (%s)", + upb_FieldDef_FullName(f)); + } + + return; + +invalid: + _upb_DefBuilder_Errf(ctx, "Invalid default '%.*s' for field %s of type %d", + (int)len, str, upb_FieldDef_FullName(f), + (int)upb_FieldDef_Type(f)); +} + +static void set_default_default(upb_DefBuilder* ctx, upb_FieldDef* f) { + switch (upb_FieldDef_CType(f)) { + case kUpb_CType_Int32: + case kUpb_CType_Int64: + f->defaultval.sint = 0; + break; + case kUpb_CType_UInt64: + case kUpb_CType_UInt32: + f->defaultval.uint = 0; + break; + case kUpb_CType_Double: + case kUpb_CType_Float: + f->defaultval.dbl = 0; + break; + case kUpb_CType_String: + case kUpb_CType_Bytes: + f->defaultval.str = newstr(ctx, NULL, 0); + break; + case kUpb_CType_Bool: + f->defaultval.boolean = false; + break; + case kUpb_CType_Enum: { + const upb_EnumValueDef* v = upb_EnumDef_Value(f->sub.enumdef, 0); + f->defaultval.sint = upb_EnumValueDef_Number(v); + break; + } + case kUpb_CType_Message: + break; + } +} + +static bool _upb_FieldDef_InferLegacyFeatures( + upb_DefBuilder* ctx, upb_FieldDef* f, + const UPB_DESC(FieldDescriptorProto*) proto, + const UPB_DESC(FieldOptions*) options, upb_Syntax syntax, + UPB_DESC(FeatureSet*) features) { + bool ret = false; + + if (UPB_DESC(FieldDescriptorProto_label)(proto) == kUpb_Label_Required) { + if (syntax == kUpb_Syntax_Proto3) { + _upb_DefBuilder_Errf(ctx, "proto3 fields cannot be required (%s)", + f->full_name); + } + int val = UPB_DESC(FeatureSet_LEGACY_REQUIRED); + UPB_DESC(FeatureSet_set_field_presence(features, val)); + ret = true; + } + + if (UPB_DESC(FieldDescriptorProto_type)(proto) == kUpb_FieldType_Group) { + int val = UPB_DESC(FeatureSet_DELIMITED); + UPB_DESC(FeatureSet_set_message_encoding(features, val)); + ret = true; + } + + if (UPB_DESC(FieldOptions_has_packed)(options)) { + int val = UPB_DESC(FieldOptions_packed)(options) + ? UPB_DESC(FeatureSet_PACKED) + : UPB_DESC(FeatureSet_EXPANDED); + UPB_DESC(FeatureSet_set_repeated_field_encoding(features, val)); + ret = true; + } + +// begin:google_only +// #ifndef UPB_BOOTSTRAP_STAGE0 +// if (syntax == kUpb_Syntax_Proto3 && +// UPB_DESC(FieldOptions_has_enforce_utf8)(options) && +// !UPB_DESC(FieldOptions_enforce_utf8)(options)) { +// int val = UPB_DESC(FeatureSet_UNVERIFIED); +// UPB_DESC(FeatureSet_set_utf8_validation(features, val)); +// ret = true; +// } +// #endif +// // clang-format off +// end:google_only + // clang-format on + + return ret; +} + +static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix, + const UPB_DESC(FeatureSet*) parent_features, + const UPB_DESC(FieldDescriptorProto*) + field_proto, + upb_MessageDef* m, upb_FieldDef* f) { + // Must happen before _upb_DefBuilder_Add() + f->file = _upb_DefBuilder_File(ctx); + + const upb_StringView name = UPB_DESC(FieldDescriptorProto_name)(field_proto); + f->full_name = _upb_DefBuilder_MakeFullName(ctx, prefix, name); + f->number_ = UPB_DESC(FieldDescriptorProto_number)(field_proto); + f->is_proto3_optional = + UPB_DESC(FieldDescriptorProto_proto3_optional)(field_proto); + f->msgdef = m; + f->scope.oneof = NULL; + + UPB_DEF_SET_OPTIONS(f->opts, FieldDescriptorProto, FieldOptions, field_proto); + + upb_Syntax syntax = upb_FileDef_Syntax(f->file); + const UPB_DESC(FeatureSet*) unresolved_features = + UPB_DESC(FieldOptions_features)(f->opts); + bool implicit = false; + + if (syntax != kUpb_Syntax_Editions) { + upb_Message_Clear(UPB_UPCAST(ctx->legacy_features), + UPB_DESC_MINITABLE(FeatureSet)); + if (_upb_FieldDef_InferLegacyFeatures(ctx, f, field_proto, f->opts, syntax, + ctx->legacy_features)) { + implicit = true; + unresolved_features = ctx->legacy_features; + } + } + + if (UPB_DESC(FieldDescriptorProto_has_oneof_index)(field_proto)) { + int oneof_index = UPB_DESC(FieldDescriptorProto_oneof_index)(field_proto); + + if (!m) { + _upb_DefBuilder_Errf(ctx, "oneof field (%s) has no containing msg", + f->full_name); + } + + if (oneof_index >= upb_MessageDef_OneofCount(m)) { + _upb_DefBuilder_Errf(ctx, "oneof_index out of range (%s)", f->full_name); + } + + upb_OneofDef* oneof = (upb_OneofDef*)upb_MessageDef_Oneof(m, oneof_index); + f->scope.oneof = oneof; + parent_features = upb_OneofDef_ResolvedFeatures(oneof); + + _upb_OneofDef_Insert(ctx, oneof, f, name.data, name.size); + } + + f->resolved_features = _upb_DefBuilder_DoResolveFeatures( + ctx, parent_features, unresolved_features, implicit); + + f->label_ = (int)UPB_DESC(FieldDescriptorProto_label)(field_proto); + if (f->label_ == kUpb_Label_Optional && + // TODO: remove once we can deprecate kUpb_Label_Required. + UPB_DESC(FeatureSet_field_presence)(f->resolved_features) == + UPB_DESC(FeatureSet_LEGACY_REQUIRED)) { + f->label_ = kUpb_Label_Required; + } + + if (!UPB_DESC(FieldDescriptorProto_has_name)(field_proto)) { + _upb_DefBuilder_Errf(ctx, "field has no name"); + } + + f->has_json_name = UPB_DESC(FieldDescriptorProto_has_json_name)(field_proto); + if (f->has_json_name) { + const upb_StringView sv = + UPB_DESC(FieldDescriptorProto_json_name)(field_proto); + f->json_name = upb_strdup2(sv.data, sv.size, ctx->arena); + } else { + f->json_name = make_json_name(name.data, name.size, ctx->arena); + } + if (!f->json_name) _upb_DefBuilder_OomErr(ctx); + + const bool has_type = UPB_DESC(FieldDescriptorProto_has_type)(field_proto); + const bool has_type_name = + UPB_DESC(FieldDescriptorProto_has_type_name)(field_proto); + + f->type_ = (int)UPB_DESC(FieldDescriptorProto_type)(field_proto); + + if (has_type) { + switch (f->type_) { + case kUpb_FieldType_Message: + case kUpb_FieldType_Group: + case kUpb_FieldType_Enum: + if (!has_type_name) { + _upb_DefBuilder_Errf(ctx, "field of type %d requires type name (%s)", + (int)f->type_, f->full_name); + } + break; + default: + if (has_type_name) { + _upb_DefBuilder_Errf( + ctx, "invalid type for field with type_name set (%s, %d)", + f->full_name, (int)f->type_); + } + } + } + + if ((!has_type && has_type_name) || f->type_ == kUpb_FieldType_Message) { + f->type_ = + UPB_FIELD_TYPE_UNSPECIFIED; // We'll assign this in resolve_subdef() + } else { + if (f->type_ < kUpb_FieldType_Double || f->type_ > kUpb_FieldType_SInt64) { + _upb_DefBuilder_Errf(ctx, "invalid type for field %s (%d)", f->full_name, + f->type_); + } + } + + if (f->label_ < kUpb_Label_Optional || f->label_ > kUpb_Label_Repeated) { + _upb_DefBuilder_Errf(ctx, "invalid label for field %s (%d)", f->full_name, + f->label_); + } + + /* We can't resolve the subdef or (in the case of extensions) the containing + * message yet, because it may not have been defined yet. We stash a pointer + * to the field_proto until later when we can properly resolve it. */ + f->sub.unresolved = field_proto; + + if (UPB_DESC(FieldDescriptorProto_has_oneof_index)(field_proto)) { + if (upb_FieldDef_Label(f) != kUpb_Label_Optional) { + _upb_DefBuilder_Errf(ctx, "fields in oneof must have OPTIONAL label (%s)", + f->full_name); + } + } + + f->has_presence = + (!upb_FieldDef_IsRepeated(f)) && + (f->is_extension || + (f->type_ == kUpb_FieldType_Message || + f->type_ == kUpb_FieldType_Group || upb_FieldDef_ContainingOneof(f) || + UPB_DESC(FeatureSet_field_presence)(f->resolved_features) != + UPB_DESC(FeatureSet_IMPLICIT))); +} + +static void _upb_FieldDef_CreateExt(upb_DefBuilder* ctx, const char* prefix, + const UPB_DESC(FeatureSet*) parent_features, + const UPB_DESC(FieldDescriptorProto*) + field_proto, + upb_MessageDef* m, upb_FieldDef* f) { + f->is_extension = true; + _upb_FieldDef_Create(ctx, prefix, parent_features, field_proto, m, f); + + if (UPB_DESC(FieldDescriptorProto_has_oneof_index)(field_proto)) { + _upb_DefBuilder_Errf(ctx, "oneof_index provided for extension field (%s)", + f->full_name); + } + + f->scope.extension_scope = m; + _upb_DefBuilder_Add(ctx, f->full_name, _upb_DefType_Pack(f, UPB_DEFTYPE_EXT)); + f->layout_index = ctx->ext_count++; + + if (ctx->layout) { + UPB_ASSERT(upb_MiniTableExtension_Number( + upb_FieldDef_MiniTableExtension(f)) == f->number_); + } +} + +static void _upb_FieldDef_CreateNotExt(upb_DefBuilder* ctx, const char* prefix, + const UPB_DESC(FeatureSet*) + parent_features, + const UPB_DESC(FieldDescriptorProto*) + field_proto, + upb_MessageDef* m, upb_FieldDef* f) { + f->is_extension = false; + _upb_FieldDef_Create(ctx, prefix, parent_features, field_proto, m, f); + + if (!UPB_DESC(FieldDescriptorProto_has_oneof_index)(field_proto)) { + if (f->is_proto3_optional) { + _upb_DefBuilder_Errf( + ctx, + "non-extension field (%s) with proto3_optional was not in a oneof", + f->full_name); + } + } + + _upb_MessageDef_InsertField(ctx, m, f); +} + +upb_FieldDef* _upb_Extensions_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(FieldDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + const char* prefix, upb_MessageDef* m) { + _upb_DefType_CheckPadding(sizeof(upb_FieldDef)); + upb_FieldDef* defs = + (upb_FieldDef*)_upb_DefBuilder_Alloc(ctx, sizeof(upb_FieldDef) * n); + + for (int i = 0; i < n; i++) { + upb_FieldDef* f = &defs[i]; + + _upb_FieldDef_CreateExt(ctx, prefix, parent_features, protos[i], m, f); + f->index_ = i; + } + + return defs; +} + +upb_FieldDef* _upb_FieldDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(FieldDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + const char* prefix, upb_MessageDef* m, + bool* is_sorted) { + _upb_DefType_CheckPadding(sizeof(upb_FieldDef)); + upb_FieldDef* defs = + (upb_FieldDef*)_upb_DefBuilder_Alloc(ctx, sizeof(upb_FieldDef) * n); + + uint32_t previous = 0; + for (int i = 0; i < n; i++) { + upb_FieldDef* f = &defs[i]; + + _upb_FieldDef_CreateNotExt(ctx, prefix, parent_features, protos[i], m, f); + f->index_ = i; + if (!ctx->layout) { + // Speculate that the def fields are sorted. We will always sort the + // MiniTable fields, so if defs are sorted then indices will match. + // + // If this is incorrect, we will overwrite later. + f->layout_index = i; + } + + const uint32_t current = f->number_; + if (previous > current) *is_sorted = false; + previous = current; + } + + return defs; +} + +static void resolve_subdef(upb_DefBuilder* ctx, const char* prefix, + upb_FieldDef* f) { + const UPB_DESC(FieldDescriptorProto)* field_proto = f->sub.unresolved; + upb_StringView name = UPB_DESC(FieldDescriptorProto_type_name)(field_proto); + bool has_name = UPB_DESC(FieldDescriptorProto_has_type_name)(field_proto); + switch ((int)f->type_) { + case UPB_FIELD_TYPE_UNSPECIFIED: { + // Type was not specified and must be inferred. + UPB_ASSERT(has_name); + upb_deftype_t type; + const void* def = + _upb_DefBuilder_ResolveAny(ctx, f->full_name, prefix, name, &type); + switch (type) { + case UPB_DEFTYPE_ENUM: + f->sub.enumdef = def; + f->type_ = kUpb_FieldType_Enum; + break; + case UPB_DEFTYPE_MSG: + f->sub.msgdef = def; + f->type_ = kUpb_FieldType_Message; + // TODO: remove once we can deprecate + // kUpb_FieldType_Group. + if (UPB_DESC(FeatureSet_message_encoding)(f->resolved_features) == + UPB_DESC(FeatureSet_DELIMITED) && + !upb_MessageDef_IsMapEntry(def) && + !(f->msgdef && upb_MessageDef_IsMapEntry(f->msgdef))) { + f->type_ = kUpb_FieldType_Group; + } + f->has_presence = !upb_FieldDef_IsRepeated(f); + break; + default: + _upb_DefBuilder_Errf(ctx, "Couldn't resolve type name for field %s", + f->full_name); + } + break; + } + case kUpb_FieldType_Message: + case kUpb_FieldType_Group: + UPB_ASSERT(has_name); + f->sub.msgdef = _upb_DefBuilder_Resolve(ctx, f->full_name, prefix, name, + UPB_DEFTYPE_MSG); + break; + case kUpb_FieldType_Enum: + UPB_ASSERT(has_name); + f->sub.enumdef = _upb_DefBuilder_Resolve(ctx, f->full_name, prefix, name, + UPB_DEFTYPE_ENUM); + break; + default: + // No resolution necessary. + break; + } +} + +static int _upb_FieldDef_Compare(const void* p1, const void* p2) { + const uint32_t v1 = (*(upb_FieldDef**)p1)->number_; + const uint32_t v2 = (*(upb_FieldDef**)p2)->number_; + return (v1 < v2) ? -1 : (v1 > v2); +} + +// _upb_FieldDefs_Sorted() is mostly a pure function of its inputs, but has one +// critical side effect that we depend on: it sets layout_index appropriately +// for non-sorted lists of fields. +const upb_FieldDef** _upb_FieldDefs_Sorted(const upb_FieldDef* f, int n, + upb_Arena* a) { + // TODO: Replace this arena alloc with a persistent scratch buffer. + upb_FieldDef** out = (upb_FieldDef**)upb_Arena_Malloc(a, n * sizeof(void*)); + if (!out) return NULL; + + for (int i = 0; i < n; i++) { + out[i] = (upb_FieldDef*)&f[i]; + } + qsort(out, n, sizeof(void*), _upb_FieldDef_Compare); + + for (int i = 0; i < n; i++) { + out[i]->layout_index = i; + } + return (const upb_FieldDef**)out; +} + +bool upb_FieldDef_MiniDescriptorEncode(const upb_FieldDef* f, upb_Arena* a, + upb_StringView* out) { + UPB_ASSERT(f->is_extension); + + upb_DescState s; + _upb_DescState_Init(&s); + + const int number = upb_FieldDef_Number(f); + const uint64_t modifiers = _upb_FieldDef_Modifiers(f); + + if (!_upb_DescState_Grow(&s, a)) return false; + s.ptr = upb_MtDataEncoder_EncodeExtension(&s.e, s.ptr, f->type_, number, + modifiers); + *s.ptr = '\0'; + + out->data = s.buf; + out->size = s.ptr - s.buf; + return true; +} + +static void resolve_extension(upb_DefBuilder* ctx, const char* prefix, + upb_FieldDef* f, + const UPB_DESC(FieldDescriptorProto) * + field_proto) { + if (!UPB_DESC(FieldDescriptorProto_has_extendee)(field_proto)) { + _upb_DefBuilder_Errf(ctx, "extension for field '%s' had no extendee", + f->full_name); + } + + upb_StringView name = UPB_DESC(FieldDescriptorProto_extendee)(field_proto); + const upb_MessageDef* m = + _upb_DefBuilder_Resolve(ctx, f->full_name, prefix, name, UPB_DEFTYPE_MSG); + f->msgdef = m; + + if (!_upb_MessageDef_IsValidExtensionNumber(m, f->number_)) { + _upb_DefBuilder_Errf( + ctx, + "field number %u in extension %s has no extension range in message %s", + (unsigned)f->number_, f->full_name, upb_MessageDef_FullName(m)); + } +} + +void _upb_FieldDef_BuildMiniTableExtension(upb_DefBuilder* ctx, + const upb_FieldDef* f) { + const upb_MiniTableExtension* ext = upb_FieldDef_MiniTableExtension(f); + + if (ctx->layout) { + UPB_ASSERT(upb_FieldDef_Number(f) == upb_MiniTableExtension_Number(ext)); + } else { + upb_StringView desc; + if (!upb_FieldDef_MiniDescriptorEncode(f, ctx->tmp_arena, &desc)) { + _upb_DefBuilder_OomErr(ctx); + } + + upb_MiniTableExtension* mut_ext = (upb_MiniTableExtension*)ext; + upb_MiniTableSub sub = {NULL}; + if (upb_FieldDef_IsSubMessage(f)) { + const upb_MiniTable* submsg = upb_MessageDef_MiniTable(f->sub.msgdef); + sub = upb_MiniTableSub_FromMessage(submsg); + } else if (_upb_FieldDef_IsClosedEnum(f)) { + const upb_MiniTableEnum* subenum = _upb_EnumDef_MiniTable(f->sub.enumdef); + sub = upb_MiniTableSub_FromEnum(subenum); + } + bool ok2 = upb_MiniTableExtension_Init(desc.data, desc.size, mut_ext, + upb_MessageDef_MiniTable(f->msgdef), + sub, ctx->status); + if (!ok2) _upb_DefBuilder_Errf(ctx, "Could not build extension mini table"); + } + + bool ok = _upb_DefPool_InsertExt(ctx->symtab, ext, f); + if (!ok) _upb_DefBuilder_OomErr(ctx); +} + +static void resolve_default(upb_DefBuilder* ctx, upb_FieldDef* f, + const UPB_DESC(FieldDescriptorProto) * + field_proto) { + // Have to delay resolving of the default value until now because of the enum + // case, since enum defaults are specified with a label. + if (UPB_DESC(FieldDescriptorProto_has_default_value)(field_proto)) { + upb_StringView defaultval = + UPB_DESC(FieldDescriptorProto_default_value)(field_proto); + + if (upb_FileDef_Syntax(f->file) == kUpb_Syntax_Proto3) { + _upb_DefBuilder_Errf(ctx, + "proto3 fields cannot have explicit defaults (%s)", + f->full_name); + } + + if (upb_FieldDef_IsSubMessage(f)) { + _upb_DefBuilder_Errf(ctx, + "message fields cannot have explicit defaults (%s)", + f->full_name); + } + + parse_default(ctx, defaultval.data, defaultval.size, f); + f->has_default = true; + } else { + set_default_default(ctx, f); + f->has_default = false; + } +} + +void _upb_FieldDef_Resolve(upb_DefBuilder* ctx, const char* prefix, + upb_FieldDef* f) { + // We have to stash this away since resolve_subdef() may overwrite it. + const UPB_DESC(FieldDescriptorProto)* field_proto = f->sub.unresolved; + + resolve_subdef(ctx, prefix, f); + resolve_default(ctx, f, field_proto); + + if (f->is_extension) { + resolve_extension(ctx, prefix, f, field_proto); + } +} + + +#include +#include +#include + + +// Must be last. + +struct upb_FileDef { + const UPB_DESC(FileOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + const char* name; + const char* package; + UPB_DESC(Edition) edition; + + const upb_FileDef** deps; + const int32_t* public_deps; + const int32_t* weak_deps; + const upb_MessageDef* top_lvl_msgs; + const upb_EnumDef* top_lvl_enums; + const upb_FieldDef* top_lvl_exts; + const upb_ServiceDef* services; + const upb_MiniTableExtension** ext_layouts; + const upb_DefPool* symtab; + + int dep_count; + int public_dep_count; + int weak_dep_count; + int top_lvl_msg_count; + int top_lvl_enum_count; + int top_lvl_ext_count; + int service_count; + int ext_count; // All exts in the file. + upb_Syntax syntax; +}; + +UPB_API const char* upb_FileDef_EditionName(int edition) { + // TODO Synchronize this with descriptor.proto better. + switch (edition) { + case UPB_DESC(EDITION_PROTO2): + return "PROTO2"; + case UPB_DESC(EDITION_PROTO3): + return "PROTO3"; + case UPB_DESC(EDITION_2023): + return "2023"; + default: + return "UNKNOWN"; + } +} + +const UPB_DESC(FileOptions) * upb_FileDef_Options(const upb_FileDef* f) { + return f->opts; +} + +const UPB_DESC(FeatureSet) * + upb_FileDef_ResolvedFeatures(const upb_FileDef* f) { + return f->resolved_features; +} + +bool upb_FileDef_HasOptions(const upb_FileDef* f) { + return f->opts != (void*)kUpbDefOptDefault; +} + +const char* upb_FileDef_Name(const upb_FileDef* f) { return f->name; } + +const char* upb_FileDef_Package(const upb_FileDef* f) { + return f->package ? f->package : ""; +} + +UPB_DESC(Edition) upb_FileDef_Edition(const upb_FileDef* f) { + return f->edition; +} + +const char* _upb_FileDef_RawPackage(const upb_FileDef* f) { return f->package; } + +upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f) { return f->syntax; } + +int upb_FileDef_TopLevelMessageCount(const upb_FileDef* f) { + return f->top_lvl_msg_count; +} + +int upb_FileDef_DependencyCount(const upb_FileDef* f) { return f->dep_count; } + +int upb_FileDef_PublicDependencyCount(const upb_FileDef* f) { + return f->public_dep_count; +} + +int upb_FileDef_WeakDependencyCount(const upb_FileDef* f) { + return f->weak_dep_count; +} + +const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f) { + return f->public_deps; +} + +const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f) { + return f->weak_deps; +} + +int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f) { + return f->top_lvl_enum_count; +} + +int upb_FileDef_TopLevelExtensionCount(const upb_FileDef* f) { + return f->top_lvl_ext_count; +} + +int upb_FileDef_ServiceCount(const upb_FileDef* f) { return f->service_count; } + +const upb_FileDef* upb_FileDef_Dependency(const upb_FileDef* f, int i) { + UPB_ASSERT(0 <= i && i < f->dep_count); + return f->deps[i]; +} + +const upb_FileDef* upb_FileDef_PublicDependency(const upb_FileDef* f, int i) { + UPB_ASSERT(0 <= i && i < f->public_dep_count); + return f->deps[f->public_deps[i]]; +} + +const upb_FileDef* upb_FileDef_WeakDependency(const upb_FileDef* f, int i) { + UPB_ASSERT(0 <= i && i < f->public_dep_count); + return f->deps[f->weak_deps[i]]; +} + +const upb_MessageDef* upb_FileDef_TopLevelMessage(const upb_FileDef* f, int i) { + UPB_ASSERT(0 <= i && i < f->top_lvl_msg_count); + return _upb_MessageDef_At(f->top_lvl_msgs, i); +} + +const upb_EnumDef* upb_FileDef_TopLevelEnum(const upb_FileDef* f, int i) { + UPB_ASSERT(0 <= i && i < f->top_lvl_enum_count); + return _upb_EnumDef_At(f->top_lvl_enums, i); +} + +const upb_FieldDef* upb_FileDef_TopLevelExtension(const upb_FileDef* f, int i) { + UPB_ASSERT(0 <= i && i < f->top_lvl_ext_count); + return _upb_FieldDef_At(f->top_lvl_exts, i); +} + +const upb_ServiceDef* upb_FileDef_Service(const upb_FileDef* f, int i) { + UPB_ASSERT(0 <= i && i < f->service_count); + return _upb_ServiceDef_At(f->services, i); +} + +const upb_DefPool* upb_FileDef_Pool(const upb_FileDef* f) { return f->symtab; } + +const upb_MiniTableExtension* _upb_FileDef_ExtensionMiniTable( + const upb_FileDef* f, int i) { + return f->ext_layouts[i]; +} + +// Note: Import cycles are not allowed so this will terminate. +bool upb_FileDef_Resolves(const upb_FileDef* f, const char* path) { + if (!strcmp(f->name, path)) return true; + + for (int i = 0; i < upb_FileDef_PublicDependencyCount(f); i++) { + const upb_FileDef* dep = upb_FileDef_PublicDependency(f, i); + if (upb_FileDef_Resolves(dep, path)) return true; + } + return false; +} + +static char* strviewdup(upb_DefBuilder* ctx, upb_StringView view) { + char* ret = upb_strdup2(view.data, view.size, _upb_DefBuilder_Arena(ctx)); + if (!ret) _upb_DefBuilder_OomErr(ctx); + return ret; +} + +static bool streql_view(upb_StringView view, const char* b) { + return view.size == strlen(b) && memcmp(view.data, b, view.size) == 0; +} + +static int count_exts_in_msg(const UPB_DESC(DescriptorProto) * msg_proto) { + size_t n; + UPB_DESC(DescriptorProto_extension)(msg_proto, &n); + int ext_count = n; + + const UPB_DESC(DescriptorProto)* const* nested_msgs = + UPB_DESC(DescriptorProto_nested_type)(msg_proto, &n); + for (size_t i = 0; i < n; i++) { + ext_count += count_exts_in_msg(nested_msgs[i]); + } + + return ext_count; +} + +const UPB_DESC(FeatureSet*) + _upb_FileDef_FindEdition(upb_DefBuilder* ctx, int edition) { + const UPB_DESC(FeatureSetDefaults)* defaults = + upb_DefPool_FeatureSetDefaults(ctx->symtab); + + int min = UPB_DESC(FeatureSetDefaults_minimum_edition)(defaults); + int max = UPB_DESC(FeatureSetDefaults_maximum_edition)(defaults); + if (edition < min) { + _upb_DefBuilder_Errf(ctx, + "Edition %s is earlier than the minimum edition %s " + "given in the defaults", + upb_FileDef_EditionName(edition), + upb_FileDef_EditionName(min)); + return NULL; + } + if (edition > max) { + _upb_DefBuilder_Errf(ctx, + "Edition %s is later than the maximum edition %s " + "given in the defaults", + upb_FileDef_EditionName(edition), + upb_FileDef_EditionName(max)); + return NULL; + } + + size_t n; + const UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault)* const* d = + UPB_DESC(FeatureSetDefaults_defaults)(defaults, &n); + const UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault)* result = NULL; + for (size_t i = 0; i < n; i++) { + if (UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault_edition)(d[i]) > + edition) { + break; + } + result = d[i]; + } + if (result == NULL) { + _upb_DefBuilder_Errf(ctx, "No valid default found for edition %s", + upb_FileDef_EditionName(edition)); + return NULL; + } + + // Merge the fixed and overridable features to get the edition's default + // feature set. + const UPB_DESC(FeatureSet)* fixed = UPB_DESC( + FeatureSetDefaults_FeatureSetEditionDefault_fixed_features)(result); + const UPB_DESC(FeatureSet)* overridable = UPB_DESC( + FeatureSetDefaults_FeatureSetEditionDefault_overridable_features)(result); + if (!fixed && !overridable) { + _upb_DefBuilder_Errf(ctx, "No valid default found for edition %s", + upb_FileDef_EditionName(edition)); + return NULL; + } else if (!fixed) { + return overridable; + } + return _upb_DefBuilder_DoResolveFeatures(ctx, fixed, overridable, + /*is_implicit=*/true); +} + +// Allocate and initialize one file def, and add it to the context object. +void _upb_FileDef_Create(upb_DefBuilder* ctx, + const UPB_DESC(FileDescriptorProto) * file_proto) { + upb_FileDef* file = _upb_DefBuilder_Alloc(ctx, sizeof(upb_FileDef)); + ctx->file = file; + + const UPB_DESC(DescriptorProto)* const* msgs; + const UPB_DESC(EnumDescriptorProto)* const* enums; + const UPB_DESC(FieldDescriptorProto)* const* exts; + const UPB_DESC(ServiceDescriptorProto)* const* services; + const upb_StringView* strs; + const int32_t* public_deps; + const int32_t* weak_deps; + size_t n; + + file->symtab = ctx->symtab; + + // Count all extensions in the file, to build a flat array of layouts. + UPB_DESC(FileDescriptorProto_extension)(file_proto, &n); + int ext_count = n; + msgs = UPB_DESC(FileDescriptorProto_message_type)(file_proto, &n); + for (size_t i = 0; i < n; i++) { + ext_count += count_exts_in_msg(msgs[i]); + } + file->ext_count = ext_count; + + if (ctx->layout) { + // We are using the ext layouts that were passed in. + file->ext_layouts = ctx->layout->UPB_PRIVATE(exts); + const int mt_ext_count = upb_MiniTableFile_ExtensionCount(ctx->layout); + if (mt_ext_count != file->ext_count) { + _upb_DefBuilder_Errf(ctx, + "Extension count did not match layout (%d vs %d)", + mt_ext_count, file->ext_count); + } + } else { + // We are building ext layouts from scratch. + file->ext_layouts = _upb_DefBuilder_Alloc( + ctx, sizeof(*file->ext_layouts) * file->ext_count); + upb_MiniTableExtension* ext = + _upb_DefBuilder_Alloc(ctx, sizeof(*ext) * file->ext_count); + for (int i = 0; i < file->ext_count; i++) { + file->ext_layouts[i] = &ext[i]; + } + } + + upb_StringView name = UPB_DESC(FileDescriptorProto_name)(file_proto); + file->name = strviewdup(ctx, name); + if (strlen(file->name) != name.size) { + _upb_DefBuilder_Errf(ctx, "File name contained embedded NULL"); + } + + upb_StringView package = UPB_DESC(FileDescriptorProto_package)(file_proto); + + if (package.size) { + _upb_DefBuilder_CheckIdentFull(ctx, package); + file->package = strviewdup(ctx, package); + } else { + file->package = NULL; + } + + // TODO: How should we validate this? + file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto); + + if (UPB_DESC(FileDescriptorProto_has_syntax)(file_proto)) { + upb_StringView syntax = UPB_DESC(FileDescriptorProto_syntax)(file_proto); + + if (streql_view(syntax, "proto2")) { + file->syntax = kUpb_Syntax_Proto2; + file->edition = UPB_DESC(EDITION_PROTO2); + } else if (streql_view(syntax, "proto3")) { + file->syntax = kUpb_Syntax_Proto3; + file->edition = UPB_DESC(EDITION_PROTO3); + } else if (streql_view(syntax, "editions")) { + file->syntax = kUpb_Syntax_Editions; + file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto); + } else { + _upb_DefBuilder_Errf(ctx, "Invalid syntax '" UPB_STRINGVIEW_FORMAT "'", + UPB_STRINGVIEW_ARGS(syntax)); + } + } else { + file->syntax = kUpb_Syntax_Proto2; + file->edition = UPB_DESC(EDITION_PROTO2); + } + + // Read options. + UPB_DEF_SET_OPTIONS(file->opts, FileDescriptorProto, FileOptions, file_proto); + + // Resolve features. + const UPB_DESC(FeatureSet*) edition_defaults = + _upb_FileDef_FindEdition(ctx, file->edition); + const UPB_DESC(FeatureSet*) unresolved = + UPB_DESC(FileOptions_features)(file->opts); + file->resolved_features = + _upb_DefBuilder_ResolveFeatures(ctx, edition_defaults, unresolved); + + // Verify dependencies. + strs = UPB_DESC(FileDescriptorProto_dependency)(file_proto, &n); + file->dep_count = n; + file->deps = _upb_DefBuilder_Alloc(ctx, sizeof(*file->deps) * n); + + for (size_t i = 0; i < n; i++) { + upb_StringView str = strs[i]; + file->deps[i] = + upb_DefPool_FindFileByNameWithSize(ctx->symtab, str.data, str.size); + if (!file->deps[i]) { + _upb_DefBuilder_Errf(ctx, + "Depends on file '" UPB_STRINGVIEW_FORMAT + "', but it has not been loaded", + UPB_STRINGVIEW_ARGS(str)); + } + } + + public_deps = UPB_DESC(FileDescriptorProto_public_dependency)(file_proto, &n); + file->public_dep_count = n; + file->public_deps = + _upb_DefBuilder_Alloc(ctx, sizeof(*file->public_deps) * n); + int32_t* mutable_public_deps = (int32_t*)file->public_deps; + for (size_t i = 0; i < n; i++) { + if (public_deps[i] >= file->dep_count) { + _upb_DefBuilder_Errf(ctx, "public_dep %d is out of range", + (int)public_deps[i]); + } + mutable_public_deps[i] = public_deps[i]; + } + + weak_deps = UPB_DESC(FileDescriptorProto_weak_dependency)(file_proto, &n); + file->weak_dep_count = n; + file->weak_deps = _upb_DefBuilder_Alloc(ctx, sizeof(*file->weak_deps) * n); + int32_t* mutable_weak_deps = (int32_t*)file->weak_deps; + for (size_t i = 0; i < n; i++) { + if (weak_deps[i] >= file->dep_count) { + _upb_DefBuilder_Errf(ctx, "weak_dep %d is out of range", + (int)weak_deps[i]); + } + mutable_weak_deps[i] = weak_deps[i]; + } + + // Create enums. + enums = UPB_DESC(FileDescriptorProto_enum_type)(file_proto, &n); + file->top_lvl_enum_count = n; + file->top_lvl_enums = + _upb_EnumDefs_New(ctx, n, enums, file->resolved_features, NULL); + + // Create extensions. + exts = UPB_DESC(FileDescriptorProto_extension)(file_proto, &n); + file->top_lvl_ext_count = n; + file->top_lvl_exts = _upb_Extensions_New( + ctx, n, exts, file->resolved_features, file->package, NULL); + + // Create messages. + msgs = UPB_DESC(FileDescriptorProto_message_type)(file_proto, &n); + file->top_lvl_msg_count = n; + file->top_lvl_msgs = + _upb_MessageDefs_New(ctx, n, msgs, file->resolved_features, NULL); + + // Create services. + services = UPB_DESC(FileDescriptorProto_service)(file_proto, &n); + file->service_count = n; + file->services = + _upb_ServiceDefs_New(ctx, n, services, file->resolved_features); + + // Now that all names are in the table, build layouts and resolve refs. + + for (int i = 0; i < file->top_lvl_msg_count; i++) { + upb_MessageDef* m = (upb_MessageDef*)upb_FileDef_TopLevelMessage(file, i); + _upb_MessageDef_Resolve(ctx, m); + } + + for (int i = 0; i < file->top_lvl_ext_count; i++) { + upb_FieldDef* f = (upb_FieldDef*)upb_FileDef_TopLevelExtension(file, i); + _upb_FieldDef_Resolve(ctx, file->package, f); + } + + for (int i = 0; i < file->top_lvl_msg_count; i++) { + upb_MessageDef* m = (upb_MessageDef*)upb_FileDef_TopLevelMessage(file, i); + _upb_MessageDef_CreateMiniTable(ctx, (upb_MessageDef*)m); + } + + for (int i = 0; i < file->top_lvl_ext_count; i++) { + upb_FieldDef* f = (upb_FieldDef*)upb_FileDef_TopLevelExtension(file, i); + _upb_FieldDef_BuildMiniTableExtension(ctx, f); + } + + for (int i = 0; i < file->top_lvl_msg_count; i++) { + upb_MessageDef* m = (upb_MessageDef*)upb_FileDef_TopLevelMessage(file, i); + _upb_MessageDef_LinkMiniTable(ctx, m); + } + + if (file->ext_count) { + bool ok = upb_ExtensionRegistry_AddArray( + _upb_DefPool_ExtReg(ctx->symtab), file->ext_layouts, file->ext_count); + if (!ok) _upb_DefBuilder_OomErr(ctx); + } +} + + +#include + + +// Must be last. + +/* The upb core does not generally have a concept of default instances. However + * for descriptor options we make an exception since the max size is known and + * modest (<200 bytes). All types can share a default instance since it is + * initialized to zeroes. + * + * We have to allocate an extra pointer for upb's internal metadata. */ +static UPB_ALIGN_AS(8) const + char opt_default_buf[_UPB_MAXOPT_SIZE + sizeof(void*)] = {0}; +const char* kUpbDefOptDefault = &opt_default_buf[sizeof(void*)]; + +const char* _upb_DefBuilder_FullToShort(const char* fullname) { + const char* p; + + if (fullname == NULL) { + return NULL; + } else if ((p = strrchr(fullname, '.')) == NULL) { + /* No '.' in the name, return the full string. */ + return fullname; + } else { + /* Return one past the last '.'. */ + return p + 1; + } +} + +void _upb_DefBuilder_FailJmp(upb_DefBuilder* ctx) { UPB_LONGJMP(ctx->err, 1); } + +void _upb_DefBuilder_Errf(upb_DefBuilder* ctx, const char* fmt, ...) { + va_list argp; + va_start(argp, fmt); + upb_Status_VSetErrorFormat(ctx->status, fmt, argp); + va_end(argp); + _upb_DefBuilder_FailJmp(ctx); +} + +void _upb_DefBuilder_OomErr(upb_DefBuilder* ctx) { + upb_Status_SetErrorMessage(ctx->status, "out of memory"); + _upb_DefBuilder_FailJmp(ctx); +} + +// Verify a relative identifier string. The loop is branchless for speed. +static void _upb_DefBuilder_CheckIdentNotFull(upb_DefBuilder* ctx, + upb_StringView name) { + bool good = name.size > 0; + + for (size_t i = 0; i < name.size; i++) { + const char c = name.data[i]; + const char d = c | 0x20; // force lowercase + const bool is_alpha = (('a' <= d) & (d <= 'z')) | (c == '_'); + const bool is_numer = ('0' <= c) & (c <= '9') & (i != 0); + + good &= is_alpha | is_numer; + } + + if (!good) _upb_DefBuilder_CheckIdentSlow(ctx, name, false); +} + +const char* _upb_DefBuilder_MakeFullName(upb_DefBuilder* ctx, + const char* prefix, + upb_StringView name) { + _upb_DefBuilder_CheckIdentNotFull(ctx, name); + if (prefix) { + // ret = prefix + '.' + name; + size_t n = strlen(prefix); + char* ret = _upb_DefBuilder_Alloc(ctx, n + name.size + 2); + strcpy(ret, prefix); + ret[n] = '.'; + memcpy(&ret[n + 1], name.data, name.size); + ret[n + 1 + name.size] = '\0'; + return ret; + } else { + char* ret = upb_strdup2(name.data, name.size, ctx->arena); + if (!ret) _upb_DefBuilder_OomErr(ctx); + return ret; + } +} + +static bool remove_component(char* base, size_t* len) { + if (*len == 0) return false; + + for (size_t i = *len - 1; i > 0; i--) { + if (base[i] == '.') { + *len = i; + return true; + } + } + + *len = 0; + return true; +} + +const void* _upb_DefBuilder_ResolveAny(upb_DefBuilder* ctx, + const char* from_name_dbg, + const char* base, upb_StringView sym, + upb_deftype_t* type) { + if (sym.size == 0) goto notfound; + upb_value v; + if (sym.data[0] == '.') { + // Symbols starting with '.' are absolute, so we do a single lookup. + // Slice to omit the leading '.' + if (!_upb_DefPool_LookupSym(ctx->symtab, sym.data + 1, sym.size - 1, &v)) { + goto notfound; + } + } else { + // Remove components from base until we find an entry or run out. + size_t baselen = base ? strlen(base) : 0; + char* tmp = upb_gmalloc(sym.size + baselen + 1); + while (1) { + char* p = tmp; + if (baselen) { + memcpy(p, base, baselen); + p[baselen] = '.'; + p += baselen + 1; + } + memcpy(p, sym.data, sym.size); + p += sym.size; + if (_upb_DefPool_LookupSym(ctx->symtab, tmp, p - tmp, &v)) { + break; + } + if (!remove_component(tmp, &baselen)) { + upb_gfree(tmp); + goto notfound; + } + } + upb_gfree(tmp); + } + + *type = _upb_DefType_Type(v); + return _upb_DefType_Unpack(v, *type); + +notfound: + _upb_DefBuilder_Errf(ctx, "couldn't resolve name '" UPB_STRINGVIEW_FORMAT "'", + UPB_STRINGVIEW_ARGS(sym)); +} + +const void* _upb_DefBuilder_Resolve(upb_DefBuilder* ctx, + const char* from_name_dbg, const char* base, + upb_StringView sym, upb_deftype_t type) { + upb_deftype_t found_type; + const void* ret = + _upb_DefBuilder_ResolveAny(ctx, from_name_dbg, base, sym, &found_type); + if (ret && found_type != type) { + _upb_DefBuilder_Errf(ctx, + "type mismatch when resolving %s: couldn't find " + "name " UPB_STRINGVIEW_FORMAT " with type=%d", + from_name_dbg, UPB_STRINGVIEW_ARGS(sym), (int)type); + } + return ret; +} + +// Per ASCII this will lower-case a letter. If the result is a letter, the +// input was definitely a letter. If the output is not a letter, this may +// have transformed the character unpredictably. +static char upb_ascii_lower(char ch) { return ch | 0x20; } + +// isalpha() etc. from are locale-dependent, which we don't want. +static bool upb_isbetween(uint8_t c, uint8_t low, uint8_t high) { + return low <= c && c <= high; +} + +static bool upb_isletter(char c) { + char lower = upb_ascii_lower(c); + return upb_isbetween(lower, 'a', 'z') || c == '_'; +} + +static bool upb_isalphanum(char c) { + return upb_isletter(c) || upb_isbetween(c, '0', '9'); +} + +static bool TryGetChar(const char** src, const char* end, char* ch) { + if (*src == end) return false; + *ch = **src; + *src += 1; + return true; +} + +static int TryGetHexDigit(const char** src, const char* end) { + char ch; + if (!TryGetChar(src, end, &ch)) return -1; + if ('0' <= ch && ch <= '9') { + return ch - '0'; + } + ch = upb_ascii_lower(ch); + if ('a' <= ch && ch <= 'f') { + return ch - 'a' + 0xa; + } + *src -= 1; // Char wasn't actually a hex digit. + return -1; +} + +static char upb_DefBuilder_ParseHexEscape(upb_DefBuilder* ctx, + const upb_FieldDef* f, + const char** src, const char* end) { + int hex_digit = TryGetHexDigit(src, end); + if (hex_digit < 0) { + _upb_DefBuilder_Errf( + ctx, "\\x must be followed by at least one hex digit (field='%s')", + upb_FieldDef_FullName(f)); + return 0; + } + unsigned int ret = hex_digit; + while ((hex_digit = TryGetHexDigit(src, end)) >= 0) { + ret = (ret << 4) | hex_digit; + } + if (ret > 0xff) { + _upb_DefBuilder_Errf(ctx, "Value of hex escape in field %s exceeds 8 bits", + upb_FieldDef_FullName(f)); + return 0; + } + return ret; +} + +static char TryGetOctalDigit(const char** src, const char* end) { + char ch; + if (!TryGetChar(src, end, &ch)) return -1; + if ('0' <= ch && ch <= '7') { + return ch - '0'; + } + *src -= 1; // Char wasn't actually an octal digit. + return -1; +} + +static char upb_DefBuilder_ParseOctalEscape(upb_DefBuilder* ctx, + const upb_FieldDef* f, + const char** src, const char* end) { + char ch = 0; + for (int i = 0; i < 3; i++) { + char digit; + if ((digit = TryGetOctalDigit(src, end)) >= 0) { + ch = (ch << 3) | digit; + } + } + return ch; +} + +char _upb_DefBuilder_ParseEscape(upb_DefBuilder* ctx, const upb_FieldDef* f, + const char** src, const char* end) { + char ch; + if (!TryGetChar(src, end, &ch)) { + _upb_DefBuilder_Errf(ctx, "unterminated escape sequence in field %s", + upb_FieldDef_FullName(f)); + return 0; + } + switch (ch) { + case 'a': + return '\a'; + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + case 'v': + return '\v'; + case '\\': + return '\\'; + case '\'': + return '\''; + case '\"': + return '\"'; + case '?': + return '\?'; + case 'x': + case 'X': + return upb_DefBuilder_ParseHexEscape(ctx, f, src, end); + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + *src -= 1; + return upb_DefBuilder_ParseOctalEscape(ctx, f, src, end); + } + _upb_DefBuilder_Errf(ctx, "Unknown escape sequence: \\%c", ch); +} + +void _upb_DefBuilder_CheckIdentSlow(upb_DefBuilder* ctx, upb_StringView name, + bool full) { + const char* str = name.data; + const size_t len = name.size; + bool start = true; + for (size_t i = 0; i < len; i++) { + const char c = str[i]; + if (c == '.') { + if (start || !full) { + _upb_DefBuilder_Errf( + ctx, "invalid name: unexpected '.' (" UPB_STRINGVIEW_FORMAT ")", + UPB_STRINGVIEW_ARGS(name)); + } + start = true; + } else if (start) { + if (!upb_isletter(c)) { + _upb_DefBuilder_Errf(ctx, + "invalid name: path components must start with a " + "letter (" UPB_STRINGVIEW_FORMAT ")", + UPB_STRINGVIEW_ARGS(name)); + } + start = false; + } else if (!upb_isalphanum(c)) { + _upb_DefBuilder_Errf( + ctx, + "invalid name: non-alphanumeric character (" UPB_STRINGVIEW_FORMAT + ")", + UPB_STRINGVIEW_ARGS(name)); + } + } + if (start) { + _upb_DefBuilder_Errf(ctx, + "invalid name: empty part (" UPB_STRINGVIEW_FORMAT ")", + UPB_STRINGVIEW_ARGS(name)); + } + + // We should never reach this point. + UPB_ASSERT(false); +} + +upb_StringView _upb_DefBuilder_MakeKey(upb_DefBuilder* ctx, + const UPB_DESC(FeatureSet*) parent, + upb_StringView key) { + size_t need = key.size + sizeof(void*); + if (ctx->tmp_buf_size < need) { + ctx->tmp_buf_size = UPB_MAX(64, upb_Log2Ceiling(need)); + ctx->tmp_buf = upb_Arena_Malloc(ctx->tmp_arena, ctx->tmp_buf_size); + if (!ctx->tmp_buf) _upb_DefBuilder_OomErr(ctx); + } + + memcpy(ctx->tmp_buf, &parent, sizeof(void*)); + memcpy(ctx->tmp_buf + sizeof(void*), key.data, key.size); + return upb_StringView_FromDataAndSize(ctx->tmp_buf, need); +} + +bool _upb_DefBuilder_GetOrCreateFeatureSet(upb_DefBuilder* ctx, + const UPB_DESC(FeatureSet*) parent, + upb_StringView key, + UPB_DESC(FeatureSet**) set) { + upb_StringView k = _upb_DefBuilder_MakeKey(ctx, parent, key); + upb_value v; + if (upb_strtable_lookup2(&ctx->feature_cache, k.data, k.size, &v)) { + *set = upb_value_getptr(v); + return false; + } + + *set = (UPB_DESC(FeatureSet*))upb_Message_DeepClone( + UPB_UPCAST(parent), UPB_DESC_MINITABLE(FeatureSet), ctx->arena); + if (!*set) _upb_DefBuilder_OomErr(ctx); + + v = upb_value_ptr(*set); + if (!upb_strtable_insert(&ctx->feature_cache, k.data, k.size, v, + ctx->tmp_arena)) { + _upb_DefBuilder_OomErr(ctx); + } + + return true; +} + +const UPB_DESC(FeatureSet*) + _upb_DefBuilder_DoResolveFeatures(upb_DefBuilder* ctx, + const UPB_DESC(FeatureSet*) parent, + const UPB_DESC(FeatureSet*) child, + bool is_implicit) { + assert(parent); + if (!child) return parent; + + if (child && !is_implicit && + upb_FileDef_Syntax(ctx->file) != kUpb_Syntax_Editions) { + _upb_DefBuilder_Errf(ctx, "Features can only be specified for editions"); + } + + UPB_DESC(FeatureSet*) resolved; + size_t child_size; + const char* child_bytes = + UPB_DESC(FeatureSet_serialize)(child, ctx->tmp_arena, &child_size); + if (!child_bytes) _upb_DefBuilder_OomErr(ctx); + + upb_StringView key = upb_StringView_FromDataAndSize(child_bytes, child_size); + if (!_upb_DefBuilder_GetOrCreateFeatureSet(ctx, parent, key, &resolved)) { + return resolved; + } + + upb_DecodeStatus dec_status = + upb_Decode(child_bytes, child_size, UPB_UPCAST(resolved), + UPB_DESC_MINITABLE(FeatureSet), NULL, 0, ctx->arena); + if (dec_status != kUpb_DecodeStatus_Ok) _upb_DefBuilder_OomErr(ctx); + + return resolved; +} + + +#include + + +// Must be last. + +char* upb_strdup2(const char* s, size_t len, upb_Arena* a) { + size_t n; + char* p; + + // Prevent overflow errors. + if (len == SIZE_MAX) return NULL; + + // Always null-terminate, even if binary data; but don't rely on the input to + // have a null-terminating byte since it may be a raw binary buffer. + n = len + 1; + p = upb_Arena_Malloc(a, n); + if (p) { + if (len != 0) memcpy(p, s, len); + p[len] = 0; + } + return p; +} + + +#include +#include + + +// Must be last. + +bool upb_Message_HasFieldByDef(const upb_Message* msg, const upb_FieldDef* f) { + const upb_MiniTableField* m_f = upb_FieldDef_MiniTable(f); + UPB_ASSERT(upb_FieldDef_HasPresence(f)); + + if (upb_MiniTableField_IsExtension(m_f)) { + return upb_Message_HasExtension(msg, (const upb_MiniTableExtension*)m_f); + } else { + return upb_Message_HasBaseField(msg, m_f); + } +} + +const upb_FieldDef* upb_Message_WhichOneof(const upb_Message* msg, + const upb_OneofDef* o) { + const upb_FieldDef* f = upb_OneofDef_Field(o, 0); + if (upb_OneofDef_IsSynthetic(o)) { + UPB_ASSERT(upb_OneofDef_FieldCount(o) == 1); + return upb_Message_HasFieldByDef(msg, f) ? f : NULL; + } else { + const upb_MiniTableField* field = upb_FieldDef_MiniTable(f); + uint32_t oneof_case = upb_Message_WhichOneofFieldNumber(msg, field); + f = oneof_case ? upb_OneofDef_LookupNumber(o, oneof_case) : NULL; + UPB_ASSERT((f != NULL) == (oneof_case != 0)); + return f; + } +} + +upb_MessageValue upb_Message_GetFieldByDef(const upb_Message* msg, + const upb_FieldDef* f) { + upb_MessageValue default_val = upb_FieldDef_Default(f); + return upb_Message_GetField(msg, upb_FieldDef_MiniTable(f), default_val); +} + +upb_MutableMessageValue upb_Message_Mutable(upb_Message* msg, + const upb_FieldDef* f, + upb_Arena* a) { + UPB_ASSERT(upb_FieldDef_IsSubMessage(f) || upb_FieldDef_IsRepeated(f)); + if (upb_FieldDef_HasPresence(f) && !upb_Message_HasFieldByDef(msg, f)) { + // We need to skip the upb_Message_GetFieldByDef() call in this case. + goto make; + } + + upb_MessageValue val = upb_Message_GetFieldByDef(msg, f); + if (val.array_val) { + return (upb_MutableMessageValue){.array = (upb_Array*)val.array_val}; + } + + upb_MutableMessageValue ret; +make: + if (!a) return (upb_MutableMessageValue){.array = NULL}; + if (upb_FieldDef_IsMap(f)) { + const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f); + const upb_FieldDef* key = + upb_MessageDef_FindFieldByNumber(entry, kUpb_MapEntry_KeyFieldNumber); + const upb_FieldDef* value = + upb_MessageDef_FindFieldByNumber(entry, kUpb_MapEntry_ValueFieldNumber); + ret.map = + upb_Map_New(a, upb_FieldDef_CType(key), upb_FieldDef_CType(value)); + } else if (upb_FieldDef_IsRepeated(f)) { + ret.array = upb_Array_New(a, upb_FieldDef_CType(f)); + } else { + UPB_ASSERT(upb_FieldDef_IsSubMessage(f)); + const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f); + ret.msg = upb_Message_New(upb_MessageDef_MiniTable(m), a); + } + + val.array_val = ret.array; + upb_Message_SetFieldByDef(msg, f, val, a); + + return ret; +} + +bool upb_Message_SetFieldByDef(upb_Message* msg, const upb_FieldDef* f, + upb_MessageValue val, upb_Arena* a) { + const upb_MiniTableField* m_f = upb_FieldDef_MiniTable(f); + + if (upb_MiniTableField_IsExtension(m_f)) { + return upb_Message_SetExtension(msg, (const upb_MiniTableExtension*)m_f, + &val, a); + } else { + upb_Message_SetBaseField(msg, m_f, &val); + return true; + } +} + +void upb_Message_ClearFieldByDef(upb_Message* msg, const upb_FieldDef* f) { + const upb_MiniTableField* m_f = upb_FieldDef_MiniTable(f); + + if (upb_MiniTableField_IsExtension(m_f)) { + upb_Message_ClearExtension(msg, (const upb_MiniTableExtension*)m_f); + } else { + upb_Message_ClearBaseField(msg, m_f); + } +} + +void upb_Message_ClearByDef(upb_Message* msg, const upb_MessageDef* m) { + upb_Message_Clear(msg, upb_MessageDef_MiniTable(m)); +} + +bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m, + const upb_DefPool* ext_pool, const upb_FieldDef** out_f, + upb_MessageValue* out_val, size_t* iter) { + const upb_MiniTable* mt = upb_MessageDef_MiniTable(m); + size_t i = *iter; + size_t n = upb_MiniTable_FieldCount(mt); + const upb_MessageValue zero = {0}; + UPB_UNUSED(ext_pool); + + // Iterate over normal fields, returning the first one that is set. + while (++i < n) { + const upb_MiniTableField* field = upb_MiniTable_GetFieldByIndex(mt, i); + upb_MessageValue val = upb_Message_GetField(msg, field, zero); + + // Skip field if unset or empty. + if (upb_MiniTableField_HasPresence(field)) { + if (!upb_Message_HasBaseField(msg, field)) continue; + } else { + switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(field)) { + case kUpb_FieldMode_Map: + if (!val.map_val || upb_Map_Size(val.map_val) == 0) continue; + break; + case kUpb_FieldMode_Array: + if (!val.array_val || upb_Array_Size(val.array_val) == 0) continue; + break; + case kUpb_FieldMode_Scalar: + if (UPB_PRIVATE(_upb_MiniTableField_DataIsZero)(field, &val)) + continue; + break; + } + } + + *out_val = val; + *out_f = + upb_MessageDef_FindFieldByNumber(m, upb_MiniTableField_Number(field)); + *iter = i; + return true; + } + + if (ext_pool) { + // Return any extensions that are set. + size_t count; + const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &count); + if (i - n < count) { + ext += count - 1 - (i - n); + memcpy(out_val, &ext->data, sizeof(*out_val)); + *out_f = upb_DefPool_FindExtensionByMiniTable(ext_pool, ext->ext); + *iter = i; + return true; + } + } + + *iter = i; + return false; +} + +bool _upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m, + int depth) { + size_t iter = kUpb_Message_Begin; + const upb_FieldDef* f; + upb_MessageValue val; + bool ret = true; + + if (--depth == 0) return false; + + _upb_Message_DiscardUnknown_shallow(msg); + + while (upb_Message_Next(msg, m, NULL /*ext_pool*/, &f, &val, &iter)) { + const upb_MessageDef* subm = upb_FieldDef_MessageSubDef(f); + if (!subm) continue; + if (upb_FieldDef_IsMap(f)) { + const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(subm, 2); + const upb_MessageDef* val_m = upb_FieldDef_MessageSubDef(val_f); + upb_Map* map = (upb_Map*)val.map_val; + size_t iter = kUpb_Map_Begin; + + if (!val_m) continue; + + upb_MessageValue map_key, map_val; + while (upb_Map_Next(map, &map_key, &map_val, &iter)) { + if (!_upb_Message_DiscardUnknown((upb_Message*)map_val.msg_val, val_m, + depth)) { + ret = false; + } + } + } else if (upb_FieldDef_IsRepeated(f)) { + const upb_Array* arr = val.array_val; + size_t i, n = upb_Array_Size(arr); + for (i = 0; i < n; i++) { + upb_MessageValue elem = upb_Array_Get(arr, i); + if (!_upb_Message_DiscardUnknown((upb_Message*)elem.msg_val, subm, + depth)) { + ret = false; + } + } + } else { + if (!_upb_Message_DiscardUnknown((upb_Message*)val.msg_val, subm, + depth)) { + ret = false; + } + } + } + + return ret; +} + +bool upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m, + int maxdepth) { + return _upb_Message_DiscardUnknown(msg, m, maxdepth); +} + + +#include +#include +#include + + +// Must be last. + +struct upb_MessageDef { + const UPB_DESC(MessageOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + const upb_MiniTable* layout; + const upb_FileDef* file; + const upb_MessageDef* containing_type; + const char* full_name; + + // Tables for looking up fields by number and name. + upb_inttable itof; + upb_strtable ntof; + + // Looking up fields by json name. + upb_strtable jtof; + + /* All nested defs. + * MEM: We could save some space here by putting nested defs in a contiguous + * region and calculating counts from offsets or vice-versa. */ + const upb_FieldDef* fields; + const upb_OneofDef* oneofs; + const upb_ExtensionRange* ext_ranges; + const upb_StringView* res_names; + const upb_MessageDef* nested_msgs; + const upb_MessageReservedRange* res_ranges; + const upb_EnumDef* nested_enums; + const upb_FieldDef* nested_exts; + + // TODO: These counters don't need anywhere near 32 bits. + int field_count; + int real_oneof_count; + int oneof_count; + int ext_range_count; + int res_range_count; + int res_name_count; + int nested_msg_count; + int nested_enum_count; + int nested_ext_count; + bool in_message_set; + bool is_sorted; + upb_WellKnown well_known_type; +#if UINTPTR_MAX == 0xffffffff + uint32_t padding; // Increase size to a multiple of 8. +#endif +}; + +static void assign_msg_wellknowntype(upb_MessageDef* m) { + const char* name = m->full_name; + if (name == NULL) { + m->well_known_type = kUpb_WellKnown_Unspecified; + return; + } + if (!strcmp(name, "google.protobuf.Any")) { + m->well_known_type = kUpb_WellKnown_Any; + } else if (!strcmp(name, "google.protobuf.FieldMask")) { + m->well_known_type = kUpb_WellKnown_FieldMask; + } else if (!strcmp(name, "google.protobuf.Duration")) { + m->well_known_type = kUpb_WellKnown_Duration; + } else if (!strcmp(name, "google.protobuf.Timestamp")) { + m->well_known_type = kUpb_WellKnown_Timestamp; + } else if (!strcmp(name, "google.protobuf.DoubleValue")) { + m->well_known_type = kUpb_WellKnown_DoubleValue; + } else if (!strcmp(name, "google.protobuf.FloatValue")) { + m->well_known_type = kUpb_WellKnown_FloatValue; + } else if (!strcmp(name, "google.protobuf.Int64Value")) { + m->well_known_type = kUpb_WellKnown_Int64Value; + } else if (!strcmp(name, "google.protobuf.UInt64Value")) { + m->well_known_type = kUpb_WellKnown_UInt64Value; + } else if (!strcmp(name, "google.protobuf.Int32Value")) { + m->well_known_type = kUpb_WellKnown_Int32Value; + } else if (!strcmp(name, "google.protobuf.UInt32Value")) { + m->well_known_type = kUpb_WellKnown_UInt32Value; + } else if (!strcmp(name, "google.protobuf.BoolValue")) { + m->well_known_type = kUpb_WellKnown_BoolValue; + } else if (!strcmp(name, "google.protobuf.StringValue")) { + m->well_known_type = kUpb_WellKnown_StringValue; + } else if (!strcmp(name, "google.protobuf.BytesValue")) { + m->well_known_type = kUpb_WellKnown_BytesValue; + } else if (!strcmp(name, "google.protobuf.Value")) { + m->well_known_type = kUpb_WellKnown_Value; + } else if (!strcmp(name, "google.protobuf.ListValue")) { + m->well_known_type = kUpb_WellKnown_ListValue; + } else if (!strcmp(name, "google.protobuf.Struct")) { + m->well_known_type = kUpb_WellKnown_Struct; + } else { + m->well_known_type = kUpb_WellKnown_Unspecified; + } +} + +upb_MessageDef* _upb_MessageDef_At(const upb_MessageDef* m, int i) { + return (upb_MessageDef*)&m[i]; +} + +bool _upb_MessageDef_IsValidExtensionNumber(const upb_MessageDef* m, int n) { + for (int i = 0; i < m->ext_range_count; i++) { + const upb_ExtensionRange* r = upb_MessageDef_ExtensionRange(m, i); + if (upb_ExtensionRange_Start(r) <= n && n < upb_ExtensionRange_End(r)) { + return true; + } + } + return false; +} + +const UPB_DESC(MessageOptions) * + upb_MessageDef_Options(const upb_MessageDef* m) { + return m->opts; +} + +bool upb_MessageDef_HasOptions(const upb_MessageDef* m) { + return m->opts != (void*)kUpbDefOptDefault; +} + +const UPB_DESC(FeatureSet) * + upb_MessageDef_ResolvedFeatures(const upb_MessageDef* m) { + return m->resolved_features; +} + +const char* upb_MessageDef_FullName(const upb_MessageDef* m) { + return m->full_name; +} + +const upb_FileDef* upb_MessageDef_File(const upb_MessageDef* m) { + return m->file; +} + +const upb_MessageDef* upb_MessageDef_ContainingType(const upb_MessageDef* m) { + return m->containing_type; +} + +const char* upb_MessageDef_Name(const upb_MessageDef* m) { + return _upb_DefBuilder_FullToShort(m->full_name); +} + +upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m) { + return upb_FileDef_Syntax(m->file); +} + +const upb_FieldDef* upb_MessageDef_FindFieldByNumber(const upb_MessageDef* m, + uint32_t i) { + upb_value val; + return upb_inttable_lookup(&m->itof, i, &val) ? upb_value_getconstptr(val) + : NULL; +} + +const upb_FieldDef* upb_MessageDef_FindFieldByNameWithSize( + const upb_MessageDef* m, const char* name, size_t size) { + upb_value val; + + if (!upb_strtable_lookup2(&m->ntof, name, size, &val)) { + return NULL; + } + + return _upb_DefType_Unpack(val, UPB_DEFTYPE_FIELD); +} + +const upb_OneofDef* upb_MessageDef_FindOneofByNameWithSize( + const upb_MessageDef* m, const char* name, size_t size) { + upb_value val; + + if (!upb_strtable_lookup2(&m->ntof, name, size, &val)) { + return NULL; + } + + return _upb_DefType_Unpack(val, UPB_DEFTYPE_ONEOF); +} + +bool _upb_MessageDef_Insert(upb_MessageDef* m, const char* name, size_t len, + upb_value v, upb_Arena* a) { + return upb_strtable_insert(&m->ntof, name, len, v, a); +} + +bool upb_MessageDef_FindByNameWithSize(const upb_MessageDef* m, + const char* name, size_t len, + const upb_FieldDef** out_f, + const upb_OneofDef** out_o) { + upb_value val; + + if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { + return false; + } + + const upb_FieldDef* f = _upb_DefType_Unpack(val, UPB_DEFTYPE_FIELD); + const upb_OneofDef* o = _upb_DefType_Unpack(val, UPB_DEFTYPE_ONEOF); + if (out_f) *out_f = f; + if (out_o) *out_o = o; + return f || o; /* False if this was a JSON name. */ +} + +const upb_FieldDef* upb_MessageDef_FindByJsonNameWithSize( + const upb_MessageDef* m, const char* name, size_t size) { + upb_value val; + + if (upb_strtable_lookup2(&m->jtof, name, size, &val)) { + return upb_value_getconstptr(val); + } + + if (!upb_strtable_lookup2(&m->ntof, name, size, &val)) { + return NULL; + } + + return _upb_DefType_Unpack(val, UPB_DEFTYPE_FIELD); +} + +int upb_MessageDef_ExtensionRangeCount(const upb_MessageDef* m) { + return m->ext_range_count; +} + +int upb_MessageDef_ReservedRangeCount(const upb_MessageDef* m) { + return m->res_range_count; +} + +int upb_MessageDef_ReservedNameCount(const upb_MessageDef* m) { + return m->res_name_count; +} + +int upb_MessageDef_FieldCount(const upb_MessageDef* m) { + return m->field_count; +} + +int upb_MessageDef_OneofCount(const upb_MessageDef* m) { + return m->oneof_count; +} + +int upb_MessageDef_RealOneofCount(const upb_MessageDef* m) { + return m->real_oneof_count; +} + +int upb_MessageDef_NestedMessageCount(const upb_MessageDef* m) { + return m->nested_msg_count; +} + +int upb_MessageDef_NestedEnumCount(const upb_MessageDef* m) { + return m->nested_enum_count; +} + +int upb_MessageDef_NestedExtensionCount(const upb_MessageDef* m) { + return m->nested_ext_count; +} + +const upb_MiniTable* upb_MessageDef_MiniTable(const upb_MessageDef* m) { + return m->layout; +} + +const upb_ExtensionRange* upb_MessageDef_ExtensionRange(const upb_MessageDef* m, + int i) { + UPB_ASSERT(0 <= i && i < m->ext_range_count); + return _upb_ExtensionRange_At(m->ext_ranges, i); +} + +const upb_MessageReservedRange* upb_MessageDef_ReservedRange( + const upb_MessageDef* m, int i) { + UPB_ASSERT(0 <= i && i < m->res_range_count); + return _upb_MessageReservedRange_At(m->res_ranges, i); +} + +upb_StringView upb_MessageDef_ReservedName(const upb_MessageDef* m, int i) { + UPB_ASSERT(0 <= i && i < m->res_name_count); + return m->res_names[i]; +} + +const upb_FieldDef* upb_MessageDef_Field(const upb_MessageDef* m, int i) { + UPB_ASSERT(0 <= i && i < m->field_count); + return _upb_FieldDef_At(m->fields, i); +} + +const upb_OneofDef* upb_MessageDef_Oneof(const upb_MessageDef* m, int i) { + UPB_ASSERT(0 <= i && i < m->oneof_count); + return _upb_OneofDef_At(m->oneofs, i); +} + +const upb_MessageDef* upb_MessageDef_NestedMessage(const upb_MessageDef* m, + int i) { + UPB_ASSERT(0 <= i && i < m->nested_msg_count); + return &m->nested_msgs[i]; +} + +const upb_EnumDef* upb_MessageDef_NestedEnum(const upb_MessageDef* m, int i) { + UPB_ASSERT(0 <= i && i < m->nested_enum_count); + return _upb_EnumDef_At(m->nested_enums, i); +} + +const upb_FieldDef* upb_MessageDef_NestedExtension(const upb_MessageDef* m, + int i) { + UPB_ASSERT(0 <= i && i < m->nested_ext_count); + return _upb_FieldDef_At(m->nested_exts, i); +} + +upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef* m) { + return m->well_known_type; +} + +bool _upb_MessageDef_InMessageSet(const upb_MessageDef* m) { + return m->in_message_set; +} + +const upb_FieldDef* upb_MessageDef_FindFieldByName(const upb_MessageDef* m, + const char* name) { + return upb_MessageDef_FindFieldByNameWithSize(m, name, strlen(name)); +} + +const upb_OneofDef* upb_MessageDef_FindOneofByName(const upb_MessageDef* m, + const char* name) { + return upb_MessageDef_FindOneofByNameWithSize(m, name, strlen(name)); +} + +bool upb_MessageDef_IsMapEntry(const upb_MessageDef* m) { + return UPB_DESC(MessageOptions_map_entry)(m->opts); +} + +bool upb_MessageDef_IsMessageSet(const upb_MessageDef* m) { + return UPB_DESC(MessageOptions_message_set_wire_format)(m->opts); +} + +static upb_MiniTable* _upb_MessageDef_MakeMiniTable(upb_DefBuilder* ctx, + const upb_MessageDef* m) { + upb_StringView desc; + // Note: this will assign layout_index for fields, so upb_FieldDef_MiniTable() + // is safe to call only after this call. + bool ok = upb_MessageDef_MiniDescriptorEncode(m, ctx->tmp_arena, &desc); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + void** scratch_data = _upb_DefPool_ScratchData(ctx->symtab); + size_t* scratch_size = _upb_DefPool_ScratchSize(ctx->symtab); + upb_MiniTable* ret = upb_MiniTable_BuildWithBuf( + desc.data, desc.size, ctx->platform, ctx->arena, scratch_data, + scratch_size, ctx->status); + if (!ret) _upb_DefBuilder_FailJmp(ctx); + + return ret; +} + +void _upb_MessageDef_Resolve(upb_DefBuilder* ctx, upb_MessageDef* m) { + for (int i = 0; i < m->field_count; i++) { + upb_FieldDef* f = (upb_FieldDef*)upb_MessageDef_Field(m, i); + _upb_FieldDef_Resolve(ctx, m->full_name, f); + } + + m->in_message_set = false; + for (int i = 0; i < upb_MessageDef_NestedExtensionCount(m); i++) { + upb_FieldDef* ext = (upb_FieldDef*)upb_MessageDef_NestedExtension(m, i); + _upb_FieldDef_Resolve(ctx, m->full_name, ext); + if (upb_FieldDef_Type(ext) == kUpb_FieldType_Message && + upb_FieldDef_Label(ext) == kUpb_Label_Optional && + upb_FieldDef_MessageSubDef(ext) == m && + UPB_DESC(MessageOptions_message_set_wire_format)( + upb_MessageDef_Options(upb_FieldDef_ContainingType(ext)))) { + m->in_message_set = true; + } + } + + for (int i = 0; i < upb_MessageDef_NestedMessageCount(m); i++) { + upb_MessageDef* n = (upb_MessageDef*)upb_MessageDef_NestedMessage(m, i); + _upb_MessageDef_Resolve(ctx, n); + } +} + +void _upb_MessageDef_InsertField(upb_DefBuilder* ctx, upb_MessageDef* m, + const upb_FieldDef* f) { + const int32_t field_number = upb_FieldDef_Number(f); + + if (field_number <= 0 || field_number > kUpb_MaxFieldNumber) { + _upb_DefBuilder_Errf(ctx, "invalid field number (%u)", field_number); + } + + const char* json_name = upb_FieldDef_JsonName(f); + const char* shortname = upb_FieldDef_Name(f); + const size_t shortnamelen = strlen(shortname); + + upb_value v = upb_value_constptr(f); + + upb_value existing_v; + if (upb_strtable_lookup(&m->ntof, shortname, &existing_v)) { + _upb_DefBuilder_Errf(ctx, "duplicate field name (%s)", shortname); + } + + const upb_value field_v = _upb_DefType_Pack(f, UPB_DEFTYPE_FIELD); + bool ok = + _upb_MessageDef_Insert(m, shortname, shortnamelen, field_v, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + bool skip_json_conflicts = + UPB_DESC(MessageOptions_deprecated_legacy_json_field_conflicts)( + upb_MessageDef_Options(m)); + if (!skip_json_conflicts && strcmp(shortname, json_name) != 0 && + UPB_DESC(FeatureSet_json_format)(m->resolved_features) == + UPB_DESC(FeatureSet_ALLOW) && + upb_strtable_lookup(&m->ntof, json_name, &v)) { + _upb_DefBuilder_Errf( + ctx, "duplicate json_name for (%s) with original field name (%s)", + shortname, json_name); + } + + if (upb_strtable_lookup(&m->jtof, json_name, &v)) { + if (!skip_json_conflicts) { + _upb_DefBuilder_Errf(ctx, "duplicate json_name (%s)", json_name); + } + } else { + const size_t json_size = strlen(json_name); + ok = upb_strtable_insert(&m->jtof, json_name, json_size, + upb_value_constptr(f), ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + } + + if (upb_inttable_lookup(&m->itof, field_number, NULL)) { + _upb_DefBuilder_Errf(ctx, "duplicate field number (%u)", field_number); + } + + ok = upb_inttable_insert(&m->itof, field_number, v, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); +} + +void _upb_MessageDef_CreateMiniTable(upb_DefBuilder* ctx, upb_MessageDef* m) { + if (ctx->layout == NULL) { + m->layout = _upb_MessageDef_MakeMiniTable(ctx, m); + } else { + m->layout = upb_MiniTableFile_Message(ctx->layout, ctx->msg_count++); + UPB_ASSERT(m->field_count == upb_MiniTable_FieldCount(m->layout)); + + // We don't need the result of this call, but it will assign layout_index + // for all the fields in O(n lg n) time. + _upb_FieldDefs_Sorted(m->fields, m->field_count, ctx->tmp_arena); + } + + for (int i = 0; i < m->nested_msg_count; i++) { + upb_MessageDef* nested = + (upb_MessageDef*)upb_MessageDef_NestedMessage(m, i); + _upb_MessageDef_CreateMiniTable(ctx, nested); + } +} + +void _upb_MessageDef_LinkMiniTable(upb_DefBuilder* ctx, + const upb_MessageDef* m) { + for (int i = 0; i < upb_MessageDef_NestedExtensionCount(m); i++) { + const upb_FieldDef* ext = upb_MessageDef_NestedExtension(m, i); + _upb_FieldDef_BuildMiniTableExtension(ctx, ext); + } + + for (int i = 0; i < m->nested_msg_count; i++) { + _upb_MessageDef_LinkMiniTable(ctx, upb_MessageDef_NestedMessage(m, i)); + } + + if (ctx->layout) return; + + for (int i = 0; i < m->field_count; i++) { + const upb_FieldDef* f = upb_MessageDef_Field(m, i); + const upb_MessageDef* sub_m = upb_FieldDef_MessageSubDef(f); + const upb_EnumDef* sub_e = upb_FieldDef_EnumSubDef(f); + const int layout_index = _upb_FieldDef_LayoutIndex(f); + upb_MiniTable* mt = (upb_MiniTable*)upb_MessageDef_MiniTable(m); + + UPB_ASSERT(layout_index < m->field_count); + upb_MiniTableField* mt_f = + (upb_MiniTableField*)&m->layout->UPB_PRIVATE(fields)[layout_index]; + if (sub_m) { + if (!mt->UPB_PRIVATE(subs)) { + _upb_DefBuilder_Errf(ctx, "unexpected submsg for (%s)", m->full_name); + } + UPB_ASSERT(mt_f); + UPB_ASSERT(sub_m->layout); + if (UPB_UNLIKELY(!upb_MiniTable_SetSubMessage(mt, mt_f, sub_m->layout))) { + _upb_DefBuilder_Errf(ctx, "invalid submsg for (%s)", m->full_name); + } + } else if (_upb_FieldDef_IsClosedEnum(f)) { + const upb_MiniTableEnum* mt_e = _upb_EnumDef_MiniTable(sub_e); + if (UPB_UNLIKELY(!upb_MiniTable_SetSubEnum(mt, mt_f, mt_e))) { + _upb_DefBuilder_Errf(ctx, "invalid subenum for (%s)", m->full_name); + } + } + } + +#ifndef NDEBUG + for (int i = 0; i < m->field_count; i++) { + const upb_FieldDef* f = upb_MessageDef_Field(m, i); + const int layout_index = _upb_FieldDef_LayoutIndex(f); + UPB_ASSERT(layout_index < upb_MiniTable_FieldCount(m->layout)); + const upb_MiniTableField* mt_f = + &m->layout->UPB_PRIVATE(fields)[layout_index]; + UPB_ASSERT(upb_FieldDef_Type(f) == upb_MiniTableField_Type(mt_f)); + UPB_ASSERT(upb_FieldDef_CType(f) == upb_MiniTableField_CType(mt_f)); + UPB_ASSERT(upb_FieldDef_HasPresence(f) == + upb_MiniTableField_HasPresence(mt_f)); + } +#endif +} + +static bool _upb_MessageDef_ValidateUtf8(const upb_MessageDef* m) { + bool has_string = false; + for (int i = 0; i < m->field_count; i++) { + const upb_FieldDef* f = upb_MessageDef_Field(m, i); + // Old binaries do not recognize the field-level "FlipValidateUtf8" wire + // modifier, so we do not actually have field-level control for old + // binaries. Given this, we judge that the better failure mode is to be + // more lax than intended, rather than more strict. To achieve this, we + // only mark the message with the ValidateUtf8 modifier if *all* fields + // validate UTF-8. + if (!_upb_FieldDef_ValidateUtf8(f)) return false; + if (upb_FieldDef_Type(f) == kUpb_FieldType_String) has_string = true; + } + return has_string; +} + +static uint64_t _upb_MessageDef_Modifiers(const upb_MessageDef* m) { + uint64_t out = 0; + + if (UPB_DESC(FeatureSet_repeated_field_encoding(m->resolved_features)) == + UPB_DESC(FeatureSet_PACKED)) { + out |= kUpb_MessageModifier_DefaultIsPacked; + } + + if (_upb_MessageDef_ValidateUtf8(m)) { + out |= kUpb_MessageModifier_ValidateUtf8; + } + + if (m->ext_range_count) { + out |= kUpb_MessageModifier_IsExtendable; + } + + return out; +} + +static bool _upb_MessageDef_EncodeMap(upb_DescState* s, const upb_MessageDef* m, + upb_Arena* a) { + if (m->field_count != 2) return false; + + const upb_FieldDef* key_field = upb_MessageDef_Field(m, 0); + const upb_FieldDef* val_field = upb_MessageDef_Field(m, 1); + if (key_field == NULL || val_field == NULL) return false; + + UPB_ASSERT(_upb_FieldDef_LayoutIndex(key_field) == 0); + UPB_ASSERT(_upb_FieldDef_LayoutIndex(val_field) == 1); + + s->ptr = upb_MtDataEncoder_EncodeMap( + &s->e, s->ptr, upb_FieldDef_Type(key_field), upb_FieldDef_Type(val_field), + _upb_FieldDef_Modifiers(key_field), _upb_FieldDef_Modifiers(val_field)); + return true; +} + +static bool _upb_MessageDef_EncodeMessage(upb_DescState* s, + const upb_MessageDef* m, + upb_Arena* a) { + const upb_FieldDef** sorted = NULL; + if (!m->is_sorted) { + sorted = _upb_FieldDefs_Sorted(m->fields, m->field_count, a); + if (!sorted) return false; + } + + s->ptr = upb_MtDataEncoder_StartMessage(&s->e, s->ptr, + _upb_MessageDef_Modifiers(m)); + + for (int i = 0; i < m->field_count; i++) { + const upb_FieldDef* f = sorted ? sorted[i] : upb_MessageDef_Field(m, i); + const upb_FieldType type = upb_FieldDef_Type(f); + const int number = upb_FieldDef_Number(f); + const uint64_t modifiers = _upb_FieldDef_Modifiers(f); + + if (!_upb_DescState_Grow(s, a)) return false; + s->ptr = upb_MtDataEncoder_PutField(&s->e, s->ptr, type, number, modifiers); + } + + for (int i = 0; i < m->real_oneof_count; i++) { + if (!_upb_DescState_Grow(s, a)) return false; + s->ptr = upb_MtDataEncoder_StartOneof(&s->e, s->ptr); + + const upb_OneofDef* o = upb_MessageDef_Oneof(m, i); + const int field_count = upb_OneofDef_FieldCount(o); + for (int j = 0; j < field_count; j++) { + const int number = upb_FieldDef_Number(upb_OneofDef_Field(o, j)); + + if (!_upb_DescState_Grow(s, a)) return false; + s->ptr = upb_MtDataEncoder_PutOneofField(&s->e, s->ptr, number); + } + } + + return true; +} + +static bool _upb_MessageDef_EncodeMessageSet(upb_DescState* s, + const upb_MessageDef* m, + upb_Arena* a) { + s->ptr = upb_MtDataEncoder_EncodeMessageSet(&s->e, s->ptr); + + return true; +} + +bool upb_MessageDef_MiniDescriptorEncode(const upb_MessageDef* m, upb_Arena* a, + upb_StringView* out) { + upb_DescState s; + _upb_DescState_Init(&s); + + if (!_upb_DescState_Grow(&s, a)) return false; + + if (upb_MessageDef_IsMapEntry(m)) { + if (!_upb_MessageDef_EncodeMap(&s, m, a)) return false; + } else if (UPB_DESC(MessageOptions_message_set_wire_format)(m->opts)) { + if (!_upb_MessageDef_EncodeMessageSet(&s, m, a)) return false; + } else { + if (!_upb_MessageDef_EncodeMessage(&s, m, a)) return false; + } + + if (!_upb_DescState_Grow(&s, a)) return false; + *s.ptr = '\0'; + + out->data = s.buf; + out->size = s.ptr - s.buf; + return true; +} + +static upb_StringView* _upb_ReservedNames_New(upb_DefBuilder* ctx, int n, + const upb_StringView* protos) { + upb_StringView* sv = _upb_DefBuilder_Alloc(ctx, sizeof(upb_StringView) * n); + for (int i = 0; i < n; i++) { + sv[i].data = + upb_strdup2(protos[i].data, protos[i].size, _upb_DefBuilder_Arena(ctx)); + sv[i].size = protos[i].size; + } + return sv; +} + +static void create_msgdef(upb_DefBuilder* ctx, const char* prefix, + const UPB_DESC(DescriptorProto*) msg_proto, + const UPB_DESC(FeatureSet*) parent_features, + const upb_MessageDef* containing_type, + upb_MessageDef* m) { + const UPB_DESC(OneofDescriptorProto)* const* oneofs; + const UPB_DESC(FieldDescriptorProto)* const* fields; + const UPB_DESC(DescriptorProto_ExtensionRange)* const* ext_ranges; + const UPB_DESC(DescriptorProto_ReservedRange)* const* res_ranges; + const upb_StringView* res_names; + size_t n_oneof, n_field, n_enum, n_ext, n_msg; + size_t n_ext_range, n_res_range, n_res_name; + upb_StringView name; + + UPB_DEF_SET_OPTIONS(m->opts, DescriptorProto, MessageOptions, msg_proto); + m->resolved_features = _upb_DefBuilder_ResolveFeatures( + ctx, parent_features, UPB_DESC(MessageOptions_features)(m->opts)); + + // Must happen before _upb_DefBuilder_Add() + m->file = _upb_DefBuilder_File(ctx); + + m->containing_type = containing_type; + m->is_sorted = true; + + name = UPB_DESC(DescriptorProto_name)(msg_proto); + + m->full_name = _upb_DefBuilder_MakeFullName(ctx, prefix, name); + _upb_DefBuilder_Add(ctx, m->full_name, _upb_DefType_Pack(m, UPB_DEFTYPE_MSG)); + + oneofs = UPB_DESC(DescriptorProto_oneof_decl)(msg_proto, &n_oneof); + fields = UPB_DESC(DescriptorProto_field)(msg_proto, &n_field); + ext_ranges = + UPB_DESC(DescriptorProto_extension_range)(msg_proto, &n_ext_range); + res_ranges = + UPB_DESC(DescriptorProto_reserved_range)(msg_proto, &n_res_range); + res_names = UPB_DESC(DescriptorProto_reserved_name)(msg_proto, &n_res_name); + + bool ok = upb_inttable_init(&m->itof, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + ok = upb_strtable_init(&m->ntof, n_oneof + n_field, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + ok = upb_strtable_init(&m->jtof, n_field, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + m->oneof_count = n_oneof; + m->oneofs = _upb_OneofDefs_New(ctx, n_oneof, oneofs, m->resolved_features, m); + + m->field_count = n_field; + m->fields = _upb_FieldDefs_New(ctx, n_field, fields, m->resolved_features, + m->full_name, m, &m->is_sorted); + + // Message Sets may not contain fields. + if (UPB_UNLIKELY(UPB_DESC(MessageOptions_message_set_wire_format)(m->opts))) { + if (UPB_UNLIKELY(n_field > 0)) { + _upb_DefBuilder_Errf(ctx, "invalid message set (%s)", m->full_name); + } + } + + m->ext_range_count = n_ext_range; + m->ext_ranges = _upb_ExtensionRanges_New(ctx, n_ext_range, ext_ranges, + m->resolved_features, m); + + m->res_range_count = n_res_range; + m->res_ranges = + _upb_MessageReservedRanges_New(ctx, n_res_range, res_ranges, m); + + m->res_name_count = n_res_name; + m->res_names = _upb_ReservedNames_New(ctx, n_res_name, res_names); + + const size_t synthetic_count = _upb_OneofDefs_Finalize(ctx, m); + m->real_oneof_count = m->oneof_count - synthetic_count; + + assign_msg_wellknowntype(m); + upb_inttable_compact(&m->itof, ctx->arena); + + const UPB_DESC(EnumDescriptorProto)* const* enums = + UPB_DESC(DescriptorProto_enum_type)(msg_proto, &n_enum); + m->nested_enum_count = n_enum; + m->nested_enums = + _upb_EnumDefs_New(ctx, n_enum, enums, m->resolved_features, m); + + const UPB_DESC(FieldDescriptorProto)* const* exts = + UPB_DESC(DescriptorProto_extension)(msg_proto, &n_ext); + m->nested_ext_count = n_ext; + m->nested_exts = _upb_Extensions_New(ctx, n_ext, exts, m->resolved_features, + m->full_name, m); + + const UPB_DESC(DescriptorProto)* const* msgs = + UPB_DESC(DescriptorProto_nested_type)(msg_proto, &n_msg); + m->nested_msg_count = n_msg; + m->nested_msgs = + _upb_MessageDefs_New(ctx, n_msg, msgs, m->resolved_features, m); +} + +// Allocate and initialize an array of |n| message defs. +upb_MessageDef* _upb_MessageDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(DescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) + parent_features, + const upb_MessageDef* containing_type) { + _upb_DefType_CheckPadding(sizeof(upb_MessageDef)); + + const char* name = containing_type ? containing_type->full_name + : _upb_FileDef_RawPackage(ctx->file); + + upb_MessageDef* m = _upb_DefBuilder_Alloc(ctx, sizeof(upb_MessageDef) * n); + for (int i = 0; i < n; i++) { + create_msgdef(ctx, name, protos[i], parent_features, containing_type, + &m[i]); + } + return m; +} + + +// Must be last. + +struct upb_MessageReservedRange { + int32_t start; + int32_t end; +}; + +upb_MessageReservedRange* _upb_MessageReservedRange_At( + const upb_MessageReservedRange* r, int i) { + return (upb_MessageReservedRange*)&r[i]; +} + +int32_t upb_MessageReservedRange_Start(const upb_MessageReservedRange* r) { + return r->start; +} +int32_t upb_MessageReservedRange_End(const upb_MessageReservedRange* r) { + return r->end; +} + +upb_MessageReservedRange* _upb_MessageReservedRanges_New( + upb_DefBuilder* ctx, int n, + const UPB_DESC(DescriptorProto_ReservedRange) * const* protos, + const upb_MessageDef* m) { + upb_MessageReservedRange* r = + _upb_DefBuilder_Alloc(ctx, sizeof(upb_MessageReservedRange) * n); + + for (int i = 0; i < n; i++) { + const int32_t start = + UPB_DESC(DescriptorProto_ReservedRange_start)(protos[i]); + const int32_t end = UPB_DESC(DescriptorProto_ReservedRange_end)(protos[i]); + const int32_t max = kUpb_MaxFieldNumber + 1; + + // A full validation would also check that each range is disjoint, and that + // none of the fields overlap with the extension ranges, but we are just + // sanity checking here. + if (start < 1 || end <= start || end > max) { + _upb_DefBuilder_Errf(ctx, + "Reserved range (%d, %d) is invalid, message=%s\n", + (int)start, (int)end, upb_MessageDef_FullName(m)); + } + + r[i].start = start; + r[i].end = end; + } + + return r; +} + + + +// Must be last. + +struct upb_MethodDef { + const UPB_DESC(MethodOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + upb_ServiceDef* service; + const char* full_name; + const upb_MessageDef* input_type; + const upb_MessageDef* output_type; + int index; + bool client_streaming; + bool server_streaming; +}; + +upb_MethodDef* _upb_MethodDef_At(const upb_MethodDef* m, int i) { + return (upb_MethodDef*)&m[i]; +} + +const upb_ServiceDef* upb_MethodDef_Service(const upb_MethodDef* m) { + return m->service; +} + +const UPB_DESC(MethodOptions) * upb_MethodDef_Options(const upb_MethodDef* m) { + return m->opts; +} + +bool upb_MethodDef_HasOptions(const upb_MethodDef* m) { + return m->opts != (void*)kUpbDefOptDefault; +} + +const UPB_DESC(FeatureSet) * + upb_MethodDef_ResolvedFeatures(const upb_MethodDef* m) { + return m->resolved_features; +} + +const char* upb_MethodDef_FullName(const upb_MethodDef* m) { + return m->full_name; +} + +const char* upb_MethodDef_Name(const upb_MethodDef* m) { + return _upb_DefBuilder_FullToShort(m->full_name); +} + +int upb_MethodDef_Index(const upb_MethodDef* m) { return m->index; } + +const upb_MessageDef* upb_MethodDef_InputType(const upb_MethodDef* m) { + return m->input_type; +} + +const upb_MessageDef* upb_MethodDef_OutputType(const upb_MethodDef* m) { + return m->output_type; +} + +bool upb_MethodDef_ClientStreaming(const upb_MethodDef* m) { + return m->client_streaming; +} + +bool upb_MethodDef_ServerStreaming(const upb_MethodDef* m) { + return m->server_streaming; +} + +static void create_method(upb_DefBuilder* ctx, + const UPB_DESC(MethodDescriptorProto*) method_proto, + const UPB_DESC(FeatureSet*) parent_features, + upb_ServiceDef* s, upb_MethodDef* m) { + UPB_DEF_SET_OPTIONS(m->opts, MethodDescriptorProto, MethodOptions, + method_proto); + m->resolved_features = _upb_DefBuilder_ResolveFeatures( + ctx, parent_features, UPB_DESC(MethodOptions_features)(m->opts)); + + upb_StringView name = UPB_DESC(MethodDescriptorProto_name)(method_proto); + + m->service = s; + m->full_name = + _upb_DefBuilder_MakeFullName(ctx, upb_ServiceDef_FullName(s), name); + m->client_streaming = + UPB_DESC(MethodDescriptorProto_client_streaming)(method_proto); + m->server_streaming = + UPB_DESC(MethodDescriptorProto_server_streaming)(method_proto); + m->input_type = _upb_DefBuilder_Resolve( + ctx, m->full_name, m->full_name, + UPB_DESC(MethodDescriptorProto_input_type)(method_proto), + UPB_DEFTYPE_MSG); + m->output_type = _upb_DefBuilder_Resolve( + ctx, m->full_name, m->full_name, + UPB_DESC(MethodDescriptorProto_output_type)(method_proto), + UPB_DEFTYPE_MSG); +} + +// Allocate and initialize an array of |n| method defs belonging to |s|. +upb_MethodDef* _upb_MethodDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(MethodDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + upb_ServiceDef* s) { + upb_MethodDef* m = _upb_DefBuilder_Alloc(ctx, sizeof(upb_MethodDef) * n); + for (int i = 0; i < n; i++) { + create_method(ctx, protos[i], parent_features, s, &m[i]); + m[i].index = i; + } + return m; +} + + +#include +#include +#include + + +// Must be last. + +struct upb_OneofDef { + const UPB_DESC(OneofOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + const upb_MessageDef* parent; + const char* full_name; + int field_count; + bool synthetic; + const upb_FieldDef** fields; + upb_strtable ntof; // lookup a field by name + upb_inttable itof; // lookup a field by number (index) +}; + +upb_OneofDef* _upb_OneofDef_At(const upb_OneofDef* o, int i) { + return (upb_OneofDef*)&o[i]; +} + +const UPB_DESC(OneofOptions) * upb_OneofDef_Options(const upb_OneofDef* o) { + return o->opts; +} + +bool upb_OneofDef_HasOptions(const upb_OneofDef* o) { + return o->opts != (void*)kUpbDefOptDefault; +} + +const UPB_DESC(FeatureSet) * + upb_OneofDef_ResolvedFeatures(const upb_OneofDef* o) { + return o->resolved_features; +} + +const char* upb_OneofDef_FullName(const upb_OneofDef* o) { + return o->full_name; +} + +const char* upb_OneofDef_Name(const upb_OneofDef* o) { + return _upb_DefBuilder_FullToShort(o->full_name); +} + +const upb_MessageDef* upb_OneofDef_ContainingType(const upb_OneofDef* o) { + return o->parent; +} + +int upb_OneofDef_FieldCount(const upb_OneofDef* o) { return o->field_count; } + +const upb_FieldDef* upb_OneofDef_Field(const upb_OneofDef* o, int i) { + UPB_ASSERT(i < o->field_count); + return o->fields[i]; +} + +int upb_OneofDef_numfields(const upb_OneofDef* o) { return o->field_count; } + +uint32_t upb_OneofDef_Index(const upb_OneofDef* o) { + // Compute index in our parent's array. + return o - upb_MessageDef_Oneof(o->parent, 0); +} + +bool upb_OneofDef_IsSynthetic(const upb_OneofDef* o) { return o->synthetic; } + +const upb_FieldDef* upb_OneofDef_LookupNameWithSize(const upb_OneofDef* o, + const char* name, + size_t size) { + upb_value val; + return upb_strtable_lookup2(&o->ntof, name, size, &val) + ? upb_value_getptr(val) + : NULL; +} + +const upb_FieldDef* upb_OneofDef_LookupName(const upb_OneofDef* o, + const char* name) { + return upb_OneofDef_LookupNameWithSize(o, name, strlen(name)); +} + +const upb_FieldDef* upb_OneofDef_LookupNumber(const upb_OneofDef* o, + uint32_t num) { + upb_value val; + return upb_inttable_lookup(&o->itof, num, &val) ? upb_value_getptr(val) + : NULL; +} + +void _upb_OneofDef_Insert(upb_DefBuilder* ctx, upb_OneofDef* o, + const upb_FieldDef* f, const char* name, + size_t size) { + o->field_count++; + if (_upb_FieldDef_IsProto3Optional(f)) o->synthetic = true; + + const int number = upb_FieldDef_Number(f); + const upb_value v = upb_value_constptr(f); + + // TODO: This lookup is unfortunate because we also perform it when + // inserting into the message's table. Unfortunately that step occurs after + // this one and moving things around could be tricky so let's leave it for + // a future refactoring. + const bool number_exists = upb_inttable_lookup(&o->itof, number, NULL); + if (UPB_UNLIKELY(number_exists)) { + _upb_DefBuilder_Errf(ctx, "oneof fields have the same number (%d)", number); + } + + // TODO: More redundant work happening here. + const bool name_exists = upb_strtable_lookup2(&o->ntof, name, size, NULL); + if (UPB_UNLIKELY(name_exists)) { + _upb_DefBuilder_Errf(ctx, "oneof fields have the same name (%.*s)", + (int)size, name); + } + + const bool ok = upb_inttable_insert(&o->itof, number, v, ctx->arena) && + upb_strtable_insert(&o->ntof, name, size, v, ctx->arena); + if (UPB_UNLIKELY(!ok)) { + _upb_DefBuilder_OomErr(ctx); + } +} + +// Returns the synthetic count. +size_t _upb_OneofDefs_Finalize(upb_DefBuilder* ctx, upb_MessageDef* m) { + int synthetic_count = 0; + + for (int i = 0; i < upb_MessageDef_OneofCount(m); i++) { + upb_OneofDef* o = (upb_OneofDef*)upb_MessageDef_Oneof(m, i); + + if (o->synthetic && o->field_count != 1) { + _upb_DefBuilder_Errf(ctx, + "Synthetic oneofs must have one field, not %d: %s", + o->field_count, upb_OneofDef_Name(o)); + } + + if (o->synthetic) { + synthetic_count++; + } else if (synthetic_count != 0) { + _upb_DefBuilder_Errf( + ctx, "Synthetic oneofs must be after all other oneofs: %s", + upb_OneofDef_Name(o)); + } + + o->fields = + _upb_DefBuilder_Alloc(ctx, sizeof(upb_FieldDef*) * o->field_count); + o->field_count = 0; + } + + for (int i = 0; i < upb_MessageDef_FieldCount(m); i++) { + const upb_FieldDef* f = upb_MessageDef_Field(m, i); + upb_OneofDef* o = (upb_OneofDef*)upb_FieldDef_ContainingOneof(f); + if (o) { + o->fields[o->field_count++] = f; + } + } + + return synthetic_count; +} + +static void create_oneofdef(upb_DefBuilder* ctx, upb_MessageDef* m, + const UPB_DESC(OneofDescriptorProto*) oneof_proto, + const UPB_DESC(FeatureSet*) parent_features, + const upb_OneofDef* _o) { + upb_OneofDef* o = (upb_OneofDef*)_o; + + UPB_DEF_SET_OPTIONS(o->opts, OneofDescriptorProto, OneofOptions, oneof_proto); + o->resolved_features = _upb_DefBuilder_ResolveFeatures( + ctx, parent_features, UPB_DESC(OneofOptions_features)(o->opts)); + + upb_StringView name = UPB_DESC(OneofDescriptorProto_name)(oneof_proto); + + o->parent = m; + o->full_name = + _upb_DefBuilder_MakeFullName(ctx, upb_MessageDef_FullName(m), name); + o->field_count = 0; + o->synthetic = false; + + if (upb_MessageDef_FindByNameWithSize(m, name.data, name.size, NULL, NULL)) { + _upb_DefBuilder_Errf(ctx, "duplicate oneof name (%s)", o->full_name); + } + + upb_value v = _upb_DefType_Pack(o, UPB_DEFTYPE_ONEOF); + bool ok = _upb_MessageDef_Insert(m, name.data, name.size, v, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + ok = upb_inttable_init(&o->itof, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); + + ok = upb_strtable_init(&o->ntof, 4, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); +} + +// Allocate and initialize an array of |n| oneof defs. +upb_OneofDef* _upb_OneofDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(OneofDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + upb_MessageDef* m) { + _upb_DefType_CheckPadding(sizeof(upb_OneofDef)); + + upb_OneofDef* o = _upb_DefBuilder_Alloc(ctx, sizeof(upb_OneofDef) * n); + for (int i = 0; i < n; i++) { + create_oneofdef(ctx, m, protos[i], parent_features, &o[i]); + } + return o; +} + + + +// Must be last. + +struct upb_ServiceDef { + const UPB_DESC(ServiceOptions*) opts; + const UPB_DESC(FeatureSet*) resolved_features; + const upb_FileDef* file; + const char* full_name; + upb_MethodDef* methods; + int method_count; + int index; +#if UINTPTR_MAX == 0xffffffff + uint32_t padding; // Increase size to a multiple of 8. +#endif +}; + +upb_ServiceDef* _upb_ServiceDef_At(const upb_ServiceDef* s, int index) { + return (upb_ServiceDef*)&s[index]; +} + +const UPB_DESC(ServiceOptions) * + upb_ServiceDef_Options(const upb_ServiceDef* s) { + return s->opts; +} + +bool upb_ServiceDef_HasOptions(const upb_ServiceDef* s) { + return s->opts != (void*)kUpbDefOptDefault; +} + +const UPB_DESC(FeatureSet) * + upb_ServiceDef_ResolvedFeatures(const upb_ServiceDef* s) { + return s->resolved_features; +} + +const char* upb_ServiceDef_FullName(const upb_ServiceDef* s) { + return s->full_name; +} + +const char* upb_ServiceDef_Name(const upb_ServiceDef* s) { + return _upb_DefBuilder_FullToShort(s->full_name); +} + +int upb_ServiceDef_Index(const upb_ServiceDef* s) { return s->index; } + +const upb_FileDef* upb_ServiceDef_File(const upb_ServiceDef* s) { + return s->file; +} + +int upb_ServiceDef_MethodCount(const upb_ServiceDef* s) { + return s->method_count; +} + +const upb_MethodDef* upb_ServiceDef_Method(const upb_ServiceDef* s, int i) { + return (i < 0 || i >= s->method_count) ? NULL + : _upb_MethodDef_At(s->methods, i); +} + +const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s, + const char* name) { + for (int i = 0; i < s->method_count; i++) { + const upb_MethodDef* m = _upb_MethodDef_At(s->methods, i); + if (strcmp(name, upb_MethodDef_Name(m)) == 0) { + return m; + } + } + return NULL; +} + +static void create_service(upb_DefBuilder* ctx, + const UPB_DESC(ServiceDescriptorProto*) svc_proto, + const UPB_DESC(FeatureSet*) parent_features, + upb_ServiceDef* s) { + UPB_DEF_SET_OPTIONS(s->opts, ServiceDescriptorProto, ServiceOptions, + svc_proto); + s->resolved_features = _upb_DefBuilder_ResolveFeatures( + ctx, parent_features, UPB_DESC(ServiceOptions_features)(s->opts)); + + // Must happen before _upb_DefBuilder_Add() + s->file = _upb_DefBuilder_File(ctx); + + upb_StringView name = UPB_DESC(ServiceDescriptorProto_name)(svc_proto); + const char* package = _upb_FileDef_RawPackage(s->file); + s->full_name = _upb_DefBuilder_MakeFullName(ctx, package, name); + _upb_DefBuilder_Add(ctx, s->full_name, + _upb_DefType_Pack(s, UPB_DEFTYPE_SERVICE)); + + size_t n; + const UPB_DESC(MethodDescriptorProto)* const* methods = + UPB_DESC(ServiceDescriptorProto_method)(svc_proto, &n); + s->method_count = n; + s->methods = _upb_MethodDefs_New(ctx, n, methods, s->resolved_features, s); +} + +upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(ServiceDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) + parent_features) { + _upb_DefType_CheckPadding(sizeof(upb_ServiceDef)); + + upb_ServiceDef* s = _upb_DefBuilder_Alloc(ctx, sizeof(upb_ServiceDef) * n); + for (int i = 0; i < n; i++) { + create_service(ctx, protos[i], parent_features, &s[i]); + s[i].index = i; + } + return s; +} + +// This should #undef all macros #defined in def.inc + +#undef UPB_SIZE +#undef UPB_PTR_AT +#undef UPB_MAPTYPE_STRING +#undef UPB_EXPORT +#undef UPB_INLINE +#undef UPB_API +#undef UPB_API_INLINE +#undef UPB_ALIGN_UP +#undef UPB_ALIGN_DOWN +#undef UPB_ALIGN_MALLOC +#undef UPB_ALIGN_OF +#undef UPB_ALIGN_AS +#undef UPB_MALLOC_ALIGN +#undef UPB_LIKELY +#undef UPB_UNLIKELY +#undef UPB_FORCEINLINE +#undef UPB_NOINLINE +#undef UPB_NORETURN +#undef UPB_PRINTF +#undef UPB_MAX +#undef UPB_MIN +#undef UPB_UNUSED +#undef UPB_ASSUME +#undef UPB_ASSERT +#undef UPB_UNREACHABLE +#undef UPB_SETJMP +#undef UPB_LONGJMP +#undef UPB_PTRADD +#undef UPB_MUSTTAIL +#undef UPB_FASTTABLE_SUPPORTED +#undef UPB_FASTTABLE_MASK +#undef UPB_FASTTABLE +#undef UPB_FASTTABLE_INIT +#undef UPB_POISON_MEMORY_REGION +#undef UPB_UNPOISON_MEMORY_REGION +#undef UPB_ASAN +#undef UPB_ASAN_GUARD_SIZE +#undef UPB_CLANG_ASAN +#undef UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN +#undef UPB_DEPRECATED +#undef UPB_GNUC_MIN +#undef UPB_DESCRIPTOR_UPB_H_FILENAME +#undef UPB_DESC +#undef UPB_DESC_MINITABLE +#undef UPB_IS_GOOGLE3 +#undef UPB_ATOMIC +#undef UPB_USE_C11_ATOMICS +#undef UPB_PRIVATE +#undef UPB_ONLYBITS diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/ruby-upb.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/ruby-upb.h new file mode 100755 index 0000000..de7948a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/ruby-upb.h @@ -0,0 +1,14349 @@ +// Ruby is still using proto3 enum semantics for proto2 +#define UPB_DISABLE_CLOSED_ENUM_CHECKING +/* Amalgamated source file */ + +/* + * This is where we define internal portability macros used across upb. + * + * All of these macros are undef'd in undef.inc to avoid leaking them to users. + * + * The correct usage is: + * + * #include "upb/foobar.h" + * #include "upb/baz.h" + * + * // MUST be last included header. + * #include "upb/port/def.inc" + * + * // Code for this file. + * // <...> + * + * // Can be omitted for .c files, required for .h. + * #include "upb/port/undef.inc" + * + * This file is private and must not be included by users! + */ + +#if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201402L) || \ + (defined(_MSC_VER) && _MSC_VER >= 1900)) +#error upb requires C99 or C++14 or MSVC >= 2015. +#endif + +// Portable check for GCC minimum version: +// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +#define UPB_GNUC_MIN(x, y) \ + (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y)) +#else +#define UPB_GNUC_MIN(x, y) 0 +#endif + +#include +#include +#include +#include +#include + +#ifndef UINTPTR_MAX +Error, UINTPTR_MAX is undefined +#endif + +#if UINTPTR_MAX == 0xffffffff +#define UPB_SIZE(size32, size64) size32 +#else +#define UPB_SIZE(size32, size64) size64 +#endif + +/* If we always read/write as a consistent type to each address, this shouldn't + * violate aliasing. + */ +#define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs))) + +#define UPB_MAPTYPE_STRING 0 + +// UPB_EXPORT: always generate a public symbol. +#if defined(__GNUC__) || defined(__clang__) +#define UPB_EXPORT __attribute__((visibility("default"))) __attribute__((used)) +#else +#define UPB_EXPORT +#endif + +// UPB_INLINE: inline if possible, emit standalone code if required. +#ifdef __cplusplus +#define UPB_INLINE inline +#elif defined (__GNUC__) || defined(__clang__) +#define UPB_INLINE static __inline__ +#else +#define UPB_INLINE static +#endif + +#ifdef UPB_BUILD_API +#define UPB_API UPB_EXPORT +#define UPB_API_INLINE UPB_EXPORT +#else +#define UPB_API +#define UPB_API_INLINE UPB_INLINE +#endif + +#define UPB_MALLOC_ALIGN 8 +#define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align)) +#define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align)) +#define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, UPB_MALLOC_ALIGN) +#ifdef __clang__ +#define UPB_ALIGN_OF(type) _Alignof(type) +#else +#define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member) +#endif + +#ifdef _MSC_VER +// Some versions of our Windows compiler don't support the C11 syntax. +#define UPB_ALIGN_AS(x) __declspec(align(x)) +#else +#define UPB_ALIGN_AS(x) _Alignas(x) +#endif + +// Hints to the compiler about likely/unlikely branches. +#if defined (__GNUC__) || defined(__clang__) +#define UPB_LIKELY(x) __builtin_expect((bool)(x), 1) +#define UPB_UNLIKELY(x) __builtin_expect((bool)(x), 0) +#else +#define UPB_LIKELY(x) (x) +#define UPB_UNLIKELY(x) (x) +#endif + +// Macros for function attributes on compilers that support them. +#ifdef __GNUC__ +#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static +#define UPB_NOINLINE __attribute__((noinline)) +#define UPB_NORETURN __attribute__((__noreturn__)) +#define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg))) +#elif defined(_MSC_VER) +#define UPB_NOINLINE +#define UPB_FORCEINLINE static +#define UPB_NORETURN __declspec(noreturn) +#define UPB_PRINTF(str, first_vararg) +#else /* !defined(__GNUC__) */ +#define UPB_FORCEINLINE static +#define UPB_NOINLINE +#define UPB_NORETURN +#define UPB_PRINTF(str, first_vararg) +#endif + +#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y)) +#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y)) + +#define UPB_UNUSED(var) (void)var + +// UPB_ASSUME(): in release mode, we tell the compiler to assume this is true. +#ifdef NDEBUG +#ifdef __GNUC__ +#define UPB_ASSUME(expr) if (!(expr)) __builtin_unreachable() +#elif defined _MSC_VER +#define UPB_ASSUME(expr) if (!(expr)) __assume(0) +#else +#define UPB_ASSUME(expr) do {} while (false && (expr)) +#endif +#else +#define UPB_ASSUME(expr) assert(expr) +#endif + +/* UPB_ASSERT(): in release mode, we use the expression without letting it be + * evaluated. This prevents "unused variable" warnings. */ +#ifdef NDEBUG +#define UPB_ASSERT(expr) do {} while (false && (expr)) +#else +#define UPB_ASSERT(expr) assert(expr) +#endif + +#if defined(__GNUC__) || defined(__clang__) +#define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0) +#elif defined(_MSC_VER) +#define UPB_UNREACHABLE() \ + do { \ + assert(0); \ + __assume(0); \ + } while (0) +#else +#define UPB_UNREACHABLE() do { assert(0); } while(0) +#endif + +/* UPB_SETJMP() / UPB_LONGJMP(): avoid setting/restoring signal mask. */ +#ifdef __APPLE__ +#define UPB_SETJMP(buf) _setjmp(buf) +#define UPB_LONGJMP(buf, val) _longjmp(buf, val) +#else +#define UPB_SETJMP(buf) setjmp(buf) +#define UPB_LONGJMP(buf, val) longjmp(buf, val) +#endif + +#ifdef __GNUC__ +#define UPB_USE_C11_ATOMICS +#define UPB_ATOMIC(T) _Atomic(T) +#else +#define UPB_ATOMIC(T) T +#endif + +/* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */ +#define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr)) + +#define UPB_PRIVATE(x) x##_dont_copy_me__upb_internal_use_only + +#ifdef UPB_ALLOW_PRIVATE_ACCESS__FOR_BITS_ONLY +#define UPB_ONLYBITS(x) x +#else +#define UPB_ONLYBITS(x) UPB_PRIVATE(x) +#endif + +/* Configure whether fasttable is switched on or not. *************************/ + +#ifdef __has_attribute +#define UPB_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +#define UPB_HAS_ATTRIBUTE(x) 0 +#endif + +#if UPB_HAS_ATTRIBUTE(musttail) +#define UPB_MUSTTAIL __attribute__((musttail)) +#else +#define UPB_MUSTTAIL +#endif + +#undef UPB_HAS_ATTRIBUTE + +/* This check is not fully robust: it does not require that we have "musttail" + * support available. We need tail calls to avoid consuming arbitrary amounts + * of stack space. + * + * GCC/Clang can mostly be trusted to generate tail calls as long as + * optimization is enabled, but, debug builds will not generate tail calls + * unless "musttail" is available. + * + * We should probably either: + * 1. require that the compiler supports musttail. + * 2. add some fallback code for when musttail isn't available (ie. return + * instead of tail calling). This is safe and portable, but this comes at + * a CPU cost. + */ +#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__) +#define UPB_FASTTABLE_SUPPORTED 1 +#else +#define UPB_FASTTABLE_SUPPORTED 0 +#endif + +/* define UPB_ENABLE_FASTTABLE to force fast table support. + * This is useful when we want to ensure we are really getting fasttable, + * for example for testing or benchmarking. */ +#if defined(UPB_ENABLE_FASTTABLE) +#if !UPB_FASTTABLE_SUPPORTED +#error fasttable is x86-64/ARM64 only and requires GCC or Clang. +#endif +#define UPB_FASTTABLE 1 +/* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible. + * This is useful for releasing code that might be used on multiple platforms, + * for example the PHP or Ruby C extensions. */ +#elif defined(UPB_TRY_ENABLE_FASTTABLE) +#define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED +#else +#define UPB_FASTTABLE 0 +#endif + +/* UPB_FASTTABLE_INIT() allows protos compiled for fasttable to gracefully + * degrade to non-fasttable if the runtime or platform do not support it. */ +#if !UPB_FASTTABLE +#define UPB_FASTTABLE_INIT(...) +#define UPB_FASTTABLE_MASK(mask) -1 +#else +#define UPB_FASTTABLE_INIT(...) __VA_ARGS__ +#define UPB_FASTTABLE_MASK(mask) mask +#endif + +#undef UPB_FASTTABLE_SUPPORTED + +/* ASAN poisoning (for arena). + * If using UPB from an interpreted language like Ruby, a build of the + * interpreter compiled with ASAN enabled must be used in order to get sane and + * expected behavior. + */ + +/* Due to preprocessor limitations, the conditional logic for setting + * UPN_CLANG_ASAN below cannot be consolidated into a portable one-liner. + * See https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html. + */ +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define UPB_CLANG_ASAN 1 +#else +#define UPB_CLANG_ASAN 0 +#endif +#else +#define UPB_CLANG_ASAN 0 +#endif + +#if defined(__SANITIZE_ADDRESS__) || UPB_CLANG_ASAN +#define UPB_ASAN 1 +#define UPB_ASAN_GUARD_SIZE 32 +#ifdef __cplusplus + extern "C" { +#endif +void __asan_poison_memory_region(void const volatile *addr, size_t size); +void __asan_unpoison_memory_region(void const volatile *addr, size_t size); +#ifdef __cplusplus +} /* extern "C" */ +#endif +#define UPB_POISON_MEMORY_REGION(addr, size) \ + __asan_poison_memory_region((addr), (size)) +#define UPB_UNPOISON_MEMORY_REGION(addr, size) \ + __asan_unpoison_memory_region((addr), (size)) +#else +#define UPB_ASAN 0 +#define UPB_ASAN_GUARD_SIZE 0 +#define UPB_POISON_MEMORY_REGION(addr, size) \ + ((void)(addr), (void)(size)) +#define UPB_UNPOISON_MEMORY_REGION(addr, size) \ + ((void)(addr), (void)(size)) +#endif + +/* Disable proto2 arena behavior (TEMPORARY) **********************************/ + +#ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING +#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1 +#else +#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0 +#endif + +#if defined(__cplusplus) +#if defined(__clang__) || UPB_GNUC_MIN(6, 0) +// https://gcc.gnu.org/gcc-6/changes.html +#if __cplusplus >= 201402L +#define UPB_DEPRECATED [[deprecated]] +#else +#define UPB_DEPRECATED __attribute__((deprecated)) +#endif +#else +#define UPB_DEPRECATED +#endif +#else +#define UPB_DEPRECATED +#endif + +// begin:google_only +// #define UPB_IS_GOOGLE3 +// end:google_only + +#if defined(UPB_IS_GOOGLE3) && !defined(UPB_BOOTSTRAP_STAGE0) +#define UPB_DESC(sym) proto2_##sym +#define UPB_DESC_MINITABLE(sym) &proto2__##sym##_msg_init +#elif defined(UPB_BOOTSTRAP_STAGE0) +#define UPB_DESC(sym) google_protobuf_##sym +#define UPB_DESC_MINITABLE(sym) google__protobuf__##sym##_msg_init() +#else +#define UPB_DESC(sym) google_protobuf_##sym +#define UPB_DESC_MINITABLE(sym) &google__protobuf__##sym##_msg_init +#endif + +#ifdef UPB_TRACING_ENABLED +#ifdef NDEBUG +error UPB_TRACING_ENABLED Tracing should be disabled in production builds +#endif +#endif + +#ifndef UPB_BASE_STATUS_H_ +#define UPB_BASE_STATUS_H_ + +#include + +// Must be last. + +#define _kUpb_Status_MaxMessage 511 + +typedef struct { + bool ok; + char msg[_kUpb_Status_MaxMessage]; // Error message; NULL-terminated. +} upb_Status; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API const char* upb_Status_ErrorMessage(const upb_Status* status); +UPB_API bool upb_Status_IsOk(const upb_Status* status); + +// These are no-op if |status| is NULL. +UPB_API void upb_Status_Clear(upb_Status* status); +void upb_Status_SetErrorMessage(upb_Status* status, const char* msg); +void upb_Status_SetErrorFormat(upb_Status* status, const char* fmt, ...) + UPB_PRINTF(2, 3); +void upb_Status_VSetErrorFormat(upb_Status* status, const char* fmt, + va_list args) UPB_PRINTF(2, 0); +void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt, + va_list args) UPB_PRINTF(2, 0); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_BASE_STATUS_H_ */ + +#ifndef UPB_GENERATED_CODE_SUPPORT_H_ +#define UPB_GENERATED_CODE_SUPPORT_H_ + +// IWYU pragma: begin_exports + +#ifndef UPB_BASE_UPCAST_H_ +#define UPB_BASE_UPCAST_H_ + +// Must be last. + +// This macro provides a way to upcast message pointers in a way that is +// somewhat more bulletproof than blindly casting a pointer. Example: +// +// typedef struct { +// upb_Message UPB_PRIVATE(base); +// } pkg_FooMessage; +// +// void f(pkg_FooMessage* msg) { +// upb_Decode(UPB_UPCAST(msg), ...); +// } + +#define UPB_UPCAST(x) (&(x)->base##_dont_copy_me__upb_internal_use_only) + + +#endif /* UPB_BASE_UPCAST_H_ */ + +#ifndef UPB_MESSAGE_ACCESSORS_H_ +#define UPB_MESSAGE_ACCESSORS_H_ + +#include +#include +#include + + +#ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_ +#define UPB_BASE_DESCRIPTOR_CONSTANTS_H_ + +// Must be last. + +// The types a field can have. Note that this list is not identical to the +// types defined in descriptor.proto, which gives INT32 and SINT32 separate +// types (we distinguish the two with the "integer encoding" enum below). +// This enum is an internal convenience only and has no meaning outside of upb. +typedef enum { + kUpb_CType_Bool = 1, + kUpb_CType_Float = 2, + kUpb_CType_Int32 = 3, + kUpb_CType_UInt32 = 4, + kUpb_CType_Enum = 5, // Enum values are int32. TODO: rename + kUpb_CType_Message = 6, + kUpb_CType_Double = 7, + kUpb_CType_Int64 = 8, + kUpb_CType_UInt64 = 9, + kUpb_CType_String = 10, + kUpb_CType_Bytes = 11 +} upb_CType; + +// The repeated-ness of each field; this matches descriptor.proto. +typedef enum { + kUpb_Label_Optional = 1, + kUpb_Label_Required = 2, + kUpb_Label_Repeated = 3 +} upb_Label; + +// Descriptor types, as defined in descriptor.proto. +typedef enum { + kUpb_FieldType_Double = 1, + kUpb_FieldType_Float = 2, + kUpb_FieldType_Int64 = 3, + kUpb_FieldType_UInt64 = 4, + kUpb_FieldType_Int32 = 5, + kUpb_FieldType_Fixed64 = 6, + kUpb_FieldType_Fixed32 = 7, + kUpb_FieldType_Bool = 8, + kUpb_FieldType_String = 9, + kUpb_FieldType_Group = 10, + kUpb_FieldType_Message = 11, + kUpb_FieldType_Bytes = 12, + kUpb_FieldType_UInt32 = 13, + kUpb_FieldType_Enum = 14, + kUpb_FieldType_SFixed32 = 15, + kUpb_FieldType_SFixed64 = 16, + kUpb_FieldType_SInt32 = 17, + kUpb_FieldType_SInt64 = 18, +} upb_FieldType; + +#define kUpb_FieldType_SizeOf 19 + +#ifdef __cplusplus +extern "C" { +#endif + +// Convert from upb_FieldType to upb_CType +UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type) { + static const upb_CType c_type[] = { + kUpb_CType_Double, // kUpb_FieldType_Double + kUpb_CType_Float, // kUpb_FieldType_Float + kUpb_CType_Int64, // kUpb_FieldType_Int64 + kUpb_CType_UInt64, // kUpb_FieldType_UInt64 + kUpb_CType_Int32, // kUpb_FieldType_Int32 + kUpb_CType_UInt64, // kUpb_FieldType_Fixed64 + kUpb_CType_UInt32, // kUpb_FieldType_Fixed32 + kUpb_CType_Bool, // kUpb_FieldType_Bool + kUpb_CType_String, // kUpb_FieldType_String + kUpb_CType_Message, // kUpb_FieldType_Group + kUpb_CType_Message, // kUpb_FieldType_Message + kUpb_CType_Bytes, // kUpb_FieldType_Bytes + kUpb_CType_UInt32, // kUpb_FieldType_UInt32 + kUpb_CType_Enum, // kUpb_FieldType_Enum + kUpb_CType_Int32, // kUpb_FieldType_SFixed32 + kUpb_CType_Int64, // kUpb_FieldType_SFixed64 + kUpb_CType_Int32, // kUpb_FieldType_SInt32 + kUpb_CType_Int64, // kUpb_FieldType_SInt64 + }; + + // -1 here because the enum is one-based but the table is zero-based. + return c_type[field_type - 1]; +} + +UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) { + // clang-format off + const unsigned kUnpackableTypes = + (1 << kUpb_FieldType_String) | + (1 << kUpb_FieldType_Bytes) | + (1 << kUpb_FieldType_Message) | + (1 << kUpb_FieldType_Group); + // clang-format on + return (1 << field_type) & ~kUnpackableTypes; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_BASE_DESCRIPTOR_CONSTANTS_H_ */ +#ifndef UPB_BASE_STRING_VIEW_H_ +#define UPB_BASE_STRING_VIEW_H_ + +#include + +// Must be last. + +#define UPB_STRINGVIEW_INIT(ptr, len) \ + { ptr, len } + +#define UPB_STRINGVIEW_FORMAT "%.*s" +#define UPB_STRINGVIEW_ARGS(view) (int)(view).size, (view).data + +// LINT.IfChange(struct_definition) +typedef struct { + const char* data; + size_t size; +} upb_StringView; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data, + size_t size) { + upb_StringView ret; + ret.data = data; + ret.size = size; + return ret; +} + +UPB_INLINE upb_StringView upb_StringView_FromString(const char* data) { + return upb_StringView_FromDataAndSize(data, strlen(data)); +} + +UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) { + return (a.size == b.size) && (!a.size || !memcmp(a.data, b.data, a.size)); +} + +// LINT.ThenChange( +// GoogleInternalName1, +// //depot/google3/third_party/upb/bits/golang/accessor.go:map_go_string, +// //depot/google3/third_party/upb/bits/typescript/string_view.ts +// ) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_BASE_STRING_VIEW_H_ */ + +/* upb_Arena is a specific allocator implementation that uses arena allocation. + * The user provides an allocator that will be used to allocate the underlying + * arena blocks. Arenas by nature do not require the individual allocations + * to be freed. However the Arena does allow users to register cleanup + * functions that will run when the arena is destroyed. + * + * A upb_Arena is *not* thread-safe. + * + * You could write a thread-safe arena allocator that satisfies the + * upb_alloc interface, but it would not be as efficient for the + * single-threaded case. */ + +#ifndef UPB_MEM_ARENA_H_ +#define UPB_MEM_ARENA_H_ + +#include +#include + + +#ifndef UPB_MEM_ALLOC_H_ +#define UPB_MEM_ALLOC_H_ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct upb_alloc upb_alloc; + +/* A combined `malloc()`/`free()` function. + * If `size` is 0 then the function acts like `free()`, otherwise it acts like + * `realloc()`. Only `oldsize` bytes from a previous allocation are + * preserved. */ +typedef void* upb_alloc_func(upb_alloc* alloc, void* ptr, size_t oldsize, + size_t size); + +/* A upb_alloc is a possibly-stateful allocator object. + * + * It could either be an arena allocator (which doesn't require individual + * `free()` calls) or a regular `malloc()` (which does). The client must + * therefore free memory unless it knows that the allocator is an arena + * allocator. */ +struct upb_alloc { + upb_alloc_func* func; +}; + +UPB_INLINE void* upb_malloc(upb_alloc* alloc, size_t size) { + UPB_ASSERT(alloc); + return alloc->func(alloc, NULL, 0, size); +} + +UPB_INLINE void* upb_realloc(upb_alloc* alloc, void* ptr, size_t oldsize, + size_t size) { + UPB_ASSERT(alloc); + return alloc->func(alloc, ptr, oldsize, size); +} + +UPB_INLINE void upb_free(upb_alloc* alloc, void* ptr) { + UPB_ASSERT(alloc); + alloc->func(alloc, ptr, 0, 0); +} + +// The global allocator used by upb. Uses the standard malloc()/free(). + +extern upb_alloc upb_alloc_global; + +/* Functions that hard-code the global malloc. + * + * We still get benefit because we can put custom logic into our global + * allocator, like injecting out-of-memory faults in debug/testing builds. */ + +UPB_INLINE void* upb_gmalloc(size_t size) { + return upb_malloc(&upb_alloc_global, size); +} + +UPB_INLINE void* upb_grealloc(void* ptr, size_t oldsize, size_t size) { + return upb_realloc(&upb_alloc_global, ptr, oldsize, size); +} + +UPB_INLINE void upb_gfree(void* ptr) { upb_free(&upb_alloc_global, ptr); } + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MEM_ALLOC_H_ */ + +#ifndef UPB_MEM_INTERNAL_ARENA_H_ +#define UPB_MEM_INTERNAL_ARENA_H_ + +#include +#include +#include + +// Must be last. + +// This is QUITE an ugly hack, which specifies the number of pointers needed +// to equal (or exceed) the storage required for one upb_Arena. +// +// We need this because the decoder inlines a upb_Arena for performance but +// the full struct is not visible outside of arena.c. Yes, I know, it's awful. +#define UPB_ARENA_SIZE_HACK 7 + +// LINT.IfChange(upb_Arena) + +struct upb_Arena { + char* UPB_ONLYBITS(ptr); + char* UPB_ONLYBITS(end); +}; + +// LINT.ThenChange(//depot/google3/third_party/upb/bits/typescript/arena.ts:upb_Arena) + +#ifdef __cplusplus +extern "C" { +#endif + +void UPB_PRIVATE(_upb_Arena_SwapIn)(struct upb_Arena* des, + const struct upb_Arena* src); +void UPB_PRIVATE(_upb_Arena_SwapOut)(struct upb_Arena* des, + const struct upb_Arena* src); + +// Returns whether |ptr| was allocated directly by |a| (so care must be used +// with fused arenas). +UPB_API bool UPB_ONLYBITS(_upb_Arena_Contains)(const struct upb_Arena* a, + void* ptr); + +UPB_INLINE size_t UPB_PRIVATE(_upb_ArenaHas)(const struct upb_Arena* a) { + return (size_t)(a->UPB_ONLYBITS(end) - a->UPB_ONLYBITS(ptr)); +} + +UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size) { + void* UPB_PRIVATE(_upb_Arena_SlowMalloc)(struct upb_Arena * a, size_t size); + + size = UPB_ALIGN_MALLOC(size); + const size_t span = size + UPB_ASAN_GUARD_SIZE; + if (UPB_UNLIKELY(UPB_PRIVATE(_upb_ArenaHas)(a) < span)) { + return UPB_PRIVATE(_upb_Arena_SlowMalloc)(a, span); + } + + // We have enough space to do a fast malloc. + void* ret = a->UPB_ONLYBITS(ptr); + UPB_ASSERT(UPB_ALIGN_MALLOC((uintptr_t)ret) == (uintptr_t)ret); + UPB_ASSERT(UPB_ALIGN_MALLOC(size) == size); + UPB_UNPOISON_MEMORY_REGION(ret, size); + + a->UPB_ONLYBITS(ptr) += span; + + return ret; +} + +UPB_API_INLINE void* upb_Arena_Realloc(struct upb_Arena* a, void* ptr, + size_t oldsize, size_t size) { + oldsize = UPB_ALIGN_MALLOC(oldsize); + size = UPB_ALIGN_MALLOC(size); + bool is_most_recent_alloc = + (uintptr_t)ptr + oldsize == (uintptr_t)a->UPB_ONLYBITS(ptr); + + if (is_most_recent_alloc) { + ptrdiff_t diff = size - oldsize; + if ((ptrdiff_t)UPB_PRIVATE(_upb_ArenaHas)(a) >= diff) { + a->UPB_ONLYBITS(ptr) += diff; + return ptr; + } + } else if (size <= oldsize) { + return ptr; + } + + void* ret = upb_Arena_Malloc(a, size); + + if (ret && oldsize > 0) { + memcpy(ret, ptr, UPB_MIN(oldsize, size)); + } + + return ret; +} + +UPB_API_INLINE void upb_Arena_ShrinkLast(struct upb_Arena* a, void* ptr, + size_t oldsize, size_t size) { + oldsize = UPB_ALIGN_MALLOC(oldsize); + size = UPB_ALIGN_MALLOC(size); + // Must be the last alloc. + UPB_ASSERT((char*)ptr + oldsize == + a->UPB_ONLYBITS(ptr) - UPB_ASAN_GUARD_SIZE); + UPB_ASSERT(size <= oldsize); + a->UPB_ONLYBITS(ptr) = (char*)ptr + size; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MEM_INTERNAL_ARENA_H_ */ + +// Must be last. + +typedef struct upb_Arena upb_Arena; + +#ifdef __cplusplus +extern "C" { +#endif + +// Creates an arena from the given initial block (if any -- n may be 0). +// Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this +// is a fixed-size arena and cannot grow. +UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc); + +UPB_API void upb_Arena_Free(upb_Arena* a); +UPB_API bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b); + +bool upb_Arena_IncRefFor(upb_Arena* a, const void* owner); +void upb_Arena_DecRefFor(upb_Arena* a, const void* owner); + +size_t upb_Arena_SpaceAllocated(upb_Arena* a, size_t* fused_count); +uint32_t upb_Arena_DebugRefCount(upb_Arena* a); + +UPB_API_INLINE upb_Arena* upb_Arena_New(void) { + return upb_Arena_Init(NULL, 0, &upb_alloc_global); +} + +UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size); + +UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize, + size_t size); + +// Shrinks the last alloc from arena. +// REQUIRES: (ptr, oldsize) was the last malloc/realloc from this arena. +// We could also add a upb_Arena_TryShrinkLast() which is simply a no-op if +// this was not the last alloc. +UPB_API_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr, + size_t oldsize, size_t size); + +#ifdef UPB_TRACING_ENABLED +void upb_Arena_SetTraceHandler(void (*initArenaTraceHandler)(const upb_Arena*, + size_t size), + void (*fuseArenaTraceHandler)(const upb_Arena*, + const upb_Arena*), + void (*freeArenaTraceHandler)(const upb_Arena*)); +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MEM_ARENA_H_ */ + +#ifndef UPB_MESSAGE_ARRAY_H_ +#define UPB_MESSAGE_ARRAY_H_ + +#include + + +#ifndef UPB_MESSAGE_INTERNAL_ARRAY_H_ +#define UPB_MESSAGE_INTERNAL_ARRAY_H_ + +#include +#include + + +// Must be last. + +#define _UPB_ARRAY_MASK_IMM 0x4 // Frozen/immutable bit. +#define _UPB_ARRAY_MASK_LG2 0x3 // Encoded elem size. +#define _UPB_ARRAY_MASK_ALL (_UPB_ARRAY_MASK_IMM | _UPB_ARRAY_MASK_LG2) + +#ifdef __cplusplus +extern "C" { +#endif + +// LINT.IfChange(upb_Array) + +// Our internal representation for repeated fields. +struct upb_Array { + // This is a tagged pointer. Bits #0 and #1 encode the elem size as follows: + // 0 maps to elem size 1 + // 1 maps to elem size 4 + // 2 maps to elem size 8 + // 3 maps to elem size 16 + // + // Bit #2 contains the frozen/immutable flag. + uintptr_t UPB_ONLYBITS(data); + + size_t UPB_ONLYBITS(size); // The number of elements in the array. + size_t UPB_PRIVATE(capacity); // Allocated storage. Measured in elements. +}; + +UPB_INLINE void UPB_PRIVATE(_upb_Array_ShallowFreeze)(struct upb_Array* arr) { + arr->UPB_ONLYBITS(data) |= _UPB_ARRAY_MASK_IMM; +} + +UPB_API_INLINE bool upb_Array_IsFrozen(const struct upb_Array* arr) { + return (arr->UPB_ONLYBITS(data) & _UPB_ARRAY_MASK_IMM) != 0; +} + +UPB_INLINE void UPB_PRIVATE(_upb_Array_SetTaggedPtr)(struct upb_Array* array, + void* data, size_t lg2) { + UPB_ASSERT(lg2 != 1); + UPB_ASSERT(lg2 <= 4); + const size_t bits = lg2 - (lg2 != 0); + array->UPB_ONLYBITS(data) = (uintptr_t)data | bits; +} + +UPB_INLINE size_t +UPB_PRIVATE(_upb_Array_ElemSizeLg2)(const struct upb_Array* array) { + const size_t bits = array->UPB_ONLYBITS(data) & _UPB_ARRAY_MASK_LG2; + const size_t lg2 = bits + (bits != 0); + return lg2; +} + +UPB_API_INLINE const void* upb_Array_DataPtr(const struct upb_Array* array) { + UPB_PRIVATE(_upb_Array_ElemSizeLg2)(array); // Check assertions. + return (void*)(array->UPB_ONLYBITS(data) & ~(uintptr_t)_UPB_ARRAY_MASK_ALL); +} + +UPB_API_INLINE void* upb_Array_MutableDataPtr(struct upb_Array* array) { + return (void*)upb_Array_DataPtr(array); +} + +UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_New)(upb_Arena* arena, + size_t init_capacity, + int elem_size_lg2) { + UPB_ASSERT(elem_size_lg2 != 1); + UPB_ASSERT(elem_size_lg2 <= 4); + const size_t array_size = + UPB_ALIGN_UP(sizeof(struct upb_Array), UPB_MALLOC_ALIGN); + const size_t bytes = array_size + (init_capacity << elem_size_lg2); + struct upb_Array* array = (struct upb_Array*)upb_Arena_Malloc(arena, bytes); + if (!array) return NULL; + UPB_PRIVATE(_upb_Array_SetTaggedPtr) + (array, UPB_PTR_AT(array, array_size, void), elem_size_lg2); + array->UPB_ONLYBITS(size) = 0; + array->UPB_PRIVATE(capacity) = init_capacity; + return array; +} + +// Resizes the capacity of the array to be at least min_size. +bool UPB_PRIVATE(_upb_Array_Realloc)(struct upb_Array* array, size_t min_size, + upb_Arena* arena); + +UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array, size_t size, + upb_Arena* arena) { + UPB_ASSERT(!upb_Array_IsFrozen(array)); + if (array->UPB_PRIVATE(capacity) < size) + return UPB_PRIVATE(_upb_Array_Realloc)(array, size, arena); + return true; +} + +// Resize without initializing new elements. +UPB_INLINE bool UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + struct upb_Array* array, size_t size, upb_Arena* arena) { + UPB_ASSERT(!upb_Array_IsFrozen(array)); + UPB_ASSERT(size <= array->UPB_ONLYBITS(size) || + arena); // Allow NULL arena when shrinking. + if (!upb_Array_Reserve(array, size, arena)) return false; + array->UPB_ONLYBITS(size) = size; + return true; +} + +// This function is intended for situations where elem_size is compile-time +// constant or a known expression of the form (1 << lg2), so that the expression +// i*elem_size does not result in an actual multiplication. +UPB_INLINE void UPB_PRIVATE(_upb_Array_Set)(struct upb_Array* array, size_t i, + const void* data, + size_t elem_size) { + UPB_ASSERT(!upb_Array_IsFrozen(array)); + UPB_ASSERT(i < array->UPB_ONLYBITS(size)); + UPB_ASSERT(elem_size == 1U << UPB_PRIVATE(_upb_Array_ElemSizeLg2)(array)); + char* arr_data = (char*)upb_Array_MutableDataPtr(array); + memcpy(arr_data + (i * elem_size), data, elem_size); +} + +UPB_API_INLINE size_t upb_Array_Size(const struct upb_Array* arr) { + return arr->UPB_ONLYBITS(size); +} + +// LINT.ThenChange(GoogleInternalName0) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#undef _UPB_ARRAY_MASK_IMM +#undef _UPB_ARRAY_MASK_LG2 +#undef _UPB_ARRAY_MASK_ALL + + +#endif /* UPB_MESSAGE_INTERNAL_ARRAY_H_ */ + +// Users should include array.h or map.h instead. +// IWYU pragma: private, include "upb/message/array.h" + +#ifndef UPB_MESSAGE_VALUE_H_ +#define UPB_MESSAGE_VALUE_H_ + +#include + + +typedef union { + bool bool_val; + float float_val; + double double_val; + int32_t int32_val; + int64_t int64_val; + uint32_t uint32_val; + uint64_t uint64_val; + const struct upb_Array* array_val; + const struct upb_Map* map_val; + const struct upb_Message* msg_val; + upb_StringView str_val; + + // EXPERIMENTAL: A tagged upb_Message*. Users must use this instead of + // msg_val if unlinked sub-messages may possibly be in use. See the + // documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more + // information. + uintptr_t tagged_msg_val; // upb_TaggedMessagePtr +} upb_MessageValue; + +typedef union { + struct upb_Array* array; + struct upb_Map* map; + struct upb_Message* msg; +} upb_MutableMessageValue; + +#endif /* UPB_MESSAGE_VALUE_H_ */ + +#ifndef UPB_MINI_TABLE_FIELD_H_ +#define UPB_MINI_TABLE_FIELD_H_ + +#include + + +#ifndef UPB_MINI_TABLE_INTERNAL_FIELD_H_ +#define UPB_MINI_TABLE_INTERNAL_FIELD_H_ + +#include +#include + + +#ifndef UPB_MINI_TABLE_INTERNAL_SIZE_LOG2_H_ +#define UPB_MINI_TABLE_INTERNAL_SIZE_LOG2_H_ + +#include +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Return the log2 of the storage size in bytes for a upb_CType +UPB_INLINE int UPB_PRIVATE(_upb_CType_SizeLg2)(upb_CType c_type) { + static const int8_t size[] = { + 0, // kUpb_CType_Bool + 2, // kUpb_CType_Float + 2, // kUpb_CType_Int32 + 2, // kUpb_CType_UInt32 + 2, // kUpb_CType_Enum + UPB_SIZE(2, 3), // kUpb_CType_Message + 3, // kUpb_CType_Double + 3, // kUpb_CType_Int64 + 3, // kUpb_CType_UInt64 + UPB_SIZE(3, 4), // kUpb_CType_String + UPB_SIZE(3, 4), // kUpb_CType_Bytes + }; + + // -1 here because the enum is one-based but the table is zero-based. + return size[c_type - 1]; +} + +// Return the log2 of the storage size in bytes for a upb_FieldType +UPB_INLINE int UPB_PRIVATE(_upb_FieldType_SizeLg2)(upb_FieldType field_type) { + static const int8_t size[] = { + 3, // kUpb_FieldType_Double + 2, // kUpb_FieldType_Float + 3, // kUpb_FieldType_Int64 + 3, // kUpb_FieldType_UInt64 + 2, // kUpb_FieldType_Int32 + 3, // kUpb_FieldType_Fixed64 + 2, // kUpb_FieldType_Fixed32 + 0, // kUpb_FieldType_Bool + UPB_SIZE(3, 4), // kUpb_FieldType_String + UPB_SIZE(2, 3), // kUpb_FieldType_Group + UPB_SIZE(2, 3), // kUpb_FieldType_Message + UPB_SIZE(3, 4), // kUpb_FieldType_Bytes + 2, // kUpb_FieldType_UInt32 + 2, // kUpb_FieldType_Enum + 2, // kUpb_FieldType_SFixed32 + 3, // kUpb_FieldType_SFixed64 + 2, // kUpb_FieldType_SInt32 + 3, // kUpb_FieldType_SInt64 + }; + + // -1 here because the enum is one-based but the table is zero-based. + return size[field_type - 1]; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_SIZE_LOG2_H_ */ + +// Must be last. + +// LINT.IfChange(struct_definition) +struct upb_MiniTableField { + uint32_t UPB_ONLYBITS(number); + uint16_t UPB_ONLYBITS(offset); + int16_t presence; // If >0, hasbit_index. If <0, ~oneof_index + + // Indexes into `upb_MiniTable.subs` + // Will be set to `kUpb_NoSub` if `descriptortype` != MESSAGE/GROUP/ENUM + uint16_t UPB_PRIVATE(submsg_index); + + uint8_t UPB_PRIVATE(descriptortype); + + // upb_FieldMode | upb_LabelFlags | (upb_FieldRep << kUpb_FieldRep_Shift) + uint8_t UPB_ONLYBITS(mode); +}; + +#define kUpb_NoSub ((uint16_t) - 1) + +typedef enum { + kUpb_FieldMode_Map = 0, + kUpb_FieldMode_Array = 1, + kUpb_FieldMode_Scalar = 2, +} upb_FieldMode; + +// Mask to isolate the upb_FieldMode from field.mode. +#define kUpb_FieldMode_Mask 3 + +// Extra flags on the mode field. +typedef enum { + kUpb_LabelFlags_IsPacked = 4, + kUpb_LabelFlags_IsExtension = 8, + // Indicates that this descriptor type is an "alternate type": + // - for Int32, this indicates that the actual type is Enum (but was + // rewritten to Int32 because it is an open enum that requires no check). + // - for Bytes, this indicates that the actual type is String (but does + // not require any UTF-8 check). + kUpb_LabelFlags_IsAlternate = 16, +} upb_LabelFlags; + +// Note: we sort by this number when calculating layout order. +typedef enum { + kUpb_FieldRep_1Byte = 0, + kUpb_FieldRep_4Byte = 1, + kUpb_FieldRep_StringView = 2, + kUpb_FieldRep_8Byte = 3, + + kUpb_FieldRep_NativePointer = + UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte), + kUpb_FieldRep_Max = kUpb_FieldRep_8Byte, +} upb_FieldRep; + +#define kUpb_FieldRep_Shift 6 + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE upb_FieldMode +UPB_PRIVATE(_upb_MiniTableField_Mode)(const struct upb_MiniTableField* f) { + return (upb_FieldMode)(f->UPB_ONLYBITS(mode) & kUpb_FieldMode_Mask); +} + +UPB_INLINE upb_FieldRep +UPB_PRIVATE(_upb_MiniTableField_GetRep)(const struct upb_MiniTableField* f) { + return (upb_FieldRep)(f->UPB_ONLYBITS(mode) >> kUpb_FieldRep_Shift); +} + +UPB_API_INLINE bool upb_MiniTableField_IsArray( + const struct upb_MiniTableField* f) { + return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Array; +} + +UPB_API_INLINE bool upb_MiniTableField_IsMap( + const struct upb_MiniTableField* f) { + return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Map; +} + +UPB_API_INLINE bool upb_MiniTableField_IsScalar( + const struct upb_MiniTableField* f) { + return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Scalar; +} + +UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsAlternate)( + const struct upb_MiniTableField* f) { + return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsAlternate) != 0; +} + +UPB_API_INLINE bool upb_MiniTableField_IsExtension( + const struct upb_MiniTableField* f) { + return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsExtension) != 0; +} + +UPB_API_INLINE bool upb_MiniTableField_IsPacked( + const struct upb_MiniTableField* f) { + return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsPacked) != 0; +} + +UPB_API_INLINE upb_FieldType +upb_MiniTableField_Type(const struct upb_MiniTableField* f) { + const upb_FieldType type = (upb_FieldType)f->UPB_PRIVATE(descriptortype); + if (UPB_PRIVATE(_upb_MiniTableField_IsAlternate)(f)) { + if (type == kUpb_FieldType_Int32) return kUpb_FieldType_Enum; + if (type == kUpb_FieldType_Bytes) return kUpb_FieldType_String; + UPB_ASSERT(false); + } + return type; +} + +UPB_API_INLINE +upb_CType upb_MiniTableField_CType(const struct upb_MiniTableField* f) { + return upb_FieldType_CType(upb_MiniTableField_Type(f)); +} + +UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_HasHasbit)( + const struct upb_MiniTableField* f) { + return f->presence > 0; +} + +UPB_INLINE char UPB_PRIVATE(_upb_MiniTableField_HasbitMask)( + const struct upb_MiniTableField* f) { + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)); + const size_t index = f->presence; + return 1 << (index % 8); +} + +UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)( + const struct upb_MiniTableField* f) { + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)); + const size_t index = f->presence; + return index / 8; +} + +UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum( + const struct upb_MiniTableField* f) { + return f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Enum; +} + +UPB_API_INLINE bool upb_MiniTableField_IsInOneof( + const struct upb_MiniTableField* f) { + return f->presence < 0; +} + +UPB_API_INLINE bool upb_MiniTableField_IsSubMessage( + const struct upb_MiniTableField* f) { + return f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Message || + f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group; +} + +UPB_API_INLINE bool upb_MiniTableField_HasPresence( + const struct upb_MiniTableField* f) { + if (upb_MiniTableField_IsExtension(f)) { + return upb_MiniTableField_IsScalar(f); + } else { + return f->presence != 0; + } +} + +UPB_API_INLINE uint32_t +upb_MiniTableField_Number(const struct upb_MiniTableField* f) { + return f->UPB_ONLYBITS(number); +} + +UPB_INLINE uint16_t +UPB_PRIVATE(_upb_MiniTableField_Offset)(const struct upb_MiniTableField* f) { + return f->UPB_ONLYBITS(offset); +} + +UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_OneofOffset)( + const struct upb_MiniTableField* f) { + UPB_ASSERT(upb_MiniTableField_IsInOneof(f)); + return ~(ptrdiff_t)f->presence; +} + +UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)( + const struct upb_MiniTableField* f) { + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == + kUpb_FieldRep_NativePointer); + UPB_ASSUME(upb_MiniTableField_IsArray(f)); + UPB_ASSUME(f->presence == 0); +} + +UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)( + const struct upb_MiniTableField* f) { + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == + kUpb_FieldRep_NativePointer); + UPB_ASSUME(upb_MiniTableField_IsMap(f)); + UPB_ASSUME(f->presence == 0); +} + +UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)( + const struct upb_MiniTableField* f) { + const upb_FieldType field_type = upb_MiniTableField_Type(f); + return UPB_PRIVATE(_upb_FieldType_SizeLg2)(field_type); +} + +// LINT.ThenChange(//depot/google3/third_party/upb/bits/typescript/mini_table_field.ts) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_FIELD_H_ */ + +// Must be last. + +typedef struct upb_MiniTableField upb_MiniTableField; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE upb_CType upb_MiniTableField_CType(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_HasPresence(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsArray(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum( + const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsExtension(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsInOneof(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsMap(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsPacked(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsScalar(const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_MiniTableField_IsSubMessage( + const upb_MiniTableField* f); + +UPB_API_INLINE uint32_t upb_MiniTableField_Number(const upb_MiniTableField* f); + +UPB_API_INLINE upb_FieldType +upb_MiniTableField_Type(const upb_MiniTableField* f); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_FIELD_H_ */ + +#ifndef UPB_MINI_TABLE_MESSAGE_H_ +#define UPB_MINI_TABLE_MESSAGE_H_ + + +#ifndef UPB_MINI_TABLE_ENUM_H_ +#define UPB_MINI_TABLE_ENUM_H_ + +#include + + +#ifndef UPB_MINI_TABLE_INTERNAL_ENUM_H_ +#define UPB_MINI_TABLE_INTERNAL_ENUM_H_ + +#include + +// Must be last. + +struct upb_MiniTableEnum { + uint32_t UPB_PRIVATE(mask_limit); // Highest that can be tested with mask. + uint32_t UPB_PRIVATE(value_count); // Number of values after the bitfield. + uint32_t UPB_PRIVATE(data)[]; // Bitmask + enumerated values follow. +}; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE bool upb_MiniTableEnum_CheckValue( + const struct upb_MiniTableEnum* e, uint32_t val) { + if (UPB_LIKELY(val < 64)) { + const uint64_t mask = + e->UPB_PRIVATE(data)[0] | ((uint64_t)e->UPB_PRIVATE(data)[1] << 32); + const uint64_t bit = 1ULL << val; + return (mask & bit) != 0; + } + if (UPB_LIKELY(val < e->UPB_PRIVATE(mask_limit))) { + const uint32_t mask = e->UPB_PRIVATE(data)[val / 32]; + const uint32_t bit = 1ULL << (val % 32); + return (mask & bit) != 0; + } + + // OPT: binary search long lists? + const uint32_t* start = + &e->UPB_PRIVATE(data)[e->UPB_PRIVATE(mask_limit) / 32]; + const uint32_t* limit = &e->UPB_PRIVATE( + data)[e->UPB_PRIVATE(mask_limit) / 32 + e->UPB_PRIVATE(value_count)]; + for (const uint32_t* p = start; p < limit; p++) { + if (*p == val) return true; + } + return false; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_ENUM_H_ */ + +// Must be last + +typedef struct upb_MiniTableEnum upb_MiniTableEnum; + +#ifdef __cplusplus +extern "C" { +#endif + +// Validates enum value against range defined by enum mini table. +UPB_API_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e, + uint32_t val); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_ENUM_H_ */ + +#ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ +#define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ + +#include + + +#ifndef UPB_MINI_TABLE_INTERNAL_SUB_H_ +#define UPB_MINI_TABLE_INTERNAL_SUB_H_ + +// Must be last. + +union upb_MiniTableSub { + const struct upb_MiniTable* UPB_PRIVATE(submsg); + const struct upb_MiniTableEnum* UPB_PRIVATE(subenum); +}; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE union upb_MiniTableSub upb_MiniTableSub_FromEnum( + const struct upb_MiniTableEnum* subenum) { + union upb_MiniTableSub out; + out.UPB_PRIVATE(subenum) = subenum; + return out; +} + +UPB_API_INLINE union upb_MiniTableSub upb_MiniTableSub_FromMessage( + const struct upb_MiniTable* submsg) { + union upb_MiniTableSub out; + out.UPB_PRIVATE(submsg) = submsg; + return out; +} + +UPB_API_INLINE const struct upb_MiniTableEnum* upb_MiniTableSub_Enum( + const union upb_MiniTableSub sub) { + return sub.UPB_PRIVATE(subenum); +} + +UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableSub_Message( + const union upb_MiniTableSub sub) { + return sub.UPB_PRIVATE(submsg); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_SUB_H_ */ + +// Must be last. + +struct upb_Decoder; +struct upb_Message; +typedef const char* _upb_FieldParser(struct upb_Decoder* d, const char* ptr, + struct upb_Message* msg, intptr_t table, + uint64_t hasbits, uint64_t data); +typedef struct { + uint64_t field_data; + _upb_FieldParser* field_parser; +} _upb_FastTable_Entry; + +typedef enum { + kUpb_ExtMode_NonExtendable = 0, // Non-extendable message. + kUpb_ExtMode_Extendable = 1, // Normal extendable message. + kUpb_ExtMode_IsMessageSet = 2, // MessageSet message. + kUpb_ExtMode_IsMessageSet_ITEM = + 3, // MessageSet item (temporary only, see decode.c) + + // During table building we steal a bit to indicate that the message is a map + // entry. *Only* used during table building! + kUpb_ExtMode_IsMapEntry = 4, +} upb_ExtMode; + +// upb_MiniTable represents the memory layout of a given upb_MessageDef. +// The members are public so generated code can initialize them, +// but users MUST NOT directly read or write any of its members. + +// LINT.IfChange(minitable_struct_definition) +struct upb_MiniTable { + const union upb_MiniTableSub* UPB_PRIVATE(subs); + const struct upb_MiniTableField* UPB_ONLYBITS(fields); + + // Must be aligned to sizeof(void*). Doesn't include internal members like + // unknown fields, extension dict, pointer to msglayout, etc. + uint16_t UPB_PRIVATE(size); + + uint16_t UPB_ONLYBITS(field_count); + + uint8_t UPB_PRIVATE(ext); // upb_ExtMode, uint8_t here so sizeof(ext) == 1 + uint8_t UPB_PRIVATE(dense_below); + uint8_t UPB_PRIVATE(table_mask); + uint8_t UPB_PRIVATE(required_count); // Required fields have the low hasbits. + +#ifdef UPB_TRACING_ENABLED + const char* UPB_PRIVATE(full_name); +#endif + +#ifdef UPB_FASTTABLE_ENABLED + // To statically initialize the tables of variable length, we need a flexible + // array member, and we need to compile in gnu99 mode (constant initialization + // of flexible array members is a GNU extension, not in C99 unfortunately. + _upb_FastTable_Entry UPB_PRIVATE(fasttable)[]; +#endif +}; +// LINT.ThenChange(//depot/google3/third_party/upb/bits/typescript/mini_table.ts) + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE(_upb_MiniTable_Empty)(void) { + extern const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty); + + return &UPB_PRIVATE(_kUpb_MiniTable_Empty); +} + +UPB_API_INLINE int upb_MiniTable_FieldCount(const struct upb_MiniTable* m) { + return m->UPB_ONLYBITS(field_count); +} + +UPB_INLINE bool UPB_PRIVATE(_upb_MiniTable_IsEmpty)( + const struct upb_MiniTable* m) { + extern const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty); + + return m == &UPB_PRIVATE(_kUpb_MiniTable_Empty); +} + +UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_GetFieldByIndex( + const struct upb_MiniTable* m, uint32_t i) { + return &m->UPB_ONLYBITS(fields)[i]; +} + +UPB_INLINE const union upb_MiniTableSub* UPB_PRIVATE( + _upb_MiniTable_GetSubByIndex)(const struct upb_MiniTable* m, uint32_t i) { + return &m->UPB_PRIVATE(subs)[i]; +} + +UPB_API_INLINE const struct upb_MiniTable* upb_MiniTable_GetSubMessageTable( + const struct upb_MiniTable* m, const struct upb_MiniTableField* f) { + UPB_ASSERT(upb_MiniTableField_CType(f) == kUpb_CType_Message); + const struct upb_MiniTable* ret = upb_MiniTableSub_Message( + m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); + UPB_ASSUME(ret); + return UPB_PRIVATE(_upb_MiniTable_IsEmpty)(ret) ? NULL : ret; +} + +UPB_API_INLINE const struct upb_MiniTable* upb_MiniTable_SubMessage( + const struct upb_MiniTable* m, const struct upb_MiniTableField* f) { + if (upb_MiniTableField_CType(f) != kUpb_CType_Message) { + return NULL; + } + return upb_MiniTableSub_Message( + m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); +} + +UPB_API_INLINE const struct upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable( + const struct upb_MiniTable* m, const struct upb_MiniTableField* f) { + UPB_ASSERT(upb_MiniTableField_CType(f) == kUpb_CType_Enum); + return upb_MiniTableSub_Enum( + m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); +} + +UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_MapKey( + const struct upb_MiniTable* m) { + UPB_ASSERT(upb_MiniTable_FieldCount(m) == 2); + const struct upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, 0); + UPB_ASSERT(upb_MiniTableField_Number(f) == 1); + return f; +} + +UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_MapValue( + const struct upb_MiniTable* m) { + UPB_ASSERT(upb_MiniTable_FieldCount(m) == 2); + const struct upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, 1); + UPB_ASSERT(upb_MiniTableField_Number(f) == 2); + return f; +} + +UPB_API_INLINE bool upb_MiniTable_FieldIsLinked( + const struct upb_MiniTable* m, const struct upb_MiniTableField* f) { + return upb_MiniTable_GetSubMessageTable(m, f) != NULL; +} + +// Computes a bitmask in which the |m->required_count| lowest bits are set. +// +// Sample output: +// RequiredMask(1) => 0b1 (0x1) +// RequiredMask(5) => 0b11111 (0x1f) +UPB_INLINE uint64_t +UPB_PRIVATE(_upb_MiniTable_RequiredMask)(const struct upb_MiniTable* m) { + int n = m->UPB_PRIVATE(required_count); + UPB_ASSERT(0 < n && n <= 64); + return (1ULL << n) - 1; +} + +#ifdef UPB_TRACING_ENABLED +UPB_INLINE const char* upb_MiniTable_FullName( + const struct upb_MiniTable* mini_table) { + return mini_table->UPB_PRIVATE(full_name); +} +// Initializes tracing proto name from language runtimes that construct +// mini tables dynamically at runtime. The runtime is responsible for passing +// controlling lifetime of name such as storing in same arena as mini_table. +UPB_INLINE void upb_MiniTable_SetFullName(struct upb_MiniTable* mini_table, + const char* full_name) { + mini_table->UPB_PRIVATE(full_name) = full_name; +} +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ */ + +// Must be last. + +typedef struct upb_MiniTable upb_MiniTable; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API const upb_MiniTableField* upb_MiniTable_FindFieldByNumber( + const upb_MiniTable* m, uint32_t number); + +UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_GetFieldByIndex( + const upb_MiniTable* m, uint32_t index); + +UPB_API_INLINE int upb_MiniTable_FieldCount(const upb_MiniTable* m); + +// DEPRECATED: use upb_MiniTable_SubMessage() instead +// Returns the MiniTable for a message field, NULL if the field is unlinked. +UPB_API_INLINE const upb_MiniTable* upb_MiniTable_GetSubMessageTable( + const upb_MiniTable* m, const upb_MiniTableField* f); + +// Returns the MiniTable for a message field if it is a submessage. +UPB_API_INLINE const upb_MiniTable* upb_MiniTable_SubMessage( + const upb_MiniTable* m, const upb_MiniTableField* f); + +// Returns the MiniTableEnum for a message field, NULL if the field is unlinked. +UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable( + const upb_MiniTable* m, const upb_MiniTableField* f); + +// Returns the MiniTableField for the key of a map. +UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapKey( + const upb_MiniTable* m); + +// Returns the MiniTableField for the value of a map. +UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapValue( + const upb_MiniTable* m); + +// Returns true if this MiniTable field is linked to a MiniTable for the +// sub-message. +UPB_API_INLINE bool upb_MiniTable_FieldIsLinked(const upb_MiniTable* m, + const upb_MiniTableField* f); + +// If this field is in a oneof, returns the first field in the oneof. +// +// Otherwise returns NULL. +// +// Usage: +// const upb_MiniTableField* field = upb_MiniTable_GetOneof(m, f); +// do { +// .. +// } while (upb_MiniTable_NextOneofField(m, &field); +// +const upb_MiniTableField* upb_MiniTable_GetOneof(const upb_MiniTable* m, + const upb_MiniTableField* f); + +// Iterates to the next field in the oneof. If this is the last field in the +// oneof, returns false. The ordering of fields in the oneof is not +// guaranteed. +// REQUIRES: |f| is the field initialized by upb_MiniTable_GetOneof and updated +// by prior upb_MiniTable_NextOneofField calls. +bool upb_MiniTable_NextOneofField(const upb_MiniTable* m, + const upb_MiniTableField** f); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_MESSAGE_H_ */ + +// Must be last. + +typedef struct upb_Array upb_Array; + +#ifdef __cplusplus +extern "C" { +#endif + +// Creates a new array on the given arena that holds elements of this type. +UPB_API upb_Array* upb_Array_New(upb_Arena* a, upb_CType type); + +// Returns the number of elements in the array. +UPB_API_INLINE size_t upb_Array_Size(const upb_Array* arr); + +// Returns the given element, which must be within the array's current size. +UPB_API upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i); + +// Returns a mutating pointer to the given element, which must be within the +// array's current size. +UPB_API upb_MutableMessageValue upb_Array_GetMutable(upb_Array* arr, size_t i); + +// Sets the given element, which must be within the array's current size. +UPB_API void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val); + +// Appends an element to the array. Returns false on allocation failure. +UPB_API bool upb_Array_Append(upb_Array* array, upb_MessageValue val, + upb_Arena* arena); + +// Moves elements within the array using memmove(). +// Like memmove(), the source and destination elements may be overlapping. +UPB_API void upb_Array_Move(upb_Array* array, size_t dst_idx, size_t src_idx, + size_t count); + +// Inserts one or more empty elements into the array. +// Existing elements are shifted right. +// The new elements have undefined state and must be set with `upb_Array_Set()`. +// REQUIRES: `i <= upb_Array_Size(arr)` +UPB_API bool upb_Array_Insert(upb_Array* array, size_t i, size_t count, + upb_Arena* arena); + +// Deletes one or more elements from the array. +// Existing elements are shifted left. +// REQUIRES: `i + count <= upb_Array_Size(arr)` +UPB_API void upb_Array_Delete(upb_Array* array, size_t i, size_t count); + +// Reserves |size| elements of storage for the array. +UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array, size_t size, + upb_Arena* arena); + +// Changes the size of a vector. New elements are initialized to NULL/0. +// Returns false on allocation failure. +UPB_API bool upb_Array_Resize(upb_Array* array, size_t size, upb_Arena* arena); + +// Returns pointer to array data. +UPB_API_INLINE const void* upb_Array_DataPtr(const upb_Array* arr); + +// Returns mutable pointer to array data. +UPB_API_INLINE void* upb_Array_MutableDataPtr(upb_Array* arr); + +// Mark an array and all of its descendents as frozen/immutable. +// If the array elements are messages then |m| must point to the minitable for +// those messages. Otherwise |m| must be NULL. +UPB_API void upb_Array_Freeze(upb_Array* arr, const upb_MiniTable* m); + +// Returns whether an array has been frozen. +UPB_API_INLINE bool upb_Array_IsFrozen(const upb_Array* arr); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_ARRAY_H_ */ + +#ifndef UPB_MESSAGE_INTERNAL_ACCESSORS_H_ +#define UPB_MESSAGE_INTERNAL_ACCESSORS_H_ + +#include +#include +#include + + +#ifndef UPB_BASE_INTERNAL_ENDIAN_H_ +#define UPB_BASE_INTERNAL_ENDIAN_H_ + +#include + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE bool upb_IsLittleEndian(void) { + const int x = 1; + return *(char*)&x == 1; +} + +UPB_INLINE uint32_t upb_BigEndian32(uint32_t val) { + if (upb_IsLittleEndian()) return val; + + return ((val & 0xff) << 24) | ((val & 0xff00) << 8) | + ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24); +} + +UPB_INLINE uint64_t upb_BigEndian64(uint64_t val) { + if (upb_IsLittleEndian()) return val; + + const uint64_t hi = ((uint64_t)upb_BigEndian32((uint32_t)val)) << 32; + const uint64_t lo = upb_BigEndian32((uint32_t)(val >> 32)); + return hi | lo; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_BASE_INTERNAL_ENDIAN_H_ */ + +#ifndef UPB_MESSAGE_INTERNAL_EXTENSION_H_ +#define UPB_MESSAGE_INTERNAL_EXTENSION_H_ + +#include + + +#ifndef UPB_MINI_TABLE_EXTENSION_H_ +#define UPB_MINI_TABLE_EXTENSION_H_ + +#include + + +#ifndef UPB_MINI_TABLE_INTERNAL_EXTENSION_H_ +#define UPB_MINI_TABLE_INTERNAL_EXTENSION_H_ + +#include + + +// Must be last. + +struct upb_MiniTableExtension { + // Do not move this field. We need to be able to alias pointers. + struct upb_MiniTableField UPB_PRIVATE(field); + + const struct upb_MiniTable* UPB_PRIVATE(extendee); + union upb_MiniTableSub UPB_PRIVATE(sub); // NULL unless submsg or proto2 enum +}; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE upb_CType +upb_MiniTableExtension_CType(const struct upb_MiniTableExtension* e) { + return upb_MiniTableField_CType(&e->UPB_PRIVATE(field)); +} + +UPB_API_INLINE uint32_t +upb_MiniTableExtension_Number(const struct upb_MiniTableExtension* e) { + return e->UPB_PRIVATE(field).UPB_ONLYBITS(number); +} + +UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableExtension_GetSubMessage( + const struct upb_MiniTableExtension* e) { + return upb_MiniTableSub_Message(e->UPB_PRIVATE(sub)); +} + +UPB_API_INLINE void upb_MiniTableExtension_SetSubMessage( + struct upb_MiniTableExtension* e, const struct upb_MiniTable* m) { + e->UPB_PRIVATE(sub).UPB_PRIVATE(submsg) = m; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_EXTENSION_H_ */ + +// Must be last. + +typedef struct upb_MiniTableExtension upb_MiniTableExtension; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE upb_CType +upb_MiniTableExtension_CType(const upb_MiniTableExtension* e); + +UPB_API_INLINE uint32_t +upb_MiniTableExtension_Number(const upb_MiniTableExtension* e); + +UPB_API_INLINE const upb_MiniTable* upb_MiniTableExtension_GetSubMessage( + const upb_MiniTableExtension* e); + +UPB_API_INLINE void upb_MiniTableExtension_SetSubMessage( + upb_MiniTableExtension* e, const upb_MiniTable* m); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_EXTENSION_H_ */ + +// Must be last. + +// The internal representation of an extension is self-describing: it contains +// enough information that we can serialize it to binary format without needing +// to look it up in a upb_ExtensionRegistry. +// +// This representation allocates 16 bytes to data on 64-bit platforms. +// This is rather wasteful for scalars (in the extreme case of bool, +// it wastes 15 bytes). We accept this because we expect messages to be +// the most common extension type. +typedef struct { + const upb_MiniTableExtension* ext; + upb_MessageValue data; +} upb_Extension; + +#ifdef __cplusplus +extern "C" { +#endif + +// Adds the given extension data to the given message. +// |ext| is copied into the message instance. +// This logically replaces any previously-added extension with this number. +upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)( + struct upb_Message* msg, const upb_MiniTableExtension* ext, + upb_Arena* arena); + +// Returns an array of extensions for this message. +// Note: the array is ordered in reverse relative to the order of creation. +const upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)( + const struct upb_Message* msg, size_t* count); + +// Returns an extension for a message with a given mini table, +// or NULL if no extension exists with this mini table. +const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)( + const struct upb_Message* msg, const upb_MiniTableExtension* ext); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_INTERNAL_EXTENSION_H_ */ + +#ifndef UPB_MESSAGE_INTERNAL_MAP_H_ +#define UPB_MESSAGE_INTERNAL_MAP_H_ + +#include +#include + + +#ifndef UPB_HASH_STR_TABLE_H_ +#define UPB_HASH_STR_TABLE_H_ + + +/* + * upb_table + * + * This header is INTERNAL-ONLY! Its interfaces are not public or stable! + * This file defines very fast int->upb_value (inttable) and string->upb_value + * (strtable) hash tables. + * + * The table uses chained scatter with Brent's variation (inspired by the Lua + * implementation of hash tables). The hash function for strings is Austin + * Appleby's "MurmurHash." + * + * The inttable uses uintptr_t as its key, which guarantees it can be used to + * store pointers or integers of at least 32 bits (upb isn't really useful on + * systems where sizeof(void*) < 4). + * + * The table must be homogeneous (all values of the same type). In debug + * mode, we check this on insert and lookup. + */ + +#ifndef UPB_HASH_COMMON_H_ +#define UPB_HASH_COMMON_H_ + +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +/* upb_value ******************************************************************/ + +typedef struct { + uint64_t val; +} upb_value; + +UPB_INLINE void _upb_value_setval(upb_value* v, uint64_t val) { v->val = val; } + +/* For each value ctype, define the following set of functions: + * + * // Get/set an int32 from a upb_value. + * int32_t upb_value_getint32(upb_value val); + * void upb_value_setint32(upb_value *val, int32_t cval); + * + * // Construct a new upb_value from an int32. + * upb_value upb_value_int32(int32_t val); */ +#define FUNCS(name, membername, type_t, converter) \ + UPB_INLINE void upb_value_set##name(upb_value* val, type_t cval) { \ + val->val = (converter)cval; \ + } \ + UPB_INLINE upb_value upb_value_##name(type_t val) { \ + upb_value ret; \ + upb_value_set##name(&ret, val); \ + return ret; \ + } \ + UPB_INLINE type_t upb_value_get##name(upb_value val) { \ + return (type_t)(converter)val.val; \ + } + +FUNCS(int32, int32, int32_t, int32_t) +FUNCS(int64, int64, int64_t, int64_t) +FUNCS(uint32, uint32, uint32_t, uint32_t) +FUNCS(uint64, uint64, uint64_t, uint64_t) +FUNCS(bool, _bool, bool, bool) +FUNCS(cstr, cstr, char*, uintptr_t) +FUNCS(uintptr, uptr, uintptr_t, uintptr_t) +FUNCS(ptr, ptr, void*, uintptr_t) +FUNCS(constptr, constptr, const void*, uintptr_t) + +#undef FUNCS + +UPB_INLINE void upb_value_setfloat(upb_value* val, float cval) { + memcpy(&val->val, &cval, sizeof(cval)); +} + +UPB_INLINE void upb_value_setdouble(upb_value* val, double cval) { + memcpy(&val->val, &cval, sizeof(cval)); +} + +UPB_INLINE upb_value upb_value_float(float cval) { + upb_value ret; + upb_value_setfloat(&ret, cval); + return ret; +} + +UPB_INLINE upb_value upb_value_double(double cval) { + upb_value ret; + upb_value_setdouble(&ret, cval); + return ret; +} + +/* upb_tabkey *****************************************************************/ + +/* Either: + * 1. an actual integer key, or + * 2. a pointer to a string prefixed by its uint32_t length, owned by us. + * + * ...depending on whether this is a string table or an int table. We would + * make this a union of those two types, but C89 doesn't support statically + * initializing a non-first union member. */ +typedef uintptr_t upb_tabkey; + +UPB_INLINE char* upb_tabstr(upb_tabkey key, uint32_t* len) { + char* mem = (char*)key; + if (len) memcpy(len, mem, sizeof(*len)); + return mem + sizeof(*len); +} + +UPB_INLINE upb_StringView upb_tabstrview(upb_tabkey key) { + upb_StringView ret; + uint32_t len; + ret.data = upb_tabstr(key, &len); + ret.size = len; + return ret; +} + +/* upb_tabval *****************************************************************/ + +typedef struct upb_tabval { + uint64_t val; +} upb_tabval; + +#define UPB_TABVALUE_EMPTY_INIT \ + { -1 } + +/* upb_table ******************************************************************/ + +typedef struct _upb_tabent { + upb_tabkey key; + upb_tabval val; + + /* Internal chaining. This is const so we can create static initializers for + * tables. We cast away const sometimes, but *only* when the containing + * upb_table is known to be non-const. This requires a bit of care, but + * the subtlety is confined to table.c. */ + const struct _upb_tabent* next; +} upb_tabent; + +typedef struct { + size_t count; /* Number of entries in the hash part. */ + uint32_t mask; /* Mask to turn hash value -> bucket. */ + uint32_t max_count; /* Max count before we hit our load limit. */ + uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */ + upb_tabent* entries; +} upb_table; + +UPB_INLINE size_t upb_table_size(const upb_table* t) { + return t->size_lg2 ? 1 << t->size_lg2 : 0; +} + +// Internal-only functions, in .h file only out of necessity. + +UPB_INLINE bool upb_tabent_isempty(const upb_tabent* e) { return e->key == 0; } + +uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_HASH_COMMON_H_ */ + +// Must be last. + +typedef struct { + upb_table t; +} upb_strtable; + +#ifdef __cplusplus +extern "C" { +#endif + +// Initialize a table. If memory allocation failed, false is returned and +// the table is uninitialized. +bool upb_strtable_init(upb_strtable* table, size_t expected_size, upb_Arena* a); + +// Returns the number of values in the table. +UPB_INLINE size_t upb_strtable_count(const upb_strtable* t) { + return t->t.count; +} + +void upb_strtable_clear(upb_strtable* t); + +// Inserts the given key into the hashtable with the given value. +// The key must not already exist in the hash table. The key is not required +// to be NULL-terminated, and the table will make an internal copy of the key. +// +// If a table resize was required but memory allocation failed, false is +// returned and the table is unchanged. */ +bool upb_strtable_insert(upb_strtable* t, const char* key, size_t len, + upb_value val, upb_Arena* a); + +// Looks up key in this table, returning "true" if the key was found. +// If v is non-NULL, copies the value for this key into *v. +bool upb_strtable_lookup2(const upb_strtable* t, const char* key, size_t len, + upb_value* v); + +// For NULL-terminated strings. +UPB_INLINE bool upb_strtable_lookup(const upb_strtable* t, const char* key, + upb_value* v) { + return upb_strtable_lookup2(t, key, strlen(key), v); +} + +// Removes an item from the table. Returns true if the remove was successful, +// and stores the removed item in *val if non-NULL. +bool upb_strtable_remove2(upb_strtable* t, const char* key, size_t len, + upb_value* val); + +UPB_INLINE bool upb_strtable_remove(upb_strtable* t, const char* key, + upb_value* v) { + return upb_strtable_remove2(t, key, strlen(key), v); +} + +// Exposed for testing only. +bool upb_strtable_resize(upb_strtable* t, size_t size_lg2, upb_Arena* a); + +/* Iteration over strtable: + * + * intptr_t iter = UPB_STRTABLE_BEGIN; + * upb_StringView key; + * upb_value val; + * while (upb_strtable_next2(t, &key, &val, &iter)) { + * // ... + * } + */ + +#define UPB_STRTABLE_BEGIN -1 + +bool upb_strtable_next2(const upb_strtable* t, upb_StringView* key, + upb_value* val, intptr_t* iter); +void upb_strtable_removeiter(upb_strtable* t, intptr_t* iter); +void upb_strtable_setentryvalue(upb_strtable* t, intptr_t iter, upb_value v); + +/* DEPRECATED iterators, slated for removal. + * + * Iterators for string tables. We are subject to some kind of unusual + * design constraints: + * + * For high-level languages: + * - we must be able to guarantee that we don't crash or corrupt memory even if + * the program accesses an invalidated iterator. + * + * For C++11 range-based for: + * - iterators must be copyable + * - iterators must be comparable + * - it must be possible to construct an "end" value. + * + * Iteration order is undefined. + * + * Modifying the table invalidates iterators. upb_{str,int}table_done() is + * guaranteed to work even on an invalidated iterator, as long as the table it + * is iterating over has not been freed. Calling next() or accessing data from + * an invalidated iterator yields unspecified elements from the table, but it is + * guaranteed not to crash and to return real table elements (except when done() + * is true). */ +/* upb_strtable_iter **********************************************************/ + +/* upb_strtable_iter i; + * upb_strtable_begin(&i, t); + * for(; !upb_strtable_done(&i); upb_strtable_next(&i)) { + * const char *key = upb_strtable_iter_key(&i); + * const upb_value val = upb_strtable_iter_value(&i); + * // ... + * } + */ + +typedef struct { + const upb_strtable* t; + size_t index; +} upb_strtable_iter; + +UPB_INLINE const upb_tabent* str_tabent(const upb_strtable_iter* i) { + return &i->t->t.entries[i->index]; +} + +void upb_strtable_begin(upb_strtable_iter* i, const upb_strtable* t); +void upb_strtable_next(upb_strtable_iter* i); +bool upb_strtable_done(const upb_strtable_iter* i); +upb_StringView upb_strtable_iter_key(const upb_strtable_iter* i); +upb_value upb_strtable_iter_value(const upb_strtable_iter* i); +void upb_strtable_iter_setdone(upb_strtable_iter* i); +bool upb_strtable_iter_isequal(const upb_strtable_iter* i1, + const upb_strtable_iter* i2); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_HASH_STR_TABLE_H_ */ + +// Must be last. + +typedef enum { + kUpb_MapInsertStatus_Inserted = 0, + kUpb_MapInsertStatus_Replaced = 1, + kUpb_MapInsertStatus_OutOfMemory = 2, +} upb_MapInsertStatus; + +// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// + +struct upb_Map { + // Size of key and val, based on the map type. + // Strings are represented as '0' because they must be handled specially. + char key_size; + char val_size; + bool UPB_PRIVATE(is_frozen); + + upb_strtable table; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE void UPB_PRIVATE(_upb_Map_ShallowFreeze)(struct upb_Map* map) { + map->UPB_PRIVATE(is_frozen) = true; +} + +UPB_API_INLINE bool upb_Map_IsFrozen(const struct upb_Map* map) { + return map->UPB_PRIVATE(is_frozen); +} + +// Converting between internal table representation and user values. +// +// _upb_map_tokey() and _upb_map_fromkey() are inverses. +// _upb_map_tovalue() and _upb_map_fromvalue() are inverses. +// +// These functions account for the fact that strings are treated differently +// from other types when stored in a map. + +UPB_INLINE upb_StringView _upb_map_tokey(const void* key, size_t size) { + if (size == UPB_MAPTYPE_STRING) { + return *(upb_StringView*)key; + } else { + return upb_StringView_FromDataAndSize((const char*)key, size); + } +} + +UPB_INLINE void _upb_map_fromkey(upb_StringView key, void* out, size_t size) { + if (size == UPB_MAPTYPE_STRING) { + memcpy(out, &key, sizeof(key)); + } else { + memcpy(out, key.data, size); + } +} + +UPB_INLINE bool _upb_map_tovalue(const void* val, size_t size, + upb_value* msgval, upb_Arena* a) { + if (size == UPB_MAPTYPE_STRING) { + upb_StringView* strp = (upb_StringView*)upb_Arena_Malloc(a, sizeof(*strp)); + if (!strp) return false; + *strp = *(upb_StringView*)val; + *msgval = upb_value_ptr(strp); + } else { + memcpy(msgval, val, size); + } + return true; +} + +UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) { + if (size == UPB_MAPTYPE_STRING) { + const upb_StringView* strp = (const upb_StringView*)upb_value_getptr(val); + memcpy(out, strp, sizeof(upb_StringView)); + } else { + memcpy(out, &val, size); + } +} + +UPB_INLINE void* _upb_map_next(const struct upb_Map* map, size_t* iter) { + upb_strtable_iter it; + it.t = &map->table; + it.index = *iter; + upb_strtable_next(&it); + *iter = it.index; + if (upb_strtable_done(&it)) return NULL; + return (void*)str_tabent(&it); +} + +UPB_INLINE void _upb_Map_Clear(struct upb_Map* map) { + UPB_ASSERT(!upb_Map_IsFrozen(map)); + + upb_strtable_clear(&map->table); +} + +UPB_INLINE bool _upb_Map_Delete(struct upb_Map* map, const void* key, + size_t key_size, upb_value* val) { + UPB_ASSERT(!upb_Map_IsFrozen(map)); + + upb_StringView k = _upb_map_tokey(key, key_size); + return upb_strtable_remove2(&map->table, k.data, k.size, val); +} + +UPB_INLINE bool _upb_Map_Get(const struct upb_Map* map, const void* key, + size_t key_size, void* val, size_t val_size) { + upb_value tabval; + upb_StringView k = _upb_map_tokey(key, key_size); + bool ret = upb_strtable_lookup2(&map->table, k.data, k.size, &tabval); + if (ret && val) { + _upb_map_fromvalue(tabval, val, val_size); + } + return ret; +} + +UPB_INLINE upb_MapInsertStatus _upb_Map_Insert(struct upb_Map* map, + const void* key, size_t key_size, + void* val, size_t val_size, + upb_Arena* a) { + UPB_ASSERT(!upb_Map_IsFrozen(map)); + + upb_StringView strkey = _upb_map_tokey(key, key_size); + upb_value tabval = {0}; + if (!_upb_map_tovalue(val, val_size, &tabval, a)) { + return kUpb_MapInsertStatus_OutOfMemory; + } + + // TODO: add overwrite operation to minimize number of lookups. + bool removed = + upb_strtable_remove2(&map->table, strkey.data, strkey.size, NULL); + if (!upb_strtable_insert(&map->table, strkey.data, strkey.size, tabval, a)) { + return kUpb_MapInsertStatus_OutOfMemory; + } + return removed ? kUpb_MapInsertStatus_Replaced + : kUpb_MapInsertStatus_Inserted; +} + +UPB_INLINE size_t _upb_Map_Size(const struct upb_Map* map) { + return map->table.t.count; +} + +// Strings/bytes are special-cased in maps. +extern char _upb_Map_CTypeSizeTable[12]; + +UPB_INLINE size_t _upb_Map_CTypeSize(upb_CType ctype) { + return _upb_Map_CTypeSizeTable[ctype]; +} + +// Creates a new map on the given arena with this key/value type. +struct upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_INTERNAL_MAP_H_ */ + +/* +** Our memory representation for parsing tables and messages themselves. +** Functions in this file are used by generated code and possibly reflection. +** +** The definitions in this file are internal to upb. +**/ + +#ifndef UPB_MESSAGE_INTERNAL_MESSAGE_H_ +#define UPB_MESSAGE_INTERNAL_MESSAGE_H_ + +#include +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +extern const float kUpb_FltInfinity; +extern const double kUpb_Infinity; +extern const double kUpb_NaN; + +// Internal members of a upb_Message that track unknown fields and/or +// extensions. We can change this without breaking binary compatibility. + +typedef struct upb_Message_Internal { + // Total size of this structure, including the data that follows. + // Must be aligned to 8, which is alignof(upb_Extension) + uint32_t size; + + /* Offsets relative to the beginning of this structure. + * + * Unknown data grows forward from the beginning to unknown_end. + * Extension data grows backward from size to ext_begin. + * When the two meet, we're out of data and have to realloc. + * + * If we imagine that the final member of this struct is: + * char data[size - overhead]; // overhead = sizeof(upb_Message_Internal) + * + * Then we have: + * unknown data: data[0 .. (unknown_end - overhead)] + * extensions data: data[(ext_begin - overhead) .. (size - overhead)] */ + uint32_t unknown_end; + uint32_t ext_begin; + // Data follows, as if there were an array: + // char data[size - sizeof(upb_Message_Internal)]; +} upb_Message_Internal; + +#ifdef UPB_TRACING_ENABLED +void UPB_PRIVATE(upb_Message_SetNewMessageTraceHandler)( + void (*newMessageTraceHandler)(const upb_MiniTable*, const upb_Arena*)); +void UPB_PRIVATE(upb_Message_LogNewMessage)(const upb_MiniTable* mini_table, + const upb_Arena* arena); +#endif + +// Inline version upb_Message_New(), for internal use. +UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* m, + upb_Arena* a) { +#ifdef UPB_TRACING_ENABLED + UPB_PRIVATE(upb_Message_LogNewMessage)(m, a); +#endif + const int size = m->UPB_PRIVATE(size); + struct upb_Message* msg = (struct upb_Message*)upb_Arena_Malloc(a, size); + if (UPB_UNLIKELY(!msg)) return NULL; + memset(msg, 0, size); + return msg; +} + +// Discards the unknown fields for this message only. +void _upb_Message_DiscardUnknown_shallow(struct upb_Message* msg); + +// Adds unknown data (serialized protobuf data) to the given message. +// The data is copied into the message instance. +bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg, + const char* data, size_t len, + upb_Arena* arena); + +bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, + upb_Arena* arena); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_INTERNAL_MESSAGE_H_ */ + +#ifndef UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ +#define UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ + +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Internal-only because empty messages cannot be created by the user. +UPB_INLINE uintptr_t +UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(struct upb_Message* ptr, bool empty) { + UPB_ASSERT(((uintptr_t)ptr & 1) == 0); + return (uintptr_t)ptr | (empty ? 1 : 0); +} + +UPB_API_INLINE bool upb_TaggedMessagePtr_IsEmpty(uintptr_t ptr) { + return ptr & 1; +} + +UPB_INLINE struct upb_Message* UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)( + uintptr_t ptr) { + return (struct upb_Message*)(ptr & ~(uintptr_t)1); +} + +UPB_API_INLINE struct upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage( + uintptr_t ptr) { + UPB_ASSERT(!upb_TaggedMessagePtr_IsEmpty(ptr)); + return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr); +} + +UPB_INLINE struct upb_Message* UPB_PRIVATE( + _upb_TaggedMessagePtr_GetEmptyMessage)(uintptr_t ptr) { + UPB_ASSERT(upb_TaggedMessagePtr_IsEmpty(ptr)); + return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ */ + +#ifndef UPB_MESSAGE_INTERNAL_TYPES_H_ +#define UPB_MESSAGE_INTERNAL_TYPES_H_ + +#include + +// Must be last. + +#define UPB_OPAQUE(x) x##_opaque + +struct upb_Message { + union { + uintptr_t UPB_OPAQUE(internal); // tagged pointer, low bit == frozen + double d; // Forces same size for 32-bit/64-bit builds + }; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE void UPB_PRIVATE(_upb_Message_ShallowFreeze)( + struct upb_Message* msg) { + msg->UPB_OPAQUE(internal) |= 1ULL; +} + +UPB_API_INLINE bool upb_Message_IsFrozen(const struct upb_Message* msg) { + return (msg->UPB_OPAQUE(internal) & 1ULL) != 0; +} + +UPB_INLINE struct upb_Message_Internal* UPB_PRIVATE(_upb_Message_GetInternal)( + const struct upb_Message* msg) { + const uintptr_t tmp = msg->UPB_OPAQUE(internal) & ~1ULL; + return (struct upb_Message_Internal*)tmp; +} + +UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)( + struct upb_Message* msg, struct upb_Message_Internal* internal) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + msg->UPB_OPAQUE(internal) = (uintptr_t)internal; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#undef UPB_OPAQUE + + +#endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */ + +// Must be last. + +#if defined(__GNUC__) && !defined(__clang__) +// GCC raises incorrect warnings in these functions. It thinks that we are +// overrunning buffers, but we carefully write the functions in this file to +// guarantee that this is impossible. GCC gets this wrong due it its failure +// to perform constant propagation as we expect: +// - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108217 +// - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108226 +// +// Unfortunately this also indicates that GCC is not optimizing away the +// switch() in cases where it should be, compromising the performance. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#if __GNUC__ >= 11 +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// LINT.IfChange(presence_logic) + +// Hasbit access /////////////////////////////////////////////////////////////// + +UPB_INLINE bool UPB_PRIVATE(_upb_Message_GetHasbit)( + const struct upb_Message* msg, const upb_MiniTableField* f) { + const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f); + const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f); + + return (*UPB_PTR_AT(msg, offset, const char) & mask) != 0; +} + +UPB_INLINE void UPB_PRIVATE(_upb_Message_SetHasbit)( + const struct upb_Message* msg, const upb_MiniTableField* f) { + const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f); + const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f); + + (*UPB_PTR_AT(msg, offset, char)) |= mask; +} + +UPB_INLINE void UPB_PRIVATE(_upb_Message_ClearHasbit)( + const struct upb_Message* msg, const upb_MiniTableField* f) { + const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f); + const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f); + + (*UPB_PTR_AT(msg, offset, char)) &= ~mask; +} + +// Oneof case access /////////////////////////////////////////////////////////// + +UPB_INLINE uint32_t* UPB_PRIVATE(_upb_Message_OneofCasePtr)( + struct upb_Message* msg, const upb_MiniTableField* f) { + return UPB_PTR_AT(msg, UPB_PRIVATE(_upb_MiniTableField_OneofOffset)(f), + uint32_t); +} + +UPB_INLINE uint32_t UPB_PRIVATE(_upb_Message_GetOneofCase)( + const struct upb_Message* msg, const upb_MiniTableField* f) { + const uint32_t* ptr = + UPB_PRIVATE(_upb_Message_OneofCasePtr)((struct upb_Message*)msg, f); + + return *ptr; +} + +UPB_INLINE void UPB_PRIVATE(_upb_Message_SetOneofCase)( + struct upb_Message* msg, const upb_MiniTableField* f) { + uint32_t* ptr = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f); + + *ptr = upb_MiniTableField_Number(f); +} + +// Returns true if the given field is the current oneof case. +// Does nothing if it is not the current oneof case. +UPB_INLINE bool UPB_PRIVATE(_upb_Message_ClearOneofCase)( + struct upb_Message* msg, const upb_MiniTableField* f) { + uint32_t* ptr = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f); + + if (*ptr != upb_MiniTableField_Number(f)) return false; + *ptr = 0; + return true; +} + +// LINT.ThenChange(GoogleInternalName2) + +// Returns false if the message is missing any of its required fields. +UPB_INLINE bool UPB_PRIVATE(_upb_Message_IsInitializedShallow)( + const struct upb_Message* msg, const upb_MiniTable* m) { + uint64_t bits; + memcpy(&bits, msg + 1, sizeof(bits)); + bits = upb_BigEndian64(bits); + return (UPB_PRIVATE(_upb_MiniTable_RequiredMask)(m) & ~bits) == 0; +} + +UPB_INLINE void* UPB_PRIVATE(_upb_Message_MutableDataPtr)( + struct upb_Message* msg, const upb_MiniTableField* f) { + return (char*)msg + f->UPB_ONLYBITS(offset); +} + +UPB_INLINE const void* UPB_PRIVATE(_upb_Message_DataPtr)( + const struct upb_Message* msg, const upb_MiniTableField* f) { + return (const char*)msg + f->UPB_ONLYBITS(offset); +} + +UPB_INLINE void UPB_PRIVATE(_upb_Message_SetPresence)( + struct upb_Message* msg, const upb_MiniTableField* f) { + if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) { + UPB_PRIVATE(_upb_Message_SetHasbit)(msg, f); + } else if (upb_MiniTableField_IsInOneof(f)) { + UPB_PRIVATE(_upb_Message_SetOneofCase)(msg, f); + } +} + +UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_DataCopy)( + const upb_MiniTableField* f, void* to, const void* from) { + switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) { + case kUpb_FieldRep_1Byte: + memcpy(to, from, 1); + return; + case kUpb_FieldRep_4Byte: + memcpy(to, from, 4); + return; + case kUpb_FieldRep_8Byte: + memcpy(to, from, 8); + return; + case kUpb_FieldRep_StringView: { + memcpy(to, from, sizeof(upb_StringView)); + return; + } + } + UPB_UNREACHABLE(); +} + +UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_DataEquals)( + const upb_MiniTableField* f, const void* a, const void* b) { + switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) { + case kUpb_FieldRep_1Byte: + return memcmp(a, b, 1) == 0; + case kUpb_FieldRep_4Byte: + return memcmp(a, b, 4) == 0; + case kUpb_FieldRep_8Byte: + return memcmp(a, b, 8) == 0; + case kUpb_FieldRep_StringView: { + const upb_StringView sa = *(const upb_StringView*)a; + const upb_StringView sb = *(const upb_StringView*)b; + return upb_StringView_IsEqual(sa, sb); + } + } + UPB_UNREACHABLE(); +} + +UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_DataClear)( + const upb_MiniTableField* f, void* val) { + const char zero[16] = {0}; + return UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, val, zero); +} + +UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_DataIsZero)( + const upb_MiniTableField* f, const void* val) { + const char zero[16] = {0}; + return UPB_PRIVATE(_upb_MiniTableField_DataEquals)(f, val, zero); +} + +// Here we define universal getter/setter functions for message fields. +// These look very branchy and inefficient, but as long as the MiniTableField +// values are known at compile time, all the branches are optimized away and +// we are left with ideal code. This can happen either through through +// literals or UPB_ASSUME(): +// +// // Via struct literals. +// bool FooMessage_set_bool_field(const upb_Message* msg, bool val) { +// const upb_MiniTableField field = {1, 0, 0, /* etc... */}; +// // All value in "field" are compile-time known. +// upb_Message_SetBaseField(msg, &field, &value); +// } +// +// // Via UPB_ASSUME(). +// UPB_INLINE bool upb_Message_SetBool(upb_Message* msg, +// const upb_MiniTableField* field, +// bool value, upb_Arena* a) { +// UPB_ASSUME(field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Bool); +// UPB_ASSUME(upb_MiniTableField_IsScalar(field)); +// UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == +// kUpb_FieldRep_1Byte); +// upb_Message_SetField(msg, field, &value, a); +// } +// +// As a result, we can use these universal getters/setters for *all* message +// accessors: generated code, MiniTable accessors, and reflection. The only +// exception is the binary encoder/decoder, which need to be a bit more clever +// about how they read/write the message data, for efficiency. +// +// These functions work on both extensions and non-extensions. If the field +// of a setter is known to be a non-extension, the arena may be NULL and the +// returned bool value may be ignored since it will always succeed. + +UPB_API_INLINE bool upb_Message_HasBaseField(const struct upb_Message* msg, + const upb_MiniTableField* field) { + UPB_ASSERT(upb_MiniTableField_HasPresence(field)); + UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); + if (upb_MiniTableField_IsInOneof(field)) { + return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, field) == + upb_MiniTableField_Number(field); + } else { + return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, field); + } +} + +UPB_API_INLINE bool upb_Message_HasExtension(const struct upb_Message* msg, + const upb_MiniTableExtension* e) { + UPB_ASSERT(upb_MiniTableField_HasPresence(&e->UPB_PRIVATE(field))); + return UPB_PRIVATE(_upb_Message_Getext)(msg, e) != NULL; +} + +UPB_FORCEINLINE void _upb_Message_GetNonExtensionField( + const struct upb_Message* msg, const upb_MiniTableField* field, + const void* default_val, void* val) { + UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); + if ((upb_MiniTableField_IsInOneof(field) || + !UPB_PRIVATE(_upb_MiniTableField_DataIsZero)(field, default_val)) && + !upb_Message_HasBaseField(msg, field)) { + UPB_PRIVATE(_upb_MiniTableField_DataCopy)(field, val, default_val); + return; + } + UPB_PRIVATE(_upb_MiniTableField_DataCopy) + (field, val, UPB_PRIVATE(_upb_Message_DataPtr)(msg, field)); +} + +UPB_INLINE void _upb_Message_GetExtensionField( + const struct upb_Message* msg, const upb_MiniTableExtension* mt_ext, + const void* default_val, void* val) { + const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getext)(msg, mt_ext); + const upb_MiniTableField* f = &mt_ext->UPB_PRIVATE(field); + UPB_ASSUME(upb_MiniTableField_IsExtension(f)); + + if (ext) { + UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, val, &ext->data); + } else { + UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, val, default_val); + } +} + +UPB_API_INLINE void upb_Message_SetBaseField(struct upb_Message* msg, + const upb_MiniTableField* f, + const void* val) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + UPB_ASSUME(!upb_MiniTableField_IsExtension(f)); + UPB_PRIVATE(_upb_Message_SetPresence)(msg, f); + UPB_PRIVATE(_upb_MiniTableField_DataCopy) + (f, UPB_PRIVATE(_upb_Message_MutableDataPtr)(msg, f), val); +} + +UPB_API_INLINE bool upb_Message_SetExtension(struct upb_Message* msg, + const upb_MiniTableExtension* e, + const void* val, upb_Arena* a) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + UPB_ASSERT(a); + upb_Extension* ext = + UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(msg, e, a); + if (!ext) return false; + UPB_PRIVATE(_upb_MiniTableField_DataCopy) + (&e->UPB_PRIVATE(field), &ext->data, val); + return true; +} + +UPB_API_INLINE void upb_Message_Clear(struct upb_Message* msg, + const upb_MiniTable* m) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + memset(msg, 0, m->UPB_PRIVATE(size)); + if (in) { + // Reset the internal buffer to empty. + in->unknown_end = sizeof(upb_Message_Internal); + in->ext_begin = in->size; + UPB_PRIVATE(_upb_Message_SetInternal)(msg, in); + } +} + +UPB_API_INLINE void upb_Message_ClearBaseField(struct upb_Message* msg, + const upb_MiniTableField* f) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) { + UPB_PRIVATE(_upb_Message_ClearHasbit)(msg, f); + } else if (upb_MiniTableField_IsInOneof(f)) { + uint32_t* ptr = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f); + if (*ptr != upb_MiniTableField_Number(f)) return; + *ptr = 0; + } + const char zeros[16] = {0}; + UPB_PRIVATE(_upb_MiniTableField_DataCopy) + (f, UPB_PRIVATE(_upb_Message_MutableDataPtr)(msg, f), zeros); +} + +UPB_API_INLINE void upb_Message_ClearExtension( + struct upb_Message* msg, const upb_MiniTableExtension* e) { + UPB_ASSERT(!upb_Message_IsFrozen(msg)); + upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + if (!in) return; + const upb_Extension* base = UPB_PTR_AT(in, in->ext_begin, upb_Extension); + upb_Extension* ext = (upb_Extension*)UPB_PRIVATE(_upb_Message_Getext)(msg, e); + if (ext) { + *ext = *base; + in->ext_begin += sizeof(upb_Extension); + } +} + +UPB_INLINE void _upb_Message_AssertMapIsUntagged( + const struct upb_Message* msg, const upb_MiniTableField* field) { + UPB_UNUSED(msg); + UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field); +#ifndef NDEBUG + uintptr_t default_val = 0; + uintptr_t tagged; + _upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged); + UPB_ASSERT(!upb_TaggedMessagePtr_IsEmpty(tagged)); +#endif +} + +UPB_INLINE struct upb_Map* _upb_Message_GetOrCreateMutableMap( + struct upb_Message* msg, const upb_MiniTableField* field, size_t key_size, + size_t val_size, upb_Arena* arena) { + UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field); + _upb_Message_AssertMapIsUntagged(msg, field); + struct upb_Map* map = NULL; + struct upb_Map* default_map_value = NULL; + _upb_Message_GetNonExtensionField(msg, field, &default_map_value, &map); + if (!map) { + map = _upb_Map_New(arena, key_size, val_size); + // Check again due to: https://godbolt.org/z/7WfaoKG1r + UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field); + upb_Message_SetBaseField(msg, field, &map); + } + return map; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + + +#endif // UPB_MESSAGE_INTERNAL_ACCESSORS_H_ + +#ifndef UPB_MESSAGE_MAP_H_ +#define UPB_MESSAGE_MAP_H_ + +#include + + +// Must be last. + +typedef struct upb_Map upb_Map; + +#ifdef __cplusplus +extern "C" { +#endif + +// Creates a new map on the given arena with the given key/value size. +UPB_API upb_Map* upb_Map_New(upb_Arena* a, upb_CType key_type, + upb_CType value_type); + +// Returns the number of entries in the map. +UPB_API size_t upb_Map_Size(const upb_Map* map); + +// Stores a value for the given key into |*val| (or the zero value if the key is +// not present). Returns whether the key was present. The |val| pointer may be +// NULL, in which case the function tests whether the given key is present. +UPB_API bool upb_Map_Get(const upb_Map* map, upb_MessageValue key, + upb_MessageValue* val); + +// Removes all entries in the map. +UPB_API void upb_Map_Clear(upb_Map* map); + +// Sets the given key to the given value, returning whether the key was inserted +// or replaced. If the key was inserted, then any existing iterators will be +// invalidated. +UPB_API upb_MapInsertStatus upb_Map_Insert(upb_Map* map, upb_MessageValue key, + upb_MessageValue val, + upb_Arena* arena); + +// Sets the given key to the given value. Returns false if memory allocation +// failed. If the key is newly inserted, then any existing iterators will be +// invalidated. +UPB_API_INLINE bool upb_Map_Set(upb_Map* map, upb_MessageValue key, + upb_MessageValue val, upb_Arena* arena) { + return upb_Map_Insert(map, key, val, arena) != + kUpb_MapInsertStatus_OutOfMemory; +} + +// Deletes this key from the table. Returns true if the key was present. +// If present and |val| is non-NULL, stores the deleted value. +UPB_API bool upb_Map_Delete(upb_Map* map, upb_MessageValue key, + upb_MessageValue* val); + +// Map iteration: +// +// size_t iter = kUpb_Map_Begin; +// upb_MessageValue key, val; +// while (upb_Map_Next(map, &key, &val, &iter)) { +// ... +// } + +#define kUpb_Map_Begin ((size_t) - 1) + +// Advances to the next entry. Returns false if no more entries are present. +// Otherwise returns true and populates both *key and *value. +UPB_API bool upb_Map_Next(const upb_Map* map, upb_MessageValue* key, + upb_MessageValue* val, size_t* iter); + +// Sets the value for the entry pointed to by iter. +// WARNING: this does not currently work for string values! +UPB_API void upb_Map_SetEntryValue(upb_Map* map, size_t iter, + upb_MessageValue val); + +// DEPRECATED iterator, slated for removal. + +/* Map iteration: + * + * size_t iter = kUpb_Map_Begin; + * while (upb_MapIterator_Next(map, &iter)) { + * upb_MessageValue key = upb_MapIterator_Key(map, iter); + * upb_MessageValue val = upb_MapIterator_Value(map, iter); + * } + */ + +// Advances to the next entry. Returns false if no more entries are present. +UPB_API bool upb_MapIterator_Next(const upb_Map* map, size_t* iter); + +// Returns true if the iterator still points to a valid entry, or false if the +// iterator is past the last element. It is an error to call this function with +// kUpb_Map_Begin (you must call next() at least once first). +UPB_API bool upb_MapIterator_Done(const upb_Map* map, size_t iter); + +// Returns the key and value for this entry of the map. +UPB_API upb_MessageValue upb_MapIterator_Key(const upb_Map* map, size_t iter); +UPB_API upb_MessageValue upb_MapIterator_Value(const upb_Map* map, size_t iter); + +// Mark a map and all of its descendents as frozen/immutable. +// If the map values are messages then |m| must point to the minitable for +// those messages. Otherwise |m| must be NULL. +UPB_API void upb_Map_Freeze(upb_Map* map, const upb_MiniTable* m); + +// Returns whether a map has been frozen. +UPB_API_INLINE bool upb_Map_IsFrozen(const upb_Map* map); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_MAP_H_ */ + +#ifndef UPB_MINI_TABLE_TAGGED_PTR_H_ +#define UPB_MINI_TABLE_TAGGED_PTR_H_ + +#include + + +// Public APIs for message operations that do not depend on the schema. +// +// MiniTable-based accessors live in accessors.h. + +#ifndef UPB_MESSAGE_MESSAGE_H_ +#define UPB_MESSAGE_MESSAGE_H_ + +#include + + +// Must be last. + +typedef struct upb_Message upb_Message; + +#ifdef __cplusplus +extern "C" { +#endif + +// Creates a new message with the given mini_table on the given arena. +UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena); + +// Returns a reference to the message's unknown data. +const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len); + +// Removes partial unknown data from message. +void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len); + +// Returns the number of extensions present in this message. +size_t upb_Message_ExtensionCount(const upb_Message* msg); + +// Mark a message and all of its descendents as frozen/immutable. +UPB_API void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m); + +// Returns whether a message has been frozen. +UPB_API_INLINE bool upb_Message_IsFrozen(const upb_Message* msg); + +#ifdef UPB_TRACING_ENABLED +UPB_INLINE void upb_Message_SetNewMessageTraceHandler( + void (*newMessageTraceHandler)(const upb_MiniTable* mini_table, + const upb_Arena* arena)) { + UPB_PRIVATE(upb_Message_SetNewMessageTraceHandler)(newMessageTraceHandler); +} +UPB_INLINE void upb_Message_LogNewMessage(const upb_MiniTable* mini_table, + const upb_Arena* arena) { + UPB_PRIVATE(upb_Message_LogNewMessage)(mini_table, arena); +} +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_MESSAGE_H_ */ + +// Must be last. + +// When a upb_Message* is stored in a message, array, or map, it is stored in a +// tagged form. If the tag bit is set, the referenced upb_Message is of type +// _kUpb_MiniTable_Empty (a sentinel message type with no fields) instead of +// that field's true message type. This forms the basis of what we call +// "dynamic tree shaking." +// +// See the documentation for kUpb_DecodeOption_ExperimentalAllowUnlinked for +// more information. + +typedef uintptr_t upb_TaggedMessagePtr; + +#ifdef __cplusplus +extern "C" { +#endif + +// Users who enable unlinked sub-messages must use this to test whether a +// message is empty before accessing it. If a message is empty, it must be +// first promoted using the interfaces in message/promote.h. +UPB_API_INLINE bool upb_TaggedMessagePtr_IsEmpty(upb_TaggedMessagePtr ptr); + +UPB_API_INLINE upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage( + upb_TaggedMessagePtr ptr); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_TAGGED_PTR_H_ */ + +#ifndef UPB_MINI_TABLE_SUB_H_ +#define UPB_MINI_TABLE_SUB_H_ + + +// Must be last. + +typedef union upb_MiniTableSub upb_MiniTableSub; + +#ifdef __cplusplus +extern "C" { +#endif + +// Constructors + +UPB_API_INLINE upb_MiniTableSub +upb_MiniTableSub_FromEnum(const upb_MiniTableEnum* subenum); + +UPB_API_INLINE upb_MiniTableSub +upb_MiniTableSub_FromMessage(const upb_MiniTable* submsg); + +// Getters + +UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableSub_Enum( + upb_MiniTableSub sub); + +UPB_API_INLINE const upb_MiniTable* upb_MiniTableSub_Message( + upb_MiniTableSub sub); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_SUB_H_ */ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Functions ending in BaseField() take a (upb_MiniTableField*) argument +// and work only on non-extension fields. +// +// Functions ending in Extension() take a (upb_MiniTableExtension*) argument +// and work only on extensions. + +UPB_API_INLINE void upb_Message_Clear(upb_Message* msg, const upb_MiniTable* m); + +UPB_API_INLINE void upb_Message_ClearBaseField(upb_Message* msg, + const upb_MiniTableField* f); + +UPB_API_INLINE void upb_Message_ClearExtension(upb_Message* msg, + const upb_MiniTableExtension* e); + +UPB_API_INLINE bool upb_Message_HasBaseField(const upb_Message* msg, + const upb_MiniTableField* f); + +UPB_API_INLINE bool upb_Message_HasExtension(const upb_Message* msg, + const upb_MiniTableExtension* e); + +UPB_API_INLINE void upb_Message_SetBaseField(upb_Message* msg, + const upb_MiniTableField* f, + const void* val); + +UPB_API_INLINE bool upb_Message_SetExtension(upb_Message* msg, + const upb_MiniTableExtension* e, + const void* val, upb_Arena* a); + +UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber( + const upb_Message* message, const upb_MiniTableField* oneof_field) { + UPB_ASSUME(upb_MiniTableField_IsInOneof(oneof_field)); + return UPB_PRIVATE(_upb_Message_GetOneofCase)(message, oneof_field); +} + +// NOTE: The default_val is only used for fields that support presence. +// For repeated/map fields, the resulting upb_Array*/upb_Map* can be NULL if a +// upb_Array/upb_Map has not been allocated yet. Array/map fields do not have +// presence, so this is semantically identical to a pointer to an empty +// array/map, and must be treated the same for all semantic purposes. +UPB_INLINE upb_MessageValue +upb_Message_GetField(const upb_Message* msg, const upb_MiniTableField* field, + upb_MessageValue default_val) { + upb_MessageValue ret; + if (upb_MiniTableField_IsExtension(field)) { + _upb_Message_GetExtensionField(msg, (upb_MiniTableExtension*)field, + &default_val, &ret); + } else { + _upb_Message_GetNonExtensionField(msg, field, &default_val, &ret); + } + return ret; +} + +// Sets the value of the given field in the given msg. The return value is true +// if the operation completed successfully, or false if memory allocation +// failed. +UPB_INLINE bool UPB_PRIVATE(_upb_Message_SetField)( + upb_Message* msg, const upb_MiniTableField* field, upb_MessageValue val, + upb_Arena* a) { + if (upb_MiniTableField_IsExtension(field)) { + const upb_MiniTableExtension* ext = (const upb_MiniTableExtension*)field; + return upb_Message_SetExtension(msg, ext, &val, a); + } else { + upb_Message_SetBaseField(msg, field, &val); + return true; + } +} + +UPB_API_INLINE bool upb_Message_GetBool(const upb_Message* msg, + const upb_MiniTableField* field, + bool default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Bool); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_1Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue def; + def.bool_val = default_val; + return upb_Message_GetField(msg, field, def).bool_val; +} + +UPB_API_INLINE bool upb_Message_SetBool(upb_Message* msg, + const upb_MiniTableField* field, + bool value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Bool); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_1Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.bool_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE int32_t upb_Message_GetInt32(const upb_Message* msg, + const upb_MiniTableField* field, + int32_t default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32 || + upb_MiniTableField_CType(field) == kUpb_CType_Enum); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_4Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + + upb_MessageValue def; + def.int32_val = default_val; + return upb_Message_GetField(msg, field, def).int32_val; +} + +UPB_API_INLINE bool upb_Message_SetInt32(upb_Message* msg, + const upb_MiniTableField* field, + int32_t value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32 || + upb_MiniTableField_CType(field) == kUpb_CType_Enum); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_4Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.int32_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE uint32_t upb_Message_GetUInt32(const upb_Message* msg, + const upb_MiniTableField* field, + uint32_t default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt32); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_4Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + + upb_MessageValue def; + def.uint32_val = default_val; + return upb_Message_GetField(msg, field, def).uint32_val; +} + +UPB_API_INLINE bool upb_Message_SetUInt32(upb_Message* msg, + const upb_MiniTableField* field, + uint32_t value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt32); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_4Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.uint32_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE void upb_Message_SetClosedEnum( + upb_Message* msg, const upb_MiniTable* msg_mini_table, + const upb_MiniTableField* field, int32_t value) { + UPB_ASSERT(upb_MiniTableField_IsClosedEnum(field)); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_4Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + UPB_ASSERT(upb_MiniTableEnum_CheckValue( + upb_MiniTable_GetSubEnumTable(msg_mini_table, field), value)); + upb_Message_SetBaseField(msg, field, &value); +} + +UPB_API_INLINE int64_t upb_Message_GetInt64(const upb_Message* msg, + const upb_MiniTableField* field, + int64_t default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int64); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_8Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + + upb_MessageValue def; + def.int64_val = default_val; + return upb_Message_GetField(msg, field, def).int64_val; +} + +UPB_API_INLINE bool upb_Message_SetInt64(upb_Message* msg, + const upb_MiniTableField* field, + int64_t value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int64); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_8Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.int64_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE uint64_t upb_Message_GetUInt64(const upb_Message* msg, + const upb_MiniTableField* field, + uint64_t default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt64); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_8Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + + upb_MessageValue def; + def.uint64_val = default_val; + return upb_Message_GetField(msg, field, def).uint64_val; +} + +UPB_API_INLINE bool upb_Message_SetUInt64(upb_Message* msg, + const upb_MiniTableField* field, + uint64_t value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt64); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_8Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.uint64_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE float upb_Message_GetFloat(const upb_Message* msg, + const upb_MiniTableField* field, + float default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Float); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_4Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + + upb_MessageValue def; + def.float_val = default_val; + return upb_Message_GetField(msg, field, def).float_val; +} + +UPB_API_INLINE bool upb_Message_SetFloat(upb_Message* msg, + const upb_MiniTableField* field, + float value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Float); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_4Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.float_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE double upb_Message_GetDouble(const upb_Message* msg, + const upb_MiniTableField* field, + double default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Double); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_8Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + + upb_MessageValue def; + def.double_val = default_val; + return upb_Message_GetField(msg, field, def).double_val; +} + +UPB_API_INLINE bool upb_Message_SetDouble(upb_Message* msg, + const upb_MiniTableField* field, + double value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Double); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_8Byte); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.double_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE upb_StringView +upb_Message_GetString(const upb_Message* msg, const upb_MiniTableField* field, + upb_StringView default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_String || + upb_MiniTableField_CType(field) == kUpb_CType_Bytes); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_StringView); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + + upb_MessageValue def; + def.str_val = default_val; + return upb_Message_GetField(msg, field, def).str_val; +} + +// Sets the value of a `string` or `bytes` field. The bytes of the value are not +// copied, so it is the caller's responsibility to ensure that they remain valid +// for the lifetime of `msg`. That might be done by copying them into the given +// arena, or by fusing that arena with the arena the bytes live in, for example. +UPB_API_INLINE bool upb_Message_SetString(upb_Message* msg, + const upb_MiniTableField* field, + upb_StringView value, upb_Arena* a) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_String || + upb_MiniTableField_CType(field) == kUpb_CType_Bytes); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + kUpb_FieldRep_StringView); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_MessageValue val; + val.str_val = value; + return UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, a); +} + +UPB_API_INLINE upb_TaggedMessagePtr upb_Message_GetTaggedMessagePtr( + const upb_Message* msg, const upb_MiniTableField* field, + upb_Message* default_val) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte)); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + upb_TaggedMessagePtr tagged; + _upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged); + return tagged; +} + +UPB_API_INLINE const upb_Message* upb_Message_GetMessage( + const upb_Message* msg, const upb_MiniTableField* field) { + upb_TaggedMessagePtr tagged = + upb_Message_GetTaggedMessagePtr(msg, field, NULL); + return upb_TaggedMessagePtr_GetNonEmptyMessage(tagged); +} + +UPB_API_INLINE upb_Message* upb_Message_GetMutableMessage( + upb_Message* msg, const upb_MiniTableField* field) { + return (upb_Message*)upb_Message_GetMessage(msg, field); +} + +// For internal use only; users cannot set tagged messages because only the +// parser and the message copier are allowed to directly create an empty +// message. +UPB_API_INLINE void _upb_Message_SetTaggedMessagePtr( + upb_Message* msg, const upb_MiniTable* mini_table, + const upb_MiniTableField* field, upb_TaggedMessagePtr sub_message) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message); + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) == + UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte)); + UPB_ASSUME(upb_MiniTableField_IsScalar(field)); + UPB_ASSERT(upb_MiniTableSub_Message( + mini_table->UPB_PRIVATE(subs)[field->UPB_PRIVATE(submsg_index)])); + upb_Message_SetBaseField(msg, field, &sub_message); +} + +// Sets the value of a message-typed field. The `mini_table` and `field` +// parameters belong to `msg`, not `sub_message`. The mini_tables of `msg` and +// `sub_message` must have been linked for this to work correctly. +UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg, + const upb_MiniTable* mini_table, + const upb_MiniTableField* field, + upb_Message* sub_message) { + _upb_Message_SetTaggedMessagePtr( + msg, mini_table, field, + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(sub_message, false)); +} + +UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage( + upb_Message* msg, const upb_MiniTable* mini_table, + const upb_MiniTableField* field, upb_Arena* arena) { + UPB_ASSERT(arena); + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message); + upb_Message* sub_message = + *UPB_PTR_AT(msg, field->UPB_ONLYBITS(offset), upb_Message*); + if (!sub_message) { + const upb_MiniTable* sub_mini_table = upb_MiniTableSub_Message( + mini_table->UPB_PRIVATE(subs)[field->UPB_PRIVATE(submsg_index)]); + UPB_ASSERT(sub_mini_table); + sub_message = _upb_Message_New(sub_mini_table, arena); + *UPB_PTR_AT(msg, field->UPB_ONLYBITS(offset), upb_Message*) = sub_message; + UPB_PRIVATE(_upb_Message_SetPresence)(msg, field); + } + return sub_message; +} + +UPB_API_INLINE const upb_Array* upb_Message_GetArray( + const upb_Message* msg, const upb_MiniTableField* field) { + UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(field); + upb_Array* ret; + const upb_Array* default_val = NULL; + _upb_Message_GetNonExtensionField(msg, field, &default_val, &ret); + return ret; +} + +UPB_API_INLINE upb_Array* upb_Message_GetMutableArray( + upb_Message* msg, const upb_MiniTableField* field) { + UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(field); + return (upb_Array*)upb_Message_GetArray(msg, field); +} + +UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray( + upb_Message* msg, const upb_MiniTableField* field, upb_Arena* arena) { + UPB_ASSERT(arena); + UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(field); + upb_Array* array = upb_Message_GetMutableArray(msg, field); + if (!array) { + array = UPB_PRIVATE(_upb_Array_New)( + arena, 4, UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)(field)); + // Check again due to: https://godbolt.org/z/7WfaoKG1r + UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(field); + upb_MessageValue val; + val.array_val = array; + UPB_PRIVATE(_upb_Message_SetField)(msg, field, val, arena); + } + return array; +} + +UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized( + upb_Message* msg, const upb_MiniTableField* field, size_t size, + upb_Arena* arena) { + UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(field); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(arr, size, arena)) { + return NULL; + } + return upb_Array_MutableDataPtr(arr); +} + +UPB_API_INLINE const upb_Map* upb_Message_GetMap( + const upb_Message* msg, const upb_MiniTableField* field) { + UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field); + _upb_Message_AssertMapIsUntagged(msg, field); + upb_Map* ret; + const upb_Map* default_val = NULL; + _upb_Message_GetNonExtensionField(msg, field, &default_val, &ret); + return ret; +} + +UPB_API_INLINE upb_Map* upb_Message_GetMutableMap( + upb_Message* msg, const upb_MiniTableField* field) { + return (upb_Map*)upb_Message_GetMap(msg, field); +} + +UPB_API_INLINE upb_Map* upb_Message_GetOrCreateMutableMap( + upb_Message* msg, const upb_MiniTable* map_entry_mini_table, + const upb_MiniTableField* field, upb_Arena* arena) { + UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message); + const upb_MiniTableField* map_entry_key_field = + &map_entry_mini_table->UPB_ONLYBITS(fields)[0]; + const upb_MiniTableField* map_entry_value_field = + &map_entry_mini_table->UPB_ONLYBITS(fields)[1]; + return _upb_Message_GetOrCreateMutableMap( + msg, field, + _upb_Map_CTypeSize(upb_MiniTableField_CType(map_entry_key_field)), + _upb_Map_CTypeSize(upb_MiniTableField_CType(map_entry_value_field)), + arena); +} + +// Updates a map entry given an entry message. +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, + const upb_MiniTableField* field, + upb_Message* map_entry_message, upb_Arena* arena); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_MESSAGE_ACCESSORS_H_ + +// These functions are only used by generated code. + +#ifndef UPB_MESSAGE_MAP_GENCODE_UTIL_H_ +#define UPB_MESSAGE_MAP_GENCODE_UTIL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Message map operations, these get the map from the message first. + +UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) { + const upb_tabent* ent = (const upb_tabent*)msg; + uint32_t u32len; + upb_StringView k; + k.data = upb_tabstr(ent->key, &u32len); + k.size = u32len; + _upb_map_fromkey(k, key, size); +} + +UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) { + const upb_tabent* ent = (const upb_tabent*)msg; + upb_value v = {ent->val.val}; + _upb_map_fromvalue(v, val, size); +} + +UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val, + size_t size) { + upb_tabent* ent = (upb_tabent*)msg; + // This is like _upb_map_tovalue() except the entry already exists + // so we can reuse the allocated upb_StringView for string fields. + if (size == UPB_MAPTYPE_STRING) { + upb_StringView* strp = (upb_StringView*)(uintptr_t)ent->val.val; + memcpy(strp, val, sizeof(*strp)); + } else { + memcpy(&ent->val.val, val, size); + } +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_MAP_GENCODE_UTIL_H_ */ + +#ifndef UPB_MINI_TABLE_DECODE_H_ +#define UPB_MINI_TABLE_DECODE_H_ + + +// Export the newer headers, for legacy users. New users should include the +// more specific headers directly. +// IWYU pragma: begin_exports + +#ifndef UPB_MINI_DESCRIPTOR_BUILD_ENUM_H_ +#define UPB_MINI_DESCRIPTOR_BUILD_ENUM_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Builds a upb_MiniTableEnum from an enum mini descriptor. +// The mini descriptor must be for an enum, not a message. +UPB_API upb_MiniTableEnum* upb_MiniTableEnum_Build(const char* data, size_t len, + upb_Arena* arena, + upb_Status* status); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_MINI_DESCRIPTOR_BUILD_ENUM_H_ + +// Functions for linking MiniTables together once they are built from a +// MiniDescriptor. +// +// These functions have names like upb_MiniTable_Link() because they operate on +// MiniTables. We put them here, rather than in the mini_table/ directory, +// because they are only needed when building MiniTables from MiniDescriptors. +// The interfaces in mini_table/ assume that MiniTables are immutable. + +#ifndef UPB_MINI_DESCRIPTOR_LINK_H_ +#define UPB_MINI_DESCRIPTOR_LINK_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Links a sub-message field to a MiniTable for that sub-message. If a +// sub-message field is not linked, it will be treated as an unknown field +// during parsing, and setting the field will not be allowed. It is possible +// to link the message field later, at which point it will no longer be treated +// as unknown. However there is no synchronization for this operation, which +// means parallel mutation requires external synchronization. +// Returns success/failure. +UPB_API bool upb_MiniTable_SetSubMessage(upb_MiniTable* table, + upb_MiniTableField* field, + const upb_MiniTable* sub); + +// Links an enum field to a MiniTable for that enum. +// All enum fields must be linked prior to parsing. +// Returns success/failure. +UPB_API bool upb_MiniTable_SetSubEnum(upb_MiniTable* table, + upb_MiniTableField* field, + const upb_MiniTableEnum* sub); + +// Returns a list of fields that require linking at runtime, to connect the +// MiniTable to its sub-messages and sub-enums. The list of fields will be +// written to the `subs` array, which must have been allocated by the caller +// and must be large enough to hold a list of all fields in the message. +// +// The order of the fields returned by this function is significant: it matches +// the order expected by upb_MiniTable_Link() below. +// +// The return value packs the sub-message count and sub-enum count into a single +// integer like so: +// return (msg_count << 16) | enum_count; +UPB_API uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt, + const upb_MiniTableField** subs); + +// Links a message to its sub-messages and sub-enums. The caller must pass +// arrays of sub-tables and sub-enums, in the same length and order as is +// returned by upb_MiniTable_GetSubList() above. However, individual elements +// of the sub_tables may be NULL if those sub-messages were tree shaken. +// +// Returns false if either array is too short, or if any of the tables fails +// to link. +UPB_API bool upb_MiniTable_Link(upb_MiniTable* mt, + const upb_MiniTable** sub_tables, + size_t sub_table_count, + const upb_MiniTableEnum** sub_enums, + size_t sub_enum_count); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_MINI_DESCRIPTOR_LINK_H_ +// IWYU pragma: end_exports + +// Must be last. + +typedef enum { + kUpb_MiniTablePlatform_32Bit, + kUpb_MiniTablePlatform_64Bit, + kUpb_MiniTablePlatform_Native = + UPB_SIZE(kUpb_MiniTablePlatform_32Bit, kUpb_MiniTablePlatform_64Bit), +} upb_MiniTablePlatform; + +#ifdef __cplusplus +extern "C" { +#endif + +// Builds a mini table from the data encoded in the buffer [data, len]. If any +// errors occur, returns NULL and sets a status message. In the success case, +// the caller must call upb_MiniTable_SetSub*() for all message or proto2 enum +// fields to link the table to the appropriate sub-tables. +upb_MiniTable* _upb_MiniTable_Build(const char* data, size_t len, + upb_MiniTablePlatform platform, + upb_Arena* arena, upb_Status* status); + +UPB_API_INLINE upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len, + upb_Arena* arena, + upb_Status* status) { + return _upb_MiniTable_Build(data, len, kUpb_MiniTablePlatform_Native, arena, + status); +} + +// Initializes a MiniTableExtension buffer that has already been allocated. +// This is needed by upb_FileDef and upb_MessageDef, which allocate all of the +// extensions together in a single contiguous array. +const char* _upb_MiniTableExtension_Init(const char* data, size_t len, + upb_MiniTableExtension* ext, + const upb_MiniTable* extendee, + upb_MiniTableSub sub, + upb_MiniTablePlatform platform, + upb_Status* status); + +UPB_API_INLINE const char* upb_MiniTableExtension_Init( + const char* data, size_t len, upb_MiniTableExtension* ext, + const upb_MiniTable* extendee, upb_MiniTableSub sub, upb_Status* status) { + return _upb_MiniTableExtension_Init(data, len, ext, extendee, sub, + kUpb_MiniTablePlatform_Native, status); +} + +UPB_API upb_MiniTableExtension* _upb_MiniTableExtension_Build( + const char* data, size_t len, const upb_MiniTable* extendee, + upb_MiniTableSub sub, upb_MiniTablePlatform platform, upb_Arena* arena, + upb_Status* status); + +UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_Build( + const char* data, size_t len, const upb_MiniTable* extendee, + upb_Arena* arena, upb_Status* status) { + upb_MiniTableSub sub = upb_MiniTableSub_FromMessage(NULL); + return _upb_MiniTableExtension_Build( + data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status); +} + +UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_BuildMessage( + const char* data, size_t len, const upb_MiniTable* extendee, + upb_MiniTable* submsg, upb_Arena* arena, upb_Status* status) { + upb_MiniTableSub sub = upb_MiniTableSub_FromMessage(submsg); + return _upb_MiniTableExtension_Build( + data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status); +} + +UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_BuildEnum( + const char* data, size_t len, const upb_MiniTable* extendee, + upb_MiniTableEnum* subenum, upb_Arena* arena, upb_Status* status) { + upb_MiniTableSub sub = upb_MiniTableSub_FromEnum(subenum); + return _upb_MiniTableExtension_Build( + data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status); +} + +// Like upb_MiniTable_Build(), but the user provides a buffer of layout data so +// it can be reused from call to call, avoiding repeated realloc()/free(). +// +// The caller owns `*buf` both before and after the call, and must free() it +// when it is no longer in use. The function will realloc() `*buf` as +// necessary, updating `*size` accordingly. +upb_MiniTable* upb_MiniTable_BuildWithBuf(const char* data, size_t len, + upb_MiniTablePlatform platform, + upb_Arena* arena, void** buf, + size_t* buf_size, upb_Status* status); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_DECODE_H_ */ + +#ifndef UPB_MINI_TABLE_EXTENSION_REGISTRY_H_ +#define UPB_MINI_TABLE_EXTENSION_REGISTRY_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +/* Extension registry: a dynamic data structure that stores a map of: + * (upb_MiniTable, number) -> extension info + * + * upb_decode() uses upb_ExtensionRegistry to look up extensions while parsing + * binary format. + * + * upb_ExtensionRegistry is part of the mini-table (msglayout) family of + * objects. Like all mini-table objects, it is suitable for reflection-less + * builds that do not want to expose names into the binary. + * + * Unlike most mini-table types, upb_ExtensionRegistry requires dynamic memory + * allocation and dynamic initialization: + * * If reflection is being used, then upb_DefPool will construct an appropriate + * upb_ExtensionRegistry automatically. + * * For a mini-table only build, the user must manually construct the + * upb_ExtensionRegistry and populate it with all of the extensions the user + * cares about. + * * A third alternative is to manually unpack relevant extensions after the + * main parse is complete, similar to how Any works. This is perhaps the + * nicest solution from the perspective of reducing dependencies, avoiding + * dynamic memory allocation, and avoiding the need to parse uninteresting + * extensions. The downsides are: + * (1) parse errors are not caught during the main parse + * (2) the CPU hit of parsing comes during access, which could cause an + * undesirable stutter in application performance. + * + * Users cannot directly get or put into this map. Users can only add the + * extensions from a generated module and pass the extension registry to the + * binary decoder. + * + * A upb_DefPool provides a upb_ExtensionRegistry, so any users who use + * reflection do not need to populate a upb_ExtensionRegistry directly. + */ + +typedef struct upb_ExtensionRegistry upb_ExtensionRegistry; + +// Creates a upb_ExtensionRegistry in the given arena. +// The arena must outlive any use of the extreg. +UPB_API upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena); + +UPB_API bool upb_ExtensionRegistry_Add(upb_ExtensionRegistry* r, + const upb_MiniTableExtension* e); + +// Adds the given extension info for the array |e| of size |count| into the +// registry. If there are any errors, the entire array is backed out. +// The extensions must outlive the registry. +// Possible errors include OOM or an extension number that already exists. +// TODO: There is currently no way to know the exact reason for failure. +bool upb_ExtensionRegistry_AddArray(upb_ExtensionRegistry* r, + const upb_MiniTableExtension** e, + size_t count); + +// Looks up the extension (if any) defined for message type |t| and field +// number |num|. Returns the extension if found, otherwise NULL. +UPB_API const upb_MiniTableExtension* upb_ExtensionRegistry_Lookup( + const upb_ExtensionRegistry* r, const upb_MiniTable* t, uint32_t num); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_EXTENSION_REGISTRY_H_ */ + +#ifndef UPB_MINI_TABLE_FILE_H_ +#define UPB_MINI_TABLE_FILE_H_ + + +#ifndef UPB_MINI_TABLE_INTERNAL_FILE_H_ +#define UPB_MINI_TABLE_INTERNAL_FILE_H_ + +// Must be last. + +struct upb_MiniTableFile { + const struct upb_MiniTable** UPB_PRIVATE(msgs); + const struct upb_MiniTableEnum** UPB_PRIVATE(enums); + const struct upb_MiniTableExtension** UPB_PRIVATE(exts); + int UPB_PRIVATE(msg_count); + int UPB_PRIVATE(enum_count); + int UPB_PRIVATE(ext_count); +}; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE int upb_MiniTableFile_EnumCount( + const struct upb_MiniTableFile* f) { + return f->UPB_PRIVATE(enum_count); +} + +UPB_API_INLINE int upb_MiniTableFile_ExtensionCount( + const struct upb_MiniTableFile* f) { + return f->UPB_PRIVATE(ext_count); +} + +UPB_API_INLINE int upb_MiniTableFile_MessageCount( + const struct upb_MiniTableFile* f) { + return f->UPB_PRIVATE(msg_count); +} + +UPB_API_INLINE const struct upb_MiniTableEnum* upb_MiniTableFile_Enum( + const struct upb_MiniTableFile* f, int i) { + UPB_ASSERT(i < f->UPB_PRIVATE(enum_count)); + return f->UPB_PRIVATE(enums)[i]; +} + +UPB_API_INLINE const struct upb_MiniTableExtension* upb_MiniTableFile_Extension( + const struct upb_MiniTableFile* f, int i) { + UPB_ASSERT(i < f->UPB_PRIVATE(ext_count)); + return f->UPB_PRIVATE(exts)[i]; +} + +UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableFile_Message( + const struct upb_MiniTableFile* f, int i) { + UPB_ASSERT(i < f->UPB_PRIVATE(msg_count)); + return f->UPB_PRIVATE(msgs)[i]; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_INTERNAL_FILE_H_ */ + +// Must be last. + +typedef struct upb_MiniTableFile upb_MiniTableFile; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableFile_Enum( + const upb_MiniTableFile* f, int i); + +UPB_API_INLINE int upb_MiniTableFile_EnumCount(const upb_MiniTableFile* f); + +UPB_API_INLINE const upb_MiniTableExtension* upb_MiniTableFile_Extension( + const upb_MiniTableFile* f, int i); + +UPB_API_INLINE int upb_MiniTableFile_ExtensionCount(const upb_MiniTableFile* f); + +UPB_API_INLINE const upb_MiniTable* upb_MiniTableFile_Message( + const upb_MiniTableFile* f, int i); + +UPB_API_INLINE int upb_MiniTableFile_MessageCount(const upb_MiniTableFile* f); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_FILE_H_ */ + +// upb_decode: parsing into a upb_Message using a upb_MiniTable. + +#ifndef UPB_WIRE_DECODE_H_ +#define UPB_WIRE_DECODE_H_ + +#include +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + /* If set, strings will alias the input buffer instead of copying into the + * arena. */ + kUpb_DecodeOption_AliasString = 1, + + /* If set, the parse will return failure if any message is missing any + * required fields when the message data ends. The parse will still continue, + * and the failure will only be reported at the end. + * + * IMPORTANT CAVEATS: + * + * 1. This can throw a false positive failure if an incomplete message is seen + * on the wire but is later completed when the sub-message occurs again. + * For this reason, a second pass is required to verify a failure, to be + * truly robust. + * + * 2. This can return a false success if you are decoding into a message that + * already has some sub-message fields present. If the sub-message does + * not occur in the binary payload, we will never visit it and discover the + * incomplete sub-message. For this reason, this check is only useful for + * implemting ParseFromString() semantics. For MergeFromString(), a + * post-parse validation step will always be necessary. */ + kUpb_DecodeOption_CheckRequired = 2, + + /* EXPERIMENTAL: + * + * If set, the parser will allow parsing of sub-message fields that were not + * previously linked using upb_MiniTable_SetSubMessage(). The data will be + * parsed into an internal "empty" message type that cannot be accessed + * directly, but can be later promoted into the true message type if the + * sub-message fields are linked at a later time. + * + * Users should set this option if they intend to perform dynamic tree shaking + * and promoting using the interfaces in message/promote.h. If this option is + * enabled, it is important that the resulting messages are only accessed by + * code that is aware of promotion rules: + * + * 1. Message pointers in upb_Message, upb_Array, and upb_Map are represented + * by a tagged pointer upb_TaggedMessagePointer. The tag indicates whether + * the message uses the internal "empty" type. + * + * 2. Any code *reading* these message pointers must test whether the "empty" + * tag bit is set, using the interfaces in mini_table/types.h. However + * writing of message pointers should always use plain upb_Message*, since + * users are not allowed to create "empty" messages. + * + * 3. It is always safe to test whether a field is present or test the array + * length; these interfaces will reflect that empty messages are present, + * even though their data cannot be accessed without promoting first. + * + * 4. If a message pointer is indeed tagged as empty, the message may not be + * accessed directly, only promoted through the interfaces in + * message/promote.h. + * + * 5. Tagged/empty messages may never be created by the user. They may only + * be created by the parser or the message-copying logic in message/copy.h. + */ + kUpb_DecodeOption_ExperimentalAllowUnlinked = 4, + + /* EXPERIMENTAL: + * + * If set, decoding will enforce UTF-8 validation for string fields, even for + * proto2 or fields with `features.utf8_validation = NONE`. Normally, only + * proto3 string fields will be validated for UTF-8. Decoding will return + * kUpb_DecodeStatus_BadUtf8 for non-UTF-8 strings, which is the same behavior + * as non-UTF-8 proto3 string fields. + */ + kUpb_DecodeOption_AlwaysValidateUtf8 = 8, +}; + +UPB_INLINE uint32_t upb_DecodeOptions_MaxDepth(uint16_t depth) { + return (uint32_t)depth << 16; +} + +UPB_INLINE uint16_t upb_DecodeOptions_GetMaxDepth(uint32_t options) { + return options >> 16; +} + +// Enforce an upper bound on recursion depth. +UPB_INLINE int upb_Decode_LimitDepth(uint32_t decode_options, uint32_t limit) { + uint32_t max_depth = upb_DecodeOptions_GetMaxDepth(decode_options); + if (max_depth > limit) max_depth = limit; + return upb_DecodeOptions_MaxDepth(max_depth) | (decode_options & 0xffff); +} + +// LINT.IfChange +typedef enum { + kUpb_DecodeStatus_Ok = 0, + kUpb_DecodeStatus_Malformed = 1, // Wire format was corrupt + kUpb_DecodeStatus_OutOfMemory = 2, // Arena alloc failed + kUpb_DecodeStatus_BadUtf8 = 3, // String field had bad UTF-8 + kUpb_DecodeStatus_MaxDepthExceeded = + 4, // Exceeded upb_DecodeOptions_MaxDepth + + // kUpb_DecodeOption_CheckRequired failed (see above), but the parse otherwise + // succeeded. + kUpb_DecodeStatus_MissingRequired = 5, + + // Unlinked sub-message field was present, but + // kUpb_DecodeOptions_ExperimentalAllowUnlinked was not specified in the list + // of options. + kUpb_DecodeStatus_UnlinkedSubMessage = 6, +} upb_DecodeStatus; +// LINT.ThenChange(//depot/google3/third_party/protobuf/rust/upb.rs:decode_status) + +UPB_API upb_DecodeStatus upb_Decode(const char* buf, size_t size, + upb_Message* msg, const upb_MiniTable* mt, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena); + +// Same as upb_Decode but with a varint-encoded length prepended. +// On success 'num_bytes_read' will be set to the how many bytes were read, +// on failure the contents of num_bytes_read is undefined. +UPB_API upb_DecodeStatus upb_DecodeLengthPrefixed( + const char* buf, size_t size, upb_Message* msg, size_t* num_bytes_read, + const upb_MiniTable* mt, const upb_ExtensionRegistry* extreg, int options, + upb_Arena* arena); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_WIRE_DECODE_H_ */ + +// upb_Encode: parsing from a upb_Message using a upb_MiniTable. + +#ifndef UPB_WIRE_ENCODE_H_ +#define UPB_WIRE_ENCODE_H_ + +#include +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + /* If set, the results of serializing will be deterministic across all + * instances of this binary. There are no guarantees across different + * binary builds. + * + * If your proto contains maps, the encoder will need to malloc()/free() + * memory during encode. */ + kUpb_EncodeOption_Deterministic = 1, + + // When set, unknown fields are not encoded. + kUpb_EncodeOption_SkipUnknown = 2, + + // When set, the encode will fail if any required fields are missing. + kUpb_EncodeOption_CheckRequired = 4, +}; + +// LINT.IfChange +typedef enum { + kUpb_EncodeStatus_Ok = 0, + kUpb_EncodeStatus_OutOfMemory = 1, // Arena alloc failed + kUpb_EncodeStatus_MaxDepthExceeded = 2, + + // kUpb_EncodeOption_CheckRequired failed but the parse otherwise succeeded. + kUpb_EncodeStatus_MissingRequired = 3, +} upb_EncodeStatus; +// LINT.ThenChange(//depot/google3/third_party/protobuf/rust/upb.rs:encode_status) + +UPB_INLINE uint32_t upb_EncodeOptions_MaxDepth(uint16_t depth) { + return (uint32_t)depth << 16; +} + +UPB_INLINE uint16_t upb_EncodeOptions_GetMaxDepth(uint32_t options) { + return options >> 16; +} + +// Enforce an upper bound on recursion depth. +UPB_INLINE int upb_Encode_LimitDepth(uint32_t encode_options, uint32_t limit) { + uint32_t max_depth = upb_EncodeOptions_GetMaxDepth(encode_options); + if (max_depth > limit) max_depth = limit; + return upb_EncodeOptions_MaxDepth(max_depth) | (encode_options & 0xffff); +} + +UPB_API upb_EncodeStatus upb_Encode(const upb_Message* msg, + const upb_MiniTable* l, int options, + upb_Arena* arena, char** buf, size_t* size); + +// Encodes the message prepended by a varint of the serialized length. +UPB_API upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg, + const upb_MiniTable* l, + int options, upb_Arena* arena, + char** buf, size_t* size); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_WIRE_ENCODE_H_ */ + +// These are the specialized field parser functions for the fast parser. +// Generated tables will refer to these by name. +// +// The function names are encoded with names like: +// +// // 123 4 +// upb_pss_1bt(); // Parse singular string, 1 byte tag. +// +// In position 1: +// - 'p' for parse, most function use this +// - 'c' for copy, for when we are copying strings instead of aliasing +// +// In position 2 (cardinality): +// - 's' for singular, with or without hasbit +// - 'o' for oneof +// - 'r' for non-packed repeated +// - 'p' for packed repeated +// +// In position 3 (type): +// - 'b1' for bool +// - 'v4' for 4-byte varint +// - 'v8' for 8-byte varint +// - 'z4' for zig-zag-encoded 4-byte varint +// - 'z8' for zig-zag-encoded 8-byte varint +// - 'f4' for 4-byte fixed +// - 'f8' for 8-byte fixed +// - 'm' for sub-message +// - 's' for string (validate UTF-8) +// - 'b' for bytes +// +// In position 4 (tag length): +// - '1' for one-byte tags (field numbers 1-15) +// - '2' for two-byte tags (field numbers 16-2048) + +#ifndef UPB_WIRE_INTERNAL_DECODE_FAST_H_ +#define UPB_WIRE_INTERNAL_DECODE_FAST_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +struct upb_Decoder; + +// The fallback, generic parsing function that can handle any field type. +// This just uses the regular (non-fast) parser to parse a single field. +const char* _upb_FastDecoder_DecodeGeneric(struct upb_Decoder* d, + const char* ptr, upb_Message* msg, + intptr_t table, uint64_t hasbits, + uint64_t data); + +#define UPB_PARSE_PARAMS \ + struct upb_Decoder *d, const char *ptr, upb_Message *msg, intptr_t table, \ + uint64_t hasbits, uint64_t data + +/* primitive fields ***********************************************************/ + +#define F(card, type, valbytes, tagbytes) \ + const char* upb_p##card##type##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS); + +#define TYPES(card, tagbytes) \ + F(card, b, 1, tagbytes) \ + F(card, v, 4, tagbytes) \ + F(card, v, 8, tagbytes) \ + F(card, z, 4, tagbytes) \ + F(card, z, 8, tagbytes) \ + F(card, f, 4, tagbytes) \ + F(card, f, 8, tagbytes) + +#define TAGBYTES(card) \ + TYPES(card, 1) \ + TYPES(card, 2) + +TAGBYTES(s) +TAGBYTES(o) +TAGBYTES(r) +TAGBYTES(p) + +#undef F +#undef TYPES +#undef TAGBYTES + +/* string fields **************************************************************/ + +#define F(card, tagbytes, type) \ + const char* upb_p##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS); \ + const char* upb_c##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS); + +#define UTF8(card, tagbytes) \ + F(card, tagbytes, s) \ + F(card, tagbytes, b) + +#define TAGBYTES(card) \ + UTF8(card, 1) \ + UTF8(card, 2) + +TAGBYTES(s) +TAGBYTES(o) +TAGBYTES(r) + +#undef F +#undef UTF8 +#undef TAGBYTES + +/* sub-message fields *********************************************************/ + +#define F(card, tagbytes, size_ceil, ceil_arg) \ + const char* upb_p##card##m_##tagbytes##bt_max##size_ceil##b(UPB_PARSE_PARAMS); + +#define SIZES(card, tagbytes) \ + F(card, tagbytes, 64, 64) \ + F(card, tagbytes, 128, 128) \ + F(card, tagbytes, 192, 192) \ + F(card, tagbytes, 256, 256) \ + F(card, tagbytes, max, -1) + +#define TAGBYTES(card) \ + SIZES(card, 1) \ + SIZES(card, 2) + +TAGBYTES(s) +TAGBYTES(o) +TAGBYTES(r) + +#undef F +#undef SIZES +#undef TAGBYTES + +#undef UPB_PARSE_PARAMS + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_WIRE_INTERNAL_DECODE_FAST_H_ */ +// IWYU pragma: end_exports + +#endif // UPB_GENERATED_CODE_SUPPORT_H_ +/* This file was generated by upb_generator from the input file: + * + * google/protobuf/descriptor.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_MINITABLE_H_ +#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_MINITABLE_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +extern const upb_MiniTable google__protobuf__FileDescriptorSet_msg_init; +extern const upb_MiniTable google__protobuf__FileDescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__DescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__DescriptorProto__ExtensionRange_msg_init; +extern const upb_MiniTable google__protobuf__DescriptorProto__ReservedRange_msg_init; +extern const upb_MiniTable google__protobuf__ExtensionRangeOptions_msg_init; +extern const upb_MiniTable google__protobuf__ExtensionRangeOptions__Declaration_msg_init; +extern const upb_MiniTable google__protobuf__FieldDescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__OneofDescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__EnumDescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init; +extern const upb_MiniTable google__protobuf__EnumValueDescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__ServiceDescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__MethodDescriptorProto_msg_init; +extern const upb_MiniTable google__protobuf__FileOptions_msg_init; +extern const upb_MiniTable google__protobuf__MessageOptions_msg_init; +extern const upb_MiniTable google__protobuf__FieldOptions_msg_init; +extern const upb_MiniTable google__protobuf__FieldOptions__EditionDefault_msg_init; +extern const upb_MiniTable google__protobuf__FieldOptions__FeatureSupport_msg_init; +extern const upb_MiniTable google__protobuf__OneofOptions_msg_init; +extern const upb_MiniTable google__protobuf__EnumOptions_msg_init; +extern const upb_MiniTable google__protobuf__EnumValueOptions_msg_init; +extern const upb_MiniTable google__protobuf__ServiceOptions_msg_init; +extern const upb_MiniTable google__protobuf__MethodOptions_msg_init; +extern const upb_MiniTable google__protobuf__UninterpretedOption_msg_init; +extern const upb_MiniTable google__protobuf__UninterpretedOption__NamePart_msg_init; +extern const upb_MiniTable google__protobuf__FeatureSet_msg_init; +extern const upb_MiniTable google__protobuf__FeatureSetDefaults_msg_init; +extern const upb_MiniTable google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init; +extern const upb_MiniTable google__protobuf__SourceCodeInfo_msg_init; +extern const upb_MiniTable google__protobuf__SourceCodeInfo__Location_msg_init; +extern const upb_MiniTable google__protobuf__GeneratedCodeInfo_msg_init; +extern const upb_MiniTable google__protobuf__GeneratedCodeInfo__Annotation_msg_init; + +extern const upb_MiniTableEnum google_protobuf_Edition_enum_init; +extern const upb_MiniTableEnum google_protobuf_ExtensionRangeOptions_VerificationState_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_EnumType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_FieldPresence_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_JsonFormat_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_MessageEncoding_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_Utf8Validation_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Label_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Type_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_CType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_JSType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_OptionRetention_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_OptionTargetType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FileOptions_OptimizeMode_enum_init; +extern const upb_MiniTableEnum google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init; +extern const upb_MiniTableEnum google_protobuf_MethodOptions_IdempotencyLevel_enum_init; +extern const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_MINITABLE_H_ */ + +#ifndef UPB_WIRE_EPS_COPY_INPUT_STREAM_H_ +#define UPB_WIRE_EPS_COPY_INPUT_STREAM_H_ + +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// The maximum number of bytes a single protobuf field can take up in the +// wire format. We only want to do one bounds check per field, so the input +// stream guarantees that after upb_EpsCopyInputStream_IsDone() is called, +// the decoder can read this many bytes without performing another bounds +// check. The stream will copy into a patch buffer as necessary to guarantee +// this invariant. +#define kUpb_EpsCopyInputStream_SlopBytes 16 + +enum { + kUpb_EpsCopyInputStream_NoAliasing = 0, + kUpb_EpsCopyInputStream_OnPatch = 1, + kUpb_EpsCopyInputStream_NoDelta = 2 +}; + +typedef struct { + const char* end; // Can read up to SlopBytes bytes beyond this. + const char* limit_ptr; // For bounds checks, = end + UPB_MIN(limit, 0) + uintptr_t aliasing; + int limit; // Submessage limit relative to end + bool error; // To distinguish between EOF and error. + char patch[kUpb_EpsCopyInputStream_SlopBytes * 2]; +} upb_EpsCopyInputStream; + +// Returns true if the stream is in the error state. A stream enters the error +// state when the user reads past a limit (caught in IsDone()) or the +// ZeroCopyInputStream returns an error. +UPB_INLINE bool upb_EpsCopyInputStream_IsError(upb_EpsCopyInputStream* e) { + return e->error; +} + +typedef const char* upb_EpsCopyInputStream_BufferFlipCallback( + upb_EpsCopyInputStream* e, const char* old_end, const char* new_start); + +typedef const char* upb_EpsCopyInputStream_IsDoneFallbackFunc( + upb_EpsCopyInputStream* e, const char* ptr, int overrun); + +// Initializes a upb_EpsCopyInputStream using the contents of the buffer +// [*ptr, size]. Updates `*ptr` as necessary to guarantee that at least +// kUpb_EpsCopyInputStream_SlopBytes are available to read. +UPB_INLINE void upb_EpsCopyInputStream_Init(upb_EpsCopyInputStream* e, + const char** ptr, size_t size, + bool enable_aliasing) { + if (size <= kUpb_EpsCopyInputStream_SlopBytes) { + memset(&e->patch, 0, 32); + if (size) memcpy(&e->patch, *ptr, size); + e->aliasing = enable_aliasing ? (uintptr_t)*ptr - (uintptr_t)e->patch + : kUpb_EpsCopyInputStream_NoAliasing; + *ptr = e->patch; + e->end = *ptr + size; + e->limit = 0; + } else { + e->end = *ptr + size - kUpb_EpsCopyInputStream_SlopBytes; + e->limit = kUpb_EpsCopyInputStream_SlopBytes; + e->aliasing = enable_aliasing ? kUpb_EpsCopyInputStream_NoDelta + : kUpb_EpsCopyInputStream_NoAliasing; + } + e->limit_ptr = e->end; + e->error = false; +} + +typedef enum { + // The current stream position is at a limit. + kUpb_IsDoneStatus_Done, + + // The current stream position is not at a limit. + kUpb_IsDoneStatus_NotDone, + + // The current stream position is not at a limit, and the stream needs to + // be flipped to a new buffer before more data can be read. + kUpb_IsDoneStatus_NeedFallback, +} upb_IsDoneStatus; + +// Returns the status of the current stream position. This is a low-level +// function, it is simpler to call upb_EpsCopyInputStream_IsDone() if possible. +UPB_INLINE upb_IsDoneStatus upb_EpsCopyInputStream_IsDoneStatus( + upb_EpsCopyInputStream* e, const char* ptr, int* overrun) { + *overrun = ptr - e->end; + if (UPB_LIKELY(ptr < e->limit_ptr)) { + return kUpb_IsDoneStatus_NotDone; + } else if (UPB_LIKELY(*overrun == e->limit)) { + return kUpb_IsDoneStatus_Done; + } else { + return kUpb_IsDoneStatus_NeedFallback; + } +} + +// Returns true if the stream has hit a limit, either the current delimited +// limit or the overall end-of-stream. As a side effect, this function may flip +// the pointer to a new buffer if there are less than +// kUpb_EpsCopyInputStream_SlopBytes of data to be read in the current buffer. +// +// Postcondition: if the function returns false, there are at least +// kUpb_EpsCopyInputStream_SlopBytes of data available to read at *ptr. +UPB_INLINE bool upb_EpsCopyInputStream_IsDoneWithCallback( + upb_EpsCopyInputStream* e, const char** ptr, + upb_EpsCopyInputStream_IsDoneFallbackFunc* func) { + int overrun; + switch (upb_EpsCopyInputStream_IsDoneStatus(e, *ptr, &overrun)) { + case kUpb_IsDoneStatus_Done: + return true; + case kUpb_IsDoneStatus_NotDone: + return false; + case kUpb_IsDoneStatus_NeedFallback: + *ptr = func(e, *ptr, overrun); + return *ptr == NULL; + } + UPB_UNREACHABLE(); +} + +const char* _upb_EpsCopyInputStream_IsDoneFallbackNoCallback( + upb_EpsCopyInputStream* e, const char* ptr, int overrun); + +// A simpler version of IsDoneWithCallback() that does not support a buffer flip +// callback. Useful in cases where we do not need to insert custom logic at +// every buffer flip. +// +// If this returns true, the user must call upb_EpsCopyInputStream_IsError() +// to distinguish between EOF and error. +UPB_INLINE bool upb_EpsCopyInputStream_IsDone(upb_EpsCopyInputStream* e, + const char** ptr) { + return upb_EpsCopyInputStream_IsDoneWithCallback( + e, ptr, _upb_EpsCopyInputStream_IsDoneFallbackNoCallback); +} + +// Returns the total number of bytes that are safe to read from the current +// buffer without reading uninitialized or unallocated memory. +// +// Note that this check does not respect any semantic limits on the stream, +// either limits from PushLimit() or the overall stream end, so some of these +// bytes may have unpredictable, nonsense values in them. The guarantee is only +// that the bytes are valid to read from the perspective of the C language +// (ie. you can read without triggering UBSAN or ASAN). +UPB_INLINE size_t upb_EpsCopyInputStream_BytesAvailable( + upb_EpsCopyInputStream* e, const char* ptr) { + return (e->end - ptr) + kUpb_EpsCopyInputStream_SlopBytes; +} + +// Returns true if the given delimited field size is valid (it does not extend +// beyond any previously-pushed limits). `ptr` should point to the beginning +// of the field data, after the delimited size. +// +// Note that this does *not* guarantee that all of the data for this field is in +// the current buffer. +UPB_INLINE bool upb_EpsCopyInputStream_CheckSize( + const upb_EpsCopyInputStream* e, const char* ptr, int size) { + UPB_ASSERT(size >= 0); + return ptr - e->end + size <= e->limit; +} + +UPB_INLINE bool _upb_EpsCopyInputStream_CheckSizeAvailable( + upb_EpsCopyInputStream* e, const char* ptr, int size, bool submessage) { + // This is one extra branch compared to the more normal: + // return (size_t)(end - ptr) < size; + // However it is one less computation if we are just about to use "ptr + len": + // https://godbolt.org/z/35YGPz + // In microbenchmarks this shows a small improvement. + uintptr_t uptr = (uintptr_t)ptr; + uintptr_t uend = (uintptr_t)e->limit_ptr; + uintptr_t res = uptr + (size_t)size; + if (!submessage) uend += kUpb_EpsCopyInputStream_SlopBytes; + // NOTE: this check depends on having a linear address space. This is not + // technically guaranteed by uintptr_t. + bool ret = res >= uptr && res <= uend; + if (size < 0) UPB_ASSERT(!ret); + return ret; +} + +// Returns true if the given delimited field size is valid (it does not extend +// beyond any previously-pushed limited) *and* all of the data for this field is +// available to be read in the current buffer. +// +// If the size is negative, this function will always return false. This +// property can be useful in some cases. +UPB_INLINE bool upb_EpsCopyInputStream_CheckDataSizeAvailable( + upb_EpsCopyInputStream* e, const char* ptr, int size) { + return _upb_EpsCopyInputStream_CheckSizeAvailable(e, ptr, size, false); +} + +// Returns true if the given sub-message size is valid (it does not extend +// beyond any previously-pushed limited) *and* all of the data for this +// sub-message is available to be parsed in the current buffer. +// +// This implies that all fields from the sub-message can be parsed from the +// current buffer while maintaining the invariant that we always have at least +// kUpb_EpsCopyInputStream_SlopBytes of data available past the beginning of +// any individual field start. +// +// If the size is negative, this function will always return false. This +// property can be useful in some cases. +UPB_INLINE bool upb_EpsCopyInputStream_CheckSubMessageSizeAvailable( + upb_EpsCopyInputStream* e, const char* ptr, int size) { + return _upb_EpsCopyInputStream_CheckSizeAvailable(e, ptr, size, true); +} + +// Returns true if aliasing_enabled=true was passed to +// upb_EpsCopyInputStream_Init() when this stream was initialized. +UPB_INLINE bool upb_EpsCopyInputStream_AliasingEnabled( + upb_EpsCopyInputStream* e) { + return e->aliasing != kUpb_EpsCopyInputStream_NoAliasing; +} + +// Returns true if aliasing_enabled=true was passed to +// upb_EpsCopyInputStream_Init() when this stream was initialized *and* we can +// alias into the region [ptr, size] in an input buffer. +UPB_INLINE bool upb_EpsCopyInputStream_AliasingAvailable( + upb_EpsCopyInputStream* e, const char* ptr, size_t size) { + // When EpsCopyInputStream supports streaming, this will need to become a + // runtime check. + return upb_EpsCopyInputStream_CheckDataSizeAvailable(e, ptr, size) && + e->aliasing >= kUpb_EpsCopyInputStream_NoDelta; +} + +// Returns a pointer into an input buffer that corresponds to the parsing +// pointer `ptr`. The returned pointer may be the same as `ptr`, but also may +// be different if we are currently parsing out of the patch buffer. +// +// REQUIRES: Aliasing must be available for the given pointer. If the input is a +// flat buffer and aliasing is enabled, then aliasing will always be available. +UPB_INLINE const char* upb_EpsCopyInputStream_GetAliasedPtr( + upb_EpsCopyInputStream* e, const char* ptr) { + UPB_ASSUME(upb_EpsCopyInputStream_AliasingAvailable(e, ptr, 0)); + uintptr_t delta = + e->aliasing == kUpb_EpsCopyInputStream_NoDelta ? 0 : e->aliasing; + return (const char*)((uintptr_t)ptr + delta); +} + +// Reads string data from the input, aliasing into the input buffer instead of +// copying. The parsing pointer is passed in `*ptr`, and will be updated if +// necessary to point to the actual input buffer. Returns the new parsing +// pointer, which will be advanced past the string data. +// +// REQUIRES: Aliasing must be available for this data region (test with +// upb_EpsCopyInputStream_AliasingAvailable(). +UPB_INLINE const char* upb_EpsCopyInputStream_ReadStringAliased( + upb_EpsCopyInputStream* e, const char** ptr, size_t size) { + UPB_ASSUME(upb_EpsCopyInputStream_AliasingAvailable(e, *ptr, size)); + const char* ret = *ptr + size; + *ptr = upb_EpsCopyInputStream_GetAliasedPtr(e, *ptr); + UPB_ASSUME(ret != NULL); + return ret; +} + +// Skips `size` bytes of data from the input and returns a pointer past the end. +// Returns NULL on end of stream or error. +UPB_INLINE const char* upb_EpsCopyInputStream_Skip(upb_EpsCopyInputStream* e, + const char* ptr, int size) { + if (!upb_EpsCopyInputStream_CheckDataSizeAvailable(e, ptr, size)) return NULL; + return ptr + size; +} + +// Copies `size` bytes of data from the input `ptr` into the buffer `to`, and +// returns a pointer past the end. Returns NULL on end of stream or error. +UPB_INLINE const char* upb_EpsCopyInputStream_Copy(upb_EpsCopyInputStream* e, + const char* ptr, void* to, + int size) { + if (!upb_EpsCopyInputStream_CheckDataSizeAvailable(e, ptr, size)) return NULL; + memcpy(to, ptr, size); + return ptr + size; +} + +// Reads string data from the stream and advances the pointer accordingly. +// If aliasing was enabled when the stream was initialized, then the returned +// pointer will point into the input buffer if possible, otherwise new data +// will be allocated from arena and copied into. We may be forced to copy even +// if aliasing was enabled if the input data spans input buffers. +// +// Returns NULL if memory allocation failed, or we reached a premature EOF. +UPB_INLINE const char* upb_EpsCopyInputStream_ReadString( + upb_EpsCopyInputStream* e, const char** ptr, size_t size, + upb_Arena* arena) { + if (upb_EpsCopyInputStream_AliasingAvailable(e, *ptr, size)) { + return upb_EpsCopyInputStream_ReadStringAliased(e, ptr, size); + } else { + // We need to allocate and copy. + if (!upb_EpsCopyInputStream_CheckDataSizeAvailable(e, *ptr, size)) { + return NULL; + } + UPB_ASSERT(arena); + char* data = (char*)upb_Arena_Malloc(arena, size); + if (!data) return NULL; + const char* ret = upb_EpsCopyInputStream_Copy(e, *ptr, data, size); + *ptr = data; + return ret; + } +} + +UPB_INLINE void _upb_EpsCopyInputStream_CheckLimit(upb_EpsCopyInputStream* e) { + UPB_ASSERT(e->limit_ptr == e->end + UPB_MIN(0, e->limit)); +} + +// Pushes a limit onto the stack of limits for the current stream. The limit +// will extend for `size` bytes beyond the position in `ptr`. Future calls to +// upb_EpsCopyInputStream_IsDone() will return `true` when the stream position +// reaches this limit. +// +// Returns a delta that the caller must store and supply to PopLimit() below. +UPB_INLINE int upb_EpsCopyInputStream_PushLimit(upb_EpsCopyInputStream* e, + const char* ptr, int size) { + int limit = size + (int)(ptr - e->end); + int delta = e->limit - limit; + _upb_EpsCopyInputStream_CheckLimit(e); + UPB_ASSERT(limit <= e->limit); + e->limit = limit; + e->limit_ptr = e->end + UPB_MIN(0, limit); + _upb_EpsCopyInputStream_CheckLimit(e); + return delta; +} + +// Pops the last limit that was pushed on this stream. This may only be called +// once IsDone() returns true. The user must pass the delta that was returned +// from PushLimit(). +UPB_INLINE void upb_EpsCopyInputStream_PopLimit(upb_EpsCopyInputStream* e, + const char* ptr, + int saved_delta) { + UPB_ASSERT(ptr - e->end == e->limit); + _upb_EpsCopyInputStream_CheckLimit(e); + e->limit += saved_delta; + e->limit_ptr = e->end + UPB_MIN(0, e->limit); + _upb_EpsCopyInputStream_CheckLimit(e); +} + +UPB_INLINE const char* _upb_EpsCopyInputStream_IsDoneFallbackInline( + upb_EpsCopyInputStream* e, const char* ptr, int overrun, + upb_EpsCopyInputStream_BufferFlipCallback* callback) { + if (overrun < e->limit) { + // Need to copy remaining data into patch buffer. + UPB_ASSERT(overrun < kUpb_EpsCopyInputStream_SlopBytes); + const char* old_end = ptr; + const char* new_start = &e->patch[0] + overrun; + memset(e->patch + kUpb_EpsCopyInputStream_SlopBytes, 0, + kUpb_EpsCopyInputStream_SlopBytes); + memcpy(e->patch, e->end, kUpb_EpsCopyInputStream_SlopBytes); + ptr = new_start; + e->end = &e->patch[kUpb_EpsCopyInputStream_SlopBytes]; + e->limit -= kUpb_EpsCopyInputStream_SlopBytes; + e->limit_ptr = e->end + e->limit; + UPB_ASSERT(ptr < e->limit_ptr); + if (e->aliasing != kUpb_EpsCopyInputStream_NoAliasing) { + e->aliasing = (uintptr_t)old_end - (uintptr_t)new_start; + } + return callback(e, old_end, new_start); + } else { + UPB_ASSERT(overrun > e->limit); + e->error = true; + return callback(e, NULL, NULL); + } +} + +typedef const char* upb_EpsCopyInputStream_ParseDelimitedFunc( + upb_EpsCopyInputStream* e, const char* ptr, void* ctx); + +// Tries to perform a fast-path handling of the given delimited message data. +// If the sub-message beginning at `*ptr` and extending for `len` is short and +// fits within this buffer, calls `func` with `ctx` as a parameter, where the +// pushing and popping of limits is handled automatically and with lower cost +// than the normal PushLimit()/PopLimit() sequence. +UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast( + upb_EpsCopyInputStream* e, const char** ptr, int len, + upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) { + if (!upb_EpsCopyInputStream_CheckSubMessageSizeAvailable(e, *ptr, len)) { + return false; + } + + // Fast case: Sub-message is <128 bytes and fits in the current buffer. + // This means we can preserve limit/limit_ptr verbatim. + const char* saved_limit_ptr = e->limit_ptr; + int saved_limit = e->limit; + e->limit_ptr = *ptr + len; + e->limit = e->limit_ptr - e->end; + UPB_ASSERT(e->limit_ptr == e->end + UPB_MIN(0, e->limit)); + *ptr = func(e, *ptr, ctx); + e->limit_ptr = saved_limit_ptr; + e->limit = saved_limit; + UPB_ASSERT(e->limit_ptr == e->end + UPB_MIN(0, e->limit)); + return true; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_WIRE_EPS_COPY_INPUT_STREAM_H_ + +#ifndef UPB_JSON_DECODE_H_ +#define UPB_JSON_DECODE_H_ + + +#ifndef UPB_REFLECTION_DEF_H_ +#define UPB_REFLECTION_DEF_H_ + +// IWYU pragma: begin_exports + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_DEF_POOL_H_ +#define UPB_REFLECTION_DEF_POOL_H_ + + +// IWYU pragma: private, include "upb/reflection/def.h" + +// Declarations common to all public def types. + +#ifndef UPB_REFLECTION_COMMON_H_ +#define UPB_REFLECTION_COMMON_H_ + +// begin:google_only +// #ifndef UPB_BOOTSTRAP_STAGE0 +// #include "net/proto2/proto/descriptor.upb.h" +// #else +// #include "google/protobuf/descriptor.upb.h" +// #endif +// end:google_only + +// begin:github_only +/* This file was generated by upb_generator from the input file: + * + * google/protobuf/descriptor.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ +#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ + + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct google_protobuf_FileDescriptorSet { upb_Message UPB_PRIVATE(base); } google_protobuf_FileDescriptorSet; +typedef struct google_protobuf_FileDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_FileDescriptorProto; +typedef struct google_protobuf_DescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_DescriptorProto; +typedef struct google_protobuf_DescriptorProto_ExtensionRange { upb_Message UPB_PRIVATE(base); } google_protobuf_DescriptorProto_ExtensionRange; +typedef struct google_protobuf_DescriptorProto_ReservedRange { upb_Message UPB_PRIVATE(base); } google_protobuf_DescriptorProto_ReservedRange; +typedef struct google_protobuf_ExtensionRangeOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_ExtensionRangeOptions; +typedef struct google_protobuf_ExtensionRangeOptions_Declaration { upb_Message UPB_PRIVATE(base); } google_protobuf_ExtensionRangeOptions_Declaration; +typedef struct google_protobuf_FieldDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldDescriptorProto; +typedef struct google_protobuf_OneofDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_OneofDescriptorProto; +typedef struct google_protobuf_EnumDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumDescriptorProto; +typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumDescriptorProto_EnumReservedRange; +typedef struct google_protobuf_EnumValueDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumValueDescriptorProto; +typedef struct google_protobuf_ServiceDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_ServiceDescriptorProto; +typedef struct google_protobuf_MethodDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_MethodDescriptorProto; +typedef struct google_protobuf_FileOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_FileOptions; +typedef struct google_protobuf_MessageOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_MessageOptions; +typedef struct google_protobuf_FieldOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldOptions; +typedef struct google_protobuf_FieldOptions_EditionDefault { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldOptions_EditionDefault; +typedef struct google_protobuf_FieldOptions_FeatureSupport { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldOptions_FeatureSupport; +typedef struct google_protobuf_OneofOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_OneofOptions; +typedef struct google_protobuf_EnumOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumOptions; +typedef struct google_protobuf_EnumValueOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumValueOptions; +typedef struct google_protobuf_ServiceOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_ServiceOptions; +typedef struct google_protobuf_MethodOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_MethodOptions; +typedef struct google_protobuf_UninterpretedOption { upb_Message UPB_PRIVATE(base); } google_protobuf_UninterpretedOption; +typedef struct google_protobuf_UninterpretedOption_NamePart { upb_Message UPB_PRIVATE(base); } google_protobuf_UninterpretedOption_NamePart; +typedef struct google_protobuf_FeatureSet { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSet; +typedef struct google_protobuf_FeatureSetDefaults { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSetDefaults; +typedef struct google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault; +typedef struct google_protobuf_SourceCodeInfo { upb_Message UPB_PRIVATE(base); } google_protobuf_SourceCodeInfo; +typedef struct google_protobuf_SourceCodeInfo_Location { upb_Message UPB_PRIVATE(base); } google_protobuf_SourceCodeInfo_Location; +typedef struct google_protobuf_GeneratedCodeInfo { upb_Message UPB_PRIVATE(base); } google_protobuf_GeneratedCodeInfo; +typedef struct google_protobuf_GeneratedCodeInfo_Annotation { upb_Message UPB_PRIVATE(base); } google_protobuf_GeneratedCodeInfo_Annotation; + +typedef enum { + google_protobuf_EDITION_UNKNOWN = 0, + google_protobuf_EDITION_1_TEST_ONLY = 1, + google_protobuf_EDITION_2_TEST_ONLY = 2, + google_protobuf_EDITION_LEGACY = 900, + google_protobuf_EDITION_PROTO2 = 998, + google_protobuf_EDITION_PROTO3 = 999, + google_protobuf_EDITION_2023 = 1000, + google_protobuf_EDITION_2024 = 1001, + google_protobuf_EDITION_99997_TEST_ONLY = 99997, + google_protobuf_EDITION_99998_TEST_ONLY = 99998, + google_protobuf_EDITION_99999_TEST_ONLY = 99999, + google_protobuf_EDITION_MAX = 2147483647 +} google_protobuf_Edition; + +typedef enum { + google_protobuf_ExtensionRangeOptions_DECLARATION = 0, + google_protobuf_ExtensionRangeOptions_UNVERIFIED = 1 +} google_protobuf_ExtensionRangeOptions_VerificationState; + +typedef enum { + google_protobuf_FeatureSet_ENUM_TYPE_UNKNOWN = 0, + google_protobuf_FeatureSet_OPEN = 1, + google_protobuf_FeatureSet_CLOSED = 2 +} google_protobuf_FeatureSet_EnumType; + +typedef enum { + google_protobuf_FeatureSet_FIELD_PRESENCE_UNKNOWN = 0, + google_protobuf_FeatureSet_EXPLICIT = 1, + google_protobuf_FeatureSet_IMPLICIT = 2, + google_protobuf_FeatureSet_LEGACY_REQUIRED = 3 +} google_protobuf_FeatureSet_FieldPresence; + +typedef enum { + google_protobuf_FeatureSet_JSON_FORMAT_UNKNOWN = 0, + google_protobuf_FeatureSet_ALLOW = 1, + google_protobuf_FeatureSet_LEGACY_BEST_EFFORT = 2 +} google_protobuf_FeatureSet_JsonFormat; + +typedef enum { + google_protobuf_FeatureSet_MESSAGE_ENCODING_UNKNOWN = 0, + google_protobuf_FeatureSet_LENGTH_PREFIXED = 1, + google_protobuf_FeatureSet_DELIMITED = 2 +} google_protobuf_FeatureSet_MessageEncoding; + +typedef enum { + google_protobuf_FeatureSet_REPEATED_FIELD_ENCODING_UNKNOWN = 0, + google_protobuf_FeatureSet_PACKED = 1, + google_protobuf_FeatureSet_EXPANDED = 2 +} google_protobuf_FeatureSet_RepeatedFieldEncoding; + +typedef enum { + google_protobuf_FeatureSet_UTF8_VALIDATION_UNKNOWN = 0, + google_protobuf_FeatureSet_VERIFY = 2, + google_protobuf_FeatureSet_NONE = 3 +} google_protobuf_FeatureSet_Utf8Validation; + +typedef enum { + google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1, + google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2, + google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3 +} google_protobuf_FieldDescriptorProto_Label; + +typedef enum { + google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1, + google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2, + google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3, + google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4, + google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5, + google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6, + google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7, + google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8, + google_protobuf_FieldDescriptorProto_TYPE_STRING = 9, + google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10, + google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11, + google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12, + google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13, + google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14, + google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15, + google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16, + google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17, + google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18 +} google_protobuf_FieldDescriptorProto_Type; + +typedef enum { + google_protobuf_FieldOptions_STRING = 0, + google_protobuf_FieldOptions_CORD = 1, + google_protobuf_FieldOptions_STRING_PIECE = 2 +} google_protobuf_FieldOptions_CType; + +typedef enum { + google_protobuf_FieldOptions_JS_NORMAL = 0, + google_protobuf_FieldOptions_JS_STRING = 1, + google_protobuf_FieldOptions_JS_NUMBER = 2 +} google_protobuf_FieldOptions_JSType; + +typedef enum { + google_protobuf_FieldOptions_RETENTION_UNKNOWN = 0, + google_protobuf_FieldOptions_RETENTION_RUNTIME = 1, + google_protobuf_FieldOptions_RETENTION_SOURCE = 2 +} google_protobuf_FieldOptions_OptionRetention; + +typedef enum { + google_protobuf_FieldOptions_TARGET_TYPE_UNKNOWN = 0, + google_protobuf_FieldOptions_TARGET_TYPE_FILE = 1, + google_protobuf_FieldOptions_TARGET_TYPE_EXTENSION_RANGE = 2, + google_protobuf_FieldOptions_TARGET_TYPE_MESSAGE = 3, + google_protobuf_FieldOptions_TARGET_TYPE_FIELD = 4, + google_protobuf_FieldOptions_TARGET_TYPE_ONEOF = 5, + google_protobuf_FieldOptions_TARGET_TYPE_ENUM = 6, + google_protobuf_FieldOptions_TARGET_TYPE_ENUM_ENTRY = 7, + google_protobuf_FieldOptions_TARGET_TYPE_SERVICE = 8, + google_protobuf_FieldOptions_TARGET_TYPE_METHOD = 9 +} google_protobuf_FieldOptions_OptionTargetType; + +typedef enum { + google_protobuf_FileOptions_SPEED = 1, + google_protobuf_FileOptions_CODE_SIZE = 2, + google_protobuf_FileOptions_LITE_RUNTIME = 3 +} google_protobuf_FileOptions_OptimizeMode; + +typedef enum { + google_protobuf_GeneratedCodeInfo_Annotation_NONE = 0, + google_protobuf_GeneratedCodeInfo_Annotation_SET = 1, + google_protobuf_GeneratedCodeInfo_Annotation_ALIAS = 2 +} google_protobuf_GeneratedCodeInfo_Annotation_Semantic; + +typedef enum { + google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0, + google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1, + google_protobuf_MethodOptions_IDEMPOTENT = 2 +} google_protobuf_MethodOptions_IdempotencyLevel; + + + +/* google.protobuf.FileDescriptorSet */ + +UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_new(upb_Arena* arena) { + return (google_protobuf_FileDescriptorSet*)_upb_Message_New(&google__protobuf__FileDescriptorSet_msg_init, arena); +} +UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorSet_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorSet_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorSet_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize_ex(const google_protobuf_FileDescriptorSet* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorSet_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FileDescriptorSet_clear_file(google_protobuf_FileDescriptorSet* msg) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet* msg, size_t* size) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_FileDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorSet_file_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorSet_file_mutable_upb_array(google_protobuf_FileDescriptorSet* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet* msg, size_t* size) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_FileDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FileDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet* msg, upb_Arena* arena) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_Message_New(&google__protobuf__FileDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.FileDescriptorProto */ + +UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_FileDescriptorProto*)_upb_Message_New(&google__protobuf__FileDescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize_ex(const google_protobuf_FileDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_name(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_package(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_message_type(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_DescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_message_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_message_type_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_enum_type(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_EnumDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_enum_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_enum_type_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_service(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_ServiceDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_service_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_service_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_extension(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_FieldDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_extension_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_extension_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_options(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto* msg) { + const google_protobuf_FileOptions* default_val = NULL; + const google_protobuf_FileOptions* ret; + const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_source_code_info(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto* msg) { + const google_protobuf_SourceCodeInfo* default_val = NULL; + const google_protobuf_SourceCodeInfo* ret; + const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_public_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_weak_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_syntax(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_edition(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FileDescriptorProto_edition(const google_protobuf_FileDescriptorProto* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_edition(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_DescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(&google__protobuf__DescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_EnumDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google__protobuf__EnumDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_ServiceDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_ServiceDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)_upb_Message_New(&google__protobuf__ServiceDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_FieldDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) { + const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FileOptions*)_upb_Message_New(&google__protobuf__FileOptions_msg_init, arena); + if (sub) google_protobuf_FileDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) { + const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg); + if (sub == NULL) { + sub = (struct google_protobuf_SourceCodeInfo*)_upb_Message_New(&google__protobuf__SourceCodeInfo_msg_init, arena); + if (sub) google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub); + } + return sub; +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_edition(google_protobuf_FileDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.DescriptorProto */ + +UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_DescriptorProto*)_upb_Message_New(&google__protobuf__DescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_DescriptorProto_serialize_ex(const google_protobuf_DescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_name(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_field(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_FieldDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_field_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_field_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_nested_type(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_DescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_nested_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_nested_type_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_enum_type(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_EnumDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_enum_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_enum_type_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_extension_range(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_DescriptorProto_ExtensionRange* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_range_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_extension(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_FieldDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_options(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto* msg) { + const google_protobuf_MessageOptions* default_val = NULL; + const google_protobuf_MessageOptions* ret; + const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_oneof_decl(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_OneofDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_oneof_decl_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_oneof_decl_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_range(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_DescriptorProto_ReservedRange* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_range_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_name(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_name_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_name_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_FieldDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_DescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(&google__protobuf__DescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_EnumDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google__protobuf__EnumDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_DescriptorProto_ExtensionRange**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto_ExtensionRange**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ExtensionRange_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_FieldDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) { + const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_MessageOptions*)_upb_Message_New(&google__protobuf__MessageOptions_msg_init, arena); + if (sub) google_protobuf_DescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_OneofDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_OneofDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)_upb_Message_New(&google__protobuf__OneofDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_DescriptorProto_ReservedRange**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto_ReservedRange**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ReservedRange_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} + +/* google.protobuf.DescriptorProto.ExtensionRange */ + +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_new(upb_Arena* arena) { + return (google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ExtensionRange_msg_init, arena); +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize_ex(const google_protobuf_DescriptorProto_ExtensionRange* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_start(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_end(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_options(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const google_protobuf_ExtensionRangeOptions* default_val = NULL; + const google_protobuf_ExtensionRangeOptions* ret; + const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) { + const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena) { + struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_ExtensionRangeOptions*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions_msg_init, arena); + if (sub) google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.DescriptorProto.ReservedRange */ + +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_new(upb_Arena* arena) { + return (google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ReservedRange_msg_init, arena); +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ReservedRange_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ReservedRange_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ReservedRange_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize_ex(const google_protobuf_DescriptorProto_ReservedRange* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ReservedRange_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_start(google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_end(google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.ExtensionRangeOptions */ + +UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_new(upb_Arena* arena) { + return (google_protobuf_ExtensionRangeOptions*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize_ex(const google_protobuf_ExtensionRangeOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_declaration(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_ExtensionRangeOptions_Declaration* const* google_protobuf_ExtensionRangeOptions_declaration(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_ExtensionRangeOptions_Declaration* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_mutable_upb_array(google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_verification(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_ExtensionRangeOptions_verification(const google_protobuf_ExtensionRangeOptions* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_verification(const google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_features(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_ExtensionRangeOptions_features(const google_protobuf_ExtensionRangeOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_features(const google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_mutable_upb_array(google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration** google_protobuf_ExtensionRangeOptions_mutable_declaration(google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_ExtensionRangeOptions_Declaration**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration** google_protobuf_ExtensionRangeOptions_resize_declaration(google_protobuf_ExtensionRangeOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_ExtensionRangeOptions_Declaration**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_add_declaration(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_ExtensionRangeOptions_Declaration* sub = (struct google_protobuf_ExtensionRangeOptions_Declaration*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_set_verification(google_protobuf_ExtensionRangeOptions *msg, int32_t value) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_set_features(google_protobuf_ExtensionRangeOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_ExtensionRangeOptions_mutable_features(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_ExtensionRangeOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_ExtensionRangeOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.ExtensionRangeOptions.Declaration */ + +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_new(upb_Arena* arena) { + return (google_protobuf_ExtensionRangeOptions_Declaration*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init, arena); +} +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions_Declaration* ret = google_protobuf_ExtensionRangeOptions_Declaration_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions_Declaration* ret = google_protobuf_ExtensionRangeOptions_Declaration_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_Declaration_serialize(const google_protobuf_ExtensionRangeOptions_Declaration* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_Declaration_serialize_ex(const google_protobuf_ExtensionRangeOptions_Declaration* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_number(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_ExtensionRangeOptions_Declaration_number(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_number(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_full_name(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_ExtensionRangeOptions_Declaration_full_name(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_full_name(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_type(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_ExtensionRangeOptions_Declaration_type(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_type(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_reserved(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_reserved(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_reserved(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_repeated(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_repeated(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_repeated(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_number(google_protobuf_ExtensionRangeOptions_Declaration *msg, int32_t value) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_full_name(google_protobuf_ExtensionRangeOptions_Declaration *msg, upb_StringView value) { + const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_type(google_protobuf_ExtensionRangeOptions_Declaration *msg, upb_StringView value) { + const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_reserved(google_protobuf_ExtensionRangeOptions_Declaration *msg, bool value) { + const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_repeated(google_protobuf_ExtensionRangeOptions_Declaration *msg, bool value) { + const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.FieldDescriptorProto */ + +UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldDescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldDescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldDescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize_ex(const google_protobuf_FieldDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldDescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_extendee(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_number(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_label(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {5, 20, 68, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = {5, 20, 68, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {5, 20, 68, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(52, 64), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {6, UPB_SIZE(52, 64), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(52, 64), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_default_value(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(60, 80), 70, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {7, UPB_SIZE(60, 80), 70, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(60, 80), 70, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_options(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(24, 96), 71, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto* msg) { + const google_protobuf_FieldOptions* default_val = NULL; + const google_protobuf_FieldOptions* ret; + const upb_MiniTableField field = {8, UPB_SIZE(24, 96), 71, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(24, 96), 71, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_oneof_index(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {9, UPB_SIZE(28, 24), 72, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {9, UPB_SIZE(28, 24), 72, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {9, UPB_SIZE(28, 24), 72, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_json_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {10, UPB_SIZE(68, 104), 73, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {10, UPB_SIZE(68, 104), 73, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {10, UPB_SIZE(68, 104), 73, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_proto3_optional(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {17, UPB_SIZE(32, 28), 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {17, UPB_SIZE(32, 28), 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_proto3_optional(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {17, UPB_SIZE(32, 28), 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = {5, 20, 68, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {6, UPB_SIZE(52, 64), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {7, UPB_SIZE(60, 80), 70, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) { + const upb_MiniTableField field = {8, UPB_SIZE(24, 96), 71, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FieldOptions*)_upb_Message_New(&google__protobuf__FieldOptions_msg_init, arena); + if (sub) google_protobuf_FieldDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = {9, UPB_SIZE(28, 24), 72, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {10, UPB_SIZE(68, 104), 73, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_proto3_optional(google_protobuf_FieldDescriptorProto *msg, bool value) { + const upb_MiniTableField field = {17, UPB_SIZE(32, 28), 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.OneofDescriptorProto */ + +UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_OneofDescriptorProto*)_upb_Message_New(&google__protobuf__OneofDescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__OneofDescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__OneofDescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__OneofDescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize_ex(const google_protobuf_OneofDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__OneofDescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_clear_name(google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = {1, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = {1, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_clear_options(google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto* msg) { + const google_protobuf_OneofOptions* default_val = NULL; + const google_protobuf_OneofOptions* ret; + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_OneofOptions*)_upb_Message_New(&google__protobuf__OneofOptions_msg_init, arena); + if (sub) google_protobuf_OneofDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.EnumDescriptorProto */ + +UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google__protobuf__EnumDescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumDescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumDescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumDescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize_ex(const google_protobuf_EnumDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumDescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_name(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(28, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(28, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(28, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_value(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_EnumValueDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_value_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_value_mutable_upb_array(google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_options(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto* msg) { + const google_protobuf_EnumOptions* default_val = NULL; + const google_protobuf_EnumOptions* ret; + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_reserved_range(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_mutable_upb_array(google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_reserved_name(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_mutable_upb_array(google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(28, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_EnumValueDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_resize_value(google_protobuf_EnumDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumValueDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumDescriptorProto_add_value(google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumValueDescriptorProto* sub = (struct google_protobuf_EnumValueDescriptorProto*)_upb_Message_New(&google__protobuf__EnumValueDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto *msg, google_protobuf_EnumOptions* value) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_EnumOptions* sub = (struct google_protobuf_EnumOptions*)google_protobuf_EnumDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_EnumOptions*)_upb_Message_New(&google__protobuf__EnumOptions_msg_init, arena); + if (sub) google_protobuf_EnumDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_mutable_reserved_range(google_protobuf_EnumDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_resize_reserved_range(google_protobuf_EnumDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_add_reserved_range(google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumDescriptorProto_EnumReservedRange* sub = (struct google_protobuf_EnumDescriptorProto_EnumReservedRange*)_upb_Message_New(&google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE upb_StringView* google_protobuf_EnumDescriptorProto_mutable_reserved_name(google_protobuf_EnumDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_EnumDescriptorProto_resize_reserved_name(google_protobuf_EnumDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_protobuf_EnumDescriptorProto* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} + +/* google.protobuf.EnumDescriptorProto.EnumReservedRange */ + +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_Arena* arena) { + return (google_protobuf_EnumDescriptorProto_EnumReservedRange*)_upb_Message_New(&google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init, arena); +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto_EnumReservedRange* ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto_EnumReservedRange* ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize_ex(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_clear_start(google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_clear_end(google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { + const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.EnumValueDescriptorProto */ + +UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_EnumValueDescriptorProto*)_upb_Message_New(&google__protobuf__EnumValueDescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumValueDescriptorProto* ret = google_protobuf_EnumValueDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumValueDescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumValueDescriptorProto* ret = google_protobuf_EnumValueDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumValueDescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumValueDescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumValueDescriptorProto_serialize_ex(const google_protobuf_EnumValueDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumValueDescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_name(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_number(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {2, 12, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {2, 12, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {2, 12, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_options(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 32), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto* msg) { + const google_protobuf_EnumValueOptions* default_val = NULL; + const google_protobuf_EnumValueOptions* ret; + const upb_MiniTableField field = {3, UPB_SIZE(16, 32), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 32), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = {2, 12, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto *msg, google_protobuf_EnumValueOptions* value) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 32), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_EnumValueOptions* sub = (struct google_protobuf_EnumValueOptions*)google_protobuf_EnumValueDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_EnumValueOptions*)_upb_Message_New(&google__protobuf__EnumValueOptions_msg_init, arena); + if (sub) google_protobuf_EnumValueDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.ServiceDescriptorProto */ + +UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_ServiceDescriptorProto*)_upb_Message_New(&google__protobuf__ServiceDescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ServiceDescriptorProto* ret = google_protobuf_ServiceDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ServiceDescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ServiceDescriptorProto* ret = google_protobuf_ServiceDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ServiceDescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ServiceDescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ServiceDescriptorProto_serialize_ex(const google_protobuf_ServiceDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ServiceDescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_clear_name(google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_clear_method(google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_MethodDescriptorProto* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_ServiceDescriptorProto_method_upb_array(const google_protobuf_ServiceDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ServiceDescriptorProto_method_mutable_upb_array(google_protobuf_ServiceDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_clear_options(google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto* msg) { + const google_protobuf_ServiceOptions* default_val = NULL; + const google_protobuf_ServiceOptions* ret; + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_MethodDescriptorProto**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_resize_method(google_protobuf_ServiceDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_MethodDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_MethodDescriptorProto* google_protobuf_ServiceDescriptorProto_add_method(google_protobuf_ServiceDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_MethodDescriptorProto* sub = (struct google_protobuf_MethodDescriptorProto*)_upb_Message_New(&google__protobuf__MethodDescriptorProto_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto *msg, google_protobuf_ServiceOptions* value) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_ServiceOptions* sub = (struct google_protobuf_ServiceOptions*)google_protobuf_ServiceDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_ServiceOptions*)_upb_Message_New(&google__protobuf__ServiceOptions_msg_init, arena); + if (sub) google_protobuf_ServiceDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.MethodDescriptorProto */ + +UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_MethodDescriptorProto*)_upb_Message_New(&google__protobuf__MethodDescriptorProto_msg_init, arena); +} +UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_MethodDescriptorProto* ret = google_protobuf_MethodDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__MethodDescriptorProto_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_MethodDescriptorProto* ret = google_protobuf_MethodDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__MethodDescriptorProto_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__MethodDescriptorProto_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_MethodDescriptorProto_serialize_ex(const google_protobuf_MethodDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__MethodDescriptorProto_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_name(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_input_type(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_output_type(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(36, 48), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {3, UPB_SIZE(36, 48), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(36, 48), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_options(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 64), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto* msg) { + const google_protobuf_MethodOptions* default_val = NULL; + const google_protobuf_MethodOptions* ret; + const upb_MiniTableField field = {4, UPB_SIZE(12, 64), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 64), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_client_streaming(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 9), 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {5, UPB_SIZE(16, 9), 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 9), 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_server_streaming(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(17, 10), 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {6, UPB_SIZE(17, 10), 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(17, 10), 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(20, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = {3, UPB_SIZE(36, 48), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto *msg, google_protobuf_MethodOptions* value) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 64), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_MethodOptions* sub = (struct google_protobuf_MethodOptions*)google_protobuf_MethodDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_MethodOptions*)_upb_Message_New(&google__protobuf__MethodOptions_msg_init, arena); + if (sub) google_protobuf_MethodDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 9), 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { + const upb_MiniTableField field = {6, UPB_SIZE(17, 10), 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.FileOptions */ + +UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_new(upb_Arena* arena) { + return (google_protobuf_FileOptions*)_upb_Message_New(&google__protobuf__FileOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FileOptions* ret = google_protobuf_FileOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FileOptions* ret = google_protobuf_FileOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FileOptions_serialize_ex(const google_protobuf_FileOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(32, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(32, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(32, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_outer_classname(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {8, 40, 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {8, 40, 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {8, 40, 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_optimize_for(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {9, 12, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = {9, 12, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {9, 12, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_multiple_files(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {10, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {10, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {10, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_go_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {11, UPB_SIZE(48, 56), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {11, UPB_SIZE(48, 56), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {11, UPB_SIZE(48, 56), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_cc_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {16, 17, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {16, 17, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {16, 17, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {17, 18, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {17, 18, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {17, 18, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_py_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {18, 19, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {18, 19, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {18, 19, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_generate_equals_and_hash(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {20, 20, 72, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {20, 20, 72, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {20, 20, 72, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_deprecated(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {23, 21, 73, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {23, 21, 73, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {23, 21, 73, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_string_check_utf8(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {27, 22, 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {27, 22, 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {27, 22, 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_cc_enable_arenas(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {31, 23, 75, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions* msg) { + bool default_val = true; + bool ret; + const upb_MiniTableField field = {31, 23, 75, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {31, 23, 75, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_objc_class_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {36, UPB_SIZE(56, 72), 76, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {36, UPB_SIZE(56, 72), 76, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {36, UPB_SIZE(56, 72), 76, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_csharp_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {37, UPB_SIZE(64, 88), 77, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {37, UPB_SIZE(64, 88), 77, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {37, UPB_SIZE(64, 88), 77, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_swift_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {39, UPB_SIZE(72, 104), 78, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {39, UPB_SIZE(72, 104), 78, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {39, UPB_SIZE(72, 104), 78, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_class_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {40, UPB_SIZE(80, 120), 79, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {40, UPB_SIZE(80, 120), 79, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {40, UPB_SIZE(80, 120), 79, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {41, UPB_SIZE(88, 136), 80, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {41, UPB_SIZE(88, 136), 80, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {41, UPB_SIZE(88, 136), 80, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_metadata_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {44, UPB_SIZE(96, 152), 81, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {44, UPB_SIZE(96, 152), 81, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {44, UPB_SIZE(96, 152), 81, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_ruby_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {45, UPB_SIZE(104, 168), 82, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {45, UPB_SIZE(104, 168), 82, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {45, UPB_SIZE(104, 168), 82, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_features(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(24, 184), 83, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_FileOptions_features(const google_protobuf_FileOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {50, UPB_SIZE(24, 184), 83, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_features(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(24, 184), 83, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_uninterpreted_option(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileOptions_uninterpreted_option_upb_array(const google_protobuf_FileOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileOptions_uninterpreted_option_mutable_upb_array(google_protobuf_FileOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(32, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {8, 40, 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions *msg, int32_t value) { + const upb_MiniTableField field = {9, 12, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {10, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {11, UPB_SIZE(48, 56), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {16, 17, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {17, 18, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {18, 19, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {20, 20, 72, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {23, 21, 73, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {27, 22, 74, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {31, 23, 75, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {36, UPB_SIZE(56, 72), 76, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {37, UPB_SIZE(64, 88), 77, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {39, UPB_SIZE(72, 104), 78, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {40, UPB_SIZE(80, 120), 79, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {41, UPB_SIZE(88, 136), 80, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {44, UPB_SIZE(96, 152), 81, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = {45, UPB_SIZE(104, 168), 82, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_features(google_protobuf_FileOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {50, UPB_SIZE(24, 184), 83, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FileOptions_mutable_features(google_protobuf_FileOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_FileOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_FileOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_resize_uninterpreted_option(google_protobuf_FileOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FileOptions_add_uninterpreted_option(google_protobuf_FileOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(28, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.MessageOptions */ + +UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_new(upb_Arena* arena) { + return (google_protobuf_MessageOptions*)_upb_Message_New(&google__protobuf__MessageOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_MessageOptions* ret = google_protobuf_MessageOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__MessageOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_MessageOptions* ret = google_protobuf_MessageOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__MessageOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__MessageOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_MessageOptions_serialize_ex(const google_protobuf_MessageOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__MessageOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_MessageOptions_clear_message_set_wire_format(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_no_standard_descriptor_accessor(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {2, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {2, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {2, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_deprecated(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {3, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {3, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {3, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_map_entry(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {7, 12, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {7, 12, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {7, 12, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_deprecated_legacy_json_field_conflicts(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {11, 13, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_deprecated_legacy_json_field_conflicts(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {11, 13, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated_legacy_json_field_conflicts(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {11, 13, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_features(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {12, 16, 69, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_MessageOptions_features(const google_protobuf_MessageOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {12, 16, 69, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_features(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {12, 16, 69, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_uninterpreted_option(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_upb_array(const google_protobuf_MessageOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_mutable_upb_array(google_protobuf_MessageOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = {2, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = {3, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = {7, 12, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_deprecated_legacy_json_field_conflicts(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = {11, 13, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_features(google_protobuf_MessageOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {12, 16, 69, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_MessageOptions_mutable_features(google_protobuf_MessageOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_MessageOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_MessageOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_resize_uninterpreted_option(google_protobuf_MessageOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MessageOptions_add_uninterpreted_option(google_protobuf_MessageOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.FieldOptions */ + +UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_new(upb_Arena* arena) { + return (google_protobuf_FieldOptions*)_upb_Message_New(&google__protobuf__FieldOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FieldOptions* ret = google_protobuf_FieldOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FieldOptions* ret = google_protobuf_FieldOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FieldOptions_serialize_ex(const google_protobuf_FieldOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FieldOptions_clear_ctype(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {1, 12, 64, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {1, 12, 64, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {1, 12, 64, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_packed(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_deprecated(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {3, 17, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {3, 17, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {3, 17, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_lazy(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {5, 18, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {5, 18, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {5, 18, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_jstype(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {6, 20, 68, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {6, 20, 68, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {6, 20, 68, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_weak(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {10, 24, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {10, 24, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {10, 24, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_unverified_lazy(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {15, 25, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_unverified_lazy(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {15, 25, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_unverified_lazy(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {15, 25, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_debug_redact(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {16, 26, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_debug_redact(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {16, 26, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_debug_redact(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {16, 26, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_retention(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {17, 28, 72, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_retention(const google_protobuf_FieldOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {17, 28, 72, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_retention(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {17, 28, 72, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_targets(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t const* google_protobuf_FieldOptions_targets(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_targets_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FieldOptions_targets_mutable_upb_array(google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FieldOptions_clear_edition_defaults(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FieldOptions_EditionDefault* const* google_protobuf_FieldOptions_edition_defaults(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_FieldOptions_EditionDefault* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_edition_defaults_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FieldOptions_edition_defaults_mutable_upb_array(google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FieldOptions_clear_features(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {21, UPB_SIZE(40, 48), 73, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_FieldOptions_features(const google_protobuf_FieldOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {21, UPB_SIZE(40, 48), 73, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_features(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {21, UPB_SIZE(40, 48), 73, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_feature_support(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {22, UPB_SIZE(44, 56), 74, 2, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FieldOptions_FeatureSupport* google_protobuf_FieldOptions_feature_support(const google_protobuf_FieldOptions* msg) { + const google_protobuf_FieldOptions_FeatureSupport* default_val = NULL; + const google_protobuf_FieldOptions_FeatureSupport* ret; + const upb_MiniTableField field = {22, UPB_SIZE(44, 56), 74, 2, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_feature_support(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {22, UPB_SIZE(44, 56), 74, 2, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_uninterpreted_option(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_mutable_upb_array(google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions *msg, int32_t value) { + const upb_MiniTableField field = {1, 12, 64, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {3, 17, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {5, 18, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions *msg, int32_t value) { + const upb_MiniTableField field = {6, 20, 68, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {10, 24, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_unverified_lazy(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {15, 25, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_debug_redact(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {16, 26, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_retention(google_protobuf_FieldOptions *msg, int32_t value) { + const upb_MiniTableField field = {17, 28, 72, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE int32_t* google_protobuf_FieldOptions_mutable_targets(google_protobuf_FieldOptions* msg, size_t* size) { + upb_MiniTableField field = {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_FieldOptions_resize_targets(google_protobuf_FieldOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_FieldOptions_add_targets(google_protobuf_FieldOptions* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = {19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE google_protobuf_FieldOptions_EditionDefault** google_protobuf_FieldOptions_mutable_edition_defaults(google_protobuf_FieldOptions* msg, size_t* size) { + upb_MiniTableField field = {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_FieldOptions_EditionDefault**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldOptions_EditionDefault** google_protobuf_FieldOptions_resize_edition_defaults(google_protobuf_FieldOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldOptions_EditionDefault**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_add_edition_defaults(google_protobuf_FieldOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldOptions_EditionDefault* sub = (struct google_protobuf_FieldOptions_EditionDefault*)_upb_Message_New(&google__protobuf__FieldOptions__EditionDefault_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_FieldOptions_set_features(google_protobuf_FieldOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {21, UPB_SIZE(40, 48), 73, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FieldOptions_mutable_features(google_protobuf_FieldOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_FieldOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_FieldOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FieldOptions_set_feature_support(google_protobuf_FieldOptions *msg, google_protobuf_FieldOptions_FeatureSupport* value) { + const upb_MiniTableField field = {22, UPB_SIZE(44, 56), 74, 2, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FieldOptions_FeatureSupport* google_protobuf_FieldOptions_mutable_feature_support(google_protobuf_FieldOptions* msg, upb_Arena* arena) { + struct google_protobuf_FieldOptions_FeatureSupport* sub = (struct google_protobuf_FieldOptions_FeatureSupport*)google_protobuf_FieldOptions_feature_support(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FieldOptions_FeatureSupport*)_upb_Message_New(&google__protobuf__FieldOptions__FeatureSupport_msg_init, arena); + if (sub) google_protobuf_FieldOptions_set_feature_support(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_resize_uninterpreted_option(google_protobuf_FieldOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FieldOptions_add_uninterpreted_option(google_protobuf_FieldOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.FieldOptions.EditionDefault */ + +UPB_INLINE google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_EditionDefault_new(upb_Arena* arena) { + return (google_protobuf_FieldOptions_EditionDefault*)_upb_Message_New(&google__protobuf__FieldOptions__EditionDefault_msg_init, arena); +} +UPB_INLINE google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_EditionDefault_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FieldOptions_EditionDefault* ret = google_protobuf_FieldOptions_EditionDefault_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldOptions__EditionDefault_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_EditionDefault_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FieldOptions_EditionDefault* ret = google_protobuf_FieldOptions_EditionDefault_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldOptions__EditionDefault_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FieldOptions_EditionDefault_serialize(const google_protobuf_FieldOptions_EditionDefault* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldOptions__EditionDefault_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FieldOptions_EditionDefault_serialize_ex(const google_protobuf_FieldOptions_EditionDefault* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldOptions__EditionDefault_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_value(google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {2, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldOptions_EditionDefault_value(const google_protobuf_FieldOptions_EditionDefault* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_value(const google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {2, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_edition(google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {3, 12, 65, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_EditionDefault_edition(const google_protobuf_FieldOptions_EditionDefault* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {3, 12, 65, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_edition(const google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {3, 12, 65, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_value(google_protobuf_FieldOptions_EditionDefault *msg, upb_StringView value) { + const upb_MiniTableField field = {2, 16, 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_edition(google_protobuf_FieldOptions_EditionDefault *msg, int32_t value) { + const upb_MiniTableField field = {3, 12, 65, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.FieldOptions.FeatureSupport */ + +UPB_INLINE google_protobuf_FieldOptions_FeatureSupport* google_protobuf_FieldOptions_FeatureSupport_new(upb_Arena* arena) { + return (google_protobuf_FieldOptions_FeatureSupport*)_upb_Message_New(&google__protobuf__FieldOptions__FeatureSupport_msg_init, arena); +} +UPB_INLINE google_protobuf_FieldOptions_FeatureSupport* google_protobuf_FieldOptions_FeatureSupport_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FieldOptions_FeatureSupport* ret = google_protobuf_FieldOptions_FeatureSupport_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldOptions__FeatureSupport_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FieldOptions_FeatureSupport* google_protobuf_FieldOptions_FeatureSupport_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FieldOptions_FeatureSupport* ret = google_protobuf_FieldOptions_FeatureSupport_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldOptions__FeatureSupport_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FieldOptions_FeatureSupport_serialize(const google_protobuf_FieldOptions_FeatureSupport* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldOptions__FeatureSupport_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FieldOptions_FeatureSupport_serialize_ex(const google_protobuf_FieldOptions_FeatureSupport* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldOptions__FeatureSupport_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_clear_edition_introduced(google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_FeatureSupport_edition_introduced(const google_protobuf_FieldOptions_FeatureSupport* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_FeatureSupport_has_edition_introduced(const google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_clear_edition_deprecated(google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_FeatureSupport_edition_deprecated(const google_protobuf_FieldOptions_FeatureSupport* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_FeatureSupport_has_edition_deprecated(const google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_clear_deprecation_warning(google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {3, 24, 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldOptions_FeatureSupport_deprecation_warning(const google_protobuf_FieldOptions_FeatureSupport* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {3, 24, 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_FeatureSupport_has_deprecation_warning(const google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {3, 24, 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_clear_edition_removed(google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {4, 20, 67, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_FeatureSupport_edition_removed(const google_protobuf_FieldOptions_FeatureSupport* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {4, 20, 67, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_FeatureSupport_has_edition_removed(const google_protobuf_FieldOptions_FeatureSupport* msg) { + const upb_MiniTableField field = {4, 20, 67, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_set_edition_introduced(google_protobuf_FieldOptions_FeatureSupport *msg, int32_t value) { + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_set_edition_deprecated(google_protobuf_FieldOptions_FeatureSupport *msg, int32_t value) { + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_set_deprecation_warning(google_protobuf_FieldOptions_FeatureSupport *msg, upb_StringView value) { + const upb_MiniTableField field = {3, 24, 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_FeatureSupport_set_edition_removed(google_protobuf_FieldOptions_FeatureSupport *msg, int32_t value) { + const upb_MiniTableField field = {4, 20, 67, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.OneofOptions */ + +UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_new(upb_Arena* arena) { + return (google_protobuf_OneofOptions*)_upb_Message_New(&google__protobuf__OneofOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_OneofOptions* ret = google_protobuf_OneofOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__OneofOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_OneofOptions* ret = google_protobuf_OneofOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__OneofOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__OneofOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_OneofOptions_serialize_ex(const google_protobuf_OneofOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__OneofOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_OneofOptions_clear_features(google_protobuf_OneofOptions* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_OneofOptions_features(const google_protobuf_OneofOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_OneofOptions_has_features(const google_protobuf_OneofOptions* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_OneofOptions_clear_uninterpreted_option(google_protobuf_OneofOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_upb_array(const google_protobuf_OneofOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_mutable_upb_array(google_protobuf_OneofOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_OneofOptions_set_features(google_protobuf_OneofOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_OneofOptions_mutable_features(google_protobuf_OneofOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_OneofOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_OneofOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_resize_uninterpreted_option(google_protobuf_OneofOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_OneofOptions_add_uninterpreted_option(google_protobuf_OneofOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.EnumOptions */ + +UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_new(upb_Arena* arena) { + return (google_protobuf_EnumOptions*)_upb_Message_New(&google__protobuf__EnumOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumOptions* ret = google_protobuf_EnumOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumOptions* ret = google_protobuf_EnumOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumOptions_serialize_ex(const google_protobuf_EnumOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumOptions_clear_allow_alias(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {2, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {2, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {2, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_deprecated(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {3, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {3, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {3, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_deprecated_legacy_json_field_conflicts(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {6, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_EnumOptions_deprecated_legacy_json_field_conflicts(const google_protobuf_EnumOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {6, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated_legacy_json_field_conflicts(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {6, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_features(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(12, 16), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_EnumOptions_features(const google_protobuf_EnumOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {7, UPB_SIZE(12, 16), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_features(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(12, 16), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_uninterpreted_option(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_upb_array(const google_protobuf_EnumOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_mutable_upb_array(google_protobuf_EnumOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions *msg, bool value) { + const upb_MiniTableField field = {2, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) { + const upb_MiniTableField field = {3, 10, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumOptions_set_deprecated_legacy_json_field_conflicts(google_protobuf_EnumOptions *msg, bool value) { + const upb_MiniTableField field = {6, 11, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumOptions_set_features(google_protobuf_EnumOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {7, UPB_SIZE(12, 16), 67, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_EnumOptions_mutable_features(google_protobuf_EnumOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_EnumOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_EnumOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_resize_uninterpreted_option(google_protobuf_EnumOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumOptions_add_uninterpreted_option(google_protobuf_EnumOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.EnumValueOptions */ + +UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_new(upb_Arena* arena) { + return (google_protobuf_EnumValueOptions*)_upb_Message_New(&google__protobuf__EnumValueOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumValueOptions* ret = google_protobuf_EnumValueOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumValueOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumValueOptions* ret = google_protobuf_EnumValueOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__EnumValueOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumValueOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumValueOptions_serialize_ex(const google_protobuf_EnumValueOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__EnumValueOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_deprecated(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_features(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_EnumValueOptions_features(const google_protobuf_EnumValueOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_features(const google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_debug_redact(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 10), 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_EnumValueOptions_debug_redact(const google_protobuf_EnumValueOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {3, UPB_SIZE(16, 10), 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_debug_redact(const google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 10), 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_feature_support(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 24), 67, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FieldOptions_FeatureSupport* google_protobuf_EnumValueOptions_feature_support(const google_protobuf_EnumValueOptions* msg) { + const google_protobuf_FieldOptions_FeatureSupport* default_val = NULL; + const google_protobuf_FieldOptions_FeatureSupport* ret; + const upb_MiniTableField field = {4, UPB_SIZE(20, 24), 67, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_feature_support(const google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 24), 67, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_uninterpreted_option(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_upb_array(const google_protobuf_EnumValueOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_mutable_upb_array(google_protobuf_EnumValueOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions *msg, bool value) { + const upb_MiniTableField field = {1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumValueOptions_set_features(google_protobuf_EnumValueOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_EnumValueOptions_mutable_features(google_protobuf_EnumValueOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_EnumValueOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_EnumValueOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_EnumValueOptions_set_debug_redact(google_protobuf_EnumValueOptions *msg, bool value) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 10), 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumValueOptions_set_feature_support(google_protobuf_EnumValueOptions *msg, google_protobuf_FieldOptions_FeatureSupport* value) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 24), 67, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FieldOptions_FeatureSupport* google_protobuf_EnumValueOptions_mutable_feature_support(google_protobuf_EnumValueOptions* msg, upb_Arena* arena) { + struct google_protobuf_FieldOptions_FeatureSupport* sub = (struct google_protobuf_FieldOptions_FeatureSupport*)google_protobuf_EnumValueOptions_feature_support(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FieldOptions_FeatureSupport*)_upb_Message_New(&google__protobuf__FieldOptions__FeatureSupport_msg_init, arena); + if (sub) google_protobuf_EnumValueOptions_set_feature_support(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_resize_uninterpreted_option(google_protobuf_EnumValueOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumValueOptions_add_uninterpreted_option(google_protobuf_EnumValueOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.ServiceOptions */ + +UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_new(upb_Arena* arena) { + return (google_protobuf_ServiceOptions*)_upb_Message_New(&google__protobuf__ServiceOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ServiceOptions* ret = google_protobuf_ServiceOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ServiceOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ServiceOptions* ret = google_protobuf_ServiceOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ServiceOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ServiceOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ServiceOptions_serialize_ex(const google_protobuf_ServiceOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ServiceOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ServiceOptions_clear_deprecated(google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ServiceOptions_clear_features(google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {34, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_ServiceOptions_features(const google_protobuf_ServiceOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {34, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceOptions_has_features(const google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {34, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_ServiceOptions_clear_uninterpreted_option(google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_upb_array(const google_protobuf_ServiceOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_mutable_upb_array(google_protobuf_ServiceOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions *msg, bool value) { + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_ServiceOptions_set_features(google_protobuf_ServiceOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {34, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_ServiceOptions_mutable_features(google_protobuf_ServiceOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_ServiceOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_ServiceOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_resize_uninterpreted_option(google_protobuf_ServiceOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ServiceOptions_add_uninterpreted_option(google_protobuf_ServiceOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.MethodOptions */ + +UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_new(upb_Arena* arena) { + return (google_protobuf_MethodOptions*)_upb_Message_New(&google__protobuf__MethodOptions_msg_init, arena); +} +UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_MethodOptions* ret = google_protobuf_MethodOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__MethodOptions_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_MethodOptions* ret = google_protobuf_MethodOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__MethodOptions_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__MethodOptions_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_MethodOptions_serialize_ex(const google_protobuf_MethodOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__MethodOptions_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_MethodOptions_clear_deprecated(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_idempotency_level(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {34, 12, 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {34, 12, 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {34, 12, 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_features(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {35, 16, 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_MethodOptions_features(const google_protobuf_MethodOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {35, 16, 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodOptions_has_features(const google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {35, 16, 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_uninterpreted_option(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_upb_array(const google_protobuf_MethodOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_mutable_upb_array(google_protobuf_MethodOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE void google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions *msg, bool value) { + const upb_MiniTableField field = {33, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions *msg, int32_t value) { + const upb_MiniTableField field = {34, 12, 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodOptions_set_features(google_protobuf_MethodOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {35, 16, 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_MethodOptions_mutable_features(google_protobuf_MethodOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_MethodOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_MethodOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_resize_uninterpreted_option(google_protobuf_MethodOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MethodOptions_add_uninterpreted_option(google_protobuf_MethodOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {999, UPB_SIZE(20, 24), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.UninterpretedOption */ + +UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_new(upb_Arena* arena) { + return (google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena); +} +UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_UninterpretedOption* ret = google_protobuf_UninterpretedOption_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__UninterpretedOption_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_UninterpretedOption* ret = google_protobuf_UninterpretedOption_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__UninterpretedOption_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__UninterpretedOption_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_serialize_ex(const google_protobuf_UninterpretedOption* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__UninterpretedOption_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_name(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_UninterpretedOption_NamePart* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_UninterpretedOption_name_upb_array(const google_protobuf_UninterpretedOption* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_UninterpretedOption_name_mutable_upb_array(google_protobuf_UninterpretedOption* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_identifier_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {3, UPB_SIZE(16, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_positive_int_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(24, 40), 65, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption* msg) { + uint64_t default_val = (uint64_t)0ull; + uint64_t ret; + const upb_MiniTableField field = {4, UPB_SIZE(24, 40), 65, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(24, 40), 65, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_negative_int_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(32, 48), 66, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption* msg) { + int64_t default_val = (int64_t)0ll; + int64_t ret; + const upb_MiniTableField field = {5, UPB_SIZE(32, 48), 66, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(32, 48), 66, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_double_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(40, 56), 67, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption* msg) { + double default_val = 0; + double ret; + const upb_MiniTableField field = {6, UPB_SIZE(40, 56), 67, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(40, 56), 67, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_string_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(48, 64), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {7, UPB_SIZE(48, 64), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(48, 64), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_aggregate_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(56, 80), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {8, UPB_SIZE(56, 80), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(56, 80), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption* msg, size_t* size) { + upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_UninterpretedOption_NamePart**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_resize_name(google_protobuf_UninterpretedOption* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption_NamePart**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_add_name(google_protobuf_UninterpretedOption* msg, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption_NamePart* sub = (struct google_protobuf_UninterpretedOption_NamePart*)_upb_Message_New(&google__protobuf__UninterpretedOption__NamePart_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption *msg, upb_StringView value) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 24), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption *msg, uint64_t value) { + const upb_MiniTableField field = {4, UPB_SIZE(24, 40), 65, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption *msg, int64_t value) { + const upb_MiniTableField field = {5, UPB_SIZE(32, 48), 66, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption *msg, double value) { + const upb_MiniTableField field = {6, UPB_SIZE(40, 56), 67, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption *msg, upb_StringView value) { + const upb_MiniTableField field = {7, UPB_SIZE(48, 64), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption *msg, upb_StringView value) { + const upb_MiniTableField field = {8, UPB_SIZE(56, 80), 69, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.UninterpretedOption.NamePart */ + +UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_new(upb_Arena* arena) { + return (google_protobuf_UninterpretedOption_NamePart*)_upb_Message_New(&google__protobuf__UninterpretedOption__NamePart_msg_init, arena); +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_UninterpretedOption_NamePart* ret = google_protobuf_UninterpretedOption_NamePart_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__UninterpretedOption__NamePart_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_UninterpretedOption_NamePart* ret = google_protobuf_UninterpretedOption_NamePart_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__UninterpretedOption__NamePart_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__UninterpretedOption__NamePart_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_NamePart_serialize_ex(const google_protobuf_UninterpretedOption_NamePart* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__UninterpretedOption__NamePart_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_clear_name_part(google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_clear_is_extension(google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = {2, 9, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {2, 9, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = {2, 9, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart *msg, bool value) { + const upb_MiniTableField field = {2, 9, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.FeatureSet */ + +UPB_INLINE google_protobuf_FeatureSet* google_protobuf_FeatureSet_new(upb_Arena* arena) { + return (google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); +} +UPB_INLINE google_protobuf_FeatureSet* google_protobuf_FeatureSet_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FeatureSet* ret = google_protobuf_FeatureSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSet_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FeatureSet* google_protobuf_FeatureSet_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FeatureSet* ret = google_protobuf_FeatureSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSet_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FeatureSet_serialize(const google_protobuf_FeatureSet* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSet_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FeatureSet_serialize_ex(const google_protobuf_FeatureSet* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSet_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FeatureSet_clear_field_presence(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_field_presence(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_field_presence(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_enum_type(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_enum_type(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_enum_type(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_repeated_field_encoding(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {3, 20, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_repeated_field_encoding(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {3, 20, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_repeated_field_encoding(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {3, 20, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_utf8_validation(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {4, 24, 67, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_utf8_validation(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {4, 24, 67, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_utf8_validation(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {4, 24, 67, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_message_encoding(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {5, 28, 68, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_message_encoding(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {5, 28, 68, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_message_encoding(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {5, 28, 68, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_json_format(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {6, 32, 69, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_json_format(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {6, 32, 69, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_json_format(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {6, 32, 69, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_FeatureSet_set_field_presence(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_enum_type(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_repeated_field_encoding(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {3, 20, 66, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_utf8_validation(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {4, 24, 67, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_message_encoding(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {5, 28, 68, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_json_format(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {6, 32, 69, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.FeatureSetDefaults */ + +UPB_INLINE google_protobuf_FeatureSetDefaults* google_protobuf_FeatureSetDefaults_new(upb_Arena* arena) { + return (google_protobuf_FeatureSetDefaults*)_upb_Message_New(&google__protobuf__FeatureSetDefaults_msg_init, arena); +} +UPB_INLINE google_protobuf_FeatureSetDefaults* google_protobuf_FeatureSetDefaults_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FeatureSetDefaults* ret = google_protobuf_FeatureSetDefaults_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSetDefaults_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FeatureSetDefaults* google_protobuf_FeatureSetDefaults_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FeatureSetDefaults* ret = google_protobuf_FeatureSetDefaults_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSetDefaults_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FeatureSetDefaults_serialize(const google_protobuf_FeatureSetDefaults* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSetDefaults_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FeatureSetDefaults_serialize_ex(const google_protobuf_FeatureSetDefaults* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSetDefaults_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_defaults(google_protobuf_FeatureSetDefaults* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* const* google_protobuf_FeatureSetDefaults_defaults(const google_protobuf_FeatureSetDefaults* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FeatureSetDefaults_defaults_upb_array(const google_protobuf_FeatureSetDefaults* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FeatureSetDefaults_defaults_mutable_upb_array(google_protobuf_FeatureSetDefaults* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_minimum_edition(google_protobuf_FeatureSetDefaults* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 12), 64, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_minimum_edition(const google_protobuf_FeatureSetDefaults* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {4, UPB_SIZE(16, 12), 64, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_minimum_edition(const google_protobuf_FeatureSetDefaults* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 12), 64, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_maximum_edition(google_protobuf_FeatureSetDefaults* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 16), 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_maximum_edition(const google_protobuf_FeatureSetDefaults* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {5, UPB_SIZE(20, 16), 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_maximum_edition(const google_protobuf_FeatureSetDefaults* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 16), 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault** google_protobuf_FeatureSetDefaults_mutable_defaults(google_protobuf_FeatureSetDefaults* msg, size_t* size) { + upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault** google_protobuf_FeatureSetDefaults_resize_defaults(google_protobuf_FeatureSetDefaults* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* google_protobuf_FeatureSetDefaults_add_defaults(google_protobuf_FeatureSetDefaults* msg, upb_Arena* arena) { + upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* sub = (struct google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault*)_upb_Message_New(&google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_set_minimum_edition(google_protobuf_FeatureSetDefaults *msg, int32_t value) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 12), 64, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_set_maximum_edition(google_protobuf_FeatureSetDefaults *msg, int32_t value) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 16), 65, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault */ + +UPB_INLINE google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_new(upb_Arena* arena) { + return (google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault*)_upb_Message_New(&google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init, arena); +} +UPB_INLINE google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* ret = google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* ret = google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_serialize(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_serialize_ex(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_clear_edition(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const upb_MiniTableField field = {3, 12, 64, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_edition(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {3, 12, 64, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_has_edition(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const upb_MiniTableField field = {3, 12, 64, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_clear_overridable_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const upb_MiniTableField field = {4, 16, 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_overridable_features(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {4, 16, 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_has_overridable_features(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const upb_MiniTableField field = {4, 16, 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_clear_fixed_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 24), 66, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_fixed_features(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {5, UPB_SIZE(20, 24), 66, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_has_fixed_features(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 24), 66, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_edition(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault *msg, int32_t value) { + const upb_MiniTableField field = {3, 12, 64, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_overridable_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {4, 16, 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_mutable_overridable_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_overridable_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_overridable_features(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_fixed_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {5, UPB_SIZE(20, 24), 66, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_mutable_fixed_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_fixed_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena); + if (sub) google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_fixed_features(msg, sub); + } + return sub; +} + +/* google.protobuf.SourceCodeInfo */ + +UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_new(upb_Arena* arena) { + return (google_protobuf_SourceCodeInfo*)_upb_Message_New(&google__protobuf__SourceCodeInfo_msg_init, arena); +} +UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_SourceCodeInfo* ret = google_protobuf_SourceCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__SourceCodeInfo_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_SourceCodeInfo* ret = google_protobuf_SourceCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__SourceCodeInfo_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__SourceCodeInfo_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_serialize_ex(const google_protobuf_SourceCodeInfo* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__SourceCodeInfo_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_clear_location(google_protobuf_SourceCodeInfo* msg) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_SourceCodeInfo_Location* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_location_upb_array(const google_protobuf_SourceCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_location_mutable_upb_array(google_protobuf_SourceCodeInfo* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_mutable_location(google_protobuf_SourceCodeInfo* msg, size_t* size) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_SourceCodeInfo_Location**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_resize_location(google_protobuf_SourceCodeInfo* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_SourceCodeInfo_Location**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_add_location(google_protobuf_SourceCodeInfo* msg, upb_Arena* arena) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_SourceCodeInfo_Location* sub = (struct google_protobuf_SourceCodeInfo_Location*)_upb_Message_New(&google__protobuf__SourceCodeInfo__Location_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.SourceCodeInfo.Location */ + +UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_new(upb_Arena* arena) { + return (google_protobuf_SourceCodeInfo_Location*)_upb_Message_New(&google__protobuf__SourceCodeInfo__Location_msg_init, arena); +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_SourceCodeInfo_Location* ret = google_protobuf_SourceCodeInfo_Location_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__SourceCodeInfo__Location_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_SourceCodeInfo_Location* ret = google_protobuf_SourceCodeInfo_Location_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__SourceCodeInfo__Location_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__SourceCodeInfo__Location_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_Location_serialize_ex(const google_protobuf_SourceCodeInfo_Location* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__SourceCodeInfo__Location_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_path(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_path_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_path_mutable_upb_array(google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_span(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_span_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_span_mutable_upb_array(google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_leading_comments(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(24, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {3, UPB_SIZE(24, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(24, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_trailing_comments(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(32, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {4, UPB_SIZE(32, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(32, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView const* google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_mutable_upb_array(google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + upb_MiniTableField field = {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_path(google_protobuf_SourceCodeInfo_Location* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_path(google_protobuf_SourceCodeInfo_Location* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = {1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_span(google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + upb_MiniTableField field = {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_span(google_protobuf_SourceCodeInfo_Location* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf_SourceCodeInfo_Location* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_StringView value) { + const upb_MiniTableField field = {3, UPB_SIZE(24, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_StringView value) { + const upb_MiniTableField field = {4, UPB_SIZE(32, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE upb_StringView* google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + upb_MiniTableField field = {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (upb_StringView*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_SourceCodeInfo_Location_resize_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = {6, UPB_SIZE(20, 64), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} + +/* google.protobuf.GeneratedCodeInfo */ + +UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_new(upb_Arena* arena) { + return (google_protobuf_GeneratedCodeInfo*)_upb_Message_New(&google__protobuf__GeneratedCodeInfo_msg_init, arena); +} +UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo* ret = google_protobuf_GeneratedCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__GeneratedCodeInfo_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo* ret = google_protobuf_GeneratedCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__GeneratedCodeInfo_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__GeneratedCodeInfo_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_serialize_ex(const google_protobuf_GeneratedCodeInfo* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__GeneratedCodeInfo_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_clear_annotation(google_protobuf_GeneratedCodeInfo* msg) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (const google_protobuf_GeneratedCodeInfo_Annotation* const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_upb_array(const google_protobuf_GeneratedCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_mutable_upb_array(google_protobuf_GeneratedCodeInfo* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} + +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_mutable_annotation(google_protobuf_GeneratedCodeInfo* msg, size_t* size) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (google_protobuf_GeneratedCodeInfo_Annotation**)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_resize_annotation(google_protobuf_GeneratedCodeInfo* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_GeneratedCodeInfo_Annotation**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE struct google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_add_annotation(google_protobuf_GeneratedCodeInfo* msg, upb_Arena* arena) { + upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return NULL; + } + struct google_protobuf_GeneratedCodeInfo_Annotation* sub = (struct google_protobuf_GeneratedCodeInfo_Annotation*)_upb_Message_New(&google__protobuf__GeneratedCodeInfo__Annotation_msg_init, arena); + if (!arr || !sub) return NULL; + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.GeneratedCodeInfo.Annotation */ + +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_new(upb_Arena* arena) { + return (google_protobuf_GeneratedCodeInfo_Annotation*)_upb_Message_New(&google__protobuf__GeneratedCodeInfo__Annotation_msg_init, arena); +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo_Annotation* ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__GeneratedCodeInfo__Annotation_msg_init, NULL, 0, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo_Annotation* ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__GeneratedCodeInfo__Annotation_msg_init, extreg, options, + arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__GeneratedCodeInfo__Annotation_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_Annotation_serialize_ex(const google_protobuf_GeneratedCodeInfo_Annotation* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__GeneratedCodeInfo__Annotation_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_path(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t const*)upb_Array_DataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_upb_array(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_mutable_upb_array(google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg), + &field, arena); + if (size) { + *size = arr ? arr->UPB_PRIVATE(size) : 0; + } + return arr; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_source_file(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE upb_StringView google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_begin(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_end(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 16), 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {4, UPB_SIZE(20, 16), 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 16), 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_semantic(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 20), 67, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_ClearBaseField(UPB_UPCAST(msg), &field); +} +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_semantic(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {5, UPB_SIZE(24, 20), 67, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field, + &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_semantic(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 20), 67, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return upb_Message_HasBaseField(UPB_UPCAST(msg), &field); +} + +UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) { + upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field); + if (arr) { + if (size) *size = arr->UPB_PRIVATE(size); + return (int32_t*)upb_Array_MutableDataPtr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_resize_path(google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg), + &field, size, arena); +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_protobuf_GeneratedCodeInfo_Annotation* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = {1, UPB_SIZE(12, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + UPB_UPCAST(msg), &field, arena); + if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)( + arr, arr->UPB_PRIVATE(size) + 1, arena)) { + return false; + } + UPB_PRIVATE(_upb_Array_Set) + (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_StringView value) { + const upb_MiniTableField field = {2, UPB_SIZE(28, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + const upb_MiniTableField field = {4, UPB_SIZE(20, 16), 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_semantic(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 20), 67, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + upb_Message_SetBaseField((upb_Message *)msg, &field, &value); +} + +/* Max size 32 is google.protobuf.FileOptions */ +/* Max size 64 is google.protobuf.FileOptions */ +#define _UPB_MAXOPT_SIZE UPB_SIZE(112, 200) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */ +// end:github_only + +typedef enum { + kUpb_Syntax_Proto2 = 2, + kUpb_Syntax_Proto3 = 3, + kUpb_Syntax_Editions = 99 +} upb_Syntax; + +// Forward declarations for circular references. +typedef struct upb_DefPool upb_DefPool; +typedef struct upb_EnumDef upb_EnumDef; +typedef struct upb_EnumReservedRange upb_EnumReservedRange; +typedef struct upb_EnumValueDef upb_EnumValueDef; +typedef struct upb_ExtensionRange upb_ExtensionRange; +typedef struct upb_FieldDef upb_FieldDef; +typedef struct upb_FileDef upb_FileDef; +typedef struct upb_MessageDef upb_MessageDef; +typedef struct upb_MessageReservedRange upb_MessageReservedRange; +typedef struct upb_MethodDef upb_MethodDef; +typedef struct upb_OneofDef upb_OneofDef; +typedef struct upb_ServiceDef upb_ServiceDef; + +// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// + +typedef struct upb_DefBuilder upb_DefBuilder; + +#endif /* UPB_REFLECTION_COMMON_H_ */ + +#ifndef UPB_REFLECTION_DEF_TYPE_H_ +#define UPB_REFLECTION_DEF_TYPE_H_ + + +// Must be last. + +// Inside a symtab we store tagged pointers to specific def types. +typedef enum { + UPB_DEFTYPE_MASK = 7, + + // Only inside symtab table. + UPB_DEFTYPE_EXT = 0, + UPB_DEFTYPE_MSG = 1, + UPB_DEFTYPE_ENUM = 2, + UPB_DEFTYPE_ENUMVAL = 3, + UPB_DEFTYPE_SERVICE = 4, + + // Only inside message table. + UPB_DEFTYPE_FIELD = 0, + UPB_DEFTYPE_ONEOF = 1, +} upb_deftype_t; + +#ifdef __cplusplus +extern "C" { +#endif + +// Our 3-bit pointer tagging requires all pointers to be multiples of 8. +// The arena will always yield 8-byte-aligned addresses, however we put +// the defs into arrays. For each element in the array to be 8-byte-aligned, +// the sizes of each def type must also be a multiple of 8. +// +// If any of these asserts fail, we need to add or remove padding on 32-bit +// machines (64-bit machines will have 8-byte alignment already due to +// pointers, which all of these structs have). +UPB_INLINE void _upb_DefType_CheckPadding(size_t size) { + UPB_ASSERT((size & UPB_DEFTYPE_MASK) == 0); +} + +upb_deftype_t _upb_DefType_Type(upb_value v); + +upb_value _upb_DefType_Pack(const void* ptr, upb_deftype_t type); + +const void* _upb_DefType_Unpack(upb_value v, upb_deftype_t type); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_DEF_TYPE_H_ */ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API void upb_DefPool_Free(upb_DefPool* s); + +UPB_API upb_DefPool* upb_DefPool_New(void); + +UPB_API const UPB_DESC(FeatureSetDefaults) * + upb_DefPool_FeatureSetDefaults(const upb_DefPool* s); + +UPB_API bool upb_DefPool_SetFeatureSetDefaults(upb_DefPool* s, + const char* serialized_defaults, + size_t serialized_len, + upb_Status* status); + +UPB_API const upb_MessageDef* upb_DefPool_FindMessageByName( + const upb_DefPool* s, const char* sym); + +const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len); + +UPB_API const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s, + const char* sym); + +const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s, + const char* sym); + +const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s, + const char* name); + +const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s, + const char* name, + size_t len); + +const upb_FieldDef* upb_DefPool_FindExtensionByMiniTable( + const upb_DefPool* s, const upb_MiniTableExtension* ext); + +UPB_API const upb_FieldDef* upb_DefPool_FindExtensionByName(const upb_DefPool* s, + const char* sym); + +const upb_FieldDef* upb_DefPool_FindExtensionByNameWithSize( + const upb_DefPool* s, const char* name, size_t size); + +const upb_FieldDef* upb_DefPool_FindExtensionByNumber(const upb_DefPool* s, + const upb_MessageDef* m, + int32_t fieldnum); + +UPB_API const upb_ServiceDef* upb_DefPool_FindServiceByName( + const upb_DefPool* s, const char* name); + +const upb_ServiceDef* upb_DefPool_FindServiceByNameWithSize( + const upb_DefPool* s, const char* name, size_t size); + +const upb_FileDef* upb_DefPool_FindFileContainingSymbol(const upb_DefPool* s, + const char* name); + +UPB_API const upb_FileDef* upb_DefPool_AddFile( + upb_DefPool* s, const UPB_DESC(FileDescriptorProto) * file_proto, + upb_Status* status); + +UPB_API const upb_ExtensionRegistry* upb_DefPool_ExtensionRegistry( + const upb_DefPool* s); + +const upb_FieldDef** upb_DefPool_GetAllExtensions(const upb_DefPool* s, + const upb_MessageDef* m, + size_t* count); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_DEF_POOL_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_ENUM_DEF_H_ +#define UPB_REFLECTION_ENUM_DEF_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +bool upb_EnumDef_CheckNumber(const upb_EnumDef* e, int32_t num); +const upb_MessageDef* upb_EnumDef_ContainingType(const upb_EnumDef* e); +int32_t upb_EnumDef_Default(const upb_EnumDef* e); +UPB_API const upb_FileDef* upb_EnumDef_File(const upb_EnumDef* e); +const upb_EnumValueDef* upb_EnumDef_FindValueByName(const upb_EnumDef* e, + const char* name); +UPB_API const upb_EnumValueDef* upb_EnumDef_FindValueByNameWithSize( + const upb_EnumDef* e, const char* name, size_t size); +UPB_API const upb_EnumValueDef* upb_EnumDef_FindValueByNumber( + const upb_EnumDef* e, int32_t num); +UPB_API const char* upb_EnumDef_FullName(const upb_EnumDef* e); +bool upb_EnumDef_HasOptions(const upb_EnumDef* e); +bool upb_EnumDef_IsClosed(const upb_EnumDef* e); +bool upb_EnumDef_IsSpecifiedAsClosed(const upb_EnumDef* e); + +// Creates a mini descriptor string for an enum, returns true on success. +bool upb_EnumDef_MiniDescriptorEncode(const upb_EnumDef* e, upb_Arena* a, + upb_StringView* out); + +const char* upb_EnumDef_Name(const upb_EnumDef* e); +const UPB_DESC(EnumOptions) * upb_EnumDef_Options(const upb_EnumDef* e); +const UPB_DESC(FeatureSet) * upb_EnumDef_ResolvedFeatures(const upb_EnumDef* e); + +upb_StringView upb_EnumDef_ReservedName(const upb_EnumDef* e, int i); +int upb_EnumDef_ReservedNameCount(const upb_EnumDef* e); + +const upb_EnumReservedRange* upb_EnumDef_ReservedRange(const upb_EnumDef* e, + int i); +int upb_EnumDef_ReservedRangeCount(const upb_EnumDef* e); + +UPB_API const upb_EnumValueDef* upb_EnumDef_Value(const upb_EnumDef* e, int i); +UPB_API int upb_EnumDef_ValueCount(const upb_EnumDef* e); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ENUM_DEF_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_ENUM_VALUE_DEF_H_ +#define UPB_REFLECTION_ENUM_VALUE_DEF_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +const upb_EnumDef* upb_EnumValueDef_Enum(const upb_EnumValueDef* v); +const char* upb_EnumValueDef_FullName(const upb_EnumValueDef* v); +bool upb_EnumValueDef_HasOptions(const upb_EnumValueDef* v); +uint32_t upb_EnumValueDef_Index(const upb_EnumValueDef* v); +UPB_API const char* upb_EnumValueDef_Name(const upb_EnumValueDef* v); +UPB_API int32_t upb_EnumValueDef_Number(const upb_EnumValueDef* v); +const UPB_DESC(EnumValueOptions) * + upb_EnumValueDef_Options(const upb_EnumValueDef* v); +const UPB_DESC(FeatureSet) * + upb_EnumValueDef_ResolvedFeatures(const upb_EnumValueDef* e); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ENUM_VALUE_DEF_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_EXTENSION_RANGE_H_ +#define UPB_REFLECTION_EXTENSION_RANGE_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t upb_ExtensionRange_Start(const upb_ExtensionRange* r); +int32_t upb_ExtensionRange_End(const upb_ExtensionRange* r); + +bool upb_ExtensionRange_HasOptions(const upb_ExtensionRange* r); +const UPB_DESC(ExtensionRangeOptions) * + upb_ExtensionRange_Options(const upb_ExtensionRange* r); +const UPB_DESC(FeatureSet) * + upb_ExtensionRange_ResolvedFeatures(const upb_ExtensionRange* e); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_EXTENSION_RANGE_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_FIELD_DEF_H_ +#define UPB_REFLECTION_FIELD_DEF_H_ + +#include + + +// Must be last. + +// Maximum field number allowed for FieldDefs. +// This is an inherent limit of the protobuf wire format. +#define kUpb_MaxFieldNumber ((1 << 29) - 1) + +#ifdef __cplusplus +extern "C" { +#endif + +const upb_OneofDef* upb_FieldDef_ContainingOneof(const upb_FieldDef* f); +UPB_API const upb_MessageDef* upb_FieldDef_ContainingType( + const upb_FieldDef* f); +UPB_API upb_CType upb_FieldDef_CType(const upb_FieldDef* f); +UPB_API upb_MessageValue upb_FieldDef_Default(const upb_FieldDef* f); +UPB_API const upb_EnumDef* upb_FieldDef_EnumSubDef(const upb_FieldDef* f); +const upb_MessageDef* upb_FieldDef_ExtensionScope(const upb_FieldDef* f); +UPB_API const upb_FileDef* upb_FieldDef_File(const upb_FieldDef* f); +const char* upb_FieldDef_FullName(const upb_FieldDef* f); +bool upb_FieldDef_HasDefault(const upb_FieldDef* f); +bool upb_FieldDef_HasJsonName(const upb_FieldDef* f); +bool upb_FieldDef_HasOptions(const upb_FieldDef* f); +UPB_API bool upb_FieldDef_HasPresence(const upb_FieldDef* f); +bool upb_FieldDef_HasSubDef(const upb_FieldDef* f); +uint32_t upb_FieldDef_Index(const upb_FieldDef* f); +bool upb_FieldDef_IsExtension(const upb_FieldDef* f); +UPB_API bool upb_FieldDef_IsMap(const upb_FieldDef* f); +bool upb_FieldDef_IsOptional(const upb_FieldDef* f); +UPB_API bool upb_FieldDef_IsPacked(const upb_FieldDef* f); +bool upb_FieldDef_IsPrimitive(const upb_FieldDef* f); +UPB_API bool upb_FieldDef_IsRepeated(const upb_FieldDef* f); +bool upb_FieldDef_IsRequired(const upb_FieldDef* f); +bool upb_FieldDef_IsString(const upb_FieldDef* f); +UPB_API bool upb_FieldDef_IsSubMessage(const upb_FieldDef* f); +UPB_API const char* upb_FieldDef_JsonName(const upb_FieldDef* f); +UPB_API upb_Label upb_FieldDef_Label(const upb_FieldDef* f); +uint32_t upb_FieldDef_LayoutIndex(const upb_FieldDef* f); +UPB_API const upb_MessageDef* upb_FieldDef_MessageSubDef(const upb_FieldDef* f); +bool _upb_FieldDef_ValidateUtf8(const upb_FieldDef* f); +bool _upb_FieldDef_IsGroupLike(const upb_FieldDef* f); + +// Creates a mini descriptor string for a field, returns true on success. +bool upb_FieldDef_MiniDescriptorEncode(const upb_FieldDef* f, upb_Arena* a, + upb_StringView* out); + +const upb_MiniTableField* upb_FieldDef_MiniTable(const upb_FieldDef* f); +const upb_MiniTableExtension* upb_FieldDef_MiniTableExtension( + const upb_FieldDef* f); +UPB_API const char* upb_FieldDef_Name(const upb_FieldDef* f); +UPB_API uint32_t upb_FieldDef_Number(const upb_FieldDef* f); +const UPB_DESC(FieldOptions) * upb_FieldDef_Options(const upb_FieldDef* f); +const UPB_DESC(FeatureSet) * + upb_FieldDef_ResolvedFeatures(const upb_FieldDef* f); +UPB_API const upb_OneofDef* upb_FieldDef_RealContainingOneof( + const upb_FieldDef* f); +UPB_API upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_FIELD_DEF_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_FILE_DEF_H_ +#define UPB_REFLECTION_FILE_DEF_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API const char* upb_FileDef_EditionName(int edition); + +const upb_FileDef* upb_FileDef_Dependency(const upb_FileDef* f, int i); +int upb_FileDef_DependencyCount(const upb_FileDef* f); +bool upb_FileDef_HasOptions(const upb_FileDef* f); +UPB_API const char* upb_FileDef_Name(const upb_FileDef* f); +const UPB_DESC(FileOptions) * upb_FileDef_Options(const upb_FileDef* f); +const UPB_DESC(FeatureSet) * upb_FileDef_ResolvedFeatures(const upb_FileDef* f); +const char* upb_FileDef_Package(const upb_FileDef* f); +UPB_DESC(Edition) upb_FileDef_Edition(const upb_FileDef* f); +UPB_API const upb_DefPool* upb_FileDef_Pool(const upb_FileDef* f); + +const upb_FileDef* upb_FileDef_PublicDependency(const upb_FileDef* f, int i); +int upb_FileDef_PublicDependencyCount(const upb_FileDef* f); + +const upb_ServiceDef* upb_FileDef_Service(const upb_FileDef* f, int i); +int upb_FileDef_ServiceCount(const upb_FileDef* f); + +UPB_API upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f); + +const upb_EnumDef* upb_FileDef_TopLevelEnum(const upb_FileDef* f, int i); +int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f); + +const upb_FieldDef* upb_FileDef_TopLevelExtension(const upb_FileDef* f, int i); +int upb_FileDef_TopLevelExtensionCount(const upb_FileDef* f); + +const upb_MessageDef* upb_FileDef_TopLevelMessage(const upb_FileDef* f, int i); +int upb_FileDef_TopLevelMessageCount(const upb_FileDef* f); + +const upb_FileDef* upb_FileDef_WeakDependency(const upb_FileDef* f, int i); +int upb_FileDef_WeakDependencyCount(const upb_FileDef* f); + +// Returns whether |symbol| is transitively included by |f| +bool upb_FileDef_Resolves(const upb_FileDef* f, const char* symbol); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_FILE_DEF_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_MESSAGE_DEF_H_ +#define UPB_REFLECTION_MESSAGE_DEF_H_ + + +// Must be last. + +// Well-known field tag numbers for map-entry messages. +#define kUpb_MapEntry_KeyFieldNumber 1 +#define kUpb_MapEntry_ValueFieldNumber 2 + +// Well-known field tag numbers for Any messages. +#define kUpb_Any_TypeFieldNumber 1 +#define kUpb_Any_ValueFieldNumber 2 + +// Well-known field tag numbers for duration messages. +#define kUpb_Duration_SecondsFieldNumber 1 +#define kUpb_Duration_NanosFieldNumber 2 + +// Well-known field tag numbers for timestamp messages. +#define kUpb_Timestamp_SecondsFieldNumber 1 +#define kUpb_Timestamp_NanosFieldNumber 2 + +// All the different kind of well known type messages. For simplicity of check, +// number wrappers and string wrappers are grouped together. Make sure the +// order and number of these groups are not changed. +typedef enum { + kUpb_WellKnown_Unspecified, + kUpb_WellKnown_Any, + kUpb_WellKnown_FieldMask, + kUpb_WellKnown_Duration, + kUpb_WellKnown_Timestamp, + + // number wrappers + kUpb_WellKnown_DoubleValue, + kUpb_WellKnown_FloatValue, + kUpb_WellKnown_Int64Value, + kUpb_WellKnown_UInt64Value, + kUpb_WellKnown_Int32Value, + kUpb_WellKnown_UInt32Value, + + // string wrappers + kUpb_WellKnown_StringValue, + kUpb_WellKnown_BytesValue, + kUpb_WellKnown_BoolValue, + kUpb_WellKnown_Value, + kUpb_WellKnown_ListValue, + kUpb_WellKnown_Struct, +} upb_WellKnown; + +#ifdef __cplusplus +extern "C" { +#endif + +const upb_MessageDef* upb_MessageDef_ContainingType(const upb_MessageDef* m); + +const upb_ExtensionRange* upb_MessageDef_ExtensionRange(const upb_MessageDef* m, + int i); +int upb_MessageDef_ExtensionRangeCount(const upb_MessageDef* m); + +UPB_API const upb_FieldDef* upb_MessageDef_Field(const upb_MessageDef* m, + int i); +UPB_API int upb_MessageDef_FieldCount(const upb_MessageDef* m); + +UPB_API const upb_FileDef* upb_MessageDef_File(const upb_MessageDef* m); + +// Returns a field by either JSON name or regular proto name. +const upb_FieldDef* upb_MessageDef_FindByJsonNameWithSize( + const upb_MessageDef* m, const char* name, size_t size); +UPB_INLINE const upb_FieldDef* upb_MessageDef_FindByJsonName( + const upb_MessageDef* m, const char* name) { + return upb_MessageDef_FindByJsonNameWithSize(m, name, strlen(name)); +} + +// Lookup of either field or oneof by name. Returns whether either was found. +// If the return is true, then the found def will be set, and the non-found +// one set to NULL. +UPB_API bool upb_MessageDef_FindByNameWithSize(const upb_MessageDef* m, + const char* name, size_t size, + const upb_FieldDef** f, + const upb_OneofDef** o); +UPB_INLINE bool upb_MessageDef_FindByName(const upb_MessageDef* m, + const char* name, + const upb_FieldDef** f, + const upb_OneofDef** o) { + return upb_MessageDef_FindByNameWithSize(m, name, strlen(name), f, o); +} + +const upb_FieldDef* upb_MessageDef_FindFieldByName(const upb_MessageDef* m, + const char* name); +UPB_API const upb_FieldDef* upb_MessageDef_FindFieldByNameWithSize( + const upb_MessageDef* m, const char* name, size_t size); +UPB_API const upb_FieldDef* upb_MessageDef_FindFieldByNumber( + const upb_MessageDef* m, uint32_t i); +const upb_OneofDef* upb_MessageDef_FindOneofByName(const upb_MessageDef* m, + const char* name); +UPB_API const upb_OneofDef* upb_MessageDef_FindOneofByNameWithSize( + const upb_MessageDef* m, const char* name, size_t size); +UPB_API const char* upb_MessageDef_FullName(const upb_MessageDef* m); +bool upb_MessageDef_HasOptions(const upb_MessageDef* m); +bool upb_MessageDef_IsMapEntry(const upb_MessageDef* m); +bool upb_MessageDef_IsMessageSet(const upb_MessageDef* m); + +// Creates a mini descriptor string for a message, returns true on success. +bool upb_MessageDef_MiniDescriptorEncode(const upb_MessageDef* m, upb_Arena* a, + upb_StringView* out); + +UPB_API const upb_MiniTable* upb_MessageDef_MiniTable(const upb_MessageDef* m); +const char* upb_MessageDef_Name(const upb_MessageDef* m); + +const upb_EnumDef* upb_MessageDef_NestedEnum(const upb_MessageDef* m, int i); +const upb_FieldDef* upb_MessageDef_NestedExtension(const upb_MessageDef* m, + int i); +const upb_MessageDef* upb_MessageDef_NestedMessage(const upb_MessageDef* m, + int i); + +int upb_MessageDef_NestedEnumCount(const upb_MessageDef* m); +int upb_MessageDef_NestedExtensionCount(const upb_MessageDef* m); +int upb_MessageDef_NestedMessageCount(const upb_MessageDef* m); + +UPB_API const upb_OneofDef* upb_MessageDef_Oneof(const upb_MessageDef* m, + int i); +UPB_API int upb_MessageDef_OneofCount(const upb_MessageDef* m); +int upb_MessageDef_RealOneofCount(const upb_MessageDef* m); + +const UPB_DESC(MessageOptions) * + upb_MessageDef_Options(const upb_MessageDef* m); +const UPB_DESC(FeatureSet) * + upb_MessageDef_ResolvedFeatures(const upb_MessageDef* m); + +upb_StringView upb_MessageDef_ReservedName(const upb_MessageDef* m, int i); +int upb_MessageDef_ReservedNameCount(const upb_MessageDef* m); + +const upb_MessageReservedRange* upb_MessageDef_ReservedRange( + const upb_MessageDef* m, int i); +int upb_MessageDef_ReservedRangeCount(const upb_MessageDef* m); + +UPB_API upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m); +UPB_API upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef* m); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_MESSAGE_DEF_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_METHOD_DEF_H_ +#define UPB_REFLECTION_METHOD_DEF_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API bool upb_MethodDef_ClientStreaming(const upb_MethodDef* m); +const char* upb_MethodDef_FullName(const upb_MethodDef* m); +bool upb_MethodDef_HasOptions(const upb_MethodDef* m); +int upb_MethodDef_Index(const upb_MethodDef* m); +UPB_API const upb_MessageDef* upb_MethodDef_InputType(const upb_MethodDef* m); +UPB_API const char* upb_MethodDef_Name(const upb_MethodDef* m); +UPB_API const UPB_DESC(MethodOptions) * + upb_MethodDef_Options(const upb_MethodDef* m); +const UPB_DESC(FeatureSet) * + upb_MethodDef_ResolvedFeatures(const upb_MethodDef* m); +UPB_API const upb_MessageDef* upb_MethodDef_OutputType(const upb_MethodDef* m); +UPB_API bool upb_MethodDef_ServerStreaming(const upb_MethodDef* m); +UPB_API const upb_ServiceDef* upb_MethodDef_Service(const upb_MethodDef* m); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_METHOD_DEF_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_ONEOF_DEF_H_ +#define UPB_REFLECTION_ONEOF_DEF_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API const upb_MessageDef* upb_OneofDef_ContainingType( + const upb_OneofDef* o); +UPB_API const upb_FieldDef* upb_OneofDef_Field(const upb_OneofDef* o, int i); +UPB_API int upb_OneofDef_FieldCount(const upb_OneofDef* o); +const char* upb_OneofDef_FullName(const upb_OneofDef* o); +bool upb_OneofDef_HasOptions(const upb_OneofDef* o); +uint32_t upb_OneofDef_Index(const upb_OneofDef* o); +bool upb_OneofDef_IsSynthetic(const upb_OneofDef* o); +const upb_FieldDef* upb_OneofDef_LookupName(const upb_OneofDef* o, + const char* name); +const upb_FieldDef* upb_OneofDef_LookupNameWithSize(const upb_OneofDef* o, + const char* name, + size_t size); +const upb_FieldDef* upb_OneofDef_LookupNumber(const upb_OneofDef* o, + uint32_t num); +UPB_API const char* upb_OneofDef_Name(const upb_OneofDef* o); +int upb_OneofDef_numfields(const upb_OneofDef* o); +const UPB_DESC(OneofOptions*) upb_OneofDef_Options(const upb_OneofDef* o); +const UPB_DESC(FeatureSet*) + upb_OneofDef_ResolvedFeatures(const upb_OneofDef* o); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ONEOF_DEF_H_ */ + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_SERVICE_DEF_H_ +#define UPB_REFLECTION_SERVICE_DEF_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API const upb_FileDef* upb_ServiceDef_File(const upb_ServiceDef* s); +const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s, + const char* name); +UPB_API const char* upb_ServiceDef_FullName(const upb_ServiceDef* s); +bool upb_ServiceDef_HasOptions(const upb_ServiceDef* s); +int upb_ServiceDef_Index(const upb_ServiceDef* s); +UPB_API const upb_MethodDef* upb_ServiceDef_Method(const upb_ServiceDef* s, + int i); +UPB_API int upb_ServiceDef_MethodCount(const upb_ServiceDef* s); +const char* upb_ServiceDef_Name(const upb_ServiceDef* s); +UPB_API const UPB_DESC(ServiceOptions) * + upb_ServiceDef_Options(const upb_ServiceDef* s); +const UPB_DESC(FeatureSet) * + upb_ServiceDef_ResolvedFeatures(const upb_ServiceDef* s); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_SERVICE_DEF_H_ */ +// IWYU pragma: end_exports + +#endif /* UPB_REFLECTION_DEF_H_ */ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +enum { upb_JsonDecode_IgnoreUnknown = 1 }; + +UPB_API bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg, + const upb_MessageDef* m, const upb_DefPool* symtab, + int options, upb_Arena* arena, upb_Status* status); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_JSONDECODE_H_ */ + +#ifndef UPB_LEX_ATOI_H_ +#define UPB_LEX_ATOI_H_ + +#include + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// We use these hand-written routines instead of strto[u]l() because the "long +// long" variants aren't in c89. Also our version allows setting a ptr limit. +// Return the new position of the pointer after parsing the int, or NULL on +// integer overflow. + +const char* upb_BufToUint64(const char* ptr, const char* end, uint64_t* val); +const char* upb_BufToInt64(const char* ptr, const char* end, int64_t* val, + bool* is_neg); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_LEX_ATOI_H_ */ + +#ifndef UPB_LEX_UNICODE_H_ +#define UPB_LEX_UNICODE_H_ + +#include + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Returns true iff a codepoint is the value for a high surrogate. +UPB_INLINE bool upb_Unicode_IsHigh(uint32_t cp) { + return (cp >= 0xd800 && cp <= 0xdbff); +} + +// Returns true iff a codepoint is the value for a low surrogate. +UPB_INLINE bool upb_Unicode_IsLow(uint32_t cp) { + return (cp >= 0xdc00 && cp <= 0xdfff); +} + +// Returns the high 16-bit surrogate value for a supplementary codepoint. +// Does not sanity-check the input. +UPB_INLINE uint16_t upb_Unicode_ToHigh(uint32_t cp) { + return (cp >> 10) + 0xd7c0; +} + +// Returns the low 16-bit surrogate value for a supplementary codepoint. +// Does not sanity-check the input. +UPB_INLINE uint16_t upb_Unicode_ToLow(uint32_t cp) { + return (cp & 0x3ff) | 0xdc00; +} + +// Returns the 32-bit value corresponding to a pair of 16-bit surrogates. +// Does not sanity-check the input. +UPB_INLINE uint32_t upb_Unicode_FromPair(uint32_t high, uint32_t low) { + return ((high & 0x3ff) << 10) + (low & 0x3ff) + 0x10000; +} + +// Outputs a codepoint as UTF8. +// Returns the number of bytes written (1-4 on success, 0 on error). +// Does not sanity-check the input. Specifically does not check for surrogates. +int upb_Unicode_ToUTF8(uint32_t cp, char* out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_LEX_UNICODE_H_ */ + +#ifndef UPB_REFLECTION_MESSAGE_H_ +#define UPB_REFLECTION_MESSAGE_H_ + +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Returns a mutable pointer to a map, array, or submessage value. If the given +// arena is non-NULL this will construct a new object if it was not previously +// present. May not be called for primitive fields. +UPB_API upb_MutableMessageValue upb_Message_Mutable(upb_Message* msg, + const upb_FieldDef* f, + upb_Arena* a); + +// Returns the field that is set in the oneof, or NULL if none are set. +UPB_API const upb_FieldDef* upb_Message_WhichOneof(const upb_Message* msg, + const upb_OneofDef* o); + +// Clear all data and unknown fields. +void upb_Message_ClearByDef(upb_Message* msg, const upb_MessageDef* m); + +// Clears any field presence and sets the value back to its default. +UPB_API void upb_Message_ClearFieldByDef(upb_Message* msg, + const upb_FieldDef* f); + +// May only be called for fields where upb_FieldDef_HasPresence(f) == true. +UPB_API bool upb_Message_HasFieldByDef(const upb_Message* msg, + const upb_FieldDef* f); + +// Returns the value in the message associated with this field def. +UPB_API upb_MessageValue upb_Message_GetFieldByDef(const upb_Message* msg, + const upb_FieldDef* f); + +// Sets the given field to the given value. For a msg/array/map/string, the +// caller must ensure that the target data outlives |msg| (by living either in +// the same arena or a different arena that outlives it). +// +// Returns false if allocation fails. +UPB_API bool upb_Message_SetFieldByDef(upb_Message* msg, const upb_FieldDef* f, + upb_MessageValue val, upb_Arena* a); + +// Iterate over present fields. +// +// size_t iter = kUpb_Message_Begin; +// const upb_FieldDef *f; +// upb_MessageValue val; +// while (upb_Message_Next(msg, m, ext_pool, &f, &val, &iter)) { +// process_field(f, val); +// } +// +// If ext_pool is NULL, no extensions will be returned. If the given symtab +// returns extensions that don't match what is in this message, those extensions +// will be skipped. + +#define kUpb_Message_Begin -1 + +UPB_API bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m, + const upb_DefPool* ext_pool, + const upb_FieldDef** f, upb_MessageValue* val, + size_t* iter); + +// Clears all unknown field data from this message and all submessages. +UPB_API bool upb_Message_DiscardUnknown(upb_Message* msg, + const upb_MessageDef* m, int maxdepth); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_MESSAGE_H_ */ + +#ifndef UPB_JSON_ENCODE_H_ +#define UPB_JSON_ENCODE_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + /* When set, emits 0/default values. TODO: proto3 only? */ + upb_JsonEncode_EmitDefaults = 1 << 0, + + /* When set, use normal (snake_case) field names instead of JSON (camelCase) + names. */ + upb_JsonEncode_UseProtoNames = 1 << 1, + + /* When set, emits enums as their integer values instead of as their names. */ + upb_JsonEncode_FormatEnumsAsIntegers = 1 << 2 +}; + +/* Encodes the given |msg| to JSON format. The message's reflection is given in + * |m|. The DefPool in |ext_pool| is used to find extensions (if NULL, + * extensions will not be printed). + * + * Output is placed in the given buffer, and always NULL-terminated. The output + * size (excluding NULL) is returned. This means that a return value >= |size| + * implies that the output was truncated. (These are the same semantics as + * snprintf()). */ +UPB_API size_t upb_JsonEncode(const upb_Message* msg, const upb_MessageDef* m, + const upb_DefPool* ext_pool, int options, + char* buf, size_t size, upb_Status* status); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_JSONENCODE_H_ */ + +#ifndef UPB_LEX_ROUND_TRIP_H_ +#define UPB_LEX_ROUND_TRIP_H_ + +// Must be last. + +// Encodes a float or double that is round-trippable, but as short as possible. +// These routines are not fully optimal (not guaranteed to be shortest), but are +// short-ish and match the implementation that has been used in protobuf since +// the beginning. + +// The given buffer size must be at least kUpb_RoundTripBufferSize. +enum { kUpb_RoundTripBufferSize = 32 }; + +#ifdef __cplusplus +extern "C" { +#endif + +void _upb_EncodeRoundTripDouble(double val, char* buf, size_t size); +void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_LEX_ROUND_TRIP_H_ */ + +#ifndef UPB_PORT_VSNPRINTF_COMPAT_H_ +#define UPB_PORT_VSNPRINTF_COMPAT_H_ + +// Must be last. + +UPB_INLINE int _upb_vsnprintf(char* buf, size_t size, const char* fmt, + va_list ap) { +#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) + // The msvc runtime has a non-conforming vsnprintf() that requires the + // following compatibility code to become conformant. + int n = -1; + if (size != 0) n = _vsnprintf_s(buf, size, _TRUNCATE, fmt, ap); + if (n == -1) n = _vscprintf(fmt, ap); + return n; +#else + return vsnprintf(buf, size, fmt, ap); +#endif +} + + +#endif // UPB_PORT_VSNPRINTF_COMPAT_H_ + +#ifndef UPB_PORT_ATOMIC_H_ +#define UPB_PORT_ATOMIC_H_ + + +#ifdef UPB_USE_C11_ATOMICS + +// IWYU pragma: begin_exports +#include +#include +// IWYU pragma: end_exports + +#define upb_Atomic_Init(addr, val) atomic_init(addr, val) +#define upb_Atomic_Load(addr, order) atomic_load_explicit(addr, order) +#define upb_Atomic_Store(addr, val, order) \ + atomic_store_explicit(addr, val, order) +#define upb_Atomic_Add(addr, val, order) \ + atomic_fetch_add_explicit(addr, val, order) +#define upb_Atomic_Sub(addr, val, order) \ + atomic_fetch_sub_explicit(addr, val, order) +#define upb_Atomic_Exchange(addr, val, order) \ + atomic_exchange_explicit(addr, val, order) +#define upb_Atomic_CompareExchangeStrong(addr, expected, desired, \ + success_order, failure_order) \ + atomic_compare_exchange_strong_explicit(addr, expected, desired, \ + success_order, failure_order) +#define upb_Atomic_CompareExchangeWeak(addr, expected, desired, success_order, \ + failure_order) \ + atomic_compare_exchange_weak_explicit(addr, expected, desired, \ + success_order, failure_order) + +#else // !UPB_USE_C11_ATOMICS + +#include + +#define upb_Atomic_Init(addr, val) (*addr = val) +#define upb_Atomic_Load(addr, order) (*addr) +#define upb_Atomic_Store(addr, val, order) (*(addr) = val) +#define upb_Atomic_Add(addr, val, order) (*(addr) += val) +#define upb_Atomic_Sub(addr, val, order) (*(addr) -= val) + +UPB_INLINE void* _upb_NonAtomic_Exchange(void* addr, void* value) { + void* old; + memcpy(&old, addr, sizeof(value)); + memcpy(addr, &value, sizeof(value)); + return old; +} + +#define upb_Atomic_Exchange(addr, val, order) _upb_NonAtomic_Exchange(addr, val) + +// `addr` and `expected` are logically double pointers. +UPB_INLINE bool _upb_NonAtomic_CompareExchangeStrongP(void* addr, + void* expected, + void* desired) { + if (memcmp(addr, expected, sizeof(desired)) == 0) { + memcpy(addr, &desired, sizeof(desired)); + return true; + } else { + memcpy(expected, addr, sizeof(desired)); + return false; + } +} + +#define upb_Atomic_CompareExchangeStrong(addr, expected, desired, \ + success_order, failure_order) \ + _upb_NonAtomic_CompareExchangeStrongP((void*)addr, (void*)expected, \ + (void*)desired) +#define upb_Atomic_CompareExchangeWeak(addr, expected, desired, success_order, \ + failure_order) \ + upb_Atomic_CompareExchangeStrong(addr, expected, desired, 0, 0) + +#endif + + +#endif // UPB_PORT_ATOMIC_H_ + +#ifndef UPB_MESSAGE_COMPAT_H_ +#define UPB_MESSAGE_COMPAT_H_ + +#include + + +// Must be last. + +// upb does not support mixing minitables from different sources but these +// functions are still used by some existing users so for now we make them +// available here. This may or may not change in the future so do not add +// them to new code. + +#ifdef __cplusplus +extern "C" { +#endif + +const upb_MiniTableExtension* upb_Message_ExtensionByIndex( + const upb_Message* msg, size_t index); + +// Returns the minitable with the given field number, or NULL on failure. +const upb_MiniTableExtension* upb_Message_FindExtensionByNumber( + const upb_Message* msg, uint32_t field_number); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_COMPAT_H_ */ + +// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// + +#ifndef UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ +#define UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ + +#include + + +#ifndef UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ +#define UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ + +#include + + +// Map entries aren't actually stored for map fields, they are only used during +// parsing. (It helps a lot if all map entry messages have the same layout.) +// The mini_table layout code will ensure that all map entries have this layout. +// +// Note that users can and do create map entries directly, which will also use +// this layout. + +typedef struct { + struct upb_Message message; + // We only need 2 hasbits max, but due to alignment we'll use 8 bytes here, + // and the uint64_t helps make this clear. + uint64_t hasbits; + union { + upb_StringView str; // For str/bytes. + upb_value val; // For all other types. + double d[2]; // Padding for 32-bit builds. + } k; + union { + upb_StringView str; // For str/bytes. + upb_value val; // For all other types. + double d[2]; // Padding for 32-bit builds. + } v; +} upb_MapEntry; + +#endif // UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// _upb_mapsorter sorts maps and provides ordered iteration over the entries. +// Since maps can be recursive (map values can be messages which contain other +// maps), _upb_mapsorter can contain a stack of maps. + +typedef struct { + void const** entries; + int size; + int cap; +} _upb_mapsorter; + +typedef struct { + int start; + int pos; + int end; +} _upb_sortedmap; + +UPB_INLINE void _upb_mapsorter_init(_upb_mapsorter* s) { + s->entries = NULL; + s->size = 0; + s->cap = 0; +} + +UPB_INLINE void _upb_mapsorter_destroy(_upb_mapsorter* s) { + if (s->entries) upb_gfree(s->entries); +} + +UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, + const struct upb_Map* map, + _upb_sortedmap* sorted, upb_MapEntry* ent) { + if (sorted->pos == sorted->end) return false; + const upb_tabent* tabent = (const upb_tabent*)s->entries[sorted->pos++]; + upb_StringView key = upb_tabstrview(tabent->key); + _upb_map_fromkey(key, &ent->k, map->key_size); + upb_value val = {tabent->val.val}; + _upb_map_fromvalue(val, &ent->v, map->val_size); + return true; +} + +UPB_INLINE bool _upb_sortedmap_nextext(_upb_mapsorter* s, + _upb_sortedmap* sorted, + const upb_Extension** ext) { + if (sorted->pos == sorted->end) return false; + *ext = (const upb_Extension*)s->entries[sorted->pos++]; + return true; +} + +UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter* s, + _upb_sortedmap* sorted) { + s->size = sorted->start; +} + +bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type, + const struct upb_Map* map, _upb_sortedmap* sorted); + +bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts, + size_t count, _upb_sortedmap* sorted); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ */ + +#ifndef UPB_BASE_INTERNAL_LOG2_H_ +#define UPB_BASE_INTERNAL_LOG2_H_ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE int upb_Log2Ceiling(int x) { + if (x <= 1) return 0; +#ifdef __GNUC__ + return 32 - __builtin_clz(x - 1); +#else + int lg2 = 0; + while ((1 << lg2) < x) lg2++; + return lg2; +#endif +} + +UPB_INLINE int upb_Log2CeilingSize(int x) { return 1 << upb_Log2Ceiling(x); } + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_BASE_INTERNAL_LOG2_H_ */ + +#ifndef UPB_MESSAGE_COMPARE_H_ +#define UPB_MESSAGE_COMPARE_H_ + +#include + + +// Must be last. + +enum { + // If set, upb_Message_IsEqual() will attempt to compare unknown fields. + // By its very nature this comparison is inexact. + kUpb_CompareOption_IncludeUnknownFields = (1 << 0) +}; + +#ifdef __cplusplus +extern "C" { +#endif + +// Returns true if no known fields or extensions are set in the message. +UPB_API bool upb_Message_IsEmpty(const upb_Message* msg, + const upb_MiniTable* m); + +UPB_API bool upb_Message_IsEqual(const upb_Message* msg1, + const upb_Message* msg2, + const upb_MiniTable* m, int options); + +// If |ctype| is a message then |m| must point to its minitable. +UPB_API_INLINE bool upb_MessageValue_IsEqual(upb_MessageValue val1, + upb_MessageValue val2, + upb_CType ctype, + const upb_MiniTable* m, + int options) { + switch (ctype) { + case kUpb_CType_Bool: + return val1.bool_val == val2.bool_val; + + case kUpb_CType_Float: + case kUpb_CType_Int32: + case kUpb_CType_UInt32: + case kUpb_CType_Enum: + return val1.int32_val == val2.int32_val; + + case kUpb_CType_Double: + case kUpb_CType_Int64: + case kUpb_CType_UInt64: + return val1.int64_val == val2.int64_val; + + case kUpb_CType_String: + case kUpb_CType_Bytes: + return upb_StringView_IsEqual(val1.str_val, val2.str_val); + + case kUpb_CType_Message: + return upb_Message_IsEqual(val1.msg_val, val2.msg_val, m, options); + + default: + UPB_UNREACHABLE(); + return false; + } +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_MESSAGE_COMPARE_H_ + +#ifndef UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ +#define UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ + +#include + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Returns true if unknown fields from the two messages are equal when sorted +// and varints are made canonical. +// +// This function is discouraged, as the comparison is inherently lossy without +// schema data: +// +// 1. We don't know whether delimited fields are sub-messages. Unknown +// sub-messages will therefore not have their fields sorted and varints +// canonicalized. +// 2. We don't know about oneof/non-repeated fields, which should semantically +// discard every value except the last. + +typedef enum { + kUpb_UnknownCompareResult_Equal = 0, + kUpb_UnknownCompareResult_NotEqual = 1, + kUpb_UnknownCompareResult_OutOfMemory = 2, + kUpb_UnknownCompareResult_MaxDepthExceeded = 3, +} upb_UnknownCompareResult; + +upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( + const char* buf1, size_t size1, const char* buf2, size_t size2, + int max_depth); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ */ + +#ifndef UPB_MESSAGE_COPY_H_ +#define UPB_MESSAGE_COPY_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Deep clones a message using the provided target arena. +upb_Message* upb_Message_DeepClone(const upb_Message* msg, + const upb_MiniTable* m, upb_Arena* arena); + +// Shallow clones a message using the provided target arena. +upb_Message* upb_Message_ShallowClone(const upb_Message* msg, + const upb_MiniTable* m, upb_Arena* arena); + +// Deep clones array contents. +upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, + const upb_MiniTable* sub, upb_Arena* arena); + +// Deep clones map contents. +upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type, + upb_CType value_type, + const upb_MiniTable* map_entry_table, + upb_Arena* arena); + +// Deep copies the message from src to dst. +bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src, + const upb_MiniTable* m, upb_Arena* arena); + +// Shallow copies the message from src to dst. +void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src, + const upb_MiniTable* m); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_MESSAGE_COPY_H_ + +#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_ +#define UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_ + +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE char _upb_ToBase92(int8_t ch) { + extern const char _kUpb_ToBase92[]; + UPB_ASSERT(0 <= ch && ch < 92); + return _kUpb_ToBase92[ch]; +} + +UPB_INLINE char _upb_FromBase92(uint8_t ch) { + extern const int8_t _kUpb_FromBase92[]; + if (' ' > ch || ch > '~') return -1; + return _kUpb_FromBase92[ch - ' ']; +} + +UPB_INLINE const char* _upb_Base92_DecodeVarint(const char* ptr, + const char* end, char first_ch, + uint8_t min, uint8_t max, + uint32_t* out_val) { + uint32_t val = 0; + uint32_t shift = 0; + const int bits_per_char = + upb_Log2Ceiling(_upb_FromBase92(max) - _upb_FromBase92(min)); + char ch = first_ch; + while (1) { + uint32_t bits = _upb_FromBase92(ch) - _upb_FromBase92(min); + val |= bits << shift; + if (ptr == end || *ptr < min || max < *ptr) { + *out_val = val; + UPB_ASSUME(ptr != NULL); + return ptr; + } + ch = *ptr++; + shift += bits_per_char; + if (shift >= 32) return NULL; + } +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_ + +#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_DECODER_H_ +#define UPB_MINI_DESCRIPTOR_INTERNAL_DECODER_H_ + + +// Must be last. + +// upb_MdDecoder: used internally for decoding MiniDescriptors for messages, +// extensions, and enums. +typedef struct { + const char* end; + upb_Status* status; + jmp_buf err; +} upb_MdDecoder; + +UPB_PRINTF(2, 3) +UPB_NORETURN UPB_INLINE void upb_MdDecoder_ErrorJmp(upb_MdDecoder* d, + const char* fmt, ...) { + if (d->status) { + va_list argp; + upb_Status_SetErrorMessage(d->status, "Error building mini table: "); + va_start(argp, fmt); + upb_Status_VAppendErrorFormat(d->status, fmt, argp); + va_end(argp); + } + UPB_LONGJMP(d->err, 1); +} + +UPB_INLINE void upb_MdDecoder_CheckOutOfMemory(upb_MdDecoder* d, + const void* ptr) { + if (!ptr) upb_MdDecoder_ErrorJmp(d, "Out of memory"); +} + +UPB_INLINE const char* upb_MdDecoder_DecodeBase92Varint( + upb_MdDecoder* d, const char* ptr, char first_ch, uint8_t min, uint8_t max, + uint32_t* out_val) { + ptr = _upb_Base92_DecodeVarint(ptr, d->end, first_ch, min, max, out_val); + if (!ptr) upb_MdDecoder_ErrorJmp(d, "Overlong varint"); + return ptr; +} + + +#endif // UPB_MINI_DESCRIPTOR_INTERNAL_DECODER_H_ + +#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_WIRE_CONSTANTS_H_ +#define UPB_MINI_DESCRIPTOR_INTERNAL_WIRE_CONSTANTS_H_ + + +// Must be last. + +typedef enum { + kUpb_EncodedType_Double = 0, + kUpb_EncodedType_Float = 1, + kUpb_EncodedType_Fixed32 = 2, + kUpb_EncodedType_Fixed64 = 3, + kUpb_EncodedType_SFixed32 = 4, + kUpb_EncodedType_SFixed64 = 5, + kUpb_EncodedType_Int32 = 6, + kUpb_EncodedType_UInt32 = 7, + kUpb_EncodedType_SInt32 = 8, + kUpb_EncodedType_Int64 = 9, + kUpb_EncodedType_UInt64 = 10, + kUpb_EncodedType_SInt64 = 11, + kUpb_EncodedType_OpenEnum = 12, + kUpb_EncodedType_Bool = 13, + kUpb_EncodedType_Bytes = 14, + kUpb_EncodedType_String = 15, + kUpb_EncodedType_Group = 16, + kUpb_EncodedType_Message = 17, + kUpb_EncodedType_ClosedEnum = 18, + + kUpb_EncodedType_RepeatedBase = 20, +} upb_EncodedType; + +typedef enum { + kUpb_EncodedFieldModifier_FlipPacked = 1 << 0, + kUpb_EncodedFieldModifier_IsRequired = 1 << 1, + kUpb_EncodedFieldModifier_IsProto3Singular = 1 << 2, + kUpb_EncodedFieldModifier_FlipValidateUtf8 = 1 << 3, +} upb_EncodedFieldModifier; + +enum { + kUpb_EncodedValue_MinField = ' ', + kUpb_EncodedValue_MaxField = 'I', + kUpb_EncodedValue_MinModifier = 'L', + kUpb_EncodedValue_MaxModifier = '[', + kUpb_EncodedValue_End = '^', + kUpb_EncodedValue_MinSkip = '_', + kUpb_EncodedValue_MaxSkip = '~', + kUpb_EncodedValue_OneofSeparator = '~', + kUpb_EncodedValue_FieldSeparator = '|', + kUpb_EncodedValue_MinOneofField = ' ', + kUpb_EncodedValue_MaxOneofField = 'b', + kUpb_EncodedValue_MaxEnumMask = 'A', +}; + +enum { + kUpb_EncodedVersion_EnumV1 = '!', + kUpb_EncodedVersion_ExtensionV1 = '#', + kUpb_EncodedVersion_MapV1 = '%', + kUpb_EncodedVersion_MessageV1 = '$', + kUpb_EncodedVersion_MessageSetV1 = '&', +}; + + +#endif // UPB_MINI_DESCRIPTOR_INTERNAL_WIRE_CONSTANTS_H_ + +#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_MODIFIERS_H_ +#define UPB_MINI_DESCRIPTOR_INTERNAL_MODIFIERS_H_ + +// Must be last. + +typedef enum { + kUpb_FieldModifier_IsRepeated = 1 << 0, + kUpb_FieldModifier_IsPacked = 1 << 1, + kUpb_FieldModifier_IsClosedEnum = 1 << 2, + kUpb_FieldModifier_IsProto3Singular = 1 << 3, + kUpb_FieldModifier_IsRequired = 1 << 4, + kUpb_FieldModifier_ValidateUtf8 = 1 << 5, +} kUpb_FieldModifier; + +// These modifiers are also used on the wire. +typedef enum { + kUpb_MessageModifier_ValidateUtf8 = 1 << 0, + kUpb_MessageModifier_DefaultIsPacked = 1 << 1, + kUpb_MessageModifier_IsExtendable = 1 << 2, +} kUpb_MessageModifier; + + +#endif // UPB_MINI_DESCRIPTOR_INTERNAL_MODIFIERS_H_ + +#ifndef UPB_MINI_TABLE_COMPAT_H_ +#define UPB_MINI_TABLE_COMPAT_H_ + + +// Must be last. + +// upb does not support mixing minitables from different sources but these +// functions are still used by some existing users so for now we make them +// available here. This may or may not change in the future so do not add +// them to new code. + +#ifdef __cplusplus +extern "C" { +#endif + +// Checks if memory layout of src is compatible with dst. +bool upb_MiniTable_Compatible(const upb_MiniTable* src, + const upb_MiniTable* dst); + +typedef enum { + kUpb_MiniTableEquals_NotEqual, + kUpb_MiniTableEquals_Equal, + kUpb_MiniTableEquals_OutOfMemory, +} upb_MiniTableEquals_Status; + +// Checks equality of mini tables originating from different language runtimes. +upb_MiniTableEquals_Status upb_MiniTable_Equals(const upb_MiniTable* src, + const upb_MiniTable* dst); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_TABLE_COMPAT_H_ */ + +#ifndef UPB_HASH_INT_TABLE_H_ +#define UPB_HASH_INT_TABLE_H_ + + +// Must be last. + +typedef struct { + upb_table t; // For entries that don't fit in the array part. + const upb_tabval* array; // Array part of the table. See const note above. + size_t array_size; // Array part size. + size_t array_count; // Array part number of elements. +} upb_inttable; + +#ifdef __cplusplus +extern "C" { +#endif + +// Initialize a table. If memory allocation failed, false is returned and +// the table is uninitialized. +bool upb_inttable_init(upb_inttable* table, upb_Arena* a); + +// Returns the number of values in the table. +size_t upb_inttable_count(const upb_inttable* t); + +// Inserts the given key into the hashtable with the given value. +// The key must not already exist in the hash table. +// The value must not be UINTPTR_MAX. +// +// If a table resize was required but memory allocation failed, false is +// returned and the table is unchanged. +bool upb_inttable_insert(upb_inttable* t, uintptr_t key, upb_value val, + upb_Arena* a); + +// Looks up key in this table, returning "true" if the key was found. +// If v is non-NULL, copies the value for this key into *v. +bool upb_inttable_lookup(const upb_inttable* t, uintptr_t key, upb_value* v); + +// Removes an item from the table. Returns true if the remove was successful, +// and stores the removed item in *val if non-NULL. +bool upb_inttable_remove(upb_inttable* t, uintptr_t key, upb_value* val); + +// Updates an existing entry in an inttable. +// If the entry does not exist, returns false and does nothing. +// Unlike insert/remove, this does not invalidate iterators. +bool upb_inttable_replace(upb_inttable* t, uintptr_t key, upb_value val); + +// Optimizes the table for the current set of entries, for both memory use and +// lookup time. Client should call this after all entries have been inserted; +// inserting more entries is legal, but will likely require a table resize. +void upb_inttable_compact(upb_inttable* t, upb_Arena* a); + +// Iteration over inttable: +// +// intptr_t iter = UPB_INTTABLE_BEGIN; +// uintptr_t key; +// upb_value val; +// while (upb_inttable_next(t, &key, &val, &iter)) { +// // ... +// } + +#define UPB_INTTABLE_BEGIN -1 + +bool upb_inttable_next(const upb_inttable* t, uintptr_t* key, upb_value* val, + intptr_t* iter); +void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_HASH_INT_TABLE_H_ */ + +#ifndef UPB_WIRE_INTERNAL_CONSTANTS_H_ +#define UPB_WIRE_INTERNAL_CONSTANTS_H_ + +#define kUpb_WireFormat_DefaultDepthLimit 100 + +// MessageSet wire format is: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required bytes message = 3; +// } +// } + +enum { + kUpb_MsgSet_Item = 1, + kUpb_MsgSet_TypeId = 2, + kUpb_MsgSet_Message = 3, +}; + +#endif /* UPB_WIRE_INTERNAL_CONSTANTS_H_ */ + +/* + * Internal implementation details of the decoder that are shared between + * decode.c and decode_fast.c. + */ + +#ifndef UPB_WIRE_INTERNAL_DECODER_H_ +#define UPB_WIRE_INTERNAL_DECODER_H_ + +#include "utf8_range.h" + +// Must be last. + +#define DECODE_NOGROUP (uint32_t) - 1 + +typedef struct upb_Decoder { + upb_EpsCopyInputStream input; + const upb_ExtensionRegistry* extreg; + const char* unknown; // Start of unknown data, preserve at buffer flip + upb_Message* unknown_msg; // Pointer to preserve data to + int depth; // Tracks recursion depth to bound stack usage. + uint32_t end_group; // field number of END_GROUP tag, else DECODE_NOGROUP. + uint16_t options; + bool missing_required; + union { + upb_Arena arena; + void* foo[UPB_ARENA_SIZE_HACK]; + }; + upb_DecodeStatus status; + jmp_buf err; + +#ifndef NDEBUG + const char* debug_tagstart; + const char* debug_valstart; +#endif +} upb_Decoder; + +/* Error function that will abort decoding with longjmp(). We can't declare this + * UPB_NORETURN, even though it is appropriate, because if we do then compilers + * will "helpfully" refuse to tailcall to it + * (see: https://stackoverflow.com/a/55657013), which will defeat a major goal + * of our optimizations. That is also why we must declare it in a separate file, + * otherwise the compiler will see that it calls longjmp() and deduce that it is + * noreturn. */ +const char* _upb_FastDecoder_ErrorJmp(upb_Decoder* d, int status); + +extern const uint8_t upb_utf8_offsets[]; + +UPB_INLINE +bool _upb_Decoder_VerifyUtf8Inline(const char* ptr, int len) { + return utf8_range_IsValid(ptr, len); +} + +const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr, + const upb_Message* msg, + const upb_MiniTable* m); + +/* x86-64 pointers always have the high 16 bits matching. So we can shift + * left 8 and right 8 without loss of information. */ +UPB_INLINE intptr_t decode_totable(const upb_MiniTable* tablep) { + return ((intptr_t)tablep << 8) | tablep->UPB_PRIVATE(table_mask); +} + +UPB_INLINE const upb_MiniTable* decode_totablep(intptr_t table) { + return (const upb_MiniTable*)(table >> 8); +} + +const char* _upb_Decoder_IsDoneFallback(upb_EpsCopyInputStream* e, + const char* ptr, int overrun); + +UPB_INLINE bool _upb_Decoder_IsDone(upb_Decoder* d, const char** ptr) { + return upb_EpsCopyInputStream_IsDoneWithCallback( + &d->input, ptr, &_upb_Decoder_IsDoneFallback); +} + +UPB_INLINE const char* _upb_Decoder_BufferFlipCallback( + upb_EpsCopyInputStream* e, const char* old_end, const char* new_start) { + upb_Decoder* d = (upb_Decoder*)e; + if (!old_end) _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed); + + if (d->unknown) { + if (!UPB_PRIVATE(_upb_Message_AddUnknown)( + d->unknown_msg, d->unknown, old_end - d->unknown, &d->arena)) { + _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); + } + d->unknown = new_start; + } + return new_start; +} + +#if UPB_FASTTABLE +UPB_INLINE +const char* _upb_FastDecoder_TagDispatch(upb_Decoder* d, const char* ptr, + upb_Message* msg, intptr_t table, + uint64_t hasbits, uint64_t tag) { + const upb_MiniTable* table_p = decode_totablep(table); + uint8_t mask = table; + uint64_t data; + size_t idx = tag & mask; + UPB_ASSUME((idx & 7) == 0); + idx >>= 3; + data = table_p->UPB_PRIVATE(fasttable)[idx].field_data ^ tag; + UPB_MUSTTAIL return table_p->UPB_PRIVATE(fasttable)[idx].field_parser( + d, ptr, msg, table, hasbits, data); +} +#endif + +UPB_INLINE uint32_t _upb_FastDecoder_LoadTag(const char* ptr) { + uint16_t tag; + memcpy(&tag, ptr, 2); + return tag; +} + + +#endif /* UPB_WIRE_INTERNAL_DECODER_H_ */ + +#ifndef UPB_WIRE_READER_H_ +#define UPB_WIRE_READER_H_ + + +#ifndef UPB_WIRE_INTERNAL_READER_H_ +#define UPB_WIRE_INTERNAL_READER_H_ + +// Must be last. + +#define kUpb_WireReader_WireTypeBits 3 +#define kUpb_WireReader_WireTypeMask 7 + +typedef struct { + const char* ptr; + uint64_t val; +} UPB_PRIVATE(_upb_WireReader_LongVarint); + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_PRIVATE(_upb_WireReader_LongVarint) +UPB_PRIVATE(_upb_WireReader_ReadLongVarint)(const char* ptr, uint64_t val); + +UPB_FORCEINLINE const char* UPB_PRIVATE(_upb_WireReader_ReadVarint)( + const char* ptr, uint64_t* val, int maxlen, uint64_t maxval) { + uint64_t byte = (uint8_t)*ptr; + if (UPB_LIKELY((byte & 0x80) == 0)) { + *val = (uint32_t)byte; + return ptr + 1; + } + const char* start = ptr; + UPB_PRIVATE(_upb_WireReader_LongVarint) + res = UPB_PRIVATE(_upb_WireReader_ReadLongVarint)(ptr, byte); + if (!res.ptr || (maxlen < 10 && res.ptr - start > maxlen) || + res.val > maxval) { + return NULL; // Malformed. + } + *val = res.val; + return res.ptr; +} + +UPB_API_INLINE uint32_t upb_WireReader_GetFieldNumber(uint32_t tag) { + return tag >> kUpb_WireReader_WireTypeBits; +} + +UPB_API_INLINE uint8_t upb_WireReader_GetWireType(uint32_t tag) { + return tag & kUpb_WireReader_WireTypeMask; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_WIRE_INTERNAL_READER_H_ + +#ifndef UPB_WIRE_TYPES_H_ +#define UPB_WIRE_TYPES_H_ + +// A list of types as they are encoded on the wire. +typedef enum { + kUpb_WireType_Varint = 0, + kUpb_WireType_64Bit = 1, + kUpb_WireType_Delimited = 2, + kUpb_WireType_StartGroup = 3, + kUpb_WireType_EndGroup = 4, + kUpb_WireType_32Bit = 5 +} upb_WireType; + +#endif /* UPB_WIRE_TYPES_H_ */ + +// Must be last. + +// The upb_WireReader interface is suitable for general-purpose parsing of +// protobuf binary wire format. It is designed to be used along with +// upb_EpsCopyInputStream for buffering, and all parsing routines in this file +// assume that at least kUpb_EpsCopyInputStream_SlopBytes worth of data is +// available to read without any bounds checks. + +#ifdef __cplusplus +extern "C" { +#endif + +// Parses a tag into `tag`, and returns a pointer past the end of the tag, or +// NULL if there was an error in the tag data. +// +// REQUIRES: there must be at least 10 bytes of data available at `ptr`. +// Bounds checks must be performed before calling this function, preferably +// by calling upb_EpsCopyInputStream_IsDone(). +UPB_FORCEINLINE const char* upb_WireReader_ReadTag(const char* ptr, + uint32_t* tag) { + uint64_t val; + ptr = UPB_PRIVATE(_upb_WireReader_ReadVarint)(ptr, &val, 5, UINT32_MAX); + if (!ptr) return NULL; + *tag = val; + return ptr; +} + +// Given a tag, returns the field number. +UPB_API_INLINE uint32_t upb_WireReader_GetFieldNumber(uint32_t tag); + +// Given a tag, returns the wire type. +UPB_API_INLINE uint8_t upb_WireReader_GetWireType(uint32_t tag); + +UPB_INLINE const char* upb_WireReader_ReadVarint(const char* ptr, + uint64_t* val) { + return UPB_PRIVATE(_upb_WireReader_ReadVarint)(ptr, val, 10, UINT64_MAX); +} + +// Skips data for a varint, returning a pointer past the end of the varint, or +// NULL if there was an error in the varint data. +// +// REQUIRES: there must be at least 10 bytes of data available at `ptr`. +// Bounds checks must be performed before calling this function, preferably +// by calling upb_EpsCopyInputStream_IsDone(). +UPB_INLINE const char* upb_WireReader_SkipVarint(const char* ptr) { + uint64_t val; + return upb_WireReader_ReadVarint(ptr, &val); +} + +// Reads a varint indicating the size of a delimited field into `size`, or +// NULL if there was an error in the varint data. +// +// REQUIRES: there must be at least 10 bytes of data available at `ptr`. +// Bounds checks must be performed before calling this function, preferably +// by calling upb_EpsCopyInputStream_IsDone(). +UPB_INLINE const char* upb_WireReader_ReadSize(const char* ptr, int* size) { + uint64_t size64; + ptr = upb_WireReader_ReadVarint(ptr, &size64); + if (!ptr || size64 >= INT32_MAX) return NULL; + *size = size64; + return ptr; +} + +// Reads a fixed32 field, performing byte swapping if necessary. +// +// REQUIRES: there must be at least 4 bytes of data available at `ptr`. +// Bounds checks must be performed before calling this function, preferably +// by calling upb_EpsCopyInputStream_IsDone(). +UPB_INLINE const char* upb_WireReader_ReadFixed32(const char* ptr, void* val) { + uint32_t uval; + memcpy(&uval, ptr, 4); + uval = upb_BigEndian32(uval); + memcpy(val, &uval, 4); + return ptr + 4; +} + +// Reads a fixed64 field, performing byte swapping if necessary. +// +// REQUIRES: there must be at least 4 bytes of data available at `ptr`. +// Bounds checks must be performed before calling this function, preferably +// by calling upb_EpsCopyInputStream_IsDone(). +UPB_INLINE const char* upb_WireReader_ReadFixed64(const char* ptr, void* val) { + uint64_t uval; + memcpy(&uval, ptr, 8); + uval = upb_BigEndian64(uval); + memcpy(val, &uval, 8); + return ptr + 8; +} + +const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)( + const char* ptr, uint32_t tag, int depth_limit, + upb_EpsCopyInputStream* stream); + +// Skips data for a group, returning a pointer past the end of the group, or +// NULL if there was an error parsing the group. The `tag` argument should be +// the start group tag that begins the group. The `depth_limit` argument +// indicates how many levels of recursion the group is allowed to have before +// reporting a parse error (this limit exists to protect against stack +// overflow). +// +// TODO: evaluate how the depth_limit should be specified. Do users need +// control over this? +UPB_INLINE const char* upb_WireReader_SkipGroup( + const char* ptr, uint32_t tag, upb_EpsCopyInputStream* stream) { + return UPB_PRIVATE(_upb_WireReader_SkipGroup)(ptr, tag, 100, stream); +} + +UPB_INLINE const char* _upb_WireReader_SkipValue( + const char* ptr, uint32_t tag, int depth_limit, + upb_EpsCopyInputStream* stream) { + switch (upb_WireReader_GetWireType(tag)) { + case kUpb_WireType_Varint: + return upb_WireReader_SkipVarint(ptr); + case kUpb_WireType_32Bit: + return ptr + 4; + case kUpb_WireType_64Bit: + return ptr + 8; + case kUpb_WireType_Delimited: { + int size; + ptr = upb_WireReader_ReadSize(ptr, &size); + if (!ptr) return NULL; + ptr += size; + return ptr; + } + case kUpb_WireType_StartGroup: + return UPB_PRIVATE(_upb_WireReader_SkipGroup)(ptr, tag, depth_limit, + stream); + case kUpb_WireType_EndGroup: + return NULL; // Should be handled before now. + default: + return NULL; // Unknown wire type. + } +} + +// Skips data for a wire value of any type, returning a pointer past the end of +// the data, or NULL if there was an error parsing the group. The `tag` argument +// should be the tag that was just parsed. The `depth_limit` argument indicates +// how many levels of recursion a group is allowed to have before reporting a +// parse error (this limit exists to protect against stack overflow). +// +// REQUIRES: there must be at least 10 bytes of data available at `ptr`. +// Bounds checks must be performed before calling this function, preferably +// by calling upb_EpsCopyInputStream_IsDone(). +// +// TODO: evaluate how the depth_limit should be specified. Do users need +// control over this? +UPB_INLINE const char* upb_WireReader_SkipValue( + const char* ptr, uint32_t tag, upb_EpsCopyInputStream* stream) { + return _upb_WireReader_SkipValue(ptr, tag, 100, stream); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // UPB_WIRE_READER_H_ + +#ifndef UPB_LEX_STRTOD_H_ +#define UPB_LEX_STRTOD_H_ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +double _upb_NoLocaleStrtod(const char *str, char **endptr); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_LEX_STRTOD_H_ */ + +#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_ +#define UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_ + +#include + + +// Must be last. + +// If the input buffer has at least this many bytes available, the encoder call +// is guaranteed to succeed (as long as field number order is maintained). +#define kUpb_MtDataEncoder_MinSize 16 + +typedef struct { + char* end; // Limit of the buffer passed as a parameter. + // Aliased to internal-only members in .cc. + char internal[32]; +} upb_MtDataEncoder; + +#ifdef __cplusplus +extern "C" { +#endif + +// Encodes field/oneof information for a given message. The sequence of calls +// should look like: +// +// upb_MtDataEncoder e; +// char buf[256]; +// char* ptr = buf; +// e.end = ptr + sizeof(buf); +// unit64_t msg_mod = ...; // bitwise & of kUpb_MessageModifiers or zero +// ptr = upb_MtDataEncoder_StartMessage(&e, ptr, msg_mod); +// // Fields *must* be in field number order. +// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...); +// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...); +// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...); +// +// // If oneofs are present. Oneofs must be encoded after regular fields. +// ptr = upb_MiniTable_StartOneof(&e, ptr) +// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); +// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); +// +// ptr = upb_MiniTable_StartOneof(&e, ptr); +// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); +// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); +// +// Oneofs must be encoded after all regular fields. +char* upb_MtDataEncoder_StartMessage(upb_MtDataEncoder* e, char* ptr, + uint64_t msg_mod); +char* upb_MtDataEncoder_PutField(upb_MtDataEncoder* e, char* ptr, + upb_FieldType type, uint32_t field_num, + uint64_t field_mod); +char* upb_MtDataEncoder_StartOneof(upb_MtDataEncoder* e, char* ptr); +char* upb_MtDataEncoder_PutOneofField(upb_MtDataEncoder* e, char* ptr, + uint32_t field_num); + +// Encodes the set of values for a given enum. The values must be given in +// order (after casting to uint32_t), and repeats are not allowed. +char* upb_MtDataEncoder_StartEnum(upb_MtDataEncoder* e, char* ptr); +char* upb_MtDataEncoder_PutEnumValue(upb_MtDataEncoder* e, char* ptr, + uint32_t val); +char* upb_MtDataEncoder_EndEnum(upb_MtDataEncoder* e, char* ptr); + +// Encodes an entire mini descriptor for an extension. +char* upb_MtDataEncoder_EncodeExtension(upb_MtDataEncoder* e, char* ptr, + upb_FieldType type, uint32_t field_num, + uint64_t field_mod); + +// Encodes an entire mini descriptor for a map. +char* upb_MtDataEncoder_EncodeMap(upb_MtDataEncoder* e, char* ptr, + upb_FieldType key_type, + upb_FieldType value_type, uint64_t key_mod, + uint64_t value_mod); + +// Encodes an entire mini descriptor for a message set. +char* upb_MtDataEncoder_EncodeMessageSet(upb_MtDataEncoder* e, char* ptr); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_ */ + +#ifndef UPB_REFLECTION_DEF_POOL_INTERNAL_H_ +#define UPB_REFLECTION_DEF_POOL_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_Arena* _upb_DefPool_Arena(const upb_DefPool* s); +size_t _upb_DefPool_BytesLoaded(const upb_DefPool* s); +upb_ExtensionRegistry* _upb_DefPool_ExtReg(const upb_DefPool* s); + +bool _upb_DefPool_InsertExt(upb_DefPool* s, const upb_MiniTableExtension* ext, + const upb_FieldDef* f); +bool _upb_DefPool_InsertSym(upb_DefPool* s, upb_StringView sym, upb_value v, + upb_Status* status); +bool _upb_DefPool_LookupSym(const upb_DefPool* s, const char* sym, size_t size, + upb_value* v); + +void** _upb_DefPool_ScratchData(const upb_DefPool* s); +size_t* _upb_DefPool_ScratchSize(const upb_DefPool* s); +void _upb_DefPool_SetPlatform(upb_DefPool* s, upb_MiniTablePlatform platform); + +// For generated code only: loads a generated descriptor. +typedef struct _upb_DefPool_Init { + struct _upb_DefPool_Init** deps; // Dependencies of this file. + const upb_MiniTableFile* layout; + const char* filename; + upb_StringView descriptor; // Serialized descriptor. +} _upb_DefPool_Init; + +bool _upb_DefPool_LoadDefInit(upb_DefPool* s, const _upb_DefPool_Init* init); + +// Should only be directly called by tests. This variant lets us suppress +// the use of compiled-in tables, forcing a rebuild of the tables at runtime. +bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init, + bool rebuild_minitable); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_DEF_POOL_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_ +#define UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_ + + +// Must be last. + +// We want to copy the options verbatim into the destination options proto. +// We use serialize+parse as our deep copy. +#define UPB_DEF_SET_OPTIONS(target, desc_type, options_type, proto) \ + if (UPB_DESC(desc_type##_has_options)(proto)) { \ + size_t size; \ + char* pb = UPB_DESC(options_type##_serialize)( \ + UPB_DESC(desc_type##_options)(proto), ctx->tmp_arena, &size); \ + if (!pb) _upb_DefBuilder_OomErr(ctx); \ + target = \ + UPB_DESC(options_type##_parse)(pb, size, _upb_DefBuilder_Arena(ctx)); \ + if (!target) _upb_DefBuilder_OomErr(ctx); \ + } else { \ + target = (const UPB_DESC(options_type)*)kUpbDefOptDefault; \ + } + +#ifdef __cplusplus +extern "C" { +#endif + +struct upb_DefBuilder { + upb_DefPool* symtab; + upb_strtable feature_cache; // Caches features by identity. + UPB_DESC(FeatureSet*) legacy_features; // For computing legacy features. + char* tmp_buf; // Temporary buffer in tmp_arena. + size_t tmp_buf_size; // Size of temporary buffer. + upb_FileDef* file; // File we are building. + upb_Arena* arena; // Allocate defs here. + upb_Arena* tmp_arena; // For temporary allocations. + upb_Status* status; // Record errors here. + const upb_MiniTableFile* layout; // NULL if we should build layouts. + upb_MiniTablePlatform platform; // Platform we are targeting. + int enum_count; // Count of enums built so far. + int msg_count; // Count of messages built so far. + int ext_count; // Count of extensions built so far. + jmp_buf err; // longjmp() on error. +}; + +extern const char* kUpbDefOptDefault; + +// ctx->status has already been set elsewhere so just fail/longjmp() +UPB_NORETURN void _upb_DefBuilder_FailJmp(upb_DefBuilder* ctx); + +UPB_NORETURN void _upb_DefBuilder_Errf(upb_DefBuilder* ctx, const char* fmt, + ...) UPB_PRINTF(2, 3); +UPB_NORETURN void _upb_DefBuilder_OomErr(upb_DefBuilder* ctx); + +const char* _upb_DefBuilder_MakeFullName(upb_DefBuilder* ctx, + const char* prefix, + upb_StringView name); + +// Given a symbol and the base symbol inside which it is defined, +// find the symbol's definition. +const void* _upb_DefBuilder_ResolveAny(upb_DefBuilder* ctx, + const char* from_name_dbg, + const char* base, upb_StringView sym, + upb_deftype_t* type); + +const void* _upb_DefBuilder_Resolve(upb_DefBuilder* ctx, + const char* from_name_dbg, const char* base, + upb_StringView sym, upb_deftype_t type); + +char _upb_DefBuilder_ParseEscape(upb_DefBuilder* ctx, const upb_FieldDef* f, + const char** src, const char* end); + +const char* _upb_DefBuilder_FullToShort(const char* fullname); + +UPB_INLINE void* _upb_DefBuilder_Alloc(upb_DefBuilder* ctx, size_t bytes) { + if (bytes == 0) return NULL; + void* ret = upb_Arena_Malloc(ctx->arena, bytes); + if (!ret) _upb_DefBuilder_OomErr(ctx); + return ret; +} + +// Adds a symbol |v| to the symtab, which must be a def pointer previously +// packed with pack_def(). The def's pointer to upb_FileDef* must be set before +// adding, so we know which entries to remove if building this file fails. +UPB_INLINE void _upb_DefBuilder_Add(upb_DefBuilder* ctx, const char* name, + upb_value v) { + upb_StringView sym = {.data = name, .size = strlen(name)}; + bool ok = _upb_DefPool_InsertSym(ctx->symtab, sym, v, ctx->status); + if (!ok) _upb_DefBuilder_FailJmp(ctx); +} + +UPB_INLINE upb_Arena* _upb_DefBuilder_Arena(const upb_DefBuilder* ctx) { + return ctx->arena; +} + +UPB_INLINE upb_FileDef* _upb_DefBuilder_File(const upb_DefBuilder* ctx) { + return ctx->file; +} + +// This version of CheckIdent() is only called by other, faster versions after +// they detect a parsing error. +void _upb_DefBuilder_CheckIdentSlow(upb_DefBuilder* ctx, upb_StringView name, + bool full); + +// Verify a full identifier string. This is slightly more complicated than +// verifying a relative identifier string because we must track '.' chars. +UPB_INLINE void _upb_DefBuilder_CheckIdentFull(upb_DefBuilder* ctx, + upb_StringView name) { + bool good = name.size > 0; + bool start = true; + + for (size_t i = 0; i < name.size; i++) { + const char c = name.data[i]; + const char d = c | 0x20; // force lowercase + const bool is_alpha = (('a' <= d) & (d <= 'z')) | (c == '_'); + const bool is_numer = ('0' <= c) & (c <= '9') & !start; + const bool is_dot = (c == '.') & !start; + + good &= is_alpha | is_numer | is_dot; + start = is_dot; + } + + if (!good) _upb_DefBuilder_CheckIdentSlow(ctx, name, true); +} + +// Returns true if the returned feature set is new and must be populated. +bool _upb_DefBuilder_GetOrCreateFeatureSet(upb_DefBuilder* ctx, + const UPB_DESC(FeatureSet*) parent, + upb_StringView key, + UPB_DESC(FeatureSet**) set); + +const UPB_DESC(FeatureSet*) + _upb_DefBuilder_DoResolveFeatures(upb_DefBuilder* ctx, + const UPB_DESC(FeatureSet*) parent, + const UPB_DESC(FeatureSet*) child, + bool is_implicit); + +UPB_INLINE const UPB_DESC(FeatureSet*) + _upb_DefBuilder_ResolveFeatures(upb_DefBuilder* ctx, + const UPB_DESC(FeatureSet*) parent, + const UPB_DESC(FeatureSet*) child) { + return _upb_DefBuilder_DoResolveFeatures(ctx, parent, child, false); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_ENUM_DEF_INTERNAL_H_ +#define UPB_REFLECTION_ENUM_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_EnumDef* _upb_EnumDef_At(const upb_EnumDef* e, int i); +bool _upb_EnumDef_Insert(upb_EnumDef* e, upb_EnumValueDef* v, upb_Arena* a); +const upb_MiniTableEnum* _upb_EnumDef_MiniTable(const upb_EnumDef* e); + +// Allocate and initialize an array of |n| enum defs. +upb_EnumDef* _upb_EnumDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(EnumDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + const upb_MessageDef* containing_type); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ENUM_DEF_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_ENUM_VALUE_DEF_INTERNAL_H_ +#define UPB_REFLECTION_ENUM_VALUE_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_EnumValueDef* _upb_EnumValueDef_At(const upb_EnumValueDef* v, int i); + +// Allocate and initialize an array of |n| enum value defs owned by |e|. +upb_EnumValueDef* _upb_EnumValueDefs_New( + upb_DefBuilder* ctx, const char* prefix, int n, + const UPB_DESC(EnumValueDescriptorProto*) const* protos, + const UPB_DESC(FeatureSet*) parent_features, upb_EnumDef* e, + bool* is_sorted); + +const upb_EnumValueDef** _upb_EnumValueDefs_Sorted(const upb_EnumValueDef* v, + int n, upb_Arena* a); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ENUM_VALUE_DEF_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_FIELD_DEF_INTERNAL_H_ +#define UPB_REFLECTION_FIELD_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_FieldDef* _upb_FieldDef_At(const upb_FieldDef* f, int i); + +bool _upb_FieldDef_IsClosedEnum(const upb_FieldDef* f); +bool _upb_FieldDef_IsProto3Optional(const upb_FieldDef* f); +int _upb_FieldDef_LayoutIndex(const upb_FieldDef* f); +uint64_t _upb_FieldDef_Modifiers(const upb_FieldDef* f); +void _upb_FieldDef_Resolve(upb_DefBuilder* ctx, const char* prefix, + upb_FieldDef* f); +void _upb_FieldDef_BuildMiniTableExtension(upb_DefBuilder* ctx, + const upb_FieldDef* f); + +// Allocate and initialize an array of |n| extensions (field defs). +upb_FieldDef* _upb_Extensions_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(FieldDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + const char* prefix, upb_MessageDef* m); + +// Allocate and initialize an array of |n| field defs. +upb_FieldDef* _upb_FieldDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(FieldDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + const char* prefix, upb_MessageDef* m, + bool* is_sorted); + +// Allocate and return a list of pointers to the |n| field defs in |ff|, +// sorted by field number. +const upb_FieldDef** _upb_FieldDefs_Sorted(const upb_FieldDef* f, int n, + upb_Arena* a); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_FIELD_DEF_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_FILE_DEF_INTERNAL_H_ +#define UPB_REFLECTION_FILE_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +const upb_MiniTableExtension* _upb_FileDef_ExtensionMiniTable( + const upb_FileDef* f, int i); +const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f); +const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f); + +// upb_FileDef_Package() returns "" if f->package is NULL, this does not. +const char* _upb_FileDef_RawPackage(const upb_FileDef* f); + +void _upb_FileDef_Create(upb_DefBuilder* ctx, + const UPB_DESC(FileDescriptorProto) * file_proto); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_FILE_DEF_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_MESSAGE_DEF_INTERNAL_H_ +#define UPB_REFLECTION_MESSAGE_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_MessageDef* _upb_MessageDef_At(const upb_MessageDef* m, int i); +bool _upb_MessageDef_InMessageSet(const upb_MessageDef* m); +bool _upb_MessageDef_Insert(upb_MessageDef* m, const char* name, size_t size, + upb_value v, upb_Arena* a); +void _upb_MessageDef_InsertField(upb_DefBuilder* ctx, upb_MessageDef* m, + const upb_FieldDef* f); +bool _upb_MessageDef_IsValidExtensionNumber(const upb_MessageDef* m, int n); +void _upb_MessageDef_CreateMiniTable(upb_DefBuilder* ctx, upb_MessageDef* m); +void _upb_MessageDef_LinkMiniTable(upb_DefBuilder* ctx, + const upb_MessageDef* m); +void _upb_MessageDef_Resolve(upb_DefBuilder* ctx, upb_MessageDef* m); + +// Allocate and initialize an array of |n| message defs. +upb_MessageDef* _upb_MessageDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(DescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) + parent_features, + const upb_MessageDef* containing_type); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_MESSAGE_DEF_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_SERVICE_DEF_INTERNAL_H_ +#define UPB_REFLECTION_SERVICE_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_ServiceDef* _upb_ServiceDef_At(const upb_ServiceDef* s, int i); + +// Allocate and initialize an array of |n| service defs. +upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(ServiceDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) + parent_features); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_SERVICE_DEF_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_UPB_EDITION_DEFAULTS_H_ +#define UPB_REFLECTION_UPB_EDITION_DEFAULTS_H_ + +// This file contains the serialized FeatureSetDefaults object for +// language-independent features and (possibly at some point) for upb-specific +// features. This is used for feature resolution under Editions. +// NOLINTBEGIN +// clang-format off +#define UPB_INTERNAL_UPB_EDITION_DEFAULTS "\n\023\030\346\007\"\000*\014\010\001\020\002\030\002 \003(\0010\002\n\023\030\347\007\"\000*\014\010\002\020\001\030\001 \002(\0010\001\n\023\030\350\007\"\014\010\001\020\001\030\001 \002(\0010\001*\000 \346\007(\350\007" +// clang-format on +// NOLINTEND + +#endif // UPB_REFLECTION_UPB_EDITION_DEFAULTS_H_ + +#ifndef UPB_REFLECTION_DESC_STATE_INTERNAL_H_ +#define UPB_REFLECTION_DESC_STATE_INTERNAL_H_ + + +// Must be last. + +// Manages the storage for mini descriptor strings as they are being encoded. +// TODO: Move some of this state directly into the encoder, maybe. +typedef struct { + upb_MtDataEncoder e; + size_t bufsize; + char* buf; + char* ptr; +} upb_DescState; + +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE void _upb_DescState_Init(upb_DescState* d) { + d->bufsize = kUpb_MtDataEncoder_MinSize * 2; + d->buf = NULL; + d->ptr = NULL; +} + +bool _upb_DescState_Grow(upb_DescState* d, upb_Arena* a); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_DESC_STATE_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_ENUM_RESERVED_RANGE_INTERNAL_H_ +#define UPB_REFLECTION_ENUM_RESERVED_RANGE_INTERNAL_H_ + + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_ENUM_RESERVED_RANGE_H_ +#define UPB_REFLECTION_ENUM_RESERVED_RANGE_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t upb_EnumReservedRange_Start(const upb_EnumReservedRange* r); +int32_t upb_EnumReservedRange_End(const upb_EnumReservedRange* r); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ENUM_RESERVED_RANGE_H_ */ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_EnumReservedRange* _upb_EnumReservedRange_At(const upb_EnumReservedRange* r, + int i); + +// Allocate and initialize an array of |n| reserved ranges owned by |e|. +upb_EnumReservedRange* _upb_EnumReservedRanges_New( + upb_DefBuilder* ctx, int n, + const UPB_DESC(EnumDescriptorProto_EnumReservedRange*) const* protos, + const upb_EnumDef* e); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ENUM_RESERVED_RANGE_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_INTERNAL_STRDUP2_H_ +#define UPB_REFLECTION_INTERNAL_STRDUP2_H_ + +#include + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +// Variant that works with a length-delimited rather than NULL-delimited string, +// as supported by strtable. +char* upb_strdup2(const char* s, size_t len, upb_Arena* a); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_INTERNAL_STRDUP2_H_ */ + +#ifndef UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_ +#define UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_ExtensionRange* _upb_ExtensionRange_At(const upb_ExtensionRange* r, int i); + +// Allocate and initialize an array of |n| extension ranges owned by |m|. +upb_ExtensionRange* _upb_ExtensionRanges_New( + upb_DefBuilder* ctx, int n, + const UPB_DESC(DescriptorProto_ExtensionRange*) const* protos, + const UPB_DESC(FeatureSet*) parent_features, const upb_MessageDef* m); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_ONEOF_DEF_INTERNAL_H_ +#define UPB_REFLECTION_ONEOF_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_OneofDef* _upb_OneofDef_At(const upb_OneofDef* o, int i); +void _upb_OneofDef_Insert(upb_DefBuilder* ctx, upb_OneofDef* o, + const upb_FieldDef* f, const char* name, size_t size); + +// Allocate and initialize an array of |n| oneof defs owned by |m|. +upb_OneofDef* _upb_OneofDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(OneofDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + upb_MessageDef* m); + +size_t _upb_OneofDefs_Finalize(upb_DefBuilder* ctx, upb_MessageDef* m); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_ONEOF_DEF_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_MESSAGE_RESERVED_RANGE_INTERNAL_H_ +#define UPB_REFLECTION_MESSAGE_RESERVED_RANGE_INTERNAL_H_ + + +// IWYU pragma: private, include "upb/reflection/def.h" + +#ifndef UPB_REFLECTION_MESSAGE_RESERVED_RANGE_H_ +#define UPB_REFLECTION_MESSAGE_RESERVED_RANGE_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t upb_MessageReservedRange_Start(const upb_MessageReservedRange* r); +int32_t upb_MessageReservedRange_End(const upb_MessageReservedRange* r); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_MESSAGE_RESERVED_RANGE_H_ */ + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_MessageReservedRange* _upb_MessageReservedRange_At( + const upb_MessageReservedRange* r, int i); + +// Allocate and initialize an array of |n| reserved ranges owned by |m|. +upb_MessageReservedRange* _upb_MessageReservedRanges_New( + upb_DefBuilder* ctx, int n, + const UPB_DESC(DescriptorProto_ReservedRange) * const* protos, + const upb_MessageDef* m); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_MESSAGE_RESERVED_RANGE_INTERNAL_H_ */ + +#ifndef UPB_REFLECTION_METHOD_DEF_INTERNAL_H_ +#define UPB_REFLECTION_METHOD_DEF_INTERNAL_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +upb_MethodDef* _upb_MethodDef_At(const upb_MethodDef* m, int i); + +// Allocate and initialize an array of |n| method defs owned by |s|. +upb_MethodDef* _upb_MethodDefs_New(upb_DefBuilder* ctx, int n, + const UPB_DESC(MethodDescriptorProto*) + const* protos, + const UPB_DESC(FeatureSet*) parent_features, + upb_ServiceDef* s); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_REFLECTION_METHOD_DEF_INTERNAL_H_ */ + +// This should #undef all macros #defined in def.inc + +#undef UPB_SIZE +#undef UPB_PTR_AT +#undef UPB_MAPTYPE_STRING +#undef UPB_EXPORT +#undef UPB_INLINE +#undef UPB_API +#undef UPB_API_INLINE +#undef UPB_ALIGN_UP +#undef UPB_ALIGN_DOWN +#undef UPB_ALIGN_MALLOC +#undef UPB_ALIGN_OF +#undef UPB_ALIGN_AS +#undef UPB_MALLOC_ALIGN +#undef UPB_LIKELY +#undef UPB_UNLIKELY +#undef UPB_FORCEINLINE +#undef UPB_NOINLINE +#undef UPB_NORETURN +#undef UPB_PRINTF +#undef UPB_MAX +#undef UPB_MIN +#undef UPB_UNUSED +#undef UPB_ASSUME +#undef UPB_ASSERT +#undef UPB_UNREACHABLE +#undef UPB_SETJMP +#undef UPB_LONGJMP +#undef UPB_PTRADD +#undef UPB_MUSTTAIL +#undef UPB_FASTTABLE_SUPPORTED +#undef UPB_FASTTABLE_MASK +#undef UPB_FASTTABLE +#undef UPB_FASTTABLE_INIT +#undef UPB_POISON_MEMORY_REGION +#undef UPB_UNPOISON_MEMORY_REGION +#undef UPB_ASAN +#undef UPB_ASAN_GUARD_SIZE +#undef UPB_CLANG_ASAN +#undef UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN +#undef UPB_DEPRECATED +#undef UPB_GNUC_MIN +#undef UPB_DESCRIPTOR_UPB_H_FILENAME +#undef UPB_DESC +#undef UPB_DESC_MINITABLE +#undef UPB_IS_GOOGLE3 +#undef UPB_ATOMIC +#undef UPB_USE_C11_ATOMICS +#undef UPB_PRIVATE +#undef UPB_ONLYBITS diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_convert.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_convert.c new file mode 100755 index 0000000..dd182bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_convert.c @@ -0,0 +1,69 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// ----------------------------------------------------------------------------- +// Ruby <-> upb data conversion functions. Strictly free of dependencies on +// Ruby interpreter internals. + +#include "shared_convert.h" + +bool shared_Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2, + upb_CType type, const upb_MessageDef* msgdef, + upb_Status* status) { + switch (type) { + case kUpb_CType_Bool: + return memcmp(&val1, &val2, 1) == 0; + case kUpb_CType_Float: + case kUpb_CType_Int32: + case kUpb_CType_UInt32: + case kUpb_CType_Enum: + return memcmp(&val1, &val2, 4) == 0; + case kUpb_CType_Double: + case kUpb_CType_Int64: + case kUpb_CType_UInt64: + return memcmp(&val1, &val2, 8) == 0; + case kUpb_CType_String: + case kUpb_CType_Bytes: + return val1.str_val.size == val2.str_val.size && + memcmp(val1.str_val.data, val2.str_val.data, val1.str_val.size) == + 0; + case kUpb_CType_Message: { + const upb_MiniTable* m = upb_MessageDef_MiniTable(msgdef); + const int options = 0; + return upb_Message_IsEqual(val1.msg_val, val2.msg_val, m, options); + } + default: + upb_Status_SetErrorMessage(status, "Internal error, unexpected type"); + return false; + } +} + +uint64_t shared_Msgval_GetHash(upb_MessageValue val, upb_CType type, + const upb_MessageDef* msgdef, uint64_t seed, + upb_Status* status) { + switch (type) { + case kUpb_CType_Bool: + return _upb_Hash(&val, 1, seed); + case kUpb_CType_Float: + case kUpb_CType_Int32: + case kUpb_CType_UInt32: + case kUpb_CType_Enum: + return _upb_Hash(&val, 4, seed); + case kUpb_CType_Double: + case kUpb_CType_Int64: + case kUpb_CType_UInt64: + return _upb_Hash(&val, 8, seed); + case kUpb_CType_String: + case kUpb_CType_Bytes: + return _upb_Hash(val.str_val.data, val.str_val.size, seed); + case kUpb_CType_Message: + return shared_Message_Hash(val.msg_val, msgdef, seed, status); + default: + upb_Status_SetErrorMessage(status, "Internal error, unexpected type"); + return 0; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_convert.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_convert.h new file mode 100755 index 0000000..ca1e91d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_convert.h @@ -0,0 +1,26 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// ----------------------------------------------------------------------------- +// Ruby <-> upb data conversion functions. Strictly free of dependencies on +// Ruby interpreter internals. + +#ifndef RUBY_PROTOBUF_SHARED_CONVERT_H_ +#define RUBY_PROTOBUF_SHARED_CONVERT_H_ + +#include "ruby-upb.h" +#include "shared_message.h" + +bool shared_Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2, + upb_CType type, const upb_MessageDef* msgdef, + upb_Status* status); + +uint64_t shared_Msgval_GetHash(upb_MessageValue val, upb_CType type, + const upb_MessageDef* msgdef, uint64_t seed, + upb_Status* status); + +#endif // RUBY_PROTOBUF_SHARED_CONVERT_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_message.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_message.c new file mode 100755 index 0000000..122682e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_message.c @@ -0,0 +1,37 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// ----------------------------------------------------------------------------- +// Ruby Message functions. Strictly free of dependencies on +// Ruby interpreter internals. + +#include "shared_message.h" + +// Support function for Message_Hash. Returns a hash value for the given +// message. +uint64_t shared_Message_Hash(const upb_Message* msg, const upb_MessageDef* m, + uint64_t seed, upb_Status* status) { + upb_Arena* arena = upb_Arena_New(); + char* data; + size_t size; + + // Hash a deterministically serialized payloads with no unknown fields. + upb_EncodeStatus encode_status = upb_Encode( + msg, upb_MessageDef_MiniTable(m), + kUpb_EncodeOption_SkipUnknown | kUpb_EncodeOption_Deterministic, arena, + &data, &size); + + if (encode_status == kUpb_EncodeStatus_Ok) { + uint64_t ret = _upb_Hash(data, size, seed); + upb_Arena_Free(arena); + return ret; + } + + upb_Arena_Free(arena); + upb_Status_SetErrorMessage(status, "Error calculating hash"); + return 0; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_message.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_message.h new file mode 100755 index 0000000..5072208 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/shared_message.h @@ -0,0 +1,21 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// ----------------------------------------------------------------------------- +// Ruby Message functions. Strictly free of dependencies on +// Ruby interpreter internals. + +#ifndef RUBY_PROTOBUF_SHARED_MESSAGE_H_ +#define RUBY_PROTOBUF_SHARED_MESSAGE_H_ + +#include "ruby-upb.h" + +// Returns a hash value for the given message. +uint64_t shared_Message_Hash(const upb_Message* msg, const upb_MessageDef* m, + uint64_t seed, upb_Status* status); + +#endif // RUBY_PROTOBUF_SHARED_MESSAGE_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/LICENSE b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/LICENSE new file mode 100755 index 0000000..e59f14f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2019 Yibo Cai +Copyright 2022 Google LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c new file mode 100755 index 0000000..9564b07 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c @@ -0,0 +1,467 @@ +// Copyright 2023 Google LLC +// +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +/* This is a wrapper for the Google range-sse.cc algorithm which checks whether + * a sequence of bytes is a valid UTF-8 sequence and finds the longest valid + * prefix of the UTF-8 sequence. + * + * The key difference is that it checks for as much ASCII symbols as possible + * and then falls back to the range-sse.cc algorithm. The changes to the + * algorithm are cosmetic, mostly to trick the clang compiler to produce optimal + * code. + * + * For API see the utf8_validity.h header. + */ +#include "utf8_range.h" + +#include +#include +#include + +#ifdef __SSE4_1__ +#include +#include +#include +#endif + +#if defined(__GNUC__) +#define FORCE_INLINE_ATTR __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define FORCE_INLINE_ATTR __forceinline +#else +#define FORCE_INLINE_ATTR +#endif + +static FORCE_INLINE_ATTR inline uint64_t utf8_range_UnalignedLoad64( + const void* p) { + uint64_t t; + memcpy(&t, p, sizeof t); + return t; +} + +static FORCE_INLINE_ATTR inline int utf8_range_AsciiIsAscii(unsigned char c) { + return c < 128; +} + +static FORCE_INLINE_ATTR inline int utf8_range_IsTrailByteOk(const char c) { + return (int8_t)(c) <= (int8_t)(0xBF); +} + +/* If return_position is false then it returns 1 if |data| is a valid utf8 + * sequence, otherwise returns 0. + * If return_position is set to true, returns the length in bytes of the prefix + of |data| that is all structurally valid UTF-8. + */ +static size_t utf8_range_ValidateUTF8Naive(const char* data, const char* end, + int return_position) { + /* We return err_pos in the loop which is always 0 if !return_position */ + size_t err_pos = 0; + size_t codepoint_bytes = 0; + /* The early check is done because of early continue's on codepoints of all + * sizes, i.e. we first check for ascii and if it is, we call continue, then + * for 2 byte codepoints, etc. This is done in order to reduce indentation and + * improve readability of the codepoint validity check. + */ + while (data + codepoint_bytes < end) { + if (return_position) { + err_pos += codepoint_bytes; + } + data += codepoint_bytes; + const size_t len = end - data; + const unsigned char byte1 = data[0]; + + /* We do not skip many ascii bytes at the same time as this function is + used for tail checking (< 16 bytes) and for non x86 platforms. We also + don't think that cases where non-ASCII codepoints are followed by ascii + happen often. For small strings it also introduces some penalty. For + purely ascii UTF8 strings (which is the overwhelming case) we call + SkipAscii function which is multiplatform and extremely fast. + */ + /* [00..7F] ASCII -> 1 byte */ + if (utf8_range_AsciiIsAscii(byte1)) { + codepoint_bytes = 1; + continue; + } + /* [C2..DF], [80..BF] -> 2 bytes */ + if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF && + utf8_range_IsTrailByteOk(data[1])) { + codepoint_bytes = 2; + continue; + } + if (len >= 3) { + const unsigned char byte2 = data[1]; + const unsigned char byte3 = data[2]; + + /* Is byte2, byte3 between [0x80, 0xBF] + * Check for 0x80 was done above. + */ + if (!utf8_range_IsTrailByteOk(byte2) || + !utf8_range_IsTrailByteOk(byte3)) { + return err_pos; + } + + if (/* E0, A0..BF, 80..BF */ + ((byte1 == 0xE0 && byte2 >= 0xA0) || + /* E1..EC, 80..BF, 80..BF */ + (byte1 >= 0xE1 && byte1 <= 0xEC) || + /* ED, 80..9F, 80..BF */ + (byte1 == 0xED && byte2 <= 0x9F) || + /* EE..EF, 80..BF, 80..BF */ + (byte1 >= 0xEE && byte1 <= 0xEF))) { + codepoint_bytes = 3; + continue; + } + if (len >= 4) { + const unsigned char byte4 = data[3]; + /* Is byte4 between 0x80 ~ 0xBF */ + if (!utf8_range_IsTrailByteOk(byte4)) { + return err_pos; + } + + if (/* F0, 90..BF, 80..BF, 80..BF */ + ((byte1 == 0xF0 && byte2 >= 0x90) || + /* F1..F3, 80..BF, 80..BF, 80..BF */ + (byte1 >= 0xF1 && byte1 <= 0xF3) || + /* F4, 80..8F, 80..BF, 80..BF */ + (byte1 == 0xF4 && byte2 <= 0x8F))) { + codepoint_bytes = 4; + continue; + } + } + } + return err_pos; + } + if (return_position) { + err_pos += codepoint_bytes; + } + /* if return_position is false, this returns 1. + * if return_position is true, this returns err_pos. + */ + return err_pos + (1 - return_position); +} + +#ifdef __SSE4_1__ +/* Returns the number of bytes needed to skip backwards to get to the first + byte of codepoint. + */ +static inline int utf8_range_CodepointSkipBackwards(int32_t codepoint_word) { + const int8_t* const codepoint = (const int8_t*)(&codepoint_word); + if (!utf8_range_IsTrailByteOk(codepoint[3])) { + return 1; + } else if (!utf8_range_IsTrailByteOk(codepoint[2])) { + return 2; + } else if (!utf8_range_IsTrailByteOk(codepoint[1])) { + return 3; + } + return 0; +} +#endif // __SSE4_1__ + +/* Skipping over ASCII as much as possible, per 8 bytes. It is intentional + as most strings to check for validity consist only of 1 byte codepoints. + */ +static inline const char* utf8_range_SkipAscii(const char* data, + const char* end) { + while (8 <= end - data && + (utf8_range_UnalignedLoad64(data) & 0x8080808080808080) == 0) { + data += 8; + } + while (data < end && utf8_range_AsciiIsAscii(*data)) { + ++data; + } + return data; +} + +static FORCE_INLINE_ATTR inline size_t utf8_range_Validate( + const char* data, size_t len, int return_position) { + if (len == 0) return 1 - return_position; + const char* const end = data + len; + data = utf8_range_SkipAscii(data, end); + /* SIMD algorithm always outperforms the naive version for any data of + length >=16. + */ + if (end - data < 16) { + return (return_position ? (data - (end - len)) : 0) + + utf8_range_ValidateUTF8Naive(data, end, return_position); + } +#ifndef __SSE4_1__ + return (return_position ? (data - (end - len)) : 0) + + utf8_range_ValidateUTF8Naive(data, end, return_position); +#else + /* This code checks that utf-8 ranges are structurally valid 16 bytes at once + * using superscalar instructions. + * The mapping between ranges of codepoint and their corresponding utf-8 + * sequences is below. + */ + + /* + * U+0000...U+007F 00...7F + * U+0080...U+07FF C2...DF 80...BF + * U+0800...U+0FFF E0 A0...BF 80...BF + * U+1000...U+CFFF E1...EC 80...BF 80...BF + * U+D000...U+D7FF ED 80...9F 80...BF + * U+E000...U+FFFF EE...EF 80...BF 80...BF + * U+10000...U+3FFFF F0 90...BF 80...BF 80...BF + * U+40000...U+FFFFF F1...F3 80...BF 80...BF 80...BF + * U+100000...U+10FFFF F4 80...8F 80...BF 80...BF + */ + + /* First we compute the type for each byte, as given by the table below. + * This type will be used as an index later on. + */ + + /* + * Index Min Max Byte Type + * 0 00 7F Single byte sequence + * 1,2,3 80 BF Second, third and fourth byte for many of the sequences. + * 4 A0 BF Second byte after E0 + * 5 80 9F Second byte after ED + * 6 90 BF Second byte after F0 + * 7 80 8F Second byte after F4 + * 8 C2 F4 First non ASCII byte + * 9..15 7F 80 Invalid byte + */ + + /* After the first step we compute the index for all bytes, then we permute + the bytes according to their indices to check the ranges from the range + table. + * The range for a given type can be found in the range_min_table and + range_max_table, the range for type/index X is in range_min_table[X] ... + range_max_table[X]. + */ + + /* Algorithm: + * Put index zero to all bytes. + * Find all non ASCII characters, give them index 8. + * For each tail byte in a codepoint sequence, give it an index corresponding + to the 1 based index from the end. + * If the first byte of the codepoint is in the [C0...DF] range, we write + index 1 in the following byte. + * If the first byte of the codepoint is in the range [E0...EF], we write + indices 2 and 1 in the next two bytes. + * If the first byte of the codepoint is in the range [F0...FF] we write + indices 3,2,1 into the next three bytes. + * For finding the number of bytes we need to look at high nibbles (4 bits) + and do the lookup from the table, it can be done with shift by 4 + shuffle + instructions. We call it `first_len`. + * Then we shift first_len by 8 bits to get the indices of the 2nd bytes. + * Saturating sub 1 and shift by 8 bits to get the indices of the 3rd bytes. + * Again to get the indices of the 4th bytes. + * Take OR of all that 4 values and check within range. + */ + /* For example: + * input C3 80 68 E2 80 20 A6 F0 A0 80 AC 20 F0 93 80 80 + * first_len 1 0 0 2 0 0 0 3 0 0 0 0 3 0 0 0 + * 1st byte 8 0 0 8 0 0 0 8 0 0 0 0 8 0 0 0 + * 2nd byte 0 1 0 0 2 0 0 0 3 0 0 0 0 3 0 0 // Shift + sub + * 3rd byte 0 0 0 0 0 1 0 0 0 2 0 0 0 0 2 0 // Shift + sub + * 4th byte 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 // Shift + sub + * Index 8 1 0 8 2 1 0 8 3 2 1 0 8 3 2 1 // OR of results + */ + + /* Checking for errors: + * Error checking is done by looking up the high nibble (4 bits) of each byte + against an error checking table. + * Because the lookup value for the second byte depends of the value of the + first byte in codepoint, we use saturated operations to adjust the index. + * Specifically we need to add 2 for E0, 3 for ED, 3 for F0 and 4 for F4 to + match the correct index. + * If we subtract from all bytes EF then EO -> 241, ED -> 254, F0 -> 1, + F4 -> 5 + * Do saturating sub 240, then E0 -> 1, ED -> 14 and we can do lookup to + match the adjustment + * Add saturating 112, then F0 -> 113, F4 -> 117, all that were > 16 will + be more 128 and lookup in ef_fe_table will return 0 but for F0 + and F4 it will be 4 and 5 accordingly + */ + /* + * Then just check the appropriate ranges with greater/smaller equal + instructions. Check tail with a naive algorithm. + * To save from previous 16 byte checks we just align previous_first_len to + get correct continuations of the codepoints. + */ + + /* + * Map high nibble of "First Byte" to legal character length minus 1 + * 0x00 ~ 0xBF --> 0 + * 0xC0 ~ 0xDF --> 1 + * 0xE0 ~ 0xEF --> 2 + * 0xF0 ~ 0xFF --> 3 + */ + const __m128i first_len_table = + _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3); + + /* Map "First Byte" to 8-th item of range table (0xC2 ~ 0xF4) */ + const __m128i first_range_table = + _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8); + + /* + * Range table, map range index to min and max values + */ + const __m128i range_min_table = + _mm_setr_epi8(0x00, 0x80, 0x80, 0x80, 0xA0, 0x80, 0x90, 0x80, 0xC2, 0x7F, + 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F); + + const __m128i range_max_table = + _mm_setr_epi8(0x7F, 0xBF, 0xBF, 0xBF, 0xBF, 0x9F, 0xBF, 0x8F, 0xF4, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80); + + /* + * Tables for fast handling of four special First Bytes(E0,ED,F0,F4), after + * which the Second Byte are not 80~BF. It contains "range index adjustment". + * +------------+---------------+------------------+----------------+ + * | First Byte | original range| range adjustment | adjusted range | + * +------------+---------------+------------------+----------------+ + * | E0 | 2 | 2 | 4 | + * +------------+---------------+------------------+----------------+ + * | ED | 2 | 3 | 5 | + * +------------+---------------+------------------+----------------+ + * | F0 | 3 | 3 | 6 | + * +------------+---------------+------------------+----------------+ + * | F4 | 4 | 4 | 8 | + * +------------+---------------+------------------+----------------+ + */ + + /* df_ee_table[1] -> E0, df_ee_table[14] -> ED as ED - E0 = 13 */ + // The values represent the adjustment in the Range Index table for a correct + // index. + const __m128i df_ee_table = + _mm_setr_epi8(0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0); + + /* ef_fe_table[1] -> F0, ef_fe_table[5] -> F4, F4 - F0 = 4 */ + // The values represent the adjustment in the Range Index table for a correct + // index. + const __m128i ef_fe_table = + _mm_setr_epi8(0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + __m128i prev_input = _mm_set1_epi8(0); + __m128i prev_first_len = _mm_set1_epi8(0); + __m128i error = _mm_set1_epi8(0); + while (end - data >= 16) { + const __m128i input = + _mm_loadu_si128((const __m128i*)(data)); + + /* high_nibbles = input >> 4 */ + const __m128i high_nibbles = + _mm_and_si128(_mm_srli_epi16(input, 4), _mm_set1_epi8(0x0F)); + + /* first_len = legal character length minus 1 */ + /* 0 for 00~7F, 1 for C0~DF, 2 for E0~EF, 3 for F0~FF */ + /* first_len = first_len_table[high_nibbles] */ + __m128i first_len = _mm_shuffle_epi8(first_len_table, high_nibbles); + + /* First Byte: set range index to 8 for bytes within 0xC0 ~ 0xFF */ + /* range = first_range_table[high_nibbles] */ + __m128i range = _mm_shuffle_epi8(first_range_table, high_nibbles); + + /* Second Byte: set range index to first_len */ + /* 0 for 00~7F, 1 for C0~DF, 2 for E0~EF, 3 for F0~FF */ + /* range |= (first_len, prev_first_len) << 1 byte */ + range = _mm_or_si128(range, _mm_alignr_epi8(first_len, prev_first_len, 15)); + + /* Third Byte: set range index to saturate_sub(first_len, 1) */ + /* 0 for 00~7F, 0 for C0~DF, 1 for E0~EF, 2 for F0~FF */ + __m128i tmp1; + __m128i tmp2; + /* tmp1 = saturate_sub(first_len, 1) */ + tmp1 = _mm_subs_epu8(first_len, _mm_set1_epi8(1)); + /* tmp2 = saturate_sub(prev_first_len, 1) */ + tmp2 = _mm_subs_epu8(prev_first_len, _mm_set1_epi8(1)); + /* range |= (tmp1, tmp2) << 2 bytes */ + range = _mm_or_si128(range, _mm_alignr_epi8(tmp1, tmp2, 14)); + + /* Fourth Byte: set range index to saturate_sub(first_len, 2) */ + /* 0 for 00~7F, 0 for C0~DF, 0 for E0~EF, 1 for F0~FF */ + /* tmp1 = saturate_sub(first_len, 2) */ + tmp1 = _mm_subs_epu8(first_len, _mm_set1_epi8(2)); + /* tmp2 = saturate_sub(prev_first_len, 2) */ + tmp2 = _mm_subs_epu8(prev_first_len, _mm_set1_epi8(2)); + /* range |= (tmp1, tmp2) << 3 bytes */ + range = _mm_or_si128(range, _mm_alignr_epi8(tmp1, tmp2, 13)); + + /* + * Now we have below range indices calculated + * Correct cases: + * - 8 for C0~FF + * - 3 for 1st byte after F0~FF + * - 2 for 1st byte after E0~EF or 2nd byte after F0~FF + * - 1 for 1st byte after C0~DF or 2nd byte after E0~EF or + * 3rd byte after F0~FF + * - 0 for others + * Error cases: + * >9 for non ascii First Byte overlapping + * E.g., F1 80 C2 90 --> 8 3 10 2, where 10 indicates error + */ + + /* Adjust Second Byte range for special First Bytes(E0,ED,F0,F4) */ + /* Overlaps lead to index 9~15, which are illegal in range table */ + __m128i shift1; + __m128i pos; + __m128i range2; + /* shift1 = (input, prev_input) << 1 byte */ + shift1 = _mm_alignr_epi8(input, prev_input, 15); + pos = _mm_sub_epi8(shift1, _mm_set1_epi8(0xEF)); + /* + * shift1: | EF F0 ... FE | FF 00 ... ... DE | DF E0 ... EE | + * pos: | 0 1 15 | 16 17 239| 240 241 255| + * pos-240: | 0 0 0 | 0 0 0 | 0 1 15 | + * pos+112: | 112 113 127| >= 128 | >= 128 | + */ + tmp1 = _mm_subs_epu8(pos, _mm_set1_epi8(-16)); + range2 = _mm_shuffle_epi8(df_ee_table, tmp1); + tmp2 = _mm_adds_epu8(pos, _mm_set1_epi8(112)); + range2 = _mm_add_epi8(range2, _mm_shuffle_epi8(ef_fe_table, tmp2)); + + range = _mm_add_epi8(range, range2); + + /* Load min and max values per calculated range index */ + __m128i min_range = _mm_shuffle_epi8(range_min_table, range); + __m128i max_range = _mm_shuffle_epi8(range_max_table, range); + + /* Check value range */ + if (return_position) { + error = _mm_cmplt_epi8(input, min_range); + error = _mm_or_si128(error, _mm_cmpgt_epi8(input, max_range)); + /* 5% performance drop from this conditional branch */ + if (!_mm_testz_si128(error, error)) { + break; + } + } else { + error = _mm_or_si128(error, _mm_cmplt_epi8(input, min_range)); + error = _mm_or_si128(error, _mm_cmpgt_epi8(input, max_range)); + } + + prev_input = input; + prev_first_len = first_len; + + data += 16; + } + /* If we got to the end, we don't need to skip any bytes backwards */ + if (return_position && (data - (end - len)) == 0) { + return utf8_range_ValidateUTF8Naive(data, end, return_position); + } + /* Find previous codepoint (not 80~BF) */ + data -= utf8_range_CodepointSkipBackwards(_mm_extract_epi32(prev_input, 3)); + if (return_position) { + return (data - (end - len)) + + utf8_range_ValidateUTF8Naive(data, end, return_position); + } + /* Test if there was any error */ + if (!_mm_testz_si128(error, error)) { + return 0; + } + /* Check the tail */ + return utf8_range_ValidateUTF8Naive(data, end, return_position); +#endif +} + +int utf8_range_IsValid(const char* data, size_t len) { + return utf8_range_Validate(data, len, /*return_position=*/0) != 0; +} + +size_t utf8_range_ValidPrefix(const char* data, size_t len) { + return utf8_range_Validate(data, len, /*return_position=*/1); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h new file mode 100755 index 0000000..d7c2326 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h @@ -0,0 +1,22 @@ +#ifndef THIRD_PARTY_UTF8_RANGE_UTF8_RANGE_H_ +#define THIRD_PARTY_UTF8_RANGE_UTF8_RANGE_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Returns 1 if the sequence of characters is a valid UTF-8 sequence, otherwise +// 0. +int utf8_range_IsValid(const char* data, size_t len); + +// Returns the length in bytes of the prefix of str that is all +// structurally valid UTF-8. +size_t utf8_range_ValidPrefix(const char* data, size_t len); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_UTF8_RANGE_UTF8_RANGE_H_ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/wrap_memcpy.c b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/wrap_memcpy.c new file mode 100755 index 0000000..2073d14 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/ext/google/protobuf_c/wrap_memcpy.c @@ -0,0 +1,29 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#include + +// On x86-64 Linux with glibc, we link against the 2.2.5 version of memcpy so +// that we avoid depending on the 2.14 version of the symbol. This way, +// distributions that are using pre-2.14 versions of glibc can successfully use +// the gem we distribute +// (https://github.com/protocolbuffers/protobuf/issues/2783). +// +// This wrapper is enabled by passing the linker flags -Wl,-wrap,memcpy in +// extconf.rb. +#ifdef __linux__ +#if defined(__x86_64__) && defined(__GNU_LIBRARY__) +__asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); +void *__wrap_memcpy(void *dest, const void *src, size_t n) { + return memcpy(dest, src, n); +} +#else +void *__wrap_memcpy(void *dest, const void *src, size_t n) { + return memmove(dest, src, n); +} +#endif +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.0/protobuf_c.so b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.0/protobuf_c.so new file mode 100755 index 0000000..e40b8c1 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.0/protobuf_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.1/protobuf_c.so b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.1/protobuf_c.so new file mode 100755 index 0000000..abec855 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.1/protobuf_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.2/protobuf_c.so b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.2/protobuf_c.so new file mode 100755 index 0000000..686744b Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.2/protobuf_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.3/protobuf_c.so b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.3/protobuf_c.so new file mode 100755 index 0000000..b6300f7 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/3.3/protobuf_c.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf.rb new file mode 100755 index 0000000..fdfa9b6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf.rb @@ -0,0 +1,61 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2008 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +# require mixins before we hook them into the java & c code +require 'google/protobuf/message_exts' +require 'google/protobuf/internal/object_cache' + +# We define these before requiring the platform-specific modules. +# That way the module init can grab references to these. +module Google + module Protobuf + class Error < StandardError; end + class ParseError < Error; end + class TypeError < ::TypeError; end + + PREFER_FFI = case ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION'] + when nil, "", /^native$/i + false + when /^ffi$/i + true + else + warn "Unexpected value `#{ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION']}` for environment variable `PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION`. Should be either \"FFI\", \"NATIVE\"." + false + end + + def self.encode(msg, options = {}) + msg.to_proto(options) + end + + def self.encode_json(msg, options = {}) + msg.to_json(options) + end + + def self.decode(klass, proto, options = {}) + klass.decode(proto, options) + end + + def self.decode_json(klass, json, options = {}) + klass.decode_json(json, options) + end + + IMPLEMENTATION = if PREFER_FFI + begin + require 'google/protobuf_ffi' + :FFI + rescue LoadError + warn "Caught exception `#{$!.message}` while loading FFI implementation of google/protobuf." + warn "Falling back to native implementation." + require 'google/protobuf_native' + :NATIVE + end + else + require 'google/protobuf_native' + :NATIVE + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/any_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/any_pb.rb new file mode 100755 index 0000000..760712e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/any_pb.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/any.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x19google/protobuf/any.proto\x12\x0fgoogle.protobuf\"&\n\x03\x41ny\x12\x10\n\x08type_url\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\x42v\n\x13\x63om.google.protobufB\x08\x41nyProtoP\x01Z,google.golang.org/protobuf/types/known/anypb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + Any = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Any").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/api_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/api_pb.rb new file mode 100755 index 0000000..e640a22 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/api_pb.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/api.proto + +require 'google/protobuf' + +require 'google/protobuf/source_context_pb' +require 'google/protobuf/type_pb' + + +descriptor_data = "\n\x19google/protobuf/api.proto\x12\x0fgoogle.protobuf\x1a$google/protobuf/source_context.proto\x1a\x1agoogle/protobuf/type.proto\"\x81\x02\n\x03\x41pi\x12\x0c\n\x04name\x18\x01 \x01(\t\x12(\n\x07methods\x18\x02 \x03(\x0b\x32\x17.google.protobuf.Method\x12(\n\x07options\x18\x03 \x03(\x0b\x32\x17.google.protobuf.Option\x12\x0f\n\x07version\x18\x04 \x01(\t\x12\x36\n\x0esource_context\x18\x05 \x01(\x0b\x32\x1e.google.protobuf.SourceContext\x12&\n\x06mixins\x18\x06 \x03(\x0b\x32\x16.google.protobuf.Mixin\x12\'\n\x06syntax\x18\x07 \x01(\x0e\x32\x17.google.protobuf.Syntax\"\xd5\x01\n\x06Method\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x18\n\x10request_type_url\x18\x02 \x01(\t\x12\x19\n\x11request_streaming\x18\x03 \x01(\x08\x12\x19\n\x11response_type_url\x18\x04 \x01(\t\x12\x1a\n\x12response_streaming\x18\x05 \x01(\x08\x12(\n\x07options\x18\x06 \x03(\x0b\x32\x17.google.protobuf.Option\x12\'\n\x06syntax\x18\x07 \x01(\x0e\x32\x17.google.protobuf.Syntax\"#\n\x05Mixin\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04root\x18\x02 \x01(\tBv\n\x13\x63om.google.protobufB\x08\x41piProtoP\x01Z,google.golang.org/protobuf/types/known/apipb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + Api = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Api").msgclass + Method = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Method").msgclass + Mixin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Mixin").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/descriptor_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/descriptor_pb.rb new file mode 100755 index 0000000..70bd72a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/descriptor_pb.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +require 'google/protobuf' + + +descriptor_data = "\n google/protobuf/descriptor.proto\x12\x0fgoogle.protobuf\"G\n\x11\x46ileDescriptorSet\x12\x32\n\x04\x66ile\x18\x01 \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\"\x86\x04\n\x13\x46ileDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07package\x18\x02 \x01(\t\x12\x12\n\ndependency\x18\x03 \x03(\t\x12\x19\n\x11public_dependency\x18\n \x03(\x05\x12\x17\n\x0fweak_dependency\x18\x0b \x03(\x05\x12\x36\n\x0cmessage_type\x18\x04 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x05 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12\x38\n\x07service\x18\x06 \x03(\x0b\x32\'.google.protobuf.ServiceDescriptorProto\x12\x38\n\textension\x18\x07 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12-\n\x07options\x18\x08 \x01(\x0b\x32\x1c.google.protobuf.FileOptions\x12\x39\n\x10source_code_info\x18\t \x01(\x0b\x32\x1f.google.protobuf.SourceCodeInfo\x12\x0e\n\x06syntax\x18\x0c \x01(\t\x12)\n\x07\x65\x64ition\x18\x0e \x01(\x0e\x32\x18.google.protobuf.Edition\"\xa9\x05\n\x0f\x44\x65scriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x34\n\x05\x66ield\x18\x02 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x38\n\textension\x18\x06 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x35\n\x0bnested_type\x18\x03 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x04 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12H\n\x0f\x65xtension_range\x18\x05 \x03(\x0b\x32/.google.protobuf.DescriptorProto.ExtensionRange\x12\x39\n\noneof_decl\x18\x08 \x03(\x0b\x32%.google.protobuf.OneofDescriptorProto\x12\x30\n\x07options\x18\x07 \x01(\x0b\x32\x1f.google.protobuf.MessageOptions\x12\x46\n\x0ereserved_range\x18\t \x03(\x0b\x32..google.protobuf.DescriptorProto.ReservedRange\x12\x15\n\rreserved_name\x18\n \x03(\t\x1a\x65\n\x0e\x45xtensionRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\x12\x37\n\x07options\x18\x03 \x01(\x0b\x32&.google.protobuf.ExtensionRangeOptions\x1a+\n\rReservedRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\"\xe5\x03\n\x15\x45xtensionRangeOptions\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\x12L\n\x0b\x64\x65\x63laration\x18\x02 \x03(\x0b\x32\x32.google.protobuf.ExtensionRangeOptions.DeclarationB\x03\x88\x01\x02\x12-\n\x08\x66\x65\x61tures\x18\x32 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12_\n\x0cverification\x18\x03 \x01(\x0e\x32\x38.google.protobuf.ExtensionRangeOptions.VerificationState:\nUNVERIFIEDB\x03\x88\x01\x02\x1ah\n\x0b\x44\x65\x63laration\x12\x0e\n\x06number\x18\x01 \x01(\x05\x12\x11\n\tfull_name\x18\x02 \x01(\t\x12\x0c\n\x04type\x18\x03 \x01(\t\x12\x10\n\x08reserved\x18\x05 \x01(\x08\x12\x10\n\x08repeated\x18\x06 \x01(\x08J\x04\x08\x04\x10\x05\"4\n\x11VerificationState\x12\x0f\n\x0b\x44\x45\x43LARATION\x10\x00\x12\x0e\n\nUNVERIFIED\x10\x01*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xd5\x05\n\x14\x46ieldDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x03 \x01(\x05\x12:\n\x05label\x18\x04 \x01(\x0e\x32+.google.protobuf.FieldDescriptorProto.Label\x12\x38\n\x04type\x18\x05 \x01(\x0e\x32*.google.protobuf.FieldDescriptorProto.Type\x12\x11\n\ttype_name\x18\x06 \x01(\t\x12\x10\n\x08\x65xtendee\x18\x02 \x01(\t\x12\x15\n\rdefault_value\x18\x07 \x01(\t\x12\x13\n\x0boneof_index\x18\t \x01(\x05\x12\x11\n\tjson_name\x18\n \x01(\t\x12.\n\x07options\x18\x08 \x01(\x0b\x32\x1d.google.protobuf.FieldOptions\x12\x17\n\x0fproto3_optional\x18\x11 \x01(\x08\"\xb6\x02\n\x04Type\x12\x0f\n\x0bTYPE_DOUBLE\x10\x01\x12\x0e\n\nTYPE_FLOAT\x10\x02\x12\x0e\n\nTYPE_INT64\x10\x03\x12\x0f\n\x0bTYPE_UINT64\x10\x04\x12\x0e\n\nTYPE_INT32\x10\x05\x12\x10\n\x0cTYPE_FIXED64\x10\x06\x12\x10\n\x0cTYPE_FIXED32\x10\x07\x12\r\n\tTYPE_BOOL\x10\x08\x12\x0f\n\x0bTYPE_STRING\x10\t\x12\x0e\n\nTYPE_GROUP\x10\n\x12\x10\n\x0cTYPE_MESSAGE\x10\x0b\x12\x0e\n\nTYPE_BYTES\x10\x0c\x12\x0f\n\x0bTYPE_UINT32\x10\r\x12\r\n\tTYPE_ENUM\x10\x0e\x12\x11\n\rTYPE_SFIXED32\x10\x0f\x12\x11\n\rTYPE_SFIXED64\x10\x10\x12\x0f\n\x0bTYPE_SINT32\x10\x11\x12\x0f\n\x0bTYPE_SINT64\x10\x12\"C\n\x05Label\x12\x12\n\x0eLABEL_OPTIONAL\x10\x01\x12\x12\n\x0eLABEL_REPEATED\x10\x03\x12\x12\n\x0eLABEL_REQUIRED\x10\x02\"T\n\x14OneofDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12.\n\x07options\x18\x02 \x01(\x0b\x32\x1d.google.protobuf.OneofOptions\"\xa4\x02\n\x13\x45numDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x03(\x0b\x32).google.protobuf.EnumValueDescriptorProto\x12-\n\x07options\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.EnumOptions\x12N\n\x0ereserved_range\x18\x04 \x03(\x0b\x32\x36.google.protobuf.EnumDescriptorProto.EnumReservedRange\x12\x15\n\rreserved_name\x18\x05 \x03(\t\x1a/\n\x11\x45numReservedRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\"l\n\x18\x45numValueDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x02 \x01(\x05\x12\x32\n\x07options\x18\x03 \x01(\x0b\x32!.google.protobuf.EnumValueOptions\"\x90\x01\n\x16ServiceDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x36\n\x06method\x18\x02 \x03(\x0b\x32&.google.protobuf.MethodDescriptorProto\x12\x30\n\x07options\x18\x03 \x01(\x0b\x32\x1f.google.protobuf.ServiceOptions\"\xc1\x01\n\x15MethodDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\ninput_type\x18\x02 \x01(\t\x12\x13\n\x0boutput_type\x18\x03 \x01(\t\x12/\n\x07options\x18\x04 \x01(\x0b\x32\x1e.google.protobuf.MethodOptions\x12\x1f\n\x10\x63lient_streaming\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1f\n\x10server_streaming\x18\x06 \x01(\x08:\x05\x66\x61lse\"\xcb\x06\n\x0b\x46ileOptions\x12\x14\n\x0cjava_package\x18\x01 \x01(\t\x12\x1c\n\x14java_outer_classname\x18\x08 \x01(\t\x12\"\n\x13java_multiple_files\x18\n \x01(\x08:\x05\x66\x61lse\x12)\n\x1djava_generate_equals_and_hash\x18\x14 \x01(\x08\x42\x02\x18\x01\x12%\n\x16java_string_check_utf8\x18\x1b \x01(\x08:\x05\x66\x61lse\x12\x46\n\x0coptimize_for\x18\t \x01(\x0e\x32).google.protobuf.FileOptions.OptimizeMode:\x05SPEED\x12\x12\n\ngo_package\x18\x0b \x01(\t\x12\"\n\x13\x63\x63_generic_services\x18\x10 \x01(\x08:\x05\x66\x61lse\x12$\n\x15java_generic_services\x18\x11 \x01(\x08:\x05\x66\x61lse\x12\"\n\x13py_generic_services\x18\x12 \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x17 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x10\x63\x63_enable_arenas\x18\x1f \x01(\x08:\x04true\x12\x19\n\x11objc_class_prefix\x18$ \x01(\t\x12\x18\n\x10\x63sharp_namespace\x18% \x01(\t\x12\x14\n\x0cswift_prefix\x18\' \x01(\t\x12\x18\n\x10php_class_prefix\x18( \x01(\t\x12\x15\n\rphp_namespace\x18) \x01(\t\x12\x1e\n\x16php_metadata_namespace\x18, \x01(\t\x12\x14\n\x0cruby_package\x18- \x01(\t\x12-\n\x08\x66\x65\x61tures\x18\x32 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\":\n\x0cOptimizeMode\x12\t\n\x05SPEED\x10\x01\x12\r\n\tCODE_SIZE\x10\x02\x12\x10\n\x0cLITE_RUNTIME\x10\x03*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08*\x10+J\x04\x08&\x10\'R\x14php_generic_services\"\xe7\x02\n\x0eMessageOptions\x12&\n\x17message_set_wire_format\x18\x01 \x01(\x08:\x05\x66\x61lse\x12.\n\x1fno_standard_descriptor_accessor\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x11\n\tmap_entry\x18\x07 \x01(\x08\x12\x32\n&deprecated_legacy_json_field_conflicts\x18\x0b \x01(\x08\x42\x02\x18\x01\x12-\n\x08\x66\x65\x61tures\x18\x0c \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x04\x10\x05J\x04\x08\x05\x10\x06J\x04\x08\x06\x10\x07J\x04\x08\x08\x10\tJ\x04\x08\t\x10\n\"\xa3\x0b\n\x0c\x46ieldOptions\x12:\n\x05\x63type\x18\x01 \x01(\x0e\x32#.google.protobuf.FieldOptions.CType:\x06STRING\x12\x0e\n\x06packed\x18\x02 \x01(\x08\x12?\n\x06jstype\x18\x06 \x01(\x0e\x32$.google.protobuf.FieldOptions.JSType:\tJS_NORMAL\x12\x13\n\x04lazy\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x0funverified_lazy\x18\x0f \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x13\n\x04weak\x18\n \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0c\x64\x65\x62ug_redact\x18\x10 \x01(\x08:\x05\x66\x61lse\x12@\n\tretention\x18\x11 \x01(\x0e\x32-.google.protobuf.FieldOptions.OptionRetention\x12?\n\x07targets\x18\x13 \x03(\x0e\x32..google.protobuf.FieldOptions.OptionTargetType\x12\x46\n\x10\x65\x64ition_defaults\x18\x14 \x03(\x0b\x32,.google.protobuf.FieldOptions.EditionDefault\x12-\n\x08\x66\x65\x61tures\x18\x15 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x45\n\x0f\x66\x65\x61ture_support\x18\x16 \x01(\x0b\x32,.google.protobuf.FieldOptions.FeatureSupport\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\x1aJ\n\x0e\x45\x64itionDefault\x12)\n\x07\x65\x64ition\x18\x03 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\r\n\x05value\x18\x02 \x01(\t\x1a\xcc\x01\n\x0e\x46\x65\x61tureSupport\x12\x34\n\x12\x65\x64ition_introduced\x18\x01 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x34\n\x12\x65\x64ition_deprecated\x18\x02 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x1b\n\x13\x64\x65precation_warning\x18\x03 \x01(\t\x12\x31\n\x0f\x65\x64ition_removed\x18\x04 \x01(\x0e\x32\x18.google.protobuf.Edition\"/\n\x05\x43Type\x12\n\n\x06STRING\x10\x00\x12\x08\n\x04\x43ORD\x10\x01\x12\x10\n\x0cSTRING_PIECE\x10\x02\"5\n\x06JSType\x12\r\n\tJS_NORMAL\x10\x00\x12\r\n\tJS_STRING\x10\x01\x12\r\n\tJS_NUMBER\x10\x02\"U\n\x0fOptionRetention\x12\x15\n\x11RETENTION_UNKNOWN\x10\x00\x12\x15\n\x11RETENTION_RUNTIME\x10\x01\x12\x14\n\x10RETENTION_SOURCE\x10\x02\"\x8c\x02\n\x10OptionTargetType\x12\x17\n\x13TARGET_TYPE_UNKNOWN\x10\x00\x12\x14\n\x10TARGET_TYPE_FILE\x10\x01\x12\x1f\n\x1bTARGET_TYPE_EXTENSION_RANGE\x10\x02\x12\x17\n\x13TARGET_TYPE_MESSAGE\x10\x03\x12\x15\n\x11TARGET_TYPE_FIELD\x10\x04\x12\x15\n\x11TARGET_TYPE_ONEOF\x10\x05\x12\x14\n\x10TARGET_TYPE_ENUM\x10\x06\x12\x1a\n\x16TARGET_TYPE_ENUM_ENTRY\x10\x07\x12\x17\n\x13TARGET_TYPE_SERVICE\x10\x08\x12\x16\n\x12TARGET_TYPE_METHOD\x10\t*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x04\x10\x05J\x04\x08\x12\x10\x13\"\x8d\x01\n\x0cOneofOptions\x12-\n\x08\x66\x65\x61tures\x18\x01 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xf6\x01\n\x0b\x45numOptions\x12\x13\n\x0b\x61llow_alias\x18\x02 \x01(\x08\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x32\n&deprecated_legacy_json_field_conflicts\x18\x06 \x01(\x08\x42\x02\x18\x01\x12-\n\x08\x66\x65\x61tures\x18\x07 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x05\x10\x06\"\x90\x02\n\x10\x45numValueOptions\x12\x19\n\ndeprecated\x18\x01 \x01(\x08:\x05\x66\x61lse\x12-\n\x08\x66\x65\x61tures\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x1b\n\x0c\x64\x65\x62ug_redact\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x45\n\x0f\x66\x65\x61ture_support\x18\x04 \x01(\x0b\x32,.google.protobuf.FieldOptions.FeatureSupport\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xaa\x01\n\x0eServiceOptions\x12-\n\x08\x66\x65\x61tures\x18\" \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x19\n\ndeprecated\x18! \x01(\x08:\x05\x66\x61lse\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xdc\x02\n\rMethodOptions\x12\x19\n\ndeprecated\x18! \x01(\x08:\x05\x66\x61lse\x12_\n\x11idempotency_level\x18\" \x01(\x0e\x32/.google.protobuf.MethodOptions.IdempotencyLevel:\x13IDEMPOTENCY_UNKNOWN\x12-\n\x08\x66\x65\x61tures\x18# \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\"P\n\x10IdempotencyLevel\x12\x17\n\x13IDEMPOTENCY_UNKNOWN\x10\x00\x12\x13\n\x0fNO_SIDE_EFFECTS\x10\x01\x12\x0e\n\nIDEMPOTENT\x10\x02*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\x9e\x02\n\x13UninterpretedOption\x12;\n\x04name\x18\x02 \x03(\x0b\x32-.google.protobuf.UninterpretedOption.NamePart\x12\x18\n\x10identifier_value\x18\x03 \x01(\t\x12\x1a\n\x12positive_int_value\x18\x04 \x01(\x04\x12\x1a\n\x12negative_int_value\x18\x05 \x01(\x03\x12\x14\n\x0c\x64ouble_value\x18\x06 \x01(\x01\x12\x14\n\x0cstring_value\x18\x07 \x01(\x0c\x12\x17\n\x0f\x61ggregate_value\x18\x08 \x01(\t\x1a\x33\n\x08NamePart\x12\x11\n\tname_part\x18\x01 \x02(\t\x12\x14\n\x0cis_extension\x18\x02 \x02(\x08\"\xc9\t\n\nFeatureSet\x12\x82\x01\n\x0e\x66ield_presence\x18\x01 \x01(\x0e\x32).google.protobuf.FeatureSet.FieldPresenceB?\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\r\x12\x08\x45XPLICIT\x18\xe6\x07\xa2\x01\r\x12\x08IMPLICIT\x18\xe7\x07\xa2\x01\r\x12\x08\x45XPLICIT\x18\xe8\x07\xb2\x01\x03\x08\xe8\x07\x12\x62\n\tenum_type\x18\x02 \x01(\x0e\x32$.google.protobuf.FeatureSet.EnumTypeB)\x88\x01\x01\x98\x01\x06\x98\x01\x01\xa2\x01\x0b\x12\x06\x43LOSED\x18\xe6\x07\xa2\x01\t\x12\x04OPEN\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\x12\x81\x01\n\x17repeated_field_encoding\x18\x03 \x01(\x0e\x32\x31.google.protobuf.FeatureSet.RepeatedFieldEncodingB-\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\r\x12\x08\x45XPANDED\x18\xe6\x07\xa2\x01\x0b\x12\x06PACKED\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\x12n\n\x0futf8_validation\x18\x04 \x01(\x0e\x32*.google.protobuf.FeatureSet.Utf8ValidationB)\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\t\x12\x04NONE\x18\xe6\x07\xa2\x01\x0b\x12\x06VERIFY\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\x12m\n\x10message_encoding\x18\x05 \x01(\x0e\x32+.google.protobuf.FeatureSet.MessageEncodingB&\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\x14\x12\x0fLENGTH_PREFIXED\x18\xe6\x07\xb2\x01\x03\x08\xe8\x07\x12v\n\x0bjson_format\x18\x06 \x01(\x0e\x32&.google.protobuf.FeatureSet.JsonFormatB9\x88\x01\x01\x98\x01\x03\x98\x01\x06\x98\x01\x01\xa2\x01\x17\x12\x12LEGACY_BEST_EFFORT\x18\xe6\x07\xa2\x01\n\x12\x05\x41LLOW\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\"\\\n\rFieldPresence\x12\x1a\n\x16\x46IELD_PRESENCE_UNKNOWN\x10\x00\x12\x0c\n\x08\x45XPLICIT\x10\x01\x12\x0c\n\x08IMPLICIT\x10\x02\x12\x13\n\x0fLEGACY_REQUIRED\x10\x03\"7\n\x08\x45numType\x12\x15\n\x11\x45NUM_TYPE_UNKNOWN\x10\x00\x12\x08\n\x04OPEN\x10\x01\x12\n\n\x06\x43LOSED\x10\x02\"V\n\x15RepeatedFieldEncoding\x12#\n\x1fREPEATED_FIELD_ENCODING_UNKNOWN\x10\x00\x12\n\n\x06PACKED\x10\x01\x12\x0c\n\x08\x45XPANDED\x10\x02\"I\n\x0eUtf8Validation\x12\x1b\n\x17UTF8_VALIDATION_UNKNOWN\x10\x00\x12\n\n\x06VERIFY\x10\x02\x12\x08\n\x04NONE\x10\x03\"\x04\x08\x01\x10\x01\"S\n\x0fMessageEncoding\x12\x1c\n\x18MESSAGE_ENCODING_UNKNOWN\x10\x00\x12\x13\n\x0fLENGTH_PREFIXED\x10\x01\x12\r\n\tDELIMITED\x10\x02\"H\n\nJsonFormat\x12\x17\n\x13JSON_FORMAT_UNKNOWN\x10\x00\x12\t\n\x05\x41LLOW\x10\x01\x12\x16\n\x12LEGACY_BEST_EFFORT\x10\x02*\x06\x08\xe8\x07\x10\x8bN*\x06\x08\x8bN\x10\x90N*\x06\x08\x90N\x10\x91NJ\x06\x08\xe7\x07\x10\xe8\x07\"\x98\x03\n\x12\x46\x65\x61tureSetDefaults\x12N\n\x08\x64\x65\x66\x61ults\x18\x01 \x03(\x0b\x32<.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault\x12\x31\n\x0fminimum_edition\x18\x04 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x31\n\x0fmaximum_edition\x18\x05 \x01(\x0e\x32\x18.google.protobuf.Edition\x1a\xcb\x01\n\x18\x46\x65\x61tureSetEditionDefault\x12)\n\x07\x65\x64ition\x18\x03 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x39\n\x14overridable_features\x18\x04 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x33\n\x0e\x66ixed_features\x18\x05 \x01(\x0b\x32\x1b.google.protobuf.FeatureSetJ\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03R\x08\x66\x65\x61tures\"\xd5\x01\n\x0eSourceCodeInfo\x12:\n\x08location\x18\x01 \x03(\x0b\x32(.google.protobuf.SourceCodeInfo.Location\x1a\x86\x01\n\x08Location\x12\x10\n\x04path\x18\x01 \x03(\x05\x42\x02\x10\x01\x12\x10\n\x04span\x18\x02 \x03(\x05\x42\x02\x10\x01\x12\x18\n\x10leading_comments\x18\x03 \x01(\t\x12\x19\n\x11trailing_comments\x18\x04 \x01(\t\x12!\n\x19leading_detached_comments\x18\x06 \x03(\t\"\x9c\x02\n\x11GeneratedCodeInfo\x12\x41\n\nannotation\x18\x01 \x03(\x0b\x32-.google.protobuf.GeneratedCodeInfo.Annotation\x1a\xc3\x01\n\nAnnotation\x12\x10\n\x04path\x18\x01 \x03(\x05\x42\x02\x10\x01\x12\x13\n\x0bsource_file\x18\x02 \x01(\t\x12\r\n\x05\x62\x65gin\x18\x03 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x04 \x01(\x05\x12H\n\x08semantic\x18\x05 \x01(\x0e\x32\x36.google.protobuf.GeneratedCodeInfo.Annotation.Semantic\"(\n\x08Semantic\x12\x08\n\x04NONE\x10\x00\x12\x07\n\x03SET\x10\x01\x12\t\n\x05\x41LIAS\x10\x02*\xa7\x02\n\x07\x45\x64ition\x12\x13\n\x0f\x45\x44ITION_UNKNOWN\x10\x00\x12\x13\n\x0e\x45\x44ITION_LEGACY\x10\x84\x07\x12\x13\n\x0e\x45\x44ITION_PROTO2\x10\xe6\x07\x12\x13\n\x0e\x45\x44ITION_PROTO3\x10\xe7\x07\x12\x11\n\x0c\x45\x44ITION_2023\x10\xe8\x07\x12\x11\n\x0c\x45\x44ITION_2024\x10\xe9\x07\x12\x17\n\x13\x45\x44ITION_1_TEST_ONLY\x10\x01\x12\x17\n\x13\x45\x44ITION_2_TEST_ONLY\x10\x02\x12\x1d\n\x17\x45\x44ITION_99997_TEST_ONLY\x10\x9d\x8d\x06\x12\x1d\n\x17\x45\x44ITION_99998_TEST_ONLY\x10\x9e\x8d\x06\x12\x1d\n\x17\x45\x44ITION_99999_TEST_ONLY\x10\x9f\x8d\x06\x12\x13\n\x0b\x45\x44ITION_MAX\x10\xff\xff\xff\xff\x07\x42~\n\x13\x63om.google.protobufB\x10\x44\x65scriptorProtosH\x01Z-google.golang.org/protobuf/types/descriptorpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1aGoogle.Protobuf.Reflection" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + FileDescriptorSet = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileDescriptorSet").msgclass + FileDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileDescriptorProto").msgclass + DescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto").msgclass + DescriptorProto::ExtensionRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto.ExtensionRange").msgclass + DescriptorProto::ReservedRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto.ReservedRange").msgclass + ExtensionRangeOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ExtensionRangeOptions").msgclass + ExtensionRangeOptions::Declaration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ExtensionRangeOptions.Declaration").msgclass + ExtensionRangeOptions::VerificationState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ExtensionRangeOptions.VerificationState").enummodule + FieldDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto").msgclass + FieldDescriptorProto::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto.Type").enummodule + FieldDescriptorProto::Label = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto.Label").enummodule + OneofDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.OneofDescriptorProto").msgclass + EnumDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumDescriptorProto").msgclass + EnumDescriptorProto::EnumReservedRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumDescriptorProto.EnumReservedRange").msgclass + EnumValueDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValueDescriptorProto").msgclass + ServiceDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ServiceDescriptorProto").msgclass + MethodDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodDescriptorProto").msgclass + FileOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileOptions").msgclass + FileOptions::OptimizeMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileOptions.OptimizeMode").enummodule + MessageOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MessageOptions").msgclass + FieldOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions").msgclass + FieldOptions::EditionDefault = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.EditionDefault").msgclass + FieldOptions::FeatureSupport = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.FeatureSupport").msgclass + FieldOptions::CType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.CType").enummodule + FieldOptions::JSType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.JSType").enummodule + FieldOptions::OptionRetention = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.OptionRetention").enummodule + FieldOptions::OptionTargetType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.OptionTargetType").enummodule + OneofOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.OneofOptions").msgclass + EnumOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumOptions").msgclass + EnumValueOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValueOptions").msgclass + ServiceOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ServiceOptions").msgclass + MethodOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodOptions").msgclass + MethodOptions::IdempotencyLevel = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodOptions.IdempotencyLevel").enummodule + UninterpretedOption = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UninterpretedOption").msgclass + UninterpretedOption::NamePart = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UninterpretedOption.NamePart").msgclass + FeatureSet = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSet").msgclass + FeatureSet::FieldPresence = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSet.FieldPresence").enummodule + FeatureSet::EnumType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSet.EnumType").enummodule + FeatureSet::RepeatedFieldEncoding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSet.RepeatedFieldEncoding").enummodule + FeatureSet::Utf8Validation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSet.Utf8Validation").enummodule + FeatureSet::MessageEncoding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSet.MessageEncoding").enummodule + FeatureSet::JsonFormat = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSet.JsonFormat").enummodule + FeatureSetDefaults = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSetDefaults").msgclass + FeatureSetDefaults::FeatureSetEditionDefault = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault").msgclass + SourceCodeInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceCodeInfo").msgclass + SourceCodeInfo::Location = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceCodeInfo.Location").msgclass + GeneratedCodeInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.GeneratedCodeInfo").msgclass + GeneratedCodeInfo::Annotation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.GeneratedCodeInfo.Annotation").msgclass + GeneratedCodeInfo::Annotation::Semantic = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.GeneratedCodeInfo.Annotation.Semantic").enummodule + Edition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Edition").enummodule + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/duration_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/duration_pb.rb new file mode 100755 index 0000000..f5b9e91 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/duration_pb.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/duration.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x1egoogle/protobuf/duration.proto\x12\x0fgoogle.protobuf\"*\n\x08\x44uration\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\x12\r\n\x05nanos\x18\x02 \x01(\x05\x42\x83\x01\n\x13\x63om.google.protobufB\rDurationProtoP\x01Z1google.golang.org/protobuf/types/known/durationpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + Duration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Duration").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/empty_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/empty_pb.rb new file mode 100755 index 0000000..0ac1b52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/empty_pb.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/empty.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x1bgoogle/protobuf/empty.proto\x12\x0fgoogle.protobuf\"\x07\n\x05\x45mptyB}\n\x13\x63om.google.protobufB\nEmptyProtoP\x01Z.google.golang.org/protobuf/types/known/emptypb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + Empty = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Empty").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/descriptor.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/descriptor.rb new file mode 100755 index 0000000..1ccaf77 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/descriptor.rb @@ -0,0 +1,166 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + ## + # Message Descriptor - Descriptor for short. + class Descriptor + attr :descriptor_pool, :msg_class + include Enumerable + + # FFI Interface methods and setup + extend ::FFI::DataConverter + native_type ::FFI::Type::POINTER + + class << self + prepend Google::Protobuf::Internal::TypeSafety + include Google::Protobuf::Internal::PointerHelper + + # @param value [Descriptor] Descriptor to convert to an FFI native type + # @param _ [Object] Unused + def to_native(value, _ = nil) + msg_def_ptr = value.nil? ? nil : value.instance_variable_get(:@msg_def) + return ::FFI::Pointer::NULL if msg_def_ptr.nil? + raise "Underlying msg_def was null!" if msg_def_ptr.null? + msg_def_ptr + end + + ## + # @param msg_def [::FFI::Pointer] MsgDef pointer to be wrapped + # @param _ [Object] Unused + def from_native(msg_def, _ = nil) + return nil if msg_def.nil? or msg_def.null? + file_def = Google::Protobuf::FFI.get_message_file_def msg_def + descriptor_from_file_def(file_def, msg_def) + end + end + + def to_native + self.class.to_native(self) + end + + ## + # Great write up of this strategy: + # See https://blog.appsignal.com/2018/08/07/ruby-magic-changing-the-way-ruby-creates-objects.html + def self.new(*arguments, &block) + raise "Descriptor objects may not be created from Ruby." + end + + def to_s + inspect + end + + def inspect + "Descriptor - (not the message class) #{name}" + end + + def file_descriptor + @descriptor_pool.send(:get_file_descriptor, Google::Protobuf::FFI.get_message_file_def(@msg_def)) + end + + def name + @name ||= Google::Protobuf::FFI.get_message_fullname(self) + end + + def each_oneof &block + n = Google::Protobuf::FFI.oneof_count(self) + 0.upto(n-1) do |i| + yield(Google::Protobuf::FFI.get_oneof_by_index(self, i)) + end + nil + end + + def each &block + n = Google::Protobuf::FFI.field_count(self) + 0.upto(n-1) do |i| + yield(Google::Protobuf::FFI.get_field_by_index(self, i)) + end + nil + end + + def lookup(name) + Google::Protobuf::FFI.get_field_by_name(self, name, name.size) + end + + def lookup_oneof(name) + Google::Protobuf::FFI.get_oneof_by_name(self, name, name.size) + end + + def msgclass + @msg_class ||= build_message_class + end + + def options + @options ||= begin + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + temporary_arena = Google::Protobuf::FFI.create_arena + buffer = Google::Protobuf::FFI.message_options(self, size_ptr, temporary_arena) + opts = Google::Protobuf::MessageOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze) + opts.clear_features() + opts.freeze + end + end + + private + + extend Google::Protobuf::Internal::Convert + + def initialize(msg_def, descriptor_pool) + @msg_def = msg_def + @msg_class = nil + @descriptor_pool = descriptor_pool + end + + def self.private_constructor(msg_def, descriptor_pool) + instance = allocate + instance.send(:initialize, msg_def, descriptor_pool) + instance + end + + def wrapper? + if defined? @wrapper + @wrapper + else + @wrapper = case Google::Protobuf::FFI.get_well_known_type self + when :DoubleValue, :FloatValue, :Int64Value, :UInt64Value, :Int32Value, :UInt32Value, :StringValue, :BytesValue, :BoolValue + true + else + false + end + end + end + + def self.get_message(msg, descriptor, arena) + return nil if msg.nil? or msg.null? + message = OBJECT_CACHE.get(msg.address) + if message.nil? + message = descriptor.msgclass.send(:private_constructor, arena, msg: msg) + message.freeze if frozen? + end + message + end + + def pool + @descriptor_pool + end + end + + class FFI + # MessageDef + attach_function :new_message_from_def, :upb_Message_New, [Descriptor, Internal::Arena], :Message + attach_function :field_count, :upb_MessageDef_FieldCount, [Descriptor], :int + attach_function :get_message_file_def, :upb_MessageDef_File, [:pointer], :FileDef + attach_function :get_message_fullname, :upb_MessageDef_FullName, [Descriptor], :string + attach_function :get_mini_table, :upb_MessageDef_MiniTable, [Descriptor], MiniTable.ptr + attach_function :oneof_count, :upb_MessageDef_OneofCount, [Descriptor], :int + attach_function :message_options, :Descriptor_serialized_options, [Descriptor, :pointer, Internal::Arena], :pointer + attach_function :get_well_known_type, :upb_MessageDef_WellKnownType, [Descriptor], WellKnown + attach_function :find_msg_def_by_name, :upb_MessageDef_FindByNameWithSize, [Descriptor, :string, :size_t, :FieldDefPointer, :OneofDefPointer], :bool + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/descriptor_pool.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/descriptor_pool.rb new file mode 100755 index 0000000..4dc177d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/descriptor_pool.rb @@ -0,0 +1,77 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class FFI + # DefPool + attach_function :add_serialized_file, :upb_DefPool_AddFile, [:DefPool, :FileDescriptorProto, Status.by_ref], :FileDef + attach_function :free_descriptor_pool, :upb_DefPool_Free, [:DefPool], :void + attach_function :create_descriptor_pool,:upb_DefPool_New, [], :DefPool + attach_function :get_extension_registry,:upb_DefPool_ExtensionRegistry, [:DefPool], :ExtensionRegistry + attach_function :lookup_enum, :upb_DefPool_FindEnumByName, [:DefPool, :string], EnumDescriptor + attach_function :lookup_extension, :upb_DefPool_FindExtensionByName,[:DefPool, :string], FieldDescriptor + attach_function :lookup_msg, :upb_DefPool_FindMessageByName, [:DefPool, :string], Descriptor + attach_function :lookup_service, :upb_DefPool_FindServiceByName, [:DefPool, :string], ServiceDescriptor + + # FileDescriptorProto + attach_function :parse, :FileDescriptorProto_parse, [:binary_string, :size_t, Internal::Arena], :FileDescriptorProto + end + class DescriptorPool + attr :descriptor_pool + attr_accessor :descriptor_class_by_def + + def initialize + @descriptor_pool = ::FFI::AutoPointer.new(Google::Protobuf::FFI.create_descriptor_pool, Google::Protobuf::FFI.method(:free_descriptor_pool)) + @descriptor_class_by_def = {} + + # Should always be the last expression of the initializer to avoid + # leaking references to this object before construction is complete. + Google::Protobuf::OBJECT_CACHE.try_add @descriptor_pool.address, self + end + + def add_serialized_file(file_contents) + # Allocate memory sized to file_contents + memBuf = ::FFI::MemoryPointer.new(:char, file_contents.bytesize) + # Insert the data + memBuf.put_bytes(0, file_contents) + temporary_arena = Google::Protobuf::FFI.create_arena + file_descriptor_proto = Google::Protobuf::FFI.parse memBuf, file_contents.bytesize, temporary_arena + raise ArgumentError.new("Unable to parse FileDescriptorProto") if file_descriptor_proto.null? + + status = Google::Protobuf::FFI::Status.new + file_descriptor = Google::Protobuf::FFI.add_serialized_file @descriptor_pool, file_descriptor_proto, status + if file_descriptor.null? + raise TypeError.new("Unable to build file to DescriptorPool: #{Google::Protobuf::FFI.error_message(status)}") + else + @descriptor_class_by_def[file_descriptor.address] = FileDescriptor.new file_descriptor, self + end + end + + def lookup name + Google::Protobuf::FFI.lookup_msg(@descriptor_pool, name) || + Google::Protobuf::FFI.lookup_enum(@descriptor_pool, name) || + Google::Protobuf::FFI.lookup_extension(@descriptor_pool, name) || + Google::Protobuf::FFI.lookup_service(@descriptor_pool, name) + end + + def self.generated_pool + @@generated_pool ||= DescriptorPool.new + end + + private + + # Implementation details below are subject to breaking changes without + # warning and are intended for use only within the gem. + + def get_file_descriptor file_def + return nil if file_def.null? + @descriptor_class_by_def[file_def.address] ||= FileDescriptor.new(file_def, self) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/enum_descriptor.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/enum_descriptor.rb new file mode 100755 index 0000000..e7ce04d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/enum_descriptor.rb @@ -0,0 +1,173 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class EnumDescriptor + attr :descriptor_pool, :enum_def + include Enumerable + + # FFI Interface methods and setup + extend ::FFI::DataConverter + native_type ::FFI::Type::POINTER + + class << self + prepend Google::Protobuf::Internal::TypeSafety + include Google::Protobuf::Internal::PointerHelper + + # @param value [EnumDescriptor] EnumDescriptor to convert to an FFI native type + # @param _ [Object] Unused + def to_native(value, _) + value.instance_variable_get(:@enum_def) || ::FFI::Pointer::NULL + end + + ## + # @param enum_def [::FFI::Pointer] EnumDef pointer to be wrapped + # @param _ [Object] Unused + def from_native(enum_def, _) + return nil if enum_def.nil? or enum_def.null? + file_def = Google::Protobuf::FFI.get_message_file_def enum_def + descriptor_from_file_def(file_def, enum_def) + end + end + + def self.new(*arguments, &block) + raise "Descriptor objects may not be created from Ruby." + end + + def file_descriptor + @descriptor_pool.send(:get_file_descriptor, Google::Protobuf::FFI.get_enum_file_descriptor(self)) + end + + def name + Google::Protobuf::FFI.get_enum_fullname(self) + end + + def to_s + inspect + end + + def inspect + "#{self.class.name}: #{name}" + end + + def lookup_name(name) + self.class.send(:lookup_name, self, name) + end + + def lookup_value(number) + self.class.send(:lookup_value, self, number) + end + + def each &block + n = Google::Protobuf::FFI.enum_value_count(self) + 0.upto(n - 1) do |i| + enum_value = Google::Protobuf::FFI.enum_value_by_index(self, i) + yield(Google::Protobuf::FFI.enum_name(enum_value).to_sym, Google::Protobuf::FFI.enum_number(enum_value)) + end + nil + end + + def enummodule + if @module.nil? + @module = build_enum_module + end + @module + end + + def options + @options ||= begin + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + temporary_arena = Google::Protobuf::FFI.create_arena + buffer = Google::Protobuf::FFI.enum_options(self, size_ptr, temporary_arena) + opts = Google::Protobuf::EnumOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze) + opts.clear_features() + opts.freeze + end + end + + private + + def initialize(enum_def, descriptor_pool) + @descriptor_pool = descriptor_pool + @enum_def = enum_def + @module = nil + end + + def self.private_constructor(enum_def, descriptor_pool) + instance = allocate + instance.send(:initialize, enum_def, descriptor_pool) + instance + end + + def self.lookup_value(enum_def, number) + enum_value = Google::Protobuf::FFI.enum_value_by_number(enum_def, number) + if enum_value.null? + nil + else + Google::Protobuf::FFI.enum_name(enum_value).to_sym + end + end + + def self.lookup_name(enum_def, name) + enum_value = Google::Protobuf::FFI.enum_value_by_name(enum_def, name.to_s, name.size) + if enum_value.null? + nil + else + Google::Protobuf::FFI.enum_number(enum_value) + end + end + + def build_enum_module + descriptor = self + dynamic_module = Module.new do + @descriptor = descriptor + + class << self + attr_accessor :descriptor + end + + def self.lookup(number) + descriptor.lookup_value number + end + + def self.resolve(name) + descriptor.lookup_name name + end + end + + self.each do |name, value| + if name[0] < 'A' || name[0] > 'Z' + if name[0] >= 'a' and name[0] <= 'z' + name = name[0].upcase + name[1..-1] # auto capitalize + else + warn( + "Enum value '#{name}' does not start with an uppercase letter " + + "as is required for Ruby constants.") + next + end + end + dynamic_module.const_set(name.to_sym, value) + end + dynamic_module + end + end + + class FFI + # EnumDescriptor + attach_function :get_enum_file_descriptor, :upb_EnumDef_File, [EnumDescriptor], :FileDef + attach_function :enum_value_by_name, :upb_EnumDef_FindValueByNameWithSize,[EnumDescriptor, :string, :size_t], :EnumValueDef + attach_function :enum_value_by_number, :upb_EnumDef_FindValueByNumber, [EnumDescriptor, :int], :EnumValueDef + attach_function :get_enum_fullname, :upb_EnumDef_FullName, [EnumDescriptor], :string + attach_function :enum_options, :EnumDescriptor_serialized_options, [EnumDescriptor, :pointer, Internal::Arena], :pointer + attach_function :enum_value_by_index, :upb_EnumDef_Value, [EnumDescriptor, :int], :EnumValueDef + attach_function :enum_value_count, :upb_EnumDef_ValueCount, [EnumDescriptor], :int + attach_function :enum_name, :upb_EnumValueDef_Name, [:EnumValueDef], :string + attach_function :enum_number, :upb_EnumValueDef_Number, [:EnumValueDef], :int + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/ffi.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/ffi.rb new file mode 100755 index 0000000..2549fcb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/ffi.rb @@ -0,0 +1,210 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class FFI + extend ::FFI::Library + # Workaround for Bazel's use of symlinks + JRuby's __FILE__ and `caller` + # that resolves them. + if ENV['BAZEL'] == 'true' + ffi_lib ::FFI::Compiler::Loader.find 'protobuf_c_ffi', ENV['PWD'] + else + ffi_lib ::FFI::Compiler::Loader.find 'protobuf_c_ffi' + end + + ## Map + Upb_Map_Begin = -1 + + ## Encoding Status + Upb_Status_MaxMessage = 511 + Upb_Encode_Deterministic = 1 + Upb_Encode_SkipUnknown = 2 + + ## JSON Encoding options + # When set, emits 0/default values. TODO: proto3 only? + Upb_JsonEncode_EmitDefaults = 1 + # When set, use normal (snake_case) field names instead of JSON (camelCase) names. + Upb_JsonEncode_UseProtoNames = 2 + # When set, emits enums as their integer values instead of as their names. + Upb_JsonEncode_FormatEnumsAsIntegers = 4 + + ## JSON Decoding options + Upb_JsonDecode_IgnoreUnknown = 1 + + typedef :pointer, :Array + typedef :pointer, :DefPool + typedef :pointer, :EnumValueDef + typedef :pointer, :ExtensionRegistry + typedef :pointer, :FieldDefPointer + typedef :pointer, :FileDef + typedef :pointer, :FileDescriptorProto + typedef :pointer, :Map + typedef :pointer, :Message # Instances of a message + typedef :pointer, :OneofDefPointer + typedef :pointer, :binary_string + if ::FFI::Platform::ARCH == "aarch64" + typedef :u_int8_t, :uint8_t + typedef :u_int16_t, :uint16_t + typedef :u_int32_t, :uint32_t + typedef :u_int64_t, :uint64_t + end + + FieldType = enum( + :double, 1, + :float, + :int64, + :uint64, + :int32, + :fixed64, + :fixed32, + :bool, + :string, + :group, + :message, + :bytes, + :uint32, + :enum, + :sfixed32, + :sfixed64, + :sint32, + :sint64 + ) + + CType = enum( + :bool, 1, + :float, + :int32, + :uint32, + :enum, + :message, + :double, + :int64, + :uint64, + :string, + :bytes + ) + + Label = enum( + :optional, 1, + :required, + :repeated + ) + + # All the different kind of well known type messages. For simplicity of check, + # number wrappers and string wrappers are grouped together. Make sure the + # order and merber of these groups are not changed. + + WellKnown = enum( + :Unspecified, + :Any, + :FieldMask, + :Duration, + :Timestamp, + # number wrappers + :DoubleValue, + :FloatValue, + :Int64Value, + :UInt64Value, + :Int32Value, + :UInt32Value, + # string wrappers + :StringValue, + :BytesValue, + :BoolValue, + :Value, + :ListValue, + :Struct + ) + + DecodeStatus = enum( + :Ok, + :Malformed, # Wire format was corrupt + :OutOfMemory, # Arena alloc failed + :BadUtf8, # String field had bad UTF-8 + :MaxDepthExceeded, # Exceeded UPB_DECODE_MAXDEPTH + + # CheckRequired failed, but the parse otherwise succeeded. + :MissingRequired, + ) + + EncodeStatus = enum( + :Ok, + :OutOfMemory, # Arena alloc failed + :MaxDepthExceeded, # Exceeded UPB_DECODE_MAXDEPTH + + # CheckRequired failed, but the parse otherwise succeeded. + :MissingRequired, + ) + + class StringView < ::FFI::Struct + layout :data, :pointer, + :size, :size_t + end + + class MiniTable < ::FFI::Struct + layout :subs, :pointer, + :fields, :pointer, + :size, :uint16_t, + :field_count, :uint16_t, + :ext, :uint8_t, # upb_ExtMode, declared as uint8_t so sizeof(ext) == 1 + :dense_below, :uint8_t, + :table_mask, :uint8_t, + :required_count, :uint8_t # Required fields have the lowest hasbits. + # To statically initialize the tables of variable length, we need a flexible + # array member, and we need to compile in gnu99 mode (constant initialization + # of flexible array members is a GNU extension, not in C99 unfortunately. */ + # _upb_FastTable_Entry fasttable[]; + end + + class Status < ::FFI::Struct + layout :ok, :bool, + :msg, [:char, Upb_Status_MaxMessage] + + def initialize + super + FFI.clear self + end + end + + class MessageValue < ::FFI::Union + layout :bool_val, :bool, + :float_val, :float, + :double_val, :double, + :int32_val, :int32_t, + :int64_val, :int64_t, + :uint32_val, :uint32_t, + :uint64_val,:uint64_t, + :map_val, :pointer, + :msg_val, :pointer, + :array_val,:pointer, + :str_val, StringView + end + + Upb_Message_Begin = -1 + + class MutableMessageValue < ::FFI::Union + layout :map, :Map, + :msg, :Message, + :array, :Array + end + + # Status + attach_function :clear, :upb_Status_Clear, [Status.by_ref], :void + attach_function :error_message, :upb_Status_ErrorMessage, [Status.by_ref], :string + + # Generic + attach_function :memcmp, [:pointer, :pointer, :size_t], :int + attach_function :memcpy, [:pointer, :pointer, :size_t], :int + + # Alternatives to pre-processor macros + def self.decode_max_depth(i) + i << 16 + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/field_descriptor.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/field_descriptor.rb new file mode 100755 index 0000000..632692b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/field_descriptor.rb @@ -0,0 +1,330 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class FieldDescriptor + attr :field_def, :descriptor_pool + + include Google::Protobuf::Internal::Convert + + # FFI Interface methods and setup + extend ::FFI::DataConverter + native_type ::FFI::Type::POINTER + + class << self + prepend Google::Protobuf::Internal::TypeSafety + include Google::Protobuf::Internal::PointerHelper + + # @param value [FieldDescriptor] FieldDescriptor to convert to an FFI native type + # @param _ [Object] Unused + def to_native(value, _) + field_def_ptr = value.instance_variable_get(:@field_def) + warn "Underlying field_def was nil!" if field_def_ptr.nil? + raise "Underlying field_def was null!" if !field_def_ptr.nil? and field_def_ptr.null? + field_def_ptr + end + + ## + # @param field_def [::FFI::Pointer] FieldDef pointer to be wrapped + # @param _ [Object] Unused + def from_native(field_def, _ = nil) + return nil if field_def.nil? or field_def.null? + file_def = Google::Protobuf::FFI.file_def_by_raw_field_def(field_def) + descriptor_from_file_def(file_def, field_def) + end + end + + def self.new(*arguments, &block) + raise "Descriptor objects may not be created from Ruby." + end + + def to_s + inspect + end + + def inspect + "#{self.class.name}: #{name}" + end + + def name + @name ||= Google::Protobuf::FFI.get_full_name(self) + end + + def json_name + @json_name ||= Google::Protobuf::FFI.get_json_name(self) + end + + def number + @number ||= Google::Protobuf::FFI.get_number(self) + end + + def type + @type ||= Google::Protobuf::FFI.get_type(self) + end + + def label + @label ||= Google::Protobuf::FFI.get_label(self) + end + + def default + return nil if Google::Protobuf::FFI.is_sub_message(self) + if Google::Protobuf::FFI.is_repeated(self) + message_value = Google::Protobuf::FFI::MessageValue.new + else + message_value = Google::Protobuf::FFI.get_default(self) + end + enum_def = Google::Protobuf::FFI.get_subtype_as_enum(self) + if enum_def.null? + convert_upb_to_ruby message_value, c_type + else + convert_upb_to_ruby message_value, c_type, enum_def + end + end + + def submsg_name + if defined? @submsg_name + @submsg_name + else + @submsg_name = case c_type + when :enum + Google::Protobuf::FFI.get_enum_fullname Google::Protobuf::FFI.get_subtype_as_enum self + when :message + Google::Protobuf::FFI.get_message_fullname Google::Protobuf::FFI.get_subtype_as_message self + else + nil + end + end + end + + ## + # Tests if this field has been set on the argument message. + # + # @param msg [Google::Protobuf::Message] + # @return [Object] Value of the field on this message. + # @raise [TypeError] If the field is not defined on this message. + def get(msg) + if msg.class.descriptor == Google::Protobuf::FFI.get_containing_message_def(self) + msg.send :get_field, self + else + raise TypeError.new "get method called on wrong message type" + end + end + + def subtype + if defined? @subtype + @subtype + else + @subtype = case c_type + when :enum + Google::Protobuf::FFI.get_subtype_as_enum(self) + when :message + Google::Protobuf::FFI.get_subtype_as_message(self) + else + nil + end + end + end + + ## + # Tests if this field has been set on the argument message. + # + # @param msg [Google::Protobuf::Message] + # @return [Boolean] True iff message has this field set + # @raise [TypeError] If this field does not exist on the message + # @raise [ArgumentError] If this field does not track presence + def has?(msg) + if msg.class.descriptor != Google::Protobuf::FFI.get_containing_message_def(self) + raise TypeError.new "has method called on wrong message type" + end + unless has_presence? + raise ArgumentError.new "does not track presence" + end + + Google::Protobuf::FFI.get_message_has msg.instance_variable_get(:@msg), self + end + + ## + # Tests if this field tracks presence. + # + # @return [Boolean] True iff this field tracks presence + def has_presence? + @has_presence ||= Google::Protobuf::FFI.get_has_presence(self) + end + + ## + # Tests if this is a repeated field that uses packed encoding. + # + # @return [Boolean] True iff this field is packed + def is_packed? + @is_packed ||= Google::Protobuf::FFI.get_is_packed(self) + end + + # @param msg [Google::Protobuf::Message] + def clear(msg) + if msg.class.descriptor != Google::Protobuf::FFI.get_containing_message_def(self) + raise TypeError.new "clear method called on wrong message type" + end + Google::Protobuf::FFI.clear_message_field msg.instance_variable_get(:@msg), self + nil + end + + ## + # call-seq: + # FieldDescriptor.set(message, value) + # + # Sets the value corresponding to this field to the given value on the given + # message. Raises an exception if message is of the wrong type. Performs the + # ordinary type-checks for field setting. + # + # @param msg [Google::Protobuf::Message] + # @param value [Object] + def set(msg, value) + if msg.class.descriptor != Google::Protobuf::FFI.get_containing_message_def(self) + raise TypeError.new "set method called on wrong message type" + end + unless set_value_on_message value, msg.instance_variable_get(:@msg), msg.instance_variable_get(:@arena) + raise RuntimeError.new "allocation failed" + end + nil + end + + def map? + @map ||= Google::Protobuf::FFI.is_map self + end + + def repeated? + @repeated ||= Google::Protobuf::FFI.is_repeated self + end + + def sub_message? + @sub_message ||= Google::Protobuf::FFI.is_sub_message self + end + + def wrapper? + if defined? @wrapper + @wrapper + else + message_descriptor = Google::Protobuf::FFI.get_subtype_as_message(self) + @wrapper = message_descriptor.nil? ? false : message_descriptor.send(:wrapper?) + end + end + + def options + @options ||= begin + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + temporary_arena = Google::Protobuf::FFI.create_arena + buffer = Google::Protobuf::FFI.field_options(self, size_ptr, temporary_arena) + opts = Google::Protobuf::FieldOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze) + opts.clear_features() + opts.freeze + end + end + + private + + def initialize(field_def, descriptor_pool) + @field_def = field_def + @descriptor_pool = descriptor_pool + end + + def self.private_constructor(field_def, descriptor_pool) + instance = allocate + instance.send(:initialize, field_def, descriptor_pool) + instance + end + + # TODO Can this be added to the public API? + def real_containing_oneof + @real_containing_oneof ||= Google::Protobuf::FFI.real_containing_oneof self + end + + # Implementation details below are subject to breaking changes without + # warning and are intended for use only within the gem. + + ## + # Sets the field this FieldDescriptor represents to the given value on the given message. + # @param value [Object] Value to be set + # @param msg [::FFI::Pointer] Pointer the the upb_Message + # @param arena [Arena] Arena of the message that owns msg + def set_value_on_message(value, msg, arena, wrap: false) + message_to_alter = msg + field_def_to_set = self + if map? + raise TypeError.new "Expected map" unless value.is_a? Google::Protobuf::Map + message_descriptor = subtype + + key_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 1) + key_field_type = Google::Protobuf::FFI.get_type(key_field_def) + raise TypeError.new "Map key type does not match field's key type" unless key_field_type == value.send(:key_type) + + value_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 2) + value_field_type = Google::Protobuf::FFI.get_type(value_field_def) + raise TypeError.new "Map value type does not match field's value type" unless value_field_type == value.send(:value_type) + + raise TypeError.new "Map value type has wrong message/enum class" unless value_field_def.subtype == value.send(:descriptor) + + arena.fuse(value.send(:arena)) + message_value = Google::Protobuf::FFI::MessageValue.new + message_value[:map_val] = value.send(:map_ptr) + elsif repeated? + raise TypeError.new "Expected repeated field array" unless value.is_a? RepeatedField + raise TypeError.new "Repeated field array has wrong message/enum class" unless value.send(:type) == type + arena.fuse(value.send(:arena)) + message_value = Google::Protobuf::FFI::MessageValue.new + message_value[:array_val] = value.send(:array) + else + if value.nil? and (sub_message? or !real_containing_oneof.nil?) + Google::Protobuf::FFI.clear_message_field message_to_alter, field_def_to_set + return true + end + if wrap + value_field_def = Google::Protobuf::FFI.get_field_by_number subtype, 1 + type_for_conversion = Google::Protobuf::FFI.get_c_type(value_field_def) + raise RuntimeError.new "Not expecting to get a msg or enum when unwrapping" if [:enum, :message].include? type_for_conversion + message_value = convert_ruby_to_upb(value, arena, type_for_conversion, nil) + message_to_alter = Google::Protobuf::FFI.get_mutable_message(msg, self, arena)[:msg] + field_def_to_set = value_field_def + else + message_value = convert_ruby_to_upb(value, arena, c_type, subtype) + end + end + Google::Protobuf::FFI.set_message_field message_to_alter, field_def_to_set, message_value, arena + end + + def c_type + @c_type ||= Google::Protobuf::FFI.get_c_type(self) + end + end + + class FFI + # MessageDef + attach_function :get_field_by_index, :upb_MessageDef_Field, [Descriptor, :int], FieldDescriptor + attach_function :get_field_by_name, :upb_MessageDef_FindFieldByNameWithSize,[Descriptor, :string, :size_t], FieldDescriptor + attach_function :get_field_by_number, :upb_MessageDef_FindFieldByNumber, [Descriptor, :uint32_t], FieldDescriptor + + # FieldDescriptor + attach_function :field_options, :FieldDescriptor_serialized_options, [FieldDescriptor, :pointer, Internal::Arena], :pointer + attach_function :get_containing_message_def, :upb_FieldDef_ContainingType, [FieldDescriptor], Descriptor + attach_function :get_c_type, :upb_FieldDef_CType, [FieldDescriptor], CType + attach_function :get_default, :upb_FieldDef_Default, [FieldDescriptor], MessageValue.by_value + attach_function :get_subtype_as_enum, :upb_FieldDef_EnumSubDef, [FieldDescriptor], EnumDescriptor + attach_function :get_has_presence, :upb_FieldDef_HasPresence, [FieldDescriptor], :bool + attach_function :get_is_packed, :upb_FieldDef_IsPacked, [FieldDescriptor], :bool + attach_function :is_map, :upb_FieldDef_IsMap, [FieldDescriptor], :bool + attach_function :is_repeated, :upb_FieldDef_IsRepeated, [FieldDescriptor], :bool + attach_function :is_sub_message, :upb_FieldDef_IsSubMessage, [FieldDescriptor], :bool + attach_function :get_json_name, :upb_FieldDef_JsonName, [FieldDescriptor], :string + attach_function :get_label, :upb_FieldDef_Label, [FieldDescriptor], Label + attach_function :get_subtype_as_message, :upb_FieldDef_MessageSubDef, [FieldDescriptor], Descriptor + attach_function :get_full_name, :upb_FieldDef_Name, [FieldDescriptor], :string + attach_function :get_number, :upb_FieldDef_Number, [FieldDescriptor], :uint32_t + attach_function :get_type, :upb_FieldDef_Type, [FieldDescriptor], FieldType + attach_function :file_def_by_raw_field_def, :upb_FieldDef_File, [:pointer], :FileDef + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/file_descriptor.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/file_descriptor.rb new file mode 100755 index 0000000..2a7bf87 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/file_descriptor.rb @@ -0,0 +1,49 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class FFI + # FileDescriptor + attach_function :file_def_name, :upb_FileDef_Name, [:FileDef], :string + attach_function :file_def_pool, :upb_FileDef_Pool, [:FileDef], :DefPool + attach_function :file_options, :FileDescriptor_serialized_options, [:FileDef, :pointer, Internal::Arena], :pointer + end + + class FileDescriptor + attr :descriptor_pool, :file_def + + def initialize(file_def, descriptor_pool) + @descriptor_pool = descriptor_pool + @file_def = file_def + end + + def to_s + inspect + end + + def inspect + "#{self.class.name}: #{name}" + end + + def name + Google::Protobuf::FFI.file_def_name(@file_def) + end + + def options + @options ||= begin + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + temporary_arena = Google::Protobuf::FFI.create_arena + buffer = Google::Protobuf::FFI.file_options(@file_def, size_ptr, temporary_arena) + opts = Google::Protobuf::FileOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze) + opts.clear_features() + opts.freeze + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/arena.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/arena.rb new file mode 100755 index 0000000..9e81977 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/arena.rb @@ -0,0 +1,66 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +## +# Implementation details below are subject to breaking changes without +# warning and are intended for use only within the gem. +module Google + module Protobuf + module Internal + class Arena + attr :pinned_messages + + # FFI Interface methods and setup + extend ::FFI::DataConverter + native_type ::FFI::Type::POINTER + + class << self + prepend Google::Protobuf::Internal::TypeSafety + + # @param value [Arena] Arena to convert to an FFI native type + # @param _ [Object] Unused + def to_native(value, _) + value.instance_variable_get(:@arena) || ::FFI::Pointer::NULL + end + + ## + # @param value [::FFI::Pointer] Arena pointer to be wrapped + # @param _ [Object] Unused + def from_native(value, _) + new(value) + end + end + + def initialize(pointer) + @arena = ::FFI::AutoPointer.new(pointer, Google::Protobuf::FFI.method(:free_arena)) + @pinned_messages = [] + end + + def fuse(other_arena) + return if other_arena == self + unless Google::Protobuf::FFI.fuse_arena(self, other_arena) + raise RuntimeError.new "Unable to fuse arenas. This should never happen since Ruby does not use initial blocks" + end + end + + def pin(message) + pinned_messages.push message + end + end + end + + class FFI + # Arena + attach_function :create_arena, :Arena_create, [], Internal::Arena + attach_function :fuse_arena, :upb_Arena_Fuse, [Internal::Arena, Internal::Arena], :bool + # Argument takes a :pointer rather than a typed Arena here due to + # implementation details of FFI::AutoPointer. + attach_function :free_arena, :upb_Arena_Free, [:pointer], :void + attach_function :arena_malloc, :upb_Arena_Malloc, [Internal::Arena, :size_t], :pointer + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/convert.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/convert.rb new file mode 100755 index 0000000..cf86693 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/convert.rb @@ -0,0 +1,289 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +## +# Implementation details below are subject to breaking changes without +# warning and are intended for use only within the gem. +module Google + module Protobuf + module Internal + module Convert + + # Arena should be the + # @param value [Object] Value to convert + # @param arena [Arena] Arena that owns the Message where the MessageValue + # will be set + # @return [Google::Protobuf::FFI::MessageValue] + def convert_ruby_to_upb(value, arena, c_type, msg_or_enum_def) + raise ArgumentError.new "Expected Descriptor or EnumDescriptor, instead got #{msg_or_enum_def.class}" unless [NilClass, Descriptor, EnumDescriptor].include? msg_or_enum_def.class + return_value = Google::Protobuf::FFI::MessageValue.new + case c_type + when :float + raise TypeError.new "Expected number type for float field '#{name}' (given #{value.class})." unless value.respond_to? :to_f + return_value[:float_val] = value.to_f + when :double + raise TypeError.new "Expected number type for double field '#{name}' (given #{value.class})." unless value.respond_to? :to_f + return_value[:double_val] = value.to_f + when :bool + raise TypeError.new "Invalid argument for boolean field '#{name}' (given #{value.class})." unless [TrueClass, FalseClass].include? value.class + return_value[:bool_val] = value + when :string + raise TypeError.new "Invalid argument for string field '#{name}' (given #{value.class})." unless value.is_a?(String) or value.is_a?(Symbol) + begin + string_value = value.to_s.encode("UTF-8") + rescue Encoding::UndefinedConversionError + # TODO - why not include the field name here? + raise Encoding::UndefinedConversionError.new "String is invalid UTF-8" + end + return_value[:str_val][:size] = string_value.bytesize + return_value[:str_val][:data] = Google::Protobuf::FFI.arena_malloc(arena, string_value.bytesize) + # TODO - how important is it to still use arena malloc, versus the following? + # buffer = ::FFI::MemoryPointer.new(:char, string_value.bytesize) + # buffer.put_bytes(0, string_value) + # return_value[:str_val][:data] = buffer + raise NoMemoryError.new "Cannot allocate #{string_value.bytesize} bytes for string on Arena" if return_value[:str_val][:data].nil? || return_value[:str_val][:data].null? + return_value[:str_val][:data].write_string(string_value) + when :bytes + raise TypeError.new "Invalid argument for bytes field '#{name}' (given #{value.class})." unless value.is_a? String + string_value = value.encode("ASCII-8BIT") + return_value[:str_val][:size] = string_value.bytesize + return_value[:str_val][:data] = Google::Protobuf::FFI.arena_malloc(arena, string_value.bytesize) + raise NoMemoryError.new "Cannot allocate #{string_value.bytesize} bytes for bytes on Arena" if return_value[:str_val][:data].nil? || return_value[:str_val][:data].null? + return_value[:str_val][:data].write_string_length(string_value, string_value.bytesize) + when :message + raise TypeError.new "nil message not allowed here." if value.nil? + if value.is_a? Hash + raise RuntimeError.new "Attempted to initialize message from Hash for field #{name} but have no definition" if msg_or_enum_def.nil? + new_message = msg_or_enum_def.msgclass. + send(:private_constructor, arena, initial_value: value) + return_value[:msg_val] = new_message.instance_variable_get(:@msg) + return return_value + end + + descriptor = value.class.respond_to?(:descriptor) ? value.class.descriptor : nil + if descriptor != msg_or_enum_def + wkt = Google::Protobuf::FFI.get_well_known_type(msg_or_enum_def) + case wkt + when :Timestamp + raise TypeError.new "Invalid type #{value.class} to assign to submessage field '#{name}'." unless value.kind_of? Time + new_message = Google::Protobuf::FFI.new_message_from_def msg_or_enum_def, arena + sec = Google::Protobuf::FFI::MessageValue.new + sec[:int64_val] = value.tv_sec + sec_field_def = Google::Protobuf::FFI.get_field_by_number msg_or_enum_def, 1 + raise "Should be impossible" unless Google::Protobuf::FFI.set_message_field new_message, sec_field_def, sec, arena + nsec_field_def = Google::Protobuf::FFI.get_field_by_number msg_or_enum_def, 2 + nsec = Google::Protobuf::FFI::MessageValue.new + nsec[:int32_val] = value.tv_nsec + raise "Should be impossible" unless Google::Protobuf::FFI.set_message_field new_message, nsec_field_def, nsec, arena + return_value[:msg_val] = new_message + when :Duration + raise TypeError.new "Invalid type #{value.class} to assign to submessage field '#{name}'." unless value.kind_of? Numeric + new_message = Google::Protobuf::FFI.new_message_from_def msg_or_enum_def, arena + sec = Google::Protobuf::FFI::MessageValue.new + sec[:int64_val] = value + sec_field_def = Google::Protobuf::FFI.get_field_by_number msg_or_enum_def, 1 + raise "Should be impossible" unless Google::Protobuf::FFI.set_message_field new_message, sec_field_def, sec, arena + nsec_field_def = Google::Protobuf::FFI.get_field_by_number msg_or_enum_def, 2 + nsec = Google::Protobuf::FFI::MessageValue.new + nsec[:int32_val] = ((value.to_f - value.to_i) * 1000000000).round + raise "Should be impossible" unless Google::Protobuf::FFI.set_message_field new_message, nsec_field_def, nsec, arena + return_value[:msg_val] = new_message + else + raise TypeError.new "Invalid type #{value.class} to assign to submessage field '#{name}'." + end + else + arena.fuse(value.instance_variable_get(:@arena)) + return_value[:msg_val] = value.instance_variable_get :@msg + end + when :enum + return_value[:int32_val] = case value + when Numeric + value.to_i + when String, Symbol + enum_number = EnumDescriptor.send(:lookup_name, msg_or_enum_def, value.to_s) + #TODO add the bad value to the error message after tests pass + raise RangeError.new "Unknown symbol value for enum field '#{name}'." if enum_number.nil? + enum_number + else + raise TypeError.new "Expected number or symbol type for enum field '#{name}'." + end + #TODO After all tests pass, improve error message across integer type by including actual offending value + when :int32 + raise TypeError.new "Expected number type for integral field '#{name}' (given #{value.class})." unless value.is_a? Numeric + raise RangeError.new "Non-integral floating point value assigned to integer field '#{name}' (given #{value.class})." if value.floor != value + raise RangeError.new "Value assigned to int32 field '#{name}' (given #{value.class}) with more than 32-bits." unless value.to_i.bit_length < 32 + return_value[:int32_val] = value.to_i + when :uint32 + raise TypeError.new "Expected number type for integral field '#{name}' (given #{value.class})." unless value.is_a? Numeric + raise RangeError.new "Non-integral floating point value assigned to integer field '#{name}' (given #{value.class})." if value.floor != value + raise RangeError.new "Assigning negative value to unsigned integer field '#{name}' (given #{value.class})." if value < 0 + raise RangeError.new "Value assigned to uint32 field '#{name}' (given #{value.class}) with more than 32-bits." unless value.to_i.bit_length < 33 + return_value[:uint32_val] = value.to_i + when :int64 + raise TypeError.new "Expected number type for integral field '#{name}' (given #{value.class})." unless value.is_a? Numeric + raise RangeError.new "Non-integral floating point value assigned to integer field '#{name}' (given #{value.class})." if value.floor != value + raise RangeError.new "Value assigned to int64 field '#{name}' (given #{value.class}) with more than 64-bits." unless value.to_i.bit_length < 64 + return_value[:int64_val] = value.to_i + when :uint64 + raise TypeError.new "Expected number type for integral field '#{name}' (given #{value.class})." unless value.is_a? Numeric + raise RangeError.new "Non-integral floating point value assigned to integer field '#{name}' (given #{value.class})." if value.floor != value + raise RangeError.new "Assigning negative value to unsigned integer field '#{name}' (given #{value.class})." if value < 0 + raise RangeError.new "Value assigned to uint64 field '#{name}' (given #{value.class}) with more than 64-bits." unless value.to_i.bit_length < 65 + return_value[:uint64_val] = value.to_i + else + raise RuntimeError.new "Unsupported type #{c_type}" + end + return_value + end + + ## + # Safe to call without an arena if the caller has checked that c_type + # is not :message. + # @param message_value [Google::Protobuf::FFI::MessageValue] Value to be converted. + # @param c_type [Google::Protobuf::FFI::CType] Enum representing the type of message_value + # @param msg_or_enum_def [::FFI::Pointer] Pointer to the MsgDef or EnumDef definition + # @param arena [Google::Protobuf::Internal::Arena] Arena to create Message instances, if needed + def convert_upb_to_ruby(message_value, c_type, msg_or_enum_def = nil, arena = nil) + throw TypeError.new "Expected MessageValue but got #{message_value.class}" unless message_value.is_a? Google::Protobuf::FFI::MessageValue + + case c_type + when :bool + message_value[:bool_val] + when :int32 + message_value[:int32_val] + when :uint32 + message_value[:uint32_val] + when :double + message_value[:double_val] + when :int64 + message_value[:int64_val] + when :uint64 + message_value[:uint64_val] + when :string + if message_value[:str_val][:size].zero? + "" + else + message_value[:str_val][:data].read_string_length(message_value[:str_val][:size]).force_encoding("UTF-8").freeze + end + when :bytes + if message_value[:str_val][:size].zero? + "" + else + message_value[:str_val][:data].read_string_length(message_value[:str_val][:size]).force_encoding("ASCII-8BIT").freeze + end + when :float + message_value[:float_val] + when :enum + EnumDescriptor.send(:lookup_value, msg_or_enum_def, message_value[:int32_val]) || message_value[:int32_val] + when :message + raise "Null Arena for message" if arena.nil? + Descriptor.send(:get_message, message_value[:msg_val], msg_or_enum_def, arena) + else + raise RuntimeError.new "Unexpected type #{c_type}" + end + end + + def to_h_internal(msg, message_descriptor) + return nil if msg.nil? or msg.null? + hash = {} + iter = ::FFI::MemoryPointer.new(:size_t, 1) + iter.write(:size_t, Google::Protobuf::FFI::Upb_Message_Begin) + message_value = Google::Protobuf::FFI::MessageValue.new + field_def_ptr = ::FFI::MemoryPointer.new :pointer + + while Google::Protobuf::FFI::message_next(msg, message_descriptor, nil, field_def_ptr, message_value, iter) do + field_descriptor = FieldDescriptor.from_native field_def_ptr.get_pointer(0) + + if field_descriptor.map? + hash_entry = map_create_hash(message_value[:map_val], field_descriptor) + elsif field_descriptor.repeated? + hash_entry = repeated_field_create_array(message_value[:array_val], field_descriptor, field_descriptor.type) + else + hash_entry = scalar_create_hash(message_value, field_descriptor.type, field_descriptor: field_descriptor) + end + + hash[field_descriptor.name.to_sym] = hash_entry + end + + hash + end + + def map_create_hash(map_ptr, field_descriptor) + return {} if map_ptr.nil? or map_ptr.null? + return_value = {} + + message_descriptor = field_descriptor.send(:subtype) + key_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 1) + key_field_type = Google::Protobuf::FFI.get_type(key_field_def) + + value_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 2) + value_field_type = Google::Protobuf::FFI.get_type(value_field_def) + + iter = ::FFI::MemoryPointer.new(:size_t, 1) + iter.write(:size_t, Google::Protobuf::FFI::Upb_Map_Begin) + while Google::Protobuf::FFI.map_next(map_ptr, iter) do + iter_size_t = iter.read(:size_t) + key_message_value = Google::Protobuf::FFI.map_key(map_ptr, iter_size_t) + value_message_value = Google::Protobuf::FFI.map_value(map_ptr, iter_size_t) + hash_key = convert_upb_to_ruby(key_message_value, key_field_type) + hash_value = scalar_create_hash(value_message_value, value_field_type, msg_or_enum_descriptor: value_field_def.subtype) + return_value[hash_key] = hash_value + end + return_value + end + + def repeated_field_create_array(array, field_descriptor, type) + return_value = [] + n = (array.nil? || array.null?) ? 0 : Google::Protobuf::FFI.array_size(array) + 0.upto(n - 1) do |i| + message_value = Google::Protobuf::FFI.get_msgval_at(array, i) + return_value << scalar_create_hash(message_value, type, field_descriptor: field_descriptor) + end + return_value + end + + # @param field_descriptor [FieldDescriptor] Descriptor of the field to convert to a hash. + def scalar_create_hash(message_value, type, field_descriptor: nil, msg_or_enum_descriptor: nil) + if [:message, :enum].include? type + if field_descriptor.nil? + if msg_or_enum_descriptor.nil? + raise "scalar_create_hash requires either a FieldDescriptor, MessageDescriptor, or EnumDescriptor as an argument, but received only nil" + end + else + msg_or_enum_descriptor = field_descriptor.subtype + end + if type == :message + to_h_internal(message_value[:msg_val], msg_or_enum_descriptor) + elsif type == :enum + convert_upb_to_ruby message_value, type, msg_or_enum_descriptor + end + else + convert_upb_to_ruby message_value, type + end + end + + def message_value_deep_copy(message_value, type, descriptor, arena) + raise unless message_value.is_a? Google::Protobuf::FFI::MessageValue + new_message_value = Google::Protobuf::FFI::MessageValue.new + case type + when :string, :bytes + # TODO - how important is it to still use arena malloc, versus using FFI MemoryPointers? + new_message_value[:str_val][:size] = message_value[:str_val][:size] + new_message_value[:str_val][:data] = Google::Protobuf::FFI.arena_malloc(arena, message_value[:str_val][:size]) + raise NoMemoryError.new "Allocation failed" if new_message_value[:str_val][:data].nil? or new_message_value[:str_val][:data].null? + Google::Protobuf::FFI.memcpy(new_message_value[:str_val][:data], message_value[:str_val][:data], message_value[:str_val][:size]) + when :message + new_message_value[:msg_val] = descriptor.msgclass.send(:deep_copy, message_value[:msg_val], arena).instance_variable_get(:@msg) + else + Google::Protobuf::FFI.memcpy(new_message_value.to_ptr, message_value.to_ptr, Google::Protobuf::FFI::MessageValue.size) + end + new_message_value + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/pointer_helper.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/pointer_helper.rb new file mode 100755 index 0000000..a7910ca --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/pointer_helper.rb @@ -0,0 +1,35 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + module Internal + module PointerHelper + # Utility code to defensively walk the object graph from a file_def to + # the pool, and either retrieve the wrapper object for the given pointer + # or create one. Assumes that the caller is the wrapper class for the + # given pointer and that it implements `private_constructor`. + def descriptor_from_file_def(file_def, pointer) + raise RuntimeError.new "FileDef is nil" if file_def.nil? + raise RuntimeError.new "FileDef is null" if file_def.null? + pool_def = Google::Protobuf::FFI.file_def_pool file_def + raise RuntimeError.new "PoolDef is nil" if pool_def.nil? + raise RuntimeError.new "PoolDef is null" if pool_def.null? + pool = Google::Protobuf::OBJECT_CACHE.get(pool_def.address) + raise "Cannot find pool in ObjectCache!" if pool.nil? + descriptor = pool.descriptor_class_by_def[pointer.address] + if descriptor.nil? + pool.descriptor_class_by_def[pointer.address] = private_constructor(pointer, pool) + else + descriptor + end + end + end + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/type_safety.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/type_safety.rb new file mode 100755 index 0000000..6cdb3e9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/internal/type_safety.rb @@ -0,0 +1,25 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +# A to_native DataConverter method that raises an error if the value is not of the same type. +# Adapted from to https://www.varvet.com/blog/advanced-topics-in-ruby-ffi/ +module Google + module Protobuf + module Internal + module TypeSafety + def to_native(value, ctx = nil) + if value.kind_of?(self) or value.nil? + super + else + raise TypeError.new "Expected a kind of #{name}, was #{value.class}" + end + end + end + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/map.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/map.rb new file mode 100755 index 0000000..90898b6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/map.rb @@ -0,0 +1,409 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class FFI + # Map + attach_function :map_clear, :upb_Map_Clear, [:Map], :void + attach_function :map_delete, :upb_Map_Delete, [:Map, MessageValue.by_value, MessageValue.by_ref], :bool + attach_function :map_get, :upb_Map_Get, [:Map, MessageValue.by_value, MessageValue.by_ref], :bool + attach_function :create_map, :upb_Map_New, [Internal::Arena, CType, CType], :Map + attach_function :map_size, :upb_Map_Size, [:Map], :size_t + attach_function :map_set, :upb_Map_Set, [:Map, MessageValue.by_value, MessageValue.by_value, Internal::Arena], :bool + + # MapIterator + attach_function :map_next, :upb_MapIterator_Next, [:Map, :pointer], :bool + attach_function :map_done, :upb_MapIterator_Done, [:Map, :size_t], :bool + attach_function :map_key, :upb_MapIterator_Key, [:Map, :size_t], MessageValue.by_value + attach_function :map_value, :upb_MapIterator_Value, [:Map, :size_t], MessageValue.by_value + end + class Map + include Enumerable + ## + # call-seq: + # Map.new(key_type, value_type, value_typeclass = nil, init_hashmap = {}) + # => new map + # + # Allocates a new Map container. This constructor may be called with 2, 3, or 4 + # arguments. The first two arguments are always present and are symbols (taking + # on the same values as field-type symbols in message descriptors) that + # indicate the type of the map key and value fields. + # + # The supported key types are: :int32, :int64, :uint32, :uint64, :bool, + # :string, :bytes. + # + # The supported value types are: :int32, :int64, :uint32, :uint64, :bool, + # :string, :bytes, :enum, :message. + # + # The third argument, value_typeclass, must be present if value_type is :enum + # or :message. As in RepeatedField#new, this argument must be a message class + # (for :message) or enum module (for :enum). + # + # The last argument, if present, provides initial content for map. Note that + # this may be an ordinary Ruby hashmap or another Map instance with identical + # key and value types. Also note that this argument may be present whether or + # not value_typeclass is present (and it is unambiguously separate from + # value_typeclass because value_typeclass's presence is strictly determined by + # value_type). The contents of this initial hashmap or Map instance are + # shallow-copied into the new Map: the original map is unmodified, but + # references to underlying objects will be shared if the value type is a + # message type. + def self.new(key_type, value_type, value_typeclass = nil, init_hashmap = {}) + instance = allocate + # TODO This argument mangling doesn't agree with the type signature, + # but does align with the text of the comments and is required to make unit tests pass. + if init_hashmap.empty? and ![:enum, :message].include?(value_type) + init_hashmap = value_typeclass + value_typeclass = nil + end + instance.send(:initialize, key_type, value_type, value_type_class: value_typeclass, initial_values: init_hashmap) + instance + end + + ## + # call-seq: + # Map.keys => [list_of_keys] + # + # Returns the list of keys contained in the map, in unspecified order. + def keys + return_value = [] + internal_iterator do |iterator| + key_message_value = Google::Protobuf::FFI.map_key(@map_ptr, iterator) + return_value << convert_upb_to_ruby(key_message_value, key_type) + end + return_value + end + + ## + # call-seq: + # Map.values => [list_of_values] + # + # Returns the list of values contained in the map, in unspecified order. + def values + return_value = [] + internal_iterator do |iterator| + value_message_value = Google::Protobuf::FFI.map_value(@map_ptr, iterator) + return_value << convert_upb_to_ruby(value_message_value, value_type, descriptor, arena) + end + return_value + end + + ## + # call-seq: + # Map.[](key) => value + # + # Accesses the element at the given key. Throws an exception if the key type is + # incorrect. Returns nil when the key is not present in the map. + def [](key) + value = Google::Protobuf::FFI::MessageValue.new + key_message_value = convert_ruby_to_upb(key, arena, key_type, nil) + if Google::Protobuf::FFI.map_get(@map_ptr, key_message_value, value) + convert_upb_to_ruby(value, value_type, descriptor, arena) + end + end + + ## + # call-seq: + # Map.[]=(key, value) => value + # + # Inserts or overwrites the value at the given key with the given new value. + # Throws an exception if the key type is incorrect. Returns the new value that + # was just inserted. + def []=(key, value) + raise FrozenError.new "can't modify frozen #{self.class}" if frozen? + key_message_value = convert_ruby_to_upb(key, arena, key_type, nil) + value_message_value = convert_ruby_to_upb(value, arena, value_type, descriptor) + Google::Protobuf::FFI.map_set(@map_ptr, key_message_value, value_message_value, arena) + value + end + + def has_key?(key) + key_message_value = convert_ruby_to_upb(key, arena, key_type, nil) + Google::Protobuf::FFI.map_get(@map_ptr, key_message_value, nil) + end + + ## + # call-seq: + # Map.delete(key) => old_value + # + # Deletes the value at the given key, if any, returning either the old value or + # nil if none was present. Throws an exception if the key is of the wrong type. + def delete(key) + raise FrozenError.new "can't modify frozen #{self.class}" if frozen? + value = Google::Protobuf::FFI::MessageValue.new + key_message_value = convert_ruby_to_upb(key, arena, key_type, nil) + if Google::Protobuf::FFI.map_delete(@map_ptr, key_message_value, value) + convert_upb_to_ruby(value, value_type, descriptor, arena) + else + nil + end + end + + def clear + raise FrozenError.new "can't modify frozen #{self.class}" if frozen? + Google::Protobuf::FFI.map_clear(@map_ptr) + nil + end + + def length + Google::Protobuf::FFI.map_size(@map_ptr) + end + alias size length + + def freeze + return self if frozen? + super + @arena.pin self + if value_type == :message + internal_iterator do |iterator| + value_message_value = Google::Protobuf::FFI.map_value(@map_ptr, iterator) + convert_upb_to_ruby(value_message_value, value_type, descriptor, arena).freeze + end + end + self + end + + ## + # call-seq: + # Map.dup => new_map + # + # Duplicates this map with a shallow copy. References to all non-primitive + # element objects (e.g., submessages) are shared. + def dup + internal_dup + end + alias clone dup + + ## + # call-seq: + # Map.==(other) => boolean + # + # Compares this map to another. Maps are equal if they have identical key sets, + # and for each key, the values in both maps compare equal. Elements are + # compared as per normal Ruby semantics, by calling their :== methods (or + # performing a more efficient comparison for primitive types). + # + # Maps with dissimilar key types or value types/typeclasses are never equal, + # even if value comparison (for example, between integers and floats) would + # have otherwise indicated that every element has equal value. + def ==(other) + if other.is_a? Hash + other = self.class.send(:private_constructor, key_type, value_type, descriptor, initial_values: other) + elsif !other.is_a? Google::Protobuf::Map + return false + end + + return true if object_id == other.object_id + return false if key_type != other.send(:key_type) or value_type != other.send(:value_type) or descriptor != other.send(:descriptor) or length != other.length + other_map_ptr = other.send(:map_ptr) + each_msg_val do |key_message_value, value_message_value| + other_value = Google::Protobuf::FFI::MessageValue.new + return false unless Google::Protobuf::FFI.map_get(other_map_ptr, key_message_value, other_value) + return false unless Google::Protobuf::FFI.message_value_equal(value_message_value, other_value, value_type, descriptor) + end + true + end + + def hash + return_value = 0 + each_msg_val do |key_message_value, value_message_value| + return_value = Google::Protobuf::FFI.message_value_hash(key_message_value, key_type, nil, return_value) + return_value = Google::Protobuf::FFI.message_value_hash(value_message_value, value_type, descriptor, return_value) + end + return_value + end + + ## + # call-seq: + # Map.to_h => {} + # + # Returns a Ruby Hash object containing all the values within the map + def to_h + return {} if map_ptr.nil? or map_ptr.null? + return_value = {} + each_msg_val do |key_message_value, value_message_value| + hash_key = convert_upb_to_ruby(key_message_value, key_type) + hash_value = scalar_create_hash(value_message_value, value_type, msg_or_enum_descriptor: descriptor) + return_value[hash_key] = hash_value + end + return_value + end + + def inspect + key_value_pairs = [] + each_msg_val do |key_message_value, value_message_value| + key_string = convert_upb_to_ruby(key_message_value, key_type).inspect + if value_type == :message + sub_msg_descriptor = Google::Protobuf::FFI.get_subtype_as_message(descriptor) + value_string = sub_msg_descriptor.msgclass.send(:inspect_internal, value_message_value[:msg_val]) + else + value_string = convert_upb_to_ruby(value_message_value, value_type, descriptor).inspect + end + key_value_pairs << "#{key_string}=>#{value_string}" + end + "{#{key_value_pairs.join(", ")}}" + end + + ## + # call-seq: + # Map.merge(other_map) => map + # + # Copies key/value pairs from other_map into a copy of this map. If a key is + # set in other_map and this map, the value from other_map overwrites the value + # in the new copy of this map. Returns the new copy of this map with merged + # contents. + def merge(other) + internal_merge(other) + end + + ## + # call-seq: + # Map.each(&block) + # + # Invokes &block on each |key, value| pair in the map, in unspecified order. + # Note that Map also includes Enumerable; map thus acts like a normal Ruby + # sequence. + def each &block + each_msg_val do |key_message_value, value_message_value| + key_value = convert_upb_to_ruby(key_message_value, key_type) + value_value = convert_upb_to_ruby(value_message_value, value_type, descriptor, arena) + yield key_value, value_value + end + nil + end + + private + attr :arena, :map_ptr, :key_type, :value_type, :descriptor, :name + + include Google::Protobuf::Internal::Convert + + def internal_iterator + iter = ::FFI::MemoryPointer.new(:size_t, 1) + iter.write(:size_t, Google::Protobuf::FFI::Upb_Map_Begin) + while Google::Protobuf::FFI.map_next(@map_ptr, iter) do + iter_size_t = iter.read(:size_t) + yield iter_size_t + end + end + + def each_msg_val &block + internal_iterator do |iterator| + key_message_value = Google::Protobuf::FFI.map_key(@map_ptr, iterator) + value_message_value = Google::Protobuf::FFI.map_value(@map_ptr, iterator) + yield key_message_value, value_message_value + end + end + + def internal_dup + instance = self.class.send(:private_constructor, key_type, value_type, descriptor, arena: arena) + new_map_ptr = instance.send(:map_ptr) + each_msg_val do |key_message_value, value_message_value| + Google::Protobuf::FFI.map_set(new_map_ptr, key_message_value, value_message_value, arena) + end + instance + end + + def internal_merge_into_self(other) + case other + when Hash + other.each do |key, value| + key_message_value = convert_ruby_to_upb(key, arena, key_type, nil) + value_message_value = convert_ruby_to_upb(value, arena, value_type, descriptor) + Google::Protobuf::FFI.map_set(@map_ptr, key_message_value, value_message_value, arena) + end + when Google::Protobuf::Map + unless key_type == other.send(:key_type) and value_type == other.send(:value_type) and descriptor == other.descriptor + raise ArgumentError.new "Attempt to merge Map with mismatching types" #TODO Improve error message by adding type information + end + arena.fuse(other.send(:arena)) + iter = ::FFI::MemoryPointer.new(:size_t, 1) + iter.write(:size_t, Google::Protobuf::FFI::Upb_Map_Begin) + other.send(:each_msg_val) do |key_message_value, value_message_value| + Google::Protobuf::FFI.map_set(@map_ptr, key_message_value, value_message_value, arena) + end + else + raise ArgumentError.new "Unknown type merging into Map" #TODO improve this error message by including type information + end + self + end + + def internal_merge(other) + internal_dup.internal_merge_into_self(other) + end + + def initialize(key_type, value_type, value_type_class: nil, initial_values: nil, arena: nil, map: nil, descriptor: nil, name: nil) + @name = name || 'Map' + + unless [:int32, :int64, :uint32, :uint64, :bool, :string, :bytes].include? key_type + raise ArgumentError.new "Invalid key type for map." #TODO improve error message to include what type was passed + end + @key_type = key_type + + unless [:int32, :int64, :uint32, :uint64, :bool, :string, :bytes, :enum, :message].include? value_type + raise ArgumentError.new "Invalid value type for map." #TODO improve error message to include what type was passed + end + @value_type = value_type + + if !descriptor.nil? + raise ArgumentError "Expected descriptor to be a Descriptor or EnumDescriptor" unless [EnumDescriptor, Descriptor].include? descriptor.class + @descriptor = descriptor + elsif [:message, :enum].include? value_type + raise ArgumentError.new "Expected at least 3 arguments for message/enum." if value_type_class.nil? + descriptor = value_type_class.respond_to?(:descriptor) ? value_type_class.descriptor : nil + raise ArgumentError.new "Type class #{value_type_class} has no descriptor. Please pass a class or enum as returned by the DescriptorPool." if descriptor.nil? + @descriptor = descriptor + else + @descriptor = nil + end + + @arena = arena || Google::Protobuf::FFI.create_arena + @map_ptr = map || Google::Protobuf::FFI.create_map(@arena, @key_type, @value_type) + + internal_merge_into_self(initial_values) unless initial_values.nil? + + # Should always be the last expression of the initializer to avoid + # leaking references to this object before construction is complete. + OBJECT_CACHE.try_add(@map_ptr.address, self) + end + + # @param field [FieldDescriptor] Descriptor of the field where the RepeatedField will be assigned + # @param values [Hash|Map] Initial value; may be nil or empty + # @param arena [Arena] Owning message's arena + def self.construct_for_field(field, arena, value: nil, map: nil) + raise ArgumentError.new "Expected Hash object as initializer value for map field '#{field.name}' (given #{value.class})." unless value.nil? or value.is_a? Hash + instance = allocate + raise ArgumentError.new "Expected field with type :message, instead got #{field.class}" unless field.type == :message + message_descriptor = field.send(:subtype) + key_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 1) + key_field_type = Google::Protobuf::FFI.get_type(key_field_def) + + value_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 2) + value_field_type = Google::Protobuf::FFI.get_type(value_field_def) + instance.send(:initialize, key_field_type, value_field_type, initial_values: value, name: field.name, arena: arena, map: map, descriptor: value_field_def.subtype) + instance + end + + def self.private_constructor(key_type, value_type, descriptor, initial_values: nil, arena: nil) + instance = allocate + instance.send(:initialize, key_type, value_type, descriptor: descriptor, initial_values: initial_values, arena: arena) + instance + end + + extend Google::Protobuf::Internal::Convert + + def self.deep_copy(map) + instance = allocate + instance.send(:initialize, map.send(:key_type), map.send(:value_type), descriptor: map.send(:descriptor)) + map.send(:each_msg_val) do |key_message_value, value_message_value| + Google::Protobuf::FFI.map_set(instance.send(:map_ptr), key_message_value, message_value_deep_copy(value_message_value, map.send(:value_type), map.send(:descriptor), instance.send(:arena)), instance.send(:arena)) + end + instance + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/message.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/message.rb new file mode 100755 index 0000000..c1b9b43 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/message.rb @@ -0,0 +1,659 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + + +# Decorates Descriptor with the `build_message_class` method that defines +# Message classes. +module Google + module Protobuf + class FFI + # Message + attach_function :clear_message_field, :upb_Message_ClearFieldByDef, [:Message, FieldDescriptor], :void + attach_function :get_message_value, :upb_Message_GetFieldByDef, [:Message, FieldDescriptor], MessageValue.by_value + attach_function :get_message_has, :upb_Message_HasFieldByDef, [:Message, FieldDescriptor], :bool + attach_function :set_message_field, :upb_Message_SetFieldByDef, [:Message, FieldDescriptor, MessageValue.by_value, Internal::Arena], :bool + attach_function :encode_message, :upb_Encode, [:Message, MiniTable.by_ref, :size_t, Internal::Arena, :pointer, :pointer], EncodeStatus + attach_function :json_decode_message, :upb_JsonDecode, [:binary_string, :size_t, :Message, Descriptor, :DefPool, :int, Internal::Arena, Status.by_ref], :bool + attach_function :json_encode_message, :upb_JsonEncode, [:Message, Descriptor, :DefPool, :int, :binary_string, :size_t, Status.by_ref], :size_t + attach_function :decode_message, :upb_Decode, [:binary_string, :size_t, :Message, MiniTable.by_ref, :ExtensionRegistry, :int, Internal::Arena], DecodeStatus + attach_function :get_mutable_message, :upb_Message_Mutable, [:Message, FieldDescriptor, Internal::Arena], MutableMessageValue.by_value + attach_function :get_message_which_oneof, :upb_Message_WhichOneof, [:Message, OneofDescriptor], FieldDescriptor + attach_function :message_discard_unknown, :upb_Message_DiscardUnknown, [:Message, Descriptor, :int], :bool + attach_function :message_next, :upb_Message_Next, [:Message, Descriptor, :DefPool, :FieldDefPointer, MessageValue.by_ref, :pointer], :bool + # MessageValue + attach_function :message_value_equal, :shared_Msgval_IsEqual, [MessageValue.by_value, MessageValue.by_value, CType, Descriptor], :bool + attach_function :message_value_hash, :shared_Msgval_GetHash, [MessageValue.by_value, CType, Descriptor, :uint64_t], :uint64_t + end + + class Descriptor + def build_message_class + descriptor = self + Class.new(Google::Protobuf::const_get(:AbstractMessage)) do + @descriptor = descriptor + class << self + attr_accessor :descriptor + private + attr_accessor :oneof_field_names + include ::Google::Protobuf::Internal::Convert + end + + alias original_method_missing method_missing + def method_missing(method_name, *args) + method_missing_internal method_name, *args, mode: :method_missing + end + + def respond_to_missing?(method_name, include_private = false) + method_missing_internal(method_name, mode: :respond_to_missing?) || super + end + + ## + # Public constructor. Automatically allocates from a new Arena. + def self.new(initial_value = nil) + instance = allocate + instance.send(:initialize, initial_value) + instance + end + + def freeze + return self if frozen? + super + @arena.pin self + self.class.descriptor.each do |field_descriptor| + next if field_descriptor.has_presence? && !Google::Protobuf::FFI.get_message_has(@msg, field_descriptor) + if field_descriptor.map? or field_descriptor.repeated? or field_descriptor.sub_message? + get_field(field_descriptor).freeze + end + end + self + end + + def dup + duplicate = self.class.private_constructor(@arena) + mini_table = Google::Protobuf::FFI.get_mini_table(self.class.descriptor) + size = mini_table[:size] + duplicate.instance_variable_get(:@msg).write_string_length(@msg.read_string_length(size), size) + duplicate + end + alias clone dup + + def eql?(other) + return false unless self.class === other + encoding_options = Google::Protobuf::FFI::Upb_Encode_Deterministic | Google::Protobuf::FFI::Upb_Encode_SkipUnknown + temporary_arena = Google::Protobuf::FFI.create_arena + mini_table = Google::Protobuf::FFI.get_mini_table(self.class.descriptor) + size_one = ::FFI::MemoryPointer.new(:size_t, 1) + encoding_one = ::FFI::MemoryPointer.new(:pointer, 1) + encoding_status = Google::Protobuf::FFI.encode_message(@msg, mini_table, encoding_options, temporary_arena, encoding_one.to_ptr, size_one) + raise ParseError.new "Error comparing messages due to #{encoding_status} while encoding LHS of `eql?()`" unless encoding_status == :Ok + + size_two = ::FFI::MemoryPointer.new(:size_t, 1) + encoding_two = ::FFI::MemoryPointer.new(:pointer, 1) + encoding_status = Google::Protobuf::FFI.encode_message(other.instance_variable_get(:@msg), mini_table, encoding_options, temporary_arena, encoding_two.to_ptr, size_two) + raise ParseError.new "Error comparing messages due to #{encoding_status} while encoding RHS of `eql?()`" unless encoding_status == :Ok + + if encoding_one.null? or encoding_two.null? + raise ParseError.new "Error comparing messages" + end + size_one.read(:size_t) == size_two.read(:size_t) and Google::Protobuf::FFI.memcmp(encoding_one.read(:pointer), encoding_two.read(:pointer), size_one.read(:size_t)).zero? + end + alias == eql? + + def hash + encoding_options = Google::Protobuf::FFI::Upb_Encode_Deterministic | Google::Protobuf::FFI::Upb_Encode_SkipUnknown + temporary_arena = Google::Protobuf::FFI.create_arena + mini_table_ptr = Google::Protobuf::FFI.get_mini_table(self.class.descriptor) + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + encoding = ::FFI::MemoryPointer.new(:pointer, 1) + encoding_status = Google::Protobuf::FFI.encode_message(@msg, mini_table_ptr, encoding_options, temporary_arena, encoding.to_ptr, size_ptr) + if encoding_status != :Ok or encoding.null? + raise ParseError.new "Error calculating hash" + end + encoding.read(:pointer).read_string(size_ptr.read(:size_t)).hash + end + + def to_h + to_h_internal @msg, self.class.descriptor + end + + ## + # call-seq: + # Message.inspect => string + # + # Returns a human-readable string representing this message. It will be + # formatted as "". Each + # field's value is represented according to its own #inspect method. + def inspect + self.class.inspect_internal @msg + end + + def to_s + self.inspect + end + + ## + # call-seq: + # Message.[](index) => value + # Accesses a field's value by field name. The provided field name + # should be a string. + def [](name) + raise TypeError.new "Expected String for name but got #{name.class}" unless name.is_a? String + index_internal name + end + + ## + # call-seq: + # Message.[]=(index, value) + # Sets a field's value by field name. The provided field name should + # be a string. + # @param name [String] Name of the field to be set + # @param value [Object] Value to set the field to + def []=(name, value) + raise TypeError.new "Expected String for name but got #{name.class}" unless name.is_a? String + index_assign_internal(value, name: name) + end + + ## + # call-seq: + # MessageClass.decode(data, options) => message + # + # Decodes the given data (as a string containing bytes in protocol buffers wire + # format) under the interpretation given by this message class's definition + # and returns a message object with the corresponding field values. + # @param data [String] Binary string in Protobuf wire format to decode + # @param options [Hash] options for the decoder + # @option options [Integer] :recursion_limit Set to maximum decoding depth for message (default is 64) + def self.decode(data, options = {}) + raise ArgumentError.new "Expected hash arguments." unless options.is_a? Hash + raise ArgumentError.new "Expected string for binary protobuf data." unless data.is_a? String + decoding_options = 0 + depth = options[:recursion_limit] + + if depth.is_a? Numeric + decoding_options |= Google::Protobuf::FFI.decode_max_depth(depth.to_i) + end + + message = new + mini_table_ptr = Google::Protobuf::FFI.get_mini_table(message.class.descriptor) + status = Google::Protobuf::FFI.decode_message( + data, + data.bytesize, + message.instance_variable_get(:@msg), + mini_table_ptr, + Google::Protobuf::FFI.get_extension_registry(message.class.descriptor.send(:pool).descriptor_pool), + decoding_options, + message.instance_variable_get(:@arena) + ) + raise ParseError.new "Error occurred during parsing" unless status == :Ok + message + end + + ## + # call-seq: + # MessageClass.encode(msg, options) => bytes + # + # Encodes the given message object to its serialized form in protocol buffers + # wire format. + # @param options [Hash] options for the encoder + # @option options [Integer] :recursion_limit Set to maximum encoding depth for message (default is 64) + def self.encode(message, options = {}) + raise ArgumentError.new "Message of wrong type." unless message.is_a? self + raise ArgumentError.new "Expected hash arguments." unless options.is_a? Hash + + encoding_options = 0 + depth = options[:recursion_limit] + + if depth.is_a? Numeric + encoding_options |= Google::Protobuf::FFI.decode_max_depth(depth.to_i) + end + + encode_internal(message.instance_variable_get(:@msg), encoding_options) do |encoding, size, _| + if encoding.nil? or encoding.null? + raise RuntimeError.new "Exceeded maximum depth (possibly cycle)" + else + encoding.read_string_length(size).force_encoding("ASCII-8BIT").freeze + end + end + end + + ## + # all-seq: + # MessageClass.decode_json(data, options = {}) => message + # + # Decodes the given data (as a string containing bytes in protocol buffers wire + # format) under the interpretation given by this message class's definition + # and returns a message object with the corresponding field values. + # + # @param options [Hash] options for the decoder + # @option options [Boolean] :ignore_unknown_fields Set true to ignore unknown fields (default is to raise an error) + # @return [Message] + def self.decode_json(data, options = {}) + decoding_options = 0 + unless options.is_a? Hash + if options.respond_to? :to_h + options options.to_h + else + #TODO can this error message be improve to include what was received? + raise ArgumentError.new "Expected hash arguments" + end + end + raise ArgumentError.new "Expected string for JSON data." unless data.is_a? String + raise RuntimeError.new "Cannot parse a wrapper directly" if descriptor.send(:wrapper?) + + if options[:ignore_unknown_fields] + decoding_options |= Google::Protobuf::FFI::Upb_JsonDecode_IgnoreUnknown + end + + message = new + pool_def = message.class.descriptor.instance_variable_get(:@descriptor_pool).descriptor_pool + status = Google::Protobuf::FFI::Status.new + unless Google::Protobuf::FFI.json_decode_message(data, data.bytesize, message.instance_variable_get(:@msg), message.class.descriptor, pool_def, decoding_options, message.instance_variable_get(:@arena), status) + raise ParseError.new "Error occurred during parsing: #{Google::Protobuf::FFI.error_message(status)}" + end + message + end + + def self.encode_json(message, options = {}) + encoding_options = 0 + unless options.is_a? Hash + if options.respond_to? :to_h + options = options.to_h + else + #TODO can this error message be improve to include what was received? + raise ArgumentError.new "Expected hash arguments" + end + end + + if options[:preserve_proto_fieldnames] + encoding_options |= Google::Protobuf::FFI::Upb_JsonEncode_UseProtoNames + end + if options[:emit_defaults] + encoding_options |= Google::Protobuf::FFI::Upb_JsonEncode_EmitDefaults + end + if options[:format_enums_as_integers] + encoding_options |= Google::Protobuf::FFI::Upb_JsonEncode_FormatEnumsAsIntegers + end + + buffer_size = 1024 + buffer = ::FFI::MemoryPointer.new(:char, buffer_size) + status = Google::Protobuf::FFI::Status.new + msg = message.instance_variable_get(:@msg) + pool_def = message.class.descriptor.instance_variable_get(:@descriptor_pool).descriptor_pool + size = Google::Protobuf::FFI::json_encode_message(msg, message.class.descriptor, pool_def, encoding_options, buffer, buffer_size, status) + unless status[:ok] + raise ParseError.new "Error occurred during encoding: #{Google::Protobuf::FFI.error_message(status)}" + end + + if size >= buffer_size + buffer_size = size + 1 + buffer = ::FFI::MemoryPointer.new(:char, buffer_size) + status.clear + size = Google::Protobuf::FFI::json_encode_message(msg, message.class.descriptor, pool_def, encoding_options, buffer, buffer_size, status) + unless status[:ok] + raise ParseError.new "Error occurred during encoding: #{Google::Protobuf::FFI.error_message(status)}" + end + if size >= buffer_size + raise ParseError.new "Inconsistent JSON encoding sizes - was #{buffer_size - 1}, now #{size}" + end + end + + buffer.read_string_length(size).force_encoding("UTF-8").freeze + end + + private + # Implementation details below are subject to breaking changes without + # warning and are intended for use only within the gem. + + include Google::Protobuf::Internal::Convert + + def self.setup_accessors! + @descriptor.each do |field_descriptor| + field_name = field_descriptor.name + unless instance_methods(true).include?(field_name.to_sym) + #TODO - at a high level, dispatching to either + # index_internal or get_field would be logically correct, but slightly slower. + if field_descriptor.map? + define_method(field_name) do + mutable_message_value = Google::Protobuf::FFI.get_mutable_message @msg, field_descriptor, @arena + get_map_field(mutable_message_value[:map], field_descriptor) + end + elsif field_descriptor.repeated? + define_method(field_name) do + mutable_message_value = Google::Protobuf::FFI.get_mutable_message @msg, field_descriptor, @arena + get_repeated_field(mutable_message_value[:array], field_descriptor) + end + elsif field_descriptor.sub_message? + define_method(field_name) do + return nil unless Google::Protobuf::FFI.get_message_has @msg, field_descriptor + mutable_message = Google::Protobuf::FFI.get_mutable_message @msg, field_descriptor, @arena + sub_message = mutable_message[:msg] + sub_message_def = Google::Protobuf::FFI.get_subtype_as_message(field_descriptor) + Descriptor.send(:get_message, sub_message, sub_message_def, @arena) + end + else + c_type = field_descriptor.send(:c_type) + if c_type == :enum + define_method(field_name) do + message_value = Google::Protobuf::FFI.get_message_value @msg, field_descriptor + convert_upb_to_ruby message_value, c_type, Google::Protobuf::FFI.get_subtype_as_enum(field_descriptor) + end + else + define_method(field_name) do + message_value = Google::Protobuf::FFI.get_message_value @msg, field_descriptor + convert_upb_to_ruby message_value, c_type + end + end + end + define_method("#{field_name}=") do |value| + index_assign_internal(value, field_descriptor: field_descriptor) + end + define_method("clear_#{field_name}") do + clear_internal(field_descriptor) + end + if field_descriptor.type == :enum + define_method("#{field_name}_const") do + if field_descriptor.repeated? + return_value = [] + get_field(field_descriptor).send(:each_msg_val) do |msg_val| + return_value << msg_val[:int32_val] + end + return_value + else + message_value = Google::Protobuf::FFI.get_message_value @msg, field_descriptor + message_value[:int32_val] + end + end + end + if !field_descriptor.repeated? and field_descriptor.wrapper? + define_method("#{field_name}_as_value") do + get_field(field_descriptor, unwrap: true) + end + define_method("#{field_name}_as_value=") do |value| + if value.nil? + clear_internal(field_descriptor) + else + index_assign_internal(value, field_descriptor: field_descriptor, wrap: true) + end + end + end + if field_descriptor.has_presence? + define_method("has_#{field_name}?") do + Google::Protobuf::FFI.get_message_has(@msg, field_descriptor) + end + end + end + end + end + + def self.setup_oneof_accessors! + @oneof_field_names = [] + @descriptor.each_oneof do |oneof_descriptor| + self.add_oneof_accessors_for! oneof_descriptor + end + end + def self.add_oneof_accessors_for!(oneof_descriptor) + field_name = oneof_descriptor.name.to_sym + @oneof_field_names << field_name + unless instance_methods(true).include?(field_name) + define_method(field_name) do + field_descriptor = Google::Protobuf::FFI.get_message_which_oneof(@msg, oneof_descriptor) + if field_descriptor.nil? + return + else + return field_descriptor.name.to_sym + end + end + define_method("clear_#{field_name}") do + field_descriptor = Google::Protobuf::FFI.get_message_which_oneof(@msg, oneof_descriptor) + unless field_descriptor.nil? + clear_internal(field_descriptor) + end + end + define_method("has_#{field_name}?") do + !Google::Protobuf::FFI.get_message_which_oneof(@msg, oneof_descriptor).nil? + end + end + end + + setup_accessors! + setup_oneof_accessors! + + def self.private_constructor(arena, msg: nil, initial_value: nil) + instance = allocate + instance.send(:initialize, initial_value, arena, msg) + instance + end + + def self.inspect_field(field_descriptor, c_type, message_value) + if field_descriptor.sub_message? + sub_msg_descriptor = Google::Protobuf::FFI.get_subtype_as_message(field_descriptor) + sub_msg_descriptor.msgclass.send(:inspect_internal, message_value[:msg_val]) + else + convert_upb_to_ruby(message_value, c_type, field_descriptor.subtype).inspect + end + end + + # @param msg [::FFI::Pointer] Pointer to the Message + def self.inspect_internal(msg) + field_output = [] + descriptor.each do |field_descriptor| + next if field_descriptor.has_presence? && !Google::Protobuf::FFI.get_message_has(msg, field_descriptor) + if field_descriptor.map? + # TODO Adapted - from map#each_msg_val and map#inspect- can this be refactored to reduce echo without introducing a arena allocation? + message_descriptor = field_descriptor.subtype + key_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 1) + key_field_type = Google::Protobuf::FFI.get_type(key_field_def) + + value_field_def = Google::Protobuf::FFI.get_field_by_number(message_descriptor, 2) + value_field_type = Google::Protobuf::FFI.get_type(value_field_def) + + message_value = Google::Protobuf::FFI.get_message_value(msg, field_descriptor) + iter = ::FFI::MemoryPointer.new(:size_t, 1) + iter.write(:size_t, Google::Protobuf::FFI::Upb_Map_Begin) + key_value_pairs = [] + while Google::Protobuf::FFI.map_next(message_value[:map_val], iter) do + iter_size_t = iter.read(:size_t) + key_message_value = Google::Protobuf::FFI.map_key(message_value[:map_val], iter_size_t) + value_message_value = Google::Protobuf::FFI.map_value(message_value[:map_val], iter_size_t) + key_string = convert_upb_to_ruby(key_message_value, key_field_type).inspect + value_string = inspect_field(value_field_def, value_field_type, value_message_value) + key_value_pairs << "#{key_string}=>#{value_string}" + end + field_output << "#{field_descriptor.name}: {#{key_value_pairs.join(", ")}}" + elsif field_descriptor.repeated? + # TODO Adapted - from repeated_field#each - can this be refactored to reduce echo? + repeated_field_output = [] + message_value = Google::Protobuf::FFI.get_message_value(msg, field_descriptor) + array = message_value[:array_val] + n = array.null? ? 0 : Google::Protobuf::FFI.array_size(array) + 0.upto(n - 1) do |i| + element = Google::Protobuf::FFI.get_msgval_at(array, i) + repeated_field_output << inspect_field(field_descriptor, field_descriptor.send(:c_type), element) + end + field_output << "#{field_descriptor.name}: [#{repeated_field_output.join(", ")}]" + else + message_value = Google::Protobuf::FFI.get_message_value msg, field_descriptor + rendered_value = inspect_field(field_descriptor, field_descriptor.send(:c_type), message_value) + field_output << "#{field_descriptor.name}: #{rendered_value}" + end + end + "<#{name}: #{field_output.join(', ')}>" + end + + def self.deep_copy(msg, arena = nil) + arena ||= Google::Protobuf::FFI.create_arena + encode_internal(msg) do |encoding, size, mini_table_ptr| + message = private_constructor(arena) + if encoding.nil? or encoding.null? or Google::Protobuf::FFI.decode_message(encoding, size, message.instance_variable_get(:@msg), mini_table_ptr, nil, 0, arena) != :Ok + raise ParseError.new "Error occurred copying proto" + end + message + end + end + + def self.encode_internal(msg, encoding_options = 0) + temporary_arena = Google::Protobuf::FFI.create_arena + + mini_table_ptr = Google::Protobuf::FFI.get_mini_table(descriptor) + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + pointer_ptr = ::FFI::MemoryPointer.new(:pointer, 1) + encoding_status = Google::Protobuf::FFI.encode_message(msg, mini_table_ptr, encoding_options, temporary_arena, pointer_ptr.to_ptr, size_ptr) + raise "Encoding failed due to #{encoding_status}" unless encoding_status == :Ok + yield pointer_ptr.read(:pointer), size_ptr.read(:size_t), mini_table_ptr + end + + def method_missing_internal(method_name, *args, mode: nil) + raise ArgumentError.new "method_missing_internal called with invalid mode #{mode.inspect}" unless [:respond_to_missing?, :method_missing].include? mode + + #TODO not being allowed is not the same thing as not responding, but this is needed to pass tests + if method_name.to_s.end_with? '=' + if self.class.send(:oneof_field_names).include? method_name.to_s[0..-2].to_sym + return false if mode == :respond_to_missing? + raise RuntimeError.new "Oneof accessors are read-only." + end + end + + original_method_missing(method_name, *args) if mode == :method_missing + end + + def clear_internal(field_def) + raise FrozenError.new "can't modify frozen #{self.class}" if frozen? + Google::Protobuf::FFI.clear_message_field(@msg, field_def) + end + + def index_internal(name) + field_descriptor = self.class.descriptor.lookup(name) + get_field field_descriptor unless field_descriptor.nil? + end + + #TODO - well known types keeps us on our toes by overloading methods. + # How much of the public API needs to be defended? + def index_assign_internal(value, name: nil, field_descriptor: nil, wrap: false) + raise FrozenError.new "can't modify frozen #{self.class}" if frozen? + if field_descriptor.nil? + field_descriptor = self.class.descriptor.lookup(name) + if field_descriptor.nil? + raise ArgumentError.new "Unknown field: #{name}" + end + end + unless field_descriptor.send :set_value_on_message, value, @msg, @arena, wrap: wrap + raise RuntimeError.new "allocation failed" + end + end + + ## + # @param initial_value [Object] initial value of this Message + # @param arena [Arena] Optional; Arena where this message will be allocated + # @param msg [::FFI::Pointer] Optional; Message to initialize; creates + # one if omitted or nil. + def initialize(initial_value = nil, arena = nil, msg = nil) + @arena = arena || Google::Protobuf::FFI.create_arena + @msg = msg || Google::Protobuf::FFI.new_message_from_def(self.class.descriptor, @arena) + + unless initial_value.nil? + raise ArgumentError.new "Expected hash arguments or message, not #{initial_value.class}" unless initial_value.respond_to? :each + + field_def_ptr = ::FFI::MemoryPointer.new :pointer + oneof_def_ptr = ::FFI::MemoryPointer.new :pointer + + initial_value.each do |key, value| + raise ArgumentError.new "Expected string or symbols as hash keys when initializing proto from hash." unless [String, Symbol].include? key.class + + unless Google::Protobuf::FFI.find_msg_def_by_name self.class.descriptor, key.to_s, key.to_s.bytesize, field_def_ptr, oneof_def_ptr + raise ArgumentError.new "Unknown field name '#{key}' in initialization map entry." + end + raise NotImplementedError.new "Haven't added oneofsupport yet" unless oneof_def_ptr.get_pointer(0).null? + raise NotImplementedError.new "Expected a field def" if field_def_ptr.get_pointer(0).null? + + field_descriptor = FieldDescriptor.from_native field_def_ptr.get_pointer(0) + + next if value.nil? + if field_descriptor.map? + index_assign_internal(Google::Protobuf::Map.send(:construct_for_field, field_descriptor, @arena, value: value), name: key.to_s) + elsif field_descriptor.repeated? + index_assign_internal(RepeatedField.send(:construct_for_field, field_descriptor, @arena, values: value), name: key.to_s) + else + index_assign_internal(value, name: key.to_s) + end + end + end + + # Should always be the last expression of the initializer to avoid + # leaking references to this object before construction is complete. + Google::Protobuf::OBJECT_CACHE.try_add @msg.address, self + end + + ## + # Gets a field of this message identified by the argument definition. + # + # @param field [FieldDescriptor] Descriptor of the field to get + def get_field(field, unwrap: false) + if field.map? + mutable_message_value = Google::Protobuf::FFI.get_mutable_message @msg, field, @arena + get_map_field(mutable_message_value[:map], field) + elsif field.repeated? + mutable_message_value = Google::Protobuf::FFI.get_mutable_message @msg, field, @arena + get_repeated_field(mutable_message_value[:array], field) + elsif field.sub_message? + return nil unless Google::Protobuf::FFI.get_message_has @msg, field + sub_message_def = Google::Protobuf::FFI.get_subtype_as_message(field) + if unwrap + if field.has?(self) + wrapper_message_value = Google::Protobuf::FFI.get_message_value @msg, field + fields = Google::Protobuf::FFI.field_count(sub_message_def) + raise "Sub message has #{fields} fields! Expected exactly 1." unless fields == 1 + value_field_def = Google::Protobuf::FFI.get_field_by_number sub_message_def, 1 + message_value = Google::Protobuf::FFI.get_message_value wrapper_message_value[:msg_val], value_field_def + convert_upb_to_ruby message_value, Google::Protobuf::FFI.get_c_type(value_field_def) + else + nil + end + else + mutable_message = Google::Protobuf::FFI.get_mutable_message @msg, field, @arena + sub_message = mutable_message[:msg] + Descriptor.send(:get_message, sub_message, sub_message_def, @arena) + end + else + c_type = field.send(:c_type) + message_value = Google::Protobuf::FFI.get_message_value @msg, field + if c_type == :enum + convert_upb_to_ruby message_value, c_type, Google::Protobuf::FFI.get_subtype_as_enum(field) + else + convert_upb_to_ruby message_value, c_type + end + end + end + + ## + # @param array [::FFI::Pointer] Pointer to the Array + # @param field [Google::Protobuf::FieldDescriptor] Type of the repeated field + def get_repeated_field(array, field) + return nil if array.nil? or array.null? + repeated_field = OBJECT_CACHE.get(array.address) + if repeated_field.nil? + repeated_field = RepeatedField.send(:construct_for_field, field, @arena, array: array) + repeated_field.freeze if frozen? + end + repeated_field + end + + ## + # @param map [::FFI::Pointer] Pointer to the Map + # @param field [Google::Protobuf::FieldDescriptor] Type of the map field + def get_map_field(map, field) + return nil if map.nil? or map.null? + map_field = OBJECT_CACHE.get(map.address) + if map_field.nil? + map_field = Google::Protobuf::Map.send(:construct_for_field, field, @arena, map: map) + map_field.freeze if frozen? + end + map_field + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/method_descriptor.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/method_descriptor.rb new file mode 100755 index 0000000..b7bbf0a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/method_descriptor.rb @@ -0,0 +1,114 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2024 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class MethodDescriptor + attr :method_def, :descriptor_pool + + include Google::Protobuf::Internal::Convert + + # FFI Interface methods and setup + extend ::FFI::DataConverter + native_type ::FFI::Type::POINTER + + class << self + prepend Google::Protobuf::Internal::TypeSafety + include Google::Protobuf::Internal::PointerHelper + + # @param value [MethodDescriptor] MethodDescriptor to convert to an FFI native type + # @param _ [Object] Unused + def to_native(value, _) + method_def_ptr = value.nil? ? nil : value.instance_variable_get(:@method_def) + return ::FFI::Pointer::NULL if method_def_ptr.nil? + raise "Underlying method_def was null!" if method_def_ptr.null? + method_def_ptr + end + + ## + # @param service_def [::FFI::Pointer] MethodDef pointer to be wrapped + # @param _ [Object] Unused + def from_native(method_def, _ = nil) + return nil if method_def.nil? or method_def.null? + service_def = Google::Protobuf::FFI.raw_service_def_by_raw_method_def(method_def) + file_def = Google::Protobuf::FFI.file_def_by_raw_service_def(service_def) + descriptor_from_file_def(file_def, method_def) + end + end + + def self.new(*arguments, &block) + raise "Descriptor objects may not be created from Ruby." + end + + def to_s + inspect + end + + def inspect + "#{self.class.name}: #{name}" + end + + def name + @name ||= Google::Protobuf::FFI.get_method_name(self) + end + + def options + @options ||= begin + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + temporary_arena = Google::Protobuf::FFI.create_arena + buffer = Google::Protobuf::FFI.method_options(self, size_ptr, temporary_arena) + Google::Protobuf::MethodOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze).freeze + end + end + + def input_type + @input_type ||= Google::Protobuf::FFI.method_input_type(self) + end + + def output_type + @output_type ||= Google::Protobuf::FFI.method_output_type(self) + end + + def client_streaming + @client_streaming ||= Google::Protobuf::FFI.method_client_streaming(self) + end + + def server_streaming + @server_streaming ||= Google::Protobuf::FFI.method_server_streaming(self) + end + + private + + def initialize(method_def, descriptor_pool) + @method_def = method_def + @descriptor_pool = descriptor_pool + end + + def self.private_constructor(method_def, descriptor_pool) + instance = allocate + instance.send(:initialize, method_def, descriptor_pool) + instance + end + + def c_type + @c_type ||= Google::Protobuf::FFI.get_c_type(self) + end + end + + class FFI + # MethodDef + attach_function :raw_service_def_by_raw_method_def, :upb_MethodDef_Service, [:pointer], :pointer + attach_function :get_method_name, :upb_MethodDef_Name, [MethodDescriptor], :string + attach_function :method_options, :MethodDescriptor_serialized_options, [MethodDescriptor, :pointer, Internal::Arena], :pointer + attach_function :method_input_type, :upb_MethodDef_InputType, [MethodDescriptor], Descriptor + attach_function :method_output_type, :upb_MethodDef_OutputType, [MethodDescriptor], Descriptor + attach_function :method_client_streaming, :upb_MethodDef_ClientStreaming, [MethodDescriptor], :bool + attach_function :method_server_streaming, :upb_MethodDef_ServerStreaming, [MethodDescriptor], :bool + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/object_cache.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/object_cache.rb new file mode 100755 index 0000000..61f5c8e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/object_cache.rb @@ -0,0 +1,30 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + private + + SIZEOF_LONG = ::FFI::MemoryPointer.new(:long).size + SIZEOF_VALUE = ::FFI::Pointer::SIZE + + def self.interpreter_supports_non_finalized_keys_in_weak_map? + ! defined? JRUBY_VERSION + end + + def self.cache_implementation + if interpreter_supports_non_finalized_keys_in_weak_map? and SIZEOF_LONG >= SIZEOF_VALUE + Google::Protobuf::Internal::ObjectCache + else + Google::Protobuf::Internal::LegacyObjectCache + end + end + + public + OBJECT_CACHE = cache_implementation.new + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/oneof_descriptor.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/oneof_descriptor.rb new file mode 100755 index 0000000..65050ef --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/oneof_descriptor.rb @@ -0,0 +1,97 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2022 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class OneofDescriptor + attr :descriptor_pool, :oneof_def + include Enumerable + + # FFI Interface methods and setup + extend ::FFI::DataConverter + native_type ::FFI::Type::POINTER + + class << self + prepend Google::Protobuf::Internal::TypeSafety + include Google::Protobuf::Internal::PointerHelper + + # @param value [OneofDescriptor] FieldDescriptor to convert to an FFI native type + # @param _ [Object] Unused + def to_native(value, _ = nil) + value.instance_variable_get(:@oneof_def) || ::FFI::Pointer::NULL + end + + ## + # @param oneof_def [::FFI::Pointer] OneofDef pointer to be wrapped + # @param _ [Object] Unused + def from_native(oneof_def, _ = nil) + return nil if oneof_def.nil? or oneof_def.null? + message_descriptor = Google::Protobuf::FFI.get_oneof_containing_type oneof_def + raise RuntimeError.new "Message Descriptor is nil" if message_descriptor.nil? + file_def = Google::Protobuf::FFI.get_message_file_def message_descriptor.to_native + descriptor_from_file_def(file_def, oneof_def) + end + end + + def self.new(*arguments, &block) + raise "OneofDescriptor objects may not be created from Ruby." + end + + def name + Google::Protobuf::FFI.get_oneof_name(self) + end + + def each &block + n = Google::Protobuf::FFI.get_oneof_field_count(self) + 0.upto(n-1) do |i| + yield(Google::Protobuf::FFI.get_oneof_field_by_index(self, i)) + end + nil + end + + def options + @options ||= begin + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + temporary_arena = Google::Protobuf::FFI.create_arena + buffer = Google::Protobuf::FFI.oneof_options(self, size_ptr, temporary_arena) + opts = Google::Protobuf::OneofOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze) + opts.clear_features() + opts.freeze + end + end + + private + + def initialize(oneof_def, descriptor_pool) + @descriptor_pool = descriptor_pool + @oneof_def = oneof_def + end + + def self.private_constructor(oneof_def, descriptor_pool) + instance = allocate + instance.send(:initialize, oneof_def, descriptor_pool) + instance + end + end + + class FFI + # MessageDef + attach_function :get_oneof_by_name, :upb_MessageDef_FindOneofByNameWithSize, [Descriptor, :string, :size_t], OneofDescriptor + attach_function :get_oneof_by_index, :upb_MessageDef_Oneof, [Descriptor, :int], OneofDescriptor + + # OneofDescriptor + attach_function :get_oneof_name, :upb_OneofDef_Name, [OneofDescriptor], :string + attach_function :get_oneof_field_count, :upb_OneofDef_FieldCount, [OneofDescriptor], :int + attach_function :get_oneof_field_by_index, :upb_OneofDef_Field, [OneofDescriptor, :int], FieldDescriptor + attach_function :get_oneof_containing_type,:upb_OneofDef_ContainingType, [:pointer], Descriptor + attach_function :oneof_options, :OneOfDescriptor_serialized_options, [OneofDescriptor, :pointer, Internal::Arena], :pointer + + # FieldDescriptor + attach_function :real_containing_oneof, :upb_FieldDef_RealContainingOneof, [FieldDescriptor], OneofDescriptor + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/repeated_field.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/repeated_field.rb new file mode 100755 index 0000000..25d2ab3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/repeated_field.rb @@ -0,0 +1,385 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2008 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +# +# This class makes RepeatedField act (almost-) like a Ruby Array. +# It has convenience methods that extend the core C or Java based +# methods. +# +# This is a best-effort to mirror Array behavior. Two comments: +# 1) patches always welcome :) +# 2) if performance is an issue, feel free to rewrite the method +# in C. The source code has plenty of examples +# +# KNOWN ISSUES +# - #[]= doesn't allow less used approaches such as `arr[1, 2] = 'fizz'` +# - #concat should return the orig array +# - #push should accept multiple arguments and push them all at the same time +# +module Google + module Protobuf + class FFI + # Array + attach_function :append_array, :upb_Array_Append, [:Array, MessageValue.by_value, Internal::Arena], :bool + attach_function :get_msgval_at,:upb_Array_Get, [:Array, :size_t], MessageValue.by_value + attach_function :create_array, :upb_Array_New, [Internal::Arena, CType], :Array + attach_function :array_resize, :upb_Array_Resize, [:Array, :size_t, Internal::Arena], :bool + attach_function :array_set, :upb_Array_Set, [:Array, :size_t, MessageValue.by_value], :void + attach_function :array_size, :upb_Array_Size, [:Array], :size_t + end + + class RepeatedField + include Enumerable + + ## + # call-seq: + # RepeatedField.new(type, type_class = nil, initial_values = []) + # + # Creates a new repeated field. The provided type must be a Ruby symbol, and + # an take on the same values as those accepted by FieldDescriptor#type=. If + # the type is :message or :enum, type_class must be non-nil, and must be the + # Ruby class or module returned by Descriptor#msgclass or + # EnumDescriptor#enummodule, respectively. An initial list of elements may also + # be provided. + def self.new(type, type_class = nil, initial_values = []) + instance = allocate + # TODO This argument mangling doesn't agree with the type signature in the comments + # but is required to make unit tests pass; + if type_class.is_a?(Enumerable) and initial_values.empty? and ![:enum, :message].include?(type) + initial_values = type_class + type_class = nil + end + instance.send(:initialize, type, type_class: type_class, initial_values: initial_values) + instance + end + + ## + # call-seq: + # RepeatedField.each(&block) + # + # Invokes the block once for each element of the repeated field. RepeatedField + # also includes Enumerable; combined with this method, the repeated field thus + # acts like an ordinary Ruby sequence. + def each &block + each_msg_val do |element| + yield(convert_upb_to_ruby(element, type, descriptor, arena)) + end + self + end + + def [](*args) + count = length + if args.size < 1 + raise ArgumentError.new "Index or range is a required argument." + end + if args[0].is_a? Range + if args.size > 1 + raise ArgumentError.new "Expected 1 when passing Range argument, but got #{args.size}" + end + range = args[0] + # Handle begin-less and/or endless ranges, when supported. + index_of_first = range.respond_to?(:begin) ? range.begin : range.last + index_of_first = 0 if index_of_first.nil? + end_of_range = range.respond_to?(:end) ? range.end : range.last + index_of_last = end_of_range.nil? ? -1 : end_of_range + + if index_of_last < 0 + index_of_last += count + end + unless range.exclude_end? and !end_of_range.nil? + index_of_last += 1 + end + index_of_first += count if index_of_first < 0 + length = index_of_last - index_of_first + return [] if length.zero? + elsif args[0].is_a? Integer + index_of_first = args[0] + index_of_first += count if index_of_first < 0 + if args.size > 2 + raise ArgumentError.new "Expected 1 or 2 arguments, but got #{args.size}" + end + if args.size == 1 # No length specified, return one element + if array.null? or index_of_first < 0 or index_of_first >= count + return nil + else + return convert_upb_to_ruby(Google::Protobuf::FFI.get_msgval_at(array, index_of_first), type, descriptor, arena) + end + else + length = [args[1],count].min + end + else + raise NotImplementedError + end + + if array.null? or index_of_first < 0 or index_of_first >= count + nil + else + if index_of_first + length > count + length = count - index_of_first + end + if length < 0 + nil + else + subarray(index_of_first, length) + end + end + end + alias at [] + + + def []=(index, value) + raise FrozenError if frozen? + count = length + index += count if index < 0 + return nil if index < 0 + if index >= count + resize(index+1) + empty_message_value = Google::Protobuf::FFI::MessageValue.new # Implicitly clear + count.upto(index-1) do |i| + Google::Protobuf::FFI.array_set(array, i, empty_message_value) + end + end + Google::Protobuf::FFI.array_set(array, index, convert_ruby_to_upb(value, arena, type, descriptor)) + nil + end + + def push(*elements) + raise FrozenError if frozen? + internal_push(*elements) + end + + def <<(element) + raise FrozenError if frozen? + push element + end + + def replace(replacements) + raise FrozenError if frozen? + clear + push(*replacements) + end + + def clear + raise FrozenError if frozen? + resize 0 + self + end + + def length + array.null? ? 0 : Google::Protobuf::FFI.array_size(array) + end + alias size :length + + def freeze + return self if frozen? + super + @arena.pin self + if type == :message + each do |element| + element.freeze + end + end + self + end + + def dup + instance = self.class.allocate + instance.send(:initialize, type, descriptor: descriptor, arena: arena) + each_msg_val do |element| + instance.send(:append_msg_val, element) + end + instance + end + alias clone dup + + def ==(other) + return true if other.object_id == object_id + if other.is_a? RepeatedField + return false unless other.length == length + each_msg_val_with_index do |msg_val, i| + other_msg_val = Google::Protobuf::FFI.get_msgval_at(other.send(:array), i) + unless Google::Protobuf::FFI.message_value_equal(msg_val, other_msg_val, type, descriptor) + return false + end + end + return true + elsif other.is_a? Enumerable + return to_ary == other.to_a + end + false + end + + ## + # call-seq: + # RepeatedField.to_ary => array + # + # Used when converted implicitly into array, e.g. compared to an Array. + # Also called as a fallback of Object#to_a + def to_ary + return_value = [] + each do |element| + return_value << element + end + return_value + end + + def hash + return_value = 0 + each_msg_val do |msg_val| + return_value = Google::Protobuf::FFI.message_value_hash(msg_val, type, descriptor, return_value) + end + return_value + end + + def +(other) + if other.is_a? RepeatedField + if type != other.instance_variable_get(:@type) or descriptor != other.instance_variable_get(:@descriptor) + raise ArgumentError.new "Attempt to append RepeatedField with different element type." + end + fuse_arena(other.send(:arena)) + super_set = dup + other.send(:each_msg_val) do |msg_val| + super_set.send(:append_msg_val, msg_val) + end + super_set + elsif other.is_a? Enumerable + super_set = dup + super_set.push(*other.to_a) + else + raise ArgumentError.new "Unknown type appending to RepeatedField" + end + end + + def concat(other) + raise ArgumentError.new "Expected Enumerable, but got #{other.class}" unless other.is_a? Enumerable + push(*other.to_a) + end + + private + include Google::Protobuf::Internal::Convert + + attr :name, :arena, :array, :type, :descriptor + + def internal_push(*elements) + elements.each do |element| + append_msg_val convert_ruby_to_upb(element, arena, type, descriptor) + end + self + end + + def pop_one + raise FrozenError if frozen? + count = length + return nil if length.zero? + last_element = Google::Protobuf::FFI.get_msgval_at(array, count-1) + return_value = convert_upb_to_ruby(last_element, type, descriptor, arena) + resize(count-1) + return_value + end + + def subarray(start, length) + return_result = [] + (start..(start + length - 1)).each do |i| + element = Google::Protobuf::FFI.get_msgval_at(array, i) + return_result << convert_upb_to_ruby(element, type, descriptor, arena) + end + return_result + end + + def each_msg_val_with_index &block + n = array.null? ? 0 : Google::Protobuf::FFI.array_size(array) + 0.upto(n-1) do |i| + yield Google::Protobuf::FFI.get_msgval_at(array, i), i + end + end + + def each_msg_val &block + each_msg_val_with_index do |msg_val, _| + yield msg_val + end + end + + # @param msg_val [Google::Protobuf::FFI::MessageValue] Value to append + def append_msg_val(msg_val) + unless Google::Protobuf::FFI.append_array(array, msg_val, arena) + raise NoMemoryError.new "Could not allocate room for #{msg_val} in Arena" + end + end + + # @param new_size [Integer] New size of the array + def resize(new_size) + unless Google::Protobuf::FFI.array_resize(array, new_size, arena) + raise NoMemoryError.new "Array resize to #{new_size} failed!" + end + end + + def initialize(type, type_class: nil, initial_values: nil, name: nil, arena: nil, array: nil, descriptor: nil) + @name = name || 'RepeatedField' + raise ArgumentError.new "Expected argument type to be a Symbol" unless type.is_a? Symbol + field_number = Google::Protobuf::FFI::FieldType[type] + raise ArgumentError.new "Unsupported type '#{type}'" if field_number.nil? + if !descriptor.nil? + @descriptor = descriptor + elsif [:message, :enum].include? type + raise ArgumentError.new "Expected at least 2 arguments for message/enum." if type_class.nil? + descriptor = type_class.respond_to?(:descriptor) ? type_class.descriptor : nil + raise ArgumentError.new "Type class #{type_class} has no descriptor. Please pass a class or enum as returned by the DescriptorPool." if descriptor.nil? + @descriptor = descriptor + else + @descriptor = nil + end + @type = type + + @arena = arena || Google::Protobuf::FFI.create_arena + @array = array || Google::Protobuf::FFI.create_array(@arena, @type) + unless initial_values.nil? + unless initial_values.is_a? Enumerable + raise ArgumentError.new "Expected array as initializer value for repeated field '#{name}' (given #{initial_values.class})." + end + internal_push(*initial_values) + end + + # Should always be the last expression of the initializer to avoid + # leaking references to this object before construction is complete. + OBJECT_CACHE.try_add(@array.address, self) + end + + # @param field [FieldDescriptor] Descriptor of the field where the RepeatedField will be assigned + # @param values [Enumerable] Initial values; may be nil or empty + # @param arena [Arena] Owning message's arena + def self.construct_for_field(field, arena, values: nil, array: nil) + instance = allocate + options = {initial_values: values, name: field.name, arena: arena, array: array} + if [:enum, :message].include? field.type + options[:descriptor] = field.subtype + end + instance.send(:initialize, field.type, **options) + instance + end + + def fuse_arena(arena) + arena.fuse(arena) + end + + extend Google::Protobuf::Internal::Convert + + def self.deep_copy(repeated_field) + instance = allocate + instance.send(:initialize, repeated_field.send(:type), descriptor: repeated_field.send(:descriptor)) + instance.send(:resize, repeated_field.length) + new_array = instance.send(:array) + repeated_field.send(:each_msg_val_with_index) do |element, i| + Google::Protobuf::FFI.array_set(new_array, i, message_value_deep_copy(element, repeated_field.send(:type), repeated_field.send(:descriptor), instance.send(:arena))) + end + instance + end + + end + end +end + +require 'google/protobuf/repeated_field' diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/service_descriptor.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/service_descriptor.rb new file mode 100755 index 0000000..d8554d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/ffi/service_descriptor.rb @@ -0,0 +1,107 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2024 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + class ServiceDescriptor + attr :service_def, :descriptor_pool + include Enumerable + + include Google::Protobuf::Internal::Convert + + # FFI Interface methods and setup + extend ::FFI::DataConverter + native_type ::FFI::Type::POINTER + + class << self + prepend Google::Protobuf::Internal::TypeSafety + include Google::Protobuf::Internal::PointerHelper + + # @param value [ServiceDescriptor] ServiceDescriptor to convert to an FFI native type + # @param _ [Object] Unused + def to_native(value, _) + service_def_ptr = value.nil? ? nil : value.instance_variable_get(:@service_def) + return ::FFI::Pointer::NULL if service_def_ptr.nil? + raise "Underlying service_def was null!" if service_def_ptr.null? + service_def_ptr + end + + ## + # @param service_def [::FFI::Pointer] ServiceDef pointer to be wrapped + # @param _ [Object] Unused + def from_native(service_def, _ = nil) + return nil if service_def.nil? or service_def.null? + file_def = Google::Protobuf::FFI.file_def_by_raw_service_def(service_def) + descriptor_from_file_def(file_def, service_def) + end + end + + def self.new(*arguments, &block) + raise "Descriptor objects may not be created from Ruby." + end + + def to_s + inspect + end + + def inspect + "#{self.class.name}: #{name}" + end + + def name + @name ||= Google::Protobuf::FFI.get_service_full_name(self) + end + + def file_descriptor + @descriptor_pool.send(:get_file_descriptor, Google::Protobuf::FFI.file_def_by_raw_service_def(@service_def)) + end + + def each &block + n = Google::Protobuf::FFI.method_count(self) + 0.upto(n-1) do |i| + yield(Google::Protobuf::FFI.get_method_by_index(self, i)) + end + nil + end + + def options + @options ||= begin + size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) + temporary_arena = Google::Protobuf::FFI.create_arena + buffer = Google::Protobuf::FFI.service_options(self, size_ptr, temporary_arena) + Google::Protobuf::ServiceOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze).freeze + end + end + + private + + def initialize(service_def, descriptor_pool) + @service_def = service_def + @descriptor_pool = descriptor_pool + end + + def self.private_constructor(service_def, descriptor_pool) + instance = allocate + instance.send(:initialize, service_def, descriptor_pool) + instance + end + + def c_type + @c_type ||= Google::Protobuf::FFI.get_c_type(self) + end + end + + class FFI + # ServiceDef + attach_function :file_def_by_raw_service_def, :upb_ServiceDef_File, [:pointer], :FileDef + attach_function :get_service_full_name, :upb_ServiceDef_FullName, [ServiceDescriptor], :string + attach_function :method_count, :upb_ServiceDef_MethodCount, [ServiceDescriptor], :int + attach_function :get_method_by_index, :upb_ServiceDef_Method, [ServiceDescriptor, :int], MethodDescriptor + attach_function :service_options, :ServiceDescriptor_serialized_options, [ServiceDescriptor, :pointer, Internal::Arena], :pointer + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/field_mask_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/field_mask_pb.rb new file mode 100755 index 0000000..f241be5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/field_mask_pb.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/field_mask.proto + +require 'google/protobuf' + + +descriptor_data = "\n google/protobuf/field_mask.proto\x12\x0fgoogle.protobuf\"\x1a\n\tFieldMask\x12\r\n\x05paths\x18\x01 \x03(\tB\x85\x01\n\x13\x63om.google.protobufB\x0e\x46ieldMaskProtoP\x01Z2google.golang.org/protobuf/types/known/fieldmaskpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + FieldMask = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldMask").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/internal/object_cache.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/internal/object_cache.rb new file mode 100755 index 0000000..38e9bb5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/internal/object_cache.rb @@ -0,0 +1,99 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + module Internal + # A pointer -> Ruby Object cache that keeps references to Ruby wrapper + # objects. This allows us to look up any Ruby wrapper object by the address + # of the object it is wrapping. That way we can avoid ever creating two + # different wrapper objects for the same C object, which saves memory and + # preserves object identity. + # + # We use WeakMap for the cache. If sizeof(long) > sizeof(VALUE), we also + # need a secondary Hash to store WeakMap keys, because our pointer keys may + # need to be stored as Bignum instead of Fixnum. Since WeakMap is weak for + # both keys and values, a Bignum key will cause the WeakMap entry to be + # collected immediately unless there is another reference to the Bignum. + # This happens on 64-bit Windows, on which pointers are 64 bits but longs + # are 32 bits. In this case, we enable the secondary Hash to hold the keys + # and prevent them from being collected. + class ObjectCache + def initialize + @map = ObjectSpace::WeakMap.new + @mutex = Mutex.new + end + + def get(key) + @map[key] + end + + def try_add(key, value) + @map[key] || @mutex.synchronize do + @map[key] ||= value + end + end + end + + class LegacyObjectCache + def initialize + @secondary_map = {} + @map = ObjectSpace::WeakMap.new + @mutex = Mutex.new + end + + def get(key) + value = if secondary_key = @secondary_map[key] + @map[secondary_key] + else + @mutex.synchronize do + @map[(@secondary_map[key] ||= Object.new)] + end + end + + # GC if we could remove at least 2000 entries or 20% of the table size + # (whichever is greater). Since the cost of the GC pass is O(N), we + # want to make sure that we condition this on overall table size, to + # avoid O(N^2) CPU costs. + cutoff = (@secondary_map.size * 0.2).ceil + cutoff = 2_000 if cutoff < 2_000 + if (@secondary_map.size - @map.size) > cutoff + purge + end + + value + end + + def try_add(key, value) + if secondary_key = @secondary_map[key] + if old_value = @map[secondary_key] + return old_value + end + end + + @mutex.synchronize do + secondary_key ||= (@secondary_map[key] ||= Object.new) + @map[secondary_key] ||= value + end + end + + private + + def purge + @mutex.synchronize do + @secondary_map.each do |key, secondary_key| + unless @map.key?(secondary_key) + @secondary_map.delete(key) + end + end + end + nil + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/message_exts.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/message_exts.rb new file mode 100755 index 0000000..dd1b732 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/message_exts.rb @@ -0,0 +1,35 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2008 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +module Google + module Protobuf + module MessageExts + + #this is only called in jruby; mri loades the ClassMethods differently + def self.included(klass) + klass.extend(ClassMethods) + end + + module ClassMethods + end + + def to_json(options = {}) + self.class.encode_json(self, options) + end + + def to_proto(options = {}) + self.class.encode(self, options) + end + + end + class AbstractMessage + include MessageExts + extend MessageExts::ClassMethods + end + private_constant :AbstractMessage + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/plugin_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/plugin_pb.rb new file mode 100755 index 0000000..de3bf07 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/plugin_pb.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/compiler/plugin.proto + +require 'google/protobuf' + +require 'google/protobuf/descriptor_pb' + + +descriptor_data = "\n%google/protobuf/compiler/plugin.proto\x12\x18google.protobuf.compiler\x1a google/protobuf/descriptor.proto\"F\n\x07Version\x12\r\n\x05major\x18\x01 \x01(\x05\x12\r\n\x05minor\x18\x02 \x01(\x05\x12\r\n\x05patch\x18\x03 \x01(\x05\x12\x0e\n\x06suffix\x18\x04 \x01(\t\"\x81\x02\n\x14\x43odeGeneratorRequest\x12\x18\n\x10\x66ile_to_generate\x18\x01 \x03(\t\x12\x11\n\tparameter\x18\x02 \x01(\t\x12\x38\n\nproto_file\x18\x0f \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\x12\x45\n\x17source_file_descriptors\x18\x11 \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\x12;\n\x10\x63ompiler_version\x18\x03 \x01(\x0b\x32!.google.protobuf.compiler.Version\"\x92\x03\n\x15\x43odeGeneratorResponse\x12\r\n\x05\x65rror\x18\x01 \x01(\t\x12\x1a\n\x12supported_features\x18\x02 \x01(\x04\x12\x17\n\x0fminimum_edition\x18\x03 \x01(\x05\x12\x17\n\x0fmaximum_edition\x18\x04 \x01(\x05\x12\x42\n\x04\x66ile\x18\x0f \x03(\x0b\x32\x34.google.protobuf.compiler.CodeGeneratorResponse.File\x1a\x7f\n\x04\x46ile\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x17\n\x0finsertion_point\x18\x02 \x01(\t\x12\x0f\n\x07\x63ontent\x18\x0f \x01(\t\x12?\n\x13generated_code_info\x18\x10 \x01(\x0b\x32\".google.protobuf.GeneratedCodeInfo\"W\n\x07\x46\x65\x61ture\x12\x10\n\x0c\x46\x45\x41TURE_NONE\x10\x00\x12\x1b\n\x17\x46\x45\x41TURE_PROTO3_OPTIONAL\x10\x01\x12\x1d\n\x19\x46\x45\x41TURE_SUPPORTS_EDITIONS\x10\x02\x42r\n\x1c\x63om.google.protobuf.compilerB\x0cPluginProtosZ)google.golang.org/protobuf/types/pluginpb\xaa\x02\x18Google.Protobuf.Compiler" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + module Compiler + Version = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.Version").msgclass + CodeGeneratorRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorRequest").msgclass + CodeGeneratorResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorResponse").msgclass + CodeGeneratorResponse::File = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorResponse.File").msgclass + CodeGeneratorResponse::Feature = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorResponse.Feature").enummodule + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/repeated_field.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/repeated_field.rb new file mode 100755 index 0000000..53de122 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/repeated_field.rb @@ -0,0 +1,177 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2008 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +require 'forwardable' + +# +# This class makes RepeatedField act (almost-) like a Ruby Array. +# It has convenience methods that extend the core C or Java based +# methods. +# +# This is a best-effort to mirror Array behavior. Two comments: +# 1) patches always welcome :) +# 2) if performance is an issue, feel free to rewrite the method +# in jruby and C. The source code has plenty of examples +# +# KNOWN ISSUES +# - #[]= doesn't allow less used approaches such as `arr[1, 2] = 'fizz'` +# - #concat should return the orig array +# - #push should accept multiple arguments and push them all at the same time +# +module Google + module Protobuf + class RepeatedField + extend Forwardable + + # methods defined in C or Java: + # + + # [], at + # []= + # concat + # clear + # dup, clone + # each + # push, << + # replace + # length, size + # == + # to_ary, to_a + # also all enumerable + # + # NOTE: using delegators rather than method_missing to make the + # relationship explicit instead of implicit + def_delegators :to_ary, + :&, :*, :-, :'<=>', + :assoc, :bsearch, :bsearch_index, :combination, :compact, :count, + :cycle, :difference, :dig, :drop, :drop_while, :eql?, :fetch, :find_index, :flatten, + :include?, :index, :inspect, :intersection, :join, + :pack, :permutation, :product, :pretty_print, :pretty_print_cycle, + :rassoc, :repeated_combination, :repeated_permutation, :reverse, + :rindex, :rotate, :sample, :shuffle, :shelljoin, + :to_s, :transpose, :union, :uniq, :| + + + def first(n=nil) + if n.nil? + return self[0] + elsif n < 0 + raise ArgumentError, "negative array size" + else + return self[0...n] + end + end + + + def last(n=nil) + if n.nil? + return self[-1] + elsif n < 0 + raise ArgumentError, "negative array size" + else + start = [self.size-n, 0].max + return self[start...self.size] + end + end + + + def pop(n=nil) + if n + results = [] + n.times{ results << pop_one } + return results + else + return pop_one + end + end + + + def empty? + self.size == 0 + end + + # array aliases into enumerable + alias_method :slice, :[] + alias_method :values_at, :select + alias_method :map, :collect + + + class << self + def define_array_wrapper_method(method_name) + define_method(method_name) do |*args, &block| + arr = self.to_a + result = arr.send(method_name, *args) + self.replace(arr) + return result if result + return block ? block.call : result + end + end + private :define_array_wrapper_method + + + def define_array_wrapper_with_result_method(method_name) + define_method(method_name) do |*args, &block| + # result can be an Enumerator, Array, or nil + # Enumerator can sometimes be returned if a block is an optional argument and it is not passed in + # nil usually specifies that no change was made + result = self.to_a.send(method_name, *args, &block) + if result + new_arr = result.to_a + self.replace(new_arr) + if result.is_a?(Enumerator) + # generate a fresh enum; rewinding the exiting one, in Ruby 2.2, will + # reset the enum with the same length, but all the #next calls will + # return nil + result = new_arr.to_enum + # generate a wrapper enum so any changes which occur by a chained + # enum can be captured + ie = ProxyingEnumerator.new(self, result) + result = ie.to_enum + end + end + result + end + end + private :define_array_wrapper_with_result_method + end + + + %w(delete delete_at shift slice! unshift).each do |method_name| + define_array_wrapper_method(method_name) + end + + + %w(collect! compact! delete_if each_index fill flatten! insert reverse! + rotate! select! shuffle! sort! sort_by! uniq!).each do |method_name| + define_array_wrapper_with_result_method(method_name) + end + alias_method :keep_if, :select! + alias_method :map!, :collect! + alias_method :reject!, :delete_if + + + # propagates changes made by user of enumerator back to the original repeated field. + # This only applies in cases where the calling function which created the enumerator, + # such as #sort!, modifies itself rather than a new array, such as #sort + class ProxyingEnumerator < Struct.new(:repeated_field, :external_enumerator) + def each(*args, &block) + results = [] + external_enumerator.each_with_index do |val, i| + result = yield(val) + results << result + #nil means no change occurred from yield; usually occurs when #to_a is called + if result + repeated_field[i] = result if result != val + end + end + results + end + end + + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/source_context_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/source_context_pb.rb new file mode 100755 index 0000000..f913c6f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/source_context_pb.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/source_context.proto + +require 'google/protobuf' + + +descriptor_data = "\n$google/protobuf/source_context.proto\x12\x0fgoogle.protobuf\"\"\n\rSourceContext\x12\x11\n\tfile_name\x18\x01 \x01(\tB\x8a\x01\n\x13\x63om.google.protobufB\x12SourceContextProtoP\x01Z6google.golang.org/protobuf/types/known/sourcecontextpb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + SourceContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceContext").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/struct_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/struct_pb.rb new file mode 100755 index 0000000..5b8422c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/struct_pb.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/struct.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x1cgoogle/protobuf/struct.proto\x12\x0fgoogle.protobuf\"\x84\x01\n\x06Struct\x12\x33\n\x06\x66ields\x18\x01 \x03(\x0b\x32#.google.protobuf.Struct.FieldsEntry\x1a\x45\n\x0b\x46ieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12%\n\x05value\x18\x02 \x01(\x0b\x32\x16.google.protobuf.Value:\x02\x38\x01\"\xea\x01\n\x05Value\x12\x30\n\nnull_value\x18\x01 \x01(\x0e\x32\x1a.google.protobuf.NullValueH\x00\x12\x16\n\x0cnumber_value\x18\x02 \x01(\x01H\x00\x12\x16\n\x0cstring_value\x18\x03 \x01(\tH\x00\x12\x14\n\nbool_value\x18\x04 \x01(\x08H\x00\x12/\n\x0cstruct_value\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x12\x30\n\nlist_value\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.ListValueH\x00\x42\x06\n\x04kind\"3\n\tListValue\x12&\n\x06values\x18\x01 \x03(\x0b\x32\x16.google.protobuf.Value*\x1b\n\tNullValue\x12\x0e\n\nNULL_VALUE\x10\x00\x42\x7f\n\x13\x63om.google.protobufB\x0bStructProtoP\x01Z/google.golang.org/protobuf/types/known/structpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + Struct = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Struct").msgclass + Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Value").msgclass + ListValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ListValue").msgclass + NullValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.NullValue").enummodule + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/timestamp_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/timestamp_pb.rb new file mode 100755 index 0000000..e3c9e07 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/timestamp_pb.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/timestamp.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x1fgoogle/protobuf/timestamp.proto\x12\x0fgoogle.protobuf\"+\n\tTimestamp\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\x12\r\n\x05nanos\x18\x02 \x01(\x05\x42\x85\x01\n\x13\x63om.google.protobufB\x0eTimestampProtoP\x01Z2google.golang.org/protobuf/types/known/timestamppb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + Timestamp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Timestamp").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/type_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/type_pb.rb new file mode 100755 index 0000000..b921d45 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/type_pb.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/type.proto + +require 'google/protobuf' + +require 'google/protobuf/any_pb' +require 'google/protobuf/source_context_pb' + + +descriptor_data = "\n\x1agoogle/protobuf/type.proto\x12\x0fgoogle.protobuf\x1a\x19google/protobuf/any.proto\x1a$google/protobuf/source_context.proto\"\xe8\x01\n\x04Type\x12\x0c\n\x04name\x18\x01 \x01(\t\x12&\n\x06\x66ields\x18\x02 \x03(\x0b\x32\x16.google.protobuf.Field\x12\x0e\n\x06oneofs\x18\x03 \x03(\t\x12(\n\x07options\x18\x04 \x03(\x0b\x32\x17.google.protobuf.Option\x12\x36\n\x0esource_context\x18\x05 \x01(\x0b\x32\x1e.google.protobuf.SourceContext\x12\'\n\x06syntax\x18\x06 \x01(\x0e\x32\x17.google.protobuf.Syntax\x12\x0f\n\x07\x65\x64ition\x18\x07 \x01(\t\"\xd5\x05\n\x05\x46ield\x12)\n\x04kind\x18\x01 \x01(\x0e\x32\x1b.google.protobuf.Field.Kind\x12\x37\n\x0b\x63\x61rdinality\x18\x02 \x01(\x0e\x32\".google.protobuf.Field.Cardinality\x12\x0e\n\x06number\x18\x03 \x01(\x05\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\x10\n\x08type_url\x18\x06 \x01(\t\x12\x13\n\x0boneof_index\x18\x07 \x01(\x05\x12\x0e\n\x06packed\x18\x08 \x01(\x08\x12(\n\x07options\x18\t \x03(\x0b\x32\x17.google.protobuf.Option\x12\x11\n\tjson_name\x18\n \x01(\t\x12\x15\n\rdefault_value\x18\x0b \x01(\t\"\xc8\x02\n\x04Kind\x12\x10\n\x0cTYPE_UNKNOWN\x10\x00\x12\x0f\n\x0bTYPE_DOUBLE\x10\x01\x12\x0e\n\nTYPE_FLOAT\x10\x02\x12\x0e\n\nTYPE_INT64\x10\x03\x12\x0f\n\x0bTYPE_UINT64\x10\x04\x12\x0e\n\nTYPE_INT32\x10\x05\x12\x10\n\x0cTYPE_FIXED64\x10\x06\x12\x10\n\x0cTYPE_FIXED32\x10\x07\x12\r\n\tTYPE_BOOL\x10\x08\x12\x0f\n\x0bTYPE_STRING\x10\t\x12\x0e\n\nTYPE_GROUP\x10\n\x12\x10\n\x0cTYPE_MESSAGE\x10\x0b\x12\x0e\n\nTYPE_BYTES\x10\x0c\x12\x0f\n\x0bTYPE_UINT32\x10\r\x12\r\n\tTYPE_ENUM\x10\x0e\x12\x11\n\rTYPE_SFIXED32\x10\x0f\x12\x11\n\rTYPE_SFIXED64\x10\x10\x12\x0f\n\x0bTYPE_SINT32\x10\x11\x12\x0f\n\x0bTYPE_SINT64\x10\x12\"t\n\x0b\x43\x61rdinality\x12\x17\n\x13\x43\x41RDINALITY_UNKNOWN\x10\x00\x12\x18\n\x14\x43\x41RDINALITY_OPTIONAL\x10\x01\x12\x18\n\x14\x43\x41RDINALITY_REQUIRED\x10\x02\x12\x18\n\x14\x43\x41RDINALITY_REPEATED\x10\x03\"\xdf\x01\n\x04\x45num\x12\x0c\n\x04name\x18\x01 \x01(\t\x12-\n\tenumvalue\x18\x02 \x03(\x0b\x32\x1a.google.protobuf.EnumValue\x12(\n\x07options\x18\x03 \x03(\x0b\x32\x17.google.protobuf.Option\x12\x36\n\x0esource_context\x18\x04 \x01(\x0b\x32\x1e.google.protobuf.SourceContext\x12\'\n\x06syntax\x18\x05 \x01(\x0e\x32\x17.google.protobuf.Syntax\x12\x0f\n\x07\x65\x64ition\x18\x06 \x01(\t\"S\n\tEnumValue\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x02 \x01(\x05\x12(\n\x07options\x18\x03 \x03(\x0b\x32\x17.google.protobuf.Option\";\n\x06Option\x12\x0c\n\x04name\x18\x01 \x01(\t\x12#\n\x05value\x18\x02 \x01(\x0b\x32\x14.google.protobuf.Any*C\n\x06Syntax\x12\x11\n\rSYNTAX_PROTO2\x10\x00\x12\x11\n\rSYNTAX_PROTO3\x10\x01\x12\x13\n\x0fSYNTAX_EDITIONS\x10\x02\x42{\n\x13\x63om.google.protobufB\tTypeProtoP\x01Z-google.golang.org/protobuf/types/known/typepb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Type").msgclass + Field = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field").msgclass + Field::Kind = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Kind").enummodule + Field::Cardinality = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Cardinality").enummodule + Enum = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Enum").msgclass + EnumValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValue").msgclass + Option = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Option").msgclass + Syntax = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Syntax").enummodule + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/well_known_types.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/well_known_types.rb new file mode 100755 index 0000000..c2df723 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/well_known_types.rb @@ -0,0 +1,211 @@ +#!/usr/bin/ruby +# Protocol Buffers - Google's data interchange format +# Copyright 2008 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +require 'google/protobuf/any_pb' +require 'google/protobuf/duration_pb' +require 'google/protobuf/field_mask_pb' +require 'google/protobuf/struct_pb' +require 'google/protobuf/timestamp_pb' + +module Google + module Protobuf + + Any.class_eval do + def self.pack(msg, type_url_prefix='type.googleapis.com/') + any = self.new + any.pack(msg, type_url_prefix) + any + end + + def pack(msg, type_url_prefix='type.googleapis.com/') + if type_url_prefix.empty? or type_url_prefix[-1] != '/' then + self.type_url = "#{type_url_prefix}/#{msg.class.descriptor.name}" + else + self.type_url = "#{type_url_prefix}#{msg.class.descriptor.name}" + end + self.value = msg.to_proto + end + + def unpack(klass) + if self.is(klass) then + klass.decode(self.value) + else + nil + end + end + + def type_name + return self.type_url.split("/")[-1] + end + + def is(klass) + return self.type_name == klass.descriptor.name + end + end + + Timestamp.class_eval do + def to_time + Time.at(seconds, nanos, :nanosecond) + end + + def self.from_time(time) + new.from_time(time) + end + + def from_time(time) + self.seconds = time.to_i + self.nanos = time.nsec + self + end + + def to_i + self.seconds + end + + def to_f + self.seconds + (self.nanos.quo(1_000_000_000)) + end + end + + Duration.class_eval do + def to_f + self.seconds + (self.nanos.to_f / 1_000_000_000) + end + end + + class UnexpectedStructType < Google::Protobuf::Error; end + + Value.class_eval do + def to_ruby(recursive = false) + case self.kind + when :struct_value + if recursive + self.struct_value.to_h + else + self.struct_value + end + when :list_value + if recursive + self.list_value.to_a + else + self.list_value + end + when :null_value + nil + when :number_value + self.number_value + when :string_value + self.string_value + when :bool_value + self.bool_value + else + raise UnexpectedStructType + end + end + + def self.from_ruby(value) + self.new.from_ruby(value) + end + + def from_ruby(value) + case value + when NilClass + self.null_value = :NULL_VALUE + when Numeric + self.number_value = value + when String + self.string_value = value + when TrueClass + self.bool_value = true + when FalseClass + self.bool_value = false + when Struct + self.struct_value = value + when Hash + self.struct_value = Struct.from_hash(value) + when ListValue + self.list_value = value + when Array + self.list_value = ListValue.from_a(value) + else + raise UnexpectedStructType + end + + self + end + end + + Struct.class_eval do + def [](key) + self.fields[key].to_ruby + rescue NoMethodError + nil + end + + def []=(key, value) + unless key.is_a?(String) + raise UnexpectedStructType, "Struct keys must be strings." + end + self.fields[key] ||= Google::Protobuf::Value.new + self.fields[key].from_ruby(value) + end + + def to_h + ret = {} + self.fields.each { |key, val| ret[key] = val.to_ruby(true) } + ret + end + + def self.from_hash(hash) + ret = Struct.new + hash.each { |key, val| ret[key] = val } + ret + end + + def has_key?(key) + self.fields.has_key?(key) + end + end + + ListValue.class_eval do + include Enumerable + + def length + self.values.length + end + + def [](index) + self.values[index].to_ruby + end + + def []=(index, value) + self.values[index].from_ruby(value) + end + + def <<(value) + wrapper = Google::Protobuf::Value.new + wrapper.from_ruby(value) + self.values << wrapper + end + + def each + self.values.each { |x| yield(x.to_ruby) } + end + + def to_a + self.values.map { |x| x.to_ruby(true) } + end + + def self.from_a(arr) + ret = ListValue.new + arr.each { |val| ret << val } + ret + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/wrappers_pb.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/wrappers_pb.rb new file mode 100755 index 0000000..dda2a15 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf/wrappers_pb.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/wrappers.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x1egoogle/protobuf/wrappers.proto\x12\x0fgoogle.protobuf\"\x1c\n\x0b\x44oubleValue\x12\r\n\x05value\x18\x01 \x01(\x01\"\x1b\n\nFloatValue\x12\r\n\x05value\x18\x01 \x01(\x02\"\x1b\n\nInt64Value\x12\r\n\x05value\x18\x01 \x01(\x03\"\x1c\n\x0bUInt64Value\x12\r\n\x05value\x18\x01 \x01(\x04\"\x1b\n\nInt32Value\x12\r\n\x05value\x18\x01 \x01(\x05\"\x1c\n\x0bUInt32Value\x12\r\n\x05value\x18\x01 \x01(\r\"\x1a\n\tBoolValue\x12\r\n\x05value\x18\x01 \x01(\x08\"\x1c\n\x0bStringValue\x12\r\n\x05value\x18\x01 \x01(\t\"\x1b\n\nBytesValue\x12\r\n\x05value\x18\x01 \x01(\x0c\x42\x83\x01\n\x13\x63om.google.protobufB\rWrappersProtoP\x01Z1google.golang.org/protobuf/types/known/wrapperspb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Protobuf + DoubleValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass + FloatValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass + Int64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass + UInt64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass + Int32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass + UInt32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass + BoolValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass + StringValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass + BytesValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf_ffi.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf_ffi.rb new file mode 100755 index 0000000..6580df4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf_ffi.rb @@ -0,0 +1,51 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +require 'ffi-compiler/loader' +require 'google/protobuf/ffi/ffi' +require 'google/protobuf/ffi/internal/type_safety' +require 'google/protobuf/ffi/internal/pointer_helper' +require 'google/protobuf/ffi/internal/arena' +require 'google/protobuf/ffi/internal/convert' +require 'google/protobuf/ffi/descriptor' +require 'google/protobuf/ffi/enum_descriptor' +require 'google/protobuf/ffi/field_descriptor' +require 'google/protobuf/ffi/oneof_descriptor' +require 'google/protobuf/ffi/method_descriptor' +require 'google/protobuf/ffi/service_descriptor' +require 'google/protobuf/ffi/descriptor_pool' +require 'google/protobuf/ffi/file_descriptor' +require 'google/protobuf/ffi/map' +require 'google/protobuf/ffi/object_cache' +require 'google/protobuf/ffi/repeated_field' +require 'google/protobuf/ffi/message' + +module Google + module Protobuf + def self.deep_copy(object) + case object + when RepeatedField + RepeatedField.send(:deep_copy, object) + when Google::Protobuf::Map + Google::Protobuf::Map.deep_copy(object) + when Google::Protobuf::MessageExts + object.class.send(:deep_copy, object.instance_variable_get(:@msg)) + else + raise NotImplementedError + end + end + + def self.discard_unknown(message) + raise FrozenError if message.frozen? + raise ArgumentError.new "Expected message, got #{message.class} instead." if message.instance_variable_get(:@msg).nil? + unless Google::Protobuf::FFI.message_discard_unknown(message.instance_variable_get(:@msg), message.class.descriptor, 128) + raise RuntimeError.new "Messages nested too deeply." + end + nil + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf_native.rb b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf_native.rb new file mode 100755 index 0000000..9605b6b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/protobuf_native.rb @@ -0,0 +1,19 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +if RUBY_PLATFORM == "java" + require 'json' + require 'google/protobuf_java' +else + begin + require "google/#{RUBY_VERSION.sub(/\.\d+$/, '')}/protobuf_c" + rescue LoadError + require 'google/protobuf_c' + end +end + +require 'google/protobuf/repeated_field' diff --git a/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/tasks/ffi.rake b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/tasks/ffi.rake new file mode 100755 index 0000000..5de10a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/google-protobuf-4.27.3-x86_64-linux/lib/google/tasks/ffi.rake @@ -0,0 +1,100 @@ +# # @param task [FFI::Compiler::CompileTask] task to configure +def configure_common_compile_task(task) + if FileUtils.pwd.include? 'ext' + src_dir = '.' + third_party_path = 'third_party/utf8_range' + else + src_dir = 'ext/google/protobuf_c' + third_party_path = 'ext/google/protobuf_c/third_party/utf8_range' + end + + task.add_include_path third_party_path + task.add_define 'NDEBUG' + task.cflags << "-std=gnu99 -O3" + [ + :convert, :defs, :map, :message, :protobuf, :repeated_field, :wrap_memcpy + ].each { |file| task.exclude << "/#{file}.c" } + task.ext_dir = src_dir + task.source_dirs = [src_dir] + if RbConfig::CONFIG['target_os'] =~ /darwin|linux/ + task.cflags << "-Wall -Wsign-compare -Wno-declaration-after-statement" + end +end + +# FFI::CompilerTask's constructor walks the filesystem at task definition time +# to create subtasks for each source file, so files from third_party must be +# copied into place before the task is defined for it to work correctly. +# TODO Is there a sane way to check for generated protos under lib too? +def with_generated_files + expected_path = FileUtils.pwd.include?('ext') ? 'third_party/utf8_range' : 'ext/google/protobuf_c/third_party/utf8_range' + if File.directory?(expected_path) + yield + else + task :default do + # It is possible, especially in cases like the first invocation of + # `rake test` following `rake clean` or a fresh checkout that the + # `copy_third_party` task has been executed since initial task definition. + # If so, run the task definition block now and invoke it explicitly. + if File.directory?(expected_path) + yield + Rake::Task[:default].invoke + else + raise "Missing directory #{File.absolute_path(expected_path)}." + + " Did you forget to run `rake copy_third_party` before building" + + " native extensions?" + end + end + end +end + +begin + require "ffi-compiler/compile_task" + + desc "Compile Protobuf library for FFI" + namespace "ffi-protobuf" do + with_generated_files do + # Compile Ruby UPB separately in order to limit use of -DUPB_BUILD_API to one + # compilation unit. + desc "Compile UPB library for FFI" + namespace "ffi-upb" do + with_generated_files do + FFI::Compiler::CompileTask.new('ruby-upb') do |c| + configure_common_compile_task c + c.add_define "UPB_BUILD_API" + c.exclude << "/glue.c" + c.exclude << "/shared_message.c" + c.exclude << "/shared_convert.c" + if RbConfig::CONFIG['target_os'] =~ /darwin|linux/ + c.cflags << "-fvisibility=hidden" + end + end + end + end + + FFI::Compiler::CompileTask.new 'protobuf_c_ffi' do |c| + configure_common_compile_task c + # Ruby UPB was already compiled with different flags. + c.exclude << "/utf8_range.c" + c.exclude << "/ruby-upb.c" + end + + # Setup dependencies so that the .o files generated by building ffi-upb are + # available to link here. + # TODO Can this be simplified? Can the single shared library be used + # instead of the object files? + protobuf_c_task = Rake::Task[:default] + protobuf_c_shared_lib_task = Rake::Task[protobuf_c_task.prereqs.last] + ruby_upb_shared_lib_task = Rake::Task[:"ffi-upb:default"].prereqs.first + Rake::Task[ruby_upb_shared_lib_task].prereqs.each do |dependency| + protobuf_c_shared_lib_task.prereqs.prepend dependency + end + end + end +rescue LoadError + desc "Compile Protobuf library for FFI" + namespace "ffi-protobuf" do + task :default do + warn "Skipping build of FFI; `gem install ffi-compiler` to enable." + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.github/workflows/linux.yml b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.github/workflows/linux.yml new file mode 100644 index 0000000..eaa94b1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.github/workflows/linux.yml @@ -0,0 +1,23 @@ +name: Testing on Ubuntu +on: + - push + - pull_request +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + ruby: [ '2.6', '2.7', '3.0' ] + os: [ 'ubuntu-latest' ] + name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: unit testing + run: | + gem install bundler rake + bundle install --jobs 4 --retry 3 + bundle exec rake diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.github/workflows/windows.yml b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.github/workflows/windows.yml new file mode 100644 index 0000000..133fa9a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.github/workflows/windows.yml @@ -0,0 +1,23 @@ +name: Testing on Windows +on: + - push + - pull_request +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + ruby: [ '2.6', '2.7', '3.0' ] + os: [ 'windows-latest' ] + name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: unit testing + run: | + gem install bundler rake + bundle install --jobs 4 --retry 3 + bundle exec rake diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.gitignore b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.gitignore new file mode 100644 index 0000000..e887a3e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.gitignore @@ -0,0 +1,12 @@ +*.bundle +*.bundle +*.gem +*.jar +*.o +*.rbc +*.so +*.swp +Gemfile.lock +Makefile +tags +tmp diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.gitmodules b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.gitmodules new file mode 100644 index 0000000..7e46b5c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/.gitmodules @@ -0,0 +1,6 @@ +[submodule "http-parser"] + path = ext/ruby_http_parser/vendor/http-parser + url = https://github.com/nodejs/http-parser.git +[submodule "http-parser-java"] + path = ext/ruby_http_parser/vendor/http-parser-java + url = https://github.com/tmm1/http-parser.java diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/Gemfile b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/Gemfile new file mode 100644 index 0000000..851fabc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gemspec diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/LICENSE-MIT b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/LICENSE-MIT new file mode 100644 index 0000000..35f0bf0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/LICENSE-MIT @@ -0,0 +1,20 @@ +Copyright 2009,2010 Marc-André Cournoyer +Copyright 2010,2011 Aman Gupta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/README.md b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/README.md new file mode 100644 index 0000000..e29ef2c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/README.md @@ -0,0 +1,90 @@ +# http_parser.rb + +A simple callback-based HTTP request/response parser for writing http +servers, clients and proxies. + +This gem is built on top of [joyent/http-parser](https://github.com/joyent/http-parser) and its java port [http-parser/http-parser.java](https://github.com/http-parser/http-parser.java). + +## Supported Platforms + +This gem aims to work on all major Ruby platforms, including: + +- MRI 1.8, 1.9 and 2.0; should work on MRI 2.4+ +- Rubinius +- JRuby +- win32 + +## Usage + +```ruby +require "http/parser" + +parser = Http::Parser.new + +parser.on_headers_complete = proc do + p parser.http_version + + p parser.http_method # for requests + p parser.request_url + + p parser.status_code # for responses + + p parser.headers +end + +parser.on_body = proc do |chunk| + # One chunk of the body + p chunk +end + +parser.on_message_complete = proc do |env| + # Headers and body is all parsed + puts "Done!" +end +``` + +# Feed raw data from the socket to the parser +`parser << raw_data` + +## Advanced Usage + +### Accept callbacks on an object + +```ruby +module MyHttpConnection + def connection_completed + @parser = Http::Parser.new(self) + end + + def receive_data(data) + @parser << data + end + + def on_message_begin + @headers = nil + @body = '' + end + + def on_headers_complete(headers) + @headers = headers + end + + def on_body(chunk) + @body << chunk + end + + def on_message_complete + p [@headers, @body] + end +end +``` + +### Stop parsing after headers + +```ruby +parser = Http::Parser.new +parser.on_headers_complete = proc{ :stop } + +offset = parser << request_data +body = request_data[offset..-1] +``` diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/Rakefile b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/Rakefile new file mode 100644 index 0000000..1820ad1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/Rakefile @@ -0,0 +1,8 @@ +require 'bundler/gem_tasks' + +# default task +task :compile => :submodules +task :default => [:compile, :spec] + +# load tasks +Dir['tasks/*.rake'].sort.each { |f| load f } diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/bench/standalone.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/bench/standalone.rb new file mode 100755 index 0000000..6b4dcb6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/bench/standalone.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +$:.unshift File.dirname(__FILE__) + "/../lib" +require "rubygems" +require "http/parser" +require "benchmark/ips" + +request = <<-REQUEST +GET / HTTP/1.1 +Host: www.example.com +Connection: keep-alive +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 S +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Encoding: gzip,deflate,sdch +Accept-Language: en-US,en;q=0.8 +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 + +REQUEST +request.gsub!(/\n/m, "\r\n") + +Benchmark.ips do |ips| + ips.report("instance") { Http::Parser.new } + ips.report("parsing") { Http::Parser.new << request } +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/bench/thin.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/bench/thin.rb new file mode 100644 index 0000000..fe0dd6d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/bench/thin.rb @@ -0,0 +1,58 @@ +$:.unshift File.dirname(__FILE__) + "/../lib" +require "rubygems" +require "thin_parser" +require "http_parser" +require "benchmark" +require "stringio" + +data = "POST /postit HTTP/1.1\r\n" + + "Host: localhost:3000\r\n" + + "User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9\r\n" + + "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n" + + "Accept-Language: en-us,en;q=0.5\r\n" + + "Accept-Encoding: gzip,deflate\r\n" + + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" + + "Keep-Alive: 300\r\n" + + "Connection: keep-alive\r\n" + + "Content-Type: text/html\r\n" + + "Content-Length: 37\r\n" + + "\r\n" + + "name=marc&email=macournoyer@gmail.com" + +def thin(data) + env = {"rack.input" => StringIO.new} + Thin::HttpParser.new.execute(env, data, 0) + env +end + +def http_parser(data) + body = StringIO.new + env = nil + + parser = HTTP::RequestParser.new + parser.on_headers_complete = proc { |e| env = e } + parser.on_body = proc { |c| body << c } + parser << data + + env["rack-input"] = body + env +end + +# p thin(data) +# p http_parser(data) + +TESTS = 30_000 +Benchmark.bmbm do |results| + results.report("thin:") { TESTS.times { thin data } } + results.report("http-parser:") { TESTS.times { http_parser data } } +end + +# On my MBP core duo 2.2Ghz +# Rehearsal ------------------------------------------------ +# thin: 1.470000 0.000000 1.470000 ( 1.474737) +# http-parser: 1.270000 0.020000 1.290000 ( 1.292758) +# --------------------------------------- total: 2.760000sec +# +# user system total real +# thin: 1.150000 0.030000 1.180000 ( 1.173767) +# http-parser: 1.250000 0.010000 1.260000 ( 1.263796) diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/.gitignore b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/.gitignore new file mode 100644 index 0000000..cb899d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/.gitignore @@ -0,0 +1 @@ +ryah_http_parser.* diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/RubyHttpParserService.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/RubyHttpParserService.java new file mode 100644 index 0000000..2ea3e8e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/RubyHttpParserService.java @@ -0,0 +1,18 @@ +import java.io.IOException; + +import org.jruby.Ruby; +import org.jruby.RubyClass; +import org.jruby.RubyModule; +import org.jruby.runtime.load.BasicLibraryService; + +import org.ruby_http_parser.*; + +public class RubyHttpParserService implements BasicLibraryService { + public boolean basicLoad(final Ruby runtime) throws IOException { + RubyModule mHTTP = runtime.defineModule("HTTP"); + RubyClass cParser = mHTTP.defineClassUnder("Parser", runtime.getObject(), RubyHttpParser.ALLOCATOR); + cParser.defineAnnotatedMethods(RubyHttpParser.class); + cParser.defineClassUnder("Error", runtime.getClass("IOError"),runtime.getClass("IOError").getAllocator()); + return true; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/ext_help.h b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/ext_help.h new file mode 100644 index 0000000..a919dff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/ext_help.h @@ -0,0 +1,18 @@ +#ifndef ext_help_h +#define ext_help_h + +#define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "NULL found for " # T " when shouldn't be."); +#define DATA_GET(from,type,name) Data_Get_Struct(from,type,name); RAISE_NOT_NULL(name); +#define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "Wrong argument type for " # V " required " # T); + +/* for compatibility with Ruby 1.8.5, which doesn't declare RSTRING_PTR */ +#ifndef RSTRING_PTR +#define RSTRING_PTR(s) (RSTRING(s)->ptr) +#endif + +/* for compatibility with Ruby 1.8.5, which doesn't declare RSTRING_LEN */ +#ifndef RSTRING_LEN +#define RSTRING_LEN(s) (RSTRING(s)->len) +#endif + +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/extconf.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/extconf.rb new file mode 100644 index 0000000..0433f9b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/extconf.rb @@ -0,0 +1,24 @@ +require 'mkmf' + +# check out code if it hasn't been already +if Dir[File.expand_path('../vendor/http-parser/*', __FILE__)].empty? + Dir.chdir(File.expand_path('../../../', __FILE__)) do + xsystem 'git submodule init' + xsystem 'git submodule update' + end +end + +# mongrel and http-parser both define http_parser_(init|execute), so we +# rename functions in http-parser before using them. +vendor_dir = File.expand_path('../vendor/http-parser/', __FILE__) +src_dir = File.expand_path('../', __FILE__) +%w[ http_parser.c http_parser.h ].each do |file| + File.open(File.join(src_dir, "ryah_#{file}"), 'w'){ |f| + f.write File.read(File.join(vendor_dir, file)).gsub('http_parser', 'ryah_http_parser') + } +end + +$CFLAGS << " -I\"#{src_dir}\"" + +dir_config("ruby_http_parser") +create_makefile("ruby_http_parser") diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/org/ruby_http_parser/RubyHttpParser.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/org/ruby_http_parser/RubyHttpParser.java new file mode 100644 index 0000000..1b97269 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/org/ruby_http_parser/RubyHttpParser.java @@ -0,0 +1,502 @@ +package org.ruby_http_parser; + +import http_parser.HTTPException; +import http_parser.HTTPMethod; +import http_parser.HTTPParser; +import http_parser.lolevel.HTTPCallback; +import http_parser.lolevel.HTTPDataCallback; +import http_parser.lolevel.ParserSettings; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; + +import org.jcodings.Encoding; +import org.jcodings.specific.UTF8Encoding; +import org.jruby.Ruby; +import org.jruby.RubyArray; +import org.jruby.RubyClass; +import org.jruby.RubyHash; +import org.jruby.RubyNumeric; +import org.jruby.RubyObject; +import org.jruby.RubyString; +import org.jruby.RubySymbol; +import org.jruby.anno.JRubyMethod; +import org.jruby.exceptions.RaiseException; +import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.ThreadContext; +import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.util.ByteList; + +public class RubyHttpParser extends RubyObject { + + @JRubyMethod(name = "strict?", module = true) + public static IRubyObject strict(IRubyObject recv) { + return recv.getRuntime().newBoolean(true); + } + + public static ObjectAllocator ALLOCATOR = new ObjectAllocator() { + public IRubyObject allocate(Ruby runtime, RubyClass klass) { + return new RubyHttpParser(runtime, klass); + } + }; + + byte[] fetchBytes(ByteBuffer b, int pos, int len) { + byte[] by = new byte[len]; + int saved = b.position(); + b.position(pos); + b.get(by); + b.position(saved); + return by; + } + + public class StopException extends RuntimeException { + } + + private Ruby runtime; + private HTTPParser parser; + private ParserSettings settings; + + private RubyClass eParserError; + + private RubyHash headers; + + private IRubyObject on_message_begin; + private IRubyObject on_headers_complete; + private IRubyObject on_body; + private IRubyObject on_message_complete; + + private IRubyObject requestUrl; + private IRubyObject requestPath; + private IRubyObject queryString; + private IRubyObject fragment; + + private IRubyObject header_value_type; + private IRubyObject upgradeData; + + private IRubyObject callback_object; + + private boolean completed; + + private byte[] _current_header; + private byte[] _last_header; + + private static final Encoding UTF8 = UTF8Encoding.INSTANCE; + + private static final List VALUE_TYPES = new ArrayList( + Arrays.asList("mixed", "arrays", "strings") + ); + + public RubyHttpParser(final Ruby runtime, RubyClass clazz) { + super(runtime, clazz); + + this.runtime = runtime; + this.eParserError = (RubyClass) runtime.getModule("HTTP").getClass("Parser").getConstant("Error"); + + this.on_message_begin = null; + this.on_headers_complete = null; + this.on_body = null; + this.on_message_complete = null; + + this.callback_object = null; + + this.completed = false; + + this.header_value_type = runtime.getModule("HTTP").getClass("Parser") + .getInstanceVariable("@default_header_value_type"); + + initSettings(); + init(); + } + + private void initSettings() { + this.settings = new ParserSettings(); + + this.settings.on_url = new HTTPDataCallback() { + public int cb(http_parser.lolevel.HTTPParser p, ByteBuffer buf, int pos, int len) { + byte[] data = fetchBytes(buf, pos, len); + if (runtime.is1_9() || runtime.is2_0()) { + ((RubyString) requestUrl).cat(data, 0, data.length, UTF8); + } else { + ((RubyString) requestUrl).cat(data); + } + return 0; + } + }; + + this.settings.on_header_field = new HTTPDataCallback() { + public int cb(http_parser.lolevel.HTTPParser p, ByteBuffer buf, int pos, int len) { + byte[] data = fetchBytes(buf, pos, len); + + if (_current_header == null) + _current_header = data; + else { + byte[] tmp = new byte[_current_header.length + data.length]; + System.arraycopy(_current_header, 0, tmp, 0, _current_header.length); + System.arraycopy(data, 0, tmp, _current_header.length, data.length); + _current_header = tmp; + } + + return 0; + } + }; + final RubySymbol arraysSym = runtime.newSymbol("arrays"); + final RubySymbol mixedSym = runtime.newSymbol("mixed"); + final RubySymbol stopSym = runtime.newSymbol("stop"); + final RubySymbol resetSym = runtime.newSymbol("reset"); + this.settings.on_header_value = new HTTPDataCallback() { + public int cb(http_parser.lolevel.HTTPParser p, ByteBuffer buf, int pos, int len) { + byte[] data = fetchBytes(buf, pos, len); + ThreadContext context = headers.getRuntime().getCurrentContext(); + IRubyObject key, val; + int new_field = 0; + + if (_current_header != null) { + new_field = 1; + _last_header = _current_header; + _current_header = null; + } + + key = RubyString.newString(runtime, new ByteList(_last_header, UTF8, false)); + val = headers.op_aref(context, key); + + if (new_field == 1) { + if (val.isNil()) { + if (header_value_type == arraysSym) { + headers.op_aset(context, key, + RubyArray.newArrayLight(runtime, RubyString.newStringLight(runtime, 10, UTF8))); + } else { + headers.op_aset(context, key, RubyString.newStringLight(runtime, 10, UTF8)); + } + } else { + if (header_value_type == mixedSym) { + if (val instanceof RubyString) { + headers.op_aset(context, key, + RubyArray.newArrayLight(runtime, val, RubyString.newStringLight(runtime, 10, UTF8))); + } else { + ((RubyArray) val).add(RubyString.newStringLight(runtime, 10, UTF8)); + } + } else if (header_value_type == arraysSym) { + ((RubyArray) val).add(RubyString.newStringLight(runtime, 10, UTF8)); + } else { + if (runtime.is1_9() || runtime.is2_0()) { + ((RubyString) val).cat(',', UTF8).cat(' ', UTF8); + } else { + ((RubyString) val).cat(',').cat(' '); + } + } + } + val = headers.op_aref(context, key); + } + + if (val instanceof RubyArray) { + val = ((RubyArray) val).entry(-1); + } + + if (runtime.is1_9() || runtime.is2_0()) { + ((RubyString) val).cat(data, 0, data.length, UTF8); + } else { + ((RubyString) val).cat(data); + } + + return 0; + } + }; + + this.settings.on_message_begin = new HTTPCallback() { + public int cb(http_parser.lolevel.HTTPParser p) { + headers = new RubyHash(runtime); + + if (runtime.is1_9() || runtime.is2_0()) { + requestUrl = RubyString.newEmptyString(runtime, UTF8); + requestPath = RubyString.newEmptyString(runtime, UTF8); + queryString = RubyString.newEmptyString(runtime, UTF8); + fragment = RubyString.newEmptyString(runtime, UTF8); + upgradeData = RubyString.newEmptyString(runtime, UTF8); + } else { + requestUrl = RubyString.newEmptyString(runtime); + requestPath = RubyString.newEmptyString(runtime); + queryString = RubyString.newEmptyString(runtime); + fragment = RubyString.newEmptyString(runtime); + upgradeData = RubyString.newEmptyString(runtime); + } + + IRubyObject ret = runtime.getNil(); + + if (callback_object != null) { + if (((RubyObject) callback_object).respondsTo("on_message_begin")) { + ThreadContext context = callback_object.getRuntime().getCurrentContext(); + ret = callback_object.callMethod(context, "on_message_begin"); + } + } else if (on_message_begin != null) { + ThreadContext context = on_message_begin.getRuntime().getCurrentContext(); + ret = on_message_begin.callMethod(context, "call"); + } + + if (ret == stopSym) { + throw new StopException(); + } else { + return 0; + } + } + }; + this.settings.on_message_complete = new HTTPCallback() { + public int cb(http_parser.lolevel.HTTPParser p) { + IRubyObject ret = runtime.getNil(); + + completed = true; + + if (callback_object != null) { + if (((RubyObject) callback_object).respondsTo("on_message_complete")) { + ThreadContext context = callback_object.getRuntime().getCurrentContext(); + ret = callback_object.callMethod(context, "on_message_complete"); + } + } else if (on_message_complete != null) { + ThreadContext context = on_message_complete.getRuntime().getCurrentContext(); + ret = on_message_complete.callMethod(context, "call"); + } + + if (ret == stopSym) { + throw new StopException(); + } else { + return 0; + } + } + }; + this.settings.on_headers_complete = new HTTPCallback() { + public int cb(http_parser.lolevel.HTTPParser p) { + IRubyObject ret = runtime.getNil(); + + if (callback_object != null) { + if (((RubyObject) callback_object).respondsTo("on_headers_complete")) { + ThreadContext context = callback_object.getRuntime().getCurrentContext(); + ret = callback_object.callMethod(context, "on_headers_complete", headers); + } + } else if (on_headers_complete != null) { + ThreadContext context = on_headers_complete.getRuntime().getCurrentContext(); + ret = on_headers_complete.callMethod(context, "call", headers); + } + + if (ret == stopSym) { + throw new StopException(); + } else if (ret == resetSym) { + return 1; + } else { + return 0; + } + } + }; + this.settings.on_body = new HTTPDataCallback() { + public int cb(http_parser.lolevel.HTTPParser p, ByteBuffer buf, int pos, int len) { + IRubyObject ret = runtime.getNil(); + byte[] data = fetchBytes(buf, pos, len); + + if (callback_object != null) { + if (((RubyObject) callback_object).respondsTo("on_body")) { + ThreadContext context = callback_object.getRuntime().getCurrentContext(); + ret = callback_object.callMethod(context, "on_body", + RubyString.newString(runtime, new ByteList(data, UTF8, false))); + } + } else if (on_body != null) { + ThreadContext context = on_body.getRuntime().getCurrentContext(); + ret = on_body.callMethod(context, "call", RubyString.newString(runtime, new ByteList(data, UTF8, false))); + } + + if (ret == stopSym) { + throw new StopException(); + } else { + return 0; + } + } + }; + } + + private void init() { + this.parser = new HTTPParser(); + this.parser.HTTP_PARSER_STRICT = true; + this.headers = null; + + this.requestUrl = runtime.getNil(); + this.requestPath = runtime.getNil(); + this.queryString = runtime.getNil(); + this.fragment = runtime.getNil(); + + this.upgradeData = runtime.getNil(); + } + + @JRubyMethod(name = "initialize") + public IRubyObject initialize() { + return this; + } + + @JRubyMethod(name = "initialize") + public IRubyObject initialize(IRubyObject arg) { + callback_object = arg; + return initialize(); + } + + @JRubyMethod(name = "initialize") + public IRubyObject initialize(IRubyObject arg, IRubyObject arg2) { + header_value_type = arg2; + return initialize(arg); + } + + @JRubyMethod(name = "on_message_begin=") + public IRubyObject set_on_message_begin(IRubyObject cb) { + on_message_begin = cb; + return cb; + } + + @JRubyMethod(name = "on_headers_complete=") + public IRubyObject set_on_headers_complete(IRubyObject cb) { + on_headers_complete = cb; + return cb; + } + + @JRubyMethod(name = "on_body=") + public IRubyObject set_on_body(IRubyObject cb) { + on_body = cb; + return cb; + } + + @JRubyMethod(name = "on_message_complete=") + public IRubyObject set_on_message_complete(IRubyObject cb) { + on_message_complete = cb; + return cb; + } + + @JRubyMethod(name = "<<") + public IRubyObject execute(IRubyObject data) { + RubyString str = (RubyString) data; + ByteList byteList = str.getByteList(); + ByteBuffer buf = ByteBuffer.wrap(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize()); + boolean stopped = false; + + try { + this.parser.execute(this.settings, buf); + } catch (HTTPException e) { + throw new RaiseException(runtime, eParserError, e.getMessage(), true); + } catch (StopException e) { + stopped = true; + } + + if (parser.getUpgrade()) { + byte[] upData = fetchBytes(buf, buf.position(), buf.limit() - buf.position()); + if (runtime.is1_9() || runtime.is2_0()) { + ((RubyString) upgradeData).cat(upData, 0, upData.length, UTF8); + } else { + ((RubyString) upgradeData).cat(upData); + } + } else if (buf.hasRemaining() && !completed) { + if (!stopped) + throw new RaiseException(runtime, eParserError, "Could not parse data entirely", true); + } + + return RubyNumeric.int2fix(runtime, buf.position()); + } + + @JRubyMethod(name = "keep_alive?") + public IRubyObject shouldKeepAlive() { + return runtime.newBoolean(parser.shouldKeepAlive()); + } + + @JRubyMethod(name = "upgrade?") + public IRubyObject shouldUpgrade() { + return runtime.newBoolean(parser.getUpgrade()); + } + + @JRubyMethod(name = "http_major") + public IRubyObject httpMajor() { + if (parser.getMajor() == 0 && parser.getMinor() == 0) + return runtime.getNil(); + else + return RubyNumeric.int2fix(runtime, parser.getMajor()); + } + + @JRubyMethod(name = "http_minor") + public IRubyObject httpMinor() { + if (parser.getMajor() == 0 && parser.getMinor() == 0) + return runtime.getNil(); + else + return RubyNumeric.int2fix(runtime, parser.getMinor()); + } + + @JRubyMethod(name = "http_version") + public IRubyObject httpVersion() { + if (parser.getMajor() == 0 && parser.getMinor() == 0) + return runtime.getNil(); + else + return runtime.newArray(httpMajor(), httpMinor()); + } + + @JRubyMethod(name = "http_method") + public IRubyObject httpMethod() { + HTTPMethod method = parser.getHTTPMethod(); + if (method != null) + return runtime.newString(new String(method.bytes)); + else + return runtime.getNil(); + } + + @JRubyMethod(name = "status_code") + public IRubyObject statusCode() { + int code = parser.getStatusCode(); + if (code != 0) + return RubyNumeric.int2fix(runtime, code); + else + return runtime.getNil(); + } + + @JRubyMethod(name = "headers") + public IRubyObject getHeaders() { + return headers == null ? runtime.getNil() : headers; + } + + @JRubyMethod(name = "request_url") + public IRubyObject getRequestUrl() { + return requestUrl == null ? runtime.getNil() : requestUrl; + } + + @JRubyMethod(name = "request_path") + public IRubyObject getRequestPath() { + return requestPath == null ? runtime.getNil() : requestPath; + } + + @JRubyMethod(name = "query_string") + public IRubyObject getQueryString() { + return queryString == null ? runtime.getNil() : queryString; + } + + @JRubyMethod(name = "fragment") + public IRubyObject getFragment() { + return fragment == null ? runtime.getNil() : fragment; + } + + @JRubyMethod(name = "header_value_type") + public IRubyObject getHeaderValueType() { + return header_value_type == null ? runtime.getNil() : header_value_type; + } + + @JRubyMethod(name = "header_value_type=") + public IRubyObject set_header_value_type(IRubyObject val) { + String valString = val.toString(); + if (!VALUE_TYPES.contains(valString)) { + throw runtime.newArgumentError("Invalid header value type"); + } + header_value_type = val; + return val; + } + + @JRubyMethod(name = "upgrade_data") + public IRubyObject upgradeData() { + return upgradeData == null ? runtime.getNil() : upgradeData; + } + + @JRubyMethod(name = "reset!") + public IRubyObject reset() { + init(); + return runtime.getTrue(); + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/ruby_http_parser.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/ruby_http_parser.c new file mode 100644 index 0000000..e30f349 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/ruby_http_parser.c @@ -0,0 +1,561 @@ +#include "ruby.h" +#include "ext_help.h" +#include "ryah_http_parser.h" + +#define GET_WRAPPER(N, from) ParserWrapper *N = (ParserWrapper *)(from)->data; +#define HASH_CAT(h, k, ptr, len) \ + do { \ + VALUE __v = rb_hash_aref(h, k); \ + if (__v != Qnil) { \ + rb_str_cat(__v, ptr, len); \ + } else { \ + rb_hash_aset(h, k, rb_str_new(ptr, len)); \ + } \ + } while(0) + +typedef struct ParserWrapper { + ryah_http_parser parser; + + VALUE status; + VALUE request_url; + + VALUE headers; + + VALUE upgrade_data; + + VALUE on_message_begin; + VALUE on_headers_complete; + VALUE on_body; + VALUE on_message_complete; + + VALUE callback_object; + VALUE stopped; + VALUE completed; + + VALUE header_value_type; + + VALUE last_field_name; + VALUE curr_field_name; + + enum ryah_http_parser_type type; +} ParserWrapper; + +void ParserWrapper_init(ParserWrapper *wrapper) { + ryah_http_parser_init(&wrapper->parser, wrapper->type); + wrapper->parser.status_code = 0; + wrapper->parser.http_major = 0; + wrapper->parser.http_minor = 0; + + wrapper->status = Qnil; + wrapper->request_url = Qnil; + + wrapper->upgrade_data = Qnil; + + wrapper->headers = Qnil; + wrapper->completed = Qfalse; + + wrapper->last_field_name = Qnil; + wrapper->curr_field_name = Qnil; +} + +void ParserWrapper_mark(void *data) { + if(data) { + ParserWrapper *wrapper = (ParserWrapper *) data; + rb_gc_mark_maybe(wrapper->status); + rb_gc_mark_maybe(wrapper->request_url); + rb_gc_mark_maybe(wrapper->upgrade_data); + rb_gc_mark_maybe(wrapper->headers); + rb_gc_mark_maybe(wrapper->on_message_begin); + rb_gc_mark_maybe(wrapper->on_headers_complete); + rb_gc_mark_maybe(wrapper->on_body); + rb_gc_mark_maybe(wrapper->on_message_complete); + rb_gc_mark_maybe(wrapper->callback_object); + rb_gc_mark_maybe(wrapper->last_field_name); + rb_gc_mark_maybe(wrapper->curr_field_name); + } +} + +void ParserWrapper_free(void *data) { + if(data) { + free(data); + } +} + +static VALUE cParser; +static VALUE cRequestParser; +static VALUE cResponseParser; + +static VALUE eParserError; + +static ID Icall; +static ID Ion_message_begin; +static ID Ion_headers_complete; +static ID Ion_body; +static ID Ion_message_complete; + +static VALUE Sstop; +static VALUE Sreset; +static VALUE Sarrays; +static VALUE Sstrings; +static VALUE Smixed; + +/** Callbacks **/ + +int on_message_begin(ryah_http_parser *parser) { + GET_WRAPPER(wrapper, parser); + + wrapper->status = rb_str_new2(""); + wrapper->request_url = rb_str_new2(""); + wrapper->headers = rb_hash_new(); + wrapper->upgrade_data = rb_str_new2(""); + + VALUE ret = Qnil; + + if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_message_begin)) { + ret = rb_funcall(wrapper->callback_object, Ion_message_begin, 0); + } else if (wrapper->on_message_begin != Qnil) { + ret = rb_funcall(wrapper->on_message_begin, Icall, 0); + } + + if (ret == Sstop) { + wrapper->stopped = Qtrue; + return -1; + } else { + return 0; + } +} + +int on_status(ryah_http_parser *parser, const char *at, size_t length) { + GET_WRAPPER(wrapper, parser); + + if (at && length) { + if (wrapper->status == Qnil) { + wrapper->status = rb_str_new(at, length); + } else { + rb_str_cat(wrapper->status, at, length); + } + } + return 0; +} + +int on_url(ryah_http_parser *parser, const char *at, size_t length) { + GET_WRAPPER(wrapper, parser); + if (at && length) { + if (wrapper->request_url == Qnil) { + wrapper->request_url = rb_str_new(at, length); + } else { + rb_str_cat(wrapper->request_url, at, length); + } + } + return 0; +} + +int on_header_field(ryah_http_parser *parser, const char *at, size_t length) { + GET_WRAPPER(wrapper, parser); + + if (wrapper->curr_field_name == Qnil) { + wrapper->last_field_name = Qnil; + wrapper->curr_field_name = rb_str_new(at, length); + } else { + rb_str_cat(wrapper->curr_field_name, at, length); + } + return 0; +} + +int on_header_value(ryah_http_parser *parser, const char *at, size_t length) { + GET_WRAPPER(wrapper, parser); + + int new_field = 0; + VALUE current_value; + + if (wrapper->last_field_name == Qnil) { + new_field = 1; + wrapper->last_field_name = wrapper->curr_field_name; + wrapper->curr_field_name = Qnil; + } + + current_value = rb_hash_aref(wrapper->headers, wrapper->last_field_name); + + if (new_field == 1) { + if (current_value == Qnil) { + if (wrapper->header_value_type == Sarrays) { + rb_hash_aset(wrapper->headers, wrapper->last_field_name, rb_ary_new3(1, rb_str_new2(""))); + } else { + rb_hash_aset(wrapper->headers, wrapper->last_field_name, rb_str_new2("")); + } + } else { + if (wrapper->header_value_type == Smixed) { + if (TYPE(current_value) == T_STRING) { + rb_hash_aset(wrapper->headers, wrapper->last_field_name, rb_ary_new3(2, current_value, rb_str_new2(""))); + } else { + rb_ary_push(current_value, rb_str_new2("")); + } + } else if (wrapper->header_value_type == Sarrays) { + rb_ary_push(current_value, rb_str_new2("")); + } else { + rb_str_cat(current_value, ", ", 2); + } + } + current_value = rb_hash_aref(wrapper->headers, wrapper->last_field_name); + } + + if (TYPE(current_value) == T_ARRAY) { + current_value = rb_ary_entry(current_value, -1); + } + + rb_str_cat(current_value, at, length); + + return 0; +} + +int on_headers_complete(ryah_http_parser *parser) { + GET_WRAPPER(wrapper, parser); + + VALUE ret = Qnil; + + if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_headers_complete)) { + ret = rb_funcall(wrapper->callback_object, Ion_headers_complete, 1, wrapper->headers); + } else if (wrapper->on_headers_complete != Qnil) { + ret = rb_funcall(wrapper->on_headers_complete, Icall, 1, wrapper->headers); + } + + if (ret == Sstop) { + wrapper->stopped = Qtrue; + return -1; + } else if (ret == Sreset){ + return 1; + } else { + return 0; + } +} + +int on_body(ryah_http_parser *parser, const char *at, size_t length) { + GET_WRAPPER(wrapper, parser); + + VALUE ret = Qnil; + + if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_body)) { + ret = rb_funcall(wrapper->callback_object, Ion_body, 1, rb_str_new(at, length)); + } else if (wrapper->on_body != Qnil) { + ret = rb_funcall(wrapper->on_body, Icall, 1, rb_str_new(at, length)); + } + + if (ret == Sstop) { + wrapper->stopped = Qtrue; + return -1; + } else { + return 0; + } +} + +int on_message_complete(ryah_http_parser *parser) { + GET_WRAPPER(wrapper, parser); + + VALUE ret = Qnil; + wrapper->completed = Qtrue; + + if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_message_complete)) { + ret = rb_funcall(wrapper->callback_object, Ion_message_complete, 0); + } else if (wrapper->on_message_complete != Qnil) { + ret = rb_funcall(wrapper->on_message_complete, Icall, 0); + } + + if (ret == Sstop) { + wrapper->stopped = Qtrue; + return -1; + } else { + return 0; + } +} + +static ryah_http_parser_settings settings = { + .on_message_begin = on_message_begin, + .on_status = on_status, + .on_url = on_url, + .on_header_field = on_header_field, + .on_header_value = on_header_value, + .on_headers_complete = on_headers_complete, + .on_body = on_body, + .on_message_complete = on_message_complete +}; + +VALUE Parser_alloc_by_type(VALUE klass, enum ryah_http_parser_type type) { + ParserWrapper *wrapper = ALLOC_N(ParserWrapper, 1); + wrapper->type = type; + wrapper->parser.data = wrapper; + + wrapper->on_message_begin = Qnil; + wrapper->on_headers_complete = Qnil; + wrapper->on_body = Qnil; + wrapper->on_message_complete = Qnil; + + wrapper->callback_object = Qnil; + + ParserWrapper_init(wrapper); + + return Data_Wrap_Struct(klass, ParserWrapper_mark, ParserWrapper_free, wrapper); +} + +VALUE Parser_alloc(VALUE klass) { + return Parser_alloc_by_type(klass, HTTP_BOTH); +} + +VALUE RequestParser_alloc(VALUE klass) { + return Parser_alloc_by_type(klass, HTTP_REQUEST); +} + +VALUE ResponseParser_alloc(VALUE klass) { + return Parser_alloc_by_type(klass, HTTP_RESPONSE); +} + +VALUE Parser_strict_p(VALUE klass) { + return HTTP_PARSER_STRICT == 1 ? Qtrue : Qfalse; +} + +VALUE Parser_initialize(int argc, VALUE *argv, VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + VALUE default_header_value_type = Qnil; + + if (argc > 0 && RB_TYPE_P(argv[argc-1], T_HASH)) { + ID keyword_ids[1]; + keyword_ids[0] = rb_intern("default_header_value_type"); + rb_get_kwargs(argv[argc-1], keyword_ids, 0, 1, &default_header_value_type); + if (default_header_value_type == Qundef) { + default_header_value_type = Qnil; + } + --argc; + } + + if (argc == 1) { + wrapper->callback_object = argv[0]; + } + + if (argc == 2) { + wrapper->callback_object = argv[0]; + default_header_value_type = argv[1]; + } + + if (default_header_value_type == Qnil) { + wrapper->header_value_type = rb_iv_get(CLASS_OF(self), "@default_header_value_type"); + } else { + wrapper->header_value_type = default_header_value_type; + } + + return self; +} + +VALUE Parser_execute(VALUE self, VALUE data) { + ParserWrapper *wrapper = NULL; + + Check_Type(data, T_STRING); + char *ptr = RSTRING_PTR(data); + long len = RSTRING_LEN(data); + + DATA_GET(self, ParserWrapper, wrapper); + + wrapper->stopped = Qfalse; + size_t nparsed = ryah_http_parser_execute(&wrapper->parser, &settings, ptr, len); + + if (wrapper->parser.upgrade) { + if (RTEST(wrapper->stopped) && !RTEST(wrapper->completed)) + nparsed += 1; + + if (nparsed < len) + rb_str_cat(wrapper->upgrade_data, ptr + nparsed, len - nparsed); + + } else if (nparsed != (size_t)len) { + if (!RTEST(wrapper->stopped) && !RTEST(wrapper->completed)) + rb_raise(eParserError, "Could not parse data entirely (%zu != %zu)", nparsed, len); + else + nparsed += 1; // error states fail on the current character + } + + return INT2FIX(nparsed); +} + +VALUE Parser_set_on_message_begin(VALUE self, VALUE callback) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + wrapper->on_message_begin = callback; + return callback; +} + +VALUE Parser_set_on_headers_complete(VALUE self, VALUE callback) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + wrapper->on_headers_complete = callback; + return callback; +} + +VALUE Parser_set_on_body(VALUE self, VALUE callback) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + wrapper->on_body = callback; + return callback; +} + +VALUE Parser_set_on_message_complete(VALUE self, VALUE callback) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + wrapper->on_message_complete = callback; + return callback; +} + +VALUE Parser_keep_alive_p(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + return http_should_keep_alive(&wrapper->parser) == 1 ? Qtrue : Qfalse; +} + +VALUE Parser_upgrade_p(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + return wrapper->parser.upgrade ? Qtrue : Qfalse; +} + +VALUE Parser_http_version(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + if (wrapper->parser.http_major == 0 && wrapper->parser.http_minor == 0) + return Qnil; + else + return rb_ary_new3(2, INT2FIX(wrapper->parser.http_major), INT2FIX(wrapper->parser.http_minor)); +} + +VALUE Parser_http_major(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + if (wrapper->parser.http_major == 0 && wrapper->parser.http_minor == 0) + return Qnil; + else + return INT2FIX(wrapper->parser.http_major); +} + +VALUE Parser_http_minor(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + if (wrapper->parser.http_major == 0 && wrapper->parser.http_minor == 0) + return Qnil; + else + return INT2FIX(wrapper->parser.http_minor); +} + +VALUE Parser_http_method(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + if (wrapper->parser.type == HTTP_REQUEST) + return rb_str_new2(http_method_str(wrapper->parser.method)); + else + return Qnil; +} + +VALUE Parser_status_code(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + if (wrapper->parser.status_code) + return INT2FIX(wrapper->parser.status_code); + else + return Qnil; +} + +#define DEFINE_GETTER(name) \ + VALUE Parser_##name(VALUE self) { \ + ParserWrapper *wrapper = NULL; \ + DATA_GET(self, ParserWrapper, wrapper); \ + return wrapper->name; \ + } + +DEFINE_GETTER(status); +DEFINE_GETTER(request_url); +DEFINE_GETTER(headers); +DEFINE_GETTER(upgrade_data); +DEFINE_GETTER(header_value_type); + +VALUE Parser_set_header_value_type(VALUE self, VALUE val) { + if (val != Sarrays && val != Sstrings && val != Smixed) { + rb_raise(rb_eArgError, "Invalid header value type"); + } + + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + wrapper->header_value_type = val; + return wrapper->header_value_type; +} + +VALUE Parser_reset(VALUE self) { + ParserWrapper *wrapper = NULL; + DATA_GET(self, ParserWrapper, wrapper); + + ParserWrapper_init(wrapper); + + return Qtrue; +} + +void Init_ruby_http_parser() { +#ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); +#endif + + VALUE mHTTP = rb_define_module("HTTP"); + cParser = rb_define_class_under(mHTTP, "Parser", rb_cObject); + cRequestParser = rb_define_class_under(mHTTP, "RequestParser", cParser); + cResponseParser = rb_define_class_under(mHTTP, "ResponseParser", cParser); + + eParserError = rb_define_class_under(cParser, "Error", rb_eIOError); + Icall = rb_intern("call"); + Ion_message_begin = rb_intern("on_message_begin"); + Ion_headers_complete = rb_intern("on_headers_complete"); + Ion_body = rb_intern("on_body"); + Ion_message_complete = rb_intern("on_message_complete"); + Sstop = ID2SYM(rb_intern("stop")); + Sreset = ID2SYM(rb_intern("reset")); + + Sarrays = ID2SYM(rb_intern("arrays")); + Sstrings = ID2SYM(rb_intern("strings")); + Smixed = ID2SYM(rb_intern("mixed")); + + rb_define_alloc_func(cParser, Parser_alloc); + rb_define_alloc_func(cRequestParser, RequestParser_alloc); + rb_define_alloc_func(cResponseParser, ResponseParser_alloc); + + rb_define_singleton_method(cParser, "strict?", Parser_strict_p, 0); + rb_define_method(cParser, "initialize", Parser_initialize, -1); + + rb_define_method(cParser, "on_message_begin=", Parser_set_on_message_begin, 1); + rb_define_method(cParser, "on_headers_complete=", Parser_set_on_headers_complete, 1); + rb_define_method(cParser, "on_body=", Parser_set_on_body, 1); + rb_define_method(cParser, "on_message_complete=", Parser_set_on_message_complete, 1); + rb_define_method(cParser, "<<", Parser_execute, 1); + + rb_define_method(cParser, "keep_alive?", Parser_keep_alive_p, 0); + rb_define_method(cParser, "upgrade?", Parser_upgrade_p, 0); + + rb_define_method(cParser, "http_version", Parser_http_version, 0); + rb_define_method(cParser, "http_major", Parser_http_major, 0); + rb_define_method(cParser, "http_minor", Parser_http_minor, 0); + + rb_define_method(cParser, "http_method", Parser_http_method, 0); + rb_define_method(cParser, "status_code", Parser_status_code, 0); + + rb_define_method(cParser, "status", Parser_status, 0); + rb_define_method(cParser, "request_url", Parser_request_url, 0); + rb_define_method(cParser, "headers", Parser_headers, 0); + rb_define_method(cParser, "upgrade_data", Parser_upgrade_data, 0); + rb_define_method(cParser, "header_value_type", Parser_header_value_type, 0); + rb_define_method(cParser, "header_value_type=", Parser_set_header_value_type, 1); + + rb_define_method(cParser, "reset!", Parser_reset, 0); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/.gitkeep b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/AUTHORS b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/AUTHORS new file mode 100644 index 0000000..abe99de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/AUTHORS @@ -0,0 +1,32 @@ +# Authors ordered by first contribution. +Ryan Dahl +Jeremy Hinegardner +Sergey Shepelev +Joe Damato +tomika +Phoenix Sol +Cliff Frey +Ewen Cheslack-Postava +Santiago Gala +Tim Becker +Jeff Terrace +Ben Noordhuis +Nathan Rajlich +Mark Nottingham +Aman Gupta +Tim Becker +Sean Cunningham +Peter Griess +Salman Haq +Cliff Frey +Jon Kolb +Fouad Mardini +Paul Querna +Felix Geisendörfer +koichik +Andre Caron +Ivo Raisr +James McLaughlin +David Gwynne +LE ROUX Thomas +Randy Rizun diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/LICENSE-MIT b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/LICENSE-MIT new file mode 100644 index 0000000..a0ae8dc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/LICENSE-MIT @@ -0,0 +1,48 @@ +Copyright 2010 Tim Becker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. + +--- END OF LICENSE + +This code mainly based on code with the following license: + + +http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright +Igor Sysoev. + +Additional changes are licensed under the same terms as NGINX and +copyright Joyent, Inc. and other Node contributors. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/README.md b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/README.md new file mode 100644 index 0000000..0a6a432 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/README.md @@ -0,0 +1,183 @@ +HTTP Parser +=========== + +This is a parser for HTTP written in Java, based quite heavily on +the Ryan Dahl's C Version: `http-parser` available here: + + http://github.com/ry/http-parser + +It parses both requests and responses. The parser is designed to be used +in performance HTTP applications. + +Features: + + * No dependencies (probably won't be able to keep it up) + * Handles persistent streams (keep-alive). + * Decodes chunked encoding. + * Upgrade support + +The parser extracts the following information from HTTP messages: + + * Header fields and values + * Content-Length + * Request method + * Response status code + * Transfer-Encoding + * HTTP version + * Request URL + * Message body + +Building +-------- + +use `ant compile|test|jar` + +Usage +----- + + TODO: in the present form, usage of the Java version of the parser + shouldn't be too difficult to figure out for someone familiar with the + C version. + + More documentation will follow shortly, in case you're looking for an + easy to use http library, this lib is probably not what you are + looking for anyway ... + + All text after this paragraph (and most of the text above it) are from + the original C version of the README and are currently only here for + reference. In case you encounter any difficulties, find bugs, need + help or have suggestions, feel free to contact me at + (tim.becker@kuriositaet.de). + + +One `http_parser` object is used per TCP connection. Initialize the struct +using `http_parser_init()` and set the callbacks. That might look something +like this for a request parser: + + http_parser_settings settings; + settings.on_path = my_path_callback; + settings.on_header_field = my_header_field_callback; + /* ... */ + + http_parser *parser = malloc(sizeof(http_parser)); + http_parser_init(parser, HTTP_REQUEST); + parser->data = my_socket; + +When data is received on the socket execute the parser and check for errors. + + size_t len = 80*1024, nparsed; + char buf[len]; + ssize_t recved; + + recved = recv(fd, buf, len, 0); + + if (recved < 0) { + /* Handle error. */ + } + + /* Start up / continue the parser. + * Note we pass recved==0 to signal that EOF has been recieved. + */ + nparsed = http_parser_execute(parser, &settings, buf, recved); + + if (parser->upgrade) { + /* handle new protocol */ + } else if (nparsed != recved) { + /* Handle error. Usually just close the connection. */ + } + +HTTP needs to know where the end of the stream is. For example, sometimes +servers send responses without Content-Length and expect the client to +consume input (for the body) until EOF. To tell http_parser about EOF, give +`0` as the forth parameter to `http_parser_execute()`. Callbacks and errors +can still be encountered during an EOF, so one must still be prepared +to receive them. + +Scalar valued message information such as `status_code`, `method`, and the +HTTP version are stored in the parser structure. This data is only +temporally stored in `http_parser` and gets reset on each new message. If +this information is needed later, copy it out of the structure during the +`headers_complete` callback. + +The parser decodes the transfer-encoding for both requests and responses +transparently. That is, a chunked encoding is decoded before being sent to +the on_body callback. + + +The Special Problem of Upgrade +------------------------------ + +HTTP supports upgrading the connection to a different protocol. An +increasingly common example of this is the Web Socket protocol which sends +a request like + + GET /demo HTTP/1.1 + Upgrade: WebSocket + Connection: Upgrade + Host: example.com + Origin: http://example.com + WebSocket-Protocol: sample + +followed by non-HTTP data. + +(See http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75 for more +information the Web Socket protocol.) + +To support this, the parser will treat this as a normal HTTP message without a +body. Issuing both on_headers_complete and on_message_complete callbacks. However +http_parser_execute() will stop parsing at the end of the headers and return. + +The user is expected to check if `parser->upgrade` has been set to 1 after +`http_parser_execute()` returns. Non-HTTP data begins at the buffer supplied +offset by the return value of `http_parser_execute()`. + + +Callbacks +--------- + +During the `http_parser_execute()` call, the callbacks set in +`http_parser_settings` will be executed. The parser maintains state and +never looks behind, so buffering the data is not necessary. If you need to +save certain data for later usage, you can do that from the callbacks. + +There are two types of callbacks: + +* notification `typedef int (*http_cb) (http_parser*);` + Callbacks: on_message_begin, on_headers_complete, on_message_complete. +* data `typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);` + Callbacks: (requests only) on_uri, + (common) on_header_field, on_header_value, on_body; + +Callbacks must return 0 on success. Returning a non-zero value indicates +error to the parser, making it exit immediately. + +In case you parse HTTP message in chunks (i.e. `read()` request line +from socket, parse, read half headers, parse, etc) your data callbacks +may be called more than once. Http-parser guarantees that data pointer is only +valid for the lifetime of callback. You can also `read()` into a heap allocated +buffer to avoid copying memory around if this fits your application. + +Reading headers may be a tricky task if you read/parse headers partially. +Basically, you need to remember whether last header callback was field or value +and apply following logic: + + (on_header_field and on_header_value shortened to on_h_*) + ------------------------ ------------ -------------------------------------------- + | State (prev. callback) | Callback | Description/action | + ------------------------ ------------ -------------------------------------------- + | nothing (first call) | on_h_field | Allocate new buffer and copy callback data | + | | | into it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_field | New header started. | + | | | Copy current name,value buffers to headers | + | | | list and allocate new buffer for new name | + ------------------------ ------------ -------------------------------------------- + | field | on_h_field | Previous name continues. Reallocate name | + | | | buffer and append callback data to it | + ------------------------ ------------ -------------------------------------------- + | field | on_h_value | Value for current header started. Allocate | + | | | new buffer and copy callback data to it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_value | Value continues. Reallocate value buffer | + | | | and append callback data to it | + ------------------------ ------------ -------------------------------------------- diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/TODO b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/TODO new file mode 100644 index 0000000..eb46a08 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/TODO @@ -0,0 +1,28 @@ +decide how to handle errs per default: + - ry: "set state to dead", return `read` + - current: call on_error w/ details, if no on_error handler set, + throw Exception, else call on_error and behave like orig... + +some tests from test.c left to port + (scan ...) +documentation + +hi level callback interface +eventloop +state() as a function (?) + - perhaps, the idea being to be able to log/debug better... +more tests + - in particular, port available c tests +impl bits of servlet api. + +DONE + +Sun Jul 18 12:19:18 CEST 2010 + +error handling + - consider callback based error handling and the current highlevel + "nice" logging moved to high level http impl. + - use Exceptions "ProtocolException"? + +better testing + - no junit to avoid dependencies diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/build.xml b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/build.xml new file mode 100755 index 0000000..d2c6af4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.c new file mode 100644 index 0000000..e961ae8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.c @@ -0,0 +1,2175 @@ +/* Based on src/http/ngx_http_parse.c from NGINX copyright Igor Sysoev + * + * Additional changes are licensed under the same terms as NGINX and + * copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "http_parser.h" +#include +#include +#include +#include +#include +#include + +#ifndef ULLONG_MAX +# define ULLONG_MAX ((uint64_t) -1) /* 2^64-1 */ +#endif + +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif + +#ifndef BIT_AT +# define BIT_AT(a, i) \ + (!!((unsigned int) (a)[(unsigned int) (i) >> 3] & \ + (1 << ((unsigned int) (i) & 7)))) +#endif + +#ifndef ELEM_AT +# define ELEM_AT(a, i, v) ((unsigned int) (i) < ARRAY_SIZE(a) ? (a)[(i)] : (v)) +#endif + +#define SET_ERRNO(e) \ +do { \ + parser->http_errno = (e); \ +} while(0) + + +/* Run the notify callback FOR, returning ER if it fails */ +#define CALLBACK_NOTIFY_(FOR, ER) \ +do { \ + assert(HTTP_PARSER_ERRNO(parser) == HPE_OK); \ + \ + if (settings->on_##FOR) { \ + if (0 != settings->on_##FOR(parser)) { \ + SET_ERRNO(HPE_CB_##FOR); \ + } \ + \ + /* We either errored above or got paused; get out */ \ + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { \ + return (ER); \ + } \ + } \ +} while (0) + +/* Run the notify callback FOR and consume the current byte */ +#define CALLBACK_NOTIFY(FOR) CALLBACK_NOTIFY_(FOR, p - data + 1) + +/* Run the notify callback FOR and don't consume the current byte */ +#define CALLBACK_NOTIFY_NOADVANCE(FOR) CALLBACK_NOTIFY_(FOR, p - data) + +/* Run data callback FOR with LEN bytes, returning ER if it fails */ +#define CALLBACK_DATA_(FOR, LEN, ER) \ +do { \ + assert(HTTP_PARSER_ERRNO(parser) == HPE_OK); \ + \ + if (FOR##_mark) { \ + if (settings->on_##FOR) { \ + if (0 != settings->on_##FOR(parser, FOR##_mark, (LEN))) { \ + SET_ERRNO(HPE_CB_##FOR); \ + } \ + \ + /* We either errored above or got paused; get out */ \ + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { \ + return (ER); \ + } \ + } \ + FOR##_mark = NULL; \ + } \ +} while (0) + +/* Run the data callback FOR and consume the current byte */ +#define CALLBACK_DATA(FOR) \ + CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1) + +/* Run the data callback FOR and don't consume the current byte */ +#define CALLBACK_DATA_NOADVANCE(FOR) \ + CALLBACK_DATA_(FOR, p - FOR##_mark, p - data) + +/* Set the mark FOR; non-destructive if mark is already set */ +#define MARK(FOR) \ +do { \ + if (!FOR##_mark) { \ + FOR##_mark = p; \ + } \ +} while (0) + + +#define PROXY_CONNECTION "proxy-connection" +#define CONNECTION "connection" +#define CONTENT_LENGTH "content-length" +#define TRANSFER_ENCODING "transfer-encoding" +#define UPGRADE "upgrade" +#define CHUNKED "chunked" +#define KEEP_ALIVE "keep-alive" +#define CLOSE "close" + + +static const char *method_strings[] = + { +#define XX(num, name, string) #string, + HTTP_METHOD_MAP(XX) +#undef XX + }; + + +/* Tokens as defined by rfc 2616. Also lowercases them. + * token = 1* + * separators = "(" | ")" | "<" | ">" | "@" + * | "," | ";" | ":" | "\" | <"> + * | "/" | "[" | "]" | "?" | "=" + * | "{" | "}" | SP | HT + */ +static const char tokens[256] = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0, '!', 0, '#', '$', '%', '&', '\'', +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 0, 0, '*', '+', 0, '-', '.', 0, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + '0', '1', '2', '3', '4', '5', '6', '7', +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + '8', '9', 0, 0, 0, 0, 0, 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 'x', 'y', 'z', 0, 0, 0, '^', '_', +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 'x', 'y', 'z', 0, '|', 0, '~', 0 }; + + +static const int8_t unhex[256] = + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + }; + + +#if HTTP_PARSER_STRICT +# define T(v) 0 +#else +# define T(v) v +#endif + + +static const uint8_t normal_url_char[32] = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0 | T(2) | 0 | 0 | T(16) | 0 | 0 | 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0 | 2 | 4 | 0 | 16 | 32 | 64 | 128, +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 0, }; + +#undef T + +enum state + { s_dead = 1 /* important that this is > 0 */ + + , s_start_req_or_res + , s_res_or_resp_H + , s_start_res + , s_res_H + , s_res_HT + , s_res_HTT + , s_res_HTTP + , s_res_first_http_major + , s_res_http_major + , s_res_first_http_minor + , s_res_http_minor + , s_res_first_status_code + , s_res_status_code + , s_res_status + , s_res_line_almost_done + + , s_start_req + + , s_req_method + , s_req_spaces_before_url + , s_req_schema + , s_req_schema_slash + , s_req_schema_slash_slash + , s_req_server_start + , s_req_server + , s_req_server_with_at + , s_req_path + , s_req_query_string_start + , s_req_query_string + , s_req_fragment_start + , s_req_fragment + , s_req_http_start + , s_req_http_H + , s_req_http_HT + , s_req_http_HTT + , s_req_http_HTTP + , s_req_first_http_major + , s_req_http_major + , s_req_first_http_minor + , s_req_http_minor + , s_req_line_almost_done + + , s_header_field_start + , s_header_field + , s_header_value_start + , s_header_value + , s_header_value_lws + + , s_header_almost_done + + , s_chunk_size_start + , s_chunk_size + , s_chunk_parameters + , s_chunk_size_almost_done + + , s_headers_almost_done + , s_headers_done + + /* Important: 's_headers_done' must be the last 'header' state. All + * states beyond this must be 'body' states. It is used for overflow + * checking. See the PARSING_HEADER() macro. + */ + + , s_chunk_data + , s_chunk_data_almost_done + , s_chunk_data_done + + , s_body_identity + , s_body_identity_eof + + , s_message_done + }; + + +#define PARSING_HEADER(state) (state <= s_headers_done) + + +enum header_states + { h_general = 0 + , h_C + , h_CO + , h_CON + + , h_matching_connection + , h_matching_proxy_connection + , h_matching_content_length + , h_matching_transfer_encoding + , h_matching_upgrade + + , h_connection + , h_content_length + , h_transfer_encoding + , h_upgrade + + , h_matching_transfer_encoding_chunked + , h_matching_connection_keep_alive + , h_matching_connection_close + + , h_transfer_encoding_chunked + , h_connection_keep_alive + , h_connection_close + }; + +enum http_host_state + { + s_http_host_dead = 1 + , s_http_userinfo_start + , s_http_userinfo + , s_http_host_start + , s_http_host_v6_start + , s_http_host + , s_http_host_v6 + , s_http_host_v6_end + , s_http_host_port_start + , s_http_host_port +}; + +/* Macros for character classes; depends on strict-mode */ +#define CR '\r' +#define LF '\n' +#define LOWER(c) (unsigned char)(c | 0x20) +#define IS_ALPHA(c) (LOWER(c) >= 'a' && LOWER(c) <= 'z') +#define IS_NUM(c) ((c) >= '0' && (c) <= '9') +#define IS_ALPHANUM(c) (IS_ALPHA(c) || IS_NUM(c)) +#define IS_HEX(c) (IS_NUM(c) || (LOWER(c) >= 'a' && LOWER(c) <= 'f')) +#define IS_MARK(c) ((c) == '-' || (c) == '_' || (c) == '.' || \ + (c) == '!' || (c) == '~' || (c) == '*' || (c) == '\'' || (c) == '(' || \ + (c) == ')') +#define IS_USERINFO_CHAR(c) (IS_ALPHANUM(c) || IS_MARK(c) || (c) == '%' || \ + (c) == ';' || (c) == ':' || (c) == '&' || (c) == '=' || (c) == '+' || \ + (c) == '$' || (c) == ',') + +#if HTTP_PARSER_STRICT +#define TOKEN(c) (tokens[(unsigned char)c]) +#define IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c)) +#define IS_HOST_CHAR(c) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-') +#else +#define TOKEN(c) ((c == ' ') ? ' ' : tokens[(unsigned char)c]) +#define IS_URL_CHAR(c) \ + (BIT_AT(normal_url_char, (unsigned char)c) || ((c) & 0x80)) +#define IS_HOST_CHAR(c) \ + (IS_ALPHANUM(c) || (c) == '.' || (c) == '-' || (c) == '_') +#endif + + +#define start_state (parser->type == HTTP_REQUEST ? s_start_req : s_start_res) + + +#if HTTP_PARSER_STRICT +# define STRICT_CHECK(cond) \ +do { \ + if (cond) { \ + SET_ERRNO(HPE_STRICT); \ + goto error; \ + } \ +} while (0) +# define NEW_MESSAGE() (http_should_keep_alive(parser) ? start_state : s_dead) +#else +# define STRICT_CHECK(cond) +# define NEW_MESSAGE() start_state +#endif + + +/* Map errno values to strings for human-readable output */ +#define HTTP_STRERROR_GEN(n, s) { "HPE_" #n, s }, +static struct { + const char *name; + const char *description; +} http_strerror_tab[] = { + HTTP_ERRNO_MAP(HTTP_STRERROR_GEN) +}; +#undef HTTP_STRERROR_GEN + +int http_message_needs_eof(const http_parser *parser); + +/* Our URL parser. + * + * This is designed to be shared by http_parser_execute() for URL validation, + * hence it has a state transition + byte-for-byte interface. In addition, it + * is meant to be embedded in http_parser_parse_url(), which does the dirty + * work of turning state transitions URL components for its API. + * + * This function should only be invoked with non-space characters. It is + * assumed that the caller cares about (and can detect) the transition between + * URL and non-URL states by looking for these. + */ +static enum state +parse_url_char(enum state s, const char ch) +{ + if (ch == ' ' || ch == '\r' || ch == '\n') { + return s_dead; + } + +#if HTTP_PARSER_STRICT + if (ch == '\t' || ch == '\f') { + return s_dead; + } +#endif + + switch (s) { + case s_req_spaces_before_url: + /* Proxied requests are followed by scheme of an absolute URI (alpha). + * All methods except CONNECT are followed by '/' or '*'. + */ + + if (ch == '/' || ch == '*') { + return s_req_path; + } + + if (IS_ALPHA(ch)) { + return s_req_schema; + } + + break; + + case s_req_schema: + if (IS_ALPHA(ch)) { + return s; + } + + if (ch == ':') { + return s_req_schema_slash; + } + + break; + + case s_req_schema_slash: + if (ch == '/') { + return s_req_schema_slash_slash; + } + + break; + + case s_req_schema_slash_slash: + if (ch == '/') { + return s_req_server_start; + } + + break; + + case s_req_server_with_at: + if (ch == '@') { + return s_dead; + } + + /* FALLTHROUGH */ + case s_req_server_start: + case s_req_server: + if (ch == '/') { + return s_req_path; + } + + if (ch == '?') { + return s_req_query_string_start; + } + + if (ch == '@') { + return s_req_server_with_at; + } + + if (IS_USERINFO_CHAR(ch) || ch == '[' || ch == ']') { + return s_req_server; + } + + break; + + case s_req_path: + if (IS_URL_CHAR(ch)) { + return s; + } + + switch (ch) { + case '?': + return s_req_query_string_start; + + case '#': + return s_req_fragment_start; + } + + break; + + case s_req_query_string_start: + case s_req_query_string: + if (IS_URL_CHAR(ch)) { + return s_req_query_string; + } + + switch (ch) { + case '?': + /* allow extra '?' in query string */ + return s_req_query_string; + + case '#': + return s_req_fragment_start; + } + + break; + + case s_req_fragment_start: + if (IS_URL_CHAR(ch)) { + return s_req_fragment; + } + + switch (ch) { + case '?': + return s_req_fragment; + + case '#': + return s; + } + + break; + + case s_req_fragment: + if (IS_URL_CHAR(ch)) { + return s; + } + + switch (ch) { + case '?': + case '#': + return s; + } + + break; + + default: + break; + } + + /* We should never fall out of the switch above unless there's an error */ + return s_dead; +} + +size_t http_parser_execute (http_parser *parser, + const http_parser_settings *settings, + const char *data, + size_t len) +{ + char c, ch; + int8_t unhex_val; + const char *p = data; + const char *header_field_mark = 0; + const char *header_value_mark = 0; + const char *url_mark = 0; + const char *body_mark = 0; + + /* We're in an error state. Don't bother doing anything. */ + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { + return 0; + } + + if (len == 0) { + switch (parser->state) { + case s_body_identity_eof: + /* Use of CALLBACK_NOTIFY() here would erroneously return 1 byte read if + * we got paused. + */ + CALLBACK_NOTIFY_NOADVANCE(message_complete); + return 0; + + case s_dead: + case s_start_req_or_res: + case s_start_res: + case s_start_req: + return 0; + + default: + SET_ERRNO(HPE_INVALID_EOF_STATE); + return 1; + } + } + + + if (parser->state == s_header_field) + header_field_mark = data; + if (parser->state == s_header_value) + header_value_mark = data; + switch (parser->state) { + case s_req_path: + case s_req_schema: + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + case s_req_server: + case s_req_server_with_at: + case s_req_query_string_start: + case s_req_query_string: + case s_req_fragment_start: + case s_req_fragment: + url_mark = data; + break; + } + + for (p=data; p != data + len; p++) { + ch = *p; + + if (PARSING_HEADER(parser->state)) { + ++parser->nread; + /* Buffer overflow attack */ + if (parser->nread > HTTP_MAX_HEADER_SIZE) { + SET_ERRNO(HPE_HEADER_OVERFLOW); + goto error; + } + } + + reexecute_byte: + switch (parser->state) { + + case s_dead: + /* this state is used after a 'Connection: close' message + * the parser will error out if it reads another message + */ + if (ch == CR || ch == LF) + break; + + SET_ERRNO(HPE_CLOSED_CONNECTION); + goto error; + + case s_start_req_or_res: + { + if (ch == CR || ch == LF) + break; + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + if (ch == 'H') { + parser->state = s_res_or_resp_H; + + CALLBACK_NOTIFY(message_begin); + } else { + parser->type = HTTP_REQUEST; + parser->state = s_start_req; + goto reexecute_byte; + } + + break; + } + + case s_res_or_resp_H: + if (ch == 'T') { + parser->type = HTTP_RESPONSE; + parser->state = s_res_HT; + } else { + if (ch != 'E') { + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + + parser->type = HTTP_REQUEST; + parser->method = HTTP_HEAD; + parser->index = 2; + parser->state = s_req_method; + } + break; + + case s_start_res: + { + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + switch (ch) { + case 'H': + parser->state = s_res_H; + break; + + case CR: + case LF: + break; + + default: + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + + CALLBACK_NOTIFY(message_begin); + break; + } + + case s_res_H: + STRICT_CHECK(ch != 'T'); + parser->state = s_res_HT; + break; + + case s_res_HT: + STRICT_CHECK(ch != 'T'); + parser->state = s_res_HTT; + break; + + case s_res_HTT: + STRICT_CHECK(ch != 'P'); + parser->state = s_res_HTTP; + break; + + case s_res_HTTP: + STRICT_CHECK(ch != '/'); + parser->state = s_res_first_http_major; + break; + + case s_res_first_http_major: + if (ch < '0' || ch > '9') { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major = ch - '0'; + parser->state = s_res_http_major; + break; + + /* major HTTP version or dot */ + case s_res_http_major: + { + if (ch == '.') { + parser->state = s_res_first_http_minor; + break; + } + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major *= 10; + parser->http_major += ch - '0'; + + if (parser->http_major > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + /* first digit of minor HTTP version */ + case s_res_first_http_minor: + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor = ch - '0'; + parser->state = s_res_http_minor; + break; + + /* minor HTTP version or end of request line */ + case s_res_http_minor: + { + if (ch == ' ') { + parser->state = s_res_first_status_code; + break; + } + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor *= 10; + parser->http_minor += ch - '0'; + + if (parser->http_minor > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + case s_res_first_status_code: + { + if (!IS_NUM(ch)) { + if (ch == ' ') { + break; + } + + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + parser->status_code = ch - '0'; + parser->state = s_res_status_code; + break; + } + + case s_res_status_code: + { + if (!IS_NUM(ch)) { + switch (ch) { + case ' ': + parser->state = s_res_status; + break; + case CR: + parser->state = s_res_line_almost_done; + break; + case LF: + parser->state = s_header_field_start; + break; + default: + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + break; + } + + parser->status_code *= 10; + parser->status_code += ch - '0'; + + if (parser->status_code > 999) { + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + + break; + } + + case s_res_status: + /* the human readable status. e.g. "NOT FOUND" + * we are not humans so just ignore this */ + if (ch == CR) { + parser->state = s_res_line_almost_done; + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + break; + } + break; + + case s_res_line_almost_done: + STRICT_CHECK(ch != LF); + parser->state = s_header_field_start; + CALLBACK_NOTIFY(status_complete); + break; + + case s_start_req: + { + if (ch == CR || ch == LF) + break; + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + if (!IS_ALPHA(ch)) { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + parser->method = (enum http_method) 0; + parser->index = 1; + switch (ch) { + case 'C': parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT */ break; + case 'D': parser->method = HTTP_DELETE; break; + case 'G': parser->method = HTTP_GET; break; + case 'H': parser->method = HTTP_HEAD; break; + case 'L': parser->method = HTTP_LOCK; break; + case 'M': parser->method = HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH */ break; + case 'N': parser->method = HTTP_NOTIFY; break; + case 'O': parser->method = HTTP_OPTIONS; break; + case 'P': parser->method = HTTP_POST; + /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ + break; + case 'R': parser->method = HTTP_REPORT; break; + case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ break; + case 'T': parser->method = HTTP_TRACE; break; + case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; + default: + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + parser->state = s_req_method; + + CALLBACK_NOTIFY(message_begin); + + break; + } + + case s_req_method: + { + const char *matcher; + if (ch == '\0') { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + matcher = method_strings[parser->method]; + if (ch == ' ' && matcher[parser->index] == '\0') { + parser->state = s_req_spaces_before_url; + } else if (ch == matcher[parser->index]) { + ; /* nada */ + } else if (parser->method == HTTP_CONNECT) { + if (parser->index == 1 && ch == 'H') { + parser->method = HTTP_CHECKOUT; + } else if (parser->index == 2 && ch == 'P') { + parser->method = HTTP_COPY; + } else { + goto error; + } + } else if (parser->method == HTTP_MKCOL) { + if (parser->index == 1 && ch == 'O') { + parser->method = HTTP_MOVE; + } else if (parser->index == 1 && ch == 'E') { + parser->method = HTTP_MERGE; + } else if (parser->index == 1 && ch == '-') { + parser->method = HTTP_MSEARCH; + } else if (parser->index == 2 && ch == 'A') { + parser->method = HTTP_MKACTIVITY; + } else { + goto error; + } + } else if (parser->method == HTTP_SUBSCRIBE) { + if (parser->index == 1 && ch == 'E') { + parser->method = HTTP_SEARCH; + } else { + goto error; + } + } else if (parser->index == 1 && parser->method == HTTP_POST) { + if (ch == 'R') { + parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ + } else if (ch == 'U') { + parser->method = HTTP_PUT; /* or HTTP_PURGE */ + } else if (ch == 'A') { + parser->method = HTTP_PATCH; + } else { + goto error; + } + } else if (parser->index == 2) { + if (parser->method == HTTP_PUT) { + if (ch == 'R') parser->method = HTTP_PURGE; + } else if (parser->method == HTTP_UNLOCK) { + if (ch == 'S') parser->method = HTTP_UNSUBSCRIBE; + } + } else if (parser->index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') { + parser->method = HTTP_PROPPATCH; + } else { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + ++parser->index; + break; + } + + case s_req_spaces_before_url: + { + if (ch == ' ') break; + + MARK(url); + if (parser->method == HTTP_CONNECT) { + parser->state = s_req_server_start; + } + + parser->state = parse_url_char((enum state)parser->state, ch); + if (parser->state == s_dead) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + + break; + } + + case s_req_schema: + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + { + switch (ch) { + /* No whitespace allowed here */ + case ' ': + case CR: + case LF: + SET_ERRNO(HPE_INVALID_URL); + goto error; + default: + parser->state = parse_url_char((enum state)parser->state, ch); + if (parser->state == s_dead) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + } + + break; + } + + case s_req_server: + case s_req_server_with_at: + case s_req_path: + case s_req_query_string_start: + case s_req_query_string: + case s_req_fragment_start: + case s_req_fragment: + { + switch (ch) { + case ' ': + parser->state = s_req_http_start; + CALLBACK_DATA(url); + break; + case CR: + case LF: + parser->http_major = 0; + parser->http_minor = 9; + parser->state = (ch == CR) ? + s_req_line_almost_done : + s_header_field_start; + CALLBACK_DATA(url); + break; + default: + parser->state = parse_url_char((enum state)parser->state, ch); + if (parser->state == s_dead) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + } + break; + } + + case s_req_http_start: + switch (ch) { + case 'H': + parser->state = s_req_http_H; + break; + case ' ': + break; + default: + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + break; + + case s_req_http_H: + STRICT_CHECK(ch != 'T'); + parser->state = s_req_http_HT; + break; + + case s_req_http_HT: + STRICT_CHECK(ch != 'T'); + parser->state = s_req_http_HTT; + break; + + case s_req_http_HTT: + STRICT_CHECK(ch != 'P'); + parser->state = s_req_http_HTTP; + break; + + case s_req_http_HTTP: + STRICT_CHECK(ch != '/'); + parser->state = s_req_first_http_major; + break; + + /* first digit of major HTTP version */ + case s_req_first_http_major: + if (ch < '1' || ch > '9') { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major = ch - '0'; + parser->state = s_req_http_major; + break; + + /* major HTTP version or dot */ + case s_req_http_major: + { + if (ch == '.') { + parser->state = s_req_first_http_minor; + break; + } + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major *= 10; + parser->http_major += ch - '0'; + + if (parser->http_major > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + /* first digit of minor HTTP version */ + case s_req_first_http_minor: + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor = ch - '0'; + parser->state = s_req_http_minor; + break; + + /* minor HTTP version or end of request line */ + case s_req_http_minor: + { + if (ch == CR) { + parser->state = s_req_line_almost_done; + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + break; + } + + /* XXX allow spaces after digit? */ + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor *= 10; + parser->http_minor += ch - '0'; + + if (parser->http_minor > 999) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + break; + } + + /* end of request line */ + case s_req_line_almost_done: + { + if (ch != LF) { + SET_ERRNO(HPE_LF_EXPECTED); + goto error; + } + + parser->state = s_header_field_start; + break; + } + + case s_header_field_start: + { + if (ch == CR) { + parser->state = s_headers_almost_done; + break; + } + + if (ch == LF) { + /* they might be just sending \n instead of \r\n so this would be + * the second \n to denote the end of headers*/ + parser->state = s_headers_almost_done; + goto reexecute_byte; + } + + c = TOKEN(ch); + + if (!c) { + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + + MARK(header_field); + + parser->index = 0; + parser->state = s_header_field; + + switch (c) { + case 'c': + parser->header_state = h_C; + break; + + case 'p': + parser->header_state = h_matching_proxy_connection; + break; + + case 't': + parser->header_state = h_matching_transfer_encoding; + break; + + case 'u': + parser->header_state = h_matching_upgrade; + break; + + default: + parser->header_state = h_general; + break; + } + break; + } + + case s_header_field: + { + c = TOKEN(ch); + + if (c) { + switch (parser->header_state) { + case h_general: + break; + + case h_C: + parser->index++; + parser->header_state = (c == 'o' ? h_CO : h_general); + break; + + case h_CO: + parser->index++; + parser->header_state = (c == 'n' ? h_CON : h_general); + break; + + case h_CON: + parser->index++; + switch (c) { + case 'n': + parser->header_state = h_matching_connection; + break; + case 't': + parser->header_state = h_matching_content_length; + break; + default: + parser->header_state = h_general; + break; + } + break; + + /* connection */ + + case h_matching_connection: + parser->index++; + if (parser->index > sizeof(CONNECTION)-1 + || c != CONNECTION[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONNECTION)-2) { + parser->header_state = h_connection; + } + break; + + /* proxy-connection */ + + case h_matching_proxy_connection: + parser->index++; + if (parser->index > sizeof(PROXY_CONNECTION)-1 + || c != PROXY_CONNECTION[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(PROXY_CONNECTION)-2) { + parser->header_state = h_connection; + } + break; + + /* content-length */ + + case h_matching_content_length: + parser->index++; + if (parser->index > sizeof(CONTENT_LENGTH)-1 + || c != CONTENT_LENGTH[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONTENT_LENGTH)-2) { + parser->header_state = h_content_length; + } + break; + + /* transfer-encoding */ + + case h_matching_transfer_encoding: + parser->index++; + if (parser->index > sizeof(TRANSFER_ENCODING)-1 + || c != TRANSFER_ENCODING[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(TRANSFER_ENCODING)-2) { + parser->header_state = h_transfer_encoding; + } + break; + + /* upgrade */ + + case h_matching_upgrade: + parser->index++; + if (parser->index > sizeof(UPGRADE)-1 + || c != UPGRADE[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(UPGRADE)-2) { + parser->header_state = h_upgrade; + } + break; + + case h_connection: + case h_content_length: + case h_transfer_encoding: + case h_upgrade: + if (ch != ' ') parser->header_state = h_general; + break; + + default: + assert(0 && "Unknown header_state"); + break; + } + break; + } + + if (ch == ':') { + parser->state = s_header_value_start; + CALLBACK_DATA(header_field); + break; + } + + if (ch == CR) { + parser->state = s_header_almost_done; + CALLBACK_DATA(header_field); + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + CALLBACK_DATA(header_field); + break; + } + + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + + case s_header_value_start: + { + if (ch == ' ' || ch == '\t') break; + + MARK(header_value); + + parser->state = s_header_value; + parser->index = 0; + + if (ch == CR) { + parser->header_state = h_general; + parser->state = s_header_almost_done; + CALLBACK_DATA(header_value); + break; + } + + if (ch == LF) { + parser->state = s_header_field_start; + CALLBACK_DATA(header_value); + break; + } + + c = LOWER(ch); + + switch (parser->header_state) { + case h_upgrade: + parser->flags |= F_UPGRADE; + parser->header_state = h_general; + break; + + case h_transfer_encoding: + /* looking for 'Transfer-Encoding: chunked' */ + if ('c' == c) { + parser->header_state = h_matching_transfer_encoding_chunked; + } else { + parser->header_state = h_general; + } + break; + + case h_content_length: + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + parser->content_length = ch - '0'; + break; + + case h_connection: + /* looking for 'Connection: keep-alive' */ + if (c == 'k') { + parser->header_state = h_matching_connection_keep_alive; + /* looking for 'Connection: close' */ + } else if (c == 'c') { + parser->header_state = h_matching_connection_close; + } else { + parser->header_state = h_general; + } + break; + + default: + parser->header_state = h_general; + break; + } + break; + } + + case s_header_value: + { + + if (ch == CR) { + parser->state = s_header_almost_done; + CALLBACK_DATA(header_value); + break; + } + + if (ch == LF) { + parser->state = s_header_almost_done; + CALLBACK_DATA_NOADVANCE(header_value); + goto reexecute_byte; + } + + c = LOWER(ch); + + switch (parser->header_state) { + case h_general: + break; + + case h_connection: + case h_transfer_encoding: + assert(0 && "Shouldn't get here."); + break; + + case h_content_length: + { + uint64_t t; + + if (ch == ' ') break; + + if (!IS_NUM(ch)) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + t = parser->content_length; + t *= 10; + t += ch - '0'; + + /* Overflow? */ + if (t < parser->content_length || t == ULLONG_MAX) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + parser->content_length = t; + break; + } + + /* Transfer-Encoding: chunked */ + case h_matching_transfer_encoding_chunked: + parser->index++; + if (parser->index > sizeof(CHUNKED)-1 + || c != CHUNKED[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CHUNKED)-2) { + parser->header_state = h_transfer_encoding_chunked; + } + break; + + /* looking for 'Connection: keep-alive' */ + case h_matching_connection_keep_alive: + parser->index++; + if (parser->index > sizeof(KEEP_ALIVE)-1 + || c != KEEP_ALIVE[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(KEEP_ALIVE)-2) { + parser->header_state = h_connection_keep_alive; + } + break; + + /* looking for 'Connection: close' */ + case h_matching_connection_close: + parser->index++; + if (parser->index > sizeof(CLOSE)-1 || c != CLOSE[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CLOSE)-2) { + parser->header_state = h_connection_close; + } + break; + + case h_transfer_encoding_chunked: + case h_connection_keep_alive: + case h_connection_close: + if (ch != ' ') parser->header_state = h_general; + break; + + default: + parser->state = s_header_value; + parser->header_state = h_general; + break; + } + break; + } + + case s_header_almost_done: + { + STRICT_CHECK(ch != LF); + + parser->state = s_header_value_lws; + + switch (parser->header_state) { + case h_connection_keep_alive: + parser->flags |= F_CONNECTION_KEEP_ALIVE; + break; + case h_connection_close: + parser->flags |= F_CONNECTION_CLOSE; + break; + case h_transfer_encoding_chunked: + parser->flags |= F_CHUNKED; + break; + default: + break; + } + + break; + } + + case s_header_value_lws: + { + if (ch == ' ' || ch == '\t') + parser->state = s_header_value_start; + else + { + parser->state = s_header_field_start; + goto reexecute_byte; + } + break; + } + + case s_headers_almost_done: + { + STRICT_CHECK(ch != LF); + + if (parser->flags & F_TRAILING) { + /* End of a chunked request */ + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + break; + } + + parser->state = s_headers_done; + + /* Set this here so that on_headers_complete() callbacks can see it */ + parser->upgrade = + (parser->flags & F_UPGRADE || parser->method == HTTP_CONNECT); + + /* Here we call the headers_complete callback. This is somewhat + * different than other callbacks because if the user returns 1, we + * will interpret that as saying that this message has no body. This + * is needed for the annoying case of recieving a response to a HEAD + * request. + * + * We'd like to use CALLBACK_NOTIFY_NOADVANCE() here but we cannot, so + * we have to simulate it by handling a change in errno below. + */ + if (settings->on_headers_complete) { + switch (settings->on_headers_complete(parser)) { + case 0: + break; + + case 1: + parser->flags |= F_SKIPBODY; + break; + + default: + SET_ERRNO(HPE_CB_headers_complete); + return p - data; /* Error */ + } + } + + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { + return p - data; + } + + goto reexecute_byte; + } + + case s_headers_done: + { + STRICT_CHECK(ch != LF); + + parser->nread = 0; + + /* Exit, the rest of the connect is in a different protocol. */ + if (parser->upgrade) { + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + return (p - data) + 1; + } + + if (parser->flags & F_SKIPBODY) { + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + } else if (parser->flags & F_CHUNKED) { + /* chunked encoding - ignore Content-Length header */ + parser->state = s_chunk_size_start; + } else { + if (parser->content_length == 0) { + /* Content-Length header given but zero: Content-Length: 0\r\n */ + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + } else if (parser->content_length != ULLONG_MAX) { + /* Content-Length header given and non-zero */ + parser->state = s_body_identity; + } else { + if (parser->type == HTTP_REQUEST || + !http_message_needs_eof(parser)) { + /* Assume content-length 0 - read the next */ + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + } else { + /* Read body until EOF */ + parser->state = s_body_identity_eof; + } + } + } + + break; + } + + case s_body_identity: + { + uint64_t to_read = MIN(parser->content_length, + (uint64_t) ((data + len) - p)); + + assert(parser->content_length != 0 + && parser->content_length != ULLONG_MAX); + + /* The difference between advancing content_length and p is because + * the latter will automaticaly advance on the next loop iteration. + * Further, if content_length ends up at 0, we want to see the last + * byte again for our message complete callback. + */ + MARK(body); + parser->content_length -= to_read; + p += to_read - 1; + + if (parser->content_length == 0) { + parser->state = s_message_done; + + /* Mimic CALLBACK_DATA_NOADVANCE() but with one extra byte. + * + * The alternative to doing this is to wait for the next byte to + * trigger the data callback, just as in every other case. The + * problem with this is that this makes it difficult for the test + * harness to distinguish between complete-on-EOF and + * complete-on-length. It's not clear that this distinction is + * important for applications, but let's keep it for now. + */ + CALLBACK_DATA_(body, p - body_mark + 1, p - data); + goto reexecute_byte; + } + + break; + } + + /* read until EOF */ + case s_body_identity_eof: + MARK(body); + p = data + len - 1; + + break; + + case s_message_done: + parser->state = NEW_MESSAGE(); + CALLBACK_NOTIFY(message_complete); + break; + + case s_chunk_size_start: + { + assert(parser->nread == 1); + assert(parser->flags & F_CHUNKED); + + unhex_val = unhex[(unsigned char)ch]; + if (unhex_val == -1) { + SET_ERRNO(HPE_INVALID_CHUNK_SIZE); + goto error; + } + + parser->content_length = unhex_val; + parser->state = s_chunk_size; + break; + } + + case s_chunk_size: + { + uint64_t t; + + assert(parser->flags & F_CHUNKED); + + if (ch == CR) { + parser->state = s_chunk_size_almost_done; + break; + } + + unhex_val = unhex[(unsigned char)ch]; + + if (unhex_val == -1) { + if (ch == ';' || ch == ' ') { + parser->state = s_chunk_parameters; + break; + } + + SET_ERRNO(HPE_INVALID_CHUNK_SIZE); + goto error; + } + + t = parser->content_length; + t *= 16; + t += unhex_val; + + /* Overflow? */ + if (t < parser->content_length || t == ULLONG_MAX) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + parser->content_length = t; + break; + } + + case s_chunk_parameters: + { + assert(parser->flags & F_CHUNKED); + /* just ignore this shit. TODO check for overflow */ + if (ch == CR) { + parser->state = s_chunk_size_almost_done; + break; + } + break; + } + + case s_chunk_size_almost_done: + { + assert(parser->flags & F_CHUNKED); + STRICT_CHECK(ch != LF); + + parser->nread = 0; + + if (parser->content_length == 0) { + parser->flags |= F_TRAILING; + parser->state = s_header_field_start; + } else { + parser->state = s_chunk_data; + } + break; + } + + case s_chunk_data: + { + uint64_t to_read = MIN(parser->content_length, + (uint64_t) ((data + len) - p)); + + assert(parser->flags & F_CHUNKED); + assert(parser->content_length != 0 + && parser->content_length != ULLONG_MAX); + + /* See the explanation in s_body_identity for why the content + * length and data pointers are managed this way. + */ + MARK(body); + parser->content_length -= to_read; + p += to_read - 1; + + if (parser->content_length == 0) { + parser->state = s_chunk_data_almost_done; + } + + break; + } + + case s_chunk_data_almost_done: + assert(parser->flags & F_CHUNKED); + assert(parser->content_length == 0); + STRICT_CHECK(ch != CR); + parser->state = s_chunk_data_done; + CALLBACK_DATA(body); + break; + + case s_chunk_data_done: + assert(parser->flags & F_CHUNKED); + STRICT_CHECK(ch != LF); + parser->nread = 0; + parser->state = s_chunk_size_start; + break; + + default: + assert(0 && "unhandled state"); + SET_ERRNO(HPE_INVALID_INTERNAL_STATE); + goto error; + } + } + + /* Run callbacks for any marks that we have leftover after we ran our of + * bytes. There should be at most one of these set, so it's OK to invoke + * them in series (unset marks will not result in callbacks). + * + * We use the NOADVANCE() variety of callbacks here because 'p' has already + * overflowed 'data' and this allows us to correct for the off-by-one that + * we'd otherwise have (since CALLBACK_DATA() is meant to be run with a 'p' + * value that's in-bounds). + */ + + assert(((header_field_mark ? 1 : 0) + + (header_value_mark ? 1 : 0) + + (url_mark ? 1 : 0) + + (body_mark ? 1 : 0)) <= 1); + + CALLBACK_DATA_NOADVANCE(header_field); + CALLBACK_DATA_NOADVANCE(header_value); + CALLBACK_DATA_NOADVANCE(url); + CALLBACK_DATA_NOADVANCE(body); + + return len; + +error: + if (HTTP_PARSER_ERRNO(parser) == HPE_OK) { + SET_ERRNO(HPE_UNKNOWN); + } + + return (p - data); +} + + +/* Does the parser need to see an EOF to find the end of the message? */ +int +http_message_needs_eof (const http_parser *parser) +{ + if (parser->type == HTTP_REQUEST) { + return 0; + } + + /* See RFC 2616 section 4.4 */ + if (parser->status_code / 100 == 1 || /* 1xx e.g. Continue */ + parser->status_code == 204 || /* No Content */ + parser->status_code == 304 || /* Not Modified */ + parser->flags & F_SKIPBODY) { /* response to a HEAD request */ + return 0; + } + + if ((parser->flags & F_CHUNKED) || parser->content_length != ULLONG_MAX) { + return 0; + } + + return 1; +} + + +int +http_should_keep_alive (const http_parser *parser) +{ + if (parser->http_major > 0 && parser->http_minor > 0) { + /* HTTP/1.1 */ + if (parser->flags & F_CONNECTION_CLOSE) { + return 0; + } + } else { + /* HTTP/1.0 or earlier */ + if (!(parser->flags & F_CONNECTION_KEEP_ALIVE)) { + return 0; + } + } + + return !http_message_needs_eof(parser); +} + + +const char * +http_method_str (enum http_method m) +{ + return ELEM_AT(method_strings, m, ""); +} + + +void +http_parser_init (http_parser *parser, enum http_parser_type t) +{ + void *data = parser->data; /* preserve application data */ + memset(parser, 0, sizeof(*parser)); + parser->data = data; + parser->type = t; + parser->state = (t == HTTP_REQUEST ? s_start_req : (t == HTTP_RESPONSE ? s_start_res : s_start_req_or_res)); + parser->http_errno = HPE_OK; +} + +const char * +http_errno_name(enum http_errno err) { + assert(err < (sizeof(http_strerror_tab)/sizeof(http_strerror_tab[0]))); + return http_strerror_tab[err].name; +} + +const char * +http_errno_description(enum http_errno err) { + assert(err < (sizeof(http_strerror_tab)/sizeof(http_strerror_tab[0]))); + return http_strerror_tab[err].description; +} + +static enum http_host_state +http_parse_host_char(enum http_host_state s, const char ch) { + switch(s) { + case s_http_userinfo: + case s_http_userinfo_start: + if (ch == '@') { + return s_http_host_start; + } + + if (IS_USERINFO_CHAR(ch)) { + return s_http_userinfo; + } + break; + + case s_http_host_start: + if (ch == '[') { + return s_http_host_v6_start; + } + + if (IS_HOST_CHAR(ch)) { + return s_http_host; + } + + break; + + case s_http_host: + if (IS_HOST_CHAR(ch)) { + return s_http_host; + } + + /* FALLTHROUGH */ + case s_http_host_v6_end: + if (ch == ':') { + return s_http_host_port_start; + } + + break; + + case s_http_host_v6: + if (ch == ']') { + return s_http_host_v6_end; + } + + /* FALLTHROUGH */ + case s_http_host_v6_start: + if (IS_HEX(ch) || ch == ':' || ch == '.') { + return s_http_host_v6; + } + + break; + + case s_http_host_port: + case s_http_host_port_start: + if (IS_NUM(ch)) { + return s_http_host_port; + } + + break; + + default: + break; + } + return s_http_host_dead; +} + +static int +http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { + enum http_host_state s; + + const char *p; + size_t buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len; + + u->field_data[UF_HOST].len = 0; + + s = found_at ? s_http_userinfo_start : s_http_host_start; + + for (p = buf + u->field_data[UF_HOST].off; p < buf + buflen; p++) { + enum http_host_state new_s = http_parse_host_char(s, *p); + + if (new_s == s_http_host_dead) { + return 1; + } + + switch(new_s) { + case s_http_host: + if (s != s_http_host) { + u->field_data[UF_HOST].off = p - buf; + } + u->field_data[UF_HOST].len++; + break; + + case s_http_host_v6: + if (s != s_http_host_v6) { + u->field_data[UF_HOST].off = p - buf; + } + u->field_data[UF_HOST].len++; + break; + + case s_http_host_port: + if (s != s_http_host_port) { + u->field_data[UF_PORT].off = p - buf; + u->field_data[UF_PORT].len = 0; + u->field_set |= (1 << UF_PORT); + } + u->field_data[UF_PORT].len++; + break; + + case s_http_userinfo: + if (s != s_http_userinfo) { + u->field_data[UF_USERINFO].off = p - buf ; + u->field_data[UF_USERINFO].len = 0; + u->field_set |= (1 << UF_USERINFO); + } + u->field_data[UF_USERINFO].len++; + break; + + default: + break; + } + s = new_s; + } + + /* Make sure we don't end somewhere unexpected */ + switch (s) { + case s_http_host_start: + case s_http_host_v6_start: + case s_http_host_v6: + case s_http_host_port_start: + case s_http_userinfo: + case s_http_userinfo_start: + return 1; + default: + break; + } + + return 0; +} + +int +http_parser_parse_url(const char *buf, size_t buflen, int is_connect, + struct http_parser_url *u) +{ + enum state s; + const char *p; + enum http_parser_url_fields uf, old_uf; + int found_at = 0; + + u->port = u->field_set = 0; + s = is_connect ? s_req_server_start : s_req_spaces_before_url; + uf = old_uf = UF_MAX; + + for (p = buf; p < buf + buflen; p++) { + s = parse_url_char(s, *p); + + /* Figure out the next field that we're operating on */ + switch (s) { + case s_dead: + return 1; + + /* Skip delimeters */ + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + case s_req_query_string_start: + case s_req_fragment_start: + continue; + + case s_req_schema: + uf = UF_SCHEMA; + break; + + case s_req_server_with_at: + found_at = 1; + + /* FALLTROUGH */ + case s_req_server: + uf = UF_HOST; + break; + + case s_req_path: + uf = UF_PATH; + break; + + case s_req_query_string: + uf = UF_QUERY; + break; + + case s_req_fragment: + uf = UF_FRAGMENT; + break; + + default: + assert(!"Unexpected state"); + return 1; + } + + /* Nothing's changed; soldier on */ + if (uf == old_uf) { + u->field_data[uf].len++; + continue; + } + + u->field_data[uf].off = p - buf; + u->field_data[uf].len = 1; + + u->field_set |= (1 << uf); + old_uf = uf; + } + + /* host must be present if there is a schema */ + /* parsing http:///toto will fail */ + if ((u->field_set & ((1 << UF_SCHEMA) | (1 << UF_HOST))) != 0) { + if (http_parse_host(buf, u, found_at) != 0) { + return 1; + } + } + + /* CONNECT requests can only contain "hostname:port" */ + if (is_connect && u->field_set != ((1 << UF_HOST)|(1 << UF_PORT))) { + return 1; + } + + if (u->field_set & (1 << UF_PORT)) { + /* Don't bother with endp; we've already validated the string */ + unsigned long v = strtoul(buf + u->field_data[UF_PORT].off, NULL, 10); + + /* Ports have a max value of 2^16 */ + if (v > 0xffff) { + return 1; + } + + u->port = (uint16_t) v; + } + + return 0; +} + +void +http_parser_pause(http_parser *parser, int paused) { + /* Users should only be pausing/unpausing a parser that is not in an error + * state. In non-debug builds, there's not much that we can do about this + * other than ignore it. + */ + if (HTTP_PARSER_ERRNO(parser) == HPE_OK || + HTTP_PARSER_ERRNO(parser) == HPE_PAUSED) { + SET_ERRNO((paused) ? HPE_PAUSED : HPE_OK); + } else { + assert(0 && "Attempting to pause parser in error state"); + } +} + +int +http_body_is_final(const struct http_parser *parser) { + return parser->state == s_message_done; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.gyp b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.gyp new file mode 100644 index 0000000..c6eada7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.gyp @@ -0,0 +1,79 @@ +# This file is used with the GYP meta build system. +# http://code.google.com/p/gyp/ +# To build try this: +# svn co http://gyp.googlecode.com/svn/trunk gyp +# ./gyp/gyp -f make --depth=`pwd` http_parser.gyp +# ./out/Debug/test +{ + 'target_defaults': { + 'default_configuration': 'Debug', + 'configurations': { + # TODO: hoist these out and put them somewhere common, because + # RuntimeLibrary MUST MATCH across the entire project + 'Debug': { + 'defines': [ 'DEBUG', '_DEBUG' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 1, # static debug + }, + }, + }, + 'Release': { + 'defines': [ 'NDEBUG' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 0, # static release + }, + }, + } + }, + 'msvs_settings': { + 'VCCLCompilerTool': { + }, + 'VCLibrarianTool': { + }, + 'VCLinkerTool': { + 'GenerateDebugInformation': 'true', + }, + }, + 'conditions': [ + ['OS == "win"', { + 'defines': [ + 'WIN32' + ], + }] + ], + }, + + 'targets': [ + { + 'target_name': 'http_parser', + 'type': 'static_library', + 'include_dirs': [ '.' ], + 'direct_dependent_settings': { + 'include_dirs': [ '.' ], + }, + 'defines': [ 'HTTP_PARSER_STRICT=0' ], + 'sources': [ './http_parser.c', ], + 'conditions': [ + ['OS=="win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + # Compile as C++. http_parser.c is actually C99, but C++ is + # close enough in this case. + 'CompileAs': 2, + }, + }, + }] + ], + }, + + { + 'target_name': 'test', + 'type': 'executable', + 'dependencies': [ 'http_parser' ], + 'sources': [ 'test.c' ] + } + ] +} + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.h b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.h new file mode 100644 index 0000000..2fff4bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/http_parser.h @@ -0,0 +1,304 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#ifndef http_parser_h +#define http_parser_h +#ifdef __cplusplus +extern "C" { +#endif + +#define HTTP_PARSER_VERSION_MAJOR 2 +#define HTTP_PARSER_VERSION_MINOR 0 + +#include +#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600) +#include +#include +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run + * faster + */ +#ifndef HTTP_PARSER_STRICT +# define HTTP_PARSER_STRICT 1 +#endif + +/* Maximium header size allowed */ +#define HTTP_MAX_HEADER_SIZE (80*1024) + + +typedef struct http_parser http_parser; +typedef struct http_parser_settings http_parser_settings; + + +/* Callbacks should return non-zero to indicate an error. The parser will + * then halt execution. + * + * The one exception is on_headers_complete. In a HTTP_RESPONSE parser + * returning '1' from on_headers_complete will tell the parser that it + * should not expect a body. This is used when receiving a response to a + * HEAD request which may contain 'Content-Length' or 'Transfer-Encoding: + * chunked' headers that indicate the presence of a body. + * + * http_data_cb does not return data chunks. It will be call arbitrarally + * many times for each string. E.G. you might get 10 callbacks for "on_url" + * each providing just a few characters more data. + */ +typedef int (*http_data_cb) (http_parser*, const char *at, size_t length); +typedef int (*http_cb) (http_parser*); + + +/* Request Methods */ +#define HTTP_METHOD_MAP(XX) \ + XX(0, DELETE, DELETE) \ + XX(1, GET, GET) \ + XX(2, HEAD, HEAD) \ + XX(3, POST, POST) \ + XX(4, PUT, PUT) \ + /* pathological */ \ + XX(5, CONNECT, CONNECT) \ + XX(6, OPTIONS, OPTIONS) \ + XX(7, TRACE, TRACE) \ + /* webdav */ \ + XX(8, COPY, COPY) \ + XX(9, LOCK, LOCK) \ + XX(10, MKCOL, MKCOL) \ + XX(11, MOVE, MOVE) \ + XX(12, PROPFIND, PROPFIND) \ + XX(13, PROPPATCH, PROPPATCH) \ + XX(14, SEARCH, SEARCH) \ + XX(15, UNLOCK, UNLOCK) \ + /* subversion */ \ + XX(16, REPORT, REPORT) \ + XX(17, MKACTIVITY, MKACTIVITY) \ + XX(18, CHECKOUT, CHECKOUT) \ + XX(19, MERGE, MERGE) \ + /* upnp */ \ + XX(20, MSEARCH, M-SEARCH) \ + XX(21, NOTIFY, NOTIFY) \ + XX(22, SUBSCRIBE, SUBSCRIBE) \ + XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \ + /* RFC-5789 */ \ + XX(24, PATCH, PATCH) \ + XX(25, PURGE, PURGE) \ + +enum http_method + { +#define XX(num, name, string) HTTP_##name = num, + HTTP_METHOD_MAP(XX) +#undef XX + }; + + +enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH }; + + +/* Flag values for http_parser.flags field */ +enum flags + { F_CHUNKED = 1 << 0 + , F_CONNECTION_KEEP_ALIVE = 1 << 1 + , F_CONNECTION_CLOSE = 1 << 2 + , F_TRAILING = 1 << 3 + , F_UPGRADE = 1 << 4 + , F_SKIPBODY = 1 << 5 + }; + + +/* Map for errno-related constants + * + * The provided argument should be a macro that takes 2 arguments. + */ +#define HTTP_ERRNO_MAP(XX) \ + /* No error */ \ + XX(OK, "success") \ + \ + /* Callback-related errors */ \ + XX(CB_message_begin, "the on_message_begin callback failed") \ + XX(CB_status_complete, "the on_status_complete callback failed") \ + XX(CB_url, "the on_url callback failed") \ + XX(CB_header_field, "the on_header_field callback failed") \ + XX(CB_header_value, "the on_header_value callback failed") \ + XX(CB_headers_complete, "the on_headers_complete callback failed") \ + XX(CB_body, "the on_body callback failed") \ + XX(CB_message_complete, "the on_message_complete callback failed") \ + \ + /* Parsing-related errors */ \ + XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \ + XX(HEADER_OVERFLOW, \ + "too many header bytes seen; overflow detected") \ + XX(CLOSED_CONNECTION, \ + "data received after completed connection: close message") \ + XX(INVALID_VERSION, "invalid HTTP version") \ + XX(INVALID_STATUS, "invalid HTTP status code") \ + XX(INVALID_METHOD, "invalid HTTP method") \ + XX(INVALID_URL, "invalid URL") \ + XX(INVALID_HOST, "invalid host") \ + XX(INVALID_PORT, "invalid port") \ + XX(INVALID_PATH, "invalid path") \ + XX(INVALID_QUERY_STRING, "invalid query string") \ + XX(INVALID_FRAGMENT, "invalid fragment") \ + XX(LF_EXPECTED, "LF character expected") \ + XX(INVALID_HEADER_TOKEN, "invalid character in header") \ + XX(INVALID_CONTENT_LENGTH, \ + "invalid character in content-length header") \ + XX(INVALID_CHUNK_SIZE, \ + "invalid character in chunk size header") \ + XX(INVALID_CONSTANT, "invalid constant string") \ + XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\ + XX(STRICT, "strict mode assertion failed") \ + XX(PAUSED, "parser is paused") \ + XX(UNKNOWN, "an unknown error occurred") + + +/* Define HPE_* values for each errno value above */ +#define HTTP_ERRNO_GEN(n, s) HPE_##n, +enum http_errno { + HTTP_ERRNO_MAP(HTTP_ERRNO_GEN) +}; +#undef HTTP_ERRNO_GEN + + +/* Get an http_errno value from an http_parser */ +#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno) + + +struct http_parser { + /** PRIVATE **/ + unsigned char type : 2; /* enum http_parser_type */ + unsigned char flags : 6; /* F_* values from 'flags' enum; semi-public */ + unsigned char state; /* enum state from http_parser.c */ + unsigned char header_state; /* enum header_state from http_parser.c */ + unsigned char index; /* index into current matcher */ + + uint32_t nread; /* # bytes read in various scenarios */ + uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */ + + /** READ-ONLY **/ + unsigned short http_major; + unsigned short http_minor; + unsigned short status_code; /* responses only */ + unsigned char method; /* requests only */ + unsigned char http_errno : 7; + + /* 1 = Upgrade header was present and the parser has exited because of that. + * 0 = No upgrade header present. + * Should be checked when http_parser_execute() returns in addition to + * error checking. + */ + unsigned char upgrade : 1; + + /** PUBLIC **/ + void *data; /* A pointer to get hook to the "connection" or "socket" object */ +}; + + +struct http_parser_settings { + http_cb on_message_begin; + http_data_cb on_url; + http_cb on_status_complete; + http_data_cb on_header_field; + http_data_cb on_header_value; + http_cb on_headers_complete; + http_data_cb on_body; + http_cb on_message_complete; +}; + + +enum http_parser_url_fields + { UF_SCHEMA = 0 + , UF_HOST = 1 + , UF_PORT = 2 + , UF_PATH = 3 + , UF_QUERY = 4 + , UF_FRAGMENT = 5 + , UF_USERINFO = 6 + , UF_MAX = 7 + }; + + +/* Result structure for http_parser_parse_url(). + * + * Callers should index into field_data[] with UF_* values iff field_set + * has the relevant (1 << UF_*) bit set. As a courtesy to clients (and + * because we probably have padding left over), we convert any port to + * a uint16_t. + */ +struct http_parser_url { + uint16_t field_set; /* Bitmask of (1 << UF_*) values */ + uint16_t port; /* Converted UF_PORT string */ + + struct { + uint16_t off; /* Offset into buffer in which field starts */ + uint16_t len; /* Length of run in buffer */ + } field_data[UF_MAX]; +}; + + +void http_parser_init(http_parser *parser, enum http_parser_type type); + + +size_t http_parser_execute(http_parser *parser, + const http_parser_settings *settings, + const char *data, + size_t len); + + +/* If http_should_keep_alive() in the on_headers_complete or + * on_message_complete callback returns 0, then this should be + * the last message on the connection. + * If you are the server, respond with the "Connection: close" header. + * If you are the client, close the connection. + */ +int http_should_keep_alive(const http_parser *parser); + +/* Returns a string version of the HTTP method. */ +const char *http_method_str(enum http_method m); + +/* Return a string name of the given error */ +const char *http_errno_name(enum http_errno err); + +/* Return a string description of the given error */ +const char *http_errno_description(enum http_errno err); + +/* Parse a URL; return nonzero on failure */ +int http_parser_parse_url(const char *buf, size_t buflen, + int is_connect, + struct http_parser_url *u); + +/* Pause or un-pause the parser; a nonzero value pauses */ +void http_parser_pause(http_parser *parser, int paused); + +/* Checks if this is the final chunk of the body. */ +int http_body_is_final(const http_parser *parser); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/Http-parser.java.iml b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/Http-parser.java.iml new file mode 100644 index 0000000..741121a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/Http-parser.java.iml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/FieldData.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/FieldData.java new file mode 100644 index 0000000..774179f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/FieldData.java @@ -0,0 +1,41 @@ +package http_parser; + +public class FieldData { + public int off; + public int len; + + public FieldData(){} + + public FieldData(int off, int len){ + this.off = off; + this.len = len; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + FieldData fieldData = (FieldData) o; + + if (len != fieldData.len) return false; + if (off != fieldData.off) return false; + + return true; + } + + @Override + public int hashCode() { + int result = off; + result = 31 * result + len; + return result; + } + + @Override + public String toString() { + return "FieldData{" + + "off=" + off + + ", len=" + len + + '}'; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPCallback.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPCallback.java new file mode 100644 index 0000000..5380b0f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPCallback.java @@ -0,0 +1,8 @@ +package http_parser; + +public abstract class HTTPCallback implements http_parser.lolevel.HTTPCallback{ + public int cb (http_parser.lolevel.HTTPParser parser) { + return this.cb((HTTPParser)parser); + } + public abstract int cb (HTTPParser parser); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPDataCallback.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPDataCallback.java new file mode 100644 index 0000000..bfe576f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPDataCallback.java @@ -0,0 +1,34 @@ +package http_parser; + +import java.nio.ByteBuffer; + +public abstract class HTTPDataCallback implements http_parser.lolevel.HTTPDataCallback{ + /* + Very raw and extremly foolhardy! DANGER! + The whole Buffer concept is difficult enough to grasp as it is, + we pass in a buffer with an arbitrary position. + + The interesting data is located at position pos and is len + bytes long. + + The contract of this callback is that the buffer is + returned in the state that it was passed in, so implementing + this require good citizenship, you'll need to remember the current + position, change the position to get at the data you're interested + in and then set the position back to how you found it... + + Therefore: there is an abstract implementation that implements + cb as described above, and provides a new callback + with signature @see cb(byte[], int, int) + */ + public int cb(http_parser.lolevel.HTTPParser p, ByteBuffer buf, int pos, int len) { + byte [] by = new byte[len]; + int saved = buf.position(); + buf.position(pos); + buf.get(by); + buf.position(saved); + return cb((HTTPParser)p, by, 0, len); + } + + public abstract int cb(HTTPParser p, byte[] by, int pos, int len); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPErrorCallback.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPErrorCallback.java new file mode 100644 index 0000000..a74206e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPErrorCallback.java @@ -0,0 +1,12 @@ +package http_parser; + + +import java.nio.ByteBuffer; + +public abstract class HTTPErrorCallback implements http_parser.lolevel.HTTPErrorCallback{ + public void cb (http_parser.lolevel.HTTPParser parser, String mes, ByteBuffer buf, int initial_position) { + this.cb((HTTPParser)parser, Util.error(mes, buf, initial_position)); + } + + public abstract void cb(HTTPParser parser, String error); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPException.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPException.java new file mode 100644 index 0000000..9ccaf14 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPException.java @@ -0,0 +1,9 @@ +package http_parser; + +@SuppressWarnings("serial") +public class HTTPException extends RuntimeException { + +public HTTPException(String mes) { + super(mes); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPMethod.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPMethod.java new file mode 100644 index 0000000..7c080c1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPMethod.java @@ -0,0 +1,107 @@ +package http_parser; + +import java.nio.charset.Charset; + +public enum HTTPMethod { + HTTP_DELETE("DELETE")// = 0 + , HTTP_GET("GET") + , HTTP_HEAD("HEAD") + , HTTP_POST("POST") + , HTTP_PUT("PUT") + , HTTP_PATCH("PATCH") + /* pathological */ + , HTTP_CONNECT("CONNECT") + , HTTP_OPTIONS("OPTIONS") + , HTTP_TRACE("TRACE") + /* webdav */ + , HTTP_COPY("COPY") + , HTTP_LOCK("LOCK") + , HTTP_MKCOL("MKCOL") + , HTTP_MOVE("MOVE") + , HTTP_PROPFIND("PROPFIND") + , HTTP_PROPPATCH("PROPPATCH") + , HTTP_UNLOCK("UNLOCK") + , HTTP_REPORT("REPORT") + , HTTP_MKACTIVITY("MKACTIVITY") + , HTTP_CHECKOUT("CHECKOUT") + , HTTP_MERGE("MERGE") + , HTTP_MSEARCH("M-SEARCH") + , HTTP_NOTIFY("NOTIFY") + , HTTP_SUBSCRIBE("SUBSCRIBE") + , HTTP_UNSUBSCRIBE("UNSUBSCRIBE") + , HTTP_PURGE("PURGE") + ; + + private static Charset ASCII; + static { + ASCII = Charset.forName("US-ASCII");; + } + public byte[] bytes; + + HTTPMethod(String name) { + // good grief, Charlie Brown, the following is necessary because + // java is retarded: + // illegal reference to static field from initializer + // this.bytes = name.getBytes(ASCII); + // yet it's not illegal to reference static fields from + // methods called from initializer. + init(name); + } + public static HTTPMethod parse(String s) { + if ("HTTP_DELETE".equalsIgnoreCase(s)) {return HTTP_DELETE;} + else if ("DELETE".equalsIgnoreCase(s)) {return HTTP_DELETE;} + else if ("HTTP_GET".equalsIgnoreCase(s)) {return HTTP_GET;} + else if ("GET".equalsIgnoreCase(s)) {return HTTP_GET;} + else if ("HTTP_HEAD".equalsIgnoreCase(s)) {return HTTP_HEAD;} + else if ("HEAD".equalsIgnoreCase(s)) {return HTTP_HEAD;} + else if ("HTTP_POST".equalsIgnoreCase(s)) {return HTTP_POST;} + else if ("POST".equalsIgnoreCase(s)) {return HTTP_POST;} + else if ("HTTP_PUT".equalsIgnoreCase(s)) {return HTTP_PUT;} + else if ("PUT".equalsIgnoreCase(s)) {return HTTP_PUT;} + else if ("HTTP_PATCH".equalsIgnoreCase(s)) {return HTTP_PATCH;} + else if ("PATCH".equalsIgnoreCase(s)) {return HTTP_PATCH;} + else if ("HTTP_CONNECT".equalsIgnoreCase(s)) {return HTTP_CONNECT;} + else if ("CONNECT".equalsIgnoreCase(s)) {return HTTP_CONNECT;} + else if ("HTTP_OPTIONS".equalsIgnoreCase(s)) {return HTTP_OPTIONS;} + else if ("OPTIONS".equalsIgnoreCase(s)) {return HTTP_OPTIONS;} + else if ("HTTP_TRACE".equalsIgnoreCase(s)) {return HTTP_TRACE;} + else if ("TRACE".equalsIgnoreCase(s)) {return HTTP_TRACE;} + else if ("HTTP_COPY".equalsIgnoreCase(s)) {return HTTP_COPY;} + else if ("COPY".equalsIgnoreCase(s)) {return HTTP_COPY;} + else if ("HTTP_LOCK".equalsIgnoreCase(s)) {return HTTP_LOCK;} + else if ("LOCK".equalsIgnoreCase(s)) {return HTTP_LOCK;} + else if ("HTTP_MKCOL".equalsIgnoreCase(s)) {return HTTP_MKCOL;} + else if ("MKCOL".equalsIgnoreCase(s)) {return HTTP_MKCOL;} + else if ("HTTP_MOVE".equalsIgnoreCase(s)) {return HTTP_MOVE;} + else if ("MOVE".equalsIgnoreCase(s)) {return HTTP_MOVE;} + else if ("HTTP_PROPFIND".equalsIgnoreCase(s)){return HTTP_PROPFIND;} + else if ("PROPFIND".equalsIgnoreCase(s)) {return HTTP_PROPFIND;} + else if ("HTTP_PROPPATCH".equalsIgnoreCase(s)){return HTTP_PROPPATCH;} + else if ("PROPPATCH".equalsIgnoreCase(s)) {return HTTP_PROPPATCH;} + else if ("HTTP_UNLOCK".equalsIgnoreCase(s)) {return HTTP_UNLOCK;} + else if ("UNLOCK".equalsIgnoreCase(s)) {return HTTP_UNLOCK;} + else if ("HTTP_REPORT".equalsIgnoreCase(s)) {return HTTP_REPORT;} + else if ("REPORT".equalsIgnoreCase(s)){return HTTP_REPORT;} + else if ("HTTP_MKACTIVITY".equalsIgnoreCase(s)) {return HTTP_MKACTIVITY;} + else if ("MKACTIVITY".equalsIgnoreCase(s)){return HTTP_MKACTIVITY;} + else if ("HTTP_CHECKOUT".equalsIgnoreCase(s)) {return HTTP_CHECKOUT;} + else if ("CHECKOUT".equalsIgnoreCase(s)){return HTTP_CHECKOUT;} + else if ("HTTP_MERGE".equalsIgnoreCase(s)) {return HTTP_MERGE;} + else if ("MERGE".equalsIgnoreCase(s)){return HTTP_MERGE;} + else if ("HTTP_MSEARCH".equalsIgnoreCase(s)) {return HTTP_MSEARCH;} + else if ("M-SEARCH".equalsIgnoreCase(s)) {return HTTP_MSEARCH;} + else if ("HTTP_NOTIFY".equalsIgnoreCase(s)) {return HTTP_NOTIFY;} + else if ("NOTIFY".equalsIgnoreCase(s)) {return HTTP_NOTIFY;} + else if ("HTTP_SUBSCRIBE".equalsIgnoreCase(s)) {return HTTP_SUBSCRIBE;} + else if ("SUBSCRIBE".equalsIgnoreCase(s)) {return HTTP_SUBSCRIBE;} + else if ("HTTP_UNSUBSCRIBE".equalsIgnoreCase(s)) {return HTTP_UNSUBSCRIBE;} + else if ("UNSUBSCRIBE".equalsIgnoreCase(s)) {return HTTP_UNSUBSCRIBE;} + else if ("PATCH".equalsIgnoreCase(s)) {return HTTP_PATCH;} + else if ("PURGE".equalsIgnoreCase(s)) {return HTTP_PURGE;} + else {return null;} + } + void init (String name) { + ASCII = null == ASCII ? Charset.forName("US-ASCII") : ASCII; + this.bytes = name.getBytes(ASCII); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParser.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParser.java new file mode 100644 index 0000000..7ab4fb4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParser.java @@ -0,0 +1,36 @@ +package http_parser; + +import java.nio.ByteBuffer; + +public class HTTPParser extends http_parser.lolevel.HTTPParser { + + public HTTPParser() { super(); } + public HTTPParser(ParserType type) { super(type); } + + public int getMajor() { + return super.http_major; + } + + public int getMinor() { + return super.http_minor; + } + + public int getStatusCode() { + return super.status_code; + } + + public HTTPMethod getHTTPMethod() { + return super.method; + } + + public boolean getUpgrade() { + return super.upgrade; + } + + public boolean shouldKeepAlive() { + return super.http_should_keep_alive(); + } + public void execute(ParserSettings settings, ByteBuffer data) { + this.execute(settings.getLoLevelSettings(), data); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParserUrl.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParserUrl.java new file mode 100644 index 0000000..d371634 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParserUrl.java @@ -0,0 +1,76 @@ +package http_parser; + +import http_parser.lolevel.*; +import http_parser.lolevel.HTTPParser; + +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; +import java.util.Arrays; + +/** + */ +public class HTTPParserUrl { + + public int field_set; + public int port; + + public FieldData[] field_data = new FieldData[]{ + new FieldData(0,0), + new FieldData(0,0), + new FieldData(0,0), + new FieldData(0,0), + new FieldData(0,0), + new FieldData(0,0) + }; //UF_MAX + + public HTTPParserUrl(){} + + public HTTPParserUrl(int field_set, int port, FieldData[] field_data){ + this.field_set = field_set; + this.port = port; + this.field_data = field_data; + } + + public String getFieldValue(HTTPParser.UrlFields field, ByteBuffer data) throws UnsupportedEncodingException { + FieldData fd = this.field_data[field.getIndex()]; + if(fd.off == 0 & fd.len == 0) return ""; + byte[] dst = new byte[fd.len]; + int current_pos = data.position(); + data.position(fd.off); + data.get(dst,0,fd.len); + data.position(current_pos); + String v = new String(dst, "UTF8"); + return v; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + HTTPParserUrl that = (HTTPParserUrl) o; + + if (field_set != that.field_set) return false; + if (port != that.port) return false; + if (!Arrays.equals(field_data, that.field_data)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = field_set; + result = 31 * result + port; + result = 31 * result + Arrays.hashCode(field_data); + return result; + } + + @Override + public String toString() { + return "HTTPParserUrl{" + + "field_set=" + field_set + + ", port=" + port + + ", field_data=" + (field_data == null ? null : Arrays.asList(field_data)) + + '}'; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserSettings.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserSettings.java new file mode 100644 index 0000000..9a5e6e9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserSettings.java @@ -0,0 +1,256 @@ +package http_parser; + + + +import primitive.collection.ByteList; + +public class ParserSettings extends http_parser.lolevel.ParserSettings { + + public HTTPCallback on_message_begin; + public HTTPDataCallback on_path; + public HTTPDataCallback on_query_string; + public HTTPDataCallback on_url; + public HTTPDataCallback on_fragment; + public HTTPCallback on_status_complete; + public HTTPDataCallback on_header_field; + public HTTPDataCallback on_header_value; + + public HTTPCallback on_headers_complete; + public HTTPDataCallback on_body; + public HTTPCallback on_message_complete; + + public HTTPErrorCallback on_error; + + private HTTPCallback _on_message_begin; + private HTTPDataCallback _on_path; + private HTTPDataCallback _on_query_string; + private HTTPDataCallback _on_url; + private HTTPDataCallback _on_fragment; + private HTTPCallback _on_status_complete; + private HTTPDataCallback _on_header_field; + private HTTPDataCallback _on_header_value; + private HTTPCallback _on_headers_complete; + private HTTPDataCallback _on_body; + private HTTPCallback _on_message_complete; + private HTTPErrorCallback _on_error; + + private http_parser.lolevel.ParserSettings settings; + + protected ByteList field = new ByteList(); + protected ByteList value = new ByteList(); + protected ByteList body = new ByteList(); + + public ParserSettings() { + this.settings = new http_parser.lolevel.ParserSettings(); + createMirrorCallbacks(); + attachCallbacks(); + } + + protected http_parser.lolevel.ParserSettings getLoLevelSettings() { + return this.settings; + } + + private void createMirrorCallbacks() { + this._on_message_begin = new HTTPCallback() { + public int cb(HTTPParser p) { + if (null != ParserSettings.this.on_message_begin) { + return ParserSettings.this.on_message_begin.cb(p); + } + return 0; + } + }; + this._on_path = new HTTPDataCallback() { + @Override + public int cb(HTTPParser p, byte[] by, int pos, int len) { + if (null != ParserSettings.this.on_path) { + return ParserSettings.this.on_path.cb(p, by, pos, len); + } + return 0; + } + }; + this._on_query_string = new HTTPDataCallback() { + @Override + public int cb(HTTPParser p, byte[] by, int pos, int len) { + if (null != ParserSettings.this.on_query_string) { + return ParserSettings.this.on_query_string.cb(p, by, pos, len); + } + return 0; + } + }; + this._on_url = new HTTPDataCallback() { + @Override + public int cb(HTTPParser p, byte[] by, int pos, int len) { + if (null != ParserSettings.this.on_url) { + return ParserSettings.this.on_url.cb(p, by, pos, len); + } + return 0; + } + }; + this._on_fragment = new HTTPDataCallback() { + @Override + public int cb(HTTPParser p, byte[] by, int pos, int len) { + if (null != ParserSettings.this.on_fragment) { + return ParserSettings.this.on_fragment.cb(p, by, pos, len); + } + return 0; + } + }; + this._on_status_complete = new HTTPCallback() { + @Override + public int cb(HTTPParser p) { + if (null != ParserSettings.this.on_status_complete) { + return ParserSettings.this.on_status_complete.cb(p); + } + return 0; + } + }; + this._on_error = new HTTPErrorCallback() { + @Override + public void cb(HTTPParser parser, String error) { + if (null != ParserSettings.this.on_error) { + ParserSettings.this.on_error.cb(parser, error); + } else { + throw new HTTPException(error); + } + + } + }; + + + +// (on_header_field and on_header_value shortened to on_h_*) +// ------------------------ ------------ -------------------------------------------- +// | State (prev. callback) | Callback | Description/action | +// ------------------------ ------------ -------------------------------------------- +// | nothing (first call) | on_h_field | Allocate new buffer and copy callback data | +// | | | into it | +// ------------------------ ------------ -------------------------------------------- +// | value | on_h_field | New header started. | +// | | | Copy current name,value buffers to headers | +// | | | list and allocate new buffer for new name | +// ------------------------ ------------ -------------------------------------------- +// | field | on_h_field | Previous name continues. Reallocate name | +// | | | buffer and append callback data to it | +// ------------------------ ------------ -------------------------------------------- +// | field | on_h_value | Value for current header started. Allocate | +// | | | new buffer and copy callback data to it | +// ------------------------ ------------ -------------------------------------------- +// | value | on_h_value | Value continues. Reallocate value buffer | +// | | | and append callback data to it | +// ------------------------ ------------ -------------------------------------------- + this._on_header_field = new HTTPDataCallback() { + @Override + public int cb(HTTPParser p, byte[] by, int pos, int len) { + // previous value complete, call on_value with full value, reset value. + if (0 != ParserSettings.this.value.size()) { + // check we're even interested... + if (null != ParserSettings.this.on_header_value) { + byte [] valueArr = ParserSettings.this.value.toArray(); + int ret = ParserSettings.this.on_header_value.cb(p, valueArr, 0, valueArr.length); + if (0 != ret) { + return ret; + } + ParserSettings.this.value.clear(); + } + } + + if (null == ParserSettings.this.on_header_field) { + return 0; + } + + ParserSettings.this.field.addAll(by); + return 0; + } + }; + this._on_header_value = new HTTPDataCallback() { + @Override + public int cb(HTTPParser p, byte[] by, int pos, int len) { + + // previous field complete, call on_field with full field value, reset field. + if (0 != ParserSettings.this.field.size()) { + // check we're even interested... + if (null != ParserSettings.this.on_header_field) { + byte [] fieldArr = ParserSettings.this.field.toArray(); + int ret = ParserSettings.this.on_header_field.cb(p, fieldArr, 0, fieldArr.length); + if (0 != ret) { + return ret; + } + ParserSettings.this.field.clear(); + } + } + + if (null == ParserSettings.this.on_header_value) { + return 0; + } + ParserSettings.this.value.addAll(by); + return 0; + } + }; + this._on_headers_complete = new HTTPCallback() { + @Override + public int cb(HTTPParser parser) { + // is there an uncompleted value ... ? + if (0 != ParserSettings.this.value.size()) { + // check we're even interested... + if (null != ParserSettings.this.on_header_value) { + byte [] valueArr = ParserSettings.this.value.toArray(); + int ret = ParserSettings.this.on_header_value.cb(parser, valueArr, 0, valueArr.length); + if (0 != ret) { + return ret; + } + ParserSettings.this.value.clear(); + } + } + if (null != ParserSettings.this.on_headers_complete) { + return ParserSettings.this.on_headers_complete.cb(parser); + } + return 0; + } + + }; + this._on_body = new HTTPDataCallback() { + @Override + public int cb(HTTPParser p, byte[] by, int pos, int len) { + if (null != ParserSettings.this.on_body) { + ParserSettings.this.body.addAll(by, pos, len); + } + return 0; + } + }; + + this._on_message_complete = new HTTPCallback() { + @Override + public int cb(HTTPParser parser) { + if (null != ParserSettings.this.on_body) { + byte [] body = ParserSettings.this.body.toArray(); + int ret = ParserSettings.this.on_body.cb(parser, body, 0, body.length); + if (0!=ret) { + return ret; + } + ParserSettings.this.body.clear(); + } + if (null != ParserSettings.this.on_message_complete) { + return ParserSettings.this.on_message_complete.cb(parser); + } + return 0; + } + }; + + } + + private void attachCallbacks() { + // these are certainly set, because we mirror them ... + this.settings.on_message_begin = this._on_message_begin; + this.settings.on_path = this._on_path; + this.settings.on_query_string = this._on_query_string; + this.settings.on_url = this._on_url; + this.settings.on_fragment = this._on_fragment; + this.settings.on_status_complete = this._on_status_complete; + this.settings.on_header_field = this._on_header_field; + this.settings.on_header_value = this._on_header_value; + this.settings.on_headers_complete = this._on_headers_complete; + this.settings.on_body = this._on_body; + this.settings.on_message_complete = this._on_message_complete; + this.settings.on_error = this._on_error; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserType.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserType.java new file mode 100644 index 0000000..a51f5b4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserType.java @@ -0,0 +1,13 @@ +package http_parser; + +public enum ParserType { +HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH; + + public static ParserType parse(String s) { + if ("HTTP_REQUEST".equalsIgnoreCase(s)) { return HTTP_REQUEST; } + else if ("HTTP_RESPONSE".equalsIgnoreCase(s)) { return HTTP_RESPONSE; } + else if ("HTTP_BOTH".equalsIgnoreCase(s)) { return HTTP_BOTH; } + else { return null; } + } +} + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/Util.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/Util.java new file mode 100644 index 0000000..575003a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/Util.java @@ -0,0 +1,111 @@ +package http_parser; + +import java.nio.ByteBuffer; + +public class Util { +// public static String toString(http_parser.lolevel.HTTPParser p) { +// StringBuilder builder = new StringBuilder(); +// +// // the stuff up to the break is ephermeral and only meaningful +// // while the parser is parsing. In general, this method is +// // probably only useful during debugging. +// +// builder.append("state :"); builder.append(p.state); builder.append("\n"); +// builder.append("header_state :"); builder.append(p.header_state); builder.append("\n"); +// builder.append("strict :"); builder.append(p.strict); builder.append("\n"); +// builder.append("index :"); builder.append(p.index); builder.append("\n"); +// builder.append("flags :"); builder.append(p.flags); builder.append("\n"); +// builder.append("nread :"); builder.append(p.nread); builder.append("\n"); +// builder.append("content_length :"); builder.append(p.content_length); builder.append("\n"); +// +// +// builder.append("type :"); builder.append(p.type); builder.append("\n"); +// builder.append("http_major :"); builder.append(p.http_major); builder.append("\n"); +// builder.append("http_minor :"); builder.append(p.http_minor); builder.append("\n"); +// builder.append("status_code :"); builder.append(p.status_code); builder.append("\n"); +// builder.append("method :"); builder.append(p.method); builder.append("\n"); +// builder.append("upgrade :"); builder.append(p.upgrade); builder.append("\n"); +// +// return builder.toString(); +// +// } + + public static String error (String mes, ByteBuffer b, int beginning) { + // the error message should look like this: + // + // Bla expected something, but it's not there (mes) + // GEt / HTTP 1_1 + // ............^. + // + // |----------------- 72 -------------------------| + + // This is ridiculously complicated and probably riddled with + // off-by-one errors, should be moved into high level interface. + // TODO. + + // also: need to keep track of the initial buffer position in + // execute so that we don't screw up any `mark()` that may have + // been set outside of our control to be nice. + + final int mes_width = 72; + int p = b.position(); // error position + int end = b.limit(); // this is the end + int m = end - beginning; // max mes length + + StringBuilder builder = new StringBuilder(); + int p_adj = p; + + byte [] orig = new byte[0]; + if (m <= mes_width) { + orig = new byte[m]; + b.position(beginning); + b.get(orig, 0, m); + p_adj = p-beginning; + + + } else { + // we'll need to trim bit off the beginning and/or end + orig = new byte[mes_width]; + // three possibilities: + // a.) plenty of stuff around p + // b.) plenty of stuff in front of p + // c.) plenty of stuff behind p + // CAN'T be not enough stuff aorund p in total, because + // m>meswidth (see if to this else) + + int before = p-beginning; + int after = end - p; + if ( (before > mes_width/2) && (after > mes_width/2)) { + // plenty of stuff in front of and behind error + p_adj = mes_width/2; + b.position(p - mes_width/2); + b.get(orig, 0, mes_width); + } else if (before <= mes_width/2) { + // take all of the begining. + b.position(beginning); + // and as much of the rest as possible + + b.get(orig, 0, mes_width); + + } else { + // plenty of stuff before + before = end-mes_width; + b.position(before); + p_adj = p - before; + b.get(orig, 0, mes_width); + } + } + + builder.append(new String(orig)); + builder.append("\n"); + for (int i = 0; i!= p_adj; ++i) { + builder.append("."); + } + builder.append("^"); + + + b.position(p); // restore position + return builder.toString(); + + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPCallback.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPCallback.java new file mode 100644 index 0000000..95c29b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPCallback.java @@ -0,0 +1,5 @@ +package http_parser.lolevel; + +public interface HTTPCallback { + public int cb (HTTPParser parser); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPDataCallback.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPDataCallback.java new file mode 100644 index 0000000..6cad156 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPDataCallback.java @@ -0,0 +1,25 @@ +package http_parser.lolevel; + +import java.nio.ByteBuffer; + +public interface HTTPDataCallback { + /* + very raw and extremly foolhardy! DANGER! + The whole Buffer concept is difficult enough to grasp as it is, + we pass in a buffer with an arbitrary position. + + The interesting data is located at position pos and is len + bytes long. + + The contract of this callback is that the buffer is + returned in the state that it was passed in, so implementing + this require good citizenship, you'll need to remember the current + position, change the position to get at the data you're interested + in and then set the position back to how you found it... + + //TODO: there should be an abstract implementation that implements + cb as described above, marks it final an provides a new callback + with signature cb(byte[], int, int) + */ + public int cb(HTTPParser p, ByteBuffer buf, int pos, int len); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPErrorCallback.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPErrorCallback.java new file mode 100644 index 0000000..d38d9d4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPErrorCallback.java @@ -0,0 +1,7 @@ +package http_parser.lolevel; + +import java.nio.ByteBuffer; + +public interface HTTPErrorCallback { + public void cb (HTTPParser parser, String mes, ByteBuffer buf, int initial_position); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPParser.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPParser.java new file mode 100644 index 0000000..42022ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPParser.java @@ -0,0 +1,2161 @@ +package http_parser.lolevel; + +import java.nio.ByteBuffer; +import http_parser.HTTPException; +import http_parser.HTTPMethod; +import http_parser.HTTPParserUrl; +import http_parser.ParserType; +import static http_parser.lolevel.HTTPParser.C.*; +import static http_parser.lolevel.HTTPParser.State.*; + +public class HTTPParser { + /* lots of unsigned chars here, not sure what + to about them, `bytes` in java suck... */ + + ParserType type; + State state; + HState header_state; + boolean strict; + + int index; + int flags; // TODO + + int nread; + long content_length; + + int p_start; // updated each call to execute to indicate where the buffer was before we began calling it. + + /** READ-ONLY **/ + public int http_major; + public int http_minor; + public int status_code; /* responses only */ + public HTTPMethod method; /* requests only */ + + /* true = Upgrade header was present and the parser has exited because of that. + * false = No upgrade header present. + * Should be checked when http_parser_execute() returns in addition to + * error checking. + */ + public boolean upgrade; + + /** PUBLIC **/ + // TODO : this is used in c to maintain application state. + // is this even necessary? we have state in java ? + // consider + // Object data; /* A pointer to get hook to the "connection" or "socket" object */ + + + /* + * technically we could combine all of these (except for url_mark) into one + * variable, saving stack space, but it seems more clear to have them + * separated. + */ + int header_field_mark = -1; + int header_value_mark = -1; + int url_mark = -1; + int body_mark = -1; + + /** + * Construct a Parser for ParserType.HTTP_BOTH, meaning it + * determines whether it's parsing a request or a response. + */ + public HTTPParser() { + this(ParserType.HTTP_BOTH); + } + + /** + * Construct a Parser and initialise it to parse either + * requests or responses. + */ + public HTTPParser(ParserType type) { + this.type = type; + switch(type) { + case HTTP_REQUEST: + this.state = State.start_req; + break; + case HTTP_RESPONSE: + this.state = State.start_res; + break; + case HTTP_BOTH: + this.state = State.start_req_or_res; + break; + default: + throw new HTTPException("can't happen, invalid ParserType enum"); + } + } + + /* + * Utility to facilitate System.out.println style debugging (the way god intended) + */ + static void p(Object o) {System.out.println(o);} + + /** Comment from C version follows + * + * Our URL parser. + * + * This is designed to be shared by http_parser_execute() for URL validation, + * hence it has a state transition + byte-for-byte interface. In addition, it + * is meant to be embedded in http_parser_parse_url(), which does the dirty + * work of turning state transitions URL components for its API. + * + * This function should only be invoked with non-space characters. It is + * assumed that the caller cares about (and can detect) the transition between + * URL and non-URL states by looking for these. + */ + public State parse_url_char(byte ch) { + + int chi = ch & 0xff; // utility, ch without signedness for table lookups. + + if(SPACE == ch){ + throw new HTTPException("space as url char"); + } + + switch(state) { + case req_spaces_before_url: + /* Proxied requests are followed by scheme of an absolute URI (alpha). + * All methods except CONNECT are followed by '/' or '*'. + */ + if(SLASH == ch || STAR == ch){ + return req_path; + } + if(isAtoZ(ch)){ + return req_schema; + } + break; + case req_schema: + if(isAtoZ(ch)){ + return req_schema; + } + if(COLON == ch){ + return req_schema_slash; + } + break; + case req_schema_slash: + if(SLASH == ch){ + return req_schema_slash_slash; + } + break; + case req_schema_slash_slash: + if(SLASH == ch){ + return req_host_start; + } + break; + case req_host_start: + if (ch == (byte)'[') { + return req_host_v6_start; + } + if (isHostChar(ch)) { + return req_host; + } + break; + + case req_host: + if (isHostChar(ch)) { + return req_host; + } + + /* FALLTHROUGH */ + case req_host_v6_end: + switch (ch) { + case ':': + return req_port_start; + case '/': + return req_path; + case '?': + return req_query_string_start; + } + break; + + case req_host_v6: + if (ch == ']') { + return req_host_v6_end; + } + + /* FALLTHROUGH */ + case req_host_v6_start: + if (isHex(ch) || ch == ':') { + return req_host_v6; + } + break; + + case req_port: + switch (ch) { + case '/': + return req_path; + case '?': + return req_query_string_start; + } + + /* FALLTHROUGH */ + case req_port_start: + if (isDigit(ch)) { + return req_port; + } + break; + + case req_path: + if (isNormalUrlChar(chi)) { + return req_path; + } + switch (ch) { + case '?': + return req_query_string_start; + case '#': + return req_fragment_start; + } + + break; + + case req_query_string_start: + case req_query_string: + if (isNormalUrlChar(chi)) { + return req_query_string; + } + + switch (ch) { + case '?': + /* allow extra '?' in query string */ + return req_query_string; + + case '#': + return req_fragment_start; + } + + break; + + case req_fragment_start: + if (isNormalUrlChar(chi)) { + return req_fragment; + } + switch (ch) { + case '?': + return req_fragment; + + case '#': + return req_fragment_start; + } + break; + + case req_fragment: + if (isNormalUrlChar(ch)) { + return req_fragment; + } + + switch (ch) { + case '?': + case '#': + return req_fragment; + } + + break; + default: + break; + } + + /* We should never fall out of the switch above unless there's an error */ + return dead; + } + + /** Execute the parser with the currently available data contained in + * the buffer. The buffers position() and limit() need to be set + * correctly (obviously) and a will be updated approriately when the + * method returns to reflect the consumed data. + */ + public int execute(ParserSettings settings, ByteBuffer data) { + + int p = data.position(); + this.p_start = p; // this is used for pretty printing errors. + // and returning the amount of processed bytes. + + + // In case the headers don't provide information about the content + // length, `execute` needs to be called with an empty buffer to + // indicate that all the data has been send be the client/server, + // else there is no way of knowing the message is complete. + int len = (data.limit() - data.position()); + if (0 == len) { +// if (State.body_identity_eof == state) { +// settings.call_on_message_complete(this); +// } + switch (state) { + case body_identity_eof: + settings.call_on_message_complete(this); + return data.position() - this.p_start; + + case dead: + case start_req_or_res: + case start_res: + case start_req: + return data.position() - this.p_start; + + default: + // should we really consider this an error!? + throw new HTTPException("empty bytes! "+state); // error + } + } + + + // in case the _previous_ call to the parser only has data to get to + // the middle of certain fields, we need to update marks to point at + // the beginning of the current buffer. + switch (state) { + case header_field: + header_field_mark = p; + break; + case header_value: + header_value_mark = p; + break; + case req_path: + case req_schema: + case req_schema_slash: + case req_schema_slash_slash: + case req_host_start: + case req_host_v6_start: + case req_host_v6: + case req_host_v6_end: + case req_host: + case req_port_start: + case req_port: + case req_query_string_start: + case req_query_string: + case req_fragment_start: + case req_fragment: + url_mark = p; + break; + } + boolean reexecute = false; + int pe = 0; + byte ch = 0; + int chi = 0; + byte c = -1; + int to_read = 0; + + // this is where the work gets done, traverse the available data... + while (data.position() != data.limit() || reexecute) { +// p(state + ": r: " + reexecute + " :: " +p ); + + if(!reexecute){ + p = data.position(); + pe = data.limit(); + ch = data.get(); // the current character to process. + chi = ch & 0xff; // utility, ch without signedness for table lookups. + c = -1; // utility variably used for up- and downcasing etc. + to_read = 0; // used to keep track of how much of body, etc. is left to read + + if (parsing_header(state)) { + ++nread; + if (nread > HTTP_MAX_HEADER_SIZE) { + return error(settings, "possible buffer overflow", data); + } + } + } + reexecute = false; +// p(state + " ::: " + ch + " : " + (((CR == ch) || (LF == ch)) ? ch : ("'" + (char)ch + "'")) +": "+p ); + + switch (state) { + /* + * this state is used after a 'Connection: close' message + * the parser will error out if it reads another message + */ + case dead: + if (CR == ch || LF == ch){ + break; + } + return error(settings, "Connection already closed", data); + + + + case start_req_or_res: + if (CR == ch || LF == ch){ + break; + } + flags = 0; + content_length = -1; + + if (H == ch) { + state = State.res_or_resp_H; + } else { + type = ParserType.HTTP_REQUEST; + method = start_req_method_assign(ch); + if (null == method) { + return error(settings, "invalid method", data); + } + index = 1; + state = State.req_method; + } + settings.call_on_message_begin(this); + break; + + + + case res_or_resp_H: + if (T == ch) { + type = ParserType.HTTP_RESPONSE; + state = State.res_HT; + } else { + if (E != ch) { + return error(settings, "not E", data); + } + type = ParserType.HTTP_REQUEST; + method = HTTPMethod.HTTP_HEAD; + index = 2; + state = State.req_method; + } + break; + + + + case start_res: + flags = 0; + content_length = -1; + + switch(ch) { + case H: + state = State.res_H; + break; + case CR: + case LF: + break; + default: + return error(settings, "Not H or CR/LF", data); + } + + settings.call_on_message_begin(this); + break; + + + + case res_H: + if (strict && T != ch) { + return error(settings, "Not T", data); + } + state = State.res_HT; + break; + case res_HT: + if (strict && T != ch) { +return error(settings, "Not T2", data); + } + state = State.res_HTT; + break; + case res_HTT: + if (strict && P != ch) { +return error(settings, "Not P", data); + } + state = State.res_HTTP; + break; + case res_HTTP: + if (strict && SLASH != ch) { +return error(settings, "Not '/'", data); + } + state = State.res_first_http_major; + break; + + + + case res_first_http_major: + if (!isDigit(ch)) { +return error(settings, "Not a digit", data); + } + http_major = (int) ch - 0x30; + state = State.res_http_major; + break; + + /* major HTTP version or dot */ + case res_http_major: + if (DOT == ch) { + state = State.res_first_http_minor; + break; + } + if (!isDigit(ch)) { +return error(settings, "Not a digit", data); + } + http_major *= 10; + http_major += (ch - 0x30); + + if (http_major > 999) { +return error(settings, "invalid http major version: ", data); + } + break; + + /* first digit of minor HTTP version */ + case res_first_http_minor: + if (!isDigit(ch)) { +return error(settings, "Not a digit", data); + } + http_minor = (int)ch - 0x30; + state = State.res_http_minor; + break; + + /* minor HTTP version or end of request line */ + case res_http_minor: + if (SPACE == ch) { + state = State.res_first_status_code; + break; + } + if (!isDigit(ch)) { +return error(settings, "Not a digit", data); + } + http_minor *= 10; + http_minor += (ch - 0x30); + if (http_minor > 999) { +return error(settings, "invalid http minor version: ", data); + } + break; + + + + case res_first_status_code: + if (!isDigit(ch)) { + if (SPACE == ch) { + break; + } +return error(settings, "Not a digit (status code)", data); + } + status_code = (int)ch - 0x30; + state = State.res_status_code; + break; + + case res_status_code: + if (!isDigit(ch)) { + switch(ch) { + case SPACE: + state = State.res_status; + break; + case CR: + state = State.res_line_almost_done; + break; + case LF: + state = State.header_field_start; + break; + default: +return error(settings, "not a valid status code", data); + } + break; + } + status_code *= 10; + status_code += (int)ch - 0x30; + if (status_code > 999) { +return error(settings, "ridiculous status code:", data); + } + + if (status_code > 99) { + settings.call_on_status_complete(this); + } + break; + + case res_status: + /* the human readable status. e.g. "NOT FOUND" + * we are not humans so just ignore this + * we are not men, we are devo. */ + + if (CR == ch) { + state = State.res_line_almost_done; + break; + } + if (LF == ch) { + state = State.header_field_start; + break; + } + break; + + case res_line_almost_done: + if (strict && LF != ch) { +return error(settings, "not LF", data); + } + state = State.header_field_start; + break; + + + + case start_req: + if (CR==ch || LF == ch) { + break; + } + flags = 0; + content_length = -1; + + if(!isAtoZ(ch)){ + return error(settings, "invalid method", data); + } + + method = start_req_method_assign(ch); + if (null == method) { + return error(settings, "invalid method", data); + } + index = 1; + state = State.req_method; + + settings.call_on_message_begin(this); + break; + + + + case req_method: + if (0 == ch) { + return error(settings, "NULL in method", data); + } + + byte [] arr = method.bytes; + + if (SPACE == ch && index == arr.length) { + state = State.req_spaces_before_url; + } else if (arr[index] == ch) { + // wuhu! + } else if (HTTPMethod.HTTP_CONNECT == method) { + if (1 == index && H == ch) { + method = HTTPMethod.HTTP_CHECKOUT; + } else if (2 == index && P == ch) { + method = HTTPMethod.HTTP_COPY; + } + } else if (HTTPMethod.HTTP_MKCOL == method) { + if (1 == index && O == ch) { + method = HTTPMethod.HTTP_MOVE; + } else if (1 == index && E == ch) { + method = HTTPMethod.HTTP_MERGE; + } else if (1 == index && DASH == ch) { /* M-SEARCH */ + method = HTTPMethod.HTTP_MSEARCH; + } else if (2 == index && A == ch) { + method = HTTPMethod.HTTP_MKACTIVITY; + } + } else if (1 == index && HTTPMethod.HTTP_POST == method) { + if(R == ch) { + method = HTTPMethod.HTTP_PROPFIND; /* or HTTP_PROPPATCH */ + }else if(U == ch){ + method = HTTPMethod.HTTP_PUT; /* or HTTP_PURGE */ + }else if(A == ch){ + method = HTTPMethod.HTTP_PATCH; + } + } else if (2 == index) { + if(HTTPMethod.HTTP_PUT == method) { + if(R == ch){ + method = HTTPMethod.HTTP_PURGE; + } + }else if(HTTPMethod.HTTP_UNLOCK == method){ + if(S == ch){ + method = HTTPMethod.HTTP_UNSUBSCRIBE; + } + } + }else if(4 == index && HTTPMethod.HTTP_PROPFIND == method && P == ch){ + method = HTTPMethod.HTTP_PROPPATCH; + } else { + return error(settings, "Invalid HTTP method", data); + } + + ++index; + break; + + + + /******************* URL *******************/ + case req_spaces_before_url: + if (SPACE == ch) { + break; + } + url_mark = p; + if(HTTPMethod.HTTP_CONNECT == method){ + state = req_host_start; + } + + state = parse_url_char(ch); + if(state == dead){ + return error(settings, "Invalid something", data); + } + break; + + + case req_schema: + case req_schema_slash: + case req_schema_slash_slash: + case req_host_start: + case req_host_v6_start: + case req_host_v6: + case req_port_start: + switch (ch) { + /* No whitespace allowed here */ + case SPACE: + case CR: + case LF: + return error(settings, "unexpected char in path", data); + default: + state = parse_url_char(ch); + if(dead == state){ + return error(settings, "unexpected char in path", data); + } + } + break; + + case req_host: + case req_host_v6_end: + case req_port: + case req_path: + case req_query_string_start: + case req_query_string: + case req_fragment_start: + case req_fragment: + switch (ch) { + case SPACE: + settings.call_on_url(this, data, url_mark, p-url_mark); + settings.call_on_path(this, data, url_mark, p - url_mark); + url_mark = -1; + state = State.req_http_start; + break; + case CR: + case LF: + http_major = 0; + http_minor = 9; + state = (CR == ch) ? req_line_almost_done : header_field_start; + settings.call_on_url(this, data, url_mark, p-url_mark); //TODO check params!!! + settings.call_on_path(this, data, url_mark, p-url_mark); + url_mark = -1; + break; + default: + state = parse_url_char(ch); + if(dead == state){ + return error(settings, "unexpected char in path", data); + } + } + break; + /******************* URL *******************/ + + + + /******************* HTTP 1.1 *******************/ + case req_http_start: + switch (ch) { + case H: + state = State.req_http_H; + break; + case SPACE: + break; + default: + return error(settings, "error in req_http_H", data); + } + break; + + case req_http_H: + if (strict && T != ch) { + return error(settings, "unexpected char", data); + } + state = State.req_http_HT; + break; + + case req_http_HT: + if (strict && T != ch) { + return error(settings, "unexpected char", data); + } + state = State.req_http_HTT; + break; + + case req_http_HTT: + if (strict && P != ch) { + return error(settings, "unexpected char", data); + } + state = State.req_http_HTTP; + break; + + case req_http_HTTP: + if (strict && SLASH != ch) { + return error(settings, "unexpected char", data); + } + state = req_first_http_major; + break; + + /* first digit of major HTTP version */ + case req_first_http_major: + if (!isDigit(ch)) { +return error(settings, "non digit in http major", data); + } + http_major = (int)ch - 0x30; + state = State.req_http_major; + break; + + /* major HTTP version or dot */ + case req_http_major: + if (DOT == ch) { + state = State.req_first_http_minor; + break; + } + + if (!isDigit(ch)) { +return error(settings, "non digit in http major", data); + } + + http_major *= 10; + http_major += (int)ch - 0x30; + + if (http_major > 999) { +return error(settings, "ridiculous http major", data); + }; + break; + + /* first digit of minor HTTP version */ + case req_first_http_minor: + if (!isDigit(ch)) { +return error(settings, "non digit in http minor", data); + } + http_minor = (int)ch - 0x30; + state = State.req_http_minor; + break; + + case req_http_minor: + if (ch == CR) { + state = State.req_line_almost_done; + break; + } + + if (ch == LF) { + state = State.header_field_start; + break; + } + + /* XXX allow spaces after digit? */ + + if (!isDigit(ch)) { +return error(settings, "non digit in http minor", data); + } + + http_minor *= 10; + http_minor += (int)ch - 0x30; + + + if (http_minor > 999) { +return error(settings, "ridiculous http minor", data); + }; + + break; + + /* end of request line */ + case req_line_almost_done: + { + if (ch != LF) { +return error(settings, "missing LF after request line", data); + } + state = header_field_start; + break; + } + + /******************* HTTP 1.1 *******************/ + + + + /******************* Header *******************/ + case header_field_start: + { + if (ch == CR) { + state = headers_almost_done; + break; + } + + if (ch == LF) { + /* they might be just sending \n instead of \r\n so this would be + * the second \n to denote the end of headers*/ + state = State.headers_almost_done; + reexecute = true; + break; + } + + c = token(ch); + + if (0 == c) { + return error(settings, "invalid char in header:", data); + } + + header_field_mark = p; + + index = 0; + state = State.header_field; + + switch (c) { + case C: + header_state = HState.C; + break; + + case P: + header_state = HState.matching_proxy_connection; + break; + + case T: + header_state = HState.matching_transfer_encoding; + break; + + case U: + header_state = HState.matching_upgrade; + break; + + default: + header_state = HState.general; + break; + } + break; + } + + + + case header_field: + { + c = token(ch); + if (0 != c) { + switch (header_state) { + case general: + break; + + case C: + index++; + header_state = (O == c ? HState.CO : HState.general); + break; + + case CO: + index++; + header_state = (N == c ? HState.CON : HState.general); + break; + + case CON: + index++; + switch (c) { + case N: + header_state = HState.matching_connection; + break; + case T: + header_state = HState.matching_content_length; + break; + default: + header_state = HState.general; + break; + } + break; + + /* connection */ + + case matching_connection: + index++; + if (index > CONNECTION.length || c != CONNECTION[index]) { + header_state = HState.general; + } else if (index == CONNECTION.length-1) { + header_state = HState.connection; + } + break; + + /* proxy-connection */ + + case matching_proxy_connection: + index++; + if (index > PROXY_CONNECTION.length || c != PROXY_CONNECTION[index]) { + header_state = HState.general; + } else if (index == PROXY_CONNECTION.length-1) { + header_state = HState.connection; + } + break; + + /* content-length */ + + case matching_content_length: + index++; + if (index > CONTENT_LENGTH.length || c != CONTENT_LENGTH[index]) { + header_state = HState.general; + } else if (index == CONTENT_LENGTH.length-1) { + header_state = HState.content_length; + } + break; + + /* transfer-encoding */ + + case matching_transfer_encoding: + index++; + if (index > TRANSFER_ENCODING.length || c != TRANSFER_ENCODING[index]) { + header_state = HState.general; + } else if (index == TRANSFER_ENCODING.length-1) { + header_state = HState.transfer_encoding; + } + break; + + /* upgrade */ + + case matching_upgrade: + index++; + if (index > UPGRADE.length || c != UPGRADE[index]) { + header_state = HState.general; + } else if (index == UPGRADE.length-1) { + header_state = HState.upgrade; + } + break; + + case connection: + case content_length: + case transfer_encoding: + case upgrade: + if (SPACE != ch) header_state = HState.general; + break; + + default: +return error(settings, "Unknown Header State", data); + } // switch: header_state + break; + } // 0 != c + + if (COLON == ch) { + settings.call_on_header_field(this, data, header_field_mark, p-header_field_mark); + header_field_mark = -1; + + state = State.header_value_start; + break; + } + + if (CR == ch) { + state = State.header_almost_done; + settings.call_on_header_field(this, data, header_field_mark, p-header_field_mark); + + header_field_mark = -1; + break; + } + + if (ch == LF) { + settings.call_on_header_field(this, data, header_field_mark, p-header_field_mark); + header_field_mark = -1; + + state = State.header_field_start; + break; + } + +return error(settings, "invalid header field", data); + } + + + + case header_value_start: + { + if ((SPACE == ch) || (TAB == ch)) break; + + header_value_mark = p; + + state = State.header_value; + index = 0; + + + if (CR == ch) { + settings.call_on_header_value(this, data, header_value_mark, p-header_value_mark); + header_value_mark = -1; + + header_state = HState.general; + state = State.header_almost_done; + break; + } + + if (LF == ch) { + settings.call_on_header_value(this, data, header_value_mark, p-header_value_mark); + header_value_mark = -1; + + state = State.header_field_start; + break; + } + + + c = upper(ch); + + switch (header_state) { + case upgrade: + flags |= F_UPGRADE; + header_state = HState.general; + break; + + case transfer_encoding: + /* looking for 'Transfer-Encoding: chunked' */ + if (C == c) { + header_state = HState.matching_transfer_encoding_chunked; + } else { + header_state = HState.general; + } + break; + + case content_length: + if (!isDigit(ch)) { +return error(settings, "Content-Length not numeric", data); + } + content_length = (int)ch - 0x30; + break; + + case connection: + /* looking for 'Connection: keep-alive' */ + if (K == c) { + header_state = HState.matching_connection_keep_alive; + /* looking for 'Connection: close' */ + } else if (C == c) { + header_state = HState.matching_connection_close; + } else { + header_state = HState.general; + } + break; + + default: + header_state = HState.general; + break; + } + break; + } // header value start + + + + case header_value: + { + + if (CR == ch) { + settings.call_on_header_value(this, data, header_value_mark, p-header_value_mark); + header_value_mark = -1; + + state = State.header_almost_done; + break; + } + + if (LF == ch) { + settings.call_on_header_value(this, data, header_value_mark, p-header_value_mark); + header_value_mark = -1; + state = header_almost_done; + reexecute = true; + break; + } + + c = upper(ch); + switch (header_state) { + case general: + break; + + case connection: + case transfer_encoding: +return error(settings, "Shouldn't be here", data); + + case content_length: + if (SPACE == ch) { + break; + } + if (!isDigit(ch)) { +return error(settings, "Content-Length not numeric", data); + } + + long t = content_length; + t *= 10; + t += (long)ch - 0x30; + + /* Overflow? */ + // t will wrap and become negative ... + if (t < content_length) { + return error(settings, "Invalid content length", data); + } + content_length = t; + break; + + /* Transfer-Encoding: chunked */ + case matching_transfer_encoding_chunked: + index++; + if (index > CHUNKED.length || c != CHUNKED[index]) { + header_state = HState.general; + } else if (index == CHUNKED.length-1) { + header_state = HState.transfer_encoding_chunked; + } + break; + + /* looking for 'Connection: keep-alive' */ + case matching_connection_keep_alive: + index++; + if (index > KEEP_ALIVE.length || c != KEEP_ALIVE[index]) { + header_state = HState.general; + } else if (index == KEEP_ALIVE.length-1) { + header_state = HState.connection_keep_alive; + } + break; + + /* looking for 'Connection: close' */ + case matching_connection_close: + index++; + if (index > CLOSE.length || c != CLOSE[index]) { + header_state = HState.general; + } else if (index == CLOSE.length-1) { + header_state = HState.connection_close; + } + break; + + case transfer_encoding_chunked: + case connection_keep_alive: + case connection_close: + if (SPACE != ch) header_state = HState.general; + break; + + default: + state = State.header_value; + header_state = HState.general; + break; + } + break; + } // header_value + + + + case header_almost_done: + if (!header_almost_done(ch)) { + return error(settings, "incorrect header ending, expecting LF", data); + } + break; + + case header_value_lws: + if (SPACE == ch || TAB == ch ){ + state = header_value_start; + } else { + state = header_field_start; + reexecute = true; + } + break; + + case headers_almost_done: + if (LF != ch) { + return error(settings, "header not properly completed", data); + } + if (0 != (flags & F_TRAILING)) { + /* End of a chunked request */ + state = new_message(); + settings.call_on_headers_complete(this); + settings.call_on_message_complete(this); + break; + } + + state = headers_done; + + if (0 != (flags & F_UPGRADE) || HTTPMethod.HTTP_CONNECT == method) { + upgrade = true; + } + + /* Here we call the headers_complete callback. This is somewhat + * different than other callbacks because if the user returns 1, we + * will interpret that as saying that this message has no body. This + * is needed for the annoying case of recieving a response to a HEAD + * request. + */ + + /* (responses to HEAD request contain a CONTENT-LENGTH header + * but no content) + * + * Consider what to do here: I don't like the idea of the callback + * interface having a different contract in the case of HEAD + * responses. The alternatives would be either to: + * + * a.) require the header_complete callback to implement a different + * interface or + * + * b.) provide an overridden execute(bla, bla, boolean + * parsingHeader) implementation ... + */ + + /*TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO */ + if (null != settings.on_headers_complete) { + settings.call_on_headers_complete(this); + //return; + } + + // if (null != settings.on_headers_complete) { + // switch (settings.on_headers_complete.cb(parser)) { + // case 0: + // break; + // + // case 1: + // flags |= F_SKIPBODY; + // break; + // + // default: + // return p - data; /* Error */ // TODO // RuntimeException ? + // } + // } + reexecute = true; + break; + + case headers_done: + if (strict && (LF != ch)) { + return error(settings, "STRICT CHECK", data); //TODO correct error msg + } + + nread = 0; + + // Exit, the rest of the connect is in a different protocol. + if (upgrade) { + state = new_message(); + settings.call_on_message_complete(this); + return data.position()-this.p_start; + } + + if (0 != (flags & F_SKIPBODY)) { + state = new_message(); + settings.call_on_message_complete(this); + } else if (0 != (flags & F_CHUNKED)) { + /* chunked encoding - ignore Content-Length header */ + state = State.chunk_size_start; + } else { + if (content_length == 0) { + /* Content-Length header given but zero: Content-Length: 0\r\n */ + state = new_message(); + settings.call_on_message_complete(this); + } else if (content_length != -1) { + /* Content-Length header given and non-zero */ + state = State.body_identity; + } else { + if (type == ParserType.HTTP_REQUEST || !http_message_needs_eof()) { + /* Assume content-length 0 - read the next */ + state = new_message(); + settings.call_on_message_complete(this); + } else { + /* Read body until EOF */ + state = State.body_identity_eof; + } + } + } + + break; + /******************* Header *******************/ + + + + + /******************* Body *******************/ + case body_identity: + to_read = min(pe - p, content_length); //TODO change to use buffer? + body_mark = p; + + if (to_read > 0) { + settings.call_on_body(this, data, p, to_read); + data.position(p+to_read); + content_length -= to_read; + + if (content_length == 0) { + state = message_done; + reexecute = true; + } + } + break; + + + + case body_identity_eof: + to_read = pe - p; // TODO change to use buffer ? + if (to_read > 0) { + settings.call_on_body(this, data, p, to_read); + data.position(p+to_read); + } + break; + + case message_done: + state = new_message(); + settings.call_on_message_complete(this); + break; + /******************* Body *******************/ + + + + /******************* Chunk *******************/ + case chunk_size_start: + if (1 != this.nread) { +return error(settings, "nread != 1 (chunking)", data); + + } + if (0 == (flags & F_CHUNKED)) { +return error(settings, "not chunked", data); + } + + c = UNHEX[chi]; + if (c == -1) { +return error(settings, "invalid hex char in chunk content length", data); + } + content_length = c; + state = State.chunk_size; + break; + + + + case chunk_size: + if (0 == (flags & F_CHUNKED)) { + return error(settings, "not chunked", data); + } + + if (CR == ch) { + state = State.chunk_size_almost_done; + break; + } + + c = UNHEX[chi]; + + if (c == -1) { + if (SEMI == ch || SPACE == ch) { + state = State.chunk_parameters; + break; + } + return error(settings, "invalid hex char in chunk content length", data); + } + long t = content_length; + + t *= 16; + t += c; + if(t < content_length){ + return error(settings, "invalid content length", data); + } + content_length = t; + break; + + + + case chunk_parameters: + if (0 == (flags & F_CHUNKED)) { +return error(settings, "not chunked", data); + } + /* just ignore this shit. TODO check for overflow */ + if (CR == ch) { + state = State.chunk_size_almost_done; + break; + } + break; + + + + case chunk_size_almost_done: + if (0 == (flags & F_CHUNKED)) { +return error(settings, "not chunked", data); + } + if (strict && LF != ch) { +return error(settings, "expected LF at end of chunk size", data); + } + + this.nread = 0; + + if (0 == content_length) { + flags |= F_TRAILING; + state = State.header_field_start; + } else { + state = State.chunk_data; + } + break; + + + + case chunk_data: + //TODO Apply changes from C version for s_chunk_data + if (0 == (flags & F_CHUNKED)) { + return error(settings, "not chunked", data); + } + + to_read = min(pe-p, content_length); + if (to_read > 0) { + settings.call_on_body(this, data, p, to_read); + data.position(p+to_read); + } + + if (to_read == content_length) { + state = State.chunk_data_almost_done; + } + + content_length -= to_read; + break; + + + + case chunk_data_almost_done: + if (0 == (flags & F_CHUNKED)) { +return error(settings, "not chunked", data); + } + if (strict && CR != ch) { +return error(settings, "chunk data terminated incorrectly, expected CR", data); + } + state = State.chunk_data_done; + //TODO CALLBACK_DATA(body) + // settings.call_on_body(this, data,p,?); + break; + + + + case chunk_data_done: + if (0 == (flags & F_CHUNKED)) { +return error(settings, "not chunked", data); + } + if (strict && LF != ch) { +return error(settings, "chunk data terminated incorrectly, expected LF", data); + } + state = State.chunk_size_start; + break; + /******************* Chunk *******************/ + + + + default: +return error(settings, "unhandled state", data); + + } // switch + } // while + + p = data.position(); + + + /* Reaching this point assumes that we only received part of a + * message, inform the callbacks about the progress made so far*/ + + settings.call_on_header_field(this, data, header_field_mark, p-header_field_mark); + settings.call_on_header_value(this, data, header_value_mark, p-header_value_mark); + settings.call_on_url (this, data, url_mark, p-url_mark); + settings.call_on_path (this, data, url_mark, p-url_mark); + + return data.position()-this.p_start; + } // execute + + int error (ParserSettings settings, String mes, ByteBuffer data) { + settings.call_on_error(this, mes, data, this.p_start); + this.state = State.dead; + return data.position()-this.p_start; + } + + public boolean http_message_needs_eof() { + if(type == ParserType.HTTP_REQUEST){ + return false; + } + /* See RFC 2616 section 4.4 */ + if ((status_code / 100 == 1) || /* 1xx e.g. Continue */ + (status_code == 204) || /* No Content */ + (status_code == 304) || /* Not Modified */ + (flags & F_SKIPBODY) != 0) { /* response to a HEAD request */ + return false; + } + if ((flags & F_CHUNKED) != 0 || content_length != -1) { + return false; + } + + return true; + } + + /* If http_should_keep_alive() in the on_headers_complete or + * on_message_complete callback returns true, then this will be should be + * the last message on the connection. + * If you are the server, respond with the "Connection: close" header. + * If you are the client, close the connection. + */ + public boolean http_should_keep_alive() { + if (http_major > 0 && http_minor > 0) { + /* HTTP/1.1 */ + if ( 0 != (flags & F_CONNECTION_CLOSE) ) { + return false; + } + } else { + /* HTTP/1.0 or earlier */ + if ( 0 == (flags & F_CONNECTION_KEEP_ALIVE) ) { + return false; + } + } + return !http_message_needs_eof(); + } + + public int parse_url(ByteBuffer data, boolean is_connect, HTTPParserUrl u) { + + UrlFields uf = UrlFields.UF_MAX; + UrlFields old_uf = UrlFields.UF_MAX; + u.port = 0; + u.field_set = 0; + state = (is_connect ? State.req_host_start : State.req_spaces_before_url); + int p_init = data.position(); + int p = 0; + byte ch = 0; + while (data.position() != data.limit()) { + p = data.position(); + ch = data.get(); + state = parse_url_char(ch); + switch(state) { + case dead: + return 1; + + /* Skip delimeters */ + case req_schema_slash: + case req_schema_slash_slash: + case req_host_start: + case req_host_v6_start: + case req_host_v6_end: + case req_port_start: + case req_query_string_start: + case req_fragment_start: + continue; + + case req_schema: + uf = UrlFields.UF_SCHEMA; + break; + + case req_host: + case req_host_v6: + uf = UrlFields.UF_HOST; + break; + + case req_port: + uf = UrlFields.UF_PORT; + break; + + case req_path: + uf = UrlFields.UF_PATH; + break; + + case req_query_string: + uf = UrlFields.UF_QUERY; + break; + + case req_fragment: + uf = UrlFields.UF_FRAGMENT; + break; + + default: + return 1; + } + /* Nothing's changed; soldier on */ + if (uf == old_uf) { + u.field_data[uf.getIndex()].len++; + continue; + } + + u.field_data[uf.getIndex()].off = p - p_init; + u.field_data[uf.getIndex()].len = 1; + + u.field_set |= (1 << uf.getIndex()); + old_uf = uf; + + } + + /* CONNECT requests can only contain "hostname:port" */ + if (is_connect && u.field_set != ((1 << UrlFields.UF_HOST.getIndex())|(1 << UrlFields.UF_PORT.getIndex()))) { + return 1; + } + + /* Make sure we don't end somewhere unexpected */ + switch (state) { + case req_host_v6_start: + case req_host_v6: + case req_host_v6_end: + case req_host: + case req_port_start: + return 1; + default: + break; + } + + if (0 != (u.field_set & (1 << UrlFields.UF_PORT.getIndex()))) { + /* Don't bother with endp; we've already validated the string */ + int v = strtoi(data, p_init + u.field_data[UrlFields.UF_PORT.getIndex()].off); + + /* Ports have a max value of 2^16 */ + if (v > 0xffff) { + return 1; + } + + u.port = v; + } + + return 0; + } + + //hacky reimplementation of srttoul, tailored for our simple needs + //we only need to parse port val, so no negative values etc + int strtoi(ByteBuffer data, int start_pos) { + data.position(start_pos); + byte ch; + String str = ""; + while(data.position() < data.limit()) { + ch = data.get(); + if(Character.isWhitespace((char)ch)){ + continue; + } + if(isDigit(ch)){ + str = str + (char)ch; //TODO replace with something less hacky + }else{ + break; + } + } + return Integer.parseInt(str); + } + + boolean isDigit(byte b) { + if (b >= 0x30 && b <=0x39) { + return true; + } + return false; + } + + boolean isHex(byte b) { + return isDigit(b) || (lower(b) >= 0x61 /*a*/ && lower(b) <= 0x66 /*f*/); + } + + boolean isAtoZ(byte b) { + byte c = lower(b); + return (c>= 0x61 /*a*/ && c <= 0x7a /*z*/); + } + + + byte lower (byte b) { + return (byte)(b|0x20); + } + + byte upper(byte b) { + char c = (char)(b); + return (byte)Character.toUpperCase(c); + } + + byte token(byte b) { + if(!strict){ + return (b == (byte)' ') ? (byte)' ' : (byte)tokens[b] ; + }else{ + return (byte)tokens[b]; + } + } + + boolean isHostChar(byte ch){ + if(!strict){ + return (isAtoZ(ch)) || isDigit(ch) || DOT == ch || DASH == ch || UNDER == ch ; + }else{ + return (isAtoZ(ch)) || isDigit(ch) || DOT == ch || DASH == ch; + } + } + + boolean isNormalUrlChar(int chi) { + if(!strict){ + return (chi > 0x80) || normal_url_char[chi]; + }else{ + return normal_url_char[chi]; + } + } + + HTTPMethod start_req_method_assign(byte c){ + switch (c) { + case C: return HTTPMethod.HTTP_CONNECT; /* or COPY, CHECKOUT */ + case D: return HTTPMethod.HTTP_DELETE; + case G: return HTTPMethod.HTTP_GET; + case H: return HTTPMethod.HTTP_HEAD; + case L: return HTTPMethod.HTTP_LOCK; + case M: return HTTPMethod.HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH */ + case N: return HTTPMethod.HTTP_NOTIFY; + case O: return HTTPMethod.HTTP_OPTIONS; + case P: return HTTPMethod.HTTP_POST; /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ + case R: return HTTPMethod.HTTP_REPORT; + case S: return HTTPMethod.HTTP_SUBSCRIBE; + case T: return HTTPMethod.HTTP_TRACE; + case U: return HTTPMethod.HTTP_UNLOCK; /* or UNSUBSCRIBE */ + } + return null; // ugh. + } + + boolean header_almost_done(byte ch) { + if (strict && LF != ch) { + return false; + } + + state = State.header_value_lws; + // TODO java enums support some sort of bitflag mechanism !? + switch (header_state) { + case connection_keep_alive: + flags |= F_CONNECTION_KEEP_ALIVE; + break; + case connection_close: + flags |= F_CONNECTION_CLOSE; + break; + case transfer_encoding_chunked: + flags |= F_CHUNKED; + break; + default: + break; + } + return true; + } + +// boolean headers_almost_done (byte ch, ParserSettings settings) { +// } // headers_almost_done + + + final int min (int a, int b) { + return a < b ? a : b; + } + + final int min (int a, long b) { + return a < b ? a : (int)b; + } + + /* probably not the best place to hide this ... */ + public boolean HTTP_PARSER_STRICT; + State new_message() { + if (HTTP_PARSER_STRICT){ + return http_should_keep_alive() ? start_state() : State.dead; + } else { + return start_state(); + } + + } + + State start_state() { + return type == ParserType.HTTP_REQUEST ? State.start_req : State.start_res; + } + + + boolean parsing_header(State state) { + + switch (state) { + case chunk_data : + case chunk_data_almost_done : + case chunk_data_done : + case body_identity : + case body_identity_eof : + case message_done : + return false; + + } + return true; + } + + /* "Dial C for Constants" */ + static class C { + static final int HTTP_MAX_HEADER_SIZE = 80 * 1024; + + static final int F_CHUNKED = 1 << 0; + static final int F_CONNECTION_KEEP_ALIVE = 1 << 1; + static final int F_CONNECTION_CLOSE = 1 << 2; + static final int F_TRAILING = 1 << 3; + static final int F_UPGRADE = 1 << 4; + static final int F_SKIPBODY = 1 << 5; + + static final byte [] UPCASE = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x2f, + 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, 0x38,0x39,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x41,0x42,0x43,0x44,0x45,0x46,0x47, 0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, 0x58,0x59,0x5a,0x00,0x00,0x00,0x00,0x5f, + 0x00,0x41,0x42,0x43,0x44,0x45,0x46,0x47, 0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, 0x58,0x59,0x5a,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + }; + static final byte [] CONNECTION = { + 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, + }; + static final byte [] PROXY_CONNECTION = { + 0x50, 0x52, 0x4f, 0x58, 0x59, 0x2d, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, + }; + static final byte [] CONTENT_LENGTH = { + 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x4e, 0x54, 0x2d, 0x4c, 0x45, 0x4e, 0x47, 0x54, 0x48, + }; + static final byte [] TRANSFER_ENCODING = { + 0x54, 0x52, 0x41, 0x4e, 0x53, 0x46, 0x45, 0x52, 0x2d, 0x45, 0x4e, 0x43, 0x4f, 0x44, 0x49, 0x4e, 0x47, + }; + static final byte [] UPGRADE = { + 0x55, 0x50, 0x47, 0x52, 0x41, 0x44, 0x45, + }; + static final byte [] CHUNKED = { + 0x43, 0x48, 0x55, 0x4e, 0x4b, 0x45, 0x44, + }; + static final byte [] KEEP_ALIVE = { + 0x4b, 0x45, 0x45, 0x50, 0x2d, 0x41, 0x4c, 0x49, 0x56, 0x45, + }; + static final byte [] CLOSE = { + 0x43, 0x4c, 0x4f, 0x53, 0x45, + }; + + /* Tokens as defined by rfc 2616. Also lowercases them. + * token = 1* + * separators = "(" | ")" | "<" | ">" | "@" + * | "," | ";" | ":" | "\" | <"> + * | "/" | "[" | "]" | "?" | "=" + * | "{" | "}" | SP | HT + */ + + static final char [] tokens = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0, '!', 0, '#', '$', '%', '&', '\'', +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 0, 0, '*', '+', 0, '-', '.', 0 , +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + '0', '1', '2', '3', '4', '5', '6', '7', +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + '8', '9', 0, 0, 0, 0, 0, 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 'X', 'Y', 'Z', 0, 0, 0, 0, '_', +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 'X', 'Y', 'Z', 0, '|', 0, '~', 0, +/* hi bit set, not ascii */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; + + static final byte [] UNHEX = + { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + }; + + static final boolean [] normal_url_char = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + false, false, false, false, false, false, false, false, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + false, false, false, false, false, false, false, false, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + false, false, false, false, false, false, false, false, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + false, false, false, false, false, false, false, false, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + false, true, true, false, true, true, true, true, +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + true, true, true, true, true, true, true, true, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + true, true, true, true, true, true, true, true, +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + true, true, true, true, true, true, true, false, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + true, true, true, true, true, true, true, true, +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + true, true, true, true, true, true, true, true, +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + true, true, true, true, true, true, true, true, +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + true, true, true, true, true, true, true, true, +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + true, true, true, true, true, true, true, true, +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + true, true, true, true, true, true, true, true, +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + true, true, true, true, true, true, true, true, +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + true, true, true, true, true, true, true, false, + +/* hi bit set, not ascii */ +/* Remainder of non-ASCII range are accepted as-is to support implicitly UTF-8 + * encoded paths. This is out of spec, but clients generate this and most other + * HTTP servers support it. We should, too. */ + + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + + }; + + public static final byte A = 0x41; + public static final byte B = 0x42; + public static final byte C = 0x43; + public static final byte D = 0x44; + public static final byte E = 0x45; + public static final byte F = 0x46; + public static final byte G = 0x47; + public static final byte H = 0x48; + public static final byte I = 0x49; + public static final byte J = 0x4a; + public static final byte K = 0x4b; + public static final byte L = 0x4c; + public static final byte M = 0x4d; + public static final byte N = 0x4e; + public static final byte O = 0x4f; + public static final byte P = 0x50; + public static final byte Q = 0x51; + public static final byte R = 0x52; + public static final byte S = 0x53; + public static final byte T = 0x54; + public static final byte U = 0x55; + public static final byte V = 0x56; + public static final byte W = 0x57; + public static final byte X = 0x58; + public static final byte Y = 0x59; + public static final byte Z = 0x5a; + public static final byte UNDER = 0x5f; + public static final byte CR = 0x0d; + public static final byte LF = 0x0a; + public static final byte DOT = 0x2e; + public static final byte SPACE = 0x20; + public static final byte TAB = 0x09; + public static final byte SEMI = 0x3b; + public static final byte COLON = 0x3a; + public static final byte HASH = 0x23; + public static final byte QMARK = 0x3f; + public static final byte SLASH = 0x2f; + public static final byte DASH = 0x2d; + public static final byte STAR = 0x2a; + public static final byte NULL = 0x00; + } + + enum State { + + dead + + , start_req_or_res + , res_or_resp_H + , start_res + , res_H + , res_HT + , res_HTT + , res_HTTP + , res_first_http_major + , res_http_major + , res_first_http_minor + , res_http_minor + , res_first_status_code + , res_status_code + , res_status + , res_line_almost_done + + , start_req + + , req_method + , req_spaces_before_url + , req_schema + , req_schema_slash + , req_schema_slash_slash + , req_host_start + , req_host_v6_start + , req_host_v6 + , req_host_v6_end + , req_host + , req_port_start + , req_port + , req_path + , req_query_string_start + , req_query_string + , req_fragment_start + , req_fragment + , req_http_start + , req_http_H + , req_http_HT + , req_http_HTT + , req_http_HTTP + , req_first_http_major + , req_http_major + , req_first_http_minor + , req_http_minor + , req_line_almost_done + + , header_field_start + , header_field + , header_value_start + , header_value + , header_value_lws + + , header_almost_done + + , chunk_size_start + , chunk_size + , chunk_parameters + , chunk_size_almost_done + + , headers_almost_done + , headers_done +// This space intentionally not left blank, comment from c, for orientation... +// the c version uses <= s_header_almost_done in java, we list the states explicitly +// in `parsing_header()` +/* Important: 's_headers_done' must be the last 'header' state. All + * states beyond this must be 'body' states. It is used for overflow + * checking. See the PARSING_HEADER() macro. + */ + , chunk_data + , chunk_data_almost_done + , chunk_data_done + + , body_identity + , body_identity_eof + , message_done + + } + enum HState { + general + , C + , CO + , CON + + , matching_connection + , matching_proxy_connection + , matching_content_length + , matching_transfer_encoding + , matching_upgrade + + , connection + , content_length + , transfer_encoding + , upgrade + + , matching_transfer_encoding_chunked + , matching_connection_keep_alive + , matching_connection_close + + , transfer_encoding_chunked + , connection_keep_alive + , connection_close + } + public enum UrlFields { + UF_SCHEMA(0) + , UF_HOST(1) + , UF_PORT(2) + , UF_PATH(3) + , UF_QUERY(4) + , UF_FRAGMENT(5) + , UF_MAX(6); + + + private final int index; + + private UrlFields(int index) { + this.index = index; + } + public int getIndex() { + return index; + } + + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/ParserSettings.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/ParserSettings.java new file mode 100644 index 0000000..1ebdd4f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/ParserSettings.java @@ -0,0 +1,83 @@ +package http_parser.lolevel; +import java.nio.ByteBuffer; +import http_parser.HTTPException; +public class ParserSettings { + + public HTTPCallback on_message_begin; + public HTTPDataCallback on_path; + public HTTPDataCallback on_query_string; + public HTTPDataCallback on_url; + public HTTPDataCallback on_fragment; + public HTTPCallback on_status_complete; + public HTTPDataCallback on_header_field; + public HTTPDataCallback on_header_value; + public HTTPCallback on_headers_complete; + public HTTPDataCallback on_body; + public HTTPCallback on_message_complete; + public HTTPErrorCallback on_error; + + void call_on_message_begin (HTTPParser p) { + call_on(on_message_begin, p); + } + + void call_on_message_complete (HTTPParser p) { + call_on(on_message_complete, p); + } + + // this one is a little bit different: + // the current `position` of the buffer is the location of the + // error, `ini_pos` indicates where the position of + // the buffer when it was passed to the `execute` method of the parser, i.e. + // using this information and `limit` we'll know all the valid data + // in the buffer around the error we can use to print pretty error + // messages. + void call_on_error (HTTPParser p, String mes, ByteBuffer buf, int ini_pos) { + if (null != on_error) { + on_error.cb(p, mes, buf, ini_pos); + return; + } + // if on_error gets called it MUST throw an exception, else the parser + // will attempt to continue parsing, which it can't because it's + // in an invalid state. + throw new HTTPException(mes); + } + + void call_on_header_field (HTTPParser p, ByteBuffer buf, int pos, int len) { + call_on(on_header_field, p, buf, pos, len); + } + void call_on_query_string (HTTPParser p, ByteBuffer buf, int pos, int len) { + call_on(on_query_string, p, buf, pos, len); + } + void call_on_fragment (HTTPParser p, ByteBuffer buf, int pos, int len) { + call_on(on_fragment, p, buf, pos, len); + } + void call_on_status_complete(HTTPParser p) { + call_on(on_status_complete, p); + } + void call_on_path (HTTPParser p, ByteBuffer buf, int pos, int len) { + call_on(on_path, p, buf, pos, len); + } + void call_on_header_value (HTTPParser p, ByteBuffer buf, int pos, int len) { + call_on(on_header_value, p, buf, pos, len); + } + void call_on_url (HTTPParser p, ByteBuffer buf, int pos, int len) { + call_on(on_url, p, buf, pos, len); + } + void call_on_body(HTTPParser p, ByteBuffer buf, int pos, int len) { + call_on(on_body, p, buf, pos, len); + } + void call_on_headers_complete(HTTPParser p) { + call_on(on_headers_complete, p); + } + void call_on (HTTPCallback cb, HTTPParser p) { + // cf. CALLBACK2 macro + if (null != cb) { + cb.cb(p); + } + } + void call_on (HTTPDataCallback cb, HTTPParser p, ByteBuffer buf, int pos, int len) { + if (null != cb && -1 != pos) { + cb.cb(p,buf,pos,len); + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Message.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Message.java new file mode 100644 index 0000000..62f0a0e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Message.java @@ -0,0 +1,374 @@ +package http_parser.lolevel; + +import java.nio.*; +import java.io.*; +import java.util.*; + +import http_parser.HTTPMethod; +import http_parser.HTTPParserUrl; +import http_parser.ParserType; +import http_parser.lolevel.TestLoaderNG.Header; +import http_parser.lolevel.TestLoaderNG.LastHeader; + +import primitive.collection.ByteList; + +import static http_parser.lolevel.Util.str; + +public class Message { + String name; + byte [] raw; + ParserType type; + HTTPMethod method; + int status_code; + String request_path; // byte [] ? + String request_url; + String fragment ; + String query_string; + byte [] body; + int body_size; + int num_headers; + LastHeader last_header_element; + Map header; + List
headers; + boolean should_keep_alive; + + byte[] upgrade; + boolean upgrade() { + return null != upgrade; + } + + int http_major; + int http_minor; + + boolean message_begin_called; + boolean headers_complete_called; + boolean message_complete_called; + boolean message_complete_on_eof; + + + Map parsed_header; + String currHField; + String currHValue; + byte [] pbody; + int num_called; + + public String toString() { + StringBuilder b = new StringBuilder(); + b.append("NAME: "); b.append(name);b.append("\n"); + b.append("type: "); b.append(type);b.append("\n"); + b.append("method: "); b.append(method);b.append("\n"); + b.append("status_code: "); b.append(status_code);b.append("\n"); + b.append("request_path: "); b.append(request_path);b.append("\n"); + b.append("request_url: "); b.append(request_url);b.append("\n"); + b.append("fragment: "); b.append(fragment);b.append("\n"); + b.append("query_string: "); b.append(query_string);b.append("\n"); + b.append("body:\n"); b.append(new String(body));b.append("\n"); + b.append("should_keep_alive: "); b.append(should_keep_alive);b.append("\n"); + b.append("upgrade: "); b.append(upgrade);b.append("\n"); + b.append("http_major: "); b.append(http_major);b.append("\n"); + b.append("http_minor: "); b.append(http_minor);b.append("\n"); + b.append("message_complete_called: "); b.append(message_complete_called);b.append("\n"); + return b.toString(); + } + + Message () { + this.header = new HashMap(); + this.headers = new LinkedList
(); + reset(); + } + /* + *prepare this Test Instance for reuse. + * */ + void reset () { + this.parsed_header = new HashMap(); + this.pbody = null; + this.num_called = 0; + + } + void check (boolean val, String mes) { + if (!val) { + //p(name+" : "+mes); + throw new RuntimeException(name+" : "+mes); + } + } + + + HTTPDataCallback getCB (final String value, final String mes, final TestSettings settings) { + return new HTTPDataCallback() { + public int cb (HTTPParser p, ByteBuffer b, int pos, int len){ + // if ("url".equals(mes)){ + // p("pos"+pos); + // p("len"+len); + // if (8==pos && 5 == len && "connect request".equals(name)) { + // //throw new RuntimeException(name); + // } + // } + //String str = str(b, pos, len); + ByteList list = settings.map.get(mes); + for (int i=0; i!=len; ++i) { + list.add(b.get(pos+i)); + } + //settings.map.put(mes, prev_val + str); + //check(value.equals(str), "incorrect "+mes+": "+str); + if (-1 == pos) { + throw new RuntimeException("he?"); + } + return 0; + } + }; + } + + void execute () { + p(name); + ByteBuffer buf = ByteBuffer.wrap(raw); + HTTPParser p = new HTTPParser(); + TestSettings s = settings(); + + + + p.execute(s, buf); + if (!p.upgrade) { + // call execute again, else parser can't know message is done + // if no content length is set. + p.execute(s, buf); + } + if (!s.success) { + throw new RuntimeException("Test: "+name+" failed"); + } + } // execute + + void execute_permutations() { + /* + |-|---------------| + |--|--------------| + |---|-------------| + (...) + |---------------|-| + |-----------------| + */ + p(name); + for (int i = 2; i != raw.length; ++i) { + // p(i); + HTTPParser p = new HTTPParser(); + TestSettings s = settings(); + ByteBuffer buf = ByteBuffer.wrap(raw); + int olimit = buf.limit(); + buf.limit(i); + + parse(p,s,buf); + if (!p.upgrade) { + buf.position(i); + buf.limit(olimit); + + parse(p,s,buf); + if (!p.upgrade) { + parse(p,s,buf); + } else { + if (!upgrade()) { + throw new RuntimeException("Test:"+name+"parsed as upgrade, is not"); + } + } + + } else { + if (!upgrade()) { + throw new RuntimeException("Test:"+name+"parsed as upgrade, is not"); + } + } + if (!s.success) { + p(this); + throw new RuntimeException("Test: "+name+" failed"); + } + reset(); + } + //System.exit(0); + } // execute_permutations + void parse(HTTPParser p, ParserSettings s, ByteBuffer b) { + //p("About to parse: "+b.position() + "->" + b.limit()); + p.execute(s, b); + } + + TestSettings settings() { + final TestSettings s = new TestSettings(); + s.on_url = getCB(request_url, "url", s); + s.on_message_begin = new HTTPCallback() { + public int cb (HTTPParser p) { + message_begin_called = true; + return -1; + } + }; + s.on_header_field = new HTTPDataCallback() { + public int cb (HTTPParser p, ByteBuffer b, int pos, int len){ + if (null != currHValue && null == currHField) { + throw new RuntimeException(name+": shouldn't happen"); + } + if (null != currHField) { + if (null == currHValue) { + currHField += str(b,pos,len); + return 0; + } else { + parsed_header.put(currHField, currHValue); + currHField = null; + currHValue = null; + } + } + currHField = str(b,pos,len); + return 0; + } + }; + s.on_header_value = new HTTPDataCallback() { + public int cb (HTTPParser p, ByteBuffer b, int pos, int len){ + if (null == currHField) { + throw new RuntimeException(name+" :shouldn't happen field"); + } + if (null == currHValue) { + currHValue = str(b,pos,len); + } else { + currHValue += str(b, pos, len); + } + return 0; + } + }; + s.on_headers_complete = new HTTPCallback() { + public int cb (HTTPParser p) { + headers_complete_called = true; + String parsed_path = null; + String parsed_query = null; + String parsed_url = null; + String parsed_frag = null; + + try { + parsed_url = new String(s.map.get("url").toArray(), "UTF8"); + + HTTPParserUrl u = new HTTPParserUrl(); + HTTPParser pp = new HTTPParser(); + ByteBuffer data = Util.buffer(parsed_url); + pp.parse_url(data,false, u); + + parsed_path = u.getFieldValue(HTTPParser.UrlFields.UF_PATH, data); + parsed_query = u.getFieldValue(HTTPParser.UrlFields.UF_QUERY, data); + parsed_frag = u.getFieldValue(HTTPParser.UrlFields.UF_FRAGMENT, data); + + } catch (java.io.UnsupportedEncodingException uee) { + throw new RuntimeException(uee); + } + + if (!request_path.equals(parsed_path)) { + throw new RuntimeException(name+": invalid path: "+parsed_path+" should be: "+request_path); + } + if (!query_string.equals(parsed_query)) { + throw new RuntimeException(name+": invalid query: "+parsed_query+" should be: "+query_string); + } + if (!request_url.equals(parsed_url)) { + throw new RuntimeException(">"+name+"<: invalid url: >"+parsed_url+"< should be: >"+request_url+"<"); + } + if (!fragment.equals(parsed_frag)) { + throw new RuntimeException(name+": invalid fragement: "+parsed_frag+" should be: "+fragment); + } + if (null != currHValue || null != currHField) { + if (null == currHField || null == currHValue) { + throw new RuntimeException("shouldn't happen"); + } + } + if (null != currHField) { + //p(currHField); + //p(">"+currHValue+"<"); + parsed_header.put(currHField, currHValue); + currHField = null; + currHValue = null; + } + + + return 0; + } + }; + // s.on_headers_complete = new HTTPCallback() { + // public int cb (HTTPParser p) { + // p("Complete:"+name); + // return 0; + // } + // }; + + s.on_body = new HTTPDataCallback() { + public int cb (HTTPParser p, ByteBuffer b, int pos, int len){ + int l = pbody == null ? len : len + pbody.length; + int off = pbody == null ? 0 : pbody.length; + byte [] nbody = new byte[l]; + + if (null != pbody) { + System.arraycopy(pbody, 0, nbody, 0, pbody.length); + } + + int saved = b.position(); + b.position(pos); + b.get(nbody, off, len); + b.position(saved); + pbody = nbody; + return 0; + } + }; + + s.on_message_complete = new HTTPCallback() { + public int cb(HTTPParser p) { + message_complete_called = true; + num_called += 1; + if ( p.http_minor != http_minor + || p.http_major != http_major + || p.status_code != status_code ) { + + throw new RuntimeException("major/minor/status_code mismatch"); + } + + //check headers + + if (header.keySet().size() != parsed_header.keySet().size()) { + p(parsed_header); + throw new RuntimeException(name+": different amount of headers"); + } + for (String key : header.keySet()) { + String pvalue = parsed_header.get(key); + if (!header.get(key).equals(pvalue)) { + throw new RuntimeException(name+" : different values for :"+key+" is >"+pvalue+"< should: >"+header.get(key)+"<"); + } + } + //check body + if (null == pbody && (null == body || body.length == 0 || body.length == 1)) { + s.success = true; + return 0; + } + if (null == pbody) { + throw new RuntimeException(name+": no body, should be: "+new String(body)); + } + if (pbody.length != body.length) { + p(pbody.length); + p(body.length); + p(new String(pbody)); + p(new String(body)); + throw new RuntimeException(name+": incorrect body length"); + } + for (int i = 0 ; i!= body.length; ++i) { + if (pbody[i] != body[i]) { + throw new RuntimeException("different body"); + } + } + s.success = true; + return 0; + } + }; + return s; + } // settings + static void p(Object o) { + System.out.println(o); + } + + static class TestSettings extends ParserSettings { + public boolean success; + Map map; + TestSettings () { + map = new HashMap(); + map.put("path", new ByteList()); + map.put("query_string", new ByteList()); + map.put("url", new ByteList()); + map.put("fragment", new ByteList()); + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/ParseUrl.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/ParseUrl.java new file mode 100644 index 0000000..0e74021 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/ParseUrl.java @@ -0,0 +1,51 @@ +package http_parser.lolevel; + +import http_parser.HTTPParserUrl; +import static http_parser.lolevel.Util.*; + +public class ParseUrl { + public static void test(int i) { + HTTPParserUrl u = new HTTPParserUrl(); + HTTPParser p = new HTTPParser(); + Url test = Url.URL_TESTS[i]; +// System.out.println(":: " + test.name); + int rv = p.parse_url(Util.buffer(test.url),test.is_connect,u); + UnitTest.check_equals(rv, test.rv); + if(test.rv == 0){ + UnitTest.check_equals(u, test.u); + } + + } + public static void test() { + p(ParseUrl.class); + + for (int i = 0; i < Url.URL_TESTS.length; i++) { + test(i); + } + } + + static void usage() { + p("usage: [jre] http_parser.lolevel.ParseUrl [i]"); + p(" i : optional test case id"); + p("---------------------------------------------"); + p("Test Cases:"); + for (int i =0; i!= Url.URL_TESTS.length; ++i) { + p(" "+i+": "+Url.URL_TESTS[i].name); + } + } + + public static void main (String [] args) { + if (0 == args.length) { + test(); + } else { + try { + int i = Integer.parseInt(args[0]); + test(i); + } catch (Throwable t) { + t.printStackTrace(); + usage(); + } + + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Requests.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Requests.java new file mode 100644 index 0000000..4367bbb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Requests.java @@ -0,0 +1,69 @@ +package http_parser.lolevel; + +import java.nio.*; +import java.util.*; + +import static http_parser.lolevel.Util.*; +import http_parser.*; + +import primitive.collection.ByteList; + +public class Requests { + + static void test_simple(String req, boolean should_pass) { + HTTPParser parser = new HTTPParser(ParserType.HTTP_REQUEST); + ByteBuffer buf = buffer(req); + boolean passed = false; + int read = 0; + try { + parser.execute(Util.SETTINGS_NULL, buf); + passed = (read == req.length()); + read = parser.execute(Util.SETTINGS_NULL, Util.empty()); + passed &= (0 == read); + } catch (Throwable t) { + passed = false; + } + check(passed == should_pass); + } + static void simple_tests() { + test_simple("hello world", false); + test_simple("GET / HTP/1.1\r\n\r\n", false); + + test_simple("ASDF / HTTP/1.1\r\n\r\n", false); + test_simple("PROPPATCHA / HTTP/1.1\r\n\r\n", false); + test_simple("GETA / HTTP/1.1\r\n\r\n", false); + } + + public static void test () { + p(Requests.class); + simple_tests(); + + List all = TestLoaderNG.load("tests.dumped"); + List requests = new LinkedList(); + for (Message m : all) { + if (ParserType.HTTP_REQUEST == m.type) { + requests.add(m); + } + } + for (Message m : requests) { + test_message(m); + } + + for (int i = 0; i!= requests.size(); ++i) { + if (!requests.get(i).should_keep_alive) continue; + for (int j = 0; j!=requests.size(); ++j) { + if (!requests.get(j).should_keep_alive) continue; + for (int k = 0; k!= requests.size(); ++k) { + test_multiple3(requests.get(i), requests.get(j), requests.get(k)); + } + } + } + + // postpone test_scan + + } + + + + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Responses.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Responses.java new file mode 100644 index 0000000..1cb71dc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Responses.java @@ -0,0 +1,52 @@ +package http_parser.lolevel; + +import java.nio.*; +import java.util.*; + +import static http_parser.lolevel.Util.*; +import http_parser.*; + +import primitive.collection.ByteList; + +public class Responses { + + + + public static void test () { + p(Responses.class); + List all = TestLoaderNG.load("tests.dumped"); + List responses = new LinkedList(); + for (Message m : all) { + if (ParserType.HTTP_RESPONSE == m.type) { + responses.add(m); + } + } + for (Message m : responses) { + test_message(m); + } + + for (int i = 0; i!= responses.size(); ++i) { + if (!responses.get(i).should_keep_alive) continue; + for (int j = 0; j!=responses.size(); ++j) { + if (!responses.get(j).should_keep_alive) continue; + for (int k = 0; k!= responses.size(); ++k) { + test_multiple3(responses.get(i), responses.get(j), responses.get(k)); + } + } + } + + // not sure what test_message_count_body does that test_message doesn't... + // Message m = find(responses, "404 no headers no body"); + // test_message_count_body(m); + // m = find(responses, "200 trailing space on chunked body"); + // test_message_count_body(m); + + // TODO test very large chunked response + + // test_scan is more or less the same as test_permutations, will implement later... + } + + + + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Test.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Test.java new file mode 100644 index 0000000..6c35898 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Test.java @@ -0,0 +1,16 @@ +package http_parser.lolevel; + + +public class Test { + public static void main (String [] args) { + UnitTest.test(); + TestHeaderOverflowError.test(); + TestNoOverflowLongBody.test(); + Responses.test(); + ParseUrl.test(); + Requests.test(); + Upgrade.test(); + WrongContentLength.test(); + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java new file mode 100644 index 0000000..ee47903 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java @@ -0,0 +1,48 @@ +package http_parser.lolevel; + +import java.nio.*; + +import static http_parser.lolevel.Util.*; + +public class TestHeaderOverflowError { + + public static void test (http_parser.ParserType type) { + HTTPParser parser = new HTTPParser(type); + ByteBuffer buf = getBytes(type); + + int numbytes = buf.limit(); + + parser.execute(Util.SETTINGS_NULL, buf); + + check(numbytes == buf.position()); + + buf = buffer("header-key: header-value\r\n"); + numbytes = buf.limit(); + for (int i = 0; i!= 1000; ++i) { + parser.execute(Util.SETTINGS_NULL, buf); + check(numbytes == buf.position()); + + buf.rewind(); + + } + } + + static ByteBuffer getBytes (http_parser.ParserType type) { + if (http_parser.ParserType.HTTP_BOTH == type) { + throw new RuntimeException("only HTTP_REQUEST and HTTP_RESPONSE"); + } + + if (http_parser.ParserType.HTTP_REQUEST == type) { + return buffer("GET / HTTP/1.1\r\n"); + } + return buffer("HTTP/1.0 200 OK\r\n"); + } + + public static void test () { + p(TestHeaderOverflowError.class); + test(http_parser.ParserType.HTTP_REQUEST); + test(http_parser.ParserType.HTTP_RESPONSE); + } + + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestLoaderNG.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestLoaderNG.java new file mode 100644 index 0000000..329485d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestLoaderNG.java @@ -0,0 +1,212 @@ +package http_parser.lolevel; +// name : 200 trailing space on chunked body +// raw : "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n25 \r\nThis is the data in the first chunk\r\n\r\n1C\r\nand this is the second one\r\n\r\n0 \r\n\r\n" +// type : HTTP_RESPONSE +// method: HTTP_DELETE +// status code :200 +// request_path: +// request_url : +// fragment : +// query_string: +// body :"This is the data in the first chunk\r\nand this is the second one\r\n" +// body_size :65 +// header_0 :{ "Content-Type": "text/plain"} +// header_1 :{ "Transfer-Encoding": "chunked"} +// should_keep_alive :1 +// upgrade :0 +// http_major :1 +// http_minor :1 + + +import java.io.FileReader; +import java.io.BufferedReader; +import java.io.StringReader; +import java.io.Reader; +import java.io.Reader; +import java.io.IOException; + +import java.util.*; +import java.util.regex.*; + +import java.nio.ByteBuffer; + +import http_parser.HTTPMethod; +import http_parser.ParserType; + +public class TestLoaderNG { + String fn; + public TestLoaderNG(String filename) { + this.fn = filename; + } + static void p(Object o) { + System.out.println(o); + } + public static List load (String fn) { + List list = null; + try { + BufferedReader buf = new BufferedReader(new FileReader(fn)); + list = load(buf); + } catch (Throwable t) { + throw new RuntimeException(t); + } + return list; + + } + public static Message parse (String message) { + List list = load(new BufferedReader(new StringReader(message))); + if (null == list || 0 == list.size() ) { + return null; + } + return list.get(0); + } + + public static List load (BufferedReader buf) { + List list = new LinkedList(); + String line = null; + Message curr = new Message(); + Pattern pattern = Pattern.compile("(\\S+)\\s*:(.*)"); + try { + while (null != (line = buf.readLine()) ){ + if ("".equals(line.trim())) { + list.add (curr); + curr = new Message(); + continue; + } + Matcher m = pattern.matcher(line); + if (m.matches()) { + // you can not be fucking serious!? + // this has got to be the most retarded regex + // interface in the history of the world ... + // (though I'm sure there's worse c++ regexp libs...) + MatchResult r = m.toMatchResult(); + String key = r.group(1).trim(); + String value = r.group(2).trim(); + if ("name".equals(key)) {curr.name = value;} + else if ("raw".equals(key)) {curr.raw = toByteArray(value);} //! + else if ("type".equals(key)) {curr.type = ParserType.parse(value);} + else if ("method".equals(key)) {curr.method = HTTPMethod.parse(value);} + else if ("status_code".equals(key)) {curr.status_code = Integer.parseInt(value);} + else if ("request_path".equals(key)) {curr.request_path = value;} + else if ("request_url".equals(key)) {curr.request_url = value;} + + else if ("fragment".equals(key)) {curr.fragment = value;} + else if ("query_string".equals(key)) {curr.query_string = value;} + else if ("body".equals(key)) {curr.body = toByteArray(value);} //! + else if ("body_size".equals(key)) {curr.body_size = Integer.parseInt(value);} + else if (key.startsWith("header")) { + String [] h = getHeader(value); + curr.header.put(h[0], h[1]); + } + else if ("should_keep_alive".equals(key)) + {curr.should_keep_alive = (1 == Integer.parseInt(value));} + else if ("upgrade".equals(key)) { curr.upgrade = toByteArray(value);} + else if ("http_major".equals(key)) {curr.http_major = Integer.parseInt(value);} + else if ("http_minor".equals(key)) {curr.http_minor = Integer.parseInt(value);} + } else { + p("WTF?"+line); + } + + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + return list; + } + + static String [] getHeader(String value) { + // { "Host": "0.0.0.0=5000"} + Pattern p = Pattern.compile("\\{ ?\"([^\"]*)\": ?\"(.*)\"}"); + Matcher m = p.matcher(value); + if (!m.matches()) { + p(value); + throw new RuntimeException("something wrong"); + } + String [] result = new String[2]; + MatchResult r = m.toMatchResult(); + result[0] = r.group(1).trim(); + result[1] = r.group(2); //.trim(); + return result; + } + + static final byte BSLASH = 0x5c; + static final byte QUOT = 0x22; + static final byte CR = 0x0d; + static final byte LF = 0x0a; + static final byte n = 0x6e; + static final byte r = 0x72; + + static final Byte[] JAVA_GENERICS_ROCK_HARD = new Byte[0]; + + + static byte [] toByteArray (String quotedString) { + ArrayList bytes = new ArrayList(); + String s = quotedString.substring(1, quotedString.length()-1); + byte [] byts = s.getBytes(java.nio.charset.Charset.forName("UTF8")); + boolean escaped = false; + for (byte b : byts) { + switch (b) { + case BSLASH: + escaped = true; + break; + case n: + if (escaped) { + bytes.add(LF); + escaped = false; + } else { + bytes.add(b); + } + break; + case r: + if (escaped) { + escaped = false; + bytes.add(CR); + } else { + bytes.add(b); + } + break; + case QUOT: + escaped = false; + bytes.add(QUOT); + break; + default: + bytes.add(b); + } + + } + + byts = new byte[bytes.size()]; + int i = 0; + for (Byte b : bytes) { + byts[i++]=b; + } + return byts; + } + + public static void main(String [] args) throws Throwable { + //TestLoaderNG l = new TestLoaderNG(args[0]); + List ts = load(args[0]); + for (Message t : ts) { +// for (int i =0; i!= t.raw.length; ++i) { +// p(i+":"+t.raw[i]); +// } +// try { + t.execute_permutations(); +// } catch (Throwable th) { +// p("failed: "+t.name); +// } + t.execute(); + // System.exit(0); + } + } + + class Header { + String field; + String value; + } + enum LastHeader { + NONE + ,FIELD + ,VALUE + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java new file mode 100644 index 0000000..13d8ea0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java @@ -0,0 +1,62 @@ +package http_parser.lolevel; + +import java.nio.*; + +import static http_parser.lolevel.Util.*; + +public class TestNoOverflowLongBody { + + public static void test (http_parser.ParserType type, int len) { + HTTPParser parser = new HTTPParser(type); + ByteBuffer buf = getBytes(type, len); + + int buflen = buf.limit(); + + parser.execute(Util.SETTINGS_NULL, buf); + + check(buflen == buf.position()); + + buf = buffer("a"); + buflen = buf.limit(); + + for (int i = 0; i!= len; ++i) { + parser.execute(Util.SETTINGS_NULL, buf); + check(buflen == buf.position()); + buf.rewind(); + } + + buf = getBytes(type, len); + buflen = buf.limit(); + + parser.execute(Util.SETTINGS_NULL, buf); + + check(buflen == buf.position()); + + } + + static ByteBuffer getBytes (http_parser.ParserType type, int length) { + if (http_parser.ParserType.HTTP_BOTH == type) { + throw new RuntimeException("only HTTP_REQUEST and HTTP_RESPONSE"); + } + + String template = "%s\r\nConnection: Keep-Alive\r\nContent-Length: %d\r\n\r\n"; + String str = null; + if (http_parser.ParserType.HTTP_REQUEST == type) { + str = String.format(template, "GET / HTTP/1.1", length); + } else { + str = String.format(template, "HTTP/1.0 200 OK", length); + } + return buffer(str); + } + + public static void test () { + p(TestNoOverflowLongBody.class); + test(http_parser.ParserType.HTTP_REQUEST, 1000); + test(http_parser.ParserType.HTTP_REQUEST, 100000); + test(http_parser.ParserType.HTTP_RESPONSE, 1000); + test(http_parser.ParserType.HTTP_RESPONSE, 100000); + } + + + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/UnitTest.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/UnitTest.java new file mode 100644 index 0000000..4159980 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/UnitTest.java @@ -0,0 +1,117 @@ +package http_parser.lolevel; + +import java.nio.ByteBuffer; +import http_parser.HTTPException; +import http_parser.Util; + +public class UnitTest { + + static void p(Object o) {System.out.println(o);} + + public static void testErrorFormat() { + String bla = "This has an error in position 10 (the n in 'an')"; + ByteBuffer buf = ByteBuffer.wrap(bla.getBytes()); + buf.position(10); + + String mes = +"This has an error in position 10 (the n in 'an')\n" + +"..........^"; + + check_equals(mes, Util.error ("test error", buf, 0)); + + + bla = "123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J"; + buf = ByteBuffer.wrap(bla.getBytes()); + buf.position(50); + mes = +"56789B123456789C123456789D123456789E123456789F123456789G123456789H123456\n"+ +"....................................^"; + check_equals(mes, Util.error("test trim right and left", buf, 0)); + + + buf.position(5); + mes = +"123456789A123456789B123456789C123456789D123456789E123456789F123456789G12\n"+ +".....^"; + check_equals(mes, Util.error("test trim right", buf, 0)); + + + int limit = buf.limit(); + buf.limit(10); + mes = +"123456789A\n"+ +".....^"; + check_equals(mes, Util.error("all before, not enough after", buf, 0)); + + + + buf.limit(limit); + buf.position(90); + mes = +"9C123456789D123456789E123456789F123456789G123456789H123456789I123456789J\n"+ +"..............................................................^"; + check_equals(mes, Util.error("test trim left", buf, 10)); + } + + + // Test that the error callbacks are properly called. + public static void testErrorCallback () { + String nothttp = "THis is certainly not valid HTTP"; + ByteBuffer buf = ByteBuffer.wrap(nothttp.getBytes()); + + ParserSettings s = new ParserSettings(); + s.on_error = new HTTPErrorCallback() { + public void cb (HTTPParser p, String mes, ByteBuffer buf, int pos) { + throw new HTTPException(mes); + } + }; // err callback + + + HTTPParser p = new HTTPParser(); + try { + p.execute(s, buf); + } catch (HTTPException e) { + check_equals("Invalid HTTP method", e.getMessage()); + } + + buf = ByteBuffer.wrap("GET / HTTP 1.10000".getBytes()); + p = new HTTPParser(); + try { + p.execute(s, buf); + } catch (HTTPException e) { + check_equals("ridiculous http minor", e.getMessage()); + } + + // if no error handler is defined, behave just like the above... + ParserSettings s0 = new ParserSettings(); + + buf = ByteBuffer.wrap("THis is certainly not valid HTTP".getBytes()); + p = new HTTPParser(); + try { + p.execute(s0, buf); + } catch (HTTPException e) { + check_equals("Invalid HTTP method", e.getMessage()); + } + + buf = ByteBuffer.wrap("GET / HTTP 1.10000".getBytes()); + p = new HTTPParser(); + try { + p.execute(s0, buf); + } catch (HTTPException e) { + check_equals("ridiculous http minor", e.getMessage()); + } + } + + static void check_equals(Object supposed2be, Object is) { + if (!supposed2be.equals(is)) { + throw new RuntimeException(is + " is supposed to be "+supposed2be); + } + } + + + public static void test () { + p(UnitTest.class); + testErrorFormat(); + testErrorCallback(); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Upgrade.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Upgrade.java new file mode 100644 index 0000000..9af3d4a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Upgrade.java @@ -0,0 +1,27 @@ +package http_parser.lolevel; + +import java.nio.*; +import java.util.*; + +import http_parser.ParserType; + +import static http_parser.lolevel.Util.*; + +public class Upgrade { + static final String upgrade = "GET /demo HTTP/1.1\r\n" + + "Connection: Upgrade\r\n" + + "Upgrade: WebSocket\r\n\r\n" + + "third key data"; + static void test () { + p(Upgrade.class); + HTTPParser parser = new HTTPParser(ParserType.HTTP_REQUEST); + ByteBuffer buf = buffer(upgrade); + + int read = parser.execute(Util.SETTINGS_NULL, buf); + check (63 == read); + String s = str(buf); + check ("third key data".equals(str(buf))); + + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Url.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Url.java new file mode 100644 index 0000000..35469d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Url.java @@ -0,0 +1,127 @@ +package http_parser.lolevel; + +import http_parser.FieldData; +import http_parser.HTTPParserUrl; + +import static http_parser.HTTPParserUrl.*; +import static http_parser.lolevel.HTTPParser.*; + +/** + */ +public class Url { + + public static Url[] URL_TESTS = new Url[]{ + new Url("proxy request", "http://hostname/", false, + new HTTPParserUrl( + (1 << UrlFields.UF_SCHEMA.getIndex()) | (1 << UrlFields.UF_HOST.getIndex()) | (1 << UrlFields.UF_PATH.getIndex()), + 0, + new FieldData[]{ + new FieldData(0,4), + new FieldData(7,8), + new FieldData(0,0), + new FieldData(15,1), + new FieldData(0,0), + new FieldData(0,0) + }), + 0), + new Url("CONNECT request", "hostname:443", true, + new HTTPParserUrl( + (1 << UrlFields.UF_HOST.getIndex()) | (1 << UrlFields.UF_PORT.getIndex()), + 443, + new FieldData[]{ + new FieldData(0,0), + new FieldData(0,8), + new FieldData(9,3), + new FieldData(0,0), + new FieldData(0,0), + new FieldData(0,0) + }), + 0), + new Url("proxy ipv6 request", "http://[1:2::3:4]/", false, + new HTTPParserUrl( + (1 << UrlFields.UF_SCHEMA.getIndex()) | (1 << UrlFields.UF_HOST.getIndex()) | (1 << UrlFields.UF_PATH.getIndex()), + 0, + new FieldData[]{ + new FieldData(0,4), + new FieldData(8,8), + new FieldData(0,0), + new FieldData(17,1), + new FieldData(0,0), + new FieldData(0,0) + }), + 0), + new Url("CONNECT ipv6 address", "[1:2::3:4]:443", true, + new HTTPParserUrl( + (1 << UrlFields.UF_HOST.getIndex()) | (1 << UrlFields.UF_PORT.getIndex()), + 443, + new FieldData[]{ + new FieldData(0,0), + new FieldData(1,8), + new FieldData(11,3), + new FieldData(0,0), + new FieldData(0,0), + new FieldData(0,0) + }), + 0), + new Url("extra ? in query string", + "http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css,fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css,fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css", + false, + new HTTPParserUrl( + (1 << UrlFields.UF_SCHEMA.getIndex()) | + (1 << UrlFields.UF_HOST.getIndex()) | + (1 << UrlFields.UF_PATH.getIndex()) | + (1 << UrlFields.UF_QUERY.getIndex()), + 0, + new FieldData[]{ + new FieldData(0,4), + new FieldData(7,10), + new FieldData(0,0), + new FieldData(17,12), + new FieldData(30,187), + new FieldData(0,0) + }), + 0), + new Url("proxy empty host", + "http://:443/", + false, + null, + 1), + new Url("proxy empty port", + "http://hostname:/", + false, + null, + 1), + new Url("CONNECT empty host", + ":443", + true, + null, + 1), + new Url("CONNECT empty port", + "hostname:", + true, + null, + 1), + new Url("CONNECT with extra bits", + "hostname:443/", + true, + null, + 1), + + }; + + String name; + String url; + boolean is_connect; + HTTPParserUrl u; + int rv; + + public Url(String name, String url, boolean is_connect, HTTPParserUrl u, int rv) { + this.name = name; + this.url = url; + this.is_connect = is_connect; + this.u = u; + this.rv = rv; + } + + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Util.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Util.java new file mode 100644 index 0000000..c73d9e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Util.java @@ -0,0 +1,236 @@ +package http_parser.lolevel; + +import java.nio.*; +import java.util.*; + +import primitive.collection.ByteList; + +import http_parser.*; + +public class Util { + + static final ParserSettings SETTINGS_NULL = new ParserSettings(); + + static String str (ByteBuffer b, int pos, int len) { + byte [] by = new byte[len]; + int saved = b.position(); + b.position(pos); + b.get(by); + b.position(saved); + return new String(by); + } + static String str (ByteBuffer b) { + int len = b.limit() - b.position(); + byte [] by = new byte[len]; + int saved = b.position(); + b.get(by); + b.position(saved); + return new String(by); + } + + static ByteBuffer buffer(String str) { + return ByteBuffer.wrap(str.getBytes()); + } + + static ByteBuffer empty() { + return ByteBuffer.wrap(new byte[0]); + } + + static void check(boolean betterBtrue) { + if (!betterBtrue) { + throw new RuntimeException("!"); + } + } + static void check (int should, int is) { + if (should != is) { + throw new RuntimeException("should be: "+should+" is:"+is); + } + } + + static void test_message(Message mes) { + int raw_len = mes.raw.length; + for (int msg1len = 0; msg1len != raw_len; ++msg1len) { + mes.reset(); + ByteBuffer msg1 = ByteBuffer.wrap(mes.raw, 0, msg1len); + ByteBuffer msg2 = ByteBuffer.wrap(mes.raw, msg1len, mes.raw.length - msg1len); + + HTTPParser parser = new HTTPParser(mes.type); + ParserSettings settings = mes.settings(); + + int read = 0; + if (msg1len !=0) { + read = parser.execute(settings, msg1); + if (mes.upgrade() && parser.upgrade) { + // Messages have a settings() that checks itself... + check(1 == mes.num_called); + continue; + } + check(read == msg1len); + } + + read = parser.execute(settings, msg2); + if (mes.upgrade() && parser.upgrade) { + check(1 == mes.num_called); + continue; + } + + check( mes.raw.length - msg1len, read); + + ByteBuffer empty = Util.empty(); + read = parser.execute(settings, empty); + + if (mes.upgrade() && parser.upgrade) { + check(1 == mes.num_called); + continue; + } + check(empty.position() == empty.limit()); + check(0 == read); + check(1 == mes.num_called); + + } + } + + static void test_multiple3(Message r1, Message r2, Message r3) { + int message_count = 1; + if (!r1.upgrade()) { + message_count++; + if (!r2.upgrade()) { + message_count++; + } + } + boolean has_upgrade = (message_count < 3 || r3.upgrade()); + + ByteList blist = new ByteList(); + blist.addAll(r1.raw); + blist.addAll(r2.raw); + blist.addAll(r3.raw); + + byte [] raw = blist.toArray(); + ByteBuffer buf = ByteBuffer.wrap(raw); + + Util.Settings settings = Util.settings(); + HTTPParser parser = new HTTPParser(r1.type); + + int read = parser.execute(settings, buf); + if (has_upgrade && parser.upgrade) { + raw = upgrade_message_fix(raw, read, r1,r2,r3); + check(settings.numCalled == message_count); + return; + } + + check(read == raw.length); + + buf = Util.empty(); + read = parser.execute(settings, buf); + if (has_upgrade && parser.upgrade) { + check(settings.numCalled == message_count); + return; + } + + check(0 == read); + check(settings.numCalled == message_count); + } + + /* Given a sequence of bytes and the number of these that we were able to + * parse, verify that upgrade bodies are correct. + */ + static byte [] upgrade_message_fix(byte[] body, int nread, Message... msgs) { + int off = 0; + for (Message m : msgs) { + off += m.raw.length; + if (m.upgrade()) { + off -= m.upgrade.length; + // Original C: + // Check the portion of the response after its specified upgrade + // if (!check_str_eq(m, "upgrade", body + off, body + nread)) { + // abort(); + // } + // to me, this seems to be equivalent to comparing off and nread ... + check (off, nread); + + // Original C: + // Fix up the response so that message_eq() will verify the beginning + // of the upgrade */ + // + // *(body + nread + strlen(m->upgrade)) = '\0'; + // This only shortens body so the strlen check passes. + return new byte[off]; + + } + } + return null; + } +//upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { +// va_list ap; +// size_t i; +// size_t off = 0; +// +// va_start(ap, nmsgs); +// +// for (i = 0; i < nmsgs; i++) { +// struct message *m = va_arg(ap, struct message *); +// +// off += strlen(m->raw); +// +// if (m->upgrade) { +// off -= strlen(m->upgrade); +// +// /* Check the portion of the response after its specified upgrade */ +// if (!check_str_eq(m, "upgrade", body + off, body + nread)) { +// abort(); +// } +// +// /* Fix up the response so that message_eq() will verify the beginning +// * of the upgrade */ +// *(body + nread + strlen(m->upgrade)) = '\0'; +// messages[num_messages -1 ].upgrade = body + nread; +// +// va_end(ap); +// return; +// } +// } +// +// va_end(ap); +// printf("\n\n*** Error: expected a message with upgrade ***\n"); +// +// abort(); +//} + static void p (Object o) { + System.out.println(o); + } + + static Settings settings() { + return new Settings(); + } + static Message find(List list, String name) { + for (Message m : list) { + if (name.equals(m.name)) { + return m; + } + } + return null; + } + + static class Settings extends ParserSettings { + public int numCalled; + public int bodyCount; + Settings() { + this.on_message_complete = new HTTPCallback() { + public int cb (HTTPParser parser) { + numCalled++; + return 0; + } + }; + this.on_body = new HTTPDataCallback() { + public int cb (HTTPParser p, ByteBuffer b, int pos, int len) { + bodyCount += len; + return 0; + } + }; + } + + int numCalled () { + return this.numCalled; + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java new file mode 100644 index 0000000..fc8f081 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java @@ -0,0 +1,59 @@ +package http_parser.lolevel; + +import java.nio.*; +import java.util.*; + +import http_parser.ParserType; + +import static http_parser.lolevel.Util.*; + +public class WrongContentLength { + static final String contentLength = "GET / HTTP/1.0\r\n" + + "Content-Length: 5\r\n" + + "\r\n" + + "hello" + + "hello_again"; + static void test () { + p(WrongContentLength.class); + HTTPParser parser = new HTTPParser(ParserType.HTTP_REQUEST); + ByteBuffer buf = buffer(contentLength); + + Settings settings = new Settings(); + + int read = parser.execute(settings, buf); + check (settings.msg_cmplt_called); + check ("invalid method".equals(settings.err)); + + } + public static void main(String [] args) { + test(); + } + + static class Settings extends ParserSettings { + public int bodyCount; + public boolean msg_cmplt_called; + public String err; + Settings () { + this.on_message_complete = new HTTPCallback () { + public int cb (HTTPParser p) { + check (5 == bodyCount); + msg_cmplt_called = true; + return 0; + } + }; + this.on_body = new HTTPDataCallback() { + public int cb (HTTPParser p, ByteBuffer b, int pos, int len) { + bodyCount += len; + check ("hello".equals(str(b, pos, len))); + return 0; + } + }; + this.on_error = new HTTPErrorCallback() { + public void cb (HTTPParser p, String mes, ByteBuffer b, int i) { + err = mes; + } + }; + } + } + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/test.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/test.c new file mode 100644 index 0000000..3840747 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/test.c @@ -0,0 +1,3425 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "http_parser.h" +#include +#include +#include +#include /* rand */ +#include +#include + +#undef TRUE +#define TRUE 1 +#undef FALSE +#define FALSE 0 + +#define MAX_HEADERS 13 +#define MAX_ELEMENT_SIZE 2048 + +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + +static http_parser *parser; + +struct message { + const char *name; // for debugging purposes + const char *raw; + enum http_parser_type type; + enum http_method method; + int status_code; + char request_path[MAX_ELEMENT_SIZE]; + char request_url[MAX_ELEMENT_SIZE]; + char fragment[MAX_ELEMENT_SIZE]; + char query_string[MAX_ELEMENT_SIZE]; + char body[MAX_ELEMENT_SIZE]; + size_t body_size; + const char *host; + const char *userinfo; + uint16_t port; + int num_headers; + enum { NONE=0, FIELD, VALUE } last_header_element; + char headers [MAX_HEADERS][2][MAX_ELEMENT_SIZE]; + int should_keep_alive; + + const char *upgrade; // upgraded body + + unsigned short http_major; + unsigned short http_minor; + + int message_begin_cb_called; + int headers_complete_cb_called; + int message_complete_cb_called; + int message_complete_on_eof; + int body_is_final; +}; + +static int currently_parsing_eof; + +static struct message messages[5]; +static int num_messages; +static http_parser_settings *current_pause_parser; + +/* * R E Q U E S T S * */ +const struct message requests[] = +#define CURL_GET 0 +{ {.name= "curl get" + ,.type= HTTP_REQUEST + ,.raw= "GET /test HTTP/1.1\r\n" + "User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\n" + "Host: 0.0.0.0=5000\r\n" + "Accept: */*\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 3 + ,.headers= + { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" } + , { "Host", "0.0.0.0=5000" } + , { "Accept", "*/*" } + } + ,.body= "" + } + +#define FIREFOX_GET 1 +, {.name= "firefox get" + ,.type= HTTP_REQUEST + ,.raw= "GET /favicon.ico HTTP/1.1\r\n" + "Host: 0.0.0.0=5000\r\n" + "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\n" + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" + "Accept-Language: en-us,en;q=0.5\r\n" + "Accept-Encoding: gzip,deflate\r\n" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" + "Keep-Alive: 300\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/favicon.ico" + ,.request_url= "/favicon.ico" + ,.num_headers= 8 + ,.headers= + { { "Host", "0.0.0.0=5000" } + , { "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0" } + , { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" } + , { "Accept-Language", "en-us,en;q=0.5" } + , { "Accept-Encoding", "gzip,deflate" } + , { "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7" } + , { "Keep-Alive", "300" } + , { "Connection", "keep-alive" } + } + ,.body= "" + } + +#define DUMBFUCK 2 +, {.name= "dumbfuck" + ,.type= HTTP_REQUEST + ,.raw= "GET /dumbfuck HTTP/1.1\r\n" + "aaaaaaaaaaaaa:++++++++++\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/dumbfuck" + ,.request_url= "/dumbfuck" + ,.num_headers= 1 + ,.headers= + { { "aaaaaaaaaaaaa", "++++++++++" } + } + ,.body= "" + } + +#define FRAGMENT_IN_URI 3 +, {.name= "fragment in url" + ,.type= HTTP_REQUEST + ,.raw= "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "page=1" + ,.fragment= "posts-17408" + ,.request_path= "/forums/1/topics/2375" + /* XXX request url does include fragment? */ + ,.request_url= "/forums/1/topics/2375?page=1#posts-17408" + ,.num_headers= 0 + ,.body= "" + } + +#define GET_NO_HEADERS_NO_BODY 4 +, {.name= "get no headers no body" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_no_headers_no_body/world HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE /* would need Connection: close */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_no_headers_no_body/world" + ,.request_url= "/get_no_headers_no_body/world" + ,.num_headers= 0 + ,.body= "" + } + +#define GET_ONE_HEADER_NO_BODY 5 +, {.name= "get one header no body" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_one_header_no_body HTTP/1.1\r\n" + "Accept: */*\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE /* would need Connection: close */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_one_header_no_body" + ,.request_url= "/get_one_header_no_body" + ,.num_headers= 1 + ,.headers= + { { "Accept" , "*/*" } + } + ,.body= "" + } + +#define GET_FUNKY_CONTENT_LENGTH 6 +, {.name= "get funky content length body hello" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_funky_content_length_body_hello HTTP/1.0\r\n" + "conTENT-Length: 5\r\n" + "\r\n" + "HELLO" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_funky_content_length_body_hello" + ,.request_url= "/get_funky_content_length_body_hello" + ,.num_headers= 1 + ,.headers= + { { "conTENT-Length" , "5" } + } + ,.body= "HELLO" + } + +#define POST_IDENTITY_BODY_WORLD 7 +, {.name= "post identity body world" + ,.type= HTTP_REQUEST + ,.raw= "POST /post_identity_body_world?q=search#hey HTTP/1.1\r\n" + "Accept: */*\r\n" + "Transfer-Encoding: identity\r\n" + "Content-Length: 5\r\n" + "\r\n" + "World" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "q=search" + ,.fragment= "hey" + ,.request_path= "/post_identity_body_world" + ,.request_url= "/post_identity_body_world?q=search#hey" + ,.num_headers= 3 + ,.headers= + { { "Accept", "*/*" } + , { "Transfer-Encoding", "identity" } + , { "Content-Length", "5" } + } + ,.body= "World" + } + +#define POST_CHUNKED_ALL_YOUR_BASE 8 +, {.name= "post - chunked body: all your base are belong to us" + ,.type= HTTP_REQUEST + ,.raw= "POST /post_chunked_all_your_base HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "1e\r\nall your base are belong to us\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/post_chunked_all_your_base" + ,.request_url= "/post_chunked_all_your_base" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding" , "chunked" } + } + ,.body= "all your base are belong to us" + } + +#define TWO_CHUNKS_MULT_ZERO_END 9 +, {.name= "two chunks ; triple zero ending" + ,.type= HTTP_REQUEST + ,.raw= "POST /two_chunks_mult_zero_end HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5\r\nhello\r\n" + "6\r\n world\r\n" + "000\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/two_chunks_mult_zero_end" + ,.request_url= "/two_chunks_mult_zero_end" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body= "hello world" + } + +#define CHUNKED_W_TRAILING_HEADERS 10 +, {.name= "chunked with trailing headers. blech." + ,.type= HTTP_REQUEST + ,.raw= "POST /chunked_w_trailing_headers HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5\r\nhello\r\n" + "6\r\n world\r\n" + "0\r\n" + "Vary: *\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/chunked_w_trailing_headers" + ,.request_url= "/chunked_w_trailing_headers" + ,.num_headers= 3 + ,.headers= + { { "Transfer-Encoding", "chunked" } + , { "Vary", "*" } + , { "Content-Type", "text/plain" } + } + ,.body= "hello world" + } + +#define CHUNKED_W_BULLSHIT_AFTER_LENGTH 11 +, {.name= "with bullshit after the length" + ,.type= HTTP_REQUEST + ,.raw= "POST /chunked_w_bullshit_after_length HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5; ihatew3;whatthefuck=aretheseparametersfor\r\nhello\r\n" + "6; blahblah; blah\r\n world\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/chunked_w_bullshit_after_length" + ,.request_url= "/chunked_w_bullshit_after_length" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body= "hello world" + } + +#define WITH_QUOTES 12 +, {.name= "with quotes" + ,.type= HTTP_REQUEST + ,.raw= "GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "foo=\"bar\"" + ,.fragment= "" + ,.request_path= "/with_\"stupid\"_quotes" + ,.request_url= "/with_\"stupid\"_quotes?foo=\"bar\"" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define APACHEBENCH_GET 13 +/* The server receiving this request SHOULD NOT wait for EOF + * to know that content-length == 0. + * How to represent this in a unit test? message_complete_on_eof + * Compare with NO_CONTENT_LENGTH_RESPONSE. + */ +, {.name = "apachebench get" + ,.type= HTTP_REQUEST + ,.raw= "GET /test HTTP/1.0\r\n" + "Host: 0.0.0.0:5000\r\n" + "User-Agent: ApacheBench/2.3\r\n" + "Accept: */*\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 3 + ,.headers= { { "Host", "0.0.0.0:5000" } + , { "User-Agent", "ApacheBench/2.3" } + , { "Accept", "*/*" } + } + ,.body= "" + } + +#define QUERY_URL_WITH_QUESTION_MARK_GET 14 +/* Some clients include '?' characters in query strings. + */ +, {.name = "query url with question mark" + ,.type= HTTP_REQUEST + ,.raw= "GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "foo=bar?baz" + ,.fragment= "" + ,.request_path= "/test.cgi" + ,.request_url= "/test.cgi?foo=bar?baz" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define PREFIX_NEWLINE_GET 15 +/* Some clients, especially after a POST in a keep-alive connection, + * will send an extra CRLF before the next request + */ +, {.name = "newline prefix get" + ,.type= HTTP_REQUEST + ,.raw= "\r\nGET /test HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define UPGRADE_REQUEST 16 +, {.name = "upgrade request" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: Upgrade\r\n" + "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" + "Sec-WebSocket-Protocol: sample\r\n" + "Upgrade: WebSocket\r\n" + "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" + "Origin: http://example.com\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 7 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Host", "example.com" } + , { "Connection", "Upgrade" } + , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } + , { "Sec-WebSocket-Protocol", "sample" } + , { "Upgrade", "WebSocket" } + , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } + , { "Origin", "http://example.com" } + } + ,.body= "" + } + +#define CONNECT_REQUEST 17 +, {.name = "connect request" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + "some data\r\n" + "and yet even more data" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "0-home0.netscape.com:443" + ,.num_headers= 2 + ,.upgrade="some data\r\nand yet even more data" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } + +#define REPORT_REQ 18 +, {.name= "report request" + ,.type= HTTP_REQUEST + ,.raw= "REPORT /test HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_REPORT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define NO_HTTP_VERSION 19 +, {.name= "request with no http version" + ,.type= HTTP_REQUEST + ,.raw= "GET /\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 0 + ,.http_minor= 9 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define MSEARCH_REQ 20 +, {.name= "m-search request" + ,.type= HTTP_REQUEST + ,.raw= "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "MAN: \"ssdp:discover\"\r\n" + "ST: \"ssdp:all\"\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_MSEARCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "*" + ,.request_url= "*" + ,.num_headers= 3 + ,.headers= { { "HOST", "239.255.255.250:1900" } + , { "MAN", "\"ssdp:discover\"" } + , { "ST", "\"ssdp:all\"" } + } + ,.body= "" + } + +#define LINE_FOLDING_IN_HEADER 21 +, {.name= "line folding in header value" + ,.type= HTTP_REQUEST + ,.raw= "GET / HTTP/1.1\r\n" + "Line1: abc\r\n" + "\tdef\r\n" + " ghi\r\n" + "\t\tjkl\r\n" + " mno \r\n" + "\t \tqrs\r\n" + "Line2: \t line2\t\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 2 + ,.headers= { { "Line1", "abcdefghijklmno qrs" } + , { "Line2", "line2\t" } + } + ,.body= "" + } + + +#define QUERY_TERMINATED_HOST 22 +, {.name= "host terminated by a query string" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "hail=all" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org?hail=all" + ,.host= "hypnotoad.org" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define QUERY_TERMINATED_HOSTPORT 23 +, {.name= "host:port terminated by a query string" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "hail=all" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org:1234?hail=all" + ,.host= "hypnotoad.org" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define SPACE_TERMINATED_HOSTPORT 24 +, {.name= "host:port terminated by a space" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org:1234 HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org:1234" + ,.host= "hypnotoad.org" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define PATCH_REQ 25 +, {.name = "PATCH request" + ,.type= HTTP_REQUEST + ,.raw= "PATCH /file.txt HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/example\r\n" + "If-Match: \"e0023aa4e\"\r\n" + "Content-Length: 10\r\n" + "\r\n" + "cccccccccc" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_PATCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/file.txt" + ,.request_url= "/file.txt" + ,.num_headers= 4 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/example" } + , { "If-Match", "\"e0023aa4e\"" } + , { "Content-Length", "10" } + } + ,.body= "cccccccccc" + } + +#define CONNECT_CAPS_REQUEST 26 +, {.name = "connect caps request" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "HOME0.NETSCAPE.COM:443" + ,.num_headers= 2 + ,.upgrade="" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } + +#if !HTTP_PARSER_STRICT +#define UTF8_PATH_REQ 27 +, {.name= "utf-8 path request" + ,.type= HTTP_REQUEST + ,.raw= "GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\n" + "Host: github.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "q=1" + ,.fragment= "narf" + ,.request_path= "/δ¶/δt/pope" + ,.request_url= "/δ¶/δt/pope?q=1#narf" + ,.num_headers= 1 + ,.headers= { {"Host", "github.com" } + } + ,.body= "" + } + +#define HOSTNAME_UNDERSCORE 28 +, {.name = "hostname underscore" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT home_0.netscape.com:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "home_0.netscape.com:443" + ,.num_headers= 2 + ,.upgrade="" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } +#endif /* !HTTP_PARSER_STRICT */ + +/* see https://github.com/ry/http-parser/issues/47 */ +#define EAT_TRAILING_CRLF_NO_CONNECTION_CLOSE 29 +, {.name = "eat CRLF between requests, no \"Connection: close\" header" + ,.raw= "POST / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 4\r\n" + "\r\n" + "q=42\r\n" /* note the trailing CRLF */ + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 3 + ,.upgrade= 0 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/x-www-form-urlencoded" } + , { "Content-Length", "4" } + } + ,.body= "q=42" + } + +/* see https://github.com/ry/http-parser/issues/47 */ +#define EAT_TRAILING_CRLF_WITH_CONNECTION_CLOSE 30 +, {.name = "eat CRLF between requests even if \"Connection: close\" is set" + ,.raw= "POST / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 4\r\n" + "Connection: close\r\n" + "\r\n" + "q=42\r\n" /* note the trailing CRLF */ + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE /* input buffer isn't empty when on_message_complete is called */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 4 + ,.upgrade= 0 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/x-www-form-urlencoded" } + , { "Content-Length", "4" } + , { "Connection", "close" } + } + ,.body= "q=42" + } + +#define PURGE_REQ 31 +, {.name = "PURGE request" + ,.type= HTTP_REQUEST + ,.raw= "PURGE /file.txt HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_PURGE + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/file.txt" + ,.request_url= "/file.txt" + ,.num_headers= 1 + ,.headers= { { "Host", "www.example.com" } } + ,.body= "" + } + +#define SEARCH_REQ 32 +, {.name = "SEARCH request" + ,.type= HTTP_REQUEST + ,.raw= "SEARCH / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_SEARCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 1 + ,.headers= { { "Host", "www.example.com" } } + ,.body= "" + } + +#define PROXY_WITH_BASIC_AUTH 33 +, {.name= "host:port and basic_auth" + ,.type= HTTP_REQUEST + ,.raw= "GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.fragment= "" + ,.request_path= "/toto" + ,.request_url= "http://a%12:b!&*$@hypnotoad.org:1234/toto" + ,.host= "hypnotoad.org" + ,.userinfo= "a%12:b!&*$" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + + +, {.name= NULL } /* sentinel */ +}; + +/* * R E S P O N S E S * */ +const struct message responses[] = +#define GOOGLE_301 0 +{ {.name= "google 301" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301 Moved Permanently\r\n" + "Location: http://www.google.com/\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Date: Sun, 26 Apr 2009 11:11:49 GMT\r\n" + "Expires: Tue, 26 May 2009 11:11:49 GMT\r\n" + "X-$PrototypeBI-Version: 1.6.0.3\r\n" /* $ char in header field */ + "Cache-Control: public, max-age=2592000\r\n" + "Server: gws\r\n" + "Content-Length: 219 \r\n" + "\r\n" + "\n" + "301 Moved\n" + "

301 Moved

\n" + "The document has moved\n" + "here.\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 301 + ,.num_headers= 8 + ,.headers= + { { "Location", "http://www.google.com/" } + , { "Content-Type", "text/html; charset=UTF-8" } + , { "Date", "Sun, 26 Apr 2009 11:11:49 GMT" } + , { "Expires", "Tue, 26 May 2009 11:11:49 GMT" } + , { "X-$PrototypeBI-Version", "1.6.0.3" } + , { "Cache-Control", "public, max-age=2592000" } + , { "Server", "gws" } + , { "Content-Length", "219 " } + } + ,.body= "\n" + "301 Moved\n" + "

301 Moved

\n" + "The document has moved\n" + "here.\r\n" + "\r\n" + } + +#define NO_CONTENT_LENGTH_RESPONSE 1 +/* The client should wait for the server's EOF. That is, when content-length + * is not specified, and "Connection: close", the end of body is specified + * by the EOF. + * Compare with APACHEBENCH_GET + */ +, {.name= "no content-length response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Date: Tue, 04 Aug 2009 07:59:32 GMT\r\n" + "Server: Apache\r\n" + "X-Powered-By: Servlet/2.5 JSP/2.1\r\n" + "Content-Type: text/xml; charset=utf-8\r\n" + "Connection: close\r\n" + "\r\n" + "\n" + "\n" + " \n" + " \n" + " SOAP-ENV:Client\n" + " Client Error\n" + " \n" + " \n" + "" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 5 + ,.headers= + { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" } + , { "Server", "Apache" } + , { "X-Powered-By", "Servlet/2.5 JSP/2.1" } + , { "Content-Type", "text/xml; charset=utf-8" } + , { "Connection", "close" } + } + ,.body= "\n" + "\n" + " \n" + " \n" + " SOAP-ENV:Client\n" + " Client Error\n" + " \n" + " \n" + "" + } + +#define NO_HEADERS_NO_BODY_404 2 +, {.name= "404 no headers no body" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 404 Not Found\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 404 + ,.num_headers= 0 + ,.headers= {} + ,.body_size= 0 + ,.body= "" + } + +#define NO_REASON_PHRASE 3 +, {.name= "301 no response phrase" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301\r\n\r\n" + ,.should_keep_alive = FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 301 + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define TRAILING_SPACE_ON_CHUNKED_BODY 4 +, {.name="200 trailing space on chunked body" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "25 \r\n" + "This is the data in the first chunk\r\n" + "\r\n" + "1C\r\n" + "and this is the second one\r\n" + "\r\n" + "0 \r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 2 + ,.headers= + { {"Content-Type", "text/plain" } + , {"Transfer-Encoding", "chunked" } + } + ,.body_size = 37+28 + ,.body = + "This is the data in the first chunk\r\n" + "and this is the second one\r\n" + + } + +#define NO_CARRIAGE_RET 5 +, {.name="no carriage ret" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\n" + "Content-Type: text/html; charset=utf-8\n" + "Connection: close\n" + "\n" + "these headers are from http://news.ycombinator.com/" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 2 + ,.headers= + { {"Content-Type", "text/html; charset=utf-8" } + , {"Connection", "close" } + } + ,.body= "these headers are from http://news.ycombinator.com/" + } + +#define PROXY_CONNECTION 6 +, {.name="proxy connection" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Content-Length: 11\r\n" + "Proxy-Connection: close\r\n" + "Date: Thu, 31 Dec 2009 20:55:48 +0000\r\n" + "\r\n" + "hello world" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 4 + ,.headers= + { {"Content-Type", "text/html; charset=UTF-8" } + , {"Content-Length", "11" } + , {"Proxy-Connection", "close" } + , {"Date", "Thu, 31 Dec 2009 20:55:48 +0000"} + } + ,.body= "hello world" + } + +#define UNDERSTORE_HEADER_KEY 7 + // shown by + // curl -o /dev/null -v "http://ad.doubleclick.net/pfadx/DARTSHELLCONFIGXML;dcmt=text/xml;" +, {.name="underscore header key" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Server: DCLK-AdSvr\r\n" + "Content-Type: text/xml\r\n" + "Content-Length: 0\r\n" + "DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 4 + ,.headers= + { {"Server", "DCLK-AdSvr" } + , {"Content-Type", "text/xml" } + , {"Content-Length", "0" } + , {"DCLK_imp", "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o" } + } + ,.body= "" + } + +#define BONJOUR_MADAME_FR 8 +/* The client should not merge two headers fields when the first one doesn't + * have a value. + */ +, {.name= "bonjourmadame.fr" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 301 Moved Permanently\r\n" + "Date: Thu, 03 Jun 2010 09:56:32 GMT\r\n" + "Server: Apache/2.2.3 (Red Hat)\r\n" + "Cache-Control: public\r\n" + "Pragma: \r\n" + "Location: http://www.bonjourmadame.fr/\r\n" + "Vary: Accept-Encoding\r\n" + "Content-Length: 0\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 301 + ,.num_headers= 9 + ,.headers= + { { "Date", "Thu, 03 Jun 2010 09:56:32 GMT" } + , { "Server", "Apache/2.2.3 (Red Hat)" } + , { "Cache-Control", "public" } + , { "Pragma", "" } + , { "Location", "http://www.bonjourmadame.fr/" } + , { "Vary", "Accept-Encoding" } + , { "Content-Length", "0" } + , { "Content-Type", "text/html; charset=UTF-8" } + , { "Connection", "keep-alive" } + } + ,.body= "" + } + +#define RES_FIELD_UNDERSCORE 9 +/* Should handle spaces in header fields */ +, {.name= "field underscore" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Date: Tue, 28 Sep 2010 01:14:13 GMT\r\n" + "Server: Apache\r\n" + "Cache-Control: no-cache, must-revalidate\r\n" + "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" + ".et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\n" + "Vary: Accept-Encoding\r\n" + "_eep-Alive: timeout=45\r\n" /* semantic value ignored */ + "_onnection: Keep-Alive\r\n" /* semantic value ignored */ + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/html\r\n" + "Connection: close\r\n" + "\r\n" + "0\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 11 + ,.headers= + { { "Date", "Tue, 28 Sep 2010 01:14:13 GMT" } + , { "Server", "Apache" } + , { "Cache-Control", "no-cache, must-revalidate" } + , { "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" } + , { ".et-Cookie", "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com" } + , { "Vary", "Accept-Encoding" } + , { "_eep-Alive", "timeout=45" } + , { "_onnection", "Keep-Alive" } + , { "Transfer-Encoding", "chunked" } + , { "Content-Type", "text/html" } + , { "Connection", "close" } + } + ,.body= "" + } + +#define NON_ASCII_IN_STATUS_LINE 10 +/* Should handle non-ASCII in status line */ +, {.name= "non-ASCII in status line" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 500 Oriëntatieprobleem\r\n" + "Date: Fri, 5 Nov 2010 23:07:12 GMT+2\r\n" + "Content-Length: 0\r\n" + "Connection: close\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 500 + ,.num_headers= 3 + ,.headers= + { { "Date", "Fri, 5 Nov 2010 23:07:12 GMT+2" } + , { "Content-Length", "0" } + , { "Connection", "close" } + } + ,.body= "" + } + +#define HTTP_VERSION_0_9 11 +/* Should handle HTTP/0.9 */ +, {.name= "http version 0.9" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/0.9 200 OK\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 0 + ,.http_minor= 9 + ,.status_code= 200 + ,.num_headers= 0 + ,.headers= + {} + ,.body= "" + } + +#define NO_CONTENT_LENGTH_NO_TRANSFER_ENCODING_RESPONSE 12 +/* The client should wait for the server's EOF. That is, when neither + * content-length nor transfer-encoding is specified, the end of body + * is specified by the EOF. + */ +, {.name= "neither content-length nor transfer-encoding response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "hello world" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 1 + ,.headers= + { { "Content-Type", "text/plain" } + } + ,.body= "hello world" + } + +#define NO_BODY_HTTP10_KA_200 13 +, {.name= "HTTP/1.0 with keep-alive and EOF-terminated 200 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 200 OK\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 200 + ,.num_headers= 1 + ,.headers= + { { "Connection", "keep-alive" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP10_KA_204 14 +, {.name= "HTTP/1.0 with keep-alive and a 204 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 204 No content\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 204 + ,.num_headers= 1 + ,.headers= + { { "Connection", "keep-alive" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_200 15 +, {.name= "HTTP/1.1 with an EOF-terminated 200 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 0 + ,.headers={} + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_204 16 +, {.name= "HTTP/1.1 with a 204 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 204 No content\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 204 + ,.num_headers= 0 + ,.headers={} + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_NOKA_204 17 +, {.name= "HTTP/1.1 with a 204 status and keep-alive disabled" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 204 No content\r\n" + "Connection: close\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 204 + ,.num_headers= 1 + ,.headers= + { { "Connection", "close" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_CHUNKED_200 18 +, {.name= "HTTP/1.1 with chunked endocing and a 200 response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body_size= 0 + ,.body= "" + } + +#if !HTTP_PARSER_STRICT +#define SPACE_IN_FIELD_RES 19 +/* Should handle spaces in header fields */ +, {.name= "field space" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Server: Microsoft-IIS/6.0\r\n" + "X-Powered-By: ASP.NET\r\n" + "en-US Content-Type: text/xml\r\n" /* this is the problem */ + "Content-Type: text/xml\r\n" + "Content-Length: 16\r\n" + "Date: Fri, 23 Jul 2010 18:45:38 GMT\r\n" + "Connection: keep-alive\r\n" + "\r\n" + "hello" /* fake body */ + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.num_headers= 7 + ,.headers= + { { "Server", "Microsoft-IIS/6.0" } + , { "X-Powered-By", "ASP.NET" } + , { "en-US Content-Type", "text/xml" } + , { "Content-Type", "text/xml" } + , { "Content-Length", "16" } + , { "Date", "Fri, 23 Jul 2010 18:45:38 GMT" } + , { "Connection", "keep-alive" } + } + ,.body= "hello" + } +#endif /* !HTTP_PARSER_STRICT */ + +, {.name= NULL } /* sentinel */ +}; + +/* strnlen() is a POSIX.2008 addition. Can't rely on it being available so + * define it ourselves. + */ +size_t +strnlen(const char *s, size_t maxlen) +{ + const char *p; + + p = memchr(s, '\0', maxlen); + if (p == NULL) + return maxlen; + + return p - s; +} + +size_t +strlncat(char *dst, size_t len, const char *src, size_t n) +{ + size_t slen; + size_t dlen; + size_t rlen; + size_t ncpy; + + slen = strnlen(src, n); + dlen = strnlen(dst, len); + + if (dlen < len) { + rlen = len - dlen; + ncpy = slen < rlen ? slen : (rlen - 1); + memcpy(dst + dlen, src, ncpy); + dst[dlen + ncpy] = '\0'; + } + + assert(len > slen + dlen); + return slen + dlen; +} + +size_t +strlcat(char *dst, const char *src, size_t len) +{ + return strlncat(dst, len, src, (size_t) -1); +} + +size_t +strlncpy(char *dst, size_t len, const char *src, size_t n) +{ + size_t slen; + size_t ncpy; + + slen = strnlen(src, n); + + if (len > 0) { + ncpy = slen < len ? slen : (len - 1); + memcpy(dst, src, ncpy); + dst[ncpy] = '\0'; + } + + assert(len > slen); + return slen; +} + +size_t +strlcpy(char *dst, const char *src, size_t len) +{ + return strlncpy(dst, len, src, (size_t) -1); +} + +int +request_url_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + strlncat(messages[num_messages].request_url, + sizeof(messages[num_messages].request_url), + buf, + len); + return 0; +} + +int +status_complete_cb (http_parser *p) { + assert(p == parser); + p->data++; + return 0; +} + +int +header_field_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + struct message *m = &messages[num_messages]; + + if (m->last_header_element != FIELD) + m->num_headers++; + + strlncat(m->headers[m->num_headers-1][0], + sizeof(m->headers[m->num_headers-1][0]), + buf, + len); + + m->last_header_element = FIELD; + + return 0; +} + +int +header_value_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + struct message *m = &messages[num_messages]; + + strlncat(m->headers[m->num_headers-1][1], + sizeof(m->headers[m->num_headers-1][1]), + buf, + len); + + m->last_header_element = VALUE; + + return 0; +} + +void +check_body_is_final (const http_parser *p) +{ + if (messages[num_messages].body_is_final) { + fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " + "on last on_body callback call " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + messages[num_messages].body_is_final = http_body_is_final(p); +} + +int +body_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + strlncat(messages[num_messages].body, + sizeof(messages[num_messages].body), + buf, + len); + messages[num_messages].body_size += len; + check_body_is_final(p); + // printf("body_cb: '%s'\n", requests[num_messages].body); + return 0; +} + +int +count_body_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + assert(buf); + messages[num_messages].body_size += len; + check_body_is_final(p); + return 0; +} + +int +message_begin_cb (http_parser *p) +{ + assert(p == parser); + messages[num_messages].message_begin_cb_called = TRUE; + return 0; +} + +int +headers_complete_cb (http_parser *p) +{ + assert(p == parser); + messages[num_messages].method = parser->method; + messages[num_messages].status_code = parser->status_code; + messages[num_messages].http_major = parser->http_major; + messages[num_messages].http_minor = parser->http_minor; + messages[num_messages].headers_complete_cb_called = TRUE; + messages[num_messages].should_keep_alive = http_should_keep_alive(parser); + return 0; +} + +int +message_complete_cb (http_parser *p) +{ + assert(p == parser); + if (messages[num_messages].should_keep_alive != http_should_keep_alive(parser)) + { + fprintf(stderr, "\n\n *** Error http_should_keep_alive() should have same " + "value in both on_message_complete and on_headers_complete " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + + if (messages[num_messages].body_size && + http_body_is_final(p) && + !messages[num_messages].body_is_final) + { + fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " + "on last on_body callback call " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + + messages[num_messages].message_complete_cb_called = TRUE; + + messages[num_messages].message_complete_on_eof = currently_parsing_eof; + + num_messages++; + return 0; +} + +/* These dontcall_* callbacks exist so that we can verify that when we're + * paused, no additional callbacks are invoked */ +int +dontcall_message_begin_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_message_begin() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_header_field_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_header_field() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_header_value_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_header_value() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_request_url_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_request_url() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_body_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_body_cb() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_headers_complete_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_headers_complete() called on paused " + "parser ***\n\n"); + abort(); +} + +int +dontcall_message_complete_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_message_complete() called on paused " + "parser ***\n\n"); + abort(); +} + +static http_parser_settings settings_dontcall = + {.on_message_begin = dontcall_message_begin_cb + ,.on_header_field = dontcall_header_field_cb + ,.on_header_value = dontcall_header_value_cb + ,.on_url = dontcall_request_url_cb + ,.on_body = dontcall_body_cb + ,.on_headers_complete = dontcall_headers_complete_cb + ,.on_message_complete = dontcall_message_complete_cb + }; + +/* These pause_* callbacks always pause the parser and just invoke the regular + * callback that tracks content. Before returning, we overwrite the parser + * settings to point to the _dontcall variety so that we can verify that + * the pause actually did, you know, pause. */ +int +pause_message_begin_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return message_begin_cb(p); +} + +int +pause_header_field_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return header_field_cb(p, buf, len); +} + +int +pause_header_value_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return header_value_cb(p, buf, len); +} + +int +pause_request_url_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return request_url_cb(p, buf, len); +} + +int +pause_body_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return body_cb(p, buf, len); +} + +int +pause_headers_complete_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return headers_complete_cb(p); +} + +int +pause_message_complete_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return message_complete_cb(p); +} + +static http_parser_settings settings_pause = + {.on_message_begin = pause_message_begin_cb + ,.on_header_field = pause_header_field_cb + ,.on_header_value = pause_header_value_cb + ,.on_url = pause_request_url_cb + ,.on_body = pause_body_cb + ,.on_headers_complete = pause_headers_complete_cb + ,.on_message_complete = pause_message_complete_cb + }; + +static http_parser_settings settings = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_body = body_cb + ,.on_headers_complete = headers_complete_cb + ,.on_message_complete = message_complete_cb + }; + +static http_parser_settings settings_count_body = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_body = count_body_cb + ,.on_headers_complete = headers_complete_cb + ,.on_message_complete = message_complete_cb + }; + +static http_parser_settings settings_null = + {.on_message_begin = 0 + ,.on_header_field = 0 + ,.on_header_value = 0 + ,.on_url = 0 + ,.on_body = 0 + ,.on_headers_complete = 0 + ,.on_message_complete = 0 + }; + +void +parser_init (enum http_parser_type type) +{ + num_messages = 0; + + assert(parser == NULL); + + parser = malloc(sizeof(http_parser)); + + http_parser_init(parser, type); + + memset(&messages, 0, sizeof messages); + +} + +void +parser_free () +{ + assert(parser); + free(parser); + parser = NULL; +} + +size_t parse (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings, buf, len); + return nparsed; +} + +size_t parse_count_body (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings_count_body, buf, len); + return nparsed; +} + +size_t parse_pause (const char *buf, size_t len) +{ + size_t nparsed; + http_parser_settings s = settings_pause; + + currently_parsing_eof = (len == 0); + current_pause_parser = &s; + nparsed = http_parser_execute(parser, current_pause_parser, buf, len); + return nparsed; +} + +static inline int +check_str_eq (const struct message *m, + const char *prop, + const char *expected, + const char *found) { + if ((expected == NULL) != (found == NULL)) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected %s\n", (expected == NULL) ? "NULL" : expected); + printf(" found %s\n", (found == NULL) ? "NULL" : found); + return 0; + } + if (expected != NULL && 0 != strcmp(expected, found)) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected '%s'\n", expected); + printf(" found '%s'\n", found); + return 0; + } + return 1; +} + +static inline int +check_num_eq (const struct message *m, + const char *prop, + int expected, + int found) { + if (expected != found) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected %d\n", expected); + printf(" found %d\n", found); + return 0; + } + return 1; +} + +#define MESSAGE_CHECK_STR_EQ(expected, found, prop) \ + if (!check_str_eq(expected, #prop, expected->prop, found->prop)) return 0 + +#define MESSAGE_CHECK_NUM_EQ(expected, found, prop) \ + if (!check_num_eq(expected, #prop, expected->prop, found->prop)) return 0 + +#define MESSAGE_CHECK_URL_EQ(u, expected, found, prop, fn) \ +do { \ + char ubuf[256]; \ + \ + if ((u)->field_set & (1 << (fn))) { \ + memcpy(ubuf, (found)->request_url + (u)->field_data[(fn)].off, \ + (u)->field_data[(fn)].len); \ + ubuf[(u)->field_data[(fn)].len] = '\0'; \ + } else { \ + ubuf[0] = '\0'; \ + } \ + \ + check_str_eq(expected, #prop, expected->prop, ubuf); \ +} while(0) + +int +message_eq (int index, const struct message *expected) +{ + int i; + struct message *m = &messages[index]; + + MESSAGE_CHECK_NUM_EQ(expected, m, http_major); + MESSAGE_CHECK_NUM_EQ(expected, m, http_minor); + + if (expected->type == HTTP_REQUEST) { + MESSAGE_CHECK_NUM_EQ(expected, m, method); + } else { + MESSAGE_CHECK_NUM_EQ(expected, m, status_code); + } + + MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); + MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof); + + assert(m->message_begin_cb_called); + assert(m->headers_complete_cb_called); + assert(m->message_complete_cb_called); + + + MESSAGE_CHECK_STR_EQ(expected, m, request_url); + + /* Check URL components; we can't do this w/ CONNECT since it doesn't + * send us a well-formed URL. + */ + if (*m->request_url && m->method != HTTP_CONNECT) { + struct http_parser_url u; + + if (http_parser_parse_url(m->request_url, strlen(m->request_url), 0, &u)) { + fprintf(stderr, "\n\n*** failed to parse URL %s ***\n\n", + m->request_url); + abort(); + } + + if (expected->host) { + MESSAGE_CHECK_URL_EQ(&u, expected, m, host, UF_HOST); + } + + if (expected->userinfo) { + MESSAGE_CHECK_URL_EQ(&u, expected, m, userinfo, UF_USERINFO); + } + + m->port = (u.field_set & (1 << UF_PORT)) ? + u.port : 0; + + MESSAGE_CHECK_URL_EQ(&u, expected, m, query_string, UF_QUERY); + MESSAGE_CHECK_URL_EQ(&u, expected, m, fragment, UF_FRAGMENT); + MESSAGE_CHECK_URL_EQ(&u, expected, m, request_path, UF_PATH); + MESSAGE_CHECK_NUM_EQ(expected, m, port); + } + + if (expected->body_size) { + MESSAGE_CHECK_NUM_EQ(expected, m, body_size); + } else { + MESSAGE_CHECK_STR_EQ(expected, m, body); + } + + MESSAGE_CHECK_NUM_EQ(expected, m, num_headers); + + int r; + for (i = 0; i < m->num_headers; i++) { + r = check_str_eq(expected, "header field", expected->headers[i][0], m->headers[i][0]); + if (!r) return 0; + r = check_str_eq(expected, "header value", expected->headers[i][1], m->headers[i][1]); + if (!r) return 0; + } + + MESSAGE_CHECK_STR_EQ(expected, m, upgrade); + + return 1; +} + +/* Given a sequence of varargs messages, return the number of them that the + * parser should successfully parse, taking into account that upgraded + * messages prevent all subsequent messages from being parsed. + */ +size_t +count_parsed_messages(const size_t nmsgs, ...) { + size_t i; + va_list ap; + + va_start(ap, nmsgs); + + for (i = 0; i < nmsgs; i++) { + struct message *m = va_arg(ap, struct message *); + + if (m->upgrade) { + va_end(ap); + return i + 1; + } + } + + va_end(ap); + return nmsgs; +} + +/* Given a sequence of bytes and the number of these that we were able to + * parse, verify that upgrade bodies are correct. + */ +void +upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { + va_list ap; + size_t i; + size_t off = 0; + + va_start(ap, nmsgs); + + for (i = 0; i < nmsgs; i++) { + struct message *m = va_arg(ap, struct message *); + + off += strlen(m->raw); + + if (m->upgrade) { + off -= strlen(m->upgrade); + + /* Check the portion of the response after its specified upgrade */ + if (!check_str_eq(m, "upgrade", body + off, body + nread)) { + abort(); + } + + /* Fix up the response so that message_eq() will verify the beginning + * of the upgrade */ + *(body + nread + strlen(m->upgrade)) = '\0'; + messages[num_messages -1 ].upgrade = body + nread; + + va_end(ap); + return; + } + } + + va_end(ap); + printf("\n\n*** Error: expected a message with upgrade ***\n"); + + abort(); +} + +static void +print_error (const char *raw, size_t error_location) +{ + fprintf(stderr, "\n*** %s ***\n\n", + http_errno_description(HTTP_PARSER_ERRNO(parser))); + + int this_line = 0, char_len = 0; + size_t i, j, len = strlen(raw), error_location_line = 0; + for (i = 0; i < len; i++) { + if (i == error_location) this_line = 1; + switch (raw[i]) { + case '\r': + char_len = 2; + fprintf(stderr, "\\r"); + break; + + case '\n': + char_len = 2; + fprintf(stderr, "\\n\n"); + + if (this_line) goto print; + + error_location_line = 0; + continue; + + default: + char_len = 1; + fputc(raw[i], stderr); + break; + } + if (!this_line) error_location_line += char_len; + } + + fprintf(stderr, "[eof]\n"); + + print: + for (j = 0; j < error_location_line; j++) { + fputc(' ', stderr); + } + fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location); +} + +void +test_preserve_data (void) +{ + char my_data[] = "application-specific data"; + http_parser parser; + parser.data = my_data; + http_parser_init(&parser, HTTP_REQUEST); + if (parser.data != my_data) { + printf("\n*** parser.data not preserved accross http_parser_init ***\n\n"); + abort(); + } +} + +struct url_test { + const char *name; + const char *url; + int is_connect; + struct http_parser_url u; + int rv; +}; + +const struct url_test url_tests[] = +{ {.name="proxy request" + ,.url="http://hostname/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 7, 8 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 15, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="proxy request with port" + ,.url="http://hostname:444/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) + ,.port=444 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 7, 8 } /* UF_HOST */ + ,{ 16, 3 } /* UF_PORT */ + ,{ 19, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT request" + ,.url="hostname:443" + ,.is_connect=1 + ,.u= + {.field_set=(1 << UF_HOST) | (1 << UF_PORT) + ,.port=443 + ,.field_data= + {{ 0, 0 } /* UF_SCHEMA */ + ,{ 0, 8 } /* UF_HOST */ + ,{ 9, 3 } /* UF_PORT */ + ,{ 0, 0 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT request but not connect" + ,.url="hostname:443" + ,.is_connect=0 + ,.rv=1 + } + +, {.name="proxy ipv6 request" + ,.url="http://[1:2::3:4]/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 8 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 17, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="proxy ipv6 request with port" + ,.url="http://[1:2::3:4]:67/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) + ,.port=67 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 8 } /* UF_HOST */ + ,{ 18, 2 } /* UF_PORT */ + ,{ 20, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT ipv6 address" + ,.url="[1:2::3:4]:443" + ,.is_connect=1 + ,.u= + {.field_set=(1 << UF_HOST) | (1 << UF_PORT) + ,.port=443 + ,.field_data= + {{ 0, 0 } /* UF_SCHEMA */ + ,{ 1, 8 } /* UF_HOST */ + ,{ 11, 3 } /* UF_PORT */ + ,{ 0, 0 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="ipv4 in ipv6 address" + ,.url="http://[2001:0000:0000:0000:0000:0000:1.9.1.1]/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 37 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 46, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="extra ? in query string" + ,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css," + "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css," + "fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css" + ,.is_connect=0 + ,.u= + {.field_set=(1<field_set, u->port); + for (i = 0; i < UF_MAX; i++) { + if ((u->field_set & (1 << i)) == 0) { + printf("\tfield_data[%u]: unset\n", i); + continue; + } + + printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n\"", + i, + u->field_data[i].off, + u->field_data[i].len, + u->field_data[i].len, + url + u->field_data[i].off); + } +} + +void +test_parse_url (void) +{ + struct http_parser_url u; + const struct url_test *test; + unsigned int i; + int rv; + + for (i = 0; i < (sizeof(url_tests) / sizeof(url_tests[0])); i++) { + test = &url_tests[i]; + memset(&u, 0, sizeof(u)); + + rv = http_parser_parse_url(test->url, + strlen(test->url), + test->is_connect, + &u); + + if (test->rv == 0) { + if (rv != 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " + "unexpected rv %d ***\n\n", test->url, test->name, rv); + abort(); + } + + if (memcmp(&u, &test->u, sizeof(u)) != 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" failed ***\n", + test->url, test->name); + + printf("target http_parser_url:\n"); + dump_url(test->url, &test->u); + printf("result http_parser_url:\n"); + dump_url(test->url, &u); + + abort(); + } + } else { + /* test->rv != 0 */ + if (rv == 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " + "unexpected rv %d ***\n\n", test->url, test->name, rv); + abort(); + } + } + } +} + +void +test_method_str (void) +{ + assert(0 == strcmp("GET", http_method_str(HTTP_GET))); + assert(0 == strcmp("", http_method_str(1337))); +} + +void +test_message (const struct message *message) +{ + size_t raw_len = strlen(message->raw); + size_t msg1len; + for (msg1len = 0; msg1len < raw_len; msg1len++) { + parser_init(message->type); + + size_t read; + const char *msg1 = message->raw; + const char *msg2 = msg1 + msg1len; + size_t msg2len = raw_len - msg1len; + + if (msg1len) { + read = parse(msg1, msg1len); + + if (message->upgrade && parser->upgrade) { + messages[num_messages - 1].upgrade = msg1 + read; + goto test; + } + + if (read != msg1len) { + print_error(msg1, read); + abort(); + } + } + + + read = parse(msg2, msg2len); + + if (message->upgrade && parser->upgrade) { + messages[num_messages - 1].upgrade = msg2 + read; + goto test; + } + + if (read != msg2len) { + print_error(msg2, read); + abort(); + } + + read = parse(NULL, 0); + + if (read != 0) { + print_error(message->raw, read); + abort(); + } + + test: + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); + abort(); + } + + if(!message_eq(0, message)) abort(); + + parser_free(); + } +} + +void +test_message_count_body (const struct message *message) +{ + parser_init(message->type); + + size_t read; + size_t l = strlen(message->raw); + size_t i, toread; + size_t chunk = 4024; + + for (i = 0; i < l; i+= chunk) { + toread = MIN(l-i, chunk); + read = parse_count_body(message->raw + i, toread); + if (read != toread) { + print_error(message->raw, read); + abort(); + } + } + + + read = parse_count_body(NULL, 0); + if (read != 0) { + print_error(message->raw, read); + abort(); + } + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); + abort(); + } + + if(!message_eq(0, message)) abort(); + + parser_free(); +} + +void +test_simple (const char *buf, enum http_errno err_expected) +{ + parser_init(HTTP_REQUEST); + + size_t parsed; + int pass; + enum http_errno err; + + parsed = parse(buf, strlen(buf)); + pass = (parsed == strlen(buf)); + err = HTTP_PARSER_ERRNO(parser); + parsed = parse(NULL, 0); + pass &= (parsed == 0); + + parser_free(); + + /* In strict mode, allow us to pass with an unexpected HPE_STRICT as + * long as the caller isn't expecting success. + */ +#if HTTP_PARSER_STRICT + if (err_expected != err && err_expected != HPE_OK && err != HPE_STRICT) { +#else + if (err_expected != err) { +#endif + fprintf(stderr, "\n*** test_simple expected %s, but saw %s ***\n\n%s\n", + http_errno_name(err_expected), http_errno_name(err), buf); + abort(); + } +} + +void +test_header_overflow_error (int req) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? "GET / HTTP/1.1\r\n" : "HTTP/1.0 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = "header-key: header-value\r\n"; + size_t buflen = strlen(buf); + + int i; + for (i = 0; i < 10000; i++) { + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + //fprintf(stderr, "error found on iter %d\n", i); + assert(HTTP_PARSER_ERRNO(&parser) == HPE_HEADER_OVERFLOW); + return; + } + } + + fprintf(stderr, "\n*** Error expected but none in header overflow test ***\n"); + abort(); +} + +static void +test_content_length_overflow (const char *buf, size_t buflen, int expect_ok) +{ + http_parser parser; + http_parser_init(&parser, HTTP_RESPONSE); + http_parser_execute(&parser, &settings_null, buf, buflen); + + if (expect_ok) + assert(HTTP_PARSER_ERRNO(&parser) == HPE_OK); + else + assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_CONTENT_LENGTH); +} + +void +test_header_content_length_overflow_error (void) +{ +#define X(size) \ + "HTTP/1.1 200 OK\r\n" \ + "Content-Length: " #size "\r\n" \ + "\r\n" + const char a[] = X(18446744073709551614); /* 2^64-2 */ + const char b[] = X(18446744073709551615); /* 2^64-1 */ + const char c[] = X(18446744073709551616); /* 2^64 */ +#undef X + test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ + test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ + test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ +} + +void +test_chunk_content_length_overflow_error (void) +{ +#define X(size) \ + "HTTP/1.1 200 OK\r\n" \ + "Transfer-Encoding: chunked\r\n" \ + "\r\n" \ + #size "\r\n" \ + "..." + const char a[] = X(FFFFFFFFFFFFFFFE); /* 2^64-2 */ + const char b[] = X(FFFFFFFFFFFFFFFF); /* 2^64-1 */ + const char c[] = X(10000000000000000); /* 2^64 */ +#undef X + test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ + test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ + test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ +} + +void +test_no_overflow_long_body (int req, size_t length) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + size_t i; + char buf1[3000]; + size_t buf1len = sprintf(buf1, "%s\r\nConnection: Keep-Alive\r\nContent-Length: %lu\r\n\r\n", + req ? "POST / HTTP/1.0" : "HTTP/1.0 200 OK", (unsigned long)length); + parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); + if (parsed != buf1len) + goto err; + + for (i = 0; i < length; i++) { + char foo = 'a'; + parsed = http_parser_execute(&parser, &settings_null, &foo, 1); + if (parsed != 1) + goto err; + } + + parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); + if (parsed != buf1len) goto err; + return; + + err: + fprintf(stderr, + "\n*** error in test_no_overflow_long_body %s of length %lu ***\n", + req ? "REQUEST" : "RESPONSE", + (unsigned long)length); + abort(); +} + +void +test_multiple3 (const struct message *r1, const struct message *r2, const struct message *r3) +{ + int message_count = count_parsed_messages(3, r1, r2, r3); + + char total[ strlen(r1->raw) + + strlen(r2->raw) + + strlen(r3->raw) + + 1 + ]; + total[0] = '\0'; + + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); + + parser_init(r1->type); + + size_t read; + + read = parse(total, strlen(total)); + + if (parser->upgrade) { + upgrade_message_fix(total, read, 3, r1, r2, r3); + goto test; + } + + if (read != strlen(total)) { + print_error(total, read); + abort(); + } + + read = parse(NULL, 0); + + if (read != 0) { + print_error(total, read); + abort(); + } + +test: + + if (message_count != num_messages) { + fprintf(stderr, "\n\n*** Parser didn't see 3 messages only %d *** \n", num_messages); + abort(); + } + + if (!message_eq(0, r1)) abort(); + if (message_count > 1 && !message_eq(1, r2)) abort(); + if (message_count > 2 && !message_eq(2, r3)) abort(); + + parser_free(); +} + +/* SCAN through every possible breaking to make sure the + * parser can handle getting the content in any chunks that + * might come from the socket + */ +void +test_scan (const struct message *r1, const struct message *r2, const struct message *r3) +{ + char total[80*1024] = "\0"; + char buf1[80*1024] = "\0"; + char buf2[80*1024] = "\0"; + char buf3[80*1024] = "\0"; + + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); + + size_t read; + + int total_len = strlen(total); + + int total_ops = 2 * (total_len - 1) * (total_len - 2) / 2; + int ops = 0 ; + + size_t buf1_len, buf2_len, buf3_len; + int message_count = count_parsed_messages(3, r1, r2, r3); + + int i,j,type_both; + for (type_both = 0; type_both < 2; type_both ++ ) { + for (j = 2; j < total_len; j ++ ) { + for (i = 1; i < j; i ++ ) { + + if (ops % 1000 == 0) { + printf("\b\b\b\b%3.0f%%", 100 * (float)ops /(float)total_ops); + fflush(stdout); + } + ops += 1; + + parser_init(type_both ? HTTP_BOTH : r1->type); + + buf1_len = i; + strlncpy(buf1, sizeof(buf1), total, buf1_len); + buf1[buf1_len] = 0; + + buf2_len = j - i; + strlncpy(buf2, sizeof(buf1), total+i, buf2_len); + buf2[buf2_len] = 0; + + buf3_len = total_len - j; + strlncpy(buf3, sizeof(buf1), total+j, buf3_len); + buf3[buf3_len] = 0; + + read = parse(buf1, buf1_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len) { + print_error(buf1, read); + goto error; + } + + read += parse(buf2, buf2_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len + buf2_len) { + print_error(buf2, read); + goto error; + } + + read += parse(buf3, buf3_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len + buf2_len + buf3_len) { + print_error(buf3, read); + goto error; + } + + parse(NULL, 0); + +test: + if (parser->upgrade) { + upgrade_message_fix(total, read, 3, r1, r2, r3); + } + + if (message_count != num_messages) { + fprintf(stderr, "\n\nParser didn't see %d messages only %d\n", + message_count, num_messages); + goto error; + } + + if (!message_eq(0, r1)) { + fprintf(stderr, "\n\nError matching messages[0] in test_scan.\n"); + goto error; + } + + if (message_count > 1 && !message_eq(1, r2)) { + fprintf(stderr, "\n\nError matching messages[1] in test_scan.\n"); + goto error; + } + + if (message_count > 2 && !message_eq(2, r3)) { + fprintf(stderr, "\n\nError matching messages[2] in test_scan.\n"); + goto error; + } + + parser_free(); + } + } + } + puts("\b\b\b\b100%"); + return; + + error: + fprintf(stderr, "i=%d j=%d\n", i, j); + fprintf(stderr, "buf1 (%u) %s\n\n", (unsigned int)buf1_len, buf1); + fprintf(stderr, "buf2 (%u) %s\n\n", (unsigned int)buf2_len , buf2); + fprintf(stderr, "buf3 (%u) %s\n", (unsigned int)buf3_len, buf3); + abort(); +} + +// user required to free the result +// string terminated by \0 +char * +create_large_chunked_message (int body_size_in_kb, const char* headers) +{ + int i; + size_t wrote = 0; + size_t headers_len = strlen(headers); + size_t bufsize = headers_len + (5+1024+2)*body_size_in_kb + 6; + char * buf = malloc(bufsize); + + memcpy(buf, headers, headers_len); + wrote += headers_len; + + for (i = 0; i < body_size_in_kb; i++) { + // write 1kb chunk into the body. + memcpy(buf + wrote, "400\r\n", 5); + wrote += 5; + memset(buf + wrote, 'C', 1024); + wrote += 1024; + strcpy(buf + wrote, "\r\n"); + wrote += 2; + } + + memcpy(buf + wrote, "0\r\n\r\n", 6); + wrote += 6; + assert(wrote == bufsize); + + return buf; +} + +void +test_status_complete (void) +{ + parser_init(HTTP_RESPONSE); + parser->data = 0; + http_parser_settings settings = settings_null; + settings.on_status_complete = status_complete_cb; + + char *response = "don't mind me, just a simple response"; + http_parser_execute(parser, &settings, response, strlen(response)); + assert(parser->data == (void*)0); // the status_complete callback was never called + assert(parser->http_errno == HPE_INVALID_CONSTANT); // the errno for an invalid status line +} + +/* Verify that we can pause parsing at any of the bytes in the + * message and still get the result that we're expecting. */ +void +test_message_pause (const struct message *msg) +{ + char *buf = (char*) msg->raw; + size_t buflen = strlen(msg->raw); + size_t nread; + + parser_init(msg->type); + + do { + nread = parse_pause(buf, buflen); + + // We can only set the upgrade buffer once we've gotten our message + // completion callback. + if (messages[0].message_complete_cb_called && + msg->upgrade && + parser->upgrade) { + messages[0].upgrade = buf + nread; + goto test; + } + + if (nread < buflen) { + + // Not much do to if we failed a strict-mode check + if (HTTP_PARSER_ERRNO(parser) == HPE_STRICT) { + parser_free(); + return; + } + + assert (HTTP_PARSER_ERRNO(parser) == HPE_PAUSED); + } + + buf += nread; + buflen -= nread; + http_parser_pause(parser, 0); + } while (buflen > 0); + + nread = parse_pause(NULL, 0); + assert (nread == 0); + +test: + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); + abort(); + } + + if(!message_eq(0, msg)) abort(); + + parser_free(); +} + +int +main (void) +{ + parser = NULL; + int i, j, k; + int request_count; + int response_count; + + printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser)); + + for (request_count = 0; requests[request_count].name; request_count++); + for (response_count = 0; responses[response_count].name; response_count++); + + //// API + test_preserve_data(); + test_parse_url(); + test_method_str(); + + //// OVERFLOW CONDITIONS + + test_header_overflow_error(HTTP_REQUEST); + test_no_overflow_long_body(HTTP_REQUEST, 1000); + test_no_overflow_long_body(HTTP_REQUEST, 100000); + + test_header_overflow_error(HTTP_RESPONSE); + test_no_overflow_long_body(HTTP_RESPONSE, 1000); + test_no_overflow_long_body(HTTP_RESPONSE, 100000); + + test_header_content_length_overflow_error(); + test_chunk_content_length_overflow_error(); + + //// RESPONSES + + for (i = 0; i < response_count; i++) { + test_message(&responses[i]); + } + + for (i = 0; i < response_count; i++) { + test_message_pause(&responses[i]); + } + + for (i = 0; i < response_count; i++) { + if (!responses[i].should_keep_alive) continue; + for (j = 0; j < response_count; j++) { + if (!responses[j].should_keep_alive) continue; + for (k = 0; k < response_count; k++) { + test_multiple3(&responses[i], &responses[j], &responses[k]); + } + } + } + + test_message_count_body(&responses[NO_HEADERS_NO_BODY_404]); + test_message_count_body(&responses[TRAILING_SPACE_ON_CHUNKED_BODY]); + + // test very large chunked response + { + char * msg = create_large_chunked_message(31337, + "HTTP/1.0 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain\r\n" + "\r\n"); + struct message large_chunked = + {.name= "large chunked" + ,.type= HTTP_RESPONSE + ,.raw= msg + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 200 + ,.num_headers= 2 + ,.headers= + { { "Transfer-Encoding", "chunked" } + , { "Content-Type", "text/plain" } + } + ,.body_size= 31337*1024 + }; + test_message_count_body(&large_chunked); + free(msg); + } + + + + printf("response scan 1/2 "); + test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY] + , &responses[NO_BODY_HTTP10_KA_204] + , &responses[NO_REASON_PHRASE] + ); + + printf("response scan 2/2 "); + test_scan( &responses[BONJOUR_MADAME_FR] + , &responses[UNDERSTORE_HEADER_KEY] + , &responses[NO_CARRIAGE_RET] + ); + + puts("responses okay"); + + + /// REQUESTS + + test_simple("hello world", HPE_INVALID_METHOD); + test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION); + + + test_simple("ASDF / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD); + test_simple("PROPPATCHA / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD); + test_simple("GETA / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD); + + // Well-formed but incomplete + test_simple("GET / HTTP/1.1\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 6\r\n" + "\r\n" + "fooba", + HPE_OK); + + static const char *all_methods[] = { + "DELETE", + "GET", + "HEAD", + "POST", + "PUT", + //"CONNECT", //CONNECT can't be tested like other methods, it's a tunnel + "OPTIONS", + "TRACE", + "COPY", + "LOCK", + "MKCOL", + "MOVE", + "PROPFIND", + "PROPPATCH", + "UNLOCK", + "REPORT", + "MKACTIVITY", + "CHECKOUT", + "MERGE", + "M-SEARCH", + "NOTIFY", + "SUBSCRIBE", + "UNSUBSCRIBE", + "PATCH", + 0 }; + const char **this_method; + for (this_method = all_methods; *this_method; this_method++) { + char buf[200]; + sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); + test_simple(buf, HPE_OK); + } + + static const char *bad_methods[] = { + "C******", + "M****", + 0 }; + for (this_method = bad_methods; *this_method; this_method++) { + char buf[200]; + sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); + test_simple(buf, HPE_UNKNOWN); + } + + const char *dumbfuck2 = + "GET / HTTP/1.1\r\n" + "X-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n" + "\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n" + "\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n" + "\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n" + "\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n" + "\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n" + "\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n" + "\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n" + "\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n" + "\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n" + "\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n" + "\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\r\n" + "\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\r\n" + "\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgHTTPAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\r\n" + "\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\r\n" + "\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\r\n" + "\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\r\n" + "\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\r\n" + "\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\r\n" + "\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\r\n" + "\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\r\n" + "\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\r\n" + "\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\r\n" + "\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\r\n" + "\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\r\n" + "\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\r\n" + "\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n" + "\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n" + "\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n" + "\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n" + "\tRA==\r\n" + "\t-----END CERTIFICATE-----\r\n" + "\r\n"; + test_simple(dumbfuck2, HPE_OK); + +#if 0 + // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body + // until EOF. + // + // no content-length + // error if there is a body without content length + const char *bad_get_no_headers_no_body = "GET /bad_get_no_headers_no_body/world HTTP/1.1\r\n" + "Accept: */*\r\n" + "\r\n" + "HELLO"; + test_simple(bad_get_no_headers_no_body, 0); +#endif + /* TODO sending junk and large headers gets rejected */ + + + /* check to make sure our predefined requests are okay */ + for (i = 0; requests[i].name; i++) { + test_message(&requests[i]); + } + + for (i = 0; i < request_count; i++) { + test_message_pause(&requests[i]); + } + + for (i = 0; i < request_count; i++) { + if (!requests[i].should_keep_alive) continue; + for (j = 0; j < request_count; j++) { + if (!requests[j].should_keep_alive) continue; + for (k = 0; k < request_count; k++) { + test_multiple3(&requests[i], &requests[j], &requests[k]); + } + } + } + + printf("request scan 1/4 "); + test_scan( &requests[GET_NO_HEADERS_NO_BODY] + , &requests[GET_ONE_HEADER_NO_BODY] + , &requests[GET_NO_HEADERS_NO_BODY] + ); + + printf("request scan 2/4 "); + test_scan( &requests[POST_CHUNKED_ALL_YOUR_BASE] + , &requests[POST_IDENTITY_BODY_WORLD] + , &requests[GET_FUNKY_CONTENT_LENGTH] + ); + + printf("request scan 3/4 "); + test_scan( &requests[TWO_CHUNKS_MULT_ZERO_END] + , &requests[CHUNKED_W_TRAILING_HEADERS] + , &requests[CHUNKED_W_BULLSHIT_AFTER_LENGTH] + ); + + printf("request scan 4/4 "); + test_scan( &requests[QUERY_URL_WITH_QUESTION_MARK_GET] + , &requests[PREFIX_NEWLINE_GET ] + , &requests[CONNECT_REQUEST] + ); + + test_status_complete(); + + puts("requests okay"); + + return 0; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tests.dumped b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tests.dumped new file mode 100644 index 0000000..038bb52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tests.dumped @@ -0,0 +1,845 @@ +name :curl get +raw :"GET /test HTTP/1.1\r\nUser-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\nHost: 0.0.0.0=5000\r\nAccept: */*\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/test +request_url :/test +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "User-Agent": "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1"} +header_1 :{ "Host": "0.0.0.0=5000"} +header_2 :{ "Accept": "*/*"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :firefox get +raw :"GET /favicon.ico HTTP/1.1\r\nHost: 0.0.0.0=5000\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/favicon.ico +request_url :/favicon.ico +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Host": "0.0.0.0=5000"} +header_1 :{ "User-Agent": "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0"} +header_2 :{ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"} +header_3 :{ "Accept-Language": "en-us,en;q=0.5"} +header_4 :{ "Accept-Encoding": "gzip,deflate"} +header_5 :{ "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7"} +header_6 :{ "Keep-Alive": "300"} +header_7 :{ "Connection": "keep-alive"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :dumbfuck +raw :"GET /dumbfuck HTTP/1.1\r\naaaaaaaaaaaaa:++++++++++\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/dumbfuck +request_url :/dumbfuck +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "aaaaaaaaaaaaa": "++++++++++"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :fragment in url +raw :"GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/forums/1/topics/2375 +request_url :/forums/1/topics/2375?page=1#posts-17408 +fragment :posts-17408 +query_string:page=1 +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :get no headers no body +raw :"GET /get_no_headers_no_body/world HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/get_no_headers_no_body/world +request_url :/get_no_headers_no_body/world +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :get one header no body +raw :"GET /get_one_header_no_body HTTP/1.1\r\nAccept: */*\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/get_one_header_no_body +request_url :/get_one_header_no_body +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Accept": "*/*"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :get funky content length body hello +raw :"GET /get_funky_content_length_body_hello HTTP/1.0\r\nconTENT-Length: 5\r\n\r\nHELLO" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/get_funky_content_length_body_hello +request_url :/get_funky_content_length_body_hello +fragment : +query_string: +body :"HELLO" +body_size :0 +header_0 :{ "conTENT-Length": "5"} +should_keep_alive :0 +http_major :1 +http_minor :0 + +name :post identity body world +raw :"POST /post_identity_body_world?q=search#hey HTTP/1.1\r\nAccept: */*\r\nTransfer-Encoding: identity\r\nContent-Length: 5\r\n\r\nWorld" +type :HTTP_REQUEST +method: HTTP_POST +status_code :0 +request_path:/post_identity_body_world +request_url :/post_identity_body_world?q=search#hey +fragment :hey +query_string:q=search +body :"World" +body_size :0 +header_0 :{ "Accept": "*/*"} +header_1 :{ "Transfer-Encoding": "identity"} +header_2 :{ "Content-Length": "5"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :post - chunked body: all your base are belong to us +raw :"POST /post_chunked_all_your_base HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n1e\r\nall your base are belong to us\r\n0\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_POST +status_code :0 +request_path:/post_chunked_all_your_base +request_url :/post_chunked_all_your_base +fragment : +query_string: +body :"all your base are belong to us" +body_size :0 +header_0 :{ "Transfer-Encoding": "chunked"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :two chunks ; triple zero ending +raw :"POST /two_chunks_mult_zero_end HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n6\r\n world\r\n000\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_POST +status_code :0 +request_path:/two_chunks_mult_zero_end +request_url :/two_chunks_mult_zero_end +fragment : +query_string: +body :"hello world" +body_size :0 +header_0 :{ "Transfer-Encoding": "chunked"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :chunked with trailing headers. blech. +raw :"POST /chunked_w_trailing_headers HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n6\r\n world\r\n0\r\nVary: *\r\nContent-Type: text/plain\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_POST +status_code :0 +request_path:/chunked_w_trailing_headers +request_url :/chunked_w_trailing_headers +fragment : +query_string: +body :"hello world" +body_size :0 +header_0 :{ "Transfer-Encoding": "chunked"} +header_1 :{ "Vary": "*"} +header_2 :{ "Content-Type": "text/plain"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :with bullshit after the length +raw :"POST /chunked_w_bullshit_after_length HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n5; ihatew3;whatthefuck=aretheseparametersfor\r\nhello\r\n6; blahblah; blah\r\n world\r\n0\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_POST +status_code :0 +request_path:/chunked_w_bullshit_after_length +request_url :/chunked_w_bullshit_after_length +fragment : +query_string: +body :"hello world" +body_size :0 +header_0 :{ "Transfer-Encoding": "chunked"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :with quotes +raw :"GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/with_"stupid"_quotes +request_url :/with_"stupid"_quotes?foo="bar" +fragment : +query_string:foo="bar" +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :apachebench get +raw :"GET /test HTTP/1.0\r\nHost: 0.0.0.0:5000\r\nUser-Agent: ApacheBench/2.3\r\nAccept: */*\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/test +request_url :/test +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Host": "0.0.0.0:5000"} +header_1 :{ "User-Agent": "ApacheBench/2.3"} +header_2 :{ "Accept": "*/*"} +should_keep_alive :0 +http_major :1 +http_minor :0 + +name :query url with question mark +raw :"GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/test.cgi +request_url :/test.cgi?foo=bar?baz +fragment : +query_string:foo=bar?baz +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :newline prefix get +raw :"\r\nGET /test HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/test +request_url :/test +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :upgrade request +raw :"GET /demo HTTP/1.1\r\nHost: example.com\r\nConnection: Upgrade\r\nSec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\nSec-WebSocket-Protocol: sample\r\nUpgrade: WebSocket\r\nSec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\nOrigin: http://example.com\r\n\r\nHot diggity dogg" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/demo +request_url :/demo +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Host": "example.com"} +header_1 :{ "Connection": "Upgrade"} +header_2 :{ "Sec-WebSocket-Key2": "12998 5 Y3 1 .P00"} +header_3 :{ "Sec-WebSocket-Protocol": "sample"} +header_4 :{ "Upgrade": "WebSocket"} +header_5 :{ "Sec-WebSocket-Key1": "4 @1 46546xW%0l 1 5"} +header_6 :{ "Origin": "http://example.com"} +should_keep_alive :1 +upgrade :"Hot diggity dogg" +http_major :1 +http_minor :1 + +name :connect request +raw :"CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\nUser-agent: Mozilla/1.1N\r\nProxy-authorization: basic aGVsbG86d29ybGQ=\r\n\r\nsome data\r\nand yet even more data" +type :HTTP_REQUEST +method: HTTP_CONNECT +status_code :0 +request_path: +request_url :0-home0.netscape.com:443 +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "User-agent": "Mozilla/1.1N"} +header_1 :{ "Proxy-authorization": "basic aGVsbG86d29ybGQ="} +should_keep_alive :0 +upgrade :"some data\r\nand yet even more data" +http_major :1 +http_minor :0 + +name :report request +raw :"REPORT /test HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_REPORT +status_code :0 +request_path:/test +request_url :/test +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :request with no http version +raw :"GET /\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/ +request_url :/ +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :0 +http_major :0 +http_minor :9 + +name :m-search request +raw :"M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: \"ssdp:discover\"\r\nST: \"ssdp:all\"\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_MSEARCH +status_code :0 +request_path:* +request_url :* +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "HOST": "239.255.255.250:1900"} +header_1 :{ "MAN": ""ssdp:discover""} +header_2 :{ "ST": ""ssdp:all""} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :line folding in header value +raw :"GET / HTTP/1.1\r\nLine1: abc\r\n def\r\n ghi\r\n jkl\r\n mno \r\n qrs\r\nLine2: line2 \r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/ +request_url :/ +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Line1": "abcdefghijklmno qrs"} +header_1 :{ "Line2": "line2 "} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :host terminated by a query string +raw :"GET http://hypnotoad.org?hail=all HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path: +request_url :http://hypnotoad.org?hail=all +fragment : +query_string:hail=all +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :host:port terminated by a query string +raw :"GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path: +request_url :http://hypnotoad.org:1234?hail=all +fragment : +query_string:hail=all +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :host:port terminated by a space +raw :"GET http://hypnotoad.org:1234 HTTP/1.1\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path: +request_url :http://hypnotoad.org:1234 +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :PATCH request +raw :"PATCH /file.txt HTTP/1.1\r\nHost: www.example.com\r\nContent-Type: application/example\r\nIf-Match: \"e0023aa4e\"\r\nContent-Length: 10\r\n\r\ncccccccccc" +type :HTTP_REQUEST +method: UNKNOWN +status_code :0 +request_path:/file.txt +request_url :/file.txt +fragment : +query_string: +body :"cccccccccc" +body_size :0 +header_0 :{ "Host": "www.example.com"} +header_1 :{ "Content-Type": "application/example"} +header_2 :{ "If-Match": ""e0023aa4e""} +header_3 :{ "Content-Length": "10"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :connect caps request +raw :"CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\nUser-agent: Mozilla/1.1N\r\nProxy-authorization: basic aGVsbG86d29ybGQ=\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_CONNECT +status_code :0 +request_path: +request_url :HOME0.NETSCAPE.COM:443 +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "User-agent": "Mozilla/1.1N"} +header_1 :{ "Proxy-authorization": "basic aGVsbG86d29ybGQ="} +should_keep_alive :0 +upgrade :"" +http_major :1 +http_minor :0 + +name :eat CRLF between requests, no "Connection: close" header +raw :"POST / HTTP/1.1\r\nHost: www.example.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 4\r\n\r\nq=42\r\n" +type :HTTP_REQUEST +method: HTTP_POST +status_code :0 +request_path:/ +request_url :/ +fragment : +query_string: +body :"q=42" +body_size :0 +header_0 :{ "Host": "www.example.com"} +header_1 :{ "Content-Type": "application/x-www-form-urlencoded"} +header_2 :{ "Content-Length": "4"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :eat CRLF between requests even if "Connection: close" is set +raw :"POST / HTTP/1.1\r\nHost: www.example.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 4\r\nConnection: close\r\n\r\nq=42\r\n" +type :HTTP_REQUEST +method: HTTP_POST +status_code :0 +request_path:/ +request_url :/ +fragment : +query_string: +body :"q=42" +body_size :0 +header_0 :{ "Host": "www.example.com"} +header_1 :{ "Content-Type": "application/x-www-form-urlencoded"} +header_2 :{ "Content-Length": "4"} +header_3 :{ "Connection": "close"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :PURGE request +raw :"PURGE /file.txt HTTP/1.1\r\nHost: www.example.com\r\n\r\n" +type :HTTP_REQUEST +method: UNKNOWN +status_code :0 +request_path:/file.txt +request_url :/file.txt +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Host": "www.example.com"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :google 301 +raw :"HTTP/1.1 301 Moved Permanently\r\nLocation: http://www.google.com/\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Sun, 26 Apr 2009 11:11:49 GMT\r\nExpires: Tue, 26 May 2009 11:11:49 GMT\r\nX-$PrototypeBI-Version: 1.6.0.3\r\nCache-Control: public, max-age=2592000\r\nServer: gws\r\nContent-Length: 219 \r\n\r\n\n301 Moved\n

301 Moved

\nThe document has moved\nhere.\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :301 +request_path: +request_url : +fragment : +query_string: +body :"\n301 Moved\n

301 Moved

\nThe document has moved\nhere.\r\n\r\n" +body_size :0 +header_0 :{ "Location": "http://www.google.com/"} +header_1 :{ "Content-Type": "text/html; charset=UTF-8"} +header_2 :{ "Date": "Sun, 26 Apr 2009 11:11:49 GMT"} +header_3 :{ "Expires": "Tue, 26 May 2009 11:11:49 GMT"} +header_4 :{ "X-$PrototypeBI-Version": "1.6.0.3"} +header_5 :{ "Cache-Control": "public, max-age=2592000"} +header_6 :{ "Server": "gws"} +header_7 :{ "Content-Length": "219 "} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :no content-length response +raw :"HTTP/1.1 200 OK\r\nDate: Tue, 04 Aug 2009 07:59:32 GMT\r\nServer: Apache\r\nX-Powered-By: Servlet/2.5 JSP/2.1\r\nContent-Type: text/xml; charset=utf-8\r\nConnection: close\r\n\r\n\n\n \n \n SOAP-ENV:Client\n Client Error\n \n \n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"\n\n \n \n SOAP-ENV:Client\n Client Error\n \n \n" +body_size :0 +header_0 :{ "Date": "Tue, 04 Aug 2009 07:59:32 GMT"} +header_1 :{ "Server": "Apache"} +header_2 :{ "X-Powered-By": "Servlet/2.5 JSP/2.1"} +header_3 :{ "Content-Type": "text/xml; charset=utf-8"} +header_4 :{ "Connection": "close"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :404 no headers no body +raw :"HTTP/1.1 404 Not Found\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :404 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :301 no response phrase +raw :"HTTP/1.1 301\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :301 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :200 trailing space on chunked body +raw :"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n25 \r\nThis is the data in the first chunk\r\n\r\n1C\r\nand this is the second one\r\n\r\n0 \r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"This is the data in the first chunk\r\nand this is the second one\r\n" +body_size :65 +header_0 :{ "Content-Type": "text/plain"} +header_1 :{ "Transfer-Encoding": "chunked"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :no carriage ret +raw :"HTTP/1.1 200 OK\nContent-Type: text/html; charset=utf-8\nConnection: close\n\nthese headers are from http://news.ycombinator.com/" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"these headers are from http://news.ycombinator.com/" +body_size :0 +header_0 :{ "Content-Type": "text/html; charset=utf-8"} +header_1 :{ "Connection": "close"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :proxy connection +raw :"HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 11\r\nProxy-Connection: close\r\nDate: Thu, 31 Dec 2009 20:55:48 +0000\r\n\r\nhello world" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"hello world" +body_size :0 +header_0 :{ "Content-Type": "text/html; charset=UTF-8"} +header_1 :{ "Content-Length": "11"} +header_2 :{ "Proxy-Connection": "close"} +header_3 :{ "Date": "Thu, 31 Dec 2009 20:55:48 +0000"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :underscore header key +raw :"HTTP/1.1 200 OK\r\nServer: DCLK-AdSvr\r\nContent-Type: text/xml\r\nContent-Length: 0\r\nDCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Server": "DCLK-AdSvr"} +header_1 :{ "Content-Type": "text/xml"} +header_2 :{ "Content-Length": "0"} +header_3 :{ "DCLK_imp": "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o"} +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :bonjourmadame.fr +raw :"HTTP/1.0 301 Moved Permanently\r\nDate: Thu, 03 Jun 2010 09:56:32 GMT\r\nServer: Apache/2.2.3 (Red Hat)\r\nCache-Control: public\r\nPragma: \r\nLocation: http://www.bonjourmadame.fr/\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: keep-alive\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :301 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Date": "Thu, 03 Jun 2010 09:56:32 GMT"} +header_1 :{ "Server": "Apache/2.2.3 (Red Hat)"} +header_2 :{ "Cache-Control": "public"} +header_3 :{ "Pragma": ""} +header_4 :{ "Location": "http://www.bonjourmadame.fr/"} +header_5 :{ "Vary": "Accept-Encoding"} +header_6 :{ "Content-Length": "0"} +header_7 :{ "Content-Type": "text/html; charset=UTF-8"} +header_8 :{ "Connection": "keep-alive"} +should_keep_alive :1 +http_major :1 +http_minor :0 + +name :field underscore +raw :"HTTP/1.1 200 OK\r\nDate: Tue, 28 Sep 2010 01:14:13 GMT\r\nServer: Apache\r\nCache-Control: no-cache, must-revalidate\r\nExpires: Mon, 26 Jul 1997 05:00:00 GMT\r\n.et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\nVary: Accept-Encoding\r\n_eep-Alive: timeout=45\r\n_onnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n0\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Date": "Tue, 28 Sep 2010 01:14:13 GMT"} +header_1 :{ "Server": "Apache"} +header_2 :{ "Cache-Control": "no-cache, must-revalidate"} +header_3 :{ "Expires": "Mon, 26 Jul 1997 05:00:00 GMT"} +header_4 :{ ".et-Cookie": "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com"} +header_5 :{ "Vary": "Accept-Encoding"} +header_6 :{ "_eep-Alive": "timeout=45"} +header_7 :{ "_onnection": "Keep-Alive"} +header_8 :{ "Transfer-Encoding": "chunked"} +header_9 :{ "Content-Type": "text/html"} +header_10 :{ "Connection": "close"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :non-ASCII in status line +raw :"HTTP/1.1 500 Oriëntatieprobleem\r\nDate: Fri, 5 Nov 2010 23:07:12 GMT+2\r\nContent-Length: 0\r\nConnection: close\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :500 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Date": "Fri, 5 Nov 2010 23:07:12 GMT+2"} +header_1 :{ "Content-Length": "0"} +header_2 :{ "Connection": "close"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :http version 0.9 +raw :"HTTP/0.9 200 OK\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :0 +http_major :0 +http_minor :9 + +name :neither content-length nor transfer-encoding response +raw :"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello world" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"hello world" +body_size :0 +header_0 :{ "Content-Type": "text/plain"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :HTTP/1.0 with keep-alive and EOF-terminated 200 status +raw :"HTTP/1.0 200 OK\r\nConnection: keep-alive\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Connection": "keep-alive"} +should_keep_alive :0 +http_major :1 +http_minor :0 + +name :HTTP/1.0 with keep-alive and a 204 status +raw :"HTTP/1.0 204 No content\r\nConnection: keep-alive\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :204 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Connection": "keep-alive"} +should_keep_alive :1 +http_major :1 +http_minor :0 + +name :HTTP/1.1 with an EOF-terminated 200 status +raw :"HTTP/1.1 200 OK\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :HTTP/1.1 with a 204 status +raw :"HTTP/1.1 204 No content\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :204 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +should_keep_alive :1 +http_major :1 +http_minor :1 + +name :HTTP/1.1 with a 204 status and keep-alive disabled +raw :"HTTP/1.1 204 No content\r\nConnection: close\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :204 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Connection": "close"} +should_keep_alive :0 +http_major :1 +http_minor :1 + +name :HTTP/1.1 with chunked endocing and a 200 response +raw :"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n" +type :HTTP_RESPONSE +method: HTTP_DELETE +status_code :200 +request_path: +request_url : +fragment : +query_string: +body :"" +body_size :0 +header_0 :{ "Transfer-Encoding": "chunked"} +should_keep_alive :1 +http_major :1 +http_minor :1 + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tests.utf8 b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tests.utf8 new file mode 100644 index 0000000..5266159 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tests.utf8 @@ -0,0 +1,17 @@ +name :utf-8 path request +raw :"GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\nHost: github.com\r\n\r\n" +type :HTTP_REQUEST +method: HTTP_GET +status_code :0 +request_path:/δ¶/δt/pope +request_url :/δ¶/δt/pope?q=1#narf +fragment :narf +query_string:q=1 +body :"" +body_size :0 +header_0 :{ "Host": "github.com"} +should_keep_alive :1 +upgrade :0 +http_major :1 +http_minor :1 + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/byte_constants.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/byte_constants.rb new file mode 100644 index 0000000..1604890 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/byte_constants.rb @@ -0,0 +1,6 @@ + +"A".upto("Z") {|c| + puts "public static final byte #{c} = 0x#{c[0].to_s(16)};" +} + + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/const_char.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/const_char.rb new file mode 100644 index 0000000..84f9699 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/const_char.rb @@ -0,0 +1,13 @@ + + +def printbytes str +str.each_byte { |b| + print "0x#{b.to_s(16)}, " +} +end + +if $0 == __FILE__ + printf "static final byte [] #{ARGV[0]} = {\n" + printbytes ARGV[0] + printf "\n};\n" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/lowcase.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/lowcase.rb new file mode 100644 index 0000000..13960cb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/lowcase.rb @@ -0,0 +1,15 @@ + + +0.upto(255) { |i| + printf "\n" if i%16 == 0 + printf " " if i%8 == 0 + s = ("" << i) + if s =~ /[A-Z0-9\-_\/ ]/ + print "0x#{i.to_s(16)}," + elsif s =~ /[a-z]/ + print "0x#{s.upcase[0].to_s(16)}," + else + print "0x00," + end + +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/parse_tests.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/parse_tests.rb new file mode 100644 index 0000000..683adb9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/tools/parse_tests.rb @@ -0,0 +1,33 @@ + + + + +# name : 200 trailing space on chunked body +# raw : "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n25 \r\nThis is the data in the first chunk\r\n\r\n1C\r\nand this is the second one\r\n\r\n0 \r\n\r\n" +# type : HTTP_RESPONSE +# method: HTTP_DELETE +# status code :200 +# request_path: +# request_url : +# fragment : +# query_string: +# body :"This is the data in the first chunk\r\nand this is the second one\r\n" +# body_size :65 +# header_0 :{ "Content-Type": "text/plain"} +# header_1 :{ "Transfer-Encoding": "chunked"} +# should_keep_alive :1 +# upgrade :0 +# http_major :1 +# http_minor :1 + + +class ParserTest + attr_accessor :name + attr_accessor :raw + attr_accessor :type + attr_accessor :method + attr_accessor :status_code + attr_accessor :request_path + attr_accessor :method +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/AUTHORS b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/AUTHORS new file mode 100644 index 0000000..5323b68 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/AUTHORS @@ -0,0 +1,68 @@ +# Authors ordered by first contribution. +Ryan Dahl +Jeremy Hinegardner +Sergey Shepelev +Joe Damato +tomika +Phoenix Sol +Cliff Frey +Ewen Cheslack-Postava +Santiago Gala +Tim Becker +Jeff Terrace +Ben Noordhuis +Nathan Rajlich +Mark Nottingham +Aman Gupta +Tim Becker +Sean Cunningham +Peter Griess +Salman Haq +Cliff Frey +Jon Kolb +Fouad Mardini +Paul Querna +Felix Geisendörfer +koichik +Andre Caron +Ivo Raisr +James McLaughlin +David Gwynne +Thomas LE ROUX +Randy Rizun +Andre Louis Caron +Simon Zimmermann +Erik Dubbelboer +Martell Malone +Bertrand Paquet +BogDan Vatra +Peter Faiman +Corey Richardson +Tóth Tamás +Cam Swords +Chris Dickinson +Uli Köhler +Charlie Somerville +Patrik Stutz +Fedor Indutny +runner +Alexis Campailla +David Wragg +Vinnie Falco +Alex Butum +Rex Feng +Alex Kocharin +Mark Koopman +Helge Heß +Alexis La Goutte +George Miroshnykov +Maciej Małecki +Marc O'Morain +Jeff Pinner +Timothy J Fontaine +Akagi201 +Romain Giraud +Jay Satiro +Arne Steen +Kjell Schubert +Olivier Mengué diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/LICENSE-MIT b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/LICENSE-MIT new file mode 100644 index 0000000..1ec0ab4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright Joyent, Inc. and other Node contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/README.md b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/README.md new file mode 100644 index 0000000..b265d71 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/README.md @@ -0,0 +1,246 @@ +HTTP Parser +=========== + +[![Build Status](https://api.travis-ci.org/nodejs/http-parser.svg?branch=master)](https://travis-ci.org/nodejs/http-parser) + +This is a parser for HTTP messages written in C. It parses both requests and +responses. The parser is designed to be used in performance HTTP +applications. It does not make any syscalls nor allocations, it does not +buffer data, it can be interrupted at anytime. Depending on your +architecture, it only requires about 40 bytes of data per message +stream (in a web server that is per connection). + +Features: + + * No dependencies + * Handles persistent streams (keep-alive). + * Decodes chunked encoding. + * Upgrade support + * Defends against buffer overflow attacks. + +The parser extracts the following information from HTTP messages: + + * Header fields and values + * Content-Length + * Request method + * Response status code + * Transfer-Encoding + * HTTP version + * Request URL + * Message body + + +Usage +----- + +One `http_parser` object is used per TCP connection. Initialize the struct +using `http_parser_init()` and set the callbacks. That might look something +like this for a request parser: +```c +http_parser_settings settings; +settings.on_url = my_url_callback; +settings.on_header_field = my_header_field_callback; +/* ... */ + +http_parser *parser = malloc(sizeof(http_parser)); +http_parser_init(parser, HTTP_REQUEST); +parser->data = my_socket; +``` + +When data is received on the socket execute the parser and check for errors. + +```c +size_t len = 80*1024, nparsed; +char buf[len]; +ssize_t recved; + +recved = recv(fd, buf, len, 0); + +if (recved < 0) { + /* Handle error. */ +} + +/* Start up / continue the parser. + * Note we pass recved==0 to signal that EOF has been received. + */ +nparsed = http_parser_execute(parser, &settings, buf, recved); + +if (parser->upgrade) { + /* handle new protocol */ +} else if (nparsed != recved) { + /* Handle error. Usually just close the connection. */ +} +``` + +`http_parser` needs to know where the end of the stream is. For example, sometimes +servers send responses without Content-Length and expect the client to +consume input (for the body) until EOF. To tell `http_parser` about EOF, give +`0` as the fourth parameter to `http_parser_execute()`. Callbacks and errors +can still be encountered during an EOF, so one must still be prepared +to receive them. + +Scalar valued message information such as `status_code`, `method`, and the +HTTP version are stored in the parser structure. This data is only +temporally stored in `http_parser` and gets reset on each new message. If +this information is needed later, copy it out of the structure during the +`headers_complete` callback. + +The parser decodes the transfer-encoding for both requests and responses +transparently. That is, a chunked encoding is decoded before being sent to +the on_body callback. + + +The Special Problem of Upgrade +------------------------------ + +`http_parser` supports upgrading the connection to a different protocol. An +increasingly common example of this is the WebSocket protocol which sends +a request like + + GET /demo HTTP/1.1 + Upgrade: WebSocket + Connection: Upgrade + Host: example.com + Origin: http://example.com + WebSocket-Protocol: sample + +followed by non-HTTP data. + +(See [RFC6455](https://tools.ietf.org/html/rfc6455) for more information the +WebSocket protocol.) + +To support this, the parser will treat this as a normal HTTP message without a +body, issuing both on_headers_complete and on_message_complete callbacks. However +http_parser_execute() will stop parsing at the end of the headers and return. + +The user is expected to check if `parser->upgrade` has been set to 1 after +`http_parser_execute()` returns. Non-HTTP data begins at the buffer supplied +offset by the return value of `http_parser_execute()`. + + +Callbacks +--------- + +During the `http_parser_execute()` call, the callbacks set in +`http_parser_settings` will be executed. The parser maintains state and +never looks behind, so buffering the data is not necessary. If you need to +save certain data for later usage, you can do that from the callbacks. + +There are two types of callbacks: + +* notification `typedef int (*http_cb) (http_parser*);` + Callbacks: on_message_begin, on_headers_complete, on_message_complete. +* data `typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);` + Callbacks: (requests only) on_url, + (common) on_header_field, on_header_value, on_body; + +Callbacks must return 0 on success. Returning a non-zero value indicates +error to the parser, making it exit immediately. + +For cases where it is necessary to pass local information to/from a callback, +the `http_parser` object's `data` field can be used. +An example of such a case is when using threads to handle a socket connection, +parse a request, and then give a response over that socket. By instantiation +of a thread-local struct containing relevant data (e.g. accepted socket, +allocated memory for callbacks to write into, etc), a parser's callbacks are +able to communicate data between the scope of the thread and the scope of the +callback in a threadsafe manner. This allows `http_parser` to be used in +multi-threaded contexts. + +Example: +```c + typedef struct { + socket_t sock; + void* buffer; + int buf_len; + } custom_data_t; + + +int my_url_callback(http_parser* parser, const char *at, size_t length) { + /* access to thread local custom_data_t struct. + Use this access save parsed data for later use into thread local + buffer, or communicate over socket + */ + parser->data; + ... + return 0; +} + +... + +void http_parser_thread(socket_t sock) { + int nparsed = 0; + /* allocate memory for user data */ + custom_data_t *my_data = malloc(sizeof(custom_data_t)); + + /* some information for use by callbacks. + * achieves thread -> callback information flow */ + my_data->sock = sock; + + /* instantiate a thread-local parser */ + http_parser *parser = malloc(sizeof(http_parser)); + http_parser_init(parser, HTTP_REQUEST); /* initialise parser */ + /* this custom data reference is accessible through the reference to the + parser supplied to callback functions */ + parser->data = my_data; + + http_parser_settings settings; /* set up callbacks */ + settings.on_url = my_url_callback; + + /* execute parser */ + nparsed = http_parser_execute(parser, &settings, buf, recved); + + ... + /* parsed information copied from callback. + can now perform action on data copied into thread-local memory from callbacks. + achieves callback -> thread information flow */ + my_data->buffer; + ... +} + +``` + +In case you parse HTTP message in chunks (i.e. `read()` request line +from socket, parse, read half headers, parse, etc) your data callbacks +may be called more than once. `http_parser` guarantees that data pointer is only +valid for the lifetime of callback. You can also `read()` into a heap allocated +buffer to avoid copying memory around if this fits your application. + +Reading headers may be a tricky task if you read/parse headers partially. +Basically, you need to remember whether last header callback was field or value +and apply the following logic: + + (on_header_field and on_header_value shortened to on_h_*) + ------------------------ ------------ -------------------------------------------- + | State (prev. callback) | Callback | Description/action | + ------------------------ ------------ -------------------------------------------- + | nothing (first call) | on_h_field | Allocate new buffer and copy callback data | + | | | into it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_field | New header started. | + | | | Copy current name,value buffers to headers | + | | | list and allocate new buffer for new name | + ------------------------ ------------ -------------------------------------------- + | field | on_h_field | Previous name continues. Reallocate name | + | | | buffer and append callback data to it | + ------------------------ ------------ -------------------------------------------- + | field | on_h_value | Value for current header started. Allocate | + | | | new buffer and copy callback data to it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_value | Value continues. Reallocate value buffer | + | | | and append callback data to it | + ------------------------ ------------ -------------------------------------------- + + +Parsing URLs +------------ + +A simplistic zero-copy URL parser is provided as `http_parser_parse_url()`. +Users of this library may wish to use it to parse URLs constructed from +consecutive `on_url` callbacks. + +See examples of reading in headers: + +* [partial example](http://gist.github.com/155877) in C +* [from http-parser tests](http://github.com/joyent/http-parser/blob/37a0ff8/test.c#L403) in C +* [from Node library](http://github.com/joyent/node/blob/842eaf4/src/http.js#L284) in Javascript diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/bench.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/bench.c new file mode 100644 index 0000000..678f555 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/bench.c @@ -0,0 +1,128 @@ +/* Copyright Fedor Indutny. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "http_parser.h" +#include +#include +#include +#include +#include + +/* 8 gb */ +static const int64_t kBytes = 8LL << 30; + +static const char data[] = + "POST /joyent/http-parser HTTP/1.1\r\n" + "Host: github.com\r\n" + "DNT: 1\r\n" + "Accept-Encoding: gzip, deflate, sdch\r\n" + "Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4\r\n" + "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/39.0.2171.65 Safari/537.36\r\n" + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9," + "image/webp,*/*;q=0.8\r\n" + "Referer: https://github.com/joyent/http-parser\r\n" + "Connection: keep-alive\r\n" + "Transfer-Encoding: chunked\r\n" + "Cache-Control: max-age=0\r\n\r\nb\r\nhello world\r\n0\r\n"; +static const size_t data_len = sizeof(data) - 1; + +static int on_info(http_parser* p) { + return 0; +} + + +static int on_data(http_parser* p, const char *at, size_t length) { + return 0; +} + +static http_parser_settings settings = { + .on_message_begin = on_info, + .on_headers_complete = on_info, + .on_message_complete = on_info, + .on_header_field = on_data, + .on_header_value = on_data, + .on_url = on_data, + .on_status = on_data, + .on_body = on_data +}; + +int bench(int iter_count, int silent) { + struct http_parser parser; + int i; + int err; + struct timeval start; + struct timeval end; + + if (!silent) { + err = gettimeofday(&start, NULL); + assert(err == 0); + } + + fprintf(stderr, "req_len=%d\n", (int) data_len); + for (i = 0; i < iter_count; i++) { + size_t parsed; + http_parser_init(&parser, HTTP_REQUEST); + + parsed = http_parser_execute(&parser, &settings, data, data_len); + assert(parsed == data_len); + } + + if (!silent) { + double elapsed; + double bw; + double total; + + err = gettimeofday(&end, NULL); + assert(err == 0); + + fprintf(stdout, "Benchmark result:\n"); + + elapsed = (double) (end.tv_sec - start.tv_sec) + + (end.tv_usec - start.tv_usec) * 1e-6f; + + total = (double) iter_count * data_len; + bw = (double) total / elapsed; + + fprintf(stdout, "%.2f mb | %.2f mb/s | %.2f req/sec | %.2f s\n", + (double) total / (1024 * 1024), + bw / (1024 * 1024), + (double) iter_count / elapsed, + elapsed); + + fflush(stdout); + } + + return 0; +} + +int main(int argc, char** argv) { + int64_t iterations; + + iterations = kBytes / (int64_t) data_len; + if (argc == 2 && strcmp(argv[1], "infinite") == 0) { + for (;;) + bench(iterations, 1); + return 0; + } else { + return bench(iterations, 0); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/contrib/parsertrace.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/contrib/parsertrace.c new file mode 100644 index 0000000..3daa7f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/contrib/parsertrace.c @@ -0,0 +1,157 @@ +/* Copyright Joyent, Inc. and other Node contributors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/* Dump what the parser finds to stdout as it happen */ + +#include "http_parser.h" +#include +#include +#include + +int on_message_begin(http_parser* _) { + (void)_; + printf("\n***MESSAGE BEGIN***\n\n"); + return 0; +} + +int on_headers_complete(http_parser* _) { + (void)_; + printf("\n***HEADERS COMPLETE***\n\n"); + return 0; +} + +int on_message_complete(http_parser* _) { + (void)_; + printf("\n***MESSAGE COMPLETE***\n\n"); + return 0; +} + +int on_url(http_parser* _, const char* at, size_t length) { + (void)_; + printf("Url: %.*s\n", (int)length, at); + return 0; +} + +int on_header_field(http_parser* _, const char* at, size_t length) { + (void)_; + printf("Header field: %.*s\n", (int)length, at); + return 0; +} + +int on_header_value(http_parser* _, const char* at, size_t length) { + (void)_; + printf("Header value: %.*s\n", (int)length, at); + return 0; +} + +int on_body(http_parser* _, const char* at, size_t length) { + (void)_; + printf("Body: %.*s\n", (int)length, at); + return 0; +} + +void usage(const char* name) { + fprintf(stderr, + "Usage: %s $type $filename\n" + " type: -x, where x is one of {r,b,q}\n" + " parses file as a Response, reQuest, or Both\n", + name); + exit(EXIT_FAILURE); +} + +int main(int argc, char* argv[]) { + enum http_parser_type file_type; + + if (argc != 3) { + usage(argv[0]); + } + + char* type = argv[1]; + if (type[0] != '-') { + usage(argv[0]); + } + + switch (type[1]) { + /* in the case of "-", type[1] will be NUL */ + case 'r': + file_type = HTTP_RESPONSE; + break; + case 'q': + file_type = HTTP_REQUEST; + break; + case 'b': + file_type = HTTP_BOTH; + break; + default: + usage(argv[0]); + } + + char* filename = argv[2]; + FILE* file = fopen(filename, "r"); + if (file == NULL) { + perror("fopen"); + goto fail; + } + + fseek(file, 0, SEEK_END); + long file_length = ftell(file); + if (file_length == -1) { + perror("ftell"); + goto fail; + } + fseek(file, 0, SEEK_SET); + + char* data = malloc(file_length); + if (fread(data, 1, file_length, file) != (size_t)file_length) { + fprintf(stderr, "couldn't read entire file\n"); + free(data); + goto fail; + } + + http_parser_settings settings; + memset(&settings, 0, sizeof(settings)); + settings.on_message_begin = on_message_begin; + settings.on_url = on_url; + settings.on_header_field = on_header_field; + settings.on_header_value = on_header_value; + settings.on_headers_complete = on_headers_complete; + settings.on_body = on_body; + settings.on_message_complete = on_message_complete; + + http_parser parser; + http_parser_init(&parser, file_type); + size_t nparsed = http_parser_execute(&parser, &settings, data, file_length); + free(data); + + if (nparsed != (size_t)file_length) { + fprintf(stderr, + "Error: %s (%s)\n", + http_errno_description(HTTP_PARSER_ERRNO(&parser)), + http_errno_name(HTTP_PARSER_ERRNO(&parser))); + goto fail; + } + + return EXIT_SUCCESS; + +fail: + fclose(file); + return EXIT_FAILURE; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/contrib/url_parser.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/contrib/url_parser.c new file mode 100644 index 0000000..f235bed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/contrib/url_parser.c @@ -0,0 +1,47 @@ +#include "http_parser.h" +#include +#include + +void +dump_url (const char *url, const struct http_parser_url *u) +{ + unsigned int i; + + printf("\tfield_set: 0x%x, port: %u\n", u->field_set, u->port); + for (i = 0; i < UF_MAX; i++) { + if ((u->field_set & (1 << i)) == 0) { + printf("\tfield_data[%u]: unset\n", i); + continue; + } + + printf("\tfield_data[%u]: off: %u, len: %u, part: %.*s\n", + i, + u->field_data[i].off, + u->field_data[i].len, + u->field_data[i].len, + url + u->field_data[i].off); + } +} + +int main(int argc, char ** argv) { + struct http_parser_url u; + int len, connect, result; + + if (argc != 3) { + printf("Syntax : %s connect|get url\n", argv[0]); + return 1; + } + len = strlen(argv[2]); + connect = strcmp("connect", argv[1]) == 0 ? 1 : 0; + printf("Parsing %s, connect %d\n", argv[2], connect); + + http_parser_url_init(&u); + result = http_parser_parse_url(argv[2], len, connect, &u); + if (result != 0) { + printf("Parse error : %d\n", result); + return result; + } + printf("Parse ok, result : \n"); + dump_url(argv[2], &u); + return 0; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.c new file mode 100644 index 0000000..f9991c3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.c @@ -0,0 +1,2440 @@ +/* Copyright Joyent, Inc. and other Node contributors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "http_parser.h" +#include +#include +#include +#include +#include + +#ifndef ULLONG_MAX +# define ULLONG_MAX ((uint64_t) -1) /* 2^64-1 */ +#endif + +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif + +#ifndef BIT_AT +# define BIT_AT(a, i) \ + (!!((unsigned int) (a)[(unsigned int) (i) >> 3] & \ + (1 << ((unsigned int) (i) & 7)))) +#endif + +#ifndef ELEM_AT +# define ELEM_AT(a, i, v) ((unsigned int) (i) < ARRAY_SIZE(a) ? (a)[(i)] : (v)) +#endif + +#define SET_ERRNO(e) \ +do { \ + parser->http_errno = (e); \ +} while(0) + +#define CURRENT_STATE() p_state +#define UPDATE_STATE(V) p_state = (enum state) (V); +#define RETURN(V) \ +do { \ + parser->state = CURRENT_STATE(); \ + return (V); \ +} while (0); +#define REEXECUTE() \ + goto reexecute; \ + + +#ifdef __GNUC__ +# define LIKELY(X) __builtin_expect(!!(X), 1) +# define UNLIKELY(X) __builtin_expect(!!(X), 0) +#else +# define LIKELY(X) (X) +# define UNLIKELY(X) (X) +#endif + + +/* Run the notify callback FOR, returning ER if it fails */ +#define CALLBACK_NOTIFY_(FOR, ER) \ +do { \ + assert(HTTP_PARSER_ERRNO(parser) == HPE_OK); \ + \ + if (LIKELY(settings->on_##FOR)) { \ + parser->state = CURRENT_STATE(); \ + if (UNLIKELY(0 != settings->on_##FOR(parser))) { \ + SET_ERRNO(HPE_CB_##FOR); \ + } \ + UPDATE_STATE(parser->state); \ + \ + /* We either errored above or got paused; get out */ \ + if (UNLIKELY(HTTP_PARSER_ERRNO(parser) != HPE_OK)) { \ + return (ER); \ + } \ + } \ +} while (0) + +/* Run the notify callback FOR and consume the current byte */ +#define CALLBACK_NOTIFY(FOR) CALLBACK_NOTIFY_(FOR, p - data + 1) + +/* Run the notify callback FOR and don't consume the current byte */ +#define CALLBACK_NOTIFY_NOADVANCE(FOR) CALLBACK_NOTIFY_(FOR, p - data) + +/* Run data callback FOR with LEN bytes, returning ER if it fails */ +#define CALLBACK_DATA_(FOR, LEN, ER) \ +do { \ + assert(HTTP_PARSER_ERRNO(parser) == HPE_OK); \ + \ + if (FOR##_mark) { \ + if (LIKELY(settings->on_##FOR)) { \ + parser->state = CURRENT_STATE(); \ + if (UNLIKELY(0 != \ + settings->on_##FOR(parser, FOR##_mark, (LEN)))) { \ + SET_ERRNO(HPE_CB_##FOR); \ + } \ + UPDATE_STATE(parser->state); \ + \ + /* We either errored above or got paused; get out */ \ + if (UNLIKELY(HTTP_PARSER_ERRNO(parser) != HPE_OK)) { \ + return (ER); \ + } \ + } \ + FOR##_mark = NULL; \ + } \ +} while (0) + +/* Run the data callback FOR and consume the current byte */ +#define CALLBACK_DATA(FOR) \ + CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1) + +/* Run the data callback FOR and don't consume the current byte */ +#define CALLBACK_DATA_NOADVANCE(FOR) \ + CALLBACK_DATA_(FOR, p - FOR##_mark, p - data) + +/* Set the mark FOR; non-destructive if mark is already set */ +#define MARK(FOR) \ +do { \ + if (!FOR##_mark) { \ + FOR##_mark = p; \ + } \ +} while (0) + +/* Don't allow the total size of the HTTP headers (including the status + * line) to exceed HTTP_MAX_HEADER_SIZE. This check is here to protect + * embedders against denial-of-service attacks where the attacker feeds + * us a never-ending header that the embedder keeps buffering. + * + * This check is arguably the responsibility of embedders but we're doing + * it on the embedder's behalf because most won't bother and this way we + * make the web a little safer. HTTP_MAX_HEADER_SIZE is still far bigger + * than any reasonable request or response so this should never affect + * day-to-day operation. + */ +#define COUNT_HEADER_SIZE(V) \ +do { \ + parser->nread += (V); \ + if (UNLIKELY(parser->nread > (HTTP_MAX_HEADER_SIZE))) { \ + SET_ERRNO(HPE_HEADER_OVERFLOW); \ + goto error; \ + } \ +} while (0) + + +#define PROXY_CONNECTION "proxy-connection" +#define CONNECTION "connection" +#define CONTENT_LENGTH "content-length" +#define TRANSFER_ENCODING "transfer-encoding" +#define UPGRADE "upgrade" +#define CHUNKED "chunked" +#define KEEP_ALIVE "keep-alive" +#define CLOSE "close" + + +static const char *method_strings[] = + { +#define XX(num, name, string) #string, + HTTP_METHOD_MAP(XX) +#undef XX + }; + + +/* Tokens as defined by rfc 2616. Also lowercases them. + * token = 1* + * separators = "(" | ")" | "<" | ">" | "@" + * | "," | ";" | ":" | "\" | <"> + * | "/" | "[" | "]" | "?" | "=" + * | "{" | "}" | SP | HT + */ +static const char tokens[256] = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0, '!', 0, '#', '$', '%', '&', '\'', +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 0, 0, '*', '+', 0, '-', '.', 0, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + '0', '1', '2', '3', '4', '5', '6', '7', +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + '8', '9', 0, 0, 0, 0, 0, 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 'x', 'y', 'z', 0, 0, 0, '^', '_', +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 'x', 'y', 'z', 0, '|', 0, '~', 0 }; + + +static const int8_t unhex[256] = + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 + ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 + }; + + +#if HTTP_PARSER_STRICT +# define T(v) 0 +#else +# define T(v) v +#endif + + +static const uint8_t normal_url_char[32] = { +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0 | T(2) | 0 | 0 | T(16) | 0 | 0 | 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0 | 2 | 4 | 0 | 16 | 32 | 64 | 128, +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128, +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 1 | 2 | 4 | 8 | 16 | 32 | 64 | 0, }; + +#undef T + +enum state + { s_dead = 1 /* important that this is > 0 */ + + , s_start_req_or_res + , s_res_or_resp_H + , s_start_res + , s_res_H + , s_res_HT + , s_res_HTT + , s_res_HTTP + , s_res_http_major + , s_res_http_dot + , s_res_http_minor + , s_res_http_end + , s_res_first_status_code + , s_res_status_code + , s_res_status_start + , s_res_status + , s_res_line_almost_done + + , s_start_req + + , s_req_method + , s_req_spaces_before_url + , s_req_schema + , s_req_schema_slash + , s_req_schema_slash_slash + , s_req_server_start + , s_req_server + , s_req_server_with_at + , s_req_path + , s_req_query_string_start + , s_req_query_string + , s_req_fragment_start + , s_req_fragment + , s_req_http_start + , s_req_http_H + , s_req_http_HT + , s_req_http_HTT + , s_req_http_HTTP + , s_req_http_major + , s_req_http_dot + , s_req_http_minor + , s_req_http_end + , s_req_line_almost_done + + , s_header_field_start + , s_header_field + , s_header_value_discard_ws + , s_header_value_discard_ws_almost_done + , s_header_value_discard_lws + , s_header_value_start + , s_header_value + , s_header_value_lws + + , s_header_almost_done + + , s_chunk_size_start + , s_chunk_size + , s_chunk_parameters + , s_chunk_size_almost_done + + , s_headers_almost_done + , s_headers_done + + /* Important: 's_headers_done' must be the last 'header' state. All + * states beyond this must be 'body' states. It is used for overflow + * checking. See the PARSING_HEADER() macro. + */ + + , s_chunk_data + , s_chunk_data_almost_done + , s_chunk_data_done + + , s_body_identity + , s_body_identity_eof + + , s_message_done + }; + + +#define PARSING_HEADER(state) (state <= s_headers_done) + + +enum header_states + { h_general = 0 + , h_C + , h_CO + , h_CON + + , h_matching_connection + , h_matching_proxy_connection + , h_matching_content_length + , h_matching_transfer_encoding + , h_matching_upgrade + + , h_connection + , h_content_length + , h_content_length_num + , h_content_length_ws + , h_transfer_encoding + , h_upgrade + + , h_matching_transfer_encoding_chunked + , h_matching_connection_token_start + , h_matching_connection_keep_alive + , h_matching_connection_close + , h_matching_connection_upgrade + , h_matching_connection_token + + , h_transfer_encoding_chunked + , h_connection_keep_alive + , h_connection_close + , h_connection_upgrade + }; + +enum http_host_state + { + s_http_host_dead = 1 + , s_http_userinfo_start + , s_http_userinfo + , s_http_host_start + , s_http_host_v6_start + , s_http_host + , s_http_host_v6 + , s_http_host_v6_end + , s_http_host_v6_zone_start + , s_http_host_v6_zone + , s_http_host_port_start + , s_http_host_port +}; + +/* Macros for character classes; depends on strict-mode */ +#define CR '\r' +#define LF '\n' +#define LOWER(c) (unsigned char)(c | 0x20) +#define IS_ALPHA(c) (LOWER(c) >= 'a' && LOWER(c) <= 'z') +#define IS_NUM(c) ((c) >= '0' && (c) <= '9') +#define IS_ALPHANUM(c) (IS_ALPHA(c) || IS_NUM(c)) +#define IS_HEX(c) (IS_NUM(c) || (LOWER(c) >= 'a' && LOWER(c) <= 'f')) +#define IS_MARK(c) ((c) == '-' || (c) == '_' || (c) == '.' || \ + (c) == '!' || (c) == '~' || (c) == '*' || (c) == '\'' || (c) == '(' || \ + (c) == ')') +#define IS_USERINFO_CHAR(c) (IS_ALPHANUM(c) || IS_MARK(c) || (c) == '%' || \ + (c) == ';' || (c) == ':' || (c) == '&' || (c) == '=' || (c) == '+' || \ + (c) == '$' || (c) == ',') + +#define STRICT_TOKEN(c) (tokens[(unsigned char)c]) + +#if HTTP_PARSER_STRICT +#define TOKEN(c) (tokens[(unsigned char)c]) +#define IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c)) +#define IS_HOST_CHAR(c) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-') +#else +#define TOKEN(c) ((c == ' ') ? ' ' : tokens[(unsigned char)c]) +#define IS_URL_CHAR(c) \ + (BIT_AT(normal_url_char, (unsigned char)c) || ((c) & 0x80)) +#define IS_HOST_CHAR(c) \ + (IS_ALPHANUM(c) || (c) == '.' || (c) == '-' || (c) == '_') +#endif + +/** + * Verify that a char is a valid visible (printable) US-ASCII + * character or %x80-FF + **/ +#define IS_HEADER_CHAR(ch) \ + (ch == CR || ch == LF || ch == 9 || ((unsigned char)ch > 31 && ch != 127)) + +#define start_state (parser->type == HTTP_REQUEST ? s_start_req : s_start_res) + + +#if HTTP_PARSER_STRICT +# define STRICT_CHECK(cond) \ +do { \ + if (cond) { \ + SET_ERRNO(HPE_STRICT); \ + goto error; \ + } \ +} while (0) +# define NEW_MESSAGE() (http_should_keep_alive(parser) ? start_state : s_dead) +#else +# define STRICT_CHECK(cond) +# define NEW_MESSAGE() start_state +#endif + + +/* Map errno values to strings for human-readable output */ +#define HTTP_STRERROR_GEN(n, s) { "HPE_" #n, s }, +static struct { + const char *name; + const char *description; +} http_strerror_tab[] = { + HTTP_ERRNO_MAP(HTTP_STRERROR_GEN) +}; +#undef HTTP_STRERROR_GEN + +int http_message_needs_eof(const http_parser *parser); + +/* Our URL parser. + * + * This is designed to be shared by http_parser_execute() for URL validation, + * hence it has a state transition + byte-for-byte interface. In addition, it + * is meant to be embedded in http_parser_parse_url(), which does the dirty + * work of turning state transitions URL components for its API. + * + * This function should only be invoked with non-space characters. It is + * assumed that the caller cares about (and can detect) the transition between + * URL and non-URL states by looking for these. + */ +static enum state +parse_url_char(enum state s, const char ch) +{ + if (ch == ' ' || ch == '\r' || ch == '\n') { + return s_dead; + } + +#if HTTP_PARSER_STRICT + if (ch == '\t' || ch == '\f') { + return s_dead; + } +#endif + + switch (s) { + case s_req_spaces_before_url: + /* Proxied requests are followed by scheme of an absolute URI (alpha). + * All methods except CONNECT are followed by '/' or '*'. + */ + + if (ch == '/' || ch == '*') { + return s_req_path; + } + + if (IS_ALPHA(ch)) { + return s_req_schema; + } + + break; + + case s_req_schema: + if (IS_ALPHA(ch)) { + return s; + } + + if (ch == ':') { + return s_req_schema_slash; + } + + break; + + case s_req_schema_slash: + if (ch == '/') { + return s_req_schema_slash_slash; + } + + break; + + case s_req_schema_slash_slash: + if (ch == '/') { + return s_req_server_start; + } + + break; + + case s_req_server_with_at: + if (ch == '@') { + return s_dead; + } + + /* FALLTHROUGH */ + case s_req_server_start: + case s_req_server: + if (ch == '/') { + return s_req_path; + } + + if (ch == '?') { + return s_req_query_string_start; + } + + if (ch == '@') { + return s_req_server_with_at; + } + + if (IS_USERINFO_CHAR(ch) || ch == '[' || ch == ']') { + return s_req_server; + } + + break; + + case s_req_path: + if (IS_URL_CHAR(ch)) { + return s; + } + + switch (ch) { + case '?': + return s_req_query_string_start; + + case '#': + return s_req_fragment_start; + } + + break; + + case s_req_query_string_start: + case s_req_query_string: + if (IS_URL_CHAR(ch)) { + return s_req_query_string; + } + + switch (ch) { + case '?': + /* allow extra '?' in query string */ + return s_req_query_string; + + case '#': + return s_req_fragment_start; + } + + break; + + case s_req_fragment_start: + if (IS_URL_CHAR(ch)) { + return s_req_fragment; + } + + switch (ch) { + case '?': + return s_req_fragment; + + case '#': + return s; + } + + break; + + case s_req_fragment: + if (IS_URL_CHAR(ch)) { + return s; + } + + switch (ch) { + case '?': + case '#': + return s; + } + + break; + + default: + break; + } + + /* We should never fall out of the switch above unless there's an error */ + return s_dead; +} + +size_t http_parser_execute (http_parser *parser, + const http_parser_settings *settings, + const char *data, + size_t len) +{ + char c, ch; + int8_t unhex_val; + const char *p = data; + const char *header_field_mark = 0; + const char *header_value_mark = 0; + const char *url_mark = 0; + const char *body_mark = 0; + const char *status_mark = 0; + enum state p_state = (enum state) parser->state; + const unsigned int lenient = parser->lenient_http_headers; + + /* We're in an error state. Don't bother doing anything. */ + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { + return 0; + } + + if (len == 0) { + switch (CURRENT_STATE()) { + case s_body_identity_eof: + /* Use of CALLBACK_NOTIFY() here would erroneously return 1 byte read if + * we got paused. + */ + CALLBACK_NOTIFY_NOADVANCE(message_complete); + return 0; + + case s_dead: + case s_start_req_or_res: + case s_start_res: + case s_start_req: + return 0; + + default: + SET_ERRNO(HPE_INVALID_EOF_STATE); + return 1; + } + } + + + if (CURRENT_STATE() == s_header_field) + header_field_mark = data; + if (CURRENT_STATE() == s_header_value) + header_value_mark = data; + switch (CURRENT_STATE()) { + case s_req_path: + case s_req_schema: + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + case s_req_server: + case s_req_server_with_at: + case s_req_query_string_start: + case s_req_query_string: + case s_req_fragment_start: + case s_req_fragment: + url_mark = data; + break; + case s_res_status: + status_mark = data; + break; + default: + break; + } + + for (p=data; p != data + len; p++) { + ch = *p; + + if (PARSING_HEADER(CURRENT_STATE())) + COUNT_HEADER_SIZE(1); + +reexecute: + switch (CURRENT_STATE()) { + + case s_dead: + /* this state is used after a 'Connection: close' message + * the parser will error out if it reads another message + */ + if (LIKELY(ch == CR || ch == LF)) + break; + + SET_ERRNO(HPE_CLOSED_CONNECTION); + goto error; + + case s_start_req_or_res: + { + if (ch == CR || ch == LF) + break; + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + if (ch == 'H') { + UPDATE_STATE(s_res_or_resp_H); + + CALLBACK_NOTIFY(message_begin); + } else { + parser->type = HTTP_REQUEST; + UPDATE_STATE(s_start_req); + REEXECUTE(); + } + + break; + } + + case s_res_or_resp_H: + if (ch == 'T') { + parser->type = HTTP_RESPONSE; + UPDATE_STATE(s_res_HT); + } else { + if (UNLIKELY(ch != 'E')) { + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + + parser->type = HTTP_REQUEST; + parser->method = HTTP_HEAD; + parser->index = 2; + UPDATE_STATE(s_req_method); + } + break; + + case s_start_res: + { + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + switch (ch) { + case 'H': + UPDATE_STATE(s_res_H); + break; + + case CR: + case LF: + break; + + default: + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + + CALLBACK_NOTIFY(message_begin); + break; + } + + case s_res_H: + STRICT_CHECK(ch != 'T'); + UPDATE_STATE(s_res_HT); + break; + + case s_res_HT: + STRICT_CHECK(ch != 'T'); + UPDATE_STATE(s_res_HTT); + break; + + case s_res_HTT: + STRICT_CHECK(ch != 'P'); + UPDATE_STATE(s_res_HTTP); + break; + + case s_res_HTTP: + STRICT_CHECK(ch != '/'); + UPDATE_STATE(s_res_http_major); + break; + + case s_res_http_major: + if (UNLIKELY(!IS_NUM(ch))) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major = ch - '0'; + UPDATE_STATE(s_res_http_dot); + break; + + case s_res_http_dot: + { + if (UNLIKELY(ch != '.')) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + UPDATE_STATE(s_res_http_minor); + break; + } + + case s_res_http_minor: + if (UNLIKELY(!IS_NUM(ch))) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor = ch - '0'; + UPDATE_STATE(s_res_http_end); + break; + + case s_res_http_end: + { + if (UNLIKELY(ch != ' ')) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + UPDATE_STATE(s_res_first_status_code); + break; + } + + case s_res_first_status_code: + { + if (!IS_NUM(ch)) { + if (ch == ' ') { + break; + } + + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + parser->status_code = ch - '0'; + UPDATE_STATE(s_res_status_code); + break; + } + + case s_res_status_code: + { + if (!IS_NUM(ch)) { + switch (ch) { + case ' ': + UPDATE_STATE(s_res_status_start); + break; + case CR: + case LF: + UPDATE_STATE(s_res_status_start); + REEXECUTE(); + break; + default: + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + break; + } + + parser->status_code *= 10; + parser->status_code += ch - '0'; + + if (UNLIKELY(parser->status_code > 999)) { + SET_ERRNO(HPE_INVALID_STATUS); + goto error; + } + + break; + } + + case s_res_status_start: + { + MARK(status); + UPDATE_STATE(s_res_status); + parser->index = 0; + + if (ch == CR || ch == LF) + REEXECUTE(); + + break; + } + + case s_res_status: + if (ch == CR) { + UPDATE_STATE(s_res_line_almost_done); + CALLBACK_DATA(status); + break; + } + + if (ch == LF) { + UPDATE_STATE(s_header_field_start); + CALLBACK_DATA(status); + break; + } + + break; + + case s_res_line_almost_done: + STRICT_CHECK(ch != LF); + UPDATE_STATE(s_header_field_start); + break; + + case s_start_req: + { + if (ch == CR || ch == LF) + break; + parser->flags = 0; + parser->content_length = ULLONG_MAX; + + if (UNLIKELY(!IS_ALPHA(ch))) { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + parser->method = (enum http_method) 0; + parser->index = 1; + switch (ch) { + case 'A': parser->method = HTTP_ACL; break; + case 'B': parser->method = HTTP_BIND; break; + case 'C': parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT */ break; + case 'D': parser->method = HTTP_DELETE; break; + case 'G': parser->method = HTTP_GET; break; + case 'H': parser->method = HTTP_HEAD; break; + case 'L': parser->method = HTTP_LOCK; /* or LINK */ break; + case 'M': parser->method = HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH, MKCALENDAR */ break; + case 'N': parser->method = HTTP_NOTIFY; break; + case 'O': parser->method = HTTP_OPTIONS; break; + case 'P': parser->method = HTTP_POST; + /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ + break; + case 'R': parser->method = HTTP_REPORT; /* or REBIND */ break; + case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH, SOURCE */ break; + case 'T': parser->method = HTTP_TRACE; break; + case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE, UNBIND, UNLINK */ break; + default: + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + UPDATE_STATE(s_req_method); + + CALLBACK_NOTIFY(message_begin); + + break; + } + + case s_req_method: + { + const char *matcher; + if (UNLIKELY(ch == '\0')) { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + matcher = method_strings[parser->method]; + if (ch == ' ' && matcher[parser->index] == '\0') { + UPDATE_STATE(s_req_spaces_before_url); + } else if (ch == matcher[parser->index]) { + ; /* nada */ + } else if ((ch >= 'A' && ch <= 'Z') || ch == '-') { + + switch (parser->method << 16 | parser->index << 8 | ch) { +#define XX(meth, pos, ch, new_meth) \ + case (HTTP_##meth << 16 | pos << 8 | ch): \ + parser->method = HTTP_##new_meth; break; + + XX(POST, 1, 'U', PUT) + XX(POST, 1, 'A', PATCH) + XX(POST, 1, 'R', PROPFIND) + XX(PUT, 2, 'R', PURGE) + XX(CONNECT, 1, 'H', CHECKOUT) + XX(CONNECT, 2, 'P', COPY) + XX(MKCOL, 1, 'O', MOVE) + XX(MKCOL, 1, 'E', MERGE) + XX(MKCOL, 1, '-', MSEARCH) + XX(MKCOL, 2, 'A', MKACTIVITY) + XX(MKCOL, 3, 'A', MKCALENDAR) + XX(SUBSCRIBE, 1, 'E', SEARCH) + XX(SUBSCRIBE, 1, 'O', SOURCE) + XX(REPORT, 2, 'B', REBIND) + XX(PROPFIND, 4, 'P', PROPPATCH) + XX(LOCK, 1, 'I', LINK) + XX(UNLOCK, 2, 'S', UNSUBSCRIBE) + XX(UNLOCK, 2, 'B', UNBIND) + XX(UNLOCK, 3, 'I', UNLINK) +#undef XX + default: + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + } else { + SET_ERRNO(HPE_INVALID_METHOD); + goto error; + } + + ++parser->index; + break; + } + + case s_req_spaces_before_url: + { + if (ch == ' ') break; + + MARK(url); + if (parser->method == HTTP_CONNECT) { + UPDATE_STATE(s_req_server_start); + } + + UPDATE_STATE(parse_url_char(CURRENT_STATE(), ch)); + if (UNLIKELY(CURRENT_STATE() == s_dead)) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + + break; + } + + case s_req_schema: + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + { + switch (ch) { + /* No whitespace allowed here */ + case ' ': + case CR: + case LF: + SET_ERRNO(HPE_INVALID_URL); + goto error; + default: + UPDATE_STATE(parse_url_char(CURRENT_STATE(), ch)); + if (UNLIKELY(CURRENT_STATE() == s_dead)) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + } + + break; + } + + case s_req_server: + case s_req_server_with_at: + case s_req_path: + case s_req_query_string_start: + case s_req_query_string: + case s_req_fragment_start: + case s_req_fragment: + { + switch (ch) { + case ' ': + UPDATE_STATE(s_req_http_start); + CALLBACK_DATA(url); + break; + case CR: + case LF: + parser->http_major = 0; + parser->http_minor = 9; + UPDATE_STATE((ch == CR) ? + s_req_line_almost_done : + s_header_field_start); + CALLBACK_DATA(url); + break; + default: + UPDATE_STATE(parse_url_char(CURRENT_STATE(), ch)); + if (UNLIKELY(CURRENT_STATE() == s_dead)) { + SET_ERRNO(HPE_INVALID_URL); + goto error; + } + } + break; + } + + case s_req_http_start: + switch (ch) { + case 'H': + UPDATE_STATE(s_req_http_H); + break; + case ' ': + break; + default: + SET_ERRNO(HPE_INVALID_CONSTANT); + goto error; + } + break; + + case s_req_http_H: + STRICT_CHECK(ch != 'T'); + UPDATE_STATE(s_req_http_HT); + break; + + case s_req_http_HT: + STRICT_CHECK(ch != 'T'); + UPDATE_STATE(s_req_http_HTT); + break; + + case s_req_http_HTT: + STRICT_CHECK(ch != 'P'); + UPDATE_STATE(s_req_http_HTTP); + break; + + case s_req_http_HTTP: + STRICT_CHECK(ch != '/'); + UPDATE_STATE(s_req_http_major); + break; + + case s_req_http_major: + if (UNLIKELY(!IS_NUM(ch))) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_major = ch - '0'; + UPDATE_STATE(s_req_http_dot); + break; + + case s_req_http_dot: + { + if (UNLIKELY(ch != '.')) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + UPDATE_STATE(s_req_http_minor); + break; + } + + case s_req_http_minor: + if (UNLIKELY(!IS_NUM(ch))) { + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + } + + parser->http_minor = ch - '0'; + UPDATE_STATE(s_req_http_end); + break; + + case s_req_http_end: + { + if (ch == CR) { + UPDATE_STATE(s_req_line_almost_done); + break; + } + + if (ch == LF) { + UPDATE_STATE(s_header_field_start); + break; + } + + SET_ERRNO(HPE_INVALID_VERSION); + goto error; + break; + } + + /* end of request line */ + case s_req_line_almost_done: + { + if (UNLIKELY(ch != LF)) { + SET_ERRNO(HPE_LF_EXPECTED); + goto error; + } + + UPDATE_STATE(s_header_field_start); + break; + } + + case s_header_field_start: + { + if (ch == CR) { + UPDATE_STATE(s_headers_almost_done); + break; + } + + if (ch == LF) { + /* they might be just sending \n instead of \r\n so this would be + * the second \n to denote the end of headers*/ + UPDATE_STATE(s_headers_almost_done); + REEXECUTE(); + } + + c = TOKEN(ch); + + if (UNLIKELY(!c)) { + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + + MARK(header_field); + + parser->index = 0; + UPDATE_STATE(s_header_field); + + switch (c) { + case 'c': + parser->header_state = h_C; + break; + + case 'p': + parser->header_state = h_matching_proxy_connection; + break; + + case 't': + parser->header_state = h_matching_transfer_encoding; + break; + + case 'u': + parser->header_state = h_matching_upgrade; + break; + + default: + parser->header_state = h_general; + break; + } + break; + } + + case s_header_field: + { + const char* start = p; + for (; p != data + len; p++) { + ch = *p; + c = TOKEN(ch); + + if (!c) + break; + + switch (parser->header_state) { + case h_general: + break; + + case h_C: + parser->index++; + parser->header_state = (c == 'o' ? h_CO : h_general); + break; + + case h_CO: + parser->index++; + parser->header_state = (c == 'n' ? h_CON : h_general); + break; + + case h_CON: + parser->index++; + switch (c) { + case 'n': + parser->header_state = h_matching_connection; + break; + case 't': + parser->header_state = h_matching_content_length; + break; + default: + parser->header_state = h_general; + break; + } + break; + + /* connection */ + + case h_matching_connection: + parser->index++; + if (parser->index > sizeof(CONNECTION)-1 + || c != CONNECTION[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONNECTION)-2) { + parser->header_state = h_connection; + } + break; + + /* proxy-connection */ + + case h_matching_proxy_connection: + parser->index++; + if (parser->index > sizeof(PROXY_CONNECTION)-1 + || c != PROXY_CONNECTION[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(PROXY_CONNECTION)-2) { + parser->header_state = h_connection; + } + break; + + /* content-length */ + + case h_matching_content_length: + parser->index++; + if (parser->index > sizeof(CONTENT_LENGTH)-1 + || c != CONTENT_LENGTH[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONTENT_LENGTH)-2) { + parser->header_state = h_content_length; + } + break; + + /* transfer-encoding */ + + case h_matching_transfer_encoding: + parser->index++; + if (parser->index > sizeof(TRANSFER_ENCODING)-1 + || c != TRANSFER_ENCODING[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(TRANSFER_ENCODING)-2) { + parser->header_state = h_transfer_encoding; + } + break; + + /* upgrade */ + + case h_matching_upgrade: + parser->index++; + if (parser->index > sizeof(UPGRADE)-1 + || c != UPGRADE[parser->index]) { + parser->header_state = h_general; + } else if (parser->index == sizeof(UPGRADE)-2) { + parser->header_state = h_upgrade; + } + break; + + case h_connection: + case h_content_length: + case h_transfer_encoding: + case h_upgrade: + if (ch != ' ') parser->header_state = h_general; + break; + + default: + assert(0 && "Unknown header_state"); + break; + } + } + + COUNT_HEADER_SIZE(p - start); + + if (p == data + len) { + --p; + break; + } + + if (ch == ':') { + UPDATE_STATE(s_header_value_discard_ws); + CALLBACK_DATA(header_field); + break; + } + + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + + case s_header_value_discard_ws: + if (ch == ' ' || ch == '\t') break; + + if (ch == CR) { + UPDATE_STATE(s_header_value_discard_ws_almost_done); + break; + } + + if (ch == LF) { + UPDATE_STATE(s_header_value_discard_lws); + break; + } + + /* FALLTHROUGH */ + + case s_header_value_start: + { + MARK(header_value); + + UPDATE_STATE(s_header_value); + parser->index = 0; + + c = LOWER(ch); + + switch (parser->header_state) { + case h_upgrade: + parser->flags |= F_UPGRADE; + parser->header_state = h_general; + break; + + case h_transfer_encoding: + /* looking for 'Transfer-Encoding: chunked' */ + if ('c' == c) { + parser->header_state = h_matching_transfer_encoding_chunked; + } else { + parser->header_state = h_general; + } + break; + + case h_content_length: + if (UNLIKELY(!IS_NUM(ch))) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + if (parser->flags & F_CONTENTLENGTH) { + SET_ERRNO(HPE_UNEXPECTED_CONTENT_LENGTH); + goto error; + } + + parser->flags |= F_CONTENTLENGTH; + parser->content_length = ch - '0'; + parser->header_state = h_content_length_num; + break; + + case h_connection: + /* looking for 'Connection: keep-alive' */ + if (c == 'k') { + parser->header_state = h_matching_connection_keep_alive; + /* looking for 'Connection: close' */ + } else if (c == 'c') { + parser->header_state = h_matching_connection_close; + } else if (c == 'u') { + parser->header_state = h_matching_connection_upgrade; + } else { + parser->header_state = h_matching_connection_token; + } + break; + + /* Multi-value `Connection` header */ + case h_matching_connection_token_start: + break; + + default: + parser->header_state = h_general; + break; + } + break; + } + + case s_header_value: + { + const char* start = p; + enum header_states h_state = (enum header_states) parser->header_state; + for (; p != data + len; p++) { + ch = *p; + if (ch == CR) { + UPDATE_STATE(s_header_almost_done); + parser->header_state = h_state; + CALLBACK_DATA(header_value); + break; + } + + if (ch == LF) { + UPDATE_STATE(s_header_almost_done); + COUNT_HEADER_SIZE(p - start); + parser->header_state = h_state; + CALLBACK_DATA_NOADVANCE(header_value); + REEXECUTE(); + } + + if (!lenient && !IS_HEADER_CHAR(ch)) { + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + + c = LOWER(ch); + + switch (h_state) { + case h_general: + { + const char* p_cr; + const char* p_lf; + size_t limit = data + len - p; + + limit = MIN(limit, HTTP_MAX_HEADER_SIZE); + + p_cr = (const char*) memchr(p, CR, limit); + p_lf = (const char*) memchr(p, LF, limit); + if (p_cr != NULL) { + if (p_lf != NULL && p_cr >= p_lf) + p = p_lf; + else + p = p_cr; + } else if (UNLIKELY(p_lf != NULL)) { + p = p_lf; + } else { + p = data + len; + } + --p; + + break; + } + + case h_connection: + case h_transfer_encoding: + assert(0 && "Shouldn't get here."); + break; + + case h_content_length: + if (ch == ' ') break; + h_state = h_content_length_num; + /* FALLTHROUGH */ + + case h_content_length_num: + { + uint64_t t; + + if (ch == ' ') { + h_state = h_content_length_ws; + break; + } + + if (UNLIKELY(!IS_NUM(ch))) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + parser->header_state = h_state; + goto error; + } + + t = parser->content_length; + t *= 10; + t += ch - '0'; + + /* Overflow? Test against a conservative limit for simplicity. */ + if (UNLIKELY((ULLONG_MAX - 10) / 10 < parser->content_length)) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + parser->header_state = h_state; + goto error; + } + + parser->content_length = t; + break; + } + + case h_content_length_ws: + if (ch == ' ') break; + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + parser->header_state = h_state; + goto error; + + /* Transfer-Encoding: chunked */ + case h_matching_transfer_encoding_chunked: + parser->index++; + if (parser->index > sizeof(CHUNKED)-1 + || c != CHUNKED[parser->index]) { + h_state = h_general; + } else if (parser->index == sizeof(CHUNKED)-2) { + h_state = h_transfer_encoding_chunked; + } + break; + + case h_matching_connection_token_start: + /* looking for 'Connection: keep-alive' */ + if (c == 'k') { + h_state = h_matching_connection_keep_alive; + /* looking for 'Connection: close' */ + } else if (c == 'c') { + h_state = h_matching_connection_close; + } else if (c == 'u') { + h_state = h_matching_connection_upgrade; + } else if (STRICT_TOKEN(c)) { + h_state = h_matching_connection_token; + } else if (c == ' ' || c == '\t') { + /* Skip lws */ + } else { + h_state = h_general; + } + break; + + /* looking for 'Connection: keep-alive' */ + case h_matching_connection_keep_alive: + parser->index++; + if (parser->index > sizeof(KEEP_ALIVE)-1 + || c != KEEP_ALIVE[parser->index]) { + h_state = h_matching_connection_token; + } else if (parser->index == sizeof(KEEP_ALIVE)-2) { + h_state = h_connection_keep_alive; + } + break; + + /* looking for 'Connection: close' */ + case h_matching_connection_close: + parser->index++; + if (parser->index > sizeof(CLOSE)-1 || c != CLOSE[parser->index]) { + h_state = h_matching_connection_token; + } else if (parser->index == sizeof(CLOSE)-2) { + h_state = h_connection_close; + } + break; + + /* looking for 'Connection: upgrade' */ + case h_matching_connection_upgrade: + parser->index++; + if (parser->index > sizeof(UPGRADE) - 1 || + c != UPGRADE[parser->index]) { + h_state = h_matching_connection_token; + } else if (parser->index == sizeof(UPGRADE)-2) { + h_state = h_connection_upgrade; + } + break; + + case h_matching_connection_token: + if (ch == ',') { + h_state = h_matching_connection_token_start; + parser->index = 0; + } + break; + + case h_transfer_encoding_chunked: + if (ch != ' ') h_state = h_general; + break; + + case h_connection_keep_alive: + case h_connection_close: + case h_connection_upgrade: + if (ch == ',') { + if (h_state == h_connection_keep_alive) { + parser->flags |= F_CONNECTION_KEEP_ALIVE; + } else if (h_state == h_connection_close) { + parser->flags |= F_CONNECTION_CLOSE; + } else if (h_state == h_connection_upgrade) { + parser->flags |= F_CONNECTION_UPGRADE; + } + h_state = h_matching_connection_token_start; + parser->index = 0; + } else if (ch != ' ') { + h_state = h_matching_connection_token; + } + break; + + default: + UPDATE_STATE(s_header_value); + h_state = h_general; + break; + } + } + parser->header_state = h_state; + + COUNT_HEADER_SIZE(p - start); + + if (p == data + len) + --p; + break; + } + + case s_header_almost_done: + { + if (UNLIKELY(ch != LF)) { + SET_ERRNO(HPE_LF_EXPECTED); + goto error; + } + + UPDATE_STATE(s_header_value_lws); + break; + } + + case s_header_value_lws: + { + if (ch == ' ' || ch == '\t') { + UPDATE_STATE(s_header_value_start); + REEXECUTE(); + } + + /* finished the header */ + switch (parser->header_state) { + case h_connection_keep_alive: + parser->flags |= F_CONNECTION_KEEP_ALIVE; + break; + case h_connection_close: + parser->flags |= F_CONNECTION_CLOSE; + break; + case h_transfer_encoding_chunked: + parser->flags |= F_CHUNKED; + break; + case h_connection_upgrade: + parser->flags |= F_CONNECTION_UPGRADE; + break; + default: + break; + } + + UPDATE_STATE(s_header_field_start); + REEXECUTE(); + } + + case s_header_value_discard_ws_almost_done: + { + STRICT_CHECK(ch != LF); + UPDATE_STATE(s_header_value_discard_lws); + break; + } + + case s_header_value_discard_lws: + { + if (ch == ' ' || ch == '\t') { + UPDATE_STATE(s_header_value_discard_ws); + break; + } else { + switch (parser->header_state) { + case h_connection_keep_alive: + parser->flags |= F_CONNECTION_KEEP_ALIVE; + break; + case h_connection_close: + parser->flags |= F_CONNECTION_CLOSE; + break; + case h_connection_upgrade: + parser->flags |= F_CONNECTION_UPGRADE; + break; + case h_transfer_encoding_chunked: + parser->flags |= F_CHUNKED; + break; + default: + break; + } + + /* header value was empty */ + MARK(header_value); + UPDATE_STATE(s_header_field_start); + CALLBACK_DATA_NOADVANCE(header_value); + REEXECUTE(); + } + } + + case s_headers_almost_done: + { + STRICT_CHECK(ch != LF); + + if (parser->flags & F_TRAILING) { + /* End of a chunked request */ + UPDATE_STATE(s_message_done); + CALLBACK_NOTIFY_NOADVANCE(chunk_complete); + REEXECUTE(); + } + + /* Cannot use chunked encoding and a content-length header together + per the HTTP specification. */ + if ((parser->flags & F_CHUNKED) && + (parser->flags & F_CONTENTLENGTH)) { + SET_ERRNO(HPE_UNEXPECTED_CONTENT_LENGTH); + goto error; + } + + UPDATE_STATE(s_headers_done); + + /* Set this here so that on_headers_complete() callbacks can see it */ + if ((parser->flags & F_UPGRADE) && + (parser->flags & F_CONNECTION_UPGRADE)) { + /* For responses, "Upgrade: foo" and "Connection: upgrade" are + * mandatory only when it is a 101 Switching Protocols response, + * otherwise it is purely informational, to announce support. + */ + parser->upgrade = + (parser->type == HTTP_REQUEST || parser->status_code == 101); + } else { + parser->upgrade = (parser->method == HTTP_CONNECT); + } + + /* Here we call the headers_complete callback. This is somewhat + * different than other callbacks because if the user returns 1, we + * will interpret that as saying that this message has no body. This + * is needed for the annoying case of recieving a response to a HEAD + * request. + * + * We'd like to use CALLBACK_NOTIFY_NOADVANCE() here but we cannot, so + * we have to simulate it by handling a change in errno below. + */ + if (settings->on_headers_complete) { + switch (settings->on_headers_complete(parser)) { + case 0: + break; + + case 2: + parser->upgrade = 1; + + /* FALLTHROUGH */ + case 1: + parser->flags |= F_SKIPBODY; + break; + + default: + SET_ERRNO(HPE_CB_headers_complete); + RETURN(p - data); /* Error */ + } + } + + if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { + RETURN(p - data); + } + + REEXECUTE(); + } + + case s_headers_done: + { + int hasBody; + STRICT_CHECK(ch != LF); + + parser->nread = 0; + + hasBody = parser->flags & F_CHUNKED || + (parser->content_length > 0 && parser->content_length != ULLONG_MAX); + if (parser->upgrade && (parser->method == HTTP_CONNECT || + (parser->flags & F_SKIPBODY) || !hasBody)) { + /* Exit, the rest of the message is in a different protocol. */ + UPDATE_STATE(NEW_MESSAGE()); + CALLBACK_NOTIFY(message_complete); + RETURN((p - data) + 1); + } + + if (parser->flags & F_SKIPBODY) { + UPDATE_STATE(NEW_MESSAGE()); + CALLBACK_NOTIFY(message_complete); + } else if (parser->flags & F_CHUNKED) { + /* chunked encoding - ignore Content-Length header */ + UPDATE_STATE(s_chunk_size_start); + } else { + if (parser->content_length == 0) { + /* Content-Length header given but zero: Content-Length: 0\r\n */ + UPDATE_STATE(NEW_MESSAGE()); + CALLBACK_NOTIFY(message_complete); + } else if (parser->content_length != ULLONG_MAX) { + /* Content-Length header given and non-zero */ + UPDATE_STATE(s_body_identity); + } else { + if (!http_message_needs_eof(parser)) { + /* Assume content-length 0 - read the next */ + UPDATE_STATE(NEW_MESSAGE()); + CALLBACK_NOTIFY(message_complete); + } else { + /* Read body until EOF */ + UPDATE_STATE(s_body_identity_eof); + } + } + } + + break; + } + + case s_body_identity: + { + uint64_t to_read = MIN(parser->content_length, + (uint64_t) ((data + len) - p)); + + assert(parser->content_length != 0 + && parser->content_length != ULLONG_MAX); + + /* The difference between advancing content_length and p is because + * the latter will automaticaly advance on the next loop iteration. + * Further, if content_length ends up at 0, we want to see the last + * byte again for our message complete callback. + */ + MARK(body); + parser->content_length -= to_read; + p += to_read - 1; + + if (parser->content_length == 0) { + UPDATE_STATE(s_message_done); + + /* Mimic CALLBACK_DATA_NOADVANCE() but with one extra byte. + * + * The alternative to doing this is to wait for the next byte to + * trigger the data callback, just as in every other case. The + * problem with this is that this makes it difficult for the test + * harness to distinguish between complete-on-EOF and + * complete-on-length. It's not clear that this distinction is + * important for applications, but let's keep it for now. + */ + CALLBACK_DATA_(body, p - body_mark + 1, p - data); + REEXECUTE(); + } + + break; + } + + /* read until EOF */ + case s_body_identity_eof: + MARK(body); + p = data + len - 1; + + break; + + case s_message_done: + UPDATE_STATE(NEW_MESSAGE()); + CALLBACK_NOTIFY(message_complete); + if (parser->upgrade) { + /* Exit, the rest of the message is in a different protocol. */ + RETURN((p - data) + 1); + } + break; + + case s_chunk_size_start: + { + assert(parser->nread == 1); + assert(parser->flags & F_CHUNKED); + + unhex_val = unhex[(unsigned char)ch]; + if (UNLIKELY(unhex_val == -1)) { + SET_ERRNO(HPE_INVALID_CHUNK_SIZE); + goto error; + } + + parser->content_length = unhex_val; + UPDATE_STATE(s_chunk_size); + break; + } + + case s_chunk_size: + { + uint64_t t; + + assert(parser->flags & F_CHUNKED); + + if (ch == CR) { + UPDATE_STATE(s_chunk_size_almost_done); + break; + } + + unhex_val = unhex[(unsigned char)ch]; + + if (unhex_val == -1) { + if (ch == ';' || ch == ' ') { + UPDATE_STATE(s_chunk_parameters); + break; + } + + SET_ERRNO(HPE_INVALID_CHUNK_SIZE); + goto error; + } + + t = parser->content_length; + t *= 16; + t += unhex_val; + + /* Overflow? Test against a conservative limit for simplicity. */ + if (UNLIKELY((ULLONG_MAX - 16) / 16 < parser->content_length)) { + SET_ERRNO(HPE_INVALID_CONTENT_LENGTH); + goto error; + } + + parser->content_length = t; + break; + } + + case s_chunk_parameters: + { + assert(parser->flags & F_CHUNKED); + /* just ignore this shit. TODO check for overflow */ + if (ch == CR) { + UPDATE_STATE(s_chunk_size_almost_done); + break; + } + break; + } + + case s_chunk_size_almost_done: + { + assert(parser->flags & F_CHUNKED); + STRICT_CHECK(ch != LF); + + parser->nread = 0; + + if (parser->content_length == 0) { + parser->flags |= F_TRAILING; + UPDATE_STATE(s_header_field_start); + } else { + UPDATE_STATE(s_chunk_data); + } + CALLBACK_NOTIFY(chunk_header); + break; + } + + case s_chunk_data: + { + uint64_t to_read = MIN(parser->content_length, + (uint64_t) ((data + len) - p)); + + assert(parser->flags & F_CHUNKED); + assert(parser->content_length != 0 + && parser->content_length != ULLONG_MAX); + + /* See the explanation in s_body_identity for why the content + * length and data pointers are managed this way. + */ + MARK(body); + parser->content_length -= to_read; + p += to_read - 1; + + if (parser->content_length == 0) { + UPDATE_STATE(s_chunk_data_almost_done); + } + + break; + } + + case s_chunk_data_almost_done: + assert(parser->flags & F_CHUNKED); + assert(parser->content_length == 0); + STRICT_CHECK(ch != CR); + UPDATE_STATE(s_chunk_data_done); + CALLBACK_DATA(body); + break; + + case s_chunk_data_done: + assert(parser->flags & F_CHUNKED); + STRICT_CHECK(ch != LF); + parser->nread = 0; + UPDATE_STATE(s_chunk_size_start); + CALLBACK_NOTIFY(chunk_complete); + break; + + default: + assert(0 && "unhandled state"); + SET_ERRNO(HPE_INVALID_INTERNAL_STATE); + goto error; + } + } + + /* Run callbacks for any marks that we have leftover after we ran our of + * bytes. There should be at most one of these set, so it's OK to invoke + * them in series (unset marks will not result in callbacks). + * + * We use the NOADVANCE() variety of callbacks here because 'p' has already + * overflowed 'data' and this allows us to correct for the off-by-one that + * we'd otherwise have (since CALLBACK_DATA() is meant to be run with a 'p' + * value that's in-bounds). + */ + + assert(((header_field_mark ? 1 : 0) + + (header_value_mark ? 1 : 0) + + (url_mark ? 1 : 0) + + (body_mark ? 1 : 0) + + (status_mark ? 1 : 0)) <= 1); + + CALLBACK_DATA_NOADVANCE(header_field); + CALLBACK_DATA_NOADVANCE(header_value); + CALLBACK_DATA_NOADVANCE(url); + CALLBACK_DATA_NOADVANCE(body); + CALLBACK_DATA_NOADVANCE(status); + + RETURN(len); + +error: + if (HTTP_PARSER_ERRNO(parser) == HPE_OK) { + SET_ERRNO(HPE_UNKNOWN); + } + + RETURN(p - data); +} + + +/* Does the parser need to see an EOF to find the end of the message? */ +int +http_message_needs_eof (const http_parser *parser) +{ + if (parser->type == HTTP_REQUEST) { + return 0; + } + + /* See RFC 2616 section 4.4 */ + if (parser->status_code / 100 == 1 || /* 1xx e.g. Continue */ + parser->status_code == 204 || /* No Content */ + parser->status_code == 304 || /* Not Modified */ + parser->flags & F_SKIPBODY) { /* response to a HEAD request */ + return 0; + } + + if ((parser->flags & F_CHUNKED) || parser->content_length != ULLONG_MAX) { + return 0; + } + + return 1; +} + + +int +http_should_keep_alive (const http_parser *parser) +{ + if (parser->http_major > 0 && parser->http_minor > 0) { + /* HTTP/1.1 */ + if (parser->flags & F_CONNECTION_CLOSE) { + return 0; + } + } else { + /* HTTP/1.0 or earlier */ + if (!(parser->flags & F_CONNECTION_KEEP_ALIVE)) { + return 0; + } + } + + return !http_message_needs_eof(parser); +} + + +const char * +http_method_str (enum http_method m) +{ + return ELEM_AT(method_strings, m, ""); +} + + +void +http_parser_init (http_parser *parser, enum http_parser_type t) +{ + void *data = parser->data; /* preserve application data */ + memset(parser, 0, sizeof(*parser)); + parser->data = data; + parser->type = t; + parser->state = (t == HTTP_REQUEST ? s_start_req : (t == HTTP_RESPONSE ? s_start_res : s_start_req_or_res)); + parser->http_errno = HPE_OK; +} + +void +http_parser_settings_init(http_parser_settings *settings) +{ + memset(settings, 0, sizeof(*settings)); +} + +const char * +http_errno_name(enum http_errno err) { + assert(((size_t) err) < ARRAY_SIZE(http_strerror_tab)); + return http_strerror_tab[err].name; +} + +const char * +http_errno_description(enum http_errno err) { + assert(((size_t) err) < ARRAY_SIZE(http_strerror_tab)); + return http_strerror_tab[err].description; +} + +static enum http_host_state +http_parse_host_char(enum http_host_state s, const char ch) { + switch(s) { + case s_http_userinfo: + case s_http_userinfo_start: + if (ch == '@') { + return s_http_host_start; + } + + if (IS_USERINFO_CHAR(ch)) { + return s_http_userinfo; + } + break; + + case s_http_host_start: + if (ch == '[') { + return s_http_host_v6_start; + } + + if (IS_HOST_CHAR(ch)) { + return s_http_host; + } + + break; + + case s_http_host: + if (IS_HOST_CHAR(ch)) { + return s_http_host; + } + + /* FALLTHROUGH */ + case s_http_host_v6_end: + if (ch == ':') { + return s_http_host_port_start; + } + + break; + + case s_http_host_v6: + if (ch == ']') { + return s_http_host_v6_end; + } + + /* FALLTHROUGH */ + case s_http_host_v6_start: + if (IS_HEX(ch) || ch == ':' || ch == '.') { + return s_http_host_v6; + } + + if (s == s_http_host_v6 && ch == '%') { + return s_http_host_v6_zone_start; + } + break; + + case s_http_host_v6_zone: + if (ch == ']') { + return s_http_host_v6_end; + } + + /* FALLTHROUGH */ + case s_http_host_v6_zone_start: + /* RFC 6874 Zone ID consists of 1*( unreserved / pct-encoded) */ + if (IS_ALPHANUM(ch) || ch == '%' || ch == '.' || ch == '-' || ch == '_' || + ch == '~') { + return s_http_host_v6_zone; + } + break; + + case s_http_host_port: + case s_http_host_port_start: + if (IS_NUM(ch)) { + return s_http_host_port; + } + + break; + + default: + break; + } + return s_http_host_dead; +} + +static int +http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { + enum http_host_state s; + + const char *p; + size_t buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len; + + assert(u->field_set & (1 << UF_HOST)); + + u->field_data[UF_HOST].len = 0; + + s = found_at ? s_http_userinfo_start : s_http_host_start; + + for (p = buf + u->field_data[UF_HOST].off; p < buf + buflen; p++) { + enum http_host_state new_s = http_parse_host_char(s, *p); + + if (new_s == s_http_host_dead) { + return 1; + } + + switch(new_s) { + case s_http_host: + if (s != s_http_host) { + u->field_data[UF_HOST].off = p - buf; + } + u->field_data[UF_HOST].len++; + break; + + case s_http_host_v6: + if (s != s_http_host_v6) { + u->field_data[UF_HOST].off = p - buf; + } + u->field_data[UF_HOST].len++; + break; + + case s_http_host_v6_zone_start: + case s_http_host_v6_zone: + u->field_data[UF_HOST].len++; + break; + + case s_http_host_port: + if (s != s_http_host_port) { + u->field_data[UF_PORT].off = p - buf; + u->field_data[UF_PORT].len = 0; + u->field_set |= (1 << UF_PORT); + } + u->field_data[UF_PORT].len++; + break; + + case s_http_userinfo: + if (s != s_http_userinfo) { + u->field_data[UF_USERINFO].off = p - buf ; + u->field_data[UF_USERINFO].len = 0; + u->field_set |= (1 << UF_USERINFO); + } + u->field_data[UF_USERINFO].len++; + break; + + default: + break; + } + s = new_s; + } + + /* Make sure we don't end somewhere unexpected */ + switch (s) { + case s_http_host_start: + case s_http_host_v6_start: + case s_http_host_v6: + case s_http_host_v6_zone_start: + case s_http_host_v6_zone: + case s_http_host_port_start: + case s_http_userinfo: + case s_http_userinfo_start: + return 1; + default: + break; + } + + return 0; +} + +void +http_parser_url_init(struct http_parser_url *u) { + memset(u, 0, sizeof(*u)); +} + +int +http_parser_parse_url(const char *buf, size_t buflen, int is_connect, + struct http_parser_url *u) +{ + enum state s; + const char *p; + enum http_parser_url_fields uf, old_uf; + int found_at = 0; + + u->port = u->field_set = 0; + s = is_connect ? s_req_server_start : s_req_spaces_before_url; + old_uf = UF_MAX; + + for (p = buf; p < buf + buflen; p++) { + s = parse_url_char(s, *p); + + /* Figure out the next field that we're operating on */ + switch (s) { + case s_dead: + return 1; + + /* Skip delimeters */ + case s_req_schema_slash: + case s_req_schema_slash_slash: + case s_req_server_start: + case s_req_query_string_start: + case s_req_fragment_start: + continue; + + case s_req_schema: + uf = UF_SCHEMA; + break; + + case s_req_server_with_at: + found_at = 1; + + /* FALLTHROUGH */ + case s_req_server: + uf = UF_HOST; + break; + + case s_req_path: + uf = UF_PATH; + break; + + case s_req_query_string: + uf = UF_QUERY; + break; + + case s_req_fragment: + uf = UF_FRAGMENT; + break; + + default: + assert(!"Unexpected state"); + return 1; + } + + /* Nothing's changed; soldier on */ + if (uf == old_uf) { + u->field_data[uf].len++; + continue; + } + + u->field_data[uf].off = p - buf; + u->field_data[uf].len = 1; + + u->field_set |= (1 << uf); + old_uf = uf; + } + + /* host must be present if there is a schema */ + /* parsing http:///toto will fail */ + if ((u->field_set & (1 << UF_SCHEMA)) && + (u->field_set & (1 << UF_HOST)) == 0) { + return 1; + } + + if (u->field_set & (1 << UF_HOST)) { + if (http_parse_host(buf, u, found_at) != 0) { + return 1; + } + } + + /* CONNECT requests can only contain "hostname:port" */ + if (is_connect && u->field_set != ((1 << UF_HOST)|(1 << UF_PORT))) { + return 1; + } + + if (u->field_set & (1 << UF_PORT)) { + uint16_t off; + uint16_t len; + const char* p; + const char* end; + unsigned long v; + + off = u->field_data[UF_PORT].off; + len = u->field_data[UF_PORT].len; + end = buf + off + len; + + /* NOTE: The characters are already validated and are in the [0-9] range */ + assert(off + len <= buflen && "Port number overflow"); + v = 0; + for (p = buf + off; p < end; p++) { + v *= 10; + v += *p - '0'; + + /* Ports have a max value of 2^16 */ + if (v > 0xffff) { + return 1; + } + } + + u->port = (uint16_t) v; + } + + return 0; +} + +void +http_parser_pause(http_parser *parser, int paused) { + /* Users should only be pausing/unpausing a parser that is not in an error + * state. In non-debug builds, there's not much that we can do about this + * other than ignore it. + */ + if (HTTP_PARSER_ERRNO(parser) == HPE_OK || + HTTP_PARSER_ERRNO(parser) == HPE_PAUSED) { + SET_ERRNO((paused) ? HPE_PAUSED : HPE_OK); + } else { + assert(0 && "Attempting to pause parser in error state"); + } +} + +int +http_body_is_final(const struct http_parser *parser) { + return parser->state == s_message_done; +} + +unsigned long +http_parser_version(void) { + return HTTP_PARSER_VERSION_MAJOR * 0x10000 | + HTTP_PARSER_VERSION_MINOR * 0x00100 | + HTTP_PARSER_VERSION_PATCH * 0x00001; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.gyp b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.gyp new file mode 100644 index 0000000..ef34eca --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.gyp @@ -0,0 +1,111 @@ +# This file is used with the GYP meta build system. +# http://code.google.com/p/gyp/ +# To build try this: +# svn co http://gyp.googlecode.com/svn/trunk gyp +# ./gyp/gyp -f make --depth=`pwd` http_parser.gyp +# ./out/Debug/test +{ + 'target_defaults': { + 'default_configuration': 'Debug', + 'configurations': { + # TODO: hoist these out and put them somewhere common, because + # RuntimeLibrary MUST MATCH across the entire project + 'Debug': { + 'defines': [ 'DEBUG', '_DEBUG' ], + 'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 1, # static debug + }, + }, + }, + 'Release': { + 'defines': [ 'NDEBUG' ], + 'cflags': [ '-Wall', '-Wextra', '-O3' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 0, # static release + }, + }, + } + }, + 'msvs_settings': { + 'VCCLCompilerTool': { + }, + 'VCLibrarianTool': { + }, + 'VCLinkerTool': { + 'GenerateDebugInformation': 'true', + }, + }, + 'conditions': [ + ['OS == "win"', { + 'defines': [ + 'WIN32' + ], + }] + ], + }, + + 'targets': [ + { + 'target_name': 'http_parser', + 'type': 'static_library', + 'include_dirs': [ '.' ], + 'direct_dependent_settings': { + 'defines': [ 'HTTP_PARSER_STRICT=0' ], + 'include_dirs': [ '.' ], + }, + 'defines': [ 'HTTP_PARSER_STRICT=0' ], + 'sources': [ './http_parser.c', ], + 'conditions': [ + ['OS=="win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + # Compile as C++. http_parser.c is actually C99, but C++ is + # close enough in this case. + 'CompileAs': 2, + }, + }, + }] + ], + }, + + { + 'target_name': 'http_parser_strict', + 'type': 'static_library', + 'include_dirs': [ '.' ], + 'direct_dependent_settings': { + 'defines': [ 'HTTP_PARSER_STRICT=1' ], + 'include_dirs': [ '.' ], + }, + 'defines': [ 'HTTP_PARSER_STRICT=1' ], + 'sources': [ './http_parser.c', ], + 'conditions': [ + ['OS=="win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + # Compile as C++. http_parser.c is actually C99, but C++ is + # close enough in this case. + 'CompileAs': 2, + }, + }, + }] + ], + }, + + { + 'target_name': 'test-nonstrict', + 'type': 'executable', + 'dependencies': [ 'http_parser' ], + 'sources': [ 'test.c' ] + }, + + { + 'target_name': 'test-strict', + 'type': 'executable', + 'dependencies': [ 'http_parser_strict' ], + 'sources': [ 'test.c' ] + } + ] +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.h b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.h new file mode 100644 index 0000000..a0de71e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/http_parser.h @@ -0,0 +1,433 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#ifndef http_parser_h +#define http_parser_h +#ifdef __cplusplus +extern "C" { +#endif + +/* Also update SONAME in the Makefile whenever you change these. */ +#define HTTP_PARSER_VERSION_MAJOR 2 +#define HTTP_PARSER_VERSION_MINOR 8 +#define HTTP_PARSER_VERSION_PATCH 1 + +#include +#if defined(_WIN32) && !defined(__MINGW32__) && \ + (!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__) +#include +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run + * faster + */ +#ifndef HTTP_PARSER_STRICT +# define HTTP_PARSER_STRICT 1 +#endif + +/* Maximium header size allowed. If the macro is not defined + * before including this header then the default is used. To + * change the maximum header size, define the macro in the build + * environment (e.g. -DHTTP_MAX_HEADER_SIZE=). To remove + * the effective limit on the size of the header, define the macro + * to a very large number (e.g. -DHTTP_MAX_HEADER_SIZE=0x7fffffff) + */ +#ifndef HTTP_MAX_HEADER_SIZE +# define HTTP_MAX_HEADER_SIZE (80*1024) +#endif + +typedef struct http_parser http_parser; +typedef struct http_parser_settings http_parser_settings; + + +/* Callbacks should return non-zero to indicate an error. The parser will + * then halt execution. + * + * The one exception is on_headers_complete. In a HTTP_RESPONSE parser + * returning '1' from on_headers_complete will tell the parser that it + * should not expect a body. This is used when receiving a response to a + * HEAD request which may contain 'Content-Length' or 'Transfer-Encoding: + * chunked' headers that indicate the presence of a body. + * + * Returning `2` from on_headers_complete will tell parser that it should not + * expect neither a body nor any futher responses on this connection. This is + * useful for handling responses to a CONNECT request which may not contain + * `Upgrade` or `Connection: upgrade` headers. + * + * http_data_cb does not return data chunks. It will be called arbitrarily + * many times for each string. E.G. you might get 10 callbacks for "on_url" + * each providing just a few characters more data. + */ +typedef int (*http_data_cb) (http_parser*, const char *at, size_t length); +typedef int (*http_cb) (http_parser*); + + +/* Status Codes */ +#define HTTP_STATUS_MAP(XX) \ + XX(100, CONTINUE, Continue) \ + XX(101, SWITCHING_PROTOCOLS, Switching Protocols) \ + XX(102, PROCESSING, Processing) \ + XX(200, OK, OK) \ + XX(201, CREATED, Created) \ + XX(202, ACCEPTED, Accepted) \ + XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \ + XX(204, NO_CONTENT, No Content) \ + XX(205, RESET_CONTENT, Reset Content) \ + XX(206, PARTIAL_CONTENT, Partial Content) \ + XX(207, MULTI_STATUS, Multi-Status) \ + XX(208, ALREADY_REPORTED, Already Reported) \ + XX(226, IM_USED, IM Used) \ + XX(300, MULTIPLE_CHOICES, Multiple Choices) \ + XX(301, MOVED_PERMANENTLY, Moved Permanently) \ + XX(302, FOUND, Found) \ + XX(303, SEE_OTHER, See Other) \ + XX(304, NOT_MODIFIED, Not Modified) \ + XX(305, USE_PROXY, Use Proxy) \ + XX(307, TEMPORARY_REDIRECT, Temporary Redirect) \ + XX(308, PERMANENT_REDIRECT, Permanent Redirect) \ + XX(400, BAD_REQUEST, Bad Request) \ + XX(401, UNAUTHORIZED, Unauthorized) \ + XX(402, PAYMENT_REQUIRED, Payment Required) \ + XX(403, FORBIDDEN, Forbidden) \ + XX(404, NOT_FOUND, Not Found) \ + XX(405, METHOD_NOT_ALLOWED, Method Not Allowed) \ + XX(406, NOT_ACCEPTABLE, Not Acceptable) \ + XX(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) \ + XX(408, REQUEST_TIMEOUT, Request Timeout) \ + XX(409, CONFLICT, Conflict) \ + XX(410, GONE, Gone) \ + XX(411, LENGTH_REQUIRED, Length Required) \ + XX(412, PRECONDITION_FAILED, Precondition Failed) \ + XX(413, PAYLOAD_TOO_LARGE, Payload Too Large) \ + XX(414, URI_TOO_LONG, URI Too Long) \ + XX(415, UNSUPPORTED_MEDIA_TYPE, Unsupported Media Type) \ + XX(416, RANGE_NOT_SATISFIABLE, Range Not Satisfiable) \ + XX(417, EXPECTATION_FAILED, Expectation Failed) \ + XX(421, MISDIRECTED_REQUEST, Misdirected Request) \ + XX(422, UNPROCESSABLE_ENTITY, Unprocessable Entity) \ + XX(423, LOCKED, Locked) \ + XX(424, FAILED_DEPENDENCY, Failed Dependency) \ + XX(426, UPGRADE_REQUIRED, Upgrade Required) \ + XX(428, PRECONDITION_REQUIRED, Precondition Required) \ + XX(429, TOO_MANY_REQUESTS, Too Many Requests) \ + XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \ + XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, Unavailable For Legal Reasons) \ + XX(500, INTERNAL_SERVER_ERROR, Internal Server Error) \ + XX(501, NOT_IMPLEMENTED, Not Implemented) \ + XX(502, BAD_GATEWAY, Bad Gateway) \ + XX(503, SERVICE_UNAVAILABLE, Service Unavailable) \ + XX(504, GATEWAY_TIMEOUT, Gateway Timeout) \ + XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) \ + XX(506, VARIANT_ALSO_NEGOTIATES, Variant Also Negotiates) \ + XX(507, INSUFFICIENT_STORAGE, Insufficient Storage) \ + XX(508, LOOP_DETECTED, Loop Detected) \ + XX(510, NOT_EXTENDED, Not Extended) \ + XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \ + +enum http_status + { +#define XX(num, name, string) HTTP_STATUS_##name = num, + HTTP_STATUS_MAP(XX) +#undef XX + }; + + +/* Request Methods */ +#define HTTP_METHOD_MAP(XX) \ + XX(0, DELETE, DELETE) \ + XX(1, GET, GET) \ + XX(2, HEAD, HEAD) \ + XX(3, POST, POST) \ + XX(4, PUT, PUT) \ + /* pathological */ \ + XX(5, CONNECT, CONNECT) \ + XX(6, OPTIONS, OPTIONS) \ + XX(7, TRACE, TRACE) \ + /* WebDAV */ \ + XX(8, COPY, COPY) \ + XX(9, LOCK, LOCK) \ + XX(10, MKCOL, MKCOL) \ + XX(11, MOVE, MOVE) \ + XX(12, PROPFIND, PROPFIND) \ + XX(13, PROPPATCH, PROPPATCH) \ + XX(14, SEARCH, SEARCH) \ + XX(15, UNLOCK, UNLOCK) \ + XX(16, BIND, BIND) \ + XX(17, REBIND, REBIND) \ + XX(18, UNBIND, UNBIND) \ + XX(19, ACL, ACL) \ + /* subversion */ \ + XX(20, REPORT, REPORT) \ + XX(21, MKACTIVITY, MKACTIVITY) \ + XX(22, CHECKOUT, CHECKOUT) \ + XX(23, MERGE, MERGE) \ + /* upnp */ \ + XX(24, MSEARCH, M-SEARCH) \ + XX(25, NOTIFY, NOTIFY) \ + XX(26, SUBSCRIBE, SUBSCRIBE) \ + XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \ + /* RFC-5789 */ \ + XX(28, PATCH, PATCH) \ + XX(29, PURGE, PURGE) \ + /* CalDAV */ \ + XX(30, MKCALENDAR, MKCALENDAR) \ + /* RFC-2068, section 19.6.1.2 */ \ + XX(31, LINK, LINK) \ + XX(32, UNLINK, UNLINK) \ + /* icecast */ \ + XX(33, SOURCE, SOURCE) \ + +enum http_method + { +#define XX(num, name, string) HTTP_##name = num, + HTTP_METHOD_MAP(XX) +#undef XX + }; + + +enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH }; + + +/* Flag values for http_parser.flags field */ +enum flags + { F_CHUNKED = 1 << 0 + , F_CONNECTION_KEEP_ALIVE = 1 << 1 + , F_CONNECTION_CLOSE = 1 << 2 + , F_CONNECTION_UPGRADE = 1 << 3 + , F_TRAILING = 1 << 4 + , F_UPGRADE = 1 << 5 + , F_SKIPBODY = 1 << 6 + , F_CONTENTLENGTH = 1 << 7 + }; + + +/* Map for errno-related constants + * + * The provided argument should be a macro that takes 2 arguments. + */ +#define HTTP_ERRNO_MAP(XX) \ + /* No error */ \ + XX(OK, "success") \ + \ + /* Callback-related errors */ \ + XX(CB_message_begin, "the on_message_begin callback failed") \ + XX(CB_url, "the on_url callback failed") \ + XX(CB_header_field, "the on_header_field callback failed") \ + XX(CB_header_value, "the on_header_value callback failed") \ + XX(CB_headers_complete, "the on_headers_complete callback failed") \ + XX(CB_body, "the on_body callback failed") \ + XX(CB_message_complete, "the on_message_complete callback failed") \ + XX(CB_status, "the on_status callback failed") \ + XX(CB_chunk_header, "the on_chunk_header callback failed") \ + XX(CB_chunk_complete, "the on_chunk_complete callback failed") \ + \ + /* Parsing-related errors */ \ + XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \ + XX(HEADER_OVERFLOW, \ + "too many header bytes seen; overflow detected") \ + XX(CLOSED_CONNECTION, \ + "data received after completed connection: close message") \ + XX(INVALID_VERSION, "invalid HTTP version") \ + XX(INVALID_STATUS, "invalid HTTP status code") \ + XX(INVALID_METHOD, "invalid HTTP method") \ + XX(INVALID_URL, "invalid URL") \ + XX(INVALID_HOST, "invalid host") \ + XX(INVALID_PORT, "invalid port") \ + XX(INVALID_PATH, "invalid path") \ + XX(INVALID_QUERY_STRING, "invalid query string") \ + XX(INVALID_FRAGMENT, "invalid fragment") \ + XX(LF_EXPECTED, "LF character expected") \ + XX(INVALID_HEADER_TOKEN, "invalid character in header") \ + XX(INVALID_CONTENT_LENGTH, \ + "invalid character in content-length header") \ + XX(UNEXPECTED_CONTENT_LENGTH, \ + "unexpected content-length header") \ + XX(INVALID_CHUNK_SIZE, \ + "invalid character in chunk size header") \ + XX(INVALID_CONSTANT, "invalid constant string") \ + XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\ + XX(STRICT, "strict mode assertion failed") \ + XX(PAUSED, "parser is paused") \ + XX(UNKNOWN, "an unknown error occurred") + + +/* Define HPE_* values for each errno value above */ +#define HTTP_ERRNO_GEN(n, s) HPE_##n, +enum http_errno { + HTTP_ERRNO_MAP(HTTP_ERRNO_GEN) +}; +#undef HTTP_ERRNO_GEN + + +/* Get an http_errno value from an http_parser */ +#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno) + + +struct http_parser { + /** PRIVATE **/ + unsigned int type : 2; /* enum http_parser_type */ + unsigned int flags : 8; /* F_* values from 'flags' enum; semi-public */ + unsigned int state : 7; /* enum state from http_parser.c */ + unsigned int header_state : 7; /* enum header_state from http_parser.c */ + unsigned int index : 7; /* index into current matcher */ + unsigned int lenient_http_headers : 1; + + uint32_t nread; /* # bytes read in various scenarios */ + uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */ + + /** READ-ONLY **/ + unsigned short http_major; + unsigned short http_minor; + unsigned int status_code : 16; /* responses only */ + unsigned int method : 8; /* requests only */ + unsigned int http_errno : 7; + + /* 1 = Upgrade header was present and the parser has exited because of that. + * 0 = No upgrade header present. + * Should be checked when http_parser_execute() returns in addition to + * error checking. + */ + unsigned int upgrade : 1; + + /** PUBLIC **/ + void *data; /* A pointer to get hook to the "connection" or "socket" object */ +}; + + +struct http_parser_settings { + http_cb on_message_begin; + http_data_cb on_url; + http_data_cb on_status; + http_data_cb on_header_field; + http_data_cb on_header_value; + http_cb on_headers_complete; + http_data_cb on_body; + http_cb on_message_complete; + /* When on_chunk_header is called, the current chunk length is stored + * in parser->content_length. + */ + http_cb on_chunk_header; + http_cb on_chunk_complete; +}; + + +enum http_parser_url_fields + { UF_SCHEMA = 0 + , UF_HOST = 1 + , UF_PORT = 2 + , UF_PATH = 3 + , UF_QUERY = 4 + , UF_FRAGMENT = 5 + , UF_USERINFO = 6 + , UF_MAX = 7 + }; + + +/* Result structure for http_parser_parse_url(). + * + * Callers should index into field_data[] with UF_* values iff field_set + * has the relevant (1 << UF_*) bit set. As a courtesy to clients (and + * because we probably have padding left over), we convert any port to + * a uint16_t. + */ +struct http_parser_url { + uint16_t field_set; /* Bitmask of (1 << UF_*) values */ + uint16_t port; /* Converted UF_PORT string */ + + struct { + uint16_t off; /* Offset into buffer in which field starts */ + uint16_t len; /* Length of run in buffer */ + } field_data[UF_MAX]; +}; + + +/* Returns the library version. Bits 16-23 contain the major version number, + * bits 8-15 the minor version number and bits 0-7 the patch level. + * Usage example: + * + * unsigned long version = http_parser_version(); + * unsigned major = (version >> 16) & 255; + * unsigned minor = (version >> 8) & 255; + * unsigned patch = version & 255; + * printf("http_parser v%u.%u.%u\n", major, minor, patch); + */ +unsigned long http_parser_version(void); + +void http_parser_init(http_parser *parser, enum http_parser_type type); + + +/* Initialize http_parser_settings members to 0 + */ +void http_parser_settings_init(http_parser_settings *settings); + + +/* Executes the parser. Returns number of parsed bytes. Sets + * `parser->http_errno` on error. */ +size_t http_parser_execute(http_parser *parser, + const http_parser_settings *settings, + const char *data, + size_t len); + + +/* If http_should_keep_alive() in the on_headers_complete or + * on_message_complete callback returns 0, then this should be + * the last message on the connection. + * If you are the server, respond with the "Connection: close" header. + * If you are the client, close the connection. + */ +int http_should_keep_alive(const http_parser *parser); + +/* Returns a string version of the HTTP method. */ +const char *http_method_str(enum http_method m); + +/* Return a string name of the given error */ +const char *http_errno_name(enum http_errno err); + +/* Return a string description of the given error */ +const char *http_errno_description(enum http_errno err); + +/* Initialize all http_parser_url members to 0 */ +void http_parser_url_init(struct http_parser_url *u); + +/* Parse a URL; return nonzero on failure */ +int http_parser_parse_url(const char *buf, size_t buflen, + int is_connect, + struct http_parser_url *u); + +/* Pause or un-pause the parser; a nonzero value pauses */ +void http_parser_pause(http_parser *parser, int paused); + +/* Checks if this is the final chunk of the body. */ +int http_body_is_final(const http_parser *parser); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/test.c b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/test.c new file mode 100644 index 0000000..df170e4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser/test.c @@ -0,0 +1,4456 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "http_parser.h" +#include +#include +#include +#include /* rand */ +#include +#include + +#if defined(__APPLE__) +# undef strlncpy +#endif /* defined(__APPLE__) */ + +#undef TRUE +#define TRUE 1 +#undef FALSE +#define FALSE 0 + +#define MAX_HEADERS 13 +#define MAX_ELEMENT_SIZE 2048 +#define MAX_CHUNKS 16 + +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x)) + +static http_parser *parser; + +struct message { + const char *name; // for debugging purposes + const char *raw; + enum http_parser_type type; + enum http_method method; + int status_code; + char response_status[MAX_ELEMENT_SIZE]; + char request_path[MAX_ELEMENT_SIZE]; + char request_url[MAX_ELEMENT_SIZE]; + char fragment[MAX_ELEMENT_SIZE]; + char query_string[MAX_ELEMENT_SIZE]; + char body[MAX_ELEMENT_SIZE]; + size_t body_size; + const char *host; + const char *userinfo; + uint16_t port; + int num_headers; + enum { NONE=0, FIELD, VALUE } last_header_element; + char headers [MAX_HEADERS][2][MAX_ELEMENT_SIZE]; + int should_keep_alive; + + int num_chunks; + int num_chunks_complete; + int chunk_lengths[MAX_CHUNKS]; + + const char *upgrade; // upgraded body + + unsigned short http_major; + unsigned short http_minor; + + int message_begin_cb_called; + int headers_complete_cb_called; + int message_complete_cb_called; + int status_cb_called; + int message_complete_on_eof; + int body_is_final; +}; + +static int currently_parsing_eof; + +static struct message messages[5]; +static int num_messages; +static http_parser_settings *current_pause_parser; + +/* * R E Q U E S T S * */ +const struct message requests[] = +#define CURL_GET 0 +{ {.name= "curl get" + ,.type= HTTP_REQUEST + ,.raw= "GET /test HTTP/1.1\r\n" + "User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\n" + "Host: 0.0.0.0=5000\r\n" + "Accept: */*\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 3 + ,.headers= + { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" } + , { "Host", "0.0.0.0=5000" } + , { "Accept", "*/*" } + } + ,.body= "" + } + +#define FIREFOX_GET 1 +, {.name= "firefox get" + ,.type= HTTP_REQUEST + ,.raw= "GET /favicon.ico HTTP/1.1\r\n" + "Host: 0.0.0.0=5000\r\n" + "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\n" + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" + "Accept-Language: en-us,en;q=0.5\r\n" + "Accept-Encoding: gzip,deflate\r\n" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" + "Keep-Alive: 300\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/favicon.ico" + ,.request_url= "/favicon.ico" + ,.num_headers= 8 + ,.headers= + { { "Host", "0.0.0.0=5000" } + , { "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0" } + , { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" } + , { "Accept-Language", "en-us,en;q=0.5" } + , { "Accept-Encoding", "gzip,deflate" } + , { "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7" } + , { "Keep-Alive", "300" } + , { "Connection", "keep-alive" } + } + ,.body= "" + } + +#define DUMBFUCK 2 +, {.name= "dumbfuck" + ,.type= HTTP_REQUEST + ,.raw= "GET /dumbfuck HTTP/1.1\r\n" + "aaaaaaaaaaaaa:++++++++++\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/dumbfuck" + ,.request_url= "/dumbfuck" + ,.num_headers= 1 + ,.headers= + { { "aaaaaaaaaaaaa", "++++++++++" } + } + ,.body= "" + } + +#define FRAGMENT_IN_URI 3 +, {.name= "fragment in url" + ,.type= HTTP_REQUEST + ,.raw= "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "page=1" + ,.fragment= "posts-17408" + ,.request_path= "/forums/1/topics/2375" + /* XXX request url does include fragment? */ + ,.request_url= "/forums/1/topics/2375?page=1#posts-17408" + ,.num_headers= 0 + ,.body= "" + } + +#define GET_NO_HEADERS_NO_BODY 4 +, {.name= "get no headers no body" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_no_headers_no_body/world HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE /* would need Connection: close */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_no_headers_no_body/world" + ,.request_url= "/get_no_headers_no_body/world" + ,.num_headers= 0 + ,.body= "" + } + +#define GET_ONE_HEADER_NO_BODY 5 +, {.name= "get one header no body" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_one_header_no_body HTTP/1.1\r\n" + "Accept: */*\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE /* would need Connection: close */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_one_header_no_body" + ,.request_url= "/get_one_header_no_body" + ,.num_headers= 1 + ,.headers= + { { "Accept" , "*/*" } + } + ,.body= "" + } + +#define GET_FUNKY_CONTENT_LENGTH 6 +, {.name= "get funky content length body hello" + ,.type= HTTP_REQUEST + ,.raw= "GET /get_funky_content_length_body_hello HTTP/1.0\r\n" + "conTENT-Length: 5\r\n" + "\r\n" + "HELLO" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/get_funky_content_length_body_hello" + ,.request_url= "/get_funky_content_length_body_hello" + ,.num_headers= 1 + ,.headers= + { { "conTENT-Length" , "5" } + } + ,.body= "HELLO" + } + +#define POST_IDENTITY_BODY_WORLD 7 +, {.name= "post identity body world" + ,.type= HTTP_REQUEST + ,.raw= "POST /post_identity_body_world?q=search#hey HTTP/1.1\r\n" + "Accept: */*\r\n" + "Transfer-Encoding: identity\r\n" + "Content-Length: 5\r\n" + "\r\n" + "World" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "q=search" + ,.fragment= "hey" + ,.request_path= "/post_identity_body_world" + ,.request_url= "/post_identity_body_world?q=search#hey" + ,.num_headers= 3 + ,.headers= + { { "Accept", "*/*" } + , { "Transfer-Encoding", "identity" } + , { "Content-Length", "5" } + } + ,.body= "World" + } + +#define POST_CHUNKED_ALL_YOUR_BASE 8 +, {.name= "post - chunked body: all your base are belong to us" + ,.type= HTTP_REQUEST + ,.raw= "POST /post_chunked_all_your_base HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "1e\r\nall your base are belong to us\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/post_chunked_all_your_base" + ,.request_url= "/post_chunked_all_your_base" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding" , "chunked" } + } + ,.body= "all your base are belong to us" + ,.num_chunks_complete= 2 + ,.chunk_lengths= { 0x1e } + } + +#define TWO_CHUNKS_MULT_ZERO_END 9 +, {.name= "two chunks ; triple zero ending" + ,.type= HTTP_REQUEST + ,.raw= "POST /two_chunks_mult_zero_end HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5\r\nhello\r\n" + "6\r\n world\r\n" + "000\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/two_chunks_mult_zero_end" + ,.request_url= "/two_chunks_mult_zero_end" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body= "hello world" + ,.num_chunks_complete= 3 + ,.chunk_lengths= { 5, 6 } + } + +#define CHUNKED_W_TRAILING_HEADERS 10 +, {.name= "chunked with trailing headers. blech." + ,.type= HTTP_REQUEST + ,.raw= "POST /chunked_w_trailing_headers HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5\r\nhello\r\n" + "6\r\n world\r\n" + "0\r\n" + "Vary: *\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/chunked_w_trailing_headers" + ,.request_url= "/chunked_w_trailing_headers" + ,.num_headers= 3 + ,.headers= + { { "Transfer-Encoding", "chunked" } + , { "Vary", "*" } + , { "Content-Type", "text/plain" } + } + ,.body= "hello world" + ,.num_chunks_complete= 3 + ,.chunk_lengths= { 5, 6 } + } + +#define CHUNKED_W_BULLSHIT_AFTER_LENGTH 11 +, {.name= "with bullshit after the length" + ,.type= HTTP_REQUEST + ,.raw= "POST /chunked_w_bullshit_after_length HTTP/1.1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "5; ihatew3;whatthefuck=aretheseparametersfor\r\nhello\r\n" + "6; blahblah; blah\r\n world\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/chunked_w_bullshit_after_length" + ,.request_url= "/chunked_w_bullshit_after_length" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body= "hello world" + ,.num_chunks_complete= 3 + ,.chunk_lengths= { 5, 6 } + } + +#define WITH_QUOTES 12 +, {.name= "with quotes" + ,.type= HTTP_REQUEST + ,.raw= "GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "foo=\"bar\"" + ,.fragment= "" + ,.request_path= "/with_\"stupid\"_quotes" + ,.request_url= "/with_\"stupid\"_quotes?foo=\"bar\"" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define APACHEBENCH_GET 13 +/* The server receiving this request SHOULD NOT wait for EOF + * to know that content-length == 0. + * How to represent this in a unit test? message_complete_on_eof + * Compare with NO_CONTENT_LENGTH_RESPONSE. + */ +, {.name = "apachebench get" + ,.type= HTTP_REQUEST + ,.raw= "GET /test HTTP/1.0\r\n" + "Host: 0.0.0.0:5000\r\n" + "User-Agent: ApacheBench/2.3\r\n" + "Accept: */*\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 3 + ,.headers= { { "Host", "0.0.0.0:5000" } + , { "User-Agent", "ApacheBench/2.3" } + , { "Accept", "*/*" } + } + ,.body= "" + } + +#define QUERY_URL_WITH_QUESTION_MARK_GET 14 +/* Some clients include '?' characters in query strings. + */ +, {.name = "query url with question mark" + ,.type= HTTP_REQUEST + ,.raw= "GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "foo=bar?baz" + ,.fragment= "" + ,.request_path= "/test.cgi" + ,.request_url= "/test.cgi?foo=bar?baz" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define PREFIX_NEWLINE_GET 15 +/* Some clients, especially after a POST in a keep-alive connection, + * will send an extra CRLF before the next request + */ +, {.name = "newline prefix get" + ,.type= HTTP_REQUEST + ,.raw= "\r\nGET /test HTTP/1.1\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define UPGRADE_REQUEST 16 +, {.name = "upgrade request" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: Upgrade\r\n" + "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" + "Sec-WebSocket-Protocol: sample\r\n" + "Upgrade: WebSocket\r\n" + "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" + "Origin: http://example.com\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 7 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Host", "example.com" } + , { "Connection", "Upgrade" } + , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } + , { "Sec-WebSocket-Protocol", "sample" } + , { "Upgrade", "WebSocket" } + , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } + , { "Origin", "http://example.com" } + } + ,.body= "" + } + +#define CONNECT_REQUEST 17 +, {.name = "connect request" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + "some data\r\n" + "and yet even more data" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "0-home0.netscape.com:443" + ,.num_headers= 2 + ,.upgrade="some data\r\nand yet even more data" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } + +#define REPORT_REQ 18 +, {.name= "report request" + ,.type= HTTP_REQUEST + ,.raw= "REPORT /test HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_REPORT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/test" + ,.request_url= "/test" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define NO_HTTP_VERSION 19 +, {.name= "request with no http version" + ,.type= HTTP_REQUEST + ,.raw= "GET /\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 0 + ,.http_minor= 9 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define MSEARCH_REQ 20 +, {.name= "m-search request" + ,.type= HTTP_REQUEST + ,.raw= "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "MAN: \"ssdp:discover\"\r\n" + "ST: \"ssdp:all\"\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_MSEARCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "*" + ,.request_url= "*" + ,.num_headers= 3 + ,.headers= { { "HOST", "239.255.255.250:1900" } + , { "MAN", "\"ssdp:discover\"" } + , { "ST", "\"ssdp:all\"" } + } + ,.body= "" + } + +#define LINE_FOLDING_IN_HEADER 21 +, {.name= "line folding in header value" + ,.type= HTTP_REQUEST + ,.raw= "GET / HTTP/1.1\r\n" + "Line1: abc\r\n" + "\tdef\r\n" + " ghi\r\n" + "\t\tjkl\r\n" + " mno \r\n" + "\t \tqrs\r\n" + "Line2: \t line2\t\r\n" + "Line3:\r\n" + " line3\r\n" + "Line4: \r\n" + " \r\n" + "Connection:\r\n" + " close\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 5 + ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" } + , { "Line2", "line2\t" } + , { "Line3", "line3" } + , { "Line4", "" } + , { "Connection", "close" }, + } + ,.body= "" + } + + +#define QUERY_TERMINATED_HOST 22 +, {.name= "host terminated by a query string" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "hail=all" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org?hail=all" + ,.host= "hypnotoad.org" + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define QUERY_TERMINATED_HOSTPORT 23 +, {.name= "host:port terminated by a query string" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "hail=all" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org:1234?hail=all" + ,.host= "hypnotoad.org" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define SPACE_TERMINATED_HOSTPORT 24 +, {.name= "host:port terminated by a space" + ,.type= HTTP_REQUEST + ,.raw= "GET http://hypnotoad.org:1234 HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "http://hypnotoad.org:1234" + ,.host= "hypnotoad.org" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define PATCH_REQ 25 +, {.name = "PATCH request" + ,.type= HTTP_REQUEST + ,.raw= "PATCH /file.txt HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/example\r\n" + "If-Match: \"e0023aa4e\"\r\n" + "Content-Length: 10\r\n" + "\r\n" + "cccccccccc" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_PATCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/file.txt" + ,.request_url= "/file.txt" + ,.num_headers= 4 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/example" } + , { "If-Match", "\"e0023aa4e\"" } + , { "Content-Length", "10" } + } + ,.body= "cccccccccc" + } + +#define CONNECT_CAPS_REQUEST 26 +, {.name = "connect caps request" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "HOME0.NETSCAPE.COM:443" + ,.num_headers= 2 + ,.upgrade="" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } + +#if !HTTP_PARSER_STRICT +#define UTF8_PATH_REQ 27 +, {.name= "utf-8 path request" + ,.type= HTTP_REQUEST + ,.raw= "GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\n" + "Host: github.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "q=1" + ,.fragment= "narf" + ,.request_path= "/δ¶/δt/pope" + ,.request_url= "/δ¶/δt/pope?q=1#narf" + ,.num_headers= 1 + ,.headers= { {"Host", "github.com" } + } + ,.body= "" + } + +#define HOSTNAME_UNDERSCORE 28 +, {.name = "hostname underscore" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT home_0.netscape.com:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.query_string= "" + ,.fragment= "" + ,.request_path= "" + ,.request_url= "home_0.netscape.com:443" + ,.num_headers= 2 + ,.upgrade="" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + } + ,.body= "" + } +#endif /* !HTTP_PARSER_STRICT */ + +/* see https://github.com/ry/http-parser/issues/47 */ +#define EAT_TRAILING_CRLF_NO_CONNECTION_CLOSE 29 +, {.name = "eat CRLF between requests, no \"Connection: close\" header" + ,.raw= "POST / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 4\r\n" + "\r\n" + "q=42\r\n" /* note the trailing CRLF */ + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 3 + ,.upgrade= 0 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/x-www-form-urlencoded" } + , { "Content-Length", "4" } + } + ,.body= "q=42" + } + +/* see https://github.com/ry/http-parser/issues/47 */ +#define EAT_TRAILING_CRLF_WITH_CONNECTION_CLOSE 30 +, {.name = "eat CRLF between requests even if \"Connection: close\" is set" + ,.raw= "POST / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 4\r\n" + "Connection: close\r\n" + "\r\n" + "q=42\r\n" /* note the trailing CRLF */ + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE /* input buffer isn't empty when on_message_complete is called */ + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 4 + ,.upgrade= 0 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/x-www-form-urlencoded" } + , { "Content-Length", "4" } + , { "Connection", "close" } + } + ,.body= "q=42" + } + +#define PURGE_REQ 31 +, {.name = "PURGE request" + ,.type= HTTP_REQUEST + ,.raw= "PURGE /file.txt HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_PURGE + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/file.txt" + ,.request_url= "/file.txt" + ,.num_headers= 1 + ,.headers= { { "Host", "www.example.com" } } + ,.body= "" + } + +#define SEARCH_REQ 32 +, {.name = "SEARCH request" + ,.type= HTTP_REQUEST + ,.raw= "SEARCH / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_SEARCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 1 + ,.headers= { { "Host", "www.example.com" } } + ,.body= "" + } + +#define PROXY_WITH_BASIC_AUTH 33 +, {.name= "host:port and basic_auth" + ,.type= HTTP_REQUEST + ,.raw= "GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.fragment= "" + ,.request_path= "/toto" + ,.request_url= "http://a%12:b!&*$@hypnotoad.org:1234/toto" + ,.host= "hypnotoad.org" + ,.userinfo= "a%12:b!&*$" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + +#define LINE_FOLDING_IN_HEADER_WITH_LF 34 +, {.name= "line folding in header value" + ,.type= HTTP_REQUEST + ,.raw= "GET / HTTP/1.1\n" + "Line1: abc\n" + "\tdef\n" + " ghi\n" + "\t\tjkl\n" + " mno \n" + "\t \tqrs\n" + "Line2: \t line2\t\n" + "Line3:\n" + " line3\n" + "Line4: \n" + " \n" + "Connection:\n" + " close\n" + "\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 5 + ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" } + , { "Line2", "line2\t" } + , { "Line3", "line3" } + , { "Line4", "" } + , { "Connection", "close" }, + } + ,.body= "" + } + +#define CONNECTION_MULTI 35 +, {.name = "multiple connection header values with folding" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: Something,\r\n" + " Upgrade, ,Keep-Alive\r\n" + "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" + "Sec-WebSocket-Protocol: sample\r\n" + "Upgrade: WebSocket\r\n" + "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" + "Origin: http://example.com\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 7 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Host", "example.com" } + , { "Connection", "Something, Upgrade, ,Keep-Alive" } + , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } + , { "Sec-WebSocket-Protocol", "sample" } + , { "Upgrade", "WebSocket" } + , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } + , { "Origin", "http://example.com" } + } + ,.body= "" + } + +#define CONNECTION_MULTI_LWS 36 +, {.name = "multiple connection header values with folding and lws" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Connection: keep-alive, upgrade\r\n" + "Upgrade: WebSocket\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 2 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Connection", "keep-alive, upgrade" } + , { "Upgrade", "WebSocket" } + } + ,.body= "" + } + +#define CONNECTION_MULTI_LWS_CRLF 37 +, {.name = "multiple connection header values with folding and lws" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Connection: keep-alive, \r\n upgrade\r\n" + "Upgrade: WebSocket\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 2 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Connection", "keep-alive, upgrade" } + , { "Upgrade", "WebSocket" } + } + ,.body= "" + } + +#define UPGRADE_POST_REQUEST 38 +, {.name = "upgrade post request" + ,.type= HTTP_REQUEST + ,.raw= "POST /demo HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: Upgrade\r\n" + "Upgrade: HTTP/2.0\r\n" + "Content-Length: 15\r\n" + "\r\n" + "sweet post body" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_POST + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 4 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Host", "example.com" } + , { "Connection", "Upgrade" } + , { "Upgrade", "HTTP/2.0" } + , { "Content-Length", "15" } + } + ,.body= "sweet post body" + } + +#define CONNECT_WITH_BODY_REQUEST 39 +, {.name = "connect with body request" + ,.type= HTTP_REQUEST + ,.raw= "CONNECT foo.bar.com:443 HTTP/1.0\r\n" + "User-agent: Mozilla/1.1N\r\n" + "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" + "Content-Length: 10\r\n" + "\r\n" + "blarfcicle" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.method= HTTP_CONNECT + ,.request_url= "foo.bar.com:443" + ,.num_headers= 3 + ,.upgrade="blarfcicle" + ,.headers= { { "User-agent", "Mozilla/1.1N" } + , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } + , { "Content-Length", "10" } + } + ,.body= "" + } + +/* Examples from the Internet draft for LINK/UNLINK methods: + * https://tools.ietf.org/id/draft-snell-link-method-01.html#rfc.section.5 + */ + +#define LINK_REQUEST 40 +, {.name = "link request" + ,.type= HTTP_REQUEST + ,.raw= "LINK /images/my_dog.jpg HTTP/1.1\r\n" + "Host: example.com\r\n" + "Link: ; rel=\"tag\"\r\n" + "Link: ; rel=\"tag\"\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_LINK + ,.request_path= "/images/my_dog.jpg" + ,.request_url= "/images/my_dog.jpg" + ,.query_string= "" + ,.fragment= "" + ,.num_headers= 3 + ,.headers= { { "Host", "example.com" } + , { "Link", "; rel=\"tag\"" } + , { "Link", "; rel=\"tag\"" } + } + ,.body= "" + } + +#define UNLINK_REQUEST 41 +, {.name = "unlink request" + ,.type= HTTP_REQUEST + ,.raw= "UNLINK /images/my_dog.jpg HTTP/1.1\r\n" + "Host: example.com\r\n" + "Link: ; rel=\"tag\"\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_UNLINK + ,.request_path= "/images/my_dog.jpg" + ,.request_url= "/images/my_dog.jpg" + ,.query_string= "" + ,.fragment= "" + ,.num_headers= 2 + ,.headers= { { "Host", "example.com" } + , { "Link", "; rel=\"tag\"" } + } + ,.body= "" + } + +#define SOURCE_REQUEST 42 +, {.name = "source request" + ,.type= HTTP_REQUEST + ,.raw= "SOURCE /music/sweet/music HTTP/1.1\r\n" + "Host: example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_SOURCE + ,.request_path= "/music/sweet/music" + ,.request_url= "/music/sweet/music" + ,.query_string= "" + ,.fragment= "" + ,.num_headers= 1 + ,.headers= { { "Host", "example.com" } } + ,.body= "" + } +}; + +/* * R E S P O N S E S * */ +const struct message responses[] = +#define GOOGLE_301 0 +{ {.name= "google 301" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301 Moved Permanently\r\n" + "Location: http://www.google.com/\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Date: Sun, 26 Apr 2009 11:11:49 GMT\r\n" + "Expires: Tue, 26 May 2009 11:11:49 GMT\r\n" + "X-$PrototypeBI-Version: 1.6.0.3\r\n" /* $ char in header field */ + "Cache-Control: public, max-age=2592000\r\n" + "Server: gws\r\n" + "Content-Length: 219 \r\n" + "\r\n" + "\n" + "301 Moved\n" + "

301 Moved

\n" + "The document has moved\n" + "here.\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 301 + ,.response_status= "Moved Permanently" + ,.num_headers= 8 + ,.headers= + { { "Location", "http://www.google.com/" } + , { "Content-Type", "text/html; charset=UTF-8" } + , { "Date", "Sun, 26 Apr 2009 11:11:49 GMT" } + , { "Expires", "Tue, 26 May 2009 11:11:49 GMT" } + , { "X-$PrototypeBI-Version", "1.6.0.3" } + , { "Cache-Control", "public, max-age=2592000" } + , { "Server", "gws" } + , { "Content-Length", "219 " } + } + ,.body= "\n" + "301 Moved\n" + "

301 Moved

\n" + "The document has moved\n" + "here.\r\n" + "\r\n" + } + +#define NO_CONTENT_LENGTH_RESPONSE 1 +/* The client should wait for the server's EOF. That is, when content-length + * is not specified, and "Connection: close", the end of body is specified + * by the EOF. + * Compare with APACHEBENCH_GET + */ +, {.name= "no content-length response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Date: Tue, 04 Aug 2009 07:59:32 GMT\r\n" + "Server: Apache\r\n" + "X-Powered-By: Servlet/2.5 JSP/2.1\r\n" + "Content-Type: text/xml; charset=utf-8\r\n" + "Connection: close\r\n" + "\r\n" + "\n" + "\n" + " \n" + " \n" + " SOAP-ENV:Client\n" + " Client Error\n" + " \n" + " \n" + "" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 5 + ,.headers= + { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" } + , { "Server", "Apache" } + , { "X-Powered-By", "Servlet/2.5 JSP/2.1" } + , { "Content-Type", "text/xml; charset=utf-8" } + , { "Connection", "close" } + } + ,.body= "\n" + "\n" + " \n" + " \n" + " SOAP-ENV:Client\n" + " Client Error\n" + " \n" + " \n" + "" + } + +#define NO_HEADERS_NO_BODY_404 2 +, {.name= "404 no headers no body" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 404 Not Found\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 404 + ,.response_status= "Not Found" + ,.num_headers= 0 + ,.headers= {} + ,.body_size= 0 + ,.body= "" + } + +#define NO_REASON_PHRASE 3 +, {.name= "301 no response phrase" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301\r\n\r\n" + ,.should_keep_alive = FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 301 + ,.response_status= "" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define TRAILING_SPACE_ON_CHUNKED_BODY 4 +, {.name="200 trailing space on chunked body" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "25 \r\n" + "This is the data in the first chunk\r\n" + "\r\n" + "1C\r\n" + "and this is the second one\r\n" + "\r\n" + "0 \r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 2 + ,.headers= + { {"Content-Type", "text/plain" } + , {"Transfer-Encoding", "chunked" } + } + ,.body_size = 37+28 + ,.body = + "This is the data in the first chunk\r\n" + "and this is the second one\r\n" + ,.num_chunks_complete= 3 + ,.chunk_lengths= { 0x25, 0x1c } + } + +#define NO_CARRIAGE_RET 5 +, {.name="no carriage ret" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\n" + "Content-Type: text/html; charset=utf-8\n" + "Connection: close\n" + "\n" + "these headers are from http://news.ycombinator.com/" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 2 + ,.headers= + { {"Content-Type", "text/html; charset=utf-8" } + , {"Connection", "close" } + } + ,.body= "these headers are from http://news.ycombinator.com/" + } + +#define PROXY_CONNECTION 6 +, {.name="proxy connection" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Content-Length: 11\r\n" + "Proxy-Connection: close\r\n" + "Date: Thu, 31 Dec 2009 20:55:48 +0000\r\n" + "\r\n" + "hello world" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 4 + ,.headers= + { {"Content-Type", "text/html; charset=UTF-8" } + , {"Content-Length", "11" } + , {"Proxy-Connection", "close" } + , {"Date", "Thu, 31 Dec 2009 20:55:48 +0000"} + } + ,.body= "hello world" + } + +#define UNDERSTORE_HEADER_KEY 7 + // shown by + // curl -o /dev/null -v "http://ad.doubleclick.net/pfadx/DARTSHELLCONFIGXML;dcmt=text/xml;" +, {.name="underscore header key" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Server: DCLK-AdSvr\r\n" + "Content-Type: text/xml\r\n" + "Content-Length: 0\r\n" + "DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 4 + ,.headers= + { {"Server", "DCLK-AdSvr" } + , {"Content-Type", "text/xml" } + , {"Content-Length", "0" } + , {"DCLK_imp", "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o" } + } + ,.body= "" + } + +#define BONJOUR_MADAME_FR 8 +/* The client should not merge two headers fields when the first one doesn't + * have a value. + */ +, {.name= "bonjourmadame.fr" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 301 Moved Permanently\r\n" + "Date: Thu, 03 Jun 2010 09:56:32 GMT\r\n" + "Server: Apache/2.2.3 (Red Hat)\r\n" + "Cache-Control: public\r\n" + "Pragma: \r\n" + "Location: http://www.bonjourmadame.fr/\r\n" + "Vary: Accept-Encoding\r\n" + "Content-Length: 0\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 301 + ,.response_status= "Moved Permanently" + ,.num_headers= 9 + ,.headers= + { { "Date", "Thu, 03 Jun 2010 09:56:32 GMT" } + , { "Server", "Apache/2.2.3 (Red Hat)" } + , { "Cache-Control", "public" } + , { "Pragma", "" } + , { "Location", "http://www.bonjourmadame.fr/" } + , { "Vary", "Accept-Encoding" } + , { "Content-Length", "0" } + , { "Content-Type", "text/html; charset=UTF-8" } + , { "Connection", "keep-alive" } + } + ,.body= "" + } + +#define RES_FIELD_UNDERSCORE 9 +/* Should handle spaces in header fields */ +, {.name= "field underscore" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Date: Tue, 28 Sep 2010 01:14:13 GMT\r\n" + "Server: Apache\r\n" + "Cache-Control: no-cache, must-revalidate\r\n" + "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" + ".et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\n" + "Vary: Accept-Encoding\r\n" + "_eep-Alive: timeout=45\r\n" /* semantic value ignored */ + "_onnection: Keep-Alive\r\n" /* semantic value ignored */ + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/html\r\n" + "Connection: close\r\n" + "\r\n" + "0\r\n\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 11 + ,.headers= + { { "Date", "Tue, 28 Sep 2010 01:14:13 GMT" } + , { "Server", "Apache" } + , { "Cache-Control", "no-cache, must-revalidate" } + , { "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" } + , { ".et-Cookie", "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com" } + , { "Vary", "Accept-Encoding" } + , { "_eep-Alive", "timeout=45" } + , { "_onnection", "Keep-Alive" } + , { "Transfer-Encoding", "chunked" } + , { "Content-Type", "text/html" } + , { "Connection", "close" } + } + ,.body= "" + ,.num_chunks_complete= 1 + ,.chunk_lengths= {} + } + +#define NON_ASCII_IN_STATUS_LINE 10 +/* Should handle non-ASCII in status line */ +, {.name= "non-ASCII in status line" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 500 Oriëntatieprobleem\r\n" + "Date: Fri, 5 Nov 2010 23:07:12 GMT+2\r\n" + "Content-Length: 0\r\n" + "Connection: close\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 500 + ,.response_status= "Oriëntatieprobleem" + ,.num_headers= 3 + ,.headers= + { { "Date", "Fri, 5 Nov 2010 23:07:12 GMT+2" } + , { "Content-Length", "0" } + , { "Connection", "close" } + } + ,.body= "" + } + +#define HTTP_VERSION_0_9 11 +/* Should handle HTTP/0.9 */ +, {.name= "http version 0.9" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/0.9 200 OK\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 0 + ,.http_minor= 9 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 0 + ,.headers= + {} + ,.body= "" + } + +#define NO_CONTENT_LENGTH_NO_TRANSFER_ENCODING_RESPONSE 12 +/* The client should wait for the server's EOF. That is, when neither + * content-length nor transfer-encoding is specified, the end of body + * is specified by the EOF. + */ +, {.name= "neither content-length nor transfer-encoding response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "hello world" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 1 + ,.headers= + { { "Content-Type", "text/plain" } + } + ,.body= "hello world" + } + +#define NO_BODY_HTTP10_KA_200 13 +, {.name= "HTTP/1.0 with keep-alive and EOF-terminated 200 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 200 OK\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 1 + ,.headers= + { { "Connection", "keep-alive" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP10_KA_204 14 +, {.name= "HTTP/1.0 with keep-alive and a 204 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.0 204 No content\r\n" + "Connection: keep-alive\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 204 + ,.response_status= "No content" + ,.num_headers= 1 + ,.headers= + { { "Connection", "keep-alive" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_200 15 +, {.name= "HTTP/1.1 with an EOF-terminated 200 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 0 + ,.headers={} + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_204 16 +, {.name= "HTTP/1.1 with a 204 status" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 204 No content\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 204 + ,.response_status= "No content" + ,.num_headers= 0 + ,.headers={} + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_NOKA_204 17 +, {.name= "HTTP/1.1 with a 204 status and keep-alive disabled" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 204 No content\r\n" + "Connection: close\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 204 + ,.response_status= "No content" + ,.num_headers= 1 + ,.headers= + { { "Connection", "close" } + } + ,.body_size= 0 + ,.body= "" + } + +#define NO_BODY_HTTP11_KA_CHUNKED_200 18 +, {.name= "HTTP/1.1 with chunked endocing and a 200 response" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 1 + ,.headers= + { { "Transfer-Encoding", "chunked" } + } + ,.body_size= 0 + ,.body= "" + ,.num_chunks_complete= 1 + } + +#if !HTTP_PARSER_STRICT +#define SPACE_IN_FIELD_RES 19 +/* Should handle spaces in header fields */ +, {.name= "field space" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Server: Microsoft-IIS/6.0\r\n" + "X-Powered-By: ASP.NET\r\n" + "en-US Content-Type: text/xml\r\n" /* this is the problem */ + "Content-Type: text/xml\r\n" + "Content-Length: 16\r\n" + "Date: Fri, 23 Jul 2010 18:45:38 GMT\r\n" + "Connection: keep-alive\r\n" + "\r\n" + "hello" /* fake body */ + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 7 + ,.headers= + { { "Server", "Microsoft-IIS/6.0" } + , { "X-Powered-By", "ASP.NET" } + , { "en-US Content-Type", "text/xml" } + , { "Content-Type", "text/xml" } + , { "Content-Length", "16" } + , { "Date", "Fri, 23 Jul 2010 18:45:38 GMT" } + , { "Connection", "keep-alive" } + } + ,.body= "hello" + } +#endif /* !HTTP_PARSER_STRICT */ + +#define AMAZON_COM 20 +, {.name= "amazon.com" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301 MovedPermanently\r\n" + "Date: Wed, 15 May 2013 17:06:33 GMT\r\n" + "Server: Server\r\n" + "x-amz-id-1: 0GPHKXSJQ826RK7GZEB2\r\n" + "p3p: policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"\r\n" + "x-amz-id-2: STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD\r\n" + "Location: http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846\r\n" + "Vary: Accept-Encoding,User-Agent\r\n" + "Content-Type: text/html; charset=ISO-8859-1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "1\r\n" + "\n\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 301 + ,.response_status= "MovedPermanently" + ,.num_headers= 9 + ,.headers= { { "Date", "Wed, 15 May 2013 17:06:33 GMT" } + , { "Server", "Server" } + , { "x-amz-id-1", "0GPHKXSJQ826RK7GZEB2" } + , { "p3p", "policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"" } + , { "x-amz-id-2", "STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD" } + , { "Location", "http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846" } + , { "Vary", "Accept-Encoding,User-Agent" } + , { "Content-Type", "text/html; charset=ISO-8859-1" } + , { "Transfer-Encoding", "chunked" } + } + ,.body= "\n" + ,.num_chunks_complete= 2 + ,.chunk_lengths= { 1 } + } + +#define EMPTY_REASON_PHRASE_AFTER_SPACE 20 +, {.name= "empty reason phrase after space" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 \r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + +#define CONTENT_LENGTH_X 21 +, {.name= "Content-Length-X" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Content-Length-X: 0\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\n" + "OK\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 2 + ,.headers= { { "Content-Length-X", "0" } + , { "Transfer-Encoding", "chunked" } + } + ,.body= "OK" + ,.num_chunks_complete= 2 + ,.chunk_lengths= { 2 } + } + +#define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER 22 +, {.name= "HTTP 101 response with Upgrade header" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 101 Switching Protocols\r\n" + "Connection: upgrade\r\n" + "Upgrade: h2c\r\n" + "\r\n" + "proto" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 101 + ,.response_status= "Switching Protocols" + ,.upgrade= "proto" + ,.num_headers= 2 + ,.headers= + { { "Connection", "upgrade" } + , { "Upgrade", "h2c" } + } + } + +#define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER_AND_CONTENT_LENGTH 23 +, {.name= "HTTP 101 response with Upgrade and Content-Length header" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 101 Switching Protocols\r\n" + "Connection: upgrade\r\n" + "Upgrade: h2c\r\n" + "Content-Length: 4\r\n" + "\r\n" + "body" + "proto" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 101 + ,.response_status= "Switching Protocols" + ,.body= "body" + ,.upgrade= "proto" + ,.num_headers= 3 + ,.headers= + { { "Connection", "upgrade" } + , { "Upgrade", "h2c" } + , { "Content-Length", "4" } + } + } + +#define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER_AND_TRANSFER_ENCODING 24 +, {.name= "HTTP 101 response with Upgrade and Transfer-Encoding header" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 101 Switching Protocols\r\n" + "Connection: upgrade\r\n" + "Upgrade: h2c\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\n" + "bo\r\n" + "2\r\n" + "dy\r\n" + "0\r\n" + "\r\n" + "proto" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 101 + ,.response_status= "Switching Protocols" + ,.body= "body" + ,.upgrade= "proto" + ,.num_headers= 3 + ,.headers= + { { "Connection", "upgrade" } + , { "Upgrade", "h2c" } + , { "Transfer-Encoding", "chunked" } + } + ,.num_chunks_complete= 3 + ,.chunk_lengths= { 2, 2 } + } + +#define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER 25 +, {.name= "HTTP 200 response with Upgrade header" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Connection: upgrade\r\n" + "Upgrade: h2c\r\n" + "\r\n" + "body" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.body= "body" + ,.upgrade= NULL + ,.num_headers= 2 + ,.headers= + { { "Connection", "upgrade" } + , { "Upgrade", "h2c" } + } + } + +#define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER_AND_CONTENT_LENGTH 26 +, {.name= "HTTP 200 response with Upgrade and Content-Length header" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Connection: upgrade\r\n" + "Upgrade: h2c\r\n" + "Content-Length: 4\r\n" + "\r\n" + "body" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 3 + ,.body= "body" + ,.upgrade= NULL + ,.headers= + { { "Connection", "upgrade" } + , { "Upgrade", "h2c" } + , { "Content-Length", "4" } + } + } + +#define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER_AND_TRANSFER_ENCODING 27 +, {.name= "HTTP 200 response with Upgrade and Transfer-Encoding header" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 200 OK\r\n" + "Connection: upgrade\r\n" + "Upgrade: h2c\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\n" + "bo\r\n" + "2\r\n" + "dy\r\n" + "0\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 3 + ,.body= "body" + ,.upgrade= NULL + ,.headers= + { { "Connection", "upgrade" } + , { "Upgrade", "h2c" } + , { "Transfer-Encoding", "chunked" } + } + ,.num_chunks_complete= 3 + ,.chunk_lengths= { 2, 2 } + } +}; + +/* strnlen() is a POSIX.2008 addition. Can't rely on it being available so + * define it ourselves. + */ +size_t +strnlen(const char *s, size_t maxlen) +{ + const char *p; + + p = memchr(s, '\0', maxlen); + if (p == NULL) + return maxlen; + + return p - s; +} + +size_t +strlncat(char *dst, size_t len, const char *src, size_t n) +{ + size_t slen; + size_t dlen; + size_t rlen; + size_t ncpy; + + slen = strnlen(src, n); + dlen = strnlen(dst, len); + + if (dlen < len) { + rlen = len - dlen; + ncpy = slen < rlen ? slen : (rlen - 1); + memcpy(dst + dlen, src, ncpy); + dst[dlen + ncpy] = '\0'; + } + + assert(len > slen + dlen); + return slen + dlen; +} + +size_t +strlncpy(char *dst, size_t len, const char *src, size_t n) +{ + size_t slen; + size_t ncpy; + + slen = strnlen(src, n); + + if (len > 0) { + ncpy = slen < len ? slen : (len - 1); + memcpy(dst, src, ncpy); + dst[ncpy] = '\0'; + } + + assert(len > slen); + return slen; +} + +int +request_url_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + strlncat(messages[num_messages].request_url, + sizeof(messages[num_messages].request_url), + buf, + len); + return 0; +} + +int +header_field_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + struct message *m = &messages[num_messages]; + + if (m->last_header_element != FIELD) + m->num_headers++; + + strlncat(m->headers[m->num_headers-1][0], + sizeof(m->headers[m->num_headers-1][0]), + buf, + len); + + m->last_header_element = FIELD; + + return 0; +} + +int +header_value_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + struct message *m = &messages[num_messages]; + + strlncat(m->headers[m->num_headers-1][1], + sizeof(m->headers[m->num_headers-1][1]), + buf, + len); + + m->last_header_element = VALUE; + + return 0; +} + +void +check_body_is_final (const http_parser *p) +{ + if (messages[num_messages].body_is_final) { + fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " + "on last on_body callback call " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + messages[num_messages].body_is_final = http_body_is_final(p); +} + +int +body_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + strlncat(messages[num_messages].body, + sizeof(messages[num_messages].body), + buf, + len); + messages[num_messages].body_size += len; + check_body_is_final(p); + // printf("body_cb: '%s'\n", requests[num_messages].body); + return 0; +} + +int +count_body_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + assert(buf); + messages[num_messages].body_size += len; + check_body_is_final(p); + return 0; +} + +int +message_begin_cb (http_parser *p) +{ + assert(p == parser); + messages[num_messages].message_begin_cb_called = TRUE; + return 0; +} + +int +headers_complete_cb (http_parser *p) +{ + assert(p == parser); + messages[num_messages].method = parser->method; + messages[num_messages].status_code = parser->status_code; + messages[num_messages].http_major = parser->http_major; + messages[num_messages].http_minor = parser->http_minor; + messages[num_messages].headers_complete_cb_called = TRUE; + messages[num_messages].should_keep_alive = http_should_keep_alive(parser); + return 0; +} + +int +message_complete_cb (http_parser *p) +{ + assert(p == parser); + if (messages[num_messages].should_keep_alive != http_should_keep_alive(parser)) + { + fprintf(stderr, "\n\n *** Error http_should_keep_alive() should have same " + "value in both on_message_complete and on_headers_complete " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + + if (messages[num_messages].body_size && + http_body_is_final(p) && + !messages[num_messages].body_is_final) + { + fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " + "on last on_body callback call " + "but it doesn't! ***\n\n"); + assert(0); + abort(); + } + + messages[num_messages].message_complete_cb_called = TRUE; + + messages[num_messages].message_complete_on_eof = currently_parsing_eof; + + num_messages++; + return 0; +} + +int +response_status_cb (http_parser *p, const char *buf, size_t len) +{ + assert(p == parser); + + messages[num_messages].status_cb_called = TRUE; + + strlncat(messages[num_messages].response_status, + sizeof(messages[num_messages].response_status), + buf, + len); + return 0; +} + +int +chunk_header_cb (http_parser *p) +{ + assert(p == parser); + int chunk_idx = messages[num_messages].num_chunks; + messages[num_messages].num_chunks++; + if (chunk_idx < MAX_CHUNKS) { + messages[num_messages].chunk_lengths[chunk_idx] = p->content_length; + } + + return 0; +} + +int +chunk_complete_cb (http_parser *p) +{ + assert(p == parser); + + /* Here we want to verify that each chunk_header_cb is matched by a + * chunk_complete_cb, so not only should the total number of calls to + * both callbacks be the same, but they also should be interleaved + * properly */ + assert(messages[num_messages].num_chunks == + messages[num_messages].num_chunks_complete + 1); + + messages[num_messages].num_chunks_complete++; + return 0; +} + +/* These dontcall_* callbacks exist so that we can verify that when we're + * paused, no additional callbacks are invoked */ +int +dontcall_message_begin_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_message_begin() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_header_field_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_header_field() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_header_value_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_header_value() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_request_url_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_request_url() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_body_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_body_cb() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_headers_complete_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_headers_complete() called on paused " + "parser ***\n\n"); + abort(); +} + +int +dontcall_message_complete_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_message_complete() called on paused " + "parser ***\n\n"); + abort(); +} + +int +dontcall_response_status_cb (http_parser *p, const char *buf, size_t len) +{ + if (p || buf || len) { } // gcc + fprintf(stderr, "\n\n*** on_status() called on paused parser ***\n\n"); + abort(); +} + +int +dontcall_chunk_header_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_chunk_header() called on paused parser ***\n\n"); + exit(1); +} + +int +dontcall_chunk_complete_cb (http_parser *p) +{ + if (p) { } // gcc + fprintf(stderr, "\n\n*** on_chunk_complete() " + "called on paused parser ***\n\n"); + exit(1); +} + +static http_parser_settings settings_dontcall = + {.on_message_begin = dontcall_message_begin_cb + ,.on_header_field = dontcall_header_field_cb + ,.on_header_value = dontcall_header_value_cb + ,.on_url = dontcall_request_url_cb + ,.on_status = dontcall_response_status_cb + ,.on_body = dontcall_body_cb + ,.on_headers_complete = dontcall_headers_complete_cb + ,.on_message_complete = dontcall_message_complete_cb + ,.on_chunk_header = dontcall_chunk_header_cb + ,.on_chunk_complete = dontcall_chunk_complete_cb + }; + +/* These pause_* callbacks always pause the parser and just invoke the regular + * callback that tracks content. Before returning, we overwrite the parser + * settings to point to the _dontcall variety so that we can verify that + * the pause actually did, you know, pause. */ +int +pause_message_begin_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return message_begin_cb(p); +} + +int +pause_header_field_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return header_field_cb(p, buf, len); +} + +int +pause_header_value_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return header_value_cb(p, buf, len); +} + +int +pause_request_url_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return request_url_cb(p, buf, len); +} + +int +pause_body_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return body_cb(p, buf, len); +} + +int +pause_headers_complete_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return headers_complete_cb(p); +} + +int +pause_message_complete_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return message_complete_cb(p); +} + +int +pause_response_status_cb (http_parser *p, const char *buf, size_t len) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return response_status_cb(p, buf, len); +} + +int +pause_chunk_header_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return chunk_header_cb(p); +} + +int +pause_chunk_complete_cb (http_parser *p) +{ + http_parser_pause(p, 1); + *current_pause_parser = settings_dontcall; + return chunk_complete_cb(p); +} + +int +connect_headers_complete_cb (http_parser *p) +{ + headers_complete_cb(p); + return 1; +} + +int +connect_message_complete_cb (http_parser *p) +{ + messages[num_messages].should_keep_alive = http_should_keep_alive(parser); + return message_complete_cb(p); +} + +static http_parser_settings settings_pause = + {.on_message_begin = pause_message_begin_cb + ,.on_header_field = pause_header_field_cb + ,.on_header_value = pause_header_value_cb + ,.on_url = pause_request_url_cb + ,.on_status = pause_response_status_cb + ,.on_body = pause_body_cb + ,.on_headers_complete = pause_headers_complete_cb + ,.on_message_complete = pause_message_complete_cb + ,.on_chunk_header = pause_chunk_header_cb + ,.on_chunk_complete = pause_chunk_complete_cb + }; + +static http_parser_settings settings = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_status = response_status_cb + ,.on_body = body_cb + ,.on_headers_complete = headers_complete_cb + ,.on_message_complete = message_complete_cb + ,.on_chunk_header = chunk_header_cb + ,.on_chunk_complete = chunk_complete_cb + }; + +static http_parser_settings settings_count_body = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_status = response_status_cb + ,.on_body = count_body_cb + ,.on_headers_complete = headers_complete_cb + ,.on_message_complete = message_complete_cb + ,.on_chunk_header = chunk_header_cb + ,.on_chunk_complete = chunk_complete_cb + }; + +static http_parser_settings settings_connect = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_status = response_status_cb + ,.on_body = dontcall_body_cb + ,.on_headers_complete = connect_headers_complete_cb + ,.on_message_complete = connect_message_complete_cb + ,.on_chunk_header = chunk_header_cb + ,.on_chunk_complete = chunk_complete_cb + }; + +static http_parser_settings settings_null = + {.on_message_begin = 0 + ,.on_header_field = 0 + ,.on_header_value = 0 + ,.on_url = 0 + ,.on_status = 0 + ,.on_body = 0 + ,.on_headers_complete = 0 + ,.on_message_complete = 0 + ,.on_chunk_header = 0 + ,.on_chunk_complete = 0 + }; + +void +parser_init (enum http_parser_type type) +{ + num_messages = 0; + + assert(parser == NULL); + + parser = malloc(sizeof(http_parser)); + + http_parser_init(parser, type); + + memset(&messages, 0, sizeof messages); + +} + +void +parser_free () +{ + assert(parser); + free(parser); + parser = NULL; +} + +size_t parse (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings, buf, len); + return nparsed; +} + +size_t parse_count_body (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings_count_body, buf, len); + return nparsed; +} + +size_t parse_pause (const char *buf, size_t len) +{ + size_t nparsed; + http_parser_settings s = settings_pause; + + currently_parsing_eof = (len == 0); + current_pause_parser = &s; + nparsed = http_parser_execute(parser, current_pause_parser, buf, len); + return nparsed; +} + +size_t parse_connect (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings_connect, buf, len); + return nparsed; +} + +static inline int +check_str_eq (const struct message *m, + const char *prop, + const char *expected, + const char *found) { + if ((expected == NULL) != (found == NULL)) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected %s\n", (expected == NULL) ? "NULL" : expected); + printf(" found %s\n", (found == NULL) ? "NULL" : found); + return 0; + } + if (expected != NULL && 0 != strcmp(expected, found)) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected '%s'\n", expected); + printf(" found '%s'\n", found); + return 0; + } + return 1; +} + +static inline int +check_num_eq (const struct message *m, + const char *prop, + int expected, + int found) { + if (expected != found) { + printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); + printf("expected %d\n", expected); + printf(" found %d\n", found); + return 0; + } + return 1; +} + +#define MESSAGE_CHECK_STR_EQ(expected, found, prop) \ + if (!check_str_eq(expected, #prop, expected->prop, found->prop)) return 0 + +#define MESSAGE_CHECK_NUM_EQ(expected, found, prop) \ + if (!check_num_eq(expected, #prop, expected->prop, found->prop)) return 0 + +#define MESSAGE_CHECK_URL_EQ(u, expected, found, prop, fn) \ +do { \ + char ubuf[256]; \ + \ + if ((u)->field_set & (1 << (fn))) { \ + memcpy(ubuf, (found)->request_url + (u)->field_data[(fn)].off, \ + (u)->field_data[(fn)].len); \ + ubuf[(u)->field_data[(fn)].len] = '\0'; \ + } else { \ + ubuf[0] = '\0'; \ + } \ + \ + check_str_eq(expected, #prop, expected->prop, ubuf); \ +} while(0) + +int +message_eq (int index, int connect, const struct message *expected) +{ + int i; + struct message *m = &messages[index]; + + MESSAGE_CHECK_NUM_EQ(expected, m, http_major); + MESSAGE_CHECK_NUM_EQ(expected, m, http_minor); + + if (expected->type == HTTP_REQUEST) { + MESSAGE_CHECK_NUM_EQ(expected, m, method); + } else { + MESSAGE_CHECK_NUM_EQ(expected, m, status_code); + MESSAGE_CHECK_STR_EQ(expected, m, response_status); + assert(m->status_cb_called); + } + + if (!connect) { + MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); + MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof); + } + + assert(m->message_begin_cb_called); + assert(m->headers_complete_cb_called); + assert(m->message_complete_cb_called); + + + MESSAGE_CHECK_STR_EQ(expected, m, request_url); + + /* Check URL components; we can't do this w/ CONNECT since it doesn't + * send us a well-formed URL. + */ + if (*m->request_url && m->method != HTTP_CONNECT) { + struct http_parser_url u; + + if (http_parser_parse_url(m->request_url, strlen(m->request_url), 0, &u)) { + fprintf(stderr, "\n\n*** failed to parse URL %s ***\n\n", + m->request_url); + abort(); + } + + if (expected->host) { + MESSAGE_CHECK_URL_EQ(&u, expected, m, host, UF_HOST); + } + + if (expected->userinfo) { + MESSAGE_CHECK_URL_EQ(&u, expected, m, userinfo, UF_USERINFO); + } + + m->port = (u.field_set & (1 << UF_PORT)) ? + u.port : 0; + + MESSAGE_CHECK_URL_EQ(&u, expected, m, query_string, UF_QUERY); + MESSAGE_CHECK_URL_EQ(&u, expected, m, fragment, UF_FRAGMENT); + MESSAGE_CHECK_URL_EQ(&u, expected, m, request_path, UF_PATH); + MESSAGE_CHECK_NUM_EQ(expected, m, port); + } + + if (connect) { + check_num_eq(m, "body_size", 0, m->body_size); + } else if (expected->body_size) { + MESSAGE_CHECK_NUM_EQ(expected, m, body_size); + } else { + MESSAGE_CHECK_STR_EQ(expected, m, body); + } + + if (connect) { + check_num_eq(m, "num_chunks_complete", 0, m->num_chunks_complete); + } else { + assert(m->num_chunks == m->num_chunks_complete); + MESSAGE_CHECK_NUM_EQ(expected, m, num_chunks_complete); + for (i = 0; i < m->num_chunks && i < MAX_CHUNKS; i++) { + MESSAGE_CHECK_NUM_EQ(expected, m, chunk_lengths[i]); + } + } + + MESSAGE_CHECK_NUM_EQ(expected, m, num_headers); + + int r; + for (i = 0; i < m->num_headers; i++) { + r = check_str_eq(expected, "header field", expected->headers[i][0], m->headers[i][0]); + if (!r) return 0; + r = check_str_eq(expected, "header value", expected->headers[i][1], m->headers[i][1]); + if (!r) return 0; + } + + if (!connect) { + MESSAGE_CHECK_STR_EQ(expected, m, upgrade); + } + + return 1; +} + +/* Given a sequence of varargs messages, return the number of them that the + * parser should successfully parse, taking into account that upgraded + * messages prevent all subsequent messages from being parsed. + */ +size_t +count_parsed_messages(const size_t nmsgs, ...) { + size_t i; + va_list ap; + + va_start(ap, nmsgs); + + for (i = 0; i < nmsgs; i++) { + struct message *m = va_arg(ap, struct message *); + + if (m->upgrade) { + va_end(ap); + return i + 1; + } + } + + va_end(ap); + return nmsgs; +} + +/* Given a sequence of bytes and the number of these that we were able to + * parse, verify that upgrade bodies are correct. + */ +void +upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { + va_list ap; + size_t i; + size_t off = 0; + + va_start(ap, nmsgs); + + for (i = 0; i < nmsgs; i++) { + struct message *m = va_arg(ap, struct message *); + + off += strlen(m->raw); + + if (m->upgrade) { + off -= strlen(m->upgrade); + + /* Check the portion of the response after its specified upgrade */ + if (!check_str_eq(m, "upgrade", body + off, body + nread)) { + abort(); + } + + /* Fix up the response so that message_eq() will verify the beginning + * of the upgrade */ + *(body + nread + strlen(m->upgrade)) = '\0'; + messages[num_messages -1 ].upgrade = body + nread; + + va_end(ap); + return; + } + } + + va_end(ap); + printf("\n\n*** Error: expected a message with upgrade ***\n"); + + abort(); +} + +static void +print_error (const char *raw, size_t error_location) +{ + fprintf(stderr, "\n*** %s ***\n\n", + http_errno_description(HTTP_PARSER_ERRNO(parser))); + + int this_line = 0, char_len = 0; + size_t i, j, len = strlen(raw), error_location_line = 0; + for (i = 0; i < len; i++) { + if (i == error_location) this_line = 1; + switch (raw[i]) { + case '\r': + char_len = 2; + fprintf(stderr, "\\r"); + break; + + case '\n': + fprintf(stderr, "\\n\n"); + + if (this_line) goto print; + + error_location_line = 0; + continue; + + default: + char_len = 1; + fputc(raw[i], stderr); + break; + } + if (!this_line) error_location_line += char_len; + } + + fprintf(stderr, "[eof]\n"); + + print: + for (j = 0; j < error_location_line; j++) { + fputc(' ', stderr); + } + fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location); +} + +void +test_preserve_data (void) +{ + char my_data[] = "application-specific data"; + http_parser parser; + parser.data = my_data; + http_parser_init(&parser, HTTP_REQUEST); + if (parser.data != my_data) { + printf("\n*** parser.data not preserved accross http_parser_init ***\n\n"); + abort(); + } +} + +struct url_test { + const char *name; + const char *url; + int is_connect; + struct http_parser_url u; + int rv; +}; + +const struct url_test url_tests[] = +{ {.name="proxy request" + ,.url="http://hostname/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 7, 8 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 15, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="proxy request with port" + ,.url="http://hostname:444/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) + ,.port=444 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 7, 8 } /* UF_HOST */ + ,{ 16, 3 } /* UF_PORT */ + ,{ 19, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT request" + ,.url="hostname:443" + ,.is_connect=1 + ,.u= + {.field_set=(1 << UF_HOST) | (1 << UF_PORT) + ,.port=443 + ,.field_data= + {{ 0, 0 } /* UF_SCHEMA */ + ,{ 0, 8 } /* UF_HOST */ + ,{ 9, 3 } /* UF_PORT */ + ,{ 0, 0 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT request but not connect" + ,.url="hostname:443" + ,.is_connect=0 + ,.rv=1 + } + +, {.name="proxy ipv6 request" + ,.url="http://[1:2::3:4]/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 8 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 17, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="proxy ipv6 request with port" + ,.url="http://[1:2::3:4]:67/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) + ,.port=67 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 8 } /* UF_HOST */ + ,{ 18, 2 } /* UF_PORT */ + ,{ 20, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="CONNECT ipv6 address" + ,.url="[1:2::3:4]:443" + ,.is_connect=1 + ,.u= + {.field_set=(1 << UF_HOST) | (1 << UF_PORT) + ,.port=443 + ,.field_data= + {{ 0, 0 } /* UF_SCHEMA */ + ,{ 1, 8 } /* UF_HOST */ + ,{ 11, 3 } /* UF_PORT */ + ,{ 0, 0 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="ipv4 in ipv6 address" + ,.url="http://[2001:0000:0000:0000:0000:0000:1.9.1.1]/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 37 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 46, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + +, {.name="extra ? in query string" + ,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css," + "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css," + "fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css" + ,.is_connect=0 + ,.u= + {.field_set=(1<field_set, u->port); + for (i = 0; i < UF_MAX; i++) { + if ((u->field_set & (1 << i)) == 0) { + printf("\tfield_data[%u]: unset\n", i); + continue; + } + + printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n\"", + i, + u->field_data[i].off, + u->field_data[i].len, + u->field_data[i].len, + url + u->field_data[i].off); + } +} + +void +test_parse_url (void) +{ + struct http_parser_url u; + const struct url_test *test; + unsigned int i; + int rv; + + for (i = 0; i < (sizeof(url_tests) / sizeof(url_tests[0])); i++) { + test = &url_tests[i]; + memset(&u, 0, sizeof(u)); + + rv = http_parser_parse_url(test->url, + strlen(test->url), + test->is_connect, + &u); + + if (test->rv == 0) { + if (rv != 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " + "unexpected rv %d ***\n\n", test->url, test->name, rv); + abort(); + } + + if (memcmp(&u, &test->u, sizeof(u)) != 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" failed ***\n", + test->url, test->name); + + printf("target http_parser_url:\n"); + dump_url(test->url, &test->u); + printf("result http_parser_url:\n"); + dump_url(test->url, &u); + + abort(); + } + } else { + /* test->rv != 0 */ + if (rv == 0) { + printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " + "unexpected rv %d ***\n\n", test->url, test->name, rv); + abort(); + } + } + } +} + +void +test_method_str (void) +{ + assert(0 == strcmp("GET", http_method_str(HTTP_GET))); + assert(0 == strcmp("", http_method_str(1337))); +} + +void +test_message (const struct message *message) +{ + size_t raw_len = strlen(message->raw); + size_t msg1len; + for (msg1len = 0; msg1len < raw_len; msg1len++) { + parser_init(message->type); + + size_t read; + const char *msg1 = message->raw; + const char *msg2 = msg1 + msg1len; + size_t msg2len = raw_len - msg1len; + + if (msg1len) { + read = parse(msg1, msg1len); + + if (message->upgrade && parser->upgrade && num_messages > 0) { + messages[num_messages - 1].upgrade = msg1 + read; + goto test; + } + + if (read != msg1len) { + print_error(msg1, read); + abort(); + } + } + + + read = parse(msg2, msg2len); + + if (message->upgrade && parser->upgrade) { + messages[num_messages - 1].upgrade = msg2 + read; + goto test; + } + + if (read != msg2len) { + print_error(msg2, read); + abort(); + } + + read = parse(NULL, 0); + + if (read != 0) { + print_error(message->raw, read); + abort(); + } + + test: + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); + abort(); + } + + if(!message_eq(0, 0, message)) abort(); + + parser_free(); + } +} + +void +test_message_count_body (const struct message *message) +{ + parser_init(message->type); + + size_t read; + size_t l = strlen(message->raw); + size_t i, toread; + size_t chunk = 4024; + + for (i = 0; i < l; i+= chunk) { + toread = MIN(l-i, chunk); + read = parse_count_body(message->raw + i, toread); + if (read != toread) { + print_error(message->raw, read); + abort(); + } + } + + + read = parse_count_body(NULL, 0); + if (read != 0) { + print_error(message->raw, read); + abort(); + } + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); + abort(); + } + + if(!message_eq(0, 0, message)) abort(); + + parser_free(); +} + +void +test_simple_type (const char *buf, + enum http_errno err_expected, + enum http_parser_type type) +{ + parser_init(type); + + enum http_errno err; + + parse(buf, strlen(buf)); + err = HTTP_PARSER_ERRNO(parser); + parse(NULL, 0); + + parser_free(); + + /* In strict mode, allow us to pass with an unexpected HPE_STRICT as + * long as the caller isn't expecting success. + */ +#if HTTP_PARSER_STRICT + if (err_expected != err && err_expected != HPE_OK && err != HPE_STRICT) { +#else + if (err_expected != err) { +#endif + fprintf(stderr, "\n*** test_simple expected %s, but saw %s ***\n\n%s\n", + http_errno_name(err_expected), http_errno_name(err), buf); + abort(); + } +} + +void +test_simple (const char *buf, enum http_errno err_expected) +{ + test_simple_type(buf, err_expected, HTTP_REQUEST); +} + +void +test_invalid_header_content (int req, const char* str) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? + "GET / HTTP/1.1\r\n" : + "HTTP/1.1 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = str; + size_t buflen = strlen(buf); + + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN); + return; + } + + fprintf(stderr, + "\n*** Error expected but none in invalid header content test ***\n"); + abort(); +} + +void +test_invalid_header_field_content_error (int req) +{ + test_invalid_header_content(req, "Foo: F\01ailure"); + test_invalid_header_content(req, "Foo: B\02ar"); +} + +void +test_invalid_header_field (int req, const char* str) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? + "GET / HTTP/1.1\r\n" : + "HTTP/1.1 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = str; + size_t buflen = strlen(buf); + + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN); + return; + } + + fprintf(stderr, + "\n*** Error expected but none in invalid header token test ***\n"); + abort(); +} + +void +test_invalid_header_field_token_error (int req) +{ + test_invalid_header_field(req, "Fo@: Failure"); + test_invalid_header_field(req, "Foo\01\test: Bar"); +} + +void +test_double_content_length_error (int req) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? + "GET / HTTP/1.1\r\n" : + "HTTP/1.1 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = "Content-Length: 0\r\nContent-Length: 1\r\n\r\n"; + size_t buflen = strlen(buf); + + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH); + return; + } + + fprintf(stderr, + "\n*** Error expected but none in double content-length test ***\n"); + abort(); +} + +void +test_chunked_content_length_error (int req) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? + "GET / HTTP/1.1\r\n" : + "HTTP/1.1 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = "Transfer-Encoding: chunked\r\nContent-Length: 1\r\n\r\n"; + size_t buflen = strlen(buf); + + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH); + return; + } + + fprintf(stderr, + "\n*** Error expected but none in chunked content-length test ***\n"); + abort(); +} + +void +test_header_cr_no_lf_error (int req) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? + "GET / HTTP/1.1\r\n" : + "HTTP/1.1 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = "Foo: 1\rBar: 1\r\n\r\n"; + size_t buflen = strlen(buf); + + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + assert(HTTP_PARSER_ERRNO(&parser) == HPE_LF_EXPECTED); + return; + } + + fprintf(stderr, + "\n*** Error expected but none in header whitespace test ***\n"); + abort(); +} + +void +test_no_overflow_parse_url (void) +{ + int rv; + struct http_parser_url u; + + http_parser_url_init(&u); + rv = http_parser_parse_url("http://example.com:8001", 22, 0, &u); + + if (rv != 0) { + fprintf(stderr, + "\n*** test_no_overflow_parse_url invalid return value=%d\n", + rv); + abort(); + } + + if (u.port != 800) { + fprintf(stderr, + "\n*** test_no_overflow_parse_url invalid port number=%d\n", + u.port); + abort(); + } +} + +void +test_header_overflow_error (int req) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + const char *buf; + buf = req ? "GET / HTTP/1.1\r\n" : "HTTP/1.0 200 OK\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + buf = "header-key: header-value\r\n"; + size_t buflen = strlen(buf); + + int i; + for (i = 0; i < 10000; i++) { + parsed = http_parser_execute(&parser, &settings_null, buf, buflen); + if (parsed != buflen) { + //fprintf(stderr, "error found on iter %d\n", i); + assert(HTTP_PARSER_ERRNO(&parser) == HPE_HEADER_OVERFLOW); + return; + } + } + + fprintf(stderr, "\n*** Error expected but none in header overflow test ***\n"); + abort(); +} + + +void +test_header_nread_value () +{ + http_parser parser; + http_parser_init(&parser, HTTP_REQUEST); + size_t parsed; + const char *buf; + buf = "GET / HTTP/1.1\r\nheader: value\nhdr: value\r\n"; + parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); + assert(parsed == strlen(buf)); + + assert(parser.nread == strlen(buf)); +} + + +static void +test_content_length_overflow (const char *buf, size_t buflen, int expect_ok) +{ + http_parser parser; + http_parser_init(&parser, HTTP_RESPONSE); + http_parser_execute(&parser, &settings_null, buf, buflen); + + if (expect_ok) + assert(HTTP_PARSER_ERRNO(&parser) == HPE_OK); + else + assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_CONTENT_LENGTH); +} + +void +test_header_content_length_overflow_error (void) +{ +#define X(size) \ + "HTTP/1.1 200 OK\r\n" \ + "Content-Length: " #size "\r\n" \ + "\r\n" + const char a[] = X(1844674407370955160); /* 2^64 / 10 - 1 */ + const char b[] = X(18446744073709551615); /* 2^64-1 */ + const char c[] = X(18446744073709551616); /* 2^64 */ +#undef X + test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ + test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ + test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ +} + +void +test_chunk_content_length_overflow_error (void) +{ +#define X(size) \ + "HTTP/1.1 200 OK\r\n" \ + "Transfer-Encoding: chunked\r\n" \ + "\r\n" \ + #size "\r\n" \ + "..." + const char a[] = X(FFFFFFFFFFFFFFE); /* 2^64 / 16 - 1 */ + const char b[] = X(FFFFFFFFFFFFFFFF); /* 2^64-1 */ + const char c[] = X(10000000000000000); /* 2^64 */ +#undef X + test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ + test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ + test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ +} + +void +test_no_overflow_long_body (int req, size_t length) +{ + http_parser parser; + http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); + size_t parsed; + size_t i; + char buf1[3000]; + size_t buf1len = sprintf(buf1, "%s\r\nConnection: Keep-Alive\r\nContent-Length: %lu\r\n\r\n", + req ? "POST / HTTP/1.0" : "HTTP/1.0 200 OK", (unsigned long)length); + parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); + if (parsed != buf1len) + goto err; + + for (i = 0; i < length; i++) { + char foo = 'a'; + parsed = http_parser_execute(&parser, &settings_null, &foo, 1); + if (parsed != 1) + goto err; + } + + parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); + if (parsed != buf1len) goto err; + return; + + err: + fprintf(stderr, + "\n*** error in test_no_overflow_long_body %s of length %lu ***\n", + req ? "REQUEST" : "RESPONSE", + (unsigned long)length); + abort(); +} + +void +test_multiple3 (const struct message *r1, const struct message *r2, const struct message *r3) +{ + int message_count = count_parsed_messages(3, r1, r2, r3); + + char total[ strlen(r1->raw) + + strlen(r2->raw) + + strlen(r3->raw) + + 1 + ]; + total[0] = '\0'; + + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); + + parser_init(r1->type); + + size_t read; + + read = parse(total, strlen(total)); + + if (parser->upgrade) { + upgrade_message_fix(total, read, 3, r1, r2, r3); + goto test; + } + + if (read != strlen(total)) { + print_error(total, read); + abort(); + } + + read = parse(NULL, 0); + + if (read != 0) { + print_error(total, read); + abort(); + } + +test: + + if (message_count != num_messages) { + fprintf(stderr, "\n\n*** Parser didn't see 3 messages only %d *** \n", num_messages); + abort(); + } + + if (!message_eq(0, 0, r1)) abort(); + if (message_count > 1 && !message_eq(1, 0, r2)) abort(); + if (message_count > 2 && !message_eq(2, 0, r3)) abort(); + + parser_free(); +} + +/* SCAN through every possible breaking to make sure the + * parser can handle getting the content in any chunks that + * might come from the socket + */ +void +test_scan (const struct message *r1, const struct message *r2, const struct message *r3) +{ + char total[80*1024] = "\0"; + char buf1[80*1024] = "\0"; + char buf2[80*1024] = "\0"; + char buf3[80*1024] = "\0"; + + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); + + size_t read; + + int total_len = strlen(total); + + int total_ops = 2 * (total_len - 1) * (total_len - 2) / 2; + int ops = 0 ; + + size_t buf1_len, buf2_len, buf3_len; + int message_count = count_parsed_messages(3, r1, r2, r3); + + int i,j,type_both; + for (type_both = 0; type_both < 2; type_both ++ ) { + for (j = 2; j < total_len; j ++ ) { + for (i = 1; i < j; i ++ ) { + + if (ops % 1000 == 0) { + printf("\b\b\b\b%3.0f%%", 100 * (float)ops /(float)total_ops); + fflush(stdout); + } + ops += 1; + + parser_init(type_both ? HTTP_BOTH : r1->type); + + buf1_len = i; + strlncpy(buf1, sizeof(buf1), total, buf1_len); + buf1[buf1_len] = 0; + + buf2_len = j - i; + strlncpy(buf2, sizeof(buf1), total+i, buf2_len); + buf2[buf2_len] = 0; + + buf3_len = total_len - j; + strlncpy(buf3, sizeof(buf1), total+j, buf3_len); + buf3[buf3_len] = 0; + + read = parse(buf1, buf1_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len) { + print_error(buf1, read); + goto error; + } + + read += parse(buf2, buf2_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len + buf2_len) { + print_error(buf2, read); + goto error; + } + + read += parse(buf3, buf3_len); + + if (parser->upgrade) goto test; + + if (read != buf1_len + buf2_len + buf3_len) { + print_error(buf3, read); + goto error; + } + + parse(NULL, 0); + +test: + if (parser->upgrade) { + upgrade_message_fix(total, read, 3, r1, r2, r3); + } + + if (message_count != num_messages) { + fprintf(stderr, "\n\nParser didn't see %d messages only %d\n", + message_count, num_messages); + goto error; + } + + if (!message_eq(0, 0, r1)) { + fprintf(stderr, "\n\nError matching messages[0] in test_scan.\n"); + goto error; + } + + if (message_count > 1 && !message_eq(1, 0, r2)) { + fprintf(stderr, "\n\nError matching messages[1] in test_scan.\n"); + goto error; + } + + if (message_count > 2 && !message_eq(2, 0, r3)) { + fprintf(stderr, "\n\nError matching messages[2] in test_scan.\n"); + goto error; + } + + parser_free(); + } + } + } + puts("\b\b\b\b100%"); + return; + + error: + fprintf(stderr, "i=%d j=%d\n", i, j); + fprintf(stderr, "buf1 (%u) %s\n\n", (unsigned int)buf1_len, buf1); + fprintf(stderr, "buf2 (%u) %s\n\n", (unsigned int)buf2_len , buf2); + fprintf(stderr, "buf3 (%u) %s\n", (unsigned int)buf3_len, buf3); + abort(); +} + +// user required to free the result +// string terminated by \0 +char * +create_large_chunked_message (int body_size_in_kb, const char* headers) +{ + int i; + size_t wrote = 0; + size_t headers_len = strlen(headers); + size_t bufsize = headers_len + (5+1024+2)*body_size_in_kb + 6; + char * buf = malloc(bufsize); + + memcpy(buf, headers, headers_len); + wrote += headers_len; + + for (i = 0; i < body_size_in_kb; i++) { + // write 1kb chunk into the body. + memcpy(buf + wrote, "400\r\n", 5); + wrote += 5; + memset(buf + wrote, 'C', 1024); + wrote += 1024; + strcpy(buf + wrote, "\r\n"); + wrote += 2; + } + + memcpy(buf + wrote, "0\r\n\r\n", 6); + wrote += 6; + assert(wrote == bufsize); + + return buf; +} + +/* Verify that we can pause parsing at any of the bytes in the + * message and still get the result that we're expecting. */ +void +test_message_pause (const struct message *msg) +{ + char *buf = (char*) msg->raw; + size_t buflen = strlen(msg->raw); + size_t nread; + + parser_init(msg->type); + + do { + nread = parse_pause(buf, buflen); + + // We can only set the upgrade buffer once we've gotten our message + // completion callback. + if (messages[0].message_complete_cb_called && + msg->upgrade && + parser->upgrade) { + messages[0].upgrade = buf + nread; + goto test; + } + + if (nread < buflen) { + + // Not much do to if we failed a strict-mode check + if (HTTP_PARSER_ERRNO(parser) == HPE_STRICT) { + parser_free(); + return; + } + + assert (HTTP_PARSER_ERRNO(parser) == HPE_PAUSED); + } + + buf += nread; + buflen -= nread; + http_parser_pause(parser, 0); + } while (buflen > 0); + + nread = parse_pause(NULL, 0); + assert (nread == 0); + +test: + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); + abort(); + } + + if(!message_eq(0, 0, msg)) abort(); + + parser_free(); +} + +/* Verify that body and next message won't be parsed in responses to CONNECT */ +void +test_message_connect (const struct message *msg) +{ + char *buf = (char*) msg->raw; + size_t buflen = strlen(msg->raw); + + parser_init(msg->type); + + parse_connect(buf, buflen); + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); + abort(); + } + + if(!message_eq(0, 1, msg)) abort(); + + parser_free(); +} + +int +main (void) +{ + parser = NULL; + unsigned i, j, k; + unsigned long version; + unsigned major; + unsigned minor; + unsigned patch; + + version = http_parser_version(); + major = (version >> 16) & 255; + minor = (version >> 8) & 255; + patch = version & 255; + printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version); + + printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser)); + + //// API + test_preserve_data(); + test_parse_url(); + test_method_str(); + + //// NREAD + test_header_nread_value(); + + //// OVERFLOW CONDITIONS + test_no_overflow_parse_url(); + + test_header_overflow_error(HTTP_REQUEST); + test_no_overflow_long_body(HTTP_REQUEST, 1000); + test_no_overflow_long_body(HTTP_REQUEST, 100000); + + test_header_overflow_error(HTTP_RESPONSE); + test_no_overflow_long_body(HTTP_RESPONSE, 1000); + test_no_overflow_long_body(HTTP_RESPONSE, 100000); + + test_header_content_length_overflow_error(); + test_chunk_content_length_overflow_error(); + + //// HEADER FIELD CONDITIONS + test_double_content_length_error(HTTP_REQUEST); + test_chunked_content_length_error(HTTP_REQUEST); + test_header_cr_no_lf_error(HTTP_REQUEST); + test_invalid_header_field_token_error(HTTP_REQUEST); + test_invalid_header_field_content_error(HTTP_REQUEST); + test_double_content_length_error(HTTP_RESPONSE); + test_chunked_content_length_error(HTTP_RESPONSE); + test_header_cr_no_lf_error(HTTP_RESPONSE); + test_invalid_header_field_token_error(HTTP_RESPONSE); + test_invalid_header_field_content_error(HTTP_RESPONSE); + + test_simple_type( + "POST / HTTP/1.1\r\n" + "Content-Length: 42 \r\n" // Note the surrounding whitespace. + "\r\n", + HPE_OK, + HTTP_REQUEST); + + test_simple_type( + "POST / HTTP/1.1\r\n" + "Content-Length: 4 2\r\n" + "\r\n", + HPE_INVALID_CONTENT_LENGTH, + HTTP_REQUEST); + + test_simple_type( + "POST / HTTP/1.1\r\n" + "Content-Length: 13 37\r\n" + "\r\n", + HPE_INVALID_CONTENT_LENGTH, + HTTP_REQUEST); + + //// RESPONSES + + test_simple_type("HTP/1.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); + test_simple_type("HTTP/01.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); + test_simple_type("HTTP/11.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); + test_simple_type("HTTP/1.01 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); + test_simple_type("HTTP/1.1\t200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); + + for (i = 0; i < ARRAY_SIZE(responses); i++) { + test_message(&responses[i]); + } + + for (i = 0; i < ARRAY_SIZE(responses); i++) { + test_message_pause(&responses[i]); + } + + for (i = 0; i < ARRAY_SIZE(responses); i++) { + test_message_connect(&responses[i]); + } + + for (i = 0; i < ARRAY_SIZE(responses); i++) { + if (!responses[i].should_keep_alive) continue; + for (j = 0; j < ARRAY_SIZE(responses); j++) { + if (!responses[j].should_keep_alive) continue; + for (k = 0; k < ARRAY_SIZE(responses); k++) { + test_multiple3(&responses[i], &responses[j], &responses[k]); + } + } + } + + test_message_count_body(&responses[NO_HEADERS_NO_BODY_404]); + test_message_count_body(&responses[TRAILING_SPACE_ON_CHUNKED_BODY]); + + // test very large chunked response + { + char * msg = create_large_chunked_message(31337, + "HTTP/1.0 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain\r\n" + "\r\n"); + struct message large_chunked = + {.name= "large chunked" + ,.type= HTTP_RESPONSE + ,.raw= msg + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 0 + ,.status_code= 200 + ,.response_status= "OK" + ,.num_headers= 2 + ,.headers= + { { "Transfer-Encoding", "chunked" } + , { "Content-Type", "text/plain" } + } + ,.body_size= 31337*1024 + ,.num_chunks_complete= 31338 + }; + for (i = 0; i < MAX_CHUNKS; i++) { + large_chunked.chunk_lengths[i] = 1024; + } + test_message_count_body(&large_chunked); + free(msg); + } + + + + printf("response scan 1/2 "); + test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY] + , &responses[NO_BODY_HTTP10_KA_204] + , &responses[NO_REASON_PHRASE] + ); + + printf("response scan 2/2 "); + test_scan( &responses[BONJOUR_MADAME_FR] + , &responses[UNDERSTORE_HEADER_KEY] + , &responses[NO_CARRIAGE_RET] + ); + + puts("responses okay"); + + + /// REQUESTS + + test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION); + test_simple("GET / HTTP/01.1\r\n\r\n", HPE_INVALID_VERSION); + test_simple("GET / HTTP/11.1\r\n\r\n", HPE_INVALID_VERSION); + test_simple("GET / HTTP/1.01\r\n\r\n", HPE_INVALID_VERSION); + + // Extended characters - see nodejs/test/parallel/test-http-headers-obstext.js + test_simple("GET / HTTP/1.1\r\n" + "Test: Düsseldorf\r\n", + HPE_OK); + + // Well-formed but incomplete + test_simple("GET / HTTP/1.1\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 6\r\n" + "\r\n" + "fooba", + HPE_OK); + + static const char *all_methods[] = { + "DELETE", + "GET", + "HEAD", + "POST", + "PUT", + //"CONNECT", //CONNECT can't be tested like other methods, it's a tunnel + "OPTIONS", + "TRACE", + "COPY", + "LOCK", + "MKCOL", + "MOVE", + "PROPFIND", + "PROPPATCH", + "SEARCH", + "UNLOCK", + "BIND", + "REBIND", + "UNBIND", + "ACL", + "REPORT", + "MKACTIVITY", + "CHECKOUT", + "MERGE", + "M-SEARCH", + "NOTIFY", + "SUBSCRIBE", + "UNSUBSCRIBE", + "PATCH", + "PURGE", + "MKCALENDAR", + "LINK", + "UNLINK", + 0 }; + const char **this_method; + for (this_method = all_methods; *this_method; this_method++) { + char buf[200]; + sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); + test_simple(buf, HPE_OK); + } + + static const char *bad_methods[] = { + "ASDF", + "C******", + "COLA", + "GEM", + "GETA", + "M****", + "MKCOLA", + "PROPPATCHA", + "PUN", + "PX", + "SA", + "hello world", + 0 }; + for (this_method = bad_methods; *this_method; this_method++) { + char buf[200]; + sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); + test_simple(buf, HPE_INVALID_METHOD); + } + + // illegal header field name line folding + test_simple("GET / HTTP/1.1\r\n" + "name\r\n" + " : value\r\n" + "\r\n", + HPE_INVALID_HEADER_TOKEN); + + const char *dumbfuck2 = + "GET / HTTP/1.1\r\n" + "X-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n" + "\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n" + "\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n" + "\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n" + "\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n" + "\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n" + "\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n" + "\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n" + "\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n" + "\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n" + "\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n" + "\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\r\n" + "\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\r\n" + "\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgHTTPAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\r\n" + "\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\r\n" + "\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\r\n" + "\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\r\n" + "\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\r\n" + "\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\r\n" + "\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\r\n" + "\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\r\n" + "\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\r\n" + "\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\r\n" + "\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\r\n" + "\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\r\n" + "\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\r\n" + "\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n" + "\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n" + "\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n" + "\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n" + "\tRA==\r\n" + "\t-----END CERTIFICATE-----\r\n" + "\r\n"; + test_simple(dumbfuck2, HPE_OK); + + const char *corrupted_connection = + "GET / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Connection\r\033\065\325eep-Alive\r\n" + "Accept-Encoding: gzip\r\n" + "\r\n"; + test_simple(corrupted_connection, HPE_INVALID_HEADER_TOKEN); + + const char *corrupted_header_name = + "GET / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "X-Some-Header\r\033\065\325eep-Alive\r\n" + "Accept-Encoding: gzip\r\n" + "\r\n"; + test_simple(corrupted_header_name, HPE_INVALID_HEADER_TOKEN); + +#if 0 + // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body + // until EOF. + // + // no content-length + // error if there is a body without content length + const char *bad_get_no_headers_no_body = "GET /bad_get_no_headers_no_body/world HTTP/1.1\r\n" + "Accept: */*\r\n" + "\r\n" + "HELLO"; + test_simple(bad_get_no_headers_no_body, 0); +#endif + /* TODO sending junk and large headers gets rejected */ + + + /* check to make sure our predefined requests are okay */ + for (i = 0; i < ARRAY_SIZE(requests); i++) { + test_message(&requests[i]); + } + + for (i = 0; i < ARRAY_SIZE(requests); i++) { + test_message_pause(&requests[i]); + } + + for (i = 0; i < ARRAY_SIZE(requests); i++) { + if (!requests[i].should_keep_alive) continue; + for (j = 0; j < ARRAY_SIZE(requests); j++) { + if (!requests[j].should_keep_alive) continue; + for (k = 0; k < ARRAY_SIZE(requests); k++) { + test_multiple3(&requests[i], &requests[j], &requests[k]); + } + } + } + + printf("request scan 1/4 "); + test_scan( &requests[GET_NO_HEADERS_NO_BODY] + , &requests[GET_ONE_HEADER_NO_BODY] + , &requests[GET_NO_HEADERS_NO_BODY] + ); + + printf("request scan 2/4 "); + test_scan( &requests[POST_CHUNKED_ALL_YOUR_BASE] + , &requests[POST_IDENTITY_BODY_WORLD] + , &requests[GET_FUNKY_CONTENT_LENGTH] + ); + + printf("request scan 3/4 "); + test_scan( &requests[TWO_CHUNKS_MULT_ZERO_END] + , &requests[CHUNKED_W_TRAILING_HEADERS] + , &requests[CHUNKED_W_BULLSHIT_AFTER_LENGTH] + ); + + printf("request scan 4/4 "); + test_scan( &requests[QUERY_URL_WITH_QUESTION_MARK_GET] + , &requests[PREFIX_NEWLINE_GET ] + , &requests[CONNECT_REQUEST] + ); + + puts("requests okay"); + + return 0; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/http_parser.rb.gemspec b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/http_parser.rb.gemspec new file mode 100644 index 0000000..56ad49c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/http_parser.rb.gemspec @@ -0,0 +1,32 @@ +Gem::Specification.new do |s| + s.name = "http_parser.rb" + s.version = "0.8.0" + s.summary = "Simple callback-based HTTP request/response parser" + s.description = "Ruby bindings to https://github.com/joyent/http-parser and https://github.com/http-parser/http-parser.java" + + s.authors = ["Marc-Andre Cournoyer", "Aman Gupta"] + s.email = ["macournoyer@gmail.com", "aman@tmm1.net"] + s.license = 'MIT' + + s.homepage = "https://github.com/tmm1/http_parser.rb" + s.files = `git ls-files`.split("\n") + Dir['ext/ruby_http_parser/vendor/**/*'] + + s.require_paths = ["lib"] + s.extensions = ["ext/ruby_http_parser/extconf.rb"] + + s.add_development_dependency 'rake-compiler', '~> 1.0' + s.add_development_dependency 'rspec', '~> 3' + s.add_development_dependency 'json', '~> 2.1' + s.add_development_dependency 'benchmark_suite', '~> 1.0' + s.add_development_dependency 'ffi', '~> 1.9' + + if RUBY_PLATFORM =~ /java/ + s.add_development_dependency 'jruby-openssl' + else + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0') + s.add_development_dependency 'yajl-ruby', '~> 1.3' + else + s.add_development_dependency 'yajl-ruby', '= 1.2.1' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/lib/http/parser.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/lib/http/parser.rb new file mode 100644 index 0000000..4881b03 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/lib/http/parser.rb @@ -0,0 +1 @@ +require 'http_parser' diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/lib/http_parser.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/lib/http_parser.rb new file mode 100644 index 0000000..c69f7a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/lib/http_parser.rb @@ -0,0 +1,21 @@ +$:.unshift File.expand_path('../', __FILE__) +require 'ruby_http_parser' + +Http = HTTP + +module HTTP + class Parser + class << self + attr_reader :default_header_value_type + + def default_header_value_type=(val) + if (val != :mixed && val != :strings && val != :arrays) + raise ArgumentError, "Invalid header value type" + end + @default_header_value_type = val + end + end + end +end + +HTTP::Parser.default_header_value_type = :mixed diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/parser_spec.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/parser_spec.rb new file mode 100644 index 0000000..9277c0f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/parser_spec.rb @@ -0,0 +1,428 @@ +if defined?(Encoding) + Encoding.default_external = "UTF-8" +end +require "spec_helper" +require "json" + +describe HTTP::Parser do + before do + @parser = HTTP::Parser.new + + @headers = nil + @body = "" + @started = false + @done = false + + @parser.on_message_begin = proc{ @started = true } + @parser.on_headers_complete = proc { |e| @headers = e } + @parser.on_body = proc { |chunk| @body << chunk } + @parser.on_message_complete = proc{ @done = true } + end + + it "should have initial state" do + expect(@parser.headers).to be_nil + + expect(@parser.http_version).to be_nil + expect(@parser.http_method).to be_nil + expect(@parser.status_code).to be_nil + + expect(@parser.request_url).to be_nil + + expect(@parser.header_value_type).to eq(:mixed) + end + + it "should be able to run in non-main ractors" do + skip unless Kernel.const_defined?(:Ractor) + default_header_value_type = HTTP::Parser.default_header_value_type + r = Ractor.new(default_header_value_type) { |type| + parser = HTTP::Parser.new(default_header_value_type: type) + done = false + parser.on_message_complete = proc { + done = true + } + parser << + "GET /ractor HTTP/1.1\r\n" + + "Content-Length: 5\r\n" + + "\r\n" + + "World" + done + } + expect(r.take).to be true + end + + it "should allow us to set the header value type" do + [:mixed, :arrays, :strings].each do |type| + @parser.header_value_type = type + expect(@parser.header_value_type).to eq(type) + + parser_tmp = HTTP::Parser.new(nil, type) + expect(parser_tmp.header_value_type).to eq(type) + + parser_tmp2 = HTTP::Parser.new(default_header_value_type: type) + expect(parser_tmp2.header_value_type).to eq(type) + end + end + + it "should allow us to set the default header value type" do + [:mixed, :arrays, :strings].each do |type| + HTTP::Parser.default_header_value_type = type + + parser = HTTP::Parser.new + expect(parser.header_value_type).to eq(type) + end + end + + it "should throw an Argument Error if header value type is invalid" do + expect{ @parser.header_value_type = 'bob' }.to raise_error(ArgumentError) + end + + it "should throw an Argument Error if default header value type is invalid" do + expect{ HTTP::Parser.default_header_value_type = 'bob' }.to raise_error(ArgumentError) + end + + it "should implement basic api" do + @parser << + "GET /test?ok=1 HTTP/1.1\r\n" + + "User-Agent: curl/7.18.0\r\n" + + "Host: 0.0.0.0:5000\r\n" + + "Accept: */*\r\n" + + "Content-Length: 5\r\n" + + "\r\n" + + "World" + + expect(@started).to be true + expect(@done).to be true + + expect(@parser.http_major).to eq(1) + expect(@parser.http_minor).to eq(1) + expect(@parser.http_version).to eq([1,1]) + expect(@parser.http_method).to eq('GET') + expect(@parser.status_code).to be_nil + + expect(@parser.request_url).to eq('/test?ok=1') + + expect(@parser.headers).to eq(@headers) + expect(@parser.headers['User-Agent']).to eq('curl/7.18.0') + expect(@parser.headers['Host']).to eq('0.0.0.0:5000') + + expect(@body).to eq("World") + end + + it "should raise errors on invalid data" do + expect{ @parser << "BLAH" }.to raise_error(HTTP::Parser::Error) + end + + it "should abort parser via header complete callback with a body" do + @parser.on_headers_complete = proc { |e| @headers = e; :stop } + + data = + "GET / HTTP/1.0\r\n" + + "Content-Length: 5\r\n" + + "\r\n" + + "World" + + bytes = @parser << data + + expect(bytes).to eq(37) + expect(data[bytes..-1]).to eq('World') + + expect(@headers).to eq({'Content-Length' => '5'}) + expect(@body).to be_empty + expect(@done).to be false + end + + it "should abort parser via header complete callback without a body" do + @parser.on_headers_complete = proc { |e| @headers = e; :stop } + + data = + "GET / HTTP/1.0\r\n" + + "Content-Length: 0\r\n" + + "\r\n" + + bytes = @parser << data + + expect(bytes).to eq(37) + expect(data[bytes..-1]).to eq('') + + expect(@headers).to eq({'Content-Length' => '0'}) + expect(@body).to be_empty + expect(@done).to be false + end + + it "should abort parser via message complete callback with a body" do + @parser.on_message_complete = proc { :stop } + + data = + "CONNECT www.example.com:443 HTTP/1.0\r\n" + + "Connection: keep-alive\r\n" + + "\r\n" + + "World" + + bytes = @parser << data + + expect(bytes).to eq(64) + expect(data[bytes..-1]).to eq('World') + + expect(@headers).to eq({'Connection' => 'keep-alive'}) + expect(@parser.upgrade_data).to eq('World') + expect(@body).to be_empty + expect(@done).to be false + end + + it "should abort parser via message complete callback without a body" do + @parser.on_message_complete = proc { :stop } + + data = + "CONNECT www.example.com:443 HTTP/1.0\r\n" + + "Connection: keep-alive\r\n" + + "\r\n" + + bytes = @parser << data + + expect(bytes).to eq(64) + expect(data[bytes..-1]).to eq('') + + expect(@headers).to eq({'Connection' => 'keep-alive'}) + expect(@parser.upgrade_data).to eq('') + expect(@body).to be_empty + expect(@done).to be false + end + + it "should reset to initial state" do + @parser << "GET / HTTP/1.0\r\n\r\n" + + expect(@parser.http_method).to eq('GET') + expect(@parser.http_version).to eq([1,0]) + + expect(@parser.request_url).to eq('/') + + expect(@parser.reset!).to be true + + expect(@parser.http_version).to be_nil + expect(@parser.http_method).to be_nil + expect(@parser.status_code).to be_nil + + expect(@parser.request_url).to be_nil + end + + it "should optionally reset parser state on no-body responses" do + expect(@parser.reset!).to be true + + @head, @complete = 0, 0 + @parser.on_headers_complete = proc {|h| @head += 1; :reset } + @parser.on_message_complete = proc { @complete += 1 } + @parser.on_body = proc {|b| fail } + + head_response = "HTTP/1.1 200 OK\r\nContent-Length:10\r\n\r\n" + + @parser << head_response + expect(@head).to eq(1) + expect(@complete).to eq(1) + + @parser << head_response + expect(@head).to eq(2) + expect(@complete).to eq(2) + end + + it "should retain callbacks after reset" do + expect(@parser.reset!).to be true + + @parser << "GET / HTTP/1.0\r\n\r\n" + expect(@started).to be true + expect(@headers).to eq({}) + expect(@done).to be true + end + + it "should parse headers incrementally" do + request = + "GET / HTTP/1.0\r\n" + + "Header1: value 1\r\n" + + "Header2: value 2\r\n" + + "\r\n" + + while chunk = request.slice!(0,2) and !chunk.empty? + @parser << chunk + end + + expect(@parser.headers).to eq({ + 'Header1' => 'value 1', + 'Header2' => 'value 2' + }) + end + + it "should handle multiple headers using strings" do + @parser.header_value_type = :strings + + @parser << + "GET / HTTP/1.0\r\n" + + "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" + + "Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" + + "\r\n" + + expect(@parser.headers["Set-Cookie"]).to eq("PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com, NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly") + end + + it "should handle multiple headers using strings" do + @parser.header_value_type = :arrays + + @parser << + "GET / HTTP/1.0\r\n" + + "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" + + "Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" + + "\r\n" + + expect(@parser.headers["Set-Cookie"]).to eq([ + "PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com", + "NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly" + ]) + end + + it "should handle multiple headers using mixed" do + @parser.header_value_type = :mixed + + @parser << + "GET / HTTP/1.0\r\n" + + "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" + + "Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" + + "\r\n" + + expect(@parser.headers["Set-Cookie"]).to eq([ + "PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com", + "NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly" + ]) + end + + it "should handle a single cookie using mixed" do + @parser.header_value_type = :mixed + + @parser << + "GET / HTTP/1.0\r\n" + + "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" + + "\r\n" + + expect(@parser.headers["Set-Cookie"]).to eq("PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com") + end + + it "should support alternative api" do + callbacks = double('callbacks') + allow(callbacks).to receive(:on_message_begin){ @started = true } + allow(callbacks).to receive(:on_headers_complete){ |e| @headers = e } + allow(callbacks).to receive(:on_body){ |chunk| @body << chunk } + allow(callbacks).to receive(:on_message_complete){ @done = true } + + @parser = HTTP::Parser.new(callbacks) + @parser << "GET / HTTP/1.0\r\n\r\n" + + expect(@started).to be true + expect(@headers).to eq({}) + expect(@body).to eq('') + expect(@done).to be true + end + + it "should ignore extra content beyond specified length" do + @parser << + "GET / HTTP/1.0\r\n" + + "Content-Length: 5\r\n" + + "\r\n" + + "hello" + + " \n" + + expect(@body).to eq('hello') + expect(@done).to be true + end + + it 'sets upgrade_data if available' do + @parser << + "GET /demo HTTP/1.1\r\n" + + "Connection: Upgrade\r\n" + + "Upgrade: WebSocket\r\n\r\n" + + "third key data" + + expect(@parser.upgrade?).to be true + expect(@parser.upgrade_data).to eq('third key data') + end + + it 'sets upgrade_data to blank if un-available' do + @parser << + "GET /demo HTTP/1.1\r\n" + + "Connection: Upgrade\r\n" + + "Upgrade: WebSocket\r\n\r\n" + + expect(@parser.upgrade?).to be true + expect(@parser.upgrade_data).to eq('') + end + + it 'should stop parsing headers when instructed' do + request = "GET /websocket HTTP/1.1\r\n" + + "host: localhost\r\n" + + "connection: Upgrade\r\n" + + "upgrade: websocket\r\n" + + "sec-websocket-key: SD6/hpYbKjQ6Sown7pBbWQ==\r\n" + + "sec-websocket-version: 13\r\n" + + "\r\n" + + @parser.on_headers_complete = proc { |e| :stop } + offset = (@parser << request) + expect(@parser.upgrade?).to be true + expect(@parser.upgrade_data).to eq('') + expect(offset).to eq(request.length) + end + + it "should execute on_body on requests with no content-length" do + expect(@parser.reset!).to be true + + @head, @complete, @body = 0, 0, 0 + @parser.on_headers_complete = proc {|h| @head += 1 } + @parser.on_message_complete = proc { @complete += 1 } + @parser.on_body = proc {|b| @body += 1 } + + head_response = "HTTP/1.1 200 OK\r\n\r\nstuff" + + @parser << head_response + @parser << '' + expect(@head).to eq(1) + expect(@complete).to eq(1) + expect(@body).to eq(1) + end + + + %w[ request response ].each do |type| + JSON.parse(File.read(File.expand_path("../support/#{type}s.json", __FILE__))).each do |test| + test['headers'] ||= {} + next if !defined?(JRUBY_VERSION) and HTTP::Parser.strict? != test['strict'] + + it "should parse #{type}: #{test['name']}" do + @parser << test['raw'] + + expect(@parser.http_method).to eq(test['method']) + expect(@parser.keep_alive?).to eq(test['should_keep_alive']) + + if test.has_key?('upgrade') and test['upgrade'] != 0 + expect(@parser.upgrade?).to be true + expect(@parser.upgrade_data).to eq(test['upgrade']) + end + + expect(@parser.send("http_major")).to eq(test["http_major"]) + expect(@parser.send("http_minor")).to eq(test["http_minor"]) + + if test['type'] == 'HTTP_REQUEST' + if defined?(JRUBY_VERSION) + expect(@parser.send("request_url")).to eq(test["request_url"]) + else + # It's created by rb_str_new(), so that encoding is Encoding::ASCII_8BIT a.k.a Encoding::BINARY + expect(@parser.send("request_url")).to eq(test["request_url"].force_encoding(Encoding::ASCII_8BIT)) + end + else + expect(@parser.send("status_code")).to eq(test["status_code"]) + expect(@parser.send("status")).to eq(test["status"].force_encoding(Encoding::ASCII_8BIT)) if !defined?(JRUBY_VERSION) + end + + expect(@headers.size).to eq(test['num_headers']) + expect(@headers).to eq(test['headers']) + + expect(@body).to eq(test['body']) + expect(@body.size).to eq(test['body_size']) if test['body_size'] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/spec_helper.rb b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/spec_helper.rb new file mode 100644 index 0000000..a4295f9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/spec_helper.rb @@ -0,0 +1 @@ +require "http_parser" diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/support/requests.json b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/support/requests.json new file mode 100644 index 0000000..4fefb01 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/support/requests.json @@ -0,0 +1,612 @@ +[ + { + "name": "curl get", + "type": "HTTP_REQUEST", + "raw": "GET /test HTTP/1.1\r\nUser-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\nHost: 0.0.0.0=5000\r\nAccept: */*\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/test", + "request_url": "/test", + "num_headers": 3, + "headers": { + "User-Agent": "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1", + "Host": "0.0.0.0=5000", + "Accept": "*/*" + }, + "body": "", + "strict": true + }, + { + "name": "firefox get", + "type": "HTTP_REQUEST", + "raw": "GET /favicon.ico HTTP/1.1\r\nHost: 0.0.0.0=5000\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/favicon.ico", + "request_url": "/favicon.ico", + "num_headers": 8, + "headers": { + "Host": "0.0.0.0=5000", + "User-Agent": "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", + "Accept-Language": "en-us,en;q=0.5", + "Accept-Encoding": "gzip,deflate", + "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7", + "Keep-Alive": "300", + "Connection": "keep-alive" + }, + "body": "", + "strict": true + }, + { + "name": "dumbfuck", + "type": "HTTP_REQUEST", + "raw": "GET /dumbfuck HTTP/1.1\r\naaaaaaaaaaaaa:++++++++++\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/dumbfuck", + "request_url": "/dumbfuck", + "num_headers": 1, + "headers": { + "aaaaaaaaaaaaa": "++++++++++" + }, + "body": "", + "strict": true + }, + { + "name": "fragment in url", + "type": "HTTP_REQUEST", + "raw": "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "page=1", + "fragment": "posts-17408", + "request_path": "/forums/1/topics/2375", + "request_url": "/forums/1/topics/2375?page=1#posts-17408", + "num_headers": 0, + "body": "", + "strict": true + }, + { + "name": "get no headers no body", + "type": "HTTP_REQUEST", + "raw": "GET /get_no_headers_no_body/world HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/get_no_headers_no_body/world", + "request_url": "/get_no_headers_no_body/world", + "num_headers": 0, + "body": "", + "strict": true + }, + { + "name": "get one header no body", + "type": "HTTP_REQUEST", + "raw": "GET /get_one_header_no_body HTTP/1.1\r\nAccept: */*\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/get_one_header_no_body", + "request_url": "/get_one_header_no_body", + "num_headers": 1, + "headers": { + "Accept": "*/*" + }, + "body": "", + "strict": true + }, + { + "name": "get funky content length body hello", + "type": "HTTP_REQUEST", + "raw": "GET /get_funky_content_length_body_hello HTTP/1.0\r\nconTENT-Length: 5\r\n\r\nHELLO", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 0, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/get_funky_content_length_body_hello", + "request_url": "/get_funky_content_length_body_hello", + "num_headers": 1, + "headers": { + "conTENT-Length": "5" + }, + "body": "HELLO", + "strict": true + }, + { + "name": "post identity body world", + "type": "HTTP_REQUEST", + "raw": "POST /post_identity_body_world?q=search#hey HTTP/1.1\r\nAccept: */*\r\nTransfer-Encoding: identity\r\nContent-Length: 5\r\n\r\nWorld", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "POST", + "query_string": "q=search", + "fragment": "hey", + "request_path": "/post_identity_body_world", + "request_url": "/post_identity_body_world?q=search#hey", + "num_headers": 3, + "headers": { + "Accept": "*/*", + "Transfer-Encoding": "identity", + "Content-Length": "5" + }, + "body": "World", + "strict": true + }, + { + "name": "post - chunked body: all your base are belong to us", + "type": "HTTP_REQUEST", + "raw": "POST /post_chunked_all_your_base HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n1e\r\nall your base are belong to us\r\n0\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "POST", + "query_string": "", + "fragment": "", + "request_path": "/post_chunked_all_your_base", + "request_url": "/post_chunked_all_your_base", + "num_headers": 1, + "headers": { + "Transfer-Encoding": "chunked" + }, + "body": "all your base are belong to us", + "strict": true + }, + { + "name": "two chunks ; triple zero ending", + "type": "HTTP_REQUEST", + "raw": "POST /two_chunks_mult_zero_end HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n6\r\n world\r\n000\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "POST", + "query_string": "", + "fragment": "", + "request_path": "/two_chunks_mult_zero_end", + "request_url": "/two_chunks_mult_zero_end", + "num_headers": 1, + "headers": { + "Transfer-Encoding": "chunked" + }, + "body": "hello world", + "strict": true + }, + { + "name": "chunked with trailing headers. blech.", + "type": "HTTP_REQUEST", + "raw": "POST /chunked_w_trailing_headers HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n6\r\n world\r\n0\r\nVary: *\r\nContent-Type: text/plain\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "POST", + "query_string": "", + "fragment": "", + "request_path": "/chunked_w_trailing_headers", + "request_url": "/chunked_w_trailing_headers", + "num_headers": 3, + "headers": { + "Transfer-Encoding": "chunked", + "Vary": "*", + "Content-Type": "text/plain" + }, + "body": "hello world", + "strict": true + }, + { + "name": "with bullshit after the length", + "type": "HTTP_REQUEST", + "raw": "POST /chunked_w_bullshit_after_length HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n5; ihatew3;whatthefuck=aretheseparametersfor\r\nhello\r\n6; blahblah; blah\r\n world\r\n0\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "POST", + "query_string": "", + "fragment": "", + "request_path": "/chunked_w_bullshit_after_length", + "request_url": "/chunked_w_bullshit_after_length", + "num_headers": 1, + "headers": { + "Transfer-Encoding": "chunked" + }, + "body": "hello world", + "strict": true + }, + { + "name": "with quotes", + "type": "HTTP_REQUEST", + "raw": "GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "foo=\"bar\"", + "fragment": "", + "request_path": "/with_\"stupid\"_quotes", + "request_url": "/with_\"stupid\"_quotes?foo=\"bar\"", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "apachebench get", + "type": "HTTP_REQUEST", + "raw": "GET /test HTTP/1.0\r\nHost: 0.0.0.0:5000\r\nUser-Agent: ApacheBench/2.3\r\nAccept: */*\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 0, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/test", + "request_url": "/test", + "num_headers": 3, + "headers": { + "Host": "0.0.0.0:5000", + "User-Agent": "ApacheBench/2.3", + "Accept": "*/*" + }, + "body": "", + "strict": true + }, + { + "name": "query url with question mark", + "type": "HTTP_REQUEST", + "raw": "GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "foo=bar?baz", + "fragment": "", + "request_path": "/test.cgi", + "request_url": "/test.cgi?foo=bar?baz", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "newline prefix get", + "type": "HTTP_REQUEST", + "raw": "\r\nGET /test HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/test", + "request_url": "/test", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "upgrade request", + "type": "HTTP_REQUEST", + "raw": "GET /demo HTTP/1.1\r\nHost: example.com\r\nConnection: Upgrade\r\nSec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\nSec-WebSocket-Protocol: sample\r\nUpgrade: WebSocket\r\nSec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\nOrigin: http://example.com\r\n\r\nHot diggity dogg", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/demo", + "request_url": "/demo", + "num_headers": 7, + "upgrade": "Hot diggity dogg", + "headers": { + "Host": "example.com", + "Connection": "Upgrade", + "Sec-WebSocket-Key2": "12998 5 Y3 1 .P00", + "Sec-WebSocket-Protocol": "sample", + "Upgrade": "WebSocket", + "Sec-WebSocket-Key1": "4 @1 46546xW%0l 1 5", + "Origin": "http://example.com" + }, + "body": "", + "strict": true + }, + { + "name": "connect request", + "type": "HTTP_REQUEST", + "raw": "CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\nUser-agent: Mozilla/1.1N\r\nProxy-authorization: basic aGVsbG86d29ybGQ=\r\n\r\nsome data\r\nand yet even more data", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 0, + "method": "CONNECT", + "query_string": "", + "fragment": "", + "request_path": "", + "request_url": "0-home0.netscape.com:443", + "num_headers": 2, + "upgrade": "some data\r\nand yet even more data", + "headers": { + "User-agent": "Mozilla/1.1N", + "Proxy-authorization": "basic aGVsbG86d29ybGQ=" + }, + "body": "", + "strict": true + }, + { + "name": "report request", + "type": "HTTP_REQUEST", + "raw": "REPORT /test HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "REPORT", + "query_string": "", + "fragment": "", + "request_path": "/test", + "request_url": "/test", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "request with no http version", + "type": "HTTP_REQUEST", + "raw": "GET /\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 0, + "http_minor": 9, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/", + "request_url": "/", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "m-search request", + "type": "HTTP_REQUEST", + "raw": "M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: \"ssdp:discover\"\r\nST: \"ssdp:all\"\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "M-SEARCH", + "query_string": "", + "fragment": "", + "request_path": "*", + "request_url": "*", + "num_headers": 3, + "headers": { + "HOST": "239.255.255.250:1900", + "MAN": "\"ssdp:discover\"", + "ST": "\"ssdp:all\"" + }, + "body": "", + "strict": true + }, + { + "name": "line folding in header value", + "type": "HTTP_REQUEST", + "raw": "GET / HTTP/1.1\r\nLine1: abc\r\n\tdef\r\n ghi\r\n\t\tjkl\r\n mno \r\n\t \tqrs\r\nLine2: \t line2\t\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "/", + "request_url": "/", + "num_headers": 2, + "headers": { + "Line1": "abc\tdef ghi\t\tjkl mno \t \tqrs", + "Line2": "line2\t" + }, + "body": "", + "strict": true + }, + { + "name": "host terminated by a query string", + "type": "HTTP_REQUEST", + "raw": "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "hail=all", + "fragment": "", + "request_path": "", + "request_url": "http://hypnotoad.org?hail=all", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "host:port terminated by a query string", + "type": "HTTP_REQUEST", + "raw": "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "hail=all", + "fragment": "", + "request_path": "", + "request_url": "http://hypnotoad.org:1234?hail=all", + "port": 1234, + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "host:port terminated by a space", + "type": "HTTP_REQUEST", + "raw": "GET http://hypnotoad.org:1234 HTTP/1.1\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "", + "fragment": "", + "request_path": "", + "request_url": "http://hypnotoad.org:1234", + "port": 1234, + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "PATCH request", + "type": "HTTP_REQUEST", + "raw": "PATCH /file.txt HTTP/1.1\r\nHost: www.example.com\r\nContent-Type: application/example\r\nIf-Match: \"e0023aa4e\"\r\nContent-Length: 10\r\n\r\ncccccccccc", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "PATCH", + "query_string": "", + "fragment": "", + "request_path": "/file.txt", + "request_url": "/file.txt", + "num_headers": 4, + "headers": { + "Host": "www.example.com", + "Content-Type": "application/example", + "If-Match": "\"e0023aa4e\"", + "Content-Length": "10" + }, + "body": "cccccccccc", + "strict": true + }, + { + "name": "connect caps request", + "type": "HTTP_REQUEST", + "raw": "CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\nUser-agent: Mozilla/1.1N\r\nProxy-authorization: basic aGVsbG86d29ybGQ=\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 0, + "method": "CONNECT", + "query_string": "", + "fragment": "", + "request_path": "", + "request_url": "HOME0.NETSCAPE.COM:443", + "num_headers": 2, + "upgrade": "", + "headers": { + "User-agent": "Mozilla/1.1N", + "Proxy-authorization": "basic aGVsbG86d29ybGQ=" + }, + "body": "", + "strict": true + }, + { + "name": "utf-8 path request", + "type": "HTTP_REQUEST", + "strict": false, + "raw": "GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\nHost: github.com\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "method": "GET", + "query_string": "q=1", + "fragment": "narf", + "request_path": "/δ¶/δt/pope", + "request_url": "/δ¶/δt/pope?q=1#narf", + "num_headers": 1, + "headers": { + "Host": "github.com" + }, + "body": "" + }, + { + "name": "hostname underscore", + "type": "HTTP_REQUEST", + "strict": false, + "raw": "CONNECT home_0.netscape.com:443 HTTP/1.0\r\nUser-agent: Mozilla/1.1N\r\nProxy-authorization: basic aGVsbG86d29ybGQ=\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 0, + "method": "CONNECT", + "query_string": "", + "fragment": "", + "request_path": "", + "request_url": "home_0.netscape.com:443", + "num_headers": 2, + "upgrade": "", + "headers": { + "User-agent": "Mozilla/1.1N", + "Proxy-authorization": "basic aGVsbG86d29ybGQ=" + }, + "body": "" + } +] \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/support/responses.json b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/support/responses.json new file mode 100644 index 0000000..a033f3b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/spec/support/responses.json @@ -0,0 +1,395 @@ +[ + { + "name": "google 301", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 301 Moved Permanently\r\nLocation: http://www.google.com/\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Sun, 26 Apr 2009 11:11:49 GMT\r\nExpires: Tue, 26 May 2009 11:11:49 GMT\r\nX-$PrototypeBI-Version: 1.6.0.3\r\nCache-Control: public, max-age=2592000\r\nServer: gws\r\nContent-Length: 219 \r\n\r\n\n301 Moved\n

301 Moved

\nThe document has moved\nhere.\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 301, + "status": "Moved Permanently", + "num_headers": 8, + "headers": { + "Location": "http://www.google.com/", + "Content-Type": "text/html; charset=UTF-8", + "Date": "Sun, 26 Apr 2009 11:11:49 GMT", + "Expires": "Tue, 26 May 2009 11:11:49 GMT", + "X-$PrototypeBI-Version": "1.6.0.3", + "Cache-Control": "public, max-age=2592000", + "Server": "gws", + "Content-Length": "219 " + }, + "body": "\n301 Moved\n

301 Moved

\nThe document has moved\nhere.\r\n\r\n", + "strict": true + }, + { + "name": "no content-length response", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\nDate: Tue, 04 Aug 2009 07:59:32 GMT\r\nServer: Apache\r\nX-Powered-By: Servlet/2.5 JSP/2.1\r\nContent-Type: text/xml; charset=utf-8\r\nConnection: close\r\n\r\n\n\n \n \n SOAP-ENV:Client\n Client Error\n \n \n", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 5, + "headers": { + "Date": "Tue, 04 Aug 2009 07:59:32 GMT", + "Server": "Apache", + "X-Powered-By": "Servlet/2.5 JSP/2.1", + "Content-Type": "text/xml; charset=utf-8", + "Connection": "close" + }, + "body": "\n\n \n \n SOAP-ENV:Client\n Client Error\n \n \n", + "strict": true + }, + { + "name": "404 no headers no body", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 404 Not Found\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 1, + "http_minor": 1, + "status_code": 404, + "status": "Not Found", + "num_headers": 0, + "headers": { + + }, + "body_size": 0, + "body": "", + "strict": true + }, + { + "name": "301 no response phrase", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 301\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 1, + "http_minor": 1, + "status_code": 301, + "status": "", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "200 trailing space on chunked body", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n25 \r\nThis is the data in the first chunk\r\n\r\n1C\r\nand this is the second one\r\n\r\n0 \r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 2, + "headers": { + "Content-Type": "text/plain", + "Transfer-Encoding": "chunked" + }, + "body_size": 65, + "body": "This is the data in the first chunk\r\nand this is the second one\r\n", + "strict": true + }, + { + "name": "no carriage ret", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\nContent-Type: text/html; charset=utf-8\nConnection: close\n\nthese headers are from http://news.ycombinator.com/", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 2, + "headers": { + "Content-Type": "text/html; charset=utf-8", + "Connection": "close" + }, + "body": "these headers are from http://news.ycombinator.com/", + "strict": true + }, + { + "name": "proxy connection", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 11\r\nProxy-Connection: close\r\nDate: Thu, 31 Dec 2009 20:55:48 +0000\r\n\r\nhello world", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 4, + "headers": { + "Content-Type": "text/html; charset=UTF-8", + "Content-Length": "11", + "Proxy-Connection": "close", + "Date": "Thu, 31 Dec 2009 20:55:48 +0000" + }, + "body": "hello world", + "strict": true + }, + { + "name": "underscore header key", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\nServer: DCLK-AdSvr\r\nContent-Type: text/xml\r\nContent-Length: 0\r\nDCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 4, + "headers": { + "Server": "DCLK-AdSvr", + "Content-Type": "text/xml", + "Content-Length": "0", + "DCLK_imp": "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o" + }, + "body": "", + "strict": true + }, + { + "name": "bonjourmadame.fr", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.0 301 Moved Permanently\r\nDate: Thu, 03 Jun 2010 09:56:32 GMT\r\nServer: Apache/2.2.3 (Red Hat)\r\nCache-Control: public\r\nPragma: \r\nLocation: http://www.bonjourmadame.fr/\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: keep-alive\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 0, + "status_code": 301, + "status": "Moved Permanently", + "num_headers": 9, + "headers": { + "Date": "Thu, 03 Jun 2010 09:56:32 GMT", + "Server": "Apache/2.2.3 (Red Hat)", + "Cache-Control": "public", + "Pragma": "", + "Location": "http://www.bonjourmadame.fr/", + "Vary": "Accept-Encoding", + "Content-Length": "0", + "Content-Type": "text/html; charset=UTF-8", + "Connection": "keep-alive" + }, + "body": "", + "strict": true + }, + { + "name": "field underscore", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\nDate: Tue, 28 Sep 2010 01:14:13 GMT\r\nServer: Apache\r\nCache-Control: no-cache, must-revalidate\r\nExpires: Mon, 26 Jul 1997 05:00:00 GMT\r\n.et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\nVary: Accept-Encoding\r\n_eep-Alive: timeout=45\r\n_onnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n0\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 11, + "headers": { + "Date": "Tue, 28 Sep 2010 01:14:13 GMT", + "Server": "Apache", + "Cache-Control": "no-cache, must-revalidate", + "Expires": "Mon, 26 Jul 1997 05:00:00 GMT", + ".et-Cookie": "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com", + "Vary": "Accept-Encoding", + "_eep-Alive": "timeout=45", + "_onnection": "Keep-Alive", + "Transfer-Encoding": "chunked", + "Content-Type": "text/html", + "Connection": "close" + }, + "body": "", + "strict": true + }, + { + "name": "non-ASCII in status line", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 500 Oriëntatieprobleem\r\nDate: Fri, 5 Nov 2010 23:07:12 GMT+2\r\nContent-Length: 0\r\nConnection: close\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 500, + "status": "Oriëntatieprobleem", + "num_headers": 3, + "headers": { + "Date": "Fri, 5 Nov 2010 23:07:12 GMT+2", + "Content-Length": "0", + "Connection": "close" + }, + "body": "", + "strict": true + }, + { + "name": "http version 0.9", + "type": "HTTP_RESPONSE", + "raw": "HTTP/0.9 200 OK\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 0, + "http_minor": 9, + "status_code": 200, + "status": "OK", + "num_headers": 0, + "headers": { + + }, + "body": "", + "strict": true + }, + { + "name": "neither content-length nor transfer-encoding response", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello world", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 1, + "headers": { + "Content-Type": "text/plain" + }, + "body": "hello world", + "strict": true + }, + { + "name": "HTTP/1.0 with keep-alive and EOF-terminated 200 status", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.0 200 OK\r\nConnection: keep-alive\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 1, + "http_minor": 0, + "status_code": 200, + "status": "OK", + "num_headers": 1, + "headers": { + "Connection": "keep-alive" + }, + "body_size": 0, + "body": "", + "strict": true + }, + { + "name": "HTTP/1.0 with keep-alive and a 204 status", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.0 204 No content\r\nConnection: keep-alive\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 0, + "status_code": 204, + "status": "No content", + "num_headers": 1, + "headers": { + "Connection": "keep-alive" + }, + "body_size": 0, + "body": "", + "strict": true + }, + { + "name": "HTTP/1.1 with an EOF-terminated 200 status", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": true, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 0, + "headers": { + + }, + "body_size": 0, + "body": "", + "strict": true + }, + { + "name": "HTTP/1.1 with a 204 status", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 204 No content\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 204, + "status": "No content", + "num_headers": 0, + "headers": { + + }, + "body_size": 0, + "body": "", + "strict": true + }, + { + "name": "HTTP/1.1 with a 204 status and keep-alive disabled", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 204 No content\r\nConnection: close\r\n\r\n", + "should_keep_alive": false, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 204, + "status": "No content", + "num_headers": 1, + "headers": { + "Connection": "close" + }, + "body_size": 0, + "body": "", + "strict": true + }, + { + "name": "HTTP/1.1 with chunked endocing and a 200 response", + "type": "HTTP_RESPONSE", + "raw": "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 1, + "headers": { + "Transfer-Encoding": "chunked" + }, + "body_size": 0, + "body": "", + "strict": true + }, + { + "name": "field space", + "type": "HTTP_RESPONSE", + "strict": false, + "raw": "HTTP/1.1 200 OK\r\nServer: Microsoft-IIS/6.0\r\nX-Powered-By: ASP.NET\r\nen-US Content-Type: text/xml\r\nContent-Type: text/xml\r\nContent-Length: 16\r\nDate: Fri, 23 Jul 2010 18:45:38 GMT\r\nConnection: keep-alive\r\n\r\nhello", + "should_keep_alive": true, + "message_complete_on_eof": false, + "http_major": 1, + "http_minor": 1, + "status_code": 200, + "status": "OK", + "num_headers": 7, + "headers": { + "Server": "Microsoft-IIS/6.0", + "X-Powered-By": "ASP.NET", + "en-US Content-Type": "text/xml", + "Content-Type": "text/xml", + "Content-Length": "16", + "Date": "Fri, 23 Jul 2010 18:45:38 GMT", + "Connection": "keep-alive" + }, + "body": "hello" + } +] \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/compile.rake b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/compile.rake new file mode 100644 index 0000000..22d6f6d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/compile.rake @@ -0,0 +1,42 @@ +require 'rubygems/package_task' +require 'rake/extensiontask' +require 'rake/javaextensiontask' + +def gemspec + @clean_gemspec ||= eval(File.read(File.expand_path('../../http_parser.rb.gemspec', __FILE__))) +end + +Gem::PackageTask.new(gemspec) do |pkg| +end + +if RUBY_PLATFORM =~ /java/ + Rake::JavaExtensionTask.new("ruby_http_parser", gemspec) do |ext| + ext.classpath = File.expand_path('../../ext/ruby_http_parser/vendor/http-parser-java/ext/primitives.jar', __FILE__) + end +else + Rake::ExtensionTask.new("ruby_http_parser", gemspec) do |ext| + unless RUBY_PLATFORM =~ /mswin|mingw/ + ext.cross_compile = true + ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60'] + + # inject 1.8/1.9 pure-ruby entry point + ext.cross_compiling do |spec| + spec.files += ['lib/ruby_http_parser.rb'] + end + end + end +end + +file 'lib/ruby_http_parser.rb' do |t| + File.open(t.name, 'wb') do |f| + f.write <<-eoruby +RUBY_VERSION =~ /(\\d+.\\d+)/ +require "\#{$1}/ruby_http_parser" + eoruby + end + at_exit{ FileUtils.rm t.name if File.exists?(t.name) } +end + +if Rake::Task.task_defined?(:cross) + task :cross => 'lib/ruby_http_parser.rb' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/fixtures.rake b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/fixtures.rake new file mode 100644 index 0000000..b5d36ef --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/fixtures.rake @@ -0,0 +1,71 @@ +desc "Generate test fixtures" +task :fixtures => :submodules do + require 'yajl' + data = File.read File.expand_path('../../ext/ruby_http_parser/vendor/http-parser/test.c', __FILE__) + + %w[ requests responses ].each do |type| + # find test definitions in between requests/responses[]= and .name=NULL + tmp = data[/#{type}\[\]\s*=(.+?),\s*\{\s*\.name=\s*NULL/m, 1] + + # replace first { with a [ (parsing an array of test cases) + tmp.sub!('{','[') + + # replace booleans + tmp.gsub!('TRUE', 'true') + tmp.gsub!('FALSE', 'false') + + # mark strict mode tests + tmp.gsub!(%r|#if\s+!HTTP_PARSER_STRICT(.+?)#endif\s*/\*\s*!HTTP_PARSER_STRICT.+\n|m){ + $1.gsub(/^(.+,\.type= .+)$/, "\\1\n, .strict= false") + } + + # remove macros and comments + tmp.gsub!(/^#(if|elif|endif|define).+$/,'') + tmp.gsub!(/\/\*(.+?)\*\/$/,'') + + # HTTP_* enums become strings + tmp.gsub!(/(= )(HTTP_\w+)/){ + "#{$1}#{$2.sub('MSEARCH','M-SEARCH').dump}" + } + + # join multiline strings for body and raw data + tmp.gsub!(/((body|raw)\s*=)(.+?)(\n\s+[\},])/m){ + before, after = $1, $4 + raw = $3.split("\n").map{ |l| l.strip[1..-2] }.join('') + "#{before} \"#{raw}\" #{after}" + } + + # make headers an array of array tuples + tmp.gsub!(/(\.headers\s*=)(.+?)(\s*,\.)/m){ + before, after = $1, $3 + raw = $2.gsub('{', '[').gsub('}', ']') + "#{before} #{raw} #{after}" + } + + # .name= becomes "name": + tmp.gsub!(/^(.{2,5})\.(\w+)\s*=/){ + "#{$1}#{$2.dump}: " + } + + # evaluate addition expressions + tmp.gsub!(/(body_size\":\s*)(\d+)\+(\d+)/){ + "#{$1}#{$2.to_i+$3.to_i}" + } + + # end result array + tmp << ']' + + # normalize data + results = Yajl.load(tmp, :symbolize_keys => true) + results.map{ |res| + res[:headers] and res[:headers] = Hash[*res[:headers].flatten] + res[:method] and res[:method].gsub!(/^HTTP_/, '') + res[:strict] = true unless res.has_key?(:strict) + } + + # write to a file + File.open("spec/support/#{type}.json", 'w'){ |f| + f.write Yajl.dump(results, :pretty => true) + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/spec.rake b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/spec.rake new file mode 100644 index 0000000..3deb568 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/spec.rake @@ -0,0 +1,5 @@ +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new do |t| + t.rspec_opts = %w(--format documentation --color) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/submodules.rake b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/submodules.rake new file mode 100644 index 0000000..d978e9f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/http_parser.rb-0.8.0/tasks/submodules.rake @@ -0,0 +1,7 @@ +desc "Fetch upstream submodules" +task :submodules do + if Dir['ext/ruby_http_parser/vendor/http-parser/*'].empty? + sh 'git submodule init' + sh 'git submodule update' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/MIT-LICENSE b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/MIT-LICENSE new file mode 100644 index 0000000..ed8e9ee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2008 The Ruby I18n team + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/README.md b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/README.md new file mode 100644 index 0000000..7b7a6bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/README.md @@ -0,0 +1,127 @@ +# Ruby I18n + +[![Gem Version](https://badge.fury.io/rb/i18n.svg)](https://badge.fury.io/rb/i18n) +[![Build Status](https://github.com/ruby-i18n/i18n/workflows/Ruby/badge.svg)](https://github.com/ruby-i18n/i18n/actions?query=workflow%3ARuby) + +Ruby internationalization and localization (i18n) solution. + +Currently maintained by @radar. + +## Usage + +### Rails + +You will most commonly use this library within a Rails app. + +We support Rails versions from 6.0 and up. + +[See the Rails Guide](https://guides.rubyonrails.org/i18n.html) for an example of its usage. + +### Ruby (without Rails) + +We support Ruby versions from 3.0 and up. + +If you want to use this library without Rails, you can simply add `i18n` to your `Gemfile`: + +```ruby +gem 'i18n' +``` + +Then configure I18n with some translations, and a default locale: + +```ruby +I18n.load_path += Dir[File.expand_path("config/locales") + "/*.yml"] +I18n.default_locale = :en # (note that `en` is already the default!) +``` + +A simple translation file in your project might live at `config/locales/en.yml` and look like: + +```yml +en: + test: "This is a test" +``` + +You can then access this translation by doing: + +```ruby +I18n.t(:test) +``` + +You can switch locales in your project by setting `I18n.locale` to a different value: + +```ruby +I18n.locale = :de +I18n.t(:test) # => "Dies ist ein Test" +``` + +## Features + +* Translation and localization +* Interpolation of values to translations +* Pluralization (CLDR compatible) +* Customizable transliteration to ASCII +* Flexible defaults +* Bulk lookup +* Lambdas as translation data +* Custom key/scope separator +* Custom exception handlers +* Extensible architecture with a swappable backend + +## Pluggable Features + +* Cache +* Pluralization: lambda pluralizers stored as translation data +* Locale fallbacks, RFC4647 compliant (optionally: RFC4646 locale validation) +* [Gettext support](https://github.com/ruby-i18n/i18n/wiki/Gettext) +* Translation metadata + +## Alternative Backend + +* Chain +* ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs) +* KeyValue (uses active_support/json and cannot store procs) + +For more information and lots of resources see [the 'Resources' page on the wiki](https://github.com/ruby-i18n/i18n/wiki/Resources). + +## Tests + +You can run tests both with + +* `rake test` or just `rake` +* run any test file directly, e.g. `ruby -Ilib:test test/api/simple_test.rb` + +You can run all tests against all Gemfiles with + +* `ruby test/run_all.rb` + +The structure of the test suite is a bit unusual as it uses modules to reuse +particular tests in different test cases. + +The reason for this is that we need to enforce the I18n API across various +combinations of extensions. E.g. the Simple backend alone needs to support +the same API as any combination of feature and/or optimization modules included +to the Simple backend. We test this by reusing the same API definition (implemented +as test methods) in test cases with different setups. + +You can find the test cases that enforce the API in test/api. And you can find +the API definition test methods in test/api/tests. + +All other test cases (e.g. as defined in test/backend, test/core_ext) etc. +follow the usual test setup and should be easy to grok. + +## More Documentation + +Additional documentation can be found here: https://github.com/ruby-i18n/i18n/wiki + +## Contributors + +* @radar +* @carlosantoniodasilva +* @josevalim +* @knapo +* @tigrish +* [and many more](https://github.com/ruby-i18n/i18n/graphs/contributors) + +## License + +MIT License. See the included MIT-LICENSE file. diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n.rb new file mode 100644 index 0000000..2980f02 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n.rb @@ -0,0 +1,475 @@ +# frozen_string_literal: true + +require 'concurrent/map' +require 'concurrent/hash' + +require 'i18n/version' +require 'i18n/utils' +require 'i18n/exceptions' +require 'i18n/interpolate/ruby' + +module I18n + autoload :Backend, 'i18n/backend' + autoload :Config, 'i18n/config' + autoload :Gettext, 'i18n/gettext' + autoload :Locale, 'i18n/locale' + autoload :Tests, 'i18n/tests' + autoload :Middleware, 'i18n/middleware' + + RESERVED_KEYS = %i[ + cascade + deep_interpolation + default + exception_handler + fallback + fallback_in_progress + fallback_original_locale + format + object + raise + resolve + scope + separator + throw + ] + EMPTY_HASH = {}.freeze + + def self.new_double_nested_cache # :nodoc: + Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new } + end + + # Marks a key as reserved. Reserved keys are used internally, + # and can't also be used for interpolation. If you are using any + # extra keys as I18n options, you should call I18n.reserve_key + # before any I18n.translate (etc) calls are made. + def self.reserve_key(key) + RESERVED_KEYS << key.to_sym + @reserved_keys_pattern = nil + end + + def self.reserved_keys_pattern # :nodoc: + @reserved_keys_pattern ||= /(?E.g., ActionView ships with the translation: + # :date => {:formats => {:short => "%b %d"}}. + # + # Translations can be looked up at any level of this hash using the key argument + # and the scope option. E.g., in this example I18n.t :date + # returns the whole translations hash {:formats => {:short => "%b %d"}}. + # + # Key can be either a single key or a dot-separated key (both Strings and Symbols + # work). E.g., the short format can be looked up using both: + # I18n.t 'date.formats.short' + # I18n.t :'date.formats.short' + # + # Scope can be either a single key, a dot-separated key or an array of keys + # or dot-separated keys. Keys and scopes can be combined freely. So these + # examples will all look up the same short date format: + # I18n.t 'date.formats.short' + # I18n.t 'formats.short', :scope => 'date' + # I18n.t 'short', :scope => 'date.formats' + # I18n.t 'short', :scope => %w(date formats) + # + # *INTERPOLATION* + # + # Translations can contain interpolation variables which will be replaced by + # values passed to #translate as part of the options hash, with the keys matching + # the interpolation variable names. + # + # E.g., with a translation :foo => "foo %{bar}" the option + # value for the key +bar+ will be interpolated into the translation: + # I18n.t :foo, :bar => 'baz' # => 'foo baz' + # + # *PLURALIZATION* + # + # Translation data can contain pluralized translations. Pluralized translations + # are arrays of singular/plural versions of translations like ['Foo', 'Foos']. + # + # Note that I18n::Backend::Simple only supports an algorithm for English + # pluralization rules. Other algorithms can be supported by custom backends. + # + # This returns the singular version of a pluralized translation: + # I18n.t :foo, :count => 1 # => 'Foo' + # + # These both return the plural version of a pluralized translation: + # I18n.t :foo, :count => 0 # => 'Foos' + # I18n.t :foo, :count => 2 # => 'Foos' + # + # The :count option can be used both for pluralization and interpolation. + # E.g., with the translation + # :foo => ['%{count} foo', '%{count} foos'], count will + # be interpolated to the pluralized translation: + # I18n.t :foo, :count => 1 # => '1 foo' + # + # *DEFAULTS* + # + # This returns the translation for :foo or default if no translation was found: + # I18n.t :foo, :default => 'default' + # + # This returns the translation for :foo or the translation for :bar if no + # translation for :foo was found: + # I18n.t :foo, :default => :bar + # + # Returns the translation for :foo or the translation for :bar + # or default if no translations for :foo and :bar were found. + # I18n.t :foo, :default => [:bar, 'default'] + # + # *BULK LOOKUP* + # + # This returns an array with the translations for :foo and :bar. + # I18n.t [:foo, :bar] + # + # Can be used with dot-separated nested keys: + # I18n.t [:'baz.foo', :'baz.bar'] + # + # Which is the same as using a scope option: + # I18n.t [:foo, :bar], :scope => :baz + # + # *LAMBDAS* + # + # Both translations and defaults can be given as Ruby lambdas. Lambdas will be + # called and passed the key and options. + # + # E.g. assuming the key :salutation resolves to: + # lambda { |key, options| options[:gender] == 'm' ? "Mr. #{options[:name]}" : "Mrs. #{options[:name]}" } + # + # Then I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith". + # + # Note that the string returned by lambda will go through string interpolation too, + # so the following lambda would give the same result: + # lambda { |key, options| options[:gender] == 'm' ? "Mr. %{name}" : "Mrs. %{name}" } + # + # It is recommended to use/implement lambdas in an "idempotent" way. E.g. when + # a cache layer is put in front of I18n.translate it will generate a cache key + # from the argument values passed to #translate. Therefore your lambdas should + # always return the same translations/values per unique combination of argument + # values. + # + # *Ruby 2.7+ keyword arguments warning* + # + # This method uses keyword arguments. + # There is a breaking change in ruby that produces warning with ruby 2.7 and won't work as expected with ruby 3.0 + # The "hash" parameter must be passed as keyword argument. + # + # Good: + # I18n.t(:salutation, :gender => 'w', :name => 'Smith') + # I18n.t(:salutation, **{ :gender => 'w', :name => 'Smith' }) + # I18n.t(:salutation, **any_hash) + # + # Bad: + # I18n.t(:salutation, { :gender => 'w', :name => 'Smith' }) + # I18n.t(:salutation, any_hash) + # + def translate(key = nil, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise + locale ||= config.locale + raise Disabled.new('t') if locale == false + enforce_available_locales!(locale) + + backend = config.backend + + if key.is_a?(Array) + key.map do |k| + translate_key(k, throw, raise, locale, backend, options) + end + else + translate_key(key, throw, raise, locale, backend, options) + end + end + alias :t :translate + + # Wrapper for translate that adds :raise => true. With + # this option, if no translation is found, it will raise I18n::MissingTranslationData + def translate!(key, **options) + translate(key, **options, raise: true) + end + alias :t! :translate! + + # Returns an array of interpolation keys for the given translation key + # + # *Examples* + # + # Suppose we have the following: + # I18n.t 'example.zero' == 'Zero interpolations' + # I18n.t 'example.one' == 'One interpolation %{foo}' + # I18n.t 'example.two' == 'Two interpolations %{foo} %{bar}' + # I18n.t 'example.three' == ['One %{foo}', 'Two %{bar}', 'Three %{baz}'] + # I18n.t 'example.one', locale: :other == 'One interpolation %{baz}' + # + # Then we can expect the following results: + # I18n.interpolation_keys('example.zero') #=> [] + # I18n.interpolation_keys('example.one') #=> ['foo'] + # I18n.interpolation_keys('example.two') #=> ['foo', 'bar'] + # I18n.interpolation_keys('example.three') #=> ['foo', 'bar', 'baz'] + # I18n.interpolation_keys('one', scope: 'example', locale: :other) #=> ['baz'] + # I18n.interpolation_keys('does-not-exist') #=> [] + # I18n.interpolation_keys('example') #=> [] + def interpolation_keys(key, **options) + raise I18n::ArgumentError if !key.is_a?(String) || key.empty? + + return [] unless exists?(key, **options.slice(:locale, :scope)) + + translation = translate(key, **options.slice(:locale, :scope)) + interpolation_keys_from_translation(translation) + .flatten.compact + end + + # Returns true if a translation exists for a given key, otherwise returns false. + def exists?(key, _locale = nil, locale: _locale, **options) + locale ||= config.locale + raise Disabled.new('exists?') if locale == false + raise I18n::ArgumentError if key.is_a?(String) && key.empty? + config.backend.exists?(locale, key, options) + end + + # Transliterates UTF-8 characters to ASCII. By default this method will + # transliterate only Latin strings to an ASCII approximation: + # + # I18n.transliterate("Ærøskøbing") + # # => "AEroskobing" + # + # I18n.transliterate("日本語") + # # => "???" + # + # It's also possible to add support for per-locale transliterations. I18n + # expects transliteration rules to be stored at + # i18n.transliterate.rule. + # + # Transliteration rules can either be a Hash or a Proc. Procs must accept a + # single string argument. Hash rules inherit the default transliteration + # rules, while Procs do not. + # + # *Examples* + # + # Setting a Hash in .yml: + # + # i18n: + # transliterate: + # rule: + # ü: "ue" + # ö: "oe" + # + # Setting a Hash using Ruby: + # + # store_translations(:de, i18n: { + # transliterate: { + # rule: { + # 'ü' => 'ue', + # 'ö' => 'oe' + # } + # } + # }) + # + # Setting a Proc: + # + # translit = lambda {|string| MyTransliterator.transliterate(string) } + # store_translations(:xx, :i18n => {:transliterate => {:rule => translit}) + # + # Transliterating strings: + # + # I18n.locale = :en + # I18n.transliterate("Jürgen") # => "Jurgen" + # I18n.locale = :de + # I18n.transliterate("Jürgen") # => "Juergen" + # I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen" + # I18n.transliterate("Jürgen", :locale => :de) # => "Juergen" + def transliterate(key, throw: false, raise: false, locale: nil, replacement: nil, **options) + locale ||= config.locale + raise Disabled.new('transliterate') if locale == false + enforce_available_locales!(locale) + + config.backend.transliterate(locale, key, replacement) + rescue I18n::ArgumentError => exception + handle_exception((throw && :throw || raise && :raise), exception, locale, key, options) + end + + # Localizes certain objects, such as dates and numbers to local formatting. + def localize(object, locale: nil, format: nil, **options) + locale ||= config.locale + raise Disabled.new('l') if locale == false + enforce_available_locales!(locale) + + format ||= :default + config.backend.localize(locale, object, format, options) + end + alias :l :localize + + # Executes block with given I18n.locale set. + def with_locale(tmp_locale = nil) + if tmp_locale == nil + yield + else + current_locale = self.locale + self.locale = tmp_locale + begin + yield + ensure + self.locale = current_locale + end + end + end + + # Merges the given locale, key and scope into a single array of keys. + # Splits keys that contain dots into multiple keys. Makes sure all + # keys are Symbols. + def normalize_keys(locale, key, scope, separator = nil) + separator ||= I18n.default_separator + + [ + *normalize_key(locale, separator), + *normalize_key(scope, separator), + *normalize_key(key, separator) + ] + end + + # Returns true when the passed locale, which can be either a String or a + # Symbol, is in the list of available locales. Returns false otherwise. + def locale_available?(locale) + I18n.config.available_locales_set.include?(locale) + end + + # Raises an InvalidLocale exception when the passed locale is not available. + def enforce_available_locales!(locale) + if locale != false && config.enforce_available_locales + raise I18n::InvalidLocale.new(locale) if !locale_available?(locale) + end + end + + def available_locales_initialized? + config.available_locales_initialized? + end + + private + + def translate_key(key, throw, raise, locale, backend, options) + result = catch(:exception) do + backend.translate(locale, key, options) + end + + if result.is_a?(MissingTranslation) + handle_exception((throw && :throw || raise && :raise), result, locale, key, options) + else + result + end + end + + # Any exceptions thrown in translate will be sent to the @@exception_handler + # which can be a Symbol, a Proc or any other Object unless they're forced to + # be raised or thrown (MissingTranslation). + # + # If exception_handler is a Symbol then it will simply be sent to I18n as + # a method call. A Proc will simply be called. In any other case the + # method #call will be called on the exception_handler object. + # + # Examples: + # + # I18n.exception_handler = :custom_exception_handler # this is the default + # I18n.custom_exception_handler(exception, locale, key, options) # will be called like this + # + # I18n.exception_handler = lambda { |*args| ... } # a lambda + # I18n.exception_handler.call(exception, locale, key, options) # will be called like this + # + # I18n.exception_handler = I18nExceptionHandler.new # an object + # I18n.exception_handler.call(exception, locale, key, options) # will be called like this + def handle_exception(handling, exception, locale, key, options) + case handling + when :raise + raise exception.respond_to?(:to_exception) ? exception.to_exception : exception + when :throw + throw :exception, exception + else + case handler = options[:exception_handler] || config.exception_handler + when Symbol + send(handler, exception, locale, key, options) + else + handler.call(exception, locale, key, options) + end + end + end + + @@normalized_key_cache = I18n.new_double_nested_cache + + def normalize_key(key, separator) + @@normalized_key_cache[separator][key] ||= + case key + when Array + key.flat_map { |k| normalize_key(k, separator) } + else + keys = key.to_s.split(separator) + keys.delete('') + keys.map! do |k| + case k + when /\A[-+]?([1-9]\d*|0)\z/ # integer + k.to_i + when 'true' + true + when 'false' + false + else + k.to_sym + end + end + keys + end + end + + def interpolation_keys_from_translation(translation) + case translation + when ::String + translation.scan(Regexp.union(I18n.config.interpolation_patterns)) + when ::Array + translation.map { |element| interpolation_keys_from_translation(element) } + else + [] + end + end + end + + extend Base +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend.rb new file mode 100644 index 0000000..863d618 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module I18n + module Backend + autoload :Base, 'i18n/backend/base' + autoload :Cache, 'i18n/backend/cache' + autoload :CacheFile, 'i18n/backend/cache_file' + autoload :Cascade, 'i18n/backend/cascade' + autoload :Chain, 'i18n/backend/chain' + autoload :Fallbacks, 'i18n/backend/fallbacks' + autoload :Flatten, 'i18n/backend/flatten' + autoload :Gettext, 'i18n/backend/gettext' + autoload :InterpolationCompiler, 'i18n/backend/interpolation_compiler' + autoload :KeyValue, 'i18n/backend/key_value' + autoload :LazyLoadable, 'i18n/backend/lazy_loadable' + autoload :Memoize, 'i18n/backend/memoize' + autoload :Metadata, 'i18n/backend/metadata' + autoload :Pluralization, 'i18n/backend/pluralization' + autoload :Simple, 'i18n/backend/simple' + autoload :Transliterator, 'i18n/backend/transliterator' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/base.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/base.rb new file mode 100644 index 0000000..7ca9c28 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/base.rb @@ -0,0 +1,306 @@ +# frozen_string_literal: true + +require 'yaml' +require 'json' + +module I18n + module Backend + module Base + include I18n::Backend::Transliterator + + # Accepts a list of paths to translation files. Loads translations from + # plain Ruby (*.rb), YAML files (*.yml), or JSON files (*.json). See #load_rb, #load_yml, and #load_json + # for details. + def load_translations(*filenames) + filenames = I18n.load_path if filenames.empty? + filenames.flatten.each do |filename| + loaded_translations = load_file(filename) + yield filename, loaded_translations if block_given? + end + end + + # This method receives a locale, a data hash and options for storing translations. + # Should be implemented + def store_translations(locale, data, options = EMPTY_HASH) + raise NotImplementedError + end + + def translate(locale, key, options = EMPTY_HASH) + raise I18n::ArgumentError if (key.is_a?(String) || key.is_a?(Symbol)) && key.empty? + raise InvalidLocale.new(locale) unless locale + return nil if key.nil? && !options.key?(:default) + + entry = lookup(locale, key, options[:scope], options) unless key.nil? + + if entry.nil? && options.key?(:default) + entry = default(locale, key, options[:default], options) + else + entry = resolve_entry(locale, key, entry, options) + end + + count = options[:count] + + if entry.nil? && (subtrees? || !count) + if (options.key?(:default) && !options[:default].nil?) || !options.key?(:default) + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + end + + entry = entry.dup if entry.is_a?(String) + entry = pluralize(locale, entry, count) if count + + if entry.nil? && !subtrees? + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + + deep_interpolation = options[:deep_interpolation] + values = Utils.except(options, *RESERVED_KEYS) unless options.empty? + if values && !values.empty? + entry = if deep_interpolation + deep_interpolate(locale, entry, values) + else + interpolate(locale, entry, values) + end + elsif entry.is_a?(String) && entry =~ I18n.reserved_keys_pattern + raise ReservedInterpolationKey.new($1.to_sym, entry) + end + entry + end + + def exists?(locale, key, options = EMPTY_HASH) + lookup(locale, key, options[:scope]) != nil + end + + # Acts the same as +strftime+, but uses a localized version of the + # format string. Takes a key from the date/time formats translations as + # a format argument (e.g., :short in :'date.formats'). + def localize(locale, object, format = :default, options = EMPTY_HASH) + if object.nil? && options.include?(:default) + return options[:default] + end + raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime) + + if Symbol === format + key = format + type = object.respond_to?(:sec) ? 'time' : 'date' + options = options.merge(:raise => true, :object => object, :locale => locale) + format = I18n.t(:"#{type}.formats.#{key}", **options) + end + + format = translate_localization_format(locale, object, format, options) + object.strftime(format) + end + + # Returns an array of locales for which translations are available + # ignoring the reserved translation meta data key :i18n. + def available_locales + raise NotImplementedError + end + + def reload! + eager_load! if eager_loaded? + end + + def eager_load! + @eager_loaded = true + end + + protected + + def eager_loaded? + @eager_loaded ||= false + end + + # The method which actually looks up for the translation in the store. + def lookup(locale, key, scope = [], options = EMPTY_HASH) + raise NotImplementedError + end + + def subtrees? + true + end + + # Evaluates defaults. + # If given subject is an Array, it walks the array and returns the + # first translation that can be resolved. Otherwise it tries to resolve + # the translation directly. + def default(locale, object, subject, options = EMPTY_HASH) + if options.size == 1 && options.has_key?(:default) + options = {} + else + options = Utils.except(options, :default) + end + + case subject + when Array + subject.each do |item| + result = resolve(locale, object, item, options) + return result unless result.nil? + end and nil + else + resolve(locale, object, subject, options) + end + end + + # Resolves a translation. + # If the given subject is a Symbol, it will be translated with the + # given options. If it is a Proc then it will be evaluated. All other + # subjects will be returned directly. + def resolve(locale, object, subject, options = EMPTY_HASH) + return subject if options[:resolve] == false + result = catch(:exception) do + case subject + when Symbol + I18n.translate(subject, **options.merge(:locale => locale, :throw => true)) + when Proc + date_or_time = options.delete(:object) || object + resolve(locale, object, subject.call(date_or_time, **options)) + else + subject + end + end + result unless result.is_a?(MissingTranslation) + end + alias_method :resolve_entry, :resolve + + # Picks a translation from a pluralized mnemonic subkey according to English + # pluralization rules : + # - It will pick the :one subkey if count is equal to 1. + # - It will pick the :other subkey otherwise. + # - It will pick the :zero subkey in the special case where count is + # equal to 0 and there is a :zero subkey present. This behaviour is + # not standard with regards to the CLDR pluralization rules. + # Other backends can implement more flexible or complex pluralization rules. + def pluralize(locale, entry, count) + entry = entry.reject { |k, _v| k == :attributes } if entry.is_a?(Hash) + return entry unless entry.is_a?(Hash) && count + + key = pluralization_key(entry, count) + raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key) + entry[key] + end + + # Interpolates values into a given subject. + # + # if the given subject is a string then: + # method interpolates "file %{file} opened by %%{user}", :file => 'test.txt', :user => 'Mr. X' + # # => "file test.txt opened by %{user}" + # + # if the given subject is an array then: + # each element of the array is recursively interpolated (until it finds a string) + # method interpolates ["yes, %{user}", ["maybe no, %{user}", "no, %{user}"]], :user => "bartuz" + # # => ["yes, bartuz", ["maybe no, bartuz", "no, bartuz"]] + def interpolate(locale, subject, values = EMPTY_HASH) + return subject if values.empty? + + case subject + when ::String then I18n.interpolate(subject, values) + when ::Array then subject.map { |element| interpolate(locale, element, values) } + else + subject + end + end + + # Deep interpolation + # + # deep_interpolate { people: { ann: "Ann is %{ann}", john: "John is %{john}" } }, + # ann: 'good', john: 'big' + # #=> { people: { ann: "Ann is good", john: "John is big" } } + def deep_interpolate(locale, data, values = EMPTY_HASH) + return data if values.empty? + + case data + when ::String + I18n.interpolate(data, values) + when ::Hash + data.each_with_object({}) do |(k, v), result| + result[k] = deep_interpolate(locale, v, values) + end + when ::Array + data.map do |v| + deep_interpolate(locale, v, values) + end + else + data + end + end + + # Loads a single translations file by delegating to #load_rb or + # #load_yml depending on the file extension and directly merges the + # data to the existing translations. Raises I18n::UnknownFileType + # for all other file extensions. + def load_file(filename) + type = File.extname(filename).tr('.', '').downcase + raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}", true) + data, keys_symbolized = send(:"load_#{type}", filename) + unless data.is_a?(Hash) + raise InvalidLocaleData.new(filename, 'expects it to return a hash, but does not') + end + data.each { |locale, d| store_translations(locale, d || {}, skip_symbolize_keys: keys_symbolized) } + + data + end + + # Loads a plain Ruby translations file. eval'ing the file must yield + # a Hash containing translation data with locales as toplevel keys. + def load_rb(filename) + translations = eval(IO.read(filename), binding, filename) + [translations, false] + end + + # Loads a YAML translations file. The data must have locales as + # toplevel keys. + def load_yml(filename) + begin + if YAML.respond_to?(:unsafe_load_file) # Psych 4.0 way + [YAML.unsafe_load_file(filename, symbolize_names: true, freeze: true), true] + else + [YAML.load_file(filename), false] + end + rescue TypeError, ScriptError, StandardError => e + raise InvalidLocaleData.new(filename, e.inspect) + end + end + alias_method :load_yaml, :load_yml + + # Loads a JSON translations file. The data must have locales as + # toplevel keys. + def load_json(filename) + begin + # Use #load_file as a proxy for a version of JSON where symbolize_names and freeze are supported. + if ::JSON.respond_to?(:load_file) + [::JSON.load_file(filename, symbolize_names: true, freeze: true), true] + else + [::JSON.parse(File.read(filename)), false] + end + rescue TypeError, StandardError => e + raise InvalidLocaleData.new(filename, e.inspect) + end + end + + def translate_localization_format(locale, object, format, options) + format.to_s.gsub(/%(|\^)[aAbBpP]/) do |match| + case match + when '%a' then I18n.t!(:"date.abbr_day_names", :locale => locale, :format => format)[object.wday] + when '%^a' then I18n.t!(:"date.abbr_day_names", :locale => locale, :format => format)[object.wday].upcase + when '%A' then I18n.t!(:"date.day_names", :locale => locale, :format => format)[object.wday] + when '%^A' then I18n.t!(:"date.day_names", :locale => locale, :format => format)[object.wday].upcase + when '%b' then I18n.t!(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon] + when '%^b' then I18n.t!(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon].upcase + when '%B' then I18n.t!(:"date.month_names", :locale => locale, :format => format)[object.mon] + when '%^B' then I18n.t!(:"date.month_names", :locale => locale, :format => format)[object.mon].upcase + when '%p' then I18n.t!(:"time.#{(object.respond_to?(:hour) ? object.hour : 0) < 12 ? :am : :pm}", :locale => locale, :format => format).upcase + when '%P' then I18n.t!(:"time.#{(object.respond_to?(:hour) ? object.hour : 0) < 12 ? :am : :pm}", :locale => locale, :format => format).downcase + end + end + rescue MissingTranslationData => e + e.message + end + + def pluralization_key(entry, count) + key = :zero if count == 0 && entry.has_key?(:zero) + key ||= count == 1 ? :one : :other + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cache.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cache.rb new file mode 100644 index 0000000..40c18d6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cache.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +# This module allows you to easily cache all responses from the backend - thus +# speeding up the I18n aspects of your application quite a bit. +# +# To enable caching you can simply include the Cache module to the Simple +# backend - or whatever other backend you are using: +# +# I18n::Backend::Simple.send(:include, I18n::Backend::Cache) +# +# You will also need to set a cache store implementation that you want to use: +# +# I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store) +# +# You can use any cache implementation you want that provides the same API as +# ActiveSupport::Cache (only the methods #fetch and #write are being used). +# +# The cache_key implementation by default assumes you pass values that return +# a valid key from #hash (see +# https://www.ruby-doc.org/core/classes/Object.html#M000337). However, you can +# configure your own digest method via which responds to #hexdigest (see +# https://ruby-doc.org/stdlib/libdoc/openssl/rdoc/OpenSSL/Digest.html): +# +# I18n.cache_key_digest = OpenSSL::Digest::SHA256.new +# +# If you use a lambda as a default value in your translation like this: +# +# I18n.t(:"date.order", :default => lambda {[:month, :day, :year]}) +# +# Then you will always have a cache miss, because each time this method +# is called the lambda will have a different hash value. If you know +# the result of the lambda is a constant as in the example above, then +# to cache this you can make the lambda a constant, like this: +# +# DEFAULT_DATE_ORDER = lambda {[:month, :day, :year]} +# ... +# I18n.t(:"date.order", :default => DEFAULT_DATE_ORDER) +# +# If the lambda may result in different values for each call then consider +# also using the Memoize backend. +# +module I18n + class << self + @@cache_store = nil + @@cache_namespace = nil + @@cache_key_digest = nil + + def cache_store + @@cache_store + end + + def cache_store=(store) + @@cache_store = store + end + + def cache_namespace + @@cache_namespace + end + + def cache_namespace=(namespace) + @@cache_namespace = namespace + end + + def cache_key_digest + @@cache_key_digest + end + + def cache_key_digest=(key_digest) + @@cache_key_digest = key_digest + end + + def perform_caching? + !cache_store.nil? + end + end + + module Backend + # TODO Should the cache be cleared if new translations are stored? + module Cache + def translate(locale, key, options = EMPTY_HASH) + I18n.perform_caching? ? fetch(cache_key(locale, key, options)) { super } : super + end + + protected + + def fetch(cache_key, &block) + result = _fetch(cache_key, &block) + throw(:exception, result) if result.is_a?(MissingTranslation) + result = result.dup if result.frozen? rescue result + result + end + + def _fetch(cache_key, &block) + result = I18n.cache_store.read(cache_key) + return result unless result.nil? + result = catch(:exception, &block) + I18n.cache_store.write(cache_key, result) unless result.is_a?(Proc) + result + end + + def cache_key(locale, key, options) + # This assumes that only simple, native Ruby values are passed to I18n.translate. + "i18n/#{I18n.cache_namespace}/#{locale}/#{digest_item(key)}/#{digest_item(options)}" + end + + private + + def digest_item(key) + I18n.cache_key_digest ? I18n.cache_key_digest.hexdigest(key.to_s) : key.to_s.hash + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cache_file.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cache_file.rb new file mode 100644 index 0000000..0c5e192 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cache_file.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'openssl' + +module I18n + module Backend + # Overwrites the Base load_file method to cache loaded file contents. + module CacheFile + # Optionally provide path_roots array to normalize filename paths, + # to make the cached i18n data portable across environments. + attr_accessor :path_roots + + protected + + # Track loaded translation files in the `i18n.load_file` scope, + # and skip loading the file if its contents are still up-to-date. + def load_file(filename) + initialized = !respond_to?(:initialized?) || initialized? + key = I18n::Backend::Flatten.escape_default_separator(normalized_path(filename)) + old_mtime, old_digest = initialized && lookup(:i18n, key, :load_file) + return if (mtime = File.mtime(filename).to_i) == old_mtime || + (digest = OpenSSL::Digest::SHA256.file(filename).hexdigest) == old_digest + super + store_translations(:i18n, load_file: { key => [mtime, digest] }) + end + + # Translate absolute filename to relative path for i18n key. + def normalized_path(file) + return file unless path_roots + path = path_roots.find(&file.method(:start_with?)) || + raise(InvalidLocaleData.new(file, 'outside expected path roots')) + file.sub(path, path_roots.index(path).to_s) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cascade.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cascade.rb new file mode 100644 index 0000000..782b07b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/cascade.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# The Cascade module adds the ability to do cascading lookups to backends that +# are compatible to the Simple backend. +# +# By cascading lookups we mean that for any key that can not be found the +# Cascade module strips one segment off the scope part of the key and then +# tries to look up the key in that scope. +# +# E.g. when a lookup for the key :"foo.bar.baz" does not yield a result then +# the segment :bar will be stripped off the scope part :"foo.bar" and the new +# scope :foo will be used to look up the key :baz. If that does not succeed +# then the remaining scope segment :foo will be omitted, too, and again the +# key :baz will be looked up (now with no scope). +# +# To enable a cascading lookup one passes the :cascade option: +# +# I18n.t(:'foo.bar.baz', :cascade => true) +# +# This will return the first translation found for :"foo.bar.baz", :"foo.baz" +# or :baz in this order. +# +# The cascading lookup takes precedence over resolving any given defaults. +# I.e. defaults will kick in after the cascading lookups haven't succeeded. +# +# This behavior is useful for libraries like ActiveRecord validations where +# the library wants to give users a bunch of more or less fine-grained options +# of scopes for a particular key. +# +# Thanks to Clemens Kofler for the initial idea and implementation! See +# http://github.com/clemens/i18n-cascading-backend + +module I18n + module Backend + module Cascade + def lookup(locale, key, scope = [], options = EMPTY_HASH) + return super unless cascade = options[:cascade] + + cascade = { :step => 1 } unless cascade.is_a?(Hash) + step = cascade[:step] || 1 + offset = cascade[:offset] || 1 + separator = options[:separator] || I18n.default_separator + skip_root = cascade.has_key?(:skip_root) ? cascade[:skip_root] : true + + scope = I18n.normalize_keys(nil, key, scope, separator) + key = (scope.slice!(-offset, offset) || []).join(separator) + + begin + result = super + return result unless result.nil? + scope = scope.dup + end while (!scope.empty? || !skip_root) && scope.slice!(-step, step) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/chain.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/chain.rb new file mode 100644 index 0000000..e081a91 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/chain.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true + +module I18n + module Backend + # Backend that chains multiple other backends and checks each of them when + # a translation needs to be looked up. This is useful when you want to use + # standard translations with a Simple backend but store custom application + # translations in a database or other backends. + # + # To use the Chain backend instantiate it and set it to the I18n module. + # You can add chained backends through the initializer or backends + # accessor: + # + # # preserves the existing Simple backend set to I18n.backend + # I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend) + # + # The implementation assumes that all backends added to the Chain implement + # a lookup method with the same API as Simple backend does. + # + # Fallback translations using the :default option are only used by the last backend of a chain. + class Chain + module Implementation + include Base + + attr_accessor :backends + + def initialize(*backends) + self.backends = backends + end + + def initialized? + backends.all? do |backend| + backend.instance_eval do + return false unless initialized? + end + end + true + end + + def reload! + backends.each { |backend| backend.reload! } + end + + def eager_load! + backends.each { |backend| backend.eager_load! } + end + + def store_translations(locale, data, options = EMPTY_HASH) + backends.first.store_translations(locale, data, options) + end + + def available_locales + backends.map { |backend| backend.available_locales }.flatten.uniq + end + + def translate(locale, key, default_options = EMPTY_HASH) + namespace = nil + options = Utils.except(default_options, :default) + + backends.each do |backend| + catch(:exception) do + options = default_options if backend == backends.last + translation = backend.translate(locale, key, options) + if namespace_lookup?(translation, options) + namespace = _deep_merge(translation, namespace || {}) + elsif !translation.nil? || (options.key?(:default) && options[:default].nil?) + return translation + end + end + end + + return namespace if namespace + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + + def exists?(locale, key, options = EMPTY_HASH) + backends.any? do |backend| + backend.exists?(locale, key, options) + end + end + + def localize(locale, object, format = :default, options = EMPTY_HASH) + backends.each do |backend| + catch(:exception) do + result = backend.localize(locale, object, format, options) and return result + end + end + throw(:exception, I18n::MissingTranslation.new(locale, format, options)) + end + + protected + def init_translations + backends.each do |backend| + backend.send(:init_translations) + end + end + + def translations + backends.reverse.each_with_object({}) do |backend, memo| + partial_translations = backend.instance_eval do + init_translations unless initialized? + translations + end + Utils.deep_merge!(memo, partial_translations) { |_, a, b| b || a } + end + end + + def namespace_lookup?(result, options) + result.is_a?(Hash) && !options.has_key?(:count) + end + + private + # This is approximately what gets used in ActiveSupport. + # However since we are not guaranteed to run in an ActiveSupport context + # it is wise to have our own copy. We underscore it + # to not pollute the namespace of the including class. + def _deep_merge(hash, other_hash) + copy = hash.dup + other_hash.each_pair do |k,v| + value_from_other = hash[k] + copy[k] = value_from_other.is_a?(Hash) && v.is_a?(Hash) ? _deep_merge(value_from_other, v) : v + end + copy + end + end + + include Implementation + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/fallbacks.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/fallbacks.rb new file mode 100644 index 0000000..a88a4fc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/fallbacks.rb @@ -0,0 +1,115 @@ +# frozen_string_literal: true + +# I18n locale fallbacks are useful when you want your application to use +# translations from other locales when translations for the current locale are +# missing. E.g. you might want to use :en translations when translations in +# your applications main locale :de are missing. +# +# To enable locale fallbacks you can simply include the Fallbacks module to +# the Simple backend - or whatever other backend you are using: +# +# I18n::Backend::Simple.include(I18n::Backend::Fallbacks) +module I18n + @@fallbacks = nil + + class << self + # Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+. + def fallbacks + @@fallbacks ||= I18n::Locale::Fallbacks.new + Thread.current[:i18n_fallbacks] || @@fallbacks + end + + # Sets the current fallbacks implementation. Use this to set a different fallbacks implementation. + def fallbacks=(fallbacks) + @@fallbacks = fallbacks.is_a?(Array) ? I18n::Locale::Fallbacks.new(fallbacks) : fallbacks + Thread.current[:i18n_fallbacks] = @@fallbacks + end + end + + module Backend + module Fallbacks + # Overwrites the Base backend translate method so that it will try each + # locale given by I18n.fallbacks for the given locale. E.g. for the + # locale :"de-DE" it might try the locales :"de-DE", :de and :en + # (depends on the fallbacks implementation) until it finds a result with + # the given options. If it does not find any result for any of the + # locales it will then throw MissingTranslation as usual. + # + # The default option takes precedence over fallback locales only when + # it's a Symbol. When the default contains a String, Proc or Hash + # it is evaluated last after all the fallback locales have been tried. + def translate(locale, key, options = EMPTY_HASH) + return super unless options.fetch(:fallback, true) + return super if options[:fallback_in_progress] + default = extract_non_symbol_default!(options) if options[:default] + + fallback_options = options.merge(:fallback_in_progress => true, fallback_original_locale: locale) + I18n.fallbacks[locale].each do |fallback| + begin + catch(:exception) do + result = super(fallback, key, fallback_options) + unless result.nil? + on_fallback(locale, fallback, key, options) if locale.to_s != fallback.to_s + return result + end + end + rescue I18n::InvalidLocale + # we do nothing when the locale is invalid, as this is a fallback anyways. + end + end + + return if options.key?(:default) && options[:default].nil? + + return super(locale, nil, options.merge(:default => default)) if default + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + + def resolve_entry(locale, object, subject, options = EMPTY_HASH) + return subject if options[:resolve] == false + result = catch(:exception) do + options.delete(:fallback_in_progress) if options.key?(:fallback_in_progress) + + case subject + when Symbol + I18n.translate(subject, **options.merge(:locale => options[:fallback_original_locale], :throw => true)) + when Proc + date_or_time = options.delete(:object) || object + resolve_entry(options[:fallback_original_locale], object, subject.call(date_or_time, **options)) + else + subject + end + end + result unless result.is_a?(MissingTranslation) + end + + def extract_non_symbol_default!(options) + defaults = [options[:default]].flatten + first_non_symbol_default = defaults.detect{|default| !default.is_a?(Symbol)} + if first_non_symbol_default + options[:default] = defaults[0, defaults.index(first_non_symbol_default)] + end + return first_non_symbol_default + end + + def exists?(locale, key, options = EMPTY_HASH) + return super unless options.fetch(:fallback, true) + I18n.fallbacks[locale].each do |fallback| + begin + return true if super(fallback, key, options) + rescue I18n::InvalidLocale + # we do nothing when the locale is invalid, as this is a fallback anyways. + end + end + + false + end + + private + + # Overwrite on_fallback to add specified logic when the fallback succeeds. + def on_fallback(_original_locale, _fallback_locale, _key, _options) + nil + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/flatten.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/flatten.rb new file mode 100644 index 0000000..e9bd9d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/flatten.rb @@ -0,0 +1,118 @@ +# frozen_string_literal: true + +module I18n + module Backend + # This module contains several helpers to assist flattening translations. + # You may want to flatten translations for: + # + # 1) speed up lookups, as in the Memoize backend; + # 2) In case you want to store translations in a data store, as in ActiveRecord backend; + # + # You can check both backends above for some examples. + # This module also keeps all links in a hash so they can be properly resolved when flattened. + module Flatten + SEPARATOR_ESCAPE_CHAR = "\001" + FLATTEN_SEPARATOR = "." + + # normalize_keys the flatten way. This method is significantly faster + # and creates way less objects than the one at I18n.normalize_keys. + # It also handles escaping the translation keys. + def self.normalize_flat_keys(locale, key, scope, separator) + keys = [scope, key] + keys.flatten! + keys.compact! + + separator ||= I18n.default_separator + + if separator != FLATTEN_SEPARATOR + from_str = "#{FLATTEN_SEPARATOR}#{separator}" + to_str = "#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}" + + keys.map! { |k| k.to_s.tr from_str, to_str } + end + + keys.join(".") + end + + # Receives a string and escape the default separator. + def self.escape_default_separator(key) #:nodoc: + key.to_s.tr(FLATTEN_SEPARATOR, SEPARATOR_ESCAPE_CHAR) + end + + # Shortcut to I18n::Backend::Flatten.normalize_flat_keys + # and then resolve_links. + def normalize_flat_keys(locale, key, scope, separator) + key = I18n::Backend::Flatten.normalize_flat_keys(locale, key, scope, separator) + resolve_link(locale, key) + end + + # Store flattened links. + def links + @links ||= I18n.new_double_nested_cache + end + + # Flatten keys for nested Hashes by chaining up keys: + # + # >> { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i" => "j"}.wind + # => { "a.b.c" => "d", "a.b.e" => "f", "a.g" => "h", "i" => "j" } + # + def flatten_keys(hash, escape, prev_key=nil, &block) + hash.each_pair do |key, value| + key = escape_default_separator(key) if escape + curr_key = [prev_key, key].compact.join(FLATTEN_SEPARATOR).to_sym + yield curr_key, value + flatten_keys(value, escape, curr_key, &block) if value.is_a?(Hash) + end + end + + # Receives a hash of translations (where the key is a locale and + # the value is another hash) and return a hash with all + # translations flattened. + # + # Nested hashes are included in the flattened hash just if subtree + # is true and Symbols are automatically stored as links. + def flatten_translations(locale, data, escape, subtree) + hash = {} + flatten_keys(data, escape) do |key, value| + if value.is_a?(Hash) + hash[key] = value if subtree + else + store_link(locale, key, value) if value.is_a?(Symbol) + hash[key] = value + end + end + hash + end + + protected + + def store_link(locale, key, link) + links[locale.to_sym][key.to_s] = link.to_s + end + + def resolve_link(locale, key) + key, locale = key.to_s, locale.to_sym + links = self.links[locale] + + if links.key?(key) + links[key] + elsif link = find_link(locale, key) + store_link(locale, key, key.gsub(*link)) + else + key + end + end + + def find_link(locale, key) #:nodoc: + links[locale].each_pair do |from, to| + return [from, to] if key[0, from.length] == from + end && nil + end + + def escape_default_separator(key) #:nodoc: + I18n::Backend::Flatten.escape_default_separator(key) + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/gettext.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/gettext.rb new file mode 100644 index 0000000..0769646 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/gettext.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +require 'i18n/gettext' +require 'i18n/gettext/po_parser' + +module I18n + module Backend + # Experimental support for using Gettext po files to store translations. + # + # To use this you can simply include the module to the Simple backend - or + # whatever other backend you are using. + # + # I18n::Backend::Simple.include(I18n::Backend::Gettext) + # + # Now you should be able to include your Gettext translation (*.po) files to + # the +I18n.load_path+ so they're loaded to the backend and you can use them as + # usual: + # + # I18n.load_path += Dir["path/to/locales/*.po"] + # + # Following the Gettext convention this implementation expects that your + # translation files are named by their locales. E.g. the file en.po would + # contain the translations for the English locale. + # + # To translate text you must use one of the translate methods provided by + # I18n::Gettext::Helpers. + # + # include I18n::Gettext::Helpers + # puts _("some string") + # + # Without it strings containing periods (".") will not be translated. + + module Gettext + class PoData < Hash + def set_comment(msgid_or_sym, comment) + # ignore + end + end + + protected + def load_po(filename) + locale = ::File.basename(filename, '.po').to_sym + data = normalize(locale, parse(filename)) + [{ locale => data }, false] + end + + def parse(filename) + GetText::PoParser.new.parse(::File.read(filename), PoData.new) + end + + def normalize(locale, data) + data.inject({}) do |result, (key, value)| + unless key.nil? || key.empty? + key = key.gsub(I18n::Gettext::CONTEXT_SEPARATOR, '|') + key, value = normalize_pluralization(locale, key, value) if key.index("\000") + + parts = key.split('|').reverse + normalized = parts.inject({}) do |_normalized, part| + { part => _normalized.empty? ? value : _normalized } + end + + Utils.deep_merge!(result, normalized) + end + result + end + end + + def normalize_pluralization(locale, key, value) + # FIXME po_parser includes \000 chars that can not be turned into Symbols + key = key.gsub("\000", I18n::Gettext::PLURAL_SEPARATOR).split(I18n::Gettext::PLURAL_SEPARATOR).first + + keys = I18n::Gettext.plural_keys(locale) + values = value.split("\000") + raise "invalid number of plurals: #{values.size}, keys: #{keys.inspect} on #{locale} locale for msgid #{key.inspect} with values #{values.inspect}" if values.size != keys.size + + result = {} + values.each_with_index { |_value, ix| result[keys[ix]] = _value } + [key, result] + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/interpolation_compiler.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/interpolation_compiler.rb new file mode 100644 index 0000000..e37b679 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/interpolation_compiler.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +# The InterpolationCompiler module contains optimizations that can tremendously +# speed up the interpolation process on the Simple backend. +# +# It works by defining a pre-compiled method on stored translation Strings that +# already bring all the knowledge about contained interpolation variables etc. +# so that the actual recurring interpolation will be very fast. +# +# To enable pre-compiled interpolations you can simply include the +# InterpolationCompiler module to the Simple backend: +# +# I18n::Backend::Simple.include(I18n::Backend::InterpolationCompiler) +# +# Note that InterpolationCompiler does not yield meaningful results and consequently +# should not be used with Ruby 1.9 (YARV) but improves performance everywhere else +# (jRuby, Rubinius). +module I18n + module Backend + module InterpolationCompiler + module Compiler + extend self + + TOKENIZER = /(%%?\{[^}]+\})/ + + def compile_if_an_interpolation(string) + if interpolated_str?(string) + string.instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + def i18n_interpolate(v = {}) + "#{compiled_interpolation_body(string)}" + end + RUBY_EVAL + end + + string + end + + def interpolated_str?(str) + str.kind_of?(::String) && str =~ TOKENIZER + end + + protected + # tokenize("foo %{bar} baz %%{buz}") # => ["foo ", "%{bar}", " baz ", "%%{buz}"] + def tokenize(str) + str.split(TOKENIZER) + end + + def compiled_interpolation_body(str) + tokenize(str).map do |token| + token.match(TOKENIZER) ? handle_interpolation_token(token) : escape_plain_str(token) + end.join + end + + def handle_interpolation_token(token) + token.start_with?('%%') ? token[1..] : compile_interpolation_token(token[2..-2]) + end + + def compile_interpolation_token(key) + "\#{#{interpolate_or_raise_missing(key)}}" + end + + def interpolate_or_raise_missing(key) + escaped_key = escape_key_sym(key) + RESERVED_KEYS.include?(key) ? reserved_key(escaped_key) : interpolate_key(escaped_key) + end + + def interpolate_key(key) + [direct_key(key), nil_key(key), missing_key(key)].join('||') + end + + def direct_key(key) + "((t = v[#{key}]) && t.respond_to?(:call) ? t.call : t)" + end + + def nil_key(key) + "(v.has_key?(#{key}) && '')" + end + + def missing_key(key) + "I18n.config.missing_interpolation_argument_handler.call(#{key}, v, self)" + end + + def reserved_key(key) + "raise(ReservedInterpolationKey.new(#{key}, self))" + end + + def escape_plain_str(str) + str.gsub(/"|\\|#/) {|x| "\\#{x}"} + end + + def escape_key_sym(key) + # rely on Ruby to do all the hard work :) + key.to_sym.inspect + end + end + + def interpolate(locale, string, values) + if string.respond_to?(:i18n_interpolate) + string.i18n_interpolate(values) + elsif values + super + else + string + end + end + + def store_translations(locale, data, options = EMPTY_HASH) + compile_all_strings_in(data) + super + end + + protected + def compile_all_strings_in(data) + data.each_value do |value| + Compiler.compile_if_an_interpolation(value) + compile_all_strings_in(value) if value.kind_of?(Hash) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/key_value.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/key_value.rb new file mode 100644 index 0000000..b937e25 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/key_value.rb @@ -0,0 +1,204 @@ +# frozen_string_literal: true + +require 'i18n/backend/base' + +module I18n + + begin + require 'oj' + class JSON + class << self + def encode(value) + Oj::Rails.encode(value) + end + def decode(value) + Oj.load(value) + end + end + end + rescue LoadError + require 'active_support/json' + JSON = ActiveSupport::JSON + end + + module Backend + # This is a basic backend for key value stores. It receives on + # initialization the store, which should respond to three methods: + # + # * store#[](key) - Used to get a value + # * store#[]=(key, value) - Used to set a value + # * store#keys - Used to get all keys + # + # Since these stores only supports string, all values are converted + # to JSON before being stored, allowing it to also store booleans, + # hashes and arrays. However, this store does not support Procs. + # + # As the ActiveRecord backend, Symbols are just supported when loading + # translations from the filesystem or through explicit store translations. + # + # Also, avoid calling I18n.available_locales since it's a somehow + # expensive operation in most stores. + # + # == Example + # + # To setup I18n to use TokyoCabinet in memory is quite straightforward: + # + # require 'rufus/tokyo/cabinet' # gem install rufus-tokyo + # I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*')) + # + # == Performance + # + # You may make this backend even faster by including the Memoize module. + # However, notice that you should properly clear the cache if you change + # values directly in the key-store. + # + # == Subtrees + # + # In most backends, you are allowed to retrieve part of a translation tree: + # + # I18n.backend.store_translations :en, :foo => { :bar => :baz } + # I18n.t "foo" #=> { :bar => :baz } + # + # This backend supports this feature by default, but it slows down the storage + # of new data considerably and makes hard to delete entries. That said, you are + # allowed to disable the storage of subtrees on initialization: + # + # I18n::Backend::KeyValue.new(@store, false) + # + # This is useful if you are using a KeyValue backend chained to a Simple backend. + class KeyValue + module Implementation + attr_accessor :store + + include Base, Flatten + + def initialize(store, subtrees=true) + @store, @subtrees = store, subtrees + end + + def initialized? + !@store.nil? + end + + def store_translations(locale, data, options = EMPTY_HASH) + escape = options.fetch(:escape, true) + flatten_translations(locale, data, escape, @subtrees).each do |key, value| + key = "#{locale}.#{key}" + + case value + when Hash + if @subtrees && (old_value = @store[key]) + old_value = JSON.decode(old_value) + value = Utils.deep_merge!(Utils.deep_symbolize_keys(old_value), value) if old_value.is_a?(Hash) + end + when Proc + raise "Key-value stores cannot handle procs" + end + + @store[key] = JSON.encode(value) unless value.is_a?(Symbol) + end + end + + def available_locales + locales = @store.keys.map { |k| k =~ /\./; $` } + locales.uniq! + locales.compact! + locales.map! { |k| k.to_sym } + locales + end + + protected + + # Queries the translations from the key-value store and converts + # them into a hash such as the one returned from loading the + # haml files + def translations + @translations = Utils.deep_symbolize_keys(@store.keys.clone.map do |main_key| + main_value = JSON.decode(@store[main_key]) + main_key.to_s.split(".").reverse.inject(main_value) do |value, key| + {key.to_sym => value} + end + end.inject{|hash, elem| Utils.deep_merge!(hash, elem)}) + end + + def init_translations + # NO OP + # This call made also inside Simple Backend and accessed by + # other plugins like I18n-js and babilu and + # to use it along with the Chain backend we need to + # provide a uniform API even for protected methods :S + end + + def subtrees? + @subtrees + end + + def lookup(locale, key, scope = [], options = EMPTY_HASH) + key = normalize_flat_keys(locale, key, scope, options[:separator]) + value = @store["#{locale}.#{key}"] + value = JSON.decode(value) if value + + if value.is_a?(Hash) + Utils.deep_symbolize_keys(value) + elsif !value.nil? + value + elsif !@subtrees + SubtreeProxy.new("#{locale}.#{key}", @store) + end + end + + def pluralize(locale, entry, count) + if subtrees? + super + else + return entry unless entry.is_a?(Hash) + key = pluralization_key(entry, count) + entry[key] + end + end + end + + class SubtreeProxy + def initialize(master_key, store) + @master_key = master_key + @store = store + @subtree = nil + end + + def has_key?(key) + @subtree && @subtree.has_key?(key) || self[key] + end + + def [](key) + unless @subtree && value = @subtree[key] + value = @store["#{@master_key}.#{key}"] + if value + value = JSON.decode(value) + (@subtree ||= {})[key] = value + end + end + value + end + + def is_a?(klass) + Hash == klass || super + end + alias :kind_of? :is_a? + + def instance_of?(klass) + Hash == klass || super + end + + def nil? + @subtree.nil? + end + + def inspect + @subtree.inspect + end + end + + include Implementation + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/lazy_loadable.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/lazy_loadable.rb new file mode 100644 index 0000000..575b32b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/lazy_loadable.rb @@ -0,0 +1,184 @@ +# frozen_string_literal: true + +module I18n + module Backend + # Backend that lazy loads translations based on the current locale. This + # implementation avoids loading all translations up front. Instead, it only + # loads the translations that belong to the current locale. This offers a + # performance incentive in local development and test environments for + # applications with many translations for many different locales. It's + # particularly useful when the application only refers to a single locales' + # translations at a time (ex. A Rails workload). The implementation + # identifies which translation files from the load path belong to the + # current locale by pattern matching against their path name. + # + # Specifically, a translation file is considered to belong to a locale if: + # a) the filename is in the I18n load path + # b) the filename ends in a supported extension (ie. .yml, .json, .po, .rb) + # c) the filename starts with the locale identifier + # d) the locale identifier and optional proceeding text is separated by an underscore, ie. "_". + # + # Examples: + # Valid files that will be selected by this backend: + # + # "files/locales/en_translation.yml" (Selected for locale "en") + # "files/locales/fr.po" (Selected for locale "fr") + # + # Invalid files that won't be selected by this backend: + # + # "files/locales/translation-file" + # "files/locales/en-translation.unsupported" + # "files/locales/french/translation.yml" + # "files/locales/fr/translation.yml" + # + # The implementation uses this assumption to defer the loading of + # translation files until the current locale actually requires them. + # + # The backend has two working modes: lazy_load and eager_load. + # + # Note: This backend should only be enabled in test environments! + # When the mode is set to false, the backend behaves exactly like the + # Simple backend, with an additional check that the paths being loaded + # abide by the format. If paths can't be matched to the format, an error is raised. + # + # You can configure lazy loaded backends through the initializer or backends + # accessor: + # + # # In test environments + # + # I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: true) + # + # # In other environments, such as production and CI + # + # I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: false) # default + # + class LocaleExtractor + class << self + def locale_from_path(path) + name = File.basename(path, ".*") + locale = name.split("_").first + locale.to_sym unless locale.nil? + end + end + end + + class LazyLoadable < Simple + def initialize(lazy_load: false) + @lazy_load = lazy_load + end + + # Returns whether the current locale is initialized. + def initialized? + if lazy_load? + initialized_locales[I18n.locale] + else + super + end + end + + # Clean up translations and uninitialize all locales. + def reload! + if lazy_load? + @initialized_locales = nil + @translations = nil + else + super + end + end + + # Eager loading is not supported in the lazy context. + def eager_load! + if lazy_load? + raise UnsupportedMethod.new(__method__, self.class, "Cannot eager load translations because backend was configured with lazy_load: true.") + else + super + end + end + + # Parse the load path and extract all locales. + def available_locales + if lazy_load? + I18n.load_path.map { |path| LocaleExtractor.locale_from_path(path) }.uniq + else + super + end + end + + def lookup(locale, key, scope = [], options = EMPTY_HASH) + if lazy_load? + I18n.with_locale(locale) do + super + end + else + super + end + end + + protected + + + # Load translations from files that belong to the current locale. + def init_translations + file_errors = if lazy_load? + initialized_locales[I18n.locale] = true + load_translations_and_collect_file_errors(filenames_for_current_locale) + else + @initialized = true + load_translations_and_collect_file_errors(I18n.load_path) + end + + raise InvalidFilenames.new(file_errors) unless file_errors.empty? + end + + def initialized_locales + @initialized_locales ||= Hash.new(false) + end + + private + + def lazy_load? + @lazy_load + end + + class FilenameIncorrect < StandardError + def initialize(file, expected_locale, unexpected_locales) + super "#{file} can only load translations for \"#{expected_locale}\". Found translations for: #{unexpected_locales}." + end + end + + # Loads each file supplied and asserts that the file only loads + # translations as expected by the name. The method returns a list of + # errors corresponding to offending files. + def load_translations_and_collect_file_errors(files) + errors = [] + + load_translations(files) do |file, loaded_translations| + assert_file_named_correctly!(file, loaded_translations) + rescue FilenameIncorrect => e + errors << e + end + + errors + end + + # Select all files from I18n load path that belong to current locale. + # These files must start with the locale identifier (ie. "en", "pt-BR"), + # followed by an "_" demarcation to separate proceeding text. + def filenames_for_current_locale + I18n.load_path.flatten.select do |path| + LocaleExtractor.locale_from_path(path) == I18n.locale + end + end + + # Checks if a filename is named in correspondence to the translations it loaded. + # The locale extracted from the path must be the single locale loaded in the translations. + def assert_file_named_correctly!(file, translations) + loaded_locales = translations.keys.map(&:to_sym) + expected_locale = LocaleExtractor.locale_from_path(file) + unexpected_locales = loaded_locales.reject { |locale| locale == expected_locale } + + raise FilenameIncorrect.new(file, expected_locale, unexpected_locales) unless unexpected_locales.empty? + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/memoize.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/memoize.rb new file mode 100644 index 0000000..3293d2b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/memoize.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Memoize module simply memoizes the values returned by lookup using +# a flat hash and can tremendously speed up the lookup process in a backend. +# +# To enable it you can simply include the Memoize module to your backend: +# +# I18n::Backend::Simple.include(I18n::Backend::Memoize) +# +# Notice that it's the responsibility of the backend to define whenever the +# cache should be cleaned. +module I18n + module Backend + module Memoize + def available_locales + @memoized_locales ||= super + end + + def store_translations(locale, data, options = EMPTY_HASH) + reset_memoizations!(locale) + super + end + + def reload! + reset_memoizations! + super + end + + def eager_load! + memoized_lookup + available_locales + super + end + + protected + + def lookup(locale, key, scope = nil, options = EMPTY_HASH) + flat_key = I18n::Backend::Flatten.normalize_flat_keys(locale, + key, scope, options[:separator]).to_sym + flat_hash = memoized_lookup[locale.to_sym] + flat_hash.key?(flat_key) ? flat_hash[flat_key] : (flat_hash[flat_key] = super) + end + + def memoized_lookup + @memoized_lookup ||= I18n.new_double_nested_cache + end + + def reset_memoizations!(locale=nil) + @memoized_locales = nil + (locale ? memoized_lookup[locale.to_sym] : memoized_lookup).clear + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/metadata.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/metadata.rb new file mode 100644 index 0000000..51ea7a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/metadata.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +# I18n translation metadata is useful when you want to access information +# about how a translation was looked up, pluralized or interpolated in +# your application. +# +# msg = I18n.t(:message, :default => 'Hi!', :scope => :foo) +# msg.translation_metadata +# # => { :key => :message, :scope => :foo, :default => 'Hi!' } +# +# If a :count option was passed to #translate it will be set to the metadata. +# Likewise, if any interpolation variables were passed they will also be set. +# +# To enable translation metadata you can simply include the Metadata module +# into the Simple backend class - or whatever other backend you are using: +# +# I18n::Backend::Simple.include(I18n::Backend::Metadata) +# +module I18n + module Backend + module Metadata + class << self + def included(base) + Object.class_eval do + def translation_metadata + unless self.frozen? + @translation_metadata ||= {} + else + {} + end + end + + def translation_metadata=(translation_metadata) + @translation_metadata = translation_metadata unless self.frozen? + end + end unless Object.method_defined?(:translation_metadata) + end + end + + def translate(locale, key, options = EMPTY_HASH) + metadata = { + :locale => locale, + :key => key, + :scope => options[:scope], + :default => options[:default], + :separator => options[:separator], + :values => options.reject { |name, _value| RESERVED_KEYS.include?(name) } + } + with_metadata(metadata) { super } + end + + def interpolate(locale, entry, values = EMPTY_HASH) + metadata = entry.translation_metadata.merge(:original => entry) + with_metadata(metadata) { super } + end + + def pluralize(locale, entry, count) + with_metadata(:count => count) { super } + end + + protected + + def with_metadata(metadata, &block) + result = yield + result.translation_metadata = result.translation_metadata.merge(metadata) if result + result + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/pluralization.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/pluralization.rb new file mode 100644 index 0000000..1d3277b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/pluralization.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true + +# I18n Pluralization are useful when you want your application to +# customize pluralization rules. +# +# To enable locale specific pluralizations you can simply include the +# Pluralization module to the Simple backend - or whatever other backend you +# are using. +# +# I18n::Backend::Simple.include(I18n::Backend::Pluralization) +# +# You also need to make sure to provide pluralization algorithms to the +# backend, i.e. include them to your I18n.load_path accordingly. +module I18n + module Backend + module Pluralization + # Overwrites the Base backend translate method so that it will check the + # translation meta data space (:i18n) for a locale specific pluralization + # rule and use it to pluralize the given entry. I.e., the library expects + # pluralization rules to be stored at I18n.t(:'i18n.plural.rule') + # + # Pluralization rules are expected to respond to #call(count) and + # return a pluralization key. Valid keys depend on the pluralization + # rules for the locale, as defined in the CLDR. + # As of v41, 6 locale-specific plural categories are defined: + # :few, :many, :one, :other, :two, :zero + # + # n.b., The :one plural category does not imply the number 1. + # Instead, :one is a category for any number that behaves like 1 in + # that locale. For example, in some locales, :one is used for numbers + # that end in "1" (like 1, 21, 151) but that don't end in + # 11 (like 11, 111, 10311). + # Similar notes apply to the :two, and :zero plural categories. + # + # If you want to have different strings for the categories of count == 0 + # (e.g. "I don't have any cars") or count == 1 (e.g. "I have a single car") + # use the explicit `"0"` and `"1"` keys. + # https://unicode-org.github.io/cldr/ldml/tr35-numbers.html#Explicit_0_1_rules + def pluralize(locale, entry, count) + return entry unless entry.is_a?(Hash) && count + + pluralizer = pluralizer(locale) + if pluralizer.respond_to?(:call) + # Deprecation: The use of the `zero` key in this way is incorrect. + # Users that want a different string for the case of `count == 0` should use the explicit "0" key instead. + # We keep this incorrect behaviour for now for backwards compatibility until we can remove it. + # Ref: https://github.com/ruby-i18n/i18n/issues/629 + return entry[:zero] if count == 0 && entry.has_key?(:zero) + + # "0" and "1" are special cases + # https://unicode-org.github.io/cldr/ldml/tr35-numbers.html#Explicit_0_1_rules + if count == 0 || count == 1 + value = entry[symbolic_count(count)] + return value if value + end + + # Lateral Inheritance of "count" attribute (http://www.unicode.org/reports/tr35/#Lateral_Inheritance): + # > If there is no value for a path, and that path has a [@count="x"] attribute and value, then: + # > 1. If "x" is numeric, the path falls back to the path with [@count=«the plural rules category for x for that locale»], within that the same locale. + # > 2. If "x" is anything but "other", it falls back to a path [@count="other"], within that the same locale. + # > 3. If "x" is "other", it falls back to the path that is completely missing the count item, within that the same locale. + # Note: We don't yet implement #3 above, since we haven't decided how lateral inheritance attributes should be represented. + plural_rule_category = pluralizer.call(count) + + value = if entry.has_key?(plural_rule_category) || entry.has_key?(:other) + entry[plural_rule_category] || entry[:other] + else + raise InvalidPluralizationData.new(entry, count, plural_rule_category) + end + else + super + end + end + + protected + + def pluralizers + @pluralizers ||= {} + end + + def pluralizer(locale) + pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false) + end + + private + + # Normalizes categories of 0.0 and 1.0 + # and returns the symbolic version + def symbolic_count(count) + count = 0 if count == 0 + count = 1 if count == 1 + count.to_s.to_sym + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/simple.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/simple.rb new file mode 100644 index 0000000..7caa7dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/simple.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +require 'i18n/backend/base' + +module I18n + module Backend + # A simple backend that reads translations from YAML files and stores them in + # an in-memory hash. Relies on the Base backend. + # + # The implementation is provided by a Implementation module allowing to easily + # extend Simple backend's behavior by including modules. E.g.: + # + # module I18n::Backend::Pluralization + # def pluralize(*args) + # # extended pluralization logic + # super + # end + # end + # + # I18n::Backend::Simple.include(I18n::Backend::Pluralization) + class Simple + module Implementation + include Base + + # Mutex to ensure that concurrent translations loading will be thread-safe + MUTEX = Mutex.new + + def initialized? + @initialized ||= false + end + + # Stores translations for the given locale in memory. + # This uses a deep merge for the translations hash, so existing + # translations will be overwritten by new ones only at the deepest + # level of the hash. + def store_translations(locale, data, options = EMPTY_HASH) + if I18n.enforce_available_locales && + I18n.available_locales_initialized? && + !I18n.locale_available?(locale) + return data + end + locale = locale.to_sym + translations[locale] ||= Concurrent::Hash.new + data = Utils.deep_symbolize_keys(data) unless options.fetch(:skip_symbolize_keys, false) + Utils.deep_merge!(translations[locale], data) + end + + # Get available locales from the translations hash + def available_locales + init_translations unless initialized? + translations.inject([]) do |locales, (locale, data)| + locales << locale unless data.size <= 1 && (data.empty? || data.has_key?(:i18n)) + locales + end + end + + # Clean up translations hash and set initialized to false on reload! + def reload! + @initialized = false + @translations = nil + super + end + + def eager_load! + init_translations unless initialized? + super + end + + def translations(do_init: false) + # To avoid returning empty translations, + # call `init_translations` + init_translations if do_init && !initialized? + + @translations ||= Concurrent::Hash.new do |h, k| + MUTEX.synchronize do + h[k] = Concurrent::Hash.new + end + end + end + + protected + + def init_translations + load_translations + @initialized = true + end + + # Looks up a translation from the translations hash. Returns nil if + # either key is nil, or locale, scope or key do not exist as a key in the + # nested translations hash. Splits keys or scopes containing dots + # into multiple keys, i.e. currency.format is regarded the same as + # %w(currency format). + def lookup(locale, key, scope = [], options = EMPTY_HASH) + init_translations unless initialized? + keys = I18n.normalize_keys(locale, key, scope, options[:separator]) + + keys.inject(translations) do |result, _key| + return nil unless result.is_a?(Hash) + unless result.has_key?(_key) + _key = _key.to_s.to_sym + return nil unless result.has_key?(_key) + end + result = result[_key] + result = resolve_entry(locale, _key, result, Utils.except(options.merge(:scope => nil), :count)) if result.is_a?(Symbol) + result + end + end + end + + include Implementation + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/transliterator.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/transliterator.rb new file mode 100644 index 0000000..70c0df3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/backend/transliterator.rb @@ -0,0 +1,108 @@ +# encoding: utf-8 +# frozen_string_literal: true + +module I18n + module Backend + module Transliterator + DEFAULT_REPLACEMENT_CHAR = "?" + + # Given a locale and a UTF-8 string, return the locale's ASCII + # approximation for the string. + def transliterate(locale, string, replacement = nil) + @transliterators ||= {} + @transliterators[locale] ||= Transliterator.get I18n.t(:'i18n.transliterate.rule', + :locale => locale, :resolve => false, :default => {}) + @transliterators[locale].transliterate(string, replacement) + end + + # Get a transliterator instance. + def self.get(rule = nil) + if !rule || rule.kind_of?(Hash) + HashTransliterator.new(rule) + elsif rule.kind_of? Proc + ProcTransliterator.new(rule) + else + raise I18n::ArgumentError, "Transliteration rule must be a proc or a hash." + end + end + + # A transliterator which accepts a Proc as its transliteration rule. + class ProcTransliterator + def initialize(rule) + @rule = rule + end + + def transliterate(string, replacement = nil) + @rule.call(string) + end + end + + # A transliterator which accepts a Hash of characters as its translation + # rule. + class HashTransliterator + DEFAULT_APPROXIMATIONS = { + "À"=>"A", "Á"=>"A", "Â"=>"A", "Ã"=>"A", "Ä"=>"A", "Å"=>"A", "Æ"=>"AE", + "Ç"=>"C", "È"=>"E", "É"=>"E", "Ê"=>"E", "Ë"=>"E", "Ì"=>"I", "Í"=>"I", + "Î"=>"I", "Ï"=>"I", "Ð"=>"D", "Ñ"=>"N", "Ò"=>"O", "Ó"=>"O", "Ô"=>"O", + "Õ"=>"O", "Ö"=>"O", "×"=>"x", "Ø"=>"O", "Ù"=>"U", "Ú"=>"U", "Û"=>"U", + "Ü"=>"U", "Ý"=>"Y", "Þ"=>"Th", "ß"=>"ss", "ẞ"=>"SS", "à"=>"a", + "á"=>"a", "â"=>"a", "ã"=>"a", "ä"=>"a", "å"=>"a", "æ"=>"ae", "ç"=>"c", + "è"=>"e", "é"=>"e", "ê"=>"e", "ë"=>"e", "ì"=>"i", "í"=>"i", "î"=>"i", + "ï"=>"i", "ð"=>"d", "ñ"=>"n", "ò"=>"o", "ó"=>"o", "ô"=>"o", "õ"=>"o", + "ö"=>"o", "ø"=>"o", "ù"=>"u", "ú"=>"u", "û"=>"u", "ü"=>"u", "ý"=>"y", + "þ"=>"th", "ÿ"=>"y", "Ā"=>"A", "ā"=>"a", "Ă"=>"A", "ă"=>"a", "Ą"=>"A", + "ą"=>"a", "Ć"=>"C", "ć"=>"c", "Ĉ"=>"C", "ĉ"=>"c", "Ċ"=>"C", "ċ"=>"c", + "Č"=>"C", "č"=>"c", "Ď"=>"D", "ď"=>"d", "Đ"=>"D", "đ"=>"d", "Ē"=>"E", + "ē"=>"e", "Ĕ"=>"E", "ĕ"=>"e", "Ė"=>"E", "ė"=>"e", "Ę"=>"E", "ę"=>"e", + "Ě"=>"E", "ě"=>"e", "Ĝ"=>"G", "ĝ"=>"g", "Ğ"=>"G", "ğ"=>"g", "Ġ"=>"G", + "ġ"=>"g", "Ģ"=>"G", "ģ"=>"g", "Ĥ"=>"H", "ĥ"=>"h", "Ħ"=>"H", "ħ"=>"h", + "Ĩ"=>"I", "ĩ"=>"i", "Ī"=>"I", "ī"=>"i", "Ĭ"=>"I", "ĭ"=>"i", "Į"=>"I", + "į"=>"i", "İ"=>"I", "ı"=>"i", "IJ"=>"IJ", "ij"=>"ij", "Ĵ"=>"J", "ĵ"=>"j", + "Ķ"=>"K", "ķ"=>"k", "ĸ"=>"k", "Ĺ"=>"L", "ĺ"=>"l", "Ļ"=>"L", "ļ"=>"l", + "Ľ"=>"L", "ľ"=>"l", "Ŀ"=>"L", "ŀ"=>"l", "Ł"=>"L", "ł"=>"l", "Ń"=>"N", + "ń"=>"n", "Ņ"=>"N", "ņ"=>"n", "Ň"=>"N", "ň"=>"n", "ʼn"=>"'n", "Ŋ"=>"NG", + "ŋ"=>"ng", "Ō"=>"O", "ō"=>"o", "Ŏ"=>"O", "ŏ"=>"o", "Ő"=>"O", "ő"=>"o", + "Œ"=>"OE", "œ"=>"oe", "Ŕ"=>"R", "ŕ"=>"r", "Ŗ"=>"R", "ŗ"=>"r", "Ř"=>"R", + "ř"=>"r", "Ś"=>"S", "ś"=>"s", "Ŝ"=>"S", "ŝ"=>"s", "Ş"=>"S", "ş"=>"s", + "Š"=>"S", "š"=>"s", "Ţ"=>"T", "ţ"=>"t", "Ť"=>"T", "ť"=>"t", "Ŧ"=>"T", + "ŧ"=>"t", "Ũ"=>"U", "ũ"=>"u", "Ū"=>"U", "ū"=>"u", "Ŭ"=>"U", "ŭ"=>"u", + "Ů"=>"U", "ů"=>"u", "Ű"=>"U", "ű"=>"u", "Ų"=>"U", "ų"=>"u", "Ŵ"=>"W", + "ŵ"=>"w", "Ŷ"=>"Y", "ŷ"=>"y", "Ÿ"=>"Y", "Ź"=>"Z", "ź"=>"z", "Ż"=>"Z", + "ż"=>"z", "Ž"=>"Z", "ž"=>"z" + }.freeze + + def initialize(rule = nil) + @rule = rule + add_default_approximations + add rule if rule + end + + def transliterate(string, replacement = nil) + replacement ||= DEFAULT_REPLACEMENT_CHAR + string.gsub(/[^\x00-\x7f]/u) do |char| + approximations[char] || replacement + end + end + + private + + def approximations + @approximations ||= {} + end + + def add_default_approximations + DEFAULT_APPROXIMATIONS.each do |key, value| + approximations[key] = value + end + end + + # Add transliteration rules to the approximations hash. + def add(hash) + hash.each do |key, value| + approximations[key.to_s] = value.to_s + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/config.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/config.rb new file mode 100644 index 0000000..9878e02 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/config.rb @@ -0,0 +1,165 @@ +# frozen_string_literal: true + +require 'set' + +module I18n + class Config + # The only configuration value that is not global and scoped to thread is :locale. + # It defaults to the default_locale. + def locale + defined?(@locale) && @locale != nil ? @locale : default_locale + end + + # Sets the current locale pseudo-globally, i.e. in the Thread.current hash. + def locale=(locale) + I18n.enforce_available_locales!(locale) + @locale = locale && locale.to_sym + end + + # Returns the current backend. Defaults to +Backend::Simple+. + def backend + @@backend ||= Backend::Simple.new + end + + # Sets the current backend. Used to set a custom backend. + def backend=(backend) + @@backend = backend + end + + # Returns the current default locale. Defaults to :'en' + def default_locale + @@default_locale ||= :en + end + + # Sets the current default locale. Used to set a custom default locale. + def default_locale=(locale) + I18n.enforce_available_locales!(locale) + @@default_locale = locale && locale.to_sym + end + + # Returns an array of locales for which translations are available. + # Unless you explicitly set these through I18n.available_locales= + # the call will be delegated to the backend. + def available_locales + @@available_locales ||= nil + @@available_locales || backend.available_locales + end + + # Caches the available locales list as both strings and symbols in a Set, so + # that we can have faster lookups to do the available locales enforce check. + def available_locales_set #:nodoc: + @@available_locales_set ||= available_locales.inject(Set.new) do |set, locale| + set << locale.to_s << locale.to_sym + end + end + + # Sets the available locales. + def available_locales=(locales) + @@available_locales = Array(locales).map { |locale| locale.to_sym } + @@available_locales = nil if @@available_locales.empty? + @@available_locales_set = nil + end + + # Returns true if the available_locales have been initialized + def available_locales_initialized? + ( !!defined?(@@available_locales) && !!@@available_locales ) + end + + # Clears the available locales set so it can be recomputed again after I18n + # gets reloaded. + def clear_available_locales_set #:nodoc: + @@available_locales_set = nil + end + + # Returns the current default scope separator. Defaults to '.' + def default_separator + @@default_separator ||= '.' + end + + # Sets the current default scope separator. + def default_separator=(separator) + @@default_separator = separator + end + + # Returns the current exception handler. Defaults to an instance of + # I18n::ExceptionHandler. + def exception_handler + @@exception_handler ||= ExceptionHandler.new + end + + # Sets the exception handler. + def exception_handler=(exception_handler) + @@exception_handler = exception_handler + end + + # Returns the current handler for situations when interpolation argument + # is missing. MissingInterpolationArgument will be raised by default. + def missing_interpolation_argument_handler + @@missing_interpolation_argument_handler ||= lambda do |missing_key, provided_hash, string| + raise MissingInterpolationArgument.new(missing_key, provided_hash, string) + end + end + + # Sets the missing interpolation argument handler. It can be any + # object that responds to #call. The arguments that will be passed to #call + # are the same as for MissingInterpolationArgument initializer. Use +Proc.new+ + # if you don't care about arity. + # + # == Example: + # You can suppress raising an exception and return string instead: + # + # I18n.config.missing_interpolation_argument_handler = Proc.new do |key| + # "#{key} is missing" + # end + def missing_interpolation_argument_handler=(exception_handler) + @@missing_interpolation_argument_handler = exception_handler + end + + # Allow clients to register paths providing translation data sources. The + # backend defines acceptable sources. + # + # E.g. the provided SimpleBackend accepts a list of paths to translation + # files which are either named *.rb and contain plain Ruby Hashes or are + # named *.yml and contain YAML data. So for the SimpleBackend clients may + # register translation files like this: + # I18n.load_path << 'path/to/locale/en.yml' + def load_path + @@load_path ||= [] + end + + # Sets the load path instance. Custom implementations are expected to + # behave like a Ruby Array. + def load_path=(load_path) + @@load_path = load_path + @@available_locales_set = nil + backend.reload! + end + + # Whether or not to verify if locales are in the list of available locales. + # Defaults to true. + @@enforce_available_locales = true + def enforce_available_locales + @@enforce_available_locales + end + + def enforce_available_locales=(enforce_available_locales) + @@enforce_available_locales = enforce_available_locales + end + + # Returns the current interpolation patterns. Defaults to + # I18n::DEFAULT_INTERPOLATION_PATTERNS. + def interpolation_patterns + @@interpolation_patterns ||= I18n::DEFAULT_INTERPOLATION_PATTERNS.dup + end + + # Sets the current interpolation patterns. Used to set a interpolation + # patterns. + # + # E.g. using {{}} as a placeholder like "{{hello}}, world!": + # + # I18n.config.interpolation_patterns << /\{\{(\w+)\}\}/ + def interpolation_patterns=(interpolation_patterns) + @@interpolation_patterns = interpolation_patterns + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/exceptions.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/exceptions.rb new file mode 100644 index 0000000..23ca46e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/exceptions.rb @@ -0,0 +1,157 @@ +# frozen_string_literal: true + +require 'cgi' + +module I18n + class ExceptionHandler + def call(exception, _locale, _key, _options) + if exception.is_a?(MissingTranslation) + exception.message + else + raise exception + end + end + end + + class ArgumentError < ::ArgumentError; end + + class Disabled < ArgumentError + def initialize(method) + super(<<~MESSAGE) + I18n.#{method} is currently disabled, likely because your application is still in its loading phase. + + This method is meant to display text in the user locale, so calling it before the user locale has + been set is likely to display text from the wrong locale to some users. + + If you have a legitimate reason to access i18n data outside of the user flow, you can do so by passing + the desired locale explicitly with the `locale` argument, e.g. `I18n.#{method}(..., locale: :en)` + MESSAGE + end + end + + class InvalidLocale < ArgumentError + attr_reader :locale + def initialize(locale) + @locale = locale + super "#{locale.inspect} is not a valid locale" + end + end + + class InvalidLocaleData < ArgumentError + attr_reader :filename + def initialize(filename, exception_message) + @filename, @exception_message = filename, exception_message + super "can not load translations from #{filename}: #{exception_message}" + end + end + + class MissingTranslation < ArgumentError + module Base + PERMITTED_KEYS = [:scope, :default].freeze + + attr_reader :locale, :key, :options + + def initialize(locale, key, options = EMPTY_HASH) + @key, @locale, @options = key, locale, options.slice(*PERMITTED_KEYS) + options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) } + end + + def keys + @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys| + keys << 'no key' if keys.size < 2 + end + end + + def message + if (default = options[:default]).is_a?(Array) && default.any? + other_options = ([key, *default]).map { |k| normalized_option(k).prepend('- ') }.join("\n") + "Translation missing. Options considered were:\n#{other_options}" + else + "Translation missing: #{keys.join('.')}" + end + end + + def normalized_option(key) + I18n.normalize_keys(locale, key, options[:scope]).join('.') + end + + alias :to_s :message + + def to_exception + MissingTranslationData.new(locale, key, options) + end + end + + include Base + end + + class MissingTranslationData < ArgumentError + include MissingTranslation::Base + end + + class InvalidPluralizationData < ArgumentError + attr_reader :entry, :count, :key + def initialize(entry, count, key) + @entry, @count, @key = entry, count, key + super "translation data #{entry.inspect} can not be used with :count => #{count}. key '#{key}' is missing." + end + end + + class MissingInterpolationArgument < ArgumentError + attr_reader :key, :values, :string + def initialize(key, values, string) + @key, @values, @string = key, values, string + super "missing interpolation argument #{key.inspect} in #{string.inspect} (#{values.inspect} given)" + end + end + + class ReservedInterpolationKey < ArgumentError + attr_reader :key, :string + def initialize(key, string) + @key, @string = key, string + super "reserved key #{key.inspect} used in #{string.inspect}" + end + end + + class UnknownFileType < ArgumentError + attr_reader :type, :filename + def initialize(type, filename) + @type, @filename = type, filename + super "can not load translations from #{filename}, the file type #{type} is not known" + end + end + + class UnsupportedMethod < ArgumentError + attr_reader :method, :backend_klass, :msg + def initialize(method, backend_klass, msg) + @method = method + @backend_klass = backend_klass + @msg = msg + super "#{backend_klass} does not support the ##{method} method. #{msg}" + end + end + + class InvalidFilenames < ArgumentError + NUMBER_OF_ERRORS_SHOWN = 20 + def initialize(file_errors) + super <<~MSG + Found #{file_errors.count} error(s). + The first #{[file_errors.count, NUMBER_OF_ERRORS_SHOWN].min} error(s): + #{file_errors.map(&:message).first(NUMBER_OF_ERRORS_SHOWN).join("\n")} + + To use the LazyLoadable backend: + 1. Filenames must start with the locale. + 2. An underscore must separate the locale with any optional text that follows. + 3. The file must only contain translation data for the single locale. + + Example: + "/config/locales/fr.yml" which contains: + ```yml + fr: + dog: + chien + ``` + MSG + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext.rb new file mode 100644 index 0000000..858daff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module I18n + module Gettext + PLURAL_SEPARATOR = "\001" + CONTEXT_SEPARATOR = "\004" + + autoload :Helpers, 'i18n/gettext/helpers' + + @@plural_keys = { :en => [:one, :other] } + + class << self + # returns an array of plural keys for the given locale or the whole hash + # of locale mappings to plural keys so that we can convert from gettext's + # integer-index based style + # TODO move this information to the pluralization module + def plural_keys(*args) + args.empty? ? @@plural_keys : @@plural_keys[args.first] || @@plural_keys[:en] + end + + def extract_scope(msgid, separator) + scope = msgid.to_s.split(separator) + msgid = scope.pop + [scope, msgid] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext/helpers.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext/helpers.rb new file mode 100644 index 0000000..d077619 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext/helpers.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +require 'i18n/gettext' + +module I18n + module Gettext + # Implements classical Gettext style accessors. To use this include the + # module to the global namespace or wherever you want to use it. + # + # include I18n::Gettext::Helpers + module Helpers + # Makes dynamic translation messages readable for the gettext parser. + # _(fruit) cannot be understood by the gettext parser. To help the parser find all your translations, + # you can add fruit = N_("Apple") which does not translate, but tells the parser: "Apple" needs translation. + # * msgid: the message id. + # * Returns: msgid. + def N_(msgsid) + msgsid + end + + def gettext(msgid, options = EMPTY_HASH) + I18n.t(msgid, **{:default => msgid, :separator => '|'}.merge(options)) + end + alias _ gettext + + def sgettext(msgid, separator = '|') + scope, msgid = I18n::Gettext.extract_scope(msgid, separator) + I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator) + end + alias s_ sgettext + + def pgettext(msgctxt, msgid) + separator = I18n::Gettext::CONTEXT_SEPARATOR + sgettext([msgctxt, msgid].join(separator), separator) + end + alias p_ pgettext + + def ngettext(msgid, msgid_plural, n = 1) + nsgettext(msgid, msgid_plural, n) + end + alias n_ ngettext + + # Method signatures: + # nsgettext('Fruits|apple', 'apples', 2) + # nsgettext(['Fruits|apple', 'apples'], 2) + def nsgettext(msgid, msgid_plural, n = 1, separator = '|') + if msgid.is_a?(Array) + msgid, msgid_plural, n, separator = msgid[0], msgid[1], msgid_plural, n + separator = '|' unless separator.is_a?(::String) + end + + scope, msgid = I18n::Gettext.extract_scope(msgid, separator) + default = { :one => msgid, :other => msgid_plural } + I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator) + end + alias ns_ nsgettext + + # Method signatures: + # npgettext('Fruits', 'apple', 'apples', 2) + # npgettext('Fruits', ['apple', 'apples'], 2) + def npgettext(msgctxt, msgid, msgid_plural, n = 1) + separator = I18n::Gettext::CONTEXT_SEPARATOR + + if msgid.is_a?(Array) + msgid_plural, msgid, n = msgid[1], [msgctxt, msgid[0]].join(separator), msgid_plural + else + msgid = [msgctxt, msgid].join(separator) + end + + nsgettext(msgid, msgid_plural, n, separator) + end + alias np_ npgettext + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext/po_parser.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext/po_parser.rb new file mode 100644 index 0000000..a07fdc5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/gettext/po_parser.rb @@ -0,0 +1,329 @@ +=begin + poparser.rb - Generate a .mo + + Copyright (C) 2003-2009 Masao Mutoh + + You may redistribute it and/or modify it under the same + license terms as Ruby. +=end + +#MODIFIED +# removed include GetText etc +# added stub translation method _(x) +require 'racc/parser' + +module GetText + + class PoParser < Racc::Parser + + def _(x) + x + end + +module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry', 108 + def unescape(orig) + ret = orig.gsub(/\\n/, "\n") + ret.gsub!(/\\t/, "\t") + ret.gsub!(/\\r/, "\r") + ret.gsub!(/\\"/, "\"") + ret + end + + def parse(str, data, ignore_fuzzy = true) + @comments = [] + @data = data + @fuzzy = false + @msgctxt = "" + $ignore_fuzzy = ignore_fuzzy + + str.strip! + @q = [] + until str.empty? do + case str + when /\A\s+/ + str = $' + when /\Amsgctxt/ + @q.push [:MSGCTXT, $&] + str = $' + when /\Amsgid_plural/ + @q.push [:MSGID_PLURAL, $&] + str = $' + when /\Amsgid/ + @q.push [:MSGID, $&] + str = $' + when /\Amsgstr/ + @q.push [:MSGSTR, $&] + str = $' + when /\A\[(\d+)\]/ + @q.push [:PLURAL_NUM, $1] + str = $' + when /\A\#~(.*)/ + $stderr.print _("Warning: obsolete msgid exists.\n") + $stderr.print " #{$&}\n" + @q.push [:COMMENT, $&] + str = $' + when /\A\#(.*)/ + @q.push [:COMMENT, $&] + str = $' + when /\A\"(.*)\"/ + @q.push [:STRING, $1] + str = $' + else + #c = str[0,1] + #@q.push [:STRING, c] + str = str[1..-1] + end + end + @q.push [false, '$end'] + if $DEBUG + @q.each do |a,b| + puts "[#{a}, #{b}]" + end + end + @yydebug = true if $DEBUG + do_parse + + if @comments.size > 0 + @data.set_comment(:last, @comments.join("\n")) + end + @data + end + + def next_token + @q.shift + end + + def on_message(msgid, msgstr) + if msgstr.size > 0 + @data[msgid] = msgstr + @data.set_comment(msgid, @comments.join("\n")) + end + @comments.clear + @msgctxt = "" + end + + def on_comment(comment) + @fuzzy = true if (/fuzzy/ =~ comment) + @comments << comment + end + + +..end src/poparser.ry modeval..id7a99570e05 + +##### racc 1.4.5 generates ### + +racc_reduce_table = [ + 0, 0, :racc_error, + 0, 10, :_reduce_none, + 2, 10, :_reduce_none, + 2, 10, :_reduce_none, + 2, 10, :_reduce_none, + 2, 12, :_reduce_5, + 1, 13, :_reduce_none, + 1, 13, :_reduce_none, + 4, 15, :_reduce_8, + 5, 16, :_reduce_9, + 2, 17, :_reduce_10, + 1, 17, :_reduce_none, + 3, 18, :_reduce_12, + 1, 11, :_reduce_13, + 2, 14, :_reduce_14, + 1, 14, :_reduce_15 ] + +racc_reduce_n = 16 + +racc_shift_n = 26 + +racc_action_table = [ + 3, 13, 5, 7, 9, 15, 16, 17, 20, 17, + 13, 17, 13, 13, 11, 17, 23, 20, 13, 17 ] + +racc_action_check = [ + 1, 16, 1, 1, 1, 12, 12, 12, 18, 18, + 7, 14, 15, 9, 3, 19, 20, 21, 23, 25 ] + +racc_action_pointer = [ + nil, 0, nil, 14, nil, nil, nil, 3, nil, 6, + nil, nil, 0, nil, 4, 5, -6, nil, 2, 8, + 8, 11, nil, 11, nil, 12 ] + +racc_action_default = [ + -1, -16, -2, -16, -3, -13, -4, -16, -6, -16, + -7, 26, -16, -15, -5, -16, -16, -14, -16, -8, + -16, -9, -11, -16, -10, -12 ] + +racc_goto_table = [ + 12, 22, 14, 4, 24, 6, 2, 8, 18, 19, + 10, 21, 1, nil, nil, nil, 25 ] + +racc_goto_check = [ + 5, 9, 5, 3, 9, 4, 2, 6, 5, 5, + 7, 8, 1, nil, nil, nil, 5 ] + +racc_goto_pointer = [ + nil, 12, 5, 2, 4, -7, 6, 9, -7, -17 ] + +racc_goto_default = [ + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ] + +racc_token_table = { + false => 0, + Object.new => 1, + :COMMENT => 2, + :MSGID => 3, + :MSGCTXT => 4, + :MSGID_PLURAL => 5, + :MSGSTR => 6, + :STRING => 7, + :PLURAL_NUM => 8 } + +racc_use_result_var = true + +racc_nt_base = 9 + +Racc_arg = [ + racc_action_table, + racc_action_check, + racc_action_default, + racc_action_pointer, + racc_goto_table, + racc_goto_check, + racc_goto_default, + racc_goto_pointer, + racc_nt_base, + racc_reduce_table, + racc_token_table, + racc_shift_n, + racc_reduce_n, + racc_use_result_var ] + +Racc_token_to_s_table = [ +'$end', +'error', +'COMMENT', +'MSGID', +'MSGCTXT', +'MSGID_PLURAL', +'MSGSTR', +'STRING', +'PLURAL_NUM', +'$start', +'msgfmt', +'comment', +'msgctxt', +'message', +'string_list', +'single_message', +'plural_message', +'msgstr_plural', +'msgstr_plural_line'] + +Racc_debug_parser = true + +##### racc system variables end ##### + + # reduce 0 omitted + + # reduce 1 omitted + + # reduce 2 omitted + + # reduce 3 omitted + + # reduce 4 omitted + +module_eval <<'.,.,', 'src/poparser.ry', 25 + def _reduce_5( val, _values, result ) + @msgctxt = unescape(val[1]) + "\004" + result + end +.,., + + # reduce 6 omitted + + # reduce 7 omitted + +module_eval <<'.,.,', 'src/poparser.ry', 48 + def _reduce_8( val, _values, result ) + if @fuzzy and $ignore_fuzzy + if val[1] != "" + $stderr.print _("Warning: fuzzy message was ignored.\n") + $stderr.print " msgid '#{val[1]}'\n" + else + on_message('', unescape(val[3])) + end + @fuzzy = false + else + on_message(@msgctxt + unescape(val[1]), unescape(val[3])) + end + result = "" + result + end +.,., + +module_eval <<'.,.,', 'src/poparser.ry', 65 + def _reduce_9( val, _values, result ) + if @fuzzy and $ignore_fuzzy + if val[1] != "" + $stderr.print _("Warning: fuzzy message was ignored.\n") + $stderr.print "msgid = '#{val[1]}\n" + else + on_message('', unescape(val[3])) + end + @fuzzy = false + else + on_message(@msgctxt + unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4])) + end + result = "" + result + end +.,., + +module_eval <<'.,.,', 'src/poparser.ry', 76 + def _reduce_10( val, _values, result ) + if val[0].size > 0 + result = val[0] + "\000" + val[1] + else + result = "" + end + result + end +.,., + + # reduce 11 omitted + +module_eval <<'.,.,', 'src/poparser.ry', 84 + def _reduce_12( val, _values, result ) + result = val[2] + result + end +.,., + +module_eval <<'.,.,', 'src/poparser.ry', 91 + def _reduce_13( val, _values, result ) + on_comment(val[0]) + result + end +.,., + +module_eval <<'.,.,', 'src/poparser.ry', 99 + def _reduce_14( val, _values, result ) + result = val.delete_if{|item| item == ""}.join + result + end +.,., + +module_eval <<'.,.,', 'src/poparser.ry', 103 + def _reduce_15( val, _values, result ) + result = val[0] + result + end +.,., + + def _reduce_none( val, _values, result ) + result + end + + end # class PoParser + +end # module GetText diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/interpolate/ruby.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/interpolate/ruby.rb new file mode 100644 index 0000000..5b50593 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/interpolate/ruby.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +# heavily based on Masao Mutoh's gettext String interpolation extension +# http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb + +module I18n + DEFAULT_INTERPOLATION_PATTERNS = [ + /%%/, + /%\{([\w|]+)\}/, # matches placeholders like "%{foo} or %{foo|word}" + /%<(\w+)>([^\d]*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%.d" + ].freeze + INTERPOLATION_PATTERN = Regexp.union(DEFAULT_INTERPOLATION_PATTERNS) + deprecate_constant :INTERPOLATION_PATTERN + + INTERPOLATION_PATTERNS_CACHE = Hash.new do |hash, patterns| + hash[patterns] = Regexp.union(patterns) + end + private_constant :INTERPOLATION_PATTERNS_CACHE + + class << self + # Return String or raises MissingInterpolationArgument exception. + # Missing argument's logic is handled by I18n.config.missing_interpolation_argument_handler. + def interpolate(string, values) + raise ReservedInterpolationKey.new($1.to_sym, string) if string =~ I18n.reserved_keys_pattern + raise ArgumentError.new('Interpolation values must be a Hash.') unless values.kind_of?(Hash) + interpolate_hash(string, values) + end + + def interpolate_hash(string, values) + pattern = INTERPOLATION_PATTERNS_CACHE[config.interpolation_patterns] + interpolated = false + + interpolated_string = string.gsub(pattern) do |match| + interpolated = true + + if match == '%%' + '%' + else + key = ($1 || $2 || match.tr("%{}", "")).to_sym + value = if values.key?(key) + values[key] + else + config.missing_interpolation_argument_handler.call(key, values, string) + end + value = value.call(values) if value.respond_to?(:call) + $3 ? sprintf("%#{$3}", value) : value + end + end + + interpolated ? interpolated_string : string + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale.rb new file mode 100644 index 0000000..c4078e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module I18n + module Locale + autoload :Fallbacks, 'i18n/locale/fallbacks' + autoload :Tag, 'i18n/locale/tag' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/fallbacks.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/fallbacks.rb new file mode 100644 index 0000000..56d08d7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/fallbacks.rb @@ -0,0 +1,107 @@ +# Locale Fallbacks +# +# Extends the I18n module to hold a fallbacks instance which is set to an +# instance of I18n::Locale::Fallbacks by default but can be swapped with a +# different implementation. +# +# Locale fallbacks will compute a number of fallback locales for a given locale. +# For example: +# +#

+# I18n.fallbacks[:"es-MX"] # => [:"es-MX", :es, :en] 
+# +# Locale fallbacks always fall back to +# +# * all parent locales of a given locale (e.g. :es for :"es-MX") first, +# * the current default locales and all of their parents second +# +# The default locales are set to [] by default but can be set to something else. +# +# One can additionally add any number of additional fallback locales manually. +# These will be added before the default locales to the fallback chain. For +# example: +# +# # using a custom locale as default fallback locale +# +# I18n.fallbacks = I18n::Locale::Fallbacks.new(:"en-GB", :"de-AT" => :de, :"de-CH" => :de) +# I18n.fallbacks[:"de-AT"] # => [:"de-AT", :de, :"en-GB", :en] +# I18n.fallbacks[:"de-CH"] # => [:"de-CH", :de, :"en-GB", :en] +# +# # mapping fallbacks to an existing instance +# +# # people speaking Catalan also speak Spanish as spoken in Spain +# fallbacks = I18n.fallbacks +# fallbacks.map(:ca => :"es-ES") +# fallbacks[:ca] # => [:ca, :"es-ES", :es, :"en-US", :en] +# +# # people speaking Arabian as spoken in Palestine also speak Hebrew as spoken in Israel +# fallbacks.map(:"ar-PS" => :"he-IL") +# fallbacks[:"ar-PS"] # => [:"ar-PS", :ar, :"he-IL", :he, :"en-US", :en] +# fallbacks[:"ar-EG"] # => [:"ar-EG", :ar, :"en-US", :en] +# +# # people speaking Sami as spoken in Finland also speak Swedish and Finnish as spoken in Finland +# fallbacks.map(:sms => [:"se-FI", :"fi-FI"]) +# fallbacks[:sms] # => [:sms, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en] + +module I18n + module Locale + class Fallbacks < Hash + def initialize(*mappings) + @map = {} + map(mappings.pop) if mappings.last.is_a?(Hash) + self.defaults = mappings.empty? ? [] : mappings + end + + def defaults=(defaults) + @defaults = defaults.flat_map { |default| compute(default, false) } + end + attr_reader :defaults + + def [](locale) + raise InvalidLocale.new(locale) if locale.nil? + raise Disabled.new('fallback#[]') if locale == false + locale = locale.to_sym + super || store(locale, compute(locale)) + end + + def map(*args, &block) + if args.count == 1 && !block_given? + mappings = args.first + mappings.each do |from, to| + from, to = from.to_sym, Array(to) + to.each do |_to| + @map[from] ||= [] + @map[from] << _to.to_sym + end + end + else + @map.map(*args, &block) + end + end + + def empty? + @map.empty? && @defaults.empty? + end + + def inspect + "#<#{self.class.name} @map=#{@map.inspect} @defaults=#{@defaults.inspect}>" + end + + protected + + def compute(tags, include_defaults = true, exclude = []) + result = [] + Array(tags).each do |tag| + tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym } - exclude + result += tags + tags.each { |_tag| result += compute(@map[_tag], false, exclude + result) if @map[_tag] } + end + + result.push(*defaults) if include_defaults + result.uniq! + result.compact! + result + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag.rb new file mode 100644 index 0000000..a640b44 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag.rb @@ -0,0 +1,28 @@ +# encoding: utf-8 + +module I18n + module Locale + module Tag + autoload :Parents, 'i18n/locale/tag/parents' + autoload :Rfc4646, 'i18n/locale/tag/rfc4646' + autoload :Simple, 'i18n/locale/tag/simple' + + class << self + # Returns the current locale tag implementation. Defaults to +I18n::Locale::Tag::Simple+. + def implementation + @@implementation ||= Simple + end + + # Sets the current locale tag implementation. Use this to set a different locale tag implementation. + def implementation=(implementation) + @@implementation = implementation + end + + # Factory method for locale tags. Delegates to the current locale tag implementation. + def tag(tag) + implementation.tag(tag) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/parents.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/parents.rb new file mode 100644 index 0000000..6283e66 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/parents.rb @@ -0,0 +1,24 @@ +module I18n + module Locale + module Tag + module Parents + def parent + @parent ||= + begin + segs = to_a + segs.compact! + segs.length > 1 ? self.class.tag(*segs[0..(segs.length - 2)].join('-')) : nil + end + end + + def self_and_parents + @self_and_parents ||= [self].concat parents + end + + def parents + @parents ||= parent ? [parent].concat(parent.parents) : [] + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/rfc4646.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/rfc4646.rb new file mode 100644 index 0000000..4ce4c75 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/rfc4646.rb @@ -0,0 +1,74 @@ +# RFC 4646/47 compliant Locale tag implementation that parses locale tags to +# subtags such as language, script, region, variant etc. +# +# For more information see by http://en.wikipedia.org/wiki/IETF_language_tag +# +# Rfc4646::Parser does not implement grandfathered tags. + +module I18n + module Locale + module Tag + RFC4646_SUBTAGS = [ :language, :script, :region, :variant, :extension, :privateuse, :grandfathered ] + RFC4646_FORMATS = { :language => :downcase, :script => :capitalize, :region => :upcase, :variant => :downcase } + + class Rfc4646 < Struct.new(*RFC4646_SUBTAGS) + class << self + # Parses the given tag and returns a Tag instance if it is valid. + # Returns false if the given tag is not valid according to RFC 4646. + def tag(tag) + matches = parser.match(tag) + new(*matches) if matches + end + + def parser + @@parser ||= Rfc4646::Parser + end + + def parser=(parser) + @@parser = parser + end + end + + include Parents + + RFC4646_FORMATS.each do |name, format| + define_method(name) { self[name].send(format) unless self[name].nil? } + end + + def to_sym + to_s.to_sym + end + + def to_s + @tag ||= to_a.compact.join("-") + end + + def to_a + members.collect { |attr| self.send(attr) } + end + + module Parser + PATTERN = %r{\A(?: + ([a-z]{2,3}(?:(?:-[a-z]{3}){0,3})?|[a-z]{4}|[a-z]{5,8}) # language + (?:-([a-z]{4}))? # script + (?:-([a-z]{2}|\d{3}))? # region + (?:-([0-9a-z]{5,8}|\d[0-9a-z]{3}))* # variant + (?:-([0-9a-wyz](?:-[0-9a-z]{2,8})+))* # extension + (?:-(x(?:-[0-9a-z]{1,8})+))?| # privateuse subtag + (x(?:-[0-9a-z]{1,8})+)| # privateuse tag + /* ([a-z]{1,3}(?:-[0-9a-z]{2,8}){1,2}) */ # grandfathered + )\z}xi + + class << self + def match(tag) + c = PATTERN.match(tag.to_s).captures + c[0..4] << (c[5].nil? ? c[6] : c[5]) << c[7] # TODO c[7] is grandfathered, throw a NotImplemented exception here? + rescue + false + end + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/simple.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/simple.rb new file mode 100644 index 0000000..18d55c2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/locale/tag/simple.rb @@ -0,0 +1,39 @@ +# Simple Locale tag implementation that computes subtags by simply splitting +# the locale tag at '-' occurrences. +module I18n + module Locale + module Tag + class Simple + class << self + def tag(tag) + new(tag) + end + end + + include Parents + + attr_reader :tag + + def initialize(*tag) + @tag = tag.join('-').to_sym + end + + def subtags + @subtags = tag.to_s.split('-').map!(&:to_s) + end + + def to_sym + tag + end + + def to_s + tag.to_s + end + + def to_a + subtags + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/middleware.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/middleware.rb new file mode 100644 index 0000000..59b377e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/middleware.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module I18n + class Middleware + + def initialize(app) + @app = app + end + + def call(env) + @app.call(env) + ensure + Thread.current[:i18n_config] = I18n::Config.new + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests.rb new file mode 100644 index 0000000..30d0ed5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module I18n + module Tests + autoload :Basics, 'i18n/tests/basics' + autoload :Defaults, 'i18n/tests/defaults' + autoload :Interpolation, 'i18n/tests/interpolation' + autoload :Link, 'i18n/tests/link' + autoload :Localization, 'i18n/tests/localization' + autoload :Lookup, 'i18n/tests/lookup' + autoload :Pluralization, 'i18n/tests/pluralization' + autoload :Procs, 'i18n/tests/procs' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/basics.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/basics.rb new file mode 100644 index 0000000..833762b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/basics.rb @@ -0,0 +1,58 @@ +module I18n + module Tests + module Basics + def teardown + I18n.available_locales = nil + end + + test "available_locales returns the available_locales produced by the backend, by default" do + I18n.backend.store_translations('de', :foo => 'bar') + I18n.backend.store_translations('en', :foo => 'foo') + + assert_equal I18n.available_locales, I18n.backend.available_locales + end + + test "available_locales can be set to something else independently from the actual locale data" do + I18n.backend.store_translations('de', :foo => 'bar') + I18n.backend.store_translations('en', :foo => 'foo') + + I18n.available_locales = :foo + assert_equal [:foo], I18n.available_locales + + I18n.available_locales = [:foo, 'bar'] + assert_equal [:foo, :bar], I18n.available_locales + + I18n.available_locales = nil + assert_equal I18n.available_locales, I18n.backend.available_locales + end + + test "available_locales memoizes when set explicitly" do + I18n.backend.expects(:available_locales).never + I18n.available_locales = [:foo] + I18n.backend.store_translations('de', :bar => 'baz') + I18n.reload! + assert_equal [:foo], I18n.available_locales + end + + test "available_locales delegates to the backend when not set explicitly" do + original_available_locales_value = I18n.backend.available_locales + I18n.backend.expects(:available_locales).returns(original_available_locales_value).twice + assert_equal I18n.backend.available_locales, I18n.available_locales + end + + test "exists? is implemented by the backend" do + I18n.backend.store_translations(:foo, :bar => 'baz') + assert I18n.exists?(:bar, :foo) + end + + test "storing a nil value as a translation removes it from the available locale data" do + I18n.backend.store_translations(:en, :to_be_deleted => 'bar') + assert_equal 'bar', I18n.t(:to_be_deleted, :default => 'baz') + + I18n.cache_store.clear if I18n.respond_to?(:cache_store) && I18n.cache_store + I18n.backend.store_translations(:en, :to_be_deleted => nil) + assert_equal 'baz', I18n.t(:to_be_deleted, :default => 'baz') + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/defaults.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/defaults.rb new file mode 100644 index 0000000..31fdb46 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/defaults.rb @@ -0,0 +1,52 @@ +# encoding: utf-8 + +module I18n + module Tests + module Defaults + def setup + super + I18n.backend.store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' }) + end + + test "defaults: given nil as a key it returns the given default" do + assert_equal 'default', I18n.t(nil, :default => 'default') + end + + test "defaults: given a symbol as a default it translates the symbol" do + assert_equal 'bar', I18n.t(nil, :default => :'foo.bar') + end + + test "defaults: given a symbol as a default and a scope it stays inside the scope when looking up the symbol" do + assert_equal 'bar', I18n.t(:missing, :default => :bar, :scope => :foo) + end + + test "defaults: given an array as a default it returns the first match" do + assert_equal 'bar', I18n.t(:does_not_exist, :default => [:does_not_exist_2, :'foo.bar']) + end + + test "defaults: given an array as a default with false it returns false" do + assert_equal false, I18n.t(:does_not_exist, :default => [false]) + end + + test "defaults: given false it returns false" do + assert_equal false, I18n.t(:does_not_exist, :default => false) + end + + test "defaults: given nil it returns nil" do + assert_nil I18n.t(:does_not_exist, :default => nil) + end + + test "defaults: given an array of missing keys it raises a MissingTranslationData exception" do + assert_raises I18n::MissingTranslationData do + I18n.t(:does_not_exist, :default => [:does_not_exist_2, :does_not_exist_3], :raise => true) + end + end + + test "defaults: using a custom scope separator" do + # data must have been stored using the custom separator when using the ActiveRecord backend + I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' }) + assert_equal 'bar', I18n.t(nil, :default => :'foo|bar', :separator => '|') + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/interpolation.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/interpolation.rb new file mode 100644 index 0000000..03c67db --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/interpolation.rb @@ -0,0 +1,185 @@ +# encoding: utf-8 + +module I18n + module Tests + module Interpolation + # If no interpolation parameter is not given, I18n should not alter the string. + # This behavior is due to three reasons: + # + # * Checking interpolation keys in all strings hits performance, badly; + # + # * This allows us to retrieve untouched values through I18n. For example + # I could have a middleware that returns I18n lookup results in JSON + # to be processed through Javascript. Leaving the keys untouched allows + # the interpolation to happen at the javascript level; + # + # * Security concerns: if I allow users to translate a web site, they can + # insert %{} in messages causing the I18n lookup to fail in every request. + # + test "interpolation: given no values it does not alter the string" do + assert_equal 'Hi %{name}!', interpolate(:default => 'Hi %{name}!') + end + + test "interpolation: given values it interpolates them into the string" do + assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => 'David') + end + + test "interpolation: works with a pipe" do + assert_equal 'Hi david!', interpolate(:default => 'Hi %{name|lowercase}!', :'name|lowercase' => 'david') + end + + test "interpolation: given a nil value it still interpolates it into the string" do + assert_equal 'Hi !', interpolate(:default => 'Hi %{name}!', :name => nil) + end + + test "interpolation: given a lambda as a value it calls it if the string contains the key" do + assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => lambda { |*args| 'David' }) + end + + test "interpolation: given a lambda as a value it does not call it if the string does not contain the key" do + assert_nothing_raised { interpolate(:default => 'Hi!', :name => lambda { |*args| raise 'fail' }) } + end + + test "interpolation: given values but missing a key it raises I18n::MissingInterpolationArgument" do + assert_raises(I18n::MissingInterpolationArgument) do + interpolate(:default => '%{foo}', :bar => 'bar') + end + end + + test "interpolation: it does not raise I18n::MissingInterpolationArgument for escaped variables" do + assert_nothing_raised do + assert_equal 'Barr %{foo}', interpolate(:default => '%{bar} %%{foo}', :bar => 'Barr') + end + end + + test "interpolation: it does not change the original, stored translation string" do + I18n.backend.store_translations(:en, :interpolate => 'Hi %{name}!') + assert_equal 'Hi David!', interpolate(:interpolate, :name => 'David') + assert_equal 'Hi Yehuda!', interpolate(:interpolate, :name => 'Yehuda') + end + + test "interpolation: given an array interpolates each element" do + I18n.backend.store_translations(:en, :array_interpolate => ['Hi', 'Mr. %{name}', 'or sir %{name}']) + assert_equal ['Hi', 'Mr. Bartuz', 'or sir Bartuz'], interpolate(:array_interpolate, :name => 'Bartuz') + end + + test "interpolation: given the translation is in utf-8 it still works" do + assert_equal 'Häi David!', interpolate(:default => 'Häi %{name}!', :name => 'David') + end + + test "interpolation: given the value is in utf-8 it still works" do + assert_equal 'Hi ゆきひろ!', interpolate(:default => 'Hi %{name}!', :name => 'ゆきひろ') + end + + test "interpolation: given the translation and the value are in utf-8 it still works" do + assert_equal 'こんにちは、ゆきひろさん!', interpolate(:default => 'こんにちは、%{name}さん!', :name => 'ゆきひろ') + end + + if Object.const_defined?(:Encoding) + test "interpolation: given a euc-jp translation and a utf-8 value it raises Encoding::CompatibilityError" do + assert_raises(Encoding::CompatibilityError) do + interpolate(:default => euc_jp('こんにちは、%{name}さん!'), :name => 'ゆきひろ') + end + end + + test "interpolation: given a utf-8 translation and a euc-jp value it raises Encoding::CompatibilityError" do + assert_raises(Encoding::CompatibilityError) do + interpolate(:default => 'こんにちは、%{name}さん!', :name => euc_jp('ゆきひろ')) + end + end + + test "interpolation: ASCII strings in the backend should be encoded to UTF8 if interpolation options are in UTF8" do + I18n.backend.store_translations 'en', 'encoding' => ('%{who} let me go'.force_encoding("ASCII")) + result = I18n.t 'encoding', :who => "måmmå miå" + assert_equal Encoding::UTF_8, result.encoding + end + + test "interpolation: UTF8 strings in the backend are still returned as UTF8 with ASCII interpolation" do + I18n.backend.store_translations 'en', 'encoding' => 'måmmå miå %{what}' + result = I18n.t 'encoding', :what => 'let me go'.force_encoding("ASCII") + assert_equal Encoding::UTF_8, result.encoding + end + + test "interpolation: UTF8 strings in the backend are still returned as UTF8 even with numbers interpolation" do + I18n.backend.store_translations 'en', 'encoding' => '%{count} times: måmmå miå' + result = I18n.t 'encoding', :count => 3 + assert_equal Encoding::UTF_8, result.encoding + end + end + + test "interpolation: given a translations containing a reserved key it raises I18n::ReservedInterpolationKey" do + assert_raises(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{exception_handler}') } + assert_raises(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{default}') } + assert_raises(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{separator}') } + assert_raises(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{scope}') } + assert_raises(I18n::ReservedInterpolationKey) { interpolate(:default => '%{scope}') } + + I18n.backend.store_translations(:en, :interpolate => 'Hi %{scope}!') + assert_raises(I18n::ReservedInterpolationKey) { interpolate(:interpolate) } + end + + test "interpolation: it does not raise I18n::ReservedInterpolationKey for escaped variables" do + assert_nothing_raised do + assert_equal '%{separator}', interpolate(:foo => :bar, :default => '%%{separator}') + end + + # Note: The two interpolations below do not remove the escape character (%) because + # I18n should not alter the strings when no interpolation parameters are given, + # see the comment at the top of this file. + assert_nothing_raised do + assert_equal '%%{scope}', interpolate(:default => '%%{scope}') + end + + I18n.backend.store_translations(:en, :interpolate => 'Hi %%{scope}!') + assert_nothing_raised do + assert_equal 'Hi %%{scope}!', interpolate(:interpolate) + end + end + + test "interpolation: deep interpolation for default string" do + assert_equal 'Hi %{name}!', interpolate(:default => 'Hi %{name}!', :deep_interpolation => true) + end + + test "interpolation: deep interpolation for interpolated string" do + assert_equal 'Hi Ann!', interpolate(:default => 'Hi %{name}!', :name => 'Ann', :deep_interpolation => true) + end + + test "interpolation: deep interpolation for Hash" do + people = { :people => { :ann => 'Ann is %{ann}', :john => 'John is %{john}' } } + interpolated_people = { :people => { :ann => 'Ann is good', :john => 'John is big' } } + assert_equal interpolated_people, interpolate(:default => people, :ann => 'good', :john => 'big', :deep_interpolation => true) + end + + test "interpolation: deep interpolation for Array" do + people = { :people => ['Ann is %{ann}', 'John is %{john}'] } + interpolated_people = { :people => ['Ann is good', 'John is big'] } + assert_equal interpolated_people, interpolate(:default => people, :ann => 'good', :john => 'big', :deep_interpolation => true) + end + + protected + + def capture(stream) + begin + stream = stream.to_s + eval "$#{stream} = StringIO.new" + yield + result = eval("$#{stream}").string + ensure + eval("$#{stream} = #{stream.upcase}") + end + + result + end + + def euc_jp(string) + string.encode!(Encoding::EUC_JP) + end + + def interpolate(*args) + options = args.last.is_a?(Hash) ? args.pop : {} + key = args.pop + I18n.backend.translate('en', key, options) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/link.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/link.rb new file mode 100644 index 0000000..d2f20e8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/link.rb @@ -0,0 +1,66 @@ +# encoding: utf-8 + +module I18n + module Tests + module Link + test "linked lookup: if a key resolves to a symbol it looks up the symbol" do + I18n.backend.store_translations 'en', { + :link => :linked, + :linked => 'linked' + } + assert_equal 'linked', I18n.backend.translate('en', :link) + end + + test "linked lookup: if a key resolves to a dot-separated symbol it looks up the symbol" do + I18n.backend.store_translations 'en', { + :link => :"foo.linked", + :foo => { :linked => 'linked' } + } + assert_equal('linked', I18n.backend.translate('en', :link)) + end + + test "linked lookup: if a dot-separated key resolves to a symbol it looks up the symbol" do + I18n.backend.store_translations 'en', { + :foo => { :link => :linked }, + :linked => 'linked' + } + assert_equal('linked', I18n.backend.translate('en', :'foo.link')) + end + + test "linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do + I18n.backend.store_translations 'en', { + :foo => { :link => :"bar.linked" }, + :bar => { :linked => 'linked' } + } + assert_equal('linked', I18n.backend.translate('en', :'foo.link')) + end + + test "linked lookup: links always refer to the absolute key" do + I18n.backend.store_translations 'en', { + :foo => { :link => :linked, :linked => 'linked in foo' }, + :linked => 'linked absolutely' + } + assert_equal 'linked absolutely', I18n.backend.translate('en', :link, :scope => :foo) + end + + test "linked lookup: a link can resolve to a namespace in the middle of a dot-separated key" do + I18n.backend.store_translations 'en', { + :activemodel => { :errors => { :messages => { :blank => "can't be blank" } } }, + :activerecord => { :errors => { :messages => :"activemodel.errors.messages" } } + } + assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank") + assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank") + end + + test "linked lookup: a link can resolve with option :count" do + I18n.backend.store_translations 'en', { + :counter => :counted, + :counted => { :foo => { :one => "one", :other => "other" }, :bar => "bar" } + } + assert_equal "one", I18n.t(:'counter.foo', count: 1) + assert_equal "other", I18n.t(:'counter.foo', count: 2) + assert_equal "bar", I18n.t(:'counter.bar', count: 3) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization.rb new file mode 100644 index 0000000..53b1502 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization.rb @@ -0,0 +1,19 @@ +module I18n + module Tests + module Localization + autoload :Date, 'i18n/tests/localization/date' + autoload :DateTime, 'i18n/tests/localization/date_time' + autoload :Time, 'i18n/tests/localization/time' + autoload :Procs, 'i18n/tests/localization/procs' + + def self.included(base) + base.class_eval do + include I18n::Tests::Localization::Date + include I18n::Tests::Localization::DateTime + include I18n::Tests::Localization::Procs + include I18n::Tests::Localization::Time + end + end + end + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/date.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/date.rb new file mode 100644 index 0000000..c21fbbf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/date.rb @@ -0,0 +1,122 @@ +# encoding: utf-8 + +module I18n + module Tests + module Localization + module Date + def setup + super + setup_date_translations + @date = ::Date.new(2008, 3, 1) + end + + test "localize Date: given the short format it uses it" do + assert_equal '01. Mär', I18n.l(@date, :format => :short, :locale => :de) + end + + test "localize Date: given the long format it uses it" do + assert_equal '01. März 2008', I18n.l(@date, :format => :long, :locale => :de) + end + + test "localize Date: given the default format it uses it" do + assert_equal '01.03.2008', I18n.l(@date, :format => :default, :locale => :de) + end + + test "localize Date: given a day name format it returns the correct day name" do + assert_equal 'Samstag', I18n.l(@date, :format => '%A', :locale => :de) + end + + test "localize Date: given a uppercased day name format it returns the correct day name in upcase" do + assert_equal 'samstag'.upcase, I18n.l(@date, :format => '%^A', :locale => :de) + end + + test "localize Date: given an abbreviated day name format it returns the correct abbreviated day name" do + assert_equal 'Sa', I18n.l(@date, :format => '%a', :locale => :de) + end + + test "localize Date: given an meridian indicator format it returns the correct meridian indicator" do + assert_equal 'AM', I18n.l(@date, :format => '%p', :locale => :de) + assert_equal 'am', I18n.l(@date, :format => '%P', :locale => :de) + end + + test "localize Date: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do + assert_equal 'sa'.upcase, I18n.l(@date, :format => '%^a', :locale => :de) + end + + test "localize Date: given a month name format it returns the correct month name" do + assert_equal 'März', I18n.l(@date, :format => '%B', :locale => :de) + end + + test "localize Date: given a uppercased month name format it returns the correct month name in upcase" do + assert_equal 'märz'.upcase, I18n.l(@date, :format => '%^B', :locale => :de) + end + + test "localize Date: given an abbreviated month name format it returns the correct abbreviated month name" do + assert_equal 'Mär', I18n.l(@date, :format => '%b', :locale => :de) + end + + test "localize Date: given an abbreviated and uppercased month name format it returns the correct abbreviated month name in upcase" do + assert_equal 'mär'.upcase, I18n.l(@date, :format => '%^b', :locale => :de) + end + + test "localize Date: given a date format with the month name upcased it returns the correct value" do + assert_equal '1. FEBRUAR 2008', I18n.l(::Date.new(2008, 2, 1), :format => "%-d. %^B %Y", :locale => :de) + end + + test "localize Date: given missing translations it returns the correct error message" do + assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@date, :format => '%b', :locale => :fr) + end + + test "localize Date: given an unknown format it does not fail" do + assert_nothing_raised { I18n.l(@date, :format => '%x') } + end + + test "localize Date: does not modify the options hash" do + options = { :format => '%b', :locale => :de } + assert_equal 'Mär', I18n.l(@date, **options) + assert_equal({ :format => '%b', :locale => :de }, options) + assert_nothing_raised { I18n.l(@date, **options.freeze) } + end + + test "localize Date: given nil with default value it returns default" do + assert_equal 'default', I18n.l(nil, :default => 'default') + end + + test "localize Date: given nil it raises I18n::ArgumentError" do + assert_raises(I18n::ArgumentError) { I18n.l(nil) } + end + + test "localize Date: given a plain Object it raises I18n::ArgumentError" do + assert_raises(I18n::ArgumentError) { I18n.l(Object.new) } + end + + test "localize Date: given a format is missing it raises I18n::MissingTranslationData" do + assert_raises(I18n::MissingTranslationData) { I18n.l(@date, :format => :missing) } + end + + test "localize Date: it does not alter the format string" do + assert_equal '01. Februar 2009', I18n.l(::Date.parse('2009-02-01'), :format => :long, :locale => :de) + assert_equal '01. Oktober 2009', I18n.l(::Date.parse('2009-10-01'), :format => :long, :locale => :de) + end + + protected + + def setup_date_translations + I18n.backend.store_translations :de, { + :date => { + :formats => { + :default => "%d.%m.%Y", + :short => "%d. %b", + :long => "%d. %B %Y", + }, + :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag), + :abbr_day_names => %w(So Mo Di Mi Do Fr Sa), + :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil), + :abbr_month_names => %w(Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil) + } + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/date_time.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/date_time.rb new file mode 100644 index 0000000..b5d3527 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/date_time.rb @@ -0,0 +1,103 @@ +# encoding: utf-8 + +module I18n + module Tests + module Localization + module DateTime + def setup + super + setup_datetime_translations + @datetime = ::DateTime.new(2008, 3, 1, 6) + @other_datetime = ::DateTime.new(2008, 3, 1, 18) + end + + test "localize DateTime: given the short format it uses it" do + assert_equal '01. Mär 06:00', I18n.l(@datetime, :format => :short, :locale => :de) + end + + test "localize DateTime: given the long format it uses it" do + assert_equal '01. März 2008 06:00', I18n.l(@datetime, :format => :long, :locale => :de) + end + + test "localize DateTime: given the default format it uses it" do + assert_equal 'Sa, 01. Mär 2008 06:00:00 +0000', I18n.l(@datetime, :format => :default, :locale => :de) + end + + test "localize DateTime: given a day name format it returns the correct day name" do + assert_equal 'Samstag', I18n.l(@datetime, :format => '%A', :locale => :de) + end + + test "localize DateTime: given a uppercased day name format it returns the correct day name in upcase" do + assert_equal 'samstag'.upcase, I18n.l(@datetime, :format => '%^A', :locale => :de) + end + + test "localize DateTime: given an abbreviated day name format it returns the correct abbreviated day name" do + assert_equal 'Sa', I18n.l(@datetime, :format => '%a', :locale => :de) + end + + test "localize DateTime: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do + assert_equal 'sa'.upcase, I18n.l(@datetime, :format => '%^a', :locale => :de) + end + + test "localize DateTime: given a month name format it returns the correct month name" do + assert_equal 'März', I18n.l(@datetime, :format => '%B', :locale => :de) + end + + test "localize DateTime: given a uppercased month name format it returns the correct month name in upcase" do + assert_equal 'märz'.upcase, I18n.l(@datetime, :format => '%^B', :locale => :de) + end + + test "localize DateTime: given an abbreviated month name format it returns the correct abbreviated month name" do + assert_equal 'Mär', I18n.l(@datetime, :format => '%b', :locale => :de) + end + + test "localize DateTime: given an abbreviated and uppercased month name format it returns the correct abbreviated month name in upcase" do + assert_equal 'mär'.upcase, I18n.l(@datetime, :format => '%^b', :locale => :de) + end + + test "localize DateTime: given a date format with the month name upcased it returns the correct value" do + assert_equal '1. FEBRUAR 2008', I18n.l(::DateTime.new(2008, 2, 1, 6), :format => "%-d. %^B %Y", :locale => :de) + end + + test "localize DateTime: given missing translations it returns the correct error message" do + assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@datetime, :format => '%b', :locale => :fr) + end + + test "localize DateTime: given a meridian indicator format it returns the correct meridian indicator" do + assert_equal 'AM', I18n.l(@datetime, :format => '%p', :locale => :de) + assert_equal 'PM', I18n.l(@other_datetime, :format => '%p', :locale => :de) + end + + test "localize DateTime: given a meridian indicator format it returns the correct meridian indicator in downcase" do + assert_equal 'am', I18n.l(@datetime, :format => '%P', :locale => :de) + assert_equal 'pm', I18n.l(@other_datetime, :format => '%P', :locale => :de) + end + + test "localize DateTime: given an unknown format it does not fail" do + assert_nothing_raised { I18n.l(@datetime, :format => '%x') } + end + + test "localize DateTime: given a format is missing it raises I18n::MissingTranslationData" do + assert_raises(I18n::MissingTranslationData) { I18n.l(@datetime, :format => :missing) } + end + + protected + + def setup_datetime_translations + # time translations might have been set up in Tests::Api::Localization::Time + I18n.backend.store_translations :de, { + :time => { + :formats => { + :default => "%a, %d. %b %Y %H:%M:%S %z", + :short => "%d. %b %H:%M", + :long => "%d. %B %Y %H:%M" + }, + :am => 'am', + :pm => 'pm' + } + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/procs.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/procs.rb new file mode 100644 index 0000000..7db45d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/procs.rb @@ -0,0 +1,118 @@ +# encoding: utf-8 + +module I18n + module Tests + module Localization + module Procs + test "localize: using day names from lambdas" do + setup_time_proc_translations + time = ::Time.utc(2008, 3, 1, 6, 0) + assert_match(/Суббота/, I18n.l(time, :format => "%A, %d %B", :locale => :ru)) + assert_match(/суббота/, I18n.l(time, :format => "%d %B (%A)", :locale => :ru)) + end + + test "localize: using month names from lambdas" do + setup_time_proc_translations + time = ::Time.utc(2008, 3, 1, 6, 0) + assert_match(/марта/, I18n.l(time, :format => "%d %B %Y", :locale => :ru)) + assert_match(/Март /, I18n.l(time, :format => "%B %Y", :locale => :ru)) + end + + test "localize: using abbreviated day names from lambdas" do + setup_time_proc_translations + time = ::Time.utc(2008, 3, 1, 6, 0) + assert_match(/марта/, I18n.l(time, :format => "%d %b %Y", :locale => :ru)) + assert_match(/март /, I18n.l(time, :format => "%b %Y", :locale => :ru)) + end + + test "localize Date: given a format that resolves to a Proc it calls the Proc with the object" do + setup_time_proc_translations + date = ::Date.new(2008, 3, 1) + assert_equal '[Sat, 01 Mar 2008, {}]', I18n.l(date, :format => :proc, :locale => :ru) + end + + test "localize Date: given a format that resolves to a Proc it calls the Proc with the object and extra options" do + setup_time_proc_translations + date = ::Date.new(2008, 3, 1) + assert_equal '[Sat, 01 Mar 2008, {:foo=>"foo"}]', I18n.l(date, :format => :proc, :foo => 'foo', :locale => :ru) + end + + test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object" do + setup_time_proc_translations + datetime = ::DateTime.new(2008, 3, 1, 6) + assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {}]', I18n.l(datetime, :format => :proc, :locale => :ru) + end + + test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object and extra options" do + setup_time_proc_translations + datetime = ::DateTime.new(2008, 3, 1, 6) + assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {:foo=>"foo"}]', I18n.l(datetime, :format => :proc, :foo => 'foo', :locale => :ru) + end + + test "localize Time: given a format that resolves to a Proc it calls the Proc with the object" do + setup_time_proc_translations + time = ::Time.utc(2008, 3, 1, 6, 0) + assert_equal I18n::Tests::Localization::Procs.inspect_args([time], {}), I18n.l(time, :format => :proc, :locale => :ru) + end + + test "localize Time: given a format that resolves to a Proc it calls the Proc with the object and extra options" do + setup_time_proc_translations + time = ::Time.utc(2008, 3, 1, 6, 0) + options = { :foo => 'foo' } + assert_equal I18n::Tests::Localization::Procs.inspect_args([time], options), I18n.l(time, **options.merge(:format => :proc, :locale => :ru)) + end + + protected + + def self.inspect_args(args, kwargs) + args << kwargs + args = args.map do |arg| + case arg + when ::Time, ::DateTime + arg.strftime('%a, %d %b %Y %H:%M:%S %Z').sub('+0000', '+00:00') + when ::Date + arg.strftime('%a, %d %b %Y') + when Hash + arg.delete(:fallback_in_progress) + arg.delete(:fallback_original_locale) + arg.inspect + else + arg.inspect + end + end + "[#{args.join(', ')}]" + end + + def setup_time_proc_translations + I18n.backend.store_translations :ru, { + :time => { + :formats => { + :proc => lambda { |*args, **kwargs| I18n::Tests::Localization::Procs.inspect_args(args, kwargs) } + } + }, + :date => { + :formats => { + :proc => lambda { |*args, **kwargs| I18n::Tests::Localization::Procs.inspect_args(args, kwargs) } + }, + :'day_names' => lambda { |key, options| + (options[:format] =~ /^%A/) ? + %w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) : + %w(воскресенье понедельник вторник среда четверг пятница суббота) + }, + :'month_names' => lambda { |key, options| + (options[:format] =~ /(%d|%e)(\s*)?(%B)/) ? + %w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) : + %w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil) + }, + :'abbr_month_names' => lambda { |key, options| + (options[:format] =~ /(%d|%e)(\s*)(%b)/) ? + %w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) : + %w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil) + }, + } + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/time.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/time.rb new file mode 100644 index 0000000..456a760 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/localization/time.rb @@ -0,0 +1,103 @@ +# encoding: utf-8 + +module I18n + module Tests + module Localization + module Time + def setup + super + setup_time_translations + @time = ::Time.utc(2008, 3, 1, 6, 0) + @other_time = ::Time.utc(2008, 3, 1, 18, 0) + end + + test "localize Time: given the short format it uses it" do + assert_equal '01. Mär 06:00', I18n.l(@time, :format => :short, :locale => :de) + end + + test "localize Time: given the long format it uses it" do + assert_equal '01. März 2008 06:00', I18n.l(@time, :format => :long, :locale => :de) + end + + # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this? + # def test_localize_given_the_default_format_it_uses_it + # assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@time, :format => :default, :locale => :de) + # end + + test "localize Time: given a day name format it returns the correct day name" do + assert_equal 'Samstag', I18n.l(@time, :format => '%A', :locale => :de) + end + + test "localize Time: given a uppercased day name format it returns the correct day name in upcase" do + assert_equal 'samstag'.upcase, I18n.l(@time, :format => '%^A', :locale => :de) + end + + test "localize Time: given an abbreviated day name format it returns the correct abbreviated day name" do + assert_equal 'Sa', I18n.l(@time, :format => '%a', :locale => :de) + end + + test "localize Time: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do + assert_equal 'sa'.upcase, I18n.l(@time, :format => '%^a', :locale => :de) + end + + test "localize Time: given a month name format it returns the correct month name" do + assert_equal 'März', I18n.l(@time, :format => '%B', :locale => :de) + end + + test "localize Time: given a uppercased month name format it returns the correct month name in upcase" do + assert_equal 'märz'.upcase, I18n.l(@time, :format => '%^B', :locale => :de) + end + + test "localize Time: given an abbreviated month name format it returns the correct abbreviated month name" do + assert_equal 'Mär', I18n.l(@time, :format => '%b', :locale => :de) + end + + test "localize Time: given an abbreviated and uppercased month name format it returns the correct abbreviated month name in upcase" do + assert_equal 'mär'.upcase, I18n.l(@time, :format => '%^b', :locale => :de) + end + + test "localize Time: given a date format with the month name upcased it returns the correct value" do + assert_equal '1. FEBRUAR 2008', I18n.l(::Time.utc(2008, 2, 1, 6, 0), :format => "%-d. %^B %Y", :locale => :de) + end + + test "localize Time: given missing translations it returns the correct error message" do + assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@time, :format => '%b', :locale => :fr) + end + + test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do + assert_equal 'AM', I18n.l(@time, :format => '%p', :locale => :de) + assert_equal 'PM', I18n.l(@other_time, :format => '%p', :locale => :de) + end + + test "localize Time: given a meridian indicator format it returns the correct meridian indicator in upcase" do + assert_equal 'am', I18n.l(@time, :format => '%P', :locale => :de) + assert_equal 'pm', I18n.l(@other_time, :format => '%P', :locale => :de) + end + + test "localize Time: given an unknown format it does not fail" do + assert_nothing_raised { I18n.l(@time, :format => '%x') } + end + + test "localize Time: given a format is missing it raises I18n::MissingTranslationData" do + assert_raises(I18n::MissingTranslationData) { I18n.l(@time, :format => :missing) } + end + + protected + + def setup_time_translations + I18n.backend.store_translations :de, { + :time => { + :formats => { + :default => "%a, %d. %b %Y %H:%M:%S %z", + :short => "%d. %b %H:%M", + :long => "%d. %B %Y %H:%M", + }, + :am => 'am', + :pm => 'pm' + } + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/lookup.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/lookup.rb new file mode 100644 index 0000000..bbd775f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/lookup.rb @@ -0,0 +1,81 @@ +# encoding: utf-8 + +module I18n + module Tests + module Lookup + def setup + super + I18n.backend.store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' }, :falsy => false, :truthy => true, + :string => "a", :array => %w(a b c), :hash => { "a" => "b" }) + end + + test "lookup: it returns a string" do + assert_equal("a", I18n.t(:string)) + end + + test "lookup: it returns hash" do + assert_equal({ :a => "b" }, I18n.t(:hash)) + end + + test "lookup: it returns an array" do + assert_equal(%w(a b c), I18n.t(:array)) + end + + test "lookup: it returns a native true" do + assert I18n.t(:truthy) === true + end + + test "lookup: it returns a native false" do + assert I18n.t(:falsy) === false + end + + test "lookup: given a missing key, no default and no raise option it returns an error message" do + assert_equal "Translation missing: en.missing", I18n.t(:missing) + end + + test "lookup: given a missing key, no default and the raise option it raises MissingTranslationData" do + assert_raises(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) } + end + + test "lookup: does not raise an exception if no translation data is present for the given locale" do + assert_nothing_raised { I18n.t(:foo, :locale => :xx) } + end + + test "lookup: does not modify the options hash" do + options = {} + assert_equal "a", I18n.t(:string, **options) + assert_equal({}, options) + assert_nothing_raised { I18n.t(:string, **options.freeze) } + end + + test "lookup: given an array of keys it translates all of them" do + assert_equal %w(bar baz), I18n.t([:bar, :baz], :scope => [:foo]) + end + + test "lookup: using a custom scope separator" do + # data must have been stored using the custom separator when using the ActiveRecord backend + I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' }) + assert_equal 'bar', I18n.t('foo|bar', :separator => '|') + end + + # In fact it probably *should* fail but Rails currently relies on using the default locale instead. + # So we'll stick to this for now until we get it fixed in Rails. + test "lookup: given nil as a locale it does not raise but use the default locale" do + # assert_raises(I18n::InvalidLocale) { I18n.t(:bar, :locale => nil) } + assert_nothing_raised { I18n.t(:bar, :locale => nil) } + end + + test "lookup: a resulting String is not frozen" do + assert !I18n.t(:string).frozen? + end + + test "lookup: a resulting Array is not frozen" do + assert !I18n.t(:array).frozen? + end + + test "lookup: a resulting Hash is not frozen" do + assert !I18n.t(:hash).frozen? + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/pluralization.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/pluralization.rb new file mode 100644 index 0000000..19e73f3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/pluralization.rb @@ -0,0 +1,35 @@ +# encoding: utf-8 + +module I18n + module Tests + module Pluralization + test "pluralization: given 0 it returns the :zero translation if it is defined" do + assert_equal 'zero', I18n.t(:default => { :zero => 'zero' }, :count => 0) + end + + test "pluralization: given 0 it returns the :other translation if :zero is not defined" do + assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 0) + end + + test "pluralization: given 1 it returns the singular translation" do + assert_equal 'bar', I18n.t(:default => { :one => 'bar' }, :count => 1) + end + + test "pluralization: given 2 it returns the :other translation" do + assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 2) + end + + test "pluralization: given 3 it returns the :other translation" do + assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 3) + end + + test "pluralization: given nil it returns the whole entry" do + assert_equal({ :one => 'bar' }, I18n.t(:default => { :one => 'bar' }, :count => nil)) + end + + test "pluralization: given incomplete pluralization data it raises I18n::InvalidPluralizationData" do + assert_raises(I18n::InvalidPluralizationData) { I18n.t(:default => { :one => 'bar' }, :count => 2) } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/procs.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/procs.rb new file mode 100644 index 0000000..6abd861 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/tests/procs.rb @@ -0,0 +1,66 @@ +# encoding: utf-8 + +module I18n + module Tests + module Procs + test "lookup: given a translation is a proc it calls the proc with the key and interpolation values" do + I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }) + assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo') + end + + test "lookup: given a translation is a proc it passes the interpolation values as keyword arguments" do + I18n.backend.store_translations(:en, :a_lambda => lambda { |key, foo:, **| I18n::Tests::Procs.filter_args(key, foo: foo) }) + assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo') + end + + test "defaults: given a default is a Proc it calls it with the key and interpolation values" do + proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } + assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') + end + + test "defaults: given a default is a key that resolves to a Proc it calls it with the key and interpolation values" do + the_lambda = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } + I18n.backend.store_translations(:en, :a_lambda => the_lambda) + assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo') + assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo') + end + + test "interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do + proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } + assert_match %r(\[\{:foo=>#\}\]), I18n.t(nil, :default => '%{foo}', :foo => proc) + end + + test "interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do + proc = lambda { |*args| "%{foo}: " + I18n::Tests::Procs.filter_args(*args) } + assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') + end + + test "pluralization: given a key resolves to a Proc that returns valid data then pluralization still works" do + proc = lambda { |*args| { :zero => 'zero', :one => 'one', :other => 'other' } } + assert_equal 'zero', I18n.t(:default => proc, :count => 0) + assert_equal 'one', I18n.t(:default => proc, :count => 1) + assert_equal 'other', I18n.t(:default => proc, :count => 2) + end + + test "lookup: given the option :resolve => false was passed it does not resolve proc translations" do + I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }) + assert_equal Proc, I18n.t(:a_lambda, :resolve => false).class + end + + test "lookup: given the option :resolve => false was passed it does not resolve proc default" do + assert_equal Proc, I18n.t(nil, :default => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }, :resolve => false).class + end + + + def self.filter_args(*args) + args.map do |arg| + if arg.is_a?(Hash) + arg.delete(:fallback_in_progress) + arg.delete(:fallback_original_locale) + end + arg + end.inspect + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/utils.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/utils.rb new file mode 100644 index 0000000..8841561 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/utils.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module I18n + module Utils + class << self + if Hash.method_defined?(:except) + def except(hash, *keys) + hash.except(*keys) + end + else + def except(hash, *keys) + hash = hash.dup + keys.each { |k| hash.delete(k) } + hash + end + end + + def deep_merge(hash, other_hash, &block) + deep_merge!(hash.dup, other_hash, &block) + end + + def deep_merge!(hash, other_hash, &block) + hash.merge!(other_hash) do |key, this_val, other_val| + if this_val.is_a?(Hash) && other_val.is_a?(Hash) + deep_merge(this_val, other_val, &block) + elsif block_given? + yield key, this_val, other_val + else + other_val + end + end + end + + def deep_symbolize_keys(hash) + hash.each_with_object({}) do |(key, value), result| + result[key.respond_to?(:to_sym) ? key.to_sym : key] = deep_symbolize_keys_in_object(value) + result + end + end + + private + + def deep_symbolize_keys_in_object(value) + case value + when Hash + deep_symbolize_keys(value) + when Array + value.map { |e| deep_symbolize_keys_in_object(e) } + else + value + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/version.rb b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/version.rb new file mode 100644 index 0000000..7c4b3ed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/i18n-1.14.5/lib/i18n/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module I18n + VERSION = "1.14.5" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/.rubocop.yml b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/.rubocop.yml new file mode 100644 index 0000000..8e31145 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/.rubocop.yml @@ -0,0 +1,474 @@ +--- +inherit_from: .rubocop_todo.yml + +require: + - rubocop-minitest + - rubocop-performance + - rubocop-rake + - rubocop-rspec + - ./rubocop/jekyll + +Jekyll/NoPutsAllowed: + Exclude: + - rake/*.rake + +AllCops: + TargetRubyVersion: 2.7 + Include: + - lib/**/*.rb + - test/**/*.rb + Exclude: + - bin/**/* + - exe/**/* + - benchmark/**/* + - script/**/* + - vendor/**/* + - tmp/**/* + +Gemspec/DeprecatedAttributeAssignment: + Enabled: true +Gemspec/RequireMFA: + Enabled: false + +Layout/BeginEndAlignment: + Enabled: true +Layout/EmptyComment: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: true +Layout/EndAlignment: + Severity: error +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent +Layout/HashAlignment: + EnforcedHashRocketStyle: table +Layout/IndentationWidth: + Severity: error +Layout/LineContinuationLeadingSpace: + Enabled: true +Layout/LineContinuationSpacing: + Enabled: true +Layout/LineEndStringConcatenationIndentation: + Enabled: true +Layout/LineLength: + Exclude: + - !ruby/regexp /features\/.*.rb/ + - Rakefile + - rake/*.rake + - Gemfile + Max: 100 + Severity: warning +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented +Layout/MultilineOperationIndentation: + EnforcedStyle: indented +Layout/SpaceAroundMethodCallOperator: + Enabled: true +Layout/SpaceBeforeBrackets: + Enabled: true +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + Exclude: + - test/**/*.rb + +Lint/AmbiguousAssignment: + Enabled: true +Lint/AmbiguousOperatorPrecedence: + Enabled: true +Lint/AmbiguousRange: + Enabled: true +Lint/BinaryOperatorWithIdenticalOperands: + Enabled: true +Lint/ConstantDefinitionInBlock: + Enabled: true + Exclude: + - test/**/*.rb +Lint/ConstantOverwrittenInRescue: + Enabled: true +Lint/DeprecatedConstants: + Enabled: true +Lint/DeprecatedOpenSSLConstant: + Enabled: true +Lint/DuplicateBranch: + Enabled: true +Lint/DuplicateElsifCondition: + Enabled: true +Lint/DuplicateRegexpCharacterClassElement: + Enabled: true +Lint/DuplicateRequire: + Enabled: true +Lint/DuplicateRescueException: + Enabled: true +Lint/EmptyBlock: + Enabled: true +Lint/EmptyClass: + Enabled: true +Lint/EmptyConditionalBody: + Enabled: true +Lint/EmptyFile: + Enabled: true +Lint/FloatComparison: + Enabled: true +Lint/HashCompareByIdentity: + Enabled: true +Lint/IdentityComparison: + Enabled: true +Lint/LambdaWithoutLiteralBlock: + Enabled: true +Lint/MissingSuper: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Exclude: + - test/test_site.rb +Lint/NoReturnInBeginEndBlocks: + Enabled: true +Lint/NumberedParameterAssignment: + Enabled: true +Lint/OrAssignmentToConstant: + Enabled: true +Lint/OutOfRangeRegexpRef: + Enabled: true +Lint/RaiseException: + Enabled: true +Lint/RedundantDirGlobSort: + Enabled: true +Lint/RedundantSafeNavigation: + Enabled: true +Lint/RequireRangeParentheses: + Enabled: true +Lint/RequireRelativeSelfPath: + Enabled: true +Lint/SelfAssignment: + Enabled: true +Lint/StructNewOverride: + Enabled: true +Lint/SymbolConversion: + Enabled: true +Lint/ToEnumArguments: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: true +Lint/TrailingCommaInAttributeDeclaration: + Enabled: true +Lint/TripleQuotes: + Enabled: true +Lint/UnexpectedBlockArity: + Enabled: true +Lint/UnmodifiedReduceAccumulator: + Enabled: true +Lint/UnreachableCode: + Severity: error +Lint/UnreachableLoop: + Enabled: true +Lint/UselessMethodDefinition: + Enabled: true +Lint/UselessTimes: + Enabled: true +Lint/Void: + Exclude: + - lib/jekyll/site.rb + +Metrics/AbcSize: + Max: 23 +Metrics/BlockLength: + Exclude: + - test/**/*.rb + - lib/jekyll/configuration.rb + - rake/*.rake +Metrics/ClassLength: + Exclude: + - !ruby/regexp /features\/.*.rb$/ + - !ruby/regexp /test\/.*.rb$/ + - lib/jekyll/document.rb + - lib/jekyll/site.rb + - lib/jekyll/commands/serve.rb + - lib/jekyll/configuration.rb + Max: 240 +Metrics/CyclomaticComplexity: + Exclude: + - lib/jekyll/utils.rb + - lib/jekyll/commands/serve.rb + Max: 11 +Metrics/MethodLength: + CountComments: false + Max: 20 + Severity: error +Metrics/ModuleLength: + Exclude: + - lib/jekyll/filters.rb + Max: 240 +Metrics/ParameterLists: + Max: 4 +Metrics/PerceivedComplexity: + Max: 13 + +Minitest/AssertEmptyLiteral: + Enabled: false +Minitest/AssertInDelta: + Enabled: true +Minitest/AssertionInLifecycleHook: + Enabled: true +Minitest/AssertKindOf: + Enabled: true +Minitest/AssertOutput: + Enabled: true +Minitest/AssertPathExists: + Enabled: true +Minitest/AssertSilent: + Enabled: true +Minitest/AssertWithExpectedArgument: + Enabled: true +Minitest/LiteralAsActualArgument: + Enabled: true +Minitest/TestMethodName: + Enabled: false +Minitest/MultipleAssertions: + Enabled: true +Minitest/RefuteInDelta: + Enabled: true +Minitest/RefuteKindOf: + Enabled: true +Minitest/RefutePathExists: + Enabled: true +Minitest/UnreachableAssertion: + Enabled: true +Minitest/UnspecifiedException: + Enabled: true + +Naming/FileName: + Enabled: false +Naming/HeredocDelimiterNaming: + Exclude: + - test/**/*.rb +Naming/MemoizedInstanceVariableName: + Exclude: + - lib/jekyll/convertible.rb + - lib/jekyll/drops/site_drop.rb + - lib/jekyll/drops/unified_payload_drop.rb + - lib/jekyll/page_without_a_file.rb + +Performance/AncestorsInclude: + Enabled: false +Performance/ArraySemiInfiniteRangeSlice: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/ChainArrayAllocation: + Enabled: true +Performance/CollectionLiteralInLoop: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MapCompact: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantEqualityComparisonBlock: + Enabled: false +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantSplitRegexpArgument: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: false +Performance/Squeeze: + Enabled: true +Performance/StringIdentifierArgument: + Enabled: true +Performance/StringInclude: + Enabled: true + Exclude: + - lib/jekyll/utils/platforms.rb +Performance/Sum: + Enabled: true + +Security/CompoundHash: + Enabled: true +Security/IoMethods: + Enabled: true +Security/MarshalLoad: + Exclude: + - !ruby/regexp /test\/.*.rb$/ + - lib/jekyll/regenerator.rb +Security/YAMLLoad: + Exclude: + - !ruby/regexp /features\/.*.rb/ + - !ruby/regexp /test\/.*.rb$/ + +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: true +Style/Alias: + EnforcedStyle: prefer_alias_method +Style/AndOr: + Severity: error +Style/ArgumentsForwarding: + Enabled: false +Style/ArrayCoercion: + Enabled: true +Style/BisectedAttrAccessor: + Enabled: true +Style/CaseLikeIf: + Enabled: true +Style/StringChars: + Enabled: true +Style/ClassAndModuleChildren: + Exclude: + - test/**/*.rb +Style/ClassEqualityComparison: + Enabled: true +Style/CollectionCompact: + Enabled: true +Style/CombinableLoops: + Enabled: true +Style/DocumentDynamicEvalDefinition: + Enabled: true +Style/Documentation: + Enabled: false +Style/DoubleNegation: + Enabled: false +Style/EmptyHeredoc: + Enabled: true +Style/EndlessMethod: + Enabled: true +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: true +Style/EnvHome: + Enabled: true +Style/FetchEnvVar: + Enabled: false +Style/FileRead: + Enabled: false +Style/FormatStringToken: + Exclude: + - lib/jekyll/utils/ansi.rb + - lib/jekyll/liquid_renderer/table.rb + - lib/jekyll/profiler.rb +Style/FrozenStringLiteralComment: + EnforcedStyle: always +Style/FileWrite: + Enabled: true +Style/GlobalStdStream: + Enabled: true +Style/GuardClause: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: true +Style/HashConversion: + Enabled: true +Style/HashEachMethods: + Enabled: true +Style/HashExcept: + Enabled: true +Style/HashLikeCase: + Enabled: true +Style/HashSyntax: + EnforcedStyle: hash_rockets + Severity: error +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: true +Style/IfWithBooleanLiteralBranches: + Enabled: true +Style/KeywordParametersOrder: + Enabled: true +Style/MagicCommentFormat: + Enabled: true +Style/MapCompactWithConditionalBlock: + Enabled: true +Style/MapToHash: + Enabled: true +Style/MixinUsage: + Exclude: + - test/helper.rb +Style/ModuleFunction: + Enabled: false +Style/MultilineTernaryOperator: + Severity: error +Style/NegatedIfElseCondition: + Enabled: true +Style/NestedFileDirname: + Enabled: true +Style/NilLambda: + Enabled: true +Style/OptionalBooleanParameter: + Enabled: true + Exclude: + - lib/jekyll/log_adapter.rb +Style/PercentLiteralDelimiters: + PreferredDelimiters: + "%Q": "{}" + "%W": () + "%q": "{}" + "%r": "!!" + "%s": () + "%w": () + "%x": () +Style/QuotedSymbols: + Enabled: true +Style/RedundantArgument: + Enabled: true +Style/RedundantAssignment: + Enabled: true +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: true +Style/RedundantInitialize: + Enabled: true + Exclude: + - lib/jekyll/plugin.rb +Style/RedundantRegexpCharacterClass: + Enabled: true +Style/RedundantRegexpEscape: + Enabled: true +Style/RedundantSelfAssignment: + Enabled: true +Style/RedundantSelfAssignmentBranch: + Enabled: true +Style/RegexpLiteral: + EnforcedStyle: percent_r +Style/RescueModifier: + Enabled: false +Style/SafeNavigation: + Exclude: + - lib/jekyll/document.rb +Style/SignalException: + EnforcedStyle: only_raise +Style/SingleArgumentDig: + Enabled: true +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: true +Style/StringConcatenation: + Enabled: true + Exclude: + - lib/jekyll/commands/*.rb + - test/**/*.rb +Style/StringLiterals: + EnforcedStyle: double_quotes +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes +Style/SwapValues: + Enabled: true +Style/SymbolArray: + EnforcedStyle: brackets +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: consistent_comma +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: consistent_comma diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/LICENSE b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/LICENSE new file mode 100644 index 0000000..91e3192 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2008-present Tom Preston-Werner and Jekyll contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/README.markdown b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/README.markdown new file mode 100644 index 0000000..ad55a2f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/README.markdown @@ -0,0 +1,83 @@ +# [Jekyll](https://jekyllrb.com/) + +[![Gem Version](https://img.shields.io/gem/v/jekyll.svg)][ruby-gems] +[![Linux Build Status](https://github.com/jekyll/jekyll/workflows/Continuous%20Integration/badge.svg)][ci-workflow] +[![Windows Build status](https://img.shields.io/appveyor/ci/jekyll/jekyll/master.svg?label=Windows%20build)][appveyor] +[![Backers on Open Collective](https://opencollective.com/jekyll/backers/badge.svg)](#backers) +[![Sponsors on Open Collective](https://opencollective.com/jekyll/sponsors/badge.svg)](#sponsors) + +[ruby-gems]: https://rubygems.org/gems/jekyll +[ci-workflow]: https://github.com/jekyll/jekyll/actions?query=workflow%3A%22Continuous+Integration%22+branch%3Amaster +[appveyor]: https://ci.appveyor.com/project/jekyll/jekyll/branch/master + +Jekyll is a simple, blog-aware, static site generator perfect for personal, project, or organization sites. Think of it like a file-based CMS, without all the complexity. Jekyll takes your content, renders Markdown and Liquid templates, and spits out a complete, static website ready to be served by Apache, Nginx or another web server. Jekyll is the engine behind [GitHub Pages](https://pages.github.com), which you can use to host sites right from your GitHub repositories. + +## Philosophy + +Jekyll does what you tell it to do — no more, no less. It doesn't try to outsmart users by making bold assumptions, nor does it burden them with needless complexity and configuration. Put simply, Jekyll gets out of your way and allows you to concentrate on what truly matters: your content. + +See: [https://jekyllrb.com/philosophy](https://jekyllrb.com/philosophy) + +## Getting Started + +* [Install](https://jekyllrb.com/docs/installation/) the gem +* Read up about its [Usage](https://jekyllrb.com/docs/usage/) and [Configuration](https://jekyllrb.com/docs/configuration/) +* Take a gander at some existing [Sites](https://github.com/jekyll/jekyll/wiki/sites) +* [Fork](https://github.com/jekyll/jekyll/fork) and [Contribute](https://jekyllrb.com/docs/contributing/) your own modifications +* Have questions? Check out our official forum community [Jekyll Talk](https://talk.jekyllrb.com/) and [`#jekyll` Channel on Libera IRC](https://libera.chat) + +## Diving In + +* [Migrate](https://import.jekyllrb.com/docs/home/) from your previous system +* Learn how [Front Matter](https://jekyllrb.com/docs/front-matter/) works +* Put information on your site with [Variables](https://jekyllrb.com/docs/variables/) +* Customize the [Permalinks](https://jekyllrb.com/docs/permalinks/) your posts are generated with +* Use the built-in [Liquid Extensions](https://jekyllrb.com/docs/templates/) to make your life easier +* Use custom [Plugins](https://jekyllrb.com/docs/plugins/) to generate content specific to your site +* Watch [video tutorials from Giraffe Academy](https://jekyllrb.com/tutorials/video-walkthroughs/) + +## Need help? + +If you don't find the answer to your problem in our [docs](https://jekyllrb.com/docs/), or in the [troubleshooting section](https://jekyllrb.com/docs/troubleshooting/), ask the [community](https://jekyllrb.com/docs/community/) for help. + +## Code of Conduct + +In order to have a more open and welcoming community, Jekyll adheres to a +[code of conduct](https://jekyllrb.com/docs/conduct/) adapted from the Ruby on Rails code of +conduct. + +Please adhere to this code of conduct in any interactions you have in the +Jekyll community. It is strictly enforced on all official Jekyll +repositories, websites, and resources. If you encounter someone violating +these terms, please let one of our [core team members](https://jekyllrb.com/team/#core-team) know and we will address it as soon as possible. + +## Credits + +### Sponsors + +Support this project by becoming a sponsor. Your logo will show up in this README with a link to your website. [Become a sponsor!](https://opencollective.com/jekyll#sponsor) +[![Jekyll Sponsor 0](https://opencollective.com/jekyll/sponsor/0/avatar.svg)](https://opencollective.com/jekyll/sponsor/0/website) +[![Jekyll Sponsor 1](https://opencollective.com/jekyll/sponsor/1/avatar.svg)](https://opencollective.com/jekyll/sponsor/1/website) +[![Jekyll Sponsor 2](https://opencollective.com/jekyll/sponsor/2/avatar.svg)](https://opencollective.com/jekyll/sponsor/2/website) +[![Jekyll Sponsor 3](https://opencollective.com/jekyll/sponsor/3/avatar.svg)](https://opencollective.com/jekyll/sponsor/3/website) +[![Jekyll Sponsor 4](https://opencollective.com/jekyll/sponsor/4/avatar.svg)](https://opencollective.com/jekyll/sponsor/4/website) +[![Jekyll Sponsor 5](https://opencollective.com/jekyll/sponsor/5/avatar.svg)](https://opencollective.com/jekyll/sponsor/5/website) +[![Jekyll Sponsor 6](https://opencollective.com/jekyll/sponsor/6/avatar.svg)](https://opencollective.com/jekyll/sponsor/6/website) +[![Jekyll Sponsor 7](https://opencollective.com/jekyll/sponsor/7/avatar.svg)](https://opencollective.com/jekyll/sponsor/7/website) +[![Jekyll Sponsor 8](https://opencollective.com/jekyll/sponsor/8/avatar.svg)](https://opencollective.com/jekyll/sponsor/8/website) +[![Jekyll Sponsor 9](https://opencollective.com/jekyll/sponsor/9/avatar.svg)](https://opencollective.com/jekyll/sponsor/9/website) + +### Contributors + +This project exists thanks to all the people who contribute. +[![Jekyll Contributors](https://opencollective.com/jekyll/contributors.svg?width=890&button=false)](../../graphs/contributors) + +### Backers + +Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/jekyll#backer) + +[![Jekyll Backers](https://opencollective.com/jekyll/backers.svg?width=890)](https://opencollective.com/jekyll#backers) + +## License + +See the [LICENSE](https://github.com/jekyll/jekyll/blob/master/LICENSE) file. diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/exe/jekyll b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/exe/jekyll new file mode 100755 index 0000000..07e1371 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/exe/jekyll @@ -0,0 +1,57 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +STDOUT.sync = true + +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) + +require "jekyll" +require "mercenary" + +Jekyll::PluginManager.require_from_bundler + +Jekyll::Deprecator.process(ARGV) + +Mercenary.program(:jekyll) do |p| + p.version Jekyll::VERSION + p.description "Jekyll is a blog-aware, static site generator in Ruby" + p.syntax "jekyll [options]" + + p.option "source", "-s", "--source [DIR]", "Source directory (defaults to ./)" + p.option "destination", "-d", "--destination [DIR]", + "Destination directory (defaults to ./_site)" + p.option "safe", "--safe", "Safe mode (defaults to false)" + p.option "plugins_dir", "-p", "--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]", Array, + "Plugins directory (defaults to ./_plugins)" + p.option "layouts_dir", "--layouts DIR", String, + "Layouts directory (defaults to ./_layouts)" + p.option "profile", "--profile", "Generate a Liquid rendering profile" + + Jekyll::External.require_if_present(Jekyll::External.blessed_gems) do |g, ver_constraint| + cmd = g.split("-").last + p.command(cmd.to_sym) do |c| + c.syntax cmd + c.action do + Jekyll.logger.abort_with "You must install the '#{g}' gem" \ + " version #{ver_constraint} to use the 'jekyll #{cmd}' command." + end + end + end + + Jekyll::Command.subclasses.each { |c| c.init_with_program(p) } + + p.action do |args, _| + if args.empty? + Jekyll.logger.error "A subcommand is required." + puts p + abort + else + subcommand = args.first + unless p.has_command? subcommand + Jekyll.logger.abort_with "fatal: 'jekyll #{args.first}' could not" \ + " be found. You may need to install the jekyll-#{args.first} gem" \ + " or a related gem to be able to use this subcommand." + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_config.yml b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_config.yml new file mode 100644 index 0000000..a0cd66a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_config.yml @@ -0,0 +1,3 @@ +url: "" # the base hostname & protocol for your site, e.g. http://example.com +baseurl: "" # the subpath of your site, e.g. /blog +title: "" # the name of your site, e.g. ACME Corp. diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_layouts/default.html b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_layouts/default.html new file mode 100644 index 0000000..fa0b00a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_layouts/default.html @@ -0,0 +1,12 @@ + + + + + + {{ page.title }} - {{ site.title }} + + + + {{ content }} + + diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_sass/base.scss b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_sass/base.scss new file mode 100644 index 0000000..126160d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/_sass/base.scss @@ -0,0 +1,9 @@ +$backgroundColor: #ffffff; +$bodyColor: #000000; +$bodyFont: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; + +body { + background: $backgroundColor; + color: $bodyColor; + font-family: $bodyFont; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/assets/css/main.scss b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/assets/css/main.scss new file mode 100644 index 0000000..9c288c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/assets/css/main.scss @@ -0,0 +1,4 @@ +--- +--- + +@import "base"; diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/index.md b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/index.md new file mode 100644 index 0000000..82eaafb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/blank_template/index.md @@ -0,0 +1,8 @@ +--- +layout: default +title: "Happy Jekylling!" +--- + +## You're ready to go! + +Start developing your Jekyll website. diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll.rb new file mode 100644 index 0000000..231f8fd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll.rb @@ -0,0 +1,195 @@ +# frozen_string_literal: true + +$LOAD_PATH.unshift __dir__ # For use/testing when no gem is installed + +# Require all of the Ruby files in the given directory. +# +# path - The String relative path from here to the directory. +# +# Returns nothing. +def require_all(path) + glob = File.join(__dir__, path, "*.rb") + Dir[glob].sort.each do |f| + require f + end +end + +# rubygems +require "rubygems" + +# stdlib +require "forwardable" +require "fileutils" +require "time" +require "English" +require "pathname" +require "logger" +require "set" +require "csv" +require "json" + +# 3rd party +require "pathutil" +require "addressable/uri" +require "safe_yaml/load" +require "liquid" +require "kramdown" +require "colorator" +require "i18n" + +SafeYAML::OPTIONS[:suppress_warnings] = true + +module Jekyll + # internal requires + autoload :Cleaner, "jekyll/cleaner" + autoload :Collection, "jekyll/collection" + autoload :Configuration, "jekyll/configuration" + autoload :Convertible, "jekyll/convertible" + autoload :Deprecator, "jekyll/deprecator" + autoload :Document, "jekyll/document" + autoload :EntryFilter, "jekyll/entry_filter" + autoload :Errors, "jekyll/errors" + autoload :Excerpt, "jekyll/excerpt" + autoload :PageExcerpt, "jekyll/page_excerpt" + autoload :External, "jekyll/external" + autoload :FrontmatterDefaults, "jekyll/frontmatter_defaults" + autoload :Hooks, "jekyll/hooks" + autoload :Layout, "jekyll/layout" + autoload :Inclusion, "jekyll/inclusion" + autoload :Cache, "jekyll/cache" + autoload :CollectionReader, "jekyll/readers/collection_reader" + autoload :DataReader, "jekyll/readers/data_reader" + autoload :LayoutReader, "jekyll/readers/layout_reader" + autoload :PostReader, "jekyll/readers/post_reader" + autoload :PageReader, "jekyll/readers/page_reader" + autoload :StaticFileReader, "jekyll/readers/static_file_reader" + autoload :ThemeAssetsReader, "jekyll/readers/theme_assets_reader" + autoload :LogAdapter, "jekyll/log_adapter" + autoload :Page, "jekyll/page" + autoload :PageWithoutAFile, "jekyll/page_without_a_file" + autoload :PathManager, "jekyll/path_manager" + autoload :PluginManager, "jekyll/plugin_manager" + autoload :Publisher, "jekyll/publisher" + autoload :Profiler, "jekyll/profiler" + autoload :Reader, "jekyll/reader" + autoload :Regenerator, "jekyll/regenerator" + autoload :RelatedPosts, "jekyll/related_posts" + autoload :Renderer, "jekyll/renderer" + autoload :LiquidRenderer, "jekyll/liquid_renderer" + autoload :Site, "jekyll/site" + autoload :StaticFile, "jekyll/static_file" + autoload :Stevenson, "jekyll/stevenson" + autoload :Theme, "jekyll/theme" + autoload :ThemeBuilder, "jekyll/theme_builder" + autoload :URL, "jekyll/url" + autoload :Utils, "jekyll/utils" + autoload :VERSION, "jekyll/version" + + # extensions + require "jekyll/plugin" + require "jekyll/converter" + require "jekyll/generator" + require "jekyll/command" + require "jekyll/liquid_extensions" + require "jekyll/filters" + + class << self + # Public: Tells you which Jekyll environment you are building in so you can skip tasks + # if you need to. This is useful when doing expensive compression tasks on css and + # images and allows you to skip that when working in development. + + def env + ENV["JEKYLL_ENV"] || "development" + end + + # Public: Generate a Jekyll configuration Hash by merging the default + # options with anything in _config.yml, and adding the given options on top. + # + # override - A Hash of config directives that override any options in both + # the defaults and the config file. + # See Jekyll::Configuration::DEFAULTS for a + # list of option names and their defaults. + # + # Returns the final configuration Hash. + def configuration(override = {}) + config = Configuration.new + override = Configuration[override].stringify_keys + unless override.delete("skip_config_files") + config = config.read_config_files(config.config_files(override)) + end + + # Merge DEFAULTS < _config.yml < override + Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |obj| + set_timezone(obj["timezone"]) if obj["timezone"] + end + end + + # Public: Set the TZ environment variable to use the timezone specified + # + # timezone - the IANA Time Zone + # + # Returns nothing + # rubocop:disable Naming/AccessorMethodName + def set_timezone(timezone) + ENV["TZ"] = if Utils::Platforms.really_windows? + Utils::WinTZ.calculate(timezone) + else + timezone + end + end + # rubocop:enable Naming/AccessorMethodName + + # Public: Fetch the logger instance for this Jekyll process. + # + # Returns the LogAdapter instance. + def logger + @logger ||= LogAdapter.new(Stevenson.new, (ENV["JEKYLL_LOG_LEVEL"] || :info).to_sym) + end + + # Public: Set the log writer. + # New log writer must respond to the same methods + # as Ruby's internal Logger. + # + # writer - the new Logger-compatible log transport + # + # Returns the new logger. + def logger=(writer) + @logger = LogAdapter.new(writer, (ENV["JEKYLL_LOG_LEVEL"] || :info).to_sym) + end + + # Public: An array of sites + # + # Returns the Jekyll sites created. + def sites + @sites ||= [] + end + + # Public: Ensures the questionable path is prefixed with the base directory + # and prepends the questionable path with the base directory if false. + # + # base_directory - the directory with which to prefix the questionable path + # questionable_path - the path we're unsure about, and want prefixed + # + # Returns the sanitized path. + def sanitized_path(base_directory, questionable_path) + return base_directory if base_directory.eql?(questionable_path) + return base_directory if questionable_path.nil? + + +Jekyll::PathManager.sanitized_path(base_directory, questionable_path) + end + + # Conditional optimizations + Jekyll::External.require_if_present("liquid/c") + end +end + +require "jekyll/drops/drop" +require "jekyll/drops/document_drop" +require_all "jekyll/commands" +require_all "jekyll/converters" +require_all "jekyll/converters/markdown" +require_all "jekyll/drops" +require_all "jekyll/generators" +require_all "jekyll/tags" + +require "jekyll-sass-converter" diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/cache.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/cache.rb new file mode 100644 index 0000000..8bffd0d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/cache.rb @@ -0,0 +1,186 @@ +# frozen_string_literal: true + +require "digest" + +module Jekyll + class Cache + # class-wide base cache + @base_cache = {} + + # class-wide directive to write cache to disk is enabled by default + @disk_cache_enabled = true + + class << self + attr_accessor :cache_dir # class-wide cache location + + attr_reader :base_cache, # class-wide base cache reader + :disk_cache_enabled # class-wide directive to write cache to disk + + # Disable Marshaling cached items to disk + def disable_disk_cache! + @disk_cache_enabled = false + end + + # Clear all caches + def clear + delete_cache_files + base_cache.each_value(&:clear) + end + + # Compare the current config to the cached config + # If they are different, clear all caches + # + # Returns nothing. + def clear_if_config_changed(config) + config = config.inspect + cache = Jekyll::Cache.new "Jekyll::Cache" + return if cache.key?("config") && cache["config"] == config + + clear + cache = Jekyll::Cache.new "Jekyll::Cache" + cache["config"] = config + nil + end + + private + + # Delete all cached items from all caches + # + # Returns nothing. + def delete_cache_files + FileUtils.rm_rf(@cache_dir) if disk_cache_enabled + end + end + + # + + # Get an existing named cache, or create a new one if none exists + # + # name - name of the cache + # + # Returns nothing. + def initialize(name) + @cache = Jekyll::Cache.base_cache[name] ||= {} + @name = name.gsub(%r![^\w\s-]!, "-") + end + + # Clear this particular cache + def clear + delete_cache_files + @cache.clear + end + + # Retrieve a cached item + # Raises if key does not exist in cache + # + # Returns cached value + def [](key) + return @cache[key] if @cache.key?(key) + + path = path_to(hash(key)) + if disk_cache_enabled? && File.file?(path) && File.readable?(path) + @cache[key] = load(path) + else + raise + end + end + + # Add an item to cache + # + # Returns nothing. + def []=(key, value) + @cache[key] = value + return unless disk_cache_enabled? + + path = path_to(hash(key)) + value = new Hash(value) if value.is_a?(Hash) && !value.default.nil? + dump(path, value) + rescue TypeError + Jekyll.logger.debug "Cache:", "Cannot dump object #{key}" + end + + # If an item already exists in the cache, retrieve it. + # Else execute code block, and add the result to the cache, and return that result. + def getset(key) + self[key] + rescue StandardError + value = yield + self[key] = value + value + end + + # Remove one particular item from the cache + # + # Returns nothing. + def delete(key) + @cache.delete(key) + File.delete(path_to(hash(key))) if disk_cache_enabled? + end + + # Check if `key` already exists in this cache + # + # Returns true if key exists in the cache, false otherwise + def key?(key) + # First, check if item is already cached in memory + return true if @cache.key?(key) + # Otherwise, it might be cached on disk + # but we should not consider the disk cache if it is disabled + return false unless disk_cache_enabled? + + path = path_to(hash(key)) + File.file?(path) && File.readable?(path) + end + + def disk_cache_enabled? + !!Jekyll::Cache.disk_cache_enabled + end + + private + + # Given a hashed key, return the path to where this item would be saved on disk. + def path_to(hash = nil) + @base_dir ||= File.join(Jekyll::Cache.cache_dir, @name) + return @base_dir if hash.nil? + + File.join(@base_dir, hash[0..1], hash[2..-1]).freeze + end + + # Given a key, return a SHA2 hash that can be used for caching this item to disk. + def hash(key) + Digest::SHA2.hexdigest(key).freeze + end + + # Remove all this caches items from disk + # + # Returns nothing. + def delete_cache_files + FileUtils.rm_rf(path_to) if disk_cache_enabled? + end + + # Load `path` from disk and return the result. + # This MUST NEVER be called in Safe Mode + # rubocop:disable Security/MarshalLoad + def load(path) + raise unless disk_cache_enabled? + + cached_file = File.open(path, "rb") + value = Marshal.load(cached_file) + cached_file.close + value + end + # rubocop:enable Security/MarshalLoad + + # Given a path and a value, save value to disk at path. + # This should NEVER be called in Safe Mode + # + # Returns nothing. + def dump(path, value) + return unless disk_cache_enabled? + + FileUtils.mkdir_p(File.dirname(path)) + File.open(path, "wb") do |cached_file| + Marshal.dump(value, cached_file) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/cleaner.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/cleaner.rb new file mode 100644 index 0000000..59e7c22 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/cleaner.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +module Jekyll + # Handles the cleanup of a site's destination before it is built. + class Cleaner + HIDDEN_FILE_REGEX = %r!/\.{1,2}$!.freeze + attr_reader :site + + def initialize(site) + @site = site + end + + # Cleans up the site's destination directory + def cleanup! + FileUtils.rm_rf(obsolete_files) + FileUtils.rm_rf(metadata_file) unless @site.incremental? + end + + private + + # Private: The list of files and directories to be deleted during cleanup process + # + # Returns an Array of the file and directory paths + def obsolete_files + out = (existing_files - new_files - new_dirs + replaced_files).to_a + Jekyll::Hooks.trigger :clean, :on_obsolete, out + out + end + + # Private: The metadata file storing dependency tree and build history + # + # Returns an Array with the metadata file as the only item + def metadata_file + [site.regenerator.metadata_file] + end + + # Private: The list of existing files, apart from those included in + # keep_files and hidden files. + # + # Returns a Set with the file paths + def existing_files + files = Set.new + regex = keep_file_regex + dirs = keep_dirs + + Utils.safe_glob(site.in_dest_dir, ["**", "*"], File::FNM_DOTMATCH).each do |file| + next if HIDDEN_FILE_REGEX.match?(file) || regex.match?(file) || dirs.include?(file) + + files << file + end + + files + end + + # Private: The list of files to be created when site is built. + # + # Returns a Set with the file paths + def new_files + @new_files ||= Set.new.tap do |files| + site.each_site_file { |item| files << item.destination(site.dest) } + end + end + + # Private: The list of directories to be created when site is built. + # These are the parent directories of the files in #new_files. + # + # Returns a Set with the directory paths + def new_dirs + @new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set + end + + # Private: The list of parent directories of a given file + # + # Returns an Array with the directory paths + def parent_dirs(file) + parent_dir = File.dirname(file) + if parent_dir == site.dest + [] + else + parent_dirs(parent_dir).unshift(parent_dir) + end + end + + # Private: The list of existing files that will be replaced by a directory + # during build + # + # Returns a Set with the file paths + def replaced_files + new_dirs.select { |dir| File.file?(dir) }.to_set + end + + # Private: The list of directories that need to be kept because they are + # parent directories of files specified in keep_files + # + # Returns a Set with the directory paths + def keep_dirs + site.keep_files.flat_map { |file| parent_dirs(site.in_dest_dir(file)) }.to_set + end + + # Private: Creates a regular expression from the config's keep_files array + # + # Examples + # ['.git','.svn'] with site.dest "/myblog/_site" creates + # the following regex: /\A\/myblog\/_site\/(\.git|\/.svn)/ + # + # Returns the regular expression + def keep_file_regex + %r!\A#{Regexp.quote(site.dest)}/(#{Regexp.union(site.keep_files).source})! + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/collection.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/collection.rb new file mode 100644 index 0000000..1ce33bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/collection.rb @@ -0,0 +1,310 @@ +# frozen_string_literal: true + +module Jekyll + class Collection + attr_reader :site, :label, :metadata + attr_writer :docs + + # Create a new Collection. + # + # site - the site to which this collection belongs. + # label - the name of the collection + # + # Returns nothing. + def initialize(site, label) + @site = site + @label = sanitize_label(label) + @metadata = extract_metadata + end + + # Fetch the Documents in this collection. + # Defaults to an empty array if no documents have been read in. + # + # Returns an array of Jekyll::Document objects. + def docs + @docs ||= [] + end + + # Override of normal respond_to? to match method_missing's logic for + # looking in @data. + def respond_to_missing?(method, include_private = false) + docs.respond_to?(method.to_sym, include_private) || super + end + + # Override of method_missing to check in @data for the key. + def method_missing(method, *args, &blck) + if docs.respond_to?(method.to_sym) + Jekyll.logger.warn "Deprecation:", + "#{label}.#{method} should be changed to #{label}.docs.#{method}." + Jekyll.logger.warn "", "Called by #{caller(0..0)}." + docs.public_send(method.to_sym, *args, &blck) + else + super + end + end + + # Fetch the static files in this collection. + # Defaults to an empty array if no static files have been read in. + # + # Returns an array of Jekyll::StaticFile objects. + def files + @files ||= [] + end + + # Read the allowed documents into the collection's array of docs. + # + # Returns the sorted array of docs. + def read + filtered_entries.each do |file_path| + full_path = collection_dir(file_path) + next if File.directory?(full_path) + + if Utils.has_yaml_header? full_path + read_document(full_path) + else + read_static_file(file_path, full_path) + end + end + site.static_files.concat(files) unless files.empty? + sort_docs! + end + + # All the entries in this collection. + # + # Returns an Array of file paths to the documents in this collection + # relative to the collection's directory + def entries + return [] unless exists? + + @entries ||= begin + collection_dir_slash = "#{collection_dir}/" + Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry| + entry[collection_dir_slash] = "" + entry + end + end + end + + # Filtered version of the entries in this collection. + # See `Jekyll::EntryFilter#filter` for more information. + # + # Returns a list of filtered entry paths. + def filtered_entries + return [] unless exists? + + @filtered_entries ||= + Dir.chdir(directory) do + entry_filter.filter(entries).reject do |f| + path = collection_dir(f) + File.directory?(path) || entry_filter.symlink?(f) + end + end + end + + # The directory for this Collection, relative to the site source or the directory + # containing the collection. + # + # Returns a String containing the directory name where the collection + # is stored on the filesystem. + def relative_directory + @relative_directory ||= "_#{label}" + end + + # The full path to the directory containing the collection. + # + # Returns a String containing th directory name where the collection + # is stored on the filesystem. + def directory + @directory ||= site.in_source_dir( + File.join(container, relative_directory) + ) + end + + # The full path to the directory containing the collection, with + # optional subpaths. + # + # *files - (optional) any other path pieces relative to the + # directory to append to the path + # + # Returns a String containing th directory name where the collection + # is stored on the filesystem. + def collection_dir(*files) + return directory if files.empty? + + site.in_source_dir(container, relative_directory, *files) + end + + # Checks whether the directory "exists" for this collection. + # The directory must exist on the filesystem and must not be a symlink + # if in safe mode. + # + # Returns false if the directory doesn't exist or if it's a symlink + # and we're in safe mode. + def exists? + File.directory?(directory) && !entry_filter.symlink?(directory) + end + + # The entry filter for this collection. + # Creates an instance of Jekyll::EntryFilter. + # + # Returns the instance of Jekyll::EntryFilter for this collection. + def entry_filter + @entry_filter ||= Jekyll::EntryFilter.new(site, relative_directory) + end + + # An inspect string. + # + # Returns the inspect string + def inspect + "#<#{self.class} @label=#{label} docs=#{docs}>" + end + + # Produce a sanitized label name + # Label names may not contain anything but alphanumeric characters, + # underscores, and hyphens. + # + # label - the possibly-unsafe label + # + # Returns a sanitized version of the label. + def sanitize_label(label) + label.gsub(%r![^a-z0-9_\-.]!i, "") + end + + # Produce a representation of this Collection for use in Liquid. + # Exposes two attributes: + # - label + # - docs + # + # Returns a representation of this collection for use in Liquid. + def to_liquid + Drops::CollectionDrop.new self + end + + # Whether the collection's documents ought to be written as individual + # files in the output. + # + # Returns true if the 'write' metadata is true, false otherwise. + def write? + !!metadata.fetch("output", false) + end + + # The URL template to render collection's documents at. + # + # Returns the URL template to render collection's documents at. + def url_template + @url_template ||= metadata.fetch("permalink") do + Utils.add_permalink_suffix("/:collection/:path", site.permalink_style) + end + end + + # Extract options for this collection from the site configuration. + # + # Returns the metadata for this collection + def extract_metadata + if site.config["collections"].is_a?(Hash) + site.config["collections"][label] || {} + else + {} + end + end + + private + + def container + @container ||= site.config["collections_dir"] + end + + def read_document(full_path) + doc = Document.new(full_path, :site => site, :collection => self) + doc.read + docs << doc if site.unpublished || doc.published? + end + + def sort_docs! + if metadata["order"].is_a?(Array) + rearrange_docs! + elsif metadata["sort_by"].is_a?(String) + sort_docs_by_key! + else + docs.sort! + end + end + + # A custom sort function based on Schwartzian transform + # Refer https://byparker.com/blog/2017/schwartzian-transform-faster-sorting/ for details + def sort_docs_by_key! + meta_key = metadata["sort_by"] + # Modify `docs` array to cache document's property along with the Document instance + docs.map! { |doc| [doc.data[meta_key], doc] }.sort! do |apples, olives| + order = determine_sort_order(meta_key, apples, olives) + + # Fall back to `Document#<=>` if the properties were equal or were non-sortable + # Otherwise continue with current sort-order + if order.nil? || order.zero? + apples[-1] <=> olives[-1] + else + order + end + + # Finally restore the `docs` array with just the Document objects themselves + end.map!(&:last) + end + + def determine_sort_order(sort_key, apples, olives) + apple_property, apple_document = apples + olive_property, olive_document = olives + + if apple_property.nil? && !olive_property.nil? + order_with_warning(sort_key, apple_document, 1) + elsif !apple_property.nil? && olive_property.nil? + order_with_warning(sort_key, olive_document, -1) + else + apple_property <=> olive_property + end + end + + def order_with_warning(sort_key, document, order) + Jekyll.logger.warn "Sort warning:", "'#{sort_key}' not defined in #{document.relative_path}" + order + end + + # Rearrange documents within the `docs` array as listed in the `metadata["order"]` array. + # + # Involves converting the two arrays into hashes based on relative_paths as keys first, then + # merging them to remove duplicates and finally retrieving the Document instances from the + # merged array. + def rearrange_docs! + docs_table = {} + custom_order = {} + + # pre-sort to normalize default array across platforms and then proceed to create a Hash + # from that sorted array. + docs.sort.each do |doc| + docs_table[doc.relative_path] = doc + end + + metadata["order"].each do |entry| + custom_order[File.join(relative_directory, entry)] = nil + end + + result = Jekyll::Utils.deep_merge_hashes(custom_order, docs_table).values + result.compact! + self.docs = result + end + + def read_static_file(file_path, full_path) + relative_dir = Jekyll.sanitized_path( + relative_directory, + File.dirname(file_path) + ).chomp("/.") + + files << StaticFile.new( + site, + site.source, + relative_dir, + File.basename(full_path), + self + ) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/command.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/command.rb new file mode 100644 index 0000000..be8890e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/command.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true + +module Jekyll + class Command + class << self + # A list of subclasses of Jekyll::Command + def subclasses + @subclasses ||= [] + end + + # Keep a list of subclasses of Jekyll::Command every time it's inherited + # Called automatically. + # + # base - the subclass + # + # Returns nothing + def inherited(base) + subclasses << base + super(base) + end + + # Run Site#process and catch errors + # + # site - the Jekyll::Site object + # + # Returns nothing + def process_site(site) + site.process + rescue Jekyll::Errors::FatalException => e + Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:" + Jekyll.logger.error "", "------------------------------------" + Jekyll.logger.error "", e.message + exit(1) + end + + # Create a full Jekyll configuration with the options passed in as overrides + # + # options - the configuration overrides + # + # Returns a full Jekyll configuration + def configuration_from_options(options) + return options if options.is_a?(Jekyll::Configuration) + + Jekyll.configuration(options) + end + + # Add common options to a command for building configuration + # + # cmd - the Jekyll::Command to add these options to + # + # Returns nothing + # rubocop:disable Metrics/MethodLength + def add_build_options(cmd) + cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", + Array, "Custom configuration file" + cmd.option "destination", "-d", "--destination DESTINATION", + "The current folder will be generated into DESTINATION" + cmd.option "source", "-s", "--source SOURCE", "Custom source directory" + cmd.option "future", "--future", "Publishes posts with a future date" + cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer, + "Limits the number of posts to parse and publish" + cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild" + cmd.option "baseurl", "-b", "--baseurl URL", + "Serve the website from the given base URL" + cmd.option "force_polling", "--force_polling", "Force watch to use polling" + cmd.option "lsi", "--lsi", "Use LSI for improved related posts" + cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder" + cmd.option "unpublished", "--unpublished", + "Render posts that were marked as unpublished" + cmd.option "disable_disk_cache", "--disable-disk-cache", + "Disable caching to disk in non-safe mode" + cmd.option "quiet", "-q", "--quiet", "Silence output." + cmd.option "verbose", "-V", "--verbose", "Print verbose output." + cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild." + cmd.option "strict_front_matter", "--strict_front_matter", + "Fail if errors are present in front matter" + end + # rubocop:enable Metrics/MethodLength + + # Run ::process method in a given set of Jekyll::Command subclasses and suggest + # re-running the associated command with --trace switch to obtain any additional + # information or backtrace regarding the encountered Exception. + # + # cmd - the Jekyll::Command to be handled + # options - configuration overrides + # klass - an array of Jekyll::Command subclasses associated with the command + # + # Note that all exceptions are rescued.. + # rubocop: disable Lint/RescueException + def process_with_graceful_fail(cmd, options, *klass) + klass.each { |k| k.process(options) if k.respond_to?(:process) } + rescue Exception => e + raise e if cmd.trace + + msg = " Please append `--trace` to the `#{cmd.name}` command " + dashes = "-" * msg.length + Jekyll.logger.error "", dashes + Jekyll.logger.error "Jekyll #{Jekyll::VERSION} ", msg + Jekyll.logger.error "", " for any additional information or backtrace. " + Jekyll.logger.abort_with "", dashes + end + # rubocop: enable Lint/RescueException + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb new file mode 100644 index 0000000..204b2a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +module Jekyll + module Commands + class Build < Command + class << self + # Create the Mercenary command for the Jekyll CLI for this Command + def init_with_program(prog) + prog.command(:build) do |c| + c.syntax "build [options]" + c.description "Build your site" + c.alias :b + + add_build_options(c) + + c.action do |_, options| + options["serving"] = false + process_with_graceful_fail(c, options, self) + end + end + end + + # Build your jekyll site + # Continuously watch if `watch` is set to true in the config. + def process(options) + # Adjust verbosity quickly + Jekyll.logger.adjust_verbosity(options) + + options = configuration_from_options(options) + site = Jekyll::Site.new(options) + + if options.fetch("skip_initial_build", false) + Jekyll.logger.warn "Build Warning:", + "Skipping the initial build. This may result in an out-of-date site." + else + build(site, options) + end + + if options.fetch("detach", false) + Jekyll.logger.info "Auto-regeneration:", + "disabled when running server detached." + elsif options.fetch("watch", false) + watch(site, options) + else + Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable." + end + end + + # Build your Jekyll site. + # + # site - the Jekyll::Site instance to build + # options - A Hash of options passed to the command + # + # Returns nothing. + def build(site, options) + t = Time.now + source = File.expand_path(options["source"]) + destination = File.expand_path(options["destination"]) + incremental = options["incremental"] + Jekyll.logger.info "Source:", source + Jekyll.logger.info "Destination:", destination + Jekyll.logger.info "Incremental build:", + (incremental ? "enabled" : "disabled. Enable with --incremental") + Jekyll.logger.info "Generating..." + process_site(site) + Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds." + end + + # Private: Watch for file changes and rebuild the site. + # + # site - A Jekyll::Site instance + # options - A Hash of options passed to the command + # + # Returns nothing. + def watch(site, options) + External.require_with_graceful_fail "jekyll-watch" + Jekyll::Watcher.watch(options, site) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/clean.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/clean.rb new file mode 100644 index 0000000..9b657a4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/clean.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Jekyll + module Commands + class Clean < Command + class << self + def init_with_program(prog) + prog.command(:clean) do |c| + c.syntax "clean [subcommand]" + c.description "Clean the site (removes site output and metadata file) without building." + + add_build_options(c) + + c.action do |_, options| + Jekyll::Commands::Clean.process(options) + end + end + end + + def process(options) + options = configuration_from_options(options) + destination = options["destination"] + metadata_file = File.join(options["source"], ".jekyll-metadata") + cache_dir = File.join(options["source"], options["cache_dir"]) + sass_cache = ".sass-cache" + + remove(destination, :checker_func => :directory?) + remove(metadata_file, :checker_func => :file?) + remove(cache_dir, :checker_func => :directory?) + remove(sass_cache, :checker_func => :directory?) + end + + def remove(filename, checker_func: :file?) + if File.public_send(checker_func, filename) + Jekyll.logger.info "Cleaner:", "Removing #{filename}..." + FileUtils.rm_rf(filename) + else + Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}." + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/doctor.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/doctor.rb new file mode 100644 index 0000000..7e01293 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/doctor.rb @@ -0,0 +1,177 @@ +# frozen_string_literal: true + +module Jekyll + module Commands + class Doctor < Command + class << self + def init_with_program(prog) + prog.command(:doctor) do |c| + c.syntax "doctor" + c.description "Search site and print specific deprecation warnings" + c.alias(:hyde) + + c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, + "Custom configuration file" + + c.action do |_, options| + Jekyll::Commands::Doctor.process(options) + end + end + end + + def process(options) + site = Jekyll::Site.new(configuration_from_options(options)) + site.reset + site.read + site.generate + + if healthy?(site) + Jekyll.logger.info "Your test results", "are in. Everything looks fine." + else + abort + end + end + + def healthy?(site) + [ + fsnotify_buggy?(site), + !deprecated_relative_permalinks(site), + !conflicting_urls(site), + !urls_only_differ_by_case(site), + proper_site_url?(site), + properly_gathered_posts?(site), + ].all? + end + + def properly_gathered_posts?(site) + return true if site.config["collections_dir"].empty? + + posts_at_root = site.in_source_dir("_posts") + return true unless File.directory?(posts_at_root) + + Jekyll.logger.warn "Warning:", + "Detected '_posts' directory outside custom `collections_dir`!" + Jekyll.logger.warn "", + "Please move '#{posts_at_root}' into the custom directory at " \ + "'#{site.in_source_dir(site.config["collections_dir"])}'" + false + end + + def deprecated_relative_permalinks(site) + if site.config["relative_permalinks"] + Jekyll::Deprecator.deprecation_message "Your site still uses relative permalinks, " \ + "which was removed in Jekyll v3.0.0." + true + end + end + + def conflicting_urls(site) + conflicting_urls = false + destination_map(site).each do |dest, paths| + next unless paths.size > 1 + + conflicting_urls = true + Jekyll.logger.warn "Conflict:", + "The following destination is shared by multiple files." + Jekyll.logger.warn "", "The written file may end up with unexpected contents." + Jekyll.logger.warn "", dest.to_s.cyan + paths.each { |path| Jekyll.logger.warn "", " - #{path}" } + Jekyll.logger.warn "" + end + conflicting_urls + end + + def fsnotify_buggy?(_site) + return true unless Utils::Platforms.osx? + + if Dir.pwd != `pwd`.strip + Jekyll.logger.error <<~STR + We have detected that there might be trouble using fsevent on your + operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug) + for possible work arounds or you can work around it immediately + with `--force-polling`. + STR + + false + end + + true + end + + def urls_only_differ_by_case(site) + urls_only_differ_by_case = false + urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest) + urls.each_value do |real_urls| + next unless real_urls.uniq.size > 1 + + urls_only_differ_by_case = true + Jekyll.logger.warn "Warning:", "The following URLs only differ by case. On a " \ + "case-insensitive file system one of the URLs will be " \ + "overwritten by the other: #{real_urls.join(", ")}" + end + urls_only_differ_by_case + end + + def proper_site_url?(site) + url = site.config["url"] + [ + url_exists?(url), + url_valid?(url), + url_absolute(url), + ].all? + end + + private + + def destination_map(site) + {}.tap do |result| + site.each_site_file do |thing| + next if allow_used_permalink?(thing) + + dest_path = thing.destination(site.dest) + (result[dest_path] ||= []) << thing.path + end + end + end + + def allow_used_permalink?(item) + defined?(JekyllRedirectFrom) && item.is_a?(JekyllRedirectFrom::RedirectPage) + end + + def case_insensitive_urls(things, destination) + things.each_with_object({}) do |thing, memo| + dest = thing.destination(destination) + (memo[dest.downcase] ||= []) << dest + end + end + + def url_exists?(url) + return true unless url.nil? || url.empty? + + Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, you may " \ + "encounter problems with some plugins." + false + end + + def url_valid?(url) + Addressable::URI.parse(url) + true + # Addressable::URI#parse only raises a TypeError + # https://github.com/sporkmonger/addressable/blob/0a0e96acb17225f9b1c9cab0bad332b448934c9a/lib/addressable/uri.rb#L103 + rescue TypeError + Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, " \ + "check the value of `url` in your config file." + false + end + + def url_absolute(url) + return true if url.is_a?(String) && Addressable::URI.parse(url).absolute? + + Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, " \ + "check the value of `url` in your config file." + false + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/help.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/help.rb new file mode 100644 index 0000000..90403df --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/help.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Jekyll + module Commands + class Help < Command + class << self + def init_with_program(prog) + prog.command(:help) do |c| + c.syntax "help [subcommand]" + c.description "Show the help message, optionally for a given subcommand." + + c.action do |args, _| + cmd = (args.first || "").to_sym + if args.empty? + Jekyll.logger.info prog.to_s + elsif prog.has_command? cmd + Jekyll.logger.info prog.commands[cmd].to_s + else + invalid_command(prog, cmd) + abort + end + end + end + end + + def invalid_command(prog, cmd) + Jekyll.logger.error "Error:", + "Hmm... we don't know what the '#{cmd}' command is." + Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ") + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/new.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/new.rb new file mode 100644 index 0000000..0a00f26 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/new.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true + +require "erb" + +module Jekyll + module Commands + class New < Command + class << self + def init_with_program(prog) + prog.command(:new) do |c| + c.syntax "new PATH" + c.description "Creates a new Jekyll site scaffold in PATH" + + c.option "force", "--force", "Force creation even if PATH already exists" + c.option "blank", "--blank", "Creates scaffolding but with empty files" + c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'" + + c.action do |args, options| + Jekyll::Commands::New.process(args, options) + end + end + end + + def process(args, options = {}) + raise ArgumentError, "You must specify a path." if args.empty? + + new_blog_path = File.expand_path(args.join(" "), Dir.pwd) + FileUtils.mkdir_p new_blog_path + if preserve_source_location?(new_blog_path, options) + Jekyll.logger.error "Conflict:", "#{new_blog_path} exists and is not empty." + Jekyll.logger.abort_with "", "Ensure #{new_blog_path} is empty or else try again " \ + "with `--force` to proceed and overwrite any files." + end + + if options["blank"] + create_blank_site new_blog_path + else + create_site new_blog_path + end + + after_install(new_blog_path, options) + end + + def blank_template + File.expand_path("../../blank_template", __dir__) + end + + def create_blank_site(path) + FileUtils.cp_r blank_template + "/.", path + FileUtils.chmod_R "u+w", path + + Dir.chdir(path) do + FileUtils.mkdir(%w(_data _drafts _includes _posts)) + end + end + + def scaffold_post_content + ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result + end + + # Internal: Gets the filename of the sample post to be created + # + # Returns the filename of the sample post, as a String + def initialized_post_name + "_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-jekyll.markdown" + end + + private + + def gemfile_contents + <<~RUBY + source "https://rubygems.org" + # Hello! This is where you manage which Jekyll version is used to run. + # When you want to use a different version, change it below, save the + # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: + # + # bundle exec jekyll serve + # + # This will help ensure the proper Jekyll version is running. + # Happy Jekylling! + gem "jekyll", "~> #{Jekyll::VERSION}" + # This is the default theme for new Jekyll sites. You may change this to anything you like. + gem "minima", "~> 2.5" + # If you want to use GitHub Pages, remove the "gem "jekyll"" above and + # uncomment the line below. To upgrade, run `bundle update github-pages`. + # gem "github-pages", group: :jekyll_plugins + # If you have any plugins, put them here! + group :jekyll_plugins do + gem "jekyll-feed", "~> 0.12" + end + + # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem + # and associated library. + platforms :mingw, :x64_mingw, :mswin, :jruby do + gem "tzinfo", ">= 1", "< 3" + gem "tzinfo-data" + end + + # Performance-booster for watching directories on Windows + gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] + + # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem + # do not have a Java counterpart. + gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] + RUBY + end + + def create_site(new_blog_path) + create_sample_files new_blog_path + + File.write(File.expand_path(initialized_post_name, new_blog_path), scaffold_post_content) + + File.write(File.expand_path("Gemfile", new_blog_path), gemfile_contents) + end + + def preserve_source_location?(path, options) + !options["force"] && !Dir["#{path}/**/*"].empty? + end + + def create_sample_files(path) + FileUtils.cp_r site_template + "/.", path + FileUtils.chmod_R "u+w", path + FileUtils.rm File.expand_path(scaffold_path, path) + end + + def site_template + File.expand_path("../../site_template", __dir__) + end + + def scaffold_path + "_posts/0000-00-00-welcome-to-jekyll.markdown.erb" + end + + # After a new blog has been created, print a success notification and + # then automatically execute bundle install from within the new blog dir + # unless the user opts to generate a blank blog or skip 'bundle install'. + + def after_install(path, options = {}) + unless options["blank"] || options["skip-bundle"] + begin + require "bundler" + bundle_install path + rescue LoadError + Jekyll.logger.info "Could not load Bundler. Bundle install skipped." + end + end + + Jekyll.logger.info "New jekyll site installed in #{path.cyan}." + Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"] + end + + def bundle_install(path) + Jekyll.logger.info "Running bundle install in #{path.cyan}..." + Dir.chdir(path) do + exe = Gem.bin_path("bundler", "bundle") + process, output = Jekyll::Utils::Exec.run("ruby", exe, "install") + + output.to_s.each_line do |line| + Jekyll.logger.info("Bundler:".green, line.strip) unless line.to_s.empty? + end + + raise SystemExit unless process.success? + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/new_theme.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/new_theme.rb new file mode 100644 index 0000000..3419d17 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/new_theme.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require "erb" + +module Jekyll + module Commands + class NewTheme < Jekyll::Command + class << self + def init_with_program(prog) + prog.command(:"new-theme") do |c| + c.syntax "new-theme NAME" + c.description "Creates a new Jekyll theme scaffold" + c.option "code_of_conduct", "-c", "--code-of-conduct", + "Include a Code of Conduct. (defaults to false)" + + c.action do |args, opts| + Jekyll::Commands::NewTheme.process(args, opts) + end + end + end + + def process(args, opts) + if !args || args.empty? + raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name." + end + + new_theme_name = args.join("_") + theme = Jekyll::ThemeBuilder.new(new_theme_name, opts) + Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." if theme.path.exist? + + theme.create! + Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}, " \ + "is ready for you in #{theme.path.to_s.cyan}!" + Jekyll.logger.info "For help getting started, read #{theme.path}/README.md." + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve.rb new file mode 100644 index 0000000..4600130 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve.rb @@ -0,0 +1,367 @@ +# frozen_string_literal: true + +module Jekyll + module Commands + class Serve < Command + # Similar to the pattern in Utils::ThreadEvent except we are maintaining the + # state of @running instead of just signaling an event. We have to maintain this + # state since Serve is just called via class methods instead of an instance + # being created each time. + @mutex = Mutex.new + @run_cond = ConditionVariable.new + @running = false + + class << self + COMMAND_OPTIONS = { + "ssl_cert" => ["--ssl-cert [CERT]", "X.509 (SSL) certificate."], + "host" => ["host", "-H", "--host [HOST]", "Host to bind to"], + "open_url" => ["-o", "--open-url", "Launch your site in a browser"], + "detach" => ["-B", "--detach", + "Run the server in the background",], + "ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."], + "port" => ["-P", "--port [PORT]", "Port to listen on"], + "show_dir_listing" => ["--show-dir-listing", + "Show a directory listing instead of loading " \ + "your index file.",], + "skip_initial_build" => ["skip_initial_build", "--skip-initial-build", + "Skips the initial site build which occurs before " \ + "the server is started.",], + "livereload" => ["-l", "--livereload", + "Use LiveReload to automatically refresh browsers",], + "livereload_ignore" => ["--livereload-ignore ignore GLOB1[,GLOB2[,...]]", + Array, + "Files for LiveReload to ignore. " \ + "Remember to quote the values so your shell " \ + "won't expand them",], + "livereload_min_delay" => ["--livereload-min-delay [SECONDS]", + "Minimum reload delay",], + "livereload_max_delay" => ["--livereload-max-delay [SECONDS]", + "Maximum reload delay",], + "livereload_port" => ["--livereload-port [PORT]", Integer, + "Port for LiveReload to listen on",], + }.freeze + + DIRECTORY_INDEX = %w( + index.htm + index.html + index.rhtml + index.xht + index.xhtml + index.cgi + index.xml + index.json + ).freeze + + LIVERELOAD_PORT = 35_729 + LIVERELOAD_DIR = File.join(__dir__, "serve", "livereload_assets") + + attr_reader :mutex, :run_cond, :running + alias_method :running?, :running + + def init_with_program(prog) + prog.command(:serve) do |cmd| + cmd.description "Serve your site locally" + cmd.syntax "serve [options]" + cmd.alias :server + cmd.alias :s + + add_build_options(cmd) + COMMAND_OPTIONS.each do |key, val| + cmd.option key, *val + end + + cmd.action do |_, opts| + opts["livereload_port"] ||= LIVERELOAD_PORT + opts["serving"] = true + opts["watch"] = true unless opts.key?("watch") + + # Set the reactor to nil so any old reactor will be GCed. + # We can't unregister a hook so while running tests we don't want to + # inadvertently keep using a reactor created by a previous test. + @reload_reactor = nil + + config = configuration_from_options(opts) + config["url"] = default_url(config) if Jekyll.env == "development" + + process_with_graceful_fail(cmd, config, Build, Serve) + end + end + end + + # + + def process(opts) + opts = configuration_from_options(opts) + destination = opts["destination"] + if opts["livereload"] + validate_options(opts) + register_reload_hooks(opts) + end + setup(destination) + + start_up_webrick(opts, destination) + end + + def shutdown + @server.shutdown if running? + end + + # Perform logical validation of CLI options + + private + + def validate_options(opts) + if opts["livereload"] + if opts["detach"] + Jekyll.logger.warn "Warning:", "--detach and --livereload are mutually exclusive. " \ + "Choosing --livereload" + opts["detach"] = false + end + if opts["ssl_cert"] || opts["ssl_key"] + # This is not technically true. LiveReload works fine over SSL, but + # EventMachine's SSL support in Windows requires building the gem's + # native extensions against OpenSSL and that proved to be a process + # so tedious that expecting users to do it is a non-starter. + Jekyll.logger.abort_with "Error:", "LiveReload does not support SSL" + end + unless opts["watch"] + # Using livereload logically implies you want to watch the files + opts["watch"] = true + end + elsif %w(livereload_min_delay + livereload_max_delay + livereload_ignore + livereload_port).any? { |o| opts[o] } + Jekyll.logger.abort_with "--livereload-min-delay, --livereload-max-delay, " \ + "--livereload-ignore, and --livereload-port require " \ + "the --livereload option." + end + end + + # rubocop:disable Metrics/AbcSize + def register_reload_hooks(opts) + require_relative "serve/live_reload_reactor" + @reload_reactor = LiveReloadReactor.new + + Jekyll::Hooks.register(:site, :post_render) do |site| + @changed_pages = [] + site.each_site_file do |item| + @changed_pages << item if site.regenerator.regenerate?(item) + end + end + + # A note on ignoring files: LiveReload errs on the side of reloading when it + # comes to the message it gets. If, for example, a page is ignored but a CSS + # file linked in the page isn't, the page will still be reloaded if the CSS + # file is contained in the message sent to LiveReload. Additionally, the + # path matching is very loose so that a message to reload "/" will always + # lead the page to reload since every page starts with "/". + Jekyll::Hooks.register(:site, :post_write) do + if @changed_pages && @reload_reactor && @reload_reactor.running? + ignore, @changed_pages = @changed_pages.partition do |p| + Array(opts["livereload_ignore"]).any? do |filter| + File.fnmatch(filter, Jekyll.sanitized_path(p.relative_path)) + end + end + Jekyll.logger.debug "LiveReload:", "Ignoring #{ignore.map(&:relative_path)}" + @reload_reactor.reload(@changed_pages) + end + @changed_pages = nil + end + end + # rubocop:enable Metrics/AbcSize + + # Do a base pre-setup of WEBRick so that everything is in place + # when we get ready to party, checking for an setting up an error page + # and making sure our destination exists. + # + # rubocop:disable Security/IoMethods + def setup(destination) + require_relative "serve/servlet" + + FileUtils.mkdir_p(destination) + if File.exist?(File.join(destination, "404.html")) + WEBrick::HTTPResponse.class_eval do + def create_error_page + @header["Content-Type"] = "text/html; charset=UTF-8" + @body = IO.read(File.join(@config[:DocumentRoot], "404.html")) + end + end + end + end + # rubocop:enable Security/IoMethods + + def webrick_opts(opts) + opts = { + :JekyllOptions => opts, + :DoNotReverseLookup => true, + :MimeTypes => mime_types, + :MimeTypesCharset => mime_types_charset, + :DocumentRoot => opts["destination"], + :StartCallback => start_callback(opts["detach"]), + :StopCallback => stop_callback(opts["detach"]), + :BindAddress => opts["host"], + :Port => opts["port"], + :DirectoryIndex => DIRECTORY_INDEX, + } + + opts[:DirectoryIndex] = [] if opts[:JekyllOptions]["show_dir_listing"] + + enable_ssl(opts) + enable_logging(opts) + opts + end + + def start_up_webrick(opts, destination) + @reload_reactor.start(opts) if opts["livereload"] + + @server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") } + @server.mount(opts["baseurl"].to_s, Servlet, destination, file_handler_opts) + + Jekyll.logger.info "Server address:", server_address(@server, opts) + launch_browser @server, opts if opts["open_url"] + boot_or_detach @server, opts + end + + # Recreate NondisclosureName under utf-8 circumstance + def file_handler_opts + WEBrick::Config::FileHandler.merge( + :FancyIndexing => true, + :NondisclosureName => [ + ".ht*", "~*", + ] + ) + end + + def server_address(server, options = {}) + format_url( + server.config[:SSLEnable], + server.config[:BindAddress], + server.config[:Port], + options["baseurl"] + ) + end + + def format_url(ssl_enabled, address, port, baseurl = nil) + format("%s://%
s:%i%s", + :prefix => ssl_enabled ? "https" : "http", + :address => address, + :port => port, + :baseurl => baseurl ? "#{baseurl}/" : "") + end + + def default_url(opts) + config = configuration_from_options(opts) + format_url( + config["ssl_cert"] && config["ssl_key"], + config["host"] == "127.0.0.1" ? "localhost" : config["host"], + config["port"] + ) + end + + def launch_browser(server, opts) + address = server_address(server, opts) + return system "start", address if Utils::Platforms.windows? + return system "xdg-open", address if Utils::Platforms.linux? + return system "open", address if Utils::Platforms.osx? + + Jekyll.logger.error "Refusing to launch browser. Platform launcher unknown." + end + + # Keep in our area with a thread or detach the server as requested + # by the user. This method determines what we do based on what you + # ask us to do. + def boot_or_detach(server, opts) + if opts["detach"] + pid = Process.fork do + server.start + end + + Process.detach(pid) + Jekyll.logger.info "Server detached with pid '#{pid}'.", + "Run `pkill -f jekyll' or `kill -9 #{pid}' to stop the server." + else + t = Thread.new { server.start } + trap("INT") { server.shutdown } + t.join + end + end + + # Make the stack verbose if the user requests it. + def enable_logging(opts) + opts[:AccessLog] = [] + level = WEBrick::Log.const_get(opts[:JekyllOptions]["verbose"] ? :DEBUG : :WARN) + opts[:Logger] = WEBrick::Log.new($stdout, level) + end + + # Add SSL to the stack if the user triggers --enable-ssl and they + # provide both types of certificates commonly needed. Raise if they + # forget to add one of the certificates. + def enable_ssl(opts) + cert, key, src = + opts[:JekyllOptions].values_at("ssl_cert", "ssl_key", "source") + + return if cert.nil? && key.nil? + raise "Missing --ssl_cert or --ssl_key. Both are required." unless cert && key + + require "openssl" + require "webrick/https" + + opts[:SSLCertificate] = OpenSSL::X509::Certificate.new(read_file(src, cert)) + begin + opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(read_file(src, key)) + rescue StandardError + if defined?(OpenSSL::PKey::EC) + opts[:SSLPrivateKey] = OpenSSL::PKey::EC.new(read_file(src, key)) + else + raise + end + end + opts[:SSLEnable] = true + end + + def start_callback(detached) + unless detached + proc do + mutex.synchronize do + # Block until EventMachine reactor starts + @reload_reactor&.started_event&.wait + @running = true + Jekyll.logger.info("Server running...", "press ctrl-c to stop.") + @run_cond.broadcast + end + end + end + end + + def stop_callback(detached) + unless detached + proc do + mutex.synchronize do + unless @reload_reactor.nil? + @reload_reactor.stop + @reload_reactor.stopped_event.wait + end + @running = false + @run_cond.broadcast + end + end + end + end + + def mime_types + file = File.expand_path("../mime.types", __dir__) + WEBrick::HTTPUtils.load_mime_types(file) + end + + def mime_types_charset + SafeYAML.load_file(File.expand_path("serve/mime_types_charset.json", __dir__)) + end + + def read_file(source_dir, file_path) + File.read(Jekyll.sanitized_path(source_dir, file_path)) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/live_reload_reactor.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/live_reload_reactor.rb new file mode 100644 index 0000000..78f9408 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/live_reload_reactor.rb @@ -0,0 +1,119 @@ +# frozen_string_literal: true + +require "em-websocket" + +require_relative "websockets" + +module Jekyll + module Commands + class Serve + class LiveReloadReactor + attr_reader :started_event, :stopped_event, :thread + + def initialize + @websockets = [] + @connections_count = 0 + @started_event = Utils::ThreadEvent.new + @stopped_event = Utils::ThreadEvent.new + end + + def stop + # There is only one EventMachine instance per Ruby process so stopping + # it here will stop the reactor thread we have running. + EM.stop if EM.reactor_running? + Jekyll.logger.debug "LiveReload Server:", "halted" + end + + def running? + EM.reactor_running? + end + + def handle_websockets_event(websocket) + websocket.onopen { |handshake| connect(websocket, handshake) } + websocket.onclose { disconnect(websocket) } + websocket.onmessage { |msg| print_message(msg) } + websocket.onerror { |error| log_error(error) } + end + + def start(opts) + @thread = Thread.new do + # Use epoll if the kernel supports it + EM.epoll + EM.run do + EM.error_handler { |e| log_error(e) } + + EM.start_server( + opts["host"], + opts["livereload_port"], + HttpAwareConnection, + opts + ) do |ws| + handle_websockets_event(ws) + end + + # Notify blocked threads that EventMachine has started or shutdown + EM.schedule { @started_event.set } + EM.add_shutdown_hook { @stopped_event.set } + + Jekyll.logger.info "LiveReload address:", + "http://#{opts["host"]}:#{opts["livereload_port"]}" + end + end + @thread.abort_on_exception = true + end + + # For a description of the protocol see + # http://feedback.livereload.com/knowledgebase/articles/86174-livereload-protocol + def reload(pages) + pages.each do |p| + json_message = JSON.dump( + :command => "reload", + :path => p.url, + :liveCSS => true + ) + + Jekyll.logger.debug "LiveReload:", "Reloading URL #{p.url.inspect}" + @websockets.each { |ws| ws.send(json_message) } + end + end + + private + + def connect(websocket, handshake) + @connections_count += 1 + if @connections_count == 1 + message = "Browser connected" + message += " over SSL/TLS" if handshake.secure? + Jekyll.logger.info "LiveReload:", message + end + websocket.send( + JSON.dump( + :command => "hello", + :protocols => ["http://livereload.com/protocols/official-7"], + :serverName => "jekyll" + ) + ) + + @websockets << websocket + end + + def disconnect(websocket) + @websockets.delete(websocket) + end + + def print_message(json_message) + msg = JSON.parse(json_message) + # Not sure what the 'url' command even does in LiveReload. The spec is silent + # on its purpose. + Jekyll.logger.info "LiveReload:", "Browser URL: #{msg["url"]}" if msg["command"] == "url" + end + + def log_error(error) + Jekyll.logger.error "LiveReload experienced an error. " \ + "Run with --trace for more information." + raise error + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/livereload_assets/livereload.js b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/livereload_assets/livereload.js new file mode 100644 index 0000000..eee60ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/livereload_assets/livereload.js @@ -0,0 +1,1183 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o tag"); + return; + } + } + this.reloader = new Reloader(this.window, this.console, Timer); + this.connector = new Connector(this.options, this.WebSocket, Timer, { + connecting: (function(_this) { + return function() {}; + })(this), + socketConnected: (function(_this) { + return function() {}; + })(this), + connected: (function(_this) { + return function(protocol) { + var _base; + if (typeof (_base = _this.listeners).connect === "function") { + _base.connect(); + } + _this.log("LiveReload is connected to " + _this.options.host + ":" + _this.options.port + " (protocol v" + protocol + ")."); + return _this.analyze(); + }; + })(this), + error: (function(_this) { + return function(e) { + if (e instanceof ProtocolError) { + if (typeof console !== "undefined" && console !== null) { + return console.log("" + e.message + "."); + } + } else { + if (typeof console !== "undefined" && console !== null) { + return console.log("LiveReload internal error: " + e.message); + } + } + }; + })(this), + disconnected: (function(_this) { + return function(reason, nextDelay) { + var _base; + if (typeof (_base = _this.listeners).disconnect === "function") { + _base.disconnect(); + } + switch (reason) { + case 'cannot-connect': + return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + ", will retry in " + nextDelay + " sec."); + case 'broken': + return _this.log("LiveReload disconnected from " + _this.options.host + ":" + _this.options.port + ", reconnecting in " + nextDelay + " sec."); + case 'handshake-timeout': + return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake timeout), will retry in " + nextDelay + " sec."); + case 'handshake-failed': + return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake failed), will retry in " + nextDelay + " sec."); + case 'manual': + break; + case 'error': + break; + default: + return _this.log("LiveReload disconnected from " + _this.options.host + ":" + _this.options.port + " (" + reason + "), reconnecting in " + nextDelay + " sec."); + } + }; + })(this), + message: (function(_this) { + return function(message) { + switch (message.command) { + case 'reload': + return _this.performReload(message); + case 'alert': + return _this.performAlert(message); + } + }; + })(this) + }); + this.initialized = true; + } + + LiveReload.prototype.on = function(eventName, handler) { + return this.listeners[eventName] = handler; + }; + + LiveReload.prototype.log = function(message) { + return this.console.log("" + message); + }; + + LiveReload.prototype.performReload = function(message) { + var _ref, _ref1; + this.log("LiveReload received reload request: " + (JSON.stringify(message, null, 2))); + return this.reloader.reload(message.path, { + liveCSS: (_ref = message.liveCSS) != null ? _ref : true, + liveImg: (_ref1 = message.liveImg) != null ? _ref1 : true, + originalPath: message.originalPath || '', + overrideURL: message.overrideURL || '', + serverURL: "http://" + this.options.host + ":" + this.options.port + }); + }; + + LiveReload.prototype.performAlert = function(message) { + return alert(message.message); + }; + + LiveReload.prototype.shutDown = function() { + var _base; + if (!this.initialized) { + return; + } + this.connector.disconnect(); + this.log("LiveReload disconnected."); + return typeof (_base = this.listeners).shutdown === "function" ? _base.shutdown() : void 0; + }; + + LiveReload.prototype.hasPlugin = function(identifier) { + return !!this.pluginIdentifiers[identifier]; + }; + + LiveReload.prototype.addPlugin = function(pluginClass) { + var plugin; + if (!this.initialized) { + return; + } + if (this.hasPlugin(pluginClass.identifier)) { + return; + } + this.pluginIdentifiers[pluginClass.identifier] = true; + plugin = new pluginClass(this.window, { + _livereload: this, + _reloader: this.reloader, + _connector: this.connector, + console: this.console, + Timer: Timer, + generateCacheBustUrl: (function(_this) { + return function(url) { + return _this.reloader.generateCacheBustUrl(url); + }; + })(this) + }); + this.plugins.push(plugin); + this.reloader.addPlugin(plugin); + }; + + LiveReload.prototype.analyze = function() { + var plugin, pluginData, pluginsData, _i, _len, _ref; + if (!this.initialized) { + return; + } + if (!(this.connector.protocol >= 7)) { + return; + } + pluginsData = {}; + _ref = this.plugins; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + plugin = _ref[_i]; + pluginsData[plugin.constructor.identifier] = pluginData = (typeof plugin.analyze === "function" ? plugin.analyze() : void 0) || {}; + pluginData.version = plugin.constructor.version; + } + this.connector.sendCommand({ + command: 'info', + plugins: pluginsData, + url: this.window.location.href + }); + }; + + return LiveReload; + + })(); + +}).call(this); + +},{"./connector":1,"./options":5,"./reloader":7,"./timer":9}],5:[function(require,module,exports){ +(function() { + var Options; + + exports.Options = Options = (function() { + function Options() { + this.https = false; + this.host = null; + this.port = 35729; + this.snipver = null; + this.ext = null; + this.extver = null; + this.mindelay = 1000; + this.maxdelay = 60000; + this.handshake_timeout = 5000; + } + + Options.prototype.set = function(name, value) { + if (typeof value === 'undefined') { + return; + } + if (!isNaN(+value)) { + value = +value; + } + return this[name] = value; + }; + + return Options; + + })(); + + Options.extract = function(document) { + var element, keyAndValue, m, mm, options, pair, src, _i, _j, _len, _len1, _ref, _ref1; + _ref = document.getElementsByTagName('script'); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + element = _ref[_i]; + if ((src = element.src) && (m = src.match(/^[^:]+:\/\/(.*)\/z?livereload\.js(?:\?(.*))?$/))) { + options = new Options(); + options.https = src.indexOf("https") === 0; + if (mm = m[1].match(/^([^\/:]+)(?::(\d+))?$/)) { + options.host = mm[1]; + if (mm[2]) { + options.port = parseInt(mm[2], 10); + } + } + if (m[2]) { + _ref1 = m[2].split('&'); + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + pair = _ref1[_j]; + if ((keyAndValue = pair.split('=')).length > 1) { + options.set(keyAndValue[0].replace(/-/g, '_'), keyAndValue.slice(1).join('=')); + } + } + } + return options; + } + } + return null; + }; + +}).call(this); + +},{}],6:[function(require,module,exports){ +(function() { + var PROTOCOL_6, PROTOCOL_7, Parser, ProtocolError, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + + exports.PROTOCOL_6 = PROTOCOL_6 = 'http://livereload.com/protocols/official-6'; + + exports.PROTOCOL_7 = PROTOCOL_7 = 'http://livereload.com/protocols/official-7'; + + exports.ProtocolError = ProtocolError = (function() { + function ProtocolError(reason, data) { + this.message = "LiveReload protocol error (" + reason + ") after receiving data: \"" + data + "\"."; + } + + return ProtocolError; + + })(); + + exports.Parser = Parser = (function() { + function Parser(handlers) { + this.handlers = handlers; + this.reset(); + } + + Parser.prototype.reset = function() { + return this.protocol = null; + }; + + Parser.prototype.process = function(data) { + var command, e, message, options, _ref; + try { + if (this.protocol == null) { + if (data.match(/^!!ver:([\d.]+)$/)) { + this.protocol = 6; + } else if (message = this._parseMessage(data, ['hello'])) { + if (!message.protocols.length) { + throw new ProtocolError("no protocols specified in handshake message"); + } else if (__indexOf.call(message.protocols, PROTOCOL_7) >= 0) { + this.protocol = 7; + } else if (__indexOf.call(message.protocols, PROTOCOL_6) >= 0) { + this.protocol = 6; + } else { + throw new ProtocolError("no supported protocols found"); + } + } + return this.handlers.connected(this.protocol); + } else if (this.protocol === 6) { + message = JSON.parse(data); + if (!message.length) { + throw new ProtocolError("protocol 6 messages must be arrays"); + } + command = message[0], options = message[1]; + if (command !== 'refresh') { + throw new ProtocolError("unknown protocol 6 command"); + } + return this.handlers.message({ + command: 'reload', + path: options.path, + liveCSS: (_ref = options.apply_css_live) != null ? _ref : true + }); + } else { + message = this._parseMessage(data, ['reload', 'alert']); + return this.handlers.message(message); + } + } catch (_error) { + e = _error; + if (e instanceof ProtocolError) { + return this.handlers.error(e); + } else { + throw e; + } + } + }; + + Parser.prototype._parseMessage = function(data, validCommands) { + var e, message, _ref; + try { + message = JSON.parse(data); + } catch (_error) { + e = _error; + throw new ProtocolError('unparsable JSON', data); + } + if (!message.command) { + throw new ProtocolError('missing "command" key', data); + } + if (_ref = message.command, __indexOf.call(validCommands, _ref) < 0) { + throw new ProtocolError("invalid command '" + message.command + "', only valid commands are: " + (validCommands.join(', ')) + ")", data); + } + return message; + }; + + return Parser; + + })(); + +}).call(this); + +},{}],7:[function(require,module,exports){ +(function() { + var IMAGE_STYLES, Reloader, numberOfMatchingSegments, pathFromUrl, pathsMatch, pickBestMatch, splitUrl; + + splitUrl = function(url) { + var hash, index, params; + if ((index = url.indexOf('#')) >= 0) { + hash = url.slice(index); + url = url.slice(0, index); + } else { + hash = ''; + } + if ((index = url.indexOf('?')) >= 0) { + params = url.slice(index); + url = url.slice(0, index); + } else { + params = ''; + } + return { + url: url, + params: params, + hash: hash + }; + }; + + pathFromUrl = function(url) { + var path; + url = splitUrl(url).url; + if (url.indexOf('file://') === 0) { + path = url.replace(/^file:\/\/(localhost)?/, ''); + } else { + path = url.replace(/^([^:]+:)?\/\/([^:\/]+)(:\d*)?\//, '/'); + } + return decodeURIComponent(path); + }; + + pickBestMatch = function(path, objects, pathFunc) { + var bestMatch, object, score, _i, _len; + bestMatch = { + score: 0 + }; + for (_i = 0, _len = objects.length; _i < _len; _i++) { + object = objects[_i]; + score = numberOfMatchingSegments(path, pathFunc(object)); + if (score > bestMatch.score) { + bestMatch = { + object: object, + score: score + }; + } + } + if (bestMatch.score > 0) { + return bestMatch; + } else { + return null; + } + }; + + numberOfMatchingSegments = function(path1, path2) { + var comps1, comps2, eqCount, len; + path1 = path1.replace(/^\/+/, '').toLowerCase(); + path2 = path2.replace(/^\/+/, '').toLowerCase(); + if (path1 === path2) { + return 10000; + } + comps1 = path1.split('/').reverse(); + comps2 = path2.split('/').reverse(); + len = Math.min(comps1.length, comps2.length); + eqCount = 0; + while (eqCount < len && comps1[eqCount] === comps2[eqCount]) { + ++eqCount; + } + return eqCount; + }; + + pathsMatch = function(path1, path2) { + return numberOfMatchingSegments(path1, path2) > 0; + }; + + IMAGE_STYLES = [ + { + selector: 'background', + styleNames: ['backgroundImage'] + }, { + selector: 'border', + styleNames: ['borderImage', 'webkitBorderImage', 'MozBorderImage'] + } + ]; + + exports.Reloader = Reloader = (function() { + function Reloader(window, console, Timer) { + this.window = window; + this.console = console; + this.Timer = Timer; + this.document = this.window.document; + this.importCacheWaitPeriod = 200; + this.plugins = []; + } + + Reloader.prototype.addPlugin = function(plugin) { + return this.plugins.push(plugin); + }; + + Reloader.prototype.analyze = function(callback) { + return results; + }; + + Reloader.prototype.reload = function(path, options) { + var plugin, _base, _i, _len, _ref; + this.options = options; + if ((_base = this.options).stylesheetReloadTimeout == null) { + _base.stylesheetReloadTimeout = 15000; + } + _ref = this.plugins; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + plugin = _ref[_i]; + if (plugin.reload && plugin.reload(path, options)) { + return; + } + } + if (options.liveCSS) { + if (path.match(/\.css$/i)) { + if (this.reloadStylesheet(path)) { + return; + } + } + } + if (options.liveImg) { + if (path.match(/\.(jpe?g|png|gif)$/i)) { + this.reloadImages(path); + return; + } + } + return this.reloadPage(); + }; + + Reloader.prototype.reloadPage = function() { + return this.window.document.location.reload(); + }; + + Reloader.prototype.reloadImages = function(path) { + var expando, img, selector, styleNames, styleSheet, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _results; + expando = this.generateUniqueString(); + _ref = this.document.images; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + img = _ref[_i]; + if (pathsMatch(path, pathFromUrl(img.src))) { + img.src = this.generateCacheBustUrl(img.src, expando); + } + } + if (this.document.querySelectorAll) { + for (_j = 0, _len1 = IMAGE_STYLES.length; _j < _len1; _j++) { + _ref1 = IMAGE_STYLES[_j], selector = _ref1.selector, styleNames = _ref1.styleNames; + _ref2 = this.document.querySelectorAll("[style*=" + selector + "]"); + for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { + img = _ref2[_k]; + this.reloadStyleImages(img.style, styleNames, path, expando); + } + } + } + if (this.document.styleSheets) { + _ref3 = this.document.styleSheets; + _results = []; + for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) { + styleSheet = _ref3[_l]; + _results.push(this.reloadStylesheetImages(styleSheet, path, expando)); + } + return _results; + } + }; + + Reloader.prototype.reloadStylesheetImages = function(styleSheet, path, expando) { + var e, rule, rules, styleNames, _i, _j, _len, _len1; + try { + rules = styleSheet != null ? styleSheet.cssRules : void 0; + } catch (_error) { + e = _error; + } + if (!rules) { + return; + } + for (_i = 0, _len = rules.length; _i < _len; _i++) { + rule = rules[_i]; + switch (rule.type) { + case CSSRule.IMPORT_RULE: + this.reloadStylesheetImages(rule.styleSheet, path, expando); + break; + case CSSRule.STYLE_RULE: + for (_j = 0, _len1 = IMAGE_STYLES.length; _j < _len1; _j++) { + styleNames = IMAGE_STYLES[_j].styleNames; + this.reloadStyleImages(rule.style, styleNames, path, expando); + } + break; + case CSSRule.MEDIA_RULE: + this.reloadStylesheetImages(rule, path, expando); + } + } + }; + + Reloader.prototype.reloadStyleImages = function(style, styleNames, path, expando) { + var newValue, styleName, value, _i, _len; + for (_i = 0, _len = styleNames.length; _i < _len; _i++) { + styleName = styleNames[_i]; + value = style[styleName]; + if (typeof value === 'string') { + newValue = value.replace(/\burl\s*\(([^)]*)\)/, (function(_this) { + return function(match, src) { + if (pathsMatch(path, pathFromUrl(src))) { + return "url(" + (_this.generateCacheBustUrl(src, expando)) + ")"; + } else { + return match; + } + }; + })(this)); + if (newValue !== value) { + style[styleName] = newValue; + } + } + } + }; + + Reloader.prototype.reloadStylesheet = function(path) { + var imported, link, links, match, style, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1; + links = (function() { + var _i, _len, _ref, _results; + _ref = this.document.getElementsByTagName('link'); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + link = _ref[_i]; + if (link.rel.match(/^stylesheet$/i) && !link.__LiveReload_pendingRemoval) { + _results.push(link); + } + } + return _results; + }).call(this); + imported = []; + _ref = this.document.getElementsByTagName('style'); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + style = _ref[_i]; + if (style.sheet) { + this.collectImportedStylesheets(style, style.sheet, imported); + } + } + for (_j = 0, _len1 = links.length; _j < _len1; _j++) { + link = links[_j]; + this.collectImportedStylesheets(link, link.sheet, imported); + } + if (this.window.StyleFix && this.document.querySelectorAll) { + _ref1 = this.document.querySelectorAll('style[data-href]'); + for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) { + style = _ref1[_k]; + links.push(style); + } + } + this.console.log("LiveReload found " + links.length + " LINKed stylesheets, " + imported.length + " @imported stylesheets"); + match = pickBestMatch(path, links.concat(imported), (function(_this) { + return function(l) { + return pathFromUrl(_this.linkHref(l)); + }; + })(this)); + if (match) { + if (match.object.rule) { + this.console.log("LiveReload is reloading imported stylesheet: " + match.object.href); + this.reattachImportedRule(match.object); + } else { + this.console.log("LiveReload is reloading stylesheet: " + (this.linkHref(match.object))); + this.reattachStylesheetLink(match.object); + } + } else { + this.console.log("LiveReload will reload all stylesheets because path '" + path + "' did not match any specific one"); + for (_l = 0, _len3 = links.length; _l < _len3; _l++) { + link = links[_l]; + this.reattachStylesheetLink(link); + } + } + return true; + }; + + Reloader.prototype.collectImportedStylesheets = function(link, styleSheet, result) { + var e, index, rule, rules, _i, _len; + try { + rules = styleSheet != null ? styleSheet.cssRules : void 0; + } catch (_error) { + e = _error; + } + if (rules && rules.length) { + for (index = _i = 0, _len = rules.length; _i < _len; index = ++_i) { + rule = rules[index]; + switch (rule.type) { + case CSSRule.CHARSET_RULE: + continue; + case CSSRule.IMPORT_RULE: + result.push({ + link: link, + rule: rule, + index: index, + href: rule.href + }); + this.collectImportedStylesheets(link, rule.styleSheet, result); + break; + default: + break; + } + } + } + }; + + Reloader.prototype.waitUntilCssLoads = function(clone, func) { + var callbackExecuted, executeCallback, poll; + callbackExecuted = false; + executeCallback = (function(_this) { + return function() { + if (callbackExecuted) { + return; + } + callbackExecuted = true; + return func(); + }; + })(this); + clone.onload = (function(_this) { + return function() { + _this.console.log("LiveReload: the new stylesheet has finished loading"); + _this.knownToSupportCssOnLoad = true; + return executeCallback(); + }; + })(this); + if (!this.knownToSupportCssOnLoad) { + (poll = (function(_this) { + return function() { + if (clone.sheet) { + _this.console.log("LiveReload is polling until the new CSS finishes loading..."); + return executeCallback(); + } else { + return _this.Timer.start(50, poll); + } + }; + })(this))(); + } + return this.Timer.start(this.options.stylesheetReloadTimeout, executeCallback); + }; + + Reloader.prototype.linkHref = function(link) { + return link.href || link.getAttribute('data-href'); + }; + + Reloader.prototype.reattachStylesheetLink = function(link) { + var clone, parent; + if (link.__LiveReload_pendingRemoval) { + return; + } + link.__LiveReload_pendingRemoval = true; + if (link.tagName === 'STYLE') { + clone = this.document.createElement('link'); + clone.rel = 'stylesheet'; + clone.media = link.media; + clone.disabled = link.disabled; + } else { + clone = link.cloneNode(false); + } + clone.href = this.generateCacheBustUrl(this.linkHref(link)); + parent = link.parentNode; + if (parent.lastChild === link) { + parent.appendChild(clone); + } else { + parent.insertBefore(clone, link.nextSibling); + } + return this.waitUntilCssLoads(clone, (function(_this) { + return function() { + var additionalWaitingTime; + if (/AppleWebKit/.test(navigator.userAgent)) { + additionalWaitingTime = 5; + } else { + additionalWaitingTime = 200; + } + return _this.Timer.start(additionalWaitingTime, function() { + var _ref; + if (!link.parentNode) { + return; + } + link.parentNode.removeChild(link); + clone.onreadystatechange = null; + return (_ref = _this.window.StyleFix) != null ? _ref.link(clone) : void 0; + }); + }; + })(this)); + }; + + Reloader.prototype.reattachImportedRule = function(_arg) { + var href, index, link, media, newRule, parent, rule, tempLink; + rule = _arg.rule, index = _arg.index, link = _arg.link; + parent = rule.parentStyleSheet; + href = this.generateCacheBustUrl(rule.href); + media = rule.media.length ? [].join.call(rule.media, ', ') : ''; + newRule = "@import url(\"" + href + "\") " + media + ";"; + rule.__LiveReload_newHref = href; + tempLink = this.document.createElement("link"); + tempLink.rel = 'stylesheet'; + tempLink.href = href; + tempLink.__LiveReload_pendingRemoval = true; + if (link.parentNode) { + link.parentNode.insertBefore(tempLink, link); + } + return this.Timer.start(this.importCacheWaitPeriod, (function(_this) { + return function() { + if (tempLink.parentNode) { + tempLink.parentNode.removeChild(tempLink); + } + if (rule.__LiveReload_newHref !== href) { + return; + } + parent.insertRule(newRule, index); + parent.deleteRule(index + 1); + rule = parent.cssRules[index]; + rule.__LiveReload_newHref = href; + return _this.Timer.start(_this.importCacheWaitPeriod, function() { + if (rule.__LiveReload_newHref !== href) { + return; + } + parent.insertRule(newRule, index); + return parent.deleteRule(index + 1); + }); + }; + })(this)); + }; + + Reloader.prototype.generateUniqueString = function() { + return 'livereload=' + Date.now(); + }; + + Reloader.prototype.generateCacheBustUrl = function(url, expando) { + var hash, oldParams, originalUrl, params, _ref; + if (expando == null) { + expando = this.generateUniqueString(); + } + _ref = splitUrl(url), url = _ref.url, hash = _ref.hash, oldParams = _ref.params; + if (this.options.overrideURL) { + if (url.indexOf(this.options.serverURL) < 0) { + originalUrl = url; + url = this.options.serverURL + this.options.overrideURL + "?url=" + encodeURIComponent(url); + this.console.log("LiveReload is overriding source URL " + originalUrl + " with " + url); + } + } + params = oldParams.replace(/(\?|&)livereload=(\d+)/, function(match, sep) { + return "" + sep + expando; + }); + if (params === oldParams) { + if (oldParams.length === 0) { + params = "?" + expando; + } else { + params = "" + oldParams + "&" + expando; + } + } + return url + params + hash; + }; + + return Reloader; + + })(); + +}).call(this); + +},{}],8:[function(require,module,exports){ +(function() { + var CustomEvents, LiveReload, k; + + CustomEvents = require('./customevents'); + + LiveReload = window.LiveReload = new (require('./livereload').LiveReload)(window); + + for (k in window) { + if (k.match(/^LiveReloadPlugin/)) { + LiveReload.addPlugin(window[k]); + } + } + + LiveReload.addPlugin(require('./less')); + + LiveReload.on('shutdown', function() { + return delete window.LiveReload; + }); + + LiveReload.on('connect', function() { + return CustomEvents.fire(document, 'LiveReloadConnect'); + }); + + LiveReload.on('disconnect', function() { + return CustomEvents.fire(document, 'LiveReloadDisconnect'); + }); + + CustomEvents.bind(document, 'LiveReloadShutDown', function() { + return LiveReload.shutDown(); + }); + +}).call(this); + +},{"./customevents":2,"./less":3,"./livereload":4}],9:[function(require,module,exports){ +(function() { + var Timer; + + exports.Timer = Timer = (function() { + function Timer(func) { + this.func = func; + this.running = false; + this.id = null; + this._handler = (function(_this) { + return function() { + _this.running = false; + _this.id = null; + return _this.func(); + }; + })(this); + } + + Timer.prototype.start = function(timeout) { + if (this.running) { + clearTimeout(this.id); + } + this.id = setTimeout(this._handler, timeout); + return this.running = true; + }; + + Timer.prototype.stop = function() { + if (this.running) { + clearTimeout(this.id); + this.running = false; + return this.id = null; + } + }; + + return Timer; + + })(); + + Timer.start = function(timeout, func) { + return setTimeout(func, timeout); + }; + +}).call(this); + +},{}]},{},[8]); diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/mime_types_charset.json b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/mime_types_charset.json new file mode 100644 index 0000000..017469b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/mime_types_charset.json @@ -0,0 +1,71 @@ +{ + "application/javascript": "UTF-8", + "application/json": "UTF-8", + "application/manifest+json": "UTF-8", + "application/vnd.syncml+xml": "UTF-8", + "application/vnd.syncml.dm+wbxml": "UTF-8", + "application/vnd.syncml.dm+xml": "UTF-8", + "application/vnd.syncml.dmddf+xml": "UTF-8", + "application/vnd.wap.wbxml": "UTF-8", + "text/cache-manifest": "UTF-8", + "text/calendar": "UTF-8", + "text/coffeescript": "UTF-8", + "text/css": "UTF-8", + "text/csv": "UTF-8", + "text/html": "UTF-8", + "text/jade": "UTF-8", + "text/jsx": "UTF-8", + "text/less": "UTF-8", + "text/markdown": "UTF-8", + "text/mathml": "UTF-8", + "text/mdx": "UTF-8", + "text/n3": "UTF-8", + "text/plain": "UTF-8", + "text/prs.lines.tag": "UTF-8", + "text/richtext": "UTF-8", + "text/sgml": "UTF-8", + "text/shex": "UTF-8", + "text/slim": "UTF-8", + "text/spdx": "UTF-8", + "text/stylus": "UTF-8", + "text/tab-separated-values": "UTF-8", + "text/troff": "UTF-8", + "text/turtle": "UTF-8", + "text/uri-list": "UTF-8", + "text/vcard": "UTF-8", + "text/vnd.curl": "UTF-8", + "text/vnd.curl.dcurl": "UTF-8", + "text/vnd.curl.mcurl": "UTF-8", + "text/vnd.curl.scurl": "UTF-8", + "text/vnd.familysearch.gedcom": "UTF-8", + "text/vnd.fly": "UTF-8", + "text/vnd.fmi.flexstor": "UTF-8", + "text/vnd.graphviz": "UTF-8", + "text/vnd.in3d.3dml": "UTF-8", + "text/vnd.in3d.spot": "UTF-8", + "text/vnd.sun.j2me.app-descriptor": "UTF-8", + "text/vnd.wap.wml": "UTF-8", + "text/vnd.wap.wmlscript": "UTF-8", + "text/vtt": "UTF-8", + "text/x-asm": "UTF-8", + "text/x-c": "UTF-8", + "text/x-component": "UTF-8", + "text/x-fortran": "UTF-8", + "text/x-handlebars-template": "UTF-8", + "text/x-java-source": "UTF-8", + "text/x-lua": "UTF-8", + "text/x-markdown": "UTF-8", + "text/x-nfo": "UTF-8", + "text/x-opml": "UTF-8", + "text/x-pascal": "UTF-8", + "text/x-processing": "UTF-8", + "text/x-sass": "UTF-8", + "text/x-scss": "UTF-8", + "text/x-setext": "UTF-8", + "text/x-sfv": "UTF-8", + "text/x-suse-ymp": "UTF-8", + "text/x-uuencode": "UTF-8", + "text/x-vcalendar": "UTF-8", + "text/x-vcard": "UTF-8", + "text/yaml": "UTF-8" +} diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/servlet.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/servlet.rb new file mode 100644 index 0000000..c8895e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/servlet.rb @@ -0,0 +1,206 @@ +# frozen_string_literal: true + +require "webrick" + +module Jekyll + module Commands + class Serve + # This class is used to determine if the Servlet should modify a served file + # to insert the LiveReload script tags + class SkipAnalyzer + BAD_USER_AGENTS = [%r!MSIE!].freeze + + def self.skip_processing?(request, response, options) + new(request, response, options).skip_processing? + end + + def initialize(request, response, options) + @options = options + @request = request + @response = response + end + + def skip_processing? + !html? || chunked? || inline? || bad_browser? + end + + def chunked? + @response["Transfer-Encoding"] == "chunked" + end + + def inline? + @response["Content-Disposition"].to_s.start_with?("inline") + end + + def bad_browser? + BAD_USER_AGENTS.any? { |pattern| pattern.match?(@request["User-Agent"]) } + end + + def html? + @response["Content-Type"].to_s.include?("text/html") + end + end + + # This class inserts the LiveReload script tags into HTML as it is served + class BodyProcessor + HEAD_TAG_REGEX = %r!|!.freeze + + attr_reader :content_length, :new_body, :livereload_added + + def initialize(body, options) + @body = body + @options = options + @processed = false + end + + def processed? + @processed + end + + # rubocop:disable Metrics/MethodLength + def process! + @new_body = [] + # @body will usually be a File object but Strings occur in rare cases + if @body.respond_to?(:each) + begin + @body.each { |line| @new_body << line.to_s } + ensure + @body.close + end + else + @new_body = @body.lines + end + + @content_length = 0 + @livereload_added = false + + @new_body.each do |line| + if !@livereload_added && line[" + document.write( + ' + TEMPLATE + end + + def livereload_args + # XHTML standard requires ampersands to be encoded as entities when in + # attributes. See http://stackoverflow.com/a/2190292 + src = "" + if @options["livereload_min_delay"] + src += "&mindelay=#{@options["livereload_min_delay"]}" + end + if @options["livereload_max_delay"] + src += "&maxdelay=#{@options["livereload_max_delay"]}" + end + src += "&port=#{@options["livereload_port"]}" if @options["livereload_port"] + src + end + end + + class Servlet < WEBrick::HTTPServlet::FileHandler + DEFAULTS = { + "Cache-Control" => "private, max-age=0, proxy-revalidate, " \ + "no-store, no-cache, must-revalidate", + }.freeze + + def initialize(server, root, callbacks) + # So we can access them easily. + @jekyll_opts = server.config[:JekyllOptions] + @mime_types_charset = server.config[:MimeTypesCharset] + set_defaults + super + end + + def search_index_file(req, res) + super || + search_file(req, res, ".html") || + search_file(req, res, ".xhtml") + end + + # Add the ability to tap file.html the same way that Nginx does on our + # Docker images (or on GitHub Pages.) The difference is that we might end + # up with a different preference on which comes first. + + def search_file(req, res, basename) + # /file.* > /file/index.html > /file.html + super || + super(req, res, "#{basename}.html") || + super(req, res, "#{basename}.xhtml") + end + + # rubocop:disable Naming/MethodName + def do_GET(req, res) + rtn = super + + if @jekyll_opts["livereload"] + return rtn if SkipAnalyzer.skip_processing?(req, res, @jekyll_opts) + + processor = BodyProcessor.new(res.body, @jekyll_opts) + processor.process! + res.body = processor.new_body + res.content_length = processor.content_length.to_s + + if processor.livereload_added + # Add a header to indicate that the page content has been modified + res["X-Rack-LiveReload"] = "1" + end + end + + conditionally_inject_charset(res) + res.header.merge!(@headers) + rtn + end + # rubocop:enable Naming/MethodName + + private + + # Inject charset based on Jekyll config only if our mime-types database contains + # the charset metadata. + # + # Refer `script/vendor-mimes` in the repository for further details. + def conditionally_inject_charset(res) + typ = res.header["content-type"] + return unless @mime_types_charset.key?(typ) + return if %r!;\s*charset=!.match?(typ) + + res.header["content-type"] = "#{typ}; charset=#{@jekyll_opts["encoding"]}" + end + + def set_defaults + hash_ = @jekyll_opts.fetch("webrick", {}).fetch("headers", {}) + DEFAULTS.each_with_object(@headers = hash_) do |(key, val), hash| + hash[key] = val unless hash.key?(key) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/websockets.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/websockets.rb new file mode 100644 index 0000000..6aa522c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/commands/serve/websockets.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +require "http/parser" + +module Jekyll + module Commands + class Serve + # The LiveReload protocol requires the server to serve livereload.js over HTTP + # despite the fact that the protocol itself uses WebSockets. This custom connection + # class addresses the dual protocols that the server needs to understand. + class HttpAwareConnection < EventMachine::WebSocket::Connection + attr_reader :reload_body, :reload_size + + def initialize(_opts) + # If EventMachine SSL support on Windows ever gets better, the code below will + # set up the reactor to handle SSL + # + # @ssl_enabled = opts["ssl_cert"] && opts["ssl_key"] + # if @ssl_enabled + # em_opts[:tls_options] = { + # :private_key_file => Jekyll.sanitized_path(opts["source"], opts["ssl_key"]), + # :cert_chain_file => Jekyll.sanitized_path(opts["source"], opts["ssl_cert"]) + # } + # em_opts[:secure] = true + # end + + # This is too noisy even for --verbose, but uncomment if you need it for + # a specific WebSockets issue. Adding ?LR-verbose=true onto the URL will + # enable logging on the client side. + # em_opts[:debug] = true + + em_opts = {} + super(em_opts) + + reload_file = File.join(Serve.singleton_class::LIVERELOAD_DIR, "livereload.js") + + @reload_body = File.read(reload_file) + @reload_size = @reload_body.bytesize + end + + # rubocop:disable Metrics/MethodLength + def dispatch(data) + parser = Http::Parser.new + parser << data + + # WebSockets requests will have a Connection: Upgrade header + if parser.http_method != "GET" || parser.upgrade? + super + elsif parser.request_url.start_with?("/livereload.js") + headers = [ + "HTTP/1.1 200 OK", + "Content-Type: application/javascript", + "Content-Length: #{reload_size}", + "", + "", + ].join("\r\n") + send_data(headers) + + # stream_file_data would free us from keeping livereload.js in memory + # but JRuby blocks on that call and never returns + send_data(reload_body) + close_connection_after_writing + else + body = "This port only serves livereload.js over HTTP.\n" + headers = [ + "HTTP/1.1 400 Bad Request", + "Content-Type: text/plain", + "Content-Length: #{body.bytesize}", + "", + "", + ].join("\r\n") + send_data(headers) + send_data(body) + close_connection_after_writing + end + end + # rubocop:enable Metrics/MethodLength + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/configuration.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/configuration.rb new file mode 100644 index 0000000..9b2fbff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/configuration.rb @@ -0,0 +1,313 @@ +# frozen_string_literal: true + +module Jekyll + class Configuration < Hash + # Default options. Overridden by values in _config.yml. + # Strings rather than symbols are used for compatibility with YAML. + DEFAULTS = { + # Where things are + "source" => Dir.pwd, + "destination" => File.join(Dir.pwd, "_site"), + "collections_dir" => "", + "cache_dir" => ".jekyll-cache", + "plugins_dir" => "_plugins", + "layouts_dir" => "_layouts", + "data_dir" => "_data", + "includes_dir" => "_includes", + "collections" => {}, + + # Handling Reading + "safe" => false, + "include" => [".htaccess"], + "exclude" => [], + "keep_files" => [".git", ".svn"], + "encoding" => "utf-8", + "markdown_ext" => "markdown,mkdown,mkdn,mkd,md", + "strict_front_matter" => false, + + # Filtering Content + "show_drafts" => nil, + "limit_posts" => 0, + "future" => false, + "unpublished" => false, + + # Plugins + "whitelist" => [], + "plugins" => [], + + # Conversion + "markdown" => "kramdown", + "highlighter" => "rouge", + "lsi" => false, + "excerpt_separator" => "\n\n", + "incremental" => false, + + # Serving + "detach" => false, # default to not detaching the server + "port" => "4000", + "host" => "127.0.0.1", + "baseurl" => nil, # this mounts at /, i.e. no subdirectory + "show_dir_listing" => false, + + # Output Configuration + "permalink" => "date", + "paginate_path" => "/page:num", + "timezone" => nil, # use the local timezone + + "quiet" => false, + "verbose" => false, + "defaults" => [], + + "liquid" => { + "error_mode" => "warn", + "strict_filters" => false, + "strict_variables" => false, + }, + + "kramdown" => { + "auto_ids" => true, + "toc_levels" => (1..6).to_a, + "entity_output" => "as_char", + "smart_quotes" => "lsquo,rsquo,ldquo,rdquo", + "input" => "GFM", + "hard_wrap" => false, + "guess_lang" => true, + "footnote_nr" => 1, + "show_warnings" => false, + }, + }.each_with_object(Configuration.new) { |(k, v), hsh| hsh[k] = v.freeze }.freeze + + class << self + # Static: Produce a Configuration ready for use in a Site. + # It takes the input, fills in the defaults where values do not exist. + # + # user_config - a Hash or Configuration of overrides. + # + # Returns a Configuration filled with defaults. + def from(user_config) + Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys) + .add_default_collections.add_default_excludes + end + end + + # Public: Turn all keys into string + # + # Return a copy of the hash where all its keys are strings + def stringify_keys + each_with_object({}) { |(k, v), hsh| hsh[k.to_s] = v } + end + + def get_config_value_with_override(config_key, override) + override[config_key] || self[config_key] || DEFAULTS[config_key] + end + + # Public: Directory of the Jekyll source folder + # + # override - the command-line options hash + # + # Returns the path to the Jekyll source directory + def source(override) + get_config_value_with_override("source", override) + end + + def quiet(override = {}) + get_config_value_with_override("quiet", override) + end + alias_method :quiet?, :quiet + + def verbose(override = {}) + get_config_value_with_override("verbose", override) + end + alias_method :verbose?, :verbose + + def safe_load_file(filename) + case File.extname(filename) + when %r!\.toml!i + Jekyll::External.require_with_graceful_fail("tomlrb") unless defined?(Tomlrb) + Tomlrb.load_file(filename) + when %r!\.ya?ml!i + SafeYAML.load_file(filename) || {} + else + raise ArgumentError, + "No parser for '#{filename}' is available. Use a .y(a)ml or .toml file instead." + end + end + + # Public: Generate list of configuration files from the override + # + # override - the command-line options hash + # + # Returns an Array of config files + def config_files(override) + # Adjust verbosity quickly + Jekyll.logger.adjust_verbosity( + :quiet => quiet?(override), + :verbose => verbose?(override) + ) + + # Get configuration from /_config.yml or / + config_files = override["config"] + if config_files.to_s.empty? + default = %w(yml yaml toml).find(-> { "yml" }) do |ext| + File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}")) + end + config_files = Jekyll.sanitized_path(source(override), "_config.#{default}") + @default_config_file = true + end + Array(config_files) + end + + # Public: Read configuration and return merged Hash + # + # file - the path to the YAML file to be read in + # + # Returns this configuration, overridden by the values in the file + def read_config_file(file) + file = File.expand_path(file) + next_config = safe_load_file(file) + + unless next_config.is_a?(Hash) + raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow + end + + Jekyll.logger.info "Configuration file:", file + next_config + rescue SystemCallError + if @default_config_file ||= nil + Jekyll.logger.warn "Configuration file:", "none" + {} + else + Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found." + raise LoadError, "The Configuration file '#{file}' could not be found." + end + end + + # Public: Read in a list of configuration files and merge with this hash + # + # files - the list of configuration file paths + # + # Returns the full configuration, with the defaults overridden by the values in the + # configuration files + def read_config_files(files) + configuration = clone + + begin + files.each do |config_file| + next if config_file.nil? || config_file.empty? + + new_config = read_config_file(config_file) + configuration = Utils.deep_merge_hashes(configuration, new_config) + end + rescue ArgumentError => e + Jekyll.logger.warn "WARNING:", "Error reading configuration. Using defaults (and options)." + warn e + end + + configuration.validate.add_default_collections + end + + # Public: Split a CSV string into an array containing its values + # + # csv - the string of comma-separated values + # + # Returns an array of the values contained in the CSV + def csv_to_array(csv) + csv.split(",").map(&:strip) + end + + # Public: Ensure the proper options are set in the configuration + # + # Returns the configuration Hash + def validate + config = clone + + check_plugins(config) + check_include_exclude(config) + + config + end + + def add_default_collections + config = clone + + # It defaults to `{}`, so this is only if someone sets it to null manually. + return config if config["collections"].nil? + + # Ensure we have a hash. + if config["collections"].is_a?(Array) + config["collections"] = config["collections"].each_with_object({}) do |collection, hash| + hash[collection] = {} + end + end + + config["collections"] = Utils.deep_merge_hashes( + { "posts" => {} }, config["collections"] + ).tap do |collections| + collections["posts"]["output"] = true + if config["permalink"] + collections["posts"]["permalink"] ||= style_to_permalink(config["permalink"]) + end + end + + config + end + + DEFAULT_EXCLUDES = %w( + .sass-cache .jekyll-cache + gemfiles Gemfile Gemfile.lock + node_modules + vendor/bundle/ vendor/cache/ vendor/gems/ vendor/ruby/ + ).freeze + + def add_default_excludes + config = clone + return config if config["exclude"].nil? + + config["exclude"].concat(DEFAULT_EXCLUDES).uniq! + config + end + + private + + STYLE_TO_PERMALINK = { + :none => "/:categories/:title:output_ext", + :date => "/:categories/:year/:month/:day/:title:output_ext", + :ordinal => "/:categories/:year/:y_day/:title:output_ext", + :pretty => "/:categories/:year/:month/:day/:title/", + :weekdate => "/:categories/:year/W:week/:short_day/:title:output_ext", + }.freeze + + private_constant :STYLE_TO_PERMALINK + + def style_to_permalink(permalink_style) + STYLE_TO_PERMALINK[permalink_style.to_sym] || permalink_style.to_s + end + + def check_include_exclude(config) + %w(include exclude).each do |option| + next unless config.key?(option) + next if config[option].is_a?(Array) + + raise Jekyll::Errors::InvalidConfigurationError, + "'#{option}' should be set as an array, but was: #{config[option].inspect}." + end + end + + # Private: Checks if the `plugins` config is a String + # + # config - the config hash + # + # Raises a Jekyll::Errors::InvalidConfigurationError if the config `plugins` + # is not an Array. + def check_plugins(config) + return unless config.key?("plugins") + return if config["plugins"].is_a?(Array) + + Jekyll.logger.error "'plugins' should be set as an array of gem-names, but was: " \ + "#{config["plugins"].inspect}. Use 'plugins_dir' instead to set " \ + "the directory for your non-gemified Ruby plugins." + raise Jekyll::Errors::InvalidConfigurationError, + "'plugins' should be set as an array, but was: #{config["plugins"].inspect}." + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converter.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converter.rb new file mode 100644 index 0000000..3cb74de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converter.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module Jekyll + class Converter < Plugin + # Public: Get or set the highlighter prefix. When an argument is specified, + # the prefix will be set. If no argument is specified, the current prefix + # will be returned. + # + # highlighter_prefix - The String prefix (default: nil). + # + # Returns the String prefix. + def self.highlighter_prefix(highlighter_prefix = nil) + unless defined?(@highlighter_prefix) && highlighter_prefix.nil? + @highlighter_prefix = highlighter_prefix + end + @highlighter_prefix + end + + # Public: Get or set the highlighter suffix. When an argument is specified, + # the suffix will be set. If no argument is specified, the current suffix + # will be returned. + # + # highlighter_suffix - The String suffix (default: nil). + # + # Returns the String suffix. + def self.highlighter_suffix(highlighter_suffix = nil) + unless defined?(@highlighter_suffix) && highlighter_suffix.nil? + @highlighter_suffix = highlighter_suffix + end + @highlighter_suffix + end + + # Initialize the converter. + # + # Returns an initialized Converter. + def initialize(config = {}) + @config = config + end + + # Get the highlighter prefix. + # + # Returns the String prefix. + def highlighter_prefix + self.class.highlighter_prefix + end + + # Get the highlighter suffix. + # + # Returns the String suffix. + def highlighter_suffix + self.class.highlighter_suffix + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/identity.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/identity.rb new file mode 100644 index 0000000..7579b33 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/identity.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Jekyll + module Converters + # Identity converter. Returns same content as given. + # For more info on converters see https://jekyllrb.com/docs/plugins/converters/ + class Identity < Converter + safe true + + priority :lowest + + # Public: Does the given extension match this converter's list of acceptable extensions? + # Takes one argument: the file's extension (including the dot). + # + # _ext - The String extension to check (not relevant here) + # + # Returns true since it always matches. + def matches(_ext) + true + end + + # Public: The extension to be given to the output file (including the dot). + # + # ext - The String extension or original file. + # + # Returns The String output file extension. + def output_ext(ext) + ext + end + + # Logic to do the content conversion. + # + # content - String content of file (without front matter). + # + # Returns a String of the converted content. + def convert(content) + content + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/markdown.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/markdown.rb new file mode 100644 index 0000000..da1f1ce --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/markdown.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +module Jekyll + module Converters + # Markdown converter. + # For more info on converters see https://jekyllrb.com/docs/plugins/converters/ + class Markdown < Converter + highlighter_prefix "\n" + highlighter_suffix "\n" + safe true + + def setup + return if @setup ||= false + + unless (@parser = get_processor) + if @config["safe"] + Jekyll.logger.warn "Build Warning:", "Custom processors are not loaded in safe mode" + end + + Jekyll.logger.error "Markdown processor:", + "#{@config["markdown"].inspect} is not a valid Markdown processor." + Jekyll.logger.error "", "Available processors are: #{valid_processors.join(", ")}" + Jekyll.logger.error "" + raise Errors::FatalException, "Invalid Markdown processor given: #{@config["markdown"]}" + end + + @cache = Jekyll::Cache.new("Jekyll::Converters::Markdown") + @setup = true + end + + # RuboCop does not allow reader methods to have names starting with `get_` + # To ensure compatibility, this check has been disabled on this method + # + # rubocop:disable Naming/AccessorMethodName + def get_processor + case @config["markdown"].downcase + when "kramdown" then KramdownParser.new(@config) + else + custom_processor + end + end + # rubocop:enable Naming/AccessorMethodName + + # Public: Provides you with a list of processors comprised of the ones we support internally + # and the ones that you have provided to us (if they're whitelisted for use in safe mode). + # + # Returns an array of symbols. + def valid_processors + [:kramdown] + third_party_processors + end + + # Public: A list of processors that you provide via plugins. + # + # Returns an array of symbols + def third_party_processors + self.class.constants - [:KramdownParser, :PRIORITIES] + end + + # Does the given extension match this converter's list of acceptable extensions? + # Takes one argument: the file's extension (including the dot). + # + # ext - The String extension to check. + # + # Returns true if it matches, false otherwise. + def matches(ext) + extname_list.include?(ext.downcase) + end + + # Public: The extension to be given to the output file (including the dot). + # + # ext - The String extension or original file. + # + # Returns The String output file extension. + def output_ext(_ext) + ".html" + end + + # Logic to do the content conversion. + # + # content - String content of file (without front matter). + # + # Returns a String of the converted content. + def convert(content) + setup + @cache.getset(content) do + @parser.convert(content) + end + end + + def extname_list + @extname_list ||= @config["markdown_ext"].split(",").map! { |e| ".#{e.downcase}" } + end + + private + + def custom_processor + converter_name = @config["markdown"] + self.class.const_get(converter_name).new(@config) if custom_class_allowed?(converter_name) + end + + # Private: Determine whether a class name is an allowed custom + # markdown class name. + # + # parser_name - the name of the parser class + # + # Returns true if the parser name contains only alphanumeric characters and is defined + # within Jekyll::Converters::Markdown + def custom_class_allowed?(parser_name) + parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?(parser_name.to_sym) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/markdown/kramdown_parser.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/markdown/kramdown_parser.rb new file mode 100644 index 0000000..1e6a1de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -0,0 +1,197 @@ +# frozen_string_literal: true + +module Kramdown + # A Kramdown::Document subclass meant to optimize memory usage from initializing + # a kramdown document for parsing. + # + # The optimization is by using the same options Hash (and its derivatives) for + # converting all Markdown documents in a Jekyll site. + class JekyllDocument < Document + class << self + attr_reader :options, :parser + + # The implementation is basically the core logic in +Kramdown::Document#initialize+ + # + # rubocop:disable Naming/MemoizedInstanceVariableName + def setup(options) + @cache ||= {} + + # reset variables on a subsequent set up with a different options Hash + unless @cache[:id] == options.hash + @options = @parser = nil + @cache[:id] = options.hash + end + + @options ||= Options.merge(options).freeze + @parser ||= begin + parser_name = (@options[:input] || "kramdown").to_s + parser_name = parser_name[0..0].upcase + parser_name[1..-1] + try_require("parser", parser_name) + + if Parser.const_defined?(parser_name) + Parser.const_get(parser_name) + else + raise Kramdown::Error, "kramdown has no parser to handle the specified " \ + "input format: #{@options[:input]}" + end + end + end + # rubocop:enable Naming/MemoizedInstanceVariableName + + private + + def try_require(type, name) + require "kramdown/#{type}/#{Utils.snake_case(name)}" + rescue LoadError + false + end + end + + def initialize(source, options = {}) + JekyllDocument.setup(options) + + @options = JekyllDocument.options + @root, @warnings = JekyllDocument.parser.parse(source, @options) + end + + # Use Kramdown::Converter::Html class to convert this document into HTML. + # + # The implementation is basically an optimized version of core logic in + # +Kramdown::Document#method_missing+ from kramdown-2.1.0. + def to_html + output, warnings = Kramdown::Converter::Html.convert(@root, @options) + @warnings.concat(warnings) + output + end + end +end + +# + +module Jekyll + module Converters + class Markdown + class KramdownParser + CODERAY_DEFAULTS = { + "css" => "style", + "bold_every" => 10, + "line_numbers" => "inline", + "line_number_start" => 1, + "tab_width" => 4, + "wrap" => "div", + }.freeze + + def initialize(config) + @main_fallback_highlighter = config["highlighter"] || "rouge" + @config = config["kramdown"] || {} + @highlighter = nil + setup + load_dependencies + end + + # Setup and normalize the configuration: + # * Create Kramdown if it doesn't exist. + # * Set syntax_highlighter, detecting enable_coderay and merging + # highlighter if none. + # * Merge kramdown[coderay] into syntax_highlighter_opts stripping coderay_. + # * Make sure `syntax_highlighter_opts` exists. + + def setup + @config["syntax_highlighter"] ||= highlighter + @config["syntax_highlighter_opts"] ||= {} + @config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext" + @config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"] + @config["coderay"] ||= {} # XXX: Legacy. + modernize_coderay_config + end + + def convert(content) + document = Kramdown::JekyllDocument.new(content, @config) + html_output = document.to_html + if @config["show_warnings"] + document.warnings.each do |warning| + Jekyll.logger.warn "Kramdown warning:", warning + end + end + html_output + end + + private + + def load_dependencies + require "kramdown-parser-gfm" if @config["input"] == "GFM" + + if highlighter == "coderay" + Jekyll::External.require_with_graceful_fail("kramdown-syntax-coderay") + end + + # `mathjax` engine is bundled within kramdown-2.x and will be handled by + # kramdown itself. + if (math_engine = @config["math_engine"]) && math_engine != "mathjax" + Jekyll::External.require_with_graceful_fail("kramdown-math-#{math_engine}") + end + end + + # config[kramdown][syntax_highlighter] > + # config[kramdown][enable_coderay] > + # config[highlighter] + # Where `enable_coderay` is now deprecated because Kramdown + # supports Rouge now too. + def highlighter + return @highlighter if @highlighter + + if @config["syntax_highlighter"] + return @highlighter = @config[ + "syntax_highlighter" + ] + end + + @highlighter = if @config.key?("enable_coderay") && @config["enable_coderay"] + Jekyll::Deprecator.deprecation_message( + "You are using 'enable_coderay', " \ + "use syntax_highlighter: coderay in your configuration file." + ) + + "coderay" + else + @main_fallback_highlighter + end + end + + def strip_coderay_prefix(hash) + hash.each_with_object({}) do |(key, val), hsh| + cleaned_key = key.to_s.delete_prefix("coderay_") + + if key != cleaned_key + Jekyll::Deprecator.deprecation_message( + "You are using '#{key}'. Normalizing to #{cleaned_key}." + ) + end + + hsh[cleaned_key] = val + end + end + + # If our highlighter is CodeRay we go in to merge the CodeRay defaults + # with your "coderay" key if it's there, deprecating it in the + # process of you using it. + def modernize_coderay_config + unless @config["coderay"].empty? + Jekyll::Deprecator.deprecation_message( + "You are using 'kramdown.coderay' in your configuration, " \ + "please use 'syntax_highlighter_opts' instead." + ) + + @config["syntax_highlighter_opts"] = begin + strip_coderay_prefix( + @config["syntax_highlighter_opts"] \ + .merge(CODERAY_DEFAULTS) \ + .merge(@config["coderay"]) + ) + end + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/smartypants.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/smartypants.rb new file mode 100644 index 0000000..606afdc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/converters/smartypants.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +module Kramdown + module Parser + class SmartyPants < Kramdown::Parser::Kramdown + def initialize(source, options) + super + @block_parsers = [:block_html, :content] + @span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html] + end + + def parse_content + add_text @src.scan(%r!\A.*\n!) + end + define_parser(:content, %r!\A!) + end + end +end + +module Jekyll + module Converters + # SmartyPants converter. + # For more info on converters see https://jekyllrb.com/docs/plugins/converters/ + class SmartyPants < Converter + safe true + priority :low + + def initialize(config) + Jekyll::External.require_with_graceful_fail "kramdown" unless defined?(Kramdown) + @config = config["kramdown"].dup || {} + @config[:input] = :SmartyPants + end + + # Does the given extension match this converter's list of acceptable extensions? + # Takes one argument: the file's extension (including the dot). + # + # ext - The String extension to check. + # + # Returns true if it matches, false otherwise. + def matches(_ext) + false + end + + # Public: The extension to be given to the output file (including the dot). + # + # ext - The String extension or original file. + # + # Returns The String output file extension. + def output_ext(_ext) + nil + end + + # Logic to do the content conversion. + # + # content - String content of file (without front matter). + # + # Returns a String of the converted content. + def convert(content) + document = Kramdown::Document.new(content, @config) + html_output = document.to_html.chomp + if @config["show_warnings"] + document.warnings.each do |warning| + Jekyll.logger.warn "Kramdown warning:", warning.sub(%r!^Warning:\s+!, "") + end + end + html_output + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/convertible.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/convertible.rb new file mode 100644 index 0000000..b9f7a93 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/convertible.rb @@ -0,0 +1,257 @@ +# frozen_string_literal: true + +# Convertible provides methods for converting a pagelike item +# from a certain type of markup into actual content +# +# Requires +# self.site -> Jekyll::Site +# self.content +# self.content= +# self.data= +# self.ext= +# self.output= +# self.name +# self.path +# self.type -> :page, :post or :draft + +module Jekyll + module Convertible + # Returns the contents as a String. + def to_s + content || "" + end + + # Whether the file is published or not, as indicated in YAML front-matter + def published? + !(data.key?("published") && data["published"] == false) + end + + # Read the YAML frontmatter. + # + # base - The String path to the dir containing the file. + # name - The String filename of the file. + # opts - optional parameter to File.read, default at site configs + # + # Returns nothing. + # rubocop:disable Metrics/AbcSize + def read_yaml(base, name, opts = {}) + filename = @path || site.in_source_dir(base, name) + Jekyll.logger.debug "Reading:", relative_path + + begin + self.content = File.read(filename, **Utils.merged_file_read_opts(site, opts)) + if content =~ Document::YAML_FRONT_MATTER_REGEXP + self.content = Regexp.last_match.post_match + self.data = SafeYAML.load(Regexp.last_match(1)) + end + rescue Psych::SyntaxError => e + Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}" + raise e if site.config["strict_front_matter"] + rescue StandardError => e + Jekyll.logger.warn "Error reading file #{filename}: #{e.message}" + raise e if site.config["strict_front_matter"] + end + + self.data ||= {} + + validate_data! filename + validate_permalink! filename + + self.data + end + # rubocop:enable Metrics/AbcSize + + def validate_data!(filename) + unless self.data.is_a?(Hash) + raise Errors::InvalidYAMLFrontMatterError, + "Invalid YAML front matter in #{filename}" + end + end + + def validate_permalink!(filename) + if self.data["permalink"] == "" + raise Errors::InvalidPermalinkError, "Invalid permalink in #{filename}" + end + end + + # Transform the contents based on the content type. + # + # Returns the transformed contents. + def transform + renderer.convert(content) + end + + # Determine the extension depending on content_type. + # + # Returns the String extension for the output file. + # e.g. ".html" for an HTML output file. + def output_ext + renderer.output_ext + end + + # Determine which converter to use based on this convertible's + # extension. + # + # Returns the Converter instance. + def converters + renderer.converters + end + + # Render Liquid in the content + # + # content - the raw Liquid content to render + # payload - the payload for Liquid + # info - the info for Liquid + # + # Returns the converted content + def render_liquid(content, payload, info, path) + renderer.render_liquid(content, payload, info, path) + end + + # Convert this Convertible's data to a Hash suitable for use by Liquid. + # + # Returns the Hash representation of this Convertible. + def to_liquid(attrs = nil) + further_data = \ + (attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh| + hsh[attribute] = send(attribute) + end + + Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data) + end + + # The type of a document, + # i.e., its classname downcase'd and to_sym'd. + # + # Returns the type of self. + def type + :pages if is_a?(Page) + end + + # returns the owner symbol for hook triggering + def hook_owner + :pages if is_a?(Page) + end + + # Determine whether the document is an asset file. + # Asset files include CoffeeScript files and Sass/SCSS files. + # + # Returns true if the extname belongs to the set of extensions + # that asset files use. + def asset_file? + sass_file? || coffeescript_file? + end + + # Determine whether the document is a Sass file. + # + # Returns true if extname == .sass or .scss, false otherwise. + def sass_file? + Jekyll::Document::SASS_FILE_EXTS.include?(ext) + end + + # Determine whether the document is a CoffeeScript file. + # + # Returns true if extname == .coffee, false otherwise. + def coffeescript_file? + ext == ".coffee" + end + + # Determine whether the file should be rendered with Liquid. + # + # Returns true if the file has Liquid Tags or Variables, false otherwise. + def render_with_liquid? + return false if data["render_with_liquid"] == false + + Jekyll::Utils.has_liquid_construct?(content) + end + + # Determine whether the file should be placed into layouts. + # + # Returns false if the document is an asset file or if the front matter + # specifies `layout: none` + def place_in_layout? + !(asset_file? || no_layout?) + end + + # Checks if the layout specified in the document actually exists + # + # layout - the layout to check + # + # Returns true if the layout is invalid, false if otherwise + def invalid_layout?(layout) + !data["layout"].nil? && layout.nil? && !(is_a? Jekyll::Excerpt) + end + + # Recursively render layouts + # + # layouts - a list of the layouts + # payload - the payload for Liquid + # info - the info for Liquid + # + # Returns nothing + def render_all_layouts(layouts, payload, info) + renderer.layouts = layouts + self.output = renderer.place_in_layouts(output, payload, info) + ensure + @renderer = nil # this will allow the modifications above to disappear + end + + # Add any necessary layouts to this convertible document. + # + # payload - The site payload Drop or Hash. + # layouts - A Hash of {"name" => "layout"}. + # + # Returns nothing. + def do_layout(payload, layouts) + self.output = renderer.tap do |doc_renderer| + doc_renderer.layouts = layouts + doc_renderer.payload = payload + end.run + + Jekyll.logger.debug "Post-Render Hooks:", relative_path + Jekyll::Hooks.trigger hook_owner, :post_render, self + ensure + @renderer = nil # this will allow the modifications above to disappear + end + + # Write the generated page file to the destination directory. + # + # dest - The String path to the destination dir. + # + # Returns nothing. + def write(dest) + path = destination(dest) + FileUtils.mkdir_p(File.dirname(path)) + Jekyll.logger.debug "Writing:", path + File.write(path, output, :mode => "wb") + Jekyll::Hooks.trigger hook_owner, :post_write, self + end + + # Accessor for data properties by Liquid. + # + # property - The String name of the property to retrieve. + # + # Returns the String value or nil if the property isn't included. + def [](property) + if self.class::ATTRIBUTES_FOR_LIQUID.include?(property) + send(property) + else + data[property] + end + end + + def renderer + @renderer ||= Jekyll::Renderer.new(site, self) + end + + private + + def defaults + @defaults ||= site.frontmatter_defaults.all(relative_path, type) + end + + def no_layout? + data["layout"] == "none" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/deprecator.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/deprecator.rb new file mode 100644 index 0000000..4ecb656 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/deprecator.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Jekyll + module Deprecator + extend self + + def process(args) + arg_is_present? args, "--server", "The --server command has been replaced by the \ + 'serve' subcommand." + arg_is_present? args, "--serve", "The --serve command has been replaced by the \ + 'serve' subcommand." + arg_is_present? args, "--no-server", "To build Jekyll without launching a server, \ + use the 'build' subcommand." + arg_is_present? args, "--auto", "The switch '--auto' has been replaced with \ + '--watch'." + arg_is_present? args, "--no-auto", "To disable auto-replication, simply leave off \ + the '--watch' switch." + arg_is_present? args, "--pygments", "The 'pygments' settings has been removed in \ + favour of 'highlighter'." + arg_is_present? args, "--paginate", "The 'paginate' setting can only be set in \ + your config files." + arg_is_present? args, "--url", "The 'url' setting can only be set in your \ + config files." + no_subcommand(args) + end + + def no_subcommand(args) + unless args.empty? || + args.first !~ %r(!/^--/!) || %w(--help --version).include?(args.first) + deprecation_message "Jekyll now uses subcommands instead of just switches. \ + Run `jekyll help` to find out more." + abort + end + end + + def arg_is_present?(args, deprecated_argument, message) + deprecation_message(message) if args.include?(deprecated_argument) + end + + def deprecation_message(message) + Jekyll.logger.warn "Deprecation:", message + end + + def defaults_deprecate_type(old, current) + Jekyll.logger.warn "Defaults:", "The '#{old}' type has become '#{current}'." + Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use \ + 'type: #{current}'." + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/document.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/document.rb new file mode 100644 index 0000000..2e39024 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/document.rb @@ -0,0 +1,543 @@ +# frozen_string_literal: true + +module Jekyll + class Document + include Comparable + extend Forwardable + + attr_reader :path, :site, :extname, :collection, :type + attr_accessor :content, :output + + def_delegator :self, :read_post_data, :post_read + + YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m.freeze + DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$!.freeze + DATE_FILENAME_MATCHER = %r!^(?>.+/)*?(\d{2,4}-\d{1,2}-\d{1,2})-([^/]*)(\.[^.]+)$!.freeze + + SASS_FILE_EXTS = %w(.sass .scss).freeze + YAML_FILE_EXTS = %w(.yaml .yml).freeze + + # + + # Class-wide cache to stash and retrieve regexp to detect "super-directories" + # of a particular Jekyll::Document object. + # + # dirname - The *special directory* for the Document. + # e.g. "_posts" or "_drafts" for Documents from the `site.posts` collection. + def self.superdirs_regex(dirname) + @superdirs_regex ||= {} + @superdirs_regex[dirname] ||= %r!#{dirname}.*! + end + + # + + # Create a new Document. + # + # path - the path to the file + # relations - a hash with keys :site and :collection, the values of which + # are the Jekyll::Site and Jekyll::Collection to which this + # Document belong. + # + # Returns nothing. + def initialize(path, relations = {}) + @site = relations[:site] + @path = path + @extname = File.extname(path) + @collection = relations[:collection] + @type = @collection.label.to_sym + + @has_yaml_header = nil + + if draft? + categories_from_path("_drafts") + else + categories_from_path(collection.relative_directory) + end + + data.default_proc = proc do |_, key| + site.frontmatter_defaults.find(relative_path, type, key) + end + + trigger_hooks(:post_init) + end + + # Fetch the Document's data. + # + # Returns a Hash containing the data. An empty hash is returned if + # no data was read. + def data + @data ||= {} + end + + # Merge some data in with this document's data. + # + # Returns the merged data. + def merge_data!(other, source: "YAML front matter") + merge_categories!(other) + Utils.deep_merge_hashes!(data, other) + merge_date!(source) + data + end + + # Returns the document date. If metadata is not present then calculates it + # based on Jekyll::Site#time or the document file modification time. + # + # Return document date string. + def date + data["date"] ||= (draft? ? source_file_mtime : site.time) + end + + # Return document file modification time in the form of a Time object. + # + # Return document file modification Time object. + def source_file_mtime + File.mtime(path) + end + + # Returns whether the document is a draft. This is only the case if + # the document is in the 'posts' collection but in a different + # directory than '_posts'. + # + # Returns whether the document is a draft. + def draft? + data["draft"] ||= relative_path.index(collection.relative_directory).nil? && + collection.label == "posts" + end + + # The path to the document, relative to the collections_dir. + # + # Returns a String path which represents the relative path from the collections_dir + # to this document. + def relative_path + @relative_path ||= path.sub("#{site.collections_path}/", "") + end + + # The output extension of the document. + # + # Returns the output extension + def output_ext + renderer.output_ext + end + + # The base filename of the document, without the file extname. + # + # Returns the basename without the file extname. + def basename_without_ext + @basename_without_ext ||= File.basename(path, ".*") + end + + # The base filename of the document. + # + # Returns the base filename of the document. + def basename + @basename ||= File.basename(path) + end + + def renderer + @renderer ||= Jekyll::Renderer.new(site, self) + end + + # Produces a "cleaned" relative path. + # The "cleaned" relative path is the relative path without the extname + # and with the collection's directory removed as well. + # This method is useful when building the URL of the document. + # + # NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`) + # + # Examples: + # When relative_path is "_methods/site/generate...md": + # cleaned_relative_path + # # => "/site/generate" + # + # Returns the cleaned relative path of the document. + def cleaned_relative_path + @cleaned_relative_path ||= + relative_path[0..-extname.length - 1] + .sub(collection.relative_directory, "") + .gsub(%r!\.*\z!, "") + end + + # Determine whether the document is a YAML file. + # + # Returns true if the extname is either .yml or .yaml, false otherwise. + def yaml_file? + YAML_FILE_EXTS.include?(extname) + end + + # Determine whether the document is an asset file. + # Asset files include CoffeeScript files and Sass/SCSS files. + # + # Returns true if the extname belongs to the set of extensions + # that asset files use. + def asset_file? + sass_file? || coffeescript_file? + end + + # Determine whether the document is a Sass file. + # + # Returns true if extname == .sass or .scss, false otherwise. + def sass_file? + SASS_FILE_EXTS.include?(extname) + end + + # Determine whether the document is a CoffeeScript file. + # + # Returns true if extname == .coffee, false otherwise. + def coffeescript_file? + extname == ".coffee" + end + + # Determine whether the file should be rendered with Liquid. + # + # Returns false if the document is either an asset file or a yaml file, + # or if the document doesn't contain any Liquid Tags or Variables, + # true otherwise. + def render_with_liquid? + return false if data["render_with_liquid"] == false + + !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content)) + end + + # Determine whether the file should be rendered with a layout. + # + # Returns true if the Front Matter specifies that `layout` is set to `none`. + def no_layout? + data["layout"] == "none" + end + + # Determine whether the file should be placed into layouts. + # + # Returns false if the document is set to `layouts: none`, or is either an + # asset file or a yaml file. Returns true otherwise. + def place_in_layout? + !(asset_file? || yaml_file? || no_layout?) + end + + # The URL template where the document would be accessible. + # + # Returns the URL template for the document. + def url_template + collection.url_template + end + + # Construct a Hash of key-value pairs which contain a mapping between + # a key in the URL template and the corresponding value for this document. + # + # Returns the Hash of key-value pairs for replacement in the URL. + def url_placeholders + @url_placeholders ||= Drops::UrlDrop.new(self) + end + + # The permalink for this Document. + # Permalink is set via the data Hash. + # + # Returns the permalink or nil if no permalink was set in the data. + def permalink + data && data.is_a?(Hash) && data["permalink"] + end + + # The computed URL for the document. See `Jekyll::URL#to_s` for more details. + # + # Returns the computed URL for the document. + def url + @url ||= URL.new( + :template => url_template, + :placeholders => url_placeholders, + :permalink => permalink + ).to_s + end + + def [](key) + data[key] + end + + # The full path to the output file. + # + # base_directory - the base path of the output directory + # + # Returns the full path to the output file of this document. + def destination(base_directory) + @destination ||= {} + @destination[base_directory] ||= begin + path = site.in_dest_dir(base_directory, URL.unescape_path(url)) + if url.end_with? "/" + path = File.join(path, "index.html") + else + path << output_ext unless path.end_with? output_ext + end + path + end + end + + # Write the generated Document file to the destination directory. + # + # dest - The String path to the destination dir. + # + # Returns nothing. + def write(dest) + path = destination(dest) + FileUtils.mkdir_p(File.dirname(path)) + Jekyll.logger.debug "Writing:", path + File.write(path, output, :mode => "wb") + + trigger_hooks(:post_write) + end + + # Whether the file is published or not, as indicated in YAML front-matter + # + # Returns 'false' if the 'published' key is specified in the + # YAML front-matter and is 'false'. Otherwise returns 'true'. + def published? + !(data.key?("published") && data["published"] == false) + end + + # Read in the file and assign the content and data based on the file contents. + # Merge the frontmatter of the file with the frontmatter default + # values + # + # Returns nothing. + def read(opts = {}) + Jekyll.logger.debug "Reading:", relative_path + + if yaml_file? + @data = SafeYAML.load_file(path) + else + begin + merge_defaults + read_content(**opts) + read_post_data + rescue StandardError => e + handle_read_error(e) + end + end + end + + # Create a Liquid-understandable version of this Document. + # + # Returns a Hash representing this Document's data. + def to_liquid + @to_liquid ||= Drops::DocumentDrop.new(self) + end + + # The inspect string for this document. + # Includes the relative path and the collection label. + # + # Returns the inspect string for this document. + def inspect + "#<#{self.class} #{relative_path} collection=#{collection.label}>" + end + + # The string representation for this document. + # + # Returns the content of the document + def to_s + output || content || "NO CONTENT" + end + + # Compare this document against another document. + # Comparison is a comparison between the 2 paths of the documents. + # + # Returns -1, 0, +1 or nil depending on whether this doc's path is less than, + # equal or greater than the other doc's path. See String#<=> for more details. + def <=>(other) + return nil unless other.respond_to?(:data) + + cmp = data["date"] <=> other.data["date"] + cmp = path <=> other.path if cmp.nil? || cmp.zero? + cmp + end + + # Determine whether this document should be written. + # Based on the Collection to which it belongs. + # + # True if the document has a collection and if that collection's #write? + # method returns true, and if the site's Publisher will publish the document. + # False otherwise. + # + # rubocop:disable Naming/MemoizedInstanceVariableName + def write? + return @write_p if defined?(@write_p) + + @write_p = collection&.write? && site.publisher.publish?(self) + end + # rubocop:enable Naming/MemoizedInstanceVariableName + + # The Document excerpt_separator, from the YAML Front-Matter or site + # default excerpt_separator value + # + # Returns the document excerpt_separator + def excerpt_separator + @excerpt_separator ||= (data["excerpt_separator"] || site.config["excerpt_separator"]).to_s + end + + # Whether to generate an excerpt + # + # Returns true if the excerpt separator is configured. + def generate_excerpt? + !excerpt_separator.empty? + end + + def next_doc + pos = collection.docs.index { |post| post.equal?(self) } + collection.docs[pos + 1] if pos && pos < collection.docs.length - 1 + end + + def previous_doc + pos = collection.docs.index { |post| post.equal?(self) } + collection.docs[pos - 1] if pos && pos.positive? + end + + def trigger_hooks(hook_name, *args) + Jekyll::Hooks.trigger collection.label.to_sym, hook_name, self, *args if collection + Jekyll::Hooks.trigger :documents, hook_name, self, *args + end + + def id + @id ||= File.join(File.dirname(url), (data["slug"] || basename_without_ext).to_s) + end + + # Calculate related posts. + # + # Returns an Array of related Posts. + def related_posts + @related_posts ||= Jekyll::RelatedPosts.new(self).build + end + + # Override of method_missing to check in @data for the key. + def method_missing(method, *args, &blck) + if data.key?(method.to_s) + Jekyll::Deprecator.deprecation_message "Document##{method} is now a key in the #data hash." + Jekyll.logger.warn "", "Called by #{caller(1..1)[0]}." + data[method.to_s] + else + super + end + end + + def respond_to_missing?(method, *) + data.key?(method.to_s) || super + end + + # Add superdirectories of the special_dir to categories. + # In the case of es/_posts, 'es' is added as a category. + # In the case of _posts/es, 'es' is NOT added as a category. + # + # Returns nothing. + def categories_from_path(special_dir) + if relative_path.start_with?(special_dir) + superdirs = [] + else + superdirs = relative_path.sub(Document.superdirs_regex(special_dir), "") + superdirs = superdirs.split(File::SEPARATOR) + superdirs.reject! { |c| c.empty? || c == special_dir || c == basename } + end + + merge_data!({ "categories" => superdirs }, :source => "file path") + end + + def populate_categories + categories = Array(data["categories"]) + Utils.pluralized_array_from_hash( + data, "category", "categories" + ) + categories.map!(&:to_s) + categories.flatten! + categories.uniq! + + merge_data!({ "categories" => categories }) + end + + def populate_tags + tags = Utils.pluralized_array_from_hash(data, "tag", "tags") + tags.flatten! + + merge_data!({ "tags" => tags }) + end + + private + + def merge_categories!(other) + if other.key?("categories") && !other["categories"].nil? + other["categories"] = other["categories"].split if other["categories"].is_a?(String) + + if data["categories"].is_a?(Array) + other["categories"] = data["categories"] | other["categories"] + end + end + end + + def merge_date!(source) + if data.key?("date") + data["date"] = Utils.parse_date( + data["date"].to_s, + "Document '#{relative_path}' does not have a valid date in the #{source}." + ) + end + end + + def merge_defaults + defaults = @site.frontmatter_defaults.all(relative_path, type) + merge_data!(defaults, :source => "front matter defaults") unless defaults.empty? + end + + def read_content(**opts) + self.content = File.read(path, **Utils.merged_file_read_opts(site, opts)) + if content =~ YAML_FRONT_MATTER_REGEXP + self.content = Regexp.last_match.post_match + data_file = SafeYAML.load(Regexp.last_match(1)) + merge_data!(data_file, :source => "YAML front matter") if data_file + end + end + + def read_post_data + populate_title + populate_categories + populate_tags + generate_excerpt + end + + def handle_read_error(error) + if error.is_a? Psych::SyntaxError + Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{error.message}" + else + Jekyll.logger.error "Error:", "could not read file #{path}: #{error.message}" + end + + if site.config["strict_front_matter"] || error.is_a?(Jekyll::Errors::FatalException) + raise error + end + end + + def populate_title + if relative_path =~ DATE_FILENAME_MATCHER + date, slug, ext = Regexp.last_match.captures + modify_date(date) + elsif relative_path =~ DATELESS_FILENAME_MATCHER + slug, ext = Regexp.last_match.captures + end + # `slug` will be nil for documents without an extension since the regex patterns + # above tests for an extension as well. + # In such cases, assign `basename_without_ext` as the slug. + slug ||= basename_without_ext + + # slugs shouldn't end with a period + # `String#gsub!` removes all trailing periods (in comparison to `String#chomp!`) + slug.gsub!(%r!\.*\z!, "") + + # Try to ensure the user gets a title. + data["title"] ||= Utils.titleize_slug(slug) + # Only overwrite slug & ext if they aren't specified. + data["slug"] ||= slug + data["ext"] ||= ext + end + + def modify_date(date) + if !data["date"] || data["date"].to_i == site.time.to_i + merge_data!({ "date" => date }, :source => "filename") + end + end + + def generate_excerpt + data["excerpt"] ||= Jekyll::Excerpt.new(self) if generate_excerpt? + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/collection_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/collection_drop.rb new file mode 100644 index 0000000..4fe95a5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/collection_drop.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class CollectionDrop < Drop + extend Forwardable + + mutable false + + delegate_method_as :write?, :output + delegate_methods :label, :docs, :files, :directory, :relative_directory + + private delegate_method_as :metadata, :fallback_data + + def to_s + docs.to_s + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/document_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/document_drop.rb new file mode 100644 index 0000000..0cff374 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/document_drop.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class DocumentDrop < Drop + extend Forwardable + + NESTED_OBJECT_FIELD_BLACKLIST = %w( + content output excerpt next previous + ).freeze + + mutable false + + delegate_method_as :relative_path, :path + private delegate_method_as :data, :fallback_data + + delegate_methods :id, :output, :content, :to_s, :relative_path, :url, :date + data_delegators "title", "categories", "tags" + + def collection + @obj.collection.label + end + + def excerpt + fallback_data["excerpt"].to_s + end + + def name + fallback_data["name"] || @obj.basename + end + + def <=>(other) + return nil unless other.is_a? DocumentDrop + + cmp = self["date"] <=> other["date"] + cmp = self["path"] <=> other["path"] if cmp.nil? || cmp.zero? + cmp + end + + def previous + @obj.previous_doc.to_liquid + end + + def next + @obj.next_doc.to_liquid + end + + # Generate a Hash for use in generating JSON. + # This is useful if fields need to be cleared before the JSON can generate. + # + # state - the JSON::State object which determines the state of current processing. + # + # Returns a Hash ready for JSON generation. + def hash_for_json(state = nil) + to_h.tap do |hash| + if state && state.depth >= 2 + hash["previous"] = collapse_document(hash["previous"]) if hash["previous"] + hash["next"] = collapse_document(hash["next"]) if hash["next"] + end + end + end + + # Generate a Hash which breaks the recursive chain. + # Certain fields which are normally available are omitted. + # + # Returns a Hash with only non-recursive fields present. + def collapse_document(doc) + doc.keys.each_with_object({}) do |(key, _), result| + result[key] = doc[key] unless NESTED_OBJECT_FIELD_BLACKLIST.include?(key) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/drop.rb new file mode 100644 index 0000000..87eed39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/drop.rb @@ -0,0 +1,293 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class Drop < Liquid::Drop + include Enumerable + + NON_CONTENT_METHODS = [:fallback_data, :collapse_document].freeze + NON_CONTENT_METHOD_NAMES = NON_CONTENT_METHODS.map(&:to_s).freeze + private_constant :NON_CONTENT_METHOD_NAMES + + # A private stash to avoid repeatedly generating the setter method name string for + # a call to `Drops::Drop#[]=`. + # The keys of the stash below have a very high probability of being called upon during + # the course of various `Jekyll::Renderer#run` calls. + SETTER_KEYS_STASH = { + "content" => "content=", + "layout" => "layout=", + "page" => "page=", + "paginator" => "paginator=", + "highlighter_prefix" => "highlighter_prefix=", + "highlighter_suffix" => "highlighter_suffix=", + }.freeze + private_constant :SETTER_KEYS_STASH + + class << self + # Get or set whether the drop class is mutable. + # Mutability determines whether or not pre-defined fields may be + # overwritten. + # + # is_mutable - Boolean set mutability of the class (default: nil) + # + # Returns the mutability of the class + def mutable(is_mutable = nil) + @is_mutable = is_mutable || false + end + + def mutable? + @is_mutable + end + + # public delegation helper methods that calls onto Drop's instance + # variable `@obj`. + + # Generate private Drop instance_methods for each symbol in the given list. + # + # Returns nothing. + def private_delegate_methods(*symbols) + symbols.each { |symbol| private delegate_method(symbol) } + nil + end + + # Generate public Drop instance_methods for each symbol in the given list. + # + # Returns nothing. + def delegate_methods(*symbols) + symbols.each { |symbol| delegate_method(symbol) } + nil + end + + # Generate public Drop instance_method for given symbol that calls `@obj.`. + # + # Returns delegated method symbol. + def delegate_method(symbol) + define_method(symbol) { @obj.send(symbol) } + end + + # Generate public Drop instance_method named `delegate` that calls `@obj.`. + # + # Returns delegated method symbol. + def delegate_method_as(original, delegate) + define_method(delegate) { @obj.send(original) } + end + + # Generate public Drop instance_methods for each string entry in the given list. + # The generated method(s) access(es) `@obj`'s data hash. + # + # Returns nothing. + def data_delegators(*strings) + strings.each do |key| + data_delegator(key) if key.is_a?(String) + end + nil + end + + # Generate public Drop instance_methods for given string `key`. + # The generated method access(es) `@obj`'s data hash. + # + # Returns method symbol. + def data_delegator(key) + define_method(key.to_sym) { @obj.data[key] } + end + + # Array of stringified instance methods that do not end with the assignment operator. + # + # (.instance_methods always generates a new Array object so it can be mutated) + # + # Returns array of strings. + def getter_method_names + @getter_method_names ||= instance_methods.map!(&:to_s).tap do |list| + list.reject! { |item| item.end_with?("=") } + end + end + end + + # Create a new Drop + # + # obj - the Jekyll Site, Collection, or Document required by the + # drop. + # + # Returns nothing + def initialize(obj) + @obj = obj + end + + # Access a method in the Drop or a field in the underlying hash data. + # If mutable, checks the mutations first. Then checks the methods, + # and finally check the underlying hash (e.g. document front matter) + # if all the previous places didn't match. + # + # key - the string key whose value to fetch + # + # Returns the value for the given key, or nil if none exists + def [](key) + if self.class.mutable? && mutations.key?(key) + mutations[key] + elsif self.class.invokable? key + public_send key + else + fallback_data[key] + end + end + alias_method :invoke_drop, :[] + + # Set a field in the Drop. If mutable, sets in the mutations and + # returns. If not mutable, checks first if it's trying to override a + # Drop method and raises a DropMutationException if so. If not + # mutable and the key is not a method on the Drop, then it sets the + # key to the value in the underlying hash (e.g. document front + # matter) + # + # key - the String key whose value to set + # val - the Object to set the key's value to + # + # Returns the value the key was set to unless the Drop is not mutable + # and the key matches a method in which case it raises a + # DropMutationException. + def []=(key, val) + setter = SETTER_KEYS_STASH[key] || "#{key}=" + if respond_to?(setter) + public_send(setter, val) + elsif respond_to?(key.to_s) + if self.class.mutable? + mutations[key] = val + else + raise Errors::DropMutationException, "Key #{key} cannot be set in the drop." + end + else + fallback_data[key] = val + end + end + + # Generates a list of strings which correspond to content getter + # methods. + # + # Returns an Array of strings which represent method-specific keys. + def content_methods + @content_methods ||= \ + self.class.getter_method_names \ + - Jekyll::Drops::Drop.getter_method_names \ + - NON_CONTENT_METHOD_NAMES + end + + # Check if key exists in Drop + # + # key - the string key whose value to fetch + # + # Returns true if the given key is present + def key?(key) + return false if key.nil? + return true if self.class.mutable? && mutations.key?(key) + + respond_to?(key) || fallback_data.key?(key) + end + + # Generates a list of keys with user content as their values. + # This gathers up the Drop methods and keys of the mutations and + # underlying data hashes and performs a set union to ensure a list + # of unique keys for the Drop. + # + # Returns an Array of unique keys for content for the Drop. + def keys + (content_methods | + mutations.keys | + fallback_data.keys).flatten + end + + # Generate a Hash representation of the Drop by resolving each key's + # value. It includes Drop methods, mutations, and the underlying object's + # data. See the documentation for Drop#keys for more. + # + # Returns a Hash with all the keys and values resolved. + def to_h + keys.each_with_object({}) do |(key, _), result| + result[key] = self[key] + end + end + alias_method :to_hash, :to_h + + # Inspect the drop's keys and values through a JSON representation + # of its keys and values. + # + # Returns a pretty generation of the hash representation of the Drop. + def inspect + JSON.pretty_generate to_h + end + + # Generate a Hash for use in generating JSON. + # This is useful if fields need to be cleared before the JSON can generate. + # + # Returns a Hash ready for JSON generation. + def hash_for_json(*) + to_h + end + + # Generate a JSON representation of the Drop. + # + # state - the JSON::State object which determines the state of current processing. + # + # Returns a JSON representation of the Drop in a String. + def to_json(state = nil) + JSON.generate(hash_for_json(state), state) + end + + # Collects all the keys and passes each to the block in turn. + # + # block - a block which accepts one argument, the key + # + # Returns nothing. + def each_key(&block) + keys.each(&block) + end + + def each + each_key.each do |key| + yield key, self[key] + end + end + + def merge(other, &block) + dup.tap do |me| + if block.nil? + me.merge!(other) + else + me.merge!(other, block) + end + end + end + + def merge!(other) + other.each_key do |key| + if block_given? + self[key] = yield key, self[key], other[key] + else + if Utils.mergable?(self[key]) && Utils.mergable?(other[key]) + self[key] = Utils.deep_merge_hashes(self[key], other[key]) + next + end + + self[key] = other[key] unless other[key].nil? + end + end + end + + # Imitate Hash.fetch method in Drop + # + # Returns value if key is present in Drop, otherwise returns default value + # KeyError is raised if key is not present and no default value given + def fetch(key, default = nil, &block) + return self[key] if key?(key) + raise KeyError, %(key not found: "#{key}") if default.nil? && block.nil? + return yield(key) unless block.nil? + return default unless default.nil? + end + + private + + def mutations + @mutations ||= {} + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/excerpt_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/excerpt_drop.rb new file mode 100644 index 0000000..82d3cdf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/excerpt_drop.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class ExcerptDrop < DocumentDrop + def layout + @obj.doc.data["layout"] + end + + def date + @obj.doc.date + end + + def excerpt + nil + end + + def name + @obj.doc.data["name"] || @obj.doc.basename + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/jekyll_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/jekyll_drop.rb new file mode 100644 index 0000000..63187cc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/jekyll_drop.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class JekyllDrop < Liquid::Drop + class << self + def global + @global ||= JekyllDrop.new + end + end + + def version + Jekyll::VERSION + end + + def environment + Jekyll.env + end + + def to_h + @to_h ||= { + "version" => version, + "environment" => environment, + } + end + + def to_json(state = nil) + JSON.generate(to_h, state) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/site_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/site_drop.rb new file mode 100644 index 0000000..cc3c60f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/site_drop.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class SiteDrop < Drop + extend Forwardable + + mutable false + + delegate_method_as :site_data, :data + delegate_methods :time, :pages, :static_files, :tags, :categories + + private delegate_method_as :config, :fallback_data + + def [](key) + if key != "posts" && @obj.collections.key?(key) + @obj.collections[key].docs + else + super(key) + end + end + + def key?(key) + (key != "posts" && @obj.collections.key?(key)) || super + end + + def posts + @site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a } + end + + def html_pages + @site_html_pages ||= @obj.pages.select do |page| + page.html? || page.url.end_with?("/") + end + end + + def collections + @site_collections ||= @obj.collections.values.sort_by(&:label).map(&:to_liquid) + end + + # `Site#documents` cannot be memoized so that `Site#docs_to_write` can access the + # latest state of the attribute. + # + # Since this method will be called after `Site#pre_render` hook, the `Site#documents` + # array shouldn't thereafter change and can therefore be safely memoized to prevent + # additional computation of `Site#documents`. + def documents + @documents ||= @obj.documents + end + + # `{{ site.related_posts }}` is how posts can get posts related to + # them, either through LSI if it's enabled, or through the most + # recent posts. + # We should remove this in 4.0 and switch to `{{ post.related_posts }}`. + def related_posts + return nil unless @current_document.is_a?(Jekyll::Document) + + @current_document.related_posts + end + attr_writer :current_document + + # return nil for `{{ site.config }}` even if --config was passed via CLI + def config; end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/static_file_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/static_file_drop.rb new file mode 100644 index 0000000..d00973b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/static_file_drop.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class StaticFileDrop < Drop + extend Forwardable + delegate_methods :name, :extname, :modified_time, :basename + delegate_method_as :relative_path, :path + delegate_method_as :type, :collection + + private delegate_method_as :data, :fallback_data + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/theme_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/theme_drop.rb new file mode 100644 index 0000000..b462532 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/theme_drop.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class ThemeDrop < Drop + delegate_methods :root + delegate_method_as :runtime_dependencies, :dependencies + + def authors + @authors ||= gemspec.authors.join(", ") + end + + def version + @version ||= gemspec.version.to_s + end + + def description + @description ||= gemspec.description || gemspec.summary + end + + def metadata + @metadata ||= gemspec.metadata + end + + private + + def gemspec + @gemspec ||= @obj.send(:gemspec) + end + + def fallback_data + @fallback_data ||= {} + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/unified_payload_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/unified_payload_drop.rb new file mode 100644 index 0000000..709ad71 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/unified_payload_drop.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class UnifiedPayloadDrop < Drop + mutable true + + attr_accessor :content, :page, :layout, :paginator, + :highlighter_prefix, :highlighter_suffix + + def jekyll + JekyllDrop.global + end + + def site + @site_drop ||= SiteDrop.new(@obj) + end + + def theme + @theme_drop ||= ThemeDrop.new(@obj.theme) if @obj.theme + end + + private + + def fallback_data + @fallback_data ||= {} + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/url_drop.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/url_drop.rb new file mode 100644 index 0000000..de58c95 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/drops/url_drop.rb @@ -0,0 +1,140 @@ +# frozen_string_literal: true + +module Jekyll + module Drops + class UrlDrop < Drop + extend Forwardable + + mutable false + + delegate_method :output_ext + delegate_method_as :cleaned_relative_path, :path + + def collection + @obj.collection.label + end + + def name + Utils.slugify(@obj.basename_without_ext) + end + + def title + Utils.slugify(@obj.data["slug"], :mode => "pretty", :cased => true) || + Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true) + end + + def slug + Utils.slugify(@obj.data["slug"]) || Utils.slugify(@obj.basename_without_ext) + end + + def categories + category_set = Set.new + Array(@obj.data["categories"]).each do |category| + category_set << category.to_s.downcase + end + category_set.to_a.join("/") + end + + # Similar to output from #categories, but each category will be downcased and + # all non-alphanumeric characters of the category replaced with a hyphen. + def slugified_categories + Array(@obj.data["categories"]).each_with_object(Set.new) do |category, set| + set << Utils.slugify(category.to_s) + end.to_a.join("/") + end + + # CCYY + def year + @obj.date.strftime("%Y") + end + + # MM: 01..12 + def month + @obj.date.strftime("%m") + end + + # DD: 01..31 + def day + @obj.date.strftime("%d") + end + + # hh: 00..23 + def hour + @obj.date.strftime("%H") + end + + # mm: 00..59 + def minute + @obj.date.strftime("%M") + end + + # ss: 00..59 + def second + @obj.date.strftime("%S") + end + + # D: 1..31 + def i_day + @obj.date.strftime("%-d") + end + + # M: 1..12 + def i_month + @obj.date.strftime("%-m") + end + + # MMM: Jan..Dec + def short_month + @obj.date.strftime("%b") + end + + # MMMM: January..December + def long_month + @obj.date.strftime("%B") + end + + # YY: 00..99 + def short_year + @obj.date.strftime("%y") + end + + # CCYYw, ISO week year + # may differ from CCYY for the first days of January and last days of December + def w_year + @obj.date.strftime("%G") + end + + # WW: 01..53 + # %W and %U do not comply with ISO 8601-1 + def week + @obj.date.strftime("%V") + end + + # d: 1..7 (Monday..Sunday) + def w_day + @obj.date.strftime("%u") + end + + # dd: Mon..Sun + def short_day + @obj.date.strftime("%a") + end + + # ddd: Monday..Sunday + def long_day + @obj.date.strftime("%A") + end + + # DDD: 001..366 + def y_day + @obj.date.strftime("%j") + end + + private + + def fallback_data + @fallback_data ||= {} + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/entry_filter.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/entry_filter.rb new file mode 100644 index 0000000..4e70a5d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/entry_filter.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true + +module Jekyll + class EntryFilter + attr_reader :site + + SPECIAL_LEADING_CHAR_REGEX = %r!\A#{Regexp.union([".", "_", "#", "~"])}!o.freeze + + def initialize(site, base_directory = nil) + @site = site + @base_directory = derive_base_directory( + @site, base_directory.to_s.dup + ) + end + + def base_directory + @base_directory.to_s + end + + def derive_base_directory(site, base_dir) + base_dir[site.source] = "" if base_dir.start_with?(site.source) + base_dir + end + + def relative_to_source(entry) + File.join( + base_directory, entry + ) + end + + def filter(entries) + entries.reject do |e| + # Reject this entry if it is just a "dot" representation. + # e.g.: '.', '..', '_movies/.', 'music/..', etc + next true if e.end_with?(".") + + # Check if the current entry is explicitly included and cache the result + included = included?(e) + + # Reject current entry if it is excluded but not explicitly included as well. + next true if excluded?(e) && !included + + # Reject current entry if it is a symlink. + next true if symlink?(e) + + # Do not reject current entry if it is explicitly included. + next false if included + + # Reject current entry if it is special or a backup file. + special?(e) || backup?(e) + end + end + + def included?(entry) + glob_include?(site.include, entry) || + glob_include?(site.include, File.basename(entry)) + end + + def special?(entry) + SPECIAL_LEADING_CHAR_REGEX.match?(entry) || + SPECIAL_LEADING_CHAR_REGEX.match?(File.basename(entry)) + end + + def backup?(entry) + entry.end_with?("~") + end + + def excluded?(entry) + glob_include?(site.exclude - site.include, relative_to_source(entry)).tap do |excluded| + if excluded + Jekyll.logger.debug( + "EntryFilter:", + "excluded #{relative_to_source(entry)}" + ) + end + end + end + + # -- + # Check if a file is a symlink. + # NOTE: This can be converted to allowing even in safe, + # since we use Pathutil#in_path? now. + # -- + def symlink?(entry) + site.safe && File.symlink?(entry) && symlink_outside_site_source?(entry) + end + + # -- + # Check if given path is outside of current site's configured source directory. + # -- + def symlink_outside_site_source?(entry) + !File.realpath(entry).start_with?(site.in_source_dir) + end + + # Check if an entry matches a specific pattern. + # Returns true if path matches against any glob pattern, else false. + def glob_include?(enumerator, entry) + entry_with_source = PathManager.join(site.source, entry) + entry_is_directory = File.directory?(entry_with_source) + + enumerator.any? do |pattern| + case pattern + when String + pattern_with_source = PathManager.join(site.source, pattern) + + File.fnmatch?(pattern_with_source, entry_with_source) || + entry_with_source.start_with?(pattern_with_source) || + (pattern_with_source == "#{entry_with_source}/" if entry_is_directory) + when Regexp + pattern.match?(entry_with_source) + else + false + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/errors.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/errors.rb new file mode 100644 index 0000000..8d659e8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/errors.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Jekyll + module Errors + FatalException = Class.new(::RuntimeError) + + InvalidThemeName = Class.new(FatalException) + + DropMutationException = Class.new(FatalException) + InvalidPermalinkError = Class.new(FatalException) + InvalidYAMLFrontMatterError = Class.new(FatalException) + MissingDependencyException = Class.new(FatalException) + + InvalidDateError = Class.new(FatalException) + InvalidPostNameError = Class.new(FatalException) + PostURLError = Class.new(FatalException) + InvalidURLError = Class.new(FatalException) + InvalidConfigurationError = Class.new(FatalException) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/excerpt.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/excerpt.rb new file mode 100644 index 0000000..6318520 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/excerpt.rb @@ -0,0 +1,200 @@ +# frozen_string_literal: true + +module Jekyll + class Excerpt + extend Forwardable + + attr_accessor :content, :doc, :ext + attr_writer :output + + def_delegators :@doc, + :site, :name, :ext, :extname, + :collection, :related_posts, :type, + :coffeescript_file?, :yaml_file?, + :url, :next_doc, :previous_doc + + private :coffeescript_file?, :yaml_file? + + # Initialize this Excerpt instance. + # + # doc - The Document. + # + # Returns the new Excerpt. + def initialize(doc) + self.doc = doc + self.content = extract_excerpt(doc.content) + end + + # Fetch YAML front-matter data from related doc, without layout key + # + # Returns Hash of doc data + def data + @data ||= doc.data.dup + @data.delete("layout") + @data.delete("excerpt") + @data + end + + def trigger_hooks(*); end + + # 'Path' of the excerpt. + # + # Returns the path for the doc this excerpt belongs to with #excerpt appended + def path + File.join(doc.path, "#excerpt") + end + + # 'Relative Path' of the excerpt. + # + # Returns the relative_path for the doc this excerpt belongs to with #excerpt appended + def relative_path + @relative_path ||= File.join(doc.relative_path, "#excerpt") + end + + # Check if excerpt includes a string + # + # Returns true if the string passed in + def include?(something) + output&.include?(something) || content.include?(something) + end + + # The UID for this doc (useful in feeds). + # e.g. /2008/11/05/my-awesome-doc + # + # Returns the String UID. + def id + "#{doc.id}#excerpt" + end + + def to_s + output || content + end + + def to_liquid + Jekyll::Drops::ExcerptDrop.new(self) + end + + # Returns the shorthand String identifier of this doc. + def inspect + "<#{self.class} id=#{id}>" + end + + def output + @output ||= Renderer.new(doc.site, self, site.site_payload).run + end + + def place_in_layout? + false + end + + def render_with_liquid? + return false if data["render_with_liquid"] == false + + !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content)) + end + + protected + + # Internal: Extract excerpt from the content + # + # By default excerpt is your first paragraph of a doc: everything before + # the first two new lines: + # + # --- + # title: Example + # --- + # + # First paragraph with [link][1]. + # + # Second paragraph. + # + # [1]: http://example.com/ + # + # This is fairly good option for Markdown and Textile files. But might cause + # problems for HTML docs (which is quite unusual for Jekyll). If default + # excerpt delimiter is not good for you, you might want to set your own via + # configuration option `excerpt_separator`. For example, following is a good + # alternative for HTML docs: + # + # # file: _config.yml + # excerpt_separator: "" + # + # Notice that all markdown-style link references will be appended to the + # excerpt. So the example doc above will have this excerpt source: + # + # First paragraph with [link][1]. + # + # [1]: http://example.com/ + # + # Excerpts are rendered same time as content is rendered. + # + # Returns excerpt String + + LIQUID_TAG_REGEX = %r!{%-?\s*(\w+)\s*.*?-?%}!m.freeze + MKDWN_LINK_REF_REGEX = %r!^ {0,3}(?:(\[[^\]]+\])(:.+))$!.freeze + + def extract_excerpt(doc_content) + head, _, tail = doc_content.to_s.partition(doc.excerpt_separator) + return head if tail.empty? + + head = sanctify_liquid_tags(head) if head.include?("{%") + definitions = extract_markdown_link_reference_definitions(head, tail) + return head if definitions.empty? + + head << "\n\n" << definitions.join("\n") + end + + private + + # append appropriate closing tag(s) (for each Liquid block), to the `head` if the + # partitioning resulted in leaving the closing tag somewhere in the `tail` partition. + def sanctify_liquid_tags(head) + modified = false + tag_names = head.scan(LIQUID_TAG_REGEX) + tag_names.flatten! + tag_names.reverse_each do |tag_name| + next unless liquid_block?(tag_name) + next if endtag_regex_stash(tag_name).match?(head) + + modified = true + head << "\n{% end#{tag_name} %}" + end + + print_build_warning if modified + head + end + + def extract_markdown_link_reference_definitions(head, tail) + [].tap do |definitions| + tail.scan(MKDWN_LINK_REF_REGEX).each do |segments| + definitions << segments.join if head.include?(segments[0]) + end + end + end + + def endtag_regex_stash(tag_name) + @endtag_regex_stash ||= {} + @endtag_regex_stash[tag_name] ||= %r!{%-?\s*end#{tag_name}.*?\s*-?%}!m + end + + def liquid_block?(tag_name) + return false unless tag_name.is_a?(String) + return false unless Liquid::Template.tags[tag_name] + + Liquid::Template.tags[tag_name].ancestors.include?(Liquid::Block) + rescue NoMethodError + Jekyll.logger.error "Error:", + "A Liquid tag in the excerpt of #{doc.relative_path} couldn't be parsed." + raise + end + + def print_build_warning + Jekyll.logger.warn "Warning:", "Excerpt modified in #{doc.relative_path}!" + Jekyll.logger.warn "", "Found a Liquid block containing the excerpt separator " \ + "#{doc.excerpt_separator.inspect}." + Jekyll.logger.warn "", "The block has been modified with the appropriate closing tag." + Jekyll.logger.warn "", "Feel free to define a custom excerpt or excerpt_separator in the" + Jekyll.logger.warn "", "document's Front Matter if the generated excerpt is unsatisfactory." + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/external.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/external.rb new file mode 100644 index 0000000..b484160 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/external.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +module Jekyll + module External + class << self + # + # Gems that, if installed, should be loaded. + # Usually contain subcommands. + # + def blessed_gems + %w( + jekyll-compose + jekyll-docs + jekyll-import + ) + end + + # + # Require a gem or file if it's present, otherwise silently fail. + # + # names - a string gem name or array of gem names + # + def require_if_present(names) + Array(names).each do |name| + require name + rescue LoadError + Jekyll.logger.debug "Couldn't load #{name}. Skipping." + yield(name, version_constraint(name)) if block_given? + false + end + end + + # + # The version constraint required to activate a given gem. + # Usually the gem version requirement is "> 0," because any version + # will do. In the case of jekyll-docs, however, we require the exact + # same version as Jekyll. + # + # Returns a String version constraint in a parseable form for + # RubyGems. + def version_constraint(gem_name) + return "= #{Jekyll::VERSION}" if gem_name.to_s.eql?("jekyll-docs") + + "> 0" + end + + # + # Require a gem or gems. If it's not present, show a very nice error + # message that explains everything and is much more helpful than the + # normal LoadError. + # + # names - a string gem name or array of gem names + # + def require_with_graceful_fail(names) + Array(names).each do |name| + Jekyll.logger.debug "Requiring:", name.to_s + require name + rescue LoadError => e + Jekyll.logger.error "Dependency Error:", <<~MSG + Yikes! It looks like you don't have #{name} or one of its dependencies installed. + In order to use Jekyll as currently configured, you'll need to install this gem. + + If you've run Jekyll with `bundle exec`, ensure that you have included the #{name} + gem in your Gemfile as well. + + The full error message from Ruby is: '#{e.message}' + + If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/! + MSG + raise Jekyll::Errors::MissingDependencyException, name + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters.rb new file mode 100644 index 0000000..5422d52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters.rb @@ -0,0 +1,532 @@ +# frozen_string_literal: true + +require_all "jekyll/filters" + +module Jekyll + module Filters + include URLFilters + include GroupingFilters + include DateFilters + + # Convert a Markdown string into HTML output. + # + # input - The Markdown String to convert. + # + # Returns the HTML formatted String. + def markdownify(input) + @context.registers[:site].find_converter_instance( + Jekyll::Converters::Markdown + ).convert(input.to_s) + end + + # Convert quotes into smart quotes. + # + # input - The String to convert. + # + # Returns the smart-quotified String. + def smartify(input) + @context.registers[:site].find_converter_instance( + Jekyll::Converters::SmartyPants + ).convert(input.to_s) + end + + # Convert a Sass string into CSS output. + # + # input - The Sass String to convert. + # + # Returns the CSS formatted String. + def sassify(input) + @context.registers[:site].find_converter_instance( + Jekyll::Converters::Sass + ).convert(input) + end + + # Convert a Scss string into CSS output. + # + # input - The Scss String to convert. + # + # Returns the CSS formatted String. + def scssify(input) + @context.registers[:site].find_converter_instance( + Jekyll::Converters::Scss + ).convert(input) + end + + # Slugify a filename or title. + # + # input - The filename or title to slugify. + # mode - how string is slugified + # + # Returns the given filename or title as a lowercase URL String. + # See Utils.slugify for more detail. + def slugify(input, mode = nil) + Utils.slugify(input, :mode => mode) + end + + # XML escape a string for use. Replaces any special characters with + # appropriate HTML entity replacements. + # + # input - The String to escape. + # + # Examples + # + # xml_escape('foo "bar" ') + # # => "foo "bar" <baz>" + # + # Returns the escaped String. + def xml_escape(input) + input.to_s.encode(:xml => :attr).gsub(%r!\A"|"\Z!, "") + end + + # CGI escape a string for use in a URL. Replaces any special characters + # with appropriate %XX replacements. + # + # input - The String to escape. + # + # Examples + # + # cgi_escape('foo,bar;baz?') + # # => "foo%2Cbar%3Bbaz%3F" + # + # Returns the escaped String. + def cgi_escape(input) + CGI.escape(input) + end + + # URI escape a string. + # + # input - The String to escape. + # + # Examples + # + # uri_escape('foo, bar \\baz?') + # # => "foo,%20bar%20%5Cbaz?" + # + # Returns the escaped String. + def uri_escape(input) + Addressable::URI.normalize_component(input) + end + + # Replace any whitespace in the input string with a single space + # + # input - The String on which to operate. + # + # Returns the formatted String + def normalize_whitespace(input) + input.to_s.gsub(%r!\s+!, " ").tap(&:strip!) + end + + # Count the number of words in the input string. + # + # input - The String on which to operate. + # + # Returns the Integer word count. + def number_of_words(input, mode = nil) + cjk_charset = '\p{Han}\p{Katakana}\p{Hiragana}\p{Hangul}' + cjk_regex = %r![#{cjk_charset}]!o + word_regex = %r![^#{cjk_charset}\s]+!o + + case mode + when "cjk" + input.scan(cjk_regex).length + input.scan(word_regex).length + when "auto" + cjk_count = input.scan(cjk_regex).length + cjk_count.zero? ? input.split.length : cjk_count + input.scan(word_regex).length + else + input.split.length + end + end + + # Join an array of things into a string by separating with commas and the + # word "and" for the last one. + # + # array - The Array of Strings to join. + # connector - Word used to connect the last 2 items in the array + # + # Examples + # + # array_to_sentence_string(["apples", "oranges", "grapes"]) + # # => "apples, oranges, and grapes" + # + # Returns the formatted String. + def array_to_sentence_string(array, connector = "and") + case array.length + when 0 + "" + when 1 + array[0].to_s + when 2 + "#{array[0]} #{connector} #{array[1]}" + else + "#{array[0...-1].join(", ")}, #{connector} #{array[-1]}" + end + end + + # Convert the input into json string + # + # input - The Array or Hash to be converted + # + # Returns the converted json string + def jsonify(input) + as_liquid(input).to_json + end + + # Filter an array of objects + # + # input - the object array. + # property - the property within each object to filter by. + # value - the desired value. + # Cannot be an instance of Array nor Hash since calling #to_s on them returns + # their `#inspect` string object. + # + # Returns the filtered array of objects + def where(input, property, value) + return input if !property || value.is_a?(Array) || value.is_a?(Hash) + return input unless input.respond_to?(:select) + + input = input.values if input.is_a?(Hash) + input_id = input.hash + + # implement a hash based on method parameters to cache the end-result + # for given parameters. + @where_filter_cache ||= {} + @where_filter_cache[input_id] ||= {} + @where_filter_cache[input_id][property] ||= {} + + # stash or retrieve results to return + @where_filter_cache[input_id][property][value] ||= input.select do |object| + compare_property_vs_target(item_property(object, property), value) + end.to_a + end + + # Filters an array of objects against an expression + # + # input - the object array + # variable - the variable to assign each item to in the expression + # expression - a Liquid comparison expression passed in as a string + # + # Returns the filtered array of objects + def where_exp(input, variable, expression) + return input unless input.respond_to?(:select) + + input = input.values if input.is_a?(Hash) # FIXME + + condition = parse_condition(expression) + @context.stack do + input.select do |object| + @context[variable] = object + condition.evaluate(@context) + end + end || [] + end + + # Search an array of objects and returns the first object that has the queried attribute + # with the given value or returns nil otherwise. + # + # input - the object array. + # property - the property within each object to search by. + # value - the desired value. + # Cannot be an instance of Array nor Hash since calling #to_s on them returns + # their `#inspect` string object. + # + # Returns the found object or nil + # + # rubocop:disable Metrics/CyclomaticComplexity + def find(input, property, value) + return input if !property || value.is_a?(Array) || value.is_a?(Hash) + return input unless input.respond_to?(:find) + + input = input.values if input.is_a?(Hash) + input_id = input.hash + + # implement a hash based on method parameters to cache the end-result for given parameters. + @find_filter_cache ||= {} + @find_filter_cache[input_id] ||= {} + @find_filter_cache[input_id][property] ||= {} + + # stash or retrieve results to return + # Since `enum.find` can return nil or false, we use a placeholder string "<__NO MATCH__>" + # to validate caching. + result = @find_filter_cache[input_id][property][value] ||= input.find do |object| + compare_property_vs_target(item_property(object, property), value) + end || "<__NO MATCH__>" + + return nil if result == "<__NO MATCH__>" + + result + end + # rubocop:enable Metrics/CyclomaticComplexity + + # Searches an array of objects against an expression and returns the first object for which + # the expression evaluates to true, or returns nil otherwise. + # + # input - the object array + # variable - the variable to assign each item to in the expression + # expression - a Liquid comparison expression passed in as a string + # + # Returns the found object or nil + def find_exp(input, variable, expression) + return input unless input.respond_to?(:find) + + input = input.values if input.is_a?(Hash) + + condition = parse_condition(expression) + @context.stack do + input.find do |object| + @context[variable] = object + condition.evaluate(@context) + end + end + end + + # Convert the input into integer + # + # input - the object string + # + # Returns the integer value + def to_integer(input) + return 1 if input == true + return 0 if input == false + + input.to_i + end + + # Sort an array of objects + # + # input - the object array + # property - property within each object to filter by + # nils ('first' | 'last') - nils appear before or after non-nil values + # + # Returns the filtered array of objects + def sort(input, property = nil, nils = "first") + raise ArgumentError, "Cannot sort a null object." if input.nil? + + if property.nil? + input.sort + else + case nils + when "first" + order = - 1 + when "last" + order = + 1 + else + raise ArgumentError, "Invalid nils order: " \ + "'#{nils}' is not a valid nils order. It must be 'first' or 'last'." + end + + sort_input(input, property, order) + end + end + + def pop(array, num = 1) + return array unless array.is_a?(Array) + + num = Liquid::Utils.to_integer(num) + new_ary = array.dup + new_ary.pop(num) + new_ary + end + + def push(array, input) + return array unless array.is_a?(Array) + + new_ary = array.dup + new_ary.push(input) + new_ary + end + + def shift(array, num = 1) + return array unless array.is_a?(Array) + + num = Liquid::Utils.to_integer(num) + new_ary = array.dup + new_ary.shift(num) + new_ary + end + + def unshift(array, input) + return array unless array.is_a?(Array) + + new_ary = array.dup + new_ary.unshift(input) + new_ary + end + + def sample(input, num = 1) + return input unless input.respond_to?(:sample) + + num = Liquid::Utils.to_integer(num) rescue 1 + if num == 1 + input.sample + else + input.sample(num) + end + end + + # Convert an object into its String representation for debugging + # + # input - The Object to be converted + # + # Returns a String representation of the object. + def inspect(input) + xml_escape(input.inspect) + end + + private + + # Sort the input Enumerable by the given property. + # If the property doesn't exist, return the sort order respective of + # which item doesn't have the property. + # We also utilize the Schwartzian transform to make this more efficient. + def sort_input(input, property, order) + input.map { |item| [item_property(item, property), item] } + .sort! do |a_info, b_info| + a_property = a_info.first + b_property = b_info.first + + if !a_property.nil? && b_property.nil? + - order + elsif a_property.nil? && !b_property.nil? + + order + else + a_property <=> b_property || a_property.to_s <=> b_property.to_s + end + end + .map!(&:last) + end + + # `where` filter helper + # + def compare_property_vs_target(property, target) + case target + when NilClass + return true if property.nil? + when Liquid::Expression::MethodLiteral # `empty` or `blank` + target = target.to_s + return true if property == target || Array(property).join == target + else + target = target.to_s + if property.is_a? String + return true if property == target + else + Array(property).each do |prop| + return true if prop.to_s == target + end + end + end + + false + end + + def item_property(item, property) + @item_property_cache ||= @context.registers[:site].filter_cache[:item_property] ||= {} + @item_property_cache[property] ||= {} + @item_property_cache[property][item] ||= begin + property = property.to_s + property = if item.respond_to?(:to_liquid) + read_liquid_attribute(item.to_liquid, property) + elsif item.respond_to?(:data) + item.data[property] + else + item[property] + end + + parse_sort_input(property) + end + end + + def read_liquid_attribute(liquid_data, property) + return liquid_data[property] unless property.include?(".") + + property.split(".").reduce(liquid_data) do |data, key| + data.respond_to?(:[]) && data[key] + end + end + + FLOAT_LIKE = %r!\A\s*-?(?:\d+\.?\d*|\.\d+)\s*\Z!.freeze + INTEGER_LIKE = %r!\A\s*-?\d+\s*\Z!.freeze + private_constant :FLOAT_LIKE, :INTEGER_LIKE + + # return numeric values as numbers for proper sorting + def parse_sort_input(property) + stringified = property.to_s + return property.to_i if INTEGER_LIKE.match?(stringified) + return property.to_f if FLOAT_LIKE.match?(stringified) + + property + end + + def as_liquid(item) + case item + when Hash + item.each_with_object({}) { |(k, v), result| result[as_liquid(k)] = as_liquid(v) } + when Array + item.map { |i| as_liquid(i) } + else + if item.respond_to?(:to_liquid) + liquidated = item.to_liquid + # prevent infinite recursion for simple types (which return `self`) + if liquidated == item + item + else + as_liquid(liquidated) + end + else + item + end + end + end + + # ----------- The following set of code was *adapted* from Liquid::If + # ----------- ref: https://github.com/Shopify/liquid/blob/ffb0ace30315bbcf3548a0383fab531452060ae8/lib/liquid/tags/if.rb#L84-L107 + + # Parse a string to a Liquid Condition + def parse_condition(exp) + parser = Liquid::Parser.new(exp) + condition = parse_binary_comparison(parser) + + parser.consume(:end_of_string) + condition + end + + # Generate a Liquid::Condition object from a Liquid::Parser object additionally processing + # the parsed expression based on whether the expression consists of binary operations with + # Liquid operators `and` or `or` + # + # - parser: an instance of Liquid::Parser + # + # Returns an instance of Liquid::Condition + def parse_binary_comparison(parser) + condition = parse_comparison(parser) + first_condition = condition + while (binary_operator = parser.id?("and") || parser.id?("or")) + child_condition = parse_comparison(parser) + condition.send(binary_operator, child_condition) + condition = child_condition + end + first_condition + end + + # Generates a Liquid::Condition object from a Liquid::Parser object based on whether the parsed + # expression involves a "comparison" operator (e.g. <, ==, >, !=, etc) + # + # - parser: an instance of Liquid::Parser + # + # Returns an instance of Liquid::Condition + def parse_comparison(parser) + left_operand = Liquid::Expression.parse(parser.expression) + operator = parser.consume?(:comparison) + + # No comparison-operator detected. Initialize a Liquid::Condition using only left operand + return Liquid::Condition.new(left_operand) unless operator + + # Parse what remained after extracting the left operand and the `:comparison` operator + # and initialize a Liquid::Condition object using the operands and the comparison-operator + Liquid::Condition.new(left_operand, operator, Liquid::Expression.parse(parser.expression)) + end + end +end + +Liquid::Template.register_filter( + Jekyll::Filters +) diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/date_filters.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/date_filters.rb new file mode 100644 index 0000000..966b49b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/date_filters.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +module Jekyll + module Filters + module DateFilters + # Format a date in short format e.g. "27 Jan 2011". + # Ordinal format is also supported, in both the UK + # (e.g. "27th Jan 2011") and US ("e.g. Jan 27th, 2011") formats. + # UK format is the default. + # + # date - the Time to format. + # type - if "ordinal" the returned String will be in ordinal format + # style - if "US" the returned String will be in US format. + # Otherwise it will be in UK format. + # + # Returns the formatting String. + def date_to_string(date, type = nil, style = nil) + stringify_date(date, "%b", type, style) + end + + # Format a date in long format e.g. "27 January 2011". + # Ordinal format is also supported, in both the UK + # (e.g. "27th January 2011") and US ("e.g. January 27th, 2011") formats. + # UK format is the default. + # + # date - the Time to format. + # type - if "ordinal" the returned String will be in ordinal format + # style - if "US" the returned String will be in US format. + # Otherwise it will be in UK format. + # + # Returns the formatted String. + def date_to_long_string(date, type = nil, style = nil) + stringify_date(date, "%B", type, style) + end + + # Format a date for use in XML. + # + # date - The Time to format. + # + # Examples + # + # date_to_xmlschema(Time.now) + # # => "2011-04-24T20:34:46+08:00" + # + # Returns the formatted String. + def date_to_xmlschema(date) + return date if date.to_s.empty? + + time(date).xmlschema + end + + # Format a date according to RFC-822 + # + # date - The Time to format. + # + # Examples + # + # date_to_rfc822(Time.now) + # # => "Sun, 24 Apr 2011 12:34:46 +0000" + # + # Returns the formatted String. + def date_to_rfc822(date) + return date if date.to_s.empty? + + time(date).rfc822 + end + + private + + # month_type: Notations that evaluate to 'Month' via `Time#strftime` ("%b", "%B") + # type: nil (default) or "ordinal" + # style: nil (default) or "US" + # + # Returns a stringified date or the empty input. + def stringify_date(date, month_type, type = nil, style = nil) + return date if date.to_s.empty? + + time = time(date) + if type == "ordinal" + day = time.day + ordinal_day = "#{day}#{ordinal(day)}" + return time.strftime("#{month_type} #{ordinal_day}, %Y") if style == "US" + + return time.strftime("#{ordinal_day} #{month_type} %Y") + end + time.strftime("%d #{month_type} %Y") + end + + def ordinal(number) + return "th" if (11..13).cover?(number) + + case number % 10 + when 1 then "st" + when 2 then "nd" + when 3 then "rd" + else "th" + end + end + + def time(input) + date = Liquid::Utils.to_date(input) + unless date.respond_to?(:to_time) + raise Errors::InvalidDateError, + "Invalid Date: '#{input.inspect}' is not a valid datetime." + end + date.to_time.dup.localtime + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/grouping_filters.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/grouping_filters.rb new file mode 100644 index 0000000..c9cdc65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/grouping_filters.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module Jekyll + module Filters + module GroupingFilters + # Group an array of items by a property + # + # input - the inputted Enumerable + # property - the property + # + # Returns an array of Hashes, each looking something like this: + # {"name" => "larry" + # "items" => [...] } # all the items where `property` == "larry" + def group_by(input, property) + if groupable?(input) + groups = input.group_by { |item| item_property(item, property).to_s } + grouped_array(groups) + else + input + end + end + + # Group an array of items by an expression + # + # input - the object array + # variable - the variable to assign each item to in the expression + # expression -a Liquid comparison expression passed in as a string + # + # Returns the filtered array of objects + def group_by_exp(input, variable, expression) + return input unless groupable?(input) + + parsed_expr = parse_expression(expression) + @context.stack do + groups = input.group_by do |item| + @context[variable] = item + parsed_expr.render(@context) + end + grouped_array(groups) + end + end + + private + + def parse_expression(str) + Liquid::Variable.new(str, Liquid::ParseContext.new) + end + + def groupable?(element) + element.respond_to?(:group_by) + end + + def grouped_array(groups) + groups.each_with_object([]) do |item, array| + array << { + "name" => item.first, + "items" => item.last, + "size" => item.last.size, + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/url_filters.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/url_filters.rb new file mode 100644 index 0000000..aa28c5a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/filters/url_filters.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: true + +module Jekyll + module Filters + module URLFilters + # Produces an absolute URL based on site.url and site.baseurl. + # + # input - the URL to make absolute. + # + # Returns the absolute URL as a String. + def absolute_url(input) + return if input.nil? + + cache = if input.is_a?(String) + (@context.registers[:site].filter_cache[:absolute_url] ||= {}) + else + (@context.registers[:cached_absolute_url] ||= {}) + end + cache[input] ||= compute_absolute_url(input) + + # Duplicate cached string so that the cached value is never mutated by + # a subsequent filter. + cache[input].dup + end + + # Produces a URL relative to the domain root based on site.baseurl + # unless it is already an absolute url with an authority (host). + # + # input - the URL to make relative to the domain root + # + # Returns a URL relative to the domain root as a String. + def relative_url(input) + return if input.nil? + + cache = if input.is_a?(String) + (@context.registers[:site].filter_cache[:relative_url] ||= {}) + else + (@context.registers[:cached_relative_url] ||= {}) + end + cache[input] ||= compute_relative_url(input) + + # Duplicate cached string so that the cached value is never mutated by + # a subsequent filter. + cache[input].dup + end + + # Strips trailing `/index.html` from URLs to create pretty permalinks + # + # input - the URL with a possible `/index.html` + # + # Returns a URL with the trailing `/index.html` removed + def strip_index(input) + return if input.nil? || input.to_s.empty? + + input.sub(%r!/index\.html?$!, "/") + end + + private + + def compute_absolute_url(input) + input = input.url if input.respond_to?(:url) + return input if Addressable::URI.parse(input.to_s).absolute? + + site = @context.registers[:site] + site_url = site.config["url"] + return relative_url(input) if site_url.nil? || site_url == "" + + Addressable::URI.parse( + site_url.to_s + relative_url(input) + ).normalize.to_s + end + + def compute_relative_url(input) + input = input.url if input.respond_to?(:url) + return input if Addressable::URI.parse(input.to_s).absolute? + + parts = [sanitized_baseurl, input] + Addressable::URI.parse( + parts.map! { |part| ensure_leading_slash(part.to_s) }.join + ).normalize.to_s + end + + def sanitized_baseurl + site = @context.registers[:site] + baseurl = site.config["baseurl"] + return "" if baseurl.nil? + + baseurl.to_s.chomp("/") + end + + def ensure_leading_slash(input) + return input if input.nil? || input.empty? || input.start_with?("/") + + "/#{input}" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/frontmatter_defaults.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/frontmatter_defaults.rb new file mode 100644 index 0000000..5ad896b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/frontmatter_defaults.rb @@ -0,0 +1,238 @@ +# frozen_string_literal: true + +module Jekyll + # This class handles custom defaults for YAML frontmatter settings. + # These are set in _config.yml and apply both to internal use (e.g. layout) + # and the data available to liquid. + # + # It is exposed via the frontmatter_defaults method on the site class. + class FrontmatterDefaults + # Initializes a new instance. + def initialize(site) + @site = site + end + + def reset + @glob_cache = {} if @glob_cache + end + + def update_deprecated_types(set) + return set unless set.key?("scope") && set["scope"].key?("type") + + set["scope"]["type"] = + case set["scope"]["type"] + when "page" + Deprecator.defaults_deprecate_type("page", "pages") + "pages" + when "post" + Deprecator.defaults_deprecate_type("post", "posts") + "posts" + when "draft" + Deprecator.defaults_deprecate_type("draft", "drafts") + "drafts" + else + set["scope"]["type"] + end + + set + end + + def ensure_time!(set) + return set unless set.key?("values") && set["values"].key?("date") + return set if set["values"]["date"].is_a?(Time) + + set["values"]["date"] = Utils.parse_date( + set["values"]["date"], + "An invalid date format was found in a front-matter default set: #{set}" + ) + set + end + + # Finds a default value for a given setting, filtered by path and type + # + # path - the path (relative to the source) of the page, + # post or :draft the default is used in + # type - a symbol indicating whether a :page, + # a :post or a :draft calls this method + # + # Returns the default value or nil if none was found + def find(path, type, setting) + value = nil + old_scope = nil + + matching_sets(path, type).each do |set| + if set["values"].key?(setting) && has_precedence?(old_scope, set["scope"]) + value = set["values"][setting] + old_scope = set["scope"] + end + end + value + end + + # Collects a hash with all default values for a page or post + # + # path - the relative path of the page or post + # type - a symbol indicating the type (:post, :page or :draft) + # + # Returns a hash with all default values (an empty hash if there are none) + def all(path, type) + defaults = {} + old_scope = nil + matching_sets(path, type).each do |set| + if has_precedence?(old_scope, set["scope"]) + defaults = Utils.deep_merge_hashes(defaults, set["values"]) + old_scope = set["scope"] + else + defaults = Utils.deep_merge_hashes(set["values"], defaults) + end + end + defaults + end + + private + + # Checks if a given default setting scope matches the given path and type + # + # scope - the hash indicating the scope, as defined in _config.yml + # path - the path to check for + # type - the type (:post, :page or :draft) to check for + # + # Returns true if the scope applies to the given type and path + def applies?(scope, path, type) + applies_type?(scope, type) && applies_path?(scope, path) + end + + def applies_path?(scope, path) + rel_scope_path = scope["path"] + return true if !rel_scope_path.is_a?(String) || rel_scope_path.empty? + + sanitized_path = sanitize_path(path) + + if rel_scope_path.include?("*") + glob_scope(sanitized_path, rel_scope_path) + else + path_is_subpath?(sanitized_path, strip_collections_dir(rel_scope_path)) + end + end + + def glob_scope(sanitized_path, rel_scope_path) + site_source = Pathname.new(@site.source) + abs_scope_path = site_source.join(rel_scope_path).to_s + + glob_cache(abs_scope_path).each do |scope_path| + scope_path = Pathname.new(scope_path).relative_path_from(site_source).to_s + scope_path = strip_collections_dir(scope_path) + Jekyll.logger.debug "Globbed Scope Path:", scope_path + return true if path_is_subpath?(sanitized_path, scope_path) + end + false + end + + def glob_cache(path) + @glob_cache ||= {} + @glob_cache[path] ||= Dir.glob(path) + end + + def path_is_subpath?(path, parent_path) + path.start_with?(parent_path) + end + + def strip_collections_dir(path) + collections_dir = @site.config["collections_dir"] + slashed_coll_dir = collections_dir.empty? ? "/" : "#{collections_dir}/" + return path if collections_dir.empty? || !path.to_s.start_with?(slashed_coll_dir) + + path.sub(slashed_coll_dir, "") + end + + # Determines whether the scope applies to type. + # The scope applies to the type if: + # 1. no 'type' is specified + # 2. the 'type' in the scope is the same as the type asked about + # + # scope - the Hash defaults set being asked about application + # type - the type of the document being processed / asked about + # its defaults. + # + # Returns true if either of the above conditions are satisfied, + # otherwise returns false + def applies_type?(scope, type) + !scope.key?("type") || type&.to_sym.eql?(scope["type"].to_sym) + end + + # Checks if a given set of default values is valid + # + # set - the default value hash, as defined in _config.yml + # + # Returns true if the set is valid and can be used in this class + def valid?(set) + set.is_a?(Hash) && set["values"].is_a?(Hash) + end + + # Determines if a new scope has precedence over an old one + # + # old_scope - the old scope hash, or nil if there's none + # new_scope - the new scope hash + # + # Returns true if the new scope has precedence over the older + # rubocop: disable Naming/PredicateName + def has_precedence?(old_scope, new_scope) + return true if old_scope.nil? + + new_path = sanitize_path(new_scope["path"]) + old_path = sanitize_path(old_scope["path"]) + + if new_path.length != old_path.length + new_path.length >= old_path.length + elsif new_scope.key?("type") + true + else + !old_scope.key? "type" + end + end + # rubocop: enable Naming/PredicateName + + # Collects a list of sets that match the given path and type + # + # Returns an array of hashes + def matching_sets(path, type) + @matched_set_cache ||= {} + @matched_set_cache[path] ||= {} + @matched_set_cache[path][type] ||= valid_sets.select do |set| + !set.key?("scope") || applies?(set["scope"], path, type) + end + end + + # Returns a list of valid sets + # + # This is not cached to allow plugins to modify the configuration + # and have their changes take effect + # + # Returns an array of hashes + def valid_sets + sets = @site.config["defaults"] + return [] unless sets.is_a?(Array) + + sets.map do |set| + if valid?(set) + ensure_time!(update_deprecated_types(set)) + else + Jekyll.logger.warn "Defaults:", "An invalid front-matter default set was found:" + Jekyll.logger.warn set.to_s + nil + end + end.tap(&:compact!) + end + + # Sanitizes the given path by removing a leading slash + def sanitize_path(path) + if path.nil? || path.empty? + "" + elsif path.start_with?("/") + path.gsub(%r!\A/|(?<=[^/])\z!, "") + else + path + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/generator.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/generator.rb new file mode 100644 index 0000000..649715f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/generator.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Jekyll + Generator = Class.new(Plugin) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/hooks.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/hooks.rb new file mode 100644 index 0000000..482d802 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/hooks.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +module Jekyll + module Hooks + DEFAULT_PRIORITY = 20 + + # compatibility layer for octopress-hooks users + PRIORITY_MAP = { + :low => 10, + :normal => 20, + :high => 30, + }.freeze + + # initial empty hooks + @registry = { + :site => { + :after_init => [], + :after_reset => [], + :post_read => [], + :pre_render => [], + :post_render => [], + :post_write => [], + }, + :pages => { + :post_init => [], + :pre_render => [], + :post_convert => [], + :post_render => [], + :post_write => [], + }, + :posts => { + :post_init => [], + :pre_render => [], + :post_convert => [], + :post_render => [], + :post_write => [], + }, + :documents => { + :post_init => [], + :pre_render => [], + :post_convert => [], + :post_render => [], + :post_write => [], + }, + :clean => { + :on_obsolete => [], + }, + } + + # map of all hooks and their priorities + @hook_priority = {} + + NotAvailable = Class.new(RuntimeError) + Uncallable = Class.new(RuntimeError) + + # register hook(s) to be called later, public API + def self.register(owners, event, priority: DEFAULT_PRIORITY, &block) + Array(owners).each do |owner| + register_one(owner, event, priority_value(priority), &block) + end + end + + # Ensure the priority is a Fixnum + def self.priority_value(priority) + return priority if priority.is_a?(Integer) + + PRIORITY_MAP[priority] || DEFAULT_PRIORITY + end + + # register a single hook to be called later, internal API + def self.register_one(owner, event, priority, &block) + @registry[owner] ||= { + :post_init => [], + :pre_render => [], + :post_convert => [], + :post_render => [], + :post_write => [], + } + + unless @registry[owner][event] + raise NotAvailable, "Invalid hook. #{owner} supports only the following hooks " \ + "#{@registry[owner].keys.inspect}" + end + + raise Uncallable, "Hooks must respond to :call" unless block.respond_to? :call + + insert_hook owner, event, priority, &block + end + + def self.insert_hook(owner, event, priority, &block) + @hook_priority[block] = [-priority, @hook_priority.size] + @registry[owner][event] << block + end + + # interface for Jekyll core components to trigger hooks + def self.trigger(owner, event, *args) + # proceed only if there are hooks to call + hooks = @registry.dig(owner, event) + return if hooks.nil? || hooks.empty? + + # sort and call hooks according to priority and load order + hooks.sort_by { |h| @hook_priority[h] }.each do |hook| + hook.call(*args) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/inclusion.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/inclusion.rb new file mode 100644 index 0000000..179ddb0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/inclusion.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Jekyll + class Inclusion + attr_reader :site, :name, :path + private :site + + def initialize(site, base, name) + @site = site + @name = name + @path = PathManager.join(base, name) + end + + def render(context) + @template ||= site.liquid_renderer.file(path).parse(content) + @template.render!(context) + rescue Liquid::Error => e + e.template_name = path + e.markup_context = "included " if e.markup_context.nil? + raise e + end + + def content + @content ||= File.read(path, **site.file_read_opts) + end + + def inspect + "#{self.class} #{path.inspect}" + end + alias_method :to_s, :inspect + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/layout.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/layout.rb new file mode 100644 index 0000000..af3ea71 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/layout.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Jekyll + class Layout + include Convertible + + attr_accessor :content, # content of layout + :data, # the Hash that holds the metadata for this layout + :ext # extension of layout + + attr_reader :name, # name of layout + :path, # path to layout + :site, # the Site object + :relative_path # path to layout relative to its base + + # Initialize a new Layout. + # + # site - The Site. + # base - The String path to the source. + # name - The String filename of the post file. + def initialize(site, base, name) + @site = site + @base = base + @name = name + + if site.theme && site.theme.layouts_path.eql?(base) + @base_dir = site.theme.root + @path = site.in_theme_dir(base, name) + else + @base_dir = site.source + @path = site.in_source_dir(base, name) + end + @relative_path = @path.sub(@base_dir, "") + + self.data = {} + + process(name) + read_yaml(base, name) + end + + # Extract information from the layout filename. + # + # name - The String filename of the layout file. + # + # Returns nothing. + def process(name) + self.ext = File.extname(name) + end + + # Returns the object as a debug String. + def inspect + "#<#{self.class} @path=#{@path.inspect}>" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_extensions.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_extensions.rb new file mode 100644 index 0000000..87e06ef --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_extensions.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Jekyll + module LiquidExtensions + # Lookup a Liquid variable in the given context. + # + # context - the Liquid context in question. + # variable - the variable name, as a string. + # + # Returns the value of the variable in the context + # or the variable name if not found. + def lookup_variable(context, variable) + lookup = context + + variable.split(".").each do |value| + lookup = lookup[value] + end + + lookup || variable + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer.rb new file mode 100644 index 0000000..7655e04 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +require_relative "liquid_renderer/file" +require_relative "liquid_renderer/table" + +module Jekyll + class LiquidRenderer + def initialize(site) + @site = site + Liquid::Template.error_mode = @site.config["liquid"]["error_mode"].to_sym + reset + end + + def reset + @stats = {} + @cache = {} + end + + def file(filename) + filename = normalize_path(filename) + LiquidRenderer::File.new(self, filename).tap do + @stats[filename] ||= new_profile_hash + end + end + + def increment_bytes(filename, bytes) + @stats[filename][:bytes] += bytes + end + + def increment_time(filename, time) + @stats[filename][:time] += time + end + + def increment_count(filename) + @stats[filename][:count] += 1 + end + + def stats_table(num_of_rows = 50) + LiquidRenderer::Table.new(@stats).to_s(num_of_rows) + end + + def self.format_error(error, path) + "#{error.message} in #{path}" + end + + # A persistent cache to store and retrieve parsed templates based on the filename + # via `LiquidRenderer::File#parse` + # + # It is emptied when `self.reset` is called. + def cache + @cache ||= {} + end + + private + + def normalize_path(filename) + @normalize_path ||= {} + @normalize_path[filename] ||= begin + theme_dir = @site.theme&.root + case filename + when %r!\A(#{Regexp.escape(@site.source)}/)(?.*)!io + Regexp.last_match(:rest) + when %r!(/gems/.*)*/gems/(?[^/]+)(?.*)!, + %r!(?[^/]+/lib)(?.*)! + "#{Regexp.last_match(:dirname)}#{Regexp.last_match(:rest)}" + when theme_dir && %r!\A#{Regexp.escape(theme_dir)}/(?.*)!io + PathManager.join(@site.theme.basename, Regexp.last_match(:rest)) + when %r!\A/(.*)! + Regexp.last_match(1) + else + filename + end + end + end + + def new_profile_hash + Hash.new { |hash, key| hash[key] = 0 } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer/file.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer/file.rb new file mode 100644 index 0000000..146c416 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer/file.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Jekyll + class LiquidRenderer + class File + def initialize(renderer, filename) + @renderer = renderer + @filename = filename + end + + def parse(content) + measure_time do + @renderer.cache[@filename] ||= Liquid::Template.parse(content, :line_numbers => true) + end + @template = @renderer.cache[@filename] + + self + end + + def render(*args) + reset_template_assigns + + measure_time do + measure_bytes do + measure_counts do + @template.render(*args) + end + end + end + end + + # This method simply 'rethrows any error' before attempting to render the template. + def render!(*args) + reset_template_assigns + + measure_time do + measure_bytes do + measure_counts do + @template.render!(*args) + end + end + end + end + + def warnings + @template.warnings + end + + private + + # clear assigns to `Liquid::Template` instance prior to rendering since + # `Liquid::Template` instances are cached in Jekyll 4. + def reset_template_assigns + @template.instance_assigns.clear + end + + def measure_counts + @renderer.increment_count(@filename) + yield + end + + def measure_bytes + yield.tap do |str| + @renderer.increment_bytes(@filename, str.bytesize) + end + end + + def measure_time + before = Time.now + yield + ensure + after = Time.now + @renderer.increment_time(@filename, after - before) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer/table.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer/table.rb new file mode 100644 index 0000000..2d06a26 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/liquid_renderer/table.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module Jekyll + class LiquidRenderer + class Table + GAUGES = [:count, :bytes, :time].freeze + + def initialize(stats) + @stats = stats + end + + def to_s(num_of_rows = 50) + Jekyll::Profiler.tabulate(data_for_table(num_of_rows)) + end + + private + + def data_for_table(num_of_rows) + sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] } + sorted = sorted.slice(0, num_of_rows) + + table = [header_labels] + sorted.each do |filename, file_stats| + row = [] + row << filename + row << file_stats[:count].to_s + row << format_bytes(file_stats[:bytes]) + row << format("%.3f", file_stats[:time]) + table << row + end + + table + end + + def header_labels + GAUGES.map { |gauge| gauge.to_s.capitalize }.unshift("Filename") + end + + def format_bytes(bytes) + bytes /= 1024.0 + format("%.2fK", bytes) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/log_adapter.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/log_adapter.rb new file mode 100644 index 0000000..6ddfa4a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/log_adapter.rb @@ -0,0 +1,151 @@ +# frozen_string_literal: true + +module Jekyll + class LogAdapter + attr_reader :writer, :messages, :level + + LOG_LEVELS = { + :debug => ::Logger::DEBUG, + :info => ::Logger::INFO, + :warn => ::Logger::WARN, + :error => ::Logger::ERROR, + }.freeze + + # Public: Create a new instance of a log writer + # + # writer - Logger compatible instance + # log_level - (optional, symbol) the log level + # + # Returns nothing + def initialize(writer, level = :info) + @messages = [] + @writer = writer + self.log_level = level + end + + # Public: Set the log level on the writer + # + # level - (symbol) the log level + # + # Returns nothing + def log_level=(level) + writer.level = level if level.is_a?(Integer) && level.between?(0, 3) + writer.level = LOG_LEVELS[level] || + raise(ArgumentError, "unknown log level") + @level = level + end + + def adjust_verbosity(options = {}) + # Quiet always wins. + if options[:quiet] + self.log_level = :error + elsif options[:verbose] + self.log_level = :debug + end + debug "Logging at level:", LOG_LEVELS.key(writer.level).to_s + debug "Jekyll Version:", Jekyll::VERSION + end + + # Public: Print a debug message + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # message - the message detail + # + # Returns nothing + def debug(topic, message = nil, &block) + write(:debug, topic, message, &block) + end + + # Public: Print a message + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # message - the message detail + # + # Returns nothing + def info(topic, message = nil, &block) + write(:info, topic, message, &block) + end + + # Public: Print a message + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # message - the message detail + # + # Returns nothing + def warn(topic, message = nil, &block) + write(:warn, topic, message, &block) + end + + # Public: Print an error message + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # message - the message detail + # + # Returns nothing + def error(topic, message = nil, &block) + write(:error, topic, message, &block) + end + + # Public: Print an error message and immediately abort the process + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # message - the message detail (can be omitted) + # + # Returns nothing + def abort_with(topic, message = nil, &block) + error(topic, message, &block) + abort + end + + # Internal: Build a topic method + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # message - the message detail + # + # Returns the formatted message + def message(topic, message = nil) + raise ArgumentError, "block or message, not both" if block_given? && message + + message = yield if block_given? + message = message.to_s.gsub(%r!\s+!, " ") + topic = formatted_topic(topic, block_given?) + out = topic + message + messages << out + out + end + + # Internal: Format the topic + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # colon - + # + # Returns the formatted topic statement + def formatted_topic(topic, colon = false) + "#{topic}#{colon ? ": " : " "}".rjust(20) + end + + # Internal: Check if the message should be written given the log level. + # + # level_of_message - the Symbol level of message, one of :debug, :info, :warn, :error + # + # Returns whether the message should be written. + def write_message?(level_of_message) + LOG_LEVELS.fetch(level) <= LOG_LEVELS.fetch(level_of_message) + end + + # Internal: Log a message. + # + # level_of_message - the Symbol level of message, one of :debug, :info, :warn, :error + # topic - the String topic or full message + # message - the String message (optional) + # block - a block containing the message (optional) + # + # Returns false if the message was not written, otherwise returns the value of calling + # the appropriate writer method, e.g. writer.info. + def write(level_of_message, topic, message = nil, &block) + return false unless write_message?(level_of_message) + + writer.public_send(level_of_message, message(topic, message, &block)) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/mime.types b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/mime.types new file mode 100644 index 0000000..10f713c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/mime.types @@ -0,0 +1,940 @@ +# Woah there. Do not edit this file directly. +# This file is generated automatically by script/vendor-mimes. + +application/andrew-inset ez +application/applixware aw +application/atom+xml atom +application/atomcat+xml atomcat +application/atomdeleted+xml atomdeleted +application/atomsvc+xml atomsvc +application/atsc-dwd+xml dwd +application/atsc-held+xml held +application/atsc-rsat+xml rsat +application/bdoc bdoc +application/calendar+xml xcs +application/ccxml+xml ccxml +application/cdfx+xml cdfx +application/cdmi-capability cdmia +application/cdmi-container cdmic +application/cdmi-domain cdmid +application/cdmi-object cdmio +application/cdmi-queue cdmiq +application/cpl+xml cpl +application/cu-seeme cu +application/dash+xml mpd +application/dash-patch+xml mpp +application/davmount+xml davmount +application/docbook+xml dbk +application/dssc+der dssc +application/dssc+xml xdssc +application/ecmascript ecma es +application/emma+xml emma +application/emotionml+xml emotionml +application/epub+zip epub +application/exi exi +application/express exp +application/fdt+xml fdt +application/font-tdpfr pfr +application/geo+json geojson +application/gml+xml gml +application/gpx+xml gpx +application/gxf gxf +application/gzip gz +application/hjson hjson +application/hyperstudio stk +application/inkml+xml ink inkml +application/ipfix ipfix +application/its+xml its +application/java-archive ear jar war +application/java-serialized-object ser +application/java-vm class +application/javascript js mjs +application/json json map +application/json5 json5 +application/jsonml+json jsonml +application/ld+json jsonld +application/lgr+xml lgr +application/lost+xml lostxml +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/mads+xml mads +application/manifest+json webmanifest +application/marc mrc +application/marcxml+xml mrcx +application/mathematica ma mb nb +application/mathml+xml mathml +application/mbox mbox +application/media-policy-dataset+xml mpf +application/mediaservercontrol+xml mscml +application/metalink+xml metalink +application/metalink4+xml meta4 +application/mets+xml mets +application/mmt-aei+xml maei +application/mmt-usd+xml musd +application/mods+xml mods +application/mp21 m21 mp21 +application/mp4 m4p mp4s +application/msword doc dot +application/mxf mxf +application/n-quads nq +application/n-triples nt +application/node cjs +application/octet-stream bin bpk buffer deb deploy dist distz dll dmg dms dump elc exe img iso lrf mar msi msm msp pkg so +application/oda oda +application/oebps-package+xml opf +application/ogg ogx +application/omdoc+xml omdoc +application/onenote onepkg onetmp onetoc onetoc2 +application/oxps oxps +application/p2p-overlay+xml relo +application/patch-ops-error+xml xer +application/pdf pdf +application/pgp-encrypted pgp +application/pgp-keys asc +application/pgp-signature sig +application/pics-rules prf +application/pkcs10 p10 +application/pkcs7-mime p7c p7m +application/pkcs7-signature p7s +application/pkcs8 p8 +application/pkix-attr-cert ac +application/pkix-cert cer +application/pkix-crl crl +application/pkix-pkipath pkipath +application/pkixcmp pki +application/pls+xml pls +application/postscript ai eps ps +application/provenance+xml provx +application/prs.cww cww +application/pskc+xml pskcxml +application/raml+yaml raml +application/rdf+xml owl rdf +application/reginfo+xml rif +application/relax-ng-compact-syntax rnc +application/resource-lists+xml rl +application/resource-lists-diff+xml rld +application/rls-services+xml rs +application/route-apd+xml rapd +application/route-s-tsid+xml sls +application/route-usd+xml rusd +application/rpki-ghostbusters gbr +application/rpki-manifest mft +application/rpki-roa roa +application/rsd+xml rsd +application/rss+xml rss +application/rtf rtf +application/sbml+xml sbml +application/scvp-cv-request scq +application/scvp-cv-response scs +application/scvp-vp-request spq +application/scvp-vp-response spp +application/sdp sdp +application/senml+xml senmlx +application/sensml+xml sensmlx +application/set-payment-initiation setpay +application/set-registration-initiation setreg +application/shf+xml shf +application/sieve sieve siv +application/smil+xml smi smil +application/sparql-query rq +application/sparql-results+xml srx +application/srgs gram +application/srgs+xml grxml +application/sru+xml sru +application/ssdl+xml ssdl +application/ssml+xml ssml +application/swid+xml swidtag +application/tei+xml tei teicorpus +application/thraud+xml tfi +application/timestamped-data tsd +application/toml toml +application/trig trig +application/ttml+xml ttml +application/ubjson ubj +application/urc-ressheet+xml rsheet +application/urc-targetdesc+xml td +application/vnd.1000minds.decision-model+xml 1km +application/vnd.3gpp.pic-bw-large plb +application/vnd.3gpp.pic-bw-small psb +application/vnd.3gpp.pic-bw-var pvb +application/vnd.3gpp2.tcap tcap +application/vnd.3m.post-it-notes pwn +application/vnd.accpac.simply.aso aso +application/vnd.accpac.simply.imp imp +application/vnd.acucobol acu +application/vnd.acucorp acutc atc +application/vnd.adobe.air-application-installer-package+zip air +application/vnd.adobe.formscentral.fcdt fcdt +application/vnd.adobe.fxp fxp fxpl +application/vnd.adobe.xdp+xml xdp +application/vnd.adobe.xfdf xfdf +application/vnd.age age +application/vnd.ahead.space ahead +application/vnd.airzip.filesecure.azf azf +application/vnd.airzip.filesecure.azs azs +application/vnd.amazon.ebook azw +application/vnd.americandynamics.acc acc +application/vnd.amiga.ami ami +application/vnd.android.package-archive apk +application/vnd.anser-web-certificate-issue-initiation cii +application/vnd.anser-web-funds-transfer-initiation fti +application/vnd.antix.game-component atx +application/vnd.apple.installer+xml mpkg +application/vnd.apple.keynote key +application/vnd.apple.mpegurl m3u8 +application/vnd.apple.numbers numbers +application/vnd.apple.pages pages +application/vnd.apple.pkpass pkpass +application/vnd.aristanetworks.swi swi +application/vnd.astraea-software.iota iota +application/vnd.audiograph aep +application/vnd.balsamiq.bmml+xml bmml +application/vnd.blueice.multipass mpm +application/vnd.bmi bmi +application/vnd.businessobjects rep +application/vnd.chemdraw+xml cdxml +application/vnd.chipnuts.karaoke-mmd mmd +application/vnd.cinderella cdy +application/vnd.citationstyles.style+xml csl +application/vnd.claymore cla +application/vnd.cloanto.rp9 rp9 +application/vnd.clonk.c4group c4d c4f c4g c4p c4u +application/vnd.cluetrust.cartomobile-config c11amc +application/vnd.cluetrust.cartomobile-config-pkg c11amz +application/vnd.commonspace csp +application/vnd.contact.cmsg cdbcmsg +application/vnd.cosmocaller cmc +application/vnd.crick.clicker clkx +application/vnd.crick.clicker.keyboard clkk +application/vnd.crick.clicker.palette clkp +application/vnd.crick.clicker.template clkt +application/vnd.crick.clicker.wordbank clkw +application/vnd.criticaltools.wbs+xml wbs +application/vnd.ctc-posml pml +application/vnd.cups-ppd ppd +application/vnd.curl.car car +application/vnd.curl.pcurl pcurl +application/vnd.dart dart +application/vnd.data-vision.rdz rdz +application/vnd.dbf dbf +application/vnd.dece.data uvd uvf uvvd uvvf +application/vnd.dece.ttml+xml uvt uvvt +application/vnd.dece.unspecified uvvx uvx +application/vnd.dece.zip uvvz uvz +application/vnd.denovo.fcselayout-link fe_launch +application/vnd.dna dna +application/vnd.dolby.mlp mlp +application/vnd.dpgraph dpg +application/vnd.dreamfactory dfac +application/vnd.ds-keypoint kpxx +application/vnd.dvb.ait ait +application/vnd.dvb.service svc +application/vnd.dynageo geo +application/vnd.ecowin.chart mag +application/vnd.enliven nml +application/vnd.epson.esf esf +application/vnd.epson.msf msf +application/vnd.epson.quickanime qam +application/vnd.epson.salt slt +application/vnd.epson.ssf ssf +application/vnd.eszigno3+xml es3 et3 +application/vnd.ezpix-album ez2 +application/vnd.ezpix-package ez3 +application/vnd.fdf fdf +application/vnd.fdsn.mseed mseed +application/vnd.fdsn.seed dataless seed +application/vnd.flographit gph +application/vnd.fluxtime.clip ftc +application/vnd.framemaker book fm frame maker +application/vnd.frogans.fnc fnc +application/vnd.frogans.ltf ltf +application/vnd.fsc.weblaunch fsc +application/vnd.fujitsu.oasys oas +application/vnd.fujitsu.oasys2 oa2 +application/vnd.fujitsu.oasys3 oa3 +application/vnd.fujitsu.oasysgp fg5 +application/vnd.fujitsu.oasysprs bh2 +application/vnd.fujixerox.ddd ddd +application/vnd.fujixerox.docuworks xdw +application/vnd.fujixerox.docuworks.binder xbd +application/vnd.fuzzysheet fzs +application/vnd.genomatix.tuxedo txd +application/vnd.geogebra.file ggb +application/vnd.geogebra.tool ggt +application/vnd.geometry-explorer gex gre +application/vnd.geonext gxt +application/vnd.geoplan g2w +application/vnd.geospace g3w +application/vnd.gmx gmx +application/vnd.google-apps.document gdoc +application/vnd.google-apps.presentation gslides +application/vnd.google-apps.spreadsheet gsheet +application/vnd.google-earth.kml+xml kml +application/vnd.google-earth.kmz kmz +application/vnd.grafeq gqf gqs +application/vnd.groove-account gac +application/vnd.groove-help ghf +application/vnd.groove-identity-message gim +application/vnd.groove-injector grv +application/vnd.groove-tool-message gtm +application/vnd.groove-tool-template tpl +application/vnd.groove-vcard vcg +application/vnd.hal+xml hal +application/vnd.handheld-entertainment+xml zmm +application/vnd.hbci hbci +application/vnd.hhe.lesson-player les +application/vnd.hp-hpgl hpgl +application/vnd.hp-hpid hpid +application/vnd.hp-hps hps +application/vnd.hp-jlyt jlt +application/vnd.hp-pcl pcl +application/vnd.hp-pclxl pclxl +application/vnd.hydrostatix.sof-data sfd-hdstx +application/vnd.ibm.minipay mpy +application/vnd.ibm.modcap afp list3820 listafp +application/vnd.ibm.rights-management irm +application/vnd.ibm.secure-container sc +application/vnd.iccprofile icc icm +application/vnd.igloader igl +application/vnd.immervision-ivp ivp +application/vnd.immervision-ivu ivu +application/vnd.insors.igm igm +application/vnd.intercon.formnet xpw xpx +application/vnd.intergeo i2g +application/vnd.intu.qbo qbo +application/vnd.intu.qfx qfx +application/vnd.ipunplugged.rcprofile rcprofile +application/vnd.irepository.package+xml irp +application/vnd.is-xpr xpr +application/vnd.isac.fcs fcs +application/vnd.jam jam +application/vnd.jcp.javame.midlet-rms rms +application/vnd.jisp jisp +application/vnd.joost.joda-archive joda +application/vnd.kahootz ktr ktz +application/vnd.kde.karbon karbon +application/vnd.kde.kchart chrt +application/vnd.kde.kformula kfo +application/vnd.kde.kivio flw +application/vnd.kde.kontour kon +application/vnd.kde.kpresenter kpr kpt +application/vnd.kde.kspread ksp +application/vnd.kde.kword kwd kwt +application/vnd.kenameaapp htke +application/vnd.kidspiration kia +application/vnd.kinar kne knp +application/vnd.koan skd skm skp skt +application/vnd.kodak-descriptor sse +application/vnd.las.las+xml lasxml +application/vnd.llamagraphics.life-balance.desktop lbd +application/vnd.llamagraphics.life-balance.exchange+xml lbe +application/vnd.lotus-1-2-3 123 +application/vnd.lotus-approach apr +application/vnd.lotus-freelance pre +application/vnd.lotus-notes nsf +application/vnd.lotus-organizer org +application/vnd.lotus-screencam scm +application/vnd.lotus-wordpro lwp +application/vnd.macports.portpkg portpkg +application/vnd.mapbox-vector-tile mvt +application/vnd.mcd mcd +application/vnd.medcalcdata mc1 +application/vnd.mediastation.cdkey cdkey +application/vnd.mfer mwf +application/vnd.mfmp mfm +application/vnd.micrografx.flo flo +application/vnd.micrografx.igx igx +application/vnd.mif mif +application/vnd.mobius.daf daf +application/vnd.mobius.dis dis +application/vnd.mobius.mbk mbk +application/vnd.mobius.mqy mqy +application/vnd.mobius.msl msl +application/vnd.mobius.plc plc +application/vnd.mobius.txf txf +application/vnd.mophun.application mpn +application/vnd.mophun.certificate mpc +application/vnd.mozilla.xul+xml xul +application/vnd.ms-artgalry cil +application/vnd.ms-cab-compressed cab +application/vnd.ms-excel xla xlc xlm xls xlt xlw +application/vnd.ms-excel.addin.macroenabled.12 xlam +application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb +application/vnd.ms-excel.sheet.macroenabled.12 xlsm +application/vnd.ms-excel.template.macroenabled.12 xltm +application/vnd.ms-fontobject eot +application/vnd.ms-htmlhelp chm +application/vnd.ms-ims ims +application/vnd.ms-lrm lrm +application/vnd.ms-officetheme thmx +application/vnd.ms-outlook msg +application/vnd.ms-pki.seccat cat +application/vnd.ms-pki.stl stl +application/vnd.ms-powerpoint pot pps ppt +application/vnd.ms-powerpoint.addin.macroenabled.12 ppam +application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm +application/vnd.ms-powerpoint.slide.macroenabled.12 sldm +application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm +application/vnd.ms-powerpoint.template.macroenabled.12 potm +application/vnd.ms-project mpt +application/vnd.ms-word.document.macroenabled.12 docm +application/vnd.ms-word.template.macroenabled.12 dotm +application/vnd.ms-works wcm wdb wks wps +application/vnd.ms-wpl wpl +application/vnd.ms-xpsdocument xps +application/vnd.mseq mseq +application/vnd.musician mus +application/vnd.muvee.style msty +application/vnd.mynfc taglet +application/vnd.neurolanguage.nlu nlu +application/vnd.nitf nitf ntf +application/vnd.noblenet-directory nnd +application/vnd.noblenet-sealer nns +application/vnd.noblenet-web nnw +application/vnd.nokia.n-gage.data ngdat +application/vnd.nokia.n-gage.symbian.install n-gage +application/vnd.nokia.radio-preset rpst +application/vnd.nokia.radio-presets rpss +application/vnd.novadigm.edm edm +application/vnd.novadigm.edx edx +application/vnd.novadigm.ext ext +application/vnd.oasis.opendocument.chart odc +application/vnd.oasis.opendocument.chart-template otc +application/vnd.oasis.opendocument.database odb +application/vnd.oasis.opendocument.formula odf +application/vnd.oasis.opendocument.formula-template odft +application/vnd.oasis.opendocument.graphics odg +application/vnd.oasis.opendocument.graphics-template otg +application/vnd.oasis.opendocument.image odi +application/vnd.oasis.opendocument.image-template oti +application/vnd.oasis.opendocument.presentation odp +application/vnd.oasis.opendocument.presentation-template otp +application/vnd.oasis.opendocument.spreadsheet ods +application/vnd.oasis.opendocument.spreadsheet-template ots +application/vnd.oasis.opendocument.text odt +application/vnd.oasis.opendocument.text-master odm +application/vnd.oasis.opendocument.text-template ott +application/vnd.oasis.opendocument.text-web oth +application/vnd.olpc-sugar xo +application/vnd.oma.dd2+xml dd2 +application/vnd.openblox.game+xml obgx +application/vnd.openofficeorg.extension oxt +application/vnd.openstreetmap.data+xml osm +application/vnd.openxmlformats-officedocument.presentationml.presentation pptx +application/vnd.openxmlformats-officedocument.presentationml.slide sldx +application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx +application/vnd.openxmlformats-officedocument.presentationml.template potx +application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx +application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx +application/vnd.openxmlformats-officedocument.wordprocessingml.document docx +application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx +application/vnd.osgeo.mapguide.package mgp +application/vnd.osgi.dp dp +application/vnd.osgi.subsystem esa +application/vnd.palm oprc pdb pqa +application/vnd.pawaafile paw +application/vnd.pg.format str +application/vnd.pg.osasli ei6 +application/vnd.picsel efif +application/vnd.pmi.widget wg +application/vnd.pocketlearn plf +application/vnd.powerbuilder6 pbd +application/vnd.previewsystems.box box +application/vnd.proteus.magazine mgz +application/vnd.publishare-delta-tree qps +application/vnd.pvi.ptid1 ptid +application/vnd.quark.quarkxpress qwd qwt qxb qxd qxl qxt +application/vnd.rar rar +application/vnd.realvnc.bed bed +application/vnd.recordare.musicxml mxl +application/vnd.recordare.musicxml+xml musicxml +application/vnd.rig.cryptonote cryptonote +application/vnd.rim.cod cod +application/vnd.rn-realmedia rm +application/vnd.rn-realmedia-vbr rmvb +application/vnd.route66.link66+xml link66 +application/vnd.sailingtracker.track st +application/vnd.seemail see +application/vnd.sema sema +application/vnd.semd semd +application/vnd.semf semf +application/vnd.shana.informed.formdata ifm +application/vnd.shana.informed.formtemplate itp +application/vnd.shana.informed.interchange iif +application/vnd.shana.informed.package ipk +application/vnd.simtech-mindmapper twd twds +application/vnd.smaf mmf +application/vnd.smart.teacher teacher +application/vnd.software602.filler.form+xml fo +application/vnd.solent.sdkm+xml sdkd sdkm +application/vnd.spotfire.dxp dxp +application/vnd.spotfire.sfs sfs +application/vnd.stardivision.calc sdc +application/vnd.stardivision.draw sda +application/vnd.stardivision.impress sdd +application/vnd.stardivision.math smf +application/vnd.stardivision.writer sdw vor +application/vnd.stardivision.writer-global sgl +application/vnd.stepmania.package smzip +application/vnd.stepmania.stepchart sm +application/vnd.sun.wadl+xml wadl +application/vnd.sun.xml.calc sxc +application/vnd.sun.xml.calc.template stc +application/vnd.sun.xml.draw sxd +application/vnd.sun.xml.draw.template std +application/vnd.sun.xml.impress sxi +application/vnd.sun.xml.impress.template sti +application/vnd.sun.xml.math sxm +application/vnd.sun.xml.writer sxw +application/vnd.sun.xml.writer.global sxg +application/vnd.sun.xml.writer.template stw +application/vnd.sus-calendar sus susp +application/vnd.svd svd +application/vnd.symbian.install sis sisx +application/vnd.syncml+xml xsm +application/vnd.syncml.dm+wbxml bdm +application/vnd.syncml.dm+xml xdm +application/vnd.syncml.dmddf+xml ddf +application/vnd.tao.intent-module-archive tao +application/vnd.tcpdump.pcap cap dmp pcap +application/vnd.tmobile-livetv tmo +application/vnd.trid.tpt tpt +application/vnd.triscape.mxs mxs +application/vnd.trueapp tra +application/vnd.ufdl ufd ufdl +application/vnd.uiq.theme utz +application/vnd.umajin umj +application/vnd.unity unityweb +application/vnd.uoml+xml uoml +application/vnd.vcx vcx +application/vnd.visio vsd vss vst vsw +application/vnd.visionary vis +application/vnd.vsf vsf +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo wtb +application/vnd.wolfram.player nbp +application/vnd.wordperfect wpd +application/vnd.wqd wqd +application/vnd.wt.stf stf +application/vnd.xara xar +application/vnd.xfdl xfdl +application/vnd.yamaha.hv-dic hvd +application/vnd.yamaha.hv-script hvs +application/vnd.yamaha.hv-voice hvp +application/vnd.yamaha.openscoreformat osf +application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg +application/vnd.yamaha.smaf-audio saf +application/vnd.yamaha.smaf-phrase spf +application/vnd.yellowriver-custom-menu cmp +application/vnd.zul zir zirz +application/vnd.zzazz.deck+xml zaz +application/voicexml+xml vxml +application/wasm wasm +application/watcherinfo+xml wif +application/widget wgt +application/winhlp hlp +application/wsdl+xml wsdl +application/wspolicy+xml wspolicy +application/x-7z-compressed 7z +application/x-abiword abw +application/x-ace-compressed ace +application/x-arj arj +application/x-authorware-bin aab u32 vox x32 +application/x-authorware-map aam +application/x-authorware-seg aas +application/x-bcpio bcpio +application/x-bittorrent torrent +application/x-blorb blb blorb +application/x-bzip bz +application/x-bzip2 boz bz2 +application/x-cbr cb7 cba cbr cbt cbz +application/x-cdlink vcd +application/x-cfs-compressed cfs +application/x-chat chat +application/x-chess-pgn pgn +application/x-chrome-extension crx +application/x-cocoa cco +application/x-conference nsc +application/x-cpio cpio +application/x-csh csh +application/x-debian-package udeb +application/x-dgc-compressed dgc +application/x-director cct cst cxt dcr dir dxr fgd swa w3d +application/x-doom wad +application/x-dtbncx+xml ncx +application/x-dtbook+xml dtb +application/x-dtbresource+xml res +application/x-dvi dvi +application/x-envoy evy +application/x-eva eva +application/x-font-bdf bdf +application/x-font-ghostscript gsf +application/x-font-linux-psf psf +application/x-font-pcf pcf +application/x-font-snf snf +application/x-font-type1 afm pfa pfb pfm +application/x-freearc arc +application/x-futuresplash spl +application/x-gca-compressed gca +application/x-glulx ulx +application/x-gnumeric gnumeric +application/x-gramps-xml gramps +application/x-gtar gtar +application/x-hdf hdf +application/x-httpd-php php +application/x-install-instructions install +application/x-java-archive-diff jardiff +application/x-java-jnlp-file jnlp +application/x-keepass2 kdbx +application/x-latex latex +application/x-lua-bytecode luac +application/x-lzh-compressed lha lzh +application/x-makeself run +application/x-mie mie +application/x-mobipocket-ebook mobi prc +application/x-ms-application application +application/x-ms-shortcut lnk +application/x-ms-wmd wmd +application/x-ms-wmz wmz +application/x-ms-xbap xbap +application/x-msaccess mdb +application/x-msbinder obd +application/x-mscardfile crd +application/x-msclip clp +application/x-msdownload bat com +application/x-msmediaview m13 m14 mvb +application/x-msmetafile emf emz wmf +application/x-msmoney mny +application/x-mspublisher pub +application/x-msschedule scd +application/x-msterminal trm +application/x-mswrite wri +application/x-netcdf cdf nc +application/x-ns-proxy-autoconfig pac +application/x-nzb nzb +application/x-perl pl pm +application/x-pkcs12 p12 pfx +application/x-pkcs7-certificates p7b spc +application/x-pkcs7-certreqresp p7r +application/x-redhat-package-manager rpm +application/x-research-info-systems ris +application/x-sea sea +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-silverlight-app xap +application/x-sql sql +application/x-stuffit sit +application/x-stuffitx sitx +application/x-subrip srt +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-t3vm-image t3 +application/x-tads gam +application/x-tar tar +application/x-tcl tcl tk +application/x-tex tex +application/x-tex-tfm tfm +application/x-texinfo texi texinfo +application/x-tgif obj +application/x-ustar ustar +application/x-virtualbox-hdd hdd +application/x-virtualbox-ova ova +application/x-virtualbox-ovf ovf +application/x-virtualbox-vbox vbox +application/x-virtualbox-vbox-extpack vbox-extpack +application/x-virtualbox-vdi vdi +application/x-virtualbox-vhd vhd +application/x-virtualbox-vmdk vmdk +application/x-wais-source src +application/x-web-app-manifest+json webapp +application/x-x509-ca-cert crt der pem +application/x-xfig fig +application/x-xliff+xml xlf +application/x-xpinstall xpi +application/x-xz xz +application/x-zmachine z1 z2 z3 z4 z5 z6 z7 z8 +application/xaml+xml xaml +application/xcap-att+xml xav +application/xcap-caps+xml xca +application/xcap-diff+xml xdf +application/xcap-el+xml xel +application/xcap-ns+xml xns +application/xenc+xml xenc +application/xhtml+xml xht xhtml +application/xml rng xml xsd xsl +application/xml-dtd dtd +application/xop+xml xop +application/xproc+xml xpl +application/xslt+xml xslt +application/xspf+xml xspf +application/xv+xml mxml xhvml xvm xvml +application/yang yang +application/yin+xml yin +application/zip zip +audio/3gpp 3gpp +audio/adpcm adp +audio/amr amr +audio/basic au snd +audio/midi kar mid midi rmi +audio/mobile-xmf mxmf +audio/mp3 mp3 +audio/mp4 m4a mp4a +audio/mpeg m2a m3a mp2 mp2a mpga +audio/ogg oga ogg opus spx +audio/s3m s3m +audio/silk sil +audio/vnd.dece.audio uva uvva +audio/vnd.digital-winds eol +audio/vnd.dra dra +audio/vnd.dts dts +audio/vnd.dts.hd dtshd +audio/vnd.lucent.voice lvp +audio/vnd.ms-playready.media.pya pya +audio/vnd.nuera.ecelp4800 ecelp4800 +audio/vnd.nuera.ecelp7470 ecelp7470 +audio/vnd.nuera.ecelp9600 ecelp9600 +audio/vnd.rip rip +audio/wav wav +audio/webm weba +audio/x-aac aac +audio/x-aiff aif aifc aiff +audio/x-caf caf +audio/x-flac flac +audio/x-matroska mka +audio/x-mpegurl m3u +audio/x-ms-wax wax +audio/x-ms-wma wma +audio/x-pn-realaudio ra ram +audio/x-pn-realaudio-plugin rmp +audio/xm xm +chemical/x-cdx cdx +chemical/x-cif cif +chemical/x-cmdf cmdf +chemical/x-cml cml +chemical/x-csml csml +chemical/x-xyz xyz +font/collection ttc +font/otf otf +font/ttf ttf +font/woff woff +font/woff2 woff2 +image/aces exr +image/apng apng +image/avci avci +image/avcs avcs +image/avif avif +image/bmp bmp +image/cgm cgm +image/dicom-rle drle +image/fits fits +image/g3fax g3 +image/gif gif +image/heic heic +image/heic-sequence heics +image/heif heif +image/heif-sequence heifs +image/hej2k hej2 +image/hsj2 hsj2 +image/ief ief +image/jls jls +image/jp2 jp2 jpg2 +image/jpeg jpe jpeg jpg +image/jph jph +image/jphc jhc +image/jpm jpm +image/jpx jpf jpx +image/jxr jxr +image/jxra jxra +image/jxrs jxrs +image/jxs jxs +image/jxsc jxsc +image/jxsi jxsi +image/jxss jxss +image/ktx ktx +image/ktx2 ktx2 +image/png png +image/prs.btif btif +image/prs.pti pti +image/sgi sgi +image/svg+xml svg svgz +image/t38 t38 +image/tiff tif tiff +image/tiff-fx tfx +image/vnd.adobe.photoshop psd +image/vnd.airzip.accelerator.azv azv +image/vnd.dece.graphic uvg uvi uvvg uvvi +image/vnd.djvu djv djvu +image/vnd.dvb.subtitle sub +image/vnd.dwg dwg +image/vnd.dxf dxf +image/vnd.fastbidsheet fbs +image/vnd.fpx fpx +image/vnd.fst fst +image/vnd.fujixerox.edmics-mmr mmr +image/vnd.fujixerox.edmics-rlc rlc +image/vnd.microsoft.icon ico +image/vnd.ms-dds dds +image/vnd.ms-modi mdi +image/vnd.ms-photo wdp +image/vnd.net-fpx npx +image/vnd.pco.b16 b16 +image/vnd.tencent.tap tap +image/vnd.valve.source.texture vtf +image/vnd.wap.wbmp wbmp +image/vnd.xiff xif +image/vnd.zbrush.pcx pcx +image/webp webp +image/x-3ds 3ds +image/x-cmu-raster ras +image/x-cmx cmx +image/x-freehand fh fh4 fh5 fh7 fhc +image/x-jng jng +image/x-mrsid-image sid +image/x-pict pct pic +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-tga tga +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +message/disposition-notification disposition-notification +message/global u8msg +message/global-delivery-status u8dsn +message/global-disposition-notification u8mdn +message/global-headers u8hdr +message/rfc822 eml mime +message/vnd.wfa.wsc wsc +model/3mf 3mf +model/gltf+json gltf +model/gltf-binary glb +model/iges iges igs +model/mesh mesh msh silo +model/mtl mtl +model/step+xml stpx +model/step+zip stpz +model/step-xml+zip stpxz +model/vnd.collada+xml dae +model/vnd.dwf dwf +model/vnd.gdl gdl +model/vnd.gtw gtw +model/vnd.mts mts +model/vnd.opengex ogex +model/vnd.parasolid.transmit.binary x_b +model/vnd.parasolid.transmit.text x_t +model/vnd.sap.vds vds +model/vnd.usdz+zip usdz +model/vnd.valve.source.compiled-map bsp +model/vnd.vtu vtu +model/vrml vrml wrl +model/x3d+binary x3db x3dbz +model/x3d+vrml x3dv x3dvz +model/x3d+xml x3d x3dz +text/cache-manifest appcache manifest +text/calendar ics ifb +text/coffeescript coffee litcoffee +text/css css +text/csv csv +text/html htm html shtml +text/jade jade +text/jsx jsx +text/less less +text/markdown markdown md +text/mathml mml +text/mdx mdx +text/n3 n3 +text/plain conf def in ini list log text txt +text/prs.lines.tag dsc +text/richtext rtx +text/sgml sgm sgml +text/shex shex +text/slim slim slm +text/spdx spdx +text/stylus styl stylus +text/tab-separated-values tsv +text/troff man me ms roff t tr +text/turtle ttl +text/uri-list uri uris urls +text/vcard vcard +text/vnd.curl curl +text/vnd.curl.dcurl dcurl +text/vnd.curl.mcurl mcurl +text/vnd.curl.scurl scurl +text/vnd.familysearch.gedcom ged +text/vnd.fly fly +text/vnd.fmi.flexstor flx +text/vnd.graphviz gv +text/vnd.in3d.3dml 3dml +text/vnd.in3d.spot spot +text/vnd.sun.j2me.app-descriptor jad +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/vtt vtt +text/x-asm asm s +text/x-c c cc cpp cxx dic h hh +text/x-component htc +text/x-fortran f f77 f90 for +text/x-handlebars-template hbs +text/x-java-source java +text/x-lua lua +text/x-markdown mkd +text/x-nfo nfo +text/x-opml opml +text/x-pascal p pas +text/x-processing pde +text/x-sass sass +text/x-scss scss +text/x-setext etx +text/x-sfv sfv +text/x-suse-ymp ymp +text/x-uuencode uu +text/x-vcalendar vcs +text/x-vcard vcf +text/yaml yaml yml +video/3gpp 3gp +video/3gpp2 3g2 +video/h261 h261 +video/h263 h263 +video/h264 h264 +video/iso.segment m4s +video/jpeg jpgv +video/jpm jpgm +video/mj2 mj2 mjp2 +video/mp2t ts +video/mp4 mp4 mp4v mpg4 +video/mpeg m1v m2v mpe mpeg mpg +video/ogg ogv +video/quicktime mov qt +video/vnd.dece.hd uvh uvvh +video/vnd.dece.mobile uvm uvvm +video/vnd.dece.pd uvp uvvp +video/vnd.dece.sd uvs uvvs +video/vnd.dece.video uvv uvvv +video/vnd.dvb.file dvb +video/vnd.fvt fvt +video/vnd.mpegurl m4u mxu +video/vnd.ms-playready.media.pyv pyv +video/vnd.uvvu.mp4 uvu uvvu +video/vnd.vivo viv +video/webm webm +video/x-f4v f4v +video/x-fli fli +video/x-flv flv +video/x-m4v m4v +video/x-matroska mk3d mks mkv +video/x-mng mng +video/x-ms-asf asf asx +video/x-ms-vob vob +video/x-ms-wm wm +video/x-ms-wmv wmv +video/x-ms-wmx wmx +video/x-ms-wvx wvx +video/x-msvideo avi +video/x-sgi-movie movie +video/x-smv smv +x-conference/x-cooltalk ice \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page.rb new file mode 100644 index 0000000..64821a8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page.rb @@ -0,0 +1,215 @@ +# frozen_string_literal: true + +module Jekyll + class Page + include Convertible + + attr_writer :dir + attr_accessor :basename, :content, :data, :ext, :name, :output, :pager, :site + + alias_method :extname, :ext + + # Attributes for Liquid templates + ATTRIBUTES_FOR_LIQUID = %w( + content + dir + excerpt + name + path + url + ).freeze + + # A set of extensions that are considered HTML or HTML-like so we + # should not alter them, this includes .xhtml through XHTM5. + + HTML_EXTENSIONS = %w( + .html + .xhtml + .htm + ).freeze + + # Initialize a new Page. + # + # site - The Site object. + # base - The String path to the source. + # dir - The String path between the source and the file. + # name - The String filename of the file. + def initialize(site, base, dir, name) + @site = site + @base = base + @dir = dir + @name = name + @path = if site.in_theme_dir(base) == base # we're in a theme + site.in_theme_dir(base, dir, name) + else + site.in_source_dir(base, dir, name) + end + + process(name) + read_yaml(PathManager.join(base, dir), name) + generate_excerpt if site.config["page_excerpts"] + + data.default_proc = proc do |_, key| + site.frontmatter_defaults.find(relative_path, type, key) + end + + Jekyll::Hooks.trigger :pages, :post_init, self + end + + # The generated directory into which the page will be placed + # upon generation. This is derived from the permalink or, if + # permalink is absent, will be '/' + # + # Returns the String destination directory. + def dir + url.end_with?("/") ? url : url_dir + end + + # The full path and filename of the post. Defined in the YAML of the post + # body. + # + # Returns the String permalink or nil if none has been set. + def permalink + data.nil? ? nil : data["permalink"] + end + + # The template of the permalink. + # + # Returns the template String. + def template + if !html? + "/:path/:basename:output_ext" + elsif index? + "/:path/" + else + Utils.add_permalink_suffix("/:path/:basename", site.permalink_style) + end + end + + # The generated relative url of this page. e.g. /about.html. + # + # Returns the String url. + def url + @url ||= URL.new( + :template => template, + :placeholders => url_placeholders, + :permalink => permalink + ).to_s + end + + # Returns a hash of URL placeholder names (as symbols) mapping to the + # desired placeholder replacements. For details see "url.rb" + def url_placeholders + { + :path => @dir, + :basename => basename, + :output_ext => output_ext, + } + end + + # Extract information from the page filename. + # + # name - The String filename of the page file. + # + # NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`) + # Returns nothing. + def process(name) + return unless name + + self.ext = File.extname(name) + self.basename = name[0..-ext.length - 1].gsub(%r!\.*\z!, "") + end + + # Add any necessary layouts to this post + # + # layouts - The Hash of {"name" => "layout"}. + # site_payload - The site payload Hash. + # + # Returns String rendered page. + def render(layouts, site_payload) + site_payload["page"] = to_liquid + site_payload["paginator"] = pager.to_liquid + + do_layout(site_payload, layouts) + end + + # The path to the source file + # + # Returns the path to the source file + def path + data.fetch("path") { relative_path } + end + + # The path to the page source file, relative to the site source + def relative_path + @relative_path ||= PathManager.join(@dir, @name).delete_prefix("/") + end + + # Obtain destination path. + # + # dest - The String path to the destination dir. + # + # Returns the destination file path String. + def destination(dest) + @destination ||= {} + @destination[dest] ||= begin + path = site.in_dest_dir(dest, URL.unescape_path(url)) + path = File.join(path, "index") if url.end_with?("/") + path << output_ext unless path.end_with? output_ext + path + end + end + + # Returns the object as a debug String. + def inspect + "#<#{self.class} @relative_path=#{relative_path.inspect}>" + end + + # Returns the Boolean of whether this Page is HTML or not. + def html? + HTML_EXTENSIONS.include?(output_ext) + end + + # Returns the Boolean of whether this Page is an index file or not. + def index? + basename == "index" + end + + def trigger_hooks(hook_name, *args) + Jekyll::Hooks.trigger :pages, hook_name, self, *args + end + + def write? + true + end + + def excerpt_separator + @excerpt_separator ||= (data["excerpt_separator"] || site.config["excerpt_separator"]).to_s + end + + def excerpt + return @excerpt if defined?(@excerpt) + + @excerpt = data["excerpt"] ? data["excerpt"].to_s : nil + end + + def generate_excerpt? + !excerpt_separator.empty? && instance_of?(Jekyll::Page) && html? + end + + private + + def generate_excerpt + return unless generate_excerpt? + + data["excerpt"] ||= Jekyll::PageExcerpt.new(self) + end + + def url_dir + @url_dir ||= begin + value = File.dirname(url) + value.end_with?("/") ? value : "#{value}/" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page_excerpt.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page_excerpt.rb new file mode 100644 index 0000000..dd79fca --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page_excerpt.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Jekyll + class PageExcerpt < Excerpt + attr_reader :doc + alias_method :id, :relative_path + + EXCERPT_ATTRIBUTES = (Page::ATTRIBUTES_FOR_LIQUID - %w(excerpt)).freeze + private_constant :EXCERPT_ATTRIBUTES + + def to_liquid + @to_liquid ||= doc.to_liquid(EXCERPT_ATTRIBUTES) + end + + def render_with_liquid? + return false if data["render_with_liquid"] == false + + Jekyll::Utils.has_liquid_construct?(content) + end + + def inspect + "#<#{self.class} id=#{id.inspect}>" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page_without_a_file.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page_without_a_file.rb new file mode 100644 index 0000000..e314f97 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/page_without_a_file.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Jekyll + # A Jekyll::Page subclass to handle processing files without reading it to + # determine the page-data and page-content based on Front Matter delimiters. + # + # The class instance is basically just a bare-bones entity with just + # attributes "dir", "name", "path", "url" defined on it. + class PageWithoutAFile < Page + def read_yaml(*) + @data ||= {} + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/path_manager.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/path_manager.rb new file mode 100644 index 0000000..5d97522 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/path_manager.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +module Jekyll + # A singleton class that caches frozen instances of path strings returned from its methods. + # + # NOTE: + # This class exists because `File.join` allocates an Array and returns a new String on every + # call using **the same arguments**. Caching the result means reduced memory usage. + # However, the caches are never flushed so that they can be used even when a site is + # regenerating. The results are frozen to deter mutation of the cached string. + # + # Therefore, employ this class only for situations where caching the result is necessary + # for performance reasons. + # + class PathManager + # This class cannot be initialized from outside + private_class_method :new + + class << self + # Wraps `File.join` to cache the frozen result. + # Reassigns `nil`, empty strings and empty arrays to a frozen empty string beforehand. + # + # Returns a frozen string. + def join(base, item) + base = "" if base.nil? || base.empty? + item = "" if item.nil? || item.empty? + @join ||= {} + @join[base] ||= {} + @join[base][item] ||= File.join(base, item).freeze + end + + # Ensures the questionable path is prefixed with the base directory + # and prepends the questionable path with the base directory if false. + # + # Returns a frozen string. + def sanitized_path(base_directory, questionable_path) + @sanitized_path ||= {} + @sanitized_path[base_directory] ||= {} + @sanitized_path[base_directory][questionable_path] ||= if questionable_path.nil? + base_directory.freeze + else + sanitize_and_join( + base_directory, questionable_path + ).freeze + end + end + + private + + def sanitize_and_join(base_directory, questionable_path) + clean_path = if questionable_path.start_with?("~") + questionable_path.dup.insert(0, "/") + else + questionable_path + end + clean_path = File.expand_path(clean_path, "/") + return clean_path if clean_path.eql?(base_directory) + + # remove any remaining extra leading slashes not stripped away by calling + # `File.expand_path` above. + clean_path.squeeze!("/") + return clean_path if clean_path.start_with?(slashed_dir_cache(base_directory)) + + clean_path.sub!(%r!\A\w:/!, "/") + join(base_directory, clean_path) + end + + def slashed_dir_cache(base_directory) + @slashed_dir_cache ||= {} + @slashed_dir_cache[base_directory] ||= base_directory.sub(%r!\z!, "/") + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/plugin.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/plugin.rb new file mode 100644 index 0000000..1157e12 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/plugin.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true + +module Jekyll + class Plugin + PRIORITIES = { + :low => -10, + :highest => 100, + :lowest => -100, + :normal => 0, + :high => 10, + }.freeze + + # + + def self.inherited(const) + catch_inheritance(const) do |const_| + catch_inheritance(const_) + end + end + + # + + def self.catch_inheritance(const) + const.define_singleton_method :inherited do |const_| + (@children ||= Set.new).add const_ + yield const_ if block_given? + end + end + + # + + def self.descendants + @children ||= Set.new + out = @children.map(&:descendants) + out << self unless superclass == Plugin + Set.new(out).flatten + end + + # Get or set the priority of this plugin. When called without an + # argument it returns the priority. When an argument is given, it will + # set the priority. + # + # priority - The Symbol priority (default: nil). Valid options are: + # :lowest, :low, :normal, :high, :highest + # + # Returns the Symbol priority. + def self.priority(priority = nil) + @priority ||= nil + @priority = priority if priority && PRIORITIES.key?(priority) + @priority || :normal + end + + # Get or set the safety of this plugin. When called without an argument + # it returns the safety. When an argument is given, it will set the + # safety. + # + # safe - The Boolean safety (default: nil). + # + # Returns the safety Boolean. + def self.safe(safe = nil) + @safe = safe unless defined?(@safe) && safe.nil? + @safe || false + end + + # Spaceship is priority [higher -> lower] + # + # other - The class to be compared. + # + # Returns -1, 0, 1. + def self.<=>(other) + PRIORITIES[other.priority] <=> PRIORITIES[priority] + end + + # Spaceship is priority [higher -> lower] + # + # other - The class to be compared. + # + # Returns -1, 0, 1. + def <=>(other) + self.class <=> other.class + end + + # Initialize a new plugin. This should be overridden by the subclass. + # + # config - The Hash of configuration options. + # + # Returns a new instance. + def initialize(config = {}) + # no-op for default + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/plugin_manager.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/plugin_manager.rb new file mode 100644 index 0000000..84c555a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/plugin_manager.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +module Jekyll + class PluginManager + attr_reader :site + + # Create an instance of this class. + # + # site - the instance of Jekyll::Site we're concerned with + # + # Returns nothing + def initialize(site) + @site = site + end + + # Require all the plugins which are allowed. + # + # Returns nothing + def conscientious_require + require_theme_deps if site.theme + require_plugin_files + require_gems + deprecation_checks + end + + # Require each of the gem plugins specified. + # + # Returns nothing. + def require_gems + Jekyll::External.require_with_graceful_fail( + site.gems.select { |plugin| plugin_allowed?(plugin) } + ) + end + + # Require each of the runtime_dependencies specified by the theme's gemspec. + # + # Returns false only if no dependencies have been specified, otherwise nothing. + def require_theme_deps + return false unless site.theme.runtime_dependencies + + site.theme.runtime_dependencies.each do |dep| + next if dep.name == "jekyll" + + External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name) + end + end + + def self.require_from_bundler + if !ENV["JEKYLL_NO_BUNDLER_REQUIRE"] && gemfile_exists? + require "bundler" + + Bundler.setup + required_gems = Bundler.require(:jekyll_plugins) + message = "Required #{required_gems.map(&:name).join(", ")}" + Jekyll.logger.debug("PluginManager:", message) + ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true" + + true + else + false + end + end + + # Check for the existence of a Gemfile. + # + # Returns true if a Gemfile exists in the places bundler will look + def self.gemfile_exists? + File.file?("Gemfile") || (ENV["BUNDLE_GEMFILE"] && File.file?(ENV["BUNDLE_GEMFILE"])) + end + + # Check whether a gem plugin is allowed to be used during this build. + # + # plugin_name - the name of the plugin + # + # Returns true if the plugin name is in the whitelist or if the site is not + # in safe mode. + def plugin_allowed?(plugin_name) + !site.safe || whitelist.include?(plugin_name) + end + + # Build an array of allowed plugin gem names. + # + # Returns an array of strings, each string being the name of a gem name + # that is allowed to be used. + def whitelist + @whitelist ||= Array[site.config["whitelist"]].flatten + end + + # Require all .rb files if safe mode is off + # + # Returns nothing. + def require_plugin_files + unless site.safe + plugins_path.each do |plugin_search_path| + plugin_files = Utils.safe_glob(plugin_search_path, File.join("**", "*.rb")) + Jekyll::External.require_with_graceful_fail(plugin_files) + end + end + end + + # Public: Setup the plugin search path + # + # Returns an Array of plugin search paths + def plugins_path + if site.config["plugins_dir"].eql? Jekyll::Configuration::DEFAULTS["plugins_dir"] + [site.in_source_dir(site.config["plugins_dir"])] + else + Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) } + end + end + + def deprecation_checks + pagination_included = (site.config["plugins"] || []).include?("jekyll-paginate") || + defined?(Jekyll::Paginate) + if site.config["paginate"] && !pagination_included + Jekyll::Deprecator.deprecation_message <<~MSG + You appear to have pagination turned on, but you haven't included the `jekyll-paginate` + gem. Ensure you have `plugins: [jekyll-paginate]` in your configuration file. + MSG + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/profiler.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/profiler.rb new file mode 100644 index 0000000..f5dbfb1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/profiler.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Jekyll + class Profiler + TERMINAL_TABLE_STYLES = { + :alignment => :right, + :border_top => false, + :border_bottom => false, + }.freeze + private_constant :TERMINAL_TABLE_STYLES + + def self.tabulate(table_rows) + require "terminal-table" + + rows = table_rows.dup + header = rows.shift + output = +"\n" + + table = Terminal::Table.new do |t| + t << header + t << :separator + rows.each { |row| t << row } + t.style = TERMINAL_TABLE_STYLES + t.align_column(0, :left) + end + + output << table.to_s << "\n" + end + + def initialize(site) + @site = site + end + + def profile_process + profile_data = { "PHASE" => "TIME" } + + [:reset, :read, :generate, :render, :cleanup, :write].each do |method| + start_time = Time.now + @site.send(method) + end_time = (Time.now - start_time).round(4) + profile_data[method.to_s.upcase] = format("%.4f", end_time) + end + + Jekyll.logger.info "\nBuild Process Summary:" + Jekyll.logger.info Profiler.tabulate(Array(profile_data)) + + Jekyll.logger.info "\nSite Render Stats:" + @site.print_stats + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/publisher.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/publisher.rb new file mode 100644 index 0000000..26fe4a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/publisher.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Jekyll + class Publisher + def initialize(site) + @site = site + end + + def publish?(thing) + can_be_published?(thing) && !hidden_in_the_future?(thing) + end + + def hidden_in_the_future?(thing) + thing.respond_to?(:date) && !@site.future && thing.date.to_i > @site.time.to_i + end + + private + + def can_be_published?(thing) + thing.data.fetch("published", true) || @site.unpublished + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/reader.rb new file mode 100644 index 0000000..5d15177 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/reader.rb @@ -0,0 +1,209 @@ +# frozen_string_literal: true + +module Jekyll + class Reader + attr_reader :site + + def initialize(site) + @site = site + end + + # Read Site data from disk and load it into internal data structures. + # + # Returns nothing. + def read + @site.layouts = LayoutReader.new(site).read + read_directories + read_included_excludes + sort_files! + CollectionReader.new(site).read + ThemeAssetsReader.new(site).read + read_data + end + + # Read and merge the data files. + # If a theme is specified and it contains data, it will be read. + # Site data will overwrite theme data with the same key using the + # semantics of Utils.deep_merge_hashes. + # + # Returns nothing. + def read_data + @site.data = DataReader.new(site).read(site.config["data_dir"]) + return unless site.theme&.data_path + + theme_data = DataReader.new( + site, + :in_source_dir => site.method(:in_theme_dir) + ).read(site.theme.data_path) + @site.data = Jekyll::Utils.deep_merge_hashes(theme_data, @site.data) + end + + # Sorts posts, pages, and static files. + def sort_files! + site.collections.each_value { |c| c.docs.sort! } + site.pages.sort_by!(&:name) + site.static_files.sort_by!(&:relative_path) + end + + # Recursively traverse directories to find pages and static files + # that will become part of the site according to the rules in + # filter_entries. + # + # dir - The String relative path of the directory to read. Default: ''. + # + # Returns nothing. + def read_directories(dir = "") + base = site.in_source_dir(dir) + + return unless File.directory?(base) + + dot_dirs = [] + dot_pages = [] + dot_static_files = [] + + dot = Dir.chdir(base) { filter_entries(Dir.entries("."), base) } + dot.each do |entry| + file_path = @site.in_source_dir(base, entry) + if File.directory?(file_path) + dot_dirs << entry + elsif Utils.has_yaml_header?(file_path) + dot_pages << entry + else + dot_static_files << entry + end + end + + retrieve_posts(dir) + retrieve_dirs(base, dir, dot_dirs) + retrieve_pages(dir, dot_pages) + retrieve_static_files(dir, dot_static_files) + end + + # Retrieves all the posts(posts/drafts) from the given directory + # and add them to the site and sort them. + # + # dir - The String representing the directory to retrieve the posts from. + # + # Returns nothing. + def retrieve_posts(dir) + return if outside_configured_directory?(dir) + + site.posts.docs.concat(post_reader.read_posts(dir)) + site.posts.docs.concat(post_reader.read_drafts(dir)) if site.show_drafts + end + + # Recursively traverse directories with the read_directories function. + # + # base - The String representing the site's base directory. + # dir - The String representing the directory to traverse down. + # dot_dirs - The Array of subdirectories in the dir. + # + # Returns nothing. + def retrieve_dirs(_base, dir, dot_dirs) + dot_dirs.each do |file| + dir_path = site.in_source_dir(dir, file) + rel_path = PathManager.join(dir, file) + @site.reader.read_directories(rel_path) unless @site.dest.chomp("/") == dir_path + end + end + + # Retrieve all the pages from the current directory, + # add them to the site and sort them. + # + # dir - The String representing the directory retrieve the pages from. + # dot_pages - The Array of pages in the dir. + # + # Returns nothing. + def retrieve_pages(dir, dot_pages) + site.pages.concat(PageReader.new(site, dir).read(dot_pages)) + end + + # Retrieve all the static files from the current directory, + # add them to the site and sort them. + # + # dir - The directory retrieve the static files from. + # dot_static_files - The static files in the dir. + # + # Returns nothing. + def retrieve_static_files(dir, dot_static_files) + site.static_files.concat(StaticFileReader.new(site, dir).read(dot_static_files)) + end + + # Filter out any files/directories that are hidden or backup files (start + # with "." or "#" or end with "~"), or contain site content (start with "_"), + # or are excluded in the site configuration, unless they are web server + # files such as '.htaccess'. + # + # entries - The Array of String file/directory entries to filter. + # base_directory - The string representing the optional base directory. + # + # Returns the Array of filtered entries. + def filter_entries(entries, base_directory = nil) + EntryFilter.new(site, base_directory).filter(entries) + end + + # Read the entries from a particular directory for processing + # + # dir - The String representing the relative path of the directory to read. + # subfolder - The String representing the directory to read. + # + # Returns the list of entries to process + def get_entries(dir, subfolder) + base = site.in_source_dir(dir, subfolder) + return [] unless File.exist?(base) + + entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) } + entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) } + end + + private + + # Internal + # + # Determine if the directory is supposed to contain posts and drafts. + # If the user has defined a custom collections_dir, then attempt to read + # posts and drafts only from within that directory. + # + # Returns true if a custom collections_dir has been set but current directory lies + # outside that directory. + def outside_configured_directory?(dir) + collections_dir = site.config["collections_dir"] + !collections_dir.empty? && !dir.start_with?("/#{collections_dir}") + end + + # Create a single PostReader instance to retrieve drafts and posts from all valid + # directories in current site. + def post_reader + @post_reader ||= PostReader.new(site) + end + + def read_included_excludes + entry_filter = EntryFilter.new(site) + + site.include.each do |entry| + entry_path = site.in_source_dir(entry) + next if File.directory?(entry_path) + next if entry_filter.symlink?(entry_path) + + read_included_file(entry_path) if File.file?(entry_path) + end + end + + def read_included_file(entry_path) + if Utils.has_yaml_header?(entry_path) + conditionally_generate_entry(entry_path, site.pages, PageReader) + else + conditionally_generate_entry(entry_path, site.static_files, StaticFileReader) + end + end + + def conditionally_generate_entry(entry_path, container, reader) + return if container.find { |item| site.in_source_dir(item.relative_path) == entry_path } + + dir, files = File.split(entry_path) + dir.sub!(site.source, "") + files = Array(files) + container.concat(reader.new(site, dir).read(files)) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/collection_reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/collection_reader.rb new file mode 100644 index 0000000..6d18275 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/collection_reader.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Jekyll + class CollectionReader + SPECIAL_COLLECTIONS = %w(posts data).freeze + + attr_reader :site, :content + + def initialize(site) + @site = site + @content = {} + end + + # Read in all collections specified in the configuration + # + # Returns nothing. + def read + site.collections.each_value do |collection| + collection.read unless SPECIAL_COLLECTIONS.include?(collection.label) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/data_reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/data_reader.rb new file mode 100644 index 0000000..80b57bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/data_reader.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +module Jekyll + class DataReader + attr_reader :site, :content + + def initialize(site, in_source_dir: nil) + @site = site + @content = {} + @entry_filter = EntryFilter.new(site) + @in_source_dir = in_source_dir || @site.method(:in_source_dir) + @source_dir = @in_source_dir.call("/") + end + + # Read all the files in and adds them to @content + # + # dir - The String relative path of the directory to read. + # + # Returns @content, a Hash of the .yaml, .yml, + # .json, and .csv files in the base directory + def read(dir) + base = @in_source_dir.call(dir) + read_data_to(base, @content) + @content + end + + # Read and parse all .yaml, .yml, .json, .csv and .tsv + # files under and add them to the variable. + # + # dir - The string absolute path of the directory to read. + # data - The variable to which data will be added. + # + # Returns nothing + def read_data_to(dir, data) + return unless File.directory?(dir) && !@entry_filter.symlink?(dir) + + entries = Dir.chdir(dir) do + Dir["*.{yaml,yml,json,csv,tsv}"] + Dir["*"].select { |fn| File.directory?(fn) } + end + + entries.each do |entry| + path = @in_source_dir.call(dir, entry) + next if @entry_filter.symlink?(path) + + if File.directory?(path) + read_data_to(path, data[sanitize_filename(entry)] = {}) + else + key = sanitize_filename(File.basename(entry, ".*")) + data[key] = read_data_file(path) + end + end + end + + # Determines how to read a data file. + # + # Returns the contents of the data file. + def read_data_file(path) + Jekyll.logger.debug "Reading:", path.sub(@source_dir, "") + + case File.extname(path).downcase + when ".csv" + CSV.read(path, **csv_config).map { |row| convert_row(row) } + when ".tsv" + CSV.read(path, **tsv_config).map { |row| convert_row(row) } + else + SafeYAML.load_file(path) + end + end + + def sanitize_filename(name) + name.gsub(%r![^\w\s-]+|(?<=^|\b\s)\s+(?=$|\s?\b)!, "") + .gsub(%r!\s+!, "_") + end + + private + + # @return [Hash] + def csv_config + @csv_config ||= read_config("csv_reader") + end + + # @return [Hash] + def tsv_config + @tsv_config ||= read_config("tsv_reader", { :col_sep => "\t" }) + end + + # @param config_key [String] + # @param overrides [Hash] + # @return [Hash] + # @see https://ruby-doc.org/stdlib-2.5.0/libdoc/csv/rdoc/CSV.html#Converters + def read_config(config_key, overrides = {}) + reader_config = config[config_key] || {} + + defaults = { + :converters => reader_config.fetch("csv_converters", []).map(&:to_sym), + :headers => reader_config.fetch("headers", true), + :encoding => reader_config.fetch("encoding", config["encoding"]), + } + + defaults.merge(overrides) + end + + def config + @config ||= site.config + end + + # @param row [Array, CSV::Row] + # @return [Array, Hash] + def convert_row(row) + row.instance_of?(CSV::Row) ? row.to_hash : row + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/layout_reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/layout_reader.rb new file mode 100644 index 0000000..981867b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/layout_reader.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +module Jekyll + class LayoutReader + attr_reader :site + + def initialize(site) + @site = site + @layouts = {} + end + + def read + layout_entries.each do |layout_file| + @layouts[layout_name(layout_file)] = \ + Layout.new(site, layout_directory, layout_file) + end + + theme_layout_entries.each do |layout_file| + @layouts[layout_name(layout_file)] ||= \ + Layout.new(site, theme_layout_directory, layout_file) + end + + @layouts + end + + def layout_directory + @layout_directory ||= site.in_source_dir(site.config["layouts_dir"]) + end + + def theme_layout_directory + @theme_layout_directory ||= site.theme.layouts_path if site.theme + end + + private + + def layout_entries + entries_in layout_directory + end + + def theme_layout_entries + theme_layout_directory ? entries_in(theme_layout_directory) : [] + end + + def entries_in(dir) + entries = [] + within(dir) do + entries = EntryFilter.new(site).filter(Dir["**/*.*"]) + end + entries + end + + def layout_name(file) + file.split(".")[0..-2].join(".") + end + + def within(directory) + return unless File.exist?(directory) + + Dir.chdir(directory) { yield } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/page_reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/page_reader.rb new file mode 100644 index 0000000..e72f767 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/page_reader.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Jekyll + class PageReader + attr_reader :site, :dir, :unfiltered_content + + def initialize(site, dir) + @site = site + @dir = dir + @unfiltered_content = [] + end + + # Create a new `Jekyll::Page` object for each entry in a given array. + # + # files - An array of file names inside `@dir` + # + # Returns an array of publishable `Jekyll::Page` objects. + def read(files) + files.each do |page| + @unfiltered_content << Page.new(@site, @site.source, @dir, page) + end + @unfiltered_content.select { |page| site.publisher.publish?(page) } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/post_reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/post_reader.rb new file mode 100644 index 0000000..25c5f98 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/post_reader.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +module Jekyll + class PostReader + attr_reader :site, :unfiltered_content + + def initialize(site) + @site = site + end + + # Read all the files in //_drafts and create a new + # Document object with each one. + # + # dir - The String relative path of the directory to read. + # + # Returns nothing. + def read_drafts(dir) + read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER) + end + + # Read all the files in //_posts and create a new Document + # object with each one. + # + # dir - The String relative path of the directory to read. + # + # Returns nothing. + def read_posts(dir) + read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER) + end + + # Read all the files in // and create a new + # Document object with each one insofar as it matches the regexp matcher. + # + # dir - The String relative path of the directory to read. + # + # Returns nothing. + def read_publishable(dir, magic_dir, matcher) + read_content(dir, magic_dir, matcher) + .tap { |docs| docs.each(&:read) } + .select { |doc| processable?(doc) } + end + + # Read all the content files from //magic_dir + # and return them with the type klass. + # + # dir - The String relative path of the directory to read. + # magic_dir - The String relative directory to , + # looks for content here. + # klass - The return type of the content. + # + # Returns klass type of content files + def read_content(dir, magic_dir, matcher) + @site.reader.get_entries(dir, magic_dir).map do |entry| + next unless matcher.match?(entry) + + path = @site.in_source_dir(File.join(dir, magic_dir, entry)) + Document.new(path, + :site => @site, + :collection => @site.posts) + end.tap(&:compact!) + end + + private + + def processable?(doc) + if doc.content.nil? + Jekyll.logger.debug "Skipping:", "Content in #{doc.relative_path} is nil" + false + elsif !doc.content.valid_encoding? + Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8" + false + else + publishable?(doc) + end + end + + def publishable?(doc) + site.publisher.publish?(doc).tap do |will_publish| + if !will_publish && site.publisher.hidden_in_the_future?(doc) + Jekyll.logger.warn "Skipping:", "#{doc.relative_path} has a future date" + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/static_file_reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/static_file_reader.rb new file mode 100644 index 0000000..5c8a677 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/static_file_reader.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Jekyll + class StaticFileReader + attr_reader :site, :dir, :unfiltered_content + + def initialize(site, dir) + @site = site + @dir = dir + @unfiltered_content = [] + end + + # Create a new StaticFile object for every entry in a given list of basenames. + # + # files - an array of file basenames. + # + # Returns an array of static files. + def read(files) + files.each do |file| + @unfiltered_content << StaticFile.new(@site, @site.source, @dir, file) + end + @unfiltered_content + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/theme_assets_reader.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/theme_assets_reader.rb new file mode 100644 index 0000000..b20a3a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/readers/theme_assets_reader.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Jekyll + class ThemeAssetsReader + attr_reader :site + + def initialize(site) + @site = site + end + + def read + return unless site.theme&.assets_path + + Find.find(site.theme.assets_path) do |path| + next if File.directory?(path) + + if File.symlink?(path) + Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}" + else + read_theme_asset(path) + end + end + end + + private + + def read_theme_asset(path) + base = site.theme.root + dir = File.dirname(path.sub("#{site.theme.root}/", "")) + name = File.basename(path) + + if Utils.has_yaml_header?(path) + append_unless_exists site.pages, + Jekyll::Page.new(site, base, dir, name) + else + append_unless_exists site.static_files, + Jekyll::StaticFile.new(site, base, "/#{dir}", name) + end + end + + def append_unless_exists(haystack, new_item) + if haystack.any? { |file| file.relative_path == new_item.relative_path } + Jekyll.logger.debug "Theme:", + "Ignoring #{new_item.relative_path} in theme due to existing file " \ + "with that path in site." + return + end + + haystack << new_item + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/regenerator.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/regenerator.rb new file mode 100644 index 0000000..88c6a81 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/regenerator.rb @@ -0,0 +1,195 @@ +# frozen_string_literal: true + +module Jekyll + class Regenerator + attr_reader :site, :metadata, :cache + attr_accessor :disabled + private :disabled, :disabled= + + def initialize(site) + @site = site + + # Read metadata from file + read_metadata + + # Initialize cache to an empty hash + clear_cache + end + + # Checks if a renderable object needs to be regenerated + # + # Returns a boolean. + def regenerate?(document) + return true if disabled + + case document + when Page + regenerate_page?(document) + when Document + regenerate_document?(document) + else + source_path = document.respond_to?(:path) ? document.path : nil + dest_path = document.destination(@site.dest) if document.respond_to?(:destination) + source_modified_or_dest_missing?(source_path, dest_path) + end + end + + # Add a path to the metadata + # + # Returns true, also on failure. + def add(path) + return true unless File.exist?(path) + + metadata[path] = { + "mtime" => File.mtime(path), + "deps" => [], + } + cache[path] = true + end + + # Force a path to regenerate + # + # Returns true. + def force(path) + cache[path] = true + end + + # Clear the metadata and cache + # + # Returns nothing + def clear + @metadata = {} + clear_cache + end + + # Clear just the cache + # + # Returns nothing + def clear_cache + @cache = {} + end + + # Checks if the source has been modified or the + # destination is missing + # + # returns a boolean + def source_modified_or_dest_missing?(source_path, dest_path) + modified?(source_path) || (dest_path && !File.exist?(dest_path)) + end + + # Checks if a path's (or one of its dependencies) + # mtime has changed + # + # Returns a boolean. + def modified?(path) + return true if disabled? + + # objects that don't have a path are always regenerated + return true if path.nil? + + # Check for path in cache + return cache[path] if cache.key? path + + if metadata[path] + # If we have seen this file before, + # check if it or one of its dependencies has been modified + existing_file_modified?(path) + else + # If we have not seen this file before, add it to the metadata and regenerate it + add(path) + end + end + + # Add a dependency of a path + # + # Returns nothing. + def add_dependency(path, dependency) + return if metadata[path].nil? || disabled + + unless metadata[path]["deps"].include? dependency + metadata[path]["deps"] << dependency + add(dependency) unless metadata.include?(dependency) + end + regenerate? dependency + end + + # Write the metadata to disk + # + # Returns nothing. + def write_metadata + unless disabled? + Jekyll.logger.debug "Writing Metadata:", ".jekyll-metadata" + File.binwrite(metadata_file, Marshal.dump(metadata)) + end + end + + # Produce the absolute path of the metadata file + # + # Returns the String path of the file. + def metadata_file + @metadata_file ||= site.in_source_dir(".jekyll-metadata") + end + + # Check if metadata has been disabled + # + # Returns a Boolean (true for disabled, false for enabled). + def disabled? + self.disabled = !site.incremental? if disabled.nil? + disabled + end + + private + + # Read metadata from the metadata file, if no file is found, + # initialize with an empty hash + # + # Returns the read metadata. + def read_metadata + @metadata = + if !disabled? && File.file?(metadata_file) + content = File.binread(metadata_file) + + begin + Marshal.load(content) + rescue TypeError + SafeYAML.load(content) + rescue ArgumentError => e + Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}") + {} + end + else + {} + end + end + + def regenerate_page?(document) + document.asset_file? || document.data["regenerate"] || + source_modified_or_dest_missing?( + site.in_source_dir(document.relative_path), document.destination(@site.dest) + ) + end + + def regenerate_document?(document) + !document.write? || document.data["regenerate"] || + source_modified_or_dest_missing?( + document.path, document.destination(@site.dest) + ) + end + + def existing_file_modified?(path) + # If one of this file dependencies have been modified, + # set the regeneration bit for both the dependency and the file to true + metadata[path]["deps"].each do |dependency| + return cache[dependency] = cache[path] = true if modified?(dependency) + end + + if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path)) + # If this file has not been modified, set the regeneration bit to false + cache[path] = false + else + # If it has been modified, set it to true + add(path) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/related_posts.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/related_posts.rb new file mode 100644 index 0000000..98fc488 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/related_posts.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Jekyll + class RelatedPosts + class << self + attr_accessor :lsi + end + + attr_reader :post, :site + + def initialize(post) + @post = post + @site = post.site + Jekyll::External.require_with_graceful_fail("classifier-reborn") if site.lsi + end + + def build + return [] unless site.posts.docs.size > 1 + + if site.lsi + build_index + lsi_related_posts + else + most_recent_posts + end + end + + def build_index + self.class.lsi ||= begin + lsi = ClassifierReborn::LSI.new(:auto_rebuild => false) + Jekyll.logger.info("Populating LSI...") + + site.posts.docs.each do |x| + lsi.add_item(x) + end + + Jekyll.logger.info("Rebuilding index...") + lsi.build_index + Jekyll.logger.info("") + lsi + end + end + + def lsi_related_posts + self.class.lsi.find_related(post, 11) + end + + def most_recent_posts + @most_recent_posts ||= (site.posts.docs.last(11).reverse! - [post]).first(10) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb new file mode 100644 index 0000000..c365a0d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb @@ -0,0 +1,263 @@ +# frozen_string_literal: true + +module Jekyll + class Renderer + attr_reader :document, :site + attr_writer :layouts, :payload + + def initialize(site, document, site_payload = nil) + @site = site + @document = document + @payload = site_payload + @layouts = nil + end + + # Fetches the payload used in Liquid rendering. + # It can be written with #payload=(new_payload) + # Falls back to site.site_payload if no payload is set. + # + # Returns a Jekyll::Drops::UnifiedPayloadDrop + def payload + @payload ||= site.site_payload + end + + # The list of layouts registered for this Renderer. + # It can be written with #layouts=(new_layouts) + # Falls back to site.layouts if no layouts are registered. + # + # Returns a Hash of String => Jekyll::Layout identified + # as basename without the extension name. + def layouts + @layouts || site.layouts + end + + # Determine which converters to use based on this document's + # extension. + # + # Returns Array of Converter instances. + def converters + @converters ||= site.converters.select { |c| c.matches(document.extname) }.tap(&:sort!) + end + + # Determine the extname the outputted file should have + # + # Returns String the output extname including the leading period. + def output_ext + @output_ext ||= (permalink_ext || converter_output_ext) + end + + # Prepare payload and render the document + # + # Returns String rendered document output + def run + Jekyll.logger.debug "Rendering:", document.relative_path + + assign_pages! + assign_current_document! + assign_highlighter_options! + assign_layout_data! + + Jekyll.logger.debug "Pre-Render Hooks:", document.relative_path + document.trigger_hooks(:pre_render, payload) + + render_document + end + + # Render the document. + # + # Returns String rendered document output + # rubocop: disable Metrics/AbcSize, Metrics/MethodLength + def render_document + info = { + :registers => { :site => site, :page => payload["page"] }, + :strict_filters => liquid_options["strict_filters"], + :strict_variables => liquid_options["strict_variables"], + } + + output = document.content + if document.render_with_liquid? + Jekyll.logger.debug "Rendering Liquid:", document.relative_path + output = render_liquid(output, payload, info, document.path) + end + + Jekyll.logger.debug "Rendering Markup:", document.relative_path + output = convert(output.to_s) + document.content = output + + Jekyll.logger.debug "Post-Convert Hooks:", document.relative_path + document.trigger_hooks(:post_convert) + output = document.content + + if document.place_in_layout? + Jekyll.logger.debug "Rendering Layout:", document.relative_path + output = place_in_layouts(output, payload, info) + end + + output + end + # rubocop: enable Metrics/AbcSize, Metrics/MethodLength + + # Convert the document using the converters which match this renderer's document. + # + # Returns String the converted content. + def convert(content) + converters.reduce(content) do |output, converter| + converter.convert output + rescue StandardError => e + Jekyll.logger.error "Conversion error:", + "#{converter.class} encountered an error while " \ + "converting '#{document.relative_path}':" + Jekyll.logger.error("", e.to_s) + raise e + end + end + + # Render the given content with the payload and info + # + # content - + # payload - + # info - + # path - (optional) the path to the file, for use in ex + # + # Returns String the content, rendered by Liquid. + def render_liquid(content, payload, info, path = nil) + template = site.liquid_renderer.file(path).parse(content) + template.warnings.each do |e| + Jekyll.logger.warn "Liquid Warning:", + LiquidRenderer.format_error(e, path || document.relative_path) + end + template.render!(payload, info) + # rubocop: disable Lint/RescueException + rescue Exception => e + Jekyll.logger.error "Liquid Exception:", + LiquidRenderer.format_error(e, path || document.relative_path) + raise e + end + # rubocop: enable Lint/RescueException + + # Checks if the layout specified in the document actually exists + # + # layout - the layout to check + # + # Returns Boolean true if the layout is invalid, false if otherwise + def invalid_layout?(layout) + !document.data["layout"].nil? && layout.nil? && !(document.is_a? Jekyll::Excerpt) + end + + # Render layouts and place document content inside. + # + # Returns String rendered content + def place_in_layouts(content, payload, info) + output = content.dup + layout = layouts[document.data["layout"].to_s] + validate_layout(layout) + + used = Set.new([layout]) + + # Reset the payload layout data to ensure it starts fresh for each page. + payload["layout"] = nil + + while layout + output = render_layout(output, layout, info) + add_regenerator_dependencies(layout) + + next unless (layout = site.layouts[layout.data["layout"]]) + break if used.include?(layout) + + used << layout + end + output + end + + private + + # Checks if the layout specified in the document actually exists + # + # layout - the layout to check + # Returns nothing + def validate_layout(layout) + return unless invalid_layout?(layout) + + Jekyll.logger.warn "Build Warning:", "Layout '#{document.data["layout"]}' requested " \ + "in #{document.relative_path} does not exist." + end + + # Render layout content into document.output + # + # Returns String rendered content + def render_layout(output, layout, info) + payload["content"] = output + payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) + + render_liquid( + layout.content, + payload, + info, + layout.path + ) + end + + def add_regenerator_dependencies(layout) + return unless document.write? + + site.regenerator.add_dependency( + site.in_source_dir(document.path), + layout.path + ) + end + + # Set page content to payload and assign pager if document has one. + # + # Returns nothing + def assign_pages! + payload["page"] = document.to_liquid + payload["paginator"] = (document.pager.to_liquid if document.respond_to?(:pager)) + end + + # Set related posts to payload if document is a post. + # + # Returns nothing + def assign_current_document! + payload["site"].current_document = document + end + + # Set highlighter prefix and suffix + # + # Returns nothing + def assign_highlighter_options! + payload["highlighter_prefix"] = converters.first.highlighter_prefix + payload["highlighter_suffix"] = converters.first.highlighter_suffix + end + + def assign_layout_data! + layout = layouts[document.data["layout"]] + payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) if layout + end + + def permalink_ext + document_permalink = document.permalink + if document_permalink && !document_permalink.end_with?("/") + permalink_ext = File.extname(document_permalink) + permalink_ext unless permalink_ext.empty? + end + end + + def converter_output_ext + if output_exts.size == 1 + output_exts.last + else + output_exts[-2] + end + end + + def output_exts + @output_exts ||= converters.map do |c| + c.output_ext(document.extname) + end.tap(&:compact!) + end + + def liquid_options + @liquid_options ||= site.config["liquid"] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/site.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/site.rb new file mode 100644 index 0000000..9ef08c3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/site.rb @@ -0,0 +1,576 @@ +# frozen_string_literal: true + +module Jekyll + class Site + attr_accessor :baseurl, :converters, :data, :drafts, :exclude, + :file_read_opts, :future, :gems, :generators, :highlighter, + :include, :inclusions, :keep_files, :layouts, :limit_posts, + :lsi, :pages, :permalink_style, :plugin_manager, :plugins, + :reader, :safe, :show_drafts, :static_files, :theme, :time, + :unpublished + + attr_reader :cache_dir, :config, :dest, :filter_cache, :includes_load_paths, + :liquid_renderer, :profiler, :regenerator, :source + + # Public: Initialize a new Site. + # + # config - A Hash containing site configuration details. + def initialize(config) + # Source and destination may not be changed after the site has been created. + @source = File.expand_path(config["source"]).freeze + @dest = File.expand_path(config["destination"]).freeze + + self.config = config + + @cache_dir = in_source_dir(config["cache_dir"]) + @filter_cache = {} + + @reader = Reader.new(self) + @profiler = Profiler.new(self) + @regenerator = Regenerator.new(self) + @liquid_renderer = LiquidRenderer.new(self) + + Jekyll.sites << self + + reset + setup + + Jekyll::Hooks.trigger :site, :after_init, self + end + + # Public: Set the site's configuration. This handles side-effects caused by + # changing values in the configuration. + # + # config - a Jekyll::Configuration, containing the new configuration. + # + # Returns the new configuration. + def config=(config) + @config = config.clone + + %w(safe lsi highlighter baseurl exclude include future unpublished + show_drafts limit_posts keep_files).each do |opt| + send("#{opt}=", config[opt]) + end + + # keep using `gems` to avoid breaking change + self.gems = config["plugins"] + + configure_cache + configure_plugins + configure_theme + configure_include_paths + configure_file_read_opts + + self.permalink_style = config["permalink"].to_sym + + # Read in a _config.yml from the current theme-gem at the very end. + @config = load_theme_configuration(config) if theme + @config + end + + # Public: Read, process, and write this Site to output. + # + # Returns nothing. + def process + return profiler.profile_process if config["profile"] + + reset + read + generate + render + cleanup + write + end + + def print_stats + Jekyll.logger.info @liquid_renderer.stats_table + end + + # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/MethodLength + # + # Reset Site details. + # + # Returns nothing + def reset + self.time = if config["time"] + Utils.parse_date(config["time"].to_s, "Invalid time in _config.yml.") + else + Time.now + end + self.layouts = {} + self.inclusions = {} + self.pages = [] + self.static_files = [] + self.data = {} + @post_attr_hash = {} + @site_data = nil + @collections = nil + @documents = nil + @docs_to_write = nil + @regenerator.clear_cache + @liquid_renderer.reset + @site_cleaner = nil + frontmatter_defaults.reset + + raise ArgumentError, "limit_posts must be a non-negative number" if limit_posts.negative? + + Jekyll::Cache.clear_if_config_changed config + Jekyll::Hooks.trigger :site, :after_reset, self + nil + end + # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/AbcSize + + # Load necessary libraries, plugins, converters, and generators. + # + # Returns nothing. + def setup + ensure_not_in_dest + + plugin_manager.conscientious_require + + self.converters = instantiate_subclasses(Jekyll::Converter) + self.generators = instantiate_subclasses(Jekyll::Generator) + end + + # Check that the destination dir isn't the source dir or a directory + # parent to the source dir. + def ensure_not_in_dest + dest_pathname = Pathname.new(dest) + Pathname.new(source).ascend do |path| + if path == dest_pathname + raise Errors::FatalException, + "Destination directory cannot be or contain the Source directory." + end + end + end + + # The list of collections and their corresponding Jekyll::Collection instances. + # If config['collections'] is set, a new instance is created + # for each item in the collection, a new hash is returned otherwise. + # + # Returns a Hash containing collection name-to-instance pairs. + def collections + @collections ||= collection_names.each_with_object({}) do |name, hsh| + hsh[name] = Jekyll::Collection.new(self, name) + end + end + + # The list of collection names. + # + # Returns an array of collection names from the configuration, + # or an empty array if the `collections` key is not set. + def collection_names + case config["collections"] + when Hash + config["collections"].keys + when Array + config["collections"] + when nil + [] + else + raise ArgumentError, "Your `collections` key must be a hash or an array." + end + end + + # Read Site data from disk and load it into internal data structures. + # + # Returns nothing. + def read + reader.read + limit_posts! + Jekyll::Hooks.trigger :site, :post_read, self + nil + end + + # Run each of the Generators. + # + # Returns nothing. + def generate + generators.each do |generator| + start = Time.now + generator.generate(self) + Jekyll.logger.debug "Generating:", + "#{generator.class} finished in #{Time.now - start} seconds." + end + nil + end + + # Render the site to the destination. + # + # Returns nothing. + def render + relative_permalinks_are_deprecated + + payload = site_payload + + Jekyll::Hooks.trigger :site, :pre_render, self, payload + + render_docs(payload) + render_pages(payload) + + Jekyll::Hooks.trigger :site, :post_render, self, payload + nil + end + + # Remove orphaned files and empty directories in destination. + # + # Returns nothing. + def cleanup + site_cleaner.cleanup! + nil + end + + # Write static files, pages, and posts. + # + # Returns nothing. + def write + Jekyll::Commands::Doctor.conflicting_urls(self) + each_site_file do |item| + item.write(dest) if regenerator.regenerate?(item) + end + regenerator.write_metadata + Jekyll::Hooks.trigger :site, :post_write, self + nil + end + + def posts + collections["posts"] ||= Collection.new(self, "posts") + end + + # Construct a Hash of Posts indexed by the specified Post attribute. + # + # post_attr - The String name of the Post attribute. + # + # Examples + # + # post_attr_hash('categories') + # # => { 'tech' => [, ], + # # 'ruby' => [] } + # + # Returns the Hash: { attr => posts } where + # attr - One of the values for the requested attribute. + # posts - The Array of Posts with the given attr value. + def post_attr_hash(post_attr) + # Build a hash map based on the specified post attribute ( post attr => + # array of posts ) then sort each array in reverse order. + @post_attr_hash[post_attr] ||= begin + hash = Hash.new { |h, key| h[key] = [] } + posts.docs.each do |p| + p.data[post_attr]&.each { |t| hash[t] << p } + end + hash.each_value { |posts| posts.sort!.reverse! } + hash + end + end + + def tags + post_attr_hash("tags") + end + + def categories + post_attr_hash("categories") + end + + # Prepare site data for site payload. The method maintains backward compatibility + # if the key 'data' is already used in _config.yml. + # + # Returns the Hash to be hooked to site.data. + def site_data + @site_data ||= (config["data"] || data) + end + + # The Hash payload containing site-wide data. + # + # Returns the Hash: { "site" => data } where data is a Hash with keys: + # "time" - The Time as specified in the configuration or the + # current time if none was specified. + # "posts" - The Array of Posts, sorted chronologically by post date + # and then title. + # "pages" - The Array of all Pages. + # "html_pages" - The Array of HTML Pages. + # "categories" - The Hash of category values and Posts. + # See Site#post_attr_hash for type info. + # "tags" - The Hash of tag values and Posts. + # See Site#post_attr_hash for type info. + def site_payload + Drops::UnifiedPayloadDrop.new self + end + alias_method :to_liquid, :site_payload + + # Get the implementation class for the given Converter. + # Returns the Converter instance implementing the given Converter. + # klass - The Class of the Converter to fetch. + def find_converter_instance(klass) + @find_converter_instance ||= {} + @find_converter_instance[klass] ||= converters.find do |converter| + converter.instance_of?(klass) + end || \ + raise("No Converters found for #{klass}") + end + + # klass - class or module containing the subclasses. + # Returns array of instances of subclasses of parameter. + # Create array of instances of the subclasses of the class or module + # passed in as argument. + + def instantiate_subclasses(klass) + klass.descendants.select { |c| !safe || c.safe }.tap do |result| + result.sort! + result.map! { |c| c.new(config) } + end + end + + # Warns the user if permanent links are relative to the parent + # directory. As this is a deprecated function of Jekyll. + # + # Returns + def relative_permalinks_are_deprecated + if config["relative_permalinks"] + Jekyll.logger.abort_with "Since v3.0, permalinks for pages " \ + "in subfolders must be relative to the " \ + "site source directory, not the parent " \ + "directory. Check https://jekyllrb.com/docs/upgrading/ " \ + "for more info." + end + end + + # Get the to be written documents + # + # Returns an Array of Documents which should be written + def docs_to_write + documents.select(&:write?) + end + + # Get the to be written static files + # + # Returns an Array of StaticFiles which should be written + def static_files_to_write + static_files.select(&:write?) + end + + # Get all the documents + # + # Returns an Array of all Documents + def documents + collections.each_with_object(Set.new) do |(_, collection), set| + set.merge(collection.docs).merge(collection.files) + end.to_a + end + + def each_site_file + pages.each { |page| yield page } + static_files.each { |file| yield(file) if file.write? } + collections.each_value { |coll| coll.docs.each { |doc| yield(doc) if doc.write? } } + end + + # Returns the FrontmatterDefaults or creates a new FrontmatterDefaults + # if it doesn't already exist. + # + # Returns The FrontmatterDefaults + def frontmatter_defaults + @frontmatter_defaults ||= FrontmatterDefaults.new(self) + end + + # Whether to perform a full rebuild without incremental regeneration + # + # Returns a Boolean: true for a full rebuild, false for normal build + def incremental?(override = {}) + override["incremental"] || config["incremental"] + end + + # Returns the publisher or creates a new publisher if it doesn't + # already exist. + # + # Returns The Publisher + def publisher + @publisher ||= Publisher.new(self) + end + + # Public: Prefix a given path with the source directory. + # + # paths - (optional) path elements to a file or directory within the + # source directory + # + # Returns a path which is prefixed with the source directory. + def in_source_dir(*paths) + paths.reduce(source) do |base, path| + Jekyll.sanitized_path(base, path) + end + end + + # Public: Prefix a given path with the theme directory. + # + # paths - (optional) path elements to a file or directory within the + # theme directory + # + # Returns a path which is prefixed with the theme root directory. + def in_theme_dir(*paths) + return nil unless theme + + paths.reduce(theme.root) do |base, path| + Jekyll.sanitized_path(base, path) + end + end + + # Public: Prefix a given path with the destination directory. + # + # paths - (optional) path elements to a file or directory within the + # destination directory + # + # Returns a path which is prefixed with the destination directory. + def in_dest_dir(*paths) + paths.reduce(dest) do |base, path| + Jekyll.sanitized_path(base, path) + end + end + + # Public: Prefix a given path with the cache directory. + # + # paths - (optional) path elements to a file or directory within the + # cache directory + # + # Returns a path which is prefixed with the cache directory. + def in_cache_dir(*paths) + paths.reduce(cache_dir) do |base, path| + Jekyll.sanitized_path(base, path) + end + end + + # Public: The full path to the directory that houses all the collections registered + # with the current site. + # + # Returns the source directory or the absolute path to the custom collections_dir + def collections_path + dir_str = config["collections_dir"] + @collections_path ||= dir_str.empty? ? source : in_source_dir(dir_str) + end + + # Public + # + # Returns the object as a debug String. + def inspect + "#<#{self.class} @source=#{@source}>" + end + + private + + def load_theme_configuration(config) + return config if config["ignore_theme_config"] == true + + theme_config_file = in_theme_dir("_config.yml") + return config unless File.exist?(theme_config_file) + + # Bail out if the theme_config_file is a symlink file irrespective of safe mode + return config if File.symlink?(theme_config_file) + + theme_config = SafeYAML.load_file(theme_config_file) + return config unless theme_config.is_a?(Hash) + + Jekyll.logger.info "Theme Config file:", theme_config_file + + # theme_config should not be overriding Jekyll's defaults + theme_config.delete_if { |key, _| Configuration::DEFAULTS.key?(key) } + + # Override theme_config with existing config and return the result. + # Additionally ensure we return a `Jekyll::Configuration` instance instead of a Hash. + Utils.deep_merge_hashes(theme_config, config) + .each_with_object(Jekyll::Configuration.new) do |(key, value), conf| + conf[key] = value + end + end + + # Limits the current posts; removes the posts which exceed the limit_posts + # + # Returns nothing + def limit_posts! + if limit_posts.positive? + limit = posts.docs.length < limit_posts ? posts.docs.length : limit_posts + posts.docs = posts.docs[-limit, limit] + end + end + + # Returns the Cleaner or creates a new Cleaner if it doesn't + # already exist. + # + # Returns The Cleaner + def site_cleaner + @site_cleaner ||= Cleaner.new(self) + end + + def hide_cache_dir_from_git + @cache_gitignore_path ||= in_source_dir(config["cache_dir"], ".gitignore") + return if File.exist?(@cache_gitignore_path) + + cache_dir_path = in_source_dir(config["cache_dir"]) + FileUtils.mkdir_p(cache_dir_path) unless File.directory?(cache_dir_path) + + File.open(@cache_gitignore_path, "wb") do |file| + file.puts("# ignore everything in this directory\n*") + end + end + + # Disable Marshaling cache to disk in Safe Mode + def configure_cache + Jekyll::Cache.cache_dir = in_source_dir(config["cache_dir"], "Jekyll/Cache") + if safe || config["disable_disk_cache"] + Jekyll::Cache.disable_disk_cache! + else + hide_cache_dir_from_git + end + end + + def configure_plugins + self.plugin_manager = Jekyll::PluginManager.new(self) + self.plugins = plugin_manager.plugins_path + end + + def configure_theme + self.theme = nil + return if config["theme"].nil? + + self.theme = + if config["theme"].is_a?(String) + Jekyll::Theme.new(config["theme"]) + else + Jekyll.logger.warn "Theme:", "value of 'theme' in config should be String to use " \ + "gem-based themes, but got #{config["theme"].class}" + nil + end + end + + def configure_include_paths + @includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s)) + @includes_load_paths << theme.includes_path if theme&.includes_path + end + + def configure_file_read_opts + self.file_read_opts = {} + file_read_opts[:encoding] = config["encoding"] if config["encoding"] + self.file_read_opts = Jekyll::Utils.merged_file_read_opts(self, {}) + end + + def render_docs(payload) + collections.each_value do |collection| + collection.docs.each do |document| + render_regenerated(document, payload) + end + end + end + + def render_pages(payload) + pages.each do |page| + render_regenerated(page, payload) + end + end + + def render_regenerated(document, payload) + return unless regenerator.regenerate?(document) + + document.renderer.payload = payload + document.output = document.renderer.run + document.trigger_hooks(:post_render) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/static_file.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/static_file.rb new file mode 100644 index 0000000..f7d99f6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/static_file.rb @@ -0,0 +1,205 @@ +# frozen_string_literal: true + +module Jekyll + class StaticFile + extend Forwardable + + attr_reader :relative_path, :extname, :name + + def_delegator :to_liquid, :to_json, :to_json + + class << self + # The cache of last modification times [path] -> mtime. + def mtimes + @mtimes ||= {} + end + + def reset_cache + @mtimes = nil + end + end + + # Initialize a new StaticFile. + # + # site - The Site. + # base - The String path to the . + # dir - The String path between and the file. + # name - The String filename of the file. + # rubocop: disable Metrics/ParameterLists + def initialize(site, base, dir, name, collection = nil) + @site = site + @base = base + @dir = dir + @name = name + @collection = collection + @relative_path = File.join(*[@dir, @name].compact) + @extname = File.extname(@name) + end + # rubocop: enable Metrics/ParameterLists + + # Returns source file path. + def path + @path ||= if !@collection.nil? && !@site.config["collections_dir"].empty? + File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact) + else + File.join(*[@base, @dir, @name].compact) + end + end + + # Obtain destination path. + # + # dest - The String path to the destination dir. + # + # Returns destination file path. + def destination(dest) + @destination ||= {} + @destination[dest] ||= @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url)) + end + + def destination_rel_dir + if @collection + File.dirname(url) + else + @dir + end + end + + def modified_time + @modified_time ||= File.stat(path).mtime + end + + # Returns last modification time for this file. + def mtime + modified_time.to_i + end + + # Is source path modified? + # + # Returns true if modified since last write. + def modified? + self.class.mtimes[path] != mtime + end + + # Whether to write the file to the filesystem + # + # Returns true unless the defaults for the destination path from + # _config.yml contain `published: false`. + def write? + publishable = defaults.fetch("published", true) + return publishable unless @collection + + publishable && @collection.write? + end + + # Write the static file to the destination directory (if modified). + # + # dest - The String path to the destination dir. + # + # Returns false if the file was not modified since last time (no-op). + def write(dest) + dest_path = destination(dest) + return false if File.exist?(dest_path) && !modified? + + self.class.mtimes[path] = mtime + + FileUtils.mkdir_p(File.dirname(dest_path)) + FileUtils.rm(dest_path) if File.exist?(dest_path) + copy_file(dest_path) + + true + end + + def data + @data ||= @site.frontmatter_defaults.all(relative_path, type) + end + + def to_liquid + @to_liquid ||= Drops::StaticFileDrop.new(self) + end + + # Generate "basename without extension" and strip away any trailing periods. + # NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`) + def basename + @basename ||= File.basename(name, extname).gsub(%r!\.*\z!, "") + end + + def placeholders + { + :collection => @collection.label, + :path => cleaned_relative_path, + :output_ext => "", + :name => basename, + :title => "", + } + end + + # Similar to Jekyll::Document#cleaned_relative_path. + # Generates a relative path with the collection's directory removed when applicable + # and additionally removes any multiple periods in the string. + # + # NOTE: `String#gsub!` removes all trailing periods (in comparison to `String#chomp!`) + # + # Examples: + # When `relative_path` is "_methods/site/my-cool-avatar...png": + # cleaned_relative_path + # # => "/site/my-cool-avatar" + # + # Returns the cleaned relative path of the static file. + def cleaned_relative_path + @cleaned_relative_path ||= begin + cleaned = relative_path[0..-extname.length - 1] + cleaned.gsub!(%r!\.*\z!, "") + cleaned.sub!(@collection.relative_directory, "") if @collection + cleaned + end + end + + # Applies a similar URL-building technique as Jekyll::Document that takes + # the collection's URL template into account. The default URL template can + # be overridden in the collection's configuration in _config.yml. + def url + @url ||= begin + base = if @collection.nil? + cleaned_relative_path + else + Jekyll::URL.new( + :template => @collection.url_template, + :placeholders => placeholders + ) + end.to_s.chomp("/") + base << extname + end + end + + # Returns the type of the collection if present, nil otherwise. + def type + @type ||= @collection.nil? ? nil : @collection.label.to_sym + end + + # Returns the front matter defaults defined for the file's URL and/or type + # as defined in _config.yml. + def defaults + @defaults ||= @site.frontmatter_defaults.all url, type + end + + # Returns a debug string on inspecting the static file. + # Includes only the relative path of the object. + def inspect + "#<#{self.class} @relative_path=#{relative_path.inspect}>" + end + + private + + def copy_file(dest_path) + if @site.safe || Jekyll.env == "production" + FileUtils.cp(path, dest_path) + else + FileUtils.copy_entry(path, dest_path) + end + + unless File.symlink?(dest_path) + File.utime(self.class.mtimes[path], self.class.mtimes[path], dest_path) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/stevenson.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/stevenson.rb new file mode 100644 index 0000000..10e5a0b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/stevenson.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Jekyll + class Stevenson < ::Logger + def initialize + formatter = proc do |_, _, _, msg| + msg.to_s + end + super($stdout, :formatter => formatter) + end + + def add(severity, message = nil, progname = nil) + severity ||= UNKNOWN + @logdev = logdevice(severity) + + return true if @logdev.nil? || severity < @level + + progname ||= @progname + if message.nil? + if block_given? + message = yield + else + message = progname + progname = @progname + end + end + @logdev.puts( + format_message(format_severity(severity), Time.now, progname, message) + ) + true + end + + # Log a +WARN+ message + def warn(progname = nil, &block) + add(WARN, nil, progname.yellow, &block) + end + + # Log an +ERROR+ message + def error(progname = nil, &block) + add(ERROR, nil, progname.red, &block) + end + + def close + # No LogDevice in use + end + + private + + def logdevice(severity) + if severity > INFO + $stderr + else + $stdout + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/highlight.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/highlight.rb new file mode 100644 index 0000000..806665e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/highlight.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true + +module Jekyll + module Tags + class HighlightBlock < Liquid::Block + include Liquid::StandardFilters + + # The regular expression syntax checker. Start with the language specifier. + # Follow that by zero or more space separated options that take one of three + # forms: name, name=value, or name="" + # + # is a space-separated list of numbers + SYNTAX = %r!^([a-zA-Z0-9.+#_-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$!.freeze + + def initialize(tag_name, markup, tokens) + super + if markup.strip =~ SYNTAX + @lang = Regexp.last_match(1).downcase + @highlight_options = parse_options(Regexp.last_match(2)) + else + raise SyntaxError, <<~MSG + Syntax Error in tag 'highlight' while parsing the following markup: + + #{markup} + + Valid syntax: highlight [linenos] + MSG + end + end + + LEADING_OR_TRAILING_LINE_TERMINATORS = %r!\A(\n|\r)+|(\n|\r)+\z!.freeze + + def render(context) + prefix = context["highlighter_prefix"] || "" + suffix = context["highlighter_suffix"] || "" + code = super.to_s.gsub(LEADING_OR_TRAILING_LINE_TERMINATORS, "") + + output = + case context.registers[:site].highlighter + when "rouge" + render_rouge(code) + when "pygments" + render_pygments(code, context) + else + render_codehighlighter(code) + end + + rendered_output = add_code_tag(output) + prefix + rendered_output + suffix + end + + private + + OPTIONS_REGEX = %r!(?:\w="[^"]*"|\w=\w|\w)+!.freeze + + def parse_options(input) + options = {} + return options if input.empty? + + # Split along 3 possible forms -- key="", key=value, or key + input.scan(OPTIONS_REGEX) do |opt| + key, value = opt.split("=") + # If a quoted list, convert to array + if value&.include?('"') + value.delete!('"') + value = value.split + end + options[key.to_sym] = value || true + end + + options[:linenos] = "inline" if options[:linenos] == true + options + end + + def render_pygments(code, _context) + Jekyll.logger.warn "Warning:", "Highlight Tag no longer supports rendering with Pygments." + Jekyll.logger.warn "", "Using the default highlighter, Rouge, instead." + render_rouge(code) + end + + def render_rouge(code) + require "rouge" + formatter = ::Rouge::Formatters::HTML.new + if @highlight_options[:linenos] + formatter = ::Rouge::Formatters::HTMLTable.new( + formatter, + { + :css_class => "highlight", + :gutter_class => "gutter", + :code_class => "code", + } + ) + end + lexer = ::Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText + formatter.format(lexer.lex(code)) + end + + def render_codehighlighter(code) + h(code).strip + end + + def add_code_tag(code) + code_attributes = [ + "class=\"language-#{@lang.to_s.tr("+", "-")}\"", + "data-lang=\"#{@lang}\"", + ].join(" ") + "
" \
+          "#{code.chomp}
" + end + end + end +end + +Liquid::Template.register_tag("highlight", Jekyll::Tags::HighlightBlock) diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/include.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/include.rb new file mode 100644 index 0000000..6960952 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/include.rb @@ -0,0 +1,275 @@ +# frozen_string_literal: true + +module Jekyll + module Tags + class IncludeTag < Liquid::Tag + VALID_SYNTAX = %r! + ([\w-]+)\s*=\s* + (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w.-]+)) + !x.freeze + VARIABLE_SYNTAX = %r! + (?[^{]*(\{\{\s*[\w\-.]+\s*(\|.*)?\}\}[^\s{}]*)+) + (?.*) + !mx.freeze + + FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!.freeze + VALID_FILENAME_CHARS = %r!^[\w/.\-()+~\#@]+$!.freeze + INVALID_SEQUENCES = %r![./]{2,}!.freeze + + def initialize(tag_name, markup, tokens) + super + markup = markup.strip + matched = markup.match(VARIABLE_SYNTAX) + if matched + @file = matched["variable"].strip + @params = matched["params"].strip + else + @file, @params = markup.split(%r!\s+!, 2) + end + validate_params if @params + @tag_name = tag_name + end + + def syntax_example + "{% #{@tag_name} file.ext param='value' param2='value' %}" + end + + def parse_params(context) + params = {} + @params.scan(VALID_SYNTAX) do |key, d_quoted, s_quoted, variable| + value = if d_quoted + d_quoted.include?('\\"') ? d_quoted.gsub('\\"', '"') : d_quoted + elsif s_quoted + s_quoted.include?("\\'") ? s_quoted.gsub("\\'", "'") : s_quoted + elsif variable + context[variable] + end + + params[key] = value + end + params + end + + def validate_file_name(file) + if INVALID_SEQUENCES.match?(file) || !VALID_FILENAME_CHARS.match?(file) + raise ArgumentError, <<~MSG + Invalid syntax for include tag. File contains invalid characters or sequences: + + #{file} + + Valid syntax: + + #{syntax_example} + + MSG + end + end + + def validate_params + unless FULL_VALID_SYNTAX.match?(@params) + raise ArgumentError, <<~MSG + Invalid syntax for include tag: + + #{@params} + + Valid syntax: + + #{syntax_example} + + MSG + end + end + + # Grab file read opts in the context + def file_read_opts(context) + context.registers[:site].file_read_opts + end + + # Render the variable if required + def render_variable(context) + Liquid::Template.parse(@file).render(context) if VARIABLE_SYNTAX.match?(@file) + end + + def tag_includes_dirs(context) + context.registers[:site].includes_load_paths.freeze + end + + def locate_include_file(context, file, safe) + includes_dirs = tag_includes_dirs(context) + includes_dirs.each do |dir| + path = PathManager.join(dir, file) + return path if valid_include_file?(path, dir.to_s, safe) + end + raise IOError, could_not_locate_message(file, includes_dirs, safe) + end + + def render(context) + site = context.registers[:site] + + file = render_variable(context) || @file + validate_file_name(file) + + path = locate_include_file(context, file, site.safe) + return unless path + + add_include_to_dependency(site, path, context) + + partial = load_cached_partial(path, context) + + context.stack do + context["include"] = parse_params(context) if @params + begin + partial.render!(context) + rescue Liquid::Error => e + e.template_name = path + e.markup_context = "included " if e.markup_context.nil? + raise e + end + end + end + + def add_include_to_dependency(site, path, context) + if context.registers[:page]&.key?("path") + site.regenerator.add_dependency( + site.in_source_dir(context.registers[:page]["path"]), + path + ) + end + end + + def load_cached_partial(path, context) + context.registers[:cached_partials] ||= {} + cached_partial = context.registers[:cached_partials] + + if cached_partial.key?(path) + cached_partial[path] + else + unparsed_file = context.registers[:site] + .liquid_renderer + .file(path) + begin + cached_partial[path] = unparsed_file.parse(read_file(path, context)) + rescue Liquid::Error => e + e.template_name = path + e.markup_context = "included " if e.markup_context.nil? + raise e + end + end + end + + def valid_include_file?(path, dir, safe) + !outside_site_source?(path, dir, safe) && File.file?(path) + end + + def outside_site_source?(path, dir, safe) + safe && !realpath_prefixed_with?(path, dir) + end + + def realpath_prefixed_with?(path, dir) + File.exist?(path) && File.realpath(path).start_with?(dir) + rescue StandardError + false + end + + # This method allows to modify the file content by inheriting from the class. + def read_file(file, context) + File.read(file, **file_read_opts(context)) + end + + private + + def could_not_locate_message(file, includes_dirs, safe) + message = "Could not locate the included file '#{file}' in any of #{includes_dirs}. " \ + "Ensure it exists in one of those directories and" + message + if safe + " is not a symlink as those are not allowed in safe mode." + else + ", if it is a symlink, does not point outside your site source." + end + end + end + + # Do not inherit from this class. + # TODO: Merge into the `Jekyll::Tags::IncludeTag` in v5.0 + class OptimizedIncludeTag < IncludeTag + def render(context) + @site ||= context.registers[:site] + + file = render_variable(context) || @file + validate_file_name(file) + + @site.inclusions[file] ||= locate_include_file(file) + inclusion = @site.inclusions[file] + + add_include_to_dependency(inclusion, context) if @site.config["incremental"] + + context.stack do + context["include"] = parse_params(context) if @params + inclusion.render(context) + end + end + + private + + def locate_include_file(file) + @site.includes_load_paths.each do |dir| + path = PathManager.join(dir, file) + return Inclusion.new(@site, dir, file) if valid_include_file?(path, dir) + end + raise IOError, could_not_locate_message(file, @site.includes_load_paths, @site.safe) + end + + def valid_include_file?(path, dir) + File.file?(path) && !outside_scope?(path, dir) + end + + def outside_scope?(path, dir) + @site.safe && !realpath_prefixed_with?(path, dir) + end + + def realpath_prefixed_with?(path, dir) + File.realpath(path).start_with?(dir) + rescue StandardError + false + end + + def add_include_to_dependency(inclusion, context) + page = context.registers[:page] + return unless page&.key?("path") + + absolute_path = \ + if page["collection"] + @site.in_source_dir(@site.config["collections_dir"], page["path"]) + else + @site.in_source_dir(page["path"]) + end + + @site.regenerator.add_dependency(absolute_path, inclusion.path) + end + end + + class IncludeRelativeTag < IncludeTag + def tag_includes_dirs(context) + Array(page_path(context)).freeze + end + + def page_path(context) + page, site = context.registers.values_at(:page, :site) + return site.source unless page + + site.in_source_dir File.dirname(resource_path(page, site)) + end + + private + + def resource_path(page, site) + path = page["path"] + path = File.join(site.config["collections_dir"], path) if page["collection"] + path.delete_suffix("/#excerpt") + end + end + end +end + +Liquid::Template.register_tag("include", Jekyll::Tags::OptimizedIncludeTag) +Liquid::Template.register_tag("include_relative", Jekyll::Tags::IncludeRelativeTag) diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/link.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/link.rb new file mode 100644 index 0000000..c986b5a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/link.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Jekyll + module Tags + class Link < Liquid::Tag + include Jekyll::Filters::URLFilters + + class << self + def tag_name + name.split("::").last.downcase + end + end + + def initialize(tag_name, relative_path, tokens) + super + + @relative_path = relative_path.strip + end + + def render(context) + @context = context + site = context.registers[:site] + relative_path = Liquid::Template.parse(@relative_path).render(context) + relative_path_with_leading_slash = PathManager.join("", relative_path) + + site.each_site_file do |item| + return relative_url(item) if item.relative_path == relative_path + # This takes care of the case for static files that have a leading / + return relative_url(item) if item.relative_path == relative_path_with_leading_slash + end + + raise ArgumentError, <<~MSG + Could not find document '#{relative_path}' in tag '#{self.class.tag_name}'. + + Make sure the document exists and the path is correct. + MSG + end + end + end +end + +Liquid::Template.register_tag(Jekyll::Tags::Link.tag_name, Jekyll::Tags::Link) diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/post_url.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/post_url.rb new file mode 100644 index 0000000..7774d37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/tags/post_url.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true + +module Jekyll + module Tags + class PostComparer + MATCHER = %r!^(.+/)*(\d+-\d+-\d+)-(.*)$!.freeze + + attr_reader :path, :date, :slug, :name + + def initialize(name) + @name = name + + all, @path, @date, @slug = *name.sub(%r!^/!, "").match(MATCHER) + unless all + raise Jekyll::Errors::InvalidPostNameError, + "'#{name}' does not contain valid date and/or title." + end + + basename_pattern = "#{date}-#{Regexp.escape(slug)}\\.[^.]+" + @name_regex = %r!^_posts/#{path}#{basename_pattern}|^#{path}_posts/?#{basename_pattern}! + end + + def post_date + @post_date ||= Utils.parse_date( + date, + "'#{date}' does not contain valid date and/or title." + ) + end + + def ==(other) + other.relative_path.match(@name_regex) + end + + def deprecated_equality(other) + slug == post_slug(other) && + post_date.year == other.date.year && + post_date.month == other.date.month && + post_date.day == other.date.day + end + + private + + # Construct the directory-aware post slug for a Jekyll::Post + # + # other - the Jekyll::Post + # + # Returns the post slug with the subdirectory (relative to _posts) + def post_slug(other) + path = other.basename.split("/")[0...-1].join("/") + if path.nil? || path == "" + other.data["slug"] + else + "#{path}/#{other.data["slug"]}" + end + end + end + + class PostUrl < Liquid::Tag + include Jekyll::Filters::URLFilters + + def initialize(tag_name, post, tokens) + super + @orig_post = post.strip + begin + @post = PostComparer.new(@orig_post) + rescue StandardError => e + raise Jekyll::Errors::PostURLError, <<~MSG + Could not parse name of post "#{@orig_post}" in tag 'post_url'. + Make sure the post exists and the name is correct. + #{e.class}: #{e.message} + MSG + end + end + + def render(context) + @context = context + site = context.registers[:site] + + site.posts.docs.each do |document| + return relative_url(document) if @post == document + end + + # New matching method did not match, fall back to old method + # with deprecation warning if this matches + + site.posts.docs.each do |document| + next unless @post.deprecated_equality document + + Jekyll::Deprecator.deprecation_message( + "A call to '{% post_url #{@post.name} %}' did not match a post using the new " \ + "matching method of checking name (path-date-slug) equality. Please make sure " \ + "that you change this tag to match the post's name exactly." + ) + return relative_url(document) + end + + raise Jekyll::Errors::PostURLError, <<~MSG + Could not find post "#{@orig_post}" in tag 'post_url'. + Make sure the post exists and the name is correct. + MSG + end + end + end +end + +Liquid::Template.register_tag("post_url", Jekyll::Tags::PostUrl) diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/theme.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/theme.rb new file mode 100644 index 0000000..a3f2a94 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/theme.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +module Jekyll + class Theme + extend Forwardable + attr_reader :name + + def_delegator :gemspec, :version, :version + + def initialize(name) + @name = name.downcase.strip + Jekyll.logger.debug "Theme:", name + Jekyll.logger.debug "Theme source:", root + end + + def root + # Must use File.realpath to resolve symlinks created by rbenv + # Otherwise, Jekyll.sanitized path with prepend the unresolved root + @root ||= File.realpath(gemspec.full_gem_path) + rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP + raise "Path #{gemspec.full_gem_path} does not exist, is not accessible or includes " \ + "a symbolic link loop" + end + + # The name of theme directory + def basename + @basename ||= File.basename(root) + end + + def includes_path + @includes_path ||= path_for "_includes" + end + + def layouts_path + @layouts_path ||= path_for "_layouts" + end + + def sass_path + @sass_path ||= path_for "_sass" + end + + def assets_path + @assets_path ||= path_for "assets" + end + + def data_path + @data_path ||= path_for "_data" + end + + def runtime_dependencies + gemspec.runtime_dependencies + end + + private + + def path_for(folder) + path = realpath_for(folder) + path if path && File.directory?(path) + end + + def realpath_for(folder) + # This resolves all symlinks for the theme subfolder and then ensures that the directory + # remains inside the theme root. This prevents the use of symlinks for theme subfolders to + # escape the theme root. + # However, symlinks are allowed to point to other directories within the theme. + Jekyll.sanitized_path(root, File.realpath(Jekyll.sanitized_path(root, folder.to_s))) + rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP => e + log_realpath_exception(e, folder) + nil + end + + def log_realpath_exception(err, folder) + return if err.is_a?(Errno::ENOENT) + + case err + when Errno::EACCES + Jekyll.logger.error "Theme error:", "Directory '#{folder}' is not accessible." + when Errno::ELOOP + Jekyll.logger.error "Theme error:", "Directory '#{folder}' includes a symbolic link loop." + end + end + + def gemspec + @gemspec ||= Gem::Specification.find_by_name(name) + rescue Gem::LoadError + raise Jekyll::Errors::MissingDependencyException, + "The #{name} theme could not be found." + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/theme_builder.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/theme_builder.rb new file mode 100644 index 0000000..b03abbf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/theme_builder.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +module Jekyll + class ThemeBuilder + SCAFFOLD_DIRECTORIES = %w( + assets _data _layouts _includes _sass + ).freeze + + attr_reader :name, :path, :code_of_conduct + + def initialize(theme_name, opts) + @name = theme_name.to_s.tr(" ", "_").squeeze("_") + @path = Pathname.new(File.expand_path(name, Dir.pwd)) + @code_of_conduct = !!opts["code_of_conduct"] + end + + def create! + create_directories + create_starter_files + create_gemspec + create_accessories + initialize_git_repo + end + + def user_name + @user_name ||= `git config user.name`.chomp + end + + def user_email + @user_email ||= `git config user.email`.chomp + end + + private + + def root + @root ||= Pathname.new(File.expand_path("../", __dir__)) + end + + def template_file(filename) + [ + root.join("theme_template", "#{filename}.erb"), + root.join("theme_template", filename.to_s), + ].find(&:exist?) + end + + def template(filename) + erb.render(template_file(filename).read) + end + + def erb + @erb ||= ERBRenderer.new(self) + end + + def mkdir_p(directories) + Array(directories).each do |directory| + full_path = path.join(directory) + Jekyll.logger.info "create", full_path.to_s + FileUtils.mkdir_p(full_path) + end + end + + def write_file(filename, contents) + full_path = path.join(filename) + Jekyll.logger.info "create", full_path.to_s + File.write(full_path, contents) + end + + def create_directories + mkdir_p(SCAFFOLD_DIRECTORIES) + end + + def create_starter_files + %w(page post default).each do |layout| + write_file("_layouts/#{layout}.html", template("_layouts/#{layout}.html")) + end + end + + def create_gemspec + write_file("Gemfile", template("Gemfile")) + write_file("#{name}.gemspec", template("theme.gemspec")) + end + + def create_accessories + accessories = %w(README.md LICENSE.txt) + accessories << "CODE_OF_CONDUCT.md" if code_of_conduct + accessories.each do |filename| + write_file(filename, template(filename)) + end + end + + def initialize_git_repo + Jekyll.logger.info "initialize", path.join(".git").to_s + Dir.chdir(path.to_s) { `git init` } + write_file(".gitignore", template("gitignore")) + end + + class ERBRenderer + extend Forwardable + + def_delegator :@theme_builder, :name, :theme_name + def_delegator :@theme_builder, :user_name, :user_name + def_delegator :@theme_builder, :user_email, :user_email + + def initialize(theme_builder) + @theme_builder = theme_builder + end + + def jekyll_version_with_minor + Jekyll::VERSION.split(".").take(2).join(".") + end + + def theme_directories + SCAFFOLD_DIRECTORIES + end + + def render(contents) + ERB.new(contents).result binding + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/url.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/url.rb new file mode 100644 index 0000000..aeb2ac0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/url.rb @@ -0,0 +1,167 @@ +# frozen_string_literal: true + +# Public: Methods that generate a URL for a resource such as a Post or a Page. +# +# Examples +# +# URL.new({ +# :template => /:categories/:title.html", +# :placeholders => {:categories => "ruby", :title => "something"} +# }).to_s +# +module Jekyll + class URL + # options - One of :permalink or :template must be supplied. + # :template - The String used as template for URL generation, + # for example "/:path/:basename:output_ext", where + # a placeholder is prefixed with a colon. + # :placeholders - A hash containing the placeholders which will be + # replaced when used inside the template. E.g. + # { "year" => Time.now.strftime("%Y") } would replace + # the placeholder ":year" with the current year. + # :permalink - If supplied, no URL will be generated from the + # template. Instead, the given permalink will be + # used as URL. + def initialize(options) + @template = options[:template] + @placeholders = options[:placeholders] || {} + @permalink = options[:permalink] + + if (@template || @permalink).nil? + raise ArgumentError, "One of :template or :permalink must be supplied." + end + end + + # The generated relative URL of the resource + # + # Returns the String URL + def to_s + sanitize_url(generated_permalink || generated_url) + end + + # Generates a URL from the permalink + # + # Returns the _unsanitized String URL + def generated_permalink + (@generated_permalink ||= generate_url(@permalink)) if @permalink + end + + # Generates a URL from the template + # + # Returns the unsanitized String URL + def generated_url + @generated_url ||= generate_url(@template) + end + + # Internal: Generate the URL by replacing all placeholders with their + # respective values in the given template + # + # Returns the unsanitized String URL + def generate_url(template) + if @placeholders.is_a? Drops::UrlDrop + generate_url_from_drop(template) + else + generate_url_from_hash(template) + end + end + + def generate_url_from_hash(template) + @placeholders.inject(template) do |result, token| + break result if result.index(":").nil? + + if token.last.nil? + # Remove leading "/" to avoid generating urls with `//` + result.gsub("/:#{token.first}", "") + else + result.gsub(":#{token.first}", self.class.escape_path(token.last)) + end + end + end + + # We include underscores in keys to allow for 'i_month' and so forth. + # This poses a problem for keys which are followed by an underscore + # but the underscore is not part of the key, e.g. '/:month_:day'. + # That should be :month and :day, but our key extraction regexp isn't + # smart enough to know that so we have to make it an explicit + # possibility. + def possible_keys(key) + if key.end_with?("_") + [key, key.chomp("_")] + else + [key] + end + end + + def generate_url_from_drop(template) + template.gsub(%r!:([a-z_]+)!) do |match| + name = Regexp.last_match(1) + pool = name.end_with?("_") ? [name, name.chomp!("_")] : [name] + + winner = pool.find { |key| @placeholders.key?(key) } + if winner.nil? + raise NoMethodError, + "The URL template doesn't have #{pool.join(" or ")} keys. " \ + "Check your permalink template!" + end + + value = @placeholders[winner] + value = "" if value.nil? + replacement = self.class.escape_path(value) + + match.sub!(":#{winner}", replacement) + end + end + + # Returns a sanitized String URL, stripping "../../" and multiples of "/", + # as well as the beginning "/" so we can enforce and ensure it. + def sanitize_url(str) + "/#{str}".gsub("..", "/").tap do |result| + result.gsub!("./", "") + result.squeeze!("/") + end + end + + # Escapes a path to be a valid URL path segment + # + # path - The path to be escaped. + # + # Examples: + # + # URL.escape_path("/a b") + # # => "/a%20b" + # + # Returns the escaped path. + def self.escape_path(path) + return path if path.empty? || %r!^[a-zA-Z0-9./-]+$!.match?(path) + + # Because URI.escape doesn't escape "?", "[" and "]" by default, + # specify unsafe string (except unreserved, sub-delims, ":", "@" and "/"). + # + # URI path segment is defined in RFC 3986 as follows: + # segment = *pchar + # pchar = unreserved / pct-encoded / sub-delims / ":" / "@" + # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + # pct-encoded = "%" HEXDIG HEXDIG + # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" + # / "*" / "+" / "," / ";" / "=" + Addressable::URI.encode(path).encode("utf-8").sub("#", "%23") + end + + # Unescapes a URL path segment + # + # path - The path to be unescaped. + # + # Examples: + # + # URL.unescape_path("/a%20b") + # # => "/a b" + # + # Returns the unescaped path. + def self.unescape_path(path) + path = path.encode("utf-8") + return path unless path.include?("%") + + Addressable::URI.unencode(path) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils.rb new file mode 100644 index 0000000..2a96527 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils.rb @@ -0,0 +1,371 @@ +# frozen_string_literal: true + +module Jekyll + module Utils + extend self + autoload :Ansi, "jekyll/utils/ansi" + autoload :Exec, "jekyll/utils/exec" + autoload :Internet, "jekyll/utils/internet" + autoload :Platforms, "jekyll/utils/platforms" + autoload :ThreadEvent, "jekyll/utils/thread_event" + autoload :WinTZ, "jekyll/utils/win_tz" + + # Constants for use in #slugify + SLUGIFY_MODES = %w(raw default pretty ascii latin).freeze + SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze + SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}]+").freeze + SLUGIFY_PRETTY_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}._~!$&'()+,;=@]+").freeze + SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze + + # Takes a slug and turns it into a simple title. + def titleize_slug(slug) + slug.split("-").map!(&:capitalize).join(" ") + end + + # Non-destructive version of deep_merge_hashes! See that method. + # + # Returns the merged hashes. + def deep_merge_hashes(master_hash, other_hash) + deep_merge_hashes!(master_hash.dup, other_hash) + end + + # Merges a master hash with another hash, recursively. + # + # master_hash - the "parent" hash whose values will be overridden + # other_hash - the other hash whose values will be persisted after the merge + # + # This code was lovingly stolen from some random gem: + # http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html + # + # Thanks to whoever made it. + def deep_merge_hashes!(target, overwrite) + merge_values(target, overwrite) + merge_default_proc(target, overwrite) + duplicate_frozen_values(target) + + target + end + + def mergable?(value) + value.is_a?(Hash) || value.is_a?(Drops::Drop) + end + + def duplicable?(obj) + case obj + when nil, false, true, Symbol, Numeric + false + else + true + end + end + + # Read array from the supplied hash favouring the singular key + # and then the plural key, and handling any nil entries. + # + # hash - the hash to read from + # singular_key - the singular key + # plural_key - the plural key + # + # Returns an array + def pluralized_array_from_hash(hash, singular_key, plural_key) + array = [] + value = value_from_singular_key(hash, singular_key) + value ||= value_from_plural_key(hash, plural_key) + + array << value + array.flatten! + array.compact! + array + end + + def value_from_singular_key(hash, key) + hash[key] if hash.key?(key) || (hash.default_proc && hash[key]) + end + + def value_from_plural_key(hash, key) + if hash.key?(key) || (hash.default_proc && hash[key]) + val = hash[key] + case val + when String + val.split + when Array + val.compact + end + end + end + + def transform_keys(hash) + result = {} + hash.each_key do |key| + result[yield(key)] = hash[key] + end + result + end + + # Apply #to_sym to all keys in the hash + # + # hash - the hash to which to apply this transformation + # + # Returns a new hash with symbolized keys + def symbolize_hash_keys(hash) + transform_keys(hash) { |key| key.to_sym rescue key } + end + + # Apply #to_s to all keys in the Hash + # + # hash - the hash to which to apply this transformation + # + # Returns a new hash with stringified keys + def stringify_hash_keys(hash) + transform_keys(hash) { |key| key.to_s rescue key } + end + + # Parse a date/time and throw an error if invalid + # + # input - the date/time to parse + # msg - (optional) the error message to show the user + # + # Returns the parsed date if successful, throws a FatalException + # if not + def parse_date(input, msg = "Input could not be parsed.") + @parse_date_cache ||= {} + @parse_date_cache[input] ||= Time.parse(input).localtime + rescue ArgumentError + raise Errors::InvalidDateError, "Invalid date '#{input}': #{msg}" + end + + # Determines whether a given file has + # + # Returns true if the YAML front matter is present. + # rubocop: disable Naming/PredicateName + def has_yaml_header?(file) + File.open(file, "rb", &:readline).match? %r!\A---\s*\r?\n! + rescue EOFError + false + end + + # Determine whether the given content string contains Liquid Tags or Variables + # + # Returns true is the string contains sequences of `{%` or `{{` + def has_liquid_construct?(content) + return false if content.nil? || content.empty? + + content.include?("{%") || content.include?("{{") + end + # rubocop: enable Naming/PredicateName + + # Slugify a filename or title. + # + # string - the filename or title to slugify + # mode - how string is slugified + # cased - whether to replace all uppercase letters with their + # lowercase counterparts + # + # When mode is "none", return the given string. + # + # When mode is "raw", return the given string, + # with every sequence of spaces characters replaced with a hyphen. + # + # When mode is "default" or nil, non-alphabetic characters are + # replaced with a hyphen too. + # + # When mode is "pretty", some non-alphabetic characters (._~!$&'()+,;=@) + # are not replaced with hyphen. + # + # When mode is "ascii", some everything else except ASCII characters + # a-z (lowercase), A-Z (uppercase) and 0-9 (numbers) are not replaced with hyphen. + # + # When mode is "latin", the input string is first preprocessed so that + # any letters with accents are replaced with the plain letter. Afterwards, + # it follows the "default" mode of operation. + # + # If cased is true, all uppercase letters in the result string are + # replaced with their lowercase counterparts. + # + # Examples: + # slugify("The _config.yml file") + # # => "the-config-yml-file" + # + # slugify("The _config.yml file", "pretty") + # # => "the-_config.yml-file" + # + # slugify("The _config.yml file", "pretty", true) + # # => "The-_config.yml file" + # + # slugify("The _config.yml file", "ascii") + # # => "the-config-yml-file" + # + # slugify("The _config.yml file", "latin") + # # => "the-config-yml-file" + # + # Returns the slugified string. + def slugify(string, mode: nil, cased: false) + mode ||= "default" + return nil if string.nil? + + unless SLUGIFY_MODES.include?(mode) + return cased ? string : string.downcase + end + + # Drop accent marks from latin characters. Everything else turns to ? + if mode == "latin" + I18n.config.available_locales = :en if I18n.config.available_locales.empty? + string = I18n.transliterate(string) + end + + slug = replace_character_sequence_with_hyphen(string, :mode => mode) + + # Remove leading/trailing hyphen + slug.gsub!(%r!^-|-$!i, "") + + slug.downcase! unless cased + Jekyll.logger.warn("Warning:", "Empty `slug` generated for '#{string}'.") if slug.empty? + slug + end + + # Add an appropriate suffix to template so that it matches the specified + # permalink style. + # + # template - permalink template without trailing slash or file extension + # permalink_style - permalink style, either built-in or custom + # + # The returned permalink template will use the same ending style as + # specified in permalink_style. For example, if permalink_style contains a + # trailing slash (or is :pretty, which indirectly has a trailing slash), + # then so will the returned template. If permalink_style has a trailing + # ":output_ext" (or is :none, :date, or :ordinal) then so will the returned + # template. Otherwise, template will be returned without modification. + # + # Examples: + # add_permalink_suffix("/:basename", :pretty) + # # => "/:basename/" + # + # add_permalink_suffix("/:basename", :date) + # # => "/:basename:output_ext" + # + # add_permalink_suffix("/:basename", "/:year/:month/:title/") + # # => "/:basename/" + # + # add_permalink_suffix("/:basename", "/:year/:month/:title") + # # => "/:basename" + # + # Returns the updated permalink template + def add_permalink_suffix(template, permalink_style) + template = template.dup + + case permalink_style + when :pretty + template << "/" + when :date, :ordinal, :none + template << ":output_ext" + else + template << "/" if permalink_style.to_s.end_with?("/") + template << ":output_ext" if permalink_style.to_s.end_with?(":output_ext") + end + + template + end + + # Work the same way as Dir.glob but separating the input into two parts + # ('dir' + '/' + 'pattern') to make sure the first part('dir') does not act + # as a pattern. + # + # For example, Dir.glob("path[/*") always returns an empty array, + # because the method fails to find the closing pattern to '[' which is ']' + # + # Examples: + # safe_glob("path[", "*") + # # => ["path[/file1", "path[/file2"] + # + # safe_glob("path", "*", File::FNM_DOTMATCH) + # # => ["path/.", "path/..", "path/file1"] + # + # safe_glob("path", ["**", "*"]) + # # => ["path[/file1", "path[/folder/file2"] + # + # dir - the dir where glob will be executed under + # (the dir will be included to each result) + # patterns - the patterns (or the pattern) which will be applied under the dir + # flags - the flags which will be applied to the pattern + # + # Returns matched paths + def safe_glob(dir, patterns, flags = 0) + return [] unless Dir.exist?(dir) + + pattern = File.join(Array(patterns)) + return [dir] if pattern.empty? + + Dir.chdir(dir) do + Dir.glob(pattern, flags).map { |f| File.join(dir, f) } + end + end + + # Returns merged option hash for File.read of self.site (if exists) + # and a given param + def merged_file_read_opts(site, opts) + merged = (site ? site.file_read_opts : {}).merge(opts) + + # always use BOM when reading UTF-encoded files + if merged[:encoding]&.downcase&.start_with?("utf-") + merged[:encoding] = "bom|#{merged[:encoding]}" + end + if merged["encoding"]&.downcase&.start_with?("utf-") + merged["encoding"] = "bom|#{merged["encoding"]}" + end + + merged + end + + private + + def merge_values(target, overwrite) + target.merge!(overwrite) do |_key, old_val, new_val| + if new_val.nil? + old_val + elsif mergable?(old_val) && mergable?(new_val) + deep_merge_hashes(old_val, new_val) + else + new_val + end + end + end + + def merge_default_proc(target, overwrite) + if target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil? + target.default_proc = overwrite.default_proc + end + end + + def duplicate_frozen_values(target) + target.each do |key, val| + target[key] = val.dup if val.frozen? && duplicable?(val) + end + end + + # Replace each character sequence with a hyphen. + # + # See Utils#slugify for a description of the character sequence specified + # by each mode. + def replace_character_sequence_with_hyphen(string, mode: "default") + replaceable_char = + case mode + when "raw" + SLUGIFY_RAW_REGEXP + when "pretty" + # "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL + # and is allowed in both extN and NTFS. + SLUGIFY_PRETTY_REGEXP + when "ascii" + # For web servers not being able to handle Unicode, the safe + # method is to ditch anything else but latin letters and numeric + # digits. + SLUGIFY_ASCII_REGEXP + else + SLUGIFY_DEFAULT_REGEXP + end + + # Strip according to the mode + string.gsub(replaceable_char, "-") + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/ansi.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/ansi.rb new file mode 100644 index 0000000..00d1b1d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/ansi.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Jekyll + module Utils + module Ansi + extend self + + ESCAPE = format("%c", 27) + MATCH = %r!#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m!ix.freeze + COLORS = { + :red => 31, + :green => 32, + :black => 30, + :magenta => 35, + :yellow => 33, + :white => 37, + :blue => 34, + :cyan => 36, + }.freeze + + # Strip ANSI from the current string. It also strips cursor stuff, + # well some of it, and it also strips some other stuff that a lot of + # the other ANSI strippers don't. + + def strip(str) + str.gsub MATCH, "" + end + + # + + def has?(str) + !!(str =~ MATCH) + end + + # Reset the color back to the default color so that you do not leak any + # colors when you move onto the next line. This is probably normally + # used as part of a wrapper so that we don't leak colors. + + def reset(str = "") + @ansi_reset ||= format("%c[0m", 27) + "#{@ansi_reset}#{str}" + end + + # SEE: `self::COLORS` for a list of methods. They are mostly + # standard base colors supported by pretty much any xterm-color, we do + # not need more than the base colors so we do not include them. + # Actually... if I'm honest we don't even need most of the + # base colors. + + COLORS.each do |color, num| + define_method color do |str| + "#{format("%c", 27)}[#{num}m#{str}#{reset}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/exec.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/exec.rb new file mode 100644 index 0000000..5838ecb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/exec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require "open3" + +module Jekyll + module Utils + module Exec + extend self + + # Runs a program in a sub-shell. + # + # *args - a list of strings containing the program name and arguments + # + # Returns a Process::Status and a String of output in an array in + # that order. + def run(*args) + stdin, stdout, stderr, process = Open3.popen3(*args) + out = stdout.read.strip + err = stderr.read.strip + + [stdin, stdout, stderr].each(&:close) + [process.value, out + err] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/internet.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/internet.rb new file mode 100644 index 0000000..945267f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/internet.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Jekyll + module Utils + module Internet + # Public: Determine whether the present device has a connection to + # the Internet. This allows plugin writers which require the outside + # world to have a neat fallback mechanism for offline building. + # + # Example: + # if Internet.connected? + # Typhoeus.get("https://pages.github.com/versions.json") + # else + # Jekyll.logger.warn "Warning:", "Version check has been disabled." + # Jekyll.logger.warn "", "Connect to the Internet to enable it." + # nil + # end + # + # Returns true if a DNS call can successfully be made, or false if not. + + module_function + + def connected? + !dns("example.com").nil? + end + + def dns(domain) + require "resolv" + Resolv::DNS.open do |resolver| + resolver.getaddress(domain) + end + rescue Resolv::ResolvError, Resolv::ResolvTimeout + nil + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/platforms.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/platforms.rb new file mode 100644 index 0000000..a6c6da9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/platforms.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +module Jekyll + module Utils + module Platforms + extend self + + def jruby? + RUBY_ENGINE == "jruby" + end + + def mri? + RUBY_ENGINE == "ruby" + end + + def windows? + vanilla_windows? || bash_on_windows? + end + + # Not a Windows Subsystem for Linux (WSL) + def vanilla_windows? + rbconfig_host.match?(%r!mswin|mingw|cygwin!) && proc_version.empty? + end + alias_method :really_windows?, :vanilla_windows? + + # Determine if Windows Subsystem for Linux (WSL) + def bash_on_windows? + linux_os? && microsoft_proc_version? + end + + def linux? + linux_os? && !microsoft_proc_version? + end + + def osx? + rbconfig_host.match?(%r!darwin|mac os!) + end + + def unix? + rbconfig_host.match?(%r!solaris|bsd!) + end + + private + + def proc_version + @proc_version ||= \ + begin + File.read("/proc/version").downcase + rescue Errno::ENOENT, Errno::EACCES + "" + end + end + + def rbconfig_host + @rbconfig_host ||= RbConfig::CONFIG["host_os"].downcase + end + + def linux_os? + rbconfig_host.include?("linux") + end + + def microsoft_proc_version? + proc_version.include?("microsoft") + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/thread_event.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/thread_event.rb new file mode 100644 index 0000000..801022e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/thread_event.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Jekyll + module Utils + # Based on the pattern and code from + # https://emptysqua.re/blog/an-event-synchronization-primitive-for-ruby/ + class ThreadEvent + attr_reader :flag + + def initialize + @lock = Mutex.new + @cond = ConditionVariable.new + @flag = false + end + + def set + @lock.synchronize do + yield if block_given? + @flag = true + @cond.broadcast + end + end + + def wait + @lock.synchronize do + @cond.wait(@lock) unless @flag + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/win_tz.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/win_tz.rb new file mode 100644 index 0000000..ad277d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/utils/win_tz.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Jekyll + module Utils + module WinTZ + extend self + + # Public: Calculate the Timezone for Windows when the config file has a defined + # 'timezone' key. + # + # timezone - the IANA Time Zone specified in "_config.yml" + # + # Returns a string that ultimately re-defines ENV["TZ"] in Windows + def calculate(timezone, now = Time.now) + External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo) + tz = TZInfo::Timezone.get(timezone) + + # + # Use period_for_utc and utc_total_offset instead of + # period_for and observed_utc_offset for compatibility with tzinfo v1. + offset = tz.period_for_utc(now.getutc).utc_total_offset + + # + # POSIX style definition reverses the offset sign. + # e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian + # is denoted as: + # EST+5 (or) EST+05:00 + # Reference: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html + sign = offset.positive? ? "-" : "+" + + rational_hours = offset.abs.to_r / 3600 + hours = rational_hours.to_i + minutes = ((rational_hours - hours) * 60).to_i + + # + # Format the hours and minutes as two-digit numbers. + time = format("%02d:%02d", :hours => hours, :minutes => minutes) + + Jekyll.logger.debug "Timezone:", "#{timezone} #{sign}#{time}" + # + # Note: The 3-letter-word below doesn't have a particular significance. + "WTZ#{sign}#{time}" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/version.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/version.rb new file mode 100644 index 0000000..7eb6d31 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/jekyll/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Jekyll + VERSION = "4.3.3" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/.gitignore b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/.gitignore new file mode 100644 index 0000000..f40fbd8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/.gitignore @@ -0,0 +1,5 @@ +_site +.sass-cache +.jekyll-cache +.jekyll-metadata +vendor diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/404.html b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/404.html new file mode 100644 index 0000000..086a5c9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/404.html @@ -0,0 +1,25 @@ +--- +permalink: /404.html +layout: default +--- + + + +
+

404

+ +

Page not found :(

+

The requested page could not be found.

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/_config.yml b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/_config.yml new file mode 100644 index 0000000..ef7ba7c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/_config.yml @@ -0,0 +1,55 @@ +# Welcome to Jekyll! +# +# This config file is meant for settings that affect your whole blog, values +# which you are expected to set up once and rarely edit after that. If you find +# yourself editing this file very often, consider using Jekyll's data files +# feature for the data you need to update frequently. +# +# For technical reasons, this file is *NOT* reloaded automatically when you use +# 'bundle exec jekyll serve'. If you change this file, please restart the server process. +# +# If you need help with YAML syntax, here are some quick references for you: +# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml +# https://learnxinyminutes.com/docs/yaml/ +# +# Site settings +# These are used to personalize your new site. If you look in the HTML files, +# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. +# You can create any custom variable you would like, and they will be accessible +# in the templates via {{ site.myvariable }}. + +title: Your awesome title +email: your-email@example.com +description: >- # this means to ignore newlines until "baseurl:" + Write an awesome description for your new site here. You can edit this + line in _config.yml. It will appear in your document head meta (for + Google search results) and in your feed.xml site description. +baseurl: "" # the subpath of your site, e.g. /blog +url: "" # the base hostname & protocol for your site, e.g. http://example.com +twitter_username: jekyllrb +github_username: jekyll + +# Build settings +theme: minima +plugins: + - jekyll-feed + +# Exclude from processing. +# The following items will not be processed, by default. +# Any item listed under the `exclude:` key here will be automatically added to +# the internal "default list". +# +# Excluded items can be processed by explicitly listing the directories or +# their entries' file path in the `include:` list. +# +# exclude: +# - .sass-cache/ +# - .jekyll-cache/ +# - gemfiles/ +# - Gemfile +# - Gemfile.lock +# - node_modules/ +# - vendor/bundle/ +# - vendor/cache/ +# - vendor/gems/ +# - vendor/ruby/ diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb new file mode 100644 index 0000000..187a4d9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb @@ -0,0 +1,29 @@ +--- +layout: post +title: "Welcome to Jekyll!" +date: <%= Time.now.strftime('%Y-%m-%d %H:%M:%S %z') %> +categories: jekyll update +--- +You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. + +Jekyll requires blog post files to be named according to the following format: + +`YEAR-MONTH-DAY-title.MARKUP` + +Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works. + +Jekyll also offers powerful support for code snippets: + +{% highlight ruby %} +def print_hi(name) + puts "Hi, #{name}" +end +print_hi('Tom') +#=> prints 'Hi, Tom' to STDOUT. +{% endhighlight %} + +Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk]. + +[jekyll-docs]: https://jekyllrb.com/docs/home +[jekyll-gh]: https://github.com/jekyll/jekyll +[jekyll-talk]: https://talk.jekyllrb.com/ diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/about.markdown b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/about.markdown new file mode 100644 index 0000000..8b4e0b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/about.markdown @@ -0,0 +1,18 @@ +--- +layout: page +title: About +permalink: /about/ +--- + +This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/) + +You can find the source code for Minima at GitHub: +[jekyll][jekyll-organization] / +[minima](https://github.com/jekyll/minima) + +You can find the source code for Jekyll at GitHub: +[jekyll][jekyll-organization] / +[jekyll](https://github.com/jekyll/jekyll) + + +[jekyll-organization]: https://github.com/jekyll diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/index.markdown b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/index.markdown new file mode 100644 index 0000000..0671507 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/site_template/index.markdown @@ -0,0 +1,6 @@ +--- +# Feel free to add content and custom Front Matter to this file. +# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults + +layout: home +--- diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/CODE_OF_CONDUCT.md.erb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/CODE_OF_CONDUCT.md.erb new file mode 100644 index 0000000..2b2c773 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/CODE_OF_CONDUCT.md.erb @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at <%= user_email %>. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/Gemfile b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/Gemfile new file mode 100644 index 0000000..bb94df8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/Gemfile @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +source "https://rubygems.org" +gemspec diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/LICENSE.txt.erb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/LICENSE.txt.erb new file mode 100644 index 0000000..38a0eb4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/LICENSE.txt.erb @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) <%= Time.now.year %> <%= user_name %> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/README.md.erb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/README.md.erb new file mode 100644 index 0000000..9e18034 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/README.md.erb @@ -0,0 +1,50 @@ +# <%= theme_name %> + +Welcome to your new Jekyll theme! In this directory, you'll find the files you need to be able to package up your theme into a gem. Put your layouts in `_layouts`, your includes in `_includes`, your sass files in `_sass` and any other assets in `assets`. + +To experiment with this code, add some sample content and run `bundle exec jekyll serve` – this directory is setup just like a Jekyll site! + +TODO: Delete this and the text above, and describe your gem + +## Installation + +Add this line to your Jekyll site's `Gemfile`: + +```ruby +gem <%= theme_name.inspect %> +``` + +And add this line to your Jekyll site's `_config.yml`: + +```yaml +theme: <%= theme_name %> +``` + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install <%= theme_name %> + +## Usage + +TODO: Write usage instructions here. Describe your available layouts, includes, sass and/or assets. + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/<%= theme_name %>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct. + +## Development + +To set up your environment to develop this theme, run `bundle install`. + +Your theme is setup just like a normal Jekyll site! To test your theme, run `bundle exec jekyll serve` and open your browser at `http://localhost:4000`. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal. + +When your theme is released, only the files in `_layouts`, `_includes`, `_sass` and `assets` tracked with Git will be bundled. +To add a custom directory to your theme-gem, please edit the regexp in `<%= theme_name %>.gemspec` accordingly. + +## License + +The theme is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/default.html b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/default.html new file mode 100644 index 0000000..cddd070 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/default.html @@ -0,0 +1 @@ +{{ content }} diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/page.html b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/page.html new file mode 100644 index 0000000..5e71126 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/page.html @@ -0,0 +1,5 @@ +--- +layout: default +--- + +{{ content }} diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/post.html b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/post.html new file mode 100644 index 0000000..5e71126 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/_layouts/post.html @@ -0,0 +1,5 @@ +--- +layout: default +--- + +{{ content }} diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/_config.yml.erb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/_config.yml.erb new file mode 100644 index 0000000..82e8d42 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/_config.yml.erb @@ -0,0 +1 @@ +theme: <%= theme_name %> diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/_post.md b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/_post.md new file mode 100644 index 0000000..145b21d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/_post.md @@ -0,0 +1,12 @@ +--- +layout: post +--- + +Eos eu docendi tractatos sapientem, brute option menandri in vix, quando vivendo accommodare te ius. Nec melius fastidii constituam id, viderer theophrastus ad sit, hinc semper periculis cum id. Noluisse postulant assentior est in, no choro sadipscing repudiandae vix. Vis in euismod delenit dignissim. Ex quod nostrum sit, suas decore animal id ius, nobis solet detracto quo te. + +{% comment %} +Might you have an include in your theme? Why not try it here! +{% include my-themes-great-include.html %} +{% endcomment %} + +No laudem altera adolescens has, volumus lucilius eum no. Eam ei nulla audiam efficiantur. Suas affert per no, ei tale nibh sea. Sea ne magna harum, in denique scriptorem sea, cetero alienum tibique ei eos. Labores persequeris referrentur eos ei. diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/index.html b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/index.html new file mode 100644 index 0000000..b688538 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/index.html @@ -0,0 +1,14 @@ +--- +layout: page +--- + +Lorem ipsum dolor sit amet, quo id prima corrumpit pertinacia, id ius dolor dolores, an veri pertinax explicari mea. Agam solum et qui, his id ludus graeco adipiscing. Duis theophrastus nam in, at his vidisse atomorum. Tantas gloriatur scripserit ne eos. Est wisi tempor habemus at, ei graeco dissentiet eos. Ne usu aliquip sanctus conceptam, te vis ignota animal, modus latine contentiones ius te. + +{% for post in site.posts %} +

{{ post.title }}

+
{{ post.excerpt }}
+{% endfor %} + +Te falli veritus sea, at molestiae scribentur deterruisset vix, et mea zril phaedrum vulputate. No cum dicit consulatu. Ut has nostro noluisse expetendis, te pro quaeque disputando, eu sed summo omnes. Eos at tale aperiam, usu cu propriae quaestio constituto, sed aperiam erroribus temporibus an. + +Quo eu liber mediocritatem, vix an delectus eleifend, iuvaret suscipit ei vel. Partem invenire per an, mea postulant dissentias eu, ius tantas audire nominavi eu. Dicunt tritani veritus ex vis, mei in case sententiae. At exerci democritum nam, cu lobortis iracundia mei. Alia eligendi consectetuer eu sed, paulo docendi noluisse sit ex. diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/style.scss b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/style.scss new file mode 100644 index 0000000..7388f52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/example/style.scss @@ -0,0 +1,7 @@ +--- +--- + +// Here, you can test out the Sass/SCSS that you include in your theme. +// Simply `@import` the necessary file(s) to get the proper styles on the site. +// E.g.: +// @import "a-file-from-my-theme"; diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/gitignore.erb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/gitignore.erb new file mode 100644 index 0000000..736d740 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/gitignore.erb @@ -0,0 +1,6 @@ +*.gem +.bundle +.jekyll-cache +.sass-cache +_site +Gemfile.lock diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/theme.gemspec.erb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/theme.gemspec.erb new file mode 100644 index 0000000..7c13cd3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/lib/theme_template/theme.gemspec.erb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +Gem::Specification.new do |spec| + spec.name = <%= theme_name.inspect %> + spec.version = "0.1.0" + spec.authors = [<%= user_name.inspect %>] + spec.email = [<%= user_email.inspect %>] + + spec.summary = "TODO: Write a short summary, because Rubygems requires one." + spec.homepage = "TODO: Put your gem's website or public repo URL here." + spec.license = "MIT" + + spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r!^(<%= theme_directories.join("|") %>|LICENSE|README|_config\.yml)!i) } + + spec.add_runtime_dependency "jekyll", "~> <%= jekyll_version_with_minor %>" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll.rb new file mode 100644 index 0000000..31236b8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Dir[File.join(File.expand_path("jekyll", __dir__), "*.rb")].each do |ruby_file| + require ruby_file +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/assert_equal_literal_actual.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/assert_equal_literal_actual.rb new file mode 100644 index 0000000..5b66569 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/assert_equal_literal_actual.rb @@ -0,0 +1,149 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Jekyll + # Checks for `assert_equal(exp, act, msg = nil)` calls containing literal values as + # second argument. The second argument should ideally be a method called on the tested + # instance. + # + # @example + # # bad + # assert_equal @foo.bar, "foobar" + # assert_equal @alpha.beta, { "foo" => "bar", "lorem" => "ipsum" } + # assert_equal @alpha.omega, ["foobar", "lipsum"] + # + # # good + # assert_equal "foobar", @foo.bar + # + # assert_equal( + # { "foo" => "bar", "lorem" => "ipsum" }, + # @alpha.beta + # ) + # + # assert_equal( + # ["foobar", "lipsum"], + # @alpha.omega + # ) + # + class AssertEqualLiteralActual < Cop + MSG = "Provide the 'expected value' as the first argument to `assert_equal`.".freeze + + SIMPLE_LITERALS = %i( + true + false + nil + int + float + str + sym + complex + rational + regopt + ).freeze + + COMPLEX_LITERALS = %i( + array + hash + pair + irange + erange + regexp + ).freeze + + def_node_matcher :literal_actual?, <<-PATTERN + (send nil? :assert_equal $(send ...) $#literal?) + PATTERN + + def_node_matcher :literal_actual_with_msg?, <<-PATTERN + (send nil? :assert_equal $(send ...) $#literal? $#opt_msg?) + PATTERN + + def on_send(node) + return unless literal_actual?(node) || literal_actual_with_msg?(node) + add_offense(node, location: :expression) + end + + def autocorrect(node) + lambda do |corrector| + corrector.replace(node.loc.expression, replacement(node)) + end + end + + private + + def opt_msg?(node) + node&.source + end + + # This is not implement using a NodePattern because it seems + # to not be able to match against an explicit (nil) sexp + def literal?(node) + node && (simple_literal?(node) || complex_literal?(node)) + end + + def simple_literal?(node) + SIMPLE_LITERALS.include?(node.type) + end + + def complex_literal?(node) + COMPLEX_LITERALS.include?(node.type) && + node.each_child_node.all?(&method(:literal?)) + end + + def replacement(node) + _, _, first_param, second_param, optional_param = *node + + replaced_text = \ + if second_param.type == :hash + replace_hash_with_variable(first_param.source, second_param.source) + elsif second_param.type == :array && second_param.source != "[]" + replace_array_with_variable(first_param.source, second_param.source) + else + replace_based_on_line_length(first_param.source, second_param.source) + end + + return "#{replaced_text}, #{optional_param.source}" if optional_param + replaced_text + end + + def replace_based_on_line_length(first_expression, second_expression) + result = "assert_equal #{second_expression}, #{first_expression}" + return result if result.length < 80 + + # fold long lines independent of Rubocop configuration for better readability + <<~TEXT + assert_equal( + #{second_expression}, + #{first_expression} + ) + TEXT + end + + def replace_hash_with_variable(first_expression, second_expression) + expect_expression = if second_expression.start_with?("{") + second_expression + else + "{#{second_expression}}" + end + <<~TEXT + expected = #{expect_expression} + assert_equal expected, #{first_expression} + TEXT + end + + def replace_array_with_variable(first_expression, second_expression) + expect_expression = if second_expression.start_with?("%") + second_expression + else + Array(second_expression) + end + <<~TEXT + expected = #{expect_expression} + assert_equal expected, #{first_expression} + TEXT + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/no_p_allowed.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/no_p_allowed.rb new file mode 100644 index 0000000..cc7d997 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/no_p_allowed.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "rubocop" + +module RuboCop + module Cop + module Jekyll + class NoPAllowed < Cop + MSG = "Avoid using `p` to print things. Use `Jekyll.logger` instead.".freeze + + def_node_search :p_called?, <<-PATTERN + (send _ :p _) + PATTERN + + def on_send(node) + if p_called?(node) + add_offense(node, :location => :selector) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/no_puts_allowed.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/no_puts_allowed.rb new file mode 100644 index 0000000..a666aac --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.3/rubocop/jekyll/no_puts_allowed.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "rubocop" + +module RuboCop + module Cop + module Jekyll + class NoPutsAllowed < Cop + MSG = "Avoid using `puts` to print things. Use `Jekyll.logger` instead.".freeze + + def_node_search :puts_called?, <<-PATTERN + (send nil? :puts _) + PATTERN + + def on_send(node) + if puts_called?(node) + add_offense(node, :location => :selector) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll-sass-converter.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll-sass-converter.rb new file mode 100644 index 0000000..ed73199 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll-sass-converter.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require "jekyll-sass-converter/version" +require "jekyll/converters/scss" +require "jekyll/converters/sass" + +module JekyllSassConverter +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll-sass-converter/version.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll-sass-converter/version.rb new file mode 100644 index 0000000..25c7fc0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll-sass-converter/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module JekyllSassConverter + VERSION = "3.0.0" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/converters/sass.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/converters/sass.rb new file mode 100644 index 0000000..7e016c8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/converters/sass.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require "jekyll/converters/scss" + +module Jekyll + module Converters + class Sass < Scss + EXTENSION_PATTERN = %r!^\.sass$!i.freeze + + safe true + priority :low + + def syntax + :indented + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/converters/scss.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/converters/scss.rb new file mode 100644 index 0000000..0044f32 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/converters/scss.rb @@ -0,0 +1,281 @@ +# frozen_string_literal: true + +# stdlib +require "json" + +# 3rd party +require "addressable/uri" +require "sass-embedded" + +# internal +require_relative "../source_map_page" + +module Jekyll + module Converters + class Scss < Converter + EXTENSION_PATTERN = %r!^\.scss$!i.freeze + + SyntaxError = Class.new(ArgumentError) + + safe true + priority :low + + # This hook is triggered just before the method {#convert(content)} is executed, it + # associates the Scss (and Sass) converters with their respective sass_page objects. + Jekyll::Hooks.register :pages, :pre_render do |page| + next unless page.is_a?(Jekyll::Page) + + page.converters.each do |converter| + converter.associate_page(page) if converter.is_a?(Jekyll::Converters::Scss) + end + end + + # This hook is triggered just after the method {#convert(content)} has been executed, it + # dissociates the Scss (and Sass) converters with their respective sass_page objects. + Jekyll::Hooks.register :pages, :post_render do |page| + next unless page.is_a?(Jekyll::Page) + + page.converters.each do |converter| + converter.dissociate_page(page) if converter.is_a?(Jekyll::Converters::Scss) + end + end + + ALLOWED_STYLES = %w(expanded compressed).freeze + + # Associate this Converter with the "page" object that manages input and output files for + # this converter. + # + # Note: changing the associated sass_page during the live time of this Converter instance + # may result in inconsistent results. + # + # @param [Jekyll:Page] page The sass_page for which this object acts as converter. + def associate_page(page) + if @sass_page + Jekyll.logger.debug "Sass Converter:", + "sass_page re-assigned: #{@sass_page.name} to #{page.name}" + dissociate_page(page) + return + end + @sass_page = page + end + + # Dissociate this Converter with the "page" object. + # + # @param [Jekyll:Page] page The sass_page for which this object has acted as a converter. + def dissociate_page(page) + unless page.equal?(@sass_page) + Jekyll.logger.debug "Sass Converter:", + "dissociating a page that was never associated #{page.name}" + end + + @source_map_page = nil + @sass_page = nil + @site = nil + end + + def matches(ext) + ext =~ self.class::EXTENSION_PATTERN + end + + def output_ext(_ext) + ".css" + end + + def safe? + !!@config["safe"] + end + + def jekyll_sass_configuration + @jekyll_sass_configuration ||= begin + options = @config["sass"] || {} + unless options["style"].nil? + options["style"] = options["style"].to_s.delete_prefix(":").to_sym + end + options + end + end + + def syntax + :scss + end + + def sass_dir + return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty? + + jekyll_sass_configuration["sass_dir"] + end + + def sass_style + style = jekyll_sass_configuration["style"] + ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : :expanded + end + + def user_sass_load_paths + Array(jekyll_sass_configuration["load_paths"]) + end + + def sass_dir_relative_to_site_source + @sass_dir_relative_to_site_source ||= + Jekyll.sanitized_path(site_source, sass_dir).sub(site.source + "/", "") + end + + # rubocop:disable Metrics/AbcSize + def sass_load_paths + paths = user_sass_load_paths + [sass_dir_relative_to_site_source] + + # Sanitize paths to prevent any attack vectors (.e.g. `/**/*`) + paths.map! { |path| Jekyll.sanitized_path(site_source, path) } if safe? + + # Expand file globs (e.g. `node_modules/*/node_modules` ) + Dir.chdir(site_source) do + paths = paths.flat_map { |path| Dir.glob(path) } + + paths.map! do |path| + # Sanitize again in case globbing was able to do something crazy. + safe? ? Jekyll.sanitized_path(site_source, path) : File.expand_path(path) + end + end + + paths.uniq! + paths << site.theme.sass_path if site.theme&.sass_path + paths.select { |path| File.directory?(path) } + end + # rubocop:enable Metrics/AbcSize + + def sass_configs + { + :load_paths => sass_load_paths, + :charset => !associate_page_failed?, + :source_map => sourcemap_required?, + :source_map_include_sources => true, + :style => sass_style, + :syntax => syntax, + :url => sass_file_url, + :quiet_deps => quiet_deps_option, + :verbose => verbose_option, + } + end + + def convert(content) + output = ::Sass.compile_string(content, **sass_configs) + result = output.css + + if sourcemap_required? + source_map = process_source_map(output.source_map) + generate_source_map_page(source_map) + + if (sm_url = source_mapping_url) + result += "#{sass_style == :compressed ? "" : "\n\n"}/*# sourceMappingURL=#{sm_url} */" + end + end + + result + rescue ::Sass::CompileError => e + Jekyll.logger.error e.full_message + raise SyntaxError, e.message + end + + private + + # The Page instance for which this object acts as a converter. + attr_reader :sass_page + + def associate_page_failed? + !sass_page + end + + # The URL of the input scss (or sass) file. This information will be used for error reporting. + def sass_file_url + return if associate_page_failed? + + file_url_from_path(Jekyll.sanitized_path(site_source, sass_page.relative_path)) + end + + # The value of the `sourcemap` option chosen by the user. + # + # This option controls when sourcemaps shall be generated or not. + # + # Returns the value of the `sourcemap`-option chosen by the user or ':always' by default. + def sourcemap_option + jekyll_sass_configuration.fetch("sourcemap", :always).to_sym + end + + # Determines whether a sourcemap shall be generated or not. + # + # Returns `true` if a sourcemap shall be generated, `false` otherwise. + def sourcemap_required? + return false if associate_page_failed? || sourcemap_option == :never + return true if sourcemap_option == :always + + !(sourcemap_option == :development && Jekyll.env != "development") + end + + def source_map_page + return if associate_page_failed? + + @source_map_page ||= SourceMapPage.new(sass_page) + end + + # Returns the directory that source map sources are relative to. + def sass_source_root + if associate_page_failed? + site_source + else + Jekyll.sanitized_path(site_source, File.dirname(sass_page.relative_path)) + end + end + + # Converts file urls in source map to relative paths. + # + # Returns processed source map string. + def process_source_map(source_map) + map_data = JSON.parse(source_map) + unless associate_page_failed? + map_data["file"] = Addressable::URI.encode(sass_page.basename + ".css") + end + source_root_url = Addressable::URI.parse(file_url_from_path("#{sass_source_root}/")) + map_data["sources"].map! do |s| + s.start_with?("file:") ? Addressable::URI.parse(s).route_from(source_root_url).to_s : s + end + JSON.generate(map_data) + end + + # Adds the source-map to the source-map-page and adds it to `site.pages`. + def generate_source_map_page(source_map) + return if associate_page_failed? + + source_map_page.source_map(source_map) + site.pages << source_map_page + end + + # Returns a source mapping url for given source-map. + def source_mapping_url + return if associate_page_failed? + + Addressable::URI.encode(sass_page.basename + ".css.map") + end + + def site + associate_page_failed? ? Jekyll.sites.last : sass_page.site + end + + def site_source + site.source + end + + def file_url_from_path(path) + Addressable::URI.encode("file://#{path.start_with?("/") ? "" : "/"}#{path}") + end + + # Returns the value of the `quiet_deps`-option chosen by the user or 'false' by default. + def quiet_deps_option + !!jekyll_sass_configuration.fetch("quiet_deps", false) + end + + # Returns the value of the `verbose`-option chosen by the user or 'false' by default. + def verbose_option + !!jekyll_sass_configuration.fetch("verbose", false) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/source_map_page.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/source_map_page.rb new file mode 100644 index 0000000..26f46bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-sass-converter-3.0.0/lib/jekyll/source_map_page.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Jekyll + # A Jekyll::Page subclass to manage the source map file associated with + # a given scss / sass page. + class SourceMapPage < Page + # Initialize a new SourceMapPage. + # + # @param [Jekyll::Page] css_page The Page object that manages the css file. + def initialize(css_page) + @site = css_page.site + @dir = css_page.dir + @data = css_page.data + @name = css_page.basename + ".css.map" + + process(@name) + Jekyll::Hooks.trigger :pages, :post_init, self + end + + def source_map(map) + self.content = map + end + + def ext + ".map" + end + + def asset_file? + true + end + + def render_with_liquid? + false + end + + # @return[String] the object as a debug String. + def inspect + "#<#{self.class} @name=#{name.inspect}>" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll-watch.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll-watch.rb new file mode 100644 index 0000000..8ec874e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll-watch.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require "jekyll-watch/version" +require_relative "jekyll/watcher" +require_relative "jekyll/commands/watch" diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll-watch/version.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll-watch/version.rb new file mode 100644 index 0000000..ececd94 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll-watch/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Jekyll + module Watch + VERSION = "2.2.1" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll/commands/watch.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll/commands/watch.rb new file mode 100644 index 0000000..0cb6f0d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll/commands/watch.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Jekyll + module Commands + module Watch + extend self + + def init_with_program(prog); end + + # Build your jekyll site + # Continuously watch if `watch` is set to true in the config. + def process(options) + Jekyll.logger.log_level = :error if options["quiet"] + Jekyll::Watcher.watch(options) if options["watch"] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll/watcher.rb b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll/watcher.rb new file mode 100644 index 0000000..6ad1d65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/jekyll-watch-2.2.1/lib/jekyll/watcher.rb @@ -0,0 +1,137 @@ +# frozen_string_literal: true + +require "listen" + +module Jekyll + module Watcher + extend self + + # Public: Continuously watch for file changes and rebuild the site + # whenever a change is detected. + # + # If the optional site argument is populated, that site instance will be + # reused and the options Hash ignored. Otherwise, a new site instance will + # be instantiated from the options Hash and used. + # + # options - A Hash containing the site configuration + # site - The current site instance (populated starting with Jekyll 3.2) + # (optional, default: nil) + # + # Returns nothing. + def watch(options, site = nil) + ENV["LISTEN_GEM_DEBUGGING"] ||= "1" if options["verbose"] + + site ||= Jekyll::Site.new(options) + listener = build_listener(site, options) + listener.start + + Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'" + + unless options["serving"] + trap("INT") do + listener.stop + Jekyll.logger.info "", "Halting auto-regeneration." + exit 0 + end + + sleep_forever + end + rescue ThreadError + # You pressed Ctrl-C, oh my! + end + + private + + def build_listener(site, options) + Listen.to( + options["source"], + :ignore => listen_ignore_paths(options), + :force_polling => options["force_polling"], + &listen_handler(site) + ) + end + + def listen_handler(site) + proc do |modified, added, removed| + t = Time.now + c = modified + added + removed + n = c.length + + Jekyll.logger.info "Regenerating:", + "#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}" + + c.each { |path| Jekyll.logger.info "", path["#{site.source}/".length..-1] } + process(site, t) + end + end + + def normalize_encoding(obj, desired_encoding) + case obj + when Array + obj.map { |entry| entry.encode!(desired_encoding, entry.encoding) } + when String + obj.encode!(desired_encoding, obj.encoding) + end + end + + def custom_excludes(options) + Array(options["exclude"]).map { |e| Jekyll.sanitized_path(options["source"], e) } + end + + def config_files(options) + %w(yml yaml toml).map do |ext| + Jekyll.sanitized_path(options["source"], "_config.#{ext}") + end + end + + def to_exclude(options) + [ + config_files(options), + options["destination"], + custom_excludes(options), + ].flatten + end + + # Paths to ignore for the watch option + # + # options - A Hash of options passed to the command + # + # Returns a list of relative paths from source that should be ignored + def listen_ignore_paths(options) + source = Pathname.new(options["source"]).expand_path + paths = to_exclude(options) + + paths.map do |p| + absolute_path = Pathname.new(normalize_encoding(p, options["source"].encoding)).expand_path + next unless absolute_path.exist? + + begin + relative_path = absolute_path.relative_path_from(source).to_s + relative_path = File.join(relative_path, "") if absolute_path.directory? + unless relative_path.start_with?("../") + path_to_ignore = %r!^#{Regexp.escape(relative_path)}! + Jekyll.logger.debug "Watcher:", "Ignoring #{path_to_ignore}" + path_to_ignore + end + rescue ArgumentError + # Could not find a relative path + end + end.compact + [%r!^\.jekyll\-metadata!] + end + + def sleep_forever + loop { sleep 1000 } + end + + def process(site, time) + begin + site.process + Jekyll.logger.info "", "...done in #{Time.now - time} seconds." + rescue StandardError => e + Jekyll.logger.warn "Error:", e.message + Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information." + end + Jekyll.logger.info "" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/AUTHORS b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/AUTHORS new file mode 100644 index 0000000..0583596 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/AUTHORS @@ -0,0 +1 @@ +The author of kramdown is Thomas Leitner . diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/CONTRIBUTERS b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/CONTRIBUTERS new file mode 100644 index 0000000..d7eba89 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/CONTRIBUTERS @@ -0,0 +1,84 @@ + Count Name +======= ==== + 964 Thomas Leitner + 18 Ashwin Maroli + 7 Christian Cornelssen + 6 Gioele Barabucci + 5 Gleb Mazovetskiy + 4 Ted Pak + 4 Shuanglei Tao + 4 Dan Allen + 4 Arne Brasseur + 3 Henning Perl + 3 gettalong + 3 Carsten Bormann + 3 Brandur + 3 Ben Armston + 3 Ashwin Maroli + 3 Alex Marandon + 2 Tom Thorogood + 2 Parker Moore + 2 Nathanael Jones + 2 Max Meyer + 2 Jo Hund + 2 Bran + 1 winniehell + 1 William + 1 Uwe Kubosch + 1 utenmiki + 1 Trevor Wennblom + 1 tomykaira + 1 tom93 + 1 Tobin Yehle + 1 timcraft + 1 Tim Blair + 1 Tim Besard + 1 Tim Bates + 1 Sun Yaozhu + 1 Stephen + 1 Stephen Crosby + 1 Stan Hu + 1 Simon Lydell + 1 Simon Coffey + 1 Shusaku NAKAZATO + 1 Sebastian Boehm + 1 scherr + 1 Postmodern + 1 Pete Michaud + 1 Noah Doersing + 1 myqlarson + 1 milo.simpson + 1 Michal Till + 1 Maxime Kjaer + 1 Matt Hickford + 1 Martyn Chamberlin + 1 Marek Tuchowski + 1 Marcus Stollsteimer + 1 Luca Barbato + 1 l3kn + 1 Kir Kolyshkin + 1 Jun Aruga + 1 Jonathan Hooper + 1 John Croisant + 1 Joe Fiorini + 1 Jens Kraemer + 1 Hirofumi Wakasugi + 1 Hector Correa + 1 Florian Klampfer + 1 Floreal Morandat florealm@gmail.com + 1 Fangyi Zhou + 1 Diego Galeota + 1 David Rodríguez + 1 Daniel Bair + 1 Damien Pollet + 1 Christopher Jefferson + 1 Cédric Boutillier + 1 Bob Lail + 1 Ashe Connor + 1 aschmitz <29508+aschmitz@users.noreply.github.com> + 1 Antoine Cotten + 1 Andrew + 1 Alpha Chen + 1 Alex Tomlins + 1 Alexey Vasiliev + 1 284km diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/COPYING b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/COPYING new file mode 100644 index 0000000..1c29282 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/COPYING @@ -0,0 +1,30 @@ +kramdown - fast, pure-Ruby Markdown-superset converter +Copyright (C) 2009-2013 Thomas Leitner + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Some test cases and the benchmark files are based on test cases from +the MDTest test suite: + + MDTest + Copyright (c) 2007 Michel Fortin + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/README.md b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/README.md new file mode 100644 index 0000000..981c004 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/README.md @@ -0,0 +1,77 @@ +# kramdown + +## Readme first! + +kramdown was originally licensed under the GPL until the 1.0.0 release. However, due to the many +requests it is now released under the MIT license and therefore can easily be used in commercial +projects, too. + +However, if you use kramdown in a commercial setting, please consider **contributing back any +changes** for the benefit of the community and/or [**becoming a +sponsor**](https://github.com/sponsors/gettalong/) or [**a +patron**](https://www.patreon.com/gettalong) - thanks! + +Sponsors: + +* **GROSSWEBER** provides software + development consulting and training services. + + +## Introduction + +kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and +supporting several common extensions. + +The syntax definition for the kramdown syntax can be found in **doc/syntax.page** (or online at +) and a quick reference is available in +**doc/quickref.page** or online at . + +The kramdown library is mainly written to support the kramdown-to-HTML conversion chain. However, +due to its flexibility (by creating an internal AST) it supports other input and output formats as +well. Here is a list of the supported formats: + +* input formats: kramdown (a Markdown superset), Markdown, GFM, HTML +* output formats: HTML, kramdown, LaTeX (and therefore PDF), PDF via Prawn + +All the documentation on the available input and output formats is available in the **doc/** +directory and online at . + +Starting from version 1.0.0 kramdown is using a versioning scheme with major, minor and patch parts +in the version number where the major number changes on backwards-incompatible changes, the minor +number on the introduction of new features and the patch number on everything else. + +For information about changes between versions, have a look at + or the commit history! + + +## Usage + +kramdown has a very simple API, so using kramdown is as easy as + +```ruby +require 'kramdown' + +Kramdown::Document.new(text).to_html +``` + +For detailed information have a look at the API documentation of the `Kramdown::Document` class. + +The full API documentation is available at , other sites with an +API documentation for kramdown probably don't provide the complete documentation! + +There are also some third-party libraries that extend the functionality of kramdown -- see the +kramdown Wiki at . + + +## Development + +Just clone the git repository as described in **doc/installation.page** and you are good to go. You +probably want to install `rake` so that you can use the provided rake tasks. + +If you want to run the tests, the development dependencies are needed as well as some additional +programs like `tidy` and `latex`. See the `.travis.yml` file for more information. + + +## License + +MIT - see the **COPYING** file. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/VERSION b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/VERSION new file mode 100644 index 0000000..197c4d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/VERSION @@ -0,0 +1 @@ +2.4.0 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/bin/kramdown b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/bin/kramdown new file mode 100755 index 0000000..e1128ab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/bin/kramdown @@ -0,0 +1,132 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'optparse' +require 'rbconfig' +require 'yaml' +require 'kramdown' + +def add_kramdown_options(opts, parsed_options, banner: [], ignore: []) + banner_shown = false + defined_options = [] + Kramdown::Options.definitions.sort.each do |n, definition| + next if ignore.include?(n) + + unless banner_shown + opts.separator("") + banner.each {|part| opts.separator(part) } + opts.separator("") + banner_shown = true + end + + defined_options << n + no = n.to_s.tr('_', '-') + if definition.type == Kramdown::Options::Boolean + opts.on("--[no-]#{no}") {|v| parsed_options[n] = Kramdown::Options.parse(n, v) } + else + type = definition.type + type = String if type == Symbol || type == Object + opts.on("--#{no} ARG", type) {|v| parsed_options[n] = Kramdown::Options.parse(n, v) } + end + + definition.desc.split(/\n/).each do |line| + opts.separator opts.summary_indent + ' ' * 6 + line + end + opts.separator '' + end + defined_options +end + +config_file = nil +begin + config_dir = case RbConfig::CONFIG['host_os'] + when /bccwin|cygwin|djgpp|mingw|mswin|wince/i + File.expand_path((ENV['HOME'] || ENV['USERPROFILE'] || "~") + "/AppData/Local") + when /darwin|mac os/ + File.expand_path("~/Library/Preferences/") + else + File.expand_path(ENV['XDG_CONFIG_HOME'] || '~/.config') + end + config_file = File.join(config_dir, "kramdownrc") +rescue StandardError +end + +options = {} +format = ['html'] + +defined_options = [] +OptionParser.new do |opts| + opts.banner = "Usage: kramdown [options] [FILE FILE ...]" + opts.summary_indent = ' ' * 4 + + opts.separator "" + opts.separator "Command line options:" + opts.separator "" + + opts.on("-i", "--input ARG", "Specify the input format: kramdown (default), " \ + "html, or markdown") {|v| options[:input] = v } + opts.on("-o", "--output ARG", Array, "Specify one or more output formats separated by commas: " \ + "html (default),", "kramdown, latex, man or remove_html_tags") {|v| format = v } + opts.on("-x", "--extension EXT", Array, "Load one or more extensions (without the 'kramdown-' " \ + "prefix) separated", "by commas (e.g. parser-gfm,syntax-coderay)", + "Note: Use this option before other options!") do |exts| + exts.each do |ext| + begin + require "kramdown-#{ext}" + new_options = add_kramdown_options(opts, options, banner: ["#{ext} options:"], + ignore: defined_options) + defined_options.concat(new_options) + rescue LoadError + $stderr.puts "Couldn't load extension #{ext}, ignoring" + end + end + end + opts.separator "" + opts.on("--no-config-file", "Do not read any configuration file. Default behavior is to check " \ + "for a", "configuration file and read it if it exists.") { config_file = nil } + opts.on("--config-file FILE", "Specify the name of a configuration file with kramdown options " \ + "in YAML", "format, e.g. \"auto_id_prefix: ARG\" instead of \"--auto-id-prefix ARG\"", + "and \"auto_ids: false\" instead of \"--no-auto-ids\".", + "Default: #{config_file}") {|v| config_file = v } + opts.separator "" + opts.on("-v", "--version", "Show the version of kramdown") do + puts Kramdown::VERSION + exit + end + opts.on("-h", "--help", "Show the help") do + puts opts.summarize('', 5, 72) + exit + end + + new_options = add_kramdown_options(opts, options, banner: ["kramdown options:"]) + defined_options.concat(new_options) +end.parse! + +begin + if config_file && File.exist?(config_file) + config_file_options = YAML.safe_load(File.read(config_file), [Symbol]) + case config_file_options + when nil # empty configuration file except perhaps YAML header and comments + # Nothing to do + when Hash + options = config_file_options.merge(options) + else + raise Kramdown::Error, "No YAML map in configuration file \"#{config_file}\"" + end + end + doc = Kramdown::Document.new(ARGF.read, options) + result = '' + format.each {|f| result = doc.send("to_#{f}") } + puts result + doc.warnings.each {|warn| $stderr.puts "Warning: #{warn}" } +rescue Kramdown::Error => e + $stderr.puts "Error: #{e.message}" + exit(1) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/data/kramdown/document.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/data/kramdown/document.html new file mode 100644 index 0000000..731d0ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/data/kramdown/document.html @@ -0,0 +1,22 @@ + + + + <% if @converter.root.options[:encoding] %> + + <% end %> +<% +extend ::Kramdown::Utils::Html +title = '' +h = @converter.root.children.find {|c| c.type == :header} +if h + collector = lambda {|c| c.children.collect {|cc| cc.type == :text ? escape_html(cc.value, :text) : collector.call(cc)}.join('')} + title = collector.call(h) +end +%> + <%= title %> + + + + <%= @body %> + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/data/kramdown/document.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/data/kramdown/document.latex new file mode 100644 index 0000000..acdf346 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/data/kramdown/document.latex @@ -0,0 +1,50 @@ +<% +encmap = { + 'UTF-8' => 'utf8x', + 'US-ASCII' => 'ascii', + 'ISO-8859-1' => 'latin1', + 'ISO-8859-2' => 'latin2', + 'ISO-8859-3' => 'latin3', + 'ISO-8859-4' => 'latin4', + 'ISO-8859-5' => 'latin5', + 'ISO-8859-9' => 'latin9', + 'ISO-8859-10' => 'latin10', + 'CP850' => 'cp850', + 'CP852' => 'cp852', + 'CP858' => 'cp858', + 'CP437' => 'cp437', + 'CP865' => 'cp865', + 'CP1250' => 'cp120', + 'CP1252' => 'cp1252', + 'CP1257' => 'cp1257' +} +%> +\documentclass{scrartcl} +<% if RUBY_VERSION >= '1.9' %> +\usepackage[<%= encmap[@body.encoding.name] %>]{inputenc} +<% else %> +\usepackage[mathletters]{ucs} +\usepackage[utf8x]{inputenc} +<% end %> +\usepackage[T1]{fontenc} +\usepackage{listings} +<% @converter.data[:packages].each {|pkg| %>\usepackage{<%= pkg %>} +<% } %> +\usepackage{hyperref} + +<% if @converter.data[:packages].include?('fancyvrb') %> +\VerbatimFootnotes +<% end %> + +<% if @converter.data[:packages].include?('acronym') %> +<% @converter.root.options[:abbrev_defs].each_pair do |k,v| %>\acrodef{<%= @converter.normalize_abbreviation_key(k) %>}[<%= k %>]{<%= @converter.escape(v) %>} +<% end %> +<% end %> + +\setcounter{footnote}{<%= @converter.options[:footnote_nr] - 1 %>} + +\hypersetup{colorlinks=true,urlcolor=blue} + +\begin{document} +<%= @body %> +\end{document} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown.rb new file mode 100644 index 0000000..3700b9d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown.rb @@ -0,0 +1,10 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/document' diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter.rb new file mode 100644 index 0000000..0055a14 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter.rb @@ -0,0 +1,68 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/utils' + +module Kramdown + + # This module contains all available converters, i.e. classes that take a root Element and convert + # it to a specific output format. The result is normally a string. For example, the + # Converter::Html module converts an element tree into valid HTML. + # + # Converters use the Base class for common functionality (like applying a template to the output) + # \- see its API documentation for how to create a custom converter class. + module Converter + + autoload :Base, 'kramdown/converter/base' + autoload :Html, 'kramdown/converter/html' + autoload :Latex, 'kramdown/converter/latex' + autoload :Kramdown, 'kramdown/converter/kramdown' + autoload :Toc, 'kramdown/converter/toc' + autoload :RemoveHtmlTags, 'kramdown/converter/remove_html_tags' + autoload :HashAST, 'kramdown/converter/hash_ast' + autoload :HashAst, 'kramdown/converter/hash_ast' + autoload :Man, 'kramdown/converter/man' + + extend ::Kramdown::Utils::Configurable + + configurable(:syntax_highlighter) + + ['Minted', "Rouge"].each do |klass_name| + kn_down = klass_name.downcase.intern + add_syntax_highlighter(kn_down) do |converter, text, lang, type, opts| + require "kramdown/converter/syntax_highlighter/#{kn_down}" + klass = ::Kramdown::Utils.deep_const_get("::Kramdown::Converter::SyntaxHighlighter::#{klass_name}") + if !klass.const_defined?(:AVAILABLE) || klass::AVAILABLE + add_syntax_highlighter(kn_down, klass) + else + add_syntax_highlighter(kn_down) { nil } + end + syntax_highlighter(kn_down).call(converter, text, lang, type, opts) + end + end + + configurable(:math_engine) + + ["Mathjax"].each do |klass_name| + kn_down = klass_name.downcase.intern + add_math_engine(kn_down) do |converter, el, opts| + require "kramdown/converter/math_engine/#{kn_down}" + klass = ::Kramdown::Utils.deep_const_get("::Kramdown::Converter::MathEngine::#{klass_name}") + if !klass.const_defined?(:AVAILABLE) || klass::AVAILABLE + add_math_engine(kn_down, klass) + else + add_math_engine(kn_down) { nil } + end + math_engine(kn_down).call(converter, el, opts) + end + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/base.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/base.rb new file mode 100644 index 0000000..66a85d6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/base.rb @@ -0,0 +1,257 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'erb' +require 'kramdown/utils' +require 'kramdown/document' + +module Kramdown + + module Converter + + # == \Base class for converters + # + # This class serves as base class for all converters. It provides methods that can/should be + # used by all converters (like #generate_id) as well as common functionality that is + # automatically applied to the result (for example, embedding the output into a template). + # + # A converter object is used as a throw-away object, i.e. it is only used for storing the needed + # state information during conversion. Therefore one can't instantiate a converter object + # directly but only use the Base::convert method. + # + # == Implementing a converter + # + # Implementing a new converter is rather easy: just derive a new class from this class and put + # it in the Kramdown::Converter module (the latter is only needed if auto-detection should work + # properly). Then you need to implement the #convert method which has to contain the conversion + # code for converting an element and has to return the conversion result. + # + # The actual transformation of the document tree can be done in any way. However, writing one + # method per element type is a straight forward way to do it - this is how the Html and Latex + # converters do the transformation. + # + # Have a look at the Base::convert method for additional information! + class Base + + # Can be used by a converter for storing arbitrary information during the conversion process. + attr_reader :data + + # The hash with the conversion options. + attr_reader :options + + # The root element that is converted. + attr_reader :root + + # The warnings array. + attr_reader :warnings + + # Initialize the converter with the given +root+ element and +options+ hash. + def initialize(root, options) + @options = options + @root = root + @data = {} + @warnings = [] + end + private_class_method(:new, :allocate) + + # Returns whether the template should be applied before the conversion of the tree. + # + # Defaults to false. + def apply_template_before? + false + end + + # Returns whether the template should be applied after the conversion of the tree. + # + # Defaults to true. + def apply_template_after? + true + end + + # Convert the element tree +tree+ and return the resulting conversion object (normally a + # string) and an array with warning messages. The parameter +options+ specifies the conversion + # options that should be used. + # + # Initializes a new instance of the calling class and then calls the #convert method with + # +tree+ as parameter. + # + # If the +template+ option is specified and non-empty, the template is evaluate with ERB + # before and/or after the tree conversion depending on the result of #apply_template_before? + # and #apply_template_after?. If the template is evaluated before, an empty string is used for + # the body; if evaluated after, the result is used as body. See ::apply_template. + # + # The template resolution is done in the following way (for the converter ConverterName): + # + # 1. Look in the current working directory for the template. + # + # 2. Append +.converter_name+ (e.g. +.html+) to the template name and look for the resulting + # file in the current working directory (the form +.convertername+ is deprecated). + # + # 3. Append +.converter_name+ to the template name and look for it in the kramdown data + # directory (the form +.convertername+ is deprecated). + # + # 4. Check if the template name starts with 'string://' and if so, strip this prefix away and + # use the rest as template. + def self.convert(tree, options = {}) + converter = new(tree, ::Kramdown::Options.merge(options.merge(tree.options[:options] || {}))) + + if !converter.options[:template].empty? && converter.apply_template_before? + apply_template(converter, '') + end + result = converter.convert(tree) + if result.respond_to?(:encode!) && result.encoding != Encoding::BINARY + result.encode!(tree.options[:encoding] || + (raise ::Kramdown::Error, "Missing encoding option on root element")) + end + if !converter.options[:template].empty? && converter.apply_template_after? + result = apply_template(converter, result) + end + + [result, converter.warnings] + end + + # Convert the element +el+ and return the resulting object. + # + # This is the only method that has to be implemented by sub-classes! + def convert(_el) + raise NotImplementedError + end + + # Apply the +template+ using +body+ as the body string. + # + # The template is evaluated using ERB and the body is available in the @body instance variable + # and the converter object in the @converter instance variable. + def self.apply_template(converter, body) # :nodoc: + erb = ERB.new(get_template(converter.options[:template])) + obj = Object.new + obj.instance_variable_set(:@converter, converter) + obj.instance_variable_set(:@body, body) + erb.result(obj.instance_eval { binding }) + end + + # Return the template specified by +template+. + def self.get_template(template) # :nodoc: + format_ext = '.' + ::Kramdown::Utils.snake_case(self.name.split(/::/).last) + shipped = File.join(::Kramdown.data_dir, template + format_ext) + if File.exist?(template) + File.read(template) + elsif File.exist?(template + format_ext) + File.read(template + format_ext) + elsif File.exist?(shipped) + File.read(shipped) + elsif template.start_with?('string://') + template.sub(/\Astring:\/\//, '') + else + raise "The specified template file #{template} does not exist" + end + end + + # Add the given warning +text+ to the warning array. + def warning(text) + @warnings << text + end + + # Return +true+ if the header element +el+ should be used for the table of contents (as + # specified by the +toc_levels+ option). + def in_toc?(el) + @options[:toc_levels].include?(el.options[:level]) && (el.attr['class'] || '') !~ /\bno_toc\b/ + end + + # Return the output header level given a level. + # + # Uses the +header_offset+ option for adjusting the header level. + def output_header_level(level) + [[level + @options[:header_offset], 6].min, 1].max + end + + # Extract the code block/span language from the attributes. + def extract_code_language(attr) + if attr['class'] && attr['class'] =~ /\blanguage-\S+/ + attr['class'].scan(/\blanguage-(\S+)/).first.first + end + end + + # See #extract_code_language + # + # *Warning*: This version will modify the given attributes if a language is present. + def extract_code_language!(attr) + lang = extract_code_language(attr) + attr['class'] = attr['class'].sub(/\blanguage-\S+/, '').strip if lang + attr.delete('class') if lang && attr['class'].empty? + lang + end + + # Highlight the given +text+ in the language +lang+ with the syntax highlighter configured + # through the option 'syntax_highlighter'. + def highlight_code(text, lang, type, opts = {}) + return nil unless @options[:syntax_highlighter] + + highlighter = ::Kramdown::Converter.syntax_highlighter(@options[:syntax_highlighter]) + if highlighter + highlighter.call(self, text, lang, type, opts) + else + warning("The configured syntax highlighter #{@options[:syntax_highlighter]} is not available.") + nil + end + end + + # Format the given math element with the math engine configured through the option + # 'math_engine'. + def format_math(el, opts = {}) + return nil unless @options[:math_engine] + + engine = ::Kramdown::Converter.math_engine(@options[:math_engine]) + if engine + engine.call(self, el, opts) + else + warning("The configured math engine #{@options[:math_engine]} is not available.") + nil + end + end + + # Generate an unique alpha-numeric ID from the the string +str+ for use as a header ID. + # + # Uses the option +auto_id_prefix+: the value of this option is prepended to every generated + # ID. + def generate_id(str) + str = ::Kramdown::Utils::Unidecoder.decode(str) if @options[:transliterated_header_ids] + gen_id = basic_generate_id(str) + gen_id = 'section' if gen_id.empty? + @used_ids ||= {} + if @used_ids.key?(gen_id) + gen_id += "-#{@used_ids[gen_id] += 1}" + else + @used_ids[gen_id] = 0 + end + @options[:auto_id_prefix] + gen_id + end + + # The basic version of the ID generator, without any special provisions for empty or unique + # IDs. + def basic_generate_id(str) + gen_id = str.gsub(/^[^a-zA-Z]+/, '') + gen_id.tr!('^a-zA-Z0-9 -', '') + gen_id.tr!(' ', '-') + gen_id.downcase! + gen_id + end + + SMART_QUOTE_INDICES = {lsquo: 0, rsquo: 1, ldquo: 2, rdquo: 3} # :nodoc: + + # Return the entity that represents the given smart_quote element. + def smart_quote_entity(el) + res = @options[:smart_quotes][SMART_QUOTE_INDICES[el.value]] + ::Kramdown::Utils::Entities.entity(res) + end + + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/hash_ast.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/hash_ast.rb new file mode 100644 index 0000000..95714d4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/hash_ast.rb @@ -0,0 +1,38 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser' +require 'kramdown/converter' +require 'kramdown/utils' + +module Kramdown + + module Converter + + # Converts a Kramdown::Document to a nested hash for further processing or debug output. + class HashAST < Base + + def convert(el) + hash = {type: el.type} + hash[:attr] = el.attr unless el.attr.empty? + hash[:value] = el.value unless el.value.nil? + hash[:options] = el.options unless el.options.empty? + unless el.children.empty? + hash[:children] = [] + el.children.each {|child| hash[:children] << convert(child) } + end + hash + end + + end + + HashAst = HashAST + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/html.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/html.rb new file mode 100644 index 0000000..ba233dc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/html.rb @@ -0,0 +1,537 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser' +require 'kramdown/converter' +require 'kramdown/utils' + +module Kramdown + + module Converter + + # Converts a Kramdown::Document to HTML. + # + # You can customize the HTML converter by sub-classing it and overriding the +convert_NAME+ + # methods. Each such method takes the following parameters: + # + # [+el+] The element of type +NAME+ to be converted. + # + # [+indent+] A number representing the current amount of spaces for indent (only used for + # block-level elements). + # + # The return value of such a method has to be a string containing the element +el+ formatted as + # HTML element. + class Html < Base + + include ::Kramdown::Utils::Html + include ::Kramdown::Parser::Html::Constants + + # The amount of indentation used when nesting HTML tags. + attr_accessor :indent + + # Initialize the HTML converter with the given Kramdown document +doc+. + def initialize(root, options) + super + @footnote_counter = @footnote_start = @options[:footnote_nr] + @footnotes = [] + @footnotes_by_name = {} + @footnote_location = nil + @toc = [] + @toc_code = nil + @indent = 2 + @stack = [] + + # stash string representation of symbol to avoid allocations from multiple interpolations. + @highlighter_class = " highlighter-#{options[:syntax_highlighter]}" + @dispatcher = Hash.new {|h, k| h[k] = :"convert_#{k}" } + end + + # Dispatch the conversion of the element +el+ to a +convert_TYPE+ method using the +type+ of + # the element. + def convert(el, indent = -@indent) + send(@dispatcher[el.type], el, indent) + end + + # Return the converted content of the children of +el+ as a string. The parameter +indent+ has + # to be the amount of indentation used for the element +el+. + # + # Pushes +el+ onto the @stack before converting the child elements and pops it from the stack + # afterwards. + def inner(el, indent) + result = +'' + indent += @indent + @stack.push(el) + el.children.each do |inner_el| + result << send(@dispatcher[inner_el.type], inner_el, indent) + end + @stack.pop + result + end + + def convert_blank(_el, _indent) + "\n" + end + + def convert_text(el, _indent) + escaped = escape_html(el.value, :text) + @options[:remove_line_breaks_for_cjk] ? fix_cjk_line_break(escaped) : escaped + end + + def convert_p(el, indent) + if el.options[:transparent] + inner(el, indent) + elsif el.children.size == 1 && el.children.first.type == :img && + el.children.first.options[:ial]&.[](:refs)&.include?('standalone') + convert_standalone_image(el, indent) + else + format_as_block_html("p", el.attr, inner(el, indent), indent) + end + end + + # Helper method used by +convert_p+ to convert a paragraph that only contains a single :img + # element. + def convert_standalone_image(el, indent) + figure_attr = el.attr.dup + image_attr = el.children.first.attr.dup + + figure_attr['class'] = image_attr.delete('class') if image_attr.key?('class') and not figure_attr.key?('class') + figure_attr['id'] = image_attr.delete('id') if image_attr.key?('id') and not figure_attr.key?('id') + + body = "#{' ' * (indent + @indent)}\n" \ + "#{' ' * (indent + @indent)}
#{image_attr['alt']}
\n" + format_as_indented_block_html("figure", figure_attr, body, indent) + end + + def convert_codeblock(el, indent) + attr = el.attr.dup + lang = extract_code_language!(attr) + hl_opts = {} + highlighted_code = highlight_code(el.value, el.options[:lang] || lang, :block, hl_opts) + + if highlighted_code + add_syntax_highlighter_to_class_attr(attr, lang || hl_opts[:default_lang]) + "#{' ' * indent}#{highlighted_code}#{' ' * indent}\n" + else + result = escape_html(el.value) + result.chomp! + if el.attr['class'].to_s =~ /\bshow-whitespaces\b/ + result.gsub!(/(?:(^[ \t]+)|([ \t]+$)|([ \t]+))/) do |m| + suffix = ($1 ? '-l' : ($2 ? '-r' : '')) + m.scan(/./).map do |c| + case c + when "\t" then "\t" + when " " then "" + end + end.join('') + end + end + code_attr = {} + code_attr['class'] = "language-#{lang}" if lang + "#{' ' * indent}" \ + "#{result}\n\n" + end + end + + def convert_blockquote(el, indent) + format_as_indented_block_html("blockquote", el.attr, inner(el, indent), indent) + end + + def convert_header(el, indent) + attr = el.attr.dup + if @options[:auto_ids] && !attr['id'] + attr['id'] = generate_id(el.options[:raw_text]) + end + @toc << [el.options[:level], attr['id'], el.children] if attr['id'] && in_toc?(el) + level = output_header_level(el.options[:level]) + format_as_block_html("h#{level}", attr, inner(el, indent), indent) + end + + def convert_hr(el, indent) + "#{' ' * indent}\n" + end + + ZERO_TO_ONETWENTYEIGHT = (0..128).to_a.freeze + private_constant :ZERO_TO_ONETWENTYEIGHT + + def convert_ul(el, indent) + if !@toc_code && el.options.dig(:ial, :refs)&.include?('toc') + @toc_code = [el.type, el.attr, ZERO_TO_ONETWENTYEIGHT.map { rand(36).to_s(36) }.join] + @toc_code.last + elsif !@footnote_location && el.options.dig(:ial, :refs)&.include?('footnotes') + @footnote_location = ZERO_TO_ONETWENTYEIGHT.map { rand(36).to_s(36) }.join + else + format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent) + end + end + alias convert_ol convert_ul + + def convert_dl(el, indent) + format_as_indented_block_html("dl", el.attr, inner(el, indent), indent) + end + + def convert_li(el, indent) + output = ' ' * indent << "<#{el.type}" << html_attributes(el.attr) << ">" + res = inner(el, indent) + if el.children.empty? || (el.children.first.type == :p && el.children.first.options[:transparent]) + output << res << (res =~ /\n\Z/ ? ' ' * indent : '') + else + output << "\n" << res << ' ' * indent + end + output << "\n" + end + alias convert_dd convert_li + + def convert_dt(el, indent) + attr = el.attr.dup + @stack.last.options[:ial][:refs].each do |ref| + if ref =~ /\Aauto_ids(?:-([\w-]+))?/ + attr['id'] = "#{$1}#{basic_generate_id(el.options[:raw_text])}".lstrip + break + end + end if !attr['id'] && @stack.last.options[:ial] && @stack.last.options[:ial][:refs] + format_as_block_html("dt", attr, inner(el, indent), indent) + end + + def convert_html_element(el, indent) + res = inner(el, indent) + if el.options[:category] == :span + "<#{el.value}#{html_attributes(el.attr)}" + \ + (res.empty? && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value) ? " />" : ">#{res}") + else + output = +'' + if @stack.last.type != :html_element || @stack.last.options[:content_model] != :raw + output << ' ' * indent + end + output << "<#{el.value}#{html_attributes(el.attr)}" + if el.options[:is_closed] && el.options[:content_model] == :raw + output << " />" + elsif !res.empty? && el.options[:content_model] != :block + output << ">#{res}" + elsif !res.empty? + output << ">\n#{res.chomp}\n" << ' ' * indent << "" + elsif HTML_ELEMENTS_WITHOUT_BODY.include?(el.value) + output << " />" + else + output << ">" + end + output << "\n" if @stack.last.type != :html_element || @stack.last.options[:content_model] != :raw + output + end + end + + def convert_xml_comment(el, indent) + if el.options[:category] == :block && + (@stack.last.type != :html_element || @stack.last.options[:content_model] != :raw) + ' ' * indent << el.value << "\n" + else + el.value + end + end + alias convert_xml_pi convert_xml_comment + + def convert_table(el, indent) + format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent) + end + alias convert_thead convert_table + alias convert_tbody convert_table + alias convert_tfoot convert_table + alias convert_tr convert_table + + ENTITY_NBSP = ::Kramdown::Utils::Entities.entity('nbsp') # :nodoc: + + def convert_td(el, indent) + res = inner(el, indent) + type = (@stack[-2].type == :thead ? :th : :td) + attr = el.attr + alignment = @stack[-3].options[:alignment][@stack.last.children.index(el)] + if alignment != :default + attr = el.attr.dup + attr['style'] = (attr.key?('style') ? "#{attr['style']}; " : '') + "text-align: #{alignment}" + end + format_as_block_html(type, attr, res.empty? ? entity_to_str(ENTITY_NBSP) : res, indent) + end + + def convert_comment(el, indent) + if el.options[:category] == :block + "#{' ' * indent}\n" + else + "" + end + end + + def convert_br(_el, _indent) + "
" + end + + def convert_a(el, indent) + format_as_span_html("a", el.attr, inner(el, indent)) + end + + def convert_img(el, _indent) + "" + end + + def convert_codespan(el, _indent) + attr = el.attr.dup + lang = extract_code_language(attr) + hl_opts = {} + result = highlight_code(el.value, lang, :span, hl_opts) + if result + add_syntax_highlighter_to_class_attr(attr, lang || hl_opts[:default_lang]) + else + result = escape_html(el.value) + end + + format_as_span_html('code', attr, result) + end + + def convert_footnote(el, _indent) + repeat = '' + name = @options[:footnote_prefix] + el.options[:name] + if (footnote = @footnotes_by_name[name]) + number = footnote[2] + repeat = ":#{footnote[3] += 1}" + else + number = @footnote_counter + @footnote_counter += 1 + @footnotes << [name, el.value, number, 0] + @footnotes_by_name[name] = @footnotes.last + end + "" \ + "" \ + "#{number}" + end + + def convert_raw(el, _indent) + if !el.options[:type] || el.options[:type].empty? || el.options[:type].include?('html') + el.value + (el.options[:category] == :block ? "\n" : '') + else + '' + end + end + + def convert_em(el, indent) + format_as_span_html(el.type, el.attr, inner(el, indent)) + end + alias convert_strong convert_em + + def convert_entity(el, _indent) + entity_to_str(el.value, el.options[:original]) + end + + TYPOGRAPHIC_SYMS = { + mdash: [::Kramdown::Utils::Entities.entity('mdash')], + ndash: [::Kramdown::Utils::Entities.entity('ndash')], + hellip: [::Kramdown::Utils::Entities.entity('hellip')], + laquo_space: [::Kramdown::Utils::Entities.entity('laquo'), + ::Kramdown::Utils::Entities.entity('nbsp')], + raquo_space: [::Kramdown::Utils::Entities.entity('nbsp'), + ::Kramdown::Utils::Entities.entity('raquo')], + laquo: [::Kramdown::Utils::Entities.entity('laquo')], + raquo: [::Kramdown::Utils::Entities.entity('raquo')], + } # :nodoc: + def convert_typographic_sym(el, _indent) + if (result = @options[:typographic_symbols][el.value]) + escape_html(result, :text) + else + TYPOGRAPHIC_SYMS[el.value].map {|e| entity_to_str(e) }.join('') + end + end + + def convert_smart_quote(el, _indent) + entity_to_str(smart_quote_entity(el)) + end + + def convert_math(el, indent) + if (result = format_math(el, indent: indent)) + result + else + attr = el.attr.dup + attr['class'] = "#{attr['class']} kdmath".lstrip + if el.options[:category] == :block + format_as_block_html('div', attr, "$$\n#{el.value}\n$$", indent) + else + format_as_span_html('span', attr, "$#{el.value}$") + end + end + end + + def convert_abbreviation(el, _indent) + title = @root.options[:abbrev_defs][el.value] + attr = @root.options[:abbrev_attr][el.value].dup + attr['title'] = title unless title.empty? + format_as_span_html("abbr", attr, el.value) + end + + def convert_root(el, indent) + result = inner(el, indent) + if @footnote_location + result.sub!(/#{@footnote_location}/, footnote_content.gsub(/\\/, "\\\\\\\\")) + else + result << footnote_content + end + if @toc_code + toc_tree = generate_toc_tree(@toc, @toc_code[0], @toc_code[1] || {}) + text = if !toc_tree.children.empty? + convert(toc_tree, 0) + else + '' + end + result.sub!(/#{@toc_code.last}/, text.gsub(/\\/, "\\\\\\\\")) + end + result + end + + # Format the given element as span HTML. + def format_as_span_html(name, attr, body) + "<#{name}#{html_attributes(attr)}>#{body}" + end + + # Format the given element as block HTML. + def format_as_block_html(name, attr, body, indent) + "#{' ' * indent}<#{name}#{html_attributes(attr)}>#{body}\n" + end + + # Format the given element as block HTML with a newline after the start tag and indentation + # before the end tag. + def format_as_indented_block_html(name, attr, body, indent) + "#{' ' * indent}<#{name}#{html_attributes(attr)}>\n#{body}#{' ' * indent}\n" + end + + # Add the syntax highlighter name to the 'class' attribute of the given attribute hash. And + # overwrites or add a "language-LANG" part using the +lang+ parameter if +lang+ is not nil. + def add_syntax_highlighter_to_class_attr(attr, lang = nil) + (attr['class'] = (attr['class'] || '') + @highlighter_class).lstrip! + attr['class'].sub!(/\blanguage-\S+|(^)/) { "language-#{lang}#{$1 ? ' ' : ''}" } if lang + end + + # Generate and return an element tree for the table of contents. + def generate_toc_tree(toc, type, attr) + sections = Element.new(type, nil, attr.dup) + sections.attr['id'] ||= 'markdown-toc' + stack = [] + toc.each do |level, id, children| + li = Element.new(:li, nil, nil, level: level) + li.children << Element.new(:p, nil, nil, transparent: true) + a = Element.new(:a, nil) + a.attr['href'] = "##{id}" + a.attr['id'] = "#{sections.attr['id']}-#{id}" + a.children.concat(fix_for_toc_entry(Marshal.load(Marshal.dump(children)))) + li.children.last.children << a + li.children << Element.new(type) + + success = false + until success + if stack.empty? + sections.children << li + stack << li + success = true + elsif stack.last.options[:level] < li.options[:level] + stack.last.children.last.children << li + stack << li + success = true + else + item = stack.pop + item.children.pop if item.children.last.children.empty? + end + end + end + until stack.empty? + item = stack.pop + item.children.pop if item.children.last.children.empty? + end + sections + end + + # Fixes the elements for use in a TOC entry. + def fix_for_toc_entry(elements) + remove_footnotes(elements) + unwrap_links(elements) + elements + end + + # Remove all link elements by unwrapping them. + def unwrap_links(elements) + elements.map! do |c| + unwrap_links(c.children) + c.type == :a ? c.children : c + end.flatten! + end + + # Remove all footnotes from the given elements. + def remove_footnotes(elements) + elements.delete_if do |c| + remove_footnotes(c.children) + c.type == :footnote + end + end + + # Obfuscate the +text+ by using HTML entities. + def obfuscate(text) + result = +'' + text.each_byte do |b| + result << (b > 128 ? b.chr : sprintf("&#%03d;", b)) + end + result.force_encoding(text.encoding) + result + end + + FOOTNOTE_BACKLINK_FMT = "%s%s" + + # Return an HTML ordered list with the footnote content for the used footnotes. + def footnote_content + ol = Element.new(:ol) + ol.attr['start'] = @footnote_start if @footnote_start != 1 + i = 0 + backlink_text = escape_html(@options[:footnote_backlink], :text) + while i < @footnotes.length + name, data, _, repeat = *@footnotes[i] + li = Element.new(:li, nil, 'id' => "fn:#{name}", 'role' => 'doc-endnote') + li.children = Marshal.load(Marshal.dump(data.children)) + + para = nil + if li.children.last.type == :p || @options[:footnote_backlink_inline] + parent = li + while !parent.children.empty? && ![:p, :header].include?(parent.children.last.type) + parent = parent.children.last + end + para = parent.children.last + insert_space = true + end + + unless para + li.children << (para = Element.new(:p)) + insert_space = false + end + + unless @options[:footnote_backlink].empty? + nbsp = entity_to_str(ENTITY_NBSP) + value = sprintf(FOOTNOTE_BACKLINK_FMT, (insert_space ? nbsp : ''), name, backlink_text) + para.children << Element.new(:raw, value) + (1..repeat).each do |index| + value = sprintf(FOOTNOTE_BACKLINK_FMT, nbsp, "#{name}:#{index}", + "#{backlink_text}#{index + 1}") + para.children << Element.new(:raw, value) + end + end + + ol.children << Element.new(:raw, convert(li, 4)) + i += 1 + end + if ol.children.empty? + '' + else + format_as_indented_block_html('div', {class: "footnotes", role: "doc-endnotes"}, convert(ol, 2), 0) + end + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/kramdown.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/kramdown.rb new file mode 100644 index 0000000..32e0c2d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/kramdown.rb @@ -0,0 +1,453 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/converter' +require 'kramdown/utils' + +module Kramdown + + module Converter + + # Converts an element tree to the kramdown format. + class Kramdown < Base + + # :stopdoc: + + include ::Kramdown::Utils::Html + + def initialize(root, options) + super + @linkrefs = [] + @footnotes = [] + @abbrevs = [] + @stack = [] + @list_indent = @options[:list_indent] + @list_spacing = ' ' * (@list_indent - 2) + end + + def convert(el, opts = {indent: 0}) + res = send("convert_#{el.type}", el, opts) + res = res.dup if res.frozen? + if ![:html_element, :li, :dt, :dd, :td].include?(el.type) && (ial = ial_for_element(el)) + res << ial + res << "\n\n" if el.block? + elsif [:ul, :dl, :ol, :codeblock].include?(el.type) && opts[:next] && + ([el.type, :codeblock].include?(opts[:next].type) || + (opts[:next].type == :blank && opts[:nnext] && + [el.type, :codeblock].include?(opts[:nnext].type))) + res << "^\n\n" + elsif el.block? && + ![:li, :dd, :dt, :td, :th, :tr, :thead, :tbody, :tfoot, :blank].include?(el.type) && + (el.type != :html_element || @stack.last.type != :html_element) && + (el.type != :p || !el.options[:transparent]) + res << "\n" + end + res + end + + def inner(el, opts = {indent: 0}) + @stack.push(el) + result = +'' + el.children.each_with_index do |inner_el, index| + options = opts.dup + options[:index] = index + options[:prev] = (index == 0 ? nil : el.children[index - 1]) + options[:pprev] = (index <= 1 ? nil : el.children[index - 2]) + options[:next] = (index == el.children.length - 1 ? nil : el.children[index + 1]) + options[:nnext] = (index >= el.children.length - 2 ? nil : el.children[index + 2]) + result << convert(inner_el, options) + end + @stack.pop + result + end + + def convert_blank(_el, _opts) + "" + end + + ESCAPED_CHAR_RE = /(\$\$|[\\*_`\[\]\{"'|])|^[ ]{0,3}(:)/ + + def convert_text(el, opts) + if opts[:raw_text] + el.value + else + el.value.gsub(/\A\n/) do + opts[:prev] && opts[:prev].type == :br ? '' : "\n" + end.gsub(/\s+/, ' ').gsub(ESCAPED_CHAR_RE) do + $1 || !opts[:prev] || opts[:prev].type == :br ? "\\#{$1 || $2}" : $& + end + end + end + + def convert_p(el, opts) + w = @options[:line_width] - opts[:indent].to_s.to_i + first, second, *rest = inner(el, opts).strip.gsub(/(.{1,#{w}})( +|$\n?)/, "\\1\n").split(/\n/) + first&.gsub!(/^(?:(#|>)|(\d+)\.|([+-]\s))/) { $1 || $3 ? "\\#{$1 || $3}" : "#{$2}\\." } + second&.gsub!(/^([=-]+\s*?)$/, "\\\1") + res = [first, second, *rest].compact.join("\n") + "\n" + res.gsub!(/^[ ]{0,3}:/, "\\:") + if el.children.length == 1 && el.children.first.type == :math + res = "\\#{res}" + elsif res.start_with?('\$$') && res.end_with?("\\$$\n") + res.sub!(/^\\\$\$/, '\$\$') + end + res + end + + def convert_codeblock(el, _opts) + el.value.split(/\n/).map {|l| l.empty? ? " " : " #{l}" }.join("\n") + "\n" + end + + def convert_blockquote(el, opts) + opts[:indent] += 2 + inner(el, opts).chomp.split(/\n/).map {|l| "> #{l}" }.join("\n") << "\n" + end + + def convert_header(el, opts) + res = +'' + res << "#{'#' * output_header_level(el.options[:level])} #{inner(el, opts)}" + res[-1, 1] = "\\#" if res[-1] == '#' + res << " {##{el.attr['id']}}" if el.attr['id'] && !el.attr['id'].strip.empty? + res << "\n" + end + + def convert_hr(_el, _opts) + "* * *\n" + end + + def convert_ul(el, opts) + inner(el, opts).sub(/\n+\Z/, "\n") + end + alias convert_ol convert_ul + alias convert_dl convert_ul + + def convert_li(el, opts) + sym, width = if @stack.last.type == :ul + ['* ' + @list_spacing, el.children.first && el.children.first.type == :codeblock ? 4 : @list_indent] + else + ["#{opts[:index] + 1}.".ljust(4), 4] + end + if (ial = ial_for_element(el)) + sym << ial << " " + end + + opts[:indent] += width + text = inner(el, opts) + newlines = text.scan(/\n*\Z/).first + first, *last = text.split(/\n/) + last = last.map {|l| " " * width + l }.join("\n") + text = (first.nil? ? "\n" : first + (last.empty? ? "" : "\n") + last + newlines) + if el.children.first && el.children.first.type == :p && !el.children.first.options[:transparent] + res = +"#{sym}#{text}" + res << "^\n" if el.children.size == 1 && @stack.last.children.last == el && + (@stack.last.children.any? {|c| c.children.first.type != :p } || @stack.last.children.size == 1) + res + elsif el.children.first && el.children.first.type == :codeblock + "#{sym}\n #{text}" + else + "#{sym}#{text}" + end + end + + def convert_dd(el, opts) + sym, width = ": " + @list_spacing, (el.children.first && el.children.first.type == :codeblock ? 4 : @list_indent) + if (ial = ial_for_element(el)) + sym << ial << " " + end + + opts[:indent] += width + text = inner(el, opts) + newlines = text.scan(/\n*\Z/).first + first, *last = text.split(/\n/) + last = last.map {|l| " " * width + l }.join("\n") + text = first.to_s + (last.empty? ? "" : "\n") + last + newlines + text.chomp! if text =~ /\n\n\Z/ && opts[:next] && opts[:next].type == :dd + text << "\n" if text !~ /\n\n\Z/ && opts[:next] && opts[:next].type == :dt + text << "\n" if el.children.empty? + if el.children.first && el.children.first.type == :p && !el.children.first.options[:transparent] + "\n#{sym}#{text}" + elsif el.children.first && el.children.first.type == :codeblock + "#{sym}\n #{text}" + else + "#{sym}#{text}" + end + end + + def convert_dt(el, opts) + result = +'' + if (ial = ial_for_element(el)) + result << ial << " " + end + result << inner(el, opts) << "\n" + end + + HTML_TAGS_WITH_BODY = ['div', 'script', 'iframe', 'textarea', 'th', 'td'] + + HTML_ELEMENT_TYPES = [:entity, :text, :html_element].freeze + private_constant :HTML_ELEMENT_TYPES + + def convert_html_element(el, opts) + markdown_attr = el.options[:category] == :block && el.children.any? do |c| + c.type != :html_element && + (c.type != :p || !c.options[:transparent] || + c.children.any? {|t| !HTML_ELEMENT_TYPES.member?(t.type) }) && + c.block? + end + opts[:force_raw_text] = true if %w[script pre code].include?(el.value) + opts[:raw_text] = opts[:force_raw_text] || opts[:block_raw_text] || \ + (el.options[:category] != :span && !markdown_attr) + opts[:block_raw_text] = true if el.options[:category] == :block && opts[:raw_text] + res = inner(el, opts) + if el.options[:category] == :span + "<#{el.value}#{html_attributes(el.attr)}" + \ + (!res.empty? || HTML_TAGS_WITH_BODY.include?(el.value) ? ">#{res}" : " />") + else + output = +'' + attr = el.attr.dup + attr['markdown'] = '1' if markdown_attr + output << "<#{el.value}#{html_attributes(attr)}" + if !res.empty? && el.options[:content_model] != :block + output << ">#{res}" + elsif !res.empty? + output << ">\n#{res}" << "" + elsif HTML_TAGS_WITH_BODY.include?(el.value) + output << ">" + else + output << " />" + end + output << "\n" if @stack.last.type != :html_element || @stack.last.options[:content_model] != :raw + output + end + end + + def convert_xml_comment(el, _opts) + if el.options[:category] == :block && + (@stack.last.type != :html_element || @stack.last.options[:content_model] != :raw) + el.value + "\n" + else + el.value.dup + end + end + alias convert_xml_pi convert_xml_comment + + def convert_table(el, opts) + opts[:alignment] = el.options[:alignment] + inner(el, opts) + end + + def convert_thead(el, opts) + rows = inner(el, opts) + if opts[:alignment].all? {|a| a == :default } + "#{rows}|#{'-' * 10}\n" + else + "#{rows}| " + opts[:alignment].map do |a| + case a + when :left then ":-" + when :right then "-:" + when :center then ":-:" + when :default then "-" + end + end.join(' ') << "\n" + end + end + + def convert_tbody(el, opts) + res = +'' + res << inner(el, opts) + res << '|' << '-' * 10 << "\n" if opts[:next] && opts[:next].type == :tbody + res + end + + def convert_tfoot(el, opts) + "|#{'=' * 10}\n#{inner(el, opts)}" + end + + def convert_tr(el, opts) + "| #{el.children.map {|c| convert(c, opts) }.join(' | ')} |\n" + end + + def convert_td(el, opts) + inner(el, opts) + end + + def convert_comment(el, _opts) + if el.options[:category] == :block + "{::comment}\n#{el.value}\n{:/}\n" + else + "{::comment}#{el.value}{:/}" + end + end + + def convert_br(_el, _opts) + " \n" + end + + def convert_a(el, opts) + if el.attr['href'].empty? + "[#{inner(el, opts)}]()" + elsif el.attr['href'] =~ /^(?:http|ftp)/ || el.attr['href'].count("()") > 0 + index = if (link_el = @linkrefs.find {|c| c.attr['href'] == el.attr['href'] }) + @linkrefs.index(link_el) + 1 + else + @linkrefs << el + @linkrefs.size + end + "[#{inner(el, opts)}][#{index}]" + else + title = parse_title(el.attr['title']) + "[#{inner(el, opts)}](#{el.attr['href']}#{title})" + end + end + + def convert_img(el, _opts) + alt_text = el.attr['alt'].to_s.gsub(ESCAPED_CHAR_RE) { $1 ? "\\#{$1}" : $2 } + src = el.attr['src'].to_s + if src.empty? + "![#{alt_text}]()" + else + title = parse_title(el.attr['title']) + link = if src.count("()") > 0 + "<#{src}>" + else + src + end + "![#{alt_text}](#{link}#{title})" + end + end + + def convert_codespan(el, _opts) + delim = (el.value.scan(/`+/).max || '') + '`' + "#{delim}#{' ' if delim.size > 1}#{el.value}#{' ' if delim.size > 1}#{delim}" + end + + def convert_footnote(el, _opts) + @footnotes << [el.options[:name], el.value] + "[^#{el.options[:name]}]" + end + + def convert_raw(el, _opts) + attr = (el.options[:type] || []).join(' ') + attr = " type=\"#{attr}\"" unless attr.empty? + if @stack.last.type == :html_element + el.value + elsif el.options[:category] == :block + "{::nomarkdown#{attr}}\n#{el.value}\n{:/}\n" + else + "{::nomarkdown#{attr}}#{el.value}{:/}" + end + end + + def convert_em(el, opts) + "*#{inner(el, opts)}*" + + (opts[:next] && [:em, :strong].include?(opts[:next].type) && !ial_for_element(el) ? '{::}' : '') + end + + def convert_strong(el, opts) + "**#{inner(el, opts)}**" + + (opts[:next] && [:em, :strong].include?(opts[:next].type) && !ial_for_element(el) ? '{::}' : '') + end + + def convert_entity(el, _opts) + entity_to_str(el.value, el.options[:original]) + end + + TYPOGRAPHIC_SYMS = { + mdash: '---', ndash: '--', hellip: '...', + laquo_space: '<< ', raquo_space: ' >>', + laquo: '<<', raquo: '>>' + } + def convert_typographic_sym(el, _opts) + TYPOGRAPHIC_SYMS[el.value] + end + + def convert_smart_quote(el, _opts) + el.value.to_s =~ /[rl]dquo/ ? "\"" : "'" + end + + def convert_math(el, _opts) + "$$#{el.value}$$" + (el.options[:category] == :block ? "\n" : '') + end + + def convert_abbreviation(el, _opts) + el.value + end + + def convert_root(el, opts) + res = inner(el, opts) + res << create_link_defs + res << create_footnote_defs + res << create_abbrev_defs + res + end + + def create_link_defs + res = +'' + res << "\n\n" unless @linkrefs.empty? + @linkrefs.each_with_index do |el, i| + title = parse_title(el.attr['title']) + res << "[#{i + 1}]: #{el.attr['href']}#{title}\n" + end + res + end + + def create_footnote_defs + res = +'' + @footnotes.each do |name, data| + res << "[^#{name}]:\n" + res << inner(data).chomp.split(/\n/).map {|l| " #{l}" }.join("\n") + "\n\n" + end + res + end + + def create_abbrev_defs + return '' unless @root.options[:abbrev_defs] + res = +'' + @root.options[:abbrev_defs].each do |name, text| + res << "*[#{name}]: #{text}\n" + res << ial_for_element(Element.new(:unused, nil, @root.options[:abbrev_attr][name])).to_s << "\n\n" + end + res + end + + # Return the IAL containing the attributes of the element +el+. + def ial_for_element(el) + res = el.attr.map do |k, v| + next if [:img, :a].include?(el.type) && ['href', 'src', 'alt', 'title'].include?(k) + next if el.type == :header && k == 'id' && !v.strip.empty? + if v.nil? + '' + elsif k == 'class' && !v.empty? && !v.index(/[\.#]/) + " " + v.split(/\s+/).map {|w| ".#{w}" }.join(" ") + elsif k == 'id' && !v.strip.empty? + " ##{v}" + else + " #{k}=\"#{v}\"" + end + end.compact.join('') + res = "toc" + (res.strip.empty? ? '' : " #{res}") if (el.type == :ul || el.type == :ol) && + el.options.dig(:ial, :refs)&.include?('toc') + res = "footnotes" + (res.strip.empty? ? '' : " #{res}") if (el.type == :ul || el.type == :ol) && + el.options.dig(:ial, :refs)&.include?('footnotes') + if el.type == :dl && el.options[:ial] && el.options[:ial][:refs] + auto_ids = el.options[:ial][:refs].select {|ref| ref.start_with?('auto_ids') }.join(" ") + res = auto_ids << (res.strip.empty? ? '' : " #{res}") unless auto_ids.empty? + end + res.strip.empty? ? nil : "{:#{res}}" + end + + def parse_title(attr) + attr.to_s.empty? ? '' : ' "' + attr.gsub(/"/, '"') + '"' + end + + # :startdoc: + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/latex.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/latex.rb new file mode 100644 index 0000000..25124d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/latex.rb @@ -0,0 +1,625 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'set' +require 'kramdown/converter' + +module Kramdown + + module Converter + + # Converts an element tree to LaTeX. + # + # This converter uses ideas from other Markdown-to-LaTeX converters like Pandoc and Maruku. + # + # You can customize this converter by sub-classing it and overriding the +convert_NAME+ methods. + # Each such method takes the following parameters: + # + # [+el+] The element of type +NAME+ to be converted. + # + # [+opts+] A hash containing processing options that are passed down from parent elements. The + # key :parent is always set and contains the parent element as value. + # + # The return value of such a method has to be a string containing the element +el+ formatted + # correctly as LaTeX markup. + class Latex < Base + + # Initialize the LaTeX converter with the +root+ element and the conversion +options+. + def initialize(root, options) + super + @data[:packages] = Set.new + end + + # Dispatch the conversion of the element +el+ to a +convert_TYPE+ method using the +type+ of + # the element. + def convert(el, opts = {}) + send("convert_#{el.type}", el, opts) + end + + # Return the converted content of the children of +el+ as a string. + def inner(el, opts) + result = +'' + options = opts.dup.merge(parent: el) + el.children.each_with_index do |inner_el, index| + options[:index] = index + options[:result] = result + result << send("convert_#{inner_el.type}", inner_el, options) + end + result + end + + def convert_root(el, opts) + inner(el, opts) + end + + def convert_blank(_el, opts) + opts[:result] =~ /\n\n\Z|\A\Z/ ? "" : "\n" + end + + def convert_text(el, _opts) + escape(el.value) + end + + def convert_p(el, opts) + if el.children.size == 1 && el.children.first.type == :img && + !(img = convert_img(el.children.first, opts)).empty? + convert_standalone_image(el, opts, img) + else + "#{latex_link_target(el)}#{inner(el, opts)}\n\n" + end + end + + # Helper method used by +convert_p+ to convert a paragraph that only contains a single :img + # element. + def convert_standalone_image(el, _opts, img) + attrs = attribute_list(el) + "\\begin{figure}#{attrs}\n\\begin{center}\n#{img}\n\\end{center}\n" \ + "\\caption{#{escape(el.children.first.attr['alt'])}}\n" \ + "#{latex_link_target(el, true)}\n\\end{figure}#{attrs}\n" + end + + def convert_codeblock(el, _opts) + show_whitespace = el.attr['class'].to_s =~ /\bshow-whitespaces\b/ + lang = extract_code_language(el.attr) + + if @options[:syntax_highlighter] == :minted && + (highlighted_code = highlight_code(el.value, lang, :block)) + @data[:packages] << 'minted' + "#{latex_link_target(el)}#{highlighted_code}\n" + elsif show_whitespace || lang + options = [] + options << (show_whitespace ? "showspaces=true,showtabs=true" : "showspaces=false,showtabs=false") + options << "language=#{lang}" if lang + options << "basicstyle=\\ttfamily\\footnotesize,columns=fixed,frame=tlbr" + id = el.attr['id'] + options << "label=#{id}" if id + attrs = attribute_list(el) + "#{latex_link_target(el)}\\begin{lstlisting}[#{options.join(',')}]\n" \ + "#{el.value}\n\\end{lstlisting}#{attrs}\n" + else + "#{latex_link_target(el)}\\begin{verbatim}#{el.value}\\end{verbatim}\n" + end + end + + def convert_blockquote(el, opts) + latex_environment(el.children.size > 1 ? 'quotation' : 'quote', el, inner(el, opts)) + end + + def convert_header(el, opts) + type = @options[:latex_headers][output_header_level(el.options[:level]) - 1] + if ((id = el.attr['id']) || + (@options[:auto_ids] && (id = generate_id(el.options[:raw_text])))) && in_toc?(el) + "\\#{type}{#{inner(el, opts)}}\\hypertarget{#{id}}{}\\label{#{id}}\n\n" + else + "\\#{type}*{#{inner(el, opts)}}\n\n" + end + end + + def convert_hr(el, _opts) + attrs = attribute_list(el) + "#{latex_link_target(el)}\\begin{center}#{attrs}\n\\rule{3in}{0.4pt}\n\\end{center}#{attrs}\n" + end + + def convert_ul(el, opts) + if !@data[:has_toc] && el.options.dig(:ial, :refs)&.include?('toc') + @data[:has_toc] = true + '\tableofcontents' + else + latex_environment(el.type == :ul ? 'itemize' : 'enumerate', el, inner(el, opts)) + end + end + alias convert_ol convert_ul + + def convert_dl(el, opts) + latex_environment('description', el, inner(el, opts)) + end + + def convert_li(el, opts) + "\\item{} #{latex_link_target(el, true)}#{inner(el, opts).sub(/\n+\Z/, '')}\n" + end + + def convert_dt(el, opts) + "\\item[#{inner(el, opts)}] " + end + + def convert_dd(el, opts) + "#{latex_link_target(el)}#{inner(el, opts)}\n\n" + end + + def convert_html_element(el, opts) + if el.value == 'i' || el.value == 'em' + "\\emph{#{inner(el, opts)}}" + elsif el.value == 'b' || el.value == 'strong' + "\\textbf{#{inner(el, opts)}}" + else + warning("Can't convert HTML element") + '' + end + end + + def convert_xml_comment(el, _opts) + el.value.split(/\n/).map {|l| "% #{l}" }.join("\n") + "\n" + end + + def convert_xml_pi(_el, _opts) + warning("Can't convert XML PI") + '' + end + + TABLE_ALIGNMENT_CHAR = {default: 'l', left: 'l', center: 'c', right: 'r'} # :nodoc: + + def convert_table(el, opts) + @data[:packages] << 'longtable' + align = el.options[:alignment].map {|a| TABLE_ALIGNMENT_CHAR[a] }.join('|') + attrs = attribute_list(el) + "#{latex_link_target(el)}\\begin{longtable}{|#{align}|}#{attrs}\n" \ + "\\hline\n#{inner(el, opts)}\\hline\n\\end{longtable}#{attrs}\n\n" + end + + def convert_thead(el, opts) + "#{inner(el, opts)}\\hline\n" + end + + def convert_tbody(el, opts) + inner(el, opts) + end + + def convert_tfoot(el, opts) + "\\hline \\hline \n#{inner(el, opts)}" + end + + def convert_tr(el, opts) + el.children.map {|c| send("convert_#{c.type}", c, opts) }.join(' & ') << "\\\\\n" + end + + def convert_td(el, opts) + inner(el, opts) + end + + def convert_comment(el, _opts) + el.value.split(/\n/).map {|l| "% #{l}" }.join("\n") << "\n" + end + + def convert_br(_el, opts) + res = +"\\newline" + res << "\n" if (c = opts[:parent].children[opts[:index] + 1]) && + (c.type != :text || c.value !~ /^\s*\n/) + res + end + + def convert_a(el, opts) + url = el.attr['href'] + if url.start_with?('#') + "\\hyperlink{#{url[1..-1].gsub('%', '\\%')}}{#{inner(el, opts)}}" + else + "\\href{#{url.gsub('%', '\\%')}}{#{inner(el, opts)}}" + end + end + + def convert_img(el, _opts) + line = el.options[:location] + if el.attr['src'] =~ /^(https?|ftps?):\/\// + warning("Cannot include non-local image#{line ? " (line #{line})" : ''}") + '' + elsif !el.attr['src'].empty? + @data[:packages] << 'graphicx' + "#{latex_link_target(el)}\\includegraphics{#{el.attr['src']}}" + else + warning("Cannot include image with empty path#{line ? " (line #{line})" : ''}") + '' + end + end + + def convert_codespan(el, _opts) + lang = extract_code_language(el.attr) + if @options[:syntax_highlighter] == :minted && + (highlighted_code = highlight_code(el.value, lang, :span)) + @data[:packages] << 'minted' + "#{latex_link_target(el)}#{highlighted_code}" + else + "\\texttt{#{latex_link_target(el)}#{escape(el.value)}}" + end + end + + def convert_footnote(el, opts) + @data[:packages] << 'fancyvrb' + "\\footnote{#{inner(el.value, opts).rstrip}}" + end + + def convert_raw(el, _opts) + if !el.options[:type] || el.options[:type].empty? || el.options[:type].include?('latex') + el.value + (el.options[:category] == :block ? "\n" : '') + else + '' + end + end + + def convert_em(el, opts) + "\\emph{#{latex_link_target(el)}#{inner(el, opts)}}" + end + + def convert_strong(el, opts) + "\\textbf{#{latex_link_target(el)}#{inner(el, opts)}}" + end + + # Inspired by Maruku: entity conversion table based on the one from htmltolatex + # (http://sourceforge.net/projects/htmltolatex/), with some small adjustments/additions + ENTITY_CONV_TABLE = { + 913 => ['$A$'], + 914 => ['$B$'], + 915 => ['$\Gamma$'], + 916 => ['$\Delta$'], + 917 => ['$E$'], + 918 => ['$Z$'], + 919 => ['$H$'], + 920 => ['$\Theta$'], + 921 => ['$I$'], + 922 => ['$K$'], + 923 => ['$\Lambda$'], + 924 => ['$M$'], + 925 => ['$N$'], + 926 => ['$\Xi$'], + 927 => ['$O$'], + 928 => ['$\Pi$'], + 929 => ['$P$'], + 931 => ['$\Sigma$'], + 932 => ['$T$'], + 933 => ['$Y$'], + 934 => ['$\Phi$'], + 935 => ['$X$'], + 936 => ['$\Psi$'], + 937 => ['$\Omega$'], + 945 => ['$\alpha$'], + 946 => ['$\beta$'], + 947 => ['$\gamma$'], + 948 => ['$\delta$'], + 949 => ['$\epsilon$'], + 950 => ['$\zeta$'], + 951 => ['$\eta$'], + 952 => ['$\theta$'], + 953 => ['$\iota$'], + 954 => ['$\kappa$'], + 955 => ['$\lambda$'], + 956 => ['$\mu$'], + 957 => ['$\nu$'], + 958 => ['$\xi$'], + 959 => ['$o$'], + 960 => ['$\pi$'], + 961 => ['$\rho$'], + 963 => ['$\sigma$'], + 964 => ['$\tau$'], + 965 => ['$\upsilon$'], + 966 => ['$\phi$'], + 967 => ['$\chi$'], + 968 => ['$\psi$'], + 969 => ['$\omega$'], + 962 => ['$\varsigma$'], + 977 => ['$\vartheta$'], + 982 => ['$\varpi$'], + 8230 => ['\ldots'], + 8242 => ['$\prime$'], + 8254 => ['-'], + 8260 => ['/'], + 8472 => ['$\wp$'], + 8465 => ['$\Im$'], + 8476 => ['$\Re$'], + 8501 => ['$\aleph$'], + 8226 => ['$\bullet$'], + 8482 => ['$^{\rm TM}$'], + 8592 => ['$\leftarrow$'], + 8594 => ['$\rightarrow$'], + 8593 => ['$\uparrow$'], + 8595 => ['$\downarrow$'], + 8596 => ['$\leftrightarrow$'], + 8629 => ['$\hookleftarrow$'], + 8657 => ['$\Uparrow$'], + 8659 => ['$\Downarrow$'], + 8656 => ['$\Leftarrow$'], + 8658 => ['$\Rightarrow$'], + 8660 => ['$\Leftrightarrow$'], + 8704 => ['$\forall$'], + 8706 => ['$\partial$'], + 8707 => ['$\exists$'], + 8709 => ['$\emptyset$'], + 8711 => ['$\nabla$'], + 8712 => ['$\in$'], + 8715 => ['$\ni$'], + 8713 => ['$\notin$'], + 8721 => ['$\sum$'], + 8719 => ['$\prod$'], + 8722 => ['$-$'], + 8727 => ['$\ast$'], + 8730 => ['$\surd$'], + 8733 => ['$\propto$'], + 8734 => ['$\infty$'], + 8736 => ['$\angle$'], + 8743 => ['$\wedge$'], + 8744 => ['$\vee$'], + 8745 => ['$\cap$'], + 8746 => ['$\cup$'], + 8747 => ['$\int$'], + 8756 => ['$\therefore$', 'amssymb'], + 8764 => ['$\sim$'], + 8776 => ['$\approx$'], + 8773 => ['$\cong$'], + 8800 => ['$\neq$'], + 8801 => ['$\equiv$'], + 8804 => ['$\leq$'], + 8805 => ['$\geq$'], + 8834 => ['$\subset$'], + 8835 => ['$\supset$'], + 8838 => ['$\subseteq$'], + 8839 => ['$\supseteq$'], + 8836 => ['$\nsubset$', 'amssymb'], + 8853 => ['$\oplus$'], + 8855 => ['$\otimes$'], + 8869 => ['$\perp$'], + 8901 => ['$\cdot$'], + 8968 => ['$\rceil$'], + 8969 => ['$\lceil$'], + 8970 => ['$\lfloor$'], + 8971 => ['$\rfloor$'], + 9001 => ['$\rangle$'], + 9002 => ['$\langle$'], + 9674 => ['$\lozenge$', 'amssymb'], + 9824 => ['$\spadesuit$'], + 9827 => ['$\clubsuit$'], + 9829 => ['$\heartsuit$'], + 9830 => ['$\diamondsuit$'], + 38 => ['\&'], + 34 => ['"'], + 39 => ['\''], + 169 => ['\copyright'], + 60 => ['\textless'], + 62 => ['\textgreater'], + 338 => ['\OE'], + 339 => ['\oe'], + 352 => ['\v{S}'], + 353 => ['\v{s}'], + 376 => ['\"Y'], + 710 => ['\textasciicircum'], + 732 => ['\textasciitilde'], + 8211 => ['--'], + 8212 => ['---'], + 8216 => ['`'], + 8217 => ['\''], + 8220 => ['``'], + 8221 => ['\'\''], + 8224 => ['\dag'], + 8225 => ['\ddag'], + 8240 => ['\permil', 'wasysym'], + 8364 => ['\euro', 'eurosym'], + 8249 => ['\guilsinglleft'], + 8250 => ['\guilsinglright'], + 8218 => ['\quotesinglbase', 'mathcomp'], + 8222 => ['\quotedblbase', 'mathcomp'], + 402 => ['\textflorin', 'mathcomp'], + 381 => ['\v{Z}'], + 382 => ['\v{z}'], + 160 => ['~'], + 161 => ['\textexclamdown'], + 163 => ['\pounds'], + 164 => ['\currency', 'wasysym'], + 165 => ['\textyen', 'textcomp'], + 166 => ['\brokenvert', 'wasysym'], + 167 => ['\S'], + 171 => ['\guillemotleft'], + 187 => ['\guillemotright'], + 174 => ['\textregistered'], + 170 => ['\textordfeminine'], + 172 => ['$\neg$'], + 173 => ['\-'], + 176 => ['$\degree$', 'mathabx'], + 177 => ['$\pm$'], + 180 => ['\''], + 181 => ['$\mu$'], + 182 => ['\P'], + 183 => ['$\cdot$'], + 186 => ['\textordmasculine'], + 162 => ['\cent', 'wasysym'], + 185 => ['$^1$'], + 178 => ['$^2$'], + 179 => ['$^3$'], + 189 => ['$\frac{1}{2}$'], + 188 => ['$\frac{1}{4}$'], + 190 => ['$\frac{3}{4}'], + 192 => ['\`A'], + 193 => ['\\\'A'], + 194 => ['\^A'], + 195 => ['\~A'], + 196 => ['\"A'], + 197 => ['\AA'], + 198 => ['\AE'], + 199 => ['\cC'], + 200 => ['\`E'], + 201 => ['\\\'E'], + 202 => ['\^E'], + 203 => ['\"E'], + 204 => ['\`I'], + 205 => ['\\\'I'], + 206 => ['\^I'], + 207 => ['\"I'], + 208 => ['$\eth$', 'amssymb'], + 209 => ['\~N'], + 210 => ['\`O'], + 211 => ['\\\'O'], + 212 => ['\^O'], + 213 => ['\~O'], + 214 => ['\"O'], + 215 => ['$\times$'], + 216 => ['\O'], + 217 => ['\`U'], + 218 => ['\\\'U'], + 219 => ['\^U'], + 220 => ['\"U'], + 221 => ['\\\'Y'], + 222 => ['\Thorn', 'wasysym'], + 223 => ['\ss'], + 224 => ['\`a'], + 225 => ['\\\'a'], + 226 => ['\^a'], + 227 => ['\~a'], + 228 => ['\"a'], + 229 => ['\aa'], + 230 => ['\ae'], + 231 => ['\cc'], + 232 => ['\`e'], + 233 => ['\\\'e'], + 234 => ['\^e'], + 235 => ['\"e'], + 236 => ['\`i'], + 237 => ['\\\'i'], + 238 => ['\^i'], + 239 => ['\"i'], + 240 => ['$\eth$'], + 241 => ['\~n'], + 242 => ['\`o'], + 243 => ['\\\'o'], + 244 => ['\^o'], + 245 => ['\~o'], + 246 => ['\"o'], + 247 => ['$\divide$'], + 248 => ['\o'], + 249 => ['\`u'], + 250 => ['\\\'u'], + 251 => ['\^u'], + 252 => ['\"u'], + 253 => ['\\\'y'], + 254 => ['\thorn', 'wasysym'], + 255 => ['\"y'], + 8201 => ['\thinspace'], + 8194 => ['\hskip .5em\relax'], + 8195 => ['\quad'], + } # :nodoc: + ENTITY_CONV_TABLE.each_value {|v| v[0] = "#{v[0]}{}" } + + def entity_to_latex(entity) + text, package = ENTITY_CONV_TABLE[entity.code_point] + if text + @data[:packages] << package if package + text + else + warning("Couldn't find entity with code #{entity.code_point} in substitution table!") + '' + end + end + + def convert_entity(el, _opts) + entity_to_latex(el.value) + end + + TYPOGRAPHIC_SYMS = { + mdash: '---', ndash: '--', hellip: '\ldots{}', + laquo_space: '\guillemotleft{}~', raquo_space: '~\guillemotright{}', + laquo: '\guillemotleft{}', raquo: '\guillemotright{}' + } # :nodoc: + def convert_typographic_sym(el, _opts) + if (result = @options[:typographic_symbols][el.value]) + escape(result) + else + TYPOGRAPHIC_SYMS[el.value] + end + end + + def convert_smart_quote(el, opts) + res = entity_to_latex(smart_quote_entity(el)).chomp('{}') + res << "{}" if ((nel = opts[:parent].children[opts[:index] + 1]) && nel.type == :smart_quote) || res =~ /\w$/ + res + end + + def convert_math(el, _opts) + @data[:packages] += %w[amssymb amsmath amsthm amsfonts] + if el.options[:category] == :block + if el.value =~ /\A\s*\\begin\{/ + el.value + else + latex_environment('displaymath', el, el.value) + end + else + "$#{el.value}$" + end + end + + def convert_abbreviation(el, _opts) + @data[:packages] += %w[acronym] + "\\ac{#{normalize_abbreviation_key(el.value)}}" + end + + # Normalize the abbreviation key so that it only contains allowed ASCII character + def normalize_abbreviation_key(key) + key.gsub(/\W/) {|m| m.unpack('H*').first } + end + + # Wrap the +text+ inside a LaTeX environment of type +type+. The element +el+ is passed on to + # the method #attribute_list -- the resulting string is appended to both the \\begin and the + # \\end lines of the LaTeX environment for easier post-processing of LaTeX environments. + def latex_environment(type, el, text) + attrs = attribute_list(el) + "\\begin{#{type}}#{latex_link_target(el)}#{attrs}\n#{text.rstrip}\n\\end{#{type}}#{attrs}\n" + end + + # Return a string containing a valid \hypertarget command if the element has an ID defined, or + # +nil+ otherwise. If the parameter +add_label+ is +true+, a \label command will also be used + # additionally to the \hypertarget command. + def latex_link_target(el, add_label = false) + if (id = el.attr['id']) + "\\hypertarget{#{id}}{}#{add_label ? "\\label{#{id}}" : ''}" + else + nil + end + end + + # Return a LaTeX comment containing all attributes as 'key="value"' pairs. + def attribute_list(el) + attrs = el.attr.map {|k, v| v.nil? ? '' : " #{k}=\"#{v}\"" }.compact.sort.join('') + attrs = " % #{attrs}" unless attrs.empty? + attrs + end + + ESCAPE_MAP = { + "^" => "\\^{}", + "\\" => "\\textbackslash{}", + "~" => "\\ensuremath{\\sim}", + "|" => "\\textbar{}", + "<" => "\\textless{}", + ">" => "\\textgreater{}", + "[" => "{[}", + "]" => "{]}", + }.merge(Hash[*("{}$%&_#".each_char.map {|c| [c, "\\#{c}"] }.flatten)]) # :nodoc: + ESCAPE_RE = Regexp.union(*ESCAPE_MAP.collect {|k, _v| k }) # :nodoc: + + # Escape the special LaTeX characters in the string +str+. + def escape(str) + str.gsub(ESCAPE_RE) {|m| ESCAPE_MAP[m] } + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/man.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/man.rb new file mode 100644 index 0000000..28aa2a6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/man.rb @@ -0,0 +1,300 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/converter' + +module Kramdown + + module Converter + + # Converts a Kramdown::Document to a manpage in groff format. See man(7), groff_man(7) and + # man-pages(7) for information regarding the output. + class Man < Base + + def convert(el, opts = {indent: 0, result: +''}) #:nodoc: + send("convert_#{el.type}", el, opts) + end + + private + + def inner(el, opts, use = :all) + arr = el.children.reject {|e| e.type == :blank } + arr.each_with_index do |inner_el, index| + next if use == :rest && index == 0 + break if use == :first && index > 0 + options = opts.dup + options[:parent] = el + options[:index] = index + options[:prev] = (index == 0 ? nil : arr[index - 1]) + options[:next] = (index == arr.length - 1 ? nil : arr[index + 1]) + convert(inner_el, options) + end + end + + def convert_root(el, opts) + @title_done = false + opts[:result] = +".\\\" generated by kramdown\n" + inner(el, opts) + opts[:result] + end + + def convert_blank(*) + end + alias convert_hr convert_blank + alias convert_xml_pi convert_blank + + def convert_p(el, opts) + if (opts[:index] != 0 && opts[:prev].type != :header) || + (opts[:parent].type == :blockquote && opts[:index] == 0) + opts[:result] << macro("P") + end + inner(el, opts) + newline(opts[:result]) + end + + def convert_header(el, opts) + return unless opts[:parent].type == :root + case el.options[:level] + when 1 + unless @title_done + @title_done = true + data = el.options[:raw_text].scan(/([^(]+)\s*\((\d\w*)\)(?:\s*-+\s*(.*))?/).first || + el.options[:raw_text].scan(/([^\s]+)\s*(?:-*\s+)?()(.*)/).first + return unless data && data[0] + name = data[0] + section = (data[1].to_s.empty? ? el.attr['data-section'] || '7' : data[1]) + description = (data[2].to_s.empty? ? nil : " - #{data[2]}") + date = el.attr['data-date'] ? quote(el.attr['data-date']) : nil + extra = (el.attr['data-extra'] ? quote(escape(el.attr['data-extra'].to_s)) : nil) + opts[:result] << macro("TH", quote(escape(name.upcase)), quote(section), date, extra) + if description + opts[:result] << macro("SH", "NAME") << escape("#{name}#{description}") << "\n" + end + end + when 2 + opts[:result] << macro("SH", quote(escape(el.options[:raw_text]))) + when 3 + opts[:result] << macro("SS", quote(escape(el.options[:raw_text]))) + else + warning("Header levels greater than three are not supported") + end + end + + def convert_codeblock(el, opts) + opts[:result] << macro("sp") << macro("RS", 4) << macro("EX") + opts[:result] << newline(escape(el.value, true)) + opts[:result] << macro("EE") << macro("RE") + end + + def convert_blockquote(el, opts) + opts[:result] << macro("RS") + inner(el, opts) + opts[:result] << macro("RE") + end + + def convert_ul(el, opts) + compact = (el.attr['class'] =~ /\bcompact\b/) + opts[:result] << macro("sp") << macro("PD", 0) if compact + inner(el, opts) + opts[:result] << macro("PD") if compact + end + alias convert_dl convert_ul + alias convert_ol convert_ul + + def convert_li(el, opts) + sym = (opts[:parent].type == :ul ? '\(bu' : "#{opts[:index] + 1}.") + opts[:result] << macro("IP", sym, 4) + inner(el, opts, :first) + if el.children.size > 1 + opts[:result] << macro("RS") + inner(el, opts, :rest) + opts[:result] << macro("RE") + end + end + + def convert_dt(el, opts) + opts[:result] << macro(opts[:prev] && opts[:prev].type == :dt ? "TQ" : "TP") + inner(el, opts) + opts[:result] << "\n" + end + + def convert_dd(el, opts) + inner(el, opts, :first) + if el.children.size > 1 + opts[:result] << macro("RS") + inner(el, opts, :rest) + opts[:result] << macro("RE") + end + opts[:result] << macro("sp") if opts[:next] && opts[:next].type == :dd + end + + TABLE_CELL_ALIGNMENT = {left: 'l', center: 'c', right: 'r', default: 'l'} + + def convert_table(el, opts) + opts[:alignment] = el.options[:alignment].map {|a| TABLE_CELL_ALIGNMENT[a] } + table_options = ["box"] + table_options << "center" if el.attr['class'] =~ /\bcenter\b/ + opts[:result] << macro("TS") << "#{table_options.join(' ')} ;\n" + inner(el, opts) + opts[:result] << macro("TE") << macro("sp") + end + + def convert_thead(el, opts) + opts[:result] << opts[:alignment].map {|a| "#{a}b" }.join(' ') << " .\n" + inner(el, opts) + opts[:result] << "=\n" + end + + def convert_tbody(el, opts) + opts[:result] << ".T&\n" if opts[:index] != 0 + opts[:result] << opts[:alignment].join(' ') << " .\n" + inner(el, opts) + opts[:result] << (opts[:next].type == :tfoot ? "=\n" : "_\n") if opts[:next] + end + + def convert_tfoot(el, opts) + inner(el, opts) + end + + def convert_tr(el, opts) + inner(el, opts) + opts[:result] << "\n" + end + + def convert_td(el, opts) + result = opts[:result] + opts[:result] = +'' + inner(el, opts) + if opts[:result] =~ /\n/ + warning("Table cells using links are not supported") + result << "\t" + else + result << opts[:result] << "\t" + end + end + + def convert_html_element(*) + warning("HTML elements are not supported") + end + + def convert_xml_comment(el, opts) + newline(opts[:result]) << ".\"#{escape(el.value, true).rstrip.gsub(/\n/, "\n.\"")}\n" + end + alias convert_comment convert_xml_comment + + def convert_a(el, opts) + if el.children.size == 1 && el.children[0].type == :text && + el.attr['href'] == el.children[0].value + newline(opts[:result]) << macro("UR", escape(el.attr['href'])) << macro("UE") + elsif el.attr['href'].start_with?('mailto:') + newline(opts[:result]) << macro("MT", escape(el.attr['href'].sub(/^mailto:/, ''))) << + macro("UE") + else + newline(opts[:result]) << macro("UR", escape(el.attr['href'])) + inner(el, opts) + newline(opts[:result]) << macro("UE") + end + end + + def convert_img(_el, _opts) + warning("Images are not supported") + end + + def convert_em(el, opts) + opts[:result] << '\fI' + inner(el, opts) + opts[:result] << '\fP' + end + + def convert_strong(el, opts) + opts[:result] << '\fB' + inner(el, opts) + opts[:result] << '\fP' + end + + def convert_codespan(el, opts) + opts[:result] << "\\fB#{escape(el.value)}\\fP" + end + + def convert_br(_el, opts) + newline(opts[:result]) << macro("br") + end + + def convert_abbreviation(el, opts) + opts[:result] << escape(el.value) + end + + def convert_math(el, opts) + if el.options[:category] == :block + convert_codeblock(el, opts) + else + convert_codespan(el, opts) + end + end + + def convert_footnote(*) + warning("Footnotes are not supported") + end + + def convert_raw(*) + warning("Raw content is not supported") + end + + def convert_text(el, opts) + text = escape(el.value) + text.lstrip! if opts[:result][-1] == "\n" + opts[:result] << text + end + + def convert_entity(el, opts) + opts[:result] << unicode_char(el.value.code_point) + end + + def convert_smart_quote(el, opts) + opts[:result] << unicode_char(::Kramdown::Utils::Entities.entity(el.value.to_s).code_point) + end + + TYPOGRAPHIC_SYMS_MAP = { + mdash: '\(em', ndash: '\(em', hellip: '\.\.\.', + laquo_space: '\[Fo]', raquo_space: '\[Fc]', laquo: '\[Fo]', raquo: '\[Fc]' + } + + def convert_typographic_sym(el, opts) + opts[:result] << TYPOGRAPHIC_SYMS_MAP[el.value] + end + + def macro(name, *args) + ".#{[name, *args].compact.join(' ')}\n" + end + + def newline(text) + text << "\n" unless text[-1] == "\n" + text + end + + def quote(text) + "\"#{text.gsub(/"/, '\\"')}\"" + end + + def escape(text, preserve_whitespace = false) + text = (preserve_whitespace ? text.dup : text.gsub(/\s+/, ' ')) + text.gsub!('\\', "\\e") + text.gsub!(/^\./, '\\\\&.') + text.gsub!(/[.'-]/) {|m| "\\#{m}" } + text + end + + def unicode_char(codepoint) + "\\[u#{codepoint.to_s(16).rjust(4, '0')}]" + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/math_engine/mathjax.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/math_engine/mathjax.rb new file mode 100644 index 0000000..850f541 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/math_engine/mathjax.rb @@ -0,0 +1,32 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown::Converter::MathEngine + + # Uses the MathJax javascript library for displaying math. + # + # Note that the javascript library itself is not include or linked, this has to be done + # separately. Only the math content is marked up correctly. + module Mathjax + + def self.call(converter, el, opts) + value = converter.escape_html(el.value) + result = el.options[:category] == :block ? "\\[#{value}\\]\n" : "\\(#{value}\\)" + if el.attr.empty? + result + elsif el.options[:category] == :block + converter.format_as_block_html('div', el.attr, result, opts[:indent]) + else + converter.format_as_span_html('span', el.attr, "$#{el.value}$") + end + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/remove_html_tags.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/remove_html_tags.rb new file mode 100644 index 0000000..e225604 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/remove_html_tags.rb @@ -0,0 +1,57 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/converter' + +module Kramdown + + module Converter + + # Removes all block (and optionally span) level HTML tags from the element tree. + # + # This converter can be used on parsed HTML documents to get an element tree that will only + # contain native kramdown elements. + # + # *Note* that the returned element tree may not be fully conformant (i.e. the content models of + # *some elements may be violated)! + # + # This converter modifies the given tree in-place and returns it. + class RemoveHtmlTags < Base + + def initialize(root, options) + super + @options[:template] = '' + end + + def convert(el) + real_el, el = el, el.value if el.type == :footnote + + children = el.children.dup + index = 0 + while index < children.length + if [:xml_pi].include?(children[index].type) || + (children[index].type == :html_element && %w[style script].include?(children[index].value)) + children[index..index] = [] + elsif children[index].type == :html_element && + ((@options[:remove_block_html_tags] && children[index].options[:category] == :block) || + (@options[:remove_span_html_tags] && children[index].options[:category] == :span)) + children[index..index] = children[index].children + else + convert(children[index]) + index += 1 + end + end + el.children = children + real_el || el + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter.rb new file mode 100644 index 0000000..683acbf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter.rb @@ -0,0 +1,56 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Converter + + # == Container for Syntax Highlighters + # + # This module serves as container for the syntax highlighters that can be used together with + # kramdown. + # + # A syntax highlighter should not store any data itself but should use the provided converter + # object to do so (See Kramdown::Converter::Base#data). + # + # == Implementing a Syntax Highlighter + # + # Implementing a new syntax highlighter is easy because it is just an object that needs to + # respond to #call. + # + # The method #call needs to take the following arguments: + # + # converter:: This argument contains the converter object that calls the syntax highlighter. It + # can be used, for example, to store data in Kramdown::Converter::Base#data for one + # conversion run. + # + # text:: The raw text that should be highlighted. + # + # lang:: The language that the text should be highlighted for (e.g. ruby, python, ...). + # + # type:: The type of text, either :span for span-level code or :block for a codeblock. + # + # opts:: A Hash with options that may be passed from the converter. + # + # The return value of the method should be the highlighted text, suitable for the given + # converter (e.g. HTML for the HTML converter). + # + # == Special Implementation Details + # + # HTML converter:: If the syntax highlighter is used with an HTML converter, it should return + # :block type text correctly wrapped (i.e. normally inside a pre-tag, but may + # also be a table-tag or just a div-tag) but :span type text *without* a + # code-tag! + # + # Also, a syntax highlighter should store the default highlighting language for + # the invocation in the +opts+ hash under the key :default_lang. + module SyntaxHighlighter + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter/minted.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter/minted.rb new file mode 100644 index 0000000..2119f00 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter/minted.rb @@ -0,0 +1,35 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown::Converter::SyntaxHighlighter + + # Uses Minted to highlight code blocks and code spans. + module Minted + + def self.call(converter, text, lang, type, _opts) + opts = converter.options[:syntax_highlighter_opts] + + # Fallback to default language + lang ||= opts[:default_lang] + + options = [] + options << "breaklines" if opts[:wrap] + options << "linenos" if opts[:line_numbers] + options << "frame=#{opts[:frame]}" if opts[:frame] + + if lang && type == :block + "\\begin{minted}[#{options.join(',')}]{#{lang}}\n#{text}\n\\end{minted}" + elsif lang && type == :span + "\\mintinline{#{lang}}{#{text}}" + else + nil + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter/rouge.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter/rouge.rb new file mode 100644 index 0000000..ed6a4f8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter/rouge.rb @@ -0,0 +1,85 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown::Converter::SyntaxHighlighter + + # Uses Rouge which is CSS-compatible to Pygments to highlight code blocks and code spans. + module Rouge + + begin + require 'rouge' + + # Highlighting via Rouge is available if this constant is +true+. + AVAILABLE = true + rescue LoadError, SyntaxError + AVAILABLE = false # :nodoc: + end + + def self.call(converter, text, lang, type, call_opts) + opts = options(converter, type) + call_opts[:default_lang] = opts[:default_lang] + return nil unless lang || opts[:default_lang] || opts[:guess_lang] + + lexer = ::Rouge::Lexer.find_fancy(lang || opts[:default_lang], text) + return nil if opts[:disable] || !lexer || (lexer.tag == "plaintext" && !opts[:guess_lang]) + + opts[:css_class] ||= 'highlight' # For backward compatibility when using Rouge 2.0 + formatter = formatter_class(opts).new(opts) + formatter.format(lexer.lex(text)) + end + + def self.options(converter, type) + prepare_options(converter) + converter.data[:syntax_highlighter_rouge][type] + end + + def self.prepare_options(converter) + return if converter.data.key?(:syntax_highlighter_rouge) + + cache = converter.data[:syntax_highlighter_rouge] = {} + + opts = converter.options[:syntax_highlighter_opts].dup + + span_opts = opts.delete(:span)&.dup || {} + block_opts = opts.delete(:block)&.dup || {} + normalize_keys(span_opts) + normalize_keys(block_opts) + + cache[:span] = opts.merge(span_opts) + cache[:span][:wrap] = false + + cache[:block] = opts.merge(block_opts) + end + + def self.normalize_keys(hash) + return if hash.empty? + + hash.keys.each do |k| + hash[k.kind_of?(String) ? Kramdown::Options.str_to_sym(k) : k] = hash.delete(k) + end + end + + def self.formatter_class(opts = {}) + case formatter = opts[:formatter] + when Class + formatter + when /\A[[:upper:]][[:alnum:]_]*\z/ + ::Rouge::Formatters.const_get(formatter, false) + else + # Available in Rouge 2.0 or later + ::Rouge::Formatters::HTMLLegacy + end + rescue NameError + # Fallback to Rouge 1.x + ::Rouge::Formatters::HTML + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/toc.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/toc.rb new file mode 100644 index 0000000..7ffbc5d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/toc.rb @@ -0,0 +1,69 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/converter' + +module Kramdown + + module Converter + + # Converts a Kramdown::Document to an element tree that represents the table of contents. + # + # The returned tree consists of Element objects of type :toc where the root element is just used + # as container object. Each :toc element contains as value the wrapped :header element and under + # the attribute key :id the header ID that should be used (note that this ID may not exist in + # the wrapped element). + # + # Since the TOC tree consists of special :toc elements, one cannot directly feed this tree to + # other converters! + class Toc < Base + + def initialize(root, options) + super + @toc = Element.new(:toc) + @stack = [] + @options[:template] = '' + end + + def convert(el) + if el.type == :header && in_toc?(el) + attr = el.attr.dup + attr['id'] = generate_id(el.options[:raw_text]) if @options[:auto_ids] && !attr['id'] + add_to_toc(el, attr['id']) if attr['id'] + else + el.children.each {|child| convert(child) } + end + @toc + end + + private + + def add_to_toc(el, id) + toc_element = Element.new(:toc, el, id: id) + + success = false + until success + if @stack.empty? + @toc.children << toc_element + @stack << toc_element + success = true + elsif @stack.last.value.options[:level] < el.options[:level] + @stack.last.children << toc_element + @stack << toc_element + success = true + else + @stack.pop + end + end + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/document.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/document.rb new file mode 100644 index 0000000..8b75f84 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/document.rb @@ -0,0 +1,139 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# +# = kramdown +# +# kramdown is fast, pure Ruby Markdown superset converter, using a strict syntax definition and +# supporting several common extensions. +# +# The kramdown library is mainly written to support the kramdown-to-HTML conversion chain. However, +# due to its flexibility it supports other input and output formats as well. Here is a list of the +# supported formats: +# +# * input formats: kramdown (a Markdown superset), Markdown, GFM, HTML +# * output formats: HTML, kramdown, LaTeX (and therefore PDF), PDF via Prawn +# +# All the documentation on the available input and output formats is available at +# http://kramdown.gettalong.org. +# +# == Usage +# +# kramdown has a simple API, so using kramdown is as easy as +# +# require 'kramdown' +# +# Kramdown::Document.new(text).to_html +# +# For detailed information have a look at the *\Kramdown::Document* class. +# +# == License +# +# MIT - see the COPYING file. + +require 'kramdown/version' +require 'kramdown/element' +require 'kramdown/error' +require 'kramdown/parser' +require 'kramdown/converter' +require 'kramdown/options' +require 'kramdown/utils' + +module Kramdown + + # Return the data directory for kramdown. + def self.data_dir + unless defined?(@data_dir) + require 'rbconfig' + @data_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'kramdown')) + @data_dir = File.expand_path(File.join(RbConfig::CONFIG["datadir"], "kramdown")) unless File.exist?(@data_dir) + raise "kramdown data directory not found! This is a bug, please report it!" unless File.directory?(@data_dir) + end + @data_dir + end + + # The main interface to kramdown. + # + # This class provides a one-stop-shop for using kramdown to convert text into various output + # formats. Use it like this: + # + # require 'kramdown' + # doc = Kramdown::Document.new('This *is* some kramdown text') + # puts doc.to_html + # + # The #to_html method is a shortcut for using the Converter::Html class. See #method_missing for + # more information. + # + # The second argument to the ::new method is an options hash for customizing the behaviour of the + # used parser and the converter. See ::new for more information! + class Document + + # The root Element of the element tree. It is immediately available after the ::new method has + # been called. + attr_accessor :root + + # The options hash which holds the options for parsing/converting the Kramdown document. + attr_reader :options + + # An array of warning messages. It is filled with warnings during the parsing phase (i.e. in + # ::new) and the conversion phase. + attr_reader :warnings + + # Create a new Kramdown document from the string +source+ and use the provided +options+. The + # options that can be used are defined in the Options module. + # + # The special options key :input can be used to select the parser that should parse the + # +source+. It has to be the name of a class in the Kramdown::Parser module. For example, to + # select the kramdown parser, one would set the :input key to +Kramdown+. If this key is not + # set, it defaults to +Kramdown+. + # + # The +source+ is immediately parsed by the selected parser so that the root element is + # immediately available and the output can be generated. + def initialize(source, options = {}) + @options = Options.merge(options).freeze + parser = (@options[:input] || 'kramdown').to_s + parser = parser[0..0].upcase + parser[1..-1] + try_require('parser', parser) + if Parser.const_defined?(parser) + @root, @warnings = Parser.const_get(parser).parse(source, @options) + else + raise Kramdown::Error, "kramdown has no parser to handle the specified " \ + "input format: #{@options[:input]}" + end + end + + # Check if a method is invoked that begins with +to_+ and if so, try to instantiate a converter + # class (i.e. a class in the Kramdown::Converter module) and use it for converting the document. + # + # For example, +to_html+ would instantiate the Kramdown::Converter::Html class. + def method_missing(id, *attr, &block) + if id.to_s =~ /^to_(\w+)$/ && (name = Utils.camelize($1)) && + try_require('converter', name) && Converter.const_defined?(name) + output, warnings = Converter.const_get(name).convert(@root, @options) + @warnings.concat(warnings) + output + else + super + end + end + + def inspect #:nodoc: + "" + end + + # Try requiring a parser or converter class and don't raise an error if the file is not found. + def try_require(type, name) + require("kramdown/#{type}/#{Utils.snake_case(name)}") + true + rescue LoadError + true + end + protected :try_require + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/element.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/element.rb new file mode 100644 index 0000000..c1d1fac --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/element.rb @@ -0,0 +1,551 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + + # Represents all elements in the element tree. + # + # kramdown only uses this one class for representing all available elements in an element tree + # (paragraphs, headers, emphasis, ...). The type of element can be set via the #type accessor. + # + # The root of a kramdown element tree has to be an element of type :root. It needs to have certain + # option keys set so that conversions work correctly. If only a part of a tree should be + # converted, duplicate the root node and assign the #children appropriately, e.g: + # + # root = doc.root + # new_root = root.dup + # new_root.children = [root.children[0]] # assign new array with elements to convert + # + # Following is a description of all supported element types. + # + # Note that the option :location may contain the start line number of an element in the source + # document. + # + # == Structural Elements + # + # === :root + # + # [Category] None + # [Usage context] As the root element of a document + # [Content model] Block-level elements + # + # Represents the root of a kramdown document. + # + # The root element contains the following option keys: + # + # :encoding:: When running on Ruby 1.9 this key has to be set to the encoding used for the text + # parts of the kramdown document. + # + # :abbrev_defs:: This key may be used to store the mapping of abbreviation to abbreviation + # definition. + # + # :abbrev_attr:: This key may be used to store the mapping of abbreviation to abbreviation + # attributes. + # + # :options:: This key may be used to store options that were set during parsing of the document. + # + # :footnote_count:: This key stores the number of actually referenced footnotes of the document. + # + # === :blank + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] Empty + # + # Represents one or more blank lines. It is not allowed to have two or more consecutive blank + # elements. + # + # The +value+ field may contain the original content of the blank lines. + # + # + # === :p + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] Span-level elements + # + # Represents a paragraph. + # + # If the option :transparent is +true+, this element just represents a block of text. I.e. this + # element just functions as a container for span-level elements. + # + # + # === :header + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] Span-level elements + # + # Represents a header. + # + # The option :level specifies the header level and has to contain a number between 1 and \6. The + # option :raw_text has to contain the raw header text. + # + # + # === :blockquote + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] Block-level elements + # + # Represents a blockquote. + # + # + # === :codeblock + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] Empty + # + # Represents a code block, i.e. a block of text that should be used as-is. + # + # The +value+ field has to contain the content of the code block. + # + # The option :lang specifies a highlighting language with possible HTML style options (e.g. + # php?start_inline=1) and should be used instead of a possibly also available language embedded in + # a class name of the form 'language-LANG'. + # + # + # === :ul + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] One or more :li elements + # + # Represents an unordered list. + # + # + # === :ol + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] One or more :li elements + # + # Represents an ordered list. + # + # + # === :li + # + # [Category] Block-level element + # [Usage context] Inside :ol and :ul elements + # [Content model] Block-level elements + # + # Represents a list item of an ordered or unordered list. + # + # Note that the first child of a list item must not be a :blank element! + # + # + # === :dl + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] One or more groups each consisting of one or more :dt elements followed by one + # or more :dd elements. + # + # Represents a definition list which contains groups consisting of terms and definitions for them. + # + # + # === :dt + # + # [Category] Block-level element + # [Usage context] Before :dt or :dd elements inside a :dl elment + # [Content model] Span-level elements + # + # Represents the term part of a term-definition group in a definition list. + # + # + # === :dd + # + # [Category] Block-level element + # [Usage context] After :dt or :dd elements inside a :dl elment + # [Content model] Block-level elements + # + # Represents the definition part of a term-definition group in a definition list. + # + # + # === :hr + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] None + # + # Represents a horizontal line. + # + # + # === :table + # + # [Category] Block-level element + # [Usage context] Where block-level elements are expected + # [Content model] Zero or one :thead elements, one or more :tbody elements, zero or one :tfoot + # elements + # + # Represents a table. Each table row (i.e. :tr element) of the table has to contain the same + # number of :td elements. + # + # The option :alignment has to be an array containing the alignment values, exactly one for each + # column of the table. The possible alignment values are :left, :center, :right and :default. + # + # + # === :thead + # + # [Category] None + # [Usage context] As first element inside a :table element + # [Content model] One or more :tr elements + # + # Represents the table header. + # + # + # === :tbody + # + # [Category] None + # [Usage context] After a :thead element but before a :tfoot element inside a :table element + # [Content model] One or more :tr elements + # + # Represents a table body. + # + # + # === :tfoot + # + # [Category] None + # [Usage context] As last element inside a :table element + # [Content model] One or more :tr elements + # + # Represents the table footer. + # + # + # === :tr + # + # [Category] None + # [Usage context] Inside :thead, :tbody and :tfoot elements + # [Content model] One or more :td elements + # + # Represents a table row. + # + # + # === :td + # + # [Category] Block-level element + # [Usage context] Inside :tr elements + # [Content model] As child of :thead/:tr span-level elements, as child of :tbody/:tr and + # :tfoot/:tr block-level elements + # + # Represents a table cell. + # + # + # === :math + # + # [Category] Block/span-level element + # [Usage context] Where block/span-level elements are expected + # [Content model] None + # + # Represents mathematical text that is written in LaTeX. + # + # The +value+ field has to contain the actual mathematical text. + # + # The option :category has to be set to either :span or :block depending on the context where the + # element is used. + # + # + # == Text Markup Elements + # + # === :text + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents text. + # + # The +value+ field has to contain the text itself. + # + # + # === :br + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents a hard line break. + # + # + # === :a + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] Span-level elements + # + # Represents a link to an URL. + # + # The attribute +href+ has to be set to the URL to which the link points. The attribute +title+ + # optionally contains the title of the link. + # + # + # === :img + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents an image. + # + # The attribute +src+ has to be set to the URL of the image. The attribute +alt+ has to contain a + # text description of the image. The attribute +title+ optionally contains the title of the image. + # + # + # === :codespan + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents verbatim text. + # + # The +value+ field has to contain the content of the code span. + # + # + # === :footnote + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents a footnote marker. + # + # The +value+ field has to contain an element whose children are the content of the footnote. The + # option :name has to contain a valid and unique footnote name. A valid footnote name consists of + # a word character or a digit and then optionally followed by other word characters, digits or + # dashes. + # + # + # === :em + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] Span-level elements + # + # Represents emphasis of its contents. + # + # + # === :strong + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] Span-level elements + # + # Represents strong importance for its contents. + # + # + # === :entity + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents an HTML entity. + # + # The +value+ field has to contain an instance of Kramdown::Utils::Entities::Entity. The option + # :original can be used to store the original representation of the entity. + # + # + # === :typographic_sym + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents a typographic symbol. + # + # The +value+ field needs to contain a Symbol representing the specific typographic symbol from + # the following list: + # + # :mdash:: An mdash character (---) + # :ndash:: An ndash character (--) + # :hellip:: An ellipsis (...) + # :laquo:: A left guillemet (<<) + # :raquo:: A right guillemet (>>) + # :laquo_space:: A left guillemet with a space (<< ) + # :raquo_space:: A right guillemet with a space ( >>) + # + # + # === :smart_quote + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents a quotation character. + # + # The +value+ field needs to contain a Symbol representing the specific quotation character: + # + # :lsquo:: Left single quote + # :rsquo:: Right single quote + # :ldquo:: Left double quote + # :rdquo:: Right double quote + # + # + # === :abbreviation + # + # [Category] Span-level element + # [Usage context] Where span-level elements are expected + # [Content model] None + # + # Represents a text part that is an abbreviation. + # + # The +value+ field has to contain the text part that is the abbreviation. The definition of the + # abbreviation is stored in the :root element of the document. + # + # + # == Other Elements + # + # === :html_element + # + # [Category] Block/span-level element + # [Usage context] Where block/span-level elements or raw HTML elements are expected + # [Content model] Depends on the element + # + # Represents an HTML element. + # + # The +value+ field has to contain the name of the HTML element the element is representing. + # + # The option :category has to be set to either :span or :block depending on the whether the + # element is a block-level or a span-level element. The option :content_model has to be set to the + # content model for the element (either :block if it contains block-level elements, :span if it + # contains span-level elements or :raw if it contains raw content). + # + # + # === :xml_comment + # + # [Category] Block/span-level element + # [Usage context] Where block/span-level elements are expected or in raw HTML elements + # [Content model] None + # + # Represents an XML/HTML comment. + # + # The +value+ field has to contain the whole XML/HTML comment including the delimiters. + # + # The option :category has to be set to either :span or :block depending on the context where the + # element is used. + # + # + # === :xml_pi + # + # [Category] Block/span-level element + # [Usage context] Where block/span-level elements are expected or in raw HTML elements + # [Content model] None + # + # Represents an XML/HTML processing instruction. + # + # The +value+ field has to contain the whole XML/HTML processing instruction including the + # delimiters. + # + # The option :category has to be set to either :span or :block depending on the context where the + # element is used. + # + # + # === :comment + # + # [Category] Block/span-level element + # [Usage context] Where block/span-level elements are expected + # [Content model] None + # + # Represents a comment. + # + # The +value+ field has to contain the comment. + # + # The option :category has to be set to either :span or :block depending on the context where the + # element is used. If it is set to :span, then no blank lines are allowed in the comment. + # + # + # === :raw + # + # [Category] Block/span-level element + # [Usage context] Where block/span-level elements are expected + # [Content model] None + # + # Represents a raw string that should not be modified. For example, the element could contain some + # HTML code that should be output as-is without modification and escaping. + # + # The +value+ field has to contain the actual raw text. + # + # The option :category has to be set to either :span or :block depending on the context where the + # element is used. If it is set to :span, then no blank lines are allowed in the raw text. + # + # The option :type can be set to an array of strings to define for which converters the raw string + # is valid. + # + class Element + + # A symbol representing the element type. For example, :p or :blockquote. + attr_accessor :type + + # The value of the element. The interpretation of this field depends on the type of the element. + # Many elements don't use this field. + attr_accessor :value + + # The child elements of this element. + attr_accessor :children + + # Create a new Element object of type +type+. The optional parameters +value+, +attr+ and + # +options+ can also be set in this constructor for convenience. + def initialize(type, value = nil, attr = nil, options = nil) + @type, @value, @attr, @options = type, value, attr, options + @children = [] + end + + # The attributes of the element. + def attr + @attr ||= {} + end + + # The options hash for the element. It is used for storing arbitray options. + def options + @options ||= {} + end + + def inspect #:nodoc: + "hallo` the emphasis tag + would normally be converted to an `:html` element with tag type `:em`. + If `html_to_native` is `true`, then the emphasis would be converted to a + native `:em` element. + + This is useful for converters that cannot deal with HTML elements. + + Default: false + Used by: kramdown parser + EOF + + define(:link_defs, Object, {}, <<~EOF) do |val| + Pre-defines link definitions + + This option can be used to pre-define link definitions. The value needs + to be a Hash where the keys are the link identifiers and the values are + two element Arrays with the link URL and the link title. + + If the value is a String, it has to contain a valid YAML hash and the + hash has to follow the above guidelines. + + Default: {} + Used by: kramdown parser + EOF + val = simple_hash_validator(val, :link_defs) + val.each do |_k, v| + if !(Array === v) || v.size > 2 || v.empty? + raise Kramdown::Error, "Invalid structure for hash value of option #{name}" + end + v << nil if v.size == 1 + end + val + end + + define(:footnote_nr, Integer, 1, <<~EOF) + The number of the first footnote + + This option can be used to specify the number that is used for the first + footnote. + + Default: 1 + Used by: HTML converter + EOF + + define(:entity_output, Symbol, :as_char, <<~EOF) + Defines how entities are output + + The possible values are :as_input (entities are output in the same + form as found in the input), :numeric (entities are output in numeric + form), :symbolic (entities are output in symbolic form if possible) or + :as_char (entities are output as characters if possible, only available + on Ruby 1.9). + + Default: :as_char + Used by: HTML converter, kramdown converter + EOF + + TOC_LEVELS_RANGE = (1..6).freeze + TOC_LEVELS_ARRAY = TOC_LEVELS_RANGE.to_a.freeze + private_constant :TOC_LEVELS_RANGE, :TOC_LEVELS_ARRAY + + define(:toc_levels, Object, TOC_LEVELS_ARRAY, <<~EOF) do |val| + Defines the levels that are used for the table of contents + + The individual levels can be specified by separating them with commas + (e.g. 1,2,3) or by using the range syntax (e.g. 1..3). Only the + specified levels are used for the table of contents. + + Default: 1..6 + Used by: HTML/Latex converter + EOF + case val + when String + if val =~ /^(\d)\.\.(\d)$/ + val = Range.new($1.to_i, $2.to_i).to_a + elsif val =~ /^\d(?:,\d)*$/ + val = val.split(/,/).map(&:to_i).uniq + else + raise Kramdown::Error, "Invalid syntax for option toc_levels" + end + when Array + unless val.eql?(TOC_LEVELS_ARRAY) + val = val.map(&:to_i).uniq + end + when Range + if val.eql?(TOC_LEVELS_RANGE) + val = TOC_LEVELS_ARRAY + else + val = val.map(&:to_i).uniq + end + else + raise Kramdown::Error, "Invalid type #{val.class} for option toc_levels" + end + if val.any? {|i| !TOC_LEVELS_RANGE.cover?(i) } + raise Kramdown::Error, "Level numbers for option toc_levels have to be integers from 1 to 6" + end + val + end + + define(:line_width, Integer, 72, <<~EOF) + Defines the line width to be used when outputting a document + + Default: 72 + Used by: kramdown converter + EOF + + define(:latex_headers, Object, %w[section subsection subsubsection paragraph subparagraph subparagraph], <<~EOF) do |val| + Defines the LaTeX commands for different header levels + + The commands for the header levels one to six can be specified by + separating them with commas. + + Default: section,subsection,subsubsection,paragraph,subparagraph,subparagraph + Used by: Latex converter + EOF + simple_array_validator(val, :latex_headers, 6) + end + + SMART_QUOTES_ENTITIES = %w[lsquo rsquo ldquo rdquo].freeze + SMART_QUOTES_STR = SMART_QUOTES_ENTITIES.join(',').freeze + private_constant :SMART_QUOTES_ENTITIES, :SMART_QUOTES_STR + + define(:smart_quotes, Object, SMART_QUOTES_ENTITIES, <<~EOF) do |val| + Defines the HTML entity names or code points for smart quote output + + The entities identified by entity name or code point that should be + used for, in order, a left single quote, a right single quote, a left + double and a right double quote are specified by separating them with + commas. + + Default: lsquo,rsquo,ldquo,rdquo + Used by: HTML/Latex converter + EOF + if val == SMART_QUOTES_STR || val == SMART_QUOTES_ENTITIES + SMART_QUOTES_ENTITIES + else + val = simple_array_validator(val, :smart_quotes, 4) + val.map! {|v| Integer(v) rescue v } + val + end + end + + define(:typographic_symbols, Object, {}, <<~EOF) do |val| + Defines a mapping from typographical symbol to output characters + + Typographical symbols are normally output using their equivalent Unicode + codepoint. However, sometimes one wants to change the output, mostly to + fallback to a sequence of ASCII characters. + + This option allows this by specifying a mapping from typographical + symbol to its output string. For example, the mapping {hellip: ...} would + output the standard ASCII representation of an ellipsis. + + The available typographical symbol names are: + + * hellip: ellipsis + * mdash: em-dash + * ndash: en-dash + * laquo: left guillemet + * raquo: right guillemet + * laquo_space: left guillemet followed by a space + * raquo_space: right guillemet preceeded by a space + + Default: {} + Used by: HTML/Latex converter + EOF + val = simple_hash_validator(val, :typographic_symbols) + val.keys.each do |k| + val[k.kind_of?(String) ? str_to_sym(k) : k] = val.delete(k).to_s + end + val + end + + define(:remove_block_html_tags, Boolean, true, <<~EOF) + Remove block HTML tags + + If this option is `true`, the RemoveHtmlTags converter removes + block HTML tags. + + Default: true + Used by: RemoveHtmlTags converter + EOF + + define(:remove_span_html_tags, Boolean, false, <<~EOF) + Remove span HTML tags + + If this option is `true`, the RemoveHtmlTags converter removes + span HTML tags. + + Default: false + Used by: RemoveHtmlTags converter + EOF + + define(:header_offset, Integer, 0, <<~EOF) + Sets the output offset for headers + + If this option is c (may also be negative) then a header with level n + will be output as a header with level c+n. If c+n is lower than 1, + level 1 will be used. If c+n is greater than 6, level 6 will be used. + + Default: 0 + Used by: HTML converter, Kramdown converter, Latex converter + EOF + + define(:syntax_highlighter, Symbol, :rouge, <<~EOF) + Set the syntax highlighter + + Specifies the syntax highlighter that should be used for highlighting + code blocks and spans. If this option is set to +nil+, no syntax + highlighting is done. + + Options for the syntax highlighter can be set with the + syntax_highlighter_opts configuration option. + + Default: rouge + Used by: HTML/Latex converter + EOF + + define(:syntax_highlighter_opts, Object, {}, <<~EOF) do |val| + Set the syntax highlighter options + + Specifies options for the syntax highlighter set via the + syntax_highlighter configuration option. + + The value needs to be a hash with key-value pairs that are understood by + the used syntax highlighter. + + Default: {} + Used by: HTML/Latex converter + EOF + val = simple_hash_validator(val, :syntax_highlighter_opts) + val.keys.each do |k| + val[k.kind_of?(String) ? str_to_sym(k) : k] = val.delete(k) + end + val + end + + define(:math_engine, Symbol, :mathjax, <<~EOF) + Set the math engine + + Specifies the math engine that should be used for converting math + blocks/spans. If this option is set to +nil+, no math engine is used and + the math blocks/spans are output as is. + + Options for the selected math engine can be set with the + math_engine_opts configuration option. + + Default: mathjax + Used by: HTML converter + EOF + + define(:math_engine_opts, Object, {}, <<~EOF) do |val| + Set the math engine options + + Specifies options for the math engine set via the math_engine + configuration option. + + The value needs to be a hash with key-value pairs that are understood by + the used math engine. + + Default: {} + Used by: HTML converter + EOF + val = simple_hash_validator(val, :math_engine_opts) + val.keys.each do |k| + val[k.kind_of?(String) ? str_to_sym(k) : k] = val.delete(k) + end + val + end + + define(:footnote_backlink, String, '↩', <<~EOF) + Defines the text that should be used for the footnote backlinks + + The footnote backlink is just text, so any special HTML characters will + be escaped. + + If the footnote backlint text is an empty string, no footnote backlinks + will be generated. + + Default: '&8617;' + Used by: HTML converter + EOF + + define(:footnote_backlink_inline, Boolean, false, <<~EOF) + Specifies whether the footnote backlink should always be inline + + With the default of false the footnote backlink is placed at the end of + the last paragraph if there is one, or an extra paragraph with only the + footnote backlink is created. + + Setting this option to true tries to place the footnote backlink in the + last, possibly nested paragraph or header. If this fails (e.g. in the + case of a table), an extra paragraph with only the footnote backlink is + created. + + Default: false + Used by: HTML converter + EOF + + define(:footnote_prefix, String, '', <<~EOF) + Prefix used for footnote IDs + + This option can be used to set a prefix for footnote IDs. This is useful + when rendering multiple documents into the same output file to avoid + duplicate IDs. The prefix should only contain characters that are valid + in an ID! + + Default: '' + Used by: HTML + EOF + + define(:remove_line_breaks_for_cjk, Boolean, false, <<~EOF) + Specifies whether line breaks should be removed between CJK characters + + Default: false + Used by: HTML converter + EOF + + define(:forbidden_inline_options, Object, %w[template], <<~EOF) do |val| + Defines the options that may not be set using the {::options} extension + + The value needs to be an array of option names. + + Default: [template] + Used by: HTML converter + EOF + val.map! {|item| item.kind_of?(String) ? str_to_sym(item) : item } + simple_array_validator(val, :forbidden_inline_options) + end + + define(:list_indent, Integer, 2, <<~EOF) + Sets the number of spaces to use for list indentation + + Default: 2 + Used by: Kramdown converter + EOF + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser.rb new file mode 100644 index 0000000..f77dcf6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + + # This module contains all available parsers. A parser takes an input string and converts the + # string to an element tree. + # + # New parsers should be derived from the Base class which provides common functionality - see its + # API documentation for how to create a custom converter class. + module Parser + + autoload :Base, 'kramdown/parser/base' + autoload :Kramdown, 'kramdown/parser/kramdown' + autoload :Html, 'kramdown/parser/html' + autoload :Markdown, 'kramdown/parser/markdown' + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/base.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/base.rb new file mode 100644 index 0000000..71ced7b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/base.rb @@ -0,0 +1,131 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/utils' +require 'kramdown/parser' + +module Kramdown + + module Parser + + # == \Base class for parsers + # + # This class serves as base class for parsers. It provides common methods that can/should be + # used by all parsers, especially by those using StringScanner(Kramdown) for parsing. + # + # A parser object is used as a throw-away object, i.e. it is only used for storing the needed + # state information during parsing. Therefore one can't instantiate a parser object directly but + # only use the Base::parse method. + # + # == Implementing a parser + # + # Implementing a new parser is rather easy: just derive a new class from this class and put it + # in the Kramdown::Parser module -- the latter is needed so that the auto-detection of the new + # parser works correctly. Then you need to implement the +#parse+ method which has to contain + # the parsing code. + # + # Have a look at the Base::parse, Base::new and Base#parse methods for additional information! + class Base + + # The hash with the parsing options. + attr_reader :options + + # The array with the parser warnings. + attr_reader :warnings + + # The original source string. + attr_reader :source + + # The root element of element tree that is created from the source string. + attr_reader :root + + # Initialize the parser object with the +source+ string and the parsing +options+. + # + # The @root element, the @warnings array and @text_type (specifies the default type for newly + # created text nodes) are automatically initialized. + def initialize(source, options) + @source = source + @options = Kramdown::Options.merge(options) + @root = Element.new(:root, nil, nil, encoding: (source.encoding rescue nil), location: 1, + options: {}, abbrev_defs: {}, abbrev_attr: {}) + @warnings = [] + @text_type = :text + end + private_class_method(:new, :allocate) + + # Parse the +source+ string into an element tree, possibly using the parsing +options+, and + # return the root element of the element tree and an array with warning messages. + # + # Initializes a new instance of the calling class and then calls the +#parse+ method that must + # be implemented by each subclass. + def self.parse(source, options = {}) + parser = new(source, options) + parser.parse + [parser.root, parser.warnings] + end + + # Parse the source string into an element tree. + # + # The parsing code should parse the source provided in @source and build an element tree the + # root of which should be @root. + # + # This is the only method that has to be implemented by sub-classes! + def parse + raise NotImplementedError + end + + # Add the given warning +text+ to the warning array. + def warning(text) + @warnings << text + # TODO: add position information + end + + # Modify the string +source+ to be usable by the parser (unifies line ending characters to + # +\n+ and makes sure +source+ ends with a new line character). + def adapt_source(source) + unless source.valid_encoding? + raise "The source text contains invalid characters for the used encoding #{source.encoding}" + end + source = source.encode('UTF-8') + source.gsub!(/\r\n?/, "\n") + source.chomp! + source << "\n" + end + + # This helper method adds the given +text+ either to the last element in the +tree+ if it is a + # +type+ element or creates a new text element with the given +type+. + def add_text(text, tree = @tree, type = @text_type) + last = tree.children.last + if last && last.type == type + last.value << text + elsif !text.empty? + location = (last && last.options[:location] || tree.options[:location]) + tree.children << Element.new(type, text, nil, location: location) + end + end + + # Extract the part of the StringScanner +strscan+ backed string specified by the +range+. This + # method works correctly under Ruby 1.8 and Ruby 1.9. + def extract_string(range, strscan) + result = nil + begin + enc = strscan.string.encoding + strscan.string.force_encoding('ASCII-8BIT') + result = strscan.string[range].force_encoding(enc) + ensure + strscan.string.force_encoding(enc) + end + result + end + + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/html.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/html.rb new file mode 100644 index 0000000..03e5de8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/html.rb @@ -0,0 +1,615 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'rexml/parsers/baseparser' +require 'strscan' +require 'kramdown/utils' +require 'kramdown/parser' + +module Kramdown + + module Parser + + # Used for parsing an HTML document. + # + # The parsing code is in the Parser module that can also be used by other parsers. + class Html < Base + + # Contains all constants that are used when parsing. + module Constants + + #:stopdoc: + # The following regexps are based on the ones used by REXML, with some slight modifications. + HTML_DOCTYPE_RE = //im + HTML_COMMENT_RE = //m + HTML_INSTRUCTION_RE = /<\?(.*?)\?>/m + HTML_ATTRIBUTE_RE = /\s*(#{REXML::Parsers::BaseParser::UNAME_STR})(?:\s*=\s*(?:(\p{Word}+)|("|')(.*?)\3))?/m + HTML_TAG_RE = /<((?>#{REXML::Parsers::BaseParser::UNAME_STR}))\s*((?>\s+#{REXML::Parsers::BaseParser::UNAME_STR}(?:\s*=\s*(?:\p{Word}+|("|').*?\3))?)*)\s*(\/)?>/m + HTML_TAG_CLOSE_RE = /<\/(#{REXML::Parsers::BaseParser::UNAME_STR})\s*>/m + HTML_ENTITY_RE = /&([\w:][\-\w\.:]*);|&#(\d+);|&\#x([0-9a-fA-F]+);/ + + HTML_CONTENT_MODEL_BLOCK = %w[address applet article aside blockquote body + dd details div dl fieldset figure figcaption + footer form header hgroup iframe li main + map menu nav noscript object section summary td] + HTML_CONTENT_MODEL_SPAN = %w[a abbr acronym b bdo big button cite caption del dfn dt em + h1 h2 h3 h4 h5 h6 i ins label legend optgroup p q rb rbc + rp rt rtc ruby select small span strong sub sup th tt] + HTML_CONTENT_MODEL_RAW = %w[script style math option textarea pre code kbd samp var] + # The following elements are also parsed as raw since they need child elements that cannot + # be expressed using kramdown syntax: colgroup table tbody thead tfoot tr ul ol + + HTML_CONTENT_MODEL = Hash.new {|h, k| h[k] = :raw } + HTML_CONTENT_MODEL_BLOCK.each {|i| HTML_CONTENT_MODEL[i] = :block } + HTML_CONTENT_MODEL_SPAN.each {|i| HTML_CONTENT_MODEL[i] = :span } + HTML_CONTENT_MODEL_RAW.each {|i| HTML_CONTENT_MODEL[i] = :raw } + + # Some HTML elements like script belong to both categories (i.e. are valid in block and + # span HTML) and don't appear therefore! + # script, textarea + HTML_SPAN_ELEMENTS = %w[a abbr acronym b big bdo br button cite code del dfn em i img input + ins kbd label mark option q rb rbc rp rt rtc ruby samp select small + span strong sub sup tt u var] + HTML_BLOCK_ELEMENTS = %w[address article aside applet body blockquote caption col colgroup + dd div dl dt fieldset figcaption footer form h1 h2 h3 h4 h5 h6 + header hgroup hr html head iframe legend menu li main map nav ol + optgroup p pre section summary table tbody td th thead tfoot tr ul] + HTML_ELEMENTS_WITHOUT_BODY = %w[area base br col command embed hr img input keygen link + meta param source track wbr] + + HTML_ELEMENT = Hash.new(false) + (HTML_SPAN_ELEMENTS + HTML_BLOCK_ELEMENTS + HTML_ELEMENTS_WITHOUT_BODY + + HTML_CONTENT_MODEL.keys).each do |a| + HTML_ELEMENT[a] = true + end + end + + # Contains the parsing methods. This module can be mixed into any parser to get HTML parsing + # functionality. The only thing that must be provided by the class are instance variable + # @stack for storing the needed state and @src (instance of StringScanner) for the actual + # parsing. + module Parser + + include Constants + + # Process the HTML start tag that has already be scanned/checked via @src. + # + # Does the common processing steps and then yields to the caller for further processing + # (first parameter is the created element; the second parameter is +true+ if the HTML + # element is already closed, ie. contains no body; the third parameter specifies whether the + # body - and the end tag - need to be handled in case closed=false). + def handle_html_start_tag(line = nil) # :yields: el, closed, handle_body + name = @src[1] + name.downcase! if HTML_ELEMENT[name.downcase] + closed = !@src[4].nil? + attrs = parse_html_attributes(@src[2], line, HTML_ELEMENT[name]) + + el = Element.new(:html_element, name, attrs, category: :block) + el.options[:location] = line if line + @tree.children << el + + if !closed && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value) + closed = true + end + if name == 'script' || name == 'style' + handle_raw_html_tag(name) + yield(el, false, false) + else + yield(el, closed, true) + end + end + + # Parses the given string for HTML attributes and returns the resulting hash. + # + # If the optional +line+ parameter is supplied, it is used in warning messages. + # + # If the optional +in_html_tag+ parameter is set to +false+, attributes are not modified to + # contain only lowercase letters. + def parse_html_attributes(str, line = nil, in_html_tag = true) + attrs = {} + str.scan(HTML_ATTRIBUTE_RE).each do |attr, val, _sep, quoted_val| + attr.downcase! if in_html_tag + if attrs.key?(attr) + warning("Duplicate HTML attribute '#{attr}' on line #{line || '?'} - overwriting previous one") + end + attrs[attr] = val || quoted_val || "" + end + attrs + end + + # Handle the raw HTML tag at the current position. + def handle_raw_html_tag(name) + curpos = @src.pos + if @src.scan_until(/(?=<\/#{name}\s*>)/mi) + add_text(extract_string(curpos...@src.pos, @src), @tree.children.last, :raw) + @src.scan(HTML_TAG_CLOSE_RE) + else + add_text(@src.rest, @tree.children.last, :raw) + @src.terminate + warning("Found no end tag for '#{name}' - auto-closing it") + end + end + + HTML_RAW_START = /(?=<(#{REXML::Parsers::BaseParser::UNAME_STR}|\/|!--|\?))/ # :nodoc: + + # Parse raw HTML from the current source position, storing the found elements in +el+. + # Parsing continues until one of the following criteria are fulfilled: + # + # - The end of the document is reached. + # - The matching end tag for the element +el+ is found (only used if +el+ is an HTML + # element). + # + # When an HTML start tag is found, processing is deferred to #handle_html_start_tag, + # providing the block given to this method. + def parse_raw_html(el, &block) + @stack.push(@tree) + @tree = el + + done = false + while !@src.eos? && !done + if (result = @src.scan_until(HTML_RAW_START)) + add_text(result, @tree, :text) + line = @src.current_line_number + if (result = @src.scan(HTML_COMMENT_RE)) + @tree.children << Element.new(:xml_comment, result, nil, category: :block, location: line) + elsif (result = @src.scan(HTML_INSTRUCTION_RE)) + @tree.children << Element.new(:xml_pi, result, nil, category: :block, location: line) + elsif @src.scan(HTML_TAG_RE) + if method(:handle_html_start_tag).arity.abs >= 1 + handle_html_start_tag(line, &block) + else + handle_html_start_tag(&block) # DEPRECATED: method needs to accept line number in 2.0 + end + elsif @src.scan(HTML_TAG_CLOSE_RE) + if @tree.value == (HTML_ELEMENT[@tree.value] ? @src[1].downcase : @src[1]) + done = true + else + add_text(@src.matched, @tree, :text) + warning("Found invalidly used HTML closing tag for '#{@src[1]}' on " \ + "line #{line} - ignoring it") + end + else + add_text(@src.getch, @tree, :text) + end + else + add_text(@src.rest, @tree, :text) + @src.terminate + if @tree.type == :html_element + warning("Found no end tag for '#{@tree.value}' on line " \ + "#{@tree.options[:location]} - auto-closing it") + end + done = true + end + end + + @tree = @stack.pop + end + + end + + # Converts HTML elements to native elements if possible. + class ElementConverter + + # :stopdoc: + + include Constants + include ::Kramdown::Utils::Entities + + REMOVE_TEXT_CHILDREN = %w[html head hgroup ol ul dl table colgroup tbody thead tfoot tr + select optgroup] + WRAP_TEXT_CHILDREN = %w[body section nav article aside header footer address div li dd + blockquote figure figcaption fieldset form] + REMOVE_WHITESPACE_CHILDREN = %w[body section nav article aside header footer address + div li dd blockquote figure figcaption td th fieldset form] + STRIP_WHITESPACE = %w[address article aside blockquote body caption dd div dl dt fieldset + figcaption form footer header h1 h2 h3 h4 h5 h6 legend li nav p + section td th] + SIMPLE_ELEMENTS = %w[em strong blockquote hr br img p thead tbody tfoot tr td th ul ol dl + li dl dt dd] + + def initialize(root) + @root = root + end + + def self.convert(root, el = root) + new(root).process(el) + end + + # Convert the element +el+ and its children. + def process(el, do_conversion = true, preserve_text = false, parent = nil) + case el.type + when :xml_comment, :xml_pi + ptype = if parent.nil? + 'div' + else + case parent.type + when :html_element then parent.value + when :code_span then 'code' + when :code_block then 'pre' + when :header then 'h1' + else parent.type.to_s + end + end + el.options.replace(category: (HTML_CONTENT_MODEL[ptype] == :span ? :span : :block)) + return + when :html_element + when :root + el.children.map! do |c| + if c.type == :text + process_text(c.value, !do_conversion) + else + process(c) + c + end + end.flatten! + remove_whitespace_children(el) + return + else return + end + + mname = "convert_#{el.value}" + if do_conversion && self.class.method_defined?(mname) + send(mname, el) + else + type = el.value + remove_text_children(el) if do_conversion && REMOVE_TEXT_CHILDREN.include?(type) + + if do_conversion && SIMPLE_ELEMENTS.include?(type) + set_basics(el, type.intern) + process_children(el, do_conversion, preserve_text) + else + process_html_element(el, do_conversion, preserve_text) + end + + if do_conversion + strip_whitespace(el) if STRIP_WHITESPACE.include?(type) + remove_whitespace_children(el) if REMOVE_WHITESPACE_CHILDREN.include?(type) + wrap_text_children(el) if WRAP_TEXT_CHILDREN.include?(type) + end + end + end + + def process_children(el, do_conversion = true, preserve_text = false) + el.children.map! do |c| + if c.type == :text + process_text(c.value, preserve_text || !do_conversion) + else + process(c, do_conversion, preserve_text, el) + c + end + end.flatten! + end + + # Process the HTML text +raw+: compress whitespace (if +preserve+ is +false+) and convert + # entities in entity elements. + def process_text(raw, preserve = false) + raw.gsub!(/\s+/, ' ') unless preserve + src = Kramdown::Utils::StringScanner.new(raw) + result = [] + until src.eos? + if (tmp = src.scan_until(/(?=#{HTML_ENTITY_RE})/o)) + result << Element.new(:text, tmp) + src.scan(HTML_ENTITY_RE) + val = src[1] || (src[2]&.to_i) || src[3].hex + result << if %w[lsquo rsquo ldquo rdquo].include?(val) + Element.new(:smart_quote, val.intern) + elsif %w[mdash ndash hellip laquo raquo].include?(val) + Element.new(:typographic_sym, val.intern) + else + begin + Element.new(:entity, entity(val), nil, original: src.matched) + rescue ::Kramdown::Error + src.pos -= src.matched_size - 1 + Element.new(:entity, ::Kramdown::Utils::Entities.entity('amp')) + end + end + else + result << Element.new(:text, src.rest) + src.terminate + end + end + result + end + + def process_html_element(el, do_conversion = true, preserve_text = false) + el.options.replace(category: HTML_SPAN_ELEMENTS.include?(el.value) ? :span : :block, + content_model: (do_conversion ? HTML_CONTENT_MODEL[el.value] : :raw)) + process_children(el, do_conversion, preserve_text) + end + + def remove_text_children(el) + el.children.delete_if {|c| c.type == :text } + end + + def wrap_text_children(el) + tmp = [] + last_is_p = false + el.children.each do |c| + if !c.block? || c.type == :text + unless last_is_p + tmp << Element.new(:p, nil, nil, transparent: true) + last_is_p = true + end + tmp.last.children << c + tmp + else + tmp << c + last_is_p = false + end + end + el.children = tmp + end + + def strip_whitespace(el) + return if el.children.empty? + if el.children.first.type == :text + el.children.first.value.lstrip! + end + if el.children.last.type == :text + el.children.last.value.rstrip! + end + end + + def remove_whitespace_children(el) + i = -1 + el.children = el.children.reject do |c| + i += 1 + c.type == :text && c.value.strip.empty? && + (i == 0 || i == el.children.length - 1 || ((el.children[i - 1]).block? && + (el.children[i + 1]).block?)) + end + end + + def set_basics(el, type, opts = {}) + el.type = type + el.options.replace(opts) + el.value = nil + end + + def extract_text(el, raw) + raw << el.value.to_s if el.type == :text + el.children.each {|c| extract_text(c, raw) } + end + + def convert_textarea(el) + process_html_element(el, true, true) + end + + def convert_a(el) + if el.attr['href'] + set_basics(el, :a) + process_children(el) + else + process_html_element(el, false) + end + end + + EMPHASIS_TYPE_MAP = {'em' => :em, 'i' => :em, 'strong' => :strong, 'b' => :strong} + def convert_em(el) + text = +'' + extract_text(el, text) + if text =~ /\A\s/ || text =~ /\s\z/ + process_html_element(el, false) + else + set_basics(el, EMPHASIS_TYPE_MAP[el.value]) + process_children(el) + end + end + %w[b strong i].each do |i| + alias_method("convert_#{i}".to_sym, :convert_em) + end + + def convert_h1(el) + set_basics(el, :header, level: el.value[1..1].to_i) + extract_text(el, el.options[:raw_text] = +'') + process_children(el) + end + %w[h2 h3 h4 h5 h6].each do |i| + alias_method("convert_#{i}".to_sym, :convert_h1) + end + + def convert_code(el) + raw = +'' + extract_text(el, raw) + result = process_text(raw, true) + begin + str = result.inject(+'') do |mem, c| + if c.type == :text + mem << c.value + elsif c.type == :entity + mem << if [60, 62, 34, 38].include?(c.value.code_point) + c.value.code_point.chr + else + c.value.char + end + elsif c.type == :smart_quote || c.type == :typographic_sym + mem << entity(c.value.to_s).char + else + raise "Bug - please report" + end + end + result.clear + result << Element.new(:text, str) + rescue StandardError + end + if result.length > 1 || result.first.type != :text + process_html_element(el, false, true) + else + if el.value == 'code' + set_basics(el, :codespan) + el.attr['class']&.gsub!(/\s+\bhighlighter-\w+\b|\bhighlighter-\w+\b\s*/, '') + else + set_basics(el, :codeblock) + if el.children.size == 1 && el.children.first.value == 'code' + value = (el.children.first.attr['class'] || '').scan(/\blanguage-\S+/).first + el.attr['class'] = "#{value} #{el.attr['class']}".rstrip if value + end + end + el.value = result.first.value + el.children.clear + end + end + alias convert_pre convert_code + + def convert_table(el) + unless is_simple_table?(el) + process_html_element(el, false) + return + end + remove_text_children(el) + process_children(el) + set_basics(el, :table) + + calc_alignment = lambda do |c| + if c.type == :tr + el.options[:alignment] = c.children.map do |td| + if td.attr['style'] + td.attr['style'].slice!(/(?:;\s*)?text-align:\s+(center|left|right)/) + td.attr.delete('style') if td.attr['style'].strip.empty? + $1 ? $1.to_sym : :default + else + :default + end + end + else + c.children.each {|cc| calc_alignment.call(cc) } + end + end + calc_alignment.call(el) + el.children.delete_if {|c| c.type == :html_element } + + change_th_type = lambda do |c| + if c.type == :th + c.type = :td + else + c.children.each {|cc| change_th_type.call(cc) } + end + end + change_th_type.call(el) + + if el.children.first.type == :tr + tbody = Element.new(:tbody) + tbody.children = el.children + el.children = [tbody] + end + end + + def is_simple_table?(el) + only_phrasing_content = lambda do |c| + c.children.all? do |cc| + (cc.type == :text || !HTML_BLOCK_ELEMENTS.include?(cc.value)) && only_phrasing_content.call(cc) + end + end + check_cells = proc do |c| + if c.value == 'th' || c.value == 'td' + return false unless only_phrasing_content.call(c) + else + c.children.each {|cc| check_cells.call(cc) } + end + end + check_cells.call(el) + + nr_cells = 0 + check_nr_cells = lambda do |t| + if t.value == 'tr' + count = t.children.select {|cc| cc.value == 'th' || cc.value == 'td' }.length + if count != nr_cells + if nr_cells == 0 + nr_cells = count + else + nr_cells = -1 + break + end + end + else + t.children.each {|cc| check_nr_cells.call(cc) } + end + end + check_nr_cells.call(el) + return false if nr_cells == -1 + + alignment = nil + check_alignment = proc do |t| + if t.value == 'tr' + cur_alignment = t.children.select {|cc| cc.value == 'th' || cc.value == 'td' }.map do |cell| + md = /text-align:\s+(center|left|right|justify|inherit)/.match(cell.attr['style'].to_s) + return false if md && (md[1] == 'justify' || md[1] == 'inherit') + md.nil? ? :default : md[1] + end + alignment = cur_alignment if alignment.nil? + return false if alignment != cur_alignment + else + t.children.each {|cc| check_alignment.call(cc) } + end + end + check_alignment.call(el) + + check_rows = lambda do |t, type| + t.children.all? {|r| (r.value == 'tr' || r.type == :text) && r.children.all? {|c| c.value == type || c.type == :text }} + end + check_rows.call(el, 'td') || + (el.children.all? do |t| + t.type == :text || (t.value == 'thead' && check_rows.call(t, 'th')) || + ((t.value == 'tfoot' || t.value == 'tbody') && check_rows.call(t, 'td')) + end && el.children.any? {|t| t.value == 'tbody' }) + end + + def convert_script(el) + if !is_math_tag?(el) + process_html_element(el) + else + handle_math_tag(el) + end + end + + def is_math_tag?(el) + el.attr['type'].to_s =~ /\bmath\/tex\b/ + end + + def handle_math_tag(el) + set_basics(el, :math, category: (el.attr['type'] =~ /mode=display/ ? :block : :span)) + el.value = el.children.shift.value.sub(/\A(?:%\s*)?\z/m, '\1') + el.attr.delete('type') + end + + end + + include Parser + + # Parse the source string provided on initialization as HTML document. + def parse + @stack, @tree = [], @root + @src = Kramdown::Utils::StringScanner.new(adapt_source(source)) + + while true + if (result = @src.scan(/\s*#{HTML_INSTRUCTION_RE}/o)) + @tree.children << Element.new(:xml_pi, result.strip, nil, category: :block) + elsif (result = @src.scan(/\s*#{HTML_DOCTYPE_RE}/o)) + # ignore the doctype + elsif (result = @src.scan(/\s*#{HTML_COMMENT_RE}/o)) + @tree.children << Element.new(:xml_comment, result.strip, nil, category: :block) + else + break + end + end + + tag_handler = lambda do |c, closed, handle_body| + parse_raw_html(c, &tag_handler) if !closed && handle_body + end + parse_raw_html(@tree, &tag_handler) + + ElementConverter.convert(@tree) + end + + end + + end + +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown.rb new file mode 100644 index 0000000..7205d58 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown.rb @@ -0,0 +1,376 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'strscan' +require 'stringio' +require 'kramdown/parser' + +# TODO: use [[:alpha:]] in all regexp to allow parsing of international values in 1.9.1 +# NOTE: use @src.pre_match only before other check/match?/... operations, otherwise the content is changed + +module Kramdown + + module Parser + + # Used for parsing a document in kramdown format. + # + # If you want to extend the functionality of the parser, you need to do the following: + # + # * Create a new subclass + # * add the needed parser methods + # * modify the @block_parsers and @span_parsers variables and add the names of your parser + # methods + # + # Here is a small example for an extended parser class that parses ERB style tags as raw text if + # they are used as span-level elements (an equivalent block-level parser should probably also be + # made to handle the block case): + # + # require 'kramdown/parser/kramdown' + # + # class Kramdown::Parser::ERBKramdown < Kramdown::Parser::Kramdown + # + # def initialize(source, options) + # super + # @span_parsers.unshift(:erb_tags) + # end + # + # ERB_TAGS_START = /<%.*?%>/ + # + # def parse_erb_tags + # @src.pos += @src.matched_size + # @tree.children << Element.new(:raw, @src.matched) + # end + # define_parser(:erb_tags, ERB_TAGS_START, '<%') + # + # end + # + # The new parser can be used like this: + # + # require 'kramdown/document' + # # require the file with the above parser class + # + # Kramdown::Document.new(input_text, :input => 'ERBKramdown').to_html + # + class Kramdown < Base + + include ::Kramdown + + # Create a new Kramdown parser object with the given +options+. + def initialize(source, options) + super + + reset_env + + @alds = {} + @footnotes = {} + @link_defs = {} + update_link_definitions(@options[:link_defs]) + + @block_parsers = [:blank_line, :codeblock, :codeblock_fenced, :blockquote, :atx_header, + :horizontal_rule, :list, :definition_list, :block_html, :setext_header, + :block_math, :table, :footnote_definition, :link_definition, + :abbrev_definition, :block_extensions, :eob_marker, :paragraph] + @span_parsers = [:emphasis, :codespan, :autolink, :span_html, :footnote_marker, :link, + :smart_quotes, :inline_math, :span_extensions, :html_entity, + :typographic_syms, :line_break, :escaped_chars] + + @span_pattern_cache ||= Hash.new { |h, k| h[k] = {} } + end + private_class_method(:new, :allocate) + + # The source string provided on initialization is parsed into the @root element. + def parse + configure_parser + parse_blocks(@root, adapt_source(source)) + update_tree(@root) + correct_abbreviations_attributes + replace_abbreviations(@root) + @footnotes.each do |_name, data| + update_tree(data[:content]) + replace_abbreviations(data[:content]) + end + footnote_count = 0 + @footnotes.each do |name, data| + (footnote_count += 1; next) if data.key?(:marker) + line = data[:content].options[:location] + warning("Footnote definition for '#{name}' on line #{line} is unreferenced - ignoring") + end + @root.options[:footnote_count] = footnote_count + end + + protected + + # :doc: + # + # Update the parser specific link definitions with the data from +link_defs+ (the value of the + # :link_defs option). + # + # The parameter +link_defs+ is a hash where the keys are possibly unnormalized link IDs and + # the values are two element arrays consisting of the link target and a title (can be +nil+). + def update_link_definitions(link_defs) + link_defs.each {|k, v| @link_defs[normalize_link_id(k)] = v } + end + + # Adapt the object to allow parsing like specified in the options. + def configure_parser + @parsers = {} + (@block_parsers + @span_parsers).each do |name| + if self.class.has_parser?(name) + @parsers[name] = self.class.parser(name) + else + raise Kramdown::Error, "Unknown parser: #{name}" + end + end + @span_start, @span_start_re = span_parser_regexps + end + + # Create the needed span parser regexps. + def span_parser_regexps(parsers = @span_parsers) + span_start = /#{parsers.map {|name| @parsers[name].span_start }.join('|')}/ + [span_start, /(?=#{span_start})/] + end + + # Parse all block-level elements in +text+ into the element +el+. + def parse_blocks(el, text = nil) + @stack.push([@tree, @src, @block_ial]) + @tree, @block_ial = el, nil + @src = (text.nil? ? @src : ::Kramdown::Utils::StringScanner.new(text, el.options[:location])) + + status = catch(:stop_block_parsing) do + until @src.eos? + @block_parsers.any? do |name| + if @src.check(@parsers[name].start_re) + send(@parsers[name].method) + else + false + end + end || begin + warning('Warning: this should not occur - no block parser handled the line') + add_text(@src.scan(/.*\n/)) + end + end + end + + @tree, @src, @block_ial = *@stack.pop + status + end + + # Update the tree by parsing all :+raw_text+ elements with the span-level parser (resets the + # environment) and by updating the attributes from the IALs. + def update_tree(element) + last_blank = nil + element.children.map! do |child| + if child.type == :raw_text + last_blank = nil + reset_env(src: ::Kramdown::Utils::StringScanner.new(child.value, element.options[:location]), + text_type: :text) + parse_spans(child) + child.children + elsif child.type == :eob + update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial] + [] + elsif child.type == :blank + if last_blank + last_blank.value << child.value + [] + else + last_blank = child + child + end + else + last_blank = nil + update_tree(child) + update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial] + # DEPRECATED: option auto_id_stripping will be removed in 2.0 because then this will be + # the default behaviour + if child.type == :dt || (child.type == :header && @options[:auto_id_stripping]) + update_raw_text(child) + end + child + end + end.flatten! + end + + def span_pattern_cache(stop_re, span_start) + @span_pattern_cache[stop_re][span_start] ||= /(?=#{Regexp.union(stop_re, span_start)})/ + end + private :span_pattern_cache + + # Parse all span-level elements in the source string of @src into +el+. + # + # If the parameter +stop_re+ (a regexp) is used, parsing is immediately stopped if the regexp + # matches and if no block is given or if a block is given and it returns +true+. + # + # The parameter +parsers+ can be used to specify the (span-level) parsing methods that should + # be used for parsing. + # + # The parameter +text_type+ specifies the type which should be used for created text nodes. + def parse_spans(el, stop_re = nil, parsers = nil, text_type = @text_type) + @stack.push([@tree, @text_type]) unless @tree.nil? + @tree, @text_type = el, text_type + + span_start = @span_start + span_start_re = @span_start_re + span_start, span_start_re = span_parser_regexps(parsers) if parsers + parsers ||= @span_parsers + + used_re = (stop_re.nil? ? span_start_re : span_pattern_cache(stop_re, span_start)) + stop_re_found = false + while !@src.eos? && !stop_re_found + if (result = @src.scan_until(used_re)) + add_text(result) + if stop_re && @src.check(stop_re) + stop_re_found = (block_given? ? yield : true) + end + processed = parsers.any? do |name| + if @src.check(@parsers[name].start_re) + send(@parsers[name].method) + true + else + false + end + end unless stop_re_found + add_text(@src.getch) if !processed && !stop_re_found + else + (add_text(@src.rest); @src.terminate) unless stop_re + break + end + end + + @tree, @text_type = @stack.pop + + stop_re_found + end + + # Reset the current parsing environment. The parameter +env+ can be used to set initial + # values for one or more environment variables. + def reset_env(opts = {}) + opts = {text_type: :raw_text, stack: []}.merge(opts) + @src = opts[:src] + @tree = opts[:tree] + @block_ial = opts[:block_ial] + @stack = opts[:stack] + @text_type = opts[:text_type] + end + + # Return the current parsing environment. + def save_env + [@src, @tree, @block_ial, @stack, @text_type] + end + + # Restore the current parsing environment. + def restore_env(env) + @src, @tree, @block_ial, @stack, @text_type = *env + end + + # Update the given attributes hash +attr+ with the information from the inline attribute list + # +ial+ and all referenced ALDs. + def update_attr_with_ial(attr, ial) + ial[:refs]&.each do |ref| + update_attr_with_ial(attr, ref) if (ref = @alds[ref]) + end + ial.each do |k, v| + if k == IAL_CLASS_ATTR + attr[k] = "#{attr[k]} #{v}".lstrip + elsif k.kind_of?(String) + attr[k] = v + end + end + end + + # Update the raw text for automatic ID generation. + def update_raw_text(item) + raw_text = +'' + + append_text = lambda do |child| + if child.type == :text + raw_text << child.value + else + child.children.each {|c| append_text.call(c) } + end + end + + append_text.call(item) + item.options[:raw_text] = raw_text + end + + # Create a new block-level element, taking care of applying a preceding block IAL if it + # exists. This method should always be used for creating a block-level element! + def new_block_el(*args) + el = Element.new(*args) + if @block_ial + el.options[:ial] = @block_ial + @block_ial = nil + end + el + end + + @@parsers = {} + + # Struct class holding all the needed data for one block/span-level parser method. + Data = Struct.new(:name, :start_re, :span_start, :method) + + # Add a parser method + # + # * with the given +name+, + # * using +start_re+ as start regexp + # * and, for span parsers, +span_start+ as a String that can be used in a regexp and + # which identifies the starting character(s) + # + # to the registry. The method name is automatically derived from the +name+ or can explicitly + # be set by using the +meth_name+ parameter. + def self.define_parser(name, start_re, span_start = nil, meth_name = "parse_#{name}") + raise "A parser with the name #{name} already exists!" if @@parsers.key?(name) + @@parsers[name] = Data.new(name, start_re, span_start, meth_name) + end + + # Return the Data structure for the parser +name+. + def self.parser(name = nil) + @@parsers[name] + end + + # Return +true+ if there is a parser called +name+. + def self.has_parser?(name) + @@parsers.key?(name) + end + + # Regexp for matching indentation (one tab or four spaces) + INDENT = /^(?:\t| {4})/ + # Regexp for matching the optional space (zero or up to three spaces) + OPT_SPACE = / {0,3}/ + + require 'kramdown/parser/kramdown/blank_line' + require 'kramdown/parser/kramdown/eob' + require 'kramdown/parser/kramdown/paragraph' + require 'kramdown/parser/kramdown/header' + require 'kramdown/parser/kramdown/blockquote' + require 'kramdown/parser/kramdown/table' + require 'kramdown/parser/kramdown/codeblock' + require 'kramdown/parser/kramdown/horizontal_rule' + require 'kramdown/parser/kramdown/list' + require 'kramdown/parser/kramdown/link' + require 'kramdown/parser/kramdown/extensions' + require 'kramdown/parser/kramdown/footnote' + require 'kramdown/parser/kramdown/html' + require 'kramdown/parser/kramdown/escaped_chars' + require 'kramdown/parser/kramdown/html_entity' + require 'kramdown/parser/kramdown/line_break' + require 'kramdown/parser/kramdown/typographic_symbol' + require 'kramdown/parser/kramdown/autolink' + require 'kramdown/parser/kramdown/codespan' + require 'kramdown/parser/kramdown/emphasis' + require 'kramdown/parser/kramdown/smart_quotes' + require 'kramdown/parser/kramdown/math' + require 'kramdown/parser/kramdown/abbreviation' + + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/abbreviation.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/abbreviation.rb new file mode 100644 index 0000000..d1cd290 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/abbreviation.rb @@ -0,0 +1,78 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + ABBREV_DEFINITION_START = /^#{OPT_SPACE}\*\[(.+?)\]:(.*?)\n/ + + # Parse the link definition at the current location. + def parse_abbrev_definition + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + abbrev_id, abbrev_text = @src[1], @src[2] + abbrev_text.strip! + if @root.options[:abbrev_defs][abbrev_id] + warning("Duplicate abbreviation ID '#{abbrev_id}' on line #{start_line_number} " \ + "- overwriting") + end + @tree.children << new_block_el(:eob, :abbrev_def) + @root.options[:abbrev_defs][abbrev_id] = abbrev_text + @root.options[:abbrev_attr][abbrev_id] = @tree.children.last + true + end + define_parser(:abbrev_definition, ABBREV_DEFINITION_START) + + # Correct abbreviation attributes. + def correct_abbreviations_attributes + @root.options[:abbrev_attr].keys.each do |k| + @root.options[:abbrev_attr][k] = @root.options[:abbrev_attr][k].attr + end + end + + # Replace the abbreviation text with elements. + def replace_abbreviations(el, regexps = nil) + return if @root.options[:abbrev_defs].empty? + unless regexps + sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a, b| b.length <=> a.length } + regexps = [Regexp.union(*sorted_abbrevs.map {|k| /#{Regexp.escape(k)}/ })] + regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries + end + el.children.map! do |child| + if child.type == :text && el.options[:content_model] != :raw + if child.value =~ regexps.first + result = [] + strscan = Kramdown::Utils::StringScanner.new(child.value, child.options[:location]) + text_lineno = strscan.current_line_number + while (temp = strscan.scan_until(regexps.last)) + abbr_lineno = strscan.current_line_number + abbr = strscan.scan(regexps.first) # begin of line case of abbr with \W char as first one + if abbr.nil? + temp << strscan.scan(/\W|^/) + abbr = strscan.scan(regexps.first) + end + result << Element.new(:text, temp, nil, location: text_lineno) + result << Element.new(:abbreviation, abbr, nil, location: abbr_lineno) + text_lineno = strscan.current_line_number + end + result << Element.new(:text, strscan.rest, nil, location: text_lineno) + else + child + end + else + replace_abbreviations(child, regexps) + child + end + end.flatten! + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/autolink.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/autolink.rb new file mode 100644 index 0000000..8fa974e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/autolink.rb @@ -0,0 +1,31 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + ACHARS = '[[:alnum:]]-_.' + AUTOLINK_START_STR = "<((mailto|https?|ftps?):.+?|[#{ACHARS}]+?@[#{ACHARS}]+?)>" + AUTOLINK_START = /#{AUTOLINK_START_STR}/u + + # Parse the autolink at the current location. + def parse_autolink + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + href = (@src[2].nil? ? "mailto:#{@src[1]}" : @src[1]) + el = Element.new(:a, nil, {'href' => href}, location: start_line_number) + add_text(@src[1].sub(/^mailto:/, ''), el) + @tree.children << el + end + define_parser(:autolink, AUTOLINK_START, '<') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/blank_line.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/blank_line.rb new file mode 100644 index 0000000..bb8989a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/blank_line.rb @@ -0,0 +1,30 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + BLANK_LINE = /(?>^\s*\n)+/ + + # Parse the blank line at the current postition. + def parse_blank_line + @src.pos += @src.matched_size + if (last_child = @tree.children.last) && last_child.type == :blank + last_child.value << @src.matched + else + @tree.children << new_block_el(:blank, @src.matched) + end + true + end + define_parser(:blank_line, BLANK_LINE) + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/block_boundary.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/block_boundary.rb new file mode 100644 index 0000000..daa0884 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/block_boundary.rb @@ -0,0 +1,34 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/extensions' +require 'kramdown/parser/kramdown/blank_line' +require 'kramdown/parser/kramdown/eob' + +module Kramdown + module Parser + class Kramdown + + BLOCK_BOUNDARY = /#{BLANK_LINE}|#{EOB_MARKER}|#{IAL_BLOCK_START}|\Z/ + + # Return +true+ if we are after a block boundary. + def after_block_boundary? + last_child = @tree.children.last + !last_child || last_child.type == :blank || + (last_child.type == :eob && last_child.value.nil?) || @block_ial + end + + # Return +true+ if we are before a block boundary. + def before_block_boundary? + @src.check(self.class::BLOCK_BOUNDARY) + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/blockquote.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/blockquote.rb new file mode 100644 index 0000000..8934c5a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/blockquote.rb @@ -0,0 +1,38 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/blank_line' +require 'kramdown/parser/kramdown/extensions' +require 'kramdown/parser/kramdown/eob' + +module Kramdown + module Parser + class Kramdown + + BLOCKQUOTE_START = /^#{OPT_SPACE}> ?/ + + # Parse the blockquote at the current location. + def parse_blockquote + start_line_number = @src.current_line_number + result = @src.scan(PARAGRAPH_MATCH) + until @src.match?(self.class::LAZY_END) + result << @src.scan(PARAGRAPH_MATCH) + end + result.gsub!(BLOCKQUOTE_START, '') + + el = new_block_el(:blockquote, nil, nil, location: start_line_number) + @tree.children << el + parse_blocks(el, result) + true + end + define_parser(:blockquote, BLOCKQUOTE_START) + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/codeblock.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/codeblock.rb new file mode 100644 index 0000000..b2b76d9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/codeblock.rb @@ -0,0 +1,57 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/blank_line' +require 'kramdown/parser/kramdown/extensions' +require 'kramdown/parser/kramdown/eob' +require 'kramdown/parser/kramdown/paragraph' + +module Kramdown + module Parser + class Kramdown + + CODEBLOCK_START = INDENT + CODEBLOCK_MATCH = /(?:#{BLANK_LINE}?(?:#{INDENT}[ \t]*\S.*\n)+(?:(?!#{IAL_BLOCK_START}|#{EOB_MARKER}|^#{OPT_SPACE}#{LAZY_END_HTML_STOP}|^#{OPT_SPACE}#{LAZY_END_HTML_START})^[ \t]*\S.*\n)*)*/ + + # Parse the indented codeblock at the current location. + def parse_codeblock + start_line_number = @src.current_line_number + data = @src.scan(self.class::CODEBLOCK_MATCH) + data.gsub!(/\n( {0,3}\S)/, ' \\1') + data.gsub!(INDENT, '') + @tree.children << new_block_el(:codeblock, data, nil, location: start_line_number) + true + end + define_parser(:codeblock, CODEBLOCK_START) + + FENCED_CODEBLOCK_START = /^~{3,}/ + FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^\1\2*\s*?\n/m + + # Parse the fenced codeblock at the current location. + def parse_codeblock_fenced + if @src.check(self.class::FENCED_CODEBLOCK_MATCH) + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + el = new_block_el(:codeblock, @src[5], nil, location: start_line_number, fenced: true) + lang = @src[3].to_s.strip + unless lang.empty? + el.options[:lang] = lang + el.attr['class'] = "language-#{@src[4]}" + end + @tree.children << el + true + else + false + end + end + define_parser(:codeblock_fenced, FENCED_CODEBLOCK_START) + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/codespan.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/codespan.rb new file mode 100644 index 0000000..44eafb1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/codespan.rb @@ -0,0 +1,58 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + CODESPAN_DELIMITER = /`+/ + + # Parse the codespan at the current scanner location. + def parse_codespan + start_line_number = @src.current_line_number + result = @src.scan(CODESPAN_DELIMITER) + simple = (result.length == 1) + saved_pos = @src.save_pos + + if simple && @src.pre_match =~ /\s\Z|\A\Z/ && @src.match?(/\s/) + add_text(result) + return + end + + # assign static regex to avoid allocating the same on every instance + # where +result+ equals a single-backtick. Interpolate otherwise. + if result == '`' + scan_pattern = /`/ + str_sub_pattern = /`\Z/ + else + scan_pattern = /#{result}/ + str_sub_pattern = /#{result}\Z/ + end + + if (text = @src.scan_until(scan_pattern)) + text.sub!(str_sub_pattern, '') + unless simple + text = text[1..-1] if text[0..0] == ' ' + text = text[0..-2] if text[-1..-1] == ' ' + end + @tree.children << Element.new(:codespan, text, nil, { + codespan_delimiter: result, + location: start_line_number + }) + + else + @src.revert_pos(saved_pos) + add_text(result) + end + end + define_parser(:codespan, CODESPAN_DELIMITER, '`') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/emphasis.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/emphasis.rb new file mode 100644 index 0000000..becba24 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/emphasis.rb @@ -0,0 +1,61 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + EMPHASIS_START = /(?:\*\*?|__?)/ + + # Parse the emphasis at the current location. + def parse_emphasis + start_line_number = @src.current_line_number + saved_pos = @src.save_pos + + result = @src.scan(EMPHASIS_START) + element = (result.length == 2 ? :strong : :em) + type = result[0..0] + + if (type == '_' && @src.pre_match =~ /[[:alpha:]]-?[[:alpha:]]*\z/) || @src.check(/\s/) || + @tree.type == element || @stack.any? {|el, _| el.type == element } + add_text(result) + return + end + + sub_parse = lambda do |delim, elem| + el = Element.new(elem, nil, nil, location: start_line_number) + stop_re = /#{Regexp.escape(delim)}/ + found = parse_spans(el, stop_re) do + (@src.pre_match[-1, 1] !~ /\s/) && + (elem != :em || !@src.match?(/#{Regexp.escape(delim * 2)}(?!#{Regexp.escape(delim)})/)) && + (type != '_' || !@src.match?(/#{Regexp.escape(delim)}[[:alnum:]]/)) && !el.children.empty? + end + [found, el, stop_re] + end + + found, el, stop_re = sub_parse.call(result, element) + if !found && element == :strong && @tree.type != :em + @src.revert_pos(saved_pos) + @src.pos += 1 + found, el, stop_re = sub_parse.call(type, :em) + end + if found + @src.scan(stop_re) + @tree.children << el + else + @src.revert_pos(saved_pos) + @src.pos += result.length + add_text(result) + end + end + define_parser(:emphasis, EMPHASIS_START, '\*|_') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/eob.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/eob.rb new file mode 100644 index 0000000..f151a9a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/eob.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + EOB_MARKER = /^\^\s*?\n/ + + # Parse the EOB marker at the current location. + def parse_eob_marker + @src.pos += @src.matched_size + @tree.children << new_block_el(:eob) + true + end + define_parser(:eob_marker, EOB_MARKER) + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/escaped_chars.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/escaped_chars.rb new file mode 100644 index 0000000..46d8b00 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/escaped_chars.rb @@ -0,0 +1,25 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + ESCAPED_CHARS = /\\([\\.*_+`<>()\[\]{}#!:|"'\$=-])/ + + # Parse the backslash-escaped character at the current location. + def parse_escaped_chars + @src.pos += @src.matched_size + add_text(@src[1]) + end + define_parser(:escaped_chars, ESCAPED_CHARS, '\\\\') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/extensions.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/extensions.rb new file mode 100644 index 0000000..637d0fa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/extensions.rb @@ -0,0 +1,214 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + IAL_CLASS_ATTR = 'class' + + # Parse the string +str+ and extract all attributes and add all found attributes to the hash + # +opts+. + def parse_attribute_list(str, opts) + return if str.strip.empty? || str.strip == ':' + attrs = str.scan(ALD_TYPE_ANY) + attrs.each do |key, sep, val, ref, id_and_or_class, _, _| + if ref + (opts[:refs] ||= []) << ref + elsif id_and_or_class + id_and_or_class.scan(ALD_TYPE_ID_OR_CLASS).each do |id_attr, class_attr| + if class_attr + opts[IAL_CLASS_ATTR] = "#{opts[IAL_CLASS_ATTR]} #{class_attr}".lstrip + else + opts['id'] = id_attr + end + end + else + val.gsub!(/\\(\}|#{sep})/, "\\1") + opts[key] = val + end + end + warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs.empty? + end + + # Update the +ial+ with the information from the inline attribute list +opts+. + def update_ial_with_ial(ial, opts) + (ial[:refs] ||= []).concat(opts[:refs]) if opts.key?(:refs) + opts.each do |k, v| + if k == IAL_CLASS_ATTR + ial[k] = "#{ial[k]} #{v}".lstrip + elsif k.kind_of?(String) + ial[k] = v + end + end + end + + # Parse the generic extension at the current point. The parameter +type+ can either be :block + # or :span depending whether we parse a block or span extension tag. + def parse_extension_start_tag(type) + saved_pos = @src.save_pos + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + + error_block = lambda do |msg| + warning(msg) + @src.revert_pos(saved_pos) + add_text(@src.getch) if type == :span + false + end + + if @src[4] || @src.matched == '{:/}' + name = (@src[4] ? "for '#{@src[4]}' " : '') + return error_block.call("Invalid extension stop tag #{name} found on line " \ + "#{start_line_number} - ignoring it") + end + + ext = @src[1] + opts = {} + body = nil + parse_attribute_list(@src[2] || '', opts) + + unless @src[3] + stop_re = (type == :block ? /#{EXT_BLOCK_STOP_STR % ext}/ : /#{EXT_STOP_STR % ext}/) + if (result = @src.scan_until(stop_re)) + body = result.sub!(stop_re, '') + body.chomp! if type == :block + else + return error_block.call("No stop tag for extension '#{ext}' found on line " \ + "#{start_line_number} - ignoring it") + end + end + + if !handle_extension(ext, opts, body, type, start_line_number) + error_block.call("Invalid extension with name '#{ext}' specified on line " \ + "#{start_line_number} - ignoring it") + else + true + end + end + + def handle_extension(name, opts, body, type, line_no = nil) + case name + when 'comment' + if body.kind_of?(String) + @tree.children << Element.new(:comment, body, nil, category: type, location: line_no) + end + true + when 'nomarkdown' + if body.kind_of?(String) + @tree.children << Element.new(:raw, body, nil, category: type, + location: line_no, type: opts['type'].to_s.split(/\s+/)) + end + true + when 'options' + opts.select do |k, v| + k = k.to_sym + if Kramdown::Options.defined?(k) + if @options[:forbidden_inline_options].include?(k) || + k == :forbidden_inline_options + warning("Option #{k} may not be set inline") + next false + end + + begin + val = Kramdown::Options.parse(k, v) + @options[k] = val + (@root.options[:options] ||= {})[k] = val + rescue StandardError + end + false + else + true + end + end.each do |k, _v| + warning("Unknown kramdown option '#{k}'") + end + @tree.children << new_block_el(:eob, :extension) if type == :block + true + else + false + end + end + + ALD_ID_CHARS = /[\w-]/ + ALD_ANY_CHARS = /\\\}|[^\}]/ + ALD_ID_NAME = /\w#{ALD_ID_CHARS}*/ + ALD_CLASS_NAME = /[^\s\.#]+/ + ALD_TYPE_KEY_VALUE_PAIR = /(#{ALD_ID_NAME})=("|')((?:\\\}|\\\2|[^\}\2])*?)\2/ + ALD_TYPE_CLASS_NAME = /\.(#{ALD_CLASS_NAME})/ + ALD_TYPE_ID_NAME = /#([A-Za-z][\w:-]*)/ + ALD_TYPE_ID_OR_CLASS = /#{ALD_TYPE_ID_NAME}|#{ALD_TYPE_CLASS_NAME}/ + ALD_TYPE_ID_OR_CLASS_MULTI = /((?:#{ALD_TYPE_ID_NAME}|#{ALD_TYPE_CLASS_NAME})+)/ + ALD_TYPE_REF = /(#{ALD_ID_NAME})/ + ALD_TYPE_ANY = /(?:\A|\s)(?:#{ALD_TYPE_KEY_VALUE_PAIR}|#{ALD_TYPE_REF}|#{ALD_TYPE_ID_OR_CLASS_MULTI})(?=\s|\Z)/ + ALD_START = /^#{OPT_SPACE}\{:(#{ALD_ID_NAME}):(#{ALD_ANY_CHARS}+)\}\s*?\n/ + + EXT_STOP_STR = "\\{:/(%s)?\\}" + EXT_START_STR = "\\{::(\\w+)(?:\\s(#{ALD_ANY_CHARS}*?)|)(\\/)?\\}" + EXT_BLOCK_START = /^#{OPT_SPACE}(?:#{EXT_START_STR}|#{EXT_STOP_STR % ALD_ID_NAME})\s*?\n/ + EXT_BLOCK_STOP_STR = "^#{OPT_SPACE}#{EXT_STOP_STR}\s*?\n" + + IAL_BLOCK = /\{:(?!:|\/)(#{ALD_ANY_CHARS}+)\}\s*?\n/ + IAL_BLOCK_START = /^#{OPT_SPACE}#{IAL_BLOCK}/ + + BLOCK_EXTENSIONS_START = /^#{OPT_SPACE}\{:/ + + # Parse one of the block extensions (ALD, block IAL or generic extension) at the current + # location. + def parse_block_extensions + if @src.scan(ALD_START) + parse_attribute_list(@src[2], @alds[@src[1]] ||= {}) + @tree.children << new_block_el(:eob, :ald) + true + elsif @src.check(EXT_BLOCK_START) + parse_extension_start_tag(:block) + elsif @src.scan(IAL_BLOCK_START) + if (last_child = @tree.children.last) && last_child.type != :blank && + (last_child.type != :eob || + [:link_def, :abbrev_def, :footnote_def].include?(last_child.value)) + parse_attribute_list(@src[1], last_child.options[:ial] ||= {}) + @tree.children << new_block_el(:eob, :ial) unless @src.check(IAL_BLOCK_START) + else + parse_attribute_list(@src[1], @block_ial ||= {}) + end + true + else + false + end + end + define_parser(:block_extensions, BLOCK_EXTENSIONS_START) + + EXT_SPAN_START = /#{EXT_START_STR}|#{EXT_STOP_STR % ALD_ID_NAME}/ + IAL_SPAN_START = /\{:(#{ALD_ANY_CHARS}+)\}/ + SPAN_EXTENSIONS_START = /\{:/ + + # Parse the extension span at the current location. + def parse_span_extensions + if @src.check(EXT_SPAN_START) + parse_extension_start_tag(:span) + elsif @src.check(IAL_SPAN_START) + if (last_child = @tree.children.last) && last_child.type != :text + @src.pos += @src.matched_size + attr = {} + parse_attribute_list(@src[1], attr) + update_ial_with_ial(last_child.options[:ial] ||= {}, attr) + update_attr_with_ial(last_child.attr, attr) + else + warning("Found span IAL after text - ignoring it") + add_text(@src.getch) + end + else + add_text(@src.getch) + end + end + define_parser(:span_extensions, SPAN_EXTENSIONS_START, '\{:') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/footnote.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/footnote.rb new file mode 100644 index 0000000..b45fc12 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/footnote.rb @@ -0,0 +1,64 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/extensions' +require 'kramdown/parser/kramdown/blank_line' +require 'kramdown/parser/kramdown/codeblock' + +module Kramdown + module Parser + class Kramdown + + FOOTNOTE_DEFINITION_START = /^#{OPT_SPACE}\[\^(#{ALD_ID_NAME})\]:\s*?(.*?\n#{CODEBLOCK_MATCH})/ + + # Parse the foot note definition at the current location. + def parse_footnote_definition + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + + el = Element.new(:footnote_def, nil, nil, location: start_line_number) + parse_blocks(el, @src[2].gsub(INDENT, '')) + if @footnotes[@src[1]] + warning("Duplicate footnote name '#{@src[1]}' on line #{start_line_number} - overwriting") + end + @tree.children << new_block_el(:eob, :footnote_def) + (@footnotes[@src[1]] = {})[:content] = el + @footnotes[@src[1]][:eob] = @tree.children.last + true + end + define_parser(:footnote_definition, FOOTNOTE_DEFINITION_START) + + FOOTNOTE_MARKER_START = /\[\^(#{ALD_ID_NAME})\]/ + + # Parse the footnote marker at the current location. + def parse_footnote_marker + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + fn_def = @footnotes[@src[1]] + if fn_def + if fn_def[:eob] + update_attr_with_ial(fn_def[:eob].attr, fn_def[:eob].options[:ial] || {}) + fn_def[:attr] = fn_def[:eob].attr + fn_def[:options] = fn_def[:eob].options + fn_def.delete(:eob) + end + fn_def[:marker] ||= [] + fn_def[:marker].push(Element.new(:footnote, fn_def[:content], fn_def[:attr], + fn_def[:options].merge(name: @src[1], location: start_line_number))) + @tree.children << fn_def[:marker].last + else + warning("Footnote definition for '#{@src[1]}' not found on line #{start_line_number}") + add_text(@src.matched) + end + end + define_parser(:footnote_marker, FOOTNOTE_MARKER_START, '\[') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/header.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/header.rb new file mode 100644 index 0000000..d490a46 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/header.rb @@ -0,0 +1,70 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/block_boundary' +require 'rexml/xmltokens' + +module Kramdown + module Parser + class Kramdown + + SETEXT_HEADER_START = /^#{OPT_SPACE}(?[^ \t].*)\n(?[-=])[-=]*[ \t\r\f\v]*\n/ + + # Parse the Setext header at the current location. + def parse_setext_header + return false unless after_block_boundary? + text, id = parse_header_contents + return false if text.empty? + add_header(@src["level"] == '-' ? 2 : 1, text, id) + true + end + define_parser(:setext_header, SETEXT_HEADER_START) + + ATX_HEADER_START = /^(?\#{1,6})[\t ]*(?[^ \t].*)\n/ + + # Parse the Atx header at the current location. + def parse_atx_header + return false unless after_block_boundary? + text, id = parse_header_contents + text.sub!(/(?#{REXML::XMLTokens::NAME_START_CHAR}#{REXML::XMLTokens::NAME_CHAR}*)}\z/ + + # Returns header text and optional ID. + def parse_header_contents + text = @src["contents"] + text.rstrip! + id_match = HEADER_ID.match(text) + if id_match + id = id_match["id"] + text = text[0...-id_match[0].length] + text.rstrip! + end + [text, id] + end + + def add_header(level, text, id) + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + el = new_block_el(:header, nil, nil, level: level, raw_text: text, location: start_line_number) + add_text(text, el) + el.attr['id'] = id if id + @tree.children << el + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/horizontal_rule.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/horizontal_rule.rb new file mode 100644 index 0000000..73a936d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/horizontal_rule.rb @@ -0,0 +1,27 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + HR_START = /^#{OPT_SPACE}(\*|-|_)[ \t]*\1[ \t]*\1(\1|[ \t])*\n/ + + # Parse the horizontal rule at the current location. + def parse_horizontal_rule + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + @tree.children << new_block_el(:hr, nil, nil, location: start_line_number) + true + end + define_parser(:horizontal_rule, HR_START) + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/html.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/html.rb new file mode 100644 index 0000000..03a3361 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/html.rb @@ -0,0 +1,162 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/html' + +module Kramdown + module Parser + class Kramdown + + include Kramdown::Parser::Html::Parser + + # Mapping of markdown attribute value to content model. I.e. :raw when "0", :default when "1" + # (use default content model for the HTML element), :span when "span", :block when block and + # for everything else +nil+ is returned. + HTML_MARKDOWN_ATTR_MAP = {"0" => :raw, "1" => :default, "span" => :span, "block" => :block} + + TRAILING_WHITESPACE = /[ \t]*\n/ + + def handle_kramdown_html_tag(el, closed, handle_body) + if @block_ial + el.options[:ial] = @block_ial + @block_ial = nil + end + + content_model = if @tree.type != :html_element || @tree.options[:content_model] != :raw + (@options[:parse_block_html] ? HTML_CONTENT_MODEL[el.value] : :raw) + else + :raw + end + if (val = HTML_MARKDOWN_ATTR_MAP[el.attr.delete('markdown')]) + content_model = (val == :default ? HTML_CONTENT_MODEL[el.value] : val) + end + + @src.scan(TRAILING_WHITESPACE) if content_model == :block + el.options[:content_model] = content_model + el.options[:is_closed] = closed + + if !closed && handle_body + if content_model == :block + unless parse_blocks(el) + warning("Found no end tag for '#{el.value}' (line #{el.options[:location]}) - auto-closing it") + end + elsif content_model == :span + curpos = @src.pos + if @src.scan_until(/(?=<\/#{el.value}\s*>)/mi) + add_text(extract_string(curpos...@src.pos, @src), el) + @src.scan(HTML_TAG_CLOSE_RE) + else + add_text(@src.rest, el) + @src.terminate + warning("Found no end tag for '#{el.value}' (line #{el.options[:location]}) - auto-closing it") + end + else + parse_raw_html(el, &method(:handle_kramdown_html_tag)) + end + unless @tree.type == :html_element && @tree.options[:content_model] == :raw + @src.scan(TRAILING_WHITESPACE) + end + end + end + + HTML_BLOCK_START = /^#{OPT_SPACE}<(#{REXML::Parsers::BaseParser::UNAME_STR}|!--|\/)/ + + # Parse the HTML at the current position as block-level HTML. + def parse_block_html + line = @src.current_line_number + if (result = @src.scan(HTML_COMMENT_RE)) + @tree.children << Element.new(:xml_comment, result, nil, category: :block, location: line) + @src.scan(TRAILING_WHITESPACE) + true + else + if @src.check(/^#{OPT_SPACE}#{HTML_TAG_RE}/o) && !HTML_SPAN_ELEMENTS.include?(@src[1].downcase) + @src.pos += @src.matched_size + handle_html_start_tag(line, &method(:handle_kramdown_html_tag)) + Kramdown::Parser::Html::ElementConverter.convert(@root, @tree.children.last) if @options[:html_to_native] + true + elsif @src.check(/^#{OPT_SPACE}#{HTML_TAG_CLOSE_RE}/o) && !HTML_SPAN_ELEMENTS.include?(@src[1].downcase) + name = @src[1].downcase + + if @tree.type == :html_element && @tree.value == name + @src.pos += @src.matched_size + throw :stop_block_parsing, :found + else + false + end + else + false + end + end + end + define_parser(:block_html, HTML_BLOCK_START) + + HTML_SPAN_START = /<(#{REXML::Parsers::BaseParser::UNAME_STR}|!--|\/)/ + + # Parse the HTML at the current position as span-level HTML. + def parse_span_html + line = @src.current_line_number + if (result = @src.scan(HTML_COMMENT_RE)) + @tree.children << Element.new(:xml_comment, result, nil, category: :span, location: line) + elsif (result = @src.scan(HTML_TAG_CLOSE_RE)) + warning("Found invalidly used HTML closing tag for '#{@src[1]}' on line #{line}") + add_text(result) + elsif (result = @src.scan(HTML_TAG_RE)) + tag_name = @src[1] + tag_name.downcase! if HTML_ELEMENT[tag_name.downcase] + if HTML_BLOCK_ELEMENTS.include?(tag_name) + warning("Found block HTML tag '#{tag_name}' in span-level text on line #{line}") + add_text(result) + return + end + + attrs = parse_html_attributes(@src[2], line, HTML_ELEMENT[tag_name]) + attrs.each_value {|value| value.gsub!(/\n+/, ' ') unless value.empty? } + + do_parsing = if HTML_CONTENT_MODEL[tag_name] == :raw || @tree.options[:content_model] == :raw + false + else + @options[:parse_span_html] + end + if (val = HTML_MARKDOWN_ATTR_MAP[attrs.delete('markdown')]) + if val == :block + warning("Cannot use block-level parsing in span-level HTML tag (line #{line}) " \ + "- using default mode") + elsif val == :span + do_parsing = true + elsif val == :default + do_parsing = HTML_CONTENT_MODEL[tag_name] != :raw + elsif val == :raw + do_parsing = false + end + end + + el = Element.new(:html_element, tag_name, attrs, category: :span, location: line, + content_model: (do_parsing ? :span : :raw), is_closed: !!@src[4]) + @tree.children << el + stop_re = /<\/#{Regexp.escape(tag_name)}\s*>/ + stop_re = Regexp.new(stop_re.source, Regexp::IGNORECASE) if HTML_ELEMENT[tag_name] + if !@src[4] && !HTML_ELEMENTS_WITHOUT_BODY.include?(el.value) + if parse_spans(el, stop_re, (do_parsing ? nil : [:span_html])) + @src.scan(stop_re) + else + warning("Found no end tag for '#{el.value}' (line #{line}) - auto-closing it") + add_text(@src.rest, el) + @src.terminate + end + end + Kramdown::Parser::Html::ElementConverter.convert(@root, el) if @options[:html_to_native] + else + add_text(@src.getch) + end + end + define_parser(:span_html, HTML_SPAN_START, '<') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/html_entity.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/html_entity.rb new file mode 100644 index 0000000..c89c7ba --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/html_entity.rb @@ -0,0 +1,34 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/html' + +module Kramdown + module Parser + class Kramdown + + # Parse the HTML entity at the current location. + def parse_html_entity + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + begin + value = ::Kramdown::Utils::Entities.entity(@src[1] || (@src[2]&.to_i) || @src[3].hex) + @tree.children << Element.new(:entity, value, + nil, original: @src.matched, location: start_line_number) + rescue ::Kramdown::Error + @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('amp'), + nil, location: start_line_number) + add_text(@src.matched[1..-1]) + end + end + define_parser(:html_entity, Kramdown::Parser::Html::Constants::HTML_ENTITY_RE, '&') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/line_break.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/line_break.rb new file mode 100644 index 0000000..5f85427 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/line_break.rb @@ -0,0 +1,25 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + LINE_BREAK = /( |\\\\)(?=\n)/ + + # Parse the line break at the current location. + def parse_line_break + @tree.children << Element.new(:br, nil, nil, location: @src.current_line_number) + @src.pos += @src.matched_size + end + define_parser(:line_break, LINE_BREAK, '( |\\\\)(?=\n)') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/link.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/link.rb new file mode 100644 index 0000000..9906bdd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/link.rb @@ -0,0 +1,149 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/escaped_chars' + +module Kramdown + module Parser + class Kramdown + + # Normalize the link identifier. + def normalize_link_id(id) + id.gsub(/[\s]+/, ' ').downcase + end + + LINK_DEFINITION_START = /^#{OPT_SPACE}\[([^\n\]]+)\]:[ \t]*(?:<(.*?)>|([^\n]*?\S[^\n]*?))(?:(?:[ \t]*?\n|[ \t]+?)[ \t]*?(["'])(.+?)\4)?[ \t]*?\n/ + + # Parse the link definition at the current location. + def parse_link_definition + return false if @src[3].to_s =~ /[ \t]+["']/ + @src.pos += @src.matched_size + link_id, link_url, link_title = normalize_link_id(@src[1]), @src[2] || @src[3], @src[5] + if @link_defs[link_id] + warning("Duplicate link ID '#{link_id}' on line #{@src.current_line_number} - overwriting") + end + @tree.children << new_block_el(:eob, :link_def) + @link_defs[link_id] = [link_url, link_title, @tree.children.last] + true + end + define_parser(:link_definition, LINK_DEFINITION_START) + + # This helper methods adds the approriate attributes to the element +el+ of type +a+ or +img+ + # and the element itself to the @tree. + def add_link(el, href, title, alt_text = nil, ial = nil) + el.options[:ial] = ial + update_attr_with_ial(el.attr, ial) if ial + if el.type == :a + el.attr['href'] = href + else + el.attr['src'] = href + el.attr['alt'] = alt_text + el.children.clear + end + el.attr['title'] = title if title + @tree.children << el + end + + LINK_BRACKET_STOP_RE = /(\])|!?\[/ + LINK_PAREN_STOP_RE = /(\()|(\))|\s(?=['"])/ + LINK_INLINE_ID_RE = /\s*?\[([^\]]+)?\]/ + LINK_INLINE_TITLE_RE = /\s*?(["'])(.+?)\1\s*?\)/m + LINK_START = /!?\[(?=[^^])/ + + # Parse the link at the current scanner position. This method is used to parse normal links as + # well as image links. + def parse_link + start_line_number = @src.current_line_number + result = @src.scan(LINK_START) + cur_pos = @src.pos + saved_pos = @src.save_pos + + link_type = (result =~ /^!/ ? :img : :a) + + # no nested links allowed + if link_type == :a && (@tree.type == :img || @tree.type == :a || + @stack.any? {|t, _| t && (t.type == :img || t.type == :a) }) + add_text(result) + return + end + el = Element.new(link_type, nil, nil, location: start_line_number) + + count = 1 + found = parse_spans(el, LINK_BRACKET_STOP_RE) do + count += (@src[1] ? -1 : 1) + count - el.children.select {|c| c.type == :img }.size == 0 + end + unless found + @src.revert_pos(saved_pos) + add_text(result) + return + end + alt_text = extract_string(cur_pos...@src.pos, @src).gsub(ESCAPED_CHARS, '\1') + @src.scan(LINK_BRACKET_STOP_RE) + + # reference style link or no link url + if @src.scan(LINK_INLINE_ID_RE) || !@src.check(/\(/) + emit_warning = !@src[1] + link_id = normalize_link_id(@src[1] || alt_text) + if @link_defs.key?(link_id) + link_def = @link_defs[link_id] + add_link(el, link_def[0], link_def[1], alt_text, + link_def[2] && link_def[2].options[:ial]) + else + if emit_warning + warning("No link definition for link ID '#{link_id}' found on line #{start_line_number}") + end + @src.revert_pos(saved_pos) + add_text(result) + end + return + end + + # link url in parentheses + if @src.scan(/\(<(.*?)>/) + link_url = @src[1] + if @src.scan(/\)/) + add_link(el, link_url, nil, alt_text) + return + end + else + link_url = +'' + nr_of_brackets = 0 + while (temp = @src.scan_until(LINK_PAREN_STOP_RE)) + link_url << temp + if @src[2] + nr_of_brackets -= 1 + break if nr_of_brackets == 0 + elsif @src[1] + nr_of_brackets += 1 + else + break + end + end + link_url = link_url[1..-2] + link_url.strip! + + if nr_of_brackets == 0 + add_link(el, link_url, nil, alt_text) + return + end + end + + if @src.scan(LINK_INLINE_TITLE_RE) + add_link(el, link_url, @src[2], alt_text) + else + @src.revert_pos(saved_pos) + add_text(result) + end + end + define_parser(:link, LINK_START, '!?\[') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/list.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/list.rb new file mode 100644 index 0000000..aa7c3d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/list.rb @@ -0,0 +1,285 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/blank_line' +require 'kramdown/parser/kramdown/eob' +require 'kramdown/parser/kramdown/horizontal_rule' +require 'kramdown/parser/kramdown/extensions' + +module Kramdown + module Parser + class Kramdown + + LIST_ITEM_IAL = /^\s*(?:\{:(?!(?:#{ALD_ID_NAME})?:|\/)(#{ALD_ANY_CHARS}+)\})\s*/ + LIST_ITEM_IAL_CHECK = /^#{LIST_ITEM_IAL}?\s*\n/ + + PARSE_FIRST_LIST_LINE_REGEXP_CACHE = Hash.new do |h, indentation| + indent_re = /^ {#{indentation}}/ + content_re = /^(?:(?:\t| {4}){#{indentation / 4}} {#{indentation % 4}}|(?:\t| {4}){#{indentation / 4 + 1}}).*\S.*\n/ + lazy_re = /(?!^ {0,#{[indentation, 3].min}}(?:#{IAL_BLOCK}|#{LAZY_END_HTML_STOP}|#{LAZY_END_HTML_START})).*\S.*\n/ + + h[indentation] = [content_re, lazy_re, indent_re] + end + + # Used for parsing the first line of a list item or a definition, i.e. the line with list item + # marker or the definition marker. + def parse_first_list_line(indentation, content) + if content =~ self.class::LIST_ITEM_IAL_CHECK + indentation = 4 + else + while content =~ /^ *\t/ + temp = content.scan(/^ */).first.length + indentation + content.sub!(/^( *)(\t+)/) { $1 << " " * (4 - (temp % 4) + ($2.length - 1) * 4) } + end + indentation += content[/^ */].length + end + content.sub!(/^\s*/, '') + + [content, indentation, *PARSE_FIRST_LIST_LINE_REGEXP_CACHE[indentation]] + end + + PATTERN_TAIL = /[\t| ].*?\n/ + + LIST_START_UL = /^(#{OPT_SPACE}[+*-])(#{PATTERN_TAIL})/ + LIST_START_OL = /^(#{OPT_SPACE}\d+\.)(#{PATTERN_TAIL})/ + LIST_START = /#{LIST_START_UL}|#{LIST_START_OL}/ + + # Parse the ordered or unordered list at the current location. + def parse_list + start_line_number = @src.current_line_number + type, list_start_re = (@src.check(LIST_START_UL) ? [:ul, LIST_START_UL] : [:ol, LIST_START_OL]) + list = new_block_el(type, nil, nil, location: start_line_number) + + item = nil + content_re, lazy_re, indent_re = nil + eob_found = false + nested_list_found = false + last_is_blank = false + until @src.eos? + start_line_number = @src.current_line_number + if last_is_blank && @src.check(HR_START) + break + elsif @src.scan(EOB_MARKER) + eob_found = true + break + elsif @src.scan(list_start_re) + list.options[:first_list_marker] ||= @src[1].strip + item = Element.new(:li, nil, nil, location: start_line_number) + item.value, indentation, content_re, lazy_re, indent_re = + parse_first_list_line(@src[1].length, @src[2]) + list.children << item + + item.value.sub!(self.class::LIST_ITEM_IAL) do + parse_attribute_list($1, item.options[:ial] ||= {}) + '' + end + + list_start_re = fetch_pattern(type, indentation) + nested_list_found = (item.value =~ LIST_START) + last_is_blank = false + item.value = [item.value] + elsif (result = @src.scan(content_re)) || (!last_is_blank && (result = @src.scan(lazy_re))) + result.sub!(/^(\t+)/) { " " * 4 * $1.length } + indentation_found = result.sub!(indent_re, '') + if !nested_list_found && indentation_found && result =~ LIST_START + item.value << +'' + nested_list_found = true + elsif nested_list_found && !indentation_found && result =~ LIST_START + result = " " * (indentation + 4) << result + end + item.value.last << result + last_is_blank = false + elsif (result = @src.scan(BLANK_LINE)) + nested_list_found = true + last_is_blank = true + item.value.last << result + else + break + end + end + + @tree.children << list + + last = nil + list.children.each do |it| + temp = Element.new(:temp, nil, nil, location: it.options[:location]) + + env = save_env + location = it.options[:location] + it.value.each do |val| + @src = ::Kramdown::Utils::StringScanner.new(val, location) + parse_blocks(temp) + location = @src.current_line_number + end + restore_env(env) + + it.children = temp.children + it.value = nil + + it_children = it.children + next if it_children.empty? + + # Handle the case where an EOB marker is inserted by a block IAL for the first paragraph + it_children.delete_at(1) if it_children.first.type == :p && + it_children.length >= 2 && it_children[1].type == :eob && it_children.first.options[:ial] + + if it_children.first.type == :p && + (it_children.length < 2 || it_children[1].type != :blank || + (it == list.children.last && it_children.length == 2 && !eob_found)) && + (list.children.last != it || list.children.size == 1 || + list.children[0..-2].any? {|cit| !cit.children.first || cit.children.first.type != :p || cit.children.first.options[:transparent] }) + it_children.first.children.first.value << "\n" if it_children.size > 1 && it_children[1].type != :blank + it_children.first.options[:transparent] = true + end + + last = (it_children.last.type == :blank ? it_children.pop : nil) + end + + @tree.children << last if !last.nil? && !eob_found + + true + end + define_parser(:list, LIST_START) + + DEFINITION_LIST_START = /^(#{OPT_SPACE}:)(#{PATTERN_TAIL})/ + + # Parse the ordered or unordered list at the current location. + def parse_definition_list + children = @tree.children + if !children.last || (children.length == 1 && children.last.type != :p) || + (children.length >= 2 && children[-1].type != :p && + (children[-1].type != :blank || children[-1].value != "\n" || children[-2].type != :p)) + return false + end + + first_as_para = false + deflist = new_block_el(:dl) + para = @tree.children.pop + if para.type == :blank + para = @tree.children.pop + first_as_para = true + end + # take location from preceding para which is the first definition term + deflist.options[:location] = para.options[:location] + para.children.first.value.split(/\n/).each do |term| + el = Element.new(:dt, nil, nil, location: @src.current_line_number) + term.sub!(self.class::LIST_ITEM_IAL) do + parse_attribute_list($1, el.options[:ial] ||= {}) + '' + end + el.options[:raw_text] = term + el.children << Element.new(:raw_text, term) + deflist.children << el + end + deflist.options[:ial] = para.options[:ial] + + item = nil + content_re, lazy_re, indent_re = nil + def_start_re = DEFINITION_LIST_START + last_is_blank = false + until @src.eos? + start_line_number = @src.current_line_number + if @src.scan(def_start_re) + item = Element.new(:dd, nil, nil, location: start_line_number) + item.options[:first_as_para] = first_as_para + item.value, indentation, content_re, lazy_re, indent_re = + parse_first_list_line(@src[1].length, @src[2]) + deflist.children << item + + item.value.sub!(self.class::LIST_ITEM_IAL) do |_match| + parse_attribute_list($1, item.options[:ial] ||= {}) + '' + end + + def_start_re = fetch_pattern(:dl, indentation) + first_as_para = false + last_is_blank = false + elsif @src.check(EOB_MARKER) + break + elsif (result = @src.scan(content_re)) || (!last_is_blank && (result = @src.scan(lazy_re))) + result.sub!(/^(\t+)/) { " " * ($1 ? 4 * $1.length : 0) } + result.sub!(indent_re, '') + item.value << result + first_as_para = false + last_is_blank = false + elsif (result = @src.scan(BLANK_LINE)) + first_as_para = true + item.value << result + last_is_blank = true + else + break + end + end + + last = nil + deflist.children.each do |it| + next if it.type == :dt + + parse_blocks(it, it.value) + it.value = nil + it_children = it.children + next if it_children.empty? + + last = (it_children.last.type == :blank ? it_children.pop : nil) + + if it_children.first && it_children.first.type == :p && !it.options.delete(:first_as_para) + it_children.first.children.first.value << "\n" if it_children.size > 1 + it_children.first.options[:transparent] = true + end + end + + children = @tree.children + if children.length >= 1 && children.last.type == :dl + children[-1].children.concat(deflist.children) + elsif children.length >= 2 && children[-1].type == :blank && + children[-2].type == :dl + children.pop + children[-1].children.concat(deflist.children) + else + children << deflist + end + + children << last if last + + true + end + define_parser(:definition_list, DEFINITION_LIST_START) + + private + + # precomputed patterns for indentations 1..4 and fallback expression + # to compute pattern when indentation is outside the 1..4 range. + def fetch_pattern(type, indentation) + if type == :ul + case indentation + when 1 then %r/^( {0}[+*-])(#{PATTERN_TAIL})/o + when 2 then %r/^( {0,1}[+*-])(#{PATTERN_TAIL})/o + when 3 then %r/^( {0,2}[+*-])(#{PATTERN_TAIL})/o + else %r/^( {0,3}[+*-])(#{PATTERN_TAIL})/o + end + elsif type == :ol + case indentation + when 1 then %r/^( {0}\d+\.)(#{PATTERN_TAIL})/o + when 2 then %r/^( {0,1}\d+\.)(#{PATTERN_TAIL})/o + when 3 then %r/^( {0,2}\d+\.)(#{PATTERN_TAIL})/o + else %r/^( {0,3}\d+\.)(#{PATTERN_TAIL})/o + end + elsif type == :dl + case indentation + when 1 then %r/^( {0}:)(#{PATTERN_TAIL})/o + when 2 then %r/^( {0,1}:)(#{PATTERN_TAIL})/o + when 3 then %r/^( {0,2}:)(#{PATTERN_TAIL})/o + else %r/^( {0,3}:)(#{PATTERN_TAIL})/o + end + end + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/math.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/math.rb new file mode 100644 index 0000000..32c87bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/math.rb @@ -0,0 +1,53 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/block_boundary' + +module Kramdown + module Parser + class Kramdown + + BLOCK_MATH_START = /^#{OPT_SPACE}(\\)?\$\$(.*?)\$\$(\s*?\n)?/m + + # Parse the math block at the current location. + def parse_block_math + start_line_number = @src.current_line_number + if !after_block_boundary? + return false + elsif @src[1] + @src.scan(/^#{OPT_SPACE}\\/o) if @src[3] + return false + end + + saved_pos = @src.save_pos + @src.pos += @src.matched_size + data = @src[2].strip + if before_block_boundary? + @tree.children << new_block_el(:math, data, nil, category: :block, location: start_line_number) + true + else + @src.revert_pos(saved_pos) + false + end + end + define_parser(:block_math, BLOCK_MATH_START) + + INLINE_MATH_START = /\$\$(.*?)\$\$/m + + # Parse the inline math at the current location. + def parse_inline_math + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + @tree.children << Element.new(:math, @src[1].strip, nil, category: :span, location: start_line_number) + end + define_parser(:inline_math, INLINE_MATH_START, '\$') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/paragraph.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/paragraph.rb new file mode 100644 index 0000000..d89e6a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/paragraph.rb @@ -0,0 +1,62 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/blank_line' +require 'kramdown/parser/kramdown/extensions' +require 'kramdown/parser/kramdown/eob' +require 'kramdown/parser/kramdown/list' +require 'kramdown/parser/kramdown/html' + +module Kramdown + module Parser + class Kramdown + + LAZY_END_HTML_SPAN_ELEMENTS = HTML_SPAN_ELEMENTS + %w[script] + LAZY_END_HTML_START = /<(?>(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR})/ + LAZY_END_HTML_STOP = /<\/(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR}\s*>/m + + LAZY_END = /#{BLANK_LINE}|#{IAL_BLOCK_START}|#{EOB_MARKER}|^#{OPT_SPACE}#{LAZY_END_HTML_STOP}|^#{OPT_SPACE}#{LAZY_END_HTML_START}|\Z/ + + PARAGRAPH_START = /^#{OPT_SPACE}[^ \t].*?\n/ + PARAGRAPH_MATCH = /^.*?\n/ + PARAGRAPH_END = /#{LAZY_END}|#{DEFINITION_LIST_START}/ + + # Parse the paragraph at the current location. + def parse_paragraph + pos = @src.pos + start_line_number = @src.current_line_number + result = @src.scan(PARAGRAPH_MATCH) + until @src.match?(paragraph_end) + result << @src.scan(PARAGRAPH_MATCH) + end + result.rstrip! + if (last_child = @tree.children.last) && last_child.type == :p + last_item_in_para = last_child.children.last + if last_item_in_para && last_item_in_para.type == @text_type + joiner = (extract_string((pos - 3)...pos, @src) == " \n" ? " \n" : "\n") + last_item_in_para.value << joiner << result + else + add_text(result, last_child) + end + else + @tree.children << new_block_el(:p, nil, nil, location: start_line_number) + result.lstrip! + add_text(result, @tree.children.last) + end + true + end + define_parser(:paragraph, PARAGRAPH_START) + + def paragraph_end + self.class::PARAGRAPH_END + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/smart_quotes.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/smart_quotes.rb new file mode 100644 index 0000000..5c17013 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/smart_quotes.rb @@ -0,0 +1,174 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# +#-- +# Parts of this file are based on code from RubyPants: +# +# = RubyPants -- SmartyPants ported to Ruby +# +# Ported by Christian Neukirchen +# Copyright (C) 2004 Christian Neukirchen +# +# Incooporates ideas, comments and documentation by Chad Miller +# Copyright (C) 2004 Chad Miller +# +# Original SmartyPants by John Gruber +# Copyright (C) 2003 John Gruber +# +# +# = RubyPants -- SmartyPants ported to Ruby +# +# +# [snip] +# +# == Authors +# +# John Gruber did all of the hard work of writing this software in +# Perl for Movable Type and almost all of this useful documentation. +# Chad Miller ported it to Python to use with Pyblosxom. +# +# Christian Neukirchen provided the Ruby port, as a general-purpose +# library that follows the *Cloth API. +# +# +# == Copyright and License +# +# === SmartyPants license: +# +# Copyright (c) 2003 John Gruber +# (http://daringfireball.net) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * 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. +# +# * Neither the name "SmartyPants" nor the names of its contributors +# may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# 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 owner 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. +# +# === RubyPants license +# +# RubyPants is a derivative work of SmartyPants and smartypants.py. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * 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. +# +# 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 owner 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. +# +# == Links +# +# John Gruber:: http://daringfireball.net +# SmartyPants:: http://daringfireball.net/projects/smartypants +# +# Chad Miller:: http://web.chad.org +# +# Christian Neukirchen:: http://kronavita.de/chris +# +#++ +# + +module Kramdown + module Parser + class Kramdown + + SQ_PUNCT = '[!"#\$\%\'()*+,\-.\/:;<=>?\@\[\\\\\]\^_`{|}~]' + SQ_CLOSE = %![^\ \\\\\t\r\n\\[{(-]! + + SQ_RULES = [ + [/("|')(?=[_*]{1,2}\S)/, [:lquote1]], + [/("|')(?=#{SQ_PUNCT}(?!\.\.)\B)/, [:rquote1]], + # Special case for double sets of quotes, e.g.: + #

He said, "'Quoted' words in a larger quote."

+ [/(\s?)"'(?=\w)/, [1, :ldquo, :lsquo]], + [/(\s?)'"(?=\w)/, [1, :lsquo, :ldquo]], + # Special case for decade abbreviations (the '80s): + [/(\s?)'(?=\d\ds)/, [1, :rsquo]], + + # Get most opening single/double quotes: + [/(\s)('|")(?=\w)/, [1, :lquote2]], + # Single/double closing quotes: + [/(#{SQ_CLOSE})('|")/, [1, :rquote2]], + # Special case for e.g. "Custer's Last Stand." + [/("|')(?=\s|s\b|$)/, [:rquote1]], + # Any remaining single quotes should be opening ones: + [/(.?)'/m, [1, :lsquo]], + [/(.?)"/m, [1, :ldquo]], + ] # '" + + SQ_SUBSTS = { + [:rquote1, '"'] => :rdquo, + [:rquote1, "'"] => :rsquo, + [:rquote2, '"'] => :rdquo, + [:rquote2, "'"] => :rsquo, + [:lquote1, '"'] => :ldquo, + [:lquote1, "'"] => :lsquo, + [:lquote2, '"'] => :ldquo, + [:lquote2, "'"] => :lsquo, + } + SMART_QUOTES_RE = /[^\\]?["']/ + + # Parse the smart quotes at current location. + def parse_smart_quotes + start_line_number = @src.current_line_number + substs = SQ_RULES.find {|reg, _subst| @src.scan(reg) }[1] + substs.each do |subst| + if subst.kind_of?(Integer) + add_text(@src[subst]) + else + val = SQ_SUBSTS[[subst, @src[subst.to_s[-1, 1].to_i]]] || subst + @tree.children << Element.new(:smart_quote, val, nil, location: start_line_number) + end + end + end + define_parser(:smart_quotes, SMART_QUOTES_RE, '[^\\\\]?["\']') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/table.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/table.rb new file mode 100644 index 0000000..68be6b4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/table.rb @@ -0,0 +1,171 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser/kramdown/block_boundary' + +module Kramdown + module Parser + class Kramdown + + TABLE_SEP_LINE = /^([+|: \t-]*?-[+|: \t-]*?)[ \t]*\n/ + TABLE_HSEP_ALIGN = /[ \t]?(:?)-+(:?)[ \t]?/ + TABLE_FSEP_LINE = /^[+|: \t=]*?=[+|: \t=]*?[ \t]*\n/ + TABLE_ROW_LINE = /^(.*?)[ \t]*\n/ + TABLE_PIPE_CHECK = /(?:\||.*?[^\\\n]\|)/ + TABLE_LINE = /#{TABLE_PIPE_CHECK}.*?\n/ + TABLE_START = /^#{OPT_SPACE}(?=\S)#{TABLE_LINE}/ + + # Parse the table at the current location. + def parse_table + return false unless after_block_boundary? + + saved_pos = @src.save_pos + orig_pos = @src.pos + table = new_block_el(:table, nil, nil, alignment: [], location: @src.current_line_number) + leading_pipe = (@src.check(TABLE_LINE) =~ /^\s*\|/) + @src.scan(TABLE_SEP_LINE) + + rows = [] + has_footer = false + columns = 0 + + add_container = lambda do |type, force| + if !has_footer || type != :tbody || force + cont = Element.new(type) + cont.children, rows = rows, [] + table.children << cont + end + end + + until @src.eos? + break unless @src.check(TABLE_LINE) + if @src.scan(TABLE_SEP_LINE) + if rows.empty? + # nothing to do, ignoring multiple consecutive separator lines + elsif table.options[:alignment].empty? && !has_footer + add_container.call(:thead, false) + table.options[:alignment] = @src[1].scan(TABLE_HSEP_ALIGN).map do |left, right| + (left.empty? && right.empty? && :default) || (right.empty? && :left) || + (left.empty? && :right) || :center + end + else # treat as normal separator line + add_container.call(:tbody, false) + end + elsif @src.scan(TABLE_FSEP_LINE) + add_container.call(:tbody, true) unless rows.empty? + has_footer = true + elsif @src.scan(TABLE_ROW_LINE) + trow = Element.new(:tr) + + # parse possible code spans on the line and correctly split the line into cells + env = save_env + cells = [] + @src[1].split(/(.*?<\/code>)/).each_with_index do |str, i| + if i.odd? + (cells.empty? ? cells : cells.last) << str + else + reset_env(src: Kramdown::Utils::StringScanner.new(str, @src.current_line_number)) + root = Element.new(:root) + parse_spans(root, nil, [:codespan]) + + root.children.each do |c| + if c.type == :raw_text + f, *l = c.value.split(/(? 1}#{c.value}#{' ' if delim.size > 1}#{delim}" + (cells.empty? ? cells : cells.last) << tmp + end + end + end + end + restore_env(env) + + cells.shift if leading_pipe && cells.first.strip.empty? + cells.pop if cells.last.strip.empty? + cells.each do |cell_text| + tcell = Element.new(:td) + tcell.children << Element.new(:raw_text, cell_text.strip) + trow.children << tcell + end + columns = [columns, cells.length].max + rows << trow + else + break + end + end + + unless before_block_boundary? + @src.revert_pos(saved_pos) + return false + end + + # Parse all lines of the table with the code span parser + env = save_env + l_src = ::Kramdown::Utils::StringScanner.new(extract_string(orig_pos...(@src.pos - 1), @src), + @src.current_line_number) + reset_env(src: l_src) + root = Element.new(:root) + parse_spans(root, nil, [:codespan, :span_html]) + restore_env(env) + + # Check if each line has at least one unescaped pipe that is not inside a code span/code + # HTML element + # Note: It doesn't matter that we parse *all* span HTML elements because the row splitting + # algorithm above only takes elements into account! + pipe_on_line = false + while (c = root.children.shift) + next unless (lines = c.value) + lines = lines.split("\n") + if c.type == :codespan + if lines.size > 2 || (lines.size == 2 && !pipe_on_line) + break + elsif lines.size == 2 && pipe_on_line + pipe_on_line = false + end + else + break if lines.size > 1 && !pipe_on_line && lines.first !~ /^#{TABLE_PIPE_CHECK}/o + pipe_on_line = (lines.size > 1 ? false : pipe_on_line) || (lines.last =~ /^#{TABLE_PIPE_CHECK}/o) + end + end + @src.revert_pos(saved_pos) and return false unless pipe_on_line + + add_container.call(has_footer ? :tfoot : :tbody, false) unless rows.empty? + + if table.children.none? {|el| el.type == :tbody } + warning("Found table without body on line #{table.options[:location]} - ignoring it") + @src.revert_pos(saved_pos) + return false + end + + # adjust all table rows to have equal number of columns, same for alignment defs + table.children.each do |kind| + kind.children.each do |row| + (columns - row.children.length).times do + row.children << Element.new(:td) + end + end + end + if table.options[:alignment].length > columns + table.options[:alignment] = table.options[:alignment][0...columns] + else + table.options[:alignment] += [:default] * (columns - table.options[:alignment].length) + end + + @tree.children << table + + true + end + define_parser(:table, TABLE_START) + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/typographic_symbol.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/typographic_symbol.rb new file mode 100644 index 0000000..095c8d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/typographic_symbol.rb @@ -0,0 +1,44 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Parser + class Kramdown + + TYPOGRAPHIC_SYMS = [['---', :mdash], ['--', :ndash], ['...', :hellip], + ['\\<<', '<<'], ['\\>>', '>>'], + ['<< ', :laquo_space], [' >>', :raquo_space], + ['<<', :laquo], ['>>', :raquo]] + TYPOGRAPHIC_SYMS_SUBST = Hash[*TYPOGRAPHIC_SYMS.flatten] + TYPOGRAPHIC_SYMS_RE = /#{TYPOGRAPHIC_SYMS.map {|k, _v| Regexp.escape(k) }.join('|')}/ + + # Parse the typographic symbols at the current location. + def parse_typographic_syms + start_line_number = @src.current_line_number + @src.pos += @src.matched_size + val = TYPOGRAPHIC_SYMS_SUBST[@src.matched] + if val.kind_of?(Symbol) + @tree.children << Element.new(:typographic_sym, val, nil, location: start_line_number) + elsif @src.matched == '\\<<' + @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('lt'), + nil, location: start_line_number) + @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('lt'), + nil, location: start_line_number) + else + @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('gt'), + nil, location: start_line_number) + @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('gt'), + nil, location: start_line_number) + end + end + define_parser(:typographic_syms, TYPOGRAPHIC_SYMS_RE, '--|\\.\\.\\.|(?:\\\\| )?(?:<<|>>)') + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/markdown.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/markdown.rb new file mode 100644 index 0000000..9f36758 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/parser/markdown.rb @@ -0,0 +1,57 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'kramdown/parser' + +module Kramdown + + module Parser + + # Used for parsing a document in Markdown format. + # + # This parser is based on the kramdown parser and removes the parser methods for the additional + # non-Markdown features. However, since some things are handled differently by the kramdown + # parser methods (like deciding when a list item contains just text), this parser differs from + # real Markdown parsers in some respects. + # + # Note, though, that the parser basically fails just one of the Markdown test cases (some others + # also fail but those failures are negligible). + class Markdown < Kramdown + + # Array with all the parsing methods that should be removed from the standard kramdown parser. + EXTENDED = [:codeblock_fenced, :table, :definition_list, :footnote_definition, + :abbrev_definition, :block_math, :block_extensions, + :footnote_marker, :smart_quotes, :inline_math, :span_extensions, :typographic_syms] + + def initialize(source, options) # :nodoc: + super + @block_parsers.delete_if {|i| EXTENDED.include?(i) } + @span_parsers.delete_if {|i| EXTENDED.include?(i) } + end + + # :stopdoc: + + BLOCK_BOUNDARY = /#{BLANK_LINE}|#{EOB_MARKER}|\Z/ + LAZY_END = /#{BLANK_LINE}|#{EOB_MARKER}|^#{OPT_SPACE}#{LAZY_END_HTML_STOP}| + ^#{OPT_SPACE}#{LAZY_END_HTML_START}|\Z/x + CODEBLOCK_MATCH = /(?:#{BLANK_LINE}?(?:#{INDENT}[ \t]*\S.*\n)+)*/ + PARAGRAPH_END = LAZY_END + + IAL_RAND_CHARS = (('a'..'z').to_a + ('0'..'9').to_a) + IAL_RAND_STRING = (1..20).collect { IAL_RAND_CHARS[rand(IAL_RAND_CHARS.size)] }.join + LIST_ITEM_IAL = /^\s*(#{IAL_RAND_STRING})?\s*\n/ + IAL_SPAN_START = LIST_ITEM_IAL + + # :startdoc: + + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils.rb new file mode 100644 index 0000000..5928def --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils.rb @@ -0,0 +1,45 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + + # == \Utils Module + # + # This module contains utility class/modules/methods that can be used by both parsers and + # converters. + module Utils + + autoload :Entities, 'kramdown/utils/entities' + autoload :Html, 'kramdown/utils/html' + autoload :Unidecoder, 'kramdown/utils/unidecoder' + autoload :StringScanner, 'kramdown/utils/string_scanner' + autoload :Configurable, 'kramdown/utils/configurable' + autoload :LRUCache, 'kramdown/utils/lru_cache' + + # Treat +name+ as if it were snake cased (e.g. snake_case) and camelize it (e.g. SnakeCase). + def self.camelize(name) + name.split('_').inject(+'') {|s, x| s << x[0..0].upcase << x[1..-1] } + end + + # Treat +name+ as if it were camelized (e.g. CamelizedName) and snake-case it (e.g. camelized_name). + def self.snake_case(name) + name = name.dup + name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + name.gsub!(/([a-z])([A-Z])/, '\1_\2') + name.downcase! + name + end + + def self.deep_const_get(str) + ::Object.const_get(str) + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/configurable.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/configurable.rb new file mode 100644 index 0000000..2989493 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/configurable.rb @@ -0,0 +1,45 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Utils + + # Methods for registering configurable extensions. + module Configurable + + # Create a new configurable extension called +name+. + # + # Three methods will be defined on the calling object which allow to use this configurable + # extension: + # + # configurables:: Returns a hash of hashes that is used to store all configurables of the + # object. + # + # (ext_name):: Return the configured extension +ext_name+. + # + # add_(ext_name, data=nil, &block):: Define an extension +ext_name+ by specifying either + # the data as argument or by using a block. + def configurable(name) + unless respond_to?(:configurables) + singleton_class.send(:define_method, :configurables) do + @_configurables ||= Hash.new {|h, k| h[k] = {} } + end + end + singleton_class.send(:define_method, name) do |data| + configurables[name][data] + end + singleton_class.send(:define_method, "add_#{name}".intern) do |data, *args, &block| + configurables[name][data] = args.first || block + end + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/entities.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/entities.rb new file mode 100644 index 0000000..e0cc8a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/entities.rb @@ -0,0 +1,344 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + + module Utils + + # Provides convenience methods for handling named and numeric entities. + module Entities + + # Represents an entity that has a +code_point+ and +name+. + Entity = Struct.new(:code_point, :name) do + # Return the UTF8 representation of the entity. + def char + [code_point].pack('U*') rescue nil + end + end + + # Array of arrays. Each sub-array specifies a code point and the associated name. + # + # This table is not used directly -- Entity objects are automatically created from it and put + # into a Hash map when this file is loaded. + ENTITY_TABLE = [ + [913, 'Alpha'], + [914, 'Beta'], + [915, 'Gamma'], + [916, 'Delta'], + [917, 'Epsilon'], + [918, 'Zeta'], + [919, 'Eta'], + [920, 'Theta'], + [921, 'Iota'], + [922, 'Kappa'], + [923, 'Lambda'], + [924, 'Mu'], + [925, 'Nu'], + [926, 'Xi'], + [927, 'Omicron'], + [928, 'Pi'], + [929, 'Rho'], + [931, 'Sigma'], + [932, 'Tau'], + [933, 'Upsilon'], + [934, 'Phi'], + [935, 'Chi'], + [936, 'Psi'], + [937, 'Omega'], + [945, 'alpha'], + [946, 'beta'], + [947, 'gamma'], + [948, 'delta'], + [949, 'epsilon'], + [950, 'zeta'], + [951, 'eta'], + [952, 'theta'], + [953, 'iota'], + [954, 'kappa'], + [955, 'lambda'], + [956, 'mu'], + [957, 'nu'], + [958, 'xi'], + [959, 'omicron'], + [960, 'pi'], + [961, 'rho'], + [963, 'sigma'], + [964, 'tau'], + [965, 'upsilon'], + [966, 'phi'], + [967, 'chi'], + [968, 'psi'], + [969, 'omega'], + [962, 'sigmaf'], + [977, 'thetasym'], + [978, 'upsih'], + [982, 'piv'], + [8204, 'zwnj'], + [8205, 'zwj'], + [8206, 'lrm'], + [8207, 'rlm'], + [8230, 'hellip'], + [8242, 'prime'], + [8243, 'Prime'], + [8254, 'oline'], + [8260, 'frasl'], + [8472, 'weierp'], + [8465, 'image'], + [8476, 'real'], + [8501, 'alefsym'], + [8226, 'bull'], + [8482, 'trade'], + [8592, 'larr'], + [8594, 'rarr'], + [8593, 'uarr'], + [8595, 'darr'], + [8596, 'harr'], + [8629, 'crarr'], + [8657, 'uArr'], + [8659, 'dArr'], + [8656, 'lArr'], + [8658, 'rArr'], + [8660, 'hArr'], + [8704, 'forall'], + [8706, 'part'], + [8707, 'exist'], + [8709, 'empty'], + [8711, 'nabla'], + [8712, 'isin'], + [8715, 'ni'], + [8713, 'notin'], + [8721, 'sum'], + [8719, 'prod'], + [8722, 'minus'], + [8727, 'lowast'], + [8730, 'radic'], + [8733, 'prop'], + [8734, 'infin'], + [8736, 'ang'], + [8743, 'and'], + [8744, 'or'], + [8745, 'cap'], + [8746, 'cup'], + [8747, 'int'], + [8756, 'there4'], + [8764, 'sim'], + [8776, 'asymp'], + [8773, 'cong'], + [8800, 'ne'], + [8801, 'equiv'], + [8804, 'le'], + [8805, 'ge'], + [8834, 'sub'], + [8835, 'sup'], + [8838, 'sube'], + [8839, 'supe'], + [8836, 'nsub'], + [8853, 'oplus'], + [8855, 'otimes'], + [8869, 'perp'], + [8901, 'sdot'], + [8942, 'vellip'], + [8968, 'rceil'], + [8969, 'lceil'], + [8970, 'lfloor'], + [8971, 'rfloor'], + [9001, 'rang'], + [9002, 'lang'], + [9674, 'loz'], + [9824, 'spades'], + [9827, 'clubs'], + [9829, 'hearts'], + [9830, 'diams'], + [38, 'amp'], + [34, 'quot'], + [39, 'apos'], + [169, 'copy'], + [60, 'lt'], + [62, 'gt'], + [338, 'OElig'], + [339, 'oelig'], + [352, 'Scaron'], + [353, 'scaron'], + [376, 'Yuml'], + [710, 'circ'], + [732, 'tilde'], + [8211, 'ndash'], + [8212, 'mdash'], + [8216, 'lsquo'], + [8217, 'rsquo'], + [8220, 'ldquo'], + [8221, 'rdquo'], + [8224, 'dagger'], + [8225, 'Dagger'], + [8240, 'permil'], + [8364, 'euro'], + [8249, 'lsaquo'], + [8250, 'rsaquo'], + [160, 'nbsp'], + [161, 'iexcl'], + [163, 'pound'], + [164, 'curren'], + [165, 'yen'], + [166, 'brvbar'], + [167, 'sect'], + [168, 'uml'], + [171, 'laquo'], + [187, 'raquo'], + [174, 'reg'], + [170, 'ordf'], + [172, 'not'], + [173, 'shy'], + [175, 'macr'], + [176, 'deg'], + [177, 'plusmn'], + [180, 'acute'], + [181, 'micro'], + [182, 'para'], + [183, 'middot'], + [184, 'cedil'], + [186, 'ordm'], + [162, 'cent'], + [185, 'sup1'], + [178, 'sup2'], + [179, 'sup3'], + [189, 'frac12'], + [188, 'frac14'], + [190, 'frac34'], + [191, 'iquest'], + [192, 'Agrave'], + [193, 'Aacute'], + [194, 'Acirc'], + [195, 'Atilde'], + [196, 'Auml'], + [197, 'Aring'], + [198, 'AElig'], + [199, 'Ccedil'], + [200, 'Egrave'], + [201, 'Eacute'], + [202, 'Ecirc'], + [203, 'Euml'], + [204, 'Igrave'], + [205, 'Iacute'], + [206, 'Icirc'], + [207, 'Iuml'], + [208, 'ETH'], + [209, 'Ntilde'], + [210, 'Ograve'], + [211, 'Oacute'], + [212, 'Ocirc'], + [213, 'Otilde'], + [214, 'Ouml'], + [215, 'times'], + [216, 'Oslash'], + [217, 'Ugrave'], + [218, 'Uacute'], + [219, 'Ucirc'], + [220, 'Uuml'], + [221, 'Yacute'], + [222, 'THORN'], + [223, 'szlig'], + [224, 'agrave'], + [225, 'aacute'], + [226, 'acirc'], + [227, 'atilde'], + [228, 'auml'], + [229, 'aring'], + [230, 'aelig'], + [231, 'ccedil'], + [232, 'egrave'], + [233, 'eacute'], + [234, 'ecirc'], + [235, 'euml'], + [236, 'igrave'], + [237, 'iacute'], + [238, 'icirc'], + [239, 'iuml'], + [240, 'eth'], + [241, 'ntilde'], + [242, 'ograve'], + [243, 'oacute'], + [244, 'ocirc'], + [245, 'otilde'], + [246, 'ouml'], + [247, 'divide'], + [248, 'oslash'], + [249, 'ugrave'], + [250, 'uacute'], + [251, 'ucirc'], + [252, 'uuml'], + [253, 'yacute'], + [254, 'thorn'], + [255, 'yuml'], + + [8218, 'sbquo'], + [402, 'fnof'], + [8222, 'bdquo'], + + [128, 8364], + [130, 8218], + [131, 402], + [132, 8222], + [133, 8230], + [134, 8224], + [135, 8225], + [136, 710], + [137, 8240], + [138, 352], + [139, 8249], + [140, 338], + [142, 381], + [145, 8216], + [146, 8217], + [147, 8220], + [148, 8221], + [149, 8226], + [150, 8211], + [151, 8212], + [152, 732], + [153, 8482], + [154, 353], + [155, 8250], + [156, 339], + [158, 382], + [159, 376], + + [8194, 'ensp'], + [8195, 'emsp'], + [8201, 'thinsp'], + ] + + # Contains the mapping of code point (or name) to the actual Entity object. + ENTITY_MAP = Hash.new do |h, k| + if k.kind_of?(Integer) + h[k] = Entity.new(k, nil) + else + raise Kramdown::Error, "Can't handle generic non-integer character reference '#{k}'" + end + end + + ENTITY_TABLE.each do |code_point, data| + if data.kind_of?(String) + ENTITY_MAP[code_point] = ENTITY_MAP[data] = Entity.new(code_point, data) + else + ENTITY_MAP[code_point] = ENTITY_MAP[data] + end + end + + # Return the entity for the given code point or name +point_or_name+. + def entity(point_or_name) + ENTITY_MAP[point_or_name] + end + + module_function :entity + + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/html.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/html.rb new file mode 100644 index 0000000..5f2cd9b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/html.rb @@ -0,0 +1,84 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'rexml/parsers/baseparser' + +module Kramdown + + module Utils + + # Provides convenience methods for HTML related tasks. + # + # *Note* that this module has to be mixed into a class that has a @root (containing an element + # of type :root) and an @options (containing an options hash) instance variable so that some of + # the methods can work correctly. + module Html + + # Convert the entity +e+ to a string. The optional parameter +original+ may contain the + # original representation of the entity. + # + # This method uses the option +entity_output+ to determine the output form for the entity. + def entity_to_str(e, original = nil) + entity_output = @options[:entity_output] + + if entity_output == :as_char && + (c = e.char.encode(@root.options[:encoding]) rescue nil) && + ((c = e.char) == '"' || !ESCAPE_MAP.key?(c)) + c + elsif (entity_output == :as_input || entity_output == :as_char) && original + original + elsif (entity_output == :symbolic || ESCAPE_MAP.key?(e.char)) && !e.name.nil? + "&#{e.name};" + else # default to :numeric + "&##{e.code_point};" + end + end + + # Return the HTML representation of the attributes +attr+. + def html_attributes(attr) + return '' if attr.empty? + + attr.map do |k, v| + v.nil? || (k == 'id' && v.strip.empty?) ? '' : " #{k}=\"#{escape_html(v.to_s, :attribute)}\"" + end.join('') + end + + # :stopdoc: + ESCAPE_MAP = { + '<' => '<', + '>' => '>', + '&' => '&', + '"' => '"', + } + ESCAPE_ALL_RE = /<|>|&/ + ESCAPE_TEXT_RE = Regexp.union(REXML::Parsers::BaseParser::REFERENCE_RE, /<|>|&/) + ESCAPE_ATTRIBUTE_RE = Regexp.union(REXML::Parsers::BaseParser::REFERENCE_RE, /<|>|&|"/) + ESCAPE_RE_FROM_TYPE = {all: ESCAPE_ALL_RE, text: ESCAPE_TEXT_RE, attribute: ESCAPE_ATTRIBUTE_RE} + # :startdoc: + + # Escape the special HTML characters in the string +str+. The parameter +type+ specifies what + # is escaped: :all - all special HTML characters except the quotation mark as well as + # entities, :text - all special HTML characters except the quotation mark but no entities and + # :attribute - all special HTML characters including the quotation mark but no entities. + def escape_html(str, type = :all) + str.gsub(ESCAPE_RE_FROM_TYPE[type]) {|m| ESCAPE_MAP[m] || m } + end + + REDUNDANT_LINE_BREAK_REGEX = /([\p{Han}\p{Hiragana}\p{Katakana}]+)\n([\p{Han}\p{Hiragana}\p{Katakana}]+)/u + def fix_cjk_line_break(str) + while str.gsub!(REDUNDANT_LINE_BREAK_REGEX, '\1\2') + end + str + end + + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/lru_cache.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/lru_cache.rb new file mode 100644 index 0000000..32549fb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/lru_cache.rb @@ -0,0 +1,41 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + module Utils + + # A simple least recently used (LRU) cache. + # + # The cache relies on the fact that Ruby's Hash class maintains insertion order. So deleting + # and re-inserting a key-value pair on access moves the key to the last position. When an + # entry is added and the cache is full, the first entry is removed. + class LRUCache + + # Creates a new LRUCache that can hold +size+ entries. + def initialize(size) + @size = size + @cache = {} + end + + # Returns the stored value for +key+ or +nil+ if no value was stored under the key. + def [](key) + (val = @cache.delete(key)).nil? ? nil : @cache[key] = val + end + + # Stores the +value+ under the +key+. + def []=(key, value) + @cache.delete(key) + @cache[key] = value + @cache.shift if @cache.length > @size + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/string_scanner.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/string_scanner.rb new file mode 100644 index 0000000..2ef194e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/string_scanner.rb @@ -0,0 +1,81 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'strscan' + +module Kramdown + module Utils + + # This patched StringScanner adds line number information for current scan position and a + # start_line_number override for nested StringScanners. + class StringScanner < ::StringScanner + + # The start line number. Used for nested StringScanners that scan a sub-string of the source + # document. The kramdown parser uses this, e.g., for span level parsers. + attr_reader :start_line_number + + # Takes the start line number as optional second argument. + # + # Note: The original second argument is no longer used so this should be safe. + def initialize(string, start_line_number = 1) + super(string) + @start_line_number = start_line_number || 1 + @previous_pos = 0 + @previous_line_number = @start_line_number + end + + # Sets the byte position of the scan pointer. + # + # Note: This also resets some internal variables, so always use pos= when setting the position + # and don't use any other method for that! + def pos=(pos) + if self.pos > pos + @previous_line_number = @start_line_number + @previous_pos = 0 + end + super + end + + # Return information needed to revert the byte position of the string scanner in a performant + # way. + # + # The returned data can be fed to #revert_pos to revert the position to the saved one. + # + # Note: Just saving #pos won't be enough. + def save_pos + [pos, @previous_pos, @previous_line_number] + end + + # Revert the position to one saved by #save_pos. + def revert_pos(data) + self.pos = data[0] + @previous_pos, @previous_line_number = data[1], data[2] + end + + # Returns the line number for current charpos. + # + # NOTE: Requires that all line endings are normalized to '\n' + # + # NOTE: Normally we'd have to add one to the count of newlines to get the correct line number. + # However we add the one indirectly by using a one-based start_line_number. + def current_line_number + # Not using string[@previous_pos..best_pos].count('\n') because it is slower + strscan = ::StringScanner.new(string) + strscan.pos = @previous_pos + old_pos = pos + 1 + @previous_line_number += 1 while strscan.skip_until(/\n/) && strscan.pos <= old_pos + + @previous_pos = (eos? ? pos : pos + 1) + @previous_line_number + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/unidecoder.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/unidecoder.rb new file mode 100644 index 0000000..6b196a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/utils/unidecoder.rb @@ -0,0 +1,50 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# +# This file is based on code originally from the Stringex library and needs the data files from +# Stringex to work correctly. + +module Kramdown + module Utils + + # Provides the ability to tranliterate Unicode strings into plain ASCII ones. + module Unidecoder + + gem 'stringex' + path = $:.find do |dir| + File.directory?(File.join(File.expand_path(dir), "stringex", "unidecoder_data")) + end + + if !path + def self.decode(string) + string + end + else + + CODEPOINTS = Hash.new do |h, k| + h[k] = YAML.load_file(File.join(path, "stringex", "unidecoder_data", "#{k}.yml")) + end + + # Transliterate string from Unicode into ASCII. + def self.decode(string) + string.gsub(/[^\x00-\x7f]/u) do |codepoint| + begin + unpacked = codepoint.unpack("U")[0] + CODEPOINTS[sprintf("x%02x", unpacked >> 8)][unpacked & 255] + rescue StandardError + "?" + end + end + end + + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/version.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/version.rb new file mode 100644 index 0000000..c48916b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/lib/kramdown/version.rb @@ -0,0 +1,15 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +module Kramdown + + # The kramdown version. + VERSION = '2.4.0' + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/man/man1/kramdown.1 b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/man/man1/kramdown.1 new file mode 100644 index 0000000..cfed337 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/man/man1/kramdown.1 @@ -0,0 +1,355 @@ +.\" generated by kramdown +.TH "KRAMDOWN" "1" "January 2019" +.SH NAME +kramdown \- a fast, pure\-Ruby Markdown\-superset converter +.SH "SYNOPSIS" +\fBkramdown\fP [\fIoptions\fP] [\fIFILE\fP\.\.\.] +.SH "DESCRIPTION" +kramdown is primarily used for parsing a superset of Markdown and converting it to different output formats\. It supports standard Markdown (with some minor modifications) and various extensions like tables and definition lists\. Due to its modular architecture it also allows other input formats than Markdown, for example, HTML or Github Flavored Markdown\. +.P +If \fIFILE\fP is not specified, kramdown reads from the standard input\. The result is written to the standard output\. +.P +There are two sets of options that kramdown accepts: The first one includes the options that are used directly by the kramdown binary\. The second set of options controls how kramdown parses and converts its input\. +.P +Default values for this second set can be set using YAML via the configuration file \fBkramdownrc\fP\&\. Note that configuration option names use underscores, not dashes (dashes are just used in the CLI options names), and boolean options do not have a \fBno\fP variant but a value of \fBtrue\fP or \fBfalse\fP\&\. This file has to be in XDG_CONFIG_HOME on Linux/Unix, ~/Library/Preferences on macOS and ~/AppData/Local on Windows\. +.SH "CLI\-ONLY OPTIONS" +.TP +\fB\-i\fP \fIFORMAT\fP, \fB\-\-input\fP \fIFORMAT\fP +Specify the input format\. Available input formats: \fIkramdown\fP (this is the default), \fImarkdown\fP, or \fIhtml\fP\&\. The input format \fIGFM\fP is available through the \fBkramdown\-parser\-gfm\fP gem\. +.TP +\fB\-o\fP \fIFORMAT\fP, \fB\-\-output\fP \fIFORMAT\fP +Specify one or more output formats separated by commas: \fIhtml\fP (default), \fIkramdown\fP, \fIlatex\fP, \fIman\fP or \fIremove_html_tags\fP\&\. The converter \fIpdf\fP is available through the \fBkramdown\-converter\-pdf\fP gem\. +.TP +\fB\-x\fP \fIEXT\fP, \fB\-\-extension\fP \fIEXT\fP +Load one or more extensions\. The name of the extension should not include the \fBkramdown\-\fP prefix, e\.g\. just \fBparser\-gfm\fP\&\. Multiple extensions can be loaded by separating them with commas\. +.RS +.P +Note: This option has to be used before any other options that rely on the extension already being loaded\. +.RE +.TP +\fB\-\-no\-config\-file\fP +Do not read any configuration file\. Default behavior is to check for a configuration file and read it if it exists\. +.TP +\fB\-\-config\-file\fP \fIFILE\fP +Override the default path and name of the configuration file\. +.TP +\fB\-v\fP, \fB\-\-version\fP +Show the version of kramdown\. +.TP +\fB\-h\fP, \fB\-\-help\fP +Show the help\. +.SH "KRAMDOWN OPTIONS" +.TP +\fB\-\-auto\-id\-prefix\fP \fIARG\fP +Prefix used for automatically generated header IDs +.RS +.P +This option can be used to set a prefix for the automatically generated header IDs so that there is no conflict when rendering multiple kramdown documents into one output file separately\. The prefix should only contain characters that are valid in an ID! +.P +Default: \[u2018]\[u2019] Used by: HTML/Latex converter +.RE +.TP +\fB\-\-[no\-]auto\-id\-stripping\fP +Strip all formatting from header text for automatic ID generation +.RS +.P +If this option is \fBtrue\fP, only the text elements of a header are used for generating the ID later (in contrast to just using the raw header text line)\. +.P +This option will be removed in version 2\.0 because this will be the default then\. +.P +Default: false Used by: kramdown parser +.RE +.TP +\fB\-\-[no\-]auto\-ids\fP +Use automatic header ID generation +.RS +.P +If this option is \fBtrue\fP, ID values for all headers are automatically generated if no ID is explicitly specified\. +.P +Default: true Used by: HTML/Latex converter +.RE +.TP +\fB\-\-entity\-output\fP \fIARG\fP +Defines how entities are output +.RS +.P +The possible values are :as_input (entities are output in the same form as found in the input), :numeric (entities are output in numeric form), :symbolic (entities are output in symbolic form if possible) or :as_char (entities are output as characters if possible, only available on Ruby 1\.9)\. +.P +Default: :as_char Used by: HTML converter, kramdown converter +.RE +.TP +\fB\-\-footnote\-backlink\fP \fIARG\fP +Defines the text that should be used for the footnote backlinks +.RS +.P +The footnote backlink is just text, so any special HTML characters will be escaped\. +.P +If the footnote backlint text is an empty string, no footnote backlinks will be generated\. +.P +Default: \[u2018]\[u0026]8617;\[u2019] Used by: HTML converter +.RE +.TP +\fB\-\-[no\-]footnote\-backlink\-inline\fP +Specifies whether the footnote backlink should always be inline +.RS +.P +With the default of false the footnote backlink is placed at the end of the last paragraph if there is one, or an extra paragraph with only the footnote backlink is created\. +.P +Setting this option to true tries to place the footnote backlink in the last, possibly nested paragraph or header\. If this fails (e\.g\. in the case of a table), an extra paragraph with only the footnote backlink is created\. +.P +Default: false Used by: HTML converter +.RE +.TP +\fB\-\-footnote\-nr\fP \fIARG\fP +The number of the first footnote +.RS +.P +This option can be used to specify the number that is used for the first footnote\. +.P +Default: 1 Used by: HTML converter +.RE +.TP +\fB\-\-footnote\-prefix\fP \fIARG\fP +Prefix used for footnote IDs +.RS +.P +This option can be used to set a prefix for footnote IDs\. This is useful when rendering multiple documents into the same output file to avoid duplicate IDs\. The prefix should only contain characters that are valid in an ID! +.P +Default: \[u2018]\[u2019] Used by: HTML +.RE +.TP +\fB\-\-forbidden\-inline\-options\fP \fIARG\fP +Defines the options that may not be set using the {::options} extension +.RS +.P +The value needs to be an array of option names\. +.P +Default: [template] Used by: HTML converter +.RE +.TP +\fB\-\-header\-offset\fP \fIARG\fP +Sets the output offset for headers +.RS +.P +If this option is c (may also be negative) then a header with level n will be output as a header with level c+n\. If c+n is lower than 1, level 1 will be used\. If c+n is greater than 6, level 6 will be used\. +.P +Default: 0 Used by: HTML converter, Kramdown converter, Latex converter +.RE +.TP +\fB\-\-[no\-]html\-to\-native\fP +Convert HTML elements to native elements +.RS +.P +If this option is \fBtrue\fP, the parser converts HTML elements to native elements\. For example, when parsing \fBhallo\fP the emphasis tag would normally be converted to an \fB:html\fP element with tag type \fB:em\fP\&\. If \fBhtml_to_native\fP is \fBtrue\fP, then the emphasis would be converted to a native \fB:em\fP element\. +.P +This is useful for converters that cannot deal with HTML elements\. +.P +Default: false Used by: kramdown parser +.RE +.TP +\fB\-\-latex\-headers\fP \fIARG\fP +Defines the LaTeX commands for different header levels +.RS +.P +The commands for the header levels one to six can be specified by separating them with commas\. +.P +Default: section,subsection,subsubsection,paragraph,subparagraph,subparagraph Used by: Latex converter +.RE +.TP +\fB\-\-line\-width\fP \fIARG\fP +Defines the line width to be used when outputting a document +.RS +.P +Default: 72 Used by: kramdown converter +.RE +.TP +\fB\-\-link\-defs\fP \fIARG\fP +Pre\-defines link definitions +.RS +.P +This option can be used to pre\-define link definitions\. The value needs to be a Hash where the keys are the link identifiers and the values are two element Arrays with the link URL and the link title\. +.P +If the value is a String, it has to contain a valid YAML hash and the hash has to follow the above guidelines\. +.P +Default: {} Used by: kramdown parser +.RE +.TP +\fB\-\-list\-indent\fP \fIARG\fP +Sets the number of spaces to use for list indentation +.RS +.P +Default: 2 Used by: Kramdown converter +.RE +.TP +\fB\-\-math\-engine\fP \fIARG\fP +Set the math engine +.RS +.P +Specifies the math engine that should be used for converting math blocks/spans\. If this option is set to +nil+, no math engine is used and the math blocks/spans are output as is\. +.P +Options for the selected math engine can be set with the math_engine_opts configuration option\. +.P +Default: mathjax Used by: HTML converter +.RE +.TP +\fB\-\-math\-engine\-opts\fP \fIARG\fP +Set the math engine options +.RS +.P +Specifies options for the math engine set via the math_engine configuration option\. +.P +The value needs to be a hash with key\-value pairs that are understood by the used math engine\. +.P +Default: {} Used by: HTML converter +.RE +.TP +\fB\-\-[no\-]parse\-block\-html\fP +Process kramdown syntax in block HTML tags +.RS +.P +If this option is \fBtrue\fP, the kramdown parser processes the content of block HTML tags as text containing block\-level elements\. Since this is not wanted normally, the default is \fBfalse\fP\&\. It is normally better to selectively enable kramdown processing via the markdown attribute\. +.P +Default: false Used by: kramdown parser +.RE +.TP +\fB\-\-[no\-]parse\-span\-html\fP +Process kramdown syntax in span HTML tags +.RS +.P +If this option is \fBtrue\fP, the kramdown parser processes the content of span HTML tags as text containing span\-level elements\. +.P +Default: true Used by: kramdown parser +.RE +.TP +\fB\-\-[no\-]remove\-block\-html\-tags\fP +Remove block HTML tags +.RS +.P +If this option is \fBtrue\fP, the RemoveHtmlTags converter removes block HTML tags\. +.P +Default: true Used by: RemoveHtmlTags converter +.RE +.TP +\fB\-\-[no\-]remove\-line\-breaks\-for\-cjk\fP +Specifies whether line breaks should be removed between CJK characters +.RS +.P +Default: false Used by: HTML converter +.RE +.TP +\fB\-\-[no\-]remove\-span\-html\-tags\fP +Remove span HTML tags +.RS +.P +If this option is \fBtrue\fP, the RemoveHtmlTags converter removes span HTML tags\. +.P +Default: false Used by: RemoveHtmlTags converter +.RE +.TP +\fB\-\-smart\-quotes\fP \fIARG\fP +Defines the HTML entity names or code points for smart quote output +.RS +.P +The entities identified by entity name or code point that should be used for, in order, a left single quote, a right single quote, a left double and a right double quote are specified by separating them with commas\. +.P +Default: lsquo,rsquo,ldquo,rdquo Used by: HTML/Latex converter +.RE +.TP +\fB\-\-syntax\-highlighter\fP \fIARG\fP +Set the syntax highlighter +.RS +.P +Specifies the syntax highlighter that should be used for highlighting code blocks and spans\. If this option is set to +nil+, no syntax highlighting is done\. +.P +Options for the syntax highlighter can be set with the syntax_highlighter_opts configuration option\. +.P +Default: rouge Used by: HTML/Latex converter +.RE +.TP +\fB\-\-syntax\-highlighter\-opts\fP \fIARG\fP +Set the syntax highlighter options +.RS +.P +Specifies options for the syntax highlighter set via the syntax_highlighter configuration option\. +.P +The value needs to be a hash with key\-value pairs that are understood by the used syntax highlighter\. +.P +Default: {} Used by: HTML/Latex converter +.RE +.TP +\fB\-\-template\fP \fIARG\fP +The name of an ERB template file that should be used to wrap the output or the ERB template itself\. +.RS +.P +This is used to wrap the output in an environment so that the output can be used as a stand\-alone document\. For example, an HTML template would provide the needed header and body tags so that the whole output is a valid HTML file\. If no template is specified, the output will be just the converted text\. +.P +When resolving the template file, the given template name is used first\. If such a file is not found, the converter extension (the same as the converter name) is appended\. If the file still cannot be found, the templates name is interpreted as a template name that is provided by kramdown (without the converter extension)\. If the file is still not found, the template name is checked if it starts with \[u2018]string://\[u2019] and if it does, this prefix is removed and the rest is used as template content\. +.P +kramdown provides a default template named \[u2018]document\[u2019] for each converter\. +.P +Default: \[u2018]\[u2019] Used by: all converters +.RE +.TP +\fB\-\-toc\-levels\fP \fIARG\fP +Defines the levels that are used for the table of contents +.RS +.P +The individual levels can be specified by separating them with commas (e\.g\. 1,2,3) or by using the range syntax (e\.g\. 1\.\.3)\. Only the specified levels are used for the table of contents\. +.P +Default: 1\.\.6 Used by: HTML/Latex converter +.RE +.TP +\fB\-\-[no\-]transliterated\-header\-ids\fP +Transliterate the header text before generating the ID +.RS +.P +Only ASCII characters are used in headers IDs\. This is not good for languages with many non\-ASCII characters\. By enabling this option the header text is transliterated to ASCII as good as possible so that the resulting header ID is more useful\. +.P +The stringex library needs to be installed for this feature to work! +.P +Default: false Used by: HTML/Latex converter +.RE +.TP +\fB\-\-typographic\-symbols\fP \fIARG\fP +Defines a mapping from typographical symbol to output characters +.RS +.P +Typographical symbols are normally output using their equivalent Unicode codepoint\. However, sometimes one wants to change the output, mostly to fallback to a sequence of ASCII characters\. +.P +This option allows this by specifying a mapping from typographical symbol to its output string\. For example, the mapping {hellip: \.\.\.} would output the standard ASCII representation of an ellipsis\. +.P +The available typographical symbol names are: +.IP \(bu 4 +hellip: ellipsis +.IP \(bu 4 +mdash: em\-dash +.IP \(bu 4 +ndash: en\-dash +.IP \(bu 4 +laquo: left guillemet +.IP \(bu 4 +raquo: right guillemet +.IP \(bu 4 +laquo_space: left guillemet followed by a space +.IP \(bu 4 +raquo_space: right guillemet preceeded by a space +.P +Default: {} Used by: HTML/Latex converter +.RE +.SH "EXIT STATUS" +The exit status is 0 if no error happened\. Otherwise it is 1\. +.SH "SEE ALSO" +The kramdown website +.UR http://kramdown\.gettalong\.org +.UE +for more information, especially on the supported input syntax\. +.SH "AUTHOR" +kramdown was written by Thomas Leitner +.MT t_leitner@gmx\.at +.UE +\&\. +.P +This manual page was written by Thomas Leitner +.MT t_leitner@gmx\.at +.UE +\&\. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/run_tests.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/run_tests.rb new file mode 100644 index 0000000..abda502 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/run_tests.rb @@ -0,0 +1,46 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +$:.unshift File.dirname(__FILE__) + '/../lib' +require 'kramdown' +require 'test/unit/assertions' +require 'yaml' + +include Test::Unit::Assertions + +arg = ARGV[0] || File.join(File.dirname(__FILE__), 'testcases') + +arg = if File.directory?(arg) + File.join(arg, '**/*.text') + else + arg + '.text' + end + +width = ((size = `stty size 2>/dev/null`).length > 0 ? size.split.last.to_i : 72) rescue 72 +width -= 8 +fwidth = 0 +Dir[arg].each {|f| fwidth = [fwidth, f.length + 10].max }.each do |file| + print(('Testing ' + file + ' ').ljust([fwidth, width].min)) + $stdout.flush + + html_file = file.sub('.text', '.html') + opts_file = file.sub('.text', '.options') + opts_file = File.join(File.dirname(file), 'options') unless File.exist?(opts_file) + options = File.exist?(opts_file) ? YAML.safe_load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1} + doc = Kramdown::Document.new(File.read(file), options) + begin + assert_equal(File.read(html_file), doc.to_html) + puts 'PASSED' + rescue StandardError + puts ' FAILED' + puts $!.message if $VERBOSE + puts $!.backtrace if $DEBUG + end + puts "Warnings:\n" + doc.warnings.join("\n") if !doc.warnings.empty? && $VERBOSE +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_files.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_files.rb new file mode 100644 index 0000000..586de3c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_files.rb @@ -0,0 +1,305 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'minitest/autorun' +require 'kramdown' +require 'yaml' +require 'tmpdir' +require 'open3' + +begin + require 'kramdown/converter/syntax_highlighter/rouge' + + Kramdown::Converter::SyntaxHighlighter::Rouge.formatter_class.send(:define_method, :format) do |tokens, &b| + super(tokens, &b).sub(/<\/code><\/pre>\n?/, "\n") + end + + # custom formatter for tests + module Rouge + module Formatters + class RougeHTMLFormatters < Kramdown::Converter::SyntaxHighlighter::Rouge.formatter_class + + tag 'rouge_html_formatters' + + def stream(tokens, &b) + yield %(
) + super + yield %(
) + end + + end + end + end +rescue LoadError, SyntaxError, NameError +end + +Encoding.default_external = 'utf-8' + +class TestFiles < Minitest::Test + + EXCLUDE_KD_FILES = [].compact + + # Generate test methods for kramdown-to-xxx conversion + Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file| + next if EXCLUDE_KD_FILES.any? {|f| text_file =~ /#{f}/ } + basename = text_file.sub(/\.text$/, '') + opts_file = text_file.sub(/\.text$/, '.options') + (Dir[basename + ".*"] - [text_file, opts_file]).each do |output_file| + output_format = File.extname(output_file)[1..-1] + next unless Kramdown::Converter.const_defined?(output_format[0..0].upcase + output_format[1..-1]) + define_method('test_' + text_file.tr('.', '_') + "_to_#{output_format}") do + opts_file = File.join(File.dirname(text_file), 'options') unless File.exist?(opts_file) + options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1} + doc = Kramdown::Document.new(File.read(text_file), options) + assert_equal(File.read(output_file), doc.send("to_#{output_format}")) + end + end + end + + # Generate test methods for html-to-{html,kramdown} conversion + `tidy -v 2>&1` + if $?.exitstatus != 0 + warn("Skipping html-to-{html,kramdown} tests because tidy executable is missing") + else + EXCLUDE_HTML_FILES = [ + 'test/testcases/block/06_codeblock/whitespace.html', # bc of span inside pre + 'test/testcases/block/09_html/simple.html', # bc of xml elements + 'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element + 'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option + 'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option + 'test/testcases/block/06_codeblock/rouge/simple.html', # bc of double surrounding
+ 'test/testcases/block/06_codeblock/rouge/multiple.html', # bc of double surrounding
+ 'test/testcases/block/06_codeblock/highlighting.html', # bc of span elements inside code element + 'test/testcases/block/06_codeblock/highlighting-opts.html', # bc of span elements inside code element + 'test/testcases/block/06_codeblock/guess_lang_css_class.html', # bc of double surrounding
+ 'test/testcases/block/12_extension/options3.html', # bc of rouge + 'test/testcases/block/14_table/empty_tag_in_cell.html', # bc of tidy + 'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview + 'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview + 'test/testcases/block/15_math/mathjax_preview_as_code.html', # bc of mathjax preview + 'test/testcases/span/05_html/mark_element.html', # bc of tidy + 'test/testcases/block/09_html/xml.html', # bc of tidy + 'test/testcases/span/05_html/xml.html', # bc of tidy + ].compact + EXCLUDE_HTML_TEXT_FILES = [ + 'test/testcases/block/09_html/parse_as_span.htmlinput', + 'test/testcases/block/09_html/parse_as_raw.htmlinput', + ].compact + Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,htmlinput}'].each do |html_file| + next if EXCLUDE_HTML_FILES.any? {|f| html_file =~ /#{f}/ } + + out_files = [] + out_files << [(html_file =~ /\.htmlinput$/ ? html_file.sub(/input$/, '') : html_file), :to_html] + if html_file =~ /\.htmlinput$/ && EXCLUDE_HTML_TEXT_FILES.none? {|f| html_file =~ /#{f}/ } + out_files << [html_file.sub(/htmlinput$/, 'text'), :to_kramdown] + end + out_files.select {|f, _| File.exist?(f) }.each do |out_file, out_method| + define_method('test_' + html_file.tr('.', '_') + "_to_#{File.extname(out_file)}") do + opts_file = html_file.sub(/\.html(input)?$/, '.options') + opts_file = File.join(File.dirname(html_file), 'options') unless File.exist?(opts_file) + options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1} + doc = Kramdown::Document.new(File.read(html_file), options.merge(input: 'html')) + if out_method == :to_html + assert_equal(tidy_output(File.read(out_file)), tidy_output(doc.send(out_method))) + else + assert_equal(File.read(out_file), doc.send(out_method)) + end + end + end + end + end + + def tidy_output(out) + cmd = "tidy -q --doctype omit -utf8" + result, error, status = Open3.capture3(cmd, stdin_data: out) + if status.exitstatus == 2 + raise "Problem using tidy: #{error}" + end + result + end + + # Generate test methods for text-to-latex conversion and compilation + `latex -v 2>&1` + if $?.exitstatus != 0 + warn("Skipping latex compilation tests because latex executable is missing") + else + EXCLUDE_LATEX_FILES = [ + 'test/testcases/span/01_link/image_in_a.text', # bc of image link + 'test/testcases/span/01_link/imagelinks.text', # bc of image links + 'test/testcases/span/01_link/empty_title.text', + 'test/testcases/span/04_footnote/markers.text', # bc of footnote in header + 'test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text', + 'test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text', + 'test/testcases/block/03_paragraph/standalone_image.text', # bc of standalone image + 'test/testcases/cjk-line-break.text', # latex unicode support + ].compact + Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file| + next if EXCLUDE_LATEX_FILES.any? {|f| text_file =~ /#{f}$/ } + define_method('test_' + text_file.tr('.', '_') + "_to_latex_compilation") do + latex = Kramdown::Document.new(File.read(text_file), auto_ids: false, footnote_nr: 1, + template: 'document').to_latex + Dir.mktmpdir do |tmpdir| + result = IO.popen("latex -output-directory='#{tmpdir}' 2>/dev/null", 'r+') do |io| + io.write(latex) + io.close_write + io.read + end + assert($?.exitstatus == 0, result.scan(/^!(.*\n.*)/).join("\n")) + end + end + end + end + + # Generate test methods for text->kramdown->html conversion + `tidy -v 2>&1` + if $?.exitstatus != 0 + warn("Skipping text->kramdown->html tests because tidy executable is missing") + else + EXCLUDE_TEXT_FILES = [ + 'test/testcases/span/05_html/markdown_attr.text', # bc of markdown attr + 'test/testcases/block/09_html/markdown_attr.text', # bc of markdown attr + 'test/testcases/span/extension/options.text', # bc of parse_span_html option + 'test/testcases/block/12_extension/options.text', # bc of options option + 'test/testcases/block/12_extension/options3.text', # bc of options option + 'test/testcases/block/09_html/content_model/tables.text', # bc of parse_block_html option + 'test/testcases/block/09_html/html_to_native/header.text', # bc of auto_ids option that interferes + 'test/testcases/block/09_html/html_to_native/table_simple.text', # bc of tr style attr getting removed + 'test/testcases/block/09_html/simple.text', # bc of webgen:block elements + 'test/testcases/block/11_ial/simple.text', # bc of change of ordering of attributes in header + 'test/testcases/span/extension/comment.text', # bc of comment text modifications (can this be avoided?) + 'test/testcases/block/04_header/header_type_offset.text', # bc of header_offset being applied twice + 'test/testcases/block/06_codeblock/rouge/simple.text', + 'test/testcases/block/06_codeblock/rouge/multiple.text', # check, what document contain more, than one code block + 'test/testcases/block/14_table/empty_tag_in_cell.text', # bc of tidy + 'test/testcases/span/01_link/link_defs_with_ial.text', # bc of attribute ordering + 'test/testcases/span/05_html/mark_element.text', # bc of tidy + 'test/testcases/block/09_html/xml.text', # bc of tidy + 'test/testcases/span/05_html/xml.text', # bc of tidy + 'test/testcases/block/03_paragraph/standalone_image.text', # bc of standalone image + 'test/testcases/cjk-line-break.text', + 'test/testcases/block/09_html/standalone_image_in_div.html', # bc of standalone image + 'test/testcases/span/abbreviations/abbrev_in_html.text', # bc of invalid abbr tag in SVG + ].compact + Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file| + next if EXCLUDE_TEXT_FILES.any? {|f| text_file =~ /#{f}$/ } + html_file = text_file.sub(/\.text$/, '.html') + next unless File.exist?(html_file) + define_method('test_' + text_file.tr('.', '_') + "_to_kramdown_to_html") do + opts_file = text_file.sub(/\.text$/, '.options') + opts_file = File.join(File.dirname(text_file), 'options') unless File.exist?(opts_file) + options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1} + kdtext = Kramdown::Document.new(File.read(text_file), options).to_kramdown + html = Kramdown::Document.new(kdtext, options).to_html + assert_equal(tidy_output(File.read(html_file)), tidy_output(html)) + kdtext4 = Kramdown::Document.new(File.read(text_file), options.merge({list_indent: 4})).to_kramdown + html = Kramdown::Document.new(kdtext4, options).to_html + assert_equal(tidy_output(File.read(html_file)), tidy_output(html)) + end + end + end + + # Generate test methods for html-to-kramdown-to-html conversion + `tidy -v 2>&1` + if $?.exitstatus != 0 + warn("Skipping html-to-kramdown-to-html tests because tidy executable is missing") + else + EXCLUDE_HTML_KD_FILES = [ + 'test/testcases/span/extension/options.html', # bc of parse_span_html option + 'test/testcases/span/05_html/normal.html', # bc of br tag before closing p tag + 'test/testcases/block/12_extension/nomarkdown.html', # bc of nomarkdown extension + 'test/testcases/block/12_extension/options3.html', # bc of rouge + 'test/testcases/block/09_html/simple.html', # bc of webgen:block elements + 'test/testcases/block/09_html/markdown_attr.html', # bc of markdown attr + 'test/testcases/block/09_html/html_to_native/table_simple.html', # bc of invalidly converted simple table + 'test/testcases/block/06_codeblock/whitespace.html', # bc of entity to char conversion + 'test/testcases/block/06_codeblock/rouge/simple.html', # bc of double surrounding
+ 'test/testcases/block/06_codeblock/rouge/multiple.html', # bc of double surrounding
+ 'test/testcases/block/06_codeblock/guess_lang_css_class.html', # bc of double surrounding
+ 'test/testcases/block/06_codeblock/highlighting.html', # bc of span elements inside code element + 'test/testcases/block/06_codeblock/highlighting-opts.html', # bc of span elements inside code element + 'test/testcases/block/11_ial/simple.html', # bc of change of ordering of attributes in header + 'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element + 'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option + 'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option + 'test/testcases/block/16_toc/toc_exclude.html', # bc of different attribute ordering + 'test/testcases/span/autolinks/url_links.html', # bc of quot entity being converted to char + 'test/testcases/block/14_table/empty_tag_in_cell.html', # bc of tidy + 'test/testcases/span/01_link/link_defs_with_ial.html', # bc of attribute ordering + 'test/testcases/span/05_html/mark_element.html', # bc of tidy + 'test/testcases/block/09_html/xml.html', # bc of tidy + 'test/testcases/span/05_html/xml.html', # bc of tidy + 'test/testcases/block/03_paragraph/standalone_image.html', # bc of standalone image + 'test/testcases/block/15_math/normal.html', # bc of mathjax and HTML parser + 'test/testcases/block/15_math/gh_128.html', # bc of mathjax and HTML parser + 'test/testcases/span/04_footnote/backlink_inline.html', # bc of mathjax + 'test/testcases/block/09_html/standalone_image_in_div.html', # bc of standalone image + 'test/testcases/block/09_html/processing_instruction.html', # bc of PI + ].compact + Dir[File.dirname(__FILE__) + '/testcases/**/*.html'].each do |html_file| + next if EXCLUDE_HTML_KD_FILES.any? {|f| html_file =~ /#{f}$/ } + define_method('test_' + html_file.tr('.', '_') + "_to_kramdown_to_html") do + kd = Kramdown::Document.new(File.read(html_file), input: 'html', + auto_ids: false, footnote_nr: 1).to_kramdown + opts_file = html_file.sub(/\.html$/, '.options') + opts_file = File.join(File.dirname(html_file), 'options') unless File.exist?(opts_file) + options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1} + doc = Kramdown::Document.new(kd, options) + assert_equal(tidy_output(File.read(html_file)), tidy_output(doc.to_html)) + end + end + end + + # Generate test methods for text-manpage conversion + Dir[File.dirname(__FILE__) + '/testcases/man/**/*.text'].each do |text_file| + define_method('test_' + text_file.tr('.', '_') + "_to_man") do + man_file = text_file.sub(/\.text$/, '.man') + doc = Kramdown::Document.new(File.read(text_file)) + assert_equal(File.read(man_file), doc.to_man) + end + end + + EXCLUDE_MODIFY = [ + 'test/testcases/block/06_codeblock/rouge/multiple.text', # bc of HTMLFormater in options + ].compact + + # Generate test methods for asserting that converters don't modify the document tree. + Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file| + opts_file = text_file.sub(/\.text$/, '.options') + options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1} + (Kramdown::Converter.constants.map(&:to_sym) - + [:Base, :RemoveHtmlTags, :MathEngine, :SyntaxHighlighter]).each do |conv_class| + next if EXCLUDE_MODIFY.any? {|f| text_file =~ /#{f}$/ } + define_method("test_whether_#{conv_class}_modifies_tree_with_file_#{text_file.tr('.', '_')}") do + doc = Kramdown::Document.new(File.read(text_file), options) + options_before = Marshal.load(Marshal.dump(doc.options)) + tree_before = Marshal.load(Marshal.dump(doc.root)) + Kramdown::Converter.const_get(conv_class).convert(doc.root, doc.options) + assert_equal(options_before, doc.options) + assert_tree_not_changed(tree_before, doc.root) + end + end + end + + def assert_tree_not_changed(old, new) + assert_equal(old.type, new.type, "type mismatch") + if old.value.kind_of?(Kramdown::Element) + assert_tree_not_changed(old.value, new.value) + else + assert(old.value == new.value, "value mismatch") + end + assert_equal(old.attr, new.attr, "attr mismatch") + assert_equal(old.options, new.options, "options mismatch") + assert_equal(old.children.length, new.children.length, "children count mismatch") + + old.children.each_with_index do |child, index| + assert_tree_not_changed(child, new.children[index]) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_location.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_location.rb new file mode 100644 index 0000000..d2642c7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_location.rb @@ -0,0 +1,216 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'minitest/autorun' +require 'kramdown' + +Encoding.default_external = 'utf-8' + +describe 'location' do + # checks that +element+'s :location option corresponds to the location stored + # in the element.attr['class'] + def check_element_for_location(element) + if (match = /^line-(\d+)/.match(element.attr['class'] || '')) + expected_line = match[1].to_i + assert_equal(expected_line, element.options[:location]) + end + element.children.each do |child| + check_element_for_location(child) + end + end + + # Test cases consist of a kramdown string that uses IALs to specify the expected + # line numbers for a given element. + test_cases = { + 'autolink' => %(testing autolinks\n\n{:.line-3}), + 'blockquote' => %( + > block quote1 + > + > * {:.line-3} list item in block quote + > * {:.line-4} list item in block quote + > {:.line-3} + {:.line-1} + + > block quote2 + {:.line-8} + ), + 'codeblock' => %(\na para\n\n~~~~\ntest code 1\n~~~~\n{:.line-3}\n\n test code 2\n{:.line-8}\n), + 'codespan' => %(a para\n\nanother para ``{:.line-3} with code\n), + 'emphasis' => %( + para *span*{:.line-1} + {:.line-1} + + ## header *span*{:.line-4} + {:.line-4} + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum *short span on single line*{:.line-11} + dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non + *long span over multiple lines - proident, sunt in culpa qui officia deserunt + mollit anim id est laborum.*{:.line-13} + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + `code span`{:.line-18} + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + {:.line-7} + ), + 'header' => %( + # header1 + {:.line-1} + + ## header2 + {:.line-4} + + ## header3 + {:.line-7} + + header4 + ======= + {:.line-10} + + ^ + + header5 + ------- + {:.line-16} + ), + 'horizontal_rule' => %(\na para\n\n----\n{:.line-3}\n), + 'html_entity' => "a para\n\nanother para with &{:.line-3} html entity.\n", + 'link' => %( + a para + + This is [a link](http://rubyforge.org){:.line-3} to a page. + + Here comes a ![smiley](../images/smiley.png){:.line-5} + ), + 'list' => %( + * {:.line-1} list item + * {:.line-2} list item + * {:.line-3} list item + {:.line-1} + + {:.line-7} + 1. {:.line-7} list item + 2. {:.line-8} list item + 3. {:.line-9} list item + + {:.line-12} + definition term 1 + : {:.line-13} definition definition 1 + definition term 2 + : {:.line-15} definition definition 2 + ), + 'math_block' => %(\na para\n\n$$5+5$$\n{:.line-3}\n), + 'math_inline' => %(\na para\n\nanother para with inline math $$5+5$${:.line-3}\n), + 'paragraph' => %( + para1 + {:.line-1} + + para2 + {:.line-4} + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse + {:.line-7} + + {:.line-14} + para with leading IAL + ), + 'table' => %( + a para + + |first|second|third| + |-----|------|-----| + |a |b |c | + {:.line-3} + ), + 'typographic_symbol' => %( + a para + + another para ---{:.line-3} + + another para ...{:.line-5} + ), + 'gh issue 129' => %( + `|` + {:.line-1} + ), + 'gh issue 131' => %( + * {:.line-1} test + line 2 + * {:.line-3} second + * {:.line-4} third + * {:.line-5} * {:.line-5} one + * {:.line-6} two + ), + 'gh issue 158' => %( + 😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁 + {:.line-1} + + - {:.line-4} T + {:.line-4} + + # T + {:.line-7} + ), + 'gh issue 243 - HTML raw elements' => %( +
    +
  • Test
  • +
+ ), + } + test_cases.each do |name, test_string| + it "Handles #{name}" do + doc = Kramdown::Document.new(test_string.gsub(/^ /, '').strip) + check_element_for_location(doc.root) + end + end + + it 'adds location info to duplicate abbreviation definition warnings' do + test_string = %(This snippet contains a duplicate abbreviation definition + +*[duplicate]: The first definition +*[duplicate]: The second definition + ) + doc = Kramdown::Document.new(test_string.strip) + assert_equal(["Duplicate abbreviation ID 'duplicate' on line 4 - overwriting"], doc.warnings) + end + + it 'handles abbreviations' do + str = "This *is* ABC and\n**and** ABC second\nanother ABC\nas ABC as\nABC at the end.\n\n*[ABC]: ABC" + doc = Kramdown::Document.new(str) + doc.root.children.first.children.select {|e| e.type == :abbreviation }.each_with_index do |e, i| + assert_equal(i + 1, e.options[:location]) + end + end + + it 'handles line breaks' do + str = "First \nsecond\\\\\nthird \n" + doc = Kramdown::Document.new(str) + doc.root.children.first.children.select {|e| e.type == :br }.each_with_index do |e, i| + assert_equal(i + 1, e.options[:location]) + end + end + + it 'handles smart quotes' do + str = "This is 'first'\nand 'second' and\n'third'" + doc = Kramdown::Document.new(str) + doc.root.children.first.children.select {|e| e.type == :smart_quote }.each_with_index do |e, i| + assert_equal(((i + 1) / 2.0).ceil, e.options[:location]) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_string_scanner_kramdown.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_string_scanner_kramdown.rb new file mode 100644 index 0000000..713c03c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/test_string_scanner_kramdown.rb @@ -0,0 +1,27 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2009-2019 Thomas Leitner +# +# This file is part of kramdown which is licensed under the MIT. +#++ +# + +require 'minitest/autorun' +require 'kramdown/utils/string_scanner' + +describe Kramdown::Utils::StringScanner do + [ + ["...........X............", [/X/], 1], + ["1\n2\n3\n4\n5\n6X", [/X/], 6], + ["1\n2\n3\n4\n5\n6X\n7\n8X", [/X/, /X/], 8], + [(".\n" * 1000) + 'X', [/X/], 1001], + ].each_with_index do |test_data, i| + test_string, scan_regexes, expect = test_data + it "computes the correct current_line_number for example ##{i + 1}" do + str_sc = Kramdown::Utils::StringScanner.new(test_string) + scan_regexes.each {|scan_re| str_sc.scan_until(scan_re) } + assert_equal(expect, str_sc.current_line_number) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/spaces.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/spaces.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/spaces.html @@ -0,0 +1 @@ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/spaces.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/spaces.text new file mode 100644 index 0000000..2cbdaa6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/spaces.text @@ -0,0 +1,3 @@ + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/tabs.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/tabs.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/tabs.html @@ -0,0 +1 @@ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/tabs.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/tabs.text new file mode 100644 index 0000000..69d6a47 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/01_blank_line/tabs.text @@ -0,0 +1,6 @@ + + + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/beginning.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/beginning.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/beginning.html @@ -0,0 +1 @@ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/beginning.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/beginning.text new file mode 100644 index 0000000..8d15802 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/beginning.text @@ -0,0 +1,3 @@ +^ + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/end.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/end.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/end.html @@ -0,0 +1 @@ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/end.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/end.text new file mode 100644 index 0000000..db56ec3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/end.text @@ -0,0 +1,3 @@ + + +^ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/middle.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/middle.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/middle.html @@ -0,0 +1 @@ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/middle.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/middle.text new file mode 100644 index 0000000..87210a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/02_eob/middle.text @@ -0,0 +1,5 @@ + + +^ + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.html new file mode 100644 index 0000000..810cfc0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.html @@ -0,0 +1,18 @@ +

This is a para.

+ +

This is a para.

+ +

This is a para.

+ +

This is a para.

+ +
This is a code block.
+
+ +

And this is another.

+ +

A para + with + mixed +indents. + and with much indent

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.html.gfm b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.html.gfm new file mode 100644 index 0000000..4440c62 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.html.gfm @@ -0,0 +1,18 @@ +

This is a para.

+ +

This is a para.

+ +

This is a para.

+ +

This is a para.

+ +
This is a code block.
+
+ +

And this is another.

+ +

A para +
with +
mixed +
indents. +
and with much indent

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.text new file mode 100644 index 0000000..5849f5b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/indented.text @@ -0,0 +1,19 @@ +This is a para. + + This is a para. + + This is a para. + + This is a para. + + This is a code block. + + + +And this is another. + +A para + with + mixed +indents. + and with much indent diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/line_break_last_line.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/line_break_last_line.html new file mode 100644 index 0000000..9bc47db --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/line_break_last_line.html @@ -0,0 +1,9 @@ +

First line
+https://example.com

+ +

First line
+https://example.com

+ +

Last Line

+ +

Last Line\

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/line_break_last_line.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/line_break_last_line.text new file mode 100644 index 0000000..bbc4cc5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/line_break_last_line.text @@ -0,0 +1,9 @@ +First line + + +First line\\ + + +Last Line + +Last Line\\ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/no_newline_at_end.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/no_newline_at_end.html new file mode 100644 index 0000000..6a209e2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/no_newline_at_end.html @@ -0,0 +1,5 @@ +

One paragraph +over + multiple lines.

+ +

Second one without newline.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/no_newline_at_end.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/no_newline_at_end.text new file mode 100644 index 0000000..7f1169d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/no_newline_at_end.text @@ -0,0 +1,5 @@ + One paragraph +over + multiple lines. + +Second one without newline. \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/one_para.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/one_para.html new file mode 100644 index 0000000..0d20e17 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/one_para.html @@ -0,0 +1 @@ +

This is just a normal paragraph.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/one_para.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/one_para.text new file mode 100644 index 0000000..0b01324 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/one_para.text @@ -0,0 +1 @@ +This is just a normal paragraph. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/standalone_image.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/standalone_image.html new file mode 100644 index 0000000..7faa971 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/standalone_image.html @@ -0,0 +1,13 @@ +

para

+ +
+ standalone image +
standalone image
+
+ +
+ standalone image +
standalone image
+
+ +

para

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/standalone_image.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/standalone_image.text new file mode 100644 index 0000000..3010140 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/standalone_image.text @@ -0,0 +1,9 @@ +para +{:standalone} + +![standalone image](some.jpg){:#id .class key="value" standalone} + +![standalone image](some.jpg){:#id .class key="value" standalone} +{:#block-id .block-class block-key="block-value"} + +para diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/to_kramdown.kramdown b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/to_kramdown.kramdown new file mode 100644 index 0000000..2108d98 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/to_kramdown.kramdown @@ -0,0 +1,7 @@ +aa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa +\: No definiion list + +a: + +*a*: + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/to_kramdown.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/to_kramdown.text new file mode 100644 index 0000000..031d2d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/to_kramdown.text @@ -0,0 +1,5 @@ +aa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa : No definiion list + +a: + +*a*: diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/two_para.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/two_para.html new file mode 100644 index 0000000..d6194ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/two_para.html @@ -0,0 +1,4 @@ +

This is just a normal paragraph. +That goes on to the second line.

+ +

Another paragraph.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/two_para.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/two_para.text new file mode 100644 index 0000000..b0c730d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/two_para.text @@ -0,0 +1,4 @@ +This is just a normal paragraph. +That goes on to the second line. + +Another paragraph. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.html new file mode 100644 index 0000000..a8831e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.html @@ -0,0 +1 @@ +

some text

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.options new file mode 100644 index 0000000..63936b9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.options @@ -0,0 +1 @@ +:html_to_native: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.text new file mode 100644 index 0000000..e5fe18a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/03_paragraph/with_html_to_native.text @@ -0,0 +1 @@ +

some text diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header.html new file mode 100644 index 0000000..0704107 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header.html @@ -0,0 +1,57 @@ +

This is a header

+ +

This is a header

+ +

This is a header

+ +

This is a header

+ +
This is a header
+ +
This is a header
+ +

Header

+

Header

+ +

Header

+
+

blockquote

+
+ +
header
+

paragraph

+ +
+

blockquote +### not a header

+
+ +

header

+ +

header

+ +

header

+ +

header #

+ +

header

+ +

#

+ +

#

+ +

Header

+ +

Header

+ +

Header

+ +

Header

+ +

Header {#9ab}

+ +

Header{#noid}

+ +

Header ##{#noid}

+ +

Last

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header.text new file mode 100644 index 0000000..392b3f6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header.text @@ -0,0 +1,54 @@ +# This is a header + +## This is a header + +### This is a header + +#### This is a header + +##### This is a header + +###### This is a header + +# Header +^ +# Header + +##Header ##### +> blockquote + +###### header +paragraph + +> blockquote +### not a header + +# header # + +# header# + +#header# + +# header \# + +# header + +# + +# + +### Header {#id} + +### Header ## {#Id} + +### Header ## {#id} + +### Header {#A-Za-z0-9_:t} + +### Header {#9ab} + +### Header{#noid} + +### Header ##{#noid} + +### Last diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header_no_newline_at_end.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header_no_newline_at_end.html new file mode 100644 index 0000000..9f49c3b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header_no_newline_at_end.html @@ -0,0 +1 @@ +

header

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header_no_newline_at_end.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header_no_newline_at_end.text new file mode 100644 index 0000000..7b74be4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/atx_header_no_newline_at_end.text @@ -0,0 +1 @@ +# header \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.html new file mode 100644 index 0000000..e031b9a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.html @@ -0,0 +1,11 @@ +

Lorem ipsum

+ +

Lorem ipsum

+ +

Lorem ipsum

+ +
Lorem ipsum
+ +

Lorem ipsum

+ +

Lorem ipsum

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.kramdown b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.kramdown new file mode 100644 index 0000000..a77deb9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.kramdown @@ -0,0 +1,12 @@ +## Lorem ipsum + +### Lorem ipsum + +#### Lorem ipsum + +###### Lorem ipsum + +## Lorem ipsum + +### Lorem ipsum + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.latex new file mode 100644 index 0000000..c9017e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.latex @@ -0,0 +1,12 @@ +\subsection*{Lorem ipsum} + +\subsubsection*{Lorem ipsum} + +\paragraph*{Lorem ipsum} + +\subparagraph*{Lorem ipsum} + +\subsection*{Lorem ipsum} + +\subsubsection*{Lorem ipsum} + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.options new file mode 100644 index 0000000..a805035 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.options @@ -0,0 +1,2 @@ +:header_offset: 1 +:auto_ids: false \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.text new file mode 100644 index 0000000..bfaefa2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/header_type_offset.text @@ -0,0 +1,13 @@ +# Lorem ipsum + +## Lorem ipsum + +### Lorem ipsum + +###### Lorem ipsum + +Lorem ipsum +=========== + +Lorem ipsum +----------- diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header.html new file mode 100644 index 0000000..147c345 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header.html @@ -0,0 +1,32 @@ +

test

+ +

test2

+ +

test

+

para

+ +
   header =
+
+ +

=

+ +

This is a para. +With two lines. +And not a header. +=================

+ +
+

Blockquote. +Not a Header +-

+
+ +

header

+ +

header

+ +

header

+ +

header{#noid}

+ +

header

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header.text new file mode 100644 index 0000000..ae94ecd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header.text @@ -0,0 +1,39 @@ +test +- + +test2 +========= + +test +- +para + + header += + + += + +This is a para. +With two lines. +And not a header. +================= + +> Blockquote. +Not a Header +- + +header {#id} +------------ + +header {#Id} +====== + +header {#A-Za-z0-9_:} +------ + +header{#noid} +----- + +header +------ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header_no_newline_at_end.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header_no_newline_at_end.html new file mode 100644 index 0000000..9f49c3b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header_no_newline_at_end.html @@ -0,0 +1 @@ +

header

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header_no_newline_at_end.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header_no_newline_at_end.text new file mode 100644 index 0000000..0f00750 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/setext_header_no_newline_at_end.text @@ -0,0 +1,2 @@ +header +====== \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.html new file mode 100644 index 0000000..724d391 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.html @@ -0,0 +1,3 @@ +

Header 1

+ +

123

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.options new file mode 100644 index 0000000..83305cb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.options @@ -0,0 +1,2 @@ +:auto_ids: true +:auto_id_prefix: hallo_ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.text new file mode 100644 index 0000000..acf09fe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_prefix.text @@ -0,0 +1,3 @@ +# Header 1 + +# 123 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.html new file mode 100644 index 0000000..1d342cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.html @@ -0,0 +1 @@ +

This is a header

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.options new file mode 100644 index 0000000..68800f6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.options @@ -0,0 +1 @@ +:auto_id_stripping: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.text new file mode 100644 index 0000000..2b57bc8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_id_stripping.text @@ -0,0 +1 @@ +# This is a header diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.html new file mode 100644 index 0000000..af8126d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.html @@ -0,0 +1,21 @@ +

This is a header

+ +

12. Another one-1-here

+ +

Do ^& it now

+ +

Hallo

+ +

Not now

+ +

Hallo

+ +

23232

+ +

33333

+ +

hallO

+ +

Header without ID

+ +

Transliterated: Đây-là-ví-dụ

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.options new file mode 100644 index 0000000..0a1fec8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.options @@ -0,0 +1,2 @@ +:auto_ids: true +:transliterated_header_ids: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.text new file mode 100644 index 0000000..f4cd91b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/04_header/with_auto_ids.text @@ -0,0 +1,24 @@ +# This is a header + +## 12. Another one-1-here + +### Do ^& it now + +Hallo +===== + +Not now +------- + +# Hallo + +# 23232 + +# 33333 + +## hallO + +# Header without ID +{: id=""} + +# Transliterated: Đây-là-ví-dụ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/indented.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/indented.html new file mode 100644 index 0000000..734bb7a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/indented.html @@ -0,0 +1,25 @@ +
+

A normal blockquote.

+
+ +
+

A normal blockquote.

+
+ +
+

A normal blockquote.

+
+ +
+

A normal blockquote.

+
+ +
> A codeblock
+
+ +
+

Blockquote +with +mixed +indents.

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/indented.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/indented.text new file mode 100644 index 0000000..70850b0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/indented.text @@ -0,0 +1,14 @@ +> A normal blockquote. + + > A normal blockquote. + + > A normal blockquote. + + > A normal blockquote. + + > A codeblock + +> Blockquote + > with + >mixed +> indents. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/lazy.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/lazy.html new file mode 100644 index 0000000..00a2102 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/lazy.html @@ -0,0 +1,34 @@ +
+

This is a long +long line.

+
+ +
+
+

Nested quote +inside +still inside

+
+
+ +
+
+

This is a subquote. +over multipline lines. +continuing +here

+
+
+ +
+

This is a quote + no code

+
+ +
+

This is a quote

+
+ +
+

This is a quote

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/lazy.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/lazy.text new file mode 100644 index 0000000..adde6a6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/lazy.text @@ -0,0 +1,20 @@ +> This is a long +long line. + +> > Nested quote +inside +> still inside + +> > This is a subquote. +> > over multipline lines. +> continuing +here + +> This is a quote + no code + +> This is a quote +{: #id} + +> This is a quote +^ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/nested.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/nested.html new file mode 100644 index 0000000..4bc94f0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/nested.html @@ -0,0 +1,10 @@ +
+

foo

+ +
+

bar + baz

+
+ +

foo

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/nested.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/nested.text new file mode 100644 index 0000000..2176882 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/nested.text @@ -0,0 +1,6 @@ +> foo +> +> > bar +>> baz +> +> foo diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/no_newline_at_end.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/no_newline_at_end.html new file mode 100644 index 0000000..1de4a60 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/no_newline_at_end.html @@ -0,0 +1,4 @@ +
+

This is a block quote +with no newline.

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/no_newline_at_end.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/no_newline_at_end.text new file mode 100644 index 0000000..402648a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/no_newline_at_end.text @@ -0,0 +1,2 @@ +> This is a block quote +> with no newline. \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/very_long_line.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/very_long_line.html new file mode 100644 index 0000000..4a9aaf5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/very_long_line.html @@ -0,0 +1,3 @@ +
+

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/very_long_line.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/very_long_line.text new file mode 100644 index 0000000..a2b33bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/very_long_line.text @@ -0,0 +1 @@ +> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/with_code_blocks.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/with_code_blocks.html new file mode 100644 index 0000000..30abd99 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/with_code_blocks.html @@ -0,0 +1,15 @@ +
+

Example:

+ +
sub status {
+    print "working";
+}
+
+ +

Or:

+ +
sub status {
+    return "working";
+}
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/with_code_blocks.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/with_code_blocks.text new file mode 100644 index 0000000..3b188dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/05_blockquote/with_code_blocks.text @@ -0,0 +1,11 @@ +>Example: +> +> sub status { +> print "working"; +> } +> +> Or: +> +> sub status { +> return "working"; +> } diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.html new file mode 100644 index 0000000..142a5d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.html @@ -0,0 +1,4 @@ +
x = Class.new
+
+
<a>href</a>
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.options new file mode 100644 index 0000000..72e9bc1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.options @@ -0,0 +1 @@ +:enable_coderay: false diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.text new file mode 100644 index 0000000..af4d0bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/disable-highlighting.text @@ -0,0 +1,4 @@ + x = Class.new +^ + href +{: lang="html"} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/error.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/error.html new file mode 100644 index 0000000..d9f9da3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/error.html @@ -0,0 +1,4 @@ +

Some para

+ +

~~~~~~ +not codeblock

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/error.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/error.text new file mode 100644 index 0000000..60ea366 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/error.text @@ -0,0 +1,4 @@ +Some para + +~~~~~~ +not codeblock diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.html new file mode 100644 index 0000000..066e909 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.html @@ -0,0 +1,15 @@ +
class Foo
+  def bar
+    puts 'Hello'
+  end
+end
+
+
+ +
class Foo
+  def bar
+    puts 'Hello'
+  end
+end
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.options new file mode 100644 index 0000000..bfc92f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.options @@ -0,0 +1,2 @@ +:syntax_highlighter_opts: + guess_lang: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.text new file mode 100644 index 0000000..4b074a8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/guess_lang_css_class.text @@ -0,0 +1,13 @@ +~~~ +class Foo + def bar + puts 'Hello' + end +end +~~~ + + class Foo + def bar + puts 'Hello' + end + end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.latex new file mode 100644 index 0000000..a092a1f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.latex @@ -0,0 +1,9 @@ +\begin{minted}[breaklines,linenos]{ruby} +x = Class.new + +\end{minted} + +\begin{minted}[breaklines,linenos]{html} +this is a reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, long link + +\end{minted} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.options new file mode 100644 index 0000000..b773fc8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.options @@ -0,0 +1,4 @@ +:syntax_highlighter: minted +:syntax_highlighter_opts: + wrap: true + line_numbers: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.text new file mode 100644 index 0000000..2636518 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted-with-opts.text @@ -0,0 +1,5 @@ + x = Class.new +{: .language-ruby} + + this is a reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, reaally, long link +{: .language-html} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.latex new file mode 100644 index 0000000..354d6ab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.latex @@ -0,0 +1,8 @@ +\begin{minted}[]{ruby} +x = Class.new + +\end{minted} +\begin{minted}[]{html} +href + +\end{minted} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.options new file mode 100644 index 0000000..b2ee189 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.options @@ -0,0 +1,3 @@ +:syntax_highlighter: minted +:syntax_highlighter_opts: + default_lang: ruby diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.text new file mode 100644 index 0000000..5ac4746 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-minted.text @@ -0,0 +1,4 @@ + x = Class.new +^ + href +{: .language-html} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.html new file mode 100644 index 0000000..b694d37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.html @@ -0,0 +1,6 @@ +
x = Class.new
+
+
+
<a>href</a>
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.options new file mode 100644 index 0000000..be21a32 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.options @@ -0,0 +1,7 @@ +:syntax_highlighter_opts: + block: + css: class + default_lang: ruby + wrap: span + line_numbers: null + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.text new file mode 100644 index 0000000..5ac4746 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting-opts.text @@ -0,0 +1,4 @@ + x = Class.new +^ + href +{: .language-html} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.html new file mode 100644 index 0000000..33dd015 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.html @@ -0,0 +1,5 @@ +
x = Class.new
+
+
<a>href</a>
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.options new file mode 100644 index 0000000..8133537 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.options @@ -0,0 +1,5 @@ +:coderay_default_lang: ruby +:coderay_wrap: span +:coderay_line_numbers: ~ +:coderay_css: class + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.text new file mode 100644 index 0000000..5ac4746 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/highlighting.text @@ -0,0 +1,4 @@ + x = Class.new +^ + href +{: .language-html} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/issue_gh45.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/issue_gh45.html new file mode 100644 index 0000000..b096a9e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/issue_gh45.html @@ -0,0 +1,164 @@ + +

B

+ +
                       BBBBBBBB. 
+
+
+
+           BBBB BB BBBBBBBB BBBBB. BBBBBBB BB BBBBB BB BBB BBBB BBBBB BBB BBB BBBB BBB BBBBBBB BBB BBBBBBB. B BBB'B BBBBB BBBB BBB BBBB BBBBBBB BBBB BBBB BBBB BBBBBBBB.
+
+
+                BBB BBBBB BBBBB BBB BBBB BBBB BBBB, BBB BBBBB BB BBBBB BBB BB BBBBBB BBBB BBB BBBBB BBBB BB. BBBBB BBB BBBBB BBBBB BBB BBBB BB BBBB BBBB BBBBB.
+
+
+                         BBBB BBBBB, BBBBB, BBBBBBBB?
+
+                   BB BBB BB BBBB BBB BBBB BBB BBBBBB /BBB BB BBBBBBBBB BBBB BBBBBBB BBBBBB BB BBB. 
+
+
+                   BBBB BBBBBBBB BBB BBBB BB BBBBB BBB BBBBBB BBBB BBBBB BBBBBB BBBBBBBBB BBBB BB BBBBB......................................................................
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+              BBBBB B'B BBB BBBBB. BBBB BBBBB BBBBB. ( B BBBBB BBBBBBBBBB BBBBB BBBB'B BBBBB BBBBB. BBB BBBB BBBBB BBBB BBBB. BBBBBBB BBB BB BBBBBBB BBB BBB B BBBB BBBBBBBBBBBB. BBBBB BBBBB.)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+             BBBB'B BB
+
+ +

.

+ +
        B BBB BBB BBB ? B. B BBB BBBBBB BBBB BBB BBBB. BBBBBBB BB BBBBBBB B BBBB BBBB BBB BBBBBB. 
+
+
+
+
+
+
+
+
+
+
+
+
+
+         BBBB BB 'BBBB' BBBB BBBBB.
+
+
+                           BBBBBBBB B BBBB BBBBBB BB BBBBBBBB BBB BBBBBBB BBBBBBB BBBBBBB. 
+
+
+     B BBBB BB BBBB. BBBBB BBBBBBBB. BBB BB BB. BB BB BBBB BB BBBBBBBBBB. BB BBBBBBBB BB BBBBBBBBB. 
+
+
+                     BBBBBBBB BB BBBB. BBBBBBB BBB BBBBB BBBBB BBBBB. B'BB BBBBBBB BB BBBBB BBBBB BBBBBBB BBB BBBBB. BBBB. 
+
+  B BBBBBB BBBB BB BBBB BBB. (BB BBB BBBBB BBBBB...............B)
+
+
+
+           BBBB!
+
+
+
+         BBBB BB BBB BBBBBBB BBBBBB.            B
+
+ +

B

+ +
     BBBBB BB/BBB BBBBB!  BBBB BBBB BBBBBBBBBBB 'BBB'B BBBBBB.' 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+          BBBB BBBBBBB BBBB BB BBB BBBBBBBB BB BBBB BBBBBB BBB BBBBBBBBB BBBB. BBBBBBBB BBBBBBB BBBB BBBB BBBB BB BBBB BB BBBB BB BBBB B BBB BB BBBBB BBBBBB.  B BBBB BBBBBBB BB BBBB BBBBB B BBB BBBBBBB BB BBBBB BBBB. BBB BBBBBBB BBBB. B BBB BBBB BBBB B BBBB BBBBBB BBB B BBBBBB BBBBBB. BBB BB BBBBBB BBBBBB BBBBBBBBBB BB...BBBBB BBBB BBBB BB BBBBB. (BBBBBBB BBB BBBBBB BBB'B BBBB BBB BBBBB BBB BB BBBBB BBBBBBBBBBB  BBBBB B BBBB BBBB BBBBB. 
+
+
+
+
+
+
+
+
+
+BBBBB BB BB BBBB B'B BBBB BBBBB BBBBB BBB BB BBBBBB/BBB (BBBBB) BBBBBB BB. 
+                          BBBBBBBB. B BBB BBBB BB BB BBB/BBBBBB BBBBBB BBB BBBB BBBBBBBB BB BB B BBBBBB BBBBBB BBBBB. (BBB/B BBB BBBB BBBB...BBB BBB BBB BBBB BB BB B BBBB BB BBB BB? BBBBBBB B BBB B BBBB BBBBBBBB BBB B BBB BBB BBBBB BBBB BBB BBBB BB B BBBBBBBB BB BBBBB BB BB BBB BBBBB BBB BB BBBBB BBBBBBB B BBB BBBBBBB. BBBBBB (BBBBB) BBBB BBBBB BBBBBBB BBBBB BBBB BBBB BBB. 100 BBBBBB BB BBBBB. BBBB BBB BBB BBBBBB BBB BB. BBB BBBB BB BBB BBBBB! BBB BB BBBBBB BBBBB B BBB'B BBBBBBBBB BBBB BBB BBB. (BBBBBB BBBBBBB BB BBBB BBBBB (BBBBBB BBBBB BBBBB BBBBB.))
+
+
+    BBB B BBBBBBBBBBB BBBB BBB BB BBB. BBBBB BBB BBBBB B BBBB BBBBBB BBBBB BBB. BB BBBBBB BBB BBBB B BBB BB BBBBBBBB BBBBBB BBBB BBB B BBBBBB BBBB BBBBBB BBBBBBB BBBB BBBB BBB BBBBBBBB.
+
+
+
+
+
+
+
+
+
+
+
+           BBBBB!!!!!!!
+
+
+         B BBB BBBB BBBBBB BBBB BBBB BBBB B BBB BBBBB BBB BBBBB B BBBB BBBBBBB BB BB BBBB BBBBBBBBB. B BBBB BBBBBB BBBBBBB BBBB BBBB BBB BBBB.
+
+                                               BB BB, BB BBBBBB BBBB, (BBBBBB BB BBB BBBB . BBBBB BB BBBB BBBB BB BB BBBB BBBB B BBBB BB BB (BB BBBB BB BBB BBBBBBB BB BBBBBBB. )) BB'BB BBB BBB'B BB BB BBBB BB B BBBB B BBBBB (BB BBBBBB BB BBB B'BB BBBBBBBB BB BBBB BBBB.)
+
+
+  B BBBBB B'BB BBB BB BBBB BBB BBB.
+
+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/issue_gh45.test b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/issue_gh45.test new file mode 100644 index 0000000..1bf8901 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/issue_gh45.test @@ -0,0 +1,188 @@ + + + B + + + + + BBBBBBBB. + + + + BBBB BB BBBBBBBB BBBBB. BBBBBBB BB BBBBB BB BBB BBBB BBBBB BBB BBB BBBB BBB BBBBBBB BBB BBBBBBB. B BBB'B BBBBB BBBB BBB BBBB BBBBBBB BBBB BBBB BBBB BBBBBBBB. + + + BBB BBBBB BBBBB BBB BBBB BBBB BBBB, BBB BBBBB BB BBBBB BBB BB BBBBBB BBBB BBB BBBBB BBBB BB. BBBBB BBB BBBBB BBBBB BBB BBBB BB BBBB BBBB BBBBB. + + + BBBB BBBBB, BBBBB, BBBBBBBB? + + BB BBB BB BBBB BBB BBBB BBB BBBBBB /BBB BB BBBBBBBBB BBBB BBBBBBB BBBBBB BB BBB. + + + BBBB BBBBBBBB BBB BBBB BB BBBBB BBB BBBBBB BBBB BBBBB BBBBBB BBBBBBBBB BBBB BB BBBBB...................................................................... + + + + + + + + + + + + + + + + + + + + + + BBBBB B'B BBB BBBBB. BBBB BBBBB BBBBB. ( B BBBBB BBBBBBBBBB BBBBB BBBB'B BBBBB BBBBB. BBB BBBB BBBBB BBBB BBBB. BBBBBBB BBB BB BBBBBBB BBB BBB B BBBB BBBBBBBBBBBB. BBBBB BBBBB.) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BBBB'B BB + + + + + + + + + + + + + + + + + + +. + + B BBB BBB BBB ? B. B BBB BBBBBB BBBB BBB BBBB. BBBBBBB BB BBBBBBB B BBBB BBBB BBB BBBBBB. + + + + + + + + + + + + + + BBBB BB 'BBBB' BBBB BBBBB. + + + BBBBBBBB B BBBB BBBBBB BB BBBBBBBB BBB BBBBBBB BBBBBBB BBBBBBB. + + + B BBBB BB BBBB. BBBBB BBBBBBBB. BBB BB BB. BB BB BBBB BB BBBBBBBBBB. BB BBBBBBBB BB BBBBBBBBB. + + + BBBBBBBB BB BBBB. BBBBBBB BBB BBBBB BBBBB BBBBB. B'BB BBBBBBB BB BBBBB BBBBB BBBBBBB BBB BBBBB. BBBB. + + B BBBBBB BBBB BB BBBB BBB. (BB BBB BBBBB BBBBB...............B) + + + + BBBB! + + + + BBBB BB BBB BBBBBBB BBBBBB. +B + +B + + + + BBBBB BB/BBB BBBBB! BBBB BBBB BBBBBBBBBBB 'BBB'B BBBBBB.' + + + + + + + + + + + + + + + BBBB BBBBBBB BBBB BB BBB BBBBBBBB BB BBBB BBBBBB BBB BBBBBBBBB BBBB. BBBBBBBB BBBBBBB BBBB BBBB BBBB BB BBBB BB BBBB BB BBBB B BBB BB BBBBB BBBBBB. B BBBB BBBBBBB BB BBBB BBBBB B BBB BBBBBBB BB BBBBB BBBB. BBB BBBBBBB BBBB. B BBB BBBB BBBB B BBBB BBBBBB BBB B BBBBBB BBBBBB. BBB BB BBBBBB BBBBBB BBBBBBBBBB BB...BBBBB BBBB BBBB BB BBBBB. (BBBBBBB BBB BBBBBB BBB'B BBBB BBB BBBBB BBB BB BBBBB BBBBBBBBBBB BBBBB B BBBB BBBB BBBBB. + + + + + + + + + + BBBBB BB BB BBBB B'B BBBB BBBBB BBBBB BBB BB BBBBBB/BBB (BBBBB) BBBBBB BB. + BBBBBBBB. B BBB BBBB BB BB BBB/BBBBBB BBBBBB BBB BBBB BBBBBBBB BB BB B BBBBBB BBBBBB BBBBB. (BBB/B BBB BBBB BBBB...BBB BBB BBB BBBB BB BB B BBBB BB BBB BB? BBBBBBB B BBB B BBBB BBBBBBBB BBB B BBB BBB BBBBB BBBB BBB BBBB BB B BBBBBBBB BB BBBBB BB BB BBB BBBBB BBB BB BBBBB BBBBBBB B BBB BBBBBBB. BBBBBB (BBBBB) BBBB BBBBB BBBBBBB BBBBB BBBB BBBB BBB. 100 BBBBBB BB BBBBB. BBBB BBB BBB BBBBBB BBB BB. BBB BBBB BB BBB BBBBB! BBB BB BBBBBB BBBBB B BBB'B BBBBBBBBB BBBB BBB BBB. (BBBBBB BBBBBBB BB BBBB BBBBB (BBBBBB BBBBB BBBBB BBBBB.)) + + + BBB B BBBBBBBBBBB BBBB BBB BB BBB. BBBBB BBB BBBBB B BBBB BBBBBB BBBBB BBB. BB BBBBBB BBB BBBB B BBB BB BBBBBBBB BBBBBB BBBB BBB B BBBBBB BBBB BBBBBB BBBBBBB BBBB BBBB BBB BBBBBBBB. + + + + + + + + + + + + BBBBB!!!!!!! + + + B BBB BBBB BBBBBB BBBB BBBB BBBB B BBB BBBBB BBB BBBBB B BBBB BBBBBBB BB BB BBBB BBBBBBBBB. B BBBB BBBBBB BBBBBBB BBBB BBBB BBB BBBB. + + BB BB, BB BBBBBB BBBB, (BBBBBB BB BBB BBBB . BBBBB BB BBBB BBBB BB BB BBBB BBBB B BBBB BB BB (BB BBBB BB BBB BBBBBBB BB BBBBBBB. )) BB'BB BBB BBB'B BB BB BBBB BB B BBBB B BBBBB (BB BBBBBB BB BBB B'BB BBBBBBBB BB BBBB BBBB.) + + + B BBBBB B'BB BBB BB BBBB BBB BBB. + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/lazy.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/lazy.html new file mode 100644 index 0000000..47188f2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/lazy.html @@ -0,0 +1,4 @@ +
This is some code
+
+This is some  other code
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/lazy.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/lazy.text new file mode 100644 index 0000000..2a95de6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/lazy.text @@ -0,0 +1,5 @@ + This is some +code + + This is some + other code diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end.html new file mode 100644 index 0000000..7a003b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end.html @@ -0,0 +1,2 @@ +
test  
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end.text new file mode 100644 index 0000000..b64563f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end.text @@ -0,0 +1 @@ + test \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end_1.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end_1.html new file mode 100644 index 0000000..005870e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end_1.html @@ -0,0 +1,2 @@ +
test   test
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end_1.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end_1.text new file mode 100644 index 0000000..65df71e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/no_newline_at_end_1.text @@ -0,0 +1,2 @@ + test +test diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/normal.html new file mode 100644 index 0000000..0bd2c1f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/normal.html @@ -0,0 +1,13 @@ +
starting code
+
+ +

paragraph

+ +
other code  
+with samples 
+
+ +

paragraph

+ +
  ending code
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/normal.text new file mode 100644 index 0000000..40ea702 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/normal.text @@ -0,0 +1,10 @@ + starting code + +paragraph + + other code + with samples + +paragraph + + ending code diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.html new file mode 100644 index 0000000..2cc34d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.html @@ -0,0 +1,2 @@ +
x = Class.new
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.options new file mode 100644 index 0000000..5688828 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.options @@ -0,0 +1,4 @@ +:syntax_highlighter: rouge +:syntax_highlighter_opts: + block: + disable: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.text new file mode 100644 index 0000000..0e50b41 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/disabled.text @@ -0,0 +1 @@ + x = Class.new diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.html new file mode 100644 index 0000000..6ece543 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.html @@ -0,0 +1,11 @@ +
puts "Hello"
+
+
+ +
puts "World"
+
+
+ +
$foo = new Bar;
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.options new file mode 100644 index 0000000..b910f75 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.options @@ -0,0 +1,4 @@ +:syntax_highlighter: rouge +:syntax_highlighter_opts: + default_lang: ruby + formatter: RougeHTMLFormatters diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.text new file mode 100644 index 0000000..d1dd283 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/multiple.text @@ -0,0 +1,11 @@ +~~~ ruby +puts "Hello" +~~~ + +~~~ ruby +puts "World" +~~~ + +~~~ php?start_inline=1 +$foo = new Bar; +~~~ \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.html new file mode 100644 index 0000000..1c2259a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.html @@ -0,0 +1,10 @@ +
x = Class.new
+
+
+
<a>href</a>
+
+
+ +
$foo = new Bar;
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.options new file mode 100644 index 0000000..f59e0ff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.options @@ -0,0 +1,3 @@ +:syntax_highlighter: rouge +:syntax_highlighter_opts: + default_lang: ruby diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.text new file mode 100644 index 0000000..6c740e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/rouge/simple.text @@ -0,0 +1,9 @@ + x = Class.new +^ + href +{: .language-html} + + +~~~ php?start_inline=1 +$foo = new Bar; +~~~ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/tilde_syntax.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/tilde_syntax.html new file mode 100644 index 0000000..1ddd91e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/tilde_syntax.html @@ -0,0 +1,7 @@ +
Here comes some code.
+
+ +
~~~~~~~
+code with tildes
+~~~~~~~~
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/tilde_syntax.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/tilde_syntax.text new file mode 100644 index 0000000..7625a1b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/tilde_syntax.text @@ -0,0 +1,9 @@ +~~~~~~~~ +Here comes some code. +~~~~~~~~ + +~~~~~~~~~~~~ +~~~~~~~ +code with tildes +~~~~~~~~ +~~~~~~~~~~~~~~~~~~ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/whitespace.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/whitespace.html new file mode 100644 index 0000000..dcbb40f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/whitespace.html @@ -0,0 +1,3 @@ +
This	issome
+whitespace
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/whitespace.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/whitespace.text new file mode 100644 index 0000000..b15c9c9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/whitespace.text @@ -0,0 +1,3 @@ + This is some + whitespace +{:.show-whitespaces} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_blank_line.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_blank_line.html new file mode 100644 index 0000000..f7c20b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_blank_line.html @@ -0,0 +1,13 @@ +

paragraph

+ +
code block
+
+continued here
+
+ +

ended

+ +
next blank line has 4 spaces
+
+ +

paragraph

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_blank_line.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_blank_line.text new file mode 100644 index 0000000..e51dfa5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_blank_line.text @@ -0,0 +1,12 @@ +paragraph + + code block + + continued here + + +ended + + next blank line has 4 spaces + +paragraph diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_eob_marker.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_eob_marker.html new file mode 100644 index 0000000..cca17a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_eob_marker.html @@ -0,0 +1,6 @@ +
code block
+
+continued here
+
+
new block here
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_eob_marker.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_eob_marker.text new file mode 100644 index 0000000..834c768 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_eob_marker.text @@ -0,0 +1,5 @@ + code block + + continued here +^ + new block here diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_ial.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_ial.html new file mode 100644 index 0000000..77085b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_ial.html @@ -0,0 +1,6 @@ +
code block
+
+continued here
+
+
new block here
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_ial.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_ial.text new file mode 100644 index 0000000..4489f2d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_ial.text @@ -0,0 +1,5 @@ + code block + + continued here +{:.cls} + new block here diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.html new file mode 100644 index 0000000..f5872c3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.html @@ -0,0 +1,24 @@ +
def what?
+  42
+end
+
+ +
def what?
+  42
+end
+
+ +
def what?
+  42
+end
+
+ +
def what?
+  42
+end
+
+ +
def what?
+  42
+end
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options new file mode 100644 index 0000000..e2e91db --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options @@ -0,0 +1,2 @@ +:syntax_highlighter: null + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.text new file mode 100644 index 0000000..07f437e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block.text @@ -0,0 +1,33 @@ +~~~ ruby +def what? + 42 +end +~~~ + +~~~ ruby +def what? + 42 +end +~~~ +{:.class1} + +~~~ +def what? + 42 +end +~~~ +{: .language-ruby} + +~~~ ruby +def what? + 42 +end +~~~ +{: .language-python} + +~~~ ruby +def what? + 42 +end +~~~ +{: class="language-python"} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.html new file mode 100644 index 0000000..2530b1e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.html @@ -0,0 +1,8 @@ +
text
+
+ +
text
+
+ +
text
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.options new file mode 100644 index 0000000..871923c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.options @@ -0,0 +1,2 @@ +:enable_coderay: false + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text new file mode 100644 index 0000000..60424a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text @@ -0,0 +1,11 @@ +~~~ asn.1 +text +~~~ + +~~~ asn#w1 +text +~~~ + +~~~ русский +text +~~~ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.html new file mode 100644 index 0000000..aa4b60f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.html @@ -0,0 +1,3 @@ +
s1'dim'a'500'm'500'q'500''
+index'j'j+1'j-1''
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.options new file mode 100644 index 0000000..871923c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.options @@ -0,0 +1,2 @@ +:enable_coderay: false + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text new file mode 100644 index 0000000..423d5b7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text @@ -0,0 +1,4 @@ +~~~ act-iii +s1'dim'a'500'm'500'q'500'' +index'j'j+1'j-1'' +~~~ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/error.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/error.html new file mode 100644 index 0000000..068811c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/error.html @@ -0,0 +1,7 @@ +

_ * _

+ +

— * * *

+ +

_ - *

+ +

———————————————- test

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/error.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/error.text new file mode 100644 index 0000000..a024710 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/error.text @@ -0,0 +1,7 @@ +_ * _ + +--- * * * + +_ - * + +---------------------------------------------- test diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/normal.html new file mode 100644 index 0000000..e74b6e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/normal.html @@ -0,0 +1,19 @@ +
+
+
+ +

d- -

+ +
+
+
+ +

para

+

text

+ +
+ +
- - -
+
+ +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/normal.text new file mode 100644 index 0000000..986101a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/normal.text @@ -0,0 +1,20 @@ +*** +* * * +- - - + +d- - + +--- +___ +*** + +para +----------- +text + +* * * + + - - - + +* * * +{:.test} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/sepspaces.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/sepspaces.html new file mode 100644 index 0000000..dbb86e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/sepspaces.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/sepspaces.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/sepspaces.text new file mode 100644 index 0000000..a5798b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/sepspaces.text @@ -0,0 +1,3 @@ +- - - +* * * +_ _ _ _ _ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/septabs.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/septabs.html new file mode 100644 index 0000000..dbb86e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/septabs.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/septabs.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/septabs.text new file mode 100644 index 0000000..464fe20 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/07_horizontal_rule/septabs.text @@ -0,0 +1,3 @@ +- - - +* * * +_ _ _ _ _ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/brackets_in_item.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/brackets_in_item.latex new file mode 100644 index 0000000..e71fde2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/brackets_in_item.latex @@ -0,0 +1,3 @@ +\begin{itemize} +\item{} {[}and{]} another +\end{itemize} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/brackets_in_item.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/brackets_in_item.text new file mode 100644 index 0000000..515e3a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/brackets_in_item.text @@ -0,0 +1 @@ +* \[and\] another diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/escaping.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/escaping.html new file mode 100644 index 0000000..afc795c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/escaping.html @@ -0,0 +1,17 @@ +

I have read the book +1984. It was great +- other say that, too!

+ +

I have read the book +1984. It was great +- other say that, too!

+ +

I have read the book + 1984. It was great.

+ +

I have read the book 1984. + - it was great!

+ +

1984. Was great!

+ +

- This too!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/escaping.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/escaping.text new file mode 100644 index 0000000..c3b1c59 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/escaping.text @@ -0,0 +1,17 @@ +I have read the book +1984. It was great +- other say that, too! + +I have read the book +1984\. It was great +\- other say that, too! + +I have read the book + 1984. It was great. + +I have read the book 1984. + - it was great! + +1984\. Was great! + +\- This too! diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/item_ial.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/item_ial.html new file mode 100644 index 0000000..e6dfd3a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/item_ial.html @@ -0,0 +1,10 @@ +
    +
  • IAL at first +continued
  • +
  • another {:.cls}
  • +
  • IAL at last + code
  • +
  • X + test
  • +
  • X OK
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/item_ial.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/item_ial.text new file mode 100644 index 0000000..67bee70 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/item_ial.text @@ -0,0 +1,8 @@ +* {:.cls} IAL at first + continued +* another {:.cls} +* {:.cls} IAL at last + code +* {::nomarkdown type="html"}X{:/nomarkdown} + test +* {::nomarkdown type="html"}X{:/nomarkdown} OK diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy.html new file mode 100644 index 0000000..01a5f9d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy.html @@ -0,0 +1,39 @@ +
    +
  • This is a simple +list item
  • +
  • +

    Followed by another +list item

    +
  • +
  • +

    Followed by

    + +

    a para list item +continued here

    +
  • +
  • and a normal one
  • +
  • +

    and

    + +

    a para +continued here

    +
  • +
+ +

para

+ +
    +
  • multi line +list item
  • +
+ +

para

+ +
    +
  • list item line1 + one line + two lines
  • +
  • list item line2 +one line +two lines
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy.text new file mode 100644 index 0000000..f372422 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy.text @@ -0,0 +1,29 @@ +* This is a simple +list item +* Followed by another +list item + + +* Followed by + + a para list item +continued here +* and a normal one +* and + + a para +continued here + +para + +* multi line +list item + +para + +* list item line1 + one line + two lines +* list item line2 + one line +two lines diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy_and_nested.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy_and_nested.html new file mode 100644 index 0000000..90c7447 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy_and_nested.html @@ -0,0 +1,9 @@ +
    +
  1. Root level + * Second level +
      +
    • Third level + * Back to second level
    • +
    +
  2. +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy_and_nested.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy_and_nested.text new file mode 100644 index 0000000..97a7755 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/lazy_and_nested.text @@ -0,0 +1,4 @@ +1. Root level + * Second level + * Third level + * Back to second level diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_hr.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_hr.html new file mode 100644 index 0000000..ecf51c7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_hr.html @@ -0,0 +1,9 @@ +
    +
  • Starting a list
  • +
+ +
+ +
    +
  • Starting a new list
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_hr.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_hr.text new file mode 100644 index 0000000..c7fcd47 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_hr.text @@ -0,0 +1,5 @@ +* Starting a list + +* * * + +* Starting a new list diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_others.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_others.html new file mode 100644 index 0000000..672428e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_others.html @@ -0,0 +1,40 @@ +
    +
  • list item
  • +
+ +
+

blockquote

+
+ +

para +* * * +para + - no list

+ +
    +
  • +

    item

    + +
    +

    block

    +
    + +

    header

    +
  • +
  • +

    test

    + +
    codeblock
    +
    + +

    test

    +
  • +
  • +

    test

    + +
    codeblock
    +
    + +

    test

    +
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_others.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_others.text new file mode 100644 index 0000000..f680262 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/list_and_others.text @@ -0,0 +1,26 @@ +* list item + +> blockquote + +para +* * * +para + - no list + ++ item + + > block + + ## header + +* test + + codeblock + + test + +* test + + codeblock + + test diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/mixed.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/mixed.html new file mode 100644 index 0000000..9bc47e3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/mixed.html @@ -0,0 +1,117 @@ +

With tabs/spaces, no paras:

+ +
    +
  • item1
  • +
  • item2
  • +
  • item3
  • +
+ +

With tabs/spaces, paras:

+ +
    +
  • +

    item1

    +
  • +
  • +

    item2

    +
  • +
  • +

    item3

    +
  • +
+ +

With tabs/spaces, no paras:

+ +
    +
  1. item1
  2. +
  3. item2
  4. +
  5. item3
  6. +
+ +

With tabs/spaces, paras:

+ +
    +
  1. +

    item1

    +
  2. +
  3. +

    item2

    +
  4. +
  5. +

    item3

    +
  6. +
+ +

Nested, without paras:

+ +
    +
  • item1 +
      +
    • item2 +
        +
      • item3
      • +
      +
    • +
    +
  • +
+ +

Nested, with paras:

+ +
    +
  • +

    item1

    + +
      +
    • item2 +
        +
      • item3 (level 3)
      • +
      +
    • +
    +
  • +
+ +

Ordered, without paras:

+ +
    +
  1. item1
  2. +
  3. item2 +
      +
    • do
    • +
    • it
    • +
    • now
    • +
    +
  4. +
  5. item3
  6. +
+ +

Ordered, with paras:

+ +
    +
  1. +

    item1

    +
  2. +
  3. +

    item2

    + +
      +
    • do
    • +
    • it
    • +
    • now
    • +
    +
  4. +
  5. +

    item3

    +
  6. +
+ +

Mixed tabs and spaces:

+ +
    +
  • some text +
      +
    • nested
    • +
    +
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/mixed.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/mixed.text new file mode 100644 index 0000000..22b578d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/mixed.text @@ -0,0 +1,66 @@ +With tabs/spaces, no paras: + +* item1 ++ item2 +- item3 + +With tabs/spaces, paras: + +- item1 + +* item2 + ++ item3 + +With tabs/spaces, no paras: + +1. item1 +20. item2 +3. item3 + +With tabs/spaces, paras: + +1. item1 + +2. item2 + +3. item3 + +Nested, without paras: + +* item1 + * item2 + * item3 + +Nested, with paras: + ++ item1 + + * item2 + * item3 (level 3) + +Ordered, without paras: + +1. item1 +2. item2 + * do + * it + * now +3. item3 + +Ordered, with paras: + +1. item1 + +2. item2 + + * do + * it + * now + +3. item3 + +Mixed tabs and spaces: + +* some text + * nested diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/nested.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/nested.html new file mode 100644 index 0000000..1921ee9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/nested.html @@ -0,0 +1,17 @@ +
    +
  • some item +
      +
    • nested
    • +
    +
  • +
  • last item
  • +
+
    +
  • +

    some text

    + +
      +
    • nested
    • +
    +
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/nested.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/nested.text new file mode 100644 index 0000000..c71d864 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/nested.text @@ -0,0 +1,7 @@ +* some item + * nested +* last item +^ +* some text + + * nested diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/other_first_element.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/other_first_element.html new file mode 100644 index 0000000..3f4cd0f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/other_first_element.html @@ -0,0 +1,39 @@ +
    +
  • +
    This is a code block.
    +
    +
  • +
  • +
    +

    This is a blockquote.

    +
    +
  • +
  • +

    A header

    +
  • +
+
    +
  • +
    This is a code block.
    +
    +
  • +
  • +
    +

    This is a blockquote. +continued by some para.

    +
    +
  • +
  • +

    A header

    +

    a para

    +
  • +
+
    +
  • +
      +
    • nested list
    • +
    • other nested item
    • +
    +
  • +
  • item 2
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/other_first_element.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/other_first_element.text new file mode 100644 index 0000000..321cef6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/other_first_element.text @@ -0,0 +1,18 @@ +* + This is a code block. +* > This is a blockquote. +* ## A header +^ +* + This is a code block. + +* > This is a blockquote. + continued by some para. + +* A header + ========= + a para +^ +* * nested list + * other nested item +* item 2 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ol.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ol.html new file mode 100644 index 0000000..84e5a6b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ol.html @@ -0,0 +1,19 @@ +
    +
  1. This is a simple list item
  2. +
  3. +

    Followed by another

    +
  4. +
  5. +

    Followed by

    + +

    a para list item

    +
  6. +
  7. and a normal one
  8. +
  9. +

    and

    + +

    a para

    +
  10. +
+ +

para

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ol.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ol.text new file mode 100644 index 0000000..aaf7dae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ol.text @@ -0,0 +1,13 @@ +1. This is a simple list item +3. Followed by another + + +10. Followed by + + a para list item +1. and a normal one +2. and + + a para + +para diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ul.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ul.html new file mode 100644 index 0000000..68db05e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ul.html @@ -0,0 +1,48 @@ +
    +
  • This is a simple list item
  • +
  • +

    Followed by another

    +
  • +
  • +

    Followed by

    + +

    a para list item

    +
  • +
  • and a normal one
  • +
  • +

    and

    + +

    a para

    +
  • +
+ +

para

+ +
    +
  • multi line +list item
  • +
+ +

para

+ +
    +
  • list item line1 +one line +two lines
  • +
  • list item line2 +one line +two lines
  • +
+ +

para

+ +
    +
  • list item line3 +one line +two lines
  • +
  • list item line4 + one line + two lines
  • +
+ +

para

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ul.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ul.text new file mode 100644 index 0000000..ccd25c3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/simple_ul.text @@ -0,0 +1,36 @@ +* This is a simple list item +* Followed by another + + +* Followed by + + a para list item +* and a normal one +* and + + a para + +para + +* multi line + list item + +para + +* list item line1 + one line + two lines +* list item line2 + one line + two lines + +para + +* list item line3 + one line + two lines +* list item line4 + one line + two lines + +para diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/single_item.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/single_item.html new file mode 100644 index 0000000..e079461 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/single_item.html @@ -0,0 +1,3 @@ +
    +
  • single
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/single_item.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/single_item.text new file mode 100644 index 0000000..877d369 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/single_item.text @@ -0,0 +1 @@ +* single diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/special_cases.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/special_cases.html new file mode 100644 index 0000000..fbc775a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/special_cases.html @@ -0,0 +1,62 @@ +
    +
  • +

    not a para +here

    + +
    +

    blockquote

    +
    +
  • +
  • +

    and not + here

    + +
    +

    blockquote

    +
    +
  • +
  • +

    this is a para

    +
  • +
  • +
    +

    blockquote

    +
    +
  • +
  • +

    this too

    +
  • +
+ +

A paragraph + 1. followed not by ol +- followed not by ul

+ +

A compact list:

+ +
    +
  • compact
  • +
  • list
  • +
  • items
  • +
+ +

A normal list:

+ +
    +
  • +

    not

    +
  • +
  • +

    compact

    +
  • +
  • +

    but here

    +
  • +
+ +

List item without content:

+ +
    +
  • +
  • a
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/special_cases.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/special_cases.text new file mode 100644 index 0000000..7406305 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/08_list/special_cases.text @@ -0,0 +1,40 @@ +* not a para + here + + > blockquote + +* and not + here + + >blockquote + +* this is a para + +* > blockquote + +* this too + +^ + +A paragraph + 1. followed not by ol +- followed not by ul + +A compact list: + +* compact +* list +* items + +A normal list: + +* not + +* compact + +* but here + +List item without content: + +* +* a diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/comment.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/comment.html new file mode 100644 index 0000000..8d31bd4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/comment.html @@ -0,0 +1,18 @@ + + +

para1

+ + + +

para2

+ + +

para

+ +
+

This is +

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/comment.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/comment.text new file mode 100644 index 0000000..b632bf2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/comment.text @@ -0,0 +1,15 @@ + + +para1 + + + +para2 + + para + +> This is +> diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.html new file mode 100644 index 0000000..587d55a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.html @@ -0,0 +1,6 @@ +
+
text
+
+

para

+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.options new file mode 100644 index 0000000..a660da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.options @@ -0,0 +1 @@ +:parse_block_html: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.text new file mode 100644 index 0000000..1e381d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/deflists.text @@ -0,0 +1,6 @@ +
+
*text*
+
+para +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.html new file mode 100644 index 0000000..e11dc14 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.html @@ -0,0 +1,14 @@ + + + + + + + + + +
Usage +Output +
Some data +

Some more

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.options new file mode 100644 index 0000000..a660da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.options @@ -0,0 +1 @@ +:parse_block_html: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.text new file mode 100644 index 0000000..c0cf2e7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/content_model/tables.text @@ -0,0 +1,14 @@ + + + + + + + + + +
*Usage* +Output +
Some *data* +# Some more +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html5_attributes.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html5_attributes.html new file mode 100644 index 0000000..743c822 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html5_attributes.html @@ -0,0 +1,15 @@ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html5_attributes.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html5_attributes.text new file mode 100644 index 0000000..44a060d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html5_attributes.text @@ -0,0 +1,15 @@ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

+ +

paragraph

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_after_block.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_after_block.html new file mode 100644 index 0000000..f51c75b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_after_block.html @@ -0,0 +1,7 @@ +

Para

+
division
+ +
+

Quote

+
+
division
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_after_block.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_after_block.text new file mode 100644 index 0000000..cdcbff6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_after_block.text @@ -0,0 +1,5 @@ +Para +
division
+ +> Quote +
division
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.html new file mode 100644 index 0000000..93d695a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.html @@ -0,0 +1,15 @@ +

para

+ +
codeblock
+
+ +
+

test

+
+ +
<p>codeblock</p>
+
+ +
+

test

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.options new file mode 100644 index 0000000..a660da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.options @@ -0,0 +1 @@ +:parse_block_html: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.text new file mode 100644 index 0000000..a3cfda7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_codeblocks.text @@ -0,0 +1,13 @@ +para + + codeblock + +
+ test +
+ +

codeblock

+ +
+ test +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_headers.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_headers.html new file mode 100644 index 0000000..65cb7e2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_headers.html @@ -0,0 +1,5 @@ +

header

+ +
+====== +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_headers.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_headers.text new file mode 100644 index 0000000..64dc477 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_and_headers.text @@ -0,0 +1,6 @@ +header +====== + +
+====== +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/code.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/code.html new file mode 100644 index 0000000..f4b3221 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/code.html @@ -0,0 +1,10 @@ +

This is a code span with <entities> that should be preserved. +This is a simple code span.

+ +

Some <

+ +
Some very important < thing
+
+ +
Some code<<
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/code.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/code.text new file mode 100644 index 0000000..fda7db5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/code.text @@ -0,0 +1,9 @@ +This is a code span with <entities> that should be preserved. +This is a simple code span. + +

Some <

+ +
Some very important < thing
+ +
Some code<<
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/comment.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/comment.html new file mode 100644 index 0000000..dacd437 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/comment.html @@ -0,0 +1,7 @@ +
+ + +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/comment.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/comment.text new file mode 100644 index 0000000..1788630 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/comment.text @@ -0,0 +1,8 @@ +
+ + + +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/emphasis.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/emphasis.html new file mode 100644 index 0000000..e4389c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/emphasis.html @@ -0,0 +1,6 @@ +

This is sizedhallo.

+ +

This is strongitalic, yes!.

+ +

This is not converted, as is + this.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/emphasis.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/emphasis.text new file mode 100644 index 0000000..7c75930 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/emphasis.text @@ -0,0 +1,6 @@ +This is sizedhallo. + +This is strongitalic, yes!. + +This is not converted, as is + this. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/entity.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/entity.html new file mode 100644 index 0000000..5c80ce6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/entity.html @@ -0,0 +1 @@ +

This is *raw* HTML text containing < entities!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/entity.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/entity.text new file mode 100644 index 0000000..5c80ce6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/entity.text @@ -0,0 +1 @@ +

This is *raw* HTML text containing < entities!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.html new file mode 100644 index 0000000..aebb206 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.html @@ -0,0 +1,6 @@ +

Some headerhere!

+

hallo

+

hallo

+

hallo

+
hallo
+
hallo
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.options new file mode 100644 index 0000000..987b4d9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.options @@ -0,0 +1,2 @@ +:auto_ids: true +:html_to_native: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.text new file mode 100644 index 0000000..27eed3b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/header.text @@ -0,0 +1,6 @@ +

Some headerhere!

+

hallo

+

hallo

+

hallo

+
hallo
+
hallo
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_dl.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_dl.html new file mode 100644 index 0000000..6eaccfe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_dl.html @@ -0,0 +1,8 @@ +
+
kram
+
down
+
kram
+
down
+
kram
+
down
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_dl.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_dl.text new file mode 100644 index 0000000..6eaccfe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_dl.text @@ -0,0 +1,8 @@ +
+
kram
+
down
+
kram
+
down
+
kram
+
down
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ol.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ol.html new file mode 100644 index 0000000..eeebdfb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ol.html @@ -0,0 +1,15 @@ +
    +
  1. This is a simple list item
  2. +
  3. +

    Followed by another

    +
  4. +
  5. +

    Followed by

    +

    a para list item

    +
  6. +
  7. and a normal one
  8. +
  9. +

    and

    +

    a para

    +
  10. +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ol.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ol.text new file mode 100644 index 0000000..41246df --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ol.text @@ -0,0 +1,17 @@ +
    +
  1. This is a simple list item
  2. +
  3. +

    Followed by another

    +
  4. +
  5. +

    Followed by

    + +

    a para list item

    +
  6. +
  7. and a normal one
  8. +
  9. +

    and

    + +

    a para

    +
  10. +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ul.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ul.html new file mode 100644 index 0000000..c9b38d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ul.html @@ -0,0 +1,19 @@ +
    +
  • This is a simple list item
  • +
  • +

    Followed by another

    +
  • +
  • +

    Followed by

    +

    a para list item

    +
  • +
  • and a normal one
  • +
  • +

    and

    +

    a para

    +
  • +
+ +
    +
  • multi line list item
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ul.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ul.text new file mode 100644 index 0000000..5a2d68e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/list_ul.text @@ -0,0 +1,22 @@ +
    +
  • This is a simple list item
  • +
  • +

    Followed by another

    +
  • +
  • +

    Followed by

    + +

    a para list item

    +
  • +
  • and a normal one
  • +
  • +

    and

    + +

    a para

    +
  • +
+ +
    +
  • multi line +list item
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/options new file mode 100644 index 0000000..63936b9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/options @@ -0,0 +1 @@ +:html_to_native: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/paragraph.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/paragraph.html new file mode 100644 index 0000000..a276b1c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/paragraph.html @@ -0,0 +1,3 @@ +

Some text here and end

+ +

Some other text here

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/paragraph.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/paragraph.text new file mode 100644 index 0000000..b10035c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/paragraph.text @@ -0,0 +1,4 @@ +

Some text here and end +

+ +

Some other text here

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_normal.html new file mode 100644 index 0000000..bdd79ee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_normal.html @@ -0,0 +1,12 @@ + + + + + + + + + +
UsageOther
Some *data* +

Some more

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_normal.text new file mode 100644 index 0000000..bdd79ee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_normal.text @@ -0,0 +1,12 @@ + + + + + + + + + +
UsageOther
Some *data* +

Some more

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_simple.html new file mode 100644 index 0000000..88d9e6c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_simple.html @@ -0,0 +1,61 @@ + + + + + + + + + + + +
UsageOutput
Some *data*Some more
+ + + + + + + + + + + + + + + + + + + + +
UsageOutput
Some *data*Some more
footlocker
+ + + + + + + + + + + + +
UsageOutput
Some *data*Some more
+ + + + + + + + + + +
Usage +Output +
Some *data* +Some more +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_simple.text new file mode 100644 index 0000000..ae7852b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/table_simple.text @@ -0,0 +1,71 @@ + + + + + + + + + +
Usage +Output +
Some *data* +Some more +
+ + + + + + + + + + + + + + + + + + + + +
Usage +Output +
Some *data* +Some more +
foot +locker +
+ + + + + + + + + + +
Usage +Output +
Some *data* +Some more +
+ + + + + + + + + + +
Usage +Output +
Some *data* +Some more +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/typography.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/typography.html new file mode 100644 index 0000000..2443965 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/typography.html @@ -0,0 +1 @@ +

This is … something “to remember”!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/typography.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/typography.text new file mode 100644 index 0000000..ee33c5c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/html_to_native/typography.text @@ -0,0 +1 @@ +

This is … something “to remember”!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_1.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_1.html new file mode 100644 index 0000000..77e0d78 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_1.html @@ -0,0 +1,5 @@ +

para

+ +

</div>

+ +

para

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_1.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_1.text new file mode 100644 index 0000000..f2fc834 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_1.text @@ -0,0 +1,5 @@ +para + +
+ +para diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_2.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_2.html new file mode 100644 index 0000000..b5da12f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_2.html @@ -0,0 +1,5 @@ +

para

+ +
+ +

para

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_2.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_2.text new file mode 100644 index 0000000..675c94f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/invalid_html_2.text @@ -0,0 +1,5 @@ +para + +
+ +para diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/markdown_attr.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/markdown_attr.html new file mode 100644 index 0000000..930b8f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/markdown_attr.html @@ -0,0 +1,38 @@ +
+

para

+
+ +
+para +
+ +
+

para

+
+ +
+*para* +
+ +

+

para

+

+ +

+para +

+ +

+para +

+ +

+*para* +

+ +
+
emphasize
+
+

para

+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/markdown_attr.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/markdown_attr.text new file mode 100644 index 0000000..12e5aee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/markdown_attr.text @@ -0,0 +1,38 @@ +
+*para* +
+ +
+*para* +
+ +
+*para* +
+ +
+*para* +
+ +

+*para* +

+ +

+*para* +

+ +

+*para* +

+ +

+*para* +

+ +
+
*emphasize*
+
+para +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/not_parsed.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/not_parsed.html new file mode 100644 index 0000000..90bda03 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/not_parsed.html @@ -0,0 +1,24 @@ +
+This is some text +
+ +
+This is some text +
+ +
+</p> +
+ +
+

Foo

+
+ +

This is some +text

+ +

http://example.com

+ +
+<http://example.com> +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/not_parsed.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/not_parsed.text new file mode 100644 index 0000000..1d1c71c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/not_parsed.text @@ -0,0 +1,24 @@ +
+This is some text +
+ +
+This is some text +
+ +
+

+
+ +
+

Foo

+
+ +

This is some +text

+ + + +
+ +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.html new file mode 100644 index 0000000..860f9b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.html @@ -0,0 +1,35 @@ +

baz { |qux| quux }

+ +

This is some para. +

+ + + + +

parsed +This too +

+ + + + + + + + + +

http://example.com

+ + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.htmlinput b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.htmlinput new file mode 100644 index 0000000..22b9ea5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.htmlinput @@ -0,0 +1,34 @@ +

baz { |qux| quux }

+ +

This is some para. +

+ + + + +

parsed +This too +

+ + + + + + + + + +

http://example.com

+ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.options new file mode 100644 index 0000000..a660da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.options @@ -0,0 +1 @@ +:parse_block_html: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.text new file mode 100644 index 0000000..e0617c4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_raw.text @@ -0,0 +1,33 @@ +

baz { |qux| quux }

+ +This is some para. + + + + +

*parsed* +This too +

+ + + + + + + + + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.html new file mode 100644 index 0000000..2a6191f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.html @@ -0,0 +1,12 @@ +

This text +should be parsed +as span +

+ +

This produces `

+

` an unwanted result.</p>

+ +

This text too

+

+some text +

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.htmlinput b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.htmlinput new file mode 100644 index 0000000..4199b8b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.htmlinput @@ -0,0 +1,12 @@ +

This text +should be parsed +as span +

+ +

This produces `

+

` an unwanted result.</p>

+ +

This text too

+

+some text +

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.options new file mode 100644 index 0000000..a660da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.options @@ -0,0 +1 @@ +:parse_block_html: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.text new file mode 100644 index 0000000..d07cf6d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_as_span.text @@ -0,0 +1,9 @@ +

This *text +should* be parsed +as span +

+ +

This produces `

` an unwanted result.

+ +

This *text* too

+some text diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.html new file mode 100644 index 0000000..8de78c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.html @@ -0,0 +1,21 @@ +

+

test

+
+ +
+
test
+
+
+
test
+
+
+
+ +
+
code block with </div>
+
+
+ +
+

No matching end tag

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.options new file mode 100644 index 0000000..a660da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.options @@ -0,0 +1 @@ +:parse_block_html: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.text new file mode 100644 index 0000000..b8b1845 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/parse_block_html.text @@ -0,0 +1,17 @@ +
+ test +
+ +
+ test +
+ test +
+
+ +
+ code block with
+
+ +
+No matching end tag diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/processing_instruction.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/processing_instruction.html new file mode 100644 index 0000000..939b996 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/processing_instruction.html @@ -0,0 +1,12 @@ +

<?xml version=”1.0”?>

+ +

para

+ +

<? test ?> para

+ +

other

+ +

<? +multiline text +is allowed +?>

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/processing_instruction.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/processing_instruction.text new file mode 100644 index 0000000..fcb866f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/processing_instruction.text @@ -0,0 +1,12 @@ + + +para + + para + +other + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.html new file mode 100644 index 0000000..0d926c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.html @@ -0,0 +1,60 @@ +
+

test

+
+ +

+para2 +

+ +
+

tes

+ +

test +weiter +

+
+ +

para4

+ +
+
+
+

foo

+
+
+
+
+

bar 

+
+
+ +

para5

+ +
+

id

+
+

test

+ +
+

hallo

+
+
+

hallo

+
+ +

para6

+ +
+
+

Another para.

+
+ +

Test

+ +

Test

+ +

Test + +

+ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.options new file mode 100644 index 0000000..a660da2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.options @@ -0,0 +1 @@ +:parse_block_html: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.text new file mode 100644 index 0000000..a2ffe25 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/simple.text @@ -0,0 +1,55 @@ +
+test +
+ +

+para2 +

+ +
+

tes

+ +

test +weiter +

+
+ +para4 + +
+
+
+foo +
+
+
+
bar  +
+
+ +para5 + +
id +
test + +
+hallo +
+hallo +
+ +para6 + +
+Another para. +
+ +Test + +

Test

+ +

Test + +

+ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/standalone_image_in_div.htmlinput b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/standalone_image_in_div.htmlinput new file mode 100644 index 0000000..72ff453 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/standalone_image_in_div.htmlinput @@ -0,0 +1,7 @@ +
+ inside +
+ +
+ text +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/standalone_image_in_div.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/standalone_image_in_div.text new file mode 100644 index 0000000..7f0d12c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/standalone_image_in_div.text @@ -0,0 +1,8 @@ +
+![inside](src.png) +
+ +
+[text](website.html) +
+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/table.kramdown b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/table.kramdown new file mode 100644 index 0000000..f8d6802 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/table.kramdown @@ -0,0 +1,8 @@ + + + + + + +
test
+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/table.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/table.text new file mode 100644 index 0000000..32e01da --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/table.text @@ -0,0 +1,7 @@ + + + + + + +
test
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/textarea.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/textarea.html new file mode 100644 index 0000000..6f5693e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/textarea.html @@ -0,0 +1,8 @@ +

This is a

+ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/textarea.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/textarea.text new file mode 100644 index 0000000..a240f5c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/textarea.text @@ -0,0 +1,8 @@ +This is a + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/xml.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/xml.html new file mode 100644 index 0000000..d941bc0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/xml.html @@ -0,0 +1,8 @@ + + +doit + +doit + +doit</some> + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/xml.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/xml.text new file mode 100644 index 0000000..6427fae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/09_html/xml.text @@ -0,0 +1,7 @@ + + +doit + +doit + +doit diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/10_ald/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/10_ald/simple.html new file mode 100644 index 0000000..74b03d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/10_ald/simple.html @@ -0,0 +1,2 @@ +

Some paragraph

+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/10_ald/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/10_ald/simple.text new file mode 100644 index 0000000..f58768a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/10_ald/simple.text @@ -0,0 +1,8 @@ +Some paragraph + +{:id: ref1} +{:id: .class1} + {:id: #id} + {:id: key="value"} + {:id: .class2 .class3 ref2 #id-with key="value" key='value' key='dfsd\}' } +{:test: k ey=value} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.html new file mode 100644 index 0000000..9857a03 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.html @@ -0,0 +1 @@ +

A header

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.options new file mode 100644 index 0000000..8776b55 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.options @@ -0,0 +1 @@ +:auto_ids: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.text new file mode 100644 index 0000000..f521fb0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/auto_id_and_ial.text @@ -0,0 +1,2 @@ +## A header +{:#myid .cls} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/nested.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/nested.html new file mode 100644 index 0000000..84cc368 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/nested.html @@ -0,0 +1,11 @@ +
+test +
+ +
+

test

+
+ +
+

para

+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/nested.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/nested.text new file mode 100644 index 0000000..827645c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/nested.text @@ -0,0 +1,15 @@ +{:.cls} +
+test +
+{:#id} + +{:.cls} +
+test +
+{:#id} + +{:.cls} +> para +{:#id} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/simple.html new file mode 100644 index 0000000..1086f0c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/simple.html @@ -0,0 +1,29 @@ +

Some paragraph.

+ +

Some paragraph.

+ +
+

quote

+
+ +
    +
  • list
  • +
+ +
code block
+
+ +
other code block
+
+ +

A header

+ +

Some paragraph here

+ +

Some paragraph here

+ +

Paragraph

+

Paragraph

+ +

Another header

+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/simple.text new file mode 100644 index 0000000..b97eef3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/11_ial/simple.text @@ -0,0 +1,41 @@ +Some paragraph. +{:.class .-class id key="val"} + +Some paragraph. +{:.cls1#id.cls2} + +> quote +{: #id} + {: .class} + +* list +{: key="val"} + + code block +{: #other} + + other code block + +## A header +{:#myid} + +{:.cls} +Some paragraph here + +{:.cls1} +{:.cls2} +Some paragraph here + +Paragraph +{:.cls} +Paragraph + +Another header +============== +{: .class #other} + +{:id: #id key="valo"} +{:id: #other .myclass other} +{:other: key1="val\"" - ig.nored as_is#this key2='val\'' .other-class} + +{:.invalid} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/comment.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/comment.html new file mode 100644 index 0000000..20b4c66 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/comment.html @@ -0,0 +1,8 @@ +

This is a simple paragraph.

+ + + +

And another paragraph

+ +

{::comment} +Another paragraph

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/comment.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/comment.text new file mode 100644 index 0000000..2dfc919 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/comment.text @@ -0,0 +1,12 @@ +This is a simple paragraph. + +{::comment} +This is a comment {:/}which is {:/comment} ignored. +{:/comment} + +And another paragraph + +{::comment this='is' .ignore /} + +{::comment} +Another paragraph diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/ignored.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/ignored.html new file mode 100644 index 0000000..17aae5c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/ignored.html @@ -0,0 +1,8 @@ +

paragraph

+ +

{::something} +anotherthing +{:/something}

+ +

{::something/} +paragraph

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/ignored.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/ignored.text new file mode 100644 index 0000000..ae94a8f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/ignored.text @@ -0,0 +1,8 @@ +paragraph + +{::something} +anotherthing +{:/something} + +{::something/} +paragraph diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.html new file mode 100644 index 0000000..7fe58d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.html @@ -0,0 +1,10 @@ +

This is a simple paragraph.

+ +This *is* not processed + +

And another paragraph

+ +bold + +

{::nomarkdown} +Another paragraph

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.kramdown b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.kramdown new file mode 100644 index 0000000..2cee512 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.kramdown @@ -0,0 +1,20 @@ +This is a simple paragraph. + +{::nomarkdown} +This *is* not processed +{:/} + +And another paragraph + +{::nomarkdown type="html"} +bold +{:/} + +{::nomarkdown type="latex"} +\begin{itemize} +\item[Yes] YESSSS! +\end{itemize} +{:/} + +\{::nomarkdown} Another paragraph + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.latex new file mode 100644 index 0000000..5af0263 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.latex @@ -0,0 +1,13 @@ +This is a simple paragraph. + +This *is* not processed + +And another paragraph + +\begin{itemize} +\item[Yes] YESSSS! +\end{itemize} + +\{::nomarkdown\} +Another paragraph + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.text new file mode 100644 index 0000000..43d441d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/nomarkdown.text @@ -0,0 +1,21 @@ +This is a simple paragraph. + +{::nomarkdown} +This *is* not processed + {:/nomarkdown} + +And another paragraph + +{::nomarkdown this='is' .ignore /} + +{::nomarkdown type='html'} +bold +{:/} +{::nomarkdown type="latex"} +\begin{itemize} +\item[Yes] YESSSS! +\end{itemize} +{:/} + +{::nomarkdown} +Another paragraph diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options.html new file mode 100644 index 0000000..364a77a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options.html @@ -0,0 +1,21 @@ +

No header id

+ +

without header id

+ +
+some *para* +
+ +
+

some para

+
+ +

Some text10.

+ +
+
    +
  1. +

    Some text. 

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options.text new file mode 100644 index 0000000..b63f34b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options.text @@ -0,0 +1,23 @@ +# No header id + +{::options unusedvar="val" /} + +# without header id + +
+some *para* +
+ +{::options parse_block_html="true" parse_span_html="true" /} + +
+some *para* +
+ +{::options footnote_nr="10" /} + +Some text[^ab]. + +[^ab]: Some text. + +{::options template="/etc/passwd" /} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options2.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options2.html new file mode 100644 index 0000000..afe4e13 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options2.html @@ -0,0 +1,10 @@ + +

Some text1.

+ +
+
    +
  1. +

    Some text. 

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options2.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options2.text new file mode 100644 index 0000000..78abfbe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options2.text @@ -0,0 +1,5 @@ +{::options footnote_nr="da10" /} + +Some text[^ab]. + +[^ab]: Some text. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options3.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options3.html new file mode 100644 index 0000000..d5a5ad6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options3.html @@ -0,0 +1,8 @@ +
x = Class.new
+
+
+ +
x = Class.new
+
+
+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options3.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options3.text new file mode 100644 index 0000000..f37839b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/12_extension/options3.text @@ -0,0 +1,7 @@ + x = Class.new +{: .language-ruby} + +{::options syntax_highlighter_opts="{default_lang: ruby\}" /} + + x = Class.new + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/auto_ids.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/auto_ids.html new file mode 100644 index 0000000..398628a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/auto_ids.html @@ -0,0 +1,15 @@ +
+
item
+
def
+
item2
+
def
+
+ +
+
item
+
def
+
item2
+
def
+
item3
+
def
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/auto_ids.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/auto_ids.text new file mode 100644 index 0000000..f1797a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/auto_ids.text @@ -0,0 +1,18 @@ +{:auto_ids} +item +: def + +item2 +: def + +^ + +{:auto_ids-prefix-} +item +: def + +item2 +: def + +{:#id} item3 +: def diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/definition_at_beginning.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/definition_at_beginning.html new file mode 100644 index 0000000..7c5cc04 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/definition_at_beginning.html @@ -0,0 +1 @@ +

: no definition

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/definition_at_beginning.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/definition_at_beginning.text new file mode 100644 index 0000000..cd3671b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/definition_at_beginning.text @@ -0,0 +1 @@ +: no definition diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/deflist_ial.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/deflist_ial.html new file mode 100644 index 0000000..3090b1e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/deflist_ial.html @@ -0,0 +1,4 @@ +
+
item
+
definition
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/deflist_ial.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/deflist_ial.text new file mode 100644 index 0000000..587c3b0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/deflist_ial.text @@ -0,0 +1,4 @@ +{:.dl-horizontal} +item +: definition +{:.dl-other} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/item_ial.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/item_ial.html new file mode 100644 index 0000000..0ed1197 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/item_ial.html @@ -0,0 +1,17 @@ +
+
item
+
definition +continued
+
another {:.cls}
+
+
code
+
+
+
IAL at last + no code bc of text
+
term
+
definition
+
term1
+
term2
+
definition
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/item_ial.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/item_ial.text new file mode 100644 index 0000000..2058d74 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/item_ial.text @@ -0,0 +1,16 @@ +item +: {:.cls} definition + continued +: another {:.cls} +: {:.class} + code +: {:.cls} IAL at last + no code bc of text + + +{:.class} term +: definition + +{:.class1} term1 +{:.class2} term2 +: definition diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/multiple_terms.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/multiple_terms.html new file mode 100644 index 0000000..e2e089b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/multiple_terms.html @@ -0,0 +1,13 @@ +
+
kram
+
down
+
now
+
definition 1
+
definition 2
+
+

definition 3

+
+
+

definition 4

+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/multiple_terms.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/multiple_terms.text new file mode 100644 index 0000000..b834258 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/multiple_terms.text @@ -0,0 +1,10 @@ +kram +*down* +now +: definition 1 +: definition 2 + +: definition 3 + + +: definition 4 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/no_def_list.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/no_def_list.html new file mode 100644 index 0000000..c16f962 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/no_def_list.html @@ -0,0 +1,2 @@ +

This is a para +: and not a definition list

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/no_def_list.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/no_def_list.text new file mode 100644 index 0000000..98b52b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/no_def_list.text @@ -0,0 +1,2 @@ +This is a para +\: and not a definition list diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/para_wrapping.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/para_wrapping.html new file mode 100644 index 0000000..5f28fdf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/para_wrapping.html @@ -0,0 +1,10 @@ +
+
term
+
+

definition

+
+
definition
+
+

definition

+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/para_wrapping.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/para_wrapping.text new file mode 100644 index 0000000..280fa47 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/para_wrapping.text @@ -0,0 +1,6 @@ +term + +: definition +: definition + +: definition diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/separated_by_eob.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/separated_by_eob.html new file mode 100644 index 0000000..0a1c4dc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/separated_by_eob.html @@ -0,0 +1,8 @@ +
+
kram
+
down
+
+
+
kram
+
down
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/separated_by_eob.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/separated_by_eob.text new file mode 100644 index 0000000..56fedf1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/separated_by_eob.text @@ -0,0 +1,5 @@ +kram +: down +^ +kram +: down diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/simple.html new file mode 100644 index 0000000..791f145 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/simple.html @@ -0,0 +1,10 @@ +
+
kram
+
down
+
novalue
+
+
kram
+
down +kram
+
down
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/simple.text new file mode 100644 index 0000000..e3bf730 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/simple.text @@ -0,0 +1,10 @@ +kram +: down + +novalue +: + +kram +: down +kram +: down diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/styled_terms.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/styled_terms.html new file mode 100644 index 0000000..cf7d785 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/styled_terms.html @@ -0,0 +1,4 @@ +
+
kram
+
down
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/styled_terms.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/styled_terms.text new file mode 100644 index 0000000..76eb355 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/styled_terms.text @@ -0,0 +1,2 @@ +*kram* +: down diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/too_much_space.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/too_much_space.html new file mode 100644 index 0000000..b4df878 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/too_much_space.html @@ -0,0 +1,3 @@ +

para

+ +

: no definition

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/too_much_space.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/too_much_space.text new file mode 100644 index 0000000..30ab445 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/too_much_space.text @@ -0,0 +1,4 @@ +para + + +: no definition diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/with_blocks.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/with_blocks.html new file mode 100644 index 0000000..45b5865 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/with_blocks.html @@ -0,0 +1,38 @@ +
+
kram
+
this is some +text
+
+

this is some +more text

+
+
kram
+
+
+

blockquote

+
+
+
kram
+
+
code
+
+
+
kram
+
+
+
kram
+
down
+
+
+
kram
+
+

header

+
+
kram
+
+
    +
  • list
  • +
  • items
  • +
+
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/with_blocks.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/with_blocks.text new file mode 100644 index 0000000..15195ce --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/13_definition_list/with_blocks.text @@ -0,0 +1,24 @@ +kram +: this is some + text + + : this is some + more text + +kram +: > blockquote + +kram +: + code + +kram +: kram + : down + +kram +: # header + +kram +: * list + * items diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.html new file mode 100644 index 0000000..af9b3e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.html @@ -0,0 +1,8 @@ + + + + + + + +
first line of cell
second line of cell
another cell
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.options new file mode 100644 index 0000000..63936b9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.options @@ -0,0 +1 @@ +:html_to_native: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.text new file mode 100644 index 0000000..60fec0b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/empty_tag_in_cell.text @@ -0,0 +1 @@ +| first line of cell
second line of cell | another cell | diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/errors.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/errors.html new file mode 100644 index 0000000..302e97a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/errors.html @@ -0,0 +1,12 @@ +

No table body

+ +

|-|-|-

+ +

|no|table|here|

+ +

|no|table|here| +paragraph

+ +

|-|-| +|-|-|

+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/errors.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/errors.text new file mode 100644 index 0000000..3565d5b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/errors.text @@ -0,0 +1,13 @@ +No table body + +|-|-|- + +[5]: test +|no|table|here| + +|no|table|here| +paragraph + +|-|-| +|-|-| + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/escaping.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/escaping.html new file mode 100644 index 0000000..b4528a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/escaping.html @@ -0,0 +1,52 @@ +

cell 1 | cell 2

+ +

cell 1 | cell 2

+ + + + + + + + +
cell 1cell 2 | continued
+ + + + + + + + +
cell 1cell 2
+ + + + + + + + +
cell 1code | span
+ +

cell 1 code | span

+ +

cell 1 | code | span

+ + + + + + + + + + + + + + +
cell 1cell `2cell 3
cell 1`cell 2cell 3
+ +

cell 1 | cell 2 | cell 3 +cell 1 | cell 2 | cell 3

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/escaping.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/escaping.text new file mode 100644 index 0000000..a8a24d6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/escaping.text @@ -0,0 +1,19 @@ +`cell 1 | cell 2` + +cell 1 \| cell 2 + +cell 1 | cell 2 \| continued + +cell 1 | cell `2` + +cell 1 | `code | span` + +cell 1 `code | span` + +cell 1 \| `code | span` + +cell 1 | cell `2 | cell 3 +cell 1` | cell 2 | cell 3 + +cell 1 \| cell `2 | cell 3 +cell 1` | cell 2 | cell 3 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/footer.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/footer.html new file mode 100644 index 0000000..e6596ed --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/footer.html @@ -0,0 +1,65 @@ +

Simple footer

+ + + + + + + + + + + + + + +
cell1cell2
cell3cell4
+ +

Full footer

+ + + + + + + + + + + + + + +
cell1cell2
cell3cell4
+ +

Footer with separator lines

+ + + + + + + + + + + + + + + + + + +
cell1cell2
cell3cell4
cell5cell6
+ +

Empty footer

+ + + + + + + + +
cell1cell2
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/footer.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/footer.text new file mode 100644 index 0000000..faaed8d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/footer.text @@ -0,0 +1,25 @@ +Simple footer + +| cell1 | cell2 +|= +| cell3 | cell4 + +Full footer + +| cell1 | cell2 +|=======|=======| +| cell3 | cell4 + +Footer with separator lines + +| cell1 | cell2 +|=======|=======| +| cell3 | cell4 +|--- +| cell5 | cell6 +|--- + +Empty footer + +| cell1 | cell2 +|= diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/header.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/header.html new file mode 100644 index 0000000..647f2c4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/header.html @@ -0,0 +1,117 @@ +

Simple header

+ + + + + + + + + + + + + + +
cell1cell2
cell3cell4
+ +

Full header

+ + + + + + + + + + + + + + +
cell1cell2
cell3cell4
+ +

With alignment and superfluous alignment defs

+ + + + + + + + + + + + + + + + + + + + +
defaultleftcenterrightdefault
cell1cell2cell3cell4cell5
+ +

With leading sep line

+ + + + + + + + + + + + + + +
cell1cell2
cell3cell4
+ +

Multiple bodies

+ + + + + + + + + + + + + + + + + + + + +
cell1cell2
cell3cell4
cell5cell6
+ +

Sep line with tab

+ + + + + + + + + + + + + + + + + + +
rightcenter
cell1cell2
cell3cell4
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/header.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/header.text new file mode 100644 index 0000000..6961bfb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/header.text @@ -0,0 +1,39 @@ +Simple header + +| cell1 | cell2 +|----- +| cell3 | cell4 + +Full header + +| cell1 | cell2 +|-------|-------| +| cell3 | cell4 + +With alignment and superfluous alignment defs + +| default | left | center | right | default +|-| :- |:-: | -: | - | :-: | :- +| cell1 | cell2 | cell3 | cell4 | cell5 + +With leading sep line + +|:-:|-:| +| cell1 | cell2 +|-------|-------| +| cell3 | cell4 + +Multiple bodies + +| cell1 | cell2 ++ :-: | +| cell3 | cell4 +|----||| +| cell5 | cell6 + +Sep line with tab + +right | center +---: | :---: +cell1 | cell2 +cell3 | cell4 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/no_table.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/no_table.html new file mode 100644 index 0000000..dce46b1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/no_table.html @@ -0,0 +1,3 @@ +

No table

+ +

| Some | thing | here

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/no_table.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/no_table.text new file mode 100644 index 0000000..90f90b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/no_table.text @@ -0,0 +1,3 @@ +No table + +\| Some \| thing \| here diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/simple.html new file mode 100644 index 0000000..506b442 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/simple.html @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + +
cell1cell2
cell3cell4
cell5cell6 |
cell7cell8
+ +

Missing cells at end

+ + + + + + + + + + + + + + + + + + + +
cell1cell2cell3
cell1  
 cell2cell3
+ +

Escaped pipe characters

+ + + + + + + + + + + + + + + + +
cell1 | cell1cell2
cell1cell2 |
cell1 | concell2
+ +

Table with code elements

+ + + + + + + + + + + + + + + + +
This is a span | with a pipe.   
Some span</em> herea span | with apipe.
+ +

Special cases regarding codespan syntax

+ + + + + + + + +
ab
+ + + + + + + +
a
+ + + + + + + + + +
tablewithial
+ + + + + + + + + +
tablewithial
+ +

not starting with a bar

+ + + + + + + + +
simpletable
+ + + + + + + + + + + + + + +
head1head2
cell1cell2
+ + + + + + + + + + + + + + +
head1head2
 cell2
+ + + + + + + + + + + + + + + + +
ab
cd
ef
+ + + + + + + + + + + + + + +
KeyValue type
Type"GROUP"|"UNKNOWN"
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/simple.text new file mode 100644 index 0000000..0f225a4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/simple.text @@ -0,0 +1,53 @@ +| cell1 | cell2 | +|cell3 | cell4| +|cell5|cell6 \| +| cell7|cell8 + +Missing cells at end + +| cell1 | cell2 | cell3 | +| cell1 || +|| cell2 | cell3 + +Escaped pipe characters + +| cell1 \| cell1 | cell2 | +| cell1 | cell2 \| +| cell1 `|` con | cell2 + +Table with code elements + +| This is a span | with a pipe. +| Some span | here | a span | with a | pipe. + +Special cases regarding codespan syntax + +|a|`b` + +|`a` + +{:.cls} +| table | with | ial + +| table | with | ial +{:.cls} + +not starting with a bar + +simple | table + +head1 | head2 +------|------ +cell1 | cell2 + + head1 | head2 +-------|------ + | cell2 + +| a | b | + c | d +| e | f | + +| Key | Value type | +|--------|------------------------| +| `Type` | `"GROUP"`\|`"UNKNOWN"` | diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.html new file mode 100644 index 0000000..7da4f9b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.html @@ -0,0 +1,25 @@ + + + + + + + + + + + +
this is 1a table
with afootnote
+ +
+
    +
  1. +

    Something

    + +
    +

    special here

    +
    +

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.latex new file mode 100644 index 0000000..99b5312 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.latex @@ -0,0 +1,11 @@ +\begin{longtable}{|l|l|} +\hline +this is \footnote{Something + +\begin{quote} +special here +\end{quote}} & a table\\ +with a & footnote\\ +\hline +\end{longtable} + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.text new file mode 100644 index 0000000..345fc5d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/14_table/table_with_footnote.text @@ -0,0 +1,6 @@ +| this is [^1] | a table +| with a | footnote + +[^1]: Something + + > special here diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/gh_128.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/gh_128.html new file mode 100644 index 0000000..9b2c127 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/gh_128.html @@ -0,0 +1 @@ +\[<script>alert('a')</script> <script>alert('b<')</script>\] diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/gh_128.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/gh_128.text new file mode 100644 index 0000000..95252a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/gh_128.text @@ -0,0 +1 @@ +$$ $$ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.html new file mode 100644 index 0000000..5d6b343 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.html @@ -0,0 +1,3 @@ +
$$ +5+5 +$$
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.options new file mode 100644 index 0000000..06d559e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.options @@ -0,0 +1 @@ +:math_engine: ~ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.text new file mode 100644 index 0000000..fdee5cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/no_engine.text @@ -0,0 +1,2 @@ +{: #math-id} +$$5+5$$ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/normal.html new file mode 100644 index 0000000..f80d56b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/normal.html @@ -0,0 +1,30 @@ +

This is a para. +\(\text{LaTeX} \lambda_5\)

+ +\[\lambda_5 = \alpha + 4\] + +

\(\lambda_\alpha > 5\) +This is a para.

+ +\[\begin{align*} +&=5 \\ +&=6 \\ +\end{align*}\] + +\[5+5\] + +\[5+5\] + +\[5+5\] + +\[5+5\] + +
$$5+5$$
+
+ +
\[5+5\] +
+
\[5+5\] +
+ +\[|x| = 5\] diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/normal.text new file mode 100644 index 0000000..aa5984a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/15_math/normal.text @@ -0,0 +1,30 @@ +This is a para. +$$ \text{LaTeX} \lambda_5 $$ + +$$\lambda_5 = \alpha + 4$$ + +$$\lambda_\alpha > 5$$ +This is a para. + +$$\begin{align*} +&=5 \\ +&=6 \\ +\end{align*}$$ + +$$5+5$$ + + $$5+5$$ + + $$5+5$$ + + $$5+5$$ + + $$5+5$$ + +{:.cls} +$$5+5$$ +^ +$$5+5$$ +{:.cls} + +$$|x| = 5$$ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/no_toc.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/no_toc.html new file mode 100644 index 0000000..bbb831e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/no_toc.html @@ -0,0 +1,14 @@ + +

Header level 1

+ +

Header level 2

+ +

Header level 3

+ +

Header level 4

+ +

Other header level 1

+ +

Other header level 2

+ +

Other header level 3

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/no_toc.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/no_toc.text new file mode 100644 index 0000000..11ad829 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/no_toc.text @@ -0,0 +1,16 @@ +* Here comes the table of content +{:toc} + +# Header level 1 + +## Header level 2 + +### Header level 3 + +#### Header level 4 + +# Other header level 1 + +## Other header level 2 + +### Other header level 3 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.html new file mode 100644 index 0000000..d352684 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.html @@ -0,0 +1,35 @@ +

Contents

+ + + +

Header level 1

+ +

Header level 2

+ +

Header level 3

+ +

Header level 4

+ +

Other header level 1

+ +

Other header level 2

+ +

Other header level 3

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.options new file mode 100644 index 0000000..8776b55 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.options @@ -0,0 +1 @@ +:auto_ids: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.text new file mode 100644 index 0000000..d8f0b86 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_exclude.text @@ -0,0 +1,19 @@ +# Contents +{:.no_toc} + +* Here comes the table of content +{:toc} + +# Header level 1 + +## Header level 2 + +### Header level 3 + +#### Header level 4 + +# Other header level 1 + +## Other header level 2 + +### Other header level 3 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.html new file mode 100644 index 0000000..e50a07c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.html @@ -0,0 +1,24 @@ + + +

Header level 1

+ +

Header \` level 2

+ +

Header level 3

+ +

Header level 4

+ +

Other header level 1

+ +

Other header level 2

+ +

Other header level 3

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.options new file mode 100644 index 0000000..bdfbeba --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.options @@ -0,0 +1,2 @@ +:toc_levels: 2..3 +:auto_ids: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.text new file mode 100644 index 0000000..1a62dea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_levels.text @@ -0,0 +1,16 @@ +* Here comes the table of content +{:toc} + +# Header level 1 + +## Header \\\` level 2 + +### Header level 3 + +#### Header level 4 + +# Other header level 1 + +## Other header level 2 + +### Other header level 3 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.html new file mode 100644 index 0000000..0a3e199 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.html @@ -0,0 +1,13 @@ + + +

Header1 level 1

+ +
+
    +
  1. +

    Some footnote content here 

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.options new file mode 100644 index 0000000..8776b55 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.options @@ -0,0 +1 @@ +:auto_ids: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.text new file mode 100644 index 0000000..5879ed5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_footnotes.text @@ -0,0 +1,6 @@ +* Here comes the table of content +{:toc} + +# Header[^1] level 1 + +[^1]: Some footnote content here diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.html new file mode 100644 index 0000000..ebde543 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.html @@ -0,0 +1,8 @@ +

Header

+ +

Header

+ + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.options new file mode 100644 index 0000000..36c20f5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.options @@ -0,0 +1,2 @@ +:auto_ids: true +:auto_id_stripping: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.text new file mode 100644 index 0000000..9b4ac07 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/block/16_toc/toc_with_links.text @@ -0,0 +1,8 @@ +# [Header] + +# [Header] + +[header]: test.html + +* toc +{:toc} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.html new file mode 100644 index 0000000..8299316 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.html @@ -0,0 +1,4 @@ +

一二三四五

+ +

あいうえお

+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.options new file mode 100644 index 0000000..4c86d36 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.options @@ -0,0 +1 @@ +:remove_line_breaks_for_cjk: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.text new file mode 100644 index 0000000..969c04c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/cjk-line-break.text @@ -0,0 +1,12 @@ +一 +二 +三 +四 +五 + +あ +い +う +え +お + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/encoding.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/encoding.html new file mode 100644 index 0000000..0339347 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/encoding.html @@ -0,0 +1,46 @@ +

Das ist gewöhnlich ein Über-Problem mit manchen
+Sälen http://example.org und anderen Dinge. Siehe +Über mich!

+ +
+

Vielleicht höre ich nicht richtig?

+
+ +
    +
  • Sollten wir uns das überlegen? Verhöhne mich nicht!
  • +
  • Ho ho höher! Sind *wir* da?
  • +
+ +

Titel sind urschön

+ +

Manche mögens ärmer

+ +
öha
+was nun?
+
+ +
+
Töne
+
Laute Geräusche
+
vielleicht noch was ähnliches
+
+ + + + + + + + + + + + + + + + +
hochhöheram höchsten
überdrübermüde
+ +

Das ist schön +gemacht

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/encoding.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/encoding.text new file mode 100644 index 0000000..65edf4b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/encoding.text @@ -0,0 +1,28 @@ +Das ist gewöhnlich *ein* [Über-Problem](http://example.org) mit manchen +Sälen und anderen Dinge. Siehe +![Über mich](http://example.org)! + +> Vielleicht *höre*{:.red} ich nicht richtig? +{:.test} + +* Sollten wir uns das überl*egen*? *Verhöhne* mich nicht! +* Ho ho höher! Sind \*wir\* da? + +Titel sind urschön +================== + +## Manche mögens *ärmer* {#hot} + + öha + was nun? + +Töne +: Laute Geräusche +: vielleicht noch was ä*hnliches* + +| hoch | höher | am höchsten | +|----------------------------| +| über | drüber | müde | + +

Das ist schön +gemacht

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/example.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/example.man new file mode 100644 index 0000000..a03d148 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/example.man @@ -0,0 +1,123 @@ +.\" generated by kramdown +.TH "NAME" "1" "November 2016" "Some extra data" +.SH NAME +name \- description +.SH "SYNOPSIS" +\fBname\fP [\fBOPTIONS\fP] \fIarguments\fP\.\.\. +.SH "DESCRIPTION" +This is a normal paragraph\. +.sp +.PD 0 +.IP \(bu 4 +A +.IP \(bu 4 +compact +.IP \(bu 4 +list +.IP \(bu 4 +with multiple +.RS +.IP \(bu 4 +items and +.RS +.IP \(bu 4 +nested +.RE +.RE +.IP \(bu 4 +as well +.PD +.RS +.P +blockquotes are fine +.IP 1. 4 +numbered lists +.IP 2. 4 +work too +.RS +.IP 1. 4 +and they +.IP 2. 4 +can be +.RS +.IP 1. 4 +nested +.RE +.RE +.IP 3. 4 +again +.RE +.sp +.RS 4 +.EX +Some fancy code + going + on + here +.EE +.RE +.TP +\fB\-o\fP +.TQ +\fB\-\-option\fP +Description lists +.sp +are useful as well +.P +And compact definition lists: +.sp +.PD 0 +.TP +\fBo\fP +Option +.TP +\fBk\fP +Key +.TP +\fBv\fP +Value +.PD +.TS +box center ; +l l l l . +tables can be centered +.TE +.sp +.TS +box ; +lb lb cb rb . +Default aligned Left aligned Center aligned Right aligned += +.T& +l l c r . +First body part Second cell Third cell fourth cell +Second \fIline\fP foo \fBstrong\fP baz +Third line \fBquux\fP baz bar +_ +.T& +l l c r . +Second body +2nd line += +Footer row one +Footer row two +.TE +.sp +.P +Inline formatting like \fIemphasis\fP, \fBstrong\fP and \fBcode span\fP work as ususal\. +.UR are_well\.html +Links +.UE +work, too! As do +.br +line breaks\. +.P +Abbreviations like MD can be used but the abbreviation title is ignored\. +.P +Math elements work \fB\elambda = 5\fP inline and in block form: +.sp +.RS 4 +.EX +\elambda_5 = \ealpha + 4 +.EE +.RE diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/example.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/example.text new file mode 100644 index 0000000..a0a2614 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/example.text @@ -0,0 +1,85 @@ +# name(1) - description +{: data-date="November 2016" data-extra="Some extra data"} + +## SYNOPSIS + +`name` \[`OPTIONS`\] *arguments*... + +## DESCRIPTION + +This is a normal paragraph. + +* A +* compact +* list +* with multiple + * items and + * nested +* as well +{:.compact} + +> blockquotes are fine +> +> 1. numbered lists +> +> 2. work too +> 1. and they +> 2. can be +> 1. nested +> +> 3. again + +~~~ +Some fancy code + going + on + here +~~~ + +`-o` +`--option` +: Description lists +: are useful as well + +And compact definition lists: + +`o` +: Option + +`k` +: Key + +`v` +: Value +{:.compact} + +| tables | can | be | centered | +{:.center} + +|-----------------+------------+-----------------+----------------| +| Default aligned |Left aligned| Center aligned | Right aligned | +|-----------------|:-----------|:---------------:|---------------:| +| First body part |Second cell | Third cell | fourth cell | +| Second *line* |foo | **strong** | baz | +| Third line |`quux` | baz | bar | +|-----------------+------------+-----------------+----------------| +| Second body | | | | +| 2nd line | | | | +|=================+============+=================+================| +| Footer row one | | | | +| Footer row two | | | | +|-----------------+------------+-----------------+----------------| + + +Inline formatting like *emphasis*, **strong** and `code span` work +as ususal. [Links](are_well.html) work, too! As do\\ +line breaks. + +Abbreviations like MD can be used but the abbreviation title is +ignored. + +*[MD]: Markdown + +Math elements work $$\lambda = 5$$ inline and in block form: + +$$\lambda_5 = \alpha + 4$$ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-dash-description.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-dash-description.man new file mode 100644 index 0000000..8e47527 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-dash-description.man @@ -0,0 +1,4 @@ +.\" generated by kramdown +.TH "NAME" "7" +.SH NAME +name \- description diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-dash-description.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-dash-description.text new file mode 100644 index 0000000..832c921 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-dash-description.text @@ -0,0 +1 @@ +# name -- description diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-description.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-description.man new file mode 100644 index 0000000..e59dc5e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-description.man @@ -0,0 +1,4 @@ +.\" generated by kramdown +.TH "NAME" "1" "November 2016" "Something extra" +.SH NAME +name \- description diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-description.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-description.text new file mode 100644 index 0000000..941482c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-description.text @@ -0,0 +1,2 @@ +# name description +{: data-section="1" data-date="November 2016" data-extra="Something extra"} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section-description.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section-description.man new file mode 100644 index 0000000..8df4ff7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section-description.man @@ -0,0 +1,4 @@ +.\" generated by kramdown +.TH "NAME" "1" +.SH NAME +name \- description diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section-description.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section-description.text new file mode 100644 index 0000000..5f3e765 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section-description.text @@ -0,0 +1 @@ +# name(1) -- description diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section.man new file mode 100644 index 0000000..7ca8757 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section.man @@ -0,0 +1,2 @@ +.\" generated by kramdown +.TH "NAME" "1" diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section.text new file mode 100644 index 0000000..da98dbd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name-section.text @@ -0,0 +1 @@ +# name(1) diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name.man new file mode 100644 index 0000000..8488496 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name.man @@ -0,0 +1,2 @@ +.\" generated by kramdown +.TH "NAME" "7" diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name.text new file mode 100644 index 0000000..5f4656a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/heading-name.text @@ -0,0 +1 @@ +# name diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/sections.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/sections.man new file mode 100644 index 0000000..14ab233 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/sections.man @@ -0,0 +1,4 @@ +.\" generated by kramdown +.SH "NAME" +works +.SS "Sub section" diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/sections.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/sections.text new file mode 100644 index 0000000..d1f5f86 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/sections.text @@ -0,0 +1,11 @@ +## NAME + +works + +### Sub section + +#### Ignored + +##### Ignored + +###### Ignored diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/text-escaping.man b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/text-escaping.man new file mode 100644 index 0000000..710a4f1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/text-escaping.man @@ -0,0 +1,8 @@ +.\" generated by kramdown +\&\. at the start of the line +.P +line with \efB backslash symbol +.P +some \. other \- escaped \' symbols +.P +\&\. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/text-escaping.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/text-escaping.text new file mode 100644 index 0000000..052b94f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/man/text-escaping.text @@ -0,0 +1,7 @@ +. at the start of the line + +line with \fB backslash symbol + +some . other - escaped \' symbols + +. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty.html new file mode 100644 index 0000000..a1102ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty.html @@ -0,0 +1,5 @@ +

This is [] empty.

+ +

This is [][] empty.

+ +

This is empty.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty.text new file mode 100644 index 0000000..cca5de5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty.text @@ -0,0 +1,5 @@ +This is [] empty. + +This is [][] empty. + +This is [](test.html) empty. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty_title.htmlinput b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty_title.htmlinput new file mode 100644 index 0000000..b95b2cc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty_title.htmlinput @@ -0,0 +1,3 @@ +

Image with empty title: alt text

+ +

Link reference with empty title.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty_title.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty_title.text new file mode 100644 index 0000000..baabe7d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/empty_title.text @@ -0,0 +1,7 @@ +Image with empty title: ![alt text](/images/other.png) + +Link [reference][1] with empty title. + + + +[1]: http://example.tld diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/image_in_a.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/image_in_a.html new file mode 100644 index 0000000..e1f4ade --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/image_in_a.html @@ -0,0 +1,5 @@ +

Simple: Some alt text

+ +

Nested: Some alt ![img](text.png) text

+ +

Simple: Some text alt text text

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/image_in_a.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/image_in_a.text new file mode 100644 index 0000000..bdbfb65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/image_in_a.text @@ -0,0 +1,5 @@ +Simple: [Some ![alt text](/images/other.png)](local.html) + +Nested: [Some ![alt ![img](text.png) text](/images/other.png)](local.html) + +Simple: [Some *text ![alt text](/images/other.png) text*](local.html) diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/imagelinks.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/imagelinks.html new file mode 100644 index 0000000..565d36f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/imagelinks.html @@ -0,0 +1,15 @@ +

Simple: alt text

+ +

Simple with title: alt text

+ +

Empty img link: alt text

+ +

Reference style: alt text

+ +

Reference style with title: alt text

+ +

No alt text:

+ +

No id: imgo

+ +

With escaped pipe: an | pipe

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/imagelinks.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/imagelinks.text new file mode 100644 index 0000000..05050a2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/imagelinks.text @@ -0,0 +1,18 @@ +Simple: ![alt text](/images/other.png) + +Simple with title: ![alt text](/images/other.png "title") + +Empty img link: ![alt text]() + +Reference style: ![alt text][img] + +Reference style with title: ![alt text][imgo] + +No alt text: ![](other.png) + +No id: ![imgo] + +[img]: other.png +[imgo]: other.png "Title" + +With escaped pipe: ![an \| pipe](other.png) diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/inline.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/inline.html new file mode 100644 index 0000000..8d00efa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/inline.html @@ -0,0 +1,46 @@ +

simple URL

+ +

simple URL

+ +

simple URL with formatting

+ +

simple URL with single quoted title

+ +

simple URL with double quoted title

+ +

simple URL [with ] escaped

+ +

simple URL with ] escaped

+ +

simple URL [with] nested

+ +

simple URL with [no](link.html) inside

+ +

simple URL with parens

+ +

simple URL with parens

+ +

simple URL broken +on line

+ +

simple URL with spaces

+ +

simple URL with spaces

+ +

simple URL with spaces

+ +

simple leading/trailing spaces

+ +

simple leading/trailing spaces

+ +

simple leading/trailing spaces

+ +

bad [URL not

+ +

bad [URL with parens](something(new.html)

+ +

bad [URL with empty title](something.html ‘’)

+ +

bad [URL](

+ +

bad [URL](no

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/inline.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/inline.text new file mode 100644 index 0000000..c705764 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/inline.text @@ -0,0 +1,48 @@ +simple [URL]() + +simple [URL](something.html) + +simple [URL *with* formatting](something.html) + +simple [URL with single quoted title](something.html 'a t"itle') + +simple [URL with double quoted title](something.html "a t'itle") + +simple [URL \[with \] escaped](something.html) + +simple [URL with \] escaped](something.html) + +simple [URL [with] nested](something.html) + +simple [URL with [no](link.html) inside](something.html) + +simple [URL with parens](/something/to(do)) + +simple [URL with parens](/something/to(do "doit") + +simple [URL broken +on line](something.html +"title") + +simple [URL with spaces](with spaces.html) + +simple [URL with spaces](with spaces.html 'title') + +simple [URL with spaces](with (spaces).html) + +simple [leading/trailing spaces]( spaces.html) + +simple [leading/trailing spaces](spaces.html ) + +simple [leading/trailing spaces]( spaces.html ) + + +bad [URL [not](something.html) + +bad [URL with parens](something(new.html) + +bad [URL with empty title](something.html '') + +bad [URL]( + +bad [URL](no diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/latex_escaping.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/latex_escaping.latex new file mode 100644 index 0000000..63e58e7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/latex_escaping.latex @@ -0,0 +1,6 @@ +\href{https://example.com/~tilde/}{https://example.com/\ensuremath{\sim}tilde/} + +\href{http://example.com/percent\%20percent}{http://example.com/percent\%20percent} + +\href{http://example.com/hash#hash}{http://example.com/hash\#hash} + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/latex_escaping.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/latex_escaping.text new file mode 100644 index 0000000..9b27ae8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/latex_escaping.text @@ -0,0 +1,5 @@ + + + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs.html new file mode 100644 index 0000000..15e2ca7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs.html @@ -0,0 +1,9 @@ +

This is a para. +[id]: http://www.example.com/

+ +
[4]: nourl
+
+ +

Points to 1 and 2 and 3 but not [4]

+ +

Points to _.:,;!?- and otherid8

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs.text new file mode 100644 index 0000000..16a25b5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs.text @@ -0,0 +1,27 @@ +This is a para. +[id]: http://www.example.com/ + +[otherid1]: http://wwww.example.com/ "title 1" +[otherid2]: http://wwww.example.com/ 'title 2' +[otherid3]: +[otherid4]: 'title' +[otherid5]: some spaces.html +[otherid6]: some spaces.html 'title' +[otherid7]: some spaces + "title" +[otherid8]:test.html#'test' 'title' + +[break]: http://www.example.com/test/asdf.html + 'Another title' + +[1]: ignored.url + [1]: one.url + [2]: two.url + [3]: three.url + [4]: nourl + +Points to [1] and [2] and [3] but not [4] + +[_.:,;!?-]: http://example.com + +Points to [_.:,;!?-] and [otherid8] diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs_with_ial.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs_with_ial.html new file mode 100644 index 0000000..f56d77d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs_with_ial.html @@ -0,0 +1,4 @@ +

Link def with attr and attr 2 and attr 3 and attr before

+ +

test

+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs_with_ial.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs_with_ial.text new file mode 100644 index 0000000..59398a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/link_defs_with_ial.text @@ -0,0 +1,16 @@ +Link def with [attr] and [attr 2] and [attr 3] and [attr before] + +[attr]: http://example.com 'title' +{: hreflang="en" .test} + +[attr 2]: http://example.com 'title' +{: hreflang="en"} +{: .test} + +[attr 3]: http://example.com +{: .test} +test + +{: hreflang="en"} +{: .test} +[attr before]: http://example.com diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/links_with_angle_brackets.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/links_with_angle_brackets.html new file mode 100644 index 0000000..ecaa31e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/links_with_angle_brackets.html @@ -0,0 +1,3 @@ +

This is a link.

+ +

This is a link.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/links_with_angle_brackets.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/links_with_angle_brackets.text new file mode 100644 index 0000000..2cf0ece --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/links_with_angle_brackets.text @@ -0,0 +1,3 @@ +This is a [link](). + +This is a [link]( 'and title'). diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.html new file mode 100644 index 0000000..f6fed18 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.html @@ -0,0 +1,37 @@ + +

simple URL and URL

+ +

simple URL and URL

+ +

simple 1 and isurl

+ +

simple 1 and isurl

+ +

this is [a holy isurl]

+ +

no [resolution][] here and [here]

+ +

with a break in +the text

+ +

this not [isurl] and not [isurl]

+ +

a Link with_BIG letters

+ +

bad [no URL] d isurl

+ +

[no url] invalid.html +[no url]:

+ +

“title”

+ +

test url but no title +test [urldef]

+ +

[urldef]: some.url ‘title”

+ +

some with spaces

+ +

this is a ‘special’ occasion for /all/ of us

+ +

this is predefined for URI

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.options new file mode 100644 index 0000000..efb4b01 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.options @@ -0,0 +1,3 @@ +:link_defs: + predefined: [predefined.html] + URI: [uri.html, My URI] diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.text new file mode 100644 index 0000000..9f39fa7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/01_link/reference.text @@ -0,0 +1,53 @@ +[isurl]: someurl.html + [1]: otherurl.html + +simple [URL][1] and [URL][isurl] + +simple [URL] [1] and [URL] +[isurl] + +simple [1][] and [isurl][] + +simple [1] and [isurl] + +this is [a holy [isurl]] + +no [resolution][] here and [here] + +with a [break in +the text] + + [break in the text]: url.html + +this not \[isurl] and not [isurl\] + +a [Link with_BIG] letters + + [link WITH_big]: letters.html + 'This is the title' + +bad [no URL] d [isurl] + +[no url] invalid.html +[no url]: + +[URL but no title]: invalid.html + + "title" + +test [url but no title] +test [urldef] + +[urldef]: some.url 'title" + + +some [with spaces] + +[with spaces]: with spaces.html "title" + +this [is a 'special' occasion for /all/ of us] + +[is a 'special' occasion for /all/ of us]: occasion.html + + +this is [predefined] for [URI] diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/empty.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/empty.html new file mode 100644 index 0000000..127e694 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/empty.html @@ -0,0 +1,3 @@ +

This __is **empty.

+ +

This **is empty.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/empty.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/empty.text new file mode 100644 index 0000000..c99d053 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/empty.text @@ -0,0 +1,3 @@ +This __is **empty. + +This ****is empty. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/errors.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/errors.html new file mode 100644 index 0000000..e62f03f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/errors.html @@ -0,0 +1,9 @@ +

This is a *star.

+ +

This is a **star.

+ +

This is *a *star.

+ +

This is *a star*.

+ +

This** is** a star.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/errors.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/errors.text new file mode 100644 index 0000000..e80e5eb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/errors.text @@ -0,0 +1,9 @@ +This is a *star. + +This is a **star. + +This is **a *star*. + +This is *a star\*. + +This** is** a star. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/nesting.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/nesting.html new file mode 100644 index 0000000..3d34cee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/nesting.html @@ -0,0 +1,41 @@ +
    +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
  • test test
  • +
+
    +
  • ab
  • +
  • ab
  • +
  • abc
  • +
  • ab
  • +
  • ab
  • +
  • abc
  • +
+
    +
  • _a_b
  • +
  • a_b_
  • +
  • a_b_c
  • +
  • __a__b
  • +
  • a__b__
  • +
  • a__b__c
  • +
  • a__2__c
  • +
  • a__2__3
  • +
  • 1__2__3
  • +
+
    +
  • a _b_ c
  • +
  • a __b__ c
  • +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/nesting.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/nesting.text new file mode 100644 index 0000000..ba67e84 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/nesting.text @@ -0,0 +1,36 @@ +- ***test test*** +- ___test test___ +- *test **test*** +- **test *test*** +- ***test* test** +- ***test** test* +- ***test* test** +- **test *test*** +- *test **test*** +- _test __test___ +- __test _test___ +- ___test_ test__ +- ___test__ test_ +- ___test_ test__ +- __test _test___ +- _test __test___ +^ +- *a*b +- a*b* +- a*b*c +- **a**b +- a**b** +- a**b**c +^ +- _a_b +- a_b_ +- a_b_c +- __a__b +- a__b__ +- a__b__c +- a__2__c +- a__2__3 +- 1__2__3 +^ +- *a _b_ c* +- **a __b__ c** diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.html new file mode 100644 index 0000000..89774f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.html @@ -0,0 +1,65 @@ +

This is so hard.

+ +

This is so hard too.

+ +

At start +At start

+ +

At end +At end

+ +

At start +At start

+ +

At end +At end

+ +

And nested.

+ +

And nest**ed.

+ +

And *nested* like this.

+ +

And not_nest_ed.

+ +

And nested.

+ +

And nested.

+ +

And neste.

+ +

And lonely * here*.

+ +

And lonely ** here**.

+ +

And lonely ** here.

+ +

** and here**.

+ +

And compli*cated * here

+ +

Some**what more * **here

+ +

Do it *this* way +Or this *this* way +Or that *that* way +Or that *that* way

+ +

http://blah.com/blah_%28

+ +

A-_B

+ +
    +
  • test
  • +
  • test
  • +
  • test
  • +
  • (“test”)
  • +
  • (test)
  • +
  • test
  • +
  • `test
  • +
  • test
  • +
+ +

it–by design–cannot have side-effects.

+ +

it—by design—cannot have side-effects.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.options new file mode 100644 index 0000000..2e6e0a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.options @@ -0,0 +1 @@ +:entity_output: :numeric diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.text new file mode 100644 index 0000000..1e04b87 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/02_emphasis/normal.text @@ -0,0 +1,63 @@ +This *is* so **hard**. + +This _is_ so __hard__ too. + +*At* start +*At* start + +At *end* +At *end* + +_At_ start +_At_ start + +At _end_ +At _end_ + +And *nest**ed***. + +And *nest**ed*. + +And *nest**ed* like** this. + +And *not_nest_ed*. + +And ***nested***. + +And ___nested___. + +And **nest*e***. + +And lonely * here*. + +And lonely ** here**. + +And **lonely ** here**. + +** and here**. + +And **compli*cated \*** here + +Some***what* more * ***he*re + +Do it *\*this\** way +Or this \**this*\* way +Or that *\*that*\* way +Or that \**that\** way + +[http://blah.com/blah_%28](http://blah.com/blah_%28) + +[A-_B](A_-B) + +- _test_ +- '_test_' +- "_test_" +- ("_test_") +- (_test_) +- “_test_” +- \`_test_' +- „_test_“ + +it--by design--_cannot have side-effects_. + +it---by design---_cannot have side-effects_. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/empty.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/empty.html new file mode 100644 index 0000000..20c5051 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/empty.html @@ -0,0 +1,5 @@ +

This is `` empty.

+ +

This is ``empty.

+ +

This is ````empty.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/empty.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/empty.text new file mode 100644 index 0000000..cbb9152 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/empty.text @@ -0,0 +1,5 @@ +This is `` empty. + +This is ``empty. + +This is ````empty. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/errors.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/errors.html new file mode 100644 index 0000000..1d341a8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/errors.html @@ -0,0 +1 @@ +

Not ended `span.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/errors.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/errors.text new file mode 100644 index 0000000..7a948b4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/errors.text @@ -0,0 +1 @@ +Not ended `span. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.latex new file mode 100644 index 0000000..a1f84d9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.latex @@ -0,0 +1,2 @@ +You can say \mintinline{ruby}{x = Class.new}, for example. + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.options new file mode 100644 index 0000000..c11ebb6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.options @@ -0,0 +1 @@ +:syntax_highlighter: minted diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.text new file mode 100644 index 0000000..7373290 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting-minted.text @@ -0,0 +1 @@ +You can say `x = Class.new`{:.language-ruby}, for example. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting.html new file mode 100644 index 0000000..4294542 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting.html @@ -0,0 +1 @@ +

You can say x = Class.new, for example.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting.text new file mode 100644 index 0000000..7373290 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/highlighting.text @@ -0,0 +1 @@ +You can say `x = Class.new`{:.language-ruby}, for example. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.html new file mode 100644 index 0000000..ec21686 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.html @@ -0,0 +1 @@ +

This is a code-span

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.options new file mode 100644 index 0000000..bfc92f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.options @@ -0,0 +1,2 @@ +:syntax_highlighter_opts: + guess_lang: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.text new file mode 100644 index 0000000..f704439 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal-css-class.text @@ -0,0 +1 @@ +This is a `code-span` diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal.html new file mode 100644 index 0000000..6de2257 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal.html @@ -0,0 +1,20 @@ +

This is a simple span.

+ +

With some<ht>&ml in it.

+ +

And ` backticks.

+ +

And ``some`` more.

+ +

With backslash in\ it.

+ +

This is a ` literal backtick. +As `are` these!

+ +

No literal backtick.

+ +

something

+ +

` `

+ +

a ` `

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal.text new file mode 100644 index 0000000..c188959 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/normal.text @@ -0,0 +1,20 @@ +This is `a` simple span. + +With `some&ml` in it. + +And `` ` `` backticks. + +And ``` ``some`` ``` more. + +With backslash `in\` it. + +This is a ` literal backtick. +As \`are\` these! + +No `` literal backtick``. + +`something` + +` ` + +a ` ` diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.html new file mode 100644 index 0000000..7822f78 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.html @@ -0,0 +1 @@ +

You can say Class.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.options new file mode 100644 index 0000000..34094e9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.options @@ -0,0 +1,4 @@ +:syntax_highlighter: rouge +:syntax_highlighter_opts: + span: + disable: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.text new file mode 100644 index 0000000..d958d91 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/disabled.text @@ -0,0 +1 @@ +You can say `Class`{:.language-ruby}. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.html new file mode 100644 index 0000000..4294542 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.html @@ -0,0 +1 @@ +

You can say x = Class.new, for example.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.options new file mode 100644 index 0000000..9ac61e7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.options @@ -0,0 +1 @@ +:syntax_highlighter: rouge diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.text new file mode 100644 index 0000000..7373290 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/03_codespan/rouge/simple.text @@ -0,0 +1 @@ +You can say `x = Class.new`{:.language-ruby}, for example. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.html new file mode 100644 index 0000000..cbb8891 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.html @@ -0,0 +1,79 @@ +

This is 123456789

+ +
+
    +
  1. + +

    A paragraph 

    +
  2. +
  3. + +

    A header 

    +
  4. +
  5. + +
    +

    blockquote

    + +

    paragraph 

    +
    +
  6. +
  7. + +
    codeblock
    +
    +

    +
  8. +
  9. + +
      +
    • item 1
    • +
    • item 2 +
        +
      • +

        sub item

        + +
        +

        blockquote

        + +

        header 

        +
        +
      • +
      +
    • +
    +
  10. +
  11. + + + + + + + + + + + + +
    ab
    cd
    +

    +
  12. +
  13. + +
    +

    +
  14. +
  15. + +\[x + 2\] +

    +
  16. +
  17. + +
    test +
    +

    +
  18. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.options new file mode 100644 index 0000000..ac54fc0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.options @@ -0,0 +1 @@ +footnote_backlink_inline: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.text new file mode 100644 index 0000000..55f94a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_inline.text @@ -0,0 +1,38 @@ +This is [^paragraph][^header][^blockquote][^codeblock][^list][^table][^hrule][^mathblock][^html] + +[^paragraph]: + A paragraph + +[^header]: + # A header + +[^blockquote]: + > blockquote + > + > paragraph + +[^codeblock]: + codeblock + +[^list]: + * item 1 + * item 2 + * sub item + + > blockquote + > + > # header + +[^table]: + | a | b | + | c | d | + +[^hrule]: + *** + +[^mathblock]: + $$x + 2$$ + +[^html]: +
test +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.html new file mode 100644 index 0000000..b10570d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.html @@ -0,0 +1,9 @@ +

Some footnote here1

+ +
+
    +
  1. +

    Some text here text &8617; <img />

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.options new file mode 100644 index 0000000..4c677ef --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.options @@ -0,0 +1 @@ +:footnote_backlink: 'text &8617; ' diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.text new file mode 100644 index 0000000..41a6f98 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/backlink_text.text @@ -0,0 +1,3 @@ +Some footnote here[^fn] + +[^fn]: Some text here diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.html new file mode 100644 index 0000000..9012cc0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.html @@ -0,0 +1,17 @@ +

Some para.

+ +
+

blockquote

+
+ +
    +
  • a list +with some text
  • +
+ +
    +
  • other list
  • +
+
code
+
+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.latex new file mode 100644 index 0000000..965653c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.latex @@ -0,0 +1,17 @@ +Some para. + +\begin{quote} +blockquote +\end{quote} + +\begin{itemize} +\item{} a list +with some text +\end{itemize} + +\begin{itemize} +\item{} other list +\end{itemize} +\begin{verbatim}code +\end{verbatim} + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.text new file mode 100644 index 0000000..44b52e0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/definitions.text @@ -0,0 +1,24 @@ +Some para. + +[^footnote]: ignored definition +[^footnote]: Some footnote text + +> blockquote + +[^other]: some + foot + + note text + +* a list + with some text + +[^tnote]: foot note + +* other list +^ + code + +[^1]: + > a blockquote + and some para diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.html new file mode 100644 index 0000000..7eedecb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.html @@ -0,0 +1,12 @@ +

This is a footnote35. And another36.

+ +
+
    +
  1. +

    Some text. 

    +
  2. +
  3. +

    Some other text. 

    +
  4. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.latex new file mode 100644 index 0000000..8f07dde --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.latex @@ -0,0 +1,2 @@ +This is a footnote\footnote{Some text.}. And another\footnote{Some other text.}. + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.options new file mode 100644 index 0000000..f606ecf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.options @@ -0,0 +1 @@ +:footnote_nr: 35 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.text new file mode 100644 index 0000000..cad2935 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_nr.text @@ -0,0 +1,4 @@ +This is a footnote[^ab]. And another[^bc]. + +[^ab]: Some text. +[^bc]: Some other text. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.html new file mode 100644 index 0000000..4d6cb95 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.html @@ -0,0 +1,12 @@ +

This is a1 footnote1. And another2.

+ +
+
    +
  1. +

    Some text.  2

    +
  2. +
  3. +

    Some other text. 

    +
  4. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.options new file mode 100644 index 0000000..51d78bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.options @@ -0,0 +1 @@ +:footnote_prefix: adf123- diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.text new file mode 100644 index 0000000..884053e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/footnote_prefix.text @@ -0,0 +1,4 @@ +This is a[^ab] footnote[^ab]. And another[^bc]. + +[^ab]: Some text. +[^bc]: Some other text. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/inside_footnote.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/inside_footnote.html new file mode 100644 index 0000000..21c2560 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/inside_footnote.html @@ -0,0 +1,17 @@ +

Lorem ipsum1 dolor sit amet.

+ +

Lorem ipsum2 dolor sit amet.

+ +
+
    +
  1. +

    Consecutur adisping.3 

    +
  2. +
  3. +

    Sed ut perspiciatis unde omnis. 

    +
  4. +
  5. +

    Sed ut. 

    +
  6. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/inside_footnote.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/inside_footnote.text new file mode 100644 index 0000000..f4f91e9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/inside_footnote.text @@ -0,0 +1,9 @@ +Lorem ipsum[^first] dolor sit amet. + +Lorem ipsum[^second] dolor sit amet. + +[^first]: Consecutur adisping.[^third] + +[^second]: Sed ut perspiciatis unde omnis. + +[^third]: Sed ut. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.html new file mode 100644 index 0000000..0c103f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.html @@ -0,0 +1,46 @@ +

This is some *ref.1

+ +
+

a blockquote 2

+
+ +
    +
  • and a list item 3
  • +
+ +

And a header4

+ +

A marker without a definition [^without].

+ +

A marker 5 used twice1 and thrice1.

+ +
+
    +
  1. +

    Some foot note text  2 3

    +
  2. +
  3. +

    other text +with more lines

    + +
    +

    and a quote

    +
    +

    +
  4. +
  5. +

    some text 

    +
  6. +
  7. + +
    code block
    +continued here
    +
    +

    +
  8. +
  9. + +

    +
  10. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.latex new file mode 100644 index 0000000..8f406b8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.latex @@ -0,0 +1,23 @@ +This is some *ref.\footnote{Some foot note text} + +\begin{quote} +a blockquote \footnote{other text +with more lines + +\begin{quote} +and a quote +\end{quote}} +\end{quote} + +\begin{itemize} +\item{} and a list item \footnote{some \emph{text}} +\end{itemize} + +\section*{And a header\footnote{\begin{verbatim}code block +continued here +\end{verbatim}}} + +A marker without a definition {[}\^{}without{]}. + +A marker \footnote{} used twice\footnote{Some foot note text} and thrice\footnote{Some foot note text}. + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.options new file mode 100644 index 0000000..5cfe250 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.options @@ -0,0 +1,2 @@ +:auto_ids: false +:entity_output: :symbolic diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.text new file mode 100644 index 0000000..42b77fb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/markers.text @@ -0,0 +1,27 @@ +This is some *ref.[^fn] + +[^fn]: Some foot note text +{: .class} + +> a blockquote [^3] + +* and a list item [^1] + +# And a header[^now] + +[^1]:some *text* +[^3]: other text + with more lines + + > and a quote + +A marker without a definition [^without]. + +A marker [^empty] used twice[^fn] and thrice[^fn]. + +[^now]: + + code block + continued here + +[^empty]: diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.html new file mode 100644 index 0000000..9acf8a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.html @@ -0,0 +1,11 @@ +
+
    +
  1. +

    Footnote \` text 

    +
  2. +
+
+ +

Some para with a1 footnote.

+ +

And another para.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.options new file mode 100644 index 0000000..2e6e0a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.options @@ -0,0 +1 @@ +:entity_output: :numeric diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.text new file mode 100644 index 0000000..97c0ab1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/placement.text @@ -0,0 +1,8 @@ +* footnotes will be placed here +{:footnotes} + +Some para with a[^1] footnote. + +[^1]: Footnote \\\` text + +And another para. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.html new file mode 100644 index 0000000..ff1b320 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.html @@ -0,0 +1,14 @@ +

Something

+

something1.

+ +

Footnotes

+ +

Test

+
+
    +
  1. + +

    A note 

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.options new file mode 100644 index 0000000..5cfe250 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.options @@ -0,0 +1,2 @@ +:auto_ids: false +:entity_output: :symbolic diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.text new file mode 100644 index 0000000..6a60c61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/regexp_problem.text @@ -0,0 +1,52 @@ +# Something +something[^note1]. + +# Footnotes +[^note1]: + A note + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# Test diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.html new file mode 100644 index 0000000..77f8e0d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.html @@ -0,0 +1,9 @@ +

Some footnote here1

+ +
+
    +
  1. +

    Some text here

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.options new file mode 100644 index 0000000..0512dd6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.options @@ -0,0 +1 @@ +:footnote_backlink: '' diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.text new file mode 100644 index 0000000..41a6f98 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/04_footnote/without_backlink.text @@ -0,0 +1,3 @@ +Some footnote here[^fn] + +[^fn]: Some text here diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/across_lines.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/across_lines.html new file mode 100644 index 0000000..e7cec40 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/across_lines.html @@ -0,0 +1 @@ +

Link: test

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/across_lines.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/across_lines.text new file mode 100644 index 0000000..8f39d95 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/across_lines.text @@ -0,0 +1,2 @@ +Link: test diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/button.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/button.html new file mode 100644 index 0000000..c49bb52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/button.html @@ -0,0 +1,7 @@ +

+ +

First some text and then a

+ +

and then text.

+ +

A it.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/button.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/button.text new file mode 100644 index 0000000..e0a7783 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/button.text @@ -0,0 +1,7 @@ + + +First some text and then a + + and then text. + +A it. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/invalid.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/invalid.html new file mode 100644 index 0000000..030552f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/invalid.html @@ -0,0 +1 @@ +

This is some text

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/invalid.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/invalid.text new file mode 100644 index 0000000..383f0a8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/invalid.text @@ -0,0 +1 @@ +This is some text diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/link_with_mailto.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/link_with_mailto.html new file mode 100644 index 0000000..7d0d6ad --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/link_with_mailto.html @@ -0,0 +1 @@ +

Link: text

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/link_with_mailto.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/link_with_mailto.text new file mode 100644 index 0000000..fb01619 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/link_with_mailto.text @@ -0,0 +1 @@ +Link: text diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/mark_element.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/mark_element.html new file mode 100644 index 0000000..b6989b7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/mark_element.html @@ -0,0 +1,3 @@ +

Lorem ipsum.

+ +

Test

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/mark_element.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/mark_element.text new file mode 100644 index 0000000..6ae30e0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/mark_element.text @@ -0,0 +1,3 @@ +Lorem ipsum. + +Test diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/markdown_attr.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/markdown_attr.html new file mode 100644 index 0000000..44158c3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/markdown_attr.html @@ -0,0 +1,6 @@ +

This is text +This is *text* +This is text +This is text +This is *nothing* to fear about. +This is <http://example.com>.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/markdown_attr.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/markdown_attr.text new file mode 100644 index 0000000..dcc10ff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/markdown_attr.text @@ -0,0 +1,6 @@ +This is *text* +This is *text* +This is *text* +This is *text* +This is *nothing* to *fear* about. +This is . diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/normal.html new file mode 100644 index 0000000..3cdc646 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/normal.html @@ -0,0 +1,43 @@ +

Empty !

+ +

title is a title.

+ +

This is <? a PI ?>.

+ +

This is comment.

+ +

This is multiline comment.

+ +

This is tag +now .

+ +

This is tag + now.

+ +

This is an empty tag.

+ +

This is something strange.

+ +

Auto-closing:

+ +

Expanding:

+ +

An invalid tag: <hR>

+ +

A <p>block tag</p>.

+ +

An invalid </closing> tag.

+ +

A tag.

+ +

An unclosed tag.

+ +

Some element with | pipe symbol

+ +

Some element with | pipe symbol

+ +

Some element with | pipe +symbol|

+ +

underlined

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/normal.text new file mode 100644 index 0000000..0156d7c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/normal.text @@ -0,0 +1,43 @@ +Empty ! + +title is a title. + +This is . + +This is comment. + +This is multiline comment. + +This is tag +now . + +This is tag + now. + +This is an empty tag. + +This is _something strange_. + +Auto-closing:
+ +Expanding: + +An invalid tag:
+ +A

block tag

. + +An invalid tag. + +A tag. + +An unclosed *tag.* + +Some element with | pipe symbol + +Some element with | pipe symbol + +Some element with | pipe +symbol| + +underlined diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/raw_span_elements.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/raw_span_elements.html new file mode 100644 index 0000000..808f1db --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/raw_span_elements.html @@ -0,0 +1,2 @@ +

This is raw --version and --version and --version and +---version.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/raw_span_elements.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/raw_span_elements.text new file mode 100644 index 0000000..5b128fc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/raw_span_elements.text @@ -0,0 +1,2 @@ +This is raw --version and --version and --version and +---version. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/xml.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/xml.html new file mode 100644 index 0000000..00b43c1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/xml.html @@ -0,0 +1,5 @@ +

This doit test

+ +

This doit test

+ +

This doit</some> test

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/xml.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/xml.text new file mode 100644 index 0000000..bc234de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/05_html/xml.text @@ -0,0 +1,5 @@ +This doit test + +This doit test + +This doit test diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev.html new file mode 100644 index 0000000..f247c53 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev.html @@ -0,0 +1,21 @@ +

This is some text.

+ +

There is some real concern about OtHeR!

+ +

is some Think empty about Oesterreich. CSS und CSS3

+ +

no abbrev here because there is someone and kulis some

+ +
    +
  • (X)HTML test
  • +
  • line two
  • +
+ +

(X)HTML

+ +
    +
  • test (X)HTML
  • +
+ +

This is awesome.

+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev.text new file mode 100644 index 0000000..1aa8100 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev.text @@ -0,0 +1,34 @@ +This is some text. + +*[is some]: Yes it is +*[OtHeR!]: This & that + +*[is some]: It is, yes +*[empty]: + +There *is some real* concern about OtHeR! + +is some Think empty about Oesterreich. CSS und CSS3 + +no abbrev here because there is someone and kulis some + +*[Oesterreich]: Very nice country + +*[CSS]: Cascading +*[CSS3]: Cascading 3 + +* (X)HTML test +* line two + +[(X)HTML](http://en.wikipedia.org/wiki/Xhtml) + +* test (X)HTML + +*[(X)HTML]: (eXtensible) HyperText Markup Language + + +This is awesome. + +{:.testit} +*[awesome]: Some text here +{:.test} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_defs.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_defs.html new file mode 100644 index 0000000..108fcfc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_defs.html @@ -0,0 +1,2 @@ +
*[4]: noabbrev
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_defs.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_defs.text new file mode 100644 index 0000000..3f3a0e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_defs.text @@ -0,0 +1,5 @@ +*[ABBR]: Some abbreviations + *[one abbr]: one abbrev + *[2 and other]: another + *[3]: yet another + *[4]: noabbrev diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_in_html.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_in_html.html new file mode 100644 index 0000000..6da3ca4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_in_html.html @@ -0,0 +1,9 @@ +

This is some TEST to check.

+ + + This TEST fails. + + + This TEST fails. + + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_in_html.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_in_html.text new file mode 100644 index 0000000..e0a0e88 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/abbrev_in_html.text @@ -0,0 +1,10 @@ +This is some TEST to check. + + + This TEST fails. + + + This TEST fails. + + +*[TEST]: This Escapes SVG Text. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/in_footnote.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/in_footnote.html new file mode 100644 index 0000000..4b6a97f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/in_footnote.html @@ -0,0 +1,9 @@ +

There is a TXT file here. 1

+ +
+
    +
  1. +

    A TXT file. 

    +
  2. +
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/in_footnote.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/in_footnote.text new file mode 100644 index 0000000..e7709cb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/abbreviations/in_footnote.text @@ -0,0 +1,5 @@ +There is a TXT file here. [^1] + +*[TXT]: Text File + +[^1]: A TXT file. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/autolinks/url_links.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/autolinks/url_links.html new file mode 100644 index 0000000..90eae7d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/autolinks/url_links.html @@ -0,0 +1,15 @@ +

This should be a http://www.example.com/ link. +This should be a john.doe@example.com link. +As should john.doe@example.com this. +As should john_doe@example.com this. +As should CSS@example.com this. +Another ampersand http://www.example.com/?doit&x=y link. +More entities http://www.example.com/?doit&x="y&z=y.

+ +

Email international übung@macht.den.meister.de, ü.äß@hülse.de +Email invalid: <me@example.com>

+ +

Autolink with underscore: http://www.example.com/with_under_score

+ +

http://www.example.com/

+ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/autolinks/url_links.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/autolinks/url_links.text new file mode 100644 index 0000000..033e8af --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/autolinks/url_links.text @@ -0,0 +1,16 @@ +This should be a link. +This should be a link. +As should this. +As should this. +As should this. +Another ampersand link. +More entities . + +Email international <übung@macht.den.meister.de>, <ü.äß@hülse.de> +Email invalid: <[me@example.com](mailtos:me@example.com)> + +Autolink with underscore: + + + +*[CSS]: Cascading diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/escaped_chars/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/escaped_chars/normal.html new file mode 100644 index 0000000..015d594 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/escaped_chars/normal.html @@ -0,0 +1,47 @@ +

\

+ +

.

+ +

*

+ +

_

+ +

+

+ +

-

+ +

`

+ +

(

+ +

)

+ +

[

+ +

]

+ +

{

+ +

}

+ +

#

+ +

!

+ +

<<

+ +

>>

+ +

:

+ +

|

+ +

"

+ +

'

+ +

=

+ +

>

+ +

<

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/escaped_chars/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/escaped_chars/normal.text new file mode 100644 index 0000000..1c47104 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/escaped_chars/normal.text @@ -0,0 +1,47 @@ +\\ + +\. + +\* + +\_ + +\+ + +\- + +\` + +\( + +\) + +\[ + +\] + +\{ + +\} + +\# + +\! + +\<< + +\>> + +\: + +\| + +\" + +\' + +\= + +\> + +\< diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/comment.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/comment.html new file mode 100644 index 0000000..3544d49 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/comment.html @@ -0,0 +1,6 @@ +

This is a paragraph. +This is a paragraph. +This is a . +This is a paragraph. +This is a {:/comment} simple {:/} paragraph. +This is a {::comment} paragraph.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/comment.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/comment.text new file mode 100644 index 0000000..8b9e8d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/comment.text @@ -0,0 +1,6 @@ +This is a {::comment}simple{:/} paragraph. +This is a {::comment}simple{:/comment} paragraph. +This is a {::comment}simple {:/other} paragraph{:/comment}. +This is a {::comment/} paragraph. +This is a {:/comment} simple {:/} paragraph. +This is a {::comment} paragraph. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/ignored.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/ignored.html new file mode 100644 index 0000000..63c2c40 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/ignored.html @@ -0,0 +1 @@ +

This is {::something}paragraph{:/}

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/ignored.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/ignored.text new file mode 100644 index 0000000..a7e7737 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/ignored.text @@ -0,0 +1 @@ +This is {::something}paragraph{:/} diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/nomarkdown.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/nomarkdown.html new file mode 100644 index 0000000..83de931 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/nomarkdown.html @@ -0,0 +1 @@ +

This is *some* text.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/nomarkdown.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/nomarkdown.text new file mode 100644 index 0000000..57c4b38 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/nomarkdown.text @@ -0,0 +1 @@ +This is {::nomarkdown}*some*{:/} text. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/options.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/options.html new file mode 100644 index 0000000..48e3076 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/options.html @@ -0,0 +1 @@ +

This is an option *true*!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/options.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/options.text new file mode 100644 index 0000000..e289491 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/extension/options.text @@ -0,0 +1 @@ +This is an {::options parse_span_html="false" /} option *true*! diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/ial/simple.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/ial/simple.html new file mode 100644 index 0000000..c0f3a47 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/ial/simple.html @@ -0,0 +1,6 @@ +

This is a span.

+ +

This is a span.

+ +

This is an{: .ignored} span ial. +This is an{: .escaped} span ial.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/ial/simple.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/ial/simple.text new file mode 100644 index 0000000..8945602 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/ial/simple.text @@ -0,0 +1,6 @@ +This is a `span`{: .hund #dog}. + +This is a `span`{: .hund #dog}{: .katz key='val'}. + +This is an{: .ignored} span ial. +This is an\{: .escaped} span ial. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.html new file mode 100644 index 0000000..11066a5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.html @@ -0,0 +1,11 @@ +

This is a line
+with a line break.

+ +

This is a line +without a line break.

+ +

This is a line
+with a line\
+break.

+ +

Line break on last line.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.latex new file mode 100644 index 0000000..a62ff56 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.latex @@ -0,0 +1,12 @@ +This is a line\newline +with a line break. + +This is a line +without a line break. + +This is a line \newline +with a line\textbackslash{} \newline +break. + +Line break on last line. + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.text new file mode 100644 index 0000000..92f866f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/line_breaks/normal.text @@ -0,0 +1,11 @@ +This is a line +with a line break. + +This is a line +without a line break. + +This is a line \\ +with a line\\ +break. + +Line break on last line. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.html new file mode 100644 index 0000000..3b93c54 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.html @@ -0,0 +1 @@ +

$5+5$ inline math

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.options new file mode 100644 index 0000000..06d559e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.options @@ -0,0 +1 @@ +:math_engine: ~ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.text new file mode 100644 index 0000000..a22f9fd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/no_engine.text @@ -0,0 +1 @@ +$$5+5$$ inline math diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/normal.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/normal.html new file mode 100644 index 0000000..459d03f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/normal.html @@ -0,0 +1,10 @@ +

This is \(\lambda_\alpha > 5\) some math. With \(1 ++ 1\) new line characters in between.

+ +

\(5+5\) inline math, $5.00 $$no math$$

+ +

$$5+5$$ inline math

+ +

\(5+5\)

+ +

$$5+5$$

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/normal.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/normal.text new file mode 100644 index 0000000..e37a007 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/math/normal.text @@ -0,0 +1,10 @@ +This is $$\lambda_\alpha > 5$$ some math. With $$1 ++ 1$$ new line characters in between. + +$$5+5$$ inline math, $5.00 \$$no math$$ + +\$\$5+5$$ inline math + +\$$5+5$$ + +\$\$5+5$$ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.html new file mode 100644 index 0000000..21a2903 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.html @@ -0,0 +1,6 @@ +

This is the A&O. © 2008 by me +As well \& as this. Some ŗ other +values may ¯ may also show but +not st. like &#xYZ;.

+ +

This <span> is BS&T; done!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.options new file mode 100644 index 0000000..036c561 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.options @@ -0,0 +1 @@ +:entity_output: :as_input diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.text new file mode 100644 index 0000000..7ef42c7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities.text @@ -0,0 +1,6 @@ +This is the A&O. © 2008 by me +As well \& as this. Some ŗ other +values may ¯ may also show but +not st. like &#xYZ;. + +This <span> is BS&T; done! diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.html new file mode 100644 index 0000000..ed2817b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.html @@ -0,0 +1 @@ +

This "is" 'the' A&O. © 2008 by me ŗ and λ

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.options new file mode 100644 index 0000000..32a751e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.options @@ -0,0 +1,2 @@ +:entity_output: :as_char +:smart_quotes: apos,apos,quot,quot diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.text new file mode 100644 index 0000000..279b511 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_char.text @@ -0,0 +1 @@ +This "is" 'the' A&O. © 2008 by me ŗ and λ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.html new file mode 100644 index 0000000..d2eec9d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.html @@ -0,0 +1 @@ +

This is the A&O. © 2008 by me ŗ and λ

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.options new file mode 100644 index 0000000..036c561 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.options @@ -0,0 +1 @@ +:entity_output: :as_input diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.text new file mode 100644 index 0000000..1ddf7cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_as_input.text @@ -0,0 +1 @@ +This is the A&O. © 2008 by me ŗ and λ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.html new file mode 100644 index 0000000..d04613e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.html @@ -0,0 +1 @@ +

This is the A&O. © 2008 by me ŗ and λ

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.options new file mode 100644 index 0000000..2e6e0a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.options @@ -0,0 +1 @@ +:entity_output: :numeric diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.text new file mode 100644 index 0000000..1ddf7cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_numeric.text @@ -0,0 +1 @@ +This is the A&O. © 2008 by me ŗ and λ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.html new file mode 100644 index 0000000..258ba14 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.html @@ -0,0 +1 @@ +

This is the A&O. © 2008 by me ŗ and λ

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.options new file mode 100644 index 0000000..c195785 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.options @@ -0,0 +1 @@ +:entity_output: :symbolic diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.text new file mode 100644 index 0000000..1ddf7cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/entities_symbolic.text @@ -0,0 +1 @@ +This is the A&O. © 2008 by me ŗ and λ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/greaterthan.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/greaterthan.html new file mode 100644 index 0000000..dcce4cc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/greaterthan.html @@ -0,0 +1 @@ +

2 > 1 > 0

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/greaterthan.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/greaterthan.text new file mode 100644 index 0000000..7dfb7f1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/greaterthan.text @@ -0,0 +1 @@ +2 > 1 > 0 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/lowerthan.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/lowerthan.html new file mode 100644 index 0000000..8ebac23 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/lowerthan.html @@ -0,0 +1 @@ +

0 < 1 < 2

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/lowerthan.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/lowerthan.text new file mode 100644 index 0000000..038df8b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/lowerthan.text @@ -0,0 +1 @@ +0 < 1 < 2 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.html new file mode 100644 index 0000000..02d1dbc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.html @@ -0,0 +1,40 @@ +

This is… something—this too–!

+ +

This «is» some text, « this » too!

+ +

“Fancy quotes” are ‘cool’, even in the ’80s! +Je t’ aime. You’re a funny one! Thomas’ name +Mark’s name. “…you” +“‘Nested’ quotes are ‘possible’”, too! +‘“Otherway” is “round”’!

+ +

‘Opening now!’

+ +

’80s are really cool.

+ +

Cluster’s Last Stand.

+ +

Nam liber tempor +“…At vero eos et accusam”

+ +

Single underscores should work.”

+ +

Single asterisks should work.”

+ +

Double underscores should work.’

+ +

Double asterisks should work.’

+ +

Hurrah!

+ +

Absolutely.’

+ +

“…some Text”

+ +

“… some Text”

+ +

This: “…some Text”

+ +

This: “… some Text”

+ +

”[foo]” “[foo]” d “[foo]”

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.options new file mode 100644 index 0000000..4f1c17c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.options @@ -0,0 +1 @@ +:entity_output: symbolic diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.text new file mode 100644 index 0000000..27e090e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography.text @@ -0,0 +1,40 @@ +This is... something---this too--! + +This <> some text, << this >> too! + +"Fancy quotes" are 'cool', even in the '80s! +Je t' aime. You're a funny one! Thomas' name +Mark's name. "...you" +"'Nested' quotes are 'possible'", too! +'"Otherway" is "round"'! + +'Opening now!' + +'80s are really cool. + +Cluster's Last Stand. + +Nam liber tempor +"...At vero eos et accusam" + +"_Single underscores_ should work." + +"*Single asterisks* should work." + +'__Double underscores__ should work.' + +'**Double asterisks** should work.' + +"_Hurrah!_" + +'__Absolutely__.' + +"...some Text" + +"... some Text" + +This: "...some Text" + +This: "... some Text" + +"\[foo]" "\[foo]" d "\[foo]" diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.html new file mode 100644 index 0000000..4a6c226 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.html @@ -0,0 +1,3 @@ +

This ... something---this too--!

+ +

This <<is>> some text, << this >> too!

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.latex b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.latex new file mode 100644 index 0000000..c7d9ba5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.latex @@ -0,0 +1,4 @@ +This ... something---this too--! + +This \textless{}\textless{}is\textgreater{}\textgreater{} some text, \textless{}\textless{} this \textgreater{}\textgreater{} too! + diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.options new file mode 100644 index 0000000..d0a0313 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.options @@ -0,0 +1,8 @@ +typographic_symbols: + hellip: '...' + mdash: '---' + ndash: '--' + laquo: '<<' + raquo: '>>' + laquo_space: '<< ' + raquo_space: ' >>' diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.text new file mode 100644 index 0000000..a3d59b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-2.4.0/test/testcases/span/text_substitutions/typography_subst.text @@ -0,0 +1,3 @@ +This ... something---this too--! + +This <> some text, << this >> too! diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/CONTRIBUTERS b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/CONTRIBUTERS new file mode 100644 index 0000000..262ad48 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/CONTRIBUTERS @@ -0,0 +1,4 @@ +Count Name +======= ==== + 15 Ashwin Maroli + 5 Thomas Leitner diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/COPYING b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/COPYING new file mode 100644 index 0000000..417fb2c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/COPYING @@ -0,0 +1,21 @@ +kramdown-parser-gfm +Copyright (C) 2019 Thomas Leitner + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/VERSION b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/VERSION new file mode 100644 index 0000000..9084fa2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/VERSION @@ -0,0 +1 @@ +1.1.0 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown-parser-gfm.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown-parser-gfm.rb new file mode 100644 index 0000000..3861bca --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown-parser-gfm.rb @@ -0,0 +1,10 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2019 Thomas Leitner +# +# This file is part of kramdown-parser-gfm which is licensed under the MIT. +#++ +# + +require_relative 'kramdown/parser/gfm' diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown/parser/gfm.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown/parser/gfm.rb new file mode 100644 index 0000000..c803e12 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown/parser/gfm.rb @@ -0,0 +1,220 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2019 Thomas Leitner +# +# This file is part of kramdown-parser-gfm which is licensed under the MIT. +#++ +# + +require 'kramdown/options' +require 'kramdown/parser/kramdown' + +require_relative 'gfm/options' + +module Kramdown + module Parser + + # This class provides a parser implementation for the GFM dialect of Markdown. + class GFM < Kramdown::Parser::Kramdown + + VERSION = '1.1.0' + + attr_reader :paragraph_end + + def initialize(source, options) + super + @options[:auto_id_stripping] = true + @id_counter = Hash.new(-1) + + @span_parsers.delete(:line_break) if @options[:hard_wrap] + @span_parsers.delete(:typographic_syms) if @options[:gfm_quirks].include?(:no_auto_typographic) + + if @options[:gfm_quirks].include?(:paragraph_end) + atx_header_parser = :atx_header_gfm_quirk + @paragraph_end = self.class::PARAGRAPH_END_GFM + else + atx_header_parser = :atx_header_gfm + @paragraph_end = self.class::PARAGRAPH_END + end + + {codeblock_fenced: :codeblock_fenced_gfm, + atx_header: atx_header_parser}.each do |current, replacement| + i = @block_parsers.index(current) + @block_parsers.delete(current) + @block_parsers.insert(i, replacement) + end + + i = @span_parsers.index(:escaped_chars) + @span_parsers[i] = :escaped_chars_gfm if i + @span_parsers << :strikethrough_gfm + + @hard_line_break = "#{@options[:hard_wrap] ? '' : '\\'}\n" + end + + def parse + super + update_elements(@root) + end + + def update_elements(element) + element.children.map! do |child| + if child.type == :text && child.value.include?(@hard_line_break) + update_text_type(element, child) + elsif child.type == :html_element + child + elsif child.type == :header && @options[:auto_ids] && !child.attr.key?('id') + child.attr['id'] = generate_gfm_header_id(child.options[:raw_text]) + child + else + update_elements(child) + child + end + end.flatten! + end + + # Update the raw text for automatic ID generation. + def update_raw_text(item) + raw_text = +'' + + append_text = lambda do |child| + case child.type + when :text, :codespan, :math + raw_text << child.value + when :entity + raw_text << child.value.char + when :smart_quote + raw_text << ::Kramdown::Utils::Entities.entity(child.value.to_s).char + when :typographic_sym + raw_text << case child.value + when :laquo_space + "« " + when :raquo_space + " »" + else + ::Kramdown::Utils::Entities.entity(child.value.to_s).char + end + else + child.children.each { |c| append_text.call(c) } + end + end + + append_text.call(item) + item.options[:raw_text] = raw_text + end + + NON_WORD_RE = /[^\p{Word}\- \t]/.freeze + + def generate_gfm_header_id(text) + result = text.downcase + result.gsub!(NON_WORD_RE, '') + result.tr!(" \t", '-') + + @id_counter[result] += 1 + counter_result = @id_counter[result] + result << "-#{counter_result}" if counter_result > 0 + + @options[:auto_id_prefix] + result + end + + ATX_HEADER_START = /^(?\#{1,6})[\t ]+(?.*)\n/.freeze + define_parser(:atx_header_gfm, ATX_HEADER_START, nil, 'parse_atx_header') + define_parser(:atx_header_gfm_quirk, ATX_HEADER_START) + + # Copied from kramdown/parser/kramdown/header.rb, removed the first line + def parse_atx_header_gfm_quirk + text, id = parse_header_contents + text.sub!(/[\t ]#+\z/, '') && text.rstrip! + return false if text.empty? + + add_header(@src["level"].length, text, id) + true + end + + FENCED_CODEBLOCK_START = /^[ ]{0,3}[~`]{3,}/.freeze + FENCED_CODEBLOCK_MATCH = /^[ ]{0,3}(([~`]){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^[ ]{0,3}\1\2*\s*?\n/m.freeze + define_parser(:codeblock_fenced_gfm, FENCED_CODEBLOCK_START, nil, 'parse_codeblock_fenced') + + STRIKETHROUGH_DELIM = /~~/.freeze + STRIKETHROUGH_MATCH = /#{STRIKETHROUGH_DELIM}(?!\s|~).*?[^\s~]#{STRIKETHROUGH_DELIM}/m.freeze + define_parser(:strikethrough_gfm, STRIKETHROUGH_MATCH, '~~') + + def parse_strikethrough_gfm + line_number = @src.current_line_number + + @src.pos += @src.matched_size + el = Element.new(:html_element, 'del', {}, category: :span, line: line_number) + @tree.children << el + + env = save_env + reset_env(src: Kramdown::Utils::StringScanner.new(@src.matched[2..-3], line_number), + text_type: :text) + parse_spans(el) + restore_env(env) + + el + end + + LIST_TYPES = [:ul, :ol].freeze + + # To handle task-lists we override the parse method for lists, converting matching text into + # checkbox input elements where necessary (as well as applying classes to the ul/ol and li + # elements). + def parse_list + super + current_list = @tree.children.select { |element| LIST_TYPES.include?(element.type) }.last + + is_tasklist = false + box_unchecked = '' + box_checked = '' + + current_list.children.each do |li| + list_items = li.children + next unless !list_items.empty? && list_items[0].type == :p + + # li -> p -> raw_text + descendant = list_items[0].children[0].value + checked = descendant.gsub!(/\A\s*\[ \]\s+/, box_unchecked) + unchecked = descendant.gsub!(/\A\s*\[x\]\s+/i, box_checked) + is_tasklist ||= checked || unchecked + + li.attr['class'] = 'task-list-item' if is_tasklist + end + + current_list.attr['class'] = 'task-list' if is_tasklist + + true + end + + ESCAPED_CHARS_GFM = /\\([\\.*_+`<>()\[\]{}#!:\|"'\$=\-~])/.freeze + define_parser(:escaped_chars_gfm, ESCAPED_CHARS_GFM, '\\\\', :parse_escaped_chars) + + PARAGRAPH_END_GFM = Regexp.union( + LAZY_END, LIST_START, ATX_HEADER_START, DEFINITION_LIST_START, + BLOCKQUOTE_START, FENCED_CODEBLOCK_START + ) + + private + + def update_text_type(element, child) + children = [] + lines = child.value.split(@hard_line_break, -1) + omit_trailing_br = (lines[-1].empty? && Kramdown::Element.category(element) == :block && + element.children[-1] == child) + + lines.each_with_index do |line, index| + new_element_options = {location: child.options[:location] + index} + children << Element.new(:text, (index > 0 ? "\n#{line}" : line), nil, new_element_options) + + if index < lines.size - 2 || (index == lines.size - 2 && !omit_trailing_br) + children << Element.new(:br, nil, nil, new_element_options) + end + end + + children + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown/parser/gfm/options.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown/parser/gfm/options.rb new file mode 100644 index 0000000..2fcd787 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/lib/kramdown/parser/gfm/options.rb @@ -0,0 +1,60 @@ +# -*- coding: utf-8; frozen_string_literal: true -*- +# +#-- +# Copyright (C) 2019 Thomas Leitner +# +# This file is part of kramdown-parser-gfm which is licensed under the MIT. +#++ +# + +module Kramdown + module Options + + define(:hard_wrap, Boolean, true, <<~EOF) + Interprets line breaks literally + + Insert HTML `
` tags inside paragraphs where the original Markdown + document had newlines (by default, Markdown ignores these newlines). + + Default: true + Used by: GFM parser + EOF + + define(:gfm_quirks, Object, [:paragraph_end], <<~EOF) do |val| + Enables a set of GFM specific quirks + + The way how GFM is transformed on Github often differs from the way + kramdown does things. Many of these differences are negligible but + others are not. + + This option allows one to enable/disable certain GFM quirks, i.e. ways + in which GFM parsing differs from kramdown parsing. + + The value has to be a list of quirk names that should be enabled, + separated by commas. Possible names are: + + * paragraph_end + + Disables the kramdown restriction that at least one blank line has to + be used after a paragraph before a new block element can be started. + + Note that if this quirk is used, lazy line wrapping does not fully + work anymore! + + * no_auto_typographic + + Disables automatic conversion of some characters into their + corresponding typographic symbols (like `--` to em-dash etc). + This helps to achieve results closer to what GitHub Flavored + Markdown produces. + + Default: paragraph_end + Used by: GFM parser + EOF + val = simple_array_validator(val, :gfm_quirks) + val.map! { |v| str_to_sym(v.to_s) } + val + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/test_files.rb b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/test_files.rb new file mode 100644 index 0000000..664f13d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/test_files.rb @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# +#-- +# Copyright (C) 2019 Thomas Leitner +# +# This file is part of kramdown-parser-gfm which is licensed under the MIT. +#++ +# + +require 'minitest/autorun' +require 'kramdown' +require 'kramdown/parser/gfm' +require 'yaml' +require 'tmpdir' + +Encoding.default_external = 'utf-8' + +class TestFiles < Minitest::Test + + # Generate test methods for gfm-to-html conversion + Dir[__dir__ + '/testcases/**/*.text'].each do |text_file| + basename = text_file.sub(/\.text$/, '') + + html_file = basename + '.html' + next unless File.exist?(html_file) + + define_method('test_gfm_' + File.basename(text_file, '.*') + '_to_html') do + opts_file = basename + '.options' + opts_file = File.join(File.dirname(html_file), 'options') if !File.exist?(opts_file) + options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1} + doc = Kramdown::Document.new(File.read(text_file), options.merge(input: 'GFM')) + assert_equal(File.read(html_file), doc.to_html) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/atx_header.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/atx_header.html new file mode 100644 index 0000000..776d7a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/atx_header.html @@ -0,0 +1,3 @@ +

header

+ +

#no header

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/atx_header.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/atx_header.text new file mode 100644 index 0000000..5e70e2b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/atx_header.text @@ -0,0 +1,3 @@ +# header + +#no header diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.html new file mode 100644 index 0000000..305f4c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.html @@ -0,0 +1,14 @@ +
Three backticks
+
+ +
Four backticks
+
+ +
Unbalanced bottom heavy
+
+ +
language no space
+
+ +
language with space
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.options new file mode 100644 index 0000000..72e9bc1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.options @@ -0,0 +1 @@ +:enable_coderay: false diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.text new file mode 100644 index 0000000..fb5c611 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/backticks_syntax.text @@ -0,0 +1,19 @@ +``` +Three backticks +``` + +```` +Four backticks +```` + +``` +Unbalanced bottom heavy +`````` + +````ruby +language no space +```` + +```` ruby +language with space +```` diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.html new file mode 100644 index 0000000..5ededae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.html @@ -0,0 +1,20 @@ +

normal

+ +
require 'kramdown'
+
+Kramdown::Document.new(text).to_html
+
+ +

indent with tab

+ +
```ruby
+require 'kramdown'
+
+Kramdown::Document.new(text).to_html
+```
+
+ +

indent with 2 spaces

+ +
  console.log("hello");
+
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.options new file mode 100644 index 0000000..72e9bc1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.options @@ -0,0 +1 @@ +:enable_coderay: false diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.text new file mode 100644 index 0000000..5e3e192 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/codeblock_fenced.text @@ -0,0 +1,21 @@ +normal + +```ruby +require 'kramdown' + +Kramdown::Document.new(text).to_html +``` + +indent with tab + + ```ruby + require 'kramdown' + + Kramdown::Document.new(text).to_html + ``` + +indent with 2 spaces + + ```js + console.log("hello"); + ``` diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks.html new file mode 100644 index 0000000..1dfb2f0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks.html @@ -0,0 +1,3 @@ +

one
+two
+three

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks.text new file mode 100644 index 0000000..f1287bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks.text @@ -0,0 +1,3 @@ +one +_two_ +three diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.html new file mode 100644 index 0000000..4b34619 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.html @@ -0,0 +1,5 @@ +

This is just a normal paragraph.
+Containing a manual line break above.

+ +

It was the best of times,
+it was the worst of times.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.options new file mode 100644 index 0000000..f2da683 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.options @@ -0,0 +1 @@ +:hard_wrap: false diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.text new file mode 100644 index 0000000..29e1d48 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/hard_line_breaks_off.text @@ -0,0 +1,5 @@ +This is just a normal paragraph. +Containing a manual line break above. + +It was the best of times,\ +it was the worst of times. diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.html new file mode 100644 index 0000000..b45fe8f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.html @@ -0,0 +1,27 @@ +

test

+ +

variable_name

+ +

abc def öúß

+ +

192 abc 192

+ +

;.;;

+ +

variable_name

+ +

variable_name

+ +

;;

+ +

before after tab

+ +

with code

+ +

with  ä space

+ +

With “smart” quotes

+ +

with — « typographic » … symbols

+ +

with

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.options new file mode 100644 index 0000000..8776b55 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.options @@ -0,0 +1 @@ +:auto_ids: true diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.text new file mode 100644 index 0000000..0a89c0b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids.text @@ -0,0 +1,27 @@ +### test {#myid} + +### variable_name + +### abc def öúß + +### 192 abc 192 + +### ;.;; + +### variable_name + +### variable_name + +### ;; + +### before after tab + +### with `code` + +### with  ä space + +### With "smart" quotes + +### with --- << typographic >> ... symbols + +### with $$m=5$$ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.html new file mode 100644 index 0000000..4aab072 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.html @@ -0,0 +1,3 @@ +

Header 1

+ +

123

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.options new file mode 100644 index 0000000..f37255d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.options @@ -0,0 +1,2 @@ +:auto_ids: true +:auto_id_prefix: hallo- diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.text new file mode 100644 index 0000000..acf09fe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/header_ids_with_prefix.text @@ -0,0 +1,3 @@ +# Header 1 + +# 123 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.html new file mode 100644 index 0000000..beecad4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.html @@ -0,0 +1,3 @@ +

Header with --ndash

+ +

with --- << typographic >> ... symbols

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.options new file mode 100644 index 0000000..4a83cd1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.options @@ -0,0 +1 @@ +:gfm_quirks: [no_auto_typographic] diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.text new file mode 100644 index 0000000..f579651 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/no_typographic.text @@ -0,0 +1,3 @@ +### Header with --ndash + +### with --- << typographic >> ... symbols diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.html new file mode 100644 index 0000000..41dfb3a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.html @@ -0,0 +1,31 @@ +

A
+ - b

+ +

This is a list
+- or is it

+ +

blockquote
+> text

+ +

header
+# text

+ +

codeblock fenced
+ +puts hello world +

+ +
    +
  • +

    level 1
    +some text

    + +

    begin level 2
    +* level 2
    +* level 2

    +
  • +
+ +

h1

+

## h2
+### h3

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.options b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.options new file mode 100644 index 0000000..704f643 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.options @@ -0,0 +1 @@ +:gfm_quirks: [] diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.text new file mode 100644 index 0000000..4e09e03 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end-disabled.text @@ -0,0 +1,27 @@ +A + - b + +This is a list +- or is it + +blockquote +> text + +header +# text + +codeblock fenced +``` +puts hello world +``` + +* level 1 + some text + + begin level 2 + * level 2 + * level 2 + +# h1 +## h2 +### h3 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end.html new file mode 100644 index 0000000..c337d61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end.html @@ -0,0 +1,38 @@ +

A

+
    +
  • b
  • +
+ +

This is a list

+
    +
  • or is it
  • +
+ +

blockquote

+
+

text

+
+ +

header

+

text

+ +

codeblock fenced

+
puts hello world
+
+ +
    +
  • +

    level 1
    +some text

    + +

    begin level 2

    +
      +
    • level 2
    • +
    • level 2
    • +
    +
  • +
+ +

h1

+

h2

+

h3

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end.text new file mode 100644 index 0000000..4e09e03 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/paragraph_end.text @@ -0,0 +1,27 @@ +A + - b + +This is a list +- or is it + +blockquote +> text + +header +# text + +codeblock fenced +``` +puts hello world +``` + +* level 1 + some text + + begin level 2 + * level 2 + * level 2 + +# h1 +## h2 +### h3 diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/strikethrough.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/strikethrough.html new file mode 100644 index 0000000..d35158f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/strikethrough.html @@ -0,0 +1,33 @@ +

This is a test

+ +

~This is another test~

+ +

This is yet another test~

+ +

~~ This is a test of it NOT working ~~

+ +

~~
+This
+is
+a
+multiline
+test
+~~

+ +

This is an inline strikethrough test

+ +

This is an ~~escaped~~ strikethrough.

+ +

This is a strikethrough with a ~ in the middle

+ +

I don’t even~ have an extra tilde.

+ +

This should ~~not be struck.

+ +

This is a complex strike through *test ~~with nesting involved* here~~.

+ +

This is a complex strike through *test with apparent nesting involved* here.

+ +

中文

+ +

a

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/strikethrough.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/strikethrough.text new file mode 100644 index 0000000..0984200 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/strikethrough.text @@ -0,0 +1,33 @@ +~~This is a test~~ + +~~~This is another test~~~ + +~~This is yet another test~~~ + +~~ This is a test of it NOT working ~~ + +~~ +This +is +a +**multiline** +test +~~ + +This is an ~~_inline_ **strikethrough**~~ test + +This is an \~~escaped~~ strikethrough. + +This is a ~~strikethrough with a ~ in the middle~~ + +I ~~don't even~~~ have an extra tilde. + +This should ~~not be struck. + +This ~~is a complex *strike* through *test ~~with nesting~~ involved* here~~. + +This ~~is a complex *strike* through *test~~ with apparent nesting ~~involved* here~~. + +~~中文~~ + +~~a~~ diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/task_list.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/task_list.html new file mode 100644 index 0000000..a11b553 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/task_list.html @@ -0,0 +1,40 @@ +

unordered task list

+ +
    +
  • first ul task item
  • +
  • second ul task item
  • +
  • third ul task item
  • +
  • fourth ul task item [ ] next
  • +
+ +

unordered list

+ +
    +
  • +
    +

    first ul item

    +
    +
  • +
  • +
  • +
    test
    +
    +
  • +
  • second ul item
  • +
+ +

ordered list

+ +
    +
  1. first ol item
  2. +
  3. second ol item
  4. +
+ +

ordered task list

+ +
    +
  1. first ol task item
  2. +
  3. second ol task item
  4. +
  5. third ol task item
  6. +
  7. fourth ol task item
  8. +
diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/task_list.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/task_list.text new file mode 100644 index 0000000..f6ade2f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/task_list.text @@ -0,0 +1,26 @@ +unordered task list + +- [ ] first ul task item +- [x] second ul task item +- [X] third ul task item +- [ ] fourth ul task item [ ] next + +unordered list + +- > first ul item +- +- + test +- second ul item + +ordered list + +1. first ol item +2. second ol item + +ordered task list + +1. [ ] first ol task item +2. [x] second ol task item +3. [X] third ol task item +4. [ ] fourth ol task item diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/two_para_hard_line_breaks.html b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/two_para_hard_line_breaks.html new file mode 100644 index 0000000..d5ba2e4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/two_para_hard_line_breaks.html @@ -0,0 +1,4 @@ +

This is just a normal paragraph.
+Containing a line break.

+ +

Another paragraph.

diff --git a/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/two_para_hard_line_breaks.text b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/two_para_hard_line_breaks.text new file mode 100644 index 0000000..6b3d7c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/kramdown-parser-gfm-1.1.0/test/testcases/two_para_hard_line_breaks.text @@ -0,0 +1,4 @@ +This is just a normal paragraph. +Containing a line break. + +Another paragraph. diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/History.md b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/History.md new file mode 100644 index 0000000..6887d18 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/History.md @@ -0,0 +1,293 @@ +# Liquid Change Log + +## 4.0.4 / (unreleased) + +### Fixed +* Fix ruby 3.2 compatibility by avoiding use of the removed taint API + +## 4.0.3 / 2019-03-12 + +### Fixed +* Fix break and continue tags inside included templates in loops (#1072) [Justin Li] + +## 4.0.2 / 2019-03-08 + +### Changed +* Add `where` filter (#1026) [Samuel Doiron] +* Add `ParseTreeVisitor` to iterate the Liquid AST (#1025) [Stephen Paul Weber] +* Improve `strip_html` performance (#1032) [printercu] + +### Fixed +* Add error checking for invalid combinations of inputs to sort, sort_natural, where, uniq, map, compact filters (#1059) [Garland Zhang] +* Validate the character encoding in url_decode (#1070) [Clayton Smith] + +## 4.0.1 / 2018-10-09 + +### Changed +* Add benchmark group in Gemfile (#855) [Jerry Liu] +* Allow benchmarks to benchmark render by itself (#851) [Jerry Liu] +* Avoid calling `line_number` on String node when rescuing a render error. (#860) [Dylan Thacker-Smith] +* Avoid duck typing to detect whether to call render on a node. [Dylan Thacker-Smith] +* Clarify spelling of `reversed` on `for` block tag (#843) [Mark Crossfield] +* Replace recursion with loop to avoid potential stack overflow from malicious input (#891, #892) [Dylan Thacker-Smith] +* Limit block tag nesting to 100 (#894) [Dylan Thacker-Smith] +* Replace `assert_equal nil` with `assert_nil` (#895) [Dylan Thacker-Smith] +* Remove Spy Gem (#896) [Dylan Thacker-Smith] +* Add `collection_name` and `variable_name` reader to `For` block (#909) +* Symbols render as strings (#920) [Justin Li] +* Remove default value from Hash objects (#932) [Maxime Bedard] +* Remove one level of nesting (#944) [Dylan Thacker-Smith] +* Update Rubocop version (#952) [Justin Li] +* Add `at_least` and `at_most` filters (#954, #958) [Nithin Bekal] +* Add a regression test for a liquid-c trim mode bug (#972) [Dylan Thacker-Smith] +* Use https rather than git protocol to fetch liquid-c [Dylan Thacker-Smith] +* Add tests against Ruby 2.4 (#963) and 2.5 (#981) +* Replace RegExp literals with constants (#988) [Ashwin Maroli] +* Replace unnecessary `#each_with_index` with `#each` (#992) [Ashwin Maroli] +* Improve the unexpected end delimiter message for block tags. (#1003) [Dylan Thacker-Smith] +* Refactor and optimize rendering (#1005) [Christopher Aue] +* Add installation instruction (#1006) [Ben Gift] +* Remove Circle CI (#1010) +* Rename deprecated `BigDecimal.new` to `BigDecimal` (#1024) [Koichi ITO] +* Rename deprecated Rubocop name (#1027) [Justin Li] + +### Fixed +* Handle `join` filter on non String joiners (#857) [Richard Monette] +* Fix duplicate inclusion condition logic error of `Liquid::Strainer.add_filter` method (#861) +* Fix `escape`, `url_encode`, `url_decode` not handling non-string values (#898) [Thierry Joyal] +* Fix raise when variable is defined but nil when using `strict_variables` [Pascal Betz] +* Fix `sort` and `sort_natural` to handle arrays with nils (#930) [Eric Chan] + +## 4.0.0 / 2016-12-14 / branch "4-0-stable" + +### Changed +* Render an opaque internal error by default for non-Liquid::Error (#835) [Dylan Thacker-Smith] +* Ruby 2.0 support dropped (#832) [Dylan Thacker-Smith] +* Add to_number Drop method to allow custom drops to work with number filters (#731) +* Add strict_variables and strict_filters options to detect undefined references (#691) +* Improve loop performance (#681) [Florian Weingarten] +* Rename Drop method `before_method` to `liquid_method_missing` (#661) [Thierry Joyal] +* Add url_decode filter to invert url_encode (#645) [Larry Archer] +* Add global_filter to apply a filter to all output (#610) [Loren Hale] +* Add compact filter (#600) [Carson Reinke] +* Rename deprecated "has_key?" and "has_interrupt?" methods (#593) [Florian Weingarten] +* Include template name with line numbers in render errors (574) [Dylan Thacker-Smith] +* Add sort_natural filter (#554) [Martin Hanzel] +* Add forloop.parentloop as a reference to the parent loop (#520) [Justin Li] +* Block parsing moved to BlockBody class (#458) [Dylan Thacker-Smith] +* Add concat filter to concatenate arrays (#429) [Diogo Beato] +* Ruby 1.9 support dropped (#491) [Justin Li] +* Liquid::Template.file_system's read_template_file method is no longer passed the context. (#441) [James Reid-Smith] +* Remove `liquid_methods` (See https://github.com/Shopify/liquid/pull/568 for replacement) +* Liquid::Template.register_filter raises when the module overrides registered public methods as private or protected (#705) [Gaurav Chande] + +### Fixed + +* Fix variable names being detected as an operator when starting with contains (#788) [Michael Angell] +* Fix include tag used with strict_variables (#828) [QuickPay] +* Fix map filter when value is a Proc (#672) [Guillaume Malette] +* Fix truncate filter when value is not a string (#672) [Guillaume Malette] +* Fix behaviour of escape filter when input is nil (#665) [Tanel Jakobsoo] +* Fix sort filter behaviour with empty array input (#652) [Marcel Cary] +* Fix test failure under certain timezones (#631) [Dylan Thacker-Smith] +* Fix bug in uniq filter (#595) [Florian Weingarten] +* Fix bug when "blank" and "empty" are used as variable names (#592) [Florian Weingarten] +* Fix condition parse order in strict mode (#569) [Justin Li] +* Fix naming of the "context variable" when dynamically including a template (#559) [Justin Li] +* Gracefully accept empty strings in the date filter (#555) [Loren Hale] +* Fix capturing into variables with a hyphen in the name (#505) [Florian Weingarten] +* Fix case sensitivity regression in date standard filter (#499) [Kelley Reynolds] +* Disallow filters with no variable in strict mode (#475) [Justin Li] +* Disallow variable names in the strict parser that are not valid in the lax parser (#463) [Justin Li] +* Fix BlockBody#warnings taking exponential time to compute (#486) [Justin Li] + +## 3.0.5 / 2015-07-23 / branch "3-0-stable" + +* Fix test failure under certain timezones [Dylan Thacker-Smith] + +## 3.0.4 / 2015-07-17 + +* Fix chained access to multi-dimensional hashes [Florian Weingarten] + +## 3.0.3 / 2015-05-28 + +* Fix condition parse order in strict mode (#569) [Justin Li] + +## 3.0.2 / 2015-04-24 + +* Expose VariableLookup private members (#551) [Justin Li] +* Documentation fixes + +## 3.0.1 / 2015-01-23 + +* Remove duplicate `index0` key in TableRow tag (#502) [Alfred Xing] + +## 3.0.0 / 2014-11-12 + +* Removed Block#end_tag. Instead, override parse with `super` followed by your code. See #446 [Dylan Thacker-Smith] +* Fixed condition with wrong data types (#423) [Bogdan Gusiev] +* Add url_encode to standard filters (#421) [Derrick Reimer] +* Add uniq to standard filters [Florian Weingarten] +* Add exception_handler feature (#397) and #254 [Bogdan Gusiev, Florian Weingarten] +* Optimize variable parsing to avoid repeated regex evaluation during template rendering #383 [Jason Hiltz-Laforge] +* Optimize checking for block interrupts to reduce object allocation #380 [Jason Hiltz-Laforge] +* Properly set context rethrow_errors on render! #349 [Thierry Joyal] +* Fix broken rendering of variables which are equal to false (#345) [Florian Weingarten] +* Remove ActionView template handler [Dylan Thacker-Smith] +* Freeze lots of string literals for new Ruby 2.1 optimization (#297) [Florian Weingarten] +* Allow newlines in tags and variables (#324) [Dylan Thacker-Smith] +* Tag#parse is called after initialize, which now takes options instead of tokens as the 3rd argument. See #321 [Dylan Thacker-Smith] +* Raise `Liquid::ArgumentError` instead of `::ArgumentError` when filter has wrong number of arguments #309 [Bogdan Gusiev] +* Add a to_s default for liquid drops (#306) [Adam Doeler] +* Add strip, lstrip, and rstrip to standard filters [Florian Weingarten] +* Make if, for & case tags return complete and consistent nodelists (#250) [Nick Jones] +* Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith] +* Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl] +* Fix resource counting bug with respond_to?(:length) (#263) [Florian Weingarten] +* Allow specifying custom patterns for template filenames (#284) [Andrei Gladkyi] +* Allow drops to optimize loading a slice of elements (#282) [Tom Burns] +* Support for passing variables to snippets in subdirs (#271) [Joost Hietbrink] +* Add a class cache to avoid runtime extend calls (#249) [James Tucker] +* Remove some legacy Ruby 1.8 compatibility code (#276) [Florian Weingarten] +* Add default filter to standard filters (#267) [Derrick Reimer] +* Add optional strict parsing and warn parsing (#235) [Tristan Hume] +* Add I18n syntax error translation (#241) [Simon Hørup Eskildsen, Sirupsen] +* Make sort filter work on enumerable drops (#239) [Florian Weingarten] +* Fix clashing method names in enumerable drops (#238) [Florian Weingarten] +* Make map filter work on enumerable drops (#233) [Florian Weingarten] +* Improved whitespace stripping for blank blocks, related to #216 [Florian Weingarten] + +## 2.6.3 / 2015-07-23 / branch "2-6-stable" + +* Fix test failure under certain timezones [Dylan Thacker-Smith] + +## 2.6.2 / 2015-01-23 + +* Remove duplicate hash key [Parker Moore] + +## 2.6.1 / 2014-01-10 + +Security fix, cherry-picked from master (4e14a65): +* Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl] +* Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith] + +## 2.6.0 / 2013-11-25 + +IMPORTANT: Liquid 2.6 is going to be the last version of Liquid which maintains explicit Ruby 1.8 compatability. +The following releases will only be tested against Ruby 1.9 and Ruby 2.0 and are likely to break on Ruby 1.8. + +* Bugfix for #106: fix example servlet [gnowoel] +* Bugfix for #97: strip_html filter supports multi-line tags [Jo Liss] +* Bugfix for #114: strip_html filter supports style tags [James Allardice] +* Bugfix for #117: 'now' support for date filter in Ruby 1.9 [Notre Dame Webgroup] +* Bugfix for #166: truncate filter on UTF-8 strings with Ruby 1.8 [Florian Weingarten] +* Bugfix for #204: 'raw' parsing bug [Florian Weingarten] +* Bugfix for #150: 'for' parsing bug [Peter Schröder] +* Bugfix for #126: Strip CRLF in strip_newline [Peter Schröder] +* Bugfix for #174, "can't convert Fixnum into String" for "replace" [jsw0528] +* Allow a Liquid::Drop to be passed into Template#render [Daniel Huckstep] +* Resource limits [Florian Weingarten] +* Add reverse filter [Jay Strybis] +* Add utf-8 support +* Use array instead of Hash to keep the registered filters [Tasos Stathopoulos] +* Cache tokenized partial templates [Tom Burns] +* Avoid warnings in Ruby 1.9.3 [Marcus Stollsteimer] +* Better documentation for 'include' tag (closes #163) [Peter Schröder] +* Use of BigDecimal on filters to have better precision (closes #155) [Arthur Nogueira Neves] + +## 2.5.5 / 2014-01-10 / branch "2-5-stable" + +Security fix, cherry-picked from master (4e14a65): +* Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl] +* Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith] + +## 2.5.4 / 2013-11-11 + +* Fix "can't convert Fixnum into String" for "replace" (#173), [jsw0528] + +## 2.5.3 / 2013-10-09 + +* #232, #234, #237: Fix map filter bugs [Florian Weingarten] + +## 2.5.2 / 2013-09-03 / deleted + +Yanked from rubygems, as it contained too many changes that broke compatibility. Those changes will be on following major releases. + +## 2.5.1 / 2013-07-24 + +* #230: Fix security issue with map filter, Use invoke_drop in map filter [Florian Weingarten] + +## 2.5.0 / 2013-03-06 + +* Prevent Object methods from being called on drops +* Avoid symbol injection from liquid +* Added break and continue statements +* Fix filter parser for args without space separators +* Add support for filter keyword arguments + + +## 2.4.0 / 2012-08-03 + +* Performance improvements +* Allow filters in `assign` +* Add `modulo` filter +* Ruby 1.8, 1.9, and Rubinius compatibility fixes +* Add support for `quoted['references']` in `tablerow` +* Add support for Enumerable to `tablerow` +* `strip_html` filter removes html comments + + +## 2.3.0 / 2011-10-16 + +* Several speed/memory improvements +* Numerous bug fixes +* Added support for MRI 1.9, Rubinius, and JRuby +* Added support for integer drop parameters +* Added epoch support to `date` filter +* New `raw` tag that suppresses parsing +* Added `else` option to `for` tag +* New `increment` tag +* New `split` filter + + +## 2.2.1 / 2010-08-23 + +* Added support for literal tags + + +## 2.2.0 / 2010-08-22 + +* Compatible with Ruby 1.8.7, 1.9.1 and 1.9.2-p0 +* Merged some changed made by the community + + +## 1.9.0 / 2008-03-04 + +* Fixed gem install rake task +* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins + + +## Before 1.9.0 + +* Added If with or / and expressions +* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods. +* Added more tags to standard library +* Added include tag ( like partials in rails ) +* [...] Gazillion of detail improvements +* Added strainers as filter hosts for better security [Tobias Luetke] +* Fixed that rails integration would call filter with the wrong "self" [Michael Geary] +* Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the filter which was obviously misleading [Tobias Luetke] +* Removed count helper from standard lib. use size [Tobias Luetke] +* Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond] +* Improved filter parameters. Filter parameters are now context sensitive; Types are resolved according to the rules of the context. Multiple parameters are now separated by the Liquid::ArgumentSeparator: , by default [Paul Hammond] + {{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }} +* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke] + + class ProductDrop < Liquid::Drop + def top_sales + Shop.current.products.find(:all, :order => 'sales', :limit => 10 ) + end + end + t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' ) + t.render('product' => ProductDrop.new ) +* Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond] diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/LICENSE b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/LICENSE new file mode 100644 index 0000000..926b04e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2005, 2006 Tobias Luetke + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/README.md b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/README.md new file mode 100644 index 0000000..77e9ff4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/README.md @@ -0,0 +1,108 @@ +[![Build Status](https://api.travis-ci.org/Shopify/liquid.svg?branch=master)](http://travis-ci.org/Shopify/liquid) +[![Inline docs](http://inch-ci.org/github/Shopify/liquid.svg?branch=master)](http://inch-ci.org/github/Shopify/liquid) + +# Liquid template engine + +* [Contributing guidelines](CONTRIBUTING.md) +* [Version history](History.md) +* [Liquid documentation from Shopify](http://docs.shopify.com/themes/liquid-basics) +* [Liquid Wiki at GitHub](https://github.com/Shopify/liquid/wiki) +* [Website](http://liquidmarkup.org/) + +## Introduction + +Liquid is a template engine which was written with very specific requirements: + +* It has to have beautiful and simple markup. Template engines which don't produce good looking markup are no fun to use. +* It needs to be non evaling and secure. Liquid templates are made so that users can edit them. You don't want to run code on your server which your users wrote. +* It has to be stateless. Compile and render steps have to be separate so that the expensive parsing and compiling can be done once and later on you can just render it passing in a hash with local variables and objects. + +## Why you should use Liquid + +* You want to allow your users to edit the appearance of your application but don't want them to run **insecure code on your server**. +* You want to render templates directly from the database. +* You like smarty (PHP) style template engines. +* You need a template engine which does HTML just as well as emails. +* You don't like the markup of your current templating engine. + +## What does it look like? + +```html +
    + {% for product in products %} +
  • +

    {{ product.name }}

    + Only {{ product.price | price }} + + {{ product.description | prettyprint | paragraph }} +
  • + {% endfor %} +
+``` + +## How to use Liquid + +Install Liquid by adding `gem 'liquid'` to your gemfile. + +Liquid supports a very simple API based around the Liquid::Template class. +For standard use you can just pass it the content of a file and call render with a parameters hash. + +```ruby +@template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template +@template.render('name' => 'tobi') # => "hi tobi" +``` + +### Error Modes + +Setting the error mode of Liquid lets you specify how strictly you want your templates to be interpreted. +Normally the parser is very lax and will accept almost anything without error. Unfortunately this can make +it very hard to debug and can lead to unexpected behaviour. + +Liquid also comes with a stricter parser that can be used when editing templates to give better error messages +when templates are invalid. You can enable this new parser like this: + +```ruby +Liquid::Template.error_mode = :strict # Raises a SyntaxError when invalid syntax is used +Liquid::Template.error_mode = :warn # Adds errors to template.errors but continues as normal +Liquid::Template.error_mode = :lax # The default mode, accepts almost anything. +``` + +If you want to set the error mode only on specific templates you can pass `:error_mode` as an option to `parse`: +```ruby +Liquid::Template.parse(source, :error_mode => :strict) +``` +This is useful for doing things like enabling strict mode only in the theme editor. + +It is recommended that you enable `:strict` or `:warn` mode on new apps to stop invalid templates from being created. +It is also recommended that you use it in the template editors of existing apps to give editors better error messages. + +### Undefined variables and filters + +By default, the renderer doesn't raise or in any other way notify you if some variables or filters are missing, i.e. not passed to the `render` method. +You can improve this situation by passing `strict_variables: true` and/or `strict_filters: true` options to the `render` method. +When one of these options is set to true, all errors about undefined variables and undefined filters will be stored in `errors` array of a `Liquid::Template` instance. +Here are some examples: + +```ruby +template = Liquid::Template.parse("{{x}} {{y}} {{z.a}} {{z.b}}") +template.render({ 'x' => 1, 'z' => { 'a' => 2 } }, { strict_variables: true }) +#=> '1 2 ' # when a variable is undefined, it's rendered as nil +template.errors +#=> [#, #] +``` + +```ruby +template = Liquid::Template.parse("{{x | filter1 | upcase}}") +template.render({ 'x' => 'foo' }, { strict_filters: true }) +#=> '' # when at least one filter in the filter chain is undefined, a whole expression is rendered as nil +template.errors +#=> [#] +``` + +If you want to raise on a first exception instead of pushing all of them in `errors`, you can use `render!` method: + +```ruby +template = Liquid::Template.parse("{{x}} {{y}}") +template.render!({ 'x' => 1}, { strict_variables: true }) +#=> Liquid::UndefinedVariable: Liquid error: undefined variable y +``` diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid.rb new file mode 100644 index 0000000..770d2f9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid.rb @@ -0,0 +1,80 @@ +# Copyright (c) 2005 Tobias Luetke +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module Liquid + FilterSeparator = /\|/ + ArgumentSeparator = ','.freeze + FilterArgumentSeparator = ':'.freeze + VariableAttributeSeparator = '.'.freeze + WhitespaceControl = '-'.freeze + TagStart = /\{\%/ + TagEnd = /\%\}/ + VariableSignature = /\(?[\w\-\.\[\]]\)?/ + VariableSegment = /[\w\-]/ + VariableStart = /\{\{/ + VariableEnd = /\}\}/ + VariableIncompleteEnd = /\}\}?/ + QuotedString = /"[^"]*"|'[^']*'/ + QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o + TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/o + AnyStartingTag = /#{TagStart}|#{VariableStart}/o + PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/om + TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om + VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o + + singleton_class.send(:attr_accessor, :cache_classes) + self.cache_classes = true +end + +require "liquid/version" +require 'liquid/parse_tree_visitor' +require 'liquid/lexer' +require 'liquid/parser' +require 'liquid/i18n' +require 'liquid/drop' +require 'liquid/tablerowloop_drop' +require 'liquid/forloop_drop' +require 'liquid/extensions' +require 'liquid/errors' +require 'liquid/interrupts' +require 'liquid/strainer' +require 'liquid/expression' +require 'liquid/context' +require 'liquid/parser_switching' +require 'liquid/tag' +require 'liquid/block' +require 'liquid/block_body' +require 'liquid/document' +require 'liquid/variable' +require 'liquid/variable_lookup' +require 'liquid/range_lookup' +require 'liquid/file_system' +require 'liquid/resource_limits' +require 'liquid/template' +require 'liquid/standardfilters' +require 'liquid/condition' +require 'liquid/utils' +require 'liquid/tokenizer' +require 'liquid/parse_context' + +# Load all the tags of the standard library +# +Dir["#{__dir__}/liquid/tags/*.rb"].each { |f| require f } diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block.rb new file mode 100644 index 0000000..00c59b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block.rb @@ -0,0 +1,77 @@ +module Liquid + class Block < Tag + MAX_DEPTH = 100 + + def initialize(tag_name, markup, options) + super + @blank = true + end + + def parse(tokens) + @body = BlockBody.new + while parse_body(@body, tokens) + end + end + + def render(context) + @body.render(context) + end + + def blank? + @blank + end + + def nodelist + @body.nodelist + end + + def unknown_tag(tag, _params, _tokens) + if tag == 'else'.freeze + raise SyntaxError.new(parse_context.locale.t("errors.syntax.unexpected_else".freeze, + block_name: block_name)) + elsif tag.start_with?('end'.freeze) + raise SyntaxError.new(parse_context.locale.t("errors.syntax.invalid_delimiter".freeze, + tag: tag, + block_name: block_name, + block_delimiter: block_delimiter)) + else + raise SyntaxError.new(parse_context.locale.t("errors.syntax.unknown_tag".freeze, tag: tag)) + end + end + + def block_name + @tag_name + end + + def block_delimiter + @block_delimiter ||= "end#{block_name}" + end + + protected + + def parse_body(body, tokens) + if parse_context.depth >= MAX_DEPTH + raise StackLevelError, "Nesting too deep".freeze + end + parse_context.depth += 1 + begin + body.parse(tokens, parse_context) do |end_tag_name, end_tag_params| + @blank &&= body.blank? + + return false if end_tag_name == block_delimiter + unless end_tag_name + raise SyntaxError.new(parse_context.locale.t("errors.syntax.tag_never_closed".freeze, block_name: block_name)) + end + + # this tag is not registered with the system + # pass it to the current block for special handling or error reporting + unknown_tag(end_tag_name, end_tag_params, tokens) + end + ensure + parse_context.depth -= 1 + end + + true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb new file mode 100644 index 0000000..ba29415 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb @@ -0,0 +1,143 @@ +module Liquid + class BlockBody + FullToken = /\A#{TagStart}#{WhitespaceControl}?\s*(\w+)\s*(.*?)#{WhitespaceControl}?#{TagEnd}\z/om + ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om + WhitespaceOrNothing = /\A\s*\z/ + TAGSTART = "{%".freeze + VARSTART = "{{".freeze + + attr_reader :nodelist + + def initialize + @nodelist = [] + @blank = true + end + + def parse(tokenizer, parse_context) + parse_context.line_number = tokenizer.line_number + while token = tokenizer.shift + next if token.empty? + case + when token.start_with?(TAGSTART) + whitespace_handler(token, parse_context) + unless token =~ FullToken + raise_missing_tag_terminator(token, parse_context) + end + tag_name = $1 + markup = $2 + # fetch the tag from registered blocks + unless tag = registered_tags[tag_name] + # end parsing if we reach an unknown tag and let the caller decide + # determine how to proceed + return yield tag_name, markup + end + new_tag = tag.parse(tag_name, markup, tokenizer, parse_context) + @blank &&= new_tag.blank? + @nodelist << new_tag + when token.start_with?(VARSTART) + whitespace_handler(token, parse_context) + @nodelist << create_variable(token, parse_context) + @blank = false + else + if parse_context.trim_whitespace + token.lstrip! + end + parse_context.trim_whitespace = false + @nodelist << token + @blank &&= !!(token =~ WhitespaceOrNothing) + end + parse_context.line_number = tokenizer.line_number + end + + yield nil, nil + end + + def whitespace_handler(token, parse_context) + if token[2] == WhitespaceControl + previous_token = @nodelist.last + if previous_token.is_a? String + previous_token.rstrip! + end + end + parse_context.trim_whitespace = (token[-3] == WhitespaceControl) + end + + def blank? + @blank + end + + def render(context) + output = [] + context.resource_limits.render_score += @nodelist.length + + idx = 0 + while node = @nodelist[idx] + case node + when String + check_resources(context, node) + output << node + when Variable + render_node_to_output(node, output, context) + when Block + render_node_to_output(node, output, context, node.blank?) + break if context.interrupt? # might have happened in a for-block + when Continue, Break + # If we get an Interrupt that means the block must stop processing. An + # Interrupt is any command that stops block execution such as {% break %} + # or {% continue %} + context.push_interrupt(node.interrupt) + break + else # Other non-Block tags + render_node_to_output(node, output, context) + break if context.interrupt? # might have happened through an include + end + idx += 1 + end + + output.join + end + + private + + def render_node_to_output(node, output, context, skip_output = false) + node_output = node.render(context) + node_output = node_output.is_a?(Array) ? node_output.join : node_output.to_s + check_resources(context, node_output) + output << node_output unless skip_output + rescue MemoryError => e + raise e + rescue UndefinedVariable, UndefinedDropMethod, UndefinedFilter => e + context.handle_error(e, node.line_number) + output << nil + rescue ::StandardError => e + line_number = node.is_a?(String) ? nil : node.line_number + output << context.handle_error(e, line_number) + end + + def check_resources(context, node_output) + context.resource_limits.render_length += node_output.length + return unless context.resource_limits.reached? + raise MemoryError.new("Memory limits exceeded".freeze) + end + + def create_variable(token, parse_context) + token.scan(ContentOfVariable) do |content| + markup = content.first + return Variable.new(markup, parse_context) + end + raise_missing_variable_terminator(token, parse_context) + end + + def raise_missing_tag_terminator(token, parse_context) + raise SyntaxError.new(parse_context.locale.t("errors.syntax.tag_termination".freeze, token: token, tag_end: TagEnd.inspect)) + end + + def raise_missing_variable_terminator(token, parse_context) + raise SyntaxError.new(parse_context.locale.t("errors.syntax.variable_termination".freeze, token: token, tag_end: VariableEnd.inspect)) + end + + def registered_tags + Template.tags + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/condition.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/condition.rb new file mode 100644 index 0000000..3b51682 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/condition.rb @@ -0,0 +1,151 @@ +module Liquid + # Container for liquid nodes which conveniently wraps decision making logic + # + # Example: + # + # c = Condition.new(1, '==', 1) + # c.evaluate #=> true + # + class Condition #:nodoc: + @@operators = { + '=='.freeze => ->(cond, left, right) { cond.send(:equal_variables, left, right) }, + '!='.freeze => ->(cond, left, right) { !cond.send(:equal_variables, left, right) }, + '<>'.freeze => ->(cond, left, right) { !cond.send(:equal_variables, left, right) }, + '<'.freeze => :<, + '>'.freeze => :>, + '>='.freeze => :>=, + '<='.freeze => :<=, + 'contains'.freeze => lambda do |cond, left, right| + if left && right && left.respond_to?(:include?) + right = right.to_s if left.is_a?(String) + left.include?(right) + else + false + end + end + } + + def self.operators + @@operators + end + + attr_reader :attachment, :child_condition + attr_accessor :left, :operator, :right + + def initialize(left = nil, operator = nil, right = nil) + @left = left + @operator = operator + @right = right + @child_relation = nil + @child_condition = nil + end + + def evaluate(context = Context.new) + condition = self + result = nil + loop do + result = interpret_condition(condition.left, condition.right, condition.operator, context) + + case condition.child_relation + when :or + break if result + when :and + break unless result + else + break + end + condition = condition.child_condition + end + result + end + + def or(condition) + @child_relation = :or + @child_condition = condition + end + + def and(condition) + @child_relation = :and + @child_condition = condition + end + + def attach(attachment) + @attachment = attachment + end + + def else? + false + end + + def inspect + "#" + end + + protected + + attr_reader :child_relation + + private + + def equal_variables(left, right) + if left.is_a?(Liquid::Expression::MethodLiteral) + if right.respond_to?(left.method_name) + return right.send(left.method_name) + else + return nil + end + end + + if right.is_a?(Liquid::Expression::MethodLiteral) + if left.respond_to?(right.method_name) + return left.send(right.method_name) + else + return nil + end + end + + left == right + end + + def interpret_condition(left, right, op, context) + # If the operator is empty this means that the decision statement is just + # a single variable. We can just poll this variable from the context and + # return this as the result. + return context.evaluate(left) if op.nil? + + left = context.evaluate(left) + right = context.evaluate(right) + + operation = self.class.operators[op] || raise(Liquid::ArgumentError.new("Unknown operator #{op}")) + + if operation.respond_to?(:call) + operation.call(self, left, right) + elsif left.respond_to?(operation) && right.respond_to?(operation) && !left.is_a?(Hash) && !right.is_a?(Hash) + begin + left.send(operation, right) + rescue ::ArgumentError => e + raise Liquid::ArgumentError.new(e.message) + end + end + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [ + @node.left, @node.right, + @node.child_condition, @node.attachment + ].compact + end + end + end + + class ElseCondition < Condition + def else? + true + end + + def evaluate(_context) + true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/context.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/context.rb new file mode 100644 index 0000000..2dcc6af --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/context.rb @@ -0,0 +1,226 @@ +module Liquid + # Context keeps the variable stack and resolves variables, as well as keywords + # + # context['variable'] = 'testing' + # context['variable'] #=> 'testing' + # context['true'] #=> true + # context['10.2232'] #=> 10.2232 + # + # context.stack do + # context['bob'] = 'bobsen' + # end + # + # context['bob'] #=> nil class Context + class Context + attr_reader :scopes, :errors, :registers, :environments, :resource_limits + attr_accessor :exception_renderer, :template_name, :partial, :global_filter, :strict_variables, :strict_filters + + def initialize(environments = {}, outer_scope = {}, registers = {}, rethrow_errors = false, resource_limits = nil) + @environments = [environments].flatten + @scopes = [(outer_scope || {})] + @registers = registers + @errors = [] + @partial = false + @strict_variables = false + @resource_limits = resource_limits || ResourceLimits.new(Template.default_resource_limits) + squash_instance_assigns_with_environments + + @this_stack_used = false + + self.exception_renderer = Template.default_exception_renderer + if rethrow_errors + self.exception_renderer = ->(e) { raise } + end + + @interrupts = [] + @filters = [] + @global_filter = nil + end + + def warnings + @warnings ||= [] + end + + def strainer + @strainer ||= Strainer.create(self, @filters) + end + + # Adds filters to this context. + # + # Note that this does not register the filters with the main Template object. see Template.register_filter + # for that + def add_filters(filters) + filters = [filters].flatten.compact + @filters += filters + @strainer = nil + end + + def apply_global_filter(obj) + global_filter.nil? ? obj : global_filter.call(obj) + end + + # are there any not handled interrupts? + def interrupt? + !@interrupts.empty? + end + + # push an interrupt to the stack. this interrupt is considered not handled. + def push_interrupt(e) + @interrupts.push(e) + end + + # pop an interrupt from the stack + def pop_interrupt + @interrupts.pop + end + + def handle_error(e, line_number = nil) + e = internal_error unless e.is_a?(Liquid::Error) + e.template_name ||= template_name + e.line_number ||= line_number + errors.push(e) + exception_renderer.call(e).to_s + end + + def invoke(method, *args) + strainer.invoke(method, *args).to_liquid + end + + # Push new local scope on the stack. use Context#stack instead + def push(new_scope = {}) + @scopes.unshift(new_scope) + raise StackLevelError, "Nesting too deep".freeze if @scopes.length > Block::MAX_DEPTH + end + + # Merge a hash of variables in the current local scope + def merge(new_scopes) + @scopes[0].merge!(new_scopes) + end + + # Pop from the stack. use Context#stack instead + def pop + raise ContextError if @scopes.size == 1 + @scopes.shift + end + + # Pushes a new local scope on the stack, pops it at the end of the block + # + # Example: + # context.stack do + # context['var'] = 'hi' + # end + # + # context['var] #=> nil + def stack(new_scope = nil) + old_stack_used = @this_stack_used + if new_scope + push(new_scope) + @this_stack_used = true + else + @this_stack_used = false + end + + yield + ensure + pop if @this_stack_used + @this_stack_used = old_stack_used + end + + def clear_instance_assigns + @scopes[0] = {} + end + + # Only allow String, Numeric, Hash, Array, Proc, Boolean or Liquid::Drop + def []=(key, value) + unless @this_stack_used + @this_stack_used = true + push({}) + end + @scopes[0][key] = value + end + + # Look up variable, either resolve directly after considering the name. We can directly handle + # Strings, digits, floats and booleans (true,false). + # If no match is made we lookup the variable in the current scope and + # later move up to the parent blocks to see if we can resolve the variable somewhere up the tree. + # Some special keywords return symbols. Those symbols are to be called on the rhs object in expressions + # + # Example: + # products == empty #=> products.empty? + def [](expression) + evaluate(Expression.parse(expression)) + end + + def key?(key) + self[key] != nil + end + + def evaluate(object) + object.respond_to?(:evaluate) ? object.evaluate(self) : object + end + + # Fetches an object starting at the local scope and then moving up the hierachy + def find_variable(key, raise_on_not_found: true) + # This was changed from find() to find_index() because this is a very hot + # path and find_index() is optimized in MRI to reduce object allocation + index = @scopes.find_index { |s| s.key?(key) } + scope = @scopes[index] if index + + variable = nil + + if scope.nil? + @environments.each do |e| + variable = lookup_and_evaluate(e, key, raise_on_not_found: raise_on_not_found) + # When lookup returned a value OR there is no value but the lookup also did not raise + # then it is the value we are looking for. + if !variable.nil? || @strict_variables && raise_on_not_found + scope = e + break + end + end + end + + scope ||= @environments.last || @scopes.last + variable ||= lookup_and_evaluate(scope, key, raise_on_not_found: raise_on_not_found) + + variable = variable.to_liquid + variable.context = self if variable.respond_to?(:context=) + + variable + end + + def lookup_and_evaluate(obj, key, raise_on_not_found: true) + if @strict_variables && raise_on_not_found && obj.respond_to?(:key?) && !obj.key?(key) + raise Liquid::UndefinedVariable, "undefined variable #{key}" + end + + value = obj[key] + + if value.is_a?(Proc) && obj.respond_to?(:[]=) + obj[key] = (value.arity == 0) ? value.call : value.call(self) + else + value + end + end + + private + + def internal_error + # raise and catch to set backtrace and cause on exception + raise Liquid::InternalError, 'internal' + rescue Liquid::InternalError => exc + exc + end + + def squash_instance_assigns_with_environments + @scopes.last.each_key do |k| + @environments.each do |env| + if env.key?(k) + scopes.last[k] = lookup_and_evaluate(env, k) + break + end + end + end + end # squash_instance_assigns_with_environments + end # Context +end # Liquid diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/document.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/document.rb new file mode 100644 index 0000000..d035dd4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/document.rb @@ -0,0 +1,27 @@ +module Liquid + class Document < BlockBody + def self.parse(tokens, parse_context) + doc = new + doc.parse(tokens, parse_context) + doc + end + + def parse(tokens, parse_context) + super do |end_tag_name, end_tag_params| + unknown_tag(end_tag_name, parse_context) if end_tag_name + end + rescue SyntaxError => e + e.line_number ||= parse_context.line_number + raise + end + + def unknown_tag(tag, parse_context) + case tag + when 'else'.freeze, 'end'.freeze + raise SyntaxError.new(parse_context.locale.t("errors.syntax.unexpected_outer_tag".freeze, tag: tag)) + else + raise SyntaxError.new(parse_context.locale.t("errors.syntax.unknown_tag".freeze, tag: tag)) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/drop.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/drop.rb new file mode 100644 index 0000000..6b5aa99 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/drop.rb @@ -0,0 +1,78 @@ +require 'set' + +module Liquid + # A drop in liquid is a class which allows you to export DOM like things to liquid. + # Methods of drops are callable. + # The main use for liquid drops is to implement lazy loaded objects. + # If you would like to make data available to the web designers which you don't want loaded unless needed then + # a drop is a great way to do that. + # + # Example: + # + # class ProductDrop < Liquid::Drop + # def top_sales + # Shop.current.products.find(:all, :order => 'sales', :limit => 10 ) + # end + # end + # + # tmpl = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {%endfor%} ' ) + # tmpl.render('product' => ProductDrop.new ) # will invoke top_sales query. + # + # Your drop can either implement the methods sans any parameters + # or implement the liquid_method_missing(name) method which is a catch all. + class Drop + attr_writer :context + + # Catch all for the method + def liquid_method_missing(method) + return nil unless @context && @context.strict_variables + raise Liquid::UndefinedDropMethod, "undefined method #{method}" + end + + # called by liquid to invoke a drop + def invoke_drop(method_or_key) + if self.class.invokable?(method_or_key) + send(method_or_key) + else + liquid_method_missing(method_or_key) + end + end + + def key?(_name) + true + end + + def inspect + self.class.to_s + end + + def to_liquid + self + end + + def to_s + self.class.name + end + + alias_method :[], :invoke_drop + + # Check for method existence without invoking respond_to?, which creates symbols + def self.invokable?(method_name) + invokable_methods.include?(method_name.to_s) + end + + def self.invokable_methods + @invokable_methods ||= begin + blacklist = Liquid::Drop.public_instance_methods + [:each] + + if include?(Enumerable) + blacklist += Enumerable.public_instance_methods + blacklist -= [:sort, :count, :first, :min, :max, :include?] + end + + whitelist = [:to_liquid] + (public_instance_methods - blacklist) + Set.new(whitelist.map(&:to_s)) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/errors.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/errors.rb new file mode 100644 index 0000000..defa5ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/errors.rb @@ -0,0 +1,56 @@ +module Liquid + class Error < ::StandardError + attr_accessor :line_number + attr_accessor :template_name + attr_accessor :markup_context + + def to_s(with_prefix = true) + str = "" + str << message_prefix if with_prefix + str << super() + + if markup_context + str << " " + str << markup_context + end + + str + end + + private + + def message_prefix + str = "" + if is_a?(SyntaxError) + str << "Liquid syntax error" + else + str << "Liquid error" + end + + if line_number + str << " (" + str << template_name << " " if template_name + str << "line " << line_number.to_s << ")" + end + + str << ": " + str + end + end + + ArgumentError = Class.new(Error) + ContextError = Class.new(Error) + FileSystemError = Class.new(Error) + StandardError = Class.new(Error) + SyntaxError = Class.new(Error) + StackLevelError = Class.new(Error) + TaintedError = Class.new(Error) + MemoryError = Class.new(Error) + ZeroDivisionError = Class.new(Error) + FloatDomainError = Class.new(Error) + UndefinedVariable = Class.new(Error) + UndefinedDropMethod = Class.new(Error) + UndefinedFilter = Class.new(Error) + MethodOverrideError = Class.new(Error) + InternalError = Class.new(Error) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/expression.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/expression.rb new file mode 100644 index 0000000..98be6db --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/expression.rb @@ -0,0 +1,49 @@ +module Liquid + class Expression + class MethodLiteral + attr_reader :method_name, :to_s + + def initialize(method_name, to_s) + @method_name = method_name + @to_s = to_s + end + + def to_liquid + to_s + end + end + + LITERALS = { + nil => nil, 'nil'.freeze => nil, 'null'.freeze => nil, ''.freeze => nil, + 'true'.freeze => true, + 'false'.freeze => false, + 'blank'.freeze => MethodLiteral.new(:blank?, '').freeze, + 'empty'.freeze => MethodLiteral.new(:empty?, '').freeze + }.freeze + + SINGLE_QUOTED_STRING = /\A'(.*)'\z/m + DOUBLE_QUOTED_STRING = /\A"(.*)"\z/m + INTEGERS_REGEX = /\A(-?\d+)\z/ + FLOATS_REGEX = /\A(-?\d[\d\.]+)\z/ + RANGES_REGEX = /\A\((\S+)\.\.(\S+)\)\z/ + + def self.parse(markup) + if LITERALS.key?(markup) + LITERALS[markup] + else + case markup + when SINGLE_QUOTED_STRING, DOUBLE_QUOTED_STRING + $1 + when INTEGERS_REGEX + $1.to_i + when RANGES_REGEX + RangeLookup.parse($1, $2) + when FLOATS_REGEX + $1.to_f + else + VariableLookup.parse(markup) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/extensions.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/extensions.rb new file mode 100644 index 0000000..0907819 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/extensions.rb @@ -0,0 +1,74 @@ +require 'time' +require 'date' + +class String # :nodoc: + def to_liquid + self + end +end + +class Symbol # :nodoc: + def to_liquid + to_s + end +end + +class Array # :nodoc: + def to_liquid + self + end +end + +class Hash # :nodoc: + def to_liquid + self + end +end + +class Numeric # :nodoc: + def to_liquid + self + end +end + +class Range # :nodoc: + def to_liquid + self + end +end + +class Time # :nodoc: + def to_liquid + self + end +end + +class DateTime < Date # :nodoc: + def to_liquid + self + end +end + +class Date # :nodoc: + def to_liquid + self + end +end + +class TrueClass + def to_liquid # :nodoc: + self + end +end + +class FalseClass + def to_liquid # :nodoc: + self + end +end + +class NilClass + def to_liquid # :nodoc: + self + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/file_system.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/file_system.rb new file mode 100644 index 0000000..13f1f46 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/file_system.rb @@ -0,0 +1,73 @@ +module Liquid + # A Liquid file system is a way to let your templates retrieve other templates for use with the include tag. + # + # You can implement subclasses that retrieve templates from the database, from the file system using a different + # path structure, you can provide them as hard-coded inline strings, or any manner that you see fit. + # + # You can add additional instance variables, arguments, or methods as needed. + # + # Example: + # + # Liquid::Template.file_system = Liquid::LocalFileSystem.new(template_path) + # liquid = Liquid::Template.parse(template) + # + # This will parse the template with a LocalFileSystem implementation rooted at 'template_path'. + class BlankFileSystem + # Called by Liquid to retrieve a template file + def read_template_file(_template_path) + raise FileSystemError, "This liquid context does not allow includes." + end + end + + # This implements an abstract file system which retrieves template files named in a manner similar to Rails partials, + # ie. with the template name prefixed with an underscore. The extension ".liquid" is also added. + # + # For security reasons, template paths are only allowed to contain letters, numbers, and underscore. + # + # Example: + # + # file_system = Liquid::LocalFileSystem.new("/some/path") + # + # file_system.full_path("mypartial") # => "/some/path/_mypartial.liquid" + # file_system.full_path("dir/mypartial") # => "/some/path/dir/_mypartial.liquid" + # + # Optionally in the second argument you can specify a custom pattern for template filenames. + # The Kernel::sprintf format specification is used. + # Default pattern is "_%s.liquid". + # + # Example: + # + # file_system = Liquid::LocalFileSystem.new("/some/path", "%s.html") + # + # file_system.full_path("index") # => "/some/path/index.html" + # + class LocalFileSystem + attr_accessor :root + + def initialize(root, pattern = "_%s.liquid".freeze) + @root = root + @pattern = pattern + end + + def read_template_file(template_path) + full_path = full_path(template_path) + raise FileSystemError, "No such template '#{template_path}'" unless File.exist?(full_path) + + File.read(full_path) + end + + def full_path(template_path) + raise FileSystemError, "Illegal template name '#{template_path}'" unless template_path =~ /\A[^.\/][a-zA-Z0-9_\/]+\z/ + + full_path = if template_path.include?('/'.freeze) + File.join(root, File.dirname(template_path), @pattern % File.basename(template_path)) + else + File.join(root, @pattern % template_path) + end + + raise FileSystemError, "Illegal template path '#{File.expand_path(full_path)}'" unless File.expand_path(full_path).start_with?(File.expand_path(root)) + + full_path + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/forloop_drop.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/forloop_drop.rb new file mode 100644 index 0000000..81b2d1a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/forloop_drop.rb @@ -0,0 +1,42 @@ +module Liquid + class ForloopDrop < Drop + def initialize(name, length, parentloop) + @name = name + @length = length + @parentloop = parentloop + @index = 0 + end + + attr_reader :name, :length, :parentloop + + def index + @index + 1 + end + + def index0 + @index + end + + def rindex + @length - @index + end + + def rindex0 + @length - @index - 1 + end + + def first + @index == 0 + end + + def last + @index == @length - 1 + end + + protected + + def increment! + @index += 1 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/i18n.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/i18n.rb new file mode 100644 index 0000000..2671507 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/i18n.rb @@ -0,0 +1,39 @@ +require 'yaml' + +module Liquid + class I18n + DEFAULT_LOCALE = File.join(File.expand_path(__dir__), "locales", "en.yml") + + TranslationError = Class.new(StandardError) + + attr_reader :path + + def initialize(path = DEFAULT_LOCALE) + @path = path + end + + def translate(name, vars = {}) + interpolate(deep_fetch_translation(name), vars) + end + alias_method :t, :translate + + def locale + @locale ||= YAML.load_file(@path) + end + + private + + def interpolate(name, vars) + name.gsub(/%\{(\w+)\}/) do + # raise TranslationError, "Undefined key #{$1} for interpolation in translation #{name}" unless vars[$1.to_sym] + (vars[$1.to_sym]).to_s + end + end + + def deep_fetch_translation(name) + name.split('.'.freeze).reduce(locale) do |level, cur| + level[cur] or raise TranslationError, "Translation for #{name} does not exist in locale #{path}" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/interrupts.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/interrupts.rb new file mode 100644 index 0000000..41359d7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/interrupts.rb @@ -0,0 +1,16 @@ +module Liquid + # An interrupt is any command that breaks processing of a block (ex: a for loop). + class Interrupt + attr_reader :message + + def initialize(message = nil) + @message = message || "interrupt".freeze + end + end + + # Interrupt that is thrown whenever a {% break %} is called. + class BreakInterrupt < Interrupt; end + + # Interrupt that is thrown whenever a {% continue %} is called. + class ContinueInterrupt < Interrupt; end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/lexer.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/lexer.rb new file mode 100644 index 0000000..f290744 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/lexer.rb @@ -0,0 +1,55 @@ +require "strscan" +module Liquid + class Lexer + SPECIALS = { + '|'.freeze => :pipe, + '.'.freeze => :dot, + ':'.freeze => :colon, + ','.freeze => :comma, + '['.freeze => :open_square, + ']'.freeze => :close_square, + '('.freeze => :open_round, + ')'.freeze => :close_round, + '?'.freeze => :question, + '-'.freeze => :dash + }.freeze + IDENTIFIER = /[a-zA-Z_][\w-]*\??/ + SINGLE_STRING_LITERAL = /'[^\']*'/ + DOUBLE_STRING_LITERAL = /"[^\"]*"/ + NUMBER_LITERAL = /-?\d+(\.\d+)?/ + DOTDOT = /\.\./ + COMPARISON_OPERATOR = /==|!=|<>|<=?|>=?|contains(?=\s)/ + WHITESPACE_OR_NOTHING = /\s*/ + + def initialize(input) + @ss = StringScanner.new(input) + end + + def tokenize + @output = [] + + until @ss.eos? + @ss.skip(WHITESPACE_OR_NOTHING) + break if @ss.eos? + tok = case + when t = @ss.scan(COMPARISON_OPERATOR) then [:comparison, t] + when t = @ss.scan(SINGLE_STRING_LITERAL) then [:string, t] + when t = @ss.scan(DOUBLE_STRING_LITERAL) then [:string, t] + when t = @ss.scan(NUMBER_LITERAL) then [:number, t] + when t = @ss.scan(IDENTIFIER) then [:id, t] + when t = @ss.scan(DOTDOT) then [:dotdot, t] + else + c = @ss.getch + if s = SPECIALS[c] + [s, c] + else + raise SyntaxError, "Unexpected character #{c}" + end + end + @output << tok + end + + @output << [:end_of_string] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/locales/en.yml b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/locales/en.yml new file mode 100644 index 0000000..48b3b1d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/locales/en.yml @@ -0,0 +1,26 @@ +--- + errors: + syntax: + tag_unexpected_args: "Syntax Error in '%{tag}' - Valid syntax: %{tag}" + assign: "Syntax Error in 'assign' - Valid syntax: assign [var] = [source]" + capture: "Syntax Error in 'capture' - Valid syntax: capture [var]" + case: "Syntax Error in 'case' - Valid syntax: case [condition]" + case_invalid_when: "Syntax Error in tag 'case' - Valid when condition: {% when [condition] [or condition2...] %}" + case_invalid_else: "Syntax Error in tag 'case' - Valid else condition: {% else %} (no parameters) " + cycle: "Syntax Error in 'cycle' - Valid syntax: cycle [name :] var [, var2, var3 ...]" + for: "Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]" + for_invalid_in: "For loops require an 'in' clause" + for_invalid_attribute: "Invalid attribute in for loop. Valid attributes are limit and offset" + if: "Syntax Error in tag 'if' - Valid syntax: if [expression]" + include: "Error in tag 'include' - Valid syntax: include '[template]' (with|for) [object|collection]" + unknown_tag: "Unknown tag '%{tag}'" + invalid_delimiter: "'%{tag}' is not a valid delimiter for %{block_name} tags. use %{block_delimiter}" + unexpected_else: "%{block_name} tag does not expect 'else' tag" + unexpected_outer_tag: "Unexpected outer '%{tag}' tag" + tag_termination: "Tag '%{token}' was not properly terminated with regexp: %{tag_end}" + variable_termination: "Variable '%{token}' was not properly terminated with regexp: %{tag_end}" + tag_never_closed: "'%{block_name}' tag was never closed" + meta_syntax_error: "Liquid syntax error: #{e.message}" + table_row: "Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3" + argument: + include: "Argument error in tag 'include' - Illegal template name" diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parse_context.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parse_context.rb new file mode 100644 index 0000000..abcdaeb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parse_context.rb @@ -0,0 +1,38 @@ +module Liquid + class ParseContext + attr_accessor :locale, :line_number, :trim_whitespace, :depth + attr_reader :partial, :warnings, :error_mode + + def initialize(options = {}) + @template_options = options ? options.dup : {} + @locale = @template_options[:locale] ||= I18n.new + @warnings = [] + self.depth = 0 + self.partial = false + end + + def [](option_key) + @options[option_key] + end + + def partial=(value) + @partial = value + @options = value ? partial_options : @template_options + @error_mode = @options[:error_mode] || Template.error_mode + value + end + + def partial_options + @partial_options ||= begin + dont_pass = @template_options[:include_options_blacklist] + if dont_pass == true + { locale: locale } + elsif dont_pass.is_a?(Array) + @template_options.reject { |k, v| dont_pass.include?(k) } + else + @template_options + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parse_tree_visitor.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parse_tree_visitor.rb new file mode 100644 index 0000000..74f5563 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parse_tree_visitor.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Liquid + class ParseTreeVisitor + def self.for(node, callbacks = Hash.new(proc {})) + if defined?(node.class::ParseTreeVisitor) + node.class::ParseTreeVisitor + else + self + end.new(node, callbacks) + end + + def initialize(node, callbacks) + @node = node + @callbacks = callbacks + end + + def add_callback_for(*classes, &block) + callback = block + callback = ->(node, _) { yield node } if block.arity.abs == 1 + callback = ->(_, _) { yield } if block.arity.zero? + classes.each { |klass| @callbacks[klass] = callback } + self + end + + def visit(context = nil) + children.map do |node| + item, new_context = @callbacks[node.class].call(node, context) + [ + item, + ParseTreeVisitor.for(node, @callbacks).visit(new_context || context) + ] + end + end + + protected + + def children + @node.respond_to?(:nodelist) ? Array(@node.nodelist) : [] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parser.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parser.rb new file mode 100644 index 0000000..6954343 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parser.rb @@ -0,0 +1,90 @@ +module Liquid + class Parser + def initialize(input) + l = Lexer.new(input) + @tokens = l.tokenize + @p = 0 # pointer to current location + end + + def jump(point) + @p = point + end + + def consume(type = nil) + token = @tokens[@p] + if type && token[0] != type + raise SyntaxError, "Expected #{type} but found #{@tokens[@p].first}" + end + @p += 1 + token[1] + end + + # Only consumes the token if it matches the type + # Returns the token's contents if it was consumed + # or false otherwise. + def consume?(type) + token = @tokens[@p] + return false unless token && token[0] == type + @p += 1 + token[1] + end + + # Like consume? Except for an :id token of a certain name + def id?(str) + token = @tokens[@p] + return false unless token && token[0] == :id + return false unless token[1] == str + @p += 1 + token[1] + end + + def look(type, ahead = 0) + tok = @tokens[@p + ahead] + return false unless tok + tok[0] == type + end + + def expression + token = @tokens[@p] + if token[0] == :id + variable_signature + elsif [:string, :number].include? token[0] + consume + elsif token.first == :open_round + consume + first = expression + consume(:dotdot) + last = expression + consume(:close_round) + "(#{first}..#{last})" + else + raise SyntaxError, "#{token} is not a valid expression" + end + end + + def argument + str = "" + # might be a keyword argument (identifier: expression) + if look(:id) && look(:colon, 1) + str << consume << consume << ' '.freeze + end + + str << expression + str + end + + def variable_signature + str = consume(:id) + while look(:open_square) + str << consume + str << expression + str << consume(:close_square) + end + if look(:dot) + str << consume + str << variable_signature + end + str + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parser_switching.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parser_switching.rb new file mode 100644 index 0000000..3aa664a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/parser_switching.rb @@ -0,0 +1,31 @@ +module Liquid + module ParserSwitching + def parse_with_selected_parser(markup) + case parse_context.error_mode + when :strict then strict_parse_with_error_context(markup) + when :lax then lax_parse(markup) + when :warn + begin + return strict_parse_with_error_context(markup) + rescue SyntaxError => e + parse_context.warnings << e + return lax_parse(markup) + end + end + end + + private + + def strict_parse_with_error_context(markup) + strict_parse(markup) + rescue SyntaxError => e + e.line_number = line_number + e.markup_context = markup_context(markup) + raise e + end + + def markup_context(markup) + "in \"#{markup.strip}\"" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/profiler.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/profiler.rb new file mode 100644 index 0000000..dc9db60 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/profiler.rb @@ -0,0 +1,158 @@ +require 'liquid/profiler/hooks' + +module Liquid + # Profiler enables support for profiling template rendering to help track down performance issues. + # + # To enable profiling, first require 'liquid/profiler'. + # Then, to profile a parse/render cycle, pass the profile: true option to Liquid::Template.parse. + # After Liquid::Template#render is called, the template object makes available an instance of this + # class via the Liquid::Template#profiler method. + # + # template = Liquid::Template.parse(template_content, profile: true) + # output = template.render + # profile = template.profiler + # + # This object contains all profiling information, containing information on what tags were rendered, + # where in the templates these tags live, and how long each tag took to render. + # + # This is a tree structure that is Enumerable all the way down, and keeps track of tags and rendering times + # inside of {% include %} tags. + # + # profile.each do |node| + # # Access to the node itself + # node.code + # + # # Which template and line number of this node. + # # If top level, this will be "". + # node.partial + # node.line_number + # + # # Render time in seconds of this node + # node.render_time + # + # # If the template used {% include %}, this node will also have children. + # node.children.each do |child2| + # # ... + # end + # end + # + # Profiler also exposes the total time of the template's render in Liquid::Profiler#total_render_time. + # + # All render times are in seconds. There is a small performance hit when profiling is enabled. + # + class Profiler + include Enumerable + + class Timing + attr_reader :code, :partial, :line_number, :children + + def initialize(node, partial) + @code = node.respond_to?(:raw) ? node.raw : node + @partial = partial + @line_number = node.respond_to?(:line_number) ? node.line_number : nil + @children = [] + end + + def self.start(node, partial) + new(node, partial).tap(&:start) + end + + def start + @start_time = Time.now + end + + def finish + @end_time = Time.now + end + + def render_time + @end_time - @start_time + end + end + + def self.profile_node_render(node) + if Profiler.current_profile && node.respond_to?(:render) + Profiler.current_profile.start_node(node) + output = yield + Profiler.current_profile.end_node(node) + output + else + yield + end + end + + def self.profile_children(template_name) + if Profiler.current_profile + Profiler.current_profile.push_partial(template_name) + output = yield + Profiler.current_profile.pop_partial + output + else + yield + end + end + + def self.current_profile + Thread.current[:liquid_profiler] + end + + def initialize + @partial_stack = [""] + + @root_timing = Timing.new("", current_partial) + @timing_stack = [@root_timing] + + @render_start_at = Time.now + @render_end_at = @render_start_at + end + + def start + Thread.current[:liquid_profiler] = self + @render_start_at = Time.now + end + + def stop + Thread.current[:liquid_profiler] = nil + @render_end_at = Time.now + end + + def total_render_time + @render_end_at - @render_start_at + end + + def each(&block) + @root_timing.children.each(&block) + end + + def [](idx) + @root_timing.children[idx] + end + + def length + @root_timing.children.length + end + + def start_node(node) + @timing_stack.push(Timing.start(node, current_partial)) + end + + def end_node(_node) + timing = @timing_stack.pop + timing.finish + + @timing_stack.last.children << timing + end + + def current_partial + @partial_stack.last + end + + def push_partial(partial_name) + @partial_stack.push(partial_name) + end + + def pop_partial + @partial_stack.pop + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/profiler/hooks.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/profiler/hooks.rb new file mode 100644 index 0000000..cb11cd7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/profiler/hooks.rb @@ -0,0 +1,23 @@ +module Liquid + class BlockBody + def render_node_with_profiling(node, output, context, skip_output = false) + Profiler.profile_node_render(node) do + render_node_without_profiling(node, output, context, skip_output) + end + end + + alias_method :render_node_without_profiling, :render_node_to_output + alias_method :render_node_to_output, :render_node_with_profiling + end + + class Include < Tag + def render_with_profiling(context) + Profiler.profile_children(context.evaluate(@template_name_expr).to_s) do + render_without_profiling(context) + end + end + + alias_method :render_without_profiling, :render + alias_method :render, :render_with_profiling + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/range_lookup.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/range_lookup.rb new file mode 100644 index 0000000..93bb420 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/range_lookup.rb @@ -0,0 +1,37 @@ +module Liquid + class RangeLookup + def self.parse(start_markup, end_markup) + start_obj = Expression.parse(start_markup) + end_obj = Expression.parse(end_markup) + if start_obj.respond_to?(:evaluate) || end_obj.respond_to?(:evaluate) + new(start_obj, end_obj) + else + start_obj.to_i..end_obj.to_i + end + end + + def initialize(start_obj, end_obj) + @start_obj = start_obj + @end_obj = end_obj + end + + def evaluate(context) + start_int = to_integer(context.evaluate(@start_obj)) + end_int = to_integer(context.evaluate(@end_obj)) + start_int..end_int + end + + private + + def to_integer(input) + case input + when Integer + input + when NilClass, String + input.to_i + else + Utils.to_integer(input) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/resource_limits.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/resource_limits.rb new file mode 100644 index 0000000..08b359b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/resource_limits.rb @@ -0,0 +1,23 @@ +module Liquid + class ResourceLimits + attr_accessor :render_length, :render_score, :assign_score, + :render_length_limit, :render_score_limit, :assign_score_limit + + def initialize(limits) + @render_length_limit = limits[:render_length_limit] + @render_score_limit = limits[:render_score_limit] + @assign_score_limit = limits[:assign_score_limit] + reset + end + + def reached? + (@render_length_limit && @render_length > @render_length_limit) || + (@render_score_limit && @render_score > @render_score_limit) || + (@assign_score_limit && @assign_score > @assign_score_limit) + end + + def reset + @render_length = @render_score = @assign_score = 0 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb new file mode 100644 index 0000000..fffee4d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb @@ -0,0 +1,506 @@ +require 'cgi' +require 'bigdecimal' + +module Liquid + module StandardFilters + HTML_ESCAPE = { + '&'.freeze => '&'.freeze, + '>'.freeze => '>'.freeze, + '<'.freeze => '<'.freeze, + '"'.freeze => '"'.freeze, + "'".freeze => '''.freeze + }.freeze + HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+));)/ + STRIP_HTML_BLOCKS = Regexp.union( + //m, + //m, + //m + ) + STRIP_HTML_TAGS = /<.*?>/m + + # Return the size of an array or of an string + def size(input) + input.respond_to?(:size) ? input.size : 0 + end + + # convert an input string to DOWNCASE + def downcase(input) + input.to_s.downcase + end + + # convert an input string to UPCASE + def upcase(input) + input.to_s.upcase + end + + # capitalize words in the input centence + def capitalize(input) + input.to_s.capitalize + end + + def escape(input) + CGI.escapeHTML(input.to_s) unless input.nil? + end + alias_method :h, :escape + + def escape_once(input) + input.to_s.gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE) + end + + def url_encode(input) + CGI.escape(input.to_s) unless input.nil? + end + + def url_decode(input) + return if input.nil? + + result = CGI.unescape(input.to_s) + raise Liquid::ArgumentError, "invalid byte sequence in #{result.encoding}" unless result.valid_encoding? + + result + end + + def slice(input, offset, length = nil) + offset = Utils.to_integer(offset) + length = length ? Utils.to_integer(length) : 1 + + if input.is_a?(Array) + input.slice(offset, length) || [] + else + input.to_s.slice(offset, length) || '' + end + end + + # Truncate a string down to x characters + def truncate(input, length = 50, truncate_string = "...".freeze) + return if input.nil? + input_str = input.to_s + length = Utils.to_integer(length) + truncate_string_str = truncate_string.to_s + l = length - truncate_string_str.length + l = 0 if l < 0 + input_str.length > length ? input_str[0...l] + truncate_string_str : input_str + end + + def truncatewords(input, words = 15, truncate_string = "...".freeze) + return if input.nil? + wordlist = input.to_s.split + words = Utils.to_integer(words) + l = words - 1 + l = 0 if l < 0 + wordlist.length > l ? wordlist[0..l].join(" ".freeze) + truncate_string.to_s : input + end + + # Split input string into an array of substrings separated by given pattern. + # + # Example: + #
{{ post | split '//' | first }}
+ # + def split(input, pattern) + input.to_s.split(pattern.to_s) + end + + def strip(input) + input.to_s.strip + end + + def lstrip(input) + input.to_s.lstrip + end + + def rstrip(input) + input.to_s.rstrip + end + + def strip_html(input) + empty = ''.freeze + result = input.to_s.gsub(STRIP_HTML_BLOCKS, empty) + result.gsub!(STRIP_HTML_TAGS, empty) + result + end + + # Remove all newlines from the string + def strip_newlines(input) + input.to_s.gsub(/\r?\n/, ''.freeze) + end + + # Join elements of the array with certain character between them + def join(input, glue = ' '.freeze) + InputIterator.new(input).join(glue) + end + + # Sort elements of the array + # provide optional property with which to sort an array of hashes or drops + def sort(input, property = nil) + ary = InputIterator.new(input) + + return [] if ary.empty? + + if property.nil? + ary.sort do |a, b| + nil_safe_compare(a, b) + end + elsif ary.all? { |el| el.respond_to?(:[]) } + begin + ary.sort { |a, b| nil_safe_compare(a[property], b[property]) } + rescue TypeError + raise_property_error(property) + end + end + end + + # Sort elements of an array ignoring case if strings + # provide optional property with which to sort an array of hashes or drops + def sort_natural(input, property = nil) + ary = InputIterator.new(input) + + return [] if ary.empty? + + if property.nil? + ary.sort do |a, b| + nil_safe_casecmp(a, b) + end + elsif ary.all? { |el| el.respond_to?(:[]) } + begin + ary.sort { |a, b| nil_safe_casecmp(a[property], b[property]) } + rescue TypeError + raise_property_error(property) + end + end + end + + # Filter the elements of an array to those with a certain property value. + # By default the target is any truthy value. + def where(input, property, target_value = nil) + ary = InputIterator.new(input) + + if ary.empty? + [] + elsif ary.first.respond_to?(:[]) && target_value.nil? + begin + ary.select { |item| item[property] } + rescue TypeError + raise_property_error(property) + end + elsif ary.first.respond_to?(:[]) + begin + ary.select { |item| item[property] == target_value } + rescue TypeError + raise_property_error(property) + end + end + end + + # Remove duplicate elements from an array + # provide optional property with which to determine uniqueness + def uniq(input, property = nil) + ary = InputIterator.new(input) + + if property.nil? + ary.uniq + elsif ary.empty? # The next two cases assume a non-empty array. + [] + elsif ary.first.respond_to?(:[]) + begin + ary.uniq { |a| a[property] } + rescue TypeError + raise_property_error(property) + end + end + end + + # Reverse the elements of an array + def reverse(input) + ary = InputIterator.new(input) + ary.reverse + end + + # map/collect on a given property + def map(input, property) + InputIterator.new(input).map do |e| + e = e.call if e.is_a?(Proc) + + if property == "to_liquid".freeze + e + elsif e.respond_to?(:[]) + r = e[property] + r.is_a?(Proc) ? r.call : r + end + end + rescue TypeError + raise_property_error(property) + end + + # Remove nils within an array + # provide optional property with which to check for nil + def compact(input, property = nil) + ary = InputIterator.new(input) + + if property.nil? + ary.compact + elsif ary.empty? # The next two cases assume a non-empty array. + [] + elsif ary.first.respond_to?(:[]) + begin + ary.reject { |a| a[property].nil? } + rescue TypeError + raise_property_error(property) + end + end + end + + # Replace occurrences of a string with another + def replace(input, string, replacement = ''.freeze) + input.to_s.gsub(string.to_s, replacement.to_s) + end + + # Replace the first occurrences of a string with another + def replace_first(input, string, replacement = ''.freeze) + input.to_s.sub(string.to_s, replacement.to_s) + end + + # remove a substring + def remove(input, string) + input.to_s.gsub(string.to_s, ''.freeze) + end + + # remove the first occurrences of a substring + def remove_first(input, string) + input.to_s.sub(string.to_s, ''.freeze) + end + + # add one string to another + def append(input, string) + input.to_s + string.to_s + end + + def concat(input, array) + unless array.respond_to?(:to_ary) + raise ArgumentError.new("concat filter requires an array argument") + end + InputIterator.new(input).concat(array) + end + + # prepend a string to another + def prepend(input, string) + string.to_s + input.to_s + end + + # Add
tags in front of all newlines in input string + def newline_to_br(input) + input.to_s.gsub(/\n/, "
\n".freeze) + end + + # Reformat a date using Ruby's core Time#strftime( string ) -> string + # + # %a - The abbreviated weekday name (``Sun'') + # %A - The full weekday name (``Sunday'') + # %b - The abbreviated month name (``Jan'') + # %B - The full month name (``January'') + # %c - The preferred local date and time representation + # %d - Day of the month (01..31) + # %H - Hour of the day, 24-hour clock (00..23) + # %I - Hour of the day, 12-hour clock (01..12) + # %j - Day of the year (001..366) + # %m - Month of the year (01..12) + # %M - Minute of the hour (00..59) + # %p - Meridian indicator (``AM'' or ``PM'') + # %s - Number of seconds since 1970-01-01 00:00:00 UTC. + # %S - Second of the minute (00..60) + # %U - Week number of the current year, + # starting with the first Sunday as the first + # day of the first week (00..53) + # %W - Week number of the current year, + # starting with the first Monday as the first + # day of the first week (00..53) + # %w - Day of the week (Sunday is 0, 0..6) + # %x - Preferred representation for the date alone, no time + # %X - Preferred representation for the time alone, no date + # %y - Year without a century (00..99) + # %Y - Year with century + # %Z - Time zone name + # %% - Literal ``%'' character + # + # See also: http://www.ruby-doc.org/core/Time.html#method-i-strftime + def date(input, format) + return input if format.to_s.empty? + + return input unless date = Utils.to_date(input) + + date.strftime(format.to_s) + end + + # Get the first element of the passed in array + # + # Example: + # {{ product.images | first | to_img }} + # + def first(array) + array.first if array.respond_to?(:first) + end + + # Get the last element of the passed in array + # + # Example: + # {{ product.images | last | to_img }} + # + def last(array) + array.last if array.respond_to?(:last) + end + + # absolute value + def abs(input) + result = Utils.to_number(input).abs + result.is_a?(BigDecimal) ? result.to_f : result + end + + # addition + def plus(input, operand) + apply_operation(input, operand, :+) + end + + # subtraction + def minus(input, operand) + apply_operation(input, operand, :-) + end + + # multiplication + def times(input, operand) + apply_operation(input, operand, :*) + end + + # division + def divided_by(input, operand) + apply_operation(input, operand, :/) + rescue ::ZeroDivisionError => e + raise Liquid::ZeroDivisionError, e.message + end + + def modulo(input, operand) + apply_operation(input, operand, :%) + rescue ::ZeroDivisionError => e + raise Liquid::ZeroDivisionError, e.message + end + + def round(input, n = 0) + result = Utils.to_number(input).round(Utils.to_number(n)) + result = result.to_f if result.is_a?(BigDecimal) + result = result.to_i if n == 0 + result + rescue ::FloatDomainError => e + raise Liquid::FloatDomainError, e.message + end + + def ceil(input) + Utils.to_number(input).ceil.to_i + rescue ::FloatDomainError => e + raise Liquid::FloatDomainError, e.message + end + + def floor(input) + Utils.to_number(input).floor.to_i + rescue ::FloatDomainError => e + raise Liquid::FloatDomainError, e.message + end + + def at_least(input, n) + min_value = Utils.to_number(n) + + result = Utils.to_number(input) + result = min_value if min_value > result + result.is_a?(BigDecimal) ? result.to_f : result + end + + def at_most(input, n) + max_value = Utils.to_number(n) + + result = Utils.to_number(input) + result = max_value if max_value < result + result.is_a?(BigDecimal) ? result.to_f : result + end + + def default(input, default_value = ''.freeze) + if !input || input.respond_to?(:empty?) && input.empty? + default_value + else + input + end + end + + private + + def raise_property_error(property) + raise Liquid::ArgumentError.new("cannot select the property '#{property}'") + end + + def apply_operation(input, operand, operation) + result = Utils.to_number(input).send(operation, Utils.to_number(operand)) + result.is_a?(BigDecimal) ? result.to_f : result + end + + def nil_safe_compare(a, b) + if !a.nil? && !b.nil? + a <=> b + else + a.nil? ? 1 : -1 + end + end + + def nil_safe_casecmp(a, b) + if !a.nil? && !b.nil? + a.to_s.casecmp(b.to_s) + else + a.nil? ? 1 : -1 + end + end + + class InputIterator + include Enumerable + + def initialize(input) + @input = if input.is_a?(Array) + input.flatten + elsif input.is_a?(Hash) + [input] + elsif input.is_a?(Enumerable) + input + else + Array(input) + end + end + + def join(glue) + to_a.join(glue.to_s) + end + + def concat(args) + to_a.concat(args) + end + + def reverse + reverse_each.to_a + end + + def uniq(&block) + to_a.uniq(&block) + end + + def compact + to_a.compact + end + + def empty? + @input.each { return false } + true + end + + def each + @input.each do |e| + yield(e.respond_to?(:to_liquid) ? e.to_liquid : e) + end + end + end + end + + Template.register_filter(StandardFilters) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/strainer.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/strainer.rb new file mode 100644 index 0000000..76d56d2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/strainer.rb @@ -0,0 +1,66 @@ +require 'set' + +module Liquid + # Strainer is the parent class for the filters system. + # New filters are mixed into the strainer class which is then instantiated for each liquid template render run. + # + # The Strainer only allows method calls defined in filters given to it via Strainer.global_filter, + # Context#add_filters or Template.register_filter + class Strainer #:nodoc: + @@global_strainer = Class.new(Strainer) do + @filter_methods = Set.new + end + @@strainer_class_cache = Hash.new do |hash, filters| + hash[filters] = Class.new(@@global_strainer) do + @filter_methods = @@global_strainer.filter_methods.dup + filters.each { |f| add_filter(f) } + end + end + + def initialize(context) + @context = context + end + + class << self + attr_reader :filter_methods + end + + def self.add_filter(filter) + raise ArgumentError, "Expected module but got: #{filter.class}" unless filter.is_a?(Module) + unless self.include?(filter) + invokable_non_public_methods = (filter.private_instance_methods + filter.protected_instance_methods).select { |m| invokable?(m) } + if invokable_non_public_methods.any? + raise MethodOverrideError, "Filter overrides registered public methods as non public: #{invokable_non_public_methods.join(', ')}" + else + send(:include, filter) + @filter_methods.merge(filter.public_instance_methods.map(&:to_s)) + end + end + end + + def self.global_filter(filter) + @@strainer_class_cache.clear + @@global_strainer.add_filter(filter) + end + + def self.invokable?(method) + @filter_methods.include?(method.to_s) + end + + def self.create(context, filters = []) + @@strainer_class_cache[filters].new(context) + end + + def invoke(method, *args) + if self.class.invokable?(method) + send(method, *args) + elsif @context && @context.strict_filters + raise Liquid::UndefinedFilter, "undefined filter #{method}" + else + args.first + end + rescue ::ArgumentError => e + raise Liquid::ArgumentError, e.message, e.backtrace + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tablerowloop_drop.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tablerowloop_drop.rb new file mode 100644 index 0000000..cda4a1e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tablerowloop_drop.rb @@ -0,0 +1,62 @@ +module Liquid + class TablerowloopDrop < Drop + def initialize(length, cols) + @length = length + @row = 1 + @col = 1 + @cols = cols + @index = 0 + end + + attr_reader :length, :col, :row + + def index + @index + 1 + end + + def index0 + @index + end + + def col0 + @col - 1 + end + + def rindex + @length - @index + end + + def rindex0 + @length - @index - 1 + end + + def first + @index == 0 + end + + def last + @index == @length - 1 + end + + def col_first + @col == 1 + end + + def col_last + @col == @cols + end + + protected + + def increment! + @index += 1 + + if @col == @cols + @col = 1 + @row += 1 + else + @col += 1 + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tag.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tag.rb new file mode 100644 index 0000000..06970c1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tag.rb @@ -0,0 +1,43 @@ +module Liquid + class Tag + attr_reader :nodelist, :tag_name, :line_number, :parse_context + alias_method :options, :parse_context + include ParserSwitching + + class << self + def parse(tag_name, markup, tokenizer, options) + tag = new(tag_name, markup, options) + tag.parse(tokenizer) + tag + end + + private :new + end + + def initialize(tag_name, markup, parse_context) + @tag_name = tag_name + @markup = markup + @parse_context = parse_context + @line_number = parse_context.line_number + end + + def parse(_tokens) + end + + def raw + "#{@tag_name} #{@markup}" + end + + def name + self.class.name.downcase + end + + def render(_context) + ''.freeze + end + + def blank? + false + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/assign.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/assign.rb new file mode 100644 index 0000000..c8d0574 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/assign.rb @@ -0,0 +1,59 @@ +module Liquid + # Assign sets a variable in your template. + # + # {% assign foo = 'monkey' %} + # + # You can then use the variable later in the page. + # + # {{ foo }} + # + class Assign < Tag + Syntax = /(#{VariableSignature}+)\s*=\s*(.*)\s*/om + + attr_reader :to, :from + + def initialize(tag_name, markup, options) + super + if markup =~ Syntax + @to = $1 + @from = Variable.new($2, options) + else + raise SyntaxError.new options[:locale].t("errors.syntax.assign".freeze) + end + end + + def render(context) + val = @from.render(context) + context.scopes.last[@to] = val + context.resource_limits.assign_score += assign_score_of(val) + ''.freeze + end + + def blank? + true + end + + private + + def assign_score_of(val) + if val.instance_of?(String) + val.length + elsif val.instance_of?(Array) || val.instance_of?(Hash) + sum = 1 + # Uses #each to avoid extra allocations. + val.each { |child| sum += assign_score_of(child) } + sum + else + 1 + end + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [@node.from] + end + end + end + + Template.register_tag('assign'.freeze, Assign) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/break.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/break.rb new file mode 100644 index 0000000..6fe0969 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/break.rb @@ -0,0 +1,18 @@ +module Liquid + # Break tag to be used to break out of a for loop. + # + # == Basic Usage: + # {% for item in collection %} + # {% if item.condition %} + # {% break %} + # {% endif %} + # {% endfor %} + # + class Break < Tag + def interrupt + BreakInterrupt.new + end + end + + Template.register_tag('break'.freeze, Break) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/capture.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/capture.rb new file mode 100644 index 0000000..8674356 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/capture.rb @@ -0,0 +1,38 @@ +module Liquid + # Capture stores the result of a block into a variable without rendering it inplace. + # + # {% capture heading %} + # Monkeys! + # {% endcapture %} + # ... + #

{{ heading }}

+ # + # Capture is useful for saving content for use later in your template, such as + # in a sidebar or footer. + # + class Capture < Block + Syntax = /(#{VariableSignature}+)/o + + def initialize(tag_name, markup, options) + super + if markup =~ Syntax + @to = $1 + else + raise SyntaxError.new(options[:locale].t("errors.syntax.capture")) + end + end + + def render(context) + output = super + context.scopes.last[@to] = output + context.resource_limits.assign_score += output.length + ''.freeze + end + + def blank? + true + end + end + + Template.register_tag('capture'.freeze, Capture) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/case.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/case.rb new file mode 100644 index 0000000..5036b27 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/case.rb @@ -0,0 +1,94 @@ +module Liquid + class Case < Block + Syntax = /(#{QuotedFragment})/o + WhenSyntax = /(#{QuotedFragment})(?:(?:\s+or\s+|\s*\,\s*)(#{QuotedFragment}.*))?/om + + attr_reader :blocks, :left + + def initialize(tag_name, markup, options) + super + @blocks = [] + + if markup =~ Syntax + @left = Expression.parse($1) + else + raise SyntaxError.new(options[:locale].t("errors.syntax.case".freeze)) + end + end + + def parse(tokens) + body = BlockBody.new + while parse_body(body, tokens) + body = @blocks.last.attachment + end + end + + def nodelist + @blocks.map(&:attachment) + end + + def unknown_tag(tag, markup, tokens) + case tag + when 'when'.freeze + record_when_condition(markup) + when 'else'.freeze + record_else_condition(markup) + else + super + end + end + + def render(context) + context.stack do + execute_else_block = true + + output = '' + @blocks.each do |block| + if block.else? + return block.attachment.render(context) if execute_else_block + elsif block.evaluate(context) + execute_else_block = false + output << block.attachment.render(context) + end + end + output + end + end + + private + + def record_when_condition(markup) + body = BlockBody.new + + while markup + unless markup =~ WhenSyntax + raise SyntaxError.new(options[:locale].t("errors.syntax.case_invalid_when".freeze)) + end + + markup = $2 + + block = Condition.new(@left, '=='.freeze, Expression.parse($1)) + block.attach(body) + @blocks << block + end + end + + def record_else_condition(markup) + unless markup.strip.empty? + raise SyntaxError.new(options[:locale].t("errors.syntax.case_invalid_else".freeze)) + end + + block = ElseCondition.new + block.attach(BlockBody.new) + @blocks << block + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [@node.left] + @node.blocks + end + end + end + + Template.register_tag('case'.freeze, Case) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/comment.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/comment.rb new file mode 100644 index 0000000..c57c9cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/comment.rb @@ -0,0 +1,16 @@ +module Liquid + class Comment < Block + def render(_context) + ''.freeze + end + + def unknown_tag(_tag, _markup, _tokens) + end + + def blank? + true + end + end + + Template.register_tag('comment'.freeze, Comment) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/continue.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/continue.rb new file mode 100644 index 0000000..9c81ec2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/continue.rb @@ -0,0 +1,18 @@ +module Liquid + # Continue tag to be used to break out of a for loop. + # + # == Basic Usage: + # {% for item in collection %} + # {% if item.condition %} + # {% continue %} + # {% endif %} + # {% endfor %} + # + class Continue < Tag + def interrupt + ContinueInterrupt.new + end + end + + Template.register_tag('continue'.freeze, Continue) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/cycle.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/cycle.rb new file mode 100644 index 0000000..17aa860 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/cycle.rb @@ -0,0 +1,65 @@ +module Liquid + # Cycle is usually used within a loop to alternate between values, like colors or DOM classes. + # + # {% for item in items %} + #
{{ item }}
+ # {% end %} + # + #
Item one
+ #
Item two
+ #
Item three
+ #
Item four
+ #
Item five
+ # + class Cycle < Tag + SimpleSyntax = /\A#{QuotedFragment}+/o + NamedSyntax = /\A(#{QuotedFragment})\s*\:\s*(.*)/om + + attr_reader :variables + + def initialize(tag_name, markup, options) + super + case markup + when NamedSyntax + @variables = variables_from_string($2) + @name = Expression.parse($1) + when SimpleSyntax + @variables = variables_from_string(markup) + @name = @variables.to_s + else + raise SyntaxError.new(options[:locale].t("errors.syntax.cycle".freeze)) + end + end + + def render(context) + context.registers[:cycle] ||= {} + + context.stack do + key = context.evaluate(@name) + iteration = context.registers[:cycle][key].to_i + result = context.evaluate(@variables[iteration]) + iteration += 1 + iteration = 0 if iteration >= @variables.size + context.registers[:cycle][key] = iteration + result + end + end + + private + + def variables_from_string(markup) + markup.split(',').collect do |var| + var =~ /\s*(#{QuotedFragment})\s*/o + $1 ? Expression.parse($1) : nil + end.compact + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + Array(@node.variables) + end + end + end + + Template.register_tag('cycle', Cycle) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/decrement.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/decrement.rb new file mode 100644 index 0000000..b5cdaaa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/decrement.rb @@ -0,0 +1,35 @@ +module Liquid + # decrement is used in a place where one needs to insert a counter + # into a template, and needs the counter to survive across + # multiple instantiations of the template. + # NOTE: decrement is a pre-decrement, --i, + # while increment is post: i++. + # + # (To achieve the survival, the application must keep the context) + # + # if the variable does not exist, it is created with value 0. + + # Hello: {% decrement variable %} + # + # gives you: + # + # Hello: -1 + # Hello: -2 + # Hello: -3 + # + class Decrement < Tag + def initialize(tag_name, markup, options) + super + @variable = markup.strip + end + + def render(context) + value = context.environments.first[@variable] ||= 0 + value -= 1 + context.environments.first[@variable] = value + value.to_s + end + end + + Template.register_tag('decrement'.freeze, Decrement) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/for.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/for.rb new file mode 100644 index 0000000..b69aa78 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/for.rb @@ -0,0 +1,203 @@ +module Liquid + # "For" iterates over an array or collection. + # Several useful variables are available to you within the loop. + # + # == Basic usage: + # {% for item in collection %} + # {{ forloop.index }}: {{ item.name }} + # {% endfor %} + # + # == Advanced usage: + # {% for item in collection %} + #
+ # Item {{ forloop.index }}: {{ item.name }} + #
+ # {% else %} + # There is nothing in the collection. + # {% endfor %} + # + # You can also define a limit and offset much like SQL. Remember + # that offset starts at 0 for the first item. + # + # {% for item in collection limit:5 offset:10 %} + # {{ item.name }} + # {% end %} + # + # To reverse the for loop simply use {% for item in collection reversed %} (note that the flag's spelling is different to the filter `reverse`) + # + # == Available variables: + # + # forloop.name:: 'item-collection' + # forloop.length:: Length of the loop + # forloop.index:: The current item's position in the collection; + # forloop.index starts at 1. + # This is helpful for non-programmers who start believe + # the first item in an array is 1, not 0. + # forloop.index0:: The current item's position in the collection + # where the first item is 0 + # forloop.rindex:: Number of items remaining in the loop + # (length - index) where 1 is the last item. + # forloop.rindex0:: Number of items remaining in the loop + # where 0 is the last item. + # forloop.first:: Returns true if the item is the first item. + # forloop.last:: Returns true if the item is the last item. + # forloop.parentloop:: Provides access to the parent loop, if present. + # + class For < Block + Syntax = /\A(#{VariableSegment}+)\s+in\s+(#{QuotedFragment}+)\s*(reversed)?/o + + attr_reader :collection_name, :variable_name, :limit, :from + + def initialize(tag_name, markup, options) + super + @from = @limit = nil + parse_with_selected_parser(markup) + @for_block = BlockBody.new + @else_block = nil + end + + def parse(tokens) + return unless parse_body(@for_block, tokens) + parse_body(@else_block, tokens) + end + + def nodelist + @else_block ? [@for_block, @else_block] : [@for_block] + end + + def unknown_tag(tag, markup, tokens) + return super unless tag == 'else'.freeze + @else_block = BlockBody.new + end + + def render(context) + segment = collection_segment(context) + + if segment.empty? + render_else(context) + else + render_segment(context, segment) + end + end + + protected + + def lax_parse(markup) + if markup =~ Syntax + @variable_name = $1 + collection_name = $2 + @reversed = !!$3 + @name = "#{@variable_name}-#{collection_name}" + @collection_name = Expression.parse(collection_name) + markup.scan(TagAttributes) do |key, value| + set_attribute(key, value) + end + else + raise SyntaxError.new(options[:locale].t("errors.syntax.for".freeze)) + end + end + + def strict_parse(markup) + p = Parser.new(markup) + @variable_name = p.consume(:id) + raise SyntaxError.new(options[:locale].t("errors.syntax.for_invalid_in".freeze)) unless p.id?('in'.freeze) + collection_name = p.expression + @name = "#{@variable_name}-#{collection_name}" + @collection_name = Expression.parse(collection_name) + @reversed = p.id?('reversed'.freeze) + + while p.look(:id) && p.look(:colon, 1) + unless attribute = p.id?('limit'.freeze) || p.id?('offset'.freeze) + raise SyntaxError.new(options[:locale].t("errors.syntax.for_invalid_attribute".freeze)) + end + p.consume + set_attribute(attribute, p.expression) + end + p.consume(:end_of_string) + end + + private + + def collection_segment(context) + offsets = context.registers[:for] ||= {} + + from = if @from == :continue + offsets[@name].to_i + else + context.evaluate(@from).to_i + end + + collection = context.evaluate(@collection_name) + collection = collection.to_a if collection.is_a?(Range) + + limit = context.evaluate(@limit) + to = limit ? limit.to_i + from : nil + + segment = Utils.slice_collection(collection, from, to) + segment.reverse! if @reversed + + offsets[@name] = from + segment.length + + segment + end + + def render_segment(context, segment) + for_stack = context.registers[:for_stack] ||= [] + length = segment.length + + result = '' + + context.stack do + loop_vars = Liquid::ForloopDrop.new(@name, length, for_stack[-1]) + + for_stack.push(loop_vars) + + begin + context['forloop'.freeze] = loop_vars + + segment.each do |item| + context[@variable_name] = item + result << @for_block.render(context) + loop_vars.send(:increment!) + + # Handle any interrupts if they exist. + if context.interrupt? + interrupt = context.pop_interrupt + break if interrupt.is_a? BreakInterrupt + next if interrupt.is_a? ContinueInterrupt + end + end + ensure + for_stack.pop + end + end + + result + end + + def set_attribute(key, expr) + case key + when 'offset'.freeze + @from = if expr == 'continue'.freeze + :continue + else + Expression.parse(expr) + end + when 'limit'.freeze + @limit = Expression.parse(expr) + end + end + + def render_else(context) + @else_block ? @else_block.render(context) : ''.freeze + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + (super + [@node.limit, @node.from, @node.collection_name]).compact + end + end + end + + Template.register_tag('for'.freeze, For) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/if.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/if.rb new file mode 100644 index 0000000..02da42b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/if.rb @@ -0,0 +1,122 @@ +module Liquid + # If is the conditional block + # + # {% if user.admin %} + # Admin user! + # {% else %} + # Not admin user + # {% endif %} + # + # There are {% if count < 5 %} less {% else %} more {% endif %} items than you need. + # + class If < Block + Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/o + ExpressionsAndOperators = /(?:\b(?:\s?and\s?|\s?or\s?)\b|(?:\s*(?!\b(?:\s?and\s?|\s?or\s?)\b)(?:#{QuotedFragment}|\S+)\s*)+)/o + BOOLEAN_OPERATORS = %w(and or).freeze + + attr_reader :blocks + + def initialize(tag_name, markup, options) + super + @blocks = [] + push_block('if'.freeze, markup) + end + + def nodelist + @blocks.map(&:attachment) + end + + def parse(tokens) + while parse_body(@blocks.last.attachment, tokens) + end + end + + def unknown_tag(tag, markup, tokens) + if ['elsif'.freeze, 'else'.freeze].include?(tag) + push_block(tag, markup) + else + super + end + end + + def render(context) + context.stack do + @blocks.each do |block| + if block.evaluate(context) + return block.attachment.render(context) + end + end + ''.freeze + end + end + + private + + def push_block(tag, markup) + block = if tag == 'else'.freeze + ElseCondition.new + else + parse_with_selected_parser(markup) + end + + @blocks.push(block) + block.attach(BlockBody.new) + end + + def lax_parse(markup) + expressions = markup.scan(ExpressionsAndOperators) + raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless expressions.pop =~ Syntax + + condition = Condition.new(Expression.parse($1), $2, Expression.parse($3)) + + until expressions.empty? + operator = expressions.pop.to_s.strip + + raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless expressions.pop.to_s =~ Syntax + + new_condition = Condition.new(Expression.parse($1), $2, Expression.parse($3)) + raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless BOOLEAN_OPERATORS.include?(operator) + new_condition.send(operator, condition) + condition = new_condition + end + + condition + end + + def strict_parse(markup) + p = Parser.new(markup) + condition = parse_binary_comparisons(p) + p.consume(:end_of_string) + condition + end + + def parse_binary_comparisons(p) + condition = parse_comparison(p) + first_condition = condition + while op = (p.id?('and'.freeze) || p.id?('or'.freeze)) + child_condition = parse_comparison(p) + condition.send(op, child_condition) + condition = child_condition + end + first_condition + end + + def parse_comparison(p) + a = Expression.parse(p.expression) + if op = p.consume?(:comparison) + b = Expression.parse(p.expression) + Condition.new(a, op, b) + else + Condition.new(a) + end + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + @node.blocks + end + end + end + + Template.register_tag('if'.freeze, If) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/ifchanged.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/ifchanged.rb new file mode 100644 index 0000000..d70cbe1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/ifchanged.rb @@ -0,0 +1,18 @@ +module Liquid + class Ifchanged < Block + def render(context) + context.stack do + output = super + + if output != context.registers[:ifchanged] + context.registers[:ifchanged] = output + output + else + ''.freeze + end + end + end + end + + Template.register_tag('ifchanged'.freeze, Ifchanged) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/include.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/include.rb new file mode 100644 index 0000000..c9f2a28 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/include.rb @@ -0,0 +1,124 @@ +module Liquid + # Include allows templates to relate with other templates + # + # Simply include another template: + # + # {% include 'product' %} + # + # Include a template with a local variable: + # + # {% include 'product' with products[0] %} + # + # Include a template for a collection: + # + # {% include 'product' for products %} + # + class Include < Tag + Syntax = /(#{QuotedFragment}+)(\s+(?:with|for)\s+(#{QuotedFragment}+))?/o + + attr_reader :template_name_expr, :variable_name_expr, :attributes + + def initialize(tag_name, markup, options) + super + + if markup =~ Syntax + + template_name = $1 + variable_name = $3 + + @variable_name_expr = variable_name ? Expression.parse(variable_name) : nil + @template_name_expr = Expression.parse(template_name) + @attributes = {} + + markup.scan(TagAttributes) do |key, value| + @attributes[key] = Expression.parse(value) + end + + else + raise SyntaxError.new(options[:locale].t("errors.syntax.include".freeze)) + end + end + + def parse(_tokens) + end + + def render(context) + template_name = context.evaluate(@template_name_expr) + raise ArgumentError.new(options[:locale].t("errors.argument.include")) unless template_name + + partial = load_cached_partial(template_name, context) + context_variable_name = template_name.split('/'.freeze).last + + variable = if @variable_name_expr + context.evaluate(@variable_name_expr) + else + context.find_variable(template_name, raise_on_not_found: false) + end + + old_template_name = context.template_name + old_partial = context.partial + begin + context.template_name = template_name + context.partial = true + context.stack do + @attributes.each do |key, value| + context[key] = context.evaluate(value) + end + + if variable.is_a?(Array) + variable.collect do |var| + context[context_variable_name] = var + partial.render(context) + end + else + context[context_variable_name] = variable + partial.render(context) + end + end + ensure + context.template_name = old_template_name + context.partial = old_partial + end + end + + private + + alias_method :parse_context, :options + private :parse_context + + def load_cached_partial(template_name, context) + cached_partials = context.registers[:cached_partials] || {} + + if cached = cached_partials[template_name] + return cached + end + source = read_template_from_file_system(context) + begin + parse_context.partial = true + partial = Liquid::Template.parse(source, parse_context) + ensure + parse_context.partial = false + end + cached_partials[template_name] = partial + context.registers[:cached_partials] = cached_partials + partial + end + + def read_template_from_file_system(context) + file_system = context.registers[:file_system] || Liquid::Template.file_system + + file_system.read_template_file(context.evaluate(@template_name_expr)) + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [ + @node.template_name_expr, + @node.variable_name_expr + ] + @node.attributes.values + end + end + end + + Template.register_tag('include'.freeze, Include) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/increment.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/increment.rb new file mode 100644 index 0000000..baa0cbb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/increment.rb @@ -0,0 +1,31 @@ +module Liquid + # increment is used in a place where one needs to insert a counter + # into a template, and needs the counter to survive across + # multiple instantiations of the template. + # (To achieve the survival, the application must keep the context) + # + # if the variable does not exist, it is created with value 0. + # + # Hello: {% increment variable %} + # + # gives you: + # + # Hello: 0 + # Hello: 1 + # Hello: 2 + # + class Increment < Tag + def initialize(tag_name, markup, options) + super + @variable = markup.strip + end + + def render(context) + value = context.environments.first[@variable] ||= 0 + context.environments.first[@variable] = value + 1 + value.to_s + end + end + + Template.register_tag('increment'.freeze, Increment) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/raw.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/raw.rb new file mode 100644 index 0000000..6b461bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/raw.rb @@ -0,0 +1,47 @@ +module Liquid + class Raw < Block + Syntax = /\A\s*\z/ + FullTokenPossiblyInvalid = /\A(.*)#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}\z/om + + def initialize(tag_name, markup, parse_context) + super + + ensure_valid_markup(tag_name, markup, parse_context) + end + + def parse(tokens) + @body = '' + while token = tokens.shift + if token =~ FullTokenPossiblyInvalid + @body << $1 if $1 != "".freeze + return if block_delimiter == $2 + end + @body << token unless token.empty? + end + + raise SyntaxError.new(parse_context.locale.t("errors.syntax.tag_never_closed".freeze, block_name: block_name)) + end + + def render(_context) + @body + end + + def nodelist + [@body] + end + + def blank? + @body.empty? + end + + protected + + def ensure_valid_markup(tag_name, markup, parse_context) + unless markup =~ Syntax + raise SyntaxError.new(parse_context.locale.t("errors.syntax.tag_unexpected_args".freeze, tag: tag_name)) + end + end + end + + Template.register_tag('raw'.freeze, Raw) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/table_row.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/table_row.rb new file mode 100644 index 0000000..7f391cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/table_row.rb @@ -0,0 +1,62 @@ +module Liquid + class TableRow < Block + Syntax = /(\w+)\s+in\s+(#{QuotedFragment}+)/o + + attr_reader :variable_name, :collection_name, :attributes + + def initialize(tag_name, markup, options) + super + if markup =~ Syntax + @variable_name = $1 + @collection_name = Expression.parse($2) + @attributes = {} + markup.scan(TagAttributes) do |key, value| + @attributes[key] = Expression.parse(value) + end + else + raise SyntaxError.new(options[:locale].t("errors.syntax.table_row".freeze)) + end + end + + def render(context) + collection = context.evaluate(@collection_name) or return ''.freeze + + from = @attributes.key?('offset'.freeze) ? context.evaluate(@attributes['offset'.freeze]).to_i : 0 + to = @attributes.key?('limit'.freeze) ? from + context.evaluate(@attributes['limit'.freeze]).to_i : nil + + collection = Utils.slice_collection(collection, from, to) + + length = collection.length + + cols = context.evaluate(@attributes['cols'.freeze]).to_i + + result = "\n" + context.stack do + tablerowloop = Liquid::TablerowloopDrop.new(length, cols) + context['tablerowloop'.freeze] = tablerowloop + + collection.each do |item| + context[@variable_name] = item + + result << "" << super << '' + + if tablerowloop.col_last && !tablerowloop.last + result << "\n" + end + + tablerowloop.send(:increment!) + end + end + result << "\n" + result + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + super + @node.attributes.values + [@node.collection_name] + end + end + end + + Template.register_tag('tablerow'.freeze, TableRow) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/unless.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/unless.rb new file mode 100644 index 0000000..1d4280d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/unless.rb @@ -0,0 +1,30 @@ +require_relative 'if' + +module Liquid + # Unless is a conditional just like 'if' but works on the inverse logic. + # + # {% unless x < 0 %} x is greater than zero {% endunless %} + # + class Unless < If + def render(context) + context.stack do + # First condition is interpreted backwards ( if not ) + first_block = @blocks.first + unless first_block.evaluate(context) + return first_block.attachment.render(context) + end + + # After the first condition unless works just like if + @blocks[1..-1].each do |block| + if block.evaluate(context) + return block.attachment.render(context) + end + end + + ''.freeze + end + end + end + + Template.register_tag('unless'.freeze, Unless) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb new file mode 100644 index 0000000..ba429ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb @@ -0,0 +1,252 @@ +module Liquid + # Templates are central to liquid. + # Interpretating templates is a two step process. First you compile the + # source code you got. During compile time some extensive error checking is performed. + # your code should expect to get some SyntaxErrors. + # + # After you have a compiled template you can then render it. + # You can use a compiled template over and over again and keep it cached. + # + # Example: + # + # template = Liquid::Template.parse(source) + # template.render('user_name' => 'bob') + # + class Template + attr_accessor :root + attr_reader :resource_limits, :warnings + + @@file_system = BlankFileSystem.new + + class TagRegistry + include Enumerable + + def initialize + @tags = {} + @cache = {} + end + + def [](tag_name) + return nil unless @tags.key?(tag_name) + return @cache[tag_name] if Liquid.cache_classes + + lookup_class(@tags[tag_name]).tap { |o| @cache[tag_name] = o } + end + + def []=(tag_name, klass) + @tags[tag_name] = klass.name + @cache[tag_name] = klass + end + + def delete(tag_name) + @tags.delete(tag_name) + @cache.delete(tag_name) + end + + def each(&block) + @tags.each(&block) + end + + private + + def lookup_class(name) + name.split("::").reject(&:empty?).reduce(Object) { |scope, const| scope.const_get(const) } + end + end + + attr_reader :profiler + + class << self + # Sets how strict the parser should be. + # :lax acts like liquid 2.5 and silently ignores malformed tags in most cases. + # :warn is the default and will give deprecation warnings when invalid syntax is used. + # :strict will enforce correct syntax. + attr_writer :error_mode + + # Deprecated. No longer used. Removed in version 5 + attr_writer :taint_mode + + attr_accessor :default_exception_renderer + Template.default_exception_renderer = lambda do |exception| + exception + end + + def file_system + @@file_system + end + + def file_system=(obj) + @@file_system = obj + end + + def register_tag(name, klass) + tags[name.to_s] = klass + end + + def tags + @tags ||= TagRegistry.new + end + + def error_mode + @error_mode ||= :lax + end + + # Deprecated. Removed in version 5 + def taint_mode + @taint_mode ||= :lax + end + + # Pass a module with filter methods which should be available + # to all liquid views. Good for registering the standard library + def register_filter(mod) + Strainer.global_filter(mod) + end + + def default_resource_limits + @default_resource_limits ||= {} + end + + # creates a new Template object from liquid source code + # To enable profiling, pass in profile: true as an option. + # See Liquid::Profiler for more information + def parse(source, options = {}) + template = Template.new + template.parse(source, options) + end + end + + def initialize + @rethrow_errors = false + @resource_limits = ResourceLimits.new(self.class.default_resource_limits) + end + + # Parse source code. + # Returns self for easy chaining + def parse(source, options = {}) + @options = options + @profiling = options[:profile] + @line_numbers = options[:line_numbers] || @profiling + parse_context = options.is_a?(ParseContext) ? options : ParseContext.new(options) + @root = Document.parse(tokenize(source), parse_context) + @warnings = parse_context.warnings + self + end + + def registers + @registers ||= {} + end + + def assigns + @assigns ||= {} + end + + def instance_assigns + @instance_assigns ||= {} + end + + def errors + @errors ||= [] + end + + # Render takes a hash with local variables. + # + # if you use the same filters over and over again consider registering them globally + # with Template.register_filter + # + # if profiling was enabled in Template#parse then the resulting profiling information + # will be available via Template#profiler + # + # Following options can be passed: + # + # * filters : array with local filters + # * registers : hash with register variables. Those can be accessed from + # filters and tags and might be useful to integrate liquid more with its host application + # + def render(*args) + return ''.freeze if @root.nil? + + context = case args.first + when Liquid::Context + c = args.shift + + if @rethrow_errors + c.exception_renderer = ->(e) { raise } + end + + c + when Liquid::Drop + drop = args.shift + drop.context = Context.new([drop, assigns], instance_assigns, registers, @rethrow_errors, @resource_limits) + when Hash + Context.new([args.shift, assigns], instance_assigns, registers, @rethrow_errors, @resource_limits) + when nil + Context.new(assigns, instance_assigns, registers, @rethrow_errors, @resource_limits) + else + raise ArgumentError, "Expected Hash or Liquid::Context as parameter" + end + + case args.last + when Hash + options = args.pop + + registers.merge!(options[:registers]) if options[:registers].is_a?(Hash) + + apply_options_to_context(context, options) + when Module, Array + context.add_filters(args.pop) + end + + # Retrying a render resets resource usage + context.resource_limits.reset + + begin + # render the nodelist. + # for performance reasons we get an array back here. join will make a string out of it. + result = with_profiling(context) do + @root.render(context) + end + result.respond_to?(:join) ? result.join : result + rescue Liquid::MemoryError => e + context.handle_error(e) + ensure + @errors = context.errors + end + end + + def render!(*args) + @rethrow_errors = true + render(*args) + end + + private + + def tokenize(source) + Tokenizer.new(source, @line_numbers) + end + + def with_profiling(context) + if @profiling && !context.partial + raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Liquid::Profiler) + + @profiler = Profiler.new + @profiler.start + + begin + yield + ensure + @profiler.stop + end + else + yield + end + end + + def apply_options_to_context(context, options) + context.add_filters(options[:filters]) if options[:filters] + context.global_filter = options[:global_filter] if options[:global_filter] + context.exception_renderer = options[:exception_renderer] if options[:exception_renderer] + context.strict_variables = options[:strict_variables] if options[:strict_variables] + context.strict_filters = options[:strict_filters] if options[:strict_filters] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tokenizer.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tokenizer.rb new file mode 100644 index 0000000..d03657e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tokenizer.rb @@ -0,0 +1,31 @@ +module Liquid + class Tokenizer + attr_reader :line_number + + def initialize(source, line_numbers = false) + @source = source + @line_number = line_numbers ? 1 : nil + @tokens = tokenize + end + + def shift + token = @tokens.shift + @line_number += token.count("\n") if @line_number && token + token + end + + private + + def tokenize + @source = @source.source if @source.respond_to?(:source) + return [] if @source.to_s.empty? + + tokens = @source.split(TemplateParser) + + # removes the rogue empty element at the beginning of the array + tokens.shift if tokens[0] && tokens[0].empty? + + tokens + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/utils.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/utils.rb new file mode 100644 index 0000000..516ac0c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/utils.rb @@ -0,0 +1,83 @@ +module Liquid + module Utils + def self.slice_collection(collection, from, to) + if (from != 0 || !to.nil?) && collection.respond_to?(:load_slice) + collection.load_slice(from, to) + else + slice_collection_using_each(collection, from, to) + end + end + + def self.slice_collection_using_each(collection, from, to) + segments = [] + index = 0 + + # Maintains Ruby 1.8.7 String#each behaviour on 1.9 + if collection.is_a?(String) + return collection.empty? ? [] : [collection] + end + return [] unless collection.respond_to?(:each) + + collection.each do |item| + if to && to <= index + break + end + + if from <= index + segments << item + end + + index += 1 + end + + segments + end + + def self.to_integer(num) + return num if num.is_a?(Integer) + num = num.to_s + begin + Integer(num) + rescue ::ArgumentError + raise Liquid::ArgumentError, "invalid integer" + end + end + + def self.to_number(obj) + case obj + when Float + BigDecimal(obj.to_s) + when Numeric + obj + when String + (obj.strip =~ /\A-?\d+\.\d+\z/) ? BigDecimal(obj) : obj.to_i + else + if obj.respond_to?(:to_number) + obj.to_number + else + 0 + end + end + end + + def self.to_date(obj) + return obj if obj.respond_to?(:strftime) + + if obj.is_a?(String) + return nil if obj.empty? + obj = obj.downcase + end + + case obj + when 'now'.freeze, 'today'.freeze + Time.now + when /\A\d+\z/, Integer + Time.at(obj.to_i) + when String + Time.parse(obj) + end + rescue ::ArgumentError + nil + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb new file mode 100644 index 0000000..8d63eb1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb @@ -0,0 +1,125 @@ +module Liquid + # Holds variables. Variables are only loaded "just in time" + # and are not evaluated as part of the render stage + # + # {{ monkey }} + # {{ user.name }} + # + # Variables can be combined with filters: + # + # {{ user | link }} + # + class Variable + FilterMarkupRegex = /#{FilterSeparator}\s*(.*)/om + FilterParser = /(?:\s+|#{QuotedFragment}|#{ArgumentSeparator})+/o + FilterArgsRegex = /(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o + JustTagAttributes = /\A#{TagAttributes}\z/o + MarkupWithQuotedFragment = /(#{QuotedFragment})(.*)/om + + attr_accessor :filters, :name, :line_number + attr_reader :parse_context + alias_method :options, :parse_context + + include ParserSwitching + + def initialize(markup, parse_context) + @markup = markup + @name = nil + @parse_context = parse_context + @line_number = parse_context.line_number + + parse_with_selected_parser(markup) + end + + def raw + @markup + end + + def markup_context(markup) + "in \"{{#{markup}}}\"" + end + + def lax_parse(markup) + @filters = [] + return unless markup =~ MarkupWithQuotedFragment + + name_markup = $1 + filter_markup = $2 + @name = Expression.parse(name_markup) + if filter_markup =~ FilterMarkupRegex + filters = $1.scan(FilterParser) + filters.each do |f| + next unless f =~ /\w+/ + filtername = Regexp.last_match(0) + filterargs = f.scan(FilterArgsRegex).flatten + @filters << parse_filter_expressions(filtername, filterargs) + end + end + end + + def strict_parse(markup) + @filters = [] + p = Parser.new(markup) + + @name = Expression.parse(p.expression) + while p.consume?(:pipe) + filtername = p.consume(:id) + filterargs = p.consume?(:colon) ? parse_filterargs(p) : [] + @filters << parse_filter_expressions(filtername, filterargs) + end + p.consume(:end_of_string) + end + + def parse_filterargs(p) + # first argument + filterargs = [p.argument] + # followed by comma separated others + filterargs << p.argument while p.consume?(:comma) + filterargs + end + + def render(context) + obj = @filters.inject(context.evaluate(@name)) do |output, (filter_name, filter_args, filter_kwargs)| + filter_args = evaluate_filter_expressions(context, filter_args, filter_kwargs) + context.invoke(filter_name, output, *filter_args) + end + + context.apply_global_filter(obj) + end + + private + + def parse_filter_expressions(filter_name, unparsed_args) + filter_args = [] + keyword_args = {} + unparsed_args.each do |a| + if matches = a.match(JustTagAttributes) + keyword_args[matches[1]] = Expression.parse(matches[2]) + else + filter_args << Expression.parse(a) + end + end + result = [filter_name, filter_args] + result << keyword_args unless keyword_args.empty? + result + end + + def evaluate_filter_expressions(context, filter_args, filter_kwargs) + parsed_args = filter_args.map{ |expr| context.evaluate(expr) } + if filter_kwargs + parsed_kwargs = {} + filter_kwargs.each do |key, expr| + parsed_kwargs[key] = context.evaluate(expr) + end + parsed_args << parsed_kwargs + end + parsed_args + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [@node.name] + @node.filters.flatten + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable_lookup.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable_lookup.rb new file mode 100644 index 0000000..62f4877 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable_lookup.rb @@ -0,0 +1,88 @@ +module Liquid + class VariableLookup + SQUARE_BRACKETED = /\A\[(.*)\]\z/m + COMMAND_METHODS = ['size'.freeze, 'first'.freeze, 'last'.freeze].freeze + + attr_reader :name, :lookups + + def self.parse(markup) + new(markup) + end + + def initialize(markup) + lookups = markup.scan(VariableParser) + + name = lookups.shift + if name =~ SQUARE_BRACKETED + name = Expression.parse($1) + end + @name = name + + @lookups = lookups + @command_flags = 0 + + @lookups.each_index do |i| + lookup = lookups[i] + if lookup =~ SQUARE_BRACKETED + lookups[i] = Expression.parse($1) + elsif COMMAND_METHODS.include?(lookup) + @command_flags |= 1 << i + end + end + end + + def evaluate(context) + name = context.evaluate(@name) + object = context.find_variable(name) + + @lookups.each_index do |i| + key = context.evaluate(@lookups[i]) + + # If object is a hash- or array-like object we look for the + # presence of the key and if its available we return it + if object.respond_to?(:[]) && + ((object.respond_to?(:key?) && object.key?(key)) || + (object.respond_to?(:fetch) && key.is_a?(Integer))) + + # if its a proc we will replace the entry with the proc + res = context.lookup_and_evaluate(object, key) + object = res.to_liquid + + # Some special cases. If the part wasn't in square brackets and + # no key with the same name was found we interpret following calls + # as commands and call them on the current object + elsif @command_flags & (1 << i) != 0 && object.respond_to?(key) + object = object.send(key).to_liquid + + # No key was present with the desired value and it wasn't one of the directly supported + # keywords either. The only thing we got left is to return nil or + # raise an exception if `strict_variables` option is set to true + else + return nil unless context.strict_variables + raise Liquid::UndefinedVariable, "undefined variable #{key}" + end + + # If we are dealing with a drop here we have to + object.context = context if object.respond_to?(:context=) + end + + object + end + + def ==(other) + self.class == other.class && state == other.state + end + + protected + + def state + [@name, @lookups, @command_flags] + end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + @node.lookups + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/version.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/version.rb new file mode 100644 index 0000000..9799863 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/version.rb @@ -0,0 +1,5 @@ +# encoding: utf-8 + +module Liquid + VERSION = "4.0.4".freeze +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/fixtures/en_locale.yml b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/fixtures/en_locale.yml new file mode 100644 index 0000000..0b113c6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/fixtures/en_locale.yml @@ -0,0 +1,9 @@ +--- + simple: "less is more" + whatever: "something %{something}" + errors: + i18n: + undefined_interpolation: "undefined key %{key}" + unknown_translation: "translation '%{name}' wasn't found" + syntax: + oops: "something wasn't right" diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/assign_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/assign_test.rb new file mode 100644 index 0000000..5502289 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/assign_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class AssignTest < Minitest::Test + include Liquid + + def test_assign_with_hyphen_in_variable_name + template_source = <<-END_TEMPLATE + {% assign this-thing = 'Print this-thing' %} + {{ this-thing }} + END_TEMPLATE + template = Template.parse(template_source) + rendered = template.render! + assert_equal "Print this-thing", rendered.strip + end + + def test_assigned_variable + assert_template_result('.foo.', + '{% assign foo = values %}.{{ foo[0] }}.', + 'values' => %w(foo bar baz)) + + assert_template_result('.bar.', + '{% assign foo = values %}.{{ foo[1] }}.', + 'values' => %w(foo bar baz)) + end + + def test_assign_with_filter + assert_template_result('.bar.', + '{% assign foo = values | split: "," %}.{{ foo[1] }}.', + 'values' => "foo,bar,baz") + end + + def test_assign_syntax_error + assert_match_syntax_error(/assign/, + '{% assign foo not values %}.', + 'values' => "foo,bar,baz") + end + + def test_assign_uses_error_mode + with_error_mode(:strict) do + assert_raises(SyntaxError) do + Template.parse("{% assign foo = ('X' | downcase) %}") + end + end + with_error_mode(:lax) do + assert Template.parse("{% assign foo = ('X' | downcase) %}") + end + end +end # AssignTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/blank_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/blank_test.rb new file mode 100644 index 0000000..e9b56df --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/blank_test.rb @@ -0,0 +1,106 @@ +require 'test_helper' + +class FoobarTag < Liquid::Tag + def render(*args) + " " + end + + Liquid::Template.register_tag('foobar', FoobarTag) +end + +class BlankTestFileSystem + def read_template_file(template_path) + template_path + end +end + +class BlankTest < Minitest::Test + include Liquid + N = 10 + + def wrap_in_for(body) + "{% for i in (1..#{N}) %}#{body}{% endfor %}" + end + + def wrap_in_if(body) + "{% if true %}#{body}{% endif %}" + end + + def wrap(body) + wrap_in_for(body) + wrap_in_if(body) + end + + def test_new_tags_are_not_blank_by_default + assert_template_result(" " * N, wrap_in_for("{% foobar %}")) + end + + def test_loops_are_blank + assert_template_result("", wrap_in_for(" ")) + end + + def test_if_else_are_blank + assert_template_result("", "{% if true %} {% elsif false %} {% else %} {% endif %}") + end + + def test_unless_is_blank + assert_template_result("", wrap("{% unless true %} {% endunless %}")) + end + + def test_mark_as_blank_only_during_parsing + assert_template_result(" " * (N + 1), wrap(" {% if false %} this never happens, but still, this block is not blank {% endif %}")) + end + + def test_comments_are_blank + assert_template_result("", wrap(" {% comment %} whatever {% endcomment %} ")) + end + + def test_captures_are_blank + assert_template_result("", wrap(" {% capture foo %} whatever {% endcapture %} ")) + end + + def test_nested_blocks_are_blank_but_only_if_all_children_are + assert_template_result("", wrap(wrap(" "))) + assert_template_result("\n but this is not " * (N + 1), + wrap('{% if true %} {% comment %} this is blank {% endcomment %} {% endif %} + {% if true %} but this is not {% endif %}')) + end + + def test_assigns_are_blank + assert_template_result("", wrap(' {% assign foo = "bar" %} ')) + end + + def test_whitespace_is_blank + assert_template_result("", wrap(" ")) + assert_template_result("", wrap("\t")) + end + + def test_whitespace_is_not_blank_if_other_stuff_is_present + body = " x " + assert_template_result(body * (N + 1), wrap(body)) + end + + def test_increment_is_not_blank + assert_template_result(" 0" * 2 * (N + 1), wrap("{% assign foo = 0 %} {% increment foo %} {% decrement foo %}")) + end + + def test_cycle_is_not_blank + assert_template_result(" " * ((N + 1) / 2) + " ", wrap("{% cycle ' ', ' ' %}")) + end + + def test_raw_is_not_blank + assert_template_result(" " * (N + 1), wrap(" {% raw %} {% endraw %}")) + end + + def test_include_is_blank + Liquid::Template.file_system = BlankTestFileSystem.new + assert_template_result "foobar" * (N + 1), wrap("{% include 'foobar' %}") + assert_template_result " foobar " * (N + 1), wrap("{% include ' foobar ' %}") + assert_template_result " " * (N + 1), wrap(" {% include ' ' %} ") + end + + def test_case_is_blank + assert_template_result("", wrap(" {% assign foo = 'bar' %} {% case foo %} {% when 'bar' %} {% when 'whatever' %} {% else %} {% endcase %} ")) + assert_template_result("", wrap(" {% assign foo = 'else' %} {% case foo %} {% when 'bar' %} {% when 'whatever' %} {% else %} {% endcase %} ")) + assert_template_result(" x " * (N + 1), wrap(" {% assign foo = 'else' %} {% case foo %} {% when 'bar' %} {% when 'whatever' %} {% else %} x {% endcase %} ")) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/block_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/block_test.rb new file mode 100644 index 0000000..0824530 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/block_test.rb @@ -0,0 +1,12 @@ +require 'test_helper' + +class BlockTest < Minitest::Test + include Liquid + + def test_unexpected_end_tag + exc = assert_raises(SyntaxError) do + Template.parse("{% if true %}{% endunless %}") + end + assert_equal exc.message, "Liquid syntax error: 'endunless' is not a valid delimiter for if tags. use endif" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/capture_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/capture_test.rb new file mode 100644 index 0000000..8d965b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/capture_test.rb @@ -0,0 +1,50 @@ +require 'test_helper' + +class CaptureTest < Minitest::Test + include Liquid + + def test_captures_block_content_in_variable + assert_template_result("test string", "{% capture 'var' %}test string{% endcapture %}{{var}}", {}) + end + + def test_capture_with_hyphen_in_variable_name + template_source = <<-END_TEMPLATE + {% capture this-thing %}Print this-thing{% endcapture %} + {{ this-thing }} + END_TEMPLATE + template = Template.parse(template_source) + rendered = template.render! + assert_equal "Print this-thing", rendered.strip + end + + def test_capture_to_variable_from_outer_scope_if_existing + template_source = <<-END_TEMPLATE + {% assign var = '' %} + {% if true %} + {% capture var %}first-block-string{% endcapture %} + {% endif %} + {% if true %} + {% capture var %}test-string{% endcapture %} + {% endif %} + {{var}} + END_TEMPLATE + template = Template.parse(template_source) + rendered = template.render! + assert_equal "test-string", rendered.gsub(/\s/, '') + end + + def test_assigning_from_capture + template_source = <<-END_TEMPLATE + {% assign first = '' %} + {% assign second = '' %} + {% for number in (1..3) %} + {% capture first %}{{number}}{% endcapture %} + {% assign second = first %} + {% endfor %} + {{ first }}-{{ second }} + END_TEMPLATE + template = Template.parse(template_source) + rendered = template.render! + assert_equal "3-3", rendered.gsub(/\s/, '') + end +end # CaptureTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/context_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/context_test.rb new file mode 100644 index 0000000..2d109bb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/context_test.rb @@ -0,0 +1,32 @@ +require 'test_helper' + +class ContextTest < Minitest::Test + include Liquid + + def test_override_global_filter + global = Module.new do + def notice(output) + "Global #{output}" + end + end + + local = Module.new do + def notice(output) + "Local #{output}" + end + end + + with_global_filter(global) do + assert_equal 'Global test', Template.parse("{{'test' | notice }}").render! + assert_equal 'Local test', Template.parse("{{'test' | notice }}").render!({}, filters: [local]) + end + end + + def test_has_key_will_not_add_an_error_for_missing_keys + with_error_mode :strict do + context = Context.new + context.key?('unknown') + assert_empty context.errors + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/document_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/document_test.rb new file mode 100644 index 0000000..bcc4a21 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/document_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class DocumentTest < Minitest::Test + include Liquid + + def test_unexpected_outer_tag + exc = assert_raises(SyntaxError) do + Template.parse("{% else %}") + end + assert_equal exc.message, "Liquid syntax error: Unexpected outer 'else' tag" + end + + def test_unknown_tag + exc = assert_raises(SyntaxError) do + Template.parse("{% foo %}") + end + assert_equal exc.message, "Liquid syntax error: Unknown tag 'foo'" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/drop_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/drop_test.rb new file mode 100644 index 0000000..723fe04 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/drop_test.rb @@ -0,0 +1,247 @@ +require 'test_helper' + +class ContextDrop < Liquid::Drop + def scopes + @context.scopes.size + end + + def scopes_as_array + (1..@context.scopes.size).to_a + end + + def loop_pos + @context['forloop.index'] + end + + def liquid_method_missing(method) + @context[method] + end +end + +class ProductDrop < Liquid::Drop + class TextDrop < Liquid::Drop + def array + ['text1', 'text2'] + end + + def text + 'text1' + end + end + + class CatchallDrop < Liquid::Drop + def liquid_method_missing(method) + 'catchall_method: ' << method.to_s + end + end + + def texts + TextDrop.new + end + + def catchall + CatchallDrop.new + end + + def context + ContextDrop.new + end + + def user_input + "foo" + end + + protected + + def callmenot + "protected" + end +end + +class EnumerableDrop < Liquid::Drop + def liquid_method_missing(method) + method + end + + def size + 3 + end + + def first + 1 + end + + def count + 3 + end + + def min + 1 + end + + def max + 3 + end + + def each + yield 1 + yield 2 + yield 3 + end +end + +class RealEnumerableDrop < Liquid::Drop + include Enumerable + + def liquid_method_missing(method) + method + end + + def each + yield 1 + yield 2 + yield 3 + end +end + +class DropsTest < Minitest::Test + include Liquid + + def test_product_drop + tpl = Liquid::Template.parse(' ') + assert_equal ' ', tpl.render!('product' => ProductDrop.new) + end + + def test_drop_does_only_respond_to_whitelisted_methods + assert_equal "", Liquid::Template.parse("{{ product.inspect }}").render!('product' => ProductDrop.new) + assert_equal "", Liquid::Template.parse("{{ product.pretty_inspect }}").render!('product' => ProductDrop.new) + assert_equal "", Liquid::Template.parse("{{ product.whatever }}").render!('product' => ProductDrop.new) + assert_equal "", Liquid::Template.parse('{{ product | map: "inspect" }}').render!('product' => ProductDrop.new) + assert_equal "", Liquid::Template.parse('{{ product | map: "pretty_inspect" }}').render!('product' => ProductDrop.new) + assert_equal "", Liquid::Template.parse('{{ product | map: "whatever" }}').render!('product' => ProductDrop.new) + end + + def test_drops_respond_to_to_liquid + assert_equal "text1", Liquid::Template.parse("{{ product.to_liquid.texts.text }}").render!('product' => ProductDrop.new) + assert_equal "text1", Liquid::Template.parse('{{ product | map: "to_liquid" | map: "texts" | map: "text" }}').render!('product' => ProductDrop.new) + end + + def test_text_drop + output = Liquid::Template.parse(' {{ product.texts.text }} ').render!('product' => ProductDrop.new) + assert_equal ' text1 ', output + end + + def test_catchall_unknown_method + output = Liquid::Template.parse(' {{ product.catchall.unknown }} ').render!('product' => ProductDrop.new) + assert_equal ' catchall_method: unknown ', output + end + + def test_catchall_integer_argument_drop + output = Liquid::Template.parse(' {{ product.catchall[8] }} ').render!('product' => ProductDrop.new) + assert_equal ' catchall_method: 8 ', output + end + + def test_text_array_drop + output = Liquid::Template.parse('{% for text in product.texts.array %} {{text}} {% endfor %}').render!('product' => ProductDrop.new) + assert_equal ' text1 text2 ', output + end + + def test_context_drop + output = Liquid::Template.parse(' {{ context.bar }} ').render!('context' => ContextDrop.new, 'bar' => "carrot") + assert_equal ' carrot ', output + end + + def test_nested_context_drop + output = Liquid::Template.parse(' {{ product.context.foo }} ').render!('product' => ProductDrop.new, 'foo' => "monkey") + assert_equal ' monkey ', output + end + + def test_protected + output = Liquid::Template.parse(' {{ product.callmenot }} ').render!('product' => ProductDrop.new) + assert_equal ' ', output + end + + def test_object_methods_not_allowed + [:dup, :clone, :singleton_class, :eval, :class_eval, :inspect].each do |method| + output = Liquid::Template.parse(" {{ product.#{method} }} ").render!('product' => ProductDrop.new) + assert_equal ' ', output + end + end + + def test_scope + assert_equal '1', Liquid::Template.parse('{{ context.scopes }}').render!('context' => ContextDrop.new) + assert_equal '2', Liquid::Template.parse('{%for i in dummy%}{{ context.scopes }}{%endfor%}').render!('context' => ContextDrop.new, 'dummy' => [1]) + assert_equal '3', Liquid::Template.parse('{%for i in dummy%}{%for i in dummy%}{{ context.scopes }}{%endfor%}{%endfor%}').render!('context' => ContextDrop.new, 'dummy' => [1]) + end + + def test_scope_though_proc + assert_equal '1', Liquid::Template.parse('{{ s }}').render!('context' => ContextDrop.new, 's' => proc{ |c| c['context.scopes'] }) + assert_equal '2', Liquid::Template.parse('{%for i in dummy%}{{ s }}{%endfor%}').render!('context' => ContextDrop.new, 's' => proc{ |c| c['context.scopes'] }, 'dummy' => [1]) + assert_equal '3', Liquid::Template.parse('{%for i in dummy%}{%for i in dummy%}{{ s }}{%endfor%}{%endfor%}').render!('context' => ContextDrop.new, 's' => proc{ |c| c['context.scopes'] }, 'dummy' => [1]) + end + + def test_scope_with_assigns + assert_equal 'variable', Liquid::Template.parse('{% assign a = "variable"%}{{a}}').render!('context' => ContextDrop.new) + assert_equal 'variable', Liquid::Template.parse('{% assign a = "variable"%}{%for i in dummy%}{{a}}{%endfor%}').render!('context' => ContextDrop.new, 'dummy' => [1]) + assert_equal 'test', Liquid::Template.parse('{% assign header_gif = "test"%}{{header_gif}}').render!('context' => ContextDrop.new) + assert_equal 'test', Liquid::Template.parse("{% assign header_gif = 'test'%}{{header_gif}}").render!('context' => ContextDrop.new) + end + + def test_scope_from_tags + assert_equal '1', Liquid::Template.parse('{% for i in context.scopes_as_array %}{{i}}{% endfor %}').render!('context' => ContextDrop.new, 'dummy' => [1]) + assert_equal '12', Liquid::Template.parse('{%for a in dummy%}{% for i in context.scopes_as_array %}{{i}}{% endfor %}{% endfor %}').render!('context' => ContextDrop.new, 'dummy' => [1]) + assert_equal '123', Liquid::Template.parse('{%for a in dummy%}{%for a in dummy%}{% for i in context.scopes_as_array %}{{i}}{% endfor %}{% endfor %}{% endfor %}').render!('context' => ContextDrop.new, 'dummy' => [1]) + end + + def test_access_context_from_drop + assert_equal '123', Liquid::Template.parse('{%for a in dummy%}{{ context.loop_pos }}{% endfor %}').render!('context' => ContextDrop.new, 'dummy' => [1, 2, 3]) + end + + def test_enumerable_drop + assert_equal '123', Liquid::Template.parse('{% for c in collection %}{{c}}{% endfor %}').render!('collection' => EnumerableDrop.new) + end + + def test_enumerable_drop_size + assert_equal '3', Liquid::Template.parse('{{collection.size}}').render!('collection' => EnumerableDrop.new) + end + + def test_enumerable_drop_will_invoke_liquid_method_missing_for_clashing_method_names + ["select", "each", "map", "cycle"].each do |method| + assert_equal method.to_s, Liquid::Template.parse("{{collection.#{method}}}").render!('collection' => EnumerableDrop.new) + assert_equal method.to_s, Liquid::Template.parse("{{collection[\"#{method}\"]}}").render!('collection' => EnumerableDrop.new) + assert_equal method.to_s, Liquid::Template.parse("{{collection.#{method}}}").render!('collection' => RealEnumerableDrop.new) + assert_equal method.to_s, Liquid::Template.parse("{{collection[\"#{method}\"]}}").render!('collection' => RealEnumerableDrop.new) + end + end + + def test_some_enumerable_methods_still_get_invoked + [ :count, :max ].each do |method| + assert_equal "3", Liquid::Template.parse("{{collection.#{method}}}").render!('collection' => RealEnumerableDrop.new) + assert_equal "3", Liquid::Template.parse("{{collection[\"#{method}\"]}}").render!('collection' => RealEnumerableDrop.new) + assert_equal "3", Liquid::Template.parse("{{collection.#{method}}}").render!('collection' => EnumerableDrop.new) + assert_equal "3", Liquid::Template.parse("{{collection[\"#{method}\"]}}").render!('collection' => EnumerableDrop.new) + end + + assert_equal "yes", Liquid::Template.parse("{% if collection contains 3 %}yes{% endif %}").render!('collection' => RealEnumerableDrop.new) + + [ :min, :first ].each do |method| + assert_equal "1", Liquid::Template.parse("{{collection.#{method}}}").render!('collection' => RealEnumerableDrop.new) + assert_equal "1", Liquid::Template.parse("{{collection[\"#{method}\"]}}").render!('collection' => RealEnumerableDrop.new) + assert_equal "1", Liquid::Template.parse("{{collection.#{method}}}").render!('collection' => EnumerableDrop.new) + assert_equal "1", Liquid::Template.parse("{{collection[\"#{method}\"]}}").render!('collection' => EnumerableDrop.new) + end + end + + def test_empty_string_value_access + assert_equal '', Liquid::Template.parse('{{ product[value] }}').render!('product' => ProductDrop.new, 'value' => '') + end + + def test_nil_value_access + assert_equal '', Liquid::Template.parse('{{ product[value] }}').render!('product' => ProductDrop.new, 'value' => nil) + end + + def test_default_to_s_on_drops + assert_equal 'ProductDrop', Liquid::Template.parse("{{ product }}").render!('product' => ProductDrop.new) + assert_equal 'EnumerableDrop', Liquid::Template.parse('{{ collection }}').render!('collection' => EnumerableDrop.new) + end +end # DropsTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/error_handling_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/error_handling_test.rb new file mode 100644 index 0000000..b2d186c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/error_handling_test.rb @@ -0,0 +1,260 @@ +require 'test_helper' + +class ErrorHandlingTest < Minitest::Test + include Liquid + + def test_templates_parsed_with_line_numbers_renders_them_in_errors + template = <<-LIQUID + Hello, + + {{ errors.standard_error }} will raise a standard error. + + Bla bla test. + + {{ errors.syntax_error }} will raise a syntax error. + + This is an argument error: {{ errors.argument_error }} + + Bla. + LIQUID + + expected = <<-TEXT + Hello, + + Liquid error (line 3): standard error will raise a standard error. + + Bla bla test. + + Liquid syntax error (line 7): syntax error will raise a syntax error. + + This is an argument error: Liquid error (line 9): argument error + + Bla. + TEXT + + output = Liquid::Template.parse(template, line_numbers: true).render('errors' => ErrorDrop.new) + assert_equal expected, output + end + + def test_standard_error + template = Liquid::Template.parse(' {{ errors.standard_error }} ') + assert_equal ' Liquid error: standard error ', template.render('errors' => ErrorDrop.new) + + assert_equal 1, template.errors.size + assert_equal StandardError, template.errors.first.class + end + + def test_syntax + template = Liquid::Template.parse(' {{ errors.syntax_error }} ') + assert_equal ' Liquid syntax error: syntax error ', template.render('errors' => ErrorDrop.new) + + assert_equal 1, template.errors.size + assert_equal SyntaxError, template.errors.first.class + end + + def test_argument + template = Liquid::Template.parse(' {{ errors.argument_error }} ') + assert_equal ' Liquid error: argument error ', template.render('errors' => ErrorDrop.new) + + assert_equal 1, template.errors.size + assert_equal ArgumentError, template.errors.first.class + end + + def test_missing_endtag_parse_time_error + assert_raises(Liquid::SyntaxError) do + Liquid::Template.parse(' {% for a in b %} ... ') + end + end + + def test_unrecognized_operator + with_error_mode(:strict) do + assert_raises(SyntaxError) do + Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ') + end + end + end + + def test_lax_unrecognized_operator + template = Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ', error_mode: :lax) + assert_equal ' Liquid error: Unknown operator =! ', template.render + assert_equal 1, template.errors.size + assert_equal Liquid::ArgumentError, template.errors.first.class + end + + def test_with_line_numbers_adds_numbers_to_parser_errors + err = assert_raises(SyntaxError) do + Liquid::Template.parse(%q( + foobar + + {% "cat" | foobar %} + + bla + ), + line_numbers: true + ) + end + + assert_match(/Liquid syntax error \(line 4\)/, err.message) + end + + def test_with_line_numbers_adds_numbers_to_parser_errors_with_whitespace_trim + err = assert_raises(SyntaxError) do + Liquid::Template.parse(%q( + foobar + + {%- "cat" | foobar -%} + + bla + ), + line_numbers: true + ) + end + + assert_match(/Liquid syntax error \(line 4\)/, err.message) + end + + def test_parsing_warn_with_line_numbers_adds_numbers_to_lexer_errors + template = Liquid::Template.parse(' + foobar + + {% if 1 =! 2 %}ok{% endif %} + + bla + ', + error_mode: :warn, + line_numbers: true + ) + + assert_equal ['Liquid syntax error (line 4): Unexpected character = in "1 =! 2"'], + template.warnings.map(&:message) + end + + def test_parsing_strict_with_line_numbers_adds_numbers_to_lexer_errors + err = assert_raises(SyntaxError) do + Liquid::Template.parse(' + foobar + + {% if 1 =! 2 %}ok{% endif %} + + bla + ', + error_mode: :strict, + line_numbers: true + ) + end + + assert_equal 'Liquid syntax error (line 4): Unexpected character = in "1 =! 2"', err.message + end + + def test_syntax_errors_in_nested_blocks_have_correct_line_number + err = assert_raises(SyntaxError) do + Liquid::Template.parse(' + foobar + + {% if 1 != 2 %} + {% foo %} + {% endif %} + + bla + ', + line_numbers: true + ) + end + + assert_equal "Liquid syntax error (line 5): Unknown tag 'foo'", err.message + end + + def test_strict_error_messages + err = assert_raises(SyntaxError) do + Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ', error_mode: :strict) + end + assert_equal 'Liquid syntax error: Unexpected character = in "1 =! 2"', err.message + + err = assert_raises(SyntaxError) do + Liquid::Template.parse('{{%%%}}', error_mode: :strict) + end + assert_equal 'Liquid syntax error: Unexpected character % in "{{%%%}}"', err.message + end + + def test_warnings + template = Liquid::Template.parse('{% if ~~~ %}{{%%%}}{% else %}{{ hello. }}{% endif %}', error_mode: :warn) + assert_equal 3, template.warnings.size + assert_equal 'Unexpected character ~ in "~~~"', template.warnings[0].to_s(false) + assert_equal 'Unexpected character % in "{{%%%}}"', template.warnings[1].to_s(false) + assert_equal 'Expected id but found end_of_string in "{{ hello. }}"', template.warnings[2].to_s(false) + assert_equal '', template.render + end + + def test_warning_line_numbers + template = Liquid::Template.parse("{% if ~~~ %}\n{{%%%}}{% else %}\n{{ hello. }}{% endif %}", error_mode: :warn, line_numbers: true) + assert_equal 'Liquid syntax error (line 1): Unexpected character ~ in "~~~"', template.warnings[0].message + assert_equal 'Liquid syntax error (line 2): Unexpected character % in "{{%%%}}"', template.warnings[1].message + assert_equal 'Liquid syntax error (line 3): Expected id but found end_of_string in "{{ hello. }}"', template.warnings[2].message + assert_equal 3, template.warnings.size + assert_equal [1, 2, 3], template.warnings.map(&:line_number) + end + + # Liquid should not catch Exceptions that are not subclasses of StandardError, like Interrupt and NoMemoryError + def test_exceptions_propagate + assert_raises Exception do + template = Liquid::Template.parse('{{ errors.exception }}') + template.render('errors' => ErrorDrop.new) + end + end + + def test_default_exception_renderer_with_internal_error + template = Liquid::Template.parse('This is a runtime error: {{ errors.runtime_error }}', line_numbers: true) + + output = template.render({ 'errors' => ErrorDrop.new }) + + assert_equal 'This is a runtime error: Liquid error (line 1): internal', output + assert_equal [Liquid::InternalError], template.errors.map(&:class) + end + + def test_setting_default_exception_renderer + old_exception_renderer = Liquid::Template.default_exception_renderer + exceptions = [] + Liquid::Template.default_exception_renderer = ->(e) { exceptions << e; '' } + template = Liquid::Template.parse('This is a runtime error: {{ errors.argument_error }}') + + output = template.render({ 'errors' => ErrorDrop.new }) + + assert_equal 'This is a runtime error: ', output + assert_equal [Liquid::ArgumentError], template.errors.map(&:class) + ensure + Liquid::Template.default_exception_renderer = old_exception_renderer if old_exception_renderer + end + + def test_exception_renderer_exposing_non_liquid_error + template = Liquid::Template.parse('This is a runtime error: {{ errors.runtime_error }}', line_numbers: true) + exceptions = [] + handler = ->(e) { exceptions << e; e.cause } + + output = template.render({ 'errors' => ErrorDrop.new }, exception_renderer: handler) + + assert_equal 'This is a runtime error: runtime error', output + assert_equal [Liquid::InternalError], exceptions.map(&:class) + assert_equal exceptions, template.errors + assert_equal '#', exceptions.first.cause.inspect + end + + class TestFileSystem + def read_template_file(template_path) + "{{ errors.argument_error }}" + end + end + + def test_included_template_name_with_line_numbers + old_file_system = Liquid::Template.file_system + + begin + Liquid::Template.file_system = TestFileSystem.new + template = Liquid::Template.parse("Argument error:\n{% include 'product' %}", line_numbers: true) + page = template.render('errors' => ErrorDrop.new) + ensure + Liquid::Template.file_system = old_file_system + end + assert_equal "Argument error:\nLiquid error (product line 1): argument error", page + assert_equal "product", template.errors.first.template_name + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/filter_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/filter_test.rb new file mode 100644 index 0000000..d3c880e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/filter_test.rb @@ -0,0 +1,178 @@ +require 'test_helper' + +module MoneyFilter + def money(input) + sprintf(' %d$ ', input) + end + + def money_with_underscore(input) + sprintf(' %d$ ', input) + end +end + +module CanadianMoneyFilter + def money(input) + sprintf(' %d$ CAD ', input) + end +end + +module SubstituteFilter + def substitute(input, params = {}) + input.gsub(/%\{(\w+)\}/) { |match| params[$1] } + end +end + +class FiltersTest < Minitest::Test + include Liquid + + module OverrideObjectMethodFilter + def tap(input) + "tap overridden" + end + end + + def setup + @context = Context.new + end + + def test_local_filter + @context['var'] = 1000 + @context.add_filters(MoneyFilter) + + assert_equal ' 1000$ ', Template.parse("{{var | money}}").render(@context) + end + + def test_underscore_in_filter_name + @context['var'] = 1000 + @context.add_filters(MoneyFilter) + assert_equal ' 1000$ ', Template.parse("{{var | money_with_underscore}}").render(@context) + end + + def test_second_filter_overwrites_first + @context['var'] = 1000 + @context.add_filters(MoneyFilter) + @context.add_filters(CanadianMoneyFilter) + + assert_equal ' 1000$ CAD ', Template.parse("{{var | money}}").render(@context) + end + + def test_size + @context['var'] = 'abcd' + @context.add_filters(MoneyFilter) + + assert_equal '4', Template.parse("{{var | size}}").render(@context) + end + + def test_join + @context['var'] = [1, 2, 3, 4] + + assert_equal "1 2 3 4", Template.parse("{{var | join}}").render(@context) + end + + def test_sort + @context['value'] = 3 + @context['numbers'] = [2, 1, 4, 3] + @context['words'] = ['expected', 'as', 'alphabetic'] + @context['arrays'] = ['flower', 'are'] + @context['case_sensitive'] = ['sensitive', 'Expected', 'case'] + + assert_equal '1 2 3 4', Template.parse("{{numbers | sort | join}}").render(@context) + assert_equal 'alphabetic as expected', Template.parse("{{words | sort | join}}").render(@context) + assert_equal '3', Template.parse("{{value | sort}}").render(@context) + assert_equal 'are flower', Template.parse("{{arrays | sort | join}}").render(@context) + assert_equal 'Expected case sensitive', Template.parse("{{case_sensitive | sort | join}}").render(@context) + end + + def test_sort_natural + @context['words'] = ['case', 'Assert', 'Insensitive'] + @context['hashes'] = [{ 'a' => 'A' }, { 'a' => 'b' }, { 'a' => 'C' }] + @context['objects'] = [TestObject.new('A'), TestObject.new('b'), TestObject.new('C')] + + # Test strings + assert_equal 'Assert case Insensitive', Template.parse("{{words | sort_natural | join}}").render(@context) + + # Test hashes + assert_equal 'A b C', Template.parse("{{hashes | sort_natural: 'a' | map: 'a' | join}}").render(@context) + + # Test objects + assert_equal 'A b C', Template.parse("{{objects | sort_natural: 'a' | map: 'a' | join}}").render(@context) + end + + def test_compact + @context['words'] = ['a', nil, 'b', nil, 'c'] + @context['hashes'] = [{ 'a' => 'A' }, { 'a' => nil }, { 'a' => 'C' }] + @context['objects'] = [TestObject.new('A'), TestObject.new(nil), TestObject.new('C')] + + # Test strings + assert_equal 'a b c', Template.parse("{{words | compact | join}}").render(@context) + + # Test hashes + assert_equal 'A C', Template.parse("{{hashes | compact: 'a' | map: 'a' | join}}").render(@context) + + # Test objects + assert_equal 'A C', Template.parse("{{objects | compact: 'a' | map: 'a' | join}}").render(@context) + end + + def test_strip_html + @context['var'] = "bla blub" + + assert_equal "bla blub", Template.parse("{{ var | strip_html }}").render(@context) + end + + def test_strip_html_ignore_comments_with_html + @context['var'] = "bla blub" + + assert_equal "bla blub", Template.parse("{{ var | strip_html }}").render(@context) + end + + def test_capitalize + @context['var'] = "blub" + + assert_equal "Blub", Template.parse("{{ var | capitalize }}").render(@context) + end + + def test_nonexistent_filter_is_ignored + @context['var'] = 1000 + + assert_equal '1000', Template.parse("{{ var | xyzzy }}").render(@context) + end + + def test_filter_with_keyword_arguments + @context['surname'] = 'john' + @context['input'] = 'hello %{first_name}, %{last_name}' + @context.add_filters(SubstituteFilter) + output = Template.parse(%({{ input | substitute: first_name: surname, last_name: 'doe' }})).render(@context) + assert_equal 'hello john, doe', output + end + + def test_override_object_method_in_filter + assert_equal "tap overridden", Template.parse("{{var | tap}}").render!({ 'var' => 1000 }, filters: [OverrideObjectMethodFilter]) + + # tap still treated as a non-existent filter + assert_equal "1000", Template.parse("{{var | tap}}").render!({ 'var' => 1000 }) + end +end + +class FiltersInTemplate < Minitest::Test + include Liquid + + def test_local_global + with_global_filter(MoneyFilter) do + assert_equal " 1000$ ", Template.parse("{{1000 | money}}").render!(nil, nil) + assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, filters: CanadianMoneyFilter) + assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, filters: [CanadianMoneyFilter]) + end + end + + def test_local_filter_with_deprecated_syntax + assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, CanadianMoneyFilter) + assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, [CanadianMoneyFilter]) + end +end # FiltersTest + +class TestObject < Liquid::Drop + attr_accessor :a + def initialize(a) + @a = a + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/hash_ordering_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/hash_ordering_test.rb new file mode 100644 index 0000000..dfc1c29 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/hash_ordering_test.rb @@ -0,0 +1,23 @@ +require 'test_helper' + +class HashOrderingTest < Minitest::Test + module MoneyFilter + def money(input) + sprintf(' %d$ ', input) + end + end + + module CanadianMoneyFilter + def money(input) + sprintf(' %d$ CAD ', input) + end + end + + include Liquid + + def test_global_register_order + with_global_filter(MoneyFilter, CanadianMoneyFilter) do + assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render(nil, nil) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/output_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/output_test.rb new file mode 100644 index 0000000..b4cf9d7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/output_test.rb @@ -0,0 +1,123 @@ +require 'test_helper' + +module FunnyFilter + def make_funny(input) + 'LOL' + end + + def cite_funny(input) + "LOL: #{input}" + end + + def add_smiley(input, smiley = ":-)") + "#{input} #{smiley}" + end + + def add_tag(input, tag = "p", id = "foo") + %(<#{tag} id="#{id}">#{input}) + end + + def paragraph(input) + "

#{input}

" + end + + def link_to(name, url) + %(#{name}) + end +end + +class OutputTest < Minitest::Test + include Liquid + + def setup + @assigns = { + 'best_cars' => 'bmw', + 'car' => { 'bmw' => 'good', 'gm' => 'bad' } + } + end + + def test_variable + text = %( {{best_cars}} ) + + expected = %( bmw ) + assert_equal expected, Template.parse(text).render!(@assigns) + end + + def test_variable_traversing_with_two_brackets + text = %({{ site.data.menu[include.menu][include.locale] }}) + assert_equal "it works!", Template.parse(text).render!( + "site" => { "data" => { "menu" => { "foo" => { "bar" => "it works!" } } } }, + "include" => { "menu" => "foo", "locale" => "bar" } + ) + end + + def test_variable_traversing + text = %( {{car.bmw}} {{car.gm}} {{car.bmw}} ) + + expected = %( good bad good ) + assert_equal expected, Template.parse(text).render!(@assigns) + end + + def test_variable_piping + text = %( {{ car.gm | make_funny }} ) + expected = %( LOL ) + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_variable_piping_with_input + text = %( {{ car.gm | cite_funny }} ) + expected = %( LOL: bad ) + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_variable_piping_with_args + text = %! {{ car.gm | add_smiley : ':-(' }} ! + expected = %| bad :-( | + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_variable_piping_with_no_args + text = %( {{ car.gm | add_smiley }} ) + expected = %| bad :-) | + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_multiple_variable_piping_with_args + text = %! {{ car.gm | add_smiley : ':-(' | add_smiley : ':-('}} ! + expected = %| bad :-( :-( | + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_variable_piping_with_multiple_args + text = %( {{ car.gm | add_tag : 'span', 'bar'}} ) + expected = %( bad ) + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_variable_piping_with_variable_args + text = %( {{ car.gm | add_tag : 'span', car.bmw}} ) + expected = %( bad ) + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_multiple_pipings + text = %( {{ best_cars | cite_funny | paragraph }} ) + expected = %(

LOL: bmw

) + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end + + def test_link_to + text = %( {{ 'Typo' | link_to: 'http://typo.leetsoft.com' }} ) + expected = %( Typo ) + + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) + end +end # OutputTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/parse_tree_visitor_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/parse_tree_visitor_test.rb new file mode 100644 index 0000000..933dbc3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/parse_tree_visitor_test.rb @@ -0,0 +1,247 @@ +# frozen_string_literal: true + +require 'test_helper' + +class ParseTreeVisitorTest < Minitest::Test + include Liquid + + def test_variable + assert_equal( + ["test"], + visit(%({{ test }})) + ) + end + + def test_varible_with_filter + assert_equal( + ["test", "infilter"], + visit(%({{ test | split: infilter }})) + ) + end + + def test_dynamic_variable + assert_equal( + ["test", "inlookup"], + visit(%({{ test[inlookup] }})) + ) + end + + def test_if_condition + assert_equal( + ["test"], + visit(%({% if test %}{% endif %})) + ) + end + + def test_complex_if_condition + assert_equal( + ["test"], + visit(%({% if 1 == 1 and 2 == test %}{% endif %})) + ) + end + + def test_if_body + assert_equal( + ["test"], + visit(%({% if 1 == 1 %}{{ test }}{% endif %})) + ) + end + + def test_unless_condition + assert_equal( + ["test"], + visit(%({% unless test %}{% endunless %})) + ) + end + + def test_complex_unless_condition + assert_equal( + ["test"], + visit(%({% unless 1 == 1 and 2 == test %}{% endunless %})) + ) + end + + def test_unless_body + assert_equal( + ["test"], + visit(%({% unless 1 == 1 %}{{ test }}{% endunless %})) + ) + end + + def test_elsif_condition + assert_equal( + ["test"], + visit(%({% if 1 == 1 %}{% elsif test %}{% endif %})) + ) + end + + def test_complex_elsif_condition + assert_equal( + ["test"], + visit(%({% if 1 == 1 %}{% elsif 1 == 1 and 2 == test %}{% endif %})) + ) + end + + def test_elsif_body + assert_equal( + ["test"], + visit(%({% if 1 == 1 %}{% elsif 2 == 2 %}{{ test }}{% endif %})) + ) + end + + def test_else_body + assert_equal( + ["test"], + visit(%({% if 1 == 1 %}{% else %}{{ test }}{% endif %})) + ) + end + + def test_case_left + assert_equal( + ["test"], + visit(%({% case test %}{% endcase %})) + ) + end + + def test_case_condition + assert_equal( + ["test"], + visit(%({% case 1 %}{% when test %}{% endcase %})) + ) + end + + def test_case_when_body + assert_equal( + ["test"], + visit(%({% case 1 %}{% when 2 %}{{ test }}{% endcase %})) + ) + end + + def test_case_else_body + assert_equal( + ["test"], + visit(%({% case 1 %}{% else %}{{ test }}{% endcase %})) + ) + end + + def test_for_in + assert_equal( + ["test"], + visit(%({% for x in test %}{% endfor %})) + ) + end + + def test_for_limit + assert_equal( + ["test"], + visit(%({% for x in (1..5) limit: test %}{% endfor %})) + ) + end + + def test_for_offset + assert_equal( + ["test"], + visit(%({% for x in (1..5) offset: test %}{% endfor %})) + ) + end + + def test_for_body + assert_equal( + ["test"], + visit(%({% for x in (1..5) %}{{ test }}{% endfor %})) + ) + end + + def test_tablerow_in + assert_equal( + ["test"], + visit(%({% tablerow x in test %}{% endtablerow %})) + ) + end + + def test_tablerow_limit + assert_equal( + ["test"], + visit(%({% tablerow x in (1..5) limit: test %}{% endtablerow %})) + ) + end + + def test_tablerow_offset + assert_equal( + ["test"], + visit(%({% tablerow x in (1..5) offset: test %}{% endtablerow %})) + ) + end + + def test_tablerow_body + assert_equal( + ["test"], + visit(%({% tablerow x in (1..5) %}{{ test }}{% endtablerow %})) + ) + end + + def test_cycle + assert_equal( + ["test"], + visit(%({% cycle test %})) + ) + end + + def test_assign + assert_equal( + ["test"], + visit(%({% assign x = test %})) + ) + end + + def test_capture + assert_equal( + ["test"], + visit(%({% capture x %}{{ test }}{% endcapture %})) + ) + end + + def test_include + assert_equal( + ["test"], + visit(%({% include test %})) + ) + end + + def test_include_with + assert_equal( + ["test"], + visit(%({% include "hai" with test %})) + ) + end + + def test_include_for + assert_equal( + ["test"], + visit(%({% include "hai" for test %})) + ) + end + + def test_preserve_tree_structure + assert_equal( + [[nil, [ + [nil, [[nil, [["other", []]]]]], + ["test", []], + ["xs", []] + ]]], + traversal(%({% for x in xs offset: test %}{{ other }}{% endfor %})).visit + ) + end + + private + + def traversal(template) + ParseTreeVisitor + .for(Template.parse(template).root) + .add_callback_for(VariableLookup) { |node| node.name } # rubocop:disable Style/SymbolProc + end + + def visit(template) + traversal(template).visit.flatten.compact + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/parsing_quirks_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/parsing_quirks_test.rb new file mode 100644 index 0000000..29cb6d6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/parsing_quirks_test.rb @@ -0,0 +1,122 @@ +require 'test_helper' + +class ParsingQuirksTest < Minitest::Test + include Liquid + + def test_parsing_css + text = " div { font-weight: bold; } " + assert_equal text, Template.parse(text).render! + end + + def test_raise_on_single_close_bracet + assert_raises(SyntaxError) do + Template.parse("text {{method} oh nos!") + end + end + + def test_raise_on_label_and_no_close_bracets + assert_raises(SyntaxError) do + Template.parse("TEST {{ ") + end + end + + def test_raise_on_label_and_no_close_bracets_percent + assert_raises(SyntaxError) do + Template.parse("TEST {% ") + end + end + + def test_error_on_empty_filter + assert Template.parse("{{test}}") + + with_error_mode(:lax) do + assert Template.parse("{{|test}}") + end + + with_error_mode(:strict) do + assert_raises(SyntaxError) { Template.parse("{{|test}}") } + assert_raises(SyntaxError) { Template.parse("{{test |a|b|}}") } + end + end + + def test_meaningless_parens_error + with_error_mode(:strict) do + assert_raises(SyntaxError) do + markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false" + Template.parse("{% if #{markup} %} YES {% endif %}") + end + end + end + + def test_unexpected_characters_syntax_error + with_error_mode(:strict) do + assert_raises(SyntaxError) do + markup = "true && false" + Template.parse("{% if #{markup} %} YES {% endif %}") + end + assert_raises(SyntaxError) do + markup = "false || true" + Template.parse("{% if #{markup} %} YES {% endif %}") + end + end + end + + def test_no_error_on_lax_empty_filter + assert Template.parse("{{test |a|b|}}", error_mode: :lax) + assert Template.parse("{{test}}", error_mode: :lax) + assert Template.parse("{{|test|}}", error_mode: :lax) + end + + def test_meaningless_parens_lax + with_error_mode(:lax) do + assigns = { 'b' => 'bar', 'c' => 'baz' } + markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false" + assert_template_result(' YES ', "{% if #{markup} %} YES {% endif %}", assigns) + end + end + + def test_unexpected_characters_silently_eat_logic_lax + with_error_mode(:lax) do + markup = "true && false" + assert_template_result(' YES ', "{% if #{markup} %} YES {% endif %}") + markup = "false || true" + assert_template_result('', "{% if #{markup} %} YES {% endif %}") + end + end + + def test_raise_on_invalid_tag_delimiter + assert_raises(Liquid::SyntaxError) do + Template.new.parse('{% end %}') + end + end + + def test_unanchored_filter_arguments + with_error_mode(:lax) do + assert_template_result('hi', "{{ 'hi there' | split$$$:' ' | first }}") + + assert_template_result('x', "{{ 'X' | downcase) }}") + + # After the messed up quotes a filter without parameters (reverse) should work + # but one with parameters (remove) shouldn't be detected. + assert_template_result('here', "{{ 'hi there' | split:\"t\"\" | reverse | first}}") + assert_template_result('hi ', "{{ 'hi there' | split:\"t\"\" | remove:\"i\" | first}}") + end + end + + def test_invalid_variables_work + with_error_mode(:lax) do + assert_template_result('bar', "{% assign 123foo = 'bar' %}{{ 123foo }}") + assert_template_result('123', "{% assign 123 = 'bar' %}{{ 123 }}") + end + end + + def test_extra_dots_in_ranges + with_error_mode(:lax) do + assert_template_result('12345', "{% for i in (1...5) %}{{ i }}{% endfor %}") + end + end + + def test_contains_in_id + assert_template_result(' YES ', '{% if containsallshipments == true %} YES {% endif %}', 'containsallshipments' => true) + end +end # ParsingQuirksTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/render_profiling_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/render_profiling_test.rb new file mode 100644 index 0000000..d0111e7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/render_profiling_test.rb @@ -0,0 +1,154 @@ +require 'test_helper' + +class RenderProfilingTest < Minitest::Test + include Liquid + + class ProfilingFileSystem + def read_template_file(template_path) + "Rendering template {% assign template_name = '#{template_path}'%}\n{{ template_name }}" + end + end + + def setup + Liquid::Template.file_system = ProfilingFileSystem.new + end + + def test_template_allows_flagging_profiling + t = Template.parse("{{ 'a string' | upcase }}") + t.render! + + assert_nil t.profiler + end + + def test_parse_makes_available_simple_profiling + t = Template.parse("{{ 'a string' | upcase }}", profile: true) + t.render! + + assert_equal 1, t.profiler.length + + node = t.profiler[0] + assert_equal " 'a string' | upcase ", node.code + end + + def test_render_ignores_raw_strings_when_profiling + t = Template.parse("This is raw string\nstuff\nNewline", profile: true) + t.render! + + assert_equal 0, t.profiler.length + end + + def test_profiling_includes_line_numbers_of_liquid_nodes + t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", profile: true) + t.render! + assert_equal 2, t.profiler.length + + # {{ 'a string' | upcase }} + assert_equal 1, t.profiler[0].line_number + # {{ increment test }} + assert_equal 2, t.profiler[1].line_number + end + + def test_profiling_includes_line_numbers_of_included_partials + t = Template.parse("{% include 'a_template' %}", profile: true) + t.render! + + included_children = t.profiler[0].children + + # {% assign template_name = 'a_template' %} + assert_equal 1, included_children[0].line_number + # {{ template_name }} + assert_equal 2, included_children[1].line_number + end + + def test_profiling_times_the_rendering_of_tokens + t = Template.parse("{% include 'a_template' %}", profile: true) + t.render! + + node = t.profiler[0] + refute_nil node.render_time + end + + def test_profiling_times_the_entire_render + t = Template.parse("{% include 'a_template' %}", profile: true) + t.render! + + assert t.profiler.total_render_time >= 0, "Total render time was not calculated" + end + + def test_profiling_uses_include_to_mark_children + t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", profile: true) + t.render! + + include_node = t.profiler[1] + assert_equal 2, include_node.children.length + end + + def test_profiling_marks_children_with_the_name_of_included_partial + t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", profile: true) + t.render! + + include_node = t.profiler[1] + include_node.children.each do |child| + assert_equal "a_template", child.partial + end + end + + def test_profiling_supports_multiple_templates + t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'b_template' %}", profile: true) + t.render! + + a_template = t.profiler[1] + a_template.children.each do |child| + assert_equal "a_template", child.partial + end + + b_template = t.profiler[2] + b_template.children.each do |child| + assert_equal "b_template", child.partial + end + end + + def test_profiling_supports_rendering_the_same_partial_multiple_times + t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'a_template' %}", profile: true) + t.render! + + a_template1 = t.profiler[1] + a_template1.children.each do |child| + assert_equal "a_template", child.partial + end + + a_template2 = t.profiler[2] + a_template2.children.each do |child| + assert_equal "a_template", child.partial + end + end + + def test_can_iterate_over_each_profiling_entry + t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", profile: true) + t.render! + + timing_count = 0 + t.profiler.each do |timing| + timing_count += 1 + end + + assert_equal 2, timing_count + end + + def test_profiling_marks_children_of_if_blocks + t = Template.parse("{% if true %} {% increment test %} {{ test }} {% endif %}", profile: true) + t.render! + + assert_equal 1, t.profiler.length + assert_equal 2, t.profiler[0].children.length + end + + def test_profiling_marks_children_of_for_blocks + t = Template.parse("{% for item in collection %} {{ item }} {% endfor %}", profile: true) + t.render!({ "collection" => ["one", "two"] }) + + assert_equal 1, t.profiler.length + # Will profile each invocation of the for block + assert_equal 2, t.profiler[0].children.length + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/security_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/security_test.rb new file mode 100644 index 0000000..f603ff0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/security_test.rb @@ -0,0 +1,80 @@ +require 'test_helper' + +module SecurityFilter + def add_one(input) + "#{input} + 1" + end +end + +class SecurityTest < Minitest::Test + include Liquid + + def setup + @assigns = {} + end + + def test_no_instance_eval + text = %( {{ '1+1' | instance_eval }} ) + expected = %( 1+1 ) + + assert_equal expected, Template.parse(text).render!(@assigns) + end + + def test_no_existing_instance_eval + text = %( {{ '1+1' | __instance_eval__ }} ) + expected = %( 1+1 ) + + assert_equal expected, Template.parse(text).render!(@assigns) + end + + def test_no_instance_eval_after_mixing_in_new_filter + text = %( {{ '1+1' | instance_eval }} ) + expected = %( 1+1 ) + + assert_equal expected, Template.parse(text).render!(@assigns) + end + + def test_no_instance_eval_later_in_chain + text = %( {{ '1+1' | add_one | instance_eval }} ) + expected = %( 1+1 + 1 ) + + assert_equal expected, Template.parse(text).render!(@assigns, filters: SecurityFilter) + end + + def test_does_not_add_filters_to_symbol_table + current_symbols = Symbol.all_symbols + + test = %( {{ "some_string" | a_bad_filter }} ) + + template = Template.parse(test) + assert_equal [], (Symbol.all_symbols - current_symbols) + + template.render! + assert_equal [], (Symbol.all_symbols - current_symbols) + end + + def test_does_not_add_drop_methods_to_symbol_table + current_symbols = Symbol.all_symbols + + assigns = { 'drop' => Drop.new } + assert_equal "", Template.parse("{{ drop.custom_method_1 }}", assigns).render! + assert_equal "", Template.parse("{{ drop.custom_method_2 }}", assigns).render! + assert_equal "", Template.parse("{{ drop.custom_method_3 }}", assigns).render! + + assert_equal [], (Symbol.all_symbols - current_symbols) + end + + def test_max_depth_nested_blocks_does_not_raise_exception + depth = Liquid::Block::MAX_DEPTH + code = "{% if true %}" * depth + "rendered" + "{% endif %}" * depth + assert_equal "rendered", Template.parse(code).render! + end + + def test_more_than_max_depth_nested_blocks_raises_exception + depth = Liquid::Block::MAX_DEPTH + 1 + code = "{% if true %}" * depth + "rendered" + "{% endif %}" * depth + assert_raises(Liquid::StackLevelError) do + Template.parse(code).render! + end + end +end # SecurityTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/standard_filter_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/standard_filter_test.rb new file mode 100644 index 0000000..6090951 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/standard_filter_test.rb @@ -0,0 +1,776 @@ +# encoding: utf-8 + +require 'test_helper' + +class Filters + include Liquid::StandardFilters +end + +class TestThing + attr_reader :foo + + def initialize + @foo = 0 + end + + def to_s + "woot: #{@foo}" + end + + def [](whatever) + to_s + end + + def to_liquid + @foo += 1 + self + end +end + +class TestDrop < Liquid::Drop + def test + "testfoo" + end +end + +class TestEnumerable < Liquid::Drop + include Enumerable + + def each(&block) + [ { "foo" => 1, "bar" => 2 }, { "foo" => 2, "bar" => 1 }, { "foo" => 3, "bar" => 3 } ].each(&block) + end +end + +class NumberLikeThing < Liquid::Drop + def initialize(amount) + @amount = amount + end + + def to_number + @amount + end +end + +class StandardFiltersTest < Minitest::Test + include Liquid + + def setup + @filters = Filters.new + end + + def test_size + assert_equal 3, @filters.size([1, 2, 3]) + assert_equal 0, @filters.size([]) + assert_equal 0, @filters.size(nil) + end + + def test_downcase + assert_equal 'testing', @filters.downcase("Testing") + assert_equal '', @filters.downcase(nil) + end + + def test_upcase + assert_equal 'TESTING', @filters.upcase("Testing") + assert_equal '', @filters.upcase(nil) + end + + def test_slice + assert_equal 'oob', @filters.slice('foobar', 1, 3) + assert_equal 'oobar', @filters.slice('foobar', 1, 1000) + assert_equal '', @filters.slice('foobar', 1, 0) + assert_equal 'o', @filters.slice('foobar', 1, 1) + assert_equal 'bar', @filters.slice('foobar', 3, 3) + assert_equal 'ar', @filters.slice('foobar', -2, 2) + assert_equal 'ar', @filters.slice('foobar', -2, 1000) + assert_equal 'r', @filters.slice('foobar', -1) + assert_equal '', @filters.slice(nil, 0) + assert_equal '', @filters.slice('foobar', 100, 10) + assert_equal '', @filters.slice('foobar', -100, 10) + assert_equal 'oob', @filters.slice('foobar', '1', '3') + assert_raises(Liquid::ArgumentError) do + @filters.slice('foobar', nil) + end + assert_raises(Liquid::ArgumentError) do + @filters.slice('foobar', 0, "") + end + end + + def test_slice_on_arrays + input = 'foobar'.split(//) + assert_equal %w(o o b), @filters.slice(input, 1, 3) + assert_equal %w(o o b a r), @filters.slice(input, 1, 1000) + assert_equal %w(), @filters.slice(input, 1, 0) + assert_equal %w(o), @filters.slice(input, 1, 1) + assert_equal %w(b a r), @filters.slice(input, 3, 3) + assert_equal %w(a r), @filters.slice(input, -2, 2) + assert_equal %w(a r), @filters.slice(input, -2, 1000) + assert_equal %w(r), @filters.slice(input, -1) + assert_equal %w(), @filters.slice(input, 100, 10) + assert_equal %w(), @filters.slice(input, -100, 10) + end + + def test_truncate + assert_equal '1234...', @filters.truncate('1234567890', 7) + assert_equal '1234567890', @filters.truncate('1234567890', 20) + assert_equal '...', @filters.truncate('1234567890', 0) + assert_equal '1234567890', @filters.truncate('1234567890') + assert_equal "测试...", @filters.truncate("测试测试测试测试", 5) + assert_equal '12341', @filters.truncate("1234567890", 5, 1) + end + + def test_split + assert_equal ['12', '34'], @filters.split('12~34', '~') + assert_equal ['A? ', ' ,Z'], @filters.split('A? ~ ~ ~ ,Z', '~ ~ ~') + assert_equal ['A?Z'], @filters.split('A?Z', '~') + assert_equal [], @filters.split(nil, ' ') + assert_equal ['A', 'Z'], @filters.split('A1Z', 1) + end + + def test_escape + assert_equal '<strong>', @filters.escape('') + assert_equal '1', @filters.escape(1) + assert_equal '2001-02-03', @filters.escape(Date.new(2001, 2, 3)) + assert_nil @filters.escape(nil) + end + + def test_h + assert_equal '<strong>', @filters.h('') + assert_equal '1', @filters.h(1) + assert_equal '2001-02-03', @filters.h(Date.new(2001, 2, 3)) + assert_nil @filters.h(nil) + end + + def test_escape_once + assert_equal '<strong>Hulk</strong>', @filters.escape_once('<strong>Hulk') + end + + def test_url_encode + assert_equal 'foo%2B1%40example.com', @filters.url_encode('foo+1@example.com') + assert_equal '1', @filters.url_encode(1) + assert_equal '2001-02-03', @filters.url_encode(Date.new(2001, 2, 3)) + assert_nil @filters.url_encode(nil) + end + + def test_url_decode + assert_equal 'foo bar', @filters.url_decode('foo+bar') + assert_equal 'foo bar', @filters.url_decode('foo%20bar') + assert_equal 'foo+1@example.com', @filters.url_decode('foo%2B1%40example.com') + assert_equal '1', @filters.url_decode(1) + assert_equal '2001-02-03', @filters.url_decode(Date.new(2001, 2, 3)) + assert_nil @filters.url_decode(nil) + exception = assert_raises Liquid::ArgumentError do + @filters.url_decode('%ff') + end + assert_equal 'Liquid error: invalid byte sequence in UTF-8', exception.message + end + + def test_truncatewords + assert_equal 'one two three', @filters.truncatewords('one two three', 4) + assert_equal 'one two...', @filters.truncatewords('one two three', 2) + assert_equal 'one two three', @filters.truncatewords('one two three') + assert_equal 'Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13”...', @filters.truncatewords('Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13” x 16” x 10.5” high) with cover.', 15) + assert_equal "测试测试测试测试", @filters.truncatewords('测试测试测试测试', 5) + assert_equal 'one two1', @filters.truncatewords("one two three", 2, 1) + end + + def test_strip_html + assert_equal 'test', @filters.strip_html("
test
") + assert_equal 'test', @filters.strip_html("
test
") + assert_equal '', @filters.strip_html("") + assert_equal '', @filters.strip_html("") + assert_equal 'test', @filters.strip_html("test
") + assert_equal 'test', @filters.strip_html("test") + assert_equal '', @filters.strip_html(nil) + + # Quirk of the existing implementation + assert_equal 'foo;', @filters.strip_html("<<") + end + + def test_join + assert_equal '1 2 3 4', @filters.join([1, 2, 3, 4]) + assert_equal '1 - 2 - 3 - 4', @filters.join([1, 2, 3, 4], ' - ') + assert_equal '1121314', @filters.join([1, 2, 3, 4], 1) + end + + def test_sort + assert_equal [1, 2, 3, 4], @filters.sort([4, 3, 2, 1]) + assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], @filters.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") + end + + def test_sort_with_nils + assert_equal [1, 2, 3, 4, nil], @filters.sort([nil, 4, 3, 2, 1]) + assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }, {}], @filters.sort([{ "a" => 4 }, { "a" => 3 }, {}, { "a" => 1 }, { "a" => 2 }], "a") + end + + def test_sort_when_property_is_sometimes_missing_puts_nils_last + input = [ + { "price" => 4, "handle" => "alpha" }, + { "handle" => "beta" }, + { "price" => 1, "handle" => "gamma" }, + { "handle" => "delta" }, + { "price" => 2, "handle" => "epsilon" } + ] + expectation = [ + { "price" => 1, "handle" => "gamma" }, + { "price" => 2, "handle" => "epsilon" }, + { "price" => 4, "handle" => "alpha" }, + { "handle" => "delta" }, + { "handle" => "beta" } + ] + assert_equal expectation, @filters.sort(input, "price") + end + + def test_sort_natural + assert_equal ["a", "B", "c", "D"], @filters.sort_natural(["c", "D", "a", "B"]) + assert_equal [{ "a" => "a" }, { "a" => "B" }, { "a" => "c" }, { "a" => "D" }], @filters.sort_natural([{ "a" => "D" }, { "a" => "c" }, { "a" => "a" }, { "a" => "B" }], "a") + end + + def test_sort_natural_with_nils + assert_equal ["a", "B", "c", "D", nil], @filters.sort_natural([nil, "c", "D", "a", "B"]) + assert_equal [{ "a" => "a" }, { "a" => "B" }, { "a" => "c" }, { "a" => "D" }, {}], @filters.sort_natural([{ "a" => "D" }, { "a" => "c" }, {}, { "a" => "a" }, { "a" => "B" }], "a") + end + + def test_sort_natural_when_property_is_sometimes_missing_puts_nils_last + input = [ + { "price" => "4", "handle" => "alpha" }, + { "handle" => "beta" }, + { "price" => "1", "handle" => "gamma" }, + { "handle" => "delta" }, + { "price" => 2, "handle" => "epsilon" } + ] + expectation = [ + { "price" => "1", "handle" => "gamma" }, + { "price" => 2, "handle" => "epsilon" }, + { "price" => "4", "handle" => "alpha" }, + { "handle" => "delta" }, + { "handle" => "beta" } + ] + assert_equal expectation, @filters.sort_natural(input, "price") + end + + def test_sort_natural_case_check + input = [ + { "key" => "X" }, + { "key" => "Y" }, + { "key" => "Z" }, + { "fake" => "t" }, + { "key" => "a" }, + { "key" => "b" }, + { "key" => "c" } + ] + expectation = [ + { "key" => "a" }, + { "key" => "b" }, + { "key" => "c" }, + { "key" => "X" }, + { "key" => "Y" }, + { "key" => "Z" }, + { "fake" => "t" } + ] + assert_equal expectation, @filters.sort_natural(input, "key") + assert_equal ["a", "b", "c", "X", "Y", "Z"], @filters.sort_natural(["X", "Y", "Z", "a", "b", "c"]) + end + + def test_sort_empty_array + assert_equal [], @filters.sort([], "a") + end + + def test_sort_invalid_property + foo = [ + [1], + [2], + [3] + ] + + assert_raises Liquid::ArgumentError do + @filters.sort(foo, "bar") + end + end + + def test_sort_natural_empty_array + assert_equal [], @filters.sort_natural([], "a") + end + + def test_sort_natural_invalid_property + foo = [ + [1], + [2], + [3] + ] + + assert_raises Liquid::ArgumentError do + @filters.sort_natural(foo, "bar") + end + end + + def test_legacy_sort_hash + assert_equal [{ a: 1, b: 2 }], @filters.sort({ a: 1, b: 2 }) + end + + def test_numerical_vs_lexicographical_sort + assert_equal [2, 10], @filters.sort([10, 2]) + assert_equal [{ "a" => 2 }, { "a" => 10 }], @filters.sort([{ "a" => 10 }, { "a" => 2 }], "a") + assert_equal ["10", "2"], @filters.sort(["10", "2"]) + assert_equal [{ "a" => "10" }, { "a" => "2" }], @filters.sort([{ "a" => "10" }, { "a" => "2" }], "a") + end + + def test_uniq + assert_equal ["foo"], @filters.uniq("foo") + assert_equal [1, 3, 2, 4], @filters.uniq([1, 1, 3, 2, 3, 1, 4, 3, 2, 1]) + assert_equal [{ "a" => 1 }, { "a" => 3 }, { "a" => 2 }], @filters.uniq([{ "a" => 1 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") + testdrop = TestDrop.new + assert_equal [testdrop], @filters.uniq([testdrop, TestDrop.new], 'test') + end + + def test_uniq_empty_array + assert_equal [], @filters.uniq([], "a") + end + + def test_uniq_invalid_property + foo = [ + [1], + [2], + [3] + ] + + assert_raises Liquid::ArgumentError do + @filters.uniq(foo, "bar") + end + end + + def test_compact_empty_array + assert_equal [], @filters.compact([], "a") + end + + def test_compact_invalid_property + foo = [ + [1], + [2], + [3] + ] + + assert_raises Liquid::ArgumentError do + @filters.compact(foo, "bar") + end + end + + def test_reverse + assert_equal [4, 3, 2, 1], @filters.reverse([1, 2, 3, 4]) + end + + def test_legacy_reverse_hash + assert_equal [{ a: 1, b: 2 }], @filters.reverse(a: 1, b: 2) + end + + def test_map + assert_equal [1, 2, 3, 4], @filters.map([{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], 'a') + assert_template_result 'abc', "{{ ary | map:'foo' | map:'bar' }}", + 'ary' => [{ 'foo' => { 'bar' => 'a' } }, { 'foo' => { 'bar' => 'b' } }, { 'foo' => { 'bar' => 'c' } }] + end + + def test_map_doesnt_call_arbitrary_stuff + assert_template_result "", '{{ "foo" | map: "__id__" }}' + assert_template_result "", '{{ "foo" | map: "inspect" }}' + end + + def test_map_calls_to_liquid + t = TestThing.new + assert_template_result "woot: 1", '{{ foo | map: "whatever" }}', "foo" => [t] + end + + def test_map_on_hashes + assert_template_result "4217", '{{ thing | map: "foo" | map: "bar" }}', + "thing" => { "foo" => [ { "bar" => 42 }, { "bar" => 17 } ] } + end + + def test_legacy_map_on_hashes_with_dynamic_key + template = "{% assign key = 'foo' %}{{ thing | map: key | map: 'bar' }}" + hash = { "foo" => { "bar" => 42 } } + assert_template_result "42", template, "thing" => hash + end + + def test_sort_calls_to_liquid + t = TestThing.new + Liquid::Template.parse('{{ foo | sort: "whatever" }}').render("foo" => [t]) + assert t.foo > 0 + end + + def test_map_over_proc + drop = TestDrop.new + p = proc{ drop } + templ = '{{ procs | map: "test" }}' + assert_template_result "testfoo", templ, "procs" => [p] + end + + def test_map_over_drops_returning_procs + drops = [ + { + "proc" => ->{ "foo" }, + }, + { + "proc" => ->{ "bar" }, + }, + ] + templ = '{{ drops | map: "proc" }}' + assert_template_result "foobar", templ, "drops" => drops + end + + def test_map_works_on_enumerables + assert_template_result "123", '{{ foo | map: "foo" }}', "foo" => TestEnumerable.new + end + + def test_map_returns_empty_on_2d_input_array + foo = [ + [1], + [2], + [3] + ] + + assert_raises Liquid::ArgumentError do + @filters.map(foo, "bar") + end + end + + def test_map_returns_empty_with_no_property + foo = [ + [1], + [2], + [3] + ] + assert_raises Liquid::ArgumentError do + @filters.map(foo, nil) + end + end + + def test_sort_works_on_enumerables + assert_template_result "213", '{{ foo | sort: "bar" | map: "foo" }}', "foo" => TestEnumerable.new + end + + def test_first_and_last_call_to_liquid + assert_template_result 'foobar', '{{ foo | first }}', 'foo' => [ThingWithToLiquid.new] + assert_template_result 'foobar', '{{ foo | last }}', 'foo' => [ThingWithToLiquid.new] + end + + def test_truncate_calls_to_liquid + assert_template_result "wo...", '{{ foo | truncate: 5 }}', "foo" => TestThing.new + end + + def test_date + assert_equal 'May', @filters.date(Time.parse("2006-05-05 10:00:00"), "%B") + assert_equal 'June', @filters.date(Time.parse("2006-06-05 10:00:00"), "%B") + assert_equal 'July', @filters.date(Time.parse("2006-07-05 10:00:00"), "%B") + + assert_equal 'May', @filters.date("2006-05-05 10:00:00", "%B") + assert_equal 'June', @filters.date("2006-06-05 10:00:00", "%B") + assert_equal 'July', @filters.date("2006-07-05 10:00:00", "%B") + + assert_equal '2006-07-05 10:00:00', @filters.date("2006-07-05 10:00:00", "") + assert_equal '2006-07-05 10:00:00', @filters.date("2006-07-05 10:00:00", "") + assert_equal '2006-07-05 10:00:00', @filters.date("2006-07-05 10:00:00", "") + assert_equal '2006-07-05 10:00:00', @filters.date("2006-07-05 10:00:00", nil) + + assert_equal '07/05/2006', @filters.date("2006-07-05 10:00:00", "%m/%d/%Y") + + assert_equal "07/16/2004", @filters.date("Fri Jul 16 01:00:00 2004", "%m/%d/%Y") + assert_equal Date.today.year.to_s, @filters.date('now', '%Y') + assert_equal Date.today.year.to_s, @filters.date('today', '%Y') + assert_equal Date.today.year.to_s, @filters.date('Today', '%Y') + + assert_nil @filters.date(nil, "%B") + + assert_equal '', @filters.date('', "%B") + + with_timezone("UTC") do + assert_equal "07/05/2006", @filters.date(1152098955, "%m/%d/%Y") + assert_equal "07/05/2006", @filters.date("1152098955", "%m/%d/%Y") + end + end + + def test_first_last + assert_equal 1, @filters.first([1, 2, 3]) + assert_equal 3, @filters.last([1, 2, 3]) + assert_nil @filters.first([]) + assert_nil @filters.last([]) + end + + def test_replace + assert_equal '2 2 2 2', @filters.replace('1 1 1 1', '1', 2) + assert_equal '2 2 2 2', @filters.replace('1 1 1 1', 1, 2) + assert_equal '2 1 1 1', @filters.replace_first('1 1 1 1', '1', 2) + assert_equal '2 1 1 1', @filters.replace_first('1 1 1 1', 1, 2) + assert_template_result '2 1 1 1', "{{ '1 1 1 1' | replace_first: '1', 2 }}" + end + + def test_remove + assert_equal ' ', @filters.remove("a a a a", 'a') + assert_equal ' ', @filters.remove("1 1 1 1", 1) + assert_equal 'a a a', @filters.remove_first("a a a a", 'a ') + assert_equal ' 1 1 1', @filters.remove_first("1 1 1 1", 1) + assert_template_result 'a a a', "{{ 'a a a a' | remove_first: 'a ' }}" + end + + def test_pipes_in_string_arguments + assert_template_result 'foobar', "{{ 'foo|bar' | remove: '|' }}" + end + + def test_strip + assert_template_result 'ab c', "{{ source | strip }}", 'source' => " ab c " + assert_template_result 'ab c', "{{ source | strip }}", 'source' => " \tab c \n \t" + end + + def test_lstrip + assert_template_result 'ab c ', "{{ source | lstrip }}", 'source' => " ab c " + assert_template_result "ab c \n \t", "{{ source | lstrip }}", 'source' => " \tab c \n \t" + end + + def test_rstrip + assert_template_result " ab c", "{{ source | rstrip }}", 'source' => " ab c " + assert_template_result " \tab c", "{{ source | rstrip }}", 'source' => " \tab c \n \t" + end + + def test_strip_newlines + assert_template_result 'abc', "{{ source | strip_newlines }}", 'source' => "a\nb\nc" + assert_template_result 'abc', "{{ source | strip_newlines }}", 'source' => "a\r\nb\nc" + end + + def test_newlines_to_br + assert_template_result "a
\nb
\nc", "{{ source | newline_to_br }}", 'source' => "a\nb\nc" + end + + def test_plus + assert_template_result "2", "{{ 1 | plus:1 }}" + assert_template_result "2.0", "{{ '1' | plus:'1.0' }}" + + assert_template_result "5", "{{ price | plus:'2' }}", 'price' => NumberLikeThing.new(3) + end + + def test_minus + assert_template_result "4", "{{ input | minus:operand }}", 'input' => 5, 'operand' => 1 + assert_template_result "2.3", "{{ '4.3' | minus:'2' }}" + + assert_template_result "5", "{{ price | minus:'2' }}", 'price' => NumberLikeThing.new(7) + end + + def test_abs + assert_template_result "17", "{{ 17 | abs }}" + assert_template_result "17", "{{ -17 | abs }}" + assert_template_result "17", "{{ '17' | abs }}" + assert_template_result "17", "{{ '-17' | abs }}" + assert_template_result "0", "{{ 0 | abs }}" + assert_template_result "0", "{{ '0' | abs }}" + assert_template_result "17.42", "{{ 17.42 | abs }}" + assert_template_result "17.42", "{{ -17.42 | abs }}" + assert_template_result "17.42", "{{ '17.42' | abs }}" + assert_template_result "17.42", "{{ '-17.42' | abs }}" + end + + def test_times + assert_template_result "12", "{{ 3 | times:4 }}" + assert_template_result "0", "{{ 'foo' | times:4 }}" + assert_template_result "6", "{{ '2.1' | times:3 | replace: '.','-' | plus:0}}" + assert_template_result "7.25", "{{ 0.0725 | times:100 }}" + assert_template_result "-7.25", '{{ "-0.0725" | times:100 }}' + assert_template_result "7.25", '{{ "-0.0725" | times: -100 }}' + assert_template_result "4", "{{ price | times:2 }}", 'price' => NumberLikeThing.new(2) + end + + def test_divided_by + assert_template_result "4", "{{ 12 | divided_by:3 }}" + assert_template_result "4", "{{ 14 | divided_by:3 }}" + + assert_template_result "5", "{{ 15 | divided_by:3 }}" + assert_equal "Liquid error: divided by 0", Template.parse("{{ 5 | divided_by:0 }}").render + + assert_template_result "0.5", "{{ 2.0 | divided_by:4 }}" + assert_raises(Liquid::ZeroDivisionError) do + assert_template_result "4", "{{ 1 | modulo: 0 }}" + end + + assert_template_result "5", "{{ price | divided_by:2 }}", 'price' => NumberLikeThing.new(10) + end + + def test_modulo + assert_template_result "1", "{{ 3 | modulo:2 }}" + assert_raises(Liquid::ZeroDivisionError) do + assert_template_result "4", "{{ 1 | modulo: 0 }}" + end + + assert_template_result "1", "{{ price | modulo:2 }}", 'price' => NumberLikeThing.new(3) + end + + def test_round + assert_template_result "5", "{{ input | round }}", 'input' => 4.6 + assert_template_result "4", "{{ '4.3' | round }}" + assert_template_result "4.56", "{{ input | round: 2 }}", 'input' => 4.5612 + assert_raises(Liquid::FloatDomainError) do + assert_template_result "4", "{{ 1.0 | divided_by: 0.0 | round }}" + end + + assert_template_result "5", "{{ price | round }}", 'price' => NumberLikeThing.new(4.6) + assert_template_result "4", "{{ price | round }}", 'price' => NumberLikeThing.new(4.3) + end + + def test_ceil + assert_template_result "5", "{{ input | ceil }}", 'input' => 4.6 + assert_template_result "5", "{{ '4.3' | ceil }}" + assert_raises(Liquid::FloatDomainError) do + assert_template_result "4", "{{ 1.0 | divided_by: 0.0 | ceil }}" + end + + assert_template_result "5", "{{ price | ceil }}", 'price' => NumberLikeThing.new(4.6) + end + + def test_floor + assert_template_result "4", "{{ input | floor }}", 'input' => 4.6 + assert_template_result "4", "{{ '4.3' | floor }}" + assert_raises(Liquid::FloatDomainError) do + assert_template_result "4", "{{ 1.0 | divided_by: 0.0 | floor }}" + end + + assert_template_result "5", "{{ price | floor }}", 'price' => NumberLikeThing.new(5.4) + end + + def test_at_most + assert_template_result "4", "{{ 5 | at_most:4 }}" + assert_template_result "5", "{{ 5 | at_most:5 }}" + assert_template_result "5", "{{ 5 | at_most:6 }}" + + assert_template_result "4.5", "{{ 4.5 | at_most:5 }}" + assert_template_result "5", "{{ width | at_most:5 }}", 'width' => NumberLikeThing.new(6) + assert_template_result "4", "{{ width | at_most:5 }}", 'width' => NumberLikeThing.new(4) + assert_template_result "4", "{{ 5 | at_most: width }}", 'width' => NumberLikeThing.new(4) + end + + def test_at_least + assert_template_result "5", "{{ 5 | at_least:4 }}" + assert_template_result "5", "{{ 5 | at_least:5 }}" + assert_template_result "6", "{{ 5 | at_least:6 }}" + + assert_template_result "5", "{{ 4.5 | at_least:5 }}" + assert_template_result "6", "{{ width | at_least:5 }}", 'width' => NumberLikeThing.new(6) + assert_template_result "5", "{{ width | at_least:5 }}", 'width' => NumberLikeThing.new(4) + assert_template_result "6", "{{ 5 | at_least: width }}", 'width' => NumberLikeThing.new(6) + end + + def test_append + assigns = { 'a' => 'bc', 'b' => 'd' } + assert_template_result('bcd', "{{ a | append: 'd'}}", assigns) + assert_template_result('bcd', "{{ a | append: b}}", assigns) + end + + def test_concat + assert_equal [1, 2, 3, 4], @filters.concat([1, 2], [3, 4]) + assert_equal [1, 2, 'a'], @filters.concat([1, 2], ['a']) + assert_equal [1, 2, 10], @filters.concat([1, 2], [10]) + + assert_raises(Liquid::ArgumentError, "concat filter requires an array argument") do + @filters.concat([1, 2], 10) + end + end + + def test_prepend + assigns = { 'a' => 'bc', 'b' => 'a' } + assert_template_result('abc', "{{ a | prepend: 'a'}}", assigns) + assert_template_result('abc', "{{ a | prepend: b}}", assigns) + end + + def test_default + assert_equal "foo", @filters.default("foo", "bar") + assert_equal "bar", @filters.default(nil, "bar") + assert_equal "bar", @filters.default("", "bar") + assert_equal "bar", @filters.default(false, "bar") + assert_equal "bar", @filters.default([], "bar") + assert_equal "bar", @filters.default({}, "bar") + end + + def test_cannot_access_private_methods + assert_template_result('a', "{{ 'a' | to_number }}") + end + + def test_date_raises_nothing + assert_template_result('', "{{ '' | date: '%D' }}") + assert_template_result('abc', "{{ 'abc' | date: '%D' }}") + end + + def test_where + input = [ + { "handle" => "alpha", "ok" => true }, + { "handle" => "beta", "ok" => false }, + { "handle" => "gamma", "ok" => false }, + { "handle" => "delta", "ok" => true } + ] + + expectation = [ + { "handle" => "alpha", "ok" => true }, + { "handle" => "delta", "ok" => true } + ] + + assert_equal expectation, @filters.where(input, "ok", true) + assert_equal expectation, @filters.where(input, "ok") + end + + def test_where_no_key_set + input = [ + { "handle" => "alpha", "ok" => true }, + { "handle" => "beta" }, + { "handle" => "gamma" }, + { "handle" => "delta", "ok" => true } + ] + + expectation = [ + { "handle" => "alpha", "ok" => true }, + { "handle" => "delta", "ok" => true } + ] + + assert_equal expectation, @filters.where(input, "ok", true) + assert_equal expectation, @filters.where(input, "ok") + end + + def test_where_non_array_map_input + assert_equal [{ "a" => "ok" }], @filters.where({ "a" => "ok" }, "a", "ok") + assert_equal [], @filters.where({ "a" => "not ok" }, "a", "ok") + end + + def test_where_indexable_but_non_map_value + assert_raises(Liquid::ArgumentError) { @filters.where(1, "ok", true) } + assert_raises(Liquid::ArgumentError) { @filters.where(1, "ok") } + end + + def test_where_non_boolean_value + input = [ + { "message" => "Bonjour!", "language" => "French" }, + { "message" => "Hello!", "language" => "English" }, + { "message" => "Hallo!", "language" => "German" } + ] + + assert_equal [{ "message" => "Bonjour!", "language" => "French" }], @filters.where(input, "language", "French") + assert_equal [{ "message" => "Hallo!", "language" => "German" }], @filters.where(input, "language", "German") + assert_equal [{ "message" => "Hello!", "language" => "English" }], @filters.where(input, "language", "English") + end + + def test_where_array_of_only_unindexable_values + assert_nil @filters.where([nil], "ok", true) + assert_nil @filters.where([nil], "ok") + end + + def test_where_no_target_value + input = [ + { "foo" => false }, + { "foo" => true }, + { "foo" => "for sure" }, + { "bar" => true } + ] + + assert_equal [{ "foo" => true }, { "foo" => "for sure" }], @filters.where(input, "foo") + end + + private + + def with_timezone(tz) + old_tz = ENV['TZ'] + ENV['TZ'] = tz + yield + ensure + ENV['TZ'] = old_tz + end +end # StandardFiltersTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/break_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/break_tag_test.rb new file mode 100644 index 0000000..0fbde83 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/break_tag_test.rb @@ -0,0 +1,15 @@ +require 'test_helper' + +class BreakTagTest < Minitest::Test + include Liquid + + # tests that no weird errors are raised if break is called outside of a + # block + def test_break_with_no_block + assigns = { 'i' => 1 } + markup = '{% break %}' + expected = '' + + assert_template_result(expected, markup, assigns) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/continue_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/continue_tag_test.rb new file mode 100644 index 0000000..ce4c158 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/continue_tag_test.rb @@ -0,0 +1,15 @@ +require 'test_helper' + +class ContinueTagTest < Minitest::Test + include Liquid + + # tests that no weird errors are raised if continue is called outside of a + # block + def test_continue_with_no_block + assigns = {} + markup = '{% continue %}' + expected = '' + + assert_template_result(expected, markup, assigns) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/for_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/for_tag_test.rb new file mode 100644 index 0000000..cb7a822 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/for_tag_test.rb @@ -0,0 +1,410 @@ +require 'test_helper' + +class ThingWithValue < Liquid::Drop + def value + 3 + end +end + +class ForTagTest < Minitest::Test + include Liquid + + def test_for + assert_template_result(' yo yo yo yo ', '{%for item in array%} yo {%endfor%}', 'array' => [1, 2, 3, 4]) + assert_template_result('yoyo', '{%for item in array%}yo{%endfor%}', 'array' => [1, 2]) + assert_template_result(' yo ', '{%for item in array%} yo {%endfor%}', 'array' => [1]) + assert_template_result('', '{%for item in array%}{%endfor%}', 'array' => [1, 2]) + expected = < [1, 2, 3]) + end + + def test_for_reversed + assigns = { 'array' => [ 1, 2, 3] } + assert_template_result('321', '{%for item in array reversed %}{{item}}{%endfor%}', assigns) + end + + def test_for_with_range + assert_template_result(' 1 2 3 ', '{%for item in (1..3) %} {{item}} {%endfor%}') + + assert_raises(Liquid::ArgumentError) do + Template.parse('{% for i in (a..2) %}{% endfor %}').render!("a" => [1, 2]) + end + + assert_template_result(' 0 1 2 3 ', '{% for item in (a..3) %} {{item}} {% endfor %}', "a" => "invalid integer") + end + + def test_for_with_variable_range + assert_template_result(' 1 2 3 ', '{%for item in (1..foobar) %} {{item}} {%endfor%}', "foobar" => 3) + end + + def test_for_with_hash_value_range + foobar = { "value" => 3 } + assert_template_result(' 1 2 3 ', '{%for item in (1..foobar.value) %} {{item}} {%endfor%}', "foobar" => foobar) + end + + def test_for_with_drop_value_range + foobar = ThingWithValue.new + assert_template_result(' 1 2 3 ', '{%for item in (1..foobar.value) %} {{item}} {%endfor%}', "foobar" => foobar) + end + + def test_for_with_variable + assert_template_result(' 1 2 3 ', '{%for item in array%} {{item}} {%endfor%}', 'array' => [1, 2, 3]) + assert_template_result('123', '{%for item in array%}{{item}}{%endfor%}', 'array' => [1, 2, 3]) + assert_template_result('123', '{% for item in array %}{{item}}{% endfor %}', 'array' => [1, 2, 3]) + assert_template_result('abcd', '{%for item in array%}{{item}}{%endfor%}', 'array' => ['a', 'b', 'c', 'd']) + assert_template_result('a b c', '{%for item in array%}{{item}}{%endfor%}', 'array' => ['a', ' ', 'b', ' ', 'c']) + assert_template_result('abc', '{%for item in array%}{{item}}{%endfor%}', 'array' => ['a', '', 'b', '', 'c']) + end + + def test_for_helpers + assigns = { 'array' => [1, 2, 3] } + assert_template_result(' 1/3 2/3 3/3 ', + '{%for item in array%} {{forloop.index}}/{{forloop.length}} {%endfor%}', + assigns) + assert_template_result(' 1 2 3 ', '{%for item in array%} {{forloop.index}} {%endfor%}', assigns) + assert_template_result(' 0 1 2 ', '{%for item in array%} {{forloop.index0}} {%endfor%}', assigns) + assert_template_result(' 2 1 0 ', '{%for item in array%} {{forloop.rindex0}} {%endfor%}', assigns) + assert_template_result(' 3 2 1 ', '{%for item in array%} {{forloop.rindex}} {%endfor%}', assigns) + assert_template_result(' true false false ', '{%for item in array%} {{forloop.first}} {%endfor%}', assigns) + assert_template_result(' false false true ', '{%for item in array%} {{forloop.last}} {%endfor%}', assigns) + end + + def test_for_and_if + assigns = { 'array' => [1, 2, 3] } + assert_template_result('+--', + '{%for item in array%}{% if forloop.first %}+{% else %}-{% endif %}{%endfor%}', + assigns) + end + + def test_for_else + assert_template_result('+++', '{%for item in array%}+{%else%}-{%endfor%}', 'array' => [1, 2, 3]) + assert_template_result('-', '{%for item in array%}+{%else%}-{%endfor%}', 'array' => []) + assert_template_result('-', '{%for item in array%}+{%else%}-{%endfor%}', 'array' => nil) + end + + def test_limiting + assigns = { 'array' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] } + assert_template_result('12', '{%for i in array limit:2 %}{{ i }}{%endfor%}', assigns) + assert_template_result('1234', '{%for i in array limit:4 %}{{ i }}{%endfor%}', assigns) + assert_template_result('3456', '{%for i in array limit:4 offset:2 %}{{ i }}{%endfor%}', assigns) + assert_template_result('3456', '{%for i in array limit: 4 offset: 2 %}{{ i }}{%endfor%}', assigns) + end + + def test_dynamic_variable_limiting + assigns = { 'array' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] } + assigns['limit'] = 2 + assigns['offset'] = 2 + + assert_template_result('34', '{%for i in array limit: limit offset: offset %}{{ i }}{%endfor%}', assigns) + end + + def test_nested_for + assigns = { 'array' => [[1, 2], [3, 4], [5, 6]] } + assert_template_result('123456', '{%for item in array%}{%for i in item%}{{ i }}{%endfor%}{%endfor%}', assigns) + end + + def test_offset_only + assigns = { 'array' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] } + assert_template_result('890', '{%for i in array offset:7 %}{{ i }}{%endfor%}', assigns) + end + + def test_pause_resume + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] } } + markup = <<-MKUP + {%for i in array.items limit: 3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit: 3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit: 3 %}{{i}}{%endfor%} + MKUP + expected = <<-XPCTD + 123 + next + 456 + next + 789 + XPCTD + assert_template_result(expected, markup, assigns) + end + + def test_pause_resume_limit + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] } } + markup = <<-MKUP + {%for i in array.items limit:3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit:3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit:1 %}{{i}}{%endfor%} + MKUP + expected = <<-XPCTD + 123 + next + 456 + next + 7 + XPCTD + assert_template_result(expected, markup, assigns) + end + + def test_pause_resume_big_limit + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] } } + markup = <<-MKUP + {%for i in array.items limit:3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit:3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit:1000 %}{{i}}{%endfor%} + MKUP + expected = <<-XPCTD + 123 + next + 456 + next + 7890 + XPCTD + assert_template_result(expected, markup, assigns) + end + + def test_pause_resume_big_offset + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] } } + markup = '{%for i in array.items limit:3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit:3 %}{{i}}{%endfor%} + next + {%for i in array.items offset:continue limit:3 offset:1000 %}{{i}}{%endfor%}' + expected = '123 + next + 456 + next + ' + assert_template_result(expected, markup, assigns) + end + + def test_for_with_break + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] } } + + markup = '{% for i in array.items %}{% break %}{% endfor %}' + expected = "" + assert_template_result(expected, markup, assigns) + + markup = '{% for i in array.items %}{{ i }}{% break %}{% endfor %}' + expected = "1" + assert_template_result(expected, markup, assigns) + + markup = '{% for i in array.items %}{% break %}{{ i }}{% endfor %}' + expected = "" + assert_template_result(expected, markup, assigns) + + markup = '{% for i in array.items %}{{ i }}{% if i > 3 %}{% break %}{% endif %}{% endfor %}' + expected = "1234" + assert_template_result(expected, markup, assigns) + + # tests to ensure it only breaks out of the local for loop + # and not all of them. + assigns = { 'array' => [[1, 2], [3, 4], [5, 6]] } + markup = '{% for item in array %}' \ + '{% for i in item %}' \ + '{% if i == 1 %}' \ + '{% break %}' \ + '{% endif %}' \ + '{{ i }}' \ + '{% endfor %}' \ + '{% endfor %}' + expected = '3456' + assert_template_result(expected, markup, assigns) + + # test break does nothing when unreached + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5] } } + markup = '{% for i in array.items %}{% if i == 9999 %}{% break %}{% endif %}{{ i }}{% endfor %}' + expected = '12345' + assert_template_result(expected, markup, assigns) + end + + def test_for_with_continue + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5] } } + + markup = '{% for i in array.items %}{% continue %}{% endfor %}' + expected = "" + assert_template_result(expected, markup, assigns) + + markup = '{% for i in array.items %}{{ i }}{% continue %}{% endfor %}' + expected = "12345" + assert_template_result(expected, markup, assigns) + + markup = '{% for i in array.items %}{% continue %}{{ i }}{% endfor %}' + expected = "" + assert_template_result(expected, markup, assigns) + + markup = '{% for i in array.items %}{% if i > 3 %}{% continue %}{% endif %}{{ i }}{% endfor %}' + expected = "123" + assert_template_result(expected, markup, assigns) + + markup = '{% for i in array.items %}{% if i == 3 %}{% continue %}{% else %}{{ i }}{% endif %}{% endfor %}' + expected = "1245" + assert_template_result(expected, markup, assigns) + + # tests to ensure it only continues the local for loop and not all of them. + assigns = { 'array' => [[1, 2], [3, 4], [5, 6]] } + markup = '{% for item in array %}' \ + '{% for i in item %}' \ + '{% if i == 1 %}' \ + '{% continue %}' \ + '{% endif %}' \ + '{{ i }}' \ + '{% endfor %}' \ + '{% endfor %}' + expected = '23456' + assert_template_result(expected, markup, assigns) + + # test continue does nothing when unreached + assigns = { 'array' => { 'items' => [1, 2, 3, 4, 5] } } + markup = '{% for i in array.items %}{% if i == 9999 %}{% continue %}{% endif %}{{ i }}{% endfor %}' + expected = '12345' + assert_template_result(expected, markup, assigns) + end + + def test_for_tag_string + # ruby 1.8.7 "String".each => Enumerator with single "String" element. + # ruby 1.9.3 no longer supports .each on String though we mimic + # the functionality for backwards compatibility + + assert_template_result('test string', + '{%for val in string%}{{val}}{%endfor%}', + 'string' => "test string") + + assert_template_result('test string', + '{%for val in string limit:1%}{{val}}{%endfor%}', + 'string' => "test string") + + assert_template_result('val-string-1-1-0-1-0-true-true-test string', + '{%for val in string%}' \ + '{{forloop.name}}-' \ + '{{forloop.index}}-' \ + '{{forloop.length}}-' \ + '{{forloop.index0}}-' \ + '{{forloop.rindex}}-' \ + '{{forloop.rindex0}}-' \ + '{{forloop.first}}-' \ + '{{forloop.last}}-' \ + '{{val}}{%endfor%}', + 'string' => "test string") + end + + def test_for_parentloop_references_parent_loop + assert_template_result('1.1 1.2 1.3 2.1 2.2 2.3 ', + '{% for inner in outer %}{% for k in inner %}' \ + '{{ forloop.parentloop.index }}.{{ forloop.index }} ' \ + '{% endfor %}{% endfor %}', + 'outer' => [[1, 1, 1], [1, 1, 1]]) + end + + def test_for_parentloop_nil_when_not_present + assert_template_result('.1 .2 ', + '{% for inner in outer %}' \ + '{{ forloop.parentloop.index }}.{{ forloop.index }} ' \ + '{% endfor %}', + 'outer' => [[1, 1, 1], [1, 1, 1]]) + end + + def test_inner_for_over_empty_input + assert_template_result 'oo', '{% for a in (1..2) %}o{% for b in empty %}{% endfor %}{% endfor %}' + end + + def test_blank_string_not_iterable + assert_template_result('', "{% for char in characters %}I WILL NOT BE OUTPUT{% endfor %}", 'characters' => '') + end + + def test_bad_variable_naming_in_for_loop + assert_raises(Liquid::SyntaxError) do + Liquid::Template.parse('{% for a/b in x %}{% endfor %}') + end + end + + def test_spacing_with_variable_naming_in_for_loop + expected = '12345' + template = '{% for item in items %}{{item}}{% endfor %}' + assigns = { 'items' => [1, 2, 3, 4, 5] } + assert_template_result(expected, template, assigns) + end + + class LoaderDrop < Liquid::Drop + attr_accessor :each_called, :load_slice_called + + def initialize(data) + @data = data + end + + def each + @each_called = true + @data.each { |el| yield el } + end + + def load_slice(from, to) + @load_slice_called = true + @data[(from..to - 1)] + end + end + + def test_iterate_with_each_when_no_limit_applied + loader = LoaderDrop.new([1, 2, 3, 4, 5]) + assigns = { 'items' => loader } + expected = '12345' + template = '{% for item in items %}{{item}}{% endfor %}' + assert_template_result(expected, template, assigns) + assert loader.each_called + assert !loader.load_slice_called + end + + def test_iterate_with_load_slice_when_limit_applied + loader = LoaderDrop.new([1, 2, 3, 4, 5]) + assigns = { 'items' => loader } + expected = '1' + template = '{% for item in items limit:1 %}{{item}}{% endfor %}' + assert_template_result(expected, template, assigns) + assert !loader.each_called + assert loader.load_slice_called + end + + def test_iterate_with_load_slice_when_limit_and_offset_applied + loader = LoaderDrop.new([1, 2, 3, 4, 5]) + assigns = { 'items' => loader } + expected = '34' + template = '{% for item in items offset:2 limit:2 %}{{item}}{% endfor %}' + assert_template_result(expected, template, assigns) + assert !loader.each_called + assert loader.load_slice_called + end + + def test_iterate_with_load_slice_returns_same_results_as_without + loader = LoaderDrop.new([1, 2, 3, 4, 5]) + loader_assigns = { 'items' => loader } + array_assigns = { 'items' => [1, 2, 3, 4, 5] } + expected = '34' + template = '{% for item in items offset:2 limit:2 %}{{item}}{% endfor %}' + assert_template_result(expected, template, loader_assigns) + assert_template_result(expected, template, array_assigns) + end + + def test_for_cleans_up_registers + context = Context.new(ErrorDrop.new) + + assert_raises(StandardError) do + Liquid::Template.parse('{% for i in (1..2) %}{{ standard_error }}{% endfor %}').render!(context) + end + + assert context.registers[:for_stack].empty? + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/if_else_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/if_else_tag_test.rb new file mode 100644 index 0000000..45a5d3a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/if_else_tag_test.rb @@ -0,0 +1,188 @@ +require 'test_helper' + +class IfElseTagTest < Minitest::Test + include Liquid + + def test_if + assert_template_result(' ', ' {% if false %} this text should not go into the output {% endif %} ') + assert_template_result(' this text should go into the output ', + ' {% if true %} this text should go into the output {% endif %} ') + assert_template_result(' you rock ?', '{% if false %} you suck {% endif %} {% if true %} you rock {% endif %}?') + end + + def test_literal_comparisons + assert_template_result(' NO ', '{% assign v = false %}{% if v %} YES {% else %} NO {% endif %}') + assert_template_result(' YES ', '{% assign v = nil %}{% if v == nil %} YES {% else %} NO {% endif %}') + end + + def test_if_else + assert_template_result(' YES ', '{% if false %} NO {% else %} YES {% endif %}') + assert_template_result(' YES ', '{% if true %} YES {% else %} NO {% endif %}') + assert_template_result(' YES ', '{% if "foo" %} YES {% else %} NO {% endif %}') + end + + def test_if_boolean + assert_template_result(' YES ', '{% if var %} YES {% endif %}', 'var' => true) + end + + def test_if_or + assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => true) + assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => false) + assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => true) + assert_template_result('', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => false) + + assert_template_result(' YES ', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => true) + assert_template_result('', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => false) + end + + def test_if_or_with_operators + assert_template_result(' YES ', '{% if a == true or b == true %} YES {% endif %}', 'a' => true, 'b' => true) + assert_template_result(' YES ', '{% if a == true or b == false %} YES {% endif %}', 'a' => true, 'b' => true) + assert_template_result('', '{% if a == false or b == false %} YES {% endif %}', 'a' => true, 'b' => true) + end + + def test_comparison_of_strings_containing_and_or_or + awful_markup = "a == 'and' and b == 'or' and c == 'foo and bar' and d == 'bar or baz' and e == 'foo' and foo and bar" + assigns = { 'a' => 'and', 'b' => 'or', 'c' => 'foo and bar', 'd' => 'bar or baz', 'e' => 'foo', 'foo' => true, 'bar' => true } + assert_template_result(' YES ', "{% if #{awful_markup} %} YES {% endif %}", assigns) + end + + def test_comparison_of_expressions_starting_with_and_or_or + assigns = { 'order' => { 'items_count' => 0 }, 'android' => { 'name' => 'Roy' } } + assert_template_result("YES", + "{% if android.name == 'Roy' %}YES{% endif %}", + assigns) + assert_template_result("YES", + "{% if order.items_count == 0 %}YES{% endif %}", + assigns) + end + + def test_if_and + assert_template_result(' YES ', '{% if true and true %} YES {% endif %}') + assert_template_result('', '{% if false and true %} YES {% endif %}') + assert_template_result('', '{% if false and true %} YES {% endif %}') + end + + def test_hash_miss_generates_false + assert_template_result('', '{% if foo.bar %} NO {% endif %}', 'foo' => {}) + end + + def test_if_from_variable + assert_template_result('', '{% if var %} NO {% endif %}', 'var' => false) + assert_template_result('', '{% if var %} NO {% endif %}', 'var' => nil) + assert_template_result('', '{% if foo.bar %} NO {% endif %}', 'foo' => { 'bar' => false }) + assert_template_result('', '{% if foo.bar %} NO {% endif %}', 'foo' => {}) + assert_template_result('', '{% if foo.bar %} NO {% endif %}', 'foo' => nil) + assert_template_result('', '{% if foo.bar %} NO {% endif %}', 'foo' => true) + + assert_template_result(' YES ', '{% if var %} YES {% endif %}', 'var' => "text") + assert_template_result(' YES ', '{% if var %} YES {% endif %}', 'var' => true) + assert_template_result(' YES ', '{% if var %} YES {% endif %}', 'var' => 1) + assert_template_result(' YES ', '{% if var %} YES {% endif %}', 'var' => {}) + assert_template_result(' YES ', '{% if var %} YES {% endif %}', 'var' => []) + assert_template_result(' YES ', '{% if "foo" %} YES {% endif %}') + assert_template_result(' YES ', '{% if foo.bar %} YES {% endif %}', 'foo' => { 'bar' => true }) + assert_template_result(' YES ', '{% if foo.bar %} YES {% endif %}', 'foo' => { 'bar' => "text" }) + assert_template_result(' YES ', '{% if foo.bar %} YES {% endif %}', 'foo' => { 'bar' => 1 }) + assert_template_result(' YES ', '{% if foo.bar %} YES {% endif %}', 'foo' => { 'bar' => {} }) + assert_template_result(' YES ', '{% if foo.bar %} YES {% endif %}', 'foo' => { 'bar' => [] }) + + assert_template_result(' YES ', '{% if var %} NO {% else %} YES {% endif %}', 'var' => false) + assert_template_result(' YES ', '{% if var %} NO {% else %} YES {% endif %}', 'var' => nil) + assert_template_result(' YES ', '{% if var %} YES {% else %} NO {% endif %}', 'var' => true) + assert_template_result(' YES ', '{% if "foo" %} YES {% else %} NO {% endif %}', 'var' => "text") + + assert_template_result(' YES ', '{% if foo.bar %} NO {% else %} YES {% endif %}', 'foo' => { 'bar' => false }) + assert_template_result(' YES ', '{% if foo.bar %} YES {% else %} NO {% endif %}', 'foo' => { 'bar' => true }) + assert_template_result(' YES ', '{% if foo.bar %} YES {% else %} NO {% endif %}', 'foo' => { 'bar' => "text" }) + assert_template_result(' YES ', '{% if foo.bar %} NO {% else %} YES {% endif %}', 'foo' => { 'notbar' => true }) + assert_template_result(' YES ', '{% if foo.bar %} NO {% else %} YES {% endif %}', 'foo' => {}) + assert_template_result(' YES ', '{% if foo.bar %} NO {% else %} YES {% endif %}', 'notfoo' => { 'bar' => true }) + end + + def test_nested_if + assert_template_result('', '{% if false %}{% if false %} NO {% endif %}{% endif %}') + assert_template_result('', '{% if false %}{% if true %} NO {% endif %}{% endif %}') + assert_template_result('', '{% if true %}{% if false %} NO {% endif %}{% endif %}') + assert_template_result(' YES ', '{% if true %}{% if true %} YES {% endif %}{% endif %}') + + assert_template_result(' YES ', '{% if true %}{% if true %} YES {% else %} NO {% endif %}{% else %} NO {% endif %}') + assert_template_result(' YES ', '{% if true %}{% if false %} NO {% else %} YES {% endif %}{% else %} NO {% endif %}') + assert_template_result(' YES ', '{% if false %}{% if true %} NO {% else %} NONO {% endif %}{% else %} YES {% endif %}') + end + + def test_comparisons_on_null + assert_template_result('', '{% if null < 10 %} NO {% endif %}') + assert_template_result('', '{% if null <= 10 %} NO {% endif %}') + assert_template_result('', '{% if null >= 10 %} NO {% endif %}') + assert_template_result('', '{% if null > 10 %} NO {% endif %}') + + assert_template_result('', '{% if 10 < null %} NO {% endif %}') + assert_template_result('', '{% if 10 <= null %} NO {% endif %}') + assert_template_result('', '{% if 10 >= null %} NO {% endif %}') + assert_template_result('', '{% if 10 > null %} NO {% endif %}') + end + + def test_else_if + assert_template_result('0', '{% if 0 == 0 %}0{% elsif 1 == 1%}1{% else %}2{% endif %}') + assert_template_result('1', '{% if 0 != 0 %}0{% elsif 1 == 1%}1{% else %}2{% endif %}') + assert_template_result('2', '{% if 0 != 0 %}0{% elsif 1 != 1%}1{% else %}2{% endif %}') + + assert_template_result('elsif', '{% if false %}if{% elsif true %}elsif{% endif %}') + end + + def test_syntax_error_no_variable + assert_raises(SyntaxError){ assert_template_result('', '{% if jerry == 1 %}') } + end + + def test_syntax_error_no_expression + assert_raises(SyntaxError) { assert_template_result('', '{% if %}') } + end + + def test_if_with_custom_condition + original_op = Condition.operators['contains'] + Condition.operators['contains'] = :[] + + assert_template_result('yes', %({% if 'bob' contains 'o' %}yes{% endif %})) + assert_template_result('no', %({% if 'bob' contains 'f' %}yes{% else %}no{% endif %})) + ensure + Condition.operators['contains'] = original_op + end + + def test_operators_are_ignored_unless_isolated + original_op = Condition.operators['contains'] + Condition.operators['contains'] = :[] + + assert_template_result('yes', + %({% if 'gnomeslab-and-or-liquid' contains 'gnomeslab-and-or-liquid' %}yes{% endif %})) + ensure + Condition.operators['contains'] = original_op + end + + def test_operators_are_whitelisted + assert_raises(SyntaxError) do + assert_template_result('', %({% if 1 or throw or or 1 %}yes{% endif %})) + end + end + + def test_multiple_conditions + tpl = "{% if a or b and c %}true{% else %}false{% endif %}" + + tests = { + [true, true, true] => true, + [true, true, false] => true, + [true, false, true] => true, + [true, false, false] => true, + [false, true, true] => true, + [false, true, false] => false, + [false, false, true] => false, + [false, false, false] => false, + } + + tests.each do |vals, expected| + a, b, c = vals + assigns = { 'a' => a, 'b' => b, 'c' => c } + assert_template_result expected.to_s, tpl, assigns, assigns.to_s + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/include_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/include_tag_test.rb new file mode 100644 index 0000000..9c188d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/include_tag_test.rb @@ -0,0 +1,253 @@ +require 'test_helper' + +class TestFileSystem + def read_template_file(template_path) + case template_path + when "product" + "Product: {{ product.title }} " + + when "locale_variables" + "Locale: {{echo1}} {{echo2}}" + + when "variant" + "Variant: {{ variant.title }}" + + when "nested_template" + "{% include 'header' %} {% include 'body' %} {% include 'footer' %}" + + when "body" + "body {% include 'body_detail' %}" + + when "nested_product_template" + "Product: {{ nested_product_template.title }} {%include 'details'%} " + + when "recursively_nested_template" + "-{% include 'recursively_nested_template' %}" + + when "pick_a_source" + "from TestFileSystem" + + when 'assignments' + "{% assign foo = 'bar' %}" + + when 'break' + "{% break %}" + + else + template_path + end + end +end + +class OtherFileSystem + def read_template_file(template_path) + 'from OtherFileSystem' + end +end + +class CountingFileSystem + attr_reader :count + def read_template_file(template_path) + @count ||= 0 + @count += 1 + 'from CountingFileSystem' + end +end + +class CustomInclude < Liquid::Tag + Syntax = /(#{Liquid::QuotedFragment}+)(\s+(?:with|for)\s+(#{Liquid::QuotedFragment}+))?/o + + def initialize(tag_name, markup, tokens) + markup =~ Syntax + @template_name = $1 + super + end + + def parse(tokens) + end + + def render(context) + @template_name[1..-2] + end +end + +class IncludeTagTest < Minitest::Test + include Liquid + + def setup + Liquid::Template.file_system = TestFileSystem.new + end + + def test_include_tag_looks_for_file_system_in_registers_first + assert_equal 'from OtherFileSystem', + Template.parse("{% include 'pick_a_source' %}").render!({}, registers: { file_system: OtherFileSystem.new }) + end + + def test_include_tag_with + assert_template_result "Product: Draft 151cm ", + "{% include 'product' with products[0] %}", "products" => [ { 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' } ] + end + + def test_include_tag_with_default_name + assert_template_result "Product: Draft 151cm ", + "{% include 'product' %}", "product" => { 'title' => 'Draft 151cm' } + end + + def test_include_tag_for + assert_template_result "Product: Draft 151cm Product: Element 155cm ", + "{% include 'product' for products %}", "products" => [ { 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' } ] + end + + def test_include_tag_with_local_variables + assert_template_result "Locale: test123 ", "{% include 'locale_variables' echo1: 'test123' %}" + end + + def test_include_tag_with_multiple_local_variables + assert_template_result "Locale: test123 test321", + "{% include 'locale_variables' echo1: 'test123', echo2: 'test321' %}" + end + + def test_include_tag_with_multiple_local_variables_from_context + assert_template_result "Locale: test123 test321", + "{% include 'locale_variables' echo1: echo1, echo2: more_echos.echo2 %}", + 'echo1' => 'test123', 'more_echos' => { "echo2" => 'test321' } + end + + def test_included_templates_assigns_variables + assert_template_result "bar", "{% include 'assignments' %}{{ foo }}" + end + + def test_nested_include_tag + assert_template_result "body body_detail", "{% include 'body' %}" + + assert_template_result "header body body_detail footer", "{% include 'nested_template' %}" + end + + def test_nested_include_with_variable + assert_template_result "Product: Draft 151cm details ", + "{% include 'nested_product_template' with product %}", "product" => { "title" => 'Draft 151cm' } + + assert_template_result "Product: Draft 151cm details Product: Element 155cm details ", + "{% include 'nested_product_template' for products %}", "products" => [{ "title" => 'Draft 151cm' }, { "title" => 'Element 155cm' }] + end + + def test_recursively_included_template_does_not_produce_endless_loop + infinite_file_system = Class.new do + def read_template_file(template_path) + "-{% include 'loop' %}" + end + end + + Liquid::Template.file_system = infinite_file_system.new + + assert_raises(Liquid::StackLevelError) do + Template.parse("{% include 'loop' %}").render! + end + end + + def test_dynamically_choosen_template + assert_template_result "Test123", "{% include template %}", "template" => 'Test123' + assert_template_result "Test321", "{% include template %}", "template" => 'Test321' + + assert_template_result "Product: Draft 151cm ", "{% include template for product %}", + "template" => 'product', 'product' => { 'title' => 'Draft 151cm' } + end + + def test_include_tag_caches_second_read_of_same_partial + file_system = CountingFileSystem.new + assert_equal 'from CountingFileSystemfrom CountingFileSystem', + Template.parse("{% include 'pick_a_source' %}{% include 'pick_a_source' %}").render!({}, registers: { file_system: file_system }) + assert_equal 1, file_system.count + end + + def test_include_tag_doesnt_cache_partials_across_renders + file_system = CountingFileSystem.new + assert_equal 'from CountingFileSystem', + Template.parse("{% include 'pick_a_source' %}").render!({}, registers: { file_system: file_system }) + assert_equal 1, file_system.count + + assert_equal 'from CountingFileSystem', + Template.parse("{% include 'pick_a_source' %}").render!({}, registers: { file_system: file_system }) + assert_equal 2, file_system.count + end + + def test_include_tag_within_if_statement + assert_template_result "foo_if_true", "{% if true %}{% include 'foo_if_true' %}{% endif %}" + end + + def test_custom_include_tag + original_tag = Liquid::Template.tags['include'] + Liquid::Template.tags['include'] = CustomInclude + begin + assert_equal "custom_foo", + Template.parse("{% include 'custom_foo' %}").render! + ensure + Liquid::Template.tags['include'] = original_tag + end + end + + def test_custom_include_tag_within_if_statement + original_tag = Liquid::Template.tags['include'] + Liquid::Template.tags['include'] = CustomInclude + begin + assert_equal "custom_foo_if_true", + Template.parse("{% if true %}{% include 'custom_foo_if_true' %}{% endif %}").render! + ensure + Liquid::Template.tags['include'] = original_tag + end + end + + def test_does_not_add_error_in_strict_mode_for_missing_variable + Liquid::Template.file_system = TestFileSystem.new + + a = Liquid::Template.parse(' {% include "nested_template" %}') + a.render! + assert_empty a.errors + end + + def test_passing_options_to_included_templates + assert_raises(Liquid::SyntaxError) do + Template.parse("{% include template %}", error_mode: :strict).render!("template" => '{{ "X" || downcase }}') + end + with_error_mode(:lax) do + assert_equal 'x', Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: true).render!("template" => '{{ "X" || downcase }}') + end + assert_raises(Liquid::SyntaxError) do + Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: [:locale]).render!("template" => '{{ "X" || downcase }}') + end + with_error_mode(:lax) do + assert_equal 'x', Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: [:error_mode]).render!("template" => '{{ "X" || downcase }}') + end + end + + def test_render_raise_argument_error_when_template_is_undefined + assert_raises(Liquid::ArgumentError) do + template = Liquid::Template.parse('{% include undefined_variable %}') + template.render! + end + assert_raises(Liquid::ArgumentError) do + template = Liquid::Template.parse('{% include nil %}') + template.render! + end + end + + def test_including_via_variable_value + assert_template_result "from TestFileSystem", "{% assign page = 'pick_a_source' %}{% include page %}" + + assert_template_result "Product: Draft 151cm ", "{% assign page = 'product' %}{% include page %}", "product" => { 'title' => 'Draft 151cm' } + + assert_template_result "Product: Draft 151cm ", "{% assign page = 'product' %}{% include page for foo %}", "foo" => { 'title' => 'Draft 151cm' } + end + + def test_including_with_strict_variables + template = Liquid::Template.parse("{% include 'simple' %}", error_mode: :warn) + template.render(nil, strict_variables: true) + + assert_equal [], template.errors + end + + def test_break_through_include + assert_template_result "1", "{% for i in (1..3) %}{{ i }}{% break %}{{ i }}{% endfor %}" + assert_template_result "1", "{% for i in (1..3) %}{{ i }}{% include 'break' %}{{ i }}{% endfor %}" + end +end # IncludeTagTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/increment_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/increment_tag_test.rb new file mode 100644 index 0000000..97c51ac --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/increment_tag_test.rb @@ -0,0 +1,23 @@ +require 'test_helper' + +class IncrementTagTest < Minitest::Test + include Liquid + + def test_inc + assert_template_result('0', '{%increment port %}', {}) + assert_template_result('0 1', '{%increment port %} {%increment port%}', {}) + assert_template_result('0 0 1 2 1', + '{%increment port %} {%increment starboard%} ' \ + '{%increment port %} {%increment port%} ' \ + '{%increment starboard %}', {}) + end + + def test_dec + assert_template_result('9', '{%decrement port %}', { 'port' => 10 }) + assert_template_result('-1 -2', '{%decrement port %} {%decrement port%}', {}) + assert_template_result('1 5 2 2 5', + '{%increment port %} {%increment starboard%} ' \ + '{%increment port %} {%decrement port%} ' \ + '{%decrement starboard %}', { 'port' => 1, 'starboard' => 5 }) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/raw_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/raw_tag_test.rb new file mode 100644 index 0000000..634d052 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/raw_tag_test.rb @@ -0,0 +1,31 @@ +require 'test_helper' + +class RawTagTest < Minitest::Test + include Liquid + + def test_tag_in_raw + assert_template_result '{% comment %} test {% endcomment %}', + '{% raw %}{% comment %} test {% endcomment %}{% endraw %}' + end + + def test_output_in_raw + assert_template_result '{{ test }}', '{% raw %}{{ test }}{% endraw %}' + end + + def test_open_tag_in_raw + assert_template_result ' Foobar {% invalid ', '{% raw %} Foobar {% invalid {% endraw %}' + assert_template_result ' Foobar invalid %} ', '{% raw %} Foobar invalid %} {% endraw %}' + assert_template_result ' Foobar {{ invalid ', '{% raw %} Foobar {{ invalid {% endraw %}' + assert_template_result ' Foobar invalid }} ', '{% raw %} Foobar invalid }} {% endraw %}' + assert_template_result ' Foobar {% invalid {% {% endraw ', '{% raw %} Foobar {% invalid {% {% endraw {% endraw %}' + assert_template_result ' Foobar {% {% {% ', '{% raw %} Foobar {% {% {% {% endraw %}' + assert_template_result ' test {% raw %} {% endraw %}', '{% raw %} test {% raw %} {% {% endraw %}endraw %}' + assert_template_result ' Foobar {{ invalid 1', '{% raw %} Foobar {{ invalid {% endraw %}{{ 1 }}' + end + + def test_invalid_raw + assert_match_syntax_error(/tag was never closed/, '{% raw %} foo') + assert_match_syntax_error(/Valid syntax/, '{% raw } foo {% endraw %}') + assert_match_syntax_error(/Valid syntax/, '{% raw } foo %}{% endraw %}') + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/standard_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/standard_tag_test.rb new file mode 100644 index 0000000..4b4703a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/standard_tag_test.rb @@ -0,0 +1,296 @@ +require 'test_helper' + +class StandardTagTest < Minitest::Test + include Liquid + + def test_no_transform + assert_template_result('this text should come out of the template without change...', + 'this text should come out of the template without change...') + + assert_template_result('blah', 'blah') + assert_template_result('', '') + assert_template_result('|,.:', '|,.:') + assert_template_result('', '') + + text = %(this shouldnt see any transformation either but has multiple lines + as you can clearly see here ...) + assert_template_result(text, text) + end + + def test_has_a_block_which_does_nothing + assert_template_result(%(the comment block should be removed .. right?), + %(the comment block should be removed {%comment%} be gone.. {%endcomment%} .. right?)) + + assert_template_result('', '{%comment%}{%endcomment%}') + assert_template_result('', '{%comment%}{% endcomment %}') + assert_template_result('', '{% comment %}{%endcomment%}') + assert_template_result('', '{% comment %}{% endcomment %}') + assert_template_result('', '{%comment%}comment{%endcomment%}') + assert_template_result('', '{% comment %}comment{% endcomment %}') + assert_template_result('', '{% comment %} 1 {% comment %} 2 {% endcomment %} 3 {% endcomment %}') + + assert_template_result('', '{%comment%}{%blabla%}{%endcomment%}') + assert_template_result('', '{% comment %}{% blabla %}{% endcomment %}') + assert_template_result('', '{%comment%}{% endif %}{%endcomment%}') + assert_template_result('', '{% comment %}{% endwhatever %}{% endcomment %}') + assert_template_result('', '{% comment %}{% raw %} {{%%%%}} }} { {% endcomment %} {% comment {% endraw %} {% endcomment %}') + + assert_template_result('foobar', 'foo{%comment%}comment{%endcomment%}bar') + assert_template_result('foobar', 'foo{% comment %}comment{% endcomment %}bar') + assert_template_result('foobar', 'foo{%comment%} comment {%endcomment%}bar') + assert_template_result('foobar', 'foo{% comment %} comment {% endcomment %}bar') + + assert_template_result('foo bar', 'foo {%comment%} {%endcomment%} bar') + assert_template_result('foo bar', 'foo {%comment%}comment{%endcomment%} bar') + assert_template_result('foo bar', 'foo {%comment%} comment {%endcomment%} bar') + + assert_template_result('foobar', 'foo{%comment%} + {%endcomment%}bar') + end + + def test_hyphenated_assign + assigns = { 'a-b' => '1' } + assert_template_result('a-b:1 a-b:2', 'a-b:{{a-b}} {%assign a-b = 2 %}a-b:{{a-b}}', assigns) + end + + def test_assign_with_colon_and_spaces + assigns = { 'var' => { 'a:b c' => { 'paged' => '1' } } } + assert_template_result('var2: 1', '{%assign var2 = var["a:b c"].paged %}var2: {{var2}}', assigns) + end + + def test_capture + assigns = { 'var' => 'content' } + assert_template_result('content foo content foo ', + '{{ var2 }}{% capture var2 %}{{ var }} foo {% endcapture %}{{ var2 }}{{ var2 }}', + assigns) + end + + def test_capture_detects_bad_syntax + assert_raises(SyntaxError) do + assert_template_result('content foo content foo ', + '{{ var2 }}{% capture %}{{ var }} foo {% endcapture %}{{ var2 }}{{ var2 }}', + { 'var' => 'content' }) + end + end + + def test_case + assigns = { 'condition' => 2 } + assert_template_result(' its 2 ', + '{% case condition %}{% when 1 %} its 1 {% when 2 %} its 2 {% endcase %}', + assigns) + + assigns = { 'condition' => 1 } + assert_template_result(' its 1 ', + '{% case condition %}{% when 1 %} its 1 {% when 2 %} its 2 {% endcase %}', + assigns) + + assigns = { 'condition' => 3 } + assert_template_result('', + '{% case condition %}{% when 1 %} its 1 {% when 2 %} its 2 {% endcase %}', + assigns) + + assigns = { 'condition' => "string here" } + assert_template_result(' hit ', + '{% case condition %}{% when "string here" %} hit {% endcase %}', + assigns) + + assigns = { 'condition' => "bad string here" } + assert_template_result('', + '{% case condition %}{% when "string here" %} hit {% endcase %}',\ + assigns) + end + + def test_case_with_else + assigns = { 'condition' => 5 } + assert_template_result(' hit ', + '{% case condition %}{% when 5 %} hit {% else %} else {% endcase %}', + assigns) + + assigns = { 'condition' => 6 } + assert_template_result(' else ', + '{% case condition %}{% when 5 %} hit {% else %} else {% endcase %}', + assigns) + + assigns = { 'condition' => 6 } + assert_template_result(' else ', + '{% case condition %} {% when 5 %} hit {% else %} else {% endcase %}', + assigns) + end + + def test_case_on_size + assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => []) + assert_template_result('1', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1]) + assert_template_result('2', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1]) + assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1]) + assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1, 1]) + assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1, 1, 1]) + end + + def test_case_on_size_with_else + assert_template_result('else', + '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', + 'a' => []) + + assert_template_result('1', + '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', + 'a' => [1]) + + assert_template_result('2', + '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', + 'a' => [1, 1]) + + assert_template_result('else', + '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', + 'a' => [1, 1, 1]) + + assert_template_result('else', + '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', + 'a' => [1, 1, 1, 1]) + + assert_template_result('else', + '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', + 'a' => [1, 1, 1, 1, 1]) + end + + def test_case_on_length_with_else + assert_template_result('else', + '{% case a.empty? %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', + {}) + + assert_template_result('false', + '{% case false %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', + {}) + + assert_template_result('true', + '{% case true %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', + {}) + + assert_template_result('else', + '{% case NULL %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', + {}) + end + + def test_assign_from_case + # Example from the shopify forums + code = "{% case collection.handle %}{% when 'menswear-jackets' %}{% assign ptitle = 'menswear' %}{% when 'menswear-t-shirts' %}{% assign ptitle = 'menswear' %}{% else %}{% assign ptitle = 'womenswear' %}{% endcase %}{{ ptitle }}" + template = Liquid::Template.parse(code) + assert_equal "menswear", template.render!("collection" => { 'handle' => 'menswear-jackets' }) + assert_equal "menswear", template.render!("collection" => { 'handle' => 'menswear-t-shirts' }) + assert_equal "womenswear", template.render!("collection" => { 'handle' => 'x' }) + assert_equal "womenswear", template.render!("collection" => { 'handle' => 'y' }) + assert_equal "womenswear", template.render!("collection" => { 'handle' => 'z' }) + end + + def test_case_when_or + code = '{% case condition %}{% when 1 or 2 or 3 %} its 1 or 2 or 3 {% when 4 %} its 4 {% endcase %}' + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 1 }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 2 }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 3 }) + assert_template_result(' its 4 ', code, { 'condition' => 4 }) + assert_template_result('', code, { 'condition' => 5 }) + + code = '{% case condition %}{% when 1 or "string" or null %} its 1 or 2 or 3 {% when 4 %} its 4 {% endcase %}' + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 1 }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 'string' }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => nil }) + assert_template_result('', code, { 'condition' => 'something else' }) + end + + def test_case_when_comma + code = '{% case condition %}{% when 1, 2, 3 %} its 1 or 2 or 3 {% when 4 %} its 4 {% endcase %}' + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 1 }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 2 }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 3 }) + assert_template_result(' its 4 ', code, { 'condition' => 4 }) + assert_template_result('', code, { 'condition' => 5 }) + + code = '{% case condition %}{% when 1, "string", null %} its 1 or 2 or 3 {% when 4 %} its 4 {% endcase %}' + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 1 }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => 'string' }) + assert_template_result(' its 1 or 2 or 3 ', code, { 'condition' => nil }) + assert_template_result('', code, { 'condition' => 'something else' }) + end + + def test_assign + assert_template_result 'variable', '{% assign a = "variable"%}{{a}}' + end + + def test_assign_unassigned + assigns = { 'var' => 'content' } + assert_template_result('var2: var2:content', 'var2:{{var2}} {%assign var2 = var%} var2:{{var2}}', assigns) + end + + def test_assign_an_empty_string + assert_template_result '', '{% assign a = ""%}{{a}}' + end + + def test_assign_is_global + assert_template_result 'variable', '{%for i in (1..2) %}{% assign a = "variable"%}{% endfor %}{{a}}' + end + + def test_case_detects_bad_syntax + assert_raises(SyntaxError) do + assert_template_result('', '{% case false %}{% when %}true{% endcase %}', {}) + end + + assert_raises(SyntaxError) do + assert_template_result('', '{% case false %}{% huh %}true{% endcase %}', {}) + end + end + + def test_cycle + assert_template_result('one', '{%cycle "one", "two"%}') + assert_template_result('one two', '{%cycle "one", "two"%} {%cycle "one", "two"%}') + assert_template_result(' two', '{%cycle "", "two"%} {%cycle "", "two"%}') + + assert_template_result('one two one', '{%cycle "one", "two"%} {%cycle "one", "two"%} {%cycle "one", "two"%}') + + assert_template_result('text-align: left text-align: right', + '{%cycle "text-align: left", "text-align: right" %} {%cycle "text-align: left", "text-align: right"%}') + end + + def test_multiple_cycles + assert_template_result('1 2 1 1 2 3 1', + '{%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%}') + end + + def test_multiple_named_cycles + assert_template_result('one one two two one one', + '{%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %} {%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %} {%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %}') + end + + def test_multiple_named_cycles_with_names_from_context + assigns = { "var1" => 1, "var2" => 2 } + assert_template_result('one one two two one one', + '{%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %} {%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %} {%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %}', assigns) + end + + def test_size_of_array + assigns = { "array" => [1, 2, 3, 4] } + assert_template_result('array has 4 elements', "array has {{ array.size }} elements", assigns) + end + + def test_size_of_hash + assigns = { "hash" => { a: 1, b: 2, c: 3, d: 4 } } + assert_template_result('hash has 4 elements', "hash has {{ hash.size }} elements", assigns) + end + + def test_illegal_symbols + assert_template_result('', '{% if true == empty %}?{% endif %}', {}) + assert_template_result('', '{% if true == null %}?{% endif %}', {}) + assert_template_result('', '{% if empty == true %}?{% endif %}', {}) + assert_template_result('', '{% if null == true %}?{% endif %}', {}) + end + + def test_ifchanged + assigns = { 'array' => [ 1, 1, 2, 2, 3, 3] } + assert_template_result('123', '{%for item in array%}{%ifchanged%}{{item}}{% endifchanged %}{%endfor%}', assigns) + + assigns = { 'array' => [ 1, 1, 1, 1] } + assert_template_result('1', '{%for item in array%}{%ifchanged%}{{item}}{% endifchanged %}{%endfor%}', assigns) + end + + def test_multiline_tag + assert_template_result '0 1 2 3', "0{%\nfor i in (1..3)\n%} {{\ni\n}}{%\nendfor\n%}" + end +end # StandardTagTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/statements_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/statements_test.rb new file mode 100644 index 0000000..eeff166 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/statements_test.rb @@ -0,0 +1,111 @@ +require 'test_helper' + +class StatementsTest < Minitest::Test + include Liquid + + def test_true_eql_true + text = ' {% if true == true %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text + end + + def test_true_not_eql_true + text = ' {% if true != true %} true {% else %} false {% endif %} ' + assert_template_result ' false ', text + end + + def test_true_lq_true + text = ' {% if 0 > 0 %} true {% else %} false {% endif %} ' + assert_template_result ' false ', text + end + + def test_one_lq_zero + text = ' {% if 1 > 0 %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text + end + + def test_zero_lq_one + text = ' {% if 0 < 1 %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text + end + + def test_zero_lq_or_equal_one + text = ' {% if 0 <= 0 %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text + end + + def test_zero_lq_or_equal_one_involving_nil + text = ' {% if null <= 0 %} true {% else %} false {% endif %} ' + assert_template_result ' false ', text + + text = ' {% if 0 <= null %} true {% else %} false {% endif %} ' + assert_template_result ' false ', text + end + + def test_zero_lqq_or_equal_one + text = ' {% if 0 >= 0 %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text + end + + def test_strings + text = " {% if 'test' == 'test' %} true {% else %} false {% endif %} " + assert_template_result ' true ', text + end + + def test_strings_not_equal + text = " {% if 'test' != 'test' %} true {% else %} false {% endif %} " + assert_template_result ' false ', text + end + + def test_var_strings_equal + text = ' {% if var == "hello there!" %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text, 'var' => 'hello there!' + end + + def test_var_strings_are_not_equal + text = ' {% if "hello there!" == var %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text, 'var' => 'hello there!' + end + + def test_var_and_long_string_are_equal + text = " {% if var == 'hello there!' %} true {% else %} false {% endif %} " + assert_template_result ' true ', text, 'var' => 'hello there!' + end + + def test_var_and_long_string_are_equal_backwards + text = " {% if 'hello there!' == var %} true {% else %} false {% endif %} " + assert_template_result ' true ', text, 'var' => 'hello there!' + end + + # def test_is_nil + # text = %| {% if var != nil %} true {% else %} false {% end %} | + # @template.assigns = { 'var' => 'hello there!'} + # expected = %| true | + # assert_equal expected, @template.parse(text) + # end + + def test_is_collection_empty + text = ' {% if array == empty %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text, 'array' => [] + end + + def test_is_not_collection_empty + text = ' {% if array == empty %} true {% else %} false {% endif %} ' + assert_template_result ' false ', text, 'array' => [1, 2, 3] + end + + def test_nil + text = ' {% if var == nil %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text, 'var' => nil + + text = ' {% if var == null %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text, 'var' => nil + end + + def test_not_nil + text = ' {% if var != nil %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text, 'var' => 1 + + text = ' {% if var != null %} true {% else %} false {% endif %} ' + assert_template_result ' true ', text, 'var' => 1 + end +end # StatementsTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/table_row_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/table_row_test.rb new file mode 100644 index 0000000..d7bc14c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/table_row_test.rb @@ -0,0 +1,64 @@ +require 'test_helper' + +class TableRowTest < Minitest::Test + include Liquid + + class ArrayDrop < Liquid::Drop + include Enumerable + + def initialize(array) + @array = array + end + + def each(&block) + @array.each(&block) + end + end + + def test_table_row + assert_template_result("\n 1 2 3 \n 4 5 6 \n", + '{% tablerow n in numbers cols:3%} {{n}} {% endtablerow %}', + 'numbers' => [1, 2, 3, 4, 5, 6]) + + assert_template_result("\n\n", + '{% tablerow n in numbers cols:3%} {{n}} {% endtablerow %}', + 'numbers' => []) + end + + def test_table_row_with_different_cols + assert_template_result("\n 1 2 3 4 5 \n 6 \n", + '{% tablerow n in numbers cols:5%} {{n}} {% endtablerow %}', + 'numbers' => [1, 2, 3, 4, 5, 6]) + end + + def test_table_col_counter + assert_template_result("\n12\n12\n12\n", + '{% tablerow n in numbers cols:2%}{{tablerowloop.col}}{% endtablerow %}', + 'numbers' => [1, 2, 3, 4, 5, 6]) + end + + def test_quoted_fragment + assert_template_result("\n 1 2 3 \n 4 5 6 \n", + "{% tablerow n in collections.frontpage cols:3%} {{n}} {% endtablerow %}", + 'collections' => { 'frontpage' => [1, 2, 3, 4, 5, 6] }) + assert_template_result("\n 1 2 3 \n 4 5 6 \n", + "{% tablerow n in collections['frontpage'] cols:3%} {{n}} {% endtablerow %}", + 'collections' => { 'frontpage' => [1, 2, 3, 4, 5, 6] }) + end + + def test_enumerable_drop + assert_template_result("\n 1 2 3 \n 4 5 6 \n", + '{% tablerow n in numbers cols:3%} {{n}} {% endtablerow %}', + 'numbers' => ArrayDrop.new([1, 2, 3, 4, 5, 6])) + end + + def test_offset_and_limit + assert_template_result("\n 1 2 3 \n 4 5 6 \n", + '{% tablerow n in numbers cols:3 offset:1 limit:6%} {{n}} {% endtablerow %}', + 'numbers' => [0, 1, 2, 3, 4, 5, 6, 7]) + end + + def test_blank_string_not_iterable + assert_template_result("\n\n", "{% tablerow char in characters cols:3 %}I WILL NOT BE OUTPUT{% endtablerow %}", 'characters' => '') + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/unless_else_tag_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/unless_else_tag_test.rb new file mode 100644 index 0000000..c414a71 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/tags/unless_else_tag_test.rb @@ -0,0 +1,26 @@ +require 'test_helper' + +class UnlessElseTagTest < Minitest::Test + include Liquid + + def test_unless + assert_template_result(' ', ' {% unless true %} this text should not go into the output {% endunless %} ') + assert_template_result(' this text should go into the output ', + ' {% unless false %} this text should go into the output {% endunless %} ') + assert_template_result(' you rock ?', '{% unless true %} you suck {% endunless %} {% unless false %} you rock {% endunless %}?') + end + + def test_unless_else + assert_template_result(' YES ', '{% unless true %} NO {% else %} YES {% endunless %}') + assert_template_result(' YES ', '{% unless false %} YES {% else %} NO {% endunless %}') + assert_template_result(' YES ', '{% unless "foo" %} NO {% else %} YES {% endunless %}') + end + + def test_unless_in_loop + assert_template_result '23', '{% for i in choices %}{% unless i %}{{ forloop.index }}{% endunless %}{% endfor %}', 'choices' => [1, nil, false] + end + + def test_unless_else_in_loop + assert_template_result ' TRUE 2 3 ', '{% for i in choices %}{% unless i %} {{ forloop.index }} {% else %} TRUE {% endunless %}{% endfor %}', 'choices' => [1, nil, false] + end +end # UnlessElseTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/template_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/template_test.rb new file mode 100644 index 0000000..d10e1c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/template_test.rb @@ -0,0 +1,332 @@ +require 'test_helper' +require 'timeout' + +class TemplateContextDrop < Liquid::Drop + def liquid_method_missing(method) + method + end + + def foo + 'fizzbuzz' + end + + def baz + @context.registers['lulz'] + end +end + +class SomethingWithLength < Liquid::Drop + def length + nil + end +end + +class ErroneousDrop < Liquid::Drop + def bad_method + raise 'ruby error in drop' + end +end + +class DropWithUndefinedMethod < Liquid::Drop + def foo + 'foo' + end +end + +class TemplateTest < Minitest::Test + include Liquid + + def test_instance_assigns_persist_on_same_template_object_between_parses + t = Template.new + assert_equal 'from instance assigns', t.parse("{% assign foo = 'from instance assigns' %}{{ foo }}").render! + assert_equal 'from instance assigns', t.parse("{{ foo }}").render! + end + + def test_warnings_is_not_exponential_time + str = "false" + 100.times do + str = "{% if true %}true{% else %}#{str}{% endif %}" + end + + t = Template.parse(str) + assert_equal [], Timeout.timeout(1) { t.warnings } + end + + def test_instance_assigns_persist_on_same_template_parsing_between_renders + t = Template.new.parse("{{ foo }}{% assign foo = 'foo' %}{{ foo }}") + assert_equal 'foo', t.render! + assert_equal 'foofoo', t.render! + end + + def test_custom_assigns_do_not_persist_on_same_template + t = Template.new + assert_equal 'from custom assigns', t.parse("{{ foo }}").render!('foo' => 'from custom assigns') + assert_equal '', t.parse("{{ foo }}").render! + end + + def test_custom_assigns_squash_instance_assigns + t = Template.new + assert_equal 'from instance assigns', t.parse("{% assign foo = 'from instance assigns' %}{{ foo }}").render! + assert_equal 'from custom assigns', t.parse("{{ foo }}").render!('foo' => 'from custom assigns') + end + + def test_persistent_assigns_squash_instance_assigns + t = Template.new + assert_equal 'from instance assigns', t.parse("{% assign foo = 'from instance assigns' %}{{ foo }}").render! + t.assigns['foo'] = 'from persistent assigns' + assert_equal 'from persistent assigns', t.parse("{{ foo }}").render! + end + + def test_lambda_is_called_once_from_persistent_assigns_over_multiple_parses_and_renders + t = Template.new + t.assigns['number'] = -> { @global ||= 0; @global += 1 } + assert_equal '1', t.parse("{{number}}").render! + assert_equal '1', t.parse("{{number}}").render! + assert_equal '1', t.render! + @global = nil + end + + def test_lambda_is_called_once_from_custom_assigns_over_multiple_parses_and_renders + t = Template.new + assigns = { 'number' => -> { @global ||= 0; @global += 1 } } + assert_equal '1', t.parse("{{number}}").render!(assigns) + assert_equal '1', t.parse("{{number}}").render!(assigns) + assert_equal '1', t.render!(assigns) + @global = nil + end + + def test_resource_limits_works_with_custom_length_method + t = Template.parse("{% assign foo = bar %}") + t.resource_limits.render_length_limit = 42 + assert_equal "", t.render!("bar" => SomethingWithLength.new) + end + + def test_resource_limits_render_length + t = Template.parse("0123456789") + t.resource_limits.render_length_limit = 5 + assert_equal "Liquid error: Memory limits exceeded", t.render + assert t.resource_limits.reached? + + t.resource_limits.render_length_limit = 10 + assert_equal "0123456789", t.render! + refute_nil t.resource_limits.render_length + end + + def test_resource_limits_render_score + t = Template.parse("{% for a in (1..10) %} {% for a in (1..10) %} foo {% endfor %} {% endfor %}") + t.resource_limits.render_score_limit = 50 + assert_equal "Liquid error: Memory limits exceeded", t.render + assert t.resource_limits.reached? + + t = Template.parse("{% for a in (1..100) %} foo {% endfor %}") + t.resource_limits.render_score_limit = 50 + assert_equal "Liquid error: Memory limits exceeded", t.render + assert t.resource_limits.reached? + + t.resource_limits.render_score_limit = 200 + assert_equal (" foo " * 100), t.render! + refute_nil t.resource_limits.render_score + end + + def test_resource_limits_assign_score + t = Template.parse("{% assign foo = 42 %}{% assign bar = 23 %}") + t.resource_limits.assign_score_limit = 1 + assert_equal "Liquid error: Memory limits exceeded", t.render + assert t.resource_limits.reached? + + t.resource_limits.assign_score_limit = 2 + assert_equal "", t.render! + refute_nil t.resource_limits.assign_score + end + + def test_resource_limits_assign_score_nested + t = Template.parse("{% assign foo = 'aaaa' | reverse %}") + + t.resource_limits.assign_score_limit = 3 + assert_equal "Liquid error: Memory limits exceeded", t.render + assert t.resource_limits.reached? + + t.resource_limits.assign_score_limit = 5 + assert_equal "", t.render! + end + + def test_resource_limits_aborts_rendering_after_first_error + t = Template.parse("{% for a in (1..100) %} foo1 {% endfor %} bar {% for a in (1..100) %} foo2 {% endfor %}") + t.resource_limits.render_score_limit = 50 + assert_equal "Liquid error: Memory limits exceeded", t.render + assert t.resource_limits.reached? + end + + def test_resource_limits_hash_in_template_gets_updated_even_if_no_limits_are_set + t = Template.parse("{% for a in (1..100) %} {% assign foo = 1 %} {% endfor %}") + t.render! + assert t.resource_limits.assign_score > 0 + assert t.resource_limits.render_score > 0 + assert t.resource_limits.render_length > 0 + end + + def test_render_length_persists_between_blocks + t = Template.parse("{% if true %}aaaa{% endif %}") + t.resource_limits.render_length_limit = 7 + assert_equal "Liquid error: Memory limits exceeded", t.render + t.resource_limits.render_length_limit = 8 + assert_equal "aaaa", t.render + + t = Template.parse("{% if true %}aaaa{% endif %}{% if true %}bbb{% endif %}") + t.resource_limits.render_length_limit = 13 + assert_equal "Liquid error: Memory limits exceeded", t.render + t.resource_limits.render_length_limit = 14 + assert_equal "aaaabbb", t.render + + t = Template.parse("{% if true %}a{% endif %}{% if true %}b{% endif %}{% if true %}a{% endif %}{% if true %}b{% endif %}{% if true %}a{% endif %}{% if true %}b{% endif %}") + t.resource_limits.render_length_limit = 5 + assert_equal "Liquid error: Memory limits exceeded", t.render + t.resource_limits.render_length_limit = 11 + assert_equal "Liquid error: Memory limits exceeded", t.render + t.resource_limits.render_length_limit = 12 + assert_equal "ababab", t.render + end + + def test_default_resource_limits_unaffected_by_render_with_context + context = Context.new + t = Template.parse("{% for a in (1..100) %} {% assign foo = 1 %} {% endfor %}") + t.render!(context) + assert context.resource_limits.assign_score > 0 + assert context.resource_limits.render_score > 0 + assert context.resource_limits.render_length > 0 + end + + def test_can_use_drop_as_context + t = Template.new + t.registers['lulz'] = 'haha' + drop = TemplateContextDrop.new + assert_equal 'fizzbuzz', t.parse('{{foo}}').render!(drop) + assert_equal 'bar', t.parse('{{bar}}').render!(drop) + assert_equal 'haha', t.parse("{{baz}}").render!(drop) + end + + def test_render_bang_force_rethrow_errors_on_passed_context + context = Context.new({ 'drop' => ErroneousDrop.new }) + t = Template.new.parse('{{ drop.bad_method }}') + + e = assert_raises RuntimeError do + t.render!(context) + end + assert_equal 'ruby error in drop', e.message + end + + def test_exception_renderer_that_returns_string + exception = nil + handler = ->(e) { exception = e; '' } + + output = Template.parse("{{ 1 | divided_by: 0 }}").render({}, exception_renderer: handler) + + assert exception.is_a?(Liquid::ZeroDivisionError) + assert_equal '', output + end + + def test_exception_renderer_that_raises + exception = nil + assert_raises(Liquid::ZeroDivisionError) do + Template.parse("{{ 1 | divided_by: 0 }}").render({}, exception_renderer: ->(e) { exception = e; raise }) + end + assert exception.is_a?(Liquid::ZeroDivisionError) + end + + def test_global_filter_option_on_render + global_filter_proc = ->(output) { "#{output} filtered" } + rendered_template = Template.parse("{{name}}").render({ "name" => "bob" }, global_filter: global_filter_proc) + + assert_equal 'bob filtered', rendered_template + end + + def test_global_filter_option_when_native_filters_exist + global_filter_proc = ->(output) { "#{output} filtered" } + rendered_template = Template.parse("{{name | upcase}}").render({ "name" => "bob" }, global_filter: global_filter_proc) + + assert_equal 'BOB filtered', rendered_template + end + + def test_undefined_variables + t = Template.parse("{{x}} {{y}} {{z.a}} {{z.b}} {{z.c.d}}") + result = t.render({ 'x' => 33, 'z' => { 'a' => 32, 'c' => { 'e' => 31 } } }, { strict_variables: true }) + + assert_equal '33 32 ', result + assert_equal 3, t.errors.count + assert_instance_of Liquid::UndefinedVariable, t.errors[0] + assert_equal 'Liquid error: undefined variable y', t.errors[0].message + assert_instance_of Liquid::UndefinedVariable, t.errors[1] + assert_equal 'Liquid error: undefined variable b', t.errors[1].message + assert_instance_of Liquid::UndefinedVariable, t.errors[2] + assert_equal 'Liquid error: undefined variable d', t.errors[2].message + end + + def test_nil_value_does_not_raise + Liquid::Template.error_mode = :strict + t = Template.parse("some{{x}}thing") + result = t.render!({ 'x' => nil }, strict_variables: true) + + assert_equal 0, t.errors.count + assert_equal 'something', result + end + + def test_undefined_variables_raise + t = Template.parse("{{x}} {{y}} {{z.a}} {{z.b}} {{z.c.d}}") + + assert_raises UndefinedVariable do + t.render!({ 'x' => 33, 'z' => { 'a' => 32, 'c' => { 'e' => 31 } } }, { strict_variables: true }) + end + end + + def test_undefined_drop_methods + d = DropWithUndefinedMethod.new + t = Template.new.parse('{{ foo }} {{ woot }}') + result = t.render(d, { strict_variables: true }) + + assert_equal 'foo ', result + assert_equal 1, t.errors.count + assert_instance_of Liquid::UndefinedDropMethod, t.errors[0] + end + + def test_undefined_drop_methods_raise + d = DropWithUndefinedMethod.new + t = Template.new.parse('{{ foo }} {{ woot }}') + + assert_raises UndefinedDropMethod do + t.render!(d, { strict_variables: true }) + end + end + + def test_undefined_filters + t = Template.parse("{{a}} {{x | upcase | somefilter1 | somefilter2 | somefilter3}}") + filters = Module.new do + def somefilter3(v) + "-#{v}-" + end + end + result = t.render({ 'a' => 123, 'x' => 'foo' }, { filters: [filters], strict_filters: true }) + + assert_equal '123 ', result + assert_equal 1, t.errors.count + assert_instance_of Liquid::UndefinedFilter, t.errors[0] + assert_equal 'Liquid error: undefined filter somefilter1', t.errors[0].message + end + + def test_undefined_filters_raise + t = Template.parse("{{x | somefilter1 | upcase | somefilter2}}") + + assert_raises UndefinedFilter do + t.render!({ 'x' => 'foo' }, { strict_filters: true }) + end + end + + def test_using_range_literal_works_as_expected + t = Template.parse("{% assign foo = (x..y) %}{{ foo }}") + result = t.render({ 'x' => 1, 'y' => 5 }) + assert_equal '1..5', result + + t = Template.parse("{% assign nums = (x..y) %}{% for num in nums %}{{ num }}{% endfor %}") + result = t.render({ 'x' => 1, 'y' => 5 }) + assert_equal '12345', result + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/trim_mode_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/trim_mode_test.rb new file mode 100644 index 0000000..52248cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/trim_mode_test.rb @@ -0,0 +1,529 @@ +require 'test_helper' + +class TrimModeTest < Minitest::Test + include Liquid + + # Make sure the trim isn't applied to standard output + def test_standard_output + text = <<-END_TEMPLATE +
+

+ {{ 'John' }} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+ John +

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_variable_output_with_multiple_blank_lines + text = <<-END_TEMPLATE +
+

+ + + {{- 'John' -}} + + +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

John

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_tag_output_with_multiple_blank_lines + text = <<-END_TEMPLATE +
+

+ + + {%- if true -%} + yes + {%- endif -%} + + +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

yes

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + # Make sure the trim isn't applied to standard tags + def test_standard_tags + whitespace = ' ' + text = <<-END_TEMPLATE +
+

+ {% if true %} + yes + {% endif %} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+#{whitespace} + yes +#{whitespace} +

+
+ END_EXPECTED + assert_template_result(expected, text) + + text = <<-END_TEMPLATE +
+

+ {% if false %} + no + {% endif %} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+#{whitespace} +

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + # Make sure the trim isn't too agressive + def test_no_trim_output + text = '

{{- \'John\' -}}

' + expected = '

John

' + assert_template_result(expected, text) + end + + # Make sure the trim isn't too agressive + def test_no_trim_tags + text = '

{%- if true -%}yes{%- endif -%}

' + expected = '

yes

' + assert_template_result(expected, text) + + text = '

{%- if false -%}no{%- endif -%}

' + expected = '

' + assert_template_result(expected, text) + end + + def test_single_line_outer_tag + text = '

{%- if true %} yes {% endif -%}

' + expected = '

yes

' + assert_template_result(expected, text) + + text = '

{%- if false %} no {% endif -%}

' + expected = '

' + assert_template_result(expected, text) + end + + def test_single_line_inner_tag + text = '

{% if true -%} yes {%- endif %}

' + expected = '

yes

' + assert_template_result(expected, text) + + text = '

{% if false -%} no {%- endif %}

' + expected = '

' + assert_template_result(expected, text) + end + + def test_single_line_post_tag + text = '

{% if true -%} yes {% endif -%}

' + expected = '

yes

' + assert_template_result(expected, text) + + text = '

{% if false -%} no {% endif -%}

' + expected = '

' + assert_template_result(expected, text) + end + + def test_single_line_pre_tag + text = '

{%- if true %} yes {%- endif %}

' + expected = '

yes

' + assert_template_result(expected, text) + + text = '

{%- if false %} no {%- endif %}

' + expected = '

' + assert_template_result(expected, text) + end + + def test_pre_trim_output + text = <<-END_TEMPLATE +
+

+ {{- 'John' }} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

John +

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_pre_trim_tags + text = <<-END_TEMPLATE +
+

+ {%- if true %} + yes + {%- endif %} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+ yes +

+
+ END_EXPECTED + assert_template_result(expected, text) + + text = <<-END_TEMPLATE +
+

+ {%- if false %} + no + {%- endif %} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_post_trim_output + text = <<-END_TEMPLATE +
+

+ {{ 'John' -}} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+ John

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_post_trim_tags + text = <<-END_TEMPLATE +
+

+ {% if true -%} + yes + {% endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+ yes +

+
+ END_EXPECTED + assert_template_result(expected, text) + + text = <<-END_TEMPLATE +
+

+ {% if false -%} + no + {% endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_pre_and_post_trim_tags + text = <<-END_TEMPLATE +
+

+ {%- if true %} + yes + {% endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+ yes +

+
+ END_EXPECTED + assert_template_result(expected, text) + + text = <<-END_TEMPLATE +
+

+ {%- if false %} + no + {% endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_post_and_pre_trim_tags + text = <<-END_TEMPLATE +
+

+ {% if true -%} + yes + {%- endif %} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+ yes +

+
+ END_EXPECTED + assert_template_result(expected, text) + + whitespace = ' ' + text = <<-END_TEMPLATE +
+

+ {% if false -%} + no + {%- endif %} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+#{whitespace} +

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_trim_output + text = <<-END_TEMPLATE +
+

+ {{- 'John' -}} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

John

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_trim_tags + text = <<-END_TEMPLATE +
+

+ {%- if true -%} + yes + {%- endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

yes

+
+ END_EXPECTED + assert_template_result(expected, text) + + text = <<-END_TEMPLATE +
+

+ {%- if false -%} + no + {%- endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_whitespace_trim_output + text = <<-END_TEMPLATE +
+

+ {{- 'John' -}}, + {{- '30' -}} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

John,30

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_whitespace_trim_tags + text = <<-END_TEMPLATE +
+

+ {%- if true -%} + yes + {%- endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

yes

+
+ END_EXPECTED + assert_template_result(expected, text) + + text = <<-END_TEMPLATE +
+

+ {%- if false -%} + no + {%- endif -%} +

+
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

+
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_complex_trim_output + text = <<-END_TEMPLATE +
+

+ {{- 'John' -}} + {{- '30' -}} +

+ + {{ 'John' -}} + {{- '30' }} + + + {{- 'John' }} + {{ '30' -}} + +
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+

John30

+ + John30 + + John + 30 +
+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_complex_trim + text = <<-END_TEMPLATE +
+ {%- if true -%} + {%- if true -%} +

+ {{- 'John' -}} +

+ {%- endif -%} + {%- endif -%} +
+ END_TEMPLATE + expected = <<-END_EXPECTED +

John

+ END_EXPECTED + assert_template_result(expected, text) + end + + def test_right_trim_followed_by_tag + assert_template_result('ab c', '{{ "a" -}}{{ "b" }} c') + end + + def test_raw_output + whitespace = ' ' + text = <<-END_TEMPLATE +
+ {% raw %} + {%- if true -%} +

+ {{- 'John' -}} +

+ {%- endif -%} + {% endraw %} +
+ END_TEMPLATE + expected = <<-END_EXPECTED +
+#{whitespace} + {%- if true -%} +

+ {{- 'John' -}} +

+ {%- endif -%} +#{whitespace} +
+ END_EXPECTED + assert_template_result(expected, text) + end +end # TrimModeTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/variable_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/variable_test.rb new file mode 100644 index 0000000..abd6e70 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/integration/variable_test.rb @@ -0,0 +1,96 @@ +require 'test_helper' + +class VariableTest < Minitest::Test + include Liquid + + def test_simple_variable + template = Template.parse(%({{test}})) + assert_equal 'worked', template.render!('test' => 'worked') + assert_equal 'worked wonderfully', template.render!('test' => 'worked wonderfully') + end + + def test_variable_render_calls_to_liquid + assert_template_result 'foobar', '{{ foo }}', 'foo' => ThingWithToLiquid.new + end + + def test_simple_with_whitespaces + template = Template.parse(%( {{ test }} )) + assert_equal ' worked ', template.render!('test' => 'worked') + assert_equal ' worked wonderfully ', template.render!('test' => 'worked wonderfully') + end + + def test_ignore_unknown + template = Template.parse(%({{ test }})) + assert_equal '', template.render! + end + + def test_using_blank_as_variable_name + template = Template.parse("{% assign foo = blank %}{{ foo }}") + assert_equal '', template.render! + end + + def test_using_empty_as_variable_name + template = Template.parse("{% assign foo = empty %}{{ foo }}") + assert_equal '', template.render! + end + + def test_hash_scoping + template = Template.parse(%({{ test.test }})) + assert_equal 'worked', template.render!('test' => { 'test' => 'worked' }) + end + + def test_false_renders_as_false + assert_equal 'false', Template.parse("{{ foo }}").render!('foo' => false) + assert_equal 'false', Template.parse("{{ false }}").render! + end + + def test_nil_renders_as_empty_string + assert_equal '', Template.parse("{{ nil }}").render! + assert_equal 'cat', Template.parse("{{ nil | append: 'cat' }}").render! + end + + def test_preset_assigns + template = Template.parse(%({{ test }})) + template.assigns['test'] = 'worked' + assert_equal 'worked', template.render! + end + + def test_reuse_parsed_template + template = Template.parse(%({{ greeting }} {{ name }})) + template.assigns['greeting'] = 'Goodbye' + assert_equal 'Hello Tobi', template.render!('greeting' => 'Hello', 'name' => 'Tobi') + assert_equal 'Hello ', template.render!('greeting' => 'Hello', 'unknown' => 'Tobi') + assert_equal 'Hello Brian', template.render!('greeting' => 'Hello', 'name' => 'Brian') + assert_equal 'Goodbye Brian', template.render!('name' => 'Brian') + assert_equal({ 'greeting' => 'Goodbye' }, template.assigns) + end + + def test_assigns_not_polluted_from_template + template = Template.parse(%({{ test }}{% assign test = 'bar' %}{{ test }})) + template.assigns['test'] = 'baz' + assert_equal 'bazbar', template.render! + assert_equal 'bazbar', template.render! + assert_equal 'foobar', template.render!('test' => 'foo') + assert_equal 'bazbar', template.render! + end + + def test_hash_with_default_proc + template = Template.parse(%(Hello {{ test }})) + assigns = Hash.new { |h, k| raise "Unknown variable '#{k}'" } + assigns['test'] = 'Tobi' + assert_equal 'Hello Tobi', template.render!(assigns) + assigns.delete('test') + e = assert_raises(RuntimeError) do + template.render!(assigns) + end + assert_equal "Unknown variable 'test'", e.message + end + + def test_multiline_variable + assert_equal 'worked', Template.parse("{{\ntest\n}}").render!('test' => 'worked') + end + + def test_render_symbol + assert_template_result 'bar', '{{ foo }}', 'foo' => :bar + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/test_helper.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/test_helper.rb new file mode 100755 index 0000000..3cee676 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/test_helper.rb @@ -0,0 +1,108 @@ +#!/usr/bin/env ruby + +ENV["MT_NO_EXPECTATIONS"] = "1" +require 'minitest/autorun' + +$LOAD_PATH.unshift(File.join(File.expand_path(__dir__), '..', 'lib')) +require 'liquid.rb' +require 'liquid/profiler' + +mode = :strict +if env_mode = ENV['LIQUID_PARSER_MODE'] + puts "-- #{env_mode.upcase} ERROR MODE" + mode = env_mode.to_sym +end +Liquid::Template.error_mode = mode + +if ENV['LIQUID-C'] == '1' + puts "-- LIQUID C" + require 'liquid/c' +end + +if Minitest.const_defined?('Test') + # We're on Minitest 5+. Nothing to do here. +else + # Minitest 4 doesn't have Minitest::Test yet. + Minitest::Test = MiniTest::Unit::TestCase +end + +module Minitest + class Test + def fixture(name) + File.join(File.expand_path(__dir__), "fixtures", name) + end + end + + module Assertions + include Liquid + + def assert_template_result(expected, template, assigns = {}, message = nil) + assert_equal expected, Template.parse(template).render!(assigns), message + end + + def assert_template_result_matches(expected, template, assigns = {}, message = nil) + return assert_template_result(expected, template, assigns, message) unless expected.is_a? Regexp + + assert_match expected, Template.parse(template).render!(assigns), message + end + + def assert_match_syntax_error(match, template, assigns = {}) + exception = assert_raises(Liquid::SyntaxError) do + Template.parse(template).render(assigns) + end + assert_match match, exception.message + end + + def with_global_filter(*globals) + original_global_strainer = Liquid::Strainer.class_variable_get(:@@global_strainer) + Liquid::Strainer.class_variable_set(:@@global_strainer, Class.new(Liquid::Strainer) do + @filter_methods = Set.new + end) + Liquid::Strainer.class_variable_get(:@@strainer_class_cache).clear + + globals.each do |global| + Liquid::Template.register_filter(global) + end + yield + ensure + Liquid::Strainer.class_variable_get(:@@strainer_class_cache).clear + Liquid::Strainer.class_variable_set(:@@global_strainer, original_global_strainer) + end + + def with_error_mode(mode) + old_mode = Liquid::Template.error_mode + Liquid::Template.error_mode = mode + yield + ensure + Liquid::Template.error_mode = old_mode + end + end +end + +class ThingWithToLiquid + def to_liquid + 'foobar' + end +end + +class ErrorDrop < Liquid::Drop + def standard_error + raise Liquid::StandardError, 'standard error' + end + + def argument_error + raise Liquid::ArgumentError, 'argument error' + end + + def syntax_error + raise Liquid::SyntaxError, 'syntax error' + end + + def runtime_error + raise 'runtime error' + end + + def exception + raise Exception, 'exception' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/block_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/block_unit_test.rb new file mode 100644 index 0000000..6a27a7d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/block_unit_test.rb @@ -0,0 +1,58 @@ +require 'test_helper' + +class BlockUnitTest < Minitest::Test + include Liquid + + def test_blankspace + template = Liquid::Template.parse(" ") + assert_equal [" "], template.root.nodelist + end + + def test_variable_beginning + template = Liquid::Template.parse("{{funk}} ") + assert_equal 2, template.root.nodelist.size + assert_equal Variable, template.root.nodelist[0].class + assert_equal String, template.root.nodelist[1].class + end + + def test_variable_end + template = Liquid::Template.parse(" {{funk}}") + assert_equal 2, template.root.nodelist.size + assert_equal String, template.root.nodelist[0].class + assert_equal Variable, template.root.nodelist[1].class + end + + def test_variable_middle + template = Liquid::Template.parse(" {{funk}} ") + assert_equal 3, template.root.nodelist.size + assert_equal String, template.root.nodelist[0].class + assert_equal Variable, template.root.nodelist[1].class + assert_equal String, template.root.nodelist[2].class + end + + def test_variable_many_embedded_fragments + template = Liquid::Template.parse(" {{funk}} {{so}} {{brother}} ") + assert_equal 7, template.root.nodelist.size + assert_equal [String, Variable, String, Variable, String, Variable, String], + block_types(template.root.nodelist) + end + + def test_with_block + template = Liquid::Template.parse(" {% comment %} {% endcomment %} ") + assert_equal [String, Comment, String], block_types(template.root.nodelist) + assert_equal 3, template.root.nodelist.size + end + + def test_with_custom_tag + Liquid::Template.register_tag("testtag", Block) + assert Liquid::Template.parse("{% testtag %} {% endtesttag %}") + ensure + Liquid::Template.tags.delete('testtag') + end + + private + + def block_types(nodelist) + nodelist.collect(&:class) + end +end # VariableTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/condition_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/condition_unit_test.rb new file mode 100644 index 0000000..b3b90e8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/condition_unit_test.rb @@ -0,0 +1,166 @@ +require 'test_helper' + +class ConditionUnitTest < Minitest::Test + include Liquid + + def setup + @context = Liquid::Context.new + end + + def test_basic_condition + assert_equal false, Condition.new(1, '==', 2).evaluate + assert_equal true, Condition.new(1, '==', 1).evaluate + end + + def test_default_operators_evalute_true + assert_evaluates_true 1, '==', 1 + assert_evaluates_true 1, '!=', 2 + assert_evaluates_true 1, '<>', 2 + assert_evaluates_true 1, '<', 2 + assert_evaluates_true 2, '>', 1 + assert_evaluates_true 1, '>=', 1 + assert_evaluates_true 2, '>=', 1 + assert_evaluates_true 1, '<=', 2 + assert_evaluates_true 1, '<=', 1 + # negative numbers + assert_evaluates_true 1, '>', -1 + assert_evaluates_true -1, '<', 1 + assert_evaluates_true 1.0, '>', -1.0 + assert_evaluates_true -1.0, '<', 1.0 + end + + def test_default_operators_evalute_false + assert_evaluates_false 1, '==', 2 + assert_evaluates_false 1, '!=', 1 + assert_evaluates_false 1, '<>', 1 + assert_evaluates_false 1, '<', 0 + assert_evaluates_false 2, '>', 4 + assert_evaluates_false 1, '>=', 3 + assert_evaluates_false 2, '>=', 4 + assert_evaluates_false 1, '<=', 0 + assert_evaluates_false 1, '<=', 0 + end + + def test_contains_works_on_strings + assert_evaluates_true 'bob', 'contains', 'o' + assert_evaluates_true 'bob', 'contains', 'b' + assert_evaluates_true 'bob', 'contains', 'bo' + assert_evaluates_true 'bob', 'contains', 'ob' + assert_evaluates_true 'bob', 'contains', 'bob' + + assert_evaluates_false 'bob', 'contains', 'bob2' + assert_evaluates_false 'bob', 'contains', 'a' + assert_evaluates_false 'bob', 'contains', '---' + end + + def test_invalid_comparation_operator + assert_evaluates_argument_error 1, '~~', 0 + end + + def test_comparation_of_int_and_str + assert_evaluates_argument_error '1', '>', 0 + assert_evaluates_argument_error '1', '<', 0 + assert_evaluates_argument_error '1', '>=', 0 + assert_evaluates_argument_error '1', '<=', 0 + end + + def test_hash_compare_backwards_compatibility + assert_nil Condition.new({}, '>', 2).evaluate + assert_nil Condition.new(2, '>', {}).evaluate + assert_equal false, Condition.new({}, '==', 2).evaluate + assert_equal true, Condition.new({ 'a' => 1 }, '==', { 'a' => 1 }).evaluate + assert_equal true, Condition.new({ 'a' => 2 }, 'contains', 'a').evaluate + end + + def test_contains_works_on_arrays + @context = Liquid::Context.new + @context['array'] = [1, 2, 3, 4, 5] + array_expr = VariableLookup.new("array") + + assert_evaluates_false array_expr, 'contains', 0 + assert_evaluates_true array_expr, 'contains', 1 + assert_evaluates_true array_expr, 'contains', 2 + assert_evaluates_true array_expr, 'contains', 3 + assert_evaluates_true array_expr, 'contains', 4 + assert_evaluates_true array_expr, 'contains', 5 + assert_evaluates_false array_expr, 'contains', 6 + assert_evaluates_false array_expr, 'contains', "1" + end + + def test_contains_returns_false_for_nil_operands + @context = Liquid::Context.new + assert_evaluates_false VariableLookup.new('not_assigned'), 'contains', '0' + assert_evaluates_false 0, 'contains', VariableLookup.new('not_assigned') + end + + def test_contains_return_false_on_wrong_data_type + assert_evaluates_false 1, 'contains', 0 + end + + def test_contains_with_string_left_operand_coerces_right_operand_to_string + assert_evaluates_true ' 1 ', 'contains', 1 + assert_evaluates_false ' 1 ', 'contains', 2 + end + + def test_or_condition + condition = Condition.new(1, '==', 2) + + assert_equal false, condition.evaluate + + condition.or Condition.new(2, '==', 1) + + assert_equal false, condition.evaluate + + condition.or Condition.new(1, '==', 1) + + assert_equal true, condition.evaluate + end + + def test_and_condition + condition = Condition.new(1, '==', 1) + + assert_equal true, condition.evaluate + + condition.and Condition.new(2, '==', 2) + + assert_equal true, condition.evaluate + + condition.and Condition.new(2, '==', 1) + + assert_equal false, condition.evaluate + end + + def test_should_allow_custom_proc_operator + Condition.operators['starts_with'] = proc { |cond, left, right| left =~ %r{^#{right}} } + + assert_evaluates_true 'bob', 'starts_with', 'b' + assert_evaluates_false 'bob', 'starts_with', 'o' + ensure + Condition.operators.delete 'starts_with' + end + + def test_left_or_right_may_contain_operators + @context = Liquid::Context.new + @context['one'] = @context['another'] = "gnomeslab-and-or-liquid" + + assert_evaluates_true VariableLookup.new("one"), '==', VariableLookup.new("another") + end + + private + + def assert_evaluates_true(left, op, right) + assert Condition.new(left, op, right).evaluate(@context), + "Evaluated false: #{left} #{op} #{right}" + end + + def assert_evaluates_false(left, op, right) + assert !Condition.new(left, op, right).evaluate(@context), + "Evaluated true: #{left} #{op} #{right}" + end + + def assert_evaluates_argument_error(left, op, right) + assert_raises(Liquid::ArgumentError) do + Condition.new(left, op, right).evaluate(@context) + end + end +end # ConditionTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/context_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/context_unit_test.rb new file mode 100644 index 0000000..d9bfedb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/context_unit_test.rb @@ -0,0 +1,490 @@ +require 'test_helper' + +class HundredCentes + def to_liquid + 100 + end +end + +class CentsDrop < Liquid::Drop + def amount + HundredCentes.new + end + + def non_zero? + true + end +end + +class ContextSensitiveDrop < Liquid::Drop + def test + @context['test'] + end +end + +class Category < Liquid::Drop + attr_accessor :name + + def initialize(name) + @name = name + end + + def to_liquid + CategoryDrop.new(self) + end +end + +class CategoryDrop + attr_accessor :category, :context + def initialize(category) + @category = category + end +end + +class CounterDrop < Liquid::Drop + def count + @count ||= 0 + @count += 1 + end +end + +class ArrayLike + def fetch(index) + end + + def [](index) + @counts ||= [] + @counts[index] ||= 0 + @counts[index] += 1 + end + + def to_liquid + self + end +end + +class ContextUnitTest < Minitest::Test + include Liquid + + def setup + @context = Liquid::Context.new + end + + def test_variables + @context['string'] = 'string' + assert_equal 'string', @context['string'] + + @context['num'] = 5 + assert_equal 5, @context['num'] + + @context['time'] = Time.parse('2006-06-06 12:00:00') + assert_equal Time.parse('2006-06-06 12:00:00'), @context['time'] + + @context['date'] = Date.today + assert_equal Date.today, @context['date'] + + now = DateTime.now + @context['datetime'] = now + assert_equal now, @context['datetime'] + + @context['bool'] = true + assert_equal true, @context['bool'] + + @context['bool'] = false + assert_equal false, @context['bool'] + + @context['nil'] = nil + assert_nil @context['nil'] + assert_nil @context['nil'] + end + + def test_variables_not_existing + assert_nil @context['does_not_exist'] + end + + def test_scoping + @context.push + @context.pop + + assert_raises(Liquid::ContextError) do + @context.pop + end + + assert_raises(Liquid::ContextError) do + @context.push + @context.pop + @context.pop + end + end + + def test_length_query + @context['numbers'] = [1, 2, 3, 4] + + assert_equal 4, @context['numbers.size'] + + @context['numbers'] = { 1 => 1, 2 => 2, 3 => 3, 4 => 4 } + + assert_equal 4, @context['numbers.size'] + + @context['numbers'] = { 1 => 1, 2 => 2, 3 => 3, 4 => 4, 'size' => 1000 } + + assert_equal 1000, @context['numbers.size'] + end + + def test_hyphenated_variable + @context['oh-my'] = 'godz' + assert_equal 'godz', @context['oh-my'] + end + + def test_add_filter + filter = Module.new do + def hi(output) + output + ' hi!' + end + end + + context = Context.new + context.add_filters(filter) + assert_equal 'hi? hi!', context.invoke(:hi, 'hi?') + + context = Context.new + assert_equal 'hi?', context.invoke(:hi, 'hi?') + + context.add_filters(filter) + assert_equal 'hi? hi!', context.invoke(:hi, 'hi?') + end + + def test_only_intended_filters_make_it_there + filter = Module.new do + def hi(output) + output + ' hi!' + end + end + + context = Context.new + assert_equal "Wookie", context.invoke("hi", "Wookie") + + context.add_filters(filter) + assert_equal "Wookie hi!", context.invoke("hi", "Wookie") + end + + def test_add_item_in_outer_scope + @context['test'] = 'test' + @context.push + assert_equal 'test', @context['test'] + @context.pop + assert_equal 'test', @context['test'] + end + + def test_add_item_in_inner_scope + @context.push + @context['test'] = 'test' + assert_equal 'test', @context['test'] + @context.pop + assert_nil @context['test'] + end + + def test_hierachical_data + @context['hash'] = { "name" => 'tobi' } + assert_equal 'tobi', @context['hash.name'] + assert_equal 'tobi', @context['hash["name"]'] + end + + def test_keywords + assert_equal true, @context['true'] + assert_equal false, @context['false'] + end + + def test_digits + assert_equal 100, @context['100'] + assert_equal 100.00, @context['100.00'] + end + + def test_strings + assert_equal "hello!", @context['"hello!"'] + assert_equal "hello!", @context["'hello!'"] + end + + def test_merge + @context.merge({ "test" => "test" }) + assert_equal 'test', @context['test'] + @context.merge({ "test" => "newvalue", "foo" => "bar" }) + assert_equal 'newvalue', @context['test'] + assert_equal 'bar', @context['foo'] + end + + def test_array_notation + @context['test'] = [1, 2, 3, 4, 5] + + assert_equal 1, @context['test[0]'] + assert_equal 2, @context['test[1]'] + assert_equal 3, @context['test[2]'] + assert_equal 4, @context['test[3]'] + assert_equal 5, @context['test[4]'] + end + + def test_recoursive_array_notation + @context['test'] = { 'test' => [1, 2, 3, 4, 5] } + + assert_equal 1, @context['test.test[0]'] + + @context['test'] = [{ 'test' => 'worked' }] + + assert_equal 'worked', @context['test[0].test'] + end + + def test_hash_to_array_transition + @context['colors'] = { + 'Blue' => ['003366', '336699', '6699CC', '99CCFF'], + 'Green' => ['003300', '336633', '669966', '99CC99'], + 'Yellow' => ['CC9900', 'FFCC00', 'FFFF99', 'FFFFCC'], + 'Red' => ['660000', '993333', 'CC6666', 'FF9999'] + } + + assert_equal '003366', @context['colors.Blue[0]'] + assert_equal 'FF9999', @context['colors.Red[3]'] + end + + def test_try_first + @context['test'] = [1, 2, 3, 4, 5] + + assert_equal 1, @context['test.first'] + assert_equal 5, @context['test.last'] + + @context['test'] = { 'test' => [1, 2, 3, 4, 5] } + + assert_equal 1, @context['test.test.first'] + assert_equal 5, @context['test.test.last'] + + @context['test'] = [1] + assert_equal 1, @context['test.first'] + assert_equal 1, @context['test.last'] + end + + def test_access_hashes_with_hash_notation + @context['products'] = { 'count' => 5, 'tags' => ['deepsnow', 'freestyle'] } + @context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] } + + assert_equal 5, @context['products["count"]'] + assert_equal 'deepsnow', @context['products["tags"][0]'] + assert_equal 'deepsnow', @context['products["tags"].first'] + assert_equal 'draft151cm', @context['product["variants"][0]["title"]'] + assert_equal 'element151cm', @context['product["variants"][1]["title"]'] + assert_equal 'draft151cm', @context['product["variants"][0]["title"]'] + assert_equal 'element151cm', @context['product["variants"].last["title"]'] + end + + def test_access_variable_with_hash_notation + @context['foo'] = 'baz' + @context['bar'] = 'foo' + + assert_equal 'baz', @context['["foo"]'] + assert_equal 'baz', @context['[bar]'] + end + + def test_access_hashes_with_hash_access_variables + @context['var'] = 'tags' + @context['nested'] = { 'var' => 'tags' } + @context['products'] = { 'count' => 5, 'tags' => ['deepsnow', 'freestyle'] } + + assert_equal 'deepsnow', @context['products[var].first'] + assert_equal 'freestyle', @context['products[nested.var].last'] + end + + def test_hash_notation_only_for_hash_access + @context['array'] = [1, 2, 3, 4, 5] + @context['hash'] = { 'first' => 'Hello' } + + assert_equal 1, @context['array.first'] + assert_nil @context['array["first"]'] + assert_equal 'Hello', @context['hash["first"]'] + end + + def test_first_can_appear_in_middle_of_callchain + @context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] } + + assert_equal 'draft151cm', @context['product.variants[0].title'] + assert_equal 'element151cm', @context['product.variants[1].title'] + assert_equal 'draft151cm', @context['product.variants.first.title'] + assert_equal 'element151cm', @context['product.variants.last.title'] + end + + def test_cents + @context.merge("cents" => HundredCentes.new) + assert_equal 100, @context['cents'] + end + + def test_nested_cents + @context.merge("cents" => { 'amount' => HundredCentes.new }) + assert_equal 100, @context['cents.amount'] + + @context.merge("cents" => { 'cents' => { 'amount' => HundredCentes.new } }) + assert_equal 100, @context['cents.cents.amount'] + end + + def test_cents_through_drop + @context.merge("cents" => CentsDrop.new) + assert_equal 100, @context['cents.amount'] + end + + def test_nested_cents_through_drop + @context.merge("vars" => { "cents" => CentsDrop.new }) + assert_equal 100, @context['vars.cents.amount'] + end + + def test_drop_methods_with_question_marks + @context.merge("cents" => CentsDrop.new) + assert @context['cents.non_zero?'] + end + + def test_context_from_within_drop + @context.merge("test" => '123', "vars" => ContextSensitiveDrop.new) + assert_equal '123', @context['vars.test'] + end + + def test_nested_context_from_within_drop + @context.merge("test" => '123', "vars" => { "local" => ContextSensitiveDrop.new }) + assert_equal '123', @context['vars.local.test'] + end + + def test_ranges + @context.merge("test" => '5') + assert_equal (1..5), @context['(1..5)'] + assert_equal (1..5), @context['(1..test)'] + assert_equal (5..5), @context['(test..test)'] + end + + def test_cents_through_drop_nestedly + @context.merge("cents" => { "cents" => CentsDrop.new }) + assert_equal 100, @context['cents.cents.amount'] + + @context.merge("cents" => { "cents" => { "cents" => CentsDrop.new } }) + assert_equal 100, @context['cents.cents.cents.amount'] + end + + def test_drop_with_variable_called_only_once + @context['counter'] = CounterDrop.new + + assert_equal 1, @context['counter.count'] + assert_equal 2, @context['counter.count'] + assert_equal 3, @context['counter.count'] + end + + def test_drop_with_key_called_only_once + @context['counter'] = CounterDrop.new + + assert_equal 1, @context['counter["count"]'] + assert_equal 2, @context['counter["count"]'] + assert_equal 3, @context['counter["count"]'] + end + + def test_proc_as_variable + @context['dynamic'] = proc { 'Hello' } + + assert_equal 'Hello', @context['dynamic'] + end + + def test_lambda_as_variable + @context['dynamic'] = proc { 'Hello' } + + assert_equal 'Hello', @context['dynamic'] + end + + def test_nested_lambda_as_variable + @context['dynamic'] = { "lambda" => proc { 'Hello' } } + + assert_equal 'Hello', @context['dynamic.lambda'] + end + + def test_array_containing_lambda_as_variable + @context['dynamic'] = [1, 2, proc { 'Hello' }, 4, 5] + + assert_equal 'Hello', @context['dynamic[2]'] + end + + def test_lambda_is_called_once + @context['callcount'] = proc { @global ||= 0; @global += 1; @global.to_s } + + assert_equal '1', @context['callcount'] + assert_equal '1', @context['callcount'] + assert_equal '1', @context['callcount'] + + @global = nil + end + + def test_nested_lambda_is_called_once + @context['callcount'] = { "lambda" => proc { @global ||= 0; @global += 1; @global.to_s } } + + assert_equal '1', @context['callcount.lambda'] + assert_equal '1', @context['callcount.lambda'] + assert_equal '1', @context['callcount.lambda'] + + @global = nil + end + + def test_lambda_in_array_is_called_once + @context['callcount'] = [1, 2, proc { @global ||= 0; @global += 1; @global.to_s }, 4, 5] + + assert_equal '1', @context['callcount[2]'] + assert_equal '1', @context['callcount[2]'] + assert_equal '1', @context['callcount[2]'] + + @global = nil + end + + def test_access_to_context_from_proc + @context.registers[:magic] = 345392 + + @context['magic'] = proc { @context.registers[:magic] } + + assert_equal 345392, @context['magic'] + end + + def test_to_liquid_and_context_at_first_level + @context['category'] = Category.new("foobar") + assert_kind_of CategoryDrop, @context['category'] + assert_equal @context, @context['category'].context + end + + def test_interrupt_avoids_object_allocations + @context.interrupt? # ruby 3.0.0 allocates on the first call + assert_no_object_allocations do + @context.interrupt? + end + end + + def test_context_initialization_with_a_proc_in_environment + contx = Context.new([test: ->(c) { c['poutine'] }], { test: :foo }) + + assert contx + assert_nil contx['poutine'] + end + + def test_apply_global_filter + global_filter_proc = ->(output) { "#{output} filtered" } + + context = Context.new + context.global_filter = global_filter_proc + + assert_equal 'hi filtered', context.apply_global_filter('hi') + end + + def test_apply_global_filter_when_no_global_filter_exist + context = Context.new + assert_equal 'hi', context.apply_global_filter('hi') + end + + private + + def assert_no_object_allocations + unless RUBY_ENGINE == 'ruby' + skip "stackprof needed to count object allocations" + end + require 'stackprof' + + profile = StackProf.run(mode: :object) do + yield + end + assert_equal 0, profile[:samples] + end +end # ContextTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/file_system_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/file_system_unit_test.rb new file mode 100644 index 0000000..2c7250b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/file_system_unit_test.rb @@ -0,0 +1,35 @@ +require 'test_helper' + +class FileSystemUnitTest < Minitest::Test + include Liquid + + def test_default + assert_raises(FileSystemError) do + BlankFileSystem.new.read_template_file("dummy") + end + end + + def test_local + file_system = Liquid::LocalFileSystem.new("/some/path") + assert_equal "/some/path/_mypartial.liquid", file_system.full_path("mypartial") + assert_equal "/some/path/dir/_mypartial.liquid", file_system.full_path("dir/mypartial") + + assert_raises(FileSystemError) do + file_system.full_path("../dir/mypartial") + end + + assert_raises(FileSystemError) do + file_system.full_path("/dir/../../dir/mypartial") + end + + assert_raises(FileSystemError) do + file_system.full_path("/etc/passwd") + end + end + + def test_custom_template_filename_patterns + file_system = Liquid::LocalFileSystem.new("/some/path", "%s.html") + assert_equal "/some/path/mypartial.html", file_system.full_path("mypartial") + assert_equal "/some/path/dir/mypartial.html", file_system.full_path("dir/mypartial") + end +end # FileSystemTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/i18n_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/i18n_unit_test.rb new file mode 100644 index 0000000..b57500e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/i18n_unit_test.rb @@ -0,0 +1,37 @@ +require 'test_helper' + +class I18nUnitTest < Minitest::Test + include Liquid + + def setup + @i18n = I18n.new(fixture("en_locale.yml")) + end + + def test_simple_translate_string + assert_equal "less is more", @i18n.translate("simple") + end + + def test_nested_translate_string + assert_equal "something wasn't right", @i18n.translate("errors.syntax.oops") + end + + def test_single_string_interpolation + assert_equal "something different", @i18n.translate("whatever", something: "different") + end + + # def test_raises_translation_error_on_undefined_interpolation_key + # assert_raises I18n::TranslationError do + # @i18n.translate("whatever", :oopstypos => "yes") + # end + # end + + def test_raises_unknown_translation + assert_raises I18n::TranslationError do + @i18n.translate("doesnt_exist") + end + end + + def test_sets_default_path_to_en + assert_equal I18n::DEFAULT_LOCALE, I18n.new.path + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/lexer_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/lexer_unit_test.rb new file mode 100644 index 0000000..5adcf2b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/lexer_unit_test.rb @@ -0,0 +1,51 @@ +require 'test_helper' + +class LexerUnitTest < Minitest::Test + include Liquid + + def test_strings + tokens = Lexer.new(%( 'this is a test""' "wat 'lol'")).tokenize + assert_equal [[:string, %('this is a test""')], [:string, %("wat 'lol'")], [:end_of_string]], tokens + end + + def test_integer + tokens = Lexer.new('hi 50').tokenize + assert_equal [[:id, 'hi'], [:number, '50'], [:end_of_string]], tokens + end + + def test_float + tokens = Lexer.new('hi 5.0').tokenize + assert_equal [[:id, 'hi'], [:number, '5.0'], [:end_of_string]], tokens + end + + def test_comparison + tokens = Lexer.new('== <> contains ').tokenize + assert_equal [[:comparison, '=='], [:comparison, '<>'], [:comparison, 'contains'], [:end_of_string]], tokens + end + + def test_specials + tokens = Lexer.new('| .:').tokenize + assert_equal [[:pipe, '|'], [:dot, '.'], [:colon, ':'], [:end_of_string]], tokens + tokens = Lexer.new('[,]').tokenize + assert_equal [[:open_square, '['], [:comma, ','], [:close_square, ']'], [:end_of_string]], tokens + end + + def test_fancy_identifiers + tokens = Lexer.new('hi five?').tokenize + assert_equal [[:id, 'hi'], [:id, 'five?'], [:end_of_string]], tokens + + tokens = Lexer.new('2foo').tokenize + assert_equal [[:number, '2'], [:id, 'foo'], [:end_of_string]], tokens + end + + def test_whitespace + tokens = Lexer.new("five|\n\t ==").tokenize + assert_equal [[:id, 'five'], [:pipe, '|'], [:comparison, '=='], [:end_of_string]], tokens + end + + def test_unexpected_character + assert_raises(SyntaxError) do + Lexer.new("%").tokenize + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/parser_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/parser_unit_test.rb new file mode 100644 index 0000000..9f23337 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/parser_unit_test.rb @@ -0,0 +1,82 @@ +require 'test_helper' + +class ParserUnitTest < Minitest::Test + include Liquid + + def test_consume + p = Parser.new("wat: 7") + assert_equal 'wat', p.consume(:id) + assert_equal ':', p.consume(:colon) + assert_equal '7', p.consume(:number) + end + + def test_jump + p = Parser.new("wat: 7") + p.jump(2) + assert_equal '7', p.consume(:number) + end + + def test_consume? + p = Parser.new("wat: 7") + assert_equal 'wat', p.consume?(:id) + assert_equal false, p.consume?(:dot) + assert_equal ':', p.consume(:colon) + assert_equal '7', p.consume?(:number) + end + + def test_id? + p = Parser.new("wat 6 Peter Hegemon") + assert_equal 'wat', p.id?('wat') + assert_equal false, p.id?('endgame') + assert_equal '6', p.consume(:number) + assert_equal 'Peter', p.id?('Peter') + assert_equal false, p.id?('Achilles') + end + + def test_look + p = Parser.new("wat 6 Peter Hegemon") + assert_equal true, p.look(:id) + assert_equal 'wat', p.consume(:id) + assert_equal false, p.look(:comparison) + assert_equal true, p.look(:number) + assert_equal true, p.look(:id, 1) + assert_equal false, p.look(:number, 1) + end + + def test_expressions + p = Parser.new("hi.there hi?[5].there? hi.there.bob") + assert_equal 'hi.there', p.expression + assert_equal 'hi?[5].there?', p.expression + assert_equal 'hi.there.bob', p.expression + + p = Parser.new("567 6.0 'lol' \"wut\"") + assert_equal '567', p.expression + assert_equal '6.0', p.expression + assert_equal "'lol'", p.expression + assert_equal '"wut"', p.expression + end + + def test_ranges + p = Parser.new("(5..7) (1.5..9.6) (young..old) (hi[5].wat..old)") + assert_equal '(5..7)', p.expression + assert_equal '(1.5..9.6)', p.expression + assert_equal '(young..old)', p.expression + assert_equal '(hi[5].wat..old)', p.expression + end + + def test_arguments + p = Parser.new("filter: hi.there[5], keyarg: 7") + assert_equal 'filter', p.consume(:id) + assert_equal ':', p.consume(:colon) + assert_equal 'hi.there[5]', p.argument + assert_equal ',', p.consume(:comma) + assert_equal 'keyarg: 7', p.argument + end + + def test_invalid_expression + assert_raises(SyntaxError) do + p = Parser.new("==") + p.expression + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/regexp_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/regexp_unit_test.rb new file mode 100644 index 0000000..0821229 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/regexp_unit_test.rb @@ -0,0 +1,44 @@ +require 'test_helper' + +class RegexpUnitTest < Minitest::Test + include Liquid + + def test_empty + assert_equal [], ''.scan(QuotedFragment) + end + + def test_quote + assert_equal ['"arg 1"'], '"arg 1"'.scan(QuotedFragment) + end + + def test_words + assert_equal ['arg1', 'arg2'], 'arg1 arg2'.scan(QuotedFragment) + end + + def test_tags + assert_equal ['', ''], ' '.scan(QuotedFragment) + assert_equal [''], ''.scan(QuotedFragment) + assert_equal ['', ''], %().scan(QuotedFragment) + end + + def test_double_quoted_words + assert_equal ['arg1', 'arg2', '"arg 3"'], 'arg1 arg2 "arg 3"'.scan(QuotedFragment) + end + + def test_single_quoted_words + assert_equal ['arg1', 'arg2', "'arg 3'"], 'arg1 arg2 \'arg 3\''.scan(QuotedFragment) + end + + def test_quoted_words_in_the_middle + assert_equal ['arg1', 'arg2', '"arg 3"', 'arg4'], 'arg1 arg2 "arg 3" arg4 '.scan(QuotedFragment) + end + + def test_variable_parser + assert_equal ['var'], 'var'.scan(VariableParser) + assert_equal ['var', 'method'], 'var.method'.scan(VariableParser) + assert_equal ['var', '[method]'], 'var[method]'.scan(VariableParser) + assert_equal ['var', '[method]', '[0]'], 'var[method][0]'.scan(VariableParser) + assert_equal ['var', '["method"]', '[0]'], 'var["method"][0]'.scan(VariableParser) + assert_equal ['var', '[method]', '[0]', 'method'], 'var[method][0].method'.scan(VariableParser) + end +end # RegexpTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/strainer_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/strainer_unit_test.rb new file mode 100644 index 0000000..5ce2100 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/strainer_unit_test.rb @@ -0,0 +1,164 @@ +require 'test_helper' + +class StrainerUnitTest < Minitest::Test + include Liquid + + module AccessScopeFilters + def public_filter + "public" + end + + def private_filter + "private" + end + private :private_filter + end + + Strainer.global_filter(AccessScopeFilters) + + def test_strainer + strainer = Strainer.create(nil) + assert_equal 5, strainer.invoke('size', 'input') + assert_equal "public", strainer.invoke("public_filter") + end + + def test_stainer_raises_argument_error + strainer = Strainer.create(nil) + assert_raises(Liquid::ArgumentError) do + strainer.invoke("public_filter", 1) + end + end + + def test_stainer_argument_error_contains_backtrace + strainer = Strainer.create(nil) + begin + strainer.invoke("public_filter", 1) + rescue Liquid::ArgumentError => e + assert_match( + /\ALiquid error: wrong number of arguments \((1 for 0|given 1, expected 0)\)\z/, + e.message) + assert_equal e.backtrace[0].split(':')[0], __FILE__ + end + end + + def test_strainer_only_invokes_public_filter_methods + strainer = Strainer.create(nil) + assert_equal false, strainer.class.invokable?('__test__') + assert_equal false, strainer.class.invokable?('test') + assert_equal false, strainer.class.invokable?('instance_eval') + assert_equal false, strainer.class.invokable?('__send__') + assert_equal true, strainer.class.invokable?('size') # from the standard lib + end + + def test_strainer_returns_nil_if_no_filter_method_found + strainer = Strainer.create(nil) + assert_nil strainer.invoke("private_filter") + assert_nil strainer.invoke("undef_the_filter") + end + + def test_strainer_returns_first_argument_if_no_method_and_arguments_given + strainer = Strainer.create(nil) + assert_equal "password", strainer.invoke("undef_the_method", "password") + end + + def test_strainer_only_allows_methods_defined_in_filters + strainer = Strainer.create(nil) + assert_equal "1 + 1", strainer.invoke("instance_eval", "1 + 1") + assert_equal "puts", strainer.invoke("__send__", "puts", "Hi Mom") + assert_equal "has_method?", strainer.invoke("invoke", "has_method?", "invoke") + end + + def test_strainer_uses_a_class_cache_to_avoid_method_cache_invalidation + a = Module.new + b = Module.new + strainer = Strainer.create(nil, [a, b]) + assert_kind_of Strainer, strainer + assert_kind_of a, strainer + assert_kind_of b, strainer + assert_kind_of Liquid::StandardFilters, strainer + end + + def test_add_filter_when_wrong_filter_class + c = Context.new + s = c.strainer + wrong_filter = ->(v) { v.reverse } + + assert_raises ArgumentError do + s.class.add_filter(wrong_filter) + end + end + + module PrivateMethodOverrideFilter + private + + def public_filter + "overriden as private" + end + end + + def test_add_filter_raises_when_module_privately_overrides_registered_public_methods + strainer = Context.new.strainer + + error = assert_raises(Liquid::MethodOverrideError) do + strainer.class.add_filter(PrivateMethodOverrideFilter) + end + assert_equal 'Liquid error: Filter overrides registered public methods as non public: public_filter', error.message + end + + module ProtectedMethodOverrideFilter + protected + + def public_filter + "overriden as protected" + end + end + + def test_add_filter_raises_when_module_overrides_registered_public_method_as_protected + strainer = Context.new.strainer + + error = assert_raises(Liquid::MethodOverrideError) do + strainer.class.add_filter(ProtectedMethodOverrideFilter) + end + assert_equal 'Liquid error: Filter overrides registered public methods as non public: public_filter', error.message + end + + module PublicMethodOverrideFilter + def public_filter + "public" + end + end + + def test_add_filter_does_not_raise_when_module_overrides_previously_registered_method + strainer = Context.new.strainer + strainer.class.add_filter(PublicMethodOverrideFilter) + assert strainer.class.filter_methods.include?('public_filter') + end + + module LateAddedFilter + def late_added_filter(input) + "filtered" + end + end + + def test_global_filter_clears_cache + assert_equal 'input', Strainer.create(nil).invoke('late_added_filter', 'input') + Strainer.global_filter(LateAddedFilter) + assert_equal 'filtered', Strainer.create(nil).invoke('late_added_filter', 'input') + end + + def test_add_filter_does_not_include_already_included_module + mod = Module.new do + class << self + attr_accessor :include_count + def included(mod) + self.include_count += 1 + end + end + self.include_count = 0 + end + strainer = Context.new.strainer + strainer.class.add_filter(mod) + strainer.class.add_filter(mod) + assert_equal 1, mod.include_count + end +end # StrainerTest diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tag_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tag_unit_test.rb new file mode 100644 index 0000000..c4b901b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tag_unit_test.rb @@ -0,0 +1,21 @@ +require 'test_helper' + +class TagUnitTest < Minitest::Test + include Liquid + + def test_tag + tag = Tag.parse('tag', "", Tokenizer.new(""), ParseContext.new) + assert_equal 'liquid::tag', tag.name + assert_equal '', tag.render(Context.new) + end + + def test_return_raw_text_of_tag + tag = Tag.parse("long_tag", "param1, param2, param3", Tokenizer.new(""), ParseContext.new) + assert_equal("long_tag param1, param2, param3", tag.raw) + end + + def test_tag_name_should_return_name_of_the_tag + tag = Tag.parse("some_tag", "", Tokenizer.new(""), ParseContext.new) + assert_equal 'some_tag', tag.tag_name + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/case_tag_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/case_tag_unit_test.rb new file mode 100644 index 0000000..7110308 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/case_tag_unit_test.rb @@ -0,0 +1,10 @@ +require 'test_helper' + +class CaseTagUnitTest < Minitest::Test + include Liquid + + def test_case_nodelist + template = Liquid::Template.parse('{% case var %}{% when true %}WHEN{% else %}ELSE{% endcase %}') + assert_equal ['WHEN', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/for_tag_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/for_tag_unit_test.rb new file mode 100644 index 0000000..b8fc520 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/for_tag_unit_test.rb @@ -0,0 +1,13 @@ +require 'test_helper' + +class ForTagUnitTest < Minitest::Test + def test_for_nodelist + template = Liquid::Template.parse('{% for item in items %}FOR{% endfor %}') + assert_equal ['FOR'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten + end + + def test_for_else_nodelist + template = Liquid::Template.parse('{% for item in items %}FOR{% else %}ELSE{% endfor %}') + assert_equal ['FOR', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/if_tag_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/if_tag_unit_test.rb new file mode 100644 index 0000000..7ecfc40 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tags/if_tag_unit_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class IfTagUnitTest < Minitest::Test + def test_if_nodelist + template = Liquid::Template.parse('{% if true %}IF{% else %}ELSE{% endif %}') + assert_equal ['IF', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/template_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/template_unit_test.rb new file mode 100644 index 0000000..6328be5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/template_unit_test.rb @@ -0,0 +1,78 @@ +require 'test_helper' + +class TemplateUnitTest < Minitest::Test + include Liquid + + def test_sets_default_localization_in_document + t = Template.new + t.parse('{%comment%}{%endcomment%}') + assert_instance_of I18n, t.root.nodelist[0].options[:locale] + end + + def test_sets_default_localization_in_context_with_quick_initialization + t = Template.new + t.parse('{%comment%}{%endcomment%}', locale: I18n.new(fixture("en_locale.yml"))) + + locale = t.root.nodelist[0].options[:locale] + assert_instance_of I18n, locale + assert_equal fixture("en_locale.yml"), locale.path + end + + def test_with_cache_classes_tags_returns_the_same_class + original_cache_setting = Liquid.cache_classes + Liquid.cache_classes = true + + original_klass = Class.new + Object.send(:const_set, :CustomTag, original_klass) + Template.register_tag('custom', CustomTag) + + Object.send(:remove_const, :CustomTag) + + new_klass = Class.new + Object.send(:const_set, :CustomTag, new_klass) + + assert Template.tags['custom'].equal?(original_klass) + ensure + Object.send(:remove_const, :CustomTag) + Template.tags.delete('custom') + Liquid.cache_classes = original_cache_setting + end + + def test_without_cache_classes_tags_reloads_the_class + original_cache_setting = Liquid.cache_classes + Liquid.cache_classes = false + + original_klass = Class.new + Object.send(:const_set, :CustomTag, original_klass) + Template.register_tag('custom', CustomTag) + + Object.send(:remove_const, :CustomTag) + + new_klass = Class.new + Object.send(:const_set, :CustomTag, new_klass) + + assert Template.tags['custom'].equal?(new_klass) + ensure + Object.send(:remove_const, :CustomTag) + Template.tags.delete('custom') + Liquid.cache_classes = original_cache_setting + end + + class FakeTag; end + + def test_tags_delete + Template.register_tag('fake', FakeTag) + assert_equal FakeTag, Template.tags['fake'] + + Template.tags.delete('fake') + assert_nil Template.tags['fake'] + end + + def test_tags_can_be_looped_over + Template.register_tag('fake', FakeTag) + result = Template.tags.map { |name, klass| [name, klass] } + assert result.include?(["fake", "TemplateUnitTest::FakeTag"]) + ensure + Template.tags.delete('fake') + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tokenizer_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tokenizer_unit_test.rb new file mode 100644 index 0000000..de84c1f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/tokenizer_unit_test.rb @@ -0,0 +1,55 @@ +require 'test_helper' + +class TokenizerTest < Minitest::Test + def test_tokenize_strings + assert_equal [' '], tokenize(' ') + assert_equal ['hello world'], tokenize('hello world') + end + + def test_tokenize_variables + assert_equal ['{{funk}}'], tokenize('{{funk}}') + assert_equal [' ', '{{funk}}', ' '], tokenize(' {{funk}} ') + assert_equal [' ', '{{funk}}', ' ', '{{so}}', ' ', '{{brother}}', ' '], tokenize(' {{funk}} {{so}} {{brother}} ') + assert_equal [' ', '{{ funk }}', ' '], tokenize(' {{ funk }} ') + end + + def test_tokenize_blocks + assert_equal ['{%comment%}'], tokenize('{%comment%}') + assert_equal [' ', '{%comment%}', ' '], tokenize(' {%comment%} ') + + assert_equal [' ', '{%comment%}', ' ', '{%endcomment%}', ' '], tokenize(' {%comment%} {%endcomment%} ') + assert_equal [' ', '{% comment %}', ' ', '{% endcomment %}', ' '], tokenize(" {% comment %} {% endcomment %} ") + end + + def test_calculate_line_numbers_per_token_with_profiling + assert_equal [1], tokenize_line_numbers("{{funk}}") + assert_equal [1, 1, 1], tokenize_line_numbers(" {{funk}} ") + assert_equal [1, 2, 2], tokenize_line_numbers("\n{{funk}}\n") + assert_equal [1, 1, 3], tokenize_line_numbers(" {{\n funk \n}} ") + end + + private + + def tokenize(source) + tokenizer = Liquid::Tokenizer.new(source) + tokens = [] + while t = tokenizer.shift + tokens << t + end + tokens + end + + def tokenize_line_numbers(source) + tokenizer = Liquid::Tokenizer.new(source, true) + line_numbers = [] + loop do + line_number = tokenizer.line_number + if tokenizer.shift + line_numbers << line_number + else + break + end + end + line_numbers + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/variable_unit_test.rb b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/variable_unit_test.rb new file mode 100644 index 0000000..5a21ace --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/test/unit/variable_unit_test.rb @@ -0,0 +1,162 @@ +require 'test_helper' + +class VariableUnitTest < Minitest::Test + include Liquid + + def test_variable + var = create_variable('hello') + assert_equal VariableLookup.new('hello'), var.name + end + + def test_filters + var = create_variable('hello | textileze') + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['textileze', []]], var.filters + + var = create_variable('hello | textileze | paragraph') + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['textileze', []], ['paragraph', []]], var.filters + + var = create_variable(%( hello | strftime: '%Y')) + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['strftime', ['%Y']]], var.filters + + var = create_variable(%( 'typo' | link_to: 'Typo', true )) + assert_equal 'typo', var.name + assert_equal [['link_to', ['Typo', true]]], var.filters + + var = create_variable(%( 'typo' | link_to: 'Typo', false )) + assert_equal 'typo', var.name + assert_equal [['link_to', ['Typo', false]]], var.filters + + var = create_variable(%( 'foo' | repeat: 3 )) + assert_equal 'foo', var.name + assert_equal [['repeat', [3]]], var.filters + + var = create_variable(%( 'foo' | repeat: 3, 3 )) + assert_equal 'foo', var.name + assert_equal [['repeat', [3, 3]]], var.filters + + var = create_variable(%( 'foo' | repeat: 3, 3, 3 )) + assert_equal 'foo', var.name + assert_equal [['repeat', [3, 3, 3]]], var.filters + + var = create_variable(%( hello | strftime: '%Y, okay?')) + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['strftime', ['%Y, okay?']]], var.filters + + var = create_variable(%( hello | things: "%Y, okay?", 'the other one')) + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['things', ['%Y, okay?', 'the other one']]], var.filters + end + + def test_filter_with_date_parameter + var = create_variable(%( '2006-06-06' | date: "%m/%d/%Y")) + assert_equal '2006-06-06', var.name + assert_equal [['date', ['%m/%d/%Y']]], var.filters + end + + def test_filters_without_whitespace + var = create_variable('hello | textileze | paragraph') + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['textileze', []], ['paragraph', []]], var.filters + + var = create_variable('hello|textileze|paragraph') + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['textileze', []], ['paragraph', []]], var.filters + + var = create_variable("hello|replace:'foo','bar'|textileze") + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['replace', ['foo', 'bar']], ['textileze', []]], var.filters + end + + def test_symbol + var = create_variable("http://disney.com/logo.gif | image: 'med' ", error_mode: :lax) + assert_equal VariableLookup.new('http://disney.com/logo.gif'), var.name + assert_equal [['image', ['med']]], var.filters + end + + def test_string_to_filter + var = create_variable("'http://disney.com/logo.gif' | image: 'med' ") + assert_equal 'http://disney.com/logo.gif', var.name + assert_equal [['image', ['med']]], var.filters + end + + def test_string_single_quoted + var = create_variable(%( "hello" )) + assert_equal 'hello', var.name + end + + def test_string_double_quoted + var = create_variable(%( 'hello' )) + assert_equal 'hello', var.name + end + + def test_integer + var = create_variable(%( 1000 )) + assert_equal 1000, var.name + end + + def test_float + var = create_variable(%( 1000.01 )) + assert_equal 1000.01, var.name + end + + def test_dashes + assert_equal VariableLookup.new('foo-bar'), create_variable('foo-bar').name + assert_equal VariableLookup.new('foo-bar-2'), create_variable('foo-bar-2').name + + with_error_mode :strict do + assert_raises(Liquid::SyntaxError) { create_variable('foo - bar') } + assert_raises(Liquid::SyntaxError) { create_variable('-foo') } + assert_raises(Liquid::SyntaxError) { create_variable('2foo') } + end + end + + def test_string_with_special_chars + var = create_variable(%( 'hello! $!@.;"ddasd" ' )) + assert_equal 'hello! $!@.;"ddasd" ', var.name + end + + def test_string_dot + var = create_variable(%( test.test )) + assert_equal VariableLookup.new('test.test'), var.name + end + + def test_filter_with_keyword_arguments + var = create_variable(%( hello | things: greeting: "world", farewell: 'goodbye')) + assert_equal VariableLookup.new('hello'), var.name + assert_equal [['things', [], { 'greeting' => 'world', 'farewell' => 'goodbye' }]], var.filters + end + + def test_lax_filter_argument_parsing + var = create_variable(%( number_of_comments | pluralize: 'comment': 'comments' ), error_mode: :lax) + assert_equal VariableLookup.new('number_of_comments'), var.name + assert_equal [['pluralize', ['comment', 'comments']]], var.filters + end + + def test_strict_filter_argument_parsing + with_error_mode(:strict) do + assert_raises(SyntaxError) do + create_variable(%( number_of_comments | pluralize: 'comment': 'comments' )) + end + end + end + + def test_output_raw_source_of_variable + var = create_variable(%( name_of_variable | upcase )) + assert_equal " name_of_variable | upcase ", var.raw + end + + def test_variable_lookup_interface + lookup = VariableLookup.new('a.b.c') + assert_equal 'a', lookup.name + assert_equal ['b', 'c'], lookup.lookups + end + + private + + def create_variable(markup, options = {}) + Variable.new(markup, ParseContext.new(options)) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/CHANGELOG.md b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/CHANGELOG.md new file mode 100644 index 0000000..232adbd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/CHANGELOG.md @@ -0,0 +1 @@ +# Moved to [GitHub releases](https://github.com/guard/listen/releases) page. diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/CONTRIBUTING.md b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/CONTRIBUTING.md new file mode 100644 index 0000000..7e5b197 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/CONTRIBUTING.md @@ -0,0 +1,45 @@ +Contribute to Listen +=================== + +File an issue +------------- + +If you haven't already, first see [TROUBLESHOOTING](https://github.com/guard/listen/blob/master/README.md#Issues-and-Troubleshooting) for known issues, solutions and workarounds. + +You can report bugs and feature requests to [GitHub Issues](https://github.com/guard/listen/issues). + +**Please don't ask question in the issue tracker**, instead ask them in our +[Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net). + +Try to figure out where the issue belongs to: Is it an issue with Listen itself or with Guard? + + +**It's most likely that your bug gets resolved faster if you provide as much information as possible!** + +The MOST useful information is debugging output from Listen (`LISTEN_GEM_DEBUGGING=1`) - see [TROUBLESHOOTING](https://github.com/guard/listen/blob/master/README.md#Issues-and-Troubleshooting) for details. + + +Development +----------- + +* Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/listen/master/frames). +* Source hosted at [GitHub](https://github.com/guard/listen). + +Pull requests are very welcome! Please try to follow these simple rules if applicable: + +* Please create a topic branch for every separate change you make. +* Make sure your patches are well tested. All specs run with `rake spec` must pass. +* Update the [Yard](http://yardoc.org/) documentation. +* Update the [README](https://github.com/guard/listen/blob/master/README.md). +* Please **do not change** the version number. + +The title of your PR will automatically be included in the release notes for the next version of the gem. A maintainer can add one of the following GitHub labels to the PR to automatically categorize it when the release notes are generated: + +- ⚠️ Breaking +- ✨ Feature +- 🐛 Bug Fix +- 📚 Docs +- 🏠 Housekeeping + +For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on +`#guard` (irc.freenode.net). diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/LICENSE.txt new file mode 100644 index 0000000..b5f71c8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2013 Thibaud Guillaume-Gentil + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/README.md b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/README.md new file mode 100644 index 0000000..cc59e02 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/README.md @@ -0,0 +1,491 @@ +# Listen + +The `listen` gem listens to file modifications and notifies you about the changes. + +[![Development Status](https://github.com/guard/listen/workflows/Development/badge.svg)](https://github.com/guard/listen/actions?workflow=Development) +[![Gem Version](https://badge.fury.io/rb/listen.svg)](http://badge.fury.io/rb/listen) +[![Code Climate](https://codeclimate.com/github/guard/listen.svg)](https://codeclimate.com/github/guard/listen) +[![Coverage Status](https://coveralls.io/repos/guard/listen/badge.svg?branch=master)](https://coveralls.io/r/guard/listen) + +## Features + +* OS-optimized adapters on MRI for Mac OS X 10.6+, Linux, \*BSD and Windows, [more info](#listen-adapters) below. +* Detects file modification, addition and removal. +* You can watch multiple directories. +* Regexp-patterns for ignoring paths for more accuracy and speed +* Increased change detection accuracy on OS X HFS and VFAT volumes. +* Continuous Integration: tested on selected Ruby environments via [Github Workflows](https://github.com/guard/listen/tree/master/.github/workflows). + +## Issues / limitations + +* Limited support for symlinked directories ([#279](https://github.com/guard/listen/issues/279)): + * Symlinks are always followed ([#25](https://github.com/guard/listen/issues/25)). + * Symlinked directories pointing within a watched directory are not supported ([#273](https://github.com/guard/listen/pull/273). +* No directory/adapter-specific configuration options. +* Support for plugins planned for future. +* TCP functionality was removed in `listen` [3.0.0](https://github.com/guard/listen/releases/tag/v3.0.0) ([#319](https://github.com/guard/listen/issues/319), [#218](https://github.com/guard/listen/issues/218)). There are plans to extract this feature to separate gems ([#258](https://github.com/guard/listen/issues/258)), until this is finished, you can use by locking the `listen` gem to version `'~> 2.10'`. +* Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.). +* Windows and \*BSD adapter aren't continuously and automatically tested. +* OSX adapter has some performance limitations ([#342](https://github.com/guard/listen/issues/342)). +* Listeners do not notify across forked processes, if you wish for multiple processes to receive change notifications you must [listen inside of each process](https://github.com/guard/listen/issues/398#issuecomment-223957952). + +Pull requests or help is very welcome for these. + +## Install + +The simplest way to install `listen` is to use [Bundler](http://bundler.io). + +```ruby +gem 'listen' +``` + +## Complete Example +Here is a complete example of using the `listen` gem: +```ruby +require 'listen' + +listener = Listen.to('/srv/app') do |modified, added, removed| + puts(modified: modified, added: added, removed: removed) +end +listener.start +sleep +``` +Running the above in the background, you can see the callback block being called in response to each command: +``` +$ cd /srv/app +$ touch a.txt +{:modified=>[], :added=>["/srv/app/a.txt"], :removed=>[]} + +$ echo more >> a.txt +{:modified=>["/srv/app/a.txt"], :added=>[], :removed=>[]} + +$ mv a.txt b.txt +{:modified=>[], :added=>["/srv/app/b.txt"], :removed=>["/srv/app/a.txt"]} + +$ vi b.txt +# add a line to this new file and press ZZ to save and exit +{:modified=>["/srv/app/b.txt"], :added=>[], :removed=>[]} + +$ vi c.txt +# add a line and press ZZ to save and exit +{:modified=>[], :added=>["/srv/app/c.txt"], :removed=>[]} + +$ rm b.txt c.txt +{:modified=>[], :added=>[], :removed=>["/srv/app/b.txt", "/srv/app/c.txt"]} +``` + +## Usage + +Call `Listen.to` with one or more directories and the "changes" callback passed as a block. + +``` ruby +listener = Listen.to('dir/to/listen', 'dir/to/listen2') do |modified, added, removed| + puts "modified absolute path array: #{modified}" + puts "added absolute path array: #{added}" + puts "removed absolute path array: #{removed}" +end +listener.start # starts a listener thread--does not block + +# do whatever you want here...just don't exit the process :) + +sleep +``` +## Changes Callback + +Changes to the listened-to directories are reported by the listener thread in a callback. +The callback receives **three** array parameters: `modified`, `added` and `removed`, in that order. +Each of these three is always an array with 0 or more entries. +Each array entry is an absolute path. + +### Pause / start / stop + +Listeners can also be easily paused and later un-paused with start: + +``` ruby +listener = Listen.to('dir/path/to/listen') { |modified, added, removed| puts 'handle changes here...' } + +listener.start +listener.paused? # => false +listener.processing? # => true + +listener.pause # stops processing changes (but keeps on collecting them) +listener.paused? # => true +listener.processing? # => false + +listener.start # resumes processing changes +listener.stop # stop both listening to changes and processing them +``` + + Note: While paused, `listen` keeps on collecting changes in the background - to clear them, call `stop`. + + Note: You should keep track of all started listeners and `stop` them properly on finish. + +### Ignore / ignore! + +`Listen` ignores some directories and extensions by default (See DEFAULT_IGNORED_FILES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer). +You can add ignoring patterns with the `ignore` option/method or overwrite default with `ignore!` option/method. + +``` ruby +listener = Listen.to('dir/path/to/listen', ignore: /\.txt/) { |modified, added, removed| # ... } +listener.start +listener.ignore! /\.pkg/ # overwrite all patterns and only ignore pkg extension. +listener.ignore /\.rb/ # ignore rb extension in addition of pkg. +sleep +``` + +Note: `:ignore` regexp patterns are evaluated against relative paths. + +Note: Ignoring paths does not improve performance, except when Polling ([#274](https://github.com/guard/listen/issues/274)). + +### Only + +`Listen` watches all files (less the ignored ones) by default. If you want to only listen to a specific type of file (i.e., just `.rb` extension), you should use the `only` option/method. + +``` ruby +listener = Listen.to('dir/path/to/listen', only: /\.rb$/) { |modified, added, removed| # ... } +listener.start +listener.only /_spec\.rb$/ # overwrite all existing only patterns. +sleep +``` + +Note: `:only` regexp patterns are evaluated only against relative **file** paths. + + +## Options + +All the following options can be set through the `Listen.to` after the directory path(s) params. + +``` ruby +ignore: [%r{/foo/bar}, /\.pid$/, /\.coffee$/] # Ignore a list of paths + # default: See DEFAULT_IGNORED_FILES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer + +ignore!: %r{/foo/bar} # Same as ignore options, but overwrite default ignored paths. + +only: %r{.rb$} # Only listen to specific files + # default: none + +latency: 0.5 # Set the delay (**in seconds**) between checking for changes + # default: 0.25 sec (1.0 sec for polling) + +wait_for_delay: 4 # Set the delay (**in seconds**) between calls to the callback when changes exist + # default: 0.10 sec + +force_polling: true # Force the use of the polling adapter + # default: none + +relative: false # Whether changes should be relative to current dir or not + # default: false + +polling_fallback_message: 'custom message' # Set a custom polling fallback message (or disable it with false) + # default: "Listen will be polling for changes. Learn more at https://github.com/guard/listen#listen-adapters." +``` + +## Logging and Debugging + +`Listen` logs its activity to `Listen.logger`. +This is the primary method of debugging. + +### Custom Logger +You can call `Listen.logger =` to set a custom `listen` logger for the process. For example: +``` ruby +Listen.logger = Rails.logger +``` + +### Default Logger +If no custom logger is set, a default `listen` logger which logs to to `STDERR` will be created and assigned to `Listen.logger`. + +The default logger defaults to the `error` logging level (severity). +You can override the logging level by setting the environment variable `LISTEN_GEM_DEBUGGING=`. +For ``, all standard `::Logger` levels are supported, with any mix of upper-/lower-case: +``` ruby +export LISTEN_GEM_DEBUGGING=debug # or 2 [deprecated] +export LISTEN_GEM_DEBUGGING=info # or 1 or true or yes [deprecated] +export LISTEN_GEM_DEBUGGING=warn +export LISTEN_GEM_DEBUGGING=fatal +export LISTEN_GEM_DEBUGGING=error +``` +The default of `error` will be used if an unsupported value is set. + +Note: The alternate values `1`, `2`, `true` and `yes` shown above are deprecated and will be removed from `listen` v4.0. + +### Disabling Logging +If you want to disable `listen` logging, set +``` ruby +Listen.logger = ::Logger.new('/dev/null') +``` + +### Adapter Warnings +If listen is having trouble with the underlying adapter, it will display warnings with `Kernel#warn` by default, +which in turn writes to STDERR. +Sometimes this is not desirable, for example in an environment where STDERR is ignored. +For these reasons, the behavior can be configured using `Listen.adapter_warn_behavior =`: +``` ruby +Listen.adapter_warn_behavior = :warn # default (true means the same) +Listen.adapter_warn_behavior = :log # send to logger.warn +Listen.adapter_warn_behavior = :silent # suppress all adapter warnings (nil or false mean the same) +``` +Also there are some cases where specific warnings are not helpful. +For example, if you are using the polling adapter--and expect to--you can suppress the warning about it +by providing a callable object like a lambda or proc that determines the behavior based on the `message`: +``` ruby +Listen.adapter_warn_behavior = ->(message) do + case message + when /Listen will be polling for changes/ + :silent + when /directory is already being watched/ + :log + else + :warn + end +end +``` +In cases where the `Listen` gem is embedded inside another service--such as `guard`--the above configuration +can be set in the environment variable `LISTEN_GEM_ADAPTER_WARN_BEHAVIOR=warn|log|silent`. + +## Listen Adapters + +The `Listen` gem has a set of adapters to notify it when there are changes. + +There are 4 OS-specific adapters to support Darwin, Linux, \*BSD and Windows. +These adapters are fast as they use some system-calls to implement the notifying function. + +There is also a polling adapter - although it's much slower than other adapters, +it works on every platform/system and scenario (including network filesystems such as VM shared folders). + +The Darwin and Linux adapters are dependencies of the `listen` gem so they work out of the box. For other adapters a specific gem will have to be added to your Gemfile, please read below. + +The `listen` gem will choose the best adapter automatically, if present. If you +want to force the use of the polling adapter, use the `:force_polling` option +while initializing the listener. + +### On Windows + +If you are on Windows, it's recommended to use the [`wdm`](https://github.com/Maher4Ever/wdm) adapter instead of polling. + +Please add the following to your Gemfile: + +```ruby +gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +``` + +### On \*BSD + +If you are on \*BSD you can try to use the [`rb-kqueue`](https://github.com/mat813/rb-kqueue) adapter instead of polling. + +Please add the following to your Gemfile: + +```ruby +require 'rbconfig' +if RbConfig::CONFIG['target_os'] =~ /bsd|dragonfly/i + gem 'rb-kqueue', '>= 0.2' +end + +``` + +### Getting the [polling fallback message](#options)? + +If you see: +``` +Listen will be polling for changes. +``` + +This means the Listen gem can’t find an optimized adapter. Typically this is caused by: + +- You’re on Windows and WDM gem isn’t installed. +- You’re running the app without Bundler or RubyGems. +- Using Sass which includes an ancient (the “dinosaur” type of ancient) version of the Listen gem. + +Possible solutions: + +1. Suppress the message by using the :force_polling option. Or, you could just ignore the message since it’s harmless. +2. Windows users: Install the WDM gem. +3. Upgrade Ruby (use RubyInstaller for Windows or RVM/rbenv for Mac) and RubyGems. +3. Run your apps using Bundler. +4. Sass users: Install the latest version of Listen and try again. + +#### Simplified Bundler and Sass example +Create a Gemfile with these lines: +``` +source 'https://rubygems.org' +gem 'listen' +gem 'sass' +``` +Next, use Bundler to update gems: +``` +$ bundle update +$ bundle exec sass --watch # ... or whatever app is using Listen. +``` + +### Increasing the amount of inotify watchers + +If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal: +``` +$ sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf" +$ sudo sysctl -p +``` +If you are running ArchLinux, search the `/etc/sysctl.d/` directory for config files with the setting: +``` +$ grep -H -s "fs.inotify.max_user_watches" /etc/sysctl.d/* +/etc/sysctl.d/40-max_user_watches.conf:fs.inotify.max_user_watches=100000 +``` +Then change the setting in the file you found above to a higher value (see [here](https://www.archlinux.org/news/deprecation-of-etcsysctlconf/) for why): +``` +$ sudo sh -c "echo fs.inotify.max_user_watches=524288 > /etc/sysctl.d/40-max-user-watches.conf" +$ sudo sysctl --system +``` + +#### The technical details +Listen uses `inotify` by default on Linux to monitor directories for changes. +It's not uncommon to encounter a system limit on the number of files you can monitor. +For example, Ubuntu Lucid's (64bit) `inotify` limit is set to 8192. + +You can get your current inotify file watch limit by executing: +``` +$ cat /proc/sys/fs/inotify/max_user_watches +``` +When this limit is not enough to monitor all files inside a directory, the limit must be increased for Listen to work properly. + +You can set a new limit temporarily with: +``` +$ sudo sysctl fs.inotify.max_user_watches=524288 +$ sudo sysctl -p +``` +If you like to make your limit permanent, use: +``` +$ sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf" +$ sudo sysctl -p +``` +You may also need to pay attention to the values of `max_queued_events` and `max_user_instances` if Listen keeps on complaining. + +#### More info +Man page for [inotify(7)](https://linux.die.net/man/7/inotify). +Blog post: [limit of inotify](https://blog.sorah.jp/2012/01/24/inotify-limitation). + +### Issues and Troubleshooting + +If the gem doesn't work as expected, start by setting `LISTEN_GEM_DEBUGGING=debug` or `LISTEN_GEM_DEBUGGING=info` as described above in [Logging and Debugging](#logging-and-debugging). + +*NOTE: without providing the output after setting the `LISTEN_GEM_DEBUGGING=debug` environment variable, it is usually impossible to guess why `listen` is not working as expected.* + +#### 3 steps before you start diagnosing problems +These 3 steps will: + +- help quickly troubleshoot obscure problems (trust me, most of them are obscure) +- help quickly identify the area of the problem (a full list is below) +- help you get familiar with listen's diagnostic mode (it really comes in handy, trust me) +- help you create relevant output before you submit an issue (so we can respond with answers instead of tons of questions) + +Step 1 - The most important option in Listen +For effective troubleshooting set the `LISTEN_GEM_DEBUGGING=info` variable before starting `listen`. + +Step 2 - Verify polling works +Polling has to work ... or something is really wrong (and we need to know that before anything else). + +(see force_polling option). + +After starting `listen`, you should see something like: +``` +INFO -- : Record.build(): 0.06773114204406738 seconds +``` +Step 3 - Trigger some changes directly without using editors or apps +Make changes e.g. touch foo or echo "a" >> foo (for troubleshooting, avoid using an editor which could generate too many misleading events). + +You should see something like: +``` +INFO -- : listen: raw changes: [[:added, "/home/me/foo"]] +INFO -- : listen: final changes: {:modified=>[], :added=>["/home/me/foo"], :removed=>[]} +``` +"raw changes" contains changes collected during the :wait_for_delay and :latency intervals, while "final changes" is what listen decided are relevant changes (for better editor support). + +## Performance + +If `listen` seems slow or unresponsive, make sure you're not using the Polling adapter (you should see a warning upon startup if you are). + +Also, if the directories you're watching contain many files, make sure you're: + +* not using Polling (ideally) +* using `:ignore` and `:only` options to avoid tracking directories you don't care about (important with Polling and on MacOS) +* running `listen` with the `:latency` and `:wait_for_delay` options not too small or too big (depends on needs) +* not watching directories with log files, database files or other frequently changing files +* not using a version of `listen` prior to 2.7.7 +* not getting silent crashes within `listen` (see `LISTEN_GEM_DEBUGGING=debug`) +* not running multiple instances of `listen` in the background +* using a file system with atime modification disabled (ideally) +* not using a filesystem with inaccurate file modification times (ideally), e.g. HFS, VFAT +* not buffering to a slow terminal (e.g. transparency + fancy font + slow gfx card + lots of output) +* ideally not running a slow encryption stack, e.g. btrfs + ecryptfs + +When in doubt, `LISTEN_GEM_DEBUGGING=debug` can help discover the actual events and time they happened. + +## Tips and Techniques +- Watch only directories you're interested in. +- Set your editor to save quickly (e.g. without backup files, without atomic-save) +- Tweak the `:latency` and `:wait_for_delay` options until you get good results (see [options](#options)). +- Add `:ignore` rules to silence all events you don't care about (reduces a lot of noise, especially if you use it on directories) + +## Development + +* Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/listen/master/frames). +* Source hosted at [GitHub](https://github.com/guard/listen). + +Pull requests are very welcome! Please try to follow these simple rules if applicable: + +* Please create a topic branch for every separate change you make. +* Make sure your patches are well tested. All specs must pass on [Travis CI](https://travis-ci.org/guard/listen). +* Update the [Yard](http://yardoc.org/) documentation. +* Update the [README](https://github.com/guard/listen/blob/master/README.md). +* Please **do not change** the version number. + +For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on +`#guard` (irc.freenode.net). + +## Releasing + +### Prerequisites + +* You must have commit rights to the GitHub repository. +* You must have push rights for rubygems.org. + +### How to release + +1. Run `bundle install` to make sure that you have all the gems necessary for testing and releasing. +2. **Ensure all tests are passing by running `bundle exec rake`.** +3. Determine which would be the correct next version number according to [semver](http://semver.org/). +4. Update the version in `./lib/listen/version.rb`. +5. Update the version in the Install section of `./README.md` (`gem 'listen', '~> X.Y'`). +6. Commit the version in a single commit, the message should be "Preparing vX.Y.Z" +7. Run `bundle exec rake release:full`; this will tag, push to GitHub, and publish to rubygems.org. +8. Update and publish the release notes on the [GitHub releases page](https://github.com/guard/listen/releases) if necessary + +## Acknowledgments + +* [Michael Kessler (netzpirat)][] for having written the [initial specs](https://github.com/guard/listen/commit/1e457b13b1bb8a25d2240428ce5ed488bafbed1f). +* [Travis Tilley (ttilley)][] for this awesome work on [fssm][] & [rb-fsevent][]. +* [Natalie Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper. +* [Mathieu Arnold (mat813)][] for [rb-kqueue][], a simple kqueue wrapper. +* [Maher Sallam][] for [wdm][], windows support wouldn't exist without him. +* [Yehuda Katz (wycats)][] for [vigilo][], that has been a great source of inspiration. + +## Author + +[Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg)) + +## Contributors + +[https://github.com/guard/listen/graphs/contributors](https://github.com/guard/listen/graphs/contributors) + +[Thibaud Guillaume-Gentil (thibaudgg)]: https://github.com/thibaudgg +[Maher Sallam]: https://github.com/Maher4Ever +[Michael Kessler (netzpirat)]: https://github.com/netzpirat +[Travis Tilley (ttilley)]: https://github.com/ttilley +[fssm]: https://github.com/ttilley/fssm +[rb-fsevent]: https://github.com/thibaudgg/rb-fsevent +[Mathieu Arnold (mat813)]: https://github.com/mat813 +[Natalie Weizenbaum (nex3)]: https://github.com/nex3 +[rb-inotify]: https://github.com/nex3/rb-inotify +[stereobooster]: https://github.com/stereobooster +[rb-fchange]: https://github.com/stereobooster/rb-fchange +[rb-kqueue]: https://github.com/mat813/rb-kqueue +[Yehuda Katz (wycats)]: https://github.com/wycats +[vigilo]: https://github.com/wycats/vigilo +[wdm]: https://github.com/Maher4Ever/wdm diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/bin/listen b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/bin/listen new file mode 100755 index 0000000..59ade96 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/bin/listen @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'listen' +require 'listen/cli' + +if !defined?(JRUBY_VERSION) && Signal.list.keys.include?('INT') + Signal.trap('INT') { Thread.new { Listen.stop } } +end + +Listen::CLI.start diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen.rb new file mode 100644 index 0000000..03857fe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'logger' +require 'weakref' +require 'listen/logger' +require 'listen/listener' + +# Won't print anything by default because of level - unless you've set +# LISTEN_GEM_DEBUGGING or provided your own logger with a high enough level +Listen.logger.info "Listen loglevel set to: #{Listen.logger.level}" +Listen.logger.info "Listen version: #{Listen::VERSION}" + +module Listen + @listeners = Queue.new + + class << self + # Listens to file system modifications on a either single directory or + # multiple directories. + # + # @param (see Listen::Listener#new) + # + # @yield [modified, added, removed] the changed files + # @yieldparam [Array] modified the list of modified files + # @yieldparam [Array] added the list of added files + # @yieldparam [Array] removed the list of removed files + # + # @return [Listen::Listener] the listener + # + def to(*args, &block) + Listener.new(*args, &block).tap do |listener| + @listeners.enq(WeakRef.new(listener)) + end + end + + # This is used by the `listen` binary to handle Ctrl-C + # + def stop + while (listener = @listeners.deq(true)) + begin + listener.stop + rescue WeakRef::RefError + end + end + rescue ThreadError + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter.rb new file mode 100644 index 0000000..dce8623 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'listen/adapter/base' +require 'listen/adapter/bsd' +require 'listen/adapter/darwin' +require 'listen/adapter/linux' +require 'listen/adapter/polling' +require 'listen/adapter/windows' + +module Listen + module Adapter + OPTIMIZED_ADAPTERS = [Darwin, Linux, BSD, Windows].freeze + POLLING_FALLBACK_MESSAGE = 'Listen will be polling for changes.'\ + 'Learn more at https://github.com/guard/listen#listen-adapters.' + + class << self + def select(options = {}) + Listen.logger.debug 'Adapter: considering polling ...' + return Polling if options[:force_polling] + Listen.logger.debug 'Adapter: considering optimized backend...' + return _usable_adapter_class if _usable_adapter_class + Listen.logger.debug 'Adapter: falling back to polling...' + _warn_polling_fallback(options) + Polling + rescue + Listen.logger.warn format('Adapter: failed: %s:%s', $ERROR_POSITION.inspect, + $ERROR_POSITION * "\n") + raise + end + + private + + def _usable_adapter_class + OPTIMIZED_ADAPTERS.find(&:usable?) + end + + def _warn_polling_fallback(options) + msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE) + Listen.adapter_warn("[Listen warning]:\n #{msg}") if msg + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/base.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/base.rb new file mode 100644 index 0000000..b7e1039 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/base.rb @@ -0,0 +1,129 @@ +# frozen_string_literal: true + +require 'listen/options' +require 'listen/record' +require 'listen/change' +require 'listen/thread' + +module Listen + module Adapter + class Base + attr_reader :options, :config + + # TODO: only used by tests + DEFAULTS = {}.freeze + + def initialize(config) + @started = false + @config = config + + @configured = nil + + fail 'No directories to watch!' if config.directories.empty? + + defaults = self.class.const_get('DEFAULTS') + @options = Listen::Options.new(config.adapter_options, defaults) + rescue + _log_exception 'adapter config failed: %s:%s called from: %s', caller + raise + end + + # TODO: it's a separate method as a temporary workaround for tests + # rubocop:disable Metrics/MethodLength + def configure + if @configured + Listen.logger.warn('Adapter already configured!') + return + end + + @configured = true + + @callbacks ||= {} + config.directories.each do |dir| + callback = @callbacks[dir] || lambda do |event| + _process_event(dir, event) + end + @callbacks[dir] = callback + _configure(dir, &callback) + end + + @snapshots ||= {} + # TODO: separate config per directory (some day maybe) + change_config = Change::Config.new(config.queue, config.silencer) + config.directories.each do |dir| + record = Record.new(dir, config.silencer) + snapshot = Change.new(change_config, record) + @snapshots[dir] = snapshot + end + end + # rubocop:enable Metrics/MethodLength + + def started? + @started + end + + def start + configure + + if started? + Listen.logger.warn('Adapter already started!') + return + end + + @started = true + + @run_thread = Listen::Thread.new("run_thread") do + @snapshots.each_value do |snapshot| + _timed('Record.build()') { snapshot.record.build } + end + _run + end + end + + def stop + _stop + config.queue.close # this causes queue.pop to return `nil` to the front-end + end + + private + + def _stop + @run_thread&.kill + @run_thread = nil + end + + def _timed(title) + start = MonotonicTime.now + yield + diff = MonotonicTime.now - start + Listen.logger.info format('%s: %.05f seconds', title, diff) + rescue + Listen.logger.warn "#{title} crashed: #{$ERROR_INFO.inspect}" + raise + end + + # TODO: allow backend adapters to pass specific invalidation objects + # e.g. Darwin -> DirRescan, INotify -> MoveScan, etc. + def _queue_change(type, dir, rel_path, options) + @snapshots[dir].invalidate(type, rel_path, options) + end + + def _log_exception(msg, caller_stack) + formatted = format( + msg, + $ERROR_INFO, + $ERROR_POSITION * "\n", + caller_stack * "\n" + ) + + Listen.logger.error(formatted) + end + + class << self + def usable? + const_get('OS_REGEXP') =~ RbConfig::CONFIG['target_os'] + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/bsd.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/bsd.rb new file mode 100644 index 0000000..aafa2ce --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/bsd.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +# Listener implementation for BSD's `kqueue`. +# @see http://www.freebsd.org/cgi/man.cgi?query=kqueue +# @see https://github.com/mat813/rb-kqueue/blob/master/lib/rb-kqueue/queue.rb +# +module Listen + module Adapter + class BSD < Base + OS_REGEXP = /bsd|dragonfly/i.freeze + + DEFAULTS = { + events: [ + :delete, + :write, + :extend, + :attrib, + :rename + # :link, :revoke + ] + }.freeze + + BUNDLER_DECLARE_GEM = <<-EOS.gsub(/^ {6}/, '') + Please add the following to your Gemfile to avoid polling for changes: + require 'rbconfig' + if RbConfig::CONFIG['target_os'] =~ /#{OS_REGEXP}/ + gem 'rb-kqueue', '>= 0.2' + end + EOS + + def self.usable? + return false unless super + require 'rb-kqueue' + require 'find' + true + rescue LoadError + Listen.adapter_warn(BUNDLER_DECLARE_GEM) + false + end + + private + + def _configure(directory, &callback) + @worker ||= KQueue::Queue.new + @callback = callback + # use Record to make a snapshot of dir, so we + # can detect new files + _find(directory.to_s) { |path| _watch_file(path, @worker) } + end + + def _run + @worker.run + end + + def _process_event(dir, event) + full_path = _event_path(event) + if full_path.directory? + # Force dir content tracking to kick in, or we won't have + # names of added files + _queue_change(:dir, dir, '.', recursive: true) + elsif full_path.exist? + path = full_path.relative_path_from(dir) + _queue_change(:file, dir, path.to_s, change: _change(event.flags)) + end + + # If it is a directory, and it has a write flag, it means a + # file has been added so find out which and deal with it. + # No need to check for removed files, kqueue will forget them + # when the vfs does. + _watch_for_new_file(event) if full_path.directory? + end + + def _change(event_flags) + { modified: [:attrib, :extend], + added: [:write], + removed: [:rename, :delete] }.each do |change, flags| + return change unless (flags & event_flags).empty? + end + nil + end + + def _event_path(event) + Pathname.new(event.watcher.path) + end + + def _watch_for_new_file(event) + queue = event.watcher.queue + _find(_event_path(event).to_s) do |file_path| + unless queue.watchers.find { |_, v| v.path == file_path.to_s } + _watch_file(file_path, queue) + end + end + end + + def _watch_file(path, queue) + queue.watch_file(path, *options.events, &@callback) + rescue Errno::ENOENT => e + Listen.logger.warn "kqueue: watch file failed: #{e.message}" + end + + # Quick rubocop workaround + def _find(*paths, &block) + Find.send(:find, *paths, &block) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/config.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/config.rb new file mode 100644 index 0000000..5a068a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/config.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'pathname' + +module Listen + module Adapter + class Config + attr_reader :directories, :silencer, :queue, :adapter_options + + def initialize(directories, queue, silencer, adapter_options) + # Default to current directory if no directories are supplied + directories = [Dir.pwd] if directories.to_a.empty? + + # TODO: fix (flatten, array, compact?) + @directories = directories.map do |directory| + Pathname.new(directory.to_s).realpath + end + + @directories.each do |pathname| + unless pathname.directory? + fail ArgumentError, "must be a directory: #{pathname}" + end + end + + @silencer = silencer + @queue = queue + @adapter_options = adapter_options + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/darwin.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/darwin.rb new file mode 100644 index 0000000..3a610c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/darwin.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +require 'listen/thread' + +module Listen + module Adapter + # Adapter implementation for Mac OS X `FSEvents`. + # + class Darwin < Base + OS_REGEXP = /darwin(?(1|2)\d+)/i.freeze + + # The default delay between checking for changes. + DEFAULTS = { latency: 0.1 }.freeze + + INCOMPATIBLE_GEM_VERSION = <<-EOS.gsub(/^ {8}/, '') + rb-fsevent > 0.9.4 no longer supports OS X 10.6 through 10.8. + + Please add the following to your Gemfile to avoid polling for changes: + require 'rbconfig' + if RbConfig::CONFIG['target_os'] =~ /darwin(1[0-3])/i + gem 'rb-fsevent', '<= 0.9.4' + end + EOS + + def self.usable? + version = RbConfig::CONFIG['target_os'][OS_REGEXP, :major_version] + return false unless version + return true if version.to_i >= 13 # darwin13 is OS X 10.9 + + require 'rb-fsevent' + fsevent_version = Gem::Version.new(FSEvent::VERSION) + return true if fsevent_version <= Gem::Version.new('0.9.4') + Listen.adapter_warn(INCOMPATIBLE_GEM_VERSION) + false + end + + private + + def _configure(dir, &callback) + @callbacks[dir] = callback + end + + def _run + require 'rb-fsevent' + worker = FSEvent.new + dirs_to_watch = @callbacks.keys.map(&:to_s) + Listen.logger.info { "fsevent: watching: #{dirs_to_watch.inspect}" } + worker.watch(dirs_to_watch, { latency: options.latency }, &method(:_process_changes)) + @worker_thread = Listen::Thread.new("worker_thread") { worker.run } + end + + def _process_changes(dirs) + dirs.each do |dir| + dir = Pathname.new(dir.sub(%r{/$}, '')) + + @callbacks.each do |watched_dir, callback| + if watched_dir.eql?(dir) || Listen::Directory.ascendant_of?(watched_dir, dir) + callback.call(dir) + end + end + end + end + + def _process_event(dir, path) + Listen.logger.debug { "fsevent: processing path: #{path.inspect}" } + # TODO: does this preserve symlinks? + rel_path = path.relative_path_from(dir).to_s + _queue_change(:dir, dir, rel_path, recursive: true) + end + + def _stop + @worker_thread&.kill + super + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/linux.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/linux.rb new file mode 100644 index 0000000..32be05f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/linux.rb @@ -0,0 +1,108 @@ +# frozen_string_literal: true + +module Listen + module Adapter + # @see https://github.com/nex3/rb-inotify + class Linux < Base + OS_REGEXP = /linux/i.freeze + + DEFAULTS = { + events: [ + :recursive, + :attrib, + :create, + :modify, + :delete, + :move, + :close_write + ], + wait_for_delay: 0.1 + }.freeze + + private + + README_URL = 'https://github.com/guard/listen'\ + '/blob/master/README.md#increasing-the-amount-of-inotify-watchers' + + def _configure(directory, &callback) + require 'rb-inotify' + @worker ||= ::INotify::Notifier.new + @worker.watch(directory.to_s, *options.events, &callback) + rescue Errno::ENOSPC + raise ::Listen::Error::INotifyMaxWatchesExceeded, <<~EOS + Unable to monitor directories for changes because iNotify max watches exceeded. See #{README_URL} . + EOS + end + + def _run + @worker.run + end + + # rubocop:disable Metrics/MethodLength + def _process_event(dir, event) + # NOTE: avoid using event.absolute_name since new API + # will need to have a custom recursion implemented + # to properly match events to configured directories + path = Pathname.new(event.watcher.path) + event.name + rel_path = path.relative_path_from(dir).to_s + + Listen.logger.debug { "inotify: #{rel_path} (#{event.flags.inspect})" } + + if /1|true/ =~ ENV['LISTEN_GEM_SIMULATE_FSEVENT'] + if (event.flags & [:moved_to, :moved_from]) || _dir_event?(event) + rel_path = path.dirname.relative_path_from(dir).to_s + end + _queue_change(:dir, dir, rel_path, {}) + return + end + + return if _skip_event?(event) + + cookie_params = event.cookie.zero? ? {} : { cookie: event.cookie } + + # Note: don't pass options to force rescanning the directory, so we can + # detect moving/deleting a whole tree + if _dir_event?(event) + _queue_change(:dir, dir, rel_path, cookie_params) + return + end + + params = cookie_params.merge(change: _change(event.flags)) + + _queue_change(:file, dir, rel_path, params) + end + # rubocop:enable Metrics/MethodLength + + def _skip_event?(event) + # Event on root directory + return true if event.name == '' + # INotify reports changes to files inside directories as events + # on the directories themselves too. + # + # @see http://linux.die.net/man/7/inotify + _dir_event?(event) && (event.flags & [:close, :modify]).any? + end + + def _change(event_flags) + { modified: [:attrib, :close_write], + moved_to: [:moved_to], + moved_from: [:moved_from], + added: [:create], + removed: [:delete] }.each do |change, flags| + return change unless (flags & event_flags).empty? + end + nil + end + + def _dir_event?(event) + event.flags.include?(:isdir) + end + + def _stop + @worker&.close + + super + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/polling.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/polling.rb new file mode 100644 index 0000000..9d281af --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/polling.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Listen + module Adapter + # Polling Adapter that works cross-platform and + # has no dependencies. This is the adapter that + # uses the most CPU processing power and has higher + # file IO than the other implementations. + # + class Polling < Base + OS_REGEXP = //.freeze # match every OS + + DEFAULTS = { latency: 1.0, wait_for_delay: 0.05 }.freeze + + private + + def _configure(_, &callback) + @polling_callbacks ||= [] + @polling_callbacks << callback + end + + def _run + loop do + start = MonotonicTime.now + @polling_callbacks.each do |callback| + callback.call(nil) + if (nap_time = options.latency - (MonotonicTime.now - start)) > 0 + # TODO: warn if nap_time is negative (polling too slow) + sleep(nap_time) + end + end + end + end + + def _process_event(dir, _) + _queue_change(:dir, dir, '.', recursive: true) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/windows.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/windows.rb new file mode 100644 index 0000000..26a6400 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/adapter/windows.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true + +module Listen + module Adapter + # Adapter implementation for Windows `wdm`. + # + class Windows < Base + OS_REGEXP = /mswin|mingw|cygwin/i.freeze + + BUNDLER_DECLARE_GEM = <<-EOS.gsub(/^ {6}/, '') + Please add the following to your Gemfile to avoid polling for changes: + gem 'wdm', '>= 0.1.0' if Gem.win_platform? + EOS + + def self.usable? + return false unless super + require 'wdm' + true + rescue LoadError + Listen.logger.debug format('wdm - load failed: %s:%s', $ERROR_INFO, + $ERROR_POSITION * "\n") + + Listen.adapter_warn(BUNDLER_DECLARE_GEM) + false + end + + private + + def _configure(dir) + require 'wdm' + Listen.logger.debug 'wdm - starting...' + @worker ||= WDM::Monitor.new + @worker.watch_recursively(dir.to_s, :files) do |change| + yield([:file, change]) + end + + @worker.watch_recursively(dir.to_s, :directories) do |change| + yield([:dir, change]) + end + + @worker.watch_recursively(dir.to_s, :attributes, :last_write) do |change| + yield([:attr, change]) + end + end + + def _run + @worker.run! + end + + # rubocop:disable Metrics/MethodLength + def _process_event(dir, event) + Listen.logger.debug "wdm - callback: #{event.inspect}" + + type, change = event + + full_path = Pathname(change.path) + + rel_path = full_path.relative_path_from(dir).to_s + + options = { change: _change(change.type) } + + case type + when :file + _queue_change(:file, dir, rel_path, options) + when :attr + unless full_path.directory? + _queue_change(:file, dir, rel_path, options) + end + when :dir + case change.type + when :removed + # TODO: check if watched dir? + _queue_change(:dir, dir, Pathname(rel_path).dirname.to_s, {}) + when :added + _queue_change(:dir, dir, rel_path, {}) + # do nothing - changed directory means either: + # - removed subdirs (handled above) + # - added subdirs (handled above) + # - removed files (handled by _file_callback) + # - added files (handled by _file_callback) + # so what's left? + end + end + end + # rubocop:enable Metrics/MethodLength + + def _change(type) + { modified: [:modified, :attrib], # TODO: is attrib really passed? + added: [:added, :renamed_new_file], + removed: [:removed, :renamed_old_file] }.find do |change, types| + types.include?(type) and break change + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/backend.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/backend.rb new file mode 100644 index 0000000..cab286c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/backend.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'listen/adapter' +require 'listen/adapter/base' +require 'listen/adapter/config' + +require 'forwardable' + +# This class just aggregates configuration object to avoid Listener specs +# from exploding with huge test setup blocks +module Listen + class Backend + extend Forwardable + + def initialize(directories, queue, silencer, config) + adapter_select_opts = config.adapter_select_options + + adapter_class = Adapter.select(adapter_select_opts) + + # Use default from adapter if possible + @min_delay_between_events = config.min_delay_between_events + @min_delay_between_events ||= adapter_class::DEFAULTS[:wait_for_delay] + @min_delay_between_events ||= 0.1 + + adapter_opts = config.adapter_instance_options(adapter_class) + + aconfig = Adapter::Config.new(directories, queue, silencer, adapter_opts) + @adapter = adapter_class.new(aconfig) + end + + delegate start: :adapter + delegate stop: :adapter + + attr_reader :min_delay_between_events + + private + + attr_reader :adapter + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/change.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/change.rb new file mode 100644 index 0000000..c19b900 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/change.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'listen/file' +require 'listen/directory' + +module Listen + # TODO: rename to Snapshot + class Change + # TODO: test this class for coverage + class Config + def initialize(queue, silencer) + @queue = queue + @silencer = silencer + end + + def silenced?(path, type) + @silencer.silenced?(Pathname(path), type) + end + + def queue(*args) + @queue << args + end + end + + attr_reader :record + + def initialize(config, record) + @config = config + @record = record + end + + # Invalidate some part of the snapshot/record (dir, file, subtree, etc.) + # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + def invalidate(type, rel_path, options) + watched_dir = Pathname.new(record.root) + + change = options[:change] + cookie = options[:cookie] + + if !cookie && @config.silenced?(rel_path, type) + Listen.logger.debug { "(silenced): #{rel_path.inspect}" } + return + end + + path = watched_dir + rel_path + + Listen.logger.debug do + log_details = options[:silence] && 'recording' || change || 'unknown' + "#{log_details}: #{type}:#{path} (#{options.inspect})" + end + + if change + options = cookie ? { cookie: cookie } : {} + @config.queue(type, change, watched_dir, rel_path, options) + elsif type == :dir + # NOTE: POSSIBLE RECURSION + # TODO: fix - use a queue instead + Directory.scan(self, rel_path, options) + elsif (change = File.change(record, rel_path)) && !options[:silence] + @config.queue(:file, change, watched_dir, rel_path) + end + end + # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/cli.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/cli.rb new file mode 100644 index 0000000..e317313 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/cli.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +require 'thor' +require 'listen' +require 'logger' + +module Listen + class CLI < Thor + default_task :start + + desc 'start', 'Starts Listen' + + class_option :verbose, + type: :boolean, + default: false, + aliases: '-v', + banner: 'Verbose' + + class_option :directory, + type: :array, + default: ['.'], + aliases: '-d', + banner: 'One or more directories to listen to' + + class_option :relative, + type: :boolean, + default: false, + aliases: '-r', + banner: 'Convert paths relative to current directory' + + def start + Listen::Forwarder.new(options).start + end + end + + class Forwarder + attr_reader :logger + + def initialize(options) + @options = options + @logger = ::Logger.new(STDOUT, level: ::Logger::INFO) + @logger.formatter = proc { |_, _, _, msg| "#{msg}\n" } + end + + def start + logger.info 'Starting listen...' + + directory = @options[:directory] + relative = @options[:relative] + callback = proc do |modified, added, removed| + if @options[:verbose] + logger.info "+ #{added}" unless added.empty? + logger.info "- #{removed}" unless removed.empty? + logger.info "> #{modified}" unless modified.empty? + end + end + + listener = Listen.to(*directory, relative: relative, &callback) + + listener.start + + sleep 0.5 while listener.processing? + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/directory.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/directory.rb new file mode 100644 index 0000000..19178b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/directory.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require 'set' + +module Listen + # TODO: refactor (turn it into a normal object, cache the stat, etc) + class Directory + # rubocop:disable Metrics/MethodLength + def self.scan(snapshot, rel_path, options) + record = snapshot.record + dir = Pathname.new(record.root) + previous = record.dir_entries(rel_path) + + record.add_dir(rel_path) + + # TODO: use children(with_directory: false) + path = dir + rel_path + current = Set.new(_children(path)) + + Listen.logger.debug do + format('%s: %s(%s): %s -> %s', + (options[:silence] ? 'Recording' : 'Scanning'), + rel_path, options.inspect, previous.inspect, current.inspect) + end + + begin + current.each do |full_path| + type = ::File.lstat(full_path.to_s).directory? ? :dir : :file + item_rel_path = full_path.relative_path_from(dir).to_s + _change(snapshot, type, item_rel_path, options) + end + rescue Errno::ENOENT + # The directory changed meanwhile, so rescan it + current = Set.new(_children(path)) + retry + end + + # TODO: this is not tested properly + previous = previous.reject { |entry, _| current.include?(path + entry) } + + _async_changes(snapshot, Pathname.new(rel_path), previous, options) + rescue Errno::ENOENT, Errno::EHOSTDOWN + record.unset_path(rel_path) + _async_changes(snapshot, Pathname.new(rel_path), previous, options) + rescue Errno::ENOTDIR + # TODO: path not tested + record.unset_path(rel_path) + _async_changes(snapshot, path, previous, options) + _change(snapshot, :file, rel_path, options) + rescue + Listen.logger.warn { format('scan DIED: %s:%s', $ERROR_INFO, $ERROR_POSITION * "\n") } + raise + end + # rubocop:enable Metrics/MethodLength + + def self.ascendant_of?(base, other) + other.ascend do |ascendant| + break true if base == ascendant + end + end + + def self._async_changes(snapshot, path, previous, options) + fail "Not a Pathname: #{path.inspect}" unless path.respond_to?(:children) + previous.each do |entry, data| + # TODO: this is a hack with insufficient testing + type = data.key?(:mtime) ? :file : :dir + rel_path_s = (path + entry).to_s + _change(snapshot, type, rel_path_s, options) + end + end + + def self._change(snapshot, type, path, options) + return snapshot.invalidate(type, path, options) if type == :dir + + # Minor param cleanup for tests + # TODO: use a dedicated Event class + opts = options.dup + opts.delete(:recursive) + snapshot.invalidate(type, path, opts) + end + + def self._children(path) + return path.children unless RUBY_ENGINE == 'jruby' + + # JRuby inconsistency workaround, see: + # https://github.com/jruby/jruby/issues/3840 + exists = path.exist? + directory = path.directory? + exists && !directory and raise Errno::ENOTDIR, path.to_s + path.children + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/error.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/error.rb new file mode 100644 index 0000000..a5f2dc1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/error.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +# Besides programming error exceptions like ArgumentError, +# all public interface exceptions should be declared here and inherit from Listen::Error. +module Listen + class Error < RuntimeError + class NotStarted < Error; end + class SymlinkLoop < Error; end + class INotifyMaxWatchesExceeded < Error; end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/config.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/config.rb new file mode 100644 index 0000000..c83ee37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/config.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Listen + module Event + class Config + attr_reader :listener, :event_queue, :min_delay_between_events + + def initialize( + listener, + event_queue, + queue_optimizer, + wait_for_delay, + &block + ) + + @listener = listener + @event_queue = event_queue + @queue_optimizer = queue_optimizer + @min_delay_between_events = wait_for_delay + @block = block + end + + def sleep(seconds) + Kernel.sleep(seconds) + end + + def call(*args) + @block&.call(*args) + end + + def callable? + @block + end + + def optimize_changes(changes) + @queue_optimizer.smoosh_changes(changes) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/loop.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/loop.rb new file mode 100644 index 0000000..dd071f0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/loop.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true + +require 'thread' + +require 'timeout' +require 'listen/event/processor' +require 'listen/thread' +require 'listen/error' + +module Listen + module Event + class Loop + include Listen::FSM + + Error = ::Listen::Error + NotStarted = ::Listen::Error::NotStarted # for backward compatibility + + start_state :pre_start + state :pre_start + state :starting + state :started + state :stopped + + def initialize(config) + @config = config + @wait_thread = nil + @reasons = ::Queue.new + initialize_fsm + end + + def wakeup_on_event + if started? && @wait_thread&.alive? + _wakeup(:event) + end + end + + def started? + state == :started + end + + MAX_STARTUP_SECONDS = 5.0 + + # @raises Error::NotStarted if background thread hasn't started in MAX_STARTUP_SECONDS + def start + # TODO: use a Fiber instead? + return unless state == :pre_start + + transition! :starting + + @wait_thread = Listen::Thread.new("wait_thread") do + _process_changes + end + + Listen.logger.debug("Waiting for processing to start...") + + wait_for_state(:started, timeout: MAX_STARTUP_SECONDS) or + raise Error::NotStarted, "thread didn't start in #{MAX_STARTUP_SECONDS} seconds (in state: #{state.inspect})" + + Listen.logger.debug('Processing started.') + end + + def pause + # TODO: works? + # fail NotImplementedError + end + + def stop + transition! :stopped + + @wait_thread&.join + @wait_thread = nil + end + + def stopped? + state == :stopped + end + + private + + def _process_changes + processor = Event::Processor.new(@config, @reasons) + + transition! :started + + processor.loop_for(@config.min_delay_between_events) + end + + def _wakeup(reason) + @reasons << reason + @wait_thread.wakeup + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/processor.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/processor.rb new file mode 100644 index 0000000..57656cb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/processor.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +require 'listen/monotonic_time' + +module Listen + module Event + class Processor + def initialize(config, reasons) + @config = config + @listener = config.listener + @reasons = reasons + _reset_no_unprocessed_events + end + + # TODO: implement this properly instead of checking the state at arbitrary + # points in time + def loop_for(latency) + @latency = latency + + loop do + event = _wait_until_events + _check_stopped + _wait_until_events_calm_down + _wait_until_no_longer_paused + _process_changes(event) + end + rescue Stopped + Listen.logger.debug('Processing stopped') + end + + private + + class Stopped < RuntimeError + end + + def _wait_until_events_calm_down + loop do + now = MonotonicTime.now + + # Assure there's at least latency between callbacks to allow + # for accumulating changes + diff = _deadline - now + break if diff <= 0 + + # give events a bit of time to accumulate so they can be + # compressed/optimized + _sleep(diff) + end + end + + def _wait_until_no_longer_paused + @listener.wait_for_state(*(Listener.states.keys - [:paused])) + end + + def _check_stopped + if @listener.stopped? + _flush_wakeup_reasons + raise Stopped + end + end + + def _sleep(seconds) + _check_stopped + config.sleep(seconds) + _check_stopped + + _flush_wakeup_reasons do |reason| + if reason == :event && !@listener.paused? + _remember_time_of_first_unprocessed_event + end + end + end + + def _remember_time_of_first_unprocessed_event + @_remember_time_of_first_unprocessed_event ||= MonotonicTime.now + end + + def _reset_no_unprocessed_events + @_remember_time_of_first_unprocessed_event = nil + end + + def _deadline + @_remember_time_of_first_unprocessed_event + @latency + end + + # blocks until event is popped + # returns the event or `nil` when the event_queue is closed + def _wait_until_events + config.event_queue.pop.tap do |_event| + @_remember_time_of_first_unprocessed_event ||= MonotonicTime.now + end + end + + def _flush_wakeup_reasons + until @reasons.empty? + reason = @reasons.pop + yield reason if block_given? + end + end + + # for easier testing without sleep loop + def _process_changes(event) + _reset_no_unprocessed_events + + changes = [event] + changes << config.event_queue.pop until config.event_queue.empty? + + return unless config.callable? + + hash = config.optimize_changes(changes) + result = [hash[:modified], hash[:added], hash[:removed]] + return if result.all?(&:empty?) + + block_start = MonotonicTime.now + exception_note = " (exception)" + ::Listen::Thread.rescue_and_log('_process_changes') do + config.call(*result) + exception_note = nil + end + Listen.logger.debug "Callback#{exception_note} took #{MonotonicTime.now - block_start} sec" + end + + attr_reader :config + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/queue.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/queue.rb new file mode 100644 index 0000000..ffcd67c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/event/queue.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'thread' + +require 'forwardable' + +module Listen + module Event + class Queue + extend Forwardable + + class Config + def initialize(relative) + @relative = relative + end + + def relative? + @relative + end + end + + def initialize(config) + @event_queue = ::Queue.new + @config = config + end + + def <<(args) + type, change, dir, path, options = *args + fail "Invalid type: #{type.inspect}" unless [:dir, :file].include? type + fail "Invalid change: #{change.inspect}" unless change.is_a?(Symbol) + fail "Invalid path: #{path.inspect}" unless path.is_a?(String) + + dir = if @config.relative? + _safe_relative_from_cwd(dir) + else + dir + end + @event_queue << [type, change, dir, path, options] + end + + delegate empty?: :@event_queue + delegate pop: :@event_queue + delegate close: :@event_queue + + private + + def _safe_relative_from_cwd(dir) + dir.relative_path_from(Pathname.pwd) + rescue ArgumentError + dir + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/file.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/file.rb new file mode 100644 index 0000000..41df632 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/file.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +require 'digest' + +module Listen + class File + # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + def self.change(record, rel_path) + path = Pathname.new(record.root) + rel_path + lstat = path.lstat + + data = { mtime: lstat.mtime.to_f, mode: lstat.mode, size: lstat.size } + + record_data = record.file_data(rel_path) + + if record_data.empty? + record.update_file(rel_path, data) + return :added + end + + if data[:mode] != record_data[:mode] + record.update_file(rel_path, data) + return :modified + end + + if data[:mtime] != record_data[:mtime] + record.update_file(rel_path, data) + return :modified + end + + if data[:size] != record_data[:size] + record.update_file(rel_path, data) + return :modified + end + + return if /1|true/ =~ ENV['LISTEN_GEM_DISABLE_HASHING'] + return unless inaccurate_mac_time?(lstat) + + # Check if change happened within 1 second (maybe it's even + # too much, e.g. 0.3-0.5 could be sufficient). + # + # With rb-fsevent, there's a (configurable) latency between + # when file was changed and when the event was triggered. + # + # If a file is saved at ???14.998, by the time the event is + # actually received by Listen, the time could already be e.g. + # ???15.7. + # + # And since Darwin adapter uses directory scanning, the file + # mtime may be the same (e.g. file was changed at ???14.001, + # then at ???14.998, but the fstat time would be ???14.0 in + # both cases). + # + # If change happened at ???14.999997, the mtime is 14.0, so for + # an mtime=???14.0 we assume it could even be almost ???15.0 + # + # So if Time.now.to_f is ???15.999998 and stat reports mtime + # at ???14.0, then event was due to that file'd change when: + # + # ???15.999997 - ???14.999998 < 1.0s + # + # So the "2" is "1 + 1" (1s to cover rb-fsevent latency + + # 1s maximum difference between real mtime and that recorded + # in the file system) + # + return if data[:mtime].to_i + 2 <= Time.now.to_f + + sha = Digest::SHA256.file(path).digest + record.update_file(rel_path, data.merge(sha: sha)) + if record_data[:sha] && sha != record_data[:sha] + :modified + end + rescue SystemCallError + record.unset_path(rel_path) + :removed + rescue + Listen.logger.debug "lstat failed for: #{rel_path} (#{$ERROR_INFO})" + raise + end + # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity + + def self.inaccurate_mac_time?(stat) + # 'mac' means Modified/Accessed/Created + + # Since precision depends on mounted FS (e.g. you can have a FAT partiion + # mounted on Linux), check for fields with a remainder to detect this + + [stat.mtime, stat.ctime, stat.atime].map(&:usec).all?(&:zero?) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/fsm.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/fsm.rb new file mode 100644 index 0000000..154ad2b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/fsm.rb @@ -0,0 +1,133 @@ +# frozen_string_literal: true + +# Code copied from https://github.com/celluloid/celluloid-fsm + +require 'thread' + +module Listen + module FSM + # Included hook to extend class methods + def self.included(klass) + klass.send :extend, ClassMethods + end + + module ClassMethods + # Obtain or set the start state + # Passing a state name sets the start state + def start_state(new_start_state = nil) + if new_start_state + new_start_state.is_a?(Symbol) or raise ArgumentError, "state name must be a Symbol (got #{new_start_state.inspect})" + @start_state = new_start_state + else + defined?(@start_state) or raise ArgumentError, "`start_state :` must be declared before `new`" + @start_state + end + end + + # The valid states for this FSM, as a hash with state name symbols as keys and State objects as values. + def states + @states ||= {} + end + + # Declare an FSM state and optionally provide a callback block to fire on state entry + # Options: + # * to: a state or array of states this state can transition to + def state(state_name, to: nil, &block) + state_name.is_a?(Symbol) or raise ArgumentError, "state name must be a Symbol (got #{state_name.inspect})" + states[state_name] = State.new(state_name, to, &block) + end + end + + # Note: including classes must call initialize_fsm from their initialize method. + def initialize_fsm + @fsm_initialized = true + @state = self.class.start_state + @mutex = ::Mutex.new + @state_changed = ::ConditionVariable.new + end + + # Current state of the FSM, stored as a symbol + attr_reader :state + + # checks for one of the given states to wait for + # if not already, waits for a state change (up to timeout seconds--`nil` means infinite) + # returns truthy iff the transition to one of the desired state has occurred + def wait_for_state(*wait_for_states, timeout: nil) + wait_for_states.each do |state| + state.is_a?(Symbol) or raise ArgumentError, "states must be symbols (got #{state.inspect})" + end + @mutex.synchronize do + if !wait_for_states.include?(@state) + @state_changed.wait(@mutex, timeout) + end + wait_for_states.include?(@state) + end + end + + private + + def transition(new_state_name) + new_state_name.is_a?(Symbol) or raise ArgumentError, "state name must be a Symbol (got #{new_state_name.inspect})" + if (new_state = validate_and_sanitize_new_state(new_state_name)) + transition_with_callbacks!(new_state) + end + end + + # Low-level, immediate state transition with no checks or callbacks. + def transition!(new_state_name) + new_state_name.is_a?(Symbol) or raise ArgumentError, "state name must be a Symbol (got #{new_state_name.inspect})" + @fsm_initialized or raise ArgumentError, "FSM not initialized. You must call initialize_fsm from initialize!" + @mutex.synchronize do + yield if block_given? + @state = new_state_name + @state_changed.broadcast + end + end + + def validate_and_sanitize_new_state(new_state_name) + return nil if @state == new_state_name + + if current_state && !current_state.valid_transition?(new_state_name) + valid = current_state.transitions.map(&:to_s).join(', ') + msg = "#{self.class} can't change state from '#{@state}' to '#{new_state_name}', only to: #{valid}" + raise ArgumentError, msg + end + + unless (new_state = self.class.states[new_state_name]) + new_state_name == self.class.start_state or raise ArgumentError, "invalid state for #{self.class}: #{new_state_name}" + end + + new_state + end + + def transition_with_callbacks!(new_state) + transition! new_state.name + new_state.call(self) + end + + def current_state + self.class.states[@state] + end + + class State + attr_reader :name, :transitions + + def initialize(name, transitions, &block) + @name = name + @block = block + @transitions = if transitions + Array(transitions).map(&:to_sym) + end + end + + def call(obj) + obj.instance_eval(&@block) if @block + end + + def valid_transition?(new_state) + # All transitions are allowed if none are expressly declared + !@transitions || @transitions.include?(new_state.to_sym) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/listener.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/listener.rb new file mode 100644 index 0000000..d886fdb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/listener.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +require 'English' + +require 'listen/version' + +require 'listen/backend' + +require 'listen/silencer' +require 'listen/silencer/controller' + +require 'listen/queue_optimizer' + +require 'listen/fsm' + +require 'listen/event/loop' +require 'listen/event/queue' +require 'listen/event/config' + +require 'listen/listener/config' + +module Listen + class Listener + include Listen::FSM + + # Initializes the directories listener. + # + # @param [String] directory the directories to listen to + # @param [Hash] options the listen options (see Listen::Listener::Options) + # + # @yield [modified, added, removed] the changed files + # @yieldparam [Array] modified the list of modified files + # @yieldparam [Array] added the list of added files + # @yieldparam [Array] removed the list of removed files + # + # rubocop:disable Metrics/MethodLength + def initialize(*dirs, &block) + options = dirs.last.is_a?(Hash) ? dirs.pop : {} + + @config = Config.new(options) + + eq_config = Event::Queue::Config.new(@config.relative?) + queue = Event::Queue.new(eq_config) + + silencer = Silencer.new + rules = @config.silencer_rules + @silencer_controller = Silencer::Controller.new(silencer, rules) + + @backend = Backend.new(dirs, queue, silencer, @config) + + optimizer_config = QueueOptimizer::Config.new(@backend, silencer) + + pconfig = Event::Config.new( + self, + queue, + QueueOptimizer.new(optimizer_config), + @backend.min_delay_between_events, + &block) + + @processor = Event::Loop.new(pconfig) + + initialize_fsm + end + # rubocop:enable Metrics/MethodLength + + start_state :initializing + + state :initializing, to: [:backend_started, :stopped] + + state :backend_started, to: [:processing_events, :stopped] do + @backend.start + end + + state :processing_events, to: [:paused, :stopped] do + @processor.start + end + + state :paused, to: [:processing_events, :stopped] do + @processor.pause + end + + state :stopped, to: [:backend_started] do + @backend.stop # halt events ASAP + @processor.stop + end + + # Starts processing events and starts adapters + # or resumes invoking callbacks if paused + def start + case state + when :initializing + transition :backend_started + transition :processing_events + when :paused + transition :processing_events + else + raise ArgumentError, "cannot start from state #{state.inspect}" + end + end + + # Stops both listening for events and processing them + def stop + transition :stopped + end + + # Stops invoking callbacks (messages pile up) + def pause + transition :paused + end + + # processing means callbacks are called + def processing? + state == :processing_events + end + + def paused? + state == :paused + end + + def stopped? + state == :stopped + end + + def ignore(regexps) + @silencer_controller.append_ignores(regexps) + end + + def ignore!(regexps) + @silencer_controller.replace_with_bang_ignores(regexps) + end + + def only(regexps) + @silencer_controller.replace_with_only(regexps) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/listener/config.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/listener/config.rb new file mode 100644 index 0000000..56e4b7c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/listener/config.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Listen + class Listener + class Config + DEFAULTS = { + # Listener options + debug: false, # TODO: is this broken? + wait_for_delay: nil, # NOTE: should be provided by adapter if possible + relative: false, + + # Backend selecting options + force_polling: false, + polling_fallback_message: nil + }.freeze + + def initialize(opts) + @options = DEFAULTS.merge(opts) + @relative = @options[:relative] + @min_delay_between_events = @options[:wait_for_delay] + @silencer_rules = @options # silencer will extract what it needs + end + + def relative? + @relative + end + + attr_reader :min_delay_between_events, :silencer_rules + + def adapter_instance_options(klass) + valid_keys = klass.const_get('DEFAULTS').keys + Hash[@options.select { |key, _| valid_keys.include?(key) }] + end + + def adapter_select_options + valid_keys = %w[force_polling polling_fallback_message].map(&:to_sym) + Hash[@options.select { |key, _| valid_keys.include?(key) }] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/logger.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/logger.rb new file mode 100644 index 0000000..9689252 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/logger.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +module Listen + @logger = nil + + # Listen.logger will always be present. + # If you don't want logging, set Listen.logger = ::Logger.new('/dev/null', level: ::Logger::UNKNOWN) + + @adapter_warn_behavior = :warn + + class << self + attr_writer :logger + attr_accessor :adapter_warn_behavior + + def logger + @logger ||= default_logger + end + + def adapter_warn(message) + case ENV['LISTEN_GEM_ADAPTER_WARN_BEHAVIOR']&.to_sym || adapter_warn_behavior_callback(message) + when :log + logger.warn(message) + when :silent, nil, false + # do nothing + else # :warn + warn(message) + end + end + + private + + def default_logger + level = + case ENV['LISTEN_GEM_DEBUGGING'].to_s + when /debug|2/i + ::Logger::DEBUG + when /info|true|yes|1/i + ::Logger::INFO + when /warn/i + ::Logger::WARN + when /fatal/i + ::Logger::FATAL + else + ::Logger::ERROR + end + + ::Logger.new(STDERR, level: level) + end + + def adapter_warn_behavior_callback(message) + if adapter_warn_behavior.respond_to?(:call) + case behavior = adapter_warn_behavior.call(message) + when Symbol + behavior + when false, nil + :silent + else + :warn + end + else + adapter_warn_behavior + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/monotonic_time.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/monotonic_time.rb new file mode 100644 index 0000000..51b0fc9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/monotonic_time.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Listen + module MonotonicTime + class << self + if defined?(Process::CLOCK_MONOTONIC) + + def now + Process.clock_gettime(Process::CLOCK_MONOTONIC) + end + + elsif defined?(Process::CLOCK_MONOTONIC_RAW) + + def now + Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW) + end + + else + + def now + Time.now.to_f + end + + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/options.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/options.rb new file mode 100644 index 0000000..0f1abb1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/options.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Listen + class Options + def initialize(opts, defaults) + @options = {} + given_options = opts.dup + defaults.each_key do |key| + @options[key] = given_options.delete(key) || defaults[key] + end + + given_options.empty? or raise ArgumentError, "Unknown options: #{given_options.inspect}" + end + + # rubocop:disable Lint/MissingSuper + def respond_to_missing?(name, *_) + @options.has_key?(name) + end + + def method_missing(name, *_) + respond_to_missing?(name) or raise NameError, "Bad option: #{name.inspect} (valid:#{@options.keys.inspect})" + @options[name] + end + # rubocop:enable Lint/MissingSuper + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/queue_optimizer.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/queue_optimizer.rb new file mode 100644 index 0000000..2ccf4cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/queue_optimizer.rb @@ -0,0 +1,129 @@ +# frozen_string_literal: true + +module Listen + class QueueOptimizer + class Config + def initialize(adapter_class, silencer) + @adapter_class = adapter_class + @silencer = silencer + end + + def exist?(path) + Pathname(path).exist? + end + + def silenced?(path, type) + @silencer.silenced?(path, type) + end + + def debug(*args, &block) + Listen.logger.debug(*args, &block) + end + end + + def smoosh_changes(changes) + # TODO: adapter could be nil at this point (shutdown) + cookies = changes.group_by do |_, _, _, _, options| + (options || {})[:cookie] + end + _squash_changes(_reinterpret_related_changes(cookies)) + end + + def initialize(config) + @config = config + end + + private + + attr_reader :config + + # groups changes into the expected structure expected by + # clients + def _squash_changes(changes) + # We combine here for backward compatibility + # Newer clients should receive dir and path separately + changes = changes.map { |change, dir, path| [change, dir + path] } + + actions = changes.group_by(&:last).map do |path, action_list| + [_logical_action_for(path, action_list.map(&:first)), path.to_s] + end + + config.debug("listen: raw changes: #{actions.inspect}") + + { modified: [], added: [], removed: [] }.tap do |squashed| + actions.each do |type, path| + squashed[type] << path unless type.nil? + end + config.debug("listen: final changes: #{squashed.inspect}") + end + end + + def _logical_action_for(path, actions) + actions << :added if actions.delete(:moved_to) + actions << :removed if actions.delete(:moved_from) + + modified = actions.find { |x| x == :modified } + _calculate_add_remove_difference(actions, path, modified) + end + + def _calculate_add_remove_difference(actions, path, default_if_exists) + added = actions.count { |x| x == :added } + removed = actions.count { |x| x == :removed } + diff = added - removed + + # TODO: avoid checking if path exists and instead assume the events are + # in order (if last is :removed, it doesn't exist, etc.) + if config.exist?(path) + if diff > 0 + :added + elsif diff.zero? && added > 0 + :modified + else + default_if_exists + end + else + diff < 0 ? :removed : nil + end + end + + # remove extraneous rb-inotify events, keeping them only if it's a possible + # editor rename() call (e.g. Kate and Sublime) + def _reinterpret_related_changes(cookies) + table = { moved_to: :added, moved_from: :removed } + cookies.flat_map do |_, changes| + if (editor_modified = editor_modified?(changes)) + [[:modified, *editor_modified]] + else + not_silenced = changes.reject do |type, _, _, path, _| + config.silenced?(Pathname(path), type) + end + not_silenced.map do |_, change, dir, path, _| + [table.fetch(change, change), dir, path] + end + end + end + end + + def editor_modified?(changes) + return unless changes.size == 2 + + from_type = from = nil + to_type = to_dir = to = nil + + changes.each do |data| + case data[1] + when :moved_from + from_type, _from_change, _, from, = data + when :moved_to + to_type, _to_change, to_dir, to, = data + end + end + + # Expect an ignored moved_from and non-ignored moved_to + # to qualify as an "editor modify" + if from && to && config.silenced?(Pathname(from), from_type) && !config.silenced?(Pathname(to), to_type) + [to_dir, to] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record.rb new file mode 100644 index 0000000..2218149 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +require 'thread' +require 'listen/record/entry' +require 'listen/record/symlink_detector' + +module Listen + class Record + # TODO: one Record object per watched directory? + # TODO: deprecate + + attr_reader :root + + def initialize(directory, silencer) + reset_tree + @root = directory.to_s + @silencer = silencer + end + + def add_dir(rel_path) + if !empty_dirname?(rel_path.to_s) + @tree[rel_path.to_s] + end + end + + def update_file(rel_path, data) + dirname, basename = Pathname(rel_path).split.map(&:to_s) + _fast_update_file(dirname, basename, data) + end + + def unset_path(rel_path) + dirname, basename = Pathname(rel_path).split.map(&:to_s) + _fast_unset_path(dirname, basename) + end + + def file_data(rel_path) + dirname, basename = Pathname(rel_path).split.map(&:to_s) + if empty_dirname?(dirname) + @tree[basename].dup + else + @tree[dirname][basename] ||= {} + @tree[dirname][basename].dup + end + end + + def dir_entries(rel_path) + rel_path_s = rel_path.to_s + subtree = if empty_dirname?(rel_path_s) + @tree + else + @tree[rel_path_s] + end + + subtree.each_with_object({}) do |(key, values), result| + # only return data for file entries inside the dir (which will each be sub-hashes) + if values.is_a?(Hash) + result[key] = values.has_key?(:mtime) ? values : {} + end + end + end + + def build + reset_tree + # TODO: test with a file name given + # TODO: test other permissions + # TODO: test with mixed encoding + symlink_detector = SymlinkDetector.new + remaining = ::Queue.new + remaining << Entry.new(root, nil, nil) + _fast_build_dir(remaining, symlink_detector) until remaining.empty? + end + + private + + def empty_dirname?(dirname) + dirname == '.' || dirname == '' + end + + def reset_tree + @tree = Hash.new { |h, k| h[k] = {} } + end + + def _fast_update_file(dirname, basename, data) + if empty_dirname?(dirname.to_s) + @tree[basename] = @tree[basename].merge(data) + else + @tree[dirname][basename] = (@tree[dirname][basename] || {}).merge(data) + end + end + + def _fast_unset_path(dirname, basename) + # this may need to be reworked to properly remove + # entries from a tree, without adding non-existing dirs to the record + if empty_dirname?(dirname.to_s) + if @tree.key?(basename) + @tree.delete(basename) + end + elsif @tree.key?(dirname) + @tree[dirname].delete(basename) + end + end + + def _fast_build_dir(remaining, symlink_detector) + entry = remaining.pop + return if @silencer.silenced?(entry.record_dir_key, :dir) + + children = entry.children # NOTE: children() implicitly tests if dir + symlink_detector.verify_unwatched!(entry) + children.each { |child| remaining << child } + add_dir(entry.record_dir_key) + rescue Errno::ENOTDIR + _fast_try_file(entry) + rescue SystemCallError, SymlinkDetector::Error + _fast_unset_path(entry.relative, entry.name) + end + + def _fast_try_file(entry) + _fast_update_file(entry.relative, entry.name, entry.meta) + rescue SystemCallError + _fast_unset_path(entry.relative, entry.name) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record/entry.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record/entry.rb new file mode 100644 index 0000000..a01a159 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record/entry.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module Listen + # @private api + class Record + # Represents a directory entry (dir or file) + class Entry + # file: "/home/me/watched_dir", "app/models", "foo.rb" + # dir, "/home/me/watched_dir", "." + def initialize(root, relative, name = nil) + @root = root + @relative = relative + @name = name + end + + attr_reader :root, :relative, :name + + def children + child_relative = _join + (_entries(sys_path) - %w[. ..]).map do |name| + Entry.new(@root, child_relative, name) + end + end + + def meta + lstat = ::File.lstat(sys_path) + { mtime: lstat.mtime.to_f, mode: lstat.mode, size: lstat.size } + end + + # record hash is e.g. + # if @record["/home/me/watched_dir"]["project/app/models"]["foo.rb"] + # if @record["/home/me/watched_dir"]["project/app"]["models"] + # record_dir_key is "project/app/models" + def record_dir_key + ::File.join(*[@relative, @name].compact) + end + + def sys_path + # Use full path in case someone uses chdir + ::File.join(*[@root, @relative, @name].compact) + end + + def real_path + @real_path ||= ::File.realpath(sys_path) + end + + private + + def _join + args = [@relative, @name].compact + args.empty? ? nil : ::File.join(*args) + end + + def _entries(dir) + return Dir.entries(dir) unless RUBY_ENGINE == 'jruby' + + # JRuby inconsistency workaround, see: + # https://github.com/jruby/jruby/issues/3840 + exists = ::File.exist?(dir) + directory = ::File.directory?(dir) + return Dir.entries(dir) unless exists && !directory + raise Errno::ENOTDIR, dir + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record/symlink_detector.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record/symlink_detector.rb new file mode 100644 index 0000000..f193043 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/record/symlink_detector.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'set' +require 'listen/error' + +module Listen + # @private api + class Record + class SymlinkDetector + README_URL = 'https://github.com/guard/listen/blob/master/README.md' + + SYMLINK_LOOP_ERROR = <<-EOS + ** ERROR: directory is already being watched! ** + + Directory: %s + + is already being watched through: %s + + MORE INFO: #{README_URL} + EOS + + Error = ::Listen::Error # for backward compatibility + + def initialize + @real_dirs = Set.new + end + + def verify_unwatched!(entry) + real_path = entry.real_path + @real_dirs.add?(real_path) or _fail(entry.sys_path, real_path) + end + + # Leaving this stub here since some warning work-arounds were referring to it. + # Deprecated. Will be removed in Listen v4.0. + def warn(message) + Listen.adapter_warn(message) + end + + private + + def _fail(symlinked, real_path) + warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path)) + raise ::Listen::Error::SymlinkLoop, 'Failed due to looped symlinks' + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/silencer.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/silencer.rb new file mode 100644 index 0000000..7253a8b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/silencer.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true + +module Listen + class Silencer + # The default list of directories that get ignored. + DEFAULT_IGNORED_FILES = %r{\A(?: + \.git + | \.svn + | \.hg + | \.rbx + | \.bundle + | bundle + | vendor/bundle + | log + | tmp + | vendor/ruby + + # emacs temp files + | \#.+\# + | \.\#.+ + )(/|\z)}x.freeze + + # The default list of files that get ignored. + DEFAULT_IGNORED_EXTENSIONS = %r{(?: + # Kate's tmp\/swp files + \..*\d+\.new + | \.kate-swp + + # Gedit tmp files + | \.goutputstream-.{6} + + # Intellij files + | ___jb_bak___ + | ___jb_old___ + + # Vim swap files and write test + | \.sw[px] + | \.swpx + | ^4913 + + # Sed temporary files - but without actual words, like 'sedatives' + | (?:\A + sed + + (?: + [a-zA-Z0-9]{0}[A-Z]{1}[a-zA-Z0-9]{5} | + [a-zA-Z0-9]{1}[A-Z]{1}[a-zA-Z0-9]{4} | + [a-zA-Z0-9]{2}[A-Z]{1}[a-zA-Z0-9]{3} | + [a-zA-Z0-9]{3}[A-Z]{1}[a-zA-Z0-9]{2} | + [a-zA-Z0-9]{4}[A-Z]{1}[a-zA-Z0-9]{1} | + [a-zA-Z0-9]{5}[A-Z]{1}[a-zA-Z0-9]{0} + ) + ) + + # Mutagen sync temporary files + | \.mutagen-temporary.* + + # other files + | \.DS_Store + | \.tmp + | ~ + )\z}x.freeze + + # TODO: deprecate these mutators; use attr_reader instead + attr_accessor :only_patterns, :ignore_patterns + + def initialize(**options) + configure(options) + end + + # TODO: deprecate this mutator + def configure(options) + @only_patterns = options[:only] ? Array(options[:only]) : nil + @ignore_patterns = _init_ignores(options[:ignore], options[:ignore!]) + end + + def silenced?(relative_path, type) + path = relative_path.to_s # in case it is a Pathname + + _ignore?(path) || (only_patterns && type == :file && !_only?(path)) + end + + private + + def _ignore?(path) + ignore_patterns.any? { |pattern| path =~ pattern } + end + + def _only?(path) + only_patterns.any? { |pattern| path =~ pattern } + end + + def _init_ignores(ignores, overrides) + patterns = [] + unless overrides + patterns << DEFAULT_IGNORED_FILES + patterns << DEFAULT_IGNORED_EXTENSIONS + end + + patterns << ignores + patterns << overrides + + patterns.compact.flatten + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/silencer/controller.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/silencer/controller.rb new file mode 100644 index 0000000..bb94d4b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/silencer/controller.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Listen + class Silencer + class Controller + def initialize(silencer, default_options) + @silencer = silencer + + opts = default_options + + @prev_silencer_options = {} + rules = [:only, :ignore, :ignore!].map do |option| + [option, opts[option]] if opts.key? option + end + + _reconfigure_silencer(Hash[rules.compact]) + end + + def append_ignores(*regexps) + prev_ignores = Array(@prev_silencer_options[:ignore]) + _reconfigure_silencer(ignore: [prev_ignores + regexps]) + end + + def replace_with_bang_ignores(regexps) + _reconfigure_silencer(ignore!: regexps) + end + + def replace_with_only(regexps) + _reconfigure_silencer(only: regexps) + end + + private + + def _reconfigure_silencer(extra_options) + opts = extra_options.dup + opts = opts.map do |key, value| + [key, Array(value).flatten.compact] + end + opts = Hash[opts] + + if opts.key?(:ignore) && opts[:ignore].empty? + opts.delete(:ignore) + end + + @prev_silencer_options = opts + @silencer.configure(@prev_silencer_options.dup.freeze) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/thread.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/thread.rb new file mode 100644 index 0000000..a1e6b3b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/thread.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'thread' + +require_relative 'logger' + +module Listen + module Thread + class << self + # Creates a new thread with the given name. + # Any exceptions raised by the thread will be logged with the thread name and complete backtrace. + # rubocop:disable Style/MultilineBlockChain + def new(name, &block) + thread_name = "listen-#{name}" + caller_stack = caller + + ::Thread.new do + rescue_and_log(thread_name, caller_stack: caller_stack, &block) + end.tap do |thread| + thread.name = thread_name + end + end + # rubocop:enable Style/MultilineBlockChain + + def rescue_and_log(method_name, *args, caller_stack: nil) + yield(*args) + rescue => exception + _log_exception(exception, method_name, caller_stack: caller_stack) + end + + private + + def _log_exception(exception, thread_name, caller_stack: nil) + complete_backtrace = if caller_stack + [*exception.backtrace, "--- Thread.new ---", *caller_stack] + else + exception.backtrace + end + message = "Exception rescued in #{thread_name}:\n#{_exception_with_causes(exception)}\n#{complete_backtrace * "\n"}" + Listen.logger.error(message) + end + + def _exception_with_causes(exception) + result = +"#{exception.class}: #{exception}" + if exception.cause + result << "\n" + result << "--- Caused by: ---\n" + result << _exception_with_causes(exception.cause) + end + result + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/version.rb b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/version.rb new file mode 100644 index 0000000..d235bf9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/listen-3.9.0/lib/listen/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Listen + VERSION = '3.9.0' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.gitignore b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.gitignore new file mode 100644 index 0000000..a28fccc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.gitignore @@ -0,0 +1,18 @@ +*.gem +*.rbc +.bundle +.config +.yardoc +Gemfile.lock +InstalledFiles +_yardoc +coverage +doc/ +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp +tmp +vendor/bundle diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rspec b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rspec new file mode 100644 index 0000000..5f16476 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rspec @@ -0,0 +1,2 @@ +--color +--format progress diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rubocop.yml b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rubocop.yml new file mode 100644 index 0000000..f6aff82 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rubocop.yml @@ -0,0 +1,10 @@ +inherit_from: .rubocop_todo.yml + +require: rubocop-jekyll +inherit_gem: + rubocop-jekyll: .rubocop.yml + +AllCops: + TargetRubyVersion: 2.4 + Exclude: + - vendor/**/* diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rubocop_todo.yml b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rubocop_todo.yml new file mode 100644 index 0000000..a7450ae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.rubocop_todo.yml @@ -0,0 +1,79 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2020-01-18 15:09:24 +0100 using RuboCop version 0.71.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +Jekyll/NoPAllowed: + Exclude: + - 'examples/help_dialogue.rb' + +# Offense count: 2 +Jekyll/NoPutsAllowed: + Exclude: + - 'lib/mercenary/command.rb' + +# Offense count: 4 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'lib/mercenary/command.rb' + - 'lib/mercenary/option.rb' + - 'lib/mercenary/presenter.rb' + +# Offense count: 2 +Lint/DuplicateMethods: + Exclude: + - 'lib/mercenary/command.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments. +Lint/HandleExceptions: + Exclude: + - 'lib/mercenary/option.rb' + +# Offense count: 1 +Lint/UselessAssignment: + Exclude: + - 'lib/mercenary/presenter.rb' + +# Offense count: 1 +Metrics/AbcSize: + Max: 25 + +# Offense count: 1 +# Configuration parameters: CountComments, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 28 + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 319 + +# Offense count: 1 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/MethodLength: + Max: 24 + +# Offense count: 1 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/mercenary/command.rb' + +# Offense count: 1 +Style/MissingRespondToMissing: + Exclude: + - 'lib/mercenary/presenter.rb' diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.travis.yml b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.travis.yml new file mode 100644 index 0000000..688caa6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/.travis.yml @@ -0,0 +1,15 @@ +language: ruby +cache: bundler +rvm: + - 2.4 + - 2.6 + +before_script: bundle update +script: script/cibuild + +notifications: + email: + recipients: + - mercenary@jekyllrb.com + on_success: change + on_failure: change diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/Gemfile b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/Gemfile new file mode 100644 index 0000000..efaf3a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/Gemfile @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +# Specify your gem's dependencies in mercenary.gemspec +gemspec diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/History.markdown b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/History.markdown new file mode 100644 index 0000000..a4f6120 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/History.markdown @@ -0,0 +1,127 @@ +## 0.4.0 / 2020-01-18 + +### Major Enhancements + + * Drop Ruby 2.3 support + +### Minor Enhancements + + * Remove parent command's flags from subcommand usage (#44) + +### Development Fixes + + * Adopt Jekyll's rubocop config for consistency + +### Documentation + + * fixes the readme (#52) + +## 0.3.6 / 2016-04-07 + +### Bug Fixes + + * Presenter: Options should include those from parent command (#42) + +## 0.3.5 / 2014-11-12 + +### Bug Fixes + + * Capture `OptionsParser::InvalidOption` and show a nice error message (#38) + * Absolute paths for requires and autoloads (#39) + +### Development Fixes + + * Bump to RSpec 3 (#40) + +## 0.3.4 / 2014-07-11 + +### Bug Fixes + + * Use option object as key in the command's `@map` hash (#35) + +## 0.3.3 / 2014-05-07 + +### Bug Fixes + + * The `--version` flag should not exit with code 1, but instead code 0. (#33) + +## 0.3.2 / 2014-03-18 + +### Bug Fixes + + * Remove duplicate commands from help output; show aliases w/command names (#29) + +## 0.3.1 / 2014-02-21 + +### Minor Enhancements + + * Add `-t/--trace` to list of options in help message (#19) + +### Bug Fixes + + * `Mercenary::Option` now accepts return values in the form of Class constants (#22) + +## 0.3.0 / 2014-02-20 + +### Major Enhancements + + * Officially drop 1.8.7 support (#14) + * Allow Commands to set their own versions (#17) + * Show subcommands, options and usage in help and attach to all commands (#18) + * Add `-t, --trace` to allow full exception backtrace to print, otherwise print just the error message (#19) + +### Minor Enhancements + + * Logging state is maintained throughout process (#12) + * Tidy up Command#logger output (#21) + +### Development Fixes + + * Added specs for `Program` (#13) + +## 0.2.1 / 2013-12-25 + +### Bug Fixes + + * Added missing comma to fix '-v' and '--version' options (#9) + +## 0.2.0 / 2013-11-30 + +### Major Enhancements + + * Add `Command#default_command` to specify a default command if none is given by the user at runtime (#7) + +### Minor Enhancements + + * Add `Command#execute` to execute the actions of a command (#6) + +### Development Fixes + + * Add standard GitHub bootstrap and cibuild scripts to `script/` (#2) + +## 0.1.0 / 2013-11-08 + +### Major Enhancements + + * It works! + +### Minor Enhancements + + * Add a logger to `Command` + * Add `--version` switch to all programs + +### Bug Fixes + + * Fix `Command#syntax` and `Command#description`'s handing of setting vs getting + * Fix load path problem in `lib/mercenary.rb` + +### Development Fixes + + * Add TomDoc to everything + * Add a couple starter specs + * Add TravisCI badge + * Add Travis configuration + +## 0.0.1 / 2013-11-06 + + * Birthday! diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/LICENSE.txt new file mode 100644 index 0000000..cb1130e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2013-present Parker Moore and the mercenary contributors + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/README.md b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/README.md new file mode 100644 index 0000000..8150890 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/README.md @@ -0,0 +1,249 @@ +# Mercenary + +Lightweight and flexible library for writing command-line apps in Ruby. + +[![Build Status](https://secure.travis-ci.org/jekyll/mercenary.png)](https://travis-ci.org/jekyll/mercenary) + +## Installation + +Add this line to your application's Gemfile: + + gem 'mercenary' + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install mercenary + +**Note: Mercenary may not work with Ruby < 1.9.3.** + +## Usage + +Creating programs and commands with Mercenary is easy: + +```ruby +Mercenary.program(:jekyll) do |p| + p.version Jekyll::VERSION + p.description 'Jekyll is a blog-aware, static site generator in Ruby' + p.syntax "jekyll [options]" + + p.command(:new) do |c| + c.syntax "new PATH" # do not include the program name or super commands + c.description "Creates a new Jekyll site scaffold in PATH" + c.option 'blank', '--blank', 'Initialize the new site without any content.' + + c.action do |args, options| + Jekyll::Commands::New.process(args, blank: options['blank']) + end + end + + p.command(:build) do |c| + c.syntax "build [options]" + c.description "Builds your Jekyll site" + + c.option 'safe', '--safe', 'Run in safe mode' + c.option 'source', '--source DIR', 'From where to collect the source files' + c.option 'destination', '--dest DIR', 'To where the compiled files should be written' + + c.action do |_, options| + Jekyll::Commands::Build.process(options) + end + end + + # Bring in command bundled in external gem + begin + require "jekyll-import" + JekyllImport.init_with_program(p) + rescue LoadError + end + + p.default_command(:build) +end +``` + +All commands have the following default options: + +- `-h/--help` - show a help message +- `-v/--version` - show the program version +- `-t/--trace` - show the full backtrace when an error occurs + +## API + +### `Mercenary` + +#### `.program` + +Creates and executes a program. Accepts two arguments: + +- `name` - program name as a Symbol +- `block` - the specification for the program, passed the program instance as an + argument. + +Example is above, under the heading [Usage](#usage). + +### `Program` + +`Program` is a subclass of `Command`, so it has all of the methods documented +below as well as those for `Command`. + +#### `#config` + +Fetches the program configuration hash. + +### `Command` + +#### `#new` + +Create a new command. Accepts one argument: + +- `name` - the name of your command, as a symbol + +#### `#version` + +Sets or gets the version of the command. Accepts an optional argument: + +- `version` - (optional) the version to set for the command. If present, this + becomes the new version for the command and persists. + +#### `#syntax` + +Sets or gets the syntax of the command. Built on parent syntaxes if a parent +exists. Accepts one optional argument: + +- `syntax` - (optional) the syntax to set for the command. Will inherit from the + parent commands or program. Usually in the form of + `"command_name [OPTIONS]"` + +When a parent command exists, say `supercommand`, with syntax set as +`supercommand [OPTIONS]`, the syntax of the command in question +will be `supercommand command_name [OPTIONS]` with both +`` and `[OPTIONS]` stripped out. Any text between `<` and `>` or +between `[` and `]` will be stripped from parent command syntaxes. The purpose +of this chaining is to reduce redundancy. + +#### `#description` + +Sets or gets the description of the command. Accepts one optional argument: + +- `desc` - (optional) the description to set for the command. If + provided, will override any previous description set for the command. + +#### `#default_command` + +Sets or gets the default subcommand of the command to execute in the event no +subcommand is passed during execution. Accepts one optional argument: + +- `command_name` - (optional) the `Symbol` name of the subcommand to be + executed. Raises an `ArgumentError` if the subcommand doesn't exist. + Overwrites previously-set default commands. + +#### `#option` + +Adds a new option to the command. Accepts many arguments: + +- `config_key` - the configuration key that the value of this option maps to. +- `*options` - all the options, globbed, to be passed to `OptionParser`, namely the + switches and the option description. Usually in the format + `"-s", "--switch", "Sets the 'switch' flag"`. + +Valid option calls: + +```ruby +cmd.option 'config_key', '-c', 'Sets the "config" flag' +cmd.option 'config_key', '--config', 'Sets the "config" flag' +cmd.option 'config_key', '-c', '--config', 'Sets the "config" flag.' +cmd.option 'config_key', '-c FILE', '--config FILE', 'The config file.' +cmd.option 'config_key', '-c FILE1[,FILE2[,FILE3...]]', '--config FILE1[,FILE2[,FILE3...]]', Array, 'The config files.' +``` + +Notice that you can specify either a short switch, a long switch, or both. If +you want to accept an argument, you have to specify it in the switch strings. +The class of the argument defaults to `String`, but you can optionally set a +different class to create, e.g. `Array`, if you are expecting a particular class +in your code from this option's value. The description is also optional, but +it's highly recommended to include a description. + +#### `#alias` + +Specifies an alias for this command such that the alias may be used in place of +the command during execution. Accepts one argument: + +- `cmd_name` - the alias name for this command as a `Symbol` + +Example: + +```ruby +cmd.alias(:my_alias) +# Now `cmd` is now also executable via "my_alias" +``` + +#### `#action` + +Specifies a block to be executed in the event the command is specified at +runtime. The block is given two arguments: + +- `args` - the non-switch arguments given from the command-line +- `options` - the options hash built via the switches passed + +**Note that actions are additive**, meaning any new call to `#action` will +result in another action to be executed at runtime. Actions will be executed in +the order they are specified in. + +Example: + +```ruby +cmd.action do |args, options| + # do something! +end +``` + +#### `#logger` + +Access the logger for this command. Useful for outputting information to STDOUT. +Accepts one optional argument: + +- `level` - (optional) the severity threshold at which to begin logging. Uses + Ruby's built-in + [`Logger`](http://www.ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html) + levels. + +Log level defaults to `Logger::INFO`. + +Examples: + +```ruby +cmd.logger(Logger::DEBUG) +cmd.logger.debug "My debug message." +cmd.logger.info "My informative message." +cmd.logger.warn "ACHTUNG!!" +cmd.logger.error "Something terrible has happened." +cmd.logger.fatal "I can't continue doing what I'm doing." +``` + +#### `#command` + +Creates a new subcommand for the current command. Accepts two arguments: + +- `cmd_name` - the command name, as a Symbol +- `block` - the specification of the subcommand in a block + +Example: + +```ruby +my_command.command(:my_subcommand) do |subcmd| + subcmd.description 'My subcommand' + subcmd.syntax 'my_subcommand [OPTIONS]' + # ... +end +``` + +## Contributing + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/Rakefile b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/Rakefile new file mode 100644 index 0000000..5263b58 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/Rakefile @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require "bundler/gem_tasks" diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/help_dialogue.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/help_dialogue.rb new file mode 100755 index 0000000..c99ccc1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/help_dialogue.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift File.join(__dir__, "..", "lib") + +require "mercenary" + +# This example sets the logging mode of mercenary to +# debug. Logging messages from "p.logger.debug" will +# be output to STDOUT. + +Mercenary.program(:help_dialogue) do |p| + p.version "2.0.1" + p.description "An example of the help dialogue in Mercenary" + p.syntax "help_dialogue " + + p.command(:some_subcommand) do |c| + c.version "1.4.2" + c.syntax "some_subcommand [options]" + c.description "Some subcommand to do something" + c.option "an_option", "-o", "--option", "Some option" + c.alias(:blah) + + c.command(:yet_another_sub) do |f| + f.syntax "yet_another_sub [options]" + f.description "Do amazing things" + f.option "blah", "-b", "--blah", "Trigger blah flag" + f.option "heh", "-H ARG", "--heh ARG", "Give a heh" + + f.action do |args, options| + print "Args: " + p args + print "Opts: " + p options + end + end + end + + p.command(:another_subcommand) do |c| + c.syntax "another_subcommand [options]" + c.description "Another subcommand to do something different." + c.option "an_option", "-O", "--option", "Some option" + c.option "another_options", "--pluginzzz", "Set where the plugins should be found from" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/logging.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/logging.rb new file mode 100755 index 0000000..3a38229 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/logging.rb @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift File.join(__dir__, "..", "lib") + +require "mercenary" + +# This example sets the logging mode of mercenary to +# debug. Logging messages from "p.logger.debug" will +# be output to STDOUT. + +Mercenary.program(:logger_output) do |p| + p.version "5.2.6" + p.description "An example of turning on logging for Mercenary." + p.syntax "logger_output" + + p.logger.info "The default log level is INFO. So this will output." + p.logger.debug "Since DEBUG is below INFO, this will not output." + + p.logger(Logger::DEBUG) + p.logger.debug "Logger level now set to DEBUG. So everything will output." + + p.logger.debug "Example of DEBUG level message." + p.logger.info "Example of INFO level message." + p.logger.warn "Example of WARN level message." + p.logger.error "Example of ERROR level message." + p.logger.fatal "Example of FATAL level message." + p.logger.unknown "Example of UNKNOWN level message." + + p.action do |_args, _options| + p.logger(Logger::INFO) + p.logger.debug "Logger level back to INFO. This line will not output." + p.logger.info "This INFO message will output." + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/trace.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/trace.rb new file mode 100755 index 0000000..cca6b6c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/examples/trace.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift File.join(__dir__, "..", "lib") + +require "mercenary" + +# This example sets the logging mode of mercenary to +# debug. Logging messages from "p.logger.debug" will +# be output to STDOUT. + +Mercenary.program(:trace) do |p| + p.version "2.0.1" + p.description "An example of traces in Mercenary" + p.syntax "trace " + + p.action do |_, _| + raise ArgumentError, "YOU DID SOMETHING TERRIBLE YOU BUFFOON" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary.rb new file mode 100644 index 0000000..cd38f78 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require File.expand_path("mercenary/version", __dir__) +require "optparse" +require "logger" + +module Mercenary + autoload :Command, File.expand_path("mercenary/command", __dir__) + autoload :Option, File.expand_path("mercenary/option", __dir__) + autoload :Presenter, File.expand_path("mercenary/presenter", __dir__) + autoload :Program, File.expand_path("mercenary/program", __dir__) + + # Public: Instantiate a new program and execute. + # + # name - the name of your program + # + # Returns nothing. + def self.program(name) + program = Program.new(name) + yield program + program.go(ARGV) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb new file mode 100644 index 0000000..08ddf94 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb @@ -0,0 +1,281 @@ +# frozen_string_literal: false + +module Mercenary + class Command + attr_reader :name + attr_reader :description + attr_reader :syntax + attr_accessor :options + attr_accessor :commands + attr_accessor :actions + attr_reader :map + attr_accessor :parent + attr_reader :trace + attr_reader :aliases + + # Public: Creates a new Command + # + # name - the name of the command + # parent - (optional) the instancce of Mercenary::Command which you wish to + # be the parent of this command + # + # Returns nothing + def initialize(name, parent = nil) + @name = name + @options = [] + @commands = {} + @actions = [] + @map = {} + @parent = parent + @trace = false + @aliases = [] + end + + # Public: Sets or gets the command version + # + # version - the command version (optional) + # + # Returns the version and sets it if an argument is non-nil + def version(version = nil) + @version = version if version + @version + end + + # Public: Sets or gets the syntax string + # + # syntax - the string which describes this command's usage syntax (optional) + # + # Returns the syntax string and sets it if an argument is present + def syntax(syntax = nil) + @syntax = syntax if syntax + syntax_list = [] + syntax_list << parent.syntax.to_s.gsub(%r!<[\w\s-]+>!, "").gsub(%r!\[[\w\s-]+\]!, "").strip if parent + syntax_list << (@syntax || name.to_s) + syntax_list.join(" ") + end + + # Public: Sets or gets the command description + # + # description - the description of what the command does (optional) + # + # Returns the description and sets it if an argument is present + def description(desc = nil) + @description = desc if desc + @description + end + + # Public: Sets the default command + # + # command_name - the command name to be executed in the event no args are + # present + # + # Returns the default command if there is one, `nil` otherwise + def default_command(command_name = nil) + if command_name + if commands.key?(command_name) + @default_command = commands[command_name] if command_name + @default_command + else + raise ArgumentError, "'#{command_name}' couldn't be found in this command's list of commands." + end + else + @default_command + end + end + + # Public: Adds an option switch + # + # sym - the variable key which is used to identify the value of the switch + # at runtime in the options hash + # + # Returns nothing + def option(sym, *options) + new_option = Option.new(sym, options) + @options << new_option + @map[new_option] = sym + end + + # Public: Adds a subcommand + # + # cmd_name - the name of the command + # block - a block accepting the new instance of Mercenary::Command to be + # modified (optional) + # + # Returns nothing + def command(cmd_name) + cmd = Command.new(cmd_name, self) + yield cmd + @commands[cmd_name] = cmd + end + + # Public: Add an alias for this command's name to be attached to the parent + # + # cmd_name - the name of the alias + # + # Returns nothing + def alias(cmd_name) + logger.debug "adding alias to parent for self: '#{cmd_name}'" + aliases << cmd_name + @parent.commands[cmd_name] = self + end + + # Public: Add an action Proc to be executed at runtime + # + # block - the Proc to be executed at runtime + # + # Returns nothing + def action(&block) + @actions << block + end + + # Public: Fetch a Logger (stdlib) + # + # level - the logger level (a Logger constant, see docs for more info) + # + # Returns the instance of Logger + + def logger(level = nil) + unless @logger + @logger = Logger.new(STDOUT) + @logger.level = level || Logger::INFO + @logger.formatter = proc do |severity, _datetime, _progname, msg| + "#{identity} | " << "#{severity.downcase.capitalize}:".ljust(7) << " #{msg}\n" + end + end + + @logger.level = level unless level.nil? + @logger + end + + # Public: Run the command + # + # argv - an array of string args + # opts - the instance of OptionParser + # config - the output config hash + # + # Returns the command to be executed + def go(argv, opts, config) + opts.banner = "Usage: #{syntax}" + process_options(opts, config) + add_default_options(opts) + + if argv[0] && cmd = commands[argv[0].to_sym] + logger.debug "Found subcommand '#{cmd.name}'" + argv.shift + cmd.go(argv, opts, config) + else + logger.debug "No additional command found, time to exec" + self + end + end + + # Public: Add this command's options to OptionParser and set a default + # action of setting the value of the option to the inputted hash + # + # opts - instance of OptionParser + # config - the Hash in which the option values should be placed + # + # Returns nothing + def process_options(opts, config) + options.each do |option| + opts.on(*option.for_option_parser) do |x| + config[map[option]] = x + end + end + end + + # Public: Add version and help options to the command + # + # opts - instance of OptionParser + # + # Returns nothing + def add_default_options(opts) + option "show_help", "-h", "--help", "Show this message" + option "show_version", "-v", "--version", "Print the name and version" + option "show_backtrace", "-t", "--trace", "Show the full backtrace when an error occurs" + opts.on("-v", "--version", "Print the version") do + puts "#{name} #{version}" + exit(0) + end + + opts.on("-t", "--trace", "Show full backtrace if an error occurs") do + @trace = true + end + + opts.on_tail("-h", "--help", "Show this message") do + puts self + exit + end + end + + # Public: Execute all actions given the inputted args and options + # + # argv - (optional) command-line args (sans opts) + # config - (optional) the Hash configuration of string key to value + # + # Returns nothing + def execute(argv = [], config = {}) + if actions.empty? && !default_command.nil? + default_command.execute + else + actions.each { |a| a.call(argv, config) } + end + end + + # Public: Check if this command has a subcommand + # + # sub_command - the name of the subcommand + # + # Returns true if this command is the parent of a command of name + # 'sub_command' and false otherwise + def has_command?(sub_command) + commands.key?(sub_command) + end + + # Public: Identify this command + # + # Returns a string which identifies this command + def ident + "" + end + + # Public: Get the full identity (name & version) of this command + # + # Returns a string containing the name and version if it exists + def identity + "#{full_name} #{version}".strip + end + + # Public: Get the name of the current command plus that of + # its parent commands + # + # Returns the full name of the command + def full_name + the_name = [] + the_name << parent.full_name if parent&.full_name + the_name << name + the_name.join(" ") + end + + # Public: Return all the names and aliases for this command. + # + # Returns a comma-separated String list of the name followed by its aliases + def names_and_aliases + ([name.to_s] + aliases).compact.join(", ") + end + + # Public: Build a string containing a summary of the command + # + # Returns a one-line summary of the command. + def summarize + " #{names_and_aliases.ljust(20)} #{description}" + end + + # Public: Build a string containing the command name, options and any subcommands + # + # Returns the string identifying this command, its options and its subcommands + def to_s + Presenter.new(self).print_command + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/option.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/option.rb new file mode 100644 index 0000000..dfd21d5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/option.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true + +module Mercenary + class Option + attr_reader :config_key, :description, :short, :long, :return_type + + # Public: Create a new Option + # + # config_key - the key in the config hash to which the value of this option + # will map + # info - an array containing first the switches, then an optional + # return type (e.g. Array), then a description of the option + # + # Returns nothing + def initialize(config_key, info) + @config_key = config_key + while arg = info.shift + begin + @return_type = Object.const_get(arg.to_s) + next + rescue NameError + end + if arg.start_with?("-") + if arg.start_with?("--") + @long = arg + else + @short = arg + end + next + end + @description = arg + end + end + + # Public: Fetch the array containing the info OptionParser is interested in + # + # Returns the array which OptionParser#on wants + def for_option_parser + [short, long, return_type, description].flatten.reject { |o| o.to_s.empty? } + end + + # Public: Build a string representation of this option including the + # switches and description + # + # Returns a string representation of this option + def to_s + "#{formatted_switches} #{description}" + end + + # Public: Build a beautifully-formatted string representation of the switches + # + # Returns a formatted string representation of the switches + def formatted_switches + [ + switches.first.rjust(10), + switches.last.ljust(13), + ].join(", ").gsub(%r! , !, " ").gsub(%r!, !, " ") + end + + # Public: Hash based on the hash value of instance variables + # + # Returns a Fixnum which is unique to this Option based on the instance variables + def hash + instance_variables.map do |var| + instance_variable_get(var).hash + end.reduce(:^) + end + + # Public: Check equivalence of two Options based on equivalence of their + # instance variables + # + # Returns true if all the instance variables are equal, false otherwise + def eql?(other) + return false unless self.class.eql?(other.class) + + instance_variables.map do |var| + instance_variable_get(var).eql?(other.instance_variable_get(var)) + end.all? + end + + # Public: Fetch an array of switches, including the short and long versions + # + # Returns an array of two strings. An empty string represents no switch in + # that position. + def switches + [short, long].map(&:to_s) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/presenter.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/presenter.rb new file mode 100644 index 0000000..11685fe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/presenter.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true + +module Mercenary + class Presenter + attr_accessor :command + + # Public: Make a new Presenter + # + # command - a Mercenary::Command to present + # + # Returns nothing + def initialize(command) + @command = command + end + + # Public: Builds a string representation of the command usage + # + # Returns the string representation of the command usage + def usage_presentation + " #{command.syntax}" + end + + # Public: Builds a string representation of the options + # + # Returns the string representation of the options + def options_presentation + return nil unless command_options_presentation || parent_command_options_presentation + + [command_options_presentation, parent_command_options_presentation].compact.join("\n") + end + + def command_options_presentation + return nil if command.options.empty? + + options = command.options + options -= command.parent.options if command.parent + options.map(&:to_s).join("\n") + end + + # Public: Builds a string representation of the options for parent + # commands + # + # Returns the string representation of the options for parent commands + def parent_command_options_presentation + return nil unless command.parent + + Presenter.new(command.parent).options_presentation + end + + # Public: Builds a string representation of the subcommands + # + # Returns the string representation of the subcommands + def subcommands_presentation + return nil if command.commands.empty? + + command.commands.values.uniq.map(&:summarize).join("\n") + end + + # Public: Builds the command header, including the command identity and description + # + # Returns the command header as a String + def command_header + header = command.identity.to_s + header << " -- #{command.description}" if command.description + header + end + + # Public: Builds a string representation of the whole command + # + # Returns the string representation of the whole command + def command_presentation + msg = [] + msg << command_header + msg << "Usage:" + msg << usage_presentation + + if opts = options_presentation + msg << "Options:\n#{opts}" + end + if subcommands = subcommands_presentation + msg << "Subcommands:\n#{subcommands_presentation}" + end + msg.join("\n\n") + end + + # Public: Turn a print_* into a *_presentation or freak out + # + # meth - the method being called + # args - an array of arguments passed to the missing method + # block - the block passed to the missing method + # + # Returns the value of whatever function is called + def method_missing(meth, *args, &block) + if meth.to_s =~ %r!^print_(.+)$! + send("#{Regexp.last_match(1).downcase}_presentation") + else + # You *must* call super if you don't handle the method, + # otherwise you'll mess up Ruby's method lookup. + super + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/program.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/program.rb new file mode 100644 index 0000000..a8d0c52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/program.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Mercenary + class Program < Command + attr_reader :optparse + attr_reader :config + + # Public: Creates a new Program + # + # name - the name of the program + # + # Returns nothing + def initialize(name) + @config = {} + super(name) + end + + # Public: Run the program + # + # argv - an array of string args (usually ARGV) + # + # Returns nothing + def go(argv) + logger.debug("Using args passed in: #{argv.inspect}") + + cmd = nil + + @optparse = OptionParser.new do |opts| + cmd = super(argv, opts, @config) + end + + begin + @optparse.parse!(argv) + rescue OptionParser::InvalidOption => e + logger.error "Whoops, we can't understand your command." + logger.error e.message.to_s + logger.error "Run your command again with the --help switch to see available options." + abort + end + + logger.debug("Parsed config: #{@config.inspect}") + + begin + cmd.execute(argv, @config) + rescue StandardError => e + if cmd.trace + raise e + else + logger.error e.message + abort + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/version.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/version.rb new file mode 100644 index 0000000..3f3e475 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Mercenary + VERSION = "0.4.0" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/mercenary.gemspec b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/mercenary.gemspec new file mode 100644 index 0000000..ff3efa4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/mercenary.gemspec @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +lib = File.expand_path("lib", __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require "mercenary/version" + +Gem::Specification.new do |spec| + spec.name = "mercenary" + spec.version = Mercenary::VERSION + spec.authors = ["Tom Preston-Werner", "Parker Moore"] + spec.email = ["tom@mojombo.com", "parkrmoore@gmail.com"] + spec.description = "Lightweight and flexible library for writing command-line apps in Ruby." + spec.summary = "Lightweight and flexible library for writing command-line apps in Ruby." + spec.homepage = "https://github.com/jekyll/mercenary" + spec.license = "MIT" + + spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) + spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r!^(test|spec|features)/!) + spec.require_paths = ["lib"] + + spec.required_ruby_version = ">= 2.4.0" + + spec.add_development_dependency "bundler" + spec.add_development_dependency "rake" + spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "rubocop-jekyll", "~> 0.10.0" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/bootstrap b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/bootstrap new file mode 100755 index 0000000..a0cf262 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/bootstrap @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +echo "Time to get set up." +bundle install +echo "Boom." diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/cibuild b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/cibuild new file mode 100755 index 0000000..43eac1a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/cibuild @@ -0,0 +1,7 @@ +#! /bin/sh + +set -ex + +bundle exec rspec +script/fmt +script/examples diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/console b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/console new file mode 100755 index 0000000..27ed279 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/console @@ -0,0 +1,3 @@ +#! /bin/bash + +irb -r./lib/mercenary.rb diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/examples b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/examples new file mode 100755 index 0000000..a722ab3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/examples @@ -0,0 +1,18 @@ +#! /bin/bash + +set -e + +function run () { + echo "+ ruby ./examples/$@" + ruby -e "puts '=' * 79" + ruby ./examples/$@ + ruby -e "puts '=' * 79" +} + +run logging.rb +run logging.rb -v +run help_dialogue.rb -h +run help_dialogue.rb some_subcommand -h +run help_dialogue.rb another_subcommand -h +run help_dialogue.rb some_subcommand yet_another_sub -h +run help_dialogue.rb some_subcommand yet_another_sub -b diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/fmt b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/fmt new file mode 100755 index 0000000..74118c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/script/fmt @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Rubocop $(bundle exec rubocop --version)" +bundle exec rubocop -S -D -E $@ diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/command_spec.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/command_spec.rb new file mode 100644 index 0000000..85d766b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/command_spec.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe(Mercenary::Command) do + context "a basic command" do + let(:command) { Mercenary::Command.new(:my_name) } + let(:parent) { Mercenary::Command.new(:my_parent) } + let(:with_sub) do + c = Mercenary::Command.new(:i_have_subcommand) + add_sub.call(c) + c + end + let(:command_with_parent) do + Mercenary::Command.new( + :i_have_parent, + parent + ) + end + let(:add_sub) do + proc do |c| + c.command(:sub_command) { |p| } + end + end + + it "can be created with just a name" do + expect(command.name).to eql(:my_name) + end + + it "can hold a parent command" do + expect(command_with_parent.parent).to eql(parent) + end + + it "can create subcommands" do + expect(add_sub.call(command)).to be_a(Mercenary::Command) + expect(add_sub.call(command).parent).to eq(command) + end + + it "can set its version" do + version = "1.4.2" + command.version version + expect(command.version).to eq(version) + end + + it "can set its syntax" do + syntax_string = "my_name [options]" + cmd = described_class.new(:my_name) + cmd.syntax syntax_string + expect(cmd.syntax).to eq(syntax_string) + end + + it "can set its description" do + desc = "run all the things" + command.description desc + expect(command.description).to eq(desc) + end + + it "can set its options" do + name = "show_drafts" + opts = ["--drafts", "Render posts in the _drafts folder"] + option = Mercenary::Option.new(name, opts) + command.option name, *opts + expect(command.options).to eql([option]) + expect(command.map.values).to include(name) + end + + it "knows its full name" do + expect(command_with_parent.full_name).to eql("my_parent i_have_parent") + end + + it "knows its identity" do + command_with_parent.version "1.8.7" + expect(command_with_parent.identity).to eql("my_parent i_have_parent 1.8.7") + end + + it "raises an ArgumentError if I specify a default_command that isn't there" do + c = command # some weird NameError with the block below? + expect { c.default_command(:nope) }.to raise_error(ArgumentError) + end + + it "sets the default_command" do + expect(with_sub.default_command(:sub_command).name).to eq(:sub_command) + end + + context "with an alias" do + before(:each) do + command_with_parent.alias(:an_alias) + end + it "shows the alias in the summary" do + expect(command_with_parent.summarize).to eql(" i_have_parent, an_alias ") + end + + it "its names_and_aliases method reports both the name and alias" do + expect(command_with_parent.names_and_aliases).to eql("i_have_parent, an_alias") + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/option_spec.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/option_spec.rb new file mode 100644 index 0000000..ce10a62 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/option_spec.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe(Mercenary::Option) do + let(:config_key) { "largo" } + let(:description) { "This is a description" } + let(:switches) { ["-l", "--largo"] } + let(:option) { described_class.new(config_key, [switches, description].flatten.reject(&:nil?)) } + + it "knows its config key" do + expect(option.config_key).to eql(config_key) + end + + it "knows its description" do + expect(option.description).to eql(description) + end + + it "knows its switches" do + expect(option.switches).to eql(switches) + end + + it "knows how to present itself" do + expect(option.to_s).to eql(" -l, --largo #{description}") + end + + it "has an OptionParser representation" do + expect(option.for_option_parser).to eql([switches, description].flatten) + end + + it "compares itself with other options well" do + new_option = described_class.new(config_key, ["-l", "--largo", description]) + expect(option.eql?(new_option)).to be(true) + expect(option.hash.eql?(new_option.hash)).to be(true) + end + + it "has a custom #hash" do + expect(option.hash.to_s).to match(%r!\d+!) + end + + context "with just the long switch" do + let(:switches) { ["--largo"] } + + it "adds an empty string in place of the short switch" do + expect(option.switches).to eql(["", "--largo"]) + end + + it "sets its description properly" do + expect(option.description).to eql(description) + end + + it "knows how to present the switch" do + expect(option.formatted_switches).to eql(" --largo ") + end + end + + context "with just the short switch" do + let(:switches) { ["-l"] } + + it "adds an empty string in place of the long switch" do + expect(option.switches).to eql(["-l", ""]) + end + + it "sets its description properly" do + expect(option.description).to eql(description) + end + + it "knows how to present the switch" do + expect(option.formatted_switches).to eql(" -l ") + end + end + + context "without a description" do + let(:description) { nil } + + it "knows there is no description" do + expect(option.description).to be(nil) + end + + it "knows both inputs are switches" do + expect(option.switches).to eql(switches) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/presenter_spec.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/presenter_spec.rb new file mode 100644 index 0000000..b72dbae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/presenter_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe(Mercenary::Presenter) do + let(:supercommand) { Mercenary::Command.new(:script_name) } + let(:command) { Mercenary::Command.new(:subcommand, supercommand) } + let(:presenter) { described_class.new(command) } + + before(:each) do + supercommand.option "version", "-v", "--version", "Show version" + supercommand.option "help", "-h", "--help", "Help!" + + command.version "1.4.2" + command.description "Do all the things." + command.option "help", "-h", "--help", "Help!" + command.option "one", "-1", "--one", "The first option" + command.option "two", "-2", "--two", "The second option" + command.alias :cmd + supercommand.commands[command.name] = command + end + + it "knows how to present the command" do + expect(presenter.command_presentation).to eql("script_name subcommand 1.4.2 -- Do all the things.\n\nUsage:\n\n script_name subcommand\n\nOptions:\n -1, --one The first option\n -2, --two The second option\n -v, --version Show version\n -h, --help Help!") + end + + it "knows how to present the subcommands, without duplicates for aliases" do + expect(described_class.new(supercommand).subcommands_presentation).to eql(" subcommand, cmd Do all the things.") + end + + it "knows how to present the usage" do + expect(presenter.usage_presentation).to eql(" script_name subcommand") + end + + it "knows how to present the options" do + expect(presenter.options_presentation).to eql(" -1, --one The first option\n -2, --two The second option\n -v, --version Show version\n -h, --help Help!") + end + + it "allows you to say print_* instead of *_presentation" do + expect(presenter.print_usage).to eql(presenter.usage_presentation) + expect(presenter.print_subcommands).to eql(presenter.subcommands_presentation) + expect(presenter.print_options).to eql(presenter.options_presentation) + expect(presenter.print_command).to eql(presenter.command_presentation) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/program_spec.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/program_spec.rb new file mode 100644 index 0000000..aeb667b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/program_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe(Mercenary::Program) do + context "a basic program" do + let(:program) { Mercenary::Program.new(:my_name) } + + it "can be created with just a name" do + expect(program.name).to eql(:my_name) + end + + it "can set its version" do + version = Mercenary::VERSION + program.version version + expect(program.version).to eq(version) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/spec_helper.rb b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/spec_helper.rb new file mode 100644 index 0000000..42801c7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/spec/spec_helper.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +lib = File.expand_path("../lib", __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require "mercenary" + +RSpec.configure do |config| + config.run_all_when_everything_filtered = true + config.filter_run :focus + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/Gemfile b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/Gemfile new file mode 100644 index 0000000..60ea36c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/Gemfile @@ -0,0 +1,22 @@ +# Frozen-string-literal: true +# Copyright: 2015 - 2017 Jordon Bedwell - MIT License +# Encoding: utf-8 + +source "https://rubygems.org" +gem "rake", :require => false +gemspec + +group :test do + gem "safe_yaml", :require => false + gem "luna-rspec-formatters", :require => false + gem "simplecov", :require => false +end + +group :development do + gem "rspec", :require => false + gem "rspec-helpers", :require => false + gem "rubocop", :github => "bbatsov/rubocop", :require => false + gem "benchmark-ips", :require => false + gem "simple-ansi", :require => false + gem "pry", :require => false +end diff --git a/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/LICENSE b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/LICENSE new file mode 100644 index 0000000..139db79 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 - 2017 Jordon Bedwell + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/Rakefile b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/Rakefile new file mode 100644 index 0000000..a090251 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/Rakefile @@ -0,0 +1,12 @@ +# Frozen-string-literal: true +# Copyright: 2017 - 2018 - MIT License +# Source: https://github.com/envygeeks/devfiles +# Author: Jordon Bedwell +# Encoding: utf-8 + +task default: [:spec] +task(:spec) { exec "script/test" } +task(:test) { exec "script/test" } +Dir.glob("script/rake.d/*.rake").each do |v| + load v +end diff --git a/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil.rb b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil.rb new file mode 100644 index 0000000..1a15873 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil.rb @@ -0,0 +1,909 @@ +# Frozen-string-literal: true +# Copyright: 2015 - 2017 Jordon Bedwell - MIT License +# Encoding: utf-8 + +require "pathutil/helpers" +require "forwardable/extended" +require "find" + +class Pathutil + attr_writer :encoding + extend Forwardable::Extended + extend Helpers + + # -- + # @note A lot of this class can be compatible with Pathname. + # Initialize a new instance. + # @return Pathutil + # -- + def initialize(path) + return @path = path if path.is_a?(String) + return @path = path.to_path if path.respond_to?(:to_path) + return @path = path.to_s + end + + # -- + # Make a path relative. + # -- + def relative + return self if relative? + self.class.new(strip_windows_drive.gsub( + %r!\A(\\+|/+)!, "" + )) + end + + # -- + # Make a path absolute + # -- + def absolute + return self if absolute? + self.class.new("/").join( + @path + ) + end + + # -- + # @see Pathname#cleanpath. + # @note This is a wholesale rip and cleanup of Pathname#cleanpath + # @return Pathutil + # -- + def cleanpath(symlink = false) + symlink ? conservative_cleanpath : aggressive_cleanpath + end + + # -- + # @yield Pathutil + # @note It will return all results that it finds across all ascending paths. + # @example Pathutil.new("~/").expand_path.search_backwards(".bashrc") => [#] + # Search backwards for a file (like Rakefile, _config.yml, opts.yml). + # @return Enum + # -- + def search_backwards(file, backwards: Float::INFINITY) + ary = [] + + ascend.with_index(1).each do |path, index| + if index > backwards + break + + else + Dir.chdir path do + if block_given? + file = self.class.new(file) + if yield(file) + ary.push( + file + ) + end + + elsif File.exist?(file) + ary.push(self.class.new( + path.join(file) + )) + end + end + end + end + + ary + end + + # -- + # Read the file as a YAML file turning it into an object. + # @see self.class.load_yaml as this a direct alias of that method. + # @return Hash + # -- + def read_yaml(throw_missing: false, **kwd) + self.class.load_yaml( + read, **kwd + ) + + rescue Errno::ENOENT + throw_missing ? raise : ( + return {} + ) + end + + # -- + # Read the file as a JSON file turning it into an object. + # @see self.class.read_json as this is a direct alias of that method. + # @return Hash + # -- + def read_json(throw_missing: false) + JSON.parse( + read + ) + + rescue Errno::ENOENT + throw_missing ? raise : ( + return {} + ) + end + + # -- + # @note The blank part is intentionally left there so that you can rejoin. + # Splits the path into all parts so that you can do step by step comparisons + # @example Pathutil.new("/my/path").split_path # => ["", "my", "path"] + # @return Array + # -- + def split_path + @path.split( + %r!\\+|/+! + ) + end + + # -- + # @see `String#==` for more details. + # A stricter version of `==` that also makes sure the object matches. + # @return true|false + # -- + def ===(other) + other.is_a?(self.class) && @path == other + end + + # -- + # @example Pathutil.new("/hello") >= Pathutil.new("/") # => true + # @example Pathutil.new("/hello") >= Pathutil.new("/hello") # => true + # Checks to see if a path falls within a path and deeper or is the other. + # @return true|false + # -- + def >=(other) + mine, other = expanded_paths(other) + return true if other == mine + mine.in_path?(other) + end + + # -- + # @example Pathutil.new("/hello/world") > Pathutil.new("/hello") # => true + # Strictly checks to see if a path is deeper but within the path of the other. + # @return true|false + # -- + def >(other) + mine, other = expanded_paths(other) + return false if other == mine + mine.in_path?(other) + end + + # -- + # @example Pathutil.new("/") < Pathutil.new("/hello") # => true + # Strictly check to see if a path is behind other path but within it. + # @return true|false + # -- + def <(other) + mine, other = expanded_paths(other) + return false if other == mine + other.in_path?(mine) + end + + # -- + # Check to see if a path is behind the other path but within it. + # @example Pathutil.new("/hello") < Pathutil.new("/hello") # => true + # @example Pathutil.new("/") < Pathutil.new("/hello") # => true + # @return true|false + # -- + def <=(other) + mine, other = expanded_paths(other) + return true if other == mine + other.in_path?(mine) + end + + # -- + # @note "./" is considered relative. + # Check to see if the path is absolute, as in: starts with "/" + # @return true|false + # -- + def absolute? + return !!( + @path =~ %r!\A(?:[A-Za-z]:)?(?:\\+|/+)! + ) + end + + # -- + # @yield Pathutil + # Break apart the path and yield each with the previous parts. + # @example Pathutil.new("/hello/world").ascend.to_a # => ["/", "/hello", "/hello/world"] + # @example Pathutil.new("/hello/world").ascend { |path| $stdout.puts path } + # @return Enum + # -- + def ascend + unless block_given? + return to_enum( + __method__ + ) + end + + yield( + path = self + ) + + while (new_path = path.dirname) + if path == new_path || new_path == "." + break + else + path = new_path + yield new_path + end + end + + nil + end + + # -- + # @yield Pathutil + # Break apart the path in reverse order and descend into the path. + # @example Pathutil.new("/hello/world").descend.to_a # => ["/hello/world", "/hello", "/"] + # @example Pathutil.new("/hello/world").descend { |path| $stdout.puts path } + # @return Enum + # -- + def descend + unless block_given? + return to_enum( + __method__ + ) + end + + ascend.to_a.reverse_each do |val| + yield val + end + + nil + end + + # -- + # @yield Pathutil + # @example Pathutil.new("/hello/world").each_line { |line| $stdout.puts line } + # Wraps `readlines` and allows you to yield on the result. + # @return Enum + # -- + def each_line + return to_enum(__method__) unless block_given? + readlines.each do |line| + yield line + end + + nil + end + + # -- + # @example Pathutil.new("/hello").fnmatch?("/hello") # => true + # Unlike traditional `fnmatch`, with this one `Regexp` is allowed. + # @example Pathutil.new("/hello").fnmatch?(/h/) # => true + # @see `File#fnmatch` for more information. + # @return true|false + # -- + def fnmatch?(matcher) + matcher.is_a?(Regexp) ? !!(self =~ matcher) : \ + File.fnmatch(matcher, self) + end + + # -- + # Allows you to quickly determine if the file is the root folder. + # @return true|false + # -- + def root? + !!(self =~ %r!\A(?:[A-Za-z]:)?(?:\\+|/+)\z!) + end + + # -- + # Allows you to check if the current path is in the path you want. + # @return true|false + # -- + def in_path?(path) + path = self.class.new(path).expand_path.split_path + mine = (symlink?? expand_path.realpath : expand_path).split_path + path.each_with_index { |part, index| return false if mine[index] != part } + true + end + + # -- + def inspect + "#<#{self.class}:#{@path}>" + end + + # -- + # @return Array + # Grab all of the children from the current directory, including hidden. + # @yield Pathutil + # -- + def children + ary = [] + + Dir.foreach(@path) do |path| + if path == "." || path == ".." + next + else + path = self.class.new(File.join(@path, path)) + yield path if block_given? + ary.push( + path + ) + end + end + + ary + end + + # -- + # @yield Pathutil + # Allows you to glob however you wish to glob in the current `Pathutil` + # @see `File::Constants` for a list of flags. + # @return Enum + # -- + def glob(pattern, flags = 0) + unless block_given? + return to_enum( + __method__, pattern, flags + ) + end + + chdir do + Dir.glob(pattern, flags).each do |file| + yield self.class.new( + File.join(@path, file) + ) + end + end + + nil + end + + # -- + # @yield &block + # Move to the current directory temporarily (or for good) and do work son. + # @note you do not need to ship a block at all. + # @return nil + # -- + def chdir + if !block_given? + Dir.chdir( + @path + ) + + else + Dir.chdir @path do + yield + end + end + end + + # -- + # @yield Pathutil + # Find all files without care and yield the given block. + # @return Enum + # -- + def find + return to_enum(__method__) unless block_given? + Find.find @path do |val| + yield self.class.new(val) + end + end + + # -- + # @yield Pathutil + # Splits the path returning each part (filename) back to you. + # @return Enum + # -- + def each_filename + return to_enum(__method__) unless block_given? + @path.split(File::SEPARATOR).delete_if(&:empty?).each do |file| + yield file + end + end + + # -- + # Get the parent of the current path. + # @note This will simply return self if "/". + # @return Pathutil + # -- + def parent + return self if @path == "/" + self.class.new(absolute?? File.dirname(@path) : File.join( + @path, ".." + )) + end + + # -- + # @yield Pathutil + # Split the file into its dirname and basename, so you can do stuff. + # @return nil + # -- + def split + File.split(@path).collect! do |path| + self.class.new(path) + end + end + + # -- + # @note Your extension should start with "." + # Replace a files extension with your given extension. + # @return Pathutil + # -- + def sub_ext(ext) + self.class.new(@path.chomp(File.extname(@path)) + ext) + end + + # -- + # A less complex version of `relative_path_from` that simply uses a + # `Regexp` and returns the full path if it cannot be determined. + # @return Pathutil + # -- + def relative_path_from(from) + from = self.class.new(from).expand_path.gsub(%r!/$!, "") + self.class.new(expand_path.gsub(%r!^#{ + from.regexp_escape + }/!, "")) + end + + # -- + # Expands the path and left joins the root to the path. + # @return Pathutil + # -- + def enforce_root(root) + return self if !relative? && in_path?(root) + self.class.new(root).join( + self + ) + end + + # -- + # Copy a directory, allowing symlinks if the link falls inside of the root. + # This is indented for people who wish some safety to their copies. + # @note Ignore is ignored on safe_copy file because it's explicit. + # @return nil + # -- + def safe_copy(to, root: nil, ignore: []) + raise ArgumentError, "must give a root" unless root + root = self.class.new(root) + to = self.class.new(to) + + if directory? + safe_copy_directory(to, { + :root => root, :ignore => ignore + }) + + else + safe_copy_file(to, { + :root => root + }) + end + end + + # -- + # @see `self.class.normalize` as this is an alias. + # -- + def normalize + return @normalize ||= begin + self.class.normalize + end + end + + # -- + # @see `self.class.encoding` as this is an alias. + # -- + def encoding + return @encoding ||= begin + self.class.encoding + end + end + + # -- + # @note You can set the default encodings via the class. + # Read took two steroid shots: it can normalize your string, and encode. + # @return String + # -- + def read(*args, **kwd) + kwd[:encoding] ||= encoding + + if normalize[:read] + File.read(self, *args, kwd).encode({ + :universal_newline => true + }) + + else + File.read( + self, *args, kwd + ) + end + end + + # -- + # @note You can set the default encodings via the class. + # Binread took two steroid shots: it can normalize your string, and encode. + # @return String + # -- + def binread(*args, **kwd) + kwd[:encoding] ||= encoding + + if normalize[:read] + File.binread(self, *args, kwd).encode({ + :universal_newline => true + }) + + else + File.read( + self, *args, kwd + ) + end + end + + # -- + # @note You can set the default encodings via the class. + # Readlines took two steroid shots: it can normalize your string, and encode. + # @return Array + # -- + def readlines(*args, **kwd) + kwd[:encoding] ||= encoding + + if normalize[:read] + File.readlines(self, *args, kwd).encode({ + :universal_newline => true + }) + + else + File.readlines( + self, *args, kwd + ) + end + end + + # -- + # @note You can set the default encodings via the class. + # Write took two steroid shots: it can normalize your string, and encode. + # @return Fixnum + # -- + def write(data, *args, **kwd) + kwd[:encoding] ||= encoding + + if normalize[:write] + File.write(self, data.encode( + :crlf_newline => true + ), *args, kwd) + + else + File.write( + self, data, *args, kwd + ) + end + end + + # -- + # @note You can set the default encodings via the class. + # Binwrite took two steroid shots: it can normalize your string, and encode. + # @return Fixnum + # -- + def binwrite(data, *args, **kwd) + kwd[:encoding] ||= encoding + + if normalize[:write] + File.binwrite(self, data.encode( + :crlf_newline => true + ), *args, kwd) + + else + File.binwrite( + self, data, *args, kwd + ) + end + end + + # -- + def to_regexp(guard: true) + Regexp.new((guard ? "\\A" : "") + Regexp.escape( + self + )) + end + + # -- + # Strips the windows drive from the path. + # -- + def strip_windows_drive(path = @path) + self.class.new(path.gsub( + %r!\A[A-Za-z]:(?:\\+|/+)!, "" + )) + end + + # -- + # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + # -- + + def aggressive_cleanpath + return self.class.new("/") if root? + + _out = split_path.each_with_object([]) do |part, out| + next if part == "." || (part == ".." && out.last == "") + if part == ".." && out.last && out.last != ".." + out.pop + + else + out.push( + part + ) + end + end + + # -- + + return self.class.new("/") if _out == [""].freeze + return self.class.new(".") if _out.empty? && (end_with?(".") || relative?) + self.class.new(_out.join("/")) + end + + # -- + def conservative_cleanpath + _out = split_path.each_with_object([]) do |part, out| + next if part == "." || (part == ".." && out.last == "") + out.push( + part + ) + end + + # -- + + if !_out.empty? && basename == "." && _out.last != "" && _out.last != ".." + _out << "." + end + + # -- + + return self.class.new("/") if _out == [""].freeze + return self.class.new(".") if _out.empty? && (end_with?(".") || relative?) + return self.class.new(_out.join("/")).join("") if @path =~ %r!/\z! \ + && _out.last != "." && _out.last != ".." + self.class.new(_out.join("/")) + end + + # -- + # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity + # Expand the paths and return. + # -- + private + def expanded_paths(path) + return expand_path, self.class.new(path).expand_path + end + + # -- + # Safely copy a file. + # -- + private + def safe_copy_file(to, root: nil) + raise Errno::EPERM, "#{self} not in #{root}" unless in_path?(root) + FileUtils.cp(self, to, { + :preserve => true + }) + end + + # -- + # Safely copy a directory and it's sub-files. + # -- + private + def safe_copy_directory(to, root: nil, ignore: []) + ignore = [ignore].flatten.uniq + + if !in_path?(root) + raise Errno::EPERM, "#{self} not in #{ + root + }" + + else + to.mkdir_p unless to.exist? + children do |file| + unless ignore.any? { |path| file.in_path?(path) } + if !file.in_path?(root) + raise Errno::EPERM, "#{file} not in #{ + root + }" + + elsif file.file? + FileUtils.cp(file, to, { + :preserve => true + }) + + else + path = file.realpath + path.safe_copy(to.join(file.basename), { + :root => root, :ignore => ignore + }) + end + end + end + end + end + + class << self + attr_writer :encoding + + # -- + # @note We do nothing special here. + # Get the current directory that Ruby knows about. + # @return Pathutil + # -- + def pwd + new( + Dir.pwd + ) + end + + alias gcwd pwd + alias cwd pwd + + # -- + # @note you are encouraged to override this if you need to. + # Aliases the default system encoding to us so that we can do most read + # and write operations with that encoding, instead of being crazy. + # -- + def encoding + return @encoding ||= begin + Encoding.default_external + end + end + + # -- + # Normalize CRLF -> LF on Windows reads, to ease your troubles. + # Normalize LF -> CLRF on Windows write, to ease your troubles. + # -- + def normalize + return @normalize ||= { + :read => Gem.win_platform?, + :write => Gem.win_platform? + } + end + + # -- + # Make a temporary directory. + # @note if you adruptly exit it will not remove the dir. + # @note this directory is removed on exit. + # @return Pathutil + # -- + def tmpdir(*args) + rtn = new(make_tmpname(*args)).tap(&:mkdir) + ObjectSpace.define_finalizer(rtn, proc do + rtn.rm_rf + end) + + rtn + end + + # -- + # Make a temporary file. + # @note if you adruptly exit it will not remove the dir. + # @note this file is removed on exit. + # @return Pathutil + # -- + def tmpfile(*args) + rtn = new(make_tmpname(*args)).tap(&:touch) + ObjectSpace.define_finalizer(rtn, proc do + rtn.rm_rf + end) + + rtn + end + end + + # -- + + rb_delegate :gcwd, :to => :"self.class" + rb_delegate :pwd, :to => :"self.class" + + # -- + + rb_delegate :sub, :to => :@path, :wrap => true + rb_delegate :chomp, :to => :@path, :wrap => true + rb_delegate :gsub, :to => :@path, :wrap => true + rb_delegate :[], :to => :@path + rb_delegate :=~, :to => :@path + rb_delegate :==, :to => :@path + rb_delegate :to_s, :to => :@path + rb_delegate :freeze, :to => :@path + rb_delegate :end_with?, :to => :@path + rb_delegate :start_with?, :to => :@path + rb_delegate :frozen?, :to => :@path + rb_delegate :to_str, :to => :@path + rb_delegate :"!~", :to => :@path + rb_delegate :<=>, :to => :@path + + # -- + + rb_delegate :chmod, :to => :File, :args => { :after => :@path } + rb_delegate :lchown, :to => :File, :args => { :after => :@path } + rb_delegate :lchmod, :to => :File, :args => { :after => :@path } + rb_delegate :chown, :to => :File, :args => { :after => :@path } + rb_delegate :basename, :to => :File, :args => :@path, :wrap => true + rb_delegate :dirname, :to => :File, :args => :@path, :wrap => true + rb_delegate :readlink, :to => :File, :args => :@path, :wrap => true + rb_delegate :expand_path, :to => :File, :args => :@path, :wrap => true + rb_delegate :realdirpath, :to => :File, :args => :@path, :wrap => true + rb_delegate :realpath, :to => :File, :args => :@path, :wrap => true + rb_delegate :rename, :to => :File, :args => :@path, :wrap => true + rb_delegate :join, :to => :File, :args => :@path, :wrap => true + rb_delegate :empty?, :to => :file, :args => :@path + rb_delegate :size, :to => :File, :args => :@path + rb_delegate :link, :to => :File, :args => :@path + rb_delegate :atime, :to => :File, :args => :@path + rb_delegate :ctime, :to => :File, :args => :@path + rb_delegate :lstat, :to => :File, :args => :@path + rb_delegate :utime, :to => :File, :args => :@path + rb_delegate :sysopen, :to => :File, :args => :@path + rb_delegate :birthtime, :to => :File, :args => :@path + rb_delegate :mountpoint?, :to => :File, :args => :@path + rb_delegate :truncate, :to => :File, :args => :@path + rb_delegate :symlink, :to => :File, :args => :@path + rb_delegate :extname, :to => :File, :args => :@path + rb_delegate :zero?, :to => :File, :args => :@path + rb_delegate :ftype, :to => :File, :args => :@path + rb_delegate :mtime, :to => :File, :args => :@path + rb_delegate :open, :to => :File, :args => :@path + rb_delegate :stat, :to => :File, :args => :@path + + # -- + + rb_delegate :pipe?, :to => :FileTest, :args => :@path + rb_delegate :file?, :to => :FileTest, :args => :@path + rb_delegate :owned?, :to => :FileTest, :args => :@path + rb_delegate :setgid?, :to => :FileTest, :args => :@path + rb_delegate :socket?, :to => :FileTest, :args => :@path + rb_delegate :readable?, :to => :FileTest, :args => :@path + rb_delegate :blockdev?, :to => :FileTest, :args => :@path + rb_delegate :directory?, :to => :FileTest, :args => :@path + rb_delegate :readable_real?, :to => :FileTest, :args => :@path + rb_delegate :world_readable?, :to => :FileTest, :args => :@path + rb_delegate :executable_real?, :to => :FileTest, :args => :@path + rb_delegate :world_writable?, :to => :FileTest, :args => :@path + rb_delegate :writable_real?, :to => :FileTest, :args => :@path + rb_delegate :executable?, :to => :FileTest, :args => :@path + rb_delegate :writable?, :to => :FileTest, :args => :@path + rb_delegate :grpowned?, :to => :FileTest, :args => :@path + rb_delegate :chardev?, :to => :FileTest, :args => :@path + rb_delegate :symlink?, :to => :FileTest, :args => :@path + rb_delegate :sticky?, :to => :FileTest, :args => :@path + rb_delegate :setuid?, :to => :FileTest, :args => :@path + rb_delegate :exist?, :to => :FileTest, :args => :@path + rb_delegate :size?, :to => :FileTest, :args => :@path + + # -- + + rb_delegate :rm_rf, :to => :FileUtils, :args => :@path + rb_delegate :rm_r, :to => :FileUtils, :args => :@path + rb_delegate :rm_f, :to => :FileUtils, :args => :@path + rb_delegate :rm, :to => :FileUtils, :args => :@path + rb_delegate :cp_r, :to => :FileUtils, :args => :@path + rb_delegate :touch, :to => :FileUtils, :args => :@path + rb_delegate :mkdir_p, :to => :FileUtils, :args => :@path + rb_delegate :mkpath, :to => :FileUtils, :args => :@path + rb_delegate :cp, :to => :FileUtils, :args => :@path + + # -- + + rb_delegate :each_child, :to => :children + rb_delegate :each_entry, :to => :children + rb_delegate :to_a, :to => :children + + # -- + + rb_delegate :opendir, :to => :Dir, :alias_of => :open + rb_delegate :relative?, :to => :self, :alias_of => :absolute?, :bool => :reverse + rb_delegate :regexp_escape, :to => :Regexp, :args => :@path, :alias_of => :escape + rb_delegate :shellescape, :to => :Shellwords, :args => :@path + rb_delegate :mkdir, :to => :Dir, :args => :@path + + # -- + + alias + join + alias delete rm + alias rmtree rm_r + alias to_path to_s + alias last basename + alias entries children + alias make_symlink symlink + alias cleanpath_conservative conservative_cleanpath + alias cleanpath_aggressive aggressive_cleanpath + alias prepend enforce_root + alias fnmatch fnmatch? + alias make_link link + alias first dirname + alias rmdir rm_r + alias unlink rm + alias / join +end diff --git a/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil/helpers.rb b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil/helpers.rb new file mode 100644 index 0000000..7398008 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil/helpers.rb @@ -0,0 +1,129 @@ +# Frozen-string-literal: true +# Copyright: 2015 - 2017 Jordon Bedwell - MIT License +# Encoding: utf-8 + +class Pathutil + module Helpers + extend self + + # -- + + def allowed + return @allowed ||= begin + { + :yaml => { + :classes => [], + :symbols => [] + } + } + end + end + + # -- + # Wraps around YAML and SafeYAML to provide alternatives to Rubies. + # @note We default aliases to yes so we can detect if you explicit true. + # @return Hash + # -- + def load_yaml(data, safe: true, whitelist_classes: allowed[:yaml][:classes], \ + whitelist_symbols: allowed[:yaml][:symbols], aliases: :yes) + + require "yaml" + unless safe + return YAML.load( + data + ) + end + + if !YAML.respond_to?(:safe_load) + setup_safe_yaml whitelist_classes, aliases + SafeYAML.load( + data + ) + + else + YAML.safe_load( + data, + whitelist_classes, + whitelist_symbols, + aliases + ) + end + end + + # -- + # Make a temporary name suitable for temporary files and directories. + # @return String + # -- + def make_tmpname(prefix = "", suffix = nil, root = nil) + prefix = tmpname_prefix(prefix) + suffix = tmpname_suffix(suffix) + + root ||= Dir::Tmpname.tmpdir + File.join(root, __make_tmpname( + prefix, suffix + )) + end + + # -- + private + def __make_tmpname((prefix, suffix), number) + prefix &&= String.try_convert(prefix) || tmpname_agerr(:prefix, prefix) + suffix &&= String.try_convert(suffix) || tmpname_agerr(:suffix, suffix) + + time = Time.now.strftime("%Y%m%d") + path = "#{prefix}#{time}-#{$$}-#{rand(0x100000000).to_s(36)}".dup + path << "-#{number}" if number + path << suffix if suffix + path + end + + private + def tmpname_agerr(type, val) + raise ArgumentError, "unexpected #{type}: #{val.inspect}" + end + + # -- + private + def tmpname_suffix(suffix) + suffix = suffix.join("-") if suffix.is_a?(Array) + suffix = suffix.gsub(/\A\-/, "") unless !suffix || suffix.empty? + suffix + end + + # -- + # Cleanup the temp name prefix, joining if necessary. + # rubocop:disable Style/ParallelAssignment + # -- + private + def tmpname_prefix(prefix) + ext, prefix = prefix, "" if !prefix.is_a?(Array) && prefix.start_with?(".") + ext = prefix.pop if prefix.is_a?(Array) && prefix[-1].start_with?(".") + prefix = prefix.join("-") if prefix.is_a?(Array) + + unless prefix.empty? + prefix = prefix.gsub(/\-\Z/, "") \ + + "-" + end + + return [ + prefix, ext || "" + ] + end + + # -- + # Wrap around, cleanup, deprecate and use SafeYAML. + # rubocop:enable Style/ParallelAssignment + # -- + private + def setup_safe_yaml(whitelist_classes, aliases) + warn "WARN: SafeYAML does not support disabling of aliases." if aliases && aliases != :yes + warn "WARN: SafeYAML will be removed when Ruby 2.0 goes EOL." + require "safe_yaml/load" + + SafeYAML.restore_defaults! + whitelist_classes.map(&SafeYAML.method( + :whitelist_class! + )) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil/version.rb b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil/version.rb new file mode 100644 index 0000000..bfe223c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/pathutil-0.16.2/lib/pathutil/version.rb @@ -0,0 +1,7 @@ +# Frozen-string-literal: true +# Copyright: 2015 - 2017 Jordon Bedwell - MIT License +# Encoding: utf-8 + +class Pathutil + VERSION = "0.16.2" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/.yardopts b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/.yardopts new file mode 100644 index 0000000..0a782de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/.yardopts @@ -0,0 +1 @@ +--title 'Ruby Public Suffix API Documentation' diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/CHANGELOG.md b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/CHANGELOG.md new file mode 100644 index 0000000..99b68e8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/CHANGELOG.md @@ -0,0 +1,491 @@ +# Changelog + +This project uses [Semantic Versioning 2.0.0](https://semver.org/). + + +## 6.0.1 + +### Changed + +- Updated definitions. + + +## 6.0.0 + +Same as 5.1.0. Re-releasing as a major version change due to a major ruby version requirement change. + +### Changed + +- Updated definitions. +- Minimum Ruby version is 3.0 + + +## 5.1.1 + +No significant changes. Releasing a mini version to address 5.1.0 release with major ruby requirement change (GH-315). + + +## 5.1.0 + +### Changed + +- Updated definitions. +- Minimum Ruby version is 3.0 + + +## 5.0.5 + +### Changed + +- Updated definitions. + + +## 5.0.4 + +### Changed + +- Reduced .gem file size (GH-258). [Thanks @ybiquitous] +- Updated definitions. + + +## 5.0.3 + +### Fixed + +- Fixed automated release workflow. + + +## 5.0.2 + +### Changed + +- Updated definitions. + + +## 5.0.1 + +### Changed + +- Updated definitions. + + +## 5.0.0 + +### Changed + +- Minimum Ruby version is 2.6 +- Updated definitions. + + +## 4.0.7 + +### Fixes + +- Fixed YARD rake task (GH-179) + +### Changed + +- Updated definitions. + + +## 4.0.6 + +### Changed + +- Updated definitions. + + +## 4.0.5 + +### Changed + +- Updated definitions. + + +## 4.0.4 + +### Changed + +- Updated definitions. + + +## 4.0.3 + +### Fixed + +- Fixed 2.7 deprecations and warnings (GH-167). [Thanks @BrianHawley] + + +## 4.0.2 + +### Changed + +- Updated definitions. + + +## 4.0.1 + +### Changed + +- Updated definitions. + + +## 4.0.0 + +### Changed + +- Minimum Ruby version is 2.3 + + +## Release 3.1.1 + +- CHANGED: Updated definitions. +- CHANGED: Rolled back support for Ruby 2.3 (GH-161, GH-162) + +IMPORTANT: 3.x is the latest version compatible with Ruby 2.1 and Ruby 2.2. + + +## Release 3.1.0 + +- CHANGED: Updated definitions. +- CHANGED: Minimum Ruby version is 2.3 +- CHANGED: Upgraded to Bundler 2.x + + +## Release 3.0.3 + +- CHANGED: Updated definitions. + + +## Release 3.0.2 + +- CHANGED: Updated definitions. + + +## Release 3.0.1 + +- CHANGED: Updated definitions. +- CHANGED: Improve performance and avoid allocation (GH-146). [Thanks @robholland] + + +## Release 3.0.0 + +This new version includes a major redesign of the library internals, with the goal to drastically +improve the lookup time while reducing storage space. + +For this reason, several public methods that are no longer applicable have been deprecated +and/or removed. You can find more information at GH-133. + +- CHANGED: Updated definitions. +- CHANGED: Dropped support for Ruby < 2.1 +- CHANGED: `PublicSuffix::List#rules` is now protected. You should not rely on it as the internal rule representation is subject to change to optimize performances. +- CHANGED: Removed `PublicSuffix::List.clear`, it was an unnecessary accessor method. Use `PublicSuffix::List.default = nil` if you **really** need to reset the default list. You shouldn't. +- CHANGED: `PublicSuffix::List#select` is now private. You should not use it, instead use `PublicSuffix::List#find`. +- CHANGED: `PublicSuffix::List` no longer implements Enumerable. Instead, use `#each` to loop over, or get an Enumerator. +- CHANGED: Redesigned internal list storage and lookup algorithm to achieve O(1) lookup time (see GH-133). + + +## Release 2.0.5 + +- CHANGED: Updated definitions. +- CHANGED: Initialization performance improvements (GH-128). [Thanks @casperisfine] + + +## Release 2.0.4 + +- FIXED: Fix a bug that caused the GEM to be published with the wrong version number in the gemspec (GH-121). + +- CHANGED: Updated definitions. + + +## Release 2.0.3 + +- CHANGED: Updated definitions. + + +## Release 2.0.2 + +- CHANGED: Updated definitions. + + +## Release 2.0.1 + +- FIXED: Fix bug that prevented .valid? to reset the default rule + + +## Release 2.0.0 + +- NEW: Added PublicSuffix.domain # => sld.tld +- NEW: Added the ability to disable the use of private domains either at runtime, in addition to the ability to not load the private domains section when reading the list (`private_domains: false`). This feature also superseded the `private_domains` class-level attribute, that is no longer available. + +- CHANGED: Considerable performance improvements (GH-92) +- CHANGED: Updated definitions. +- CHANGED: Removed deprecated PublicSuffix::InvalidDomain exception +- CHANGED: If the suffix is now listed, then the prevaling rule is "*" as defined by the PSL algorithm (GH-91) +- CHANGED: Input validation is performed only if you call `PublicSuffix.parse` or `PublicSuffix.list` +- CHANGED: Input with leading dot is invalid per PSL acceptance tests +- CHANGED: Removed `private_domains` class-level attribute. It is replaced by the `private_domains: false` option in the list parse method. +- CHANGED: The default list now assumes you use UTF-8 for reading the input (GH-94), + +- REMOVED: Removed futile utility helpers such as `Domain#rule`, `Domain#is_a_domain?`, `Domain#is_a_subdomain?`, `Domain#valid?`. You can easily obtain the same result by having a custom method that reconstructs the logic, and/or calling `PublicSuffix.{domain|parse}(domain.to_s)`. + + +## Release 1.5.3 + +- FIXED: Don't duplicate rule indices when creating index (GH-77). [Thanks @ags] + +- CHANGED: Updated definitions. + + +## Release 1.5.2 + +- CHANGED: Updated definitions. + + +## Release 1.5.1 + +- FIXED: Ignore case for parsing and validating (GH-62) + +- CHANGED: Updated definitions. + + +## Release 1.5.0 + +- CHANGED: Dropped support for Ruby < 2.0 + +- CHANGED: Updated definitions. + + +## Release 1.4.6 + +- CHANGED: Updated definitions. + + +## Release 1.4.5 + +- CHANGED: Updated definitions. + + +## Release 1.4.4 + +- CHANGED: Updated definitions. + + +## Release 1.4.3 + +- CHANGED: Updated definitions. + + +## Release 1.4.2 + +- CHANGED: Updated definitions. + + +## Release 1.4.1 + +- CHANGED: Updated definitions. + + +## Release 1.4.0 + +- CHANGED: Moved the definitions in the lib folder. + +- CHANGED: Updated definitions. + + +## Release 1.3.3 + +- CHANGED: Updated definitions. + + +## Release 1.3.2 + +- CHANGED: Updated definitions. + + +## Release 1.3.1 + +- CHANGED: Updated definitions. + + +## Release 1.3.0 + +- NEW: Ability to skip Private Domains (GH-28). [Thanks @rb2k] + +- CHANGED: Updated definitions. + + +## Release 1.2.1 + +- CHANGED: Updated definitions. + + +## Release 1.2.0 + +- NEW: Allow a custom List on `PublicSuffix.parse` (GH-26). [Thanks @itspriddle] + +- FIXED: PublicSuffix.parse and PublicSuffix.valid? crashes when input is nil (GH-20). + +- CHANGED: Updated definitions. + + +## Release 1.1.3 + +- CHANGED: Updated definitions. + + +## Release 1.1.2 + +- CHANGED: Updated definitions. + + +## Release 1.1.1 + +- CHANGED: Updated definitions. + + +## Release 1.1.0 + +- FIXED: #valid? and #parse consider URIs as valid domains (GH-15) + +- CHANGED: Updated definitions. + +- CHANGED: Removed deprecatd PublicSuffixService::RuleList. + + +## Release 1.0.0 + +- CHANGED: Updated definitions. + + +## Release 1.0.0.rc1 + +The library is now known as PublicSuffix. + + +## Release 0.9.1 + +- CHANGED: Renamed PublicSuffixService::RuleList to PublicSuffixService::List. + +- CHANGED: Renamed PublicSuffixService::List#list to PublicSuffixService::List#rules. + +- CHANGED: Renamed PublicSuffixService to PublicSuffix. + +- CHANGED: Updated definitions. + + +## Release 0.9.0 + +- CHANGED: Minimum Ruby version increased to Ruby 1.8.7. + +- CHANGED: rake/gempackagetask is deprecated. Use rubygems/package_task instead. + + +## Release 0.8.4 + +- FIXED: Reverted bugfix for issue #12 for Ruby 1.8.6. + This is the latest version compatible with Ruby 1.8.6. + + +## Release 0.8.3 + +- FIXED: Fixed ArgumentError: invalid byte sequence in US-ASCII with Ruby 1.9.2 (#12). + +- CHANGED: Updated definitions (#11). + +- CHANGED: Renamed definitions.txt to definitions.dat. + + +## Release 0.8.2 + +- NEW: Added support for rubygems-test. + +- CHANGED: Integrated Bundler. + +- CHANGED: Updated definitions. + + +## Release 0.8.1 + +- FIXED: The files in the release 0.8.0 have wrong permission 600 and can't be loaded (#10). + + +## Release 0.8.0 + +- CHANGED: Update public suffix list to d1a5599b49fa 2010-10-25 15:10 +0100 (#9) + +- NEW: Add support for Fully Qualified Domain Names (#7) + + +## Release 0.7.0 + +- CHANGED: Using YARD to document the code instead of RDoc. + +- FIXED: RuleList cache is not recreated when a new rule is appended to the list (#6) + +- FIXED: PublicSuffixService.valid? should return false if the domain is not defined or not allowed (#4, #5) + + +## Release 0.6.0 + +- NEW: PublicSuffixService.parse raises DomainNotAllowed when trying to parse a domain name + which exists, but is not allowed by the current definition list (#3) + + PublicSuffixService.parse("nic.do") + # => PublicSuffixService::DomainNotAllowed + +- CHANGED: Renamed PublicSuffixService::InvalidDomain to PublicSuffixService::DomainInvalid + + +## Release 0.5.2 + +- CHANGED: Update public suffix list to 248ea690d671 2010-09-16 18:02 +0100 + + +## Release 0.5.1 + +- CHANGED: Update public suffix list to 14dc66dd53c1 2010-09-15 17:09 +0100 + + +## Release 0.5.0 + +- CHANGED: Improve documentation for Domain#domain and Domain#subdomain (#1). + +- CHANGED: Performance improvements (#2). + + +## Release 0.4.0 + +- CHANGED: Rename library from DomainName to PublicSuffixService to reduce the probability of name conflicts. + + +## Release 0.3.1 + +- Deprecated DomainName library. + + +## Release 0.3.0 + +- CHANGED: DomainName#domain and DomainName#subdomain are no longer alias of Domain#sld and Domain#tld. + +- CHANGED: Removed DomainName#labels and decoupled Rule from DomainName. + +- CHANGED: DomainName#valid? no longer instantiates new DomainName objects. This means less overhead. + +- CHANGED: Refactoring the entire DomainName API. Removed the internal on-the-fly parsing. Added a bunch of new methods to check and validate the DomainName. + + +## Release 0.2.0 + +- NEW: DomainName#valid? + +- NEW: DomainName#parse and DomainName#parse! + +- NEW: DomainName#valid_domain? and DomainName#valid_subdomain? + +- CHANGED: Make sure RuleList lookup is only performed once. + + +## Release 0.1.0 + +- Initial version diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/LICENSE.txt new file mode 100644 index 0000000..32b1ac8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2009-2024 Simone Carletti + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/README.md b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/README.md new file mode 100644 index 0000000..46e7759 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/README.md @@ -0,0 +1,222 @@ +# Public Suffix for Ruby + +PublicSuffix is a Ruby domain name parser based on the [Public Suffix List](https://publicsuffix.org/). + +[![Build Status](https://github.com/weppos/publicsuffix-ruby/actions/workflows/tests.yml/badge.svg)](https://github.com/weppos/publicsuffix-ruby/actions/workflows/tests.yml) +[![Tidelift dependencies](https://tidelift.com/badges/package/rubygems/public_suffix)](https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix&utm_medium=referral&utm_campaign=enterprise) + + +## Links + +- [Homepage](https://simonecarletti.com/code/publicsuffix-ruby) +- [Repository](https://github.com/weppos/publicsuffix-ruby) +- [API Documentation](https://rubydoc.info/gems/public_suffix) +- [Introducing the Public Suffix List library for Ruby](https://simonecarletti.com/blog/2010/06/public-suffix-list-library-for-ruby/) + + +## Requirements + +PublicSuffix requires **Ruby >= 3.0**. For an older versions of Ruby use a previous release. + + +## Installation + +You can install the gem manually: + +```shell +gem install public_suffix +``` + +Or use Bundler and define it as a dependency in your `Gemfile`: + +```ruby +gem 'public_suffix' +``` + +## Usage + +Extract the domain out from a name: + +```ruby +PublicSuffix.domain("google.com") +# => "google.com" +PublicSuffix.domain("www.google.com") +# => "google.com" +PublicSuffix.domain("www.google.co.uk") +# => "google.co.uk" +``` + +Parse a domain without subdomains: + +```ruby +domain = PublicSuffix.parse("google.com") +# => # +domain.tld +# => "com" +domain.sld +# => "google" +domain.trd +# => nil +domain.domain +# => "google.com" +domain.subdomain +# => nil +``` + +Parse a domain with subdomains: + +```ruby +domain = PublicSuffix.parse("www.google.com") +# => # +domain.tld +# => "com" +domain.sld +# => "google" +domain.trd +# => "www" +domain.domain +# => "google.com" +domain.subdomain +# => "www.google.com" +``` + +Simple validation example: + +```ruby +PublicSuffix.valid?("google.com") +# => true + +PublicSuffix.valid?("www.google.com") +# => true + +# Explicitly forbidden, it is listed as a private domain +PublicSuffix.valid?("blogspot.com") +# => false + +# Unknown/not-listed TLD domains are valid by default +PublicSuffix.valid?("example.tldnotlisted") +# => true +``` + +Strict validation (without applying the default * rule): + +```ruby +PublicSuffix.valid?("example.tldnotlisted", default_rule: nil) +# => false +``` + + +## Fully Qualified Domain Names + +This library automatically recognizes Fully Qualified Domain Names. A FQDN is a domain name that end with a trailing dot. + +```ruby +# Parse a standard domain name +PublicSuffix.domain("www.google.com") +# => "google.com" + +# Parse a fully qualified domain name +PublicSuffix.domain("www.google.com.") +# => "google.com" +``` + +## Private domains + +This library has support for switching off support for private (non-ICANN). + +```ruby +# Extract a domain including private domains (by default) +PublicSuffix.domain("something.blogspot.com") +# => "something.blogspot.com" + +# Extract a domain excluding private domains +PublicSuffix.domain("something.blogspot.com", ignore_private: true) +# => "blogspot.com" + +# It also works for #parse and #valid? +PublicSuffix.parse("something.blogspot.com", ignore_private: true) +PublicSuffix.valid?("something.blogspot.com", ignore_private: true) +``` + +If you don't care about private domains at all, it's more efficient to exclude them when the list is parsed: + +```ruby +# Disable support for private TLDs +PublicSuffix::List.default = PublicSuffix::List.parse(File.read(PublicSuffix::List::DEFAULT_LIST_PATH), private_domains: false) +# => "blogspot.com" +PublicSuffix.domain("something.blogspot.com") +# => "blogspot.com" +``` + +## Add domain to list + +If you want to manually add a domain to the list just run: + +```ruby +PublicSuffix::List.default << PublicSuffix::Rule.factory('onmicrosoft.com') +``` + +## What is the Public Suffix List? + +The [Public Suffix List](https://publicsuffix.org) is a cross-vendor initiative to provide an accurate list of domain name suffixes. + +The Public Suffix List is an initiative of the Mozilla Project, but is maintained as a community resource. It is available for use in any software, but was originally created to meet the needs of browser manufacturers. + +A "public suffix" is one under which Internet users can directly register names. Some examples of public suffixes are ".com", ".co.uk" and "pvt.k12.wy.us". The Public Suffix List is a list of all known public suffixes. + + +## Why the Public Suffix List is better than any available Regular Expression parser? + +Previously, browsers used an algorithm which basically only denied setting wide-ranging cookies for top-level domains with no dots (e.g. com or org). However, this did not work for top-level domains where only third-level registrations are allowed (e.g. co.uk). In these cases, websites could set a cookie for co.uk which will be passed onto every website registered under co.uk. + +Clearly, this was a security risk as it allowed websites other than the one setting the cookie to read it, and therefore potentially extract sensitive information. + +Since there is no algorithmic method of finding the highest level at which a domain may be registered for a particular top-level domain (the policies differ with each registry), the only method is to create a list of all top-level domains and the level at which domains can be registered. This is the aim of the effective TLD list. + +As well as being used to prevent cookies from being set where they shouldn't be, the list can also potentially be used for other applications where the registry controlled and privately controlled parts of a domain name need to be known, for example when grouping by top-level domains. + +Source: https://wiki.mozilla.org/Public_Suffix_List + +Not convinced yet? Check out [this real world example](https://stackoverflow.com/q/288810/123527). + + +## Does PublicSuffix make requests to Public Suffix List website? + +No. PublicSuffix comes with a bundled list. It does not make any HTTP requests to parse or validate a domain. + + +## Support + +Library documentation is auto-generated from the [README](https://github.com/weppos/publicsuffix-ruby/blob/master/README.md) and the source code, and it's available at https://rubydoc.info/gems/public_suffix. + +- The PublicSuffix bug tracker is here: https://github.com/weppos/publicsuffix-ruby/issues +- The PublicSuffix code repository is here: https://github.com/weppos/publicsuffix-ruby. Contributions are welcome! Please include tests and/or feature coverage for every patch, and create a topic branch for every separate change you make. + +[Consider subscribing to Tidelift which provides Enterprise support for this project](https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix&utm_medium=referral&utm_campaign=readme) as part of the Tidelift Subscription. Tidelift subscriptions also help the maintainers by funding the project, which in turn allows us to ship releases, bugfixes, and security updates more often. + + +## Security and Vulnerability Reporting + +Full information and description of our security policy please visit [`SECURITY.md`](SECURITY.md) + + +## Changelog + +See the [CHANGELOG.md](CHANGELOG.md) file for details. + + +## License + +Copyright (c) 2009-2024 Simone Carletti. This is Free Software distributed under the MIT license. + +The [Public Suffix List source](https://publicsuffix.org/list/) is subject to the terms of the Mozilla Public License, v. 2.0. + +## Definitions + +tld = Top level domain, this is in reference to the last segment of a domain, sometimes the part that is directly after the "dot" symbol. For example, `mozilla.org`, the `.org` portion is the tld. + +sld = Second level domain, a domain that is directly below a top-level domain. For example, in `https://www.mozilla.org/en-US/`, `mozilla` is the second-level domain of the .org tld. + +trd = Transit routing domain, or known as a subdomain. This is the part of the domain that is before the sld or root domain. For example, in `https://www.mozilla.org/en-US/`, `www` is the trd. + +FQDN = Fully Qualified Domain Names, are domain names that are written with the hostname and the domain name, and include the top-level domain, the format looks like `[hostname].[domain].[tld].` for ex. `[www].[mozilla].[org]`. diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/SECURITY.md b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/SECURITY.md new file mode 100644 index 0000000..da6e619 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/SECURITY.md @@ -0,0 +1,24 @@ +# Security Policy + +## Supported Versions + +Security updates are provided only for the current minor version. + +If you are using a previous minor version, we recommend to upgrade to the current minor version. This project uses [semantic versioning](https://semver.org/), therefore you can upgrade to a more recent minor version without incurring into breaking changes. + +Exceptionally, we may support previous minor versions upon request if there are significant reasons preventing to immediately switch the latest minor version. + +Older major versions are no longer supported. + + +## Reporting a Vulnerability + +To make a report, please email weppos@weppos.net. + +> [!IMPORTANT] +> Please consider encrypting your report with GPG using the key [0x420da82a989398df](https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x420da82a989398df). + + +## Tracking Security Updates + +Information about security vulnerabilities are published in the [Security Advisories](https://github.com/weppos/publicsuffix-ruby/security/advisories) page. diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/data/list.txt b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/data/list.txt new file mode 100644 index 0000000..0fac662 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/data/list.txt @@ -0,0 +1,15843 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Please pull this list from, and only from https://publicsuffix.org/list/public_suffix_list.dat, +// rather than any other VCS sites. Pulling from any other URL is not guaranteed to be supported. + +// Instructions on pulling and using this list can be found at https://publicsuffix.org/list/. + +// ===BEGIN ICANN DOMAINS=== + +// ac : http://nic.ac/rules.htm +ac +com.ac +edu.ac +gov.ac +net.ac +mil.ac +org.ac + +// ad : https://en.wikipedia.org/wiki/.ad +ad +nom.ad + +// ae : https://tdra.gov.ae/en/aeda/ae-policies +ae +co.ae +net.ae +org.ae +sch.ae +ac.ae +gov.ae +mil.ae + +// aero : https://information.aero/registration/policies/dmp +aero +// 2LDs +airline.aero +airport.aero +// 2LDs (currently not accepting registration, seemingly never have) +// As of 2024-07, these are marked as reserved for potential 3LD +// registrations (clause 11 "allocated subdomains" in the 2006 TLD +// policy), but the relevant industry partners have not opened them up +// for registration. Current status can be determined from the TLD's +// policy document: 2LDs that are open for registration must list +// their policy in the TLD's policy. Any 2LD without such a policy is +// not open for registrations. +accident-investigation.aero +accident-prevention.aero +aerobatic.aero +aeroclub.aero +aerodrome.aero +agents.aero +air-surveillance.aero +air-traffic-control.aero +aircraft.aero +airtraffic.aero +ambulance.aero +association.aero +author.aero +ballooning.aero +broker.aero +caa.aero +cargo.aero +catering.aero +certification.aero +championship.aero +charter.aero +civilaviation.aero +club.aero +conference.aero +consultant.aero +consulting.aero +control.aero +council.aero +crew.aero +design.aero +dgca.aero +educator.aero +emergency.aero +engine.aero +engineer.aero +entertainment.aero +equipment.aero +exchange.aero +express.aero +federation.aero +flight.aero +freight.aero +fuel.aero +gliding.aero +government.aero +groundhandling.aero +group.aero +hanggliding.aero +homebuilt.aero +insurance.aero +journal.aero +journalist.aero +leasing.aero +logistics.aero +magazine.aero +maintenance.aero +marketplace.aero +media.aero +microlight.aero +modelling.aero +navigation.aero +parachuting.aero +paragliding.aero +passenger-association.aero +pilot.aero +press.aero +production.aero +recreation.aero +repbody.aero +res.aero +research.aero +rotorcraft.aero +safety.aero +scientist.aero +services.aero +show.aero +skydiving.aero +software.aero +student.aero +taxi.aero +trader.aero +trading.aero +trainer.aero +union.aero +workinggroup.aero +works.aero + +// af : http://www.nic.af/help.jsp +af +gov.af +com.af +org.af +net.af +edu.af + +// ag : http://www.nic.ag/prices.htm +ag +com.ag +org.ag +net.ag +co.ag +nom.ag + +// ai : http://nic.com.ai/ +ai +off.ai +com.ai +net.ai +org.ai + +// al : http://www.ert.gov.al/ert_alb/faq_det.html?Id=31 +al +com.al +edu.al +gov.al +mil.al +net.al +org.al + +// am : https://www.amnic.net/policy/en/Policy_EN.pdf +am +co.am +com.am +commune.am +net.am +org.am + +// ao : https://en.wikipedia.org/wiki/.ao +// http://www.dns.ao/REGISTR.DOC +ao +ed.ao +gv.ao +og.ao +co.ao +pb.ao +it.ao + +// aq : https://en.wikipedia.org/wiki/.aq +aq + +// ar : https://nic.ar/es/nic-argentina/normativa +ar +bet.ar +com.ar +coop.ar +edu.ar +gob.ar +gov.ar +int.ar +mil.ar +musica.ar +mutual.ar +net.ar +org.ar +senasa.ar +tur.ar + +// arpa : https://en.wikipedia.org/wiki/.arpa +// Confirmed by registry 2008-06-18 +arpa +e164.arpa +in-addr.arpa +ip6.arpa +iris.arpa +uri.arpa +urn.arpa + +// as : https://en.wikipedia.org/wiki/.as +as +gov.as + +// asia : https://en.wikipedia.org/wiki/.asia +asia + +// at : https://en.wikipedia.org/wiki/.at +// Confirmed by registry 2008-06-17 +at +ac.at +co.at +gv.at +or.at +sth.ac.at + +// au : https://en.wikipedia.org/wiki/.au +// http://www.auda.org.au/ +au +// 2LDs +com.au +net.au +org.au +edu.au +gov.au +asn.au +id.au +// Historic 2LDs (closed to new registration, but sites still exist) +info.au +conf.au +oz.au +// CGDNs - http://www.cgdn.org.au/ +act.au +nsw.au +nt.au +qld.au +sa.au +tas.au +vic.au +wa.au +// 3LDs +act.edu.au +catholic.edu.au +// eq.edu.au - Removed at the request of the Queensland Department of Education +nsw.edu.au +nt.edu.au +qld.edu.au +sa.edu.au +tas.edu.au +vic.edu.au +wa.edu.au +// act.gov.au Bug 984824 - Removed at request of Greg Tankard +// nsw.gov.au Bug 547985 - Removed at request of +// nt.gov.au Bug 940478 - Removed at request of Greg Connors +qld.gov.au +sa.gov.au +tas.gov.au +vic.gov.au +wa.gov.au +// 4LDs +// education.tas.edu.au - Removed at the request of the Department of Education Tasmania +schools.nsw.edu.au + +// aw : https://en.wikipedia.org/wiki/.aw +aw +com.aw + +// ax : https://en.wikipedia.org/wiki/.ax +ax + +// az : https://en.wikipedia.org/wiki/.az +az +com.az +net.az +int.az +gov.az +org.az +edu.az +info.az +pp.az +mil.az +name.az +pro.az +biz.az + +// ba : http://nic.ba/users_data/files/pravilnik_o_registraciji.pdf +ba +com.ba +edu.ba +gov.ba +mil.ba +net.ba +org.ba + +// bb : https://en.wikipedia.org/wiki/.bb +bb +biz.bb +co.bb +com.bb +edu.bb +gov.bb +info.bb +net.bb +org.bb +store.bb +tv.bb + +// bd : https://en.wikipedia.org/wiki/.bd +*.bd + +// be : https://en.wikipedia.org/wiki/.be +// Confirmed by registry 2008-06-08 +be +ac.be + +// bf : https://en.wikipedia.org/wiki/.bf +bf +gov.bf + +// bg : https://en.wikipedia.org/wiki/.bg +// https://www.register.bg/user/static/rules/en/index.html +bg +a.bg +b.bg +c.bg +d.bg +e.bg +f.bg +g.bg +h.bg +i.bg +j.bg +k.bg +l.bg +m.bg +n.bg +o.bg +p.bg +q.bg +r.bg +s.bg +t.bg +u.bg +v.bg +w.bg +x.bg +y.bg +z.bg +0.bg +1.bg +2.bg +3.bg +4.bg +5.bg +6.bg +7.bg +8.bg +9.bg + +// bh : https://en.wikipedia.org/wiki/.bh +bh +com.bh +edu.bh +net.bh +org.bh +gov.bh + +// bi : https://en.wikipedia.org/wiki/.bi +// http://whois.nic.bi/ +bi +co.bi +com.bi +edu.bi +or.bi +org.bi + +// biz : https://en.wikipedia.org/wiki/.biz +biz + +// bj : https://nic.bj/bj-suffixes.txt +// submitted by registry +bj +africa.bj +agro.bj +architectes.bj +assur.bj +avocats.bj +co.bj +com.bj +eco.bj +econo.bj +edu.bj +info.bj +loisirs.bj +money.bj +net.bj +org.bj +ote.bj +resto.bj +restaurant.bj +tourism.bj +univ.bj + +// bm : http://www.bermudanic.bm/dnr-text.txt +bm +com.bm +edu.bm +gov.bm +net.bm +org.bm + +// bn : http://www.bnnic.bn/faqs +bn +com.bn +edu.bn +gov.bn +net.bn +org.bn + +// bo : https://nic.bo/delegacion2015.php#h-1.10 +bo +com.bo +edu.bo +gob.bo +int.bo +org.bo +net.bo +mil.bo +tv.bo +web.bo +// Social Domains +academia.bo +agro.bo +arte.bo +blog.bo +bolivia.bo +ciencia.bo +cooperativa.bo +democracia.bo +deporte.bo +ecologia.bo +economia.bo +empresa.bo +indigena.bo +industria.bo +info.bo +medicina.bo +movimiento.bo +musica.bo +natural.bo +nombre.bo +noticias.bo +patria.bo +politica.bo +profesional.bo +plurinacional.bo +pueblo.bo +revista.bo +salud.bo +tecnologia.bo +tksat.bo +transporte.bo +wiki.bo + +// br : http://registro.br/dominio/categoria.html +// Submitted by registry +br +9guacu.br +abc.br +adm.br +adv.br +agr.br +aju.br +am.br +anani.br +aparecida.br +app.br +arq.br +art.br +ato.br +b.br +barueri.br +belem.br +bhz.br +bib.br +bio.br +blog.br +bmd.br +boavista.br +bsb.br +campinagrande.br +campinas.br +caxias.br +cim.br +cng.br +cnt.br +com.br +contagem.br +coop.br +coz.br +cri.br +cuiaba.br +curitiba.br +def.br +des.br +det.br +dev.br +ecn.br +eco.br +edu.br +emp.br +enf.br +eng.br +esp.br +etc.br +eti.br +far.br +feira.br +flog.br +floripa.br +fm.br +fnd.br +fortal.br +fot.br +foz.br +fst.br +g12.br +geo.br +ggf.br +goiania.br +gov.br +// gov.br 26 states + df https://en.wikipedia.org/wiki/States_of_Brazil +ac.gov.br +al.gov.br +am.gov.br +ap.gov.br +ba.gov.br +ce.gov.br +df.gov.br +es.gov.br +go.gov.br +ma.gov.br +mg.gov.br +ms.gov.br +mt.gov.br +pa.gov.br +pb.gov.br +pe.gov.br +pi.gov.br +pr.gov.br +rj.gov.br +rn.gov.br +ro.gov.br +rr.gov.br +rs.gov.br +sc.gov.br +se.gov.br +sp.gov.br +to.gov.br +gru.br +imb.br +ind.br +inf.br +jab.br +jampa.br +jdf.br +joinville.br +jor.br +jus.br +leg.br +lel.br +log.br +londrina.br +macapa.br +maceio.br +manaus.br +maringa.br +mat.br +med.br +mil.br +morena.br +mp.br +mus.br +natal.br +net.br +niteroi.br +*.nom.br +not.br +ntr.br +odo.br +ong.br +org.br +osasco.br +palmas.br +poa.br +ppg.br +pro.br +psc.br +psi.br +pvh.br +qsl.br +radio.br +rec.br +recife.br +rep.br +ribeirao.br +rio.br +riobranco.br +riopreto.br +salvador.br +sampa.br +santamaria.br +santoandre.br +saobernardo.br +saogonca.br +seg.br +sjc.br +slg.br +slz.br +sorocaba.br +srv.br +taxi.br +tc.br +tec.br +teo.br +the.br +tmp.br +trd.br +tur.br +tv.br +udi.br +vet.br +vix.br +vlog.br +wiki.br +zlg.br + +// bs : http://www.nic.bs/rules.html +bs +com.bs +net.bs +org.bs +edu.bs +gov.bs + +// bt : https://en.wikipedia.org/wiki/.bt +bt +com.bt +edu.bt +gov.bt +net.bt +org.bt + +// bv : No registrations at this time. +// Submitted by registry +bv + +// bw : https://en.wikipedia.org/wiki/.bw +// http://www.gobin.info/domainname/bw.doc +// list of other 2nd level tlds ? +bw +co.bw +org.bw + +// by : https://en.wikipedia.org/wiki/.by +// http://tld.by/rules_2006_en.html +// list of other 2nd level tlds ? +by +gov.by +mil.by +// Official information does not indicate that com.by is a reserved +// second-level domain, but it's being used as one (see www.google.com.by and +// www.yahoo.com.by, for example), so we list it here for safety's sake. +com.by +// http://hoster.by/ +of.by + +// bz : https://en.wikipedia.org/wiki/.bz +// http://www.belizenic.bz/ +bz +com.bz +net.bz +org.bz +edu.bz +gov.bz + +// ca : https://en.wikipedia.org/wiki/.ca +ca +// ca geographical names +ab.ca +bc.ca +mb.ca +nb.ca +nf.ca +nl.ca +ns.ca +nt.ca +nu.ca +on.ca +pe.ca +qc.ca +sk.ca +yk.ca +// gc.ca: https://en.wikipedia.org/wiki/.gc.ca +// see also: http://registry.gc.ca/en/SubdomainFAQ +gc.ca + +// cat : https://en.wikipedia.org/wiki/.cat +cat + +// cc : https://en.wikipedia.org/wiki/.cc +cc + +// cd : https://en.wikipedia.org/wiki/.cd +// see also: https://www.nic.cd/domain/insertDomain_2.jsp?act=1 +cd +gov.cd + +// cf : https://en.wikipedia.org/wiki/.cf +cf + +// cg : https://en.wikipedia.org/wiki/.cg +cg + +// ch : https://en.wikipedia.org/wiki/.ch +ch + +// ci : https://en.wikipedia.org/wiki/.ci +// http://www.nic.ci/index.php?page=charte +ci +org.ci +or.ci +com.ci +co.ci +edu.ci +ed.ci +ac.ci +net.ci +go.ci +asso.ci +aéroport.ci +int.ci +presse.ci +md.ci +gouv.ci + +// ck : https://en.wikipedia.org/wiki/.ck +*.ck +!www.ck + +// cl : https://www.nic.cl +// Confirmed by .CL registry +cl +co.cl +gob.cl +gov.cl +mil.cl + +// cm : https://en.wikipedia.org/wiki/.cm plus bug 981927 +cm +co.cm +com.cm +gov.cm +net.cm + +// cn : https://en.wikipedia.org/wiki/.cn +// Submitted by registry +cn +ac.cn +com.cn +edu.cn +gov.cn +net.cn +org.cn +mil.cn +公司.cn +网络.cn +網絡.cn +// cn geographic names +ah.cn +bj.cn +cq.cn +fj.cn +gd.cn +gs.cn +gz.cn +gx.cn +ha.cn +hb.cn +he.cn +hi.cn +hl.cn +hn.cn +jl.cn +js.cn +jx.cn +ln.cn +nm.cn +nx.cn +qh.cn +sc.cn +sd.cn +sh.cn +sn.cn +sx.cn +tj.cn +xj.cn +xz.cn +yn.cn +zj.cn +hk.cn +mo.cn +tw.cn + +// co : https://en.wikipedia.org/wiki/.co +// Submitted by registry +co +arts.co +com.co +edu.co +firm.co +gov.co +info.co +int.co +mil.co +net.co +nom.co +org.co +rec.co +web.co + +// com : https://en.wikipedia.org/wiki/.com +com + +// coop : https://en.wikipedia.org/wiki/.coop +coop + +// cr : http://www.nic.cr/niccr_publico/showRegistroDominiosScreen.do +cr +ac.cr +co.cr +ed.cr +fi.cr +go.cr +or.cr +sa.cr + +// cu : https://en.wikipedia.org/wiki/.cu +cu +com.cu +edu.cu +org.cu +net.cu +gov.cu +inf.cu + +// cv : https://en.wikipedia.org/wiki/.cv +// cv : http://www.dns.cv/tldcv_portal/do?com=DS;5446457100;111;+PAGE(4000018)+K-CAT-CODIGO(RDOM)+RCNT(100); <- registration rules +cv +com.cv +edu.cv +int.cv +nome.cv +org.cv + +// cw : http://www.una.cw/cw_registry/ +// Confirmed by registry 2013-03-26 +cw +com.cw +edu.cw +net.cw +org.cw + +// cx : https://en.wikipedia.org/wiki/.cx +// list of other 2nd level tlds ? +cx +gov.cx + +// cy : http://www.nic.cy/ +// Submitted by registry Panayiotou Fotia +// namespace policies URL https://www.nic.cy/portal//sites/default/files/symfonia_gia_eggrafi.pdf +cy +ac.cy +biz.cy +com.cy +ekloges.cy +gov.cy +ltd.cy +mil.cy +net.cy +org.cy +press.cy +pro.cy +tm.cy + +// cz : https://en.wikipedia.org/wiki/.cz +cz + +// de : https://en.wikipedia.org/wiki/.de +// Confirmed by registry (with technical +// reservations) 2008-07-01 +de + +// dj : https://en.wikipedia.org/wiki/.dj +dj + +// dk : https://en.wikipedia.org/wiki/.dk +// Confirmed by registry 2008-06-17 +dk + +// dm : https://en.wikipedia.org/wiki/.dm +dm +com.dm +net.dm +org.dm +edu.dm +gov.dm + +// do : https://en.wikipedia.org/wiki/.do +do +art.do +com.do +edu.do +gob.do +gov.do +mil.do +net.do +org.do +sld.do +web.do + +// dz : http://www.nic.dz/images/pdf_nic/charte.pdf +dz +art.dz +asso.dz +com.dz +edu.dz +gov.dz +org.dz +net.dz +pol.dz +soc.dz +tm.dz + +// ec : http://www.nic.ec/reg/paso1.asp +// Submitted by registry +ec +com.ec +info.ec +net.ec +fin.ec +k12.ec +med.ec +pro.ec +org.ec +edu.ec +gov.ec +gob.ec +mil.ec + +// edu : https://en.wikipedia.org/wiki/.edu +edu + +// ee : http://www.eenet.ee/EENet/dom_reeglid.html#lisa_B +ee +edu.ee +gov.ee +riik.ee +lib.ee +med.ee +com.ee +pri.ee +aip.ee +org.ee +fie.ee + +// eg : https://en.wikipedia.org/wiki/.eg +eg +com.eg +edu.eg +eun.eg +gov.eg +mil.eg +name.eg +net.eg +org.eg +sci.eg + +// er : https://en.wikipedia.org/wiki/.er +*.er + +// es : https://www.nic.es/site_ingles/ingles/dominios/index.html +es +com.es +nom.es +org.es +gob.es +edu.es + +// et : https://en.wikipedia.org/wiki/.et +et +com.et +gov.et +org.et +edu.et +biz.et +name.et +info.et +net.et + +// eu : https://en.wikipedia.org/wiki/.eu +eu + +// fi : https://www.iana.org/domains/root/db/fi.html +fi +// aland.fi : https://www.iana.org/domains/root/db/ax.html +// This domain is being phased out in favor of .ax. As there are still many +// domains under aland.fi, we still keep it on the list until aland.fi is +// completely removed. +aland.fi + +// fj : http://domains.fj/ +// Submitted by registry 2020-02-11 +fj +ac.fj +biz.fj +com.fj +gov.fj +info.fj +mil.fj +name.fj +net.fj +org.fj +pro.fj + +// fk : https://en.wikipedia.org/wiki/.fk +*.fk + +// fm : https://en.wikipedia.org/wiki/.fm +com.fm +edu.fm +net.fm +org.fm +fm + +// fo : https://en.wikipedia.org/wiki/.fo +fo + +// fr : https://www.afnic.fr/ https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf +fr +asso.fr +com.fr +gouv.fr +nom.fr +prd.fr +tm.fr +// Other SLDs now selfmanaged out of AFNIC range. Former "domaines sectoriels", still registration suffixes +avoues.fr +cci.fr +greta.fr +huissier-justice.fr + +// ga : https://en.wikipedia.org/wiki/.ga +ga + +// gb : This registry is effectively dormant +// Submitted by registry +gb + +// gd : https://en.wikipedia.org/wiki/.gd +edu.gd +gov.gd +gd + +// ge : http://www.nic.net.ge/policy_en.pdf +ge +com.ge +edu.ge +gov.ge +org.ge +mil.ge +net.ge +pvt.ge + +// gf : https://en.wikipedia.org/wiki/.gf +gf + +// gg : http://www.channelisles.net/register-domains/ +// Confirmed by registry 2013-11-28 +gg +co.gg +net.gg +org.gg + +// gh : https://en.wikipedia.org/wiki/.gh +// see also: http://www.nic.gh/reg_now.php +// Although domains directly at second level are not possible at the moment, +// they have been possible for some time and may come back. +gh +com.gh +edu.gh +gov.gh +org.gh +mil.gh + +// gi : http://www.nic.gi/rules.html +gi +com.gi +ltd.gi +gov.gi +mod.gi +edu.gi +org.gi + +// gl : https://en.wikipedia.org/wiki/.gl +// http://nic.gl +gl +co.gl +com.gl +edu.gl +net.gl +org.gl + +// gm : http://www.nic.gm/htmlpages%5Cgm-policy.htm +gm + +// gn : http://psg.com/dns/gn/gn.txt +// Submitted by registry +gn +ac.gn +com.gn +edu.gn +gov.gn +org.gn +net.gn + +// gov : https://en.wikipedia.org/wiki/.gov +gov + +// gp : http://www.nic.gp/index.php?lang=en +gp +com.gp +net.gp +mobi.gp +edu.gp +org.gp +asso.gp + +// gq : https://en.wikipedia.org/wiki/.gq +gq + +// gr : https://grweb.ics.forth.gr/english/1617-B-2005.html +// Submitted by registry +gr +com.gr +edu.gr +net.gr +org.gr +gov.gr + +// gs : https://en.wikipedia.org/wiki/.gs +gs + +// gt : https://www.gt/sitio/registration_policy.php?lang=en +gt +com.gt +edu.gt +gob.gt +ind.gt +mil.gt +net.gt +org.gt + +// gu : http://gadao.gov.gu/register.html +// University of Guam : https://www.uog.edu +// Submitted by uognoc@triton.uog.edu +gu +com.gu +edu.gu +gov.gu +guam.gu +info.gu +net.gu +org.gu +web.gu + +// gw : https://en.wikipedia.org/wiki/.gw +// gw : https://nic.gw/regras/ +gw + +// gy : https://en.wikipedia.org/wiki/.gy +// http://registry.gy/ +gy +co.gy +com.gy +edu.gy +gov.gy +net.gy +org.gy + +// hk : https://www.hkirc.hk +// Submitted by registry +hk +com.hk +edu.hk +gov.hk +idv.hk +net.hk +org.hk +公司.hk +教育.hk +敎育.hk +政府.hk +個人.hk +个人.hk +箇人.hk +網络.hk +网络.hk +组織.hk +網絡.hk +网絡.hk +组织.hk +組織.hk +組织.hk + +// hm : https://en.wikipedia.org/wiki/.hm +hm + +// hn : http://www.nic.hn/politicas/ps02,,05.html +hn +com.hn +edu.hn +org.hn +net.hn +mil.hn +gob.hn + +// hr : http://www.dns.hr/documents/pdf/HRTLD-regulations.pdf +hr +iz.hr +from.hr +name.hr +com.hr + +// ht : http://www.nic.ht/info/charte.cfm +ht +com.ht +shop.ht +firm.ht +info.ht +adult.ht +net.ht +pro.ht +org.ht +med.ht +art.ht +coop.ht +pol.ht +asso.ht +edu.ht +rel.ht +gouv.ht +perso.ht + +// hu : http://www.domain.hu/domain/English/sld.html +// Confirmed by registry 2008-06-12 +hu +co.hu +info.hu +org.hu +priv.hu +sport.hu +tm.hu +2000.hu +agrar.hu +bolt.hu +casino.hu +city.hu +erotica.hu +erotika.hu +film.hu +forum.hu +games.hu +hotel.hu +ingatlan.hu +jogasz.hu +konyvelo.hu +lakas.hu +media.hu +news.hu +reklam.hu +sex.hu +shop.hu +suli.hu +szex.hu +tozsde.hu +utazas.hu +video.hu + +// id : https://pandi.id/en/domain/registration-requirements/ +id +ac.id +biz.id +co.id +desa.id +go.id +mil.id +my.id +net.id +or.id +ponpes.id +sch.id +web.id + +// ie : https://en.wikipedia.org/wiki/.ie +ie +gov.ie + +// il : http://www.isoc.org.il/domains/ +// see also: https://en.isoc.org.il/il-cctld/registration-rules +// ISOC-IL (operated by .il Registry) +il +ac.il +co.il +gov.il +idf.il +k12.il +muni.il +net.il +org.il +// xn--4dbrk0ce ("Israel", Hebrew) : IL +ישראל +// xn--4dbgdty6c.xn--4dbrk0ce. +אקדמיה.ישראל +// xn--5dbhl8d.xn--4dbrk0ce. +ישוב.ישראל +// xn--8dbq2a.xn--4dbrk0ce. +צהל.ישראל +// xn--hebda8b.xn--4dbrk0ce. +ממשל.ישראל + +// im : https://www.nic.im/ +// Submitted by registry +im +ac.im +co.im +com.im +ltd.co.im +net.im +org.im +plc.co.im +tt.im +tv.im + +// in : https://en.wikipedia.org/wiki/.in +// see also: https://registry.in/policies +// Please note, that nic.in is not an official eTLD, but used by most +// government institutions. +in +5g.in +6g.in +ac.in +ai.in +am.in +bihar.in +biz.in +business.in +ca.in +cn.in +co.in +com.in +coop.in +cs.in +delhi.in +dr.in +edu.in +er.in +firm.in +gen.in +gov.in +gujarat.in +ind.in +info.in +int.in +internet.in +io.in +me.in +mil.in +net.in +nic.in +org.in +pg.in +post.in +pro.in +res.in +travel.in +tv.in +uk.in +up.in +us.in + +// info : https://en.wikipedia.org/wiki/.info +info + +// int : https://en.wikipedia.org/wiki/.int +// Confirmed by registry 2008-06-18 +int +eu.int + +// io : http://www.nic.io/rules.htm +// list of other 2nd level tlds ? +io +com.io + +// iq : http://www.cmc.iq/english/iq/iqregister1.htm +iq +gov.iq +edu.iq +mil.iq +com.iq +org.iq +net.iq + +// ir : http://www.nic.ir/Terms_and_Conditions_ir,_Appendix_1_Domain_Rules +// Also see http://www.nic.ir/Internationalized_Domain_Names +// Two .ir entries added at request of , 2010-04-16 +ir +ac.ir +co.ir +gov.ir +id.ir +net.ir +org.ir +sch.ir +// xn--mgba3a4f16a.ir (.ir, Persian YEH) +ایران.ir +// xn--mgba3a4fra.ir (.ir, Arabic YEH) +ايران.ir + +// is : http://www.isnic.is/domain/rules.php +// Confirmed by registry 2008-12-06 +is +net.is +com.is +edu.is +gov.is +org.is +int.is + +// it : https://en.wikipedia.org/wiki/.it +it +gov.it +edu.it +// Reserved geo-names (regions and provinces): +// https://www.nic.it/sites/default/files/archivio/docs/Regulation_assignation_v7.1.pdf +// Regions +abr.it +abruzzo.it +aosta-valley.it +aostavalley.it +bas.it +basilicata.it +cal.it +calabria.it +cam.it +campania.it +emilia-romagna.it +emiliaromagna.it +emr.it +friuli-v-giulia.it +friuli-ve-giulia.it +friuli-vegiulia.it +friuli-venezia-giulia.it +friuli-veneziagiulia.it +friuli-vgiulia.it +friuliv-giulia.it +friulive-giulia.it +friulivegiulia.it +friulivenezia-giulia.it +friuliveneziagiulia.it +friulivgiulia.it +fvg.it +laz.it +lazio.it +lig.it +liguria.it +lom.it +lombardia.it +lombardy.it +lucania.it +mar.it +marche.it +mol.it +molise.it +piedmont.it +piemonte.it +pmn.it +pug.it +puglia.it +sar.it +sardegna.it +sardinia.it +sic.it +sicilia.it +sicily.it +taa.it +tos.it +toscana.it +trentin-sud-tirol.it +trentin-süd-tirol.it +trentin-sudtirol.it +trentin-südtirol.it +trentin-sued-tirol.it +trentin-suedtirol.it +trentino-a-adige.it +trentino-aadige.it +trentino-alto-adige.it +trentino-altoadige.it +trentino-s-tirol.it +trentino-stirol.it +trentino-sud-tirol.it +trentino-süd-tirol.it +trentino-sudtirol.it +trentino-südtirol.it +trentino-sued-tirol.it +trentino-suedtirol.it +trentino.it +trentinoa-adige.it +trentinoaadige.it +trentinoalto-adige.it +trentinoaltoadige.it +trentinos-tirol.it +trentinostirol.it +trentinosud-tirol.it +trentinosüd-tirol.it +trentinosudtirol.it +trentinosüdtirol.it +trentinosued-tirol.it +trentinosuedtirol.it +trentinsud-tirol.it +trentinsüd-tirol.it +trentinsudtirol.it +trentinsüdtirol.it +trentinsued-tirol.it +trentinsuedtirol.it +tuscany.it +umb.it +umbria.it +val-d-aosta.it +val-daosta.it +vald-aosta.it +valdaosta.it +valle-aosta.it +valle-d-aosta.it +valle-daosta.it +valleaosta.it +valled-aosta.it +valledaosta.it +vallee-aoste.it +vallée-aoste.it +vallee-d-aoste.it +vallée-d-aoste.it +valleeaoste.it +valléeaoste.it +valleedaoste.it +valléedaoste.it +vao.it +vda.it +ven.it +veneto.it +// Provinces +ag.it +agrigento.it +al.it +alessandria.it +alto-adige.it +altoadige.it +an.it +ancona.it +andria-barletta-trani.it +andria-trani-barletta.it +andriabarlettatrani.it +andriatranibarletta.it +ao.it +aosta.it +aoste.it +ap.it +aq.it +aquila.it +ar.it +arezzo.it +ascoli-piceno.it +ascolipiceno.it +asti.it +at.it +av.it +avellino.it +ba.it +balsan-sudtirol.it +balsan-südtirol.it +balsan-suedtirol.it +balsan.it +bari.it +barletta-trani-andria.it +barlettatraniandria.it +belluno.it +benevento.it +bergamo.it +bg.it +bi.it +biella.it +bl.it +bn.it +bo.it +bologna.it +bolzano-altoadige.it +bolzano.it +bozen-sudtirol.it +bozen-südtirol.it +bozen-suedtirol.it +bozen.it +br.it +brescia.it +brindisi.it +bs.it +bt.it +bulsan-sudtirol.it +bulsan-südtirol.it +bulsan-suedtirol.it +bulsan.it +bz.it +ca.it +cagliari.it +caltanissetta.it +campidano-medio.it +campidanomedio.it +campobasso.it +carbonia-iglesias.it +carboniaiglesias.it +carrara-massa.it +carraramassa.it +caserta.it +catania.it +catanzaro.it +cb.it +ce.it +cesena-forli.it +cesena-forlì.it +cesenaforli.it +cesenaforlì.it +ch.it +chieti.it +ci.it +cl.it +cn.it +co.it +como.it +cosenza.it +cr.it +cremona.it +crotone.it +cs.it +ct.it +cuneo.it +cz.it +dell-ogliastra.it +dellogliastra.it +en.it +enna.it +fc.it +fe.it +fermo.it +ferrara.it +fg.it +fi.it +firenze.it +florence.it +fm.it +foggia.it +forli-cesena.it +forlì-cesena.it +forlicesena.it +forlìcesena.it +fr.it +frosinone.it +ge.it +genoa.it +genova.it +go.it +gorizia.it +gr.it +grosseto.it +iglesias-carbonia.it +iglesiascarbonia.it +im.it +imperia.it +is.it +isernia.it +kr.it +la-spezia.it +laquila.it +laspezia.it +latina.it +lc.it +le.it +lecce.it +lecco.it +li.it +livorno.it +lo.it +lodi.it +lt.it +lu.it +lucca.it +macerata.it +mantova.it +massa-carrara.it +massacarrara.it +matera.it +mb.it +mc.it +me.it +medio-campidano.it +mediocampidano.it +messina.it +mi.it +milan.it +milano.it +mn.it +mo.it +modena.it +monza-brianza.it +monza-e-della-brianza.it +monza.it +monzabrianza.it +monzaebrianza.it +monzaedellabrianza.it +ms.it +mt.it +na.it +naples.it +napoli.it +no.it +novara.it +nu.it +nuoro.it +og.it +ogliastra.it +olbia-tempio.it +olbiatempio.it +or.it +oristano.it +ot.it +pa.it +padova.it +padua.it +palermo.it +parma.it +pavia.it +pc.it +pd.it +pe.it +perugia.it +pesaro-urbino.it +pesarourbino.it +pescara.it +pg.it +pi.it +piacenza.it +pisa.it +pistoia.it +pn.it +po.it +pordenone.it +potenza.it +pr.it +prato.it +pt.it +pu.it +pv.it +pz.it +ra.it +ragusa.it +ravenna.it +rc.it +re.it +reggio-calabria.it +reggio-emilia.it +reggiocalabria.it +reggioemilia.it +rg.it +ri.it +rieti.it +rimini.it +rm.it +rn.it +ro.it +roma.it +rome.it +rovigo.it +sa.it +salerno.it +sassari.it +savona.it +si.it +siena.it +siracusa.it +so.it +sondrio.it +sp.it +sr.it +ss.it +suedtirol.it +südtirol.it +sv.it +ta.it +taranto.it +te.it +tempio-olbia.it +tempioolbia.it +teramo.it +terni.it +tn.it +to.it +torino.it +tp.it +tr.it +trani-andria-barletta.it +trani-barletta-andria.it +traniandriabarletta.it +tranibarlettaandria.it +trapani.it +trento.it +treviso.it +trieste.it +ts.it +turin.it +tv.it +ud.it +udine.it +urbino-pesaro.it +urbinopesaro.it +va.it +varese.it +vb.it +vc.it +ve.it +venezia.it +venice.it +verbania.it +vercelli.it +verona.it +vi.it +vibo-valentia.it +vibovalentia.it +vicenza.it +viterbo.it +vr.it +vs.it +vt.it +vv.it + +// je : http://www.channelisles.net/register-domains/ +// Confirmed by registry 2013-11-28 +je +co.je +net.je +org.je + +// jm : http://www.com.jm/register.html +*.jm + +// jo : http://www.dns.jo/Registration_policy.aspx +jo +com.jo +org.jo +net.jo +edu.jo +sch.jo +gov.jo +mil.jo +name.jo + +// jobs : https://en.wikipedia.org/wiki/.jobs +jobs + +// jp : https://en.wikipedia.org/wiki/.jp +// http://jprs.co.jp/en/jpdomain.html +// Submitted by registry +jp +// jp organizational type names +ac.jp +ad.jp +co.jp +ed.jp +go.jp +gr.jp +lg.jp +ne.jp +or.jp +// jp prefecture type names +aichi.jp +akita.jp +aomori.jp +chiba.jp +ehime.jp +fukui.jp +fukuoka.jp +fukushima.jp +gifu.jp +gunma.jp +hiroshima.jp +hokkaido.jp +hyogo.jp +ibaraki.jp +ishikawa.jp +iwate.jp +kagawa.jp +kagoshima.jp +kanagawa.jp +kochi.jp +kumamoto.jp +kyoto.jp +mie.jp +miyagi.jp +miyazaki.jp +nagano.jp +nagasaki.jp +nara.jp +niigata.jp +oita.jp +okayama.jp +okinawa.jp +osaka.jp +saga.jp +saitama.jp +shiga.jp +shimane.jp +shizuoka.jp +tochigi.jp +tokushima.jp +tokyo.jp +tottori.jp +toyama.jp +wakayama.jp +yamagata.jp +yamaguchi.jp +yamanashi.jp +栃木.jp +愛知.jp +愛媛.jp +兵庫.jp +熊本.jp +茨城.jp +北海道.jp +千葉.jp +和歌山.jp +長崎.jp +長野.jp +新潟.jp +青森.jp +静岡.jp +東京.jp +石川.jp +埼玉.jp +三重.jp +京都.jp +佐賀.jp +大分.jp +大阪.jp +奈良.jp +宮城.jp +宮崎.jp +富山.jp +山口.jp +山形.jp +山梨.jp +岩手.jp +岐阜.jp +岡山.jp +島根.jp +広島.jp +徳島.jp +沖縄.jp +滋賀.jp +神奈川.jp +福井.jp +福岡.jp +福島.jp +秋田.jp +群馬.jp +香川.jp +高知.jp +鳥取.jp +鹿児島.jp +// jp geographic type names +// http://jprs.jp/doc/rule/saisoku-1.html +*.kawasaki.jp +*.kitakyushu.jp +*.kobe.jp +*.nagoya.jp +*.sapporo.jp +*.sendai.jp +*.yokohama.jp +!city.kawasaki.jp +!city.kitakyushu.jp +!city.kobe.jp +!city.nagoya.jp +!city.sapporo.jp +!city.sendai.jp +!city.yokohama.jp +// 4th level registration +aisai.aichi.jp +ama.aichi.jp +anjo.aichi.jp +asuke.aichi.jp +chiryu.aichi.jp +chita.aichi.jp +fuso.aichi.jp +gamagori.aichi.jp +handa.aichi.jp +hazu.aichi.jp +hekinan.aichi.jp +higashiura.aichi.jp +ichinomiya.aichi.jp +inazawa.aichi.jp +inuyama.aichi.jp +isshiki.aichi.jp +iwakura.aichi.jp +kanie.aichi.jp +kariya.aichi.jp +kasugai.aichi.jp +kira.aichi.jp +kiyosu.aichi.jp +komaki.aichi.jp +konan.aichi.jp +kota.aichi.jp +mihama.aichi.jp +miyoshi.aichi.jp +nishio.aichi.jp +nisshin.aichi.jp +obu.aichi.jp +oguchi.aichi.jp +oharu.aichi.jp +okazaki.aichi.jp +owariasahi.aichi.jp +seto.aichi.jp +shikatsu.aichi.jp +shinshiro.aichi.jp +shitara.aichi.jp +tahara.aichi.jp +takahama.aichi.jp +tobishima.aichi.jp +toei.aichi.jp +togo.aichi.jp +tokai.aichi.jp +tokoname.aichi.jp +toyoake.aichi.jp +toyohashi.aichi.jp +toyokawa.aichi.jp +toyone.aichi.jp +toyota.aichi.jp +tsushima.aichi.jp +yatomi.aichi.jp +akita.akita.jp +daisen.akita.jp +fujisato.akita.jp +gojome.akita.jp +hachirogata.akita.jp +happou.akita.jp +higashinaruse.akita.jp +honjo.akita.jp +honjyo.akita.jp +ikawa.akita.jp +kamikoani.akita.jp +kamioka.akita.jp +katagami.akita.jp +kazuno.akita.jp +kitaakita.akita.jp +kosaka.akita.jp +kyowa.akita.jp +misato.akita.jp +mitane.akita.jp +moriyoshi.akita.jp +nikaho.akita.jp +noshiro.akita.jp +odate.akita.jp +oga.akita.jp +ogata.akita.jp +semboku.akita.jp +yokote.akita.jp +yurihonjo.akita.jp +aomori.aomori.jp +gonohe.aomori.jp +hachinohe.aomori.jp +hashikami.aomori.jp +hiranai.aomori.jp +hirosaki.aomori.jp +itayanagi.aomori.jp +kuroishi.aomori.jp +misawa.aomori.jp +mutsu.aomori.jp +nakadomari.aomori.jp +noheji.aomori.jp +oirase.aomori.jp +owani.aomori.jp +rokunohe.aomori.jp +sannohe.aomori.jp +shichinohe.aomori.jp +shingo.aomori.jp +takko.aomori.jp +towada.aomori.jp +tsugaru.aomori.jp +tsuruta.aomori.jp +abiko.chiba.jp +asahi.chiba.jp +chonan.chiba.jp +chosei.chiba.jp +choshi.chiba.jp +chuo.chiba.jp +funabashi.chiba.jp +futtsu.chiba.jp +hanamigawa.chiba.jp +ichihara.chiba.jp +ichikawa.chiba.jp +ichinomiya.chiba.jp +inzai.chiba.jp +isumi.chiba.jp +kamagaya.chiba.jp +kamogawa.chiba.jp +kashiwa.chiba.jp +katori.chiba.jp +katsuura.chiba.jp +kimitsu.chiba.jp +kisarazu.chiba.jp +kozaki.chiba.jp +kujukuri.chiba.jp +kyonan.chiba.jp +matsudo.chiba.jp +midori.chiba.jp +mihama.chiba.jp +minamiboso.chiba.jp +mobara.chiba.jp +mutsuzawa.chiba.jp +nagara.chiba.jp +nagareyama.chiba.jp +narashino.chiba.jp +narita.chiba.jp +noda.chiba.jp +oamishirasato.chiba.jp +omigawa.chiba.jp +onjuku.chiba.jp +otaki.chiba.jp +sakae.chiba.jp +sakura.chiba.jp +shimofusa.chiba.jp +shirako.chiba.jp +shiroi.chiba.jp +shisui.chiba.jp +sodegaura.chiba.jp +sosa.chiba.jp +tako.chiba.jp +tateyama.chiba.jp +togane.chiba.jp +tohnosho.chiba.jp +tomisato.chiba.jp +urayasu.chiba.jp +yachimata.chiba.jp +yachiyo.chiba.jp +yokaichiba.chiba.jp +yokoshibahikari.chiba.jp +yotsukaido.chiba.jp +ainan.ehime.jp +honai.ehime.jp +ikata.ehime.jp +imabari.ehime.jp +iyo.ehime.jp +kamijima.ehime.jp +kihoku.ehime.jp +kumakogen.ehime.jp +masaki.ehime.jp +matsuno.ehime.jp +matsuyama.ehime.jp +namikata.ehime.jp +niihama.ehime.jp +ozu.ehime.jp +saijo.ehime.jp +seiyo.ehime.jp +shikokuchuo.ehime.jp +tobe.ehime.jp +toon.ehime.jp +uchiko.ehime.jp +uwajima.ehime.jp +yawatahama.ehime.jp +echizen.fukui.jp +eiheiji.fukui.jp +fukui.fukui.jp +ikeda.fukui.jp +katsuyama.fukui.jp +mihama.fukui.jp +minamiechizen.fukui.jp +obama.fukui.jp +ohi.fukui.jp +ono.fukui.jp +sabae.fukui.jp +sakai.fukui.jp +takahama.fukui.jp +tsuruga.fukui.jp +wakasa.fukui.jp +ashiya.fukuoka.jp +buzen.fukuoka.jp +chikugo.fukuoka.jp +chikuho.fukuoka.jp +chikujo.fukuoka.jp +chikushino.fukuoka.jp +chikuzen.fukuoka.jp +chuo.fukuoka.jp +dazaifu.fukuoka.jp +fukuchi.fukuoka.jp +hakata.fukuoka.jp +higashi.fukuoka.jp +hirokawa.fukuoka.jp +hisayama.fukuoka.jp +iizuka.fukuoka.jp +inatsuki.fukuoka.jp +kaho.fukuoka.jp +kasuga.fukuoka.jp +kasuya.fukuoka.jp +kawara.fukuoka.jp +keisen.fukuoka.jp +koga.fukuoka.jp +kurate.fukuoka.jp +kurogi.fukuoka.jp +kurume.fukuoka.jp +minami.fukuoka.jp +miyako.fukuoka.jp +miyama.fukuoka.jp +miyawaka.fukuoka.jp +mizumaki.fukuoka.jp +munakata.fukuoka.jp +nakagawa.fukuoka.jp +nakama.fukuoka.jp +nishi.fukuoka.jp +nogata.fukuoka.jp +ogori.fukuoka.jp +okagaki.fukuoka.jp +okawa.fukuoka.jp +oki.fukuoka.jp +omuta.fukuoka.jp +onga.fukuoka.jp +onojo.fukuoka.jp +oto.fukuoka.jp +saigawa.fukuoka.jp +sasaguri.fukuoka.jp +shingu.fukuoka.jp +shinyoshitomi.fukuoka.jp +shonai.fukuoka.jp +soeda.fukuoka.jp +sue.fukuoka.jp +tachiarai.fukuoka.jp +tagawa.fukuoka.jp +takata.fukuoka.jp +toho.fukuoka.jp +toyotsu.fukuoka.jp +tsuiki.fukuoka.jp +ukiha.fukuoka.jp +umi.fukuoka.jp +usui.fukuoka.jp +yamada.fukuoka.jp +yame.fukuoka.jp +yanagawa.fukuoka.jp +yukuhashi.fukuoka.jp +aizubange.fukushima.jp +aizumisato.fukushima.jp +aizuwakamatsu.fukushima.jp +asakawa.fukushima.jp +bandai.fukushima.jp +date.fukushima.jp +fukushima.fukushima.jp +furudono.fukushima.jp +futaba.fukushima.jp +hanawa.fukushima.jp +higashi.fukushima.jp +hirata.fukushima.jp +hirono.fukushima.jp +iitate.fukushima.jp +inawashiro.fukushima.jp +ishikawa.fukushima.jp +iwaki.fukushima.jp +izumizaki.fukushima.jp +kagamiishi.fukushima.jp +kaneyama.fukushima.jp +kawamata.fukushima.jp +kitakata.fukushima.jp +kitashiobara.fukushima.jp +koori.fukushima.jp +koriyama.fukushima.jp +kunimi.fukushima.jp +miharu.fukushima.jp +mishima.fukushima.jp +namie.fukushima.jp +nango.fukushima.jp +nishiaizu.fukushima.jp +nishigo.fukushima.jp +okuma.fukushima.jp +omotego.fukushima.jp +ono.fukushima.jp +otama.fukushima.jp +samegawa.fukushima.jp +shimogo.fukushima.jp +shirakawa.fukushima.jp +showa.fukushima.jp +soma.fukushima.jp +sukagawa.fukushima.jp +taishin.fukushima.jp +tamakawa.fukushima.jp +tanagura.fukushima.jp +tenei.fukushima.jp +yabuki.fukushima.jp +yamato.fukushima.jp +yamatsuri.fukushima.jp +yanaizu.fukushima.jp +yugawa.fukushima.jp +anpachi.gifu.jp +ena.gifu.jp +gifu.gifu.jp +ginan.gifu.jp +godo.gifu.jp +gujo.gifu.jp +hashima.gifu.jp +hichiso.gifu.jp +hida.gifu.jp +higashishirakawa.gifu.jp +ibigawa.gifu.jp +ikeda.gifu.jp +kakamigahara.gifu.jp +kani.gifu.jp +kasahara.gifu.jp +kasamatsu.gifu.jp +kawaue.gifu.jp +kitagata.gifu.jp +mino.gifu.jp +minokamo.gifu.jp +mitake.gifu.jp +mizunami.gifu.jp +motosu.gifu.jp +nakatsugawa.gifu.jp +ogaki.gifu.jp +sakahogi.gifu.jp +seki.gifu.jp +sekigahara.gifu.jp +shirakawa.gifu.jp +tajimi.gifu.jp +takayama.gifu.jp +tarui.gifu.jp +toki.gifu.jp +tomika.gifu.jp +wanouchi.gifu.jp +yamagata.gifu.jp +yaotsu.gifu.jp +yoro.gifu.jp +annaka.gunma.jp +chiyoda.gunma.jp +fujioka.gunma.jp +higashiagatsuma.gunma.jp +isesaki.gunma.jp +itakura.gunma.jp +kanna.gunma.jp +kanra.gunma.jp +katashina.gunma.jp +kawaba.gunma.jp +kiryu.gunma.jp +kusatsu.gunma.jp +maebashi.gunma.jp +meiwa.gunma.jp +midori.gunma.jp +minakami.gunma.jp +naganohara.gunma.jp +nakanojo.gunma.jp +nanmoku.gunma.jp +numata.gunma.jp +oizumi.gunma.jp +ora.gunma.jp +ota.gunma.jp +shibukawa.gunma.jp +shimonita.gunma.jp +shinto.gunma.jp +showa.gunma.jp +takasaki.gunma.jp +takayama.gunma.jp +tamamura.gunma.jp +tatebayashi.gunma.jp +tomioka.gunma.jp +tsukiyono.gunma.jp +tsumagoi.gunma.jp +ueno.gunma.jp +yoshioka.gunma.jp +asaminami.hiroshima.jp +daiwa.hiroshima.jp +etajima.hiroshima.jp +fuchu.hiroshima.jp +fukuyama.hiroshima.jp +hatsukaichi.hiroshima.jp +higashihiroshima.hiroshima.jp +hongo.hiroshima.jp +jinsekikogen.hiroshima.jp +kaita.hiroshima.jp +kui.hiroshima.jp +kumano.hiroshima.jp +kure.hiroshima.jp +mihara.hiroshima.jp +miyoshi.hiroshima.jp +naka.hiroshima.jp +onomichi.hiroshima.jp +osakikamijima.hiroshima.jp +otake.hiroshima.jp +saka.hiroshima.jp +sera.hiroshima.jp +seranishi.hiroshima.jp +shinichi.hiroshima.jp +shobara.hiroshima.jp +takehara.hiroshima.jp +abashiri.hokkaido.jp +abira.hokkaido.jp +aibetsu.hokkaido.jp +akabira.hokkaido.jp +akkeshi.hokkaido.jp +asahikawa.hokkaido.jp +ashibetsu.hokkaido.jp +ashoro.hokkaido.jp +assabu.hokkaido.jp +atsuma.hokkaido.jp +bibai.hokkaido.jp +biei.hokkaido.jp +bifuka.hokkaido.jp +bihoro.hokkaido.jp +biratori.hokkaido.jp +chippubetsu.hokkaido.jp +chitose.hokkaido.jp +date.hokkaido.jp +ebetsu.hokkaido.jp +embetsu.hokkaido.jp +eniwa.hokkaido.jp +erimo.hokkaido.jp +esan.hokkaido.jp +esashi.hokkaido.jp +fukagawa.hokkaido.jp +fukushima.hokkaido.jp +furano.hokkaido.jp +furubira.hokkaido.jp +haboro.hokkaido.jp +hakodate.hokkaido.jp +hamatonbetsu.hokkaido.jp +hidaka.hokkaido.jp +higashikagura.hokkaido.jp +higashikawa.hokkaido.jp +hiroo.hokkaido.jp +hokuryu.hokkaido.jp +hokuto.hokkaido.jp +honbetsu.hokkaido.jp +horokanai.hokkaido.jp +horonobe.hokkaido.jp +ikeda.hokkaido.jp +imakane.hokkaido.jp +ishikari.hokkaido.jp +iwamizawa.hokkaido.jp +iwanai.hokkaido.jp +kamifurano.hokkaido.jp +kamikawa.hokkaido.jp +kamishihoro.hokkaido.jp +kamisunagawa.hokkaido.jp +kamoenai.hokkaido.jp +kayabe.hokkaido.jp +kembuchi.hokkaido.jp +kikonai.hokkaido.jp +kimobetsu.hokkaido.jp +kitahiroshima.hokkaido.jp +kitami.hokkaido.jp +kiyosato.hokkaido.jp +koshimizu.hokkaido.jp +kunneppu.hokkaido.jp +kuriyama.hokkaido.jp +kuromatsunai.hokkaido.jp +kushiro.hokkaido.jp +kutchan.hokkaido.jp +kyowa.hokkaido.jp +mashike.hokkaido.jp +matsumae.hokkaido.jp +mikasa.hokkaido.jp +minamifurano.hokkaido.jp +mombetsu.hokkaido.jp +moseushi.hokkaido.jp +mukawa.hokkaido.jp +muroran.hokkaido.jp +naie.hokkaido.jp +nakagawa.hokkaido.jp +nakasatsunai.hokkaido.jp +nakatombetsu.hokkaido.jp +nanae.hokkaido.jp +nanporo.hokkaido.jp +nayoro.hokkaido.jp +nemuro.hokkaido.jp +niikappu.hokkaido.jp +niki.hokkaido.jp +nishiokoppe.hokkaido.jp +noboribetsu.hokkaido.jp +numata.hokkaido.jp +obihiro.hokkaido.jp +obira.hokkaido.jp +oketo.hokkaido.jp +okoppe.hokkaido.jp +otaru.hokkaido.jp +otobe.hokkaido.jp +otofuke.hokkaido.jp +otoineppu.hokkaido.jp +oumu.hokkaido.jp +ozora.hokkaido.jp +pippu.hokkaido.jp +rankoshi.hokkaido.jp +rebun.hokkaido.jp +rikubetsu.hokkaido.jp +rishiri.hokkaido.jp +rishirifuji.hokkaido.jp +saroma.hokkaido.jp +sarufutsu.hokkaido.jp +shakotan.hokkaido.jp +shari.hokkaido.jp +shibecha.hokkaido.jp +shibetsu.hokkaido.jp +shikabe.hokkaido.jp +shikaoi.hokkaido.jp +shimamaki.hokkaido.jp +shimizu.hokkaido.jp +shimokawa.hokkaido.jp +shinshinotsu.hokkaido.jp +shintoku.hokkaido.jp +shiranuka.hokkaido.jp +shiraoi.hokkaido.jp +shiriuchi.hokkaido.jp +sobetsu.hokkaido.jp +sunagawa.hokkaido.jp +taiki.hokkaido.jp +takasu.hokkaido.jp +takikawa.hokkaido.jp +takinoue.hokkaido.jp +teshikaga.hokkaido.jp +tobetsu.hokkaido.jp +tohma.hokkaido.jp +tomakomai.hokkaido.jp +tomari.hokkaido.jp +toya.hokkaido.jp +toyako.hokkaido.jp +toyotomi.hokkaido.jp +toyoura.hokkaido.jp +tsubetsu.hokkaido.jp +tsukigata.hokkaido.jp +urakawa.hokkaido.jp +urausu.hokkaido.jp +uryu.hokkaido.jp +utashinai.hokkaido.jp +wakkanai.hokkaido.jp +wassamu.hokkaido.jp +yakumo.hokkaido.jp +yoichi.hokkaido.jp +aioi.hyogo.jp +akashi.hyogo.jp +ako.hyogo.jp +amagasaki.hyogo.jp +aogaki.hyogo.jp +asago.hyogo.jp +ashiya.hyogo.jp +awaji.hyogo.jp +fukusaki.hyogo.jp +goshiki.hyogo.jp +harima.hyogo.jp +himeji.hyogo.jp +ichikawa.hyogo.jp +inagawa.hyogo.jp +itami.hyogo.jp +kakogawa.hyogo.jp +kamigori.hyogo.jp +kamikawa.hyogo.jp +kasai.hyogo.jp +kasuga.hyogo.jp +kawanishi.hyogo.jp +miki.hyogo.jp +minamiawaji.hyogo.jp +nishinomiya.hyogo.jp +nishiwaki.hyogo.jp +ono.hyogo.jp +sanda.hyogo.jp +sannan.hyogo.jp +sasayama.hyogo.jp +sayo.hyogo.jp +shingu.hyogo.jp +shinonsen.hyogo.jp +shiso.hyogo.jp +sumoto.hyogo.jp +taishi.hyogo.jp +taka.hyogo.jp +takarazuka.hyogo.jp +takasago.hyogo.jp +takino.hyogo.jp +tamba.hyogo.jp +tatsuno.hyogo.jp +toyooka.hyogo.jp +yabu.hyogo.jp +yashiro.hyogo.jp +yoka.hyogo.jp +yokawa.hyogo.jp +ami.ibaraki.jp +asahi.ibaraki.jp +bando.ibaraki.jp +chikusei.ibaraki.jp +daigo.ibaraki.jp +fujishiro.ibaraki.jp +hitachi.ibaraki.jp +hitachinaka.ibaraki.jp +hitachiomiya.ibaraki.jp +hitachiota.ibaraki.jp +ibaraki.ibaraki.jp +ina.ibaraki.jp +inashiki.ibaraki.jp +itako.ibaraki.jp +iwama.ibaraki.jp +joso.ibaraki.jp +kamisu.ibaraki.jp +kasama.ibaraki.jp +kashima.ibaraki.jp +kasumigaura.ibaraki.jp +koga.ibaraki.jp +miho.ibaraki.jp +mito.ibaraki.jp +moriya.ibaraki.jp +naka.ibaraki.jp +namegata.ibaraki.jp +oarai.ibaraki.jp +ogawa.ibaraki.jp +omitama.ibaraki.jp +ryugasaki.ibaraki.jp +sakai.ibaraki.jp +sakuragawa.ibaraki.jp +shimodate.ibaraki.jp +shimotsuma.ibaraki.jp +shirosato.ibaraki.jp +sowa.ibaraki.jp +suifu.ibaraki.jp +takahagi.ibaraki.jp +tamatsukuri.ibaraki.jp +tokai.ibaraki.jp +tomobe.ibaraki.jp +tone.ibaraki.jp +toride.ibaraki.jp +tsuchiura.ibaraki.jp +tsukuba.ibaraki.jp +uchihara.ibaraki.jp +ushiku.ibaraki.jp +yachiyo.ibaraki.jp +yamagata.ibaraki.jp +yawara.ibaraki.jp +yuki.ibaraki.jp +anamizu.ishikawa.jp +hakui.ishikawa.jp +hakusan.ishikawa.jp +kaga.ishikawa.jp +kahoku.ishikawa.jp +kanazawa.ishikawa.jp +kawakita.ishikawa.jp +komatsu.ishikawa.jp +nakanoto.ishikawa.jp +nanao.ishikawa.jp +nomi.ishikawa.jp +nonoichi.ishikawa.jp +noto.ishikawa.jp +shika.ishikawa.jp +suzu.ishikawa.jp +tsubata.ishikawa.jp +tsurugi.ishikawa.jp +uchinada.ishikawa.jp +wajima.ishikawa.jp +fudai.iwate.jp +fujisawa.iwate.jp +hanamaki.iwate.jp +hiraizumi.iwate.jp +hirono.iwate.jp +ichinohe.iwate.jp +ichinoseki.iwate.jp +iwaizumi.iwate.jp +iwate.iwate.jp +joboji.iwate.jp +kamaishi.iwate.jp +kanegasaki.iwate.jp +karumai.iwate.jp +kawai.iwate.jp +kitakami.iwate.jp +kuji.iwate.jp +kunohe.iwate.jp +kuzumaki.iwate.jp +miyako.iwate.jp +mizusawa.iwate.jp +morioka.iwate.jp +ninohe.iwate.jp +noda.iwate.jp +ofunato.iwate.jp +oshu.iwate.jp +otsuchi.iwate.jp +rikuzentakata.iwate.jp +shiwa.iwate.jp +shizukuishi.iwate.jp +sumita.iwate.jp +tanohata.iwate.jp +tono.iwate.jp +yahaba.iwate.jp +yamada.iwate.jp +ayagawa.kagawa.jp +higashikagawa.kagawa.jp +kanonji.kagawa.jp +kotohira.kagawa.jp +manno.kagawa.jp +marugame.kagawa.jp +mitoyo.kagawa.jp +naoshima.kagawa.jp +sanuki.kagawa.jp +tadotsu.kagawa.jp +takamatsu.kagawa.jp +tonosho.kagawa.jp +uchinomi.kagawa.jp +utazu.kagawa.jp +zentsuji.kagawa.jp +akune.kagoshima.jp +amami.kagoshima.jp +hioki.kagoshima.jp +isa.kagoshima.jp +isen.kagoshima.jp +izumi.kagoshima.jp +kagoshima.kagoshima.jp +kanoya.kagoshima.jp +kawanabe.kagoshima.jp +kinko.kagoshima.jp +kouyama.kagoshima.jp +makurazaki.kagoshima.jp +matsumoto.kagoshima.jp +minamitane.kagoshima.jp +nakatane.kagoshima.jp +nishinoomote.kagoshima.jp +satsumasendai.kagoshima.jp +soo.kagoshima.jp +tarumizu.kagoshima.jp +yusui.kagoshima.jp +aikawa.kanagawa.jp +atsugi.kanagawa.jp +ayase.kanagawa.jp +chigasaki.kanagawa.jp +ebina.kanagawa.jp +fujisawa.kanagawa.jp +hadano.kanagawa.jp +hakone.kanagawa.jp +hiratsuka.kanagawa.jp +isehara.kanagawa.jp +kaisei.kanagawa.jp +kamakura.kanagawa.jp +kiyokawa.kanagawa.jp +matsuda.kanagawa.jp +minamiashigara.kanagawa.jp +miura.kanagawa.jp +nakai.kanagawa.jp +ninomiya.kanagawa.jp +odawara.kanagawa.jp +oi.kanagawa.jp +oiso.kanagawa.jp +sagamihara.kanagawa.jp +samukawa.kanagawa.jp +tsukui.kanagawa.jp +yamakita.kanagawa.jp +yamato.kanagawa.jp +yokosuka.kanagawa.jp +yugawara.kanagawa.jp +zama.kanagawa.jp +zushi.kanagawa.jp +aki.kochi.jp +geisei.kochi.jp +hidaka.kochi.jp +higashitsuno.kochi.jp +ino.kochi.jp +kagami.kochi.jp +kami.kochi.jp +kitagawa.kochi.jp +kochi.kochi.jp +mihara.kochi.jp +motoyama.kochi.jp +muroto.kochi.jp +nahari.kochi.jp +nakamura.kochi.jp +nankoku.kochi.jp +nishitosa.kochi.jp +niyodogawa.kochi.jp +ochi.kochi.jp +okawa.kochi.jp +otoyo.kochi.jp +otsuki.kochi.jp +sakawa.kochi.jp +sukumo.kochi.jp +susaki.kochi.jp +tosa.kochi.jp +tosashimizu.kochi.jp +toyo.kochi.jp +tsuno.kochi.jp +umaji.kochi.jp +yasuda.kochi.jp +yusuhara.kochi.jp +amakusa.kumamoto.jp +arao.kumamoto.jp +aso.kumamoto.jp +choyo.kumamoto.jp +gyokuto.kumamoto.jp +kamiamakusa.kumamoto.jp +kikuchi.kumamoto.jp +kumamoto.kumamoto.jp +mashiki.kumamoto.jp +mifune.kumamoto.jp +minamata.kumamoto.jp +minamioguni.kumamoto.jp +nagasu.kumamoto.jp +nishihara.kumamoto.jp +oguni.kumamoto.jp +ozu.kumamoto.jp +sumoto.kumamoto.jp +takamori.kumamoto.jp +uki.kumamoto.jp +uto.kumamoto.jp +yamaga.kumamoto.jp +yamato.kumamoto.jp +yatsushiro.kumamoto.jp +ayabe.kyoto.jp +fukuchiyama.kyoto.jp +higashiyama.kyoto.jp +ide.kyoto.jp +ine.kyoto.jp +joyo.kyoto.jp +kameoka.kyoto.jp +kamo.kyoto.jp +kita.kyoto.jp +kizu.kyoto.jp +kumiyama.kyoto.jp +kyotamba.kyoto.jp +kyotanabe.kyoto.jp +kyotango.kyoto.jp +maizuru.kyoto.jp +minami.kyoto.jp +minamiyamashiro.kyoto.jp +miyazu.kyoto.jp +muko.kyoto.jp +nagaokakyo.kyoto.jp +nakagyo.kyoto.jp +nantan.kyoto.jp +oyamazaki.kyoto.jp +sakyo.kyoto.jp +seika.kyoto.jp +tanabe.kyoto.jp +uji.kyoto.jp +ujitawara.kyoto.jp +wazuka.kyoto.jp +yamashina.kyoto.jp +yawata.kyoto.jp +asahi.mie.jp +inabe.mie.jp +ise.mie.jp +kameyama.mie.jp +kawagoe.mie.jp +kiho.mie.jp +kisosaki.mie.jp +kiwa.mie.jp +komono.mie.jp +kumano.mie.jp +kuwana.mie.jp +matsusaka.mie.jp +meiwa.mie.jp +mihama.mie.jp +minamiise.mie.jp +misugi.mie.jp +miyama.mie.jp +nabari.mie.jp +shima.mie.jp +suzuka.mie.jp +tado.mie.jp +taiki.mie.jp +taki.mie.jp +tamaki.mie.jp +toba.mie.jp +tsu.mie.jp +udono.mie.jp +ureshino.mie.jp +watarai.mie.jp +yokkaichi.mie.jp +furukawa.miyagi.jp +higashimatsushima.miyagi.jp +ishinomaki.miyagi.jp +iwanuma.miyagi.jp +kakuda.miyagi.jp +kami.miyagi.jp +kawasaki.miyagi.jp +marumori.miyagi.jp +matsushima.miyagi.jp +minamisanriku.miyagi.jp +misato.miyagi.jp +murata.miyagi.jp +natori.miyagi.jp +ogawara.miyagi.jp +ohira.miyagi.jp +onagawa.miyagi.jp +osaki.miyagi.jp +rifu.miyagi.jp +semine.miyagi.jp +shibata.miyagi.jp +shichikashuku.miyagi.jp +shikama.miyagi.jp +shiogama.miyagi.jp +shiroishi.miyagi.jp +tagajo.miyagi.jp +taiwa.miyagi.jp +tome.miyagi.jp +tomiya.miyagi.jp +wakuya.miyagi.jp +watari.miyagi.jp +yamamoto.miyagi.jp +zao.miyagi.jp +aya.miyazaki.jp +ebino.miyazaki.jp +gokase.miyazaki.jp +hyuga.miyazaki.jp +kadogawa.miyazaki.jp +kawaminami.miyazaki.jp +kijo.miyazaki.jp +kitagawa.miyazaki.jp +kitakata.miyazaki.jp +kitaura.miyazaki.jp +kobayashi.miyazaki.jp +kunitomi.miyazaki.jp +kushima.miyazaki.jp +mimata.miyazaki.jp +miyakonojo.miyazaki.jp +miyazaki.miyazaki.jp +morotsuka.miyazaki.jp +nichinan.miyazaki.jp +nishimera.miyazaki.jp +nobeoka.miyazaki.jp +saito.miyazaki.jp +shiiba.miyazaki.jp +shintomi.miyazaki.jp +takaharu.miyazaki.jp +takanabe.miyazaki.jp +takazaki.miyazaki.jp +tsuno.miyazaki.jp +achi.nagano.jp +agematsu.nagano.jp +anan.nagano.jp +aoki.nagano.jp +asahi.nagano.jp +azumino.nagano.jp +chikuhoku.nagano.jp +chikuma.nagano.jp +chino.nagano.jp +fujimi.nagano.jp +hakuba.nagano.jp +hara.nagano.jp +hiraya.nagano.jp +iida.nagano.jp +iijima.nagano.jp +iiyama.nagano.jp +iizuna.nagano.jp +ikeda.nagano.jp +ikusaka.nagano.jp +ina.nagano.jp +karuizawa.nagano.jp +kawakami.nagano.jp +kiso.nagano.jp +kisofukushima.nagano.jp +kitaaiki.nagano.jp +komagane.nagano.jp +komoro.nagano.jp +matsukawa.nagano.jp +matsumoto.nagano.jp +miasa.nagano.jp +minamiaiki.nagano.jp +minamimaki.nagano.jp +minamiminowa.nagano.jp +minowa.nagano.jp +miyada.nagano.jp +miyota.nagano.jp +mochizuki.nagano.jp +nagano.nagano.jp +nagawa.nagano.jp +nagiso.nagano.jp +nakagawa.nagano.jp +nakano.nagano.jp +nozawaonsen.nagano.jp +obuse.nagano.jp +ogawa.nagano.jp +okaya.nagano.jp +omachi.nagano.jp +omi.nagano.jp +ookuwa.nagano.jp +ooshika.nagano.jp +otaki.nagano.jp +otari.nagano.jp +sakae.nagano.jp +sakaki.nagano.jp +saku.nagano.jp +sakuho.nagano.jp +shimosuwa.nagano.jp +shinanomachi.nagano.jp +shiojiri.nagano.jp +suwa.nagano.jp +suzaka.nagano.jp +takagi.nagano.jp +takamori.nagano.jp +takayama.nagano.jp +tateshina.nagano.jp +tatsuno.nagano.jp +togakushi.nagano.jp +togura.nagano.jp +tomi.nagano.jp +ueda.nagano.jp +wada.nagano.jp +yamagata.nagano.jp +yamanouchi.nagano.jp +yasaka.nagano.jp +yasuoka.nagano.jp +chijiwa.nagasaki.jp +futsu.nagasaki.jp +goto.nagasaki.jp +hasami.nagasaki.jp +hirado.nagasaki.jp +iki.nagasaki.jp +isahaya.nagasaki.jp +kawatana.nagasaki.jp +kuchinotsu.nagasaki.jp +matsuura.nagasaki.jp +nagasaki.nagasaki.jp +obama.nagasaki.jp +omura.nagasaki.jp +oseto.nagasaki.jp +saikai.nagasaki.jp +sasebo.nagasaki.jp +seihi.nagasaki.jp +shimabara.nagasaki.jp +shinkamigoto.nagasaki.jp +togitsu.nagasaki.jp +tsushima.nagasaki.jp +unzen.nagasaki.jp +ando.nara.jp +gose.nara.jp +heguri.nara.jp +higashiyoshino.nara.jp +ikaruga.nara.jp +ikoma.nara.jp +kamikitayama.nara.jp +kanmaki.nara.jp +kashiba.nara.jp +kashihara.nara.jp +katsuragi.nara.jp +kawai.nara.jp +kawakami.nara.jp +kawanishi.nara.jp +koryo.nara.jp +kurotaki.nara.jp +mitsue.nara.jp +miyake.nara.jp +nara.nara.jp +nosegawa.nara.jp +oji.nara.jp +ouda.nara.jp +oyodo.nara.jp +sakurai.nara.jp +sango.nara.jp +shimoichi.nara.jp +shimokitayama.nara.jp +shinjo.nara.jp +soni.nara.jp +takatori.nara.jp +tawaramoto.nara.jp +tenkawa.nara.jp +tenri.nara.jp +uda.nara.jp +yamatokoriyama.nara.jp +yamatotakada.nara.jp +yamazoe.nara.jp +yoshino.nara.jp +aga.niigata.jp +agano.niigata.jp +gosen.niigata.jp +itoigawa.niigata.jp +izumozaki.niigata.jp +joetsu.niigata.jp +kamo.niigata.jp +kariwa.niigata.jp +kashiwazaki.niigata.jp +minamiuonuma.niigata.jp +mitsuke.niigata.jp +muika.niigata.jp +murakami.niigata.jp +myoko.niigata.jp +nagaoka.niigata.jp +niigata.niigata.jp +ojiya.niigata.jp +omi.niigata.jp +sado.niigata.jp +sanjo.niigata.jp +seiro.niigata.jp +seirou.niigata.jp +sekikawa.niigata.jp +shibata.niigata.jp +tagami.niigata.jp +tainai.niigata.jp +tochio.niigata.jp +tokamachi.niigata.jp +tsubame.niigata.jp +tsunan.niigata.jp +uonuma.niigata.jp +yahiko.niigata.jp +yoita.niigata.jp +yuzawa.niigata.jp +beppu.oita.jp +bungoono.oita.jp +bungotakada.oita.jp +hasama.oita.jp +hiji.oita.jp +himeshima.oita.jp +hita.oita.jp +kamitsue.oita.jp +kokonoe.oita.jp +kuju.oita.jp +kunisaki.oita.jp +kusu.oita.jp +oita.oita.jp +saiki.oita.jp +taketa.oita.jp +tsukumi.oita.jp +usa.oita.jp +usuki.oita.jp +yufu.oita.jp +akaiwa.okayama.jp +asakuchi.okayama.jp +bizen.okayama.jp +hayashima.okayama.jp +ibara.okayama.jp +kagamino.okayama.jp +kasaoka.okayama.jp +kibichuo.okayama.jp +kumenan.okayama.jp +kurashiki.okayama.jp +maniwa.okayama.jp +misaki.okayama.jp +nagi.okayama.jp +niimi.okayama.jp +nishiawakura.okayama.jp +okayama.okayama.jp +satosho.okayama.jp +setouchi.okayama.jp +shinjo.okayama.jp +shoo.okayama.jp +soja.okayama.jp +takahashi.okayama.jp +tamano.okayama.jp +tsuyama.okayama.jp +wake.okayama.jp +yakage.okayama.jp +aguni.okinawa.jp +ginowan.okinawa.jp +ginoza.okinawa.jp +gushikami.okinawa.jp +haebaru.okinawa.jp +higashi.okinawa.jp +hirara.okinawa.jp +iheya.okinawa.jp +ishigaki.okinawa.jp +ishikawa.okinawa.jp +itoman.okinawa.jp +izena.okinawa.jp +kadena.okinawa.jp +kin.okinawa.jp +kitadaito.okinawa.jp +kitanakagusuku.okinawa.jp +kumejima.okinawa.jp +kunigami.okinawa.jp +minamidaito.okinawa.jp +motobu.okinawa.jp +nago.okinawa.jp +naha.okinawa.jp +nakagusuku.okinawa.jp +nakijin.okinawa.jp +nanjo.okinawa.jp +nishihara.okinawa.jp +ogimi.okinawa.jp +okinawa.okinawa.jp +onna.okinawa.jp +shimoji.okinawa.jp +taketomi.okinawa.jp +tarama.okinawa.jp +tokashiki.okinawa.jp +tomigusuku.okinawa.jp +tonaki.okinawa.jp +urasoe.okinawa.jp +uruma.okinawa.jp +yaese.okinawa.jp +yomitan.okinawa.jp +yonabaru.okinawa.jp +yonaguni.okinawa.jp +zamami.okinawa.jp +abeno.osaka.jp +chihayaakasaka.osaka.jp +chuo.osaka.jp +daito.osaka.jp +fujiidera.osaka.jp +habikino.osaka.jp +hannan.osaka.jp +higashiosaka.osaka.jp +higashisumiyoshi.osaka.jp +higashiyodogawa.osaka.jp +hirakata.osaka.jp +ibaraki.osaka.jp +ikeda.osaka.jp +izumi.osaka.jp +izumiotsu.osaka.jp +izumisano.osaka.jp +kadoma.osaka.jp +kaizuka.osaka.jp +kanan.osaka.jp +kashiwara.osaka.jp +katano.osaka.jp +kawachinagano.osaka.jp +kishiwada.osaka.jp +kita.osaka.jp +kumatori.osaka.jp +matsubara.osaka.jp +minato.osaka.jp +minoh.osaka.jp +misaki.osaka.jp +moriguchi.osaka.jp +neyagawa.osaka.jp +nishi.osaka.jp +nose.osaka.jp +osakasayama.osaka.jp +sakai.osaka.jp +sayama.osaka.jp +sennan.osaka.jp +settsu.osaka.jp +shijonawate.osaka.jp +shimamoto.osaka.jp +suita.osaka.jp +tadaoka.osaka.jp +taishi.osaka.jp +tajiri.osaka.jp +takaishi.osaka.jp +takatsuki.osaka.jp +tondabayashi.osaka.jp +toyonaka.osaka.jp +toyono.osaka.jp +yao.osaka.jp +ariake.saga.jp +arita.saga.jp +fukudomi.saga.jp +genkai.saga.jp +hamatama.saga.jp +hizen.saga.jp +imari.saga.jp +kamimine.saga.jp +kanzaki.saga.jp +karatsu.saga.jp +kashima.saga.jp +kitagata.saga.jp +kitahata.saga.jp +kiyama.saga.jp +kouhoku.saga.jp +kyuragi.saga.jp +nishiarita.saga.jp +ogi.saga.jp +omachi.saga.jp +ouchi.saga.jp +saga.saga.jp +shiroishi.saga.jp +taku.saga.jp +tara.saga.jp +tosu.saga.jp +yoshinogari.saga.jp +arakawa.saitama.jp +asaka.saitama.jp +chichibu.saitama.jp +fujimi.saitama.jp +fujimino.saitama.jp +fukaya.saitama.jp +hanno.saitama.jp +hanyu.saitama.jp +hasuda.saitama.jp +hatogaya.saitama.jp +hatoyama.saitama.jp +hidaka.saitama.jp +higashichichibu.saitama.jp +higashimatsuyama.saitama.jp +honjo.saitama.jp +ina.saitama.jp +iruma.saitama.jp +iwatsuki.saitama.jp +kamiizumi.saitama.jp +kamikawa.saitama.jp +kamisato.saitama.jp +kasukabe.saitama.jp +kawagoe.saitama.jp +kawaguchi.saitama.jp +kawajima.saitama.jp +kazo.saitama.jp +kitamoto.saitama.jp +koshigaya.saitama.jp +kounosu.saitama.jp +kuki.saitama.jp +kumagaya.saitama.jp +matsubushi.saitama.jp +minano.saitama.jp +misato.saitama.jp +miyashiro.saitama.jp +miyoshi.saitama.jp +moroyama.saitama.jp +nagatoro.saitama.jp +namegawa.saitama.jp +niiza.saitama.jp +ogano.saitama.jp +ogawa.saitama.jp +ogose.saitama.jp +okegawa.saitama.jp +omiya.saitama.jp +otaki.saitama.jp +ranzan.saitama.jp +ryokami.saitama.jp +saitama.saitama.jp +sakado.saitama.jp +satte.saitama.jp +sayama.saitama.jp +shiki.saitama.jp +shiraoka.saitama.jp +soka.saitama.jp +sugito.saitama.jp +toda.saitama.jp +tokigawa.saitama.jp +tokorozawa.saitama.jp +tsurugashima.saitama.jp +urawa.saitama.jp +warabi.saitama.jp +yashio.saitama.jp +yokoze.saitama.jp +yono.saitama.jp +yorii.saitama.jp +yoshida.saitama.jp +yoshikawa.saitama.jp +yoshimi.saitama.jp +aisho.shiga.jp +gamo.shiga.jp +higashiomi.shiga.jp +hikone.shiga.jp +koka.shiga.jp +konan.shiga.jp +kosei.shiga.jp +koto.shiga.jp +kusatsu.shiga.jp +maibara.shiga.jp +moriyama.shiga.jp +nagahama.shiga.jp +nishiazai.shiga.jp +notogawa.shiga.jp +omihachiman.shiga.jp +otsu.shiga.jp +ritto.shiga.jp +ryuoh.shiga.jp +takashima.shiga.jp +takatsuki.shiga.jp +torahime.shiga.jp +toyosato.shiga.jp +yasu.shiga.jp +akagi.shimane.jp +ama.shimane.jp +gotsu.shimane.jp +hamada.shimane.jp +higashiizumo.shimane.jp +hikawa.shimane.jp +hikimi.shimane.jp +izumo.shimane.jp +kakinoki.shimane.jp +masuda.shimane.jp +matsue.shimane.jp +misato.shimane.jp +nishinoshima.shimane.jp +ohda.shimane.jp +okinoshima.shimane.jp +okuizumo.shimane.jp +shimane.shimane.jp +tamayu.shimane.jp +tsuwano.shimane.jp +unnan.shimane.jp +yakumo.shimane.jp +yasugi.shimane.jp +yatsuka.shimane.jp +arai.shizuoka.jp +atami.shizuoka.jp +fuji.shizuoka.jp +fujieda.shizuoka.jp +fujikawa.shizuoka.jp +fujinomiya.shizuoka.jp +fukuroi.shizuoka.jp +gotemba.shizuoka.jp +haibara.shizuoka.jp +hamamatsu.shizuoka.jp +higashiizu.shizuoka.jp +ito.shizuoka.jp +iwata.shizuoka.jp +izu.shizuoka.jp +izunokuni.shizuoka.jp +kakegawa.shizuoka.jp +kannami.shizuoka.jp +kawanehon.shizuoka.jp +kawazu.shizuoka.jp +kikugawa.shizuoka.jp +kosai.shizuoka.jp +makinohara.shizuoka.jp +matsuzaki.shizuoka.jp +minamiizu.shizuoka.jp +mishima.shizuoka.jp +morimachi.shizuoka.jp +nishiizu.shizuoka.jp +numazu.shizuoka.jp +omaezaki.shizuoka.jp +shimada.shizuoka.jp +shimizu.shizuoka.jp +shimoda.shizuoka.jp +shizuoka.shizuoka.jp +susono.shizuoka.jp +yaizu.shizuoka.jp +yoshida.shizuoka.jp +ashikaga.tochigi.jp +bato.tochigi.jp +haga.tochigi.jp +ichikai.tochigi.jp +iwafune.tochigi.jp +kaminokawa.tochigi.jp +kanuma.tochigi.jp +karasuyama.tochigi.jp +kuroiso.tochigi.jp +mashiko.tochigi.jp +mibu.tochigi.jp +moka.tochigi.jp +motegi.tochigi.jp +nasu.tochigi.jp +nasushiobara.tochigi.jp +nikko.tochigi.jp +nishikata.tochigi.jp +nogi.tochigi.jp +ohira.tochigi.jp +ohtawara.tochigi.jp +oyama.tochigi.jp +sakura.tochigi.jp +sano.tochigi.jp +shimotsuke.tochigi.jp +shioya.tochigi.jp +takanezawa.tochigi.jp +tochigi.tochigi.jp +tsuga.tochigi.jp +ujiie.tochigi.jp +utsunomiya.tochigi.jp +yaita.tochigi.jp +aizumi.tokushima.jp +anan.tokushima.jp +ichiba.tokushima.jp +itano.tokushima.jp +kainan.tokushima.jp +komatsushima.tokushima.jp +matsushige.tokushima.jp +mima.tokushima.jp +minami.tokushima.jp +miyoshi.tokushima.jp +mugi.tokushima.jp +nakagawa.tokushima.jp +naruto.tokushima.jp +sanagochi.tokushima.jp +shishikui.tokushima.jp +tokushima.tokushima.jp +wajiki.tokushima.jp +adachi.tokyo.jp +akiruno.tokyo.jp +akishima.tokyo.jp +aogashima.tokyo.jp +arakawa.tokyo.jp +bunkyo.tokyo.jp +chiyoda.tokyo.jp +chofu.tokyo.jp +chuo.tokyo.jp +edogawa.tokyo.jp +fuchu.tokyo.jp +fussa.tokyo.jp +hachijo.tokyo.jp +hachioji.tokyo.jp +hamura.tokyo.jp +higashikurume.tokyo.jp +higashimurayama.tokyo.jp +higashiyamato.tokyo.jp +hino.tokyo.jp +hinode.tokyo.jp +hinohara.tokyo.jp +inagi.tokyo.jp +itabashi.tokyo.jp +katsushika.tokyo.jp +kita.tokyo.jp +kiyose.tokyo.jp +kodaira.tokyo.jp +koganei.tokyo.jp +kokubunji.tokyo.jp +komae.tokyo.jp +koto.tokyo.jp +kouzushima.tokyo.jp +kunitachi.tokyo.jp +machida.tokyo.jp +meguro.tokyo.jp +minato.tokyo.jp +mitaka.tokyo.jp +mizuho.tokyo.jp +musashimurayama.tokyo.jp +musashino.tokyo.jp +nakano.tokyo.jp +nerima.tokyo.jp +ogasawara.tokyo.jp +okutama.tokyo.jp +ome.tokyo.jp +oshima.tokyo.jp +ota.tokyo.jp +setagaya.tokyo.jp +shibuya.tokyo.jp +shinagawa.tokyo.jp +shinjuku.tokyo.jp +suginami.tokyo.jp +sumida.tokyo.jp +tachikawa.tokyo.jp +taito.tokyo.jp +tama.tokyo.jp +toshima.tokyo.jp +chizu.tottori.jp +hino.tottori.jp +kawahara.tottori.jp +koge.tottori.jp +kotoura.tottori.jp +misasa.tottori.jp +nanbu.tottori.jp +nichinan.tottori.jp +sakaiminato.tottori.jp +tottori.tottori.jp +wakasa.tottori.jp +yazu.tottori.jp +yonago.tottori.jp +asahi.toyama.jp +fuchu.toyama.jp +fukumitsu.toyama.jp +funahashi.toyama.jp +himi.toyama.jp +imizu.toyama.jp +inami.toyama.jp +johana.toyama.jp +kamiichi.toyama.jp +kurobe.toyama.jp +nakaniikawa.toyama.jp +namerikawa.toyama.jp +nanto.toyama.jp +nyuzen.toyama.jp +oyabe.toyama.jp +taira.toyama.jp +takaoka.toyama.jp +tateyama.toyama.jp +toga.toyama.jp +tonami.toyama.jp +toyama.toyama.jp +unazuki.toyama.jp +uozu.toyama.jp +yamada.toyama.jp +arida.wakayama.jp +aridagawa.wakayama.jp +gobo.wakayama.jp +hashimoto.wakayama.jp +hidaka.wakayama.jp +hirogawa.wakayama.jp +inami.wakayama.jp +iwade.wakayama.jp +kainan.wakayama.jp +kamitonda.wakayama.jp +katsuragi.wakayama.jp +kimino.wakayama.jp +kinokawa.wakayama.jp +kitayama.wakayama.jp +koya.wakayama.jp +koza.wakayama.jp +kozagawa.wakayama.jp +kudoyama.wakayama.jp +kushimoto.wakayama.jp +mihama.wakayama.jp +misato.wakayama.jp +nachikatsuura.wakayama.jp +shingu.wakayama.jp +shirahama.wakayama.jp +taiji.wakayama.jp +tanabe.wakayama.jp +wakayama.wakayama.jp +yuasa.wakayama.jp +yura.wakayama.jp +asahi.yamagata.jp +funagata.yamagata.jp +higashine.yamagata.jp +iide.yamagata.jp +kahoku.yamagata.jp +kaminoyama.yamagata.jp +kaneyama.yamagata.jp +kawanishi.yamagata.jp +mamurogawa.yamagata.jp +mikawa.yamagata.jp +murayama.yamagata.jp +nagai.yamagata.jp +nakayama.yamagata.jp +nanyo.yamagata.jp +nishikawa.yamagata.jp +obanazawa.yamagata.jp +oe.yamagata.jp +oguni.yamagata.jp +ohkura.yamagata.jp +oishida.yamagata.jp +sagae.yamagata.jp +sakata.yamagata.jp +sakegawa.yamagata.jp +shinjo.yamagata.jp +shirataka.yamagata.jp +shonai.yamagata.jp +takahata.yamagata.jp +tendo.yamagata.jp +tozawa.yamagata.jp +tsuruoka.yamagata.jp +yamagata.yamagata.jp +yamanobe.yamagata.jp +yonezawa.yamagata.jp +yuza.yamagata.jp +abu.yamaguchi.jp +hagi.yamaguchi.jp +hikari.yamaguchi.jp +hofu.yamaguchi.jp +iwakuni.yamaguchi.jp +kudamatsu.yamaguchi.jp +mitou.yamaguchi.jp +nagato.yamaguchi.jp +oshima.yamaguchi.jp +shimonoseki.yamaguchi.jp +shunan.yamaguchi.jp +tabuse.yamaguchi.jp +tokuyama.yamaguchi.jp +toyota.yamaguchi.jp +ube.yamaguchi.jp +yuu.yamaguchi.jp +chuo.yamanashi.jp +doshi.yamanashi.jp +fuefuki.yamanashi.jp +fujikawa.yamanashi.jp +fujikawaguchiko.yamanashi.jp +fujiyoshida.yamanashi.jp +hayakawa.yamanashi.jp +hokuto.yamanashi.jp +ichikawamisato.yamanashi.jp +kai.yamanashi.jp +kofu.yamanashi.jp +koshu.yamanashi.jp +kosuge.yamanashi.jp +minami-alps.yamanashi.jp +minobu.yamanashi.jp +nakamichi.yamanashi.jp +nanbu.yamanashi.jp +narusawa.yamanashi.jp +nirasaki.yamanashi.jp +nishikatsura.yamanashi.jp +oshino.yamanashi.jp +otsuki.yamanashi.jp +showa.yamanashi.jp +tabayama.yamanashi.jp +tsuru.yamanashi.jp +uenohara.yamanashi.jp +yamanakako.yamanashi.jp +yamanashi.yamanashi.jp + +// ke : http://www.kenic.or.ke/index.php/en/ke-domains/ke-domains +ke +ac.ke +co.ke +go.ke +info.ke +me.ke +mobi.ke +ne.ke +or.ke +sc.ke + +// kg : http://www.domain.kg/dmn_n.html +kg +org.kg +net.kg +com.kg +edu.kg +gov.kg +mil.kg + +// kh : http://www.mptc.gov.kh/dns_registration.htm +*.kh + +// ki : http://www.ki/dns/index.html +ki +edu.ki +biz.ki +net.ki +org.ki +gov.ki +info.ki +com.ki + +// km : https://en.wikipedia.org/wiki/.km +// http://www.domaine.km/documents/charte.doc +km +org.km +nom.km +gov.km +prd.km +tm.km +edu.km +mil.km +ass.km +com.km +// These are only mentioned as proposed suggestions at domaine.km, but +// https://en.wikipedia.org/wiki/.km says they're available for registration: +coop.km +asso.km +presse.km +medecin.km +notaires.km +pharmaciens.km +veterinaire.km +gouv.km + +// kn : https://en.wikipedia.org/wiki/.kn +// http://www.dot.kn/domainRules.html +kn +net.kn +org.kn +edu.kn +gov.kn + +// kp : http://www.kcce.kp/en_index.php +kp +com.kp +edu.kp +gov.kp +org.kp +rep.kp +tra.kp + +// kr : https://en.wikipedia.org/wiki/.kr +// see also: http://domain.nida.or.kr/eng/registration.jsp +kr +ac.kr +co.kr +es.kr +go.kr +hs.kr +kg.kr +mil.kr +ms.kr +ne.kr +or.kr +pe.kr +re.kr +sc.kr +// kr geographical names +busan.kr +chungbuk.kr +chungnam.kr +daegu.kr +daejeon.kr +gangwon.kr +gwangju.kr +gyeongbuk.kr +gyeonggi.kr +gyeongnam.kr +incheon.kr +jeju.kr +jeonbuk.kr +jeonnam.kr +seoul.kr +ulsan.kr + +// kw : https://www.nic.kw/policies/ +// Confirmed by registry +kw +com.kw +edu.kw +emb.kw +gov.kw +ind.kw +net.kw +org.kw + +// ky : http://www.icta.ky/da_ky_reg_dom.php +// Confirmed by registry 2008-06-17 +ky +com.ky +edu.ky +net.ky +org.ky + +// kz : https://en.wikipedia.org/wiki/.kz +// see also: http://www.nic.kz/rules/index.jsp +kz +org.kz +edu.kz +net.kz +gov.kz +mil.kz +com.kz + +// la : https://en.wikipedia.org/wiki/.la +// Submitted by registry +la +int.la +net.la +info.la +edu.la +gov.la +per.la +com.la +org.la + +// lb : https://en.wikipedia.org/wiki/.lb +// Submitted by registry +lb +com.lb +edu.lb +gov.lb +net.lb +org.lb + +// lc : https://en.wikipedia.org/wiki/.lc +// see also: http://www.nic.lc/rules.htm +lc +com.lc +net.lc +co.lc +org.lc +edu.lc +gov.lc + +// li : https://en.wikipedia.org/wiki/.li +li + +// lk : https://www.nic.lk/index.php/domain-registration/lk-domain-naming-structure +lk +gov.lk +sch.lk +net.lk +int.lk +com.lk +org.lk +edu.lk +ngo.lk +soc.lk +web.lk +ltd.lk +assn.lk +grp.lk +hotel.lk +ac.lk + +// lr : http://psg.com/dns/lr/lr.txt +// Submitted by registry +lr +com.lr +edu.lr +gov.lr +org.lr +net.lr + +// ls : http://www.nic.ls/ +// Confirmed by registry +ls +ac.ls +biz.ls +co.ls +edu.ls +gov.ls +info.ls +net.ls +org.ls +sc.ls + +// lt : https://en.wikipedia.org/wiki/.lt +lt +// gov.lt : http://www.gov.lt/index_en.php +gov.lt + +// lu : http://www.dns.lu/en/ +lu + +// lv : http://www.nic.lv/DNS/En/generic.php +lv +com.lv +edu.lv +gov.lv +org.lv +mil.lv +id.lv +net.lv +asn.lv +conf.lv + +// ly : http://www.nic.ly/regulations.php +ly +com.ly +net.ly +gov.ly +plc.ly +edu.ly +sch.ly +med.ly +org.ly +id.ly + +// ma : https://en.wikipedia.org/wiki/.ma +// http://www.anrt.ma/fr/admin/download/upload/file_fr782.pdf +ma +co.ma +net.ma +gov.ma +org.ma +ac.ma +press.ma + +// mc : http://www.nic.mc/ +mc +tm.mc +asso.mc + +// md : https://en.wikipedia.org/wiki/.md +md + +// me : https://en.wikipedia.org/wiki/.me +me +co.me +net.me +org.me +edu.me +ac.me +gov.me +its.me +priv.me + +// mg : http://nic.mg/nicmg/?page_id=39 +mg +org.mg +nom.mg +gov.mg +prd.mg +tm.mg +edu.mg +mil.mg +com.mg +co.mg + +// mh : https://en.wikipedia.org/wiki/.mh +mh + +// mil : https://en.wikipedia.org/wiki/.mil +mil + +// mk : https://en.wikipedia.org/wiki/.mk +// see also: http://dns.marnet.net.mk/postapka.php +mk +com.mk +org.mk +net.mk +edu.mk +gov.mk +inf.mk +name.mk + +// ml : http://www.gobin.info/domainname/ml-template.doc +// see also: https://en.wikipedia.org/wiki/.ml +ml +com.ml +edu.ml +gouv.ml +gov.ml +net.ml +org.ml +presse.ml + +// mm : https://en.wikipedia.org/wiki/.mm +*.mm + +// mn : https://en.wikipedia.org/wiki/.mn +mn +gov.mn +edu.mn +org.mn + +// mo : http://www.monic.net.mo/ +mo +com.mo +net.mo +org.mo +edu.mo +gov.mo + +// mobi : https://en.wikipedia.org/wiki/.mobi +mobi + +// mp : http://www.dot.mp/ +// Confirmed by registry 2008-06-17 +mp + +// mq : https://en.wikipedia.org/wiki/.mq +mq + +// mr : https://en.wikipedia.org/wiki/.mr +mr +gov.mr + +// ms : http://www.nic.ms/pdf/MS_Domain_Name_Rules.pdf +ms +com.ms +edu.ms +gov.ms +net.ms +org.ms + +// mt : https://www.nic.org.mt/go/policy +// Submitted by registry +mt +com.mt +edu.mt +net.mt +org.mt + +// mu : https://en.wikipedia.org/wiki/.mu +mu +com.mu +net.mu +org.mu +gov.mu +ac.mu +co.mu +or.mu + +// museum : https://welcome.museum/wp-content/uploads/2018/05/20180525-Registration-Policy-MUSEUM-EN_VF-2.pdf https://welcome.museum/buy-your-dot-museum-2/ +museum + +// mv : https://en.wikipedia.org/wiki/.mv +// "mv" included because, contra Wikipedia, google.mv exists. +mv +aero.mv +biz.mv +com.mv +coop.mv +edu.mv +gov.mv +info.mv +int.mv +mil.mv +museum.mv +name.mv +net.mv +org.mv +pro.mv + +// mw : http://www.registrar.mw/ +mw +ac.mw +biz.mw +co.mw +com.mw +coop.mw +edu.mw +gov.mw +int.mw +museum.mw +net.mw +org.mw + +// mx : http://www.nic.mx/ +// Submitted by registry +mx +com.mx +org.mx +gob.mx +edu.mx +net.mx + +// my : http://www.mynic.my/ +// Available strings: https://mynic.my/resources/domains/buying-a-domain/ +my +biz.my +com.my +edu.my +gov.my +mil.my +name.my +net.my +org.my + +// mz : http://www.uem.mz/ +// Submitted by registry +mz +ac.mz +adv.mz +co.mz +edu.mz +gov.mz +mil.mz +net.mz +org.mz + +// na : http://www.na-nic.com.na/ +// http://www.info.na/domain/ +na +info.na +pro.na +name.na +school.na +or.na +dr.na +us.na +mx.na +ca.na +in.na +cc.na +tv.na +ws.na +mobi.na +co.na +com.na +org.na + +// name : has 2nd-level tlds, but there's no list of them +name + +// nc : http://www.cctld.nc/ +nc +asso.nc +nom.nc + +// ne : https://en.wikipedia.org/wiki/.ne +ne + +// net : https://en.wikipedia.org/wiki/.net +net + +// nf : https://en.wikipedia.org/wiki/.nf +nf +com.nf +net.nf +per.nf +rec.nf +web.nf +arts.nf +firm.nf +info.nf +other.nf +store.nf + +// ng : http://www.nira.org.ng/index.php/join-us/register-ng-domain/189-nira-slds +ng +com.ng +edu.ng +gov.ng +i.ng +mil.ng +mobi.ng +name.ng +net.ng +org.ng +sch.ng + +// ni : http://www.nic.ni/ +ni +ac.ni +biz.ni +co.ni +com.ni +edu.ni +gob.ni +in.ni +info.ni +int.ni +mil.ni +net.ni +nom.ni +org.ni +web.ni + +// nl : https://en.wikipedia.org/wiki/.nl +// https://www.sidn.nl/ +// ccTLD for the Netherlands +nl + +// no : https://www.norid.no/en/om-domenenavn/regelverk-for-no/ +// Norid geographical second level domains : https://www.norid.no/en/om-domenenavn/regelverk-for-no/vedlegg-b/ +// Norid category second level domains : https://www.norid.no/en/om-domenenavn/regelverk-for-no/vedlegg-c/ +// Norid category second-level domains managed by parties other than Norid : https://www.norid.no/en/om-domenenavn/regelverk-for-no/vedlegg-d/ +// RSS feed: https://teknisk.norid.no/en/feed/ +no +// Norid category second level domains : https://www.norid.no/en/om-domenenavn/regelverk-for-no/vedlegg-c/ +fhs.no +vgs.no +fylkesbibl.no +folkebibl.no +museum.no +idrett.no +priv.no +// Norid category second-level domains managed by parties other than Norid : https://www.norid.no/en/om-domenenavn/regelverk-for-no/vedlegg-d/ +mil.no +stat.no +dep.no +kommune.no +herad.no +// Norid geographical second level domains : https://www.norid.no/en/om-domenenavn/regelverk-for-no/vedlegg-b/ +// counties +aa.no +ah.no +bu.no +fm.no +hl.no +hm.no +jan-mayen.no +mr.no +nl.no +nt.no +of.no +ol.no +oslo.no +rl.no +sf.no +st.no +svalbard.no +tm.no +tr.no +va.no +vf.no +// primary and lower secondary schools per county +gs.aa.no +gs.ah.no +gs.bu.no +gs.fm.no +gs.hl.no +gs.hm.no +gs.jan-mayen.no +gs.mr.no +gs.nl.no +gs.nt.no +gs.of.no +gs.ol.no +gs.oslo.no +gs.rl.no +gs.sf.no +gs.st.no +gs.svalbard.no +gs.tm.no +gs.tr.no +gs.va.no +gs.vf.no +// cities +akrehamn.no +åkrehamn.no +algard.no +ålgård.no +arna.no +brumunddal.no +bryne.no +bronnoysund.no +brønnøysund.no +drobak.no +drøbak.no +egersund.no +fetsund.no +floro.no +florø.no +fredrikstad.no +hokksund.no +honefoss.no +hønefoss.no +jessheim.no +jorpeland.no +jørpeland.no +kirkenes.no +kopervik.no +krokstadelva.no +langevag.no +langevåg.no +leirvik.no +mjondalen.no +mjøndalen.no +mo-i-rana.no +mosjoen.no +mosjøen.no +nesoddtangen.no +orkanger.no +osoyro.no +osøyro.no +raholt.no +råholt.no +sandnessjoen.no +sandnessjøen.no +skedsmokorset.no +slattum.no +spjelkavik.no +stathelle.no +stavern.no +stjordalshalsen.no +stjørdalshalsen.no +tananger.no +tranby.no +vossevangen.no +// communities +afjord.no +åfjord.no +agdenes.no +al.no +ål.no +alesund.no +ålesund.no +alstahaug.no +alta.no +áltá.no +alaheadju.no +álaheadju.no +alvdal.no +amli.no +åmli.no +amot.no +åmot.no +andebu.no +andoy.no +andøy.no +andasuolo.no +ardal.no +årdal.no +aremark.no +arendal.no +ås.no +aseral.no +åseral.no +asker.no +askim.no +askvoll.no +askoy.no +askøy.no +asnes.no +åsnes.no +audnedaln.no +aukra.no +aure.no +aurland.no +aurskog-holand.no +aurskog-høland.no +austevoll.no +austrheim.no +averoy.no +averøy.no +balestrand.no +ballangen.no +balat.no +bálát.no +balsfjord.no +bahccavuotna.no +báhccavuotna.no +bamble.no +bardu.no +beardu.no +beiarn.no +bajddar.no +bájddar.no +baidar.no +báidár.no +berg.no +bergen.no +berlevag.no +berlevåg.no +bearalvahki.no +bearalváhki.no +bindal.no +birkenes.no +bjarkoy.no +bjarkøy.no +bjerkreim.no +bjugn.no +bodo.no +bodø.no +badaddja.no +bådåddjå.no +budejju.no +bokn.no +bremanger.no +bronnoy.no +brønnøy.no +bygland.no +bykle.no +barum.no +bærum.no +bo.telemark.no +bø.telemark.no +bo.nordland.no +bø.nordland.no +bievat.no +bievát.no +bomlo.no +bømlo.no +batsfjord.no +båtsfjord.no +bahcavuotna.no +báhcavuotna.no +dovre.no +drammen.no +drangedal.no +dyroy.no +dyrøy.no +donna.no +dønna.no +eid.no +eidfjord.no +eidsberg.no +eidskog.no +eidsvoll.no +eigersund.no +elverum.no +enebakk.no +engerdal.no +etne.no +etnedal.no +evenes.no +evenassi.no +evenášši.no +evje-og-hornnes.no +farsund.no +fauske.no +fuossko.no +fuoisku.no +fedje.no +fet.no +finnoy.no +finnøy.no +fitjar.no +fjaler.no +fjell.no +flakstad.no +flatanger.no +flekkefjord.no +flesberg.no +flora.no +fla.no +flå.no +folldal.no +forsand.no +fosnes.no +frei.no +frogn.no +froland.no +frosta.no +frana.no +fræna.no +froya.no +frøya.no +fusa.no +fyresdal.no +forde.no +førde.no +gamvik.no +gangaviika.no +gáŋgaviika.no +gaular.no +gausdal.no +gildeskal.no +gildeskål.no +giske.no +gjemnes.no +gjerdrum.no +gjerstad.no +gjesdal.no +gjovik.no +gjøvik.no +gloppen.no +gol.no +gran.no +grane.no +granvin.no +gratangen.no +grimstad.no +grong.no +kraanghke.no +kråanghke.no +grue.no +gulen.no +hadsel.no +halden.no +halsa.no +hamar.no +hamaroy.no +habmer.no +hábmer.no +hapmir.no +hápmir.no +hammerfest.no +hammarfeasta.no +hámmárfeasta.no +haram.no +hareid.no +harstad.no +hasvik.no +aknoluokta.no +ákŋoluokta.no +hattfjelldal.no +aarborte.no +haugesund.no +hemne.no +hemnes.no +hemsedal.no +heroy.more-og-romsdal.no +herøy.møre-og-romsdal.no +heroy.nordland.no +herøy.nordland.no +hitra.no +hjartdal.no +hjelmeland.no +hobol.no +hobøl.no +hof.no +hol.no +hole.no +holmestrand.no +holtalen.no +holtålen.no +hornindal.no +horten.no +hurdal.no +hurum.no +hvaler.no +hyllestad.no +hagebostad.no +hægebostad.no +hoyanger.no +høyanger.no +hoylandet.no +høylandet.no +ha.no +hå.no +ibestad.no +inderoy.no +inderøy.no +iveland.no +jevnaker.no +jondal.no +jolster.no +jølster.no +karasjok.no +karasjohka.no +kárášjohka.no +karlsoy.no +galsa.no +gálsá.no +karmoy.no +karmøy.no +kautokeino.no +guovdageaidnu.no +klepp.no +klabu.no +klæbu.no +kongsberg.no +kongsvinger.no +kragero.no +kragerø.no +kristiansand.no +kristiansund.no +krodsherad.no +krødsherad.no +kvalsund.no +rahkkeravju.no +ráhkkerávju.no +kvam.no +kvinesdal.no +kvinnherad.no +kviteseid.no +kvitsoy.no +kvitsøy.no +kvafjord.no +kvæfjord.no +giehtavuoatna.no +kvanangen.no +kvænangen.no +navuotna.no +návuotna.no +kafjord.no +kåfjord.no +gaivuotna.no +gáivuotna.no +larvik.no +lavangen.no +lavagis.no +loabat.no +loabát.no +lebesby.no +davvesiida.no +leikanger.no +leirfjord.no +leka.no +leksvik.no +lenvik.no +leangaviika.no +leaŋgaviika.no +lesja.no +levanger.no +lier.no +lierne.no +lillehammer.no +lillesand.no +lindesnes.no +lindas.no +lindås.no +lom.no +loppa.no +lahppi.no +láhppi.no +lund.no +lunner.no +luroy.no +lurøy.no +luster.no +lyngdal.no +lyngen.no +ivgu.no +lardal.no +lerdal.no +lærdal.no +lodingen.no +lødingen.no +lorenskog.no +lørenskog.no +loten.no +løten.no +malvik.no +masoy.no +måsøy.no +muosat.no +muosát.no +mandal.no +marker.no +marnardal.no +masfjorden.no +meland.no +meldal.no +melhus.no +meloy.no +meløy.no +meraker.no +meråker.no +moareke.no +moåreke.no +midsund.no +midtre-gauldal.no +modalen.no +modum.no +molde.no +moskenes.no +moss.no +mosvik.no +malselv.no +målselv.no +malatvuopmi.no +málatvuopmi.no +namdalseid.no +aejrie.no +namsos.no +namsskogan.no +naamesjevuemie.no +nååmesjevuemie.no +laakesvuemie.no +nannestad.no +narvik.no +narviika.no +naustdal.no +nedre-eiker.no +nes.akershus.no +nes.buskerud.no +nesna.no +nesodden.no +nesseby.no +unjarga.no +unjárga.no +nesset.no +nissedal.no +nittedal.no +nord-aurdal.no +nord-fron.no +nord-odal.no +norddal.no +nordkapp.no +davvenjarga.no +davvenjárga.no +nordre-land.no +nordreisa.no +raisa.no +ráisa.no +nore-og-uvdal.no +notodden.no +naroy.no +nærøy.no +notteroy.no +nøtterøy.no +odda.no +oksnes.no +øksnes.no +oppdal.no +oppegard.no +oppegård.no +orkdal.no +orland.no +ørland.no +orskog.no +ørskog.no +orsta.no +ørsta.no +os.hedmark.no +os.hordaland.no +osen.no +osteroy.no +osterøy.no +ostre-toten.no +østre-toten.no +overhalla.no +ovre-eiker.no +øvre-eiker.no +oyer.no +øyer.no +oygarden.no +øygarden.no +oystre-slidre.no +øystre-slidre.no +porsanger.no +porsangu.no +porsáŋgu.no +porsgrunn.no +radoy.no +radøy.no +rakkestad.no +rana.no +ruovat.no +randaberg.no +rauma.no +rendalen.no +rennebu.no +rennesoy.no +rennesøy.no +rindal.no +ringebu.no +ringerike.no +ringsaker.no +rissa.no +risor.no +risør.no +roan.no +rollag.no +rygge.no +ralingen.no +rælingen.no +rodoy.no +rødøy.no +romskog.no +rømskog.no +roros.no +røros.no +rost.no +røst.no +royken.no +røyken.no +royrvik.no +røyrvik.no +rade.no +råde.no +salangen.no +siellak.no +saltdal.no +salat.no +sálát.no +sálat.no +samnanger.no +sande.more-og-romsdal.no +sande.møre-og-romsdal.no +sande.vestfold.no +sandefjord.no +sandnes.no +sandoy.no +sandøy.no +sarpsborg.no +sauda.no +sauherad.no +sel.no +selbu.no +selje.no +seljord.no +sigdal.no +siljan.no +sirdal.no +skaun.no +skedsmo.no +ski.no +skien.no +skiptvet.no +skjervoy.no +skjervøy.no +skierva.no +skiervá.no +skjak.no +skjåk.no +skodje.no +skanland.no +skånland.no +skanit.no +skánit.no +smola.no +smøla.no +snillfjord.no +snasa.no +snåsa.no +snoasa.no +snaase.no +snåase.no +sogndal.no +sokndal.no +sola.no +solund.no +songdalen.no +sortland.no +spydeberg.no +stange.no +stavanger.no +steigen.no +steinkjer.no +stjordal.no +stjørdal.no +stokke.no +stor-elvdal.no +stord.no +stordal.no +storfjord.no +omasvuotna.no +strand.no +stranda.no +stryn.no +sula.no +suldal.no +sund.no +sunndal.no +surnadal.no +sveio.no +svelvik.no +sykkylven.no +sogne.no +søgne.no +somna.no +sømna.no +sondre-land.no +søndre-land.no +sor-aurdal.no +sør-aurdal.no +sor-fron.no +sør-fron.no +sor-odal.no +sør-odal.no +sor-varanger.no +sør-varanger.no +matta-varjjat.no +mátta-várjjat.no +sorfold.no +sørfold.no +sorreisa.no +sørreisa.no +sorum.no +sørum.no +tana.no +deatnu.no +time.no +tingvoll.no +tinn.no +tjeldsund.no +dielddanuorri.no +tjome.no +tjøme.no +tokke.no +tolga.no +torsken.no +tranoy.no +tranøy.no +tromso.no +tromsø.no +tromsa.no +romsa.no +trondheim.no +troandin.no +trysil.no +trana.no +træna.no +trogstad.no +trøgstad.no +tvedestrand.no +tydal.no +tynset.no +tysfjord.no +divtasvuodna.no +divttasvuotna.no +tysnes.no +tysvar.no +tysvær.no +tonsberg.no +tønsberg.no +ullensaker.no +ullensvang.no +ulvik.no +utsira.no +vadso.no +vadsø.no +cahcesuolo.no +čáhcesuolo.no +vaksdal.no +valle.no +vang.no +vanylven.no +vardo.no +vardø.no +varggat.no +várggát.no +vefsn.no +vaapste.no +vega.no +vegarshei.no +vegårshei.no +vennesla.no +verdal.no +verran.no +vestby.no +vestnes.no +vestre-slidre.no +vestre-toten.no +vestvagoy.no +vestvågøy.no +vevelstad.no +vik.no +vikna.no +vindafjord.no +volda.no +voss.no +varoy.no +værøy.no +vagan.no +vågan.no +voagat.no +vagsoy.no +vågsøy.no +vaga.no +vågå.no +valer.ostfold.no +våler.østfold.no +valer.hedmark.no +våler.hedmark.no + +// np : http://www.mos.com.np/register.html +*.np + +// nr : http://cenpac.net.nr/dns/index.html +// Submitted by registry +nr +biz.nr +info.nr +gov.nr +edu.nr +org.nr +net.nr +com.nr + +// nu : https://en.wikipedia.org/wiki/.nu +nu + +// nz : https://en.wikipedia.org/wiki/.nz +// Submitted by registry +nz +ac.nz +co.nz +cri.nz +geek.nz +gen.nz +govt.nz +health.nz +iwi.nz +kiwi.nz +maori.nz +mil.nz +māori.nz +net.nz +org.nz +parliament.nz +school.nz + +// om : https://en.wikipedia.org/wiki/.om +om +co.om +com.om +edu.om +gov.om +med.om +museum.om +net.om +org.om +pro.om + +// onion : https://tools.ietf.org/html/rfc7686 +onion + +// org : https://en.wikipedia.org/wiki/.org +org + +// pa : http://www.nic.pa/ +// Some additional second level "domains" resolve directly as hostnames, such as +// pannet.pa, so we add a rule for "pa". +pa +ac.pa +gob.pa +com.pa +org.pa +sld.pa +edu.pa +net.pa +ing.pa +abo.pa +med.pa +nom.pa + +// pe : https://www.nic.pe/InformeFinalComision.pdf +pe +edu.pe +gob.pe +nom.pe +mil.pe +org.pe +com.pe +net.pe + +// pf : http://www.gobin.info/domainname/formulaire-pf.pdf +pf +com.pf +org.pf +edu.pf + +// pg : https://en.wikipedia.org/wiki/.pg +*.pg + +// ph : http://www.domains.ph/FAQ2.asp +// Submitted by registry +ph +com.ph +net.ph +org.ph +gov.ph +edu.ph +ngo.ph +mil.ph +i.ph + +// pk : http://pk5.pknic.net.pk/pk5/msgNamepk.PK +pk +com.pk +net.pk +edu.pk +org.pk +fam.pk +biz.pk +web.pk +gov.pk +gob.pk +gok.pk +gon.pk +gop.pk +gos.pk +info.pk + +// pl http://www.dns.pl/english/index.html +// Submitted by registry +pl +com.pl +net.pl +org.pl +// pl functional domains (http://www.dns.pl/english/index.html) +aid.pl +agro.pl +atm.pl +auto.pl +biz.pl +edu.pl +gmina.pl +gsm.pl +info.pl +mail.pl +miasta.pl +media.pl +mil.pl +nieruchomosci.pl +nom.pl +pc.pl +powiat.pl +priv.pl +realestate.pl +rel.pl +sex.pl +shop.pl +sklep.pl +sos.pl +szkola.pl +targi.pl +tm.pl +tourism.pl +travel.pl +turystyka.pl +// Government domains +gov.pl +ap.gov.pl +griw.gov.pl +ic.gov.pl +is.gov.pl +kmpsp.gov.pl +konsulat.gov.pl +kppsp.gov.pl +kwp.gov.pl +kwpsp.gov.pl +mup.gov.pl +mw.gov.pl +oia.gov.pl +oirm.gov.pl +oke.gov.pl +oow.gov.pl +oschr.gov.pl +oum.gov.pl +pa.gov.pl +pinb.gov.pl +piw.gov.pl +po.gov.pl +pr.gov.pl +psp.gov.pl +psse.gov.pl +pup.gov.pl +rzgw.gov.pl +sa.gov.pl +sdn.gov.pl +sko.gov.pl +so.gov.pl +sr.gov.pl +starostwo.gov.pl +ug.gov.pl +ugim.gov.pl +um.gov.pl +umig.gov.pl +upow.gov.pl +uppo.gov.pl +us.gov.pl +uw.gov.pl +uzs.gov.pl +wif.gov.pl +wiih.gov.pl +winb.gov.pl +wios.gov.pl +witd.gov.pl +wiw.gov.pl +wkz.gov.pl +wsa.gov.pl +wskr.gov.pl +wsse.gov.pl +wuoz.gov.pl +wzmiuw.gov.pl +zp.gov.pl +zpisdn.gov.pl +// pl regional domains (http://www.dns.pl/english/index.html) +augustow.pl +babia-gora.pl +bedzin.pl +beskidy.pl +bialowieza.pl +bialystok.pl +bielawa.pl +bieszczady.pl +boleslawiec.pl +bydgoszcz.pl +bytom.pl +cieszyn.pl +czeladz.pl +czest.pl +dlugoleka.pl +elblag.pl +elk.pl +glogow.pl +gniezno.pl +gorlice.pl +grajewo.pl +ilawa.pl +jaworzno.pl +jelenia-gora.pl +jgora.pl +kalisz.pl +kazimierz-dolny.pl +karpacz.pl +kartuzy.pl +kaszuby.pl +katowice.pl +kepno.pl +ketrzyn.pl +klodzko.pl +kobierzyce.pl +kolobrzeg.pl +konin.pl +konskowola.pl +kutno.pl +lapy.pl +lebork.pl +legnica.pl +lezajsk.pl +limanowa.pl +lomza.pl +lowicz.pl +lubin.pl +lukow.pl +malbork.pl +malopolska.pl +mazowsze.pl +mazury.pl +mielec.pl +mielno.pl +mragowo.pl +naklo.pl +nowaruda.pl +nysa.pl +olawa.pl +olecko.pl +olkusz.pl +olsztyn.pl +opoczno.pl +opole.pl +ostroda.pl +ostroleka.pl +ostrowiec.pl +ostrowwlkp.pl +pila.pl +pisz.pl +podhale.pl +podlasie.pl +polkowice.pl +pomorze.pl +pomorskie.pl +prochowice.pl +pruszkow.pl +przeworsk.pl +pulawy.pl +radom.pl +rawa-maz.pl +rybnik.pl +rzeszow.pl +sanok.pl +sejny.pl +slask.pl +slupsk.pl +sosnowiec.pl +stalowa-wola.pl +skoczow.pl +starachowice.pl +stargard.pl +suwalki.pl +swidnica.pl +swiebodzin.pl +swinoujscie.pl +szczecin.pl +szczytno.pl +tarnobrzeg.pl +tgory.pl +turek.pl +tychy.pl +ustka.pl +walbrzych.pl +warmia.pl +warszawa.pl +waw.pl +wegrow.pl +wielun.pl +wlocl.pl +wloclawek.pl +wodzislaw.pl +wolomin.pl +wroclaw.pl +zachpomor.pl +zagan.pl +zarow.pl +zgora.pl +zgorzelec.pl + +// pm : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf +pm + +// pn : http://www.government.pn/PnRegistry/policies.htm +pn +gov.pn +co.pn +org.pn +edu.pn +net.pn + +// post : https://en.wikipedia.org/wiki/.post +post + +// pr : http://www.nic.pr/index.asp?f=1 +pr +com.pr +net.pr +org.pr +gov.pr +edu.pr +isla.pr +pro.pr +biz.pr +info.pr +name.pr +// these aren't mentioned on nic.pr, but on https://en.wikipedia.org/wiki/.pr +est.pr +prof.pr +ac.pr + +// pro : http://registry.pro/get-pro +pro +aaa.pro +aca.pro +acct.pro +avocat.pro +bar.pro +cpa.pro +eng.pro +jur.pro +law.pro +med.pro +recht.pro + +// ps : https://en.wikipedia.org/wiki/.ps +// http://www.nic.ps/registration/policy.html#reg +ps +edu.ps +gov.ps +sec.ps +plo.ps +com.ps +org.ps +net.ps + +// pt : https://www.dns.pt/en/domain/pt-terms-and-conditions-registration-rules/ +pt +net.pt +gov.pt +org.pt +edu.pt +int.pt +publ.pt +com.pt +nome.pt + +// pw : https://en.wikipedia.org/wiki/.pw +pw +co.pw +ne.pw +or.pw +ed.pw +go.pw +belau.pw + +// py : http://www.nic.py/pautas.html#seccion_9 +// Submitted by registry +py +com.py +coop.py +edu.py +gov.py +mil.py +net.py +org.py + +// qa : http://domains.qa/en/ +qa +com.qa +edu.qa +gov.qa +mil.qa +name.qa +net.qa +org.qa +sch.qa + +// re : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf +re +asso.re +com.re +nom.re + +// ro : http://www.rotld.ro/ +ro +arts.ro +com.ro +firm.ro +info.ro +nom.ro +nt.ro +org.ro +rec.ro +store.ro +tm.ro +www.ro + +// rs : https://www.rnids.rs/en/domains/national-domains +rs +ac.rs +co.rs +edu.rs +gov.rs +in.rs +org.rs + +// ru : https://cctld.ru/files/pdf/docs/en/rules_ru-rf.pdf +// Submitted by George Georgievsky +ru + +// rw : https://www.ricta.org.rw/sites/default/files/resources/registry_registrar_contract_0.pdf +rw +ac.rw +co.rw +coop.rw +gov.rw +mil.rw +net.rw +org.rw + +// sa : http://www.nic.net.sa/ +sa +com.sa +net.sa +org.sa +gov.sa +med.sa +pub.sa +edu.sa +sch.sa + +// sb : http://www.sbnic.net.sb/ +// Submitted by registry +sb +com.sb +edu.sb +gov.sb +net.sb +org.sb + +// sc : http://www.nic.sc/ +sc +com.sc +gov.sc +net.sc +org.sc +edu.sc + +// sd : http://www.isoc.sd/sudanic.isoc.sd/billing_pricing.htm +// Submitted by registry +sd +com.sd +net.sd +org.sd +edu.sd +med.sd +tv.sd +gov.sd +info.sd + +// se : https://en.wikipedia.org/wiki/.se +// Submitted by registry +se +a.se +ac.se +b.se +bd.se +brand.se +c.se +d.se +e.se +f.se +fh.se +fhsk.se +fhv.se +g.se +h.se +i.se +k.se +komforb.se +kommunalforbund.se +komvux.se +l.se +lanbib.se +m.se +n.se +naturbruksgymn.se +o.se +org.se +p.se +parti.se +pp.se +press.se +r.se +s.se +t.se +tm.se +u.se +w.se +x.se +y.se +z.se + +// sg : http://www.nic.net.sg/page/registration-policies-procedures-and-guidelines +sg +com.sg +net.sg +org.sg +gov.sg +edu.sg +per.sg + +// sh : http://nic.sh/rules.htm +sh +com.sh +net.sh +gov.sh +org.sh +mil.sh + +// si : https://en.wikipedia.org/wiki/.si +si + +// sj : No registrations at this time. +// Submitted by registry +sj + +// sk : https://en.wikipedia.org/wiki/.sk +// list of 2nd level domains ? +sk + +// sl : http://www.nic.sl +// Submitted by registry +sl +com.sl +net.sl +edu.sl +gov.sl +org.sl + +// sm : https://en.wikipedia.org/wiki/.sm +sm + +// sn : https://en.wikipedia.org/wiki/.sn +sn +art.sn +com.sn +edu.sn +gouv.sn +org.sn +perso.sn +univ.sn + +// so : http://sonic.so/policies/ +so +com.so +edu.so +gov.so +me.so +net.so +org.so + +// sr : https://en.wikipedia.org/wiki/.sr +sr + +// ss : https://registry.nic.ss/ +// Submitted by registry +ss +biz.ss +com.ss +edu.ss +gov.ss +me.ss +net.ss +org.ss +sch.ss + +// st : http://www.nic.st/html/policyrules/ +st +co.st +com.st +consulado.st +edu.st +embaixada.st +mil.st +net.st +org.st +principe.st +saotome.st +store.st + +// su : https://en.wikipedia.org/wiki/.su +su + +// sv : http://www.svnet.org.sv/niveldos.pdf +sv +com.sv +edu.sv +gob.sv +org.sv +red.sv + +// sx : https://en.wikipedia.org/wiki/.sx +// Submitted by registry +sx +gov.sx + +// sy : https://en.wikipedia.org/wiki/.sy +// see also: http://www.gobin.info/domainname/sy.doc +sy +edu.sy +gov.sy +net.sy +mil.sy +com.sy +org.sy + +// sz : https://en.wikipedia.org/wiki/.sz +// http://www.sispa.org.sz/ +sz +co.sz +ac.sz +org.sz + +// tc : https://en.wikipedia.org/wiki/.tc +tc + +// td : https://en.wikipedia.org/wiki/.td +td + +// tel: https://en.wikipedia.org/wiki/.tel +// http://www.telnic.org/ +tel + +// tf : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf +tf + +// tg : https://en.wikipedia.org/wiki/.tg +// http://www.nic.tg/ +tg + +// th : https://en.wikipedia.org/wiki/.th +// Submitted by registry +th +ac.th +co.th +go.th +in.th +mi.th +net.th +or.th + +// tj : http://www.nic.tj/policy.html +tj +ac.tj +biz.tj +co.tj +com.tj +edu.tj +go.tj +gov.tj +int.tj +mil.tj +name.tj +net.tj +nic.tj +org.tj +test.tj +web.tj + +// tk : https://en.wikipedia.org/wiki/.tk +tk + +// tl : https://en.wikipedia.org/wiki/.tl +tl +gov.tl + +// tm : http://www.nic.tm/local.html +tm +com.tm +co.tm +org.tm +net.tm +nom.tm +gov.tm +mil.tm +edu.tm + +// tn : http://www.registre.tn/fr/ +// https://whois.ati.tn/ +tn +com.tn +ens.tn +fin.tn +gov.tn +ind.tn +info.tn +intl.tn +mincom.tn +nat.tn +net.tn +org.tn +perso.tn +tourism.tn + +// to : https://en.wikipedia.org/wiki/.to +// Submitted by registry +to +com.to +gov.to +net.to +org.to +edu.to +mil.to + +// tr : https://nic.tr/ +// https://nic.tr/forms/eng/policies.pdf +// https://nic.tr/index.php?USRACTN=PRICELST +tr +av.tr +bbs.tr +bel.tr +biz.tr +com.tr +dr.tr +edu.tr +gen.tr +gov.tr +info.tr +mil.tr +k12.tr +kep.tr +name.tr +net.tr +org.tr +pol.tr +tel.tr +tsk.tr +tv.tr +web.tr +// Used by Northern Cyprus +nc.tr +// Used by government agencies of Northern Cyprus +gov.nc.tr + +// tt : http://www.nic.tt/ +tt +co.tt +com.tt +org.tt +net.tt +biz.tt +info.tt +pro.tt +int.tt +coop.tt +jobs.tt +mobi.tt +travel.tt +museum.tt +aero.tt +name.tt +gov.tt +edu.tt + +// tv : https://en.wikipedia.org/wiki/.tv +// Not listing any 2LDs as reserved since none seem to exist in practice, +// Wikipedia notwithstanding. +tv + +// tw : https://en.wikipedia.org/wiki/.tw +tw +edu.tw +gov.tw +mil.tw +com.tw +net.tw +org.tw +idv.tw +game.tw +ebiz.tw +club.tw +網路.tw +組織.tw +商業.tw + +// tz : http://www.tznic.or.tz/index.php/domains +// Submitted by registry +tz +ac.tz +co.tz +go.tz +hotel.tz +info.tz +me.tz +mil.tz +mobi.tz +ne.tz +or.tz +sc.tz +tv.tz + +// ua : https://hostmaster.ua/policy/?ua +// Submitted by registry +ua +// ua 2LD +com.ua +edu.ua +gov.ua +in.ua +net.ua +org.ua +// ua geographic names +// https://hostmaster.ua/2ld/ +cherkassy.ua +cherkasy.ua +chernigov.ua +chernihiv.ua +chernivtsi.ua +chernovtsy.ua +ck.ua +cn.ua +cr.ua +crimea.ua +cv.ua +dn.ua +dnepropetrovsk.ua +dnipropetrovsk.ua +donetsk.ua +dp.ua +if.ua +ivano-frankivsk.ua +kh.ua +kharkiv.ua +kharkov.ua +kherson.ua +khmelnitskiy.ua +khmelnytskyi.ua +kiev.ua +kirovograd.ua +km.ua +kr.ua +kropyvnytskyi.ua +krym.ua +ks.ua +kv.ua +kyiv.ua +lg.ua +lt.ua +lugansk.ua +luhansk.ua +lutsk.ua +lv.ua +lviv.ua +mk.ua +mykolaiv.ua +nikolaev.ua +od.ua +odesa.ua +odessa.ua +pl.ua +poltava.ua +rivne.ua +rovno.ua +rv.ua +sb.ua +sebastopol.ua +sevastopol.ua +sm.ua +sumy.ua +te.ua +ternopil.ua +uz.ua +uzhgorod.ua +uzhhorod.ua +vinnica.ua +vinnytsia.ua +vn.ua +volyn.ua +yalta.ua +zakarpattia.ua +zaporizhzhe.ua +zaporizhzhia.ua +zhitomir.ua +zhytomyr.ua +zp.ua +zt.ua + +// ug : https://www.registry.co.ug/ +ug +co.ug +or.ug +ac.ug +sc.ug +go.ug +ne.ug +com.ug +org.ug + +// uk : https://en.wikipedia.org/wiki/.uk +// Submitted by registry +uk +ac.uk +co.uk +gov.uk +ltd.uk +me.uk +net.uk +nhs.uk +org.uk +plc.uk +police.uk +*.sch.uk + +// us : https://en.wikipedia.org/wiki/.us +us +dni.us +fed.us +isa.us +kids.us +nsn.us +// us geographic names +ak.us +al.us +ar.us +as.us +az.us +ca.us +co.us +ct.us +dc.us +de.us +fl.us +ga.us +gu.us +hi.us +ia.us +id.us +il.us +in.us +ks.us +ky.us +la.us +ma.us +md.us +me.us +mi.us +mn.us +mo.us +ms.us +mt.us +nc.us +nd.us +ne.us +nh.us +nj.us +nm.us +nv.us +ny.us +oh.us +ok.us +or.us +pa.us +pr.us +ri.us +sc.us +sd.us +tn.us +tx.us +ut.us +vi.us +vt.us +va.us +wa.us +wi.us +wv.us +wy.us +// The registrar notes several more specific domains available in each state, +// such as state.*.us, dst.*.us, etc., but resolution of these is somewhat +// haphazard; in some states these domains resolve as addresses, while in others +// only subdomains are available, or even nothing at all. We include the +// most common ones where it's clear that different sites are different +// entities. +k12.ak.us +k12.al.us +k12.ar.us +k12.as.us +k12.az.us +k12.ca.us +k12.co.us +k12.ct.us +k12.dc.us +k12.fl.us +k12.ga.us +k12.gu.us +// k12.hi.us Bug 614565 - Hawaii has a state-wide DOE login +k12.ia.us +k12.id.us +k12.il.us +k12.in.us +k12.ks.us +k12.ky.us +k12.la.us +k12.ma.us +k12.md.us +k12.me.us +k12.mi.us +k12.mn.us +k12.mo.us +k12.ms.us +k12.mt.us +k12.nc.us +// k12.nd.us Bug 1028347 - Removed at request of Travis Rosso +k12.ne.us +k12.nh.us +k12.nj.us +k12.nm.us +k12.nv.us +k12.ny.us +k12.oh.us +k12.ok.us +k12.or.us +k12.pa.us +k12.pr.us +// k12.ri.us Removed at request of Kim Cournoyer +k12.sc.us +// k12.sd.us Bug 934131 - Removed at request of James Booze +k12.tn.us +k12.tx.us +k12.ut.us +k12.vi.us +k12.vt.us +k12.va.us +k12.wa.us +k12.wi.us +// k12.wv.us Bug 947705 - Removed at request of Verne Britton +k12.wy.us +cc.ak.us +cc.al.us +cc.ar.us +cc.as.us +cc.az.us +cc.ca.us +cc.co.us +cc.ct.us +cc.dc.us +cc.de.us +cc.fl.us +cc.ga.us +cc.gu.us +cc.hi.us +cc.ia.us +cc.id.us +cc.il.us +cc.in.us +cc.ks.us +cc.ky.us +cc.la.us +cc.ma.us +cc.md.us +cc.me.us +cc.mi.us +cc.mn.us +cc.mo.us +cc.ms.us +cc.mt.us +cc.nc.us +cc.nd.us +cc.ne.us +cc.nh.us +cc.nj.us +cc.nm.us +cc.nv.us +cc.ny.us +cc.oh.us +cc.ok.us +cc.or.us +cc.pa.us +cc.pr.us +cc.ri.us +cc.sc.us +cc.sd.us +cc.tn.us +cc.tx.us +cc.ut.us +cc.vi.us +cc.vt.us +cc.va.us +cc.wa.us +cc.wi.us +cc.wv.us +cc.wy.us +lib.ak.us +lib.al.us +lib.ar.us +lib.as.us +lib.az.us +lib.ca.us +lib.co.us +lib.ct.us +lib.dc.us +// lib.de.us Issue #243 - Moved to Private section at request of Ed Moore +lib.fl.us +lib.ga.us +lib.gu.us +lib.hi.us +lib.ia.us +lib.id.us +lib.il.us +lib.in.us +lib.ks.us +lib.ky.us +lib.la.us +lib.ma.us +lib.md.us +lib.me.us +lib.mi.us +lib.mn.us +lib.mo.us +lib.ms.us +lib.mt.us +lib.nc.us +lib.nd.us +lib.ne.us +lib.nh.us +lib.nj.us +lib.nm.us +lib.nv.us +lib.ny.us +lib.oh.us +lib.ok.us +lib.or.us +lib.pa.us +lib.pr.us +lib.ri.us +lib.sc.us +lib.sd.us +lib.tn.us +lib.tx.us +lib.ut.us +lib.vi.us +lib.vt.us +lib.va.us +lib.wa.us +lib.wi.us +// lib.wv.us Bug 941670 - Removed at request of Larry W Arnold +lib.wy.us +// k12.ma.us contains school districts in Massachusetts. The 4LDs are +// managed independently except for private (PVT), charter (CHTR) and +// parochial (PAROCH) schools. Those are delegated directly to the +// 5LD operators. +pvt.k12.ma.us +chtr.k12.ma.us +paroch.k12.ma.us +// Merit Network, Inc. maintains the registry for =~ /(k12|cc|lib).mi.us/ and the following +// see also: http://domreg.merit.edu +// see also: whois -h whois.domreg.merit.edu help +ann-arbor.mi.us +cog.mi.us +dst.mi.us +eaton.mi.us +gen.mi.us +mus.mi.us +tec.mi.us +washtenaw.mi.us + +// uy : http://www.nic.org.uy/ +uy +com.uy +edu.uy +gub.uy +mil.uy +net.uy +org.uy + +// uz : http://www.reg.uz/ +uz +co.uz +com.uz +net.uz +org.uz + +// va : https://en.wikipedia.org/wiki/.va +va + +// vc : https://en.wikipedia.org/wiki/.vc +// Submitted by registry +vc +com.vc +net.vc +org.vc +gov.vc +mil.vc +edu.vc + +// ve : https://registro.nic.ve/ +// Submitted by registry nic@nic.ve and nicve@conatel.gob.ve +ve +arts.ve +bib.ve +co.ve +com.ve +e12.ve +edu.ve +firm.ve +gob.ve +gov.ve +info.ve +int.ve +mil.ve +net.ve +nom.ve +org.ve +rar.ve +rec.ve +store.ve +tec.ve +web.ve + +// vg : https://en.wikipedia.org/wiki/.vg +vg + +// vi : http://www.nic.vi/newdomainform.htm +// http://www.nic.vi/Domain_Rules/body_domain_rules.html indicates some other +// TLDs are "reserved", such as edu.vi and gov.vi, but doesn't actually say they +// are available for registration (which they do not seem to be). +vi +co.vi +com.vi +k12.vi +net.vi +org.vi + +// vn : https://www.vnnic.vn/en/domain/cctld-vn +// https://vnnic.vn/sites/default/files/tailieu/vn.cctld.domains.txt +vn +ac.vn +ai.vn +biz.vn +com.vn +edu.vn +gov.vn +health.vn +id.vn +info.vn +int.vn +io.vn +name.vn +net.vn +org.vn +pro.vn + +// vn geographical names +angiang.vn +bacgiang.vn +backan.vn +baclieu.vn +bacninh.vn +baria-vungtau.vn +bentre.vn +binhdinh.vn +binhduong.vn +binhphuoc.vn +binhthuan.vn +camau.vn +cantho.vn +caobang.vn +daklak.vn +daknong.vn +danang.vn +dienbien.vn +dongnai.vn +dongthap.vn +gialai.vn +hagiang.vn +haiduong.vn +haiphong.vn +hanam.vn +hanoi.vn +hatinh.vn +haugiang.vn +hoabinh.vn +hungyen.vn +khanhhoa.vn +kiengiang.vn +kontum.vn +laichau.vn +lamdong.vn +langson.vn +laocai.vn +longan.vn +namdinh.vn +nghean.vn +ninhbinh.vn +ninhthuan.vn +phutho.vn +phuyen.vn +quangbinh.vn +quangnam.vn +quangngai.vn +quangninh.vn +quangtri.vn +soctrang.vn +sonla.vn +tayninh.vn +thaibinh.vn +thainguyen.vn +thanhhoa.vn +thanhphohochiminh.vn +thuathienhue.vn +tiengiang.vn +travinh.vn +tuyenquang.vn +vinhlong.vn +vinhphuc.vn +yenbai.vn + +// vu : https://en.wikipedia.org/wiki/.vu +// http://www.vunic.vu/ +vu +com.vu +edu.vu +net.vu +org.vu + +// wf : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf +wf + +// ws : https://en.wikipedia.org/wiki/.ws +// http://samoanic.ws/index.dhtml +ws +com.ws +net.ws +org.ws +gov.ws +edu.ws + +// yt : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf +yt + +// IDN ccTLDs +// When submitting patches, please maintain a sort by ISO 3166 ccTLD, then +// U-label, and follow this format: +// // A-Label ("", [, variant info]) : +// // [sponsoring org] +// U-Label + +// xn--mgbaam7a8h ("Emerat", Arabic) : AE +// http://nic.ae/english/arabicdomain/rules.jsp +امارات + +// xn--y9a3aq ("hye", Armenian) : AM +// ISOC AM (operated by .am Registry) +հայ + +// xn--54b7fta0cc ("Bangla", Bangla) : BD +বাংলা + +// xn--90ae ("bg", Bulgarian) : BG +бг + +// xn--mgbcpq6gpa1a ("albahrain", Arabic) : BH +البحرين + +// xn--90ais ("bel", Belarusian/Russian Cyrillic) : BY +// Operated by .by registry +бел + +// xn--fiqs8s ("Zhongguo/China", Chinese, Simplified) : CN +// CNNIC +// http://cnnic.cn/html/Dir/2005/10/11/3218.htm +中国 + +// xn--fiqz9s ("Zhongguo/China", Chinese, Traditional) : CN +// CNNIC +// http://cnnic.cn/html/Dir/2005/10/11/3218.htm +中國 + +// xn--lgbbat1ad8j ("Algeria/Al Jazair", Arabic) : DZ +الجزائر + +// xn--wgbh1c ("Egypt/Masr", Arabic) : EG +// http://www.dotmasr.eg/ +مصر + +// xn--e1a4c ("eu", Cyrillic) : EU +// https://eurid.eu +ею + +// xn--qxa6a ("eu", Greek) : EU +// https://eurid.eu +ευ + +// xn--mgbah1a3hjkrd ("Mauritania", Arabic) : MR +موريتانيا + +// xn--node ("ge", Georgian Mkhedruli) : GE +გე + +// xn--qxam ("el", Greek) : GR +// Hellenic Ministry of Infrastructure, Transport, and Networks +ελ + +// xn--j6w193g ("Hong Kong", Chinese) : HK +// https://www.hkirc.hk +// Submitted by registry +// https://www.hkirc.hk/content.jsp?id=30#!/34 +香港 +公司.香港 +教育.香港 +政府.香港 +個人.香港 +網絡.香港 +組織.香港 + +// xn--2scrj9c ("Bharat", Kannada) : IN +// India +ಭಾರತ + +// xn--3hcrj9c ("Bharat", Oriya) : IN +// India +ଭାରତ + +// xn--45br5cyl ("Bharatam", Assamese) : IN +// India +ভাৰত + +// xn--h2breg3eve ("Bharatam", Sanskrit) : IN +// India +भारतम् + +// xn--h2brj9c8c ("Bharot", Santali) : IN +// India +भारोत + +// xn--mgbgu82a ("Bharat", Sindhi) : IN +// India +ڀارت + +// xn--rvc1e0am3e ("Bharatam", Malayalam) : IN +// India +ഭാരതം + +// xn--h2brj9c ("Bharat", Devanagari) : IN +// India +भारत + +// xn--mgbbh1a ("Bharat", Kashmiri) : IN +// India +بارت + +// xn--mgbbh1a71e ("Bharat", Arabic) : IN +// India +بھارت + +// xn--fpcrj9c3d ("Bharat", Telugu) : IN +// India +భారత్ + +// xn--gecrj9c ("Bharat", Gujarati) : IN +// India +ભારત + +// xn--s9brj9c ("Bharat", Gurmukhi) : IN +// India +ਭਾਰਤ + +// xn--45brj9c ("Bharat", Bengali) : IN +// India +ভারত + +// xn--xkc2dl3a5ee0h ("India", Tamil) : IN +// India +இந்தியா + +// xn--mgba3a4f16a ("Iran", Persian) : IR +ایران + +// xn--mgba3a4fra ("Iran", Arabic) : IR +ايران + +// xn--mgbtx2b ("Iraq", Arabic) : IQ +// Communications and Media Commission +عراق + +// xn--mgbayh7gpa ("al-Ordon", Arabic) : JO +// National Information Technology Center (NITC) +// Royal Scientific Society, Al-Jubeiha +الاردن + +// xn--3e0b707e ("Republic of Korea", Hangul) : KR +한국 + +// xn--80ao21a ("Kaz", Kazakh) : KZ +қаз + +// xn--q7ce6a ("Lao", Lao) : LA +ລາວ + +// xn--fzc2c9e2c ("Lanka", Sinhalese-Sinhala) : LK +// https://nic.lk +ලංකා + +// xn--xkc2al3hye2a ("Ilangai", Tamil) : LK +// https://nic.lk +இலங்கை + +// xn--mgbc0a9azcg ("Morocco/al-Maghrib", Arabic) : MA +المغرب + +// xn--d1alf ("mkd", Macedonian) : MK +// MARnet +мкд + +// xn--l1acc ("mon", Mongolian) : MN +мон + +// xn--mix891f ("Macao", Chinese, Traditional) : MO +// MONIC / HNET Asia (Registry Operator for .mo) +澳門 + +// xn--mix082f ("Macao", Chinese, Simplified) : MO +澳门 + +// xn--mgbx4cd0ab ("Malaysia", Malay) : MY +مليسيا + +// xn--mgb9awbf ("Oman", Arabic) : OM +عمان + +// xn--mgbai9azgqp6j ("Pakistan", Urdu/Arabic) : PK +پاکستان + +// xn--mgbai9a5eva00b ("Pakistan", Urdu/Arabic, variant) : PK +پاكستان + +// xn--ygbi2ammx ("Falasteen", Arabic) : PS +// The Palestinian National Internet Naming Authority (PNINA) +// http://www.pnina.ps +فلسطين + +// xn--90a3ac ("srb", Cyrillic) : RS +// https://www.rnids.rs/en/domains/national-domains +срб +пр.срб +орг.срб +обр.срб +од.срб +упр.срб +ак.срб + +// xn--p1ai ("rf", Russian-Cyrillic) : RU +// https://cctld.ru/files/pdf/docs/en/rules_ru-rf.pdf +// Submitted by George Georgievsky +рф + +// xn--wgbl6a ("Qatar", Arabic) : QA +// http://www.ict.gov.qa/ +قطر + +// xn--mgberp4a5d4ar ("AlSaudiah", Arabic) : SA +// http://www.nic.net.sa/ +السعودية + +// xn--mgberp4a5d4a87g ("AlSaudiah", Arabic, variant) : SA +السعودیة + +// xn--mgbqly7c0a67fbc ("AlSaudiah", Arabic, variant) : SA +السعودیۃ + +// xn--mgbqly7cvafr ("AlSaudiah", Arabic, variant) : SA +السعوديه + +// xn--mgbpl2fh ("sudan", Arabic) : SD +// Operated by .sd registry +سودان + +// xn--yfro4i67o Singapore ("Singapore", Chinese) : SG +新加坡 + +// xn--clchc0ea0b2g2a9gcd ("Singapore", Tamil) : SG +சிங்கப்பூர் + +// xn--ogbpf8fl ("Syria", Arabic) : SY +سورية + +// xn--mgbtf8fl ("Syria", Arabic, variant) : SY +سوريا + +// xn--o3cw4h ("Thai", Thai) : TH +// http://www.thnic.co.th +ไทย +ศึกษา.ไทย +ธุรกิจ.ไทย +รัฐบาล.ไทย +ทหาร.ไทย +เน็ต.ไทย +องค์กร.ไทย + +// xn--pgbs0dh ("Tunisia", Arabic) : TN +// http://nic.tn +تونس + +// xn--kpry57d ("Taiwan", Chinese, Traditional) : TW +// http://www.twnic.net/english/dn/dn_07a.htm +台灣 + +// xn--kprw13d ("Taiwan", Chinese, Simplified) : TW +// http://www.twnic.net/english/dn/dn_07a.htm +台湾 + +// xn--nnx388a ("Taiwan", Chinese, variant) : TW +臺灣 + +// xn--j1amh ("ukr", Cyrillic) : UA +укр + +// xn--mgb2ddes ("AlYemen", Arabic) : YE +اليمن + +// xxx : http://icmregistry.com +xxx + +// ye : http://www.y.net.ye/services/domain_name.htm +ye +com.ye +edu.ye +gov.ye +net.ye +mil.ye +org.ye + +// za : https://www.zadna.org.za/content/page/domain-information/ +ac.za +agric.za +alt.za +co.za +edu.za +gov.za +grondar.za +law.za +mil.za +net.za +ngo.za +nic.za +nis.za +nom.za +org.za +school.za +tm.za +web.za + +// zm : https://zicta.zm/ +// Submitted by registry +zm +ac.zm +biz.zm +co.zm +com.zm +edu.zm +gov.zm +info.zm +mil.zm +net.zm +org.zm +sch.zm + +// zw : https://www.potraz.gov.zw/ +// Confirmed by registry 2017-01-25 +zw +ac.zw +co.zw +gov.zw +mil.zw +org.zw + + +// newGTLDs + +// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2024-07-12T15:14:39Z +// This list is auto-generated, don't edit it manually. +// aaa : American Automobile Association, Inc. +// https://www.iana.org/domains/root/db/aaa.html +aaa + +// aarp : AARP +// https://www.iana.org/domains/root/db/aarp.html +aarp + +// abb : ABB Ltd +// https://www.iana.org/domains/root/db/abb.html +abb + +// abbott : Abbott Laboratories, Inc. +// https://www.iana.org/domains/root/db/abbott.html +abbott + +// abbvie : AbbVie Inc. +// https://www.iana.org/domains/root/db/abbvie.html +abbvie + +// abc : Disney Enterprises, Inc. +// https://www.iana.org/domains/root/db/abc.html +abc + +// able : Able Inc. +// https://www.iana.org/domains/root/db/able.html +able + +// abogado : Registry Services, LLC +// https://www.iana.org/domains/root/db/abogado.html +abogado + +// abudhabi : Abu Dhabi Systems and Information Centre +// https://www.iana.org/domains/root/db/abudhabi.html +abudhabi + +// academy : Binky Moon, LLC +// https://www.iana.org/domains/root/db/academy.html +academy + +// accenture : Accenture plc +// https://www.iana.org/domains/root/db/accenture.html +accenture + +// accountant : dot Accountant Limited +// https://www.iana.org/domains/root/db/accountant.html +accountant + +// accountants : Binky Moon, LLC +// https://www.iana.org/domains/root/db/accountants.html +accountants + +// aco : ACO Severin Ahlmann GmbH & Co. KG +// https://www.iana.org/domains/root/db/aco.html +aco + +// actor : Dog Beach, LLC +// https://www.iana.org/domains/root/db/actor.html +actor + +// ads : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/ads.html +ads + +// adult : ICM Registry AD LLC +// https://www.iana.org/domains/root/db/adult.html +adult + +// aeg : Aktiebolaget Electrolux +// https://www.iana.org/domains/root/db/aeg.html +aeg + +// aetna : Aetna Life Insurance Company +// https://www.iana.org/domains/root/db/aetna.html +aetna + +// afl : Australian Football League +// https://www.iana.org/domains/root/db/afl.html +afl + +// africa : ZA Central Registry NPC trading as Registry.Africa +// https://www.iana.org/domains/root/db/africa.html +africa + +// agakhan : Fondation Aga Khan (Aga Khan Foundation) +// https://www.iana.org/domains/root/db/agakhan.html +agakhan + +// agency : Binky Moon, LLC +// https://www.iana.org/domains/root/db/agency.html +agency + +// aig : American International Group, Inc. +// https://www.iana.org/domains/root/db/aig.html +aig + +// airbus : Airbus S.A.S. +// https://www.iana.org/domains/root/db/airbus.html +airbus + +// airforce : Dog Beach, LLC +// https://www.iana.org/domains/root/db/airforce.html +airforce + +// airtel : Bharti Airtel Limited +// https://www.iana.org/domains/root/db/airtel.html +airtel + +// akdn : Fondation Aga Khan (Aga Khan Foundation) +// https://www.iana.org/domains/root/db/akdn.html +akdn + +// alibaba : Alibaba Group Holding Limited +// https://www.iana.org/domains/root/db/alibaba.html +alibaba + +// alipay : Alibaba Group Holding Limited +// https://www.iana.org/domains/root/db/alipay.html +alipay + +// allfinanz : Allfinanz Deutsche Vermögensberatung Aktiengesellschaft +// https://www.iana.org/domains/root/db/allfinanz.html +allfinanz + +// allstate : Allstate Fire and Casualty Insurance Company +// https://www.iana.org/domains/root/db/allstate.html +allstate + +// ally : Ally Financial Inc. +// https://www.iana.org/domains/root/db/ally.html +ally + +// alsace : Region Grand Est +// https://www.iana.org/domains/root/db/alsace.html +alsace + +// alstom : ALSTOM +// https://www.iana.org/domains/root/db/alstom.html +alstom + +// amazon : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/amazon.html +amazon + +// americanexpress : American Express Travel Related Services Company, Inc. +// https://www.iana.org/domains/root/db/americanexpress.html +americanexpress + +// americanfamily : AmFam, Inc. +// https://www.iana.org/domains/root/db/americanfamily.html +americanfamily + +// amex : American Express Travel Related Services Company, Inc. +// https://www.iana.org/domains/root/db/amex.html +amex + +// amfam : AmFam, Inc. +// https://www.iana.org/domains/root/db/amfam.html +amfam + +// amica : Amica Mutual Insurance Company +// https://www.iana.org/domains/root/db/amica.html +amica + +// amsterdam : Gemeente Amsterdam +// https://www.iana.org/domains/root/db/amsterdam.html +amsterdam + +// analytics : Campus IP LLC +// https://www.iana.org/domains/root/db/analytics.html +analytics + +// android : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/android.html +android + +// anquan : Beijing Qihu Keji Co., Ltd. +// https://www.iana.org/domains/root/db/anquan.html +anquan + +// anz : Australia and New Zealand Banking Group Limited +// https://www.iana.org/domains/root/db/anz.html +anz + +// aol : Yahoo Inc. +// https://www.iana.org/domains/root/db/aol.html +aol + +// apartments : Binky Moon, LLC +// https://www.iana.org/domains/root/db/apartments.html +apartments + +// app : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/app.html +app + +// apple : Apple Inc. +// https://www.iana.org/domains/root/db/apple.html +apple + +// aquarelle : Aquarelle.com +// https://www.iana.org/domains/root/db/aquarelle.html +aquarelle + +// arab : League of Arab States +// https://www.iana.org/domains/root/db/arab.html +arab + +// aramco : Aramco Services Company +// https://www.iana.org/domains/root/db/aramco.html +aramco + +// archi : Identity Digital Limited +// https://www.iana.org/domains/root/db/archi.html +archi + +// army : Dog Beach, LLC +// https://www.iana.org/domains/root/db/army.html +army + +// art : UK Creative Ideas Limited +// https://www.iana.org/domains/root/db/art.html +art + +// arte : Association Relative à la Télévision Européenne G.E.I.E. +// https://www.iana.org/domains/root/db/arte.html +arte + +// asda : Wal-Mart Stores, Inc. +// https://www.iana.org/domains/root/db/asda.html +asda + +// associates : Binky Moon, LLC +// https://www.iana.org/domains/root/db/associates.html +associates + +// athleta : The Gap, Inc. +// https://www.iana.org/domains/root/db/athleta.html +athleta + +// attorney : Dog Beach, LLC +// https://www.iana.org/domains/root/db/attorney.html +attorney + +// auction : Dog Beach, LLC +// https://www.iana.org/domains/root/db/auction.html +auction + +// audi : AUDI Aktiengesellschaft +// https://www.iana.org/domains/root/db/audi.html +audi + +// audible : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/audible.html +audible + +// audio : XYZ.COM LLC +// https://www.iana.org/domains/root/db/audio.html +audio + +// auspost : Australian Postal Corporation +// https://www.iana.org/domains/root/db/auspost.html +auspost + +// author : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/author.html +author + +// auto : XYZ.COM LLC +// https://www.iana.org/domains/root/db/auto.html +auto + +// autos : XYZ.COM LLC +// https://www.iana.org/domains/root/db/autos.html +autos + +// aws : AWS Registry LLC +// https://www.iana.org/domains/root/db/aws.html +aws + +// axa : AXA Group Operations SAS +// https://www.iana.org/domains/root/db/axa.html +axa + +// azure : Microsoft Corporation +// https://www.iana.org/domains/root/db/azure.html +azure + +// baby : XYZ.COM LLC +// https://www.iana.org/domains/root/db/baby.html +baby + +// baidu : Baidu, Inc. +// https://www.iana.org/domains/root/db/baidu.html +baidu + +// banamex : Citigroup Inc. +// https://www.iana.org/domains/root/db/banamex.html +banamex + +// band : Dog Beach, LLC +// https://www.iana.org/domains/root/db/band.html +band + +// bank : fTLD Registry Services LLC +// https://www.iana.org/domains/root/db/bank.html +bank + +// bar : Punto 2012 Sociedad Anonima Promotora de Inversion de Capital Variable +// https://www.iana.org/domains/root/db/bar.html +bar + +// barcelona : Municipi de Barcelona +// https://www.iana.org/domains/root/db/barcelona.html +barcelona + +// barclaycard : Barclays Bank PLC +// https://www.iana.org/domains/root/db/barclaycard.html +barclaycard + +// barclays : Barclays Bank PLC +// https://www.iana.org/domains/root/db/barclays.html +barclays + +// barefoot : Gallo Vineyards, Inc. +// https://www.iana.org/domains/root/db/barefoot.html +barefoot + +// bargains : Binky Moon, LLC +// https://www.iana.org/domains/root/db/bargains.html +bargains + +// baseball : MLB Advanced Media DH, LLC +// https://www.iana.org/domains/root/db/baseball.html +baseball + +// basketball : Fédération Internationale de Basketball (FIBA) +// https://www.iana.org/domains/root/db/basketball.html +basketball + +// bauhaus : Werkhaus GmbH +// https://www.iana.org/domains/root/db/bauhaus.html +bauhaus + +// bayern : Bayern Connect GmbH +// https://www.iana.org/domains/root/db/bayern.html +bayern + +// bbc : British Broadcasting Corporation +// https://www.iana.org/domains/root/db/bbc.html +bbc + +// bbt : BB&T Corporation +// https://www.iana.org/domains/root/db/bbt.html +bbt + +// bbva : BANCO BILBAO VIZCAYA ARGENTARIA, S.A. +// https://www.iana.org/domains/root/db/bbva.html +bbva + +// bcg : The Boston Consulting Group, Inc. +// https://www.iana.org/domains/root/db/bcg.html +bcg + +// bcn : Municipi de Barcelona +// https://www.iana.org/domains/root/db/bcn.html +bcn + +// beats : Beats Electronics, LLC +// https://www.iana.org/domains/root/db/beats.html +beats + +// beauty : XYZ.COM LLC +// https://www.iana.org/domains/root/db/beauty.html +beauty + +// beer : Registry Services, LLC +// https://www.iana.org/domains/root/db/beer.html +beer + +// bentley : Bentley Motors Limited +// https://www.iana.org/domains/root/db/bentley.html +bentley + +// berlin : dotBERLIN GmbH & Co. KG +// https://www.iana.org/domains/root/db/berlin.html +berlin + +// best : BestTLD Pty Ltd +// https://www.iana.org/domains/root/db/best.html +best + +// bestbuy : BBY Solutions, Inc. +// https://www.iana.org/domains/root/db/bestbuy.html +bestbuy + +// bet : Identity Digital Limited +// https://www.iana.org/domains/root/db/bet.html +bet + +// bharti : Bharti Enterprises (Holding) Private Limited +// https://www.iana.org/domains/root/db/bharti.html +bharti + +// bible : American Bible Society +// https://www.iana.org/domains/root/db/bible.html +bible + +// bid : dot Bid Limited +// https://www.iana.org/domains/root/db/bid.html +bid + +// bike : Binky Moon, LLC +// https://www.iana.org/domains/root/db/bike.html +bike + +// bing : Microsoft Corporation +// https://www.iana.org/domains/root/db/bing.html +bing + +// bingo : Binky Moon, LLC +// https://www.iana.org/domains/root/db/bingo.html +bingo + +// bio : Identity Digital Limited +// https://www.iana.org/domains/root/db/bio.html +bio + +// black : Identity Digital Limited +// https://www.iana.org/domains/root/db/black.html +black + +// blackfriday : Registry Services, LLC +// https://www.iana.org/domains/root/db/blackfriday.html +blackfriday + +// blockbuster : Dish DBS Corporation +// https://www.iana.org/domains/root/db/blockbuster.html +blockbuster + +// blog : Knock Knock WHOIS There, LLC +// https://www.iana.org/domains/root/db/blog.html +blog + +// bloomberg : Bloomberg IP Holdings LLC +// https://www.iana.org/domains/root/db/bloomberg.html +bloomberg + +// blue : Identity Digital Limited +// https://www.iana.org/domains/root/db/blue.html +blue + +// bms : Bristol-Myers Squibb Company +// https://www.iana.org/domains/root/db/bms.html +bms + +// bmw : Bayerische Motoren Werke Aktiengesellschaft +// https://www.iana.org/domains/root/db/bmw.html +bmw + +// bnpparibas : BNP Paribas +// https://www.iana.org/domains/root/db/bnpparibas.html +bnpparibas + +// boats : XYZ.COM LLC +// https://www.iana.org/domains/root/db/boats.html +boats + +// boehringer : Boehringer Ingelheim International GmbH +// https://www.iana.org/domains/root/db/boehringer.html +boehringer + +// bofa : Bank of America Corporation +// https://www.iana.org/domains/root/db/bofa.html +bofa + +// bom : Núcleo de Informação e Coordenação do Ponto BR - NIC.br +// https://www.iana.org/domains/root/db/bom.html +bom + +// bond : ShortDot SA +// https://www.iana.org/domains/root/db/bond.html +bond + +// boo : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/boo.html +boo + +// book : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/book.html +book + +// booking : Booking.com B.V. +// https://www.iana.org/domains/root/db/booking.html +booking + +// bosch : Robert Bosch GMBH +// https://www.iana.org/domains/root/db/bosch.html +bosch + +// bostik : Bostik SA +// https://www.iana.org/domains/root/db/bostik.html +bostik + +// boston : Registry Services, LLC +// https://www.iana.org/domains/root/db/boston.html +boston + +// bot : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/bot.html +bot + +// boutique : Binky Moon, LLC +// https://www.iana.org/domains/root/db/boutique.html +boutique + +// box : Intercap Registry Inc. +// https://www.iana.org/domains/root/db/box.html +box + +// bradesco : Banco Bradesco S.A. +// https://www.iana.org/domains/root/db/bradesco.html +bradesco + +// bridgestone : Bridgestone Corporation +// https://www.iana.org/domains/root/db/bridgestone.html +bridgestone + +// broadway : Celebrate Broadway, Inc. +// https://www.iana.org/domains/root/db/broadway.html +broadway + +// broker : Dog Beach, LLC +// https://www.iana.org/domains/root/db/broker.html +broker + +// brother : Brother Industries, Ltd. +// https://www.iana.org/domains/root/db/brother.html +brother + +// brussels : DNS.be vzw +// https://www.iana.org/domains/root/db/brussels.html +brussels + +// build : Plan Bee LLC +// https://www.iana.org/domains/root/db/build.html +build + +// builders : Binky Moon, LLC +// https://www.iana.org/domains/root/db/builders.html +builders + +// business : Binky Moon, LLC +// https://www.iana.org/domains/root/db/business.html +business + +// buy : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/buy.html +buy + +// buzz : DOTSTRATEGY CO. +// https://www.iana.org/domains/root/db/buzz.html +buzz + +// bzh : Association www.bzh +// https://www.iana.org/domains/root/db/bzh.html +bzh + +// cab : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cab.html +cab + +// cafe : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cafe.html +cafe + +// cal : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/cal.html +cal + +// call : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/call.html +call + +// calvinklein : PVH gTLD Holdings LLC +// https://www.iana.org/domains/root/db/calvinklein.html +calvinklein + +// cam : Cam Connecting SARL +// https://www.iana.org/domains/root/db/cam.html +cam + +// camera : Binky Moon, LLC +// https://www.iana.org/domains/root/db/camera.html +camera + +// camp : Binky Moon, LLC +// https://www.iana.org/domains/root/db/camp.html +camp + +// canon : Canon Inc. +// https://www.iana.org/domains/root/db/canon.html +canon + +// capetown : ZA Central Registry NPC trading as ZA Central Registry +// https://www.iana.org/domains/root/db/capetown.html +capetown + +// capital : Binky Moon, LLC +// https://www.iana.org/domains/root/db/capital.html +capital + +// capitalone : Capital One Financial Corporation +// https://www.iana.org/domains/root/db/capitalone.html +capitalone + +// car : XYZ.COM LLC +// https://www.iana.org/domains/root/db/car.html +car + +// caravan : Caravan International, Inc. +// https://www.iana.org/domains/root/db/caravan.html +caravan + +// cards : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cards.html +cards + +// care : Binky Moon, LLC +// https://www.iana.org/domains/root/db/care.html +care + +// career : dotCareer LLC +// https://www.iana.org/domains/root/db/career.html +career + +// careers : Binky Moon, LLC +// https://www.iana.org/domains/root/db/careers.html +careers + +// cars : XYZ.COM LLC +// https://www.iana.org/domains/root/db/cars.html +cars + +// casa : Registry Services, LLC +// https://www.iana.org/domains/root/db/casa.html +casa + +// case : Digity, LLC +// https://www.iana.org/domains/root/db/case.html +case + +// cash : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cash.html +cash + +// casino : Binky Moon, LLC +// https://www.iana.org/domains/root/db/casino.html +casino + +// catering : Binky Moon, LLC +// https://www.iana.org/domains/root/db/catering.html +catering + +// catholic : Pontificium Consilium de Comunicationibus Socialibus (PCCS) (Pontifical Council for Social Communication) +// https://www.iana.org/domains/root/db/catholic.html +catholic + +// cba : COMMONWEALTH BANK OF AUSTRALIA +// https://www.iana.org/domains/root/db/cba.html +cba + +// cbn : The Christian Broadcasting Network, Inc. +// https://www.iana.org/domains/root/db/cbn.html +cbn + +// cbre : CBRE, Inc. +// https://www.iana.org/domains/root/db/cbre.html +cbre + +// center : Binky Moon, LLC +// https://www.iana.org/domains/root/db/center.html +center + +// ceo : XYZ.COM LLC +// https://www.iana.org/domains/root/db/ceo.html +ceo + +// cern : European Organization for Nuclear Research ("CERN") +// https://www.iana.org/domains/root/db/cern.html +cern + +// cfa : CFA Institute +// https://www.iana.org/domains/root/db/cfa.html +cfa + +// cfd : ShortDot SA +// https://www.iana.org/domains/root/db/cfd.html +cfd + +// chanel : Chanel International B.V. +// https://www.iana.org/domains/root/db/chanel.html +chanel + +// channel : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/channel.html +channel + +// charity : Public Interest Registry +// https://www.iana.org/domains/root/db/charity.html +charity + +// chase : JPMorgan Chase Bank, National Association +// https://www.iana.org/domains/root/db/chase.html +chase + +// chat : Binky Moon, LLC +// https://www.iana.org/domains/root/db/chat.html +chat + +// cheap : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cheap.html +cheap + +// chintai : CHINTAI Corporation +// https://www.iana.org/domains/root/db/chintai.html +chintai + +// christmas : XYZ.COM LLC +// https://www.iana.org/domains/root/db/christmas.html +christmas + +// chrome : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/chrome.html +chrome + +// church : Binky Moon, LLC +// https://www.iana.org/domains/root/db/church.html +church + +// cipriani : Hotel Cipriani Srl +// https://www.iana.org/domains/root/db/cipriani.html +cipriani + +// circle : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/circle.html +circle + +// cisco : Cisco Technology, Inc. +// https://www.iana.org/domains/root/db/cisco.html +cisco + +// citadel : Citadel Domain LLC +// https://www.iana.org/domains/root/db/citadel.html +citadel + +// citi : Citigroup Inc. +// https://www.iana.org/domains/root/db/citi.html +citi + +// citic : CITIC Group Corporation +// https://www.iana.org/domains/root/db/citic.html +citic + +// city : Binky Moon, LLC +// https://www.iana.org/domains/root/db/city.html +city + +// claims : Binky Moon, LLC +// https://www.iana.org/domains/root/db/claims.html +claims + +// cleaning : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cleaning.html +cleaning + +// click : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/click.html +click + +// clinic : Binky Moon, LLC +// https://www.iana.org/domains/root/db/clinic.html +clinic + +// clinique : The Estée Lauder Companies Inc. +// https://www.iana.org/domains/root/db/clinique.html +clinique + +// clothing : Binky Moon, LLC +// https://www.iana.org/domains/root/db/clothing.html +clothing + +// cloud : Aruba PEC S.p.A. +// https://www.iana.org/domains/root/db/cloud.html +cloud + +// club : Registry Services, LLC +// https://www.iana.org/domains/root/db/club.html +club + +// clubmed : Club Méditerranée S.A. +// https://www.iana.org/domains/root/db/clubmed.html +clubmed + +// coach : Binky Moon, LLC +// https://www.iana.org/domains/root/db/coach.html +coach + +// codes : Binky Moon, LLC +// https://www.iana.org/domains/root/db/codes.html +codes + +// coffee : Binky Moon, LLC +// https://www.iana.org/domains/root/db/coffee.html +coffee + +// college : XYZ.COM LLC +// https://www.iana.org/domains/root/db/college.html +college + +// cologne : dotKoeln GmbH +// https://www.iana.org/domains/root/db/cologne.html +cologne + +// commbank : COMMONWEALTH BANK OF AUSTRALIA +// https://www.iana.org/domains/root/db/commbank.html +commbank + +// community : Binky Moon, LLC +// https://www.iana.org/domains/root/db/community.html +community + +// company : Binky Moon, LLC +// https://www.iana.org/domains/root/db/company.html +company + +// compare : Registry Services, LLC +// https://www.iana.org/domains/root/db/compare.html +compare + +// computer : Binky Moon, LLC +// https://www.iana.org/domains/root/db/computer.html +computer + +// comsec : VeriSign, Inc. +// https://www.iana.org/domains/root/db/comsec.html +comsec + +// condos : Binky Moon, LLC +// https://www.iana.org/domains/root/db/condos.html +condos + +// construction : Binky Moon, LLC +// https://www.iana.org/domains/root/db/construction.html +construction + +// consulting : Dog Beach, LLC +// https://www.iana.org/domains/root/db/consulting.html +consulting + +// contact : Dog Beach, LLC +// https://www.iana.org/domains/root/db/contact.html +contact + +// contractors : Binky Moon, LLC +// https://www.iana.org/domains/root/db/contractors.html +contractors + +// cooking : Registry Services, LLC +// https://www.iana.org/domains/root/db/cooking.html +cooking + +// cool : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cool.html +cool + +// corsica : Collectivité de Corse +// https://www.iana.org/domains/root/db/corsica.html +corsica + +// country : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/country.html +country + +// coupon : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/coupon.html +coupon + +// coupons : Binky Moon, LLC +// https://www.iana.org/domains/root/db/coupons.html +coupons + +// courses : Registry Services, LLC +// https://www.iana.org/domains/root/db/courses.html +courses + +// cpa : American Institute of Certified Public Accountants +// https://www.iana.org/domains/root/db/cpa.html +cpa + +// credit : Binky Moon, LLC +// https://www.iana.org/domains/root/db/credit.html +credit + +// creditcard : Binky Moon, LLC +// https://www.iana.org/domains/root/db/creditcard.html +creditcard + +// creditunion : DotCooperation LLC +// https://www.iana.org/domains/root/db/creditunion.html +creditunion + +// cricket : dot Cricket Limited +// https://www.iana.org/domains/root/db/cricket.html +cricket + +// crown : Crown Equipment Corporation +// https://www.iana.org/domains/root/db/crown.html +crown + +// crs : Federated Co-operatives Limited +// https://www.iana.org/domains/root/db/crs.html +crs + +// cruise : Viking River Cruises (Bermuda) Ltd. +// https://www.iana.org/domains/root/db/cruise.html +cruise + +// cruises : Binky Moon, LLC +// https://www.iana.org/domains/root/db/cruises.html +cruises + +// cuisinella : SCHMIDT GROUPE S.A.S. +// https://www.iana.org/domains/root/db/cuisinella.html +cuisinella + +// cymru : Nominet UK +// https://www.iana.org/domains/root/db/cymru.html +cymru + +// cyou : ShortDot SA +// https://www.iana.org/domains/root/db/cyou.html +cyou + +// dabur : Dabur India Limited +// https://www.iana.org/domains/root/db/dabur.html +dabur + +// dad : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/dad.html +dad + +// dance : Dog Beach, LLC +// https://www.iana.org/domains/root/db/dance.html +dance + +// data : Dish DBS Corporation +// https://www.iana.org/domains/root/db/data.html +data + +// date : dot Date Limited +// https://www.iana.org/domains/root/db/date.html +date + +// dating : Binky Moon, LLC +// https://www.iana.org/domains/root/db/dating.html +dating + +// datsun : NISSAN MOTOR CO., LTD. +// https://www.iana.org/domains/root/db/datsun.html +datsun + +// day : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/day.html +day + +// dclk : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/dclk.html +dclk + +// dds : Registry Services, LLC +// https://www.iana.org/domains/root/db/dds.html +dds + +// deal : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/deal.html +deal + +// dealer : Intercap Registry Inc. +// https://www.iana.org/domains/root/db/dealer.html +dealer + +// deals : Binky Moon, LLC +// https://www.iana.org/domains/root/db/deals.html +deals + +// degree : Dog Beach, LLC +// https://www.iana.org/domains/root/db/degree.html +degree + +// delivery : Binky Moon, LLC +// https://www.iana.org/domains/root/db/delivery.html +delivery + +// dell : Dell Inc. +// https://www.iana.org/domains/root/db/dell.html +dell + +// deloitte : Deloitte Touche Tohmatsu +// https://www.iana.org/domains/root/db/deloitte.html +deloitte + +// delta : Delta Air Lines, Inc. +// https://www.iana.org/domains/root/db/delta.html +delta + +// democrat : Dog Beach, LLC +// https://www.iana.org/domains/root/db/democrat.html +democrat + +// dental : Binky Moon, LLC +// https://www.iana.org/domains/root/db/dental.html +dental + +// dentist : Dog Beach, LLC +// https://www.iana.org/domains/root/db/dentist.html +dentist + +// desi +// https://www.iana.org/domains/root/db/desi.html +desi + +// design : Registry Services, LLC +// https://www.iana.org/domains/root/db/design.html +design + +// dev : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/dev.html +dev + +// dhl : Deutsche Post AG +// https://www.iana.org/domains/root/db/dhl.html +dhl + +// diamonds : Binky Moon, LLC +// https://www.iana.org/domains/root/db/diamonds.html +diamonds + +// diet : XYZ.COM LLC +// https://www.iana.org/domains/root/db/diet.html +diet + +// digital : Binky Moon, LLC +// https://www.iana.org/domains/root/db/digital.html +digital + +// direct : Binky Moon, LLC +// https://www.iana.org/domains/root/db/direct.html +direct + +// directory : Binky Moon, LLC +// https://www.iana.org/domains/root/db/directory.html +directory + +// discount : Binky Moon, LLC +// https://www.iana.org/domains/root/db/discount.html +discount + +// discover : Discover Financial Services +// https://www.iana.org/domains/root/db/discover.html +discover + +// dish : Dish DBS Corporation +// https://www.iana.org/domains/root/db/dish.html +dish + +// diy : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/diy.html +diy + +// dnp : Dai Nippon Printing Co., Ltd. +// https://www.iana.org/domains/root/db/dnp.html +dnp + +// docs : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/docs.html +docs + +// doctor : Binky Moon, LLC +// https://www.iana.org/domains/root/db/doctor.html +doctor + +// dog : Binky Moon, LLC +// https://www.iana.org/domains/root/db/dog.html +dog + +// domains : Binky Moon, LLC +// https://www.iana.org/domains/root/db/domains.html +domains + +// dot : Dish DBS Corporation +// https://www.iana.org/domains/root/db/dot.html +dot + +// download : dot Support Limited +// https://www.iana.org/domains/root/db/download.html +download + +// drive : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/drive.html +drive + +// dtv : Dish DBS Corporation +// https://www.iana.org/domains/root/db/dtv.html +dtv + +// dubai : Dubai Smart Government Department +// https://www.iana.org/domains/root/db/dubai.html +dubai + +// dunlop : The Goodyear Tire & Rubber Company +// https://www.iana.org/domains/root/db/dunlop.html +dunlop + +// dupont : DuPont Specialty Products USA, LLC +// https://www.iana.org/domains/root/db/dupont.html +dupont + +// durban : ZA Central Registry NPC trading as ZA Central Registry +// https://www.iana.org/domains/root/db/durban.html +durban + +// dvag : Deutsche Vermögensberatung Aktiengesellschaft DVAG +// https://www.iana.org/domains/root/db/dvag.html +dvag + +// dvr : DISH Technologies L.L.C. +// https://www.iana.org/domains/root/db/dvr.html +dvr + +// earth : Interlink Systems Innovation Institute K.K. +// https://www.iana.org/domains/root/db/earth.html +earth + +// eat : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/eat.html +eat + +// eco : Big Room Inc. +// https://www.iana.org/domains/root/db/eco.html +eco + +// edeka : EDEKA Verband kaufmännischer Genossenschaften e.V. +// https://www.iana.org/domains/root/db/edeka.html +edeka + +// education : Binky Moon, LLC +// https://www.iana.org/domains/root/db/education.html +education + +// email : Binky Moon, LLC +// https://www.iana.org/domains/root/db/email.html +email + +// emerck : Merck KGaA +// https://www.iana.org/domains/root/db/emerck.html +emerck + +// energy : Binky Moon, LLC +// https://www.iana.org/domains/root/db/energy.html +energy + +// engineer : Dog Beach, LLC +// https://www.iana.org/domains/root/db/engineer.html +engineer + +// engineering : Binky Moon, LLC +// https://www.iana.org/domains/root/db/engineering.html +engineering + +// enterprises : Binky Moon, LLC +// https://www.iana.org/domains/root/db/enterprises.html +enterprises + +// epson : Seiko Epson Corporation +// https://www.iana.org/domains/root/db/epson.html +epson + +// equipment : Binky Moon, LLC +// https://www.iana.org/domains/root/db/equipment.html +equipment + +// ericsson : Telefonaktiebolaget L M Ericsson +// https://www.iana.org/domains/root/db/ericsson.html +ericsson + +// erni : ERNI Group Holding AG +// https://www.iana.org/domains/root/db/erni.html +erni + +// esq : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/esq.html +esq + +// estate : Binky Moon, LLC +// https://www.iana.org/domains/root/db/estate.html +estate + +// eurovision : European Broadcasting Union (EBU) +// https://www.iana.org/domains/root/db/eurovision.html +eurovision + +// eus : Puntueus Fundazioa +// https://www.iana.org/domains/root/db/eus.html +eus + +// events : Binky Moon, LLC +// https://www.iana.org/domains/root/db/events.html +events + +// exchange : Binky Moon, LLC +// https://www.iana.org/domains/root/db/exchange.html +exchange + +// expert : Binky Moon, LLC +// https://www.iana.org/domains/root/db/expert.html +expert + +// exposed : Binky Moon, LLC +// https://www.iana.org/domains/root/db/exposed.html +exposed + +// express : Binky Moon, LLC +// https://www.iana.org/domains/root/db/express.html +express + +// extraspace : Extra Space Storage LLC +// https://www.iana.org/domains/root/db/extraspace.html +extraspace + +// fage : Fage International S.A. +// https://www.iana.org/domains/root/db/fage.html +fage + +// fail : Binky Moon, LLC +// https://www.iana.org/domains/root/db/fail.html +fail + +// fairwinds : FairWinds Partners, LLC +// https://www.iana.org/domains/root/db/fairwinds.html +fairwinds + +// faith : dot Faith Limited +// https://www.iana.org/domains/root/db/faith.html +faith + +// family : Dog Beach, LLC +// https://www.iana.org/domains/root/db/family.html +family + +// fan : Dog Beach, LLC +// https://www.iana.org/domains/root/db/fan.html +fan + +// fans : ZDNS International Limited +// https://www.iana.org/domains/root/db/fans.html +fans + +// farm : Binky Moon, LLC +// https://www.iana.org/domains/root/db/farm.html +farm + +// farmers : Farmers Insurance Exchange +// https://www.iana.org/domains/root/db/farmers.html +farmers + +// fashion : Registry Services, LLC +// https://www.iana.org/domains/root/db/fashion.html +fashion + +// fast : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/fast.html +fast + +// fedex : Federal Express Corporation +// https://www.iana.org/domains/root/db/fedex.html +fedex + +// feedback : Top Level Spectrum, Inc. +// https://www.iana.org/domains/root/db/feedback.html +feedback + +// ferrari : Fiat Chrysler Automobiles N.V. +// https://www.iana.org/domains/root/db/ferrari.html +ferrari + +// ferrero : Ferrero Trading Lux S.A. +// https://www.iana.org/domains/root/db/ferrero.html +ferrero + +// fidelity : Fidelity Brokerage Services LLC +// https://www.iana.org/domains/root/db/fidelity.html +fidelity + +// fido : Rogers Communications Canada Inc. +// https://www.iana.org/domains/root/db/fido.html +fido + +// film : Motion Picture Domain Registry Pty Ltd +// https://www.iana.org/domains/root/db/film.html +film + +// final : Núcleo de Informação e Coordenação do Ponto BR - NIC.br +// https://www.iana.org/domains/root/db/final.html +final + +// finance : Binky Moon, LLC +// https://www.iana.org/domains/root/db/finance.html +finance + +// financial : Binky Moon, LLC +// https://www.iana.org/domains/root/db/financial.html +financial + +// fire : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/fire.html +fire + +// firestone : Bridgestone Licensing Services, Inc +// https://www.iana.org/domains/root/db/firestone.html +firestone + +// firmdale : Firmdale Holdings Limited +// https://www.iana.org/domains/root/db/firmdale.html +firmdale + +// fish : Binky Moon, LLC +// https://www.iana.org/domains/root/db/fish.html +fish + +// fishing : Registry Services, LLC +// https://www.iana.org/domains/root/db/fishing.html +fishing + +// fit : Registry Services, LLC +// https://www.iana.org/domains/root/db/fit.html +fit + +// fitness : Binky Moon, LLC +// https://www.iana.org/domains/root/db/fitness.html +fitness + +// flickr : Flickr, Inc. +// https://www.iana.org/domains/root/db/flickr.html +flickr + +// flights : Binky Moon, LLC +// https://www.iana.org/domains/root/db/flights.html +flights + +// flir : FLIR Systems, Inc. +// https://www.iana.org/domains/root/db/flir.html +flir + +// florist : Binky Moon, LLC +// https://www.iana.org/domains/root/db/florist.html +florist + +// flowers : XYZ.COM LLC +// https://www.iana.org/domains/root/db/flowers.html +flowers + +// fly : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/fly.html +fly + +// foo : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/foo.html +foo + +// food : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/food.html +food + +// football : Binky Moon, LLC +// https://www.iana.org/domains/root/db/football.html +football + +// ford : Ford Motor Company +// https://www.iana.org/domains/root/db/ford.html +ford + +// forex : Dog Beach, LLC +// https://www.iana.org/domains/root/db/forex.html +forex + +// forsale : Dog Beach, LLC +// https://www.iana.org/domains/root/db/forsale.html +forsale + +// forum : Fegistry, LLC +// https://www.iana.org/domains/root/db/forum.html +forum + +// foundation : Public Interest Registry +// https://www.iana.org/domains/root/db/foundation.html +foundation + +// fox : FOX Registry, LLC +// https://www.iana.org/domains/root/db/fox.html +fox + +// free : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/free.html +free + +// fresenius : Fresenius Immobilien-Verwaltungs-GmbH +// https://www.iana.org/domains/root/db/fresenius.html +fresenius + +// frl : FRLregistry B.V. +// https://www.iana.org/domains/root/db/frl.html +frl + +// frogans : OP3FT +// https://www.iana.org/domains/root/db/frogans.html +frogans + +// frontier : Frontier Communications Corporation +// https://www.iana.org/domains/root/db/frontier.html +frontier + +// ftr : Frontier Communications Corporation +// https://www.iana.org/domains/root/db/ftr.html +ftr + +// fujitsu : Fujitsu Limited +// https://www.iana.org/domains/root/db/fujitsu.html +fujitsu + +// fun : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/fun.html +fun + +// fund : Binky Moon, LLC +// https://www.iana.org/domains/root/db/fund.html +fund + +// furniture : Binky Moon, LLC +// https://www.iana.org/domains/root/db/furniture.html +furniture + +// futbol : Dog Beach, LLC +// https://www.iana.org/domains/root/db/futbol.html +futbol + +// fyi : Binky Moon, LLC +// https://www.iana.org/domains/root/db/fyi.html +fyi + +// gal : Asociación puntoGAL +// https://www.iana.org/domains/root/db/gal.html +gal + +// gallery : Binky Moon, LLC +// https://www.iana.org/domains/root/db/gallery.html +gallery + +// gallo : Gallo Vineyards, Inc. +// https://www.iana.org/domains/root/db/gallo.html +gallo + +// gallup : Gallup, Inc. +// https://www.iana.org/domains/root/db/gallup.html +gallup + +// game : XYZ.COM LLC +// https://www.iana.org/domains/root/db/game.html +game + +// games : Dog Beach, LLC +// https://www.iana.org/domains/root/db/games.html +games + +// gap : The Gap, Inc. +// https://www.iana.org/domains/root/db/gap.html +gap + +// garden : Registry Services, LLC +// https://www.iana.org/domains/root/db/garden.html +garden + +// gay : Registry Services, LLC +// https://www.iana.org/domains/root/db/gay.html +gay + +// gbiz : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/gbiz.html +gbiz + +// gdn : Joint Stock Company "Navigation-information systems" +// https://www.iana.org/domains/root/db/gdn.html +gdn + +// gea : GEA Group Aktiengesellschaft +// https://www.iana.org/domains/root/db/gea.html +gea + +// gent : Easyhost BV +// https://www.iana.org/domains/root/db/gent.html +gent + +// genting : Resorts World Inc Pte. Ltd. +// https://www.iana.org/domains/root/db/genting.html +genting + +// george : Wal-Mart Stores, Inc. +// https://www.iana.org/domains/root/db/george.html +george + +// ggee : GMO Internet, Inc. +// https://www.iana.org/domains/root/db/ggee.html +ggee + +// gift : DotGift, LLC +// https://www.iana.org/domains/root/db/gift.html +gift + +// gifts : Binky Moon, LLC +// https://www.iana.org/domains/root/db/gifts.html +gifts + +// gives : Public Interest Registry +// https://www.iana.org/domains/root/db/gives.html +gives + +// giving : Public Interest Registry +// https://www.iana.org/domains/root/db/giving.html +giving + +// glass : Binky Moon, LLC +// https://www.iana.org/domains/root/db/glass.html +glass + +// gle : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/gle.html +gle + +// global : Identity Digital Limited +// https://www.iana.org/domains/root/db/global.html +global + +// globo : Globo Comunicação e Participações S.A +// https://www.iana.org/domains/root/db/globo.html +globo + +// gmail : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/gmail.html +gmail + +// gmbh : Binky Moon, LLC +// https://www.iana.org/domains/root/db/gmbh.html +gmbh + +// gmo : GMO Internet, Inc. +// https://www.iana.org/domains/root/db/gmo.html +gmo + +// gmx : 1&1 Mail & Media GmbH +// https://www.iana.org/domains/root/db/gmx.html +gmx + +// godaddy : Go Daddy East, LLC +// https://www.iana.org/domains/root/db/godaddy.html +godaddy + +// gold : Binky Moon, LLC +// https://www.iana.org/domains/root/db/gold.html +gold + +// goldpoint : YODOBASHI CAMERA CO.,LTD. +// https://www.iana.org/domains/root/db/goldpoint.html +goldpoint + +// golf : Binky Moon, LLC +// https://www.iana.org/domains/root/db/golf.html +golf + +// goo : NTT DOCOMO, INC. +// https://www.iana.org/domains/root/db/goo.html +goo + +// goodyear : The Goodyear Tire & Rubber Company +// https://www.iana.org/domains/root/db/goodyear.html +goodyear + +// goog : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/goog.html +goog + +// google : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/google.html +google + +// gop : Republican State Leadership Committee, Inc. +// https://www.iana.org/domains/root/db/gop.html +gop + +// got : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/got.html +got + +// grainger : Grainger Registry Services, LLC +// https://www.iana.org/domains/root/db/grainger.html +grainger + +// graphics : Binky Moon, LLC +// https://www.iana.org/domains/root/db/graphics.html +graphics + +// gratis : Binky Moon, LLC +// https://www.iana.org/domains/root/db/gratis.html +gratis + +// green : Identity Digital Limited +// https://www.iana.org/domains/root/db/green.html +green + +// gripe : Binky Moon, LLC +// https://www.iana.org/domains/root/db/gripe.html +gripe + +// grocery : Wal-Mart Stores, Inc. +// https://www.iana.org/domains/root/db/grocery.html +grocery + +// group : Binky Moon, LLC +// https://www.iana.org/domains/root/db/group.html +group + +// gucci : Guccio Gucci S.p.a. +// https://www.iana.org/domains/root/db/gucci.html +gucci + +// guge : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/guge.html +guge + +// guide : Binky Moon, LLC +// https://www.iana.org/domains/root/db/guide.html +guide + +// guitars : XYZ.COM LLC +// https://www.iana.org/domains/root/db/guitars.html +guitars + +// guru : Binky Moon, LLC +// https://www.iana.org/domains/root/db/guru.html +guru + +// hair : XYZ.COM LLC +// https://www.iana.org/domains/root/db/hair.html +hair + +// hamburg : Hamburg Top-Level-Domain GmbH +// https://www.iana.org/domains/root/db/hamburg.html +hamburg + +// hangout : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/hangout.html +hangout + +// haus : Dog Beach, LLC +// https://www.iana.org/domains/root/db/haus.html +haus + +// hbo : HBO Registry Services, Inc. +// https://www.iana.org/domains/root/db/hbo.html +hbo + +// hdfc : HOUSING DEVELOPMENT FINANCE CORPORATION LIMITED +// https://www.iana.org/domains/root/db/hdfc.html +hdfc + +// hdfcbank : HDFC Bank Limited +// https://www.iana.org/domains/root/db/hdfcbank.html +hdfcbank + +// health : Registry Services, LLC +// https://www.iana.org/domains/root/db/health.html +health + +// healthcare : Binky Moon, LLC +// https://www.iana.org/domains/root/db/healthcare.html +healthcare + +// help : Innovation service Limited +// https://www.iana.org/domains/root/db/help.html +help + +// helsinki : City of Helsinki +// https://www.iana.org/domains/root/db/helsinki.html +helsinki + +// here : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/here.html +here + +// hermes : HERMES INTERNATIONAL +// https://www.iana.org/domains/root/db/hermes.html +hermes + +// hiphop : Dot Hip Hop, LLC +// https://www.iana.org/domains/root/db/hiphop.html +hiphop + +// hisamitsu : Hisamitsu Pharmaceutical Co.,Inc. +// https://www.iana.org/domains/root/db/hisamitsu.html +hisamitsu + +// hitachi : Hitachi, Ltd. +// https://www.iana.org/domains/root/db/hitachi.html +hitachi + +// hiv : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/hiv.html +hiv + +// hkt : PCCW-HKT DataCom Services Limited +// https://www.iana.org/domains/root/db/hkt.html +hkt + +// hockey : Binky Moon, LLC +// https://www.iana.org/domains/root/db/hockey.html +hockey + +// holdings : Binky Moon, LLC +// https://www.iana.org/domains/root/db/holdings.html +holdings + +// holiday : Binky Moon, LLC +// https://www.iana.org/domains/root/db/holiday.html +holiday + +// homedepot : Home Depot Product Authority, LLC +// https://www.iana.org/domains/root/db/homedepot.html +homedepot + +// homegoods : The TJX Companies, Inc. +// https://www.iana.org/domains/root/db/homegoods.html +homegoods + +// homes : XYZ.COM LLC +// https://www.iana.org/domains/root/db/homes.html +homes + +// homesense : The TJX Companies, Inc. +// https://www.iana.org/domains/root/db/homesense.html +homesense + +// honda : Honda Motor Co., Ltd. +// https://www.iana.org/domains/root/db/honda.html +honda + +// horse : Registry Services, LLC +// https://www.iana.org/domains/root/db/horse.html +horse + +// hospital : Binky Moon, LLC +// https://www.iana.org/domains/root/db/hospital.html +hospital + +// host : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/host.html +host + +// hosting : XYZ.COM LLC +// https://www.iana.org/domains/root/db/hosting.html +hosting + +// hot : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/hot.html +hot + +// hotels : Booking.com B.V. +// https://www.iana.org/domains/root/db/hotels.html +hotels + +// hotmail : Microsoft Corporation +// https://www.iana.org/domains/root/db/hotmail.html +hotmail + +// house : Binky Moon, LLC +// https://www.iana.org/domains/root/db/house.html +house + +// how : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/how.html +how + +// hsbc : HSBC Global Services (UK) Limited +// https://www.iana.org/domains/root/db/hsbc.html +hsbc + +// hughes : Hughes Satellite Systems Corporation +// https://www.iana.org/domains/root/db/hughes.html +hughes + +// hyatt : Hyatt GTLD, L.L.C. +// https://www.iana.org/domains/root/db/hyatt.html +hyatt + +// hyundai : Hyundai Motor Company +// https://www.iana.org/domains/root/db/hyundai.html +hyundai + +// ibm : International Business Machines Corporation +// https://www.iana.org/domains/root/db/ibm.html +ibm + +// icbc : Industrial and Commercial Bank of China Limited +// https://www.iana.org/domains/root/db/icbc.html +icbc + +// ice : IntercontinentalExchange, Inc. +// https://www.iana.org/domains/root/db/ice.html +ice + +// icu : ShortDot SA +// https://www.iana.org/domains/root/db/icu.html +icu + +// ieee : IEEE Global LLC +// https://www.iana.org/domains/root/db/ieee.html +ieee + +// ifm : ifm electronic gmbh +// https://www.iana.org/domains/root/db/ifm.html +ifm + +// ikano : Ikano S.A. +// https://www.iana.org/domains/root/db/ikano.html +ikano + +// imamat : Fondation Aga Khan (Aga Khan Foundation) +// https://www.iana.org/domains/root/db/imamat.html +imamat + +// imdb : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/imdb.html +imdb + +// immo : Binky Moon, LLC +// https://www.iana.org/domains/root/db/immo.html +immo + +// immobilien : Dog Beach, LLC +// https://www.iana.org/domains/root/db/immobilien.html +immobilien + +// inc : Intercap Registry Inc. +// https://www.iana.org/domains/root/db/inc.html +inc + +// industries : Binky Moon, LLC +// https://www.iana.org/domains/root/db/industries.html +industries + +// infiniti : NISSAN MOTOR CO., LTD. +// https://www.iana.org/domains/root/db/infiniti.html +infiniti + +// ing : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/ing.html +ing + +// ink : Registry Services, LLC +// https://www.iana.org/domains/root/db/ink.html +ink + +// institute : Binky Moon, LLC +// https://www.iana.org/domains/root/db/institute.html +institute + +// insurance : fTLD Registry Services LLC +// https://www.iana.org/domains/root/db/insurance.html +insurance + +// insure : Binky Moon, LLC +// https://www.iana.org/domains/root/db/insure.html +insure + +// international : Binky Moon, LLC +// https://www.iana.org/domains/root/db/international.html +international + +// intuit : Intuit Administrative Services, Inc. +// https://www.iana.org/domains/root/db/intuit.html +intuit + +// investments : Binky Moon, LLC +// https://www.iana.org/domains/root/db/investments.html +investments + +// ipiranga : Ipiranga Produtos de Petroleo S.A. +// https://www.iana.org/domains/root/db/ipiranga.html +ipiranga + +// irish : Binky Moon, LLC +// https://www.iana.org/domains/root/db/irish.html +irish + +// ismaili : Fondation Aga Khan (Aga Khan Foundation) +// https://www.iana.org/domains/root/db/ismaili.html +ismaili + +// ist : Istanbul Metropolitan Municipality +// https://www.iana.org/domains/root/db/ist.html +ist + +// istanbul : Istanbul Metropolitan Municipality +// https://www.iana.org/domains/root/db/istanbul.html +istanbul + +// itau : Itau Unibanco Holding S.A. +// https://www.iana.org/domains/root/db/itau.html +itau + +// itv : ITV Services Limited +// https://www.iana.org/domains/root/db/itv.html +itv + +// jaguar : Jaguar Land Rover Ltd +// https://www.iana.org/domains/root/db/jaguar.html +jaguar + +// java : Oracle Corporation +// https://www.iana.org/domains/root/db/java.html +java + +// jcb : JCB Co., Ltd. +// https://www.iana.org/domains/root/db/jcb.html +jcb + +// jeep : FCA US LLC. +// https://www.iana.org/domains/root/db/jeep.html +jeep + +// jetzt : Binky Moon, LLC +// https://www.iana.org/domains/root/db/jetzt.html +jetzt + +// jewelry : Binky Moon, LLC +// https://www.iana.org/domains/root/db/jewelry.html +jewelry + +// jio : Reliance Industries Limited +// https://www.iana.org/domains/root/db/jio.html +jio + +// jll : Jones Lang LaSalle Incorporated +// https://www.iana.org/domains/root/db/jll.html +jll + +// jmp : Matrix IP LLC +// https://www.iana.org/domains/root/db/jmp.html +jmp + +// jnj : Johnson & Johnson Services, Inc. +// https://www.iana.org/domains/root/db/jnj.html +jnj + +// joburg : ZA Central Registry NPC trading as ZA Central Registry +// https://www.iana.org/domains/root/db/joburg.html +joburg + +// jot : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/jot.html +jot + +// joy : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/joy.html +joy + +// jpmorgan : JPMorgan Chase Bank, National Association +// https://www.iana.org/domains/root/db/jpmorgan.html +jpmorgan + +// jprs : Japan Registry Services Co., Ltd. +// https://www.iana.org/domains/root/db/jprs.html +jprs + +// juegos : Dog Beach, LLC +// https://www.iana.org/domains/root/db/juegos.html +juegos + +// juniper : JUNIPER NETWORKS, INC. +// https://www.iana.org/domains/root/db/juniper.html +juniper + +// kaufen : Dog Beach, LLC +// https://www.iana.org/domains/root/db/kaufen.html +kaufen + +// kddi : KDDI CORPORATION +// https://www.iana.org/domains/root/db/kddi.html +kddi + +// kerryhotels : Kerry Trading Co. Limited +// https://www.iana.org/domains/root/db/kerryhotels.html +kerryhotels + +// kerrylogistics : Kerry Trading Co. Limited +// https://www.iana.org/domains/root/db/kerrylogistics.html +kerrylogistics + +// kerryproperties : Kerry Trading Co. Limited +// https://www.iana.org/domains/root/db/kerryproperties.html +kerryproperties + +// kfh : Kuwait Finance House +// https://www.iana.org/domains/root/db/kfh.html +kfh + +// kia : KIA MOTORS CORPORATION +// https://www.iana.org/domains/root/db/kia.html +kia + +// kids : DotKids Foundation Limited +// https://www.iana.org/domains/root/db/kids.html +kids + +// kim : Identity Digital Limited +// https://www.iana.org/domains/root/db/kim.html +kim + +// kindle : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/kindle.html +kindle + +// kitchen : Binky Moon, LLC +// https://www.iana.org/domains/root/db/kitchen.html +kitchen + +// kiwi : DOT KIWI LIMITED +// https://www.iana.org/domains/root/db/kiwi.html +kiwi + +// koeln : dotKoeln GmbH +// https://www.iana.org/domains/root/db/koeln.html +koeln + +// komatsu : Komatsu Ltd. +// https://www.iana.org/domains/root/db/komatsu.html +komatsu + +// kosher : Kosher Marketing Assets LLC +// https://www.iana.org/domains/root/db/kosher.html +kosher + +// kpmg : KPMG International Cooperative (KPMG International Genossenschaft) +// https://www.iana.org/domains/root/db/kpmg.html +kpmg + +// kpn : Koninklijke KPN N.V. +// https://www.iana.org/domains/root/db/kpn.html +kpn + +// krd : KRG Department of Information Technology +// https://www.iana.org/domains/root/db/krd.html +krd + +// kred : KredTLD Pty Ltd +// https://www.iana.org/domains/root/db/kred.html +kred + +// kuokgroup : Kerry Trading Co. Limited +// https://www.iana.org/domains/root/db/kuokgroup.html +kuokgroup + +// kyoto : Academic Institution: Kyoto Jyoho Gakuen +// https://www.iana.org/domains/root/db/kyoto.html +kyoto + +// lacaixa : Fundación Bancaria Caixa d’Estalvis i Pensions de Barcelona, “la Caixa” +// https://www.iana.org/domains/root/db/lacaixa.html +lacaixa + +// lamborghini : Automobili Lamborghini S.p.A. +// https://www.iana.org/domains/root/db/lamborghini.html +lamborghini + +// lamer : The Estée Lauder Companies Inc. +// https://www.iana.org/domains/root/db/lamer.html +lamer + +// lancaster : LANCASTER +// https://www.iana.org/domains/root/db/lancaster.html +lancaster + +// land : Binky Moon, LLC +// https://www.iana.org/domains/root/db/land.html +land + +// landrover : Jaguar Land Rover Ltd +// https://www.iana.org/domains/root/db/landrover.html +landrover + +// lanxess : LANXESS Corporation +// https://www.iana.org/domains/root/db/lanxess.html +lanxess + +// lasalle : Jones Lang LaSalle Incorporated +// https://www.iana.org/domains/root/db/lasalle.html +lasalle + +// lat : XYZ.COM LLC +// https://www.iana.org/domains/root/db/lat.html +lat + +// latino : Dish DBS Corporation +// https://www.iana.org/domains/root/db/latino.html +latino + +// latrobe : La Trobe University +// https://www.iana.org/domains/root/db/latrobe.html +latrobe + +// law : Registry Services, LLC +// https://www.iana.org/domains/root/db/law.html +law + +// lawyer : Dog Beach, LLC +// https://www.iana.org/domains/root/db/lawyer.html +lawyer + +// lds : IRI Domain Management, LLC +// https://www.iana.org/domains/root/db/lds.html +lds + +// lease : Binky Moon, LLC +// https://www.iana.org/domains/root/db/lease.html +lease + +// leclerc : A.C.D. LEC Association des Centres Distributeurs Edouard Leclerc +// https://www.iana.org/domains/root/db/leclerc.html +leclerc + +// lefrak : LeFrak Organization, Inc. +// https://www.iana.org/domains/root/db/lefrak.html +lefrak + +// legal : Binky Moon, LLC +// https://www.iana.org/domains/root/db/legal.html +legal + +// lego : LEGO Juris A/S +// https://www.iana.org/domains/root/db/lego.html +lego + +// lexus : TOYOTA MOTOR CORPORATION +// https://www.iana.org/domains/root/db/lexus.html +lexus + +// lgbt : Identity Digital Limited +// https://www.iana.org/domains/root/db/lgbt.html +lgbt + +// lidl : Schwarz Domains und Services GmbH & Co. KG +// https://www.iana.org/domains/root/db/lidl.html +lidl + +// life : Binky Moon, LLC +// https://www.iana.org/domains/root/db/life.html +life + +// lifeinsurance : American Council of Life Insurers +// https://www.iana.org/domains/root/db/lifeinsurance.html +lifeinsurance + +// lifestyle : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/lifestyle.html +lifestyle + +// lighting : Binky Moon, LLC +// https://www.iana.org/domains/root/db/lighting.html +lighting + +// like : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/like.html +like + +// lilly : Eli Lilly and Company +// https://www.iana.org/domains/root/db/lilly.html +lilly + +// limited : Binky Moon, LLC +// https://www.iana.org/domains/root/db/limited.html +limited + +// limo : Binky Moon, LLC +// https://www.iana.org/domains/root/db/limo.html +limo + +// lincoln : Ford Motor Company +// https://www.iana.org/domains/root/db/lincoln.html +lincoln + +// link : Nova Registry Ltd +// https://www.iana.org/domains/root/db/link.html +link + +// lipsy : Lipsy Ltd +// https://www.iana.org/domains/root/db/lipsy.html +lipsy + +// live : Dog Beach, LLC +// https://www.iana.org/domains/root/db/live.html +live + +// living : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/living.html +living + +// llc : Identity Digital Limited +// https://www.iana.org/domains/root/db/llc.html +llc + +// llp : Intercap Registry Inc. +// https://www.iana.org/domains/root/db/llp.html +llp + +// loan : dot Loan Limited +// https://www.iana.org/domains/root/db/loan.html +loan + +// loans : Binky Moon, LLC +// https://www.iana.org/domains/root/db/loans.html +loans + +// locker : Orange Domains LLC +// https://www.iana.org/domains/root/db/locker.html +locker + +// locus : Locus Analytics LLC +// https://www.iana.org/domains/root/db/locus.html +locus + +// lol : XYZ.COM LLC +// https://www.iana.org/domains/root/db/lol.html +lol + +// london : Dot London Domains Limited +// https://www.iana.org/domains/root/db/london.html +london + +// lotte : Lotte Holdings Co., Ltd. +// https://www.iana.org/domains/root/db/lotte.html +lotte + +// lotto : Identity Digital Limited +// https://www.iana.org/domains/root/db/lotto.html +lotto + +// love : Waterford Limited +// https://www.iana.org/domains/root/db/love.html +love + +// lpl : LPL Holdings, Inc. +// https://www.iana.org/domains/root/db/lpl.html +lpl + +// lplfinancial : LPL Holdings, Inc. +// https://www.iana.org/domains/root/db/lplfinancial.html +lplfinancial + +// ltd : Binky Moon, LLC +// https://www.iana.org/domains/root/db/ltd.html +ltd + +// ltda : InterNetX, Corp +// https://www.iana.org/domains/root/db/ltda.html +ltda + +// lundbeck : H. Lundbeck A/S +// https://www.iana.org/domains/root/db/lundbeck.html +lundbeck + +// luxe : Registry Services, LLC +// https://www.iana.org/domains/root/db/luxe.html +luxe + +// luxury : Luxury Partners, LLC +// https://www.iana.org/domains/root/db/luxury.html +luxury + +// madrid : Comunidad de Madrid +// https://www.iana.org/domains/root/db/madrid.html +madrid + +// maif : Mutuelle Assurance Instituteur France (MAIF) +// https://www.iana.org/domains/root/db/maif.html +maif + +// maison : Binky Moon, LLC +// https://www.iana.org/domains/root/db/maison.html +maison + +// makeup : XYZ.COM LLC +// https://www.iana.org/domains/root/db/makeup.html +makeup + +// man : MAN SE +// https://www.iana.org/domains/root/db/man.html +man + +// management : Binky Moon, LLC +// https://www.iana.org/domains/root/db/management.html +management + +// mango : PUNTO FA S.L. +// https://www.iana.org/domains/root/db/mango.html +mango + +// map : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/map.html +map + +// market : Dog Beach, LLC +// https://www.iana.org/domains/root/db/market.html +market + +// marketing : Binky Moon, LLC +// https://www.iana.org/domains/root/db/marketing.html +marketing + +// markets : Dog Beach, LLC +// https://www.iana.org/domains/root/db/markets.html +markets + +// marriott : Marriott Worldwide Corporation +// https://www.iana.org/domains/root/db/marriott.html +marriott + +// marshalls : The TJX Companies, Inc. +// https://www.iana.org/domains/root/db/marshalls.html +marshalls + +// mattel : Mattel Sites, Inc. +// https://www.iana.org/domains/root/db/mattel.html +mattel + +// mba : Binky Moon, LLC +// https://www.iana.org/domains/root/db/mba.html +mba + +// mckinsey : McKinsey Holdings, Inc. +// https://www.iana.org/domains/root/db/mckinsey.html +mckinsey + +// med : Medistry LLC +// https://www.iana.org/domains/root/db/med.html +med + +// media : Binky Moon, LLC +// https://www.iana.org/domains/root/db/media.html +media + +// meet : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/meet.html +meet + +// melbourne : The Crown in right of the State of Victoria, represented by its Department of State Development, Business and Innovation +// https://www.iana.org/domains/root/db/melbourne.html +melbourne + +// meme : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/meme.html +meme + +// memorial : Dog Beach, LLC +// https://www.iana.org/domains/root/db/memorial.html +memorial + +// men : Exclusive Registry Limited +// https://www.iana.org/domains/root/db/men.html +men + +// menu : Dot Menu Registry, LLC +// https://www.iana.org/domains/root/db/menu.html +menu + +// merckmsd : MSD Registry Holdings, Inc. +// https://www.iana.org/domains/root/db/merckmsd.html +merckmsd + +// miami : Registry Services, LLC +// https://www.iana.org/domains/root/db/miami.html +miami + +// microsoft : Microsoft Corporation +// https://www.iana.org/domains/root/db/microsoft.html +microsoft + +// mini : Bayerische Motoren Werke Aktiengesellschaft +// https://www.iana.org/domains/root/db/mini.html +mini + +// mint : Intuit Administrative Services, Inc. +// https://www.iana.org/domains/root/db/mint.html +mint + +// mit : Massachusetts Institute of Technology +// https://www.iana.org/domains/root/db/mit.html +mit + +// mitsubishi : Mitsubishi Corporation +// https://www.iana.org/domains/root/db/mitsubishi.html +mitsubishi + +// mlb : MLB Advanced Media DH, LLC +// https://www.iana.org/domains/root/db/mlb.html +mlb + +// mls : The Canadian Real Estate Association +// https://www.iana.org/domains/root/db/mls.html +mls + +// mma : MMA IARD +// https://www.iana.org/domains/root/db/mma.html +mma + +// mobile : Dish DBS Corporation +// https://www.iana.org/domains/root/db/mobile.html +mobile + +// moda : Dog Beach, LLC +// https://www.iana.org/domains/root/db/moda.html +moda + +// moe : Interlink Systems Innovation Institute K.K. +// https://www.iana.org/domains/root/db/moe.html +moe + +// moi : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/moi.html +moi + +// mom : XYZ.COM LLC +// https://www.iana.org/domains/root/db/mom.html +mom + +// monash : Monash University +// https://www.iana.org/domains/root/db/monash.html +monash + +// money : Binky Moon, LLC +// https://www.iana.org/domains/root/db/money.html +money + +// monster : XYZ.COM LLC +// https://www.iana.org/domains/root/db/monster.html +monster + +// mormon : IRI Domain Management, LLC +// https://www.iana.org/domains/root/db/mormon.html +mormon + +// mortgage : Dog Beach, LLC +// https://www.iana.org/domains/root/db/mortgage.html +mortgage + +// moscow : Foundation for Assistance for Internet Technologies and Infrastructure Development (FAITID) +// https://www.iana.org/domains/root/db/moscow.html +moscow + +// moto : Motorola Trademark Holdings, LLC +// https://www.iana.org/domains/root/db/moto.html +moto + +// motorcycles : XYZ.COM LLC +// https://www.iana.org/domains/root/db/motorcycles.html +motorcycles + +// mov : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/mov.html +mov + +// movie : Binky Moon, LLC +// https://www.iana.org/domains/root/db/movie.html +movie + +// msd : MSD Registry Holdings, Inc. +// https://www.iana.org/domains/root/db/msd.html +msd + +// mtn : MTN Dubai Limited +// https://www.iana.org/domains/root/db/mtn.html +mtn + +// mtr : MTR Corporation Limited +// https://www.iana.org/domains/root/db/mtr.html +mtr + +// music : DotMusic Limited +// https://www.iana.org/domains/root/db/music.html +music + +// nab : National Australia Bank Limited +// https://www.iana.org/domains/root/db/nab.html +nab + +// nagoya : GMO Registry, Inc. +// https://www.iana.org/domains/root/db/nagoya.html +nagoya + +// navy : Dog Beach, LLC +// https://www.iana.org/domains/root/db/navy.html +navy + +// nba : NBA REGISTRY, LLC +// https://www.iana.org/domains/root/db/nba.html +nba + +// nec : NEC Corporation +// https://www.iana.org/domains/root/db/nec.html +nec + +// netbank : COMMONWEALTH BANK OF AUSTRALIA +// https://www.iana.org/domains/root/db/netbank.html +netbank + +// netflix : Netflix, Inc. +// https://www.iana.org/domains/root/db/netflix.html +netflix + +// network : Binky Moon, LLC +// https://www.iana.org/domains/root/db/network.html +network + +// neustar : NeuStar, Inc. +// https://www.iana.org/domains/root/db/neustar.html +neustar + +// new : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/new.html +new + +// news : Dog Beach, LLC +// https://www.iana.org/domains/root/db/news.html +news + +// next : Next plc +// https://www.iana.org/domains/root/db/next.html +next + +// nextdirect : Next plc +// https://www.iana.org/domains/root/db/nextdirect.html +nextdirect + +// nexus : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/nexus.html +nexus + +// nfl : NFL Reg Ops LLC +// https://www.iana.org/domains/root/db/nfl.html +nfl + +// ngo : Public Interest Registry +// https://www.iana.org/domains/root/db/ngo.html +ngo + +// nhk : Japan Broadcasting Corporation (NHK) +// https://www.iana.org/domains/root/db/nhk.html +nhk + +// nico : DWANGO Co., Ltd. +// https://www.iana.org/domains/root/db/nico.html +nico + +// nike : NIKE, Inc. +// https://www.iana.org/domains/root/db/nike.html +nike + +// nikon : NIKON CORPORATION +// https://www.iana.org/domains/root/db/nikon.html +nikon + +// ninja : Dog Beach, LLC +// https://www.iana.org/domains/root/db/ninja.html +ninja + +// nissan : NISSAN MOTOR CO., LTD. +// https://www.iana.org/domains/root/db/nissan.html +nissan + +// nissay : Nippon Life Insurance Company +// https://www.iana.org/domains/root/db/nissay.html +nissay + +// nokia : Nokia Corporation +// https://www.iana.org/domains/root/db/nokia.html +nokia + +// norton : NortonLifeLock Inc. +// https://www.iana.org/domains/root/db/norton.html +norton + +// now : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/now.html +now + +// nowruz : Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +// https://www.iana.org/domains/root/db/nowruz.html +nowruz + +// nowtv : Starbucks (HK) Limited +// https://www.iana.org/domains/root/db/nowtv.html +nowtv + +// nra : NRA Holdings Company, INC. +// https://www.iana.org/domains/root/db/nra.html +nra + +// nrw : Minds + Machines GmbH +// https://www.iana.org/domains/root/db/nrw.html +nrw + +// ntt : NIPPON TELEGRAPH AND TELEPHONE CORPORATION +// https://www.iana.org/domains/root/db/ntt.html +ntt + +// nyc : The City of New York by and through the New York City Department of Information Technology & Telecommunications +// https://www.iana.org/domains/root/db/nyc.html +nyc + +// obi : OBI Group Holding SE & Co. KGaA +// https://www.iana.org/domains/root/db/obi.html +obi + +// observer : Fegistry, LLC +// https://www.iana.org/domains/root/db/observer.html +observer + +// office : Microsoft Corporation +// https://www.iana.org/domains/root/db/office.html +office + +// okinawa : BRregistry, Inc. +// https://www.iana.org/domains/root/db/okinawa.html +okinawa + +// olayan : Competrol (Luxembourg) Sarl +// https://www.iana.org/domains/root/db/olayan.html +olayan + +// olayangroup : Competrol (Luxembourg) Sarl +// https://www.iana.org/domains/root/db/olayangroup.html +olayangroup + +// ollo : Dish DBS Corporation +// https://www.iana.org/domains/root/db/ollo.html +ollo + +// omega : The Swatch Group Ltd +// https://www.iana.org/domains/root/db/omega.html +omega + +// one : One.com A/S +// https://www.iana.org/domains/root/db/one.html +one + +// ong : Public Interest Registry +// https://www.iana.org/domains/root/db/ong.html +ong + +// onl : iRegistry GmbH +// https://www.iana.org/domains/root/db/onl.html +onl + +// online : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/online.html +online + +// ooo : INFIBEAM AVENUES LIMITED +// https://www.iana.org/domains/root/db/ooo.html +ooo + +// open : American Express Travel Related Services Company, Inc. +// https://www.iana.org/domains/root/db/open.html +open + +// oracle : Oracle Corporation +// https://www.iana.org/domains/root/db/oracle.html +oracle + +// orange : Orange Brand Services Limited +// https://www.iana.org/domains/root/db/orange.html +orange + +// organic : Identity Digital Limited +// https://www.iana.org/domains/root/db/organic.html +organic + +// origins : The Estée Lauder Companies Inc. +// https://www.iana.org/domains/root/db/origins.html +origins + +// osaka : Osaka Registry Co., Ltd. +// https://www.iana.org/domains/root/db/osaka.html +osaka + +// otsuka : Otsuka Holdings Co., Ltd. +// https://www.iana.org/domains/root/db/otsuka.html +otsuka + +// ott : Dish DBS Corporation +// https://www.iana.org/domains/root/db/ott.html +ott + +// ovh : MédiaBC +// https://www.iana.org/domains/root/db/ovh.html +ovh + +// page : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/page.html +page + +// panasonic : Panasonic Holdings Corporation +// https://www.iana.org/domains/root/db/panasonic.html +panasonic + +// paris : City of Paris +// https://www.iana.org/domains/root/db/paris.html +paris + +// pars : Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +// https://www.iana.org/domains/root/db/pars.html +pars + +// partners : Binky Moon, LLC +// https://www.iana.org/domains/root/db/partners.html +partners + +// parts : Binky Moon, LLC +// https://www.iana.org/domains/root/db/parts.html +parts + +// party : Blue Sky Registry Limited +// https://www.iana.org/domains/root/db/party.html +party + +// pay : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/pay.html +pay + +// pccw : PCCW Enterprises Limited +// https://www.iana.org/domains/root/db/pccw.html +pccw + +// pet : Identity Digital Limited +// https://www.iana.org/domains/root/db/pet.html +pet + +// pfizer : Pfizer Inc. +// https://www.iana.org/domains/root/db/pfizer.html +pfizer + +// pharmacy : National Association of Boards of Pharmacy +// https://www.iana.org/domains/root/db/pharmacy.html +pharmacy + +// phd : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/phd.html +phd + +// philips : Koninklijke Philips N.V. +// https://www.iana.org/domains/root/db/philips.html +philips + +// phone : Dish DBS Corporation +// https://www.iana.org/domains/root/db/phone.html +phone + +// photo : Registry Services, LLC +// https://www.iana.org/domains/root/db/photo.html +photo + +// photography : Binky Moon, LLC +// https://www.iana.org/domains/root/db/photography.html +photography + +// photos : Binky Moon, LLC +// https://www.iana.org/domains/root/db/photos.html +photos + +// physio : PhysBiz Pty Ltd +// https://www.iana.org/domains/root/db/physio.html +physio + +// pics : XYZ.COM LLC +// https://www.iana.org/domains/root/db/pics.html +pics + +// pictet : Pictet Europe S.A. +// https://www.iana.org/domains/root/db/pictet.html +pictet + +// pictures : Binky Moon, LLC +// https://www.iana.org/domains/root/db/pictures.html +pictures + +// pid : Top Level Spectrum, Inc. +// https://www.iana.org/domains/root/db/pid.html +pid + +// pin : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/pin.html +pin + +// ping : Ping Registry Provider, Inc. +// https://www.iana.org/domains/root/db/ping.html +ping + +// pink : Identity Digital Limited +// https://www.iana.org/domains/root/db/pink.html +pink + +// pioneer : Pioneer Corporation +// https://www.iana.org/domains/root/db/pioneer.html +pioneer + +// pizza : Binky Moon, LLC +// https://www.iana.org/domains/root/db/pizza.html +pizza + +// place : Binky Moon, LLC +// https://www.iana.org/domains/root/db/place.html +place + +// play : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/play.html +play + +// playstation : Sony Interactive Entertainment Inc. +// https://www.iana.org/domains/root/db/playstation.html +playstation + +// plumbing : Binky Moon, LLC +// https://www.iana.org/domains/root/db/plumbing.html +plumbing + +// plus : Binky Moon, LLC +// https://www.iana.org/domains/root/db/plus.html +plus + +// pnc : PNC Domain Co., LLC +// https://www.iana.org/domains/root/db/pnc.html +pnc + +// pohl : Deutsche Vermögensberatung Aktiengesellschaft DVAG +// https://www.iana.org/domains/root/db/pohl.html +pohl + +// poker : Identity Digital Limited +// https://www.iana.org/domains/root/db/poker.html +poker + +// politie : Politie Nederland +// https://www.iana.org/domains/root/db/politie.html +politie + +// porn : ICM Registry PN LLC +// https://www.iana.org/domains/root/db/porn.html +porn + +// pramerica : Prudential Financial, Inc. +// https://www.iana.org/domains/root/db/pramerica.html +pramerica + +// praxi : Praxi S.p.A. +// https://www.iana.org/domains/root/db/praxi.html +praxi + +// press : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/press.html +press + +// prime : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/prime.html +prime + +// prod : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/prod.html +prod + +// productions : Binky Moon, LLC +// https://www.iana.org/domains/root/db/productions.html +productions + +// prof : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/prof.html +prof + +// progressive : Progressive Casualty Insurance Company +// https://www.iana.org/domains/root/db/progressive.html +progressive + +// promo : Identity Digital Limited +// https://www.iana.org/domains/root/db/promo.html +promo + +// properties : Binky Moon, LLC +// https://www.iana.org/domains/root/db/properties.html +properties + +// property : Digital Property Infrastructure Limited +// https://www.iana.org/domains/root/db/property.html +property + +// protection : XYZ.COM LLC +// https://www.iana.org/domains/root/db/protection.html +protection + +// pru : Prudential Financial, Inc. +// https://www.iana.org/domains/root/db/pru.html +pru + +// prudential : Prudential Financial, Inc. +// https://www.iana.org/domains/root/db/prudential.html +prudential + +// pub : Dog Beach, LLC +// https://www.iana.org/domains/root/db/pub.html +pub + +// pwc : PricewaterhouseCoopers LLP +// https://www.iana.org/domains/root/db/pwc.html +pwc + +// qpon : dotQPON LLC +// https://www.iana.org/domains/root/db/qpon.html +qpon + +// quebec : PointQuébec Inc +// https://www.iana.org/domains/root/db/quebec.html +quebec + +// quest : XYZ.COM LLC +// https://www.iana.org/domains/root/db/quest.html +quest + +// racing : Premier Registry Limited +// https://www.iana.org/domains/root/db/racing.html +racing + +// radio : European Broadcasting Union (EBU) +// https://www.iana.org/domains/root/db/radio.html +radio + +// read : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/read.html +read + +// realestate : dotRealEstate LLC +// https://www.iana.org/domains/root/db/realestate.html +realestate + +// realtor : Real Estate Domains LLC +// https://www.iana.org/domains/root/db/realtor.html +realtor + +// realty : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/realty.html +realty + +// recipes : Binky Moon, LLC +// https://www.iana.org/domains/root/db/recipes.html +recipes + +// red : Identity Digital Limited +// https://www.iana.org/domains/root/db/red.html +red + +// redstone : Redstone Haute Couture Co., Ltd. +// https://www.iana.org/domains/root/db/redstone.html +redstone + +// redumbrella : Travelers TLD, LLC +// https://www.iana.org/domains/root/db/redumbrella.html +redumbrella + +// rehab : Dog Beach, LLC +// https://www.iana.org/domains/root/db/rehab.html +rehab + +// reise : Binky Moon, LLC +// https://www.iana.org/domains/root/db/reise.html +reise + +// reisen : Binky Moon, LLC +// https://www.iana.org/domains/root/db/reisen.html +reisen + +// reit : National Association of Real Estate Investment Trusts, Inc. +// https://www.iana.org/domains/root/db/reit.html +reit + +// reliance : Reliance Industries Limited +// https://www.iana.org/domains/root/db/reliance.html +reliance + +// ren : ZDNS International Limited +// https://www.iana.org/domains/root/db/ren.html +ren + +// rent : XYZ.COM LLC +// https://www.iana.org/domains/root/db/rent.html +rent + +// rentals : Binky Moon, LLC +// https://www.iana.org/domains/root/db/rentals.html +rentals + +// repair : Binky Moon, LLC +// https://www.iana.org/domains/root/db/repair.html +repair + +// report : Binky Moon, LLC +// https://www.iana.org/domains/root/db/report.html +report + +// republican : Dog Beach, LLC +// https://www.iana.org/domains/root/db/republican.html +republican + +// rest : Punto 2012 Sociedad Anonima Promotora de Inversion de Capital Variable +// https://www.iana.org/domains/root/db/rest.html +rest + +// restaurant : Binky Moon, LLC +// https://www.iana.org/domains/root/db/restaurant.html +restaurant + +// review : dot Review Limited +// https://www.iana.org/domains/root/db/review.html +review + +// reviews : Dog Beach, LLC +// https://www.iana.org/domains/root/db/reviews.html +reviews + +// rexroth : Robert Bosch GMBH +// https://www.iana.org/domains/root/db/rexroth.html +rexroth + +// rich : iRegistry GmbH +// https://www.iana.org/domains/root/db/rich.html +rich + +// richardli : Pacific Century Asset Management (HK) Limited +// https://www.iana.org/domains/root/db/richardli.html +richardli + +// ricoh : Ricoh Company, Ltd. +// https://www.iana.org/domains/root/db/ricoh.html +ricoh + +// ril : Reliance Industries Limited +// https://www.iana.org/domains/root/db/ril.html +ril + +// rio : Empresa Municipal de Informática SA - IPLANRIO +// https://www.iana.org/domains/root/db/rio.html +rio + +// rip : Dog Beach, LLC +// https://www.iana.org/domains/root/db/rip.html +rip + +// rocks : Dog Beach, LLC +// https://www.iana.org/domains/root/db/rocks.html +rocks + +// rodeo : Registry Services, LLC +// https://www.iana.org/domains/root/db/rodeo.html +rodeo + +// rogers : Rogers Communications Canada Inc. +// https://www.iana.org/domains/root/db/rogers.html +rogers + +// room : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/room.html +room + +// rsvp : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/rsvp.html +rsvp + +// rugby : World Rugby Strategic Developments Limited +// https://www.iana.org/domains/root/db/rugby.html +rugby + +// ruhr : dotSaarland GmbH +// https://www.iana.org/domains/root/db/ruhr.html +ruhr + +// run : Binky Moon, LLC +// https://www.iana.org/domains/root/db/run.html +run + +// rwe : RWE AG +// https://www.iana.org/domains/root/db/rwe.html +rwe + +// ryukyu : BRregistry, Inc. +// https://www.iana.org/domains/root/db/ryukyu.html +ryukyu + +// saarland : dotSaarland GmbH +// https://www.iana.org/domains/root/db/saarland.html +saarland + +// safe : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/safe.html +safe + +// safety : Safety Registry Services, LLC. +// https://www.iana.org/domains/root/db/safety.html +safety + +// sakura : SAKURA Internet Inc. +// https://www.iana.org/domains/root/db/sakura.html +sakura + +// sale : Dog Beach, LLC +// https://www.iana.org/domains/root/db/sale.html +sale + +// salon : Binky Moon, LLC +// https://www.iana.org/domains/root/db/salon.html +salon + +// samsclub : Wal-Mart Stores, Inc. +// https://www.iana.org/domains/root/db/samsclub.html +samsclub + +// samsung : SAMSUNG SDS CO., LTD +// https://www.iana.org/domains/root/db/samsung.html +samsung + +// sandvik : Sandvik AB +// https://www.iana.org/domains/root/db/sandvik.html +sandvik + +// sandvikcoromant : Sandvik AB +// https://www.iana.org/domains/root/db/sandvikcoromant.html +sandvikcoromant + +// sanofi : Sanofi +// https://www.iana.org/domains/root/db/sanofi.html +sanofi + +// sap : SAP AG +// https://www.iana.org/domains/root/db/sap.html +sap + +// sarl : Binky Moon, LLC +// https://www.iana.org/domains/root/db/sarl.html +sarl + +// sas : Research IP LLC +// https://www.iana.org/domains/root/db/sas.html +sas + +// save : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/save.html +save + +// saxo : Saxo Bank A/S +// https://www.iana.org/domains/root/db/saxo.html +saxo + +// sbi : STATE BANK OF INDIA +// https://www.iana.org/domains/root/db/sbi.html +sbi + +// sbs : ShortDot SA +// https://www.iana.org/domains/root/db/sbs.html +sbs + +// scb : The Siam Commercial Bank Public Company Limited ("SCB") +// https://www.iana.org/domains/root/db/scb.html +scb + +// schaeffler : Schaeffler Technologies AG & Co. KG +// https://www.iana.org/domains/root/db/schaeffler.html +schaeffler + +// schmidt : SCHMIDT GROUPE S.A.S. +// https://www.iana.org/domains/root/db/schmidt.html +schmidt + +// scholarships : Scholarships.com, LLC +// https://www.iana.org/domains/root/db/scholarships.html +scholarships + +// school : Binky Moon, LLC +// https://www.iana.org/domains/root/db/school.html +school + +// schule : Binky Moon, LLC +// https://www.iana.org/domains/root/db/schule.html +schule + +// schwarz : Schwarz Domains und Services GmbH & Co. KG +// https://www.iana.org/domains/root/db/schwarz.html +schwarz + +// science : dot Science Limited +// https://www.iana.org/domains/root/db/science.html +science + +// scot : Dot Scot Registry Limited +// https://www.iana.org/domains/root/db/scot.html +scot + +// search : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/search.html +search + +// seat : SEAT, S.A. (Sociedad Unipersonal) +// https://www.iana.org/domains/root/db/seat.html +seat + +// secure : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/secure.html +secure + +// security : XYZ.COM LLC +// https://www.iana.org/domains/root/db/security.html +security + +// seek : Seek Limited +// https://www.iana.org/domains/root/db/seek.html +seek + +// select : Registry Services, LLC +// https://www.iana.org/domains/root/db/select.html +select + +// sener : Sener Ingeniería y Sistemas, S.A. +// https://www.iana.org/domains/root/db/sener.html +sener + +// services : Binky Moon, LLC +// https://www.iana.org/domains/root/db/services.html +services + +// seven : Seven West Media Ltd +// https://www.iana.org/domains/root/db/seven.html +seven + +// sew : SEW-EURODRIVE GmbH & Co KG +// https://www.iana.org/domains/root/db/sew.html +sew + +// sex : ICM Registry SX LLC +// https://www.iana.org/domains/root/db/sex.html +sex + +// sexy : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/sexy.html +sexy + +// sfr : Societe Francaise du Radiotelephone - SFR +// https://www.iana.org/domains/root/db/sfr.html +sfr + +// shangrila : Shangri‐La International Hotel Management Limited +// https://www.iana.org/domains/root/db/shangrila.html +shangrila + +// sharp : Sharp Corporation +// https://www.iana.org/domains/root/db/sharp.html +sharp + +// shell : Shell Information Technology International Inc +// https://www.iana.org/domains/root/db/shell.html +shell + +// shia : Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +// https://www.iana.org/domains/root/db/shia.html +shia + +// shiksha : Identity Digital Limited +// https://www.iana.org/domains/root/db/shiksha.html +shiksha + +// shoes : Binky Moon, LLC +// https://www.iana.org/domains/root/db/shoes.html +shoes + +// shop : GMO Registry, Inc. +// https://www.iana.org/domains/root/db/shop.html +shop + +// shopping : Binky Moon, LLC +// https://www.iana.org/domains/root/db/shopping.html +shopping + +// shouji : Beijing Qihu Keji Co., Ltd. +// https://www.iana.org/domains/root/db/shouji.html +shouji + +// show : Binky Moon, LLC +// https://www.iana.org/domains/root/db/show.html +show + +// silk : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/silk.html +silk + +// sina : Sina Corporation +// https://www.iana.org/domains/root/db/sina.html +sina + +// singles : Binky Moon, LLC +// https://www.iana.org/domains/root/db/singles.html +singles + +// site : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/site.html +site + +// ski : Identity Digital Limited +// https://www.iana.org/domains/root/db/ski.html +ski + +// skin : XYZ.COM LLC +// https://www.iana.org/domains/root/db/skin.html +skin + +// sky : Sky International AG +// https://www.iana.org/domains/root/db/sky.html +sky + +// skype : Microsoft Corporation +// https://www.iana.org/domains/root/db/skype.html +skype + +// sling : DISH Technologies L.L.C. +// https://www.iana.org/domains/root/db/sling.html +sling + +// smart : Smart Communications, Inc. (SMART) +// https://www.iana.org/domains/root/db/smart.html +smart + +// smile : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/smile.html +smile + +// sncf : Société Nationale SNCF +// https://www.iana.org/domains/root/db/sncf.html +sncf + +// soccer : Binky Moon, LLC +// https://www.iana.org/domains/root/db/soccer.html +soccer + +// social : Dog Beach, LLC +// https://www.iana.org/domains/root/db/social.html +social + +// softbank : SoftBank Group Corp. +// https://www.iana.org/domains/root/db/softbank.html +softbank + +// software : Dog Beach, LLC +// https://www.iana.org/domains/root/db/software.html +software + +// sohu : Sohu.com Limited +// https://www.iana.org/domains/root/db/sohu.html +sohu + +// solar : Binky Moon, LLC +// https://www.iana.org/domains/root/db/solar.html +solar + +// solutions : Binky Moon, LLC +// https://www.iana.org/domains/root/db/solutions.html +solutions + +// song : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/song.html +song + +// sony : Sony Corporation +// https://www.iana.org/domains/root/db/sony.html +sony + +// soy : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/soy.html +soy + +// spa : Asia Spa and Wellness Promotion Council Limited +// https://www.iana.org/domains/root/db/spa.html +spa + +// space : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/space.html +space + +// sport : SportAccord +// https://www.iana.org/domains/root/db/sport.html +sport + +// spot : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/spot.html +spot + +// srl : InterNetX, Corp +// https://www.iana.org/domains/root/db/srl.html +srl + +// stada : STADA Arzneimittel AG +// https://www.iana.org/domains/root/db/stada.html +stada + +// staples : Staples, Inc. +// https://www.iana.org/domains/root/db/staples.html +staples + +// star : Star India Private Limited +// https://www.iana.org/domains/root/db/star.html +star + +// statebank : STATE BANK OF INDIA +// https://www.iana.org/domains/root/db/statebank.html +statebank + +// statefarm : State Farm Mutual Automobile Insurance Company +// https://www.iana.org/domains/root/db/statefarm.html +statefarm + +// stc : Saudi Telecom Company +// https://www.iana.org/domains/root/db/stc.html +stc + +// stcgroup : Saudi Telecom Company +// https://www.iana.org/domains/root/db/stcgroup.html +stcgroup + +// stockholm : Stockholms kommun +// https://www.iana.org/domains/root/db/stockholm.html +stockholm + +// storage : XYZ.COM LLC +// https://www.iana.org/domains/root/db/storage.html +storage + +// store : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/store.html +store + +// stream : dot Stream Limited +// https://www.iana.org/domains/root/db/stream.html +stream + +// studio : Dog Beach, LLC +// https://www.iana.org/domains/root/db/studio.html +studio + +// study : Registry Services, LLC +// https://www.iana.org/domains/root/db/study.html +study + +// style : Binky Moon, LLC +// https://www.iana.org/domains/root/db/style.html +style + +// sucks : Vox Populi Registry Ltd. +// https://www.iana.org/domains/root/db/sucks.html +sucks + +// supplies : Binky Moon, LLC +// https://www.iana.org/domains/root/db/supplies.html +supplies + +// supply : Binky Moon, LLC +// https://www.iana.org/domains/root/db/supply.html +supply + +// support : Binky Moon, LLC +// https://www.iana.org/domains/root/db/support.html +support + +// surf : Registry Services, LLC +// https://www.iana.org/domains/root/db/surf.html +surf + +// surgery : Binky Moon, LLC +// https://www.iana.org/domains/root/db/surgery.html +surgery + +// suzuki : SUZUKI MOTOR CORPORATION +// https://www.iana.org/domains/root/db/suzuki.html +suzuki + +// swatch : The Swatch Group Ltd +// https://www.iana.org/domains/root/db/swatch.html +swatch + +// swiss : Swiss Confederation +// https://www.iana.org/domains/root/db/swiss.html +swiss + +// sydney : State of New South Wales, Department of Premier and Cabinet +// https://www.iana.org/domains/root/db/sydney.html +sydney + +// systems : Binky Moon, LLC +// https://www.iana.org/domains/root/db/systems.html +systems + +// tab : Tabcorp Holdings Limited +// https://www.iana.org/domains/root/db/tab.html +tab + +// taipei : Taipei City Government +// https://www.iana.org/domains/root/db/taipei.html +taipei + +// talk : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/talk.html +talk + +// taobao : Alibaba Group Holding Limited +// https://www.iana.org/domains/root/db/taobao.html +taobao + +// target : Target Domain Holdings, LLC +// https://www.iana.org/domains/root/db/target.html +target + +// tatamotors : Tata Motors Ltd +// https://www.iana.org/domains/root/db/tatamotors.html +tatamotors + +// tatar : Limited Liability Company "Coordination Center of Regional Domain of Tatarstan Republic" +// https://www.iana.org/domains/root/db/tatar.html +tatar + +// tattoo : Registry Services, LLC +// https://www.iana.org/domains/root/db/tattoo.html +tattoo + +// tax : Binky Moon, LLC +// https://www.iana.org/domains/root/db/tax.html +tax + +// taxi : Binky Moon, LLC +// https://www.iana.org/domains/root/db/taxi.html +taxi + +// tci : Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +// https://www.iana.org/domains/root/db/tci.html +tci + +// tdk : TDK Corporation +// https://www.iana.org/domains/root/db/tdk.html +tdk + +// team : Binky Moon, LLC +// https://www.iana.org/domains/root/db/team.html +team + +// tech : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/tech.html +tech + +// technology : Binky Moon, LLC +// https://www.iana.org/domains/root/db/technology.html +technology + +// temasek : Temasek Holdings (Private) Limited +// https://www.iana.org/domains/root/db/temasek.html +temasek + +// tennis : Binky Moon, LLC +// https://www.iana.org/domains/root/db/tennis.html +tennis + +// teva : Teva Pharmaceutical Industries Limited +// https://www.iana.org/domains/root/db/teva.html +teva + +// thd : Home Depot Product Authority, LLC +// https://www.iana.org/domains/root/db/thd.html +thd + +// theater : Binky Moon, LLC +// https://www.iana.org/domains/root/db/theater.html +theater + +// theatre : XYZ.COM LLC +// https://www.iana.org/domains/root/db/theatre.html +theatre + +// tiaa : Teachers Insurance and Annuity Association of America +// https://www.iana.org/domains/root/db/tiaa.html +tiaa + +// tickets : XYZ.COM LLC +// https://www.iana.org/domains/root/db/tickets.html +tickets + +// tienda : Binky Moon, LLC +// https://www.iana.org/domains/root/db/tienda.html +tienda + +// tips : Binky Moon, LLC +// https://www.iana.org/domains/root/db/tips.html +tips + +// tires : Binky Moon, LLC +// https://www.iana.org/domains/root/db/tires.html +tires + +// tirol : punkt Tirol GmbH +// https://www.iana.org/domains/root/db/tirol.html +tirol + +// tjmaxx : The TJX Companies, Inc. +// https://www.iana.org/domains/root/db/tjmaxx.html +tjmaxx + +// tjx : The TJX Companies, Inc. +// https://www.iana.org/domains/root/db/tjx.html +tjx + +// tkmaxx : The TJX Companies, Inc. +// https://www.iana.org/domains/root/db/tkmaxx.html +tkmaxx + +// tmall : Alibaba Group Holding Limited +// https://www.iana.org/domains/root/db/tmall.html +tmall + +// today : Binky Moon, LLC +// https://www.iana.org/domains/root/db/today.html +today + +// tokyo : GMO Registry, Inc. +// https://www.iana.org/domains/root/db/tokyo.html +tokyo + +// tools : Binky Moon, LLC +// https://www.iana.org/domains/root/db/tools.html +tools + +// top : .TOP Registry +// https://www.iana.org/domains/root/db/top.html +top + +// toray : Toray Industries, Inc. +// https://www.iana.org/domains/root/db/toray.html +toray + +// toshiba : TOSHIBA Corporation +// https://www.iana.org/domains/root/db/toshiba.html +toshiba + +// total : TotalEnergies SE +// https://www.iana.org/domains/root/db/total.html +total + +// tours : Binky Moon, LLC +// https://www.iana.org/domains/root/db/tours.html +tours + +// town : Binky Moon, LLC +// https://www.iana.org/domains/root/db/town.html +town + +// toyota : TOYOTA MOTOR CORPORATION +// https://www.iana.org/domains/root/db/toyota.html +toyota + +// toys : Binky Moon, LLC +// https://www.iana.org/domains/root/db/toys.html +toys + +// trade : Elite Registry Limited +// https://www.iana.org/domains/root/db/trade.html +trade + +// trading : Dog Beach, LLC +// https://www.iana.org/domains/root/db/trading.html +trading + +// training : Binky Moon, LLC +// https://www.iana.org/domains/root/db/training.html +training + +// travel : Dog Beach, LLC +// https://www.iana.org/domains/root/db/travel.html +travel + +// travelers : Travelers TLD, LLC +// https://www.iana.org/domains/root/db/travelers.html +travelers + +// travelersinsurance : Travelers TLD, LLC +// https://www.iana.org/domains/root/db/travelersinsurance.html +travelersinsurance + +// trust : Internet Naming Company LLC +// https://www.iana.org/domains/root/db/trust.html +trust + +// trv : Travelers TLD, LLC +// https://www.iana.org/domains/root/db/trv.html +trv + +// tube : Latin American Telecom LLC +// https://www.iana.org/domains/root/db/tube.html +tube + +// tui : TUI AG +// https://www.iana.org/domains/root/db/tui.html +tui + +// tunes : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/tunes.html +tunes + +// tushu : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/tushu.html +tushu + +// tvs : T V SUNDRAM IYENGAR & SONS LIMITED +// https://www.iana.org/domains/root/db/tvs.html +tvs + +// ubank : National Australia Bank Limited +// https://www.iana.org/domains/root/db/ubank.html +ubank + +// ubs : UBS AG +// https://www.iana.org/domains/root/db/ubs.html +ubs + +// unicom : China United Network Communications Corporation Limited +// https://www.iana.org/domains/root/db/unicom.html +unicom + +// university : Binky Moon, LLC +// https://www.iana.org/domains/root/db/university.html +university + +// uno : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/uno.html +uno + +// uol : UBN INTERNET LTDA. +// https://www.iana.org/domains/root/db/uol.html +uol + +// ups : UPS Market Driver, Inc. +// https://www.iana.org/domains/root/db/ups.html +ups + +// vacations : Binky Moon, LLC +// https://www.iana.org/domains/root/db/vacations.html +vacations + +// vana : D3 Registry LLC +// https://www.iana.org/domains/root/db/vana.html +vana + +// vanguard : The Vanguard Group, Inc. +// https://www.iana.org/domains/root/db/vanguard.html +vanguard + +// vegas : Dot Vegas, Inc. +// https://www.iana.org/domains/root/db/vegas.html +vegas + +// ventures : Binky Moon, LLC +// https://www.iana.org/domains/root/db/ventures.html +ventures + +// verisign : VeriSign, Inc. +// https://www.iana.org/domains/root/db/verisign.html +verisign + +// versicherung : tldbox GmbH +// https://www.iana.org/domains/root/db/versicherung.html +versicherung + +// vet : Dog Beach, LLC +// https://www.iana.org/domains/root/db/vet.html +vet + +// viajes : Binky Moon, LLC +// https://www.iana.org/domains/root/db/viajes.html +viajes + +// video : Dog Beach, LLC +// https://www.iana.org/domains/root/db/video.html +video + +// vig : VIENNA INSURANCE GROUP AG Wiener Versicherung Gruppe +// https://www.iana.org/domains/root/db/vig.html +vig + +// viking : Viking River Cruises (Bermuda) Ltd. +// https://www.iana.org/domains/root/db/viking.html +viking + +// villas : Binky Moon, LLC +// https://www.iana.org/domains/root/db/villas.html +villas + +// vin : Binky Moon, LLC +// https://www.iana.org/domains/root/db/vin.html +vin + +// vip : Registry Services, LLC +// https://www.iana.org/domains/root/db/vip.html +vip + +// virgin : Virgin Enterprises Limited +// https://www.iana.org/domains/root/db/virgin.html +virgin + +// visa : Visa Worldwide Pte. Limited +// https://www.iana.org/domains/root/db/visa.html +visa + +// vision : Binky Moon, LLC +// https://www.iana.org/domains/root/db/vision.html +vision + +// viva : Saudi Telecom Company +// https://www.iana.org/domains/root/db/viva.html +viva + +// vivo : Telefonica Brasil S.A. +// https://www.iana.org/domains/root/db/vivo.html +vivo + +// vlaanderen : DNS.be vzw +// https://www.iana.org/domains/root/db/vlaanderen.html +vlaanderen + +// vodka : Registry Services, LLC +// https://www.iana.org/domains/root/db/vodka.html +vodka + +// volvo : Volvo Holding Sverige Aktiebolag +// https://www.iana.org/domains/root/db/volvo.html +volvo + +// vote : Monolith Registry LLC +// https://www.iana.org/domains/root/db/vote.html +vote + +// voting : Valuetainment Corp. +// https://www.iana.org/domains/root/db/voting.html +voting + +// voto : Monolith Registry LLC +// https://www.iana.org/domains/root/db/voto.html +voto + +// voyage : Binky Moon, LLC +// https://www.iana.org/domains/root/db/voyage.html +voyage + +// wales : Nominet UK +// https://www.iana.org/domains/root/db/wales.html +wales + +// walmart : Wal-Mart Stores, Inc. +// https://www.iana.org/domains/root/db/walmart.html +walmart + +// walter : Sandvik AB +// https://www.iana.org/domains/root/db/walter.html +walter + +// wang : Zodiac Wang Limited +// https://www.iana.org/domains/root/db/wang.html +wang + +// wanggou : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/wanggou.html +wanggou + +// watch : Binky Moon, LLC +// https://www.iana.org/domains/root/db/watch.html +watch + +// watches : Identity Digital Limited +// https://www.iana.org/domains/root/db/watches.html +watches + +// weather : International Business Machines Corporation +// https://www.iana.org/domains/root/db/weather.html +weather + +// weatherchannel : International Business Machines Corporation +// https://www.iana.org/domains/root/db/weatherchannel.html +weatherchannel + +// webcam : dot Webcam Limited +// https://www.iana.org/domains/root/db/webcam.html +webcam + +// weber : Saint-Gobain Weber SA +// https://www.iana.org/domains/root/db/weber.html +weber + +// website : Radix Technologies Inc. +// https://www.iana.org/domains/root/db/website.html +website + +// wed +// https://www.iana.org/domains/root/db/wed.html +wed + +// wedding : Registry Services, LLC +// https://www.iana.org/domains/root/db/wedding.html +wedding + +// weibo : Sina Corporation +// https://www.iana.org/domains/root/db/weibo.html +weibo + +// weir : Weir Group IP Limited +// https://www.iana.org/domains/root/db/weir.html +weir + +// whoswho : Who's Who Registry +// https://www.iana.org/domains/root/db/whoswho.html +whoswho + +// wien : punkt.wien GmbH +// https://www.iana.org/domains/root/db/wien.html +wien + +// wiki : Registry Services, LLC +// https://www.iana.org/domains/root/db/wiki.html +wiki + +// williamhill : William Hill Organization Limited +// https://www.iana.org/domains/root/db/williamhill.html +williamhill + +// win : First Registry Limited +// https://www.iana.org/domains/root/db/win.html +win + +// windows : Microsoft Corporation +// https://www.iana.org/domains/root/db/windows.html +windows + +// wine : Binky Moon, LLC +// https://www.iana.org/domains/root/db/wine.html +wine + +// winners : The TJX Companies, Inc. +// https://www.iana.org/domains/root/db/winners.html +winners + +// wme : William Morris Endeavor Entertainment, LLC +// https://www.iana.org/domains/root/db/wme.html +wme + +// wolterskluwer : Wolters Kluwer N.V. +// https://www.iana.org/domains/root/db/wolterskluwer.html +wolterskluwer + +// woodside : Woodside Petroleum Limited +// https://www.iana.org/domains/root/db/woodside.html +woodside + +// work : Registry Services, LLC +// https://www.iana.org/domains/root/db/work.html +work + +// works : Binky Moon, LLC +// https://www.iana.org/domains/root/db/works.html +works + +// world : Binky Moon, LLC +// https://www.iana.org/domains/root/db/world.html +world + +// wow : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/wow.html +wow + +// wtc : World Trade Centers Association, Inc. +// https://www.iana.org/domains/root/db/wtc.html +wtc + +// wtf : Binky Moon, LLC +// https://www.iana.org/domains/root/db/wtf.html +wtf + +// xbox : Microsoft Corporation +// https://www.iana.org/domains/root/db/xbox.html +xbox + +// xerox : Xerox DNHC LLC +// https://www.iana.org/domains/root/db/xerox.html +xerox + +// xihuan : Beijing Qihu Keji Co., Ltd. +// https://www.iana.org/domains/root/db/xihuan.html +xihuan + +// xin : Elegant Leader Limited +// https://www.iana.org/domains/root/db/xin.html +xin + +// xn--11b4c3d : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--11b4c3d.html +कॉम + +// xn--1ck2e1b : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--1ck2e1b.html +セール + +// xn--1qqw23a : Guangzhou YU Wei Information Technology Co., Ltd. +// https://www.iana.org/domains/root/db/xn--1qqw23a.html +佛山 + +// xn--30rr7y : Excellent First Limited +// https://www.iana.org/domains/root/db/xn--30rr7y.html +慈善 + +// xn--3bst00m : Eagle Horizon Limited +// https://www.iana.org/domains/root/db/xn--3bst00m.html +集团 + +// xn--3ds443g : TLD REGISTRY LIMITED OY +// https://www.iana.org/domains/root/db/xn--3ds443g.html +在线 + +// xn--3pxu8k : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--3pxu8k.html +点看 + +// xn--42c2d9a : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--42c2d9a.html +คอม + +// xn--45q11c : Zodiac Gemini Ltd +// https://www.iana.org/domains/root/db/xn--45q11c.html +八卦 + +// xn--4gbrim : Helium TLDs Ltd +// https://www.iana.org/domains/root/db/xn--4gbrim.html +موقع + +// xn--55qw42g : China Organizational Name Administration Center +// https://www.iana.org/domains/root/db/xn--55qw42g.html +公益 + +// xn--55qx5d : China Internet Network Information Center (CNNIC) +// https://www.iana.org/domains/root/db/xn--55qx5d.html +公司 + +// xn--5su34j936bgsg : Shangri‐La International Hotel Management Limited +// https://www.iana.org/domains/root/db/xn--5su34j936bgsg.html +香格里拉 + +// xn--5tzm5g : Global Website TLD Asia Limited +// https://www.iana.org/domains/root/db/xn--5tzm5g.html +网站 + +// xn--6frz82g : Identity Digital Limited +// https://www.iana.org/domains/root/db/xn--6frz82g.html +移动 + +// xn--6qq986b3xl : Tycoon Treasure Limited +// https://www.iana.org/domains/root/db/xn--6qq986b3xl.html +我爱你 + +// xn--80adxhks : Foundation for Assistance for Internet Technologies and Infrastructure Development (FAITID) +// https://www.iana.org/domains/root/db/xn--80adxhks.html +москва + +// xn--80aqecdr1a : Pontificium Consilium de Comunicationibus Socialibus (PCCS) (Pontifical Council for Social Communication) +// https://www.iana.org/domains/root/db/xn--80aqecdr1a.html +католик + +// xn--80asehdb : CORE Association +// https://www.iana.org/domains/root/db/xn--80asehdb.html +онлайн + +// xn--80aswg : CORE Association +// https://www.iana.org/domains/root/db/xn--80aswg.html +сайт + +// xn--8y0a063a : China United Network Communications Corporation Limited +// https://www.iana.org/domains/root/db/xn--8y0a063a.html +联通 + +// xn--9dbq2a : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--9dbq2a.html +קום + +// xn--9et52u : RISE VICTORY LIMITED +// https://www.iana.org/domains/root/db/xn--9et52u.html +时尚 + +// xn--9krt00a : Sina Corporation +// https://www.iana.org/domains/root/db/xn--9krt00a.html +微博 + +// xn--b4w605ferd : Temasek Holdings (Private) Limited +// https://www.iana.org/domains/root/db/xn--b4w605ferd.html +淡马锡 + +// xn--bck1b9a5dre4c : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--bck1b9a5dre4c.html +ファッション + +// xn--c1avg : Public Interest Registry +// https://www.iana.org/domains/root/db/xn--c1avg.html +орг + +// xn--c2br7g : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--c2br7g.html +नेट + +// xn--cck2b3b : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--cck2b3b.html +ストア + +// xn--cckwcxetd : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--cckwcxetd.html +アマゾン + +// xn--cg4bki : SAMSUNG SDS CO., LTD +// https://www.iana.org/domains/root/db/xn--cg4bki.html +삼성 + +// xn--czr694b : Internet DotTrademark Organisation Limited +// https://www.iana.org/domains/root/db/xn--czr694b.html +商标 + +// xn--czrs0t : Binky Moon, LLC +// https://www.iana.org/domains/root/db/xn--czrs0t.html +商店 + +// xn--czru2d : Zodiac Aquarius Limited +// https://www.iana.org/domains/root/db/xn--czru2d.html +商城 + +// xn--d1acj3b : The Foundation for Network Initiatives “The Smart Internet” +// https://www.iana.org/domains/root/db/xn--d1acj3b.html +дети + +// xn--eckvdtc9d : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--eckvdtc9d.html +ポイント + +// xn--efvy88h : Guangzhou YU Wei Information Technology Co., Ltd. +// https://www.iana.org/domains/root/db/xn--efvy88h.html +新闻 + +// xn--fct429k : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--fct429k.html +家電 + +// xn--fhbei : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--fhbei.html +كوم + +// xn--fiq228c5hs : TLD REGISTRY LIMITED OY +// https://www.iana.org/domains/root/db/xn--fiq228c5hs.html +中文网 + +// xn--fiq64b : CITIC Group Corporation +// https://www.iana.org/domains/root/db/xn--fiq64b.html +中信 + +// xn--fjq720a : Binky Moon, LLC +// https://www.iana.org/domains/root/db/xn--fjq720a.html +娱乐 + +// xn--flw351e : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/xn--flw351e.html +谷歌 + +// xn--fzys8d69uvgm : PCCW Enterprises Limited +// https://www.iana.org/domains/root/db/xn--fzys8d69uvgm.html +電訊盈科 + +// xn--g2xx48c : Nawang Heli(Xiamen) Network Service Co., LTD. +// https://www.iana.org/domains/root/db/xn--g2xx48c.html +购物 + +// xn--gckr3f0f : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--gckr3f0f.html +クラウド + +// xn--gk3at1e : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--gk3at1e.html +通販 + +// xn--hxt814e : Zodiac Taurus Limited +// https://www.iana.org/domains/root/db/xn--hxt814e.html +网店 + +// xn--i1b6b1a6a2e : Public Interest Registry +// https://www.iana.org/domains/root/db/xn--i1b6b1a6a2e.html +संगठन + +// xn--imr513n : Internet DotTrademark Organisation Limited +// https://www.iana.org/domains/root/db/xn--imr513n.html +餐厅 + +// xn--io0a7i : China Internet Network Information Center (CNNIC) +// https://www.iana.org/domains/root/db/xn--io0a7i.html +网络 + +// xn--j1aef : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--j1aef.html +ком + +// xn--jlq480n2rg : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--jlq480n2rg.html +亚马逊 + +// xn--jvr189m : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--jvr189m.html +食品 + +// xn--kcrx77d1x4a : Koninklijke Philips N.V. +// https://www.iana.org/domains/root/db/xn--kcrx77d1x4a.html +飞利浦 + +// xn--kput3i : Beijing RITT-Net Technology Development Co., Ltd +// https://www.iana.org/domains/root/db/xn--kput3i.html +手机 + +// xn--mgba3a3ejt : Aramco Services Company +// https://www.iana.org/domains/root/db/xn--mgba3a3ejt.html +ارامكو + +// xn--mgba7c0bbn0a : Competrol (Luxembourg) Sarl +// https://www.iana.org/domains/root/db/xn--mgba7c0bbn0a.html +العليان + +// xn--mgbab2bd : CORE Association +// https://www.iana.org/domains/root/db/xn--mgbab2bd.html +بازار + +// xn--mgbca7dzdo : Abu Dhabi Systems and Information Centre +// https://www.iana.org/domains/root/db/xn--mgbca7dzdo.html +ابوظبي + +// xn--mgbi4ecexp : Pontificium Consilium de Comunicationibus Socialibus (PCCS) (Pontifical Council for Social Communication) +// https://www.iana.org/domains/root/db/xn--mgbi4ecexp.html +كاثوليك + +// xn--mgbt3dhd : Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +// https://www.iana.org/domains/root/db/xn--mgbt3dhd.html +همراه + +// xn--mk1bu44c : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--mk1bu44c.html +닷컴 + +// xn--mxtq1m : Net-Chinese Co., Ltd. +// https://www.iana.org/domains/root/db/xn--mxtq1m.html +政府 + +// xn--ngbc5azd : International Domain Registry Pty. Ltd. +// https://www.iana.org/domains/root/db/xn--ngbc5azd.html +شبكة + +// xn--ngbe9e0a : Kuwait Finance House +// https://www.iana.org/domains/root/db/xn--ngbe9e0a.html +بيتك + +// xn--ngbrx : League of Arab States +// https://www.iana.org/domains/root/db/xn--ngbrx.html +عرب + +// xn--nqv7f : Public Interest Registry +// https://www.iana.org/domains/root/db/xn--nqv7f.html +机构 + +// xn--nqv7fs00ema : Public Interest Registry +// https://www.iana.org/domains/root/db/xn--nqv7fs00ema.html +组织机构 + +// xn--nyqy26a : Stable Tone Limited +// https://www.iana.org/domains/root/db/xn--nyqy26a.html +健康 + +// xn--otu796d : Jiang Yu Liang Cai Technology Company Limited +// https://www.iana.org/domains/root/db/xn--otu796d.html +招聘 + +// xn--p1acf : Rusnames Limited +// https://www.iana.org/domains/root/db/xn--p1acf.html +рус + +// xn--pssy2u : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--pssy2u.html +大拿 + +// xn--q9jyb4c : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/xn--q9jyb4c.html +みんな + +// xn--qcka1pmc : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/xn--qcka1pmc.html +グーグル + +// xn--rhqv96g : Stable Tone Limited +// https://www.iana.org/domains/root/db/xn--rhqv96g.html +世界 + +// xn--rovu88b : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/xn--rovu88b.html +書籍 + +// xn--ses554g : KNET Co., Ltd. +// https://www.iana.org/domains/root/db/xn--ses554g.html +网址 + +// xn--t60b56a : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--t60b56a.html +닷넷 + +// xn--tckwe : VeriSign Sarl +// https://www.iana.org/domains/root/db/xn--tckwe.html +コム + +// xn--tiq49xqyj : Pontificium Consilium de Comunicationibus Socialibus (PCCS) (Pontifical Council for Social Communication) +// https://www.iana.org/domains/root/db/xn--tiq49xqyj.html +天主教 + +// xn--unup4y : Binky Moon, LLC +// https://www.iana.org/domains/root/db/xn--unup4y.html +游戏 + +// xn--vermgensberater-ctb : Deutsche Vermögensberatung Aktiengesellschaft DVAG +// https://www.iana.org/domains/root/db/xn--vermgensberater-ctb.html +vermögensberater + +// xn--vermgensberatung-pwb : Deutsche Vermögensberatung Aktiengesellschaft DVAG +// https://www.iana.org/domains/root/db/xn--vermgensberatung-pwb.html +vermögensberatung + +// xn--vhquv : Binky Moon, LLC +// https://www.iana.org/domains/root/db/xn--vhquv.html +企业 + +// xn--vuq861b : Beijing Tele-info Technology Co., Ltd. +// https://www.iana.org/domains/root/db/xn--vuq861b.html +信息 + +// xn--w4r85el8fhu5dnra : Kerry Trading Co. Limited +// https://www.iana.org/domains/root/db/xn--w4r85el8fhu5dnra.html +嘉里大酒店 + +// xn--w4rs40l : Kerry Trading Co. Limited +// https://www.iana.org/domains/root/db/xn--w4rs40l.html +嘉里 + +// xn--xhq521b : Guangzhou YU Wei Information Technology Co., Ltd. +// https://www.iana.org/domains/root/db/xn--xhq521b.html +广东 + +// xn--zfr164b : China Organizational Name Administration Center +// https://www.iana.org/domains/root/db/xn--zfr164b.html +政务 + +// xyz : XYZ.COM LLC +// https://www.iana.org/domains/root/db/xyz.html +xyz + +// yachts : XYZ.COM LLC +// https://www.iana.org/domains/root/db/yachts.html +yachts + +// yahoo : Yahoo Inc. +// https://www.iana.org/domains/root/db/yahoo.html +yahoo + +// yamaxun : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/yamaxun.html +yamaxun + +// yandex : Yandex Europe B.V. +// https://www.iana.org/domains/root/db/yandex.html +yandex + +// yodobashi : YODOBASHI CAMERA CO.,LTD. +// https://www.iana.org/domains/root/db/yodobashi.html +yodobashi + +// yoga : Registry Services, LLC +// https://www.iana.org/domains/root/db/yoga.html +yoga + +// yokohama : GMO Registry, Inc. +// https://www.iana.org/domains/root/db/yokohama.html +yokohama + +// you : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/you.html +you + +// youtube : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/youtube.html +youtube + +// yun : Beijing Qihu Keji Co., Ltd. +// https://www.iana.org/domains/root/db/yun.html +yun + +// zappos : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/zappos.html +zappos + +// zara : Industria de Diseño Textil, S.A. (INDITEX, S.A.) +// https://www.iana.org/domains/root/db/zara.html +zara + +// zero : Amazon Registry Services, Inc. +// https://www.iana.org/domains/root/db/zero.html +zero + +// zip : Charleston Road Registry Inc. +// https://www.iana.org/domains/root/db/zip.html +zip + +// zone : Binky Moon, LLC +// https://www.iana.org/domains/root/db/zone.html +zone + +// zuerich : Kanton Zürich (Canton of Zurich) +// https://www.iana.org/domains/root/db/zuerich.html +zuerich + + +// ===END ICANN DOMAINS=== +// ===BEGIN PRIVATE DOMAINS=== +// (Note: these are in alphabetical order by company name) + +// 12CHARS: https://12chars.com +// Submitted by Kenny Niehage +12chars.dev +12chars.it +12chars.pro + +// 1GB LLC : https://www.1gb.ua/ +// Submitted by 1GB LLC +cc.ua +inf.ua +ltd.ua + +// 611coin : https://611project.org/ +611.to + +// AAA workspace : https://aaa.vodka +// Submitted by Kirill Rezraf +aaa.vodka + +// A2 Hosting +// Submitted by Tyler Hall +a2hosted.com +cpserver.com + +// Aaron Marais' Gitlab pages: https://lab.aaronleem.co.za +// Submitted by Aaron Marais +graphox.us + +// accesso Technology Group, plc. : https://accesso.com/ +// Submitted by accesso Team +*.devcdnaccesso.com + +// Acorn Labs : https://acorn.io +// Submitted by Craig Jellick +*.on-acorn.io + +// ActiveTrail: https://www.activetrail.biz/ +// Submitted by Ofer Kalaora +activetrail.biz + +// Adaptable.io : https://adaptable.io +// Submitted by Mark Terrel +adaptable.app + +// Adobe : https://www.adobe.com/ +// Submitted by Ian Boston and Lars Trieloff +adobeaemcloud.com +*.dev.adobeaemcloud.com +aem.live +hlx.live +adobeaemcloud.net +aem.page +hlx.page +hlx3.page + +// Adobe Developer Platform : https://developer.adobe.com +// Submitted by Jesse MacFadyen +adobeio-static.net +adobeioruntime.net + +// Agnat sp. z o.o. : https://domena.pl +// Submitted by Przemyslaw Plewa +beep.pl + +// Airkit : https://www.airkit.com/ +// Submitted by Grant Cooksey +airkitapps.com +airkitapps-au.com +airkitapps.eu + +// Aiven: https://aiven.io/ +// Submitted by Etienne Stalmans +aivencloud.com + +// Akamai : https://www.akamai.com/ +// Submitted by Akamai Team +akadns.net +akamai.net +akamai-staging.net +akamaiedge.net +akamaiedge-staging.net +akamaihd.net +akamaihd-staging.net +akamaiorigin.net +akamaiorigin-staging.net +akamaized.net +akamaized-staging.net +edgekey.net +edgekey-staging.net +edgesuite.net +edgesuite-staging.net + +// alboto.ca : http://alboto.ca +// Submitted by Anton Avramov +barsy.ca + +// Alces Software Ltd : http://alces-software.com +// Submitted by Mark J. Titorenko +*.compute.estate +*.alces.network + +// all-inkl.com : https://all-inkl.com +// Submitted by Werner Kaltofen +kasserver.com + +// Altervista: https://www.altervista.org +// Submitted by Carlo Cannas +altervista.org + +// alwaysdata : https://www.alwaysdata.com +// Submitted by Cyril +alwaysdata.net + +// Amaze Software : https://amaze.co +// Submitted by Domain Admin +myamaze.net + +// Amazon : https://www.amazon.com/ +// Submitted by AWS Security +// Subsections of Amazon/subsidiaries will appear until "concludes" tag + +// Amazon API Gateway +// Submitted by AWS Security +// Reference: 9e37648f-a66c-4655-9ab1-5981f8737197 +execute-api.cn-north-1.amazonaws.com.cn +execute-api.cn-northwest-1.amazonaws.com.cn +execute-api.af-south-1.amazonaws.com +execute-api.ap-east-1.amazonaws.com +execute-api.ap-northeast-1.amazonaws.com +execute-api.ap-northeast-2.amazonaws.com +execute-api.ap-northeast-3.amazonaws.com +execute-api.ap-south-1.amazonaws.com +execute-api.ap-south-2.amazonaws.com +execute-api.ap-southeast-1.amazonaws.com +execute-api.ap-southeast-2.amazonaws.com +execute-api.ap-southeast-3.amazonaws.com +execute-api.ap-southeast-4.amazonaws.com +execute-api.ca-central-1.amazonaws.com +execute-api.ca-west-1.amazonaws.com +execute-api.eu-central-1.amazonaws.com +execute-api.eu-central-2.amazonaws.com +execute-api.eu-north-1.amazonaws.com +execute-api.eu-south-1.amazonaws.com +execute-api.eu-south-2.amazonaws.com +execute-api.eu-west-1.amazonaws.com +execute-api.eu-west-2.amazonaws.com +execute-api.eu-west-3.amazonaws.com +execute-api.il-central-1.amazonaws.com +execute-api.me-central-1.amazonaws.com +execute-api.me-south-1.amazonaws.com +execute-api.sa-east-1.amazonaws.com +execute-api.us-east-1.amazonaws.com +execute-api.us-east-2.amazonaws.com +execute-api.us-gov-east-1.amazonaws.com +execute-api.us-gov-west-1.amazonaws.com +execute-api.us-west-1.amazonaws.com +execute-api.us-west-2.amazonaws.com + +// Amazon CloudFront +// Submitted by Donavan Miller +// Reference: 54144616-fd49-4435-8535-19c6a601bdb3 +cloudfront.net + +// Amazon Cognito +// Submitted by AWS Security +// Reference: cb38c251-c93d-4cda-81ec-e72c4f0fdb72 +auth.af-south-1.amazoncognito.com +auth.ap-east-1.amazoncognito.com +auth.ap-northeast-1.amazoncognito.com +auth.ap-northeast-2.amazoncognito.com +auth.ap-northeast-3.amazoncognito.com +auth.ap-south-1.amazoncognito.com +auth.ap-south-2.amazoncognito.com +auth.ap-southeast-1.amazoncognito.com +auth.ap-southeast-2.amazoncognito.com +auth.ap-southeast-3.amazoncognito.com +auth.ap-southeast-4.amazoncognito.com +auth.ca-central-1.amazoncognito.com +auth.ca-west-1.amazoncognito.com +auth.eu-central-1.amazoncognito.com +auth.eu-central-2.amazoncognito.com +auth.eu-north-1.amazoncognito.com +auth.eu-south-1.amazoncognito.com +auth.eu-south-2.amazoncognito.com +auth.eu-west-1.amazoncognito.com +auth.eu-west-2.amazoncognito.com +auth.eu-west-3.amazoncognito.com +auth.il-central-1.amazoncognito.com +auth.me-central-1.amazoncognito.com +auth.me-south-1.amazoncognito.com +auth.sa-east-1.amazoncognito.com +auth.us-east-1.amazoncognito.com +auth-fips.us-east-1.amazoncognito.com +auth.us-east-2.amazoncognito.com +auth-fips.us-east-2.amazoncognito.com +auth-fips.us-gov-west-1.amazoncognito.com +auth.us-west-1.amazoncognito.com +auth-fips.us-west-1.amazoncognito.com +auth.us-west-2.amazoncognito.com +auth-fips.us-west-2.amazoncognito.com + +// Amazon EC2 +// Submitted by Luke Wells +// Reference: 4c38fa71-58ac-4768-99e5-689c1767e537 +*.compute.amazonaws.com.cn +*.compute.amazonaws.com +*.compute-1.amazonaws.com +us-east-1.amazonaws.com + +// Amazon EMR +// Submitted by AWS Security +// Reference: 82f43f9f-bbb8-400e-8349-854f5a62f20d +emrappui-prod.cn-north-1.amazonaws.com.cn +emrnotebooks-prod.cn-north-1.amazonaws.com.cn +emrstudio-prod.cn-north-1.amazonaws.com.cn +emrappui-prod.cn-northwest-1.amazonaws.com.cn +emrnotebooks-prod.cn-northwest-1.amazonaws.com.cn +emrstudio-prod.cn-northwest-1.amazonaws.com.cn +emrappui-prod.af-south-1.amazonaws.com +emrnotebooks-prod.af-south-1.amazonaws.com +emrstudio-prod.af-south-1.amazonaws.com +emrappui-prod.ap-east-1.amazonaws.com +emrnotebooks-prod.ap-east-1.amazonaws.com +emrstudio-prod.ap-east-1.amazonaws.com +emrappui-prod.ap-northeast-1.amazonaws.com +emrnotebooks-prod.ap-northeast-1.amazonaws.com +emrstudio-prod.ap-northeast-1.amazonaws.com +emrappui-prod.ap-northeast-2.amazonaws.com +emrnotebooks-prod.ap-northeast-2.amazonaws.com +emrstudio-prod.ap-northeast-2.amazonaws.com +emrappui-prod.ap-northeast-3.amazonaws.com +emrnotebooks-prod.ap-northeast-3.amazonaws.com +emrstudio-prod.ap-northeast-3.amazonaws.com +emrappui-prod.ap-south-1.amazonaws.com +emrnotebooks-prod.ap-south-1.amazonaws.com +emrstudio-prod.ap-south-1.amazonaws.com +emrappui-prod.ap-south-2.amazonaws.com +emrnotebooks-prod.ap-south-2.amazonaws.com +emrstudio-prod.ap-south-2.amazonaws.com +emrappui-prod.ap-southeast-1.amazonaws.com +emrnotebooks-prod.ap-southeast-1.amazonaws.com +emrstudio-prod.ap-southeast-1.amazonaws.com +emrappui-prod.ap-southeast-2.amazonaws.com +emrnotebooks-prod.ap-southeast-2.amazonaws.com +emrstudio-prod.ap-southeast-2.amazonaws.com +emrappui-prod.ap-southeast-3.amazonaws.com +emrnotebooks-prod.ap-southeast-3.amazonaws.com +emrstudio-prod.ap-southeast-3.amazonaws.com +emrappui-prod.ap-southeast-4.amazonaws.com +emrnotebooks-prod.ap-southeast-4.amazonaws.com +emrstudio-prod.ap-southeast-4.amazonaws.com +emrappui-prod.ca-central-1.amazonaws.com +emrnotebooks-prod.ca-central-1.amazonaws.com +emrstudio-prod.ca-central-1.amazonaws.com +emrappui-prod.ca-west-1.amazonaws.com +emrnotebooks-prod.ca-west-1.amazonaws.com +emrstudio-prod.ca-west-1.amazonaws.com +emrappui-prod.eu-central-1.amazonaws.com +emrnotebooks-prod.eu-central-1.amazonaws.com +emrstudio-prod.eu-central-1.amazonaws.com +emrappui-prod.eu-central-2.amazonaws.com +emrnotebooks-prod.eu-central-2.amazonaws.com +emrstudio-prod.eu-central-2.amazonaws.com +emrappui-prod.eu-north-1.amazonaws.com +emrnotebooks-prod.eu-north-1.amazonaws.com +emrstudio-prod.eu-north-1.amazonaws.com +emrappui-prod.eu-south-1.amazonaws.com +emrnotebooks-prod.eu-south-1.amazonaws.com +emrstudio-prod.eu-south-1.amazonaws.com +emrappui-prod.eu-south-2.amazonaws.com +emrnotebooks-prod.eu-south-2.amazonaws.com +emrstudio-prod.eu-south-2.amazonaws.com +emrappui-prod.eu-west-1.amazonaws.com +emrnotebooks-prod.eu-west-1.amazonaws.com +emrstudio-prod.eu-west-1.amazonaws.com +emrappui-prod.eu-west-2.amazonaws.com +emrnotebooks-prod.eu-west-2.amazonaws.com +emrstudio-prod.eu-west-2.amazonaws.com +emrappui-prod.eu-west-3.amazonaws.com +emrnotebooks-prod.eu-west-3.amazonaws.com +emrstudio-prod.eu-west-3.amazonaws.com +emrappui-prod.il-central-1.amazonaws.com +emrnotebooks-prod.il-central-1.amazonaws.com +emrstudio-prod.il-central-1.amazonaws.com +emrappui-prod.me-central-1.amazonaws.com +emrnotebooks-prod.me-central-1.amazonaws.com +emrstudio-prod.me-central-1.amazonaws.com +emrappui-prod.me-south-1.amazonaws.com +emrnotebooks-prod.me-south-1.amazonaws.com +emrstudio-prod.me-south-1.amazonaws.com +emrappui-prod.sa-east-1.amazonaws.com +emrnotebooks-prod.sa-east-1.amazonaws.com +emrstudio-prod.sa-east-1.amazonaws.com +emrappui-prod.us-east-1.amazonaws.com +emrnotebooks-prod.us-east-1.amazonaws.com +emrstudio-prod.us-east-1.amazonaws.com +emrappui-prod.us-east-2.amazonaws.com +emrnotebooks-prod.us-east-2.amazonaws.com +emrstudio-prod.us-east-2.amazonaws.com +emrappui-prod.us-gov-east-1.amazonaws.com +emrnotebooks-prod.us-gov-east-1.amazonaws.com +emrstudio-prod.us-gov-east-1.amazonaws.com +emrappui-prod.us-gov-west-1.amazonaws.com +emrnotebooks-prod.us-gov-west-1.amazonaws.com +emrstudio-prod.us-gov-west-1.amazonaws.com +emrappui-prod.us-west-1.amazonaws.com +emrnotebooks-prod.us-west-1.amazonaws.com +emrstudio-prod.us-west-1.amazonaws.com +emrappui-prod.us-west-2.amazonaws.com +emrnotebooks-prod.us-west-2.amazonaws.com +emrstudio-prod.us-west-2.amazonaws.com + +// Amazon Managed Workflows for Apache Airflow +// Submitted by AWS Security +// Reference: f5ea5d0a-ec6a-4f23-ac1c-553fbff13f5c +*.cn-north-1.airflow.amazonaws.com.cn +*.cn-northwest-1.airflow.amazonaws.com.cn +*.af-south-1.airflow.amazonaws.com +*.ap-east-1.airflow.amazonaws.com +*.ap-northeast-1.airflow.amazonaws.com +*.ap-northeast-2.airflow.amazonaws.com +*.ap-northeast-3.airflow.amazonaws.com +*.ap-south-1.airflow.amazonaws.com +*.ap-south-2.airflow.amazonaws.com +*.ap-southeast-1.airflow.amazonaws.com +*.ap-southeast-2.airflow.amazonaws.com +*.ap-southeast-3.airflow.amazonaws.com +*.ap-southeast-4.airflow.amazonaws.com +*.ca-central-1.airflow.amazonaws.com +*.ca-west-1.airflow.amazonaws.com +*.eu-central-1.airflow.amazonaws.com +*.eu-central-2.airflow.amazonaws.com +*.eu-north-1.airflow.amazonaws.com +*.eu-south-1.airflow.amazonaws.com +*.eu-south-2.airflow.amazonaws.com +*.eu-west-1.airflow.amazonaws.com +*.eu-west-2.airflow.amazonaws.com +*.eu-west-3.airflow.amazonaws.com +*.il-central-1.airflow.amazonaws.com +*.me-central-1.airflow.amazonaws.com +*.me-south-1.airflow.amazonaws.com +*.sa-east-1.airflow.amazonaws.com +*.us-east-1.airflow.amazonaws.com +*.us-east-2.airflow.amazonaws.com +*.us-west-1.airflow.amazonaws.com +*.us-west-2.airflow.amazonaws.com + +// Amazon S3 +// Submitted by AWS Security +// Reference: cd5c8b3a-67b7-4b40-9236-c87ce81a3d10 +s3.dualstack.cn-north-1.amazonaws.com.cn +s3-accesspoint.dualstack.cn-north-1.amazonaws.com.cn +s3-website.dualstack.cn-north-1.amazonaws.com.cn +s3.cn-north-1.amazonaws.com.cn +s3-accesspoint.cn-north-1.amazonaws.com.cn +s3-deprecated.cn-north-1.amazonaws.com.cn +s3-object-lambda.cn-north-1.amazonaws.com.cn +s3-website.cn-north-1.amazonaws.com.cn +s3.dualstack.cn-northwest-1.amazonaws.com.cn +s3-accesspoint.dualstack.cn-northwest-1.amazonaws.com.cn +s3.cn-northwest-1.amazonaws.com.cn +s3-accesspoint.cn-northwest-1.amazonaws.com.cn +s3-object-lambda.cn-northwest-1.amazonaws.com.cn +s3-website.cn-northwest-1.amazonaws.com.cn +s3.dualstack.af-south-1.amazonaws.com +s3-accesspoint.dualstack.af-south-1.amazonaws.com +s3-website.dualstack.af-south-1.amazonaws.com +s3.af-south-1.amazonaws.com +s3-accesspoint.af-south-1.amazonaws.com +s3-object-lambda.af-south-1.amazonaws.com +s3-website.af-south-1.amazonaws.com +s3.dualstack.ap-east-1.amazonaws.com +s3-accesspoint.dualstack.ap-east-1.amazonaws.com +s3.ap-east-1.amazonaws.com +s3-accesspoint.ap-east-1.amazonaws.com +s3-object-lambda.ap-east-1.amazonaws.com +s3-website.ap-east-1.amazonaws.com +s3.dualstack.ap-northeast-1.amazonaws.com +s3-accesspoint.dualstack.ap-northeast-1.amazonaws.com +s3-website.dualstack.ap-northeast-1.amazonaws.com +s3.ap-northeast-1.amazonaws.com +s3-accesspoint.ap-northeast-1.amazonaws.com +s3-object-lambda.ap-northeast-1.amazonaws.com +s3-website.ap-northeast-1.amazonaws.com +s3.dualstack.ap-northeast-2.amazonaws.com +s3-accesspoint.dualstack.ap-northeast-2.amazonaws.com +s3-website.dualstack.ap-northeast-2.amazonaws.com +s3.ap-northeast-2.amazonaws.com +s3-accesspoint.ap-northeast-2.amazonaws.com +s3-object-lambda.ap-northeast-2.amazonaws.com +s3-website.ap-northeast-2.amazonaws.com +s3.dualstack.ap-northeast-3.amazonaws.com +s3-accesspoint.dualstack.ap-northeast-3.amazonaws.com +s3-website.dualstack.ap-northeast-3.amazonaws.com +s3.ap-northeast-3.amazonaws.com +s3-accesspoint.ap-northeast-3.amazonaws.com +s3-object-lambda.ap-northeast-3.amazonaws.com +s3-website.ap-northeast-3.amazonaws.com +s3.dualstack.ap-south-1.amazonaws.com +s3-accesspoint.dualstack.ap-south-1.amazonaws.com +s3-website.dualstack.ap-south-1.amazonaws.com +s3.ap-south-1.amazonaws.com +s3-accesspoint.ap-south-1.amazonaws.com +s3-object-lambda.ap-south-1.amazonaws.com +s3-website.ap-south-1.amazonaws.com +s3.dualstack.ap-south-2.amazonaws.com +s3-accesspoint.dualstack.ap-south-2.amazonaws.com +s3.ap-south-2.amazonaws.com +s3-accesspoint.ap-south-2.amazonaws.com +s3-object-lambda.ap-south-2.amazonaws.com +s3-website.ap-south-2.amazonaws.com +s3.dualstack.ap-southeast-1.amazonaws.com +s3-accesspoint.dualstack.ap-southeast-1.amazonaws.com +s3-website.dualstack.ap-southeast-1.amazonaws.com +s3.ap-southeast-1.amazonaws.com +s3-accesspoint.ap-southeast-1.amazonaws.com +s3-object-lambda.ap-southeast-1.amazonaws.com +s3-website.ap-southeast-1.amazonaws.com +s3.dualstack.ap-southeast-2.amazonaws.com +s3-accesspoint.dualstack.ap-southeast-2.amazonaws.com +s3-website.dualstack.ap-southeast-2.amazonaws.com +s3.ap-southeast-2.amazonaws.com +s3-accesspoint.ap-southeast-2.amazonaws.com +s3-object-lambda.ap-southeast-2.amazonaws.com +s3-website.ap-southeast-2.amazonaws.com +s3.dualstack.ap-southeast-3.amazonaws.com +s3-accesspoint.dualstack.ap-southeast-3.amazonaws.com +s3.ap-southeast-3.amazonaws.com +s3-accesspoint.ap-southeast-3.amazonaws.com +s3-object-lambda.ap-southeast-3.amazonaws.com +s3-website.ap-southeast-3.amazonaws.com +s3.dualstack.ap-southeast-4.amazonaws.com +s3-accesspoint.dualstack.ap-southeast-4.amazonaws.com +s3.ap-southeast-4.amazonaws.com +s3-accesspoint.ap-southeast-4.amazonaws.com +s3-object-lambda.ap-southeast-4.amazonaws.com +s3-website.ap-southeast-4.amazonaws.com +s3.dualstack.ca-central-1.amazonaws.com +s3-accesspoint.dualstack.ca-central-1.amazonaws.com +s3-accesspoint-fips.dualstack.ca-central-1.amazonaws.com +s3-fips.dualstack.ca-central-1.amazonaws.com +s3-website.dualstack.ca-central-1.amazonaws.com +s3.ca-central-1.amazonaws.com +s3-accesspoint.ca-central-1.amazonaws.com +s3-accesspoint-fips.ca-central-1.amazonaws.com +s3-fips.ca-central-1.amazonaws.com +s3-object-lambda.ca-central-1.amazonaws.com +s3-website.ca-central-1.amazonaws.com +s3.dualstack.ca-west-1.amazonaws.com +s3-accesspoint.dualstack.ca-west-1.amazonaws.com +s3-accesspoint-fips.dualstack.ca-west-1.amazonaws.com +s3-fips.dualstack.ca-west-1.amazonaws.com +s3-website.dualstack.ca-west-1.amazonaws.com +s3.ca-west-1.amazonaws.com +s3-accesspoint.ca-west-1.amazonaws.com +s3-accesspoint-fips.ca-west-1.amazonaws.com +s3-fips.ca-west-1.amazonaws.com +s3-website.ca-west-1.amazonaws.com +s3.dualstack.eu-central-1.amazonaws.com +s3-accesspoint.dualstack.eu-central-1.amazonaws.com +s3-website.dualstack.eu-central-1.amazonaws.com +s3.eu-central-1.amazonaws.com +s3-accesspoint.eu-central-1.amazonaws.com +s3-object-lambda.eu-central-1.amazonaws.com +s3-website.eu-central-1.amazonaws.com +s3.dualstack.eu-central-2.amazonaws.com +s3-accesspoint.dualstack.eu-central-2.amazonaws.com +s3.eu-central-2.amazonaws.com +s3-accesspoint.eu-central-2.amazonaws.com +s3-object-lambda.eu-central-2.amazonaws.com +s3-website.eu-central-2.amazonaws.com +s3.dualstack.eu-north-1.amazonaws.com +s3-accesspoint.dualstack.eu-north-1.amazonaws.com +s3.eu-north-1.amazonaws.com +s3-accesspoint.eu-north-1.amazonaws.com +s3-object-lambda.eu-north-1.amazonaws.com +s3-website.eu-north-1.amazonaws.com +s3.dualstack.eu-south-1.amazonaws.com +s3-accesspoint.dualstack.eu-south-1.amazonaws.com +s3-website.dualstack.eu-south-1.amazonaws.com +s3.eu-south-1.amazonaws.com +s3-accesspoint.eu-south-1.amazonaws.com +s3-object-lambda.eu-south-1.amazonaws.com +s3-website.eu-south-1.amazonaws.com +s3.dualstack.eu-south-2.amazonaws.com +s3-accesspoint.dualstack.eu-south-2.amazonaws.com +s3.eu-south-2.amazonaws.com +s3-accesspoint.eu-south-2.amazonaws.com +s3-object-lambda.eu-south-2.amazonaws.com +s3-website.eu-south-2.amazonaws.com +s3.dualstack.eu-west-1.amazonaws.com +s3-accesspoint.dualstack.eu-west-1.amazonaws.com +s3-website.dualstack.eu-west-1.amazonaws.com +s3.eu-west-1.amazonaws.com +s3-accesspoint.eu-west-1.amazonaws.com +s3-deprecated.eu-west-1.amazonaws.com +s3-object-lambda.eu-west-1.amazonaws.com +s3-website.eu-west-1.amazonaws.com +s3.dualstack.eu-west-2.amazonaws.com +s3-accesspoint.dualstack.eu-west-2.amazonaws.com +s3.eu-west-2.amazonaws.com +s3-accesspoint.eu-west-2.amazonaws.com +s3-object-lambda.eu-west-2.amazonaws.com +s3-website.eu-west-2.amazonaws.com +s3.dualstack.eu-west-3.amazonaws.com +s3-accesspoint.dualstack.eu-west-3.amazonaws.com +s3-website.dualstack.eu-west-3.amazonaws.com +s3.eu-west-3.amazonaws.com +s3-accesspoint.eu-west-3.amazonaws.com +s3-object-lambda.eu-west-3.amazonaws.com +s3-website.eu-west-3.amazonaws.com +s3.dualstack.il-central-1.amazonaws.com +s3-accesspoint.dualstack.il-central-1.amazonaws.com +s3.il-central-1.amazonaws.com +s3-accesspoint.il-central-1.amazonaws.com +s3-object-lambda.il-central-1.amazonaws.com +s3-website.il-central-1.amazonaws.com +s3.dualstack.me-central-1.amazonaws.com +s3-accesspoint.dualstack.me-central-1.amazonaws.com +s3.me-central-1.amazonaws.com +s3-accesspoint.me-central-1.amazonaws.com +s3-object-lambda.me-central-1.amazonaws.com +s3-website.me-central-1.amazonaws.com +s3.dualstack.me-south-1.amazonaws.com +s3-accesspoint.dualstack.me-south-1.amazonaws.com +s3.me-south-1.amazonaws.com +s3-accesspoint.me-south-1.amazonaws.com +s3-object-lambda.me-south-1.amazonaws.com +s3-website.me-south-1.amazonaws.com +s3.amazonaws.com +s3-1.amazonaws.com +s3-ap-east-1.amazonaws.com +s3-ap-northeast-1.amazonaws.com +s3-ap-northeast-2.amazonaws.com +s3-ap-northeast-3.amazonaws.com +s3-ap-south-1.amazonaws.com +s3-ap-southeast-1.amazonaws.com +s3-ap-southeast-2.amazonaws.com +s3-ca-central-1.amazonaws.com +s3-eu-central-1.amazonaws.com +s3-eu-north-1.amazonaws.com +s3-eu-west-1.amazonaws.com +s3-eu-west-2.amazonaws.com +s3-eu-west-3.amazonaws.com +s3-external-1.amazonaws.com +s3-fips-us-gov-east-1.amazonaws.com +s3-fips-us-gov-west-1.amazonaws.com +mrap.accesspoint.s3-global.amazonaws.com +s3-me-south-1.amazonaws.com +s3-sa-east-1.amazonaws.com +s3-us-east-2.amazonaws.com +s3-us-gov-east-1.amazonaws.com +s3-us-gov-west-1.amazonaws.com +s3-us-west-1.amazonaws.com +s3-us-west-2.amazonaws.com +s3-website-ap-northeast-1.amazonaws.com +s3-website-ap-southeast-1.amazonaws.com +s3-website-ap-southeast-2.amazonaws.com +s3-website-eu-west-1.amazonaws.com +s3-website-sa-east-1.amazonaws.com +s3-website-us-east-1.amazonaws.com +s3-website-us-gov-west-1.amazonaws.com +s3-website-us-west-1.amazonaws.com +s3-website-us-west-2.amazonaws.com +s3.dualstack.sa-east-1.amazonaws.com +s3-accesspoint.dualstack.sa-east-1.amazonaws.com +s3-website.dualstack.sa-east-1.amazonaws.com +s3.sa-east-1.amazonaws.com +s3-accesspoint.sa-east-1.amazonaws.com +s3-object-lambda.sa-east-1.amazonaws.com +s3-website.sa-east-1.amazonaws.com +s3.dualstack.us-east-1.amazonaws.com +s3-accesspoint.dualstack.us-east-1.amazonaws.com +s3-accesspoint-fips.dualstack.us-east-1.amazonaws.com +s3-fips.dualstack.us-east-1.amazonaws.com +s3-website.dualstack.us-east-1.amazonaws.com +s3.us-east-1.amazonaws.com +s3-accesspoint.us-east-1.amazonaws.com +s3-accesspoint-fips.us-east-1.amazonaws.com +s3-deprecated.us-east-1.amazonaws.com +s3-fips.us-east-1.amazonaws.com +s3-object-lambda.us-east-1.amazonaws.com +s3-website.us-east-1.amazonaws.com +s3.dualstack.us-east-2.amazonaws.com +s3-accesspoint.dualstack.us-east-2.amazonaws.com +s3-accesspoint-fips.dualstack.us-east-2.amazonaws.com +s3-fips.dualstack.us-east-2.amazonaws.com +s3.us-east-2.amazonaws.com +s3-accesspoint.us-east-2.amazonaws.com +s3-accesspoint-fips.us-east-2.amazonaws.com +s3-deprecated.us-east-2.amazonaws.com +s3-fips.us-east-2.amazonaws.com +s3-object-lambda.us-east-2.amazonaws.com +s3-website.us-east-2.amazonaws.com +s3.dualstack.us-gov-east-1.amazonaws.com +s3-accesspoint.dualstack.us-gov-east-1.amazonaws.com +s3-accesspoint-fips.dualstack.us-gov-east-1.amazonaws.com +s3-fips.dualstack.us-gov-east-1.amazonaws.com +s3.us-gov-east-1.amazonaws.com +s3-accesspoint.us-gov-east-1.amazonaws.com +s3-accesspoint-fips.us-gov-east-1.amazonaws.com +s3-fips.us-gov-east-1.amazonaws.com +s3-object-lambda.us-gov-east-1.amazonaws.com +s3-website.us-gov-east-1.amazonaws.com +s3.dualstack.us-gov-west-1.amazonaws.com +s3-accesspoint.dualstack.us-gov-west-1.amazonaws.com +s3-accesspoint-fips.dualstack.us-gov-west-1.amazonaws.com +s3-fips.dualstack.us-gov-west-1.amazonaws.com +s3.us-gov-west-1.amazonaws.com +s3-accesspoint.us-gov-west-1.amazonaws.com +s3-accesspoint-fips.us-gov-west-1.amazonaws.com +s3-fips.us-gov-west-1.amazonaws.com +s3-object-lambda.us-gov-west-1.amazonaws.com +s3-website.us-gov-west-1.amazonaws.com +s3.dualstack.us-west-1.amazonaws.com +s3-accesspoint.dualstack.us-west-1.amazonaws.com +s3-accesspoint-fips.dualstack.us-west-1.amazonaws.com +s3-fips.dualstack.us-west-1.amazonaws.com +s3-website.dualstack.us-west-1.amazonaws.com +s3.us-west-1.amazonaws.com +s3-accesspoint.us-west-1.amazonaws.com +s3-accesspoint-fips.us-west-1.amazonaws.com +s3-fips.us-west-1.amazonaws.com +s3-object-lambda.us-west-1.amazonaws.com +s3-website.us-west-1.amazonaws.com +s3.dualstack.us-west-2.amazonaws.com +s3-accesspoint.dualstack.us-west-2.amazonaws.com +s3-accesspoint-fips.dualstack.us-west-2.amazonaws.com +s3-fips.dualstack.us-west-2.amazonaws.com +s3-website.dualstack.us-west-2.amazonaws.com +s3.us-west-2.amazonaws.com +s3-accesspoint.us-west-2.amazonaws.com +s3-accesspoint-fips.us-west-2.amazonaws.com +s3-deprecated.us-west-2.amazonaws.com +s3-fips.us-west-2.amazonaws.com +s3-object-lambda.us-west-2.amazonaws.com +s3-website.us-west-2.amazonaws.com + +// Amazon SageMaker Ground Truth +// Submitted by AWS Security +// Reference: 98dbfde4-7802-48c3-8751-b60f204e0d9c +labeling.ap-northeast-1.sagemaker.aws +labeling.ap-northeast-2.sagemaker.aws +labeling.ap-south-1.sagemaker.aws +labeling.ap-southeast-1.sagemaker.aws +labeling.ap-southeast-2.sagemaker.aws +labeling.ca-central-1.sagemaker.aws +labeling.eu-central-1.sagemaker.aws +labeling.eu-west-1.sagemaker.aws +labeling.eu-west-2.sagemaker.aws +labeling.us-east-1.sagemaker.aws +labeling.us-east-2.sagemaker.aws +labeling.us-west-2.sagemaker.aws + +// Amazon SageMaker Notebook Instances +// Submitted by AWS Security +// Reference: b5ea56df-669e-43cc-9537-14aa172f5dfc +notebook.af-south-1.sagemaker.aws +notebook.ap-east-1.sagemaker.aws +notebook.ap-northeast-1.sagemaker.aws +notebook.ap-northeast-2.sagemaker.aws +notebook.ap-northeast-3.sagemaker.aws +notebook.ap-south-1.sagemaker.aws +notebook.ap-south-2.sagemaker.aws +notebook.ap-southeast-1.sagemaker.aws +notebook.ap-southeast-2.sagemaker.aws +notebook.ap-southeast-3.sagemaker.aws +notebook.ap-southeast-4.sagemaker.aws +notebook.ca-central-1.sagemaker.aws +notebook-fips.ca-central-1.sagemaker.aws +notebook.ca-west-1.sagemaker.aws +notebook-fips.ca-west-1.sagemaker.aws +notebook.eu-central-1.sagemaker.aws +notebook.eu-central-2.sagemaker.aws +notebook.eu-north-1.sagemaker.aws +notebook.eu-south-1.sagemaker.aws +notebook.eu-south-2.sagemaker.aws +notebook.eu-west-1.sagemaker.aws +notebook.eu-west-2.sagemaker.aws +notebook.eu-west-3.sagemaker.aws +notebook.il-central-1.sagemaker.aws +notebook.me-central-1.sagemaker.aws +notebook.me-south-1.sagemaker.aws +notebook.sa-east-1.sagemaker.aws +notebook.us-east-1.sagemaker.aws +notebook-fips.us-east-1.sagemaker.aws +notebook.us-east-2.sagemaker.aws +notebook-fips.us-east-2.sagemaker.aws +notebook.us-gov-east-1.sagemaker.aws +notebook-fips.us-gov-east-1.sagemaker.aws +notebook.us-gov-west-1.sagemaker.aws +notebook-fips.us-gov-west-1.sagemaker.aws +notebook.us-west-1.sagemaker.aws +notebook-fips.us-west-1.sagemaker.aws +notebook.us-west-2.sagemaker.aws +notebook-fips.us-west-2.sagemaker.aws +notebook.cn-north-1.sagemaker.com.cn +notebook.cn-northwest-1.sagemaker.com.cn + +// Amazon SageMaker Studio +// Submitted by AWS Security +// Reference: 69c723d9-6e1a-4bff-a203-48eecd203183 +studio.af-south-1.sagemaker.aws +studio.ap-east-1.sagemaker.aws +studio.ap-northeast-1.sagemaker.aws +studio.ap-northeast-2.sagemaker.aws +studio.ap-northeast-3.sagemaker.aws +studio.ap-south-1.sagemaker.aws +studio.ap-southeast-1.sagemaker.aws +studio.ap-southeast-2.sagemaker.aws +studio.ap-southeast-3.sagemaker.aws +studio.ca-central-1.sagemaker.aws +studio.eu-central-1.sagemaker.aws +studio.eu-north-1.sagemaker.aws +studio.eu-south-1.sagemaker.aws +studio.eu-south-2.sagemaker.aws +studio.eu-west-1.sagemaker.aws +studio.eu-west-2.sagemaker.aws +studio.eu-west-3.sagemaker.aws +studio.il-central-1.sagemaker.aws +studio.me-central-1.sagemaker.aws +studio.me-south-1.sagemaker.aws +studio.sa-east-1.sagemaker.aws +studio.us-east-1.sagemaker.aws +studio.us-east-2.sagemaker.aws +studio.us-gov-east-1.sagemaker.aws +studio-fips.us-gov-east-1.sagemaker.aws +studio.us-gov-west-1.sagemaker.aws +studio-fips.us-gov-west-1.sagemaker.aws +studio.us-west-1.sagemaker.aws +studio.us-west-2.sagemaker.aws +studio.cn-north-1.sagemaker.com.cn +studio.cn-northwest-1.sagemaker.com.cn + +// Amazon SageMaker with MLflow +// Submited by: AWS Security +// Reference: c19f92b3-a82a-452d-8189-831b572eea7e +*.experiments.sagemaker.aws + +// Analytics on AWS +// Submitted by AWS Security +// Reference: 955f9f40-a495-4e73-ae85-67b77ac9cadd +analytics-gateway.ap-northeast-1.amazonaws.com +analytics-gateway.ap-northeast-2.amazonaws.com +analytics-gateway.ap-south-1.amazonaws.com +analytics-gateway.ap-southeast-1.amazonaws.com +analytics-gateway.ap-southeast-2.amazonaws.com +analytics-gateway.eu-central-1.amazonaws.com +analytics-gateway.eu-west-1.amazonaws.com +analytics-gateway.us-east-1.amazonaws.com +analytics-gateway.us-east-2.amazonaws.com +analytics-gateway.us-west-2.amazonaws.com + +// AWS Amplify +// Submitted by AWS Security +// Reference: c35bed18-6f4f-424f-9298-5756f2f7d72b +amplifyapp.com + +// AWS App Runner +// Submitted by AWS Security +// Reference: 6828c008-ba5d-442f-ade5-48da4e7c2316 +*.awsapprunner.com + +// AWS Cloud9 +// Submitted by: AWS Security +// Reference: 30717f72-4007-4f0f-8ed4-864c6f2efec9 +webview-assets.aws-cloud9.af-south-1.amazonaws.com +vfs.cloud9.af-south-1.amazonaws.com +webview-assets.cloud9.af-south-1.amazonaws.com +webview-assets.aws-cloud9.ap-east-1.amazonaws.com +vfs.cloud9.ap-east-1.amazonaws.com +webview-assets.cloud9.ap-east-1.amazonaws.com +webview-assets.aws-cloud9.ap-northeast-1.amazonaws.com +vfs.cloud9.ap-northeast-1.amazonaws.com +webview-assets.cloud9.ap-northeast-1.amazonaws.com +webview-assets.aws-cloud9.ap-northeast-2.amazonaws.com +vfs.cloud9.ap-northeast-2.amazonaws.com +webview-assets.cloud9.ap-northeast-2.amazonaws.com +webview-assets.aws-cloud9.ap-northeast-3.amazonaws.com +vfs.cloud9.ap-northeast-3.amazonaws.com +webview-assets.cloud9.ap-northeast-3.amazonaws.com +webview-assets.aws-cloud9.ap-south-1.amazonaws.com +vfs.cloud9.ap-south-1.amazonaws.com +webview-assets.cloud9.ap-south-1.amazonaws.com +webview-assets.aws-cloud9.ap-southeast-1.amazonaws.com +vfs.cloud9.ap-southeast-1.amazonaws.com +webview-assets.cloud9.ap-southeast-1.amazonaws.com +webview-assets.aws-cloud9.ap-southeast-2.amazonaws.com +vfs.cloud9.ap-southeast-2.amazonaws.com +webview-assets.cloud9.ap-southeast-2.amazonaws.com +webview-assets.aws-cloud9.ca-central-1.amazonaws.com +vfs.cloud9.ca-central-1.amazonaws.com +webview-assets.cloud9.ca-central-1.amazonaws.com +webview-assets.aws-cloud9.eu-central-1.amazonaws.com +vfs.cloud9.eu-central-1.amazonaws.com +webview-assets.cloud9.eu-central-1.amazonaws.com +webview-assets.aws-cloud9.eu-north-1.amazonaws.com +vfs.cloud9.eu-north-1.amazonaws.com +webview-assets.cloud9.eu-north-1.amazonaws.com +webview-assets.aws-cloud9.eu-south-1.amazonaws.com +vfs.cloud9.eu-south-1.amazonaws.com +webview-assets.cloud9.eu-south-1.amazonaws.com +webview-assets.aws-cloud9.eu-west-1.amazonaws.com +vfs.cloud9.eu-west-1.amazonaws.com +webview-assets.cloud9.eu-west-1.amazonaws.com +webview-assets.aws-cloud9.eu-west-2.amazonaws.com +vfs.cloud9.eu-west-2.amazonaws.com +webview-assets.cloud9.eu-west-2.amazonaws.com +webview-assets.aws-cloud9.eu-west-3.amazonaws.com +vfs.cloud9.eu-west-3.amazonaws.com +webview-assets.cloud9.eu-west-3.amazonaws.com +webview-assets.aws-cloud9.il-central-1.amazonaws.com +vfs.cloud9.il-central-1.amazonaws.com +webview-assets.aws-cloud9.me-south-1.amazonaws.com +vfs.cloud9.me-south-1.amazonaws.com +webview-assets.cloud9.me-south-1.amazonaws.com +webview-assets.aws-cloud9.sa-east-1.amazonaws.com +vfs.cloud9.sa-east-1.amazonaws.com +webview-assets.cloud9.sa-east-1.amazonaws.com +webview-assets.aws-cloud9.us-east-1.amazonaws.com +vfs.cloud9.us-east-1.amazonaws.com +webview-assets.cloud9.us-east-1.amazonaws.com +webview-assets.aws-cloud9.us-east-2.amazonaws.com +vfs.cloud9.us-east-2.amazonaws.com +webview-assets.cloud9.us-east-2.amazonaws.com +webview-assets.aws-cloud9.us-west-1.amazonaws.com +vfs.cloud9.us-west-1.amazonaws.com +webview-assets.cloud9.us-west-1.amazonaws.com +webview-assets.aws-cloud9.us-west-2.amazonaws.com +vfs.cloud9.us-west-2.amazonaws.com +webview-assets.cloud9.us-west-2.amazonaws.com + +// AWS Directory Service +// Submitted by AWS Security +// Reference: a13203e8-42dc-4045-a0d2-2ee67bed1068 +awsapps.com + +// AWS Elastic Beanstalk +// Submitted by AWS Security +// Reference: bb5a965c-dec3-4967-aa22-e306ad064797 +cn-north-1.eb.amazonaws.com.cn +cn-northwest-1.eb.amazonaws.com.cn +elasticbeanstalk.com +af-south-1.elasticbeanstalk.com +ap-east-1.elasticbeanstalk.com +ap-northeast-1.elasticbeanstalk.com +ap-northeast-2.elasticbeanstalk.com +ap-northeast-3.elasticbeanstalk.com +ap-south-1.elasticbeanstalk.com +ap-southeast-1.elasticbeanstalk.com +ap-southeast-2.elasticbeanstalk.com +ap-southeast-3.elasticbeanstalk.com +ca-central-1.elasticbeanstalk.com +eu-central-1.elasticbeanstalk.com +eu-north-1.elasticbeanstalk.com +eu-south-1.elasticbeanstalk.com +eu-west-1.elasticbeanstalk.com +eu-west-2.elasticbeanstalk.com +eu-west-3.elasticbeanstalk.com +il-central-1.elasticbeanstalk.com +me-south-1.elasticbeanstalk.com +sa-east-1.elasticbeanstalk.com +us-east-1.elasticbeanstalk.com +us-east-2.elasticbeanstalk.com +us-gov-east-1.elasticbeanstalk.com +us-gov-west-1.elasticbeanstalk.com +us-west-1.elasticbeanstalk.com +us-west-2.elasticbeanstalk.com + +// (AWS) Elastic Load Balancing +// Submitted by Luke Wells +// Reference: 12a3d528-1bac-4433-a359-a395867ffed2 +*.elb.amazonaws.com.cn +*.elb.amazonaws.com + +// AWS Global Accelerator +// Submitted by Daniel Massaguer +// Reference: d916759d-a08b-4241-b536-4db887383a6a +awsglobalaccelerator.com + +// AWS re:Post Private +// Submitted by AWS Security +// Reference: 83385945-225f-416e-9aa0-ad0632bfdcee +*.private.repost.aws + +// eero +// Submitted by Yue Kang +// Reference: 264afe70-f62c-4c02-8ab9-b5281ed24461 +eero.online +eero-stage.online + +// concludes Amazon + +// Amune : https://amune.org/ +// Submitted by Team Amune +t3l3p0rt.net +tele.amune.org + +// Apigee : https://apigee.com/ +// Submitted by Apigee Security Team +apigee.io + +// Apis Networks: https://apisnetworks.com +// Submitted by Matt Saladna +panel.dev + +// Apphud : https://apphud.com +// Submitted by Alexander Selivanov +siiites.com + +// Appspace : https://www.appspace.com +// Submitted by Appspace Security Team +appspacehosted.com +appspaceusercontent.com + +// Appudo UG (haftungsbeschränkt) : https://www.appudo.com +// Submitted by Alexander Hochbaum +appudo.net + +// Aptible : https://www.aptible.com/ +// Submitted by Thomas Orozco +on-aptible.com + +// Aquapal : https://aquapal.net/ +// Submitted by Aki Ueno +f5.si + +// ASEINet : https://www.aseinet.com/ +// Submitted by Asei SEKIGUCHI +user.aseinet.ne.jp +gv.vc +d.gv.vc + +// Asociación Amigos de la Informática "Euskalamiga" : http://encounter.eus/ +// Submitted by Hector Martin +user.party.eus + +// Association potager.org : https://potager.org/ +// Submitted by Lunar +pimienta.org +poivron.org +potager.org +sweetpepper.org + +// ASUSTOR Inc. : http://www.asustor.com +// Submitted by Vincent Tseng +myasustor.com + +// Atlassian : https://atlassian.com +// Submitted by Sam Smyth +cdn.prod.atlassian-dev.net + +// Authentick UG (haftungsbeschränkt) : https://authentick.net +// Submitted by Lukas Reschke +translated.page + +// Autocode : https://autocode.com +// Submitted by Jacob Lee +autocode.dev + +// AVM : https://avm.de +// Submitted by Andreas Weise +myfritz.link +myfritz.net + +// AVStack Pte. Ltd. : https://avstack.io +// Submitted by Jasper Hugo +onavstack.net + +// AW AdvisorWebsites.com Software Inc : https://advisorwebsites.com +// Submitted by James Kennedy +*.awdev.ca +*.advisor.ws + +// AZ.pl sp. z.o.o: https://az.pl +// Submitted by Krzysztof Wolski +ecommerce-shop.pl + +// b-data GmbH : https://www.b-data.io +// Submitted by Olivier Benz +b-data.io + +// backplane : https://www.backplane.io +// Submitted by Anthony Voutas +backplaneapp.io + +// Balena : https://www.balena.io +// Submitted by Petros Angelatos +balena-devices.com + +// University of Banja Luka : https://unibl.org +// Domains for Republic of Srpska administrative entity. +// Submitted by Marko Ivanovic +rs.ba + +// Banzai Cloud +// Submitted by Janos Matyas +*.banzai.cloud +app.banzaicloud.io +*.backyards.banzaicloud.io + +// BASE, Inc. : https://binc.jp +// Submitted by Yuya NAGASAWA +base.ec +official.ec +buyshop.jp +fashionstore.jp +handcrafted.jp +kawaiishop.jp +supersale.jp +theshop.jp +shopselect.net +base.shop + +// BeagleBoard.org Foundation : https://beagleboard.org +// Submitted by Jason Kridner +beagleboard.io + +// Beget Ltd +// Submitted by Lev Nekrasov +*.beget.app + +// Besties : https://besties.house +// Submitted by Hazel Cora +pages.gay + +// BetaInABox +// Submitted by Adrian +betainabox.com + +// University of Bielsko-Biala regional domain: http://dns.bielsko.pl/ +// Submitted by Marcin +bielsko.pl + +// BinaryLane : http://www.binarylane.com +// Submitted by Nathan O'Sullivan +bnr.la + +// Bitbucket : http://bitbucket.org +// Submitted by Andy Ortlieb +bitbucket.io + +// Blackbaud, Inc. : https://www.blackbaud.com +// Submitted by Paul Crowder +blackbaudcdn.net + +// Blatech : http://www.blatech.net +// Submitted by Luke Bratch +of.je + +// Blue Bite, LLC : https://bluebite.com +// Submitted by Joshua Weiss +bluebite.io + +// Boomla : https://boomla.com +// Submitted by Tibor Halter +boomla.net + +// Boutir : https://www.boutir.com +// Submitted by Eric Ng Ka Ka +boutir.com + +// Boxfuse : https://boxfuse.com +// Submitted by Axel Fontaine +boxfuse.io + +// bplaced : https://www.bplaced.net/ +// Submitted by Miroslav Bozic +square7.ch +bplaced.com +bplaced.de +square7.de +bplaced.net +square7.net + +// Brave : https://brave.com +// Submitted by Andrea Brancaleoni +*.s.brave.io + +// Brendly : https://brendly.rs +// Submitted by Dusan Radovanovic +shop.brendly.hr +shop.brendly.rs + +// BrowserSafetyMark +// Submitted by Dave Tharp +browsersafetymark.io + +// Bytemark Hosting : https://www.bytemark.co.uk +// Submitted by Paul Cammish +uk0.bigv.io +dh.bytemark.co.uk +vm.bytemark.co.uk + +// Caf.js Labs LLC : https://www.cafjs.com +// Submitted by Antonio Lain +cafjs.com + +// callidomus : https://www.callidomus.com/ +// Submitted by Marcus Popp +mycd.eu + +// Canva Pty Ltd : https://canva.com/ +// Submitted by Joel Aquilina +canva-apps.cn +*.my.canvasite.cn +canva-apps.com +*.my.canva.site + +// Carrd : https://carrd.co +// Submitted by AJ +drr.ac +uwu.ai +carrd.co +crd.co +ju.mp + +// CentralNic : http://www.centralnic.com/names/domains +// Submitted by registry +za.bz +br.com +cn.com +de.com +eu.com +jpn.com +mex.com +ru.com +sa.com +uk.com +us.com +za.com +com.de +gb.net +hu.net +jp.net +se.net +uk.net +ae.org +com.se + +// No longer operated by CentralNic, these entries should be adopted and/or removed by current operators +// Submitted by Gavin Brown +ar.com +hu.com +kr.com +no.com +qc.com +uy.com + +// Africa.com Web Solutions Ltd : https://registry.africa.com +// Submitted by Gavin Brown +africa.com + +// iDOT Services Limited : http://www.domain.gr.com +// Submitted by Gavin Brown +gr.com + +// Radix FZC : http://domains.in.net +// Submitted by Gavin Brown +web.in +in.net + +// US REGISTRY LLC : http://us.org +// Submitted by Gavin Brown +us.org + +// co.com Registry, LLC : https://registry.co.com +// Submitted by Gavin Brown +co.com + +// Roar Domains LLC : https://roar.basketball/ +// Submitted by Gavin Brown +aus.basketball +nz.basketball + +// BRS Media : https://brsmedia.com/ +// Submitted by Gavin Brown +radio.am +radio.fm + +// certmgr.org : https://certmgr.org +// Submitted by B. Blechschmidt +certmgr.org + +// Cityhost LLC : https://cityhost.ua +// Submitted by Maksym Rivtin +cx.ua + +// Civilized Discourse Construction Kit, Inc. : https://www.discourse.org/ +// Submitted by Rishabh Nambiar & Michael Brown +discourse.group +discourse.team + +// Clever Cloud : https://www.clever-cloud.com/ +// Submitted by Quentin Adam +cleverapps.cc +*.services.clever-cloud.com +cleverapps.io +cleverapps.tech + +// Clerk : https://www.clerk.dev +// Submitted by Colin Sidoti +clerk.app +clerkstage.app +*.lcl.dev +*.lclstage.dev +*.stg.dev +*.stgstage.dev + +// ClickRising : https://clickrising.com/ +// Submitted by Umut Gumeli +clickrising.net + +// Cloud66 : https://www.cloud66.com/ +// Submitted by Khash Sajadi +c66.me +cloud66.ws +cloud66.zone + +// CloudAccess.net : https://www.cloudaccess.net/ +// Submitted by Pawel Panek +jdevcloud.com +wpdevcloud.com +cloudaccess.host +freesite.host +cloudaccess.net + +// cloudControl : https://www.cloudcontrol.com/ +// Submitted by Tobias Wilken +cloudcontrolapp.com +cloudcontrolled.com + +// Cloudera, Inc. : https://www.cloudera.com/ +// Submitted by Kedarnath Waikar +*.cloudera.site + +// Cloudflare, Inc. : https://www.cloudflare.com/ +// Submitted by Cloudflare Team +cf-ipfs.com +cloudflare-ipfs.com +trycloudflare.com +pages.dev +r2.dev +workers.dev +cdn.cloudflareanycast.net +cdn.cloudflarecn.net +cdn.cloudflareglobal.net +cloudflare.net +cdn.cloudflare.net + +// cloudscale.ch AG : https://www.cloudscale.ch/ +// Submitted by Gaudenz Steinlin +cust.cloudscale.ch +objects.lpg.cloudscale.ch +objects.rma.cloudscale.ch + +// Clovyr : https://clovyr.io +// Submitted by Patrick Nielsen +wnext.app + +// co.ca : http://registry.co.ca/ +co.ca + +// Co & Co : https://co-co.nl/ +// Submitted by Govert Versluis +*.otap.co + +// i-registry s.r.o. : http://www.i-registry.cz/ +// Submitted by Martin Semrad +co.cz + +// CDN77.com : http://www.cdn77.com +// Submitted by Jan Krpes +cdn77-storage.com +rsc.contentproxy9.cz +r.cdn77.net +cdn77-ssl.net +c.cdn77.org +rsc.cdn77.org +ssl.origin.cdn77-secure.org + +// Cloud DNS Ltd : http://www.cloudns.net +// Submitted by Aleksander Hristov & Boyan Peychev +cloudns.asia +cloudns.be +cloudns.biz +cloudns.cc +cloudns.ch +cloudns.cl +cloudns.club +dnsabr.com +cloudns.cx +cloudns.eu +cloudns.in +cloudns.info +dns-cloud.net +dns-dynamic.net +cloudns.nz +cloudns.org +cloudns.ph +cloudns.pro +cloudns.pw +cloudns.us + +// CNPY : https://cnpy.gdn +// Submitted by Angelo Gladding +cnpy.gdn + +// Codeberg e. V. : https://codeberg.org +// Submitted by Moritz Marquardt +codeberg.page + +// CodeSandbox B.V. : https://codesandbox.io +// Submitted by Ives van Hoorne +csb.app +preview.csb.app + +// CoDNS B.V. +co.nl +co.no + +// Combell.com : https://www.combell.com +// Submitted by Thomas Wouters +webhosting.be +hosting-cluster.nl + +// Convex : https://convex.dev/ +// Submitted by James Cowling +convex.site + +// Coordination Center for TLD RU and XN--P1AI : https://cctld.ru/en/domains/domens_ru/reserved/ +// Submitted by George Georgievsky +ac.ru +edu.ru +gov.ru +int.ru +mil.ru +test.ru + +// COSIMO GmbH : http://www.cosimo.de +// Submitted by Rene Marticke +dyn.cosidns.de +dnsupdater.de +dynamisches-dns.de +internet-dns.de +l-o-g-i-n.de +dynamic-dns.info +feste-ip.net +knx-server.net +static-access.net + +// Craft Docs Ltd : https://www.craft.do/ +// Submitted by Zsombor Fuszenecker +craft.me + +// Craynic, s.r.o. : http://www.craynic.com/ +// Submitted by Ales Krajnik +realm.cz + +// Crisp IM SAS : https://crisp.chat/ +// Submitted by Baptiste Jamin +on.crisp.email + +// Cryptonomic : https://cryptonomic.net/ +// Submitted by Andrew Cady +*.cryptonomic.net + +// Cupcake : https://cupcake.io/ +// Submitted by Jonathan Rudenberg +cupcake.is + +// Curv UG : https://curv-labs.de/ +// Submitted by Marvin Wiesner +curv.dev + +// Customer OCI - Oracle Dyn https://cloud.oracle.com/home https://dyn.com/dns/ +// Submitted by Gregory Drake +// Note: This is intended to also include customer-oci.com due to wildcards implicitly including the current label +*.customer-oci.com +*.oci.customer-oci.com +*.ocp.customer-oci.com +*.ocs.customer-oci.com + +// cyber_Folks S.A. : https://cyberfolks.pl +// Submitted by Bartlomiej Kida +cfolks.pl + +// Cyclic Software : https://www.cyclic.sh +// Submitted by Kam Lasater +cyclic.app +cyclic.cloud +cyclic-app.com +cyclic.co.in + +// cyon GmbH : https://www.cyon.ch/ +// Submitted by Dominic Luechinger +cyon.link +cyon.site + +// Danger Science Group: https://dangerscience.com/ +// Submitted by Skylar MacDonald +platform0.app +fnwk.site +folionetwork.site + +// Daplie, Inc : https://daplie.com +// Submitted by AJ ONeal +daplie.me +localhost.daplie.me + +// Datto, Inc. : https://www.datto.com/ +// Submitted by Philipp Heckel +dattolocal.com +dattorelay.com +dattoweb.com +mydatto.com +dattolocal.net +mydatto.net + +// Dansk.net : http://www.dansk.net/ +// Submitted by Anani Voule +biz.dk +co.dk +firm.dk +reg.dk +store.dk + +// dappnode.io : https://dappnode.io/ +// Submitted by Abel Boldu / DAppNode Team +dyndns.dappnode.io + +// dapps.earth : https://dapps.earth/ +// Submitted by Daniil Burdakov +*.dapps.earth +*.bzz.dapps.earth + +// Dark, Inc. : https://darklang.com +// Submitted by Paul Biggar +builtwithdark.com +darklang.io + +// DataDetect, LLC. : https://datadetect.com +// Submitted by Andrew Banchich +demo.datadetect.com +instance.datadetect.com + +// Datawire, Inc : https://www.datawire.io +// Submitted by Richard Li +edgestack.me + +// DDNS5 : https://ddns5.com +// Submitted by Cameron Elliott +ddns5.com + +// Debian : https://www.debian.org/ +// Submitted by Peter Palfrader / Debian Sysadmin Team +debian.net + +// Deno Land Inc : https://deno.com/ +// Submitted by Luca Casonato +deno.dev +deno-staging.dev + +// deSEC : https://desec.io/ +// Submitted by Peter Thomassen +dedyn.io + +// Deta: https://www.deta.sh/ +// Submitted by Aavash Shrestha +deta.app +deta.dev + +// dhosting.pl Sp. z o.o.: https://dhosting.pl/ +// Submitted by Michal Kokoszkiewicz +dfirma.pl +dkonto.pl +you2.pl + +// Diher Solutions : https://diher.solutions +// Submitted by Didi Hermawan +*.rss.my.id +*.diher.solutions + +// Discord Inc : https://discord.com +// Submitted by Sahn Lam +discordsays.com +discordsez.com + +// DNS Africa Ltd https://dns.business +// Submitted by Calvin Browne +jozi.biz + +// DNShome : https://www.dnshome.de/ +// Submitted by Norbert Auler +dnshome.de + +// DotArai : https://www.dotarai.com/ +// Submitted by Atsadawat Netcharadsang +online.th +shop.th + +// DrayTek Corp. : https://www.draytek.com/ +// Submitted by Paul Fang +drayddns.com + +// DreamCommerce : https://shoper.pl/ +// Submitted by Konrad Kotarba +shoparena.pl + +// DreamHost : http://www.dreamhost.com/ +// Submitted by Andrew Farmer +dreamhosters.com + +// Dreamyoungs, Inc. : https://durumis.com +// Submitted by Infra Team +durumis.com + +// Drobo : http://www.drobo.com/ +// Submitted by Ricardo Padilha +mydrobo.com + +// Drud Holdings, LLC. : https://www.drud.com/ +// Submitted by Kevin Bridges +drud.io +drud.us + +// DuckDNS : http://www.duckdns.org/ +// Submitted by Richard Harper +duckdns.org + +// Bip : https://bip.sh +// Submitted by Joel Kennedy +bip.sh + +// bitbridge.net : Submitted by Craig Welch, abeliidev@gmail.com +bitbridge.net + +// dy.fi : http://dy.fi/ +// Submitted by Heikki Hannikainen +dy.fi +tunk.org + +// DynDNS.com : http://www.dyndns.com/services/dns/dyndns/ +dyndns.biz +for-better.biz +for-more.biz +for-some.biz +for-the.biz +selfip.biz +webhop.biz +ftpaccess.cc +game-server.cc +myphotos.cc +scrapping.cc +blogdns.com +cechire.com +dnsalias.com +dnsdojo.com +doesntexist.com +dontexist.com +doomdns.com +dyn-o-saur.com +dynalias.com +dyndns-at-home.com +dyndns-at-work.com +dyndns-blog.com +dyndns-free.com +dyndns-home.com +dyndns-ip.com +dyndns-mail.com +dyndns-office.com +dyndns-pics.com +dyndns-remote.com +dyndns-server.com +dyndns-web.com +dyndns-wiki.com +dyndns-work.com +est-a-la-maison.com +est-a-la-masion.com +est-le-patron.com +est-mon-blogueur.com +from-ak.com +from-al.com +from-ar.com +from-ca.com +from-ct.com +from-dc.com +from-de.com +from-fl.com +from-ga.com +from-hi.com +from-ia.com +from-id.com +from-il.com +from-in.com +from-ks.com +from-ky.com +from-ma.com +from-md.com +from-mi.com +from-mn.com +from-mo.com +from-ms.com +from-mt.com +from-nc.com +from-nd.com +from-ne.com +from-nh.com +from-nj.com +from-nm.com +from-nv.com +from-oh.com +from-ok.com +from-or.com +from-pa.com +from-pr.com +from-ri.com +from-sc.com +from-sd.com +from-tn.com +from-tx.com +from-ut.com +from-va.com +from-vt.com +from-wa.com +from-wi.com +from-wv.com +from-wy.com +getmyip.com +gotdns.com +hobby-site.com +homelinux.com +homeunix.com +iamallama.com +is-a-anarchist.com +is-a-blogger.com +is-a-bookkeeper.com +is-a-bulls-fan.com +is-a-caterer.com +is-a-chef.com +is-a-conservative.com +is-a-cpa.com +is-a-cubicle-slave.com +is-a-democrat.com +is-a-designer.com +is-a-doctor.com +is-a-financialadvisor.com +is-a-geek.com +is-a-green.com +is-a-guru.com +is-a-hard-worker.com +is-a-hunter.com +is-a-landscaper.com +is-a-lawyer.com +is-a-liberal.com +is-a-libertarian.com +is-a-llama.com +is-a-musician.com +is-a-nascarfan.com +is-a-nurse.com +is-a-painter.com +is-a-personaltrainer.com +is-a-photographer.com +is-a-player.com +is-a-republican.com +is-a-rockstar.com +is-a-socialist.com +is-a-student.com +is-a-teacher.com +is-a-techie.com +is-a-therapist.com +is-an-accountant.com +is-an-actor.com +is-an-actress.com +is-an-anarchist.com +is-an-artist.com +is-an-engineer.com +is-an-entertainer.com +is-certified.com +is-gone.com +is-into-anime.com +is-into-cars.com +is-into-cartoons.com +is-into-games.com +is-leet.com +is-not-certified.com +is-slick.com +is-uberleet.com +is-with-theband.com +isa-geek.com +isa-hockeynut.com +issmarterthanyou.com +likes-pie.com +likescandy.com +neat-url.com +saves-the-whales.com +selfip.com +sells-for-less.com +sells-for-u.com +servebbs.com +simple-url.com +space-to-rent.com +teaches-yoga.com +writesthisblog.com +ath.cx +fuettertdasnetz.de +isteingeek.de +istmein.de +lebtimnetz.de +leitungsen.de +traeumtgerade.de +barrel-of-knowledge.info +barrell-of-knowledge.info +dyndns.info +for-our.info +groks-the.info +groks-this.info +here-for-more.info +knowsitall.info +selfip.info +webhop.info +forgot.her.name +forgot.his.name +at-band-camp.net +blogdns.net +broke-it.net +buyshouses.net +dnsalias.net +dnsdojo.net +does-it.net +dontexist.net +dynalias.net +dynathome.net +endofinternet.net +from-az.net +from-co.net +from-la.net +from-ny.net +gets-it.net +ham-radio-op.net +homeftp.net +homeip.net +homelinux.net +homeunix.net +in-the-band.net +is-a-chef.net +is-a-geek.net +isa-geek.net +kicks-ass.net +office-on-the.net +podzone.net +scrapper-site.net +selfip.net +sells-it.net +servebbs.net +serveftp.net +thruhere.net +webhop.net +merseine.nu +mine.nu +shacknet.nu +blogdns.org +blogsite.org +boldlygoingnowhere.org +dnsalias.org +dnsdojo.org +doesntexist.org +dontexist.org +doomdns.org +dvrdns.org +dynalias.org +dyndns.org +go.dyndns.org +home.dyndns.org +endofinternet.org +endoftheinternet.org +from-me.org +game-host.org +gotdns.org +hobby-site.org +homedns.org +homeftp.org +homelinux.org +homeunix.org +is-a-bruinsfan.org +is-a-candidate.org +is-a-celticsfan.org +is-a-chef.org +is-a-geek.org +is-a-knight.org +is-a-linux-user.org +is-a-patsfan.org +is-a-soxfan.org +is-found.org +is-lost.org +is-saved.org +is-very-bad.org +is-very-evil.org +is-very-good.org +is-very-nice.org +is-very-sweet.org +isa-geek.org +kicks-ass.org +misconfused.org +podzone.org +readmyblog.org +selfip.org +sellsyourhome.org +servebbs.org +serveftp.org +servegame.org +stuff-4-sale.org +webhop.org +better-than.tv +dyndns.tv +on-the-web.tv +worse-than.tv +is-by.us +land-4-sale.us +stuff-4-sale.us +dyndns.ws +mypets.ws + +// ddnss.de : https://www.ddnss.de/ +// Submitted by Robert Niedziela +ddnss.de +dyn.ddnss.de +dyndns.ddnss.de +dyn-ip24.de +dyndns1.de +home-webserver.de +dyn.home-webserver.de +myhome-server.de +ddnss.org + +// Definima : http://www.definima.com/ +// Submitted by Maxence Bitterli +definima.io +definima.net + +// DigitalOcean App Platform : https://www.digitalocean.com/products/app-platform/ +// Submitted by Braxton Huggins +ondigitalocean.app + +// DigitalOcean Spaces : https://www.digitalocean.com/products/spaces/ +// Submitted by Robin H. Johnson +*.digitaloceanspaces.com + +// DigitalPlat : https://www.digitalplat.org/ +// Submitted by Edward Hsing +us.kg + +// dnstrace.pro : https://dnstrace.pro/ +// Submitted by Chris Partridge +bci.dnstrace.pro + +// Dynu.com : https://www.dynu.com/ +// Submitted by Sue Ye +ddnsfree.com +ddnsgeek.com +giize.com +gleeze.com +kozow.com +loseyourip.com +ooguy.com +theworkpc.com +casacam.net +dynu.net +accesscam.org +camdvr.org +freeddns.org +mywire.org +webredirect.org +myddns.rocks +blogsite.xyz + +// dynv6 : https://dynv6.com +// Submitted by Dominik Menke +dynv6.net + +// E4YOU spol. s.r.o. : https://e4you.cz/ +// Submitted by Vladimir Dudr +e4.cz + +// Easypanel : https://easypanel.io +// Submitted by Andrei Canta +easypanel.app +easypanel.host + +// EasyWP : https://www.easywp.com +// Submitted by +*.ewp.live + +// eDirect Corp. : https://hosting.url.com.tw/ +// Submitted by C.S. chang +twmail.cc +twmail.net +twmail.org +mymailer.com.tw +url.tw + +// Electromagnetic Field : https://www.emfcamp.org +// Submitted by +at.emf.camp + +// Elefunc, Inc. : https://elefunc.com +// Submitted by Cetin Sert +rt.ht + +// Elementor : Elementor Ltd. +// Submitted by Anton Barkan +elementor.cloud +elementor.cool + +// En root‽ : https://en-root.org +// Submitted by Emmanuel Raviart +en-root.fr + +// Enalean SAS: https://www.enalean.com +// Submitted by Enalean Security Team +mytuleap.com +tuleap-partners.com + +// Encoretivity AB: https://encore.dev +// Submitted by André Eriksson +encr.app +encoreapi.com + +// ECG Robotics, Inc: https://ecgrobotics.org +// Submitted by +onred.one +staging.onred.one + +// encoway GmbH : https://www.encoway.de +// Submitted by Marcel Daus +eu.encoway.cloud + +// EU.org https://eu.org/ +// Submitted by Pierre Beyssac +eu.org +al.eu.org +asso.eu.org +at.eu.org +au.eu.org +be.eu.org +bg.eu.org +ca.eu.org +cd.eu.org +ch.eu.org +cn.eu.org +cy.eu.org +cz.eu.org +de.eu.org +dk.eu.org +edu.eu.org +ee.eu.org +es.eu.org +fi.eu.org +fr.eu.org +gr.eu.org +hr.eu.org +hu.eu.org +ie.eu.org +il.eu.org +in.eu.org +int.eu.org +is.eu.org +it.eu.org +jp.eu.org +kr.eu.org +lt.eu.org +lu.eu.org +lv.eu.org +mc.eu.org +me.eu.org +mk.eu.org +mt.eu.org +my.eu.org +net.eu.org +ng.eu.org +nl.eu.org +no.eu.org +nz.eu.org +paris.eu.org +pl.eu.org +pt.eu.org +q-a.eu.org +ro.eu.org +ru.eu.org +se.eu.org +si.eu.org +sk.eu.org +tr.eu.org +uk.eu.org +us.eu.org + +// Eurobyte : https://eurobyte.ru +// Submitted by Evgeniy Subbotin +eurodir.ru + +// Evennode : http://www.evennode.com/ +// Submitted by Michal Kralik +eu-1.evennode.com +eu-2.evennode.com +eu-3.evennode.com +eu-4.evennode.com +us-1.evennode.com +us-2.evennode.com +us-3.evennode.com +us-4.evennode.com + +// Evervault : https://evervault.com +// Submitted by Hannah Neary +relay.evervault.app +relay.evervault.dev + +// Expo : https://expo.dev/ +// Submitted by James Ide +expo.app +staging.expo.app + +// Fabrica Technologies, Inc. : https://www.fabrica.dev/ +// Submitted by Eric Jiang +onfabrica.com + +// FAITID : https://faitid.org/ +// Submitted by Maxim Alzoba +// https://www.flexireg.net/stat_info +ru.net +adygeya.ru +bashkiria.ru +bir.ru +cbg.ru +com.ru +dagestan.ru +grozny.ru +kalmykia.ru +kustanai.ru +marine.ru +mordovia.ru +msk.ru +mytis.ru +nalchik.ru +nov.ru +pyatigorsk.ru +spb.ru +vladikavkaz.ru +vladimir.ru +abkhazia.su +adygeya.su +aktyubinsk.su +arkhangelsk.su +armenia.su +ashgabad.su +azerbaijan.su +balashov.su +bashkiria.su +bryansk.su +bukhara.su +chimkent.su +dagestan.su +east-kazakhstan.su +exnet.su +georgia.su +grozny.su +ivanovo.su +jambyl.su +kalmykia.su +kaluga.su +karacol.su +karaganda.su +karelia.su +khakassia.su +krasnodar.su +kurgan.su +kustanai.su +lenug.su +mangyshlak.su +mordovia.su +msk.su +murmansk.su +nalchik.su +navoi.su +north-kazakhstan.su +nov.su +obninsk.su +penza.su +pokrovsk.su +sochi.su +spb.su +tashkent.su +termez.su +togliatti.su +troitsk.su +tselinograd.su +tula.su +tuva.su +vladikavkaz.su +vladimir.su +vologda.su + +// Fancy Bits, LLC : http://getchannels.com +// Submitted by Aman Gupta +channelsdvr.net +u.channelsdvr.net + +// Fastly Inc. : http://www.fastly.com/ +// Submitted by Fastly Security +edgecompute.app +fastly-edge.com +fastly-terrarium.com +freetls.fastly.net +map.fastly.net +a.prod.fastly.net +global.prod.fastly.net +a.ssl.fastly.net +b.ssl.fastly.net +global.ssl.fastly.net +fastlylb.net +map.fastlylb.net + +// Fastmail : https://www.fastmail.com/ +// Submitted by Marc Bradshaw +*.user.fm + +// FASTVPS EESTI OU : https://fastvps.ru/ +// Submitted by Likhachev Vasiliy +fastvps-server.com +fastvps.host +myfast.host +fastvps.site +myfast.space + +// Fedora : https://fedoraproject.org/ +// submitted by Patrick Uiterwijk +fedorainfracloud.org +fedorapeople.org +cloud.fedoraproject.org +app.os.fedoraproject.org +app.os.stg.fedoraproject.org + +// FearWorks Media Ltd. : https://fearworksmedia.co.uk +// submitted by Keith Fairley +conn.uk +copro.uk +hosp.uk + +// Fermax : https://fermax.com/ +// submitted by Koen Van Isterdael +mydobiss.com + +// FH Muenster : https://www.fh-muenster.de +// Submitted by Robin Naundorf +fh-muenster.io + +// Filegear Inc. : https://www.filegear.com +// Submitted by Jason Zhu +filegear.me +filegear-au.me +filegear-de.me +filegear-gb.me +filegear-ie.me +filegear-jp.me +filegear-sg.me + +// Firebase, Inc. +// Submitted by Chris Raynor +firebaseapp.com + +// Firewebkit : https://www.firewebkit.com +// Submitted by Majid Qureshi +fireweb.app + +// FLAP : https://www.flap.cloud +// Submitted by Louis Chemineau +flap.id + +// FlashDrive : https://flashdrive.io +// Submitted by Eric Chan +onflashdrive.app +fldrv.com + +// FlutterFlow : https://flutterflow.io +// Submitted by Anton Emelyanov +flutterflow.app + +// fly.io: https://fly.io +// Submitted by Kurt Mackey +fly.dev +shw.io +edgeapp.net + +// Flynn : https://flynn.io +// Submitted by Jonathan Rudenberg +flynnhosting.net + +// Forgerock : https://www.forgerock.com +// Submitted by Roderick Parr +forgeblocks.com +id.forgerock.io + +// Framer : https://www.framer.com +// Submitted by Koen Rouwhorst +framer.ai +framer.app +framercanvas.com +framer.media +framer.photos +framer.website +framer.wiki + +// Frusky MEDIA&PR : https://www.frusky.de +// Submitted by Victor Pupynin +*.frusky.de + +// RavPage : https://www.ravpage.co.il +// Submitted by Roni Horowitz +ravpage.co.il + +// Frederik Braun https://frederik-braun.com +// Submitted by Frederik Braun +0e.vc + +// Freebox : http://www.freebox.fr +// Submitted by Romain Fliedel +freebox-os.com +freeboxos.com +fbx-os.fr +fbxos.fr +freebox-os.fr +freeboxos.fr + +// freedesktop.org : https://www.freedesktop.org +// Submitted by Daniel Stone +freedesktop.org + +// freemyip.com : https://freemyip.com +// Submitted by Cadence +freemyip.com + +// FunkFeuer - Verein zur Förderung freier Netze : https://www.funkfeuer.at +// Submitted by Daniel A. Maierhofer +wien.funkfeuer.at + +// Future Versatile Group. : https://www.fvg-on.net/ +// T.Kabu +daemon.asia +dix.asia +mydns.bz +0am.jp +0g0.jp +0j0.jp +0t0.jp +mydns.jp +pgw.jp +wjg.jp +keyword-on.net +live-on.net +server-on.net +mydns.tw +mydns.vc + +// Futureweb GmbH : https://www.futureweb.at +// Submitted by Andreas Schnederle-Wagner +*.futurecms.at +*.ex.futurecms.at +*.in.futurecms.at +futurehosting.at +futuremailing.at +*.ex.ortsinfo.at +*.kunden.ortsinfo.at +*.statics.cloud + +// GCom Internet : https://www.gcom.net.au +// Submitted by Leo Julius +aliases121.com + +// GDS : https://www.gov.uk/service-manual/technology/managing-domain-names +// Submitted by Stephen Ford +campaign.gov.uk +service.gov.uk +independent-commission.uk +independent-inquest.uk +independent-inquiry.uk +independent-panel.uk +independent-review.uk +public-inquiry.uk +royal-commission.uk + +// CDDO : https://www.gov.uk/guidance/get-an-api-domain-on-govuk +// Submitted by Jamie Tanna +api.gov.uk + +// Gehirn Inc. : https://www.gehirn.co.jp/ +// Submitted by Kohei YOSHIDA +gehirn.ne.jp +usercontent.jp + +// Gentlent, Inc. : https://www.gentlent.com +// Submitted by Tom Klein +gentapps.com +gentlentapis.com +lab.ms +cdn-edges.net + +// Getlocalcert: https://www.getlocalcert.net +// Submitted by Robert Alexander +localcert.net +localhostcert.net +corpnet.work + +// GignoSystemJapan: http://gsj.bz +// Submitted by GignoSystemJapan +gsj.bz + +// GitHub, Inc. +// Submitted by Patrick Toomey +githubusercontent.com +githubpreview.dev +github.io + +// GitLab, Inc. +// Submitted by Alex Hanselka +gitlab.io + +// Gitplac.si - https://gitplac.si +// Submitted by Aljaž Starc +gitapp.si +gitpage.si + +// Glitch, Inc : https://glitch.com +// Submitted by Mads Hartmann +glitch.me + +// Global NOG Alliance : https://nogalliance.org/ +// Submitted by Sander Steffann +nog.community + +// Globe Hosting SRL : https://www.globehosting.com/ +// Submitted by Gavin Brown +co.ro +shop.ro + +// GMO Pepabo, Inc. : https://pepabo.com/ +// Submitted by Hosting Div +lolipop.io +angry.jp +babyblue.jp +babymilk.jp +backdrop.jp +bambina.jp +bitter.jp +blush.jp +boo.jp +boy.jp +boyfriend.jp +but.jp +candypop.jp +capoo.jp +catfood.jp +cheap.jp +chicappa.jp +chillout.jp +chips.jp +chowder.jp +chu.jp +ciao.jp +cocotte.jp +coolblog.jp +cranky.jp +cutegirl.jp +daa.jp +deca.jp +deci.jp +digick.jp +egoism.jp +fakefur.jp +fem.jp +flier.jp +floppy.jp +fool.jp +frenchkiss.jp +girlfriend.jp +girly.jp +gloomy.jp +gonna.jp +greater.jp +hacca.jp +heavy.jp +her.jp +hiho.jp +hippy.jp +holy.jp +hungry.jp +icurus.jp +itigo.jp +jellybean.jp +kikirara.jp +kill.jp +kilo.jp +kuron.jp +littlestar.jp +lolipopmc.jp +lolitapunk.jp +lomo.jp +lovepop.jp +lovesick.jp +main.jp +mods.jp +mond.jp +mongolian.jp +moo.jp +namaste.jp +nikita.jp +nobushi.jp +noor.jp +oops.jp +parallel.jp +parasite.jp +pecori.jp +peewee.jp +penne.jp +pepper.jp +perma.jp +pigboat.jp +pinoko.jp +punyu.jp +pupu.jp +pussycat.jp +pya.jp +raindrop.jp +readymade.jp +sadist.jp +schoolbus.jp +secret.jp +staba.jp +stripper.jp +sub.jp +sunnyday.jp +thick.jp +tonkotsu.jp +under.jp +upper.jp +velvet.jp +verse.jp +versus.jp +vivian.jp +watson.jp +weblike.jp +whitesnow.jp +zombie.jp +heteml.net + +// GoDaddy Registry : https://registry.godaddy +// Submitted by Rohan Durrant +graphic.design + +// GOV.UK Platform as a Service : https://www.cloud.service.gov.uk/ +// Submitted by Tom Whitwell +cloudapps.digital +london.cloudapps.digital + +// GOV.UK Pay : https://www.payments.service.gov.uk/ +// Submitted by Richard Baker +pymnt.uk + +// GoIP DNS Services : http://www.goip.de +// Submitted by Christian Poulter +goip.de + +// Google, Inc. +// Submitted by Shannon McCabe +blogspot.ae +blogspot.al +blogspot.am +*.hosted.app +*.run.app +web.app +blogspot.com.ar +blogspot.co.at +blogspot.com.au +blogspot.ba +blogspot.be +blogspot.bg +blogspot.bj +blogspot.com.br +blogspot.com.by +blogspot.ca +blogspot.cf +blogspot.ch +blogspot.cl +blogspot.com.co +*.0emm.com +appspot.com +*.r.appspot.com +blogspot.com +codespot.com +googleapis.com +googlecode.com +pagespeedmobilizer.com +publishproxy.com +withgoogle.com +withyoutube.com +blogspot.cv +blogspot.com.cy +blogspot.cz +blogspot.de +*.gateway.dev +blogspot.dk +blogspot.com.ee +blogspot.com.eg +blogspot.com.es +blogspot.fi +blogspot.fr +cloud.goog +translate.goog +*.usercontent.goog +blogspot.gr +blogspot.hk +blogspot.hr +blogspot.hu +blogspot.co.id +blogspot.ie +blogspot.co.il +blogspot.in +blogspot.is +blogspot.it +blogspot.jp +blogspot.co.ke +blogspot.kr +blogspot.li +blogspot.lt +blogspot.lu +blogspot.md +blogspot.mk +blogspot.mr +blogspot.com.mt +blogspot.mx +blogspot.my +cloudfunctions.net +blogspot.com.ng +blogspot.nl +blogspot.no +blogspot.co.nz +blogspot.pe +blogspot.pt +blogspot.qa +blogspot.re +blogspot.ro +blogspot.rs +blogspot.ru +blogspot.se +blogspot.sg +blogspot.si +blogspot.sk +blogspot.sn +blogspot.td +blogspot.com.tr +blogspot.tw +blogspot.ug +blogspot.co.uk +blogspot.com.uy +blogspot.vn +blogspot.co.za + +// Goupile : https://goupile.fr +// Submitted by Niels Martignene +goupile.fr + +// Government of the Netherlands: https://www.government.nl +// Submitted by +gov.nl + +// GrayJay Web Solutions Inc. : https://grayjaysports.ca +// Submitted by Matt Yamkowy +grayjayleagues.com + +// Group 53, LLC : https://www.group53.com +// Submitted by Tyler Todd +awsmppl.com + +// GünstigBestellen : https://günstigbestellen.de +// Submitted by Furkan Akkoc +günstigbestellen.de +günstigliefern.de + +// Hakaran group: http://hakaran.cz +// Submitted by Arseniy Sokolov +fin.ci +free.hr +caa.li +ua.rs +conf.se + +// Handshake : https://handshake.org +// Submitted by Mike Damm +hs.run +hs.zone + +// Hashbang : https://hashbang.sh +hashbang.sh + +// Hasura : https://hasura.io +// Submitted by Shahidh K Muhammed +hasura.app +hasura-app.io + +// Hatena Co., Ltd. : https://hatena.co.jp +// Submitted by Masato Nakamura +hatenablog.com +hatenadiary.com +hateblo.jp +hatenablog.jp +hatenadiary.jp +hatenadiary.org + +// Heilbronn University of Applied Sciences - Faculty Informatics (GitLab Pages): https://www.hs-heilbronn.de +// Submitted by Richard Zowalla +pages.it.hs-heilbronn.de + +// Helio Networks : https://heliohost.org +// Submitted by Ben Frede +helioho.st +heliohost.us + +// HeiyuSpace: https://lazycat.cloud +// Submitted by Xia Bin +heiyu.space + +// Hepforge : https://www.hepforge.org +// Submitted by David Grellscheid +hepforge.org + +// Heroku : https://www.heroku.com/ +// Submitted by Tom Maher +herokuapp.com +herokussl.com + +// Hibernating Rhinos +// Submitted by Oren Eini +ravendb.cloud +ravendb.community +development.run +ravendb.run + +// home.pl S.A.: https://home.pl +// Submitted by Krzysztof Wolski +homesklep.pl + +// Homebase : https://homebase.id/ +// Submitted by Jason Babo +*.kin.one +*.id.pub +*.kin.pub + +// Hong Kong Productivity Council: https://www.hkpc.org/ +// Submitted by SECaaS Team +secaas.hk + +// Hoplix : https://www.hoplix.com +// Submitted by Danilo De Franco +hoplix.shop + + +// HOSTBIP REGISTRY : https://www.hostbip.com/ +// Submitted by Atanunu Igbunuroghene +orx.biz +biz.gl +col.ng +firm.ng +gen.ng +ltd.ng +ngo.ng +edu.scot +sch.so + +// HostFly : https://www.ie.ua +// Submitted by Bohdan Dub +ie.ua + +// HostyHosting (https://hostyhosting.com) +hostyhosting.io + +// Hypernode B.V. : https://www.hypernode.com/ +// Submitted by Cipriano Groenendal +hypernode.io + +// Häkkinen.fi +// Submitted by Eero Häkkinen +häkkinen.fi + +// Ici la Lune : http://www.icilalune.com/ +// Submitted by Simon Morvan +*.moonscale.io +moonscale.net + +// iki.fi +// Submitted by Hannu Aronsson +iki.fi + +// iliad italia: https://www.iliad.it +// Submitted by Marios Makassikis +ibxos.it +iliadboxos.it + +// Impertrix Solutions : +// Submitted by Zhixiang Zhao +impertrix.com +impertrixcdn.com + +// Incsub, LLC: https://incsub.com/ +// Submitted by Aaron Edwards +smushcdn.com +wphostedmail.com +wpmucdn.com +tempurl.host +wpmudev.host + +// Individual Network Berlin e.V. : https://www.in-berlin.de/ +// Submitted by Christian Seitz +dyn-berlin.de +in-berlin.de +in-brb.de +in-butter.de +in-dsl.de +in-vpn.de +in-dsl.net +in-vpn.net +in-dsl.org +in-vpn.org + +// info.at : http://www.info.at/ +biz.at +info.at + +// info.cx : http://info.cx +// Submitted by June Slater +info.cx + +// Interlegis : http://www.interlegis.leg.br +// Submitted by Gabriel Ferreira +ac.leg.br +al.leg.br +am.leg.br +ap.leg.br +ba.leg.br +ce.leg.br +df.leg.br +es.leg.br +go.leg.br +ma.leg.br +mg.leg.br +ms.leg.br +mt.leg.br +pa.leg.br +pb.leg.br +pe.leg.br +pi.leg.br +pr.leg.br +rj.leg.br +rn.leg.br +ro.leg.br +rr.leg.br +rs.leg.br +sc.leg.br +se.leg.br +sp.leg.br +to.leg.br + +// intermetrics GmbH : https://pixolino.com/ +// Submitted by Wolfgang Schwarz +pixolino.com + +// Internet-Pro, LLP: https://netangels.ru/ +// Submitted by Vasiliy Sheredeko +na4u.ru + +// iopsys software solutions AB : https://iopsys.eu/ +// Submitted by Roman Azarenko +iopsys.se + +// IPiFony Systems, Inc. : https://www.ipifony.com/ +// Submitted by Matthew Hardeman +ipifony.net + +// is-a.dev : https://www.is-a.dev +// Submitted by William Harrison +is-a.dev + +// ir.md : https://nic.ir.md +// Submitted by Ali Soizi +ir.md + +// IServ GmbH : https://iserv.de +// Submitted by Mario Hoberg +iservschule.de +mein-iserv.de +schulplattform.de +schulserver.de +test-iserv.de +iserv.dev + +// I-O DATA DEVICE, INC. : http://www.iodata.com/ +// Submitted by Yuji Minagawa +iobb.net + +// Jelastic, Inc. : https://jelastic.com/ +// Submitted by Ihor Kolodyuk +mel.cloudlets.com.au +cloud.interhostsolutions.be +mycloud.by +alp1.ae.flow.ch +appengine.flow.ch +es-1.axarnet.cloud +diadem.cloud +vip.jelastic.cloud +jele.cloud +it1.eur.aruba.jenv-aruba.cloud +it1.jenv-aruba.cloud +keliweb.cloud +cs.keliweb.cloud +oxa.cloud +tn.oxa.cloud +uk.oxa.cloud +primetel.cloud +uk.primetel.cloud +ca.reclaim.cloud +uk.reclaim.cloud +us.reclaim.cloud +ch.trendhosting.cloud +de.trendhosting.cloud +jele.club +amscompute.com +dopaas.com +paas.hosted-by-previder.com +rag-cloud.hosteur.com +rag-cloud-ch.hosteur.com +jcloud.ik-server.com +jcloud-ver-jpc.ik-server.com +demo.jelastic.com +kilatiron.com +paas.massivegrid.com +jed.wafaicloud.com +lon.wafaicloud.com +ryd.wafaicloud.com +j.scaleforce.com.cy +jelastic.dogado.eu +fi.cloudplatform.fi +demo.datacenter.fi +paas.datacenter.fi +jele.host +mircloud.host +paas.beebyte.io +sekd1.beebyteapp.io +jele.io +cloud-fr1.unispace.io +jc.neen.it +cloud.jelastic.open.tim.it +jcloud.kz +upaas.kazteleport.kz +cloudjiffy.net +fra1-de.cloudjiffy.net +west1-us.cloudjiffy.net +jls-sto1.elastx.net +jls-sto2.elastx.net +jls-sto3.elastx.net +faststacks.net +fr-1.paas.massivegrid.net +lon-1.paas.massivegrid.net +lon-2.paas.massivegrid.net +ny-1.paas.massivegrid.net +ny-2.paas.massivegrid.net +sg-1.paas.massivegrid.net +jelastic.saveincloud.net +nordeste-idc.saveincloud.net +j.scaleforce.net +jelastic.tsukaeru.net +sdscloud.pl +unicloud.pl +mircloud.ru +jelastic.regruhosting.ru +enscaled.sg +jele.site +jelastic.team +orangecloud.tn +j.layershift.co.uk +phx.enscaled.us +mircloud.us + +// Jino : https://www.jino.ru +// Submitted by Sergey Ulyashin +myjino.ru +*.hosting.myjino.ru +*.landing.myjino.ru +*.spectrum.myjino.ru +*.vps.myjino.ru + +// Jotelulu S.L. : https://jotelulu.com +// Submitted by Daniel Fariña +jotelulu.cloud + +// JouwWeb B.V. : https://www.jouwweb.nl +// Submitted by Camilo Sperberg +webadorsite.com +jouwweb.site + +// Joyent : https://www.joyent.com/ +// Submitted by Brian Bennett +*.cns.joyent.com +*.triton.zone + +// JS.ORG : http://dns.js.org +// Submitted by Stefan Keim +js.org + +// KaasHosting : http://www.kaashosting.nl/ +// Submitted by Wouter Bakker +kaas.gg +khplay.nl + +// Kakao : https://www.kakaocorp.com/ +// Submitted by JaeYoong Lee +ktistory.com + +// Kapsi : https://kapsi.fi +// Submitted by Tomi Juntunen +kapsi.fi + +// Keyweb AG : https://www.keyweb.de +// Submitted by Martin Dannehl +keymachine.de + +// KingHost : https://king.host +// Submitted by Felipe Keller Braz +kinghost.net +uni5.net + +// KnightPoint Systems, LLC : http://www.knightpoint.com/ +// Submitted by Roy Keene +knightpoint.systems + +// KoobinEvent, SL: https://www.koobin.com +// Submitted by Iván Oliva +koobin.events + +// KUROKU LTD : https://kuroku.ltd/ +// Submitted by DisposaBoy +oya.to + +// Katholieke Universiteit Leuven: https://www.kuleuven.be +// Submitted by Abuse KU Leuven +ezproxy.kuleuven.be +kuleuven.cloud + +// .KRD : http://nic.krd/data/krd/Registration%20Policy.pdf +co.krd +edu.krd + +// Krellian Ltd. : https://krellian.com +// Submitted by Ben Francis +webthings.io +krellian.net + +// LCube - Professional hosting e.K. : https://www.lcube-webhosting.de +// Submitted by Lars Laehn +git-repos.de +lcube-server.de +svn-repos.de + +// Leadpages : https://www.leadpages.net +// Submitted by Greg Dallavalle +leadpages.co +lpages.co +lpusercontent.com + +// Lelux.fi : https://lelux.fi/ +// Submitted by Lelux Admin +lelux.site + +// Libre IT Ltd : https://libre.nz +// Submitted by Tomas Maggio +runcontainers.dev + +// Lifetime Hosting : https://Lifetime.Hosting/ +// Submitted by Mike Fillator +co.business +co.education +co.events +co.financial +co.network +co.place +co.technology + +// linkyard ldt: https://www.linkyard.ch/ +// Submitted by Mario Siegenthaler +linkyard-cloud.ch +linkyard.cloud + +// Linode : https://linode.com +// Submitted by +members.linode.com +*.nodebalancer.linode.com +*.linodeobjects.com +ip.linodeusercontent.com + +// LiquidNet Ltd : http://www.liquidnetlimited.com/ +// Submitted by Victor Velchev +we.bs + +// Localcert : https://localcert.dev +// Submitted by Lann Martin +*.user.localcert.dev + +// localzone.xyz +// Submitted by Kenny Niehage +localzone.xyz + +// Log'in Line : https://www.loginline.com/ +// Submitted by Rémi Mach +loginline.app +loginline.dev +loginline.io +loginline.services +loginline.site + +// Lokalized : https://lokalized.nl +// Submitted by Noah Taheij +servers.run + +// Lõhmus Family, The +// Submitted by Heiki Lõhmus +lohmus.me + +// LubMAN UMCS Sp. z o.o : https://lubman.pl/ +// Submitted by Ireneusz Maliszewski +krasnik.pl +leczna.pl +lubartow.pl +lublin.pl +poniatowa.pl +swidnik.pl + +// Lug.org.uk : https://lug.org.uk +// Submitted by Jon Spriggs +glug.org.uk +lug.org.uk +lugs.org.uk + +// Lukanet Ltd : https://lukanet.com +// Submitted by Anton Avramov +barsy.bg +barsy.club +barsycenter.com +barsyonline.com +barsy.de +barsy.dev +barsy.eu +barsy.gr +barsy.in +barsy.info +barsy.io +barsy.me +barsy.menu +barsyonline.menu +barsy.mobi +barsy.net +barsy.online +barsy.org +barsy.pro +barsy.pub +barsy.ro +barsy.rs +barsy.shop +barsyonline.shop +barsy.site +barsy.store +barsy.support +barsy.uk +barsy.co.uk +barsyonline.co.uk + +// Magento Commerce +// Submitted by Damien Tournoud +*.magentosite.cloud + +// May First - People Link : https://mayfirst.org/ +// Submitted by Jamie McClelland +mayfirst.info +mayfirst.org + +// Mail.Ru Group : https://hb.cldmail.ru +// Submitted by Ilya Zaretskiy +hb.cldmail.ru + +// Maze Play: https://www.mazeplay.com +// Submitted by Adam Humpherys +mazeplay.com + +// mcpe.me : https://mcpe.me +// Submitted by Noa Heyl +mcpe.me + +// McHost : https://mchost.ru +// Submitted by Evgeniy Subbotin +mcdir.me +mcdir.ru +vps.mcdir.ru +mcpre.ru + +// Mediatech : https://mediatech.by +// Submitted by Evgeniy Kozhuhovskiy +mediatech.by +mediatech.dev + +// Medicom Health : https://medicomhealth.com +// Submitted by Michael Olson +hra.health + +// Memset hosting : https://www.memset.com +// Submitted by Tom Whitwell +miniserver.com +memset.net + +// Messerli Informatik AG : https://www.messerli.ch/ +// Submitted by Ruben Schmidmeister +messerli.app + +// Meta Platforms, Inc. : https://meta.com/ +// Submitted by Jacob Cordero +atmeta.com +apps.fbsbx.com + +// MetaCentrum, CESNET z.s.p.o. : https://www.metacentrum.cz/en/ +// Submitted by Zdeněk Šustr +*.cloud.metacentrum.cz +custom.metacentrum.cz + +// MetaCentrum, CESNET z.s.p.o. : https://www.metacentrum.cz/en/ +// Submitted by Radim Janča +flt.cloud.muni.cz +usr.cloud.muni.cz + +// Meteor Development Group : https://www.meteor.com/hosting +// Submitted by Pierre Carrier +meteorapp.com +eu.meteorapp.com + +// Michau Enterprises Limited : http://www.co.pl/ +co.pl + +// Microsoft Corporation : http://microsoft.com +// Submitted by Public Suffix List Admin +// Managed by Corporate Domains +// Microsoft Azure : https://home.azure +*.azurecontainer.io +azure-api.net +azure-mobile.net +azureedge.net +azurefd.net +azurestaticapps.net +1.azurestaticapps.net +2.azurestaticapps.net +3.azurestaticapps.net +4.azurestaticapps.net +5.azurestaticapps.net +6.azurestaticapps.net +7.azurestaticapps.net +centralus.azurestaticapps.net +eastasia.azurestaticapps.net +eastus2.azurestaticapps.net +westeurope.azurestaticapps.net +westus2.azurestaticapps.net +azurewebsites.net +cloudapp.net +trafficmanager.net +blob.core.windows.net +servicebus.windows.net + +// minion.systems : http://minion.systems +// Submitted by Robert Böttinger +csx.cc + +// Mintere : https://mintere.com/ +// Submitted by Ben Aubin +mintere.site + +// MobileEducation, LLC : https://joinforte.com +// Submitted by Grayson Martin +forte.id + +// MODX Systems LLC : https://modx.com +// Submitted by Elizabeth Southwell +modx.dev + +// Mozilla Corporation : https://mozilla.com +// Submitted by Ben Francis +mozilla-iot.org + +// Mozilla Foundation : https://mozilla.org/ +// Submitted by glob +bmoattachments.org + +// MSK-IX : https://www.msk-ix.ru/ +// Submitted by Khannanov Roman +net.ru +org.ru +pp.ru + +// Mythic Beasts : https://www.mythic-beasts.com +// Submitted by Paul Cammish +hostedpi.com +caracal.mythic-beasts.com +customer.mythic-beasts.com +fentiger.mythic-beasts.com +lynx.mythic-beasts.com +ocelot.mythic-beasts.com +oncilla.mythic-beasts.com +onza.mythic-beasts.com +sphinx.mythic-beasts.com +vs.mythic-beasts.com +x.mythic-beasts.com +yali.mythic-beasts.com +cust.retrosnub.co.uk + +// Nabu Casa : https://www.nabucasa.com +// Submitted by Paulus Schoutsen +ui.nabu.casa + +// Net at Work Gmbh : https://www.netatwork.de +// Submitted by Jan Jaeschke +cloud.nospamproxy.com + +// Netfy Domains : https://netfy.domains +// Submitted by Suranga Ranasinghe +netfy.app + +// Netlify : https://www.netlify.com +// Submitted by Jessica Parsons +netlify.app + +// Neustar Inc. +// Submitted by Trung Tran +4u.com + +// NGO.US Registry : https://nic.ngo.us +// Submitted by Alstra Solutions Ltd. Networking Team +ngo.us + +// ngrok : https://ngrok.com/ +// Submitted by Alan Shreve +ngrok.app +ngrok-free.app +ngrok.dev +ngrok-free.dev +ngrok.io +ap.ngrok.io +au.ngrok.io +eu.ngrok.io +in.ngrok.io +jp.ngrok.io +sa.ngrok.io +us.ngrok.io +ngrok.pizza +ngrok.pro + +// Nicolaus Copernicus University in Torun - MSK TORMAN (https://www.man.torun.pl) +torun.pl + +// Nimbus Hosting Ltd. : https://www.nimbushosting.co.uk/ +// Submitted by Nicholas Ford +nh-serv.co.uk +nimsite.uk + +// NFSN, Inc. : https://www.NearlyFreeSpeech.NET/ +// Submitted by Jeff Wheelhouse +nfshost.com + +// NFT.Storage : https://nft.storage/ +// Submitted by Vasco Santos or +ipfs.nftstorage.link + +// Noop : https://noop.app +// Submitted by Nathaniel Schweinberg +*.developer.app +noop.app + +// Northflank Ltd. : https://northflank.com/ +// Submitted by Marco Suter +*.northflank.app +*.build.run +*.code.run +*.database.run +*.migration.run + +// Noticeable : https://noticeable.io +// Submitted by Laurent Pellegrino +noticeable.news + +// Notion Labs, Inc : https://www.notion.so/ +// Submitted by Jess Yao +notion.site + +// Now-DNS : https://now-dns.com +// Submitted by Steve Russell +dnsking.ch +mypi.co +n4t.co +001www.com +ddnslive.com +myiphost.com +forumz.info +16-b.it +32-b.it +64-b.it +soundcast.me +tcp4.me +dnsup.net +hicam.net +now-dns.net +ownip.net +vpndns.net +dynserv.org +now-dns.org +x443.pw +now-dns.top +ntdll.top +freeddns.us +crafting.xyz +zapto.xyz + +// nsupdate.info : https://www.nsupdate.info/ +// Submitted by Thomas Waldmann +nsupdate.info +nerdpol.ovh + +// No-IP.com : https://noip.com/ +// Submitted by Deven Reza +mmafan.biz +myftp.biz +no-ip.biz +no-ip.ca +fantasyleague.cc +gotdns.ch +3utilities.com +blogsyte.com +ciscofreak.com +damnserver.com +ddnsking.com +ditchyourip.com +dnsiskinky.com +dynns.com +geekgalaxy.com +health-carereform.com +homesecuritymac.com +homesecuritypc.com +myactivedirectory.com +mysecuritycamera.com +myvnc.com +net-freaks.com +onthewifi.com +point2this.com +quicksytes.com +securitytactics.com +servebeer.com +servecounterstrike.com +serveexchange.com +serveftp.com +servegame.com +servehalflife.com +servehttp.com +servehumour.com +serveirc.com +servemp3.com +servep2p.com +servepics.com +servequake.com +servesarcasm.com +stufftoread.com +unusualperson.com +workisboring.com +dvrcam.info +ilovecollege.info +no-ip.info +brasilia.me +ddns.me +dnsfor.me +hopto.me +loginto.me +noip.me +webhop.me +bounceme.net +ddns.net +eating-organic.net +mydissent.net +myeffect.net +mymediapc.net +mypsx.net +mysecuritycamera.net +nhlfan.net +no-ip.net +pgafan.net +privatizehealthinsurance.net +redirectme.net +serveblog.net +serveminecraft.net +sytes.net +cable-modem.org +collegefan.org +couchpotatofries.org +hopto.org +mlbfan.org +myftp.org +mysecuritycamera.org +nflfan.org +no-ip.org +read-books.org +ufcfan.org +zapto.org +no-ip.co.uk +golffan.us +noip.us +pointto.us + +// NodeArt : https://nodeart.io +// Submitted by Konstantin Nosov +stage.nodeart.io + +// Nucleos Inc. : https://nucleos.com +// Submitted by Piotr Zduniak +pcloud.host + +// NYC.mn : http://www.information.nyc.mn +// Submitted by Matthew Brown +nyc.mn + +// O3O.Foundation : https://o3o.foundation/ +// Submitted by the prvcy.page Registry Team +prvcy.page + +// Obl.ong : +// Submitted by Reese Armstrong +obl.ong + +// Observable, Inc. : https://observablehq.com +// Submitted by Mike Bostock +observablehq.cloud +static.observableusercontent.com + +// Octopodal Solutions, LLC. : https://ulterius.io/ +// Submitted by Andrew Sampson +cya.gg + +// OMG.LOL : +// Submitted by Adam Newbold +omg.lol + +// Omnibond Systems, LLC. : https://www.omnibond.com +// Submitted by Cole Estep +cloudycluster.net + +// OmniWe Limited: https://omniwe.com +// Submitted by Vicary Archangel +omniwe.site + +// One.com: https://www.one.com/ +// Submitted by Jacob Bunk Nielsen +123webseite.at +123website.be +simplesite.com.br +123website.ch +simplesite.com +123webseite.de +123hjemmeside.dk +123miweb.es +123kotisivu.fi +123siteweb.fr +simplesite.gr +123homepage.it +123website.lu +123website.nl +123hjemmeside.no +service.one +simplesite.pl +123paginaweb.pt +123minsida.se + +// One Fold Media : http://www.onefoldmedia.com/ +// Submitted by Eddie Jones +nid.io + +// Open Domains : https://open-domains.net +// Submitted by William Harrison +is-cool.dev +is-not-a.dev +localplayer.dev +is-local.org + +// Open Social : https://www.getopensocial.com/ +// Submitted by Alexander Varwijk +opensocial.site + +// OpenCraft GmbH : http://opencraft.com/ +// Submitted by Sven Marnach +opencraft.hosting + +// OpenResearch GmbH: https://openresearch.com/ +// Submitted by Philipp Schmid +orsites.com + +// Opera Software, A.S.A. +// Submitted by Yngve Pettersen +operaunite.com + +// Orange : https://www.orange.com +// Submitted by Alexandre Linte +tech.orange + +// OsSav Technology Ltd. : https://ossav.com/ +// TLD Nic: http://nic.can.re - TLD Whois Server: whois.can.re +// Submitted by OsSav Technology Ltd. +can.re + +// Oursky Limited : https://authgear.com/, https://skygear.io/ +// Submitted by Authgear Team , Skygear Developer +authgear-staging.com +authgearapps.com +skygearapp.com + +// OutSystems +// Submitted by Duarte Santos +outsystemscloud.com + +// OVHcloud: https://ovhcloud.com +// Submitted by Vincent Cassé +*.hosting.ovh.net +*.webpaas.ovh.net + +// OwnProvider GmbH: http://www.ownprovider.com +// Submitted by Jan Moennich +ownprovider.com +own.pm + +// OwO : https://whats-th.is/ +// Submitted by Dean Sheather +*.owo.codes + +// OX : http://www.ox.rs +// Submitted by Adam Grand +ox.rs + +// oy.lc +// Submitted by Charly Coste +oy.lc + +// Pagefog : https://pagefog.com/ +// Submitted by Derek Myers +pgfog.com + +// Pagefront : https://www.pagefronthq.com/ +// Submitted by Jason Kriss +pagefrontapp.com + +// PageXL : https://pagexl.com +// Submitted by Yann Guichard +pagexl.com + +// Paywhirl, Inc : https://paywhirl.com/ +// Submitted by Daniel Netzer +*.paywhirl.com + +// pcarrier.ca Software Inc: https://pcarrier.ca/ +// Submitted by Pierre Carrier +*.xmit.co +xmit.dev +madethis.site +srv.us +gh.srv.us +gl.srv.us + +// .pl domains (grandfathered) +art.pl +gliwice.pl +krakow.pl +poznan.pl +wroc.pl +zakopane.pl + +// Pantheon Systems, Inc. : https://pantheon.io/ +// Submitted by Gary Dylina +gotpantheon.com +pantheonsite.io + +// Peplink | Pepwave : http://peplink.com/ +// Submitted by Steve Leung +mypep.link + +// Perspecta : https://perspecta.com/ +// Submitted by Kenneth Van Alstyne +perspecta.cloud + +// PE Ulyanov Kirill Sergeevich : https://airy.host +// Submitted by Kirill Ulyanov +lk3.ru + +// Planet-Work : https://www.planet-work.com/ +// Submitted by Frédéric VANNIÈRE +on-web.fr + +// Platform.sh : https://platform.sh +// Submitted by Nikola Kotur +*.upsun.app +upsunapp.com +ent.platform.sh +eu.platform.sh +us.platform.sh +*.platformsh.site +*.tst.site + +// Platter: https://platter.dev +// Submitted by Patrick Flor +platter-app.com +platter-app.dev +platterp.us + +// Pley AB : https://www.pley.com/ +// Submitted by Henning Pohl +pley.games + +// Port53 : https://port53.io/ +// Submitted by Maximilian Schieder +dyn53.io + +// Porter : https://porter.run/ +// Submitted by Rudraksh MK +onporter.run + +// Positive Codes Technology Company : http://co.bn/faq.html +// Submitted by Zulfais +co.bn + +// Postman, Inc : https://postman.com +// Submitted by Rahul Dhawan +postman-echo.com +pstmn.io +mock.pstmn.io +httpbin.org + +// prequalifyme.today : https://prequalifyme.today +// Submitted by DeepakTiwari deepak@ivylead.io +prequalifyme.today + +// prgmr.com : https://prgmr.com/ +// Submitted by Sarah Newman +xen.prgmr.com + +// priv.at : http://www.nic.priv.at/ +// Submitted by registry +priv.at + +// Protocol Labs : https://protocol.ai/ +// Submitted by Michael Burns +*.dweb.link + +// Protonet GmbH : http://protonet.io +// Submitted by Martin Meier +protonet.io + +// Publication Presse Communication SARL : https://ppcom.fr +// Submitted by Yaacov Akiba Slama +chirurgiens-dentistes-en-france.fr +byen.site + +// pubtls.org: https://www.pubtls.org +// Submitted by Kor Nielsen +pubtls.org + +// PythonAnywhere LLP: https://www.pythonanywhere.com +// Submitted by Giles Thomas +pythonanywhere.com +eu.pythonanywhere.com + +// QOTO, Org. +// Submitted by Jeffrey Phillips Freeman +qoto.io + +// Qualifio : https://qualifio.com/ +// Submitted by Xavier De Cock +qualifioapp.com + +// Quality Unit: https://qualityunit.com +// Submitted by Vasyl Tsalko +ladesk.com + +// QuickBackend: https://www.quickbackend.com +// Submitted by Dani Biro +qbuser.com + +// Rad Web Hosting: https://radwebhosting.com +// Submitted by Scott Claeys +cloudsite.builders +myradweb.net +servername.us + +// Raidboxes GmbH : https://raidboxes.de +// Submitted by Auke Tembrink +myrdbx.io +site.rb-hosting.io + +// Redgate Software: https://red-gate.com +// Submitted by Andrew Farries +instances.spawn.cc + +// Russian Academy of Sciences +// Submitted by Tech Support +ras.ru + +// QA2 +// Submitted by Daniel Dent (https://www.danieldent.com/) +qa2.com + +// QCX +// Submitted by Cassandra Beelen +qcx.io +*.sys.qcx.io + +// QNAP System Inc : https://www.qnap.com +// Submitted by Nick Chang +myqnapcloud.cn +alpha-myqnapcloud.com +dev-myqnapcloud.com +mycloudnas.com +mynascloud.com +myqnapcloud.com + +// Quip : https://quip.com +// Submitted by Patrick Linehan +*.quipelements.com + +// Qutheory LLC : http://qutheory.io +// Submitted by Jonas Schwartz +vapor.cloud +vaporcloud.io + +// Rackmaze LLC : https://www.rackmaze.com +// Submitted by Kirill Pertsev +rackmaze.com +rackmaze.net + +// Rancher Labs, Inc : https://rancher.com +// Submitted by Vincent Fiduccia +*.on-rancher.cloud +*.on-k3s.io +*.on-rio.io + +// Read The Docs, Inc : https://www.readthedocs.org +// Submitted by David Fischer +readthedocs.io + +// Red Hat, Inc. OpenShift : https://openshift.redhat.com/ +// Submitted by Tim Kramer +rhcloud.com + +// Render : https://render.com +// Submitted by Anurag Goel +onrender.com +app.render.com + +// Repl.it : https://repl.it +// Submitted by Lincoln Bergeson +replit.app +id.replit.app +firewalledreplit.co +id.firewalledreplit.co +repl.co +id.repl.co +replit.dev +archer.replit.dev +bones.replit.dev +canary.replit.dev +global.replit.dev +hacker.replit.dev +id.replit.dev +janeway.replit.dev +kim.replit.dev +kira.replit.dev +kirk.replit.dev +odo.replit.dev +paris.replit.dev +picard.replit.dev +pike.replit.dev +prerelease.replit.dev +reed.replit.dev +riker.replit.dev +sisko.replit.dev +spock.replit.dev +staging.replit.dev +sulu.replit.dev +tarpit.replit.dev +teams.replit.dev +tucker.replit.dev +wesley.replit.dev +worf.replit.dev +repl.run + +// Resin.io : https://resin.io +// Submitted by Tim Perry +resindevice.io +devices.resinstaging.io + +// RethinkDB : https://www.rethinkdb.com/ +// Submitted by Chris Kastorff +hzc.io + +// Revitalised Limited : http://www.revitalised.co.uk +// Submitted by Jack Price +wellbeingzone.eu +wellbeingzone.co.uk + +// Rico Developments Limited : https://adimo.co +// Submitted by Colin Brown +adimo.co.uk + +// Riseup Networks : https://riseup.net +// Submitted by Micah Anderson +itcouldbewor.se + +// Rochester Institute of Technology : http://www.rit.edu/ +// Submitted by Jennifer Herting +git-pages.rit.edu + +// Rocky Enterprise Software Foundation : https://resf.org +// Submitted by Neil Hanlon +rocky.page + +// Rusnames Limited: http://rusnames.ru/ +// Submitted by Sergey Zotov +биз.рус +ком.рус +крым.рус +мир.рус +мск.рус +орг.рус +самара.рус +сочи.рус +спб.рус +я.рус + +// SAKURA Internet Inc. : https://www.sakura.ad.jp/ +// Submitted by Internet Service Department +180r.com +dojin.com +sakuratan.com +sakuraweb.com +x0.com +2-d.jp +bona.jp +crap.jp +daynight.jp +eek.jp +flop.jp +halfmoon.jp +jeez.jp +matrix.jp +mimoza.jp +ivory.ne.jp +mail-box.ne.jp +mints.ne.jp +mokuren.ne.jp +opal.ne.jp +sakura.ne.jp +sumomo.ne.jp +topaz.ne.jp +netgamers.jp +nyanta.jp +o0o0.jp +rdy.jp +rgr.jp +rulez.jp +s3.isk01.sakurastorage.jp +s3.isk02.sakurastorage.jp +saloon.jp +sblo.jp +skr.jp +tank.jp +uh-oh.jp +undo.jp +rs.webaccel.jp +user.webaccel.jp +websozai.jp +xii.jp +squares.net +jpn.org +kirara.st +x0.to +from.tv +sakura.tv + +// Salesforce.com, Inc. https://salesforce.com/ +// Submitted by Salesforce Public Suffix List Team +*.builder.code.com +*.dev-builder.code.com +*.stg-builder.code.com +*.001.test.code-builder-stg.platform.salesforce.com +*.d.crm.dev +*.w.crm.dev +*.wa.crm.dev +*.wb.crm.dev +*.wc.crm.dev +*.wd.crm.dev +*.we.crm.dev +*.wf.crm.dev + +// Sandstorm Development Group, Inc. : https://sandcats.io/ +// Submitted by Asheesh Laroia +sandcats.io + +// SBE network solutions GmbH : https://www.sbe.de/ +// Submitted by Norman Meilick +logoip.com +logoip.de + +// Scaleway : https://www.scaleway.com/ +// Submitted by Rémy Léone +fr-par-1.baremetal.scw.cloud +fr-par-2.baremetal.scw.cloud +nl-ams-1.baremetal.scw.cloud +cockpit.fr-par.scw.cloud +fnc.fr-par.scw.cloud +functions.fnc.fr-par.scw.cloud +k8s.fr-par.scw.cloud +nodes.k8s.fr-par.scw.cloud +s3.fr-par.scw.cloud +s3-website.fr-par.scw.cloud +whm.fr-par.scw.cloud +priv.instances.scw.cloud +pub.instances.scw.cloud +k8s.scw.cloud +cockpit.nl-ams.scw.cloud +k8s.nl-ams.scw.cloud +nodes.k8s.nl-ams.scw.cloud +s3.nl-ams.scw.cloud +s3-website.nl-ams.scw.cloud +whm.nl-ams.scw.cloud +cockpit.pl-waw.scw.cloud +k8s.pl-waw.scw.cloud +nodes.k8s.pl-waw.scw.cloud +s3.pl-waw.scw.cloud +s3-website.pl-waw.scw.cloud +scalebook.scw.cloud +smartlabeling.scw.cloud +dedibox.fr + +// schokokeks.org GbR : https://schokokeks.org/ +// Submitted by Hanno Böck +schokokeks.net + +// Scottish Government: https://www.gov.scot +// Submitted by Martin Ellis +gov.scot +service.gov.scot + +// Scry Security : http://www.scrysec.com +// Submitted by Shante Adam +scrysec.com + +// Scrypted : https://scrypted.app +// Submitted by Koushik Dutta +client.scrypted.io + +// Securepoint GmbH : https://www.securepoint.de +// Submitted by Erik Anders +firewall-gateway.com +firewall-gateway.de +my-gateway.de +my-router.de +spdns.de +spdns.eu +firewall-gateway.net +my-firewall.org +myfirewall.org +spdns.org + +// Seidat : https://www.seidat.com +// Submitted by Artem Kondratev +seidat.net + +// Sellfy : https://sellfy.com +// Submitted by Yuriy Romadin +sellfy.store + +// Senseering GmbH : https://www.senseering.de +// Submitted by Felix Mönckemeyer +senseering.net + +// Sendmsg: https://www.sendmsg.co.il +// Submitted by Assaf Stern +minisite.ms + +// Servebolt AS: https://servebolt.com +// Submitted by Daniel Kjeserud +servebolt.cloud + +// Service Magnet : https://myservicemagnet.com +// Submitted by Dave Sanders +magnet.page + +// Service Online LLC : http://drs.ua/ +// Submitted by Serhii Bulakh +biz.ua +co.ua +pp.ua + +// Shanghai Accounting Society : https://www.sasf.org.cn +// Submitted by Information Administration +as.sh.cn + +// Sheezy.Art : https://sheezy.art +// Submitted by Nyoom +sheezy.games + +// Shift Crypto AG : https://shiftcrypto.ch +// Submitted by alex +shiftcrypto.dev +shiftcrypto.io + +// ShiftEdit : https://shiftedit.net/ +// Submitted by Adam Jimenez +shiftedit.io + +// Shopblocks : http://www.shopblocks.com/ +// Submitted by Alex Bowers +myshopblocks.com + +// Shopify : https://www.shopify.com +// Submitted by Alex Richter +myshopify.com + +// Shopit : https://www.shopitcommerce.com/ +// Submitted by Craig McMahon +shopitsite.com + +// shopware AG : https://shopware.com +// Submitted by Jens Küper +shopware.store + +// Siemens Mobility GmbH +// Submitted by Oliver Graebner +mo-siemens.io + +// SinaAppEngine : http://sae.sina.com.cn/ +// Submitted by SinaAppEngine +1kapp.com +appchizi.com +applinzi.com +sinaapp.com +vipsinaapp.com + +// Siteleaf : https://www.siteleaf.com/ +// Submitted by Skylar Challand +siteleaf.net + +// Skyhat : http://www.skyhat.io +// Submitted by Shante Adam +bounty-full.com +alpha.bounty-full.com +beta.bounty-full.com + +// Smallregistry by Promopixel SARL: https://www.smallregistry.net +// Former AFNIC's SLDs +// Submitted by Jérôme Lipowicz +aeroport.fr +avocat.fr +chambagri.fr +chirurgiens-dentistes.fr +experts-comptables.fr +medecin.fr +notaires.fr +pharmacien.fr +port.fr +veterinaire.fr + +// Small Technology Foundation : https://small-tech.org +// Submitted by Aral Balkan +small-web.org + +// Smoove.io : https://www.smoove.io/ +// Submitted by Dan Kozak +vp4.me + +// Snowflake Inc : https://www.snowflake.com/ +// Submitted by Sam Haar +*.snowflake.app +*.privatelink.snowflake.app +streamlit.app +streamlitapp.com + +// Snowplow Analytics : https://snowplowanalytics.com/ +// Submitted by Ian Streeter +try-snowplow.com + +// SourceHut : https://sourcehut.org +// Submitted by Drew DeVault +srht.site + +// SparrowHost : https://sparrowhost.in/ +// Submitted by Anant Pandey +ind.mom + +// StackBlitz : https://stackblitz.com +// Submitted by Dominic Elm +w-corp-staticblitz.com +w-credentialless-staticblitz.com +w-staticblitz.com + +// Stackhero : https://www.stackhero.io +// Submitted by Adrien Gillon +stackhero-network.com + +// STACKIT : https://www.stackit.de/en/ +// Submitted by STACKIT-DNS Team (Simon Stier) +runs.onstackit.cloud +stackit.gg +stackit.rocks +stackit.run +stackit.zone + +// Staclar : https://staclar.com +// Submitted by Q Misell +// Submitted by Matthias Merkel +musician.io +novecore.site + +// staticland : https://static.land +// Submitted by Seth Vincent +static.land +dev.static.land +sites.static.land + +// Storebase : https://www.storebase.io +// Submitted by Tony Schirmer +storebase.store + +// Strapi : https://strapi.io/ +// Submitted by Florent Baldino +strapiapp.com +media.strapiapp.com + +// Strategic System Consulting (eApps Hosting): https://www.eapps.com/ +// Submitted by Alex Oancea +vps-host.net +atl.jelastic.vps-host.net +njs.jelastic.vps-host.net +ric.jelastic.vps-host.net + +// Sony Interactive Entertainment LLC : https://sie.com/ +// Submitted by David Coles +playstation-cloud.com + +// SourceLair PC : https://www.sourcelair.com +// Submitted by Antonis Kalipetis +apps.lair.io +*.stolos.io + +// SpaceKit : https://www.spacekit.io/ +// Submitted by Reza Akhavan +spacekit.io + +// SpeedPartner GmbH: https://www.speedpartner.de/ +// Submitted by Stefan Neufeind +customer.speedpartner.de + +// Spreadshop (sprd.net AG) : https://www.spreadshop.com/ +// Submitted by Martin Breest +myspreadshop.at +myspreadshop.com.au +myspreadshop.be +myspreadshop.ca +myspreadshop.ch +myspreadshop.com +myspreadshop.de +myspreadshop.dk +myspreadshop.es +myspreadshop.fi +myspreadshop.fr +myspreadshop.ie +myspreadshop.it +myspreadshop.net +myspreadshop.nl +myspreadshop.no +myspreadshop.pl +myspreadshop.se +myspreadshop.co.uk + +// Standard Library : https://stdlib.com +// Submitted by Jacob Lee +api.stdlib.com + +// stereosense GmbH : https://www.involve.me +// Submitted by Florian Burmann +feedback.ac +forms.ac +assessments.cx +calculators.cx +funnels.cx +paynow.cx +quizzes.cx +researched.cx +tests.cx +surveys.so + +// Storipress : https://storipress.com +// Submitted by Benno Liu +storipress.app + +// Storj Labs Inc. : https://storj.io/ +// Submitted by Philip Hutchins +storj.farm + +// Streak : https://streak.com +// Submitted by Blake Kadatz +streak-link.com +streaklinks.com +streakusercontent.com + +// Studenten Net Twente : http://www.snt.utwente.nl/ +// Submitted by Silke Hofstra +utwente.io + +// Student-Run Computing Facility : https://www.srcf.net/ +// Submitted by Edwin Balani +soc.srcf.net +user.srcf.net + +// Sub 6 Limited: http://www.sub6.com +// Submitted by Dan Miller +temp-dns.com + +// Supabase : https://supabase.io +// Submitted by Inian Parameshwaran +supabase.co +supabase.in +supabase.net + +// Symfony, SAS : https://symfony.com/ +// Submitted by Fabien Potencier +*.sensiosite.cloud +*.s5y.io + +// Syncloud : https://syncloud.org +// Submitted by Boris Rybalkin +syncloud.it + +// Synology, Inc. : https://www.synology.com/ +// Submitted by Rony Weng +dscloud.biz +direct.quickconnect.cn +dsmynas.com +familyds.com +diskstation.me +dscloud.me +i234.me +myds.me +synology.me +dscloud.mobi +dsmynas.net +familyds.net +dsmynas.org +familyds.org +direct.quickconnect.to +vpnplus.to + +// Tabit Technologies Ltd. : https://tabit.cloud/ +// Submitted by Oren Agiv +mytabit.com +mytabit.co.il +tabitorder.co.il + +// TAIFUN Software AG : http://taifun-software.de +// Submitted by Bjoern Henke +taifun-dns.de + +// Tailscale Inc. : https://www.tailscale.com +// Submitted by David Anderson +beta.tailscale.net +ts.net +*.c.ts.net + +// TASK geographical domains (https://www.task.gda.pl/uslugi/dns) +gda.pl +gdansk.pl +gdynia.pl +med.pl +sopot.pl + +// tawk.to, Inc : https://www.tawk.to +// Submitted by tawk.to developer team +p.tawk.email +p.tawkto.email + +// team.blue https://team.blue +// Submitted by Cedric Dubois +site.tb-hosting.com + +// Teckids e.V. : https://www.teckids.org +// Submitted by Dominik George +edugit.io +s3.teckids.org + +// Telebit : https://telebit.cloud +// Submitted by AJ ONeal +telebit.app +telebit.io +*.telebit.xyz + +// Thingdust AG : https://thingdust.com/ +// Submitted by Adrian Imboden +*.firenet.ch +*.svc.firenet.ch +reservd.com +thingdustdata.com +cust.dev.thingdust.io +reservd.dev.thingdust.io +cust.disrec.thingdust.io +reservd.disrec.thingdust.io +cust.prod.thingdust.io +cust.testing.thingdust.io +reservd.testing.thingdust.io + +// ticket i/O GmbH : https://ticket.io +// Submitted by Christian Franke +tickets.io + +// Tlon.io : https://tlon.io +// Submitted by Mark Staarink +arvo.network +azimuth.network +tlon.network + +// Tor Project, Inc. : https://torproject.org +// Submitted by Antoine Beaupré +torproject.net +pages.torproject.net + +// TownNews.com : http://www.townnews.com +// Submitted by Dustin Ward +bloxcms.com +townnews-staging.com + +// TrafficPlex GmbH : https://www.trafficplex.de/ +// Submitted by Phillipp Röll +12hp.at +2ix.at +4lima.at +lima-city.at +12hp.ch +2ix.ch +4lima.ch +lima-city.ch +trafficplex.cloud +de.cool +12hp.de +2ix.de +4lima.de +lima-city.de +1337.pictures +clan.rip +lima-city.rocks +webspace.rocks +lima.zone + +// TransIP : https://www.transip.nl +// Submitted by Rory Breuk +*.transurl.be +*.transurl.eu +*.transurl.nl + +// TransIP: https://www.transip.nl +// Submitted by Cedric Dubois +site.transip.me + +// TuxFamily : http://tuxfamily.org +// Submitted by TuxFamily administrators +tuxfamily.org + +// TwoDNS : https://www.twodns.de/ +// Submitted by TwoDNS-Support +dd-dns.de +dray-dns.de +draydns.de +dyn-vpn.de +dynvpn.de +mein-vigor.de +my-vigor.de +my-wan.de +syno-ds.de +synology-diskstation.de +synology-ds.de +diskstation.eu +diskstation.org + +// Typedream : https://typedream.com +// Submitted by Putri Karunia +typedream.app + +// Typeform : https://www.typeform.com +// Submitted by Sergi Ferriz +pro.typeform.com + +// Uberspace : https://uberspace.de +// Submitted by Moritz Werner +*.uberspace.de +uber.space + +// UDR Limited : http://www.udr.hk.com +// Submitted by registry +hk.com +inc.hk +ltd.hk +hk.org + +// UK Intis Telecom LTD : https://it.com +// Submitted by ITComdomains +it.com + +// Unison Computing, PBC : https://unison.cloud +// Submitted by Simon Højberg +unison-services.cloud + +// UNIVERSAL DOMAIN REGISTRY : https://www.udr.org.yt/ +// see also: whois -h whois.udr.org.yt help +// Submitted by Atanunu Igbunuroghene +name.pm +sch.tf +biz.wf +sch.wf +org.yt + +// United Gameserver GmbH : https://united-gameserver.de +// Submitted by Stefan Schwarz +virtual-user.de +virtualuser.de + +// Upli : https://upli.io +// Submitted by Lenny Bakkalian +upli.io + +// urown.net : https://urown.net +// Submitted by Hostmaster +urown.cloud +dnsupdate.info + +// .US +// Submitted by Ed Moore +lib.de.us + +// Val Town, Inc : https://val.town/ +// Submitted by Tom MacWright +express.val.run +web.val.run + +// VeryPositive SIA : http://very.lv +// Submitted by Danko Aleksejevs +2038.io + +// Vercel, Inc : https://vercel.com/ +// Submitted by Connor Davis +vercel.app +vercel.dev +now.sh + +// Viprinet Europe GmbH : http://www.viprinet.com +// Submitted by Simon Kissel +router.management + +// Virtual-Info : https://www.virtual-info.info/ +// Submitted by Adnan RIHAN +v-info.info + +// Voorloper.com: https://voorloper.com +// Submitted by Nathan van Bakel +voorloper.cloud + +// V.UA Domain Administrator : https://domain.v.ua/ +// Submitted by Serhii Rostilo +v.ua + +// Vultr Objects : https://www.vultr.com/products/object-storage/ +// Submitted by Niels Maumenee +*.vultrobjects.com + +// Waffle Computer Inc., Ltd. : https://docs.waffleinfo.com +// Submitted by Masayuki Note +wafflecell.com + +// Webflow, Inc. : https://www.webflow.com +// Submitted by Webflow Security Team +webflow.io +webflowtest.io + +// WebHare bv: https://www.webhare.com/ +// Submitted by Arnold Hendriks +*.webhare.dev + +// WebHotelier Technologies Ltd: https://www.webhotelier.net/ +// Submitted by Apostolos Tsakpinis +bookonline.app +hotelwithflight.com +reserve-online.com +reserve-online.net + +// WebPros International, LLC : https://webpros.com/ +// Submitted by Nicolas Rochelemagne +cprapid.com +pleskns.com +wp2.host +pdns.page +plesk.page +wpsquared.site + +// WebWaddle Ltd: https://webwaddle.com/ +// Submitted by Merlin Glander +*.wadl.top + +// WeDeploy by Liferay, Inc. : https://www.wedeploy.com +// Submitted by Henrique Vicente +wedeploy.io +wedeploy.me +wedeploy.sh + +// Western Digital Technologies, Inc : https://www.wdc.com +// Submitted by Jung Jin +remotewd.com + +// Whatbox Inc. : https://whatbox.ca/ +// Submitted by Anthony Ryan +box.ca + +// WIARD Enterprises : https://wiardweb.com +// Submitted by Kidd Hustle +pages.wiardweb.com + +// Wikimedia Labs : https://wikitech.wikimedia.org +// Submitted by Arturo Borrero Gonzalez +toolforge.org +wmcloud.org +wmflabs.org + +// WISP : https://wisp.gg +// Submitted by Stepan Fedotov +panel.gg +daemon.panel.gg + +// Wix.com, Inc. : https://www.wix.com +// Submitted by Shahar Talmi / Alon Kochba +wixsite.com +wixstudio.com +editorx.io +wixstudio.io +wix.run + +// Wizard Zines : https://wizardzines.com +// Submitted by Julia Evans +messwithdns.com + +// WoltLab GmbH : https://www.woltlab.com +// Submitted by Tim Düsterhus +woltlab-demo.com +myforum.community +community-pro.de +diskussionsbereich.de +community-pro.net +meinforum.net + +// Woods Valldata : https://www.woodsvalldata.co.uk/ +// Submitted by Chris Whittle +affinitylottery.org.uk +raffleentry.org.uk +weeklylottery.org.uk + +// WP Engine : https://wpengine.com/ +// Submitted by Michael Smith +// Submitted by Brandon DuRette +wpenginepowered.com +js.wpenginepowered.com + +// XenonCloud GbR: https://xenoncloud.net +// Submitted by Julian Uphoff +half.host + +// XnBay Technology : http://www.xnbay.com/ +// Submitted by XnBay Developer +xnbay.com +u2.xnbay.com +u2-local.xnbay.com + +// XS4ALL Internet bv : https://www.xs4all.nl/ +// Submitted by Daniel Mostertman +cistron.nl +demon.nl +xs4all.space + +// Yandex.Cloud LLC: https://cloud.yandex.com +// Submitted by Alexander Lodin +yandexcloud.net +storage.yandexcloud.net +website.yandexcloud.net + +// YesCourse Pty Ltd : https://yescourse.com +// Submitted by Atul Bhouraskar +official.academy + +// Yola : https://www.yola.com/ +// Submitted by Stefano Rivera +yolasite.com + +// Yombo : https://yombo.net +// Submitted by Mitch Schwenk +ybo.faith +yombo.me +homelink.one +ybo.party +ybo.review +ybo.science +ybo.trade + +// Yunohost : https://yunohost.org +// Submitted by Valentin Grimaud +ynh.fr +nohost.me +noho.st + +// ZaNiC : http://www.za.net/ +// Submitted by registry +za.net +za.org + +// ZAP-Hosting GmbH & Co. KG : https://zap-hosting.com +// Submitted by Julian Alker +zap.cloud + +// Zeabur : https://zeabur.com/ +// Submitted by Zeabur Team +zeabur.app + +// Zine EOOD : https://zine.bg/ +// Submitted by Martin Angelov +bss.design + +// Zitcom A/S : https://www.zitcom.dk +// Submitted by Emil Stahl +basicserver.io +virtualserver.io +enterprisecloud.nu + +// ===END PRIVATE DOMAINS=== diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix.rb b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix.rb new file mode 100644 index 0000000..bd131e3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix.rb @@ -0,0 +1,177 @@ +# frozen_string_literal: true + +# = Public Suffix +# +# Domain name parser based on the Public Suffix List. +# +# Copyright (c) 2009-2024 Simone Carletti + +require_relative "public_suffix/domain" +require_relative "public_suffix/version" +require_relative "public_suffix/errors" +require_relative "public_suffix/rule" +require_relative "public_suffix/list" + +# PublicSuffix is a Ruby domain name parser based on the Public Suffix List. +# +# The [Public Suffix List](https://publicsuffix.org) is a cross-vendor initiative +# to provide an accurate list of domain name suffixes. +# +# The Public Suffix List is an initiative of the Mozilla Project, +# but is maintained as a community resource. It is available for use in any software, +# but was originally created to meet the needs of browser manufacturers. +module PublicSuffix + + DOT = "." + BANG = "!" + STAR = "*" + + # Parses +name+ and returns the {PublicSuffix::Domain} instance. + # + # @example Parse a valid domain + # PublicSuffix.parse("google.com") + # # => # + # + # @example Parse a valid subdomain + # PublicSuffix.parse("www.google.com") + # # => # + # + # @example Parse a fully qualified domain + # PublicSuffix.parse("google.com.") + # # => # + # + # @example Parse a fully qualified domain (subdomain) + # PublicSuffix.parse("www.google.com.") + # # => # + # + # @example Parse an invalid (unlisted) domain + # PublicSuffix.parse("x.yz") + # # => # + # + # @example Parse an invalid (unlisted) domain with strict checking (without applying the default * rule) + # PublicSuffix.parse("x.yz", default_rule: nil) + # # => PublicSuffix::DomainInvalid: `x.yz` is not a valid domain + # + # @example Parse an URL (not supported, only domains) + # PublicSuffix.parse("http://www.google.com") + # # => PublicSuffix::DomainInvalid: http://www.google.com is not expected to contain a scheme + # + # + # @param name [#to_s] The domain name or fully qualified domain name to parse. + # @param list [PublicSuffix::List] The rule list to search, defaults to the default {PublicSuffix::List} + # @param ignore_private [Boolean] + # @return [PublicSuffix::Domain] + # + # @raise [PublicSuffix::DomainInvalid] If domain is not a valid domain. + # @raise [PublicSuffix::DomainNotAllowed] If a rule for +domain+ is found, but the rule doesn't allow +domain+. + def self.parse(name, list: List.default, default_rule: list.default_rule, ignore_private: false) + what = normalize(name) + raise what if what.is_a?(DomainInvalid) + + rule = list.find(what, default: default_rule, ignore_private: ignore_private) + + # rubocop:disable Style/IfUnlessModifier + if rule.nil? + raise DomainInvalid, "`#{what}` is not a valid domain" + end + if rule.decompose(what).last.nil? + raise DomainNotAllowed, "`#{what}` is not allowed according to Registry policy" + end + + # rubocop:enable Style/IfUnlessModifier + + decompose(what, rule) + end + + # Checks whether +domain+ is assigned and allowed, without actually parsing it. + # + # This method doesn't care whether domain is a domain or subdomain. + # The validation is performed using the default {PublicSuffix::List}. + # + # @example Validate a valid domain + # PublicSuffix.valid?("example.com") + # # => true + # + # @example Validate a valid subdomain + # PublicSuffix.valid?("www.example.com") + # # => true + # + # @example Validate a not-listed domain + # PublicSuffix.valid?("example.tldnotlisted") + # # => true + # + # @example Validate a not-listed domain with strict checking (without applying the default * rule) + # PublicSuffix.valid?("example.tldnotlisted") + # # => true + # PublicSuffix.valid?("example.tldnotlisted", default_rule: nil) + # # => false + # + # @example Validate a fully qualified domain + # PublicSuffix.valid?("google.com.") + # # => true + # PublicSuffix.valid?("www.google.com.") + # # => true + # + # @example Check an URL (which is not a valid domain) + # PublicSuffix.valid?("http://www.example.com") + # # => false + # + # + # @param name [#to_s] The domain name or fully qualified domain name to validate. + # @param ignore_private [Boolean] + # @return [Boolean] + def self.valid?(name, list: List.default, default_rule: list.default_rule, ignore_private: false) + what = normalize(name) + return false if what.is_a?(DomainInvalid) + + rule = list.find(what, default: default_rule, ignore_private: ignore_private) + + !rule.nil? && !rule.decompose(what).last.nil? + end + + # Attempt to parse the name and returns the domain, if valid. + # + # This method doesn't raise. Instead, it returns nil if the domain is not valid for whatever reason. + # + # @param name [#to_s] The domain name or fully qualified domain name to parse. + # @param list [PublicSuffix::List] The rule list to search, defaults to the default {PublicSuffix::List} + # @param ignore_private [Boolean] + # @return [String] + def self.domain(name, **options) + parse(name, **options).domain + rescue PublicSuffix::Error + nil + end + + + # private + + def self.decompose(name, rule) + left, right = rule.decompose(name) + + parts = left.split(DOT) + # If we have 0 parts left, there is just a tld and no domain or subdomain + # If we have 1 part left, there is just a tld, domain and not subdomain + # If we have 2 parts left, the last part is the domain, the other parts (combined) are the subdomain + tld = right + sld = parts.empty? ? nil : parts.pop + trd = parts.empty? ? nil : parts.join(DOT) + + Domain.new(tld, sld, trd) + end + + # Pretend we know how to deal with user input. + def self.normalize(name) + name = name.to_s.dup + name.strip! + name.chomp!(DOT) + name.downcase! + + return DomainInvalid.new("Name is blank") if name.empty? + return DomainInvalid.new("Name starts with a dot") if name.start_with?(DOT) + return DomainInvalid.new(format("%s is not expected to contain a scheme", name)) if name.include?("://") + + name + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/domain.rb b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/domain.rb new file mode 100644 index 0000000..54e05f9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/domain.rb @@ -0,0 +1,235 @@ +# frozen_string_literal: true + +# = Public Suffix +# +# Domain name parser based on the Public Suffix List. +# +# Copyright (c) 2009-2024 Simone Carletti + +module PublicSuffix + + # Domain represents a domain name, composed by a TLD, SLD and TRD. + class Domain + + # Splits a string into the labels, that is the dot-separated parts. + # + # The input is not validated, but it is assumed to be a valid domain name. + # + # @example + # + # name_to_labels('example.com') + # # => ['example', 'com'] + # + # name_to_labels('example.co.uk') + # # => ['example', 'co', 'uk'] + # + # @param name [String, #to_s] The domain name to split. + # @return [Array] + def self.name_to_labels(name) + name.to_s.split(DOT) + end + + + attr_reader :tld, :sld, :trd + + # Creates and returns a new {PublicSuffix::Domain} instance. + # + # @overload initialize(tld) + # Initializes with a +tld+. + # @param [String] tld The TLD (extension) + # @overload initialize(tld, sld) + # Initializes with a +tld+ and +sld+. + # @param [String] tld The TLD (extension) + # @param [String] sld The TRD (domain) + # @overload initialize(tld, sld, trd) + # Initializes with a +tld+, +sld+ and +trd+. + # @param [String] tld The TLD (extension) + # @param [String] sld The SLD (domain) + # @param [String] trd The TRD (subdomain) + # + # @yield [self] Yields on self. + # @yieldparam [PublicSuffix::Domain] self The newly creates instance + # + # @example Initialize with a TLD + # PublicSuffix::Domain.new("com") + # # => # + # + # @example Initialize with a TLD and SLD + # PublicSuffix::Domain.new("com", "example") + # # => # + # + # @example Initialize with a TLD, SLD and TRD + # PublicSuffix::Domain.new("com", "example", "wwww") + # # => # + # + def initialize(*args) + @tld, @sld, @trd = args + yield(self) if block_given? + end + + # Returns a string representation of this object. + # + # @return [String] + def to_s + name + end + + # Returns an array containing the domain parts. + # + # @return [Array] + # + # @example + # + # PublicSuffix::Domain.new("google.com").to_a + # # => [nil, "google", "com"] + # + # PublicSuffix::Domain.new("www.google.com").to_a + # # => [nil, "google", "com"] + # + def to_a + [@trd, @sld, @tld] + end + + # Returns the full domain name. + # + # @return [String] + # + # @example Gets the domain name of a domain + # PublicSuffix::Domain.new("com", "google").name + # # => "google.com" + # + # @example Gets the domain name of a subdomain + # PublicSuffix::Domain.new("com", "google", "www").name + # # => "www.google.com" + # + def name + [@trd, @sld, @tld].compact.join(DOT) + end + + # Returns a domain-like representation of this object + # if the object is a {#domain?}, nil otherwise. + # + # PublicSuffix::Domain.new("com").domain + # # => nil + # + # PublicSuffix::Domain.new("com", "google").domain + # # => "google.com" + # + # PublicSuffix::Domain.new("com", "google", "www").domain + # # => "www.google.com" + # + # This method doesn't validate the input. It handles the domain + # as a valid domain name and simply applies the necessary transformations. + # + # This method returns a FQD, not just the domain part. + # To get the domain part, use #sld (aka second level domain). + # + # PublicSuffix::Domain.new("com", "google", "www").domain + # # => "google.com" + # + # PublicSuffix::Domain.new("com", "google", "www").sld + # # => "google" + # + # @see #domain? + # @see #subdomain + # + # @return [String] + def domain + [@sld, @tld].join(DOT) if domain? + end + + # Returns a subdomain-like representation of this object + # if the object is a {#subdomain?}, nil otherwise. + # + # PublicSuffix::Domain.new("com").subdomain + # # => nil + # + # PublicSuffix::Domain.new("com", "google").subdomain + # # => nil + # + # PublicSuffix::Domain.new("com", "google", "www").subdomain + # # => "www.google.com" + # + # This method doesn't validate the input. It handles the domain + # as a valid domain name and simply applies the necessary transformations. + # + # This method returns a FQD, not just the subdomain part. + # To get the subdomain part, use #trd (aka third level domain). + # + # PublicSuffix::Domain.new("com", "google", "www").subdomain + # # => "www.google.com" + # + # PublicSuffix::Domain.new("com", "google", "www").trd + # # => "www" + # + # @see #subdomain? + # @see #domain + # + # @return [String] + def subdomain + [@trd, @sld, @tld].join(DOT) if subdomain? + end + + # Checks whether self looks like a domain. + # + # This method doesn't actually validate the domain. + # It only checks whether the instance contains + # a value for the {#tld} and {#sld} attributes. + # + # @example + # + # PublicSuffix::Domain.new("com").domain? + # # => false + # + # PublicSuffix::Domain.new("com", "google").domain? + # # => true + # + # PublicSuffix::Domain.new("com", "google", "www").domain? + # # => true + # + # # This is an invalid domain, but returns true + # # because this method doesn't validate the content. + # PublicSuffix::Domain.new("com", nil).domain? + # # => true + # + # @see #subdomain? + # + # @return [Boolean] + def domain? + !(@tld.nil? || @sld.nil?) + end + + # Checks whether self looks like a subdomain. + # + # This method doesn't actually validate the subdomain. + # It only checks whether the instance contains + # a value for the {#tld}, {#sld} and {#trd} attributes. + # If you also want to validate the domain, + # use {#valid_subdomain?} instead. + # + # @example + # + # PublicSuffix::Domain.new("com").subdomain? + # # => false + # + # PublicSuffix::Domain.new("com", "google").subdomain? + # # => false + # + # PublicSuffix::Domain.new("com", "google", "www").subdomain? + # # => true + # + # # This is an invalid domain, but returns true + # # because this method doesn't validate the content. + # PublicSuffix::Domain.new("com", "example", nil).subdomain? + # # => true + # + # @see #domain? + # + # @return [Boolean] + def subdomain? + !(@tld.nil? || @sld.nil? || @trd.nil?) + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/errors.rb b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/errors.rb new file mode 100644 index 0000000..40ee981 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/errors.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +# = Public Suffix +# +# Domain name parser based on the Public Suffix List. +# +# Copyright (c) 2009-2024 Simone Carletti + +module PublicSuffix + + class Error < StandardError + end + + # Raised when trying to parse an invalid name. + # A name is considered invalid when no rule is found in the definition list. + # + # @example + # + # PublicSuffix.parse("nic.test") + # # => PublicSuffix::DomainInvalid + # + # PublicSuffix.parse("http://www.nic.it") + # # => PublicSuffix::DomainInvalid + # + class DomainInvalid < Error + end + + # Raised when trying to parse a name that matches a suffix. + # + # @example + # + # PublicSuffix.parse("nic.do") + # # => PublicSuffix::DomainNotAllowed + # + # PublicSuffix.parse("www.nic.do") + # # => PublicSuffix::Domain + # + class DomainNotAllowed < DomainInvalid + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/list.rb b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/list.rb new file mode 100644 index 0000000..d90b723 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/list.rb @@ -0,0 +1,247 @@ +# frozen_string_literal: true + +# = Public Suffix +# +# Domain name parser based on the Public Suffix List. +# +# Copyright (c) 2009-2024 Simone Carletti + +module PublicSuffix + + # A {PublicSuffix::List} is a collection of one + # or more {PublicSuffix::Rule}. + # + # Given a {PublicSuffix::List}, + # you can add or remove {PublicSuffix::Rule}, + # iterate all items in the list or search for the first rule + # which matches a specific domain name. + # + # # Create a new list + # list = PublicSuffix::List.new + # + # # Push two rules to the list + # list << PublicSuffix::Rule.factory("it") + # list << PublicSuffix::Rule.factory("com") + # + # # Get the size of the list + # list.size + # # => 2 + # + # # Search for the rule matching given domain + # list.find("example.com") + # # => # + # list.find("example.org") + # # => nil + # + # You can create as many {PublicSuffix::List} you want. + # The {PublicSuffix::List.default} rule list is used + # to tokenize and validate a domain. + # + class List + + DEFAULT_LIST_PATH = File.expand_path("../../data/list.txt", __dir__) + + # Gets the default rule list. + # + # Initializes a new {PublicSuffix::List} parsing the content + # of {PublicSuffix::List.default_list_content}, if required. + # + # @return [PublicSuffix::List] + def self.default(**options) + @default ||= parse(File.read(DEFAULT_LIST_PATH), **options) + end + + # Sets the default rule list to +value+. + # + # @param value [PublicSuffix::List] the new list + # @return [PublicSuffix::List] + def self.default=(value) + @default = value + end + + # Parse given +input+ treating the content as Public Suffix List. + # + # See http://publicsuffix.org/format/ for more details about input format. + # + # @param input [#each_line] the list to parse + # @param private_domains [Boolean] whether to ignore the private domains section + # @return [PublicSuffix::List] + def self.parse(input, private_domains: true) + comment_token = "//" + private_token = "===BEGIN PRIVATE DOMAINS===" + section = nil # 1 == ICANN, 2 == PRIVATE + + new do |list| + input.each_line do |line| + line.strip! + case # rubocop:disable Style/EmptyCaseCondition + + # skip blank lines + when line.empty? + next + + # include private domains or stop scanner + when line.include?(private_token) + break if !private_domains + + section = 2 + + # skip comments + when line.start_with?(comment_token) # rubocop:disable Lint/DuplicateBranch + next + + else + list.add(Rule.factory(line, private: section == 2)) + + end + end + end + end + + + # Initializes an empty {PublicSuffix::List}. + # + # @yield [self] Yields on self. + # @yieldparam [PublicSuffix::List] self The newly created instance. + def initialize + @rules = {} + yield(self) if block_given? + end + + + # Checks whether two lists are equal. + # + # List one is equal to two, if two is an instance of + # {PublicSuffix::List} and each +PublicSuffix::Rule::*+ + # in list one is available in list two, in the same order. + # + # @param other [PublicSuffix::List] the List to compare + # @return [Boolean] + def ==(other) + return false unless other.is_a?(List) + + equal?(other) || @rules == other.rules + end + alias eql? == + + # Iterates each rule in the list. + def each(&block) + Enumerator.new do |y| + @rules.each do |key, node| + y << entry_to_rule(node, key) + end + end.each(&block) + end + + + # Adds the given object to the list and optionally refreshes the rule index. + # + # @param rule [PublicSuffix::Rule::*] the rule to add to the list + # @return [self] + def add(rule) + @rules[rule.value] = rule_to_entry(rule) + self + end + alias << add + + # Gets the number of rules in the list. + # + # @return [Integer] + def size + @rules.size + end + + # Checks whether the list is empty. + # + # @return [Boolean] + def empty? + @rules.empty? + end + + # Removes all rules. + # + # @return [self] + def clear + @rules.clear + self + end + + # Finds and returns the rule corresponding to the longest public suffix for the hostname. + # + # @param name [#to_s] the hostname + # @param default [PublicSuffix::Rule::*] the default rule to return in case no rule matches + # @return [PublicSuffix::Rule::*] + def find(name, default: default_rule, **options) + rule = select(name, **options).inject do |l, r| + return r if r.instance_of?(Rule::Exception) + + l.length > r.length ? l : r + end + rule || default + end + + # Selects all the rules matching given hostame. + # + # If `ignore_private` is set to true, the algorithm will skip the rules that are flagged as + # private domain. Note that the rules will still be part of the loop. + # If you frequently need to access lists ignoring the private domains, + # you should create a list that doesn't include these domains setting the + # `private_domains: false` option when calling {.parse}. + # + # Note that this method is currently private, as you should not rely on it. Instead, + # the public interface is {#find}. The current internal algorithm allows to return all + # matching rules, but different data structures may not be able to do it, and instead would + # return only the match. For this reason, you should rely on {#find}. + # + # @param name [#to_s] the hostname + # @param ignore_private [Boolean] + # @return [Array] + def select(name, ignore_private: false) + name = name.to_s + + parts = name.split(DOT).reverse! + index = 0 + query = parts[index] + rules = [] + + loop do + match = @rules[query] + rules << entry_to_rule(match, query) if !match.nil? && (ignore_private == false || match.private == false) + + index += 1 + break if index >= parts.size + + query = parts[index] + DOT + query + end + + rules + end + private :select + + # Gets the default rule. + # + # @see PublicSuffix::Rule.default_rule + # + # @return [PublicSuffix::Rule::*] + def default_rule + PublicSuffix::Rule.default + end + + + protected + + attr_reader :rules + + + private + + def entry_to_rule(entry, value) + entry.type.new(value: value, length: entry.length, private: entry.private) + end + + def rule_to_entry(rule) + Rule::Entry.new(rule.class, rule.length, rule.private) + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/rule.rb b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/rule.rb new file mode 100644 index 0000000..23696f3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/rule.rb @@ -0,0 +1,350 @@ +# frozen_string_literal: true + +# = Public Suffix +# +# Domain name parser based on the Public Suffix List. +# +# Copyright (c) 2009-2024 Simone Carletti + +module PublicSuffix + + # A Rule is a special object which holds a single definition + # of the Public Suffix List. + # + # There are 3 types of rules, each one represented by a specific + # subclass within the +PublicSuffix::Rule+ namespace. + # + # To create a new Rule, use the {PublicSuffix::Rule#factory} method. + # + # PublicSuffix::Rule.factory("ar") + # # => # + # + module Rule + + # @api internal + Entry = Struct.new(:type, :length, :private) # rubocop:disable Lint/StructNewOverride + + # = Abstract rule class + # + # This represent the base class for a Rule definition + # in the {Public Suffix List}[https://publicsuffix.org]. + # + # This is intended to be an Abstract class + # and you shouldn't create a direct instance. The only purpose + # of this class is to expose a common interface + # for all the available subclasses. + # + # * {PublicSuffix::Rule::Normal} + # * {PublicSuffix::Rule::Exception} + # * {PublicSuffix::Rule::Wildcard} + # + # ## Properties + # + # A rule is composed by 4 properties: + # + # value - A normalized version of the rule name. + # The normalization process depends on rule tpe. + # + # Here's an example + # + # PublicSuffix::Rule.factory("*.google.com") + # # + # + # ## Rule Creation + # + # The best way to create a new rule is passing the rule name + # to the PublicSuffix::Rule.factory method. + # + # PublicSuffix::Rule.factory("com") + # # => PublicSuffix::Rule::Normal + # + # PublicSuffix::Rule.factory("*.com") + # # => PublicSuffix::Rule::Wildcard + # + # This method will detect the rule type and create an instance + # from the proper rule class. + # + # ## Rule Usage + # + # A rule describes the composition of a domain name and explains how to tokenize + # the name into tld, sld and trd. + # + # To use a rule, you first need to be sure the name you want to tokenize + # can be handled by the current rule. + # You can use the #match? method. + # + # rule = PublicSuffix::Rule.factory("com") + # + # rule.match?("google.com") + # # => true + # + # rule.match?("google.com") + # # => false + # + # Rule order is significant. A name can match more than one rule. + # See the {Public Suffix Documentation}[http://publicsuffix.org/format/] + # to learn more about rule priority. + # + # When you have the right rule, you can use it to tokenize the domain name. + # + # rule = PublicSuffix::Rule.factory("com") + # + # rule.decompose("google.com") + # # => ["google", "com"] + # + # rule.decompose("www.google.com") + # # => ["www.google", "com"] + # + # @abstract + # + class Base + + # @return [String] the rule definition + attr_reader :value + + # @return [String] the length of the rule + attr_reader :length + + # @return [Boolean] true if the rule is a private domain + attr_reader :private + + + # Initializes a new rule from the content. + # + # @param content [String] the content of the rule + # @param private [Boolean] + def self.build(content, private: false) + new(value: content, private: private) + end + + # Initializes a new rule. + # + # @param value [String] + # @param private [Boolean] + def initialize(value:, length: nil, private: false) + @value = value.to_s + @length = length || (@value.count(DOT) + 1) + @private = private + end + + # Checks whether this rule is equal to other. + # + # @param other [PublicSuffix::Rule::*] The rule to compare + # @return [Boolean] true if this rule and other are instances of the same class + # and has the same value, false otherwise. + def ==(other) + equal?(other) || (self.class == other.class && value == other.value) + end + alias eql? == + + # Checks if this rule matches +name+. + # + # A domain name is said to match a rule if and only if + # all of the following conditions are met: + # + # - When the domain and rule are split into corresponding labels, + # that the domain contains as many or more labels than the rule. + # - Beginning with the right-most labels of both the domain and the rule, + # and continuing for all labels in the rule, one finds that for every pair, + # either they are identical, or that the label from the rule is "*". + # + # @see https://publicsuffix.org/list/ + # + # @example + # PublicSuffix::Rule.factory("com").match?("example.com") + # # => true + # PublicSuffix::Rule.factory("com").match?("example.net") + # # => false + # + # @param name [String] the domain name to check + # @return [Boolean] + def match?(name) + # NOTE: it works because of the assumption there are no + # rules like foo.*.com. If the assumption is incorrect, + # we need to properly walk the input and skip parts according + # to wildcard component. + diff = name.chomp(value) + diff.empty? || diff.end_with?(DOT) + end + + # @abstract + def parts + raise NotImplementedError + end + + # @abstract + # @param domain [#to_s] The domain name to decompose + # @return [Array] + def decompose(*) + raise NotImplementedError + end + + end + + # Normal represents a standard rule (e.g. com). + class Normal < Base + + # Gets the original rule definition. + # + # @return [String] The rule definition. + def rule + value + end + + # Decomposes the domain name according to rule properties. + # + # @param domain [#to_s] The domain name to decompose + # @return [Array] The array with [trd + sld, tld]. + def decompose(domain) + suffix = parts.join('\.') + matches = domain.to_s.match(/^(.*)\.(#{suffix})$/) + matches ? matches[1..2] : [nil, nil] + end + + # dot-split rule value and returns all rule parts + # in the order they appear in the value. + # + # @return [Array] + def parts + @value.split(DOT) + end + + end + + # Wildcard represents a wildcard rule (e.g. *.co.uk). + class Wildcard < Base + + # Initializes a new rule from the content. + # + # @param content [String] the content of the rule + # @param private [Boolean] + def self.build(content, private: false) + new(value: content.to_s[2..], private: private) + end + + # Initializes a new rule. + # + # @param value [String] + # @param length [Integer] + # @param private [Boolean] + def initialize(value:, length: nil, private: false) + super + length or @length += 1 # * counts as 1 + end + + # Gets the original rule definition. + # + # @return [String] The rule definition. + def rule + value == "" ? STAR : STAR + DOT + value + end + + # Decomposes the domain name according to rule properties. + # + # @param domain [#to_s] The domain name to decompose + # @return [Array] The array with [trd + sld, tld]. + def decompose(domain) + suffix = ([".*?"] + parts).join('\.') + matches = domain.to_s.match(/^(.*)\.(#{suffix})$/) + matches ? matches[1..2] : [nil, nil] + end + + # dot-split rule value and returns all rule parts + # in the order they appear in the value. + # + # @return [Array] + def parts + @value.split(DOT) + end + + end + + # Exception represents an exception rule (e.g. !parliament.uk). + class Exception < Base + + # Initializes a new rule from the content. + # + # @param content [#to_s] the content of the rule + # @param private [Boolean] + def self.build(content, private: false) + new(value: content.to_s[1..], private: private) + end + + # Gets the original rule definition. + # + # @return [String] The rule definition. + def rule + BANG + value + end + + # Decomposes the domain name according to rule properties. + # + # @param domain [#to_s] The domain name to decompose + # @return [Array] The array with [trd + sld, tld]. + def decompose(domain) + suffix = parts.join('\.') + matches = domain.to_s.match(/^(.*)\.(#{suffix})$/) + matches ? matches[1..2] : [nil, nil] + end + + # dot-split rule value and returns all rule parts + # in the order they appear in the value. + # The leftmost label is not considered a label. + # + # See http://publicsuffix.org/format/: + # If the prevailing rule is a exception rule, + # modify it by removing the leftmost label. + # + # @return [Array] + def parts + @value.split(DOT)[1..] + end + + end + + + # Takes the +name+ of the rule, detects the specific rule class + # and creates a new instance of that class. + # The +name+ becomes the rule +value+. + # + # @example Creates a Normal rule + # PublicSuffix::Rule.factory("ar") + # # => # + # + # @example Creates a Wildcard rule + # PublicSuffix::Rule.factory("*.ar") + # # => # + # + # @example Creates an Exception rule + # PublicSuffix::Rule.factory("!congresodelalengua3.ar") + # # => # + # + # @param content [#to_s] the content of the rule + # @return [PublicSuffix::Rule::*] A rule instance. + def self.factory(content, private: false) + case content.to_s[0, 1] + when STAR + Wildcard + when BANG + Exception + else + Normal + end.build(content, private: private) + end + + # The default rule to use if no rule match. + # + # The default rule is "*". From https://publicsuffix.org/list/: + # + # > If no rules match, the prevailing rule is "*". + # + # @return [PublicSuffix::Rule::Wildcard] The default rule. + def self.default + factory(STAR) + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/version.rb b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/version.rb new file mode 100644 index 0000000..2584d37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/public_suffix-6.0.1/lib/public_suffix/version.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# = Public Suffix +# +# Domain name parser based on the Public Suffix List. +# +# Copyright (c) 2009-2024 Simone Carletti + +module PublicSuffix + + # @return [String] the current library version + VERSION = "6.0.1" + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/History.rdoc b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/History.rdoc new file mode 100644 index 0000000..b8751f9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/History.rdoc @@ -0,0 +1,2403 @@ +=== 13.0.6 + +* Additional fix for #389 + Pull request #390 by hsbt + +=== 13.0.5 + +* Fixed the regression of #388 + Pull request #389 by hsbt + +=== 13.0.4 + +* Fix rake test loader swallowing useful error information. + Pull request #367 by deivid-rodriguez +* Add -C/--directory option the same as GNU make. + Pull request #376 by nobu + +=== 13.0.3 + +* Fix breaking change of execution order on TestTask. + Pull request #368 by ysakasin + +=== 13.0.2 + +==== Enhancements + +* Fix tests to work with current FileUtils + Pull Request #358 by jeremyevans +* Simplify default rake test loader + Pull Request #357 by deivid-rodriguez +* Update rdoc + Pull Request #366 by bahasalien +* Update broken links to rake articles from Avdi in README + Pull Request #360 by svl7 + +=== 13.0.1 + +==== Bug fixes + +* Fixed bug: Reenabled task raises previous exception on second invokation + Pull Request #271 by thorsteneckel +* Fix an incorrectly resolved arg pattern + Pull Request #327 by mjbellantoni + +=== 13.0.0 + +==== Enhancements + +* Follows recent changes on keyword arguments in ruby 2.7. + Pull Request #326 by nobu +* Make `PackageTask` be able to omit parent directory while packing files + Pull Request #310 by tonytonyjan +* Add order only dependency + Pull Request #269 by take-cheeze + +==== Compatibility changes + +* Drop old ruby versions(< 2.2) + +=== 12.3.3 + +==== Bug fixes + +* Use the application's name in error message if a task is not found. + Pull Request #303 by tmatilai + +==== Enhancements: + +* Use File.open explicitly. + +=== 12.3.2 + +==== Bug fixes + +* Fixed test fails caused by 2.6 warnings. + Pull Request #297 by hsbt + +==== Enhancements: + +* Rdoc improvements. + Pull Request #293 by colby-swandale +* Improve multitask performance. + Pull Request #273 by jsm +* Add alias `prereqs`. + Pull Request #268 by take-cheeze + +=== 12.3.1 + +==== Bug fixes + +* Support did_you_mean >= v1.2.0 which has a breaking change on formatters. + Pull request #262 by FUJI Goro. + +==== Enhancements: + +* Don't run task if it depends on already invoked but failed task. + Pull request #252 by Gonzalo Rodriguez. +* Make space trimming consistent for all task arguments. + Pull request #259 by Gonzalo Rodriguez. +* Removes duplicated inclusion of Rake::DSL in tests. + Pull request #254 by Gonzalo Rodriguez. +* Re-raise a LoadError that didn't come from require in the test loader. + Pull request #250 by Dylan Thacker-Smith. + +=== 12.3.0 + +==== Compatibility Changes + +* Bump `required_ruby_version` to Ruby 2.0.0. Rake has already + removed support for Ruby 1.9.x. + +==== Enhancements: + +* Support `test-bundled-gems` task on ruby core. + +=== 12.2.1 + +==== Bug fixes + +* Fixed to break Capistrano::Application on capistrano3. + +=== 12.2.0 + +==== Enhancements: + +* Make rake easier to use as a library + Pull request #211 by @drbrain +* Fix quadratic performance in FileTask#out_of_date? + Pull request #224 by @doudou +* Clarify output when printing nested exception traces + Pull request #232 by @urbanautomaton + +==== Bug fixes + +* Account for a file that match 2 or more patterns. + Pull request #231 by @styd + +=== 12.1.0 + +==== Enhancements: + +* Added did_you_mean feature for invalid rake task. + Pull request #221 by @xtina-starr +* Enabled to dependency chained by extensions. Pull request #39 by Petr Skocik. +* Make all of string literals to frozen objects on Ruby 2.4 or later. + +==== Bug fixes + +* Typo fixes in rakefile.rdoc. Pull request #180 by Yuta Kurotaki. +* Fix unexpected behavior of file task with dryrun option. + Pull request #183 by @aycabta. +* Make LoadError from running tests more obvious. Pull request #195 + by Eric Hodel. +* Fix unexpected TypeError with hash style option. Pull request #202 + by Kuniaki IGARASHI. + +=== 12.0.0 + +==== Compatibility Changes + +* Removed arguments on clear #157 by Jesse Bowes +* Removed `rake/contrib` packages. These are extracted to `rake-contrib` gem. +* Removed deprecated method named `last\_comment`. + +==== Enhancements: + +* Re-use trace option on `cleanup` task. #164 by Brian Henderson +* Actions adore keyword arguments #174 by Josh Cheek +* Rake::TaskArguments#key? alias of #has_key? #175 by Paul Annesley + +=== 11.3.0 / 2016-09-20 + +==== Enhancements: + +* Remove to reference `Fixnum` constant. Pull request #160 by nobu + +=== 11.2.2 / 2016-06-12 + +==== Bug fixes + +* Fix unexpected behavior with multiple dependencies on Rake::TestTask + +=== 11.2.1 / 2016-06-12 + +==== Bug fixes + +* Fix regression of dependencies handling on Rake::TestTask. Report #139 + +=== 11.2.0 / 2016-06-11 + +==== Bug fixes + +* Fix unexpected cut-out behavior on task description using triple dots + and exclamation. Report #106 from Stephan Kämper and Pull request #134 by Lee +* Fix empty argument assignment with `with_defaults` option. Pull request #135 + by bakunyo +* Ignore to use `hwprefs` on Darwin platform. Use sysctl now. Report #128 + +==== Enhancements + +* Spawn options for sh Pull equest #138 by Eric Hodel. +* Allow to specify dependencies(prerequisites) for Rake::TestTask + Pull request #117 by Tim Maslyuchenko +* Use Bundler task instead of hoe for gem release. +* Remove explicitly load to rubygems for Ruby 1.8. +* Unify to declare `Rake::VERSION`. +* Support xz format for PackageTask. + +=== 11.1.2 / 2016-03-28 + +==== Bug fixes + +* Remove `-W` option when Rake::TestTask#verbose enabled. It's misunderstanding + specification change with Rake 11. Partly revert #67 + +=== 11.1.1 / 2016-03-14 + +==== Bug fixes + +* Use `-W` instead of `--verbose` when Rake::TestTask#verbose enabled. + JRuby doesn't have `--verbose` option. + +=== 11.1.0 / 2016-03-11 + +==== Compatibility Changes + +* Revert to remove `last\_comment`. It will remove Rake 12. + +=== 11.0.1 / 2016-03-09 + +==== Bug fixes + +* Fixed packaging manifest. + +=== 11.0.0 / 2016-03-09 + +==== Bug fixes + +* Correctly handle bad encoding in exception messages. Pull request #113 + by Tomer Brisker +* Fix verbose option at TestTask. Pull request #67 by Mike Blumtritt + +==== Enhancements + +* Make FileList#exclude more analogous to FileList#include. +* Use IO.open instead of Open3.popen3 for CPU counter. +* Make Rake::Task#already_invoked publicly accessible. + Pull request #93 by Joe Rafaniello +* Lookup prerequisites with same name outside of scope instead of + matching self. Pull request #96 by Sandy Vanderbleek +* Make FileList#pathmap behave like String#pathmap. + Pull request #61 by Daniel Tamai +* Add fetch method to task arguments. + Pull request #12 by Chris Keathley +* Use ruby warnings by default. Pull request #97 by Harold Giménez + +==== Compatibility Changes + +* Removed to support Ruby 1.8.x +* Removed constant named `RAKEVERSION` +* Removed Rake::AltSystem +* Removed Rake::RubyForgePublisher +* Removed Rake::TaskManager#last\_comment. Use last\_description. +* Removed Rake::TaskLib#paste +* Removed Top-level SshDirPublisher, SshFreshDirPublisher, SshFilePublisher + and CompositePublisher from lib/rake/contrib/publisher.rb +* Removed "rake/runtest.rb" + +=== 10.5.0 / 2016-01-13 + +==== Enhancements + +* Removed monkey patching for Ruby 1.8. Pull request #46 by Pablo Herrero. +* Inheritance class of Rake::FileList returns always self class. + Pull request #74 by Thomas Scholz + +=== 10.4.2 / 2014-12-02 + +==== Bug fixes + +* Rake no longer edits ARGV. This allows you to re-exec rake from a rake + task. Pull requset #9 by Matt Palmer. +* Documented how Rake::DSL#desc handles sentences in task descriptions. + Issue #7 by Raza Sayed. +* Fixed test error on 1.9.3 with legacy RubyGems. Issue #8 by Matt Palmer. +* Deleted duplicated History entry. Pull request #10 by Yuji Yamamoto. + +=== 10.4.1 / 2014-12-01 + +==== Bug fixes + +* Reverted fix for #277 as it caused numerous issues for rake users. + rails/spring issue #366 by Gustavo Dutra. + +=== 10.4.0 / 2014-11-22 + +==== Enhancements + +* Upgraded to minitest 5. Pull request #292 by Teo Ljungberg. +* Added support for Pathname in rake tasks. Pull request #271 by Randy + Coulman. +* Rake now ignores falsy dependencies which allows for easier programmatic + creation of tasks. Pull request #273 by Manav. +* Rake no longer edits ARGV. This allows you to re-exec rake from a rake + task. Issue #277 by Matt Palmer. +* Etc.nprocessors is used for counting the number of CPUs. + +==== Bug fixes + +* Updated rake manpage. Issue #283 by Nathan Long, pull request #291 by + skittleys. +* Add Rake::LATE to allow rebuilding of files that depend on deleted files. + Bug #286, pull request #287 by David Grayson. +* Fix relinking of files when repackaging. Bug #276 by Muenze. +* Fixed some typos. Pull request #280 by Jed Northridge. +* Try counting CPUs via cpuinfo if host_os was not matched. Pull request + #282 by Edouard B. + +=== 10.3.2 / 2014-05-15 + +==== Bug fixes + +* Rake no longer infinitely loops when showing exception causes that refer to + each other. Bug #272 by Chris Bandy. +* Fixed documentation typos. Bug #275 by Jake Worth. + +=== 10.3.1 / 2014-04-17 + +==== Bug fixes + +* Really stop reporting an error when cleaning already-deleted files. Pull + request #269 by Randy Coulman +* Fixed infinite loop when cleaning already-deleted files on windows. + +=== 10.3 / 2014-04-15 + +==== Enhancements + +* Added --build-all option to rake which treats all file prerequisites as + out-of-date. Pull request #254 by Andrew Gilbert. +* Added Rake::NameSpace#scope. Issue #263 by Jon San Miguel. + +==== Bug fixes + +* Suppress org.jruby package files in rake error messages for JRuby users. + Issue #213 by Charles Nutter. +* Fixed typo, removed extra "h". Pull request #267 by Hsing-Hui Hsu. +* Rake no longer reports an error when cleaning already-deleted files. Pull + request #266 by Randy Coulman. +* Consume stderr while determining CPU count to avoid hang. Issue #268 by + Albert Sun. + +=== 10.2.2 / 2014-03-27 + +==== Bug fixes + +* Restored Ruby 1.8.7 compatibility + +=== 10.2.1 / 2014-03-25 + +==== Bug fixes + +* File tasks including a ':' are now top-level tasks again. Issue #262 by + Josh Holtrop. +* Use sysctl for CPU count for all BSDs. Pull request #261 by Joshua Stein. +* Fixed CPU detection for unknown platforms. + +=== 10.2.0 / 2014-03-24 + +==== Enhancements + +* Rake now requires Ruby 1.9 or newer. For me, this is a breaking change, but + it seems that Jim planned to release it with Rake 10.2. See also pull + request #247 by Philip Arndt. +* Rake now allows you to declare tasks under a namespace like: + + task 'a:b' do ... end + + Pull request #232 by Judson Lester. +* Task#source defaults to the first prerequisite in non-rule tasks. Pull + request #215 by Avdi Grimm. +* Rake now automatically rebuilds and reloads imported files. Pull request + #209 by Randy Coulman. +* The rake task arguments can contain escaped commas. Pull request #214 by + Filip Hrbek. +* Rake now prints the exception class on errors. Patch #251 by David Cornu. + +==== Bug fixes + +* Fixed typos. Pull request #256 by Valera Rozuvan, #250 via Jake Worth, #260 + by Zachary Scott. +* Fixed documentation for calling tasks with arguments. Pull request #235 by + John Varghese. +* Clarified `rake -f` usage message. Pull request #252 by Marco Pfatschbacher. +* Fixed a test failure on windows. Pull request #231 by Hiroshi Shirosaki. +* Fixed corrupted rake.1.gz. Pull request #225 by Michel Boaventura. +* Fixed bug in can\_detect\_signals? in test. Patch from #243 by Alexey + Borzenkov. + +=== 10.1.1 + +* Use http://github.com/jimweirich/rake instead of http://rake.rubyforge.org for + canonical project url. + +=== 10.1.0 + +==== Changes + +===== New Features + +* Add support for variable length task argument lists. If more actual + arguments are supplied than named arguments, then the extra + arguments values will be in args.extras. + +* Application name is not displayed in the help banner. (Previously + "rake" was hardcoded, now rake-based applications can display their + own names). + +===== Bug Fixes + +Bug fixes include: + +* Fix backtrace suppression issues. + +* Rules now explicit get task arguments passed to them. + +* Rename FileList#exclude? to FileList#exclude\_from\_list? to avoid + conflict with new Rails method. + +* Clean / Clobber tasks now report failure to remove files. + +* Plus heaps of internal code cleanup. + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. +The following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Michael Nikitochkin (general code cleanup) +* Vipul A M (general code cleanup) +* Dennis Bell (variable length task argument lists) +* Jacob Swanner (rules arguments) +* Rafael Rosa Fu (documentation typo) +* Stuart Nelson (install.rb fixes) +* Lee Hambley (application name in help banner) + +-- Jim Weirich + +=== 10.0.3 + + "Jim, when will Rake reach version 1.0?" + +Over the past several years I've been asked that question at +conferences, panels and over twitter. Due to historical reasons (or +maybe just plain laziness) Rake has (incorrectly) been treating the +second digit of the version as the major release number. So in my head +Rake was already at version 9. + +Well, it's time to fix things. This next version of Rake drops old, +crufty, backwards compatibility hacks such as top level constants, DSL +methods defined in Object and numerous other features that are just no +longer desired. It's also time to drop the leading zero from the +version number as well and call this new version of rake what it +really is: Version 10. + +So, welcome to Rake 10.0! + +Rake 10 is actually feature identical to the latest version of Rake 9 +(that would be the version spelled 0.9.3), *except* that Rake 10 drops +all the sundry deprecated features that have accumulated over the years. + +If your Rakefile is up to date and current with all the new features +of Rake 10, you are ready to go. If your Rakefile still uses a few +deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same +feature set. Just be aware that future features will be in Rake 10 +family line. + +==== Changes + +As mentioned above, there are no new features in Rake 10. However, +there are a number of features missing: + +* Classic namespaces are now gone. Rake is no longer able to reflect + the options settings in the global variables ($rakefile, $show\_tasks, + $show\_prereqs, $trace, $dryrun and $silent). The + --classic-namespace option is no longer supported. + +* Global constants are no longer supported. This includes + Task, FileTask, FileCreationTask and + RakeApp). The constant missing hook to warn about using + global rake constants has been removed. + +* The Rake DSL methods (task, file, directory, etc) are in their own + module (Rake::DSL). The stub versions of these methods (that printed + warnings) in Object have been removed. However, the DSL methods are + added to the top-level main object. Since main is + not in the inheritance tree, the presence of the DSL methods in main + should be low impact on other libraries. + + If you want to use the Rake DSL commands from your own code, just + include Rake::DSL into your own classes and modules. + +* The deprecated syntax for task arguments (the one using + :needs) has been removed. + +* The --reduce-compat flag has been removed (it's not needed + anymore). + +* The deprecated rake/sys.rb library has been removed. + +* The deprecated rake/rdoctask.rb library has been removed. + RDoc supplies its own rake task now. + +* The deprecated rake/gempackagetask.rb library has been + removed. Gem supplies its own package task now. + +There is one small behavioral change: + +* Non-file tasks now always report the current time as their time + stamp. This is different from the previous behavior where non-file + tasks reported current time only if there were no prerequisites, and + the max prerequisite timestamp otherwise. This lead to inconsistent + and surprising behavior when adding prerequisites to tasks that in + turn were prequisites to file tasks. The new behavior is more + consistent and predictable. + +==== Changes (from 0.9.3, 0.9.4, 0.9.5) + +Since Rake 10 includes the changes from the last version of Rake 9, +we'll repeat the changes for versions 0.9.3 through 0.9.5 here. + +===== New Features (in 0.9.3) + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --suppress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +===== Bug Fixes (in 0.9.3) + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + +===== Bug Fixes (in 0.9.4) + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +===== Bug Fixes (in 0.9.5) + +* --trace and --backtrace no longer swallow following task names. + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 10.0.2 + +==== Changes + +===== Bug Fixes + +* --trace and --backtrace no longer swallow following task names. + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 10.0.1 + +==== Changes + +===== Bug Fixes + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 10.0.0 + + "Jim, when will Rake reach version 1.0?" + +Over the past several years I've been asked that question at +conferences, panels and over twitter. Due to historical reasons (or +maybe just plain laziness) Rake has (incorrectly) been treating the +second digit of the version as the major release number. So in my head +Rake was already at version 9. + +Well, it's time to fix things. This next version of Rake drops old, +crufty, backwards compatibility hacks such as top level constants, DSL +methods defined in Object and numerous other features that are just no +longer desired. It's also time to drop the leading zero from the +version number as well and call this new version of rake what it +really is: Version 10. + +So, welcome to Rake 10.0! + +Rake 10 is actually feature identical to the latest version of Rake 9 +(that would be the version spelled 0.9.3), *except* that Rake 10 drops +all the sundry deprecated features that have accumulated over the years. + +If your Rakefile is up to date and current with all the new features +of Rake 10, you are ready to go. If your Rakefile still uses a few +deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same +feature set. Just be aware that future features will be in Rake 10 +family line. + +==== Changes in 10.0 + +As mentioned above, there are no new features in Rake 10. However, +there are a number of features missing: + +* Classic namespaces are now gone. Rake is no longer able to reflect + the options settings in the global variables ($rakefile, $show\_tasks, + $show\_prereqs, $trace, $dryrun and $silent). The + --classic-namespace option is no longer supported. + +* Global constants are no longer supported. This includes + Task, FileTask, FileCreationTask and + RakeApp). The constant missing hook to warn about using + global rake constants has been removed. + +* The Rake DSL methods (task, file, directory, etc) are in their own + module (Rake::DSL). The stub versions of these methods (that printed + warnings) in Object have been removed. However, the DSL methods are + added to the top-level main object. Since main is + not in the inheritance tree, the presence of the DSL methods in main + should be low impact on other libraries. + + If you want to use the Rake DSL commands from your own code, just + include Rake::DSL into your own classes and modules. + +* The deprecated syntax for task arguments (the one using + :needs) has been removed. + +* The --reduce-compat flag has been removed (it's not needed + anymore). + +* The deprecated rake/sys.rb library has been removed. + +* The deprecated rake/rdoctask.rb library has been removed. + RDoc supplies its own rake task now. + +* The deprecated rake/gempackagetask.rb library has been + removed. Gem supplies its own package task now. + +There is one small behavioral change: + +* Non-file tasks now always report the current time as their time + stamp. This is different from the previous behavior where non-file + tasks reported current time only if there were no prerequisites, and + the max prerequisite timestamp otherwise. This lead to inconsistent + and surprising behavior when adding prerequisites to tasks that in + turn were prequisites to file tasks. The new behavior is more + consistent and predictable. + +==== Changes (from 0.9.3) + +Since Rake 10 includes the changes from the last version of Rake 9, +we'll repeat the changes for version 0.9.3 here. + +===== New Features + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --suppress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +===== Bug Fixes + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.6 + +Rake version 0.9.6 contains a number of fixes mainly for merging +Rake into the Ruby source tree and fixing tests. + +==== Changes + +===== Bug Fixes (0.9.6) + +* Better trace output when using a multi-threaded Rakefile. +* Arg parsing is now consistent for tasks and multitasks. +* Skip exit code test in versions of Ruby that don't support it well. + +Changes for better integration with the Ruby source tree: + +* Fix version literal for Ruby source tree build. +* Better loading of libraries for testing in Ruby build. +* Use the ruby version provided by Ruby's tests. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.5 + +Rake version 0.9.5 contains a number of bug fixes. + +==== Changes + +===== Bug Fixes (0.9.5) + +* --trace and --backtrace no longer swallow following task names. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.4 + +Rake version 0.9.4 contains a number of bug fixes. + +==== Changes + +===== Bug Fixes (0.9.4) + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.3 + +Rake version 0.9.3 contains some new, backwards compatible features and +a number of bug fixes. + +==== Changes + +===== New Features + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --suppress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +===== Bug Fixes + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== Rake 0.9.2.2 + +Rake version 0.9.2.2 is mainly bug fixes. + +==== Changes + +* The rake test loader now removes arguments it has processed. Issue #51 +* Rake::TaskArguments now responds to #values\_at +* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7 +* Rake tests are now directory-independent +* Rake tests are no longer require flexmock +* Commands constant is no longer polluting top level namespace. +* Show only the interesting portion of the backtrace by default (James M. Lawrence). +* Added --reduce-compat option to remove backward compatible DSL hacks (James M. Lawrence). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + +=== 0.9.2 + +Rake version 0.9.2 has a few small fixes. See below for details. + +==== Changes + +* Support for Ruby 1.8.6 was fixed. +* Global DSL warnings now honor --no-deprecate + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + +=== 0.9.1 + +Rake version 0.9.1 has a number of bug fixes and enhancments (see +below for more details). Additionally, the internals have be slightly +restructured and improved. + +==== Changes + +Rake 0.9.1 adds back the global DSL methods, but with deprecation +messages. This allows Rake 0.9.1 to be used with older rakefiles with +warning messages. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + +=== 0.9.0 + +Rake version 0.9.0 has a number of bug fixes and enhancments (see +below for more details). Additionally, the internals have be slightly +restructured and improved. + +==== Changes + +===== New Features / Enhancements / Bug Fixes in Version 0.9.0 + +* Rake now warns when the deprecated :needs syntax used (and suggests + the proper syntax in the warning). + +* Moved Rake DSL commands to top level ruby object 'main'. Rake DSL + commands are no longer private methods in Object. (Suggested by + James M. Lawrence/quix) + +* Rake now uses case-insensitive comparisons to find the Rakefile on Windows. + Based on patch by Roger Pack. + +* Rake now requires (instead of loads) files in the test task. Patch by Cezary + Baginski. + +* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow. + +* Rake now prints the Rakefile directory only when it's different from the + current directory. Patch by Alex Chaffee. + +* Improved rakefile_location discovery on Windows. Patch by James Tucker. + +* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias + Lüdtke + +* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require + 'rdoc/task') + +* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require + 'rubygems/package\_task') + +* Rake now outputs various messages to $stderr instead of $stdout. + +* Rake no longer emits warnings for Config. Patch by Santiago Pastorino. + +* Removed Rake's DSL methods from the top level scope. If you need to + call 'task :xzy' in your code, include Rake::DSL into your class, or + put the code in a Rake::DSL.environment do ... end block. + +* Split rake.rb into individual files. + +* Support for the --where (-W) flag for showing where a task is defined. + +* Fixed quoting in test task. + (http://onestepback.org/redmine/issues/show/44, + http://www.pivotaltracker.com/story/show/1223138) + +* Fixed the silent option parsing problem. + (http://onestepback.org/redmine/issues/show/47) + +* Fixed :verbose=>false flag on sh and ruby commands. + +* Rake command line options may be given by default in a RAKEOPT + environment variable. + +* Errors in Rake will now display the task invocation chain in effect + at the time of the error. + +* Accepted change by warnickr to not expand test patterns in shell + (allowing more files in the test suite). + +* Fixed that file tasks did not perform prereq lookups in scope + (Redmine #57). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + + +=== 0.8.7 + +Rake version 0.8.5 introduced greatly improved support for executing +commands on Windows. The "sh" command now has the same semantics on +Windows that it has on Unix based platforms. + +Rake version 0.8.6 includes minor fixes the the RDoc generation. +Rake version 0.8.7 includes a minor fix for JRuby running on windows. + +==== Changes + +===== New Features / Enhancements in Version 0.8.5 + +* Improved implementation of the Rake system command for Windows. + (patch from James M. Lawrence/quix) + +* Support for Ruby 1.9's improved system command. (patch from James + M. Lawrence/quix) + +* Rake now includes the configured extension when invoking an + executable (Config::CONFIG['EXEEXT]) + +===== Bug Fixes in Version 0.8.5 + +* Environment variable keys are now correctly cased (it matters in + some implementations). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Charles Nutter + +-- Jim Weirich + +=== 0.8.6 + +Rake version 0.8.5 introduced greatly improved support for executing +commands on Windows. The "sh" command now has the same semantics on +Windows that it has on Unix based platforms. + +Rake version 0.8.5 includes minor fixes the the RDoc generation. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena + +-- Jim Weirich + +=== 0.8.5 + +Rake version 0.8.5 is a new release of Rake with greatly improved +support for executing commands on Windows. The "sh" command now has +the same semantics on Windows that it has on Unix based platforms. + +==== Changes + +===== New Features / Enhancements in Version 0.8.5 + +* Improved implementation of the Rake system command for Windows. + (patch from James M. Lawrence/quix) + +* Support for Ruby 1.9's improved system command. (patch from James + M. Lawrence/quix) + +* Rake now includes the configured extension when invoking an + executable (Config::CONFIG['EXEEXT]) + +===== Bug Fixes in Version 0.8.5 + +* Environment variable keys are now correctly cased (it matters in + some implementations). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena + +-- Jim Weirich + +=== 0.8.4 + +Rake version 0.8.4 is a bug-fix release of rake. + +NOTE: The version of Rake that comes with Ruby 1.9 has diverged + slightly from the core Rake code base. Rake 0.8.4 will work + with Ruby 1.9, but is not a strict upgrade for the Rake that + comes with Ruby 1.9. A (near) future release of Rake will unify + those two codebases. + +==== Letter Writing Campaign + +Thanks to Aaron Patterson (@tenderlove) and Eric Hodel (@drbrain) for +their encouraging support in organizing a letter writing campaign to +lobby for the "Warning Free" release of rake 0.8.4. A special callout +goes to Jonathan D. Lord, Sr (Dr. Wingnut) whose postcard was the +first to actually reach me. (see +http://tenderlovemaking.com/2009/02/26/we-need-a-new-version-of-rake/ +for details) + +==== Changes + +===== New Features / Enhancements in Version 0.8.4 + +* Case is preserved on rakefile names. (patch from James + M. Lawrence/quix) + +* Improved Rakefile case insensitivity testing (patch from Luis + Lavena). + +* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH, + APPDATA, USERPROFILE (patch from Luis Lavena) + +* MingGW is now recognized as a windows platform. (patch from Luis + Lavena) + +===== Bug Fixes in Version 0.8.4 + +* Removed reference to manage_gem to fix the warning produced by the + gem package task. + +* Fixed stray ARGV option problem that was interfering with + Test::Unit::Runner. (patch from Pivotal Labs) + +===== Infrastructure Improvements in Version 0.8.4 + +* Numerous fixes to the windows test suite (patch from Luis Lavena). + +* Improved Rakefile case insensitivity testing (patch from Luis + Lavena). + +* Better support for windows paths in the test task (patch from Simon + Chiang/bahuvrihi) + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena +* Pivotal Labs +* Simon Chiang/bahuvrihi + +-- Jim Weirich + +=== 0.8.3 + +Rake version 0.8.3 is a bug-fix release of rake. + +==== Changes + +===== Bug Fixes in Version 0.8.3 + +* Enhanced the system directory detection in windows. We now check + HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch + supplied by James Tucker). Rake no long aborts if it can't find the + directory. + +* Added fix to handle ruby installations in directories with spaces in + their name. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Edwin Pratomo +* Gavin Stark +* Adam Q. Salter +* Adam Majer +* Emanuel Indermühle +* Ittay Dror +* Bheeshmar Redheendran (for spending an afternoon with me debugging + windows issues) + +-- Jim Weirich + + +=== 0.8.2 + +Rake version 0.8.2 is a new release of rake that includes a number of +new features and numerous bug fixes. + +==== Changes + +===== New Features in Version 0.8.2 + +* Switched from getoptlong to optparse (patches supplied by Edwin + Pratomo). + +* The -T option will now attempt to dynamically sense the size of the + terminal. The -T output will only self-truncate if the output is a + tty. However, if RAKE_COLUMNS is explicitly set, it will be honored + in any case. (Patch provided by Gavin Stark). + +* The following public methods have been added to rake task objects: + + * task.clear -- Clear both the prerequisites and actions of the + target rake task. + * task.clear_prerequisites -- Clear all the existing prerequisites + from the target rake task. + * task.clear_actions -- Clear all the existing actions from the + target rake task. + * task.reenable -- Re-enable a task, allowing its actions to be + executed again if the task is invoked. + +* Changed RDoc test task to have no default template. This makes it + easier for the tempate to pick up the template from the environment. + +* Default values for task arguments can easily be specified with the + :with_defaults method. (Idea for default argument merging supplied + by (Adam Q. Salter) + +===== Bug Fixes in Version 0.8.2 + +* Fixed bug in package task so that it will include the subdir + directory in the package for testing. (Bug found by Adam Majer) + +* Fixed filename dependency order bug in test\_inspect\_pending and + test\_to\_s\_pending. (Bug found by Adam Majer) + +* Fixed check for file utils options to make them immune to the + symbol/string differences. (Patch supplied by Edwin Pratomo) + +* Fixed bug with rules involving multiple source, where only the first + dependency of a rule has any effect (Patch supplied by Emanuel + Indermühle) + +* FileList#clone and FileList#dup have better sematics w.r.t. taint + and freeze. + +* Changed from using Mutex to Monitor. Evidently Mutex causes thread + join errors when Ruby is compiled with -disable-pthreads. (Patch + supplied by Ittay Dror) + +* Fixed bug in makefile parser that had problems with extra spaces in + file task names. (Patch supplied by Ittay Dror) + +==== Other changes in Version 0.8.2 + +* Added ENV var to rake's own Rakefile to prevent OS X from including + extended attribute junk in the rake package tar file. (Bug found by + Adam Majer) + +* Added a performance patch for reading large makefile dependency + files. (Patch supplied by Ittay Dror) + +==== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.2] + +And the string "0.8.2" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +===== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the parameters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Edwin Pratomo +* Gavin Stark +* Adam Q. Salter +* Adam Majer +* Emanuel Indermühle +* Ittay Dror +* Bheeshmar Redheendran (for spending an afternoon with me debugging + windows issues) + +-- Jim Weirich + +=== 0.8.0/0.8.1 + +Rake version 0.8.0 is a new release of rake that includes serveral new +features. + +==== Changes + +===== New Features in Version 0.8.0 + +* Tasks can now receive command line parameters. See the examples + below for more details. + +* Comments are limited to 80 columns on output, but full comments can + be seen by using the -D parameter. (feature suggested by Jamis + Buck). + +* Explicit exit(n) calls will now set the exit status to n. (patch + provided by Stephen Touset). + +* Rake is now compatible with Ruby 1.9. + +Version 0.8.1 is a minor update that includes additional Ruby 1.9 +compatibility fixes. + +==== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.0] + +And the string "0.8.0" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +===== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the parameters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Jamis Buck (for comment formatting suggestions) +* Stephen Touset (for exit status patch). + +-- Jim Weirich + + +=== 0.7.3 + +Rake version 0.7.3 is a minor release that includes some refactoring to better +support custom Rake applications. + +==== Changes + +===== New Features in Version 0.7.3 + +* Added the +init+ and +top_level+ methods to make the creation of custom Rake applications a bit easier. E.g. + + gem 'rake', ">= 0.7.3" + require 'rake' + + Rake.application.init('myrake') + + task :default do + something_interesting + end + + Rake.application.top_level + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +-- Jim Weirich + + +=== 0.7.2 + + +Version 0.7.2 supplies a bug fix and a few minor enhancements. In +particular, the new version fixes an incompatibility with the soon to +be released Ruby 1.8.6. We strongly recommend upgrading to Rake 0.7.2 +in order to be compatible with the new version of Ruby. + +==== Changes + +===== Bug Fixes in 0.7.2 + +There are quite a number of bug fixes in the new 0.7.2 version of +Rake: + +* Removed dependency on internal fu_xxx functions from FileUtils. + +* Error messages are now send to stderr rather than stdout (from + Payton Quackenbush). + +* Better error handling on invalid command line arguments (from Payton + Quackenbush). + +* Fixed some bugs where the application object was going to the global + appliation instead of using its own data. + +* Fixed the method name leak from FileUtils (bug found by Glenn + Vanderburg). + +* Added test for noop, bad_option and verbose flags to sh command. + +* Added a description to the gem task in GemPackageTask. + +* Fixed a bug when rules have multiple prerequisites (patch by Joel + VanderWerf) + +* Added the handful of RakeFileUtils to the private method as well. + +===== New Features in 0.7.2 + +The following new features are available in Rake version 0.7.2: + +* Added square and curly bracket patterns to FileList#include (Tilman + Sauerbeck). + +* FileLists can now pass a block to FileList#exclude to exclude files + based on calculated values. + +* Added plain filename support to rule dependents (suggested by Nobu + Nakada). + +* Added pathmap support to rule dependents. In other words, if a + pathmap format (beginning with a '%') is given as a Rake rule + dependent, then the name of the depend will be the name of the + target with the pathmap format applied. + +* Added a 'tasks' method to a namespace to get a list of tasks + associated with the namespace. + +* Added tar_command and zip_command options to the Package task. + +* The clean task will no longer delete 'core' if it is a directory. + +===== Internal Rake Improvements + +The following changes will are mainly internal improvements and +refactorings and have little effect on the end user. But they may be +of interest to the general public. + +* Added rcov task and updated unit testing for better code coverage. + +* Added a 'shame' task to the Rakefile. + +* Added rake_extension to handle detection of extension collisions. + +* Added a protected 'require "rubygems"' to test/test_application to + unbreak cruisecontrol.rb. + +* Removed rake\_dup. Now we just simply rescue a bad dup. + +* Refactored the FileList reject logic to remove duplication. + +* Removed if \_\_FILE\_\_ at the end of the rake.rb file. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Payton Quackenbush -- For several error handling improvements. + +* Glenn Vanderburg -- For finding and fixing the method name leak from + FileUtils. + +* Joel VanderWerf -- for finding and fixing a bug in the handling of + multiple prerequisites. + +* Tilman Sauerbeck -- For some enhancing FileList to support more + advanced file globbing. + +* Nobu Nakada -- For suggesting plain file name support to rule dependents. + +-- Jim Weirich + +=== 0.7.1 + +Version 0.7.1 supplies a bug fix and a few minor enhancements. + +==== Changes + +===== Bug Fixes in 0.7.1 + +* Changes in the exception reported for the FileUtils.ln caused + safe_ln to fail with a NotImplementedError. Rake 0.7.1 will now + catch that error or any StandardError and properly fall back to + using +cp+. + +===== New Features in 0.7.1 + +* You can filter the results of the --task option by supplying an + optional regular expression. This allows the user to easily find a + particular task name in a long list of possible names. + +* Transforming procs in a rule may now return a list of prerequisites. + This allows more flexible rule formation. + +* FileList and String now support a +pathmap+ melthod that makes the + transforming paths a bit easier. See the API docs for +pathmap+ for + details. + +* The -f option without a value will disable the search for a + Rakefile. This allows the Rakefile to be defined entirely in a + library (and loaded with the -r option). The current working + directory is not changed when this is done. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* James Britt and Assaph Mehr for reporting and helping to debug the + safe_ln issue. + +-- Jim Weirich + + +=== 0.7.0 + +These changes for Rake have been brewing for a long time. Here they +are, I hope you enjoy them. + +==== Changes + +===== New Features + +* Name space support for task names (see below). +* Prerequisites can be executed in parallel (see below). +* Added safe_ln support for openAFS (via Ludvig Omholt). +* RDoc defaults to internal (in-process) invocation. The old behavior + is still available by setting the +external+ flag to true. +* Rakefiles are now loaded with the expanded path to prevent + accidental pollution from the Ruby load path. +* Task objects my now be used in prerequisite lists directly. +* Task objects (in addition to task names) may now be included in the + prerequisite list of a task. +* Internals cleanup and refactoring. + +===== Bug Fixes + +* Compatibility fixes for Ruby 1.8.4 FileUtils changes. + +===== Namespaces + +Tasks can now be nested inside their own namespaces. Tasks within one +namespace will not accidentally interfer with tasks named in a different +namespace. + +For example: + + namespace "main" do + task :build do + # Build the main program + end + end + + namespace "samples" do + task :build do + # Build the sample programs + end + end + + task :build_all => ["main:build", "samples:build"] + +Even though both tasks are named :build, they are separate tasks in +their own namespaces. The :build_all task (defined in the toplevel +namespace) references both build tasks in its prerequisites. + +You may invoke each of the individual build tasks with the following +commands: + + rake main:build + rake samples:build + +Or invoke both via the :build_all command: + + rake build_all + +Namespaces may be nested arbitrarily. Since the name of file tasks +correspond to the name of a file in the external file system, +FileTasks are not affected by the namespaces. + +See the Rakefile format documentation (in the Rake API documents) for +more information. + +===== Parallel Tasks + +Sometimes you have several tasks that can be executed in parallel. By +specifying these tasks as prerequisites to a +multitask+ task. + +In the following example the tasks copy\_src, copy\_doc and copy\_bin +will all execute in parallel in their own thread. + + multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do + puts "All Copies Complete" + end + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Doug Young (inspiration for the parallel task) +* David Heinemeier Hansson (for --trace message enhancement and for + pushing for namespace support). +* Ludvig Omholt (for the openAFS fix) + +-- Jim Weirich + +=== 0.6.1 + +* Rebuilt 0.6.0 gem without signing. + +=== 0.6.0 + +Its time for some long requested enhancements and lots of bug fixes +... And a whole new web page. + +==== New Web Page + +The primary documentation for rake has moved from the RubyForge based +wiki to its own Hieraki based web site. Constant spam on the wiki +made it a difficult to keep clean. The new site will be easier to +update and organize. + +Check out the new documentation at: http://docs.rubyrake.org + +We will be adding new documentation to the site as time goes on. + +In addition to the new docs page, make sure you check out Martin +Fowlers article on rake at http://martinfowler.com/articles/rake.html + +==== Changes + +===== New Features + +* Multiple prerequisites on Rake rules now allowed. However, keep the + following in mind: + + 1. All the prerequisites of a rule must be available before a rule + is triggered, where "enabled" means (a) an existing file, (b) a + defined rule, or (c) another rule which also must be + trigger-able. + 2. Rules are checked in order of definition, so it is important to + order your rules properly. If a file can be created by two + different rules, put the more specific rule first (otherwise the + more general rule will trigger first and the specific one will + never be triggered). + 3. The source method now returns the name of the first + prerequisite listed in the rule. sources returns the + names of all the rule prerequisites, ordered as they are defined + in the rule. If the task has other prerequisites not defined in + the rule (but defined in an explicit task definition), then they + will _not_ be included in the sources list. + +* FileLists may now use the egrep command. This popular enhancement + is now a core part of the FileList object. If you want to get a + list of all your to-dos, fixmes and TBD comments, add the following + to your Rakefile. + + desc "Look for TODO and FIXME tags in the code" + task :todo do + FileList['**/*.rb'].egrep /#.*(FIXME|TODO|TBD)/ + end + +* The investigation method was added to task object to dump + out some important values. This makes it a bit easier to debug Rake + tasks. + + For example, if you are having problems with a particular task, just + print it out: + + task :huh do + puts Rake::Task['huh'].investigation + end + +* The Rake::TestTask class now supports a "ruby\_opts" option to pass + arbitrary ruby options to a test subprocess. + +===== Some Incompatibilities + +* When using the ruby command to start a Ruby subprocess, the + Ruby interpreter that is currently running rake is used by default. + This makes it easier to use rake in an environment with multiple + ruby installation. (Previously, the first ruby command found in the + PATH was used). + + If you wish to chose a different Ruby interpreter, you can + explicitly choose the interpreter via the sh command. + +* The major rake classes (Task, FileTask, FileCreationTask, RakeApp) + have been moved out of the toplevel scope and are now accessible as + Rake::Task, Rake::FileTask, Rake::FileCreationTask and + Rake::Application. If your Rakefile + directly references any one of these tasks, you may: + + 1. Update your Rakefile to use the new classnames + 2. Use the --classic-namespace option on the rake command to get the + old behavior, + 3. Add require 'rake/classic_namespace' to the + Rakefile to get the old behavior. + + rake will print a rather annoying warning whenever a + deprecated class name is referenced without enabling classic + namespace. + +===== Bug Fixes + +* Several unit tests and functional tests were fixed to run better + under windows. + +* Directory tasks are now a specialized version of a File task. A + directory task will only be triggered if it doesn't exist. It will + not be triggered if it is out of date w.r.t. any of its + prerequisites. + +* Fixed a bug in the Rake::GemPackageTask class so that the gem now + properly contains the platform name. + +* Fixed a bug where a prerequisite on a file task would cause + an exception if the prerequisite did not exist. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Greg Fast (better ruby_opt test options) +* Kelly Felkins (requested by better namespace support) +* Martin Fowler (suggested Task.investigation) +* Stuart Jansen (send initial patch for multiple prerequisites). +* Masao Mutch (better support for non-ruby Gem platforms) +* Philipp Neubeck (patch for file task exception fix) + +-- Jim Weirich + +=== 0.5.4 + +Time for some minor bug fixes and small enhancements + +==== Changes + +Here are the changes for version 0.5.4 ... + +* Added double quotes to the test runner. This allows the location of + the tests (and runner) to be in a directory path that contains + spaces (e.g. "C:/Program Files/ruby/bin"). +* Added .svn to default ignore list. Now subversion project metadata + is automatically ignored by Rake's FileList. +* Updated FileList#include to support nested arrays and filelists. + FileLists are flat lists of file names. Using a FileList in an + include will flatten out the nested file names. + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +Thanks to ... + +* Tilman Sauerbeck for the nested FileList suggestion. +* Josh Knowles for pointing out the spaces in directory name problem. + +-- Jim Weirich + +=== 0.5.3 + +Although it has only been two weeks since the last release, we have +enough updates to the Rake program to make it time for another +release. + +==== Changes + +Here are the changes for version 0.5.3 ... + +* FileLists have been extensively changed so that they mimic the + behavior of real arrays even more closely. In particular, + operations on FileLists that return a new collection (e.g. collect, + reject) will now return a FileList rather than an array. In + addition, several places where FileLists were not properly expanded + before use have been fixed. +* A method (+ext+) to simplify the handling of file extensions was + added to String and to Array. +* The 'testrb' script in test/unit tends to silently swallow syntax + errors in test suites. Because of that, the default test loader is + now a rake-provided script. You can still use 'testrb' by setting + the loader flag in the test task to :testrb. (See the API documents + for TestTask for all the loader flag values). +* FileUtil methods (e.g. cp, mv, install) are now declared to be + private. This will cut down on the interference with user defined + methods of the same name. +* Fixed the verbose flag in the TestTask so that the test code is + controlled by the flag. Also shortened up some failure messages. + (Thanks to Tobias Luetke for the suggestion). +* Rules will now properly detect a task that can generate a source + file. Previously rules would only consider source files that were + already present. +* Added an +import+ command that allows Rake to dynamically import + dependendencies into a running Rake session. The +import+ command + can run tasks to update the dependency file before loading them. + Dependency files can be in rake or make format, allowing rake to + work with tools designed to generate dependencies for make. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +Thanks to ... + +* Brian Gernhardt for the rules fix (especially for the patience to + explain the problem to me until I got what he was talking about). +* Stefan Lang for pointing out problems in the dark corners of the + FileList implementation. +* Alexey Verkhovsky pointing out the silently swallows syntax errors + in tests. +* Tobias Luetke for beautifying the test task output. +* Sam Roberts for some of the ideas behind dependency loading. + +-- Jim Weirich + + +=== 0.5.0 + +It has been a long time in coming, but we finally have a new version +of Rake available. + +==== Changes + +* Fixed documentation that was lacking the Rake module name (Tilman + Sauerbeck). +* Added tar.gz and tar.bz2 support to package task (Tilman Sauerbeck). +* Recursive rules are now supported (Tilman Sauerbeck). +* Added warning option for the Test Task (requested by Eric Hodel). +* The jamis rdoc template is only used if it exists. +* Added fix for Ruby 1.8.2 test/unit and rails problem. +* Added contributed rake man file (Jani Monoses). +* Added Brian Candler's fix for problems in --trace and --dry-run + mode. + +==== Thanks + +Lots of people provided input to this release. Thanks to Tilman +Sauerbeck for numerous patches, documentation fixes and suggestions. +And for also pushing me to get this release out. Also, thanks to +Brian Candler for the finding and fixing --trace/dry-run fix. That +was an obscure bug. Also to Eric Hodel for some good suggestions. + +-- Jim Weirich + +=== 0.4.15 + +==== Changes + +Version 0.4.15 is a bug fix update for the Ruby 1.8.2 compatibility +changes. This release includes: + +* Fixed a bug that prevented the TESTOPTS flag from working with the + revised for 1.8.2 test task. +* Updated the docs on --trace to indicate that it also enables a full + backtrace on errors. +* Several fixes for new warnings generated. + +==== Mini-Roadmap + +I will continue to issue Rake updates in the 0.4.xx series as new +Ruby-1.8.2 issues become manifest. Once the codebase stabilizes, I +will release a 0.5.0 version incorporating all the changes. If you +are not using Ruby-1.8.2 and wish to avoid version churn, I recommend +staying with a release prior to Rake-0.4.14. + +=== 0.4.14 + +Version 0.4.14 is a compatibility fix to allow Rake's test task to +work under Ruby 1.8.2. A change in the Test::Unit autorun feature +prevented Rake from running any tests. This release fixes the +problem. + +Rake 0.4.14 is the recommended release for anyone using Ruby 1.8.2. + +=== 0.4.13 + +* Fixed the dry-run flag so it is operating again. +* Multiple arguments to sh and ruby commands will not be interpreted + by the shell (patch provided by Jonathan Paisley). + +=== 0.4.12 + +* Added --silent (-s) to suppress the (in directory) rake message. + +=== 0.4.11 + +* Changed the "don't know how to rake" message (finally) +* Changes references to a literal "Rakefile" to reference the global + variable $rakefile (which contains the actual name of the rakefile). + +=== 0.4.10 + +* Added block support to the "sh" command, allowing users to take + special actions on the result of the system call. E.g. + + sh "shell_command" do |ok, res| + puts "Program returned #{res.exitstatus}" if ! ok + end + +=== 0.4.9 + +* Switched to Jamis Buck's RDoc template. +* Removed autorequire from Rake's gem spec. This prevents the Rake + libraries from loading while using rails. + +=== 0.4.8 + +* Added support for .rb versions of Rakefile. +* Removed \\\n's from test task. +* Fixed Ruby 1.9 compatibility issue with FileList. + +=== 0.4.7 + +* Fixed problem in FileList that caused Ruby 1.9 to go into infinite + recursion. Since to_a was removed from Object, it does not need to + added back into the list of methods to rewrite in FileList. (Thanks + to Kent Sibilev for pointing this out). + +=== 0.4.6 +* Removed test version of ln in FileUtils that prevented safe_ln from + using ln. + +=== 0.4.5 +* Upgraded comments in TestTask. +* FileList to_s and inspect now automatically resolve pending changes. +* FileList#exclude properly returns the FileList. + +=== 0.4.4 +* Fixed initialization problem with @comment. +* Now using multi -r technique in TestTask. Switch Rakefile back to + using the built-in test task macros because the rake runtime is no + longer needed. +* Added 'TEST=filename' and 'TESTOPTS=options' to the Test Task + macros. +* Allow a +test_files+ attribute in test tasks. This allows more + flexibility in specifying test files. + +=== 0.4.3 +* Fixed Comment leakage. + +=== 0.4.2 +* Added safe_ln that falls back to a copy if a file link is not supported. +* Package builder now uses safe\_ln. + +=== 0.4.1 +* Task comments are now additive, combined with "/". +* Works with (soon to be released) rubygems 0.6.2 (or 0.7.0) + +=== 0.4.0 +* FileList now uses deferred loading. The file system is not searched + until the first call that needs the file names. +* VAR=VALUE options are now accepted on the command line and are + treated like environment variables. The values may be tested in a + Rakefile by referencing ENV['VAR']. +* File.mtime is now used (instead of File.new().mtime). + +=== 0.3.2.x + +* Removed some hidden dependencies on rubygems. Tests now will test + gems only if they are installed. +* Removed Sys from some example files. I believe that is that last + reference to Sys outside of the contrib area. +* Updated all copyright notices to include 2004. + +=== 0.3.2 + +* GEM Installation now works with the application stub. + +=== 0.3.1 + +* FileLists now automatically ignore CVS, .bak, ! +* GEM Installation now works. + +=== 0.3.0 + +Promoted 0.2.10. + +=== 0.2.10 +General + +* Added title to Rake's rdocs +* Contrib packages are no longer included in the documentation. + +RDoc Issues + +* Removed default for the '--main' option +* Fixed rendering of the rdoc options +* Fixed clean/clobber confusion with rerdoc +* 'title' attribute added + +Package Task Library Issues + +* Version (or explicit :noversion) is required. +* +package_file+ attribute is now writable + +FileList Issues + +* Dropped bang version of exclude. Now using ant-like include/exclude semantics. +* Enabled the "yield self" idiom in FileList#initialize. + +=== 0.2.9 + +This version contains numerous changes as the RubyConf.new(2003) +presentation was being prepared. The changes include: + +* The monolithic rubyapp task library is in the process of being + dropped in favor of lighter weight task libraries. + +=== 0.2.7 + +* Added "desc" for task descriptions. +* -T will now display tasks with descriptions. +* -P will display tasks and prerequisites. +* Dropped the Sys module in favor of the 1.8.x FileUtils module. Sys + is still supported in the contrib area. + +=== 0.2.6 + +* Moved to RubyForge + +=== 0.2.5 + +* Switched to standard ruby app builder. +* Added no_match option to file matcher. + +=== 0.2.4 + +* Fixed indir, which neglected to actually change directories. + +=== 0.2.3 + +* Added rake module for a help target +* Added 'for\_files' to Sys +* Added a $rakefile constant +* Added test for selecting proper rule with multiple targets. diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/MIT-LICENSE b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/MIT-LICENSE new file mode 100644 index 0000000..4292f3b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/MIT-LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Jim Weirich + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/README.rdoc b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/README.rdoc new file mode 100644 index 0000000..3fc72db --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/README.rdoc @@ -0,0 +1,155 @@ += RAKE -- Ruby Make + +home :: https://github.com/ruby/rake +bugs :: https://github.com/ruby/rake/issues +docs :: https://ruby.github.io/rake + +== Description + +Rake is a Make-like program implemented in Ruby. Tasks and dependencies are +specified in standard Ruby syntax. + +Rake has the following features: + +* Rakefiles (rake's version of Makefiles) are completely defined in + standard Ruby syntax. No XML files to edit. No quirky Makefile + syntax to worry about (is that a tab or a space?) + +* Users can specify tasks with prerequisites. + +* Rake supports rule patterns to synthesize implicit tasks. + +* Flexible FileLists that act like arrays but know about manipulating + file names and paths. + +* A library of prepackaged tasks to make building rakefiles easier. For example, + tasks for building tarballs. (Formerly + tasks for building RDoc, Gems, and publishing to FTP were included in rake but they're now + available in RDoc, RubyGems, and rake-contrib respectively.) + +* Supports parallel execution of tasks. + +== Installation + +=== Gem Installation + +Download and install rake with the following. + + gem install rake + +== Usage + +=== Simple Example + +First, you must write a "Rakefile" file which contains the build rules. Here's +a simple example: + + task default: %w[test] + + task :test do + ruby "test/unittest.rb" + end + +This Rakefile has two tasks: + +* A task named "test", which -- upon invocation -- will run a unit test file + in Ruby. +* A task named "default". This task does nothing by itself, but it has exactly + one dependency, namely the "test" task. Invoking the "default" task will + cause Rake to invoke the "test" task as well. + +Running the "rake" command without any options will cause it to run the +"default" task in the Rakefile: + + % ls + Rakefile test/ + % rake + (in /home/some_user/Projects/rake) + ruby test/unittest.rb + ....unit test output here... + +Type "rake --help" for all available options. + +== Resources + +=== Rake Information + +* {Rake command-line}[link:doc/command_line_usage.rdoc] +* {Writing Rakefiles}[link:doc/rakefile.rdoc] +* The original {Rake announcement}[link:doc/rational.rdoc] +* Rake {glossary}[link:doc/glossary.rdoc] + +=== Presentations and Articles about Rake + +* Avdi Grimm's rake series: + 1. {Rake Basics}[https://avdi.codes/rake-part-1-basics/] + 2. {Rake File Lists}[https://avdi.codes/rake-part-2-file-lists-2/] + 3. {Rake Rules}[https://avdi.codes/rake-part-3-rules/] + 4. {Rake Pathmap}[https://avdi.codes/rake-part-4-pathmap/] + 5. {File Operations}[https://avdi.codes/rake-part-5-file-operations/] + 6. {Clean and Clobber}[https://avdi.codes/rake-part-6-clean-and-clobber/] + 7. {MultiTask}[https://avdi.codes/rake-part-7-multitask/] +* {Jim Weirich's 2003 RubyConf presentation}[https://web.archive.org/web/20140221123354/http://onestepback.org/articles/buildingwithrake/] +* Martin Fowler's article on Rake: https://martinfowler.com/articles/rake.html + +== Other Make Re-envisionings ... + +Rake is a late entry in the make replacement field. Here are links to +other projects with similar (and not so similar) goals. + +* https://directory.fsf.org/wiki/Bras -- Bras, one of earliest + implementations of "make in a scripting language". +* http://www.a-a-p.org -- Make in Python +* https://ant.apache.org -- The Ant project +* https://search.cpan.org/search?query=PerlBuildSystem -- The Perl Build System +* https://www.rubydoc.info/gems/rant/0.5.7/frames -- Rant, another Ruby make tool. + +== Credits + +[Jim Weirich] Who originally created Rake. + +[Ryan Dlugosz] For the initial conversation that sparked Rake. + +[Nobuyoshi Nakada ] For the initial patch for rule support. + +[Tilman Sauerbeck ] For the recursive rule patch. + +[Eric Hodel] For aid in maintaining rake. + +[Hiroshi SHIBATA] Maintainer of Rake 10 and later + +== License + +Rake is available under an MIT-style license. + +:include: MIT-LICENSE + +--- + += Other stuff + +Author:: Jim Weirich +Requires:: Ruby 2.0.0 or later +License:: Copyright Jim Weirich. + Released under an MIT-style license. See the MIT-LICENSE + file included in the distribution. + +== Warranty + +This software is provided "as is" and without any express or implied +warranties, including, without limitation, the implied warranties of +merchantability and fitness for a particular purpose. + +== Historical + +Rake was originally created by Jim Weirich, who unfortunately passed away in +February 2014. This repository was originally hosted at +{github.com/jimweirich/rake}[https://github.com/jimweirich/rake/], however +with his passing, has been moved to {ruby/rake}[https://github.com/ruby/rake]. + +You can view Jim's last commit here: +https://github.com/jimweirich/rake/tree/336559f28f55bce418e2ebcc0a57548dcbac4025 + +You can {read more about Jim}[https://en.wikipedia.org/wiki/Jim_Weirich] at Wikipedia. + +Thank you for this great tool, Jim. We'll remember you. diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/command_line_usage.rdoc b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/command_line_usage.rdoc new file mode 100644 index 0000000..105d6c8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/command_line_usage.rdoc @@ -0,0 +1,158 @@ += Rake Command Line Usage + +Rake is invoked from the command line using: + + % rake [options ...] [VAR=VALUE ...] [targets ...] + +Options are: + +[name=value] + Set the environment variable name to value + during the execution of the rake command. You can access + the value by using ENV['name']. + +[--all (-A)] + Used in combination with the -T and -D options, will force + those options to show all the tasks, even the ones without comments. + +[--backtrace{=_output_} (-n)] + Enable a full backtrace (i.e. like --trace, but without the task + tracing details). The _output_ parameter is optional, but if + specified it controls where the backtrace output is sent. If + _output_ is stdout, then backtrace output is directed to + standard output. If _output_ is stderr, or if it is + missing, then the backtrace output is sent to standard error. + +[--comments] + Used in combination with the -W options to force the output to + contain commented options only. This is the reverse of + --all. + +[--describe _pattern_ (-D)] + Describe the tasks (matching optional PATTERN), then exit. + +[--dry-run (-n)] + Do a dry run. Print the tasks invoked and executed, but do not + actually execute any of the actions. + +[--execute _code_ (-e)] + Execute some Ruby code and exit. + +[--execute-print _code_ (-p)] + Execute some Ruby code, print the result, and exit. + +[--execute-continue _code_ (-E)] + Execute some Ruby code, then continue with normal task processing. + +[--help (-H)] + Display some help text and exit. + +[--jobs _number_ (-j)] + + Specifies the maximum number of concurrent threads allowed. Rake + will allocate threads as needed up to this maximum number. + + If omitted, Rake will attempt to estimate the number of CPUs on + the system and add 4 to that number. + + The concurrent threads are used to execute the multitask + prerequisites. Also see the -m option which turns all + tasks into multitasks. + + Sample values: + (no -j) : Allow up to (# of CPUs + 4) number of threads + --jobs : Allow unlimited number of threads + --jobs=1 : Allow only one thread (the main thread) + --jobs=16 : Allow up to 16 concurrent threads + +[--job-stats _level_] + + Display job statistics at the completion of the run. By default, + this will display the requested number of active threads (from the + -j options) and the maximum number of threads in play at any given + time. + + If the optional _level_ is history, then a complete trace + of task history will be displayed on standard output. + +[--libdir _directory_ (-I)] + Add _directory_ to the list of directories searched for require. + +[--multitask (-m)] + Treat all tasks as multitasks. ('make/drake' semantics) + +[--nosearch (-N)] + Do not search for a Rakefile in parent directories. + +[--prereqs (-P)] + Display a list of all tasks and their immediate prerequisites. + +[--quiet (-q)] + Do not echo commands from FileUtils. + +[--rakefile _filename_ (-f)] + Use _filename_ as the name of the rakefile. The default rakefile + names are +rakefile+ and +Rakefile+ (with +rakefile+ taking + precedence). If the rakefile is not found in the current + directory, +rake+ will search parent directories for a match. The + directory where the Rakefile is found will become the current + directory for the actions executed in the Rakefile. + +[--rakelibdir _rakelibdir_ (-R)] + Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib') + +[--require _name_ (-r)] + Require _name_ before executing the Rakefile. + +[--rules] + Trace the rules resolution. + +[--silent (-s)] + Like --quiet, but also suppresses the 'in directory' announcement. + +[--suppress-backtrace _pattern_ ] + Line matching the regular expression _pattern_ will be removed + from the backtrace output. Note that the --backtrace option is the + full backtrace without these lines suppressed. + +[--system (-g)] + Use the system wide (global) rakefiles. The project Rakefile is + ignored. By default, the system wide rakefiles are used only if no + project Rakefile is found. On Unix-like system, the system wide + rake files are located in $HOME/.rake. On a windows system they + are stored in $APPDATA/Rake. + +[--no-system (-G)] + Use the project level Rakefile, ignoring the system-wide (global) + rakefiles. + +[--tasks pattern (-T)] + Display a list of the major tasks and their comments. Comments + are defined using the "desc" command. If a pattern is given, then + only tasks matching the pattern are displayed. + +[--trace{=_output_} (-t)] + Turn on invoke/execute tracing. Also enable full backtrace on + errors. The _output_ parameter is optional, but if specified it + controls where the trace output is sent. If _output_ is + stdout, then trace output is directed to standard output. + If _output_ is stderr, or if it is missing, then trace + output is sent to standard error. + +[--verbose (-v)] + Echo the Sys commands to standard output. + +[--version (-V)] + Display the program version and exit. + +[--where pattern (-W)] + Display tasks that match pattern and the file and line + number where the task is defined. By default this option will + display all tasks, not just the tasks that have descriptions. + +[--no-deprecation-warnings (-X)] + Do not display the deprecation warnings. + +In addition, any command line option of the form +VAR=VALUE will be added to the environment hash +ENV and may be tested in the Rakefile. diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/Rakefile1 b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/Rakefile1 new file mode 100644 index 0000000..39f8bcc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/Rakefile1 @@ -0,0 +1,38 @@ +# Example Rakefile -*- ruby -*- + +task :default => [:main] + +file "a.o" => ["a.c"] do |t| + src = t.name.sub(/\.o$/, '.c') + sh "gcc #{src} -c -o #{t.name}" +end + +file "b.o" => ["b.c"] do |t| + src = t.name.sub(/\.o$/, '.c') + sh "gcc #{src} -c -o #{t.name}" +end + +file "main.o" => ["main.c"] do |t| + src = t.name.sub(/\.o$/, '.c') + sh "gcc #{src} -c -o #{t.name}" +end + +OBJFILES = ["a.o", "b.o", "main.o"] +task :obj => OBJFILES + +file "main" => OBJFILES do |t| + sh "gcc -o #{t.name} main.o a.o b.o" +end + +task :clean do + rm_f FileList['*.o'] + Dir['*~'].each { |fn| rm_f fn } +end + +task :clobber => [:clean] do + rm_f "main" +end + +task :run => ["main"] do + sh "./main" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/Rakefile2 b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/Rakefile2 new file mode 100644 index 0000000..35310ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/Rakefile2 @@ -0,0 +1,35 @@ +# Example Rakefile -*- ruby -*- +# Using the power of Ruby + +task :default => [:main] + +def ext(fn, newext) + fn.sub(/\.[^.]+$/, newext) +end + +SRCFILES = Dir['*.c'] +OBJFILES = SRCFILES.collect { |fn| ext(fn,".o") } + +OBJFILES.each do |objfile| + srcfile = ext(objfile, ".c") + file objfile => [srcfile] do |t| + sh "gcc #{srcfile} -c -o #{t.name}" + end +end + +file "main" => OBJFILES do |t| + sh "gcc -o #{t.name} main.o a.o b.o" +end + +task :clean do + rm_f FileList['*.o'] + Dir['*~'].each { |fn| rm_f fn } +end + +task :clobber => [:clean] do + rm_f "main" +end + +task :run => ["main"] do + sh "./main" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/a.c b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/a.c new file mode 100644 index 0000000..620e6f8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/a.c @@ -0,0 +1,6 @@ +#include + +void a() +{ + printf ("In function a\n"); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/b.c b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/b.c new file mode 100644 index 0000000..9b24aa1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/b.c @@ -0,0 +1,6 @@ +#include + +void b() +{ + printf ("In function b\n"); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/main.c b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/main.c new file mode 100644 index 0000000..a04558a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/example/main.c @@ -0,0 +1,11 @@ +#include + +extern void a(); +extern void b(); + +int main () +{ + a(); + b(); + return 0; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/glossary.rdoc b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/glossary.rdoc new file mode 100644 index 0000000..9d592b0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/glossary.rdoc @@ -0,0 +1,42 @@ += Glossary + +action :: + Code to be executed in order to perform a task. Actions in a Rakefile are + specified in a code block. (Usually delimited by +do+/+end+ pairs.) + +execute :: + When a task is executed, all of its actions are performed in the order they + were defined. Note that, unlike invoke, execute always + executes the actions (without invoking or executing the prerequisites). + +file task (Rake::FileTask) :: + A file task is a task whose purpose is to create a file (which has the same + name as the task). When invoked, a file task will only execute if one or + more of the following conditions are true. + + 1. The associated file does not exist. + 2. A prerequisite has a later time stamp than the existing file. + + Because normal Tasks always have the current time as timestamp, a FileTask + that has a normal Task prerequisite will always execute. + +invoke :: + When a task is invoked, first we check to see if it has been invoked before. + If it has been, then nothing else is done. If this is the first time it has + been invoked, then we invoke each of its prerequisites. Finally, we check + to see if we need to execute the actions of this task by calling + Rake::Task#needed?. If the task is needed, we execute its actions. + + NOTE: Prerequisites are still invoked even if the task is not needed. + +prerequisites :: + Every task has a (possibly empty) set of prerequisites. A prerequisite P to + Task T is itself a task that must be invoked before Task T. + +rule :: + A rule is a recipe for synthesizing a task when no task is explicitly + defined. Rules generally synthesize file tasks. + +task (Rake::Task) :: + The basic unit of work in a Rakefile. A task has a name, a set of + prerequisites, and a list of actions to be performed. diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/jamis.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/jamis.rb new file mode 100644 index 0000000..531aa75 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/jamis.rb @@ -0,0 +1,592 @@ +# frozen_string_literal: true +module RDoc +module Page + +FONTS = "\"Bitstream Vera Sans\", Verdana, Arial, Helvetica, sans-serif" + +STYLE = < pre { + padding: 0.5em; + border: 1px dotted black; + background: #FFE; +} + +CSS + +XHTML_PREAMBLE = %{ + +} + +HEADER = XHTML_PREAMBLE + < + + %title% + + + + + + + +ENDHEADER + +FILE_PAGE = < + + + + +
File
%short_name%
+ + + + + + + + + +
Path:%full_path% +IF:cvsurl +  (CVS) +ENDIF:cvsurl +
Modified:%dtm_modified%
+
+ +
+HTML + +################################################################### + +CLASS_PAGE = < + %classmod%
%full_name% + + + + + + +IF:parent + + + + +ENDIF:parent +
In: +START:infiles +HREF:full_path_url:full_path: +IF:cvsurl + (CVS) +ENDIF:cvsurl +END:infiles +
Parent: +IF:par_url + +ENDIF:par_url +%parent% +IF:par_url + +ENDIF:par_url +
+ + + +HTML + +################################################################### + +METHOD_LIST = < +IF:diagram +
+ %diagram% +
+ENDIF:diagram + +IF:description +
%description%
+ENDIF:description + +IF:requires +
Required Files
+
    +START:requires +
  • HREF:aref:name:
  • +END:requires +
+ENDIF:requires + +IF:toc +
Contents
+ +ENDIF:toc + +IF:methods +
Methods
+
    +START:methods +
  • HREF:aref:name:
  • +END:methods +
+ENDIF:methods + +IF:includes +
Included Modules
+
    +START:includes +
  • HREF:aref:name:
  • +END:includes +
+ENDIF:includes + +START:sections +IF:sectitle + +IF:seccomment +
+%seccomment% +
+ENDIF:seccomment +ENDIF:sectitle + +IF:classlist +
Classes and Modules
+ %classlist% +ENDIF:classlist + +IF:constants +
Constants
+ +START:constants + + + + + +IF:desc + + + + +ENDIF:desc +END:constants +
%name%=%value%
 %desc%
+ENDIF:constants + +IF:attributes +
Attributes
+ +START:attributes + + + + + +END:attributes +
+IF:rw +[%rw%] +ENDIF:rw + %name%%a_desc%
+ENDIF:attributes + +IF:method_list +START:method_list +IF:methods +
%type% %category% methods
+START:methods +
+
+IF:callseq + %callseq% +ENDIF:callseq +IFNOT:callseq + %name%%params% +ENDIF:callseq +IF:codeurl +[ source ] +ENDIF:codeurl +
+IF:m_desc +
+ %m_desc% +
+ENDIF:m_desc +IF:aka +
+ This method is also aliased as +START:aka + %name% +END:aka +
+ENDIF:aka +IF:sourcecode +
+ +
+
+%sourcecode%
+
+
+
+ENDIF:sourcecode +
+END:methods +ENDIF:methods +END:method_list +ENDIF:method_list +END:sections +
+HTML + +FOOTER = < + +ENDFOOTER + +BODY = HEADER + < + +
+ #{METHOD_LIST} +
+ + #{FOOTER} +ENDBODY + +########################## Source code ########################## + +SRC_PAGE = XHTML_PREAMBLE + < +%title% + + + + +
%code%
+ + +HTML + +########################## Index ################################ + +FR_INDEX_BODY = < + + + + + + + +
+START:entries +%name%
+END:entries +
+ +HTML + +CLASS_INDEX = FILE_INDEX +METHOD_INDEX = FILE_INDEX + +INDEX = XHTML_PREAMBLE + < + + %title% + + + + + + + + + +IF:inline_source + +ENDIF:inline_source +IFNOT:inline_source + + + + +ENDIF:inline_source + + <body bgcolor="white"> + Click <a href="html/index.html">here</a> for a non-frames + version of this page. + </body> + + + + +HTML + +end +end + + diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/proto_rake.rdoc b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/proto_rake.rdoc new file mode 100644 index 0000000..a9e33d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/proto_rake.rdoc @@ -0,0 +1,127 @@ += Original Prototype Rake + +This is the original 100 line prototype rake program. + +--- + #!/usr/bin/env ruby + + require 'ftools' + + class Task + TASKS = Hash.new + + attr_reader :prerequisites + + def initialize(task_name) + @name = task_name + @prerequisites = [] + @actions = [] + end + + def enhance(deps=nil, &block) + @prerequisites |= deps if deps + @actions << block if block_given? + self + end + + def name + @name.to_s + end + + def invoke + @prerequisites.each { |n| Task[n].invoke } + execute if needed? + end + + def execute + return if @triggered + @triggered = true + @actions.collect { |act| result = act.call(self) }.last + end + + def needed? + true + end + + def timestamp + Time.now + end + + class << self + def [](task_name) + TASKS[intern(task_name)] or fail "Don't know how to rake #{task_name}" + end + + def define_task(args, &block) + case args + when Hash + fail "Too Many Target Names: #{args.keys.join(' ')}" if args.size > 1 + fail "No Task Name Given" if args.size < 1 + task_name = args.keys[0] + deps = args[task_name] + else + task_name = args + deps = [] + end + deps = deps.collect {|d| intern(d) } + get(task_name).enhance(deps, &block) + end + + def get(task_name) + name = intern(task_name) + TASKS[name] ||= self.new(name) + end + + def intern(task_name) + (Symbol === task_name) ? task_name : task_name.intern + end + end + end + + class FileTask < Task + def needed? + return true unless File.exist?(name) + latest_prereq = @prerequisites.collect{|n| Task[n].timestamp}.max + return false if latest_prereq.nil? + timestamp < latest_prereq + end + + def timestamp + File.new(name.to_s).mtime + end + end + + def task(args, &block) + Task.define_task(args, &block) + end + + def file(args, &block) + FileTask.define_task(args, &block) + end + + def sys(cmd) + puts cmd + system(cmd) or fail "Command Failed: [#{cmd}]" + end + + def rake + begin + here = Dir.pwd + while ! File.exist?("Rakefile") + Dir.chdir("..") + fail "No Rakefile found" if Dir.pwd == here + here = Dir.pwd + end + puts "(in #{Dir.pwd})" + load "./Rakefile" + ARGV.push("default") if ARGV.size == 0 + ARGV.each { |task_name| Task[task_name].invoke } + rescue Exception => ex + puts "rake aborted ... #{ex.message}" + puts ex.backtrace.find {|str| str =~ /Rakefile/ } || "" + end + end + + if __FILE__ == $0 then + rake + end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rake.1 b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rake.1 new file mode 100644 index 0000000..c6bfa25 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rake.1 @@ -0,0 +1,156 @@ +.Dd June 12, 2016 +.Dt RAKE 1 +.Os rake 11.2.2 +.Sh NAME +.Nm rake +.Nd make-like build utility for Ruby +.Sh SYNOPSIS +.Nm +.Op Fl f Ar rakefile +.Op Ar options +.Ar targets ... +.Sh DESCRIPTION +.Nm +is a +.Xr make 1 Ns -like +build utility for Ruby. +Tasks and dependencies are specified in standard Ruby syntax. +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl m , Fl -multitask +Treat all tasks as multitasks. +.It Fl B , Fl -build-all +Build all prerequisites, including those which are up\-to\-date. +.It Fl j , Fl -jobs Ar num_jobs +Specifies the maximum number of tasks to execute in parallel (default is number of CPU cores + 4). +.El +.Ss Modules +.Bl -tag -width Ds +.It Fl I , Fl -libdir Ar libdir +Include +.Ar libdir +in the search path for required modules. +.It Fl r , Fl -require Ar module +Require +.Ar module +before executing +.Pa rakefile . +.El +.Ss Rakefile location +.Bl -tag -width Ds +.It Fl f , Fl -rakefile Ar filename +Use +.Ar filename +as the rakefile to search for. +.It Fl N , Fl -no-search , Fl -nosearch +Do not search parent directories for the Rakefile. +.It Fl G , Fl -no-system , Fl -nosystem +Use standard project Rakefile search paths, ignore system wide rakefiles. +.It Fl R , Fl -rakelib Ar rakelibdir , Fl -rakelibdir Ar rakelibdir +Auto-import any .rake files in +.Ar rakelibdir +(default is +.Sq rakelib ) +.It Fl g , Fl -system +Use system-wide (global) rakefiles (usually +.Pa ~/.rake/*.rake ) . +.El +.Ss Debugging +.Bl -tag -width Ds +.It Fl -backtrace Ns = Ns Ar out +Enable full backtrace. +.Ar out +can be +.Dv stderr +(default) or +.Dv stdout . +.It Fl t , Fl -trace Ns = Ns Ar out +Turn on invoke/execute tracing, enable full backtrace. +.Ar out +can be +.Dv stderr +(default) or +.Dv stdout . +.It Fl -suppress-backtrace Ar pattern +Suppress backtrace lines matching regexp +.Ar pattern . +Ignored if +.Fl -trace +is on. +.It Fl -rules +Trace the rules resolution. +.It Fl n , Fl -dry-run +Do a dry run without executing actions. +.It Fl T , Fl -tasks Op Ar pattern +Display the tasks (matching optional +.Ar pattern ) +with descriptions, then exit. +.It Fl D , Fl -describe Op Ar pattern +Describe the tasks (matching optional +.Ar pattern ) , +then exit. +.It Fl W , Fl -where Op Ar pattern +Describe the tasks (matching optional +.Ar pattern ) , +then exit. +.It Fl P , Fl -prereqs +Display the tasks and dependencies, then exit. +.It Fl e , Fl -execute Ar code +Execute some Ruby code and exit. +.It Fl p , Fl -execute-print Ar code +Execute some Ruby code, print the result, then exit. +.It Fl E , Fl -execute-continue Ar code +Execute some Ruby code, then continue with normal task processing. +.El +.Ss Information +.Bl -tag -width Ds +.It Fl v , Fl -verbose +Log message to standard output. +.It Fl q , Fl -quiet +Do not log messages to standard output. +.It Fl s , Fl -silent +Like +.Fl -quiet , +but also suppresses the +.Sq in directory +announcement. +.It Fl X , Fl -no-deprecation-warnings +Disable the deprecation warnings. +.It Fl -comments +Show commented tasks only +.It Fl A , Fl -all +Show all tasks, even uncommented ones (in combination with +.Fl T +or +.Fl D ) +.It Fl -job-stats Op Ar level +Display job statistics. +If +.Ar level +is +.Sq history , +displays a complete job list. +.It Fl V , Fl -version +Display the program version. +.It Fl h , Fl H , Fl -help +Display a help message. +.El +.Sh SEE ALSO +The complete documentation for +.Nm rake +has been installed at +.Pa /usr/share/doc/rake-doc/html/index.html . +It is also available online at +.Lk https://ruby.github.io/rake . +.Sh AUTHORS +.An -nosplit +.Nm +was written by +.An Jim Weirich Aq Mt jim@weirichhouse.org . +.Pp +This manual was created by +.An Caitlin Matos Aq Mt caitlin.matos@zoho.com +for the Debian project (but may be used by others). +It was inspired by the manual by +.An Jani Monoses Aq Mt jani@iv.ro +for the Ubuntu project. diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rakefile.rdoc b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rakefile.rdoc new file mode 100644 index 0000000..4014306 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rakefile.rdoc @@ -0,0 +1,622 @@ += Rakefile Format + +First of all, there is no special format for a Rakefile. A Rakefile +contains executable Ruby code. Anything legal in a ruby script is +allowed in a Rakefile. + +Now that we understand there is no special syntax in a Rakefile, there +are some conventions that are used in a Rakefile that are a little +unusual in a typical Ruby program. Since a Rakefile is tailored to +specifying tasks and actions, the idioms used in a Rakefile are +designed to support that. + +So, what goes into a Rakefile? + +== Tasks + +Tasks are the main unit of work in a Rakefile. Tasks have a name +(usually given as a symbol or a string), a list of prerequisites (more +symbols or strings) and a list of actions (given as a block). + +=== Simple Tasks + +A task is declared by using the +task+ method. +task+ takes a single +parameter that is the name of the task. + + task :name + +=== Tasks with Prerequisites + +Any prerequisites are given as a list (enclosed in square brackets) +following the name and an arrow (=>). + + task name: [:prereq1, :prereq2] + +*NOTE:* Although this syntax looks a little funky, it is legal +Ruby. We are constructing a hash where the key is :name and the value +for that key is the list of prerequisites. It is equivalent to the +following ... + + hash = Hash.new + hash[:name] = [:prereq1, :prereq2] + task(hash) + +You can also use strings for task names and prerequisites, rake doesn't care. +This is the same task definition: + + task 'name' => %w[prereq1 prereq2] + +As is this: + + task name: %w[prereq1 prereq2] + +We'll prefer this style for regular tasks with prerequisites throughout the +rest of the document. Using an array of strings for the prerequisites means +you will need to make fewer changes if you need to move tasks into namespaces +or perform other refactorings. + +=== Tasks with Actions + +Actions are defined by passing a block to the +task+ method. Any Ruby +code can be placed in the block. The block may reference the task +object via the block parameter. + + task name: [:prereq1, :prereq2] do |t| + # actions (may reference t) + end + +=== Multiple Definitions + +A task may be specified more than once. Each specification adds its +prerequisites and actions to the existing definition. This allows one +part of a rakefile to specify the actions and a different rakefile +(perhaps separately generated) to specify the dependencies. + +For example, the following is equivalent to the single task +specification given above. + + task :name + task name: :prereq1 + task name: %w[prereq2] + task :name do |t| + # actions + end + +== File Tasks + +Some tasks are designed to create a file from one or more other files. +Tasks that generate these files may be skipped if the file already +exists. File tasks are used to specify file creation tasks. + +File tasks are declared using the +file+ method (instead of the +task+ +method). In addition, file tasks are usually named with a string +rather than a symbol. + +The following file task creates a executable program (named +prog+) +given two object files named +a.o+ and +b.o+. The tasks +for creating +a.o+ and +b.o+ are not shown. + + file "prog" => ["a.o", "b.o"] do |t| + sh "cc -o #{t.name} #{t.prerequisites.join(' ')}" + end + +== Directory Tasks + +It is common to need to create directories upon demand. The ++directory+ convenience method is a short-hand for creating a FileTask +that creates the directory. For example, the following declaration +... + + directory "testdata/examples/doc" + +is equivalent to ... + + file "testdata" do |t| mkdir t.name end + file "testdata/examples" => ["testdata"] do |t| mkdir t.name end + file "testdata/examples/doc" => ["testdata/examples"] do |t| mkdir t.name end + +The +directory+ method does not accept prerequisites or actions, but +both prerequisites and actions can be added later. For example ... + + directory "testdata" + file "testdata" => ["otherdata"] + file "testdata" do + cp Dir["standard_data/*.data"], "testdata" + end + +== Tasks with Parallel Prerequisites + +Rake allows parallel execution of prerequisites using the following syntax: + + multitask copy_files: %w[copy_src copy_doc copy_bin] do + puts "All Copies Complete" + end + +In this example, +copy_files+ is a normal rake task. Its actions are +executed whenever all of its prerequisites are done. The big +difference is that the prerequisites (+copy_src+, +copy_bin+ and ++copy_doc+) are executed in parallel. Each of the prerequisites are +run in their own Ruby thread, possibly allowing faster overall runtime. + +=== Secondary Prerequisites + +If any of the primary prerequisites of a multitask have common secondary +prerequisites, all of the primary/parallel prerequisites will wait +until the common prerequisites have been run. + +For example, if the copy_xxx tasks have the +following prerequisites: + + task copy_src: :prep_for_copy + task copy_bin: :prep_for_copy + task copy_doc: :prep_for_copy + +Then the +prep_for_copy+ task is run before starting all the copies in +parallel. Once +prep_for_copy+ is complete, +copy_src+, +copy_bin+, +and +copy_doc+ are all run in parallel. Note that +prep_for_copy+ is +run only once, even though it is referenced in multiple threads. + +=== Thread Safety + +The Rake internal data structures are thread-safe with respect +to the multitask parallel execution, so there is no need for the user +to do extra synchronization for Rake's benefit. However, if there are +user data structures shared between the parallel prerequisites, the +user must do whatever is necessary to prevent race conditions. + +== Tasks with Arguments + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.2] + +And the string "0.8.2" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire name + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +=== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, [:first_name, :last_name] + +The first argument is still the name of the task (:name in this case). +The next two arguments are the names of the parameters expected by +:name in an array (:first_name and :last_name in the example). + +To access the values of the parameters, the block defining the task +behaviour can now accept a second parameter: + + task :name, [:first_name, :last_name] do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. + +If you wish to specify default values for the arguments, you can use +the with_defaults method in the task body. Here is the above example +where we specify default values for the first and last names: + + task :name, [:first_name, :last_name] do |t, args| + args.with_defaults(:first_name => "John", :last_name => "Dough") + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +=== Tasks that Expect Parameters and Have Prerequisites + +Tasks that use parameters have a slightly different format for +prerequisites. Use the arrow notation to indicate the prerequisites +for tasks with arguments. For example: + + task :name, [:first_name, :last_name] => [:pre_name] do |t, args| + args.with_defaults(:first_name => "John", :last_name => "Dough") + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +=== Tasks that take Variable-length Parameters + +Tasks that need to handle a list of values as a parameter can use the +extras method of the args variable. This allows for tasks that can +loop over a variable number of values, and its compatible with named +parameters as well: + + task :email, [:message] do |t, args| + mail = Mail.new(args.message) + recipients = args.extras + recipients.each do |target| + mail.send_to(target) + end + end + +There is also the convenience method to_a that returns all parameters +in the sequential order they were given, including those associated +with named parameters. + +=== Deprecated Task Parameters Format + +There is an older format for declaring task parameters that omitted +the task argument array and used the :needs keyword to introduce the +dependencies. That format is still supported for compatibility, but +is not recommended for use. The older format may be dropped in future +versions of rake. + +== Accessing Task Programmatically + +Sometimes it is useful to manipulate tasks programmatically in a +Rakefile. To find a task object use Rake::Task.[]. + +=== Programmatic Task Example + +For example, the following Rakefile defines two tasks. The :doit task +simply prints a simple "DONE" message. The :dont class will lookup +the doit class and remove (clear) all of its prerequisites and +actions. + + task :doit do + puts "DONE" + end + + task :dont do + Rake::Task[:doit].clear + end + +Running this example: + + $ rake doit + (in /Users/jim/working/git/rake/x) + DONE + $ rake dont doit + (in /Users/jim/working/git/rake/x) + $ + +The ability to programmatically manipulate tasks gives rake very +powerful meta-programming capabilities w.r.t. task execution, but +should be used with caution. + +== Rules + +When a file is named as a prerequisite, but does not have a file task +defined for it, Rake will attempt to synthesize a task by looking at a +list of rules supplied in the Rakefile. + +Suppose we were trying to invoke task "mycode.o", but no task is +defined for it. But the rakefile has a rule that look like this ... + + rule '.o' => ['.c'] do |t| + sh "cc #{t.source} -c -o #{t.name}" + end + +This rule will synthesize any task that ends in ".o". It has a +prerequisite a source file with an extension of ".c" must exist. If +Rake is able to find a file named "mycode.c", it will automatically +create a task that builds "mycode.o" from "mycode.c". + +If the file "mycode.c" does not exist, rake will attempt +to recursively synthesize a rule for it. + +When a task is synthesized from a rule, the +source+ attribute of the +task is set to the matching source file. This allows us to write +rules with actions that reference the source file. + +=== Advanced Rules + +Any regular expression may be used as the rule pattern. Additionally, +a proc may be used to calculate the name of the source file. This +allows for complex patterns and sources. + +The following rule is equivalent to the example above. + + rule( /\.o$/ => [ + proc {|task_name| task_name.sub(/\.[^.]+$/, '.c') } + ]) do |t| + sh "cc #{t.source} -c -o #{t.name}" + end + +*NOTE:* Because of a _quirk_ in Ruby syntax, parenthesis are +required on *rule* when the first argument is a regular expression. + +The following rule might be used for Java files ... + + rule '.class' => [ + proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') } + ] do |t| + java_compile(t.source, t.name) + end + +*NOTE:* +java_compile+ is a hypothetical method that invokes the +java compiler. + +== Importing Dependencies + +Any ruby file (including other rakefiles) can be included with a +standard Ruby +require+ command. The rules and declarations in the +required file are just added to the definitions already accumulated. + +Because the files are loaded _before_ the rake targets are evaluated, +the loaded files must be "ready to go" when the rake command is +invoked. This makes generated dependency files difficult to use. By +the time rake gets around to updating the dependencies file, it is too +late to load it. + +The +import+ command addresses this by specifying a file to be loaded +_after_ the main rakefile is loaded, but _before_ any targets on the +command line are invoked. In addition, if the file name matches an +explicit task, that task is invoked before loading the file. This +allows dependency files to be generated and used in a single rake +command invocation. + +Example: + + require 'rake/loaders/makefile' + + file ".depends.mf" => [SRC_LIST] do |t| + sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}" + end + + import ".depends.mf" + +If ".depends" does not exist, or is out of date w.r.t. the source +files, a new ".depends" file is generated using +makedepend+ before +loading. + +== Comments + +Standard Ruby comments (beginning with "#") can be used anywhere it is +legal in Ruby source code, including comments for tasks and rules. +However, if you wish a task to be described using the "-T" switch, +then you need to use the +desc+ command to describe the task. + +Example: + + desc "Create a distribution package" + task package: %w[ ... ] do ... end + +The "-T" switch (or "--tasks" if you like to spell things out) will +display a list of tasks that have a description. If you use +desc+ to +describe your major tasks, you have a semi-automatic way of generating +a summary of your Rake file. + + $ rake -T + (in /home/.../rake) + rake clean # Remove any temporary products. + rake clobber # Remove any generated file. + rake clobber_rdoc # Remove rdoc products + rake contrib_test # Run tests for contrib_test + rake default # Default Task + rake install # Install the application + rake lines # Count lines in the main rake file + rake rdoc # Build the rdoc HTML Files + rake rerdoc # Force a rebuild of the RDOC files + rake test # Run tests + rake testall # Run all test targets + +Only tasks with descriptions will be displayed with the "-T" switch. +Use "-P" (or "--prereqs") to get a list of all tasks and their +prerequisites. + +== Namespaces + +As projects grow (and along with it, the number of tasks), it is +common for task names to begin to clash. For example, if you might +have a main program and a set of sample programs built by a single +Rakefile. By placing the tasks related to the main program in one +namespace, and the tasks for building the sample programs in a +different namespace, the task names will not interfere with each other. + +For example: + + namespace "main" do + task :build do + # Build the main program + end + end + + namespace "samples" do + task :build do + # Build the sample programs + end + end + + task build: %w[main:build samples:build] + +Referencing a task in a separate namespace can be achieved by +prefixing the task name with the namespace and a colon +(e.g. "main:build" refers to the :build task in the +main+ namespace). +Nested namespaces are supported. + +Note that the name given in the +task+ command is always the unadorned +task name without any namespace prefixes. The +task+ command always +defines a task in the current namespace. + +=== FileTasks + +File task names are not scoped by the namespace command. Since the +name of a file task is the name of an actual file in the file system, +it makes little sense to include file task names in name space. +Directory tasks (created by the +directory+ command) are a type of +file task and are also not affected by namespaces. + +=== Name Resolution + +When looking up a task name, rake will start with the current +namespace and attempt to find the name there. If it fails to find a +name in the current namespace, it will search the parent namespaces +until a match is found (or an error occurs if there is no match). + +The "rake" namespace is a special implicit namespace that refers to +the toplevel names. + +If a task name begins with a "^" character, the name resolution will +start in the parent namespace. Multiple "^" characters are allowed. + +Here is an example file with multiple :run tasks and how various names +resolve in different locations. + + task :run + + namespace "one" do + task :run + + namespace "two" do + task :run + + # :run => "one:two:run" + # "two:run" => "one:two:run" + # "one:two:run" => "one:two:run" + # "one:run" => "one:run" + # "^run" => "one:run" + # "^^run" => "rake:run" (the top level task) + # "rake:run" => "rake:run" (the top level task) + end + + # :run => "one:run" + # "two:run" => "one:two:run" + # "^run" => "rake:run" + end + + # :run => "rake:run" + # "one:run" => "one:run" + # "one:two:run" => "one:two:run" + +== FileLists + +FileLists are the way Rake manages lists of files. You can treat a +FileList as an array of strings for the most part, but FileLists +support some additional operations. + +=== Creating a FileList + +Creating a file list is easy. Just give it the list of file names: + + fl = FileList['file1.rb', file2.rb'] + +Or give it a glob pattern: + + fl = FileList['*.rb'] + +== Odds and Ends + +=== do/end versus { } + +Blocks may be specified with either a +do+/+end+ pair, or with curly +braces in Ruby. We _strongly_ recommend using +do+/+end+ to specify the +actions for tasks and rules. Because the rakefile idiom tends to +leave off parentheses on the task/file/rule methods, unusual +ambiguities can arise when using curly braces. + +For example, suppose that the method +object_files+ returns a list of +object files in a project. Now we use +object_files+ as the +prerequisites in a rule specified with actions in curly braces. + + # DON'T DO THIS! + file "prog" => object_files { + # Actions are expected here (but it doesn't work)! + } + +Because curly braces have a higher precedence than +do+/+end+, the +block is associated with the +object_files+ method rather than the ++file+ method. + +This is the proper way to specify the task ... + + # THIS IS FINE + file "prog" => object_files do + # Actions go here + end + +== Rakefile Path + +When issuing the +rake+ command in a terminal, Rake will look +for a Rakefile in the current directory. If a Rakefile is not found, +it will search parent directories until one is found. + +For example, if a Rakefile resides in the +project/+ directory, +moving deeper into the project's directory tree will not have an adverse +effect on rake tasks: + + $ pwd + /home/user/project + + $ cd lib/foo/bar + $ pwd + /home/user/project/lib/foo/bar + + $ rake run_pwd + /home/user/project + +As far as rake is concerned, all tasks are run from the directory in +which the Rakefile resides. + +=== Multiple Rake Files + +Not all tasks need to be included in a single Rakefile. Additional +rake files (with the file extension "+.rake+") may be placed in ++rakelib+ directory located at the top level of a project (i.e. +the same directory that contains the main +Rakefile+). + +Also, rails projects may include additional rake files in the ++lib/tasks+ directory. + +=== Clean and Clobber Tasks + +Through require 'rake/clean' Rake provides +clean+ and +clobber+ +tasks: + ++clean+ :: + Clean up the project by deleting scratch files and backup files. Add files + to the +CLEAN+ FileList to have the +clean+ target handle them. + ++clobber+ :: + Clobber all generated and non-source files in a project. The task depends + on +clean+, so all the +CLEAN+ files will be deleted as well as files in the + +CLOBBER+ FileList. The intent of this task is to return a project to its + pristine, just unpacked state. + +You can add file names or glob patterns to both the +CLEAN+ and +CLOBBER+ +lists. + +=== Phony Task + +The phony task can be used as a dependency to allow file-based tasks to use +non-file-based-tasks as prerequisites without forcing them to rebuild. You +can require 'rake/phony' to add the +phony+ task. + +---- + +== See + +* README.rdoc -- Main documentation for Rake. diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rational.rdoc b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rational.rdoc new file mode 100644 index 0000000..0e1c338 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/doc/rational.rdoc @@ -0,0 +1,151 @@ += Why rake? + +Ok, let me state from the beginning that I never intended to write this +code. I'm not convinced it is useful, and I'm not convinced anyone +would even be interested in it. All I can say is that Why's onion truck +must by been passing through the Ohio valley. + +What am I talking about? ... A Ruby version of Make. + +See, I can sense you cringing already, and I agree. The world certainly +doesn't need yet another reworking of the "make" program. I mean, we +already have "ant". Isn't that enough? + +It started yesterday. I was helping a coworker fix a problem in one of +the Makefiles we use in our project. Not a particularly tough problem, +but during the course of the conversation I began lamenting some of the +shortcomings of make. In particular, in one of my makefiles I wanted to +determine the name of a file dynamically and had to resort to some +simple scripting (in Ruby) to make it work. "Wouldn't it be nice if you +could just use Ruby inside a Makefile" I said. + +My coworker (a recent convert to Ruby) agreed, but wondered what it +would look like. So I sketched the following on the whiteboard... + + "What if you could specify the make tasks in Ruby, like this ..." + + task "build" do + java_compile(...args, etc ...) + end + + "The task function would register "build" as a target to be made, + and the block would be the action executed whenever the build + system determined that it was time to do the build target." + +We agreed that would be cool, but writing make from scratch would be WAY +too much work. And that was the end of that! + +... Except I couldn't get the thought out of my head. What exactly +would be needed to make the about syntax work as a make file? Hmmm, you +would need to register the tasks, you need some way of specifying +dependencies between tasks, and some way of kicking off the process. +Hey! What if we did ... and fifteen minutes later I had a working +prototype of Ruby make, complete with dependencies and actions. + +I showed the code to my coworker and we had a good laugh. It was just +about a page worth of code that reproduced an amazing amount of the +functionality of make. We were both truly stunned with the power of +Ruby. + +But it didn't do everything make did. In particular, it didn't have +timestamp based file dependencies (where a file is rebuilt if any of its +prerequisite files have a later timestamp). Obviously THAT would be a +pain to add and so Ruby Make would remain an interesting experiment. + +... Except as I walked back to my desk, I started thinking about what +file based dependencies would really need. Rats! I was hooked again, +and by adding a new class and two new methods, file/timestamp +dependencies were implemented. + +Ok, now I was really hooked. Last night (during CSI!) I massaged the +code and cleaned it up a bit. The result is a bare-bones replacement +for make in exactly 100 lines of code. + +For the curious, you can see it at ... +* doc/proto_rake.rdoc + +Oh, about the name. When I wrote the example Ruby Make task on my +whiteboard, my coworker exclaimed "Oh! I have the perfect name: Rake ... +Get it? Ruby-Make. Rake!" He said he envisioned the tasks as leaves +and Rake would clean them up ... or something like that. Anyways, the +name stuck. + +Some quick examples ... + +A simple task to delete backup files ... + + task :clean do + Dir['*~'].each {|fn| rm fn rescue nil} + end + +Note that task names are symbols (they are slightly easier to type +than quoted strings ... but you may use quoted string if you would +rather). Rake makes the methods of the FileUtils module directly +available, so we take advantage of the rm command. Also note +the use of "rescue nil" to trap and ignore errors in the rm +command. + +To run it, just type "rake clean". Rake will automatically find a +Rakefile in the current directory (or above!) and will invoke the +targets named on the command line. If there are no targets explicitly +named, rake will invoke the task "default". + +Here's another task with dependencies ... + + task :clobber => [:clean] do + rm_r "tempdir" + end + +Task :clobber depends upon task :clean, so :clean will be run before +:clobber is executed. + +Files are specified by using the "file" command. It is similar to the +task command, except that the task name represents a file, and the task +will be run only if the file doesn't exist, or if its modification time +is earlier than any of its prerequisites. + +Here is a file based dependency that will compile "hello.cc" to +"hello.o". + + file "hello.cc" + file "hello.o" => ["hello.cc"] do |t| + srcfile = t.name.sub(/\.o$/, ".cc") + sh %{g++ #{srcfile} -c -o #{t.name}} + end + +I normally specify file tasks with string (rather than symbols). Some +file names can't be represented by symbols. Plus it makes the +distinction between them more clear to the casual reader. + +Currently writing a task for each and every file in the project would be +tedious at best. I envision a set of libraries to make this job +easier. For instance, perhaps something like this ... + + require 'rake/ctools' + Dir['*.c'].each do |fn| + c_source_file(fn) + end + +where "c_source_file" will create all the tasks need to compile all the +C source files in a directory. Any number of useful libraries could be +created for rake. + +That's it. There's no documentation (other than whats in this +message). Does this sound interesting to anyone? If so, I'll continue +to clean it up and write it up and publish it on RAA. Otherwise, I'll +leave it as an interesting exercise and a tribute to the power of Ruby. + +Why /might/ rake be interesting to Ruby programmers. I don't know, +perhaps ... + +* No weird make syntax (only weird Ruby syntax :-) +* No need to edit or read XML (a la ant) +* Platform independent build scripts. +* Will run anywhere Ruby exists, so no need to have "make" installed. + If you stay away from the "sys" command and use things like + 'ftools', you can have a perfectly platform independent + build script. Also rake is only 100 lines of code, so it can + easily be packaged along with the rest of your code. + +So ... Sorry for the long rambling message. Like I said, I never +intended to write this code at all. diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/exe/rake b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/exe/rake new file mode 100755 index 0000000..a00975f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/exe/rake @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +#-- +# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +#++ + +require "rake" + +Rake.application.run diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake.rb new file mode 100644 index 0000000..0f3d6a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true +#-- +# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +#++ + +module Rake; end + +require "rake/version" + +require "rbconfig" +require "fileutils" +require "singleton" +require "monitor" +require "optparse" + +require "rake/ext/string" + +require "rake/win32" + +require "rake/linked_list" +require "rake/cpu_counter" +require "rake/scope" +require "rake/task_argument_error" +require "rake/rule_recursion_overflow_error" +require "rake/rake_module" +require "rake/trace_output" +require "rake/pseudo_status" +require "rake/task_arguments" +require "rake/invocation_chain" +require "rake/task" +require "rake/file_task" +require "rake/file_creation_task" +require "rake/multi_task" +require "rake/dsl_definition" +require "rake/file_utils_ext" +require "rake/file_list" +require "rake/default_loader" +require "rake/early_time" +require "rake/late_time" +require "rake/name_space" +require "rake/task_manager" +require "rake/application" +require "rake/backtrace" + +$trace = false + +# :stopdoc: +# +# Some top level Constants. + +FileList = Rake::FileList +RakeFileUtils = Rake::FileUtilsExt diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb new file mode 100644 index 0000000..2ea8c78 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb @@ -0,0 +1,861 @@ +# frozen_string_literal: true +require "optparse" + +require "rake/task_manager" +require "rake/file_list" +require "rake/thread_pool" +require "rake/thread_history_display" +require "rake/trace_output" +require "rake/win32" + +module Rake + + CommandLineOptionError = Class.new(StandardError) + + ## + # Rake main application object. When invoking +rake+ from the + # command line, a Rake::Application object is created and run. + + class Application + include TaskManager + include TraceOutput + + # The name of the application (typically 'rake') + attr_reader :name + + # The original directory where rake was invoked. + attr_reader :original_dir + + # Name of the actual rakefile used. + attr_reader :rakefile + + # Number of columns on the terminal + attr_accessor :terminal_columns + + # List of the top level task names (task names from the command line). + attr_reader :top_level_tasks + + # Override the detected TTY output state (mostly for testing) + attr_writer :tty_output + + DEFAULT_RAKEFILES = [ + "rakefile", + "Rakefile", + "rakefile.rb", + "Rakefile.rb" + ].freeze + + # Initialize a Rake::Application object. + def initialize + super + @name = "rake" + @rakefiles = DEFAULT_RAKEFILES.dup + @rakefile = nil + @pending_imports = [] + @imported = [] + @loaders = {} + @default_loader = Rake::DefaultLoader.new + @original_dir = Dir.pwd + @top_level_tasks = [] + add_loader("rb", DefaultLoader.new) + add_loader("rf", DefaultLoader.new) + add_loader("rake", DefaultLoader.new) + @tty_output = STDOUT.tty? + @terminal_columns = ENV["RAKE_COLUMNS"].to_i + + set_default_options + end + + # Run the Rake application. The run method performs the following + # three steps: + # + # * Initialize the command line options (+init+). + # * Define the tasks (+load_rakefile+). + # * Run the top level tasks (+top_level+). + # + # If you wish to build a custom rake command, you should call + # +init+ on your application. Then define any tasks. Finally, + # call +top_level+ to run your top level tasks. + def run(argv = ARGV) + standard_exception_handling do + init "rake", argv + load_rakefile + top_level + end + end + + # Initialize the command line parameters and app name. + def init(app_name="rake", argv = ARGV) + standard_exception_handling do + @name = app_name + begin + args = handle_options argv + rescue ArgumentError + # Backward compatibility for capistrano + args = handle_options + end + load_debug_at_stop_feature + collect_command_line_tasks(args) + end + end + + def load_debug_at_stop_feature + return unless ENV["RAKE_DEBUG"] + require "debug/session" + DEBUGGER__::start no_sigint_hook: true, nonstop: true + Rake::Task.prepend Module.new { + def execute(*) + exception = DEBUGGER__::SESSION.capture_exception_frames(/(exe|bin|lib)\/rake/) do + super + end + + if exception + STDERR.puts exception.message + DEBUGGER__::SESSION.enter_postmortem_session exception + raise exception + end + end + } + rescue LoadError + end + private :load_debug_at_stop_feature + + # Find the rakefile and then load it and any pending imports. + def load_rakefile + standard_exception_handling do + raw_load_rakefile + end + end + + # Run the top level tasks of a Rake application. + def top_level + run_with_threads do + if options.show_tasks + display_tasks_and_comments + elsif options.show_prereqs + display_prerequisites + else + top_level_tasks.each { |task_name| invoke_task(task_name) } + end + end + end + + # Run the given block with the thread startup and shutdown. + def run_with_threads + thread_pool.gather_history if options.job_stats == :history + + yield + + thread_pool.join if defined?(@thread_pool) + if options.job_stats + stats = thread_pool.statistics + puts "Maximum active threads: #{stats[:max_active_threads]} + main" + puts "Total threads in play: #{stats[:total_threads_in_play]} + main" + end + ThreadHistoryDisplay.new(thread_pool.history).show if + options.job_stats == :history + end + + # Add a loader to handle imported files ending in the extension + # +ext+. + def add_loader(ext, loader) + ext = ".#{ext}" unless ext =~ /^\./ + @loaders[ext] = loader + end + + # Application options from the command line + def options + @options ||= Struct.new( + :always_multitask, :backtrace, :build_all, :dryrun, + :ignore_deprecate, :ignore_system, :job_stats, :load_system, + :nosearch, :rakelib, :show_all_tasks, :show_prereqs, + :show_task_pattern, :show_tasks, :silent, :suppress_backtrace_pattern, + :thread_pool_size, :trace, :trace_output, :trace_rules + ).new + end + + # Return the thread pool used for multithreaded processing. + def thread_pool # :nodoc: + @thread_pool ||= ThreadPool.new(options.thread_pool_size || Rake.suggested_thread_count-1) + end + + # internal ---------------------------------------------------------------- + + # Invokes a task with arguments that are extracted from +task_string+ + def invoke_task(task_string) # :nodoc: + name, args = parse_task_string(task_string) + t = self[name] + t.invoke(*args) + end + + def parse_task_string(string) # :nodoc: + /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s + + name = $1 + remaining_args = $2 + + return string, [] unless name + return name, [] if remaining_args.empty? + + args = [] + + begin + /\s*((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args + + remaining_args = $2 + args << $1.gsub(/\\(.)/, '\1') + end while remaining_args + + return name, args + end + + # Provide standard exception handling for the given block. + def standard_exception_handling # :nodoc: + yield + rescue SystemExit + # Exit silently with current status + raise + rescue OptionParser::InvalidOption => ex + $stderr.puts ex.message + exit(false) + rescue Exception => ex + # Exit with error message + display_error_message(ex) + exit_because_of_exception(ex) + end + + # Exit the program because of an unhandled exception. + # (may be overridden by subclasses) + def exit_because_of_exception(ex) # :nodoc: + exit(false) + end + + # Display the error message that caused the exception. + def display_error_message(ex) # :nodoc: + trace "#{name} aborted!" + display_exception_details(ex) + trace "Tasks: #{ex.chain}" if has_chain?(ex) + trace "(See full trace by running task with --trace)" unless + options.backtrace + end + + def display_exception_details(ex) # :nodoc: + display_exception_details_seen << ex + + display_exception_message_details(ex) + display_exception_backtrace(ex) if ex.backtrace + display_cause_details(ex.cause) if has_cause?(ex) + end + + def display_cause_details(ex) # :nodoc: + return if display_exception_details_seen.include? ex + + trace "\nCaused by:" + display_exception_details(ex) + end + + def display_exception_details_seen # :nodoc: + Thread.current[:rake_display_exception_details_seen] ||= [] + end + + def has_cause?(ex) # :nodoc: + ex.respond_to?(:cause) && ex.cause + end + + def display_exception_message_details(ex) # :nodoc: + if ex.instance_of?(RuntimeError) + trace ex.message + elsif ex.respond_to?(:detailed_message) + trace "#{ex.class.name}: #{ex.detailed_message(highlight: false)}" + else + trace "#{ex.class.name}: #{ex.message}" + end + end + + def display_exception_backtrace(ex) # :nodoc: + if options.backtrace + trace ex.backtrace.join("\n") + else + trace Backtrace.collapse(ex.backtrace).join("\n") + end + end + + # Warn about deprecated usage. + # + # Example: + # Rake.application.deprecate("import", "Rake.import", caller.first) + # + def deprecate(old_usage, new_usage, call_site) # :nodoc: + unless options.ignore_deprecate + $stderr.puts "WARNING: '#{old_usage}' is deprecated. " + + "Please use '#{new_usage}' instead.\n" + + " at #{call_site}" + end + end + + # Does the exception have a task invocation chain? + def has_chain?(exception) # :nodoc: + exception.respond_to?(:chain) && exception.chain + end + private :has_chain? + + # True if one of the files in RAKEFILES is in the current directory. + # If a match is found, it is copied into @rakefile. + def have_rakefile # :nodoc: + @rakefiles.each do |fn| + if File.exist?(fn) + others = FileList.glob(fn, File::FNM_CASEFOLD) + return others.size == 1 ? others.first : fn + elsif fn == "" + return fn + end + end + return nil + end + + # True if we are outputting to TTY, false otherwise + def tty_output? # :nodoc: + @tty_output + end + + # We will truncate output if we are outputting to a TTY or if we've been + # given an explicit column width to honor + def truncate_output? # :nodoc: + tty_output? || @terminal_columns.nonzero? + end + + # Display the tasks and comments. + def display_tasks_and_comments # :nodoc: + displayable_tasks = tasks.select { |t| + (options.show_all_tasks || t.comment) && + t.name =~ options.show_task_pattern + } + case options.show_tasks + when :tasks + width = displayable_tasks.map { |t| t.name_with_args.length }.max || 10 + if truncate_output? + max_column = terminal_width - name.size - width - 7 + else + max_column = nil + end + + displayable_tasks.each do |t| + printf("#{name} %-#{width}s # %s\n", + t.name_with_args, + max_column ? truncate(t.comment, max_column) : t.comment) + end + when :describe + displayable_tasks.each do |t| + puts "#{name} #{t.name_with_args}" + comment = t.full_comment || "" + comment.split("\n").each do |line| + puts " #{line}" + end + puts + end + when :lines + displayable_tasks.each do |t| + t.locations.each do |loc| + printf "#{name} %-30s %s\n", t.name_with_args, loc + end + end + else + fail "Unknown show task mode: '#{options.show_tasks}'" + end + end + + def terminal_width # :nodoc: + if @terminal_columns.nonzero? + result = @terminal_columns + else + result = unix? ? dynamic_width : 80 + end + (result < 10) ? 80 : result + rescue + 80 + end + + # Calculate the dynamic width of the + def dynamic_width # :nodoc: + @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) + end + + def dynamic_width_stty # :nodoc: + %x{stty size 2>/dev/null}.split[1].to_i + end + + def dynamic_width_tput # :nodoc: + %x{tput cols 2>/dev/null}.to_i + end + + def unix? # :nodoc: + RbConfig::CONFIG["host_os"] =~ + /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i + end + + def windows? # :nodoc: + Win32.windows? + end + + def truncate(string, width) # :nodoc: + if string.nil? + "" + elsif string.length <= width + string + else + (string[0, width - 3] || "") + "..." + end + end + + # Display the tasks and prerequisites + def display_prerequisites # :nodoc: + tasks.each do |t| + puts "#{name} #{t.name}" + t.prerequisites.each { |pre| puts " #{pre}" } + end + end + + def trace(*strings) # :nodoc: + options.trace_output ||= $stderr + trace_on(options.trace_output, *strings) + end + + def sort_options(options) # :nodoc: + options.sort_by { |opt| + opt.select { |o| o.is_a?(String) && o =~ /^-/ }.map(&:downcase).sort.reverse + } + end + private :sort_options + + # A list of all the standard options used in rake, suitable for + # passing to OptionParser. + def standard_rake_options # :nodoc: + sort_options( + [ + ["--all", "-A", + "Show all tasks, even uncommented ones (in combination with -T or -D)", + lambda { |value| + options.show_all_tasks = value + } + ], + ["--backtrace=[OUT]", + "Enable full backtrace. OUT can be stderr (default) or stdout.", + lambda { |value| + options.backtrace = true + select_trace_output(options, "backtrace", value) + } + ], + ["--build-all", "-B", + "Build all prerequisites, including those which are up-to-date.", + lambda { |value| + options.build_all = true + } + ], + ["--comments", + "Show commented tasks only", + lambda { |value| + options.show_all_tasks = !value + } + ], + ["--describe", "-D [PATTERN]", + "Describe the tasks (matching optional PATTERN), then exit.", + lambda { |value| + select_tasks_to_show(options, :describe, value) + } + ], + ["--directory", "-C [DIRECTORY]", + "Change to DIRECTORY before doing anything.", + lambda { |value| + Dir.chdir value + @original_dir = Dir.pwd + } + ], + ["--dry-run", "-n", + "Do a dry run without executing actions.", + lambda { |value| + Rake.verbose(true) + Rake.nowrite(true) + options.dryrun = true + options.trace = true + } + ], + ["--execute", "-e CODE", + "Execute some Ruby code and exit.", + lambda { |value| + eval(value) + exit + } + ], + ["--execute-print", "-p CODE", + "Execute some Ruby code, print the result, then exit.", + lambda { |value| + puts eval(value) + exit + } + ], + ["--execute-continue", "-E CODE", + "Execute some Ruby code, " + + "then continue with normal task processing.", + lambda { |value| eval(value) } + ], + ["--jobs", "-j [NUMBER]", + "Specifies the maximum number of tasks to execute in parallel. " + + "(default is number of CPU cores + 4)", + lambda { |value| + if value.nil? || value == "" + value = Float::INFINITY + elsif value =~ /^\d+$/ + value = value.to_i + else + value = Rake.suggested_thread_count + end + value = 1 if value < 1 + options.thread_pool_size = value - 1 + } + ], + ["--job-stats [LEVEL]", + "Display job statistics. " + + "LEVEL=history displays a complete job list", + lambda { |value| + if value =~ /^history/i + options.job_stats = :history + else + options.job_stats = true + end + } + ], + ["--libdir", "-I LIBDIR", + "Include LIBDIR in the search path for required modules.", + lambda { |value| $:.push(value) } + ], + ["--multitask", "-m", + "Treat all tasks as multitasks.", + lambda { |value| options.always_multitask = true } + ], + ["--no-search", "--nosearch", + "-N", "Do not search parent directories for the Rakefile.", + lambda { |value| options.nosearch = true } + ], + ["--prereqs", "-P", + "Display the tasks and dependencies, then exit.", + lambda { |value| options.show_prereqs = true } + ], + ["--quiet", "-q", + "Do not log messages to standard output.", + lambda { |value| Rake.verbose(false) } + ], + ["--rakefile", "-f [FILENAME]", + "Use FILENAME as the rakefile to search for.", + lambda { |value| + value ||= "" + @rakefiles.clear + @rakefiles << value + } + ], + ["--rakelibdir", "--rakelib", "-R RAKELIBDIR", + "Auto-import any .rake files in RAKELIBDIR. " + + "(default is 'rakelib')", + lambda { |value| + options.rakelib = value.split(File::PATH_SEPARATOR) + } + ], + ["--require", "-r MODULE", + "Require MODULE before executing rakefile.", + lambda { |value| + begin + require value + rescue LoadError => ex + begin + rake_require value + rescue LoadError + raise ex + end + end + } + ], + ["--rules", + "Trace the rules resolution.", + lambda { |value| options.trace_rules = true } + ], + ["--silent", "-s", + "Like --quiet, but also suppresses the " + + "'in directory' announcement.", + lambda { |value| + Rake.verbose(false) + options.silent = true + } + ], + ["--suppress-backtrace PATTERN", + "Suppress backtrace lines matching regexp PATTERN. " + + "Ignored if --trace is on.", + lambda { |value| + options.suppress_backtrace_pattern = Regexp.new(value) + } + ], + ["--system", "-g", + "Using system wide (global) rakefiles " + + "(usually '~/.rake/*.rake').", + lambda { |value| options.load_system = true } + ], + ["--no-system", "--nosystem", "-G", + "Use standard project Rakefile search paths, " + + "ignore system wide rakefiles.", + lambda { |value| options.ignore_system = true } + ], + ["--tasks", "-T [PATTERN]", + "Display the tasks (matching optional PATTERN) " + + "with descriptions, then exit. " + + "-AT combination displays all the tasks, including those without descriptions.", + lambda { |value| + select_tasks_to_show(options, :tasks, value) + } + ], + ["--trace=[OUT]", "-t", + "Turn on invoke/execute tracing, enable full backtrace. " + + "OUT can be stderr (default) or stdout.", + lambda { |value| + options.trace = true + options.backtrace = true + select_trace_output(options, "trace", value) + Rake.verbose(true) + } + ], + ["--verbose", "-v", + "Log message to standard output.", + lambda { |value| Rake.verbose(true) } + ], + ["--version", "-V", + "Display the program version.", + lambda { |value| + puts "rake, version #{Rake::VERSION}" + exit + } + ], + ["--where", "-W [PATTERN]", + "Describe the tasks (matching optional PATTERN), then exit.", + lambda { |value| + select_tasks_to_show(options, :lines, value) + options.show_all_tasks = true + } + ], + ["--no-deprecation-warnings", "-X", + "Disable the deprecation warnings.", + lambda { |value| + options.ignore_deprecate = true + } + ], + ]) + end + + def select_tasks_to_show(options, show_tasks, value) # :nodoc: + options.show_tasks = show_tasks + options.show_task_pattern = Regexp.new(value || "") + Rake::TaskManager.record_task_metadata = true + end + private :select_tasks_to_show + + def select_trace_output(options, trace_option, value) # :nodoc: + value = value.strip unless value.nil? + case value + when "stdout" + options.trace_output = $stdout + when "stderr", nil + options.trace_output = $stderr + else + fail CommandLineOptionError, + "Unrecognized --#{trace_option} option '#{value}'" + end + end + private :select_trace_output + + # Read and handle the command line options. Returns the command line + # arguments that we didn't understand, which should (in theory) be just + # task names and env vars. + def handle_options(argv) # :nodoc: + set_default_options + + OptionParser.new do |opts| + opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..." + opts.separator "" + opts.separator "Options are ..." + + opts.on_tail("-h", "--help", "-H", "Display this help message.") do + puts opts + exit + end + + standard_rake_options.each { |args| opts.on(*args) } + opts.environment("RAKEOPT") + end.parse(argv) + end + + # Similar to the regular Ruby +require+ command, but will check + # for *.rake files in addition to *.rb files. + def rake_require(file_name, paths=$LOAD_PATH, loaded=$") # :nodoc: + fn = file_name + ".rake" + return false if loaded.include?(fn) + paths.each do |path| + full_path = File.join(path, fn) + if File.exist?(full_path) + Rake.load_rakefile(full_path) + loaded << fn + return true + end + end + fail LoadError, "Can't find #{file_name}" + end + + def find_rakefile_location # :nodoc: + here = Dir.pwd + until (fn = have_rakefile) + Dir.chdir("..") + return nil if Dir.pwd == here || options.nosearch + here = Dir.pwd + end + [fn, here] + ensure + Dir.chdir(Rake.original_dir) + end + + def print_rakefile_directory(location) # :nodoc: + $stderr.puts "(in #{Dir.pwd})" unless + options.silent or original_dir == location + end + + def raw_load_rakefile # :nodoc: + rakefile, location = find_rakefile_location + if (!options.ignore_system) && + (options.load_system || rakefile.nil?) && + system_dir && File.directory?(system_dir) + print_rakefile_directory(location) + glob("#{system_dir}/*.rake") do |name| + add_import name + end + else + fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if + rakefile.nil? + @rakefile = rakefile + Dir.chdir(location) + print_rakefile_directory(location) + Rake.load_rakefile(File.expand_path(@rakefile)) if + @rakefile && @rakefile != "" + options.rakelib.each do |rlib| + glob("#{rlib}/*.rake") do |name| + add_import name + end + end + end + load_imports + end + + def glob(path, &block) # :nodoc: + FileList.glob(path.tr("\\", "/")).each(&block) + end + private :glob + + # The directory path containing the system wide rakefiles. + def system_dir # :nodoc: + @system_dir ||= + begin + if ENV["RAKE_SYSTEM"] + ENV["RAKE_SYSTEM"] + else + standard_system_dir + end + end + end + + # The standard directory containing system wide rake files. + if Win32.windows? + def standard_system_dir #:nodoc: + Win32.win32_system_dir + end + else + def standard_system_dir #:nodoc: + File.join(File.expand_path("~"), ".rake") + end + end + private :standard_system_dir + + # Collect the list of tasks on the command line. If no tasks are + # given, return a list containing only the default task. + # Environmental assignments are processed at this time as well. + # + # `args` is the list of arguments to peruse to get the list of tasks. + # It should be the command line that was given to rake, less any + # recognised command-line options, which OptionParser.parse will + # have taken care of already. + def collect_command_line_tasks(args) # :nodoc: + @top_level_tasks = [] + args.each do |arg| + if arg =~ /^(\w+)=(.*)$/m + ENV[$1] = $2 + else + @top_level_tasks << arg unless arg =~ /^-/ + end + end + @top_level_tasks.push(default_task_name) if @top_level_tasks.empty? + end + + # Default task name ("default"). + # (May be overridden by subclasses) + def default_task_name # :nodoc: + "default" + end + + # Add a file to the list of files to be imported. + def add_import(fn) # :nodoc: + @pending_imports << fn + end + + # Load the pending list of imported files. + def load_imports # :nodoc: + while fn = @pending_imports.shift + next if @imported.member?(fn) + fn_task = lookup(fn) and fn_task.invoke + ext = File.extname(fn) + loader = @loaders[ext] || @default_loader + loader.load(fn) + if fn_task = lookup(fn) and fn_task.needed? + fn_task.reenable + fn_task.invoke + loader.load(fn) + end + @imported << fn + end + end + + def rakefile_location(backtrace=caller) # :nodoc: + backtrace.map { |t| t[/([^:]+):/, 1] } + + re = /^#{@rakefile}$/ + re = /#{re.source}/i if windows? + + backtrace.find { |str| str =~ re } || "" + end + + def set_default_options # :nodoc: + options.always_multitask = false + options.backtrace = false + options.build_all = false + options.dryrun = false + options.ignore_deprecate = false + options.ignore_system = false + options.job_stats = false + options.load_system = false + options.nosearch = false + options.rakelib = %w[rakelib] + options.show_all_tasks = false + options.show_prereqs = false + options.show_task_pattern = nil + options.show_tasks = nil + options.silent = false + options.suppress_backtrace_pattern = nil + options.thread_pool_size = Rake.suggested_thread_count + options.trace = false + options.trace_output = $stderr + options.trace_rules = false + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/backtrace.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/backtrace.rb new file mode 100644 index 0000000..c87f2f9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/backtrace.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true +module Rake + module Backtrace # :nodoc: all + SYS_KEYS = RbConfig::CONFIG.keys.grep(/(?:[a-z]prefix|libdir)\z/) + SYS_PATHS = RbConfig::CONFIG.values_at(*SYS_KEYS).uniq + + [ File.join(File.dirname(__FILE__), "..") ] + + SUPPRESSED_PATHS = SYS_PATHS. + map { |s| s.tr("\\", "/") }. + map { |f| File.expand_path(f) }. + reject { |s| s.nil? || s =~ /^ *$/ } + SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|") + SUPPRESSED_PATHS_RE << "|^" + SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if + Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == "jruby" + + SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i + + def self.collapse(backtrace) + pattern = Rake.application.options.suppress_backtrace_pattern || + SUPPRESS_PATTERN + backtrace.reject { |elem| elem =~ pattern } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/clean.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/clean.rb new file mode 100644 index 0000000..b52e832 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/clean.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true +# The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and +# two rake tasks (:clean and :clobber). +# +# [:clean] Clean up the project by deleting scratch files and backup +# files. Add files to the CLEAN file list to have the :clean +# target handle them. +# +# [:clobber] Clobber all generated and non-source files in a project. +# The task depends on :clean, so all the clean files will +# be deleted as well as files in the CLOBBER file list. +# The intent of this task is to return a project to its +# pristine, just unpacked state. + +require "rake" + +# :stopdoc: + +module Rake + module Cleaner + extend FileUtils + + module_function + + def cleanup_files(file_names) + file_names.each do |file_name| + cleanup(file_name) + end + end + + def cleanup(file_name, **opts) + begin + opts = { verbose: Rake.application.options.trace }.merge(opts) + rm_r file_name, **opts + rescue StandardError => ex + puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name) + end + end + + def file_already_gone?(file_name) + return false if File.exist?(file_name) + + path = file_name + prev = nil + + while path = File.dirname(path) + return false if cant_be_deleted?(path) + break if [prev, "."].include?(path) + prev = path + end + true + end + private_class_method :file_already_gone? + + def cant_be_deleted?(path_name) + File.exist?(path_name) && + (!File.readable?(path_name) || !File.executable?(path_name)) + end + private_class_method :cant_be_deleted? + end +end + +CLEAN = ::Rake::FileList["**/*~", "**/*.bak", "**/core"] +CLEAN.clear_exclude.exclude { |fn| + fn.pathmap("%f").downcase == "core" && File.directory?(fn) +} + +desc "Remove any temporary products." +task :clean do + Rake::Cleaner.cleanup_files(CLEAN) +end + +CLOBBER = ::Rake::FileList.new + +desc "Remove any generated files." +task clobber: [:clean] do + Rake::Cleaner.cleanup_files(CLOBBER) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/cloneable.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/cloneable.rb new file mode 100644 index 0000000..eddb77e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/cloneable.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +module Rake + ## + # Mixin for creating easily cloned objects. + + module Cloneable # :nodoc: + # The hook that is invoked by 'clone' and 'dup' methods. + def initialize_copy(source) + super + source.instance_variables.each do |var| + src_value = source.instance_variable_get(var) + value = src_value.clone rescue src_value + instance_variable_set(var, value) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/cpu_counter.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/cpu_counter.rb new file mode 100644 index 0000000..564a628 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/cpu_counter.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true +module Rake + + # Based on a script at: + # http://stackoverflow.com/questions/891537/ruby-detect-number-of-cpus-installed + class CpuCounter # :nodoc: all + def self.count + new.count_with_default + end + + def count_with_default(default=4) + count || default + rescue StandardError + default + end + + begin + require "etc" + rescue LoadError + else + if Etc.respond_to?(:nprocessors) + def count + return Etc.nprocessors + end + end + end + end +end + +unless Rake::CpuCounter.method_defined?(:count) + Rake::CpuCounter.class_eval <<-'end;', __FILE__, __LINE__+1 + require 'rbconfig' + + def count + if RUBY_PLATFORM == 'java' + count_via_java_runtime + else + case RbConfig::CONFIG['host_os'] + when /linux/ + count_via_cpuinfo + when /darwin|bsd/ + count_via_sysctl + when /mswin|mingw/ + count_via_win32 + else + # Try everything + count_via_win32 || + count_via_sysctl || + count_via_cpuinfo + end + end + end + + def count_via_java_runtime + Java::Java.lang.Runtime.getRuntime.availableProcessors + rescue StandardError + nil + end + + def count_via_win32 + require 'win32ole' + wmi = WIN32OLE.connect("winmgmts://") + cpu = wmi.ExecQuery("select NumberOfCores from Win32_Processor") # TODO count hyper-threaded in this + cpu.to_enum.first.NumberOfCores + rescue StandardError, LoadError + nil + end + + def count_via_cpuinfo + open('/proc/cpuinfo') { |f| f.readlines }.grep(/processor/).size + rescue StandardError + nil + end + + def count_via_sysctl + run 'sysctl', '-n', 'hw.ncpu' + end + + def run(command, *args) + cmd = resolve_command(command) + if cmd + IO.popen [cmd, *args] do |io| + io.read.to_i + end + else + nil + end + end + + def resolve_command(command) + look_for_command("/usr/sbin", command) || + look_for_command("/sbin", command) || + in_path_command(command) + end + + def look_for_command(dir, command) + path = File.join(dir, command) + File.exist?(path) ? path : nil + end + + def in_path_command(command) + IO.popen ['which', command] do |io| + io.eof? ? nil : command + end + end + end; +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/default_loader.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/default_loader.rb new file mode 100644 index 0000000..d3b4650 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/default_loader.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true +module Rake + + # Default Rakefile loader used by +import+. + class DefaultLoader + + ## + # Loads a rakefile into the current application from +fn+ + + def load(fn) + Rake.load_rakefile(File.expand_path(fn)) + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/dsl_definition.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/dsl_definition.rb new file mode 100644 index 0000000..6bd660c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/dsl_definition.rb @@ -0,0 +1,196 @@ +# frozen_string_literal: true +# Rake DSL functions. +require "rake/file_utils_ext" + +module Rake + + ## + # DSL is a module that provides #task, #desc, #namespace, etc. Use this + # when you'd like to use rake outside the top level scope. + # + # For a Rakefile you run from the command line this module is automatically + # included. + + module DSL + + #-- + # Include the FileUtils file manipulation functions in the top + # level module, but mark them private so that they don't + # unintentionally define methods on other objects. + #++ + + include FileUtilsExt + private(*FileUtils.instance_methods(false)) + private(*FileUtilsExt.instance_methods(false)) + + private + + # :call-seq: + # task(task_name) + # task(task_name: dependencies) + # task(task_name, arguments => dependencies) + # + # Declare a basic task. The +task_name+ is always the first argument. If + # the task name contains a ":" it is defined in that namespace. + # + # The +dependencies+ may be a single task name or an Array of task names. + # The +argument+ (a single name) or +arguments+ (an Array of names) define + # the arguments provided to the task. + # + # The task, argument and dependency names may be either symbols or + # strings. + # + # A task with a single dependency: + # + # task clobber: %w[clean] do + # rm_rf "html" + # end + # + # A task with an argument and a dependency: + # + # task :package, [:version] => :test do |t, args| + # # ... + # end + # + # To invoke this task from the command line: + # + # $ rake package[1.2.3] + # + def task(*args, &block) # :doc: + Rake::Task.define_task(*args, &block) + end + + # Declare a file task. + # + # Example: + # file "config.cfg" => ["config.template"] do + # open("config.cfg", "w") do |outfile| + # open("config.template") do |infile| + # while line = infile.gets + # outfile.puts line + # end + # end + # end + # end + # + def file(*args, &block) # :doc: + Rake::FileTask.define_task(*args, &block) + end + + # Declare a file creation task. + # (Mainly used for the directory command). + def file_create(*args, &block) + Rake::FileCreationTask.define_task(*args, &block) + end + + # Declare a set of files tasks to create the given directories on + # demand. + # + # Example: + # directory "testdata/doc" + # + def directory(*args, &block) # :doc: + args = args.flat_map { |arg| arg.is_a?(FileList) ? arg.to_a.flatten : arg } + result = file_create(*args, &block) + dir, _ = *Rake.application.resolve_args(args) + dir = Rake.from_pathname(dir) + Rake.each_dir_parent(dir) do |d| + file_create d do |t| + mkdir_p t.name unless File.exist?(t.name) + end + end + result + end + + # Declare a task that performs its prerequisites in + # parallel. Multitasks does *not* guarantee that its prerequisites + # will execute in any given order (which is obvious when you think + # about it) + # + # Example: + # multitask deploy: %w[deploy_gem deploy_rdoc] + # + def multitask(*args, &block) # :doc: + Rake::MultiTask.define_task(*args, &block) + end + + # Create a new rake namespace and use it for evaluating the given + # block. Returns a NameSpace object that can be used to lookup + # tasks defined in the namespace. + # + # Example: + # + # ns = namespace "nested" do + # # the "nested:run" task + # task :run + # end + # task_run = ns[:run] # find :run in the given namespace. + # + # Tasks can also be defined in a namespace by using a ":" in the task + # name: + # + # task "nested:test" do + # # ... + # end + # + def namespace(name=nil, &block) # :doc: + name = name.to_s if name.kind_of?(Symbol) + name = name.to_str if name.respond_to?(:to_str) + unless name.kind_of?(String) || name.nil? + raise ArgumentError, "Expected a String or Symbol for a namespace name" + end + Rake.application.in_namespace(name, &block) + end + + # Declare a rule for auto-tasks. + # + # Example: + # rule '.o' => '.c' do |t| + # sh 'cc', '-c', '-o', t.name, t.source + # end + # + def rule(*args, &block) # :doc: + Rake::Task.create_rule(*args, &block) + end + + # Describes the next rake task. Duplicate descriptions are discarded. + # Descriptions are shown with rake -T (up to the first + # sentence) and rake -D (the entire description). + # + # Example: + # desc "Run the Unit Tests" + # task test: [:build] do + # # ... run tests + # end + # + def desc(description) # :doc: + Rake.application.last_description = description + end + + # Import the partial Rakefiles +fn+. Imported files are loaded + # _after_ the current file is completely loaded. This allows the + # import statement to appear anywhere in the importing file, and yet + # allowing the imported files to depend on objects defined in the + # importing file. + # + # A common use of the import statement is to include files + # containing dependency declarations. + # + # See also the --rakelibdir command line option. + # + # Example: + # import ".depend", "my_rules" + # + def import(*fns) # :doc: + fns.each do |fn| + Rake.application.add_import(fn) + end + end + end + extend FileUtilsExt +end + +# Extend the main object with the DSL commands. This allows top-level +# calls to task, etc. to work from a Rakefile without polluting the +# object inheritance tree. +self.extend Rake::DSL diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/early_time.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/early_time.rb new file mode 100644 index 0000000..80cc6bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/early_time.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +module Rake + + # EarlyTime is a fake timestamp that occurs _before_ any other time value. + class EarlyTime + include Comparable + include Singleton + + ## + # The EarlyTime always comes before +other+! + + def <=>(other) + -1 + end + + def to_s # :nodoc: + "" + end + end + + EARLY = EarlyTime.instance +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/ext/core.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/ext/core.rb new file mode 100644 index 0000000..226f212 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/ext/core.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true +class Module + # Check for an existing method in the current class before extending. If + # the method already exists, then a warning is printed and the extension is + # not added. Otherwise the block is yielded and any definitions in the + # block will take effect. + # + # Usage: + # + # class String + # rake_extension("xyz") do + # def xyz + # ... + # end + # end + # end + # + def rake_extension(method) # :nodoc: + if method_defined?(method) + $stderr.puts "WARNING: Possible conflict with Rake extension: " + + "#{self}##{method} already exists" + else + yield + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/ext/string.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/ext/string.rb new file mode 100644 index 0000000..c70236a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/ext/string.rb @@ -0,0 +1,176 @@ +# frozen_string_literal: true +require "rake/ext/core" + +class String + + rake_extension("ext") do + # Replace the file extension with +newext+. If there is no extension on + # the string, append the new extension to the end. If the new extension + # is not given, or is the empty string, remove any existing extension. + # + # +ext+ is a user added method for the String class. + # + # This String extension comes from Rake + def ext(newext="") + return self.dup if [".", ".."].include? self + if newext != "" + newext = "." + newext unless newext =~ /^\./ + end + self.chomp(File.extname(self)) << newext + end + end + + rake_extension("pathmap") do + # Explode a path into individual components. Used by +pathmap+. + # + # This String extension comes from Rake + def pathmap_explode + head, tail = File.split(self) + return [self] if head == self + return [tail] if head == "." || tail == "/" + return [head, tail] if head == "/" + return head.pathmap_explode + [tail] + end + protected :pathmap_explode + + # Extract a partial path from the path. Include +n+ directories from the + # front end (left hand side) if +n+ is positive. Include |+n+| + # directories from the back end (right hand side) if +n+ is negative. + # + # This String extension comes from Rake + def pathmap_partial(n) + dirs = File.dirname(self).pathmap_explode + partial_dirs = + if n > 0 + dirs[0...n] + elsif n < 0 + dirs.reverse[0...-n].reverse + else + "." + end + File.join(partial_dirs) + end + protected :pathmap_partial + + # Perform the pathmap replacement operations on the given path. The + # patterns take the form 'pat1,rep1;pat2,rep2...'. + # + # This String extension comes from Rake + def pathmap_replace(patterns, &block) + result = self + patterns.split(";").each do |pair| + pattern, replacement = pair.split(",") + pattern = Regexp.new(pattern) + if replacement == "*" && block_given? + result = result.sub(pattern, &block) + elsif replacement + result = result.sub(pattern, replacement) + else + result = result.sub(pattern, "") + end + end + result + end + protected :pathmap_replace + + # Map the path according to the given specification. The specification + # controls the details of the mapping. The following special patterns are + # recognized: + # + # %p :: The complete path. + # %f :: The base file name of the path, with its file extension, + # but without any directories. + # %n :: The file name of the path without its file extension. + # %d :: The directory list of the path. + # %x :: The file extension of the path. An empty string if there + # is no extension. + # %X :: Everything *but* the file extension. + # %s :: The alternate file separator if defined, otherwise use # + # the standard file separator. + # %% :: A percent sign. + # + # The %d specifier can also have a numeric prefix (e.g. '%2d'). + # If the number is positive, only return (up to) +n+ directories in the + # path, starting from the left hand side. If +n+ is negative, return (up + # to) +n+ directories from the right hand side of the path. + # + # Examples: + # + # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b' + # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d' + # + # Also the %d, %p, %f, %n, + # %x, and %X operators can take a pattern/replacement + # argument to perform simple string substitutions on a particular part of + # the path. The pattern and replacement are separated by a comma and are + # enclosed by curly braces. The replacement spec comes after the % + # character but before the operator letter. (e.g. "%{old,new}d"). + # Multiple replacement specs should be separated by semi-colons (e.g. + # "%{old,new;src,bin}d"). + # + # Regular expressions may be used for the pattern, and back refs may be + # used in the replacement text. Curly braces, commas and semi-colons are + # excluded from both the pattern and replacement text (let's keep parsing + # reasonable). + # + # For example: + # + # "src/org/onestepback/proj/A.java".pathmap("%{^src,class}X.class") + # + # returns: + # + # "class/org/onestepback/proj/A.class" + # + # If the replacement text is '*', then a block may be provided to perform + # some arbitrary calculation for the replacement. + # + # For example: + # + # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext| + # ext.downcase + # } + # + # Returns: + # + # "/path/to/file.txt" + # + # This String extension comes from Rake + def pathmap(spec=nil, &block) + return self if spec.nil? + result = "".dup + spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag| + case frag + when "%f" + result << File.basename(self) + when "%n" + result << File.basename(self).ext + when "%d" + result << File.dirname(self) + when "%x" + result << File.extname(self) + when "%X" + result << self.ext + when "%p" + result << self + when "%s" + result << (File::ALT_SEPARATOR || File::SEPARATOR) + when "%-" + # do nothing + when "%%" + result << "%" + when /%(-?\d+)d/ + result << pathmap_partial($1.to_i) + when /^%\{([^}]*)\}(\d*[dpfnxX])/ + patterns, operator = $1, $2 + result << pathmap("%" + operator).pathmap_replace(patterns, &block) + when /^%/ + fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'" + else + result << frag + end + end + result + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_creation_task.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_creation_task.rb new file mode 100644 index 0000000..5a4c684 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_creation_task.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true +require "rake/file_task" +require "rake/early_time" + +module Rake + + # A FileCreationTask is a file task that when used as a dependency will be + # needed if and only if the file has not been created. Once created, it is + # not re-triggered if any of its dependencies are newer, nor does trigger + # any rebuilds of tasks that depend on it whenever it is updated. + # + class FileCreationTask < FileTask + # Is this file task needed? Yes if it doesn't exist. + def needed? + !File.exist?(name) + end + + # Time stamp for file creation task. This time stamp is earlier + # than any other time stamp. + def timestamp + Rake::EARLY + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_list.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_list.rb new file mode 100644 index 0000000..22c339f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_list.rb @@ -0,0 +1,435 @@ +# frozen_string_literal: true +require "rake/cloneable" +require "rake/file_utils_ext" +require "rake/ext/string" + +module Rake + + ## + # A FileList is essentially an array with a few helper methods defined to + # make file manipulation a bit easier. + # + # FileLists are lazy. When given a list of glob patterns for possible files + # to be included in the file list, instead of searching the file structures + # to find the files, a FileList holds the pattern for latter use. + # + # This allows us to define a number of FileList to match any number of + # files, but only search out the actual files when then FileList itself is + # actually used. The key is that the first time an element of the + # FileList/Array is requested, the pending patterns are resolved into a real + # list of file names. + # + class FileList + + include Cloneable + + # == Method Delegation + # + # The lazy evaluation magic of FileLists happens by implementing all the + # array specific methods to call +resolve+ before delegating the heavy + # lifting to an embedded array object (@items). + # + # In addition, there are two kinds of delegation calls. The regular kind + # delegates to the @items array and returns the result directly. Well, + # almost directly. It checks if the returned value is the @items object + # itself, and if so will return the FileList object instead. + # + # The second kind of delegation call is used in methods that normally + # return a new Array object. We want to capture the return value of these + # methods and wrap them in a new FileList object. We enumerate these + # methods in the +SPECIAL_RETURN+ list below. + + # List of array methods (that are not in +Object+) that need to be + # delegated. + ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map(&:to_s) + + # List of additional methods that must be delegated. + MUST_DEFINE = %w[inspect <=>] + + # List of methods that should not be delegated here (we define special + # versions of them explicitly below). + MUST_NOT_DEFINE = %w[to_a to_ary partition * <<] + + # List of delegated methods that return new array values which need + # wrapping. + SPECIAL_RETURN = %w[ + map collect sort sort_by select find_all reject grep + compact flatten uniq values_at + + - & | + ] + + DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).map(&:to_s).sort.uniq + + # Now do the delegation. + DELEGATING_METHODS.each do |sym| + if SPECIAL_RETURN.include?(sym) + ln = __LINE__ + 1 + class_eval %{ + def #{sym}(*args, &block) + resolve + result = @items.send(:#{sym}, *args, &block) + self.class.new.import(result) + end + }, __FILE__, ln + else + ln = __LINE__ + 1 + class_eval %{ + def #{sym}(*args, &block) + resolve + result = @items.send(:#{sym}, *args, &block) + result.object_id == @items.object_id ? self : result + end + }, __FILE__, ln + end + end + + GLOB_PATTERN = %r{[*?\[\{]} + + # Create a file list from the globbable patterns given. If you wish to + # perform multiple includes or excludes at object build time, use the + # "yield self" pattern. + # + # Example: + # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb') + # + # pkg_files = FileList.new('lib/**/*') do |fl| + # fl.exclude(/\bCVS\b/) + # end + # + def initialize(*patterns) + @pending_add = [] + @pending = false + @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup + @exclude_procs = DEFAULT_IGNORE_PROCS.dup + @items = [] + patterns.each { |pattern| include(pattern) } + yield self if block_given? + end + + # Add file names defined by glob patterns to the file list. If an array + # is given, add each element of the array. + # + # Example: + # file_list.include("*.java", "*.cfg") + # file_list.include %w( math.c lib.h *.o ) + # + def include(*filenames) + # TODO: check for pending + filenames.each do |fn| + if fn.respond_to? :to_ary + include(*fn.to_ary) + else + @pending_add << Rake.from_pathname(fn) + end + end + @pending = true + self + end + alias :add :include + + # Register a list of file name patterns that should be excluded from the + # list. Patterns may be regular expressions, glob patterns or regular + # strings. In addition, a block given to exclude will remove entries that + # return true when given to the block. + # + # Note that glob patterns are expanded against the file system. If a file + # is explicitly added to a file list, but does not exist in the file + # system, then an glob pattern in the exclude list will not exclude the + # file. + # + # Examples: + # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c'] + # FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c'] + # + # If "a.c" is a file, then ... + # FileList['a.c', 'b.c'].exclude("a.*") => ['b.c'] + # + # If "a.c" is not a file, then ... + # FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c'] + # + def exclude(*patterns, &block) + patterns.each do |pat| + if pat.respond_to? :to_ary + exclude(*pat.to_ary) + else + @exclude_patterns << Rake.from_pathname(pat) + end + end + @exclude_procs << block if block_given? + resolve_exclude unless @pending + self + end + + # Clear all the exclude patterns so that we exclude nothing. + def clear_exclude + @exclude_patterns = [] + @exclude_procs = [] + self + end + + # A FileList is equal through array equality. + def ==(array) + to_ary == array + end + + # Return the internal array object. + def to_a + resolve + @items + end + + # Return the internal array object. + def to_ary + to_a + end + + # Lie about our class. + def is_a?(klass) + klass == Array || super(klass) + end + alias kind_of? is_a? + + # Redefine * to return either a string or a new file list. + def *(other) + result = @items * other + case result + when Array + self.class.new.import(result) + else + result + end + end + + def <<(obj) + resolve + @items << Rake.from_pathname(obj) + self + end + + # Resolve all the pending adds now. + def resolve + if @pending + @pending = false + @pending_add.each do |fn| resolve_add(fn) end + @pending_add = [] + resolve_exclude + end + self + end + + def resolve_add(fn) # :nodoc: + case fn + when GLOB_PATTERN + add_matching(fn) + else + self << fn + end + end + private :resolve_add + + def resolve_exclude # :nodoc: + reject! { |fn| excluded_from_list?(fn) } + self + end + private :resolve_exclude + + # Return a new FileList with the results of running +sub+ against each + # element of the original list. + # + # Example: + # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o'] + # + def sub(pat, rep) + inject(self.class.new) { |res, fn| res << fn.sub(pat, rep) } + end + + # Return a new FileList with the results of running +gsub+ against each + # element of the original list. + # + # Example: + # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\") + # => ['lib\\test\\file', 'x\\y'] + # + def gsub(pat, rep) + inject(self.class.new) { |res, fn| res << fn.gsub(pat, rep) } + end + + # Same as +sub+ except that the original file list is modified. + def sub!(pat, rep) + each_with_index { |fn, i| self[i] = fn.sub(pat, rep) } + self + end + + # Same as +gsub+ except that the original file list is modified. + def gsub!(pat, rep) + each_with_index { |fn, i| self[i] = fn.gsub(pat, rep) } + self + end + + # Apply the pathmap spec to each of the included file names, returning a + # new file list with the modified paths. (See String#pathmap for + # details.) + def pathmap(spec=nil, &block) + collect { |fn| fn.pathmap(spec, &block) } + end + + # Return a new FileList with String#ext method applied to + # each member of the array. + # + # This method is a shortcut for: + # + # array.collect { |item| item.ext(newext) } + # + # +ext+ is a user added method for the Array class. + def ext(newext="") + collect { |fn| fn.ext(newext) } + end + + # Grep each of the files in the filelist using the given pattern. If a + # block is given, call the block on each matching line, passing the file + # name, line number, and the matching line of text. If no block is given, + # a standard emacs style file:linenumber:line message will be printed to + # standard out. Returns the number of matched items. + def egrep(pattern, *options) + matched = 0 + each do |fn| + begin + File.open(fn, "r", *options) do |inf| + count = 0 + inf.each do |line| + count += 1 + if pattern.match(line) + matched += 1 + if block_given? + yield fn, count, line + else + puts "#{fn}:#{count}:#{line}" + end + end + end + end + rescue StandardError => ex + $stderr.puts "Error while processing '#{fn}': #{ex}" + end + end + matched + end + + # Return a new file list that only contains file names from the current + # file list that exist on the file system. + def existing + select { |fn| File.exist?(fn) }.uniq + end + + # Modify the current file list so that it contains only file name that + # exist on the file system. + def existing! + resolve + @items = @items.select { |fn| File.exist?(fn) }.uniq + self + end + + # FileList version of partition. Needed because the nested arrays should + # be FileLists in this version. + def partition(&block) # :nodoc: + resolve + result = @items.partition(&block) + [ + self.class.new.import(result[0]), + self.class.new.import(result[1]), + ] + end + + # Convert a FileList to a string by joining all elements with a space. + def to_s + resolve + self.join(" ") + end + + # Add matching glob patterns. + def add_matching(pattern) + self.class.glob(pattern).each do |fn| + self << fn unless excluded_from_list?(fn) + end + end + private :add_matching + + # Should the given file name be excluded from the list? + # + # NOTE: This method was formerly named "exclude?", but Rails + # introduced an exclude? method as an array method and setup a + # conflict with file list. We renamed the method to avoid + # confusion. If you were using "FileList#exclude?" in your user + # code, you will need to update. + def excluded_from_list?(fn) + return true if @exclude_patterns.any? do |pat| + case pat + when Regexp + fn =~ pat + when GLOB_PATTERN + flags = File::FNM_PATHNAME + # Ruby <= 1.9.3 does not support File::FNM_EXTGLOB + flags |= File::FNM_EXTGLOB if defined? File::FNM_EXTGLOB + File.fnmatch?(pat, fn, flags) + else + fn == pat + end + end + @exclude_procs.any? { |p| p.call(fn) } + end + + DEFAULT_IGNORE_PATTERNS = [ + /(^|[\/\\])CVS([\/\\]|$)/, + /(^|[\/\\])\.svn([\/\\]|$)/, + /\.bak$/, + /~$/ + ] + DEFAULT_IGNORE_PROCS = [ + proc { |fn| fn =~ /(^|[\/\\])core$/ && !File.directory?(fn) } + ] + + def import(array) # :nodoc: + @items = array + self + end + + class << self + # Create a new file list including the files listed. Similar to: + # + # FileList.new(*args) + def [](*args) + new(*args) + end + + # Get a sorted list of files matching the pattern. This method + # should be preferred to Dir[pattern] and Dir.glob(pattern) because + # the files returned are guaranteed to be sorted. + def glob(pattern, *args) + Dir.glob(pattern, *args).sort + end + end + end +end + +module Rake + class << self + + # Yield each file or directory component. + def each_dir_parent(dir) # :nodoc: + old_length = nil + while dir != "." && dir.length != old_length + yield(dir) + old_length = dir.length + dir = File.dirname(dir) + end + end + + # Convert Pathname and Pathname-like objects to strings; + # leave everything else alone + def from_pathname(path) # :nodoc: + path = path.to_path if path.respond_to?(:to_path) + path = path.to_str if path.respond_to?(:to_str) + path + end + end +end # module Rake diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_task.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_task.rb new file mode 100644 index 0000000..c36b496 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_task.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true +require "rake/task" +require "rake/early_time" + +module Rake + + # A FileTask is a task that includes time based dependencies. If any of a + # FileTask's prerequisites have a timestamp that is later than the file + # represented by this task, then the file must be rebuilt (using the + # supplied actions). + # + class FileTask < Task + + # Is this file task needed? Yes if it doesn't exist, or if its time stamp + # is out of date. + def needed? + begin + out_of_date?(File.mtime(name)) || @application.options.build_all + rescue Errno::ENOENT + true + end + end + + # Time stamp for file task. + def timestamp + begin + File.mtime(name) + rescue Errno::ENOENT + Rake::LATE + end + end + + private + + # Are there any prerequisites with a later time than the given time stamp? + def out_of_date?(stamp) + all_prerequisite_tasks.any? { |prereq| + prereq_task = application[prereq, @scope] + if prereq_task.instance_of?(Rake::FileTask) + prereq_task.timestamp > stamp || @application.options.build_all + else + prereq_task.timestamp > stamp + end + } + end + + # ---------------------------------------------------------------- + # Task class methods. + # + class << self + # Apply the scope to the task name according to the rules for this kind + # of task. File based tasks ignore the scope when creating the name. + def scope_name(scope, task_name) + Rake.from_pathname(task_name) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_utils.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_utils.rb new file mode 100644 index 0000000..1510d95 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_utils.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true +require "rbconfig" +require "fileutils" + +#-- +# This a FileUtils extension that defines several additional commands to be +# added to the FileUtils utility functions. +module FileUtils + # Path to the currently running Ruby program + RUBY = ENV["RUBY"] || File.join( + RbConfig::CONFIG["bindir"], + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]). + sub(/.*\s.*/m, '"\&"') + + # Run the system command +cmd+. If multiple arguments are given the command + # is run directly (without the shell, same semantics as Kernel::exec and + # Kernel::system). + # + # It is recommended you use the multiple argument form over interpolating + # user input for both usability and security reasons. With the multiple + # argument form you can easily process files with spaces or other shell + # reserved characters in them. With the multiple argument form your rake + # tasks are not vulnerable to users providing an argument like + # ; rm # -rf /. + # + # If a block is given, upon command completion the block is called with an + # OK flag (true on a zero exit status) and a Process::Status object. + # Without a block a RuntimeError is raised when the command exits non-zero. + # + # Examples: + # + # sh 'ls -ltr' + # + # sh 'ls', 'file with spaces' + # + # # check exit status after command runs + # sh %{grep pattern file} do |ok, res| + # if !ok + # puts "pattern not found (status = #{res.exitstatus})" + # end + # end + # + def sh(*cmd, &block) + options = (Hash === cmd.last) ? cmd.pop : {} + shell_runner = block_given? ? block : create_shell_runner(cmd) + + set_verbose_option(options) + verbose = options.delete :verbose + noop = options.delete(:noop) || Rake::FileUtilsExt.nowrite_flag + + Rake.rake_output_message sh_show_command cmd if verbose + + unless noop + res = (Hash === cmd.last) ? system(*cmd) : system(*cmd, options) + status = $? + status = Rake::PseudoStatus.new(1) if !res && status.nil? + shell_runner.call(res, status) + end + end + + def create_shell_runner(cmd) # :nodoc: + show_command = sh_show_command cmd + lambda do |ok, status| + ok or + fail "Command failed with status (#{status.exitstatus}): " + + "[#{show_command}]" + end + end + private :create_shell_runner + + def sh_show_command(cmd) # :nodoc: + cmd = cmd.dup + + if Hash === cmd.first + env = cmd.first + env = env.map { |name, value| "#{name}=#{value}" }.join " " + cmd[0] = env + end + + cmd.join " " + end + private :sh_show_command + + def set_verbose_option(options) # :nodoc: + unless options.key? :verbose + options[:verbose] = + (Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT) || + Rake::FileUtilsExt.verbose_flag + end + end + private :set_verbose_option + + # Run a Ruby interpreter with the given arguments. + # + # Example: + # ruby %{-pe '$_.upcase!' 1 + sh(RUBY, *args, **options, &block) + else + sh("#{RUBY} #{args.first}", **options, &block) + end + end + + LN_SUPPORTED = [true] + + # Attempt to do a normal file link, but fall back to a copy if the link + # fails. + def safe_ln(*args, **options) + if LN_SUPPORTED[0] + begin + return options.empty? ? ln(*args) : ln(*args, **options) + rescue StandardError, NotImplementedError + LN_SUPPORTED[0] = false + end + end + options.empty? ? cp(*args) : cp(*args, **options) + end + + # Split a file path into individual directory names. + # + # Example: + # split_all("a/b/c") => ['a', 'b', 'c'] + # + def split_all(path) + head, tail = File.split(path) + return [tail] if head == "." || tail == "/" + return [head, tail] if head == "/" + return split_all(head) + [tail] + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_utils_ext.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_utils_ext.rb new file mode 100644 index 0000000..e91ad59 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/file_utils_ext.rb @@ -0,0 +1,134 @@ +# frozen_string_literal: true +require "rake/file_utils" + +module Rake + # + # FileUtilsExt provides a custom version of the FileUtils methods + # that respond to the verbose and nowrite + # commands. + # + module FileUtilsExt + include FileUtils + + class << self + attr_accessor :verbose_flag, :nowrite_flag + end + + DEFAULT = Object.new + + FileUtilsExt.verbose_flag = DEFAULT + FileUtilsExt.nowrite_flag = false + + FileUtils.commands.each do |name| + opts = FileUtils.options_of name + default_options = [] + if opts.include?("verbose") + default_options << "verbose: FileUtilsExt.verbose_flag" + end + if opts.include?("noop") + default_options << "noop: FileUtilsExt.nowrite_flag" + end + + next if default_options.empty? + module_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{name}(*args, **options, &block) + super(*args, + #{default_options.join(', ')}, + **options, &block) + end + EOS + end + + # Get/set the verbose flag controlling output from the FileUtils + # utilities. If verbose is true, then the utility method is + # echoed to standard output. + # + # Examples: + # verbose # return the current value of the + # # verbose flag + # verbose(v) # set the verbose flag to _v_. + # verbose(v) { code } # Execute code with the verbose flag set + # # temporarily to _v_. Return to the + # # original value when code is done. + def verbose(value=nil) + oldvalue = FileUtilsExt.verbose_flag + FileUtilsExt.verbose_flag = value unless value.nil? + if block_given? + begin + yield + ensure + FileUtilsExt.verbose_flag = oldvalue + end + end + FileUtilsExt.verbose_flag + end + + # Get/set the nowrite flag controlling output from the FileUtils + # utilities. If verbose is true, then the utility method is + # echoed to standard output. + # + # Examples: + # nowrite # return the current value of the + # # nowrite flag + # nowrite(v) # set the nowrite flag to _v_. + # nowrite(v) { code } # Execute code with the nowrite flag set + # # temporarily to _v_. Return to the + # # original value when code is done. + def nowrite(value=nil) + oldvalue = FileUtilsExt.nowrite_flag + FileUtilsExt.nowrite_flag = value unless value.nil? + if block_given? + begin + yield + ensure + FileUtilsExt.nowrite_flag = oldvalue + end + end + oldvalue + end + + # Use this function to prevent potentially destructive ruby code + # from running when the :nowrite flag is set. + # + # Example: + # + # when_writing("Building Project") do + # project.build + # end + # + # The following code will build the project under normal + # conditions. If the nowrite(true) flag is set, then the example + # will print: + # + # DRYRUN: Building Project + # + # instead of actually building the project. + # + def when_writing(msg=nil) + if FileUtilsExt.nowrite_flag + $stderr.puts "DRYRUN: #{msg}" if msg + else + yield + end + end + + # Send the message to the default rake output (which is $stderr). + def rake_output_message(message) + $stderr.puts(message) + end + + # Check that the options do not contain options not listed in + # +optdecl+. An ArgumentError exception is thrown if non-declared + # options are found. + def rake_check_options(options, *optdecl) + h = options.dup + optdecl.each do |name| + h.delete name + end + raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless + h.empty? + end + + extend self + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/invocation_chain.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/invocation_chain.rb new file mode 100644 index 0000000..44a9954 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/invocation_chain.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +module Rake + + # InvocationChain tracks the chain of task invocations to detect + # circular dependencies. + class InvocationChain < LinkedList + + # Is the invocation already in the chain? + def member?(invocation) + head == invocation || tail.member?(invocation) + end + + # Append an invocation to the chain of invocations. It is an error + # if the invocation already listed. + def append(invocation) + if member?(invocation) + fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}" + end + conj(invocation) + end + + # Convert to string, ie: TOP => invocation => invocation + def to_s + "#{prefix}#{head}" + end + + # Class level append. + def self.append(invocation, chain) + chain.append(invocation) + end + + private + + def prefix + "#{tail} => " + end + + # Null object for an empty chain. + class EmptyInvocationChain < LinkedList::EmptyLinkedList + @parent = InvocationChain + + def member?(obj) + false + end + + def append(invocation) + conj(invocation) + end + + def to_s + "TOP" + end + end + + EMPTY = EmptyInvocationChain.new + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/invocation_exception_mixin.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/invocation_exception_mixin.rb new file mode 100644 index 0000000..b0d307a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/invocation_exception_mixin.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +module Rake + module InvocationExceptionMixin + # Return the invocation chain (list of Rake tasks) that were in + # effect when this exception was detected by rake. May be null if + # no tasks were active. + def chain + @rake_invocation_chain ||= nil + end + + # Set the invocation chain in effect when this exception was + # detected. + def chain=(value) + @rake_invocation_chain = value + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/late_time.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/late_time.rb new file mode 100644 index 0000000..8fe0249 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/late_time.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +module Rake + # LateTime is a fake timestamp that occurs _after_ any other time value. + class LateTime + include Comparable + include Singleton + + def <=>(other) + 1 + end + + def to_s + "" + end + end + + LATE = LateTime.instance +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/linked_list.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/linked_list.rb new file mode 100644 index 0000000..11fa46f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/linked_list.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true +module Rake + + # Polylithic linked list structure used to implement several data + # structures in Rake. + class LinkedList + include Enumerable + attr_reader :head, :tail + + # Polymorphically add a new element to the head of a list. The + # type of head node will be the same list type as the tail. + def conj(item) + self.class.cons(item, self) + end + + # Is the list empty? + # .make guards against a list being empty making any instantiated LinkedList + # object not empty by default + # You should consider overriding this method if you implement your own .make method + def empty? + false + end + + # Lists are structurally equivalent. + def ==(other) + current = self + while !current.empty? && !other.empty? + return false if current.head != other.head + current = current.tail + other = other.tail + end + current.empty? && other.empty? + end + + # Convert to string: LL(item, item...) + def to_s + items = map(&:to_s).join(", ") + "LL(#{items})" + end + + # Same as +to_s+, but with inspected items. + def inspect + items = map(&:inspect).join(", ") + "LL(#{items})" + end + + # For each item in the list. + def each + current = self + while !current.empty? + yield(current.head) + current = current.tail + end + self + end + + # Make a list out of the given arguments. This method is + # polymorphic + def self.make(*args) + # return an EmptyLinkedList if there are no arguments + return empty if !args || args.empty? + + # build a LinkedList by starting at the tail and iterating + # through each argument + # inject takes an EmptyLinkedList to start + args.reverse.inject(empty) do |list, item| + list = cons(item, list) + list # return the newly created list for each item in the block + end + end + + # Cons a new head onto the tail list. + def self.cons(head, tail) + new(head, tail) + end + + # The standard empty list class for the given LinkedList class. + def self.empty + self::EMPTY + end + + protected + + def initialize(head, tail=EMPTY) + @head = head + @tail = tail + end + + # Represent an empty list, using the Null Object Pattern. + # + # When inheriting from the LinkedList class, you should implement + # a type specific Empty class as well. Make sure you set the class + # instance variable @parent to the associated list class (this + # allows conj, cons and make to work polymorphically). + class EmptyLinkedList < LinkedList + @parent = LinkedList + + def initialize + end + + def empty? + true + end + + def self.cons(head, tail) + @parent.cons(head, tail) + end + end + + EMPTY = EmptyLinkedList.new + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/loaders/makefile.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/loaders/makefile.rb new file mode 100644 index 0000000..46f4bea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/loaders/makefile.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true +module Rake + + # Makefile loader to be used with the import file loader. Use this to + # import dependencies from make dependency tools: + # + # require 'rake/loaders/makefile' + # + # file ".depends.mf" => [SRC_LIST] do |t| + # sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}" + # end + # + # import ".depends.mf" + # + # See {Importing Dependencies}[link:doc/rakefile_rdoc.html#label-Importing+Dependencies] + # for further details. + + class MakefileLoader + include Rake::DSL + + SPACE_MARK = "\0" # :nodoc: + + # Load the makefile dependencies in +fn+. + def load(fn) # :nodoc: + lines = File.read fn + lines.gsub!(/\\ /, SPACE_MARK) + lines.gsub!(/#[^\n]*\n/m, "") + lines.gsub!(/\\\n/, " ") + lines.each_line do |line| + process_line(line) + end + end + + private + + # Process one logical line of makefile data. + def process_line(line) # :nodoc: + file_tasks, args = line.split(":", 2) + return if args.nil? + dependents = args.split.map { |d| respace(d) } + file_tasks.scan(/\S+/) do |file_task| + file_task = respace(file_task) + file file_task => dependents + end + end + + def respace(str) # :nodoc: + str.tr SPACE_MARK, " " + end + end + + # Install the handler + Rake.application.add_loader("mf", MakefileLoader.new) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/multi_task.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/multi_task.rb new file mode 100644 index 0000000..3ae363c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/multi_task.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true +module Rake + + # Same as a regular task, but the immediate prerequisites are done in + # parallel using Ruby threads. + # + class MultiTask < Task + private + + def invoke_prerequisites(task_args, invocation_chain) # :nodoc: + invoke_prerequisites_concurrently(task_args, invocation_chain) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/name_space.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/name_space.rb new file mode 100644 index 0000000..32f8139 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/name_space.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true +## +# The NameSpace class will lookup task names in the scope defined by a +# +namespace+ command. + +class Rake::NameSpace + + ## + # Create a namespace lookup object using the given task manager + # and the list of scopes. + + def initialize(task_manager, scope_list) + @task_manager = task_manager + @scope = scope_list.dup + end + + ## + # Lookup a task named +name+ in the namespace. + + def [](name) + @task_manager.lookup(name, @scope) + end + + ## + # The scope of the namespace (a LinkedList) + + def scope + @scope.dup + end + + ## + # Return the list of tasks defined in this and nested namespaces. + + def tasks + @task_manager.tasks_in_scope(@scope) + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/packagetask.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/packagetask.rb new file mode 100644 index 0000000..1b014d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/packagetask.rb @@ -0,0 +1,222 @@ +# frozen_string_literal: true +# Define a package task library to aid in the definition of +# redistributable package files. + +require "rake" +require "rake/tasklib" + +module Rake + + # Create a packaging task that will package the project into + # distributable files (e.g zip archive or tar files). + # + # The PackageTask will create the following targets: + # + # +:package+ :: + # Create all the requested package files. + # + # +:clobber_package+ :: + # Delete all the package files. This target is automatically + # added to the main clobber target. + # + # +:repackage+ :: + # Rebuild the package files from scratch, even if they are not out + # of date. + # + # "package_dir/name-version.tgz" :: + # Create a gzipped tar package (if need_tar is true). + # + # "package_dir/name-version.tar.gz" :: + # Create a gzipped tar package (if need_tar_gz is true). + # + # "package_dir/name-version.tar.bz2" :: + # Create a bzip2'd tar package (if need_tar_bz2 is true). + # + # "package_dir/name-version.zip" :: + # Create a zip package archive (if need_zip is true). + # + # Example: + # + # Rake::PackageTask.new("rake", "1.2.3") do |p| + # p.need_tar = true + # p.package_files.include("lib/**/*.rb") + # end + # + class PackageTask < TaskLib + # Name of the package (from the GEM Spec). + attr_accessor :name + + # Version of the package (e.g. '1.3.2'). + attr_accessor :version + + # Directory used to store the package files (default is 'pkg'). + attr_accessor :package_dir + + # True if a gzipped tar file (tgz) should be produced (default is + # false). + attr_accessor :need_tar + + # True if a gzipped tar file (tar.gz) should be produced (default + # is false). + attr_accessor :need_tar_gz + + # True if a bzip2'd tar file (tar.bz2) should be produced (default + # is false). + attr_accessor :need_tar_bz2 + + # True if a xz'd tar file (tar.xz) should be produced (default is false) + attr_accessor :need_tar_xz + + # True if a zip file should be produced (default is false) + attr_accessor :need_zip + + # List of files to be included in the package. + attr_accessor :package_files + + # Tar command for gzipped or bzip2ed archives. The default is 'tar'. + attr_accessor :tar_command + + # Zip command for zipped archives. The default is 'zip'. + attr_accessor :zip_command + + # True if parent directory should be omitted (default is false) + attr_accessor :without_parent_dir + + # Create a Package Task with the given name and version. Use +:noversion+ + # as the version to build a package without a version or to provide a + # fully-versioned package name. + + def initialize(name=nil, version=nil) + init(name, version) + yield self if block_given? + define unless name.nil? + end + + # Initialization that bypasses the "yield self" and "define" step. + def init(name, version) + @name = name + @version = version + @package_files = Rake::FileList.new + @package_dir = "pkg" + @need_tar = false + @need_tar_gz = false + @need_tar_bz2 = false + @need_tar_xz = false + @need_zip = false + @tar_command = "tar" + @zip_command = "zip" + @without_parent_dir = false + end + + # Create the tasks defined by this task library. + def define + fail "Version required (or :noversion)" if @version.nil? + @version = nil if :noversion == @version + + desc "Build all the packages" + task :package + + desc "Force a rebuild of the package files" + task repackage: [:clobber_package, :package] + + desc "Remove package products" + task :clobber_package do + rm_r package_dir rescue nil + end + + task clobber: [:clobber_package] + + [ + [need_tar, tgz_file, "z"], + [need_tar_gz, tar_gz_file, "z"], + [need_tar_bz2, tar_bz2_file, "j"], + [need_tar_xz, tar_xz_file, "J"] + ].each do |need, file, flag| + if need + task package: ["#{package_dir}/#{file}"] + file "#{package_dir}/#{file}" => + [package_dir_path] + package_files do + chdir(working_dir) { sh @tar_command, "#{flag}cvf", file, target_dir } + mv "#{package_dir_path}/#{target_dir}", package_dir if without_parent_dir + end + end + end + + if need_zip + task package: ["#{package_dir}/#{zip_file}"] + file "#{package_dir}/#{zip_file}" => + [package_dir_path] + package_files do + chdir(working_dir) { sh @zip_command, "-r", zip_file, target_dir } + mv "#{package_dir_path}/#{zip_file}", package_dir if without_parent_dir + end + end + + directory package_dir_path => @package_files do + @package_files.each do |fn| + f = File.join(package_dir_path, fn) + fdir = File.dirname(f) + mkdir_p(fdir) unless File.exist?(fdir) + if File.directory?(fn) + mkdir_p(f) + else + rm_f f + safe_ln(fn, f) + end + end + end + self + end + + # The name of this package + + def package_name + @version ? "#{@name}-#{@version}" : @name + end + + # The directory this package will be built in + + def package_dir_path + "#{package_dir}/#{package_name}" + end + + # The package name with .tgz added + + def tgz_file + "#{package_name}.tgz" + end + + # The package name with .tar.gz added + + def tar_gz_file + "#{package_name}.tar.gz" + end + + # The package name with .tar.bz2 added + + def tar_bz2_file + "#{package_name}.tar.bz2" + end + + # The package name with .tar.xz added + + def tar_xz_file + "#{package_name}.tar.xz" + end + + # The package name with .zip added + + def zip_file + "#{package_name}.zip" + end + + def working_dir + without_parent_dir ? package_dir_path : package_dir + end + + # target directory relative to working_dir + def target_dir + without_parent_dir ? "." : package_name + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/phony.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/phony.rb new file mode 100644 index 0000000..8caa5de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/phony.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true +# Defines a :phony task that you can use as a dependency. This allows +# file-based tasks to use non-file-based tasks as prerequisites +# without forcing them to rebuild. +# +# See FileTask#out_of_date? and Task#timestamp for more info. + +require "rake" + +task :phony + +Rake::Task[:phony].tap do |task| + def task.timestamp # :nodoc: + Time.at 0 + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/private_reader.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/private_reader.rb new file mode 100644 index 0000000..2815ce6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/private_reader.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +module Rake + + # Include PrivateReader to use +private_reader+. + module PrivateReader # :nodoc: all + + def self.included(base) + base.extend(ClassMethods) + end + + module ClassMethods + + # Declare a list of private accessors + def private_reader(*names) + attr_reader(*names) + private(*names) + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/promise.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/promise.rb new file mode 100644 index 0000000..f45af4f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/promise.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true +module Rake + + # A Promise object represents a promise to do work (a chore) in the + # future. The promise is created with a block and a list of + # arguments for the block. Calling value will return the value of + # the promised chore. + # + # Used by ThreadPool. + # + class Promise # :nodoc: all + NOT_SET = Object.new.freeze # :nodoc: + + attr_accessor :recorder + + # Create a promise to do the chore specified by the block. + def initialize(args, &block) + @mutex = Mutex.new + @result = NOT_SET + @error = NOT_SET + @args = args + @block = block + end + + # Return the value of this promise. + # + # If the promised chore is not yet complete, then do the work + # synchronously. We will wait. + def value + unless complete? + stat :sleeping_on, item_id: object_id + @mutex.synchronize do + stat :has_lock_on, item_id: object_id + chore + stat :releasing_lock_on, item_id: object_id + end + end + error? ? raise(@error) : @result + end + + # If no one else is working this promise, go ahead and do the chore. + def work + stat :attempting_lock_on, item_id: object_id + if @mutex.try_lock + stat :has_lock_on, item_id: object_id + chore + stat :releasing_lock_on, item_id: object_id + @mutex.unlock + else + stat :bailed_on, item_id: object_id + end + end + + private + + # Perform the chore promised + def chore + if complete? + stat :found_completed, item_id: object_id + return + end + stat :will_execute, item_id: object_id + begin + @result = @block.call(*@args) + rescue Exception => e + @error = e + end + stat :did_execute, item_id: object_id + discard + end + + # Do we have a result for the promise + def result? + !@result.equal?(NOT_SET) + end + + # Did the promise throw an error + def error? + !@error.equal?(NOT_SET) + end + + # Are we done with the promise + def complete? + result? || error? + end + + # free up these items for the GC + def discard + @args = nil + @block = nil + end + + # Record execution statistics if there is a recorder + def stat(*args) + @recorder.call(*args) if @recorder + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/pseudo_status.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/pseudo_status.rb new file mode 100644 index 0000000..8b3c989 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/pseudo_status.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true +module Rake + + ## + # Exit status class for times the system just gives us a nil. + class PseudoStatus # :nodoc: all + attr_reader :exitstatus + + def initialize(code=0) + @exitstatus = code + end + + def to_i + @exitstatus << 8 + end + + def >>(n) + to_i >> n + end + + def stopped? + false + end + + def exited? + true + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rake_module.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rake_module.rb new file mode 100644 index 0000000..03c2956 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rake_module.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true +require "rake/application" + +module Rake + + class << self + # Current Rake Application + def application + @application ||= Rake::Application.new + end + + # Set the current Rake application object. + def application=(app) + @application = app + end + + def suggested_thread_count # :nodoc: + @cpu_count ||= Rake::CpuCounter.count + @cpu_count + 4 + end + + # Return the original directory where the Rake application was started. + def original_dir + application.original_dir + end + + # Load a rakefile. + def load_rakefile(path) + load(path) + end + + # Add files to the rakelib list + def add_rakelib(*files) + application.options.rakelib ||= [] + application.options.rakelib.concat(files) + end + + # Make +block_application+ the default rake application inside a block so + # you can load rakefiles into a different application. + # + # This is useful when you want to run rake tasks inside a library without + # running rake in a sub-shell. + # + # Example: + # + # Dir.chdir 'other/directory' + # + # other_rake = Rake.with_application do |rake| + # rake.load_rakefile + # end + # + # puts other_rake.tasks + + def with_application(block_application = Rake::Application.new) + orig_application = Rake.application + + Rake.application = block_application + + yield block_application + + block_application + ensure + Rake.application = orig_application + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb new file mode 100644 index 0000000..3ecee5d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require "rake/file_list" + +# Load the test files from the command line. +argv = ARGV.select do |argument| + case argument + when /^-/ then + argument + when /\*/ then + Rake::FileList[argument].to_a.each do |file| + require File.expand_path file + end + + false + else + path = File.expand_path argument + + abort "\nFile does not exist: #{path}\n\n" unless File.exist?(path) + + require path + + false + end +end + +ARGV.replace argv diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rule_recursion_overflow_error.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rule_recursion_overflow_error.rb new file mode 100644 index 0000000..a51e774 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/rule_recursion_overflow_error.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true +module Rake + + # Error indicating a recursion overflow error in task selection. + class RuleRecursionOverflowError < StandardError + def initialize(*args) + super + @targets = [] + end + + def add_target(target) + @targets << target + end + + def message + super + ": [" + @targets.reverse.join(" => ") + "]" + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/scope.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/scope.rb new file mode 100644 index 0000000..fc1eb6c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/scope.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true +module Rake + class Scope < LinkedList # :nodoc: all + + # Path for the scope. + def path + map(&:to_s).reverse.join(":") + end + + # Path for the scope + the named path. + def path_with_task_name(task_name) + "#{path}:#{task_name}" + end + + # Trim +n+ innermost scope levels from the scope. In no case will + # this trim beyond the toplevel scope. + def trim(n) + result = self + while n > 0 && !result.empty? + result = result.tail + n -= 1 + end + result + end + + # Scope lists always end with an EmptyScope object. See Null + # Object Pattern) + class EmptyScope < EmptyLinkedList + @parent = Scope + + def path + "" + end + + def path_with_task_name(task_name) + task_name + end + end + + # Singleton null object for an empty scope. + EMPTY = EmptyScope.new + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb new file mode 100644 index 0000000..a8ed24d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb @@ -0,0 +1,434 @@ +# frozen_string_literal: true +require "rake/invocation_exception_mixin" + +module Rake + + ## + # A Task is the basic unit of work in a Rakefile. Tasks have associated + # actions (possibly more than one) and a list of prerequisites. When + # invoked, a task will first ensure that all of its prerequisites have an + # opportunity to run and then it will execute its own actions. + # + # Tasks are not usually created directly using the new method, but rather + # use the +file+ and +task+ convenience methods. + # + class Task + # List of prerequisites for a task. + attr_reader :prerequisites + alias prereqs prerequisites + + # List of order only prerequisites for a task. + attr_reader :order_only_prerequisites + + # List of actions attached to a task. + attr_reader :actions + + # Application owning this task. + attr_accessor :application + + # Array of nested namespaces names used for task lookup by this task. + attr_reader :scope + + # File/Line locations of each of the task definitions for this + # task (only valid if the task was defined with the detect + # location option set). + attr_reader :locations + + # Has this task already been invoked? Already invoked tasks + # will be skipped unless you reenable them. + attr_reader :already_invoked + + # Return task name + def to_s + name + end + + def inspect # :nodoc: + "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>" + end + + # List of sources for task. + attr_writer :sources + def sources + if defined?(@sources) + @sources + else + prerequisites + end + end + + # List of prerequisite tasks + def prerequisite_tasks + (prerequisites + order_only_prerequisites).map { |pre| lookup_prerequisite(pre) } + end + + def lookup_prerequisite(prerequisite_name) # :nodoc: + scoped_prerequisite_task = application[prerequisite_name, @scope] + if scoped_prerequisite_task == self + unscoped_prerequisite_task = application[prerequisite_name] + end + unscoped_prerequisite_task || scoped_prerequisite_task + end + private :lookup_prerequisite + + # List of all unique prerequisite tasks including prerequisite tasks' + # prerequisites. + # Includes self when cyclic dependencies are found. + def all_prerequisite_tasks + seen = {} + collect_prerequisites(seen) + seen.values + end + + def collect_prerequisites(seen) # :nodoc: + prerequisite_tasks.each do |pre| + next if seen[pre.name] + seen[pre.name] = pre + pre.collect_prerequisites(seen) + end + end + protected :collect_prerequisites + + # First source from a rule (nil if no sources) + def source + sources.first + end + + # Create a task named +task_name+ with no actions or prerequisites. Use + # +enhance+ to add actions and prerequisites. + def initialize(task_name, app) + @name = task_name.to_s + @prerequisites = [] + @actions = [] + @already_invoked = false + @comments = [] + @lock = Monitor.new + @application = app + @scope = app.current_scope + @arg_names = nil + @locations = [] + @invocation_exception = nil + @order_only_prerequisites = [] + end + + # Enhance a task with prerequisites or actions. Returns self. + def enhance(deps=nil, &block) + @prerequisites |= deps if deps + @actions << block if block_given? + self + end + + # Name of the task, including any namespace qualifiers. + def name + @name.to_s + end + + # Name of task with argument list description. + def name_with_args # :nodoc: + if arg_description + "#{name}#{arg_description}" + else + name + end + end + + # Argument description (nil if none). + def arg_description # :nodoc: + @arg_names ? "[#{arg_names.join(',')}]" : nil + end + + # Name of arguments for this task. + def arg_names + @arg_names || [] + end + + # Reenable the task, allowing its tasks to be executed if the task + # is invoked again. + def reenable + @already_invoked = false + @invocation_exception = nil + end + + # Clear the existing prerequisites, actions, comments, and arguments of a rake task. + def clear + clear_prerequisites + clear_actions + clear_comments + clear_args + self + end + + # Clear the existing prerequisites of a rake task. + def clear_prerequisites + prerequisites.clear + self + end + + # Clear the existing actions on a rake task. + def clear_actions + actions.clear + self + end + + # Clear the existing comments on a rake task. + def clear_comments + @comments = [] + self + end + + # Clear the existing arguments on a rake task. + def clear_args + @arg_names = nil + self + end + + # Invoke the task if it is needed. Prerequisites are invoked first. + def invoke(*args) + task_args = TaskArguments.new(arg_names, args) + invoke_with_call_chain(task_args, InvocationChain::EMPTY) + end + + # Same as invoke, but explicitly pass a call chain to detect + # circular dependencies. + # + # If multiple tasks depend on this + # one in parallel, they will all fail if the first execution of + # this task fails. + def invoke_with_call_chain(task_args, invocation_chain) + new_chain = Rake::InvocationChain.append(self, invocation_chain) + @lock.synchronize do + begin + if application.options.trace + application.trace "** Invoke #{name} #{format_trace_flags}" + end + + if @already_invoked + if @invocation_exception + if application.options.trace + application.trace "** Previous invocation of #{name} failed #{format_trace_flags}" + end + raise @invocation_exception + else + return + end + end + + @already_invoked = true + + invoke_prerequisites(task_args, new_chain) + execute(task_args) if needed? + rescue Exception => ex + add_chain_to(ex, new_chain) + @invocation_exception = ex + raise ex + end + end + end + protected :invoke_with_call_chain + + def add_chain_to(exception, new_chain) # :nodoc: + exception.extend(InvocationExceptionMixin) unless + exception.respond_to?(:chain) + exception.chain = new_chain if exception.chain.nil? + end + private :add_chain_to + + # Invoke all the prerequisites of a task. + def invoke_prerequisites(task_args, invocation_chain) # :nodoc: + if application.options.always_multitask + invoke_prerequisites_concurrently(task_args, invocation_chain) + else + prerequisite_tasks.each { |p| + prereq_args = task_args.new_scope(p.arg_names) + p.invoke_with_call_chain(prereq_args, invocation_chain) + } + end + end + + # Invoke all the prerequisites of a task in parallel. + def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc: + futures = prerequisite_tasks.map do |p| + prereq_args = task_args.new_scope(p.arg_names) + application.thread_pool.future(p) do |r| + r.invoke_with_call_chain(prereq_args, invocation_chain) + end + end + # Iterate in reverse to improve performance related to thread waiting and switching + futures.reverse_each(&:value) + end + + # Format the trace flags for display. + def format_trace_flags + flags = [] + flags << "first_time" unless @already_invoked + flags << "not_needed" unless needed? + flags.empty? ? "" : "(" + flags.join(", ") + ")" + end + private :format_trace_flags + + # Execute the actions associated with this task. + def execute(args=nil) + args ||= EMPTY_TASK_ARGS + if application.options.dryrun + application.trace "** Execute (dry run) #{name}" + return + end + application.trace "** Execute #{name}" if application.options.trace + application.enhance_with_matching_rule(name) if @actions.empty? + if opts = Hash.try_convert(args) and !opts.empty? + @actions.each { |act| act.call(self, args, **opts) } + else + @actions.each { |act| act.call(self, args) } + end + end + + # Is this task needed? + def needed? + true + end + + # Timestamp for this task. Basic tasks return the current time for their + # time stamp. Other tasks can be more sophisticated. + def timestamp + Time.now + end + + # Add a description to the task. The description can consist of an option + # argument list (enclosed brackets) and an optional comment. + def add_description(description) + return unless description + comment = description.strip + add_comment(comment) if comment && !comment.empty? + end + + def comment=(comment) # :nodoc: + add_comment(comment) + end + + def add_comment(comment) # :nodoc: + return if comment.nil? + @comments << comment unless @comments.include?(comment) + end + private :add_comment + + # Full collection of comments. Multiple comments are separated by + # newlines. + def full_comment + transform_comments("\n") + end + + # First line (or sentence) of all comments. Multiple comments are + # separated by a "/". + def comment + transform_comments(" / ") { |c| first_sentence(c) } + end + + # Transform the list of comments as specified by the block and + # join with the separator. + def transform_comments(separator, &block) + if @comments.empty? + nil + else + block ||= lambda { |c| c } + @comments.map(&block).join(separator) + end + end + private :transform_comments + + # Get the first sentence in a string. The sentence is terminated + # by the first period, exclamation mark, or the end of the line. + # Decimal points do not count as periods. + def first_sentence(string) + string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first + end + private :first_sentence + + # Set the names of the arguments for this task. +args+ should be + # an array of symbols, one for each argument name. + def set_arg_names(args) + @arg_names = args.map(&:to_sym) + end + + # Return a string describing the internal state of a task. Useful for + # debugging. + def investigation + result = "------------------------------\n".dup + result << "Investigating #{name}\n" + result << "class: #{self.class}\n" + result << "task needed: #{needed?}\n" + result << "timestamp: #{timestamp}\n" + result << "pre-requisites: \n" + prereqs = prerequisite_tasks + prereqs.sort! { |a, b| a.timestamp <=> b.timestamp } + prereqs.each do |p| + result << "--#{p.name} (#{p.timestamp})\n" + end + latest_prereq = prerequisite_tasks.map(&:timestamp).max + result << "latest-prerequisite time: #{latest_prereq}\n" + result << "................................\n\n" + return result + end + + # Format dependencies parameter to pass to task. + def self.format_deps(deps) + deps = [deps] unless deps.respond_to?(:to_ary) + deps.map { |d| Rake.from_pathname(d).to_s } + end + + # Add order only dependencies. + def |(deps) + @order_only_prerequisites |= Task.format_deps(deps) - @prerequisites + self + end + + # ---------------------------------------------------------------- + # Rake Module Methods + # + class << self + + # Clear the task list. This cause rake to immediately forget all the + # tasks that have been assigned. (Normally used in the unit tests.) + def clear + Rake.application.clear + end + + # List of all defined tasks. + def tasks + Rake.application.tasks + end + + # Return a task with the given name. If the task is not currently + # known, try to synthesize one from the defined rules. If no rules are + # found, but an existing file matches the task name, assume it is a file + # task with no dependencies or actions. + def [](task_name) + Rake.application[task_name] + end + + # TRUE if the task name is already defined. + def task_defined?(task_name) + Rake.application.lookup(task_name) != nil + end + + # Define a task given +args+ and an option block. If a rule with the + # given name already exists, the prerequisites and actions are added to + # the existing task. Returns the defined task. + def define_task(*args, &block) + Rake.application.define_task(self, *args, &block) + end + + # Define a rule for synthesizing tasks. + def create_rule(*args, &block) + Rake.application.create_rule(*args, &block) + end + + # Apply the scope to the task name according to the rules for + # this kind of task. Generic tasks will accept the scope as + # part of the name. + def scope_name(scope, task_name) + scope.path_with_task_name(task_name) + end + + end # class << Rake::Task + end # class Rake::Task +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_argument_error.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_argument_error.rb new file mode 100644 index 0000000..ef20076 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_argument_error.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +module Rake + + # Error indicating an ill-formed task declaration. + class TaskArgumentError < ArgumentError + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_arguments.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_arguments.rb new file mode 100644 index 0000000..0d3001a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_arguments.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true +module Rake + + ## + # TaskArguments manage the arguments passed to a task. + # + class TaskArguments + include Enumerable + + # Argument names + attr_reader :names + + # Create a TaskArgument object with a list of argument +names+ and a set + # of associated +values+. +parent+ is the parent argument object. + def initialize(names, values, parent=nil) + @names = names + @parent = parent + @hash = {} + @values = values + names.each_with_index { |name, i| + next if values[i].nil? || values[i] == "" + @hash[name.to_sym] = values[i] + } + end + + # Retrieve the complete array of sequential values + def to_a + @values.dup + end + + # Retrieve the list of values not associated with named arguments + def extras + @values[@names.length..-1] || [] + end + + # Create a new argument scope using the prerequisite argument + # names. + def new_scope(names) + values = names.map { |n| self[n] } + self.class.new(names, values + extras, self) + end + + # Find an argument value by name or index. + def [](index) + lookup(index.to_sym) + end + + # Specify a hash of default values for task arguments. Use the + # defaults only if there is no specific value for the given + # argument. + def with_defaults(defaults) + @hash = defaults.merge(@hash) + end + + # Enumerates the arguments and their values + def each(&block) + @hash.each(&block) + end + + # Extracts the argument values at +keys+ + def values_at(*keys) + keys.map { |k| lookup(k) } + end + + # Returns the value of the given argument via method_missing + def method_missing(sym, *args) + lookup(sym.to_sym) + end + + # Returns a Hash of arguments and their values + def to_hash + @hash.dup + end + + def to_s # :nodoc: + inspect + end + + def inspect # :nodoc: + inspection = @hash.map do |k,v| + "#{k.to_s}: #{v.to_s}" + end.join(", ") + + "#<#{self.class} #{inspection}>" + end + + # Returns true if +key+ is one of the arguments + def has_key?(key) + @hash.has_key?(key) + end + alias key? has_key? + + def fetch(*args, &block) + @hash.fetch(*args, &block) + end + + protected + + def lookup(name) # :nodoc: + if @hash.has_key?(name) + @hash[name] + elsif @parent + @parent.lookup(name) + end + end + end + + EMPTY_TASK_ARGS = TaskArguments.new([], []) # :nodoc: +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_manager.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_manager.rb new file mode 100644 index 0000000..0db5c24 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task_manager.rb @@ -0,0 +1,331 @@ +# frozen_string_literal: true +module Rake + + # The TaskManager module is a mixin for managing tasks. + module TaskManager + # Track the last comment made in the Rakefile. + attr_accessor :last_description + + def initialize # :nodoc: + super + @tasks = Hash.new + @rules = Array.new + @scope = Scope.make + @last_description = nil + end + + def create_rule(*args, &block) # :nodoc: + pattern, args, deps, order_only = resolve_args(args) + pattern = Regexp.new(Regexp.quote(pattern) + "$") if String === pattern + @rules << [pattern, args, deps, order_only, block] + end + + def define_task(task_class, *args, &block) # :nodoc: + task_name, arg_names, deps, order_only = resolve_args(args) + + original_scope = @scope + if String === task_name and + not task_class.ancestors.include? Rake::FileTask + task_name, *definition_scope = *(task_name.split(":").reverse) + @scope = Scope.make(*(definition_scope + @scope.to_a)) + end + + task_name = task_class.scope_name(@scope, task_name) + task = intern(task_class, task_name) + task.set_arg_names(arg_names) unless arg_names.empty? + if Rake::TaskManager.record_task_metadata + add_location(task) + task.add_description(get_description(task)) + end + task.enhance(Task.format_deps(deps), &block) + task | order_only unless order_only.nil? + task + ensure + @scope = original_scope + end + + # Lookup a task. Return an existing task if found, otherwise + # create a task of the current type. + def intern(task_class, task_name) + @tasks[task_name.to_s] ||= task_class.new(task_name, self) + end + + # Find a matching task for +task_name+. + def [](task_name, scopes=nil) + task_name = task_name.to_s + self.lookup(task_name, scopes) or + enhance_with_matching_rule(task_name) or + synthesize_file_task(task_name) or + fail generate_message_for_undefined_task(task_name) + end + + def generate_message_for_undefined_task(task_name) + message = "Don't know how to build task '#{task_name}' "\ + "(See the list of available tasks with `#{Rake.application.name} --tasks`)" + message + generate_did_you_mean_suggestions(task_name) + end + + def generate_did_you_mean_suggestions(task_name) + return "" unless defined?(::DidYouMean::SpellChecker) + + suggestions = ::DidYouMean::SpellChecker.new(dictionary: @tasks.keys).correct(task_name.to_s) + if ::DidYouMean.respond_to?(:formatter)# did_you_mean v1.2.0 or later + ::DidYouMean.formatter.message_for(suggestions) + elsif defined?(::DidYouMean::Formatter) # before did_you_mean v1.2.0 + ::DidYouMean::Formatter.new(suggestions).to_s + else + "" + end + end + + def synthesize_file_task(task_name) # :nodoc: + return nil unless File.exist?(task_name) + define_task(Rake::FileTask, task_name) + end + + # Resolve the arguments for a task/rule. Returns a tuple of + # [task_name, arg_name_list, prerequisites, order_only_prerequisites]. + def resolve_args(args) + if args.last.is_a?(Hash) + deps = args.pop + resolve_args_with_dependencies(args, deps) + else + resolve_args_without_dependencies(args) + end + end + + # Resolve task arguments for a task or rule when there are no + # dependencies declared. + # + # The patterns recognized by this argument resolving function are: + # + # task :t + # task :t, [:a] + # + def resolve_args_without_dependencies(args) + task_name = args.shift + if args.size == 1 && args.first.respond_to?(:to_ary) + arg_names = args.first.to_ary + else + arg_names = args + end + [task_name, arg_names, [], nil] + end + private :resolve_args_without_dependencies + + # Resolve task arguments for a task or rule when there are + # dependencies declared. + # + # The patterns recognized by this argument resolving function are: + # + # task :t, order_only: [:e] + # task :t => [:d] + # task :t => [:d], order_only: [:e] + # task :t, [a] => [:d] + # task :t, [a] => [:d], order_only: [:e] + # + def resolve_args_with_dependencies(args, hash) # :nodoc: + fail "Task Argument Error" if + hash.size != 1 && + (hash.size != 2 || !hash.key?(:order_only)) + order_only = hash.delete(:order_only) + key, value = hash.map { |k, v| [k, v] }.first + if args.empty? + task_name = key + arg_names = [] + deps = value || [] + else + task_name = args.shift + arg_names = key || args.shift|| [] + deps = value || [] + end + deps = [deps] unless deps.respond_to?(:to_ary) + [task_name, arg_names, deps, order_only] + end + private :resolve_args_with_dependencies + + # If a rule can be found that matches the task name, enhance the + # task with the prerequisites and actions from the rule. Set the + # source attribute of the task appropriately for the rule. Return + # the enhanced task or nil of no rule was found. + def enhance_with_matching_rule(task_name, level=0) + fail Rake::RuleRecursionOverflowError, + "Rule Recursion Too Deep" if level >= 16 + @rules.each do |pattern, args, extensions, order_only, block| + if pattern && pattern.match(task_name) + task = attempt_rule(task_name, pattern, args, extensions, block, level) + task | order_only unless order_only.nil? + return task if task + end + end + nil + rescue Rake::RuleRecursionOverflowError => ex + ex.add_target(task_name) + fail ex + end + + # List of all defined tasks in this application. + def tasks + @tasks.values.sort_by { |t| t.name } + end + + # List of all the tasks defined in the given scope (and its + # sub-scopes). + def tasks_in_scope(scope) + prefix = scope.path + tasks.select { |t| + /^#{prefix}:/ =~ t.name + } + end + + # Clear all tasks in this application. + def clear + @tasks.clear + @rules.clear + end + + # Lookup a task, using scope and the scope hints in the task name. + # This method performs straight lookups without trying to + # synthesize file tasks or rules. Special scope names (e.g. '^') + # are recognized. If no scope argument is supplied, use the + # current scope. Return nil if the task cannot be found. + def lookup(task_name, initial_scope=nil) + initial_scope ||= @scope + task_name = task_name.to_s + if task_name =~ /^rake:/ + scopes = Scope.make + task_name = task_name.sub(/^rake:/, "") + elsif task_name =~ /^(\^+)/ + scopes = initial_scope.trim($1.size) + task_name = task_name.sub(/^(\^+)/, "") + else + scopes = initial_scope + end + lookup_in_scope(task_name, scopes) + end + + # Lookup the task name + def lookup_in_scope(name, scope) + loop do + tn = scope.path_with_task_name(name) + task = @tasks[tn] + return task if task + break if scope.empty? + scope = scope.tail + end + nil + end + private :lookup_in_scope + + # Return the list of scope names currently active in the task + # manager. + def current_scope + @scope + end + + # Evaluate the block in a nested namespace named +name+. Create + # an anonymous namespace if +name+ is nil. + def in_namespace(name) + name ||= generate_name + @scope = Scope.new(name, @scope) + ns = NameSpace.new(self, @scope) + yield(ns) + ns + ensure + @scope = @scope.tail + end + + private + + # Add a location to the locations field of the given task. + def add_location(task) + loc = find_location + task.locations << loc if loc + task + end + + # Find the location that called into the dsl layer. + def find_location + locations = caller + i = 0 + while locations[i] + return locations[i + 1] if locations[i] =~ /rake\/dsl_definition.rb/ + i += 1 + end + nil + end + + # Generate an anonymous namespace name. + def generate_name + @seed ||= 0 + @seed += 1 + "_anon_#{@seed}" + end + + def trace_rule(level, message) # :nodoc: + options.trace_output.puts "#{" " * level}#{message}" if + Rake.application.options.trace_rules + end + + # Attempt to create a rule given the list of prerequisites. + def attempt_rule(task_name, task_pattern, args, extensions, block, level) + sources = make_sources(task_name, task_pattern, extensions) + prereqs = sources.map { |source| + trace_rule level, "Attempting Rule #{task_name} => #{source}" + if File.exist?(source) || Rake::Task.task_defined?(source) + trace_rule level, "(#{task_name} => #{source} ... EXIST)" + source + elsif parent = enhance_with_matching_rule(source, level + 1) + trace_rule level, "(#{task_name} => #{source} ... ENHANCE)" + parent.name + else + trace_rule level, "(#{task_name} => #{source} ... FAIL)" + return nil + end + } + task = FileTask.define_task(task_name, { args => prereqs }, &block) + task.sources = prereqs + task + end + + # Make a list of sources from the list of file name extensions / + # translation procs. + def make_sources(task_name, task_pattern, extensions) + result = extensions.map { |ext| + case ext + when /%/ + task_name.pathmap(ext) + when %r{/} + ext + when /^\./ + source = task_name.sub(task_pattern, ext) + source == ext ? task_name.ext(ext) : source + when String, Symbol + ext.to_s + when Proc, Method + if ext.arity == 1 + ext.call(task_name) + else + ext.call + end + else + fail "Don't know how to handle rule dependent: #{ext.inspect}" + end + } + result.flatten + end + + # Return the current description, clearing it in the process. + def get_description(task) + desc = @last_description + @last_description = nil + desc + end + + class << self + attr_accessor :record_task_metadata # :nodoc: + TaskManager.record_task_metadata = false + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/tasklib.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/tasklib.rb new file mode 100644 index 0000000..5354b4f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/tasklib.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +require "rake" + +module Rake + + # Base class for Task Libraries. + class TaskLib + include Cloneable + include Rake::DSL + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/testtask.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/testtask.rb new file mode 100644 index 0000000..56521d2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/testtask.rb @@ -0,0 +1,189 @@ +# frozen_string_literal: true +require "rake" +require "rake/tasklib" + +module Rake + + # Create a task that runs a set of tests. + # + # Example: + # require "rake/testtask" + # + # Rake::TestTask.new do |t| + # t.libs << "test" + # t.test_files = FileList['test/test*.rb'] + # t.verbose = true + # end + # + # If rake is invoked with a "TEST=filename" command line option, + # then the list of test files will be overridden to include only the + # filename specified on the command line. This provides an easy way + # to run just one test. + # + # If rake is invoked with a "TESTOPTS=options" command line option, + # then the given options are passed to the test process after a + # '--'. This allows Test::Unit options to be passed to the test + # suite. + # + # Examples: + # + # rake test # run tests normally + # rake test TEST=just_one_file.rb # run just one test file. + # rake test TESTOPTS="-v" # run in verbose mode + # rake test TESTOPTS="--runner=fox" # use the fox test runner + # + class TestTask < TaskLib + + # Name of test task. (default is :test) + attr_accessor :name + + # List of directories added to $LOAD_PATH before running the + # tests. (default is 'lib') + attr_accessor :libs + + # True if verbose test output desired. (default is false) + attr_accessor :verbose + + # Test options passed to the test suite. An explicit + # TESTOPTS=opts on the command line will override this. (default + # is NONE) + attr_accessor :options + + # Request that the tests be run with the warning flag set. + # E.g. warning=true implies "ruby -w" used to run the tests. + # (default is true) + attr_accessor :warning + + # Glob pattern to match test files. (default is 'test/test*.rb') + attr_accessor :pattern + + # Style of test loader to use. Options are: + # + # * :rake -- Rake provided test loading script (default). + # * :testrb -- Ruby provided test loading script. + # * :direct -- Load tests using command line loader. + # + attr_accessor :loader + + # Array of command line options to pass to ruby when running test loader. + attr_accessor :ruby_opts + + # Description of the test task. (default is 'Run tests') + attr_accessor :description + + # Task prerequisites. + attr_accessor :deps + + # Explicitly define the list of test files to be included in a + # test. +list+ is expected to be an array of file names (a + # FileList is acceptable). If both +pattern+ and +test_files+ are + # used, then the list of test files is the union of the two. + def test_files=(list) + @test_files = list + end + + # Create a testing task. + def initialize(name=:test) + @name = name + @libs = ["lib"] + @pattern = nil + @options = nil + @test_files = nil + @verbose = false + @warning = true + @loader = :rake + @ruby_opts = [] + @description = "Run tests" + (@name == :test ? "" : " for #{@name}") + @deps = [] + if @name.is_a?(Hash) + @deps = @name.values.first + @name = @name.keys.first + end + yield self if block_given? + @pattern = "test/test*.rb" if @pattern.nil? && @test_files.nil? + define + end + + # Create the tasks defined by this task lib. + def define + desc @description + task @name => Array(deps) do + FileUtilsExt.verbose(@verbose) do + puts "Use TESTOPTS=\"--verbose\" to pass --verbose" \ + ", etc. to runners." if ARGV.include? "--verbose" + args = + "#{ruby_opts_string} #{run_code} " + + "#{file_list_string} #{option_list}" + ruby args do |ok, status| + if !ok && status.respond_to?(:signaled?) && status.signaled? + raise SignalException.new(status.termsig) + elsif !ok + status = "Command failed with status (#{status.exitstatus})" + details = ": [ruby #{args}]" + message = + if Rake.application.options.trace or @verbose + status + details + else + status + end + + fail message + end + end + end + end + self + end + + def option_list # :nodoc: + (ENV["TESTOPTS"] || + ENV["TESTOPT"] || + ENV["TEST_OPTS"] || + ENV["TEST_OPT"] || + @options || + "") + end + + def ruby_opts_string # :nodoc: + opts = @ruby_opts.dup + opts.unshift("-I\"#{lib_path}\"") unless @libs.empty? + opts.unshift("-w") if @warning + opts.join(" ") + end + + def lib_path # :nodoc: + @libs.join(File::PATH_SEPARATOR) + end + + def file_list_string # :nodoc: + file_list.map { |fn| "\"#{fn}\"" }.join(" ") + end + + def file_list # :nodoc: + if ENV["TEST"] + FileList[ENV["TEST"]] + else + result = [] + result += @test_files.to_a if @test_files + result += FileList[@pattern].to_a if @pattern + result + end + end + + def ruby_version # :nodoc: + RUBY_VERSION + end + + def run_code # :nodoc: + case @loader + when :direct + "-e \"ARGV.each{|f| require f}\"" + when :testrb + "-S testrb" + when :rake + "#{__dir__}/rake_test_loader.rb" + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/thread_history_display.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/thread_history_display.rb new file mode 100644 index 0000000..412ea37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/thread_history_display.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true +require "rake/private_reader" + +module Rake + + class ThreadHistoryDisplay # :nodoc: all + include Rake::PrivateReader + + private_reader :stats, :items, :threads + + def initialize(stats) + @stats = stats + @items = { _seq_: 1 } + @threads = { _seq_: "A" } + end + + def show + puts "Job History:" + stats.each do |stat| + stat[:data] ||= {} + rename(stat, :thread, threads) + rename(stat[:data], :item_id, items) + rename(stat[:data], :new_thread, threads) + rename(stat[:data], :deleted_thread, threads) + printf("%8d %2s %-20s %s\n", + (stat[:time] * 1_000_000).round, + stat[:thread], + stat[:event], + stat[:data].map do |k, v| "#{k}:#{v}" end.join(" ")) + end + end + + private + + def rename(hash, key, renames) + if hash && hash[key] + original = hash[key] + value = renames[original] + unless value + value = renames[:_seq_] + renames[:_seq_] = renames[:_seq_].succ + renames[original] = value + end + hash[key] = value + end + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/thread_pool.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/thread_pool.rb new file mode 100644 index 0000000..76aa3b7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/thread_pool.rb @@ -0,0 +1,163 @@ +# frozen_string_literal: true + +require "rake/promise" +require "set" + +module Rake + + class ThreadPool # :nodoc: all + + # Creates a ThreadPool object. The +thread_count+ parameter is the size + # of the pool. + def initialize(thread_count) + @max_active_threads = [thread_count, 0].max + @threads = Set.new + @threads_mon = Monitor.new + @queue = Queue.new + @join_cond = @threads_mon.new_cond + + @history_start_time = nil + @history = [] + @history_mon = Monitor.new + @total_threads_in_play = 0 + end + + # Creates a future executed by the +ThreadPool+. + # + # The args are passed to the block when executing (similarly to + # Thread#new) The return value is an object representing + # a future which has been created and added to the queue in the + # pool. Sending #value to the object will sleep the + # current thread until the future is finished and will return the + # result (or raise an exception thrown from the future) + def future(*args, &block) + promise = Promise.new(args, &block) + promise.recorder = lambda { |*stats| stat(*stats) } + + @queue.enq promise + stat :queued, item_id: promise.object_id + start_thread + promise + end + + # Waits until the queue of futures is empty and all threads have exited. + def join + @threads_mon.synchronize do + begin + stat :joining + @join_cond.wait unless @threads.empty? + stat :joined + rescue Exception => e + stat :joined + $stderr.puts e + $stderr.print "Queue contains #{@queue.size} items. " + + "Thread pool contains #{@threads.count} threads\n" + $stderr.print "Current Thread #{Thread.current} status = " + + "#{Thread.current.status}\n" + $stderr.puts e.backtrace.join("\n") + @threads.each do |t| + $stderr.print "Thread #{t} status = #{t.status}\n" + $stderr.puts t.backtrace.join("\n") + end + raise e + end + end + end + + # Enable the gathering of history events. + def gather_history #:nodoc: + @history_start_time = Time.now if @history_start_time.nil? + end + + # Return a array of history events for the thread pool. + # + # History gathering must be enabled to be able to see the events + # (see #gather_history). Best to call this when the job is + # complete (i.e. after ThreadPool#join is called). + def history # :nodoc: + @history_mon.synchronize { @history.dup }. + sort_by { |i| i[:time] }. + each { |i| i[:time] -= @history_start_time } + end + + # Return a hash of always collected statistics for the thread pool. + def statistics # :nodoc: + { + total_threads_in_play: @total_threads_in_play, + max_active_threads: @max_active_threads, + } + end + + private + + # processes one item on the queue. Returns true if there was an + # item to process, false if there was no item + def process_queue_item #:nodoc: + return false if @queue.empty? + + # Even though we just asked if the queue was empty, it + # still could have had an item which by this statement + # is now gone. For this reason we pass true to Queue#deq + # because we will sleep indefinitely if it is empty. + promise = @queue.deq(true) + stat :dequeued, item_id: promise.object_id + promise.work + return true + + rescue ThreadError # this means the queue is empty + false + end + + def safe_thread_count + @threads_mon.synchronize do + @threads.count + end + end + + def start_thread # :nodoc: + @threads_mon.synchronize do + next unless @threads.count < @max_active_threads + + t = Thread.new do + begin + while safe_thread_count <= @max_active_threads + break unless process_queue_item + end + ensure + @threads_mon.synchronize do + @threads.delete Thread.current + stat :ended, thread_count: @threads.count + @join_cond.broadcast if @threads.empty? + end + end + end + + @threads << t + stat( + :spawned, + new_thread: t.object_id, + thread_count: @threads.count) + @total_threads_in_play = @threads.count if + @threads.count > @total_threads_in_play + end + end + + def stat(event, data=nil) # :nodoc: + return if @history_start_time.nil? + info = { + event: event, + data: data, + time: Time.now, + thread: Thread.current.object_id, + } + @history_mon.synchronize { @history << info } + end + + # for testing only + + def __queue__ # :nodoc: + @queue + end + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/trace_output.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/trace_output.rb new file mode 100644 index 0000000..d713a09 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/trace_output.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true +module Rake + module TraceOutput # :nodoc: all + + # Write trace output to output stream +out+. + # + # The write is done as a single IO call (to print) to lessen the + # chance that the trace output is interrupted by other tasks also + # producing output. + def trace_on(out, *strings) + sep = $\ || "\n" + if strings.empty? + output = sep + else + output = strings.map { |s| + next if s.nil? + s.end_with?(sep) ? s : s + sep + }.join + end + out.print(output) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/version.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/version.rb new file mode 100644 index 0000000..bba5f1b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/version.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +module Rake + VERSION = "13.2.1" + + module Version # :nodoc: all + MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split "." + + NUMBERS = [MAJOR, MINOR, BUILD, *OTHER] + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/win32.rb b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/win32.rb new file mode 100644 index 0000000..6e62031 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/win32.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "rbconfig" + +module Rake + # Win 32 interface methods for Rake. Windows specific functionality + # will be placed here to collect that knowledge in one spot. + module Win32 # :nodoc: all + + # Error indicating a problem in locating the home directory on a + # Win32 system. + class Win32HomeError < RuntimeError + end + + class << self + # True if running on a windows system. + def windows? + RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw|[Ww]indows)! + end + + # The standard directory containing system wide rake files on + # Win 32 systems. Try the following environment variables (in + # order): + # + # * HOME + # * HOMEDRIVE + HOMEPATH + # * APPDATA + # * USERPROFILE + # + # If the above are not defined, the return nil. + def win32_system_dir #:nodoc: + win32_shared_path = ENV["HOME"] + if win32_shared_path.nil? && ENV["HOMEDRIVE"] && ENV["HOMEPATH"] + win32_shared_path = ENV["HOMEDRIVE"] + ENV["HOMEPATH"] + end + + win32_shared_path ||= ENV["APPDATA"] + win32_shared_path ||= ENV["USERPROFILE"] + raise Win32HomeError, + "Unable to determine home path environment variable." if + win32_shared_path.nil? or win32_shared_path.empty? + normalize(File.join(win32_shared_path, "Rake")) + end + + # Normalize a win32 path so that the slashes are all forward slashes. + def normalize(path) + path.gsub(/\\/, "/") + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/rake.gemspec b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/rake.gemspec new file mode 100644 index 0000000..b3e8a8e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/rake.gemspec @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +require_relative "lib/rake/version" + +Gem::Specification.new do |s| + s.name = "rake" + s.version = Rake::VERSION + s.authors = ["Hiroshi SHIBATA", "Eric Hodel", "Jim Weirich"] + s.email = ["hsbt@ruby-lang.org", "drbrain@segment7.net", ""] + + s.summary = "Rake is a Make-like program implemented in Ruby" + s.description = <<~DESCRIPTION + Rake is a Make-like program implemented in Ruby. Tasks and dependencies are + specified in standard Ruby syntax. + Rake has the following features: + * Rakefiles (rake's version of Makefiles) are completely defined in standard Ruby syntax. + No XML files to edit. No quirky Makefile syntax to worry about (is that a tab or a space?) + * Users can specify tasks with prerequisites. + * Rake supports rule patterns to synthesize implicit tasks. + * Flexible FileLists that act like arrays but know about manipulating file names and paths. + * Supports parallel execution of tasks. + DESCRIPTION + s.homepage = "https://github.com/ruby/rake" + s.licenses = ["MIT"] + + s.metadata = { + "bug_tracker_uri" => "https://github.com/ruby/rake/issues", + "changelog_uri" => "https://github.com/ruby/rake/blob/v#{s.version}/History.rdoc", + "documentation_uri" => "https://ruby.github.io/rake", + "source_code_uri" => "https://github.com/ruby/rake/tree/v#{s.version}" + } + + s.files = [ + "History.rdoc", + "MIT-LICENSE", + "README.rdoc", + "doc/command_line_usage.rdoc", + "doc/example/Rakefile1", + "doc/example/Rakefile2", + "doc/example/a.c", + "doc/example/b.c", + "doc/example/main.c", + "doc/glossary.rdoc", + "doc/jamis.rb", + "doc/proto_rake.rdoc", + "doc/rake.1", + "doc/rakefile.rdoc", + "doc/rational.rdoc", + "exe/rake", + "lib/rake.rb", + "lib/rake/application.rb", + "lib/rake/backtrace.rb", + "lib/rake/clean.rb", + "lib/rake/cloneable.rb", + "lib/rake/cpu_counter.rb", + "lib/rake/default_loader.rb", + "lib/rake/dsl_definition.rb", + "lib/rake/early_time.rb", + "lib/rake/ext/core.rb", + "lib/rake/ext/string.rb", + "lib/rake/file_creation_task.rb", + "lib/rake/file_list.rb", + "lib/rake/file_task.rb", + "lib/rake/file_utils.rb", + "lib/rake/file_utils_ext.rb", + "lib/rake/invocation_chain.rb", + "lib/rake/invocation_exception_mixin.rb", + "lib/rake/late_time.rb", + "lib/rake/linked_list.rb", + "lib/rake/loaders/makefile.rb", + "lib/rake/multi_task.rb", + "lib/rake/name_space.rb", + "lib/rake/packagetask.rb", + "lib/rake/phony.rb", + "lib/rake/private_reader.rb", + "lib/rake/promise.rb", + "lib/rake/pseudo_status.rb", + "lib/rake/rake_module.rb", + "lib/rake/rake_test_loader.rb", + "lib/rake/rule_recursion_overflow_error.rb", + "lib/rake/scope.rb", + "lib/rake/task.rb", + "lib/rake/task_argument_error.rb", + "lib/rake/task_arguments.rb", + "lib/rake/task_manager.rb", + "lib/rake/tasklib.rb", + "lib/rake/testtask.rb", + "lib/rake/thread_history_display.rb", + "lib/rake/thread_pool.rb", + "lib/rake/trace_output.rb", + "lib/rake/version.rb", + "lib/rake/win32.rb", + "rake.gemspec" + ] + s.bindir = "exe" + s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) } + s.require_paths = ["lib"] + + s.required_ruby_version = Gem::Requirement.new(">= 2.3") + s.rdoc_options = ["--main", "README.rdoc"] +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/.gitignore b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/.gitignore new file mode 100644 index 0000000..25a0e9a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/.gitignore @@ -0,0 +1,13 @@ +*.gem +.DS_Store +.Trashes +.bundle +.com.apple.timemachine.supported +.fseventsd +.idea +.rbx +/ext/build +Desktop DB +Desktop DF +Gemfile.lock +pkg/* diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Gemfile b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Gemfile new file mode 100644 index 0000000..b4e2a20 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gemspec diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Guardfile b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Guardfile new file mode 100644 index 0000000..63a666e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Guardfile @@ -0,0 +1,8 @@ +# A sample Guardfile +# More info at http://github.com/guard/guard#readme + +guard :rspec do + watch(%r(^spec/(.*)_spec.rb)) + watch(%r(^lib/(.*)\.rb)) { |m| "spec/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { 'spec' } +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/LICENSE.txt new file mode 100644 index 0000000..b083ecd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2010-2014 Thibaud Guillaume-Gentil & Travis Tilley + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/README.md b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/README.md new file mode 100644 index 0000000..3d87bcc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/README.md @@ -0,0 +1,260 @@ +[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/thibaudgg/rb-fsevent) +[![endorse](https://api.coderwall.com/ttilley/endorsecount.png)](https://coderwall.com/ttilley) + +# rb-fsevent + +Very simple & usable Mac OSX FSEvents API + +* Signals are working (really) +* Tested on MRI 2.4.1, RBX 3.72, JRuby 1.7.26 and 9.1.8.0 +* Tested on 10.8 + +## HFS+ filename corruption bug + +There is a _very_ long-standing (since 2011) OSX bug where sometimes the filename metadata for HFS+ filesystems will get corrupted, resulting in some APIs returning one case for a file, and other APIs returning another. The result is that sometimes, _for no visible reason to the user_, fsevents would simply not work. As of rb-fsevent 0.9.5 this issue is properly detected and an insanely hacky (but effective) workaround is used that replaces the system `realpath()` with a custom implementation that should almost always return the same value as the kernel reporting (thus fixing fsevents). The major flaw in the workaround is that it may return the wrong path for hard links. + +Please note that this doesn't repair the underlying issue on disk. Other apps and libraries using fsevents will continue to break with no warning. There may be other issues unrelated to fsevents. + +__This bug is resolved in MacOS 10.12 and all users are strongly encouraged to upgrade.__ + +## Install + + gem install rb-fsevent + +### re-compilation + +rb-fsevent comes with a pre-compiled fsevent\_watch binary supporting x86\_64 on 10.9 and above. The binary is codesigned with my (Travis Tilley) Developer ID as an extra precaution when distributing pre-compiled code and contains an embedded plist describing its build environment. This should be sufficient for most users, but if you need to use rb-fsevent on 10.8 or lower then recompilation is necessary. This can be done by entering the installed gem's ext directory and running: + + MACOSX_DEPLOYMENT_TARGET="10.7" rake replace_exe + +The following ENV vars are recognized: + +* CC +* CFLAGS +* ARCHFLAGS +* MACOSX\_DEPLOYMENT\_TARGET +* FWDEBUG (enables debug mode, printing an obscene number of informational + messages to STDERR) + +### embedded plist + +You can retrieve the values in the embedded plist via the CLI: + + fsevent_watch --show-plist + +The output is essentially formatted as `"#{key}:\n #{value}\n"` to make it easier to read than plist style xml. The result looks like this: + + DTSDKName: + macosx10.5 + FSEWBuildTriple: + i386-apple-darwin10.8.0 + FSEWCC: + /usr/bin/gcc-4.2 + DTSDKPath: + /Developer/SDKs/MacOSX10.5.sdk + FSEWCCVersion: + i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) + FSEWCFLAGS: + -fconstant-cfstrings -fno-strict-aliasing -Wall -mmacosx-version-min=10.5 -O3 + +If, for some perverse reason, you prefer to look at the xml... it can be retrieved via: + + otool -s __TEXT __info_plist ./bin/fsevent_watch | grep ^0 | xxd -r - + +### codesign + +You can verify code signing information for a specific fsevent\_watch via: + + codesign -d -vvv ./bin/fsevent_watch + +If you're using the pre-compiled binary, then the output should contain something to the effect of: + + Authority=Developer ID Application: Travis Tilley + Authority=Developer ID Certification Authority + Authority=Apple Root CA + Timestamp=Dec 31, 2012 12:49:13 PM + +## Usage + +### Singular path + +```ruby +require 'rb-fsevent' + +fsevent = FSEvent.new +fsevent.watch Dir.pwd do |directories| + puts "Detected change inside: #{directories.inspect}" +end +fsevent.run +``` + +### Multiple paths + +```ruby +require 'rb-fsevent' + +paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd] + +fsevent = FSEvent.new +fsevent.watch paths do |directories| + puts "Detected change inside: #{directories.inspect}" +end +fsevent.run +``` + +### Multiple paths and additional options as a Hash + +```ruby +require 'rb-fsevent' + +paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd] +options = {:latency => 1.5, :no_defer => true } + +fsevent = FSEvent.new +fsevent.watch paths, options do |directories| + puts "Detected change inside: #{directories.inspect}" +end +fsevent.run +``` + +### Multiple paths and additional options as an Array + +```ruby +require 'rb-fsevent' + +paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd] +options = ['--latency', 1.5, '--no-defer'] + +fsevent = FSEvent.new +fsevent.watch paths, options do |directories| + puts "Detected change inside: #{directories.inspect}" +end +fsevent.run +``` + +### Using _full_ event information + +```ruby +require 'rb-fsevent' +fsevent = FSEvent.new +fsevent.watch Dir.pwd do |paths, event_meta| + event_meta['events'].each do |event| + puts "event ID: #{event['id']}" + puts "path: #{event['path']}" + puts "c flags: #{event['cflags']}" + puts "named flags: #{event['flags'].join(', ')}" + # named flags will include strings such as `ItemInodeMetaMod` or `OwnEvent` + end +end +fsevent.run +``` + +## Options + +When defining options using a hash or hash-like object, it gets checked for validity and converted to the appropriate fsevent\_watch commandline arguments array when the FSEvent class is instantiated. This is obviously the safest and preferred method of passing in options. + +You may, however, choose to pass in an array of commandline arguments as your options value and it will be passed on, unmodified, to the fsevent\_watch binary when called. + +So far, the following options are supported: + +* :latency => 0.5 # in seconds +* :no\_defer => true +* :watch\_root => true +* :since\_when => 18446744073709551615 # an FSEventStreamEventId +* :file\_events => true + +### Latency + +The :latency parameter determines how long the service should wait after the first event before passing that information along to the client. If your latency is set to 4 seconds, and 300 changes occur in the first three, then the callback will be fired only once. If latency is set to 0.1 in the exact same scenario, you will see that callback fire somewhere closer to between 25 and 30 times. + +Setting a higher latency value allows for more effective temporal coalescing, resulting in fewer callbacks and greater overall efficiency... at the cost of apparent responsiveness. Setting this to a reasonably high value (and NOT setting :no\_defer) is particularly well suited for background, daemon, or batch processing applications. + +Implementation note: It appears that FSEvents will only coalesce events from a maximum of 32 distinct subpaths, making the above completely accurate only when events are to fewer than 32 subpaths. Creating 300 files in one directory, for example, or 30 files in 10 subdirectories, but not 300 files within 300 subdirectories. In the latter case, you may receive 31 callbacks in one go after the latency period. As this appears to be an implementation detail, the number could potentially differ across OS revisions. It is entirely possible that this number is somehow configurable, but I have not yet discovered an accepted method of doing so. + +### NoDefer + +The :no\_defer option changes the behavior of the latency parameter completely. Rather than waiting for $latency period of time before sending along events in an attempt to coalesce a potential deluge ahead of time, that first event is sent along to the client immediately and is followed by a $latency period of silence before sending along any additional events that occurred within that period. + +This behavior is particularly useful for interactive applications where that feeling of apparent responsiveness is most important, but you still don't want to get overwhelmed by a series of events that occur in rapid succession. + +### WatchRoot + +The :watch\_root option allows for catching the scenario where you start watching "~/src/demo\_project" and either it is later renamed to "~/src/awesome\_sauce\_3000" or the path changes in such a manner that the original directory is now at "~/clients/foo/iteration4/demo\_project". + +Unfortunately, while this behavior is somewhat supported in the fsevent\_watch binary built as part of this project, support for passing across detailed metadata is not (yet). As a result, you would not receive the appropriate RootChanged event and be able to react appropriately. Also, since the C code doesn't open watched directories and retain that file descriptor as part of path-specific callback metadata, we are unable to issue an F\_GETPATH fcntl() to determine the directory's new path. + +Please do not use this option until proper support is added (or, even better, add it and submit a pull request). + +### SinceWhen + +The FSEventStreamEventId passed in to :since\_when is used as a base for reacting to historic events. Unfortunately, not only is the metadata for transitioning from historic to live events not currently passed along, but it is incorrectly passed as a change event on the root path, and only per-host event streams are currently supported. When using per-host event streams, the event IDs are not guaranteed to be unique or contiguous when shared volumes (firewire/USB/net/etc) are used on multiple macs. + +Please do not use this option until proper support is added, unless it's acceptable for you to receive that one fake event that's handled incorrectly when events transition from historical to live. Even in that scenario, there's no metadata available for determining the FSEventStreamEventId of the last received event. + +WARNING: passing in 0 as the parameter to :since\_when will return events for every directory modified since "the beginning of time". + +### FileEvents ### + +Prepare yourself for an obscene number of callbacks. Realistically, an "Atomic Save" could easily fire maybe 6 events for the combination of creating the new file, changing metadata/permissions, writing content, swapping out the old file for the new may itself result in multiple events being fired, and so forth. By the time you get the event for the temporary file being created as part of the atomic save, it will already be gone and swapped with the original file. This and issues of a similar nature have prevented me from adding the option to the ruby code despite the fsevent\_watch binary supporting file level events for quite some time now. Mountain Lion seems to be better at coalescing needless events, but that might just be my imagination. + +## Debugging output + +If the gem is re-compiled with the environment variable FWDEBUG set, then fsevent\_watch will be built with its various DEBUG sections defined, and the output to STDERR is truly verbose (and hopefully helpful in debugging your application and not just fsevent\_watch itself). If enough people find this to be directly useful when developing code that makes use of rb-fsevent, then it wouldn't be hard to clean this up and make it a feature enabled by a commandline argument instead. Until somebody files an issue, however, I will assume otherwise. + + append_path called for: /tmp/moo/cow/ + resolved path to: /private/tmp/moo/cow + + config.sinceWhen 18446744073709551615 + config.latency 0.300000 + config.flags 00000000 + config.paths + /private/tmp/moo/cow + + FSEventStreamRef @ 0x100108540: + allocator = 0x7fff705a4ee0 + callback = 0x10000151e + context = {0, 0x0, 0x0, 0x0, 0x0} + numPathsToWatch = 1 + pathsToWatch = 0x7fff705a4ee0 + pathsToWatch[0] = '/private/tmp/moo/cow' + latestEventId = -1 + latency = 300000 (microseconds) + flags = 0x00000000 + runLoop = 0x0 + runLoopMode = 0x0 + + FSEventStreamCallback fired! + numEvents: 32 + event path: /private/tmp/moo/cow/1/a/ + event flags: 00000000 + event ID: 1023767 + event path: /private/tmp/moo/cow/1/b/ + event flags: 00000000 + event ID: 1023782 + event path: /private/tmp/moo/cow/1/c/ + event flags: 00000000 + event ID: 1023797 + event path: /private/tmp/moo/cow/1/d/ + event flags: 00000000 + event ID: 1023812 + [etc] + + +## Development + +* Source hosted at [GitHub](http://github.com/thibaudgg/rb-fsevent) +* Report issues/Questions/Feature requests on [GitHub Issues](http://github.com/thibaudgg/rb-fsevent/issues) + +Pull requests are quite welcome! Please ensure that your commits are in a topic branch for each individual changeset that can be reasonably isolated. It is also important to ensure that your changes are well tested... whether that means new tests, modified tests, or fixing a scenario where the existing tests currently fail. If you have rbenv and ruby-build, we have a helper task for running the testsuite in all of them: + + rake spec:portability + +The list of tested targets is currently: + + %w[2.4.1 rbx-3.72 jruby-1.7.26 jruby-9.1.8.0] + +## Authors + +* [Travis Tilley](http://github.com/ttilley) +* [Thibaud Guillaume-Gentil](http://github.com/thibaudgg) +* [Andrey Tarantsov](https://github.com/andreyvit) diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Rakefile b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Rakefile new file mode 100644 index 0000000..53a08a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/Rakefile @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +require 'bundler' +Bundler::GemHelper.install_tasks + +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) +task :default => :spec + +namespace(:spec) do + desc "Run all specs on multiple ruby versions" + task(:portability) do + versions = %w[2.4.1 rbx-3.72 jruby-1.7.26 jruby-9.1.8.0] + versions.each do |version| + # system <<-BASH + # bash -c 'source ~/.rvm/scripts/rvm; + # rvm #{version}; + # echo "--------- version #{version} ----------\n"; + # bundle install; + # rake spec' + # BASH + system <<-BASH + bash -c 'export PATH="$HOME/.rbenv/bin:$PATH"; + [[ `which rbenv` ]] && eval "$(rbenv init -)"; + [[ ! -a $HOME/.rbenv/versions/#{version} ]] && rbenv install #{version}; + rbenv shell #{version}; + rbenv which bundle 2> /dev/null || gem install bundler; + rm Gemfile.lock; + bundle install; + rake spec;' + BASH + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/bin/fsevent_watch b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/bin/fsevent_watch new file mode 100755 index 0000000..4fb821d Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/bin/fsevent_watch differ diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/LICENSE b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/LICENSE new file mode 100644 index 0000000..a35e195 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2011-2013 Travis Tilley + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/FSEventsFix.c b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/FSEventsFix.c new file mode 100644 index 0000000..60e3d37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/FSEventsFix.c @@ -0,0 +1,626 @@ +/* + * FSEventsFix + * + * Resolves a long-standing bug in realpath() that prevents FSEvents API from + * monitoring certain folders on a wide range of OS X released (10.6-10.10 at least). + * + * The underlying issue is that for some folders, realpath() call starts returning + * a path with incorrect casing (e.g. "/users/smt" instead of "/Users/smt"). + * FSEvents is case-sensitive and calls realpath() on the paths you pass in, so + * an incorrect value returned by realpath() prevents FSEvents from seeing any + * change events. + * + * See the discussion at https://github.com/thibaudgg/rb-fsevent/issues/10 about + * the history of this bug and how this library came to exist. + * + * This library uses Facebook's fishhook to replace a custom implementation of + * realpath in place of the system realpath; FSEvents will then invoke our custom + * implementation (which does not screw up the names) and will thus work correctly. + * + * Our implementation of realpath is based on the open-source implementation from + * OS X 10.10, with a single change applied (enclosed in "BEGIN WORKAROUND FOR + * OS X BUG" ... "END WORKAROUND FOR OS X BUG"). + * + * Include FSEventsFix.{h,c} into your project and call FSEventsFixInstall(). + * + * It is recommended that you install FSEventsFix on demand, using FSEventsFixIsBroken + * to check if the folder you're about to pass to FSEventStreamCreate needs the fix. + * Note that the fix must be applied before calling FSEventStreamCreate. + * + * FSEventsFixIsBroken requires a path that uses the correct case for all folder names, + * i.e. a path provided by the system APIs or constructed from folder names provided + * by the directory enumeration APIs. + * + * Copyright (c) 2015 Andrey Tarantsov + * Copyright (c) 2003 Constantin S. Svintsoff + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Based on a realpath implementation from Apple libc 498.1.7, taken from + * http://www.opensource.apple.com/source/Libc/Libc-498.1.7/stdlib/FreeBSD/realpath.c + * and provided under the following license: + * + * Copyright (c) 2003 Constantin S. Svintsoff + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. + * 3. The names of the authors may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + */ + + +#include "FSEventsFix.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +const char *const FSEventsFixVersionString = "0.11.0"; + + +#pragma mark - Forward declarations + +static char *(*orig_realpath)(const char *restrict file_name, char resolved_name[PATH_MAX]); +static char *CFURL_realpath(const char *restrict file_name, char resolved_name[PATH_MAX]); +static char *FSEventsFix_realpath_wrapper(const char *restrict src, char *restrict dst); + +static void _FSEventsFixHookInstall(); +static void _FSEventsFixHookUninstall(); + + +#pragma mark - Internal state + +static dispatch_queue_t g_queue = NULL; + +static int64_t g_enable_refcount = 0; + +static bool g_in_self_test = false; +static bool g_hook_operational = false; + +static void(^g_logging_block)(FSEventsFixMessageType type, const char *message); +static FSEventsFixDebugOptions g_debug_opt = 0; + +typedef struct { + char *name; + void *replacement; + void *original; + uint hooked_symbols; +} rebinding_t; + +static rebinding_t g_rebindings[] = { + { "_realpath$DARWIN_EXTSN", (void *) &FSEventsFix_realpath_wrapper, (void *) &realpath, 0 } +}; +static const uint g_rebindings_nel = sizeof(g_rebindings) / sizeof(g_rebindings[0]); + + +#pragma mark - Logging + +static void _FSEventsFixLog(FSEventsFixMessageType type, const char *__restrict fmt, ...) __attribute__((__format__ (__printf__, 2, 3))); + +static void _FSEventsFixLog(FSEventsFixMessageType type, const char *__restrict fmt, ...) { + if (g_logging_block) { + char *message = NULL; + va_list va; + va_start(va, fmt); + vasprintf(&message, fmt, va); + va_end(va); + + if (message) { + if (!!(g_debug_opt & FSEventsFixDebugOptionLogToStderr)) { + fprintf(stderr, "FSEventsFix: %s\n", message); + } + if (g_logging_block) { + g_logging_block(type, message); + } + free(message); + } + } +} + + +#pragma mark - API + +void _FSEventsFixInitialize() { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + g_queue = dispatch_queue_create("FSEventsFix", DISPATCH_QUEUE_SERIAL); + }); +} + +void FSEventsFixConfigure(FSEventsFixDebugOptions debugOptions, void(^loggingBlock)(FSEventsFixMessageType severity, const char *message)) { + _FSEventsFixInitialize(); + loggingBlock = Block_copy(loggingBlock); + dispatch_sync(g_queue, ^{ + g_debug_opt = debugOptions; + g_logging_block = loggingBlock; + }); +} + +// Must be called from the private serial queue. +void _FSEventsFixSelfTest() { + g_in_self_test = true; + g_hook_operational = false; + static char result[1024]; + realpath("/Etc/__!FSEventsFixSelfTest!__", result); + g_in_self_test = false; +} + +void FSEventsFixEnable() { + _FSEventsFixInitialize(); + dispatch_sync(g_queue, ^{ + if (++g_enable_refcount == 1) { + orig_realpath = dlsym(RTLD_DEFAULT, "realpath"); + _FSEventsFixHookInstall(); + _FSEventsFixSelfTest(); + if (g_hook_operational) { + _FSEventsFixLog(FSEventsFixMessageTypeStatusChange, "Enabled"); + } else { + _FSEventsFixLog(FSEventsFixMessageTypeFatalError, "Failed to enable (hook not called)"); + } + } + }); +} + +void FSEventsFixDisable() { + _FSEventsFixInitialize(); + dispatch_sync(g_queue, ^{ + if (g_enable_refcount == 0) { + abort(); + } + if (--g_enable_refcount == 0) { + _FSEventsFixHookUninstall(); + _FSEventsFixSelfTest(); + if (!g_hook_operational) { + _FSEventsFixLog(FSEventsFixMessageTypeStatusChange, "Disabled"); + } else { + _FSEventsFixLog(FSEventsFixMessageTypeFatalError, "Failed to disable (hook still called)"); + } + } + }); +} + +bool FSEventsFixIsOperational() { + _FSEventsFixInitialize(); + __block bool result = false; + dispatch_sync(g_queue, ^{ + result = g_hook_operational; + }); + return result; +} + +bool _FSEventsFixIsBroken_noresolve(const char *resolved) { + if (!!(g_debug_opt & FSEventsFixDebugOptionSimulateBroken)) { + if (strstr(resolved, FSEventsFixSimulatedBrokenFolderMarker)) { + return true; + } + } + + char *reresolved = realpath(resolved, NULL); + if (reresolved) { + bool broken = (0 != strcmp(resolved, reresolved)); + free(reresolved); + return broken; + } else { + return true; + } +} + +bool FSEventsFixIsBroken(const char *path) { + char *resolved = CFURL_realpath(path, NULL); + if (!resolved) { + return true; + } + bool broken = _FSEventsFixIsBroken_noresolve(resolved); + free(resolved); + return broken; +} + +char *FSEventsFixCopyRootBrokenFolderPath(const char *inpath) { + if (!FSEventsFixIsBroken(inpath)) { + return NULL; + } + + // get a mutable copy of an absolute path + char *path = CFURL_realpath(inpath, NULL); + if (!path) { + return NULL; + } + + for (;;) { + char *sep = strrchr(path, '/'); + if ((sep == NULL) || (sep == path)) { + break; + } + *sep = 0; + if (!_FSEventsFixIsBroken_noresolve(path)) { + *sep = '/'; + break; + } + } + + return path; +} + +static void _FSEventsFixAttemptRepair(const char *folder) { + int rv = rename(folder, folder); + + if (!!(g_debug_opt & FSEventsFixDebugOptionSimulateRepair)) { + const char *pos = strstr(folder, FSEventsFixSimulatedBrokenFolderMarker); + if (pos) { + char *fixed = strdup(folder); + fixed[pos - folder] = 0; + strcat(fixed, pos + strlen(FSEventsFixSimulatedBrokenFolderMarker)); + + rv = rename(folder, fixed); + free(fixed); + } + } + + if (rv != 0) { + if (errno == EPERM) { + _FSEventsFixLog(FSEventsFixMessageTypeResult, "Permission error when trying to repair '%s'", folder); + } else { + _FSEventsFixLog(FSEventsFixMessageTypeExpectedFailure, "Unknown error when trying to repair '%s': errno = %d", folder, errno); + } + } +} + +FSEventsFixRepairStatus FSEventsFixRepairIfNeeded(const char *inpath) { + char *root = FSEventsFixCopyRootBrokenFolderPath(inpath); + if (root == NULL) { + return FSEventsFixRepairStatusNotBroken; + } + + for (;;) { + _FSEventsFixAttemptRepair(root); + char *newRoot = FSEventsFixCopyRootBrokenFolderPath(inpath); + if (newRoot == NULL) { + _FSEventsFixLog(FSEventsFixMessageTypeResult, "Repaired '%s' in '%s'", root, inpath); + free(root); + return FSEventsFixRepairStatusRepaired; + } + if (0 == strcmp(root, newRoot)) { + _FSEventsFixLog(FSEventsFixMessageTypeResult, "Failed to repair '%s' in '%s'", root, inpath); + free(root); + free(newRoot); + return FSEventsFixRepairStatusFailed; + } + _FSEventsFixLog(FSEventsFixMessageTypeResult, "Partial success, repaired '%s' in '%s'", root, inpath); + free(root); + root = newRoot; + } +} + + +#pragma mark - FSEventsFix realpath wrapper + +static char *FSEventsFix_realpath_wrapper(const char * __restrict src, char * __restrict dst) { + if (g_in_self_test) { + if (strstr(src, "__!FSEventsFixSelfTest!__")) { + g_hook_operational = true; + } + } + + // CFURL_realpath doesn't support putting where resolution failed into the + // dst buffer, so we call the original realpath here first and if it gets a + // result, replace that with the output of CFURL_realpath. that way all the + // features of the original realpath are available. + char *rv = NULL; + char *orv = orig_realpath(src, dst); + if (orv != NULL) { rv = CFURL_realpath(src, dst); } + + if (!!(g_debug_opt & FSEventsFixDebugOptionLogCalls)) { + char *result = rv ?: dst; + _FSEventsFixLog(FSEventsFixMessageTypeCall, "realpath(%s) => %s\n", src, result); + } + + if (!!(g_debug_opt & FSEventsFixDebugOptionUppercaseReturn)) { + char *result = rv ?: dst; + if (result) { + for (char *pch = result; *pch; ++pch) { + *pch = (char)toupper(*pch); + } + } + } + + return rv; +} + + +#pragma mark - realpath + +// naive implementation of realpath on top of CFURL +// NOTE: doesn't quite support the full range of errno results one would +// expect here, in part because some of these functions just return a boolean, +// and in part because i'm not dealing with messy CFErrorRef objects and +// attempting to translate those to sane errno values. +// NOTE: the OSX realpath will return _where_ resolution failed in resolved_name +// if passed in and return NULL. we can't properly support that extension here +// since the resolution happens entirely behind the scenes to us in CFURL. +static char* CFURL_realpath(const char *file_name, char resolved_name[PATH_MAX]) +{ + char* resolved; + CFURLRef url1; + CFURLRef url2; + CFStringRef path; + + if (file_name == NULL) { + errno = EINVAL; + return (NULL); + } + +#if __DARWIN_UNIX03 + if (*file_name == 0) { + errno = ENOENT; + return (NULL); + } +#endif + + // create a buffer to store our result if we weren't passed one + if (!resolved_name) { + if ((resolved = malloc(PATH_MAX)) == NULL) return (NULL); + } else { + resolved = resolved_name; + } + + url1 = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)file_name, (CFIndex)strlen(file_name), false); + if (url1 == NULL) { goto error_return; } + + url2 = CFURLCopyAbsoluteURL(url1); + CFRelease(url1); + if (url2 == NULL) { goto error_return; } + + url1 = CFURLCreateFileReferenceURL(NULL, url2, NULL); + CFRelease(url2); + if (url1 == NULL) { goto error_return; } + + // if there are multiple hard links to the original path, this may end up + // being _completely_ different from what was intended + url2 = CFURLCreateFilePathURL(NULL, url1, NULL); + CFRelease(url1); + if (url2 == NULL) { goto error_return; } + + path = CFURLCopyFileSystemPath(url2, kCFURLPOSIXPathStyle); + CFRelease(url2); + if (path == NULL) { goto error_return; } + + bool success = CFStringGetCString(path, resolved, PATH_MAX, kCFStringEncodingUTF8); + CFRelease(path); + if (!success) { goto error_return; } + + return resolved; + +error_return: + if (!resolved_name) { + // we weren't passed in an output buffer and created our own. free it + int e = errno; + free(resolved); + errno = e; + } + return (NULL); +} + + +#pragma mark - fishhook + +// Copyright (c) 2013, Facebook, Inc. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * 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. +// * Neither the name Facebook nor the names of its contributors may be used to +// endorse or promote products derived from this software without specific +// prior written permission. +// 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. + +#import +#import +#import +#import +#import +#import + +#ifdef __LP64__ +typedef struct mach_header_64 mach_header_t; +typedef struct segment_command_64 segment_command_t; +typedef struct section_64 section_t; +typedef struct nlist_64 nlist_t; +#define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT_64 +#else +typedef struct mach_header mach_header_t; +typedef struct segment_command segment_command_t; +typedef struct section section_t; +typedef struct nlist nlist_t; +#define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT +#endif + +static volatile bool g_hook_installed = false; + +static void _FSEventsFixHookUpdateSection(section_t *section, intptr_t slide, nlist_t *symtab, char *strtab, uint32_t *indirect_symtab) +{ + uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1; + void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr); + for (uint i = 0; i < section->size / sizeof(void *); i++) { + uint32_t symtab_index = indirect_symbol_indices[i]; + if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL || + symtab_index == (INDIRECT_SYMBOL_LOCAL | INDIRECT_SYMBOL_ABS)) { + continue; + } + uint32_t strtab_offset = symtab[symtab_index].n_un.n_strx; + char *symbol_name = strtab + strtab_offset; + for (rebinding_t *cur = g_rebindings, *end = g_rebindings + g_rebindings_nel; cur < end; ++cur) { + if (strcmp(symbol_name, cur->name) == 0) { + if (g_hook_installed) { + if (indirect_symbol_bindings[i] != cur->replacement) { + indirect_symbol_bindings[i] = cur->replacement; + ++cur->hooked_symbols; + } + } else if (cur->original != NULL) { + if (indirect_symbol_bindings[i] == cur->replacement) { + indirect_symbol_bindings[i] = cur->original; + if (cur->hooked_symbols > 0) { + --cur->hooked_symbols; + } + } + } + goto symbol_loop; + } + } + symbol_loop:; + } +} + +static void _FSEventsFixHookUpdateImage(const struct mach_header *header, intptr_t slide) { + Dl_info info; + if (dladdr(header, &info) == 0) { + return; + } + + segment_command_t *cur_seg_cmd; + segment_command_t *linkedit_segment = NULL; + struct symtab_command* symtab_cmd = NULL; + struct dysymtab_command* dysymtab_cmd = NULL; + + uintptr_t cur = (uintptr_t)header + sizeof(mach_header_t); + for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) { + cur_seg_cmd = (segment_command_t *)cur; + if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) { + if (strcmp(cur_seg_cmd->segname, SEG_LINKEDIT) == 0) { + linkedit_segment = cur_seg_cmd; + } + } else if (cur_seg_cmd->cmd == LC_SYMTAB) { + symtab_cmd = (struct symtab_command*)cur_seg_cmd; + } else if (cur_seg_cmd->cmd == LC_DYSYMTAB) { + dysymtab_cmd = (struct dysymtab_command*)cur_seg_cmd; + } + } + + if (!symtab_cmd || !dysymtab_cmd || !linkedit_segment || + !dysymtab_cmd->nindirectsyms) { + return; + } + + // Find base symbol/string table addresses + uintptr_t linkedit_base = (uintptr_t)slide + linkedit_segment->vmaddr - linkedit_segment->fileoff; + nlist_t *symtab = (nlist_t *)(linkedit_base + symtab_cmd->symoff); + char *strtab = (char *)(linkedit_base + symtab_cmd->stroff); + + // Get indirect symbol table (array of uint32_t indices into symbol table) + uint32_t *indirect_symtab = (uint32_t *)(linkedit_base + dysymtab_cmd->indirectsymoff); + + cur = (uintptr_t)header + sizeof(mach_header_t); + for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) { + cur_seg_cmd = (segment_command_t *)cur; + if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) { + if (strcmp(cur_seg_cmd->segname, SEG_DATA) != 0) { + continue; + } + for (uint j = 0; j < cur_seg_cmd->nsects; j++) { + section_t *sect = + (section_t *)(cur + sizeof(segment_command_t)) + j; + if ((sect->flags & SECTION_TYPE) == S_LAZY_SYMBOL_POINTERS) { + _FSEventsFixHookUpdateSection(sect, slide, symtab, strtab, indirect_symtab); + } + if ((sect->flags & SECTION_TYPE) == S_NON_LAZY_SYMBOL_POINTERS) { + _FSEventsFixHookUpdateSection(sect, slide, symtab, strtab, indirect_symtab); + } + } + } + } +} + +static void _FSEventsFixHookSaveOriginals() { + for (rebinding_t *cur = g_rebindings, *end = g_rebindings + g_rebindings_nel; cur < end; ++cur) { + void *original = cur->original = dlsym(RTLD_DEFAULT, cur->name+1); + if (!original) { + const char *error = dlerror(); + _FSEventsFixLog(FSEventsFixMessageTypeFatalError, "Cannot find symbol %s, dlsym says: %s\n", cur->name, error); + } + } +} + +static void _FSEventsFixHookUpdate() { + uint32_t c = _dyld_image_count(); + for (uint32_t i = 0; i < c; i++) { + _FSEventsFixHookUpdateImage(_dyld_get_image_header(i), _dyld_get_image_vmaddr_slide(i)); + } +} + +static void _FSEventsFixHookInstall() { + static bool first_rebinding_done = false; + + if (!g_hook_installed) { + g_hook_installed = true; + + if (!first_rebinding_done) { + first_rebinding_done = true; + _FSEventsFixHookSaveOriginals(); + _dyld_register_func_for_add_image(_FSEventsFixHookUpdateImage); + } else { + _FSEventsFixHookUpdate(); + } + } +} + +static void _FSEventsFixHookUninstall() { + if (g_hook_installed) { + g_hook_installed = false; + _FSEventsFixHookUpdate(); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/FSEventsFix.h b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/FSEventsFix.h new file mode 100644 index 0000000..b70b880 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/FSEventsFix.h @@ -0,0 +1,105 @@ +/* + * FSEventsFix + * + * Works around a long-standing bug in realpath() that prevents FSEvents API from + * monitoring certain folders on a wide range of OS X releases (10.6-10.10 at least). + * + * The underlying issue is that for some folders, realpath() call starts returning + * a path with incorrect casing (e.g. "/users/smt" instead of "/Users/smt"). + * FSEvents is case-sensitive and calls realpath() on the paths you pass in, so + * an incorrect value returned by realpath() prevents FSEvents from seeing any + * change events. + * + * See the discussion at https://github.com/thibaudgg/rb-fsevent/issues/10 about + * the history of this bug and how this library came to exist. + * + * This library uses Facebook's fishhook to replace a custom implementation of + * realpath in place of the system realpath; FSEvents will then invoke our custom + * implementation (which does not screw up the names) and will thus work correctly. + * + * Our implementation of realpath is based on the open-source implementation from + * OS X 10.10, with a single change applied (enclosed in "BEGIN WORKAROUND FOR + * OS X BUG" ... "END WORKAROUND FOR OS X BUG"). + * + * Include FSEventsFix.{h,c} into your project and call FSEventsFixInstall(). + * + * It is recommended that you install FSEventsFix on demand, using FSEventsFixIsBroken + * to check if the folder you're about to pass to FSEventStreamCreate needs the fix. + * Note that the fix must be applied before calling FSEventStreamCreate. + * + * FSEventsFixIsBroken requires a path that uses the correct case for all folder names, + * i.e. a path provided by the system APIs or constructed from folder names provided + * by the directory enumeration APIs. + * + * See .c file for license & copyrights, but basically this is available under a mix + * of MIT and BSD licenses. + */ + +#ifndef __FSEventsFix__ +#define __FSEventsFix__ + +#include + +/// A library version string (e.g. 1.2.3) for displaying and logging purposes +extern const char *const FSEventsFixVersionString; + +/// See FSEventsFixDebugOptionSimulateBroken +#define FSEventsFixSimulatedBrokenFolderMarker "__!FSEventsBroken!__" + +typedef CF_OPTIONS(unsigned, FSEventsFixDebugOptions) { + /// Always return an uppercase string from realpath + FSEventsFixDebugOptionUppercaseReturn = 0x01, + + /// Log all calls to realpath using the logger configured via FSEventsFixConfigure + FSEventsFixDebugOptionLogCalls = 0x02, + + /// In addition to the logging block (if any), log everything to stderr + FSEventsFixDebugOptionLogToStderr = 0x08, + + /// Report paths containing FSEventsFixSimulatedBrokenFolderMarker as broken + FSEventsFixDebugOptionSimulateBroken = 0x10, + + /// Repair paths containing FSEventsFixSimulatedBrokenFolderMarker by renaming them + FSEventsFixDebugOptionSimulateRepair = 0x20, +}; + +typedef CF_ENUM(int, FSEventsFixMessageType) { + /// Call logging requested via FSEventsFixDebugOptionLogCalls + FSEventsFixMessageTypeCall, + + /// Results of actions like repair, and other pretty verbose, but notable, stuff. + FSEventsFixMessageTypeResult, + + /// Enabled/disabled status change + FSEventsFixMessageTypeStatusChange, + + /// Expected failure (treat as a warning) + FSEventsFixMessageTypeExpectedFailure, + + /// Severe failure that most likely means that the library won't work + FSEventsFixMessageTypeFatalError +}; + +typedef CF_ENUM(int, FSEventsFixRepairStatus) { + FSEventsFixRepairStatusNotBroken, + FSEventsFixRepairStatusRepaired, + FSEventsFixRepairStatusFailed, +}; + +/// Note that the logging block can be called on any dispatch queue. +void FSEventsFixConfigure(FSEventsFixDebugOptions debugOptions, void(^loggingBlock)(FSEventsFixMessageType type, const char *message)); + +void FSEventsFixEnable(); +void FSEventsFixDisable(); + +bool FSEventsFixIsOperational(); + +bool FSEventsFixIsBroken(const char *path); + +/// If the path is broken, returns a string identifying the root broken folder, +/// otherwise, returns NULL. You need to free() the returned string. +char *FSEventsFixCopyRootBrokenFolderPath(const char *path); + +FSEventsFixRepairStatus FSEventsFixRepairIfNeeded(const char *path); + +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/TSICTString.c b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/TSICTString.c new file mode 100644 index 0000000..6e033d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/TSICTString.c @@ -0,0 +1,373 @@ +// +// TSICTString.c +// TSITString +// +// Created by Travis Tilley on 9/27/11. +// + +#include "TSICTString.h" + + +const char* const TNetstringTypes = ",#^!~}]Z"; +const char* const OTNetstringTypes = ",#^!~{[Z"; +const UInt8 TNetstringSeparator = ':'; + +TSITStringFormat TSITStringDefaultFormat = kTSITStringFormatTNetstring; + +static const CFRange BeginningRange = {0,0}; + +static CFTypeID kCFDataTypeID = -1UL; +static CFTypeID kCFStringTypeID = -1UL; +static CFTypeID kCFNumberTypeID = -1UL; +static CFTypeID kCFBooleanTypeID = -1UL; +static CFTypeID kCFNullTypeID = -1UL; +static CFTypeID kCFArrayTypeID = -1UL; +static CFTypeID kCFDictionaryTypeID = -1UL; + + +__attribute__((constructor)) void Init_TSICTString(void) +{ + kCFDataTypeID = CFDataGetTypeID(); + kCFStringTypeID = CFStringGetTypeID(); + kCFNumberTypeID = CFNumberGetTypeID(); + kCFBooleanTypeID = CFBooleanGetTypeID(); + kCFNullTypeID = CFNullGetTypeID(); + kCFArrayTypeID = CFArrayGetTypeID(); + kCFDictionaryTypeID = CFDictionaryGetTypeID(); +} + + +void TSICTStringSetDefaultFormat(TSITStringFormat format) +{ + if (format == kTSITStringFormatDefault) { + TSITStringDefaultFormat = kTSITStringFormatTNetstring; + } else { + TSITStringDefaultFormat = format; + } +} + +TSITStringFormat TSICTStringGetDefaultFormat(void) +{ + return TSITStringDefaultFormat; +} + + +void TSICTStringDestroy(TStringIRep* rep) +{ + CFRelease(rep->data); + free(rep->length); + free(rep); +} + + +static inline TStringIRep* TSICTStringCreateWithDataOfTypeAndFormat(CFDataRef data, TSITStringTag type, TSITStringFormat format) +{ + if (format == kTSITStringFormatDefault) { + format = TSICTStringGetDefaultFormat(); + } + + TStringIRep* rep = calloc(1, sizeof(TStringIRep)); + rep->data = CFDataCreateCopy(kCFAllocatorDefault, data); + rep->type = type; + rep->format = format; + rep->length = calloc(10, sizeof(char)); + + CFIndex len = CFDataGetLength(rep->data); + if (snprintf(rep->length, 10, "%lu", len)) { + return rep; + } else { + TSICTStringDestroy(rep); + return NULL; + } +} + +static inline CFDataRef TSICTStringCreateDataFromIntermediateRepresentation(TStringIRep* rep) +{ + CFIndex len = CFDataGetLength(rep->data); + CFMutableDataRef buffer = CFDataCreateMutableCopy(kCFAllocatorDefault, (len + 12), rep->data); + UInt8* bufferBytes = CFDataGetMutableBytePtr(buffer); + + size_t prefixLength = strlen(rep->length) + 1; + CFDataReplaceBytes(buffer, BeginningRange, (const UInt8*)rep->length, (CFIndex)prefixLength); + + if (rep->format == kTSITStringFormatTNetstring) { + const UInt8 ftag = (UInt8)TNetstringTypes[rep->type]; + CFDataAppendBytes(buffer, &ftag, 1); + bufferBytes[(prefixLength - 1)] = TNetstringSeparator; + } else if (rep->format == kTSITStringFormatOTNetstring) { + const UInt8 ftag = (UInt8)OTNetstringTypes[rep->type]; + bufferBytes[(prefixLength - 1)] = ftag; + } + + CFDataRef dataRep = CFDataCreateCopy(kCFAllocatorDefault, buffer); + CFRelease(buffer); + + return dataRep; +} + +static inline CFStringRef TSICTStringCreateStringFromIntermediateRepresentation(TStringIRep* rep) +{ + CFDataRef data = TSICTStringCreateDataFromIntermediateRepresentation(rep); + CFStringRef string = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, data, kCFStringEncodingUTF8); + CFRelease(data); + return string; +} + +static inline void TSICTStringAppendObjectToMutableDataWithFormat(CFTypeRef object, CFMutableDataRef buffer, TSITStringFormat format) +{ + if (object == NULL) { + object = kCFNull; + } + + CFRetain(object); + + TStringIRep* objRep = TSICTStringCreateWithObjectAndFormat(object, format); + CFDataRef objData = TSICTStringCreateDataFromIntermediateRepresentation(objRep); + CFDataAppendBytes(buffer, (CFDataGetBytePtr(objData)), CFDataGetLength(objData)); + CFRelease(objData); + TSICTStringDestroy(objRep); + + CFRelease(object); +} + +static void ArrayBufferAppendCallback(const void* item, void* context) +{ + TStringCollectionCallbackContext* cx = (TStringCollectionCallbackContext*)context; + CFMutableDataRef buffer = cx->buffer; + TSITStringFormat format = cx->format; + + TSICTStringAppendObjectToMutableDataWithFormat(item, buffer, format); +} + +static void DictionaryBufferAppendCallback(const void* key, const void* value, void* context) +{ + TStringCollectionCallbackContext* cx = (TStringCollectionCallbackContext*)context; + CFMutableDataRef buffer = cx->buffer; + TSITStringFormat format = cx->format; + + TSICTStringAppendObjectToMutableDataWithFormat(key, buffer, format); + TSICTStringAppendObjectToMutableDataWithFormat(value, buffer, format); +} + + +CFDataRef TSICTStringCreateRenderedData(TStringIRep* rep) +{ + return TSICTStringCreateDataFromIntermediateRepresentation(rep); +} + +CFDataRef TSICTStringCreateRenderedDataFromObjectWithFormat(CFTypeRef object, TSITStringFormat format) +{ + if (object == NULL) { + object = kCFNull; + } + + CFRetain(object); + + TStringIRep* rep = TSICTStringCreateWithObjectAndFormat(object, format); + CFDataRef data = TSICTStringCreateDataFromIntermediateRepresentation(rep); + + TSICTStringDestroy(rep); + CFRelease(object); + + return data; +} + +CFStringRef TSICTStringCreateRenderedString(TStringIRep* rep) +{ + return TSICTStringCreateStringFromIntermediateRepresentation(rep); +} + +CFStringRef TSICTStringCreateRenderedStringFromObjectWithFormat(CFTypeRef object, TSITStringFormat format) +{ + if (object == NULL) { + object = kCFNull; + } + + CFRetain(object); + + TStringIRep* rep = TSICTStringCreateWithObjectAndFormat(object, format); + CFStringRef string = TSICTStringCreateStringFromIntermediateRepresentation(rep); + + TSICTStringDestroy(rep); + CFRelease(object); + + return string; +} + + +TStringIRep* TSICTStringCreateWithObjectAndFormat(CFTypeRef object, TSITStringFormat format) +{ + if (object == NULL) { + return TSICTStringCreateNullWithFormat(format); + } + CFRetain(object); + + CFTypeID cfType = CFGetTypeID(object); + TStringIRep* rep = NULL; + + if (cfType == kCFDataTypeID) { + rep = TSICTStringCreateWithDataOfTypeAndFormat(object, kTSITStringTagString, format); + } else if (cfType == kCFStringTypeID) { + rep = TSICTStringCreateWithStringAndFormat(object, format); + } else if (cfType == kCFNumberTypeID) { + rep = TSICTStringCreateWithNumberAndFormat(object, format); + } else if (cfType == kCFBooleanTypeID) { + if (CFBooleanGetValue(object)) { + rep = TSICTStringCreateTrueWithFormat(format); + } else { + rep = TSICTStringCreateFalseWithFormat(format); + } + } else if (cfType == kCFNullTypeID) { + rep = TSICTStringCreateNullWithFormat(format); + } else if (cfType == kCFArrayTypeID) { + rep = TSICTStringCreateWithArrayAndFormat(object, format); + } else if (cfType == kCFDictionaryTypeID) { + rep = TSICTStringCreateWithDictionaryAndFormat(object, format); + } else { + rep = TSICTStringCreateInvalidWithFormat(format); + } + + CFRelease(object); + return rep; +} + +TStringIRep* TSICTStringCreateWithStringAndFormat(CFStringRef string, TSITStringFormat format) +{ + CFRetain(string); + CFDataRef data = CFStringCreateExternalRepresentation(kCFAllocatorDefault, string, kCFStringEncodingUTF8, '?'); + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, kTSITStringTagString, format); + CFRelease(data); + CFRelease(string); + return rep; +} + +TStringIRep* TSICTStringCreateWithNumberAndFormat(CFNumberRef number, TSITStringFormat format) +{ + CFRetain(number); + TSITStringTag tag = kTSITStringTagNumber; + CFDataRef data; + CFNumberType numType = CFNumberGetType(number); + + switch(numType) { + case kCFNumberCharType: + { + int value; + if (CFNumberGetValue(number, kCFNumberIntType, &value)) { + if (value == 0 || value == 1) { + tag = kTSITStringTagBool; + } else { + tag = kTSITStringTagString; + } + } + break; + } + case kCFNumberFloat32Type: + case kCFNumberFloat64Type: + case kCFNumberFloatType: + case kCFNumberDoubleType: + { + tag = kTSITStringTagFloat; + break; + } + } + + if (tag == kTSITStringTagBool) { + bool value; + CFNumberGetValue(number, kCFNumberIntType, &value); + if (value) { + data = CFDataCreate(kCFAllocatorDefault, (UInt8*)"true", 4); + } else { + data = CFDataCreate(kCFAllocatorDefault, (UInt8*)"false", 5); + } + } else if (tag == kTSITStringTagFloat) { + char buf[32]; + char *p, *e; + double value; + + CFNumberGetValue(number, numType, &value); + sprintf(buf, "%#.15g", value); + + e = buf + strlen(buf); + p = e; + while (p[-1]=='0' && ('0' <= p[-2] && p[-2] <= '9')) { + p--; + } + memmove(p, e, strlen(e)+1); + + data = CFDataCreate(kCFAllocatorDefault, (UInt8*)buf, (CFIndex)strlen(buf)); + } else { + char buf[32]; + SInt64 value; + CFNumberGetValue(number, numType, &value); + sprintf(buf, "%lli", value); + data = CFDataCreate(kCFAllocatorDefault, (UInt8*)buf, (CFIndex)strlen(buf)); + } + + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, tag, format); + CFRelease(data); + CFRelease(number); + return rep; +} + +TStringIRep* TSICTStringCreateTrueWithFormat(TSITStringFormat format) +{ + CFDataRef data = CFDataCreate(kCFAllocatorDefault, (UInt8*)"true", 4); + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, kTSITStringTagBool, format); + CFRelease(data); + return rep; +} + +TStringIRep* TSICTStringCreateFalseWithFormat(TSITStringFormat format) +{ + CFDataRef data = CFDataCreate(kCFAllocatorDefault, (UInt8*)"false", 5); + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, kTSITStringTagBool, format); + CFRelease(data); + return rep; +} + +TStringIRep* TSICTStringCreateNullWithFormat(TSITStringFormat format) +{ + CFDataRef data = CFDataCreate(kCFAllocatorDefault, NULL, 0); + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, kTSITStringTagNull, format); + CFRelease(data); + return rep; +} + +TStringIRep* TSICTStringCreateInvalidWithFormat(TSITStringFormat format) +{ + CFDataRef data = CFDataCreate(kCFAllocatorDefault, NULL, 0); + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, kTSITStringTagInvalid, format); + CFRelease(data); + return rep; +} + +TStringIRep* TSICTStringCreateWithArrayAndFormat(CFArrayRef array, TSITStringFormat format) +{ + CFRetain(array); + + CFMutableDataRef buffer = CFDataCreateMutable(kCFAllocatorDefault, 0); + + CFRange all = CFRangeMake(0, CFArrayGetCount(array)); + TStringCollectionCallbackContext cx = {buffer, format}; + CFArrayApplyFunction(array, all, ArrayBufferAppendCallback, &cx); + + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(buffer, kTSITStringTagList, format); + CFRelease(buffer); + CFRelease(array); + return rep; +} + +TStringIRep* TSICTStringCreateWithDictionaryAndFormat(CFDictionaryRef dictionary, TSITStringFormat format) +{ + CFRetain(dictionary); + + CFMutableDataRef buffer = CFDataCreateMutable(kCFAllocatorDefault, 0); + + TStringCollectionCallbackContext cx = {buffer, format}; + CFDictionaryApplyFunction(dictionary, DictionaryBufferAppendCallback, &cx); + + TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(buffer, kTSITStringTagDict, format); + CFRelease(buffer); + CFRelease(dictionary); + return rep; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/TSICTString.h b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/TSICTString.h new file mode 100644 index 0000000..daf085c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/TSICTString.h @@ -0,0 +1,74 @@ +// +// TSICTString.h +// TSITString +// +// Created by Travis Tilley on 9/27/11. +// + +#ifndef TSICTString_H +#define TSICTString_H + +#include + + +typedef enum { + kTSITStringTagString = 0, + kTSITStringTagNumber = 1, + kTSITStringTagFloat = 2, + kTSITStringTagBool = 3, + kTSITStringTagNull = 4, + kTSITStringTagDict = 5, + kTSITStringTagList = 6, + kTSITStringTagInvalid = 7, +} TSITStringTag; + +extern const char* const TNetstringTypes; +extern const char* const OTNetstringTypes; +extern const UInt8 TNetstringSeparator; + +typedef enum { + kTSITStringFormatDefault = 0, + kTSITStringFormatOTNetstring = 1, + kTSITStringFormatTNetstring = 2, +} TSITStringFormat; + +extern TSITStringFormat TSITStringDefaultFormat; + +typedef struct TSITStringIntermediate { + CFDataRef data; + char* length; + TSITStringTag type; + TSITStringFormat format; +} TStringIRep; + +typedef struct { + CFMutableDataRef buffer; + TSITStringFormat format; +} TStringCollectionCallbackContext; + + +void Init_TSICTString(void); + +void TSICTStringSetDefaultFormat(TSITStringFormat format); +TSITStringFormat TSICTStringGetDefaultFormat(void); + +void TSICTStringDestroy(TStringIRep* rep); + +CFDataRef TSICTStringCreateRenderedData(TStringIRep* rep); +CFDataRef TSICTStringCreateRenderedDataFromObjectWithFormat(CFTypeRef object, TSITStringFormat format); + +CFStringRef TSICTStringCreateRenderedString(TStringIRep* rep); +CFStringRef TSICTStringCreateRenderedStringFromObjectWithFormat(CFTypeRef object, TSITStringFormat format); + +TStringIRep* TSICTStringCreateWithObjectAndFormat(CFTypeRef object, TSITStringFormat format); +TStringIRep* TSICTStringCreateWithStringAndFormat(CFStringRef string, TSITStringFormat format); +TStringIRep* TSICTStringCreateWithNumberAndFormat(CFNumberRef number, TSITStringFormat format); +TStringIRep* TSICTStringCreateTrueWithFormat(TSITStringFormat format); +TStringIRep* TSICTStringCreateFalseWithFormat(TSITStringFormat format); +TStringIRep* TSICTStringCreateNullWithFormat(TSITStringFormat format); +TStringIRep* TSICTStringCreateInvalidWithFormat(TSITStringFormat format); +TStringIRep* TSICTStringCreateWithArrayAndFormat(CFArrayRef array, TSITStringFormat format); +TStringIRep* TSICTStringCreateWithDictionaryAndFormat(CFDictionaryRef dictionary, TSITStringFormat format); + + +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/cli.c b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/cli.c new file mode 100644 index 0000000..6d36dd1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/cli.c @@ -0,0 +1,201 @@ +#include +#include "cli.h" + +const char* cli_info_purpose = "A flexible command-line interface for the FSEvents API"; +const char* cli_info_usage = "Usage: fsevent_watch [OPTIONS]... [PATHS]..."; +const char* cli_info_help[] = { + " -h, --help you're looking at it", + " -V, --version print version number and exit", + " -p, --show-plist display the embedded Info.plist values", + " -s, --since-when=EventID fire historical events since ID", + " -l, --latency=seconds latency period (default='0.5')", + " -n, --no-defer enable no-defer latency modifier", + " -r, --watch-root watch for when the root path has changed", + // " -i, --ignore-self ignore current process", + " -F, --file-events provide file level event data", + " -f, --format=name output format (classic, niw, \n" + " tnetstring, otnetstring)", + 0 +}; + +static void default_args (struct cli_info* args_info) +{ + args_info->since_when_arg = kFSEventStreamEventIdSinceNow; + args_info->latency_arg = 0.5; + args_info->no_defer_flag = false; + args_info->watch_root_flag = false; + args_info->ignore_self_flag = false; + args_info->file_events_flag = false; + args_info->mark_self_flag = false; + args_info->format_arg = kFSEventWatchOutputFormatOTNetstring; +} + +static void cli_parser_release (struct cli_info* args_info) +{ + unsigned int i; + + for (i=0; i < args_info->inputs_num; ++i) { + free(args_info->inputs[i]); + } + + if (args_info->inputs_num) { + free(args_info->inputs); + } + + args_info->inputs_num = 0; +} + +void cli_parser_init (struct cli_info* args_info) +{ + default_args(args_info); + + args_info->inputs = 0; + args_info->inputs_num = 0; +} + +void cli_parser_free (struct cli_info* args_info) +{ + cli_parser_release(args_info); +} + +static void cli_print_info_dict (const void *key, + const void *value, + void *context) +{ + CFStringRef entry = CFStringCreateWithFormat(NULL, NULL, + CFSTR("%@:\n %@"), key, value); + if (entry) { + CFShow(entry); + CFRelease(entry); + } +} + +void cli_show_plist (void) +{ + CFBundleRef mainBundle = CFBundleGetMainBundle(); + CFRetain(mainBundle); + CFDictionaryRef mainBundleDict = CFBundleGetInfoDictionary(mainBundle); + if (mainBundleDict) { + CFRetain(mainBundleDict); + printf("Embedded Info.plist metadata:\n\n"); + CFDictionaryApplyFunction(mainBundleDict, cli_print_info_dict, NULL); + CFRelease(mainBundleDict); + } + CFRelease(mainBundle); + printf("\n"); +} + +void cli_print_version (void) +{ + printf("%s %s\n\n", CLI_NAME, CLI_VERSION); +#ifdef COMPILED_AT + printf("Compiled at: %s\n", COMPILED_AT); +#endif +#ifdef COMPILER + printf("Compiled with: %s\n", COMPILER); +#endif +#ifdef TARGET_CPU + printf("Compiled for: %s\n", TARGET_CPU); +#endif + printf("\n"); +} + +void cli_print_help (void) +{ + cli_print_version(); + + printf("\n%s\n", cli_info_purpose); + printf("\n%s\n", cli_info_usage); + printf("\n"); + + int i = 0; + while (cli_info_help[i]) { + printf("%s\n", cli_info_help[i++]); + } +} + +int cli_parser (int argc, const char** argv, struct cli_info* args_info) +{ + static struct option longopts[] = { + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'V' }, + { "show-plist", no_argument, NULL, 'p' }, + { "since-when", required_argument, NULL, 's' }, + { "latency", required_argument, NULL, 'l' }, + { "no-defer", no_argument, NULL, 'n' }, + { "watch-root", no_argument, NULL, 'r' }, + { "ignore-self", no_argument, NULL, 'i' }, + { "file-events", no_argument, NULL, 'F' }, + { "mark-self", no_argument, NULL, 'm' }, + { "format", required_argument, NULL, 'f' }, + { 0, 0, 0, 0 } + }; + + const char* shortopts = "hVps:l:nriFf:"; + + int c = -1; + + while ((c = getopt_long(argc, (char * const*)argv, shortopts, longopts, NULL)) != -1) { + switch(c) { + case 's': // since-when + args_info->since_when_arg = strtoull(optarg, NULL, 0); + break; + case 'l': // latency + args_info->latency_arg = strtod(optarg, NULL); + break; + case 'n': // no-defer + args_info->no_defer_flag = true; + break; + case 'r': // watch-root + args_info->watch_root_flag = true; + break; + case 'i': // ignore-self + args_info->ignore_self_flag = true; + break; + case 'F': // file-events + args_info->file_events_flag = true; + break; + case 'm': // mark-self + args_info->mark_self_flag = true; + break; + case 'f': // format + if (strcmp(optarg, "classic") == 0) { + args_info->format_arg = kFSEventWatchOutputFormatClassic; + } else if (strcmp(optarg, "niw") == 0) { + args_info->format_arg = kFSEventWatchOutputFormatNIW; + } else if (strcmp(optarg, "tnetstring") == 0) { + args_info->format_arg = kFSEventWatchOutputFormatTNetstring; + } else if (strcmp(optarg, "otnetstring") == 0) { + args_info->format_arg = kFSEventWatchOutputFormatOTNetstring; + } else { + fprintf(stderr, "Unknown output format: %s\n", optarg); + exit(EXIT_FAILURE); + } + break; + case 'V': // version + cli_print_version(); + exit(EXIT_SUCCESS); + case 'p': // show-plist + cli_show_plist(); + exit(EXIT_SUCCESS); + case 'h': // help + case '?': // invalid option + case ':': // missing argument + cli_print_help(); + exit((c == 'h') ? EXIT_SUCCESS : EXIT_FAILURE); + } + } + + if (optind < argc) { + int i = 0; + args_info->inputs_num = (unsigned int)(argc - optind); + args_info->inputs = + (char**)(malloc ((args_info->inputs_num)*sizeof(char*))); + while (optind < argc) + if (argv[optind++] != argv[0]) { + args_info->inputs[i++] = strdup(argv[optind-1]); + } + } + + return EXIT_SUCCESS; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/cli.h b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/cli.h new file mode 100644 index 0000000..2164995 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/cli.h @@ -0,0 +1,45 @@ +#ifndef CLI_H +#define CLI_H + +#include "common.h" + +#ifndef CLI_NAME +#define CLI_NAME "fsevent_watch" +#endif /* CLI_NAME */ + +#ifndef PROJECT_VERSION +#error "PROJECT_VERSION not set" +#endif /* PROJECT_VERSION */ + +#ifndef CLI_VERSION +#define CLI_VERSION _xstr(PROJECT_VERSION) +#endif /* CLI_VERSION */ + + +struct cli_info { + UInt64 since_when_arg; + double latency_arg; + bool no_defer_flag; + bool watch_root_flag; + bool ignore_self_flag; + bool file_events_flag; + bool mark_self_flag; + enum FSEventWatchOutputFormat format_arg; + + char** inputs; + unsigned inputs_num; +}; + +extern const char* cli_info_purpose; +extern const char* cli_info_usage; +extern const char* cli_info_help[]; + +void cli_print_help(void); +void cli_print_version(void); + +int cli_parser (int argc, const char** argv, struct cli_info* args_info); +void cli_parser_init (struct cli_info* args_info); +void cli_parser_free (struct cli_info* args_info); + + +#endif /* CLI_H */ diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/common.h b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/common.h new file mode 100644 index 0000000..b2d3e4e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/common.h @@ -0,0 +1,22 @@ +#ifndef fsevent_watch_common_h +#define fsevent_watch_common_h + +#include +#ifdef __OBJC__ +#import +#endif + +#include +#include +#include "compat.h" +#include "defines.h" +#include "TSICTString.h" + +enum FSEventWatchOutputFormat { + kFSEventWatchOutputFormatClassic, + kFSEventWatchOutputFormatNIW, + kFSEventWatchOutputFormatTNetstring, + kFSEventWatchOutputFormatOTNetstring +}; + +#endif /* fsevent_watch_common_h */ diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/compat.c b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/compat.c new file mode 100644 index 0000000..5f51baf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/compat.c @@ -0,0 +1,41 @@ +#include "compat.h" + + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_6) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_6_0) +FSEventStreamCreateFlags kFSEventStreamCreateFlagIgnoreSelf = 0x00000008; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_7) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_6_0) +FSEventStreamCreateFlags kFSEventStreamCreateFlagFileEvents = 0x00000010; +FSEventStreamEventFlags kFSEventStreamEventFlagItemCreated = 0x00000100; +FSEventStreamEventFlags kFSEventStreamEventFlagItemRemoved = 0x00000200; +FSEventStreamEventFlags kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400; +FSEventStreamEventFlags kFSEventStreamEventFlagItemRenamed = 0x00000800; +FSEventStreamEventFlags kFSEventStreamEventFlagItemModified = 0x00001000; +FSEventStreamEventFlags kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000; +FSEventStreamEventFlags kFSEventStreamEventFlagItemChangeOwner = 0x00004000; +FSEventStreamEventFlags kFSEventStreamEventFlagItemXattrMod = 0x00008000; +FSEventStreamEventFlags kFSEventStreamEventFlagItemIsFile = 0x00010000; +FSEventStreamEventFlags kFSEventStreamEventFlagItemIsDir = 0x00020000; +FSEventStreamEventFlags kFSEventStreamEventFlagItemIsSymlink = 0x00040000; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_9) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0) +FSEventStreamCreateFlags kFSEventStreamCreateFlagMarkSelf = 0x00000020; +FSEventStreamEventFlags kFSEventStreamEventFlagOwnEvent = 0x00080000; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_10) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0) +FSEventStreamEventFlags kFSEventStreamEventFlagItemIsHardlink = 0x00100000; +FSEventStreamEventFlags kFSEventStreamEventFlagItemIsLastHardlink = 0x00200000; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_13) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_11_0) +FSEventStreamCreateFlags kFSEventStreamCreateFlagUseExtendedData = 0x00000040; +FSEventStreamEventFlags kFSEventStreamEventFlagItemCloned = 0x00400000; +#endif diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/compat.h b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/compat.h new file mode 100644 index 0000000..757b413 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/compat.h @@ -0,0 +1,100 @@ +/** + * @headerfile compat.h + * FSEventStream flag compatibility shim + * + * In order to compile a binary against an older SDK yet still support the + * features present in later OS releases, we need to define any missing enum + * constants not present in the older SDK. This allows us to safely defer + * feature detection to runtime (and avoid recompilation). + */ + + +#ifndef listen_fsevents_compat_h +#define listen_fsevents_compat_h + +#ifndef __CORESERVICES__ +#include +#endif // __CORESERVICES__ + +#ifndef __AVAILABILITY__ +#include +#endif // __AVAILABILITY__ + +#ifndef __MAC_10_6 +#define __MAC_10_6 1060 +#endif +#ifndef __MAC_10_7 +#define __MAC_10_7 1070 +#endif +#ifndef __MAC_10_9 +#define __MAC_10_9 1090 +#endif +#ifndef __MAC_10_10 +#define __MAC_10_10 101000 +#endif +#ifndef __MAC_10_13 +#define __MAC_10_13 101300 +#endif +#ifndef __IPHONE_6_0 +#define __IPHONE_6_0 60000 +#endif +#ifndef __IPHONE_7_0 +#define __IPHONE_7_0 70000 +#endif +#ifndef __IPHONE_9_0 +#define __IPHONE_9_0 90000 +#endif +#ifndef __IPHONE_11_0 +#define __IPHONE_11_0 110000 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_6) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_6_0) +extern FSEventStreamCreateFlags kFSEventStreamCreateFlagIgnoreSelf; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_7) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_6_0) +extern FSEventStreamCreateFlags kFSEventStreamCreateFlagFileEvents; +extern FSEventStreamEventFlags kFSEventStreamEventFlagItemCreated, + kFSEventStreamEventFlagItemRemoved, + kFSEventStreamEventFlagItemInodeMetaMod, + kFSEventStreamEventFlagItemRenamed, + kFSEventStreamEventFlagItemModified, + kFSEventStreamEventFlagItemFinderInfoMod, + kFSEventStreamEventFlagItemChangeOwner, + kFSEventStreamEventFlagItemXattrMod, + kFSEventStreamEventFlagItemIsFile, + kFSEventStreamEventFlagItemIsDir, + kFSEventStreamEventFlagItemIsSymlink; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_9) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0) +extern FSEventStreamCreateFlags kFSEventStreamCreateFlagMarkSelf; +extern FSEventStreamEventFlags kFSEventStreamEventFlagOwnEvent; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_10) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0) +extern FSEventStreamEventFlags kFSEventStreamEventFlagItemIsHardlink, + kFSEventStreamEventFlagItemIsLastHardlink; +#endif + +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_13) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_11_0) +extern FSEventStreamCreateFlags kFSEventStreamCreateFlagUseExtendedData; +extern FSEventStreamEventFlags kFSEventStreamEventFlagItemCloned; +#endif + + +#ifdef __cplusplus +} +#endif + +#endif // listen_fsevents_compat_h diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/defines.h b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/defines.h new file mode 100644 index 0000000..34879c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/defines.h @@ -0,0 +1,42 @@ +#ifndef fsevent_watch_defines_h +#define fsevent_watch_defines_h + +#define _str(s) #s +#define _xstr(s) _str(s) + +#define COMPILED_AT __DATE__ " " __TIME__ + +#if defined (__clang__) +#define COMPILER "clang " __clang_version__ +#elif defined (__GNUC__) +#define COMPILER "gcc " __VERSION__ +#else +#define COMPILER "unknown" +#endif + +#if defined(__ppc__) +#define TARGET_CPU "ppc" +#elif defined(__ppc64__) +#define TARGET_CPU "ppc64" +#elif defined(__i386__) +#define TARGET_CPU "i386" +#elif defined(__x86_64__) +#define TARGET_CPU "x86_64" +#elif defined(__arm64__) +#define TARGET_CPU "arm64" +#else +#define TARGET_CPU "unknown" +#endif + +#define FLAG_CHECK(flags, flag) ((flags) & (flag)) + +#define FPRINTF_FLAG_CHECK(flags, flag, msg, fd) \ + do { \ + if (FLAG_CHECK(flags, flag)) { \ + fprintf(fd, "%s", msg "\n"); } } \ + while (0) + +#define FLAG_CHECK_STDERR(flags, flag, msg) \ + FPRINTF_FLAG_CHECK(flags, flag, msg, stderr) + +#endif /* fsevent_watch_defines_h */ diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/main.c b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/main.c new file mode 100644 index 0000000..b18596a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/main.c @@ -0,0 +1,548 @@ +#include "common.h" +#include "signal_handlers.h" +#include "cli.h" +#include "FSEventsFix.h" + +// TODO: set on fire. cli.{h,c} handle both parsing and defaults, so there's +// no need to set those here. also, in order to scope metadata by path, +// each stream will need its own configuration... so this won't work as +// a global any more. In the end the goal is to make the output format +// able to declare not just that something happened and what flags were +// attached, but what path it was watching that caused those events (so +// that the path itself can be used for routing that information to the +// relevant callback). +// +// Structure for storing metadata parsed from the commandline +static struct { + FSEventStreamEventId sinceWhen; + CFTimeInterval latency; + FSEventStreamCreateFlags flags; + CFMutableArrayRef paths; + enum FSEventWatchOutputFormat format; +} config = { + (UInt64) kFSEventStreamEventIdSinceNow, + (double) 0.3, + (CFOptionFlags) kFSEventStreamCreateFlagNone, + NULL, + kFSEventWatchOutputFormatOTNetstring +}; + +// Prototypes +static void append_path(const char* path); +static inline void parse_cli_settings(int argc, const char* argv[]); +static void callback(FSEventStreamRef streamRef, + void* clientCallBackInfo, + size_t numEvents, + void* eventPaths, + const FSEventStreamEventFlags eventFlags[], + const FSEventStreamEventId eventIds[]); +static bool needs_fsevents_fix = false; + +// Resolve a path and append it to the CLI settings structure +// The FSEvents API will, internally, resolve paths using a similar scheme. +// Performing this ahead of time makes things less confusing, IMHO. +static void append_path(const char* path) +{ +#ifdef DEBUG + fprintf(stderr, "\n"); + fprintf(stderr, "append_path called for: %s\n", path); +#endif + +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 + +#ifdef DEBUG + fprintf(stderr, "compiled against 10.6+, using CFURLCreateFileReferenceURL\n"); +#endif + + CFURLRef url = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)path, (CFIndex)strlen(path), false); + CFURLRef placeholder = CFURLCopyAbsoluteURL(url); + CFRelease(url); + + CFMutableArrayRef imaginary = NULL; + + // if we don't have an existing url, spin until we get to a parent that + // does exist, saving any imaginary components for appending back later + while(!CFURLResourceIsReachable(placeholder, NULL)) { +#ifdef DEBUG + fprintf(stderr, "path does not exist\n"); +#endif + + CFStringRef child; + + if (imaginary == NULL) { + imaginary = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + } + + child = CFURLCopyLastPathComponent(placeholder); + CFArrayInsertValueAtIndex(imaginary, 0, child); + CFRelease(child); + + url = CFURLCreateCopyDeletingLastPathComponent(NULL, placeholder); + CFRelease(placeholder); + placeholder = url; + +#ifdef DEBUG + fprintf(stderr, "parent: "); + CFShow(placeholder); +#endif + } + +#ifdef DEBUG + fprintf(stderr, "path exists\n"); +#endif + + // realpath() doesn't always return the correct case for a path, so this + // is a funky workaround that converts a path into a (volId/inodeId) pair + // and asks what the path should be for that. since it looks at the actual + // inode instead of returning the same case passed in like realpath() + // appears to do for HFS+, it should always be correct. + url = CFURLCreateFileReferenceURL(NULL, placeholder, NULL); + CFRelease(placeholder); + placeholder = CFURLCreateFilePathURL(NULL, url, NULL); + CFRelease(url); + +#ifdef DEBUG + fprintf(stderr, "path resolved to: "); + CFShow(placeholder); +#endif + + // if we stripped off any imaginary path components, append them back on + if (imaginary != NULL) { + CFIndex count = CFArrayGetCount(imaginary); + for (CFIndex i = 0; i= 6)) { + config.flags |= kFSEventStreamCreateFlagIgnoreSelf; + } else { + fprintf(stderr, "MacOSX 10.6 or later is required for --ignore-self\n"); + exit(EXIT_FAILURE); + } + } + + if (args_info.file_events_flag) { + if ((osMajorVersion == 10) & (osMinorVersion >= 7)) { + config.flags |= kFSEventStreamCreateFlagFileEvents; + } else { + fprintf(stderr, "MacOSX 10.7 or later required for --file-events\n"); + exit(EXIT_FAILURE); + } + } + + if (args_info.mark_self_flag) { + if ((osMajorVersion == 10) & (osMinorVersion >= 9)) { + config.flags |= kFSEventStreamCreateFlagMarkSelf; + } else { + fprintf(stderr, "MacOSX 10.9 or later required for --mark-self\n"); + exit(EXIT_FAILURE); + } + } + + if (args_info.inputs_num == 0) { + append_path("."); + } else { + for (unsigned int i=0; i < args_info.inputs_num; ++i) { + append_path(args_info.inputs[i]); + } + } + + cli_parser_free(&args_info); + +#ifdef DEBUG + fprintf(stderr, "config.sinceWhen %llu\n", config.sinceWhen); + fprintf(stderr, "config.latency %f\n", config.latency); + +// STFU clang +#if defined(__LP64__) + fprintf(stderr, "config.flags %#.8x\n", config.flags); +#else + fprintf(stderr, "config.flags %#.8lx\n", config.flags); +#endif + + FLAG_CHECK_STDERR(config.flags, kFSEventStreamCreateFlagUseCFTypes, + " Using CF instead of C types"); + FLAG_CHECK_STDERR(config.flags, kFSEventStreamCreateFlagNoDefer, + " NoDefer latency modifier enabled"); + FLAG_CHECK_STDERR(config.flags, kFSEventStreamCreateFlagWatchRoot, + " WatchRoot notifications enabled"); + FLAG_CHECK_STDERR(config.flags, kFSEventStreamCreateFlagIgnoreSelf, + " IgnoreSelf enabled"); + FLAG_CHECK_STDERR(config.flags, kFSEventStreamCreateFlagFileEvents, + " FileEvents enabled"); + + fprintf(stderr, "config.paths\n"); + + long numpaths = CFArrayGetCount(config.paths); + + for (long i = 0; i < numpaths; i++) { + char path[PATH_MAX]; + CFStringGetCString(CFArrayGetValueAtIndex(config.paths, i), + path, + PATH_MAX, + kCFStringEncodingUTF8); + fprintf(stderr, " %s\n", path); + } + + fprintf(stderr, "\n"); +#endif +} + +// original output format for rb-fsevent +static void classic_output_format(size_t numEvents, + char** paths) +{ + for (size_t i = 0; i < numEvents; i++) { + fprintf(stdout, "%s:", paths[i]); + } + fprintf(stdout, "\n"); +} + +// output format used in the Yoshimasa Niwa branch of rb-fsevent +static void niw_output_format(size_t numEvents, + char** paths, + const FSEventStreamEventFlags eventFlags[], + const FSEventStreamEventId eventIds[]) +{ + for (size_t i = 0; i < numEvents; i++) { + fprintf(stdout, "%lu:%llu:%s\n", + (unsigned long)eventFlags[i], + (unsigned long long)eventIds[i], + paths[i]); + } + fprintf(stdout, "\n"); +} + +static void tstring_output_format(size_t numEvents, + char** paths, + const FSEventStreamEventFlags eventFlags[], + const FSEventStreamEventId eventIds[], + TSITStringFormat format) +{ + CFMutableArrayRef events = CFArrayCreateMutable(kCFAllocatorDefault, + 0, &kCFTypeArrayCallBacks); + + for (size_t i = 0; i < numEvents; i++) { + CFMutableDictionaryRef event = CFDictionaryCreateMutable(kCFAllocatorDefault, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + CFStringRef path = CFStringCreateWithBytes(kCFAllocatorDefault, + (const UInt8*)paths[i], + (CFIndex)strlen(paths[i]), + kCFStringEncodingUTF8, + false); + CFDictionarySetValue(event, CFSTR("path"), path); + + CFNumberRef ident = CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &eventIds[i]); + CFDictionarySetValue(event, CFSTR("id"), ident); + + CFNumberRef cflags = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &eventFlags[i]); + CFDictionarySetValue(event, CFSTR("cflags"), cflags); + + CFMutableArrayRef flags = CFArrayCreateMutable(kCFAllocatorDefault, + 0, &kCFTypeArrayCallBacks); + +#define FLAG_ADD_NAME(flagsnum, flagnum, flagname, flagarray) \ + do { \ + if (FLAG_CHECK(flagsnum, flagnum)) { \ + CFArrayAppendValue(flagarray, CFSTR(flagname)); } } \ + while(0) + + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagMustScanSubDirs, "MustScanSubDirs", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagUserDropped, "UserDropped", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagKernelDropped, "KernelDropped", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagEventIdsWrapped, "EventIdsWrapped", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagHistoryDone, "HistoryDone", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagRootChanged, "RootChanged", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagMount, "Mount", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagUnmount, "Unmount", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemCreated, "ItemCreated", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemRemoved, "ItemRemoved", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemInodeMetaMod, "ItemInodeMetaMod", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemRenamed, "ItemRenamed", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemModified, "ItemModified", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemFinderInfoMod, "ItemFinderInfoMod", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemChangeOwner, "ItemChangeOwner", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemXattrMod, "ItemXattrMod", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemIsFile, "ItemIsFile", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemIsDir, "ItemIsDir", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemIsSymlink, "ItemIsSymlink", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagOwnEvent, "OwnEvent", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemIsHardlink, "ItemIsHardLink", flags); + FLAG_ADD_NAME(eventFlags[i], kFSEventStreamEventFlagItemIsLastHardlink, "ItemIsLastHardLink", flags); + + CFDictionarySetValue(event, CFSTR("flags"), flags); + + + CFArrayAppendValue(events, event); + + CFRelease(event); + CFRelease(path); + CFRelease(ident); + CFRelease(cflags); + CFRelease(flags); + } + + CFMutableDictionaryRef meta = CFDictionaryCreateMutable(kCFAllocatorDefault, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + CFDictionarySetValue(meta, CFSTR("events"), events); + + CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &numEvents); + CFDictionarySetValue(meta, CFSTR("numEvents"), num); + + CFDataRef data = TSICTStringCreateRenderedDataFromObjectWithFormat(meta, format); + fprintf(stdout, "%s", CFDataGetBytePtr(data)); + + CFRelease(events); + CFRelease(num); + CFRelease(meta); + CFRelease(data); +} + +static void callback(__attribute__((unused)) FSEventStreamRef streamRef, + __attribute__((unused)) void* clientCallBackInfo, + size_t numEvents, + void* eventPaths, + const FSEventStreamEventFlags eventFlags[], + const FSEventStreamEventId eventIds[]) +{ + char** paths = eventPaths; + + +#ifdef DEBUG + fprintf(stderr, "\n"); + fprintf(stderr, "FSEventStreamCallback fired!\n"); + fprintf(stderr, " numEvents: %lu\n", numEvents); + + for (size_t i = 0; i < numEvents; i++) { + fprintf(stderr, "\n"); + fprintf(stderr, " event ID: %llu\n", eventIds[i]); + +// STFU clang +#if defined(__LP64__) + fprintf(stderr, " event flags: %#.8x\n", eventFlags[i]); +#else + fprintf(stderr, " event flags: %#.8lx\n", eventFlags[i]); +#endif + + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagMustScanSubDirs, + " Recursive scanning of directory required"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagUserDropped, + " Buffering problem: events dropped user-side"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagKernelDropped, + " Buffering problem: events dropped kernel-side"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagEventIdsWrapped, + " Event IDs have wrapped"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagHistoryDone, + " All historical events have been processed"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagRootChanged, + " Root path has changed"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagMount, + " A new volume was mounted at this path"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagUnmount, + " A volume was unmounted from this path"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemCreated, + " Item created"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemRemoved, + " Item removed"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemInodeMetaMod, + " Item metadata modified"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemRenamed, + " Item renamed"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemModified, + " Item modified"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemFinderInfoMod, + " Item Finder Info modified"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemChangeOwner, + " Item changed ownership"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemXattrMod, + " Item extended attributes modified"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemIsFile, + " Item is a file"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemIsDir, + " Item is a directory"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemIsSymlink, + " Item is a symbolic link"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemIsHardlink, + " Item is a hard link"); + FLAG_CHECK_STDERR(eventFlags[i], kFSEventStreamEventFlagItemIsLastHardlink, + " Item is the last hard link"); + fprintf(stderr, " event path: %s\n", paths[i]); + fprintf(stderr, "\n"); + } + + fprintf(stderr, "\n"); +#endif + + if (config.format == kFSEventWatchOutputFormatClassic) { + classic_output_format(numEvents, paths); + } else if (config.format == kFSEventWatchOutputFormatNIW) { + niw_output_format(numEvents, paths, eventFlags, eventIds); + } else if (config.format == kFSEventWatchOutputFormatTNetstring) { + tstring_output_format(numEvents, paths, eventFlags, eventIds, + kTSITStringFormatTNetstring); + } else if (config.format == kFSEventWatchOutputFormatOTNetstring) { + tstring_output_format(numEvents, paths, eventFlags, eventIds, + kTSITStringFormatOTNetstring); + } + + fflush(stdout); +} + +int main(int argc, const char* argv[]) +{ + install_signal_handlers(); + parse_cli_settings(argc, argv); + + if (needs_fsevents_fix) { + FSEventsFixEnable(); + } + + FSEventStreamContext context = {0, NULL, NULL, NULL, NULL}; + FSEventStreamRef stream; + stream = FSEventStreamCreate(kCFAllocatorDefault, + (FSEventStreamCallback)&callback, + &context, + config.paths, + config.sinceWhen, + config.latency, + config.flags); + +#ifdef DEBUG + FSEventStreamShow(stream); + fprintf(stderr, "\n"); +#endif + + if (needs_fsevents_fix) { + FSEventsFixDisable(); + } + + FSEventStreamScheduleWithRunLoop(stream, + CFRunLoopGetCurrent(), + kCFRunLoopDefaultMode); + FSEventStreamStart(stream); + CFRunLoopRun(); + FSEventStreamFlushSync(stream); + FSEventStreamStop(stream); + + return 0; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/signal_handlers.c b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/signal_handlers.c new file mode 100644 index 0000000..b20da3f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/signal_handlers.c @@ -0,0 +1,66 @@ +#include "signal_handlers.h" +#include +#include +#include +#include +#include +#include + + +#define PPID_ALARM_INTERVAL 2 // send SIGALRM every this seconds + + +static pid_t orig_ppid; + + +static void signal_handler(int _) { + exit(EXIT_FAILURE); +} + +static void check_ppid(void) { + if (getppid() != orig_ppid) { + exit(EXIT_FAILURE); + } +} + +static void check_stdout_open(void) { + if (fcntl(STDOUT_FILENO, F_GETFD) < 0) { + exit(EXIT_FAILURE); + } +} + +static void alarm_handler(int _) { + check_ppid(); + check_stdout_open(); + alarm(PPID_ALARM_INTERVAL); + signal(SIGALRM, alarm_handler); +} + +static void die(const char *msg) { + fprintf(stderr, "\nFATAL: %s\n", msg); + abort(); +} + +static void install_signal_handler(int sig, void (*handler)(int)) { + if (signal(sig, handler) == SIG_ERR) { + die("Could not install signal handler"); + } +} + +void install_signal_handlers(void) { + // check pipe is still connected + check_stdout_open(); + + // watch getppid() every PPID_ALARM_INTERVAL seconds + orig_ppid = getppid(); + if (orig_ppid <= 1) { + die("prematurely zombied"); + } + install_signal_handler(SIGALRM, alarm_handler); + alarm(PPID_ALARM_INTERVAL); + + // be sure to exit on SIGHUP, SIGPIPE + install_signal_handler(SIGHUP, signal_handler); + install_signal_handler(SIGPIPE, signal_handler); +} + diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/signal_handlers.h b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/signal_handlers.h new file mode 100644 index 0000000..c31685d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/fsevent_watch/signal_handlers.h @@ -0,0 +1,16 @@ +/** + * @headerfile signal_handlers.h + * Signal handlers to stop the zombie hordes + * + * Catch and handle signals better so that we die faster like a good meat puppet. + */ + + +#ifndef fsevent_watch_signal_handlers_h +#define fsevent_watch_signal_handlers_h + + +void install_signal_handlers(void); + + +#endif // fsevent_watch_signal_handlers_h diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/rakefile.rb b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/rakefile.rb new file mode 100644 index 0000000..e50e888 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/ext/rakefile.rb @@ -0,0 +1,231 @@ +# -*- encoding: utf-8 -*- +require 'rubygems' unless defined?(Gem) +require 'pathname' +require 'date' +require 'time' +require 'rake/clean' + +raise "unable to find xcodebuild" unless system('which', 'xcodebuild') + + +FSEVENT_WATCH_EXE_VERSION = '0.1.5' + +$this_dir = Pathname.new(__FILE__).dirname.expand_path +$final_exe = $this_dir.parent.join('bin/fsevent_watch') + +$src_dir = $this_dir.join('fsevent_watch') +$obj_dir = $this_dir.join('build') + +SRC = Pathname.glob("#{$src_dir}/*.c") +OBJ = SRC.map {|s| $obj_dir.join("#{s.basename('.c')}.o")} + +$now = DateTime.now.xmlschema rescue Time.now.xmlschema + +$CC = ENV['CC'] || `which clang || which gcc`.strip +$CFLAGS = ENV['CFLAGS'] || '-fconstant-cfstrings -fasm-blocks -fstrict-aliasing -Wall' +$ARCHFLAGS = ENV['ARCHFLAGS'] || '-arch x86_64' +$DEFINES = "-DNS_BUILD_32_LIKE_64 -DNS_BLOCK_ASSERTIONS -DPROJECT_VERSION=#{FSEVENT_WATCH_EXE_VERSION}" + +$GCC_C_LANGUAGE_STANDARD = ENV['GCC_C_LANGUAGE_STANDARD'] || 'gnu11' + +# generic developer id name so it'll match correctly for anyone who has only +# one developer id in their keychain (not that I expect anyone else to bother) +$CODE_SIGN_IDENTITY = 'Developer ID Application' + +$arch = `uname -m`.strip +$os_release = `uname -r`.strip +$BUILD_TRIPLE = "#{$arch}-apple-darwin#{$os_release}" + +$CCVersion = `#{$CC} --version | head -n 1`.strip + + +CLEAN.include OBJ.map(&:to_s) +CLEAN.include $obj_dir.join('Info.plist').to_s +CLEAN.include $obj_dir.join('fsevent_watch').to_s +CLOBBER.include $final_exe.to_s + + +task :sw_vers do + $mac_product_version = `sw_vers -productVersion`.strip + $mac_build_version = `sw_vers -buildVersion`.strip + $MACOSX_DEPLOYMENT_TARGET = ENV['MACOSX_DEPLOYMENT_TARGET'] || $mac_product_version.sub(/\.\d*$/, '') + $CFLAGS = "#{$CFLAGS} -mmacosx-version-min=#{$MACOSX_DEPLOYMENT_TARGET}" +end + +task :get_sdk_info => :sw_vers do + $SDK_INFO = {} + version_info = `xcodebuild -version -sdk macosx#{$MACOSX_DEPLOYMENT_TARGET}` + raise "invalid SDK" unless !!$?.exitstatus + version_info.strip.each_line do |line| + next if line.strip.empty? + next unless line.include?(':') + match = line.match(/([^:]*): (.*)/) + next unless match + $SDK_INFO[match[1]] = match[2] + end +end + +task :debug => :sw_vers do + $DEFINES = "-DDEBUG #{$DEFINES}" + $CFLAGS = "#{$CFLAGS} -O0 -fno-omit-frame-pointer -g" +end + +task :release => :sw_vers do + $DEFINES = "-DNDEBUG #{$DEFINES}" + $CFLAGS = "#{$CFLAGS} -Ofast" +end + +desc 'configure build type depending on whether ENV var FWDEBUG is set' +task :set_build_type => :sw_vers do + if ENV['FWDEBUG'] + Rake::Task[:debug].invoke + else + Rake::Task[:release].invoke + end +end + +desc 'set build arch to ppc' +task :ppc do + $ARCHFLAGS = '-arch ppc' +end + +desc 'set build arch to x86_64' +task :x86_64 do + $ARCHFLAGS = '-arch x86_64' +end + +desc 'set build arch to i386' +task :x86 do + $ARCHFLAGS = '-arch i386' +end + +desc 'set build arch to arm64' +task :arm64 do + $ARCHFLAGS = '-arch arm64' +end + +task :setup_env => [:set_build_type, :sw_vers, :get_sdk_info] + +directory $obj_dir.to_s +file $obj_dir.to_s => :setup_env + +SRC.zip(OBJ).each do |source, object| + file object.to_s => [source.to_s, $obj_dir.to_s] do + cmd = [ + $CC, + $ARCHFLAGS, + "-std=#{$GCC_C_LANGUAGE_STANDARD}", + $CFLAGS, + $DEFINES, + "-I#{$src_dir}", + '-isysroot', + $SDK_INFO['Path'], + '-c', source, + '-o', object + ] + sh(cmd.map {|s| s.to_s}.join(' ')) + end +end + +file $obj_dir.join('Info.plist').to_s => [$obj_dir.to_s, :setup_env] do + File.open($obj_dir.join('Info.plist').to_s, 'w+') do |file| + indentation = '' + indent = lambda {|num| indentation = ' ' * num } + add = lambda {|str| file << "#{indentation}#{str}\n" } + key = lambda {|str| add["#{str}"] } + string = lambda {|str| add["#{str}"] } + + + add[''] + add[''] + add[''] + + indent[2] + add[''] + indent[4] + + key['CFBundleExecutable'] + string['fsevent_watch'] + key['CFBundleIdentifier'] + string['com.teaspoonofinsanity.fsevent_watch'] + key['CFBundleName'] + string['fsevent_watch'] + key['CFBundleDisplayName'] + string['FSEvent Watch CLI'] + key['NSHumanReadableCopyright'] + string['Copyright (C) 2011-2017 Travis Tilley'] + + key['CFBundleVersion'] + string["#{FSEVENT_WATCH_EXE_VERSION}"] + key['LSMinimumSystemVersion'] + string["#{$MACOSX_DEPLOYMENT_TARGET}"] + key['DTSDKBuild'] + string["#{$SDK_INFO['ProductBuildVersion']}"] + key['DTSDKName'] + string["macosx#{$SDK_INFO['SDKVersion']}"] + key['DTSDKPath'] + string["#{$SDK_INFO['Path']}"] + key['BuildMachineOSBuild'] + string["#{$mac_build_version}"] + key['BuildMachineOSVersion'] + string["#{$mac_product_version}"] + key['FSEWCompiledAt'] + string["#{$now}"] + key['FSEWVersionInfoBuilder'] + string["#{`whoami`.strip}"] + key['FSEWBuildTriple'] + string["#{$BUILD_TRIPLE}"] + key['FSEWCC'] + string["#{$CC}"] + key['FSEWCCVersion'] + string["#{$CCVersion}"] + key['FSEWCFLAGS'] + string["#{$CFLAGS}"] + + indent[2] + add[''] + indent[0] + + add[''] + end +end + +desc 'generate an Info.plist used for code signing as well as embedding build settings into the resulting binary' +task :plist => $obj_dir.join('Info.plist').to_s + + +file $obj_dir.join('fsevent_watch').to_s => [$obj_dir.to_s, $obj_dir.join('Info.plist').to_s] + OBJ.map(&:to_s) do + cmd = [ + $CC, + $ARCHFLAGS, + "-std=#{$GCC_C_LANGUAGE_STANDARD}", + $CFLAGS, + $DEFINES, + "-I#{$src_dir}", + '-isysroot', + $SDK_INFO['Path'], + '-framework CoreFoundation -framework CoreServices', + '-sectcreate __TEXT __info_plist', + $obj_dir.join('Info.plist') + ] + OBJ + [ + '-o', $obj_dir.join('fsevent_watch') + ] + sh(cmd.map {|s| s.to_s}.join(' ')) +end + +desc 'compile and link build/fsevent_watch' +task :build => $obj_dir.join('fsevent_watch').to_s + +desc 'codesign build/fsevent_watch binary' +task :codesign => :build do + sh "codesign -s '#{$CODE_SIGN_IDENTITY}' #{$obj_dir.join('fsevent_watch')}" +end + +directory $this_dir.parent.join('bin') + +desc 'replace bundled fsevent_watch binary with build/fsevent_watch' +task :replace_exe => [$this_dir.parent.join('bin'), :build] do + sh "mv #{$obj_dir.join('fsevent_watch')} #{$final_exe}" +end + +task :default => [:replace_exe, :clean] diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/otnetstring.rb b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/otnetstring.rb new file mode 100644 index 0000000..7623d67 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/otnetstring.rb @@ -0,0 +1,85 @@ +# Copyright (c) 2011 Konstantin Haase +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + + +require 'stringio' + +module OTNetstring + class Error < StandardError; end + + class << self + def parse(io, encoding = 'internal', fallback_encoding = nil) + fallback_encoding = io.encoding if io.respond_to? :encoding + io = StringIO.new(io) if io.respond_to? :to_str + length, byte = String.new, nil + + while byte.nil? || byte =~ /\d/ + length << byte if byte + byte = io.read(1) + end + + if length.size > 9 + raise Error, "#{length} is longer than 9 digits" + elsif length !~ /\d+/ + raise Error, "Expected '#{byte}' to be a digit" + end + length = Integer(length) + + case byte + when '#' then Integer io.read(length) + when ',' then with_encoding io.read(length), encoding, fallback_encoding + when '~' then + raise Error, "nil has length of 0, #{length} given" unless length == 0 + when '!' then io.read(length) == 'true' + when '[', '{' + array = [] + start = io.pos + array << parse(io, encoding, fallback_encoding) while io.pos - start < length + raise Error, 'Nested element longer than container' if io.pos - start != length + byte == "{" ? Hash[*array] : array + else + raise Error, "Unknown type '#{byte}'" + end + end + + def encode(obj, string_sep = ',') + case obj + when String then with_encoding "#{obj.bytesize}#{string_sep}#{obj}", "binary" + when Integer then encode(obj.inspect, '#') + when NilClass then "0~" + when Array then encode(obj.map { |e| encode(e) }.join, '[') + when Hash then encode(obj.map { |a,b| encode(a)+encode(b) }.join, '{') + when FalseClass, TrueClass then encode(obj.inspect, '!') + else raise Error, 'cannot encode %p' % obj + end + end + + private + + def with_encoding(str, encoding, fallback = nil) + return str unless str.respond_to? :encode + encoding = Encoding.find encoding if encoding.respond_to? :to_str + encoding ||= fallback + encoding ? str.encode(encoding) : str + rescue EncodingError + str.force_encoding(encoding) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent.rb b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent.rb new file mode 100644 index 0000000..1ff68a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent.rb @@ -0,0 +1,3 @@ +# -*- encoding: utf-8 -*- +require 'rb-fsevent/fsevent' +require 'rb-fsevent/version' diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent/fsevent.rb b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent/fsevent.rb new file mode 100644 index 0000000..fac2364 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent/fsevent.rb @@ -0,0 +1,157 @@ +# -*- encoding: utf-8 -*- + +require 'otnetstring' + +class FSEvent + class << self + class_eval <<-END + def root_path + "#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))}" + end + END + class_eval <<-END + def watcher_path + "#{File.join(FSEvent.root_path, 'bin', 'fsevent_watch')}" + end + END + end + + attr_reader :paths, :callback + + def initialize args = nil, &block + watch(args, &block) unless args.nil? + end + + def watch(watch_paths, options=nil, &block) + @paths = watch_paths.kind_of?(Array) ? watch_paths : [watch_paths] + @callback = block + + if options.kind_of?(Hash) + @options = parse_options(options) + elsif options.kind_of?(Array) + @options = options + else + @options = [] + end + end + + def run + @pipe = open_pipe + @running = true + + # please note the use of IO::select() here, as it is used specifically to + # preserve correct signal handling behavior in ruby 1.8. + while @running && IO::select([@pipe], nil, nil, nil) + # managing the IO ourselves allows us to be careful and never pass an + # incomplete message to OTNetstring.parse() + message = String.new + length = String.new + byte = nil + + reading_length = true + found_length = false + + while reading_length + byte = @pipe.read_nonblock(1) + if "#{byte}" =~ /\d/ + length << byte + found_length = true + elsif found_length == false + next + else + reading_length = false + end + end + length = Integer(length, 10) + type = byte + + message << "#{length}#{type}" + message << @pipe.read(length) + + decoded = OTNetstring.parse(message) + modified_paths = decoded["events"].map {|event| event["path"]} + # passing the full info as a second block param feels icky, but such is + # the trap of backward compatibility. + case callback.arity + when 1 + callback.call(modified_paths) + when 2 + callback.call(modified_paths, decoded) + end + end + rescue Interrupt, IOError, Errno::EBADF + ensure + stop + end + + def stop + unless @pipe.nil? + Process.kill('KILL', @pipe.pid) if process_running?(@pipe.pid) + @pipe.close + end + rescue IOError, Errno::EBADF + ensure + @running = false + end + + def process_running?(pid) + begin + Process.kill(0, pid) + true + rescue Errno::ESRCH + false + end + end + + if RUBY_VERSION < '1.9' + def open_pipe + IO.popen("'#{self.class.watcher_path}' #{options_string} #{shellescaped_paths}") + end + + private + + def options_string + @options.join(' ') + end + + def shellescaped_paths + @paths.map {|path| shellescape(path)}.join(' ') + end + + # for Ruby 1.8.6 support + def shellescape(str) + # An empty argument will be skipped, so return empty quotes. + return "''" if str.empty? + + str = str.dup + + # Process as a single byte sequence because not all shell + # implementations are multibyte aware. + str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1") + + # A LF cannot be escaped with a backslash because a backslash + LF + # combo is regarded as line continuation and simply ignored. + str.gsub!(/\n/, "'\n'") + + return str + end + else + def open_pipe + IO.popen([self.class.watcher_path] + @options + @paths) + end + end + + private + + def parse_options(options={}) + opts = ['--format=otnetstring'] + opts.concat(['--since-when', options[:since_when]]) if options[:since_when] + opts.concat(['--latency', options[:latency]]) if options[:latency] + opts.push('--no-defer') if options[:no_defer] + opts.push('--watch-root') if options[:watch_root] + opts.push('--file-events') if options[:file_events] + # ruby 1.9's IO.popen(array-of-stuff) syntax requires all items to be strings + opts.map {|opt| "#{opt}"} + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent/version.rb b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent/version.rb new file mode 100644 index 0000000..332be3b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/lib/rb-fsevent/version.rb @@ -0,0 +1,5 @@ +# -*- encoding: utf-8 -*- + +class FSEvent + VERSION = '0.11.2' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/rb-fsevent.gemspec b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/rb-fsevent.gemspec new file mode 100644 index 0000000..8f1e5aa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-fsevent-0.11.2/rb-fsevent.gemspec @@ -0,0 +1,26 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'rb-fsevent/version' + +Gem::Specification.new do |s| + s.name = 'rb-fsevent' + s.version = FSEvent::VERSION + s.authors = ['Thibaud Guillaume-Gentil', 'Travis Tilley'] + s.email = ['thibaud@thibaud.gg', 'ttilley@gmail.com'] + s.homepage = 'http://rubygems.org/gems/rb-fsevent' + s.summary = 'Very simple & usable FSEvents API' + s.description = 'FSEvents API with Signals catching (without RubyCocoa)' + s.license = 'MIT' + + s.metadata = { + 'source_code_uri' => 'https://github.com/thibaudgg/rb-fsevent' + } + + s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) } + s.require_path = 'lib' + + s.add_development_dependency 'rspec', '~> 3.6' + s.add_development_dependency 'guard-rspec', '~> 4.2' + s.add_development_dependency 'rake', '~> 12.0' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.github/workflows/test.yaml b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.github/workflows/test.yaml new file mode 100644 index 0000000..4b9d68b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.github/workflows/test.yaml @@ -0,0 +1,53 @@ +name: Test + +on: [push, pull_request] + +permissions: + contents: read + +env: + CONSOLE_OUTPUT: XTerm + +jobs: + test: + name: ${{matrix.ruby}} on ${{matrix.os}} + runs-on: ${{matrix.os}}-latest + continue-on-error: ${{matrix.experimental}} + + strategy: + matrix: + os: + - ubuntu + + ruby: + - "2.5" + - "2.6" + - "2.7" + - "3.0" + - "3.1" + - "3.2" + - "3.3" + + experimental: [false] + + include: + - os: ubuntu + ruby: truffleruby + experimental: true + - os: ubuntu + ruby: jruby + experimental: true + - os: ubuntu + ruby: head + experimental: true + + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{matrix.ruby}} + bundler-cache: true + + - name: Run tests + timeout-minutes: 10 + run: bundle exec rspec diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.gitignore b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.gitignore new file mode 100644 index 0000000..79dfcae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.gitignore @@ -0,0 +1,21 @@ +*.gem +*.rbc +.bundle +.config +.yardoc +Gemfile.lock +InstalledFiles +_yardoc +coverage +doc/ +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp +tmp +.tags* +.rspec_status +/guard/ +/listen/ diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.yardopts b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.yardopts new file mode 100644 index 0000000..cd347c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/.yardopts @@ -0,0 +1,4 @@ +--readme README.md +--markup markdown +--markup-provider maruku +--no-private diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/Gemfile b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/Gemfile new file mode 100644 index 0000000..f0544e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/Gemfile @@ -0,0 +1,20 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in utopia.gemspec +gemspec + +group :maintenance, optional: true do + gem "bake-gem" + gem "bake-modernize" +end + +group :test do + gem "rspec", "~> 3.6" + + gem 'simplecov' + gem 'coveralls', require: false + + gem "bundler" + gem "rake" + gem "concurrent-ruby" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/LICENSE.md b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/LICENSE.md new file mode 100644 index 0000000..bba4996 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/LICENSE.md @@ -0,0 +1,10 @@ +# The MIT License + +Copyright, 2009, by [Natalie Weizenbaum](https://github.com/nex3). +Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com). + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/README.md b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/README.md new file mode 100644 index 0000000..4cc0345 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/README.md @@ -0,0 +1,111 @@ +# rb-inotify + +This is a simple wrapper over the [inotify](http://en.wikipedia.org/wiki/Inotify) Linux kernel subsystem +for monitoring changes to files and directories. +It uses the [FFI](http://wiki.github.com/ffi/ffi) gem to avoid having to compile a C extension. + +[API documentation is available on rdoc.info](http://rdoc.info/projects/nex3/rb-inotify). + +[![Development Status](https://github.com/guard/rb-inotify/workflows/Test/badge.svg)](https://github.com/guard/rb-inotify/actions?workflow=Test) + +## Usage + +The API is similar to the inotify C API, but with a more Rubyish feel. +First, create a notifier: + + notifier = INotify::Notifier.new + +Then, tell it to watch the paths you're interested in +for the events you care about: + + notifier.watch("path/to/foo.txt", :modify) {puts "foo.txt was modified!"} + notifier.watch("path/to/bar", :moved_to, :create) do |event| + puts "#{event.name} is now in path/to/bar!" + end + +Inotify can watch directories or individual files. +It can pay attention to all sorts of events; +for a full list, see [the inotify man page](http://www.tin.org/bin/man.cgi?section=7&topic=inotify). + +Finally, you get at the events themselves: + + notifier.run + +This will loop infinitely, calling the appropriate callbacks when the files are changed. +If you don't want infinite looping, +you can also block until there are available events, +process them all at once, +and then continue on your merry way: + + notifier.process + +## Advanced Usage + +Sometimes it's necessary to have finer control over the underlying IO operations +than is provided by the simple callback API. +The trick to this is that the \{INotify::Notifier#to_io Notifier#to_io} method +returns a fully-functional IO object, +with a file descriptor and everything. +This means, for example, that it can be passed to `IO#select`: + + # Wait 10 seconds for an event then give up + if IO.select([notifier.to_io], [], [], 10) + notifier.process + end + +It can even be used with EventMachine: + + require 'eventmachine' + + EM.run do + EM.watch notifier.to_io do + notifier.process + end + end + +Unfortunately, this currently doesn't work under JRuby. +JRuby currently doesn't use native file descriptors for the IO object, +so we can't use the notifier's file descriptor as a stand-in. + +### Resource Limits + +If you get an error like `inotify event queue has overflowed` you might be running into system limits. You can add the following to your `/etc/sysctl.conf` to increase the number of files that can be monitored: + +``` +fs.inotify.max_user_watches = 100000 +fs.inotify.max_queued_events = 100000 +fs.inotify.max_user_instances = 100000 +``` + +## Contributing + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request + +## License + +Released under the MIT license. + +Copyright, 2009, by [Natalie Weizenbaum](https://github.com/nex3). +Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify.rb new file mode 100644 index 0000000..8897aef --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify.rb @@ -0,0 +1,15 @@ +require 'rb-inotify/version' +require 'rb-inotify/native' +require 'rb-inotify/native/flags' +require 'rb-inotify/notifier' +require 'rb-inotify/watcher' +require 'rb-inotify/event' +require 'rb-inotify/errors' + +# The root module of the library, which is laid out as so: +# +# * {Notifier} -- The main class, where the notifications are set up +# * {Watcher} -- A watcher for a single file or directory +# * {Event} -- An filesystem event notification +module INotify +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/errors.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/errors.rb new file mode 100644 index 0000000..afee709 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/errors.rb @@ -0,0 +1,3 @@ +module INotify + class QueueOverflowError < RuntimeError; end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/event.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/event.rb new file mode 100644 index 0000000..11701ac --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/event.rb @@ -0,0 +1,146 @@ +module INotify + # An event caused by a change on the filesystem. + # Each {Watcher} can fire many events, + # which are passed to that watcher's callback. + class Event + # A list of other events that are related to this one. + # Currently, this is only used for files that are moved within the same directory: + # the `:moved_from` and the `:moved_to` events will be related. + # + # @return [Array] + attr_reader :related + + # The name of the file that the event occurred on. + # This is only set for events that occur on files in directories; + # otherwise, it's `""`. + # Similarly, if the event is being fired for the directory itself + # the name will be `""` + # + # This pathname is relative to the enclosing directory. + # For the absolute pathname, use \{#absolute\_name}. + # Note that when the `:recursive` flag is passed to {Notifier#watch}, + # events in nested subdirectories will still have a `#name` field + # relative to their immediately enclosing directory. + # For example, an event on the file `"foo/bar/baz"` + # will have name `"baz"`. + # + # @return [String] + attr_reader :name + + # The {Notifier} that fired this event. + # + # @return [Notifier] + attr_reader :notifier + + # An integer specifying that this event is related to some other event, + # which will have the same cookie. + # + # Currently, this is only used for files that are moved within the same directory. + # Both the `:moved_from` and the `:moved_to` events will have the same cookie. + # + # @private + # @return [Fixnum] + attr_reader :cookie + + # The {Watcher#id id} of the {Watcher} that fired this event. + # + # @private + # @return [Fixnum] + attr_reader :watcher_id + + # Returns the {Watcher} that fired this event. + # + # @return [Watcher] + def watcher + @watcher ||= @notifier.watchers[@watcher_id] + end + + # The absolute path of the file that the event occurred on. + # + # This is actually only as absolute as the path passed to the {Watcher} + # that created this event. + # However, it is relative to the working directory, + # assuming that hasn't changed since the watcher started. + # + # @return [String] + def absolute_name + return watcher.path if name.empty? + return File.join(watcher.path, name) + end + + # Returns the flags that describe this event. + # This is generally similar to the input to {Notifier#watch}, + # except that it won't contain options flags nor `:all_events`, + # and it may contain one or more of the following flags: + # + # `:unmount` + # : The filesystem containing the watched file or directory was unmounted. + # + # `:ignored` + # : The \{#watcher watcher} was closed, or the watched file or directory was deleted. + # + # `:isdir` + # : The subject of this event is a directory. + # + # @return [Array] + def flags + @flags ||= Native::Flags.from_mask(@native[:mask]) + end + + # Constructs an {Event} object from a string of binary data, + # and destructively modifies the string to get rid of the initial segment + # used to construct the Event. + # + # @private + # @param data [String] The string to be modified + # @param notifier [Notifier] The {Notifier} that fired the event + # @return [Event, nil] The event, or `nil` if the string is empty + def self.consume(data, notifier) + return nil if data.empty? + ev = new(data, notifier) + data.replace data[ev.size..-1] + ev + end + + # Creates an event from a string of binary data. + # Differs from {Event.consume} in that it doesn't modify the string. + # + # @private + # @param data [String] The data string + # @param notifier [Notifier] The {Notifier} that fired the event + def initialize(data, notifier) + ptr = FFI::MemoryPointer.from_string(data) + @native = Native::Event.new(ptr) + @related = [] + @cookie = @native[:cookie] + @name = fix_encoding(data[@native.size, @native[:len]].gsub(/\0+$/, '')) + @notifier = notifier + @watcher_id = @native[:wd] + + raise QueueOverflowError.new("inotify event queue has overflowed.") if @native[:mask] & Native::Flags::IN_Q_OVERFLOW != 0 + end + + # Calls the callback of the watcher that fired this event, + # passing in the event itself. + # + # @private + def callback! + watcher && watcher.callback!(self) + end + + # Returns the size of this event object in bytes, + # including the \{#name} string. + # + # @return [Fixnum] + def size + @native.size + @native[:len] + end + + private + + def fix_encoding(name) + name.force_encoding('filesystem') if name.respond_to?(:force_encoding) + name + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/native.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/native.rb new file mode 100644 index 0000000..6da36eb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/native.rb @@ -0,0 +1,33 @@ +require 'ffi' + +module INotify + # This module contains the low-level foreign-function interface code + # for dealing with the inotify C APIs. + # It's an implementation detail, and not meant for users to deal with. + # + # @private + module Native + extend FFI::Library + ffi_lib FFI::Library::LIBC + begin + ffi_lib 'inotify' + rescue LoadError + end + + # The C struct describing an inotify event. + # + # @private + class Event < FFI::Struct + layout( + :wd, :int, + :mask, :uint32, + :cookie, :uint32, + :len, :uint32) + end + + attach_function :inotify_init, [], :int + attach_function :inotify_add_watch, [:int, :string, :uint32], :int + attach_function :inotify_rm_watch, [:int, :uint32], :int + attach_function :fpathconf, [:int, :int], :long + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/native/flags.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/native/flags.rb new file mode 100644 index 0000000..5640130 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/native/flags.rb @@ -0,0 +1,94 @@ +module INotify + module Native + # A module containing all the inotify flags + # to be passed to {Notifier#watch}. + # + # @private + module Flags + # File was accessed. + IN_ACCESS = 0x00000001 + # Metadata changed. + IN_ATTRIB = 0x00000004 + # Writtable file was closed. + IN_CLOSE_WRITE = 0x00000008 + # File was modified. + IN_MODIFY = 0x00000002 + # Unwrittable file closed. + IN_CLOSE_NOWRITE = 0x00000010 + # File was opened. + IN_OPEN = 0x00000020 + # File was moved from X. + IN_MOVED_FROM = 0x00000040 + # File was moved to Y. + IN_MOVED_TO = 0x00000080 + # Subfile was created. + IN_CREATE = 0x00000100 + # Subfile was deleted. + IN_DELETE = 0x00000200 + # Self was deleted. + IN_DELETE_SELF = 0x00000400 + # Self was moved. + IN_MOVE_SELF = 0x00000800 + + ## Helper events. + + # Close. + IN_CLOSE = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) + # Moves. + IN_MOVE = (IN_MOVED_FROM | IN_MOVED_TO) + # All events which a program can wait on. + IN_ALL_EVENTS = (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | + IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_CREATE | + IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF) + + + ## Special flags. + + # Only watch the path if it is a directory. + IN_ONLYDIR = 0x01000000 + # Do not follow a sym link. + IN_DONT_FOLLOW = 0x02000000 + # Add to the mask of an already existing watch. + IN_MASK_ADD = 0x20000000 + # Only send event once. + IN_ONESHOT = 0x80000000 + + + ## Events sent by the kernel. + + # Backing fs was unmounted. + IN_UNMOUNT = 0x00002000 + # Event queued overflowed. + IN_Q_OVERFLOW = 0x00004000 + # File was ignored. + IN_IGNORED = 0x00008000 + # Event occurred against dir. + IN_ISDIR = 0x40000000 + + ## fpathconf Macros + + # returns the maximum length of a filename in the directory path or fd that the process is allowed to create. The corresponding macro is _POSIX_NAME_MAX. + PC_NAME_MAX = 3 + + # Converts a list of flags to the bitmask that the C API expects. + # + # @param flags [Array] + # @return [Fixnum] + def self.to_mask(flags) + flags.map {|flag| const_get("IN_#{flag.to_s.upcase}")}. + inject(0) {|mask, flag| mask | flag} + end + + # Converts a bitmask from the C API into a list of flags. + # + # @param mask [Fixnum] + # @return [Array] + def self.from_mask(mask) + constants.map {|c| c.to_s}.select do |c| + next false unless c =~ /^IN_/ + const_get(c) & mask != 0 + end.map {|c| c.sub("IN_", "").downcase.to_sym} - [:all_events] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/notifier.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/notifier.rb new file mode 100644 index 0000000..398ef99 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/notifier.rb @@ -0,0 +1,322 @@ +require 'thread' + +module INotify + # Notifier wraps a single instance of inotify. + # It's possible to have more than one instance, + # but usually unnecessary. + # + # @example + # # Create the notifier + # notifier = INotify::Notifier.new + # + # # Run this callback whenever the file path/to/foo.txt is read + # notifier.watch("path/to/foo.txt", :access) do + # puts "Foo.txt was accessed!" + # end + # + # # Watch for any file in the directory being deleted + # # or moved out of the directory. + # notifier.watch("path/to/directory", :delete, :moved_from) do |event| + # # The #name field of the event object contains the name of the affected file + # puts "#{event.name} is no longer in the directory!" + # end + # + # # Nothing happens until you run the notifier! + # notifier.run + class Notifier + # * Files in `/dev/fd` sometimes register as directories, but are not enumerable. + NON_RECURSIVE = "/dev/fd" + + # A hash from {Watcher} ids to the instances themselves. + # + # @private + # @return [{Fixnum => Watcher}] + attr_reader :watchers + + # The underlying file descriptor for this notifier. + # This is a valid OS file descriptor, and can be used as such + # (except under JRuby -- see \{#to\_io}). + # + # @return [Fixnum] + def fd + @handle.fileno + end + + # Creates a new {Notifier}. + # + # @return [Notifier] + # @raise [SystemCallError] if inotify failed to initialize for some reason + def initialize + @running = Mutex.new + @stop = false + @pipe = IO.pipe + # JRuby shutdown sometimes runs IO finalizers before all threads finish. + if RUBY_ENGINE == 'jruby' + @pipe[0].autoclose = false + @pipe[1].autoclose = false + end + + @watchers = {} + + fd = Native.inotify_init + unless fd < 0 + @handle = IO.new(fd) + @handle.autoclose = false if RUBY_ENGINE == 'jruby' + return + end + + raise SystemCallError.new( + "Failed to initialize inotify" + + case FFI.errno + when Errno::EMFILE::Errno; ": the user limit on the total number of inotify instances has been reached." + when Errno::ENFILE::Errno; ": the system limit on the total number of file descriptors has been reached." + when Errno::ENOMEM::Errno; ": insufficient kernel memory is available." + else; "" + end, + FFI.errno) + end + + # Returns a Ruby IO object wrapping the underlying file descriptor. + # Since this file descriptor is fully functional (except under JRuby), + # this IO object can be used in any way a Ruby-created IO object can. + # This includes passing it to functions like `#select`. + # + # Note that this always returns the same IO object. + # Creating lots of IO objects for the same file descriptor + # can cause some odd problems. + # + # **This is not supported under JRuby**. + # JRuby currently doesn't use native file descriptors for the IO object, + # so we can't use this file descriptor as a stand-in. + # + # @return [IO] An IO object wrapping the file descriptor + # @raise [NotImplementedError] if this is being called in JRuby + def to_io + @handle + end + + # Watches a file or directory for changes, + # calling the callback when there are. + # This is only activated once \{#process} or \{#run} is called. + # + # **Note that by default, this does not recursively watch subdirectories + # of the watched directory**. + # To do so, use the `:recursive` flag. + # + # ## Flags + # + # `:access` + # : A file is accessed (that is, read). + # + # `:attrib` + # : A file's metadata is changed (e.g. permissions, timestamps, etc). + # + # `:close_write` + # : A file that was opened for writing is closed. + # + # `:close_nowrite` + # : A file that was not opened for writing is closed. + # + # `:modify` + # : A file is modified. + # + # `:open` + # : A file is opened. + # + # ### Directory-Specific Flags + # + # These flags only apply when a directory is being watched. + # + # `:moved_from` + # : A file is moved out of the watched directory. + # + # `:moved_to` + # : A file is moved into the watched directory. + # + # `:create` + # : A file is created in the watched directory. + # + # `:delete` + # : A file is deleted in the watched directory. + # + # `:delete_self` + # : The watched file or directory itself is deleted. + # + # `:move_self` + # : The watched file or directory itself is moved. + # + # ### Helper Flags + # + # These flags are just combinations of the flags above. + # + # `:close` + # : Either `:close_write` or `:close_nowrite` is activated. + # + # `:move` + # : Either `:moved_from` or `:moved_to` is activated. + # + # `:all_events` + # : Any event above is activated. + # + # ### Options Flags + # + # These flags don't actually specify events. + # Instead, they specify options for the watcher. + # + # `:onlydir` + # : Only watch the path if it's a directory. + # + # `:dont_follow` + # : Don't follow symlinks. + # + # `:mask_add` + # : Add these flags to the pre-existing flags for this path. + # + # `:oneshot` + # : Only send the event once, then shut down the watcher. + # + # `:recursive` + # : Recursively watch any subdirectories that are created. + # Note that this is a feature of rb-inotify, + # rather than of inotify itself, which can only watch one level of a directory. + # This means that the {Event#name} field + # will contain only the basename of the modified file. + # When using `:recursive`, {Event#absolute_name} should always be used. + # + # @param path [String] The path to the file or directory + # @param flags [Array] Which events to watch for + # @yield [event] A block that will be called + # whenever one of the specified events occur + # @yieldparam event [Event] The Event object containing information + # about the event that occured + # @return [Watcher] A Watcher set up to watch this path for these events + # @raise [SystemCallError] if the file or directory can't be watched, + # e.g. if the file isn't found, read access is denied, + # or the flags don't contain any events + def watch(path, *flags, &callback) + return Watcher.new(self, path, *flags, &callback) unless flags.include?(:recursive) + + dont_follow = flags.include?(:dont_follow) + + Dir.each_child(path) do |base| + d = File.join(path, base) + next unless File.directory?(d) + next if dont_follow && File.symlink?(d) + next if NON_RECURSIVE == d + + watch(d, *flags, &callback) + end + + + rec_flags = [:create, :moved_to] + return watch(path, *((flags - [:recursive]) | rec_flags)) do |event| + callback.call(event) if flags.include?(:all_events) || !(flags & event.flags).empty? + next if (rec_flags & event.flags).empty? || !event.flags.include?(:isdir) + begin + watch(event.absolute_name, *flags, &callback) + rescue Errno::ENOENT + # If the file has been deleted since the glob was run, we don't want to error out. + end + end + end + + # Starts the notifier watching for filesystem events. + # Blocks until \{#stop} is called. + # + # @see #process + def run + @running.synchronize do + Thread.current[:INOTIFY_RUN_THREAD] = true + + process until @stop + end + ensure + Thread.current[:INOTIFY_RUN_THREAD] = false + @stop = false + end + + # Stop watching for filesystem events. + # That is, if we're in a \{#run} loop, + # exit out as soon as we finish handling the events. + def stop + @stop = true + @pipe.last.write "." + + unless Thread.current[:INOTIFY_RUN_THREAD] + @running.synchronize do + # no-op: we just needed to wait until the lock was available + end + end + end + + # Blocks until there are one or more filesystem events + # that this notifier has watchers registered for. + # Once there are events, the appropriate callbacks are called + # and this function returns. + # + # @see #run + def process + read_events.each do |event| + event.callback! + event.flags.include?(:ignored) && event.notifier.watchers.delete(event.watcher_id) + end + end + + # Close the notifier. + # + # @raise [SystemCallError] if closing the underlying file descriptor fails. + def close + stop + @handle.close + @watchers.clear + end + + # Blocks until there are one or more filesystem events that this notifier + # has watchers registered for. Once there are events, returns their {Event} + # objects. + # + # This can return an empty list if the watcher was closed elsewhere. + # + # {#run} or {#process} are ususally preferable to calling this directly. + def read_events + size = Native::Event.size + Native.fpathconf(fd, Native::Flags::PC_NAME_MAX) + 1 + tries = 1 + + begin + data = readpartial(size) + rescue SystemCallError => er + # EINVAL means that there's more data to be read + # than will fit in the buffer size + raise er unless er.errno == Errno::EINVAL::Errno && tries < 5 + size *= 2 + tries += 1 + retry + end + return [] if data.nil? + + events = [] + cookies = {} + while event = Event.consume(data, self) + events << event + next if event.cookie == 0 + cookies[event.cookie] ||= [] + cookies[event.cookie] << event + end + cookies.each {|c, evs| evs.each {|ev| ev.related.replace(evs - [ev]).freeze}} + events + end + + private + + # Same as IO#readpartial, or as close as we need. + def readpartial(size) + readable, = select([@handle, @pipe.first]) + return nil if readable.include?(@pipe.first) + @handle.readpartial(size) + rescue Errno::EBADF + # If the IO has already been closed, reading from it will cause + # Errno::EBADF. + nil + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/version.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/version.rb new file mode 100644 index 0000000..fc04216 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/version.rb @@ -0,0 +1,24 @@ +# Copyright, 2012, by Natalie Weizenbaum. +# Copyright, 2017, by Samuel G. D. Williams. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +module INotify + VERSION = '0.11.1' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/watcher.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/watcher.rb new file mode 100644 index 0000000..1205e2d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/lib/rb-inotify/watcher.rb @@ -0,0 +1,88 @@ +module INotify + # Watchers monitor a single path for changes, + # specified by {INotify::Notifier#watch event flags}. + # A watcher is usually created via \{Notifier#watch}. + # + # One {Notifier} may have many {Watcher}s. + # The Notifier actually takes care of the checking for events, + # via \{Notifier#run #run} or \{Notifier#process #process}. + # The main purpose of having Watcher objects + # is to be able to disable them using \{#close}. + class Watcher + # The {Notifier} that this Watcher belongs to. + # + # @return [Notifier] + attr_reader :notifier + + # The path that this Watcher is watching. + # + # @return [String] + attr_reader :path + + # The {INotify::Notifier#watch flags} + # specifying the events that this Watcher is watching for, + # and potentially some options as well. + # + # @return [Array] + attr_reader :flags + + # The id for this Watcher. + # Used to retrieve this Watcher from {Notifier#watchers}. + # + # @private + # @return [Fixnum] + attr_reader :id + + # Calls this Watcher's callback with the given {Event}. + # + # @private + # @param event [Event] + def callback!(event) + @callback[event] + end + + # Disables this Watcher, so that it doesn't fire any more events. + # + # @raise [SystemCallError] if the watch fails to be disabled for some reason + def close + if Native.inotify_rm_watch(@notifier.fd, @id) == 0 + @notifier.watchers.delete(@id) + return + end + + raise SystemCallError.new("Failed to stop watching #{path.inspect}", + FFI.errno) + end + + # Creates a new {Watcher}. + # + # @private + # @see Notifier#watch + def initialize(notifier, path, *flags, &callback) + @notifier = notifier + @callback = callback || proc {} + @path = path + @flags = flags.freeze + @id = Native.inotify_add_watch(@notifier.fd, path.dup, + Native::Flags.to_mask(flags)) + + unless @id < 0 + @notifier.watchers[@id] = self + return + end + + raise SystemCallError.new( + "Failed to watch #{path.inspect}" + + case FFI.errno + when Errno::EACCES::Errno; ": read access to the given file is not permitted." + when Errno::EBADF::Errno; ": the given file descriptor is not valid." + when Errno::EFAULT::Errno; ": path points outside of the process's accessible address space." + when Errno::EINVAL::Errno; ": the given event mask contains no legal events; or fd is not an inotify file descriptor." + when Errno::ENOMEM::Errno; ": insufficient kernel memory was available." + when Errno::ENOSPC::Errno; ": The user limit on the total number of inotify watches was reached or the kernel failed to allocate a needed resource." + else; "" + end, + FFI.errno) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/rb-inotify.gemspec b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/rb-inotify.gemspec new file mode 100644 index 0000000..5ce4bc3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/rb-inotify.gemspec @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +require_relative 'lib/rb-inotify/version' + +Gem::Specification.new do |spec| + spec.name = 'rb-inotify' + spec.version = INotify::VERSION + spec.platform = Gem::Platform::RUBY + + spec.summary = 'A Ruby wrapper for Linux inotify, using FFI' + spec.authors = ['Natalie Weizenbaum', 'Samuel Williams'] + spec.email = ['nex342@gmail.com', 'samuel.williams@oriontransfer.co.nz'] + spec.homepage = 'https://github.com/guard/rb-inotify' + spec.licenses = ['MIT'] + + spec.files = `git ls-files`.split($/) + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ["lib"] + + spec.required_ruby_version = '>= 2.5' + + spec.add_dependency "ffi", "~> 1.0" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/inotify_spec.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/inotify_spec.rb new file mode 100644 index 0000000..b73ea30 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/inotify_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe INotify do + describe "version" do + it "exists" do + expect(INotify::VERSION).to be_truthy + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/notifier_spec.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/notifier_spec.rb new file mode 100644 index 0000000..8370151 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/notifier_spec.rb @@ -0,0 +1,190 @@ +require 'spec_helper' +require 'tmpdir' +require 'concurrent' + +describe INotify::Notifier do + describe "instance" do + around do |block| + Dir.mktmpdir do |dir| + @root = Pathname.new(dir) + @notifier = INotify::Notifier.new + + begin + block.call + ensure + @notifier.close + end + end + end + + let(:dir) do + @root.join("foo").tap(&:mkdir) + end + + let(:another_dir) do + @root.join("bar").tap(&:mkdir) + end + + it "stops" do + @notifier.stop + end + + describe :process do + it "gets events" do + events = recording(dir, :create) + dir.join("test.txt").write("hello world") + + @notifier.process + + expect(events.size).to eq(1) + expect(events.first.name).to eq("test.txt") + expect(events.first.absolute_name).to eq(dir.join("test.txt").to_s) + end + + it "gets simultaneous events" do + events = recording(dir, :create) + + dir.join("one.txt").write("hello world") + dir.join("two.txt").write("hello world") + + @notifier.process + + expect(events.map(&:name)).to match_array(%w(one.txt two.txt)) + end + + it "separates events between watches" do + bar_events = nil + + foo_events = recording(dir, :create) + bar_events = recording(another_dir, :create) + + dir.join("test.txt").write("hello world") + another_dir.join("test_two.txt").write("hello world") + + @notifier.process + + expect(foo_events.size).to eq(1) + expect(foo_events.first.name).to eq("test.txt") + expect(foo_events.first.absolute_name).to eq(dir.join("test.txt").to_s) + + expect(bar_events.size).to eq(1) + expect(bar_events.first.name).to eq("test_two.txt") + expect(bar_events.first.absolute_name).to eq(another_dir.join("test_two.txt").to_s) + end + end + + describe :run do + it "processes repeatedly until stopped" do + barriers = Array.new(3) { Concurrent::Event.new } + barrier_queue = barriers.dup + events = recording(dir, :create) { barrier_queue.shift.set } + + run_thread = Thread.new { @notifier.run } + + dir.join("one.txt").write("hello world") + barriers.shift.wait(1) or raise "timeout" + + expect(events.map(&:name)).to match_array(%w(one.txt)) + + dir.join("two.txt").write("hello world") + barriers.shift.wait(1) or raise "timeout" + + expect(events.map(&:name)).to match_array(%w(one.txt two.txt)) + + @notifier.stop + + dir.join("three.txt").write("hello world") + run_thread.join(1) or raise "timeout" + + expect(events.map(&:name)).to match_array(%w(one.txt two.txt)) + end + + it "can be stopped from within a callback" do + recording(dir, :create) { @notifier.stop } + + run_thread = Thread.new { @notifier.run } + + dir.join("one.txt").write("hello world") + run_thread.join(1) or raise "timeout" + end + + it "can be stopped before it starts processing" do + barrier = Concurrent::Event.new + + run_thread = Thread.new do + barrier.wait + @notifier.run + end + + @notifier.stop + barrier.set + + run_thread.join(1) or raise "timeout" + end + end + + describe :fd do + it "returns an integer" do + expect(@notifier.fd).to be_an(Integer) + end + end + + describe :to_io do + it "returns a ruby IO" do + expect(@notifier.to_io).to be_an(::IO) + end + + it "matches the fd" do + expect(@notifier.to_io.fileno).to eq(@notifier.fd) + end + + it "caches its result" do + expect(@notifier.to_io).to be(@notifier.to_io) + end + + it "is selectable" do + events = recording(dir, :create) + expect(select([@notifier.to_io], nil, nil, 0.2)).to be_nil + + dir.join("test.txt").write("hello world") + expect(select([@notifier.to_io], nil, nil, 0.2)).to eq([[@notifier.to_io], [], []]) + + @notifier.process + expect(select([@notifier.to_io], nil, nil, 0.2)).to be_nil + end + end + + private + + def recording(dir, *flags, callback: nil) + events = [] + @notifier.watch(dir.to_s, *flags) do |event| + events << event + yield if block_given? + end + + events + end + end + + describe "mixed instances" do + it "doesn't tangle fds" do + notifiers = Array.new(30) { INotify::Notifier.new } + notifiers.each(&:to_io) + + one = Array.new(10) { IO.pipe.last } + notifiers.each(&:close) + + two = Array.new(10) { IO.pipe.last } + + notifiers = nil + GC.start + + _, writable, _ = select(nil, one, nil, 1) + expect(writable).to match_array(one) + + _, writable, _ = select(nil, two, nil, 1) + expect(writable).to match_array(two) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/spec_helper.rb b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/spec_helper.rb new file mode 100644 index 0000000..b62f9cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rb-inotify-0.11.1/spec/spec_helper.rb @@ -0,0 +1,29 @@ + +if ENV['COVERAGE'] || ENV['TRAVIS'] + begin + require 'simplecov' + + SimpleCov.start do + add_filter "/spec/" + end + + if ENV['TRAVIS'] + require 'coveralls' + Coveralls.wear! + end + rescue LoadError + warn "Could not load simplecov: #{$!}" + end +end + +require "bundler/setup" +require "rb-inotify" + +RSpec.configure do |config| + # Enable flags like --only-failures and --next-failure + config.example_status_persistence_file_path = ".rspec_status" + + config.expect_with :rspec do |c| + c.syntax = :expect + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/LICENSE.txt new file mode 100644 index 0000000..a009cae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +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. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/NEWS.md b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/NEWS.md new file mode 100644 index 0000000..165b1c7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/NEWS.md @@ -0,0 +1,543 @@ +# News + +## 3.3.5 - 2024-08-12 {#version-3-3-5} + +### Fixes + + * Fixed a bug that `REXML::Security.entity_expansion_text_limit` + check has wrong text size calculation in SAX and pull parsers. + * GH-193 + * GH-195 + * Reported by Viktor Ivarsson. + * Patch by NAITOH Jun. + +### Thanks + + * Viktor Ivarsson + + * NAITOH Jun + +## 3.3.4 - 2024-08-01 {#version-3-3-4} + +### Fixes + + * Fixed a bug that `REXML::Security` isn't defined when + `REXML::Parsers::StreamParser` is used and + `rexml/parsers/streamparser` is only required. + * GH-189 + * Patch by takuya kodama. + +### Thanks + + * takuya kodama + +## 3.3.3 - 2024-08-01 {#version-3-3-3} + +### Improvements + + * Added support for detecting invalid XML that has unsupported + content before root element + * GH-184 + * Patch by NAITOH Jun. + + * Added support for `REXML::Security.entity_expansion_limit=` and + `REXML::Security.entity_expansion_text_limit=` in SAX2 and pull + parsers + * GH-187 + * Patch by NAITOH Jun. + + * Added more tests for invalid XMLs. + * GH-183 + * Patch by Watson. + + * Added more performance tests. + * Patch by Watson. + + * Improved parse performance. + * GH-186 + * Patch by tomoya ishida. + +### Thanks + + * NAITOH Jun + + * Watson + + * tomoya ishida + +## 3.3.2 - 2024-07-16 {#version-3-3-2} + +### Improvements + + * Improved parse performance. + * GH-160 + * Patch by NAITOH Jun. + + * Improved parse performance. + * GH-169 + * GH-170 + * GH-171 + * GH-172 + * GH-173 + * GH-174 + * GH-175 + * GH-176 + * GH-177 + * Patch by Watson. + + * Added support for raising a parse exception when an XML has extra + content after the root element. + * GH-161 + * Patch by NAITOH Jun. + + * Added support for raising a parse exception when an XML + declaration exists in wrong position. + * GH-162 + * Patch by NAITOH Jun. + + * Removed needless a space after XML declaration in pretty print mode. + * GH-164 + * Patch by NAITOH Jun. + + * Stopped to emit `:text` event after the root element. + * GH-167 + * Patch by NAITOH Jun. + +### Fixes + + * Fixed a bug that SAX2 parser doesn't expand predefined entities for + `characters` callback. + * GH-168 + * Patch by NAITOH Jun. + +### Thanks + + * NAITOH Jun + + * Watson + +## 3.3.1 - 2024-06-25 {#version-3-3-1} + +### Improvements + + * Added support for detecting malformed top-level comments. + * GH-145 + * Patch by Hiroya Fujinami. + + * Improved `REXML::Element#attribute` performance. + * GH-146 + * Patch by Hiroya Fujinami. + + * Added support for detecting malformed `` comments. + * GH-147 + * Patch by Hiroya Fujinami. + + * Added support for detecting unclosed `DOCTYPE`. + * GH-152 + * Patch by Hiroya Fujinami. + + * Added `changlog_uri` metadata to gemspec. + * GH-156 + * Patch by fynsta. + + * Improved parse performance. + * GH-157 + * GH-158 + * Patch by NAITOH Jun. + +### Fixes + + * Fixed a bug that large XML can't be parsed. + * GH-154 + * Patch by NAITOH Jun. + + * Fixed a bug that private constants are visible. + * GH-155 + * Patch by NAITOH Jun. + +### Thanks + + * Hiroya Fujinami + + * NAITOH Jun + + * fynsta + +## 3.3.0 - 2024-06-11 {#version-3-3-0} + +### Improvements + + * Added support for strscan 0.7.0 installed with Ruby 2.6. + * GH-142 + * Reported by Fernando Trigoso. + +### Thanks + + * Fernando Trigoso + +## 3.2.9 - 2024-06-09 {#version-3-2-9} + +### Improvements + + * Added support for old strscan. + * GH-132 + * Reported by Adam. + + * Improved attribute value parse performance. + * GH-135 + * Patch by NAITOH Jun. + + * Improved `REXML::Node#each_recursive` performance. + * GH-134 + * GH-139 + * Patch by Hiroya Fujinami. + + * Improved text parse performance. + * Reported by mprogrammer. + +### Thanks + + * Adam + * NAITOH Jun + * Hiroya Fujinami + * mprogrammer + +## 3.2.8 - 2024-05-16 {#version-3-2-8} + +### Fixes + + * Suppressed a warning + +## 3.2.7 - 2024-05-16 {#version-3-2-7} + +### Improvements + + * Improve parse performance by using `StringScanner`. + + * GH-106 + * GH-107 + * GH-108 + * GH-109 + * GH-112 + * GH-113 + * GH-114 + * GH-115 + * GH-116 + * GH-117 + * GH-118 + * GH-119 + * GH-121 + + * Patch by NAITOH Jun. + + * Improved parse performance when an attribute has many `<`s. + + * GH-126 + +### Fixes + + * XPath: Fixed a bug of `normalize_space(array)`. + + * GH-110 + * GH-111 + + * Patch by flatisland. + + * XPath: Fixed a bug that wrong position is used with nested path. + + * GH-110 + * GH-122 + + * Reported by jcavalieri. + * Patch by NAITOH Jun. + + * Fixed a bug that an exception message can't be generated for + invalid encoding XML. + + * GH-29 + * GH-123 + + * Reported by DuKewu. + * Patch by NAITOH Jun. + +### Thanks + + * NAITOH Jun + * flatisland + * jcavalieri + * DuKewu + +## 3.2.6 - 2023-07-27 {#version-3-2-6} + +### Improvements + + * Required Ruby 2.5 or later explicitly. + [GH-69][gh-69] + [Patch by Ivo Anjo] + + * Added documentation for maintenance cycle. + [GH-71][gh-71] + [Patch by Ivo Anjo] + + * Added tutorial. + [GH-77][gh-77] + [GH-78][gh-78] + [Patch by Burdette Lamar] + + * Improved performance and memory usage. + [GH-94][gh-94] + [Patch by fatkodima] + + * `REXML::Parsers::XPathParser#abbreviate`: Added support for + function arguments. + [GH-95][gh-95] + [Reported by pulver] + + * `REXML::Parsers::XPathParser#abbreviate`: Added support for string + literal that contains double-quote. + [GH-96][gh-96] + [Patch by pulver] + + * `REXML::Parsers::XPathParser#abbreviate`: Added missing `/` to + `:descendant_or_self/:self/:parent`. + [GH-97][gh-97] + [Reported by pulver] + + * `REXML::Parsers::XPathParser#abbreviate`: Added support for more patterns. + [GH-97][gh-97] + [Reported by pulver] + +### Fixes + + * Fixed a typo in NEWS. + [GH-72][gh-72] + [Patch by Spencer Goodman] + + * Fixed a typo in NEWS. + [GH-75][gh-75] + [Patch by Andrew Bromwich] + + * Fixed documents. + [GH-87][gh-87] + [Patch by Alexander Ilyin] + + * Fixed a bug that `Attriute` convert `'` and `'` even when + `attribute_quote: :quote` is used. + [GH-92][gh-92] + [Reported by Edouard Brière] + + * Fixed links in tutorial. + [GH-99][gh-99] + [Patch by gemmaro] + + +### Thanks + + * Ivo Anjo + + * Spencer Goodman + + * Andrew Bromwich + + * Burdette Lamar + + * Alexander Ilyin + + * Edouard Brière + + * fatkodima + + * pulver + + * gemmaro + +[gh-69]:https://github.com/ruby/rexml/issues/69 +[gh-71]:https://github.com/ruby/rexml/issues/71 +[gh-72]:https://github.com/ruby/rexml/issues/72 +[gh-75]:https://github.com/ruby/rexml/issues/75 +[gh-77]:https://github.com/ruby/rexml/issues/77 +[gh-87]:https://github.com/ruby/rexml/issues/87 +[gh-92]:https://github.com/ruby/rexml/issues/92 +[gh-94]:https://github.com/ruby/rexml/issues/94 +[gh-95]:https://github.com/ruby/rexml/issues/95 +[gh-96]:https://github.com/ruby/rexml/issues/96 +[gh-97]:https://github.com/ruby/rexml/issues/97 +[gh-98]:https://github.com/ruby/rexml/issues/98 +[gh-99]:https://github.com/ruby/rexml/issues/99 + +## 3.2.5 - 2021-04-05 {#version-3-2-5} + +### Improvements + + * Add more validations to XPath parser. + + * `require "rexml/document"` by default. + [GitHub#36][Patch by Koichi ITO] + + * Don't add `#dclone` method to core classes globally. + [GitHub#37][Patch by Akira Matsuda] + + * Add more documentations. + [Patch by Burdette Lamar] + + * Added `REXML::Elements#parent`. + [GitHub#52][Patch by Burdette Lamar] + +### Fixes + + * Fixed a bug that `REXML::DocType#clone` doesn't copy external ID + information. + + * Fixed round-trip vulnerability bugs. + See also: https://www.ruby-lang.org/en/news/2021/04/05/xml-round-trip-vulnerability-in-rexml-cve-2021-28965/ + [HackerOne#1104077][CVE-2021-28965][Reported by Juho Nurminen] + +### Thanks + + * Koichi ITO + + * Akira Matsuda + + * Burdette Lamar + + * Juho Nurminen + +## 3.2.4 - 2020-01-31 {#version-3-2-4} + +### Improvements + + * Don't use `taint` with Ruby 2.7 or later. + [GitHub#21][Patch by Jeremy Evans] + +### Fixes + + * Fixed a `elsif` typo. + [GitHub#22][Patch by Nobuyoshi Nakada] + +### Thanks + + * Jeremy Evans + + * Nobuyoshi Nakada + +## 3.2.3 - 2019-10-12 {#version-3-2-3} + +### Fixes + + * Fixed a bug that `REXML::XMLDecl#close` doesn't copy `@writethis`. + [GitHub#20][Patch by hirura] + +### Thanks + + * hirura + +## 3.2.2 - 2019-06-03 {#version-3-2-2} + +### Fixes + + * xpath: Fixed a bug for equality and relational expressions. + [GitHub#17][Reported by Mirko Budszuhn] + + * xpath: Fixed `boolean()` implementation. + + * xpath: Fixed `local_name()` with nonexistent node. + + * xpath: Fixed `number()` implementation with node set. + [GitHub#18][Reported by Mirko Budszuhn] + +### Thanks + + * Mirko Budszuhn + +## 3.2.1 - 2019-05-04 {#version-3-2-1} + +### Improvements + + * Improved error message. + [GitHub#12][Patch by FUJI Goro] + + * Improved error message. + [GitHub#16][Patch by ujihisa] + + * Improved documentation markup. + [GitHub#14][Patch by Alyssa Ross] + +### Fixes + + * Fixed a bug that `nil` variable value raises an unexpected exception. + [GitHub#13][Patch by Alyssa Ross] + +### Thanks + + * FUJI Goro + + * Alyssa Ross + + * ujihisa + +## 3.2.0 - 2019-01-01 {#version-3-2-0} + +### Fixes + + * Fixed a bug that no namespace attribute isn't matched with prefix. + + [ruby-list:50731][Reported by Yasuhiro KIMURA] + + * Fixed a bug that the default namespace is applied to attribute names. + + NOTE: It's a backward incompatible change. If your program has any + problem with this change, please report it. We may revert this fix. + + * `REXML::Attribute#prefix` returns `""` for no namespace attribute. + + * `REXML::Attribute#namespace` returns `""` for no namespace attribute. + +### Thanks + + * Yasuhiro KIMURA + +## 3.1.9 - 2018-12-20 {#version-3-1-9} + +### Improvements + + * Improved backward compatibility. + + Restored `REXML::Parsers::BaseParser::UNQME_STR` because it's used + by kramdown. + +## 3.1.8 - 2018-12-20 {#version-3-1-8} + +### Improvements + + * Added support for customizing quote character in prologue. + [GitHub#8][Bug #9367][Reported by Takashi Oguma] + + * You can use `"` as quote character by specifying `:quote` to + `REXML::Document#context[:prologue_quote]`. + + * You can use `'` as quote character by specifying `:apostrophe` + to `REXML::Document#context[:prologue_quote]`. + + * Added processing instruction target check. The target must not nil. + [GitHub#7][Reported by Ariel Zelivansky] + + * Added name check for element and attribute. + [GitHub#7][Reported by Ariel Zelivansky] + + * Stopped to use `Exception`. + [GitHub#9][Patch by Jean Boussier] + +### Fixes + + * Fixed a bug that `REXML::Text#clone` escapes value twice. + [ruby-dev:50626][Bug #15058][Reported by Ryosuke Nanba] + +### Thanks + + * Takashi Oguma + + * Ariel Zelivansky + + * Jean Boussier + + * Ryosuke Nanba diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/README.md b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/README.md new file mode 100644 index 0000000..e8ab508 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/README.md @@ -0,0 +1,57 @@ +# REXML + +REXML was inspired by the Electric XML library for Java, which features an easy-to-use API, small size, and speed. Hopefully, REXML, designed with the same philosophy, has these same features. I've tried to keep the API as intuitive as possible, and have followed the Ruby methodology for method naming and code flow, rather than mirroring the Java API. + +REXML supports both tree and stream document parsing. Stream parsing is faster (about 1.5 times as fast). However, with stream parsing, you don't get access to features such as XPath. + +## API + +See the [API documentation](https://ruby.github.io/rexml/). + +## Usage + +We'll start with parsing an XML document + +```ruby +require "rexml/document" +file = File.new( "mydoc.xml" ) +doc = REXML::Document.new file +``` + +Line 3 creates a new document and parses the supplied file. You can also do the following + +```ruby +require "rexml/document" +include REXML # so that we don't have to prefix everything with REXML::... +string = < + Text, text, text + +EOF +doc = Document.new string +``` + +So parsing a string is just as easy as parsing a file. + +## Support + +REXML support follows the same maintenance cycle as Ruby releases, as shown on . + +If you are running on an end-of-life Ruby, do not expect modern REXML releases to be compatible with it; in fact, it's recommended that you DO NOT use this gem, and instead use the REXML version that came bundled with your end-of-life Ruby version. + +The `required_ruby_version` on the gemspec is kept updated on a [best-effort basis](https://github.com/ruby/rexml/pull/70) by the community. +Up to version 3.2.5, this information was not set. That version [is known broken with at least Ruby < 2.3](https://github.com/ruby/rexml/issues/69). + +## Development + +After checking out the repo, run `rake test` to run the tests. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/rexml. + +## License + +The gem is available as open source under the terms of the [BSD-2-Clause](LICENSE.txt). diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/context.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/context.rdoc new file mode 100644 index 0000000..7ef01f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/context.rdoc @@ -0,0 +1,143 @@ +== Element Context + +Notes: +- All code on this page presupposes that the following has been executed: + + require 'rexml/document' + +- For convenience, examples on this page use +REXML::Document.new+, not +REXML::Element.new+. + This is completely valid, because REXML::Document is a subclass of REXML::Element. + +The context for an element is a hash of processing directives +that influence the way \XML is read, stored, and written. +The context entries are: + +- +:respect_whitespace+: controls treatment of whitespace. +- +:compress_whitespace+: determines whether whitespace is compressed. +- +:ignore_whitespace_nodes+: determines whether whitespace-only nodes are to be ignored. +- +:raw+: controls treatment of special characters and entities. + +The default context for a new element is {}. +You can set the context at element-creation time: + + d = REXML::Document.new('', {compress_whitespace: :all, raw: :all}) + d.context # => {:compress_whitespace=>:all, :raw=>:all} + +You can reset the entire context by assigning a new hash: + + d.context = {ignore_whitespace_nodes: :all} + d.context # => {:ignore_whitespace_nodes=>:all} + +Or you can create or modify an individual entry: + + d.context[:raw] = :all + d.context # => {:ignore_whitespace_nodes=>:all, :raw=>:all} + +=== +:respect_whitespace+ + +Affects: +REXML::Element.new+, +REXML::Element.text=+. + +By default, all parsed whitespace is respected (that is, stored whitespace not compressed): + + xml_string = 'a b c d e f' + d = REXML::Document.new(xml_string) + d.to_s # => "a b c d e f" + +Use +:respect_whitespace+ with an array of element names +to specify the elements that _are_ to have their whitespace respected; +other elements' whitespace, and whitespace between elements, will be compressed. + +In this example: +foo+ and +baz+ will have their whitespace respected; ++bar+ and the space between elements will have their whitespace compressed: + + d = REXML::Document.new(xml_string, {respect_whitespace: ['foo', 'baz']}) + d.to_s # => "a b c d e f" + bar = d.root[2] # => ... + bar.text = 'X Y' + d.to_s # => "a b X Y e f" + +=== +:compress_whitespace+ + +Affects: +REXML::Element.new+, +REXML::Element.text=+. + +Use compress_whitespace: :all +to compress whitespace both within and between elements: + + xml_string = 'a b c d e f' + d = REXML::Document.new(xml_string, {compress_whitespace: :all}) + d.to_s # => "a b c d e f" + +Use +:compress_whitespace+ with an array of element names +to compress whitespace in those elements, +but not in other elements nor between elements. + +In this example, +foo+ and +baz+ will have their whitespace compressed; ++bar+ and the space between elements will not: + + d = REXML::Document.new(xml_string, {compress_whitespace: ['foo', 'baz']}) + d.to_s # => "a b c d e f" + foo = d.root[0] # => ... + foo.text= 'X Y' + d.to_s # => "X Y c d e f" + +=== +:ignore_whitespace_nodes+ + +Affects: +REXML::Element.new+. + +Use ignore_whitespace_nodes: :all to omit all whitespace-only elements. + +In this example, +bar+ has a text node, while nodes +foo+ and +baz+ do not: + + xml_string = ' BAR ' + d = REXML::Document.new(xml_string, {ignore_whitespace_nodes: :all}) + d.to_s # => " FOO BAZ " + root = d.root # => ... + foo = root[0] # => + bar = root[1] # => ... + baz = root[2] # => + foo.first.class # => NilClass + bar.first.class # => REXML::Text + baz.first.class # => NilClass + +Use +:ignore_whitespace_nodes+ with an array of element names +to specify the elements that are to have whitespace nodes ignored. + +In this example, +bar+ and +baz+ have text nodes, while node +foo+ does not. + + xml_string = ' BAR ' + d = REXML::Document.new(xml_string, {ignore_whitespace_nodes: ['foo']}) + d.to_s # => " BAR " + root = d.root # => ... + foo = root[0] # => + bar = root[1] # => ... + baz = root[2] # => ... + foo.first.class # => NilClass + bar.first.class # => REXML::Text + baz.first.class # => REXML::Text + +=== +:raw+ + +Affects: +Element.text=+, +Element.add_text+, +Text.to_s+. + +Parsing of +a+ elements is not affected by +raw+: + + xml_string = '0 < 11 > 0' + d = REXML::Document.new(xml_string, {:raw => ['a']}) + d.root.to_s # => "0 < 11 > 0" + a, b = *d.root.elements + a.to_s # => "0 < 1" + b.to_s # => "1 > 0" + +But Element#text= is affected: + + a.text = '0 < 1' + b.text = '1 > 0' + a.to_s # => "0 < 1" + b.to_s # => "1 &gt; 0" + +As is Element.add_text: + + a.add_text(' so 1 > 0') + b.add_text(' so 0 < 1') + a.to_s # => "0 < 1 so 1 > 0" + b.to_s # => "1 &gt; 0 so 0 &lt; 1" diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/child.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/child.rdoc new file mode 100644 index 0000000..8953638 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/child.rdoc @@ -0,0 +1,87 @@ +== Class Child + +Class Child includes module Node; +see {Tasks for Node}[node_rdoc.html]. + +:include: ../tocs/child_toc.rdoc + +=== Relationships + +==== Task: Set the Parent + +Use method {Child#parent=}[../../../../REXML/Parent.html#method-i-parent-3D] +to set the parent: + + e0 = REXML::Element.new('foo') + e1 = REXML::Element.new('bar') + e1.parent # => nil + e1.parent = e0 + e1.parent # => + +==== Task: Insert Previous Sibling + +Use method {Child#previous_sibling=}[../../../../REXML/Parent.html#method-i-previous_sibling-3D] +to insert a previous sibling: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.to_a # => [, ] + c = d.root[1] # => + b = REXML::Element.new('b') + c.previous_sibling = b + d.root.to_a # => [, , ] + +==== Task: Insert Next Sibling + +Use method {Child#next_sibling=}[../../../../REXML/Parent.html#method-i-next-sibling-3D] +to insert a previous sibling: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.to_a # => [, ] + a = d.root[0] # => + b = REXML::Element.new('b') + a.next_sibling = b + d.root.to_a # => [, , ] + +=== Removal or Replacement + +==== Task: Remove Child from Parent + +Use method {Child#remove}[../../../../REXML/Parent.html#method-i-remove] +to remove a child from its parent; returns the removed child: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.to_a # => [, , ] + b = d.root[1] # => + b.remove # => + d.root.to_a # => [, ] + +==== Task: Replace Child + +Use method {Child#replace_with}[../../../../REXML/Parent.html#method-i-replace] +to replace a child; +returns the replaced child: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.to_a # => [, , ] + b = d.root[1] # => + d = REXML::Element.new('d') + b.replace_with(d) # => + d.root.to_a # => [, , ] + +=== Document + +==== Task: Get the Document + +Use method {Child#document}[../../../../REXML/Parent.html#method-i-document] +to get the document for the child: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.to_a # => [, , ] + b = d.root[1] # => + b.document == d # => true + REXML::Child.new.document # => nil diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/document.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/document.rdoc new file mode 100644 index 0000000..96d0335 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/document.rdoc @@ -0,0 +1,276 @@ +== Class Document + +Class Document has methods from its superclasses and included modules; +see: + +- {Tasks for Element}[element_rdoc.html]. +- {Tasks for Parent}[parent_rdoc.html]. +- {Tasks for Child}[child_rdoc.html]. +- {Tasks for Node}[node_rdoc.html]. +- {Module Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html]. + +:include: ../tocs/document_toc.rdoc + +=== New Document + +==== Task: Create an Empty Document + +Use method {Document::new}[../../../../REXML/Document.html#method-c-new] +to create an empty document. + + d = REXML::Document.new + +==== Task: Parse a \String into a New Document + +Use method {Document::new}[../../../../REXML/Document.html#method-c-new] +to parse an XML string into a new document: + + xml_string = 'textmore' + d = REXML::Document.new(xml_string) + d.root # => ... + +==== Task: Parse an \IO Stream into a New Document + +Use method {Document::new}[../../../../REXML/Document.html#method-c-new] +to parse an XML \IO stream into a new document: + + xml_string = 'textmore' + File.write('t.xml', xml_string) + d = File.open('t.xml', 'r') do |file| + REXML::Document.new(file) + end + d.root # => ... + +==== Task: Create a Document from an Existing Document + +Use method {Document::new}[../../../../REXML/Document.html#method-c-new] +to create a document from an existing document. +The context and attributes are copied to the new document, +but not the children: + + xml_string = 'textmore' + d = REXML::Document.new(xml_string) + d.children # => [ ... ] + d.context = {raw: :all, compress_whitespace: :all} + d.add_attributes({'bar' => 0, 'baz' => 1}) + d1 = REXML::Document.new(d) + d1.context # => {:raw=>:all, :compress_whitespace=>:all} + d1.attributes # => {"bar"=>bar='0', "baz"=>baz='1'} + d1.children # => [] + +==== Task: Clone a Document + +Use method {Document#clone}[../../../../REXML/Document.html#method-i-clone] +to clone a document. +The context and attributes are copied to the new document, +but not the children: + + xml_string = 'textmore' + d = REXML::Document.new(xml_string) + d.children # => [ ... ] + d.context = {raw: :all, compress_whitespace: :all} + d.add_attributes({'bar' => 0, 'baz' => 1}) + d1 = d.clone # => < bar='0' baz='1'/> + d1.context # => {:raw=>:all, :compress_whitespace=>:all} + d1.attributes # => {"bar"=>bar='0', "baz"=>baz='1'} + d1.children # => [] + +=== Document Type + +==== Task: Get the Document Type + +Use method {Document#doctype}[../../../../REXML/Document.html#method-i-doctype] +to get the document type: + + d = REXML::Document.new('') + d.doctype.class # => REXML::DocType + d = REXML::Document.new('') + d.doctype.class # => nil + +==== Task: Set the Document Type + +Use method {document#add}[../../../../REXML/Document.html#method-i-add] +to add or replace the document type: + + d = REXML::Document.new('') + d.doctype.class # => nil + d.add(REXML::DocType.new('foo')) + d.doctype.class # => REXML::DocType + +=== XML Declaration + +==== Task: Get the XML Declaration + +Use method {document#xml_decl}[../../../../REXML/Document.html#method-i-xml_decl] +to get the XML declaration: + + d = REXML::Document.new('') + d.xml_decl.class # => REXML::XMLDecl + d.xml_decl # => + d = REXML::Document.new('') + d.xml_decl.class # => REXML::XMLDecl + d.xml_decl # => + +==== Task: Set the XML Declaration + +Use method {document#add}[../../../../REXML/Document.html#method-i-add] +to replace the XML declaration: + + d = REXML::Document.new('') + d.add(REXML::XMLDecl.new) + +=== Children + +==== Task: Add an Element Child + +Use method +{document#add_element}[../../../../REXML/Document.html#method-i-add_element] +to add an element to the document: + + d = REXML::Document.new('') + d.add_element(REXML::Element.new('root')) + d.children # => [] + +==== Task: Add a Non-Element Child + +Use method +{document#add}[../../../../REXML/Document.html#method-i-add] +to add a non-element to the document: + + xml_string = 'textmore' + d = REXML::Document.new(xml_string) + d.add(REXML::Text.new('foo')) + d.children # => [ ... , "foo"] + +=== Writing + +==== Task: Write to $stdout + +Use method +{document#write}[../../../../REXML/Document.html#method-i-write] +to write the document to $stdout: + + xml_string = 'textmore' + d = REXML::Document.new(xml_string) + d.write + +Output: + + textmore + +==== Task: Write to IO Stream + +Use method +{document#write}[../../../../REXML/Document.html#method-i-write] +to write the document to $stdout: + + xml_string = 'textmore' + d = REXML::Document.new(xml_string) + File.open('t.xml', 'w') do |file| + d.write(file) + end + p File.read('t.xml') + +Output: + + "textmore" + +==== Task: Write with No Indentation + +Use method +{document#write}[../../../../REXML/Document.html#method-i-write] +to write the document with no indentation: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.write({indent: 0}) + +Output: + + + + + + + + + +==== Task: Write with Specified Indentation + +Use method +{document#write}[../../../../REXML/Document.html#method-i-write] +to write the document with a specified indentation: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.write({indent: 2}) + +Output: + + + + + + + + + +=== Querying + +==== Task: Get the Document + +Use method +{document#document}[../../../../REXML/Document.html#method-i-document] +to get the document (+self+); overrides Element#document: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.document == d # => true + +==== Task: Get the Encoding + +Use method +{document#document}[../../../../REXML/Document.html#method-i-document] +to get the document (+self+); overrides Element#document: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.encoding # => "UTF-8" + +==== Task: Get the Node Type + +Use method +{document#node_type}[../../../../REXML/Document.html#method-i-node_type] +to get the node type (+:document+); overrides Element#node_type: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.node_type # => :document + +==== Task: Get the Root Element + +Use method +{document#root}[../../../../REXML/Document.html#method-i-root] +to get the root element: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root # => ... + +==== Task: Determine Whether Stand-Alone + +Use method +{document#stand_alone?}[../../../../REXML/Document.html#method-i-stand_alone-3F] +to get the stand-alone value: + + d = REXML::Document.new('') + d.stand_alone? # => "yes" + +==== Task: Get the Version + +Use method +{document#version}[../../../../REXML/Document.html#method-i-version] +to get the version: + + d = REXML::Document.new('') + d.version # => "2.0" diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/element.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/element.rdoc new file mode 100644 index 0000000..4b3609b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/element.rdoc @@ -0,0 +1,602 @@ +== Class Element + +Class Element has methods from its superclasses and included modules; +see: + +- {Tasks for Parent}[parent_rdoc.html]. +- {Tasks for Child}[child_rdoc.html]. +- {Tasks for Node}[node_rdoc.html]. +- {Module Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html]. + +:include: ../tocs/element_toc.rdoc + +=== New Element + +==== Task: Create a Default Element + +Use method +{Element::new}[../../../../REXML/Element.html#method-c-new] +with no arguments to create a default element: + + e = REXML::Element.new + e.name # => "UNDEFINED" + e.parent # => nil + e.context # => nil + +==== Task: Create a Named Element + +Use method +{Element::new}[../../../../REXML/Element.html#method-c-new] +with a string name argument +to create a named element: + + e = REXML::Element.new('foo') + e.name # => "foo" + e.parent # => nil + e.context # => nil + +==== Task: Create an Element with Name and Parent + +Use method +{Element::new}[../../../../REXML/Element.html#method-c-new] +with name and parent arguments +to create an element with name and parent: + + p = REXML::Parent.new + e = REXML::Element.new('foo', p) + e.name # => "foo" + e.parent # => #]> + e.context # => nil + +==== Task: Create an Element with Name, Parent, and Context + +Use method +{Element::new}[../../../../REXML/Element.html#method-c-new] +with name, parent, and context arguments +to create an element with name, parent, and context: + + p = REXML::Parent.new + e = REXML::Element.new('foo', p, {compress_whitespace: :all}) + e.name # => "foo" + e.parent # => #]> + e.context # => {:compress_whitespace=>:all} + +==== Task: Create a Shallow Clone + +Use method +{Element#clone}[../../../../REXML/Element.html#method-i-clone] +to create a shallow clone of an element, +copying only the name, attributes, and context: + + e0 = REXML::Element.new('foo', nil, {compress_whitespace: :all}) + e0.add_attribute(REXML::Attribute.new('bar', 'baz')) + e0.context = {compress_whitespace: :all} + e1 = e0.clone # => + e1.name # => "foo" + e1.context # => {:compress_whitespace=>:all} + +=== Attributes + +==== Task: Create and Add an Attribute + +Use method +{Element#add_attribute}[../../../../REXML/Element.html#method-i-add_attribute] +to create and add an attribute: + + e = REXML::Element.new + e.add_attribute('attr', 'value') # => "value" + e['attr'] # => "value" + e.add_attribute('attr', 'VALUE') # => "VALUE" + e['attr'] # => "VALUE" + +==== Task: Add an Existing Attribute + +Use method +{Element#add_attribute}[../../../../REXML/Element.html#method-i-add_attribute] +to add an existing attribute: + + e = REXML::Element.new + a = REXML::Attribute.new('attr', 'value') + e.add_attribute(a) + e['attr'] # => "value" + a = REXML::Attribute.new('attr', 'VALUE') + e.add_attribute(a) + e['attr'] # => "VALUE" + +==== Task: Add Multiple Attributes from a Hash + +Use method +{Element#add_attributes}[../../../../REXML/Element.html#method-i-add_attributes] +to add multiple attributes from a hash: + + e = REXML::Element.new + h = {'foo' => 0, 'bar' => 1} + e.add_attributes(h) + e['foo'] # => "0" + e['bar'] # => "1" + +==== Task: Add Multiple Attributes from an Array + +Use method +{Element#add_attributes}[../../../../REXML/Element.html#method-i-add_attributes] +to add multiple attributes from an array: + + e = REXML::Element.new + a = [['foo', 0], ['bar', 1]] + e.add_attributes(a) + e['foo'] # => "0" + e['bar'] # => "1" + +==== Task: Retrieve the Value for an Attribute Name + +Use method +{Element#[]}[../../../../REXML/Element.html#method-i-5B-5D] +to retrieve the value for an attribute name: + + e = REXML::Element.new + e.add_attribute('attr', 'value') # => "value" + e['attr'] # => "value" + +==== Task: Retrieve the Attribute Value for a Name and Namespace + +Use method +{Element#attribute}[../../../../REXML/Element.html#method-i-attribute] +to retrieve the value for an attribute name: + + xml_string = "" + d = REXML::Document.new(xml_string) + e = d.root + e.attribute("x") # => x='x' + e.attribute("x", "a") # => a:x='a:x' + +==== Task: Delete an Attribute + +Use method +{Element#delete_attribute}[../../../../REXML/Element.html#method-i-delete_attribute] +to remove an attribute: + + e = REXML::Element.new('foo') + e.add_attribute('bar', 'baz') + e.delete_attribute('bar') + e.delete_attribute('bar') + e['bar'] # => nil + +==== Task: Determine Whether the Element Has Attributes + +Use method +{Element#has_attributes?}[../../../../REXML/Element.html#method-i-has_attributes-3F] +to determine whether the element has attributes: + + e = REXML::Element.new('foo') + e.has_attributes? # => false + e.add_attribute('bar', 'baz') + e.has_attributes? # => true + +=== Children + +Element Children + +==== Task: Create and Add an Element + +Use method +{Element#add_element}[../../../../REXML/Element.html#method-i-add_element] +to create a new element and add it to this element: + + e0 = REXML::Element.new('foo') + e0.add_element('bar') + e0.children # => [] + +==== Task: Add an Existing Element + +Use method +{Element#add_element}[../../../../REXML/Element.html#method-i-add_element] +to add an element to this element: + + e0 = REXML::Element.new('foo') + e1 = REXML::Element.new('bar') + e0.add_element(e1) + e0.children # => [] + +==== Task: Create and Add an Element with Attributes + +Use method +{Element#add_element}[../../../../REXML/Element.html#method-i-add_element] +to create a new element with attributes, and add it to this element: + + e0 = REXML::Element.new('foo') + e0.add_element('bar', {'name' => 'value'}) + e0.children # => [] + +==== Task: Add an Existing Element with Added Attributes + +Use method +{Element#add_element}[../../../../REXML/Element.html#method-i-add_element] +to add an element to this element: + + e0 = REXML::Element.new('foo') + e1 = REXML::Element.new('bar') + e0.add_element(e1, {'name' => 'value'}) + e0.children # => [] + +==== Task: Delete a Specified Element + +Use method +{Element#delete_element}[../../../../REXML/Element.html#method-i-delete_element] +to remove a specified element from this element: + + e0 = REXML::Element.new('foo') + e1 = REXML::Element.new('bar') + e0.add_element(e1) + e0.children # => [] + e0.delete_element(e1) + e0.children # => [] + +==== Task: Delete an Element by Index + +Use method +{Element#delete_element}[../../../../REXML/Element.html#method-i-delete_element] +to remove an element from this element by index: + + e0 = REXML::Element.new('foo') + e1 = REXML::Element.new('bar') + e0.add_element(e1) + e0.children # => [] + e0.delete_element(1) + e0.children # => [] + +==== Task: Delete an Element by XPath + +Use method +{Element#delete_element}[../../../../REXML/Element.html#method-i-delete_element] +to remove an element from this element by XPath: + + e0 = REXML::Element.new('foo') + e1 = REXML::Element.new('bar') + e0.add_element(e1) + e0.children # => [] + e0.delete_element('//bar/') + e0.children # => [] + +==== Task: Determine Whether Element Children + +Use method +{Element#has_elements?}[../../../../REXML/Element.html#method-i-has_elements-3F] +to determine whether the element has element children: + + e0 = REXML::Element.new('foo') + e0.has_elements? # => false + e0.add_element(REXML::Element.new('bar')) + e0.has_elements? # => true + +==== Task: Get Element Descendants by XPath + +Use method +{Element#get_elements}[../../../../REXML/Element.html#method-i-get_elements] +to fetch all element descendant children by XPath: + + xml_string = <<-EOT + + + + + + EOT + d = REXML::Document.new(xml_string) + d.root.get_elements('//a') # => [ ... , ] + +==== Task: Get Next Element Sibling + +Use method +{Element#next_element}[../../../../REXML/Element.html#method-i-next_element] +to retrieve the next element sibling: + + d = REXML::Document.new 'text' + d.root.elements['b'].next_element #-> + d.root.elements['c'].next_element #-> nil + +==== Task: Get Previous Element Sibling + +Use method +{Element#previous_element}[../../../../REXML/Element.html#method-i-previous_element] +to retrieve the previous element sibling: + + d = REXML::Document.new 'text' + d.root.elements['c'].previous_element #-> + d.root.elements['b'].previous_element #-> nil + +Text Children + +==== Task: Add a Text Node + +Use method +{Element#add_text}[../../../../REXML/Element.html#method-i-add_text] +to add a text node to the element: + + d = REXML::Document.new('foobar') + e = d.root + e.add_text(REXML::Text.new('baz')) + e.to_a # => ["foo", , "bar", "baz"] + e.add_text(REXML::Text.new('baz')) + e.to_a # => ["foo", , "bar", "baz", "baz"] + +==== Task: Replace the First Text Node + +Use method +{Element#text=}[../../../../REXML/Element.html#method-i-text-3D] +to replace the first text node in the element: + + d = REXML::Document.new('textmore') + e = d.root + e.to_a # => [, "text", , "more", ] + e.text = 'oops' + e.to_a # => [, "oops", , "more", ] + +==== Task: Remove the First Text Node + +Use method +{Element#text=}[../../../../REXML/Element.html#method-i-text-3D] +to remove the first text node in the element: + + d = REXML::Document.new('textmore') + e = d.root + e.to_a # => [, "text", , "more", ] + e.text = nil + e.to_a # => [, , "more", ] + +==== Task: Retrieve the First Text Node + +Use method +{Element#get_text}[../../../../REXML/Element.html#method-i-get_text] +to retrieve the first text node in the element: + + d = REXML::Document.new('textmore') + e = d.root + e.to_a # => [, "text", , "more", ] + e.get_text # => "text" + +==== Task: Retrieve a Specific Text Node + +Use method +{Element#get_text}[../../../../REXML/Element.html#method-i-get_text] +to retrieve the first text node in a specified element: + + d = REXML::Document.new "some text this is bold! more text" + e = d.root + e.get_text('//root') # => "some text " + e.get_text('//b') # => "this is bold!" + +==== Task: Determine Whether the Element has Text Nodes + +Use method +{Element#has_text?}[../../../../REXML/Element.html#method-i-has_text-3F] +to determine whether the element has text: + + e = REXML::Element.new('foo') + e.has_text? # => false + e.add_text('bar') + e.has_text? # => true + +Other Children + +==== Task: Get the Child at a Given Index + +Use method +{Element#[]}[../../../../REXML/Element.html#method-i-5B-5D] +to retrieve the child at a given index: + + d = REXML::Document.new '>textmore' + e = d.root + e[0] # => + e[1] # => "text" + e[2] # => + +==== Task: Get All CDATA Children + +Use method +{Element#cdatas}[../../../../REXML/Element.html#method-i-cdatas] +to retrieve all CDATA children: + + xml_string = <<-EOT + + + + + EOT + d = REXML::Document.new(xml_string) + d.root.cdatas # => ["foo", "bar"] + +==== Task: Get All Comment Children + +Use method +{Element#comments}[../../../../REXML/Element.html#method-i-comments] +to retrieve all comment children: + + xml_string = <<-EOT + + + + + EOT + d = REXML::Document.new(xml_string) + d.root.comments.map {|comment| comment.to_s } # => ["foo", "bar"] + +==== Task: Get All Processing Instruction Children + +Use method +{Element#instructions}[../../../../REXML/Element.html#method-i-instructions] +to retrieve all processing instruction children: + + xml_string = <<-EOT + + + + + EOT + d = REXML::Document.new(xml_string) + instructions = d.root.instructions.map {|instruction| instruction.to_s } + instructions # => ["", ""] + +==== Task: Get All Text Children + +Use method +{Element#texts}[../../../../REXML/Element.html#method-i-texts] +to retrieve all text children: + + xml_string = 'textmore' + d = REXML::Document.new(xml_string) + d.root.texts # => ["text", "more"] + +=== Namespaces + +==== Task: Add a Namespace + +Use method +{Element#add_namespace}[../../../../REXML/Element.html#method-i-add_namespace] +to add a namespace to the element: + + e = REXML::Element.new('foo') + e.add_namespace('bar') + e.namespaces # => {"xmlns"=>"bar"} + +==== Task: Delete the Default Namespace + +Use method +{Element#delete_namespace}[../../../../REXML/Element.html#method-i-delete_namespace] +to remove the default namespace from the element: + + d = REXML::Document.new "" + d.to_s # => "" + d.root.delete_namespace # => + d.to_s # => "" + +==== Task: Delete a Specific Namespace + +Use method +{Element#delete_namespace}[../../../../REXML/Element.html#method-i-delete_namespace] +to remove a specific namespace from the element: + + d = REXML::Document.new "" + d.to_s # => "" + d.root.delete_namespace # => + d.to_s # => "" + d.root.delete_namespace('foo') + d.to_s # => "" + +==== Task: Get a Namespace URI + +Use method +{Element#namespace}[../../../../REXML/Element.html#method-i-namespace] +to retrieve a specific namespace URI for the element: + + xml_string = <<-EOT + + + + + + + EOT + d = REXML::Document.new(xml_string) + b = d.elements['//b'] + b.namespace # => "1" + b.namespace('y') # => "2" + +==== Task: Retrieve Namespaces + +Use method +{Element#namespaces}[../../../../REXML/Element.html#method-i-namespaces] +to retrieve all namespaces for the element: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.attributes.namespaces # => {"xmlns"=>"foo", "x"=>"bar", "y"=>"twee"} + +==== Task: Retrieve Namespace Prefixes + +Use method +{Element#prefixes}[../../../../REXML/Element.html#method-i-prefixes] +to retrieve all prefixes (namespace names) for the element: + + xml_string = <<-EOT + + + + + + + EOT + d = REXML::Document.new(xml_string, {compress_whitespace: :all}) + d.elements['//a'].prefixes # => ["x", "y"] + d.elements['//b'].prefixes # => ["x", "y"] + d.elements['//c'].prefixes # => ["x", "y", "z"] + +=== Iteration + +==== Task: Iterate Over Elements + +Use method +{Element#each_element}[../../../../REXML/Element.html#method-i-each_element] +to iterate over element children: + + d = REXML::Document.new 'bbd' + d.root.each_element {|e| p e } + +Output: + + ... + ... + ... + + +==== Task: Iterate Over Elements Having a Specified Attribute + +Use method +{Element#each_element_with_attribute}[../../../../REXML/Element.html#method-i-each_element_with_attribute] +to iterate over element children that have a specified attribute: + + d = REXML::Document.new '' + a = d.root + a.each_element_with_attribute('id') {|e| p e } + +Output: + + + + + +==== Task: Iterate Over Elements Having a Specified Attribute and Value + +Use method +{Element#each_element_with_attribute}[../../../../REXML/Element.html#method-i-each_element_with_attribute] +to iterate over element children that have a specified attribute and value: + + d = REXML::Document.new '' + a = d.root + a.each_element_with_attribute('id', '1') {|e| p e } + +Output: + + + + +==== Task: Iterate Over Elements Having Specified Text + +Use method +{Element#each_element_with_text}[../../../../REXML/Element.html#method-i-each_element_with_text] +to iterate over element children that have specified text: + + +=== Context + +#whitespace +#ignore_whitespace_nodes +#raw + +=== Other Getters + +#document +#root +#root_node +#node_type +#xpath +#inspect diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/node.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/node.rdoc new file mode 100644 index 0000000..d5d2e12 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/node.rdoc @@ -0,0 +1,97 @@ +== Module Node + +:include: ../tocs/node_toc.rdoc + +=== Siblings + +==== Task: Find Previous Sibling + +Use method +{Node.previous_sibling_node}[../../../../REXML/Node.html#method-i-previous_sibling] +to retrieve the previous sibling: + + d = REXML::Document.new('') + b = d.root[1] # => + b.previous_sibling_node # => + +==== Task: Find Next Sibling + +Use method +{Node.next_sibling_node}[../../../../REXML/Node.html#method-i-next_sibling] +to retrieve the next sibling: + + d = REXML::Document.new('') + b = d.root[1] # => + b.next_sibling_node # => + +=== Position + +==== Task: Find Own Index Among Siblings + +Use method +{Node.index_in_parent}[../../../../REXML/Node.html#method-i-index_in_parent] +to retrieve the 1-based index of this node among its siblings: + + d = REXML::Document.new('') + b = d.root[1] # => + b.index_in_parent # => 2 + +=== Recursive Traversal + +==== Task: Traverse Each Recursively + +Use method +{Node.each_recursive}[../../../../REXML/Node.html#method-i-each_recursive] +to traverse a tree of nodes recursively: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.each_recursive {|node| p node } + +Output: + + ... + ... + + ... + + +=== Recursive Search + +==== Task: Traverse Each Recursively + +Use method +{Node.find_first_recursive}[../../../../REXML/Node.html#method-i-find_first_recursive] +to search a tree of nodes recursively: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.find_first_recursive {|node| node.name == 'c' } # => + +=== Representation + +==== Task: Represent a String + +Use method {Node.to_s}[../../../../REXML/Node.html#method-i-to_s] +to represent the node as a string: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.to_s # => "" + +=== Parent? + +==== Task: Determine Whether the Node is a Parent + +Use method {Node.parent?}[../../../../REXML/Node.html#method-i-parent-3F] +to determine whether the node is a parent; +class Text derives from Node: + + d = REXML::Document.new('textmore') + t = d.root[1] # => "text" + t.parent? # => false + +Class Parent also derives from Node, but overrides this method: + + p = REXML::Parent.new + p.parent? # => true diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/parent.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/parent.rdoc new file mode 100644 index 0000000..54f1dbe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/rdoc/parent.rdoc @@ -0,0 +1,267 @@ +== Class Parent + +Class Parent has methods from its superclasses and included modules; +see: + +- {Tasks for Child}[child_rdoc.html]. +- {Tasks for Node}[node_rdoc.html]. +- {Module Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html]. + +:include: ../tocs/parent_toc.rdoc + +=== Queries + +==== Task: Get the Count of Children + +Use method {Parent#size}[../../../../REXML/Parent.html#method-i-size] +(or its alias +length+) to get the count of the parent's children: + + p = REXML::Parent.new + p.size # => 0 + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.size # => 3 + +==== Task: Get the Child at a Given Index + +Use method {Parent#[]}[../../../../REXML/Parent.html#method-i-5B-5D] +to get the child at a given index: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root[1] # => + d.root[-1] # => + d.root[50] # => nil + +==== Task: Get the Index of a Given Child + +Use method {Parent#index}[../../../../REXML/Parent.html#method-i-index] +to get the index (0-based offset) of a child: + + d = REXML::Document.new('') + root = d.root + e0 = REXML::Element.new('foo') + e1 = REXML::Element.new('bar') + root.add(e0) # => + root.add(e1) # => + root.add(e0) # => + root.add(e1) # => + root.index(e0) # => 0 + root.index(e1) # => 1 + +==== Task: Get the Children + +Use method {Parent#children}[../../../../REXML/Parent.html#method-i-children] +(or its alias +to_a+) to get the parent's children: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + +==== Task: Determine Whether the Node is a Parent + +Use method {Parent#parent?}[../../../../REXML/Parent.html#method-i-parent-3F] +to determine whether the node is a parent; +class Text derives from Node: + + d = REXML::Document.new('textmore') + t = d.root[1] # => "text" + t.parent? # => false + +Class Parent also derives from Node, but overrides this method: + + p = REXML::Parent.new + p.parent? # => true + +=== Additions + +==== Task: Add a Child at the Beginning + +Use method {Parent#unshift}[../../../../REXML/Parent.html#method-i-unshift] +to add a child as at the beginning of the children: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + d.root.unshift REXML::Element.new('d') + d.root.children # => [, , , ] + +==== Task: Add a Child at the End + +Use method {Parent#<<}[../../../../REXML/Parent.html#method-i-3C-3C] +(or an alias +push+ or +add+) to add a child as at the end of the children: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + d.root << REXML::Element.new('d') + d.root.children # => [, , , ] + +==== Task: Replace a Child with Another Child + +Use method {Parent#replace}[../../../../REXML/Parent.html#method-i-replace] + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + b = d.root[1] # => + d.replace_child(b, REXML::Element.new('d')) + d.root.children # => [, ] + +==== Task: Replace Multiple Children with Another Child + +Use method {Parent#[]=}[../../../../REXML/Parent.html#method-i-parent-5B-5D-3D] +to replace multiple consecutive children with another child: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , , ] + d.root[1, 2] = REXML::Element.new('x') + d.root.children # => [, , ] + d.root[1, 5] = REXML::Element.new('x') + d.root.children # => [, ] # BUG? + +==== Task: Insert Child Before a Given Child + +Use method {Parent#insert_before}[../../../../REXML/Parent.html#method-i-insert_before] +to insert a child immediately before a given child: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + b = d.root[1] # => + x = REXML::Element.new('x') + d.root.insert_before(b, x) + d.root.children # => [, , , ] + +==== Task: Insert Child After a Given Child + +Use method {Parent#insert_after}[../../../../REXML/Parent.html#method-i-insert_after] +to insert a child immediately after a given child: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + b = d.root[1] # => + x = REXML::Element.new('x') + d.root.insert_after(b, x) + d.root.children # => [, , , ] + +=== Deletions + +==== Task: Remove a Given Child + +Use method {Parent#delete}[../../../../REXML/Parent.html#method-i-delete] +to remove all occurrences of a given child: + + d = REXML::Document.new('') + a = REXML::Element.new('a') + b = REXML::Element.new('b') + d.root.add(a) + d.root.add(b) + d.root.add(a) + d.root.add(b) + d.root.children # => [, , , ] + d.root.delete(b) + d.root.children # => [, ] + +==== Task: Remove the Child at a Specified Offset + +Use method {Parent#delete_at}[../../../../REXML/Parent.html#method-i-delete_at] +to remove the child at a specified offset: + + d = REXML::Document.new('') + a = REXML::Element.new('a') + b = REXML::Element.new('b') + d.root.add(a) + d.root.add(b) + d.root.add(a) + d.root.add(b) + d.root.children # => [, , , ] + d.root.delete_at(2) + d.root.children # => [, , ] + +==== Task: Remove Children That Meet Specified Criteria + +Use method {Parent#delete_if}[../../../../REXML/Parent.html#method-i-delete_if] +to remove children that meet criteria specified in the given block: + + d = REXML::Document.new('') + d.root.add(REXML::Element.new('x')) + d.root.add(REXML::Element.new('xx')) + d.root.add(REXML::Element.new('xxx')) + d.root.add(REXML::Element.new('xxxx')) + d.root.children # => [, , , ] + d.root.delete_if {|child| child.name.size.odd? } + d.root.children # => [, ] + +=== Iterations + +==== Task: Iterate Over Children + +Use method {Parent#each_child}[../../../../REXML/Parent.html#method-i-each_child] +(or its alias +each+) to iterate over all children: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + d.root.each_child {|child| p child } + +Output: + + + + + +==== Task: Iterate Over Child Indexes + +Use method {Parent#each_index}[../../../../REXML/Parent.html#method-i-each_index] +to iterate over all child indexes: + + xml_string = '' + d = REXML::Document.new(xml_string) + d.root.children # => [, , ] + d.root.each_index {|child| p child } + +Output: + + 0 + 1 + 2 + +=== Clones + +==== Task: Clone Deeply + +Use method {Parent#deep_clone}[../../../../REXML/Parent.html#method-i-deep_clone] +to clone deeply; that is, to clone every nested node that is a Parent object: + + xml_string = <<-EOT + + + + Everyday Italian + Giada De Laurentiis + 2005 + 30.00 + + + Harry Potter + J K. Rowling + 2005 + 29.99 + + + Learning XML + Erik T. Ray + 2003 + 39.95 + + + EOT + d = REXML::Document.new(xml_string) + root = d.root + shallow = root.clone + deep = root.deep_clone + shallow.to_s.size # => 12 + deep.to_s.size # => 590 diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/child_toc.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/child_toc.rdoc new file mode 100644 index 0000000..a2083a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/child_toc.rdoc @@ -0,0 +1,12 @@ +Tasks on this page: + +- {Relationships}[#label-Relationships] + - {Task: Set the Parent}[#label-Task-3A+Set+the+Parent] + - {Task: Insert Previous Sibling}[#label-Task-3A+Insert+Previous+Sibling] + - {Task: Insert Next Sibling}[#label-Task-3A+Insert+Next+Sibling] +- {Removal or Replacement}[#label-Removal+or+Replacement] + - {Task: Remove Child from Parent}[#label-Task-3A+Remove+Child+from+Parent] + - {Task: Replace Child}[#label-Task-3A+Replace+Child] +- {Document}[#label-Document] + - {Task: Get the Document}[#label-Task-3A+Get+the+Document] + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/document_toc.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/document_toc.rdoc new file mode 100644 index 0000000..5db055f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/document_toc.rdoc @@ -0,0 +1,30 @@ +Tasks on this page: + +- {New Document}[#label-New+Document] + - {Task: Create an Empty Document}[#label-Task-3A+Create+an+Empty+Document] + - {Task: Parse a String into a New Document}[#label-Task-3A+Parse+a+String+into+a+New+Document] + - {Task: Parse an IO Stream into a New Document}[#label-Task-3A+Parse+an+IO+Stream+into+a+New+Document] + - {Task: Create a Document from an Existing Document}[#label-Task-3A+Create+a+Document+from+an+Existing+Document] + - {Task: Clone a Document}[#label-Task-3A+Clone+a+Document] +- {Document Type}[#label-Document+Type] + - {Task: Get the Document Type}[#label-Task-3A+Get+the+Document+Type] + - {Task: Set the Document Type}[#label-Task-3A+Set+the+Document+Type] +- {XML Declaration}[#label-XML+Declaration] + - {Task: Get the XML Declaration}[#label-Task-3A+Get+the+XML+Declaration] + - {Task: Set the XML Declaration}[#label-Task-3A+Set+the+XML+Declaration] +- {Children}[#label-Children] + - {Task: Add an Element Child}[#label-Task-3A+Add+an+Element+Child] + - {Task: Add a Non-Element Child}[#label-Task-3A+Add+a+Non-Element+Child] +- {Writing}[#label-Writing] + - {Task: Write to $stdout}[#label-Task-3A+Write+to+-24stdout] + - {Task: Write to IO Stream}[#label-Task-3A+Write+to+IO+Stream] + - {Task: Write with No Indentation}[#label-Task-3A+Write+with+No+Indentation] + - {Task: Write with Specified Indentation}[#label-Task-3A+Write+with+Specified+Indentation] +- {Querying}[#label-Querying] + - {Task: Get the Document}[#label-Task-3A+Get+the+Document] + - {Task: Get the Encoding}[#label-Task-3A+Get+the+Encoding] + - {Task: Get the Node Type}[#label-Task-3A+Get+the+Node+Type] + - {Task: Get the Root Element}[#label-Task-3A+Get+the+Root+Element] + - {Task: Determine Whether Stand-Alone}[#label-Task-3A+Determine+Whether+Stand-Alone] + - {Task: Get the Version}[#label-Task-3A+Get+the+Version] + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/element_toc.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/element_toc.rdoc new file mode 100644 index 0000000..60a504a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/element_toc.rdoc @@ -0,0 +1,55 @@ +Tasks on this page: + +- {New Element}[#label-New+Element] + - {Task: Create a Default Element}[#label-Task-3A+Create+a+Default+Element] + - {Task: Create a Named Element}[#label-Task-3A+Create+a+Named+Element] + - {Task: Create an Element with Name and Parent}[#label-Task-3A+Create+an+Element+with+Name+and+Parent] + - {Task: Create an Element with Name, Parent, and Context}[#label-Task-3A+Create+an+Element+with+Name-2C+Parent-2C+and+Context] + - {Task: Create a Shallow Clone}[#label-Task-3A+Create+a+Shallow+Clone] +- {Attributes}[#label-Attributes] + - {Task: Create and Add an Attribute}[#label-Task-3A+Create+and+Add+an+Attribute] + - {Task: Add an Existing Attribute}[#label-Task-3A+Add+an+Existing+Attribute] + - {Task: Add Multiple Attributes from a Hash}[#label-Task-3A+Add+Multiple+Attributes+from+a+Hash] + - {Task: Add Multiple Attributes from an Array}[#label-Task-3A+Add+Multiple+Attributes+from+an+Array] + - {Task: Retrieve the Value for an Attribute Name}[#label-Task-3A+Retrieve+the+Value+for+an+Attribute+Name] + - {Task: Retrieve the Attribute Value for a Name and Namespace}[#label-Task-3A+Retrieve+the+Attribute+Value+for+a+Name+and+Namespace] + - {Task: Delete an Attribute}[#label-Task-3A+Delete+an+Attribute] + - {Task: Determine Whether the Element Has Attributes}[#label-Task-3A+Determine+Whether+the+Element+Has+Attributes] +- {Children}[#label-Children] + - {Task: Create and Add an Element}[#label-Task-3A+Create+and+Add+an+Element] + - {Task: Add an Existing Element}[#label-Task-3A+Add+an+Existing+Element] + - {Task: Create and Add an Element with Attributes}[#label-Task-3A+Create+and+Add+an+Element+with+Attributes] + - {Task: Add an Existing Element with Added Attributes}[#label-Task-3A+Add+an+Existing+Element+with+Added+Attributes] + - {Task: Delete a Specified Element}[#label-Task-3A+Delete+a+Specified+Element] + - {Task: Delete an Element by Index}[#label-Task-3A+Delete+an+Element+by+Index] + - {Task: Delete an Element by XPath}[#label-Task-3A+Delete+an+Element+by+XPath] + - {Task: Determine Whether Element Children}[#label-Task-3A+Determine+Whether+Element+Children] + - {Task: Get Element Descendants by XPath}[#label-Task-3A+Get+Element+Descendants+by+XPath] + - {Task: Get Next Element Sibling}[#label-Task-3A+Get+Next+Element+Sibling] + - {Task: Get Previous Element Sibling}[#label-Task-3A+Get+Previous+Element+Sibling] + - {Task: Add a Text Node}[#label-Task-3A+Add+a+Text+Node] + - {Task: Replace the First Text Node}[#label-Task-3A+Replace+the+First+Text+Node] + - {Task: Remove the First Text Node}[#label-Task-3A+Remove+the+First+Text+Node] + - {Task: Retrieve the First Text Node}[#label-Task-3A+Retrieve+the+First+Text+Node] + - {Task: Retrieve a Specific Text Node}[#label-Task-3A+Retrieve+a+Specific+Text+Node] + - {Task: Determine Whether the Element has Text Nodes}[#label-Task-3A+Determine+Whether+the+Element+has+Text+Nodes] + - {Task: Get the Child at a Given Index}[#label-Task-3A+Get+the+Child+at+a+Given+Index] + - {Task: Get All CDATA Children}[#label-Task-3A+Get+All+CDATA+Children] + - {Task: Get All Comment Children}[#label-Task-3A+Get+All+Comment+Children] + - {Task: Get All Processing Instruction Children}[#label-Task-3A+Get+All+Processing+Instruction+Children] + - {Task: Get All Text Children}[#label-Task-3A+Get+All+Text+Children] +- {Namespaces}[#label-Namespaces] + - {Task: Add a Namespace}[#label-Task-3A+Add+a+Namespace] + - {Task: Delete the Default Namespace}[#label-Task-3A+Delete+the+Default+Namespace] + - {Task: Delete a Specific Namespace}[#label-Task-3A+Delete+a+Specific+Namespace] + - {Task: Get a Namespace URI}[#label-Task-3A+Get+a+Namespace+URI] + - {Task: Retrieve Namespaces}[#label-Task-3A+Retrieve+Namespaces] + - {Task: Retrieve Namespace Prefixes}[#label-Task-3A+Retrieve+Namespace+Prefixes] +- {Iteration}[#label-Iteration] + - {Task: Iterate Over Elements}[#label-Task-3A+Iterate+Over+Elements] + - {Task: Iterate Over Elements Having a Specified Attribute}[#label-Task-3A+Iterate+Over+Elements+Having+a+Specified+Attribute] + - {Task: Iterate Over Elements Having a Specified Attribute and Value}[#label-Task-3A+Iterate+Over+Elements+Having+a+Specified+Attribute+and+Value] + - {Task: Iterate Over Elements Having Specified Text}[#label-Task-3A+Iterate+Over+Elements+Having+Specified+Text] +- {Context}[#label-Context] +- {Other Getters}[#label-Other+Getters] + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/master_toc.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/master_toc.rdoc new file mode 100644 index 0000000..0214f6b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/master_toc.rdoc @@ -0,0 +1,135 @@ +== Tasks + +=== {Child}[../../tasks/rdoc/child_rdoc.html] +- {Relationships}[../../tasks/rdoc/child_rdoc.html#label-Relationships] + - {Task: Set the Parent}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Set+the+Parent] + - {Task: Insert Previous Sibling}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Insert+Previous+Sibling] + - {Task: Insert Next Sibling}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Insert+Next+Sibling] +- {Removal or Replacement}[../../tasks/rdoc/child_rdoc.html#label-Removal+or+Replacement] + - {Task: Remove Child from Parent}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Remove+Child+from+Parent] + - {Task: Replace Child}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Replace+Child] +- {Document}[../../tasks/rdoc/child_rdoc.html#label-Document] + - {Task: Get the Document}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Get+the+Document] + +=== {Document}[../../tasks/rdoc/document_rdoc.html] +- {New Document}[../../tasks/rdoc/document_rdoc.html#label-New+Document] + - {Task: Create an Empty Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Create+an+Empty+Document] + - {Task: Parse a String into a New Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Parse+a+String+into+a+New+Document] + - {Task: Parse an IO Stream into a New Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Parse+an+IO+Stream+into+a+New+Document] + - {Task: Create a Document from an Existing Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Create+a+Document+from+an+Existing+Document] + - {Task: Clone a Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Clone+a+Document] +- {Document Type}[../../tasks/rdoc/document_rdoc.html#label-Document+Type] + - {Task: Get the Document Type}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Document+Type] + - {Task: Set the Document Type}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Set+the+Document+Type] +- {XML Declaration}[../../tasks/rdoc/document_rdoc.html#label-XML+Declaration] + - {Task: Get the XML Declaration}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+XML+Declaration] + - {Task: Set the XML Declaration}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Set+the+XML+Declaration] +- {Children}[../../tasks/rdoc/document_rdoc.html#label-Children] + - {Task: Add an Element Child}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Add+an+Element+Child] + - {Task: Add a Non-Element Child}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Add+a+Non-Element+Child] +- {Writing}[../../tasks/rdoc/document_rdoc.html#label-Writing] + - {Task: Write to $stdout}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+to+-24stdout] + - {Task: Write to IO Stream}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+to+IO+Stream] + - {Task: Write with No Indentation}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+with+No+Indentation] + - {Task: Write with Specified Indentation}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+with+Specified+Indentation] +- {Querying}[../../tasks/rdoc/document_rdoc.html#label-Querying] + - {Task: Get the Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Document] + - {Task: Get the Encoding}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Encoding] + - {Task: Get the Node Type}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Node+Type] + - {Task: Get the Root Element}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Root+Element] + - {Task: Determine Whether Stand-Alone}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Determine+Whether+Stand-Alone] + - {Task: Get the Version}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Version] + +=== {Element}[../../tasks/rdoc/element_rdoc.html] +- {New Element}[../../tasks/rdoc/element_rdoc.html#label-New+Element] + - {Task: Create a Default Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+a+Default+Element] + - {Task: Create a Named Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+a+Named+Element] + - {Task: Create an Element with Name and Parent}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+an+Element+with+Name+and+Parent] + - {Task: Create an Element with Name, Parent, and Context}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+an+Element+with+Name-2C+Parent-2C+and+Context] + - {Task: Create a Shallow Clone}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+a+Shallow+Clone] +- {Attributes}[../../tasks/rdoc/element_rdoc.html#label-Attributes] + - {Task: Create and Add an Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+and+Add+an+Attribute] + - {Task: Add an Existing Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+an+Existing+Attribute] + - {Task: Add Multiple Attributes from a Hash}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+Multiple+Attributes+from+a+Hash] + - {Task: Add Multiple Attributes from an Array}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+Multiple+Attributes+from+an+Array] + - {Task: Retrieve the Value for an Attribute Name}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+the+Value+for+an+Attribute+Name] + - {Task: Retrieve the Attribute Value for a Name and Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+the+Attribute+Value+for+a+Name+and+Namespace] + - {Task: Delete an Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+an+Attribute] + - {Task: Determine Whether the Element Has Attributes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Determine+Whether+the+Element+Has+Attributes] +- {Children}[../../tasks/rdoc/element_rdoc.html#label-Children] + - {Task: Create and Add an Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+and+Add+an+Element] + - {Task: Add an Existing Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+an+Existing+Element] + - {Task: Create and Add an Element with Attributes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+and+Add+an+Element+with+Attributes] + - {Task: Add an Existing Element with Added Attributes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+an+Existing+Element+with+Added+Attributes] + - {Task: Delete a Specified Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+a+Specified+Element] + - {Task: Delete an Element by Index}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+an+Element+by+Index] + - {Task: Delete an Element by XPath}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+an+Element+by+XPath] + - {Task: Determine Whether Element Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Determine+Whether+Element+Children] + - {Task: Get Element Descendants by XPath}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+Element+Descendants+by+XPath] + - {Task: Get Next Element Sibling}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+Next+Element+Sibling] + - {Task: Get Previous Element Sibling}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+Previous+Element+Sibling] + - {Task: Add a Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+a+Text+Node] + - {Task: Replace the First Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Replace+the+First+Text+Node] + - {Task: Remove the First Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Remove+the+First+Text+Node] + - {Task: Retrieve the First Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+the+First+Text+Node] + - {Task: Retrieve a Specific Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+a+Specific+Text+Node] + - {Task: Determine Whether the Element has Text Nodes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Determine+Whether+the+Element+has+Text+Nodes] + - {Task: Get the Child at a Given Index}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+the+Child+at+a+Given+Index] + - {Task: Get All CDATA Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+CDATA+Children] + - {Task: Get All Comment Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+Comment+Children] + - {Task: Get All Processing Instruction Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+Processing+Instruction+Children] + - {Task: Get All Text Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+Text+Children] +- {Namespaces}[../../tasks/rdoc/element_rdoc.html#label-Namespaces] + - {Task: Add a Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+a+Namespace] + - {Task: Delete the Default Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+the+Default+Namespace] + - {Task: Delete a Specific Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+a+Specific+Namespace] + - {Task: Get a Namespace URI}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+a+Namespace+URI] + - {Task: Retrieve Namespaces}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+Namespaces] + - {Task: Retrieve Namespace Prefixes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+Namespace+Prefixes] +- {Iteration}[../../tasks/rdoc/element_rdoc.html#label-Iteration] + - {Task: Iterate Over Elements}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements] + - {Task: Iterate Over Elements Having a Specified Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements+Having+a+Specified+Attribute] + - {Task: Iterate Over Elements Having a Specified Attribute and Value}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements+Having+a+Specified+Attribute+and+Value] + - {Task: Iterate Over Elements Having Specified Text}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements+Having+Specified+Text] +- {Context}[../../tasks/rdoc/element_rdoc.html#label-Context] +- {Other Getters}[../../tasks/rdoc/element_rdoc.html#label-Other+Getters] + +=== {Node}[../../tasks/rdoc/node_rdoc.html] +- {Siblings}[../../tasks/rdoc/node_rdoc.html#label-Siblings] + - {Task: Find Previous Sibling}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Find+Previous+Sibling] + - {Task: Find Next Sibling}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Find+Next+Sibling] +- {Position}[../../tasks/rdoc/node_rdoc.html#label-Position] + - {Task: Find Own Index Among Siblings}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Find+Own+Index+Among+Siblings] +- {Recursive Traversal}[../../tasks/rdoc/node_rdoc.html#label-Recursive+Traversal] + - {Task: Traverse Each Recursively}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Traverse+Each+Recursively] +- {Recursive Search}[../../tasks/rdoc/node_rdoc.html#label-Recursive+Search] + - {Task: Traverse Each Recursively}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Traverse+Each+Recursively] +- {Representation}[../../tasks/rdoc/node_rdoc.html#label-Representation] + - {Task: Represent a String}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Represent+a+String] +- {Parent?}[../../tasks/rdoc/node_rdoc.html#label-Parent-3F] + - {Task: Determine Whether the Node is a Parent}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Determine+Whether+the+Node+is+a+Parent] + +=== {Parent}[../../tasks/rdoc/parent_rdoc.html] +- {Queries}[../../tasks/rdoc/parent_rdoc.html#label-Queries] + - {Task: Get the Count of Children}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Count+of+Children] + - {Task: Get the Child at a Given Index}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Child+at+a+Given+Index] + - {Task: Get the Index of a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Index+of+a+Given+Child] + - {Task: Get the Children}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Children] + - {Task: Determine Whether the Node is a Parent}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Determine+Whether+the+Node+is+a+Parent] +- {Additions}[../../tasks/rdoc/parent_rdoc.html#label-Additions] + - {Task: Add a Child at the Beginning}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Add+a+Child+at+the+Beginning] + - {Task: Add a Child at the End}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Add+a+Child+at+the+End] + - {Task: Replace a Child with Another Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Replace+a+Child+with+Another+Child] + - {Task: Replace Multiple Children with Another Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Replace+Multiple+Children+with+Another+Child] + - {Task: Insert Child Before a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Insert+Child+Before+a+Given+Child] + - {Task: Insert Child After a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Insert+Child+After+a+Given+Child] +- {Deletions}[../../tasks/rdoc/parent_rdoc.html#label-Deletions] + - {Task: Remove a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Remove+a+Given+Child] + - {Task: Remove the Child at a Specified Offset}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Remove+the+Child+at+a+Specified+Offset] + - {Task: Remove Children That Meet Specified Criteria}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Remove+Children+That+Meet+Specified+Criteria] +- {Iterations}[../../tasks/rdoc/parent_rdoc.html#label-Iterations] + - {Task: Iterate Over Children}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Iterate+Over+Children] + - {Task: Iterate Over Child Indexes}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Iterate+Over+Child+Indexes] +- {Clones}[../../tasks/rdoc/parent_rdoc.html#label-Clones] + - {Task: Clone Deeply}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Clone+Deeply] + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/node_toc.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/node_toc.rdoc new file mode 100644 index 0000000..d9114fa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/node_toc.rdoc @@ -0,0 +1,16 @@ +Tasks on this page: + +- {Siblings}[#label-Siblings] + - {Task: Find Previous Sibling}[#label-Task-3A+Find+Previous+Sibling] + - {Task: Find Next Sibling}[#label-Task-3A+Find+Next+Sibling] +- {Position}[#label-Position] + - {Task: Find Own Index Among Siblings}[#label-Task-3A+Find+Own+Index+Among+Siblings] +- {Recursive Traversal}[#label-Recursive+Traversal] + - {Task: Traverse Each Recursively}[#label-Task-3A+Traverse+Each+Recursively] +- {Recursive Search}[#label-Recursive+Search] + - {Task: Traverse Each Recursively}[#label-Task-3A+Traverse+Each+Recursively] +- {Representation}[#label-Representation] + - {Task: Represent a String}[#label-Task-3A+Represent+a+String] +- {Parent?}[#label-Parent-3F] + - {Task: Determine Whether the Node is a Parent}[#label-Task-3A+Determine+Whether+the+Node+is+a+Parent] + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/parent_toc.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/parent_toc.rdoc new file mode 100644 index 0000000..68fc0b7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tasks/tocs/parent_toc.rdoc @@ -0,0 +1,25 @@ +Tasks on this page: + +- {Queries}[#label-Queries] + - {Task: Get the Count of Children}[#label-Task-3A+Get+the+Count+of+Children] + - {Task: Get the Child at a Given Index}[#label-Task-3A+Get+the+Child+at+a+Given+Index] + - {Task: Get the Index of a Given Child}[#label-Task-3A+Get+the+Index+of+a+Given+Child] + - {Task: Get the Children}[#label-Task-3A+Get+the+Children] + - {Task: Determine Whether the Node is a Parent}[#label-Task-3A+Determine+Whether+the+Node+is+a+Parent] +- {Additions}[#label-Additions] + - {Task: Add a Child at the Beginning}[#label-Task-3A+Add+a+Child+at+the+Beginning] + - {Task: Add a Child at the End}[#label-Task-3A+Add+a+Child+at+the+End] + - {Task: Replace a Child with Another Child}[#label-Task-3A+Replace+a+Child+with+Another+Child] + - {Task: Replace Multiple Children with Another Child}[#label-Task-3A+Replace+Multiple+Children+with+Another+Child] + - {Task: Insert Child Before a Given Child}[#label-Task-3A+Insert+Child+Before+a+Given+Child] + - {Task: Insert Child After a Given Child}[#label-Task-3A+Insert+Child+After+a+Given+Child] +- {Deletions}[#label-Deletions] + - {Task: Remove a Given Child}[#label-Task-3A+Remove+a+Given+Child] + - {Task: Remove the Child at a Specified Offset}[#label-Task-3A+Remove+the+Child+at+a+Specified+Offset] + - {Task: Remove Children That Meet Specified Criteria}[#label-Task-3A+Remove+Children+That+Meet+Specified+Criteria] +- {Iterations}[#label-Iterations] + - {Task: Iterate Over Children}[#label-Task-3A+Iterate+Over+Children] + - {Task: Iterate Over Child Indexes}[#label-Task-3A+Iterate+Over+Child+Indexes] +- {Clones}[#label-Clones] + - {Task: Clone Deeply}[#label-Task-3A+Clone+Deeply] + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tutorial.rdoc b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tutorial.rdoc new file mode 100644 index 0000000..c85a70d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/doc/rexml/tutorial.rdoc @@ -0,0 +1,1358 @@ += \REXML Tutorial + +== Why \REXML? + +- Ruby's \REXML library is part of the Ruby distribution, + so using it requires no gem installations. +- \REXML is fully maintained. +- \REXML is mature, having been in use for long years. + +== To Include, or Not to Include? + +REXML is a module. +To use it, you must require it: + + require 'rexml' # => true + +If you do not also include it, you must fully qualify references to REXML: + + REXML::Document # => REXML::Document + +If you also include the module, you may optionally omit REXML::: + + include REXML + Document # => REXML::Document + REXML::Document # => REXML::Document + +== Preliminaries + +All examples here assume that the following code has been executed: + + require 'rexml' + include REXML + +The source XML for many examples here is from file +{books.xml}[https://www.w3schools.com/xml/books.xml] at w3schools.com. +You may find it convenient to open that page in a new tab +(Ctrl-click in some browsers). + +Note that your browser may display the XML with modified whitespace +and without the XML declaration, which in this case is: + + + +For convenience, we capture the XML into a string variable: + + require 'open-uri' + source_string = URI.open('https://www.w3schools.com/xml/books.xml').read + +And into a file: + + File.write('source_file.xml', source_string) + +Throughout these examples, variable +doc+ will hold only the document +derived from these sources: + + doc = Document.new(source_string) + +== Parsing \XML \Source + +=== Parsing a Document + +Use method REXML::Document::new to parse XML source. + +The source may be a string: + + doc = Document.new(source_string) + +Or an \IO stream: + + doc = File.open('source_file.xml', 'r') do |io| + Document.new(io) + end + +Method URI.open returns a StringIO object, +so the source can be from a web page: + + require 'open-uri' + io = URI.open("https://www.w3schools.com/xml/books.xml") + io.class # => StringIO + doc = Document.new(io) + +For any of these sources, the returned object is an REXML::Document: + + doc # => ... + doc.class # => REXML::Document + +Note: 'UNDEFINED' is the "name" displayed for a document, +even though doc.name returns an empty string "". + +A parsed document may produce \REXML objects of many classes, +but the two that are likely to be of greatest interest are +REXML::Document and REXML::Element. +These two classes are covered in great detail in this tutorial. + +=== Context (Parsing Options) + +The context for parsing a document is a hash that influences +the way the XML is read and stored. + +The context entries are: + +- +:respect_whitespace+: controls treatment of whitespace. +- +:compress_whitespace+: determines whether whitespace is compressed. +- +:ignore_whitespace_nodes+: determines whether whitespace-only nodes are to be ignored. +- +:raw+: controls treatment of special characters and entities. + +See {Element Context}[../context_rdoc.html]. + +== Exploring the Document + +An REXML::Document object represents an XML document. + +The object inherits from its ancestor classes: + +- REXML::Child (includes module REXML::Node) + - REXML::Parent (includes module {Enumerable}[rdoc-ref:Enumerable]). + - REXML::Element (includes module REXML::Namespace). + - REXML::Document + +This section covers only those properties and methods that are unique to a document +(that is, not inherited or included). + +=== Document Properties + +A document has several properties (other than its children); + +- Document type. +- Node type. +- Name. +- Document. +- XPath + +[Document Type] + + A document may have a document type: + + my_xml = '' + my_doc = Document.new(my_xml) + doc_type = my_doc.doctype + doc_type.class # => REXML::DocType + doc_type.to_s # => "" + +[Node Type] + + A document also has a node type (always +:document+): + + doc.node_type # => :document + +[Name] + + A document has a name (always an empty string): + + doc.name # => "" + +[Document] + + \Method REXML::Document#document returns +self+: + + doc.document == doc # => true + + An object of a different class (\REXML::Element or \REXML::Child) + may have a document, which is the document to which the object belongs; + if so, that document will be an \REXML::Document object. + + doc.root.document.class # => REXML::Document + +[XPath] + + \method REXML::Element#xpath returns the string xpath to the element, + relative to its most distant ancestor: + + doc.root.class # => REXML::Element + doc.root.xpath # => "/bookstore" + doc.root.texts.first # => "\n\n" + doc.root.texts.first.xpath # => "/bookstore/text()" + + If there is no ancestor, returns the expanded name of the element: + + Element.new('foo').xpath # => "foo" + +=== Document Children + +A document may have children of these types: + +- XML declaration. +- Root element. +- Text. +- Processing instructions. +- Comments. +- CDATA. + +[XML Declaration] + + A document may an XML declaration, which is stored as an REXML::XMLDecl object: + + doc.xml_decl # => + doc.xml_decl.class # => REXML::XMLDecl + + Document.new('').xml_decl # => + + my_xml = '"' + my_doc = Document.new(my_xml) + xml_decl = my_doc.xml_decl + xml_decl.to_s # => "" + + The version, encoding, and stand-alone values may be retrieved separately: + + my_doc.version # => "1.0" + my_doc.encoding # => "UTF-8" + my_doc.stand_alone? # => "yes" + +[Root Element] + + A document may have a single element child, called the _root_ _element_, + which is stored as an REXML::Element object; + it may be retrieved with method +root+: + + doc.root # => ... + doc.root.class # => REXML::Element + + Document.new('').root # => nil + +[Text] + + A document may have text passages, each of which is stored + as an REXML::Text object: + + doc.texts.each {|t| p [t.class, t] } + + Output: + + [REXML::Text, "\n"] + +[Processing Instructions] + + A document may have processing instructions, which are stored + as REXML::Instruction objects: + + + + Output: + + [REXML::Instruction, ] + [REXML::Instruction, ] + +[Comments] + + A document may have comments, which are stored + as REXML::Comment objects: + + my_xml = <<-EOT + + + EOT + my_doc = Document.new(my_xml) + my_doc.comments.each {|c| p [c.class, c] } + + Output: + + [REXML::Comment, # ... , @string="foo">] + [REXML::Comment, # ... , @string="bar">] + +[CDATA] + + A document may have CDATA entries, which are stored + as REXML::CData objects: + + my_xml = <<-EOT + + + EOT + my_doc = Document.new(my_xml) + my_doc.cdatas.each {|cd| p [cd.class, cd] } + + Output: + + [REXML::CData, "foo"] + [REXML::CData, "bar"] + +The payload of a document is a tree of nodes, descending from the root element: + + doc.root.children.each do |child| + p [child, child.class] + end + +Output: + + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + +== Exploring an Element + +An REXML::Element object represents an XML element. + +The object inherits from its ancestor classes: + +- REXML::Child (includes module REXML::Node) + - REXML::Parent (includes module {Enumerable}[rdoc-ref:Enumerable]). + - REXML::Element (includes module REXML::Namespace). + +This section covers methods: + +- Defined in REXML::Element itself. +- Inherited from REXML::Parent and REXML::Child. +- Included from REXML::Node. + +=== Inside the Element + +[Brief String Representation] + + Use method REXML::Element#inspect to retrieve a brief string representation. + + doc.root.inspect # => " ... " + + The ellipsis (...) indicates that the element has children. + When there are no children, the ellipsis is omitted: + + Element.new('foo').inspect # => "" + + If the element has attributes, those are also included: + + doc.root.elements.first.inspect # => " ... " + +[Extended String Representation] + + Use inherited method REXML::Child.bytes to retrieve an extended + string representation. + + doc.root.bytes # => "\n\n\n Everyday Italian\n Giada De Laurentiis\n 2005\n 30.00\n\n\n\n Harry Potter\n J K. Rowling\n 2005\n 29.99\n\n\n\n XQuery Kick Start\n James McGovern\n Per Bothner\n Kurt Cagle\n James Linn\n Vaidyanathan Nagarajan\n 2003\n 49.99\n\n\n\n Learning XML\n Erik T. Ray\n 2003\n 39.95\n\n\n" + +[Node Type] + + Use method REXML::Element#node_type to retrieve the node type (always +:element+): + + doc.root.node_type # => :element + +[Raw Mode] + + Use method REXML::Element#raw to retrieve whether (+true+ or +nil+) + raw mode is set. + + doc.root.raw # => nil + +[Context] + + Use method REXML::Element#context to retrieve the context hash + (see {Element Context}[../context_rdoc.html]): + + doc.root.context # => {} + +=== Relationships + +An element may have: + +- Ancestors. +- Siblings. +- Children. + +==== Ancestors + +[Containing Document] + + Use method REXML::Element#document to retrieve the containing document, if any: + + ele = doc.root.elements.first # => ... + ele.document # => ... + ele = Element.new('foo') # => + ele.document # => nil + +[Root Element] + + Use method REXML::Element#root to retrieve the root element: + + ele = doc.root.elements.first # => ... + ele.root # => ... + ele = Element.new('foo') # => + ele.root # => + +[Root Node] + + Use method REXML::Element#root_node to retrieve the most distant ancestor, + which is the containing document, if any, otherwise the root element: + + ele = doc.root.elements.first # => ... + ele.root_node # => ... + ele = Element.new('foo') # => + ele.root_node # => + +[Parent] + + Use inherited method REXML::Child#parent to retrieve the parent + + ele = doc.root # => ... + ele.parent # => ... + ele = doc.root.elements.first # => ... + ele.parent # => ... + + Use included method REXML::Node#index_in_parent to retrieve the index + of the element among all of its parents children (not just the element children). + Note that while the index for doc.root.elements[n] is 1-based, + the returned index is 0-based. + + doc.root.children # => + # ["\n\n", + # ... , + # "\n\n", + # ... , + # "\n\n", + # ... , + # "\n\n", + # ... , + # "\n\n"] + ele = doc.root.elements[1] # => ... + ele.index_in_parent # => 2 + ele = doc.root.elements[2] # => ... + ele.index_in_parent# => 4 + +==== Siblings + +[Next Element] + + Use method REXML::Element#next_element to retrieve the first following + sibling that is itself an element (+nil+ if there is none): + + ele = doc.root.elements[1] + while ele do + p [ele.class, ele] + ele = ele.next_element + end + p ele + + Output: + + [REXML::Element, ... ] + [REXML::Element, ... ] + [REXML::Element, ... ] + [REXML::Element, ... ] + +[Previous Element] + + Use method REXML::Element#previous_element to retrieve the first preceding + sibling that is itself an element (+nil+ if there is none): + + ele = doc.root.elements[4] + while ele do + p [ele.class, ele] + ele = ele.previous_element + end + p ele + + Output: + + [REXML::Element, ... ] + [REXML::Element, ... ] + [REXML::Element, ... ] + [REXML::Element, ... ] + +[Next Node] + + Use included method REXML::Node.next_sibling_node + (or its alias next_sibling) to retrieve the first following node + regardless of its class: + + node = doc.root.children[0] + while node do + p [node.class, node] + node = node.next_sibling + end + p node + + Output: + + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + +[Previous Node] + + Use included method REXML::Node.previous_sibling_node + (or its alias previous_sibling) to retrieve the first preceding node + regardless of its class: + + node = doc.root.children[-1] + while node do + p [node.class, node] + node = node.previous_sibling + end + p node + + Output: + + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + +==== Children + +[Child Count] + + Use inherited method REXML::Parent.size to retrieve the count + of nodes (of all types) in the element: + + doc.root.size # => 9 + +[Child Nodes] + + Use inherited method REXML::Parent.children to retrieve an array + of the child nodes (of all types): + + doc.root.children # => + # ["\n\n", + # ... , + # "\n\n", + # ... , + # "\n\n", + # ... , + # "\n\n", + # ... , + # "\n\n"] + +[Child at Index] + + Use method REXML::Element#[] to retrieve the child at a given numerical index, + or +nil+ if there is no such child: + + doc.root[0] # => "\n\n" + doc.root[1] # => ... + doc.root[7] # => ... + doc.root[8] # => "\n\n" + + doc.root[-1] # => "\n\n" + doc.root[-2] # => ... + + doc.root[50] # => nil + +[Index of Child] + + Use method REXML::Parent#index to retrieve the zero-based child index + of the given object, or #size - 1 if there is no such child: + + ele = doc.root # => ... + ele.index(ele[0]) # => 0 + ele.index(ele[1]) # => 1 + ele.index(ele[7]) # => 7 + ele.index(ele[8]) # => 8 + + ele.index(ele[-1]) # => 8 + ele.index(ele[-2]) # => 7 + + ele.index(ele[50]) # => 8 + +[Element Children] + + Use method REXML::Element#has_elements? to retrieve whether the element + has element children: + + doc.root.has_elements? # => true + REXML::Element.new('foo').has_elements? # => false + + Use method REXML::Element#elements to retrieve the REXML::Elements object + containing the element children: + + eles = doc.root.elements + eles # => # ... > + eles.size # => 4 + eles.each {|e| p [e.class], e } + + Output: + + [ ... , + ... , + ... , + ... + ] + +Note that while in this example, all the element children of the root element are +elements of the same name, 'book', that is not true of all documents; +a root element (or any other element) may have any mixture of child elements. + +[CDATA Children] + + Use method REXML::Element#cdatas to retrieve a frozen array of CDATA children: + + my_xml = <<-EOT + + + + + EOT + my_doc = REXML::Document.new(my_xml) + cdatas my_doc.root.cdatas + cdatas.frozen? # => true + cdatas.map {|cd| cd.class } # => [REXML::CData, REXML::CData] + +[Comment Children] + + Use method REXML::Element#comments to retrieve a frozen array of comment children: + + my_xml = <<-EOT + + + + + EOT + my_doc = REXML::Document.new(my_xml) + comments = my_doc.root.comments + comments.frozen? # => true + comments.map {|c| c.class } # => [REXML::Comment, REXML::Comment] + comments.map {|c| c.to_s } # => ["foo", "bar"] + +[Processing Instruction Children] + + Use method REXML::Element#instructions to retrieve a frozen array + of processing instruction children: + + my_xml = <<-EOT + + + + + EOT + my_doc = REXML::Document.new(my_xml) + instrs = my_doc.root.instructions + instrs.frozen? # => true + instrs.map {|i| i.class } # => [REXML::Instruction, REXML::Instruction] + instrs.map {|i| i.to_s } # => ["", ""] + +[Text Children] + + Use method REXML::Element#has_text? to retrieve whether the element + has text children: + + doc.root.has_text? # => true + REXML::Element.new('foo').has_text? # => false + + Use method REXML::Element#texts to retrieve a frozen array of text children: + + my_xml = 'textmore' + my_doc = REXML::Document.new(my_xml) + texts = my_doc.root.texts + texts.frozen? # => true + texts.map {|t| t.class } # => [REXML::Text, REXML::Text] + texts.map {|t| t.to_s } # => ["text", "more"] + +[Parenthood] + + Use inherited method REXML::Parent.parent? to retrieve whether the element is a parent; + always returns +true+; only REXML::Child#parent returns +false+. + + doc.root.parent? # => true + +=== Element Attributes + +Use method REXML::Element#has_attributes? to return whether the element +has attributes: + + ele = doc.root # => ... + ele.has_attributes? # => false + ele = ele.elements.first # => ... + ele.has_attributes? # => true + +Use method REXML::Element#attributes to return the hash +containing the attributes for the element. +Each hash key is a string attribute name; +each hash value is an REXML::Attribute object. + + ele = doc.root # => ... + attrs = ele.attributes # => {} + + ele = ele.elements.first # => ... + attrs = ele.attributes # => {"category"=>category='cooking'} + attrs.size # => 1 + attr_name = attrs.keys.first # => "category" + attr_name.class # => String + attr_value = attrs.values.first # => category='cooking' + attr_value.class # => REXML::Attribute + +Use method REXML::Element#[] to retrieve the string value for a given attribute, +which may be given as either a string or a symbol: + + ele = doc.root.elements.first # => ... + attr_value = ele['category'] # => "cooking" + attr_value.class # => String + ele['nosuch'] # => nil + +Use method REXML::Element#attribute to retrieve the value of a named attribute: + + my_xml = "" + my_doc = REXML::Document.new(my_xml) + my_doc.root.attribute("x") # => x='x' + my_doc.root.attribute("x", "a") # => a:x='a:x' + +== Whitespace + +Use method REXML::Element#ignore_whitespace_nodes to determine whether +whitespace nodes were ignored when the XML was parsed; +returns +true+ if so, +nil+ otherwise. + +Use method REXML::Element#whitespace to determine whether whitespace +is respected for the element; returns +true+ if so, +false+ otherwise. + +== Namespaces + +Use method REXML::Element#namespace to retrieve the string namespace URI +for the element, which may derive from one of its ancestors: + + xml_string = <<-EOT + + + + + + + EOT + d = Document.new(xml_string) + b = d.elements['//b'] + b.namespace # => "1" + b.namespace('y') # => "2" + b.namespace('nosuch') # => nil + +Use method REXML::Element#namespaces to retrieve a hash of all defined namespaces +in the element and its ancestors: + + xml_string = <<-EOT + + + + + + + EOT + d = Document.new(xml_string) + d.elements['//a'].namespaces # => {"x"=>"1", "y"=>"2"} + d.elements['//b'].namespaces # => {"x"=>"1", "y"=>"2"} + d.elements['//c'].namespaces # => {"x"=>"1", "y"=>"2", "z"=>"3"} + +Use method REXML::Element#prefixes to retrieve an array of the string prefixes (names) +of all defined namespaces in the element and its ancestors: + + xml_string = <<-EOT + + + + + + + EOT + d = Document.new(xml_string, {compress_whitespace: :all}) + d.elements['//a'].prefixes # => ["x", "y"] + d.elements['//b'].prefixes # => ["x", "y"] + d.elements['//c'].prefixes # => ["x", "y", "z"] + +== Traversing + +You can use certain methods to traverse children of the element. +Each child that meets given criteria is yielded to the given block. + +[Traverse All Children] + + Use inherited method REXML::Parent#each (or its alias #each_child) to traverse + all children of the element: + + doc.root.each {|child| p [child.class, child] } + + Output: + + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + [REXML::Element, ... ] + [REXML::Text, "\n\n"] + +[Traverse Element Children] + + Use method REXML::Element#each_element to traverse only the element children + of the element: + + doc.root.each_element {|e| p [e.class, e] } + + Output: + + [REXML::Element, ... ] + [REXML::Element, ... ] + [REXML::Element, ... ] + [REXML::Element, ... ] + +[Traverse Element Children with Attribute] + + Use method REXML::Element#each_element_with_attribute with the single argument + +attr_name+ to traverse each element child that has the given attribute: + + my_doc = Document.new '' + my_doc.root.each_element_with_attribute('id') {|e| p [e.class, e] } + + Output: + + [REXML::Element, ] + [REXML::Element, ] + [REXML::Element, ] + + Use the same method with a second argument +value+ to traverse + each element child element that has the given attribute and value: + + my_doc.root.each_element_with_attribute('id', '1') {|e| p [e.class, e] } + + Output: + + [REXML::Element, ] + [REXML::Element, ] + + Use the same method with a third argument +max+ to traverse + no more than the given number of element children: + + my_doc.root.each_element_with_attribute('id', '1', 1) {|e| p [e.class, e] } + + Output: + + [REXML::Element, ] + + Use the same method with a fourth argument +xpath+ to traverse + only those element children that match the given xpath: + + my_doc.root.each_element_with_attribute('id', '1', 2, '//d') {|e| p [e.class, e] } + + Output: + + [REXML::Element, ] + +[Traverse Element Children with Text] + + Use method REXML::Element#each_element_with_text with no arguments + to traverse those element children that have text: + + my_doc = Document.new 'bbd' + my_doc.root.each_element_with_text {|e| p [e.class, e] } + + Output: + + [REXML::Element, ... ] + [REXML::Element, ... ] + [REXML::Element, ... ] + + Use the same method with the single argument +text+ to traverse + those element children that have exactly that text: + + my_doc.root.each_element_with_text('b') {|e| p [e.class, e] } + + Output: + + [REXML::Element, ... ] + [REXML::Element, ... ] + + Use the same method with additional second argument +max+ to traverse + no more than the given number of element children: + + my_doc.root.each_element_with_text('b', 1) {|e| p [e.class, e] } + + Output: + + [REXML::Element, ... ] + + Use the same method with additional third argument +xpath+ to traverse + only those element children that also match the given xpath: + + my_doc.root.each_element_with_text('b', 2, '//c') {|e| p [e.class, e] } + + Output: + + [REXML::Element, ... ] + +[Traverse Element Children's Indexes] + + Use inherited method REXML::Parent#each_index to traverse all children's indexes + (not just those of element children): + + doc.root.each_index {|i| print i } + + Output: + + 012345678 + +[Traverse Children Recursively] + + Use included method REXML::Node#each_recursive to traverse all children recursively: + + doc.root.each_recursive {|child| p [child.class, child] } + + Output: + + [REXML::Element, ... ] + [REXML::Element, ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <year> ... </>] + [REXML::Element, <price> ... </>] + [REXML::Element, <book category='children'> ... </>] + [REXML::Element, <title lang='en'> ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <year> ... </>] + [REXML::Element, <price> ... </>] + [REXML::Element, <book category='web'> ... </>] + [REXML::Element, <title lang='en'> ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <year> ... </>] + [REXML::Element, <price> ... </>] + [REXML::Element, <book category='web' cover='paperback'> ... </>] + [REXML::Element, <title lang='en'> ... </>] + [REXML::Element, <author> ... </>] + [REXML::Element, <year> ... </>] + [REXML::Element, <price> ... </>] + +== Searching + +You can use certain methods to search among the descendants of an element. + +Use method REXML::Element#get_elements to retrieve all element children of the element +that match the given +xpath+: + + xml_string = <<-EOT + <root> + <a level='1'> + <a level='2'/> + </a> + </root> + EOT + d = Document.new(xml_string) + d.root.get_elements('//a') # => [<a level='1'> ... </>, <a level='2'/>] + +Use method REXML::Element#get_text with no argument to retrieve the first text node +in the first child: + + my_doc = Document.new "<p>some text <b>this is bold!</b> more text</p>" + text_node = my_doc.root.get_text + text_node.class # => REXML::Text + text_node.to_s # => "some text " + +Use the same method with argument +xpath+ to retrieve the first text node +in the first child that matches the xpath: + + my_doc.root.get_text(1) # => "this is bold!" + +Use method REXML::Element#text with no argument to retrieve the text +from the first text node in the first child: + + my_doc = Document.new "<p>some text <b>this is bold!</b> more text</p>" + text_node = my_doc.root.text + text_node.class # => String + text_node # => "some text " + +Use the same method with argument +xpath+ to retrieve the text from the first text node +in the first child that matches the xpath: + + my_doc.root.text(1) # => "this is bold!" + +Use included method REXML::Node#find_first_recursive +to retrieve the first descendant element +for which the given block returns a truthy value, or +nil+ if none: + + doc.root.find_first_recursive do |ele| + ele.name == 'price' + end # => <price> ... </> + doc.root.find_first_recursive do |ele| + ele.name == 'nosuch' + end # => nil + +== Editing + +=== Editing a Document + +[Creating a Document] + + Create a new document with method REXML::Document::new: + + doc = Document.new(source_string) + empty_doc = REXML::Document.new + +[Adding to the Document] + + Add an XML declaration with method REXML::Document#add + and an argument of type REXML::XMLDecl: + + my_doc = Document.new + my_doc.xml_decl.to_s # => "" + my_doc.add(XMLDecl.new('2.0')) + my_doc.xml_decl.to_s # => "<?xml version='2.0'?>" + + Add a document type with method REXML::Document#add + and an argument of type REXML::DocType: + + my_doc = Document.new + my_doc.doctype.to_s # => "" + my_doc.add(DocType.new('foo')) + my_doc.doctype.to_s # => "<!DOCTYPE foo>" + + Add a node of any other REXML type with method REXML::Document#add and an argument + that is not of type REXML::XMLDecl or REXML::DocType: + + my_doc = Document.new + my_doc.add(Element.new('foo')) + my_doc.to_s # => "<foo/>" + + Add an existing element as the root element with method REXML::Document#add_element: + + ele = Element.new('foo') + my_doc = Document.new + my_doc.add_element(ele) + my_doc.root # => <foo/> + + Create and add an element as the root element with method REXML::Document#add_element: + + my_doc = Document.new + my_doc.add_element('foo') + my_doc.root # => <foo/> + +=== Editing an Element + +==== Creating an Element + +Create a new element with method REXML::Element::new: + + ele = Element.new('foo') # => <foo/> + +==== Setting Element Properties + +Set the context for an element with method REXML::Element#context= +(see {Element Context}[../context_rdoc.html]): + + ele.context # => nil + ele.context = {ignore_whitespace_nodes: :all} + ele.context # => {:ignore_whitespace_nodes=>:all} + +Set the parent for an element with inherited method REXML::Child#parent= + + ele.parent # => nil + ele.parent = Element.new('bar') + ele.parent # => <bar/> + +Set the text for an element with method REXML::Element#text=: + + ele.text # => nil + ele.text = 'bar' + ele.text # => "bar" + +==== Adding to an Element + +Add a node as the last child with inherited method REXML::Parent#add (or its alias #push): + + ele = Element.new('foo') # => <foo/> + ele.push(Text.new('bar')) + ele.push(Element.new('baz')) + ele.children # => ["bar", <baz/>] + +Add a node as the first child with inherited method REXML::Parent#unshift: + + ele = Element.new('foo') # => <foo/> + ele.unshift(Element.new('bar')) + ele.unshift(Text.new('baz')) + ele.children # => ["bar", <baz/>] + +Add an element as the last child with method REXML::Element#add_element: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_element(Element.new('baz')) + ele.children # => [<bar/>, <baz/>] + +Add a text node as the last child with method REXML::Element#add_text: + + ele = Element.new('foo') # => <foo/> + ele.add_text('bar') + ele.add_text(Text.new('baz')) + ele.children # => ["bar", "baz"] + +Insert a node before a given node with method REXML::Parent#insert_before: + + ele = Element.new('foo') # => <foo/> + ele.add_text('bar') + ele.add_text(Text.new('baz')) + ele.children # => ["bar", "baz"] + target = ele[1] # => "baz" + ele.insert_before(target, Text.new('bat')) + ele.children # => ["bar", "bat", "baz"] + +Insert a node after a given node with method REXML::Parent#insert_after: + + ele = Element.new('foo') # => <foo/> + ele.add_text('bar') + ele.add_text(Text.new('baz')) + ele.children # => ["bar", "baz"] + target = ele[0] # => "bar" + ele.insert_after(target, Text.new('bat')) + ele.children # => ["bar", "bat", "baz"] + +Add an attribute with method REXML::Element#add_attribute: + + ele = Element.new('foo') # => <foo/> + ele.add_attribute('bar', 'baz') + ele.add_attribute(Attribute.new('bat', 'bam')) + ele.attributes # => {"bar"=>bar='baz', "bat"=>bat='bam'} + +Add multiple attributes with method REXML::Element#add_attributes: + + ele = Element.new('foo') # => <foo/> + ele.add_attributes({'bar' => 'baz', 'bat' => 'bam'}) + ele.add_attributes([['ban', 'bap'], ['bah', 'bad']]) + ele.attributes # => {"bar"=>bar='baz', "bat"=>bat='bam', "ban"=>ban='bap', "bah"=>bah='bad'} + +Add a namespace with method REXML::Element#add_namespace: + + ele = Element.new('foo') # => <foo/> + ele.add_namespace('bar') + ele.add_namespace('baz', 'bat') + ele.namespaces # => {"xmlns"=>"bar", "baz"=>"bat"} + +==== Deleting from an Element + +Delete a specific child object with inherited method REXML::Parent#delete: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.children # => [<bar/>, "baz"] + target = ele[1] # => "baz" + ele.delete(target) # => "baz" + ele.children # => [<bar/>] + target = ele[0] # => <baz/> + ele.delete(target) # => <baz/> + ele.children # => [] + +Delete a child at a specific index with inherited method REXML::Parent#delete_at: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.children # => [<bar/>, "baz"] + ele.delete_at(1) + ele.children # => [<bar/>] + ele.delete_at(0) + ele.children # => [] + +Delete all children meeting a specified criterion with inherited method +REXML::Parent#delete_if: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.add_element('bat') + ele.add_text('bam') + ele.children # => [<bar/>, "baz", <bat/>, "bam"] + ele.delete_if {|child| child.instance_of?(Text) } + ele.children # => [<bar/>, <bat/>] + +Delete an element at a specific 1-based index with method REXML::Element#delete_element: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.add_element('bat') + ele.add_text('bam') + ele.children # => [<bar/>, "baz", <bat/>, "bam"] + ele.delete_element(2) # => <bat/> + ele.children # => [<bar/>, "baz", "bam"] + ele.delete_element(1) # => <bar/> + ele.children # => ["baz", "bam"] + +Delete a specific element with the same method: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.add_element('bat') + ele.add_text('bam') + ele.children # => [<bar/>, "baz", <bat/>, "bam"] + target = ele.elements[2] # => <bat/> + ele.delete_element(target) # => <bat/> + ele.children # => [<bar/>, "baz", "bam"] + +Delete an element matching an xpath using the same method: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.add_element('bat') + ele.add_text('bam') + ele.children # => [<bar/>, "baz", <bat/>, "bam"] + ele.delete_element('./bat') # => <bat/> + ele.children # => [<bar/>, "baz", "bam"] + ele.delete_element('./bar') # => <bar/> + ele.children # => ["baz", "bam"] + +Delete an attribute by name with method REXML::Element#delete_attribute: + + ele = Element.new('foo') # => <foo/> + ele.add_attributes({'bar' => 'baz', 'bam' => 'bat'}) + ele.attributes # => {"bar"=>bar='baz', "bam"=>bam='bat'} + ele.delete_attribute('bam') + ele.attributes # => {"bar"=>bar='baz'} + +Delete a namespace with method REXML::Element#delete_namespace: + + ele = Element.new('foo') # => <foo/> + ele.add_namespace('bar') + ele.add_namespace('baz', 'bat') + ele.namespaces # => {"xmlns"=>"bar", "baz"=>"bat"} + ele.delete_namespace('xmlns') + ele.namespaces # => {} # => {"baz"=>"bat"} + ele.delete_namespace('baz') + ele.namespaces # => {} # => {} + +Remove an element from its parent with inherited method REXML::Child#remove: + + ele = Element.new('foo') # => <foo/> + parent = Element.new('bar') # => <bar/> + parent.add_element(ele) # => <foo/> + parent.children.size # => 1 + ele.remove # => <foo/> + parent.children.size # => 0 + +==== Replacing Nodes + +Replace the node at a given 0-based index with inherited method REXML::Parent#[]=: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.add_element('bat') + ele.add_text('bam') + ele.children # => [<bar/>, "baz", <bat/>, "bam"] + ele[2] = Text.new('bad') # => "bad" + ele.children # => [<bar/>, "baz", "bad", "bam"] + +Replace a given node with another node with inherited method REXML::Parent#replace_child: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.add_element('bat') + ele.add_text('bam') + ele.children # => [<bar/>, "baz", <bat/>, "bam"] + target = ele[2] # => <bat/> + ele.replace_child(target, Text.new('bah')) + ele.children # => [<bar/>, "baz", "bah", "bam"] + +Replace +self+ with a given node with inherited method REXML::Child#replace_with: + + ele = Element.new('foo') # => <foo/> + ele.add_element('bar') + ele.add_text('baz') + ele.add_element('bat') + ele.add_text('bam') + ele.children # => [<bar/>, "baz", <bat/>, "bam"] + target = ele[2] # => <bat/> + target.replace_with(Text.new('bah')) + ele.children # => [<bar/>, "baz", "bah", "bam"] + +=== Cloning + +Create a shallow clone of an element with method REXML::Element#clone. +The clone contains the name and attributes, but not the parent or children: + + ele = Element.new('foo') + ele.add_attributes({'bar' => 0, 'baz' => 1}) + ele.clone # => <foo bar='0' baz='1'/> + +Create a shallow clone of a document with method REXML::Document#clone. +The XML declaration is copied; the document type and root element are not cloned: + + my_xml = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE foo><root/>' + my_doc = Document.new(my_xml) + clone_doc = my_doc.clone + + my_doc.xml_decl # => <?xml ... ?> + clone_doc.xml_decl # => <?xml ... ?> + + my_doc.doctype.to_s # => "<?xml version='1.0' encoding='UTF-8'?>" + clone_doc.doctype.to_s # => "" + + my_doc.root # => <root/> + clone_doc.root # => nil + +Create a deep clone of an element with inherited method REXML::Parent#deep_clone. +All nodes and attributes are copied: + + doc.to_s.size # => 825 + clone = doc.deep_clone + clone.to_s.size # => 825 + +== Writing the Document + +Write a document to an \IO stream (defaults to <tt>$stdout</tt>) +with method REXML::Document#write: + + doc.write + +Output: + + <?xml version='1.0' encoding='UTF-8'?> + <bookstore> + + <book category='cooking'> + <title lang='en'>Everyday Italian + Giada De Laurentiis + 2005 + 30.00 + + + + Harry Potter + J K. Rowling + 2005 + 29.99 + + + + XQuery Kick Start + James McGovern + Per Bothner + Kurt Cagle + James Linn + Vaidyanathan Nagarajan + 2003 + 49.99 + + + + Learning XML + Erik T. Ray + 2003 + 39.95 + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml.rb new file mode 100644 index 0000000..eee246e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "rexml/document" diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/attlistdecl.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/attlistdecl.rb new file mode 100644 index 0000000..44a91d6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/attlistdecl.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: false +#vim:ts=2 sw=2 noexpandtab: +require_relative 'child' +require_relative 'source' + +module REXML + # This class needs: + # * Documentation + # * Work! Not all types of attlists are intelligently parsed, so we just + # spew back out what we get in. This works, but it would be better if + # we formatted the output ourselves. + # + # AttlistDecls provide *just* enough support to allow namespace + # declarations. If you need some sort of generalized support, or have an + # interesting idea about how to map the hideous, terrible design of DTD + # AttlistDecls onto an intuitive Ruby interface, let me know. I'm desperate + # for anything to make DTDs more palateable. + class AttlistDecl < Child + include Enumerable + + # What is this? Got me. + attr_reader :element_name + + # Create an AttlistDecl, pulling the information from a Source. Notice + # that this isn't very convenient; to create an AttlistDecl, you basically + # have to format it yourself, and then have the initializer parse it. + # Sorry, but for the foreseeable future, DTD support in REXML is pretty + # weak on convenience. Have I mentioned how much I hate DTDs? + def initialize(source) + super() + if (source.kind_of? Array) + @element_name, @pairs, @contents = *source + end + end + + # Access the attlist attribute/value pairs. + # value = attlist_decl[ attribute_name ] + def [](key) + @pairs[key] + end + + # Whether an attlist declaration includes the given attribute definition + # if attlist_decl.include? "xmlns:foobar" + def include?(key) + @pairs.keys.include? key + end + + # Iterate over the key/value pairs: + # attlist_decl.each { |attribute_name, attribute_value| ... } + def each(&block) + @pairs.each(&block) + end + + # Write out exactly what we got in. + def write out, indent=-1 + out << @contents + end + + def node_type + :attlistdecl + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/attribute.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/attribute.rb new file mode 100644 index 0000000..11893a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/attribute.rb @@ -0,0 +1,210 @@ +# frozen_string_literal: true +require_relative "namespace" +require_relative 'text' + +module REXML + # Defines an Element Attribute; IE, a attribute=value pair, as in: + # . Attributes can be in their own + # namespaces. General users of REXML will not interact with the + # Attribute class much. + class Attribute + include Node + include Namespace + + # The element to which this attribute belongs + attr_reader :element + PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\2/um + + NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um + + # Constructor. + # FIXME: The parser doesn't catch illegal characters in attributes + # + # first:: + # Either: an Attribute, which this new attribute will become a + # clone of; or a String, which is the name of this attribute + # second:: + # If +first+ is an Attribute, then this may be an Element, or nil. + # If nil, then the Element parent of this attribute is the parent + # of the +first+ Attribute. If the first argument is a String, + # then this must also be a String, and is the content of the attribute. + # If this is the content, it must be fully normalized (contain no + # illegal characters). + # parent:: + # Ignored unless +first+ is a String; otherwise, may be the Element + # parent of this attribute, or nil. + # + # + # Attribute.new( attribute_to_clone ) + # Attribute.new( attribute_to_clone, parent_element ) + # Attribute.new( "attr", "attr_value" ) + # Attribute.new( "attr", "attr_value", parent_element ) + def initialize( first, second=nil, parent=nil ) + @normalized = @unnormalized = @element = nil + if first.kind_of? Attribute + self.name = first.expanded_name + @unnormalized = first.value + if second.kind_of? Element + @element = second + else + @element = first.element + end + elsif first.kind_of? String + @element = parent + self.name = first + @normalized = second.to_s + else + raise "illegal argument #{first.class.name} to Attribute constructor" + end + end + + # Returns the namespace of the attribute. + # + # e = Element.new( "elns:myelement" ) + # e.add_attribute( "nsa:a", "aval" ) + # e.add_attribute( "b", "bval" ) + # e.attributes.get_attribute( "a" ).prefix # -> "nsa" + # e.attributes.get_attribute( "b" ).prefix # -> "" + # a = Attribute.new( "x", "y" ) + # a.prefix # -> "" + def prefix + super + end + + # Returns the namespace URL, if defined, or nil otherwise + # + # e = Element.new("el") + # e.add_namespace("ns", "http://url") + # e.add_attribute("ns:a", "b") + # e.add_attribute("nsx:a", "c") + # e.attribute("ns:a").namespace # => "http://url" + # e.attribute("nsx:a").namespace # => nil + # + # This method always returns "" for no namespace attribute. Because + # the default namespace doesn't apply to attribute names. + # + # From https://www.w3.org/TR/xml-names/#uniqAttrs + # + # > the default namespace does not apply to attribute names + # + # e = REXML::Element.new("el") + # e.add_namespace("", "http://example.com/") + # e.namespace # => "http://example.com/" + # e.add_attribute("a", "b") + # e.attribute("a").namespace # => "" + def namespace arg=nil + arg = prefix if arg.nil? + if arg == "" + "" + else + @element.namespace(arg) + end + end + + # Returns true if other is an Attribute and has the same name and value, + # false otherwise. + def ==( other ) + other.kind_of?(Attribute) and other.name==name and other.value==value + end + + # Creates (and returns) a hash from both the name and value + def hash + name.hash + value.hash + end + + # Returns this attribute out as XML source, expanding the name + # + # a = Attribute.new( "x", "y" ) + # a.to_string # -> "x='y'" + # b = Attribute.new( "ns:x", "y" ) + # b.to_string # -> "ns:x='y'" + def to_string + value = to_s + if @element and @element.context and @element.context[:attribute_quote] == :quote + value = value.gsub('"', '"') if value.include?('"') + %Q^#@expanded_name="#{value}"^ + else + value = value.gsub("'", ''') if value.include?("'") + "#@expanded_name='#{value}'" + end + end + + def doctype + if @element + doc = @element.document + doc.doctype if doc + end + end + + # Returns the attribute value, with entities replaced + def to_s + return @normalized if @normalized + + @normalized = Text::normalize( @unnormalized, doctype ) + @normalized + end + + # Returns the UNNORMALIZED value of this attribute. That is, entities + # have been expanded to their values + def value + return @unnormalized if @unnormalized + @unnormalized = Text::unnormalize( @normalized, doctype ) + @unnormalized + end + + # The normalized value of this attribute. That is, the attribute with + # entities intact. + def normalized=(new_normalized) + @normalized = new_normalized + @unnormalized = nil + end + + # Returns a copy of this attribute + def clone + Attribute.new self + end + + # Sets the element of which this object is an attribute. Normally, this + # is not directly called. + # + # Returns this attribute + def element=( element ) + @element = element + + if @normalized + Text.check( @normalized, NEEDS_A_SECOND_CHECK, doctype ) + end + + self + end + + # Removes this Attribute from the tree, and returns true if successful + # + # This method is usually not called directly. + def remove + @element.attributes.delete self.name unless @element.nil? + end + + # Writes this attribute (EG, puts 'key="value"' to the output) + def write( output, indent=-1 ) + output << to_string + end + + def node_type + :attribute + end + + def inspect + rv = +"" + write( rv ) + rv + end + + def xpath + path = @element.xpath + path += "/@#{self.expanded_name}" + return path + end + end +end +#vim:ts=2 sw=2 noexpandtab: diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/cdata.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/cdata.rb new file mode 100644 index 0000000..997f5a0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/cdata.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: false +require_relative "text" + +module REXML + class CData < Text + START = '' + ILLEGAL = /(\]\]>)/ + + # Constructor. CData is data between + # + # _Examples_ + # CData.new( source ) + # CData.new( "Here is some CDATA" ) + # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element ) + def initialize( first, whitespace=true, parent=nil ) + super( first, whitespace, parent, false, true, ILLEGAL ) + end + + # Make a copy of this object + # + # _Examples_ + # c = CData.new( "Some text" ) + # d = c.clone + # d.to_s # -> "Some text" + def clone + CData.new self + end + + # Returns the content of this CData object + # + # _Examples_ + # c = CData.new( "Some text" ) + # c.to_s # -> "Some text" + def to_s + @string + end + + def value + @string + end + + # == DEPRECATED + # See the rexml/formatters package + # + # Generates XML output of this object + # + # output:: + # Where to write the string. Defaults to $stdout + # indent:: + # The amount to indent this node by + # transitive:: + # Ignored + # ie_hack:: + # Ignored + # + # _Examples_ + # c = CData.new( " Some text " ) + # c.write( $stdout ) #-> + def write( output=$stdout, indent=-1, transitive=false, ie_hack=false ) + Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1) + indent( output, indent ) + output << START + output << @string + output << STOP + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/child.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/child.rb new file mode 100644 index 0000000..cc6e9a4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/child.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: false +require_relative "node" + +module REXML + ## + # A Child object is something contained by a parent, and this class + # contains methods to support that. Most user code will not use this + # class directly. + class Child + include Node + attr_reader :parent # The Parent of this object + + # Constructor. Any inheritors of this class should call super to make + # sure this method is called. + # parent:: + # if supplied, the parent of this child will be set to the + # supplied value, and self will be added to the parent + def initialize( parent = nil ) + @parent = nil + # Declare @parent, but don't define it. The next line sets the + # parent. + parent.add( self ) if parent + end + + # Replaces this object with another object. Basically, calls + # Parent.replace_child + # + # Returns:: self + def replace_with( child ) + @parent.replace_child( self, child ) + self + end + + # Removes this child from the parent. + # + # Returns:: self + def remove + unless @parent.nil? + @parent.delete self + end + self + end + + # Sets the parent of this child to the supplied argument. + # + # other:: + # Must be a Parent object. If this object is the same object as the + # existing parent of this child, no action is taken. Otherwise, this + # child is removed from the current parent (if one exists), and is added + # to the new parent. + # Returns:: The parent added + def parent=( other ) + return @parent if @parent == other + @parent.delete self if defined? @parent and @parent + @parent = other + end + + alias :next_sibling :next_sibling_node + alias :previous_sibling :previous_sibling_node + + # Sets the next sibling of this child. This can be used to insert a child + # after some other child. + # a = Element.new("a") + # b = a.add_element("b") + # c = Element.new("c") + # b.next_sibling = c + # # => + def next_sibling=( other ) + parent.insert_after self, other + end + + # Sets the previous sibling of this child. This can be used to insert a + # child before some other child. + # a = Element.new("a") + # b = a.add_element("b") + # c = Element.new("c") + # b.previous_sibling = c + # # => + def previous_sibling=(other) + parent.insert_before self, other + end + + # Returns:: the document this child belongs to, or nil if this child + # belongs to no document + def document + return parent.document unless parent.nil? + nil + end + + # This doesn't yet handle encodings + def bytes + document.encoding + + to_s + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/comment.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/comment.rb new file mode 100644 index 0000000..52c58b4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/comment.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: false +require_relative "child" + +module REXML + ## + # Represents an XML comment; that is, text between \ + class Comment < Child + include Comparable + START = "" + + # The content text + + attr_accessor :string + + ## + # Constructor. The first argument can be one of three types: + # @param first If String, the contents of this comment are set to the + # argument. If Comment, the argument is duplicated. If + # Source, the argument is scanned for a comment. + # @param second If the first argument is a Source, this argument + # should be nil, not supplied, or a Parent to be set as the parent + # of this object + def initialize( first, second = nil ) + super(second) + if first.kind_of? String + @string = first + elsif first.kind_of? Comment + @string = first.string + end + end + + def clone + Comment.new self + end + + # == DEPRECATED + # See REXML::Formatters + # + # output:: + # Where to write the string + # indent:: + # An integer. If -1, no indenting will be used; otherwise, the + # indentation will be this number of spaces, and children will be + # indented an additional amount. + # transitive:: + # Ignored by this class. The contents of comments are never modified. + # ie_hack:: + # Needed for conformity to the child API, but not used by this class. + def write( output, indent=-1, transitive=false, ie_hack=false ) + Kernel.warn("Comment.write is deprecated. See REXML::Formatters", uplevel: 1) + indent( output, indent ) + output << START + output << @string + output << STOP + end + + alias :to_s :string + + ## + # Compares this Comment to another; the contents of the comment are used + # in the comparison. + def <=>(other) + other.to_s <=> @string + end + + ## + # Compares this Comment to another; the contents of the comment are used + # in the comparison. + def ==( other ) + other.kind_of? Comment and + (other <=> self) == 0 + end + + def node_type + :comment + end + end +end +#vim:ts=2 sw=2 noexpandtab: diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/doctype.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/doctype.rb new file mode 100644 index 0000000..f359048 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/doctype.rb @@ -0,0 +1,311 @@ +# frozen_string_literal: false +require_relative "parent" +require_relative "parseexception" +require_relative "namespace" +require_relative 'entity' +require_relative 'attlistdecl' +require_relative 'xmltokens' + +module REXML + class ReferenceWriter + def initialize(id_type, + public_id_literal, + system_literal, + context=nil) + @id_type = id_type + @public_id_literal = public_id_literal + @system_literal = system_literal + if context and context[:prologue_quote] == :apostrophe + @default_quote = "'" + else + @default_quote = "\"" + end + end + + def write(output) + output << " #{@id_type}" + if @public_id_literal + if @public_id_literal.include?("'") + quote = "\"" + else + quote = @default_quote + end + output << " #{quote}#{@public_id_literal}#{quote}" + end + if @system_literal + if @system_literal.include?("'") + quote = "\"" + elsif @system_literal.include?("\"") + quote = "'" + else + quote = @default_quote + end + output << " #{quote}#{@system_literal}#{quote}" + end + end + end + + # Represents an XML DOCTYPE declaration; that is, the contents of . DOCTYPES can be used to declare the DTD of a document, as well as + # being used to declare entities used in the document. + class DocType < Parent + include XMLTokens + START = "" + SYSTEM = "SYSTEM" + PUBLIC = "PUBLIC" + DEFAULT_ENTITIES = { + 'gt'=>EntityConst::GT, + 'lt'=>EntityConst::LT, + 'quot'=>EntityConst::QUOT, + "apos"=>EntityConst::APOS + } + + # name is the name of the doctype + # external_id is the referenced DTD, if given + attr_reader :name, :external_id, :entities, :namespaces + + # Constructor + # + # dt = DocType.new( 'foo', '-//I/Hate/External/IDs' ) + # # + # dt = DocType.new( doctype_to_clone ) + # # Incomplete. Shallow clone of doctype + # + # +Note+ that the constructor: + # + # Doctype.new( Source.new( "" ) ) + # + # is _deprecated_. Do not use it. It will probably disappear. + def initialize( first, parent=nil ) + @entities = DEFAULT_ENTITIES + @long_name = @uri = nil + if first.kind_of? String + super() + @name = first + @external_id = parent + elsif first.kind_of? DocType + super( parent ) + @name = first.name + @external_id = first.external_id + @long_name = first.instance_variable_get(:@long_name) + @uri = first.instance_variable_get(:@uri) + elsif first.kind_of? Array + super( parent ) + @name = first[0] + @external_id = first[1] + @long_name = first[2] + @uri = first[3] + elsif first.kind_of? Source + super( parent ) + parser = Parsers::BaseParser.new( first ) + event = parser.pull + if event[0] == :start_doctype + @name, @external_id, @long_name, @uri, = event[1..-1] + end + else + super() + end + end + + def node_type + :doctype + end + + def attributes_of element + rv = [] + each do |child| + child.each do |key,val| + rv << Attribute.new(key,val) + end if child.kind_of? AttlistDecl and child.element_name == element + end + rv + end + + def attribute_of element, attribute + att_decl = find do |child| + child.kind_of? AttlistDecl and + child.element_name == element and + child.include? attribute + end + return nil unless att_decl + att_decl[attribute] + end + + def clone + DocType.new self + end + + # output:: + # Where to write the string + # indent:: + # An integer. If -1, no indentation will be used; otherwise, the + # indentation will be this number of spaces, and children will be + # indented an additional amount. + # transitive:: + # Ignored + # ie_hack:: + # Ignored + def write( output, indent=0, transitive=false, ie_hack=false ) + f = REXML::Formatters::Default.new + indent( output, indent ) + output << START + output << ' ' + output << @name + if @external_id + reference_writer = ReferenceWriter.new(@external_id, + @long_name, + @uri, + context) + reference_writer.write(output) + end + unless @children.empty? + output << ' [' + @children.each { |child| + output << "\n" + f.write( child, output ) + } + output << "\n]" + end + output << STOP + end + + def context + if @parent + @parent.context + else + nil + end + end + + def entity( name ) + @entities[name].unnormalized if @entities[name] + end + + def add child + super(child) + @entities = DEFAULT_ENTITIES.clone if @entities == DEFAULT_ENTITIES + @entities[ child.name ] = child if child.kind_of? Entity + end + + # This method retrieves the public identifier identifying the document's + # DTD. + # + # Method contributed by Henrik Martensson + def public + case @external_id + when "SYSTEM" + nil + when "PUBLIC" + @long_name + end + end + + # This method retrieves the system identifier identifying the document's DTD + # + # Method contributed by Henrik Martensson + def system + case @external_id + when "SYSTEM" + @long_name + when "PUBLIC" + @uri.kind_of?(String) ? @uri : nil + end + end + + # This method returns a list of notations that have been declared in the + # _internal_ DTD subset. Notations in the external DTD subset are not + # listed. + # + # Method contributed by Henrik Martensson + def notations + children().select {|node| node.kind_of?(REXML::NotationDecl)} + end + + # Retrieves a named notation. Only notations declared in the internal + # DTD subset can be retrieved. + # + # Method contributed by Henrik Martensson + def notation(name) + notations.find { |notation_decl| + notation_decl.name == name + } + end + end + + # We don't really handle any of these since we're not a validating + # parser, so we can be pretty dumb about them. All we need to be able + # to do is spew them back out on a write() + + # This is an abstract class. You never use this directly; it serves as a + # parent class for the specific declarations. + class Declaration < Child + def initialize src + super() + @string = src + end + + def to_s + @string+'>' + end + + # == DEPRECATED + # See REXML::Formatters + # + def write( output, indent ) + output << to_s + end + end + + public + class ElementDecl < Declaration + def initialize( src ) + super + end + end + + class ExternalEntity < Child + def initialize( src ) + super() + @entity = src + end + def to_s + @entity + end + def write( output, indent ) + output << @entity + end + end + + class NotationDecl < Child + attr_accessor :public, :system + def initialize name, middle, pub, sys + super(nil) + @name = name + @middle = middle + @public = pub + @system = sys + end + + def to_s + context = nil + context = parent.context if parent + notation = "" + notation + end + + def write( output, indent=-1 ) + output << to_s + end + + # This method retrieves the name of the notation. + # + # Method contributed by Henrik Martensson + def name + @name + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/document.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/document.rb new file mode 100644 index 0000000..b1caa02 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/document.rb @@ -0,0 +1,451 @@ +# frozen_string_literal: false +require_relative "security" +require_relative "element" +require_relative "xmldecl" +require_relative "source" +require_relative "comment" +require_relative "doctype" +require_relative "instruction" +require_relative "rexml" +require_relative "parseexception" +require_relative "output" +require_relative "parsers/baseparser" +require_relative "parsers/streamparser" +require_relative "parsers/treeparser" + +module REXML + # Represents an XML document. + # + # A document may have: + # + # - A single child that may be accessed via method #root. + # - An XML declaration. + # - A document type. + # - Processing instructions. + # + # == In a Hurry? + # + # If you're somewhat familiar with XML + # and have a particular task in mind, + # you may want to see the + # {tasks pages}[../doc/rexml/tasks/tocs/master_toc_rdoc.html], + # and in particular, the + # {tasks page for documents}[../doc/rexml/tasks/tocs/document_toc_rdoc.html]. + # + class Document < Element + # A convenient default XML declaration. Use: + # + # mydoc << XMLDecl.default + # + DECLARATION = XMLDecl.default + + # :call-seq: + # new(string = nil, context = {}) -> new_document + # new(io_stream = nil, context = {}) -> new_document + # new(document = nil, context = {}) -> new_document + # + # Returns a new \REXML::Document object. + # + # When no arguments are given, + # returns an empty document: + # + # d = REXML::Document.new + # d.to_s # => "" + # + # When argument +string+ is given, it must be a string + # containing a valid XML document: + # + # xml_string = 'FooBar' + # d = REXML::Document.new(xml_string) + # d.to_s # => "FooBar" + # + # When argument +io_stream+ is given, it must be an \IO object + # that is opened for reading, and when read must return a valid XML document: + # + # File.write('t.xml', xml_string) + # d = File.open('t.xml', 'r') do |io| + # REXML::Document.new(io) + # end + # d.to_s # => "FooBar" + # + # When argument +document+ is given, it must be an existing + # document object, whose context and attributes (but not children) + # are cloned into the new document: + # + # d = REXML::Document.new(xml_string) + # d.children # => [ ... ] + # d.context = {raw: :all, compress_whitespace: :all} + # d.add_attributes({'bar' => 0, 'baz' => 1}) + # d1 = REXML::Document.new(d) + # d1.children # => [] + # d1.context # => {:raw=>:all, :compress_whitespace=>:all} + # d1.attributes # => {"bar"=>bar='0', "baz"=>baz='1'} + # + # When argument +context+ is given, it must be a hash + # containing context entries for the document; + # see {Element Context}[../doc/rexml/context_rdoc.html]: + # + # context = {raw: :all, compress_whitespace: :all} + # d = REXML::Document.new(xml_string, context) + # d.context # => {:raw=>:all, :compress_whitespace=>:all} + # + def initialize( source = nil, context = {} ) + @entity_expansion_count = 0 + super() + @context = context + return if source.nil? + if source.kind_of? Document + @context = source.context + super source + else + build( source ) + end + end + + # :call-seq: + # node_type -> :document + # + # Returns the symbol +:document+. + # + def node_type + :document + end + + # :call-seq: + # clone -> new_document + # + # Returns the new document resulting from executing + # Document.new(self). See Document.new. + # + def clone + Document.new self + end + + # :call-seq: + # expanded_name -> empty_string + # + # Returns an empty string. + # + def expanded_name + '' + #d = doc_type + #d ? d.name : "UNDEFINED" + end + alias :name :expanded_name + + # :call-seq: + # add(xml_decl) -> self + # add(doc_type) -> self + # add(object) -> self + # + # Adds an object to the document; returns +self+. + # + # When argument +xml_decl+ is given, + # it must be an REXML::XMLDecl object, + # which becomes the XML declaration for the document, + # replacing the previous XML declaration if any: + # + # d = REXML::Document.new + # d.xml_decl.to_s # => "" + # d.add(REXML::XMLDecl.new('2.0')) + # d.xml_decl.to_s # => "" + # + # When argument +doc_type+ is given, + # it must be an REXML::DocType object, + # which becomes the document type for the document, + # replacing the previous document type, if any: + # + # d = REXML::Document.new + # d.doctype.to_s # => "" + # d.add(REXML::DocType.new('foo')) + # d.doctype.to_s # => "" + # + # When argument +object+ (not an REXML::XMLDecl or REXML::DocType object) + # is given it is added as the last child: + # + # d = REXML::Document.new + # d.add(REXML::Element.new('foo')) + # d.to_s # => "" + # + def add( child ) + if child.kind_of? XMLDecl + if @children[0].kind_of? XMLDecl + @children[0] = child + else + @children.unshift child + end + child.parent = self + elsif child.kind_of? DocType + # Find first Element or DocType node and insert the decl right + # before it. If there is no such node, just insert the child at the + # end. If there is a child and it is an DocType, then replace it. + insert_before_index = @children.find_index { |x| + x.kind_of?(Element) || x.kind_of?(DocType) + } + if insert_before_index # Not null = not end of list + if @children[ insert_before_index ].kind_of? DocType + @children[ insert_before_index ] = child + else + @children[ insert_before_index-1, 0 ] = child + end + else # Insert at end of list + @children << child + end + child.parent = self + else + rv = super + raise "attempted adding second root element to document" if @elements.size > 1 + rv + end + end + alias :<< :add + + # :call-seq: + # add_element(name_or_element = nil, attributes = nil) -> new_element + # + # Adds an element to the document by calling REXML::Element.add_element: + # + # REXML::Element.add_element(name_or_element, attributes) + def add_element(arg=nil, arg2=nil) + rv = super + raise "attempted adding second root element to document" if @elements.size > 1 + rv + end + + # :call-seq: + # root -> root_element or nil + # + # Returns the root element of the document, if it exists, otherwise +nil+: + # + # d = REXML::Document.new('') + # d.root # => + # d = REXML::Document.new('') + # d.root # => nil + # + def root + elements[1] + #self + #@children.find { |item| item.kind_of? Element } + end + + # :call-seq: + # doctype -> doc_type or nil + # + # Returns the DocType object for the document, if it exists, otherwise +nil+: + # + # d = REXML::Document.new('') + # d.doctype.class # => REXML::DocType + # d = REXML::Document.new('') + # d.doctype.class # => nil + # + def doctype + @children.find { |item| item.kind_of? DocType } + end + + # :call-seq: + # xml_decl -> xml_decl + # + # Returns the XMLDecl object for the document, if it exists, + # otherwise the default XMLDecl object: + # + # d = REXML::Document.new('') + # d.xml_decl.class # => REXML::XMLDecl + # d.xml_decl.to_s # => "" + # d = REXML::Document.new('') + # d.xml_decl.class # => REXML::XMLDecl + # d.xml_decl.to_s # => "" + # + def xml_decl + rv = @children[0] + return rv if rv.kind_of? XMLDecl + @children.unshift(XMLDecl.default)[0] + end + + # :call-seq: + # version -> version_string + # + # Returns the XMLDecl version of this document as a string, + # if it has been set, otherwise the default version: + # + # d = REXML::Document.new('') + # d.version # => "2.0" + # d = REXML::Document.new('') + # d.version # => "1.0" + # + def version + xml_decl().version + end + + # :call-seq: + # encoding -> encoding_string + # + # Returns the XMLDecl encoding of the document, + # if it has been set, otherwise the default encoding: + # + # d = REXML::Document.new('') + # d.encoding # => "UTF-16" + # d = REXML::Document.new('') + # d.encoding # => "UTF-8" + # + def encoding + xml_decl().encoding + end + + # :call-seq: + # stand_alone? + # + # Returns the XMLDecl standalone value of the document as a string, + # if it has been set, otherwise the default standalone value: + # + # d = REXML::Document.new('') + # d.stand_alone? # => "yes" + # d = REXML::Document.new('') + # d.stand_alone? # => nil + # + def stand_alone? + xml_decl().stand_alone? + end + + # :call-seq: + # doc.write(output=$stdout, indent=-1, transtive=false, ie_hack=false, encoding=nil) + # doc.write(options={:output => $stdout, :indent => -1, :transtive => false, :ie_hack => false, :encoding => nil}) + # + # Write the XML tree out, optionally with indent. This writes out the + # entire XML document, including XML declarations, doctype declarations, + # and processing instructions (if any are given). + # + # A controversial point is whether Document should always write the XML + # declaration () whether or not one is given by the + # user (or source document). REXML does not write one if one was not + # specified, because it adds unnecessary bandwidth to applications such + # as XML-RPC. + # + # Accept Nth argument style and options Hash style as argument. + # The recommended style is options Hash style for one or more + # arguments case. + # + # _Examples_ + # Document.new("").write + # + # output = "" + # Document.new("").write(output) + # + # output = "" + # Document.new("").write(:output => output, :indent => 2) + # + # See also the classes in the rexml/formatters package for the proper way + # to change the default formatting of XML output. + # + # _Examples_ + # + # output = "" + # tr = Transitive.new + # tr.write(Document.new(""), output) + # + # output:: + # output an object which supports '<< string'; this is where the + # document will be written. + # indent:: + # An integer. If -1, no indenting will be used; otherwise, the + # indentation will be twice this number of spaces, and children will be + # indented an additional amount. For a value of 3, every item will be + # indented 3 more levels, or 6 more spaces (2 * 3). Defaults to -1 + # transitive:: + # If transitive is true and indent is >= 0, then the output will be + # pretty-printed in such a way that the added whitespace does not affect + # the absolute *value* of the document -- that is, it leaves the value + # and number of Text nodes in the document unchanged. + # ie_hack:: + # This hack inserts a space before the /> on empty tags to address + # a limitation of Internet Explorer. Defaults to false + # encoding:: + # Encoding name as String. Change output encoding to specified encoding + # instead of encoding in XML declaration. + # Defaults to nil. It means encoding in XML declaration is used. + def write(*arguments) + if arguments.size == 1 and arguments[0].class == Hash + options = arguments[0] + + output = options[:output] + indent = options[:indent] + transitive = options[:transitive] + ie_hack = options[:ie_hack] + encoding = options[:encoding] + else + output, indent, transitive, ie_hack, encoding, = *arguments + end + + output ||= $stdout + indent ||= -1 + transitive = false if transitive.nil? + ie_hack = false if ie_hack.nil? + encoding ||= xml_decl.encoding + + if encoding != 'UTF-8' && !output.kind_of?(Output) + output = Output.new( output, encoding ) + end + formatter = if indent > -1 + if transitive + require_relative "formatters/transitive" + REXML::Formatters::Transitive.new( indent, ie_hack ) + else + REXML::Formatters::Pretty.new( indent, ie_hack ) + end + else + REXML::Formatters::Default.new( ie_hack ) + end + formatter.write( self, output ) + end + + + def Document::parse_stream( source, listener ) + Parsers::StreamParser.new( source, listener ).parse + end + + # Set the entity expansion limit. By default the limit is set to 10000. + # + # Deprecated. Use REXML::Security.entity_expansion_limit= instead. + def Document::entity_expansion_limit=( val ) + Security.entity_expansion_limit = val + end + + # Get the entity expansion limit. By default the limit is set to 10000. + # + # Deprecated. Use REXML::Security.entity_expansion_limit= instead. + def Document::entity_expansion_limit + return Security.entity_expansion_limit + end + + # Set the entity expansion limit. By default the limit is set to 10240. + # + # Deprecated. Use REXML::Security.entity_expansion_text_limit= instead. + def Document::entity_expansion_text_limit=( val ) + Security.entity_expansion_text_limit = val + end + + # Get the entity expansion limit. By default the limit is set to 10240. + # + # Deprecated. Use REXML::Security.entity_expansion_text_limit instead. + def Document::entity_expansion_text_limit + return Security.entity_expansion_text_limit + end + + attr_reader :entity_expansion_count + + def record_entity_expansion + @entity_expansion_count += 1 + if @entity_expansion_count > Security.entity_expansion_limit + raise "number of entity expansions exceeded, processing aborted." + end + end + + def document + self + end + + private + def build( source ) + Parsers::TreeParser.new( source, self ).parse + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/attlistdecl.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/attlistdecl.rb new file mode 100644 index 0000000..1326cb2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/attlistdecl.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: false +require_relative "../child" +module REXML + module DTD + class AttlistDecl < Child + START = ")/um + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/dtd.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/dtd.rb new file mode 100644 index 0000000..8b0f2d7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/dtd.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: false +require_relative "elementdecl" +require_relative "entitydecl" +require_relative "../comment" +require_relative "notationdecl" +require_relative "attlistdecl" +require_relative "../parent" + +module REXML + module DTD + class Parser + def Parser.parse( input ) + case input + when String + parse_helper input + when File + parse_helper input.read + end + end + + # Takes a String and parses it out + def Parser.parse_helper( input ) + contents = Parent.new + while input.size > 0 + case input + when ElementDecl.PATTERN_RE + match = $& + contents << ElementDecl.new( match ) + when AttlistDecl.PATTERN_RE + matchdata = $~ + contents << AttlistDecl.new( matchdata ) + when EntityDecl.PATTERN_RE + matchdata = $~ + contents << EntityDecl.new( matchdata ) + when Comment.PATTERN_RE + matchdata = $~ + contents << Comment.new( matchdata ) + when NotationDecl.PATTERN_RE + matchdata = $~ + contents << NotationDecl.new( matchdata ) + end + end + contents + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/elementdecl.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/elementdecl.rb new file mode 100644 index 0000000..20ed023 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/elementdecl.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: false +require_relative "../child" +module REXML + module DTD + class ElementDecl < Child + START = "/um + PATTERN_RE = /^\s*#{START}\s+((?:[:\w][-\.\w]*:)?[-!\*\.\w]*)(.*?)>/ + #\s*((((["']).*?\5)|[^\/'">]*)*?)(\/)?>/um, true) + + def initialize match + @name = match[1] + @rest = match[2] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/entitydecl.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/entitydecl.rb new file mode 100644 index 0000000..312df65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/entitydecl.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: false +require_relative "../child" +module REXML + module DTD + class EntityDecl < Child + START = "/um + SYSTEM = /^\s*#{START}\s+(?:%\s+)?(\w+)\s+SYSTEM\s+((["']).*?\3)(?:\s+NDATA\s+\w+)?\s*>/um + PLAIN = /^\s*#{START}\s+(\w+)\s+((["']).*?\3)\s*>/um + PERCENT = /^\s*#{START}\s+%\s+(\w+)\s+((["']).*?\3)\s*>/um + # + # + def initialize src + super() + md = nil + if src.match( PUBLIC ) + md = src.match( PUBLIC, true ) + @middle = "PUBLIC" + @content = "#{md[2]} #{md[4]}" + elsif src.match( SYSTEM ) + md = src.match( SYSTEM, true ) + @middle = "SYSTEM" + @content = md[2] + elsif src.match( PLAIN ) + md = src.match( PLAIN, true ) + @middle = "" + @content = md[2] + elsif src.match( PERCENT ) + md = src.match( PERCENT, true ) + @middle = "" + @content = md[2] + end + raise ParseException.new("failed Entity match", src) if md.nil? + @name = md[1] + end + + def to_s + rv = " 0 + rv << @content + rv + end + + def write( output, indent ) + indent( output, indent ) + output << to_s + end + + def EntityDecl.parse_source source, listener + md = source.match( PATTERN_RE, true ) + thing = md[0].squeeze(" \t\n\r") + listener.send inspect.downcase, thing + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/notationdecl.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/notationdecl.rb new file mode 100644 index 0000000..04a9b08 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/dtd/notationdecl.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: false +require_relative "../child" +module REXML + module DTD + class NotationDecl < Child + START = "/um + SYSTEM = /^\s*#{START}\s+(\w[\w-]*)\s+(SYSTEM)\s+((["']).*?\4)\s*>/um + def initialize src + super() + if src.match( PUBLIC ) + md = src.match( PUBLIC, true ) + elsif src.match( SYSTEM ) + md = src.match( SYSTEM, true ) + else + raise ParseException.new( "error parsing notation: no matching pattern", src ) + end + @name = md[1] + @middle = md[2] + @rest = md[3] + end + + def to_s + "" + end + + def write( output, indent ) + indent( output, indent ) + output << to_s + end + + def NotationDecl.parse_source source, listener + md = source.match( PATTERN_RE, true ) + thing = md[0].squeeze(" \t\n\r") + listener.send inspect.downcase, thing + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/element.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/element.rb new file mode 100644 index 0000000..a5808d7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/element.rb @@ -0,0 +1,2586 @@ +# frozen_string_literal: false +require_relative "parent" +require_relative "namespace" +require_relative "attribute" +require_relative "cdata" +require_relative "xpath" +require_relative "parseexception" + +module REXML + # An \REXML::Element object represents an XML element. + # + # An element: + # + # - Has a name (string). + # - May have a parent (another element). + # - Has zero or more children + # (other elements, text, CDATA, processing instructions, and comments). + # - Has zero or more siblings + # (other elements, text, CDATA, processing instructions, and comments). + # - Has zero or more named attributes. + # + # == In a Hurry? + # + # If you're somewhat familiar with XML + # and have a particular task in mind, + # you may want to see the + # {tasks pages}[../doc/rexml/tasks/tocs/master_toc_rdoc.html], + # and in particular, the + # {tasks page for elements}[../doc/rexml/tasks/tocs/element_toc_rdoc.html]. + # + # === Name + # + # An element has a name, which is initially set when the element is created: + # + # e = REXML::Element.new('foo') + # e.name # => "foo" + # + # The name may be changed: + # + # e.name = 'bar' + # e.name # => "bar" + # + # + # === \Parent + # + # An element may have a parent. + # + # Its parent may be assigned explicitly when the element is created: + # + # e0 = REXML::Element.new('foo') + # e1 = REXML::Element.new('bar', e0) + # e1.parent # => ... + # + # Note: the representation of an element always shows the element's name. + # If the element has children, the representation indicates that + # by including an ellipsis (...). + # + # The parent may be assigned explicitly at any time: + # + # e2 = REXML::Element.new('baz') + # e1.parent = e2 + # e1.parent # => + # + # When an element is added as a child, its parent is set automatically: + # + # e1.add_element(e0) + # e0.parent # => ... + # + # For an element that has no parent, method +parent+ returns +nil+. + # + # === Children + # + # An element has zero or more children. + # The children are an ordered collection + # of all objects whose parent is the element itself. + # + # The children may include any combination of elements, text, comments, + # processing instructions, and CDATA. + # (This example keeps things clean by controlling whitespace + # via a +context+ setting.) + # + # xml_string = <<-EOT + # + # + # text 0 + # + # + # + # + # text 1 + # + # + # + # + # EOT + # context = {ignore_whitespace_nodes: :all, compress_whitespace: :all} + # d = REXML::Document.new(xml_string, context) + # root = d.root + # root.children.size # => 10 + # root.each {|child| p "#{child.class}: #{child}" } + # + # Output: + # + # "REXML::Element: " + # "REXML::Text: \n text 0\n " + # "REXML::Comment: comment 0" + # "REXML::Instruction: " + # "REXML::CData: cdata 0" + # "REXML::Element: " + # "REXML::Text: \n text 1\n " + # "REXML::Comment: comment 1" + # "REXML::Instruction: " + # "REXML::CData: cdata 1" + # + # A child may be added using inherited methods + # Parent#insert_before or Parent#insert_after: + # + # xml_string = '' + # d = REXML::Document.new(xml_string) + # root = d.root + # c = d.root[1] # => + # root.insert_before(c, REXML::Element.new('b')) + # root.to_a # => [, , , ] + # + # A child may be replaced using Parent#replace_child: + # + # root.replace_child(c, REXML::Element.new('x')) + # root.to_a # => [, , , ] + # + # A child may be removed using Parent#delete: + # + # x = root[2] # => + # root.delete(x) + # root.to_a # => [, , ] + # + # === Siblings + # + # An element has zero or more siblings, + # which are the other children of the element's parent. + # + # In the example above, element +ele_1+ is between a CDATA sibling + # and a text sibling: + # + # ele_1 = root[5] # => + # ele_1.previous_sibling # => "cdata 0" + # ele_1.next_sibling # => "\n text 1\n " + # + # === \Attributes + # + # An element has zero or more named attributes. + # + # A new element has no attributes: + # + # e = REXML::Element.new('foo') + # e.attributes # => {} + # + # Attributes may be added: + # + # e.add_attribute('bar', 'baz') + # e.add_attribute('bat', 'bam') + # e.attributes.size # => 2 + # e['bar'] # => "baz" + # e['bat'] # => "bam" + # + # An existing attribute may be modified: + # + # e.add_attribute('bar', 'bad') + # e.attributes.size # => 2 + # e['bar'] # => "bad" + # + # An existing attribute may be deleted: + # + # e.delete_attribute('bar') + # e.attributes.size # => 1 + # e['bar'] # => nil + # + # == What's Here + # + # To begin with, what's elsewhere? + # + # \Class \REXML::Element inherits from its ancestor classes: + # + # - REXML::Child + # - REXML::Parent + # + # \REXML::Element itself and its ancestors also include modules: + # + # - {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html] + # - REXML::Namespace + # - REXML::Node + # - REXML::XMLTokens + # + # === Methods for Creating an \Element + # + # ::new:: Returns a new empty element. + # #clone:: Returns a clone of another element. + # + # === Methods for Attributes + # + # {[attribute_name]}[#method-i-5B-5D]:: Returns an attribute value. + # #add_attribute:: Adds a new attribute. + # #add_attributes:: Adds multiple new attributes. + # #attribute:: Returns the attribute value for a given name and optional namespace. + # #delete_attribute:: Removes an attribute. + # + # === Methods for Children + # + # {[index]}[#method-i-5B-5D]:: Returns the child at the given offset. + # #add_element:: Adds an element as the last child. + # #delete_element:: Deletes a child element. + # #each_element:: Calls the given block with each child element. + # #each_element_with_attribute:: Calls the given block with each child element + # that meets given criteria, + # which can include the attribute name. + # #each_element_with_text:: Calls the given block with each child element + # that meets given criteria, + # which can include text. + # #get_elements:: Returns an array of element children that match a given xpath. + # + # === Methods for \Text Children + # + # #add_text:: Adds a text node to the element. + # #get_text:: Returns a text node that meets specified criteria. + # #text:: Returns the text string from the first node that meets specified criteria. + # #texts:: Returns an array of the text children of the element. + # #text=:: Adds, removes, or replaces the first text child of the element + # + # === Methods for Other Children + # + # #cdatas:: Returns an array of the cdata children of the element. + # #comments:: Returns an array of the comment children of the element. + # #instructions:: Returns an array of the instruction children of the element. + # + # === Methods for Namespaces + # + # #add_namespace:: Adds a namespace to the element. + # #delete_namespace:: Removes a namespace from the element. + # #namespace:: Returns the string namespace URI for the element. + # #namespaces:: Returns a hash of all defined namespaces in the element. + # #prefixes:: Returns an array of the string prefixes (names) + # of all defined namespaces in the element + # + # === Methods for Querying + # + # #document:: Returns the document, if any, that the element belongs to. + # #root:: Returns the most distant element (not document) ancestor of the element. + # #root_node:: Returns the most distant ancestor of the element. + # #xpath:: Returns the string xpath to the element + # relative to the most distant parent + # #has_attributes?:: Returns whether the element has attributes. + # #has_elements?:: Returns whether the element has elements. + # #has_text?:: Returns whether the element has text. + # #next_element:: Returns the next sibling that is an element. + # #previous_element:: Returns the previous sibling that is an element. + # #raw:: Returns whether raw mode is set for the element. + # #whitespace:: Returns whether whitespace is respected for the element. + # #ignore_whitespace_nodes:: Returns whether whitespace nodes + # are to be ignored for the element. + # #node_type:: Returns symbol :element. + # + # === One More Method + # + # #inspect:: Returns a string representation of the element. + # + # === Accessors + # + # #elements:: Returns the REXML::Elements object for the element. + # #attributes:: Returns the REXML::Attributes object for the element. + # #context:: Returns or sets the context hash for the element. + # + class Element < Parent + include Namespace + + UNDEFINED = "UNDEFINED"; # The default name + + # Mechanisms for accessing attributes and child elements of this + # element. + attr_reader :attributes, :elements + # The context holds information about the processing environment, such as + # whitespace handling. + attr_accessor :context + + # :call-seq: + # Element.new(name = 'UNDEFINED', parent = nil, context = nil) -> new_element + # Element.new(element, parent = nil, context = nil) -> new_element + # + # Returns a new \REXML::Element object. + # + # When no arguments are given, + # returns an element with name 'UNDEFINED': + # + # e = REXML::Element.new # => + # e.class # => REXML::Element + # e.name # => "UNDEFINED" + # + # When only argument +name+ is given, + # returns an element of the given name: + # + # REXML::Element.new('foo') # => + # + # When only argument +element+ is given, it must be an \REXML::Element object; + # returns a shallow copy of the given element: + # + # e0 = REXML::Element.new('foo') + # e1 = REXML::Element.new(e0) # => + # + # When argument +parent+ is also given, it must be an REXML::Parent object: + # + # e = REXML::Element.new('foo', REXML::Parent.new) + # e.parent # => #]> + # + # When argument +context+ is also given, it must be a hash + # representing the context for the element; + # see {Element Context}[../doc/rexml/context_rdoc.html]: + # + # e = REXML::Element.new('foo', nil, {raw: :all}) + # e.context # => {:raw=>:all} + # + def initialize( arg = UNDEFINED, parent=nil, context=nil ) + super(parent) + + @elements = Elements.new(self) + @attributes = Attributes.new(self) + @context = context + + if arg.kind_of? String + self.name = arg + elsif arg.kind_of? Element + self.name = arg.expanded_name + arg.attributes.each_attribute{ |attribute| + @attributes << Attribute.new( attribute ) + } + @context = arg.context + end + end + + # :call-seq: + # inspect -> string + # + # Returns a string representation of the element. + # + # For an element with no attributes and no children, shows the element name: + # + # REXML::Element.new.inspect # => "" + # + # Shows attributes, if any: + # + # e = REXML::Element.new('foo') + # e.add_attributes({'bar' => 0, 'baz' => 1}) + # e.inspect # => "" + # + # Shows an ellipsis (...), if there are child elements: + # + # e.add_element(REXML::Element.new('bar')) + # e.add_element(REXML::Element.new('baz')) + # e.inspect # => " ... " + # + def inspect + rv = "<#@expanded_name" + + @attributes.each_attribute do |attr| + rv << " " + attr.write( rv, 0 ) + end + + if children.size > 0 + rv << "> ... " + else + rv << "/>" + end + end + + # :call-seq: + # clone -> new_element + # + # Returns a shallow copy of the element, containing the name and attributes, + # but not the parent or children: + # + # e = REXML::Element.new('foo') + # e.add_attributes({'bar' => 0, 'baz' => 1}) + # e.clone # => + # + def clone + self.class.new self + end + + # :call-seq: + # root_node -> document or element + # + # Returns the most distant ancestor of +self+. + # + # When the element is part of a document, + # returns the root node of the document. + # Note that the root node is different from the document element; + # in this example +a+ is document element and the root node is its parent: + # + # d = REXML::Document.new('') + # top_element = d.first # => ... + # child = top_element.first # => ... + # d.root_node == d # => true + # top_element.root_node == d # => true + # child.root_node == d # => true + # + # When the element is not part of a document, but does have ancestor elements, + # returns the most distant ancestor element: + # + # e0 = REXML::Element.new('foo') + # e1 = REXML::Element.new('bar') + # e1.parent = e0 + # e2 = REXML::Element.new('baz') + # e2.parent = e1 + # e2.root_node == e0 # => true + # + # When the element has no ancestor elements, + # returns +self+: + # + # e = REXML::Element.new('foo') + # e.root_node == e # => true + # + # Related: #root, #document. + # + def root_node + parent.nil? ? self : parent.root_node + end + + # :call-seq: + # root -> element + # + # Returns the most distant _element_ (not document) ancestor of the element: + # + # d = REXML::Document.new('') + # top_element = d.first + # child = top_element.first + # top_element.root == top_element # => true + # child.root == top_element # => true + # + # For a document, returns the topmost element: + # + # d.root == top_element # => true + # + # Related: #root_node, #document. + # + def root + return elements[1] if self.kind_of? Document + return self if parent.kind_of? Document or parent.nil? + return parent.root + end + + # :call-seq: + # document -> document or nil + # + # If the element is part of a document, returns that document: + # + # d = REXML::Document.new('') + # top_element = d.first + # child = top_element.first + # top_element.document == d # => true + # child.document == d # => true + # + # If the element is not part of a document, returns +nil+: + # + # REXML::Element.new.document # => nil + # + # For a document, returns +self+: + # + # d.document == d # => true + # + # Related: #root, #root_node. + # + def document + rt = root + rt.parent if rt + end + + # :call-seq: + # whitespace + # + # Returns +true+ if whitespace is respected for this element, + # +false+ otherwise. + # + # See {Element Context}[../doc/rexml/context_rdoc.html]. + # + # The evaluation is tested against the element's +expanded_name+, + # and so is namespace-sensitive. + def whitespace + @whitespace = nil + if @context + if @context[:respect_whitespace] + @whitespace = (@context[:respect_whitespace] == :all or + @context[:respect_whitespace].include? expanded_name) + end + @whitespace = false if (@context[:compress_whitespace] and + (@context[:compress_whitespace] == :all or + @context[:compress_whitespace].include? expanded_name) + ) + end + @whitespace = true unless @whitespace == false + @whitespace + end + + # :call-seq: + # ignore_whitespace_nodes + # + # Returns +true+ if whitespace nodes are ignored for the element. + # + # See {Element Context}[../doc/rexml/context_rdoc.html]. + # + def ignore_whitespace_nodes + @ignore_whitespace_nodes = false + if @context + if @context[:ignore_whitespace_nodes] + @ignore_whitespace_nodes = + (@context[:ignore_whitespace_nodes] == :all or + @context[:ignore_whitespace_nodes].include? expanded_name) + end + end + end + + # :call-seq: + # raw + # + # Returns +true+ if raw mode is set for the element. + # + # See {Element Context}[../doc/rexml/context_rdoc.html]. + # + # The evaluation is tested against +expanded_name+, and so is namespace + # sensitive. + def raw + @raw = (@context and @context[:raw] and + (@context[:raw] == :all or + @context[:raw].include? expanded_name)) + @raw + end + + #once :whitespace, :raw, :ignore_whitespace_nodes + + ################################################# + # Namespaces # + ################################################# + + # :call-seq: + # prefixes -> array_of_namespace_prefixes + # + # Returns an array of the string prefixes (names) of all defined namespaces + # in the element and its ancestors: + # + # xml_string = <<-EOT + # + # + # + # + # + # + # EOT + # d = REXML::Document.new(xml_string, {compress_whitespace: :all}) + # d.elements['//a'].prefixes # => ["x", "y"] + # d.elements['//b'].prefixes # => ["x", "y"] + # d.elements['//c'].prefixes # => ["x", "y", "z"] + # + def prefixes + prefixes = [] + prefixes = parent.prefixes if parent + prefixes |= attributes.prefixes + return prefixes + end + + # :call-seq: + # namespaces -> array_of_namespace_names + # + # Returns a hash of all defined namespaces + # in the element and its ancestors: + # + # xml_string = <<-EOT + # + # + # + # + # + # + # EOT + # d = REXML::Document.new(xml_string) + # d.elements['//a'].namespaces # => {"x"=>"1", "y"=>"2"} + # d.elements['//b'].namespaces # => {"x"=>"1", "y"=>"2"} + # d.elements['//c'].namespaces # => {"x"=>"1", "y"=>"2", "z"=>"3"} + # + def namespaces + namespaces = {} + namespaces = parent.namespaces if parent + namespaces = namespaces.merge( attributes.namespaces ) + return namespaces + end + + # :call-seq: + # namespace(prefix = nil) -> string_uri or nil + # + # Returns the string namespace URI for the element, + # possibly deriving from one of its ancestors. + # + # xml_string = <<-EOT + # + # + # + # + # + # + # EOT + # d = REXML::Document.new(xml_string) + # b = d.elements['//b'] + # b.namespace # => "1" + # b.namespace('y') # => "2" + # b.namespace('nosuch') # => nil + # + def namespace(prefix=nil) + if prefix.nil? + prefix = prefix() + end + if prefix == '' + prefix = "xmlns" + else + prefix = "xmlns:#{prefix}" unless prefix[0,5] == 'xmlns' + end + ns = attributes[ prefix ] + ns = parent.namespace(prefix) if ns.nil? and parent + ns = '' if ns.nil? and prefix == 'xmlns' + return ns + end + + # :call-seq: + # add_namespace(prefix, uri = nil) -> self + # + # Adds a namespace to the element; returns +self+. + # + # With the single argument +prefix+, + # adds a namespace using the given +prefix+ and the namespace URI: + # + # e = REXML::Element.new('foo') + # e.add_namespace('bar') + # e.namespaces # => {"xmlns"=>"bar"} + # + # With both arguments +prefix+ and +uri+ given, + # adds a namespace using both arguments: + # + # e.add_namespace('baz', 'bat') + # e.namespaces # => {"xmlns"=>"bar", "baz"=>"bat"} + # + def add_namespace( prefix, uri=nil ) + unless uri + @attributes["xmlns"] = prefix + else + prefix = "xmlns:#{prefix}" unless prefix =~ /^xmlns:/ + @attributes[ prefix ] = uri + end + self + end + + # :call-seq: + # delete_namespace(namespace = 'xmlns') -> self + # + # Removes a namespace from the element. + # + # With no argument, removes the default namespace: + # + # d = REXML::Document.new "" + # d.to_s # => "" + # d.root.delete_namespace # => + # d.to_s # => "" + # + # With argument +namespace+, removes the specified namespace: + # + # d.root.delete_namespace('foo') + # d.to_s # => "" + # + # Does nothing if no such namespace is found: + # + # d.root.delete_namespace('nosuch') + # d.to_s # => "" + # + def delete_namespace namespace="xmlns" + namespace = "xmlns:#{namespace}" unless namespace == 'xmlns' + attribute = attributes.get_attribute(namespace) + attribute.remove unless attribute.nil? + self + end + + ################################################# + # Elements # + ################################################# + + # :call-seq: + # add_element(name, attributes = nil) -> new_element + # add_element(element, attributes = nil) -> element + # + # Adds a child element, optionally setting attributes + # on the added element; returns the added element. + # + # With string argument +name+, creates a new element with that name + # and adds the new element as a child: + # + # e0 = REXML::Element.new('foo') + # e0.add_element('bar') + # e0[0] # => + # + # + # With argument +name+ and hash argument +attributes+, + # sets attributes on the new element: + # + # e0.add_element('baz', {'bat' => '0', 'bam' => '1'}) + # e0[1] # => + # + # With element argument +element+, adds that element as a child: + # + # e0 = REXML::Element.new('foo') + # e1 = REXML::Element.new('bar') + # e0.add_element(e1) + # e0[0] # => + # + # With argument +element+ and hash argument +attributes+, + # sets attributes on the added element: + # + # e0.add_element(e1, {'bat' => '0', 'bam' => '1'}) + # e0[1] # => + # + def add_element element, attrs=nil + raise "First argument must be either an element name, or an Element object" if element.nil? + el = @elements.add(element) + attrs.each do |key, value| + el.attributes[key]=value + end if attrs.kind_of? Hash + el + end + + # :call-seq: + # delete_element(index) -> removed_element or nil + # delete_element(element) -> removed_element or nil + # delete_element(xpath) -> removed_element or nil + # + # Deletes a child element. + # + # When 1-based integer argument +index+ is given, + # removes and returns the child element at that offset if it exists; + # indexing does not include text nodes; + # returns +nil+ if the element does not exist: + # + # d = REXML::Document.new 'text' + # a = d.root # => ... + # a.delete_element(1) # => + # a.delete_element(1) # => + # a.delete_element(1) # => nil + # + # When element argument +element+ is given, + # removes and returns that child element if it exists, + # otherwise returns +nil+: + # + # d = REXML::Document.new 'text' + # a = d.root # => ... + # c = a[2] # => + # a.delete_element(c) # => + # a.delete_element(c) # => nil + # + # When xpath argument +xpath+ is given, + # removes and returns the element at xpath if it exists, + # otherwise returns +nil+: + # + # d = REXML::Document.new 'text' + # a = d.root # => ... + # a.delete_element('//c') # => + # a.delete_element('//c') # => nil + # + def delete_element element + @elements.delete element + end + + # :call-seq: + # has_elements? + # + # Returns +true+ if the element has one or more element children, + # +false+ otherwise: + # + # d = REXML::Document.new 'text' + # a = d.root # => ... + # a.has_elements? # => true + # b = a[0] # => + # b.has_elements? # => false + # + def has_elements? + !@elements.empty? + end + + # :call-seq: + # each_element_with_attribute(attr_name, value = nil, max = 0, xpath = nil) {|e| ... } + # + # Calls the given block with each child element that meets given criteria. + # + # When only string argument +attr_name+ is given, + # calls the block with each child element that has that attribute: + # + # d = REXML::Document.new '' + # a = d.root + # a.each_element_with_attribute('id') {|e| p e } + # + # Output: + # + # + # + # + # + # With argument +attr_name+ and string argument +value+ given, + # calls the block with each child element that has that attribute + # with that value: + # + # a.each_element_with_attribute('id', '1') {|e| p e } + # + # Output: + # + # + # + # + # With arguments +attr_name+, +value+, and integer argument +max+ given, + # calls the block with at most +max+ child elements: + # + # a.each_element_with_attribute('id', '1', 1) {|e| p e } + # + # Output: + # + # + # + # With all arguments given, including +xpath+, + # calls the block with only those child elements + # that meet the first three criteria, + # and also match the given +xpath+: + # + # a.each_element_with_attribute('id', '1', 2, '//d') {|e| p e } + # + # Output: + # + # + # + def each_element_with_attribute( key, value=nil, max=0, name=nil, &block ) # :yields: Element + each_with_something( proc {|child| + if value.nil? + child.attributes[key] != nil + else + child.attributes[key]==value + end + }, max, name, &block ) + end + + # :call-seq: + # each_element_with_text(text = nil, max = 0, xpath = nil) {|e| ... } + # + # Calls the given block with each child element that meets given criteria. + # + # With no arguments, calls the block with each child element that has text: + # + # d = REXML::Document.new 'bbd' + # a = d.root + # a.each_element_with_text {|e| p e } + # + # Output: + # + # ... + # ... + # ... + # + # With the single string argument +text+, + # calls the block with each element that has exactly that text: + # + # a.each_element_with_text('b') {|e| p e } + # + # Output: + # + # ... + # ... + # + # With argument +text+ and integer argument +max+, + # calls the block with at most +max+ elements: + # + # a.each_element_with_text('b', 1) {|e| p e } + # + # Output: + # + # ... + # + # With all arguments given, including +xpath+, + # calls the block with only those child elements + # that meet the first two criteria, + # and also match the given +xpath+: + # + # a.each_element_with_text('b', 2, '//c') {|e| p e } + # + # Output: + # + # ... + # + def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element + each_with_something( proc {|child| + if text.nil? + child.has_text? + else + child.text == text + end + }, max, name, &block ) + end + + # :call-seq: + # each_element {|e| ... } + # + # Calls the given block with each child element: + # + # d = REXML::Document.new 'bbd' + # a = d.root + # a.each_element {|e| p e } + # + # Output: + # + # ... + # ... + # ... + # + # + def each_element( xpath=nil, &block ) # :yields: Element + @elements.each( xpath, &block ) + end + + # :call-seq: + # get_elements(xpath) + # + # Returns an array of the elements that match the given +xpath+: + # + # xml_string = <<-EOT + # + # + # + # + # + # EOT + # d = REXML::Document.new(xml_string) + # d.root.get_elements('//a') # => [ ... , ] + # + def get_elements( xpath ) + @elements.to_a( xpath ) + end + + # :call-seq: + # next_element + # + # Returns the next sibling that is an element if it exists, + # +niL+ otherwise: + # + # d = REXML::Document.new 'text' + # d.root.elements['b'].next_element #-> + # d.root.elements['c'].next_element #-> nil + # + def next_element + element = next_sibling + element = element.next_sibling until element.nil? or element.kind_of? Element + return element + end + + # :call-seq: + # previous_element + # + # Returns the previous sibling that is an element if it exists, + # +niL+ otherwise: + # + # d = REXML::Document.new 'text' + # d.root.elements['c'].previous_element #-> + # d.root.elements['b'].previous_element #-> nil + # + def previous_element + element = previous_sibling + element = element.previous_sibling until element.nil? or element.kind_of? Element + return element + end + + + ################################################# + # Text # + ################################################# + + # :call-seq: + # has_text? -> true or false + # + # Returns +true+ if the element has one or more text noded, + # +false+ otherwise: + # + # d = REXML::Document.new 'text' + # a = d.root + # a.has_text? # => true + # b = a[0] + # b.has_text? # => false + # + def has_text? + not text().nil? + end + + # :call-seq: + # text(xpath = nil) -> text_string or nil + # + # Returns the text string from the first text node child + # in a specified element, if it exists, +nil+ otherwise. + # + # With no argument, returns the text from the first text node in +self+: + # + # d = REXML::Document.new "

some text this is bold! more text

" + # d.root.text.class # => String + # d.root.text # => "some text " + # + # With argument +xpath+, returns text from the first text node + # in the element that matches +xpath+: + # + # d.root.text(1) # => "this is bold!" + # + # Note that an element may have multiple text nodes, + # possibly separated by other non-text children, as above. + # Even so, the returned value is the string text from the first such node. + # + # Note also that the text note is retrieved by method get_text, + # and so is always normalized text. + # + def text( path = nil ) + rv = get_text(path) + return rv.value unless rv.nil? + nil + end + + # :call-seq: + # get_text(xpath = nil) -> text_node or nil + # + # Returns the first text node child in a specified element, if it exists, + # +nil+ otherwise. + # + # With no argument, returns the first text node from +self+: + # + # d = REXML::Document.new "

some text this is bold! more text

" + # d.root.get_text.class # => REXML::Text + # d.root.get_text # => "some text " + # + # With argument +xpath+, returns the first text node from the element + # that matches +xpath+: + # + # d.root.get_text(1) # => "this is bold!" + # + def get_text path = nil + rv = nil + if path + element = @elements[ path ] + rv = element.get_text unless element.nil? + else + rv = @children.find { |node| node.kind_of? Text } + end + return rv + end + + # :call-seq: + # text = string -> string + # text = nil -> nil + # + # Adds, replaces, or removes the first text node child in the element. + # + # With string argument +string+, + # creates a new \REXML::Text node containing that string, + # honoring the current settings for whitespace and row, + # then places the node as the first text child in the element; + # returns +string+. + # + # If the element has no text child, the text node is added: + # + # d = REXML::Document.new '' + # d.root.text = 'foo' #-> 'foo' + # + # If the element has a text child, it is replaced: + # + # d.root.text = 'bar' #-> 'bar' + # + # With argument +nil+, removes the first text child: + # + # d.root.text = nil #-> '' + # + def text=( text ) + if text.kind_of? String + text = Text.new( text, whitespace(), nil, raw() ) + elsif !text.nil? and !text.kind_of? Text + text = Text.new( text.to_s, whitespace(), nil, raw() ) + end + old_text = get_text + if text.nil? + old_text.remove unless old_text.nil? + else + if old_text.nil? + self << text + else + old_text.replace_with( text ) + end + end + return self + end + + # :call-seq: + # add_text(string) -> nil + # add_text(text_node) -> self + # + # Adds text to the element. + # + # When string argument +string+ is given, returns +nil+. + # + # If the element has no child text node, + # creates a \REXML::Text object using the string, + # honoring the current settings for whitespace and raw, + # then adds that node to the element: + # + # d = REXML::Document.new('') + # a = d.root + # a.add_text('foo') + # a.to_a # => [, "foo"] + # + # If the element has child text nodes, + # appends the string to the _last_ text node: + # + # d = REXML::Document.new('foobar') + # a = d.root + # a.add_text('baz') + # a.to_a # => ["foo", , "barbaz"] + # a.add_text('baz') + # a.to_a # => ["foo", , "barbazbaz"] + # + # When text node argument +text_node+ is given, + # appends the node as the last text node in the element; + # returns +self+: + # + # d = REXML::Document.new('foobar') + # a = d.root + # a.add_text(REXML::Text.new('baz')) + # a.to_a # => ["foo", , "bar", "baz"] + # a.add_text(REXML::Text.new('baz')) + # a.to_a # => ["foo", , "bar", "baz", "baz"] + # + def add_text( text ) + if text.kind_of? String + if @children[-1].kind_of? Text + @children[-1] << text + return + end + text = Text.new( text, whitespace(), nil, raw() ) + end + self << text unless text.nil? + return self + end + + # :call-seq: + # node_type -> :element + # + # Returns symbol :element: + # + # d = REXML::Document.new('') + # a = d.root # => + # a.node_type # => :element + # + def node_type + :element + end + + # :call-seq: + # xpath -> string_xpath + # + # Returns the string xpath to the element + # relative to the most distant parent: + # + # d = REXML::Document.new('') + # a = d.root # => ... + # b = a[0] # => ... + # c = b[0] # => + # d.xpath # => "" + # a.xpath # => "/a" + # b.xpath # => "/a/b" + # c.xpath # => "/a/b/c" + # + # If there is no parent, returns the expanded name of the element: + # + # e = REXML::Element.new('foo') + # e.xpath # => "foo" + # + def xpath + path_elements = [] + cur = self + path_elements << __to_xpath_helper( self ) + while cur.parent + cur = cur.parent + path_elements << __to_xpath_helper( cur ) + end + return path_elements.reverse.join( "/" ) + end + + ################################################# + # Attributes # + ################################################# + + # :call-seq: + # [index] -> object + # [attr_name] -> attr_value + # [attr_sym] -> attr_value + # + # With integer argument +index+ given, + # returns the child at offset +index+, or +nil+ if none: + # + # d = REXML::Document.new '>textmore
' + # root = d.root + # (0..root.size).each do |index| + # node = root[index] + # p "#{index}: #{node} (#{node.class})" + # end + # + # Output: + # + # "0: (REXML::Element)" + # "1: text (REXML::Text)" + # "2: (REXML::Element)" + # "3: more (REXML::Text)" + # "4: (REXML::Element)" + # "5: (NilClass)" + # + # With string argument +attr_name+ given, + # returns the string value for the given attribute name if it exists, + # otherwise +nil+: + # + # d = REXML::Document.new('') + # root = d.root + # root['attr'] # => "value" + # root['nosuch'] # => nil + # + # With symbol argument +attr_sym+ given, + # returns [attr_sym.to_s]: + # + # root[:attr] # => "value" + # root[:nosuch] # => nil + # + def [](name_or_index) + case name_or_index + when String + attributes[name_or_index] + when Symbol + attributes[name_or_index.to_s] + else + super + end + end + + + # :call-seq: + # attribute(name, namespace = nil) + # + # Returns the string value for the given attribute name. + # + # With only argument +name+ given, + # returns the value of the named attribute if it exists, otherwise +nil+: + # + # xml_string = <<-EOT + # + # + # + # + #
+ # EOT + # d = REXML::Document.new(xml_string) + # root = d.root + # a = root[1] # => + # a.attribute('attr') # => attr='value' + # a.attribute('nope') # => nil + # + # With arguments +name+ and +namespace+ given, + # returns the value of the named attribute if it exists, otherwise +nil+: + # + # xml_string = "" + # document = REXML::Document.new(xml_string) + # document.root.attribute("x") # => x='x' + # document.root.attribute("x", "a") # => a:x='a:x' + # + def attribute( name, namespace=nil ) + prefix = namespaces.key(namespace) if namespace + prefix = nil if prefix == 'xmlns' + + ret_val = + attributes.get_attribute( prefix ? "#{prefix}:#{name}" : name ) + + return ret_val unless ret_val.nil? + return nil if prefix.nil? + + # now check that prefix'es namespace is not the same as the + # default namespace + return nil unless ( namespaces[ prefix ] == namespaces[ 'xmlns' ] ) + + attributes.get_attribute( name ) + + end + + # :call-seq: + # has_attributes? -> true or false + # + # Returns +true+ if the element has attributes, +false+ otherwise: + # + # d = REXML::Document.new('') + # a, b = *d.root + # a.has_attributes? # => true + # b.has_attributes? # => false + # + def has_attributes? + return !@attributes.empty? + end + + # :call-seq: + # add_attribute(name, value) -> value + # add_attribute(attribute) -> attribute + # + # Adds an attribute to this element, overwriting any existing attribute + # by the same name. + # + # With string argument +name+ and object +value+ are given, + # adds the attribute created with that name and value: + # + # e = REXML::Element.new + # e.add_attribute('attr', 'value') # => "value" + # e['attr'] # => "value" + # e.add_attribute('attr', 'VALUE') # => "VALUE" + # e['attr'] # => "VALUE" + # + # With only attribute object +attribute+ given, + # adds the given attribute: + # + # a = REXML::Attribute.new('attr', 'value') + # e.add_attribute(a) # => attr='value' + # e['attr'] # => "value" + # a = REXML::Attribute.new('attr', 'VALUE') + # e.add_attribute(a) # => attr='VALUE' + # e['attr'] # => "VALUE" + # + def add_attribute( key, value=nil ) + if key.kind_of? Attribute + @attributes << key + else + @attributes[key] = value + end + end + + # :call-seq: + # add_attributes(hash) -> hash + # add_attributes(array) + # + # Adds zero or more attributes to the element; + # returns the argument. + # + # If hash argument +hash+ is given, + # each key must be a string; + # adds each attribute created with the key/value pair: + # + # e = REXML::Element.new + # h = {'foo' => 'bar', 'baz' => 'bat'} + # e.add_attributes(h) + # + # If argument +array+ is given, + # each array member must be a 2-element array [name, value]; + # each name must be a string: + # + # e = REXML::Element.new + # a = [['foo' => 'bar'], ['baz' => 'bat']] + # e.add_attributes(a) + # + def add_attributes hash + if hash.kind_of? Hash + hash.each_pair {|key, value| @attributes[key] = value } + elsif hash.kind_of? Array + hash.each { |value| @attributes[ value[0] ] = value[1] } + end + end + + # :call-seq: + # delete_attribute(name) -> removed_attribute or nil + # + # Removes a named attribute if it exists; + # returns the removed attribute if found, otherwise +nil+: + # + # e = REXML::Element.new('foo') + # e.add_attribute('bar', 'baz') + # e.delete_attribute('bar') # => + # e.delete_attribute('bar') # => nil + # + def delete_attribute(key) + attr = @attributes.get_attribute(key) + attr.remove unless attr.nil? + end + + ################################################# + # Other Utilities # + ################################################# + + # :call-seq: + # cdatas -> array_of_cdata_children + # + # Returns a frozen array of the REXML::CData children of the element: + # + # xml_string = <<-EOT + # + # + # + # + # EOT + # d = REXML::Document.new(xml_string) + # cds = d.root.cdatas # => ["foo", "bar"] + # cds.frozen? # => true + # cds.map {|cd| cd.class } # => [REXML::CData, REXML::CData] + # + def cdatas + find_all { |child| child.kind_of? CData }.freeze + end + + # :call-seq: + # comments -> array_of_comment_children + # + # Returns a frozen array of the REXML::Comment children of the element: + # + # xml_string = <<-EOT + # + # + # + # + # EOT + # d = REXML::Document.new(xml_string) + # cs = d.root.comments + # cs.frozen? # => true + # cs.map {|c| c.class } # => [REXML::Comment, REXML::Comment] + # cs.map {|c| c.to_s } # => ["foo", "bar"] + # + def comments + find_all { |child| child.kind_of? Comment }.freeze + end + + # :call-seq: + # instructions -> array_of_instruction_children + # + # Returns a frozen array of the REXML::Instruction children of the element: + # + # xml_string = <<-EOT + # + # + # + # + # EOT + # d = REXML::Document.new(xml_string) + # is = d.root.instructions + # is.frozen? # => true + # is.map {|i| i.class } # => [REXML::Instruction, REXML::Instruction] + # is.map {|i| i.to_s } # => ["", ""] + # + def instructions + find_all { |child| child.kind_of? Instruction }.freeze + end + + # :call-seq: + # texts -> array_of_text_children + # + # Returns a frozen array of the REXML::Text children of the element: + # + # xml_string = 'textmore' + # d = REXML::Document.new(xml_string) + # ts = d.root.texts + # ts.frozen? # => true + # ts.map {|t| t.class } # => [REXML::Text, REXML::Text] + # ts.map {|t| t.to_s } # => ["text", "more"] + # + def texts + find_all { |child| child.kind_of? Text }.freeze + end + + # == DEPRECATED + # See REXML::Formatters + # + # Writes out this element, and recursively, all children. + # output:: + # output an object which supports '<< string'; this is where the + # document will be written. + # indent:: + # An integer. If -1, no indenting will be used; otherwise, the + # indentation will be this number of spaces, and children will be + # indented an additional amount. Defaults to -1 + # transitive:: + # If transitive is true and indent is >= 0, then the output will be + # pretty-printed in such a way that the added whitespace does not affect + # the parse tree of the document + # ie_hack:: + # This hack inserts a space before the /> on empty tags to address + # a limitation of Internet Explorer. Defaults to false + # + # out = '' + # doc.write( out ) #-> doc is written to the string 'out' + # doc.write( $stdout ) #-> doc written to the console + def write(output=$stdout, indent=-1, transitive=false, ie_hack=false) + Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters", uplevel: 1) + formatter = if indent > -1 + if transitive + require_relative "formatters/transitive" + REXML::Formatters::Transitive.new( indent, ie_hack ) + else + REXML::Formatters::Pretty.new( indent, ie_hack ) + end + else + REXML::Formatters::Default.new( ie_hack ) + end + formatter.write( self, output ) + end + + + private + def __to_xpath_helper node + rv = node.expanded_name.clone + if node.parent + results = node.parent.find_all {|n| + n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name + } + if results.length > 1 + idx = results.index( node ) + rv << "[#{idx+1}]" + end + end + rv + end + + # A private helper method + def each_with_something( test, max=0, name=nil ) + num = 0 + @elements.each( name ){ |child| + yield child if test.call(child) and num += 1 + return if max>0 and num == max + } + end + end + + ######################################################################## + # ELEMENTS # + ######################################################################## + + # A class which provides filtering of children for Elements, and + # XPath search support. You are expected to only encounter this class as + # the element.elements object. Therefore, you are + # _not_ expected to instantiate this yourself. + # + # xml_string = <<-EOT + # + # + # + # Everyday Italian + # Giada De Laurentiis + # 2005 + # 30.00 + # + # + # Harry Potter + # J K. Rowling + # 2005 + # 29.99 + # + # + # XQuery Kick Start + # James McGovern + # Per Bothner + # Kurt Cagle + # James Linn + # Vaidyanathan Nagarajan + # 2003 + # 49.99 + # + # + # Learning XML + # Erik T. Ray + # 2003 + # 39.95 + # + # + # EOT + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements # => # ... > + # + class Elements + include Enumerable + # :call-seq: + # new(parent) -> new_elements_object + # + # Returns a new \Elements object with the given +parent+. + # Does _not_ assign parent.elements = self: + # + # d = REXML::Document.new(xml_string) + # eles = REXML::Elements.new(d.root) + # eles # => # ... > + # eles == d.root.elements # => false + # + def initialize parent + @element = parent + end + + # :call-seq: + # parent + # + # Returns the parent element cited in creating the \Elements object. + # This element is also the default starting point for searching + # in the \Elements object. + # + # d = REXML::Document.new(xml_string) + # elements = REXML::Elements.new(d.root) + # elements.parent == d.root # => true + # + def parent + @element + end + + # :call-seq: + # elements[index] -> element or nil + # elements[xpath] -> element or nil + # elements[n, name] -> element or nil + # + # Returns the first \Element object selected by the arguments, + # if any found, or +nil+ if none found. + # + # Notes: + # - The +index+ is 1-based, not 0-based, so that: + # - The first element has index 1 + # - The _nth_ element has index +n+. + # - The selection ignores non-\Element nodes. + # + # When the single argument +index+ is given, + # returns the element given by the index, if any; otherwise, +nil+: + # + # d = REXML::Document.new(xml_string) + # eles = d.root.elements + # eles # => # ... > + # eles[1] # => ... + # eles.size # => 4 + # eles[4] # => ... + # eles[5] # => nil + # + # The node at this index is not an \Element, and so is not returned: + # + # eles = d.root.first.first # => ... </> + # eles.to_a # => ["Everyday Italian"] + # eles[1] # => nil + # + # When the single argument +xpath+ is given, + # returns the first element found via that +xpath+, if any; otherwise, +nil+: + # + # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>> + # eles['/bookstore'] # => <bookstore> ... </> + # eles['//book'] # => <book category='cooking'> ... </> + # eles['//book [@category="children"]'] # => <book category='children'> ... </> + # eles['/nosuch'] # => nil + # eles['//nosuch'] # => nil + # eles['//book [@category="nosuch"]'] # => nil + # eles['.'] # => <bookstore> ... </> + # eles['..'].class # => REXML::Document + # + # With arguments +n+ and +name+ given, + # returns the _nth_ found element that has the given +name+, + # or +nil+ if there is no such _nth_ element: + # + # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>> + # eles[1, 'book'] # => <book category='cooking'> ... </> + # eles[4, 'book'] # => <book category='web' cover='paperback'> ... </> + # eles[5, 'book'] # => nil + # + def []( index, name=nil) + if index.kind_of? Integer + raise "index (#{index}) must be >= 1" if index < 1 + name = literalize(name) if name + num = 0 + @element.find { |child| + child.kind_of? Element and + (name.nil? ? true : child.has_name?( name )) and + (num += 1) == index + } + else + return XPath::first( @element, index ) + #{ |element| + # return element if element.kind_of? Element + #} + #return nil + end + end + + # :call-seq: + # elements[] = index, replacement_element -> replacement_element or nil + # + # Replaces or adds an element. + # + # When <tt>eles[index]</tt> exists, replaces it with +replacement_element+ + # and returns +replacement_element+: + # + # d = REXML::Document.new(xml_string) + # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>> + # eles[1] # => <book category='cooking'> ... </> + # eles[1] = REXML::Element.new('foo') + # eles[1] # => <foo/> + # + # Does nothing (or raises an exception) + # if +replacement_element+ is not an \Element: + # eles[2] # => <book category='web' cover='paperback'> ... </> + # eles[2] = REXML::Text.new('bar') + # eles[2] # => <book category='web' cover='paperback'> ... </> + # + # When <tt>eles[index]</tt> does not exist, + # adds +replacement_element+ to the element and returns + # + # d = REXML::Document.new(xml_string) + # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>> + # eles.size # => 4 + # eles[50] = REXML::Element.new('foo') # => <foo/> + # eles.size # => 5 + # eles[5] # => <foo/> + # + # Does nothing (or raises an exception) + # if +replacement_element+ is not an \Element: + # + # eles[50] = REXML::Text.new('bar') # => "bar" + # eles.size # => 5 + # + def []=( index, element ) + previous = self[index] + if previous.nil? + @element.add element + else + previous.replace_with element + end + return previous + end + + # :call-seq: + # empty? -> true or false + # + # Returns +true+ if there are no children, +false+ otherwise. + # + # d = REXML::Document.new('') + # d.elements.empty? # => true + # d = REXML::Document.new(xml_string) + # d.elements.empty? # => false + # + def empty? + @element.find{ |child| child.kind_of? Element}.nil? + end + + # :call-seq: + # index(element) + # + # Returns the 1-based index of the given +element+, if found; + # otherwise, returns -1: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # ele_1, ele_2, ele_3, ele_4 = *elements + # elements.index(ele_4) # => 4 + # elements.delete(ele_3) + # elements.index(ele_4) # => 3 + # elements.index(ele_3) # => -1 + # + def index element + rv = 0 + found = @element.find do |child| + child.kind_of? Element and + (rv += 1) and + child == element + end + return rv if found == element + return -1 + end + + # :call-seq: + # delete(index) -> removed_element or nil + # delete(element) -> removed_element or nil + # delete(xpath) -> removed_element or nil + # + # Removes an element; returns the removed element, or +nil+ if none removed. + # + # With integer argument +index+ given, + # removes the child element at that offset: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements.size # => 4 + # elements[2] # => <book category='children'> ... </> + # elements.delete(2) # => <book category='children'> ... </> + # elements.size # => 3 + # elements[2] # => <book category='web'> ... </> + # elements.delete(50) # => nil + # + # With element argument +element+ given, + # removes that child element: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # ele_1, ele_2, ele_3, ele_4 = *elements + # elements.size # => 4 + # elements[2] # => <book category='children'> ... </> + # elements.delete(ele_2) # => <book category='children'> ... </> + # elements.size # => 3 + # elements[2] # => <book category='web'> ... </> + # elements.delete(ele_2) # => nil + # + # With string argument +xpath+ given, + # removes the first element found via that xpath: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements.delete('//book') # => <book category='cooking'> ... </> + # elements.delete('//book [@category="children"]') # => <book category='children'> ... </> + # elements.delete('//nosuch') # => nil + # + def delete element + if element.kind_of? Element + @element.delete element + else + el = self[element] + el.remove if el + end + end + + # :call-seq: + # delete_all(xpath) + # + # Removes all elements found via the given +xpath+; + # returns the array of removed elements, if any, else +nil+. + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements.size # => 4 + # deleted_elements = elements.delete_all('//book [@category="web"]') + # deleted_elements.size # => 2 + # elements.size # => 2 + # deleted_elements = elements.delete_all('//book') + # deleted_elements.size # => 2 + # elements.size # => 0 + # elements.delete_all('//book') # => [] + # + def delete_all( xpath ) + rv = [] + XPath::each( @element, xpath) {|element| + rv << element if element.kind_of? Element + } + rv.each do |element| + @element.delete element + element.remove + end + return rv + end + + # :call-seq: + # add -> new_element + # add(name) -> new_element + # add(element) -> element + # + # Adds an element; returns the element added. + # + # With no argument, creates and adds a new element. + # The new element has: + # + # - No name. + # - \Parent from the \Elements object. + # - Context from the that parent. + # + # Example: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # parent = elements.parent # => <bookstore> ... </> + # parent.context = {raw: :all} + # elements.size # => 4 + # new_element = elements.add # => </> + # elements.size # => 5 + # new_element.name # => nil + # new_element.parent # => <bookstore> ... </> + # new_element.context # => {:raw=>:all} + # + # With string argument +name+, creates and adds a new element. + # The new element has: + # + # - Name +name+. + # - \Parent from the \Elements object. + # - Context from the that parent. + # + # Example: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # parent = elements.parent # => <bookstore> ... </> + # parent.context = {raw: :all} + # elements.size # => 4 + # new_element = elements.add('foo') # => <foo/> + # elements.size # => 5 + # new_element.name # => "foo" + # new_element.parent # => <bookstore> ... </> + # new_element.context # => {:raw=>:all} + # + # With argument +element+, + # creates and adds a clone of the given +element+. + # The new element has name, parent, and context from the given +element+. + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements.size # => 4 + # e0 = REXML::Element.new('foo') + # e1 = REXML::Element.new('bar', e0, {raw: :all}) + # element = elements.add(e1) # => <bar/> + # elements.size # => 5 + # element.name # => "bar" + # element.parent # => <bookstore> ... </> + # element.context # => {:raw=>:all} + # + def add element=nil + if element.nil? + Element.new("", self, @element.context) + elsif not element.kind_of?(Element) + Element.new(element, self, @element.context) + else + @element << element + element.context = @element.context + element + end + end + + alias :<< :add + + # :call-seq: + # each(xpath = nil) {|element| ... } -> self + # + # Iterates over the elements. + # + # With no argument, calls the block with each element: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements.each {|element| p element } + # + # Output: + # + # <book category='cooking'> ... </> + # <book category='children'> ... </> + # <book category='web'> ... </> + # <book category='web' cover='paperback'> ... </> + # + # With argument +xpath+, calls the block with each element + # that matches the given +xpath+: + # + # elements.each('//book [@category="web"]') {|element| p element } + # + # Output: + # + # <book category='web'> ... </> + # <book category='web' cover='paperback'> ... </> + # + def each( xpath=nil ) + XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element } + end + + # :call-seq: + # collect(xpath = nil) {|element| ... } -> array + # + # Iterates over the elements; returns the array of block return values. + # + # With no argument, iterates over all elements: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements.collect {|element| element.size } # => [9, 9, 17, 9] + # + # With argument +xpath+, iterates over elements that match + # the given +xpath+: + # + # xpath = '//book [@category="web"]' + # elements.collect(xpath) {|element| element.size } # => [17, 9] + # + def collect( xpath=nil ) + collection = [] + XPath::each( @element, xpath ) {|e| + collection << yield(e) if e.kind_of?(Element) + } + collection + end + + # :call-seq: + # inject(xpath = nil, initial = nil) -> object + # + # Calls the block with elements; returns the last block return value. + # + # With no argument, iterates over the elements, calling the block + # <tt>elements.size - 1</tt> times. + # + # - The first call passes the first and second elements. + # - The second call passes the first block return value and the third element. + # - The third call passes the second block return value and the fourth element. + # - And so on. + # + # In this example, the block returns the passed element, + # which is then the object argument to the next call: + # + # d = REXML::Document.new(xml_string) + # elements = d.root.elements + # elements.inject do |object, element| + # p [elements.index(object), elements.index(element)] + # element + # end + # + # Output: + # + # [1, 2] + # [2, 3] + # [3, 4] + # + # With the single argument +xpath+, calls the block only with + # elements matching that xpath: + # + # elements.inject('//book [@category="web"]') do |object, element| + # p [elements.index(object), elements.index(element)] + # element + # end + # + # Output: + # + # [3, 4] + # + # With argument +xpath+ given as +nil+ + # and argument +initial+ also given, + # calls the block once for each element. + # + # - The first call passes the +initial+ and the first element. + # - The second call passes the first block return value and the second element. + # - The third call passes the second block return value and the third element. + # - And so on. + # + # In this example, the first object index is <tt>-1</tt> + # + # elements.inject(nil, 'Initial') do |object, element| + # p [elements.index(object), elements.index(element)] + # element + # end + # + # Output: + # + # [-1, 1] + # [1, 2] + # [2, 3] + # [3, 4] + # + # In this form the passed object can be used as an accumulator: + # + # elements.inject(nil, 0) do |total, element| + # total += element.size + # end # => 44 + # + # With both arguments +xpath+ and +initial+ are given, + # calls the block only with elements matching that xpath: + # + # elements.inject('//book [@category="web"]', 0) do |total, element| + # total += element.size + # end # => 26 + # + def inject( xpath=nil, initial=nil ) + first = true + XPath::each( @element, xpath ) {|e| + if (e.kind_of? Element) + if (first and initial == nil) + initial = e + first = false + else + initial = yield( initial, e ) if e.kind_of? Element + end + end + } + initial + end + + # :call-seq: + # size -> integer + # + # Returns the count of \Element children: + # + # d = REXML::Document.new '<a>sean<b/>elliott<b/>russell<b/></a>' + # d.root.elements.size # => 3 # Three elements. + # d.root.size # => 6 # Three elements plus three text nodes.. + # + def size + count = 0 + @element.each {|child| count+=1 if child.kind_of? Element } + count + end + + # :call-seq: + # to_a(xpath = nil) -> array_of_elements + # + # Returns an array of element children (not including non-element children). + # + # With no argument, returns an array of all element children: + # + # d = REXML::Document.new '<a>sean<b/>elliott<c/></a>' + # elements = d.root.elements + # elements.to_a # => [<b/>, <c/>] # Omits non-element children. + # children = d.root.children + # children # => ["sean", <b/>, "elliott", <c/>] # Includes non-element children. + # + # With argument +xpath+, returns an array of element children + # that match the xpath: + # + # elements.to_a('//c') # => [<c/>] + # + def to_a( xpath=nil ) + rv = XPath.match( @element, xpath ) + return rv.find_all{|e| e.kind_of? Element} if xpath + rv + end + + private + # Private helper class. Removes quotes from quoted strings + def literalize name + name = name[1..-2] if name[0] == ?' or name[0] == ?" #' + name + end + end + + ######################################################################## + # ATTRIBUTES # + ######################################################################## + + # A class that defines the set of Attributes of an Element and provides + # operations for accessing elements in that set. + class Attributes < Hash + + # :call-seq: + # new(element) + # + # Creates and returns a new \REXML::Attributes object. + # The element given by argument +element+ is stored, + # but its own attributes are not modified: + # + # ele = REXML::Element.new('foo') + # attrs = REXML::Attributes.new(ele) + # attrs.object_id == ele.attributes.object_id # => false + # + # Other instance methods in class \REXML::Attributes may refer to: + # + # - +element.document+. + # - +element.prefix+. + # - +element.expanded_name+. + # + def initialize element + @element = element + end + + # :call-seq: + # [name] -> attribute_value or nil + # + # Returns the value for the attribute given by +name+, + # if it exists; otherwise +nil+. + # The value returned is the unnormalized attribute value, + # with entities expanded: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # ele.attributes['att'] # => "<" + # ele.attributes['bar:att'] # => "2" + # ele.attributes['nosuch'] # => nil + # + # Related: get_attribute (returns an \Attribute object). + # + def [](name) + attr = get_attribute(name) + return attr.value unless attr.nil? + return nil + end + + # :call-seq: + # to_a -> array_of_attribute_objects + # + # Returns an array of \REXML::Attribute objects representing + # the attributes: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # attrs = ele.attributes.to_a # => [foo:att='1', bar:att='2', att='<'] + # attrs.first.class # => REXML::Attribute + # + def to_a + enum_for(:each_attribute).to_a + end + + # :call-seq: + # length + # + # Returns the count of attributes: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # ele.attributes.length # => 3 + # + def length + c = 0 + each_attribute { c+=1 } + c + end + alias :size :length + + # :call-seq: + # each_attribute {|attr| ... } + # + # Calls the given block with each \REXML::Attribute object: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # ele.attributes.each_attribute do |attr| + # p [attr.class, attr] + # end + # + # Output: + # + # [REXML::Attribute, foo:att='1'] + # [REXML::Attribute, bar:att='2'] + # [REXML::Attribute, att='<'] + # + def each_attribute # :yields: attribute + return to_enum(__method__) unless block_given? + each_value do |val| + if val.kind_of? Attribute + yield val + else + val.each_value { |atr| yield atr } + end + end + end + + # :call-seq: + # each {|expanded_name, value| ... } + # + # Calls the given block with each expanded-name/value pair: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # ele.attributes.each do |expanded_name, value| + # p [expanded_name, value] + # end + # + # Output: + # + # ["foo:att", "1"] + # ["bar:att", "2"] + # ["att", "<"] + # + def each + return to_enum(__method__) unless block_given? + each_attribute do |attr| + yield [attr.expanded_name, attr.value] + end + end + + # :call-seq: + # get_attribute(name) -> attribute_object or nil + # + # Returns the \REXML::Attribute object for the given +name+: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # attrs = ele.attributes + # attrs.get_attribute('foo:att') # => foo:att='1' + # attrs.get_attribute('foo:att').class # => REXML::Attribute + # attrs.get_attribute('bar:att') # => bar:att='2' + # attrs.get_attribute('att') # => att='<' + # attrs.get_attribute('nosuch') # => nil + # + def get_attribute( name ) + attr = fetch( name, nil ) + if attr.nil? + return nil if name.nil? + # Look for prefix + name =~ Namespace::NAMESPLIT + prefix, n = $1, $2 + if prefix + attr = fetch( n, nil ) + # check prefix + if attr == nil + elsif attr.kind_of? Attribute + return attr if prefix == attr.prefix + else + attr = attr[ prefix ] + return attr + end + end + element_document = @element.document + if element_document and element_document.doctype + expn = @element.expanded_name + expn = element_document.doctype.name if expn.size == 0 + attr_val = element_document.doctype.attribute_of(expn, name) + return Attribute.new( name, attr_val ) if attr_val + end + return nil + end + if attr.kind_of? Hash + attr = attr[ @element.prefix ] + end + return attr + end + + # :call-seq: + # [name] = value -> value + # + # When +value+ is non-+nil+, + # assigns that to the attribute for the given +name+, + # overwriting the previous value if it exists: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # attrs = ele.attributes + # attrs['foo:att'] = '2' # => "2" + # attrs['baz:att'] = '3' # => "3" + # + # When +value+ is +nil+, deletes the attribute if it exists: + # + # attrs['baz:att'] = nil + # attrs.include?('baz:att') # => false + # + def []=( name, value ) + if value.nil? # Delete the named attribute + attr = get_attribute(name) + delete attr + return + end + + unless value.kind_of? Attribute + if @element.document and @element.document.doctype + value = Text::normalize( value, @element.document.doctype ) + else + value = Text::normalize( value, nil ) + end + value = Attribute.new(name, value) + end + value.element = @element + old_attr = fetch(value.name, nil) + if old_attr.nil? + store(value.name, value) + elsif old_attr.kind_of? Hash + old_attr[value.prefix] = value + elsif old_attr.prefix != value.prefix + # Check for conflicting namespaces + if value.prefix != "xmlns" and old_attr.prefix != "xmlns" + old_namespace = old_attr.namespace + new_namespace = value.namespace + if old_namespace == new_namespace + raise ParseException.new( + "Namespace conflict in adding attribute \"#{value.name}\": "+ + "Prefix \"#{old_attr.prefix}\" = \"#{old_namespace}\" and "+ + "prefix \"#{value.prefix}\" = \"#{new_namespace}\"") + end + end + store value.name, {old_attr.prefix => old_attr, + value.prefix => value} + else + store value.name, value + end + return @element + end + + # :call-seq: + # prefixes -> array_of_prefix_strings + # + # Returns an array of prefix strings in the attributes. + # The array does not include the default + # namespace declaration, if one exists. + # + # xml_string = '<a xmlns="foo" xmlns:x="bar" xmlns:y="twee" z="glorp"/>' + # d = REXML::Document.new(xml_string) + # d.root.attributes.prefixes # => ["x", "y"] + # + def prefixes + ns = [] + each_attribute do |attribute| + ns << attribute.name if attribute.prefix == 'xmlns' + end + if @element.document and @element.document.doctype + expn = @element.expanded_name + expn = @element.document.doctype.name if expn.size == 0 + @element.document.doctype.attributes_of(expn).each { + |attribute| + ns << attribute.name if attribute.prefix == 'xmlns' + } + end + ns + end + + # :call-seq: + # namespaces + # + # Returns a hash of name/value pairs for the namespaces: + # + # xml_string = '<a xmlns="foo" xmlns:x="bar" xmlns:y="twee" z="glorp"/>' + # d = REXML::Document.new(xml_string) + # d.root.attributes.namespaces # => {"xmlns"=>"foo", "x"=>"bar", "y"=>"twee"} + # + def namespaces + namespaces = {} + each_attribute do |attribute| + namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns' + end + if @element.document and @element.document.doctype + expn = @element.expanded_name + expn = @element.document.doctype.name if expn.size == 0 + @element.document.doctype.attributes_of(expn).each { + |attribute| + namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns' + } + end + namespaces + end + + # :call-seq: + # delete(name) -> element + # delete(attribute) -> element + # + # Removes a specified attribute if it exists; + # returns the attributes' element. + # + # When string argument +name+ is given, + # removes the attribute of that name if it exists: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # attrs = ele.attributes + # attrs.delete('foo:att') # => <ele bar:att='2' att='<'/> + # attrs.delete('foo:att') # => <ele bar:att='2' att='<'/> + # + # When attribute argument +attribute+ is given, + # removes that attribute if it exists: + # + # attr = REXML::Attribute.new('bar:att', '2') + # attrs.delete(attr) # => <ele att='<'/> # => <ele att='<'/> + # attrs.delete(attr) # => <ele att='<'/> # => <ele/> + # + def delete( attribute ) + name = nil + prefix = nil + if attribute.kind_of? Attribute + name = attribute.name + prefix = attribute.prefix + else + attribute =~ Namespace::NAMESPLIT + prefix, name = $1, $2 + prefix = '' unless prefix + end + old = fetch(name, nil) + if old.kind_of? Hash # the supplied attribute is one of many + old.delete(prefix) + if old.size == 1 + repl = nil + old.each_value{|v| repl = v} + store name, repl + end + elsif old.nil? + return @element + else # the supplied attribute is a top-level one + super(name) + end + @element + end + + # :call-seq: + # add(attribute) -> attribute + # + # Adds attribute +attribute+, replacing the previous + # attribute of the same name if it exists; + # returns +attribute+: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # attrs = ele.attributes + # attrs # => {"att"=>{"foo"=>foo:att='1', "bar"=>bar:att='2', ""=>att='<'}} + # attrs.add(REXML::Attribute.new('foo:att', '2')) # => foo:att='2' + # attrs.add(REXML::Attribute.new('baz', '3')) # => baz='3' + # attrs.include?('baz') # => true + # + def add( attribute ) + self[attribute.name] = attribute + end + + alias :<< :add + + # :call-seq: + # delete_all(name) -> array_of_removed_attributes + # + # Removes all attributes matching the given +name+; + # returns an array of the removed attributes: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # attrs = ele.attributes + # attrs.delete_all('att') # => [att='<'] + # + def delete_all( name ) + rv = [] + each_attribute { |attribute| + rv << attribute if attribute.expanded_name == name + } + rv.each{ |attr| attr.remove } + return rv + end + + # :call-seq: + # get_attribute_ns(namespace, name) + # + # Returns the \REXML::Attribute object among the attributes + # that matches the given +namespace+ and +name+: + # + # xml_string = <<-EOT + # <root xmlns:foo="http://foo" xmlns:bar="http://bar"> + # <ele foo:att='1' bar:att='2' att='<'/> + # </root> + # EOT + # d = REXML::Document.new(xml_string) + # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/> + # attrs = ele.attributes + # attrs.get_attribute_ns('http://foo', 'att') # => foo:att='1' + # attrs.get_attribute_ns('http://foo', 'nosuch') # => nil + # + def get_attribute_ns(namespace, name) + result = nil + each_attribute() { |attribute| + if name == attribute.name && + namespace == attribute.namespace() && + ( !namespace.empty? || !attribute.fully_expanded_name.index(':') ) + # foo will match xmlns:foo, but only if foo isn't also an attribute + result = attribute if !result or !namespace.empty? or + !attribute.fully_expanded_name.index(':') + end + } + result + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/encoding.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/encoding.rb new file mode 100644 index 0000000..da2d70d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/encoding.rb @@ -0,0 +1,51 @@ +# coding: US-ASCII +# frozen_string_literal: false +module REXML + module Encoding + # ID ---> Encoding name + attr_reader :encoding + def encoding=(encoding) + encoding = encoding.name if encoding.is_a?(Encoding) + if encoding.is_a?(String) + original_encoding = encoding + encoding = find_encoding(encoding) + unless encoding + raise ArgumentError, "Bad encoding name #{original_encoding}" + end + end + return false if defined?(@encoding) and encoding == @encoding + if encoding + @encoding = encoding.upcase + else + @encoding = 'UTF-8' + end + true + end + + def encode(string) + string.encode(@encoding) + end + + def decode(string) + string.encode(::Encoding::UTF_8, @encoding) + end + + private + def find_encoding(name) + case name + when /\Ashift-jis\z/i + return "SHIFT_JIS" + when /\ACP-(\d+)\z/ + name = "CP#{$1}" + when /\AUTF-8\z/i + return name + end + begin + ::Encoding::Converter.search_convpath(name, 'UTF-8') + rescue ::Encoding::ConverterNotFoundError + return nil + end + name + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/entity.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/entity.rb new file mode 100644 index 0000000..573db69 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/entity.rb @@ -0,0 +1,181 @@ +# frozen_string_literal: false +require_relative 'child' +require_relative 'source' +require_relative 'xmltokens' + +module REXML + class Entity < Child + include XMLTokens + PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#" + SYSTEMLITERAL = %Q{((?:"[^"]*")|(?:'[^']*'))} + PUBIDLITERAL = %Q{("[#{PUBIDCHAR}']*"|'[#{PUBIDCHAR}]*')} + EXTERNALID = "(?:(?:(SYSTEM)\\s+#{SYSTEMLITERAL})|(?:(PUBLIC)\\s+#{PUBIDLITERAL}\\s+#{SYSTEMLITERAL}))" + NDATADECL = "\\s+NDATA\\s+#{NAME}" + PEREFERENCE = "%#{NAME};" + ENTITYVALUE = %Q{((?:"(?:[^%&"]|#{PEREFERENCE}|#{REFERENCE})*")|(?:'([^%&']|#{PEREFERENCE}|#{REFERENCE})*'))} + PEDEF = "(?:#{ENTITYVALUE}|#{EXTERNALID})" + ENTITYDEF = "(?:#{ENTITYVALUE}|(?:#{EXTERNALID}(#{NDATADECL})?))" + PEDECL = "<!ENTITY\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>" + GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>" + ENTITYDECL = /\s*(?:#{GEDECL})|(?:#{PEDECL})/um + + attr_reader :name, :external, :ref, :ndata, :pubid + + # Create a new entity. Simple entities can be constructed by passing a + # name, value to the constructor; this creates a generic, plain entity + # reference. For anything more complicated, you have to pass a Source to + # the constructor with the entity definition, or use the accessor methods. + # +WARNING+: There is no validation of entity state except when the entity + # is read from a stream. If you start poking around with the accessors, + # you can easily create a non-conformant Entity. + # + # e = Entity.new( 'amp', '&' ) + def initialize stream, value=nil, parent=nil, reference=false + super(parent) + @ndata = @pubid = @value = @external = nil + if stream.kind_of? Array + @name = stream[1] + if stream[-1] == '%' + @reference = true + stream.pop + else + @reference = false + end + if stream[2] =~ /SYSTEM|PUBLIC/ + @external = stream[2] + if @external == 'SYSTEM' + @ref = stream[3] + @ndata = stream[4] if stream.size == 5 + else + @pubid = stream[3] + @ref = stream[4] + end + else + @value = stream[2] + end + else + @reference = reference + @external = nil + @name = stream + @value = value + end + end + + # Evaluates whether the given string matches an entity definition, + # returning true if so, and false otherwise. + def Entity::matches? string + (ENTITYDECL =~ string) == 0 + end + + # Evaluates to the unnormalized value of this entity; that is, replacing + # all entities -- both %ent; and &ent; entities. This differs from + # +value()+ in that +value+ only replaces %ent; entities. + def unnormalized + document.record_entity_expansion unless document.nil? + v = value() + return nil if v.nil? + @unnormalized = Text::unnormalize(v, parent) + @unnormalized + end + + #once :unnormalized + + # Returns the value of this entity unprocessed -- raw. This is the + # normalized value; that is, with all %ent; and &ent; entities intact + def normalized + @value + end + + # Write out a fully formed, correct entity definition (assuming the Entity + # object itself is valid.) + # + # out:: + # An object implementing <TT><<</TT> to which the entity will be + # output + # indent:: + # *DEPRECATED* and ignored + def write out, indent=-1 + out << '<!ENTITY ' + out << '% ' if @reference + out << @name + out << ' ' + if @external + out << @external << ' ' + if @pubid + q = @pubid.include?('"')?"'":'"' + out << q << @pubid << q << ' ' + end + q = @ref.include?('"')?"'":'"' + out << q << @ref << q + out << ' NDATA ' << @ndata if @ndata + else + q = @value.include?('"')?"'":'"' + out << q << @value << q + end + out << '>' + end + + # Returns this entity as a string. See write(). + def to_s + rv = '' + write rv + rv + end + + PEREFERENCE_RE = /#{PEREFERENCE}/um + # Returns the value of this entity. At the moment, only internal entities + # are processed. If the value contains internal references (IE, + # %blah;), those are replaced with their values. IE, if the doctype + # contains: + # <!ENTITY % foo "bar"> + # <!ENTITY yada "nanoo %foo; nanoo> + # then: + # doctype.entity('yada').value #-> "nanoo bar nanoo" + def value + @resolved_value ||= resolve_value + end + + def parent=(other) + @resolved_value = nil + super + end + + private + def resolve_value + return nil if @value.nil? + return @value unless @value.match?(PEREFERENCE_RE) + + matches = @value.scan(PEREFERENCE_RE) + rv = @value.clone + if @parent + sum = 0 + matches.each do |entity_reference| + entity_value = @parent.entity( entity_reference[0] ) + if sum + entity_value.bytesize > Security.entity_expansion_text_limit + raise "entity expansion has grown too large" + else + sum += entity_value.bytesize + end + rv.gsub!( /%#{entity_reference.join};/um, entity_value ) + end + end + rv + end + end + + # This is a set of entity constants -- the ones defined in the XML + # specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+. + # CAUTION: these entities does not have parent and document + module EntityConst + # +>+ + GT = Entity.new( 'gt', '>' ) + # +<+ + LT = Entity.new( 'lt', '<' ) + # +&+ + AMP = Entity.new( 'amp', '&' ) + # +"+ + QUOT = Entity.new( 'quot', '"' ) + # +'+ + APOS = Entity.new( 'apos', "'" ) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/default.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/default.rb new file mode 100644 index 0000000..811b2ff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/default.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: false + +module REXML + module Formatters + class Default + # Prints out the XML document with no formatting -- except if ie_hack is + # set. + # + # ie_hack:: + # If set to true, then inserts whitespace before the close of an empty + # tag, so that IE's bad XML parser doesn't choke. + def initialize( ie_hack=false ) + @ie_hack = ie_hack + end + + # Writes the node to some output. + # + # node:: + # The node to write + # output:: + # A class implementing <TT><<</TT>. Pass in an Output object to + # change the output encoding. + def write( node, output ) + case node + + when Document + if node.xml_decl.encoding != 'UTF-8' && !output.kind_of?(Output) + output = Output.new( output, node.xml_decl.encoding ) + end + write_document( node, output ) + + when Element + write_element( node, output ) + + when Declaration, ElementDecl, NotationDecl, ExternalEntity, Entity, + Attribute, AttlistDecl + node.write( output,-1 ) + + when Instruction + write_instruction( node, output ) + + when DocType, XMLDecl + node.write( output ) + + when Comment + write_comment( node, output ) + + when CData + write_cdata( node, output ) + + when Text + write_text( node, output ) + + else + raise Exception.new("XML FORMATTING ERROR") + + end + end + + protected + def write_document( node, output ) + node.children.each { |child| write( child, output ) } + end + + def write_element( node, output ) + output << "<#{node.expanded_name}" + + node.attributes.to_a.map { |a| + Hash === a ? a.values : a + }.flatten.sort_by {|attr| attr.name}.each do |attr| + output << " " + attr.write( output ) + end unless node.attributes.empty? + + if node.children.empty? + output << " " if @ie_hack + output << "/" + else + output << ">" + node.children.each { |child| + write( child, output ) + } + output << "</#{node.expanded_name}" + end + output << ">" + end + + def write_text( node, output ) + output << node.to_s() + end + + def write_comment( node, output ) + output << Comment::START + output << node.to_s + output << Comment::STOP + end + + def write_cdata( node, output ) + output << CData::START + output << node.to_s + output << CData::STOP + end + + def write_instruction( node, output ) + output << Instruction::START + output << node.target + content = node.content + if content + output << ' ' + output << content + end + output << Instruction::STOP + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/pretty.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/pretty.rb new file mode 100644 index 0000000..a838d83 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/pretty.rb @@ -0,0 +1,142 @@ +# frozen_string_literal: true +require_relative 'default' + +module REXML + module Formatters + # Pretty-prints an XML document. This destroys whitespace in text nodes + # and will insert carriage returns and indentations. + # + # TODO: Add an option to print attributes on new lines + class Pretty < Default + + # If compact is set to true, then the formatter will attempt to use as + # little space as possible + attr_accessor :compact + # The width of a page. Used for formatting text + attr_accessor :width + + # Create a new pretty printer. + # + # output:: + # An object implementing '<<(String)', to which the output will be written. + # indentation:: + # An integer greater than 0. The indentation of each level will be + # this number of spaces. If this is < 1, the behavior of this object + # is undefined. Defaults to 2. + # ie_hack:: + # If true, the printer will insert whitespace before closing empty + # tags, thereby allowing Internet Explorer's XML parser to + # function. Defaults to false. + def initialize( indentation=2, ie_hack=false ) + @indentation = indentation + @level = 0 + @ie_hack = ie_hack + @width = 80 + @compact = false + end + + protected + def write_element(node, output) + output << ' '*@level + output << "<#{node.expanded_name}" + + node.attributes.each_attribute do |attr| + output << " " + attr.write( output ) + end unless node.attributes.empty? + + if node.children.empty? + if @ie_hack + output << " " + end + output << "/" + else + output << ">" + # If compact and all children are text, and if the formatted output + # is less than the specified width, then try to print everything on + # one line + skip = false + if compact + if node.children.inject(true) {|s,c| s & c.kind_of?(Text)} + string = +"" + old_level = @level + @level = 0 + node.children.each { |child| write( child, string ) } + @level = old_level + if string.length < @width + output << string + skip = true + end + end + end + unless skip + output << "\n" + @level += @indentation + node.children.each { |child| + next if child.kind_of?(Text) and child.to_s.strip.length == 0 + write( child, output ) + output << "\n" + } + @level -= @indentation + output << ' '*@level + end + output << "</#{node.expanded_name}" + end + output << ">" + end + + def write_text( node, output ) + s = node.to_s() + s.gsub!(/\s/,' ') + s.squeeze!(" ") + s = wrap(s, @width - @level) + s = indent_text(s, @level, " ", true) + output << (' '*@level + s) + end + + def write_comment( node, output) + output << ' ' * @level + super + end + + def write_cdata( node, output) + output << ' ' * @level + super + end + + def write_document( node, output ) + # Ok, this is a bit odd. All XML documents have an XML declaration, + # but it may not write itself if the user didn't specifically add it, + # either through the API or in the input document. If it doesn't write + # itself, then we don't need a carriage return... which makes this + # logic more complex. + node.children.each { |child| + next if child.instance_of?(Text) + unless child == node.children[0] or child.instance_of?(Text) or + (child == node.children[1] and !node.children[0].writethis) + output << "\n" + end + write( child, output ) + } + end + + private + def indent_text(string, level=1, style="\t", indentfirstline=true) + return string if level < 0 + string.gsub(/\n/, "\n#{style*level}") + end + + def wrap(string, width) + parts = [] + while string.length > width and place = string.rindex(' ', width) + parts << string[0...place] + string = string[place+1..-1] + end + parts << string + parts.join("\n") + end + + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/transitive.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/transitive.rb new file mode 100644 index 0000000..5ff51e1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/formatters/transitive.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: false +require_relative 'pretty' + +module REXML + module Formatters + # The Transitive formatter writes an XML document that parses to an + # identical document as the source document. This means that no extra + # whitespace nodes are inserted, and whitespace within text nodes is + # preserved. Within these constraints, the document is pretty-printed, + # with whitespace inserted into the metadata to introduce formatting. + # + # Note that this is only useful if the original XML is not already + # formatted. Since this formatter does not alter whitespace nodes, the + # results of formatting already formatted XML will be odd. + class Transitive < Default + def initialize( indentation=2, ie_hack=false ) + @indentation = indentation + @level = 0 + @ie_hack = ie_hack + end + + protected + def write_element( node, output ) + output << "<#{node.expanded_name}" + + node.attributes.each_attribute do |attr| + output << " " + attr.write( output ) + end unless node.attributes.empty? + + output << "\n" + output << ' '*@level + if node.children.empty? + output << " " if @ie_hack + output << "/" + else + output << ">" + # If compact and all children are text, and if the formatted output + # is less than the specified width, then try to print everything on + # one line + @level += @indentation + node.children.each { |child| + write( child, output ) + } + @level -= @indentation + output << "</#{node.expanded_name}" + output << "\n" + output << ' '*@level + end + output << ">" + end + + def write_text( node, output ) + output << node.to_s() + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/functions.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/functions.rb new file mode 100644 index 0000000..4c11461 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/functions.rb @@ -0,0 +1,446 @@ +# frozen_string_literal: false +module REXML + # If you add a method, keep in mind two things: + # (1) the first argument will always be a list of nodes from which to + # filter. In the case of context methods (such as position), the function + # should return an array with a value for each child in the array. + # (2) all method calls from XML will have "-" replaced with "_". + # Therefore, in XML, "local-name()" is identical (and actually becomes) + # "local_name()" + module Functions + @@available_functions = {} + @@context = nil + @@namespace_context = {} + @@variables = {} + + INTERNAL_METHODS = [ + :namespace_context, + :namespace_context=, + :variables, + :variables=, + :context=, + :get_namespace, + :send, + ] + class << self + def singleton_method_added(name) + unless INTERNAL_METHODS.include?(name) + @@available_functions[name] = true + end + end + end + + def Functions::namespace_context=(x) ; @@namespace_context=x ; end + def Functions::variables=(x) ; @@variables=x ; end + def Functions::namespace_context ; @@namespace_context ; end + def Functions::variables ; @@variables ; end + + def Functions::context=(value); @@context = value; end + + def Functions::text( ) + if @@context[:node].node_type == :element + return @@context[:node].find_all{|n| n.node_type == :text}.collect{|n| n.value} + elsif @@context[:node].node_type == :text + return @@context[:node].value + else + return false + end + end + + # Returns the last node of the given list of nodes. + def Functions::last( ) + @@context[:size] + end + + def Functions::position( ) + @@context[:index] + end + + # Returns the size of the given list of nodes. + def Functions::count( node_set ) + node_set.size + end + + # Since REXML is non-validating, this method is not implemented as it + # requires a DTD + def Functions::id( object ) + end + + def Functions::local_name(node_set=nil) + get_namespace(node_set) do |node| + return node.local_name + end + "" + end + + def Functions::namespace_uri( node_set=nil ) + get_namespace( node_set ) {|node| node.namespace} + end + + def Functions::name( node_set=nil ) + get_namespace( node_set ) do |node| + node.expanded_name + end + end + + # Helper method. + def Functions::get_namespace( node_set = nil ) + if node_set == nil + yield @@context[:node] if @@context[:node].respond_to?(:namespace) + else + if node_set.respond_to? :each + result = [] + node_set.each do |node| + result << yield(node) if node.respond_to?(:namespace) + end + result + elsif node_set.respond_to? :namespace + yield node_set + end + end + end + + # A node-set is converted to a string by returning the string-value of the + # node in the node-set that is first in document order. If the node-set is + # empty, an empty string is returned. + # + # A number is converted to a string as follows + # + # NaN is converted to the string NaN + # + # positive zero is converted to the string 0 + # + # negative zero is converted to the string 0 + # + # positive infinity is converted to the string Infinity + # + # negative infinity is converted to the string -Infinity + # + # if the number is an integer, the number is represented in decimal form + # as a Number with no decimal point and no leading zeros, preceded by a + # minus sign (-) if the number is negative + # + # otherwise, the number is represented in decimal form as a Number + # including a decimal point with at least one digit before the decimal + # point and at least one digit after the decimal point, preceded by a + # minus sign (-) if the number is negative; there must be no leading zeros + # before the decimal point apart possibly from the one required digit + # immediately before the decimal point; beyond the one required digit + # after the decimal point there must be as many, but only as many, more + # digits as are needed to uniquely distinguish the number from all other + # IEEE 754 numeric values. + # + # The boolean false value is converted to the string false. The boolean + # true value is converted to the string true. + # + # An object of a type other than the four basic types is converted to a + # string in a way that is dependent on that type. + def Functions::string( object=@@context[:node] ) + if object.respond_to?(:node_type) + case object.node_type + when :attribute + object.value + when :element + string_value(object) + when :document + string_value(object.root) + when :processing_instruction + object.content + else + object.to_s + end + else + case object + when Array + string(object[0]) + when Float + if object.nan? + "NaN" + else + integer = object.to_i + if object == integer + "%d" % integer + else + object.to_s + end + end + else + object.to_s + end + end + end + + # A node-set is converted to a string by + # returning the concatenation of the string-value + # of each of the children of the node in the + # node-set that is first in document order. + # If the node-set is empty, an empty string is returned. + def Functions::string_value( o ) + rv = "" + o.children.each { |e| + if e.node_type == :text + rv << e.to_s + elsif e.node_type == :element + rv << string_value( e ) + end + } + rv + end + + def Functions::concat( *objects ) + concatenated = "" + objects.each do |object| + concatenated << string(object) + end + concatenated + end + + # Fixed by Mike Stok + def Functions::starts_with( string, test ) + string(string).index(string(test)) == 0 + end + + # Fixed by Mike Stok + def Functions::contains( string, test ) + string(string).include?(string(test)) + end + + # Kouhei fixed this + def Functions::substring_before( string, test ) + ruby_string = string(string) + ruby_index = ruby_string.index(string(test)) + if ruby_index.nil? + "" + else + ruby_string[ 0...ruby_index ] + end + end + + # Kouhei fixed this too + def Functions::substring_after( string, test ) + ruby_string = string(string) + return $1 if ruby_string =~ /#{test}(.*)/ + "" + end + + # Take equal portions of Mike Stok and Sean Russell; mix + # vigorously, and pour into a tall, chilled glass. Serves 10,000. + def Functions::substring( string, start, length=nil ) + ruby_string = string(string) + ruby_length = if length.nil? + ruby_string.length.to_f + else + number(length) + end + ruby_start = number(start) + + # Handle the special cases + return '' if ( + ruby_length.nan? or + ruby_start.nan? or + ruby_start.infinite? + ) + + infinite_length = ruby_length.infinite? == 1 + ruby_length = ruby_string.length if infinite_length + + # Now, get the bounds. The XPath bounds are 1..length; the ruby bounds + # are 0..length. Therefore, we have to offset the bounds by one. + ruby_start = round(ruby_start) - 1 + ruby_length = round(ruby_length) + + if ruby_start < 0 + ruby_length += ruby_start unless infinite_length + ruby_start = 0 + end + return '' if ruby_length <= 0 + ruby_string[ruby_start,ruby_length] + end + + # UNTESTED + def Functions::string_length( string ) + string(string).length + end + + def Functions::normalize_space( string=nil ) + string = string(@@context[:node]) if string.nil? + if string.kind_of? Array + string.collect{|x| x.to_s.strip.gsub(/\s+/um, ' ') if x} + else + string.to_s.strip.gsub(/\s+/um, ' ') + end + end + + # This is entirely Mike Stok's beast + def Functions::translate( string, tr1, tr2 ) + from = string(tr1) + to = string(tr2) + + # the map is our translation table. + # + # if a character occurs more than once in the + # from string then we ignore the second & + # subsequent mappings + # + # if a character maps to nil then we delete it + # in the output. This happens if the from + # string is longer than the to string + # + # there's nothing about - or ^ being special in + # http://www.w3.org/TR/xpath#function-translate + # so we don't build ranges or negated classes + + map = Hash.new + 0.upto(from.length - 1) { |pos| + from_char = from[pos] + unless map.has_key? from_char + map[from_char] = + if pos < to.length + to[pos] + else + nil + end + end + } + + if ''.respond_to? :chars + string(string).chars.collect { |c| + if map.has_key? c then map[c] else c end + }.compact.join + else + string(string).unpack('U*').collect { |c| + if map.has_key? c then map[c] else c end + }.compact.pack('U*') + end + end + + def Functions::boolean(object=@@context[:node]) + case object + when true, false + object + when Float + return false if object.zero? + return false if object.nan? + true + when Numeric + not object.zero? + when String + not object.empty? + when Array + not object.empty? + else + object ? true : false + end + end + + # UNTESTED + def Functions::not( object ) + not boolean( object ) + end + + # UNTESTED + def Functions::true( ) + true + end + + # UNTESTED + def Functions::false( ) + false + end + + # UNTESTED + def Functions::lang( language ) + lang = false + node = @@context[:node] + attr = nil + until node.nil? + if node.node_type == :element + attr = node.attributes["xml:lang"] + unless attr.nil? + lang = compare_language(string(language), attr) + break + else + end + end + node = node.parent + end + lang + end + + def Functions::compare_language lang1, lang2 + lang2.downcase.index(lang1.downcase) == 0 + end + + # a string that consists of optional whitespace followed by an optional + # minus sign followed by a Number followed by whitespace is converted to + # the IEEE 754 number that is nearest (according to the IEEE 754 + # round-to-nearest rule) to the mathematical value represented by the + # string; any other string is converted to NaN + # + # boolean true is converted to 1; boolean false is converted to 0 + # + # a node-set is first converted to a string as if by a call to the string + # function and then converted in the same way as a string argument + # + # an object of a type other than the four basic types is converted to a + # number in a way that is dependent on that type + def Functions::number(object=@@context[:node]) + case object + when true + Float(1) + when false + Float(0) + when Array + number(string(object)) + when Numeric + object.to_f + else + str = string(object) + case str.strip + when /\A\s*(-?(?:\d+(?:\.\d*)?|\.\d+))\s*\z/ + $1.to_f + else + Float::NAN + end + end + end + + def Functions::sum( nodes ) + nodes = [nodes] unless nodes.kind_of? Array + nodes.inject(0) { |r,n| r + number(string(n)) } + end + + def Functions::floor( number ) + number(number).floor + end + + def Functions::ceiling( number ) + number(number).ceil + end + + def Functions::round( number ) + number = number(number) + begin + neg = number.negative? + number = number.abs.round + neg ? -number : number + rescue FloatDomainError + number + end + end + + def Functions::processing_instruction( node ) + node.node_type == :processing_instruction + end + + def Functions::send(name, *args) + if @@available_functions[name.to_sym] + super + else + # TODO: Maybe, this is not XPath spec behavior. + # This behavior must be reconsidered. + XPath.match(@@context[:node], name.to_s) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/instruction.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/instruction.rb new file mode 100644 index 0000000..318741f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/instruction.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: false + +require_relative "child" +require_relative "source" + +module REXML + # Represents an XML Instruction; IE, <? ... ?> + # TODO: Add parent arg (3rd arg) to constructor + class Instruction < Child + START = "<?" + STOP = "?>" + + # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?> + # content is everything else. + attr_accessor :target, :content + + # Constructs a new Instruction + # @param target can be one of a number of things. If String, then + # the target of this instruction is set to this. If an Instruction, + # then the Instruction is shallowly cloned (target and content are + # copied). + # @param content Must be either a String, or a Parent. Can only + # be a Parent if the target argument is a Source. Otherwise, this + # String is set as the content of this instruction. + def initialize(target, content=nil) + case target + when String + super() + @target = target + @content = content + when Instruction + super(content) + @target = target.target + @content = target.content + else + message = + "processing instruction target must be String or REXML::Instruction: " + message << "<#{target.inspect}>" + raise ArgumentError, message + end + @content.strip! if @content + end + + def clone + Instruction.new self + end + + # == DEPRECATED + # See the rexml/formatters package + # + def write writer, indent=-1, transitive=false, ie_hack=false + Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1) + indent(writer, indent) + writer << START + writer << @target + if @content + writer << ' ' + writer << @content + end + writer << STOP + end + + # @return true if other is an Instruction, and the content and target + # of the other matches the target and content of this object. + def ==( other ) + other.kind_of? Instruction and + other.target == @target and + other.content == @content + end + + def node_type + :processing_instruction + end + + def inspect + "<?p-i #{target} ...?>" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/light/node.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/light/node.rb new file mode 100644 index 0000000..3dab885 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/light/node.rb @@ -0,0 +1,188 @@ +# frozen_string_literal: false +require_relative '../xmltokens' + +module REXML + module Light + # Represents a tagged XML element. Elements are characterized by + # having children, attributes, and names, and can themselves be + # children. + class Node + NAMESPLIT = /^(?:(#{XMLTokens::NCNAME_STR}):)?(#{XMLTokens::NCNAME_STR})/u + PARENTS = [ :element, :document, :doctype ] + # Create a new element. + def initialize node=nil + @node = node + if node.kind_of? String + node = [ :text, node ] + elsif node.nil? + node = [ :document, nil, nil ] + elsif node[0] == :start_element + node[0] = :element + elsif node[0] == :start_doctype + node[0] = :doctype + elsif node[0] == :start_document + node[0] = :document + end + end + + def size + if PARENTS.include? @node[0] + @node[-1].size + else + 0 + end + end + + def each + size.times { |x| yield( at(x+4) ) } + end + + def name + at(2) + end + + def name=( name_str, ns=nil ) + pfx = '' + pfx = "#{prefix(ns)}:" if ns + _old_put(2, "#{pfx}#{name_str}") + end + + def parent=( node ) + _old_put(1,node) + end + + def local_name + namesplit + @name + end + + def local_name=( name_str ) + _old_put( 1, "#@prefix:#{name_str}" ) + end + + def prefix( namespace=nil ) + prefix_of( self, namespace ) + end + + def namespace( prefix=prefix() ) + namespace_of( self, prefix ) + end + + def namespace=( namespace ) + @prefix = prefix( namespace ) + pfx = '' + pfx = "#@prefix:" if @prefix.size > 0 + _old_put(1, "#{pfx}#@name") + end + + def []( reference, ns=nil ) + if reference.kind_of? String + pfx = '' + pfx = "#{prefix(ns)}:" if ns + at(3)["#{pfx}#{reference}"] + elsif reference.kind_of? Range + _old_get( Range.new(4+reference.begin, reference.end, reference.exclude_end?) ) + else + _old_get( 4+reference ) + end + end + + def =~( path ) + XPath.match( self, path ) + end + + # Doesn't handle namespaces yet + def []=( reference, ns, value=nil ) + if reference.kind_of? String + value = ns unless value + at( 3 )[reference] = value + elsif reference.kind_of? Range + _old_put( Range.new(3+reference.begin, reference.end, reference.exclude_end?), ns ) + else + if value + _old_put( 4+reference, ns, value ) + else + _old_put( 4+reference, ns ) + end + end + end + + # Append a child to this element, optionally under a provided namespace. + # The namespace argument is ignored if the element argument is an Element + # object. Otherwise, the element argument is a string, the namespace (if + # provided) is the namespace the element is created in. + def << element + if node_type() == :text + at(-1) << element + else + newnode = Node.new( element ) + newnode.parent = self + self.push( newnode ) + end + at(-1) + end + + def node_type + _old_get(0) + end + + def text=( foo ) + replace = at(4).kind_of?(String)? 1 : 0 + self._old_put(4,replace, normalizefoo) + end + + def root + context = self + context = context.at(1) while context.at(1) + end + + def has_name?( name, namespace = '' ) + at(3) == name and namespace() == namespace + end + + def children + self + end + + def parent + at(1) + end + + def to_s + + end + + private + + def namesplit + return if @name.defined? + at(2) =~ NAMESPLIT + @prefix = '' || $1 + @name = $2 + end + + def namespace_of( node, prefix=nil ) + if not prefix + name = at(2) + name =~ NAMESPLIT + prefix = $1 + end + to_find = 'xmlns' + to_find = "xmlns:#{prefix}" if not prefix.nil? + ns = at(3)[ to_find ] + ns ? ns : namespace_of( @node[0], prefix ) + end + + def prefix_of( node, namespace=nil ) + if not namespace + name = node.name + name =~ NAMESPLIT + $1 + else + ns = at(3).find { |k,v| v == namespace } + ns ? ns : prefix_of( node.parent, namespace ) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/namespace.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/namespace.rb new file mode 100644 index 0000000..2e67252 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/namespace.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative 'xmltokens' + +module REXML + # Adds named attributes to an object. + module Namespace + # The name of the object, valid if set + attr_reader :name, :expanded_name + # The expanded name of the object, valid if name is set + attr_accessor :prefix + include XMLTokens + NAME_WITHOUT_NAMESPACE = /\A#{NCNAME_STR}\z/ + NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u + + # Sets the name and the expanded name + def name=( name ) + @expanded_name = name + if name.match?(NAME_WITHOUT_NAMESPACE) + @prefix = "" + @namespace = "" + @name = name + elsif name =~ NAMESPLIT + if $1 + @prefix = $1 + else + @prefix = "" + @namespace = "" + end + @name = $2 + elsif name == "" + @prefix = nil + @namespace = nil + @name = nil + else + message = "name must be \#{PREFIX}:\#{LOCAL_NAME} or \#{LOCAL_NAME}: " + message += "<#{name.inspect}>" + raise ArgumentError, message + end + end + + # Compares names optionally WITH namespaces + def has_name?( other, ns=nil ) + if ns + return (namespace() == ns and name() == other) + elsif other.include? ":" + return fully_expanded_name == other + else + return name == other + end + end + + alias :local_name :name + + # Fully expand the name, even if the prefix wasn't specified in the + # source file. + def fully_expanded_name + ns = prefix + return "#{ns}:#@name" if ns.size > 0 + return @name + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/node.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/node.rb new file mode 100644 index 0000000..c771db7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/node.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: false +require_relative "parseexception" +require_relative "formatters/pretty" +require_relative "formatters/default" + +module REXML + # Represents a node in the tree. Nodes are never encountered except as + # superclasses of other objects. Nodes have siblings. + module Node + # @return the next sibling (nil if unset) + def next_sibling_node + return nil if @parent.nil? + @parent[ @parent.index(self) + 1 ] + end + + # @return the previous sibling (nil if unset) + def previous_sibling_node + return nil if @parent.nil? + ind = @parent.index(self) + return nil if ind == 0 + @parent[ ind - 1 ] + end + + # indent:: + # *DEPRECATED* This parameter is now ignored. See the formatters in the + # REXML::Formatters package for changing the output style. + def to_s indent=nil + unless indent.nil? + Kernel.warn( "#{self.class.name}.to_s(indent) parameter is deprecated", uplevel: 1) + f = REXML::Formatters::Pretty.new( indent ) + f.write( self, rv = "" ) + else + f = REXML::Formatters::Default.new + f.write( self, rv = "" ) + end + return rv + end + + def indent to, ind + if @parent and @parent.context and not @parent.context[:indentstyle].nil? then + indentstyle = @parent.context[:indentstyle] + else + indentstyle = ' ' + end + to << indentstyle*ind unless ind<1 + end + + def parent? + false; + end + + + # Visit all subnodes of +self+ recursively + def each_recursive(&block) # :yields: node + stack = [] + each { |child| stack.unshift child if child.node_type == :element } + until stack.empty? + child = stack.pop + yield child + n = stack.size + child.each { |grandchild| stack.insert n, grandchild if grandchild.node_type == :element } + end + end + + # Find (and return) first subnode (recursively) for which the block + # evaluates to true. Returns +nil+ if none was found. + def find_first_recursive(&block) # :yields: node + each_recursive {|node| + return node if block.call(node) + } + return nil + end + + # Returns the position that +self+ holds in its parent's array, indexed + # from 1. + def index_in_parent + parent.index(self)+1 + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/output.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/output.rb new file mode 100644 index 0000000..88a5fb3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/output.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: false +require_relative 'encoding' + +module REXML + class Output + include Encoding + + attr_reader :encoding + + def initialize real_IO, encd="iso-8859-1" + @output = real_IO + self.encoding = encd + + @to_utf = encoding != 'UTF-8' + + if encoding == "UTF-16" + @output << "\ufeff".encode("UTF-16BE") + self.encoding = "UTF-16BE" + end + end + + def <<( content ) + @output << (@to_utf ? self.encode(content) : content) + end + + def to_s + "Output[#{encoding}]" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parent.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parent.rb new file mode 100644 index 0000000..6a53b37 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parent.rb @@ -0,0 +1,166 @@ +# frozen_string_literal: false +require_relative "child" + +module REXML + # A parent has children, and has methods for accessing them. The Parent + # class is never encountered except as the superclass for some other + # object. + class Parent < Child + include Enumerable + + # Constructor + # @param parent if supplied, will be set as the parent of this object + def initialize parent=nil + super(parent) + @children = [] + end + + def add( object ) + object.parent = self + @children << object + object + end + + alias :push :add + alias :<< :push + + def unshift( object ) + object.parent = self + @children.unshift object + end + + def delete( object ) + found = false + @children.delete_if {|c| c.equal?(object) and found = true } + object.parent = nil if found + found ? object : nil + end + + def each(&block) + @children.each(&block) + end + + def delete_if( &block ) + @children.delete_if(&block) + end + + def delete_at( index ) + @children.delete_at index + end + + def each_index( &block ) + @children.each_index(&block) + end + + # Fetches a child at a given index + # @param index the Integer index of the child to fetch + def []( index ) + @children[index] + end + + alias :each_child :each + + + + # Set an index entry. See Array.[]= + # @param index the index of the element to set + # @param opt either the object to set, or an Integer length + # @param child if opt is an Integer, this is the child to set + # @return the parent (self) + def []=( *args ) + args[-1].parent = self + @children[*args[0..-2]] = args[-1] + end + + # Inserts an child before another child + # @param child1 this is either an xpath or an Element. If an Element, + # child2 will be inserted before child1 in the child list of the parent. + # If an xpath, child2 will be inserted before the first child to match + # the xpath. + # @param child2 the child to insert + # @return the parent (self) + def insert_before( child1, child2 ) + if child1.kind_of? String + child1 = XPath.first( self, child1 ) + child1.parent.insert_before child1, child2 + else + ind = index(child1) + child2.parent.delete(child2) if child2.parent + @children[ind,0] = child2 + child2.parent = self + end + self + end + + # Inserts an child after another child + # @param child1 this is either an xpath or an Element. If an Element, + # child2 will be inserted after child1 in the child list of the parent. + # If an xpath, child2 will be inserted after the first child to match + # the xpath. + # @param child2 the child to insert + # @return the parent (self) + def insert_after( child1, child2 ) + if child1.kind_of? String + child1 = XPath.first( self, child1 ) + child1.parent.insert_after child1, child2 + else + ind = index(child1)+1 + child2.parent.delete(child2) if child2.parent + @children[ind,0] = child2 + child2.parent = self + end + self + end + + def to_a + @children.dup + end + + # Fetches the index of a given child + # @param child the child to get the index of + # @return the index of the child, or nil if the object is not a child + # of this parent. + def index( child ) + count = -1 + @children.find { |i| count += 1 ; i.hash == child.hash } + count + end + + # @return the number of children of this parent + def size + @children.size + end + + alias :length :size + + # Replaces one child with another, making sure the nodelist is correct + # @param to_replace the child to replace (must be a Child) + # @param replacement the child to insert into the nodelist (must be a + # Child) + def replace_child( to_replace, replacement ) + @children.map! {|c| c.equal?( to_replace ) ? replacement : c } + to_replace.parent = nil + replacement.parent = self + end + + # Deeply clones this object. This creates a complete duplicate of this + # Parent, including all descendants. + def deep_clone + cl = clone() + each do |child| + if child.kind_of? Parent + cl << child.deep_clone + else + cl << child.clone + end + end + cl + end + + alias :children :to_a + + def parent? + true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parseexception.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parseexception.rb new file mode 100644 index 0000000..e57d05f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parseexception.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: false +module REXML + class ParseException < RuntimeError + attr_accessor :source, :parser, :continued_exception + + def initialize( message, source=nil, parser=nil, exception=nil ) + super(message) + @source = source + @parser = parser + @continued_exception = exception + end + + def to_s + # Quote the original exception, if there was one + if @continued_exception + err = @continued_exception.inspect + err << "\n" + err << @continued_exception.backtrace.join("\n") + err << "\n...\n" + else + err = "" + end + + # Get the stack trace and error message + err << super + + # Add contextual information + if @source + err << "\nLine: #{line}\n" + err << "Position: #{position}\n" + err << "Last 80 unconsumed characters:\n" + err.force_encoding("ASCII-8BIT") + err << @source.buffer[0..80].force_encoding("ASCII-8BIT").gsub(/\n/, ' ') + end + + err + end + + def position + @source.current_line[0] if @source and defined? @source.current_line and + @source.current_line + end + + def line + @source.current_line[2] if @source and defined? @source.current_line and + @source.current_line + end + + def context + @source.current_line + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/baseparser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/baseparser.rb new file mode 100644 index 0000000..342f948 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/baseparser.rb @@ -0,0 +1,782 @@ +# frozen_string_literal: true +require_relative '../parseexception' +require_relative '../undefinednamespaceexception' +require_relative '../security' +require_relative '../source' +require 'set' +require "strscan" + +module REXML + module Parsers + if StringScanner::Version < "3.0.8" + module StringScannerCaptures + refine StringScanner do + def captures + values_at(*(1...size)) + end + end + end + using StringScannerCaptures + end + + # = Using the Pull Parser + # <em>This API is experimental, and subject to change.</em> + # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" ) + # while parser.has_next? + # res = parser.next + # puts res[1]['att'] if res.start_tag? and res[0] == 'b' + # end + # See the PullEvent class for information on the content of the results. + # The data is identical to the arguments passed for the various events to + # the StreamListener API. + # + # Notice that: + # parser = PullParser.new( "<a>BAD DOCUMENT" ) + # while parser.has_next? + # res = parser.next + # raise res[1] if res.error? + # end + # + # Nat Price gave me some good ideas for the API. + class BaseParser + LETTER = '[:alpha:]' + DIGIT = '[:digit:]' + + COMBININGCHAR = '' # TODO + EXTENDER = '' # TODO + + NCNAME_STR= "[#{LETTER}_][-[:alnum:]._#{COMBININGCHAR}#{EXTENDER}]*" + QNAME_STR= "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})" + QNAME = /(#{QNAME_STR})/ + + # Just for backward compatibility. For example, kramdown uses this. + # It's not used in REXML. + UNAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}" + + NAMECHAR = '[\-\w\.:]' + NAME = "([\\w:]#{NAMECHAR}*)" + NMTOKEN = "(?:#{NAMECHAR})+" + NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*" + REFERENCE = "&(?:#{NAME};|#\\d+;|#x[0-9a-fA-F]+;)" + REFERENCE_RE = /#{REFERENCE}/ + + DOCTYPE_START = /\A\s*<!DOCTYPE\s/um + DOCTYPE_END = /\A\s*\]\s*>/um + ATTRIBUTE_PATTERN = /\s*(#{QNAME_STR})\s*=\s*(["'])(.*?)\4/um + COMMENT_START = /\A<!--/u + COMMENT_PATTERN = /<!--(.*?)-->/um + CDATA_START = /\A<!\[CDATA\[/u + CDATA_END = /\A\s*\]\s*>/um + CDATA_PATTERN = /<!\[CDATA\[(.*?)\]\]>/um + XMLDECL_START = /\A<\?xml\s/u; + XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>/um + INSTRUCTION_START = /\A<\?/u + INSTRUCTION_PATTERN = /<\?#{NAME}(\s+.*?)?\?>/um + TAG_MATCH = /\A<((?>#{QNAME_STR}))/um + CLOSE_MATCH = /\A\s*<\/(#{QNAME_STR})\s*>/um + + VERSION = /\bversion\s*=\s*["'](.*?)['"]/um + ENCODING = /\bencoding\s*=\s*["'](.*?)['"]/um + STANDALONE = /\bstandalone\s*=\s*["'](.*?)['"]/um + + ENTITY_START = /\A\s*<!ENTITY/ + ELEMENTDECL_START = /\A\s*<!ELEMENT/um + ELEMENTDECL_PATTERN = /\A\s*(<!ELEMENT.*?)>/um + SYSTEMENTITY = /\A\s*(%.*?;)\s*$/um + ENUMERATION = "\\(\\s*#{NMTOKEN}(?:\\s*\\|\\s*#{NMTOKEN})*\\s*\\)" + NOTATIONTYPE = "NOTATION\\s+\\(\\s*#{NAME}(?:\\s*\\|\\s*#{NAME})*\\s*\\)" + ENUMERATEDTYPE = "(?:(?:#{NOTATIONTYPE})|(?:#{ENUMERATION}))" + ATTTYPE = "(CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS|#{ENUMERATEDTYPE})" + ATTVALUE = "(?:\"((?:[^<&\"]|#{REFERENCE})*)\")|(?:'((?:[^<&']|#{REFERENCE})*)')" + DEFAULTDECL = "(#REQUIRED|#IMPLIED|(?:(#FIXED\\s+)?#{ATTVALUE}))" + ATTDEF = "\\s+#{NAME}\\s+#{ATTTYPE}\\s+#{DEFAULTDECL}" + ATTDEF_RE = /#{ATTDEF}/ + ATTLISTDECL_START = /\A\s*<!ATTLIST/um + ATTLISTDECL_PATTERN = /\A\s*<!ATTLIST\s+#{NAME}(?:#{ATTDEF})*\s*>/um + + TEXT_PATTERN = /\A([^<]*)/um + + # Entity constants + PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#" + SYSTEMLITERAL = %Q{((?:"[^"]*")|(?:'[^']*'))} + PUBIDLITERAL = %Q{("[#{PUBIDCHAR}']*"|'[#{PUBIDCHAR}]*')} + EXTERNALID = "(?:(?:(SYSTEM)\\s+#{SYSTEMLITERAL})|(?:(PUBLIC)\\s+#{PUBIDLITERAL}\\s+#{SYSTEMLITERAL}))" + NDATADECL = "\\s+NDATA\\s+#{NAME}" + PEREFERENCE = "%#{NAME};" + ENTITYVALUE = %Q{((?:"(?:[^%&"]|#{PEREFERENCE}|#{REFERENCE})*")|(?:'([^%&']|#{PEREFERENCE}|#{REFERENCE})*'))} + PEDEF = "(?:#{ENTITYVALUE}|#{EXTERNALID})" + ENTITYDEF = "(?:#{ENTITYVALUE}|(?:#{EXTERNALID}(#{NDATADECL})?))" + PEDECL = "<!ENTITY\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>" + GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>" + ENTITYDECL = /\s*(?:#{GEDECL})|\s*(?:#{PEDECL})/um + + NOTATIONDECL_START = /\A\s*<!NOTATION/um + EXTERNAL_ID_PUBLIC = /\A\s*PUBLIC\s+#{PUBIDLITERAL}\s+#{SYSTEMLITERAL}\s*/um + EXTERNAL_ID_SYSTEM = /\A\s*SYSTEM\s+#{SYSTEMLITERAL}\s*/um + PUBLIC_ID = /\A\s*PUBLIC\s+#{PUBIDLITERAL}\s*/um + + EREFERENCE = /&(?!#{NAME};)/ + + DEFAULT_ENTITIES = { + 'gt' => [/>/, '>', '>', />/], + 'lt' => [/</, '<', '<', /</], + 'quot' => [/"/, '"', '"', /"/], + "apos" => [/'/, "'", "'", /'/] + } + + module Private + TAG_PATTERN = /((?>#{QNAME_STR}))\s*/um + CLOSE_PATTERN = /(#{QNAME_STR})\s*>/um + ATTLISTDECL_END = /\s+#{NAME}(?:#{ATTDEF})*\s*>/um + NAME_PATTERN = /#{NAME}/um + GEDECL_PATTERN = "\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>" + PEDECL_PATTERN = "\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>" + ENTITYDECL_PATTERN = /(?:#{GEDECL_PATTERN})|(?:#{PEDECL_PATTERN})/um + CARRIAGE_RETURN_NEWLINE_PATTERN = /\r\n?/ + CHARACTER_REFERENCES = /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ + DEFAULT_ENTITIES_PATTERNS = {} + default_entities = ['gt', 'lt', 'quot', 'apos', 'amp'] + default_entities.each do |term| + DEFAULT_ENTITIES_PATTERNS[term] = /&#{term};/ + end + end + private_constant :Private + + def initialize( source ) + self.stream = source + @listeners = [] + @prefixes = Set.new + @entity_expansion_count = 0 + end + + def add_listener( listener ) + @listeners << listener + end + + attr_reader :source + attr_reader :entity_expansion_count + + def stream=( source ) + @source = SourceFactory.create_from( source ) + @closed = nil + @have_root = false + @document_status = nil + @tags = [] + @stack = [] + @entities = [] + @nsstack = [] + end + + def position + if @source.respond_to? :position + @source.position + else + # FIXME + 0 + end + end + + # Returns true if there are no more events + def empty? + return (@source.empty? and @stack.empty?) + end + + # Returns true if there are more events. Synonymous with !empty? + def has_next? + return !(@source.empty? and @stack.empty?) + end + + # Push an event back on the head of the stream. This method + # has (theoretically) infinite depth. + def unshift token + @stack.unshift(token) + end + + # Peek at the +depth+ event in the stack. The first element on the stack + # is at depth 0. If +depth+ is -1, will parse to the end of the input + # stream and return the last event, which is always :end_document. + # Be aware that this causes the stream to be parsed up to the +depth+ + # event, so you can effectively pre-parse the entire document (pull the + # entire thing into memory) using this method. + def peek depth=0 + raise %Q[Illegal argument "#{depth}"] if depth < -1 + temp = [] + if depth == -1 + temp.push(pull()) until empty? + else + while @stack.size+temp.size < depth+1 + temp.push(pull()) + end + end + @stack += temp if temp.size > 0 + @stack[depth] + end + + # Returns the next event. This is a +PullEvent+ object. + def pull + @source.drop_parsed_content + + pull_event.tap do |event| + @listeners.each do |listener| + listener.receive event + end + end + end + + def pull_event + if @closed + x, @closed = @closed, nil + return [ :end_element, x ] + end + if empty? + if @document_status == :in_doctype + raise ParseException.new("Malformed DOCTYPE: unclosed", @source) + end + return [ :end_document ] + end + return @stack.shift if @stack.size > 0 + #STDERR.puts @source.encoding + #STDERR.puts "BUFFER = #{@source.buffer.inspect}" + + @source.ensure_buffer + if @document_status == nil + start_position = @source.position + if @source.match("<?", true) + return process_instruction + elsif @source.match("<!", true) + if @source.match("--", true) + md = @source.match(/(.*?)-->/um, true) + if md.nil? + raise REXML::ParseException.new("Unclosed comment", @source) + end + if /--|-\z/.match?(md[1]) + raise REXML::ParseException.new("Malformed comment", @source) + end + return [ :comment, md[1] ] + elsif @source.match("DOCTYPE", true) + base_error_message = "Malformed DOCTYPE" + unless @source.match(/\s+/um, true) + if @source.match(">") + message = "#{base_error_message}: name is missing" + else + message = "#{base_error_message}: invalid name" + end + @source.position = start_position + raise REXML::ParseException.new(message, @source) + end + @nsstack.unshift(Set.new) + name = parse_name(base_error_message) + if @source.match(/\s*\[/um, true) + id = [nil, nil, nil] + @document_status = :in_doctype + elsif @source.match(/\s*>/um, true) + id = [nil, nil, nil] + @document_status = :after_doctype + @source.ensure_buffer + else + id = parse_id(base_error_message, + accept_external_id: true, + accept_public_id: false) + if id[0] == "SYSTEM" + # For backward compatibility + id[1], id[2] = id[2], nil + end + if @source.match(/\s*\[/um, true) + @document_status = :in_doctype + elsif @source.match(/\s*>/um, true) + @document_status = :after_doctype + @source.ensure_buffer + else + message = "#{base_error_message}: garbage after external ID" + raise REXML::ParseException.new(message, @source) + end + end + args = [:start_doctype, name, *id] + if @document_status == :after_doctype + @source.match(/\s*/um, true) + @stack << [ :end_doctype ] + end + return args + else + message = "Invalid XML" + raise REXML::ParseException.new(message, @source) + end + end + end + if @document_status == :in_doctype + @source.match(/\s*/um, true) # skip spaces + start_position = @source.position + if @source.match("<!", true) + if @source.match("ELEMENT", true) + md = @source.match(/(.*?)>/um, true) + raise REXML::ParseException.new( "Bad ELEMENT declaration!", @source ) if md.nil? + return [ :elementdecl, "<!ELEMENT" + md[1] ] + elsif @source.match("ENTITY", true) + match_data = @source.match(Private::ENTITYDECL_PATTERN, true) + unless match_data + raise REXML::ParseException.new("Malformed entity declaration", @source) + end + match = [:entitydecl, *match_data.captures.compact] + ref = false + if match[1] == '%' + ref = true + match.delete_at 1 + end + # Now we have to sort out what kind of entity reference this is + if match[2] == 'SYSTEM' + # External reference + match[3] = match[3][1..-2] # PUBID + match.delete_at(4) if match.size > 4 # Chop out NDATA decl + # match is [ :entity, name, SYSTEM, pubid(, ndata)? ] + elsif match[2] == 'PUBLIC' + # External reference + match[3] = match[3][1..-2] # PUBID + match[4] = match[4][1..-2] # HREF + match.delete_at(5) if match.size > 5 # Chop out NDATA decl + # match is [ :entity, name, PUBLIC, pubid, href(, ndata)? ] + else + match[2] = match[2][1..-2] + match.pop if match.size == 4 + # match is [ :entity, name, value ] + end + match << '%' if ref + return match + elsif @source.match("ATTLIST", true) + md = @source.match(Private::ATTLISTDECL_END, true) + raise REXML::ParseException.new( "Bad ATTLIST declaration!", @source ) if md.nil? + element = md[1] + contents = md[0] + + pairs = {} + values = md[0].strip.scan( ATTDEF_RE ) + values.each do |attdef| + unless attdef[3] == "#IMPLIED" + attdef.compact! + val = attdef[3] + val = attdef[4] if val == "#FIXED " + pairs[attdef[0]] = val + if attdef[0] =~ /^xmlns:(.*)/ + @nsstack[0] << $1 + end + end + end + return [ :attlistdecl, element, pairs, contents ] + elsif @source.match("NOTATION", true) + base_error_message = "Malformed notation declaration" + unless @source.match(/\s+/um, true) + if @source.match(">") + message = "#{base_error_message}: name is missing" + else + message = "#{base_error_message}: invalid name" + end + @source.position = start_position + raise REXML::ParseException.new(message, @source) + end + name = parse_name(base_error_message) + id = parse_id(base_error_message, + accept_external_id: true, + accept_public_id: true) + unless @source.match(/\s*>/um, true) + message = "#{base_error_message}: garbage before end >" + raise REXML::ParseException.new(message, @source) + end + return [:notationdecl, name, *id] + elsif md = @source.match(/--(.*?)-->/um, true) + case md[1] + when /--/, /-\z/ + raise REXML::ParseException.new("Malformed comment", @source) + end + return [ :comment, md[1] ] if md + end + elsif match = @source.match(/(%.*?;)\s*/um, true) + return [ :externalentity, match[1] ] + elsif @source.match(/\]\s*>/um, true) + @document_status = :after_doctype + return [ :end_doctype ] + end + if @document_status == :in_doctype + raise ParseException.new("Malformed DOCTYPE: invalid declaration", @source) + end + end + if @document_status == :after_doctype + @source.match(/\s*/um, true) + end + begin + start_position = @source.position + if @source.match("<", true) + # :text's read_until may remain only "<" in buffer. In the + # case, buffer is empty here. So we need to fill buffer + # here explicitly. + @source.ensure_buffer + if @source.match("/", true) + @nsstack.shift + last_tag = @tags.pop + md = @source.match(Private::CLOSE_PATTERN, true) + if md and !last_tag + message = "Unexpected top-level end tag (got '#{md[1]}')" + raise REXML::ParseException.new(message, @source) + end + if md.nil? or last_tag != md[1] + message = "Missing end tag for '#{last_tag}'" + message += " (got '#{md[1]}')" if md + @source.position = start_position if md.nil? + raise REXML::ParseException.new(message, @source) + end + return [ :end_element, last_tag ] + elsif @source.match("!", true) + md = @source.match(/([^>]*>)/um) + #STDERR.puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}" + raise REXML::ParseException.new("Malformed node", @source) unless md + if md[0][0] == ?- + md = @source.match(/--(.*?)-->/um, true) + + if md.nil? || /--|-\z/.match?(md[1]) + raise REXML::ParseException.new("Malformed comment", @source) + end + + return [ :comment, md[1] ] + else + md = @source.match(/\[CDATA\[(.*?)\]\]>/um, true) + return [ :cdata, md[1] ] if md + end + raise REXML::ParseException.new( "Declarations can only occur "+ + "in the doctype declaration.", @source) + elsif @source.match("?", true) + return process_instruction + else + # Get the next tag + md = @source.match(Private::TAG_PATTERN, true) + unless md + @source.position = start_position + raise REXML::ParseException.new("malformed XML: missing tag start", @source) + end + tag = md[1] + @document_status = :in_element + @prefixes.clear + @prefixes << md[2] if md[2] + @nsstack.unshift(curr_ns=Set.new) + attributes, closed = parse_attributes(@prefixes, curr_ns) + # Verify that all of the prefixes have been defined + for prefix in @prefixes + unless @nsstack.find{|k| k.member?(prefix)} + raise UndefinedNamespaceException.new(prefix,@source,self) + end + end + + if closed + @closed = tag + @nsstack.shift + else + if @tags.empty? and @have_root + raise ParseException.new("Malformed XML: Extra tag at the end of the document (got '<#{tag}')", @source) + end + @tags.push( tag ) + end + @have_root = true + return [ :start_element, tag, attributes ] + end + else + text = @source.read_until("<") + if text.chomp!("<") + @source.position -= "<".bytesize + end + if @tags.empty? + unless /\A\s*\z/.match?(text) + if @have_root + raise ParseException.new("Malformed XML: Extra content at the end of the document (got '#{text}')", @source) + else + raise ParseException.new("Malformed XML: Content at the start of the document (got '#{text}')", @source) + end + end + return pull_event if @have_root + end + return [ :text, text ] + end + rescue REXML::UndefinedNamespaceException + raise + rescue REXML::ParseException + raise + rescue => error + raise REXML::ParseException.new( "Exception parsing", + @source, self, (error ? error : $!) ) + end + return [ :dummy ] + end + private :pull_event + + def entity( reference, entities ) + value = nil + value = entities[ reference ] if entities + if value + record_entity_expansion + else + value = DEFAULT_ENTITIES[ reference ] + value = value[2] if value + end + unnormalize( value, entities ) if value + end + + # Escapes all possible entities + def normalize( input, entities=nil, entity_filter=nil ) + copy = input.clone + # Doing it like this rather than in a loop improves the speed + copy.gsub!( EREFERENCE, '&' ) + entities.each do |key, value| + copy.gsub!( value, "&#{key};" ) unless entity_filter and + entity_filter.include?(entity) + end if entities + copy.gsub!( EREFERENCE, '&' ) + DEFAULT_ENTITIES.each do |key, value| + copy.gsub!( value[3], value[1] ) + end + copy + end + + # Unescapes all possible entities + def unnormalize( string, entities=nil, filter=nil ) + if string.include?("\r") + rv = string.gsub( Private::CARRIAGE_RETURN_NEWLINE_PATTERN, "\n" ) + else + rv = string.dup + end + matches = rv.scan( REFERENCE_RE ) + return rv if matches.size == 0 + rv.gsub!( Private::CHARACTER_REFERENCES ) { + m=$1 + m = "0#{m}" if m[0] == ?x + [Integer(m)].pack('U*') + } + matches.collect!{|x|x[0]}.compact! + if matches.size > 0 + matches.each do |entity_reference| + unless filter and filter.include?(entity_reference) + entity_value = entity( entity_reference, entities ) + if entity_value + re = Private::DEFAULT_ENTITIES_PATTERNS[entity_reference] || /&#{entity_reference};/ + rv.gsub!( re, entity_value ) + if rv.bytesize > Security.entity_expansion_text_limit + raise "entity expansion has grown too large" + end + else + er = DEFAULT_ENTITIES[entity_reference] + rv.gsub!( er[0], er[2] ) if er + end + end + end + rv.gsub!( Private::DEFAULT_ENTITIES_PATTERNS['amp'], '&' ) + end + rv + end + + private + + def record_entity_expansion + @entity_expansion_count += 1 + if @entity_expansion_count > Security.entity_expansion_limit + raise "number of entity expansions exceeded, processing aborted." + end + end + + def need_source_encoding_update?(xml_declaration_encoding) + return false if xml_declaration_encoding.nil? + return false if /\AUTF-16\z/i =~ xml_declaration_encoding + true + end + + def parse_name(base_error_message) + md = @source.match(Private::NAME_PATTERN, true) + unless md + if @source.match(/\S/um) + message = "#{base_error_message}: invalid name" + else + message = "#{base_error_message}: name is missing" + end + raise REXML::ParseException.new(message, @source) + end + md[0] + end + + def parse_id(base_error_message, + accept_external_id:, + accept_public_id:) + if accept_external_id and (md = @source.match(EXTERNAL_ID_PUBLIC, true)) + pubid = system = nil + pubid_literal = md[1] + pubid = pubid_literal[1..-2] if pubid_literal # Remove quote + system_literal = md[2] + system = system_literal[1..-2] if system_literal # Remove quote + ["PUBLIC", pubid, system] + elsif accept_public_id and (md = @source.match(PUBLIC_ID, true)) + pubid = system = nil + pubid_literal = md[1] + pubid = pubid_literal[1..-2] if pubid_literal # Remove quote + ["PUBLIC", pubid, nil] + elsif accept_external_id and (md = @source.match(EXTERNAL_ID_SYSTEM, true)) + system = nil + system_literal = md[1] + system = system_literal[1..-2] if system_literal # Remove quote + ["SYSTEM", nil, system] + else + details = parse_id_invalid_details(accept_external_id: accept_external_id, + accept_public_id: accept_public_id) + message = "#{base_error_message}: #{details}" + raise REXML::ParseException.new(message, @source) + end + end + + def parse_id_invalid_details(accept_external_id:, + accept_public_id:) + public = /\A\s*PUBLIC/um + system = /\A\s*SYSTEM/um + if (accept_external_id or accept_public_id) and @source.match(/#{public}/um) + if @source.match(/#{public}(?:\s+[^'"]|\s*[\[>])/um) + return "public ID literal is missing" + end + unless @source.match(/#{public}\s+#{PUBIDLITERAL}/um) + return "invalid public ID literal" + end + if accept_public_id + if @source.match(/#{public}\s+#{PUBIDLITERAL}\s+[^'"]/um) + return "system ID literal is missing" + end + unless @source.match(/#{public}\s+#{PUBIDLITERAL}\s+#{SYSTEMLITERAL}/um) + return "invalid system literal" + end + "garbage after system literal" + else + "garbage after public ID literal" + end + elsif accept_external_id and @source.match(/#{system}/um) + if @source.match(/#{system}(?:\s+[^'"]|\s*[\[>])/um) + return "system literal is missing" + end + unless @source.match(/#{system}\s+#{SYSTEMLITERAL}/um) + return "invalid system literal" + end + "garbage after system literal" + else + unless @source.match(/\A\s*(?:PUBLIC|SYSTEM)\s/um) + return "invalid ID type" + end + "ID type is missing" + end + end + + def process_instruction + name = parse_name("Malformed XML: Invalid processing instruction node") + if @source.match(/\s+/um, true) + match_data = @source.match(/(.*?)\?>/um, true) + unless match_data + raise ParseException.new("Malformed XML: Unclosed processing instruction", @source) + end + content = match_data[1] + else + content = nil + unless @source.match("?>", true) + raise ParseException.new("Malformed XML: Unclosed processing instruction", @source) + end + end + if name == "xml" + if @document_status + raise ParseException.new("Malformed XML: XML declaration is not at the start", @source) + end + version = VERSION.match(content) + version = version[1] unless version.nil? + encoding = ENCODING.match(content) + encoding = encoding[1] unless encoding.nil? + if need_source_encoding_update?(encoding) + @source.encoding = encoding + end + if encoding.nil? and /\AUTF-16(?:BE|LE)\z/i =~ @source.encoding + encoding = "UTF-16" + end + standalone = STANDALONE.match(content) + standalone = standalone[1] unless standalone.nil? + return [ :xmldecl, version, encoding, standalone ] + end + [:processing_instruction, name, content] + end + + def parse_attributes(prefixes, curr_ns) + attributes = {} + closed = false + while true + if @source.match(">", true) + return attributes, closed + elsif @source.match("/>", true) + closed = true + return attributes, closed + elsif match = @source.match(QNAME, true) + name = match[1] + prefix = match[2] + local_part = match[3] + + unless @source.match(/\s*=\s*/um, true) + message = "Missing attribute equal: <#{name}>" + raise REXML::ParseException.new(message, @source) + end + unless match = @source.match(/(['"])/, true) + message = "Missing attribute value start quote: <#{name}>" + raise REXML::ParseException.new(message, @source) + end + quote = match[1] + start_position = @source.position + value = @source.read_until(quote) + unless value.chomp!(quote) + @source.position = start_position + message = "Missing attribute value end quote: <#{name}>: <#{quote}>" + raise REXML::ParseException.new(message, @source) + end + @source.match(/\s*/um, true) + if prefix == "xmlns" + if local_part == "xml" + if value != "http://www.w3.org/XML/1998/namespace" + msg = "The 'xml' prefix must not be bound to any other namespace "+ + "(http://www.w3.org/TR/REC-xml-names/#ns-decl)" + raise REXML::ParseException.new( msg, @source, self ) + end + elsif local_part == "xmlns" + msg = "The 'xmlns' prefix must not be declared "+ + "(http://www.w3.org/TR/REC-xml-names/#ns-decl)" + raise REXML::ParseException.new( msg, @source, self) + end + curr_ns << local_part + elsif prefix + prefixes << prefix unless prefix == "xml" + end + + if attributes[name] + msg = "Duplicate attribute #{name.inspect}" + raise REXML::ParseException.new(msg, @source, self) + end + + attributes[name] = value + else + message = "Invalid attribute name: <#{@source.buffer.split(%r{[/>\s]}).first}>" + raise REXML::ParseException.new(message, @source) + end + end + end + end + end +end + +=begin + case event[0] + when :start_element + when :text + when :end_element + when :processing_instruction + when :cdata + when :comment + when :xmldecl + when :start_doctype + when :end_doctype + when :externalentity + when :elementdecl + when :entity + when :attlistdecl + when :notationdecl + when :end_doctype + end +=end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/lightparser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/lightparser.rb new file mode 100644 index 0000000..bdc0827 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/lightparser.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: false +require_relative 'streamparser' +require_relative 'baseparser' +require_relative '../light/node' + +module REXML + module Parsers + class LightParser + def initialize stream + @stream = stream + @parser = REXML::Parsers::BaseParser.new( stream ) + end + + def add_listener( listener ) + @parser.add_listener( listener ) + end + + def rewind + @stream.rewind + @parser.stream = @stream + end + + def parse + root = context = [ :document ] + while true + event = @parser.pull + case event[0] + when :end_document + break + when :start_element, :start_doctype + new_node = event + context << new_node + new_node[1,0] = [context] + context = new_node + when :end_element, :end_doctype + context = context[1] + else + new_node = event + context << new_node + new_node[1,0] = [context] + end + end + root + end + end + + # An element is an array. The array contains: + # 0 The parent element + # 1 The tag name + # 2 A hash of attributes + # 3..-1 The child elements + # An element is an array of size > 3 + # Text is a String + # PIs are [ :processing_instruction, target, data ] + # Comments are [ :comment, data ] + # DocTypes are DocType structs + # The root is an array with XMLDecls, Text, DocType, Array, Text + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/pullparser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/pullparser.rb new file mode 100644 index 0000000..36b4595 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/pullparser.rb @@ -0,0 +1,201 @@ +# frozen_string_literal: false +require 'forwardable' + +require_relative '../parseexception' +require_relative 'baseparser' +require_relative '../xmltokens' + +module REXML + module Parsers + # = Using the Pull Parser + # <em>This API is experimental, and subject to change.</em> + # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" ) + # while parser.has_next? + # res = parser.next + # puts res[1]['att'] if res.start_tag? and res[0] == 'b' + # end + # See the PullEvent class for information on the content of the results. + # The data is identical to the arguments passed for the various events to + # the StreamListener API. + # + # Notice that: + # parser = PullParser.new( "<a>BAD DOCUMENT" ) + # while parser.has_next? + # res = parser.next + # raise res[1] if res.error? + # end + # + # Nat Price gave me some good ideas for the API. + class PullParser + include XMLTokens + extend Forwardable + + def_delegators( :@parser, :has_next? ) + def_delegators( :@parser, :entity ) + def_delegators( :@parser, :empty? ) + def_delegators( :@parser, :source ) + + def initialize stream + @entities = {} + @listeners = nil + @parser = BaseParser.new( stream ) + @my_stack = [] + end + + def add_listener( listener ) + @listeners = [] unless @listeners + @listeners << listener + end + + def entity_expansion_count + @parser.entity_expansion_count + end + + def each + while has_next? + yield self.pull + end + end + + def peek depth=0 + if @my_stack.length <= depth + (depth - @my_stack.length + 1).times { + e = PullEvent.new(@parser.pull) + @my_stack.push(e) + } + end + @my_stack[depth] + end + + def pull + return @my_stack.shift if @my_stack.length > 0 + + event = @parser.pull + case event[0] + when :entitydecl + @entities[ event[1] ] = + event[2] unless event[2] =~ /PUBLIC|SYSTEM/ + when :text + unnormalized = @parser.unnormalize( event[1], @entities ) + event << unnormalized + end + PullEvent.new( event ) + end + + def unshift token + @my_stack.unshift token + end + end + + # A parsing event. The contents of the event are accessed as an +Array?, + # and the type is given either by the ...? methods, or by accessing the + # +type+ accessor. The contents of this object vary from event to event, + # but are identical to the arguments passed to +StreamListener+s for each + # event. + class PullEvent + # The type of this event. Will be one of :tag_start, :tag_end, :text, + # :processing_instruction, :comment, :doctype, :attlistdecl, :entitydecl, + # :notationdecl, :entity, :cdata, :xmldecl, or :error. + def initialize(arg) + @contents = arg + end + + def []( start, endd=nil) + if start.kind_of? Range + @contents.slice( start.begin+1 .. start.end ) + elsif start.kind_of? Numeric + if endd.nil? + @contents.slice( start+1 ) + else + @contents.slice( start+1, endd ) + end + else + raise "Illegal argument #{start.inspect} (#{start.class})" + end + end + + def event_type + @contents[0] + end + + # Content: [ String tag_name, Hash attributes ] + def start_element? + @contents[0] == :start_element + end + + # Content: [ String tag_name ] + def end_element? + @contents[0] == :end_element + end + + # Content: [ String raw_text, String unnormalized_text ] + def text? + @contents[0] == :text + end + + # Content: [ String text ] + def instruction? + @contents[0] == :processing_instruction + end + + # Content: [ String text ] + def comment? + @contents[0] == :comment + end + + # Content: [ String name, String pub_sys, String long_name, String uri ] + def doctype? + @contents[0] == :start_doctype + end + + # Content: [ String text ] + def attlistdecl? + @contents[0] == :attlistdecl + end + + # Content: [ String text ] + def elementdecl? + @contents[0] == :elementdecl + end + + # Due to the wonders of DTDs, an entity declaration can be just about + # anything. There's no way to normalize it; you'll have to interpret the + # content yourself. However, the following is true: + # + # * If the entity declaration is an internal entity: + # [ String name, String value ] + # Content: [ String text ] + def entitydecl? + @contents[0] == :entitydecl + end + + # Content: [ String text ] + def notationdecl? + @contents[0] == :notationdecl + end + + # Content: [ String text ] + def entity? + @contents[0] == :entity + end + + # Content: [ String text ] + def cdata? + @contents[0] == :cdata + end + + # Content: [ String version, String encoding, String standalone ] + def xmldecl? + @contents[0] == :xmldecl + end + + def error? + @contents[0] == :error + end + + def inspect + @contents[0].to_s + ": " + @contents[1..-1].inspect + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/sax2parser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/sax2parser.rb new file mode 100644 index 0000000..cec9d2f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/sax2parser.rb @@ -0,0 +1,260 @@ +# frozen_string_literal: false +require_relative 'baseparser' +require_relative '../parseexception' +require_relative '../namespace' +require_relative '../text' + +module REXML + module Parsers + # SAX2Parser + class SAX2Parser + def initialize source + @parser = BaseParser.new(source) + @listeners = [] + @procs = [] + @namespace_stack = [] + @has_listeners = false + @tag_stack = [] + @entities = {} + end + + def source + @parser.source + end + + def entity_expansion_count + @parser.entity_expansion_count + end + + def add_listener( listener ) + @parser.add_listener( listener ) + end + + # Listen arguments: + # + # Symbol, Array, Block + # Listen to Symbol events on Array elements + # Symbol, Block + # Listen to Symbol events + # Array, Listener + # Listen to all events on Array elements + # Array, Block + # Listen to :start_element events on Array elements + # Listener + # Listen to All events + # + # Symbol can be one of: :start_element, :end_element, + # :start_prefix_mapping, :end_prefix_mapping, :characters, + # :processing_instruction, :doctype, :attlistdecl, :elementdecl, + # :entitydecl, :notationdecl, :cdata, :xmldecl, :comment + # + # There is an additional symbol that can be listened for: :progress. + # This will be called for every event generated, passing in the current + # stream position. + # + # Array contains regular expressions or strings which will be matched + # against fully qualified element names. + # + # Listener must implement the methods in SAX2Listener + # + # Block will be passed the same arguments as a SAX2Listener method would + # be, where the method name is the same as the matched Symbol. + # See the SAX2Listener for more information. + def listen( *args, &blok ) + if args[0].kind_of? Symbol + if args.size == 2 + args[1].each { |match| @procs << [args[0], match, blok] } + else + add( [args[0], nil, blok] ) + end + elsif args[0].kind_of? Array + if args.size == 2 + args[0].each { |match| add( [nil, match, args[1]] ) } + else + args[0].each { |match| add( [ :start_element, match, blok ] ) } + end + else + add([nil, nil, args[0]]) + end + end + + def deafen( listener=nil, &blok ) + if listener + @listeners.delete_if {|item| item[-1] == listener } + @has_listeners = false if @listeners.size == 0 + else + @procs.delete_if {|item| item[-1] == blok } + end + end + + def parse + @procs.each { |sym,match,block| block.call if sym == :start_document } + @listeners.each { |sym,match,block| + block.start_document if sym == :start_document or sym.nil? + } + context = [] + while true + event = @parser.pull + case event[0] + when :end_document + handle( :end_document ) + break + when :start_doctype + handle( :doctype, *event[1..-1]) + when :end_doctype + context = context[1] + when :start_element + @tag_stack.push(event[1]) + # find the observers for namespaces + procs = get_procs( :start_prefix_mapping, event[1] ) + listeners = get_listeners( :start_prefix_mapping, event[1] ) + if procs or listeners + # break out the namespace declarations + # The attributes live in event[2] + event[2].each {|n, v| event[2][n] = @parser.normalize(v)} + nsdecl = event[2].find_all { |n, value| n =~ /^xmlns(:|$)/ } + nsdecl.collect! { |n, value| [ n[6..-1], value ] } + @namespace_stack.push({}) + nsdecl.each do |n,v| + @namespace_stack[-1][n] = v + # notify observers of namespaces + procs.each { |ob| ob.call( n, v ) } if procs + listeners.each { |ob| ob.start_prefix_mapping(n, v) } if listeners + end + end + event[1] =~ Namespace::NAMESPLIT + prefix = $1 + local = $2 + uri = get_namespace(prefix) + # find the observers for start_element + procs = get_procs( :start_element, event[1] ) + listeners = get_listeners( :start_element, event[1] ) + # notify observers + procs.each { |ob| ob.call( uri, local, event[1], event[2] ) } if procs + listeners.each { |ob| + ob.start_element( uri, local, event[1], event[2] ) + } if listeners + when :end_element + @tag_stack.pop + event[1] =~ Namespace::NAMESPLIT + prefix = $1 + local = $2 + uri = get_namespace(prefix) + # find the observers for start_element + procs = get_procs( :end_element, event[1] ) + listeners = get_listeners( :end_element, event[1] ) + # notify observers + procs.each { |ob| ob.call( uri, local, event[1] ) } if procs + listeners.each { |ob| + ob.end_element( uri, local, event[1] ) + } if listeners + + namespace_mapping = @namespace_stack.pop + # find the observers for namespaces + procs = get_procs( :end_prefix_mapping, event[1] ) + listeners = get_listeners( :end_prefix_mapping, event[1] ) + if procs or listeners + namespace_mapping.each do |ns_prefix, ns_uri| + # notify observers of namespaces + procs.each { |ob| ob.call( ns_prefix ) } if procs + listeners.each { |ob| ob.end_prefix_mapping(ns_prefix) } if listeners + end + end + when :text + unnormalized = @parser.unnormalize( event[1], @entities ) + handle( :characters, unnormalized ) + when :entitydecl + handle_entitydecl( event ) + when :processing_instruction, :comment, :attlistdecl, + :elementdecl, :cdata, :notationdecl, :xmldecl + handle( *event ) + end + handle( :progress, @parser.position ) + end + end + + private + def handle( symbol, *arguments ) + tag = @tag_stack[-1] + procs = get_procs( symbol, tag ) + listeners = get_listeners( symbol, tag ) + # notify observers + procs.each { |ob| ob.call( *arguments ) } if procs + listeners.each { |l| + l.send( symbol.to_s, *arguments ) + } if listeners + end + + def handle_entitydecl( event ) + @entities[ event[1] ] = event[2] if event.size == 3 + parameter_reference_p = false + case event[2] + when "SYSTEM" + if event.size == 5 + if event.last == "%" + parameter_reference_p = true + else + event[4, 0] = "NDATA" + end + end + when "PUBLIC" + if event.size == 6 + if event.last == "%" + parameter_reference_p = true + else + event[5, 0] = "NDATA" + end + end + else + parameter_reference_p = (event.size == 4) + end + event[1, 0] = event.pop if parameter_reference_p + handle( event[0], event[1..-1] ) + end + + # The following methods are duplicates, but it is faster than using + # a helper + def get_procs( symbol, name ) + return nil if @procs.size == 0 + @procs.find_all do |sym, match, block| + ( + (sym.nil? or symbol == sym) and + ((name.nil? and match.nil?) or match.nil? or ( + (name == match) or + (match.kind_of? Regexp and name =~ match) + ) + ) + ) + end.collect{|x| x[-1]} + end + def get_listeners( symbol, name ) + return nil if @listeners.size == 0 + @listeners.find_all do |sym, match, block| + ( + (sym.nil? or symbol == sym) and + ((name.nil? and match.nil?) or match.nil? or ( + (name == match) or + (match.kind_of? Regexp and name =~ match) + ) + ) + ) + end.collect{|x| x[-1]} + end + + def add( pair ) + if pair[-1].respond_to? :call + @procs << pair unless @procs.include? pair + else + @listeners << pair unless @listeners.include? pair + @has_listeners = true + end + end + + def get_namespace( prefix ) + uris = (@namespace_stack.find_all { |ns| not ns[prefix].nil? }) || + (@namespace_stack.find { |ns| not ns[nil].nil? }) + uris[-1][prefix] unless uris.nil? or 0 == uris.size + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/streamparser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/streamparser.rb new file mode 100644 index 0000000..fa3ac49 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/streamparser.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: false +require_relative "baseparser" + +module REXML + module Parsers + class StreamParser + def initialize source, listener + @listener = listener + @parser = BaseParser.new( source ) + @tag_stack = [] + end + + def add_listener( listener ) + @parser.add_listener( listener ) + end + + def parse + # entity string + while true + event = @parser.pull + case event[0] + when :end_document + unless @tag_stack.empty? + tag_path = "/" + @tag_stack.join("/") + raise ParseException.new("Missing end tag for '#{tag_path}'", + @parser.source) + end + return + when :start_element + @tag_stack << event[1] + attrs = event[2].each do |n, v| + event[2][n] = @parser.unnormalize( v ) + end + @listener.tag_start( event[1], attrs ) + when :end_element + @listener.tag_end( event[1] ) + @tag_stack.pop + when :text + unnormalized = @parser.unnormalize( event[1] ) + @listener.text( unnormalized ) + when :processing_instruction + @listener.instruction( *event[1,2] ) + when :start_doctype + @listener.doctype( *event[1..-1] ) + when :end_doctype + # FIXME: remove this condition for milestone:3.2 + @listener.doctype_end if @listener.respond_to? :doctype_end + when :comment, :attlistdecl, :cdata, :xmldecl, :elementdecl + @listener.send( event[0].to_s, *event[1..-1] ) + when :entitydecl, :notationdecl + @listener.send( event[0].to_s, event[1..-1] ) + when :externalentity + entity_reference = event[1] + content = entity_reference.gsub(/\A%|;\z/, "") + @listener.entity(content) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/treeparser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/treeparser.rb new file mode 100644 index 0000000..0cb6f7c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/treeparser.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: false +require_relative '../validation/validationexception' +require_relative '../undefinednamespaceexception' + +module REXML + module Parsers + class TreeParser + def initialize( source, build_context = Document.new ) + @build_context = build_context + @parser = Parsers::BaseParser.new( source ) + end + + def add_listener( listener ) + @parser.add_listener( listener ) + end + + def parse + tag_stack = [] + entities = nil + begin + while true + event = @parser.pull + #STDERR.puts "TREEPARSER GOT #{event.inspect}" + case event[0] + when :end_document + unless tag_stack.empty? + raise ParseException.new("No close tag for #{@build_context.xpath}", + @parser.source, @parser) + end + return + when :start_element + tag_stack.push(event[1]) + el = @build_context = @build_context.add_element( event[1] ) + event[2].each do |key, value| + el.attributes[key]=Attribute.new(key,value,self) + end + when :end_element + tag_stack.pop + @build_context = @build_context.parent + when :text + if @build_context[-1].instance_of? Text + @build_context[-1] << event[1] + else + @build_context.add( + Text.new(event[1], @build_context.whitespace, nil, true) + ) unless ( + @build_context.ignore_whitespace_nodes and + event[1].strip.size==0 + ) + end + when :comment + c = Comment.new( event[1] ) + @build_context.add( c ) + when :cdata + c = CData.new( event[1] ) + @build_context.add( c ) + when :processing_instruction + @build_context.add( Instruction.new( event[1], event[2] ) ) + when :end_doctype + entities.each { |k,v| entities[k] = @build_context.entities[k].value } + @build_context = @build_context.parent + when :start_doctype + doctype = DocType.new( event[1..-1], @build_context ) + @build_context = doctype + entities = {} + when :attlistdecl + n = AttlistDecl.new( event[1..-1] ) + @build_context.add( n ) + when :externalentity + n = ExternalEntity.new( event[1] ) + @build_context.add( n ) + when :elementdecl + n = ElementDecl.new( event[1] ) + @build_context.add(n) + when :entitydecl + entities[ event[1] ] = event[2] unless event[2] =~ /PUBLIC|SYSTEM/ + @build_context.add(Entity.new(event)) + when :notationdecl + n = NotationDecl.new( *event[1..-1] ) + @build_context.add( n ) + when :xmldecl + x = XMLDecl.new( event[1], event[2], event[3] ) + @build_context.add( x ) + end + end + rescue REXML::Validation::ValidationException + raise + rescue REXML::ParseException + raise + rescue + raise ParseException.new( $!.message, @parser.source, @parser, $! ) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/ultralightparser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/ultralightparser.rb new file mode 100644 index 0000000..e0029f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/ultralightparser.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: false +require_relative 'streamparser' +require_relative 'baseparser' + +module REXML + module Parsers + class UltraLightParser + def initialize stream + @stream = stream + @parser = REXML::Parsers::BaseParser.new( stream ) + end + + def add_listener( listener ) + @parser.add_listener( listener ) + end + + def rewind + @stream.rewind + @parser.stream = @stream + end + + def parse + root = context = [] + while true + event = @parser.pull + case event[0] + when :end_document + break + when :end_doctype + context = context[1] + when :start_element, :start_doctype + context << event + event[1,0] = [context] + context = event + when :end_element + context = context[1] + else + context << event + end + end + root + end + end + + # An element is an array. The array contains: + # 0 The parent element + # 1 The tag name + # 2 A hash of attributes + # 3..-1 The child elements + # An element is an array of size > 3 + # Text is a String + # PIs are [ :processing_instruction, target, data ] + # Comments are [ :comment, data ] + # DocTypes are DocType structs + # The root is an array with XMLDecls, Text, DocType, Array, Text + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/xpathparser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/xpathparser.rb new file mode 100644 index 0000000..bd3b685 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/parsers/xpathparser.rb @@ -0,0 +1,739 @@ +# frozen_string_literal: false + +require_relative '../namespace' +require_relative '../xmltokens' + +module REXML + module Parsers + # You don't want to use this class. Really. Use XPath, which is a wrapper + # for this class. Believe me. You don't want to poke around in here. + # There is strange, dark magic at work in this code. Beware. Go back! Go + # back while you still can! + class XPathParser + include XMLTokens + LITERAL = /^'([^']*)'|^"([^"]*)"/u + + def namespaces=( namespaces ) + Functions::namespace_context = namespaces + @namespaces = namespaces + end + + def parse path + path = path.dup + path.gsub!(/([\(\[])\s+/, '\1') # Strip ignorable spaces + path.gsub!( /\s+([\]\)])/, '\1') + parsed = [] + rest = OrExpr(path, parsed) + if rest + unless rest.strip.empty? + raise ParseException.new("Garbage component exists at the end: " + + "<#{rest}>: <#{path}>") + end + end + parsed + end + + def predicate path + parsed = [] + Predicate( "[#{path}]", parsed ) + parsed + end + + def abbreviate(path_or_parsed) + if path_or_parsed.kind_of?(String) + parsed = parse(path_or_parsed) + else + parsed = path_or_parsed + end + components = [] + component = nil + while parsed.size > 0 + op = parsed.shift + case op + when :node + component << "node()" + when :attribute + component = "@" + components << component + when :child + component = "" + components << component + when :descendant_or_self + next_op = parsed[0] + if next_op == :node + parsed.shift + component = "" + components << component + else + component = "descendant-or-self::" + components << component + end + when :self + next_op = parsed[0] + if next_op == :node + parsed.shift + components << "." + else + component = "self::" + components << component + end + when :parent + next_op = parsed[0] + if next_op == :node + parsed.shift + components << ".." + else + component = "parent::" + components << component + end + when :any + component << "*" + when :text + component << "text()" + when :following, :following_sibling, + :ancestor, :ancestor_or_self, :descendant, + :namespace, :preceding, :preceding_sibling + component = op.to_s.tr("_", "-") << "::" + components << component + when :qname + prefix = parsed.shift + name = parsed.shift + component << prefix+":" if prefix.size > 0 + component << name + when :predicate + component << '[' + component << predicate_to_path(parsed.shift) {|x| abbreviate(x)} + component << ']' + when :document + components << "" + when :function + component << parsed.shift + component << "( " + component << predicate_to_path(parsed.shift[0]) {|x| abbreviate(x)} + component << " )" + when :literal + component << quote_literal(parsed.shift) + else + component << "UNKNOWN(" + component << op.inspect + component << ")" + end + end + case components + when [""] + "/" + when ["", ""] + "//" + else + components.join("/") + end + end + + def expand(path_or_parsed) + if path_or_parsed.kind_of?(String) + parsed = parse(path_or_parsed) + else + parsed = path_or_parsed + end + path = "" + document = false + while parsed.size > 0 + op = parsed.shift + case op + when :node + path << "node()" + when :attribute, :child, :following, :following_sibling, + :ancestor, :ancestor_or_self, :descendant, :descendant_or_self, + :namespace, :preceding, :preceding_sibling, :self, :parent + path << "/" unless path.size == 0 + path << op.to_s.tr("_", "-") + path << "::" + when :any + path << "*" + when :qname + prefix = parsed.shift + name = parsed.shift + path << prefix+":" if prefix.size > 0 + path << name + when :predicate + path << '[' + path << predicate_to_path( parsed.shift ) { |x| expand(x) } + path << ']' + when :document + document = true + else + path << "UNKNOWN(" + path << op.inspect + path << ")" + end + end + path = "/"+path if document + path + end + + def predicate_to_path(parsed, &block) + path = "" + case parsed[0] + when :and, :or, :mult, :plus, :minus, :neq, :eq, :lt, :gt, :lteq, :gteq, :div, :mod, :union + op = parsed.shift + case op + when :eq + op = "=" + when :lt + op = "<" + when :gt + op = ">" + when :lteq + op = "<=" + when :gteq + op = ">=" + when :neq + op = "!=" + when :union + op = "|" + end + left = predicate_to_path( parsed.shift, &block ) + right = predicate_to_path( parsed.shift, &block ) + path << left + path << " " + path << op.to_s + path << " " + path << right + when :function + parsed.shift + name = parsed.shift + path << name + path << "(" + parsed.shift.each_with_index do |argument, i| + path << ", " if i > 0 + path << predicate_to_path(argument, &block) + end + path << ")" + when :literal + parsed.shift + path << quote_literal(parsed.shift) + else + path << yield( parsed ) + end + return path.squeeze(" ") + end + # For backward compatibility + alias_method :preciate_to_string, :predicate_to_path + + private + def quote_literal( literal ) + case literal + when String + # XPath 1.0 does not support escape characters. + # Assumes literal does not contain both single and double quotes. + if literal.include?("'") + "\"#{literal}\"" + else + "'#{literal}'" + end + else + literal.inspect + end + end + + #LocationPath + # | RelativeLocationPath + # | '/' RelativeLocationPath? + # | '//' RelativeLocationPath + def LocationPath path, parsed + path = path.lstrip + if path[0] == ?/ + parsed << :document + if path[1] == ?/ + parsed << :descendant_or_self + parsed << :node + path = path[2..-1] + else + path = path[1..-1] + end + end + return RelativeLocationPath( path, parsed ) if path.size > 0 + end + + #RelativeLocationPath + # | Step + # | (AXIS_NAME '::' | '@' | '') AxisSpecifier + # NodeTest + # Predicate + # | '.' | '..' AbbreviatedStep + # | RelativeLocationPath '/' Step + # | RelativeLocationPath '//' Step + AXIS = /^(ancestor|ancestor-or-self|attribute|child|descendant|descendant-or-self|following|following-sibling|namespace|parent|preceding|preceding-sibling|self)::/ + def RelativeLocationPath path, parsed + loop do + original_path = path + path = path.lstrip + + return original_path if path.empty? + + # (axis or @ or <child::>) nodetest predicate > + # OR > / Step + # (. or ..) > + if path[0] == ?. + if path[1] == ?. + parsed << :parent + parsed << :node + path = path[2..-1] + else + parsed << :self + parsed << :node + path = path[1..-1] + end + else + path_before_axis_specifier = path + parsed_not_abberviated = [] + if path[0] == ?@ + parsed_not_abberviated << :attribute + path = path[1..-1] + # Goto Nodetest + elsif path =~ AXIS + parsed_not_abberviated << $1.tr('-','_').intern + path = $' + # Goto Nodetest + else + parsed_not_abberviated << :child + end + + path_before_node_test = path + path = NodeTest(path, parsed_not_abberviated) + if path == path_before_node_test + return path_before_axis_specifier + end + path = Predicate(path, parsed_not_abberviated) + + parsed.concat(parsed_not_abberviated) + end + + original_path = path + path = path.lstrip + return original_path if path.empty? + + return original_path if path[0] != ?/ + + if path[1] == ?/ + parsed << :descendant_or_self + parsed << :node + path = path[2..-1] + else + path = path[1..-1] + end + end + end + + # Returns a 1-1 map of the nodeset + # The contents of the resulting array are either: + # true/false, if a positive match + # String, if a name match + #NodeTest + # | ('*' | NCNAME ':' '*' | QNAME) NameTest + # | '*' ':' NCNAME NameTest since XPath 2.0 + # | NODE_TYPE '(' ')' NodeType + # | PI '(' LITERAL ')' PI + # | '[' expr ']' Predicate + PREFIX_WILDCARD = /^\*:(#{NCNAME_STR})/u + LOCAL_NAME_WILDCARD = /^(#{NCNAME_STR}):\*/u + QNAME = Namespace::NAMESPLIT + NODE_TYPE = /^(comment|text|node)\(\s*\)/m + PI = /^processing-instruction\(/ + def NodeTest path, parsed + original_path = path + path = path.lstrip + case path + when PREFIX_WILDCARD + prefix = nil + name = $1 + path = $' + parsed << :qname + parsed << prefix + parsed << name + when /^\*/ + path = $' + parsed << :any + when NODE_TYPE + type = $1 + path = $' + parsed << type.tr('-', '_').intern + when PI + path = $' + literal = nil + if path =~ /^\s*\)/ + path = $' + else + path =~ LITERAL + literal = $1 + path = $' + raise ParseException.new("Missing ')' after processing instruction") if path[0] != ?) + path = path[1..-1] + end + parsed << :processing_instruction + parsed << (literal || '') + when LOCAL_NAME_WILDCARD + prefix = $1 + path = $' + parsed << :namespace + parsed << prefix + when QNAME + prefix = $1 + name = $2 + path = $' + prefix = "" unless prefix + parsed << :qname + parsed << prefix + parsed << name + else + path = original_path + end + return path + end + + # Filters the supplied nodeset on the predicate(s) + def Predicate path, parsed + original_path = path + path = path.lstrip + return original_path unless path[0] == ?[ + predicates = [] + while path[0] == ?[ + path, expr = get_group(path) + predicates << expr[1..-2] if expr + end + predicates.each{ |pred| + preds = [] + parsed << :predicate + parsed << preds + OrExpr(pred, preds) + } + path + end + + # The following return arrays of true/false, a 1-1 mapping of the + # supplied nodeset, except for axe(), which returns a filtered + # nodeset + + #| OrExpr S 'or' S AndExpr + #| AndExpr + def OrExpr path, parsed + n = [] + rest = AndExpr( path, n ) + if rest != path + while rest =~ /^\s*( or )/ + n = [ :or, n, [] ] + rest = AndExpr( $', n[-1] ) + end + end + if parsed.size == 0 and n.size != 0 + parsed.replace(n) + elsif n.size > 0 + parsed << n + end + rest + end + + #| AndExpr S 'and' S EqualityExpr + #| EqualityExpr + def AndExpr path, parsed + n = [] + rest = EqualityExpr( path, n ) + if rest != path + while rest =~ /^\s*( and )/ + n = [ :and, n, [] ] + rest = EqualityExpr( $', n[-1] ) + end + end + if parsed.size == 0 and n.size != 0 + parsed.replace(n) + elsif n.size > 0 + parsed << n + end + rest + end + + #| EqualityExpr ('=' | '!=') RelationalExpr + #| RelationalExpr + def EqualityExpr path, parsed + n = [] + rest = RelationalExpr( path, n ) + if rest != path + while rest =~ /^\s*(!?=)\s*/ + if $1[0] == ?! + n = [ :neq, n, [] ] + else + n = [ :eq, n, [] ] + end + rest = RelationalExpr( $', n[-1] ) + end + end + if parsed.size == 0 and n.size != 0 + parsed.replace(n) + elsif n.size > 0 + parsed << n + end + rest + end + + #| RelationalExpr ('<' | '>' | '<=' | '>=') AdditiveExpr + #| AdditiveExpr + def RelationalExpr path, parsed + n = [] + rest = AdditiveExpr( path, n ) + if rest != path + while rest =~ /^\s*([<>]=?)\s*/ + if $1[0] == ?< + sym = "lt" + else + sym = "gt" + end + sym << "eq" if $1[-1] == ?= + n = [ sym.intern, n, [] ] + rest = AdditiveExpr( $', n[-1] ) + end + end + if parsed.size == 0 and n.size != 0 + parsed.replace(n) + elsif n.size > 0 + parsed << n + end + rest + end + + #| AdditiveExpr ('+' | '-') MultiplicativeExpr + #| MultiplicativeExpr + def AdditiveExpr path, parsed + n = [] + rest = MultiplicativeExpr( path, n ) + if rest != path + while rest =~ /^\s*(\+|-)\s*/ + if $1[0] == ?+ + n = [ :plus, n, [] ] + else + n = [ :minus, n, [] ] + end + rest = MultiplicativeExpr( $', n[-1] ) + end + end + if parsed.size == 0 and n.size != 0 + parsed.replace(n) + elsif n.size > 0 + parsed << n + end + rest + end + + #| MultiplicativeExpr ('*' | S ('div' | 'mod') S) UnaryExpr + #| UnaryExpr + def MultiplicativeExpr path, parsed + n = [] + rest = UnaryExpr( path, n ) + if rest != path + while rest =~ /^\s*(\*| div | mod )\s*/ + if $1[0] == ?* + n = [ :mult, n, [] ] + elsif $1.include?( "div" ) + n = [ :div, n, [] ] + else + n = [ :mod, n, [] ] + end + rest = UnaryExpr( $', n[-1] ) + end + end + if parsed.size == 0 and n.size != 0 + parsed.replace(n) + elsif n.size > 0 + parsed << n + end + rest + end + + #| '-' UnaryExpr + #| UnionExpr + def UnaryExpr path, parsed + path =~ /^(\-*)/ + path = $' + if $1 and (($1.size % 2) != 0) + mult = -1 + else + mult = 1 + end + parsed << :neg if mult < 0 + + n = [] + path = UnionExpr( path, n ) + parsed.concat( n ) + path + end + + #| UnionExpr '|' PathExpr + #| PathExpr + def UnionExpr path, parsed + n = [] + rest = PathExpr( path, n ) + if rest != path + while rest =~ /^\s*(\|)\s*/ + n = [ :union, n, [] ] + rest = PathExpr( $', n[-1] ) + end + end + if parsed.size == 0 and n.size != 0 + parsed.replace( n ) + elsif n.size > 0 + parsed << n + end + rest + end + + #| LocationPath + #| FilterExpr ('/' | '//') RelativeLocationPath + def PathExpr path, parsed + path = path.lstrip + n = [] + rest = FilterExpr( path, n ) + if rest != path + if rest and rest[0] == ?/ + rest = RelativeLocationPath(rest, n) + parsed.concat(n) + return rest + end + end + rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w*]/ + parsed.concat(n) + return rest + end + + #| FilterExpr Predicate + #| PrimaryExpr + def FilterExpr path, parsed + n = [] + path_before_primary_expr = path + path = PrimaryExpr(path, n) + return path_before_primary_expr if path == path_before_primary_expr + path = Predicate(path, n) + parsed.concat(n) + path + end + + #| VARIABLE_REFERENCE + #| '(' expr ')' + #| LITERAL + #| NUMBER + #| FunctionCall + VARIABLE_REFERENCE = /^\$(#{NAME_STR})/u + NUMBER = /^(\d*\.?\d+)/ + NT = /^comment|text|processing-instruction|node$/ + def PrimaryExpr path, parsed + case path + when VARIABLE_REFERENCE + varname = $1 + path = $' + parsed << :variable + parsed << varname + #arry << @variables[ varname ] + when /^(\w[-\w]*)(?:\()/ + fname = $1 + tmp = $' + return path if fname =~ NT + path = tmp + parsed << :function + parsed << fname + path = FunctionCall(path, parsed) + when NUMBER + varname = $1.nil? ? $2 : $1 + path = $' + parsed << :literal + parsed << (varname.include?('.') ? varname.to_f : varname.to_i) + when LITERAL + varname = $1.nil? ? $2 : $1 + path = $' + parsed << :literal + parsed << varname + when /^\(/ #/ + path, contents = get_group(path) + contents = contents[1..-2] + n = [] + OrExpr( contents, n ) + parsed.concat(n) + end + path + end + + #| FUNCTION_NAME '(' ( expr ( ',' expr )* )? ')' + def FunctionCall rest, parsed + path, arguments = parse_args(rest) + argset = [] + for argument in arguments + args = [] + OrExpr( argument, args ) + argset << args + end + parsed << argset + path + end + + # get_group( '[foo]bar' ) -> ['bar', '[foo]'] + def get_group string + ind = 0 + depth = 0 + st = string[0,1] + en = (st == "(" ? ")" : "]") + begin + case string[ind,1] + when st + depth += 1 + when en + depth -= 1 + end + ind += 1 + end while depth > 0 and ind < string.length + return nil unless depth==0 + [string[ind..-1], string[0..ind-1]] + end + + def parse_args( string ) + arguments = [] + ind = 0 + inquot = false + inapos = false + depth = 1 + begin + case string[ind] + when ?" + inquot = !inquot unless inapos + when ?' + inapos = !inapos unless inquot + else + unless inquot or inapos + case string[ind] + when ?( + depth += 1 + if depth == 1 + string = string[1..-1] + ind -= 1 + end + when ?) + depth -= 1 + if depth == 0 + s = string[0,ind].strip + arguments << s unless s == "" + string = string[ind+1..-1] + end + when ?, + if depth == 1 + s = string[0,ind].strip + arguments << s unless s == "" + string = string[ind+1..-1] + ind = -1 + end + end + end + end + ind += 1 + end while depth > 0 and ind < string.length + return nil unless depth==0 + [string,arguments] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/quickpath.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/quickpath.rb new file mode 100644 index 0000000..a0466b2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/quickpath.rb @@ -0,0 +1,266 @@ +# frozen_string_literal: false +require_relative 'functions' +require_relative 'xmltokens' + +module REXML + class QuickPath + include Functions + include XMLTokens + + # A base Hash object to be used when initializing a + # default empty namespaces set. + EMPTY_HASH = {} + + def QuickPath::first element, path, namespaces=EMPTY_HASH + match(element, path, namespaces)[0] + end + + def QuickPath::each element, path, namespaces=EMPTY_HASH, &block + path = "*" unless path + match(element, path, namespaces).each( &block ) + end + + def QuickPath::match element, path, namespaces=EMPTY_HASH + raise "nil is not a valid xpath" unless path + results = nil + Functions::namespace_context = namespaces + case path + when /^\/([^\/]|$)/u + # match on root + path = path[1..-1] + return [element.root.parent] if path == '' + results = filter([element.root], path) + when /^[-\w]*::/u + results = filter([element], path) + when /^\*/u + results = filter(element.to_a, path) + when /^[\[!\w:]/u + # match on child + children = element.to_a + results = filter(children, path) + else + results = filter([element], path) + end + return results + end + + # Given an array of nodes it filters the array based on the path. The + # result is that when this method returns, the array will contain elements + # which match the path + def QuickPath::filter elements, path + return elements if path.nil? or path == '' or elements.size == 0 + case path + when /^\/\//u # Descendant + return axe( elements, "descendant-or-self", $' ) + when /^\/?\b(\w[-\w]*)\b::/u # Axe + return axe( elements, $1, $' ) + when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child + rest = $' + results = [] + elements.each do |element| + results |= filter( element.to_a, rest ) + end + return results + when /^\/?(\w[-\w]*)\(/u # / Function + return function( elements, $1, $' ) + when Namespace::NAMESPLIT # Element name + name = $2 + ns = $1 + rest = $' + elements.delete_if do |element| + !(element.kind_of? Element and + (element.expanded_name == name or + (element.name == name and + element.namespace == Functions.namespace_context[ns]))) + end + return filter( elements, rest ) + when /^\/\[/u + matches = [] + elements.each do |element| + matches |= predicate( element.to_a, path[1..-1] ) if element.kind_of? Element + end + return matches + when /^\[/u # Predicate + return predicate( elements, path ) + when /^\/?\.\.\./u # Ancestor + return axe( elements, "ancestor", $' ) + when /^\/?\.\./u # Parent + return filter( elements.collect{|e|e.parent}, $' ) + when /^\/?\./u # Self + return filter( elements, $' ) + when /^\*/u # Any + results = [] + elements.each do |element| + results |= filter( [element], $' ) if element.kind_of? Element + #if element.kind_of? Element + # children = element.to_a + # children.delete_if { |child| !child.kind_of?(Element) } + # results |= filter( children, $' ) + #end + end + return results + end + return [] + end + + def QuickPath::axe( elements, axe_name, rest ) + matches = [] + matches = filter( elements.dup, rest ) if axe_name =~ /-or-self$/u + case axe_name + when /^descendant/u + elements.each do |element| + matches |= filter( element.to_a, "descendant-or-self::#{rest}" ) if element.kind_of? Element + end + when /^ancestor/u + elements.each do |element| + while element.parent + matches << element.parent + element = element.parent + end + end + matches = filter( matches, rest ) + when "self" + matches = filter( elements, rest ) + when "child" + elements.each do |element| + matches |= filter( element.to_a, rest ) if element.kind_of? Element + end + when "attribute" + elements.each do |element| + matches << element.attributes[ rest ] if element.kind_of? Element + end + when "parent" + matches = filter(elements.collect{|element| element.parent}.uniq, rest) + when "following-sibling" + matches = filter(elements.collect{|element| element.next_sibling}.uniq, + rest) + when "previous-sibling" + matches = filter(elements.collect{|element| + element.previous_sibling}.uniq, rest ) + end + return matches.uniq + end + + OPERAND_ = '((?=(?:(?!and|or).)*[^\s<>=])[^\s<>=]+)' + # A predicate filters a node-set with respect to an axis to produce a + # new node-set. For each node in the node-set to be filtered, the + # PredicateExpr is evaluated with that node as the context node, with + # the number of nodes in the node-set as the context size, and with the + # proximity position of the node in the node-set with respect to the + # axis as the context position; if PredicateExpr evaluates to true for + # that node, the node is included in the new node-set; otherwise, it is + # not included. + # + # A PredicateExpr is evaluated by evaluating the Expr and converting + # the result to a boolean. If the result is a number, the result will + # be converted to true if the number is equal to the context position + # and will be converted to false otherwise; if the result is not a + # number, then the result will be converted as if by a call to the + # boolean function. Thus a location path para[3] is equivalent to + # para[position()=3]. + def QuickPath::predicate( elements, path ) + ind = 1 + bcount = 1 + while bcount > 0 + bcount += 1 if path[ind] == ?[ + bcount -= 1 if path[ind] == ?] + ind += 1 + end + ind -= 1 + predicate = path[1..ind-1] + rest = path[ind+1..-1] + + # have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c' + # + predicate.gsub!( + /#{OPERAND_}\s*([<>=])\s*#{OPERAND_}\s*([<>=])\s*#{OPERAND_}/u, + '\1 \2 \3 and \3 \4 \5' ) + # Let's do some Ruby trickery to avoid some work: + predicate.gsub!( /&/u, "&&" ) + predicate.gsub!( /=/u, "==" ) + predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' ) + predicate.gsub!( /\bmod\b/u, "%" ) + predicate.gsub!( /\b(\w[-\w.]*\()/u ) { + fname = $1 + fname.gsub( /-/u, "_" ) + } + + Functions.pair = [ 0, elements.size ] + results = [] + elements.each do |element| + Functions.pair[0] += 1 + Functions.node = element + res = eval( predicate ) + case res + when true + results << element + when Integer + results << element if Functions.pair[0] == res + when String + results << element + end + end + return filter( results, rest ) + end + + def QuickPath::attribute( name ) + return Functions.node.attributes[name] if Functions.node.kind_of? Element + end + + def QuickPath::name() + return Functions.node.name if Functions.node.kind_of? Element + end + + def QuickPath::method_missing( id, *args ) + begin + Functions.send( id.id2name, *args ) + rescue Exception + raise "METHOD: #{id.id2name}(#{args.join ', '})\n#{$!.message}" + end + end + + def QuickPath::function( elements, fname, rest ) + args = parse_args( elements, rest ) + Functions.pair = [0, elements.size] + results = [] + elements.each do |element| + Functions.pair[0] += 1 + Functions.node = element + res = Functions.send( fname, *args ) + case res + when true + results << element + when Integer + results << element if Functions.pair[0] == res + end + end + return results + end + + def QuickPath::parse_args( element, string ) + # /.*?(?:\)|,)/ + arguments = [] + buffer = "" + while string and string != "" + c = string[0] + string.sub!(/^./u, "") + case c + when ?, + # if depth = 1, then we start a new argument + arguments << evaluate( buffer ) + #arguments << evaluate( string[0..count] ) + when ?( + # start a new method call + function( element, buffer, string ) + buffer = "" + when ?) + # close the method call and return arguments + return arguments + else + buffer << c + end + end + "" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/rexml.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/rexml.rb new file mode 100644 index 0000000..bb804b0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/rexml.rb @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# frozen_string_literal: false +# +# \Module \REXML provides classes and methods for parsing, +# editing, and generating XML. +# +# == Implementation +# +# \REXML: +# - Is pure Ruby. +# - Provides tree, stream, SAX2, pull, and lightweight APIs. +# - Conforms to {XML version 1.0}[https://www.w3.org/TR/REC-xml/]. +# - Fully implements {XPath version 1.0}[http://www.w3c.org/tr/xpath]. +# - Is {non-validating}[https://www.w3.org/TR/xml/]. +# - Passes 100% of the non-validating {Oasis tests}[http://www.oasis-open.org/committees/xml-conformance/xml-test-suite.shtml]. +# +# == In a Hurry? +# +# If you're somewhat familiar with XML +# and have a particular task in mind, +# you may want to see {the tasks pages}[doc/rexml/tasks/tocs/master_toc_rdoc.html]. +# +# == API +# +# Among the most important classes for using \REXML are: +# - REXML::Document. +# - REXML::Element. +# +# There's also an {REXML tutorial}[doc/rexml/tutorial_rdoc.html]. +# +module REXML + COPYRIGHT = "Copyright © 2001-2008 Sean Russell <ser@germane-software.com>" + DATE = "2008/019" + VERSION = "3.3.5" + REVISION = "" + + Copyright = COPYRIGHT + Version = VERSION +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/sax2listener.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/sax2listener.rb new file mode 100644 index 0000000..5afdc80 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/sax2listener.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: false +module REXML + # A template for stream parser listeners. + # Note that the declarations (attlistdecl, elementdecl, etc) are trivially + # processed; REXML doesn't yet handle doctype entity declarations, so you + # have to parse them out yourself. + # === Missing methods from SAX2 + # ignorable_whitespace + # === Methods extending SAX2 + # +WARNING+ + # These methods are certainly going to change, until DTDs are fully + # supported. Be aware of this. + # start_document + # end_document + # doctype + # elementdecl + # attlistdecl + # entitydecl + # notationdecl + # cdata + # xmldecl + # comment + module SAX2Listener + def start_document + end + def end_document + end + def start_prefix_mapping prefix, uri + end + def end_prefix_mapping prefix + end + def start_element uri, localname, qname, attributes + end + def end_element uri, localname, qname + end + def characters text + end + def processing_instruction target, data + end + # Handles a doctype declaration. Any attributes of the doctype which are + # not supplied will be nil. # EG, <!DOCTYPE me PUBLIC "foo" "bar"> + # @p name the name of the doctype; EG, "me" + # @p pub_sys "PUBLIC", "SYSTEM", or nil. EG, "PUBLIC" + # @p long_name the supplied long name, or nil. EG, "foo" + # @p uri the uri of the doctype, or nil. EG, "bar" + def doctype name, pub_sys, long_name, uri + end + # If a doctype includes an ATTLIST declaration, it will cause this + # method to be called. The content is the declaration itself, unparsed. + # EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el + # attr CDATA #REQUIRED". This is the same for all of the .*decl + # methods. + def attlistdecl(element, pairs, contents) + end + # <!ELEMENT ...> + def elementdecl content + end + # <!ENTITY ...> + # The argument passed to this method is an array of the entity + # declaration. It can be in a number of formats, but in general it + # returns (example, result): + # <!ENTITY % YN '"Yes"'> + # ["%", "YN", "\"Yes\""] + # <!ENTITY % YN 'Yes'> + # ["%", "YN", "Yes"] + # <!ENTITY WhatHeSaid "He said %YN;"> + # ["WhatHeSaid", "He said %YN;"] + # <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"> + # ["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"] + # <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml"> + # ["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"] + # <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif> + # ["hatch-pic", "SYSTEM", "../grafix/OpenHatch.gif", "NDATA", "gif"] + def entitydecl declaration + end + # <!NOTATION ...> + def notationdecl name, public_or_system, public_id, system_id + end + # Called when <![CDATA[ ... ]]> is encountered in a document. + # @p content "..." + def cdata content + end + # Called when an XML PI is encountered in the document. + # EG: <?xml version="1.0" encoding="utf"?> + # @p version the version attribute value. EG, "1.0" + # @p encoding the encoding attribute value, or nil. EG, "utf" + # @p standalone the standalone attribute value, or nil. EG, nil + # @p spaced the declaration is followed by a line break + def xmldecl version, encoding, standalone + end + # Called when a comment is encountered. + # @p comment The content of the comment + def comment comment + end + def progress position + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/security.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/security.rb new file mode 100644 index 0000000..99b7460 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/security.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: false +module REXML + module Security + @@entity_expansion_limit = 10_000 + + # Set the entity expansion limit. By default the limit is set to 10000. + def self.entity_expansion_limit=( val ) + @@entity_expansion_limit = val + end + + # Get the entity expansion limit. By default the limit is set to 10000. + def self.entity_expansion_limit + return @@entity_expansion_limit + end + + @@entity_expansion_text_limit = 10_240 + + # Set the entity expansion limit. By default the limit is set to 10240. + def self.entity_expansion_text_limit=( val ) + @@entity_expansion_text_limit = val + end + + # Get the entity expansion limit. By default the limit is set to 10240. + def self.entity_expansion_text_limit + return @@entity_expansion_text_limit + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/source.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/source.rb new file mode 100644 index 0000000..ff887fc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/source.rb @@ -0,0 +1,328 @@ +# coding: US-ASCII +# frozen_string_literal: false + +require "strscan" + +require_relative 'encoding' + +module REXML + if StringScanner::Version < "1.0.0" + module StringScannerCheckScanString + refine StringScanner do + def check(pattern) + pattern = /#{Regexp.escape(pattern)}/ if pattern.is_a?(String) + super(pattern) + end + + def scan(pattern) + pattern = /#{Regexp.escape(pattern)}/ if pattern.is_a?(String) + super(pattern) + end + end + end + using StringScannerCheckScanString + end + + # Generates Source-s. USE THIS CLASS. + class SourceFactory + # Generates a Source object + # @param arg Either a String, or an IO + # @return a Source, or nil if a bad argument was given + def SourceFactory::create_from(arg) + if arg.respond_to? :read and + arg.respond_to? :readline and + arg.respond_to? :nil? and + arg.respond_to? :eof? + IOSource.new(arg) + elsif arg.respond_to? :to_str + require 'stringio' + IOSource.new(StringIO.new(arg)) + elsif arg.kind_of? Source + arg + else + raise "#{arg.class} is not a valid input stream. It must walk \n"+ + "like either a String, an IO, or a Source." + end + end + end + + # A Source can be searched for patterns, and wraps buffers and other + # objects and provides consumption of text + class Source + include Encoding + # The line number of the last consumed text + attr_reader :line + attr_reader :encoding + + module Private + SCANNER_RESET_SIZE = 100000 + PRE_DEFINED_TERM_PATTERNS = {} + pre_defined_terms = ["'", '"', "<"] + pre_defined_terms.each do |term| + PRE_DEFINED_TERM_PATTERNS[term] = /#{Regexp.escape(term)}/ + end + end + private_constant :Private + + # Constructor + # @param arg must be a String, and should be a valid XML document + # @param encoding if non-null, sets the encoding of the source to this + # value, overriding all encoding detection + def initialize(arg, encoding=nil) + @orig = arg + @scanner = StringScanner.new(@orig) + if encoding + self.encoding = encoding + else + detect_encoding + end + @line = 0 + end + + # The current buffer (what we're going to read next) + def buffer + @scanner.rest + end + + def drop_parsed_content + if @scanner.pos > Private::SCANNER_RESET_SIZE + @scanner.string = @scanner.rest + end + end + + def buffer_encoding=(encoding) + @scanner.string.force_encoding(encoding) + end + + # Inherited from Encoding + # Overridden to support optimized en/decoding + def encoding=(enc) + return unless super + encoding_updated + end + + def read(term = nil) + end + + def read_until(term) + pattern = Private::PRE_DEFINED_TERM_PATTERNS[term] || /#{Regexp.escape(term)}/ + data = @scanner.scan_until(pattern) + unless data + data = @scanner.rest + @scanner.pos = @scanner.string.bytesize + end + data + end + + def ensure_buffer + end + + def match(pattern, cons=false) + if cons + @scanner.scan(pattern).nil? ? nil : @scanner + else + @scanner.check(pattern).nil? ? nil : @scanner + end + end + + def position + @scanner.pos + end + + def position=(pos) + @scanner.pos = pos + end + + # @return true if the Source is exhausted + def empty? + @scanner.eos? + end + + # @return the current line in the source + def current_line + lines = @orig.split + res = lines.grep @scanner.rest[0..30] + res = res[-1] if res.kind_of? Array + lines.index( res ) if res + end + + private + + def detect_encoding + scanner_encoding = @scanner.rest.encoding + detected_encoding = "UTF-8" + begin + @scanner.string.force_encoding("ASCII-8BIT") + if @scanner.scan(/\xfe\xff/n) + detected_encoding = "UTF-16BE" + elsif @scanner.scan(/\xff\xfe/n) + detected_encoding = "UTF-16LE" + elsif @scanner.scan(/\xef\xbb\xbf/n) + detected_encoding = "UTF-8" + end + ensure + @scanner.string.force_encoding(scanner_encoding) + end + self.encoding = detected_encoding + end + + def encoding_updated + if @encoding != 'UTF-8' + @scanner.string = decode(@scanner.rest) + @to_utf = true + else + @to_utf = false + @scanner.string.force_encoding(::Encoding::UTF_8) + end + end + end + + # A Source that wraps an IO. See the Source class for method + # documentation + class IOSource < Source + #attr_reader :block_size + + # block_size has been deprecated + def initialize(arg, block_size=500, encoding=nil) + @er_source = @source = arg + @to_utf = false + @pending_buffer = nil + + if encoding + super("", encoding) + else + super(@source.read(3) || "") + end + + if !@to_utf and + @orig.respond_to?(:force_encoding) and + @source.respond_to?(:external_encoding) and + @source.external_encoding != ::Encoding::UTF_8 + @force_utf8 = true + else + @force_utf8 = false + end + end + + def read(term = nil, min_bytes = 1) + term = encode(term) if term + begin + str = readline(term) + @scanner << str + read_bytes = str.bytesize + begin + while read_bytes < min_bytes + str = readline(term) + @scanner << str + read_bytes += str.bytesize + end + rescue IOError + end + true + rescue Exception, NameError + @source = nil + false + end + end + + def read_until(term) + pattern = Private::PRE_DEFINED_TERM_PATTERNS[term] || /#{Regexp.escape(term)}/ + term = encode(term) + until str = @scanner.scan_until(pattern) + break if @source.nil? + break if @source.eof? + @scanner << readline(term) + end + if str + read if @scanner.eos? and !@source.eof? + str + else + rest = @scanner.rest + @scanner.pos = @scanner.string.bytesize + rest + end + end + + def ensure_buffer + read if @scanner.eos? && @source + end + + def match( pattern, cons=false ) + # To avoid performance issue, we need to increase bytes to read per scan + min_bytes = 1 + while true + if cons + md = @scanner.scan(pattern) + else + md = @scanner.check(pattern) + end + break if md + return nil if pattern.is_a?(String) + return nil if @source.nil? + return nil unless read(nil, min_bytes) + min_bytes *= 2 + end + + md.nil? ? nil : @scanner + end + + def empty? + super and ( @source.nil? || @source.eof? ) + end + + # @return the current line in the source + def current_line + begin + pos = @er_source.pos # The byte position in the source + lineno = @er_source.lineno # The XML < position in the source + @er_source.rewind + line = 0 # The \r\n position in the source + begin + while @er_source.pos < pos + @er_source.readline + line += 1 + end + rescue + end + @er_source.seek(pos) + rescue IOError + pos = -1 + line = -1 + end + [pos, lineno, line] + end + + private + def readline(term = nil) + str = @source.readline(term || @line_break) + if @pending_buffer + if str.nil? + str = @pending_buffer + else + str = @pending_buffer + str + end + @pending_buffer = nil + end + return nil if str.nil? + + if @to_utf + decode(str) + else + str.force_encoding(::Encoding::UTF_8) if @force_utf8 + str + end + end + + def encoding_updated + case @encoding + when "UTF-16BE", "UTF-16LE" + @source.binmode + @source.set_encoding(@encoding, @encoding) + end + @line_break = encode(">") + @pending_buffer, @scanner.string = @scanner.rest, "" + @pending_buffer.force_encoding(@encoding) + super + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/streamlistener.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/streamlistener.rb new file mode 100644 index 0000000..30c8945 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/streamlistener.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: false +module REXML + # A template for stream parser listeners. + # Note that the declarations (attlistdecl, elementdecl, etc) are trivially + # processed; REXML doesn't yet handle doctype entity declarations, so you + # have to parse them out yourself. + module StreamListener + # Called when a tag is encountered. + # @p name the tag name + # @p attrs an array of arrays of attribute/value pairs, suitable for + # use with assoc or rassoc. IE, <tag attr1="value1" attr2="value2"> + # will result in + # tag_start( "tag", # [["attr1","value1"],["attr2","value2"]]) + def tag_start name, attrs + end + # Called when the end tag is reached. In the case of <tag/>, tag_end + # will be called immediately after tag_start + # @p the name of the tag + def tag_end name + end + # Called when text is encountered in the document + # @p text the text content. + def text text + end + # Called when an instruction is encountered. EG: <?xsl sheet='foo'?> + # @p name the instruction name; in the example, "xsl" + # @p instruction the rest of the instruction. In the example, + # "sheet='foo'" + def instruction name, instruction + end + # Called when a comment is encountered. + # @p comment The content of the comment + def comment comment + end + # Handles a doctype declaration. Any attributes of the doctype which are + # not supplied will be nil. # EG, <!DOCTYPE me PUBLIC "foo" "bar"> + # @p name the name of the doctype; EG, "me" + # @p pub_sys "PUBLIC", "SYSTEM", or nil. EG, "PUBLIC" + # @p long_name the supplied long name, or nil. EG, "foo" + # @p uri the uri of the doctype, or nil. EG, "bar" + def doctype name, pub_sys, long_name, uri + end + # Called when the doctype is done + def doctype_end + end + # If a doctype includes an ATTLIST declaration, it will cause this + # method to be called. The content is the declaration itself, unparsed. + # EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el + # attr CDATA #REQUIRED". This is the same for all of the .*decl + # methods. + def attlistdecl element_name, attributes, raw_content + end + # <!ELEMENT ...> + def elementdecl content + end + # <!ENTITY ...> + # The argument passed to this method is an array of the entity + # declaration. It can be in a number of formats, but in general it + # returns (example, result): + # <!ENTITY % YN '"Yes"'> + # ["YN", "\"Yes\"", "%"] + # <!ENTITY % YN 'Yes'> + # ["YN", "Yes", "%"] + # <!ENTITY WhatHeSaid "He said %YN;"> + # ["WhatHeSaid", "He said %YN;"] + # <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"> + # ["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"] + # <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml"> + # ["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"] + # <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif> + # ["hatch-pic", "SYSTEM", "../grafix/OpenHatch.gif", "gif"] + def entitydecl content + end + # <!NOTATION ...> + def notationdecl content + end + # Called when %foo; is encountered in a doctype declaration. + # @p content "foo" + def entity content + end + # Called when <![CDATA[ ... ]]> is encountered in a document. + # @p content "..." + def cdata content + end + # Called when an XML PI is encountered in the document. + # EG: <?xml version="1.0" encoding="utf"?> + # @p version the version attribute value. EG, "1.0" + # @p encoding the encoding attribute value, or nil. EG, "utf" + # @p standalone the standalone attribute value, or nil. EG, nil + def xmldecl version, encoding, standalone + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/text.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/text.rb new file mode 100644 index 0000000..7e0befe --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/text.rb @@ -0,0 +1,446 @@ +# frozen_string_literal: true +require_relative 'security' +require_relative 'entity' +require_relative 'doctype' +require_relative 'child' +require_relative 'doctype' +require_relative 'parseexception' + +module REXML + # Represents text nodes in an XML document + class Text < Child + include Comparable + # The order in which the substitutions occur + SPECIALS = [ /&(?!#?[\w-]+;)/u, /</u, />/u, /"/u, /'/u, /\r/u ] + SUBSTITUTES = ['&', '<', '>', '"', ''', ' '] + # Characters which are substituted in written strings + SLAICEPS = [ '<', '>', '"', "'", '&' ] + SETUTITSBUS = [ /</u, />/u, /"/u, /'/u, /&/u ] + + # If +raw+ is true, then REXML leaves the value alone + attr_accessor :raw + + NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um + NUMERICENTITY = /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ + VALID_CHAR = [ + 0x9, 0xA, 0xD, + (0x20..0xD7FF), + (0xE000..0xFFFD), + (0x10000..0x10FFFF) + ] + + if String.method_defined? :encode + VALID_XML_CHARS = Regexp.new('^['+ + VALID_CHAR.map { |item| + case item + when Integer + [item].pack('U').force_encoding('utf-8') + when Range + [item.first, '-'.ord, item.last].pack('UUU').force_encoding('utf-8') + end + }.join + + ']*$') + else + VALID_XML_CHARS = /^( + [\x09\x0A\x0D\x20-\x7E] # ASCII + | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte + | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs + | [\xE1-\xEC\xEE][\x80-\xBF]{2} # straight 3-byte + | \xEF[\x80-\xBE]{2} # + | \xEF\xBF[\x80-\xBD] # excluding U+fffe and U+ffff + | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates + | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 + | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 + | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 + )*$/nx; + end + + # Constructor + # +arg+ if a String, the content is set to the String. If a Text, + # the object is shallowly cloned. + # + # +respect_whitespace+ (boolean, false) if true, whitespace is + # respected + # + # +parent+ (nil) if this is a Parent object, the parent + # will be set to this. + # + # +raw+ (nil) This argument can be given three values. + # If true, then the value of used to construct this object is expected to + # contain no unescaped XML markup, and REXML will not change the text. If + # this value is false, the string may contain any characters, and REXML will + # escape any and all defined entities whose values are contained in the + # text. If this value is nil (the default), then the raw value of the + # parent will be used as the raw value for this node. If there is no raw + # value for the parent, and no value is supplied, the default is false. + # Use this field if you have entities defined for some text, and you don't + # want REXML to escape that text in output. + # Text.new( "<&", false, nil, false ) #-> "<&" + # Text.new( "<&", false, nil, false ) #-> "&lt;&amp;" + # Text.new( "<&", false, nil, true ) #-> Parse exception + # Text.new( "<&", false, nil, true ) #-> "<&" + # # Assume that the entity "s" is defined to be "sean" + # # and that the entity "r" is defined to be "russell" + # Text.new( "sean russell" ) #-> "&s; &r;" + # Text.new( "sean russell", false, nil, true ) #-> "sean russell" + # + # +entity_filter+ (nil) This can be an array of entities to match in the + # supplied text. This argument is only useful if +raw+ is set to false. + # Text.new( "sean russell", false, nil, false, ["s"] ) #-> "&s; russell" + # Text.new( "sean russell", false, nil, true, ["s"] ) #-> "sean russell" + # In the last example, the +entity_filter+ argument is ignored. + # + # +illegal+ INTERNAL USE ONLY + def initialize(arg, respect_whitespace=false, parent=nil, raw=nil, + entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK ) + + @raw = false + @parent = nil + @entity_filter = nil + + if parent + super( parent ) + @raw = parent.raw + end + + if arg.kind_of? String + @string = arg.dup + elsif arg.kind_of? Text + @string = arg.instance_variable_get(:@string).dup + @raw = arg.raw + @entity_filter = arg.instance_variable_get(:@entity_filter) + else + raise "Illegal argument of type #{arg.type} for Text constructor (#{arg})" + end + + @string.squeeze!(" \n\t") unless respect_whitespace + @string.gsub!(/\r\n?/, "\n") + @raw = raw unless raw.nil? + @entity_filter = entity_filter if entity_filter + clear_cache + + Text.check(@string, illegal, doctype) if @raw + end + + def parent= parent + super(parent) + Text.check(@string, NEEDS_A_SECOND_CHECK, doctype) if @raw and @parent + end + + # check for illegal characters + def Text.check string, pattern, doctype + + # illegal anywhere + if !string.match?(VALID_XML_CHARS) + if String.method_defined? :encode + string.chars.each do |c| + case c.ord + when *VALID_CHAR + else + raise "Illegal character #{c.inspect} in raw string #{string.inspect}" + end + end + else + string.scan(/[\x00-\x7F]|[\x80-\xBF][\xC0-\xF0]*|[\xC0-\xF0]/n) do |c| + case c.unpack('U') + when *VALID_CHAR + else + raise "Illegal character #{c.inspect} in raw string #{string.inspect}" + end + end + end + end + + pos = 0 + while (index = string.index(/<|&/, pos)) + if string[index] == "<" + raise "Illegal character \"#{string[index]}\" in raw string #{string.inspect}" + end + + unless (end_index = string.index(/[^\s];/, index + 1)) + raise "Illegal character \"#{string[index]}\" in raw string #{string.inspect}" + end + + value = string[(index + 1)..end_index] + if /\s/.match?(value) + raise "Illegal character \"#{string[index]}\" in raw string #{string.inspect}" + end + + if value[0] == "#" + character_reference = value[1..-1] + + unless (/\A(\d+|x[0-9a-fA-F]+)\z/.match?(character_reference)) + if character_reference[0] == "x" || character_reference[-1] == "x" + raise "Illegal character \"#{string[index]}\" in raw string #{string.inspect}" + else + raise "Illegal character #{string.inspect} in raw string #{string.inspect}" + end + end + + case (character_reference[0] == "x" ? character_reference[1..-1].to_i(16) : character_reference[0..-1].to_i) + when *VALID_CHAR + else + raise "Illegal character #{string.inspect} in raw string #{string.inspect}" + end + elsif !(/\A#{Entity::NAME}\z/um.match?(value)) + raise "Illegal character \"#{string[index]}\" in raw string #{string.inspect}" + end + + pos = end_index + 1 + end + + string + end + + def node_type + :text + end + + def empty? + @string.size==0 + end + + + def clone + return Text.new(self, true) + end + + + # Appends text to this text node. The text is appended in the +raw+ mode + # of this text node. + # + # +returns+ the text itself to enable method chain like + # 'text << "XXX" << "YYY"'. + def <<( to_append ) + @string << to_append.gsub( /\r\n?/, "\n" ) + clear_cache + self + end + + + # +other+ a String or a Text + # +returns+ the result of (to_s <=> arg.to_s) + def <=>( other ) + to_s() <=> other.to_s + end + + def doctype + if @parent + doc = @parent.document + doc.doctype if doc + end + end + + REFERENCE = /#{Entity::REFERENCE}/ + # Returns the string value of this text node. This string is always + # escaped, meaning that it is a valid XML text node string, and all + # entities that can be escaped, have been inserted. This method respects + # the entity filter set in the constructor. + # + # # Assume that the entity "s" is defined to be "sean", and that the + # # entity "r" is defined to be "russell" + # t = Text.new( "< & sean russell", false, nil, false, ['s'] ) + # t.to_s #-> "< & &s; russell" + # t = Text.new( "< & &s; russell", false, nil, false ) + # t.to_s #-> "< & &s; russell" + # u = Text.new( "sean russell", false, nil, true ) + # u.to_s #-> "sean russell" + def to_s + return @string if @raw + @normalized ||= Text::normalize( @string, doctype, @entity_filter ) + end + + def inspect + @string.inspect + end + + # Returns the string value of this text. This is the text without + # entities, as it might be used programmatically, or printed to the + # console. This ignores the 'raw' attribute setting, and any + # entity_filter. + # + # # Assume that the entity "s" is defined to be "sean", and that the + # # entity "r" is defined to be "russell" + # t = Text.new( "< & sean russell", false, nil, false, ['s'] ) + # t.value #-> "< & sean russell" + # t = Text.new( "< & &s; russell", false, nil, false ) + # t.value #-> "< & sean russell" + # u = Text.new( "sean russell", false, nil, true ) + # u.value #-> "sean russell" + def value + @unnormalized ||= Text::unnormalize( @string, doctype ) + end + + # Sets the contents of this text node. This expects the text to be + # unnormalized. It returns self. + # + # e = Element.new( "a" ) + # e.add_text( "foo" ) # <a>foo</a> + # e[0].value = "bar" # <a>bar</a> + # e[0].value = "<a>" # <a><a></a> + def value=( val ) + @string = val.gsub( /\r\n?/, "\n" ) + clear_cache + @raw = false + end + + def wrap(string, width, addnewline=false) + # Recursively wrap string at width. + return string if string.length <= width + place = string.rindex(' ', width) # Position in string with last ' ' before cutoff + if addnewline then + return "\n" + string[0,place] + "\n" + wrap(string[place+1..-1], width) + else + return string[0,place] + "\n" + wrap(string[place+1..-1], width) + end + end + + def indent_text(string, level=1, style="\t", indentfirstline=true) + return string if level < 0 + new_string = '' + string.each_line { |line| + indent_string = style * level + new_line = (indent_string + line).sub(/[\s]+$/,'') + new_string << new_line + } + new_string.strip! unless indentfirstline + return new_string + end + + # == DEPRECATED + # See REXML::Formatters + # + def write( writer, indent=-1, transitive=false, ie_hack=false ) + Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters", uplevel: 1) + formatter = if indent > -1 + REXML::Formatters::Pretty.new( indent ) + else + REXML::Formatters::Default.new + end + formatter.write( self, writer ) + end + + # FIXME + # This probably won't work properly + def xpath + path = @parent.xpath + path += "/text()" + return path + end + + # Writes out text, substituting special characters beforehand. + # +out+ A String, IO, or any other object supporting <<( String ) + # +input+ the text to substitute and the write out + # + # z=utf8.unpack("U*") + # ascOut="" + # z.each{|r| + # if r < 0x100 + # ascOut.concat(r.chr) + # else + # ascOut.concat(sprintf("&#x%x;", r)) + # end + # } + # puts ascOut + def write_with_substitution out, input + copy = input.clone + # Doing it like this rather than in a loop improves the speed + copy.gsub!( SPECIALS[0], SUBSTITUTES[0] ) + copy.gsub!( SPECIALS[1], SUBSTITUTES[1] ) + copy.gsub!( SPECIALS[2], SUBSTITUTES[2] ) + copy.gsub!( SPECIALS[3], SUBSTITUTES[3] ) + copy.gsub!( SPECIALS[4], SUBSTITUTES[4] ) + copy.gsub!( SPECIALS[5], SUBSTITUTES[5] ) + out << copy + end + + private + def clear_cache + @normalized = nil + @unnormalized = nil + end + + # Reads text, substituting entities + def Text::read_with_substitution( input, illegal=nil ) + copy = input.clone + + if copy =~ illegal + raise ParseException.new( "malformed text: Illegal character #$& in \"#{copy}\"" ) + end if illegal + + copy.gsub!( /\r\n?/, "\n" ) + if copy.include? ?& + copy.gsub!( SETUTITSBUS[0], SLAICEPS[0] ) + copy.gsub!( SETUTITSBUS[1], SLAICEPS[1] ) + copy.gsub!( SETUTITSBUS[2], SLAICEPS[2] ) + copy.gsub!( SETUTITSBUS[3], SLAICEPS[3] ) + copy.gsub!( SETUTITSBUS[4], SLAICEPS[4] ) + copy.gsub!( /�*((?:\d+)|(?:x[a-f0-9]+));/ ) { + m=$1 + #m='0' if m=='' + m = "0#{m}" if m[0] == ?x + [Integer(m)].pack('U*') + } + end + copy + end + + EREFERENCE = /&(?!#{Entity::NAME};)/ + # Escapes all possible entities + def Text::normalize( input, doctype=nil, entity_filter=nil ) + copy = input.to_s + # Doing it like this rather than in a loop improves the speed + #copy = copy.gsub( EREFERENCE, '&' ) + copy = copy.gsub( "&", "&" ) if copy.include?("&") + if doctype + # Replace all ampersands that aren't part of an entity + doctype.entities.each_value do |entity| + copy = copy.gsub( entity.value, + "&#{entity.name};" ) if entity.value and + not( entity_filter and entity_filter.include?(entity.name) ) + end + else + # Replace all ampersands that aren't part of an entity + DocType::DEFAULT_ENTITIES.each_value do |entity| + if copy.include?(entity.value) + copy = copy.gsub(entity.value, "&#{entity.name};" ) + end + end + end + copy + end + + # Unescapes all possible entities + def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil ) + sum = 0 + string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) { + s = Text.expand($&, doctype, filter) + if sum + s.bytesize > Security.entity_expansion_text_limit + raise "entity expansion has grown too large" + else + sum += s.bytesize + end + s + } + end + + def Text.expand(ref, doctype, filter) + if ref[1] == ?# + if ref[2] == ?x + [ref[3...-1].to_i(16)].pack('U*') + else + [ref[2...-1].to_i].pack('U*') + end + elsif ref == '&' + '&' + elsif filter and filter.include?( ref[1...-1] ) + ref + elsif doctype + doctype.entity( ref[1...-1] ) or ref + else + entity_value = DocType::DEFAULT_ENTITIES[ ref[1...-1] ] + entity_value ? entity_value.value : ref + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/undefinednamespaceexception.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/undefinednamespaceexception.rb new file mode 100644 index 0000000..492a098 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/undefinednamespaceexception.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: false +require_relative 'parseexception' +module REXML + class UndefinedNamespaceException < ParseException + def initialize( prefix, source, parser ) + super( "Undefined prefix #{prefix} found" ) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/relaxng.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/relaxng.rb new file mode 100644 index 0000000..f29a2c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/relaxng.rb @@ -0,0 +1,539 @@ +# frozen_string_literal: false +require_relative "validation" +require_relative "../parsers/baseparser" + +module REXML + module Validation + # Implemented: + # * empty + # * element + # * attribute + # * text + # * optional + # * choice + # * oneOrMore + # * zeroOrMore + # * group + # * value + # * interleave + # * mixed + # * ref + # * grammar + # * start + # * define + # + # Not implemented: + # * data + # * param + # * include + # * externalRef + # * notAllowed + # * anyName + # * nsName + # * except + # * name + class RelaxNG + include Validator + + INFINITY = 1.0 / 0.0 + EMPTY = Event.new( nil ) + TEXT = [:start_element, "text"] + attr_accessor :current + attr_accessor :count + attr_reader :references + + # FIXME: Namespaces + def initialize source + parser = REXML::Parsers::BaseParser.new( source ) + + @count = 0 + @references = {} + @root = @current = Sequence.new(self) + @root.previous = true + states = [ @current ] + begin + event = parser.pull + case event[0] + when :start_element + case event[1] + when "empty" + when "element", "attribute", "text", "value" + states[-1] << event + when "optional" + states << Optional.new( self ) + states[-2] << states[-1] + when "choice" + states << Choice.new( self ) + states[-2] << states[-1] + when "oneOrMore" + states << OneOrMore.new( self ) + states[-2] << states[-1] + when "zeroOrMore" + states << ZeroOrMore.new( self ) + states[-2] << states[-1] + when "group" + states << Sequence.new( self ) + states[-2] << states[-1] + when "interleave" + states << Interleave.new( self ) + states[-2] << states[-1] + when "mixed" + states << Interleave.new( self ) + states[-2] << states[-1] + states[-1] << TEXT + when "define" + states << [ event[2]["name"] ] + when "ref" + states[-1] << Ref.new( event[2]["name"] ) + when "anyName" + states << AnyName.new( self ) + states[-2] << states[-1] + when "nsName" + when "except" + when "name" + when "data" + when "param" + when "include" + when "grammar" + when "start" + when "externalRef" + when "notAllowed" + end + when :end_element + case event[1] + when "element", "attribute" + states[-1] << event + when "zeroOrMore", "oneOrMore", "choice", "optional", + "interleave", "group", "mixed" + states.pop + when "define" + ref = states.pop + @references[ ref.shift ] = ref + #when "empty" + end + when :end_document + states[-1] << event + when :text + states[-1] << event + end + end while event[0] != :end_document + end + + def receive event + validate( event ) + end + end + + class State + def initialize( context ) + @previous = [] + @events = [] + @current = 0 + @count = context.count += 1 + @references = context.references + @value = false + end + + def reset + return if @current == 0 + @current = 0 + @events.each {|s| s.reset if s.kind_of? State } + end + + def previous=( previous ) + @previous << previous + end + + def next( event ) + #print "In next with #{event.inspect}. " + #p @previous + return @previous.pop.next( event ) if @events[@current].nil? + expand_ref_in( @events, @current ) if @events[@current].class == Ref + if ( @events[@current].kind_of? State ) + @current += 1 + @events[@current-1].previous = self + return @events[@current-1].next( event ) + end + if ( @events[@current].matches?(event) ) + @current += 1 + if @events[@current].nil? + return @previous.pop + elsif @events[@current].kind_of? State + @current += 1 + @events[@current-1].previous = self + return @events[@current-1] + else + return self + end + else + return nil + end + end + + def to_s + # Abbreviated: + self.class.name =~ /(?:::)(\w)\w+$/ + # Full: + #self.class.name =~ /(?:::)(\w+)$/ + "#$1.#@count" + end + + def inspect + "< #{to_s} #{@events.collect{|e| + pre = e == @events[@current] ? '#' : '' + pre + e.inspect unless self == e + }.join(', ')} >" + end + + def expected + return [@events[@current]] + end + + def <<( event ) + add_event_to_arry( @events, event ) + end + + + protected + def expand_ref_in( arry, ind ) + new_events = [] + @references[ arry[ind].to_s ].each{ |evt| + add_event_to_arry(new_events,evt) + } + arry[ind,1] = new_events + end + + def add_event_to_arry( arry, evt ) + evt = generate_event( evt ) + if evt.kind_of? String + arry[-1].event_arg = evt if arry[-1].kind_of? Event and @value + @value = false + else + arry << evt + end + end + + def generate_event( event ) + return event if event.kind_of? State or event.class == Ref + evt = nil + arg = nil + case event[0] + when :start_element + case event[1] + when "element" + evt = :start_element + arg = event[2]["name"] + when "attribute" + evt = :start_attribute + arg = event[2]["name"] + when "text" + evt = :text + when "value" + evt = :text + @value = true + end + when :text + return event[1] + when :end_document + return Event.new( event[0] ) + else # then :end_element + case event[1] + when "element" + evt = :end_element + when "attribute" + evt = :end_attribute + end + end + return Event.new( evt, arg ) + end + end + + + class Sequence < State + def matches?(event) + @events[@current].matches?( event ) + end + end + + + class Optional < State + def next( event ) + if @current == 0 + rv = super + return rv if rv + @prior = @previous.pop + return @prior.next( event ) + end + super + end + + def matches?(event) + @events[@current].matches?(event) || + (@current == 0 and @previous[-1].matches?(event)) + end + + def expected + return [ @prior.expected, @events[0] ].flatten if @current == 0 + return [@events[@current]] + end + end + + + class ZeroOrMore < Optional + def next( event ) + expand_ref_in( @events, @current ) if @events[@current].class == Ref + if ( @events[@current].matches?(event) ) + @current += 1 + if @events[@current].nil? + @current = 0 + return self + elsif @events[@current].kind_of? State + @current += 1 + @events[@current-1].previous = self + return @events[@current-1] + else + return self + end + else + @prior = @previous.pop + return @prior.next( event ) if @current == 0 + return nil + end + end + + def expected + return [ @prior.expected, @events[0] ].flatten if @current == 0 + return [@events[@current]] + end + end + + + class OneOrMore < State + def initialize context + super + @ord = 0 + end + + def reset + super + @ord = 0 + end + + def next( event ) + expand_ref_in( @events, @current ) if @events[@current].class == Ref + if ( @events[@current].matches?(event) ) + @current += 1 + @ord += 1 + if @events[@current].nil? + @current = 0 + return self + elsif @events[@current].kind_of? State + @current += 1 + @events[@current-1].previous = self + return @events[@current-1] + else + return self + end + else + return @previous.pop.next( event ) if @current == 0 and @ord > 0 + return nil + end + end + + def matches?( event ) + @events[@current].matches?(event) || + (@current == 0 and @ord > 0 and @previous[-1].matches?(event)) + end + + def expected + if @current == 0 and @ord > 0 + return [@previous[-1].expected, @events[0]].flatten + else + return [@events[@current]] + end + end + end + + + class Choice < State + def initialize context + super + @choices = [] + end + + def reset + super + @events = [] + @choices.each { |c| c.each { |s| s.reset if s.kind_of? State } } + end + + def <<( event ) + add_event_to_arry( @choices, event ) + end + + def next( event ) + # Make the choice if we haven't + if @events.size == 0 + c = 0 ; max = @choices.size + while c < max + if @choices[c][0].class == Ref + expand_ref_in( @choices[c], 0 ) + @choices += @choices[c] + @choices.delete( @choices[c] ) + max -= 1 + else + c += 1 + end + end + @events = @choices.find { |evt| evt[0].matches? event } + # Remove the references + # Find the events + end + unless @events + @events = [] + return nil + end + super + end + + def matches?( event ) + return @events[@current].matches?( event ) if @events.size > 0 + !@choices.find{|evt| evt[0].matches?(event)}.nil? + end + + def expected + return [@events[@current]] if @events.size > 0 + return @choices.collect do |x| + if x[0].kind_of? State + x[0].expected + else + x[0] + end + end.flatten + end + + def inspect + "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' or ')} >" + end + + protected + def add_event_to_arry( arry, evt ) + if evt.kind_of? State or evt.class == Ref + arry << [evt] + elsif evt[0] == :text + if arry[-1] and + arry[-1][-1].kind_of?( Event ) and + arry[-1][-1].event_type == :text and @value + + arry[-1][-1].event_arg = evt[1] + @value = false + end + else + arry << [] if evt[0] == :start_element + arry[-1] << generate_event( evt ) + end + end + end + + + class Interleave < Choice + def initialize context + super + @choice = 0 + end + + def reset + @choice = 0 + end + + def next_current( event ) + # Expand references + c = 0 ; max = @choices.size + while c < max + if @choices[c][0].class == Ref + expand_ref_in( @choices[c], 0 ) + @choices += @choices[c] + @choices.delete( @choices[c] ) + max -= 1 + else + c += 1 + end + end + @events = @choices[@choice..-1].find { |evt| evt[0].matches? event } + @current = 0 + if @events + # reorder the choices + old = @choices[@choice] + idx = @choices.index( @events ) + @choices[@choice] = @events + @choices[idx] = old + @choice += 1 + end + + @events = [] unless @events + end + + + def next( event ) + # Find the next series + next_current(event) unless @events[@current] + return nil unless @events[@current] + + expand_ref_in( @events, @current ) if @events[@current].class == Ref + if ( @events[@current].kind_of? State ) + @current += 1 + @events[@current-1].previous = self + return @events[@current-1].next( event ) + end + return @previous.pop.next( event ) if @events[@current].nil? + if ( @events[@current].matches?(event) ) + @current += 1 + if @events[@current].nil? + return self unless @choices[@choice].nil? + return @previous.pop + elsif @events[@current].kind_of? State + @current += 1 + @events[@current-1].previous = self + return @events[@current-1] + else + return self + end + else + return nil + end + end + + def matches?( event ) + return @events[@current].matches?( event ) if @events[@current] + !@choices[@choice..-1].find{|evt| evt[0].matches?(event)}.nil? + end + + def expected + return [@events[@current]] if @events[@current] + return @choices[@choice..-1].collect do |x| + if x[0].kind_of? State + x[0].expected + else + x[0] + end + end.flatten + end + + def inspect + "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' and ')} >" + end + end + + class Ref + def initialize value + @value = value + end + def to_s + @value + end + def inspect + "{#{to_s}}" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/validation.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/validation.rb new file mode 100644 index 0000000..0ad6ada --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/validation.rb @@ -0,0 +1,144 @@ +# frozen_string_literal: false +require_relative 'validationexception' + +module REXML + module Validation + module Validator + NILEVENT = [ nil ] + def reset + @current = @root + @root.reset + @root.previous = true + @attr_stack = [] + self + end + def dump + puts @root.inspect + end + def validate( event ) + @attr_stack = [] unless defined? @attr_stack + match = @current.next(event) + raise ValidationException.new( "Validation error. Expected: "+ + @current.expected.join( " or " )+" from #{@current.inspect} "+ + " but got #{Event.new( event[0], event[1] ).inspect}" ) unless match + @current = match + + # Check for attributes + case event[0] + when :start_element + @attr_stack << event[2] + begin + sattr = [:start_attribute, nil] + eattr = [:end_attribute] + text = [:text, nil] + k, = event[2].find { |key,value| + sattr[1] = key + m = @current.next( sattr ) + if m + # If the state has text children... + if m.matches?( eattr ) + @current = m + else + text[1] = value + m = m.next( text ) + text[1] = nil + return false unless m + @current = m if m + end + m = @current.next( eattr ) + if m + @current = m + true + else + false + end + else + false + end + } + event[2].delete(k) if k + end while k + when :end_element + attrs = @attr_stack.pop + raise ValidationException.new( "Validation error. Illegal "+ + " attributes: #{attrs.inspect}") if attrs.length > 0 + end + end + end + + class Event + def initialize(event_type, event_arg=nil ) + @event_type = event_type + @event_arg = event_arg + end + + attr_reader :event_type + attr_accessor :event_arg + + def done? + @done + end + + def single? + return (@event_type != :start_element and @event_type != :start_attribute) + end + + def matches?( event ) + return false unless event[0] == @event_type + case event[0] + when nil + return true + when :start_element + return true if event[1] == @event_arg + when :end_element + return true + when :start_attribute + return true if event[1] == @event_arg + when :end_attribute + return true + when :end_document + return true + when :text + return (@event_arg.nil? or @event_arg == event[1]) +=begin + when :processing_instruction + false + when :xmldecl + false + when :start_doctype + false + when :end_doctype + false + when :externalentity + false + when :elementdecl + false + when :entity + false + when :attlistdecl + false + when :notationdecl + false + when :end_doctype + false +=end + else + false + end + end + + def ==( other ) + return false unless other.kind_of? Event + @event_type == other.event_type and @event_arg == other.event_arg + end + + def to_s + inspect + end + + def inspect + "#{@event_type.inspect}( #@event_arg )" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/validationexception.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/validationexception.rb new file mode 100644 index 0000000..78cd63f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/validation/validationexception.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: false +module REXML + module Validation + class ValidationException < RuntimeError + def initialize msg + super + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xmldecl.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xmldecl.rb new file mode 100644 index 0000000..d19407c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xmldecl.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: false + +require_relative 'encoding' +require_relative 'source' + +module REXML + # NEEDS DOCUMENTATION + class XMLDecl < Child + include Encoding + + DEFAULT_VERSION = "1.0" + DEFAULT_ENCODING = "UTF-8" + DEFAULT_STANDALONE = "no" + START = "<?xml" + STOP = "?>" + + attr_accessor :version, :standalone + attr_reader :writeencoding, :writethis + + def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil) + @writethis = true + @writeencoding = !encoding.nil? + if version.kind_of? XMLDecl + super() + @version = version.version + self.encoding = version.encoding + @writeencoding = version.writeencoding + @standalone = version.standalone + @writethis = version.writethis + else + super() + @version = version + self.encoding = encoding + @standalone = standalone + end + @version = DEFAULT_VERSION if @version.nil? + end + + def clone + XMLDecl.new(self) + end + + # indent:: + # Ignored. There must be no whitespace before an XML declaration + # transitive:: + # Ignored + # ie_hack:: + # Ignored + def write(writer, indent=-1, transitive=false, ie_hack=false) + return nil unless @writethis or writer.kind_of? Output + writer << START + writer << " #{content encoding}" + writer << STOP + end + + def ==( other ) + other.kind_of?(XMLDecl) and + other.version == @version and + other.encoding == self.encoding and + other.standalone == @standalone + end + + def xmldecl version, encoding, standalone + @version = version + self.encoding = encoding + @standalone = standalone + end + + def node_type + :xmldecl + end + + alias :stand_alone? :standalone + alias :old_enc= :encoding= + + def encoding=( enc ) + if enc.nil? + self.old_enc = "UTF-8" + @writeencoding = false + else + self.old_enc = enc + @writeencoding = true + end + self.dowrite + end + + # Only use this if you do not want the XML declaration to be written; + # this object is ignored by the XML writer. Otherwise, instantiate your + # own XMLDecl and add it to the document. + # + # Note that XML 1.1 documents *must* include an XML declaration + def XMLDecl.default + rv = XMLDecl.new( "1.0" ) + rv.nowrite + rv + end + + def nowrite + @writethis = false + end + + def dowrite + @writethis = true + end + + def inspect + "#{START} ... #{STOP}" + end + + private + def content(enc) + context = nil + context = parent.context if parent + if context and context[:prologue_quote] == :quote + quote = "\"" + else + quote = "'" + end + + rv = "version=#{quote}#{@version}#{quote}" + if @writeencoding or enc !~ /\Autf-8\z/i + rv << " encoding=#{quote}#{enc}#{quote}" + end + if @standalone + rv << " standalone=#{quote}#{@standalone}#{quote}" + end + rv + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xmltokens.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xmltokens.rb new file mode 100644 index 0000000..392b47b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xmltokens.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: false +module REXML + # Defines a number of tokens used for parsing XML. Not for general + # consumption. + module XMLTokens + # From http://www.w3.org/TR/REC-xml/#sec-common-syn + # + # [4] NameStartChar ::= + # ":" | + # [A-Z] | + # "_" | + # [a-z] | + # [#xC0-#xD6] | + # [#xD8-#xF6] | + # [#xF8-#x2FF] | + # [#x370-#x37D] | + # [#x37F-#x1FFF] | + # [#x200C-#x200D] | + # [#x2070-#x218F] | + # [#x2C00-#x2FEF] | + # [#x3001-#xD7FF] | + # [#xF900-#xFDCF] | + # [#xFDF0-#xFFFD] | + # [#x10000-#xEFFFF] + name_start_chars = [ + ":", + "A-Z", + "_", + "a-z", + "\\u00C0-\\u00D6", + "\\u00D8-\\u00F6", + "\\u00F8-\\u02FF", + "\\u0370-\\u037D", + "\\u037F-\\u1FFF", + "\\u200C-\\u200D", + "\\u2070-\\u218F", + "\\u2C00-\\u2FEF", + "\\u3001-\\uD7FF", + "\\uF900-\\uFDCF", + "\\uFDF0-\\uFFFD", + "\\u{10000}-\\u{EFFFF}", + ] + # From http://www.w3.org/TR/REC-xml/#sec-common-syn + # + # [4a] NameChar ::= + # NameStartChar | + # "-" | + # "." | + # [0-9] | + # #xB7 | + # [#x0300-#x036F] | + # [#x203F-#x2040] + name_chars = name_start_chars + [ + "\\-", + "\\.", + "0-9", + "\\u00B7", + "\\u0300-\\u036F", + "\\u203F-\\u2040", + ] + NAME_START_CHAR = "[#{name_start_chars.join('')}]" + NAME_CHAR = "[#{name_chars.join('')}]" + NAMECHAR = NAME_CHAR # deprecated. Use NAME_CHAR instead. + + # From http://www.w3.org/TR/xml-names11/#NT-NCName + # + # [6] NCNameStartChar ::= NameStartChar - ':' + ncname_start_chars = name_start_chars - [":"] + # From http://www.w3.org/TR/xml-names11/#NT-NCName + # + # [5] NCNameChar ::= NameChar - ':' + ncname_chars = name_chars - [":"] + NCNAME_STR = "[#{ncname_start_chars.join('')}][#{ncname_chars.join('')}]*" + NAME_STR = "(?:#{NCNAME_STR}:)?#{NCNAME_STR}" + + NAME = "(#{NAME_START_CHAR}#{NAME_CHAR}*)" + NMTOKEN = "(?:#{NAME_CHAR})+" + NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*" + REFERENCE = "(?:&#{NAME};|&#\\d+;|&#x[0-9a-fA-F]+;)" + + #REFERENCE = "(?:#{ENTITYREF}|#{CHARREF})" + #ENTITYREF = "&#{NAME};" + #CHARREF = "&#\\d+;|&#x[0-9a-fA-F]+;" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xpath.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xpath.rb new file mode 100644 index 0000000..a0921bd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xpath.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: false +require_relative 'functions' +require_relative 'xpath_parser' + +module REXML + # Wrapper class. Use this class to access the XPath functions. + class XPath + include Functions + # A base Hash object, supposing to be used when initializing a + # default empty namespaces set, but is currently unused. + # TODO: either set the namespaces=EMPTY_HASH, or deprecate this. + EMPTY_HASH = {} + + # Finds and returns the first node that matches the supplied xpath. + # element:: + # The context element + # path:: + # The xpath to search for. If not supplied or nil, returns the first + # node matching '*'. + # namespaces:: + # If supplied, a Hash which defines a namespace mapping. + # variables:: + # If supplied, a Hash which maps $variables in the query + # to values. This can be used to avoid XPath injection attacks + # or to automatically handle escaping string values. + # + # XPath.first( node ) + # XPath.first( doc, "//b"} ) + # XPath.first( node, "a/x:b", { "x"=>"http://doofus" } ) + # XPath.first( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"}) + def XPath::first(element, path=nil, namespaces=nil, variables={}, options={}) + raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash) + raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash) + parser = XPathParser.new(**options) + parser.namespaces = namespaces + parser.variables = variables + path = "*" unless path + element = [element] unless element.kind_of? Array + parser.parse(path, element).flatten[0] + end + + # Iterates over nodes that match the given path, calling the supplied + # block with the match. + # element:: + # The context element + # path:: + # The xpath to search for. If not supplied or nil, defaults to '*' + # namespaces:: + # If supplied, a Hash which defines a namespace mapping + # variables:: + # If supplied, a Hash which maps $variables in the query + # to values. This can be used to avoid XPath injection attacks + # or to automatically handle escaping string values. + # + # XPath.each( node ) { |el| ... } + # XPath.each( node, '/*[@attr='v']' ) { |el| ... } + # XPath.each( node, 'ancestor::x' ) { |el| ... } + # XPath.each( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"}) \ + # {|el| ... } + def XPath::each(element, path=nil, namespaces=nil, variables={}, options={}, &block) + raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash) + raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash) + parser = XPathParser.new(**options) + parser.namespaces = namespaces + parser.variables = variables + path = "*" unless path + element = [element] unless element.kind_of? Array + parser.parse(path, element).each( &block ) + end + + # Returns an array of nodes matching a given XPath. + def XPath::match(element, path=nil, namespaces=nil, variables={}, options={}) + parser = XPathParser.new(**options) + parser.namespaces = namespaces + parser.variables = variables + path = "*" unless path + element = [element] unless element.kind_of? Array + parser.parse(path,element) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xpath_parser.rb b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xpath_parser.rb new file mode 100644 index 0000000..5eb1e5a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rexml-3.3.5/lib/rexml/xpath_parser.rb @@ -0,0 +1,978 @@ +# frozen_string_literal: false + +require "pp" + +require_relative 'namespace' +require_relative 'xmltokens' +require_relative 'attribute' +require_relative 'parsers/xpathparser' + +module REXML + module DClonable + refine Object do + # provides a unified +clone+ operation, for REXML::XPathParser + # to use across multiple Object types + def dclone + clone + end + end + refine Symbol do + # provides a unified +clone+ operation, for REXML::XPathParser + # to use across multiple Object types + def dclone ; self ; end + end + refine Integer do + # provides a unified +clone+ operation, for REXML::XPathParser + # to use across multiple Object types + def dclone ; self ; end + end + refine Float do + # provides a unified +clone+ operation, for REXML::XPathParser + # to use across multiple Object types + def dclone ; self ; end + end + refine Array do + # provides a unified +clone+ operation, for REXML::XPathParser + # to use across multiple Object+ types + def dclone + klone = self.clone + klone.clear + self.each{|v| klone << v.dclone} + klone + end + end + end +end + +using REXML::DClonable + +module REXML + # You don't want to use this class. Really. Use XPath, which is a wrapper + # for this class. Believe me. You don't want to poke around in here. + # There is strange, dark magic at work in this code. Beware. Go back! Go + # back while you still can! + class XPathParser + include XMLTokens + LITERAL = /^'([^']*)'|^"([^"]*)"/u + + DEBUG = (ENV["REXML_XPATH_PARSER_DEBUG"] == "true") + + def initialize(strict: false) + @debug = DEBUG + @parser = REXML::Parsers::XPathParser.new + @namespaces = nil + @variables = {} + @nest = 0 + @strict = strict + end + + def namespaces=( namespaces={} ) + Functions::namespace_context = namespaces + @namespaces = namespaces + end + + def variables=( vars={} ) + Functions::variables = vars + @variables = vars + end + + def parse path, nodeset + path_stack = @parser.parse( path ) + match( path_stack, nodeset ) + end + + def get_first path, nodeset + path_stack = @parser.parse( path ) + first( path_stack, nodeset ) + end + + def predicate path, nodeset + path_stack = @parser.parse( path ) + match( path_stack, nodeset ) + end + + def []=( variable_name, value ) + @variables[ variable_name ] = value + end + + + # Performs a depth-first (document order) XPath search, and returns the + # first match. This is the fastest, lightest way to return a single result. + # + # FIXME: This method is incomplete! + def first( path_stack, node ) + return nil if path.size == 0 + + case path[0] + when :document + # do nothing + return first( path[1..-1], node ) + when :child + for c in node.children + r = first( path[1..-1], c ) + return r if r + end + when :qname + name = path[2] + if node.name == name + return node if path.size == 3 + return first( path[3..-1], node ) + else + return nil + end + when :descendant_or_self + r = first( path[1..-1], node ) + return r if r + for c in node.children + r = first( path, c ) + return r if r + end + when :node + return first( path[1..-1], node ) + when :any + return first( path[1..-1], node ) + end + return nil + end + + + def match(path_stack, nodeset) + nodeset = nodeset.collect.with_index do |node, i| + position = i + 1 + XPathNode.new(node, position: position) + end + result = expr(path_stack, nodeset) + case result + when Array # nodeset + unnode(result) + else + [result] + end + end + + private + def strict? + @strict + end + + # Returns a String namespace for a node, given a prefix + # The rules are: + # + # 1. Use the supplied namespace mapping first. + # 2. If no mapping was supplied, use the context node to look up the namespace + def get_namespace( node, prefix ) + if @namespaces + return @namespaces[prefix] || '' + else + return node.namespace( prefix ) if node.node_type == :element + return '' + end + end + + + # Expr takes a stack of path elements and a set of nodes (either a Parent + # or an Array and returns an Array of matching nodes + def expr( path_stack, nodeset, context=nil ) + enter(:expr, path_stack, nodeset) if @debug + return nodeset if path_stack.length == 0 || nodeset.length == 0 + while path_stack.length > 0 + trace(:while, path_stack, nodeset) if @debug + if nodeset.length == 0 + path_stack.clear + return [] + end + op = path_stack.shift + case op + when :document + first_raw_node = nodeset.first.raw_node + nodeset = [XPathNode.new(first_raw_node.root_node, position: 1)] + when :self + nodeset = step(path_stack) do + [nodeset] + end + when :child + nodeset = step(path_stack) do + child(nodeset) + end + when :literal + trace(:literal, path_stack, nodeset) if @debug + return path_stack.shift + when :attribute + nodeset = step(path_stack, any_type: :attribute) do + nodesets = [] + nodeset.each do |node| + raw_node = node.raw_node + next unless raw_node.node_type == :element + attributes = raw_node.attributes + next if attributes.empty? + nodesets << attributes.each_attribute.collect.with_index do |attribute, i| + XPathNode.new(attribute, position: i + 1) + end + end + nodesets + end + when :namespace + pre_defined_namespaces = { + "xml" => "http://www.w3.org/XML/1998/namespace", + } + nodeset = step(path_stack, any_type: :namespace) do + nodesets = [] + nodeset.each do |node| + raw_node = node.raw_node + case raw_node.node_type + when :element + if @namespaces + nodesets << pre_defined_namespaces.merge(@namespaces) + else + nodesets << pre_defined_namespaces.merge(raw_node.namespaces) + end + when :attribute + if @namespaces + nodesets << pre_defined_namespaces.merge(@namespaces) + else + nodesets << pre_defined_namespaces.merge(raw_node.element.namespaces) + end + end + end + nodesets + end + when :parent + nodeset = step(path_stack) do + nodesets = [] + nodeset.each do |node| + raw_node = node.raw_node + if raw_node.node_type == :attribute + parent = raw_node.element + else + parent = raw_node.parent + end + nodesets << [XPathNode.new(parent, position: 1)] if parent + end + nodesets + end + when :ancestor + nodeset = step(path_stack) do + nodesets = [] + # new_nodes = {} + nodeset.each do |node| + raw_node = node.raw_node + new_nodeset = [] + while raw_node.parent + raw_node = raw_node.parent + # next if new_nodes.key?(node) + new_nodeset << XPathNode.new(raw_node, + position: new_nodeset.size + 1) + # new_nodes[node] = true + end + nodesets << new_nodeset unless new_nodeset.empty? + end + nodesets + end + when :ancestor_or_self + nodeset = step(path_stack) do + nodesets = [] + # new_nodes = {} + nodeset.each do |node| + raw_node = node.raw_node + next unless raw_node.node_type == :element + new_nodeset = [XPathNode.new(raw_node, position: 1)] + # new_nodes[node] = true + while raw_node.parent + raw_node = raw_node.parent + # next if new_nodes.key?(node) + new_nodeset << XPathNode.new(raw_node, + position: new_nodeset.size + 1) + # new_nodes[node] = true + end + nodesets << new_nodeset unless new_nodeset.empty? + end + nodesets + end + when :descendant_or_self + nodeset = step(path_stack) do + descendant(nodeset, true) + end + when :descendant + nodeset = step(path_stack) do + descendant(nodeset, false) + end + when :following_sibling + nodeset = step(path_stack) do + nodesets = [] + nodeset.each do |node| + raw_node = node.raw_node + next unless raw_node.respond_to?(:parent) + next if raw_node.parent.nil? + all_siblings = raw_node.parent.children + current_index = all_siblings.index(raw_node) + following_siblings = all_siblings[(current_index + 1)..-1] + next if following_siblings.empty? + nodesets << following_siblings.collect.with_index do |sibling, i| + XPathNode.new(sibling, position: i + 1) + end + end + nodesets + end + when :preceding_sibling + nodeset = step(path_stack, order: :reverse) do + nodesets = [] + nodeset.each do |node| + raw_node = node.raw_node + next unless raw_node.respond_to?(:parent) + next if raw_node.parent.nil? + all_siblings = raw_node.parent.children + current_index = all_siblings.index(raw_node) + preceding_siblings = all_siblings[0, current_index].reverse + next if preceding_siblings.empty? + nodesets << preceding_siblings.collect.with_index do |sibling, i| + XPathNode.new(sibling, position: i + 1) + end + end + nodesets + end + when :preceding + nodeset = step(path_stack, order: :reverse) do + unnode(nodeset) do |node| + preceding(node) + end + end + when :following + nodeset = step(path_stack) do + unnode(nodeset) do |node| + following(node) + end + end + when :variable + var_name = path_stack.shift + return [@variables[var_name]] + + when :eq, :neq, :lt, :lteq, :gt, :gteq + left = expr( path_stack.shift, nodeset.dup, context ) + right = expr( path_stack.shift, nodeset.dup, context ) + res = equality_relational_compare( left, op, right ) + trace(op, left, right, res) if @debug + return res + + when :or + left = expr(path_stack.shift, nodeset.dup, context) + return true if Functions.boolean(left) + right = expr(path_stack.shift, nodeset.dup, context) + return Functions.boolean(right) + + when :and + left = expr(path_stack.shift, nodeset.dup, context) + return false unless Functions.boolean(left) + right = expr(path_stack.shift, nodeset.dup, context) + return Functions.boolean(right) + + when :div, :mod, :mult, :plus, :minus + left = expr(path_stack.shift, nodeset, context) + right = expr(path_stack.shift, nodeset, context) + left = unnode(left) if left.is_a?(Array) + right = unnode(right) if right.is_a?(Array) + left = Functions::number(left) + right = Functions::number(right) + case op + when :div + return left / right + when :mod + return left % right + when :mult + return left * right + when :plus + return left + right + when :minus + return left - right + else + raise "[BUG] Unexpected operator: <#{op.inspect}>" + end + when :union + left = expr( path_stack.shift, nodeset, context ) + right = expr( path_stack.shift, nodeset, context ) + left = unnode(left) if left.is_a?(Array) + right = unnode(right) if right.is_a?(Array) + return (left | right) + when :neg + res = expr( path_stack, nodeset, context ) + res = unnode(res) if res.is_a?(Array) + return -Functions.number(res) + when :not + when :function + func_name = path_stack.shift.tr('-','_') + arguments = path_stack.shift + + if nodeset.size != 1 + message = "[BUG] Node set size must be 1 for function call: " + message += "<#{func_name}>: <#{nodeset.inspect}>: " + message += "<#{arguments.inspect}>" + raise message + end + + node = nodeset.first + if context + target_context = context + else + target_context = {:size => nodeset.size} + if node.is_a?(XPathNode) + target_context[:node] = node.raw_node + target_context[:index] = node.position + else + target_context[:node] = node + target_context[:index] = 1 + end + end + args = arguments.dclone.collect do |arg| + result = expr(arg, nodeset, target_context) + result = unnode(result) if result.is_a?(Array) + result + end + Functions.context = target_context + return Functions.send(func_name, *args) + + else + raise "[BUG] Unexpected path: <#{op.inspect}>: <#{path_stack.inspect}>" + end + end # while + return nodeset + ensure + leave(:expr, path_stack, nodeset) if @debug + end + + def step(path_stack, any_type: :element, order: :forward) + nodesets = yield + begin + enter(:step, path_stack, nodesets) if @debug + nodesets = node_test(path_stack, nodesets, any_type: any_type) + while path_stack[0] == :predicate + path_stack.shift # :predicate + predicate_expression = path_stack.shift.dclone + nodesets = evaluate_predicate(predicate_expression, nodesets) + end + if nodesets.size == 1 + ordered_nodeset = nodesets[0] + else + raw_nodes = [] + nodesets.each do |nodeset| + nodeset.each do |node| + if node.respond_to?(:raw_node) + raw_nodes << node.raw_node + else + raw_nodes << node + end + end + end + ordered_nodeset = sort(raw_nodes, order) + end + new_nodeset = [] + ordered_nodeset.each do |node| + # TODO: Remove duplicated + new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1) + end + new_nodeset + ensure + leave(:step, path_stack, new_nodeset) if @debug + end + end + + def node_test(path_stack, nodesets, any_type: :element) + enter(:node_test, path_stack, nodesets) if @debug + operator = path_stack.shift + case operator + when :qname + prefix = path_stack.shift + name = path_stack.shift + new_nodesets = nodesets.collect do |nodeset| + filter_nodeset(nodeset) do |node| + raw_node = node.raw_node + case raw_node.node_type + when :element + if prefix.nil? + raw_node.name == name + elsif prefix.empty? + if strict? + raw_node.name == name and raw_node.namespace == "" + else + # FIXME: This DOUBLES the time XPath searches take + ns = get_namespace(raw_node, prefix) + raw_node.name == name and raw_node.namespace == ns + end + else + # FIXME: This DOUBLES the time XPath searches take + ns = get_namespace(raw_node, prefix) + raw_node.name == name and raw_node.namespace == ns + end + when :attribute + if prefix.nil? + raw_node.name == name + elsif prefix.empty? + raw_node.name == name and raw_node.namespace == "" + else + # FIXME: This DOUBLES the time XPath searches take + ns = get_namespace(raw_node.element, prefix) + raw_node.name == name and raw_node.namespace == ns + end + else + false + end + end + end + when :namespace + prefix = path_stack.shift + new_nodesets = nodesets.collect do |nodeset| + filter_nodeset(nodeset) do |node| + raw_node = node.raw_node + case raw_node.node_type + when :element + namespaces = @namespaces || raw_node.namespaces + raw_node.namespace == namespaces[prefix] + when :attribute + namespaces = @namespaces || raw_node.element.namespaces + raw_node.namespace == namespaces[prefix] + else + false + end + end + end + when :any + new_nodesets = nodesets.collect do |nodeset| + filter_nodeset(nodeset) do |node| + raw_node = node.raw_node + raw_node.node_type == any_type + end + end + when :comment + new_nodesets = nodesets.collect do |nodeset| + filter_nodeset(nodeset) do |node| + raw_node = node.raw_node + raw_node.node_type == :comment + end + end + when :text + new_nodesets = nodesets.collect do |nodeset| + filter_nodeset(nodeset) do |node| + raw_node = node.raw_node + raw_node.node_type == :text + end + end + when :processing_instruction + target = path_stack.shift + new_nodesets = nodesets.collect do |nodeset| + filter_nodeset(nodeset) do |node| + raw_node = node.raw_node + (raw_node.node_type == :processing_instruction) and + (target.empty? or (raw_node.target == target)) + end + end + when :node + new_nodesets = nodesets.collect do |nodeset| + filter_nodeset(nodeset) do |node| + true + end + end + else + message = "[BUG] Unexpected node test: " + + "<#{operator.inspect}>: <#{path_stack.inspect}>" + raise message + end + new_nodesets + ensure + leave(:node_test, path_stack, new_nodesets) if @debug + end + + def filter_nodeset(nodeset) + new_nodeset = [] + nodeset.each do |node| + next unless yield(node) + new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1) + end + new_nodeset + end + + def evaluate_predicate(expression, nodesets) + enter(:predicate, expression, nodesets) if @debug + new_nodeset_count = 0 + new_nodesets = nodesets.collect do |nodeset| + new_nodeset = [] + subcontext = { :size => nodeset.size } + nodeset.each_with_index do |node, index| + if node.is_a?(XPathNode) + subcontext[:node] = node.raw_node + subcontext[:index] = node.position + else + subcontext[:node] = node + subcontext[:index] = index + 1 + end + result = expr(expression.dclone, [node], subcontext) + trace(:predicate_evaluate, expression, node, subcontext, result) if @debug + result = result[0] if result.kind_of? Array and result.length == 1 + if result.kind_of? Numeric + if result == node.position + new_nodeset_count += 1 + new_nodeset << XPathNode.new(node, position: new_nodeset_count) + end + elsif result.instance_of? Array + if result.size > 0 and result.inject(false) {|k,s| s or k} + if result.size > 0 + new_nodeset_count += 1 + new_nodeset << XPathNode.new(node, position: new_nodeset_count) + end + end + else + if result + new_nodeset_count += 1 + new_nodeset << XPathNode.new(node, position: new_nodeset_count) + end + end + end + new_nodeset + end + new_nodesets + ensure + leave(:predicate, new_nodesets) if @debug + end + + def trace(*args) + indent = " " * @nest + PP.pp(args, "").each_line do |line| + puts("#{indent}#{line}") + end + end + + def enter(tag, *args) + trace(:enter, tag, *args) + @nest += 1 + end + + def leave(tag, *args) + @nest -= 1 + trace(:leave, tag, *args) + end + + # Reorders an array of nodes so that they are in document order + # It tries to do this efficiently. + # + # FIXME: I need to get rid of this, but the issue is that most of the XPath + # interpreter functions as a filter, which means that we lose context going + # in and out of function calls. If I knew what the index of the nodes was, + # I wouldn't have to do this. Maybe add a document IDX for each node? + # Problems with mutable documents. Or, rewrite everything. + def sort(array_of_nodes, order) + new_arry = [] + array_of_nodes.each { |node| + node_idx = [] + np = node.node_type == :attribute ? node.element : node + while np.parent and np.parent.node_type == :element + node_idx << np.parent.index( np ) + np = np.parent + end + new_arry << [ node_idx.reverse, node ] + } + ordered = new_arry.sort_by do |index, node| + if order == :forward + index + else + -index + end + end + ordered.collect do |_index, node| + node + end + end + + def descendant(nodeset, include_self) + nodesets = [] + nodeset.each do |node| + new_nodeset = [] + new_nodes = {} + descendant_recursive(node.raw_node, new_nodeset, new_nodes, include_self) + nodesets << new_nodeset unless new_nodeset.empty? + end + nodesets + end + + def descendant_recursive(raw_node, new_nodeset, new_nodes, include_self) + if include_self + return if new_nodes.key?(raw_node) + new_nodeset << XPathNode.new(raw_node, position: new_nodeset.size + 1) + new_nodes[raw_node] = true + end + + node_type = raw_node.node_type + if node_type == :element or node_type == :document + raw_node.children.each do |child| + descendant_recursive(child, new_nodeset, new_nodes, true) + end + end + end + + # Builds a nodeset of all of the preceding nodes of the supplied node, + # in reverse document order + # preceding:: includes every element in the document that precedes this node, + # except for ancestors + def preceding(node) + ancestors = [] + parent = node.parent + while parent + ancestors << parent + parent = parent.parent + end + + precedings = [] + preceding_node = preceding_node_of(node) + while preceding_node + if ancestors.include?(preceding_node) + ancestors.delete(preceding_node) + else + precedings << XPathNode.new(preceding_node, + position: precedings.size + 1) + end + preceding_node = preceding_node_of(preceding_node) + end + precedings + end + + def preceding_node_of( node ) + psn = node.previous_sibling_node + if psn.nil? + if node.parent.nil? or node.parent.class == Document + return nil + end + return node.parent + #psn = preceding_node_of( node.parent ) + end + while psn and psn.kind_of? Element and psn.children.size > 0 + psn = psn.children[-1] + end + psn + end + + def following(node) + followings = [] + following_node = next_sibling_node(node) + while following_node + followings << XPathNode.new(following_node, + position: followings.size + 1) + following_node = following_node_of(following_node) + end + followings + end + + def following_node_of( node ) + if node.kind_of? Element and node.children.size > 0 + return node.children[0] + end + return next_sibling_node(node) + end + + def next_sibling_node(node) + psn = node.next_sibling_node + while psn.nil? + if node.parent.nil? or node.parent.class == Document + return nil + end + node = node.parent + psn = node.next_sibling_node + end + return psn + end + + def child(nodeset) + nodesets = [] + nodeset.each do |node| + raw_node = node.raw_node + node_type = raw_node.node_type + # trace(:child, node_type, node) + case node_type + when :element + nodesets << raw_node.children.collect.with_index do |child_node, i| + XPathNode.new(child_node, position: i + 1) + end + when :document + new_nodeset = [] + raw_node.children.each do |child| + case child + when XMLDecl, Text + # Ignore + else + new_nodeset << XPathNode.new(child, position: new_nodeset.size + 1) + end + end + nodesets << new_nodeset unless new_nodeset.empty? + end + end + nodesets + end + + def norm b + case b + when true, false + return b + when 'true', 'false' + return Functions::boolean( b ) + when /^\d+(\.\d+)?$/, Numeric + return Functions::number( b ) + else + return Functions::string( b ) + end + end + + def equality_relational_compare(set1, op, set2) + set1 = unnode(set1) if set1.is_a?(Array) + set2 = unnode(set2) if set2.is_a?(Array) + + if set1.kind_of? Array and set2.kind_of? Array + # If both objects to be compared are node-sets, then the + # comparison will be true if and only if there is a node in the + # first node-set and a node in the second node-set such that the + # result of performing the comparison on the string-values of + # the two nodes is true. + set1.product(set2).any? do |node1, node2| + node_string1 = Functions.string(node1) + node_string2 = Functions.string(node2) + compare(node_string1, op, node_string2) + end + elsif set1.kind_of? Array or set2.kind_of? Array + # If one is nodeset and other is number, compare number to each item + # in nodeset s.t. number op number(string(item)) + # If one is nodeset and other is string, compare string to each item + # in nodeset s.t. string op string(item) + # If one is nodeset and other is boolean, compare boolean to each item + # in nodeset s.t. boolean op boolean(item) + if set1.kind_of? Array + a = set1 + b = set2 + else + a = set2 + b = set1 + end + + case b + when true, false + each_unnode(a).any? do |unnoded| + compare(Functions.boolean(unnoded), op, b) + end + when Numeric + each_unnode(a).any? do |unnoded| + compare(Functions.number(unnoded), op, b) + end + when /\A\d+(\.\d+)?\z/ + b = Functions.number(b) + each_unnode(a).any? do |unnoded| + compare(Functions.number(unnoded), op, b) + end + else + b = Functions::string(b) + each_unnode(a).any? do |unnoded| + compare(Functions::string(unnoded), op, b) + end + end + else + # If neither is nodeset, + # If op is = or != + # If either boolean, convert to boolean + # If either number, convert to number + # Else, convert to string + # Else + # Convert both to numbers and compare + compare(set1, op, set2) + end + end + + def value_type(value) + case value + when true, false + :boolean + when Numeric + :number + when String + :string + else + raise "[BUG] Unexpected value type: <#{value.inspect}>" + end + end + + def normalize_compare_values(a, operator, b) + a_type = value_type(a) + b_type = value_type(b) + case operator + when :eq, :neq + if a_type == :boolean or b_type == :boolean + a = Functions.boolean(a) unless a_type == :boolean + b = Functions.boolean(b) unless b_type == :boolean + elsif a_type == :number or b_type == :number + a = Functions.number(a) unless a_type == :number + b = Functions.number(b) unless b_type == :number + else + a = Functions.string(a) unless a_type == :string + b = Functions.string(b) unless b_type == :string + end + when :lt, :lteq, :gt, :gteq + a = Functions.number(a) unless a_type == :number + b = Functions.number(b) unless b_type == :number + else + message = "[BUG] Unexpected compare operator: " + + "<#{operator.inspect}>: <#{a.inspect}>: <#{b.inspect}>" + raise message + end + [a, b] + end + + def compare(a, operator, b) + a, b = normalize_compare_values(a, operator, b) + case operator + when :eq + a == b + when :neq + a != b + when :lt + a < b + when :lteq + a <= b + when :gt + a > b + when :gteq + a >= b + else + message = "[BUG] Unexpected compare operator: " + + "<#{operator.inspect}>: <#{a.inspect}>: <#{b.inspect}>" + raise message + end + end + + def each_unnode(nodeset) + return to_enum(__method__, nodeset) unless block_given? + nodeset.each do |node| + if node.is_a?(XPathNode) + unnoded = node.raw_node + else + unnoded = node + end + yield(unnoded) + end + end + + def unnode(nodeset) + each_unnode(nodeset).collect do |unnoded| + unnoded = yield(unnoded) if block_given? + unnoded + end + end + end + + # @private + class XPathNode + attr_reader :raw_node, :context + def initialize(node, context=nil) + if node.is_a?(XPathNode) + @raw_node = node.raw_node + else + @raw_node = node + end + @context = context || {} + end + + def position + @context[:position] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/Gemfile b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/Gemfile new file mode 100644 index 0000000..2e880cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/Gemfile @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +source 'http://rubygems.org' + +gemspec + +gem 'rake' + +gem 'minitest', '>= 5.0' +gem 'minitest-power_assert' +gem 'power_assert', '~> 2.0' + +# don't try to install redcarpet under jruby +gem 'redcarpet', platforms: :ruby + +# Profiling +gem 'memory_profiler', require: false + +group :development do + gem 'pry' + + # Needed for a Rake task + gem 'git' + gem 'yard' + + gem 'rubocop', '~> 1.0', '<= 1.11' + gem 'rubocop-performance' + + # docs + gem 'github-markup' + + # for visual tests + gem 'sinatra' + + # Ruby 3 no longer ships with a web server + gem 'puma' if RUBY_VERSION >= '3' + gem 'shotgun' +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/LICENSE b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/LICENSE new file mode 100644 index 0000000..660592c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/LICENSE @@ -0,0 +1,186 @@ +# MIT license. See http://www.opensource.org/licenses/mit-license.php + +Copyright (c) 2012 Jeanine Adkisson. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +# SPECIAL NOTE: +Many of the lexers in this project are adaptations of those in Pygments +(pygments.org). The license for Pygments is as follows: + +# BEGIN pygments/LICENSE # + +Copyright (c) 2006-2012 by the respective authors (see AUTHORS file). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* 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. + +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 +OWNER 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. + +# END pygments/LICENSE # + +The contents of the AUTHORS file at the time of porting was: + +# BEGIN pygments/AUTHORS # + +Pygments is written and maintained by Georg Brandl <georg@python.org>. + +Major developers are Tim Hatch <tim@timhatch.com> and Armin Ronacher +<armin.ronacher@active-4.com>. + +Other contributors, listed alphabetically, are: + +* Sam Aaron -- Ioke lexer +* Kumar Appaiah -- Debian control lexer +* Ali Afshar -- image formatter +* Andreas Amann -- AppleScript lexer +* Jeffrey Arnold -- R/S lexer, BUGS lexers +* Jeremy Ashkenas -- CoffeeScript lexer +* Stefan Matthias Aust -- Smalltalk lexer +* Ben Bangert -- Mako lexers +* Max Battcher -- Darcs patch lexer +* Paul Baumgart, 280 North, Inc. -- Objective-J lexer +* Michael Bayer -- Myghty lexers +* John Benediktsson -- Factor lexer +* Christopher Bertels -- Fancy lexer +* Jarrett Billingsley -- MiniD lexer +* Adam Blinkinsop -- Haskell, Redcode lexers +* Frits van Bommel -- assembler lexers +* Pierre Bourdon -- bugfixes +* Hiram Chirino -- Scaml and Jade lexers +* Leaf Corcoran -- MoonScript lexer +* Christopher Creutzig -- MuPAD lexer +* Pete Curry -- bugfixes +* Owen Durni -- haXe lexer +* Nick Efford -- Python 3 lexer +* Sven Efftinge -- Xtend lexer +* Artem Egorkine -- terminal256 formatter +* James H. Fisher -- PostScript lexer +* Carlos Galdino -- Elixir and Elixir Console lexers +* Naveen Garg -- Autohotkey lexer +* Laurent Gautier -- R/S lexer +* Alex Gaynor -- PyPy log lexer +* Bertrand Goetzmann -- Groovy lexer +* Krzysiek Goj -- Scala lexer +* Matt Good -- Genshi, Cheetah lexers +* Patrick Gotthardt -- PHP namespaces support +* Olivier Guibe -- Asymptote lexer +* Martin Harriman -- SNOBOL lexer +* Matthew Harrison -- SVG formatter +* Steven Hazel -- Tcl lexer +* Aslak Hellesøy -- Gherkin lexer +* Greg Hendershott -- Racket lexer +* Jordi Gutiérrez Hermoso -- Octave lexer +* David Hess, Fish Software, Inc. -- Objective-J lexer +* Varun Hiremath -- Debian control lexer +* Doug Hogan -- Mscgen lexer +* Ben Hollis -- Mason lexer +* Tim Howard -- BlitzMax lexer +* Ivan Inozemtsev -- Fantom lexer +* Brian R. Jackson -- Tea lexer +* Dennis Kaarsemaker -- sources.list lexer +* Igor Kalnitsky -- vhdl lexer +* Eric Knibbe -- Lasso lexer +* Adam Koprowski -- Opa lexer +* Benjamin Kowarsch -- Modula-2 lexer +* Alexander Kriegisch -- Kconfig and AspectJ lexers +* Marek Kubica -- Scheme lexer +* Jochen Kupperschmidt -- Markdown processor +* Gerd Kurzbach -- Modelica lexer +* Olov Lassus -- Dart lexer +* Sylvestre Ledru -- Scilab lexer +* Mark Lee -- Vala lexer +* Ben Mabey -- Gherkin lexer +* Simone Margaritelli -- Hybris lexer +* Kirk McDonald -- D lexer +* Gordon McGregor -- SystemVerilog lexer +* Stephen McKamey -- Duel/JBST lexer +* Brian McKenna -- F# lexer +* Lukas Meuser -- BBCode formatter, Lua lexer +* Paul Miller -- LiveScript lexer +* Hong Minhee -- HTTP lexer +* Michael Mior -- Awk lexer +* Jon Morton -- Rust lexer +* Paulo Moura -- Logtalk lexer +* Mher Movsisyan -- DTD lexer +* Ana Nelson -- Ragel, ANTLR, R console lexers +* Nam T. Nguyen -- Monokai style +* Jesper Noehr -- HTML formatter "anchorlinenos" +* Mike Nolta -- Julia lexer +* Jonas Obrist -- BBCode lexer +* David Oliva -- Rebol lexer +* Jon Parise -- Protocol buffers lexer +* Ronny Pfannschmidt -- BBCode lexer +* Benjamin Peterson -- Test suite refactoring +* Dominik Picheta -- Nimrod lexer +* Clément Prévost -- UrbiScript lexer +* Kashif Rasul -- CUDA lexer +* Justin Reidy -- MXML lexer +* Norman Richards -- JSON lexer +* Lubomir Rintel -- GoodData MAQL and CL lexers +* Andre Roberge -- Tango style +* Konrad Rudolph -- LaTeX formatter enhancements +* Mario Ruggier -- Evoque lexers +* Stou Sandalski -- NumPy, FORTRAN, tcsh and XSLT lexers +* Matteo Sasso -- Common Lisp lexer +* Joe Schafer -- Ada lexer +* Ken Schutte -- Matlab lexers +* Tassilo Schweyer -- Io, MOOCode lexers +* Joerg Sieker -- ABAP lexer +* Robert Simmons -- Standard ML lexer +* Kirill Simonov -- YAML lexer +* Steve Spigarelli -- XQuery lexer +* Jerome St-Louis -- eC lexer +* James Strachan -- Kotlin lexer +* Tiberius Teng -- default style overhaul +* Jeremy Thurgood -- Erlang, Squid config lexers +* Erick Tryzelaar -- Felix lexer +* Daniele Varrazzo -- PostgreSQL lexers +* Abe Voelker -- OpenEdge ABL lexer +* Whitney Young -- ObjectiveC lexer +* Matthias Vallentin -- Bro lexer +* Nathan Weizenbaum -- Haml and Sass lexers +* Dietmar Winkler -- Modelica lexer +* Nils Winter -- Smalltalk lexer +* Davy Wybiral -- Clojure lexer +* Diego Zamboni -- CFengine3 lexer +* Alex Zimin -- Nemerle lexer + +Many thanks for all contributions! + +# END pygments/AUTHORS # diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/bin/rougify b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/bin/rougify new file mode 100755 index 0000000..13f2b10 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/bin/rougify @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'pathname' +ROOT_DIR = Pathname.new(__FILE__).dirname.parent +Kernel::load ROOT_DIR.join('lib/rouge.rb') +Kernel::load ROOT_DIR.join('lib/rouge/cli.rb') +Signal.trap('PIPE', 'SYSTEM_DEFAULT') if Signal.list.include? 'PIPE' + +begin + Rouge::CLI.parse(ARGV).run +rescue Rouge::CLI::Error => e + puts e.message + exit e.status +rescue Interrupt + $stderr.puts "\nrouge: interrupted" + exit 2 +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge.rb new file mode 100644 index 0000000..f8cffcb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge.rb @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# stdlib +require 'pathname' + +# The containing module for Rouge +module Rouge + # cache value in a constant since `__dir__` allocates a new string + # on every call. + LIB_DIR = __dir__.freeze + + class << self + def reload! + Object::send :remove_const, :Rouge + Kernel::load __FILE__ + end + + # Highlight some text with a given lexer and formatter. + # + # @example + # Rouge.highlight('@foo = 1', 'ruby', 'html') + # Rouge.highlight('var foo = 1;', 'js', 'terminal256') + # + # # streaming - chunks become available as they are lexed + # Rouge.highlight(large_string, 'ruby', 'html') do |chunk| + # $stdout.print chunk + # end + def highlight(text, lexer, formatter, &b) + lexer = Lexer.find(lexer) unless lexer.respond_to? :lex + raise "unknown lexer #{lexer}" unless lexer + + formatter = Formatter.find(formatter) unless formatter.respond_to? :format + raise "unknown formatter #{formatter}" unless formatter + + formatter.format(lexer.lex(text), &b) + end + + # Load a file relative to the `lib/rouge` path. + # + # @api private + def load_file(path) + Kernel::load File.join(LIB_DIR, "rouge/#{path}.rb") + end + + # Load the lexers in the `lib/rouge/lexers` directory. + # + # @api private + def load_lexers + lexer_dir = Pathname.new(LIB_DIR) / "rouge/lexers" + Pathname.glob(lexer_dir / '*.rb').each do |f| + Lexers.load_lexer(f.relative_path_from(lexer_dir)) + end + end + end +end + +Rouge.load_file 'version' +Rouge.load_file 'util' +Rouge.load_file 'text_analyzer' +Rouge.load_file 'token' + +Rouge.load_file 'lexer' +Rouge.load_file 'regex_lexer' +Rouge.load_file 'template_lexer' + +Rouge.load_lexers + +Rouge.load_file 'guesser' +Rouge.load_file 'guessers/util' +Rouge.load_file 'guessers/glob_mapping' +Rouge.load_file 'guessers/modeline' +Rouge.load_file 'guessers/filename' +Rouge.load_file 'guessers/mimetype' +Rouge.load_file 'guessers/source' +Rouge.load_file 'guessers/disambiguation' + +Rouge.load_file 'formatter' +Rouge.load_file 'formatters/html' +Rouge.load_file 'formatters/html_table' +Rouge.load_file 'formatters/html_pygments' +Rouge.load_file 'formatters/html_legacy' +Rouge.load_file 'formatters/html_linewise' +Rouge.load_file 'formatters/html_line_highlighter' +Rouge.load_file 'formatters/html_line_table' +Rouge.load_file 'formatters/html_inline' +Rouge.load_file 'formatters/terminal256' +Rouge.load_file 'formatters/terminal_truecolor' +Rouge.load_file 'formatters/tex' +Rouge.load_file 'formatters/null' + +Rouge.load_file 'theme' +Rouge.load_file 'tex_theme_renderer' +Rouge.load_file 'themes/thankful_eyes' +Rouge.load_file 'themes/colorful' +Rouge.load_file 'themes/base16' +Rouge.load_file 'themes/github' +Rouge.load_file 'themes/igor_pro' +Rouge.load_file 'themes/monokai' +Rouge.load_file 'themes/molokai' +Rouge.load_file 'themes/monokai_sublime' +Rouge.load_file 'themes/gruvbox' +Rouge.load_file 'themes/tulip' +Rouge.load_file 'themes/pastie' +Rouge.load_file 'themes/bw' +Rouge.load_file 'themes/magritte' diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/cli.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/cli.rb new file mode 100644 index 0000000..49d9df4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/cli.rb @@ -0,0 +1,529 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# not required by the main lib. +# to use this module, require 'rouge/cli'. + +require 'rbconfig' + +module Rouge + class FileReader + attr_reader :input + def initialize(input) + @input = input + end + + def file + case input + when '-' + IO.new($stdin.fileno, 'rt:bom|utf-8') + when String + File.new(input, 'rt:bom|utf-8') + when ->(i){ i.respond_to? :read } + input + end + end + + def read + @read ||= begin + file.read + rescue => e + $stderr.puts "unable to open #{input}: #{e.message}" + exit 1 + ensure + file.close + end + end + end + + class CLI + def self.doc + return enum_for(:doc) unless block_given? + + yield %|usage: rougify {global options} [command] [args...]| + yield %|| + yield %|where <command> is one of:| + yield %| highlight #{Highlight.desc}| + yield %| debug #{Debug.desc}| + yield %| help #{Help.desc}| + yield %| style #{Style.desc}| + yield %| list #{List.desc}| + yield %| guess #{Guess.desc}| + yield %| version #{Version.desc}| + yield %|| + yield %|global options:| + yield %[ --require|-r <fname> require <fname> after loading rouge] + yield %|| + yield %|See `rougify help <command>` for more info.| + end + + class Error < StandardError + attr_reader :message, :status + def initialize(message, status=1) + @message = message + @status = status + end + end + + def self.parse(argv=ARGV) + argv = normalize_syntax(argv) + + while (head = argv.shift) + case head + when '-h', '--help', 'help', '-help' + return Help.parse(argv) + when '--require', '-r' + require argv.shift + else + break + end + end + + klass = class_from_arg(head) + return klass.parse(argv) if klass + + argv.unshift(head) if head + Highlight.parse(argv) + end + + def initialize(options={}) + end + + def self.error!(msg, status=1) + raise Error.new(msg, status) + end + + def error!(*a) + self.class.error!(*a) + end + + def self.class_from_arg(arg) + case arg + when 'version', '--version', '-v' + Version + when 'help', nil + Help + when 'highlight', 'hi' + Highlight + when 'debug' + Debug + when 'style' + Style + when 'list' + List + when 'guess' + Guess + end + end + + class Version < CLI + def self.desc + "print the rouge version number" + end + + def self.parse(*); new; end + + def run + puts Rouge.version + end + end + + class Help < CLI + def self.desc + "print help info" + end + + def self.doc + return enum_for(:doc) unless block_given? + + yield %|usage: rougify help <command>| + yield %|| + yield %|print help info for <command>.| + end + + def self.parse(argv) + opts = { :mode => CLI } + until argv.empty? + arg = argv.shift + klass = class_from_arg(arg) + if klass + opts[:mode] = klass + next + end + end + new(opts) + end + + def initialize(opts={}) + @mode = opts[:mode] + end + + def run + @mode.doc.each(&method(:puts)) + end + end + + class Highlight < CLI + def self.desc + "highlight code" + end + + def self.doc + return enum_for(:doc) unless block_given? + + yield %[usage: rougify highlight <filename> [options...]] + yield %[ rougify highlight [options...]] + yield %[] + yield %[--input-file|-i <filename> specify a file to read, or - to use stdin] + yield %[] + yield %[--lexer|-l <lexer> specify the lexer to use.] + yield %[ If not provided, rougify will try to guess] + yield %[ based on --mimetype, the filename, and the] + yield %[ file contents.] + yield %[] + yield %[--formatter-preset|-f <opts> specify the output formatter to use.] + yield %[ If not provided, rougify will default to] + yield %[ terminal256. options are: terminal256,] + yield %[ terminal-truecolor, html, html-pygments,] + yield %[ html-inline, html-line-table, html-table,] + yield %[ null/raw/tokens, or tex.] + yield %[] + yield %[--theme|-t <theme> specify the theme to use for highlighting] + yield %[ the file. (only applies to some formatters)] + yield %[] + yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing] + yield %[] + yield %[--lexer-opts|-L <opts> specify lexer options in CGI format] + yield %[ (opt1=val1&opt2=val2)] + yield %[] + yield %[--formatter-opts|-F <opts> specify formatter options in CGI format] + yield %[ (opt1=val1&opt2=val2)] + yield %[] + yield %[--require|-r <filename> require a filename or library before] + yield %[ highlighting] + yield %[] + yield %[--escape allow the use of escapes between <! and !>] + yield %[] + yield %[--escape-with <l> <r> allow the use of escapes between custom] + yield %[ delimiters. implies --escape] + end + + # There is no consistent way to do this, but this is used elsewhere, + # and we provide explicit opt-in and opt-out with $COLORTERM + def self.supports_truecolor? + return true if %w(24bit truecolor).include?(ENV['COLORTERM']) + return false if ENV['COLORTERM'] && ENV['COLORTERM'] =~ /256/ + + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ + ENV['ConEmuANSI'] == 'ON' && !ENV['ANSICON'] + else + ENV['TERM'] !~ /(^rxvt)|(-color$)/ + end + end + + def self.parse_opts(argv) + opts = { + :formatter => supports_truecolor? ? 'terminal-truecolor' : 'terminal256', + :theme => 'thankful_eyes', + :css_class => 'codehilite', + :input_file => '-', + :lexer_opts => {}, + :formatter_opts => {}, + :requires => [], + } + + until argv.empty? + arg = argv.shift + case arg + when '-r', '--require' + opts[:requires] << argv.shift + when '--input-file', '-i' + opts[:input_file] = argv.shift + when '--mimetype', '-m' + opts[:mimetype] = argv.shift + when '--lexer', '-l' + opts[:lexer] = argv.shift + when '--formatter-preset', '-f' + opts[:formatter] = argv.shift + when '--theme', '-t' + opts[:theme] = argv.shift + when '--css-class', '-c' + opts[:css_class] = argv.shift + when '--lexer-opts', '-L' + opts[:lexer_opts] = parse_cgi(argv.shift) + when '--escape' + opts[:escape] = ['<!', '!>'] + when '--escape-with' + opts[:escape] = [argv.shift, argv.shift] + when /^--/ + error! "unknown option #{arg.inspect}" + else + opts[:input_file] = arg + end + end + + opts + end + + def self.parse(argv) + new(parse_opts(argv)) + end + + def input_stream + @input_stream ||= FileReader.new(@input_file) + end + + def input + @input ||= input_stream.read + end + + def lexer_class + @lexer_class ||= Lexer.guess( + :filename => @input_file, + :mimetype => @mimetype, + :source => input_stream, + ) + end + + def raw_lexer + lexer_class.new(@lexer_opts) + end + + def escape_lexer + Rouge::Lexers::Escape.new( + start: @escape[0], + end: @escape[1], + lang: raw_lexer, + ) + end + + def lexer + @lexer ||= @escape ? escape_lexer : raw_lexer + end + + attr_reader :input_file, :lexer_name, :mimetype, :formatter, :escape + + def initialize(opts={}) + Rouge::Lexer.enable_debug! + + opts[:requires].each do |r| + require r + end + + @input_file = opts[:input_file] + + if opts[:lexer] + @lexer_class = Lexer.find(opts[:lexer]) \ + or error! "unknown lexer #{opts[:lexer].inspect}" + else + @lexer_name = opts[:lexer] + @mimetype = opts[:mimetype] + end + + @lexer_opts = opts[:lexer_opts] + + theme = Theme.find(opts[:theme]).new or error! "unknown theme #{opts[:theme]}" + + # TODO: document this in --help + @formatter = case opts[:formatter] + when 'terminal256' then Formatters::Terminal256.new(theme) + when 'terminal-truecolor' then Formatters::TerminalTruecolor.new(theme) + when 'html' then Formatters::HTML.new + when 'html-pygments' then Formatters::HTMLPygments.new(Formatters::HTML.new, opts[:css_class]) + when 'html-inline' then Formatters::HTMLInline.new(theme) + when 'html-line-table' then Formatters::HTMLLineTable.new(Formatters::HTML.new) + when 'html-table' then Formatters::HTMLTable.new(Formatters::HTML.new) + when 'null', 'raw', 'tokens' then Formatters::Null.new + when 'tex' then Formatters::Tex.new + else + error! "unknown formatter preset #{opts[:formatter]}" + end + + @escape = opts[:escape] + end + + def run + Formatter.enable_escape! if @escape + formatter.format(lexer.lex(input), &method(:print)) + end + + private_class_method def self.parse_cgi(str) + pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] } + Hash[pairs] + end + end + + class Debug < Highlight + def self.desc + end + + def self.doc + return enum_for(:doc) unless block_given? + + yield %|usage: rougify debug [<options>]| + yield %|| + yield %|Debug a lexer. Similar options to `rougify highlight`, but| + yield %|defaults to the `null` formatter, and ensures the `debug`| + yield %|option is enabled, to print debugging information to stdout.| + end + + def self.parse_opts(argv) + out = super(argv) + out[:lexer_opts]['debug'] = '1' + out[:formatter] = 'null' + + out + end + end + + class Style < CLI + def self.desc + "print CSS styles" + end + + def self.doc + return enum_for(:doc) unless block_given? + + yield %|usage: rougify style [<theme-name>] [<options>]| + yield %|| + yield %|Print CSS styles for the given theme. Extra options are| + yield %|passed to the theme. To select a mode (light/dark) for the| + yield %|theme, append '.light' or '.dark' to the <theme-name>| + yield %|respectively. Theme defaults to thankful_eyes.| + yield %|| + yield %|options:| + yield %| --scope (default: .highlight) a css selector to scope by| + yield %| --tex (default: false) render as TeX| + yield %| --tex-prefix (default: RG) a command prefix for TeX| + yield %| implies --tex if specified| + yield %|| + yield %|available themes:| + yield %| #{Theme.registry.keys.sort.join(', ')}| + end + + def self.parse(argv) + opts = { + :theme_name => 'thankful_eyes', + :tex => false, + :tex_prefix => 'RG' + } + + until argv.empty? + arg = argv.shift + case arg + when '--tex' + opts[:tex] = true + when '--tex-prefix' + opts[:tex] = true + opts[:tex_prefix] = argv.shift + when /--(\w+)/ + opts[$1.tr('-', '_').to_sym] = argv.shift + else + opts[:theme_name] = arg + end + end + + new(opts) + end + + def initialize(opts) + theme_name = opts.delete(:theme_name) + theme_class = Theme.find(theme_name) \ + or error! "unknown theme: #{theme_name}" + + @theme = theme_class.new(opts) + if opts[:tex] + tex_prefix = opts[:tex_prefix] + @theme = TexThemeRenderer.new(@theme, prefix: tex_prefix) + end + end + + def run + @theme.render(&method(:puts)) + end + end + + class List < CLI + def self.desc + "list available lexers" + end + + def self.doc + return enum_for(:doc) unless block_given? + + yield %|usage: rouge list| + yield %|| + yield %|print a list of all available lexers with their descriptions.| + end + + def self.parse(argv) + new + end + + def run + puts "== Available Lexers ==" + + Lexer.all.sort_by(&:tag).each do |lexer| + desc = String.new("#{lexer.desc}") + if lexer.aliases.any? + desc << " [aliases: #{lexer.aliases.join(',')}]" + end + puts "%s: %s" % [lexer.tag, desc] + + lexer.option_docs.keys.sort.each do |option| + puts " ?#{option}= #{lexer.option_docs[option]}" + end + + puts + end + end + end + + class Guess < CLI + def self.desc + "guess the languages of file" + end + + def self.parse(args) + new(input_file: args.shift) + end + + attr_reader :input_file, :input_source + + def initialize(opts) + @input_file = opts[:input_file] || '-' + @input_source = FileReader.new(@input_file).read + end + + def lexers + Lexer.guesses( + filename: input_file, + source: input_source, + ) + end + + def run + lexers.each do |l| + puts "{ tag: #{l.tag.inspect}, title: #{l.title.inspect}, desc: #{l.desc.inspect} }" + end + end + end + + + private_class_method def self.normalize_syntax(argv) + out = [] + argv.each do |arg| + case arg + when /^(--\w+)=(.*)$/ + out << $1 << $2 + when /^(-\w)(.+)$/ + out << $1 << $2 + else + out << arg + end + end + + out + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/abap b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/abap new file mode 100644 index 0000000..1f0171b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/abap @@ -0,0 +1,6 @@ +lo_obj ?= lo_obj->do_nothing( 'Char' && ` String` ). + +SELECT SINGLE * FROM mara INTO ls_mara WHERE matkl EQ '1324'. +LOOP AT lt_mara ASSIGNING <mara>. + CHECK <mara>-mtart EQ '0001'. +ENDLOOP. diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/actionscript b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/actionscript new file mode 100644 index 0000000..f081e25 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/actionscript @@ -0,0 +1,4 @@ +function hello(name:String):void +{ + trace("hello " + name); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ada b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ada new file mode 100644 index 0000000..36182fb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ada @@ -0,0 +1,26 @@ +with Ada.Directories; +with Ada.Direct_IO; +with Ada.Text_IO; + +procedure Extra_IO.Read_File (Name : String) is + + package Dirs renames Ada.Directories; + package Text_IO renames Ada.Text_IO; + + -- Get the size of the file for a new string. + Size : Natural := Natural (Dirs.Size (Name)); + subtype File_String is String (1 .. Size); + + -- Instantiate Direct_IO for our file type. + package FIO is new Ada.Direct_IO (File_String); + + File : FIO.File_Type; + Contents : File_String; + +begin + FIO.Open (File, FIO.In_File, Name); + FIO.Read (File, Contents); + FIO.Close (File); + + Text_IO.Put (Contents); +end Extra_IO.Read_File; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apache b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apache new file mode 100644 index 0000000..ce3e5fc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apache @@ -0,0 +1,21 @@ +AddDefaultCharset UTF-8 + +RewriteEngine On + +# Serve gzipped version if available and accepted +AddEncoding x-gzip .gz +RewriteCond %{HTTP:Accept-Encoding} gzip +RewriteCond %{REQUEST_FILENAME}.gz -f +RewriteRule ^(.*)$ $1.gz [QSA,L] +<FilesMatch \.css\.gz$> + ForceType text/css + Header append Vary Accept-Encoding +</FilesMatch> +<FilesMatch \.js\.gz$> + ForceType application/javascript + Header append Vary Accept-Encoding +</FilesMatch> +<FilesMatch \.html\.gz$> + ForceType text/html + Header append Vary Accept-Encoding +</FilesMatch> diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apex b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apex new file mode 100644 index 0000000..5b23b00 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apex @@ -0,0 +1,9 @@ +public class with sharing Trigger { + @Deprecated + public void resolveSum(int x, int y) { + System.debug('x is ' + x); + System.debug('y is ' + y); + + System.debug('x + y = ' + (x+y)); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apiblueprint b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apiblueprint new file mode 100644 index 0000000..25dc577 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/apiblueprint @@ -0,0 +1,33 @@ +FORMAT: 1A +HOST: http://polls.apiblueprint.org/ + +# Polls + +Polls is a simple API allowing consumers to view polls and vote in them. + +# Polls API Root [/] + +## Group Question + +Resources related to questions in the API. + +## Question [/questions/{question_id}] + ++ Parameters + + question_id: 1 (number, required) - ID of the Question in form of an integer + ++ Attributes + + question: `Favourite programming language?` (required) + + published_at: `2014-11-11T08:40:51.620Z` - An ISO8601 date when the question was published + + choices (array[Choice], required) - An array of Choice objects + + url: /questions/1 + +### View a Questions Detail [GET] + ++ Response 200 (application/json) + + Attributes (Question) + +### Delete a Question [DELETE] + ++ Relation: delete ++ Response 204 diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/applescript b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/applescript new file mode 100644 index 0000000..c824919 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/applescript @@ -0,0 +1,2 @@ +-- AppleScript playing with iTunes +tell application "iTunes" to get current selection diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/armasm b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/armasm new file mode 100644 index 0000000..b8bdf65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/armasm @@ -0,0 +1,12 @@ + GET common.s + +RetVal * 0x123 :SHL: 4 + + AREA |Area$$Name|, CODE, READONLY + +MyFunction ROUT ; This is a comment + ASSERT RetVal <> 0 +1 MOVW r0, #RetVal + BX lr + + END diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/augeas b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/augeas new file mode 100644 index 0000000..8f0ab0c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/augeas @@ -0,0 +1,16 @@ +(* + This is a comment +*) +module Foo = +autoload xfm + +let a = b | c . d + +let lns = a* + +let filter = incl "/path/to/file" + . incl "/path/to/other_file" + . Util.stdexcl + +(* xmf is the transform *) +let xmf = transform lns filter diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/awk b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/awk new file mode 100644 index 0000000..fb6ca72 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/awk @@ -0,0 +1,4 @@ +BEGIN { # Simulate echo(1) + for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i] + printf "\n" + exit } diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/batchfile b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/batchfile new file mode 100644 index 0000000..9426eb4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/batchfile @@ -0,0 +1,3 @@ +@echo off +setlocal enableextensions enabledelayedexpansion +for /f "tokens=*" %%a in ("hello !username! hi") do echo %%~a diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bbcbasic b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bbcbasic new file mode 100644 index 0000000..5737a5f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bbcbasic @@ -0,0 +1,6 @@ +REM > DefaultFilename +REM Ordinary comment +FOR n=1 TO 10 +PRINTTAB(n)"Hello there ";FNnumber(n)DIV3+1 +NEXT:END +DEFFNnumber(x%)=ABS(x%-4) diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bibtex b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bibtex new file mode 100644 index 0000000..e029265 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bibtex @@ -0,0 +1,12 @@ +@article{Witten:1988hf, + author = "Witten, Edward", + title = "{Quantum Field Theory and the Jones Polynomial}", + journal = "Commun. Math. Phys.", + volume = "121", + year = "1989", + pages = "351-399", + doi = "10.1007/BF01217730", + note = "[,233(1988)]", + reportNumber = "IASSNS-HEP-88-33", + SLACcitation = "%%CITATION = CMPHA,121,351;%%" +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/biml b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/biml new file mode 100644 index 0000000..e4d5f68 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/biml @@ -0,0 +1,38 @@ +<#@ template language="C#" #> +<#@ import namespace="System.Data" #> +<Biml xmlns="http://schemas.varigence.com/biml.xsd"> + <Connections> + <!-- Creates a connection to the Adventure Works database --> + <Connection + Name="AdventureWorks" + ConnectionString="Provider=SQLNCLI10.1;Data Source=Localhost;Persist Security Info=False;Integrated Security=SSPI;Initial Catalog=AdventureWorksDW" + /> + </Connections> + <!-- Packages Collection --> + <Packages> + <!-- A Package --> + <Package + Name="MyFirstPackage" + ConstraintMode="Linear" + > + <!-- A Package's Tasks --> + <Tasks> + <ExecuteSQL Name="ExecuteStoredProc" ConnectionName="AdventureWorks"> + <DirectInput>EXEC usp_StoredProc</DirectInput> + </ExecuteSQL> + <# foreach (var table in RootNode.Tables) { #> + <Dataflow Name="Duplicate <#=table.Name#> Data"> + <Transformations> + <OleDbSource Name="Retrieve Data" ConnectionName="AdventureWorks"> + <DirectInput>SELECT * FROM <#=table.Name#></DirectInput> + </OleDbSource> + <OleDbDestination Name="Insert Data" ConnectionName="AdventureWorks"> + <ExternalTableOutput Table="<#=table.Name#>" /> + </OleDbDestination> + </Transformations> + </Dataflow> + <# } #> + </Tasks> + </Package> + </Packages> +</Biml> diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bpf b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bpf new file mode 100644 index 0000000..45c2083 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bpf @@ -0,0 +1,7 @@ +r0 = *(u8 *)skb[23] +*(u32 *)(r10 - 4) = r0 +r1 = *(u32 *)(r6 + 4) +r1 = 0 ll +call 1 /* lookup */ +if r0 == 0 goto +2 <LBB0_3> +lock *(u64 *)(r0 + 0) += r1 diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/brainfuck b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/brainfuck new file mode 100644 index 0000000..87cc69f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/brainfuck @@ -0,0 +1,5 @@ +[ + This is a sample + comment. +] +.[>+<-]>, diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/brightscript b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/brightscript new file mode 100644 index 0000000..72224eb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/brightscript @@ -0,0 +1,6 @@ +function main(args as dynamic) as void + screen = CreateObject("roSGScreen") + 'Create a scene and load /components/helloworld.xml' + scene = screen.CreateScene("HelloWorld") + screen.show() +end function diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bsl b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bsl new file mode 100644 index 0000000..8a6a8d9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/bsl @@ -0,0 +1,7 @@ +#Область ПрограммныйИнтерфейс + +Процедура ПриветМир() Экспорт + Сообщить("Привет мир"); +КонецПроцедуры + +#КонецОбласти diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/c b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/c new file mode 100644 index 0000000..34771c8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/c @@ -0,0 +1,8 @@ +#include "ruby/ruby.h" + +static int +clone_method_i(st_data_t key, st_data_t value, st_data_t data) +{ + clone_method((VALUE)data, (ID)key, (const rb_method_entry_t *)value); + return ST_CONTINUE; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ceylon b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ceylon new file mode 100644 index 0000000..fcf19e0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ceylon @@ -0,0 +1,7 @@ +shared class CeylonClass<Parameter>() + given Parameter satisfies Object { + + shared String name => "CeylonClass"; +} + +shared void run() => CeylonClass(); diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cfscript b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cfscript new file mode 100644 index 0000000..b91d82d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cfscript @@ -0,0 +1,18 @@ +component accessors="true" { + + property type="string" name="firstName" default=""; + property string username; + + function init(){ + return this; + } + + public any function submitOrder( required product, coupon="", boolean results=true ){ + + var foo = function( required string baz, x=true, y=false ){ + return "bar!"; + }; + + return foo; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cisco_ios b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cisco_ios new file mode 100644 index 0000000..c4d4e69 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cisco_ios @@ -0,0 +1,19 @@ +interface FastEthernet0.20 + encapsulation dot1Q 20 + no ip route-cache + bridge-group 1 + no bridge-group 1 source-learning + bridge-group 1 spanning-disabled + +! Supports shortened versions of config words, too +inter gi0.10 +encap dot1q 10 native +inter gi0 + +banner login # Authenticate yourself! # + +! Supports #, $ and % to delimit banners, and multiline +banner motd $ +Attention! +We will be having scheduled system maintenance on this device. +$ diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/clean b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/clean new file mode 100644 index 0000000..9f947f6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/clean @@ -0,0 +1,6 @@ +delete :: !a !.(Set a) -> Set a | < a +delete x Tip = Tip +delete x (Bin _ y l r) + | x < y = balanceR y (delete x l) r + | x > y = balanceL y l (delete x r) + | otherwise = glue l r diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/clojure b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/clojure new file mode 100644 index 0000000..a9b682e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/clojure @@ -0,0 +1,5 @@ +(defn make-adder [x] + (let [y x] + (fn [z] (+ y z)))) +(def add2 (make-adder 2)) +(add2 4) diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cmake b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cmake new file mode 100644 index 0000000..89fcc51 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cmake @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.3) + +project(foo C) + +# some note +add_executable(foo utils.c "foo.c") +target_link_libraries(foo ${LIBRARIES}) diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cmhg b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cmhg new file mode 100644 index 0000000..76eeaf9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cmhg @@ -0,0 +1,8 @@ +; Header comments + +#include "definitions.h" + +command-keyword-table: command_handler + foo(min-args:0, max-args:0,; comment + international:, + invalid-syntax: "syntaxtoken" help-text: "helptoken") diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/codeowners b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/codeowners new file mode 100644 index 0000000..e4d88dc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/codeowners @@ -0,0 +1,6 @@ +# Specify a default Code Owner by using a wildcard: +* @default-codeowner + +/docs/ @all-docs + +[Development] @dev-team diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/coffeescript b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/coffeescript new file mode 100644 index 0000000..a562db6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/coffeescript @@ -0,0 +1,5 @@ +# Objects: +math = + root: Math.sqrt + square: square + cube: (x) -> x * square x diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/common_lisp b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/common_lisp new file mode 100644 index 0000000..c6d2861 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/common_lisp @@ -0,0 +1 @@ +(defun square (x) (* x x)) diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/conf b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/conf new file mode 100644 index 0000000..5386d4e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/conf @@ -0,0 +1,4 @@ +# A generic configuration file +option1 "val1" +option2 23 +option3 'val3' diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/console b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/console new file mode 100644 index 0000000..9d6ed1c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/console @@ -0,0 +1,6 @@ +# prints "hello, world" to the screen +~# echo Hello, World +Hello, World + +# don't run this +~# rm -rf --no-preserve-root / diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/coq b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/coq new file mode 100644 index 0000000..eadd44a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/coq @@ -0,0 +1,16 @@ +Require Import Coq.Lists.List. + +Section with_T. + Context {T : Type}. + + Fixpoint length (ls : list T) : nat := + match ls with + | nil => 0 + | _ :: ls => S (length ls) + end. +End with_T. + +Definition a_string := "hello +world". +Definition escape_string := "0123". +Definition zero_string := "0". diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cpp b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cpp new file mode 100644 index 0000000..c20cf27 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cpp @@ -0,0 +1,8 @@ +#include<iostream> + +using namespace std; + +int main() +{ + cout << "Hello World" << endl; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/crystal b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/crystal new file mode 100644 index 0000000..988753e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/crystal @@ -0,0 +1,45 @@ +lib LibC + WNOHANG = 0x00000001 + + @[ReturnsTwice] + fun fork : PidT + fun getpgid(pid : PidT) : PidT + fun kill(pid : PidT, signal : Int) : Int + fun getpid : PidT + fun getppid : PidT + fun exit(status : Int) : NoReturn + + ifdef x86_64 + alias ClockT = UInt64 + else + alias ClockT = UInt32 + end + + SC_CLK_TCK = 3 + + struct Tms + utime : ClockT + stime : ClockT + cutime : ClockT + cstime : ClockT + end + + fun times(buffer : Tms*) : ClockT + fun sysconf(name : Int) : Long +end + +class Process + def self.exit(status = 0) + LibC.exit(status) + end + + def self.pid + LibC.getpid + end + + def self.getpgid(pid : Int32) + ret = LibC.getpgid(pid) + raise Errno.new(ret) if ret < 0 + ret + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/csharp b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/csharp new file mode 100644 index 0000000..04e4a8e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/csharp @@ -0,0 +1,5 @@ +// reverse byte order (16-bit) +public static UInt16 ReverseBytes(UInt16 value) +{ + return (UInt16)((value & 0xFFU) << 8 | (value & 0xFF00U) >> 8); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/css b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/css new file mode 100644 index 0000000..0d1fe74 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/css @@ -0,0 +1,4 @@ +body { + font-size: 12pt; + background: #fff url(temp.png) top left no-repeat; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/csvs b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/csvs new file mode 100644 index 0000000..6112b7c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/csvs @@ -0,0 +1,8 @@ +version 1.1 +@totalColumns 5 +@separator ',' +Transaction_Date: xDate +Transaction_ID: notEmpty +Originator_Name: notEmpty +Originator_Address: any("yes","no") +Originator_Country: notEmpty diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cuda b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cuda new file mode 100644 index 0000000..6f9fa56 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cuda @@ -0,0 +1,11 @@ +#include <cstdio> + +__global__ void helloFromGPU() { + std::printf("Hello World\n"); + __syncthreads(); +} + +int main() { + dim3 block(1, 10); + helloFromGPU<<<1, block>>>(); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cypher b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cypher new file mode 100644 index 0000000..098df7c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cypher @@ -0,0 +1,5 @@ +// Cypher Mode for Rouge +CREATE (john:Person {name: 'John'}) +MATCH (user)-[:friend]->(follower) +WHERE user.name IN ['Joe', 'John', 'Sara', 'Maria', 'Steve'] AND follower.name =~ 'S.*' +RETURN user.name, follower.name diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cython b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cython new file mode 100644 index 0000000..be57661 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/cython @@ -0,0 +1,6 @@ +cdef extern from 'foo.h': + int foo_int + struct foo_struct: + pass + +ctypedef int word diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/d b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/d new file mode 100644 index 0000000..65d4945 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/d @@ -0,0 +1,16 @@ +import std.algorithm, std.conv, std.functional, + std.math, std.regex, std.stdio; + +alias round = pipe!(to!real, std.math.round, to!string); +static reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`; + +void main() +{ + // Replace anything that looks like a real + // number with the rounded equivalent. + stdin + .byLine + .map!(l => l.replaceAll!(c => c.hit.round) + (reFloatingPoint)) + .each!writeln; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dafny b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dafny new file mode 100644 index 0000000..66415a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dafny @@ -0,0 +1,16 @@ +module A { + const i: int := 56_78 +} + +method m(b: bool, s: string) { + var x: string; + var i: int; + if b then i := 1; else i := 2; + i := if b 1 else 2; + assert b; + assume b; + print s; + expect b; +} + +function f(i: int): int { i + 1 } diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dart b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dart new file mode 100644 index 0000000..4b40da5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dart @@ -0,0 +1,6 @@ +void main() { + var collection=[1,2,3,4,5]; + for(var a in collection){ + print(a); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/datastudio b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/datastudio new file mode 100644 index 0000000..17db7a5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/datastudio @@ -0,0 +1,20 @@ + +Get_Variable("EUSER","ENV","USERNAME"); + +Message("Le Login Windows est : %EUSER%"); + +Get_Variable("st","JOB","FOLDER1.date_err.SYSTEM.STATUS"); + + +AFFECT("filter1", '%%/"t"'); +AFFECT("filter2", '%%/"pi"'); +JSONTOSQL("%{jsonpath}%/file.json", "", + " JSONPATH like '%filter1%' ", "a = JSONVALUE", + " JSONPATH like '%filter2%' ", "b = JSONVALUE; output(json_data, a, b)"); + + +Affect(VAR1,'%TEST%'); //Créer et affecter la variable VAR1 avec une chaîne +select * from TABLE1 where COL1 like %VAR1%; //utiliser la variable VAR1 dans une requête + +select * from TEST_TABLE; //exécution d'une requête Select pour ramener des valeurs +Affect_LastColumns("TEST1"); //création du paramètre TEST1 diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/diff b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/diff new file mode 100644 index 0000000..ab4f316 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/diff @@ -0,0 +1,7 @@ +--- file1 2012-10-16 15:07:58.086886874 +0100 ++++ file2 2012-10-16 15:08:07.642887236 +0100 +@@ -1,3 +1,3 @@ + a b c +-d e f ++D E F + g h i diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/digdag b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/digdag new file mode 100644 index 0000000..f7dbad0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/digdag @@ -0,0 +1,19 @@ +# this is digdag task definitions +timezone: UTC + ++setup: + echo>: start ${session_time} + ++disp_current_date: + echo>: ${moment(session_time).utc().format('YYYY-MM-DD HH:mm:ss Z')} + ++repeat: + for_each>: + order: [first, second, third] + animal: [dog, cat] + _do: + echo>: ${order} ${animal} + _parallel: true + ++teardown: + echo>: finish ${session_time} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/docker b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/docker new file mode 100644 index 0000000..656d2bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/docker @@ -0,0 +1,9 @@ +maintainer First O'Last + +run echo \ + 123 $bar +# comment +onbuild add . /app/src +onbuild run echo \ + 123 $bar +CMD /bin/bash diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dot b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dot new file mode 100644 index 0000000..243ee73 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/dot @@ -0,0 +1,5 @@ +// The graph name and the semicolons are optional +graph G { + a -- b -- c; + b -- d; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ecl b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ecl new file mode 100644 index 0000000..b63b320 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ecl @@ -0,0 +1,17 @@ +/* + Example code - use without restriction. +*/ +Layout_Person := RECORD + UNSIGNED1 PersonID; + STRING15 FirstName; + STRING25 LastName; +END; + +allPeople := DATASET([ {1,'Fred','Smith'}, + {2,'Joe','Blow'}, + {3,'Jane','Smith'}],Layout_Person); + +somePeople := allPeople(LastName = 'Smith'); + +// Outputs --- +somePeople; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/eex b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/eex new file mode 100644 index 0000000..1f922b6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/eex @@ -0,0 +1 @@ +<title><%= @title %> diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/eiffel b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/eiffel new file mode 100644 index 0000000..ec025cc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/eiffel @@ -0,0 +1,30 @@ +note + description: "Represents a person." + +class + PERSON + +create + make, make_unknown + +feature {NONE} -- Creation + + make (a_name: like name) + -- Create a person with `a_name' as `name'. + do + name := a_name + ensure + name = a_name + end + + make_unknown + do ensure + name = Void + end + +feature -- Access + + name: detachable STRING + -- Full name or Void if unknown. + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/elixir b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/elixir new file mode 100644 index 0000000..f81d641 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/elixir @@ -0,0 +1 @@ +Enum.map([1,2,3], fn(x) -> x * 2 end) diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/elm b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/elm new file mode 100644 index 0000000..8d38380 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/elm @@ -0,0 +1,4 @@ +import Html exposing (text) + +main = + text "Hello, World!" diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/email b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/email new file mode 100644 index 0000000..b355729 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/email @@ -0,0 +1,11 @@ +From: Me +To: You +Date: Tue, 21 Jul 2020 15:14:03 +0000 +Subject: A very important message + +> Please investigate. Thank you. + +I have investigated. + +-- +This message is highly confidential and will self-destruct. diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/epp b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/epp new file mode 100644 index 0000000..e8decec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/epp @@ -0,0 +1,4 @@ +<%- | + Optional[String] $title, +| -%> +<%= $title %> diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/erb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/erb new file mode 100644 index 0000000..1f922b6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/erb @@ -0,0 +1 @@ +<%= @title %> diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/erlang b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/erlang new file mode 100644 index 0000000..4c3cb99 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/erlang @@ -0,0 +1,7 @@ +%%% Geometry module. +-module(geometry). +-export([area/1]). + +%% Compute rectangle and circle area. +area({rectangle, Width, Ht}) -> Width * Ht; +area({circle, R}) -> 3.14159 * R * R. diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/escape b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/escape new file mode 100644 index 0000000..b71d6b3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/escape @@ -0,0 +1,3 @@ +If Formatter.enable_escape! is called, this allows escaping into html +or the parent format with a special delimiter. For example: +!>underlined text!!> diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/factor b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/factor new file mode 100644 index 0000000..2538dff --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/factor @@ -0,0 +1,5 @@ +USING: io kernel sequences ; + +4 iota [ + "Happy Birthday " write 2 = "dear NAME" "to You" ? print +] each diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fluent b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fluent new file mode 100644 index 0000000..2e7ac8f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fluent @@ -0,0 +1,13 @@ +# Simple things are simple. +hello-user = Hello, {$userName}! + +# Complex things are possible. +shared-photos = + {$userName} {$photoCount -> + [one] added a new photo + *[other] added {$photoCount} new photos + } to {$userGender -> + [male] his stream + [female] her stream + *[other] their stream + }. diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fortran b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fortran new file mode 100644 index 0000000..4fc52c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fortran @@ -0,0 +1,22 @@ +program bottles + + implicit none + integer :: nbottles + + do nbottles = 99, 1, -1 + call print_bottles(nbottles) + end do + +contains + + subroutine print_bottles(n) + implicit none + integer, intent(in) :: n + + write(*, "(I0, 1X, 'bottles of beer on the wall,')") n + write(*, "(I0, 1X, 'bottles of beer.')") n + write(*, "('Take one down, pass it around,')") + write(*, "(I0, 1X, 'bottles of beer on the wall.', /)") n - 1 + end subroutine print_bottles + +end program bottles diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/freefem b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/freefem new file mode 100644 index 0000000..9205675 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/freefem @@ -0,0 +1,16 @@ +include "MUMPS" + +// Parameters +func f = 1.; + +// Mesh +int nn = 25; //Mesh quality +mesh Th = square(nn, nn); + +// Fespace +func Pk = P2; +fespace Uh(Th, Pk); +Uh u; + +// Plot +plot(u, nbiso=30, fill=true, value=true, cmm="A"); diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fsharp b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fsharp new file mode 100644 index 0000000..2e58e03 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/fsharp @@ -0,0 +1,12 @@ +(* Binary tree with leaves car­rying an integer. *) +type Tree = Leaf of int | Node of Tree * Tree + +let rec existsLeaf test tree = + match tree with + | Leaf v -> test v + | Node (left, right) -> + existsLeaf test left + || existsLeaf test right + +let hasEvenLeaf tree = + existsLeaf (fun n -> n % 2 = 0) tree diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/gdscript b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/gdscript new file mode 100644 index 0000000..72ba52c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/gdscript @@ -0,0 +1,18 @@ +extends Node + +# Variables & Built-in Types + +var a = 5 +var b = true +var s = "Hello" +var arr = [1, 2, 3] + +# Constants & Enums + +const ANSWER = 42 +enum { UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALLY } + +# Functions + +func _ready(): + print("Hello, World") diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ghc-cmm b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ghc-cmm new file mode 100644 index 0000000..72b764e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ghc-cmm @@ -0,0 +1,23 @@ +[lvl_s4t3_entry() // [R1] + { info_tbls: [(c4uB, + label: lvl_s4t3_info + rep: HeapRep 1 ptrs { Thunk } + srt: Nothing)] + stack_info: arg_space: 8 updfr_space: Just 8 + } + {offset + c4uB: // global + if ((Sp + -32) < SpLim) (likely: False) goto c4uC; else goto c4uD; + c4uC: // global + R1 = R1; + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; + c4uD: // global + I64[Sp - 16] = stg_upd_frame_info; + P64[Sp - 8] = R1; + R2 = P64[R1 + 16]; + I64[Sp - 32] = stg_ap_p_info; + P64[Sp - 24] = Main.fib3_closure+1; + Sp = Sp - 32; + call GHC.Num.fromInteger_info(R2) args: 40, res: 0, upd: 24; + } + } diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ghc-core b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ghc-core new file mode 100644 index 0000000..a421f79 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ghc-core @@ -0,0 +1,26 @@ +Rec { +-- RHS size: {terms: 24, types: 3, coercions: 0, joins: 0/0} +Main.fib_fib [Occ=LoopBreaker] :: Integer -> Integer +[GblId, Arity=1, Str=, Unf=OtherCon []] +Main.fib_fib + = \ (ds_d2OU :: Integer) -> + case integer-gmp-1.0.2.0:GHC.Integer.Type.eqInteger# + ds_d2OU Main.fib1 + of { + __DEFAULT -> + case integer-gmp-1.0.2.0:GHC.Integer.Type.eqInteger# + ds_d2OU Main.fib3 + of { + __DEFAULT -> + integer-gmp-1.0.2.0:GHC.Integer.Type.plusInteger + (Main.fib_fib + (integer-gmp-1.0.2.0:GHC.Integer.Type.minusInteger + ds_d2OU Main.fib3)) + (Main.fib_fib + (integer-gmp-1.0.2.0:GHC.Integer.Type.minusInteger + ds_d2OU Main.fib2)); + 1# -> Main.fib3 + }; + 1# -> Main.fib1 + } +end Rec } diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/gherkin b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/gherkin new file mode 100644 index 0000000..78e4ba6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/gherkin @@ -0,0 +1,17 @@ +# language: en +Feature: Addition + In order to avoid silly mistakes + As someone who has trouble with mental math + I want to be told the sum of two numbers + + Scenario Outline: Add two numbers + Given I have entered into the calculator + And I have entered into the calculator + When I press + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/rml b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/rml new file mode 100644 index 0000000..5a09810 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/rml @@ -0,0 +1,33 @@ +// A system agnostic domain specific language for runtime monitoring and verification +// Basic events + +insert(index,elem) matches {event:'func_pre',name:'my_insert',args:[index,elem]}; + +relevant matches insert(_,_)|remove(_,_)|size(_)|get(_,_); + +insert_in_bounds(size) matches insert(index,_) with index >= 0 && index <= size; + +del_false matches del(_,false); +not_add_true_del(el) not matches add(el,true) | del(el,_); + +Main = relevant >> (CheckIndex<0> /\ add_rm_get >> CheckElem)!; +CheckIndex = + get_size(size)* (insert_in_bounds(size) CheckIndex \/ remove_in_bounds(size) CheckIndex); + +Msg = if(inf<=sup) msg(inf) Msg else empty; +Main=relevant>>Msg<1,4>*!; + +acquire(id) matches {event:'func_pre',name:'acquire',args:[_,id,...]}; + +Main = relevant >> Resources; +Resources = + {let id; acquire(id) + ((Resources | use(id)* release(id)) /\ + acqRel(id) >> release(id) all) + }?; + +msg(ty) matches {event:'func_pre',name:'msg',args:[ty]}; +relevant matches msg(_); + +Msg = if(inf<=sup) msg(inf) Msg else empty; +Main=relevant>>Msg<1,4>*!; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/robot_framework b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/robot_framework new file mode 100644 index 0000000..3ba3fdc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/robot_framework @@ -0,0 +1,27 @@ +*** Settings *** +Document Example taken from http://robotframework.org/ +Suite Setup Open Browser To Login Page +Suite Teardown Close Browser +Test Setup Go To Login Page +Test Template Login With Invalid Credentials Should Fail +Resource resource.txt + +*** Test Cases *** User Name Password +Invalid Username invalid ${VALID PASSWORD} +Invalid Password ${VALID USER} invalid +Invalid Username And Password invalid whatever +Empty Username ${EMPTY} ${VALID PASSWORD} +Empty Password ${VALID USER} ${EMPTY} +Empty Username And Password ${EMPTY} ${EMPTY} + +*** Keywords *** +Login With Invalid Credentials Should Fail + [Arguments] ${username} ${password} + Input Username ${username} + Input Password ${password} + Submit Credentials + Login Should Have Failed + +Login Should Have Failed + Location Should Be ${ERROR URL} + Title Should Be Error Page diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ruby b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ruby new file mode 100644 index 0000000..be609a1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ruby @@ -0,0 +1,9 @@ +class Greeter + def initialize(name="World") + @name = name + end + + def say_hi + puts "Hi #{@name}!" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/rust b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/rust new file mode 100644 index 0000000..b73b162 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/rust @@ -0,0 +1,12 @@ +use core::*; + +fn main() { + for ["Alice", "Bob", "Carol"].each |&name| { + do task::spawn { + let v = rand::Rng().shuffle([1, 2, 3]); + for v.each |&num| { + io::print(fmt!("%s says: '%d'\n", name, num)) + } + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sas b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sas new file mode 100644 index 0000000..1eee876 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sas @@ -0,0 +1,13 @@ +data sim; + do i = 1 to 100; + x1 = rand("Normal"); + x2 = rand("Binomial", 0.5, 100); + output; + end; +run; + +proc means data=sashelp.class; + class sex; + var height weight; + output out = mean_by_sex; +run; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sass b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sass new file mode 100644 index 0000000..1e768de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sass @@ -0,0 +1,3 @@ +@for $i from 1 through 3 + .item-#{$i} + width: 2em * $i diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scala b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scala new file mode 100644 index 0000000..75f19ee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scala @@ -0,0 +1,3 @@ +class Greeter(name: String = "World") { + def sayHi() { println("Hi " + name + "!") } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scheme b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scheme new file mode 100644 index 0000000..c9c4dbd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scheme @@ -0,0 +1,4 @@ +(define Y + (lambda (m) + ((lambda (f) (m (lambda (a) ((f f) a)))) + (lambda (f) (m (lambda (a) ((f f) a))))))) diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scss b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scss new file mode 100644 index 0000000..3f259a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/scss @@ -0,0 +1,5 @@ +@for $i from 1 through 3 { + .item-#{$i} { + width: 2em * $i; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sed b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sed new file mode 100644 index 0000000..4683cd3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sed @@ -0,0 +1,4 @@ +/begin/,/end/ { + /begin/n # skip over the line that has "begin" on it + s/old/new/ +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/shell b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/shell new file mode 100644 index 0000000..f01fe48 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/shell @@ -0,0 +1,2 @@ +# If not running interactively, don't do anything +[[ -z "$PS1" ]] && return diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sieve b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sieve new file mode 100644 index 0000000..5f6889d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sieve @@ -0,0 +1,10 @@ +require "fileinto"; +require "imap4flags"; + +if header :is "X-Spam" "Yes" { + fileinto "Junk"; + setflag "\\seen"; + stop; +} + +/* Other messages get filed into Inbox or to user's scripts */ diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/slice b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/slice new file mode 100644 index 0000000..7c38220 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/slice @@ -0,0 +1,10 @@ +// Printer.ice +module Demo +{ + interface Printer + { + // A client can invoke this operation on a server. + // In this example we print the string s + void printString(string s); + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/slim b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/slim new file mode 100644 index 0000000..215a4e2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/slim @@ -0,0 +1,17 @@ +doctype html +html + body + h1 Markup examples + #content + p + | Slim can have #{ruby_code} interpolated! + /[if IE] + javascript: + alert('Slim supports embedded javascript!') + + - unless items.empty? + table + - for item in items do + tr + td.name = item.name + td.price = item.price diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/smalltalk b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/smalltalk new file mode 100644 index 0000000..af97161 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/smalltalk @@ -0,0 +1,6 @@ +quadMultiply: i1 and: i2 + "This method multiplies the given numbers by each other + and the result by 4." + | mul | + mul := i1 * i2. + ^mul * 4 diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/smarty b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/smarty new file mode 100644 index 0000000..cf36485 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/smarty @@ -0,0 +1,11 @@ +{foo bar='single quotes' baz="double quotes" test3=$test3} + +
    + {foreach from=$myvariable item=data} +
  • {$data.field}
  • + {foreachelse} +
  • No Data
  • + {/foreach} +
+ +
{$foo.bar.baz}
diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sml b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sml new file mode 100644 index 0000000..02a57d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sml @@ -0,0 +1,4 @@ +datatype shape + = Circle of loc * real (* center and radius *) + | Square of loc * real (* upper-left corner and side length; axis-aligned *) + | Triangle of loc * loc * loc (* corners *) diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sparql b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sparql new file mode 100644 index 0000000..6884bd0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sparql @@ -0,0 +1,6 @@ +SELECT ?item ?itemLabel +WHERE +{ + ?item wdt:P31 wd:Q146. + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sqf b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sqf new file mode 100644 index 0000000..9f54383 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sqf @@ -0,0 +1,14 @@ +// Creates a dot marker at the given position +#include "script_component.hpp" +params ["_pos", "_txt"]; + +if (isNil QGVAR(markerID)) then { + GVAR(markerID) = 0; +}; + +_markerstr = createMarker [QGVAR(marker) + str GVAR(markerID), _pos]; +_markerstr setMarkerShape "ICON"; +_markerstr setMarkerType "hd_dot"; +_markerstr setMarkerText _txt; + +GVAR(markerID) = GVAR(markerID) + 1; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sql b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sql new file mode 100644 index 0000000..45a7a17 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/sql @@ -0,0 +1 @@ +SELECT * FROM `users` WHERE `user`.`id` = 1 diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ssh b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ssh new file mode 100644 index 0000000..47f9cdb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ssh @@ -0,0 +1,4 @@ +Host example + Hostname example.com + User user + Port 1234 diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/stan b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/stan new file mode 100644 index 0000000..0eac821 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/stan @@ -0,0 +1,13 @@ +data { + int N; + vector[N] x; + vector[N] y; +} +parameters { + real alpha; + real beta; + real sigma; +} +model { + y ~ normal(alpha + beta * x, sigma); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/stata b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/stata new file mode 100644 index 0000000..3d2430d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/stata @@ -0,0 +1,14 @@ +* Run a series of linear regressions +sysuse auto, clear +foreach v of varlist mpg weight-turn { + regress price `v', robust +} + +regress price i.foreign +local num_obs = e(N) +global myglobal = 4 + +* Generate and manipulate variables +generate newvar1 = "string" +generate newvar2 = 34 - `num_obs' +replace newvar2 = $myglobal diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/supercollider b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/supercollider new file mode 100644 index 0000000..23a8e4b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/supercollider @@ -0,0 +1,11 @@ +// modulate a sine frequency and a noise amplitude with another sine +// whose frequency depends on the horizontal mouse pointer position +~myFunction = { + var x = SinOsc.ar(MouseX.kr(1, 100)); + SinOsc.ar(300 * x + 800, 0, 0.1) + + + PinkNoise.ar(0.1 * x + 0.1) +}; + +~myFunction.play; +"that's all, folks!".postln; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/svelte b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/svelte new file mode 100644 index 0000000..8b3bb5c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/svelte @@ -0,0 +1,29 @@ + + + + + +{#await loadSrc(src)} + loading... +{:then data} + {#each cats as { name }, i} +
  • {name}
  • + {/each} + + + {#each cats as cat (cat.id)} +
  • {cat.name}
  • + {/each} +{:catch err} + {@debug err} + {#await solveErr(err, {x: 'asdf'}) then reason}{@html reason}{/await} +{/await} + + diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/swift b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/swift new file mode 100644 index 0000000..0c54ed2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/swift @@ -0,0 +1,5 @@ +// Say hello to poeple +func sayHello(personName: String) -> String { + let greeting = "Hello, " + personName + "!" + return greeting +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/systemd b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/systemd new file mode 100644 index 0000000..e68c72e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/systemd @@ -0,0 +1,4 @@ +[Unit] +Description=Snap Daemon +Requires=snapd.socket +OnFailure=snapd.failure.service diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/syzlang b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/syzlang new file mode 100644 index 0000000..bebdb1e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/syzlang @@ -0,0 +1,15 @@ +include + +resource fd_test[fd] + +openat$test(fd const[AT_FDCWD], file ptr[in, string["/dev/test"]], flags flags[open_flags], mode const[0]) fd_test + +ioctl$TEST(fd fd_test, cmd const[TEST], arg ptr[in, test]) + +test { + number int32 + size len[data, int32] + data array[int8] +} + +_ = TEST diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/syzprog b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/syzprog new file mode 100644 index 0000000..92ef895 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/syzprog @@ -0,0 +1,8 @@ +# Source: https://github.com/google/syzkaller/blob/master/sys/linux/test/vusb_hid + +r0 = syz_usb_connect$hid(0x0, 0x36, &(0x7f0000000040)=ANY=[@ANYBLOB="12010000000018105e04da07000000000001090224000100000000090400000903000000092100000001222200090581030800000000"], 0x0) +syz_usb_control_io$hid(r0, 0x0, 0x0) +syz_usb_control_io$hid(r0, &(0x7f00000001c0)={0x24, 0x0, 0x0, &(0x7f0000000000)={0x0, 0x22, 0x22, {[@global=@item_012={0x2, 0x1, 0x9, "2313"}, @global=@item_012={0x2, 0x1, 0x0, "e53f"}, @global=@item_4={0x3, 0x1, 0x0, '\f\x00'}, @local=@item_012={0x2, 0x2, 0x2, "9000"}, @global=@item_4={0x3, 0x1, 0x0, "0900be00"}, @main=@item_4={0x3, 0x0, 0x8, '\x00'}, @local=@item_4={0x3, 0x2, 0x0, "09007a15"}, @local=@item_4={0x3, 0x2, 0x0, "5d8c3dda"}]}}, 0x0}, 0x0) +syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB') +syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB') +syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB') diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tap b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tap new file mode 100644 index 0000000..1d9bf5a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tap @@ -0,0 +1,5 @@ +ok 1 - Input file opened +not ok 2 - First line of the input valid +ok 3 - Read the rest of the file +not ok 4 - Summarized correctly # TODO Not written yet +1..4 diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tcl b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tcl new file mode 100644 index 0000000..9bbe87c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tcl @@ -0,0 +1 @@ +proc cross_sum {s} {expr [join [split $s ""] +]} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/terraform b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/terraform new file mode 100644 index 0000000..006e4f8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/terraform @@ -0,0 +1,16 @@ +resource "aws_elb" "web" { + name = "terraform-example-elb" + + # The same availability zone as our instances + availability_zones = ["${aws_instance.web.*.availability_zone}"] + + listener { + instance_port = 80 + instance_protocol = "http" + lb_port = 80 + lb_protocol = "http" + } + + # The instances are registered automatically + instances = ["${aws_instance.web.*.id}"] +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tex b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tex new file mode 100644 index 0000000..430510f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tex @@ -0,0 +1 @@ +To write \LaTeX\ you would type \verb:\LaTeX:. diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/toml b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/toml new file mode 100644 index 0000000..40c11c1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/toml @@ -0,0 +1,9 @@ +# This is a TOML document. Boom. + +title = "TOML Example" + +[owner] +name = "Tom Preston-Werner" +organization = "GitHub" +bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." +dob = 1979-05-27T07:32:00Z # First class dates? Why not? diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tsx b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tsx new file mode 100644 index 0000000..422d2a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tsx @@ -0,0 +1,17 @@ +class HelloWorld extends React.Component<{date: Date}, void> { + render() { + return ( +

    + Hello, ! + It is {this.props.date.toTimeString()} +

    + ); + } +} + +setInterval(function() { + ReactDOM.render( + , + document.getElementById('example') + ); +}, 500); diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ttcn3 b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ttcn3 new file mode 100644 index 0000000..969107d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/ttcn3 @@ -0,0 +1,6 @@ +module DNSTester { + type integer Identification( 0..65535 ); // 16-bit integer + type enumerated MessageKind {e_Question, e_Answer}; + type charstring Question; + type charstring Answer; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tulip b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tulip new file mode 100644 index 0000000..8c18ccf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/tulip @@ -0,0 +1,13 @@ +@module ref + +ref value = Ref (spawn [ ! => loop value ]) + +loop value = receive [ + .set new-value => loop new-value + p, id, .get => { send p (id, value); loop value } +] + +@object Ref pid [ + set val = .set val > send pid + get! = .get > send-wait pid +] diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/turtle b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/turtle new file mode 100644 index 0000000..8c86d0c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/turtle @@ -0,0 +1,26 @@ +@prefix xsd: +@prefix dcat: . +@prefix dcterms: . +@prefix foaf: . +@base . + +PREFIX test: +PrEfIx insensitive: + +GRAPH { + a dcat:Dataset ; + +#-----Mandatory-----# + + dcterms:title 'Test title'@cs, "Test title"@en ; + dcterms:description """Multiline + string"""@cs, '''Another + multiline string '''@en ; + +#-----Recommended-----# + dcat:contactPoint [ a foaf:Person ] ; + test:list ( 1 1.1 +1 -1 1.2E+4 "Test" "\"Quote\"" ) ; + test:datatype "2016-07-20"^^xsd:date ; + test:text """next multiline"""; + . +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/twig b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/twig new file mode 100644 index 0000000..2e5e577 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/twig @@ -0,0 +1,9 @@ +{% include 'header.html' %} + +{% for user in users %} + * {{ user.name }} +{% else %} + No users have been found. +{% endfor %} + +{% include 'footer.html' %} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/typescript b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/typescript new file mode 100644 index 0000000..134a70e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/typescript @@ -0,0 +1 @@ +$(document).ready(function() { alert('ready!'); }); diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vala b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vala new file mode 100644 index 0000000..2989be0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vala @@ -0,0 +1,8 @@ +class Demo.HelloWorld : GLib.Object +{ + public static int main (String[] args) + { + stdout.printf("Hello World\n"); + return 0; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vb new file mode 100644 index 0000000..f7e323d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vb @@ -0,0 +1,4 @@ +Private Sub Form_Load() + ' Execute a simple message box that says "Hello, World!" + MsgBox "Hello, World!" +End Sub diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vcl b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vcl new file mode 100644 index 0000000..75c8eea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vcl @@ -0,0 +1,12 @@ +vcl 4.0; + +backend server1 { + .host = "server1.example.com"; + .probe = { + .url = "/"; + .timeout = 1s; + .interval = 5s; + .window = 5; + .threshold = 3; + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/velocity b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/velocity new file mode 100644 index 0000000..845776b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/velocity @@ -0,0 +1,9 @@ +#* + There is multi-line comment. + see this text because the Velocity Templating Engine will ignore it. +*# +

    List

    +## This is a single line comment. +#if( $allProducts ) +

    not found.

    +#end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/verilog b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/verilog new file mode 100644 index 0000000..7f752c6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/verilog @@ -0,0 +1,27 @@ +/** + * Verilog Lexer + */ +module Foo( + input logic Clk_CI, + input logic Rst_RBI, + input logic A, + input logic B, + output logic C +); + logic C_DN, C_DP; + + assign C = C_DP; + + always_comb begin : proc_next_state + C_DN = A + B; + end + + // Clocked process + always_ff @(posedge Clk_CI, negedge Rst_RBI) begin + if(~Rst_RBI) begin + C_DP <= 1'b0; + end else begin + C_DP <= C_DN; + end + end +endmodule diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vhdl b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vhdl new file mode 100644 index 0000000..9355b50 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vhdl @@ -0,0 +1,23 @@ +entity toggle_demo is + port ( + clk_in : in std_logic; -- System Clock + data_q : out std_logic -- Toggling Port + ); +end entity toggle_demo; + +architecture RTL of toggle_demo is + signal data : std_logic := '0'; +begin + + data_q <= data; + + data_proc : process (clk_in) + begin + + if (rising_edge(clk_in)) then + data <= not data; + end if; + + end process; + +end architecture RTL; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/viml b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/viml new file mode 100644 index 0000000..93a364b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/viml @@ -0,0 +1,14 @@ +function! s:Make(dir, make, format, name) abort + let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd' + let cwd = getcwd() + let [mp, efm, cc] = [&l:mp, &l:efm, get(b:, 'current_compiler', '')] + try + execute cd fnameescape(dir) + let [&l:mp, &l:efm, b:current_compiler] = [a:make, a:format, a:compiler] + execute (exists(':Make') == 2 ? 'Make' : 'make') + finally + let [&l:mp, &l:efm, b:current_compiler] = [mp, efm, cc] + if empty(cc) | unlet! b:current_compiler | endif + execute cd fnameescape(cwd) + endtry +endfunction diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vue b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vue new file mode 100644 index 0000000..8b54b28 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/vue @@ -0,0 +1,11 @@ + + + diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/wollok b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/wollok new file mode 100644 index 0000000..ae467f4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/wollok @@ -0,0 +1,11 @@ +object pepita { + var energy = 100 + + method energy() = energy + + method fly(kilometers) { + energy -= kilometers + 10 + } + + method sayHi() = "Coo!" +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xml b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xml new file mode 100644 index 0000000..149844b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xml @@ -0,0 +1,2 @@ + + diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xojo b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xojo new file mode 100644 index 0000000..698a921 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xojo @@ -0,0 +1,14 @@ +Dim f As FolderItem +f = GetOpenFolderItem(FileTypes1.jpeg) // defined in the File Type Set editor +rem - we should check for nil! +If not f.Exists Then + Beep 'Just for fun + MsgBox("The file " + f.NativePath + "doesn't ""exist.""") +Else // document exists + ImageWell1.image=Picture.Open(f) +End If +if f isa folderitem then + msgbox(f.name) +end if +Exception err As NilObjectException + MsgBox("Invalid pathname!") diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xpath b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xpath new file mode 100644 index 0000000..ddc4b6a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xpath @@ -0,0 +1,2 @@ +(: Authors named Bob Joe who didn't graduate from Harvard :) +//author[first-name = "Joe" and last-name = "Bob"][degree/@from != "Harvard"] diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xquery b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xquery new file mode 100644 index 0000000..4f7b325 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/xquery @@ -0,0 +1,22 @@ +declare namespace html = "http://www.w3.org/1999/xhtml"; + +declare function local:test-function($catalog as document-node()) { + + + XQuery example for the Rouge highlighter + + + +

    List

    +
      + {for $product in $catalog/items/product[@sell-by > current-date()] return +
    • +
        +
      • {data($product/name)}
      • +
      • {$product/price * (1 + $product/tax)}$
      • +
      +
    • } +
    + + +}; diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/yaml b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/yaml new file mode 100644 index 0000000..2f622de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/yaml @@ -0,0 +1,4 @@ +--- +one: Mark McGwire +two: Sammy Sosa +three: Ken Griffey diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/yang b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/yang new file mode 100644 index 0000000..c68ff7b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/yang @@ -0,0 +1,17 @@ +module petstore { + namespace "http://autlan.dt/gribok/yang/example"; + prefix ex; + + revision 2020-04-01 { + description "Example yang"; + } + + container pets { + list dogs { + key name; + leaf name { + type string; + } + } + } +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/zig b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/zig new file mode 100644 index 0000000..8374aa4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/demos/zig @@ -0,0 +1,6 @@ +const std = @import("std"); +const warn = std.debug.warn; + +fn add_floats(x: f16, y: f16) f16 { + return x + y; +} diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatter.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatter.rb new file mode 100644 index 0000000..a953812 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatter.rb @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + # A Formatter takes a token stream and formats it for human viewing. + class Formatter + # @private + REGISTRY = {} + + # Specify or get the unique tag for this formatter. This is used + # for specifying a formatter in `rougify`. + def self.tag(tag=nil) + return @tag unless tag + REGISTRY[tag] = self + + @tag = tag + end + + # Find a formatter class given a unique tag. + def self.find(tag) + REGISTRY[tag] + end + + def self.with_escape + Thread.current[:'rouge/with-escape'] = true + yield + ensure + Thread.current[:'rouge/with-escape'] = false + end + + def self.escape_enabled? + !!(((defined? @escape_enabled) && @escape_enabled) || Thread.current[:'rouge/with-escape']) + end + + def self.enable_escape! + @escape_enabled = true + end + + def self.disable_escape! + @escape_enabled = false + Thread.current[:'rouge/with-escape'] = false + end + + # Format a token stream. Delegates to {#format}. + def self.format(tokens, *args, **kwargs, &b) + new(*args, **kwargs).format(tokens, &b) + end + + def initialize(opts={}) + # pass + end + + def escape?(tok) + tok == Token::Tokens::Escape + end + + def filter_escapes(tokens) + tokens.each do |t, v| + if t == Token::Tokens::Escape + yield Token::Tokens::Error, v + else + yield t, v + end + end + end + + # Format a token stream. + def format(tokens, &b) + tokens = enum_for(:filter_escapes, tokens) unless Formatter.escape_enabled? + + return stream(tokens, &b) if block_given? + + out = String.new('') + stream(tokens) { |piece| out << piece } + + out + end + + # @deprecated Use {#format} instead. + def render(tokens) + warn 'Formatter#render is deprecated, use #format instead.' + format(tokens) + end + + # @abstract + # yield strings that, when concatenated, form the formatted output + def stream(tokens, &b) + raise 'abstract' + end + + protected + def token_lines(tokens, &b) + return enum_for(:token_lines, tokens) unless block_given? + + out = [] + tokens.each do |tok, val| + val.scan %r/\n|[^\n]+/ do |s| + if s == "\n" + yield out + out = [] + else + out << [tok, s] + end + end + end + + # for inputs not ending in a newline + yield out if out.any? + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html.rb new file mode 100644 index 0000000..643fd19 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html.rb @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + # Transforms a token stream into HTML output. + class HTML < Formatter + TABLE_FOR_ESCAPE_HTML = { + '&' => '&', + '<' => '<', + '>' => '>', + }.freeze + + ESCAPE_REGEX = /[&<>]/.freeze + + tag 'html' + + # @yield the html output. + def stream(tokens, &b) + tokens.each { |tok, val| yield span(tok, val) } + end + + def span(tok, val) + return val if escape?(tok) + + safe_span(tok, escape_special_html_chars(val)) + end + + def safe_span(tok, safe_val) + if tok == Token::Tokens::Text + safe_val + else + shortname = tok.shortname or raise "unknown token: #{tok.inspect} for #{safe_val.inspect}" + + "#{safe_val}" + end + end + + private + + # A performance-oriented helper method to escape `&`, `<` and `>` for the rendered + # HTML from this formatter. + # + # `String#gsub` will always return a new string instance irrespective of whether + # a substitution occurs. This method however invokes `String#gsub` only if + # a substitution is imminent. + # + # Returns either the given `value` argument string as is or a new string with the + # special characters replaced with their escaped counterparts. + def escape_special_html_chars(value) + return value unless value =~ ESCAPE_REGEX + + value.gsub(ESCAPE_REGEX, TABLE_FOR_ESCAPE_HTML) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_inline.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_inline.rb new file mode 100644 index 0000000..13f6e95 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_inline.rb @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + class HTMLInline < HTML + tag 'html_inline' + + def initialize(theme) + if theme.is_a?(Class) && theme < Rouge::Theme + @theme = theme.new + elsif theme.is_a?(Rouge::Theme) + @theme = theme + elsif theme.is_a?(String) + @theme = Rouge::Theme.find(theme).new + else + raise ArgumentError, "invalid theme: #{theme.inspect}" + end + end + + def safe_span(tok, safe_val) + return safe_val if tok == Token::Tokens::Text + + rules = @theme.style_for(tok).rendered_rules + + "#{safe_val}" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_legacy.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_legacy.rb new file mode 100644 index 0000000..8327564 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_legacy.rb @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# stdlib +require 'cgi' + +module Rouge + module Formatters + # Transforms a token stream into HTML output. + class HTMLLegacy < Formatter + tag 'html_legacy' + + # @option opts [String] :css_class ('highlight') + # @option opts [true/false] :line_numbers (false) + # @option opts [Rouge::CSSTheme] :inline_theme (nil) + # @option opts [true/false] :wrap (true) + # + # Initialize with options. + # + # If `:inline_theme` is given, then instead of rendering the + # tokens as tags with CSS classes, the styles according to + # the given theme will be inlined in "style" attributes. This is + # useful for formats in which stylesheets are not available. + # + # Content will be wrapped in a tag (`div` if tableized, `pre` if + # not) with the given `:css_class` unless `:wrap` is set to `false`. + def initialize(opts={}) + @formatter = opts[:inline_theme] ? HTMLInline.new(opts[:inline_theme]) + : HTML.new + + + @formatter = HTMLTable.new(@formatter, opts) if opts[:line_numbers] + + if opts.fetch(:wrap, true) + @formatter = HTMLPygments.new(@formatter, opts.fetch(:css_class, 'codehilite')) + end + end + + # @yield the html output. + def stream(tokens, &b) + @formatter.stream(tokens, &b) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_line_highlighter.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_line_highlighter.rb new file mode 100644 index 0000000..2fffec0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_line_highlighter.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + class HTMLLineHighlighter < Formatter + tag 'html_line_highlighter' + + def initialize(delegate, opts = {}) + @delegate = delegate + @highlight_line_class = opts.fetch(:highlight_line_class, 'hll') + @highlight_lines = opts[:highlight_lines] || [] + end + + def stream(tokens) + token_lines(tokens).with_index(1) do |line_tokens, lineno| + line = %(#{@delegate.format(line_tokens)}\n) + line = %(#{line}) if @highlight_lines.include? lineno + yield line + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_line_table.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_line_table.rb new file mode 100644 index 0000000..bb21584 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_line_table.rb @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + class HTMLLineTable < Formatter + tag 'html_line_table' + + # @param [Rouge::Formatters::Formatter] formatter An instance of a + # `Rouge::Formatters::HTML` or `Rouge::Formatters::HTMLInline` + # @param [Hash] opts options for HTMLLineTable instance. + # @option opts [Integer] :start_line line number to start from. Defaults to `1`. + # @option opts [String] :table_class Class name for the table. + # Defaults to `"rouge-line-table"`. + # @option opts [String] :line_id a `sprintf` template for generating an `id` + # attribute for each table row corresponding to current line number. + # Defaults to `"line-%i"`. + # @option opts [String] :line_class Class name for each table row. + # Defaults to `"lineno"`. + # @option opts [String] :gutter_class Class name for rendered line-number cell. + # Defaults to `"rouge-gutter"`. + # @option opts [String] :code_class Class name for rendered code cell. + # Defaults to `"rouge-code"`. + def initialize(formatter, opts={}) + @formatter = formatter + @start_line = opts.fetch :start_line, 1 + @table_class = opts.fetch :table_class, 'rouge-line-table' + @gutter_class = opts.fetch :gutter_class, 'rouge-gutter' + @code_class = opts.fetch :code_class, 'rouge-code' + @line_class = opts.fetch :line_class, 'lineno' + @line_id = opts.fetch :line_id, 'line-%i' + end + + def stream(tokens, &b) + buffer = [%()] + token_lines(tokens).with_index(@start_line) do |line_tokens, lineno| + buffer << %() + buffer << %() + buffer << %(" + end + buffer << %(
    ) + buffer << %(
    #{lineno}
    )
    +          @formatter.stream(line_tokens) { |formatted| buffer << formatted }
    +          buffer << "\n
    ) + yield buffer.join + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_linewise.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_linewise.rb new file mode 100644 index 0000000..dc58d91 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_linewise.rb @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + class HTMLLinewise < Formatter + def initialize(formatter, opts={}) + @formatter = formatter + @tag_name = opts.fetch(:tag_name, 'div') + @class_format = opts.fetch(:class, 'line-%i') + end + + def stream(tokens, &b) + token_lines(tokens).with_index(1) do |line_tokens, lineno| + yield %(<#{@tag_name} class="#{sprintf @class_format, lineno}">) + @formatter.stream(line_tokens) {|formatted| yield formatted } + yield %(\n) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_pygments.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_pygments.rb new file mode 100644 index 0000000..8ed8f54 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_pygments.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Rouge + module Formatters + class HTMLPygments < Formatter + def initialize(inner, css_class='codehilite') + @inner = inner + @css_class = css_class + end + + def stream(tokens, &b) + yield %(
    )
    +        @inner.stream(tokens, &b)
    +        yield "
    " + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_table.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_table.rb new file mode 100644 index 0000000..fa9a181 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/html_table.rb @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + class HTMLTable < Formatter + tag 'html_table' + + def initialize(inner, opts={}) + @inner = inner + @start_line = opts.fetch(:start_line, 1) + @line_format = opts.fetch(:line_format, '%i') + @table_class = opts.fetch(:table_class, 'rouge-table') + @gutter_class = opts.fetch(:gutter_class, 'rouge-gutter') + @code_class = opts.fetch(:code_class, 'rouge-code') + end + + def style(scope) + yield %(#{scope} .rouge-table { border-spacing: 0 }) + yield %(#{scope} .rouge-gutter { text-align: right }) + end + + def stream(tokens, &b) + last_val = nil + num_lines = tokens.reduce(0) {|count, (_, val)| count + (last_val = val).count(?\n) } + formatted = @inner.format(tokens) + unless last_val && last_val.end_with?(?\n) + num_lines += 1 + formatted << ?\n + end + + # generate a string of newline-separated line numbers for the gutter> + formatted_line_numbers = (@start_line..(@start_line + num_lines - 1)).map do |i| + sprintf(@line_format, i) + end.join(?\n) << ?\n + + buffer = [%()] + # the "gl" class applies the style for Generic.Lineno + buffer << %(' + buffer << %(' + buffer << '
    ) + buffer << %(
    #{formatted_line_numbers}
    ) + buffer << '
    )
    +        buffer << formatted
    +        buffer << '
    ' + + yield buffer.join + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/null.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/null.rb new file mode 100644 index 0000000..078c461 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/null.rb @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + # A formatter which renders nothing. + class Null < Formatter + tag 'null' + + def initialize(*) + end + + def stream(tokens, &b) + tokens.each do |tok, val| + yield "#{tok.qualname} #{val.inspect}\n" + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/terminal256.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/terminal256.rb new file mode 100644 index 0000000..140d53c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/terminal256.rb @@ -0,0 +1,198 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + # A formatter for 256-color terminals + class Terminal256 < Formatter + tag 'terminal256' + + # @private + attr_reader :theme + + # @param [Hash,Rouge::Theme] theme + # the theme to render with. + def initialize(theme = Themes::ThankfulEyes.new) + if theme.is_a?(Rouge::Theme) + @theme = theme + elsif theme.is_a?(Hash) + @theme = theme[:theme] || Themes::ThankfulEyes.new + else + raise ArgumentError, "invalid theme: #{theme.inspect}" + end + end + + def stream(tokens, &b) + tokens.each do |tok, val| + escape_sequence(tok).stream_value(val, &b) + end + end + + class EscapeSequence + attr_reader :style + def initialize(style) + @style = style + end + + def self.xterm_colors + @xterm_colors ||= [].tap do |out| + # colors 0..15: 16 basic colors + out << [0x00, 0x00, 0x00] # 0 + out << [0xcd, 0x00, 0x00] # 1 + out << [0x00, 0xcd, 0x00] # 2 + out << [0xcd, 0xcd, 0x00] # 3 + out << [0x00, 0x00, 0xee] # 4 + out << [0xcd, 0x00, 0xcd] # 5 + out << [0x00, 0xcd, 0xcd] # 6 + out << [0xe5, 0xe5, 0xe5] # 7 + out << [0x7f, 0x7f, 0x7f] # 8 + out << [0xff, 0x00, 0x00] # 9 + out << [0x00, 0xff, 0x00] # 10 + out << [0xff, 0xff, 0x00] # 11 + out << [0x5c, 0x5c, 0xff] # 12 + out << [0xff, 0x00, 0xff] # 13 + out << [0x00, 0xff, 0xff] # 14 + out << [0xff, 0xff, 0xff] # 15 + + # colors 16..232: the 6x6x6 color cube + valuerange = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff] + + 217.times do |i| + r = valuerange[(i / 36) % 6] + g = valuerange[(i / 6) % 6] + b = valuerange[i % 6] + out << [r, g, b] + end + + # colors 233..253: grayscale + 1.upto 22 do |i| + v = 8 + i * 10 + out << [v, v, v] + end + end + end + + def fg + return @fg if instance_variable_defined? :@fg + @fg = style.fg && self.class.color_index(style.fg) + end + + def bg + return @bg if instance_variable_defined? :@bg + @bg = style.bg && self.class.color_index(style.bg) + end + + + def stream_value(val, &b) + yield style_string + yield val.gsub("\e", "\\e") + .gsub("\n", "#{reset_string}\n#{style_string}") + yield reset_string + end + + def style_string + @style_string ||= begin + attrs = [] + + attrs << ['38', '5', fg.to_s] if fg + attrs << ['48', '5', bg.to_s] if bg + attrs << '01' if style[:bold] + attrs << '04' if style[:italic] # underline, but hey, whatevs + escape(attrs) + end + end + + def reset_string + @reset_string ||= begin + attrs = [] + attrs << '39' if fg # fg reset + attrs << '49' if bg # bg reset + attrs << '00' if style[:bold] || style[:italic] + + escape(attrs) + end + end + + private + def escape(attrs) + return '' if attrs.empty? + "\e[#{attrs.join(';')}m" + end + + def self.color_index(color) + @color_index_cache ||= {} + @color_index_cache[color] ||= closest_color(*get_rgb(color)) + end + + def self.get_rgb(color) + color = $1 if color =~ /#([0-9a-f]+)/i + hexes = case color.size + when 3 + color.chars.map { |c| "#{c}#{c}" } + when 6 + color.scan(/../) + else + raise "invalid color: #{color}" + end + + hexes.map { |h| h.to_i(16) } + end + + # max distance between two colors, #000000 to #ffffff + MAX_DISTANCE = 257 * 257 * 3 + + def self.closest_color(r, g, b) + @@colors_cache ||= {} + key = (r << 16) + (g << 8) + b + @@colors_cache.fetch(key) do + distance = MAX_DISTANCE + + match = 0 + + xterm_colors.each_with_index do |(cr, cg, cb), i| + d = (r - cr)**2 + (g - cg)**2 + (b - cb)**2 + next if d >= distance + + match = i + distance = d + end + + match + end + end + end + + class Unescape < EscapeSequence + def initialize(*) end + def style_string(*) '' end + def reset_string(*) '' end + def stream_value(val) yield val end + end + + # private + def escape_sequence(token) + return Unescape.new if escape?(token) + @escape_sequences ||= {} + @escape_sequences[token.qualname] ||= + make_escape_sequence(get_style(token)) + end + + def make_escape_sequence(style) + EscapeSequence.new(style) + end + + def get_style(token) + return text_style if token.ancestors.include? Token::Tokens::Text + + theme.get_own_style(token) || text_style + end + + def text_style + style = theme.get_style(Token['Text']) + # don't highlight text backgrounds + style.delete :bg + style + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/terminal_truecolor.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/terminal_truecolor.rb new file mode 100644 index 0000000..07feab0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/terminal_truecolor.rb @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true +module Rouge + module Formatters + class TerminalTruecolor < Terminal256 + tag 'terminal_truecolor' + + class TruecolorEscapeSequence < Terminal256::EscapeSequence + def style_string + @style_string ||= begin + out = String.new('') + out << escape(['48', '2', *get_rgb(style.bg)]) if style.bg + out << escape(['38', '2', *get_rgb(style.fg)]) if style.fg + out << escape(['1']) if style[:bold] || style[:italic] + out + end + end + + def get_rgb(color) + color = $1 if color =~ /#(\h+)/ + + case color.size + when 3 then color.chars.map { |c| c.to_i(16) * 2 } + when 6 then color.scan(/../).map { |cc| cc.to_i(16) } + else + raise "invalid color: #{color.inspect}" + end + end + end + + # @override + def make_escape_sequence(style) + TruecolorEscapeSequence.new(style) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/tex.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/tex.rb new file mode 100644 index 0000000..e42c2bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/formatters/tex.rb @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Formatters + class Tex < Formatter + tag 'tex' + + # A map of TeX escape characters. + # Newlines are handled specially by using #token_lines + # spaces are preserved as long as they aren't at the beginning + # of a line. see #tag_first for our initial-space strategy + ESCAPE = { + '&' => '\&', + '%' => '\%', + '$' => '\$', + '#' => '\#', + '_' => '\_', + '{' => '\{', + '}' => '\}', + '~' => '{\textasciitilde}', + '^' => '{\textasciicircum}', + '|' => '{\textbar}', + '\\' => '{\textbackslash}', + '`' => '{\textasciigrave}', + "'" => "'{}", + '"' => '"{}', + "\t" => '{\tab}', + } + + ESCAPE_REGEX = /[#{ESCAPE.keys.map(&Regexp.method(:escape)).join}]/om + + def initialize(opts={}) + @prefix = opts.fetch(:prefix) { 'RG' } + end + + def escape_tex(str) + str.gsub(ESCAPE_REGEX, ESCAPE) + end + + def stream(tokens, &b) + # surround the output with \begin{RG*}...\end{RG*} + yield "\\begin{#{@prefix}*}%\n" + + # we strip the newline off the last line to avoid + # an extra line being rendered. we do this by yielding + # the \newline tag *before* every line group except + # the first. + first = true + + token_lines tokens do |line| + if first + first = false + else + yield "\\newline%\n" + end + + render_line(line, &b) + end + + yield "%\n\\end{#{@prefix}*}%\n" + end + + def render_line(line, &b) + line.each do |(tok, val)| + hphantom_tag(tok, val, &b) + end + end + + # Special handling for leading spaces, since they may be gobbled + # by a previous command. We replace all initial spaces with + # \hphantom{xxxx}, which renders an empty space equal to the size + # of the x's. + def hphantom_tag(tok, val) + leading = nil + val.sub!(/^[ ]+/) { leading = $&.size; '' } + yield "\\hphantom{#{'x' * leading}}" if leading + yield tag(tok, val) unless val.empty? + end + + def tag(tok, val) + if escape?(tok) + val + elsif tok == Token::Tokens::Text + escape_tex(val) + else + "\\#@prefix{#{tok.shortname}}{#{escape_tex(val)}}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guesser.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guesser.rb new file mode 100644 index 0000000..7cfc3e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guesser.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Rouge + class Guesser + class Ambiguous < StandardError + attr_reader :alternatives + def initialize(alternatives); @alternatives = alternatives; end + + def message + "Ambiguous guess: can't decide between #{alternatives.map(&:tag).inspect}" + end + end + + def self.guess(guessers, lexers) + original_size = lexers.size + + guessers.each do |g| + new_lexers = case g + when Guesser then g.filter(lexers) + when proc { |x| x.respond_to? :call } then g.call(lexers) + else raise "bad guesser: #{g}" + end + + lexers = new_lexers && new_lexers.any? ? new_lexers : lexers + end + + # if we haven't filtered the input at *all*, + # then we have no idea what language it is, + # so we bail and return []. + lexers.size < original_size ? lexers : [] + end + + def collect_best(lexers, opts={}, &scorer) + best = [] + best_score = opts[:threshold] + + lexers.each do |lexer| + score = scorer.call(lexer) + + next if score.nil? + + if best_score.nil? || score > best_score + best_score = score + best = [lexer] + elsif score == best_score + best << lexer + end + end + + best + end + + def filter(lexers) + raise 'abstract' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/disambiguation.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/disambiguation.rb new file mode 100644 index 0000000..e3031f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/disambiguation.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true + +module Rouge + module Guessers + class Disambiguation < Guesser + include Util + include Lexers + + def initialize(filename, source) + @filename = File.basename(filename) + @source = source + end + + def filter(lexers) + return lexers if lexers.size == 1 + return lexers if lexers.size == Lexer.all.size + + @analyzer = TextAnalyzer.new(get_source(@source)) + + self.class.disambiguators.each do |disambiguator| + next unless disambiguator.match?(@filename) + + filtered = disambiguator.decide!(self) + return filtered if filtered + end + + return lexers + end + + def contains?(text) + return @analyzer.include?(text) + end + + def matches?(re) + return !!(@analyzer =~ re) + end + + @disambiguators = [] + def self.disambiguate(*patterns, &decider) + @disambiguators << Disambiguator.new(patterns, &decider) + end + + def self.disambiguators + @disambiguators + end + + class Disambiguator + include Util + + def initialize(patterns, &decider) + @patterns = patterns + @decider = decider + end + + def decide!(guesser) + out = guesser.instance_eval(&@decider) + case out + when Array then out + when nil then nil + else [out] + end + end + + def match?(filename) + @patterns.any? { |p| test_glob(p, filename) } + end + end + + disambiguate '*.pl' do + next Perl if contains?('my $') + next Prolog if contains?(':-') + next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./) + end + + disambiguate '*.h' do + next ObjectiveC if matches?(/@(end|implementation|protocol|property)\b/) + next ObjectiveC if contains?('@"') + next Cpp if matches?(/^\s*(?:catch|class|constexpr|namespace|private| + protected|public|template|throw|try|using)\b/x) + + C + end + + disambiguate '*.m' do + next ObjectiveC if matches?(/@(end|implementation|protocol|property)\b/) + next ObjectiveC if contains?('@"') + + next Mathematica if contains?('(*') + next Mathematica if contains?(':=') + + next Mason if matches?(/<%(def|method|text|doc|args|flags|attr|init|once|shared|perl|cleanup|filter)([^>]*)(>)/) + + next Matlab if matches?(/^\s*?%/) + + next Mason if matches? %r!( lexer name mappings + class GlobMapping < Guesser + include Util + + def self.by_pairs(mapping, filename) + glob_map = {} + mapping.each do |(glob, lexer_name)| + lexer = Lexer.find(lexer_name) + + # ignore unknown lexers + next unless lexer + + glob_map[lexer.name] ||= [] + glob_map[lexer.name] << glob + end + + new(glob_map, filename) + end + + attr_reader :glob_map, :filename + def initialize(glob_map, filename) + @glob_map = glob_map + @filename = filename + end + + def filter(lexers) + basename = File.basename(filename) + + collect_best(lexers) do |lexer| + (@glob_map[lexer.name] || []).map do |pattern| + if test_glob(pattern, basename) + # specificity is better the fewer wildcards there are + -pattern.scan(/[*?\[]/).size + end + end.compact.min + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/mimetype.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/mimetype.rb new file mode 100644 index 0000000..92a1d43 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/mimetype.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Rouge + module Guessers + class Mimetype < Guesser + attr_reader :mimetype + def initialize(mimetype) + @mimetype = mimetype + end + + def filter(lexers) + lexers.select { |lexer| lexer.mimetypes.include? @mimetype } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/modeline.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/modeline.rb new file mode 100644 index 0000000..9754798 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/modeline.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Rouge + module Guessers + class Modeline < Guesser + include Util + + # [jneen] regexen stolen from linguist + EMACS_MODELINE = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i + + # First form vim modeline + # [text]{white}{vi:|vim:|ex:}[white]{options} + # ex: 'vim: syntax=ruby' + VIM_MODELINE_1 = /(?:vim|vi|ex):\s*(?:ft|filetype|syntax)=(\w+)\s?/i + + # Second form vim modeline (compatible with some versions of Vi) + # [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text] + # ex: 'vim set syntax=ruby:' + VIM_MODELINE_2 = /(?:vim|vi|Vim|ex):\s*se(?:t)?.*\s(?:ft|filetype|syntax)=(\w+)\s?.*:/i + + MODELINES = [EMACS_MODELINE, VIM_MODELINE_1, VIM_MODELINE_2] + + def initialize(source, opts={}) + @source = source + @lines = opts[:lines] || 5 + end + + def filter(lexers) + # don't bother reading the stream if we've already decided + return lexers if lexers.size == 1 + + source_text = get_source(@source) + + lines = source_text.split(/\n/) + + search_space = (lines.first(@lines) + lines.last(@lines)).join("\n") + + matches = MODELINES.map { |re| re.match(search_space) }.compact + return lexers unless matches.any? + + match_set = Set.new(matches.map { |m| m[1] }) + lexers.select { |l| match_set.include?(l.tag) || l.aliases.any? { |a| match_set.include?(a) } } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/source.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/source.rb new file mode 100644 index 0000000..90a51cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/source.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Rouge + module Guessers + class Source < Guesser + include Util + + attr_reader :source + def initialize(source) + @source = source + end + + def filter(lexers) + # don't bother reading the input if + # we've already filtered to 1 + return lexers if lexers.size == 1 + + source_text = get_source(@source) + + Lexer.assert_utf8!(source_text) + + source_text = TextAnalyzer.new(source_text) + + collect_best(lexers) do |lexer| + next unless lexer.detectable? + lexer.detect?(source_text) ? 1 : nil + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/util.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/util.rb new file mode 100644 index 0000000..89c50be --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/guessers/util.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Rouge + module Guessers + module Util + module SourceNormalizer + UTF8_BOM = "\xEF\xBB\xBF" + UTF8_BOM_RE = /\A#{UTF8_BOM}/ + + # @param [String,nil] source + # @return [String,nil] + def self.normalize(source) + source.sub(UTF8_BOM_RE, '').gsub(/\r\n/, "\n") + end + end + + def test_glob(pattern, path) + File.fnmatch?(pattern, path, File::FNM_DOTMATCH | File::FNM_CASEFOLD) + end + + # @param [String,IO] source + # @return [String] + def get_source(source) + if source.respond_to?(:to_str) + SourceNormalizer.normalize(source.to_str) + elsif source.respond_to?(:read) + SourceNormalizer.normalize(source.read) + else + raise ArgumentError, "Invalid source: #{source.inspect}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexer.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexer.rb new file mode 100644 index 0000000..0e7f7b1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexer.rb @@ -0,0 +1,535 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# stdlib +require 'strscan' +require 'cgi' +require 'set' + +module Rouge + # @abstract + # A lexer transforms text into a stream of `[token, chunk]` pairs. + class Lexer + include Token::Tokens + + @option_docs = {} + + class << self + # Lexes `stream` with the given options. The lex is delegated to a + # new instance. + # + # @see #lex + def lex(stream, opts={}, &b) + new(opts).lex(stream, &b) + end + + # In case #continue_lex is called statically, we simply + # begin a new lex from the beginning, since there is no state. + # + # @see #continue_lex + def continue_lex(*a, &b) + lex(*a, &b) + end + + # Given a name in string, return the correct lexer class. + # @param [String] name + # @return [Class,nil] + def find(name) + registry[name.to_s] + end + + # Same as ::find_fancy, except instead of returning an instantiated + # lexer, returns a pair of [lexer_class, options], so that you can + # modify or provide additional options to the lexer. + # + # Please note: the lexer class might be nil! + def lookup_fancy(str, code=nil, default_options={}) + if str && !str.include?('?') && str != 'guess' + lexer_class = find(str) + return [lexer_class, default_options] + end + + name, opts = str ? str.split('?', 2) : [nil, ''] + + # parse the options hash from a cgi-style string + opts = CGI.parse(opts || '').map do |k, vals| + val = case vals.size + when 0 then true + when 1 then vals[0] + else vals + end + + [ k.to_s, val ] + end + + opts = default_options.merge(Hash[opts]) + + lexer_class = case name + when 'guess', nil + self.guess(:source => code, :mimetype => opts['mimetype']) + when String + self.find(name) + end + + [lexer_class, opts] + end + + # Find a lexer, with fancy shiny features. + # + # * The string you pass can include CGI-style options + # + # Lexer.find_fancy('erb?parent=tex') + # + # * You can pass the special name 'guess' so we guess for you, + # and you can pass a second argument of the code to guess by + # + # Lexer.find_fancy('guess', "#!/bin/bash\necho Hello, world") + # + # If the code matches more than one lexer then Guesser::Ambiguous + # is raised. + # + # This is used in the Redcarpet plugin as well as Rouge's own + # markdown lexer for highlighting internal code blocks. + # + def find_fancy(str, code=nil, default_options={}) + lexer_class, opts = lookup_fancy(str, code, default_options) + + lexer_class && lexer_class.new(opts) + end + + # Specify or get this lexer's title. Meant to be human-readable. + def title(t=nil) + if t.nil? + t = tag.capitalize + end + @title ||= t + end + + # Specify or get this lexer's description. + def desc(arg=:absent) + if arg == :absent + @desc + else + @desc = arg + end + end + + def option_docs + @option_docs ||= InheritableHash.new(superclass.option_docs) + end + + def option(name, desc) + option_docs[name.to_s] = desc + end + + # Specify or get the path name containing a small demo for + # this lexer (can be overriden by {demo}). + def demo_file(arg=:absent) + return @demo_file = Pathname.new(arg) unless arg == :absent + + @demo_file = Pathname.new(File.join(__dir__, 'demos', tag)) + end + + # Specify or get a small demo string for this lexer + def demo(arg=:absent) + return @demo = arg unless arg == :absent + + @demo = File.read(demo_file, mode: 'rt:bom|utf-8') + end + + # @return a list of all lexers. + def all + @all ||= registry.values.uniq + end + + # Guess which lexer to use based on a hash of info. + # + # This accepts the same arguments as Lexer.guess, but will never throw + # an error. It will return a (possibly empty) list of potential lexers + # to use. + def guesses(info={}) + mimetype, filename, source = info.values_at(:mimetype, :filename, :source) + custom_globs = info[:custom_globs] + + guessers = (info[:guessers] || []).dup + + guessers << Guessers::Mimetype.new(mimetype) if mimetype + guessers << Guessers::GlobMapping.by_pairs(custom_globs, filename) if custom_globs && filename + guessers << Guessers::Filename.new(filename) if filename + guessers << Guessers::Modeline.new(source) if source + guessers << Guessers::Source.new(source) if source + guessers << Guessers::Disambiguation.new(filename, source) if source && filename + + Guesser.guess(guessers, Lexer.all) + end + + # Guess which lexer to use based on a hash of info. + # + # @option info :mimetype + # A mimetype to guess by + # @option info :filename + # A filename to guess by + # @option info :source + # The source itself, which, if guessing by mimetype or filename + # fails, will be searched for shebangs, tags, and + # other hints. + # @param [Proc] fallback called if multiple lexers are detected. + # If omitted, Guesser::Ambiguous is raised. + # + # @see Lexer.detect? + # @see Lexer.guesses + # @return [Class] + def guess(info={}, &fallback) + lexers = guesses(info) + + return Lexers::PlainText if lexers.empty? + return lexers[0] if lexers.size == 1 + + if fallback + fallback.call(lexers) + else + raise Guesser::Ambiguous.new(lexers) + end + end + + def guess_by_mimetype(mt) + guess :mimetype => mt + end + + def guess_by_filename(fname) + guess :filename => fname + end + + def guess_by_source(source) + guess :source => source + end + + def enable_debug! + @debug_enabled = true + end + + def disable_debug! + remove_instance_variable :@debug_enabled if defined? @debug_enabled + end + + def debug_enabled? + (defined? @debug_enabled) ? true : false + end + + # Determine if a lexer has a method named +:detect?+ defined in its + # singleton class. + def detectable? + return @detectable if defined?(@detectable) + @detectable = singleton_methods(false).include?(:detect?) + end + + protected + # @private + def register(name, lexer) + # reset an existing list of lexers + @all = nil if defined?(@all) + registry[name.to_s] = lexer + end + + public + # Used to specify or get the canonical name of this lexer class. + # + # @example + # class MyLexer < Lexer + # tag 'foo' + # end + # + # MyLexer.tag # => 'foo' + # + # Lexer.find('foo') # => MyLexer + def tag(t=nil) + return @tag if t.nil? + + @tag = t.to_s + Lexer.register(@tag, self) + end + + # Used to specify alternate names this lexer class may be found by. + # + # @example + # class Erb < Lexer + # tag 'erb' + # aliases 'eruby', 'rhtml' + # end + # + # Lexer.find('eruby') # => Erb + def aliases(*args) + args.map!(&:to_s) + args.each { |arg| Lexer.register(arg, self) } + (@aliases ||= []).concat(args) + end + + # Specify a list of filename globs associated with this lexer. + # + # If a filename glob is associated with more than one lexer, this can + # cause a Guesser::Ambiguous error to be raised in various guessing + # methods. These errors can be avoided by disambiguation. Filename globs + # are disambiguated in one of two ways. Either the lexer will define a + # `self.detect?` method (intended for use with shebangs and doctypes) or a + # manual rule will be specified in Guessers::Disambiguation. + # + # @example + # class Ruby < Lexer + # filenames '*.rb', '*.ruby', 'Gemfile', 'Rakefile' + # end + def filenames(*fnames) + (@filenames ||= []).concat(fnames) + end + + # Specify a list of mimetypes associated with this lexer. + # + # @example + # class Html < Lexer + # mimetypes 'text/html', 'application/xhtml+xml' + # end + def mimetypes(*mts) + (@mimetypes ||= []).concat(mts) + end + + # @private + def assert_utf8!(str) + encoding = str.encoding + return if encoding == Encoding::US_ASCII || encoding == Encoding::UTF_8 || encoding == Encoding::BINARY + + raise EncodingError.new( + "Bad encoding: #{str.encoding.names.join(',')}. " + + "Please convert your string to UTF-8." + ) + end + + private + def registry + @registry ||= {} + end + end + + # -*- instance methods -*- # + + attr_reader :options + # Create a new lexer with the given options. Individual lexers may + # specify extra options. The only current globally accepted option + # is `:debug`. + # + # @option opts :debug + # Prints debug information to stdout. The particular info depends + # on the lexer in question. In regex lexers, this will log the + # state stack at the beginning of each step, along with each regex + # tried and each stream consumed. Try it, it's pretty useful. + def initialize(opts={}) + @options = {} + opts.each { |k, v| @options[k.to_s] = v } + + @debug = Lexer.debug_enabled? && bool_option('debug') + end + + # Returns a new lexer with the given options set. Useful for e.g. setting + # debug flags post hoc, or providing global overrides for certain options + def with(opts={}) + new_options = @options.dup + opts.each { |k, v| new_options[k.to_s] = v } + self.class.new(new_options) + end + + def as_bool(val) + case val + when nil, false, 0, '0', 'false', 'off' + false + when Array + val.empty? ? true : as_bool(val.last) + else + true + end + end + + def as_string(val) + return as_string(val.last) if val.is_a?(Array) + + val ? val.to_s : nil + end + + def as_list(val) + case val + when Array + val.flat_map { |v| as_list(v) } + when String + val.split(',') + else + [] + end + end + + def as_lexer(val) + return as_lexer(val.last) if val.is_a?(Array) + return val.new(@options) if val.is_a?(Class) && val < Lexer + + case val + when Lexer + val + when String + lexer_class = Lexer.find(val) + lexer_class && lexer_class.new(@options) + end + end + + def as_token(val) + return as_token(val.last) if val.is_a?(Array) + case val + when Token + val + else + Token[val] + end + end + + def bool_option(name, &default) + name_str = name.to_s + + if @options.key?(name_str) + as_bool(@options[name_str]) + else + default ? default.call : false + end + end + + def string_option(name, &default) + as_string(@options.delete(name.to_s, &default)) + end + + def lexer_option(name, &default) + as_lexer(@options.delete(name.to_s, &default)) + end + + def list_option(name, &default) + as_list(@options.delete(name.to_s, &default)) + end + + def token_option(name, &default) + as_token(@options.delete(name.to_s, &default)) + end + + def hash_option(name, defaults, &val_cast) + name = name.to_s + out = defaults.dup + + base = @options.delete(name.to_s) + base = {} unless base.is_a?(Hash) + base.each { |k, v| out[k.to_s] = val_cast ? val_cast.call(v) : v } + + @options.keys.each do |key| + next unless key =~ /(\w+)\[(\w+)\]/ and $1 == name + value = @options.delete(key) + + out[$2] = val_cast ? val_cast.call(value) : value + end + + out + end + + # @abstract + # + # Called after each lex is finished. The default implementation + # is a noop. + def reset! + end + + # Given a string, yield [token, chunk] pairs. If no block is given, + # an enumerator is returned. + # + # @option opts :continue + # Continue the lex from the previous state (i.e. don't call #reset!) + # + # @note The use of :continue => true has been deprecated. A warning is + # issued if run with `$VERBOSE` set to true. + # + # @note The use of arbitrary `opts` has never been supported, but we + # previously ignored them with no error. We now warn unconditionally. + def lex(string, opts=nil, &b) + if opts + if (opts.keys - [:continue]).size > 0 + # improper use of options hash + warn('Improper use of Lexer#lex - this method does not receive options.' + + ' This will become an error in a future version.') + end + + if opts[:continue] + warn '`lex :continue => true` is deprecated, please use #continue_lex instead' + return continue_lex(string, &b) + end + end + + return enum_for(:lex, string) unless block_given? + + Lexer.assert_utf8!(string) + reset! + + continue_lex(string, &b) + end + + # Continue the lex from the the current state without resetting + def continue_lex(string, &b) + return enum_for(:continue_lex, string, &b) unless block_given? + + # consolidate consecutive tokens of the same type + last_token = nil + last_val = nil + stream_tokens(string) do |tok, val| + next if val.empty? + + if tok == last_token + last_val << val + next + end + + b.call(last_token, last_val) if last_token + last_token = tok + last_val = val + end + + b.call(last_token, last_val) if last_token + end + + # delegated to {Lexer.tag} + def tag + self.class.tag + end + + # @abstract + # + # Yield `[token, chunk]` pairs, given a prepared input stream. This + # must be implemented. + # + # @param [StringScanner] stream + # the stream + def stream_tokens(stream, &b) + raise 'abstract' + end + + # @abstract + # + # Return true if there is an in-text indication (such as a shebang + # or DOCTYPE declaration) that this lexer should be used. + # + # @param [TextAnalyzer] text + # the text to be analyzed, with a couple of handy methods on it, + # like {TextAnalyzer#shebang?} and {TextAnalyzer#doctype?} + def self.detect?(text) + false + end + end + + module Lexers + BASE_DIR = "#{__dir__}/lexers".freeze + @_loaded_lexers = {} + + def self.load_lexer(relpath) + return if @_loaded_lexers.key?(relpath) + @_loaded_lexers[relpath] = true + Kernel::load File.join(BASE_DIR, relpath) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/abap.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/abap.rb new file mode 100644 index 0000000..8be9e95 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/abap.rb @@ -0,0 +1,240 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# ABAP elements taken from http://help.sap.com/abapdocu_750/en/index.htm?file=abapdo.htm + +module Rouge + module Lexers + class ABAP < RegexLexer + title "ABAP" + desc "SAP - Advanced Business Application Programming" + tag 'abap' + filenames '*.abap' + mimetypes 'text/x-abap' + + def self.keywords + @keywords = Set.new %w( + *-INPUT ?TO ABAP-SOURCE ABBREVIATED ABS ABSTRACT ACCEPT ACCEPTING + ACCORDING ACCP ACTIVATION ACTUAL ADD ADD-CORRESPONDING ADJACENT + AFTER ALIAS ALIASES ALIGN ALL ALLOCATE ALPHA ANALYSIS ANALYZER AND + ANY APPEND APPENDAGE APPENDING APPLICATION ARCHIVE AREA ARITHMETIC + AS ASCENDING ASPECT ASSERT ASSIGN ASSIGNED ASSIGNING ASSOCIATION + ASYNCHRONOUS AT ATTRIBUTES AUTHORITY AUTHORITY-CHECK AVG BACK + BACKGROUND BACKUP BACKWARD BADI BASE BEFORE BEGIN BETWEEN BIG BINARY + BINTOHEX BIT BIT-AND BIT-NOT BIT-OR BIT-XOR BLACK BLANK BLANKS BLOB + BLOCK BLOCKS BLUE BOUND BOUNDARIES BOUNDS BOXED BREAK-POINT BT + BUFFER BY BYPASSING BYTE BYTE-CA BYTE-CN BYTE-CO BYTE-CS BYTE-NA + BYTE-NS BYTE-ORDER CA CALL CALLING CASE CAST CASTING CATCH CEIL + CENTER CENTERED CHAIN CHAIN-INPUT CHAIN-REQUEST CHANGE CHANGING + CHANNELS CHAR CHAR-TO-HEX CHARACTER CHECK CHECKBOX CIRCULAR CLASS + CLASS-CODING CLASS-DATA CLASS-EVENTS CLASS-METHODS CLASS-POOL + CLEANUP CLEAR CLIENT CLNT CLOB CLOCK CLOSE CN CO COALESCE CODE + CODING COLLECT COLOR COLUMN COLUMNS COL_BACKGROUND COL_GROUP + COL_HEADING COL_KEY COL_NEGATIVE COL_NORMAL COL_POSITIVE COL_TOTAL + COMMENT COMMENTS COMMIT COMMON COMMUNICATION COMPARING COMPONENT + COMPONENTS COMPRESSION COMPUTE CONCAT CONCATENATE CONCAT_WITH_SPACE + COND CONDENSE CONDITION CONNECT CONNECTION CONSTANTS CONTEXT + CONTEXTS CONTINUE CONTROL CONTROLS CONV CONVERSION CONVERT COPIES + COPY CORRESPONDING COUNT COUNTRY COVER CP CPI CREATE CREATING + CRITICAL CS CUKY CURR CURRENCY CURRENCY_CONVERSION CURRENT CURSOR + CURSOR-SELECTION CUSTOMER CUSTOMER-FUNCTION CX_DYNAMIC_CHECK + CX_NO_CHECK CX_ROOT CX_SQL_EXCEPTION CX_STATIC_CHECK DANGEROUS DATA + DATABASE DATAINFO DATASET DATE DATS DATS_ADD_DAYS DATS_ADD_MONTHS + DATS_DAYS_BETWEEN DATS_IS_VALID DAYLIGHT DD/MM/YY DD/MM/YYYY DDMMYY + DEALLOCATE DEC DECIMALS DECIMAL_SHIFT DECLARATIONS DEEP DEFAULT + DEFERRED DEFINE DEFINING DEFINITION DELETE DELETING DEMAND + DEPARTMENT DESCENDING DESCRIBE DESTINATION DETAIL DF16_DEC DF16_RAW + DF16_SCL DF34_DEC DF34_RAW DF34_SCL DIALOG DIRECTORY DISCONNECT + DISPLAY DISPLAY-MODE DISTANCE DISTINCT DIV DIVIDE + DIVIDE-CORRESPONDING DIVISION DO DUMMY DUPLICATE DUPLICATES DURATION + DURING DYNAMIC DYNPRO E EDIT EDITOR-CALL ELSE ELSEIF EMPTY ENABLED + ENABLING ENCODING END END-ENHANCEMENT-SECTION END-LINES + END-OF-DEFINITION END-OF-FILE END-OF-PAGE END-OF-SELECTION + END-TEST-INJECTION END-TEST-SEAM ENDAT ENDCASE ENDCATCH ENDCHAIN + ENDCLASS ENDDO ENDENHANCEMENT ENDEXEC ENDFORM ENDFUNCTION ENDIAN + ENDIF ENDING ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON + ENDPROVIDE ENDSELECT ENDTRY ENDWHILE ENDWITH ENGINEERING ENHANCEMENT + ENHANCEMENT-POINT ENHANCEMENT-SECTION ENHANCEMENTS ENTRIES ENTRY + ENVIRONMENT EQ EQUIV ERRORMESSAGE ERRORS ESCAPE ESCAPING EVENT + EVENTS EXACT EXCEPT EXCEPTION EXCEPTION-TABLE EXCEPTIONS EXCLUDE + EXCLUDING EXEC EXECUTE EXISTS EXIT EXIT-COMMAND EXPAND EXPANDING + EXPIRATION EXPLICIT EXPONENT EXPORT EXPORTING EXTEND EXTENDED + EXTENSION EXTRACT FAIL FETCH FIELD FIELD-GROUPS FIELD-SYMBOL + FIELD-SYMBOLS FIELDS FILE FILTER FILTER-TABLE FILTERS FINAL FIND + FIRST FIRST-LINE FIXED-POINT FKEQ FKGE FLOOR FLTP FLUSH FONT FOR + FORM FORMAT FORWARD FOUND FRAME FRAMES FREE FRIENDS FROM FUNCTION + FUNCTION-POOL FUNCTIONALITY FURTHER GAPS GE GENERATE GET + GET_PRINT_PARAMETERS GIVING GKEQ GKGE GLOBAL GRANT GREEN GROUP + GROUPS GT HANDLE HANDLER HARMLESS HASHED HAVING HDB HEAD-LINES + HEADER HEADERS HEADING HELP-ID HELP-REQUEST HEXTOBIN HIDE HIGH HINT + HOLD HOTSPOT I ICON ID IDENTIFICATION IDENTIFIER IDS IF + IF_ABAP_CLOSE_RESOURCE IF_ABAP_CODEPAGE IF_ABAP_DB_BLOB_HANDLE + IF_ABAP_DB_CLOB_HANDLE IF_ABAP_DB_LOB_HANDLE IF_ABAP_DB_READER + IF_ABAP_DB_WRITER IF_ABAP_READER IF_ABAP_WRITER IF_MESSAGE + IF_OS_CA_INSTANCE IF_OS_CA_PERSISTENCY IF_OS_FACTORY IF_OS_QUERY + IF_OS_QUERY_MANAGER IF_OS_QUERY_OPTIONS IF_OS_STATE + IF_OS_TRANSACTION IF_OS_TRANSACTION_MANAGER IF_SERIALIZABLE_OBJECT + IF_SHM_BUILD_INSTANCE IF_SYSTEM_UUID IF_T100_DYN_MSG IF_T100_MESSAGE + IGNORE IGNORING IMMEDIATELY IMPLEMENTATION IMPLEMENTATIONS + IMPLEMENTED IMPLICIT IMPORT IMPORTING IN INACTIVE INCL INCLUDE + INCLUDES INCLUDING INCREMENT INDEX INDEX-LINE INFOTYPES INHERITING + INIT INITIAL INITIALIZATION INNER INOUT INPUT INSERT INSTANCE + INSTANCES INSTR INT1 INT2 INT4 INT8 INTENSIFIED INTERFACE + INTERFACE-POOL INTERFACES INTERNAL INTERVALS INTO INVERSE + INVERTED-DATE IS ISO ITNO JOB JOIN KEEP KEEPING KERNEL KEY KEYS + KEYWORDS KIND LANG LANGUAGE LAST LATE LAYOUT LCHR LDB_PROCESS LE + LEADING LEAVE LEFT LEFT-JUSTIFIED LEFTPLUS LEFTSPACE LEGACY LENGTH + LET LEVEL LEVELS LIKE LINE LINE-COUNT LINE-SELECTION LINE-SIZE + LINEFEED LINES LIST LIST-PROCESSING LISTBOX LITTLE LLANG LOAD + LOAD-OF-PROGRAM LOB LOCAL LOCALE LOCATOR LOG-POINT LOGFILE LOGICAL + LONG LOOP LOW LOWER LPAD LPI LRAW LT LTRIM M MAIL MAIN MAJOR-ID + MAPPING MARGIN MARK MASK MATCH MATCHCODE MAX MAXIMUM MEDIUM MEMBERS + MEMORY MESH MESSAGE MESSAGE-ID MESSAGES MESSAGING METHOD METHODS MIN + MINIMUM MINOR-ID MM/DD/YY MM/DD/YYYY MMDDYY MOD MODE MODIF MODIFIER + MODIFY MODULE MOVE MOVE-CORRESPONDING MULTIPLY + MULTIPLY-CORRESPONDING NA NAME NAMETAB NATIVE NB NE NESTED NESTING + NEW NEW-LINE NEW-PAGE NEW-SECTION NEXT NO NO-DISPLAY NO-EXTENSION + NO-GAP NO-GAPS NO-GROUPING NO-HEADING NO-SCROLLING NO-SIGN NO-TITLE + NO-TOPOFPAGE NO-ZERO NODE NODES NON-UNICODE NON-UNIQUE NOT NP NS + NULL NUMBER NUMC O OBJECT OBJECTS OBLIGATORY OCCURRENCE OCCURRENCES + OCCURS OF OFF OFFSET ON ONLY OPEN OPTION OPTIONAL OPTIONS OR ORDER + OTHER OTHERS OUT OUTER OUTPUT OUTPUT-LENGTH OVERFLOW OVERLAY PACK + PACKAGE PAD PADDING PAGE PAGES PARAMETER PARAMETER-TABLE PARAMETERS + PART PARTIALLY PATTERN PERCENTAGE PERFORM PERFORMING PERSON PF + PF-STATUS PINK PLACES POOL POSITION POS_HIGH POS_LOW PRAGMAS PREC + PRECOMPILED PREFERRED PRESERVING PRIMARY PRINT PRINT-CONTROL + PRIORITY PRIVATE PROCEDURE PROCESS PROGRAM PROPERTY PROTECTED + PROVIDE PUBLIC PUSH PUSHBUTTON PUT QUAN QUEUE-ONLY QUICKINFO + RADIOBUTTON RAISE RAISING RANGE RANGES RAW RAWSTRING READ READ-ONLY + READER RECEIVE RECEIVED RECEIVER RECEIVING RED REDEFINITION REDUCE + REDUCED REF REFERENCE REFRESH REGEX REJECT REMOTE RENAMING REPLACE + REPLACEMENT REPLACING REPORT REQUEST REQUESTED RESERVE RESET + RESOLUTION RESPECTING RESPONSIBLE RESULT RESULTS RESUMABLE RESUME + RETRY RETURN RETURNCODE RETURNING RETURNS RIGHT RIGHT-JUSTIFIED + RIGHTPLUS RIGHTSPACE RISK RMC_COMMUNICATION_FAILURE + RMC_INVALID_STATUS RMC_SYSTEM_FAILURE ROLE ROLLBACK ROUND ROWS RPAD + RTRIM RUN SAP SAP-SPOOL SAVING SCALE_PRESERVING + SCALE_PRESERVING_SCIENTIFIC SCAN SCIENTIFIC + SCIENTIFIC_WITH_LEADING_ZERO SCREEN SCROLL SCROLL-BOUNDARY SCROLLING + SEARCH SECONDARY SECONDS SECTION SELECT SELECT-OPTIONS SELECTION + SELECTION-SCREEN SELECTION-SET SELECTION-SETS SELECTION-TABLE + SELECTIONS SEND SEPARATE SEPARATED SET SHARED SHIFT SHORT + SHORTDUMP-ID SIGN SIGN_AS_POSTFIX SIMPLE SINGLE SIZE SKIP SKIPPING + SMART SOME SORT SORTABLE SORTED SOURCE SPACE SPECIFIED SPLIT SPOOL + SPOTS SQL SQLSCRIPT SSTRING STABLE STAMP STANDARD START-OF-SELECTION + STARTING STATE STATEMENT STATEMENTS STATIC STATICS STATUSINFO + STEP-LOOP STOP STRING STRUCTURE STRUCTURES STYLE SUBKEY SUBMATCHES + SUBMIT SUBROUTINE SUBSCREEN SUBSTRING SUBTRACT + SUBTRACT-CORRESPONDING SUFFIX SUM SUMMARY SUMMING SUPPLIED SUPPLY + SUPPRESS SWITCH SWITCHSTATES SYMBOL SYNCPOINTS SYNTAX SYNTAX-CHECK + SYNTAX-TRACE SYST SYSTEM-CALL SYSTEM-EXCEPTIONS SYSTEM-EXIT TAB + TABBED TABLE TABLES TABLEVIEW TABSTRIP TARGET TASK TASKS TEST + TEST-INJECTION TEST-SEAM TESTING TEXT TEXTPOOL THEN THROW TIME TIMES + TIMESTAMP TIMEZONE TIMS TIMS_IS_VALID TITLE TITLE-LINES TITLEBAR TO + TOKENIZATION TOKENS TOP-LINES TOP-OF-PAGE TRACE-FILE TRACE-TABLE + TRAILING TRANSACTION TRANSFER TRANSFORMATION TRANSLATE TRANSPORTING + TRMAC TRUNCATE TRUNCATION TRY TSTMP_ADD_SECONDS + TSTMP_CURRENT_UTCTIMESTAMP TSTMP_IS_VALID TSTMP_SECONDS_BETWEEN TYPE + TYPE-POOL TYPE-POOLS TYPES ULINE UNASSIGN UNDER UNICODE UNION UNIQUE + UNIT UNIT_CONVERSION UNIX UNPACK UNTIL UNWIND UP UPDATE UPPER USER + USER-COMMAND USING UTF-8 VALID VALUE VALUE-REQUEST VALUES VARC VARY + VARYING VERIFICATION-MESSAGE VERSION VIA VIEW VISIBLE WAIT WARNING + WHEN WHENEVER WHERE WHILE WIDTH WINDOW WINDOWS WITH WITH-HEADING + WITH-TITLE WITHOUT WORD WORK WRITE WRITER XML XSD YELLOW YES YYMMDD + Z ZERO ZONE + ) + end + + def self.builtins + @keywords = Set.new %w( + acos apply asin assign atan attribute bit-set boolc boolx call + call-method cast ceil cfunc charlen char_off class_constructor clear + cluster cmax cmin cnt communication_failure concat_lines_of cond + cond-var condense constructor contains contains_any_not_of + contains_any_of copy cos cosh count count_any_not_of count_any_of + create cursor data dbmaxlen dbtab deserialize destructor distance + empty error_message escape exp extensible find find_any_not_of + find_any_of find_end floor frac from_mixed group hashed header idx + include index insert ipow itab key lax lines line_exists line_index + log log10 loop loop_key match matches me mesh_path namespace nmax + nmin node numeric numofchar object parameter primary_key read ref + repeat replace rescale resource_failure reverse root round segment + sender serialize shift_left shift_right sign simple sin sinh skip + sorted space sqrt standard strlen substring substring_after + substring_before substring_from substring_to sum switch switch-var + system_failure table table_line tan tanh template text to_lower + to_mixed to_upper transform translate trunc type value variable write + xsdbool xsequence xstrlen + ) + end + + def self.types + @types = Set.new %w( + b c d decfloat16 decfloat34 f i int8 n p s t x + clike csequence decfloat string xstring + ) + end + + def self.new_keywords + @types = Set.new %w( + DATA FIELD-SYMBOL + ) + end + + state :root do + rule %r/\s+/m, Text + + rule %r/".*/, Comment::Single + rule %r(^\*.*), Comment::Multiline + rule %r/\d+/, Num::Integer + rule %r/('|`)/, Str::Single, :single_string + rule %r/[\[\]\(\)\{\}\.,:\|]/, Punctuation + + # builtins / new ABAP 7.40 keywords (@DATA(), ...) + rule %r/(->|=>)?([A-Za-z][A-Za-z0-9_\-]*)(\()/ do |m| + if m[1] != '' + token Operator, m[1] + end + + if (self.class.new_keywords.include? m[2].upcase) && m[1].nil? + token Keyword, m[2] + elsif (self.class.builtins.include? m[2].downcase) && m[1].nil? + token Name::Builtin, m[2] + else + token Name, m[2] + end + token Punctuation, m[3] + end + + # keywords, types and normal text + rule %r/\w\w*/ do |m| + if self.class.keywords.include? m[0].upcase + token Keyword + elsif self.class.types.include? m[0].downcase + token Keyword::Type + else + token Name + end + end + + # operators + rule %r((->|->>|=>)), Operator + rule %r([-\*\+%/~=&\?<>!#\@\^]+), Operator + + end + + state :operators do + rule %r((->|->>|=>)), Operator + rule %r([-\*\+%/~=&\?<>!#\@\^]+), Operator + end + + state :single_string do + rule %r/\\./, Str::Escape + rule %r/(''|``)/, Str::Escape + rule %r/['`]/, Str::Single, :pop! + rule %r/[^\\'`]+/, Str::Single + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/actionscript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/actionscript.rb new file mode 100644 index 0000000..557320e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/actionscript.rb @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Actionscript < RegexLexer + title "ActionScript" + desc "ActionScript" + + tag 'actionscript' + aliases 'as', 'as3' + filenames '*.as' + mimetypes 'application/x-actionscript' + + state :comments_and_whitespace do + rule %r/\s+/, Text + rule %r(//.*?$), Comment::Single + rule %r(/\*.*?\*/)m, Comment::Multiline + end + + state :expr_start do + mixin :comments_and_whitespace + + rule %r(/) do + token Str::Regex + goto :regex + end + + rule %r/[{]/, Punctuation, :object + + rule %r//, Text, :pop! + end + + state :regex do + rule %r(/) do + token Str::Regex + goto :regex_end + end + + rule %r([^/]\n), Error, :pop! + + rule %r/\n/, Error, :pop! + rule %r/\[\^/, Str::Escape, :regex_group + rule %r/\[/, Str::Escape, :regex_group + rule %r/\\./, Str::Escape + rule %r{[(][?][:=>>? | === + | !== )x, + Operator, :expr_start + rule %r([:-<>+*%&|\^/!=]=?), Operator, :expr_start + rule %r/[(\[,]/, Punctuation, :expr_start + rule %r/;/, Punctuation, :statement + rule %r/[)\].]/, Punctuation + + rule %r/[?]/ do + token Punctuation + push :ternary + push :expr_start + end + + rule %r/[{}]/, Punctuation, :statement + + rule id do |m| + if self.class.keywords.include? m[0] + token Keyword + push :expr_start + elsif self.class.declarations.include? m[0] + token Keyword::Declaration + push :expr_start + elsif self.class.reserved.include? m[0] + token Keyword::Reserved + elsif self.class.constants.include? m[0] + token Keyword::Constant + elsif self.class.builtins.include? m[0] + token Name::Builtin + else + token Name::Other + end + end + + rule %r/\-?[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float + rule %r/0x[0-9a-fA-F]+/, Num::Hex + rule %r/\-?[0-9]+/, Num::Integer + rule %r/"(\\\\|\\"|[^"])*"/, Str::Double + rule %r/'(\\\\|\\'|[^'])*'/, Str::Single + end + + # braced parts that aren't object literals + state :statement do + rule %r/(#{id})(\s*)(:)/ do + groups Name::Label, Text, Punctuation + end + + rule %r/[{}]/, Punctuation + + mixin :expr_start + end + + # object literals + state :object do + mixin :comments_and_whitespace + rule %r/[}]/ do + token Punctuation + goto :statement + end + + rule %r/(#{id})(\s*)(:)/ do + groups Name::Attribute, Text, Punctuation + push :expr_start + end + + rule %r/:/, Punctuation + mixin :root + end + + # ternary expressions, where : is not a label! + state :ternary do + rule %r/:/ do + token Punctuation + goto :expr_start + end + + mixin :root + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ada.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ada.rb new file mode 100644 index 0000000..21065bb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ada.rb @@ -0,0 +1,162 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Ada < RegexLexer + tag 'ada' + filenames '*.ada', '*.ads', '*.adb', '*.gpr' + mimetypes 'text/x-ada' + + title 'Ada' + desc 'The Ada 2012 programming language' + + # Ada identifiers are Unicode with underscores only allowed as separators. + ID = /\b[[:alpha:]](?:\p{Pc}?[[:alnum:]])*\b/ + + # Numerals can also contain underscores. + NUM = /\d(_?\d)*/ + XNUM = /\h(_?\h)*/ + EXP = /(E[-+]?#{NUM})?/i + + # Return a hash mapping lower-case identifiers to token classes. + def self.idents + @idents ||= Hash.new(Name).tap do |h| + %w( + abort abstract accept access aliased all array at begin body + case constant declare delay delta digits do else elsif end + exception exit for generic goto if in interface is limited + loop new null of others out overriding pragma private + protected raise range record renames requeue return reverse + select separate some synchronized tagged task terminate then + until use when while with + ).each {|w| h[w] = Keyword} + + %w(abs and mod not or rem xor).each {|w| h[w] = Operator::Word} + + %w( + entry function package procedure subtype type + ).each {|w| h[w] = Keyword::Declaration} + + %w( + boolean character constraint_error duration float integer + natural positive long_float long_integer long_long_float + long_long_integer program_error short_float short_integer + short_short_integer storage_error string tasking_error + wide_character wide_string wide_wide_character + wide_wide_string + ).each {|w| h[w] = Name::Builtin} + end + end + + state :whitespace do + rule %r{\s+}m, Text + rule %r{--.*$}, Comment::Single + end + + state :dquote_string do + rule %r{[^"\n]+}, Literal::String::Double + rule %r{""}, Literal::String::Escape + rule %r{"}, Literal::String::Double, :pop! + rule %r{\n}, Error, :pop! + end + + state :attr do + mixin :whitespace + rule ID, Name::Attribute, :pop! + rule %r{}, Text, :pop! + end + + # Handle a dotted name immediately following a declaration keyword. + state :decl_name do + mixin :whitespace + rule %r{body\b}i, Keyword::Declaration # package body Foo.Bar is... + rule %r{(#{ID})(\.)} do + groups Name::Namespace, Punctuation + end + # function "<=" (Left, Right: Type) is ... + rule %r{#{ID}|"(and|or|xor|/?=|<=?|>=?|\+|–|&\|/|mod|rem|\*?\*|abs|not)"}, + Name::Function, :pop! + rule %r{}, Text, :pop! + end + + # Handle a sequence of library unit names: with Ada.Foo, Ada.Bar; + # + # There's a chance we entered this state mistakenly since 'with' + # has multiple other uses in Ada (none of which are likely to + # appear at the beginning of a line). Try to bail as soon as + # possible if we see something suspicious like keywords. + # + # See ada_spec.rb for some examples. + state :libunit_name do + mixin :whitespace + + rule ID do |m| + t = self.class.idents[m[0].downcase] + if t <= Name + # Convert all kinds of Name to namespaces in this context. + token Name::Namespace + else + # Yikes, we're not supposed to get a keyword in a library unit name! + # We probably entered this state by mistake, so try to fix it. + token t + if t == Keyword::Declaration + goto :decl_name + else + pop! + end + end + end + + rule %r{[.,]}, Punctuation + rule %r{}, Text, :pop! + end + + state :root do + mixin :whitespace + + # String literals. + rule %r{'.'}, Literal::String::Char + rule %r{"[^"\n]*}, Literal::String::Double, :dquote_string + + # Real literals. + rule %r{#{NUM}\.#{NUM}#{EXP}}, Literal::Number::Float + rule %r{#{NUM}##{XNUM}\.#{XNUM}##{EXP}}, Literal::Number::Float + + # Integer literals. + rule %r{2#[01](_?[01])*##{EXP}}, Literal::Number::Bin + rule %r{8#[0-7](_?[0-7])*##{EXP}}, Literal::Number::Oct + rule %r{16##{XNUM}*##{EXP}}, Literal::Number::Hex + rule %r{#{NUM}##{XNUM}##{EXP}}, Literal::Number::Integer + rule %r{#{NUM}#\w+#}, Error + rule %r{#{NUM}#{EXP}}, Literal::Number::Integer + + # Special constructs. + rule %r{'}, Punctuation, :attr + rule %r{<<#{ID}>>}, Name::Label + + # Context clauses are tricky because the 'with' keyword is used + # for many purposes. Detect at beginning of the line only. + rule %r{^(?:(limited)(\s+))?(?:(private)(\s+))?(with)\b}i do + groups Keyword::Namespace, Text, Keyword::Namespace, Text, Keyword::Namespace + push :libunit_name + end + + # Operators and punctuation characters. + rule %r{[+*/&<=>|]|-|=>|\.\.|\*\*|[:>>|<>}, Operator + rule %r{[.,:;()]}, Punctuation + + rule ID do |m| + t = self.class.idents[m[0].downcase] + token t + if t == Keyword::Declaration + push :decl_name + end + end + + # Flag word-like things that don't match the ID pattern. + rule %r{\b(\p{Pc}|[[:alpha:]])\p{Word}*}, Error + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apache.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apache.rb new file mode 100644 index 0000000..2b8046b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apache.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +require 'yaml' + +module Rouge + module Lexers + class Apache < RegexLexer + title "Apache" + desc 'configuration files for Apache web server' + tag 'apache' + mimetypes 'text/x-httpd-conf', 'text/x-apache-conf' + filenames '.htaccess', 'httpd.conf' + + # self-modifying method that loads the keywords file + def self.directives + Kernel::load File.join(Lexers::BASE_DIR, 'apache/keywords.rb') + directives + end + + def self.sections + Kernel::load File.join(Lexers::BASE_DIR, 'apache/keywords.rb') + sections + end + + def self.values + Kernel::load File.join(Lexers::BASE_DIR, 'apache/keywords.rb') + values + end + + def name_for_token(token, tktype) + if self.class.sections.include? token + tktype + elsif self.class.directives.include? token + tktype + elsif self.class.values.include? token + tktype + else + Text + end + end + + state :whitespace do + rule %r/\#.*/, Comment + rule %r/\s+/m, Text + end + + state :root do + mixin :whitespace + + rule %r/(<\/?)(\w+)/ do |m| + groups Punctuation, name_for_token(m[2].downcase, Name::Label) + push :section + end + + rule %r/\w+/ do |m| + token name_for_token(m[0].downcase, Name::Class) + push :directive + end + end + + state :section do + # Match section arguments + rule %r/([^>]+)?(>(?:\r\n?|\n)?)/ do + groups Literal::String::Regex, Punctuation + pop! + end + + mixin :whitespace + end + + state :directive do + # Match value literals and other directive arguments + rule %r/\r\n?|\n/, Text, :pop! + + mixin :whitespace + + rule %r/\S+/ do |m| + token name_for_token(m[0].downcase, Literal::String::Symbol) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apache/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apache/keywords.rb new file mode 100644 index 0000000..e71876e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apache/keywords.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# DO NOT EDIT +# This file is automatically generated by `rake builtins:apache`. +# See tasks/builtins/apache.rake for more info. + +module Rouge + module Lexers + class Apache + def self.directives + @directives ||= Set.new ["acceptfilter", "acceptpathinfo", "accessfilename", "action", "addalt", "addaltbyencoding", "addaltbytype", "addcharset", "adddefaultcharset", "adddescription", "addencoding", "addhandler", "addicon", "addiconbyencoding", "addiconbytype", "addinputfilter", "addlanguage", "addmoduleinfo", "addoutputfilter", "addoutputfilterbytype", "addtype", "alias", "aliasmatch", "allow", "allowconnect", "allowencodedslashes", "allowmethods", "allowoverride", "allowoverridelist", "anonymous", "anonymous_logemail", "anonymous_mustgiveemail", "anonymous_nouserid", "anonymous_verifyemail", "asyncrequestworkerfactor", "authbasicauthoritative", "authbasicfake", "authbasicprovider", "authbasicusedigestalgorithm", "authdbduserpwquery", "authdbduserrealmquery", "authdbmgroupfile", "authdbmtype", "authdbmuserfile", "authdigestalgorithm", "authdigestdomain", "authdigestnoncelifetime", "authdigestprovider", "authdigestqop", "authdigestshmemsize", "authformauthoritative", "authformbody", "authformdisablenostore", "authformfakebasicauth", "authformlocation", "authformloginrequiredlocation", "authformloginsuccesslocation", "authformlogoutlocation", "authformmethod", "authformmimetype", "authformpassword", "authformprovider", "authformsitepassphrase", "authformsize", "authformusername", "authgroupfile", "authldapauthorizeprefix", "authldapbindauthoritative", "authldapbinddn", "authldapbindpassword", "authldapcharsetconfig", "authldapcompareasuser", "authldapcomparednonserver", "authldapdereferencealiases", "authldapgroupattribute", "authldapgroupattributeisdn", "authldapinitialbindasuser", "authldapinitialbindpattern", "authldapmaxsubgroupdepth", "authldapremoteuserattribute", "authldapremoteuserisdn", "authldapsearchasuser", "authldapsubgroupattribute", "authldapsubgroupclass", "authldapurl", "authmerging", "authname", "authncachecontext", "authncacheenable", "authncacheprovidefor", "authncachesocache", "authncachetimeout", "authnzfcgicheckauthnprovider", "authnzfcgidefineprovider", "authtype", "authuserfile", "authzdbdlogintoreferer", "authzdbdquery", "authzdbdredirectquery", "authzdbmtype", "authzsendforbiddenonfailure", "balancergrowth", "balancerinherit", "balancermember", "balancerpersist", "brotlialteretag", "brotlicompressionmaxinputblock", "brotlicompressionquality", "brotlicompressionwindow", "brotlifilternote", "browsermatch", "browsermatchnocase", "bufferedlogs", "buffersize", "cachedefaultexpire", "cachedetailheader", "cachedirlength", "cachedirlevels", "cachedisable", "cacheenable", "cachefile", "cacheheader", "cacheignorecachecontrol", "cacheignoreheaders", "cacheignorenolastmod", "cacheignorequerystring", "cacheignoreurlsessionidentifiers", "cachekeybaseurl", "cachelastmodifiedfactor", "cachelock", "cachelockmaxage", "cachelockpath", "cachemaxexpire", "cachemaxfilesize", "cacheminexpire", "cacheminfilesize", "cachenegotiateddocs", "cachequickhandler", "cachereadsize", "cachereadtime", "cacheroot", "cachesocache", "cachesocachemaxsize", "cachesocachemaxtime", "cachesocachemintime", "cachesocachereadsize", "cachesocachereadtime", "cachestaleonerror", "cachestoreexpired", "cachestorenostore", "cachestoreprivate", "cgidscripttimeout", "cgimapextension", "cgipassauth", "cgivar", "charsetdefault", "charsetoptions", "charsetsourceenc", "checkcaseonly", "checkspelling", "chrootdir", "contentdigest", "cookiedomain", "cookieexpires", "cookiename", "cookiestyle", "cookietracking", "coredumpdirectory", "customlog", "dav", "davdepthinfinity", "davgenericlockdb", "davlockdb", "davmintimeout", "dbdexptime", "dbdinitsql", "dbdkeep", "dbdmax", "dbdmin", "dbdparams", "dbdpersist", "dbdpreparesql", "dbdriver", "defaulticon", "defaultlanguage", "defaultruntimedir", "defaulttype", "define", "deflatebuffersize", "deflatecompressionlevel", "deflatefilternote", "deflateinflatelimitrequestbody", "deflateinflateratioburst", "deflateinflateratiolimit", "deflatememlevel", "deflatewindowsize", "deny", "directorycheckhandler", "directoryindex", "directoryindexredirect", "directoryslash", "documentroot", "dtraceprivileges", "dumpioinput", "dumpiooutput", "enableexceptionhook", "enablemmap", "enablesendfile", "error", "errordocument", "errorlog", "errorlogformat", "example", "expiresactive", "expiresbytype", "expiresdefault", "extendedstatus", "extfilterdefine", "extfilteroptions", "fallbackresource", "fileetag", "filterchain", "filterdeclare", "filterprotocol", "filterprovider", "filtertrace", "forcelanguagepriority", "forcetype", "forensiclog", "globallog", "gprofdir", "gracefulshutdowntimeout", "group", "h2copyfiles", "h2direct", "h2earlyhints", "h2maxsessionstreams", "h2maxworkeridleseconds", "h2maxworkers", "h2minworkers", "h2moderntlsonly", "h2push", "h2pushdiarysize", "h2pushpriority", "h2pushresource", "h2serializeheaders", "h2streammaxmemsize", "h2tlscooldownsecs", "h2tlswarmupsize", "h2upgrade", "h2windowsize", "header", "headername", "heartbeataddress", "heartbeatlisten", "heartbeatmaxservers", "heartbeatstorage", "heartbeatstorage", "hostnamelookups", "httpprotocoloptions", "identitycheck", "identitychecktimeout", "imapbase", "imapdefault", "imapmenu", "include", "includeoptional", "indexheadinsert", "indexignore", "indexignorereset", "indexoptions", "indexorderdefault", "indexstylesheet", "inputsed", "isapiappendlogtoerrors", "isapiappendlogtoquery", "isapicachefile", "isapifakeasync", "isapilognotsupported", "isapireadaheadbuffer", "keepalive", "keepalivetimeout", "keptbodysize", "languagepriority", "ldapcacheentries", "ldapcachettl", "ldapconnectionpoolttl", "ldapconnectiontimeout", "ldaplibrarydebug", "ldapopcacheentries", "ldapopcachettl", "ldapreferralhoplimit", "ldapreferrals", "ldapretries", "ldapretrydelay", "ldapsharedcachefile", "ldapsharedcachesize", "ldaptimeout", "ldaptrustedclientcert", "ldaptrustedglobalcert", "ldaptrustedmode", "ldapverifyservercert", "limitinternalrecursion", "limitrequestbody", "limitrequestfields", "limitrequestfieldsize", "limitrequestline", "limitxmlrequestbody", "listen", "listenbacklog", "listencoresbucketsratio", "loadfile", "loadmodule", "logformat", "logiotrackttfb", "loglevel", "logmessage", "luaauthzprovider", "luacodecache", "luahookaccesschecker", "luahookauthchecker", "luahookcheckuserid", "luahookfixups", "luahookinsertfilter", "luahooklog", "luahookmaptostorage", "luahooktranslatename", "luahooktypechecker", "luainherit", "luainputfilter", "luamaphandler", "luaoutputfilter", "luapackagecpath", "luapackagepath", "luaquickhandler", "luaroot", "luascope", "maxconnectionsperchild", "maxkeepaliverequests", "maxmemfree", "maxrangeoverlaps", "maxrangereversals", "maxranges", "maxrequestworkers", "maxspareservers", "maxsparethreads", "maxthreads", "mdbaseserver", "mdcachallenges", "mdcertificateagreement", "mdcertificateauthority", "mdcertificateprotocol", "mddrivemode", "mdhttpproxy", "mdmember", "mdmembers", "mdmuststaple", "mdnotifycmd", "mdomain", "mdportmap", "mdprivatekeys", "mdrenewwindow", "mdrequirehttps", "mdstoredir", "memcacheconnttl", "mergetrailers", "metadir", "metafiles", "metasuffix", "mimemagicfile", "minspareservers", "minsparethreads", "mmapfile", "modemstandard", "modmimeusepathinfo", "multiviewsmatch", "mutex", "namevirtualhost", "noproxy", "nwssltrustedcerts", "nwsslupgradeable", "options", "order", "outputsed", "passenv", "pidfile", "privilegesmode", "protocol", "protocolecho", "protocols", "protocolshonororder", "proxyaddheaders", "proxybadheader", "proxyblock", "proxydomain", "proxyerroroverride", "proxyexpressdbmfile", "proxyexpressdbmtype", "proxyexpressenable", "proxyfcgibackendtype", "proxyfcgisetenvif", "proxyftpdircharset", "proxyftpescapewildcards", "proxyftplistonwildcard", "proxyhcexpr", "proxyhctemplate", "proxyhctpsize", "proxyhtmlbufsize", "proxyhtmlcharsetout", "proxyhtmldoctype", "proxyhtmlenable", "proxyhtmlevents", "proxyhtmlextended", "proxyhtmlfixups", "proxyhtmlinterp", "proxyhtmllinks", "proxyhtmlmeta", "proxyhtmlstripcomments", "proxyhtmlurlmap", "proxyiobuffersize", "proxymaxforwards", "proxypass", "proxypassinherit", "proxypassinterpolateenv", "proxypassmatch", "proxypassreverse", "proxypassreversecookiedomain", "proxypassreversecookiepath", "proxypreservehost", "proxyreceivebuffersize", "proxyremote", "proxyremotematch", "proxyrequests", "proxyscgiinternalredirect", "proxyscgisendfile", "proxyset", "proxysourceaddress", "proxystatus", "proxytimeout", "proxyvia", "qualifyredirecturl", "readmename", "receivebuffersize", "redirect", "redirectmatch", "redirectpermanent", "redirecttemp", "reflectorheader", "registerhttpmethod", "remoteipheader", "remoteipinternalproxy", "remoteipinternalproxylist", "remoteipproxiesheader", "remoteipproxyprotocol", "remoteipproxyprotocolexceptions", "remoteiptrustedproxy", "remoteiptrustedproxylist", "removecharset", "removeencoding", "removehandler", "removeinputfilter", "removelanguage", "removeoutputfilter", "removetype", "requestheader", "requestreadtimeout", "require", "rewritebase", "rewritecond", "rewriteengine", "rewritemap", "rewriteoptions", "rewriterule", "rlimitcpu", "rlimitmem", "rlimitnproc", "satisfy", "scoreboardfile", "script", "scriptalias", "scriptaliasmatch", "scriptinterpretersource", "scriptlog", "scriptlogbuffer", "scriptloglength", "scriptsock", "securelisten", "seerequesttail", "sendbuffersize", "serveradmin", "serveralias", "serverlimit", "servername", "serverpath", "serverroot", "serversignature", "servertokens", "session", "sessioncookiename", "sessioncookiename2", "sessioncookieremove", "sessioncryptocipher", "sessioncryptodriver", "sessioncryptopassphrase", "sessioncryptopassphrasefile", "sessiondbdcookiename", "sessiondbdcookiename2", "sessiondbdcookieremove", "sessiondbddeletelabel", "sessiondbdinsertlabel", "sessiondbdperuser", "sessiondbdselectlabel", "sessiondbdupdatelabel", "sessionenv", "sessionexclude", "sessionheader", "sessioninclude", "sessionmaxage", "setenv", "setenvif", "setenvifexpr", "setenvifnocase", "sethandler", "setinputfilter", "setoutputfilter", "ssiendtag", "ssierrormsg", "ssietag", "ssilastmodified", "ssilegacyexprparser", "ssistarttag", "ssitimeformat", "ssiundefinedecho", "sslcacertificatefile", "sslcacertificatepath", "sslcadnrequestfile", "sslcadnrequestpath", "sslcarevocationcheck", "sslcarevocationfile", "sslcarevocationpath", "sslcertificatechainfile", "sslcertificatefile", "sslcertificatekeyfile", "sslciphersuite", "sslcompression", "sslcryptodevice", "sslengine", "sslfips", "sslhonorcipherorder", "sslinsecurerenegotiation", "sslocspdefaultresponder", "sslocspenable", "sslocspnoverify", "sslocspoverrideresponder", "sslocspproxyurl", "sslocsprespondercertificatefile", "sslocsprespondertimeout", "sslocspresponsemaxage", "sslocspresponsetimeskew", "sslocspuserequestnonce", "sslopensslconfcmd", "ssloptions", "sslpassphrasedialog", "sslprotocol", "sslproxycacertificatefile", "sslproxycacertificatepath", "sslproxycarevocationcheck", "sslproxycarevocationfile", "sslproxycarevocationpath", "sslproxycheckpeercn", "sslproxycheckpeerexpire", "sslproxycheckpeername", "sslproxyciphersuite", "sslproxyengine", "sslproxymachinecertificatechainfile", "sslproxymachinecertificatefile", "sslproxymachinecertificatepath", "sslproxyprotocol", "sslproxyverify", "sslproxyverifydepth", "sslrandomseed", "sslrenegbuffersize", "sslrequire", "sslrequiressl", "sslsessioncache", "sslsessioncachetimeout", "sslsessionticketkeyfile", "sslsessiontickets", "sslsrpunknownuserseed", "sslsrpverifierfile", "sslstaplingcache", "sslstaplingerrorcachetimeout", "sslstaplingfaketrylater", "sslstaplingforceurl", "sslstaplingrespondertimeout", "sslstaplingresponsemaxage", "sslstaplingresponsetimeskew", "sslstaplingreturnrespondererrors", "sslstaplingstandardcachetimeout", "sslstrictsnivhostcheck", "sslusername", "sslusestapling", "sslverifyclient", "sslverifydepth", "startservers", "startthreads", "substitute", "substituteinheritbefore", "substitutemaxlinelength", "suexec", "suexecusergroup", "threadlimit", "threadsperchild", "threadstacksize", "timeout", "traceenable", "transferlog", "typesconfig", "undefine", "undefmacro", "unsetenv", "use", "usecanonicalname", "usecanonicalphysicalport", "user", "userdir", "vhostcgimode", "vhostcgiprivs", "vhostgroup", "vhostprivs", "vhostsecure", "vhostuser", "virtualdocumentroot", "virtualdocumentrootip", "virtualscriptalias", "virtualscriptaliasip", "watchdoginterval", "xbithack", "xml2encalias", "xml2encdefault", "xml2startparse"] + end + + def self.sections + @sections ||= Set.new ["authnprovideralias", "authzprovideralias", "directory", "directorymatch", "else", "elseif", "files", "filesmatch", "if", "ifdefine", "ifmodule", "ifversion", "limit", "limitexcept", "location", "locationmatch", "macro", "mdomainset", "proxy", "proxymatch", "requireall", "requireany", "requirenone", "virtualhost"] + end + + def self.values + @values ||= Set.new ["add", "addaltclass", "addsuffix", "alias", "all", "allow", "allowanyuri", "allownoslash", "always", "and", "any", "ap_auth_internal_per_uri", "api_version", "append", "ascending", "attribute", "auth", "auth-int", "authconfig", "auto", "backend-address", "balancer_name", "balancer_route_changed", "balancer_session_route", "balancer_session_sticky", "balancer_worker_name", "balancer_worker_route", "base", "basedn", "basic", "before", "block", "boolean", "byte", "byteranges", "cache", "cache-hit", "cache-invalidate", "cache-miss", "cache-revalidate", "cgi", "chain", "change", "charset", "circle", "cmd", "conditional-expression", "condpattern", "conn", "conn_remote_addr", "cookie", "cookie2", "current-uri", "date", "date_gmt", "date_local", "db", "dbm", "decoding", "default", "deny", "descending", "description", "descriptionwidth", "digest", "disabled", "disableenv", "dns", "document_args", "document_name", "document_root", "document_uri", "domain", "double", "duration", "early", "echo", "echomsg", "edit", "edit*", "email", "enableenv", "encoding", "env", "environment-variable-name", "errmsg", "error", "errorlog", "errorlogformat", "execcgi", "expr", "fallback", "fancyindexing", "fast", "file", "file-group", "file-owner", "fileinfo", "filename", "filter", "filter-name", "filter_name", "filters", "finding", "first-dot", "foldersfirst", "followsymlinks", "forever", "form", "formatted", "fpm", "from", "ftype", "full", "function_name", "gdbm", "generic", "gone", "handlers", "hit", "hook_function_name", "host", "hostname", "hse_append_log_parameter", "hse_req_done_with_session", "hse_req_is_connected", "hse_req_is_keep_conn", "hse_req_map_url_to_path", "hse_req_send_response_header", "hse_req_send_response_header_ex", "hse_req_send_url", "hse_req_send_url_redirect_resp", "html", "htmltable", "https", "iconheight", "iconsarelinks", "iconwidth", "ignore", "ignorecase", "ignoreclient", "ignorecontextinfo", "ignoreinherit", "imal", "in", "includes", "includesnoexec", "indexes", "inherit", "inheritbefore", "inheritdown", "inheritdownbefore", "inode", "input", "int", "integer", "intype", "ipaddr", "is_subreq", "iserror", "last-dot", "last_modified", "ldap", "leaf", "legacyprefixdocroot", "level", "limit", "log_function_name", "major", "manual", "map", "map1", "map2", "max", "md5", "md5-sess", "menu", "merge", "mergebase", "minor", "miss", "mod_cache_disk", "mod_cache_socache", "mode", "mtime", "multiviews", "mutual-failure", "mysql", "name", "namewidth", "ndbm", "negotiatedonly", "never", "no", "nochange", "nocontent", "nodecode", "none", "nonfatal", "note", "number-of-ranges", "odbc", "off", "on", "once", "onerror", "onfail", "option", "optional", "options", "or", "oracle", "order", "original-uri", "os", "output", "outtype", "parent-first", "parent-last", "path", "path_info", "permanent", "pipe", "point", "poly", "postgresql", "prefer", "preservescontentlength", "prg", "protocol", "provider-name", "provider_name", "proxy", "proxy-chain-auth", "proxy-fcgi-pathinfo", "proxy-initial-not-pooled", "proxy-interim-response", "proxy-nokeepalive", "proxy-scgi-pathinfo", "proxy-sendcl", "proxy-sendextracrlf", "proxy-source-port", "proxy-status", "qs", "query_string_unescaped", "range", "ratio", "rect", "referer", "regex", "registry", "registry-strict", "remote_addr", "remote_host", "remote_ident", "remote_user", "remove", "request", "request_filename", "request_rec", "request_scheme", "request_uri", "reset", "revalidate", "rewritecond", "rfc2109", "rnd", "scanhtmltitles", "scope", "script", "sdbm", "searching", "secure", "seeother", "selective", "semiformatted", "server", "server_addr", "server_admin", "server_name", "set", "setifempty", "showforbidden", "size", "sizefmt", "sqlite2", "sqlite3", "ssl", "ssl-access-forbidden", "ssl-secure-reneg", "startbody", "stat", "string", "string1", "subnet", "suppresscolumnsorting", "suppressdescription", "suppresshtmlpreamble", "suppressicon", "suppresslastmodified", "suppressrules", "suppresssize", "symlinksifownermatch", "temp", "temporary", "test_condition1", "the_request", "thread", "timefmt", "tls", "to-pattern", "trackmodified", "transform", "txt", "type", "uctonly", "uid", "unescape", "unformatted", "unlimited", "unset", "uri-pattern", "url", "url-of-terms-of-service", "url-path", "useolddateformat", "value", "value-expression", "var", "versionsort", "virtual", "x-forwarded-for", "x-forwarded-host", "x-forwarded-server", "xhtml"] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apex.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apex.rb new file mode 100644 index 0000000..79b5d33 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apex.rb @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Apex < RegexLexer + title "Apex" + desc "The Apex programming language (provided by salesforce)" + + tag 'apex' + filenames '*.cls' + mimetypes 'text/x-apex' + + def self.keywords + @keywords ||= Set.new %w( + assert break case catch continue default do else finally for if goto + instanceof new return switch this throw try while insert update + delete + ) + end + + def self.declarations + @declarations ||= Set.new %w( + abstract const enum extends final implements native private protected + public static super synchronized throws transient volatile with + sharing without inherited virtual global testmethod + ) + end + + def self.soql + @soql ||= Set.new %w( + SELECT FROM WHERE UPDATE LIKE TYPEOF END USING SCOPE WITH DATA + CATEGORY GROUP BY ROLLUP CUBE HAVING ORDER BY ASC DESC NULLS FIRST + LAST LIMIT OFFSET FOR VIEW REFERENCE UPDATE TRACKING VIEWSTAT OR AND + ) + end + + def self.types + @types ||= Set.new %w( + String boolean byte char double float int long short var void + ) + end + + def self.constants + @constants ||= Set.new %w(true false null) + end + + id = /[a-z_][a-z0-9_]*/i + + state :root do + rule %r/\s+/m, Text + + rule %r(//.*?$), Comment::Single + rule %r(/\*.*?\*/)m, Comment::Multiline + + rule %r/(?:class|interface)\b/, Keyword::Declaration, :class + rule %r/import\b/, Keyword::Namespace, :import + + rule %r/([@$.]?)(#{id})([:(]?)/io do |m| + lowercased = m[0].downcase + uppercased = m[0].upcase + if self.class.keywords.include? lowercased + token Keyword + elsif self.class.soql.include? uppercased + token Keyword + elsif self.class.declarations.include? lowercased + token Keyword::Declaration + elsif self.class.types.include? lowercased + token Keyword::Type + elsif self.class.constants.include? lowercased + token Keyword::Constant + elsif lowercased == 'package' + token Keyword::Namespace + elsif m[1] == "@" + token Name::Decorator + elsif m[3] == ":" + groups Operator, Name::Label, Punctuation + elsif m[3] == "(" + groups Operator, Name::Function, Punctuation + elsif m[1] == "." + groups Operator, Name::Property, Punctuation + else + token Name + end + end + + rule %r/"/, Str::Double, :dq + rule %r/'/, Str::Single, :sq + + digit = /[0-9]_+[0-9]|[0-9]/ + rule %r/#{digit}+\.#{digit}+([eE]#{digit}+)?[fd]?/, Num::Float + rule %r/0b(?:[01]_+[01]|[01])+/i, Num::Bin + rule %r/0x(?:\h_+\h|\h)+/i, Num::Hex + rule %r/0(?:[0-7]_+[0-7]|[0-7])+/, Num::Oct + rule %r/#{digit}+L?/, Num::Integer + + rule %r/[-+\/*~^!%&<>|=.?]/, Operator + rule %r/[\[\](){},:;]/, Punctuation; + end + + state :class do + rule %r/\s+/m, Text + rule id, Name::Class, :pop! + end + + state :import do + rule %r/\s+/m, Text + rule %r/[a-z0-9_.]+\*?/i, Name::Namespace, :pop! + end + + state :escape do + rule %r/\\[btnfr\\"']/, Str::Escape + end + + state :dq do + mixin :escape + rule %r/[^\\"]+/, Str::Double + rule %r/"/, Str::Double, :pop! + end + + state :sq do + mixin :escape + rule %r/[^\\']+/, Str::Double + rule %r/'/, Str::Double, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apiblueprint.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apiblueprint.rb new file mode 100644 index 0000000..7695c39 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apiblueprint.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'markdown.rb' + + class APIBlueprint < Markdown + title 'API Blueprint' + desc 'Markdown based API description language.' + + tag 'apiblueprint' + aliases 'apiblueprint', 'apib' + filenames '*.apib' + mimetypes 'text/vnd.apiblueprint' + + prepend :root do + # Metadata + rule(/(\S+)(:\s*)(.*)$/) do + groups Name::Variable, Punctuation, Literal::String + end + + # Resource Group + rule(/^(#+)(\s*Group\s+)(.*)$/) do + groups Punctuation, Keyword, Generic::Heading + end + + # Resource \ Action + rule(/^(#+)(.*)(\[.*\])$/) do + groups Punctuation, Generic::Heading, Literal::String + end + + # Relation + rule(/^([\+\-\*])(\s*Relation:)(\s*.*)$/) do + groups Punctuation, Keyword, Literal::String + end + + # MSON + rule(/^(\s+[\+\-\*]\s*)(Attributes|Parameters)(.*)$/) do + groups Punctuation, Keyword, Literal::String + end + + # Request/Response + rule(/^([\+\-\*]\s*)(Request|Response)(\s+\d\d\d)?(.*)$/) do + groups Punctuation, Keyword, Literal::Number, Literal::String + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apple_script.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apple_script.rb new file mode 100644 index 0000000..7a47b29 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/apple_script.rb @@ -0,0 +1,370 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class AppleScript < RegexLexer + title "AppleScript" + desc "The AppleScript scripting language by Apple Inc. (https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html)" + + tag 'applescript' + aliases 'applescript' + + filenames '*.applescript', '*.scpt' + + mimetypes 'application/x-applescript' + + def self.literals + @literals ||= ['AppleScript', 'current application', 'false', 'linefeed', + 'missing value', 'pi','quote', 'result', 'return', 'space', + 'tab', 'text item delimiters', 'true', 'version'] + end + + def self.classes + @classes ||= ['alias ', 'application ', 'boolean ', 'class ', 'constant ', + 'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ', + 'real ', 'record ', 'reference ', 'RGB color ', 'script ', + 'text ', 'unit types', '(?:Unicode )?text', 'string'] + end + + def self.builtins + @builtins ||= ['attachment', 'attribute run', 'character', 'day', 'month', + 'paragraph', 'word', 'year'] + end + + def self.handler_params + @handler_params ||= ['about', 'above', 'against', 'apart from', 'around', + 'aside from', 'at', 'below', 'beneath', 'beside', + 'between', 'for', 'given', 'instead of', 'on', 'onto', + 'out of', 'over', 'since'] + end + + def self.commands + @commands ||= ['ASCII (character|number)', 'activate', 'beep', 'choose URL', + 'choose application', 'choose color', 'choose file( name)?', + 'choose folder', 'choose from list', + 'choose remote application', 'clipboard info', + 'close( access)?', 'copy', 'count', 'current date', 'delay', + 'delete', 'display (alert|dialog)', 'do shell script', + 'duplicate', 'exists', 'get eof', 'get volume settings', + 'info for', 'launch', 'list (disks|folder)', 'load script', + 'log', 'make', 'mount volume', 'new', 'offset', + 'open( (for access|location))?', 'path to', 'print', 'quit', + 'random number', 'read', 'round', 'run( script)?', + 'say', 'scripting components', + 'set (eof|the clipboard to|volume)', 'store script', + 'summarize', 'system attribute', 'system info', + 'the clipboard', 'time to GMT', 'write', 'quoted form'] + end + + def self.references + @references ||= ['(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)', + 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', + 'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back', + 'before', 'behind', 'every', 'front', 'index', 'last', + 'middle', 'some', 'that', 'through', 'thru', 'where', 'whose'] + end + + def self.operators + @operators ||= ["and", "or", "is equal", "equals", "(is )?equal to", "is not", + "isn't", "isn't equal( to)?", "is not equal( to)?", + "doesn't equal", "does not equal", "(is )?greater than", + "comes after", "is not less than or equal( to)?", + "isn't less than or equal( to)?", "(is )?less than", + "comes before", "is not greater than or equal( to)?", + "isn't greater than or equal( to)?", + "(is )?greater than or equal( to)?", "is not less than", + "isn't less than", "does not come before", + "doesn't come before", "(is )?less than or equal( to)?", + "is not greater than", "isn't greater than", + "does not come after", "doesn't come after", "starts? with", + "begins? with", "ends? with", "contains?", "does not contain", + "doesn't contain", "is in", "is contained by", "is not in", + "is not contained by", "isn't contained by", "div", "mod", + "not", "(a )?(ref( to)?|reference to)", "is", "does"] + end + + def self.controls + @controls ||= ['considering', 'else', 'error', 'exit', 'from', 'if', + 'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to', + 'try', 'until', 'using terms from', 'while', 'whith', + 'with timeout( of)?', 'with transaction', 'by', 'continue', + 'end', 'its?', 'me', 'my', 'return', 'of' , 'as'] + end + + def self.declarations + @declarations ||= ['global', 'local', 'prop(erty)?', 'set', 'get'] + end + + def self.reserved + @reserved ||= ['but', 'put', 'returning', 'the'] + end + + def self.studio_classes + @studio_classes ||= ['action cell', 'alert reply', 'application', 'box', + 'browser( cell)?', 'bundle', 'button( cell)?', 'cell', + 'clip view', 'color well', 'color-panel', + 'combo box( item)?', 'control', + 'data( (cell|column|item|row|source))?', 'default entry', + 'dialog reply', 'document', 'drag info', 'drawer', + 'event', 'font(-panel)?', 'formatter', + 'image( (cell|view))?', 'matrix', 'menu( item)?', 'item', + 'movie( view)?', 'open-panel', 'outline view', 'panel', + 'pasteboard', 'plugin', 'popup button', + 'progress indicator', 'responder', 'save-panel', + 'scroll view', 'secure text field( cell)?', 'slider', + 'sound', 'split view', 'stepper', 'tab view( item)?', + 'table( (column|header cell|header view|view))', + 'text( (field( cell)?|view))?', 'toolbar( item)?', + 'user-defaults', 'view', 'window'] + end + + def self.studio_events + @studio_events ||= ['accept outline drop', 'accept table drop', 'action', + 'activated', 'alert ended', 'awake from nib', 'became key', + 'became main', 'begin editing', 'bounds changed', + 'cell value', 'cell value changed', 'change cell value', + 'change item value', 'changed', 'child of item', + 'choose menu item', 'clicked', 'clicked toolbar item', + 'closed', 'column clicked', 'column moved', + 'column resized', 'conclude drop', 'data representation', + 'deminiaturized', 'dialog ended', 'document nib name', + 'double clicked', 'drag( (entered|exited|updated))?', + 'drop', 'end editing', 'exposed', 'idle', 'item expandable', + 'item value', 'item value changed', 'items changed', + 'keyboard down', 'keyboard up', 'launched', + 'load data representation', 'miniaturized', 'mouse down', + 'mouse dragged', 'mouse entered', 'mouse exited', + 'mouse moved', 'mouse up', 'moved', + 'number of browser rows', 'number of items', + 'number of rows', 'open untitled', 'opened', 'panel ended', + 'parameters updated', 'plugin loaded', 'prepare drop', + 'prepare outline drag', 'prepare outline drop', + 'prepare table drag', 'prepare table drop', + 'read from file', 'resigned active', 'resigned key', + 'resigned main', 'resized( sub views)?', + 'right mouse down', 'right mouse dragged', + 'right mouse up', 'rows changed', 'scroll wheel', + 'selected tab view item', 'selection changed', + 'selection changing', 'should begin editing', + 'should close', 'should collapse item', + 'should end editing', 'should expand item', + 'should open( untitled)?', + 'should quit( after last window closed)?', + 'should select column', 'should select item', + 'should select row', 'should select tab view item', + 'should selection change', 'should zoom', 'shown', + 'update menu item', 'update parameters', + 'update toolbar item', 'was hidden', 'was miniaturized', + 'will become active', 'will close', 'will dismiss', + 'will display browser cell', 'will display cell', + 'will display item cell', 'will display outline cell', + 'will finish launching', 'will hide', 'will miniaturize', + 'will move', 'will open', 'will pop up', 'will quit', + 'will resign active', 'will resize( sub views)?', + 'will select tab view item', 'will show', 'will zoom', + 'write to file', 'zoomed'] + end + + def self.studio_commands + @studio_commands ||= ['animate', 'append', 'call method', 'center', + 'close drawer', 'close panel', 'display', + 'display alert', 'display dialog', 'display panel', 'go', + 'hide', 'highlight', 'increment', 'item for', + 'load image', 'load movie', 'load nib', 'load panel', + 'load sound', 'localized string', 'lock focus', 'log', + 'open drawer', 'path for', 'pause', 'perform action', + 'play', 'register', 'resume', 'scroll', 'select( all)?', + 'show', 'size to fit', 'start', 'step back', + 'step forward', 'stop', 'synchronize', 'unlock focus', + 'update'] + end + + def self.studio_properties + @studio_properties ||= ['accepts arrow key', 'action method', 'active', + 'alignment', 'allowed identifiers', + 'allows branch selection', 'allows column reordering', + 'allows column resizing', 'allows column selection', + 'allows customization', 'allows editing text attributes', + 'allows empty selection', 'allows mixed state', + 'allows multiple selection', 'allows reordering', + 'allows undo', 'alpha( value)?', 'alternate image', + 'alternate increment value', 'alternate title', + 'animation delay', 'associated file name', + 'associated object', 'auto completes', 'auto display', + 'auto enables items', 'auto repeat', 'auto resizes( outline column)?', + 'auto save expanded items', 'auto save name', + 'auto save table columns', 'auto saves configuration', + 'auto scroll', 'auto sizes all columns to fit', + 'auto sizes cells', 'background color', 'bezel state', + 'bezel style', 'bezeled', 'border rect', 'border type', + 'bordered', 'bounds( rotation)?', 'box type', + 'button returned', 'button type', + 'can choose directories', 'can choose files', 'can draw', 'can hide', + 'cell( (background color|size|type))?', 'characters', + 'class', 'click count', 'clicked( data)? column', + 'clicked data item', 'clicked( data)? row', + 'closeable', 'collating', 'color( (mode|panel))', + 'command key down', 'configuration', + 'content(s| (size|view( margins)?))?', 'context', + 'continuous', 'control key down', 'control size', + 'control tint', 'control view', + 'controller visible', 'coordinate system', + 'copies( on scroll)?', 'corner view', 'current cell', + 'current column', 'current( field)? editor', + 'current( menu)? item', 'current row', + 'current tab view item', 'data source', + 'default identifiers', 'delta (x|y|z)', + 'destination window', 'directory', 'display mode', + 'displayed cell', 'document( (edited|rect|view))?', + 'double value', 'dragged column', 'dragged distance', + 'dragged items', 'draws( cell)? background', + 'draws grid', 'dynamically scrolls', 'echos bullets', + 'edge', 'editable', 'edited( data)? column', + 'edited data item', 'edited( data)? row', 'enabled', + 'enclosing scroll view', 'ending page', + 'error handling', 'event number', 'event type', + 'excluded from windows menu', 'executable path', + 'expanded', 'fax number', 'field editor', 'file kind', + 'file name', 'file type', 'first responder', + 'first visible column', 'flipped', 'floating', + 'font( panel)?', 'formatter', 'frameworks path', + 'frontmost', 'gave up', 'grid color', 'has data items', + 'has horizontal ruler', 'has horizontal scroller', + 'has parent data item', 'has resize indicator', + 'has shadow', 'has sub menu', 'has vertical ruler', + 'has vertical scroller', 'header cell', 'header view', + 'hidden', 'hides when deactivated', 'highlights by', + 'horizontal line scroll', 'horizontal page scroll', + 'horizontal ruler view', 'horizontally resizable', + 'icon image', 'id', 'identifier', + 'ignores multiple clicks', + 'image( (alignment|dims when disabled|frame style|scaling))?', + 'imports graphics', 'increment value', + 'indentation per level', 'indeterminate', 'index', + 'integer value', 'intercell spacing', 'item height', + 'key( (code|equivalent( modifier)?|window))?', + 'knob thickness', 'label', 'last( visible)? column', + 'leading offset', 'leaf', 'level', 'line scroll', + 'loaded', 'localized sort', 'location', 'loop mode', + 'main( (bunde|menu|window))?', 'marker follows cell', + 'matrix mode', 'maximum( content)? size', + 'maximum visible columns', + 'menu( form representation)?', 'miniaturizable', + 'miniaturized', 'minimized image', 'minimized title', + 'minimum column width', 'minimum( content)? size', + 'modal', 'modified', 'mouse down state', + 'movie( (controller|file|rect))?', 'muted', 'name', + 'needs display', 'next state', 'next text', + 'number of tick marks', 'only tick mark values', + 'opaque', 'open panel', 'option key down', + 'outline table column', 'page scroll', 'pages across', + 'pages down', 'palette label', 'pane splitter', + 'parent data item', 'parent window', 'pasteboard', + 'path( (names|separator))?', 'playing', + 'plays every frame', 'plays selection only', 'position', + 'preferred edge', 'preferred type', 'pressure', + 'previous text', 'prompt', 'properties', + 'prototype cell', 'pulls down', 'rate', + 'released when closed', 'repeated', + 'requested print time', 'required file type', + 'resizable', 'resized column', 'resource path', + 'returns records', 'reuses columns', 'rich text', + 'roll over', 'row height', 'rulers visible', + 'save panel', 'scripts path', 'scrollable', + 'selectable( identifiers)?', 'selected cell', + 'selected( data)? columns?', 'selected data items?', + 'selected( data)? rows?', 'selected item identifier', + 'selection by rect', 'send action on arrow key', + 'sends action when done editing', 'separates columns', + 'separator item', 'sequence number', 'services menu', + 'shared frameworks path', 'shared support path', + 'sheet', 'shift key down', 'shows alpha', + 'shows state by', 'size( mode)?', + 'smart insert delete enabled', 'sort case sensitivity', + 'sort column', 'sort order', 'sort type', + 'sorted( data rows)?', 'sound', 'source( mask)?', + 'spell checking enabled', 'starting page', 'state', + 'string value', 'sub menu', 'super menu', 'super view', + 'tab key traverses cells', 'tab state', 'tab type', + 'tab view', 'table view', 'tag', 'target( printer)?', + 'text color', 'text container insert', + 'text container origin', 'text returned', + 'tick mark position', 'time stamp', + 'title(d| (cell|font|height|position|rect))?', + 'tool tip', 'toolbar', 'trailing offset', 'transparent', + 'treat packages as directories', 'truncated labels', + 'types', 'unmodified characters', 'update views', + 'use sort indicator', 'user defaults', + 'uses data source', 'uses ruler', 'uses threaded animation', + 'uses title from previous column', 'value wraps', 'version', + 'vertical( (line scroll|page scroll|ruler view))?', 'vertically resizable', 'view', + 'visible( document rect)?', 'volume', 'width', 'window', + 'windows menu', 'wraps', 'zoomable', 'zoomed'] + end + + operators = %r(\b(#{self.operators.to_a.join('|')})\b) + classes = %r(\b(as )(#{self.classes.to_a.join('|')})\b) + literals = %r(\b(#{self.literals.to_a.join('|')})\b) + commands = %r(\b(#{self.commands.to_a.join('|')})\b) + controls = %r(\b(#{self.controls.to_a.join('|')})\b) + declarations = %r(\b(#{self.declarations.to_a.join('|')})\b) + reserved = %r(\b(#{self.reserved.to_a.join('|')})\b) + builtins = %r(\b(#{self.builtins.to_a.join('|')})s?\b) + handler_params = %r(\b(#{self.handler_params.to_a.join('|')})\b) + references = %r(\b(#{self.references.to_a.join('|')})\b) + studio_properties = %r(\b(#{self.studio_properties.to_a.join('|')})\b) + studio_classes = %r(\b(#{self.studio_classes.to_a.join('|')})s?\b) + studio_commands = %r(\b(#{self.studio_commands.to_a.join('|')})\b) + identifiers = %r(\b([a-zA-Z]\w*)\b) + + state :root do + rule %r/\s+/, Text::Whitespace + rule %r/¬\n/, Literal::String::Escape + rule %r/'s\s+/, Text + rule %r/(--|#).*?$/, Comment::Single + rule %r/\(\*/, Comment::Multiline + rule %r/[\(\){}!,.:]/, Punctuation + rule %r/(«)([^»]+)(»)/ do |match| + token Text, match[1] + token Name::Builtin, match[2] + token Text, match[3] + end + rule %r/\b((?:considering|ignoring)\s*)(application responses|case|diacriticals|hyphens|numeric strings|punctuation|white space)/ do |match| + token Keyword, match[1] + token Name::Builtin, match[2] + end + rule %r/(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|\/|÷|\^)/, Operator + rule operators, Operator::Word + rule %r/^(\s*(?:on|end)\s+)'r'(%s)/ do |match| + token Keyword, match[1] + token Name::Function, match[2] + end + rule %r/^(\s*)(in|on|script|to)(\s+)/ do |match| + token Text, match[1] + token Keyword, match[2] + token Text, match[3] + end + rule classes do |match| + token Keyword, match[1] + token Name::Class, match[2] + end + rule literals, Name::Builtin + rule commands, Name::Builtin + rule controls, Keyword + rule declarations, Keyword + rule reserved, Name::Builtin + rule builtins, Name::Builtin + rule handler_params, Name::Builtin + rule studio_properties, Name::Attribute + rule studio_classes, Name::Builtin + rule studio_commands, Name::Builtin + rule references, Name::Builtin + rule %r/"(\\\\|\\"|[^"])*"/, Literal::String::Double + rule identifiers, Name::Variable + rule %r/[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?/, Literal::Number::Float + rule %r/[-+]?\d+/, Literal::Number::Integer + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/armasm.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/armasm.rb new file mode 100644 index 0000000..51b4a38 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/armasm.rb @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class ArmAsm < RegexLexer + title "ArmAsm" + desc "Arm assembly syntax" + tag 'armasm' + filenames '*.s' + + def self.preproc_keyword + @preproc_keyword ||= %w( + define elif else endif error if ifdef ifndef include line pragma undef warning + ) + end + + def self.file_directive + @file_directive ||= %w( + BIN GET INCBIN INCLUDE LNK + ) + end + + def self.general_directive + @general_directive ||= %w( + ALIAS ALIGN AOF AOUT AREA ARM ASSERT ATTR CN CODE16 CODE32 COMMON CP + DATA DCB DCD DCDO DCDU DCFD DCFDU DCFH DCFHU DCFS DCFSU DCI DCI.N DCI.W + DCQ DCQU DCW DCWU DN ELIF ELSE END ENDFUNC ENDIF ENDP ENTRY EQU EXPORT + EXPORTAS EXTERN FIELD FILL FN FRAME FUNCTION GBLA GBLL GBLS GLOBAL IF + IMPORT INFO KEEP LCLA LCLL LCLS LEADR LEAF LTORG MACRO MAP MEND MEXIT + NOFP OPT ORG PRESERVE8 PROC QN RELOC REQUIRE REQUIRE8 RLIST RN ROUT + SETA SETL SETS SN SPACE STRONG SUBT THUMB THUMBX TTL WEND WHILE + \[ \] [|!#*=%&^] + ) + end + + def self.shift_or_condition + @shift_or_condition ||= %w( + ASR LSL LSR ROR RRX AL CC CS EQ GE GT HI HS LE LO LS LT MI NE PL VC VS + asr lsl lsr ror rrx al cc cs eq ge gt hi hs le lo ls lt mi ne pl vc vs + ) + end + + def self.builtin + @builtin ||= %w( + ARCHITECTURE AREANAME ARMASM_VERSION CODESIZE COMMANDLINE CONFIG CPU + ENDIAN FALSE FPIC FPU INPUTFILE INTER LINENUM LINENUMUP LINENUMUPPER + OBJASM_VERSION OPT PC PCSTOREOFFSET REENTRANT ROPI RWPI TRUE VAR + ) + end + + def self.operator + @operator ||= %w( + AND BASE CC CC_ENCODING CHR DEF EOR FATTR FEXEC FLOAD FSIZE INDEX LAND + LEFT LEN LEOR LNOT LOR LOWERCASE MOD NOT OR RCONST REVERSE_CC RIGHT ROL + ROR SHL SHR STR TARGET_ARCH_[0-9A-Z_]+ TARGET_FEATURE_[0-9A-Z_]+ + TARGET_FPU_[A-Z_] TARGET_PROFILE_[ARM] UAL UPPERCASE + ) + end + + state :root do + rule %r/\n/, Text + rule %r/^([ \t]*)(#[ \t]*(?:(?:#{ArmAsm.preproc_keyword.join('|')})(?:[ \t].*)?)?)(\n)/ do + groups Text, Comment::Preproc, Text + end + rule %r/[ \t]+/, Text, :command + rule %r/;.*/, Comment + rule %r/\$[a-z_]\w*\.?/i, Name::Namespace # variable substitution or macro argument + rule %r/\w+|\|[^|\n]+\|/, Name::Label + end + + state :command do + rule %r/\n/, Text, :pop! + rule %r/[ \t]+/ do |m| + token Text + goto :args + end + rule %r/;.*/, Comment, :pop! + rule %r/(?:#{ArmAsm.file_directive.join('|')})\b/ do |m| + token Keyword + goto :filespec + end + rule %r/(?:#{ArmAsm.general_directive.join('|')})(?=[; \t\n])/, Keyword + rule %r/(?:[A-Z][\dA-Z]*|[a-z][\da-z]*)(?:\.[NWnw])?(?:\.[DFIPSUdfipsu]?(?:8|16|32|64)?){,3}\b/, Name::Builtin # rather than attempt to list all opcodes, rely on all-uppercase or all-lowercase rule + rule %r/[a-z_]\w*|\|[^|\n]+\|/i, Name::Function # probably a macro name + rule %r/\$[a-z]\w*\.?/i, Name::Namespace + end + + state :args do + rule %r/\n/, Text, :pop! + rule %r/[ \t]+/, Text + rule %r/;.*/, Comment, :pop! + rule %r/(?:#{ArmAsm.shift_or_condition.join('|')})\b/, Name::Builtin + rule %r/[a-z_]\w*|\|[^|\n]+\|/i, Name::Variable # various types of symbol + rule %r/%[bf]?[at]?\d+(?:[a-z_]\w*)?/i, Name::Label + rule %r/(?:&|0x)\h+(?!p)/i, Literal::Number::Hex + rule %r/(?:&|0x)[.\h]+(?:p[-+]?\d+)?/i, Literal::Number::Float + rule %r/0f_\h{8}|0d_\h{16}/i, Literal::Number::Float + rule %r/(?:2_[01]+|3_[0-2]+|4_[0-3]+|5_[0-4]+|6_[0-5]+|7_[0-6]+|8_[0-7]+|9_[0-8]+|\d+)(?!e)/i, Literal::Number::Integer + rule %r/(?:2_[.01]+|3_[.0-2]+|4_[.0-3]+|5_[.0-4]+|6_[.0-5]+|7_[.0-6]+|8_[.0-7]+|9_[.0-8]+|[.\d]+)(?:e[-+]?\d+)?/i, Literal::Number::Float + rule %r/[@:](?=[ \t]*(?:8|16|32|64|128|256)[^\d])/, Operator + rule %r/[.@]|\{(?:#{ArmAsm.builtin.join('|')})\}/, Name::Constant + rule %r/[-!#%&()*+,\/<=>?^{|}]|\[|\]|!=|&&|\/=|<<|<=|<>|==|><|>=|>>|\|\||:(?:#{ArmAsm.operator.join('|')}):/, Operator + rule %r/\$[a-z]\w*\.?/i, Name::Namespace + rule %r/'/ do |m| + token Literal::String::Char + goto :singlequoted + end + rule %r/"/ do |m| + token Literal::String::Double + goto :doublequoted + end + end + + state :singlequoted do + rule %r/\n/, Text, :pop! + rule %r/\$\$/, Literal::String::Char + rule %r/\$[a-z]\w*\.?/i, Name::Namespace + rule %r/'/ do |m| + token Literal::String::Char + goto :args + end + rule %r/[^$'\n]+/, Literal::String::Char + end + + state :doublequoted do + rule %r/\n/, Text, :pop! + rule %r/\$\$/, Literal::String::Double + rule %r/\$[a-z]\w*\.?/i, Name::Namespace + rule %r/"/ do |m| + token Literal::String::Double + goto :args + end + rule %r/[^$"\n]+/, Literal::String::Double + end + + state :filespec do + rule %r/\n/, Text, :pop! + rule %r/\$\$/, Literal::String::Other + rule %r/\$[a-z]\w*\.?/i, Name::Namespace + rule %r/[^$\n]+/, Literal::String::Other + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/augeas.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/augeas.rb new file mode 100644 index 0000000..2fda76f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/augeas.rb @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Augeas < RegexLexer + title "Augeas" + desc "The Augeas programming language (augeas.net)" + + tag 'augeas' + aliases 'aug' + filenames '*.aug' + mimetypes 'text/x-augeas' + + def self.reserved + @reserved ||= Set.new %w( + _ let del store value counter seq key label autoload incl excl + transform test get put in after set clear insa insb print_string + print_regexp print_endline print_tree lens_ctype lens_atype + lens_ktype lens_vtype lens_format_atype regexp_match + ) + end + + state :basic do + rule %r/\s+/m, Text + rule %r/\(\*/, Comment::Multiline, :comment + end + + state :comment do + rule %r/\*\)/, Comment::Multiline, :pop! + rule %r/\(\*/, Comment::Multiline, :comment + rule %r/[^*)]+/, Comment::Multiline + rule %r/[*)]/, Comment::Multiline + end + + state :root do + mixin :basic + + rule %r/(:)(\w\w*)/ do + groups Punctuation, Keyword::Type + end + + rule %r/\w[\w']*/ do |m| + name = m[0] + if name == "module" + token Keyword::Reserved + push :module + elsif self.class.reserved.include? name + token Keyword::Reserved + elsif name =~ /\A[A-Z]/ + token Keyword::Namespace + else + token Name + end + end + + rule %r/"/, Str, :string + rule %r/\//, Str, :regexp + + rule %r([-*+.=?\|]+), Operator + rule %r/[\[\](){}:;]/, Punctuation + end + + state :module do + rule %r/\s+/, Text + rule %r/[A-Z][a-zA-Z0-9_.]*/, Name::Namespace, :pop! + end + + state :regexp do + rule %r/\//, Str::Regex, :pop! + rule %r/[^\\\/]+/, Str::Regex + rule %r/\\[\\\/]/, Str::Regex + rule %r/\\/, Str::Regex + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\/, Str::Escape, :escape + rule %r/[^\\"]+/, Str + end + + state :escape do + rule %r/[abfnrtv"'&\\]/, Str::Escape, :pop! + rule %r/\^[\]\[A-Z@\^_]/, Str::Escape, :pop! + rule %r/o[0-7]+/i, Str::Escape, :pop! + rule %r/x[\da-f]+/i, Str::Escape, :pop! + rule %r/\d+/, Str::Escape, :pop! + rule %r/\s+/, Str::Escape, :pop! + rule %r/./, Str, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/awk.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/awk.rb new file mode 100644 index 0000000..8301f86 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/awk.rb @@ -0,0 +1,162 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Awk < RegexLexer + title "Awk" + desc "pattern-directed scanning and processing language" + + tag 'awk' + filenames '*.awk' + mimetypes 'application/x-awk' + + def self.detect?(text) + return true if text.shebang?('awk') + end + + id = /[$a-zA-Z_][a-zA-Z0-9_]*/ + + def self.keywords + @keywords ||= Set.new %w( + if else while for do break continue return next nextfile delete + exit print printf getline + ) + end + + def self.declarations + @declarations ||= Set.new %w(function) + end + + def self.reserved + @reserved ||= Set.new %w(BEGIN END) + end + + def self.constants + @constants ||= Set.new %w( + CONVFMT FS NF NR FNR FILENAME RS OFS ORS OFMT SUBSEP ARGC ARGV + ENVIRON + ) + end + + def self.builtins + @builtins ||= %w( + exp log sqrt sin cos atan2 length rand srand int substr index match + split sub gsub sprintf system tolower toupper + ) + end + + state :comments_and_whitespace do + rule %r/\s+/, Text + rule %r(#.*?$), Comment::Single + end + + state :expr_start do + mixin :comments_and_whitespace + rule %r(/) do + token Str::Regex + goto :regex + end + rule %r//, Text, :pop! + end + + state :regex do + rule %r(/) do + token Str::Regex + goto :regex_end + end + + rule %r([^/]\n), Error, :pop! + + rule %r/\n/, Error, :pop! + rule %r/\[\^/, Str::Escape, :regex_group + rule %r/\[/, Str::Escape, :regex_group + rule %r/\\./, Str::Escape + rule %r{[(][?][:=+*/%\^!=]=?|in\b|\+\+|--|\|), Operator, :expr_start + rule %r(&&|\|\||~!?), Operator, :expr_start + rule %r/[(\[,]/, Punctuation, :expr_start + rule %r/;/, Punctuation, :statement + rule %r/[)\].]/, Punctuation + + rule %r/[?]/ do + token Punctuation + push :ternary + push :expr_start + end + + rule %r/[{}]/, Punctuation, :statement + + rule id do |m| + if self.class.keywords.include? m[0] + token Keyword + push :expr_start + elsif self.class.declarations.include? m[0] + token Keyword::Declaration + push :expr_start + elsif self.class.reserved.include? m[0] + token Keyword::Reserved + elsif self.class.constants.include? m[0] + token Keyword::Constant + elsif self.class.builtins.include? m[0] + token Name::Builtin + elsif m[0] =~ /^\$/ + token Name::Variable + else + token Name::Other + end + end + + rule %r/[0-9]+\.[0-9]+/, Num::Float + rule %r/[0-9]+/, Num::Integer + rule %r/"(\\[\\"]|[^"])*"/, Str::Double + rule %r/:/, Punctuation + end + + state :statement do + rule %r/[{}]/, Punctuation + mixin :expr_start + end + + state :ternary do + rule %r/:/ do + token Punctuation + goto :expr_start + end + + mixin :root + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/batchfile.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/batchfile.rb new file mode 100644 index 0000000..cc61d85 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/batchfile.rb @@ -0,0 +1,165 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Batchfile < RegexLexer + title "Batchfile" + desc "Windows Batch File" + + tag 'batchfile' + aliases 'bat', 'batch', 'dosbatch', 'winbatch' + filenames '*.bat', '*.cmd' + + mimetypes 'application/bat', 'application/x-bat', 'application/x-msdos-program' + + def self.keywords + @keywords ||= %w( + if else for in do goto call exit + ) + end + + def self.operator_words + @operator_words ||= %w( + exist defined errorlevel cmdextversion not equ neq lss leq gtr geq + ) + end + + def self.devices + @devices ||= %w( + con prn aux nul com1 com2 com3 com4 com5 com6 com7 com8 com9 lpt1 lpt2 + lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9 + ) + end + + def self.builtin_commands + @builtin_commands ||= %w( + assoc attrib break bcdedit cacls cd chcp chdir chkdsk chkntfs choice + cls cmd color comp compact convert copy date del dir diskpart doskey + dpath driverquery echo endlocal erase fc find findstr format fsutil + ftype gpresult graftabl help icacls label md mkdir mklink mode more + move openfiles path pause popd print prompt pushd rd recover ren + rename replace rmdir robocopy setlocal sc schtasks shift shutdown sort + start subst systeminfo takeown tasklist taskkill time timeout title + tree type ver verify vol xcopy waitfor wmic + ) + end + + def self.other_commands + @other_commands ||= %w( + addusers admodcmd ansicon arp at bcdboot bitsadmin browstat certreq + certutil change cidiag cipher cleanmgr clip cmdkey compress convertcp + coreinfo csccmd csvde cscript curl debug defrag delprof deltree devcon + diamond dirquota diruse diskshadow diskuse dism dnscmd dsacls dsadd + dsget dsquery dsmod dsmove dsrm dsmgmt dsregcmd edlin eventcreate + expand extract fdisk fltmc forfiles freedisk ftp getmac gpupdate + hostname ifmember inuse ipconfig kill lgpo lodctr logman logoff + logtime makecab mapisend mbsacli mem mountvol moveuser msg mshta + msiexec msinfo32 mstsc nbtstat net net1 netdom netsh netstat nlsinfo + nltest now nslookup ntbackup ntdsutil ntoskrnl ntrights nvspbind + pathping perms ping portqry powercfg pngout pnputil printbrm prncnfg + prnmngr procdump psexec psfile psgetsid psinfo pskill pslist + psloggedon psloglist pspasswd psping psservice psshutdown pssuspend + qbasic qgrep qprocess query quser qwinsta rasdial reg reg1 regdump + regedt32 regsvr32 regini reset restore rundll32 rmtshare route rpcping + run runas scandisk setspn setx sfc share shellrunas shortcut sigcheck + sleep slmgr strings subinacl sysmon telnet tftp tlist touch tracerpt + tracert tscon tsdiscon tskill tttracer typeperf tzutil undelete + unformat verifier vmconnect vssadmin w32tm wbadmin wecutil wevtutil + wget where whoami windiff winrm winrs wpeutil wpr wusa wuauclt wscript + ) + end + + def self.attributes + @attributes ||= %w( + on off disable enableextensions enabledelayedexpansion + ) + end + + state :basic do + # Comments + rule %r/@?\brem\b.*$/i, Comment + + # Empty Labels + rule %r/^::.*$/, Comment + + # Labels + rule %r/:[a-z]+/i, Name::Label + + rule %r/([a-z]\w*)(\.exe|com|bat|cmd|msi)?/i do |m| + if self.class.devices.include? m[1] + groups Keyword::Reserved, Error + elsif self.class.keywords.include? m[1] + groups Keyword, Error + elsif self.class.operator_words.include? m[1] + groups Operator::Word, Error + elsif self.class.builtin_commands.include? m[1] + token Name::Builtin + elsif self.class.other_commands.include? m[1] + token Name::Builtin + elsif self.class.attributes.include? m[1] + groups Name::Attribute, Error + elsif "set".casecmp m[1] + groups Keyword::Declaration, Error + else + token Text + end + end + + rule %r/((?:[\/\+]|--?)[a-z]+)\s*/i, Name::Attribute + + mixin :expansions + + rule %r/[<>&|(){}\[\]\-+=;,~?*]/, Operator + end + + state :escape do + rule %r/\^./m, Str::Escape + end + + state :expansions do + # Normal and Delayed expansion + rule %r/[%!]+([a-z_$@#]+)[%!]+/i, Name::Variable + # For Variables + rule %r/(\%+~?[a-z]+\d?)/i, Name::Variable::Magic + end + + state :double_quotes do + mixin :escape + rule %r/["]/, Str::Double, :pop! + mixin :expansions + rule %r/[^\^"%!]+/, Str::Double + end + + state :single_quotes do + mixin :escape + rule %r/[']/, Str::Single, :pop! + mixin :expansions + rule %r/[^\^'%!]+/, Str::Single + end + + state :backtick do + mixin :escape + rule %r/[`]/, Str::Backtick, :pop! + mixin :expansions + rule %r/[^\^`%!]+/, Str::Backtick + end + + state :data do + rule %r/\s+/, Text + rule %r/0x[0-9a-f]+/i, Literal::Number::Hex + rule %r/[0-9]/, Literal::Number + rule %r/["]/, Str::Double, :double_quotes + rule %r/[']/, Str::Single, :single_quotes + rule %r/[`]/, Str::Backtick, :backtick + rule %r/[^\s&|()\[\]{}\^=;!%+\-,"'`~?*]+/, Text + mixin :escape + end + + state :root do + mixin :basic + mixin :data + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bbcbasic.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bbcbasic.rb new file mode 100644 index 0000000..c64a1b6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bbcbasic.rb @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class BBCBASIC < RegexLexer + title "BBCBASIC" + desc "BBC BASIC syntax" + tag 'bbcbasic' + filenames '*,fd1' + + def self.punctuation + @punctuation ||= %w( + [,;'~] SPC TAB + ) + end + + def self.function + @function ||= %w( + ABS ACS ADVAL ASC ASN ATN BEATS BEAT BGET# CHR\$ COS COUNT DEG DIM + EOF# ERL ERR EVAL EXP EXT# FN GET\$# GET\$ GET HIMEM INKEY\$ INKEY + INSTR INT LEFT\$ LEN LN LOG LOMEM MID\$ OPENIN OPENOUT OPENUP PAGE + POINT POS PTR# RAD REPORT\$ RIGHT\$ RND SGN SIN SQR STR\$ STRING\$ SUM + SUMLEN TAN TEMPO TIME\$ TIME TOP USR VAL VPOS + ) + end + + def self.statement + @statement ||= %w( + BEATS BPUT# CALL CASE CHAIN CLEAR CLG CLOSE# CLS COLOR COLOUR DATA + ELSE ENDCASE ENDIF ENDPROC ENDWHILE END ENVELOPE FOR GCOL GOSUB GOTO + IF INSTALL LET LIBRARY MODE NEXT OFF OF ON ORIGIN OSCI OTHERWISE + OVERLAY PLOT PRINT# PRINT PROC QUIT READ REPEAT REPORT RETURN SOUND + STEP STEREO STOP SWAP SYS THEN TINT TO VDU VOICES VOICE UNTIL WAIT + WHEN WHILE WIDTH + ) + end + + def self.operator + @operator ||= %w( + << <= <> < >= >>> >> > [-!$()*+/=?^|] AND DIV EOR MOD NOT OR + ) + end + + def self.constant + @constant ||= %w( + FALSE TRUE + ) + end + + state :expression do + rule %r/#{BBCBASIC.function.join('|')}/o, Name::Builtin # function or pseudo-variable + rule %r/#{BBCBASIC.operator.join('|')}/o, Operator + rule %r/#{BBCBASIC.constant.join('|')}/o, Name::Constant + rule %r/"[^"]*"/o, Literal::String + rule %r/[a-z_`][\w`]*[$%]?/io, Name::Variable + rule %r/@%/o, Name::Variable + rule %r/[\d.]+/o, Literal::Number + rule %r/%[01]+/o, Literal::Number::Bin + rule %r/&[\h]+/o, Literal::Number::Hex + end + + state :root do + rule %r/(:+)( *)(\*)(.*)/ do + groups Punctuation, Text, Keyword, Text # CLI command + end + rule %r/(\n+ *)(\*)(.*)/ do + groups Text, Keyword, Text # CLI command + end + rule %r/(ELSE|OTHERWISE|REPEAT|THEN)( *)(\*)(.*)/ do + groups Keyword, Text, Keyword, Text # CLI command + end + rule %r/[ \n]+/o, Text + rule %r/:+/o, Punctuation + rule %r/[\[]/o, Keyword, :assembly1 + rule %r/REM *>.*/o, Comment::Special + rule %r/REM.*/o, Comment + rule %r/(?:#{BBCBASIC.statement.join('|')}|CIRCLE(?: *FILL)?|DEF *(?:FN|PROC)|DRAW(?: *BY)?|DIM(?!\()|ELLIPSE(?: *FILL)?|ERROR(?: *EXT)?|FILL(?: *BY)?|INPUT(?:#| *LINE)?|LINE(?: *INPUT)?|LOCAL(?: *DATA| *ERROR)?|MOUSE(?: *COLOUR| *OFF| *ON| *RECTANGLE| *STEP| *TO)?|MOVE(?: *BY)?|ON(?! *ERROR)|ON *ERROR *(?:LOCAL|OFF)?|POINT(?: *BY)?(?!\()|RECTANGE(?: *FILL)?|RESTORE(?: *DATA| *ERROR)?|TRACE(?: *CLOSE| *ENDPROC| *OFF| *STEP(?: *FN| *ON| *PROC)?| *TO)?)/o, Keyword + mixin :expression + rule %r/#{BBCBASIC.punctuation.join('|')}/o, Punctuation + end + + # Assembly statements are parsed as + # {label} {directive|opcode |']' {expressions}} {comment} + # Technically, you don't need whitespace between opcodes and arguments, + # but this is rare in uncrunched source and trying to enumerate all + # possible opcodes here is impractical so we colour it as though + # the whitespace is required. Opcodes and directives can only easily be + # distinguished from the symbols that make up expressions by looking at + # their position within the statement. Similarly, ']' is treated as a + # keyword at the start of a statement or as punctuation elsewhere. This + # requires a two-state state machine. + + state :assembly1 do + rule %r/ +/o, Text + rule %r/]/o, Keyword, :pop! + rule %r/[:\n]/o, Punctuation + rule %r/\.[a-z_`][\w`]*%? */io, Name::Label + rule %r/(?:REM|;)[^:\n]*/o, Comment + rule %r/[^ :\n]+/o, Keyword, :assembly2 + end + + state :assembly2 do + rule %r/ +/o, Text + rule %r/[:\n]/o, Punctuation, :pop! + rule %r/(?:REM|;)[^:\n]*/o, Comment, :pop! + mixin :expression + rule %r/[!#,@\[\]^{}]/, Punctuation + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bibtex.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bibtex.rb new file mode 100644 index 0000000..cc6ece7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bibtex.rb @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# Regular expressions based on https://github.com/SaswatPadhi/prismjs-bibtex +# and https://github.com/alecthomas/chroma/blob/master/lexers/b/bibtex.go + +module Rouge + module Lexers + class BibTeX < RegexLexer + title 'BibTeX' + desc "BibTeX" + tag 'bibtex' + aliases 'bib' + filenames '*.bib' + + valid_punctuation = Regexp.quote("@!$&.\\:;<>?[]^`|~*/+-") + valid_name = /[a-z_#{valid_punctuation}][\w#{valid_punctuation}]*/io + + state :root do + mixin :whitespace + + rule %r/@(#{valid_name})/o do |m| + match = m[1].downcase + + if match == "comment" + token Comment + elsif match == "preamble" + token Name::Class + push :closing_brace + push :value + push :opening_brace + elsif match == "string" + token Name::Class + push :closing_brace + push :field + push :opening_brace + else + token Name::Class + push :closing_brace + push :command_body + push :opening_brace + end + end + + rule %r/.+/, Comment + end + + state :opening_brace do + mixin :whitespace + rule %r/[{(]/, Punctuation, :pop! + end + + state :closing_brace do + mixin :whitespace + rule %r/[})]/, Punctuation, :pop! + end + + state :command_body do + mixin :whitespace + rule %r/[^\s\,\}]+/ do + token Name::Label + pop! + push :fields + end + end + + state :fields do + mixin :whitespace + rule %r/,/, Punctuation, :field + rule(//) { pop! } + end + + state :field do + mixin :whitespace + rule valid_name do + token Name::Attribute + push :value + push :equal_sign + end + rule(//) { pop! } + end + + state :equal_sign do + mixin :whitespace + rule %r/=/, Punctuation, :pop! + end + + state :value do + mixin :whitespace + rule valid_name, Name::Variable + rule %r/"/, Literal::String, :quoted_string + rule %r/\{/, Literal::String, :braced_string + rule %r/\d+/, Literal::Number + rule %r/#/, Punctuation + rule(//) { pop! } + end + + state :quoted_string do + rule %r/\{/, Literal::String, :braced_string + rule %r/"/, Literal::String, :pop! + rule %r/[^\{\"]+/, Literal::String + end + + state :braced_string do + rule %r/\{/, Literal::String, :braced_string + rule %r/\}/, Literal::String, :pop! + rule %r/[^\{\}]+/, Literal::String + end + + state :whitespace do + rule %r/\s+/, Text + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/biml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/biml.rb new file mode 100644 index 0000000..602a57a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/biml.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'xml.rb' + + class BIML < XML + title "BIML" + desc "BIML, Business Intelligence Markup Language" + tag 'biml' + filenames '*.biml' + + def self.detect?(text) + return true if text =~ /<\s*Biml\b/ + end + + prepend :root do + rule %r(<#\@\s*)m, Name::Tag, :directive_tag + + rule %r(<#[=]?\s*)m, Name::Tag, :directive_as_csharp + end + + prepend :attr do + #TODO: how to deal with embedded <# tags inside a attribute string + #rule %r("<#[=]?\s*)m, Name::Tag, :directive_as_csharp + end + + state :directive_as_csharp do + rule %r/\s*#>\s*/m, Name::Tag, :pop! + rule %r(.*?(?=\s*#>\s*))m do + delegate CSharp + end + end + + state :directive_tag do + rule %r/\s+/m, Text + rule %r/[\w.:-]+\s*=/m, Name::Attribute, :attr + rule %r/\w+\s*/m, Name::Attribute + rule %r(/?\s*#>), Name::Tag, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bpf.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bpf.rb new file mode 100644 index 0000000..cd3307c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bpf.rb @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class BPF < RegexLexer + title "BPF" + desc "BPF bytecode syntax" + tag 'bpf' + + TYPE_KEYWORDS = %w( + u8 u16 u32 u64 s8 s16 s32 s64 ll + ).join('|') + + MISC_KEYWORDS = %w( + be16 be32 be64 le16 le32 le64 bswap16 bswap32 bswap64 exit lock map + ).join('|') + + state :root do + # Line numbers and hexadecimal output from bpftool/objdump + rule %r/(\d+)(:)(\s+)(\(\h{2}\))/i do + groups Generic::Lineno, Punctuation, Text::Whitespace, Generic + end + rule %r/(\d+)(:)(\s+)((?:\h{2} ){8})/i do + groups Generic::Lineno, Punctuation, Text::Whitespace, Generic + end + rule %r/(\d+)(:)(\s+)/i do + groups Generic::Lineno, Punctuation, Text::Whitespace + end + + # Calls to helpers + rule %r/(call)(\s+)(\d+)/i do + groups Keyword, Text::Whitespace, Literal::Number::Integer + end + rule %r/(call)(\s+)(\w+)(?:(#)(\d+))?/i do + groups Keyword, Text::Whitespace, Name::Builtin, Punctuation, Literal::Number::Integer + end + + # Unconditional jumps + rule %r/(gotol?)(\s*)([-+]0x\w+)?([-+]\d+)?(\s*)(?)/i do + groups Keyword, Text::Whitespace, Literal::Number::Hex, Literal::Number::Integer, Text::Whitespace, Name::Label + end + + # Conditional jumps + rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)(0x\h+|[-]?\d+)(\s*)(gotol?)(\s*)([-+]0x\w+)?([-+]\d+)?(\s*)(?)/i do + groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Hex, Literal::Number::Integer, Text::Whitespace, Name::Label + end + rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)([rw]\d+)(\s*)(gotol?)(\s*)([-+]0x\w+)?([-+]\d+)?(\s*)(?)/i do + groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Name, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Hex, Literal::Number::Integer, Text::Whitespace, Name::Label + end + + # Dereferences + rule %r/(\*)(\s*)(\()(#{TYPE_KEYWORDS})(\s*)(\*)(\))/i do + groups Operator, Text::Whitespace, Punctuation, Keyword::Type, Text::Whitespace, Operator, Punctuation + push :address + end + + # Operators + rule %r/[+-\/\*&|><^s]{0,3}=/i, Operator + + # Registers + rule %r/([+-]?)([rw]\d+)/i do + groups Punctuation, Name + end + + # Comments + rule %r/\/\//, Comment::Single, :linecomment + rule %r/\/\*/, Comment::Multiline, :multilinescomment + + rule %r/#{MISC_KEYWORDS}/i, Keyword + + # Literals and global objects (maps) refered by name + rule %r/([-]?0x\h+|[-]?\d+)(\s*)(ll)?/i do + groups Literal::Number, Text::Whitespace, Keyword::Type + end + rule %r/(\w+)(\s*)(ll)/i do + groups Name, Text::Whitespace, Keyword::Type + end + + # Labels + rule %r/(\w+)(\s*)(:)/i do + groups Name::Label, Text::Whitespace, Punctuation + end + + rule %r{.}m, Text + end + + state :address do + # Address is offset from register + rule %r/(\()([rw]\d+)(\s*)([+-])(\s*)(\d+)(\))/i do + groups Punctuation, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number::Integer, Punctuation + pop! + end + + # Address is array subscript + rule %r/(\w+)(\[)(\d+)(\])/i do + groups Name, Punctuation, Literal::Number::Integer, Punctuation + pop! + end + rule %r/(\w+)(\[)([rw]\d+)(\])/i do + groups Name, Punctuation, Name, Punctuation + pop! + end + end + + state :linecomment do + rule %r/\n/, Comment::Single, :pop! + rule %r/.+/, Comment::Single + end + + state :multilinescomment do + rule %r/\*\//, Comment::Multiline, :pop! + rule %r/([^\*\/]+)/, Comment::Multiline + rule %r/([\*\/])/, Comment::Multiline + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/brainfuck.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/brainfuck.rb new file mode 100644 index 0000000..6c25d00 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/brainfuck.rb @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Brainfuck < RegexLexer + tag 'brainfuck' + filenames '*.b', '*.bf' + mimetypes 'text/x-brainfuck' + + title "Brainfuck" + aliases "bf" + desc "The Brainfuck programming language" + + start { push :bol } + + state :bol do + rule %r/\s+/m, Text + rule %r/\[/, Comment::Multiline, :comment_multi + rule(//) { pop! } + end + + state :root do + rule %r/\]/, Error + rule %r/\[/, Punctuation, :loop + + mixin :comment_single + mixin :commands + end + + state :comment_multi do + rule %r/\[/, Comment::Multiline, :comment_multi + rule %r/\]/, Comment::Multiline, :pop! + rule %r/[^\[\]]+?/m, Comment::Multiline + end + + state :comment_single do + rule %r/[^><+\-.,\[\]]+/, Comment::Single + end + + state :loop do + rule %r/\[/, Punctuation, :loop + rule %r/\]/, Punctuation, :pop! + mixin :comment_single + mixin :commands + end + + state :commands do + rule %r/[><]+/, Name::Builtin + rule %r/[+\-.,]+/, Name::Function + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/brightscript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/brightscript.rb new file mode 100644 index 0000000..ebd6336 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/brightscript.rb @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Brightscript < RegexLexer + title "BrightScript" + desc "BrightScript Programming Language (https://developer.roku.com/en-ca/docs/references/brightscript/language/brightscript-language-reference.md)" + tag 'brightscript' + aliases 'bs', 'brs' + filenames '*.brs' + + # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md + # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-string-functions.md + # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-math-functions.md + def self.name_builtin + @name_builtin ||= Set.new %w( + ABS ASC ATN CDBL CHR CINT CONTROL COPYFILE COS CREATEDIRECTORY CSNG + DELETEDIRECTORY DELETEFILE EXP FINDMEMBERFUNCTION FINDNODE FIX + FORMATDRIVEFORMATJSON GETINTERFACE INSTR INT LCASE LEFT LEN LISTDIR + LOG MATCHFILES MID MOVEFILE OBSERVEFIELD PARSEJSON PARSEXML + READASCIIFILE REBOOTSYSTEM RIGHT RND RUNGARBAGECOLLECTOR SGN SIN + SLEEP SQR STR STRI STRING STRINGI STRTOI SUBSTITUTE TANTEXTTOP TEXT + TRUCASE UPTIME VALVISIBLE VISIBLE WAIT + ) + end + + # https://developer.roku.com/en-ca/docs/references/brightscript/language/reserved-words.md + def self.keyword_reserved + @keyword_reserved ||= Set.new %w( + BOX CREATEOBJECT DIM EACH ELSE ELSEIF END ENDFUNCTION ENDIF ENDSUB + ENDWHILE EVAL EXIT EXITWHILE FALSE FOR FUNCTION GETGLOBALAA + GETLASTRUNCOMPILEERROR GETLASTRUNRUNTIMEERROR GOTO IF IN INVALID LET + LINE_NUM M NEXT OBJFUN POS PRINT REM RETURN RUN STEP STOP SUB TAB TO + TRUE TYPE WHILE + ) + end + + # These keywords are present in BrightScript, but not supported in standard .brs files + def self.keyword_reserved_unsupported + @keyword_reserved_unsupported ||= Set.new %w( + CLASS CONST IMPORT LIBRARY NAMESPACE PRIVATE PROTECTED PUBLIC + ) + end + + # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md + def self.keyword_type + @keyword_type ||= Set.new %w( + BOOLEAN DIM DOUBLE DYNAMIC FLOAT FUNCTION INTEGER INTERFACE INVALID + LONGINTEGER OBJECT STRING VOID + ) + end + + # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators + def self.operator_word + @operator_word ||= Set.new %w( + AND AS MOD NOT OR THEN + ) + end + + # Scene graph components configured as builtins. See BrightScript component documentation e.g. + # https://developer.roku.com/en-ca/docs/references/brightscript/components/roappinfo.md + def self.builtins + @builtins ||= Set.new %w( + roAppendFile roAppInfo roAppManager roArray roAssociativeArray + roAudioGuide roAudioMetadata roAudioPlayer roAudioPlayerEvent + roAudioResourceroBitmap roBoolean roBoolean roBrightPackage roBrSub + roButton roByteArray roCaptionRenderer roCaptionRendererEvent + roCecInterface roCECStatusEvent roChannelStore roChannelStoreEvent + roClockWidget roCodeRegistrationScreen + roCodeRegistrationScreenEventroCompositor roControlDown roControlPort + roControlPort roControlUp roCreateFile roDatagramReceiver + roDatagramSender roDataGramSocket roDateTime roDeviceInfo + roDeviceInfoEvent roDoubleroEVPCipher roEVPDigest roFileSystem + roFileSystemEvent roFloat roFont roFontMetrics roFontRegistry + roFunction roGlobal roGpio roGridScreen roGridScreenEvent + roHdmiHotPlugEventroHdmiStatus roHdmiStatusEvent roHMAC roHttpAgent + roImageCanvas roImageCanvasEvent roImageMetadata roImagePlayer + roImageWidgetroInput roInputEvent roInt roInt roInvalid roInvalid + roIRRemote roKeyboard roKeyboardPress roKeyboardScreen + roKeyboardScreenEventroList roListScreen roListScreenEvent + roLocalization roLongInteger roMessageDialog roMessageDialogEvent + roMessagePort roMicrophone roMicrophoneEvent roNetworkConfiguration + roOneLineDialog roOneLineDialogEventroParagraphScreen + roParagraphScreenEvent roPath roPinEntryDialog roPinEntryDialogEvent + roPinentryScreen roPosterScreen roPosterScreenEventroProgramGuide + roQuadravoxButton roReadFile roRectangleroRegexroRegion roRegistry + roRegistrySection roResourceManager roRSA roRssArticle roRssParser + roScreen roSearchHistory roSearchScreen roSearchScreenEvent + roSerialPort roSGNode roSGNodeEvent roSGScreenroSGScreenEvent + roSlideShowroSlideShowEvent roSNS5 roSocketAddress roSocketEvent + roSpringboardScreen roSpringboardScreenEventroSprite roStorageInfo + roStreamSocket roStringroSystemLogroSystemLogEvent roSystemTime + roTextFieldroTextScreen roTextScreenEvent roTextToSpeech + roTextToSpeechEvent roTextureManager roTextureRequest + roTextureRequestEventroTextWidget roTimer roTimespan roTouchScreen + roTunerroTunerEvent roUniversalControlEvent roUrlEvent roUrlTransfer + roVideoEvent roVideoInput roVideoMode roVideoPlayer roVideoPlayerEvent + roVideoScreen roVideoScreenEventroWriteFile roXMLElement roXMLList + ) + end + + id = /[$a-z_][a-z0-9_]*/io + + state :root do + rule %r/\s+/m, Text::Whitespace + + # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#comments + rule %r/\'.*/, Comment::Single + rule %r/REM.*/i, Comment::Single + + # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators + rule %r([~!%^&*+=\|?:<>/-]), Operator + + rule %r/\d*\.\d+(e-?\d+)?/i, Num::Float + rule %r/\d+[lu]*/i, Num::Integer + + rule %r/".*?"/, Str::Double + + rule %r/#{id}(?=\s*[(])/, Name::Function + + rule %r/[()\[\],.;{}]/, Punctuation + + rule id do |m| + caseSensitiveChunk = m[0] + caseInsensitiveChunk = m[0].upcase + + if self.class.builtins.include?(caseSensitiveChunk) + token Keyword::Reserved + elsif self.class.keyword_reserved.include?(caseInsensitiveChunk) + token Keyword::Reserved + elsif self.class.keyword_reserved_unsupported.include?(caseInsensitiveChunk) + token Keyword::Reserved + elsif self.class.keyword_type.include?(caseInsensitiveChunk) + token Keyword::Type + elsif self.class.name_builtin.include?(caseInsensitiveChunk) + token Name::Builtin + elsif self.class.operator_word.include?(caseInsensitiveChunk) + token Operator::Word + else + token Name + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bsl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bsl.rb new file mode 100644 index 0000000..109d81f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bsl.rb @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Bsl < RegexLexer + title "1C (BSL)" + desc "The 1C:Enterprise programming language" + tag 'bsl' + filenames '*.bsl', '*.os' + + KEYWORDS = /(?<=[^\wа-яё]|^)(?: + КонецПроцедуры | EndProcedure | КонецФункции | EndFunction + | Прервать | Break | Продолжить | Continue + | Возврат | Return | Если | If + | Иначе | Else | ИначеЕсли | ElsIf + | Тогда | Then | КонецЕсли | EndIf + | Попытка | Try | Исключение | Except + | КонецПопытки | EndTry | Raise | ВызватьИсключение + | Пока | While | Для | For + | Каждого | Each | Из | In + | По | To | Цикл | Do + | КонецЦикла | EndDo | НЕ | NOT + | И | AND | ИЛИ | OR + | Новый | New | Процедура | Procedure + | Функция | Function | Перем | Var + | Экспорт | Export | Знач | Val + )(?=[^\wа-яё]|$)/ix + + BUILTINS = /(?<=[^\wа-яё]|^)(?: + СтрДлина|StrLen|СокрЛ|TrimL|СокрП|TrimR|СокрЛП|TrimAll|Лев|Left|Прав|Right|Сред|Mid|СтрНайти|StrFind|ВРег|Upper|НРег|Lower|ТРег|Title|Символ|Char|КодСимвола|CharCode|ПустаяСтрока|IsBlankString|СтрЗаменить|StrReplace|СтрЧислоСтрок|StrLineCount|СтрПолучитьСтроку|StrGetLine|СтрЧислоВхождений|StrOccurrenceCount|СтрСравнить|StrCompare|СтрНачинаетсяС|StrStartWith|СтрЗаканчиваетсяНа|StrEndsWith|СтрРазделить|StrSplit|СтрСоединить|StrConcat + | Цел|Int|Окр|Round|ACos|ACos|ASin|ASin|ATan|ATan|Cos|Cos|Exp|Exp|Log|Log|Log10|Log10|Pow|Pow|Sin|Sin|Sqrt|Sqrt|Tan|Tan + | Год|Year|Месяц|Month|День|Day|Час|Hour|Минута|Minute|Секунда|Second|НачалоГода|BegOfYear|НачалоДня|BegOfDay|НачалоКвартала|BegOfQuarter|НачалоМесяца|BegOfMonth|НачалоМинуты|BegOfMinute|НачалоНедели|BegOfWeek|НачалоЧаса|BegOfHour|КонецГода|EndOfYear|КонецДня|EndOfDay|КонецКвартала|EndOfQuarter|КонецМесяца|EndOfMonth|КонецМинуты|EndOfMinute|КонецНедели|EndOfWeek|КонецЧаса|EndOfHour|НеделяГода|WeekOfYear|ДеньГода|DayOfYear|ДеньНедели|WeekDay|ТекущаяДата|CurrentDate|ДобавитьМесяц|AddMonth + | Тип|Type|ТипЗнч|TypeOf + | Булево|Boolean|Число|Number|Строка|String|Дата|Date + | ПоказатьВопрос|ShowQueryBox|Вопрос|DoQueryBox|ПоказатьПредупреждение|ShowMessageBox|Предупреждение|DoMessageBox|Сообщить|Message|ОчиститьСообщения|ClearMessages|ОповеститьОбИзменении|NotifyChanged|Состояние|Status|Сигнал|Beep|ПоказатьЗначение|ShowValue|ОткрытьЗначение|OpenValue|Оповестить|Notify|ОбработкаПрерыванияПользователя|UserInterruptProcessing|ОткрытьСодержаниеСправки|OpenHelpContent|ОткрытьИндексСправки|OpenHelpIndex|ОткрытьСправку|OpenHelp|ПоказатьИнформациюОбОшибке|ShowErrorInfo|КраткоеПредставлениеОшибки|BriefErrorDescription|ПодробноеПредставлениеОшибки|DetailErrorDescription|ПолучитьФорму|GetForm|ЗакрытьСправку|CloseHelp|ПоказатьОповещениеПользователя|ShowUserNotification|ОткрытьФорму|OpenForm|ОткрытьФормуМодально|OpenFormModal|АктивноеОкно|ActiveWindow|ВыполнитьОбработкуОповещения|ExecuteNotifyProcessing + | ПоказатьВводЗначения|ShowInputValue|ВвестиЗначение|InputValue|ПоказатьВводЧисла|ShowInputNumber|ВвестиЧисло|InputNumber|ПоказатьВводСтроки|ShowInputString|ВвестиСтроку|InputString|ПоказатьВводДаты|ShowInputDate|ВвестиДату|InputDate + | Формат|Format|ЧислоПрописью|NumberInWords|НСтр|NStr|ПредставлениеПериода|PeriodPresentation|СтрШаблон|StrTemplate + | ПолучитьОбщийМакет|GetCommonTemplate|ПолучитьОбщуюФорму|GetCommonForm|ПредопределенноеЗначение|PredefinedValue|ПолучитьПолноеИмяПредопределенногоЗначения|GetPredefinedValueFullName + | ПолучитьЗаголовокСистемы|GetCaption|ПолучитьСкоростьКлиентскогоСоединения|GetClientConnectionSpeed|ПодключитьОбработчикОжидания|AttachIdleHandler|УстановитьЗаголовокСистемы|SetCaption|ОтключитьОбработчикОжидания|DetachIdleHandler|ИмяКомпьютера|ComputerName|ЗавершитьРаботуСистемы|Exit|ИмяПользователя|UserName|ПрекратитьРаботуСистемы|Terminate|ПолноеИмяПользователя|UserFullName|ЗаблокироватьРаботуПользователя|LockApplication|КаталогПрограммы|BinDir|КаталогВременныхФайлов|TempFilesDir|ПравоДоступа|AccessRight|РольДоступна|IsInRole|ТекущийЯзык|CurrentLanguage|ТекущийКодЛокализации|CurrentLocaleCode|СтрокаСоединенияИнформационнойБазы|InfoBaseConnectionString|ПодключитьОбработчикОповещения|AttachNotificationHandler|ОтключитьОбработчикОповещения|DetachNotificationHandler|ПолучитьСообщенияПользователю|GetUserMessages|ПараметрыДоступа|AccessParameters|ПредставлениеПриложения|ApplicationPresentation|ТекущийЯзыкСистемы|CurrentSystemLanguage|ЗапуститьСистему|RunSystem|ТекущийРежимЗапуска|CurrentRunMode|УстановитьЧасовойПоясСеанса|SetSessionTimeZone|ЧасовойПоясСеанса|SessionTimeZone|ТекущаяДатаСеанса|CurrentSessionDate|УстановитьКраткийЗаголовокПриложения|SetShortApplicationCaption|ПолучитьКраткийЗаголовокПриложения|GetShortApplicationCaption|ПредставлениеПрава|RightPresentation|ВыполнитьПроверкуПравДоступа|VerifyAccessRights|РабочийКаталогДанныхПользователя|UserDataWorkDir|КаталогДокументов|DocumentsDir|ПолучитьИнформациюЭкрановКлиента|GetClientDisplaysInformation|ТекущийВариантОсновногоШрифтаКлиентскогоПриложения|ClientApplicationBaseFontCurrentVariant|ТекущийВариантИнтерфейсаКлиентскогоПриложения|ClientApplicationInterfaceCurrentVariant|УстановитьЗаголовокКлиентскогоПриложения|SetClientApplicationCaption|ПолучитьЗаголовокКлиентскогоПриложения|GetClientApplicationCaption|НачатьПолучениеКаталогаВременныхФайлов|BeginGettingTempFilesDir|НачатьПолучениеКаталогаДокументов|BeginGettingDocumentsDir|НачатьПолучениеРабочегоКаталогаДанныхПользователя|BeginGettingUserDataWorkDir|ПодключитьОбработчикЗапросаНастроекКлиентаЛицензирования|AttachLicensingClientParametersRequestHandler|ОтключитьОбработчикЗапросаНастроекКлиентаЛицензирования|DetachLicensingClientParametersRequestHandler + | ЗначениеВСтрокуВнутр|ValueToStringInternal|ЗначениеИзСтрокиВнутр|ValueFromStringInternal|ЗначениеВФайл|ValueToFile|ЗначениеИзФайла|ValueFromFile + | КомандаСистемы|System|ЗапуститьПриложение|RunApp|ПолучитьCOMОбъект|GetCOMObject|ПользователиОС|OSUsers|НачатьЗапускПриложения|BeginRunningApplication + | ПодключитьВнешнююКомпоненту|AttachAddIn|НачатьУстановкуВнешнейКомпоненты|BeginInstallAddIn|УстановитьВнешнююКомпоненту|InstallAddIn|НачатьПодключениеВнешнейКомпоненты|BeginAttachingAddIn + | КопироватьФайл|FileCopy|ПереместитьФайл|MoveFile|УдалитьФайлы|DeleteFiles|НайтиФайлы|FindFiles|СоздатьКаталог|CreateDirectory|ПолучитьИмяВременногоФайла|GetTempFileName|РазделитьФайл|SplitFile|ОбъединитьФайлы|MergeFiles|ПолучитьФайл|GetFile|НачатьПомещениеФайла|BeginPutFile|ПоместитьФайл|PutFile|ЭтоАдресВременногоХранилища|IsTempStorageURL|УдалитьИзВременногоХранилища|DeleteFromTempStorage|ПолучитьИзВременногоХранилища|GetFromTempStorage|ПоместитьВоВременноеХранилище|PutToTempStorage|ПодключитьРасширениеРаботыСФайлами|AttachFileSystemExtension|НачатьУстановкуРасширенияРаботыСФайлами|BeginInstallFileSystemExtension|УстановитьРасширениеРаботыСФайлами|InstallFileSystemExtension|ПолучитьФайлы|GetFiles|ПоместитьФайлы|PutFiles|ЗапроситьРазрешениеПользователя|RequestUserPermission|ПолучитьМаскуВсеФайлы|GetAllFilesMask|ПолучитьМаскуВсеФайлыКлиента|GetClientAllFilesMask|ПолучитьМаскуВсеФайлыСервера|GetServerAllFilesMask|ПолучитьРазделительПути|GetPathSeparator|ПолучитьРазделительПутиКлиента|GetClientPathSeparator|ПолучитьРазделительПутиСервера|GetServerPathSeparator|НачатьПодключениеРасширенияРаботыСФайлами|BeginAttachingFileSystemExtension|НачатьЗапросРазрешенияПользователя|BeginRequestingUserPermission|НачатьПоискФайлов|BeginFindingFiles|НачатьСозданиеКаталога|BeginCreatingDirectory|НачатьКопированиеФайла|BeginCopyingFile|НачатьПеремещениеФайла|BeginMovingFile|НачатьУдалениеФайлов|BeginDeletingFiles|НачатьПолучениеФайлов|BeginGettingFiles|НачатьПомещениеФайлов|BeginPuttingFiles + | НачатьТранзакцию|BeginTransaction|ЗафиксироватьТранзакцию|CommitTransaction|ОтменитьТранзакцию|RollbackTransaction|УстановитьМонопольныйРежим|SetExclusiveMode|МонопольныйРежим|ExclusiveMode|ПолучитьОперативнуюОтметкуВремени|GetRealTimeTimestamp|ПолучитьСоединенияИнформационнойБазы|GetInfoBaseConnections|НомерСоединенияИнформационнойБазы|InfoBaseConnectionNumber|КонфигурацияИзменена|ConfigurationChanged|КонфигурацияБазыДанныхИзмененаДинамически|DataBaseConfigurationChangedDynamically|УстановитьВремяОжиданияБлокировкиДанных|SetLockWaitTime|ОбновитьНумерациюОбъектов|RefreshObjectsNumbering|ПолучитьВремяОжиданияБлокировкиДанных|GetLockWaitTime|КодЛокализацииИнформационнойБазы|InfoBaseLocaleCode|УстановитьМинимальнуюДлинуПаролейПользователей|SetUserPasswordMinLength|ПолучитьМинимальнуюДлинуПаролейПользователей|GetUserPasswordMinLength|ИнициализироватьПредопределенныеДанные|InitializePredefinedData|УдалитьДанныеИнформационнойБазы|EraseInfoBaseData|УстановитьПроверкуСложностиПаролейПользователей|SetUserPasswordStrengthCheck|ПолучитьПроверкуСложностиПаролейПользователей|GetUserPasswordStrengthCheck|ПолучитьСтруктуруХраненияБазыДанных|GetDBStorageStructureInfo|УстановитьПривилегированныйРежим|SetPrivilegedMode|ПривилегированныйРежим|PrivilegedMode|ТранзакцияАктивна|TransactionActive|НеобходимостьЗавершенияСоединения|ConnectionStopRequest|НомерСеансаИнформационнойБазы|InfoBaseSessionNumber|ПолучитьСеансыИнформационнойБазы|GetInfoBaseSessions|ЗаблокироватьДанныеДляРедактирования|LockDataForEdit|УстановитьСоединениеСВнешнимИсточникомДанных|ConnectExternalDataSource|РазблокироватьДанныеДляРедактирования|UnlockDataForEdit|РазорватьСоединениеСВнешнимИсточникомДанных|DisconnectExternalDataSource|ПолучитьБлокировкуСеансов|GetSessionsLock|УстановитьБлокировкуСеансов|SetSessionsLock|ОбновитьПовторноИспользуемыеЗначения|RefreshReusableValues|УстановитьБезопасныйРежим|SetSafeMode|БезопасныйРежим|SafeMode|ПолучитьДанныеВыбора|GetChoiceData|УстановитьЧасовойПоясИнформационнойБазы|SetInfoBaseTimeZone|ПолучитьЧасовойПоясИнформационнойБазы|GetInfoBaseTimeZone|ПолучитьОбновлениеКонфигурацииБазыДанных|GetDataBaseConfigurationUpdate|УстановитьБезопасныйРежимРазделенияДанных|SetDataSeparationSafeMode|БезопасныйРежимРазделенияДанных|DataSeparationSafeMode|УстановитьВремяЗасыпанияПассивногоСеанса|SetPassiveSessionHibernateTime|ПолучитьВремяЗасыпанияПассивногоСеанса|GetPassiveSessionHibernateTime|УстановитьВремяЗавершенияСпящегоСеанса|SetHibernateSessionTerminateTime|ПолучитьВремяЗавершенияСпящегоСеанса|GetHibernateSessionTerminateTime|ПолучитьТекущийСеансИнформационнойБазы|GetCurrentInfoBaseSession|ПолучитьИдентификаторКонфигурации|GetConfigurationID|УстановитьНастройкиКлиентаЛицензирования|SetLicensingClientParameters|ПолучитьИмяКлиентаЛицензирования|GetLicensingClientName|ПолучитьДополнительныйПараметрКлиентаЛицензирования|GetLicensingClientAdditionalParameter + | НайтиПомеченныеНаУдаление|FindMarkedForDeletion|НайтиПоСсылкам|FindByRef|УдалитьОбъекты|DeleteObjects|УстановитьОбновлениеПредопределенныхДанныхИнформационнойБазы|SetInfoBasePredefinedDataUpdate|ПолучитьОбновлениеПредопределенныхДанныхИнформационнойБазы|GetInfoBasePredefinedData + | XMLСтрока|XMLString|XMLЗначение|XMLValue|XMLТип|XMLType|XMLТипЗнч|XMLTypeOf|ИзXMLТипа|FromXMLType|ВозможностьЧтенияXML|CanReadXML|ПолучитьXMLТип|GetXMLType|ПрочитатьXML|ReadXML|ЗаписатьXML|WriteXML|НайтиНедопустимыеСимволыXML|FindDisallowedXMLCharacters|ИмпортМоделиXDTO|ImportXDTOModel|СоздатьФабрикуXDTO|CreateXDTOFactory + | ЗаписатьJSON|WriteJSON|ПрочитатьJSON|ReadJSON|ПрочитатьДатуJSON|ReadJSONDate|ЗаписатьДатуJSON|WriteJSONDate + | ЗаписьЖурналаРегистрации|WriteLogEvent|ПолучитьИспользованиеЖурналаРегистрации|GetEventLogUsing|УстановитьИспользованиеЖурналаРегистрации|SetEventLogUsing|ПредставлениеСобытияЖурналаРегистрации|EventLogEventPresentation|ВыгрузитьЖурналРегистрации|UnloadEventLog|ПолучитьЗначенияОтбораЖурналаРегистрации|GetEventLogFilterValues|УстановитьИспользованиеСобытияЖурналаРегистрации|SetEventLogEventUse|ПолучитьИспользованиеСобытияЖурналаРегистрации|GetEventLogEventUse|СкопироватьЖурналРегистрации|CopyEventLog|ОчиститьЖурналРегистрации|ClearEventLog + | ЗначениеВДанныеФормы|ValueToFormData|ДанныеФормыВЗначение|FormDataToValue|КопироватьДанныеФормы|CopyFormData|УстановитьСоответствиеОбъектаИФормы|SetObjectAndFormConformity|ПолучитьСоответствиеОбъектаИФормы|GetObjectAndFormConformity + | ПолучитьФункциональнуюОпцию|GetFunctionalOption|ПолучитьФункциональнуюОпциюИнтерфейса|GetInterfaceFunctionalOption|УстановитьПараметрыФункциональныхОпцийИнтерфейса|SetInterfaceFunctionalOptionParameters|ПолучитьПараметрыФункциональныхОпцийИнтерфейса|GetInterfaceFunctionalOptionParameters|ОбновитьИнтерфейс|RefreshInterface + | УстановитьРасширениеРаботыСКриптографией|InstallCryptoExtension|НачатьУстановкуРасширенияРаботыСКриптографией|BeginInstallCryptoExtension|ПодключитьРасширениеРаботыСКриптографией|AttachCryptoExtension|НачатьПодключениеРасширенияРаботыСКриптографией|BeginAttachingCryptoExtension + | УстановитьСоставСтандартногоИнтерфейсаOData|SetStandardODataInterfaceContent|ПолучитьСоставСтандартногоИнтерфейсаOData|GetStandardODataInterfaceContent + | Мин|Min|Макс|Max|ОписаниеОшибки|ErrorDescription|Вычислить|Eval|ИнформацияОбОшибке|ErrorInfo|Base64Значение|Base64Value|Base64Строка|Base64String|ЗаполнитьЗначенияСвойств|FillPropertyValues|ЗначениеЗаполнено|ValueIsFilled|ПолучитьПредставленияНавигационныхСсылок|GetURLsPresentations|НайтиОкноПоНавигационнойСсылке|FindWindowByURL|ПолучитьОкна|GetWindows|ПерейтиПоНавигационнойСсылке|GotoURL|ПолучитьНавигационнуюСсылку|GetURL|ПолучитьДопустимыеКодыЛокализации|GetAvailableLocaleCodes|ПолучитьНавигационнуюСсылкуИнформационнойБазы|GetInfoBaseURL|ПредставлениеКодаЛокализации|LocaleCodePresentation|ПолучитьДопустимыеЧасовыеПояса|GetAvailableTimeZones|ПредставлениеЧасовогоПояса|TimeZonePresentation|ТекущаяУниверсальнаяДата|CurrentUniversalDate|ТекущаяУниверсальнаяДатаВМиллисекундах|CurrentUniversalDateInMilliseconds|МестноеВремя|ToLocalTime|УниверсальноеВремя|ToUniversalTime|ЧасовойПояс|TimeZone|СмещениеЛетнегоВремени|DaylightTimeOffset|СмещениеСтандартногоВремени|StandardTimeOffset|КодироватьСтроку|EncodeString|РаскодироватьСтроку|DecodeString|Найти|Find + | ПередНачаломРаботыСистемы|BeforeStart|ПриНачалеРаботыСистемы|OnStart|ПередЗавершениемРаботыСистемы|BeforeExit|ПриЗавершенииРаботыСистемы|OnExit|ОбработкаВнешнегоСобытия|ExternEventProcessing|УстановкаПараметровСеанса|SessionParametersSetting|ПриИзмененииПараметровЭкрана|OnChangeDisplaySettings + | WSСсылки|WSReferences|БиблиотекаКартинок|PictureLib|БиблиотекаМакетовОформленияКомпоновкиДанных|DataCompositionAppearanceTemplateLib|БиблиотекаСтилей|StyleLib|БизнесПроцессы|BusinessProcesses|ВнешниеИсточникиДанных|ExternalDataSources|ВнешниеОбработки|ExternalDataProcessors|ВнешниеОтчеты|ExternalReports|Документы|Documents|ДоставляемыеУведомления|DeliverableNotifications|ЖурналыДокументов|DocumentJournals|Задачи|Tasks|ИспользованиеРабочейДаты|WorkingDateUse|ИсторияРаботыПользователя|UserWorkHistory|Константы|Constants|КритерииОтбора|FilterCriteria|Метаданные|Metadata|Обработки|DataProcessors|ОтправкаДоставляемыхУведомлений|DeliverableNotificationSend|Отчеты|Reports|ПараметрыСеанса|SessionParameters|Перечисления|Enums|ПланыВидовРасчета|ChartsOfCalculationTypes|ПланыВидовХарактеристик|ChartsOfCharacteristicTypes|ПланыОбмена|ExchangePlans|ПланыСчетов|ChartsOfAccounts|ПолнотекстовыйПоиск|FullTextSearch|ПользователиИнформационнойБазы|InfoBaseUsers|Последовательности|Sequences|РасширенияКонфигурации|ConfigurationExtensions|РегистрыБухгалтерии|AccountingRegisters|РегистрыНакопления|AccumulationRegisters|РегистрыРасчета|CalculationRegisters|РегистрыСведений|InformationRegisters|РегламентныеЗадания|ScheduledJobs|СериализаторXDTO|XDTOSerializer|Справочники|Catalogs|СредстваГеопозиционирования|LocationTools|СредстваКриптографии|CryptoToolsManager|СредстваМультимедиа|MultimediaTools|СредстваПочты|MailTools|СредстваТелефонии|TelephonyTools|ФабрикаXDTO|XDTOFactory|ФоновыеЗадания|BackgroundJobs|ХранилищаНастроек + | ГлавныйИнтерфейс|MainInterface|ГлавныйСтиль|MainStyle|ПараметрЗапуска|LaunchParameter|РабочаяДата|WorkingDate|SettingsStorages|ХранилищеВариантовОтчетов|ReportsVariantsStorage|ХранилищеНастроекДанныхФорм|FormDataSettingsStorage|ХранилищеОбщихНастроек|CommonSettingsStorage|ХранилищеПользовательскихНастроекДинамическихСписков|DynamicListsUserSettingsStorage|ХранилищеПользовательскихНастроекОтчетов|ReportsUserSettingsStorage|ХранилищеСистемныхНастроек|SystemSettingsStorage + | Если|If|ИначеЕсли|ElsIf|Иначе|Else|КонецЕсли|EndIf|Тогда|Then + | Неопределено|Undefined|Истина|True|Ложь|False|NULL + )\s*(?=\()/ix + + state :root do + rule %r/\n/, Text + rule %r/[^\S\n]+/, Text + rule %r(//.*$), Comment::Single + rule %r/[\[\]:(),;]/, Punctuation + rule %r/(?<=[^\wа-яё]|^)\&.*$/, Keyword::Declaration + rule %r/[-+\/*%=<>.?&]/, Operator + rule %r/(?<=[^\wа-яё]|^)\#.*$/, Keyword::Declaration + rule KEYWORDS, Keyword + rule BUILTINS, Name::Builtin + rule %r/[\wа-яё][\wа-яё]*/i, Name::Variable + + #literals + rule %r/\b((\h{8}-(\h{4}-){3}\h{12})|\d+\.?\d*)\b/, Literal::Number + rule %r/\'.*\'/, Literal::Date + rule %r/".*?("|$)/, Literal::String::Single + rule %r/(?<=[^\wа-яё]|^)\|((?!\"\").)*?(\"|$)/, Literal::String + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/c.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/c.rb new file mode 100644 index 0000000..ad6624a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/c.rb @@ -0,0 +1,200 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class C < RegexLexer + tag 'c' + filenames '*.c', '*.h', '*.idc' + mimetypes 'text/x-chdr', 'text/x-csrc' + + title "C" + desc "The C programming language" + + # optional comment or whitespace + ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+) + id = /[a-zA-Z_][a-zA-Z0-9_]*/ + + def self.keywords + @keywords ||= Set.new %w( + auto break case const continue default do else enum extern + for goto if register restricted return sizeof static struct + switch typedef union volatile virtual while + + _Alignas _Alignof _Atomic _Generic _Imaginary + _Noreturn _Static_assert _Thread_local + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + int long float short double char unsigned signed void + + jmp_buf FILE DIR div_t ldiv_t mbstate_t sig_atomic_t fpos_t + clock_t time_t va_list size_t ssize_t off_t wchar_t ptrdiff_t + wctrans_t wint_t wctype_t + + _Bool _Complex int8_t int16_t int32_t int64_t + uint8_t uint16_t uint32_t uint64_t int_least8_t + int_least16_t int_least32_t int_least64_t + uint_least8_t uint_least16_t uint_least32_t + uint_least64_t int_fast8_t int_fast16_t int_fast32_t + int_fast64_t uint_fast8_t uint_fast16_t uint_fast32_t + uint_fast64_t intptr_t uintptr_t intmax_t + uintmax_t + + char16_t char32_t + ) + end + + def self.reserved + @reserved ||= Set.new %w( + __asm __int8 __based __except __int16 __stdcall __cdecl + __fastcall __int32 __declspec __finally __int61 __try __leave + inline _inline __inline naked _naked __naked restrict _restrict + __restrict thread _thread __thread typename _typename __typename + ) + end + + def self.builtins + @builtins ||= [] + end + + start { push :bol } + + state :expr_bol do + mixin :inline_whitespace + + rule %r/#if\s0/, Comment, :if_0 + rule %r/#/, Comment::Preproc, :macro + + rule(//) { pop! } + end + + # :expr_bol is the same as :bol but without labels, since + # labels can only appear at the beginning of a statement. + state :bol do + rule %r/#{id}:(?!:)/, Name::Label + mixin :expr_bol + end + + state :inline_whitespace do + rule %r/[ \t\r]+/, Text + rule %r/\\\n/, Text # line continuation + rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline + end + + state :whitespace do + rule %r/\n+/m, Text, :bol + rule %r(//(\\.|.)*?$), Comment::Single, :bol + mixin :inline_whitespace + end + + state :expr_whitespace do + rule %r/\n+/m, Text, :expr_bol + mixin :whitespace + end + + state :statements do + mixin :whitespace + rule %r/(u8|u|U|L)?"/, Str, :string + rule %r((u8|u|U|L)?'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char + rule %r((\d+[.]\d*|[.]?\d+)e[+-]?\d+[lu]*)i, Num::Float + rule %r(\d+e[+-]?\d+[lu]*)i, Num::Float + rule %r/0x[0-9a-f]+[lu]*/i, Num::Hex + rule %r/0[0-7]+[lu]*/i, Num::Oct + rule %r/\d+[lu]*/i, Num::Integer + rule %r(\*/), Error + rule %r([~!%^&*+=\|?:<>/-]), Operator + rule %r/[()\[\],.;]/, Punctuation + rule %r/\bcase\b/, Keyword, :case + rule %r/(?:true|false|NULL)\b/, Name::Builtin + rule id do |m| + name = m[0] + + if self.class.keywords.include? name + token Keyword + elsif self.class.keywords_type.include? name + token Keyword::Type + elsif self.class.reserved.include? name + token Keyword::Reserved + elsif self.class.builtins.include? name + token Name::Builtin + else + token Name + end + end + end + + state :case do + rule %r/:/, Punctuation, :pop! + mixin :statements + end + + state :root do + mixin :expr_whitespace + rule %r( + ([\w*\s]+?[\s*]) # return arguments + (#{id}) # function name + (\s*\([^;]*?\)) # signature + (#{ws}?)({|;) # open brace or semicolon + )mx do |m| + # TODO: do this better. + recurse m[1] + token Name::Function, m[2] + recurse m[3] + recurse m[4] + token Punctuation, m[5] + if m[5] == ?{ + push :function + end + end + rule %r/\{/, Punctuation, :function + mixin :statements + end + + state :function do + mixin :whitespace + mixin :statements + rule %r/;/, Punctuation + rule %r/{/, Punctuation, :function + rule %r/}/, Punctuation, :pop! + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape + rule %r/[^\\"\n]+/, Str + rule %r/\\\n/, Str + rule %r/\\/, Str # stray backslash + end + + state :macro do + mixin :include + rule %r([^/\n\\]+), Comment::Preproc + rule %r/\\./m, Comment::Preproc + mixin :inline_whitespace + rule %r(/), Comment::Preproc + # NB: pop! goes back to :bol + rule %r/\n/, Comment::Preproc, :pop! + end + + state :include do + rule %r/(include)(\s*)(<[^>]+>)([^\n]*)/ do + groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single + end + rule %r/(include)(\s*)("[^"]+")([^\n]*)/ do + groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single + end + end + + state :if_0 do + # NB: no \b here, to cover #ifdef and #ifndef + rule %r/^\s*#if/, Comment, :if_0 + rule %r/^\s*#\s*el(?:se|if)/, Comment, :pop! + rule %r/^\s*#\s*endif\b.*?(?|+=:;,./?`-]), Operator + rule %r(\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?), Literal::Number::Float + rule %r(\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?), + Literal::Number::Float + rule %r([0-9][0-9]*\.\d{1,3}(_\d{3})+[kMGTPmunpf]?), Literal::Number::Float + rule %r([0-9][0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?), + Literal::Number::Float + rule %r(#([0-9a-fA-F]{4})(_[0-9a-fA-F]{4})+), Literal::Number::Hex + rule %r(#[0-9a-fA-F]+), Literal::Number::Hex + rule %r(\$([01]{4})(_[01]{4})+), Literal::Number::Bin + rule %r(\$[01]+), Literal::Number::Bin + rule %r(\d{1,3}(_\d{3})+[kMGTP]?), Literal::Number::Integer + rule %r([0-9]+[kMGTP]?), Literal::Number::Integer + rule %r(\n), Text + + end + + state :class do + mixin :whitespace + rule %r([A-Za-z_]\w*), Name::Class, :pop! + end + + state :import do + rule %r([a-z][\w.]*), Name::Namespace, :pop! + rule %r("(\\\\|\\"|[^"])*"), Literal::String, :pop! + end + + state :comment do + rule %r([^*/]), Comment.Multiline + rule %r(/\*), Comment::Multiline, :push! + rule %r(\*/), Comment::Multiline, :pop! + rule %r([*/]), Comment::Multiline + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cfscript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cfscript.rb new file mode 100644 index 0000000..6b083ce --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cfscript.rb @@ -0,0 +1,154 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + + class Cfscript < RegexLexer + title "CFScript" + desc 'CFScript, the CFML scripting language' + tag 'cfscript' + aliases 'cfc' + filenames '*.cfc' + + def self.keywords + @keywords ||= %w( + if else var xml default break switch do try catch throw in continue for return while required + ) + end + + def self.declarations + @declarations ||= %w( + component property function remote public package private + ) + end + + def self.types + @types ||= %w( + any array binary boolean component date guid numeric query string struct uuid void xml + ) + end + + constants = %w(application session client cookie super this variables arguments cgi) + + + operators = %w(\+\+ -- && \|\| <= >= < > == != mod eq lt gt lte gte not is and or xor eqv imp equal contains \? ) + dotted_id = /[$a-zA-Z_][a-zA-Z0-9_.]*/ + + state :root do + mixin :comments_and_whitespace + rule %r/(?:#{operators.join('|')}|does not contain|greater than(?: or equal to)?|less than(?: or equal to)?)\b/i, Operator, :expr_start + rule %r([-<>+*%&|\^/!=]=?), Operator, :expr_start + + rule %r/[(\[,]/, Punctuation, :expr_start + rule %r/;/, Punctuation, :statement + rule %r/[)\].]/, Punctuation + + rule %r/[?]/ do + token Punctuation + push :ternary + push :expr_start + end + + rule %r/[{}]/, Punctuation, :statement + + rule %r/(?:#{constants.join('|')})\b/, Name::Constant + rule %r/(?:true|false|null)\b/, Keyword::Constant + rule %r/import\b/, Keyword::Namespace, :import + rule %r/(#{dotted_id})(\s*)(:)(\s*)/ do + groups Name, Text, Punctuation, Text + push :expr_start + end + + rule %r/([A-Za-z_$][\w.]*)(\s*)(\()/ do |m| + if self.class.keywords.include? m[1] + token Keyword, m[1] + token Text, m[2] + token Punctuation, m[3] + else + token Name::Function, m[1] + token Text, m[2] + token Punctuation, m[3] + end + end + + rule dotted_id do |m| + if self.class.declarations.include? m[0] + token Keyword::Declaration + push :expr_start + elsif self.class.keywords.include? m[0] + token Keyword + push :expr_start + elsif self.class.types.include? m[0] + token Keyword::Type + push :expr_start + else + token Name::Other + end + end + + rule %r/[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float + rule %r/0x[0-9a-fA-F]+/, Num::Hex + rule %r/[0-9]+/, Num::Integer + rule %r/"(\\\\|\\"|[^"])*"/, Str::Double + rule %r/'(\\\\|\\'|[^'])*'/, Str::Single + + end + + # same as java, broken out + state :comments_and_whitespace do + rule %r/\s+/, Text + rule %r(//.*?$), Comment::Single + rule %r(/\*.*?\*/)m, Comment::Multiline + end + + state :expr_start do + mixin :comments_and_whitespace + + rule %r/[{]/, Punctuation, :object + + rule %r//, Text, :pop! + end + + state :statement do + + rule %r/[{}]/, Punctuation + + mixin :expr_start + end + + # object literals + state :object do + mixin :comments_and_whitespace + rule %r/[}]/ do + token Punctuation + push :expr_start + end + + rule %r/(#{dotted_id})(\s*)(:)/ do + groups Name::Other, Text, Punctuation + push :expr_start + end + + rule %r/:/, Punctuation + mixin :root + end + + # ternary expressions, where : is not a label! + state :ternary do + rule %r/:/ do + token Punctuation + goto :expr_start + end + + mixin :root + end + + state :import do + rule %r/\s+/m, Text + rule %r/[a-z0-9_.]+\*?/i, Name::Namespace, :pop! + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cisco_ios.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cisco_ios.rb new file mode 100644 index 0000000..685c2ca --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cisco_ios.rb @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# Based on/regexes mostly from Brandon Bennett's pygments-routerlexers: +# https://github.com/nemith/pygments-routerlexers + +module Rouge + module Lexers + class CiscoIos < RegexLexer + title 'Cisco IOS' + desc 'Cisco IOS configuration lexer' + tag 'cisco_ios' + filenames '*.cfg' + mimetypes 'text/x-cisco-conf' + + state :root do + rule %r/^!.*/, Comment::Single + + rule %r/^(version\s+)(.*)$/ do + groups Keyword, Num::Float + end + + rule %r/(desc*r*i*p*t*i*o*n*)(.*?)$/ do + groups Keyword, Comment::Single + end + + rule %r/^(inte*r*f*a*c*e*|controller|router \S+|voice translation-\S+|voice-port|line)(.*)$/ do + groups Keyword::Type, Name::Function + end + + rule %r/(password|secret)(\s+[57]\s+)(\S+)/ do + groups Keyword, Num, String::Double + end + + rule %r/(permit|deny)/, Operator::Word + + rule %r/^(banner\s+)(motd\s+|login\s+)([#$%])/ do + groups Keyword, Name::Function, Str::Delimiter + push :cisco_ios_text + end + + rule %r/^(dial-peer\s+\S+\s+)(\S+)(.*?)$/ do + groups Keyword, Name::Attribute, Keyword + end + + rule %r/^(vlan\s+)(\d+)$/ do + groups Keyword, Name::Attribute + end + + # IPv4 Address/Prefix + rule %r/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\/\d{1,2})?/, Num + + # NSAP + rule %r/49\.\d{4}\.\d{4}\.\d{4}\.\d{4}\.\d{2}/, Num + + # MAC Address + rule %r/[a-f0-9]{4}\.[a-f0-9]{4}\.[a-f0-9]{4}/, Num::Hex + + rule %r/^(\s*no\s+)(\S+)/ do + groups Keyword::Constant, Keyword + end + + rule %r/^[^\n\r]\s*\S+/, Keyword + + # Obfuscated Passwords + rule %r/\*+/, Name::Entity + + rule %r/(?<= )\d+(?= )/, Num + + # Newline catcher, avoid errors on empty lines + rule %r/\n+/m, Text + + # This one goes last, a text catch-all + rule %r/./, Text + end + + state :cisco_ios_text do + rule %r/[^#$%]/, Text + rule %r/[#$%]/, Str::Delimiter, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/clean.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/clean.rb new file mode 100644 index 0000000..031cd61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/clean.rb @@ -0,0 +1,156 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Clean < RegexLexer + title "Clean" + desc "The Clean programming language (clean.cs.ru.nl)" + + tag 'clean' + filenames '*.dcl', '*.icl' + + def self.keywords + @keywords ||= Set.new %w( + if otherwise + let in + with where + case of + infix infixl infixr + class instance + generic derive + special + implementation definition system module + from import qualified as + dynamic + code inline foreign export ccall stdcall + ) + end + + # These are literal patterns common to the ABC intermediate language and + # Clean. Clean has more extensive literal patterns (see :basic below). + state :common_literals do + rule %r/'(?:[^'\\]|\\(?:x[0-9a-fA-F]+|\d+|.))'/, Str::Char + + rule %r/[+~-]?\d+\.\d+(?:E[+-]?\d+)?\b/, Num::Float + rule %r/[+~-]?\d+E[+-]?\d+\b/, Num::Float + rule %r/[+~-]?\d+/, Num::Integer + + rule %r/"/, Str::Double, :string + end + + state :basic do + rule %r/\s+/m, Text::Whitespace + + rule %r/\/\/\*.*/, Comment::Doc + rule %r/\/\/.*/, Comment::Single + rule %r/\/\*\*/, Comment::Doc, :comment_doc + rule %r/\/\*/, Comment::Multiline, :comment + + rule %r/[+~-]?0[0-7]+/, Num::Oct + rule %r/[+~-]?0x[0-9a-fA-F]+/, Num::Hex + mixin :common_literals + rule %r/(\[)(\s*)(')(?=.*?'\])/ do + groups Punctuation, Text::Whitespace, Str::Single, Punctuation + push :charlist + end + end + + # nested commenting + state :comment_doc do + rule %r/\*\//, Comment::Doc, :pop! + rule %r/\/\/.*/, Comment::Doc # Singleline comments in multiline comments are skipped + rule %r/\/\*/, Comment::Doc, :comment + rule %r/[^*\/]+/, Comment::Doc + rule %r/[*\/]/, Comment::Doc + end + + # This is the same as the above, but with Multiline instead of Doc + state :comment do + rule %r/\*\//, Comment::Multiline, :pop! + rule %r/\/\/.*/, Comment::Multiline # Singleline comments in multiline comments are skipped + rule %r/\/\*/, Comment::Multiline, :comment + rule %r/[^*\/]+/, Comment::Multiline + rule %r/[*\/]/, Comment::Multiline + end + + state :root do + mixin :basic + + rule %r/code(\s+inline)?\s*{/, Comment::Preproc, :abc + + rule %r/_*[a-z][\w`]*/ do |m| + if self.class.keywords.include?(m[0]) + token Keyword + else + token Name + end + end + + rule %r/_*[A-Z][\w`]*/ do |m| + if m[0]=='True' || m[0]=='False' + token Keyword::Constant + else + token Keyword::Type + end + end + + rule %r/[^\w\s`]/, Punctuation + rule %r/_\b/, Punctuation + end + + state :escapes do + rule %r/\\x[0-9a-fA-F]{1,2}/i, Str::Escape + rule %r/\\d\d{0,3}/i, Str::Escape + rule %r/\\0[0-7]{0,3}/, Str::Escape + rule %r/\\[0-7]{1,3}/, Str::Escape + rule %r/\\[nrfbtv\\"']/, Str::Escape + end + + state :string do + rule %r/"/, Str::Double, :pop! + mixin :escapes + rule %r/[^\\"]+/, Str::Double + end + + state :charlist do + rule %r/(')(\])/ do + groups Str::Single, Punctuation + pop! + end + mixin :escapes + rule %r/[^\\']/, Str::Single + end + + state :abc_basic do + rule %r/\s+/, Text::Whitespace + rule %r/\|.*/, Comment::Single + mixin :common_literals + end + + # The ABC intermediate language can be included, similar to C's inline + # assembly. For some information about ABC, see: + # https://en.wikipedia.org/wiki/Clean_(programming_language)#The_ABC-Machine + state :abc do + mixin :abc_basic + + rule %r/}/, Comment::Preproc, :pop! + rule %r/\.\w*/, Keyword, :abc_rest_of_line + rule %r/[\w]+/, Name::Builtin, :abc_rest_of_line + end + + state :abc_rest_of_line do + rule %r/\n/, Text::Whitespace, :pop! + rule %r/}/ do + token Comment::Preproc + pop! + pop! + end + + mixin :abc_basic + + rule %r/\S+/, Name + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/clojure.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/clojure.rb new file mode 100644 index 0000000..06b34e0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/clojure.rb @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Clojure < RegexLexer + title "Clojure" + desc "The Clojure programming language (clojure.org)" + + tag 'clojure' + aliases 'clj', 'cljs' + + filenames '*.clj', '*.cljs', '*.cljc', 'build.boot', '*.edn' + + mimetypes 'text/x-clojure', 'application/x-clojure' + + def self.keywords + @keywords ||= Set.new %w( + fn def defn defmacro defmethod defmulti defn- defstruct if + cond let for + ) + end + + def self.builtins + @builtins ||= Set.new %w( + . .. * + - -> / < <= = == > >= accessor agent agent-errors + aget alength all-ns alter and append-child apply array-map + aset aset-boolean aset-byte aset-char aset-double aset-float + aset-int aset-long aset-short assert assoc await await-for bean + binding bit-and bit-not bit-or bit-shift-left bit-shift-right + bit-xor boolean branch? butlast byte cast char children + class clear-agent-errors comment commute comp comparator + complement concat conj cons constantly construct-proxy + contains? count create-ns create-struct cycle dec deref + difference disj dissoc distinct doall doc dorun doseq dosync + dotimes doto double down drop drop-while edit end? ensure eval + every? false? ffirst file-seq filter find find-doc find-ns + find-var first float flush fnseq frest gensym get-proxy-class + get hash-map hash-set identical? identity if-let import in-ns + inc index insert-child insert-left insert-right inspect-table + inspect-tree instance? int interleave intersection into + into-array iterate join key keys keyword keyword? last lazy-cat + lazy-cons left lefts line-seq list* list load load-file locking + long loop macroexpand macroexpand-1 make-array make-node map + map-invert map? mapcat max max-key memfn merge merge-with meta + min min-key name namespace neg? new newline next nil? node not + not-any? not-every? not= ns-imports ns-interns ns-map ns-name + ns-publics ns-refers ns-resolve ns-unmap nth nthrest or parse + partial path peek pop pos? pr pr-str print print-str println + println-str prn prn-str project proxy proxy-mappings quot + rand rand-int range re-find re-groups re-matcher re-matches + re-pattern re-seq read read-line reduce ref ref-set refer rem + remove remove-method remove-ns rename rename-keys repeat replace + replicate resolve rest resultset-seq reverse rfirst right + rights root rrest rseq second select select-keys send send-off + seq seq-zip seq? set short slurp some sort sort-by sorted-map + sorted-map-by sorted-set special-symbol? split-at split-with + str string? struct struct-map subs subvec symbol symbol? + sync take take-nth take-while test time to-array to-array-2d + tree-seq true? union up update-proxy val vals var-get var-set + var? vector vector-zip vector? when when-first when-let + when-not with-local-vars with-meta with-open with-out-str + xml-seq xml-zip zero? zipmap zipper' + ) + end + + identifier = %r([\w!$%*+,<=>?/.-]+) + keyword = %r([\w!\#$%*+,<=>?/.-]+) + + def name_token(name) + return Keyword if self.class.keywords.include?(name) + return Name::Builtin if self.class.builtins.include?(name) + nil + end + + state :root do + rule %r/;.*?$/, Comment::Single + rule %r/\s+/m, Text::Whitespace + + rule %r/-?\d+\.\d+/, Num::Float + rule %r/-?\d+/, Num::Integer + rule %r/0x-?[0-9a-fA-F]+/, Num::Hex + + rule %r/"(\\.|[^"])*"/, Str + rule %r/'#{keyword}/, Str::Symbol + rule %r/::?#{keyword}/, Name::Constant + rule %r/\\(.|[a-z]+)/i, Str::Char + + + rule %r/~@|[`\'#^~&@]/, Operator + + rule %r/(\()(\s*)(#{identifier})/m do |m| + token Punctuation, m[1] + token Text::Whitespace, m[2] + token(name_token(m[3]) || Name::Function, m[3]) + end + + rule identifier do |m| + token name_token(m[0]) || Name + end + + # vectors + rule %r/[\[\]]/, Punctuation + + # maps + rule %r/[{}]/, Punctuation + + # parentheses + rule %r/[()]/, Punctuation + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cmake.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cmake.rb new file mode 100644 index 0000000..a22169c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cmake.rb @@ -0,0 +1,218 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class CMake < RegexLexer + title 'CMake' + desc 'The cross-platform, open-source build system' + tag 'cmake' + filenames 'CMakeLists.txt', '*.cmake' + mimetypes 'text/x-cmake' + + SPACE = '[ \t]' + BRACKET_OPEN = '\[=*\[' + + STATES_MAP = { + :root => Text, + :bracket_string => Str::Double, + :quoted_argument => Str::Double, + :bracket_comment => Comment::Multiline, + :variable_reference => Name::Variable, + } + + BUILTIN_COMMANDS = Set.new %w[ + add_compile_definitions + add_compile_options + add_custom_command + add_custom_target + add_definitions + add_dependencies + add_executable + add_library + add_link_options + add_subdirectory + add_test + aux_source_directory + break + build_command + build_name + cmake_host_system_information + cmake_language + cmake_minimum_required + cmake_parse_arguments + cmake_policy + configure_file + create_test_sourcelist + define_property + else + elseif + enable_language + enable_testing + endforeach + endfunction + endif + endmacro + endwhile + exec_program + execute_process + export + export_library_dependencies + file + find_file + find_library + find_package + find_path + find_program + fltk_wrap_ui + foreach + function + get_cmake_property + get_directory_property + get_filename_component + get_property + get_source_file_property + get_target_property + get_test_property + if + include + include_directories + include_external_msproject + include_guard + include_regular_expression + install + install_files + install_programs + install_targets + link_directories + link_libraries + list + load_cache + load_command + macro + make_directory + mark_as_advanced + math + message + option + output_required_files + project + qt_wrap_cpp + qt_wrap_ui + remove + remove_definitions + return + separate_arguments + set + set_directory_properties + set_property + set_source_files_properties + set_target_properties + set_tests_properties + site_name + source_group + string + subdir_depends + subdirs + target_compile_definitions + target_compile_features + target_compile_options + target_include_directories + target_link_directories + target_link_libraries + target_link_options + target_precompile_headers + target_sources + try_compile + try_run + unset + use_mangled_mesa + utility_source + variable_requires + variable_watch + while + write_file + ] + + state :default do + rule %r/\r\n?|\n/ do + token STATES_MAP[state.name.to_sym] + end + rule %r/./ do + token STATES_MAP[state.name.to_sym] + end + end + + state :variable_interpolation do + rule %r/\$\{/ do + token Str::Interpol + push :variable_reference + end + end + + state :bracket_close do + rule %r/\]=*\]/ do |m| + token STATES_MAP[state.name.to_sym] + goto :root if m[0].length == @bracket_len + end + end + + state :root do + mixin :variable_interpolation + + rule %r/#{SPACE}/, Text + rule %r/[()]/, Punctuation + + rule %r/##{BRACKET_OPEN}/ do |m| + token Comment::Multiline + @bracket_len = m[0].length - 1 # decount '#' + goto :bracket_comment + end + rule %r/#{BRACKET_OPEN}/ do |m| + token Str::Double + @bracket_len = m[0].length + goto :bracket_string + end + + rule %r/\\"/, Text + rule %r/"/, Str::Double, :quoted_argument + + rule %r/([A-Za-z_][A-Za-z0-9_]*)(#{SPACE}*)(\()/ do |m| + groups BUILTIN_COMMANDS.include?(m[1]) ? Name::Builtin : Name::Function, Text, Punctuation + end + + rule %r/#.*/, Comment::Single + + mixin :default + end + + state :bracket_string do + mixin :bracket_close + mixin :variable_interpolation + mixin :default + end + + state :bracket_comment do + mixin :bracket_close + mixin :default + end + + state :variable_reference do + mixin :variable_interpolation + + rule %r/}/, Str::Interpol, :pop! + + mixin :default + end + + state :quoted_argument do + mixin :variable_interpolation + + rule %r/"/, Str::Double, :root + rule %r/\\[()#" \\$@^trn;]/, Str::Escape + + mixin :default + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cmhg.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cmhg.rb new file mode 100644 index 0000000..338a3fa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/cmhg.rb @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class CMHG < RegexLexer + title "CMHG" + desc "RISC OS C module header generator source file" + tag 'cmhg' + filenames '*.cmhg' + + def self.preproc_keyword + @preproc_keyword ||= %w( + define elif else endif error if ifdef ifndef include line pragma undef warning + ) + end + + state :root do + rule %r/;[^\n]*/, Comment + rule %r/^([ \t]*)(#[ \t]*(?:(?:#{CMHG.preproc_keyword.join('|')})(?:[ \t].*)?)?)(?=\n)/ do + groups Text, Comment::Preproc + end + rule %r/[-a-z]+:/, Keyword::Declaration + rule %r/[a-z_]\w+/i, Name::Entity + rule %r/"[^"]*"/, Literal::String + rule %r/(?:&|0x)\h+/, Literal::Number::Hex + rule %r/\d+/, Literal::Number + rule %r/[,\/()]/, Punctuation + rule %r/[ \t]+/, Text + rule %r/\n+/, Text + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/codeowners.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/codeowners.rb new file mode 100644 index 0000000..7f07911 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/codeowners.rb @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Codeowners < RegexLexer + title 'CODEOWNERS' + desc 'Code Owners syntax (https://docs.gitlab.com/ee/user/project/codeowners/reference.html)' + tag 'codeowners' + filenames 'CODEOWNERS' + + state :root do + rule %r/[ \t\r\n]+/, Text::Whitespace + rule %r/^\s*#.*$/, Comment::Single + + rule %r( + (\^?\[(?!\d+\])[^\]]+\]) + (\[\d+\])? + )x do + groups Name::Namespace, Literal::Number + end + + rule %r/\S*@\S+/, Name::Function + + rule %r/[\p{Word}\.\/\-\*]+/, Name + rule %r/.*\\[\#\s]/, Name + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/coffeescript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/coffeescript.rb new file mode 100644 index 0000000..032943b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/coffeescript.rb @@ -0,0 +1,215 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Coffeescript < RegexLexer + tag 'coffeescript' + aliases 'coffee', 'coffee-script' + filenames '*.coffee', 'Cakefile' + mimetypes 'text/coffeescript' + + title "CoffeeScript" + desc 'The Coffeescript programming language (coffeescript.org)' + + def self.detect?(text) + return true if text.shebang? 'coffee' + end + + def self.keywords + @keywords ||= Set.new %w( + for by while until loop break continue return + switch when then if else do yield throw try catch finally await + new delete typeof instanceof super extends this class + import export debugger + ) + end + + def self.reserved + @reserved ||= Set.new %w( + case function var void with const let enum + native implements interface package private protected public static + ) + end + + def self.constants + @constants ||= Set.new %w( + true false yes no on off null NaN Infinity undefined + ) + end + + def self.builtins + @builtins ||= Set.new %w( + Array Boolean Date Error Function Math netscape Number Object + Packages RegExp String sun decodeURI decodeURIComponent + encodeURI encodeURIComponent eval isFinite isNaN parseFloat + parseInt document window + ) + end + + id = /[$a-zA-Z_][a-zA-Z0-9_]*/ + + state :comments do + rule %r/###[^#].*?###/m, Comment::Multiline + rule %r/#.*$/, Comment::Single + end + + state :whitespace do + rule %r/\s+/m, Text + end + + state :regex_comment do + rule %r/^#(?!\{).*$/, Comment::Single + rule %r/(\s+)(#(?!\{).*)$/ do + groups Text, Comment::Single + end + end + + state :multiline_regex_begin do + rule %r(///) do + token Str::Regex + goto :multiline_regex + end + end + + state :multiline_regex_end do + rule %r(///([gimy]+\b|\B)), Str::Regex, :pop! + end + + state :multiline_regex do + mixin :multiline_regex_end + mixin :regex_comment + mixin :has_interpolation + mixin :comments + mixin :whitespace + mixin :code_escape + + rule %r/\\\D/, Str::Escape + rule %r/\\\d+/, Name::Variable + rule %r/./m, Str::Regex + end + + state :slash_starts_regex do + mixin :comments + mixin :whitespace + mixin :multiline_regex_begin + + rule %r( + /(\\.|[^\[/\\\n]|\[(\\.|[^\]\\\n])*\])+/ # a regex + ([gimy]+\b|\B) + )x, Str::Regex, :pop! + + rule(//) { pop! } + end + + state :root do + rule(%r(^(?=\s|/| + rule %r/--(?![!#\$\%&*+.\/<=>?@\^\|_~]).*?$/, Comment::Single + end + + # nested commenting + state :comment do + rule %r/-}/, Comment::Multiline, :pop! + rule %r/{-/, Comment::Multiline, :comment + rule %r/[^-{}]+/, Comment::Multiline + rule %r/[-{}]/, Comment::Multiline + end + + state :comment_preproc do + rule %r/-}/, Comment::Preproc, :pop! + rule %r/{-/, Comment::Preproc, :comment + rule %r/[^-{}]+/, Comment::Preproc + rule %r/[-{}]/, Comment::Preproc + end + + state :root do + mixin :basic + + rule %r/'(?=(?:.|\\\S+)')/, Str::Char, :character + rule %r/"/, Str, :string + + rule %r/\d+e[+-]?\d+/i, Num::Float + rule %r/\d+\.\d+(e[+-]?\d+)?/i, Num::Float + rule %r/0o[0-7]+/i, Num::Oct + rule %r/0x[\da-f]+/i, Num::Hex + rule %r/\d+/, Num::Integer + + rule %r/[\w']+/ do |m| + match = m[0] + if match == "import" + token Keyword::Reserved + push :import + elsif match == "module" + token Keyword::Reserved + push :module + elsif reserved.include?(match) + token Keyword::Reserved + elsif match =~ /\A'?[A-Z]/ + token Keyword::Type + else + token Name + end + end + + # lambda operator + rule %r(\\(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Name::Function + # special operators + rule %r((<-|::|->|=>|=)(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Operator + # constructor/type operators + rule %r(:[:!#\$\%&*+.\\/<=>?@^\|~-]*), Operator + # other operators + rule %r([:!#\$\%&*+.\\/<=>?@^\|~-]+), Operator + + rule %r/\[\s*\]/, Keyword::Type + rule %r/\(\s*\)/, Name::Builtin + + # Quasiquotations + rule %r/(\[)([_a-z][\w']*)(\|)/ do |m| + token Operator, m[1] + token Name, m[2] + token Operator, m[3] + push :quasiquotation + end + + rule %r/[\[\](),;`{}]/, Punctuation + end + + state :import do + rule %r/\s+/, Text + rule %r/"/, Str, :string + rule %r/\bqualified\b/, Keyword + # import X as Y + rule %r/([A-Z][\w.]*)(\s+)(as)(\s+)([A-Z][a-zA-Z0-9_.]*)/ do + groups( + Name::Namespace, # X + Text, Keyword, # as + Text, Name # Y + ) + pop! + end + + # import X hiding (functions) + rule %r/([A-Z][\w.]*)(\s+)(hiding)(\s+)(\()/ do + groups( + Name::Namespace, # X + Text, Keyword, # hiding + Text, Punctuation # ( + ) + goto :funclist + end + + # import X (functions) + rule %r/([A-Z][\w.]*)(\s+)(\()/ do + groups( + Name::Namespace, # X + Text, + Punctuation # ( + ) + goto :funclist + end + + rule %r/[\w.]+/, Name::Namespace, :pop! + end + + state :module do + rule %r/\s+/, Text + # module Foo (functions) + rule %r/([A-Z][\w.]*)(\s+)(\()/ do + groups Name::Namespace, Text, Punctuation + push :funclist + end + + rule %r/\bwhere\b/, Keyword::Reserved, :pop! + + rule %r/[A-Z][a-zA-Z0-9_.]*/, Name::Namespace, :pop! + end + + state :funclist do + mixin :basic + rule %r/[A-Z]\w*/, Keyword::Type + rule %r/(_[\w\']+|[a-z][\w\']*)/, Name::Function + rule %r/,/, Punctuation + rule %r/[:!#\$\%&*+.\\\/<=>?@^\|~-]+/, Operator + rule %r/\(/, Punctuation, :funclist + rule %r/\)/, Punctuation, :pop! + end + + state :character do + rule %r/\\/ do + token Str::Escape + goto :character_end + push :escape + end + + rule %r/./ do + token Str::Char + goto :character_end + end + end + + state :character_end do + rule %r/'/, Str::Char, :pop! + rule %r/./, Error, :pop! + end + + state :quasiquotation do + rule %r/\|\]/, Operator, :pop! + rule %r/[^\|]+/m, Text + rule %r/\|/, Text + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\/, Str::Escape, :escape + rule %r/[^\\"]+/, Str + end + + state :escape do + rule %r/[abfnrtv"'&\\]/, Str::Escape, :pop! + rule %r/\^[\]\[A-Z@\^_]/, Str::Escape, :pop! + rule %r/#{ascii.join('|')}/, Str::Escape, :pop! + rule %r/o[0-7]+/i, Str::Escape, :pop! + rule %r/x[\da-f]+/i, Str::Escape, :pop! + rule %r/\d+/, Str::Escape, :pop! + rule %r/\s+\\/, Str::Escape, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/haxe.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/haxe.rb new file mode 100644 index 0000000..bca64ce --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/haxe.rb @@ -0,0 +1,265 @@ +# -*- coding: utf-8 -*- # + +module Rouge + module Lexers + class Haxe < RegexLexer + title "Haxe" + desc "Haxe Cross-platform Toolkit (http://haxe.org)" + + tag 'haxe' + aliases 'hx', 'haxe' + filenames '*.hx' + mimetypes 'text/haxe', 'text/x-haxe', 'text/x-hx' + + def self.detect?(text) + return true if text.shebang? "haxe" + end + + def self.keywords + @keywords ||= Set.new %w( + as break case cast catch class continue default do else enum false for + function if import in interface macro new null override package private + public return switch this throw true try untyped while + ) + end + + def self.imports + @imports ||= Set.new %w( + package import using + ) + end + + def self.declarations + @declarations ||= Set.new %w( + abstract dynamic extern extends from implements inline static to + typedef var + ) + end + + def self.reserved + @reserved ||= Set.new %w( + super trace inline build autoBuild enum + ) + end + + def self.constants + @constants ||= Set.new %w(true false null) + end + + def self.builtins + @builtins ||= %w( + Void Dynamic Math Class Any Float Int UInt String StringTools Sys + EReg isNaN parseFloat parseInt this Array Map Date DateTools Bool + Lambda Reflect Std File FileSystem + ) + end + + id = /[$a-zA-Z_][a-zA-Z0-9_]*/ + dotted_id = /[$a-zA-Z_][a-zA-Z0-9_.]*/ + + state :comments_and_whitespace do + rule %r/\s+/, Text + rule %r(//.*?$), Comment::Single + rule %r(/\*.*?\*/)m, Comment::Multiline + end + + state :expr_start do + mixin :comments_and_whitespace + + rule %r/#(?:if|elseif|else|end).*/, Comment::Preproc + + rule %r(~) do + token Str::Regex + goto :regex + end + + rule %r/[{]/, Punctuation, :object + + rule %r//, Text, :pop! + end + + state :namespace do + mixin :comments_and_whitespace + + rule %r/ + (#{dotted_id}) + (\s+)(in|as)(\s+) + (#{id}) + /x do + groups(Name::Namespace, Text::Whitespace, Keyword, Text::Whitespace, Name) + end + + rule %r/#{dotted_id}/, Name::Namespace + + rule(//) { pop! } + end + + state :regex do + rule %r(/) do + token Str::Regex + goto :regex_end + end + + rule %r([^/]\n), Error, :pop! + + rule %r/\n/, Error, :pop! + rule %r/\[\^/, Str::Escape, :regex_group + rule %r/\[/, Str::Escape, :regex_group + rule %r/\\./, Str::Escape + rule %r{[(][?][:=> | == + | != )x, + Operator, :expr_start + rule %r([-:<>+*%&|\^/!=]=?), Operator, :expr_start + rule %r/[(\[,]/, Punctuation, :expr_start + rule %r/;/, Punctuation, :statement + rule %r/[)\]}.]/, Punctuation + + rule %r/[?]/ do + token Punctuation + push :ternary + push :expr_start + end + + rule id do |m| + match = m[0] + + if self.class.imports.include?(match) + token Keyword::Namespace + push :namespace + elsif self.class.keywords.include?(match) + token Keyword + push :expr_start + elsif self.class.declarations.include?(match) + token Keyword::Declaration + push :expr_start + elsif self.class.reserved.include?(match) + token Keyword::Reserved + elsif self.class.constants.include?(match) + token Keyword::Constant + elsif self.class.builtins.include?(match) + token Name::Builtin + else + token Name::Other + end + end + + rule %r/\-?\d+\.\d+(?:[eE]\d+)?[fd]?/, Num::Float + rule %r/0x\h+/, Num::Hex + rule %r/\-?[0-9]+/, Num::Integer + rule %r/"/, Str::Double, :str_double + rule %r/'/, Str::Single, :str_single + end + + # braced parts that aren't object literals + state :statement do + rule %r/(#{id})(\s*)(:)/ do + groups Name::Label, Text, Punctuation + end + + mixin :expr_start + end + + # object literals + state :object do + mixin :comments_and_whitespace + rule %r/[}]/ do + token Punctuation + goto :statement + end + + rule %r/(#{id})(\s*)(:)/ do + groups Name::Attribute, Text, Punctuation + push :expr_start + end + + rule %r/:/, Punctuation + mixin :root + end + + state :metadata do + rule %r/(#{id})(\()?/ do |m| + groups Name::Decorator, Punctuation + pop! unless m[2] + end + rule %r/:#{id}(?:\.#{id})*/, Name::Decorator, :pop! + rule %r/\)/, Name::Decorator, :pop! + mixin :root + end + + # ternary expressions, where : is not a label! + state :ternary do + rule %r/:/ do + token Punctuation + goto :expr_start + end + + mixin :root + end + + state :str_double do + mixin :str_escape + rule %r/"/, Str::Double, :pop! + rule %r/[^\\"]+/, Str::Double + end + + state :str_single do + mixin :str_escape + rule %r/'/, Str::Single, :pop! + rule %r/\$\$/, Str::Single + rule %r/\$#{id}/, Str::Interpol + rule %r/\$\{/, Str::Interpol, :str_interpol + rule %r/[^\\$']+/, Str::Single + end + + state :str_escape do + rule %r/\\[\\tnr'"]/, Str::Escape + rule %r/\\[0-7]{3}/, Str::Escape + rule %r/\\x\h{2}/, Str::Escape + rule %r/\\u\h{4}/, Str::Escape + rule %r/\\u\{\h{1,6}\}/, Str::Escape + end + + state :str_interpol do + rule %r/\}/, Str::Interpol, :pop! + mixin :root + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hcl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hcl.rb new file mode 100644 index 0000000..69a65f9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hcl.rb @@ -0,0 +1,166 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Hcl < RegexLexer + tag 'hcl' + filenames '*.hcl', '*.nomad' + + title 'Hashicorp Configuration Language' + desc 'Hashicorp Configuration Language, used by Terraform and other Hashicorp tools' + + state :multiline_comment do + rule %r([*]/), Comment::Multiline, :pop! + rule %r([^*/]+), Comment::Multiline + rule %r([*/]), Comment::Multiline + end + + state :comments_and_whitespace do + rule %r/\s+/, Text + rule %r(//.*?$), Comment::Single + rule %r(#.*?$), Comment::Single + rule %r(/[*]), Comment::Multiline, :multiline_comment + end + + state :primitives do + rule %r/[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?([kKmMgG]b?)?/, Num::Float + rule %r/[0-9]+([kKmMgG]b?)?/, Num::Integer + rule %r/[-+*\/!%&<>|=:?]/, Operator + + rule %r/"/, Str::Double, :dq + rule %r/'/, Str::Single, :sq + rule %r/(<<-?)(\s*)(\'?)(\\?)(\w+)(\3)/ do |m| + groups Operator, Text, Str::Heredoc, Str::Heredoc, Name::Constant, Str::Heredoc + @heredocstr = Regexp.escape(m[5]) + push :heredoc + end + end + + def self.keywords + @keywords ||= Set.new %w() + end + + def self.declarations + @declarations ||= Set.new %w() + end + + def self.reserved + @reserved ||= Set.new %w() + end + + def self.constants + @constants ||= Set.new %w(true false null) + end + + def self.builtins + @builtins ||= %w() + end + + id = /[$a-z_\-][a-z0-9_\-]*/io + + state :root do + mixin :comments_and_whitespace + mixin :primitives + + rule %r/\{/ do + token Punctuation + push :hash + end + rule %r/\[/ do + token Punctuation + push :array + end + + rule id do |m| + if self.class.keywords.include? m[0] + token Keyword + push :composite + elsif self.class.declarations.include? m[0] + token Keyword::Declaration + push :composite + elsif self.class.reserved.include? m[0] + token Keyword::Reserved + elsif self.class.constants.include? m[0] + token Keyword::Constant + elsif self.class.builtins.include? m[0] + token Name::Builtin + else + token Name::Other + push :composite + end + end + end + + state :composite do + mixin :comments_and_whitespace + + rule %r/[{]/ do + token Punctuation + pop! + push :hash + end + + rule %r/[\[]/ do + token Punctuation + pop! + push :array + end + + mixin :root + + rule %r//, Text, :pop! + end + + state :hash do + mixin :comments_and_whitespace + + rule %r/[.,()\\\/*]/, Punctuation + rule %r/\=/, Punctuation + rule %r/\}/, Punctuation, :pop! + + mixin :root + end + + state :array do + mixin :comments_and_whitespace + + rule %r/[.,()\\\/*]/, Punctuation + rule %r/\]/, Punctuation, :pop! + + mixin :root + end + + state :dq do + rule %r/[^\\"]+/, Str::Double + rule %r/\\"/, Str::Escape + rule %r/"/, Str::Double, :pop! + end + + state :sq do + rule %r/[^\\']+/, Str::Single + rule %r/\\'/, Str::Escape + rule %r/'/, Str::Single, :pop! + end + + state :heredoc do + rule %r/\n/, Str::Heredoc, :heredoc_nl + rule %r/[^$\n]+/, Str::Heredoc + rule %r/[$]/, Str::Heredoc + end + + state :heredoc_nl do + rule %r/\s*(\w+)\s*\n/ do |m| + if m[1] == @heredocstr + token Name::Constant + pop! 2 + else + token Str::Heredoc + end + end + + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hlsl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hlsl.rb new file mode 100644 index 0000000..8fac6fa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hlsl.rb @@ -0,0 +1,166 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'c.rb' + + class HLSL < C + title "HLSL" + desc "HLSL, the High Level Shading Language for DirectX (docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl)" + tag 'hlsl' + filenames '*.hlsl', '*.hlsli' + mimetypes 'text/x-hlsl' + + def self.keywords + @keywords ||= Set.new %w( + asm asm_fragment break case cbuffer centroid class column_major + compile compile_fragment const continue default discard do else export + extern for fxgroup globallycoherent groupshared if in inline inout + interface line lineadj linear namespace nointerpolation noperspective + NULL out packoffset pass pixelfragment point precise return register + row_major sample sampler shared stateblock stateblock_state static + struct switch tbuffer technique technique10 technique11 texture + typedef triangle uniform vertexfragment volatile while + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + dword matrix snorm string unorm unsigned void vector BlendState Buffer + ByteAddressBuffer ComputeShader DepthStencilState DepthStencilView + DomainShader GeometryShader HullShader InputPatch LineStream + OutputPatch PixelShader PointStream RasterizerState RenderTargetView + RasterizerOrderedBuffer RasterizerOrderedByteAddressBuffer + RasterizerOrderedStructuredBuffer RasterizerOrderedTexture1D + RasterizerOrderedTexture1DArray RasterizerOrderedTexture2D + RasterizerOrderedTexture2DArray RasterizerOrderedTexture3D RWBuffer + RWByteAddressBuffer RWStructuredBuffer RWTexture1D RWTexture1DArray + RWTexture2D RWTexture2DArray RWTexture3D SamplerState + SamplerComparisonState StructuredBuffer Texture1D Texture1DArray + Texture2D Texture2DArray Texture2DMS Texture2DMSArray Texture3D + TextureCube TextureCubeArray TriangleStream VertexShader + + bool1 bool2 bool3 bool4 BOOL1 BOOL2 BOOL3 BOOL4 + int1 int2 int3 int4 + half1 half2 half3 half4 + float1 float2 float3 float4 + double1 double2 double3 double4 + + bool1x1 bool1x2 bool1x3 bool1x4 bool2x1 bool2x2 bool2x3 bool2x4 + bool3x1 bool3x2 bool3x3 bool3x4 bool4x1 bool4x2 bool4x3 bool4x4 + BOOL1x1 BOOL1x2 BOOL1x3 BOOL1x4 BOOL2x1 BOOL2x2 BOOL2x3 BOOL2x4 + BOOL3x1 BOOL3x2 BOOL3x3 BOOL3x4 BOOL4x1 BOOL4x2 BOOL4x3 BOOL4x4 + half1x1 half1x2 half1x3 half1x4 half2x1 half2x2 half2x3 half2x4 + half3x1 half3x2 half3x3 half3x4 half4x1 half4x2 half4x3 half4x4 + int1x1 int1x2 int1x3 int1x4 int2x1 int2x2 int2x3 int2x4 + int3x1 int3x2 int3x3 int3x4 int4x1 int4x2 int4x3 int4x4 + float1x1 float1x2 float1x3 float1x4 float2x1 float2x2 float2x3 float2x4 + float3x1 float3x2 float3x3 float3x4 float4x1 float4x2 float4x3 float4x4 + double1x1 double1x2 double1x3 double1x4 double2x1 double2x2 double2x3 double2x4 + double3x1 double3x2 double3x3 double3x4 double4x1 double4x2 double4x3 double4x4 + ) + end + + def self.reserved + @reserved ||= Set.new %w( + auto catch char const_cast delete dynamic_cast enum explicit friend + goto long mutable new operator private protected public + reinterpret_cast short signed sizeof static_cast template this throw + try typename union unsigned using virtual + ) + end + + def self.builtins + @builtins ||= Set.new %w( + abort abs acos all AllMemoryBarrier AllMemoryBarrierWithGroupSync any + AppendStructuredBuffer asdouble asfloat asin asint asuint asuint atan + atan2 ceil CheckAccessFullyMapped clamp clip CompileShader + ConsumeStructuredBuffer cos cosh countbits cross D3DCOLORtoUBYTE4 ddx + ddx_coarse ddx_fine ddy ddy_coarse ddy_fine degrees determinant + DeviceMemoryBarrier DeviceMemoryBarrierWithGroupSync distance dot dst + errorf EvaluateAttributeAtCentroid EvaluateAttributeAtSample + EvaluateAttributeSnapped exp exp2 f16tof32 f32tof16 faceforward + firstbithigh firstbitlow floor fma fmod frac frexp fwidth + GetRenderTargetSampleCount GetRenderTargetSamplePosition + GlobalOrderedCountIncrement GroupMemoryBarrier + GroupMemoryBarrierWithGroupSync InterlockedAdd InterlockedAnd + InterlockedCompareExchange InterlockedCompareStore InterlockedExchange + InterlockedMax InterlockedMin InterlockedOr InterlockedXor isfinite + isinf isnan ldexp length lerp lit log log10 log2 mad max min modf + msad4 mul noise normalize pow printf Process2DQuadTessFactorsAvg + Process2DQuadTessFactorsMax Process2DQuadTessFactorsMin + ProcessIsolineTessFactors ProcessQuadTessFactorsAvg + ProcessQuadTessFactorsMax ProcessQuadTessFactorsMin + ProcessTriTessFactorsAvg ProcessTriTessFactorsMax + ProcessTriTessFactorsMin QuadReadLaneAt QuadSwapX QuadSwapY radians + rcp reflect refract reversebits round rsqrt saturate sign sin sincos + sinh smoothstep sqrt step tan tanh tex1D tex1D tex1Dbias tex1Dgrad + tex1Dlod tex1Dproj tex2D tex2D tex2Dbias tex2Dgrad tex2Dlod tex2Dproj + tex3D tex3D tex3Dbias tex3Dgrad tex3Dlod tex3Dproj texCUBE texCUBE + texCUBEbias texCUBEgrad texCUBElod texCUBEproj transpose trunc + WaveAllBitAnd WaveAllMax WaveAllMin WaveAllBitOr WaveAllBitXor + WaveAllEqual WaveAllProduct WaveAllSum WaveAllTrue WaveAnyTrue + WaveBallot WaveGetLaneCount WaveGetLaneIndex WaveGetOrderedIndex + WaveIsHelperLane WaveOnce WavePrefixProduct WavePrefixSum + WaveReadFirstLane WaveReadLaneAt + + SV_CLIPDISTANCE SV_CLIPDISTANCE0 SV_CLIPDISTANCE1 SV_CULLDISTANCE + SV_CULLDISTANCE0 SV_CULLDISTANCE1 SV_COVERAGE SV_DEPTH + SV_DEPTHGREATEREQUAL SV_DEPTHLESSEQUAL SV_DISPATCHTHREADID + SV_DOMAINLOCATION SV_GROUPID SV_GROUPINDEX SV_GROUPTHREADID + SV_GSINSTANCEID SV_INNERCOVERAGE SV_INSIDETESSFACTOR SV_INSTANCEID + SV_ISFRONTFACE SV_OUTPUTCONTROLPOINTID SV_POSITION SV_PRIMITIVEID + SV_RENDERTARGETARRAYINDEX SV_SAMPLEINDEX SV_STENCILREF SV_TESSFACTOR + SV_VERTEXID SV_VIEWPORTARRAYINDEX + + allow_uav_condition branch call domain earlydepthstencil fastopt + flatten forcecase instance loop maxtessfactor numthreads + outputcontrolpoints outputtopology partitioning patchconstantfunc + unroll + + BINORMAL BINORMAL0 BINORMAL1 BINORMAL2 BINORMAL3 BINORMAL4 + BLENDINDICES0 BLENDINDICES1 BLENDINDICES2 BLENDINDICES3 BLENDINDICES4 + BLENDWEIGHT0 BLENDWEIGHT1 BLENDWEIGHT2 BLENDWEIGHT3 BLENDWEIGHT4 COLOR + COLOR0 COLOR1 COLOR2 COLOR3 COLOR4 NORMAL NORMAL0 NORMAL1 NORMAL2 + NORMAL3 NORMAL4 POSITION POSITION0 POSITION1 POSITION2 POSITION3 + POSITION4 POSITIONT PSIZE0 PSIZE1 PSIZE2 PSIZE3 PSIZE4 TANGENT + TANGENT0 TANGENT1 TANGENT2 TANGENT3 TANGENT4 TESSFACTOR0 TESSFACTOR1 + TESSFACTOR2 TESSFACTOR3 TESSFACTOR4 TEXCOORD0 TEXCOORD1 TEXCOORD2 + TEXCOORD3 TEXCOORD4 + + FOG PSIZE + + VFACE VPOS + + DEPTH0 DEPTH1 DEPTH2 DEPTH3 DEPTH4 + ) + end + + ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+) + id = /[a-zA-Z_][a-zA-Z0-9_]*/ + + state :root do + mixin :expr_whitespace + rule %r( + ([\w*\s]+?[\s*]) # return arguments + (#{id}) # function name + (\s*\([^;]*?\)(?:\s*:\s+#{id})?) # signature + (#{ws}?)({|;) # open brace or semicolon + )mx do |m| + # This is copied from the C lexer + recurse m[1] + token Name::Function, m[2] + recurse m[3] + recurse m[4] + token Punctuation, m[5] + if m[5] == ?{ + push :function + end + end + rule %r/\{/, Punctuation, :function + mixin :statements + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hocon.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hocon.rb new file mode 100644 index 0000000..881a969 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hocon.rb @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'json.rb' + + class HOCON < JSON + title 'HOCON' + desc "Human-Optimized Config Object Notation (https://github.com/lightbend/config)" + tag 'hocon' + filenames '*.hocon' + + state :comments do + # Comments + rule %r(//.*?$), Comment::Single + rule %r(#.*?$), Comment::Single + end + + prepend :root do + mixin :comments + end + + prepend :object do + # Keywords + rule %r/\b(?:include|url|file|classpath)\b/, Keyword + end + + state :name do + rule %r/("(?:\"|[^"\n])*?")(\s*)([:=]|(?={))/ do + groups Name::Label, Text::Whitespace, Punctuation + end + + rule %r/([-\w.]+)(\s*)([:=]|(?={))/ do + groups Name::Label, Text::Whitespace, Punctuation + end + end + + state :value do + mixin :comments + + rule %r/\n/, Text::Whitespace + rule %r/\s+/, Text::Whitespace + + mixin :constants + + # Interpolation + rule %r/[$][{][?]?/, Literal::String::Interpol, :interpolation + + # Strings + rule %r/"""/, Literal::String::Double, :multiline_string + rule %r/"/, Str::Double, :string + + rule %r/\[/, Punctuation, :array + rule %r/{/, Punctuation, :object + + # Symbols (only those not handled by JSON) + rule %r/[()=]/, Punctuation + + # Values + rule %r/[^$"{}\[\]:=,\+#`^?!@*&]+?/, Literal + end + + state :interpolation do + rule %r/[\w\-\.]+?/, Name::Variable + rule %r/}/, Literal::String::Interpol, :pop! + end + + prepend :string do + rule %r/[$][{][?]?/, Literal::String::Interpol, :interpolation + rule %r/[^\\"\${]+/, Literal::String::Double + end + + state :multiline_string do + rule %r/"[^"]{1,2}/, Literal::String::Double + mixin :string + rule %r/"""/, Literal::String::Double, :pop! + end + + prepend :constants do + # Numbers (handle the case where we have multiple periods, ie. IP addresses) + rule %r/\d+\.(\d+\.?){3,}/, Literal + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hql.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hql.rb new file mode 100644 index 0000000..ba7dab4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/hql.rb @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- # + +module Rouge + module Lexers + load_lexer 'sql.rb' + + class HQL < SQL + title "HQL" + desc "Hive Query Language SQL dialect" + tag 'hql' + filenames '*.hql' + + def self.keywords + # sources: + # https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL + # https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF + @keywords ||= Set.new(%w( + ADD ADMIN AFTER ANALYZE ARCHIVE ASC BEFORE BUCKET BUCKETS CASCADE + CHANGE CLUSTER CLUSTERED CLUSTERSTATUS COLLECTION COLUMNS COMMENT + COMPACT COMPACTIONS COMPUTE CONCATENATE CONTINUE DATA DATABASES + DATETIME DAY DBPROPERTIES DEFERRED DEFINED DELIMITED DEPENDENCY DESC + DIRECTORIES DIRECTORY DISABLE DISTRIBUTE ELEM_TYPE ENABLE ESCAPED + EXCLUSIVE EXPLAIN EXPORT FIELDS FILE FILEFORMAT FIRST FORMAT FORMATTED + FUNCTIONS HOLD_DDLTIME HOUR IDXPROPERTIES IGNORE INDEX INDEXES INPATH + INPUTDRIVER INPUTFORMAT ITEMS JAR KEYS KEY_TYPE LIMIT LINES LOAD + LOCATION LOCK LOCKS LOGICAL LONG MAPJOIN MATERIALIZED METADATA MINUS + MINUTE MONTH MSCK NOSCAN NO_DROP OFFLINE OPTION OUTPUTDRIVER + OUTPUTFORMAT OVERWRITE OWNER PARTITIONED PARTITIONS PLUS PRETTY + PRINCIPALS PROTECTION PURGE READ READONLY REBUILD RECORDREADER + RECORDWRITER REGEXP RELOAD RENAME REPAIR REPLACE REPLICATION RESTRICT + REWRITE RLIKE ROLE ROLES SCHEMA SCHEMAS SECOND SEMI SERDE + SERDEPROPERTIES SERVER SETS SHARED SHOW SHOW_DATABASE SKEWED SORT + SORTED SSL STATISTICS STORED STREAMTABLE STRING STRUCT TABLES + TBLPROPERTIES TEMPORARY TERMINATED TINYINT TOUCH TRANSACTIONS UNARCHIVE + UNDO UNIONTYPE UNLOCK UNSET UNSIGNED URI USE UTC UTCTIMESTAMP + VALUE_TYPE VIEW WHILE YEAR IF + + ALL ALTER AND ARRAY AS AUTHORIZATION BETWEEN BIGINT BINARY BOOLEAN + BOTH BY CASE CAST CHAR COLUMN CONF CREATE CROSS CUBE CURRENT + CURRENT_DATE CURRENT_TIMESTAMP CURSOR DATABASE DATE DECIMAL DELETE + DESCRIBE DISTINCT DOUBLE DROP ELSE END EXCHANGE EXISTS EXTENDED + EXTERNAL FALSE FETCH FLOAT FOLLOWING FOR FROM FULL FUNCTION GRANT + GROUP GROUPING HAVING IF IMPORT IN INNER INSERT INT INTERSECT + INTERVAL INTO IS JOIN LATERAL LEFT LESS LIKE LOCAL MACRO MAP MORE + NONE NOT NULL OF ON OR ORDER OUT OUTER OVER PARTIALSCAN PARTITION + PERCENT PRECEDING PRESERVE PROCEDURE RANGE READS REDUCE REVOKE RIGHT + ROLLUP ROW ROWS SELECT SET SMALLINT TABLE TABLESAMPLE THEN TIMESTAMP + TO TRANSFORM TRIGGER TRUE TRUNCATE UNBOUNDED UNION UNIQUEJOIN UPDATE + USER USING UTC_TMESTAMP VALUES VARCHAR WHEN WHERE WINDOW WITH + + AUTOCOMMIT ISOLATION LEVEL OFFSET SNAPSHOT TRANSACTION WORK WRITE + + COMMIT ONLY REGEXP RLIKE ROLLBACK START + + ABORT KEY LAST NORELY NOVALIDATE NULLS RELY VALIDATE + + CACHE CONSTRAINT FOREIGN PRIMARY REFERENCES + + DETAIL DOW EXPRESSION OPERATOR QUARTER SUMMARY VECTORIZATION WEEK YEARS MONTHS WEEKS DAYS HOURS MINUTES SECONDS + + DAYOFWEEK EXTRACT FLOOR INTEGER PRECISION VIEWS + + TIMESTAMPTZ ZONE + + TIME NUMERIC + + NAMED_STRUCT CREATE_UNION + + ROUND BROUND FLOOR CEIL CEILING RAND EXP LN LOG10 LOG2 LOG POW POWER SQRT BIN + HEX UNHEX CONV ABS PMOD SIN ASIN COS ACOS TAN ATAN DEGREES RADIANS POSITIVE + NEGATIVE SIGN E PI FACTORIAL CBRT SHIFTLEFT SHIFTRIGHT SHIFTRIGHTUNSIGNED + GREATEST LEAST WIDTH_BUCKET SIZE SIZE MAP_KEYS MAP_VALUES ARRAY_CONTAINS + SORT_ARRAY BINARY CAST FROM_UNIXTIME UNIX_TIMESTAMP UNIX_TIMESTAMP + UNIX_TIMESTAMP TO_DATE YEAR QUARTER MONTH DAY DAYOFMONTH HOUR MINUTE SECOND + WEEKOFYEAR EXTRACT DATEDIFF DATE_ADD DATE_SUB FROM_UTC_TIMESTAMP + TO_UTC_TIMESTAMP CURRENT_DATE CURRENT_TIMESTAMP ADD_MONTHS LAST_DAY NEXT_DAY + TRUNC MONTHS_BETWEEN DATE_FORMAT IF ISNULL ISNOTNULL NVL COALESCE CASE WHEN + then else end NULLIF ASSERT_TRUE ASCII BASE64 CHARACTER_LENGTH CHR CONCAT + CONTEXT_NGRAMS CONCAT_WS CONCAT_WS DECODE ELT ENCODE FIELD FIND_IN_SET + FORMAT_NUMBER GET_JSON_OBJECT IN_FILE INSTR LENGTH LOCATE LOWER LCASE LPAD LTRIM + NGRAMS OCTET_LENGTH PARSE_URL PRINTF REGEXP_EXTRACT REGEXP_REPLACE REPEAT + REPLACE REVERSE RPAD RTRIM SENTENCES SPACE SPLIT STR_TO_MAP SUBSTR SUBSTRING + SUBSTRING_INDEX TRANSLATE TRIM UNBASE64 UPPER UCASE INITCAP LEVENSHTEIN SOUNDEX + MASK MASK_FIRST_N MASK_LAST_N MASK_SHOW_FIRST_N MASK_SHOW_LAST_N MASK_HASH + JAVA_METHOD REFLECT HASH CURRENT_USER LOGGED_IN_USER CURRENT_DATABASE MD5 SHA1 + SHA CRC32 SHA2 AES_ENCRYPT AES_DECRYPT VERSION COUNT SUM AVG MIN MAX VARIANCE + VAR_POP VAR_SAMP STDDEV_POP STDDEV_SAMP COVAR_POP COVAR_SAMP CORR PERCENTILE + PERCENTILE_APPROX PERCENTILE_APPROX REGR_AVGX REGR_AVGY REGR_COUNT + REGR_INTERCEPT REGR_R2 REGR_SLOPE REGR_SXX REGR_SXY REGR_SYY HISTOGRAM_NUMERIC + COLLECT_SET COLLECT_LIST NTILE EXPLODE EXPLODE POSEXPLODE INLINE STACK + + JSON_TUPLE PARSE_URL_TUPLE + + XPATH XPATH_SHORT XPATH_INT XPATH_LONG XPATH_FLOAT XPATH_DOUBLE + XPATH_NUMBER XPATH_STRING GET_JSON_OBJECT JSON_TUPLE + + PARSE_URL_TUPLE + )) + end + + def self.keywords_type + # source: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types + @keywords_type ||= Set.new(%w( + TINYINT SMALLINT INT INTEGER BIGINT FLOAT DOUBLE PRECISION DECIMAL NUMERIC + TIMESTAMP DATE INTERVAL + STRING VARCHAR CHAR + BOOLEAN BINARY + ARRAY MAP STRUCT UNIONTYPE + )) + end + + prepend :root do + # a double-quoted string is a string literal in Hive QL. + rule %r/"/, Str::Double, :double_string + + # interpolation of variables through ${...} + rule %r/\$\{/, Name::Variable, :hive_variable + end + + prepend :single_string do + rule %r/\$\{/, Name::Variable, :hive_variable + rule %r/[^\\'\$]+/, Str::Single + end + + prepend :double_string do + rule %r/\$\{/, Name::Variable, :hive_variable + # double-quoted strings are string literals so need to change token + rule %r/"/, Str::Double, :pop! + rule %r/[^\\"\$]+/, Str::Double + end + + state :hive_variable do + rule %r/\}/, Name::Variable, :pop! + rule %r/[^\}]+/, Name::Variable + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/html.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/html.rb new file mode 100644 index 0000000..3ed80de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/html.rb @@ -0,0 +1,141 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class HTML < RegexLexer + title "HTML" + desc "HTML, the markup language of the web" + tag 'html' + filenames '*.htm', '*.html', '*.xhtml', '*.cshtml' + mimetypes 'text/html', 'application/xhtml+xml' + + def self.detect?(text) + return true if text.doctype?(/\bhtml\b/i) + return false if text =~ /\A<\?xml\b/ + return true if text =~ /<\s*html\b/ + end + + start do + @javascript = Javascript.new(options) + @css = CSS.new(options) + end + + state :root do + rule %r/[^<&]+/m, Text + rule %r/&\S*?;/, Name::Entity + rule %r//im, Comment::Preproc + rule %r//m, Comment::Preproc + rule %r//, Comment, :pop! + rule %r/-/, Comment + end + + state :tag do + rule %r/\s+/m, Text + rule %r/[\p{L}:_\[\]()*.-][\p{Word}\p{Cf}:.·\[\]()*-]*\s*=\s*/m, Name::Attribute, :attr + rule %r/[\p{L}:_*#-][\p{Word}\p{Cf}:.·*#-]*/, Name::Attribute + rule %r(/?\s*>)m, Name::Tag, :pop! + end + + state :attr do + # TODO: are backslash escapes valid here? + rule %r/"/ do + token Str + goto :dq + end + + rule %r/'/ do + token Str + goto :sq + end + + rule %r/[^\s>]+/, Str, :pop! + end + + state :dq do + rule %r/"/, Str, :pop! + rule %r/[^"]+/, Str + end + + state :sq do + rule %r/'/, Str, :pop! + rule %r/[^']+/, Str + end + + state :script_content do + rule %r([^<]+) do + delegate @javascript + end + + rule %r(<\s*/\s*script\s*>)m, Name::Tag, :pop! + + rule %r(<) do + delegate @javascript + end + end + + state :style_content do + rule %r/[^<]+/ do + delegate @lang + end + + rule %r(<\s*/\s*style\s*>)m, Name::Tag, :pop! + + rule %r/ ->> . / // + //= /= < << <<= <= = > >= >> + >>= @ @= ^ ^= accumulate apply as-> assoc butlast + calling-module-name car cdr chain coll? combinations comp complement compress cond + cons cons? constantly count cut cycle dec defclass defmacro defmacro! + defmacro/g! defmain defn defreader dict-comp disassemble dispatch-reader-macro distinct do doto + drop drop-last drop-while empty? eval eval-and-compile eval-when-compile even? every? filter + first flatten float? fn for* fraction genexpr gensym get group-by + identity if* if-not if-python2 inc input instance? integer integer-char? integer? + interleave interpose islice iterable? iterate iterator? juxt keyword keyword? last + let lif lif-not list* list-comp macro-error macroexpand macroexpand-1 map merge-with + multicombinations name neg? none? not-in not? nth numeric? odd? partition + permutations pos? product quasiquote quote range read read-str reduce remove + repeat repeatedly require rest second set-comp setv some string string? + symbol? take take-nth take-while tee unless unquote unquote-splicing when with* + with-decorator with-gensyms xor yield-from zero? zip zip-longest | |= ~ + ) + end + + identifier = %r([\w!$%*+,<=>?/.-]+) + keyword = %r([\w!\#$%*+,<=>?/.-]+) + + def name_token(name) + return Keyword if self.class.keywords.include?(name) + return Name::Builtin if self.class.builtins.include?(name) + nil + end + + state :root do + rule %r/;.*?$/, Comment::Single + rule %r/\s+/m, Text::Whitespace + + rule %r/-?\d+\.\d+/, Num::Float + rule %r/-?\d+/, Num::Integer + rule %r/0x-?[0-9a-fA-F]+/, Num::Hex + + rule %r/"(\\.|[^"])*"/, Str + rule %r/'#{keyword}/, Str::Symbol + rule %r/::?#{keyword}/, Name::Constant + rule %r/\\(.|[a-z]+)/i, Str::Char + + + rule %r/~@|[`\'#^~&@]/, Operator + + rule %r/(\()(\s*)(#{identifier})/m do |m| + token Punctuation, m[1] + token Text::Whitespace, m[2] + token(name_token(m[3]) || Name::Function, m[3]) + end + + rule identifier do |m| + token name_token(m[0]) || Name + end + + # vectors + rule %r/[\[\]]/, Punctuation + + # maps + rule %r/[{}]/, Punctuation + + # parentheses + rule %r/[()]/, Punctuation + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/idlang.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/idlang.rb new file mode 100644 index 0000000..6431ce4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/idlang.rb @@ -0,0 +1,312 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# vim: set ts=2 sw=2 et: + +module Rouge + module Lexers + class IDLang < RegexLexer + title "IDL" + desc "Interactive Data Language" + + tag 'idlang' + filenames '*.idl' + + name = /[_A-Z]\w*/i + kind_param = /(\d+|#{name})/ + exponent = /[dDeE][+-]\d+/ + + def self.exec_unit + @exec_unit ||= Set.new %w( + PRO FUNCTION + ) + end + + def self.keywords + @keywords ||= Set.new %w( + STRUCT INHERITS + RETURN CONTINUE BEGIN END BREAK GOTO + ) + end + + def self.standalone_statements + # Must not have a comma afterwards + @standalone_statements ||= Set.new %w( + COMMON FORWARD_FUNCTION + ) + end + + def self.decorators + # Must not have a comma afterwards + @decorators ||= Set.new %w( + COMPILE_OPT + ) + end + + def self.operators + @operators ||= Set.new %w( + AND= EQ= GE= GT= LE= LT= MOD= NE= OR= XOR= NOT= + ) + end + + def self.conditionals + @conditionals ||= Set.new %w( + OF DO ENDIF ENDELSE ENDFOR ENDFOREACH ENDWHILE ENDREP ENDCASE ENDSWITCH + IF THEN ELSE FOR FOREACH WHILE REPEAT UNTIL CASE SWITCH + AND EQ GE GT LE LT MOD NE OR XOR NOT + ) + end + + def self.routines + @routines ||= Set.new %w( + A_CORRELATE ABS ACOS ADAPT_HIST_EQUAL ALOG ALOG10 + AMOEBA ANNOTATE ARG_PRESENT ARRAY_EQUAL + ARRAY_INDICES ARROW ASCII_TEMPLATE ASIN ASSOC ATAN + AXIS BAR_PLOT BESELI BESELJ BESELK BESELY BETA + BILINEAR BIN_DATE BINARY_TEMPLATE BINDGEN BINOMIAL + BLAS_AXPY BLK_CON BOX_CURSOR BREAK BREAKPOINT + BROYDEN BYTARR BYTE BYTEORDER BYTSCL C_CORRELATE + CALDAT CALENDAR CALL_EXTERNAL CALL_FUNCTION + CALL_METHOD CALL_PROCEDURE CATCH CD CEIL CHEBYSHEV + CHECK_MATH CHISQR_CVF CHISQR_PDF CHOLDC CHOLSOL + CINDGEN CIR_3PNT CLOSE CLUST_WTS CLUSTER + COLOR_CONVERT COLOR_QUAN COLORMAP_APPLICABLE COMFIT + COMPLEX COMPLEXARR COMPLEXROUND + COMPUTE_MESH_NORMALS COND CONGRID CONJ + CONSTRAINED_MIN CONTOUR CONVERT_COORD CONVOL + COORD2TO3 CORRELATE COS COSH CRAMER CREATE_STRUCT + CREATE_VIEW CROSSP CRVLENGTH CT_LUMINANCE CTI_TEST + CURSOR CURVEFIT CV_COORD CVTTOBM CW_ANIMATE + CW_ANIMATE_GETP CW_ANIMATE_LOAD CW_ANIMATE_RUN + CW_ARCBALL CW_BGROUP CW_CLR_INDEX CW_COLORSEL + CW_DEFROI CW_FIELD CW_FILESEL CW_FORM CW_FSLIDER + CW_LIGHT_EDITOR CW_LIGHT_EDITOR_GET + CW_LIGHT_EDITOR_SET CW_ORIENT CW_PALETTE_EDITOR + CW_PALETTE_EDITOR_GET CW_PALETTE_EDITOR_SET + CW_PDMENU CW_RGBSLIDER CW_TMPL CW_ZOOM DBLARR + DCINDGEN DCOMPLEX DCOMPLEXARR DEFINE_KEY DEFROI + DEFSYSV DELETE_SYMBOL DELLOG DELVAR DERIV DERIVSIG + DETERM DEVICE DFPMIN DIALOG_MESSAGE + DIALOG_PICKFILE DIALOG_PRINTERSETUP + DIALOG_PRINTJOB DIALOG_READ_IMAGE + DIALOG_WRITE_IMAGE DICTIONARY DIGITAL_FILTER DILATE DINDGEN + DISSOLVE DIST DLM_LOAD DLM_REGISTER + DO_APPLE_SCRIPT DOC_LIBRARY DOUBLE DRAW_ROI EFONT + EIGENQL EIGENVEC ELMHES EMPTY ENABLE_SYSRTN EOF + ERASE ERODE ERRORF ERRPLOT EXECUTE EXIT EXP EXPAND + EXPAND_PATH EXPINT EXTRAC EXTRACT_SLICE F_CVF + F_PDF FACTORIAL FFT FILE_CHMOD FILE_DELETE + FILE_EXPAND_PATH FILE_MKDIR FILE_TEST FILE_WHICH + FILE_SEARCH PATH_SEP FILE_DIRNAME FILE_BASENAME + FILE_INFO FILE_MOVE FILE_COPY FILE_LINK FILE_POLL_INPUT + FILEPATH FINDFILE FINDGEN FINITE FIX FLICK FLOAT + FLOOR FLOW3 FLTARR FLUSH FORMAT_AXIS_VALUES + FORWARD_FUNCTION FREE_LUN FSTAT FULSTR FUNCT + FV_TEST FX_ROOT FZ_ROOTS GAMMA GAMMA_CT + GAUSS_CVF GAUSS_PDF GAUSS2DFIT GAUSSFIT GAUSSINT + GET_DRIVE_LIST GET_KBRD GET_LUN GET_SCREEN_SIZE + GET_SYMBOL GETENV GOTO GREG2JUL GRID_TPS GRID3 GS_ITER + H_EQ_CT H_EQ_INT HANNING HASH HEAP_GC HELP HILBERT + HIST_2D HIST_EQUAL HISTOGRAM HLS HOUGH HQR HSV + IBETA IDENTITY IDL_CONTAINER IDLANROI + IDLANROIGROUP IDLFFDICOM IDLFFDXF IDLFFLANGUAGECAT + IDLFFSHAPE IDLGRAXIS IDLGRBUFFER IDLGRCLIPBOARD + IDLGRCOLORBAR IDLGRCONTOUR IDLGRFONT IDLGRIMAGE + IDLGRLEGEND IDLGRLIGHT IDLGRMODEL IDLGRMPEG + IDLGRPALETTE IDLGRPATTERN IDLGRPLOT IDLGRPOLYGON + IDLGRPOLYLINE IDLGRPRINTER IDLGRROI IDLGRROIGROUP + IDLGRSCENE IDLGRSURFACE IDLGRSYMBOL + IDLGRTESSELLATOR IDLGRTEXT IDLGRVIEW + IDLGRVIEWGROUP IDLGRVOLUME IDLGRVRML IDLGRWINDOW + IGAMMA IMAGE_CONT IMAGE_STATISTICS IMAGINARY + INDGEN INT_2D INT_3D INT_TABULATED INTARR INTERPOL + INTERPOLATE INVERT IOCTL ISA ISHFT ISOCONTOUR + ISOSURFACE JOURNAL JUL2GREG JULDAY KEYWORD_SET KRIG2D + KURTOSIS KW_TEST L64INDGEN LABEL_DATE LABEL_REGION + LADFIT LAGUERRE LEEFILT LEGENDRE LINBCG LINDGEN + LINFIT LINKIMAGE LIST LIVE_CONTOUR LIVE_CONTROL + LIVE_DESTROY LIVE_EXPORT LIVE_IMAGE LIVE_INFO + LIVE_LINE LIVE_LOAD LIVE_OPLOT LIVE_PLOT + LIVE_PRINT LIVE_RECT LIVE_STYLE LIVE_SURFACE + LIVE_TEXT LJLCT LL_ARC_DISTANCE LMFIT LMGR LNGAMMA + LNP_TEST LOADCT LOCALE_GET LON64ARR LONARR LONG + LONG64 LSODE LU_COMPLEX LUDC LUMPROVE LUSOL + M_CORRELATE MACHAR MAKE_ARRAY MAKE_DLL MAP_2POINTS + MAP_CONTINENTS MAP_GRID MAP_IMAGE MAP_PATCH + MAP_PROJ_INFO MAP_SET MAX MATRIX_MULTIPLY MD_TEST MEAN + MEANABSDEV MEDIAN MEMORY MESH_CLIP MESH_DECIMATE + MESH_ISSOLID MESH_MERGE MESH_NUMTRIANGLES MESH_OBJ + MESH_SMOOTH MESH_SURFACEAREA MESH_VALIDATE + MESH_VOLUME MESSAGE MIN MIN_CURVE_SURF MK_HTML_HELP + MODIFYCT MOMENT MORPH_CLOSE MORPH_DISTANCE + MORPH_GRADIENT MORPH_HITORMISS MORPH_OPEN + MORPH_THIN MORPH_TOPHAT MPEG_CLOSE MPEG_OPEN + MPEG_PUT MPEG_SAVE MSG_CAT_CLOSE MSG_CAT_COMPILE + MSG_CAT_OPEN MULTI N_ELEMENTS N_PARAMS N_TAGS + NEWTON NORM OBJ_CLASS OBJ_DESTROY OBJ_ISA OBJ_NEW + OBJ_VALID OBJARR ON_ERROR ON_IOERROR ONLINE_HELP + OPEN OPENR OPENW OPENU OPLOT OPLOTERR ORDEREDHASH P_CORRELATE + PARTICLE_TRACE PCOMP PLOT PLOT_3DBOX PLOT_FIELD + PLOTERR PLOTS PNT_LINE POINT_LUN POLAR_CONTOUR + POLAR_SURFACE POLY POLY_2D POLY_AREA POLY_FIT + POLYFILL POLYFILLV POLYSHADE POLYWARP POPD POWELL + PRIMES PRINT PRINTF PRINTD PRODUCT PROFILE PROFILER + PROFILES PROJECT_VOL PS_SHOW_FONTS PSAFM PSEUDO + PTR_FREE PTR_NEW PTR_VALID PTRARR PUSHD QROMB + QROMO QSIMP QUERY_CSV R_CORRELATE R_TEST RADON RANDOMN + RANDOMU RANKS RDPIX READ READF READ_ASCII + READ_BINARY READ_BMP READ_CSV READ_DICOM READ_IMAGE + READ_INTERFILE READ_JPEG READ_PICT READ_PNG + READ_PPM READ_SPR READ_SRF READ_SYLK READ_TIFF + READ_WAV READ_WAVE READ_X11_BITMAP READ_XWD READS + READU REBIN RECALL_COMMANDS RECON3 REDUCE_COLORS + REFORM REGRESS REPLICATE REPLICATE_INPLACE + RESOLVE_ALL RESOLVE_ROUTINE RESTORE RETALL + REVERSE REWIND RK4 ROBERTS ROT ROTATE ROUND + ROUTINE_INFO RS_TEST S_TEST SAVE SAVGOL SCALE3 + SCALE3D SCOPE_LEVEL SCOPE_TRACEBACK SCOPE_VARFETCH + SCOPE_VARNAME SEARCH2D SEARCH3D SET_PLOT SET_SHADING + SET_SYMBOL SETENV SETLOG SETUP_KEYS SFIT + SHADE_SURF SHADE_SURF_IRR SHADE_VOLUME SHIFT SHOW3 + SHOWFONT SIGNUM SIN SINDGEN SINH SIZE SKEWNESS SKIPF + SLICER3 SLIDE_IMAGE SMOOTH SOBEL SOCKET SORT SPAWN + SPH_4PNT SPH_SCAT SPHER_HARM SPL_INIT SPL_INTERP + SPLINE SPLINE_P SPRSAB SPRSAX SPRSIN SPRSTP SQRT + STANDARDIZE STDDEV STOP STRARR STRCMP STRCOMPRESS + STREAMLINE STREGEX STRETCH STRING STRJOIN STRLEN + STRLOWCASE STRMATCH STRMESSAGE STRMID STRPOS + STRPUT STRSPLIT STRTRIM STRUCT_ASSIGN STRUCT_HIDE + STRUPCASE SURFACE SURFR SVDC SVDFIT SVSOL + SWAP_ENDIAN SWITCH SYSTIME T_CVF T_PDF T3D + TAG_NAMES TAN TANH TAPRD TAPWRT TEK_COLOR + TEMPORARY TETRA_CLIP TETRA_SURFACE TETRA_VOLUME + THIN THREED TIME_TEST2 TIMEGEN TM_TEST TOTAL TRACE + TRANSPOSE TRI_SURF TRIANGULATE TRIGRID TRIQL + TRIRED TRISOL TRNLOG TS_COEF TS_DIFF TS_FCAST + TS_SMOOTH TV TVCRS TVLCT TVRD TVSCL TYPENAME UINDGEN UINT + UINTARR UL64INDGEN ULINDGEN ULON64ARR ULONARR + ULONG ULONG64 UNIQ USERSYM VALUE_LOCATE VARIANCE + VAX_FLOAT VECTOR_FIELD VEL VELOVECT VERT_T3D VOIGT + VORONOI VOXEL_PROJ WAIT WARP_TRI WATERSHED WDELETE + WEOF WF_DRAW WHERE WIDGET_BASE WIDGET_BUTTON + WIDGET_CONTROL WIDGET_DRAW WIDGET_DROPLIST + WIDGET_EVENT WIDGET_INFO WIDGET_LABEL WIDGET_LIST + WIDGET_SLIDER WIDGET_TABLE WIDGET_TEXT WINDOW + WRITE_BMP WRITE_CSV WRITE_IMAGE WRITE_JPEG WRITE_NRIF + WRITE_PICT WRITE_PNG WRITE_PPM WRITE_SPR WRITE_SRF + WRITE_SYLK WRITE_TIFF WRITE_WAV WRITE_WAVE WRITEU + WSET WSHOW WTN WV_APPLET WV_CW_WAVELET WV_CWT + WV_DENOISE WV_DWT WV_FN_COIFLET WV_FN_DAUBECHIES + WV_FN_GAUSSIAN WV_FN_HAAR WV_FN_MORLET WV_FN_PAUL + WV_FN_SYMLET WV_IMPORT_DATA WV_IMPORT_WAVELET + WV_PLOT3D_WPS WV_PLOT_MULTIRES WV_PWT + WV_TOOL_DENOISE XBM_EDIT XDISPLAYFILE XDXF XFONT + XINTERANIMATE XLOADCT XMANAGER XMNG_TMPL XMTOOL + XOBJVIEW XPALETTE XPCOLOR XPLOT3D XREGISTERED XROI + XSQ_TEST XSURFACE XVAREDIT XVOLUME XVOLUME_ROTATE + XVOLUME_WRITE_IMAGE XYOUTS ZOOM ZOOM_24 + ) + end + + state :root do + rule %r/\s+/, Text::Whitespace + # Normal comments + rule %r/;.*$/, Comment::Single + rule %r/\,\s*\,/, Error + rule %r/\!#{name}/, Name::Variable::Global + + rule %r/[(),:\&\$]/, Punctuation + + ## Format statements are quite a strange beast. + ## Better process them in their own state. + #rule %r/\b(FORMAT)(\s*)(\()/mi do |m| + # token Keyword, m[1] + # token Text::Whitespace, m[2] + # token Punctuation, m[3] + # push :format_spec + #end + + rule %r( + [+-]? # sign + ( + (\d+[.]\d*|[.]\d+)(#{exponent})? + | \d+#{exponent} # exponent is mandatory + ) + (_#{kind_param})? # kind parameter + )xi, Num::Float + + rule %r/\d+(B|S|U|US|LL|L|ULL|UL)?/i, Num::Integer + rule %r/"[0-7]+(B|O|U|ULL|UL|LL|L)?/i, Num::Oct + rule %r/'[0-9A-F]+'X(B|S|US|ULL|UL|U|LL|L)?/i, Num::Hex + rule %r/(#{kind_param}_)?'/, Str::Single, :string_single + rule %r/(#{kind_param}_)?"/, Str::Double, :string_double + + rule %r{\#\#|\#|\&\&|\|\||/=|<=|>=|->|\@|\?|[-+*/<=~^{}]}, Operator + # Structures and the like + rule %r/(#{name})(\.)([^\s,]*)/i do + groups Name, Operator, Name + #delegate IDLang, m[3] + end + + rule %r/(function|pro)((?:\s|\$\s)+)/i do + groups Keyword, Text::Whitespace + push :funcname + end + + rule %r/#{name}/m do |m| + match = m[0].upcase + if self.class.keywords.include? match + token Keyword + elsif self.class.conditionals.include? match + token Keyword + elsif self.class.decorators.include? match + token Name::Decorator + elsif self.class.standalone_statements.include? match + token Keyword::Reserved + elsif self.class.operators.include? match + token Operator::Word + elsif self.class.routines.include? match + token Name::Builtin + else + token Name + end + end + + end + + state :funcname do + rule %r/#{name}/, Name::Function + + rule %r/\s+/, Text::Whitespace + rule %r/(:+|\$)/, Operator + rule %r/;.*/, Comment::Single + + # Be done with this state if we hit EOL or comma + rule %r/$/, Text::Whitespace, :pop! + rule %r/,/, Operator, :pop! + end + + state :string_single do + rule %r/[^']+/, Str::Single + rule %r/''/, Str::Escape + rule %r/'/, Str::Single, :pop! + end + + state :string_double do + rule %r/[^"]+/, Str::Double + rule %r/"/, Str::Double, :pop! + end + + state :format_spec do + rule %r/'/, Str::Single, :string_single + rule %r/"/, Str::Double, :string_double + rule %r/\(/, Punctuation, :format_spec + rule %r/\)/, Punctuation, :pop! + rule %r/,/, Punctuation + rule %r/\s+/, Text::Whitespace + # Edit descriptors could be seen as a kind of "format literal". + rule %r/[^\s'"(),]+/, Literal + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/idris.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/idris.rb new file mode 100644 index 0000000..99b4cb5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/idris.rb @@ -0,0 +1,210 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Idris < RegexLexer + title "Idris" + desc "The Idris programming language (idris-lang.org)" + + tag 'idris' + aliases 'idr' + filenames '*.idr' + mimetypes 'text/x-idris' + + def self.reserved_keywords + @reserved_keywords ||= %w( + _ data class instance namespace + infix[lr]? let where of with type + do if then else case in + ) + end + + def self.ascii + @ascii ||= %w( + NUL SOH [SE]TX EOT ENQ ACK BEL BS HT LF VT FF CR S[OI] DLE + DC[1-4] NAK SYN ETB CAN EM SUB ESC [FGRU]S SP DEL + ) + end + + def self.prelude_functions + @prelude_functions ||= %w( + abs acos all and any asin atan atan2 break ceiling compare concat + concatMap const cos cosh curry cycle div drop dropWhile elem + encodeFloat enumFrom enumFromThen enumFromThenTo enumFromTo exp + fail filter flip floor foldl foldl1 foldr foldr1 fromInteger fst + gcd getChar getLine head id init iterate last lcm length lines log + lookup map max maxBound maximum maybe min minBound minimum mod + negate not null or pi pred print product putChar putStr putStrLn + readFile recip repeat replicate return reverse scanl scanl1 sequence + sequence_ show sin sinh snd span splitAt sqrt succ sum tail take + takeWhile tan tanh uncurry unlines unwords unzip unzip3 words + writeFile zip zip3 zipWith zipWith3 + ) + end + + state :basic do + rule %r/\s+/m, Text + rule %r/{-#/, Comment::Preproc, :comment_preproc + rule %r/{-/, Comment::Multiline, :comment + rule %r/^\|\|\|.*$/, Comment::Doc + rule %r/--(?![!#\$\%&*+.\/<=>?@\^\|_~]).*?$/, Comment::Single + end + + # nested commenting + state :comment do + rule %r/-}/, Comment::Multiline, :pop! + rule %r/{-/, Comment::Multiline, :comment + rule %r/[^-{}]+/, Comment::Multiline + rule %r/[-{}]/, Comment::Multiline + end + state :comment_preproc do + rule %r/-}/, Comment::Preproc, :pop! + rule %r/{-/, Comment::Preproc, :comment + rule %r/[^-{}]+/, Comment::Preproc + rule %r/[-{}]/, Comment::Preproc + end + + state :directive do + rule %r/\%(default)\s+(total|partial)/, Keyword # totality + rule %r/\%(access)\s+(public|abstract|private|export)/, Keyword # export + rule %r/\%(language)\s+(.*)/, Keyword # language + rule %r/\%(provide)\s+.*\s+(with)\s+/, Keyword # type + end + + state :prelude do + rule %r/\b(Type|Exists|World|IO|IntTy|FTy|File|Mode|Dec|Bool|Ordering|Either|IsJust|List|Maybe|Nat|Stream|StrM|Not|Lazy|Inf)\s/, Keyword::Type + rule %r/\b(Eq|Ord|Num|MinBound|MaxBound|Integral|Applicative|Alternative|Cast|Foldable|Functor|Monad|Traversable|Uninhabited|Semigroup|Monoid)\s/, Name::Class + rule %r/\b(?:#{Idris.prelude_functions.join('|')})[ ]+(?![=:-])/, Name::Builtin + end + + state :root do + mixin :basic + mixin :directive + + rule %r/\bimport\b/, Keyword::Reserved, :import + rule %r/\bmodule\b/, Keyword::Reserved, :module + rule %r/\b(?:#{Idris.reserved_keywords.join('|')})\b/, Keyword::Reserved + rule %r/\b(Just|Nothing|Left|Right|True|False|LT|LTE|EQ|GT|GTE)\b/, Keyword::Constant + # function signature + rule %r/^[\w']+\s*:/, Name::Function + # should be below as you can override names defined in Prelude + mixin :prelude + rule %r/[_a-z][\w']*/, Name + rule %r/[A-Z][\w']*/, Keyword::Type + + # lambda operator + rule %r(\\(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Name::Function + # special operators + rule %r((<-|::|->|=>|=)(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Operator + # constructor/type operators + rule %r(:[:!#\$\%&*+.\\/<=>?@^\|~-]*), Operator + # other operators + rule %r([:!#\$\%&*+.\\/<=>?@^\|~-]+), Operator + + rule %r/\d+(\.\d+)?(e[+-]?\d+)?/i, Num::Float + rule %r/0o[0-7]+/i, Num::Oct + rule %r/0x[\da-f]+/i, Num::Hex + rule %r/\d+/, Num::Integer + + rule %r/'/, Str::Char, :character + rule %r/"/, Str, :string + + rule %r/\[\s*\]/, Keyword::Type + rule %r/\(\s*\)/, Name::Builtin + + # Quasiquotations + rule %r/(\[)([_a-z][\w']*)(\|)/ do |m| + token Operator, m[1] + token Name, m[2] + token Operator, m[3] + push :quasiquotation + end + + rule %r/[\[\](),;`{}]/, Punctuation + end + + state :import do + rule %r/\s+/, Text + rule %r/"/, Str, :string + # import X as Y + rule %r/([A-Z][\w.]*)(\s+)(as)(\s+)([A-Z][a-zA-Z0-9_.]*)/ do + groups( + Name::Namespace, # X + Text, Keyword, # as + Text, Name # Y + ) + pop! + end + + # import X (functions) + rule %r/([A-Z][\w.]*)(\s+)(\()/ do + groups( + Name::Namespace, # X + Text, + Punctuation # ( + ) + goto :funclist + end + + rule %r/[\w.]+/, Name::Namespace, :pop! + end + + state :module do + rule %r/\s+/, Text + # module X + rule %r/([A-Z][\w.]*)/, Name::Namespace, :pop! + end + + state :funclist do + mixin :basic + rule %r/[A-Z]\w*/, Keyword::Type + rule %r/(_[\w\']+|[a-z][\w\']*)/, Name::Function + rule %r/,/, Punctuation + rule %r/[:!#\$\%&*+.\\\/<=>?@^\|~-]+/, Operator + rule %r/\(/, Punctuation, :funclist + rule %r/\)/, Punctuation, :pop! + end + + state :character do + rule %r/\\/ do + token Str::Escape + goto :character_end + push :escape + end + + rule %r/./ do + token Str::Char + goto :character_end + end + end + + state :character_end do + rule %r/'/, Str::Char, :pop! + rule %r/./, Error, :pop! + end + + state :quasiquotation do + rule %r/\|\]/, Operator, :pop! + rule %r/[^\|]+/m, Text + rule %r/\|/, Text + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\/, Str::Escape, :escape + rule %r/[^\\"]+/, Str + end + + state :escape do + rule %r/[abfnrtv"'&\\]/, Str::Escape, :pop! + rule %r/\^[\]\[A-Z@\^_]/, Str::Escape, :pop! + rule %r/#{Idris.ascii.join('|')}/, Str::Escape, :pop! + rule %r/o[0-7]+/i, Str::Escape, :pop! + rule %r/x[\da-fA-F]+/i, Str::Escape, :pop! + rule %r/\d+/, Str::Escape, :pop! + rule %r/\s+\\/, Str::Escape, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/iecst.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/iecst.rb new file mode 100644 index 0000000..d1e1196 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/iecst.rb @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class IecST < RegexLexer + tag 'iecst' + title "IEC 61131-3 Structured Text" + desc 'Structured text is a programming language for PLCs (programmable logic controllers).' + filenames '*.awl', '*.scl', '*.st' + + mimetypes 'text/x-iecst' + + def self.keywords + blocks = %w( + PROGRAM CONFIGURATION INITIAL_STEP INTERFACE FUNCTION_BLOCK FUNCTION ACTION TRANSITION + TYPE STRUCT STEP NAMESPACE LIBRARY CHANNEL FOLDER RESOURCE + VAR_ACCESS VAR_CONFIG VAR_EXTERNAL VAR_GLOBAL VAR_INPUT VAR_IN_OUT VAR_OUTPUT VAR_TEMP VAR + CONST METHOD PROPERTY + CASE FOR IF REPEAT WHILE + ) + @keywords ||= Set.new %w( + AT BEGIN BY CONSTANT CONTINUE DO ELSE ELSIF EXIT EXTENDS FROM GET GOTO IMPLEMENTS JMP + NON_RETAIN OF PRIVATE PROTECTED PUBLIC RETAIN RETURN SET TASK THEN TO UNTIL USING WITH + __CATCH __ENDTRY __FINALLY __TRY + ) + blocks + blocks.map {|kw| "END_" + kw} + end + + def self.types + @types ||= Set.new %w( + ANY ARRAY BOOL BYTE POINTER STRING + DATE DATE_AND_TIME DT TIME TIME_OF_DAY TOD + INT DINT LINT SINT UINT UDINT ULINT USINT + WORD DWORD LWORD + REAL LREAL + ) + end + + def self.literals + @literals ||= Set.new %w(TRUE FALSE NULL) + end + + def self.operators + @operators ||= Set.new %w(AND EQ EXPT GE GT LE LT MOD NE NOT OR XOR) + end + + state :whitespace do + # Spaces + rule %r/\s+/m, Text + # // Comments + rule %r((//).*$\n?), Comment::Single + # (* Comments *) + rule %r(\(\*.*?\*\))m, Comment::Multiline + # { Comments } + rule %r(\{.*?\})m, Comment::Special + end + + state :root do + mixin :whitespace + + rule %r/'[^']+'/, Literal::String::Single + rule %r/"[^"]+"/, Literal::String::Symbol + rule %r/%[IQM][XBWDL][\d.]*|%[IQ][\d.]*/, Name::Variable::Magic + rule %r/\b(?:D|DT|T|TOD)#[\d_shmd:]*/i, Literal::Date + rule %r/\b(?:16#[\d_a-f]+|0x[\d_a-f]+)\b/i, Literal::Number::Hex + rule %r/\b2#[01_]+/, Literal::Number::Bin + rule %r/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, Literal::Number::Float + rule %r/\b[\d.,_]+/, Literal::Number + + rule %r/\b[A-Z_]+\b/i do |m| + name = m[0].upcase + if self.class.keywords.include?(name) + token Keyword + elsif self.class.types.include?(name) + token Keyword::Type + elsif self.class.literals.include?(name) + token Literal + elsif self.class.operators.include?(name) + token Operator + else + token Name + end + end + + rule %r/S?R?:?=>?|&&?|\*\*?|<[=>]?|>=?|[-:^\/+#]/, Operator + rule %r/\b[a-z_]\w*(?=\s*\()/i, Name::Function + rule %r/\b[a-z_]\w*\b/i, Name + rule %r/[()\[\].,;]/, Punctuation + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/igorpro.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/igorpro.rb new file mode 100644 index 0000000..a542cea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/igorpro.rb @@ -0,0 +1,664 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class IgorPro < RegexLexer + tag 'igorpro' + filenames '*.ipf' + mimetypes 'text/x-igorpro' + + title "IgorPro" + desc "WaveMetrics Igor Pro" + + def self.keywords + @keywords ||= Set.new %w( + structure endstructure + threadsafe static + macro proc window menu function end + if else elseif endif switch strswitch endswitch + break return continue + for endfor do while + case default + try catch endtry + abortonrte + ) + end + + def self.preprocessor + @preprocessor ||= Set.new %w( + pragma include + define ifdef ifndef undef + if elif else endif + ) + end + + def self.igorDeclarations + @igorDeclarations ||= Set.new %w( + variable string wave strconstant constant + nvar svar dfref funcref struct + char uchar int16 uint16 int32 uint32 int64 uint64 float double + ) + end + + def self.igorConstants + @igorConstants ||= Set.new %w( + nan inf + ) + end + + def self.igorFunction + @igorFunction ||= Set.new %w( + AddListItem AiryA AiryAD AiryB AiryBD AnnotationInfo + AnnotationList AxisInfo AxisList AxisValFromPixel + AxonTelegraphAGetDataNum AxonTelegraphAGetDataString + AxonTelegraphAGetDataStruct AxonTelegraphGetDataNum + AxonTelegraphGetDataString AxonTelegraphGetDataStruct + AxonTelegraphGetTimeoutMs AxonTelegraphSetTimeoutMs + Base64Decode Base64Encode Besseli Besselj Besselk + Bessely BinarySearch BinarySearchInterp CTabList + CaptureHistory CaptureHistoryStart CheckName + ChildWindowList CleanupName ContourInfo ContourNameList + ContourNameToWaveRef ContourZ ControlNameList + ConvertTextEncoding CountObjects CountObjectsDFR + CreationDate CsrInfo CsrWave CsrWaveRef CsrXWave + CsrXWaveRef DataFolderDir DataFolderExists + DataFolderRefStatus DataFolderRefsEqual DateToJulian + Dawson DimDelta DimOffset DimSize Faddeeva FetchURL + FindDimLabel FindListItem FontList FontSizeHeight + FontSizeStringWidth FresnelCos FresnelSin FuncRefInfo + FunctionInfo FunctionList FunctionPath + GISGetAllFileFormats GISSRefsAreEqual Gauss Gauss1D + Gauss2D GetBrowserLine GetBrowserSelection + GetDataFolder GetDataFolderDFR GetDefaultFont + GetDefaultFontSize GetDefaultFontStyle GetDimLabel + GetEnvironmentVariable GetErrMessage GetFormula + GetIndependentModuleName GetIndexedObjName + GetIndexedObjNameDFR GetKeyState GetRTErrMessage + GetRTError GetRTLocInfo GetRTLocation GetRTStackInfo + GetScrapText GetUserData GetWavesDataFolder + GetWavesDataFolderDFR GizmoInfo GizmoScale GrepList + GrepString GuideInfo GuideNameList HDF5AttributeInfo + HDF5DatasetInfo HDF5LibraryInfo HDF5TypeInfo Hash + HyperG0F1 HyperG1F1 HyperG2F1 HyperGNoise HyperGPFQ + IgorInfo IgorVersion ImageInfo ImageNameList + ImageNameToWaveRef IndependentModuleList IndexToScale + IndexedDir IndexedFile Inf Integrate1D Interp2D + Interp3D ItemsInList JacobiCn JacobiSn JulianToDate + Laguerre LaguerreA LaguerreGauss LambertW LayoutInfo + LegendreA ListMatch ListToTextWave ListToWaveRefWave + LowerStr MCC_AutoBridgeBal MCC_AutoFastComp + MCC_AutoPipetteOffset MCC_AutoSlowComp + MCC_AutoWholeCellComp MCC_GetBridgeBalEnable + MCC_GetBridgeBalResist MCC_GetFastCompCap + MCC_GetFastCompTau MCC_GetHolding MCC_GetHoldingEnable + MCC_GetMode MCC_GetNeutralizationCap + MCC_GetNeutralizationEnable MCC_GetOscKillerEnable + MCC_GetPipetteOffset MCC_GetPrimarySignalGain + MCC_GetPrimarySignalHPF MCC_GetPrimarySignalLPF + MCC_GetRsCompBandwidth MCC_GetRsCompCorrection + MCC_GetRsCompEnable MCC_GetRsCompPrediction + MCC_GetSecondarySignalGain MCC_GetSecondarySignalLPF + MCC_GetSlowCompCap MCC_GetSlowCompTau + MCC_GetSlowCompTauX20Enable MCC_GetSlowCurrentInjEnable + MCC_GetSlowCurrentInjLevel + MCC_GetSlowCurrentInjSetlTime MCC_GetWholeCellCompCap + MCC_GetWholeCellCompEnable MCC_GetWholeCellCompResist + MCC_SelectMultiClamp700B MCC_SetBridgeBalEnable + MCC_SetBridgeBalResist MCC_SetFastCompCap + MCC_SetFastCompTau MCC_SetHolding MCC_SetHoldingEnable + MCC_SetMode MCC_SetNeutralizationCap + MCC_SetNeutralizationEnable MCC_SetOscKillerEnable + MCC_SetPipetteOffset MCC_SetPrimarySignalGain + MCC_SetPrimarySignalHPF MCC_SetPrimarySignalLPF + MCC_SetRsCompBandwidth MCC_SetRsCompCorrection + MCC_SetRsCompEnable MCC_SetRsCompPrediction + MCC_SetSecondarySignalGain MCC_SetSecondarySignalLPF + MCC_SetSlowCompCap MCC_SetSlowCompTau + MCC_SetSlowCompTauX20Enable MCC_SetSlowCurrentInjEnable + MCC_SetSlowCurrentInjLevel + MCC_SetSlowCurrentInjSetlTime MCC_SetTimeoutMs + MCC_SetWholeCellCompCap MCC_SetWholeCellCompEnable + MCC_SetWholeCellCompResist MPFXEMGPeak + MPFXExpConvExpPeak MPFXGaussPeak MPFXLorenzianPeak + MPFXVoigtPeak MacroList MandelbrotPoint MarcumQ + MatrixCondition MatrixDet MatrixDot MatrixRank + MatrixTrace ModDate NVAR_Exists NaN NameOfWave + NewFreeDataFolder NewFreeWave NormalizeUnicode + NumVarOrDefault NumberByKey OperationList PICTInfo + PICTList PadString PanelResolution ParamIsDefault + ParseFilePath PathList Pi PixelFromAxisVal PolygonArea + PossiblyQuoteName ProcedureText RemoveByKey + RemoveEnding RemoveFromList RemoveListItem + ReplaceNumberByKey ReplaceString ReplaceStringByKey + SQL2DBinaryWaveToTextWave SQLAllocHandle SQLAllocStmt + SQLBinaryWavesToTextWave SQLBindCol SQLBindParameter + SQLBrowseConnect SQLBulkOperations SQLCancel + SQLCloseCursor SQLColAttributeNum SQLColAttributeStr + SQLColumnPrivileges SQLColumns SQLConnect + SQLDataSources SQLDescribeCol SQLDescribeParam + SQLDisconnect SQLDriverConnect SQLDrivers SQLEndTran + SQLError SQLExecDirect SQLExecute SQLFetch + SQLFetchScroll SQLForeignKeys SQLFreeConnect SQLFreeEnv + SQLFreeHandle SQLFreeStmt SQLGetConnectAttrNum + SQLGetConnectAttrStr SQLGetCursorName SQLGetDataNum + SQLGetDataStr SQLGetDescFieldNum SQLGetDescFieldStr + SQLGetDescRec SQLGetDiagFieldNum SQLGetDiagFieldStr + SQLGetDiagRec SQLGetEnvAttrNum SQLGetEnvAttrStr + SQLGetFunctions SQLGetInfoNum SQLGetInfoStr + SQLGetStmtAttrNum SQLGetStmtAttrStr SQLGetTypeInfo + SQLMoreResults SQLNativeSql SQLNumParams + SQLNumResultCols SQLNumResultRowsIfKnown + SQLNumRowsFetched SQLParamData SQLPrepare + SQLPrimaryKeys SQLProcedureColumns SQLProcedures + SQLPutData SQLReinitialize SQLRowCount + SQLSetConnectAttrNum SQLSetConnectAttrStr + SQLSetCursorName SQLSetDescFieldNum SQLSetDescFieldStr + SQLSetDescRec SQLSetEnvAttrNum SQLSetEnvAttrStr + SQLSetPos SQLSetStmtAttrNum SQLSetStmtAttrStr + SQLSpecialColumns SQLStatistics SQLTablePrivileges + SQLTables SQLTextWaveTo2DBinaryWave + SQLTextWaveToBinaryWaves SQLUpdateBoundValues + SQLXOPCheckState SVAR_Exists ScreenResolution Secs2Date + Secs2Time SelectNumber SelectString + SetEnvironmentVariable SortList SpecialCharacterInfo + SpecialCharacterList SpecialDirPath SphericalBessJ + SphericalBessJD SphericalBessY SphericalBessYD + SphericalHarmonics StartMSTimer StatsBetaCDF + StatsBetaPDF StatsBinomialCDF StatsBinomialPDF + StatsCMSSDCDF StatsCauchyCDF StatsCauchyPDF StatsChiCDF + StatsChiPDF StatsCorrelation StatsDExpCDF StatsDExpPDF + StatsEValueCDF StatsEValuePDF StatsErlangCDF + StatsErlangPDF StatsErrorPDF StatsExpCDF StatsExpPDF + StatsFCDF StatsFPDF StatsFriedmanCDF StatsGEVCDF + StatsGEVPDF StatsGammaCDF StatsGammaPDF + StatsGeometricCDF StatsGeometricPDF StatsHyperGCDF + StatsHyperGPDF StatsInvBetaCDF StatsInvBinomialCDF + StatsInvCMSSDCDF StatsInvCauchyCDF StatsInvChiCDF + StatsInvDExpCDF StatsInvEValueCDF StatsInvExpCDF + StatsInvFCDF StatsInvFriedmanCDF StatsInvGammaCDF + StatsInvGeometricCDF StatsInvKuiperCDF + StatsInvLogNormalCDF StatsInvLogisticCDF + StatsInvMaxwellCDF StatsInvMooreCDF + StatsInvNBinomialCDF StatsInvNCChiCDF StatsInvNCFCDF + StatsInvNormalCDF StatsInvParetoCDF StatsInvPoissonCDF + StatsInvPowerCDF StatsInvQCDF StatsInvQpCDF + StatsInvRayleighCDF StatsInvRectangularCDF + StatsInvSpearmanCDF StatsInvStudentCDF + StatsInvTopDownCDF StatsInvTriangularCDF + StatsInvUsquaredCDF StatsInvVonMisesCDF + StatsInvWeibullCDF StatsKuiperCDF StatsLogNormalCDF + StatsLogNormalPDF StatsLogisticCDF StatsLogisticPDF + StatsMaxwellCDF StatsMaxwellPDF StatsMedian + StatsMooreCDF StatsNBinomialCDF StatsNBinomialPDF + StatsNCChiCDF StatsNCChiPDF StatsNCFCDF StatsNCFPDF + StatsNCTCDF StatsNCTPDF StatsNormalCDF StatsNormalPDF + StatsParetoCDF StatsParetoPDF StatsPermute + StatsPoissonCDF StatsPoissonPDF StatsPowerCDF + StatsPowerNoise StatsPowerPDF StatsQCDF StatsQpCDF + StatsRayleighCDF StatsRayleighPDF StatsRectangularCDF + StatsRectangularPDF StatsRunsCDF StatsSpearmanRhoCDF + StatsStudentCDF StatsStudentPDF StatsTopDownCDF + StatsTriangularCDF StatsTriangularPDF StatsTrimmedMean + StatsUSquaredCDF StatsVonMisesCDF StatsVonMisesNoise + StatsVonMisesPDF StatsWaldCDF StatsWaldPDF + StatsWeibullCDF StatsWeibullPDF StopMSTimer + StrVarOrDefault StringByKey StringFromList StringList + StudentA StudentT TDMAddChannel TDMAddGroup + TDMAppendDataValues TDMAppendDataValuesTime + TDMChannelPropertyExists TDMCloseChannel TDMCloseFile + TDMCloseGroup TDMCreateChannelProperty TDMCreateFile + TDMCreateFileProperty TDMCreateGroupProperty + TDMFilePropertyExists TDMGetChannelPropertyNames + TDMGetChannelPropertyNum TDMGetChannelPropertyStr + TDMGetChannelPropertyTime TDMGetChannelPropertyType + TDMGetChannelStringPropertyLen TDMGetChannels + TDMGetDataType TDMGetDataValues TDMGetDataValuesTime + TDMGetFilePropertyNames TDMGetFilePropertyNum + TDMGetFilePropertyStr TDMGetFilePropertyTime + TDMGetFilePropertyType TDMGetFileStringPropertyLen + TDMGetGroupPropertyNames TDMGetGroupPropertyNum + TDMGetGroupPropertyStr TDMGetGroupPropertyTime + TDMGetGroupPropertyType TDMGetGroupStringPropertyLen + TDMGetGroups TDMGetLibraryErrorDescription + TDMGetNumChannelProperties TDMGetNumChannels + TDMGetNumDataValues TDMGetNumFileProperties + TDMGetNumGroupProperties TDMGetNumGroups + TDMGroupPropertyExists TDMOpenFile TDMOpenFileEx + TDMRemoveChannel TDMRemoveGroup TDMReplaceDataValues + TDMReplaceDataValuesTime TDMSaveFile + TDMSetChannelPropertyNum TDMSetChannelPropertyStr + TDMSetChannelPropertyTime TDMSetDataValues + TDMSetDataValuesTime TDMSetFilePropertyNum + TDMSetFilePropertyStr TDMSetFilePropertyTime + TDMSetGroupPropertyNum TDMSetGroupPropertyStr + TDMSetGroupPropertyTime TableInfo TagVal TagWaveRef + TextEncodingCode TextEncodingName TextFile + ThreadGroupCreate ThreadGroupGetDF ThreadGroupGetDFR + ThreadGroupRelease ThreadGroupWait ThreadProcessorCount + ThreadReturnValue TraceFromPixel TraceInfo + TraceNameList TraceNameToWaveRef TrimString URLDecode + URLEncode UnPadString UniqueName + UnsetEnvironmentVariable UpperStr VariableList Variance + VoigtFunc VoigtPeak WaveCRC WaveDims WaveExists + WaveHash WaveInfo WaveList WaveMax WaveMin WaveName + WaveRefIndexed WaveRefIndexedDFR WaveRefWaveToList + WaveRefsEqual WaveTextEncoding WaveType WaveUnits + WhichListItem WinList WinName WinRecreation WinType + XWaveName XWaveRefFromTrace ZernikeR abs acos acosh + alog area areaXY asin asinh atan atan2 atanh beta betai + binomial binomialNoise binomialln cabs ceil cequal + char2num chebyshev chebyshevU cmplx cmpstr conj cos + cosIntegral cosh cot coth cpowi csc csch date date2secs + datetime defined deltax digamma dilogarithm ei enoise + equalWaves erf erfc erfcw exists exp expInt + expIntegralE1 expNoise fDAQmx_AI_GetReader + fDAQmx_AO_UpdateOutputs fDAQmx_CTR_Finished + fDAQmx_CTR_IsFinished fDAQmx_CTR_IsPulseFinished + fDAQmx_CTR_ReadCounter fDAQmx_CTR_ReadWithOptions + fDAQmx_CTR_SetPulseFrequency fDAQmx_CTR_Start + fDAQmx_ConnectTerminals fDAQmx_DIO_Finished + fDAQmx_DIO_PortWidth fDAQmx_DIO_Read fDAQmx_DIO_Write + fDAQmx_DeviceNames fDAQmx_DisconnectTerminals + fDAQmx_ErrorString fDAQmx_ExternalCalDate + fDAQmx_NumAnalogInputs fDAQmx_NumAnalogOutputs + fDAQmx_NumCounters fDAQmx_NumDIOPorts fDAQmx_ReadChan + fDAQmx_ReadNamedChan fDAQmx_ResetDevice + fDAQmx_ScanGetAvailable fDAQmx_ScanGetNextIndex + fDAQmx_ScanStart fDAQmx_ScanStop fDAQmx_ScanWait + fDAQmx_ScanWaitWithTimeout fDAQmx_SelfCalDate + fDAQmx_SelfCalibration fDAQmx_WF_IsFinished + fDAQmx_WF_WaitUntilFinished fDAQmx_WaveformStart + fDAQmx_WaveformStop fDAQmx_WriteChan factorial fakedata + faverage faverageXY floor gamma gammaEuler gammaInc + gammaNoise gammln gammp gammq gcd gnoise hcsr hermite + hermiteGauss imag interp inverseERF inverseERFC leftx + limit ln log logNormalNoise lorentzianNoise magsqr max + mean median min mod norm note num2char num2istr num2str + numpnts numtype p2rect pcsr pnt2x poissonNoise poly + poly2D qcsr r2polar real rightx round sawtooth + scaleToIndex sec sech sign sin sinIntegral sinc sinh + sqrt str2num stringCRC stringmatch strlen strsearch sum + tan tango_close_device tango_command_inout + tango_compute_image_proj tango_get_dev_attr_list + tango_get_dev_black_box tango_get_dev_cmd_list + tango_get_dev_status tango_get_dev_timeout + tango_get_error_stack tango_open_device + tango_ping_device tango_read_attribute + tango_read_attributes tango_reload_dev_interface + tango_resume_attr_monitor tango_set_attr_monitor_period + tango_set_dev_timeout tango_start_attr_monitor + tango_stop_attr_monitor tango_suspend_attr_monitor + tango_write_attribute tango_write_attributes tanh ticks + time trunc vcsr viAssertIntrSignal viAssertTrigger + viAssertUtilSignal viClear viClose viDisableEvent + viDiscardEvents viEnableEvent viFindNext viFindRsrc + viGetAttribute viGetAttributeString viGpibCommand + viGpibControlATN viGpibControlREN viGpibPassControl + viGpibSendIFC viIn16 viIn32 viIn8 viLock viMapAddress + viMapTrigger viMemAlloc viMemFree viMoveIn16 viMoveIn32 + viMoveIn8 viMoveOut16 viMoveOut32 viMoveOut8 viOpen + viOpenDefaultRM viOut16 viOut32 viOut8 viPeek16 + viPeek32 viPeek8 viPoke16 viPoke32 viPoke8 viRead + viReadSTB viSetAttribute viSetAttributeString + viStatusDesc viTerminate viUnlock viUnmapAddress + viUnmapTrigger viUsbControlIn viUsbControlOut + viVxiCommandQuery viWaitOnEvent viWrite wnoise x2pnt + xcsr zcsr zeromq_client_connect zeromq_client_connect + zeromq_client_recv zeromq_client_recv + zeromq_client_send zeromq_client_send + zeromq_handler_start zeromq_handler_start + zeromq_handler_stop zeromq_handler_stop + zeromq_server_bind zeromq_server_bind + zeromq_server_recv zeromq_server_recv + zeromq_server_send zeromq_server_send zeromq_set + zeromq_set zeromq_stop zeromq_stop + zeromq_test_callfunction zeromq_test_callfunction + zeromq_test_serializeWave zeromq_test_serializeWave + zeta + ) + end + + def self.igorOperation + @igorOperation ||= Set.new %w( + APMath Abort AddFIFOData AddFIFOVectData AddMovieAudio + AddMovieFrame AddWavesToBoxPlot AddWavesToViolinPlot + AdoptFiles Append AppendBoxPlot AppendImage + AppendLayoutObject AppendMatrixContour AppendText + AppendToGizmo AppendToGraph AppendToLayout + AppendToTable AppendViolinPlot AppendXYZContour + AutoPositionWindow AxonTelegraphFindServers + BackgroundInfo Beep BoundingBall BoxSmooth BrowseURL + BuildMenu Button CWT Chart CheckBox CheckDisplayed + ChooseColor Close CloseHelp CloseMovie CloseProc + ColorScale ColorTab2Wave Concatenate ControlBar + ControlInfo ControlUpdate + ConvertGlobalStringTextEncoding ConvexHull Convolve + CopyDimLabels CopyFile CopyFolder CopyScales Correlate + CreateAliasShortcut CreateBrowser Cross CtrlBackground + CtrlFIFO CtrlNamedBackground Cursor CurveFit + CustomControl DAQmx_AI_SetupReader DAQmx_AO_SetOutputs + DAQmx_CTR_CountEdges DAQmx_CTR_OutputPulse + DAQmx_CTR_Period DAQmx_CTR_PulseWidth DAQmx_DIO_Config + DAQmx_DIO_WriteNewData DAQmx_Scan DAQmx_WaveformGen + DPSS DSPDetrend DSPPeriodogram DWT Debugger + DebuggerOptions DefaultFont DefaultGuiControls + DefaultGuiFont DefaultTextEncoding DefineGuide + DelayUpdate DeleteAnnotations DeleteFile DeleteFolder + DeletePoints Differentiate Display DisplayHelpTopic + DisplayProcedure DoAlert DoIgorMenu DoUpdate DoWindow + DoXOPIdle DrawAction DrawArc DrawBezier DrawLine + DrawOval DrawPICT DrawPoly DrawRRect DrawRect DrawText + DrawUserShape Duplicate DuplicateDataFolder EdgeStats + Edit ErrorBars EstimatePeakSizes Execute + ExecuteScriptText ExperimentInfo ExperimentModified + ExportGizmo Extract FBinRead FBinWrite FFT FGetPos + FIFO2Wave FIFOStatus FMaxFlat FPClustering FReadLine + FSetPos FStatus FTPCreateDirectory FTPDelete + FTPDownload FTPUpload FastGaussTransform FastOp + FilterFIR FilterIIR FindAPeak FindContour + FindDuplicates FindLevel FindLevels FindPeak + FindPointsInPoly FindRoots FindSequence FindValue + FuncFit FuncFitMD GBLoadWave GISCreateVectorLayer + GISGetRasterInfo GISGetRegisteredFileInfo + GISGetVectorLayerInfo GISLoadRasterData + GISLoadVectorData GISRasterizeVectorData + GISRegisterFile GISTransformCoords GISUnRegisterFile + GISWriteFieldData GISWriteGeometryData GISWriteRaster + GPIB2 GPIBRead2 GPIBReadBinary2 GPIBReadBinaryWave2 + GPIBReadWave2 GPIBWrite2 GPIBWriteBinary2 + GPIBWriteBinaryWave2 GPIBWriteWave2 GetAxis GetCamera + GetFileFolderInfo GetGizmo GetLastUserMenuInfo + GetMarquee GetMouse GetSelection GetWindow GraphNormal + GraphWaveDraw GraphWaveEdit Grep GroupBox + HDF5CloseFile HDF5CloseGroup HDF5ConvertColors + HDF5CreateFile HDF5CreateGroup HDF5CreateLink HDF5Dump + HDF5DumpErrors HDF5DumpState HDF5FlushFile + HDF5ListAttributes HDF5ListGroup HDF5LoadData + HDF5LoadGroup HDF5LoadImage HDF5OpenFile HDF5OpenGroup + HDF5SaveData HDF5SaveGroup HDF5SaveImage + HDF5TestOperation HDF5UnlinkObject HDFInfo + HDFReadImage HDFReadSDS HDFReadVset Hanning + HideIgorMenus HideInfo HideProcedures HideTools + HilbertTransform Histogram ICA IFFT ITCCloseAll2 + ITCCloseDevice2 ITCConfigAllChannels2 + ITCConfigChannel2 ITCConfigChannelReset2 + ITCConfigChannelUpload2 ITCFIFOAvailable2 + ITCFIFOAvailableAll2 ITCGetAllChannelsConfig2 + ITCGetChannelConfig2 ITCGetCurrentDevice2 + ITCGetDeviceInfo2 ITCGetDevices2 ITCGetErrorString2 + ITCGetSerialNumber2 ITCGetState2 ITCGetVersions2 + ITCInitialize2 ITCOpenDevice2 ITCReadADC2 + ITCReadDigital2 ITCReadTimer2 ITCSelectDevice2 + ITCSetDAC2 ITCSetGlobals2 ITCSetModes2 ITCSetState2 + ITCStartAcq2 ITCStopAcq2 ITCUpdateFIFOPosition2 + ITCUpdateFIFOPositionAll2 ITCWriteDigital2 + ImageAnalyzeParticles ImageBlend ImageBoundaryToMask + ImageComposite ImageEdgeDetection ImageFileInfo + ImageFilter ImageFocus ImageFromXYZ ImageGLCM + ImageGenerateROIMask ImageHistModification + ImageHistogram ImageInterpolate ImageLineProfile + ImageLoad ImageMorphology ImageRegistration + ImageRemoveBackground ImageRestore ImageRotate + ImageSave ImageSeedFill ImageSkeleton3d ImageSnake + ImageStats ImageThreshold ImageTransform + ImageUnwrapPhase ImageWindow IndexSort InsertPoints + Integrate Integrate2D IntegrateODE Interp3DPath + Interpolate2 Interpolate3D JCAMPLoadWave + JointHistogram KMeans KillBackground KillControl + KillDataFolder KillFIFO KillFreeAxis KillPICTs + KillPath KillStrings KillVariables KillWaves + KillWindow Label Layout LayoutPageAction + LayoutSlideShow Legend LinearFeedbackShiftRegister + ListBox LoadData LoadPICT LoadPackagePreferences + LoadWave Loess LombPeriodogram MCC_FindServers + MFR_CheckForNewBricklets MFR_CloseResultFile + MFR_CreateOverviewTable MFR_GetBrickletCount + MFR_GetBrickletData MFR_GetBrickletDeployData + MFR_GetBrickletMetaData MFR_GetBrickletRawData + MFR_GetReportTemplate MFR_GetResultFileMetaData + MFR_GetResultFileName MFR_GetVernissageVersion + MFR_GetVersion MFR_GetXOPErrorMessage + MFR_OpenResultFile + MLLoadWave Make MakeIndex MarkPerfTestTime + MatrixConvolve MatrixCorr MatrixEigenV MatrixFilter + MatrixGLM MatrixGaussJ MatrixInverse MatrixLLS + MatrixLUBkSub MatrixLUD MatrixLUDTD MatrixLinearSolve + MatrixLinearSolveTD MatrixMultiply MatrixOP + MatrixSVBkSub MatrixSVD MatrixSchur MatrixSolve + MatrixTranspose MeasureStyledText Modify ModifyBoxPlot + ModifyBrowser ModifyCamera ModifyContour ModifyControl + ModifyControlList ModifyFreeAxis ModifyGizmo + ModifyGraph ModifyImage ModifyLayout ModifyPanel + ModifyTable ModifyViolinPlot ModifyWaterfall + MoveDataFolder MoveFile MoveFolder MoveString + MoveSubwindow MoveVariable MoveWave MoveWindow + MultiTaperPSD MultiThreadingControl NC_CloseFile + NC_DumpErrors NC_Inquire NC_ListAttributes + NC_ListObjects NC_LoadData NC_OpenFile NI4882 + NILoadWave NeuralNetworkRun NeuralNetworkTrain + NewCamera NewDataFolder NewFIFO NewFIFOChan + NewFreeAxis NewGizmo NewImage NewLayout NewMovie + NewNotebook NewPanel NewPath NewWaterfall Note + Notebook NotebookAction Open OpenHelp OpenNotebook + Optimize PCA ParseOperationTemplate PathInfo + PauseForUser PauseUpdate PlayMovie PlayMovieAction + PlaySound PopupContextualMenu PopupMenu Preferences + PrimeFactors Print PrintGraphs PrintLayout + PrintNotebook PrintSettings PrintTable Project + PulseStats PutScrapText Quit RatioFromNumber + Redimension Remez Remove RemoveContour RemoveFromGizmo + RemoveFromGraph RemoveFromLayout RemoveFromTable + RemoveImage RemoveLayoutObjects RemovePath Rename + RenameDataFolder RenamePICT RenamePath RenameWindow + ReorderImages ReorderTraces ReplaceText ReplaceWave + Resample ResumeUpdate Reverse Rotate SQLHighLevelOp + STFT Save SaveData SaveExperiment SaveGizmoCopy + SaveGraphCopy SaveNotebook SavePICT + SavePackagePreferences SaveTableCopy + SetActiveSubwindow SetAxis SetBackground + SetDashPattern SetDataFolder SetDimLabel SetDrawEnv + SetDrawLayer SetFileFolderInfo SetFormula + SetIdlePeriod SetIgorHook SetIgorMenuMode + SetIgorOption SetMarquee SetProcessSleep SetRandomSeed + SetScale SetVariable SetWaveLock SetWaveTextEncoding + SetWindow ShowIgorMenus ShowInfo ShowTools Silent + Sleep Slider Smooth SmoothCustom Sort SortColumns + SoundInRecord SoundInSet SoundInStartChart + SoundInStatus SoundInStopChart SoundLoadWave + SoundSaveWave SphericalInterpolate + SphericalTriangulate SplitString SplitWave Stack + StackWindows StatsANOVA1Test StatsANOVA2NRTest + StatsANOVA2RMTest StatsANOVA2Test + StatsAngularDistanceTest StatsChiTest + StatsCircularCorrelationTest StatsCircularMeans + StatsCircularMoments StatsCircularTwoSampleTest + StatsCochranTest StatsContingencyTable StatsDIPTest + StatsDunnettTest StatsFTest StatsFriedmanTest + StatsHodgesAjneTest StatsJBTest StatsKDE StatsKSTest + StatsKWTest StatsKendallTauTest + StatsLinearCorrelationTest StatsLinearRegression + StatsMultiCorrelationTest StatsNPMCTest + StatsNPNominalSRTest StatsQuantiles + StatsRankCorrelationTest StatsResample StatsSRTest + StatsSample StatsScheffeTest StatsShapiroWilkTest + StatsSignTest StatsTTest StatsTukeyTest + StatsVariancesTest StatsWRCorrelationTest + StatsWatsonUSquaredTest StatsWatsonWilliamsTest + StatsWheelerWatsonTest StatsWilcoxonRankTest String + StructFill StructGet StructPut SumDimension SumSeries + TDMLoadData TDMSaveData TabControl Tag TextBox + ThreadGroupPutDF ThreadStart TickWavesFromAxis Tile + TileWindows TitleBox ToCommandLine ToolsGrid + Triangulate3d URLRequest Unwrap VDT2 VDTClosePort2 + VDTGetPortList2 VDTGetStatus2 VDTOpenPort2 + VDTOperationsPort2 VDTRead2 VDTReadBinary2 + VDTReadBinaryWave2 VDTReadHex2 VDTReadHexWave2 + VDTReadWave2 VDTTerminalPort2 VDTWrite2 + VDTWriteBinary2 VDTWriteBinaryWave2 VDTWriteHex2 + VDTWriteHexWave2 VDTWriteWave2 VISAControl VISARead + VISAReadBinary VISAReadBinaryWave VISAReadWave + VISAWrite VISAWriteBinary VISAWriteBinaryWave + VISAWriteWave ValDisplay Variable WaveMeanStdv + WaveStats WaveTransform WignerTransform WindowFunction + XLLoadWave cd dir fprintf printf pwd sprintf sscanf + wfprintf + ) + end + + def self.object_name + /\b[a-z][a-z0-9_\.]*?\b/i + end + + object = self.object_name + noLineBreak = /(?:[ \t]|(?:\\\s*[\r\n]))+/ + operator = %r([\#$~!%^&*+=\|?:<>/-]) + punctuation = /[{}()\[\],.;]/ + number_float= /0x[a-f0-9]+/i + number_hex = /\d+\.\d+(e[\+\-]?\d+)?/ + number_int = /[\d]+(?:_\d+)*/ + + state :root do + rule %r(//), Comment, :comments + + rule %r/#{object}/ do |m| + if m[0].downcase =~ /function/ + token Keyword::Declaration + push :parse_function + elsif self.class.igorDeclarations.include? m[0].downcase + token Keyword::Declaration + push :parse_variables + elsif self.class.keywords.include? m[0].downcase + token Keyword + elsif self.class.igorConstants.include? m[0].downcase + token Keyword::Constant + elsif self.class.igorFunction.include? m[0].downcase + token Name::Builtin + elsif self.class.igorOperation.include? m[0].downcase + token Keyword::Reserved + push :operationFlags + elsif m[0].downcase =~ /\b(v|s|w)_[a-z]+[a-z0-9]*/ + token Name::Constant + else + token Name + end + end + + mixin :preprocessor + mixin :waveFlag + + mixin :characters + mixin :numbers + mixin :whitespace + end + + state :preprocessor do + rule %r((\#)(#{object})) do |m| + if self.class.preprocessor.include? m[2].downcase + token Comment::Preproc + else + token Punctuation, m[1] #i.e. ModuleFunctions + token Name, m[2] + end + + + end + end + + state :assignment do + mixin :whitespace + rule %r/\"/, Literal::String::Double, :string1 #punctuation for string + mixin :string2 + rule %r/#{number_float}/, Literal::Number::Float, :pop! + rule %r/#{number_int}/, Literal::Number::Integer, :pop! + rule %r/[\(\[\{][^\)\]\}]+[\)\]\}]/, Generic, :pop! + rule %r/[^\s\/\(]+/, Generic, :pop! + rule(//) { pop! } + end + + state :parse_variables do + mixin :whitespace + rule %r/[=]/, Punctuation, :assignment + rule object, Name::Variable + rule %r/[\[\]]/, Punctuation # optional variables in functions + rule %r/[,]/, Punctuation, :parse_variables + rule %r/\)/, Punctuation, :pop! # end of function + rule %r([/][a-z]+)i, Keyword::Pseudo, :parse_variables + rule(//) { pop! } + end + + state :parse_function do + rule %r([/][a-z]+)i, Keyword::Pseudo # only one flag + mixin :whitespace + rule object, Name::Function + rule %r/[\(]/, Punctuation, :parse_variables + rule(//) { pop! } + end + + state :operationFlags do + rule %r/#{noLineBreak}/, Text + rule %r/[=]/, Punctuation, :assignment + rule %r([/][a-z]+)i, Keyword::Pseudo, :operationFlags + rule %r/(as)(\s*)(#{object})/i do + groups Keyword::Type, Text, Name::Label + end + rule(//) { pop! } + end + + # inline variable assignments (i.e. for Make) with strict syntax + state :waveFlag do + rule %r( + (/(?:wave|X|Y)) + (\s*)(=)(\s*) + (#{object}) + )ix do |m| + token Keyword::Pseudo, m[1] + token Text, m[2] + token Punctuation, m[3] + token Text, m[4] + token Name::Variable, m[5] + end + end + + state :characters do + rule %r/\s/, Text + rule %r/#{operator}/, Operator + rule %r/#{punctuation}/, Punctuation + rule %r/\"/, Literal::String::Double, :string1 #punctuation for string + mixin :string2 + end + + state :numbers do + rule %r/#{number_float}/, Literal::Number::Float + rule %r/#{number_hex}/, Literal::Number::Hex + rule %r/#{number_int}/, Literal::Number::Integer + end + + state :whitespace do + rule %r/#{noLineBreak}/, Text + end + + state :string1 do + rule %r/%\w\b/, Literal::String::Other + rule %r/\\\\/, Literal::String::Escape + rule %r/\\\"/, Literal::String::Escape + rule %r/\\/, Literal::String::Escape + rule %r/[^"]/, Literal::String + rule %r/\"/, Literal::String::Double, :pop! #punctuation for string + end + + state :string2 do + rule %r/\'[^']*\'/, Literal::String::Single + end + + state :comments do + rule %r{([/]\s*)([@]\w+\b)}i do + # doxygen comments + groups Comment, Comment::Special + end + rule %r/[^\r\n]/, Comment + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ini.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ini.rb new file mode 100644 index 0000000..b44014e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ini.rb @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class INI < RegexLexer + title "INI" + desc 'the INI configuration format' + tag 'ini' + + # TODO add more here + filenames '*.ini', '*.INI', '*.gitconfig' + mimetypes 'text/x-ini' + + identifier = /[\w\-.]+/ + + state :basic do + rule %r/[;#].*?\n/, Comment + rule %r/\s+/, Text + rule %r/\\\n/, Str::Escape + end + + state :root do + mixin :basic + + rule %r/(#{identifier})(\s*)(=)/ do + groups Name::Property, Text, Punctuation + push :value + end + + rule %r/\[.*?\]/, Name::Namespace + end + + state :value do + rule %r/\n/, Text, :pop! + mixin :basic + rule %r/"/, Str, :dq + rule %r/'.*?'/, Str + mixin :esc_str + rule %r/[^\\\n]+/, Str + end + + state :dq do + rule %r/"/, Str, :pop! + mixin :esc_str + rule %r/[^\\"]+/m, Str + end + + state :esc_str do + rule %r/\\./m, Str::Escape + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/io.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/io.rb new file mode 100644 index 0000000..9e049a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/io.rb @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class IO < RegexLexer + tag 'io' + title "Io" + desc 'The IO programming language (http://iolanguage.com)' + mimetypes 'text/x-iosrc' + filenames '*.io' + + def self.detect?(text) + return true if text.shebang? 'io' + end + + def self.constants + @constants ||= Set.new %w(nil false true) + end + + def self.builtins + @builtins ||= Set.new %w( + args call clone do doFile doString else elseif for if list + method return super then + ) + end + + state :root do + rule %r/\s+/m, Text + rule %r(//.*), Comment::Single + rule %r(#.*), Comment::Single + rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline + rule %r(/[+]), Comment::Multiline, :nested_comment + + rule %r/"(\\\\|\\"|[^"])*"/, Str + + rule %r(:?:=), Keyword + rule %r/[()]/, Punctuation + + rule %r([-=;,*+>"*] | + [>"*]> + ) + )x + end + + def allow_comments? + true + end + end + + load_lexer 'ruby.rb' + class IRBOutputLexer < Ruby + tag 'irb_output' + + start do + push :stdout + end + + state :has_irb_output do + rule %r(=>), Punctuation, :pop! + rule %r/.+?(\n|$)/, Generic::Output + end + + state :irb_error do + rule %r/.+?(\n|$)/, Generic::Error + mixin :has_irb_output + end + + state :stdout do + rule %r/\w+?(Error|Exception):.+?(\n|$)/, Generic::Error, :irb_error + mixin :has_irb_output + end + + prepend :root do + rule %r/#/, Keyword::Type, :pop! + mixin :root + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isabelle.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isabelle.rb new file mode 100644 index 0000000..6b97b22 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isabelle.rb @@ -0,0 +1,251 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true +# Lexer adapted from https://github.com/pygments/pygments/blob/ad55974ce83b85dbb333ab57764415ab84169461/pygments/lexers/theorem.py + +module Rouge + module Lexers + class Isabelle < RegexLexer + title "Isabelle" + desc 'Isabelle theories (isabelle.in.tum.de)' + tag 'isabelle' + aliases 'isa', 'Isabelle' + filenames '*.thy' + mimetypes 'text/x-isabelle' + + def self.keyword_minor + @keyword_minor ||= Set.new %w( + and assumes attach avoids binder checking + class_instance class_relation code_module congs + constant constrains datatypes defines file fixes + for functions hints identifier if imports in + includes infix infixl infixr is keywords lazy + module_name monos morphisms no_discs_sels notes + obtains open output overloaded parametric permissive + pervasive rep_compat shows structure type_class + type_constructor unchecked unsafe where + ) + end + + def self.keyword_diag + @keyword_diag ||= Set.new %w( + ML_command ML_val class_deps code_deps code_thms + display_drafts find_consts find_theorems find_unused_assms + full_prf help locale_deps nitpick pr prf + print_abbrevs print_antiquotations print_attributes + print_binds print_bnfs print_bundles + print_case_translations print_cases print_claset + print_classes print_codeproc print_codesetup + print_coercions print_commands print_context + print_defn_rules print_dependencies print_facts + print_induct_rules print_inductives print_interps + print_locale print_locales print_methods print_options + print_orders print_quot_maps print_quotconsts + print_quotients print_quotientsQ3 print_quotmapsQ3 + print_rules print_simpset print_state print_statement + print_syntax print_theorems print_theory print_trans_rules + prop pwd quickcheck refute sledgehammer smt_status + solve_direct spark_status term thm thm_deps thy_deps + try try0 typ unused_thms value values welcome + print_ML_antiquotations print_term_bindings values_prolog + ) + end + + def self.keyword_thy + @keyword_thy ||= Set.new %w(theory begin end) + end + + def self.keyword_section + @keyword_section ||= Set.new %w(header chapter) + end + + def self.keyword_subsection + @keyword_subsection ||= Set.new %w(section subsection subsubsection sect subsect subsubsect) + end + + def self.keyword_theory_decl + @keyword_theory_decl ||= Set.new %w( + ML ML_file abbreviation adhoc_overloading arities + atom_decl attribute_setup axiomatization bundle + case_of_simps class classes classrel codatatype + code_abort code_class code_const code_datatype + code_identifier code_include code_instance code_modulename + code_monad code_printing code_reflect code_reserved + code_type coinductive coinductive_set consts context + datatype datatype_new datatype_new_compat declaration + declare default_sort defer_recdef definition defs + domain domain_isomorphism domaindef equivariance + export_code extract extract_type fixrec fun + fun_cases hide_class hide_const hide_fact hide_type + import_const_map import_file import_tptp import_type_map + inductive inductive_set instantiation judgment lemmas + lifting_forget lifting_update local_setup locale + method_setup nitpick_params no_adhoc_overloading + no_notation no_syntax no_translations no_type_notation + nominal_datatype nonterminal notation notepad oracle + overloading parse_ast_translation parse_translation + partial_function primcorec primrec primrec_new + print_ast_translation print_translation quickcheck_generator + quickcheck_params realizability realizers recdef record + refute_params setup setup_lifting simproc_setup + simps_of_case sledgehammer_params spark_end spark_open + spark_open_siv spark_open_vcg spark_proof_functions + spark_types statespace syntax syntax_declaration text + text_raw theorems translations type_notation + type_synonym typed_print_translation typedecl hoarestate + install_C_file install_C_types wpc_setup c_defs c_types + memsafe SML_export SML_file SML_import approximate + bnf_axiomatization cartouche datatype_compat + free_constructors functor nominal_function + nominal_termination permanent_interpretation + binds defining smt2_status term_cartouche + boogie_file text_cartouche + ) + end + + def self.keyword_theory_script + @keyword_theory_script ||= Set.new %w(inductive_cases inductive_simps) + end + + def self.keyword_theory_goal + @keyword_theory_goal ||= Set.new %w( + ax_specification bnf code_pred corollary cpodef + crunch crunch_ignore + enriched_type function instance interpretation lemma + lift_definition nominal_inductive nominal_inductive2 + nominal_primrec pcpodef primcorecursive + quotient_definition quotient_type recdef_tc rep_datatype + schematic_corollary schematic_lemma schematic_theorem + spark_vc specification subclass sublocale termination + theorem typedef wrap_free_constructors + ) + end + + def self.keyword_qed + @keyword_qed ||= Set.new %w(by done qed) + end + + def self.keyword_abandon_proof + @keyword_abandon_proof ||= Set.new %w(sorry oops) + end + + def self.keyword_proof_goal + @keyword_proof_goal ||= Set.new %w(have hence interpret) + end + + def self.keyword_proof_block + @keyword_proof_block ||= Set.new %w(next proof) + end + + def self.keyword_proof_chain + @keyword_proof_chain ||= Set.new %w(finally from then ultimately with) + end + + def self.keyword_proof_decl + @keyword_proof_decl ||= Set.new %w( + ML_prf also include including let moreover note + txt txt_raw unfolding using write + ) + end + + def self.keyword_proof_asm + @keyword_proof_asm ||= Set.new %w(assume case def fix presume) + end + + def self.keyword_proof_asm_goal + @keyword_proof_asm_goal ||= Set.new %w(guess obtain show thus) + end + + def self.keyword_proof_script + @keyword_proof_script ||= Set.new %w(apply apply_end apply_trace back defer prefer) + end + + state :root do + rule %r/\s+/, Text::Whitespace + rule %r/\(\*/, Comment, :comment + rule %r/\{\*|‹/, Text, :text + + rule %r/::|\[|\]|-|[:()_=,|+!?]/, Operator + rule %r/[{}.]|\.\./, Operator::Word + + def word(keywords) + return %r/\b(#{keywords.join('|')})\b/ + end + + rule %r/[a-zA-Z]\w*/ do |m| + sym = m[0] + + if self.class.keyword_minor.include?(sym) || + self.class.keyword_proof_script.include?(sym) + token Keyword::Pseudo + elsif self.class.keyword_diag.include?(sym) + token Keyword::Type + elsif self.class.keyword_thy.include?(sym) || + self.class.keyword_theory_decl.include?(sym) || + self.class.keyword_qed.include?(sym) || + self.class.keyword_proof_goal.include?(sym) || + self.class.keyword_proof_block.include?(sym) || + self.class.keyword_proof_decl.include?(sym) || + self.class.keyword_proof_chain.include?(sym) || + self.class.keyword_proof_asm.include?(sym) || + self.class.keyword_proof_asm_goal.include?(sym) + token Keyword + elsif self.class.keyword_section.include?(sym) + token Generic::Heading + elsif self.class.keyword_subsection.include?(sym) + token Generic::Subheading + elsif self.class.keyword_theory_goal.include?(sym) || + self.class.keyword_theory_script.include?(sym) + token Keyword::Namespace + elsif self.class.keyword_abandon_proof.include?(sym) + token Generic::Error + else + token Name + end + end + + rule %r/\\<\w*>/, Str::Symbol + + rule %r/'[^\W\d][.\w']*/, Name::Variable + + rule %r/0[xX][\da-fA-F][\da-fA-F_]*/, Num::Hex + rule %r/0[oO][0-7][0-7_]*/, Num::Oct + rule %r/0[bB][01][01_]*/, Num::Bin + + rule %r/"/, Str, :string + rule %r/`/, Str::Other, :fact + # Everything except for (most) operators whitespaces may be name + rule %r/[^\s:|\[\]\-()=,+!?{}._][^\s:|\[\]\-()=,+!?{}]*/, Name + end + + state :comment do + rule %r/[^(*)]+/, Comment + rule %r/\(\*/, Comment, :comment + rule %r/\*\)/, Comment, :pop! + rule %r/[(*)]/, Comment + end + + state :text do + rule %r/[^{*}‹›]+/, Text + rule %r/\{\*|‹/, Text, :text + rule %r/\*\}|›/, Text, :pop! + rule %r/[{*}]/, Text + end + + state :string do + rule %r/[^"\\]+/, Str + rule %r/\\<\w*>/, Str::Symbol + rule %r/\\"/, Str + rule %r/\\/, Str + rule %r/"/, Str, :pop! + end + + state :fact do + rule %r/[^`\\]+/, Str::Other + rule %r/\\<\w*>/, Str::Symbol + rule %r/\\`/, Str::Other + rule %r/\\/, Str::Other + rule %r/`/, Str::Other, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isbl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isbl.rb new file mode 100644 index 0000000..2e1184b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isbl.rb @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class ISBL < RegexLexer + title "ISBL" + desc "The ISBL programming language" + tag 'isbl' + filenames '*.isbl' + + def self.builtins + Kernel::load File.join(Lexers::BASE_DIR, 'isbl/builtins.rb') + self.builtins + end + + def self.constants + @constants ||= self.builtins["const"].merge(self.builtins["enum"]).collect!(&:downcase) + end + + def self.interfaces + @interfaces ||= self.builtins["interface"].collect!(&:downcase) + end + + def self.globals + @globals ||= self.builtins["global"].collect!(&:downcase) + end + + def self.keywords + @keywords = Set.new %w( + and и else иначе endexcept endfinally endforeach конецвсе endif конецесли endwhile + конецпока except exitfor finally foreach все if если in в not не or или try while пока + ) + end + + state :whitespace do + rule %r/\s+/m, Text + rule %r(//.*?$), Comment::Single + rule %r(/[*].*?[*]/)m, Comment::Multiline + end + + state :dotted do + mixin :whitespace + rule %r/[a-zа-яё_0-9]+/i do |m| + name = m[0] + if self.class.constants.include? name.downcase + token Name::Builtin + elsif in_state? :type + token Keyword::Type + else + token Name + end + pop! + end + end + + state :type do + mixin :whitespace + rule %r/[a-zа-яё_0-9]+/i do |m| + name = m[0] + if self.class.interfaces.include? name.downcase + token Keyword::Type + else + token Name + end + pop! + end + rule %r/[.]/, Punctuation, :dotted + rule(//) { pop! } + end + + state :root do + mixin :whitespace + rule %r/[:]/, Punctuation, :type + rule %r/[.]/, Punctuation, :dotted + rule %r/[\[\]();]/, Punctuation + rule %r([&*+=<>/-]), Operator + rule %r/\b[a-zа-яё_][a-zа-яё_0-9]*(?=[(])/i, Name::Function + rule %r/[a-zа-яё_!][a-zа-яё_0-9]*/i do |m| + name = m[0] + if self.class.keywords.include? name.downcase + token Keyword + elsif self.class.constants.include? name.downcase + token Name::Builtin + elsif self.class.globals.include? name.downcase + token Name::Variable::Global + else + token Name::Variable + end + end + rule %r/\b(\d+(\.\d+)?)\b/, Literal::Number + rule %r(["].*?["])m, Literal::String::Double + rule %r(['].*?['])m, Literal::String::Single + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isbl/builtins.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isbl/builtins.rb new file mode 100644 index 0000000..5e9eeeb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/isbl/builtins.rb @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class ISBL + def self.builtins + @builtins ||= {}.tap do |b| + b["const"] = Set.new %w(SYSRES_CONST_ACCES_RIGHT_TYPE_EDIT SYSRES_CONST_ACCES_RIGHT_TYPE_FULL SYSRES_CONST_ACCES_RIGHT_TYPE_VIEW SYSRES_CONST_ACCESS_MODE_REQUISITE_CODE SYSRES_CONST_ACCESS_NO_ACCESS_VIEW SYSRES_CONST_ACCESS_NO_ACCESS_VIEW_CODE SYSRES_CONST_ACCESS_RIGHTS_ADD_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_ADD_REQUISITE_YES_CODE SYSRES_CONST_ACCESS_RIGHTS_CHANGE_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_CHANGE_REQUISITE_YES_CODE SYSRES_CONST_ACCESS_RIGHTS_DELETE_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_DELETE_REQUISITE_YES_CODE SYSRES_CONST_ACCESS_RIGHTS_EXECUTE_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_EXECUTE_REQUISITE_YES_CODE SYSRES_CONST_ACCESS_RIGHTS_NO_ACCESS_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_NO_ACCESS_REQUISITE_YES_CODE SYSRES_CONST_ACCESS_RIGHTS_RATIFY_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_RATIFY_REQUISITE_YES_CODE SYSRES_CONST_ACCESS_RIGHTS_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_VIEW SYSRES_CONST_ACCESS_RIGHTS_VIEW_CODE SYSRES_CONST_ACCESS_RIGHTS_VIEW_REQUISITE_CODE SYSRES_CONST_ACCESS_RIGHTS_VIEW_REQUISITE_YES_CODE SYSRES_CONST_ACCESS_TYPE_CHANGE SYSRES_CONST_ACCESS_TYPE_CHANGE_CODE SYSRES_CONST_ACCESS_TYPE_EXISTS SYSRES_CONST_ACCESS_TYPE_EXISTS_CODE SYSRES_CONST_ACCESS_TYPE_FULL SYSRES_CONST_ACCESS_TYPE_FULL_CODE SYSRES_CONST_ACCESS_TYPE_VIEW SYSRES_CONST_ACCESS_TYPE_VIEW_CODE SYSRES_CONST_ACTION_TYPE_ABORT SYSRES_CONST_ACTION_TYPE_ACCEPT SYSRES_CONST_ACTION_TYPE_ACCESS_RIGHTS SYSRES_CONST_ACTION_TYPE_ADD_ATTACHMENT SYSRES_CONST_ACTION_TYPE_CHANGE_CARD SYSRES_CONST_ACTION_TYPE_CHANGE_KIND SYSRES_CONST_ACTION_TYPE_CHANGE_STORAGE SYSRES_CONST_ACTION_TYPE_CONTINUE SYSRES_CONST_ACTION_TYPE_COPY SYSRES_CONST_ACTION_TYPE_CREATE SYSRES_CONST_ACTION_TYPE_CREATE_VERSION SYSRES_CONST_ACTION_TYPE_DELETE SYSRES_CONST_ACTION_TYPE_DELETE_ATTACHMENT SYSRES_CONST_ACTION_TYPE_DELETE_VERSION SYSRES_CONST_ACTION_TYPE_DISABLE_DELEGATE_ACCESS_RIGHTS SYSRES_CONST_ACTION_TYPE_ENABLE_DELEGATE_ACCESS_RIGHTS SYSRES_CONST_ACTION_TYPE_ENCRYPTION_BY_CERTIFICATE SYSRES_CONST_ACTION_TYPE_ENCRYPTION_BY_CERTIFICATE_AND_PASSWORD SYSRES_CONST_ACTION_TYPE_ENCRYPTION_BY_PASSWORD SYSRES_CONST_ACTION_TYPE_EXPORT_WITH_LOCK SYSRES_CONST_ACTION_TYPE_EXPORT_WITHOUT_LOCK SYSRES_CONST_ACTION_TYPE_IMPORT_WITH_UNLOCK SYSRES_CONST_ACTION_TYPE_IMPORT_WITHOUT_UNLOCK SYSRES_CONST_ACTION_TYPE_LIFE_CYCLE_STAGE SYSRES_CONST_ACTION_TYPE_LOCK SYSRES_CONST_ACTION_TYPE_LOCK_FOR_SERVER SYSRES_CONST_ACTION_TYPE_LOCK_MODIFY SYSRES_CONST_ACTION_TYPE_MARK_AS_READED SYSRES_CONST_ACTION_TYPE_MARK_AS_UNREADED SYSRES_CONST_ACTION_TYPE_MODIFY SYSRES_CONST_ACTION_TYPE_MODIFY_CARD SYSRES_CONST_ACTION_TYPE_MOVE_TO_ARCHIVE SYSRES_CONST_ACTION_TYPE_OFF_ENCRYPTION SYSRES_CONST_ACTION_TYPE_PASSWORD_CHANGE SYSRES_CONST_ACTION_TYPE_PERFORM SYSRES_CONST_ACTION_TYPE_RECOVER_FROM_LOCAL_COPY SYSRES_CONST_ACTION_TYPE_RESTART SYSRES_CONST_ACTION_TYPE_RESTORE_FROM_ARCHIVE SYSRES_CONST_ACTION_TYPE_REVISION SYSRES_CONST_ACTION_TYPE_SEND_BY_MAIL SYSRES_CONST_ACTION_TYPE_SIGN SYSRES_CONST_ACTION_TYPE_START SYSRES_CONST_ACTION_TYPE_UNLOCK SYSRES_CONST_ACTION_TYPE_UNLOCK_FROM_SERVER SYSRES_CONST_ACTION_TYPE_VERSION_STATE SYSRES_CONST_ACTION_TYPE_VERSION_VISIBILITY SYSRES_CONST_ACTION_TYPE_VIEW SYSRES_CONST_ACTION_TYPE_VIEW_SHADOW_COPY SYSRES_CONST_ACTION_TYPE_WORKFLOW_DESCRIPTION_MODIFY SYSRES_CONST_ACTION_TYPE_WRITE_HISTORY SYSRES_CONST_ACTIVE_VERSION_STATE_PICK_VALUE SYSRES_CONST_ADD_REFERENCE_MODE_NAME SYSRES_CONST_ADDITION_REQUISITE_CODE SYSRES_CONST_ADDITIONAL_PARAMS_REQUISITE_CODE SYSRES_CONST_ADITIONAL_JOB_END_DATE_REQUISITE_NAME SYSRES_CONST_ADITIONAL_JOB_READ_REQUISITE_NAME SYSRES_CONST_ADITIONAL_JOB_START_DATE_REQUISITE_NAME SYSRES_CONST_ADITIONAL_JOB_STATE_REQUISITE_NAME SYSRES_CONST_ADMINISTRATION_HISTORY_ADDING_USER_TO_GROUP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_ADDING_USER_TO_GROUP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_CREATION_COMP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_CREATION_COMP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_CREATION_GROUP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_CREATION_GROUP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_CREATION_USER_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_CREATION_USER_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_DATABASE_USER_CREATION SYSRES_CONST_ADMINISTRATION_HISTORY_DATABASE_USER_CREATION_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_DATABASE_USER_DELETION SYSRES_CONST_ADMINISTRATION_HISTORY_DATABASE_USER_DELETION_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_COMP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_COMP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_GROUP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_GROUP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_USER_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_USER_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_USER_FROM_GROUP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_DELETION_USER_FROM_GROUP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_FILTERER_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_FILTERER_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_FILTERER_RESTRICTION_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_FILTERER_RESTRICTION_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_PRIVILEGE_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_PRIVILEGE_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_RIGHTS_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_GRANTING_RIGHTS_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_IS_MAIN_SERVER_CHANGED_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_IS_MAIN_SERVER_CHANGED_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_IS_PUBLIC_CHANGED_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_IS_PUBLIC_CHANGED_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_FILTERER_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_FILTERER_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_FILTERER_RESTRICTION_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_FILTERER_RESTRICTION_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_PRIVILEGE_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_PRIVILEGE_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_RIGHTS_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_REMOVING_RIGHTS_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_SERVER_LOGIN_CREATION SYSRES_CONST_ADMINISTRATION_HISTORY_SERVER_LOGIN_CREATION_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_SERVER_LOGIN_DELETION SYSRES_CONST_ADMINISTRATION_HISTORY_SERVER_LOGIN_DELETION_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_CATEGORY_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_CATEGORY_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_COMP_TITLE_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_COMP_TITLE_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_FULL_NAME_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_FULL_NAME_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_GROUP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_GROUP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_PARENT_GROUP_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_PARENT_GROUP_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_USER_AUTH_TYPE_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_USER_AUTH_TYPE_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_USER_LOGIN_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_USER_LOGIN_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_USER_STATUS_ACTION SYSRES_CONST_ADMINISTRATION_HISTORY_UPDATING_USER_STATUS_ACTION_CODE SYSRES_CONST_ADMINISTRATION_HISTORY_USER_PASSWORD_CHANGE SYSRES_CONST_ADMINISTRATION_HISTORY_USER_PASSWORD_CHANGE_ACTION SYSRES_CONST_ALL_ACCEPT_CONDITION_RUS SYSRES_CONST_ALL_USERS_GROUP SYSRES_CONST_ALL_USERS_GROUP_NAME SYSRES_CONST_ALL_USERS_SERVER_GROUP_NAME SYSRES_CONST_ALLOWED_ACCESS_TYPE_CODE SYSRES_CONST_ALLOWED_ACCESS_TYPE_NAME SYSRES_CONST_APP_VIEWER_TYPE_REQUISITE_CODE SYSRES_CONST_APPROVING_SIGNATURE_NAME SYSRES_CONST_APPROVING_SIGNATURE_REQUISITE_CODE SYSRES_CONST_ASSISTANT_SUBSTITUE_TYPE SYSRES_CONST_ASSISTANT_SUBSTITUE_TYPE_CODE SYSRES_CONST_ATTACH_TYPE_COMPONENT_TOKEN SYSRES_CONST_ATTACH_TYPE_DOC SYSRES_CONST_ATTACH_TYPE_EDOC SYSRES_CONST_ATTACH_TYPE_FOLDER SYSRES_CONST_ATTACH_TYPE_JOB SYSRES_CONST_ATTACH_TYPE_REFERENCE SYSRES_CONST_ATTACH_TYPE_TASK SYSRES_CONST_AUTH_ENCODED_PASSWORD SYSRES_CONST_AUTH_ENCODED_PASSWORD_CODE SYSRES_CONST_AUTH_NOVELL SYSRES_CONST_AUTH_PASSWORD SYSRES_CONST_AUTH_PASSWORD_CODE SYSRES_CONST_AUTH_WINDOWS SYSRES_CONST_AUTHENTICATING_SIGNATURE_NAME SYSRES_CONST_AUTHENTICATING_SIGNATURE_REQUISITE_CODE SYSRES_CONST_AUTO_ENUM_METHOD_FLAG SYSRES_CONST_AUTO_NUMERATION_CODE SYSRES_CONST_AUTO_STRONG_ENUM_METHOD_FLAG SYSRES_CONST_AUTOTEXT_NAME_REQUISITE_CODE SYSRES_CONST_AUTOTEXT_TEXT_REQUISITE_CODE SYSRES_CONST_AUTOTEXT_USAGE_ALL SYSRES_CONST_AUTOTEXT_USAGE_ALL_CODE SYSRES_CONST_AUTOTEXT_USAGE_SIGN SYSRES_CONST_AUTOTEXT_USAGE_SIGN_CODE SYSRES_CONST_AUTOTEXT_USAGE_WORK SYSRES_CONST_AUTOTEXT_USAGE_WORK_CODE SYSRES_CONST_AUTOTEXT_USE_ANYWHERE_CODE SYSRES_CONST_AUTOTEXT_USE_ON_SIGNING_CODE SYSRES_CONST_AUTOTEXT_USE_ON_WORK_CODE SYSRES_CONST_BEGIN_DATE_REQUISITE_CODE SYSRES_CONST_BLACK_LIFE_CYCLE_STAGE_FONT_COLOR SYSRES_CONST_BLUE_LIFE_CYCLE_STAGE_FONT_COLOR SYSRES_CONST_BTN_PART SYSRES_CONST_CALCULATED_ROLE_TYPE_CODE SYSRES_CONST_CALL_TYPE_VARIABLE_BUTTON_VALUE SYSRES_CONST_CALL_TYPE_VARIABLE_PROGRAM_VALUE SYSRES_CONST_CANCEL_MESSAGE_FUNCTION_RESULT SYSRES_CONST_CARD_PART SYSRES_CONST_CARD_REFERENCE_MODE_NAME SYSRES_CONST_CERTIFICATE_TYPE_REQUISITE_ENCRYPT_VALUE SYSRES_CONST_CERTIFICATE_TYPE_REQUISITE_SIGN_AND_ENCRYPT_VALUE SYSRES_CONST_CERTIFICATE_TYPE_REQUISITE_SIGN_VALUE SYSRES_CONST_CHECK_PARAM_VALUE_DATE_PARAM_TYPE SYSRES_CONST_CHECK_PARAM_VALUE_FLOAT_PARAM_TYPE SYSRES_CONST_CHECK_PARAM_VALUE_INTEGER_PARAM_TYPE SYSRES_CONST_CHECK_PARAM_VALUE_PICK_PARAM_TYPE SYSRES_CONST_CHECK_PARAM_VALUE_REEFRENCE_PARAM_TYPE SYSRES_CONST_CLOSED_RECORD_FLAG_VALUE_FEMININE SYSRES_CONST_CLOSED_RECORD_FLAG_VALUE_MASCULINE SYSRES_CONST_CODE_COMPONENT_TYPE_ADMIN SYSRES_CONST_CODE_COMPONENT_TYPE_DEVELOPER SYSRES_CONST_CODE_COMPONENT_TYPE_DOCS SYSRES_CONST_CODE_COMPONENT_TYPE_EDOC_CARDS SYSRES_CONST_CODE_COMPONENT_TYPE_EXTERNAL_EXECUTABLE SYSRES_CONST_CODE_COMPONENT_TYPE_OTHER SYSRES_CONST_CODE_COMPONENT_TYPE_REFERENCE SYSRES_CONST_CODE_COMPONENT_TYPE_REPORT SYSRES_CONST_CODE_COMPONENT_TYPE_SCRIPT SYSRES_CONST_CODE_COMPONENT_TYPE_URL SYSRES_CONST_CODE_REQUISITE_ACCESS SYSRES_CONST_CODE_REQUISITE_CODE SYSRES_CONST_CODE_REQUISITE_COMPONENT SYSRES_CONST_CODE_REQUISITE_DESCRIPTION SYSRES_CONST_CODE_REQUISITE_EXCLUDE_COMPONENT SYSRES_CONST_CODE_REQUISITE_RECORD SYSRES_CONST_COMMENT_REQ_CODE SYSRES_CONST_COMMON_SETTINGS_REQUISITE_CODE SYSRES_CONST_COMP_CODE_GRD SYSRES_CONST_COMPONENT_GROUP_TYPE_REQUISITE_CODE SYSRES_CONST_COMPONENT_TYPE_ADMIN_COMPONENTS SYSRES_CONST_COMPONENT_TYPE_DEVELOPER_COMPONENTS SYSRES_CONST_COMPONENT_TYPE_DOCS SYSRES_CONST_COMPONENT_TYPE_EDOC_CARDS SYSRES_CONST_COMPONENT_TYPE_EDOCS SYSRES_CONST_COMPONENT_TYPE_EXTERNAL_EXECUTABLE SYSRES_CONST_COMPONENT_TYPE_OTHER SYSRES_CONST_COMPONENT_TYPE_REFERENCE_TYPES SYSRES_CONST_COMPONENT_TYPE_REFERENCES SYSRES_CONST_COMPONENT_TYPE_REPORTS SYSRES_CONST_COMPONENT_TYPE_SCRIPTS SYSRES_CONST_COMPONENT_TYPE_URL SYSRES_CONST_COMPONENTS_REMOTE_SERVERS_VIEW_CODE SYSRES_CONST_CONDITION_BLOCK_DESCRIPTION SYSRES_CONST_CONST_FIRM_STATUS_COMMON SYSRES_CONST_CONST_FIRM_STATUS_INDIVIDUAL SYSRES_CONST_CONST_NEGATIVE_VALUE SYSRES_CONST_CONST_POSITIVE_VALUE SYSRES_CONST_CONST_SERVER_STATUS_DONT_REPLICATE SYSRES_CONST_CONST_SERVER_STATUS_REPLICATE SYSRES_CONST_CONTENTS_REQUISITE_CODE SYSRES_CONST_DATA_TYPE_BOOLEAN SYSRES_CONST_DATA_TYPE_DATE SYSRES_CONST_DATA_TYPE_FLOAT SYSRES_CONST_DATA_TYPE_INTEGER SYSRES_CONST_DATA_TYPE_PICK SYSRES_CONST_DATA_TYPE_REFERENCE SYSRES_CONST_DATA_TYPE_STRING SYSRES_CONST_DATA_TYPE_TEXT SYSRES_CONST_DATA_TYPE_VARIANT SYSRES_CONST_DATE_CLOSE_REQ_CODE SYSRES_CONST_DATE_FORMAT_DATE_ONLY_CHAR SYSRES_CONST_DATE_OPEN_REQ_CODE SYSRES_CONST_DATE_REQUISITE SYSRES_CONST_DATE_REQUISITE_CODE SYSRES_CONST_DATE_REQUISITE_NAME SYSRES_CONST_DATE_REQUISITE_TYPE SYSRES_CONST_DATE_TYPE_CHAR SYSRES_CONST_DATETIME_FORMAT_VALUE SYSRES_CONST_DEA_ACCESS_RIGHTS_ACTION_CODE SYSRES_CONST_DESCRIPTION_LOCALIZE_ID_REQUISITE_CODE SYSRES_CONST_DESCRIPTION_REQUISITE_CODE SYSRES_CONST_DET1_PART SYSRES_CONST_DET2_PART SYSRES_CONST_DET3_PART SYSRES_CONST_DET4_PART SYSRES_CONST_DET5_PART SYSRES_CONST_DET6_PART SYSRES_CONST_DETAIL_DATASET_KEY_REQUISITE_CODE SYSRES_CONST_DETAIL_PICK_REQUISITE_CODE SYSRES_CONST_DETAIL_REQ_CODE SYSRES_CONST_DO_NOT_USE_ACCESS_TYPE_CODE SYSRES_CONST_DO_NOT_USE_ACCESS_TYPE_NAME SYSRES_CONST_DO_NOT_USE_ON_VIEW_ACCESS_TYPE_CODE SYSRES_CONST_DO_NOT_USE_ON_VIEW_ACCESS_TYPE_NAME SYSRES_CONST_DOCUMENT_STORAGES_CODE SYSRES_CONST_DOCUMENT_TEMPLATES_TYPE_NAME SYSRES_CONST_DOUBLE_REQUISITE_CODE SYSRES_CONST_EDITOR_CLOSE_FILE_OBSERV_TYPE_CODE SYSRES_CONST_EDITOR_CLOSE_PROCESS_OBSERV_TYPE_CODE SYSRES_CONST_EDITOR_TYPE_REQUISITE_CODE SYSRES_CONST_EDITORS_APPLICATION_NAME_REQUISITE_CODE SYSRES_CONST_EDITORS_CREATE_SEVERAL_PROCESSES_REQUISITE_CODE SYSRES_CONST_EDITORS_EXTENSION_REQUISITE_CODE SYSRES_CONST_EDITORS_OBSERVER_BY_PROCESS_TYPE SYSRES_CONST_EDITORS_REFERENCE_CODE SYSRES_CONST_EDITORS_REPLACE_SPEC_CHARS_REQUISITE_CODE SYSRES_CONST_EDITORS_USE_PLUGINS_REQUISITE_CODE SYSRES_CONST_EDITORS_VIEW_DOCUMENT_OPENED_TO_EDIT_CODE SYSRES_CONST_EDOC_CARD_TYPE_REQUISITE_CODE SYSRES_CONST_EDOC_CARD_TYPES_LINK_REQUISITE_CODE SYSRES_CONST_EDOC_CERTIFICATE_AND_PASSWORD_ENCODE_CODE SYSRES_CONST_EDOC_CERTIFICATE_ENCODE_CODE SYSRES_CONST_EDOC_DATE_REQUISITE_CODE SYSRES_CONST_EDOC_KIND_REFERENCE_CODE SYSRES_CONST_EDOC_KINDS_BY_TEMPLATE_ACTION_CODE SYSRES_CONST_EDOC_MANAGE_ACCESS_CODE SYSRES_CONST_EDOC_NONE_ENCODE_CODE SYSRES_CONST_EDOC_NUMBER_REQUISITE_CODE SYSRES_CONST_EDOC_PASSWORD_ENCODE_CODE SYSRES_CONST_EDOC_READONLY_ACCESS_CODE SYSRES_CONST_EDOC_SHELL_LIFE_TYPE_VIEW_VALUE SYSRES_CONST_EDOC_SIZE_RESTRICTION_PRIORITY_REQUISITE_CODE SYSRES_CONST_EDOC_STORAGE_CHECK_ACCESS_RIGHTS_REQUISITE_CODE SYSRES_CONST_EDOC_STORAGE_COMPUTER_NAME_REQUISITE_CODE SYSRES_CONST_EDOC_STORAGE_DATABASE_NAME_REQUISITE_CODE SYSRES_CONST_EDOC_STORAGE_EDIT_IN_STORAGE_REQUISITE_CODE SYSRES_CONST_EDOC_STORAGE_LOCAL_PATH_REQUISITE_CODE SYSRES_CONST_EDOC_STORAGE_SHARED_SOURCE_NAME_REQUISITE_CODE SYSRES_CONST_EDOC_TEMPLATE_REQUISITE_CODE SYSRES_CONST_EDOC_TYPES_REFERENCE_CODE SYSRES_CONST_EDOC_VERSION_ACTIVE_STAGE_CODE SYSRES_CONST_EDOC_VERSION_DESIGN_STAGE_CODE SYSRES_CONST_EDOC_VERSION_OBSOLETE_STAGE_CODE SYSRES_CONST_EDOC_WRITE_ACCES_CODE SYSRES_CONST_EDOCUMENT_CARD_REQUISITES_REFERENCE_CODE_SELECTED_REQUISITE SYSRES_CONST_ENCODE_CERTIFICATE_TYPE_CODE SYSRES_CONST_END_DATE_REQUISITE_CODE SYSRES_CONST_ENUMERATION_TYPE_REQUISITE_CODE SYSRES_CONST_EXECUTE_ACCESS_RIGHTS_TYPE_CODE SYSRES_CONST_EXECUTIVE_FILE_STORAGE_TYPE SYSRES_CONST_EXIST_CONST SYSRES_CONST_EXIST_VALUE SYSRES_CONST_EXPORT_LOCK_TYPE_ASK SYSRES_CONST_EXPORT_LOCK_TYPE_WITH_LOCK SYSRES_CONST_EXPORT_LOCK_TYPE_WITHOUT_LOCK SYSRES_CONST_EXPORT_VERSION_TYPE_ASK SYSRES_CONST_EXPORT_VERSION_TYPE_LAST SYSRES_CONST_EXPORT_VERSION_TYPE_LAST_ACTIVE SYSRES_CONST_EXTENSION_REQUISITE_CODE SYSRES_CONST_FILTER_NAME_REQUISITE_CODE SYSRES_CONST_FILTER_REQUISITE_CODE SYSRES_CONST_FILTER_TYPE_COMMON_CODE SYSRES_CONST_FILTER_TYPE_COMMON_NAME SYSRES_CONST_FILTER_TYPE_USER_CODE SYSRES_CONST_FILTER_TYPE_USER_NAME SYSRES_CONST_FILTER_VALUE_REQUISITE_NAME SYSRES_CONST_FLOAT_NUMBER_FORMAT_CHAR SYSRES_CONST_FLOAT_REQUISITE_TYPE SYSRES_CONST_FOLDER_AUTHOR_VALUE SYSRES_CONST_FOLDER_KIND_ANY_OBJECTS SYSRES_CONST_FOLDER_KIND_COMPONENTS SYSRES_CONST_FOLDER_KIND_EDOCS SYSRES_CONST_FOLDER_KIND_JOBS SYSRES_CONST_FOLDER_KIND_TASKS SYSRES_CONST_FOLDER_TYPE_COMMON SYSRES_CONST_FOLDER_TYPE_COMPONENT SYSRES_CONST_FOLDER_TYPE_FAVORITES SYSRES_CONST_FOLDER_TYPE_INBOX SYSRES_CONST_FOLDER_TYPE_OUTBOX SYSRES_CONST_FOLDER_TYPE_QUICK_LAUNCH SYSRES_CONST_FOLDER_TYPE_SEARCH SYSRES_CONST_FOLDER_TYPE_SHORTCUTS SYSRES_CONST_FOLDER_TYPE_USER SYSRES_CONST_FROM_DICTIONARY_ENUM_METHOD_FLAG SYSRES_CONST_FULL_SUBSTITUTE_TYPE SYSRES_CONST_FULL_SUBSTITUTE_TYPE_CODE SYSRES_CONST_FUNCTION_CANCEL_RESULT SYSRES_CONST_FUNCTION_CATEGORY_SYSTEM SYSRES_CONST_FUNCTION_CATEGORY_USER SYSRES_CONST_FUNCTION_FAILURE_RESULT SYSRES_CONST_FUNCTION_SAVE_RESULT SYSRES_CONST_GENERATED_REQUISITE SYSRES_CONST_GREEN_LIFE_CYCLE_STAGE_FONT_COLOR SYSRES_CONST_GROUP_ACCOUNT_TYPE_VALUE_CODE SYSRES_CONST_GROUP_CATEGORY_NORMAL_CODE SYSRES_CONST_GROUP_CATEGORY_NORMAL_NAME SYSRES_CONST_GROUP_CATEGORY_SERVICE_CODE SYSRES_CONST_GROUP_CATEGORY_SERVICE_NAME SYSRES_CONST_GROUP_COMMON_CATEGORY_FIELD_VALUE SYSRES_CONST_GROUP_FULL_NAME_REQUISITE_CODE SYSRES_CONST_GROUP_NAME_REQUISITE_CODE SYSRES_CONST_GROUP_RIGHTS_T_REQUISITE_CODE SYSRES_CONST_GROUP_SERVER_CODES_REQUISITE_CODE SYSRES_CONST_GROUP_SERVER_NAME_REQUISITE_CODE SYSRES_CONST_GROUP_SERVICE_CATEGORY_FIELD_VALUE SYSRES_CONST_GROUP_USER_REQUISITE_CODE SYSRES_CONST_GROUPS_REFERENCE_CODE SYSRES_CONST_GROUPS_REQUISITE_CODE SYSRES_CONST_HIDDEN_MODE_NAME SYSRES_CONST_HIGH_LVL_REQUISITE_CODE SYSRES_CONST_HISTORY_ACTION_CREATE_CODE SYSRES_CONST_HISTORY_ACTION_DELETE_CODE SYSRES_CONST_HISTORY_ACTION_EDIT_CODE SYSRES_CONST_HOUR_CHAR SYSRES_CONST_ID_REQUISITE_CODE SYSRES_CONST_IDSPS_REQUISITE_CODE SYSRES_CONST_IMAGE_MODE_COLOR SYSRES_CONST_IMAGE_MODE_GREYSCALE SYSRES_CONST_IMAGE_MODE_MONOCHROME SYSRES_CONST_IMPORTANCE_HIGH SYSRES_CONST_IMPORTANCE_LOW SYSRES_CONST_IMPORTANCE_NORMAL SYSRES_CONST_IN_DESIGN_VERSION_STATE_PICK_VALUE SYSRES_CONST_INCOMING_WORK_RULE_TYPE_CODE SYSRES_CONST_INT_REQUISITE SYSRES_CONST_INT_REQUISITE_TYPE SYSRES_CONST_INTEGER_NUMBER_FORMAT_CHAR SYSRES_CONST_INTEGER_TYPE_CHAR SYSRES_CONST_IS_GENERATED_REQUISITE_NEGATIVE_VALUE SYSRES_CONST_IS_PUBLIC_ROLE_REQUISITE_CODE SYSRES_CONST_IS_REMOTE_USER_NEGATIVE_VALUE SYSRES_CONST_IS_REMOTE_USER_POSITIVE_VALUE SYSRES_CONST_IS_STORED_REQUISITE_NEGATIVE_VALUE SYSRES_CONST_IS_STORED_REQUISITE_STORED_VALUE SYSRES_CONST_ITALIC_LIFE_CYCLE_STAGE_DRAW_STYLE SYSRES_CONST_JOB_BLOCK_DESCRIPTION SYSRES_CONST_JOB_KIND_CONTROL_JOB SYSRES_CONST_JOB_KIND_JOB SYSRES_CONST_JOB_KIND_NOTICE SYSRES_CONST_JOB_STATE_ABORTED SYSRES_CONST_JOB_STATE_COMPLETE SYSRES_CONST_JOB_STATE_WORKING SYSRES_CONST_KIND_REQUISITE_CODE SYSRES_CONST_KIND_REQUISITE_NAME SYSRES_CONST_KINDS_CREATE_SHADOW_COPIES_REQUISITE_CODE SYSRES_CONST_KINDS_DEFAULT_EDOC_LIFE_STAGE_REQUISITE_CODE SYSRES_CONST_KINDS_EDOC_ALL_TEPLATES_ALLOWED_REQUISITE_CODE SYSRES_CONST_KINDS_EDOC_ALLOW_LIFE_CYCLE_STAGE_CHANGING_REQUISITE_CODE SYSRES_CONST_KINDS_EDOC_ALLOW_MULTIPLE_ACTIVE_VERSIONS_REQUISITE_CODE SYSRES_CONST_KINDS_EDOC_SHARE_ACCES_RIGHTS_BY_DEFAULT_CODE SYSRES_CONST_KINDS_EDOC_TEMPLATE_REQUISITE_CODE SYSRES_CONST_KINDS_EDOC_TYPE_REQUISITE_CODE SYSRES_CONST_KINDS_SIGNERS_REQUISITES_CODE SYSRES_CONST_KOD_INPUT_TYPE SYSRES_CONST_LAST_UPDATE_DATE_REQUISITE_CODE SYSRES_CONST_LIFE_CYCLE_START_STAGE_REQUISITE_CODE SYSRES_CONST_LILAC_LIFE_CYCLE_STAGE_FONT_COLOR SYSRES_CONST_LINK_OBJECT_KIND_COMPONENT SYSRES_CONST_LINK_OBJECT_KIND_DOCUMENT SYSRES_CONST_LINK_OBJECT_KIND_EDOC SYSRES_CONST_LINK_OBJECT_KIND_FOLDER SYSRES_CONST_LINK_OBJECT_KIND_JOB SYSRES_CONST_LINK_OBJECT_KIND_REFERENCE SYSRES_CONST_LINK_OBJECT_KIND_TASK SYSRES_CONST_LINK_REF_TYPE_REQUISITE_CODE SYSRES_CONST_LIST_REFERENCE_MODE_NAME SYSRES_CONST_LOCALIZATION_DICTIONARY_MAIN_VIEW_CODE SYSRES_CONST_MAIN_VIEW_CODE SYSRES_CONST_MANUAL_ENUM_METHOD_FLAG SYSRES_CONST_MASTER_COMP_TYPE_REQUISITE_CODE SYSRES_CONST_MASTER_TABLE_REC_ID_REQUISITE_CODE SYSRES_CONST_MAXIMIZED_MODE_NAME SYSRES_CONST_ME_VALUE SYSRES_CONST_MESSAGE_ATTENTION_CAPTION SYSRES_CONST_MESSAGE_CONFIRMATION_CAPTION SYSRES_CONST_MESSAGE_ERROR_CAPTION SYSRES_CONST_MESSAGE_INFORMATION_CAPTION SYSRES_CONST_MINIMIZED_MODE_NAME SYSRES_CONST_MINUTE_CHAR SYSRES_CONST_MODULE_REQUISITE_CODE SYSRES_CONST_MONITORING_BLOCK_DESCRIPTION SYSRES_CONST_MONTH_FORMAT_VALUE SYSRES_CONST_NAME_LOCALIZE_ID_REQUISITE_CODE SYSRES_CONST_NAME_REQUISITE_CODE SYSRES_CONST_NAME_SINGULAR_REQUISITE_CODE SYSRES_CONST_NAMEAN_INPUT_TYPE SYSRES_CONST_NEGATIVE_PICK_VALUE SYSRES_CONST_NEGATIVE_VALUE SYSRES_CONST_NO SYSRES_CONST_NO_PICK_VALUE SYSRES_CONST_NO_SIGNATURE_REQUISITE_CODE SYSRES_CONST_NO_VALUE SYSRES_CONST_NONE_ACCESS_RIGHTS_TYPE_CODE SYSRES_CONST_NONOPERATING_RECORD_FLAG_VALUE SYSRES_CONST_NONOPERATING_RECORD_FLAG_VALUE_MASCULINE SYSRES_CONST_NORMAL_ACCESS_RIGHTS_TYPE_CODE SYSRES_CONST_NORMAL_LIFE_CYCLE_STAGE_DRAW_STYLE SYSRES_CONST_NORMAL_MODE_NAME SYSRES_CONST_NOT_ALLOWED_ACCESS_TYPE_CODE SYSRES_CONST_NOT_ALLOWED_ACCESS_TYPE_NAME SYSRES_CONST_NOTE_REQUISITE_CODE SYSRES_CONST_NOTICE_BLOCK_DESCRIPTION SYSRES_CONST_NUM_REQUISITE SYSRES_CONST_NUM_STR_REQUISITE_CODE SYSRES_CONST_NUMERATION_AUTO_NOT_STRONG SYSRES_CONST_NUMERATION_AUTO_STRONG SYSRES_CONST_NUMERATION_FROM_DICTONARY SYSRES_CONST_NUMERATION_MANUAL SYSRES_CONST_NUMERIC_TYPE_CHAR SYSRES_CONST_NUMREQ_REQUISITE_CODE SYSRES_CONST_OBSOLETE_VERSION_STATE_PICK_VALUE SYSRES_CONST_OPERATING_RECORD_FLAG_VALUE SYSRES_CONST_OPERATING_RECORD_FLAG_VALUE_CODE SYSRES_CONST_OPERATING_RECORD_FLAG_VALUE_FEMININE SYSRES_CONST_OPERATING_RECORD_FLAG_VALUE_MASCULINE SYSRES_CONST_OPTIONAL_FORM_COMP_REQCODE_PREFIX SYSRES_CONST_ORANGE_LIFE_CYCLE_STAGE_FONT_COLOR SYSRES_CONST_ORIGINALREF_REQUISITE_CODE SYSRES_CONST_OURFIRM_REF_CODE SYSRES_CONST_OURFIRM_REQUISITE_CODE SYSRES_CONST_OURFIRM_VAR SYSRES_CONST_OUTGOING_WORK_RULE_TYPE_CODE SYSRES_CONST_PICK_NEGATIVE_RESULT SYSRES_CONST_PICK_POSITIVE_RESULT SYSRES_CONST_PICK_REQUISITE SYSRES_CONST_PICK_REQUISITE_TYPE SYSRES_CONST_PICK_TYPE_CHAR SYSRES_CONST_PLAN_STATUS_REQUISITE_CODE SYSRES_CONST_PLATFORM_VERSION_COMMENT SYSRES_CONST_PLUGINS_SETTINGS_DESCRIPTION_REQUISITE_CODE SYSRES_CONST_POSITIVE_PICK_VALUE SYSRES_CONST_POWER_TO_CREATE_ACTION_CODE SYSRES_CONST_POWER_TO_SIGN_ACTION_CODE SYSRES_CONST_PRIORITY_REQUISITE_CODE SYSRES_CONST_QUALIFIED_TASK_TYPE SYSRES_CONST_QUALIFIED_TASK_TYPE_CODE SYSRES_CONST_RECSTAT_REQUISITE_CODE SYSRES_CONST_RED_LIFE_CYCLE_STAGE_FONT_COLOR SYSRES_CONST_REF_ID_T_REF_TYPE_REQUISITE_CODE SYSRES_CONST_REF_REQUISITE SYSRES_CONST_REF_REQUISITE_TYPE SYSRES_CONST_REF_REQUISITES_REFERENCE_CODE_SELECTED_REQUISITE SYSRES_CONST_REFERENCE_RECORD_HISTORY_CREATE_ACTION_CODE SYSRES_CONST_REFERENCE_RECORD_HISTORY_DELETE_ACTION_CODE SYSRES_CONST_REFERENCE_RECORD_HISTORY_MODIFY_ACTION_CODE SYSRES_CONST_REFERENCE_TYPE_CHAR SYSRES_CONST_REFERENCE_TYPE_REQUISITE_NAME SYSRES_CONST_REFERENCES_ADD_PARAMS_REQUISITE_CODE SYSRES_CONST_REFERENCES_DISPLAY_REQUISITE_REQUISITE_CODE SYSRES_CONST_REMOTE_SERVER_STATUS_WORKING SYSRES_CONST_REMOTE_SERVER_TYPE_MAIN SYSRES_CONST_REMOTE_SERVER_TYPE_SECONDARY SYSRES_CONST_REMOTE_USER_FLAG_VALUE_CODE SYSRES_CONST_REPORT_APP_EDITOR_INTERNAL SYSRES_CONST_REPORT_BASE_REPORT_ID_REQUISITE_CODE SYSRES_CONST_REPORT_BASE_REPORT_REQUISITE_CODE SYSRES_CONST_REPORT_SCRIPT_REQUISITE_CODE SYSRES_CONST_REPORT_TEMPLATE_REQUISITE_CODE SYSRES_CONST_REPORT_VIEWER_CODE_REQUISITE_CODE SYSRES_CONST_REQ_ALLOW_COMPONENT_DEFAULT_VALUE SYSRES_CONST_REQ_ALLOW_RECORD_DEFAULT_VALUE SYSRES_CONST_REQ_ALLOW_SERVER_COMPONENT_DEFAULT_VALUE SYSRES_CONST_REQ_MODE_AVAILABLE_CODE SYSRES_CONST_REQ_MODE_EDIT_CODE SYSRES_CONST_REQ_MODE_HIDDEN_CODE SYSRES_CONST_REQ_MODE_NOT_AVAILABLE_CODE SYSRES_CONST_REQ_MODE_VIEW_CODE SYSRES_CONST_REQ_NUMBER_REQUISITE_CODE SYSRES_CONST_REQ_SECTION_VALUE SYSRES_CONST_REQ_TYPE_VALUE SYSRES_CONST_REQUISITE_FORMAT_BY_UNIT SYSRES_CONST_REQUISITE_FORMAT_DATE_FULL SYSRES_CONST_REQUISITE_FORMAT_DATE_TIME SYSRES_CONST_REQUISITE_FORMAT_LEFT SYSRES_CONST_REQUISITE_FORMAT_RIGHT SYSRES_CONST_REQUISITE_FORMAT_WITHOUT_UNIT SYSRES_CONST_REQUISITE_NUMBER_REQUISITE_CODE SYSRES_CONST_REQUISITE_SECTION_ACTIONS SYSRES_CONST_REQUISITE_SECTION_BUTTON SYSRES_CONST_REQUISITE_SECTION_BUTTONS SYSRES_CONST_REQUISITE_SECTION_CARD SYSRES_CONST_REQUISITE_SECTION_TABLE SYSRES_CONST_REQUISITE_SECTION_TABLE10 SYSRES_CONST_REQUISITE_SECTION_TABLE11 SYSRES_CONST_REQUISITE_SECTION_TABLE12 SYSRES_CONST_REQUISITE_SECTION_TABLE13 SYSRES_CONST_REQUISITE_SECTION_TABLE14 SYSRES_CONST_REQUISITE_SECTION_TABLE15 SYSRES_CONST_REQUISITE_SECTION_TABLE16 SYSRES_CONST_REQUISITE_SECTION_TABLE17 SYSRES_CONST_REQUISITE_SECTION_TABLE18 SYSRES_CONST_REQUISITE_SECTION_TABLE19 SYSRES_CONST_REQUISITE_SECTION_TABLE2 SYSRES_CONST_REQUISITE_SECTION_TABLE20 SYSRES_CONST_REQUISITE_SECTION_TABLE21 SYSRES_CONST_REQUISITE_SECTION_TABLE22 SYSRES_CONST_REQUISITE_SECTION_TABLE23 SYSRES_CONST_REQUISITE_SECTION_TABLE24 SYSRES_CONST_REQUISITE_SECTION_TABLE3 SYSRES_CONST_REQUISITE_SECTION_TABLE4 SYSRES_CONST_REQUISITE_SECTION_TABLE5 SYSRES_CONST_REQUISITE_SECTION_TABLE6 SYSRES_CONST_REQUISITE_SECTION_TABLE7 SYSRES_CONST_REQUISITE_SECTION_TABLE8 SYSRES_CONST_REQUISITE_SECTION_TABLE9 SYSRES_CONST_REQUISITES_PSEUDOREFERENCE_REQUISITE_NUMBER_REQUISITE_CODE SYSRES_CONST_RIGHT_ALIGNMENT_CODE SYSRES_CONST_ROLES_REFERENCE_CODE SYSRES_CONST_ROUTE_STEP_AFTER_RUS SYSRES_CONST_ROUTE_STEP_AND_CONDITION_RUS SYSRES_CONST_ROUTE_STEP_OR_CONDITION_RUS SYSRES_CONST_ROUTE_TYPE_COMPLEX SYSRES_CONST_ROUTE_TYPE_PARALLEL SYSRES_CONST_ROUTE_TYPE_SERIAL SYSRES_CONST_SBDATASETDESC_NEGATIVE_VALUE SYSRES_CONST_SBDATASETDESC_POSITIVE_VALUE SYSRES_CONST_SBVIEWSDESC_POSITIVE_VALUE SYSRES_CONST_SCRIPT_BLOCK_DESCRIPTION SYSRES_CONST_SEARCH_BY_TEXT_REQUISITE_CODE SYSRES_CONST_SEARCHES_COMPONENT_CONTENT SYSRES_CONST_SEARCHES_CRITERIA_ACTION_NAME SYSRES_CONST_SEARCHES_EDOC_CONTENT SYSRES_CONST_SEARCHES_FOLDER_CONTENT SYSRES_CONST_SEARCHES_JOB_CONTENT SYSRES_CONST_SEARCHES_REFERENCE_CODE SYSRES_CONST_SEARCHES_TASK_CONTENT SYSRES_CONST_SECOND_CHAR SYSRES_CONST_SECTION_REQUISITE_ACTIONS_VALUE SYSRES_CONST_SECTION_REQUISITE_CARD_VALUE SYSRES_CONST_SECTION_REQUISITE_CODE SYSRES_CONST_SECTION_REQUISITE_DETAIL_1_VALUE SYSRES_CONST_SECTION_REQUISITE_DETAIL_2_VALUE SYSRES_CONST_SECTION_REQUISITE_DETAIL_3_VALUE SYSRES_CONST_SECTION_REQUISITE_DETAIL_4_VALUE SYSRES_CONST_SECTION_REQUISITE_DETAIL_5_VALUE SYSRES_CONST_SECTION_REQUISITE_DETAIL_6_VALUE SYSRES_CONST_SELECT_REFERENCE_MODE_NAME SYSRES_CONST_SELECT_TYPE_SELECTABLE SYSRES_CONST_SELECT_TYPE_SELECTABLE_ONLY_CHILD SYSRES_CONST_SELECT_TYPE_SELECTABLE_WITH_CHILD SYSRES_CONST_SELECT_TYPE_UNSLECTABLE SYSRES_CONST_SERVER_TYPE_MAIN SYSRES_CONST_SERVICE_USER_CATEGORY_FIELD_VALUE SYSRES_CONST_SETTINGS_USER_REQUISITE_CODE SYSRES_CONST_SIGNATURE_AND_ENCODE_CERTIFICATE_TYPE_CODE SYSRES_CONST_SIGNATURE_CERTIFICATE_TYPE_CODE SYSRES_CONST_SINGULAR_TITLE_REQUISITE_CODE SYSRES_CONST_SQL_SERVER_AUTHENTIFICATION_FLAG_VALUE_CODE SYSRES_CONST_SQL_SERVER_ENCODE_AUTHENTIFICATION_FLAG_VALUE_CODE SYSRES_CONST_STANDART_ROUTE_REFERENCE_CODE SYSRES_CONST_STANDART_ROUTE_REFERENCE_COMMENT_REQUISITE_CODE SYSRES_CONST_STANDART_ROUTES_GROUPS_REFERENCE_CODE SYSRES_CONST_STATE_REQ_NAME SYSRES_CONST_STATE_REQUISITE_ACTIVE_VALUE SYSRES_CONST_STATE_REQUISITE_CLOSED_VALUE SYSRES_CONST_STATE_REQUISITE_CODE SYSRES_CONST_STATIC_ROLE_TYPE_CODE SYSRES_CONST_STATUS_PLAN_DEFAULT_VALUE SYSRES_CONST_STATUS_VALUE_AUTOCLEANING SYSRES_CONST_STATUS_VALUE_BLUE_SQUARE SYSRES_CONST_STATUS_VALUE_COMPLETE SYSRES_CONST_STATUS_VALUE_GREEN_SQUARE SYSRES_CONST_STATUS_VALUE_ORANGE_SQUARE SYSRES_CONST_STATUS_VALUE_PURPLE_SQUARE SYSRES_CONST_STATUS_VALUE_RED_SQUARE SYSRES_CONST_STATUS_VALUE_SUSPEND SYSRES_CONST_STATUS_VALUE_YELLOW_SQUARE SYSRES_CONST_STDROUTE_SHOW_TO_USERS_REQUISITE_CODE SYSRES_CONST_STORAGE_TYPE_FILE SYSRES_CONST_STORAGE_TYPE_SQL_SERVER SYSRES_CONST_STR_REQUISITE SYSRES_CONST_STRIKEOUT_LIFE_CYCLE_STAGE_DRAW_STYLE SYSRES_CONST_STRING_FORMAT_LEFT_ALIGN_CHAR SYSRES_CONST_STRING_FORMAT_RIGHT_ALIGN_CHAR SYSRES_CONST_STRING_REQUISITE_CODE SYSRES_CONST_STRING_REQUISITE_TYPE SYSRES_CONST_STRING_TYPE_CHAR SYSRES_CONST_SUBSTITUTES_PSEUDOREFERENCE_CODE SYSRES_CONST_SUBTASK_BLOCK_DESCRIPTION SYSRES_CONST_SYSTEM_SETTING_CURRENT_USER_PARAM_VALUE SYSRES_CONST_SYSTEM_SETTING_EMPTY_VALUE_PARAM_VALUE SYSRES_CONST_SYSTEM_VERSION_COMMENT SYSRES_CONST_TASK_ACCESS_TYPE_ALL SYSRES_CONST_TASK_ACCESS_TYPE_ALL_MEMBERS SYSRES_CONST_TASK_ACCESS_TYPE_MANUAL SYSRES_CONST_TASK_ENCODE_TYPE_CERTIFICATION SYSRES_CONST_TASK_ENCODE_TYPE_CERTIFICATION_AND_PASSWORD SYSRES_CONST_TASK_ENCODE_TYPE_NONE SYSRES_CONST_TASK_ENCODE_TYPE_PASSWORD SYSRES_CONST_TASK_ROUTE_ALL_CONDITION SYSRES_CONST_TASK_ROUTE_AND_CONDITION SYSRES_CONST_TASK_ROUTE_OR_CONDITION SYSRES_CONST_TASK_STATE_ABORTED SYSRES_CONST_TASK_STATE_COMPLETE SYSRES_CONST_TASK_STATE_CONTINUED SYSRES_CONST_TASK_STATE_CONTROL SYSRES_CONST_TASK_STATE_INIT SYSRES_CONST_TASK_STATE_WORKING SYSRES_CONST_TASK_TITLE SYSRES_CONST_TASK_TYPES_GROUPS_REFERENCE_CODE SYSRES_CONST_TASK_TYPES_REFERENCE_CODE SYSRES_CONST_TEMPLATES_REFERENCE_CODE SYSRES_CONST_TEST_DATE_REQUISITE_NAME SYSRES_CONST_TEST_DEV_DATABASE_NAME SYSRES_CONST_TEST_DEV_SYSTEM_CODE SYSRES_CONST_TEST_EDMS_DATABASE_NAME SYSRES_CONST_TEST_EDMS_MAIN_CODE SYSRES_CONST_TEST_EDMS_MAIN_DB_NAME SYSRES_CONST_TEST_EDMS_SECOND_CODE SYSRES_CONST_TEST_EDMS_SECOND_DB_NAME SYSRES_CONST_TEST_EDMS_SYSTEM_CODE SYSRES_CONST_TEST_NUMERIC_REQUISITE_NAME SYSRES_CONST_TEXT_REQUISITE SYSRES_CONST_TEXT_REQUISITE_CODE SYSRES_CONST_TEXT_REQUISITE_TYPE SYSRES_CONST_TEXT_TYPE_CHAR SYSRES_CONST_TYPE_CODE_REQUISITE_CODE SYSRES_CONST_TYPE_REQUISITE_CODE SYSRES_CONST_UNDEFINED_LIFE_CYCLE_STAGE_FONT_COLOR SYSRES_CONST_UNITS_SECTION_ID_REQUISITE_CODE SYSRES_CONST_UNITS_SECTION_REQUISITE_CODE SYSRES_CONST_UNOPERATING_RECORD_FLAG_VALUE_CODE SYSRES_CONST_UNSTORED_DATA_REQUISITE_CODE SYSRES_CONST_UNSTORED_DATA_REQUISITE_NAME SYSRES_CONST_USE_ACCESS_TYPE_CODE SYSRES_CONST_USE_ACCESS_TYPE_NAME SYSRES_CONST_USER_ACCOUNT_TYPE_VALUE_CODE SYSRES_CONST_USER_ADDITIONAL_INFORMATION_REQUISITE_CODE SYSRES_CONST_USER_AND_GROUP_ID_FROM_PSEUDOREFERENCE_REQUISITE_CODE SYSRES_CONST_USER_CATEGORY_NORMAL SYSRES_CONST_USER_CERTIFICATE_REQUISITE_CODE SYSRES_CONST_USER_CERTIFICATE_STATE_REQUISITE_CODE SYSRES_CONST_USER_CERTIFICATE_SUBJECT_NAME_REQUISITE_CODE SYSRES_CONST_USER_CERTIFICATE_THUMBPRINT_REQUISITE_CODE SYSRES_CONST_USER_COMMON_CATEGORY SYSRES_CONST_USER_COMMON_CATEGORY_CODE SYSRES_CONST_USER_FULL_NAME_REQUISITE_CODE SYSRES_CONST_USER_GROUP_TYPE_REQUISITE_CODE SYSRES_CONST_USER_LOGIN_REQUISITE_CODE SYSRES_CONST_USER_REMOTE_CONTROLLER_REQUISITE_CODE SYSRES_CONST_USER_REMOTE_SYSTEM_REQUISITE_CODE SYSRES_CONST_USER_RIGHTS_T_REQUISITE_CODE SYSRES_CONST_USER_SERVER_NAME_REQUISITE_CODE SYSRES_CONST_USER_SERVICE_CATEGORY SYSRES_CONST_USER_SERVICE_CATEGORY_CODE SYSRES_CONST_USER_STATUS_ADMINISTRATOR_CODE SYSRES_CONST_USER_STATUS_ADMINISTRATOR_NAME SYSRES_CONST_USER_STATUS_DEVELOPER_CODE SYSRES_CONST_USER_STATUS_DEVELOPER_NAME SYSRES_CONST_USER_STATUS_DISABLED_CODE SYSRES_CONST_USER_STATUS_DISABLED_NAME SYSRES_CONST_USER_STATUS_SYSTEM_DEVELOPER_CODE SYSRES_CONST_USER_STATUS_USER_CODE SYSRES_CONST_USER_STATUS_USER_NAME SYSRES_CONST_USER_STATUS_USER_NAME_DEPRECATED SYSRES_CONST_USER_TYPE_FIELD_VALUE_USER SYSRES_CONST_USER_TYPE_REQUISITE_CODE SYSRES_CONST_USERS_CONTROLLER_REQUISITE_CODE SYSRES_CONST_USERS_IS_MAIN_SERVER_REQUISITE_CODE SYSRES_CONST_USERS_REFERENCE_CODE SYSRES_CONST_USERS_REGISTRATION_CERTIFICATES_ACTION_NAME SYSRES_CONST_USERS_REQUISITE_CODE SYSRES_CONST_USERS_SYSTEM_REQUISITE_CODE SYSRES_CONST_USERS_USER_ACCESS_RIGHTS_TYPR_REQUISITE_CODE SYSRES_CONST_USERS_USER_AUTHENTICATION_REQUISITE_CODE SYSRES_CONST_USERS_USER_COMPONENT_REQUISITE_CODE SYSRES_CONST_USERS_USER_GROUP_REQUISITE_CODE SYSRES_CONST_USERS_VIEW_CERTIFICATES_ACTION_NAME SYSRES_CONST_VIEW_DEFAULT_CODE SYSRES_CONST_VIEW_DEFAULT_NAME SYSRES_CONST_VIEWER_REQUISITE_CODE SYSRES_CONST_WAITING_BLOCK_DESCRIPTION SYSRES_CONST_WIZARD_FORM_LABEL_TEST_STRING SYSRES_CONST_WIZARD_QUERY_PARAM_HEIGHT_ETALON_STRING SYSRES_CONST_WIZARD_REFERENCE_COMMENT_REQUISITE_CODE SYSRES_CONST_WORK_RULES_DESCRIPTION_REQUISITE_CODE SYSRES_CONST_WORK_TIME_CALENDAR_REFERENCE_CODE SYSRES_CONST_WORK_WORKFLOW_HARD_ROUTE_TYPE_VALUE SYSRES_CONST_WORK_WORKFLOW_HARD_ROUTE_TYPE_VALUE_CODE SYSRES_CONST_WORK_WORKFLOW_HARD_ROUTE_TYPE_VALUE_CODE_RUS SYSRES_CONST_WORK_WORKFLOW_SOFT_ROUTE_TYPE_VALUE_CODE_RUS SYSRES_CONST_WORKFLOW_ROUTE_TYPR_HARD SYSRES_CONST_WORKFLOW_ROUTE_TYPR_SOFT SYSRES_CONST_XML_ENCODING SYSRES_CONST_XREC_STAT_REQUISITE_CODE SYSRES_CONST_XRECID_FIELD_NAME SYSRES_CONST_YES SYSRES_CONST_YES_NO_2_REQUISITE_CODE SYSRES_CONST_YES_NO_REQUISITE_CODE SYSRES_CONST_YES_NO_T_REF_TYPE_REQUISITE_CODE SYSRES_CONST_YES_PICK_VALUE SYSRES_CONST_YES_VALUE CR FALSE nil NO_VALUE NULL TAB TRUE YES_VALUE ADMINISTRATORS_GROUP_NAME CUSTOMIZERS_GROUP_NAME DEVELOPERS_GROUP_NAME SERVICE_USERS_GROUP_NAME DECISION_BLOCK_FIRST_OPERAND_PROPERTY DECISION_BLOCK_NAME_PROPERTY DECISION_BLOCK_OPERATION_PROPERTY DECISION_BLOCK_RESULT_TYPE_PROPERTY DECISION_BLOCK_SECOND_OPERAND_PROPERTY ANY_FILE_EXTENTION COMPRESSED_DOCUMENT_EXTENSION EXTENDED_DOCUMENT_EXTENSION SHORT_COMPRESSED_DOCUMENT_EXTENSION SHORT_EXTENDED_DOCUMENT_EXTENSION JOB_BLOCK_ABORT_DEADLINE_PROPERTY JOB_BLOCK_AFTER_FINISH_EVENT JOB_BLOCK_AFTER_QUERY_PARAMETERS_EVENT JOB_BLOCK_ATTACHMENT_PROPERTY JOB_BLOCK_ATTACHMENTS_RIGHTS_GROUP_PROPERTY JOB_BLOCK_ATTACHMENTS_RIGHTS_TYPE_PROPERTY JOB_BLOCK_BEFORE_QUERY_PARAMETERS_EVENT JOB_BLOCK_BEFORE_START_EVENT JOB_BLOCK_CREATED_JOBS_PROPERTY JOB_BLOCK_DEADLINE_PROPERTY JOB_BLOCK_EXECUTION_RESULTS_PROPERTY JOB_BLOCK_IS_PARALLEL_PROPERTY JOB_BLOCK_IS_RELATIVE_ABORT_DEADLINE_PROPERTY JOB_BLOCK_IS_RELATIVE_DEADLINE_PROPERTY JOB_BLOCK_JOB_TEXT_PROPERTY JOB_BLOCK_NAME_PROPERTY JOB_BLOCK_NEED_SIGN_ON_PERFORM_PROPERTY JOB_BLOCK_PERFORMER_PROPERTY JOB_BLOCK_RELATIVE_ABORT_DEADLINE_TYPE_PROPERTY JOB_BLOCK_RELATIVE_DEADLINE_TYPE_PROPERTY JOB_BLOCK_SUBJECT_PROPERTY ENGLISH_LANGUAGE_CODE RUSSIAN_LANGUAGE_CODE smHidden smMaximized smMinimized smNormal wmNo wmYes COMPONENT_TOKEN_LINK_KIND DOCUMENT_LINK_KIND EDOCUMENT_LINK_KIND FOLDER_LINK_KIND JOB_LINK_KIND REFERENCE_LINK_KIND TASK_LINK_KIND COMPONENT_TOKEN_LOCK_TYPE EDOCUMENT_VERSION_LOCK_TYPE MONITOR_BLOCK_AFTER_FINISH_EVENT MONITOR_BLOCK_BEFORE_START_EVENT MONITOR_BLOCK_DEADLINE_PROPERTY MONITOR_BLOCK_INTERVAL_PROPERTY MONITOR_BLOCK_INTERVAL_TYPE_PROPERTY MONITOR_BLOCK_IS_RELATIVE_DEADLINE_PROPERTY MONITOR_BLOCK_NAME_PROPERTY MONITOR_BLOCK_RELATIVE_DEADLINE_TYPE_PROPERTY MONITOR_BLOCK_SEARCH_SCRIPT_PROPERTY NOTICE_BLOCK_AFTER_FINISH_EVENT NOTICE_BLOCK_ATTACHMENT_PROPERTY NOTICE_BLOCK_ATTACHMENTS_RIGHTS_GROUP_PROPERTY NOTICE_BLOCK_ATTACHMENTS_RIGHTS_TYPE_PROPERTY NOTICE_BLOCK_BEFORE_START_EVENT NOTICE_BLOCK_CREATED_NOTICES_PROPERTY NOTICE_BLOCK_DEADLINE_PROPERTY NOTICE_BLOCK_IS_RELATIVE_DEADLINE_PROPERTY NOTICE_BLOCK_NAME_PROPERTY NOTICE_BLOCK_NOTICE_TEXT_PROPERTY NOTICE_BLOCK_PERFORMER_PROPERTY NOTICE_BLOCK_RELATIVE_DEADLINE_TYPE_PROPERTY NOTICE_BLOCK_SUBJECT_PROPERTY dseAfterCancel dseAfterClose dseAfterDelete dseAfterDeleteOutOfTransaction dseAfterInsert dseAfterOpen dseAfterScroll dseAfterUpdate dseAfterUpdateOutOfTransaction dseBeforeCancel dseBeforeClose dseBeforeDelete dseBeforeDetailUpdate dseBeforeInsert dseBeforeOpen dseBeforeUpdate dseOnAnyRequisiteChange dseOnCloseRecord dseOnDeleteError dseOnOpenRecord dseOnPrepareUpdate dseOnUpdateError dseOnUpdateRatifiedRecord dseOnValidDelete dseOnValidUpdate reOnChange reOnChangeValues SELECTION_BEGIN_ROUTE_EVENT SELECTION_END_ROUTE_EVENT CURRENT_PERIOD_IS_REQUIRED PREVIOUS_CARD_TYPE_NAME SHOW_RECORD_PROPERTIES_FORM ACCESS_RIGHTS_SETTING_DIALOG_CODE ADMINISTRATOR_USER_CODE ANALYTIC_REPORT_TYPE asrtHideLocal asrtHideRemote CALCULATED_ROLE_TYPE_CODE COMPONENTS_REFERENCE_DEVELOPER_VIEW_CODE DCTS_TEST_PROTOCOLS_FOLDER_PATH E_EDOC_VERSION_ALREADY_APPROVINGLY_SIGNED E_EDOC_VERSION_ALREADY_APPROVINGLY_SIGNED_BY_USER E_EDOC_VERSION_ALREDY_SIGNED E_EDOC_VERSION_ALREDY_SIGNED_BY_USER EDOC_TYPES_CODE_REQUISITE_FIELD_NAME EDOCUMENTS_ALIAS_NAME FILES_FOLDER_PATH FILTER_OPERANDS_DELIMITER FILTER_OPERATIONS_DELIMITER FORMCARD_NAME FORMLIST_NAME GET_EXTENDED_DOCUMENT_EXTENSION_CREATION_MODE GET_EXTENDED_DOCUMENT_EXTENSION_IMPORT_MODE INTEGRATED_REPORT_TYPE IS_BUILDER_APPLICATION_ROLE IS_BUILDER_APPLICATION_ROLE2 IS_BUILDER_USERS ISBSYSDEV LOG_FOLDER_PATH mbCancel mbNo mbNoToAll mbOK mbYes mbYesToAll MEMORY_DATASET_DESRIPTIONS_FILENAME mrNo mrNoToAll mrYes mrYesToAll MULTIPLE_SELECT_DIALOG_CODE NONOPERATING_RECORD_FLAG_FEMININE NONOPERATING_RECORD_FLAG_MASCULINE OPERATING_RECORD_FLAG_FEMININE OPERATING_RECORD_FLAG_MASCULINE PROFILING_SETTINGS_COMMON_SETTINGS_CODE_VALUE PROGRAM_INITIATED_LOOKUP_ACTION ratDelete ratEdit ratInsert REPORT_TYPE REQUIRED_PICK_VALUES_VARIABLE rmCard rmList SBRTE_PROGID_DEV SBRTE_PROGID_RELEASE STATIC_ROLE_TYPE_CODE SUPPRESS_EMPTY_TEMPLATE_CREATION SYSTEM_USER_CODE UPDATE_DIALOG_DATASET USED_IN_OBJECT_HINT_PARAM USER_INITIATED_LOOKUP_ACTION USER_NAME_FORMAT USER_SELECTION_RESTRICTIONS WORKFLOW_TEST_PROTOCOLS_FOLDER_PATH ELS_SUBTYPE_CONTROL_NAME ELS_FOLDER_KIND_CONTROL_NAME REPEAT_PROCESS_CURRENT_OBJECT_EXCEPTION_NAME PRIVILEGE_COMPONENT_FULL_ACCESS PRIVILEGE_DEVELOPMENT_EXPORT PRIVILEGE_DEVELOPMENT_IMPORT PRIVILEGE_DOCUMENT_DELETE PRIVILEGE_ESD PRIVILEGE_FOLDER_DELETE PRIVILEGE_MANAGE_ACCESS_RIGHTS PRIVILEGE_MANAGE_REPLICATION PRIVILEGE_MANAGE_SESSION_SERVER PRIVILEGE_OBJECT_FULL_ACCESS PRIVILEGE_OBJECT_VIEW PRIVILEGE_RESERVE_LICENSE PRIVILEGE_SYSTEM_CUSTOMIZE PRIVILEGE_SYSTEM_DEVELOP PRIVILEGE_SYSTEM_INSTALL PRIVILEGE_TASK_DELETE PRIVILEGE_USER_PLUGIN_SETTINGS_CUSTOMIZE PRIVILEGES_PSEUDOREFERENCE_CODE ACCESS_TYPES_PSEUDOREFERENCE_CODE ALL_AVAILABLE_COMPONENTS_PSEUDOREFERENCE_CODE ALL_AVAILABLE_PRIVILEGES_PSEUDOREFERENCE_CODE ALL_REPLICATE_COMPONENTS_PSEUDOREFERENCE_CODE AVAILABLE_DEVELOPERS_COMPONENTS_PSEUDOREFERENCE_CODE COMPONENTS_PSEUDOREFERENCE_CODE FILTRATER_SETTINGS_CONFLICTS_PSEUDOREFERENCE_CODE GROUPS_PSEUDOREFERENCE_CODE RECEIVE_PROTOCOL_PSEUDOREFERENCE_CODE REFERENCE_REQUISITE_PSEUDOREFERENCE_CODE REFERENCE_REQUISITES_PSEUDOREFERENCE_CODE REFTYPES_PSEUDOREFERENCE_CODE REPLICATION_SEANCES_DIARY_PSEUDOREFERENCE_CODE SEND_PROTOCOL_PSEUDOREFERENCE_CODE SUBSTITUTES_PSEUDOREFERENCE_CODE SYSTEM_SETTINGS_PSEUDOREFERENCE_CODE UNITS_PSEUDOREFERENCE_CODE USERS_PSEUDOREFERENCE_CODE VIEWERS_PSEUDOREFERENCE_CODE CERTIFICATE_TYPE_ENCRYPT CERTIFICATE_TYPE_SIGN CERTIFICATE_TYPE_SIGN_AND_ENCRYPT STORAGE_TYPE_FILE STORAGE_TYPE_NAS_CIFS STORAGE_TYPE_SAPERION STORAGE_TYPE_SQL_SERVER COMPTYPE2_REQUISITE_DOCUMENTS_VALUE COMPTYPE2_REQUISITE_TASKS_VALUE COMPTYPE2_REQUISITE_FOLDERS_VALUE COMPTYPE2_REQUISITE_REFERENCES_VALUE SYSREQ_CODE SYSREQ_COMPTYPE2 SYSREQ_CONST_AVAILABLE_FOR_WEB SYSREQ_CONST_COMMON_CODE SYSREQ_CONST_COMMON_VALUE SYSREQ_CONST_FIRM_CODE SYSREQ_CONST_FIRM_STATUS SYSREQ_CONST_FIRM_VALUE SYSREQ_CONST_SERVER_STATUS SYSREQ_CONTENTS SYSREQ_DATE_OPEN SYSREQ_DATE_CLOSE SYSREQ_DESCRIPTION SYSREQ_DESCRIPTION_LOCALIZE_ID SYSREQ_DOUBLE SYSREQ_EDOC_ACCESS_TYPE SYSREQ_EDOC_AUTHOR SYSREQ_EDOC_CREATED SYSREQ_EDOC_DELEGATE_RIGHTS_REQUISITE_CODE SYSREQ_EDOC_EDITOR SYSREQ_EDOC_ENCODE_TYPE SYSREQ_EDOC_ENCRYPTION_PLUGIN_NAME SYSREQ_EDOC_ENCRYPTION_PLUGIN_VERSION SYSREQ_EDOC_EXPORT_DATE SYSREQ_EDOC_EXPORTER SYSREQ_EDOC_KIND SYSREQ_EDOC_LIFE_STAGE_NAME SYSREQ_EDOC_LOCKED_FOR_SERVER_CODE SYSREQ_EDOC_MODIFIED SYSREQ_EDOC_NAME SYSREQ_EDOC_NOTE SYSREQ_EDOC_QUALIFIED_ID SYSREQ_EDOC_SESSION_KEY SYSREQ_EDOC_SESSION_KEY_ENCRYPTION_PLUGIN_NAME SYSREQ_EDOC_SESSION_KEY_ENCRYPTION_PLUGIN_VERSION SYSREQ_EDOC_SIGNATURE_TYPE SYSREQ_EDOC_SIGNED SYSREQ_EDOC_STORAGE SYSREQ_EDOC_STORAGES_ARCHIVE_STORAGE SYSREQ_EDOC_STORAGES_CHECK_RIGHTS SYSREQ_EDOC_STORAGES_COMPUTER_NAME SYSREQ_EDOC_STORAGES_EDIT_IN_STORAGE SYSREQ_EDOC_STORAGES_EXECUTIVE_STORAGE SYSREQ_EDOC_STORAGES_FUNCTION SYSREQ_EDOC_STORAGES_INITIALIZED SYSREQ_EDOC_STORAGES_LOCAL_PATH SYSREQ_EDOC_STORAGES_SAPERION_DATABASE_NAME SYSREQ_EDOC_STORAGES_SEARCH_BY_TEXT SYSREQ_EDOC_STORAGES_SERVER_NAME SYSREQ_EDOC_STORAGES_SHARED_SOURCE_NAME SYSREQ_EDOC_STORAGES_TYPE SYSREQ_EDOC_TEXT_MODIFIED SYSREQ_EDOC_TYPE_ACT_CODE SYSREQ_EDOC_TYPE_ACT_DESCRIPTION SYSREQ_EDOC_TYPE_ACT_DESCRIPTION_LOCALIZE_ID SYSREQ_EDOC_TYPE_ACT_ON_EXECUTE SYSREQ_EDOC_TYPE_ACT_ON_EXECUTE_EXISTS SYSREQ_EDOC_TYPE_ACT_SECTION SYSREQ_EDOC_TYPE_ADD_PARAMS SYSREQ_EDOC_TYPE_COMMENT SYSREQ_EDOC_TYPE_EVENT_TEXT SYSREQ_EDOC_TYPE_NAME_IN_SINGULAR SYSREQ_EDOC_TYPE_NAME_IN_SINGULAR_LOCALIZE_ID SYSREQ_EDOC_TYPE_NAME_LOCALIZE_ID SYSREQ_EDOC_TYPE_NUMERATION_METHOD SYSREQ_EDOC_TYPE_PSEUDO_REQUISITE_CODE SYSREQ_EDOC_TYPE_REQ_CODE SYSREQ_EDOC_TYPE_REQ_DESCRIPTION SYSREQ_EDOC_TYPE_REQ_DESCRIPTION_LOCALIZE_ID SYSREQ_EDOC_TYPE_REQ_IS_LEADING SYSREQ_EDOC_TYPE_REQ_IS_REQUIRED SYSREQ_EDOC_TYPE_REQ_NUMBER SYSREQ_EDOC_TYPE_REQ_ON_CHANGE SYSREQ_EDOC_TYPE_REQ_ON_CHANGE_EXISTS SYSREQ_EDOC_TYPE_REQ_ON_SELECT SYSREQ_EDOC_TYPE_REQ_ON_SELECT_KIND SYSREQ_EDOC_TYPE_REQ_SECTION SYSREQ_EDOC_TYPE_VIEW_CARD SYSREQ_EDOC_TYPE_VIEW_CODE SYSREQ_EDOC_TYPE_VIEW_COMMENT SYSREQ_EDOC_TYPE_VIEW_IS_MAIN SYSREQ_EDOC_TYPE_VIEW_NAME SYSREQ_EDOC_TYPE_VIEW_NAME_LOCALIZE_ID SYSREQ_EDOC_VERSION_AUTHOR SYSREQ_EDOC_VERSION_CRC SYSREQ_EDOC_VERSION_DATA SYSREQ_EDOC_VERSION_EDITOR SYSREQ_EDOC_VERSION_EXPORT_DATE SYSREQ_EDOC_VERSION_EXPORTER SYSREQ_EDOC_VERSION_HIDDEN SYSREQ_EDOC_VERSION_LIFE_STAGE SYSREQ_EDOC_VERSION_MODIFIED SYSREQ_EDOC_VERSION_NOTE SYSREQ_EDOC_VERSION_SIGNATURE_TYPE SYSREQ_EDOC_VERSION_SIGNED SYSREQ_EDOC_VERSION_SIZE SYSREQ_EDOC_VERSION_SOURCE SYSREQ_EDOC_VERSION_TEXT_MODIFIED SYSREQ_EDOCKIND_DEFAULT_VERSION_STATE_CODE SYSREQ_FOLDER_KIND SYSREQ_FUNC_CATEGORY SYSREQ_FUNC_COMMENT SYSREQ_FUNC_GROUP SYSREQ_FUNC_GROUP_COMMENT SYSREQ_FUNC_GROUP_NUMBER SYSREQ_FUNC_HELP SYSREQ_FUNC_PARAM_DEF_VALUE SYSREQ_FUNC_PARAM_IDENT SYSREQ_FUNC_PARAM_NUMBER SYSREQ_FUNC_PARAM_TYPE SYSREQ_FUNC_TEXT SYSREQ_GROUP_CATEGORY SYSREQ_ID SYSREQ_LAST_UPDATE SYSREQ_LEADER_REFERENCE SYSREQ_LINE_NUMBER SYSREQ_MAIN_RECORD_ID SYSREQ_NAME SYSREQ_NAME_LOCALIZE_ID SYSREQ_NOTE SYSREQ_ORIGINAL_RECORD SYSREQ_OUR_FIRM SYSREQ_PROFILING_SETTINGS_BATCH_LOGING SYSREQ_PROFILING_SETTINGS_BATCH_SIZE SYSREQ_PROFILING_SETTINGS_PROFILING_ENABLED SYSREQ_PROFILING_SETTINGS_SQL_PROFILING_ENABLED SYSREQ_PROFILING_SETTINGS_START_LOGGED SYSREQ_RECORD_STATUS SYSREQ_REF_REQ_FIELD_NAME SYSREQ_REF_REQ_FORMAT SYSREQ_REF_REQ_GENERATED SYSREQ_REF_REQ_LENGTH SYSREQ_REF_REQ_PRECISION SYSREQ_REF_REQ_REFERENCE SYSREQ_REF_REQ_SECTION SYSREQ_REF_REQ_STORED SYSREQ_REF_REQ_TOKENS SYSREQ_REF_REQ_TYPE SYSREQ_REF_REQ_VIEW SYSREQ_REF_TYPE_ACT_CODE SYSREQ_REF_TYPE_ACT_DESCRIPTION SYSREQ_REF_TYPE_ACT_DESCRIPTION_LOCALIZE_ID SYSREQ_REF_TYPE_ACT_ON_EXECUTE SYSREQ_REF_TYPE_ACT_ON_EXECUTE_EXISTS SYSREQ_REF_TYPE_ACT_SECTION SYSREQ_REF_TYPE_ADD_PARAMS SYSREQ_REF_TYPE_COMMENT SYSREQ_REF_TYPE_COMMON_SETTINGS SYSREQ_REF_TYPE_DISPLAY_REQUISITE_NAME SYSREQ_REF_TYPE_EVENT_TEXT SYSREQ_REF_TYPE_MAIN_LEADING_REF SYSREQ_REF_TYPE_NAME_IN_SINGULAR SYSREQ_REF_TYPE_NAME_IN_SINGULAR_LOCALIZE_ID SYSREQ_REF_TYPE_NAME_LOCALIZE_ID SYSREQ_REF_TYPE_NUMERATION_METHOD SYSREQ_REF_TYPE_REQ_CODE SYSREQ_REF_TYPE_REQ_DESCRIPTION SYSREQ_REF_TYPE_REQ_DESCRIPTION_LOCALIZE_ID SYSREQ_REF_TYPE_REQ_IS_CONTROL SYSREQ_REF_TYPE_REQ_IS_FILTER SYSREQ_REF_TYPE_REQ_IS_LEADING SYSREQ_REF_TYPE_REQ_IS_REQUIRED SYSREQ_REF_TYPE_REQ_NUMBER SYSREQ_REF_TYPE_REQ_ON_CHANGE SYSREQ_REF_TYPE_REQ_ON_CHANGE_EXISTS SYSREQ_REF_TYPE_REQ_ON_SELECT SYSREQ_REF_TYPE_REQ_ON_SELECT_KIND SYSREQ_REF_TYPE_REQ_SECTION SYSREQ_REF_TYPE_VIEW_CARD SYSREQ_REF_TYPE_VIEW_CODE SYSREQ_REF_TYPE_VIEW_COMMENT SYSREQ_REF_TYPE_VIEW_IS_MAIN SYSREQ_REF_TYPE_VIEW_NAME SYSREQ_REF_TYPE_VIEW_NAME_LOCALIZE_ID SYSREQ_REFERENCE_TYPE_ID SYSREQ_STATE SYSREQ_STATЕ SYSREQ_SYSTEM_SETTINGS_VALUE SYSREQ_TYPE SYSREQ_UNIT SYSREQ_UNIT_ID SYSREQ_USER_GROUPS_GROUP_FULL_NAME SYSREQ_USER_GROUPS_GROUP_NAME SYSREQ_USER_GROUPS_GROUP_SERVER_NAME SYSREQ_USERS_ACCESS_RIGHTS SYSREQ_USERS_AUTHENTICATION SYSREQ_USERS_CATEGORY SYSREQ_USERS_COMPONENT SYSREQ_USERS_COMPONENT_USER_IS_PUBLIC SYSREQ_USERS_DOMAIN SYSREQ_USERS_FULL_USER_NAME SYSREQ_USERS_GROUP SYSREQ_USERS_IS_MAIN_SERVER SYSREQ_USERS_LOGIN SYSREQ_USERS_REFERENCE_USER_IS_PUBLIC SYSREQ_USERS_STATUS SYSREQ_USERS_USER_CERTIFICATE SYSREQ_USERS_USER_CERTIFICATE_INFO SYSREQ_USERS_USER_CERTIFICATE_PLUGIN_NAME SYSREQ_USERS_USER_CERTIFICATE_PLUGIN_VERSION SYSREQ_USERS_USER_CERTIFICATE_STATE SYSREQ_USERS_USER_CERTIFICATE_SUBJECT_NAME SYSREQ_USERS_USER_CERTIFICATE_THUMBPRINT SYSREQ_USERS_USER_DEFAULT_CERTIFICATE SYSREQ_USERS_USER_DESCRIPTION SYSREQ_USERS_USER_GLOBAL_NAME SYSREQ_USERS_USER_LOGIN SYSREQ_USERS_USER_MAIN_SERVER SYSREQ_USERS_USER_TYPE SYSREQ_WORK_RULES_FOLDER_ID RESULT_VAR_NAME RESULT_VAR_NAME_ENG AUTO_NUMERATION_RULE_ID CANT_CHANGE_ID_REQUISITE_RULE_ID CANT_CHANGE_OURFIRM_REQUISITE_RULE_ID CHECK_CHANGING_REFERENCE_RECORD_USE_RULE_ID CHECK_CODE_REQUISITE_RULE_ID CHECK_DELETING_REFERENCE_RECORD_USE_RULE_ID CHECK_FILTRATER_CHANGES_RULE_ID CHECK_RECORD_INTERVAL_RULE_ID CHECK_REFERENCE_INTERVAL_RULE_ID CHECK_REQUIRED_DATA_FULLNESS_RULE_ID CHECK_REQUIRED_REQUISITES_FULLNESS_RULE_ID MAKE_RECORD_UNRATIFIED_RULE_ID RESTORE_AUTO_NUMERATION_RULE_ID SET_FIRM_CONTEXT_FROM_RECORD_RULE_ID SET_FIRST_RECORD_IN_LIST_FORM_RULE_ID SET_IDSPS_VALUE_RULE_ID SET_NEXT_CODE_VALUE_RULE_ID SET_OURFIRM_BOUNDS_RULE_ID SET_OURFIRM_REQUISITE_RULE_ID SCRIPT_BLOCK_AFTER_FINISH_EVENT SCRIPT_BLOCK_BEFORE_START_EVENT SCRIPT_BLOCK_EXECUTION_RESULTS_PROPERTY SCRIPT_BLOCK_NAME_PROPERTY SCRIPT_BLOCK_SCRIPT_PROPERTY SUBTASK_BLOCK_ABORT_DEADLINE_PROPERTY SUBTASK_BLOCK_AFTER_FINISH_EVENT SUBTASK_BLOCK_ASSIGN_PARAMS_EVENT SUBTASK_BLOCK_ATTACHMENTS_PROPERTY SUBTASK_BLOCK_ATTACHMENTS_RIGHTS_GROUP_PROPERTY SUBTASK_BLOCK_ATTACHMENTS_RIGHTS_TYPE_PROPERTY SUBTASK_BLOCK_BEFORE_START_EVENT SUBTASK_BLOCK_CREATED_TASK_PROPERTY SUBTASK_BLOCK_CREATION_EVENT SUBTASK_BLOCK_DEADLINE_PROPERTY SUBTASK_BLOCK_IMPORTANCE_PROPERTY SUBTASK_BLOCK_INITIATOR_PROPERTY SUBTASK_BLOCK_IS_RELATIVE_ABORT_DEADLINE_PROPERTY SUBTASK_BLOCK_IS_RELATIVE_DEADLINE_PROPERTY SUBTASK_BLOCK_JOBS_TYPE_PROPERTY SUBTASK_BLOCK_NAME_PROPERTY SUBTASK_BLOCK_PARALLEL_ROUTE_PROPERTY SUBTASK_BLOCK_PERFORMERS_PROPERTY SUBTASK_BLOCK_RELATIVE_ABORT_DEADLINE_TYPE_PROPERTY SUBTASK_BLOCK_RELATIVE_DEADLINE_TYPE_PROPERTY SUBTASK_BLOCK_REQUIRE_SIGN_PROPERTY SUBTASK_BLOCK_STANDARD_ROUTE_PROPERTY SUBTASK_BLOCK_START_EVENT SUBTASK_BLOCK_STEP_CONTROL_PROPERTY SUBTASK_BLOCK_SUBJECT_PROPERTY SUBTASK_BLOCK_TASK_CONTROL_PROPERTY SUBTASK_BLOCK_TEXT_PROPERTY SUBTASK_BLOCK_UNLOCK_ATTACHMENTS_ON_STOP_PROPERTY SUBTASK_BLOCK_USE_STANDARD_ROUTE_PROPERTY SUBTASK_BLOCK_WAIT_FOR_TASK_COMPLETE_PROPERTY SYSCOMP_CONTROL_JOBS SYSCOMP_FOLDERS SYSCOMP_JOBS SYSCOMP_NOTICES SYSCOMP_TASKS SYSDLG_CREATE_EDOCUMENT SYSDLG_CREATE_EDOCUMENT_VERSION SYSDLG_CURRENT_PERIOD SYSDLG_EDIT_FUNCTION_HELP SYSDLG_EDOCUMENT_KINDS_FOR_TEMPLATE SYSDLG_EXPORT_MULTIPLE_EDOCUMENTS SYSDLG_EXPORT_SINGLE_EDOCUMENT SYSDLG_IMPORT_EDOCUMENT SYSDLG_MULTIPLE_SELECT SYSDLG_SETUP_ACCESS_RIGHTS SYSDLG_SETUP_DEFAULT_RIGHTS SYSDLG_SETUP_FILTER_CONDITION SYSDLG_SETUP_SIGN_RIGHTS SYSDLG_SETUP_TASK_OBSERVERS SYSDLG_SETUP_TASK_ROUTE SYSDLG_SETUP_USERS_LIST SYSDLG_SIGN_EDOCUMENT SYSDLG_SIGN_MULTIPLE_EDOCUMENTS SYSREF_ACCESS_RIGHTS_TYPES SYSREF_ADMINISTRATION_HISTORY SYSREF_ALL_AVAILABLE_COMPONENTS SYSREF_ALL_AVAILABLE_PRIVILEGES SYSREF_ALL_REPLICATING_COMPONENTS SYSREF_AVAILABLE_DEVELOPERS_COMPONENTS SYSREF_CALENDAR_EVENTS SYSREF_COMPONENT_TOKEN_HISTORY SYSREF_COMPONENT_TOKENS SYSREF_COMPONENTS SYSREF_CONSTANTS SYSREF_DATA_RECEIVE_PROTOCOL SYSREF_DATA_SEND_PROTOCOL SYSREF_DIALOGS SYSREF_DIALOGS_REQUISITES SYSREF_EDITORS SYSREF_EDOC_CARDS SYSREF_EDOC_TYPES SYSREF_EDOCUMENT_CARD_REQUISITES SYSREF_EDOCUMENT_CARD_TYPES SYSREF_EDOCUMENT_CARD_TYPES_REFERENCE SYSREF_EDOCUMENT_CARDS SYSREF_EDOCUMENT_HISTORY SYSREF_EDOCUMENT_KINDS SYSREF_EDOCUMENT_REQUISITES SYSREF_EDOCUMENT_SIGNATURES SYSREF_EDOCUMENT_TEMPLATES SYSREF_EDOCUMENT_TEXT_STORAGES SYSREF_EDOCUMENT_VIEWS SYSREF_FILTERER_SETUP_CONFLICTS SYSREF_FILTRATER_SETTING_CONFLICTS SYSREF_FOLDER_HISTORY SYSREF_FOLDERS SYSREF_FUNCTION_GROUPS SYSREF_FUNCTION_PARAMS SYSREF_FUNCTIONS SYSREF_JOB_HISTORY SYSREF_LINKS SYSREF_LOCALIZATION_DICTIONARY SYSREF_LOCALIZATION_LANGUAGES SYSREF_MODULES SYSREF_PRIVILEGES SYSREF_RECORD_HISTORY SYSREF_REFERENCE_REQUISITES SYSREF_REFERENCE_TYPE_VIEWS SYSREF_REFERENCE_TYPES SYSREF_REFERENCES SYSREF_REFERENCES_REQUISITES SYSREF_REMOTE_SERVERS SYSREF_REPLICATION_SESSIONS_LOG SYSREF_REPLICATION_SESSIONS_PROTOCOL SYSREF_REPORTS SYSREF_ROLES SYSREF_ROUTE_BLOCK_GROUPS SYSREF_ROUTE_BLOCKS SYSREF_SCRIPTS SYSREF_SEARCHES SYSREF_SERVER_EVENTS SYSREF_SERVER_EVENTS_HISTORY SYSREF_STANDARD_ROUTE_GROUPS SYSREF_STANDARD_ROUTES SYSREF_STATUSES SYSREF_SYSTEM_SETTINGS SYSREF_TASK_HISTORY SYSREF_TASK_KIND_GROUPS SYSREF_TASK_KINDS SYSREF_TASK_RIGHTS SYSREF_TASK_SIGNATURES SYSREF_TASKS SYSREF_UNITS SYSREF_USER_GROUPS SYSREF_USER_GROUPS_REFERENCE SYSREF_USER_SUBSTITUTION SYSREF_USERS SYSREF_USERS_REFERENCE SYSREF_VIEWERS SYSREF_WORKING_TIME_CALENDARS ACCESS_RIGHTS_TABLE_NAME EDMS_ACCESS_TABLE_NAME EDOC_TYPES_TABLE_NAME TEST_DEV_DB_NAME TEST_DEV_SYSTEM_CODE TEST_EDMS_DB_NAME TEST_EDMS_MAIN_CODE TEST_EDMS_MAIN_DB_NAME TEST_EDMS_SECOND_CODE TEST_EDMS_SECOND_DB_NAME TEST_EDMS_SYSTEM_CODE TEST_ISB5_MAIN_CODE TEST_ISB5_SECOND_CODE TEST_SQL_SERVER_2005_NAME TEST_SQL_SERVER_NAME ATTENTION_CAPTION cbsCommandLinks cbsDefault CONFIRMATION_CAPTION ERROR_CAPTION INFORMATION_CAPTION mrCancel mrOk EDOC_VERSION_ACTIVE_STAGE_CODE EDOC_VERSION_DESIGN_STAGE_CODE EDOC_VERSION_OBSOLETE_STAGE_CODE cpDataEnciphermentEnabled cpDigitalSignatureEnabled cpID cpIssuer cpPluginVersion cpSerial cpSubjectName cpSubjSimpleName cpValidFromDate cpValidToDate ISBL_SYNTAX NO_SYNTAX XML_SYNTAX WAIT_BLOCK_AFTER_FINISH_EVENT WAIT_BLOCK_BEFORE_START_EVENT WAIT_BLOCK_DEADLINE_PROPERTY WAIT_BLOCK_IS_RELATIVE_DEADLINE_PROPERTY WAIT_BLOCK_NAME_PROPERTY WAIT_BLOCK_RELATIVE_DEADLINE_TYPE_PROPERTY SYSRES_COMMON SYSRES_CONST SYSRES_MBFUNC SYSRES_SBDATA SYSRES_SBGUI SYSRES_SBINTF SYSRES_SBREFDSC SYSRES_SQLERRORS SYSRES_SYSCOMP) + b["enum"] = Set.new %w(atUser atGroup atRole aemEnabledAlways aemDisabledAlways aemEnabledOnBrowse aemEnabledOnEdit aemDisabledOnBrowseEmpty apBegin apEnd alLeft alRight asmNever asmNoButCustomize asmAsLastTime asmYesButCustomize asmAlways cirCommon cirRevoked ctSignature ctEncode ctSignatureEncode clbUnchecked clbChecked clbGrayed ceISB ceAlways ceNever ctDocument ctReference ctScript ctUnknown ctReport ctDialog ctFunction ctFolder ctEDocument ctTask ctJob ctNotice ctControlJob cfInternal cfDisplay ciUnspecified ciWrite ciRead ckFolder ckEDocument ckTask ckJob ckComponentToken ckAny ckReference ckScript ckReport ckDialog ctISBLEditor ctBevel ctButton ctCheckListBox ctComboBox ctComboEdit ctGrid ctDBCheckBox ctDBComboBox ctDBEdit ctDBEllipsis ctDBMemo ctDBNavigator ctDBRadioGroup ctDBStatusLabel ctEdit ctGroupBox ctInplaceHint ctMemo ctPanel ctListBox ctRadioButton ctRichEdit ctTabSheet ctWebBrowser ctImage ctHyperLink ctLabel ctDBMultiEllipsis ctRibbon ctRichView ctInnerPanel ctPanelGroup ctBitButton cctDate cctInteger cctNumeric cctPick cctReference cctString cctText cltInternal cltPrimary cltGUI dseBeforeOpen dseAfterOpen dseBeforeClose dseAfterClose dseOnValidDelete dseBeforeDelete dseAfterDelete dseAfterDeleteOutOfTransaction dseOnDeleteError dseBeforeInsert dseAfterInsert dseOnValidUpdate dseBeforeUpdate dseOnUpdateRatifiedRecord dseAfterUpdate dseAfterUpdateOutOfTransaction dseOnUpdateError dseAfterScroll dseOnOpenRecord dseOnCloseRecord dseBeforeCancel dseAfterCancel dseOnUpdateDeadlockError dseBeforeDetailUpdate dseOnPrepareUpdate dseOnAnyRequisiteChange dssEdit dssInsert dssBrowse dssInActive dftDate dftShortDate dftDateTime dftTimeStamp dotDays dotHours dotMinutes dotSeconds dtkndLocal dtkndUTC arNone arView arEdit arFull ddaView ddaEdit emLock emEdit emSign emExportWithLock emImportWithUnlock emChangeVersionNote emOpenForModify emChangeLifeStage emDelete emCreateVersion emImport emUnlockExportedWithLock emStart emAbort emReInit emMarkAsReaded emMarkAsUnreaded emPerform emAccept emResume emChangeRights emEditRoute emEditObserver emRecoveryFromLocalCopy emChangeWorkAccessType emChangeEncodeTypeToCertificate emChangeEncodeTypeToPassword emChangeEncodeTypeToNone emChangeEncodeTypeToCertificatePassword emChangeStandardRoute emGetText emOpenForView emMoveToStorage emCreateObject emChangeVersionHidden emDeleteVersion emChangeLifeCycleStage emApprovingSign emExport emContinue emLockFromEdit emUnLockForEdit emLockForServer emUnlockFromServer emDelegateAccessRights emReEncode ecotFile ecotProcess eaGet eaCopy eaCreate eaCreateStandardRoute edltAll edltNothing edltQuery essmText essmCard esvtLast esvtLastActive esvtSpecified edsfExecutive edsfArchive edstSQLServer edstFile edvstNone edvstEDocumentVersionCopy edvstFile edvstTemplate edvstScannedFile vsDefault vsDesign vsActive vsObsolete etNone etCertificate etPassword etCertificatePassword ecException ecWarning ecInformation estAll estApprovingOnly evtLast evtLastActive evtQuery fdtString fdtNumeric fdtInteger fdtDate fdtText fdtUnknown fdtWideString fdtLargeInteger ftInbox ftOutbox ftFavorites ftCommonFolder ftUserFolder ftComponents ftQuickLaunch ftShortcuts ftSearch grhAuto grhX1 grhX2 grhX3 hltText hltRTF hltHTML iffBMP iffJPEG iffMultiPageTIFF iffSinglePageTIFF iffTIFF iffPNG im8bGrayscale im24bRGB im1bMonochrome itBMP itJPEG itWMF itPNG ikhInformation ikhWarning ikhError ikhNoIcon icUnknown icScript icFunction icIntegratedReport icAnalyticReport icDataSetEventHandler icActionHandler icFormEventHandler icLookUpEventHandler icRequisiteChangeEventHandler icBeforeSearchEventHandler icRoleCalculation icSelectRouteEventHandler icBlockPropertyCalculation icBlockQueryParamsEventHandler icChangeSearchResultEventHandler icBlockEventHandler icSubTaskInitEventHandler icEDocDataSetEventHandler icEDocLookUpEventHandler icEDocActionHandler icEDocFormEventHandler icEDocRequisiteChangeEventHandler icStructuredConversionRule icStructuredConversionEventBefore icStructuredConversionEventAfter icWizardEventHandler icWizardFinishEventHandler icWizardStepEventHandler icWizardStepFinishEventHandler icWizardActionEnableEventHandler icWizardActionExecuteEventHandler icCreateJobsHandler icCreateNoticesHandler icBeforeLookUpEventHandler icAfterLookUpEventHandler icTaskAbortEventHandler icWorkflowBlockActionHandler icDialogDataSetEventHandler icDialogActionHandler icDialogLookUpEventHandler icDialogRequisiteChangeEventHandler icDialogFormEventHandler icDialogValidCloseEventHandler icBlockFormEventHandler icTaskFormEventHandler icReferenceMethod icEDocMethod icDialogMethod icProcessMessageHandler isShow isHide isByUserSettings jkJob jkNotice jkControlJob jtInner jtLeft jtRight jtFull jtCross lbpAbove lbpBelow lbpLeft lbpRight eltPerConnection eltPerUser sfcUndefined sfcBlack sfcGreen sfcRed sfcBlue sfcOrange sfcLilac sfsItalic sfsStrikeout sfsNormal ldctStandardRoute ldctWizard ldctScript ldctFunction ldctRouteBlock ldctIntegratedReport ldctAnalyticReport ldctReferenceType ldctEDocumentType ldctDialog ldctServerEvents mrcrtNone mrcrtUser mrcrtMaximal mrcrtCustom vtEqual vtGreaterOrEqual vtLessOrEqual vtRange rdYesterday rdToday rdTomorrow rdThisWeek rdThisMonth rdThisYear rdNextMonth rdNextWeek rdLastWeek rdLastMonth rdWindow rdFile rdPrinter rdtString rdtNumeric rdtInteger rdtDate rdtReference rdtAccount rdtText rdtPick rdtUnknown rdtLargeInteger rdtDocument reOnChange reOnChangeValues ttGlobal ttLocal ttUser ttSystem ssmBrowse ssmSelect ssmMultiSelect ssmBrowseModal smSelect smLike smCard stNone stAuthenticating stApproving sctString sctStream sstAnsiSort sstNaturalSort svtEqual svtContain soatString soatNumeric soatInteger soatDatetime soatReferenceRecord soatText soatPick soatBoolean soatEDocument soatAccount soatIntegerCollection soatNumericCollection soatStringCollection soatPickCollection soatDatetimeCollection soatBooleanCollection soatReferenceRecordCollection soatEDocumentCollection soatAccountCollection soatContents soatUnknown tarAbortByUser tarAbortByWorkflowException tvtAllWords tvtExactPhrase tvtAnyWord usNone usCompleted usRedSquare usBlueSquare usYellowSquare usGreenSquare usOrangeSquare usPurpleSquare usFollowUp utUnknown utUser utDeveloper utAdministrator utSystemDeveloper utDisconnected btAnd btDetailAnd btOr btNotOr btOnly vmView vmSelect vmNavigation vsmSingle vsmMultiple vsmMultipleCheck vsmNoSelection wfatPrevious wfatNext wfatCancel wfatFinish wfepUndefined wfepText3 wfepText6 wfepText9 wfepSpinEdit wfepDropDown wfepRadioGroup wfepFlag wfepText12 wfepText15 wfepText18 wfepText21 wfepText24 wfepText27 wfepText30 wfepRadioGroupColumn1 wfepRadioGroupColumn2 wfepRadioGroupColumn3 wfetQueryParameter wfetText wfetDelimiter wfetLabel wptString wptInteger wptNumeric wptBoolean wptDateTime wptPick wptText wptUser wptUserList wptEDocumentInfo wptEDocumentInfoList wptReferenceRecordInfo wptReferenceRecordInfoList wptFolderInfo wptTaskInfo wptContents wptFileName wptDate wsrComplete wsrGoNext wsrGoPrevious wsrCustom wsrCancel wsrGoFinal wstForm wstEDocument wstTaskCard wstReferenceRecordCard wstFinal waAll waPerformers waManual wsbStart wsbFinish wsbNotice wsbStep wsbDecision wsbWait wsbMonitor wsbScript wsbConnector wsbSubTask wsbLifeCycleStage wsbPause wdtInteger wdtFloat wdtString wdtPick wdtDateTime wdtBoolean wdtTask wdtJob wdtFolder wdtEDocument wdtReferenceRecord wdtUser wdtGroup wdtRole wdtIntegerCollection wdtFloatCollection wdtStringCollection wdtPickCollection wdtDateTimeCollection wdtBooleanCollection wdtTaskCollection wdtJobCollection wdtFolderCollection wdtEDocumentCollection wdtReferenceRecordCollection wdtUserCollection wdtGroupCollection wdtRoleCollection wdtContents wdtUserList wdtSearchDescription wdtDeadLine wdtPickSet wdtAccountCollection wiLow wiNormal wiHigh wrtSoft wrtHard wsInit wsRunning wsDone wsControlled wsAborted wsContinued wtmFull wtmFromCurrent wtmOnlyCurrent) + b["global"] = Set.new %w(AltState Application CallType ComponentTokens CreatedJobs CreatedNotices ControlState DialogResult Dialogs EDocuments EDocumentVersionSource Folders GlobalIDs Job Jobs InputValue LookUpReference LookUpRequisiteNames LookUpSearch Object ParentComponent Processes References Requisite ReportName Reports Result Scripts Searches SelectedAttachments SelectedItems SelectMode Sender ServerEvents ServiceFactory ShiftState SubTask SystemDialogs Tasks Wizard Wizards Work ВызовСпособ ИмяОтчета РеквЗнач) + b["interface"] = Set.new %w(IApplication IAccessRights IAccountRepository IAccountSelectionRestrictions IAction IActionList IAdministrationHistoryDescription IAnchors IApplication IArchiveInfo IAttachment IAttachmentList ICheckListBox ICheckPointedList IColumn IComponent IComponentDescription IComponentToken IComponentTokenFactory IComponentTokenInfo ICompRecordInfo IConnection IContents IControl IControlJob IControlJobInfo IControlList ICrypto ICrypto2 ICustomJob ICustomJobInfo ICustomListBox ICustomObjectWizardStep ICustomWork ICustomWorkInfo IDataSet IDataSetAccessInfo IDataSigner IDateCriterion IDateRequisite IDateRequisiteDescription IDateValue IDeaAccessRights IDeaObjectInfo IDevelopmentComponentLock IDialog IDialogFactory IDialogPickRequisiteItems IDialogsFactory IDICSFactory IDocRequisite IDocumentInfo IDualListDialog IECertificate IECertificateInfo IECertificates IEditControl IEditorForm IEdmsExplorer IEdmsObject IEdmsObjectDescription IEdmsObjectFactory IEdmsObjectInfo IEDocument IEDocumentAccessRights IEDocumentDescription IEDocumentEditor IEDocumentFactory IEDocumentInfo IEDocumentStorage IEDocumentVersion IEDocumentVersionListDialog IEDocumentVersionSource IEDocumentWizardStep IEDocVerSignature IEDocVersionState IEnabledMode IEncodeProvider IEncrypter IEvent IEventList IException IExternalEvents IExternalHandler IFactory IField IFileDialog IFolder IFolderDescription IFolderDialog IFolderFactory IFolderInfo IForEach IForm IFormTitle IFormWizardStep IGlobalIDFactory IGlobalIDInfo IGrid IHasher IHistoryDescription IHyperLinkControl IImageButton IImageControl IInnerPanel IInplaceHint IIntegerCriterion IIntegerList IIntegerRequisite IIntegerValue IISBLEditorForm IJob IJobDescription IJobFactory IJobForm IJobInfo ILabelControl ILargeIntegerCriterion ILargeIntegerRequisite ILargeIntegerValue ILicenseInfo ILifeCycleStage IList IListBox ILocalIDInfo ILocalization ILock IMemoryDataSet IMessagingFactory IMetadataRepository INotice INoticeInfo INumericCriterion INumericRequisite INumericValue IObject IObjectDescription IObjectImporter IObjectInfo IObserver IPanelGroup IPickCriterion IPickProperty IPickRequisite IPickRequisiteDescription IPickRequisiteItem IPickRequisiteItems IPickValue IPrivilege IPrivilegeList IProcess IProcessFactory IProcessMessage IProgress IProperty IPropertyChangeEvent IQuery IReference IReferenceCriterion IReferenceEnabledMode IReferenceFactory IReferenceHistoryDescription IReferenceInfo IReferenceRecordCardWizardStep IReferenceRequisiteDescription IReferencesFactory IReferenceValue IRefRequisite IReport IReportFactory IRequisite IRequisiteDescription IRequisiteDescriptionList IRequisiteFactory IRichEdit IRouteStep IRule IRuleList ISchemeBlock IScript IScriptFactory ISearchCriteria ISearchCriterion ISearchDescription ISearchFactory ISearchFolderInfo ISearchForObjectDescription ISearchResultRestrictions ISecuredContext ISelectDialog IServerEvent IServerEventFactory IServiceDialog IServiceFactory ISignature ISignProvider ISignProvider2 ISignProvider3 ISimpleCriterion IStringCriterion IStringList IStringRequisite IStringRequisiteDescription IStringValue ISystemDialogsFactory ISystemInfo ITabSheet ITask ITaskAbortReasonInfo ITaskCardWizardStep ITaskDescription ITaskFactory ITaskInfo ITaskRoute ITextCriterion ITextRequisite ITextValue ITreeListSelectDialog IUser IUserList IValue IView IWebBrowserControl IWizard IWizardAction IWizardFactory IWizardFormElement IWizardParam IWizardPickParam IWizardReferenceParam IWizardStep IWorkAccessRights IWorkDescription IWorkflowAskableParam IWorkflowAskableParams IWorkflowBlock IWorkflowBlockResult IWorkflowEnabledMode IWorkflowParam IWorkflowPickParam IWorkflowReferenceParam IWorkState IWorkTreeCustomNode IWorkTreeJobNode IWorkTreeTaskNode IXMLEditorForm SBCrypto) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/j.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/j.rb new file mode 100644 index 0000000..7a5ede1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/j.rb @@ -0,0 +1,244 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class J < RegexLexer + title 'J' + desc "The J programming language (jsoftware.com)" + tag 'j' + filenames '*.ijs', '*.ijt' + + # For J-specific terms we use, see: + # https://code.jsoftware.com/wiki/Vocabulary/AET + # https://code.jsoftware.com/wiki/Vocabulary/Glossary + + # https://code.jsoftware.com/wiki/Vocabulary/PartsOfSpeech + def self.token_map + @token_map ||= { + noun: Keyword::Constant, + verb: Name::Function, + modifier: Operator, + name: Name, + param: Name::Builtin::Pseudo, + other: Punctuation, + nil => Error, + } + end + + # https://code.jsoftware.com/wiki/NuVoc + def self.inflection_list + @inflection_list ||= ['', '.', ':', '..', '.:', ':.', '::'] + end + + def self.primitive_table + @primitive_table ||= Hash.new([:name]).tap do |h| + { + '()' => [:other], + '=' => [:verb, :other, :other], + '<>+-*%$|,#' => [:verb, :verb, :verb], + '^' => [:verb, :verb, :modifier], + '~"' => [:modifier, :verb, :verb], + '.:@' => [:modifier, :modifier, :modifier], + ';' => [:verb, :modifier, :verb], + '!' => [:verb, :modifier, :modifier], + '/\\' => [:modifier, :modifier, :verb], + '[' => [:verb, nil, :verb], + ']' => [:verb], + '{' => [:verb, :verb, :verb, nil, nil, nil, :verb], + '}' => [:modifier, :verb, :verb, nil, nil, nil, :modifier], + '`' => [:modifier, nil, :modifier], + '&' => [:modifier, :modifier, :modifier, nil, :modifier], + '?' => [:verb, :verb], + 'a' => [:name, :noun, :noun], + 'ACeEIjorv' => [:name, :verb], + 'bdfHMT' => [:name, :modifier], + 'Dt' => [:name, :modifier, :modifier], + 'F' => [:name, :modifier, :modifier, :modifier, :modifier, + :modifier, :modifier], + 'iu' => [:name, :verb, :verb], + 'L' => [:name, :verb, :modifier], + 'mny' => [:param], + 'p' => [:name, :verb, :verb, :verb], + 'qsZ' => [:name, nil, :verb], + 'S' => [:name, nil, :modifier], + 'u' => [:param, :verb, :verb], + 'v' => [:param, :verb], + 'x' => [:param, nil, :verb], + }.each {|k, v| k.each_char {|c| h[c] = v } } + end + end + + def self.primitive(char, inflection) + i = inflection_list.index(inflection) or return Error + token_map[primitive_table[char][i]] + end + + def self.control_words + @control_words ||= Set.new %w( + assert break case catch catchd catcht continue do else elseif end + fcase for if return select throw try while whilst + ) + end + + def self.control_words_id + @control_words_id ||= Set.new %w(for goto label) + end + + state :expr do + rule %r/\s+/, Text + + rule %r'([!-&(-/:-@\[-^`{-~]|[A-Za-z]\b)([.:]*)' do |m| + token J.primitive(m[1], m[2]) + end + + rule %r/(?:\d|_\d?):([.:]*)/ do |m| + token m[1].empty? ? J.token_map[:verb] : Error + end + + rule %r/[\d_][\w.]*([.:]*)/ do |m| + token m[1].empty? ? Num : Error + end + + rule %r/'/, Str::Single, :str + + rule %r/NB\.(?![.:]).*/, Comment::Single + + rule %r/([A-Za-z]\w*)([.:]*)/ do |m| + if m[2] == '.' + word, sep, id = m[1].partition '_' + list = if sep.empty? + J.control_words + elsif not id.empty? + J.control_words_id + end + if list and list.include? word + token Keyword, word + sep + token((word == 'for' ? Name : Name::Label), id) + token Keyword, m[2] + else + token Error + end + else + token m[2].empty? ? Name : Error + end + end + end + + state :str do + rule %r/''/, Str::Escape + rule %r/[^'\n]+/, Str::Single + rule %r/'|$/, Str::Single, :pop! + end + + start do + @note_next = false + end + + state :root do + rule %r/\n/ do + token Text + if @note_next + push :note + @note_next = false + end + end + + # https://code.jsoftware.com/wiki/Vocabulary/com + # https://code.jsoftware.com/wiki/Vocabulary/NounExplicitDefinition + rule %r/ + ([0-4]|13|adverb|conjunction|dyad|monad|noun|verb)([\ \t]+) + (def(?:ine)?\b|:)(?![.:])([\ \t]*) + /x do |m| + groups Keyword::Pseudo, Text, Keyword::Pseudo, Text + @def_body = (m[1] == '0' || m[1] == 'noun') ? :noun : :code + if m[3] == 'define' + # stack: [:root] + # or [:root, ..., :def_next] + pop! if stack.size > 1 + push @def_body + push :def_next # [:root, ..., @def_body, :def_next] + else + push :expl_def + end + end + + rule %r/^([ \t]*)(Note\b(?![.:]))([ \t\r]*)(?!=[.:]|$)/ do + groups Text, Name, Text + @note_next = true + end + + rule %r/[mnuvxy]\b(?![.:])/, Name + mixin :expr + end + + state :def_next do + rule %r/\n/, Text, :pop! + mixin :root + end + + state :expl_def do + rule %r/0\b(?![.:])/ do + token Keyword::Pseudo + # stack: [:root, :expl_def] + # or [:root, ..., :def_next, :expl_def] + pop! if stack.size > 2 + goto @def_body + push :def_next # [:root, ..., @def_body, :def_next] + end + rule %r/'/ do + if @def_body == :noun + token Str::Single + goto :str + else + token Punctuation + goto :q_expr + end + end + rule(//) { pop! } + end + + # `q_expr` lexes the content of a string literal which is a part of an + # explicit definition. + # e.g. dyad def 'x + y' + state :q_expr do + rule %r/''/, Str::Single, :q_str + rule %r/'|$/, Punctuation, :pop! + rule %r/NB\.(?![.:])([^'\n]|'')*/, Comment::Single + mixin :expr + end + + state :q_str do + rule %r/''''/, Str::Escape + rule %r/[^'\n]+/, Str::Single + rule %r/''/, Str::Single, :pop! + rule(/'|$/) { token Punctuation; pop! 2 } + end + + state :note do + mixin :delimiter + rule %r/.+\n?/, Comment::Multiline + end + + state :noun do + mixin :delimiter + rule %r/.+\n?/, Str::Heredoc + end + + state :code do + mixin :delimiter + rule %r/^([ \t]*)(:)([ \t\r]*)$/ do + groups Text, Punctuation, Text + end + mixin :expr + end + + state :delimiter do + rule %r/^([ \t]*)(\))([ \t\r]*$\n?)/ do + groups Text, Punctuation, Text + pop! + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/janet.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/janet.rb new file mode 100644 index 0000000..18b2465 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/janet.rb @@ -0,0 +1,218 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Janet < RegexLexer + title "Janet" + desc "The Janet programming language (janet-lang.org)" + + tag 'janet' + aliases 'jdn' + + filenames '*.janet', '*.jdn' + + mimetypes 'text/x-janet', 'application/x-janet' + + def self.specials + @specials ||= Set.new %w( + break def do fn if quote quasiquote splice set unquote var while + ) + end + + def self.bundled + @bundled ||= Set.new %w( + % %= * *= + ++ += - -- -= -> ->> -?> -?>> / /= < <= = > >= + abstract? accumulate accumulate2 all all-bindings + all-dynamics and apply array array/concat array/ensure + array/fill array/insert array/new array/new-filled + array/peek array/pop array/push array/remove array/slice + array? as-> as?-> asm assert bad-compile bad-parse band + blshift bnot boolean? bor brshift brushift buffer buffer/bit + buffer/bit-clear buffer/bit-set buffer/bit-toggle + buffer/blit buffer/clear buffer/fill buffer/format + buffer/new buffer/new-filled buffer/popn buffer/push-byte + buffer/push-string buffer/push-word buffer/slice buffer? + bxor bytes? case cfunction? chr cli-main comment comp + compare compare= compare< compare<= compare> compare>= + compile complement comptime cond coro count debug + debug/arg-stack debug/break debug/fbreak debug/lineage + debug/stack debug/stacktrace debug/step debug/unbreak + debug/unfbreak debugger-env dec deep-not= deep= default + default-peg-grammar def- defer defmacro defmacro- defn defn- + defglobal describe dictionary? disasm distinct doc doc* + doc-format dofile drop drop-until drop-while dyn each eachk + eachp eachy edefer eflush empty? env-lookup eprin eprinf + eprint eprintf error errorf eval eval-string even? every? + extreme false? fiber/can-resume? fiber/current fiber/getenv + fiber/maxstack fiber/new fiber/root fiber/setenv + fiber/setmaxstack fiber/status fiber? file/close file/flush + file/open file/popen file/read file/seek file/temp + file/write filter find find-index first flatten flatten-into + flush for forv freeze frequencies function? gccollect + gcinterval gcsetinterval generate gensym get get-in getline + hash idempotent? identity import import* if-let if-not + if-with in inc indexed? int/s64 int/u64 int? interleave + interpose invert janet/build janet/config-bits janet/version + juxt juxt* keep keys keyword keyword? kvs label last length + let load-image load-image-dict loop macex macex1 make-env + make-image make-image-dict map mapcat marshal math/-inf + math/abs math/acos math/acosh math/asin math/asinh math/atan + math/atan2 math/atanh math/cbrt math/ceil math/cos math/cosh + math/e math/erf math/erfc math/exp math/exp2 math/expm1 + math/floor math/gamma math/hypot math/inf math/log + math/log10 math/log1p math/log2 math/next math/pi math/pow + math/random math/rng math/rng-buffer math/rng-int + math/rng-uniform math/round math/seedrandom math/sin + math/sinh math/sqrt math/tan math/tanh math/trunc match max + mean merge merge-into min mod module/add-paths module/cache + module/expand-path module/find module/loaders module/loading + module/paths nan? nat? native neg? net/chunk net/close + net/connect net/read net/server net/write next nil? not not= + number? odd? one? or os/arch os/cd os/chmod os/clock + os/cryptorand os/cwd os/date os/dir os/environ os/execute + os/exit os/getenv os/link os/lstat os/mkdir os/mktime + os/perm-int os/perm-string os/readlink os/realpath os/rename + os/rm os/rmdir os/setenv os/shell os/sleep os/stat + os/symlink os/time os/touch os/umask os/which pairs parse + parser/byte parser/clone parser/consume parser/eof + parser/error parser/flush parser/has-more parser/insert + parser/new parser/produce parser/state parser/status + parser/where partial partition peg/compile peg/match pos? + postwalk pp prewalk prin prinf print printf product prompt + propagate protect put put-in quit range reduce reduce2 + repeat repl require resume return reverse reversed root-env + run-context scan-number seq setdyn shortfn signal slice + slurp some sort sort-by sorted sorted-by spit stderr stdin + stdout string string/ascii-lower string/ascii-upper + string/bytes string/check-set string/find string/find-all + string/format string/from-bytes string/has-prefix? + string/has-suffix? string/join string/repeat string/replace + string/replace-all string/reverse string/slice string/split + string/trim string/triml string/trimr string? struct struct? + sum symbol symbol? table table/clone table/getproto + table/new table/rawget table/setproto table/to-struct table? + take take-until take-while tarray/buffer tarray/copy-bytes + tarray/length tarray/new tarray/properties tarray/slice + tarray/swap-bytes thread/close thread/current thread/new + thread/receive thread/send trace tracev true? truthy? try + tuple tuple/brackets tuple/setmap tuple/slice + tuple/sourcemap tuple/type tuple? type unless unmarshal + untrace update update-in use values var- varfn varglobal + walk walk-ind walk-dict when when-let when-with with + with-dyns with-syms with-vars yield zero? zipcoll + ) + end + + def name_token(name) + if self.class.specials.include? name + Keyword + elsif self.class.bundled.include? name + Keyword::Reserved + else + Name::Function + end + end + + punctuation = %r/[_!$%^&*+=~<>.?\/-]/o + symbol = %r/([[:alpha:]]|#{punctuation})([[:word:]]|#{punctuation}|:)*/o + + state :root do + rule %r/#.*?$/, Comment::Single + rule %r/\s+/m, Text::Whitespace + + rule %r/(true|false|nil)\b/, Name::Constant + rule %r/(['~])(#{symbol})/ do + groups Operator, Str::Symbol + end + rule %r/:([[:word:]]|#{punctuation}|:)*/, Keyword::Constant + + # radix-specified numbers + rule %r/[+-]?\d{1,2}r[\w.]+(&[+-]?\w+)?/, Num::Float + + # hex numbers + rule %r/[+-]?0x\h[\h_]*(\.\h[\h_]*)?/, Num::Hex + rule %r/[+-]?0x\.\h[\h_]*/, Num::Hex + + # decimal numbers (Janet treats all decimals as floats) + rule %r/[+-]?\d[\d_]*(\.\d[\d_]*)?([e][+-]?\d+)?/i, Num::Float + rule %r/[+-]?\.\d[\d_]*([e][+-]?\d+)?/i, Num::Float + + rule %r/@?"/, Str::Double, :string + rule %r/@?(`+).*?\1/m, Str::Heredoc + + rule %r/\(/, Punctuation, :function + + rule %r/(')(@?[(\[{])/ do + groups Operator, Punctuation + push :quote + end + + rule %r/(~)(@?[(\[{])/ do + groups Operator, Punctuation + push :quasiquote + end + + rule %r/[\#~,';\|]/, Operator + + rule %r/@?[(){}\[\]]/, Punctuation + + rule symbol, Name + end + + state :string do + rule %r/"/, Str::Double, :pop! + rule %r/\\(u\h{4}|U\h{6})/, Str::Escape + rule %r/\\./, Str::Escape + rule %r/[^"\\]+/, Str::Double + end + + state :function do + rule %r/[\)]/, Punctuation, :pop! + + rule symbol do |m| + case m[0] + when "quote" + token Keyword + goto :quote + when "quasiquote" + token Keyword + goto :quasiquote + else + token name_token(m[0]) + goto :root + end + end + + mixin :root + end + + state :quote do + rule %r/[(\[{]/, Punctuation, :push + rule %r/[)\]}]/, Punctuation, :pop! + rule symbol, Str::Escape + mixin :root + end + + state :quasiquote do + rule %r/(,)(\()/ do + groups Operator, Punctuation + push :function + end + rule %r/(\()(\s*)(unquote)(\s+)(\()/ do + groups Punctuation, Text, Keyword, Text, Punctuation + push :function + end + + rule %r/(,)(#{symbol})/ do + groups Operator, Name + end + rule %r/(\()(\s*)(unquote)(\s+)(#{symbol})/ do + groups Punctuation, Text, Keyword, Text, Name + end + + mixin :quote + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/java.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/java.rb new file mode 100644 index 0000000..051531f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/java.rb @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Java < RegexLexer + title "Java" + desc "The Java programming language (java.com)" + + tag 'java' + filenames '*.java' + mimetypes 'text/x-java' + + keywords = %w( + assert break case catch continue default do else finally for + if goto instanceof new return switch this throw try while + ) + + declarations = %w( + abstract const enum extends final implements native private protected + public static strictfp super synchronized throws transient volatile + ) + + types = %w(boolean byte char double float int long short var void) + + id = /[[:alpha:]_][[:word:]]*/ + const_name = /[[:upper:]][[:upper:][:digit:]_]*\b/ + class_name = /[[:upper:]][[:alnum:]]*\b/ + + state :root do + rule %r/[^\S\n]+/, Text + rule %r(//.*?$), Comment::Single + rule %r(/\*.*?\*/)m, Comment::Multiline + # keywords: go before method names to avoid lexing "throw new XYZ" + # as a method signature + rule %r/(?:#{keywords.join('|')})\b/, Keyword + + rule %r( + (\s*(?:[a-zA-Z_][a-zA-Z0-9_.\[\]<>]*\s+)+?) # return arguments + ([a-zA-Z_][a-zA-Z0-9_]*) # method name + (\s*)(\() # signature start + )mx do |m| + # TODO: do this better, this shouldn't need a delegation + delegate Java, m[1] + token Name::Function, m[2] + token Text, m[3] + token Operator, m[4] + end + + rule %r/@#{id}/, Name::Decorator + rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration + rule %r/(?:#{types.join('|')})\b/, Keyword::Type + rule %r/(?:true|false|null)\b/, Keyword::Constant + rule %r/(?:class|interface)\b/, Keyword::Declaration, :class + rule %r/(?:import|package)\b/, Keyword::Namespace, :import + rule %r/"""\s*\n.*?(?\|+=:;,.\/?-]/, Operator + + digit = /[0-9]_+[0-9]|[0-9]/ + bin_digit = /[01]_+[01]|[01]/ + oct_digit = /[0-7]_+[0-7]|[0-7]/ + hex_digit = /[0-9a-f]_+[0-9a-f]|[0-9a-f]/i + rule %r/#{digit}+\.#{digit}+([eE]#{digit}+)?[fd]?/, Num::Float + rule %r/0b#{bin_digit}+/i, Num::Bin + rule %r/0x#{hex_digit}+/i, Num::Hex + rule %r/0#{oct_digit}+/, Num::Oct + rule %r/#{digit}+L?/, Num::Integer + rule %r/\n/, Text + end + + state :class do + rule %r/\s+/m, Text + rule id, Name::Class, :pop! + end + + state :import do + rule %r/\s+/m, Text + rule %r/[a-z0-9_.]+\*?/i, Name::Namespace, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/javascript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/javascript.rb new file mode 100644 index 0000000..ce11ad7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/javascript.rb @@ -0,0 +1,315 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + # IMPORTANT NOTICE: + # + # Please do not copy this lexer and open a pull request + # for a new language. It will not get merged, you will + # be unhappy, and kittens will cry. + # + class Javascript < RegexLexer + title "JavaScript" + desc "JavaScript, the browser scripting language" + + tag 'javascript' + aliases 'js' + filenames '*.cjs', '*.js', '*.mjs' + mimetypes 'application/javascript', 'application/x-javascript', + 'text/javascript', 'text/x-javascript' + + # Pseudo-documentation: https://stackoverflow.com/questions/1661197/what-characters-are-valid-for-javascript-variable-names + + def self.detect?(text) + return 1 if text.shebang?('node') + return 1 if text.shebang?('jsc') + # TODO: rhino, spidermonkey, etc + end + + state :multiline_comment do + rule %r([*]/), Comment::Multiline, :pop! + rule %r([^*/]+), Comment::Multiline + rule %r([*/]), Comment::Multiline + end + + state :comments_and_whitespace do + rule %r/\s+/, Text + rule %r/|<(script|style).*?\2>|<(?!\?(lasso(script)?|=)))+/im) { delegate parent } + end + + state :nosquarebrackets do + rule %r/\[noprocess\]/, Comment::Preproc, :noprocess + rule %r/<\?(lasso(script)?|=)/i, Comment::Preproc, :anglebrackets + rule(/([^\[<]||<(script|style).*?\2>|<(?!\?(lasso(script)?|=))|\[(?!noprocess))+/im) { delegate parent } + end + + state :noprocess do + rule %r(\[/noprocess\]), Comment::Preproc, :pop! + rule(%r(([^\[]|\[(?!/noprocess))+)i) { delegate parent } + end + + state :squarebrackets do + rule %r/\]/, Comment::Preproc, :pop! + mixin :lasso + end + + state :anglebrackets do + rule %r/\?>/, Comment::Preproc, :pop! + mixin :lasso + end + + state :lassofile do + rule %r/\]|\?>/, Comment::Preproc, :pop! + mixin :lasso + end + + state :whitespacecomments do + rule %r/\s+/, Text + rule %r(//.*?\n), Comment::Single + rule %r(/\*\*!.*?\*/)m, Comment::Doc + rule %r(/\*.*?\*/)m, Comment::Multiline + end + + state :lasso do + mixin :whitespacecomments + + # literals + rule %r/\d*\.\d+(e[+-]?\d+)?/i, Num::Float + rule %r/0x[\da-f]+/i, Num::Hex + rule %r/\d+/, Num::Integer + rule %r/(infinity|NaN)\b/i, Num + rule %r/'[^'\\]*(\\.[^'\\]*)*'/m, Str::Single + rule %r/"[^"\\]*(\\.[^"\\]*)*"/m, Str::Double + rule %r/`[^`]*`/m, Str::Backtick + + # names + rule %r/\$#{id}/, Name::Variable + rule %r/#(#{id}|\d+\b)/, Name::Variable::Instance + rule %r/(\.\s*)('#{id}')/ do + groups Name::Builtin::Pseudo, Name::Variable::Class + end + rule %r/(self)(\s*->\s*)('#{id}')/i do + groups Name::Builtin::Pseudo, Operator, Name::Variable::Class + end + rule %r/(\.\.?\s*)(#{id}(=(?!=))?)/ do + groups Name::Builtin::Pseudo, Name::Other + end + rule %r/(->\\?\s*|&\s*)(#{id}(=(?!=))?)/ do + groups Operator, Name::Other + end + rule %r/(?)(self|inherited|currentcapture|givenblock)\b/i, Name::Builtin::Pseudo + rule %r/-(?!infinity)#{id}/i, Name::Attribute + rule %r/::\s*#{id}/, Name::Label + + # definitions + rule %r/(define)(\s+)(#{id})(\s*=>\s*)(type|trait|thread)\b/i do + groups Keyword::Declaration, Text, Name::Class, Operator, Keyword + end + rule %r((define)(\s+)(#{id})(\s*->\s*)(#{id}=?|[-+*/%]))i do + groups Keyword::Declaration, Text, Name::Class, Operator, Name::Function + push :signature + end + rule %r/(define)(\s+)(#{id})/i do + groups Keyword::Declaration, Text, Name::Function + push :signature + end + rule %r((public|protected|private|provide)(\s+)((#{id}=?|[-+*/%])(?=\s*\()))i do + groups Keyword, Text, Name::Function + push :signature + end + rule %r/(public|protected|private|provide)(\s+)(#{id})/i do + groups Keyword, Text, Name::Function + end + + # keywords + rule %r/(true|false|none|minimal|full|all|void)\b/i, Keyword::Constant + rule %r/(local|var|variable|global|data(?=\s))\b/i, Keyword::Declaration + rule %r/(#{id})(\s+)(in)\b/i do + groups Name, Text, Keyword + end + rule %r/(let|into)(\s+)(#{id})/i do + groups Keyword, Text, Name + end + + # other + rule %r/,/, Punctuation, :commamember + rule %r/(and|or|not)\b/i, Operator::Word + rule %r/(#{id})(\s*::\s*#{id})?(\s*=(?!=|>))/ do + groups Name, Name::Label, Operator + end + + rule %r((/?)([\w.]+)) do |m| + name = m[2].downcase + + if m[1] != '' + token Punctuation, m[1] + end + + if name == 'namespace_using' + token Keyword::Namespace, m[2] + elsif self.class.keywords[:exceptions].include? name + token Name::Exception, m[2] + elsif self.class.keywords[:types].include? name + token Keyword::Type, m[2] + elsif self.class.keywords[:traits].include? name + token Name::Decorator, m[2] + elsif self.class.keywords[:keywords].include? name + token Keyword, m[2] + elsif self.class.keywords[:builtins].include? name + token Name::Builtin, m[2] + else + token Name::Other, m[2] + end + end + + rule %r/(=)(n?bw|n?ew|n?cn|lte?|gte?|n?eq|n?rx|ft)\b/i do + groups Operator, Operator::Word + end + rule %r(:=|[-+*/%=<>&|!?\\]+), Operator + rule %r/[{}():;,@^]/, Punctuation + end + + state :signature do + rule %r/\=>/, Operator, :pop! + rule %r/\)/, Punctuation, :pop! + rule %r/[(,]/, Punctuation, :parameter + mixin :lasso + end + + state :parameter do + rule %r/\)/, Punctuation, :pop! + rule %r/-?#{id}/, Name::Attribute, :pop! + rule %r/\.\.\./, Name::Builtin::Pseudo + mixin :lasso + end + + state :commamember do + rule %r((#{id}=?|[-+*/%])(?=\s*(\(([^()]*\([^()]*\))*[^\)]*\)\s*)?(::[\w.\s]+)?=>)), Name::Function, :signature + mixin :whitespacecomments + rule %r//, Text, :pop! + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lasso/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lasso/keywords.rb new file mode 100644 index 0000000..f5c4eea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lasso/keywords.rb @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# DO NOT EDIT +# This file is automatically generated by `rake builtins:lasso`. +# See tasks/builtins/lasso.rake for more info. + +module Rouge + module Lexers + def Lasso.keywords + @keywords ||= {}.tap do |h| + h[:types] = Set.new ["array", "date", "decimal", "duration", "integer", "map", "pair", "string", "tag", "xml", "null", "boolean", "bytes", "keyword", "list", "locale", "queue", "set", "stack", "staticarray", "atbegin", "bson_iter", "bson", "bytes_document_body", "cache_server_element", "cache_server", "capture", "client_address", "client_ip", "component_container", "component_render_state", "component", "curl", "curltoken", "currency", "custom", "data_document", "database_registry", "dateandtime", "dbgp_packet", "dbgp_server", "debugging_stack", "delve", "dir", "dirdesc", "dns_response", "document_base", "document_body", "document_header", "dsinfo", "eacher", "email_compose", "email_parse", "email_pop", "email_queue_impl_base", "email_queue_impl", "email_smtp", "email_stage_impl_base", "email_stage_impl", "fastcgi_each_fcgi_param", "fastcgi_server", "fcgi_record", "fcgi_request", "file", "filedesc", "filemaker_datasource", "generateforeachkeyed", "generateforeachunkeyed", "generateseries", "hash_map", "html_atomic_element", "html_attr", "html_base", "html_binary", "html_br", "html_cdata", "html_container_element", "html_div", "html_document_body", "html_document_head", "html_eol", "html_fieldset", "html_form", "html_h1", "html_h2", "html_h3", "html_h4", "html_h5", "html_h6", "html_hr", "html_img", "html_input", "html_json", "html_label", "html_legend", "html_link", "html_meta", "html_object", "html_option", "html_raw", "html_script", "html_select", "html_span", "html_style", "html_table", "html_td", "html_text", "html_th", "html_tr", "http_document_header", "http_document", "http_error", "http_header_field", "http_server_connection_handler_globals", "http_server_connection_handler", "http_server_request_logger_thread", "http_server_web_connection", "http_server", "image", "include_cache", "inline_type", "java_jnienv", "jbyte", "jbytearray", "jchar", "jchararray", "jfieldid", "jfloat", "jint", "jmethodid", "jobject", "jshort", "json_decode", "json_encode", "json_literal", "json_object", "lassoapp_compiledsrc_appsource", "lassoapp_compiledsrc_fileresource", "lassoapp_content_rep_halt", "lassoapp_dirsrc_appsource", "lassoapp_dirsrc_fileresource", "lassoapp_installer", "lassoapp_livesrc_appsource", "lassoapp_livesrc_fileresource", "lassoapp_long_expiring_bytes", "lassoapp_manualsrc_appsource", "lassoapp_zip_file_server", "lassoapp_zipsrc_appsource", "lassoapp_zipsrc_fileresource", "ldap", "library_thread_loader", "list_node", "log_impl_base", "log_impl", "magick_image", "map_node", "memberstream", "memory_session_driver_impl_entry", "memory_session_driver_impl", "memory_session_driver", "mime_reader", "mongo_client", "mongo_collection", "mongo_cursor", "mustache_ctx", "mysql_session_driver_impl", "mysql_session_driver", "net_named_pipe", "net_tcp_ssl", "net_tcp", "net_udp_packet", "net_udp", "odbc_session_driver_impl", "odbc_session_driver", "opaque", "os_process", "pair_compare", "pairup", "pdf_barcode", "pdf_chunk", "pdf_color", "pdf_doc", "pdf_font", "pdf_hyphenator", "pdf_image", "pdf_list", "pdf_paragraph", "pdf_phrase", "pdf_read", "pdf_table", "pdf_text", "pdf_typebase", "percent", "portal_impl", "queriable_groupby", "queriable_grouping", "queriable_groupjoin", "queriable_join", "queriable_orderby", "queriable_orderbydescending", "queriable_select", "queriable_selectmany", "queriable_skip", "queriable_take", "queriable_thenby", "queriable_thenbydescending", "queriable_where", "raw_document_body", "regexp", "repeat", "scientific", "security_registry", "serialization_element", "serialization_object_identity_compare", "serialization_reader", "serialization_writer_ref", "serialization_writer_standin", "serialization_writer", "session_delete_expired_thread", "signature", "sourcefile", "sqlite_column", "sqlite_currentrow", "sqlite_db", "sqlite_results", "sqlite_session_driver_impl_entry", "sqlite_session_driver_impl", "sqlite_session_driver", "sqlite_table", "sqlite3_stmt", "sqlite3", "sys_process", "text_document", "tie", "timeonly", "tree_base", "tree_node", "tree_nullnode", "ucal", "usgcpu", "usgvm", "web_error_atend", "web_node_base", "web_node_content_representation_css_specialized", "web_node_content_representation_html_specialized", "web_node_content_representation_js_specialized", "web_node_content_representation_xhr_container", "web_node_echo", "web_node_root", "web_request_impl", "web_request", "web_response_impl", "web_response", "web_router", "websocket_handler", "worker_pool", "xml_attr", "xml_cdatasection", "xml_characterdata", "xml_comment", "xml_document", "xml_documentfragment", "xml_documenttype", "xml_domimplementation", "xml_element", "xml_entity", "xml_entityreference", "xml_namednodemap_attr", "xml_namednodemap_ht", "xml_namednodemap", "xml_node", "xml_nodelist", "xml_notation", "xml_processinginstruction", "xml_text", "xmlstream", "zip_file_impl", "zip_file", "zip_impl", "zip"] + h[:traits] = Set.new ["any", "formattingbase", "html_attributed", "html_element_coreattrs", "html_element_eventsattrs", "html_element_i18nattrs", "lassoapp_capabilities", "lassoapp_resource", "lassoapp_source", "queriable_asstring", "session_driver", "trait_array", "trait_asstring", "trait_backcontractible", "trait_backended", "trait_backexpandable", "trait_close", "trait_contractible", "trait_decompose_assignment", "trait_doubleended", "trait_each_sub", "trait_encodeurl", "trait_endedfullymutable", "trait_expandable", "trait_file", "trait_finite", "trait_finiteforeach", "trait_foreach", "trait_foreachtextelement", "trait_frontcontractible", "trait_frontended", "trait_frontexpandable", "trait_fullymutable", "trait_generator", "trait_generatorcentric", "trait_hashable", "trait_json_serialize", "trait_keyed", "trait_keyedfinite", "trait_keyedforeach", "trait_keyedmutable", "trait_list", "trait_map", "trait_net", "trait_pathcomponents", "trait_positionallykeyed", "trait_positionallysearchable", "trait_queriable", "trait_queriablelambda", "trait_readbytes", "trait_readstring", "trait_scalar", "trait_searchable", "trait_serializable", "trait_setencoding", "trait_setoperations", "trait_stack", "trait_treenode", "trait_writebytes", "trait_writestring", "trait_xml_elementcompat", "trait_xml_nodecompat", "web_connection", "web_node_container", "web_node_content_css_specialized", "web_node_content_document", "web_node_content_html_specialized", "web_node_content_js_specialized", "web_node_content_json_specialized", "web_node_content_representation", "web_node_content", "web_node_postable", "web_node"] + h[:builtins] = Set.new ["__char", "__sync_timestamp__", "_admin_addgroup", "_admin_adduser", "_admin_defaultconnector", "_admin_defaultconnectornames", "_admin_defaultdatabase", "_admin_defaultfield", "_admin_defaultgroup", "_admin_defaulthost", "_admin_defaulttable", "_admin_defaultuser", "_admin_deleteconnector", "_admin_deletedatabase", "_admin_deletefield", "_admin_deletegroup", "_admin_deletehost", "_admin_deletetable", "_admin_deleteuser", "_admin_duplicategroup", "_admin_internaldatabase", "_admin_listconnectors", "_admin_listdatabases", "_admin_listfields", "_admin_listgroups", "_admin_listhosts", "_admin_listtables", "_admin_listusers", "_admin_refreshconnector", "_admin_refreshsecurity", "_admin_servicepath", "_admin_updateconnector", "_admin_updatedatabase", "_admin_updatefield", "_admin_updategroup", "_admin_updatehost", "_admin_updatetable", "_admin_updateuser", "_chartfx_activation_string", "_chartfx_getchallengestring", "_chop_args", "_chop_mimes", "_client_addr_old", "_client_address_old", "_client_ip_old", "_database_names", "_datasource_reload", "_date_current", "_date_format", "_date_msec", "_date_parse", "_execution_timelimit", "_file_chmod", "_initialize", "_jdbc_acceptsurl", "_jdbc_debug", "_jdbc_deletehost", "_jdbc_driverclasses", "_jdbc_driverinfo", "_jdbc_metainfo", "_jdbc_propertyinfo", "_jdbc_setdriver", "_lasso_param", "_log_helper", "_proc_noparam", "_proc_withparam", "_recursion_limit", "_request_param", "_security_binaryexpiration", "_security_flushcaches", "_security_isserialized", "_security_serialexpiration", "_srand", "_strict_literals", "_substring", "_xmlrpc_exconverter", "_xmlrpc_inconverter", "_xmlrpc_xmlinconverter", "action_addinfo", "action_addrecord", "action_setfoundcount", "action_setrecordid", "action_settotalcount", "admin_allowedfileroots", "admin_changeuser", "admin_createuser", "admin_groupassignuser", "admin_grouplistusers", "admin_groupremoveuser", "admin_listgroups", "admin_refreshlicensing", "admin_refreshsecurity", "admin_reloaddatasource", "admin_userlistgroups", "array_iterator", "auth_auth", "auth", "base64", "bean", "bigint", "cache_delete", "cache_empty", "cache_exists", "cache_fetch", "cache_internal", "cache_maintenance", "cache_object", "cache_preferences", "cache_store", "chartfx_records", "chartfx_serve", "chartfx", "choice_list", "choice_listitem", "choicelistitem", "click_text", "client_ipfrominteger", "compare_beginswith", "compare_contains", "compare_endswith", "compare_equalto", "compare_greaterthan", "compare_greaterthanorequals", "compare_greaterthanorequls", "compare_lessthan", "compare_lessthanorequals", "compare_notbeginswith", "compare_notcontains", "compare_notendswith", "compare_notequalto", "compare_notregexp", "compare_regexp", "compare_strictequalto", "compare_strictnotequalto", "compiler_removecacheddoc", "compiler_setdefaultparserflags", "curl_ftp_getfile", "curl_ftp_getlisting", "curl_ftp_putfile", "curl_include_url", "database_changecolumn", "database_changefield", "database_createcolumn", "database_createfield", "database_createtable", "database_fmcontainer", "database_hostinfo", "database_inline", "database_nameitem", "database_realname", "database_removecolumn", "database_removefield", "database_removetable", "database_repeating_valueitem", "database_repeating", "database_repeatingvalueitem", "database_schemanameitem", "database_tablecolumn", "database_tablenameitem", "datasource_name", "datasource_register", "date__date_current", "date__date_format", "date__date_msec", "date__date_parse", "date_add", "date_date", "date_difference", "date_duration", "date_format", "date_getcurrentdate", "date_getday", "date_getdayofweek", "date_gethour", "date_getlocaltimezone", "date_getminute", "date_getmonth", "date_getsecond", "date_gettime", "date_getyear", "date_gmttolocal", "date_localtogmt", "date_maximum", "date_minimum", "date_msec", "date_setformat", "date_subtract", "db_layoutnameitem", "db_layoutnames", "db_nameitem", "db_names", "db_tablenameitem", "db_tablenames", "dbi_column_names", "dbi_field_names", "decimal_setglobaldefaultprecision", "decode_base64", "decode_bheader", "decode_hex", "decode_html", "decode_json", "decode_qheader", "decode_quotedprintable", "decode_quotedprintablebytes", "decode_url", "decode_xml", "decrypt_blowfish2", "default", "define_constant", "define_prototype", "define_tagp", "define_typep", "deserialize", "directory_directorynameitem", "directory_lister", "directory_nameitem", "directorynameitem", "email_mxerror", "encode_base64", "encode_bheader", "encode_break", "encode_breaks", "encode_crc32", "encode_hex", "encode_html", "encode_htmltoxml", "encode_json", "encode_quotedprintable", "encode_quotedprintablebytes", "encode_smart", "encode_sql", "encode_sql92", "encode_stricturl", "encode_url", "encode_xml", "encrypt_blowfish2", "error_currenterror", "error_norecordsfound", "error_seterrorcode", "error_seterrormessage", "euro", "event_schedule", "file_autoresolvefullpaths", "file_chmod", "file_control", "file_copy", "file_create", "file_creationdate", "file_currenterror", "file_delete", "file_exists", "file_getlinecount", "file_getsize", "file_isdirectory", "file_listdirectory", "file_moddate", "file_move", "file_openread", "file_openreadwrite", "file_openwrite", "file_openwriteappend", "file_openwritetruncate", "file_probeeol", "file_processuploads", "file_read", "file_readline", "file_rename", "file_serve", "file_setsize", "file_stream", "file_streamcopy", "file_uploads", "file_waitread", "file_waittimeout", "file_waitwrite", "file_write", "find_soap_ops", "form_param", "global_defined", "global_remove", "global_reset", "globals", "http_getfile", "ical_alarm", "ical_attribute", "ical_calendar", "ical_daylight", "ical_event", "ical_freebusy", "ical_item", "ical_journal", "ical_parse", "ical_standard", "ical_timezone", "ical_todo", "image_url", "img", "include_cgi", "iterator", "java_bean", "java", "json_records", "lasso_comment", "lasso_datasourceis", "lasso_datasourceis4d", "lasso_datasourceisfilemaker", "lasso_datasourceisfilemaker7", "lasso_datasourceisfilemaker9", "lasso_datasourceisfilemakersa", "lasso_datasourceisjdbc", "lasso_datasourceislassomysql", "lasso_datasourceismysql", "lasso_datasourceisodbc", "lasso_datasourceisopenbase", "lasso_datasourceisoracle", "lasso_datasourceispostgresql", "lasso_datasourceisspotlight", "lasso_datasourceissqlite", "lasso_datasourceissqlserver", "lasso_datasourcemodulename", "lasso_datatype", "lasso_disableondemand", "lasso_parser", "lasso_process", "lasso_sessionid", "lasso_siteid", "lasso_siteisrunning", "lasso_sitename", "lasso_siterestart", "lasso_sitestart", "lasso_sitestop", "lasso_tagmodulename", "lasso_updatecheck", "lasso_uptime", "lassoapp_create", "lassoapp_dump", "lassoapp_flattendir", "lassoapp_getappdata", "lassoapp_list", "lassoapp_process", "lassoapp_unitize", "ldml_ldml", "ldml", "link_currentactionparams", "link_currentactionurl", "link_currentgroupparams", "link_currentgroupurl", "link_currentrecordparams", "link_currentrecordurl", "link_currentsearch", "link_currentsearchparams", "link_currentsearchurl", "link_detailparams", "link_detailurl", "link_firstgroupparams", "link_firstgroupurl", "link_firstrecordparams", "link_firstrecordurl", "link_lastgroupparams", "link_lastgroupurl", "link_lastrecordparams", "link_lastrecordurl", "link_nextgroupparams", "link_nextgroupurl", "link_nextrecordparams", "link_nextrecordurl", "link_params", "link_prevgroupparams", "link_prevgroupurl", "link_prevrecordparams", "link_prevrecordurl", "link_setformat", "link_url", "list_additem", "list_fromlist", "list_fromstring", "list_getitem", "list_itemcount", "list_iterator", "list_removeitem", "list_replaceitem", "list_reverseiterator", "list_tostring", "literal", "ljax_end", "ljax_hastarget", "ljax_include", "ljax_start", "local_defined", "local_remove", "local_reset", "locals", "logicalop_value", "logicaloperator_value", "map_iterator", "match_comparator", "match_notrange", "match_notregexp", "match_range", "match_regexp", "math_abs", "math_acos", "math_add", "math_asin", "math_atan", "math_atan2", "math_ceil", "math_converteuro", "math_cos", "math_div", "math_exp", "math_floor", "math_internal_rand", "math_internal_randmax", "math_internal_srand", "math_ln", "math_log", "math_log10", "math_max", "math_min", "math_mod", "math_mult", "math_pow", "math_random", "math_range", "math_rint", "math_roman", "math_round", "math_sin", "math_sqrt", "math_sub", "math_tan", "mime_type", "misc__srand", "misc_randomnumber", "misc_roman", "misc_valid_creditcard", "named_param", "namespace_current", "namespace_delimiter", "namespace_exists", "namespace_file_fullpathexists", "namespace_load", "namespace_page", "namespace_unload", "net", "no_default_output", "object", "once", "oneoff", "op_logicalvalue", "operator_logicalvalue", "option", "postcondition", "precondition", "prettyprintingnsmap", "prettyprintingtypemap", "priorityqueue", "proc_convert", "proc_convertbody", "proc_convertone", "proc_extract", "proc_extractone", "proc_find", "proc_first", "proc_foreach", "proc_get", "proc_join", "proc_lasso", "proc_last", "proc_map_entry", "proc_null", "proc_regexp", "proc_xml", "proc_xslt", "rand", "randomnumber", "raw", "recid_value", "record_count", "recordcount", "recordid_value", "reference", "repeating_valueitem", "repeatingvalueitem", "repetition", "req_column", "req_field", "required_column", "required_field", "response_fileexists", "reverseiterator", "roman", "row_count", "search_columnitem", "search_fielditem", "search_operatoritem", "search_opitem", "search_valueitem", "searchfielditem", "searchoperatoritem", "searchopitem", "searchvalueitem", "serialize", "server_date", "server_day", "server_siteisrunning", "server_sitestart", "server_sitestop", "server_time", "session_addoutputfilter", "session_addvariable", "session_removevariable", "session_setdriver", "set_iterator", "set_reverseiterator", "site_atbegin", "site_restart", "soap_convertpartstopairs", "soap_info", "soap_stub", "sort_columnitem", "sort_fielditem", "sort_orderitem", "sortcolumnitem", "sortfielditem", "sortorderitem", "srand", "stock_quote", "string_charfromname", "string_concatenate", "string_countfields", "string_endswith", "string_extract", "string_findposition", "string_findregexp", "string_fordigit", "string_getfield", "string_getunicodeversion", "string_insert", "string_isalpha", "string_isalphanumeric", "string_isdigit", "string_ishexdigit", "string_islower", "string_isnumeric", "string_ispunctuation", "string_isspace", "string_isupper", "string_length", "string_lowercase", "string_remove", "string_removeleading", "string_removetrailing", "string_replace", "string_replaceregexp", "string_todecimal", "string_tointeger", "string_uppercase", "table_realname", "tags_find", "tags_list", "tags", "tcp_close", "tcp_open", "tcp_send", "tcp_tcp_close", "tcp_tcp_open", "tcp_tcp_send", "thread_abort", "thread_event", "thread_exists", "thread_getcurrentid", "thread_getpriority", "thread_info", "thread_list", "thread_lock", "thread_pipe", "thread_priority_default", "thread_priority_high", "thread_priority_low", "thread_rwlock", "thread_semaphore", "thread_setpriority", "total_records", "treemap_iterator", "url_rewrite", "valid_creditcard", "valid_date", "valid_email", "valid_url", "var_defined", "var_remove", "var_reset", "var_set", "variable_defined", "variable_set", "variables", "variant_count", "vars", "wsdl_extract", "wsdl_getbinding", "wsdl_getbindingforoperation", "wsdl_getbindingoperations", "wsdl_getmessagenamed", "wsdl_getmessageparts", "wsdl_getmessagetriofromporttype", "wsdl_getopbodystyle", "wsdl_getopbodyuse", "wsdl_getoperation", "wsdl_getoplocation", "wsdl_getopmessagetypes", "wsdl_getopsoapaction", "wsdl_getportaddress", "wsdl_getportsforservice", "wsdl_getporttype", "wsdl_getporttypeoperation", "wsdl_getservicedocumentation", "wsdl_getservices", "wsdl_gettargetnamespace", "wsdl_issoapoperation", "wsdl_listoperations", "wsdl_maketest", "xml_extract", "xml_rpc", "xml_rpccall", "xml_rw", "xml_serve", "xml_xml", "xml_xmlstream", "xsd_attribute", "xsd_blankarraybase", "xsd_blankbase", "xsd_buildtype", "xsd_cache", "xsd_checkcardinality", "xsd_continueall", "xsd_continueannotation", "xsd_continueany", "xsd_continueanyattribute", "xsd_continueattribute", "xsd_continueattributegroup", "xsd_continuechoice", "xsd_continuecomplexcontent", "xsd_continuecomplextype", "xsd_continuedocumentation", "xsd_continueextension", "xsd_continuegroup", "xsd_continuekey", "xsd_continuelist", "xsd_continuerestriction", "xsd_continuesequence", "xsd_continuesimplecontent", "xsd_continuesimpletype", "xsd_continueunion", "xsd_deserialize", "xsd_fullyqualifyname", "xsd_generate", "xsd_generateblankfromtype", "xsd_generateblanksimpletype", "xsd_generatetype", "xsd_getschematype", "xsd_issimpletype", "xsd_loadschema", "xsd_lookupnamespaceuri", "xsd_lookuptype", "xsd_processany", "xsd_processattribute", "xsd_processattributegroup", "xsd_processcomplextype", "xsd_processelement", "xsd_processgroup", "xsd_processimport", "xsd_processinclude", "xsd_processschema", "xsd_processsimpletype", "xsd_ref", "xsd_type", "_ffi", "abort_clear", "abort_now", "action_param", "action_params", "action_statement", "admin_authorization", "admin_currentgroups", "admin_currentuserid", "admin_currentusername", "admin_getpref", "admin_initialize", "admin_lassoservicepath", "admin_removepref", "admin_setpref", "admin_userexists", "auth_admin", "auth_check", "auth_custom", "auth_group", "auth_prompt", "auth_user", "bom_utf16be", "bom_utf16le", "bom_utf32be", "bom_utf32le", "bom_utf8", "capture_nearestloopabort", "capture_nearestloopcontinue", "capture_nearestloopcount", "checked", "cipher_decrypt_private", "cipher_decrypt_public", "cipher_decrypt", "cipher_digest", "cipher_encrypt_private", "cipher_encrypt_public", "cipher_encrypt", "cipher_generate_key", "cipher_hmac", "cipher_keylength", "cipher_list", "cipher_open", "cipher_seal", "cipher_sign", "cipher_verify", "client_addr", "client_authorization", "client_browser", "client_contentlength", "client_contenttype", "client_cookielist", "client_cookies", "client_encoding", "client_formmethod", "client_getargs", "client_getparam", "client_getparams", "client_headers", "client_integertoip", "client_iptointeger", "client_password", "client_postargs", "client_postparam", "client_postparams", "client_type", "client_url", "client_username", "column_name", "column_names", "column_type", "column", "compress", "content_addheader", "content_body", "content_encoding", "content_header", "content_replaceheader", "content_type", "cookie_set", "cookie", "curl_easy_cleanup", "curl_easy_duphandle", "curl_easy_getinfo", "curl_easy_init", "curl_easy_reset", "curl_easy_setopt", "curl_easy_strerror", "curl_getdate", "curl_http_version_1_0", "curl_http_version_1_1", "curl_http_version_none", "curl_ipresolve_v4", "curl_ipresolve_v6", "curl_ipresolve_whatever", "curl_multi_perform", "curl_multi_result", "curl_netrc_ignored", "curl_netrc_optional", "curl_netrc_required", "curl_sslversion_default", "curl_sslversion_sslv2", "curl_sslversion_sslv3", "curl_sslversion_tlsv1", "curl_version_asynchdns", "curl_version_debug", "curl_version_gssnegotiate", "curl_version_idn", "curl_version_info", "curl_version_ipv6", "curl_version_kerberos4", "curl_version_largefile", "curl_version_libz", "curl_version_ntlm", "curl_version_spnego", "curl_version_ssl", "curl_version", "curlauth_any", "curlauth_anysafe", "curlauth_basic", "curlauth_digest", "curlauth_gssnegotiate", "curlauth_none", "curlauth_ntlm", "curle_aborted_by_callback", "curle_bad_calling_order", "curle_bad_content_encoding", "curle_bad_download_resume", "curle_bad_function_argument", "curle_bad_password_entered", "curle_couldnt_connect", "curle_couldnt_resolve_host", "curle_couldnt_resolve_proxy", "curle_failed_init", "curle_file_couldnt_read_file", "curle_filesize_exceeded", "curle_ftp_access_denied", "curle_ftp_cant_get_host", "curle_ftp_cant_reconnect", "curle_ftp_couldnt_get_size", "curle_ftp_couldnt_retr_file", "curle_ftp_couldnt_set_ascii", "curle_ftp_couldnt_set_binary", "curle_ftp_couldnt_use_rest", "curle_ftp_port_failed", "curle_ftp_quote_error", "curle_ftp_ssl_failed", "curle_ftp_user_password_incorrect", "curle_ftp_weird_227_format", "curle_ftp_weird_pass_reply", "curle_ftp_weird_pasv_reply", "curle_ftp_weird_server_reply", "curle_ftp_weird_user_reply", "curle_ftp_write_error", "curle_function_not_found", "curle_got_nothing", "curle_http_post_error", "curle_http_range_error", "curle_http_returned_error", "curle_interface_failed", "curle_ldap_cannot_bind", "curle_ldap_invalid_url", "curle_ldap_search_failed", "curle_library_not_found", "curle_login_denied", "curle_malformat_user", "curle_obsolete", "curle_ok", "curle_operation_timeouted", "curle_out_of_memory", "curle_partial_file", "curle_read_error", "curle_recv_error", "curle_send_error", "curle_send_fail_rewind", "curle_share_in_use", "curle_ssl_cacert", "curle_ssl_certproblem", "curle_ssl_cipher", "curle_ssl_connect_error", "curle_ssl_engine_initfailed", "curle_ssl_engine_notfound", "curle_ssl_engine_setfailed", "curle_ssl_peer_certificate", "curle_telnet_option_syntax", "curle_too_many_redirects", "curle_unknown_telnet_option", "curle_unsupported_protocol", "curle_url_malformat_user", "curle_url_malformat", "curle_write_error", "curlftpauth_default", "curlftpauth_ssl", "curlftpauth_tls", "curlftpssl_all", "curlftpssl_control", "curlftpssl_last", "curlftpssl_none", "curlftpssl_try", "curlinfo_connect_time", "curlinfo_content_length_download", "curlinfo_content_length_upload", "curlinfo_content_type", "curlinfo_effective_url", "curlinfo_filetime", "curlinfo_header_size", "curlinfo_http_connectcode", "curlinfo_httpauth_avail", "curlinfo_namelookup_time", "curlinfo_num_connects", "curlinfo_os_errno", "curlinfo_pretransfer_time", "curlinfo_proxyauth_avail", "curlinfo_redirect_count", "curlinfo_redirect_time", "curlinfo_request_size", "curlinfo_response_code", "curlinfo_size_download", "curlinfo_size_upload", "curlinfo_speed_download", "curlinfo_speed_upload", "curlinfo_ssl_engines", "curlinfo_ssl_verifyresult", "curlinfo_starttransfer_time", "curlinfo_total_time", "curlmsg_done", "curlopt_autoreferer", "curlopt_buffersize", "curlopt_cainfo", "curlopt_capath", "curlopt_connecttimeout", "curlopt_cookie", "curlopt_cookiefile", "curlopt_cookiejar", "curlopt_cookiesession", "curlopt_crlf", "curlopt_customrequest", "curlopt_dns_use_global_cache", "curlopt_egdsocket", "curlopt_encoding", "curlopt_failonerror", "curlopt_filetime", "curlopt_followlocation", "curlopt_forbid_reuse", "curlopt_fresh_connect", "curlopt_ftp_account", "curlopt_ftp_create_missing_dirs", "curlopt_ftp_response_timeout", "curlopt_ftp_ssl", "curlopt_ftp_use_eprt", "curlopt_ftp_use_epsv", "curlopt_ftpappend", "curlopt_ftplistonly", "curlopt_ftpport", "curlopt_ftpsslauth", "curlopt_header", "curlopt_http_version", "curlopt_http200aliases", "curlopt_httpauth", "curlopt_httpget", "curlopt_httpheader", "curlopt_httppost", "curlopt_httpproxytunnel", "curlopt_infilesize_large", "curlopt_infilesize", "curlopt_interface", "curlopt_ipresolve", "curlopt_krb4level", "curlopt_low_speed_limit", "curlopt_low_speed_time", "curlopt_mail_from", "curlopt_mail_rcpt", "curlopt_maxconnects", "curlopt_maxfilesize_large", "curlopt_maxfilesize", "curlopt_maxredirs", "curlopt_netrc_file", "curlopt_netrc", "curlopt_nobody", "curlopt_noprogress", "curlopt_port", "curlopt_post", "curlopt_postfields", "curlopt_postfieldsize_large", "curlopt_postfieldsize", "curlopt_postquote", "curlopt_prequote", "curlopt_proxy", "curlopt_proxyauth", "curlopt_proxyport", "curlopt_proxytype", "curlopt_proxyuserpwd", "curlopt_put", "curlopt_quote", "curlopt_random_file", "curlopt_range", "curlopt_readdata", "curlopt_referer", "curlopt_resume_from_large", "curlopt_resume_from", "curlopt_ssl_cipher_list", "curlopt_ssl_verifyhost", "curlopt_ssl_verifypeer", "curlopt_sslcert", "curlopt_sslcerttype", "curlopt_sslengine_default", "curlopt_sslengine", "curlopt_sslkey", "curlopt_sslkeypasswd", "curlopt_sslkeytype", "curlopt_sslversion", "curlopt_tcp_nodelay", "curlopt_timecondition", "curlopt_timeout", "curlopt_timevalue", "curlopt_transfertext", "curlopt_unrestricted_auth", "curlopt_upload", "curlopt_url", "curlopt_use_ssl", "curlopt_useragent", "curlopt_userpwd", "curlopt_verbose", "curlopt_writedata", "curlproxy_http", "curlproxy_socks4", "curlproxy_socks5", "database_adddefaultsqlitehost", "database_database", "database_initialize", "database_name", "database_qs", "database_table_database_tables", "database_table_datasource_databases", "database_table_datasource_hosts", "database_table_datasources", "database_table_table_fields", "database_util_cleanpath", "dbgp_stop_stack_name", "debugging_break", "debugging_breakpoint_get", "debugging_breakpoint_list", "debugging_breakpoint_remove", "debugging_breakpoint_set", "debugging_breakpoint_update", "debugging_context_locals", "debugging_context_self", "debugging_context_vars", "debugging_detach", "debugging_enabled", "debugging_get_context", "debugging_get_stack", "debugging_run", "debugging_step_in", "debugging_step_out", "debugging_step_over", "debugging_stop", "debugging_terminate", "decimal_random", "decompress", "decrypt_blowfish", "define_atbegin", "define_atend", "dns_default", "dns_lookup", "document", "email_attachment_mime_type", "email_digestchallenge", "email_digestresponse", "email_extract", "email_findemails", "email_fix_address_list", "email_fix_address", "email_fs_error_clean", "email_immediate", "email_initialize", "email_merge", "email_mxlookup", "email_pop_priv_extract", "email_pop_priv_quote", "email_pop_priv_substring", "email_queue", "email_result", "email_safeemail", "email_send", "email_status", "email_token", "email_translatebreakstocrlf", "encode_qheader", "encoding_iso88591", "encoding_utf8", "encrypt_blowfish", "encrypt_crammd5", "encrypt_hmac", "encrypt_md5", "eol", "error_code", "error_msg", "error_obj", "error_pop", "error_push", "error_reset", "error_stack", "escape_tag", "evdns_resolve_ipv4", "evdns_resolve_ipv6", "evdns_resolve_reverse_ipv6", "evdns_resolve_reverse", "fail_now", "failure_clear", "fastcgi_createfcgirequest", "fastcgi_handlecon", "fastcgi_handlereq", "fastcgi_initialize", "fastcgi_initiate_request", "fcgi_abort_request", "fcgi_authorize", "fcgi_begin_request", "fcgi_bodychunksize", "fcgi_cant_mpx_conn", "fcgi_data", "fcgi_end_request", "fcgi_filter", "fcgi_get_values_result", "fcgi_get_values", "fcgi_keep_conn", "fcgi_makeendrequestbody", "fcgi_makestdoutbody", "fcgi_max_conns", "fcgi_max_reqs", "fcgi_mpxs_conns", "fcgi_null_request_id", "fcgi_overloaded", "fcgi_params", "fcgi_read_timeout_seconds", "fcgi_readparam", "fcgi_request_complete", "fcgi_responder", "fcgi_stderr", "fcgi_stdin", "fcgi_stdout", "fcgi_unknown_role", "fcgi_unknown_type", "fcgi_version_1", "fcgi_x_stdin", "field_name", "field_names", "field", "file_copybuffersize", "file_defaultencoding", "file_forceroot", "file_modechar", "file_modeline", "file_stderr", "file_stdin", "file_stdout", "file_tempfile", "filemakerds_initialize", "filemakerds", "found_count", "ftp_deletefile", "ftp_getdata", "ftp_getfile", "ftp_getlisting", "ftp_putdata", "ftp_putfile", "generateforeach", "hash_primes", "http_char_colon", "http_char_cr", "http_char_htab", "http_char_lf", "http_char_question", "http_char_space", "http_default_files", "http_read_headers", "http_read_timeout_secs", "http_server_apps_path", "http_server_request_logger", "include_cache_compare", "include_currentpath", "include_filepath", "include_localpath", "include_once", "include_path", "include_raw", "include_url", "include", "includes", "inline_colinfo_name_pos", "inline_colinfo_type_pos", "inline_colinfo_valuelist_pos", "inline_columninfo_pos", "inline_foundcount_pos", "inline_namedget", "inline_namedput", "inline_resultrows_pos", "inline_scopeget", "inline_scopepop", "inline_scopepush", "integer_bitor", "integer_random", "io_dir_dt_blk", "io_dir_dt_chr", "io_dir_dt_dir", "io_dir_dt_fifo", "io_dir_dt_lnk", "io_dir_dt_reg", "io_dir_dt_sock", "io_dir_dt_unknown", "io_dir_dt_wht", "io_file_access", "io_file_chdir", "io_file_chmod", "io_file_chown", "io_file_dirname", "io_file_f_dupfd", "io_file_f_getfd", "io_file_f_getfl", "io_file_f_getlk", "io_file_f_rdlck", "io_file_f_setfd", "io_file_f_setfl", "io_file_f_setlk", "io_file_f_setlkw", "io_file_f_test", "io_file_f_tlock", "io_file_f_ulock", "io_file_f_unlck", "io_file_f_wrlck", "io_file_fd_cloexec", "io_file_fioasync", "io_file_fioclex", "io_file_fiodtype", "io_file_fiogetown", "io_file_fionbio", "io_file_fionclex", "io_file_fionread", "io_file_fiosetown", "io_file_getcwd", "io_file_lchown", "io_file_link", "io_file_lockf", "io_file_lstat_atime", "io_file_lstat_mode", "io_file_lstat_mtime", "io_file_lstat_size", "io_file_mkdir", "io_file_mkfifo", "io_file_mkstemp", "io_file_o_append", "io_file_o_async", "io_file_o_creat", "io_file_o_excl", "io_file_o_exlock", "io_file_o_fsync", "io_file_o_nofollow", "io_file_o_nonblock", "io_file_o_rdonly", "io_file_o_rdwr", "io_file_o_shlock", "io_file_o_sync", "io_file_o_trunc", "io_file_o_wronly", "io_file_pipe", "io_file_readlink", "io_file_realpath", "io_file_remove", "io_file_rename", "io_file_rmdir", "io_file_s_ifblk", "io_file_s_ifchr", "io_file_s_ifdir", "io_file_s_ififo", "io_file_s_iflnk", "io_file_s_ifmt", "io_file_s_ifreg", "io_file_s_ifsock", "io_file_s_irgrp", "io_file_s_iroth", "io_file_s_irusr", "io_file_s_irwxg", "io_file_s_irwxo", "io_file_s_irwxu", "io_file_s_isgid", "io_file_s_isuid", "io_file_s_isvtx", "io_file_s_iwgrp", "io_file_s_iwoth", "io_file_s_iwusr", "io_file_s_ixgrp", "io_file_s_ixoth", "io_file_s_ixusr", "io_file_seek_cur", "io_file_seek_end", "io_file_seek_set", "io_file_stat_atime", "io_file_stat_mode", "io_file_stat_mtime", "io_file_stat_size", "io_file_stderr", "io_file_stdin", "io_file_stdout", "io_file_symlink", "io_file_tempnam", "io_file_truncate", "io_file_umask", "io_file_unlink", "io_net_accept", "io_net_af_inet", "io_net_af_inet6", "io_net_af_unix", "io_net_bind", "io_net_connect", "io_net_getpeername", "io_net_getsockname", "io_net_ipproto_ip", "io_net_ipproto_udp", "io_net_listen", "io_net_msg_oob", "io_net_msg_peek", "io_net_msg_waitall", "io_net_recv", "io_net_recvfrom", "io_net_send", "io_net_sendto", "io_net_shut_rd", "io_net_shut_rdwr", "io_net_shut_wr", "io_net_shutdown", "io_net_so_acceptconn", "io_net_so_broadcast", "io_net_so_debug", "io_net_so_dontroute", "io_net_so_error", "io_net_so_keepalive", "io_net_so_linger", "io_net_so_oobinline", "io_net_so_rcvbuf", "io_net_so_rcvlowat", "io_net_so_rcvtimeo", "io_net_so_reuseaddr", "io_net_so_sndbuf", "io_net_so_sndlowat", "io_net_so_sndtimeo", "io_net_so_timestamp", "io_net_so_type", "io_net_so_useloopback", "io_net_sock_dgram", "io_net_sock_raw", "io_net_sock_rdm", "io_net_sock_seqpacket", "io_net_sock_stream", "io_net_socket", "io_net_sol_socket", "io_net_ssl_accept", "io_net_ssl_begin", "io_net_ssl_connect", "io_net_ssl_end", "io_net_ssl_error", "io_net_ssl_errorstring", "io_net_ssl_funcerrorstring", "io_net_ssl_liberrorstring", "io_net_ssl_read", "io_net_ssl_reasonerrorstring", "io_net_ssl_setacceptstate", "io_net_ssl_setconnectstate", "io_net_ssl_setverifylocations", "io_net_ssl_shutdown", "io_net_ssl_usecertificatechainfile", "io_net_ssl_useprivatekeyfile", "io_net_ssl_write", "java_jvm_create", "java_jvm_getenv", "jdbc_initialize", "json_back_slash", "json_back_space", "json_close_array", "json_close_object", "json_colon", "json_comma", "json_consume_array", "json_consume_object", "json_consume_string", "json_consume_token", "json_cr", "json_debug", "json_deserialize", "json_e_lower", "json_e_upper", "json_f_lower", "json_form_feed", "json_forward_slash", "json_lf", "json_n_lower", "json_negative", "json_open_array", "json_open_object", "json_period", "json_positive", "json_quote_double", "json_rpccall", "json_serialize", "json_t_lower", "json_tab", "json_white_space", "keycolumn_name", "keycolumn_value", "keyfield_name", "keyfield_value", "lasso_currentaction", "lasso_errorreporting", "lasso_executiontimelimit", "lasso_methodexists", "lasso_tagexists", "lasso_uniqueid", "lasso_version", "lassoapp_current_app", "lassoapp_current_include", "lassoapp_do_with_include", "lassoapp_exists", "lassoapp_find_missing_file", "lassoapp_format_mod_date", "lassoapp_get_capabilities_name", "lassoapp_include_current", "lassoapp_include", "lassoapp_initialize_db", "lassoapp_initialize", "lassoapp_invoke_resource", "lassoapp_issourcefileextension", "lassoapp_link", "lassoapp_load_module", "lassoapp_mime_get", "lassoapp_mime_type_appcache", "lassoapp_mime_type_css", "lassoapp_mime_type_csv", "lassoapp_mime_type_doc", "lassoapp_mime_type_docx", "lassoapp_mime_type_eof", "lassoapp_mime_type_eot", "lassoapp_mime_type_gif", "lassoapp_mime_type_html", "lassoapp_mime_type_ico", "lassoapp_mime_type_jpg", "lassoapp_mime_type_js", "lassoapp_mime_type_lasso", "lassoapp_mime_type_map", "lassoapp_mime_type_pdf", "lassoapp_mime_type_png", "lassoapp_mime_type_ppt", "lassoapp_mime_type_rss", "lassoapp_mime_type_svg", "lassoapp_mime_type_swf", "lassoapp_mime_type_tif", "lassoapp_mime_type_ttf", "lassoapp_mime_type_txt", "lassoapp_mime_type_woff", "lassoapp_mime_type_xaml", "lassoapp_mime_type_xap", "lassoapp_mime_type_xbap", "lassoapp_mime_type_xhr", "lassoapp_mime_type_xml", "lassoapp_mime_type_zip", "lassoapp_path_to_method_name", "lassoapp_settingsdb", "layout_name", "lcapi_datasourceadd", "lcapi_datasourcecloseconnection", "lcapi_datasourcedelete", "lcapi_datasourceduplicate", "lcapi_datasourceexecsql", "lcapi_datasourcefindall", "lcapi_datasourceimage", "lcapi_datasourceinfo", "lcapi_datasourceinit", "lcapi_datasourcematchesname", "lcapi_datasourcenames", "lcapi_datasourcenothing", "lcapi_datasourceopand", "lcapi_datasourceopany", "lcapi_datasourceopbw", "lcapi_datasourceopct", "lcapi_datasourceopeq", "lcapi_datasourceopew", "lcapi_datasourceopft", "lcapi_datasourceopgt", "lcapi_datasourceopgteq", "lcapi_datasourceopin", "lcapi_datasourceoplt", "lcapi_datasourceoplteq", "lcapi_datasourceopnbw", "lcapi_datasourceopnct", "lcapi_datasourceopneq", "lcapi_datasourceopnew", "lcapi_datasourceopnin", "lcapi_datasourceopno", "lcapi_datasourceopnot", "lcapi_datasourceopnrx", "lcapi_datasourceopor", "lcapi_datasourceoprx", "lcapi_datasourcepreparesql", "lcapi_datasourceprotectionnone", "lcapi_datasourceprotectionreadonly", "lcapi_datasourcerandom", "lcapi_datasourceschemanames", "lcapi_datasourcescripts", "lcapi_datasourcesearch", "lcapi_datasourcesortascending", "lcapi_datasourcesortcustom", "lcapi_datasourcesortdescending", "lcapi_datasourcetablenames", "lcapi_datasourceterm", "lcapi_datasourcetickle", "lcapi_datasourcetypeblob", "lcapi_datasourcetypeboolean", "lcapi_datasourcetypedate", "lcapi_datasourcetypedecimal", "lcapi_datasourcetypeinteger", "lcapi_datasourcetypestring", "lcapi_datasourceunpreparesql", "lcapi_datasourceupdate", "lcapi_fourchartointeger", "lcapi_listdatasources", "lcapi_loadmodule", "lcapi_loadmodules", "lcapi_updatedatasourceslist", "ldap_scope_base", "ldap_scope_children", "ldap_scope_onelevel", "ldap_scope_subtree", "library_once", "library", "ljapi_initialize", "locale_availablelocales", "locale_canada", "locale_canadafrench", "locale_china", "locale_chinese", "locale_default", "locale_english", "locale_format_style_date_time", "locale_format_style_default", "locale_format_style_full", "locale_format_style_long", "locale_format_style_medium", "locale_format_style_none", "locale_format_style_short", "locale_format", "locale_france", "locale_french", "locale_german", "locale_germany", "locale_isocountries", "locale_isolanguages", "locale_italian", "locale_italy", "locale_japan", "locale_japanese", "locale_korea", "locale_korean", "locale_prc", "locale_setdefault", "locale_simplifiedchinese", "locale_taiwan", "locale_traditionalchinese", "locale_uk", "locale_us", "log_always", "log_critical", "log_deprecated", "log_destination_console", "log_destination_database", "log_destination_file", "log_detail", "log_initialize", "log_level_critical", "log_level_deprecated", "log_level_detail", "log_level_sql", "log_level_warning", "log_max_file_size", "log_setdestination", "log_sql", "log_trim_file_size", "log_warning", "loop_key_pop", "loop_key_push", "loop_key", "loop_pop", "loop_push", "loop_value_pop", "loop_value_push", "loop_value", "main_thread_only", "maxrecords_value", "median", "method_name", "micros", "millis", "mongo_insert_continue_on_error", "mongo_insert_no_validate", "mongo_insert_none", "mongo_query_await_data", "mongo_query_exhaust", "mongo_query_no_cursor_timeout", "mongo_query_none", "mongo_query_oplog_replay", "mongo_query_partial", "mongo_query_slave_ok", "mongo_query_tailable_cursor", "mongo_remove_none", "mongo_remove_single_remove", "mongo_update_multi_update", "mongo_update_no_validate", "mongo_update_none", "mongo_update_upsert", "mustache_compile_file", "mustache_compile_string", "mustache_include", "mysqlds", "namespace_global", "namespace_import", "net_connectinprogress", "net_connectok", "net_typessl", "net_typessltcp", "net_typessludp", "net_typetcp", "net_typeudp", "net_waitread", "net_waittimeout", "net_waitwrite", "nslookup", "odbc_session_driver_mssql", "odbc", "output", "pdf_package", "pdf_rectangle", "pdf_serve", "pi", "postgresql", "process", "protect_now", "queriable_average", "queriable_defaultcompare", "queriable_do", "queriable_internal_combinebindings", "queriable_max", "queriable_min", "queriable_qsort", "queriable_reversecompare", "queriable_sum", "random_seed", "range", "records_array", "records_map", "redirect_url", "referer_url", "referrer_url", "register_thread", "register", "response_filepath", "response_localpath", "response_path", "response_realm", "response_root", "resultset_count", "resultsets", "rows_array", "rows_impl", "schema_name", "security_database", "security_default_realm", "security_initialize", "security_table_groups", "security_table_ug_map", "security_table_users", "selected", "series", "server_admin", "server_ip", "server_name", "server_port", "server_protocol", "server_push", "server_signature", "server_software", "session_abort", "session_addvar", "session_decorate", "session_deleteexpired", "session_end", "session_getdefaultdriver", "session_id", "session_initialize", "session_removevar", "session_result", "session_setdefaultdriver", "session_start", "shown_count", "shown_first", "shown_last", "site_id", "site_name", "skiprecords_value", "sleep", "sqlite_abort", "sqlite_auth", "sqlite_blob", "sqlite_busy", "sqlite_cantopen", "sqlite_constraint", "sqlite_corrupt", "sqlite_createdb", "sqlite_done", "sqlite_empty", "sqlite_error", "sqlite_float", "sqlite_format", "sqlite_full", "sqlite_integer", "sqlite_internal", "sqlite_interrupt", "sqlite_ioerr", "sqlite_locked", "sqlite_mismatch", "sqlite_misuse", "sqlite_nolfs", "sqlite_nomem", "sqlite_notadb", "sqlite_notfound", "sqlite_null", "sqlite_ok", "sqlite_perm", "sqlite_protocol", "sqlite_range", "sqlite_readonly", "sqlite_row", "sqlite_schema", "sqlite_setsleepmillis", "sqlite_setsleeptries", "sqlite_text", "sqlite_toobig", "sqliteconnector", "staticarray_join", "stdout", "stdoutnl", "string_validcharset", "suspend", "sys_appspath", "sys_chroot", "sys_clock", "sys_clockspersec", "sys_credits", "sys_daemon", "sys_databasespath", "sys_detach_exec", "sys_difftime", "sys_dll_ext", "sys_drand48", "sys_environ", "sys_eol", "sys_erand48", "sys_errno", "sys_exec_pid_to_os_pid", "sys_exec", "sys_exit", "sys_fork", "sys_garbagecollect", "sys_getbytessincegc", "sys_getchar", "sys_getegid", "sys_getenv", "sys_geteuid", "sys_getgid", "sys_getgrnam", "sys_getheapfreebytes", "sys_getheapsize", "sys_getlogin", "sys_getpid", "sys_getppid", "sys_getpwnam", "sys_getpwuid", "sys_getstartclock", "sys_getthreadcount", "sys_getuid", "sys_growheapby", "sys_homepath", "sys_is_full_path", "sys_is_windows", "sys_isfullpath", "sys_iswindows", "sys_iterate", "sys_jrand48", "sys_kill_exec", "sys_kill", "sys_lcong48", "sys_librariespath", "sys_library", "sys_listtraits", "sys_listtypes", "sys_listunboundmethods", "sys_load_dynamic_library", "sys_loadlibrary", "sys_lrand48", "sys_masterhomepath", "sys_mrand48", "sys_nrand48", "sys_pid_exec", "sys_pointersize", "sys_rand", "sys_random", "sys_seed48", "sys_setenv", "sys_setgid", "sys_setsid", "sys_setuid", "sys_sigabrt", "sys_sigalrm", "sys_sigbus", "sys_sigchld", "sys_sigcont", "sys_sigfpe", "sys_sighup", "sys_sigill", "sys_sigint", "sys_sigkill", "sys_sigpipe", "sys_sigprof", "sys_sigquit", "sys_sigsegv", "sys_sigstop", "sys_sigsys", "sys_sigterm", "sys_sigtrap", "sys_sigtstp", "sys_sigttin", "sys_sigttou", "sys_sigurg", "sys_sigusr1", "sys_sigusr2", "sys_sigvtalrm", "sys_sigxcpu", "sys_sigxfsz", "sys_srand", "sys_srand48", "sys_srandom", "sys_strerror", "sys_supportpath", "sys_test_exec", "sys_time", "sys_uname", "sys_unsetenv", "sys_usercapimodulepath", "sys_userstartuppath", "sys_version", "sys_wait_exec", "sys_waitpid", "sys_wcontinued", "sys_while", "sys_wnohang", "sys_wuntraced", "table_name", "tag_exists", "thread_var_get", "thread_var_pop", "thread_var_push", "threadvar_find", "threadvar_get", "threadvar_set_asrt", "threadvar_set", "timer", "token_value", "treemap", "u_lb_alphabetic", "u_lb_ambiguous", "u_lb_break_after", "u_lb_break_before", "u_lb_break_both", "u_lb_break_symbols", "u_lb_carriage_return", "u_lb_close_punctuation", "u_lb_combining_mark", "u_lb_complex_context", "u_lb_contingent_break", "u_lb_exclamation", "u_lb_glue", "u_lb_h2", "u_lb_h3", "u_lb_hyphen", "u_lb_ideographic", "u_lb_infix_numeric", "u_lb_inseparable", "u_lb_jl", "u_lb_jt", "u_lb_jv", "u_lb_line_feed", "u_lb_mandatory_break", "u_lb_next_line", "u_lb_nonstarter", "u_lb_numeric", "u_lb_open_punctuation", "u_lb_postfix_numeric", "u_lb_prefix_numeric", "u_lb_quotation", "u_lb_space", "u_lb_surrogate", "u_lb_unknown", "u_lb_word_joiner", "u_lb_zwspace", "u_nt_decimal", "u_nt_digit", "u_nt_none", "u_nt_numeric", "u_sb_aterm", "u_sb_close", "u_sb_format", "u_sb_lower", "u_sb_numeric", "u_sb_oletter", "u_sb_other", "u_sb_sep", "u_sb_sp", "u_sb_sterm", "u_sb_upper", "u_wb_aletter", "u_wb_extendnumlet", "u_wb_format", "u_wb_katakana", "u_wb_midletter", "u_wb_midnum", "u_wb_numeric", "u_wb_other", "ucal_ampm", "ucal_dayofmonth", "ucal_dayofweek", "ucal_dayofweekinmonth", "ucal_dayofyear", "ucal_daysinfirstweek", "ucal_dowlocal", "ucal_dstoffset", "ucal_era", "ucal_extendedyear", "ucal_firstdayofweek", "ucal_hour", "ucal_hourofday", "ucal_julianday", "ucal_lenient", "ucal_listtimezones", "ucal_millisecond", "ucal_millisecondsinday", "ucal_minute", "ucal_month", "ucal_second", "ucal_weekofmonth", "ucal_weekofyear", "ucal_year", "ucal_yearwoy", "ucal_zoneoffset", "uchar_age", "uchar_alphabetic", "uchar_ascii_hex_digit", "uchar_bidi_class", "uchar_bidi_control", "uchar_bidi_mirrored", "uchar_bidi_mirroring_glyph", "uchar_bidi_paired_bracket", "uchar_block", "uchar_canonical_combining_class", "uchar_case_folding", "uchar_case_sensitive", "uchar_dash", "uchar_decomposition_type", "uchar_default_ignorable_code_point", "uchar_deprecated", "uchar_diacritic", "uchar_east_asian_width", "uchar_extender", "uchar_full_composition_exclusion", "uchar_general_category_mask", "uchar_general_category", "uchar_grapheme_base", "uchar_grapheme_cluster_break", "uchar_grapheme_extend", "uchar_grapheme_link", "uchar_hangul_syllable_type", "uchar_hex_digit", "uchar_hyphen", "uchar_id_continue", "uchar_ideographic", "uchar_ids_binary_operator", "uchar_ids_trinary_operator", "uchar_iso_comment", "uchar_join_control", "uchar_joining_group", "uchar_joining_type", "uchar_lead_canonical_combining_class", "uchar_line_break", "uchar_logical_order_exception", "uchar_lowercase_mapping", "uchar_lowercase", "uchar_math", "uchar_name", "uchar_nfc_inert", "uchar_nfc_quick_check", "uchar_nfd_inert", "uchar_nfd_quick_check", "uchar_nfkc_inert", "uchar_nfkc_quick_check", "uchar_nfkd_inert", "uchar_nfkd_quick_check", "uchar_noncharacter_code_point", "uchar_numeric_type", "uchar_numeric_value", "uchar_pattern_syntax", "uchar_pattern_white_space", "uchar_posix_alnum", "uchar_posix_blank", "uchar_posix_graph", "uchar_posix_print", "uchar_posix_xdigit", "uchar_quotation_mark", "uchar_radical", "uchar_s_term", "uchar_script", "uchar_segment_starter", "uchar_sentence_break", "uchar_simple_case_folding", "uchar_simple_lowercase_mapping", "uchar_simple_titlecase_mapping", "uchar_simple_uppercase_mapping", "uchar_soft_dotted", "uchar_terminal_punctuation", "uchar_titlecase_mapping", "uchar_trail_canonical_combining_class", "uchar_unicode_1_name", "uchar_unified_ideograph", "uchar_uppercase_mapping", "uchar_uppercase", "uchar_variation_selector", "uchar_white_space", "uchar_word_break", "uchar_xid_continue", "uncompress", "usage", "uuid_compare", "uuid_copy", "uuid_generate_random", "uuid_generate_time", "uuid_generate", "uuid_is_null", "uuid_parse", "uuid_unparse_lower", "uuid_unparse_upper", "uuid_unparse", "value_listitem", "valuelistitem", "var_keys", "var_values", "wap_isenabled", "wap_maxbuttons", "wap_maxcolumns", "wap_maxhorzpixels", "wap_maxrows", "wap_maxvertpixels", "web_handlefcgirequest", "web_node_content_representation_css", "web_node_content_representation_html", "web_node_content_representation_js", "web_node_content_representation_xhr", "web_node_forpath", "web_nodes_initialize", "web_nodes_normalizeextension", "web_nodes_processcontentnode", "web_nodes_requesthandler", "web_response_nodesentry", "web_router_database", "web_router_initialize", "websocket_handler_timeout", "wexitstatus", "wifcontinued", "wifexited", "wifsignaled", "wifstopped", "wstopsig", "wtermsig", "xml_transform", "zip_add_dir", "zip_add", "zip_checkcons", "zip_close", "zip_cm_bzip2", "zip_cm_default", "zip_cm_deflate", "zip_cm_deflate64", "zip_cm_implode", "zip_cm_pkware_implode", "zip_cm_reduce_1", "zip_cm_reduce_2", "zip_cm_reduce_3", "zip_cm_reduce_4", "zip_cm_shrink", "zip_cm_store", "zip_create", "zip_delete", "zip_em_3des_112", "zip_em_3des_168", "zip_em_aes_128", "zip_em_aes_192", "zip_em_aes_256", "zip_em_des", "zip_em_none", "zip_em_rc2_old", "zip_em_rc2", "zip_em_rc4", "zip_em_trad_pkware", "zip_em_unknown", "zip_er_changed", "zip_er_close", "zip_er_compnotsupp", "zip_er_crc", "zip_er_deleted", "zip_er_eof", "zip_er_exists", "zip_er_incons", "zip_er_internal", "zip_er_inval", "zip_er_memory", "zip_er_multidisk", "zip_er_noent", "zip_er_nozip", "zip_er_ok", "zip_er_open", "zip_er_read", "zip_er_remove", "zip_er_rename", "zip_er_seek", "zip_er_tmpopen", "zip_er_write", "zip_er_zipclosed", "zip_er_zlib", "zip_error_get_sys_type", "zip_error_get", "zip_error_to_str", "zip_et_none", "zip_et_sys", "zip_et_zlib", "zip_excl", "zip_fclose", "zip_file_error_get", "zip_file_strerror", "zip_fl_compressed", "zip_fl_nocase", "zip_fl_nodir", "zip_fl_unchanged", "zip_fopen_index", "zip_fopen", "zip_fread", "zip_get_archive_comment", "zip_get_file_comment", "zip_get_name", "zip_get_num_files", "zip_name_locate", "zip_open", "zip_rename", "zip_replace", "zip_set_archive_comment", "zip_set_file_comment", "zip_stat_index", "zip_stat", "zip_strerror", "zip_unchange_all", "zip_unchange_archive", "zip_unchange", "zlib_version"] + h[:keywords] = Set.new ["cache", "database_names", "database_schemanames", "database_tablenames", "define_tag", "define_type", "email_batch", "encode_set", "html_comment", "handle", "handle_error", "header", "if", "inline", "iterate", "ljax_target", "link", "link_currentaction", "link_currentgroup", "link_currentrecord", "link_detail", "link_firstgroup", "link_firstrecord", "link_lastgroup", "link_lastrecord", "link_nextgroup", "link_nextrecord", "link_prevgroup", "link_prevrecord", "log", "loop", "namespace_using", "output_none", "portal", "private", "protect", "records", "referer", "referrer", "repeating", "resultset", "rows", "search_args", "search_arguments", "select", "sort_args", "sort_arguments", "thread_atomic", "value_list", "while", "abort", "case", "else", "fail_if", "fail_ifnot", "fail", "if_empty", "if_false", "if_null", "if_true", "loop_abort", "loop_continue", "loop_count", "params", "params_up", "return", "return_value", "run_children", "soap_definetag", "soap_lastrequest", "soap_lastresponse", "tag_name", "ascending", "average", "by", "define", "descending", "do", "equals", "frozen", "group", "handle_failure", "import", "in", "into", "join", "let", "match", "max", "min", "on", "order", "parent", "protected", "provide", "public", "require", "returnhome", "skip", "split_thread", "sum", "take", "thread", "to", "trait", "type", "where", "with", "yield", "yieldhome"] + h[:exceptions] = Set.new ["error_adderror", "error_columnrestriction", "error_databaseconnectionunavailable", "error_databasetimeout", "error_deleteerror", "error_fieldrestriction", "error_filenotfound", "error_invaliddatabase", "error_invalidpassword", "error_invalidusername", "error_modulenotfound", "error_noerror", "error_nopermission", "error_outofmemory", "error_reqcolumnmissing", "error_reqfieldmissing", "error_requiredcolumnmissing", "error_requiredfieldmissing", "error_updateerror"] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lean.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lean.rb new file mode 100644 index 0000000..d19d7f8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lean.rb @@ -0,0 +1,164 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# NOTE: This is for Lean 3 (community fork). +module Rouge + module Lexers + class Lean < RegexLexer + title 'Lean' + desc 'The Lean programming language (leanprover.github.io)' + tag 'lean' + aliases 'lean' + filenames '*.lean' + + def self.keywords + @keywords ||= Set.new %w( + abbreviation + add_rewrite + alias + assume + axiom + begin + by + calc + calc_refl + calc_subst + calc_trans + #check + coercion + conjecture + constant + constants + context + corollary + def + definition + end + #eval + example + export + expose + exposing + exit + extends + from + fun + have + help + hiding + hott + hypothesis + import + include + including + inductive + infix + infixl + infixr + inline + instance + irreducible + lemma + match + namespace + notation + opaque + opaque_hint + open + options + parameter + parameters + postfix + precedence + prefix + #print + private + protected + #reduce + reducible + renaming + repeat + section + set_option + show + tactic_hint + theorem + universe + universes + using + variable + variables + with + ) + end + + def self.types + @types ||= %w( + Sort + Prop + Type + ) + end + + def self.operators + @operators ||= %w( + != # & && \* \+ - / @ ! ` -\. -> + \. \.\. \.\.\. :: :> ; ;; < + <- = == > _ \| \|\| ~ => <= >= + /\ \/ ∀ Π λ ↔ ∧ ∨ ≠ ≤ ≥ ⊎ + ¬ ⁻¹ ⬝ ▸ → ∃ ℕ ℤ ≈ × ⌞ ⌟ ≡ ⟨ ⟩ + ) + end + + state :root do + # comments starting after some space + rule %r/\s*--+\s+.*?$/, Comment::Doc + + rule %r/"/, Str, :string + rule %r/\d+/, Num::Integer + + # special commands or keywords + rule(/#?\w+/) do |m| + match = m[0] + if self.class.keywords.include?(match) + token Keyword + elsif self.class.types.include?(match) + token Keyword::Type + else + token Name + end + end + + # special unicode keywords + rule %r/[λ]/, Keyword + + # ---------------- + # operators rules + # ---------------- + + rule %r/\:=?/, Text + rule %r/\.[0-9]*/, Operator + + rule %r(#{Lean.operators.join('|')}), Operator + + # unmatched symbols + rule %r/[\s\(\),\[\]αβ‹›]+/, Text + + # show missing matches + rule %r/./, Error + + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\/, Str::Escape, :escape + rule %r/[^\\"]+/, Str + end + + state :escape do + rule %r/[nrt"'\\]/, Str::Escape, :pop! + rule %r/x[\da-f]+/i, Str::Escape, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/liquid.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/liquid.rb new file mode 100644 index 0000000..c54d700 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/liquid.rb @@ -0,0 +1,285 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Liquid < RegexLexer + title "Liquid" + desc 'Liquid is a templating engine for Ruby (liquidmarkup.org)' + tag 'liquid' + filenames '*.liquid' + mimetypes 'text/html+liquid' + + state :root do + rule %r/[^\{]+/, Text + + rule %r/(\{%-?)(\s*)/ do + groups Comment::Preproc, Text::Whitespace + push :logic + end + + rule %r/(\{\{-?)(\s*)/ do + groups Comment::Preproc, Text::Whitespace + push :output + end + + rule %r/\{/, Text + end + + state :end_logic do + rule(/(\s*)(-?%\})/) do + groups Text::Whitespace, Comment::Preproc + reset_stack + end + + rule(/\n\s*/) do + token Text::Whitespace + if in_state? :liquid + pop! until state? :liquid + end + end + + mixin :whitespace + end + + state :end_output do + rule(/(\s*)(-?\}\})/) do + groups Text::Whitespace, Comment::Preproc + reset_stack + end + end + + state :liquid do + mixin :end_logic + mixin :logic + end + + state :logic do + rule %r/(liquid)\b/, Name::Tag, :liquid + + # builtin logic blocks + rule %r/(if|elsif|unless|case)\b/, Name::Tag, :condition + rule %r/(when)\b/, Name::Tag, :value + rule %r/(else|ifchanged|end\w+)\b/, Name::Tag, :end_logic + rule %r/(break|continue)\b/, Keyword::Reserved, :end_logic + + # builtin iteration blocks + rule %r/(for|tablerow)(\s+)(\S+)(\s+)(in)(\s+)/ do + groups Name::Tag, Text::Whitespace, Name::Variable, Text::Whitespace, + Name::Tag, Text::Whitespace + push :iteration_args + end + + # other builtin blocks + rule %r/(capture|(?:in|de)crement)(\s+)([a-zA-Z_](?:\w|-(?!%))*)/ do + groups Name::Tag, Text::Whitespace, Name::Variable + push :end_logic + end + + rule %r/(comment)(\s*)(-?%\})/ do + groups Name::Tag, Text::Whitespace, Comment::Preproc + push :comment + end + + rule %r/(raw)(\s*)(-?%\})/ do + groups Name::Tag, Text::Whitespace, Comment::Preproc + push :raw + end + + # builtin tags + rule %r/(assign|echo)\b/, Name::Tag, :assign + + rule %r/(include|render)(\s+)([\/\w-]+(?:\.[\w-]+)+\b)?/ do + groups Name::Tag, Text::Whitespace, Text + push :include + end + + rule %r/(cycle)(\s+)(?:([\w-]+|'[^']*'|"[^"]*")(\s*)(:))?(\s*)/ do |m| + token_class = case m[3] + when %r/'[^']*'/ then Str::Single + when %r/"[^"]*"/ then Str::Double + else + Name::Attribute + end + groups Name::Tag, Text::Whitespace, token_class, + Text::Whitespace, Punctuation, Text::Whitespace + push :tag_args + end + + # custom tags or blocks + rule %r/(\w+)\b/, Name::Tag, :block_args + + mixin :end_logic + end + + state :output do + rule %r/(\|)(\s*)/ do + groups Punctuation, Text::Whitespace + push :filters + push :filter + end + + mixin :end_output + mixin :static + mixin :variable + end + + state :condition do + rule %r/([=!]=|[<>]=?)/, Operator + rule %r/(and|or|contains)\b/, Operator::Word + + mixin :value + end + + state :value do + mixin :end_logic + mixin :static + mixin :variable + end + + state :iteration_args do + rule %r/(reversed|continue)\b/, Name::Attribute + rule %r/\(/, Punctuation, :range + + mixin :tag_args + end + + state :block_args do + rule %r/(\{\{-?)/, Comment::Preproc, :output_embed + + rule %r/(\|)(\s*)/ do + groups Punctuation, Text::Whitespace + push :filters + push :filter + end + + mixin :tag_args + end + + state :tag_args do + mixin :end_logic + mixin :args + end + + state :comment do + rule %r/[^\{]+/, Comment + + rule %r/(\{%-?)(\s*)(endcomment)(\s*)(-?%\})/ do + groups Comment::Preproc, Text::Whitespace, Name::Tag, Text::Whitespace, Comment::Preproc + reset_stack + end + + rule %r/\{/, Comment + end + + state :raw do + rule %r/[^\{]+/, Text + + rule %r/(\{%-?)(\s*)(endraw)(\s*)(-?%\})/ do + groups Comment::Preproc, Text::Whitespace, Name::Tag, Text::Whitespace, Comment::Preproc + reset_stack + end + + rule %r/\{/, Text + end + + state :assign do + rule %r/=/, Operator + rule %r/\(/, Punctuation, :range + + rule %r/(\|)(\s*)/ do + groups Punctuation, Text::Whitespace + push :filters + push :filter + end + + mixin :value + end + + state :include do + rule %r/(\{\{-?)/, Comment::Preproc, :output_embed + rule %r/(with|for|as)\b/, Keyword::Reserved + + mixin :tag_args + end + + state :output_embed do + rule %r/(\|)(\s*)([a-zA-Z_](?:\w|-(?!}))*)/ do + groups Punctuation, Text::Whitespace, Name::Function + end + + rule %r/-?\}\}/, Comment::Preproc, :pop! + + mixin :args + end + + state :range do + rule %r/\.\./, Punctuation + rule %r/\)/, Punctuation, :pop! + + mixin :whitespace + mixin :number + mixin :variable + end + + state :filters do + rule %r/(\|)(\s*)/ do + groups Punctuation, Text::Whitespace + push :filter + end + + mixin :end_logic + mixin :end_output + mixin :args + end + + state :filter do + rule %r/[a-zA-Z_](?:\w|-(?![%}]))*/, Name::Function, :pop! + + mixin :whitespace + end + + state :args do + mixin :static + + rule %r/([a-zA-Z_][\w-]*)(\s*)(=|:)/ do + groups Name::Attribute, Text::Whitespace, Operator + end + + mixin :variable + end + + state :static do + rule %r/(false|true|nil)\b/, Keyword::Constant + rule %r/'[^']*'/, Str::Single + rule %r/"[^"]*"/, Str::Double + rule %r/[,:]/, Punctuation + + mixin :whitespace + mixin :number + end + + state :whitespace do + rule %r/\s+/, Text::Whitespace + rule %r/#.*?(?=$|-?[}%]})/, Comment + end + + state :number do + rule %r/-/, Operator + rule %r/\d+\.\d+/, Num::Float + rule %r/\d+/, Num::Integer + end + + state :variable do + rule %r/(\.)(\s*)(first|last|size)\b(?![?!\/])/ do + groups Punctuation, Text::Whitespace, Name::Function + end + + rule %r/\.(?= *\w)|\[|\]/, Punctuation + rule %r/(empty|blank|(for|tablerow)loop\.(parentloop\.)*\w+)\b(?![?!\/])/, Name::Builtin + rule %r/[a-zA-Z_][\w-]*\b-?(?![?!\/])/, Name::Variable + rule %r/\S+/, Text + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/literate_coffeescript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/literate_coffeescript.rb new file mode 100644 index 0000000..b991fdf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/literate_coffeescript.rb @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class LiterateCoffeescript < RegexLexer + tag 'literate_coffeescript' + title "Literate CoffeeScript" + desc 'Literate coffeescript' + aliases 'litcoffee' + filenames '*.litcoffee' + + def markdown + @markdown ||= Markdown.new(options) + end + + def coffee + @coffee ||= Coffeescript.new(options) + end + + start { markdown.reset!; coffee.reset! } + + state :root do + rule %r/^( .*?\n)+/m do + delegate coffee + end + + rule %r/^([ ]{0,3}(\S.*?|)\n)*/m do + delegate markdown + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/literate_haskell.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/literate_haskell.rb new file mode 100644 index 0000000..cf43e85 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/literate_haskell.rb @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class LiterateHaskell < RegexLexer + title "Literate Haskell" + desc 'Literate haskell' + tag 'literate_haskell' + aliases 'lithaskell', 'lhaskell', 'lhs' + filenames '*.lhs' + mimetypes 'text/x-literate-haskell' + + def haskell + @haskell ||= Haskell.new(options) + end + + start { haskell.reset! } + + # TODO: support TeX versions as well. + state :root do + rule %r/\s*?\n(?=>)/, Text, :code + rule %r/.*?\n/, Text + rule %r/.+\z/, Text + end + + state :code do + rule %r/(>)( .*?(\n|\z))/ do |m| + token Name::Label, m[1] + delegate haskell, m[2] + end + + rule %r/\s*\n(?=\s*[^>])/, Text, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/livescript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/livescript.rb new file mode 100644 index 0000000..0825e63 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/livescript.rb @@ -0,0 +1,310 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Livescript < RegexLexer + tag 'livescript' + aliases 'ls' + filenames '*.ls' + mimetypes 'text/livescript' + + title 'LiveScript' + desc 'LiveScript, a language which compiles to JavaScript (livescript.net)' + + def self.detect?(text) + return text.shebang? 'lsc' + end + + def self.declarations + @declarations ||= Set.new %w(const let var function class extends implements) + end + + def self.keywords + @keywords ||= Set.new %w( + loop until for in of while break return continue switch case + fallthrough default otherwise when then if unless else throw try + catch finally new delete typeof instanceof super by from to til + with require do debugger import export yield + ) + end + + def self.constants + @constants ||= Javascript.constants + %w(yes no on off void) + end + + def self.builtins + @builtins ||= Javascript.builtins + %w(this it that arguments) + end + + def self.loop_control_keywords + @loop_control_keywords ||= Set.new %w(break continue) + end + + id = /[$a-z_]((-(?=[a-z]))?[a-z0-9_])*/i + int_number = /\d[\d_]*/ + int = /#{int_number}(e[+-]?#{int_number})?[$\w]*/ # the last class matches units + + state :root do + rule(%r(^(?=\s|/))) { push :slash_starts_regex } + mixin :comments + mixin :whitespace + + # list of words + rule %r/(<\[)(.*?)(\]>)/m do + groups Punctuation, Str, Punctuation + end + + # function declarations + rule %r/!\s*function\b/, Keyword::Declaration + rule %r/!?[-~]>|<[-~]!?/, Keyword::Declaration + + # switch arrow + rule %r/(=>)/, Keyword + + # prototype attributes + rule %r/(::)(#{id})/ do + groups Punctuation, Name::Attribute + push :id + end + rule %r/(::)(#{int})/ do + groups Punctuation, Num::Integer + push :id + end + + # instance attributes + rule %r/(@)(#{id})/ do + groups Name::Variable::Instance, Name::Attribute + push :id + end + rule %r/([.])(#{id})/ do + groups Punctuation, Name::Attribute + push :id + end + rule %r/([.])(\d+)/ do + groups Punctuation, Num::Integer + push :id + end + rule %r/#{id}(?=\s*:[^:=])/, Name::Attribute + + # operators + rule %r( + [+][+]|--|&&|\b(and|x?or|is(nt)?|not)\b(?!-[a-zA-Z]|_)|[|][|]| + [.]([|&^]|<<|>>>?)[.]|\\(?=\n)|[.:]=|<<<| + (<<|>>|==?|!=?|[-<>+*%^/~?])=? + )x, Operator, :slash_starts_regex + + # arguments shorthand + rule %r/(&)(#{id})?/ do + groups Name::Builtin, Name::Attribute + end + + # switch case + rule %r/[|]|\bcase(?=\s)/, Keyword, :switch_underscore + + rule %r/@/, Name::Variable::Instance + rule %r/[.]{3}/, Punctuation + rule %r/:/, Punctuation + + # keywords + rule %r/#{id}/ do |m| + if self.class.loop_control_keywords.include? m[0] + token Keyword + push :loop_control + next + elsif self.class.keywords.include? m[0] + token Keyword + elsif self.class.constants.include? m[0] + token Name::Constant + elsif self.class.builtins.include? m[0] + token Name::Builtin + elsif self.class.declarations.include? m[0] + token Keyword::Declaration + elsif /^[A-Z]/.match(m[0]) && /[^-][a-z]/.match(m[0]) + token Name::Class + else + token Name::Variable + end + push :id + end + + # punctuation and brackets + rule %r/\](?=[!?.]|#{id})/, Punctuation, :id + rule %r/[{(\[;,]/, Punctuation, :slash_starts_regex + rule %r/[})\].]/, Punctuation + + # literals + rule %r/#{int_number}[.]#{int}/, Num::Float + rule %r/0x[0-9A-Fa-f]+/, Num::Hex + rule %r/#{int}/, Num::Integer + + # strings + rule %r/"""/ do + token Str + push do + rule %r/"""/, Str, :pop! + rule %r/"/, Str + mixin :double_strings + end + end + + rule %r/'''/ do + token Str + push do + rule %r/'''/, Str, :pop! + rule %r/'/, Str + mixin :single_strings + end + end + + rule %r/"/ do + token Str + push do + rule %r/"/, Str, :pop! + mixin :double_strings + end + end + + rule %r/'/ do + token Str + push do + rule %r/'/, Str, :pop! + mixin :single_strings + end + end + + # words + rule %r/\\\S[^\s,;\])}]*/, Str + end + + state :code_escape do + rule %r(\\( + c[A-Z]| + x[0-9a-fA-F]{2}| + u[0-9a-fA-F]{4}| + u\{[0-9a-fA-F]{4}\} + ))x, Str::Escape + end + + state :interpolated_expression do + rule %r/}/, Str::Interpol, :pop! + mixin :root + end + + state :interpolation do + # with curly braces + rule %r/[#][{]/, Str::Interpol, :interpolated_expression + # without curly braces + rule %r/(#)(#{id})/ do |m| + groups Str::Interpol, (self.class.builtins.include? m[2]) ? Name::Builtin : Name::Variable + end + end + + state :whitespace do + # white space and loop labels + rule %r/(\s+?)(?:^([^\S\n]*)(:#{id}))?/m do + groups Text, Text, Name::Label + end + end + + state :whitespace_single_line do + rule %r([^\S\n]+), Text + end + + state :slash_starts_regex do + mixin :comments + mixin :whitespace + mixin :multiline_regex_begin + + rule %r( + /(\\.|[^\[/\\\n]|\[(\\.|[^\]\\\n])*\])+/ # a regex + ([gimy]+\b|\B) + )x, Str::Regex, :pop! + + rule(//) { pop! } + end + + state :multiline_regex_begin do + rule %r(//) do + token Str::Regex + goto :multiline_regex + end + end + + state :multiline_regex_end do + rule %r(//([gimy]+\b|\B)), Str::Regex, :pop! + end + + state :multiline_regex do + mixin :multiline_regex_end + mixin :regex_comment + mixin :interpolation + mixin :code_escape + rule %r/\\\D/, Str::Escape + rule %r/\\\d+/, Name::Variable + rule %r/./m, Str::Regex + end + + state :regex_comment do + rule %r/^#(\s+.*)?$/, Comment::Single + rule %r/(\s+)(#)(\s+.*)?$/ do + groups Text, Comment::Single, Comment::Single + end + end + + state :comments do + rule %r(/\*.*?\*/)m, Comment::Multiline + rule %r/#.*$/, Comment::Single + end + + state :switch_underscore do + mixin :whitespace_single_line + rule %r/_(?=\s*=>|\s+then\b)/, Keyword + rule(//) { pop! } + end + + state :loop_control do + mixin :whitespace_single_line + rule %r/#{id}(?=[);\n])/, Name::Label + rule(//) { pop! } + end + + state :id do + rule %r/[!?]|[.](?!=)/, Punctuation + rule %r/[{]/ do + # destructuring + token Punctuation + push do + rule %r/[,;]/, Punctuation + rule %r/#{id}/, Name::Attribute + rule %r/#{int}/, Num::Integer + mixin :whitespace + rule %r/[}]/, Punctuation, :pop! + end + end + rule %r/#{id}/, Name::Attribute + rule %r/#{int}/, Num::Integer + rule(//) { goto :slash_starts_regex } + end + + state :strings do + # all strings are multi-line + rule %r/[^#\\'"]+/m, Str + mixin :code_escape + rule %r/\\./, Str::Escape + rule %r/#/, Str + end + + state :double_strings do + rule %r/'/, Str + mixin :interpolation + mixin :strings + end + + state :single_strings do + rule %r/"/, Str + mixin :strings + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/llvm.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/llvm.rb new file mode 100644 index 0000000..b5ffa44 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/llvm.rb @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class LLVM < RegexLexer + title "LLVM" + desc 'The LLVM Compiler Infrastructure (http://llvm.org/)' + tag 'llvm' + + filenames '*.ll' + mimetypes 'text/x-llvm' + + string = /"[^"]*?"/ + identifier = /([-a-zA-Z$._][-a-zA-Z$._0-9]*|#{string})/ + + def self.keywords + Kernel::load File.join(Lexers::BASE_DIR, "llvm/keywords.rb") + keywords + end + + def self.instructions + Kernel::load File.join(Lexers::BASE_DIR, "llvm/keywords.rb") + instructions + end + + def self.types + Kernel::load File.join(Lexers::BASE_DIR, "llvm/keywords.rb") + types + end + + state :basic do + rule %r/;.*?$/, Comment::Single + rule %r/\s+/, Text + + rule %r/#{identifier}\s*:/, Name::Label + + rule %r/@(#{identifier}|\d+)/, Name::Variable::Global + rule %r/#\d+/, Name::Variable::Global + rule %r/(%|!)#{identifier}/, Name::Variable + rule %r/(%|!)\d+/, Name::Variable + + rule %r/c?#{string}/, Str + + rule %r/0[xX][a-fA-F0-9]+/, Num + rule %r/-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?/, Num + + rule %r/[=<>{}\[\]()*.,!]|x/, Punctuation + end + + state :root do + mixin :basic + + rule %r/i[1-9]\d*/, Keyword::Type + + rule %r/\w+/ do |m| + if self.class.types.include? m[0] + token Keyword::Type + elsif self.class.instructions.include? m[0] + token Keyword + elsif self.class.keywords.include? m[0] + token Keyword + else + token Error + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/llvm/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/llvm/keywords.rb new file mode 100644 index 0000000..405ee52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/llvm/keywords.rb @@ -0,0 +1,25 @@ +# encoding: utf-8 +# frozen_string_literal: true + +# DO NOT EDIT +# This file is automatically generated by `rake builtins:llvm`. +# See tasks/builtins/llvm.rake for more info. + +module Rouge + module Lexers + class LLVM + def self.keywords + @keywords ||= Set.new ["aarch64_sve_vector_pcs", "aarch64_vector_pcs", "acq_rel", "acquire", "addrspace", "afn", "alias", "aliasee", "align", "alignLog2", "alignstack", "allOnes", "allocalign", "allocptr", "allocsize", "alwaysInline", "alwaysinline", "amdgpu_cs", "amdgpu_es", "amdgpu_gfx", "amdgpu_gs", "amdgpu_hs", "amdgpu_kernel", "amdgpu_ls", "amdgpu_ps", "amdgpu_vs", "any", "anyregcc", "appending", "arcp", "argmemonly", "args", "arm_aapcs_vfpcc", "arm_aapcscc", "arm_apcscc", "asm", "async", "atomic", "attributes", "available_externally", "avr_intrcc", "avr_signalcc", "bit", "bitMask", "blockaddress", "blockcount", "branchFunnel", "builtin", "byArg", "byref", "byte", "byteArray", "byval", "c", "callee", "caller", "calls", "canAutoHide", "catch", "cc", "ccc", "cfguard_checkcc", "cleanup", "cold", "coldcc", "comdat", "common", "constant", "contract", "convergent", "critical", "cxx_fast_tlscc", "datalayout", "declare", "default", "define", "dereferenceable", "dereferenceable_or_null", "disable_sanitizer_instrumentation", "distinct", "dllexport", "dllimport", "dsoLocal", "dso_local", "dso_local_equivalent", "dso_preemptable", "elementtype", "eq", "exact", "exactmatch", "extern_weak", "external", "externally_initialized", "false", "fast", "fastcc", "filter", "flags", "from", "funcFlags", "function", "gc", "ghccc", "global", "guid", "gv", "hasUnknownCall", "hash", "hhvm_ccc", "hhvmcc", "hidden", "hot", "hotness", "ifunc", "immarg", "inaccessiblemem_or_argmemonly", "inaccessiblememonly", "inalloca", "inbounds", "indir", "info", "initialexec", "inline", "inlineBits", "inlinehint", "inrange", "inreg", "insts", "intel_ocl_bicc", "inteldialect", "internal", "jumptable", "kind", "largest", "linkage", "linkonce", "linkonce_odr", "live", "local_unnamed_addr", "localdynamic", "localexec", "max", "mayThrow", "min", "minsize", "module", "monotonic", "msp430_intrcc", "mustBeUnreachable", "mustprogress", "musttail", "naked", "name", "nand", "ne", "nest", "ninf", "nnan", "noInline", "noRecurse", "noUnwind", "no_cfi", "noalias", "nobuiltin", "nocallback", "nocapture", "nocf_check", "nodeduplicate", "noduplicate", "nofree", "noimplicitfloat", "noinline", "nomerge", "none", "nonlazybind", "nonnull", "noprofile", "norecurse", "noredzone", "noreturn", "nosanitize_bounds", "nosanitize_coverage", "nosync", "notEligibleToImport", "notail", "noundef", "nounwind", "nsw", "nsz", "null", "null_pointer_is_valid", "nuw", "oeq", "offset", "oge", "ogt", "ole", "olt", "one", "opaque", "optforfuzzing", "optnone", "optsize", "ord", "param", "params", "partition", "path", "personality", "poison", "preallocated", "prefix", "preserve_allcc", "preserve_mostcc", "private", "prologue", "protected", "ptx_device", "ptx_kernel", "readNone", "readOnly", "readnone", "readonly", "reassoc", "refs", "relbf", "release", "resByArg", "returnDoesNotAlias", "returned", "returns_twice", "safestack", "samesize", "sanitize_address", "sanitize_hwaddress", "sanitize_memory", "sanitize_memtag", "sanitize_thread", "section", "seq_cst", "sge", "sgt", "shadowcallstack", "sideeffect", "signext", "single", "singleImpl", "singleImplName", "sizeM1", "sizeM1BitWidth", "sle", "slt", "source_filename", "speculatable", "speculative_load_hardening", "spir_func", "spir_kernel", "sret", "ssp", "sspreq", "sspstrong", "strictfp", "summaries", "summary", "swiftasync", "swiftcc", "swifterror", "swiftself", "swifttailcc", "sync", "syncscope", "tail", "tailcc", "target", "thread_local", "to", "triple", "true", "type", "typeCheckedLoadConstVCalls", "typeCheckedLoadVCalls", "typeIdInfo", "typeTestAssumeConstVCalls", "typeTestAssumeVCalls", "typeTestRes", "typeTests", "typeid", "typeidCompatibleVTable", "ueq", "uge", "ugt", "ule", "ult", "umax", "umin", "undef", "une", "uniformRetVal", "uniqueRetVal", "unknown", "unnamed_addr", "uno", "unordered", "unsat", "unwind", "uselistorder", "uselistorder_bb", "uwtable", "vFuncId", "vTableFuncs", "varFlags", "variable", "vcall_visibility", "virtFunc", "virtualConstProp", "visibility", "volatile", "vscale", "vscale_range", "weak", "weak_odr", "webkit_jscc", "willreturn", "win64cc", "within", "wpdRes", "wpdResolutions", "writeonly", "x", "x86_64_sysvcc", "x86_fastcallcc", "x86_intrcc", "x86_regcallcc", "x86_stdcallcc", "x86_thiscallcc", "x86_vectorcallcc", "xchg", "zeroext", "zeroinitializer"] + end + + def self.types + @types ||= Set.new ["bfloat", "double", "float", "fp128", "half", "label", "metadata", "ppc_fp128", "ptr", "token", "void", "x86_amx", "x86_fp80", "x86_mmx"] + end + + def self.instructions + @instructions ||= Set.new ["add", "addrspacecast", "alloca", "and", "ashr", "atomicrmw", "bitcast", "br", "call", "callbr", "catchpad", "catchret", "catchswitch", "cleanuppad", "cleanupret", "cmpxchg", "extractelement", "extractvalue", "fadd", "fcmp", "fdiv", "fence", "fmul", "fneg", "fpext", "fptosi", "fptoui", "fptrunc", "freeze", "frem", "fsub", "getelementptr", "icmp", "indirectbr", "insertelement", "insertvalue", "inttoptr", "invoke", "landingpad", "load", "lshr", "mul", "or", "phi", "ptrtoint", "resume", "ret", "sdiv", "select", "sext", "shl", "shufflevector", "sitofp", "srem", "store", "sub", "switch", "trunc", "udiv", "uitofp", "unreachable", "urem", "va_arg", "xor", "zext"] + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lua.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lua.rb new file mode 100644 index 0000000..6e1887b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lua.rb @@ -0,0 +1,164 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Lua < RegexLexer + title "Lua" + desc "Lua (http://www.lua.org)" + tag 'lua' + filenames '*.lua', '*.wlua' + + mimetypes 'text/x-lua', 'application/x-lua' + + option :function_highlighting, 'Whether to highlight builtin functions (default: true)' + option :disabled_modules, 'builtin modules to disable' + + def initialize(opts={}) + @function_highlighting = opts.delete(:function_highlighting) { true } + @disabled_modules = opts.delete(:disabled_modules) { [] } + super(opts) + end + + def self.detect?(text) + return true if text.shebang? 'lua' + end + + def self.builtins + Kernel::load File.join(Lexers::BASE_DIR, 'lua/keywords.rb') + builtins + end + + def builtins + return [] unless @function_highlighting + + @builtins ||= Set.new.tap do |builtins| + self.class.builtins.each do |mod, fns| + next if @disabled_modules.include? mod + builtins.merge(fns) + end + end + end + + state :root do + # lua allows a file to start with a shebang + rule %r(#!(.*?)$), Comment::Preproc + rule %r//, Text, :base + end + + state :base do + rule %r(--\[(=*)\[.*?\]\1\])m, Comment::Multiline + rule %r(--.*$), Comment::Single + + rule %r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'), Num::Float + rule %r((?i)\d+e[+-]?\d+), Num::Float + rule %r((?i)0x[0-9a-f]*), Num::Hex + rule %r(\d+), Num::Integer + + rule %r(\n), Text + rule %r([^\S\n]), Text + # multiline strings + rule %r(\[(=*)\[.*?\]\1\])m, Str + + rule %r((==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])), Operator + rule %r([\[\]\{\}\(\)\.,:;]), Punctuation + rule %r((and|or|not)\b), Operator::Word + + rule %r((break|do|else|elseif|end|for|if|in|repeat|return|then|until|while)\b), Keyword + rule %r((local)\b), Keyword::Declaration + rule %r((true|false|nil)\b), Keyword::Constant + + rule %r((function)\b), Keyword, :function_name + + rule %r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?) do |m| + name = m[0] + if name == "gsub" + token Name::Builtin + push :gsub + elsif self.builtins.include?(name) + token Name::Builtin + elsif name =~ /\./ + a, b = name.split('.', 2) + token Name, a + token Punctuation, '.' + token Name, b + else + token Name + end + end + + rule %r('), Str::Single, :escape_sqs + rule %r("), Str::Double, :escape_dqs + end + + state :function_name do + rule %r/\s+/, Text + rule %r((?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)) do + groups Name::Class, Punctuation, Name::Function + pop! + end + # inline function + rule %r(\(), Punctuation, :pop! + end + + state :gsub do + rule %r/\)/, Punctuation, :pop! + rule %r/[(,]/, Punctuation + rule %r/\s+/, Text + rule %r/"/, Str::Regex, :regex + end + + state :regex do + rule %r(") do + token Str::Regex + goto :regex_end + end + + rule %r/\[\^?/, Str::Escape, :regex_group + rule %r/\\./, Str::Escape + rule %r{[(][?][:=?@^|~#-]+) + id = /[a-z_][\w']*/i + + state :root do + rule %r/\s+/m, Text + rule %r/false|true/, Keyword::Constant + rule %r(\-\-.*), Comment::Single + rule %r(/\*.*?\*/)m, Comment::Multiline + rule %r(\(\*.*?\*\))m, Comment::Multiline + rule id do |m| + match = m[0] + if self.class.keywords.include? match + token Keyword + elsif self.class.word_operators.include? match + token Operator::Word + elsif self.class.primitives.include? match + token Keyword::Type + else + token Name + end + end + + rule %r/[(){}\[\];]+/, Punctuation + rule operator, Operator + + rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float + rule %r/\d[\d_]*/, Num::Integer + + rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char + rule %r/'[.]'/, Str::Char + rule %r/"/, Str::Double, :string + rule %r/[~?]#{id}/, Name::Variable + end + + state :string do + rule %r/[^\\"]+/, Str::Double + mixin :escape_sequence + rule %r/\\\n/, Str::Double + rule %r/"/, Str::Double, :pop! + end + + state :escape_sequence do + rule %r/\\[\\"'ntbr]/, Str::Escape + rule %r/\\\d{3}/, Str::Escape + rule %r/\\x\h{2}/, Str::Escape + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lutin.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lutin.rb new file mode 100644 index 0000000..cc1ac53 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/lutin.rb @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true +# +# adapted from lustre.rf (adapted from ocaml.rb), hence some ocaml-ism migth remains +module Rouge + module Lexers + load_lexer 'lustre.rb' + + class Lutin < Lustre + title "Lutin" + desc 'The Lutin programming language (Verimag)' + tag 'lutin' + filenames '*.lut' + mimetypes 'text/x-lutin' + + def self.keywords + @keywords ||= Set.new %w( + let in node extern system returns weak strong assert raise try catch + trap do exist erun run type ref exception include false true + ) + end + + def self.word_operators + @word_operators ||= Set.new %w( + div and xor mod or not nor if then else pre) + end + + def self.primitives + @primitives ||= Set.new %w(int real bool trace loop fby) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/m68k.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/m68k.rb new file mode 100644 index 0000000..cb610b7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/m68k.rb @@ -0,0 +1,143 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class M68k < RegexLexer + tag 'm68k' + + title "M68k" + desc "Motorola 68k Assembler" + + id = /[a-zA-Z_][a-zA-Z0-9_]*/ + + def self.keywords + @keywords ||= Set.new %w( + abcd add adda addi addq addx and andi asl asr + + bcc bcs beq bge bgt bhi ble bls blt bmi bne bpl bvc bvs bhs blo + bchg bclr bfchg bfclr bfests bfextu bfffo bfins bfset bftst bkpt bra bse bsr btst + + callm cas cas2 chk chk2 clr cmp cmpa cmpi cmpm cmp2 + + dbcc dbcs dbeq dbge dbgt dbhi dble dbls dblt dbmi dbne dbpl dbvc dbvs dbhs dblo + dbra dbf dbt divs divsl divu divul + + eor eori exg ext extb + + illegal jmp jsr lea link lsl lsr + + move movea move16 movem movep moveq muls mulu + + nbcd neg negx nop not or ori + + pack pea rol ror roxl roxr rtd rtm rtr rts + + sbcd + + seq sne spl smi svc svs st sf sge sgt sle slt scc shi sls scs shs slo + sub suba subi subq subx swap + + tas trap trapcc TODO trapv tst + + unlk unpk eori + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + dc ds dcb + ) + end + + def self.reserved + @reserved ||= Set.new %w( + include incdir incbin end endf endfunc endmain endproc fpu func machine main mmu opword proc set opt section + rept endr + ifeq ifne ifgt ifge iflt ifle iif ifd ifnd ifc ifnc elseif else endc + even cnop fail machine + output radix __G2 __LK + list nolist plen llen ttl subttl spc page listchar format + equ equenv equr set reg + rsreset rsset offset + cargs + fequ.s fequ.d fequ.x fequ.p fequ.w fequ.l fopt + macro endm mexit narg + ) + end + + def self.builtins + @builtins ||=Set.new %w( + d0 d1 d2 d3 d4 d5 d6 d7 + a0 a1 a2 a3 a4 a5 a6 a7 a7' + pc usp ssp ccr + ) + end + + start { push :expr_bol } + + state :expr_bol do + mixin :inline_whitespace + rule(//) { pop! } + end + + state :inline_whitespace do + rule %r/\s+/, Text + end + + state :whitespace do + rule %r/\n+/m, Text, :expr_bol + rule %r(^\*(\\.|.)*?$), Comment::Single, :expr_bol + rule %r(;(\\.|.)*?$), Comment::Single, :expr_bol + mixin :inline_whitespace + end + + state :root do + rule(//) { push :statements } + end + + state :statements do + mixin :whitespace + rule %r/"/, Str, :string + rule %r/#/, Name::Decorator + rule %r/^\.?[a-zA-Z0-9_]+:?/, Name::Label + rule %r/\.[bswl]\s/i, Name::Decorator + rule %r('(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char + rule %r/\$[0-9a-f]+/i, Num::Hex + rule %r/@[0-8]+/i, Num::Oct + rule %r/%[01]+/i, Num::Bin + rule %r/\d+/i, Num::Integer + rule %r([*~&+=\|?:<>/-]), Operator + rule %r/\\./, Comment::Preproc + rule %r/[(),.]/, Punctuation + rule %r/\[[a-zA-Z0-9]*\]/, Punctuation + + rule id do |m| + name = m[0] + + if self.class.keywords.include? name.downcase + token Keyword + elsif self.class.keywords_type.include? name.downcase + token Keyword::Type + elsif self.class.reserved.include? name.downcase + token Keyword::Reserved + elsif self.class.builtins.include? name.downcase + token Name::Builtin + elsif name =~ /[a-zA-Z0-9]+/ + token Name::Variable + else + token Name + end + end + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape + rule %r/[^\\"\n]+/, Str + rule %r/\\\n/, Str + rule %r/\\/, Str # stray backslash + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/magik.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/magik.rb new file mode 100644 index 0000000..0a3f47a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/magik.rb @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Magik < RegexLexer + title "Magik" + desc "Smallworld Magik" + tag 'magik' + filenames '*.magik' + mimetypes 'text/x-magik', 'application/x-magik' + + def self.keywords + @keywords ||= %w( + _package + _pragma + _block _endblock + _handling _default + _protect _protection _endprotect + _try _with _when _endtry + _catch _endcatch + _throw + _lock _endlock + _if _then _elif _else _endif + _for _over _while _loop _finally _endloop _loopbody _continue _leave + _return + _class + _local _constant _recursive _global _dynamic _import + _private _iter _abstract _method _endmethod + _proc _endproc + _gather _scatter _allresults _optional + _thisthread _self _clone _super + _primitive + _unset _true _false _maybe + _is _isnt _not _and _or _xor _cf _andif _orif + _div _mod + ) + end + + def self.string_double + @string_double ||= /"[^"\n]*?"/ + end + def self.string_single + @string_single ||= /'[^'\n]*?'/ + end + + def self.digits + @digits ||= /[0-9]+/ + end + def self.radix + @radix ||= /r[0-9a-z]/i + end + def self.exponent + @exponent ||= /(e|&)[+-]?#{Magik.digits}/i + end + def self.decimal + @decimal ||= /\.#{Magik.digits}/ + end + def self.number + @number = /#{Magik.digits}(#{Magik.radix}|#{Magik.exponent}|#{Magik.decimal})*/ + end + + def self.character + @character ||= /%u[0-9a-z]{4}|%[^\s]+/i + end + + def self.simple_identifier + @simple_identifier ||= /(?>(?:[a-z0-9_!?]|\\.)+)/i + end + def self.piped_identifier + @piped_identifier ||= /\|[^\|\n]*\|/ + end + def self.identifier + @identifier ||= /(?:#{Magik.simple_identifier}|#{Magik.piped_identifier})+/i + end + def self.package_identifier + @package_identifier ||= /#{Magik.identifier}:#{Magik.identifier}/ + end + def self.symbol + @symbol ||= /:#{Magik.identifier}/i + end + def self.global_ref + @global_ref ||= /@[\s]*#{Magik.identifier}:#{Magik.identifier}/ + end + def self.label + @label = /@[\s]*#{Magik.identifier}/ + end + + state :root do + rule %r/##(.*)?/, Comment::Doc + rule %r/#(.*)?/, Comment::Single + + rule %r/(_method)(\s+)/ do + groups Keyword, Text::Whitespace + push :method_name + end + + rule %r/(?:#{Magik.keywords.join('|')})\b/, Keyword + + rule Magik.string_double, Literal::String + rule Magik.string_single, Literal::String + rule Magik.symbol, Str::Symbol + rule Magik.global_ref, Name::Label + rule Magik.label, Name::Label + rule Magik.character, Literal::String::Char + rule Magik.number, Literal::Number + rule Magik.package_identifier, Name + rule Magik.identifier, Name + + rule %r/[\[\]{}()\.,;]/, Punctuation + rule %r/\$/, Punctuation + rule %r/(<<|^<<)/, Operator + rule %r/(>>)/, Operator + rule %r/[-~+\/*%=&^<>]|!=/, Operator + + rule %r/[\s]+/, Text::Whitespace + end + + state :method_name do + rule %r/(#{Magik.identifier})(\.)(#{Magik.identifier})/ do + groups Name::Class, Punctuation, Name::Function + pop! + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/make.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/make.rb new file mode 100644 index 0000000..7320632 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/make.rb @@ -0,0 +1,144 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Make < RegexLexer + title "Make" + desc "Makefile syntax" + tag 'make' + aliases 'makefile', 'mf', 'gnumake', 'bsdmake' + filenames '*.make', '*.mak', '*.mk', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile', '*,fe1' + mimetypes 'text/x-makefile' + + def self.functions + @functions ||= %w( + abspath addprefix addsuffix and basename call dir error eval file + filter filter-out findstring firstword flavor foreach if join lastword + notdir or origin patsubst realpath shell sort strip subst suffix value + warning wildcard word wordlist words + ) + end + + def initialize(opts={}) + super + @shell = Shell.new(opts) + end + + start { @shell.reset! } + + state :root do + rule %r/\s+/, Text + + rule %r/#.*?\n/, Comment + + rule %r/([-s]?include)((?:[\t ]+[^\t\n #]+)+)/ do + groups Keyword, Literal::String::Other + end + + rule %r/((?:ifn?def|ifn?eq|unexport)\b)([\t ]+)([^#\n]+)/ do + groups Keyword, Text, Name::Variable + end + + rule %r/(?:else|endif|endef|endfor)[\t ]*(?=[#\n])/, Keyword + + rule %r/(export)([\t ]+)(?=[\w\${}()\t -]+\n)/ do + groups Keyword, Text + push :export + end + + rule %r/export[\t ]+/, Keyword + + # assignment + rule %r/(override\b)*([\t ]*)([\w${}().-]+)([\t ]*)([!?:+]?=)/m do |m| + groups Name::Builtin, Text, Name::Variable, Text, Operator + push :shell_line + end + + rule %r/"(\\\\|\\.|[^"\\])*"/, Str::Double + rule %r/'(\\\\|\\.|[^'\\])*'/, Str::Single + rule %r/([^\n:]+)(:+)([ \t]*)/ do + groups Name::Label, Operator, Text + push :block_header + end + + rule %r/(override\b)*([\t ])*(define)([\t ]+)([^#\n]+)/ do + groups Name::Builtin, Text, Keyword, Text, Name::Variable + end + + rule %r/(\$[({])([\t ]*)(#{Make.functions.join('|')})([\t ]+)/m do + groups Name::Function, Text, Name::Builtin, Text + push :shell_expr + end + end + + state :export do + rule %r/[\w\${}()-]/, Name::Variable + rule %r/\n/, Text, :pop! + rule %r/[\t ]+/, Text + end + + state :block_header do + rule %r/[^,\\\n#]+/, Name::Function + rule %r/,/, Punctuation + rule %r/#.*?/, Comment + rule %r/\\\n/, Text + rule %r/\\./, Text + rule %r/\n/ do + token Text + goto :block_body + end + end + + state :block_body do + rule %r/(ifn?def|ifn?eq)([\t ]+)([^#\n]+)(#.*)?(\n)/ do + groups Keyword, Text, Name::Variable, Comment, Text + end + + rule %r/(else|endif)([\t ]*)(#.*)?(\n)/ do + groups Keyword, Text, Comment, Text + end + + rule %r/(\t[\t ]*)([@-]?)/ do + groups Text, Punctuation + push :shell_line + end + + rule(//) { @shell.reset!; pop! } + end + + state :shell do + # macro interpolation + rule %r/[\$]{1,2}[({]/, Punctuation, :macro_expr + + # function invocation + rule %r/(\$[({])([\t ]*)(#{Make.functions.join('|')})([\t ]+)/m do + groups Punctuation, Text, Name::Builtin, Text + push :shell_expr + end + + rule(/\\./m) { delegate @shell } + stop = /[\$]{1,2}\(|[\$]{1,2}\{|\(|\)|\}|\\|$/ + rule(/.+?(?=#{stop})/m) { delegate @shell } + rule(stop) { delegate @shell } + end + + state :macro_expr do + rule %r/[)}]/, Punctuation, :pop! + rule %r/\n/, Text, :pop! + mixin :shell + end + + state :shell_expr do + rule(/[({]/) { delegate @shell; push } + rule %r/[)}]/, Punctuation, :pop! + mixin :shell + end + + state :shell_line do + rule %r/\n/, Text, :pop! + mixin :shell + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/markdown.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/markdown.rb new file mode 100644 index 0000000..7d0d2c4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/markdown.rb @@ -0,0 +1,183 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Markdown < RegexLexer + title "Markdown" + desc "Markdown, a light-weight markup language for authors" + + tag 'markdown' + aliases 'md', 'mkd' + filenames '*.markdown', '*.md', '*.mkd' + mimetypes 'text/x-markdown' + + def html + @html ||= HTML.new(options) + end + + start { html.reset! } + + edot = /\\.|[^\\\n]/ + + state :root do + # YAML frontmatter + rule(/\A(---\s*\n.*?\n?)^(---\s*$\n?)/m) { delegate YAML } + + rule %r/\\./, Str::Escape + + rule %r/^[\S ]+\n(?:---*)\n/, Generic::Heading + rule %r/^[\S ]+\n(?:===*)\n/, Generic::Subheading + + rule %r/^#(?=[^#]).*?$/, Generic::Heading + rule %r/^##*.*?$/, Generic::Subheading + + rule %r/^([ \t]*)(`{3,}|~{3,})([^\n]*\n)((.*?)(\n\1)(\2))?/m do |m| + name = m[3].strip + sublexer = + begin + Lexer.find_fancy(name.empty? ? "guess" : name, m[5], @options) + rescue Guesser::Ambiguous => e + e.alternatives.first.new(@options) + end + + sublexer ||= PlainText.new(@options.merge(:token => Str::Backtick)) + sublexer.reset! + + token Text, m[1] + token Punctuation, m[2] + token Name::Label, m[3] + if m[5] + delegate sublexer, m[5] + end + + token Text, m[6] + + if m[7] + token Punctuation, m[7] + else + push do + rule %r/^([ \t]*)(#{m[2]})/ do |mb| + pop! + token Text, mb[1] + token Punctuation, mb[2] + end + rule %r/^.*\n/ do |mb| + delegate sublexer, mb[1] + end + end + end + end + + rule %r/\n\n(( |\t).*?\n|\n)+/, Str::Backtick + + rule %r/(`+)(?:#{edot}|\n)+?\1/, Str::Backtick + + # various uses of * are in order of precedence + + # line breaks + rule %r/^(\s*[*]){3,}\s*$/, Punctuation + rule %r/^(\s*[-]){3,}\s*$/, Punctuation + + # bulleted lists + rule %r/^\s*[*+-](?=\s)/, Punctuation + + # numbered lists + rule %r/^\s*\d+\./, Punctuation + + # blockquotes + rule %r/^\s*>.*?$/, Generic::Traceback + + # link references + # [foo]: bar "baz" + rule %r(^ + (\s*) # leading whitespace + (\[) (#{edot}+?) (\]) # the reference + (\s*) (:) # colon + )x do + groups Text, Punctuation, Str::Symbol, Punctuation, Text, Punctuation + + push :title + push :url + end + + # links and images + rule %r/(!?\[)(#{edot}*?|[^\]]*?)(\])(?=[\[(])/ do + groups Punctuation, Name::Variable, Punctuation + push :link + end + + rule %r/[*]{2}[^* \n][^*\n]*[*]{2}/, Generic::Strong + rule %r/[*]{3}[^* \n][^*\n]*[*]{3}/, Generic::EmphStrong + rule %r/__#{edot}*?__/, Generic::Strong + + rule %r/[*]#{edot}*?[*]/, Generic::Emph + rule %r/_#{edot}*?_/, Generic::Emph + + # Automatic links + rule %r/<.*?@.+[.].+>/, Name::Variable + rule %r[<(https?|mailto|ftp)://#{edot}*?>], Name::Variable + + rule %r/[^\\`\[*\n&<]+/, Text + + # inline html + rule(/&\S*;/) { delegate html } + rule(/<#{edot}*?>/) { delegate html } + rule %r/[&<]/, Text + + # An opening square bracket that is not a link + rule %r/\[/, Text + + rule %r/\n/, Text + end + + state :link do + rule %r/(\[)(#{edot}*?)(\])/ do + groups Punctuation, Str::Symbol, Punctuation + pop! + end + + rule %r/[(]/ do + token Punctuation + push :inline_title + push :inline_url + end + + rule %r/[ \t]+/, Text + + rule(//) { pop! } + end + + state :url do + rule %r/[ \t]+/, Text + + # the url + rule %r/(<)(#{edot}*?)(>)/ do + groups Name::Tag, Str::Other, Name::Tag + pop! + end + + rule %r/\S+/, Str::Other, :pop! + end + + state :title do + rule %r/"#{edot}*?"/, Name::Namespace + rule %r/'#{edot}*?'/, Name::Namespace + rule %r/[(]#{edot}*?[)]/, Name::Namespace + rule %r/\s*(?=["'()])/, Text + rule(//) { pop! } + end + + state :inline_title do + rule %r/[)]/, Punctuation, :pop! + mixin :title + end + + state :inline_url do + rule %r/[^<\s)]+/, Str::Other, :pop! + rule %r/\s+/m, Text + mixin :url + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mason.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mason.rb new file mode 100644 index 0000000..06e9f9d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mason.rb @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Mason < TemplateLexer + title 'Mason' + desc 'The HTML::Mason framework (https://metacpan.org/pod/HTML::Mason)' + tag 'mason' + filenames '*.mi', '*.mc', '*.mas', '*.m', '*.mhtml', '*.mcomp', 'autohandler', 'dhandler' + mimetypes 'text/x-mason', 'application/x-mason' + + def initialize(*) + super + @perl = Perl.new + end + + # Note: If you add a tag in the lines below, you also need to modify "disambiguate '*.m'" in file disambiguation.rb + TEXT_BLOCKS = %w(text doc) + PERL_BLOCKS = %w(args flags attr init once shared perl cleanup filter) + COMPONENTS = %w(def method) + + state :root do + mixin :mason_tags + end + + state :mason_tags do + rule %r/\s+/, Text::Whitespace + + rule %r/<%(#{TEXT_BLOCKS.join('|')})>/oi, Comment::Preproc, :text_block + + rule %r/<%(#{PERL_BLOCKS.join('|')})>/oi, Comment::Preproc, :perl_block + + rule %r/(<%(#{COMPONENTS.join('|')}))([^>]*)(>)/oi do |m| + token Comment::Preproc, m[1] + token Name, m[3] + token Comment::Preproc, m[4] + push :component_block + end + + # perl line + rule %r/^(%)(.*)$/ do |m| + token Comment::Preproc, m[1] + delegate @perl, m[2] + end + + # start of component call + rule %r/<%/, Comment::Preproc, :component_call + + # start of component with content + rule %r/<&\|/ do + token Comment::Preproc + push :component_with_content + push :component_sub + end + + # start of component substitution + rule %r/<&/, Comment::Preproc, :component_sub + + # fallback to HTML until a mason tag is encountered + rule(/(.+?)(?=(<\/?&|<\/?%|^%|^#))/m) { delegate parent } + + # if we get here, there's no more mason tags, so we parse the rest of the doc as HTML + rule(/.+/m) { delegate parent } + end + + state :perl_block do + rule %r/<\/%(#{PERL_BLOCKS.join('|')})>/oi, Comment::Preproc, :pop! + rule %r/\s+/, Text::Whitespace + rule %r/^(#.*)$/, Comment + rule(/(.*?[^"])(?=<\/%)/m) { delegate @perl } + end + + state :text_block do + rule %r/<\/%(#{TEXT_BLOCKS.join('|')})>/oi, Comment::Preproc, :pop! + rule %r/\s+/, Text::Whitespace + rule %r/^(#.*)$/, Comment + rule %r/(.*?[^"])(?=<\/%)/m, Comment + end + + state :component_block do + rule %r/<\/%(#{COMPONENTS.join('|')})>/oi, Comment::Preproc, :pop! + rule %r/\s+/, Text::Whitespace + rule %r/^(#.*)$/, Comment + mixin :mason_tags + end + + state :component_with_content do + rule %r/<\/&>/ do + token Comment::Preproc + pop! + end + + mixin :mason_tags + end + + state :component_sub do + rule %r/&>/, Comment::Preproc, :pop! + + rule(/(.*?)(?=&>)/m) { delegate @perl } + end + + state :component_call do + rule %r/%>/, Comment::Preproc, :pop! + + rule(/(.*?)(?=%>)/m) { delegate @perl } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mathematica.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mathematica.rb new file mode 100644 index 0000000..cb6d3b5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mathematica.rb @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Mathematica < RegexLexer + title "Mathematica" + desc "Wolfram Mathematica, the world's definitive system for modern technical computing." + tag 'mathematica' + aliases 'wl', 'wolfram' + filenames '*.m', '*.wl' + mimetypes 'application/vnd.wolfram.mathematica.package', 'application/vnd.wolfram.wl' + + # Mathematica has various input forms for numbers. We need to handle numbers in bases, precision, accuracy, + # and *^ scientific notation. All this works for integers and real numbers. Some examples + # 1 1234567 1.1 .3 0.2 1*^10 2*^+10 3*^-10 + # 1`1 1``1 1.2` 1.2``1.234*^-10 1.2``1.234*^+10 1.2``1.234*^10 + # 2^^01001 10^^1.2``20.1234*^-10 + base = /(?:\d+)/ + number = /(?:\.\d+|\d+\.\d*|\d+)/ + number_base = /(?:\.\w+|\w+\.\w*|\w+)/ + precision = /`(`?#{number})?/ + + operators = /[+\-*\/|,;.:@~=><&`'^?!_%]/ + braces = /[\[\](){}]/ + + string = /"(\\\\|\\"|[^"])*"/ + + # symbols and namespaced symbols. Note the special form \[Gamma] for named characters. These are also symbols. + # Module With Block Integrate Table Plot + # x32 $x x$ $Context` Context123`$x `Private`Context + # \[Gamma] \[Alpha]x32 Context`\[Xi] + identifier = /[a-zA-Z$][$a-zA-Z0-9]*/ + named_character = /\\\[#{identifier}\]/ + symbol = /(#{identifier}|#{named_character})+/ + context_symbol = /`?#{symbol}(`#{symbol})*`?/ + + # Slots for pure functions. + # Examples: # ## #1 ##3 #Test #"Test" #[Test] #["Test"] + association_slot = /#(#{identifier}|\"#{identifier}\")/ + slot = /#{association_slot}|#[0-9]*/ + + # Handling of message like symbol::usage or symbol::"argx" + message = /::(#{identifier}|#{string})/ + + # Highlighting of the special in and out markers that are prepended when you copy a cell + in_out = /(In|Out)\[[0-9]+\]:?=/ + + # Although Module, With and Block are normal built-in symbols, we give them a special treatment as they are + # the most important expressions for defining local variables + def self.keywords + @keywords = Set.new %w( + Module With Block + ) + end + + # The list of built-in symbols comes from a wolfram server and is created automatically by rake + def self.builtins + Kernel::load File.join(Lexers::BASE_DIR, 'mathematica/keywords.rb') + builtins + end + + state :root do + rule %r/\s+/, Text::Whitespace + rule %r/\(\*/, Comment, :comment + rule %r/#{base}\^\^#{number_base}#{precision}?(\*\^[+-]?\d+)?/, Num # a number with a base + rule %r/(?:#{number}#{precision}?(?:\*\^[+-]?\d+)?)/, Num # all other numbers + rule message, Name::Tag + rule in_out, Generic::Prompt + rule %r/#{context_symbol}/m do |m| + match = m[0] + if self.class.keywords.include? match + token Name::Builtin::Pseudo + elsif self.class.builtins.include? match + token Name::Builtin + else + token Name::Variable + end + end + rule slot, Name::Function + rule operators, Operator + rule braces, Punctuation + rule string, Str + end + + # Allow for nested comments and special treatment of ::Section:: or :Author: markup + state :comment do + rule %r/\(\*/, Comment, :comment + rule %r/\*\)/, Comment, :pop! + rule %r/::#{identifier}::/, Comment::Preproc + rule %r/[ ]:(#{identifier}|[^\S])+:[ ]/, Comment::Preproc + rule %r/./, Comment + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mathematica/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mathematica/keywords.rb new file mode 100644 index 0000000..95fdd61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mathematica/keywords.rb @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# DO NOT EDIT + +# This file is automatically generated by `rake builtins:mathematica`. +# See tasks/builtins/mathematica.rake for more info. + +module Rouge + module Lexers + class Mathematica + def self.builtins + @builtins ||= Set.new ["AASTriangle", "AngleVector", "AsymptoticDSolveValue", "AbelianGroup", "AngularGauge", "AsymptoticEqual", "Abort", "Animate", "AsymptoticEquivalent", "AbortKernels", "AnimationDirection", "AsymptoticGreater", "AbortProtect", "AnimationRate", "AsymptoticGreaterEqual", "Above", "AnimationRepetitions", "AsymptoticIntegrate", "Abs", "AnimationRunning", "AsymptoticLess", "AbsArg", "AnimationRunTime", "AsymptoticLessEqual", "AbsArgPlot", "AnimationTimeIndex", "AsymptoticOutputTracker", "AbsoluteCorrelation", "Animator", "AsymptoticProduct", "AbsoluteCorrelationFunction", "Annotate", "AsymptoticRSolveValue", "AbsoluteCurrentValue", "Annotation", "AsymptoticSolve", "AbsoluteDashing", "AnnotationDelete", "AsymptoticSum", "AbsoluteFileName", "AnnotationKeys", "Asynchronous", "AbsoluteOptions", "AnnotationRules", "Atom", "AbsolutePointSize", "AnnotationValue", "AtomCoordinates", "AbsoluteThickness", "Annuity", "AtomCount", "AbsoluteTime", "AnnuityDue", "AtomDiagramCoordinates", "AbsoluteTiming", "Annulus", "AtomList", "AcceptanceThreshold", "AnomalyDetection", "AtomQ", "AccountingForm", "AnomalyDetector", "AttentionLayer", "Accumulate", "AnomalyDetectorFunction", "Attributes", "Accuracy", "Anonymous", "Audio", "AccuracyGoal", "Antialiasing", "AudioAmplify", "ActionMenu", "AntihermitianMatrixQ", "AudioAnnotate", "Activate", "Antisymmetric", "AudioAnnotationLookup", "ActiveClassification", "AntisymmetricMatrixQ", "AudioBlockMap", "ActiveClassificationObject", "Antonyms", "AudioCapture", "ActivePrediction", "AnyOrder", "AudioChannelAssignment", "ActivePredictionObject", "AnySubset", "AudioChannelCombine", "ActiveStyle", "AnyTrue", "AudioChannelMix", "AcyclicGraphQ", "Apart", "AudioChannels", "AddSides", "ApartSquareFree", "AudioChannelSeparate", "AddTo", "APIFunction", "AudioData", "AddToSearchIndex", "Appearance", "AudioDelay", "AddUsers", "AppearanceElements", "AudioDelete", "AdjacencyGraph", "AppearanceRules", "AudioDistance", "AdjacencyList", "AppellF1", "AudioEncoding", "AdjacencyMatrix", "Append", "AudioFade", "AdjacentMeshCells", "AppendLayer", "AudioFrequencyShift", "AdjustmentBox", "AppendTo", "AudioGenerator", "AdjustmentBoxOptions", "Apply", "AudioIdentify", "AdjustTimeSeriesForecast", "ApplySides", "AudioInputDevice", "AdministrativeDivisionData", "ArcCos", "AudioInsert", "AffineHalfSpace", "ArcCosh", "AudioInstanceQ", "AffineSpace", "ArcCot", "AudioIntervals", "AffineStateSpaceModel", "ArcCoth", "AudioJoin", "AffineTransform", "ArcCsc", "AudioLabel", "After", "ArcCsch", "AudioLength", "AggregatedEntityClass", "ArcCurvature", "AudioLocalMeasurements", "AggregationLayer", "ARCHProcess", "AudioLoudness", "AircraftData", "ArcLength", "AudioMeasurements", "AirportData", "ArcSec", "AudioNormalize", "AirPressureData", "ArcSech", "AudioOutputDevice", "AirTemperatureData", "ArcSin", "AudioOverlay", "AiryAi", "ArcSinDistribution", "AudioPad", "AiryAiPrime", "ArcSinh", "AudioPan", "AiryAiZero", "ArcTan", "AudioPartition", "AiryBi", "ArcTanh", "AudioPause", "AiryBiPrime", "Area", "AudioPitchShift", "AiryBiZero", "Arg", "AudioPlay", "AlgebraicIntegerQ", "ArgMax", "AudioPlot", "AlgebraicNumber", "ArgMin", "AudioQ", "AlgebraicNumberDenominator", "ARIMAProcess", "AudioRecord", "AlgebraicNumberNorm", "ArithmeticGeometricMean", "AudioReplace", "AlgebraicNumberPolynomial", "ARMAProcess", "AudioResample", "AlgebraicNumberTrace", "Around", "AudioReverb", "Algebraics", "AroundReplace", "AudioReverse", "AlgebraicUnitQ", "ARProcess", "AudioSampleRate", "Alignment", "Array", "AudioSpectralMap", "AlignmentPoint", "ArrayComponents", "AudioSpectralTransformation", "All", "ArrayDepth", "AudioSplit", "AllowedCloudExtraParameters", "ArrayFilter", "AudioStop", "AllowedCloudParameterExtensions", "ArrayFlatten", "AudioStream", "AllowedDimensions", "ArrayMesh", "AudioStreams", "AllowedFrequencyRange", "ArrayPad", "AudioTimeStretch", "AllowedHeads", "ArrayPlot", "AudioTracks", "AllowGroupClose", "ArrayQ", "AudioTrim", "AllowInlineCells", "ArrayResample", "AudioType", "AllowLooseGrammar", "ArrayReshape", "AugmentedPolyhedron", "AllowReverseGroupClose", "ArrayRules", "AugmentedSymmetricPolynomial", "AllowVersionUpdate", "Arrays", "Authentication", "AllTrue", "Arrow", "AuthenticationDialog", "Alphabet", "Arrowheads", "AutoAction", "AlphabeticOrder", "ASATriangle", "Autocomplete", "AlphabeticSort", "Ask", "AutocompletionFunction", "AlphaChannel", "AskAppend", "AutoCopy", "AlternatingFactorial", "AskConfirm", "AutocorrelationTest", "AlternatingGroup", "AskDisplay", "AutoDelete", "AlternativeHypothesis", "AskedQ", "AutoIndent", "Alternatives", "AskedValue", "AutoItalicWords", "AltitudeMethod", "AskFunction", "Automatic", "AmbiguityFunction", "AskState", "AutoMultiplicationSymbol", "AmbiguityList", "AskTemplateDisplay", "AutoRefreshed", "AnatomyData", "AspectRatio", "AutoRemove", "AnatomyPlot3D", "Assert", "AutorunSequencing", "AnatomySkinStyle", "AssociateTo", "AutoScroll", "AnatomyStyling", "Association", "AutoSpacing", "AnchoredSearch", "AssociationFormat", "AutoSubmitting", "And", "AssociationMap", "Axes", "AndersonDarlingTest", "AssociationQ", "AxesEdge", "AngerJ", "AssociationThread", "AxesLabel", "AngleBisector", "AssumeDeterministic", "AxesOrigin", "AngleBracket", "Assuming", "AxesStyle", "AnglePath", "Assumptions", "AxiomaticTheory", "AnglePath3D", "Asymptotic", "Axis", "BabyMonsterGroupB", "BezierFunction", "BooleanCountingFunction", "Back", "BilateralFilter", "BooleanFunction", "Background", "Binarize", "BooleanGraph", "Backslash", "BinaryDeserialize", "BooleanMaxterms", "Backward", "BinaryDistance", "BooleanMinimize", "Ball", "BinaryFormat", "BooleanMinterms", "Band", "BinaryImageQ", "BooleanQ", "BandpassFilter", "BinaryRead", "BooleanRegion", "BandstopFilter", "BinaryReadList", "Booleans", "BarabasiAlbertGraphDistribution", "BinarySerialize", "BooleanStrings", "BarChart", "BinaryWrite", "BooleanTable", "BarChart3D", "BinCounts", "BooleanVariables", "BarcodeImage", "BinLists", "BorderDimensions", "BarcodeRecognize", "Binomial", "BorelTannerDistribution", "BaringhausHenzeTest", "BinomialDistribution", "Bottom", "BarLegend", "BinomialProcess", "BottomHatTransform", "BarlowProschanImportance", "BinormalDistribution", "BoundaryDiscretizeGraphics", "BarnesG", "BiorthogonalSplineWavelet", "BoundaryDiscretizeRegion", "BarOrigin", "BipartiteGraphQ", "BoundaryMesh", "BarSpacing", "BiquadraticFilterModel", "BoundaryMeshRegion", "BartlettHannWindow", "BirnbaumImportance", "BoundaryMeshRegionQ", "BartlettWindow", "BirnbaumSaundersDistribution", "BoundaryStyle", "BaseDecode", "BitAnd", "BoundedRegionQ", "BaseEncode", "BitClear", "BoundingRegion", "BaseForm", "BitGet", "BoxData", "Baseline", "BitLength", "Boxed", "BaselinePosition", "BitNot", "Boxes", "BaseStyle", "BitOr", "BoxMatrix", "BasicRecurrentLayer", "BitSet", "BoxObject", "BatchNormalizationLayer", "BitShiftLeft", "BoxRatios", "BatchSize", "BitShiftRight", "BoxStyle", "BatesDistribution", "BitXor", "BoxWhiskerChart", "BattleLemarieWavelet", "BiweightLocation", "BracketingBar", "BayesianMaximization", "BiweightMidvariance", "BrayCurtisDistance", "BayesianMaximizationObject", "Black", "BreadthFirstScan", "BayesianMinimization", "BlackmanHarrisWindow", "Break", "BayesianMinimizationObject", "BlackmanNuttallWindow", "BridgeData", "Because", "BlackmanWindow", "BrightnessEqualize", "BeckmannDistribution", "Blank", "BroadcastStationData", "Beep", "BlankNullSequence", "Brown", "Before", "BlankSequence", "BrownForsytheTest", "Begin", "Blend", "BrownianBridgeProcess", "BeginDialogPacket", "Block", "BSplineBasis", "BeginPackage", "BlockchainAddressData", "BSplineCurve", "BellB", "BlockchainBase", "BSplineFunction", "BellY", "BlockchainBlockData", "BSplineSurface", "Below", "BlockchainContractValue", "BubbleChart", "BenfordDistribution", "BlockchainData", "BubbleChart3D", "BeniniDistribution", "BlockchainGet", "BubbleScale", "BenktanderGibratDistribution", "BlockchainKeyEncode", "BubbleSizes", "BenktanderWeibullDistribution", "BlockchainPut", "BuildingData", "BernoulliB", "BlockchainTokenData", "BulletGauge", "BernoulliDistribution", "BlockchainTransaction", "BusinessDayQ", "BernoulliGraphDistribution", "BlockchainTransactionData", "ButterflyGraph", "BernoulliProcess", "BlockchainTransactionSign", "ButterworthFilterModel", "BernsteinBasis", "BlockchainTransactionSubmit", "Button", "BesselFilterModel", "BlockMap", "ButtonBar", "BesselI", "BlockRandom", "ButtonBox", "BesselJ", "BlomqvistBeta", "ButtonBoxOptions", "BesselJZero", "BlomqvistBetaTest", "ButtonData", "BesselK", "Blue", "ButtonFunction", "BesselY", "Blur", "ButtonMinHeight", "BesselYZero", "BodePlot", "ButtonNotebook", "Beta", "BohmanWindow", "ButtonSource", "BetaBinomialDistribution", "Bold", "Byte", "BetaDistribution", "Bond", "ByteArray", "BetaNegativeBinomialDistribution", "BondCount", "ByteArrayFormat", "BetaPrimeDistribution", "BondList", "ByteArrayQ", "BetaRegularized", "BondQ", "ByteArrayToString", "Between", "Bookmarks", "ByteCount", "BetweennessCentrality", "Boole", "ByteOrdering", "BeveledPolyhedron", "BooleanConsecutiveFunction", "BezierCurve", "BooleanConvert", "C", "ClearSystemCache", "Construct", "CachePersistence", "ClebschGordan", "Containing", "CalendarConvert", "ClickPane", "ContainsAll", "CalendarData", "Clip", "ContainsAny", "CalendarType", "ClippingStyle", "ContainsExactly", "Callout", "ClipPlanes", "ContainsNone", "CalloutMarker", "ClipPlanesStyle", "ContainsOnly", "CalloutStyle", "ClipRange", "ContentFieldOptions", "CallPacket", "Clock", "ContentLocationFunction", "CanberraDistance", "ClockGauge", "ContentObject", "Cancel", "Close", "ContentPadding", "CancelButton", "CloseKernels", "ContentSelectable", "CandlestickChart", "ClosenessCentrality", "ContentSize", "CanonicalGraph", "Closing", "Context", "CanonicalizePolygon", "CloudAccountData", "Contexts", "CanonicalizePolyhedron", "CloudBase", "ContextToFileName", "CanonicalName", "CloudConnect", "Continue", "CanonicalWarpingCorrespondence", "CloudDeploy", "ContinuedFraction", "CanonicalWarpingDistance", "CloudDirectory", "ContinuedFractionK", "CantorMesh", "CloudDisconnect", "ContinuousAction", "CantorStaircase", "CloudEvaluate", "ContinuousMarkovProcess", "Cap", "CloudExport", "ContinuousTask", "CapForm", "CloudExpression", "ContinuousTimeModelQ", "CapitalDifferentialD", "CloudExpressions", "ContinuousWaveletData", "Capitalize", "CloudFunction", "ContinuousWaveletTransform", "CapsuleShape", "CloudGet", "ContourDetect", "CaptureRunning", "CloudImport", "ContourLabels", "CarlemanLinearize", "CloudLoggingData", "ContourPlot", "CarmichaelLambda", "CloudObject", "ContourPlot3D", "CaseOrdering", "CloudObjectNameFormat", "Contours", "Cases", "CloudObjects", "ContourShading", "CaseSensitive", "CloudObjectURLType", "ContourStyle", "Cashflow", "CloudPublish", "ContraharmonicMean", "Casoratian", "CloudPut", "ContrastiveLossLayer", "Catalan", "CloudRenderingMethod", "Control", "CatalanNumber", "CloudSave", "ControlActive", "Catch", "CloudShare", "ControllabilityGramian", "CategoricalDistribution", "CloudSubmit", "ControllabilityMatrix", "Catenate", "CloudSymbol", "ControllableDecomposition", "CatenateLayer", "CloudUnshare", "ControllableModelQ", "CauchyDistribution", "ClusterClassify", "ControllerInformation", "CauchyWindow", "ClusterDissimilarityFunction", "ControllerLinking", "CayleyGraph", "ClusteringComponents", "ControllerManipulate", "CDF", "ClusteringTree", "ControllerMethod", "CDFDeploy", "CMYKColor", "ControllerPath", "CDFWavelet", "CodeAssistOptions", "ControllerState", "Ceiling", "Coefficient", "ControlPlacement", "CelestialSystem", "CoefficientArrays", "ControlsRendering", "Cell", "CoefficientList", "ControlType", "CellAutoOverwrite", "CoefficientRules", "Convergents", "CellBaseline", "CoifletWavelet", "ConversionRules", "CellBracketOptions", "Collect", "ConvexHullMesh", "CellChangeTimes", "Colon", "ConvexPolygonQ", "CellContext", "ColorBalance", "ConvexPolyhedronQ", "CellDingbat", "ColorCombine", "ConvolutionLayer", "CellDynamicExpression", "ColorConvert", "Convolve", "CellEditDuplicate", "ColorCoverage", "ConwayGroupCo1", "CellEpilog", "ColorData", "ConwayGroupCo2", "CellEvaluationDuplicate", "ColorDataFunction", "ConwayGroupCo3", "CellEvaluationFunction", "ColorDetect", "CookieFunction", "CellEventActions", "ColorDistance", "CoordinateBoundingBox", "CellFrame", "ColorFunction", "CoordinateBoundingBoxArray", "CellFrameColor", "ColorFunctionScaling", "CoordinateBounds", "CellFrameLabelMargins", "Colorize", "CoordinateBoundsArray", "CellFrameLabels", "ColorNegate", "CoordinateChartData", "CellFrameMargins", "ColorProfileData", "CoordinatesToolOptions", "CellGroup", "ColorQ", "CoordinateTransform", "CellGroupData", "ColorQuantize", "CoordinateTransformData", "CellGrouping", "ColorReplace", "CoprimeQ", "CellID", "ColorRules", "Coproduct", "CellLabel", "ColorSeparate", "CopulaDistribution", "CellLabelAutoDelete", "ColorSetter", "Copyable", "CellLabelStyle", "ColorSlider", "CopyDatabin", "CellMargins", "ColorsNear", "CopyDirectory", "CellObject", "ColorSpace", "CopyFile", "CellOpen", "ColorToneMapping", "CopyToClipboard", "CellPrint", "Column", "CornerFilter", "CellProlog", "ColumnAlignments", "CornerNeighbors", "Cells", "ColumnLines", "Correlation", "CellStyle", "ColumnsEqual", "CorrelationDistance", "CellTags", "ColumnSpacings", "CorrelationFunction", "CellularAutomaton", "ColumnWidths", "CorrelationTest", "CensoredDistribution", "CombinedEntityClass", "Cos", "Censoring", "CombinerFunction", "Cosh", "Center", "CometData", "CoshIntegral", "CenterArray", "Commonest", "CosineDistance", "CenterDot", "CommonestFilter", "CosineWindow", "CentralFeature", "CommonName", "CosIntegral", "CentralMoment", "CommonUnits", "Cot", "CentralMomentGeneratingFunction", "CommunityBoundaryStyle", "Coth", "Cepstrogram", "CommunityGraphPlot", "Count", "CepstrogramArray", "CommunityLabels", "CountDistinct", "CepstrumArray", "CommunityRegionStyle", "CountDistinctBy", "CForm", "CompanyData", "CountRoots", "ChampernowneNumber", "CompatibleUnitQ", "CountryData", "ChannelBase", "CompilationOptions", "Counts", "ChannelBrokerAction", "CompilationTarget", "CountsBy", "ChannelHistoryLength", "Compile", "Covariance", "ChannelListen", "Compiled", "CovarianceEstimatorFunction", "ChannelListener", "CompiledCodeFunction", "CovarianceFunction", "ChannelListeners", "CompiledFunction", "CoxianDistribution", "ChannelObject", "CompilerOptions", "CoxIngersollRossProcess", "ChannelReceiverFunction", "Complement", "CoxModel", "ChannelSend", "ComplementedEntityClass", "CoxModelFit", "ChannelSubscribers", "CompleteGraph", "CramerVonMisesTest", "ChanVeseBinarize", "CompleteGraphQ", "CreateArchive", "Character", "CompleteKaryTree", "CreateCellID", "CharacterCounts", "Complex", "CreateChannel", "CharacterEncoding", "ComplexContourPlot", "CreateCloudExpression", "CharacteristicFunction", "Complexes", "CreateDatabin", "CharacteristicPolynomial", "ComplexExpand", "CreateDataStructure", "CharacterName", "ComplexInfinity", "CreateDataSystemModel", "CharacterNormalize", "ComplexityFunction", "CreateDialog", "CharacterRange", "ComplexListPlot", "CreateDirectory", "Characters", "ComplexPlot", "CreateDocument", "ChartBaseStyle", "ComplexPlot3D", "CreateFile", "ChartElementFunction", "ComplexRegionPlot", "CreateIntermediateDirectories", "ChartElements", "ComplexStreamPlot", "CreateManagedLibraryExpression", "ChartLabels", "ComplexVectorPlot", "CreateNotebook", "ChartLayout", "ComponentMeasurements", "CreatePacletArchive", "ChartLegends", "ComposeList", "CreatePalette", "ChartStyle", "ComposeSeries", "CreatePermissionsGroup", "Chebyshev1FilterModel", "CompositeQ", "CreateSearchIndex", "Chebyshev2FilterModel", "Composition", "CreateSystemModel", "ChebyshevT", "CompoundElement", "CreateUUID", "ChebyshevU", "CompoundExpression", "CreateWindow", "Check", "CompoundPoissonDistribution", "CriterionFunction", "CheckAbort", "CompoundPoissonProcess", "CriticalityFailureImportance", "Checkbox", "CompoundRenewalProcess", "CriticalitySuccessImportance", "CheckboxBar", "Compress", "CriticalSection", "ChemicalData", "CompressionLevel", "Cross", "ChessboardDistance", "ComputeUncertainty", "CrossEntropyLossLayer", "ChiDistribution", "Condition", "CrossingCount", "ChineseRemainder", "ConditionalExpression", "CrossingDetect", "ChiSquareDistribution", "Conditioned", "CrossingPolygon", "ChoiceButtons", "Cone", "CrossMatrix", "ChoiceDialog", "ConfidenceLevel", "Csc", "CholeskyDecomposition", "ConfidenceRange", "Csch", "Chop", "ConfidenceTransform", "CTCLossLayer", "ChromaticityPlot", "ConformAudio", "Cube", "ChromaticityPlot3D", "ConformImages", "CubeRoot", "ChromaticPolynomial", "Congruent", "Cubics", "Circle", "ConicHullRegion", "Cuboid", "CircleDot", "ConicOptimization", "Cumulant", "CircleMinus", "Conjugate", "CumulantGeneratingFunction", "CirclePlus", "ConjugateTranspose", "Cup", "CirclePoints", "Conjunction", "CupCap", "CircleThrough", "ConnectedComponents", "Curl", "CircleTimes", "ConnectedGraphComponents", "CurrencyConvert", "CirculantGraph", "ConnectedGraphQ", "CurrentDate", "CircularOrthogonalMatrixDistribution", "ConnectedMeshComponents", "CurrentImage", "CircularQuaternionMatrixDistribution", "ConnectedMoleculeComponents", "CurrentNotebookImage", "CircularRealMatrixDistribution", "ConnectedMoleculeQ", "CurrentScreenImage", "CircularSymplecticMatrixDistribution", "ConnectionSettings", "CurrentValue", "CircularUnitaryMatrixDistribution", "ConnectLibraryCallbackFunction", "CurryApplied", "Circumsphere", "ConnectSystemModelComponents", "CurvatureFlowFilter", "CityData", "ConnesWindow", "CurveClosed", "ClassifierFunction", "ConoverTest", "Cyan", "ClassifierMeasurements", "Constant", "CycleGraph", "ClassifierMeasurementsObject", "ConstantArray", "CycleIndexPolynomial", "Classify", "ConstantArrayLayer", "Cycles", "ClassPriors", "ConstantImage", "CyclicGroup", "Clear", "ConstantPlusLayer", "Cyclotomic", "ClearAll", "ConstantRegionQ", "Cylinder", "ClearAttributes", "Constants", "CylindricalDecomposition", "ClearCookies", "ConstantTimesLayer", "ClearPermissions", "ConstellationData", "D", "DeleteFile", "DiscreteLyapunovSolve", "DagumDistribution", "DeleteMissing", "DiscreteMarkovProcess", "DamData", "DeleteObject", "DiscreteMaxLimit", "DamerauLevenshteinDistance", "DeletePermissionsKey", "DiscreteMinLimit", "Darker", "DeleteSearchIndex", "DiscretePlot", "Dashed", "DeleteSmallComponents", "DiscretePlot3D", "Dashing", "DeleteStopwords", "DiscreteRatio", "DatabaseConnect", "DelimitedSequence", "DiscreteRiccatiSolve", "DatabaseDisconnect", "Delimiter", "DiscreteShift", "DatabaseReference", "DelimiterFlashTime", "DiscreteTimeModelQ", "Databin", "Delimiters", "DiscreteUniformDistribution", "DatabinAdd", "DeliveryFunction", "DiscreteVariables", "DatabinRemove", "Dendrogram", "DiscreteWaveletData", "Databins", "Denominator", "DiscreteWaveletPacketTransform", "DatabinUpload", "DensityHistogram", "DiscreteWaveletTransform", "DataDistribution", "DensityPlot", "DiscretizeGraphics", "DataRange", "DensityPlot3D", "DiscretizeRegion", "DataReversed", "DependentVariables", "Discriminant", "Dataset", "Deploy", "DisjointQ", "DataStructure", "Deployed", "Disjunction", "DataStructureQ", "Depth", "Disk", "DateBounds", "DepthFirstScan", "DiskMatrix", "Dated", "Derivative", "DiskSegment", "DateDifference", "DerivativeFilter", "Dispatch", "DatedUnit", "DerivedKey", "DispersionEstimatorFunction", "DateFormat", "DescriptorStateSpace", "DisplayAllSteps", "DateFunction", "DesignMatrix", "DisplayEndPacket", "DateHistogram", "Det", "DisplayForm", "DateInterval", "DeviceClose", "DisplayFunction", "DateList", "DeviceConfigure", "DisplayPacket", "DateListLogPlot", "DeviceExecute", "DistanceFunction", "DateListPlot", "DeviceExecuteAsynchronous", "DistanceMatrix", "DateListStepPlot", "DeviceObject", "DistanceTransform", "DateObject", "DeviceOpen", "Distribute", "DateObjectQ", "DeviceRead", "Distributed", "DateOverlapsQ", "DeviceReadBuffer", "DistributedContexts", "DatePattern", "DeviceReadLatest", "DistributeDefinitions", "DatePlus", "DeviceReadList", "DistributionChart", "DateRange", "DeviceReadTimeSeries", "DistributionFitTest", "DateReduction", "Devices", "DistributionParameterAssumptions", "DateString", "DeviceStreams", "DistributionParameterQ", "DateTicksFormat", "DeviceWrite", "Dithering", "DateValue", "DeviceWriteBuffer", "Div", "DateWithinQ", "DGaussianWavelet", "Divide", "DaubechiesWavelet", "Diagonal", "DivideBy", "DavisDistribution", "DiagonalizableMatrixQ", "Dividers", "DawsonF", "DiagonalMatrix", "DivideSides", "DayCount", "DiagonalMatrixQ", "Divisible", "DayCountConvention", "Dialog", "Divisors", "DayHemisphere", "DialogInput", "DivisorSigma", "DaylightQ", "DialogNotebook", "DivisorSum", "DayMatchQ", "DialogProlog", "DMSList", "DayName", "DialogReturn", "DMSString", "DayNightTerminator", "DialogSymbols", "Do", "DayPlus", "Diamond", "DockedCells", "DayRange", "DiamondMatrix", "DocumentGenerator", "DayRound", "DiceDissimilarity", "DocumentGeneratorInformation", "DeBruijnGraph", "DictionaryLookup", "DocumentGenerators", "DeBruijnSequence", "DictionaryWordQ", "DocumentNotebook", "Decapitalize", "DifferenceDelta", "DocumentWeightingRules", "DecimalForm", "DifferenceQuotient", "Dodecahedron", "DeclarePackage", "DifferenceRoot", "DominantColors", "Decompose", "DifferenceRootReduce", "Dot", "DeconvolutionLayer", "Differences", "DotDashed", "Decrement", "DifferentialD", "DotEqual", "Decrypt", "DifferentialRoot", "DotLayer", "DecryptFile", "DifferentialRootReduce", "Dotted", "DedekindEta", "DifferentiatorFilter", "DoubleBracketingBar", "DeepSpaceProbeData", "DigitalSignature", "DoubleDownArrow", "Default", "DigitBlock", "DoubleLeftArrow", "DefaultAxesStyle", "DigitCharacter", "DoubleLeftRightArrow", "DefaultBaseStyle", "DigitCount", "DoubleLeftTee", "DefaultBoxStyle", "DigitQ", "DoubleLongLeftArrow", "DefaultButton", "DihedralAngle", "DoubleLongLeftRightArrow", "DefaultDuplicateCellStyle", "DihedralGroup", "DoubleLongRightArrow", "DefaultDuration", "Dilation", "DoubleRightArrow", "DefaultElement", "DimensionalCombinations", "DoubleRightTee", "DefaultFaceGridsStyle", "DimensionalMeshComponents", "DoubleUpArrow", "DefaultFieldHintStyle", "DimensionReduce", "DoubleUpDownArrow", "DefaultFrameStyle", "DimensionReducerFunction", "DoubleVerticalBar", "DefaultFrameTicksStyle", "DimensionReduction", "DownArrow", "DefaultGridLinesStyle", "Dimensions", "DownArrowBar", "DefaultLabelStyle", "DiracComb", "DownArrowUpArrow", "DefaultMenuStyle", "DiracDelta", "DownLeftRightVector", "DefaultNaturalLanguage", "DirectedEdge", "DownLeftTeeVector", "DefaultNewCellStyle", "DirectedEdges", "DownLeftVector", "DefaultOptions", "DirectedGraph", "DownLeftVectorBar", "DefaultPrintPrecision", "DirectedGraphQ", "DownRightTeeVector", "DefaultTicksStyle", "DirectedInfinity", "DownRightVector", "DefaultTooltipStyle", "Direction", "DownRightVectorBar", "Defer", "Directive", "Downsample", "DefineInputStreamMethod", "Directory", "DownTee", "DefineOutputStreamMethod", "DirectoryName", "DownTeeArrow", "DefineResourceFunction", "DirectoryQ", "DownValues", "Definition", "DirectoryStack", "Drop", "Degree", "DirichletBeta", "DropoutLayer", "DegreeCentrality", "DirichletCharacter", "DSolve", "DegreeGraphDistribution", "DirichletCondition", "DSolveValue", "DEigensystem", "DirichletConvolve", "Dt", "DEigenvalues", "DirichletDistribution", "DualPolyhedron", "Deinitialization", "DirichletEta", "DualSystemsModel", "Del", "DirichletL", "DumpSave", "DelaunayMesh", "DirichletLambda", "DuplicateFreeQ", "Delayed", "DirichletTransform", "Duration", "Deletable", "DirichletWindow", "Dynamic", "Delete", "DisableFormatting", "DynamicEvaluationTimeout", "DeleteAnomalies", "DiscreteAsymptotic", "DynamicGeoGraphics", "DeleteBorderComponents", "DiscreteChirpZTransform", "DynamicImage", "DeleteCases", "DiscreteConvolve", "DynamicModule", "DeleteChannel", "DiscreteDelta", "DynamicModuleValues", "DeleteCloudExpression", "DiscreteHadamardTransform", "DynamicSetting", "DeleteContents", "DiscreteIndicator", "DynamicUpdating", "DeleteDirectory", "DiscreteLimit", "DynamicWrapper", "DeleteDuplicates", "DiscreteLQEstimatorGains", "DeleteDuplicatesBy", "DiscreteLQRegulatorGains", "E", "EndOfFile", "EventHandler", "EarthImpactData", "EndOfLine", "EventLabels", "EarthquakeData", "EndOfString", "EventSeries", "EccentricityCentrality", "EndPackage", "ExactBlackmanWindow", "Echo", "EngineeringForm", "ExactNumberQ", "EchoFunction", "EnterExpressionPacket", "ExampleData", "EclipseType", "EnterTextPacket", "Except", "EdgeAdd", "Entity", "ExcludedForms", "EdgeBetweennessCentrality", "EntityClass", "ExcludedLines", "EdgeCapacity", "EntityClassList", "ExcludedPhysicalQuantities", "EdgeConnectivity", "EntityCopies", "ExcludePods", "EdgeContract", "EntityFunction", "Exclusions", "EdgeCost", "EntityGroup", "ExclusionsStyle", "EdgeCount", "EntityInstance", "Exists", "EdgeCoverQ", "EntityList", "Exit", "EdgeCycleMatrix", "EntityPrefetch", "ExoplanetData", "EdgeDelete", "EntityProperties", "Exp", "EdgeDetect", "EntityProperty", "Expand", "EdgeForm", "EntityPropertyClass", "ExpandAll", "EdgeIndex", "EntityRegister", "ExpandDenominator", "EdgeLabels", "EntityStore", "ExpandFileName", "EdgeLabelStyle", "EntityStores", "ExpandNumerator", "EdgeList", "EntityTypeName", "Expectation", "EdgeQ", "EntityUnregister", "ExpGammaDistribution", "EdgeRules", "EntityValue", "ExpIntegralE", "EdgeShapeFunction", "Entropy", "ExpIntegralEi", "EdgeStyle", "EntropyFilter", "ExpirationDate", "EdgeTaggedGraph", "Environment", "Exponent", "EdgeTaggedGraphQ", "Epilog", "ExponentFunction", "EdgeTags", "EpilogFunction", "ExponentialDistribution", "EdgeWeight", "Equal", "ExponentialFamily", "EdgeWeightedGraphQ", "EqualTilde", "ExponentialGeneratingFunction", "Editable", "EqualTo", "ExponentialMovingAverage", "EditDistance", "Equilibrium", "ExponentialPowerDistribution", "EffectiveInterest", "EquirippleFilterKernel", "ExponentStep", "Eigensystem", "Equivalent", "Export", "Eigenvalues", "Erf", "ExportByteArray", "EigenvectorCentrality", "Erfc", "ExportForm", "Eigenvectors", "Erfi", "ExportString", "Element", "ErlangB", "Expression", "ElementData", "ErlangC", "ExpressionCell", "ElementwiseLayer", "ErlangDistribution", "ExpressionGraph", "ElidedForms", "Erosion", "ExpToTrig", "Eliminate", "ErrorBox", "ExtendedEntityClass", "Ellipsoid", "EscapeRadius", "ExtendedGCD", "EllipticE", "EstimatedBackground", "Extension", "EllipticExp", "EstimatedDistribution", "ExtentElementFunction", "EllipticExpPrime", "EstimatedProcess", "ExtentMarkers", "EllipticF", "EstimatorGains", "ExtentSize", "EllipticFilterModel", "EstimatorRegulator", "ExternalBundle", "EllipticK", "EuclideanDistance", "ExternalEvaluate", "EllipticLog", "EulerAngles", "ExternalFunction", "EllipticNomeQ", "EulerCharacteristic", "ExternalIdentifier", "EllipticPi", "EulerE", "ExternalObject", "EllipticTheta", "EulerGamma", "ExternalOptions", "EllipticThetaPrime", "EulerianGraphQ", "ExternalSessionObject", "EmbedCode", "EulerMatrix", "ExternalSessions", "EmbeddedHTML", "EulerPhi", "ExternalStorageBase", "EmbeddedService", "Evaluatable", "ExternalStorageDownload", "EmbeddingLayer", "Evaluate", "ExternalStorageGet", "EmitSound", "EvaluatePacket", "ExternalStorageObject", "EmpiricalDistribution", "EvaluationBox", "ExternalStoragePut", "EmptyGraphQ", "EvaluationCell", "ExternalStorageUpload", "EmptyRegion", "EvaluationData", "ExternalTypeSignature", "Enabled", "EvaluationElements", "ExternalValue", "Encode", "EvaluationEnvironment", "Extract", "Encrypt", "EvaluationMonitor", "ExtractArchive", "EncryptedObject", "EvaluationNotebook", "ExtractLayer", "EncryptFile", "EvaluationObject", "ExtractPacletArchive", "End", "Evaluator", "ExtremeValueDistribution", "EndDialogPacket", "EvenQ", "EndOfBuffer", "EventData", "FaceAlign", "FindFaces", "ForceVersionInstall", "FaceForm", "FindFile", "Format", "FaceGrids", "FindFit", "FormatType", "FaceGridsStyle", "FindFormula", "FormBox", "FacialFeatures", "FindFundamentalCycles", "FormBoxOptions", "Factor", "FindGeneratingFunction", "FormControl", "Factorial", "FindGeoLocation", "FormFunction", "Factorial2", "FindGeometricConjectures", "FormLayoutFunction", "FactorialMoment", "FindGeometricTransform", "FormObject", "FactorialMomentGeneratingFunction", "FindGraphCommunities", "FormPage", "FactorialPower", "FindGraphIsomorphism", "FormulaData", "FactorInteger", "FindGraphPartition", "FormulaLookup", "FactorList", "FindHamiltonianCycle", "FortranForm", "FactorSquareFree", "FindHamiltonianPath", "Forward", "FactorSquareFreeList", "FindHiddenMarkovStates", "ForwardBackward", "FactorTerms", "FindImageText", "Fourier", "FactorTermsList", "FindIndependentEdgeSet", "FourierCoefficient", "Failure", "FindIndependentVertexSet", "FourierCosCoefficient", "FailureAction", "FindInstance", "FourierCosSeries", "FailureDistribution", "FindIntegerNullVector", "FourierCosTransform", "FailureQ", "FindKClan", "FourierDCT", "False", "FindKClique", "FourierDCTFilter", "FareySequence", "FindKClub", "FourierDCTMatrix", "FARIMAProcess", "FindKPlex", "FourierDST", "FeatureDistance", "FindLibrary", "FourierDSTMatrix", "FeatureExtract", "FindLinearRecurrence", "FourierMatrix", "FeatureExtraction", "FindList", "FourierParameters", "FeatureExtractor", "FindMatchingColor", "FourierSequenceTransform", "FeatureExtractorFunction", "FindMaximum", "FourierSeries", "FeatureNames", "FindMaximumCut", "FourierSinCoefficient", "FeatureNearest", "FindMaximumFlow", "FourierSinSeries", "FeatureSpacePlot", "FindMaxValue", "FourierSinTransform", "FeatureSpacePlot3D", "FindMeshDefects", "FourierTransform", "FeatureTypes", "FindMinimum", "FourierTrigSeries", "FeedbackLinearize", "FindMinimumCostFlow", "FractionalBrownianMotionProcess", "FeedbackSector", "FindMinimumCut", "FractionalGaussianNoiseProcess", "FeedbackSectorStyle", "FindMinValue", "FractionalPart", "FeedbackType", "FindMoleculeSubstructure", "FractionBox", "FetalGrowthData", "FindPath", "FractionBoxOptions", "Fibonacci", "FindPeaks", "Frame", "Fibonorial", "FindPermutation", "FrameBox", "FieldCompletionFunction", "FindPostmanTour", "FrameBoxOptions", "FieldHint", "FindProcessParameters", "Framed", "FieldHintStyle", "FindRepeat", "FrameLabel", "FieldMasked", "FindRoot", "FrameMargins", "FieldSize", "FindSequenceFunction", "FrameRate", "File", "FindSettings", "FrameStyle", "FileBaseName", "FindShortestPath", "FrameTicks", "FileByteCount", "FindShortestTour", "FrameTicksStyle", "FileConvert", "FindSpanningTree", "FRatioDistribution", "FileDate", "FindSystemModelEquilibrium", "FrechetDistribution", "FileExistsQ", "FindTextualAnswer", "FreeQ", "FileExtension", "FindThreshold", "FrenetSerretSystem", "FileFormat", "FindTransientRepeat", "FrequencySamplingFilterKernel", "FileHash", "FindVertexCover", "FresnelC", "FileNameDepth", "FindVertexCut", "FresnelF", "FileNameDrop", "FindVertexIndependentPaths", "FresnelG", "FileNameForms", "FinishDynamic", "FresnelS", "FileNameJoin", "FiniteAbelianGroupCount", "Friday", "FileNames", "FiniteGroupCount", "FrobeniusNumber", "FileNameSetter", "FiniteGroupData", "FrobeniusSolve", "FileNameSplit", "First", "FromAbsoluteTime", "FileNameTake", "FirstCase", "FromCharacterCode", "FilePrint", "FirstPassageTimeDistribution", "FromCoefficientRules", "FileSize", "FirstPosition", "FromContinuedFraction", "FileSystemMap", "FischerGroupFi22", "FromDigits", "FileSystemScan", "FischerGroupFi23", "FromDMS", "FileTemplate", "FischerGroupFi24Prime", "FromEntity", "FileTemplateApply", "FisherHypergeometricDistribution", "FromJulianDate", "FileType", "FisherRatioTest", "FromLetterNumber", "FilledCurve", "FisherZDistribution", "FromPolarCoordinates", "Filling", "Fit", "FromRomanNumeral", "FillingStyle", "FitRegularization", "FromSphericalCoordinates", "FillingTransform", "FittedModel", "FromUnixTime", "FilteredEntityClass", "FixedOrder", "Front", "FilterRules", "FixedPoint", "FrontEndDynamicExpression", "FinancialBond", "FixedPointList", "FrontEndEventActions", "FinancialData", "Flat", "FrontEndExecute", "FinancialDerivative", "Flatten", "FrontEndToken", "FinancialIndicator", "FlattenAt", "FrontEndTokenExecute", "Find", "FlattenLayer", "Full", "FindAnomalies", "FlatTopWindow", "FullDefinition", "FindArgMax", "FlipView", "FullForm", "FindArgMin", "Floor", "FullGraphics", "FindChannels", "FlowPolynomial", "FullInformationOutputRegulator", "FindClique", "Fold", "FullRegion", "FindClusters", "FoldList", "FullSimplify", "FindCookies", "FoldPair", "Function", "FindCurvePath", "FoldPairList", "FunctionCompile", "FindCycle", "FollowRedirects", "FunctionCompileExport", "FindDevices", "FontColor", "FunctionCompileExportByteArray", "FindDistribution", "FontFamily", "FunctionCompileExportLibrary", "FindDistributionParameters", "FontSize", "FunctionCompileExportString", "FindDivisions", "FontSlant", "FunctionDomain", "FindEdgeCover", "FontSubstitutions", "FunctionExpand", "FindEdgeCut", "FontTracking", "FunctionInterpolation", "FindEdgeIndependentPaths", "FontVariations", "FunctionPeriod", "FindEquationalProof", "FontWeight", "FunctionRange", "FindEulerianCycle", "For", "FunctionSpace", "FindExternalEvaluators", "ForAll", "FussellVeselyImportance", "GaborFilter", "GeoGraphics", "Graph", "GaborMatrix", "GeogravityModelData", "Graph3D", "GaborWavelet", "GeoGridDirectionDifference", "GraphAssortativity", "GainMargins", "GeoGridLines", "GraphAutomorphismGroup", "GainPhaseMargins", "GeoGridLinesStyle", "GraphCenter", "GalaxyData", "GeoGridPosition", "GraphComplement", "GalleryView", "GeoGridRange", "GraphData", "Gamma", "GeoGridRangePadding", "GraphDensity", "GammaDistribution", "GeoGridUnitArea", "GraphDiameter", "GammaRegularized", "GeoGridUnitDistance", "GraphDifference", "GapPenalty", "GeoGridVector", "GraphDisjointUnion", "GARCHProcess", "GeoGroup", "GraphDistance", "GatedRecurrentLayer", "GeoHemisphere", "GraphDistanceMatrix", "Gather", "GeoHemisphereBoundary", "GraphEmbedding", "GatherBy", "GeoHistogram", "GraphHighlight", "GaugeFaceElementFunction", "GeoIdentify", "GraphHighlightStyle", "GaugeFaceStyle", "GeoImage", "GraphHub", "GaugeFrameElementFunction", "GeoLabels", "Graphics", "GaugeFrameSize", "GeoLength", "Graphics3D", "GaugeFrameStyle", "GeoListPlot", "GraphicsColumn", "GaugeLabels", "GeoLocation", "GraphicsComplex", "GaugeMarkers", "GeologicalPeriodData", "GraphicsGrid", "GaugeStyle", "GeomagneticModelData", "GraphicsGroup", "GaussianFilter", "GeoMarker", "GraphicsRow", "GaussianIntegers", "GeometricAssertion", "GraphIntersection", "GaussianMatrix", "GeometricBrownianMotionProcess", "GraphLayout", "GaussianOrthogonalMatrixDistribution", "GeometricDistribution", "GraphLinkEfficiency", "GaussianSymplecticMatrixDistribution", "GeometricMean", "GraphPeriphery", "GaussianUnitaryMatrixDistribution", "GeometricMeanFilter", "GraphPlot", "GaussianWindow", "GeometricOptimization", "GraphPlot3D", "GCD", "GeometricScene", "GraphPower", "GegenbauerC", "GeometricTransformation", "GraphPropertyDistribution", "General", "GeoModel", "GraphQ", "GeneralizedLinearModelFit", "GeoNearest", "GraphRadius", "GenerateAsymmetricKeyPair", "GeoPath", "GraphReciprocity", "GenerateConditions", "GeoPosition", "GraphUnion", "GeneratedCell", "GeoPositionENU", "Gray", "GeneratedDocumentBinding", "GeoPositionXYZ", "GrayLevel", "GenerateDerivedKey", "GeoProjection", "Greater", "GenerateDigitalSignature", "GeoProjectionData", "GreaterEqual", "GenerateDocument", "GeoRange", "GreaterEqualLess", "GeneratedParameters", "GeoRangePadding", "GreaterEqualThan", "GeneratedQuantityMagnitudes", "GeoRegionValuePlot", "GreaterFullEqual", "GenerateFileSignature", "GeoResolution", "GreaterGreater", "GenerateHTTPResponse", "GeoScaleBar", "GreaterLess", "GenerateSecuredAuthenticationKey", "GeoServer", "GreaterSlantEqual", "GenerateSymmetricKey", "GeoSmoothHistogram", "GreaterThan", "GeneratingFunction", "GeoStreamPlot", "GreaterTilde", "GeneratorDescription", "GeoStyling", "Green", "GeneratorHistoryLength", "GeoStylingImageFunction", "GreenFunction", "GeneratorOutputType", "GeoVariant", "Grid", "GenericCylindricalDecomposition", "GeoVector", "GridBox", "GenomeData", "GeoVectorENU", "GridDefaultElement", "GenomeLookup", "GeoVectorPlot", "GridGraph", "GeoAntipode", "GeoVectorXYZ", "GridLines", "GeoArea", "GeoVisibleRegion", "GridLinesStyle", "GeoArraySize", "GeoVisibleRegionBoundary", "GroebnerBasis", "GeoBackground", "GeoWithinQ", "GroupActionBase", "GeoBoundingBox", "GeoZoomLevel", "GroupBy", "GeoBounds", "GestureHandler", "GroupCentralizer", "GeoBoundsRegion", "Get", "GroupElementFromWord", "GeoBubbleChart", "GetEnvironment", "GroupElementPosition", "GeoCenter", "Glaisher", "GroupElementQ", "GeoCircle", "GlobalClusteringCoefficient", "GroupElements", "GeoContourPlot", "Glow", "GroupElementToWord", "GeoDensityPlot", "GoldenAngle", "GroupGenerators", "GeodesicClosing", "GoldenRatio", "Groupings", "GeodesicDilation", "GompertzMakehamDistribution", "GroupMultiplicationTable", "GeodesicErosion", "GoochShading", "GroupOrbits", "GeodesicOpening", "GoodmanKruskalGamma", "GroupOrder", "GeoDestination", "GoodmanKruskalGammaTest", "GroupPageBreakWithin", "GeodesyData", "Goto", "GroupSetwiseStabilizer", "GeoDirection", "Grad", "GroupStabilizer", "GeoDisk", "Gradient", "GroupStabilizerChain", "GeoDisplacement", "GradientFilter", "GrowCutComponents", "GeoDistance", "GradientOrientationFilter", "Gudermannian", "GeoDistanceList", "GrammarApply", "GuidedFilter", "GeoElevationData", "GrammarRules", "GumbelDistribution", "GeoEntities", "GrammarToken", "HaarWavelet", "HermiteH", "HoldComplete", "HadamardMatrix", "HermitianMatrixQ", "HoldFirst", "HalfLine", "HessenbergDecomposition", "HoldForm", "HalfNormalDistribution", "HeunB", "HoldPattern", "HalfPlane", "HeunBPrime", "HoldRest", "HalfSpace", "HeunC", "HolidayCalendar", "HalftoneShading", "HeunCPrime", "HorizontalGauge", "HamiltonianGraphQ", "HeunD", "HornerForm", "HammingDistance", "HeunDPrime", "HostLookup", "HammingWindow", "HeunG", "HotellingTSquareDistribution", "HandlerFunctions", "HeunGPrime", "HoytDistribution", "HandlerFunctionsKeys", "HeunT", "HTTPErrorResponse", "HankelH1", "HeunTPrime", "HTTPRedirect", "HankelH2", "HexadecimalCharacter", "HTTPRequest", "HankelMatrix", "Hexahedron", "HTTPRequestData", "HankelTransform", "HiddenItems", "HTTPResponse", "HannPoissonWindow", "HiddenMarkovProcess", "Hue", "HannWindow", "Highlighted", "HumanGrowthData", "HaradaNortonGroupHN", "HighlightGraph", "HumpDownHump", "HararyGraph", "HighlightImage", "HumpEqual", "HarmonicMean", "HighlightMesh", "HurwitzLerchPhi", "HarmonicMeanFilter", "HighpassFilter", "HurwitzZeta", "HarmonicNumber", "HigmanSimsGroupHS", "HyperbolicDistribution", "Hash", "HilbertCurve", "HypercubeGraph", "HatchFilling", "HilbertFilter", "HyperexponentialDistribution", "HatchShading", "HilbertMatrix", "Hyperfactorial", "Haversine", "Histogram", "Hypergeometric0F1", "HazardFunction", "Histogram3D", "Hypergeometric0F1Regularized", "Head", "HistogramDistribution", "Hypergeometric1F1", "HeaderAlignment", "HistogramList", "Hypergeometric1F1Regularized", "HeaderBackground", "HistogramTransform", "Hypergeometric2F1", "HeaderDisplayFunction", "HistogramTransformInterpolation", "Hypergeometric2F1Regularized", "HeaderLines", "HistoricalPeriodData", "HypergeometricDistribution", "HeaderSize", "HitMissTransform", "HypergeometricPFQ", "HeaderStyle", "HITSCentrality", "HypergeometricPFQRegularized", "Heads", "HjorthDistribution", "HypergeometricU", "HeavisideLambda", "HodgeDual", "Hyperlink", "HeavisidePi", "HoeffdingD", "HyperlinkAction", "HeavisideTheta", "HoeffdingDTest", "Hyperplane", "HeldGroupHe", "Hold", "Hyphenation", "Here", "HoldAll", "HypoexponentialDistribution", "HermiteDecomposition", "HoldAllComplete", "HypothesisTestData", "I", "ImageSizeMultipliers", "IntegerName", "IconData", "ImageSubtract", "IntegerPart", "Iconize", "ImageTake", "IntegerPartitions", "IconRules", "ImageTransformation", "IntegerQ", "Icosahedron", "ImageTrim", "IntegerReverse", "Identity", "ImageType", "Integers", "IdentityMatrix", "ImageValue", "IntegerString", "If", "ImageValuePositions", "Integrate", "IgnoreCase", "ImagingDevice", "Interactive", "IgnoreDiacritics", "ImplicitRegion", "InteractiveTradingChart", "IgnorePunctuation", "Implies", "Interleaving", "IgnoringInactive", "Import", "InternallyBalancedDecomposition", "Im", "ImportByteArray", "InterpolatingFunction", "Image", "ImportOptions", "InterpolatingPolynomial", "Image3D", "ImportString", "Interpolation", "Image3DProjection", "ImprovementImportance", "InterpolationOrder", "Image3DSlices", "In", "InterpolationPoints", "ImageAccumulate", "Inactivate", "Interpretation", "ImageAdd", "Inactive", "InterpretationBox", "ImageAdjust", "IncidenceGraph", "InterpretationBoxOptions", "ImageAlign", "IncidenceList", "Interpreter", "ImageApply", "IncidenceMatrix", "InterquartileRange", "ImageApplyIndexed", "IncludeAromaticBonds", "Interrupt", "ImageAspectRatio", "IncludeConstantBasis", "IntersectedEntityClass", "ImageAssemble", "IncludeDefinitions", "IntersectingQ", "ImageAugmentationLayer", "IncludeDirectories", "Intersection", "ImageBoundingBoxes", "IncludeGeneratorTasks", "Interval", "ImageCapture", "IncludeHydrogens", "IntervalIntersection", "ImageCaptureFunction", "IncludeInflections", "IntervalMarkers", "ImageCases", "IncludeMetaInformation", "IntervalMarkersStyle", "ImageChannels", "IncludePods", "IntervalMemberQ", "ImageClip", "IncludeQuantities", "IntervalSlider", "ImageCollage", "IncludeRelatedTables", "IntervalUnion", "ImageColorSpace", "IncludeWindowTimes", "Inverse", "ImageCompose", "Increment", "InverseBetaRegularized", "ImageContainsQ", "IndefiniteMatrixQ", "InverseCDF", "ImageContents", "IndependenceTest", "InverseChiSquareDistribution", "ImageConvolve", "IndependentEdgeSetQ", "InverseContinuousWaveletTransform", "ImageCooccurrence", "IndependentPhysicalQuantity", "InverseDistanceTransform", "ImageCorners", "IndependentUnit", "InverseEllipticNomeQ", "ImageCorrelate", "IndependentUnitDimension", "InverseErf", "ImageCorrespondingPoints", "IndependentVertexSetQ", "InverseErfc", "ImageCrop", "Indeterminate", "InverseFourier", "ImageData", "IndeterminateThreshold", "InverseFourierCosTransform", "ImageDeconvolve", "Indexed", "InverseFourierSequenceTransform", "ImageDemosaic", "IndexEdgeTaggedGraph", "InverseFourierSinTransform", "ImageDifference", "IndexGraph", "InverseFourierTransform", "ImageDimensions", "InexactNumberQ", "InverseFunction", "ImageDisplacements", "InfiniteFuture", "InverseFunctions", "ImageDistance", "InfiniteLine", "InverseGammaDistribution", "ImageEffect", "InfinitePast", "InverseGammaRegularized", "ImageExposureCombine", "InfinitePlane", "InverseGaussianDistribution", "ImageFeatureTrack", "Infinity", "InverseGudermannian", "ImageFileApply", "Infix", "InverseHankelTransform", "ImageFileFilter", "InflationAdjust", "InverseHaversine", "ImageFileScan", "InflationMethod", "InverseImagePyramid", "ImageFilter", "Information", "InverseJacobiCD", "ImageFocusCombine", "Inherited", "InverseJacobiCN", "ImageForestingComponents", "InheritScope", "InverseJacobiCS", "ImageFormattingWidth", "InhomogeneousPoissonProcess", "InverseJacobiDC", "ImageForwardTransformation", "InitialEvaluationHistory", "InverseJacobiDN", "ImageGraphics", "Initialization", "InverseJacobiDS", "ImageHistogram", "InitializationCell", "InverseJacobiNC", "ImageIdentify", "InitializationObjects", "InverseJacobiND", "ImageInstanceQ", "InitializationValue", "InverseJacobiNS", "ImageKeypoints", "Initialize", "InverseJacobiSC", "ImageLabels", "InitialSeeding", "InverseJacobiSD", "ImageLegends", "Inner", "InverseJacobiSN", "ImageLevels", "InnerPolygon", "InverseLaplaceTransform", "ImageLines", "InnerPolyhedron", "InverseMellinTransform", "ImageMargins", "Inpaint", "InversePermutation", "ImageMarker", "Input", "InverseRadon", "ImageMeasurements", "InputAliases", "InverseRadonTransform", "ImageMesh", "InputAssumptions", "InverseSeries", "ImageMultiply", "InputAutoReplacements", "InverseShortTimeFourier", "ImagePad", "InputField", "InverseSpectrogram", "ImagePadding", "InputForm", "InverseSurvivalFunction", "ImagePartition", "InputNamePacket", "InverseTransformedRegion", "ImagePeriodogram", "InputNotebook", "InverseWaveletTransform", "ImagePerspectiveTransformation", "InputPacket", "InverseWeierstrassP", "ImagePosition", "InputStream", "InverseWishartMatrixDistribution", "ImagePreviewFunction", "InputString", "InverseZTransform", "ImagePyramid", "InputStringPacket", "Invisible", "ImagePyramidApply", "Insert", "IPAddress", "ImageQ", "InsertionFunction", "IrreduciblePolynomialQ", "ImageRecolor", "InsertLinebreaks", "IslandData", "ImageReflect", "InsertResults", "IsolatingInterval", "ImageResize", "Inset", "IsomorphicGraphQ", "ImageResolution", "Insphere", "IsotopeData", "ImageRestyle", "Install", "Italic", "ImageRotate", "InstallService", "Item", "ImageSaliencyFilter", "InString", "ItemAspectRatio", "ImageScaled", "Integer", "ItemDisplayFunction", "ImageScan", "IntegerDigits", "ItemSize", "ImageSize", "IntegerExponent", "ItemStyle", "ImageSizeAction", "IntegerLength", "ItoProcess", "JaccardDissimilarity", "JacobiSC", "JoinAcross", "JacobiAmplitude", "JacobiSD", "Joined", "JacobiCD", "JacobiSN", "JoinedCurve", "JacobiCN", "JacobiSymbol", "JoinForm", "JacobiCS", "JacobiZeta", "JordanDecomposition", "JacobiDC", "JankoGroupJ1", "JordanModelDecomposition", "JacobiDN", "JankoGroupJ2", "JulianDate", "JacobiDS", "JankoGroupJ3", "JuliaSetBoettcher", "JacobiNC", "JankoGroupJ4", "JuliaSetIterationCount", "JacobiND", "JarqueBeraALMTest", "JuliaSetPlot", "JacobiNS", "JohnsonDistribution", "JuliaSetPoints", "JacobiP", "Join", "KagiChart", "KernelObject", "Khinchin", "KaiserBesselWindow", "Kernels", "KillProcess", "KaiserWindow", "Key", "KirchhoffGraph", "KalmanEstimator", "KeyCollisionFunction", "KirchhoffMatrix", "KalmanFilter", "KeyComplement", "KleinInvariantJ", "KarhunenLoeveDecomposition", "KeyDrop", "KnapsackSolve", "KaryTree", "KeyDropFrom", "KnightTourGraph", "KatzCentrality", "KeyExistsQ", "KnotData", "KCoreComponents", "KeyFreeQ", "KnownUnitQ", "KDistribution", "KeyIntersection", "KochCurve", "KEdgeConnectedComponents", "KeyMap", "KolmogorovSmirnovTest", "KEdgeConnectedGraphQ", "KeyMemberQ", "KroneckerDelta", "KeepExistingVersion", "KeypointStrength", "KroneckerModelDecomposition", "KelvinBei", "Keys", "KroneckerProduct", "KelvinBer", "KeySelect", "KroneckerSymbol", "KelvinKei", "KeySort", "KuiperTest", "KelvinKer", "KeySortBy", "KumaraswamyDistribution", "KendallTau", "KeyTake", "Kurtosis", "KendallTauTest", "KeyUnion", "KuwaharaFilter", "KernelFunction", "KeyValueMap", "KVertexConnectedComponents", "KernelMixtureDistribution", "KeyValuePattern", "KVertexConnectedGraphQ", "LABColor", "LetterQ", "ListPickerBox", "Label", "Level", "ListPickerBoxOptions", "Labeled", "LeveneTest", "ListPlay", "LabelingFunction", "LeviCivitaTensor", "ListPlot", "LabelingSize", "LevyDistribution", "ListPlot3D", "LabelStyle", "LibraryDataType", "ListPointPlot3D", "LabelVisibility", "LibraryFunction", "ListPolarPlot", "LaguerreL", "LibraryFunctionError", "ListQ", "LakeData", "LibraryFunctionInformation", "ListSliceContourPlot3D", "LambdaComponents", "LibraryFunctionLoad", "ListSliceDensityPlot3D", "LaminaData", "LibraryFunctionUnload", "ListSliceVectorPlot3D", "LanczosWindow", "LibraryLoad", "ListStepPlot", "LandauDistribution", "LibraryUnload", "ListStreamDensityPlot", "Language", "LiftingFilterData", "ListStreamPlot", "LanguageCategory", "LiftingWaveletTransform", "ListSurfacePlot3D", "LanguageData", "LightBlue", "ListVectorDensityPlot", "LanguageIdentify", "LightBrown", "ListVectorPlot", "LaplaceDistribution", "LightCyan", "ListVectorPlot3D", "LaplaceTransform", "Lighter", "ListZTransform", "Laplacian", "LightGray", "LocalAdaptiveBinarize", "LaplacianFilter", "LightGreen", "LocalCache", "LaplacianGaussianFilter", "Lighting", "LocalClusteringCoefficient", "Large", "LightingAngle", "LocalizeVariables", "Larger", "LightMagenta", "LocalObject", "Last", "LightOrange", "LocalObjects", "Latitude", "LightPink", "LocalResponseNormalizationLayer", "LatitudeLongitude", "LightPurple", "LocalSubmit", "LatticeData", "LightRed", "LocalSymbol", "LatticeReduce", "LightYellow", "LocalTime", "LaunchKernels", "Likelihood", "LocalTimeZone", "LayeredGraphPlot", "Limit", "LocationEquivalenceTest", "LayerSizeFunction", "LimitsPositioning", "LocationTest", "LCHColor", "LindleyDistribution", "Locator", "LCM", "Line", "LocatorAutoCreate", "LeaderSize", "LinearFractionalOptimization", "LocatorPane", "LeafCount", "LinearFractionalTransform", "LocatorRegion", "LeapYearQ", "LinearGradientImage", "Locked", "LearnDistribution", "LinearizingTransformationData", "Log", "LearnedDistribution", "LinearLayer", "Log10", "LearningRate", "LinearModelFit", "Log2", "LearningRateMultipliers", "LinearOffsetFunction", "LogBarnesG", "LeastSquares", "LinearOptimization", "LogGamma", "LeastSquaresFilterKernel", "LinearProgramming", "LogGammaDistribution", "Left", "LinearRecurrence", "LogicalExpand", "LeftArrow", "LinearSolve", "LogIntegral", "LeftArrowBar", "LinearSolveFunction", "LogisticDistribution", "LeftArrowRightArrow", "LineBreakChart", "LogisticSigmoid", "LeftDownTeeVector", "LineGraph", "LogitModelFit", "LeftDownVector", "LineIndent", "LogLikelihood", "LeftDownVectorBar", "LineIndentMaxFraction", "LogLinearPlot", "LeftRightArrow", "LineIntegralConvolutionPlot", "LogLogisticDistribution", "LeftRightVector", "LineIntegralConvolutionScale", "LogLogPlot", "LeftTee", "LineLegend", "LogMultinormalDistribution", "LeftTeeArrow", "LineSpacing", "LogNormalDistribution", "LeftTeeVector", "LinkActivate", "LogPlot", "LeftTriangle", "LinkClose", "LogRankTest", "LeftTriangleBar", "LinkConnect", "LogSeriesDistribution", "LeftTriangleEqual", "LinkCreate", "Longest", "LeftUpDownVector", "LinkFunction", "LongestCommonSequence", "LeftUpTeeVector", "LinkInterrupt", "LongestCommonSequencePositions", "LeftUpVector", "LinkLaunch", "LongestCommonSubsequence", "LeftUpVectorBar", "LinkObject", "LongestCommonSubsequencePositions", "LeftVector", "LinkPatterns", "LongestOrderedSequence", "LeftVectorBar", "LinkProtocol", "Longitude", "LegendAppearance", "LinkRankCentrality", "LongLeftArrow", "Legended", "LinkRead", "LongLeftRightArrow", "LegendFunction", "LinkReadyQ", "LongRightArrow", "LegendLabel", "Links", "LongShortTermMemoryLayer", "LegendLayout", "LinkWrite", "Lookup", "LegendMargins", "LiouvilleLambda", "LoopFreeGraphQ", "LegendMarkers", "List", "Looping", "LegendMarkerSize", "Listable", "LossFunction", "LegendreP", "ListAnimate", "LowerCaseQ", "LegendreQ", "ListContourPlot", "LowerLeftArrow", "Length", "ListContourPlot3D", "LowerRightArrow", "LengthWhile", "ListConvolve", "LowerTriangularize", "LerchPhi", "ListCorrelate", "LowerTriangularMatrixQ", "Less", "ListCurvePathPlot", "LowpassFilter", "LessEqual", "ListDeconvolve", "LQEstimatorGains", "LessEqualGreater", "ListDensityPlot", "LQGRegulator", "LessEqualThan", "ListDensityPlot3D", "LQOutputRegulatorGains", "LessFullEqual", "ListFormat", "LQRegulatorGains", "LessGreater", "ListFourierSequenceTransform", "LucasL", "LessLess", "ListInterpolation", "LuccioSamiComponents", "LessSlantEqual", "ListLineIntegralConvolutionPlot", "LUDecomposition", "LessThan", "ListLinePlot", "LunarEclipse", "LessTilde", "ListLogLinearPlot", "LUVColor", "LetterCharacter", "ListLogLogPlot", "LyapunovSolve", "LetterCounts", "ListLogPlot", "LyonsGroupLy", "LetterNumber", "ListPicker", "MachineNumberQ", "MaxMemoryUsed", "MinimalPolynomial", "MachinePrecision", "MaxMixtureKernels", "MinimalStateSpaceModel", "Magenta", "MaxOverlapFraction", "Minimize", "Magnification", "MaxPlotPoints", "MinimumTimeIncrement", "Magnify", "MaxRecursion", "MinIntervalSize", "MailAddressValidation", "MaxStableDistribution", "MinkowskiQuestionMark", "MailExecute", "MaxStepFraction", "MinLimit", "MailFolder", "MaxSteps", "MinMax", "MailItem", "MaxStepSize", "MinorPlanetData", "MailReceiverFunction", "MaxTrainingRounds", "Minors", "MailResponseFunction", "MaxValue", "MinStableDistribution", "MailSearch", "MaxwellDistribution", "Minus", "MailServerConnect", "MaxWordGap", "MinusPlus", "MailServerConnection", "McLaughlinGroupMcL", "MinValue", "MailSettings", "Mean", "Missing", "Majority", "MeanAbsoluteLossLayer", "MissingBehavior", "MakeBoxes", "MeanAround", "MissingDataMethod", "MakeExpression", "MeanClusteringCoefficient", "MissingDataRules", "ManagedLibraryExpressionID", "MeanDegreeConnectivity", "MissingQ", "ManagedLibraryExpressionQ", "MeanDeviation", "MissingString", "MandelbrotSetBoettcher", "MeanFilter", "MissingStyle", "MandelbrotSetDistance", "MeanGraphDistance", "MissingValuePattern", "MandelbrotSetIterationCount", "MeanNeighborDegree", "MittagLefflerE", "MandelbrotSetMemberQ", "MeanShift", "MixedFractionParts", "MandelbrotSetPlot", "MeanShiftFilter", "MixedGraphQ", "MangoldtLambda", "MeanSquaredLossLayer", "MixedMagnitude", "ManhattanDistance", "Median", "MixedRadix", "Manipulate", "MedianDeviation", "MixedRadixQuantity", "Manipulator", "MedianFilter", "MixedUnit", "MannedSpaceMissionData", "MedicalTestData", "MixtureDistribution", "MannWhitneyTest", "Medium", "Mod", "MantissaExponent", "MeijerG", "Modal", "Manual", "MeijerGReduce", "ModularInverse", "Map", "MeixnerDistribution", "ModularLambda", "MapAll", "MellinConvolve", "Module", "MapAt", "MellinTransform", "Modulus", "MapIndexed", "MemberQ", "MoebiusMu", "MAProcess", "MemoryAvailable", "Molecule", "MapThread", "MemoryConstrained", "MoleculeContainsQ", "MarchenkoPasturDistribution", "MemoryConstraint", "MoleculeEquivalentQ", "MarcumQ", "MemoryInUse", "MoleculeGraph", "MardiaCombinedTest", "MengerMesh", "MoleculeModify", "MardiaKurtosisTest", "MenuCommandKey", "MoleculePattern", "MardiaSkewnessTest", "MenuPacket", "MoleculePlot", "MarginalDistribution", "MenuSortingValue", "MoleculePlot3D", "MarkovProcessProperties", "MenuStyle", "MoleculeProperty", "Masking", "MenuView", "MoleculeQ", "MatchingDissimilarity", "Merge", "MoleculeRecognize", "MatchLocalNames", "MergingFunction", "MoleculeValue", "MatchQ", "MersennePrimeExponent", "Moment", "MathematicalFunctionData", "MersennePrimeExponentQ", "MomentConvert", "MathieuC", "Mesh", "MomentEvaluate", "MathieuCharacteristicA", "MeshCellCentroid", "MomentGeneratingFunction", "MathieuCharacteristicB", "MeshCellCount", "MomentOfInertia", "MathieuCharacteristicExponent", "MeshCellHighlight", "Monday", "MathieuCPrime", "MeshCellIndex", "Monitor", "MathieuGroupM11", "MeshCellLabel", "MonomialList", "MathieuGroupM12", "MeshCellMarker", "MonsterGroupM", "MathieuGroupM22", "MeshCellMeasure", "MoonPhase", "MathieuGroupM23", "MeshCellQuality", "MoonPosition", "MathieuGroupM24", "MeshCells", "MorletWavelet", "MathieuS", "MeshCellShapeFunction", "MorphologicalBinarize", "MathieuSPrime", "MeshCellStyle", "MorphologicalBranchPoints", "MathMLForm", "MeshConnectivityGraph", "MorphologicalComponents", "Matrices", "MeshCoordinates", "MorphologicalEulerNumber", "MatrixExp", "MeshFunctions", "MorphologicalGraph", "MatrixForm", "MeshPrimitives", "MorphologicalPerimeter", "MatrixFunction", "MeshQualityGoal", "MorphologicalTransform", "MatrixLog", "MeshRefinementFunction", "MortalityData", "MatrixNormalDistribution", "MeshRegion", "Most", "MatrixPlot", "MeshRegionQ", "MountainData", "MatrixPower", "MeshShading", "MouseAnnotation", "MatrixPropertyDistribution", "MeshStyle", "MouseAppearance", "MatrixQ", "Message", "Mouseover", "MatrixRank", "MessageDialog", "MousePosition", "MatrixTDistribution", "MessageList", "MovieData", "Max", "MessageName", "MovingAverage", "MaxCellMeasure", "MessagePacket", "MovingMap", "MaxColorDistance", "Messages", "MovingMedian", "MaxDate", "MetaInformation", "MoyalDistribution", "MaxDetect", "MeteorShowerData", "Multicolumn", "MaxDuration", "Method", "MultiedgeStyle", "MaxExtraBandwidths", "MexicanHatWavelet", "MultigraphQ", "MaxExtraConditions", "MeyerWavelet", "Multinomial", "MaxFeatureDisplacement", "Midpoint", "MultinomialDistribution", "MaxFeatures", "Min", "MultinormalDistribution", "MaxFilter", "MinColorDistance", "MultiplicativeOrder", "MaximalBy", "MinDate", "MultiplySides", "Maximize", "MinDetect", "Multiselection", "MaxItems", "MineralData", "MultivariateHypergeometricDistribution", "MaxIterations", "MinFilter", "MultivariatePoissonDistribution", "MaxLimit", "MinimalBy", "MultivariateTDistribution", "N", "NHoldFirst", "NotificationFunction", "NakagamiDistribution", "NHoldRest", "NotLeftTriangle", "NameQ", "NicholsGridLines", "NotLeftTriangleBar", "Names", "NicholsPlot", "NotLeftTriangleEqual", "Nand", "NightHemisphere", "NotLess", "NArgMax", "NIntegrate", "NotLessEqual", "NArgMin", "NMaximize", "NotLessFullEqual", "NBodySimulation", "NMaxValue", "NotLessGreater", "NBodySimulationData", "NMinimize", "NotLessLess", "NCache", "NMinValue", "NotLessSlantEqual", "NDEigensystem", "NominalVariables", "NotLessTilde", "NDEigenvalues", "NoncentralBetaDistribution", "NotNestedGreaterGreater", "NDSolve", "NoncentralChiSquareDistribution", "NotNestedLessLess", "NDSolveValue", "NoncentralFRatioDistribution", "NotPrecedes", "Nearest", "NoncentralStudentTDistribution", "NotPrecedesEqual", "NearestFunction", "NonCommutativeMultiply", "NotPrecedesSlantEqual", "NearestMeshCells", "NonConstants", "NotPrecedesTilde", "NearestNeighborGraph", "NondimensionalizationTransform", "NotReverseElement", "NearestTo", "None", "NotRightTriangle", "NebulaData", "NoneTrue", "NotRightTriangleBar", "NeedlemanWunschSimilarity", "NonlinearModelFit", "NotRightTriangleEqual", "Needs", "NonlinearStateSpaceModel", "NotSquareSubset", "Negative", "NonlocalMeansFilter", "NotSquareSubsetEqual", "NegativeBinomialDistribution", "NonNegative", "NotSquareSuperset", "NegativeDefiniteMatrixQ", "NonNegativeIntegers", "NotSquareSupersetEqual", "NegativeIntegers", "NonNegativeRationals", "NotSubset", "NegativeMultinomialDistribution", "NonNegativeReals", "NotSubsetEqual", "NegativeRationals", "NonPositive", "NotSucceeds", "NegativeReals", "NonPositiveIntegers", "NotSucceedsEqual", "NegativeSemidefiniteMatrixQ", "NonPositiveRationals", "NotSucceedsSlantEqual", "NeighborhoodData", "NonPositiveReals", "NotSucceedsTilde", "NeighborhoodGraph", "Nor", "NotSuperset", "Nest", "NorlundB", "NotSupersetEqual", "NestedGreaterGreater", "Norm", "NotTilde", "NestedLessLess", "Normal", "NotTildeEqual", "NestGraph", "NormalDistribution", "NotTildeFullEqual", "NestList", "NormalizationLayer", "NotTildeTilde", "NestWhile", "Normalize", "NotVerticalBar", "NestWhileList", "Normalized", "Now", "NetAppend", "NormalizedSquaredEuclideanDistance", "NoWhitespace", "NetBidirectionalOperator", "NormalMatrixQ", "NProbability", "NetChain", "NormalsFunction", "NProduct", "NetDecoder", "NormFunction", "NRoots", "NetDelete", "Not", "NSolve", "NetDrop", "NotCongruent", "NSum", "NetEncoder", "NotCupCap", "NuclearExplosionData", "NetEvaluationMode", "NotDoubleVerticalBar", "NuclearReactorData", "NetExtract", "Notebook", "Null", "NetFlatten", "NotebookApply", "NullRecords", "NetFoldOperator", "NotebookAutoSave", "NullSpace", "NetGANOperator", "NotebookClose", "NullWords", "NetGraph", "NotebookDelete", "Number", "NetInitialize", "NotebookDirectory", "NumberCompose", "NetInsert", "NotebookDynamicExpression", "NumberDecompose", "NetInsertSharedArrays", "NotebookEvaluate", "NumberExpand", "NetJoin", "NotebookEventActions", "NumberFieldClassNumber", "NetMapOperator", "NotebookFileName", "NumberFieldDiscriminant", "NetMapThreadOperator", "NotebookFind", "NumberFieldFundamentalUnits", "NetMeasurements", "NotebookGet", "NumberFieldIntegralBasis", "NetModel", "NotebookImport", "NumberFieldNormRepresentatives", "NetNestOperator", "NotebookInformation", "NumberFieldRegulator", "NetPairEmbeddingOperator", "NotebookLocate", "NumberFieldRootsOfUnity", "NetPort", "NotebookObject", "NumberFieldSignature", "NetPortGradient", "NotebookOpen", "NumberForm", "NetPrepend", "NotebookPrint", "NumberFormat", "NetRename", "NotebookPut", "NumberLinePlot", "NetReplace", "NotebookRead", "NumberMarks", "NetReplacePart", "Notebooks", "NumberMultiplier", "NetSharedArray", "NotebookSave", "NumberPadding", "NetStateObject", "NotebookSelection", "NumberPoint", "NetTake", "NotebooksMenu", "NumberQ", "NetTrain", "NotebookTemplate", "NumberSeparator", "NetTrainResultsObject", "NotebookWrite", "NumberSigns", "NetworkPacketCapture", "NotElement", "NumberString", "NetworkPacketRecording", "NotEqualTilde", "Numerator", "NetworkPacketTrace", "NotExists", "NumeratorDenominator", "NeumannValue", "NotGreater", "NumericalOrder", "NevilleThetaC", "NotGreaterEqual", "NumericalSort", "NevilleThetaD", "NotGreaterFullEqual", "NumericArray", "NevilleThetaN", "NotGreaterGreater", "NumericArrayQ", "NevilleThetaS", "NotGreaterLess", "NumericArrayType", "NExpectation", "NotGreaterSlantEqual", "NumericFunction", "NextCell", "NotGreaterTilde", "NumericQ", "NextDate", "Nothing", "NuttallWindow", "NextPrime", "NotHumpDownHump", "NyquistGridLines", "NHoldAll", "NotHumpEqual", "NyquistPlot", "O", "OperatingSystem", "OuterPolyhedron", "ObservabilityGramian", "OperatorApplied", "OutputControllabilityMatrix", "ObservabilityMatrix", "OptimumFlowData", "OutputControllableModelQ", "ObservableDecomposition", "Optional", "OutputForm", "ObservableModelQ", "OptionalElement", "OutputNamePacket", "OceanData", "Options", "OutputResponse", "Octahedron", "OptionsPattern", "OutputSizeLimit", "OddQ", "OptionValue", "OutputStream", "Off", "Or", "OverBar", "Offset", "Orange", "OverDot", "On", "Order", "Overflow", "ONanGroupON", "OrderDistribution", "OverHat", "Once", "OrderedQ", "Overlaps", "OneIdentity", "Ordering", "Overlay", "Opacity", "OrderingBy", "Overscript", "OpacityFunction", "OrderingLayer", "OverscriptBox", "OpacityFunctionScaling", "Orderless", "OverscriptBoxOptions", "OpenAppend", "OrderlessPatternSequence", "OverTilde", "Opener", "OrnsteinUhlenbeckProcess", "OverVector", "OpenerView", "Orthogonalize", "OverwriteTarget", "Opening", "OrthogonalMatrixQ", "OwenT", "OpenRead", "Out", "OwnValues", "OpenWrite", "Outer", "Operate", "OuterPolygon", "PacletDataRebuild", "PeriodicBoundaryCondition", "PolynomialLCM", "PacletDirectoryLoad", "Periodogram", "PolynomialMod", "PacletDirectoryUnload", "PeriodogramArray", "PolynomialQ", "PacletDisable", "Permanent", "PolynomialQuotient", "PacletEnable", "Permissions", "PolynomialQuotientRemainder", "PacletFind", "PermissionsGroup", "PolynomialReduce", "PacletFindRemote", "PermissionsGroups", "PolynomialRemainder", "PacletInstall", "PermissionsKey", "PoolingLayer", "PacletInstallSubmit", "PermissionsKeys", "PopupMenu", "PacletNewerQ", "PermutationCycles", "PopupView", "PacletObject", "PermutationCyclesQ", "PopupWindow", "PacletSite", "PermutationGroup", "Position", "PacletSiteObject", "PermutationLength", "PositionIndex", "PacletSiteRegister", "PermutationList", "Positive", "PacletSites", "PermutationListQ", "PositiveDefiniteMatrixQ", "PacletSiteUnregister", "PermutationMax", "PositiveIntegers", "PacletSiteUpdate", "PermutationMin", "PositiveRationals", "PacletUninstall", "PermutationOrder", "PositiveReals", "PaddedForm", "PermutationPower", "PositiveSemidefiniteMatrixQ", "Padding", "PermutationProduct", "PossibleZeroQ", "PaddingLayer", "PermutationReplace", "Postfix", "PaddingSize", "Permutations", "Power", "PadeApproximant", "PermutationSupport", "PowerDistribution", "PadLeft", "Permute", "PowerExpand", "PadRight", "PeronaMalikFilter", "PowerMod", "PageBreakAbove", "PerpendicularBisector", "PowerModList", "PageBreakBelow", "PersistenceLocation", "PowerRange", "PageBreakWithin", "PersistenceTime", "PowerSpectralDensity", "PageFooters", "PersistentObject", "PowersRepresentations", "PageHeaders", "PersistentObjects", "PowerSymmetricPolynomial", "PageRankCentrality", "PersistentValue", "PrecedenceForm", "PageTheme", "PersonData", "Precedes", "PageWidth", "PERTDistribution", "PrecedesEqual", "Pagination", "PetersenGraph", "PrecedesSlantEqual", "PairedBarChart", "PhaseMargins", "PrecedesTilde", "PairedHistogram", "PhaseRange", "Precision", "PairedSmoothHistogram", "PhysicalSystemData", "PrecisionGoal", "PairedTTest", "Pi", "PreDecrement", "PairedZTest", "Pick", "Predict", "PaletteNotebook", "PIDData", "PredictorFunction", "PalindromeQ", "PIDDerivativeFilter", "PredictorMeasurements", "Pane", "PIDFeedforward", "PredictorMeasurementsObject", "Panel", "PIDTune", "PreemptProtect", "Paneled", "Piecewise", "Prefix", "PaneSelector", "PiecewiseExpand", "PreIncrement", "ParabolicCylinderD", "PieChart", "Prepend", "ParagraphIndent", "PieChart3D", "PrependLayer", "ParagraphSpacing", "PillaiTrace", "PrependTo", "ParallelArray", "PillaiTraceTest", "PreprocessingRules", "ParallelCombine", "PingTime", "PreserveColor", "ParallelDo", "Pink", "PreserveImageOptions", "Parallelepiped", "PitchRecognize", "PreviousCell", "ParallelEvaluate", "PixelValue", "PreviousDate", "Parallelization", "PixelValuePositions", "PriceGraphDistribution", "Parallelize", "Placed", "Prime", "ParallelMap", "Placeholder", "PrimeNu", "ParallelNeeds", "PlaceholderReplace", "PrimeOmega", "Parallelogram", "Plain", "PrimePi", "ParallelProduct", "PlanarAngle", "PrimePowerQ", "ParallelSubmit", "PlanarGraph", "PrimeQ", "ParallelSum", "PlanarGraphQ", "Primes", "ParallelTable", "PlanckRadiationLaw", "PrimeZetaP", "ParallelTry", "PlaneCurveData", "PrimitivePolynomialQ", "ParameterEstimator", "PlanetaryMoonData", "PrimitiveRoot", "ParameterMixtureDistribution", "PlanetData", "PrimitiveRootList", "ParametricFunction", "PlantData", "PrincipalComponents", "ParametricNDSolve", "Play", "PrincipalValue", "ParametricNDSolveValue", "PlayRange", "Print", "ParametricPlot", "Plot", "PrintableASCIIQ", "ParametricPlot3D", "Plot3D", "PrintingStyleEnvironment", "ParametricRampLayer", "PlotLabel", "Printout3D", "ParametricRegion", "PlotLabels", "Printout3DPreviewer", "ParentBox", "PlotLayout", "PrintTemporary", "ParentCell", "PlotLegends", "Prism", "ParentDirectory", "PlotMarkers", "PrivateCellOptions", "ParentNotebook", "PlotPoints", "PrivateFontOptions", "ParetoDistribution", "PlotRange", "PrivateKey", "ParetoPickandsDistribution", "PlotRangeClipping", "PrivateNotebookOptions", "ParkData", "PlotRangePadding", "Probability", "Part", "PlotRegion", "ProbabilityDistribution", "PartBehavior", "PlotStyle", "ProbabilityPlot", "PartialCorrelationFunction", "PlotTheme", "ProbabilityScalePlot", "ParticleAcceleratorData", "Pluralize", "ProbitModelFit", "ParticleData", "Plus", "ProcessConnection", "Partition", "PlusMinus", "ProcessDirectory", "PartitionGranularity", "Pochhammer", "ProcessEnvironment", "PartitionsP", "PodStates", "Processes", "PartitionsQ", "PodWidth", "ProcessEstimator", "PartLayer", "Point", "ProcessInformation", "PartOfSpeech", "PointFigureChart", "ProcessObject", "PartProtection", "PointLegend", "ProcessParameterAssumptions", "ParzenWindow", "PointSize", "ProcessParameterQ", "PascalDistribution", "PoissonConsulDistribution", "ProcessStatus", "PassEventsDown", "PoissonDistribution", "Product", "PassEventsUp", "PoissonProcess", "ProductDistribution", "Paste", "PoissonWindow", "ProductLog", "PasteButton", "PolarAxes", "ProgressIndicator", "Path", "PolarAxesOrigin", "Projection", "PathGraph", "PolarGridLines", "Prolog", "PathGraphQ", "PolarPlot", "ProofObject", "Pattern", "PolarTicks", "Proportion", "PatternFilling", "PoleZeroMarkers", "Proportional", "PatternSequence", "PolyaAeppliDistribution", "Protect", "PatternTest", "PolyGamma", "Protected", "PauliMatrix", "Polygon", "ProteinData", "PaulWavelet", "PolygonalNumber", "Pruning", "Pause", "PolygonAngle", "PseudoInverse", "PDF", "PolygonCoordinates", "PsychrometricPropertyData", "PeakDetect", "PolygonDecomposition", "PublicKey", "PeanoCurve", "Polyhedron", "PublisherID", "PearsonChiSquareTest", "PolyhedronAngle", "PulsarData", "PearsonCorrelationTest", "PolyhedronCoordinates", "PunctuationCharacter", "PearsonDistribution", "PolyhedronData", "Purple", "PercentForm", "PolyhedronDecomposition", "Put", "PerfectNumber", "PolyhedronGenus", "PutAppend", "PerfectNumberQ", "PolyLog", "Pyramid", "PerformanceGoal", "PolynomialExtendedGCD", "Perimeter", "PolynomialGCD", "QBinomial", "Quantity", "Quartics", "QFactorial", "QuantityArray", "QuartileDeviation", "QGamma", "QuantityDistribution", "Quartiles", "QHypergeometricPFQ", "QuantityForm", "QuartileSkewness", "QnDispersion", "QuantityMagnitude", "Query", "QPochhammer", "QuantityQ", "QueueingNetworkProcess", "QPolyGamma", "QuantityUnit", "QueueingProcess", "QRDecomposition", "QuantityVariable", "QueueProperties", "QuadraticIrrationalQ", "QuantityVariableCanonicalUnit", "Quiet", "QuadraticOptimization", "QuantityVariableDimensions", "Quit", "Quantile", "QuantityVariableIdentifier", "Quotient", "QuantilePlot", "QuantityVariablePhysicalQuantity", "QuotientRemainder", "RadialGradientImage", "RegionEqual", "Restricted", "RadialityCentrality", "RegionFillingStyle", "Resultant", "RadicalBox", "RegionFunction", "Return", "RadicalBoxOptions", "RegionImage", "ReturnExpressionPacket", "RadioButton", "RegionIntersection", "ReturnPacket", "RadioButtonBar", "RegionMeasure", "ReturnReceiptFunction", "Radon", "RegionMember", "ReturnTextPacket", "RadonTransform", "RegionMemberFunction", "Reverse", "RamanujanTau", "RegionMoment", "ReverseApplied", "RamanujanTauL", "RegionNearest", "ReverseBiorthogonalSplineWavelet", "RamanujanTauTheta", "RegionNearestFunction", "ReverseElement", "RamanujanTauZ", "RegionPlot", "ReverseEquilibrium", "Ramp", "RegionPlot3D", "ReverseGraph", "RandomChoice", "RegionProduct", "ReverseSort", "RandomColor", "RegionQ", "ReverseSortBy", "RandomComplex", "RegionResize", "ReverseUpEquilibrium", "RandomEntity", "RegionSize", "RevolutionAxis", "RandomFunction", "RegionSymmetricDifference", "RevolutionPlot3D", "RandomGeoPosition", "RegionUnion", "RGBColor", "RandomGraph", "RegionWithin", "RiccatiSolve", "RandomImage", "RegisterExternalEvaluator", "RiceDistribution", "RandomInstance", "RegularExpression", "RidgeFilter", "RandomInteger", "Regularization", "RiemannR", "RandomPermutation", "RegularlySampledQ", "RiemannSiegelTheta", "RandomPoint", "RegularPolygon", "RiemannSiegelZ", "RandomPolygon", "ReIm", "RiemannXi", "RandomPolyhedron", "ReImLabels", "Riffle", "RandomPrime", "ReImPlot", "Right", "RandomReal", "ReImStyle", "RightArrow", "RandomSample", "RelationalDatabase", "RightArrowBar", "RandomSeeding", "RelationGraph", "RightArrowLeftArrow", "RandomVariate", "ReleaseHold", "RightComposition", "RandomWalkProcess", "ReliabilityDistribution", "RightCosetRepresentative", "RandomWord", "ReliefImage", "RightDownTeeVector", "Range", "ReliefPlot", "RightDownVector", "RangeFilter", "RemoteAuthorizationCaching", "RightDownVectorBar", "RankedMax", "RemoteConnect", "RightTee", "RankedMin", "RemoteConnectionObject", "RightTeeArrow", "RarerProbability", "RemoteFile", "RightTeeVector", "Raster", "RemoteRun", "RightTriangle", "Raster3D", "RemoteRunProcess", "RightTriangleBar", "Rasterize", "Remove", "RightTriangleEqual", "RasterSize", "RemoveAlphaChannel", "RightUpDownVector", "Rational", "RemoveAudioStream", "RightUpTeeVector", "Rationalize", "RemoveBackground", "RightUpVector", "Rationals", "RemoveChannelListener", "RightUpVectorBar", "Ratios", "RemoveChannelSubscribers", "RightVector", "RawBoxes", "RemoveDiacritics", "RightVectorBar", "RawData", "RemoveInputStreamMethod", "RiskAchievementImportance", "RayleighDistribution", "RemoveOutputStreamMethod", "RiskReductionImportance", "Re", "RemoveUsers", "RogersTanimotoDissimilarity", "Read", "RemoveVideoStream", "RollPitchYawAngles", "ReadByteArray", "RenameDirectory", "RollPitchYawMatrix", "ReadLine", "RenameFile", "RomanNumeral", "ReadList", "RenderingOptions", "Root", "ReadProtected", "RenewalProcess", "RootApproximant", "ReadString", "RenkoChart", "RootIntervals", "Real", "RepairMesh", "RootLocusPlot", "RealAbs", "Repeated", "RootMeanSquare", "RealBlockDiagonalForm", "RepeatedNull", "RootOfUnityQ", "RealDigits", "RepeatedTiming", "RootReduce", "RealExponent", "RepeatingElement", "Roots", "Reals", "Replace", "RootSum", "RealSign", "ReplaceAll", "Rotate", "Reap", "ReplaceImageValue", "RotateLabel", "RecognitionPrior", "ReplaceList", "RotateLeft", "Record", "ReplacePart", "RotateRight", "RecordLists", "ReplacePixelValue", "RotationAction", "RecordSeparators", "ReplaceRepeated", "RotationMatrix", "Rectangle", "ReplicateLayer", "RotationTransform", "RectangleChart", "RequiredPhysicalQuantities", "Round", "RectangleChart3D", "Resampling", "RoundingRadius", "RectangularRepeatingElement", "ResamplingAlgorithmData", "Row", "RecurrenceFilter", "ResamplingMethod", "RowAlignments", "RecurrenceTable", "Rescale", "RowBox", "Red", "RescalingTransform", "RowLines", "Reduce", "ResetDirectory", "RowMinHeight", "ReferenceLineStyle", "ReshapeLayer", "RowReduce", "Refine", "Residue", "RowsEqual", "ReflectionMatrix", "ResizeLayer", "RowSpacings", "ReflectionTransform", "Resolve", "RSolve", "Refresh", "ResourceData", "RSolveValue", "RefreshRate", "ResourceFunction", "RudinShapiro", "Region", "ResourceObject", "RudvalisGroupRu", "RegionBinarize", "ResourceRegister", "Rule", "RegionBoundary", "ResourceRemove", "RuleDelayed", "RegionBoundaryStyle", "ResourceSearch", "RulePlot", "RegionBounds", "ResourceSubmit", "RulerUnits", "RegionCentroid", "ResourceSystemBase", "Run", "RegionDifference", "ResourceSystemPath", "RunProcess", "RegionDimension", "ResourceUpdate", "RunThrough", "RegionDisjoint", "ResourceVersion", "RuntimeAttributes", "RegionDistance", "ResponseForm", "RuntimeOptions", "RegionDistanceFunction", "Rest", "RussellRaoDissimilarity", "RegionEmbeddingDimension", "RestartInterval", "SameQ", "SingularValueDecomposition", "StreamDensityPlot", "SameTest", "SingularValueList", "StreamMarkers", "SameTestProperties", "SingularValuePlot", "StreamPlot", "SampledEntityClass", "Sinh", "StreamPoints", "SampleDepth", "SinhIntegral", "StreamPosition", "SampledSoundFunction", "SinIntegral", "Streams", "SampledSoundList", "SixJSymbol", "StreamScale", "SampleRate", "Skeleton", "StreamStyle", "SamplingPeriod", "SkeletonTransform", "String", "SARIMAProcess", "SkellamDistribution", "StringCases", "SARMAProcess", "Skewness", "StringContainsQ", "SASTriangle", "SkewNormalDistribution", "StringCount", "SatelliteData", "Skip", "StringDelete", "SatisfiabilityCount", "SliceContourPlot3D", "StringDrop", "SatisfiabilityInstances", "SliceDensityPlot3D", "StringEndsQ", "SatisfiableQ", "SliceDistribution", "StringExpression", "Saturday", "SliceVectorPlot3D", "StringExtract", "Save", "Slider", "StringForm", "SaveConnection", "Slider2D", "StringFormat", "SaveDefinitions", "SlideView", "StringFreeQ", "SavitzkyGolayMatrix", "Slot", "StringInsert", "SawtoothWave", "SlotSequence", "StringJoin", "Scale", "Small", "StringLength", "Scaled", "SmallCircle", "StringMatchQ", "ScaleDivisions", "Smaller", "StringPadLeft", "ScaleOrigin", "SmithDecomposition", "StringPadRight", "ScalePadding", "SmithDelayCompensator", "StringPart", "ScaleRanges", "SmithWatermanSimilarity", "StringPartition", "ScaleRangeStyle", "SmoothDensityHistogram", "StringPosition", "ScalingFunctions", "SmoothHistogram", "StringQ", "ScalingMatrix", "SmoothHistogram3D", "StringRepeat", "ScalingTransform", "SmoothKernelDistribution", "StringReplace", "Scan", "SnDispersion", "StringReplaceList", "ScheduledTask", "Snippet", "StringReplacePart", "SchurDecomposition", "SnubPolyhedron", "StringReverse", "ScientificForm", "SocialMediaData", "StringRiffle", "ScientificNotationThreshold", "SocketConnect", "StringRotateLeft", "ScorerGi", "SocketListen", "StringRotateRight", "ScorerGiPrime", "SocketListener", "StringSkeleton", "ScorerHi", "SocketObject", "StringSplit", "ScorerHiPrime", "SocketOpen", "StringStartsQ", "ScreenStyleEnvironment", "SocketReadMessage", "StringTake", "ScriptBaselineShifts", "SocketReadyQ", "StringTemplate", "ScriptMinSize", "Sockets", "StringToByteArray", "ScriptSizeMultipliers", "SocketWaitAll", "StringToStream", "Scrollbars", "SocketWaitNext", "StringTrim", "ScrollingOptions", "SoftmaxLayer", "StripBoxes", "ScrollPosition", "SokalSneathDissimilarity", "StripOnInput", "SearchAdjustment", "SolarEclipse", "StripWrapperBoxes", "SearchIndexObject", "SolarSystemFeatureData", "StructuralImportance", "SearchIndices", "SolidAngle", "StructuredSelection", "SearchQueryString", "SolidData", "StruveH", "SearchResultObject", "SolidRegionQ", "StruveL", "Sec", "Solve", "Stub", "Sech", "SolveAlways", "StudentTDistribution", "SechDistribution", "Sort", "Style", "SecondOrderConeOptimization", "SortBy", "StyleBox", "SectorChart", "SortedBy", "StyleData", "SectorChart3D", "SortedEntityClass", "StyleDefinitions", "SectorOrigin", "Sound", "Subdivide", "SectorSpacing", "SoundNote", "Subfactorial", "SecuredAuthenticationKey", "SoundVolume", "Subgraph", "SecuredAuthenticationKeys", "SourceLink", "SubMinus", "SeedRandom", "Sow", "SubPlus", "Select", "SpaceCurveData", "SubresultantPolynomialRemainders", "Selectable", "Spacer", "SubresultantPolynomials", "SelectComponents", "Spacings", "Subresultants", "SelectedCells", "Span", "Subscript", "SelectedNotebook", "SpanFromAbove", "SubscriptBox", "SelectFirst", "SpanFromBoth", "SubscriptBoxOptions", "SelectionCreateCell", "SpanFromLeft", "Subsequences", "SelectionEvaluate", "SparseArray", "Subset", "SelectionEvaluateCreateCell", "SpatialGraphDistribution", "SubsetCases", "SelectionMove", "SpatialMedian", "SubsetCount", "SelfLoopStyle", "SpatialTransformationLayer", "SubsetEqual", "SemanticImport", "Speak", "SubsetMap", "SemanticImportString", "SpeakerMatchQ", "SubsetPosition", "SemanticInterpretation", "SpearmanRankTest", "SubsetQ", "SemialgebraicComponentInstances", "SpearmanRho", "SubsetReplace", "SemidefiniteOptimization", "SpeciesData", "Subsets", "SendMail", "SpecificityGoal", "SubStar", "SendMessage", "SpectralLineData", "SubstitutionSystem", "Sequence", "Spectrogram", "Subsuperscript", "SequenceAlignment", "SpectrogramArray", "SubsuperscriptBox", "SequenceCases", "Specularity", "SubsuperscriptBoxOptions", "SequenceCount", "SpeechCases", "SubtitleEncoding", "SequenceFold", "SpeechInterpreter", "SubtitleTracks", "SequenceFoldList", "SpeechRecognize", "Subtract", "SequenceHold", "SpeechSynthesize", "SubtractFrom", "SequenceLastLayer", "SpellingCorrection", "SubtractSides", "SequenceMostLayer", "SpellingCorrectionList", "Succeeds", "SequencePosition", "SpellingOptions", "SucceedsEqual", "SequencePredict", "Sphere", "SucceedsSlantEqual", "SequencePredictorFunction", "SpherePoints", "SucceedsTilde", "SequenceReplace", "SphericalBesselJ", "Success", "SequenceRestLayer", "SphericalBesselY", "SuchThat", "SequenceReverseLayer", "SphericalHankelH1", "Sum", "SequenceSplit", "SphericalHankelH2", "SumConvergence", "Series", "SphericalHarmonicY", "SummationLayer", "SeriesCoefficient", "SphericalPlot3D", "Sunday", "SeriesData", "SphericalRegion", "SunPosition", "SeriesTermGoal", "SphericalShell", "Sunrise", "ServiceConnect", "SpheroidalEigenvalue", "Sunset", "ServiceDisconnect", "SpheroidalJoiningFactor", "SuperDagger", "ServiceExecute", "SpheroidalPS", "SuperMinus", "ServiceObject", "SpheroidalPSPrime", "SupernovaData", "ServiceRequest", "SpheroidalQS", "SuperPlus", "ServiceSubmit", "SpheroidalQSPrime", "Superscript", "SessionSubmit", "SpheroidalRadialFactor", "SuperscriptBox", "SessionTime", "SpheroidalS1", "SuperscriptBoxOptions", "Set", "SpheroidalS1Prime", "Superset", "SetAccuracy", "SpheroidalS2", "SupersetEqual", "SetAlphaChannel", "SpheroidalS2Prime", "SuperStar", "SetAttributes", "Splice", "Surd", "SetCloudDirectory", "SplicedDistribution", "SurdForm", "SetCookies", "SplineClosed", "SurfaceArea", "SetDelayed", "SplineDegree", "SurfaceData", "SetDirectory", "SplineKnots", "SurvivalDistribution", "SetEnvironment", "SplineWeights", "SurvivalFunction", "SetFileDate", "Split", "SurvivalModel", "SetOptions", "SplitBy", "SurvivalModelFit", "SetPermissions", "SpokenString", "SuzukiDistribution", "SetPrecision", "Sqrt", "SuzukiGroupSuz", "SetSelectedNotebook", "SqrtBox", "SwatchLegend", "SetSharedFunction", "SqrtBoxOptions", "Switch", "SetSharedVariable", "Square", "Symbol", "SetStreamPosition", "SquaredEuclideanDistance", "SymbolName", "SetSystemModel", "SquareFreeQ", "SymletWavelet", "SetSystemOptions", "SquareIntersection", "Symmetric", "Setter", "SquareMatrixQ", "SymmetricGroup", "SetterBar", "SquareRepeatingElement", "SymmetricKey", "Setting", "SquaresR", "SymmetricMatrixQ", "SetUsers", "SquareSubset", "SymmetricPolynomial", "Shallow", "SquareSubsetEqual", "SymmetricReduction", "ShannonWavelet", "SquareSuperset", "Symmetrize", "ShapiroWilkTest", "SquareSupersetEqual", "SymmetrizedArray", "Share", "SquareUnion", "SymmetrizedArrayRules", "SharingList", "SquareWave", "SymmetrizedDependentComponents", "Sharpen", "SSSTriangle", "SymmetrizedIndependentComponents", "ShearingMatrix", "StabilityMargins", "SymmetrizedReplacePart", "ShearingTransform", "StabilityMarginsStyle", "SynchronousInitialization", "ShellRegion", "StableDistribution", "SynchronousUpdating", "ShenCastanMatrix", "Stack", "Synonyms", "ShiftedGompertzDistribution", "StackBegin", "SyntaxForm", "ShiftRegisterSequence", "StackComplete", "SyntaxInformation", "Short", "StackedDateListPlot", "SyntaxLength", "ShortDownArrow", "StackedListPlot", "SyntaxPacket", "Shortest", "StackInhibit", "SyntaxQ", "ShortestPathFunction", "StadiumShape", "SynthesizeMissingValues", "ShortLeftArrow", "StandardAtmosphereData", "SystemCredential", "ShortRightArrow", "StandardDeviation", "SystemCredentialData", "ShortTimeFourier", "StandardDeviationFilter", "SystemCredentialKey", "ShortTimeFourierData", "StandardForm", "SystemCredentialKeys", "ShortUpArrow", "Standardize", "SystemCredentialStoreObject", "Show", "Standardized", "SystemDialogInput", "ShowAutoSpellCheck", "StandardOceanData", "SystemInformation", "ShowAutoStyles", "StandbyDistribution", "SystemInstall", "ShowCellBracket", "Star", "SystemModel", "ShowCellLabel", "StarClusterData", "SystemModeler", "ShowCellTags", "StarData", "SystemModelExamples", "ShowCursorTracker", "StarGraph", "SystemModelLinearize", "ShowGroupOpener", "StartExternalSession", "SystemModelParametricSimulate", "ShowPageBreaks", "StartingStepSize", "SystemModelPlot", "ShowSelection", "StartOfLine", "SystemModelProgressReporting", "ShowSpecialCharacters", "StartOfString", "SystemModelReliability", "ShowStringCharacters", "StartProcess", "SystemModels", "ShrinkingDelay", "StartWebSession", "SystemModelSimulate", "SiderealTime", "StateFeedbackGains", "SystemModelSimulateSensitivity", "SiegelTheta", "StateOutputEstimator", "SystemModelSimulationData", "SiegelTukeyTest", "StateResponse", "SystemOpen", "SierpinskiCurve", "StateSpaceModel", "SystemOptions", "SierpinskiMesh", "StateSpaceRealization", "SystemProcessData", "Sign", "StateSpaceTransform", "SystemProcesses", "Signature", "StateTransformationLinearize", "SystemsConnectionsModel", "SignedRankTest", "StationaryDistribution", "SystemsModelDelay", "SignedRegionDistance", "StationaryWaveletPacketTransform", "SystemsModelDelayApproximate", "SignificanceLevel", "StationaryWaveletTransform", "SystemsModelDelete", "SignPadding", "StatusArea", "SystemsModelDimensions", "SignTest", "StatusCentrality", "SystemsModelExtract", "SimilarityRules", "StepMonitor", "SystemsModelFeedbackConnect", "SimpleGraph", "StereochemistryElements", "SystemsModelLabels", "SimpleGraphQ", "StieltjesGamma", "SystemsModelLinearity", "SimplePolygonQ", "StippleShading", "SystemsModelMerge", "SimplePolyhedronQ", "StirlingS1", "SystemsModelOrder", "Simplex", "StirlingS2", "SystemsModelParallelConnect", "Simplify", "StoppingPowerData", "SystemsModelSeriesConnect", "Sin", "StrataVariables", "SystemsModelStateFeedbackConnect", "Sinc", "StratonovichProcess", "SystemsModelVectorRelativeOrders", "SinghMaddalaDistribution", "StreamColorFunction", "SingleLetterItalics", "StreamColorFunctionScaling", "Table", "Thickness", "TraceDepth", "TableAlignments", "Thin", "TraceDialog", "TableDepth", "Thinning", "TraceForward", "TableDirections", "ThompsonGroupTh", "TraceOff", "TableForm", "Thread", "TraceOn", "TableHeadings", "ThreadingLayer", "TraceOriginal", "TableSpacing", "ThreeJSymbol", "TracePrint", "TableView", "Threshold", "TraceScan", "TabView", "Through", "TrackedSymbols", "TagBox", "Throw", "TrackingFunction", "TagBoxOptions", "ThueMorse", "TracyWidomDistribution", "TaggingRules", "Thumbnail", "TradingChart", "TagSet", "Thursday", "TraditionalForm", "TagSetDelayed", "Ticks", "TrainingProgressCheckpointing", "TagUnset", "TicksStyle", "TrainingProgressFunction", "Take", "TideData", "TrainingProgressMeasurements", "TakeDrop", "Tilde", "TrainingProgressReporting", "TakeLargest", "TildeEqual", "TrainingStoppingCriterion", "TakeLargestBy", "TildeFullEqual", "TrainingUpdateSchedule", "TakeList", "TildeTilde", "TransferFunctionCancel", "TakeSmallest", "TimeConstrained", "TransferFunctionExpand", "TakeSmallestBy", "TimeConstraint", "TransferFunctionFactor", "TakeWhile", "TimeDirection", "TransferFunctionModel", "Tally", "TimeFormat", "TransferFunctionPoles", "Tan", "TimeGoal", "TransferFunctionTransform", "Tanh", "TimelinePlot", "TransferFunctionZeros", "TargetDevice", "TimeObject", "TransformationClass", "TargetFunctions", "TimeObjectQ", "TransformationFunction", "TargetSystem", "TimeRemaining", "TransformationFunctions", "TargetUnits", "Times", "TransformationMatrix", "TaskAbort", "TimesBy", "TransformedDistribution", "TaskExecute", "TimeSeries", "TransformedField", "TaskObject", "TimeSeriesAggregate", "TransformedProcess", "TaskRemove", "TimeSeriesForecast", "TransformedRegion", "TaskResume", "TimeSeriesInsert", "TransitionDirection", "Tasks", "TimeSeriesInvertibility", "TransitionDuration", "TaskSuspend", "TimeSeriesMap", "TransitionEffect", "TaskWait", "TimeSeriesMapThread", "TransitiveClosureGraph", "TautologyQ", "TimeSeriesModel", "TransitiveReductionGraph", "TelegraphProcess", "TimeSeriesModelFit", "Translate", "TemplateApply", "TimeSeriesResample", "TranslationOptions", "TemplateBox", "TimeSeriesRescale", "TranslationTransform", "TemplateBoxOptions", "TimeSeriesShift", "Transliterate", "TemplateExpression", "TimeSeriesThread", "Transparent", "TemplateIf", "TimeSeriesWindow", "Transpose", "TemplateObject", "TimeUsed", "TransposeLayer", "TemplateSequence", "TimeValue", "TravelDirections", "TemplateSlot", "TimeZone", "TravelDirectionsData", "TemplateWith", "TimeZoneConvert", "TravelDistance", "TemporalData", "TimeZoneOffset", "TravelDistanceList", "TemporalRegularity", "Timing", "TravelMethod", "Temporary", "Tiny", "TravelTime", "TensorContract", "TitsGroupT", "TreeForm", "TensorDimensions", "ToBoxes", "TreeGraph", "TensorExpand", "ToCharacterCode", "TreeGraphQ", "TensorProduct", "ToContinuousTimeModel", "TreePlot", "TensorRank", "Today", "TrendStyle", "TensorReduce", "ToDiscreteTimeModel", "Triangle", "TensorSymmetry", "ToEntity", "TriangleCenter", "TensorTranspose", "ToeplitzMatrix", "TriangleConstruct", "TensorWedge", "ToExpression", "TriangleMeasurement", "TestID", "Together", "TriangleWave", "TestReport", "Toggler", "TriangularDistribution", "TestReportObject", "TogglerBar", "TriangulateMesh", "TestResultObject", "ToInvertibleTimeSeries", "Trig", "Tetrahedron", "TokenWords", "TrigExpand", "TeXForm", "Tolerance", "TrigFactor", "Text", "ToLowerCase", "TrigFactorList", "TextAlignment", "Tomorrow", "Trigger", "TextCases", "ToNumberField", "TrigReduce", "TextCell", "Tooltip", "TrigToExp", "TextClipboardType", "TooltipDelay", "TrimmedMean", "TextContents", "TooltipStyle", "TrimmedVariance", "TextData", "ToonShading", "TropicalStormData", "TextElement", "Top", "True", "TextGrid", "TopHatTransform", "TrueQ", "TextJustification", "ToPolarCoordinates", "TruncatedDistribution", "TextPacket", "TopologicalSort", "TruncatedPolyhedron", "TextPosition", "ToRadicals", "TsallisQExponentialDistribution", "TextRecognize", "ToRules", "TsallisQGaussianDistribution", "TextSearch", "ToSphericalCoordinates", "TTest", "TextSearchReport", "ToString", "Tube", "TextSentences", "Total", "Tuesday", "TextString", "TotalLayer", "TukeyLambdaDistribution", "TextStructure", "TotalVariationFilter", "TukeyWindow", "TextTranslation", "TotalWidth", "TunnelData", "Texture", "TouchPosition", "Tuples", "TextureCoordinateFunction", "TouchscreenAutoZoom", "TuranGraph", "TextureCoordinateScaling", "TouchscreenControlPlacement", "TuringMachine", "TextWords", "ToUpperCase", "TuttePolynomial", "Therefore", "Tr", "TwoWayRule", "ThermodynamicData", "Trace", "Typed", "ThermometerGauge", "TraceAbove", "TypeSpecifier", "Thick", "TraceBackward", "UnateQ", "UnitaryMatrixQ", "UpperCaseQ", "Uncompress", "UnitBox", "UpperLeftArrow", "UnconstrainedParameters", "UnitConvert", "UpperRightArrow", "Undefined", "UnitDimensions", "UpperTriangularize", "UnderBar", "Unitize", "UpperTriangularMatrixQ", "Underflow", "UnitRootTest", "Upsample", "Underlined", "UnitSimplify", "UpSet", "Underoverscript", "UnitStep", "UpSetDelayed", "UnderoverscriptBox", "UnitSystem", "UpTee", "UnderoverscriptBoxOptions", "UnitTriangle", "UpTeeArrow", "Underscript", "UnitVector", "UpTo", "UnderscriptBox", "UnitVectorLayer", "UpValues", "UnderscriptBoxOptions", "UnityDimensions", "URL", "UnderseaFeatureData", "UniverseModelData", "URLBuild", "UndirectedEdge", "UniversityData", "URLDecode", "UndirectedGraph", "UnixTime", "URLDispatcher", "UndirectedGraphQ", "Unprotect", "URLDownload", "UndoOptions", "UnregisterExternalEvaluator", "URLDownloadSubmit", "UndoTrackedVariables", "UnsameQ", "URLEncode", "Unequal", "UnsavedVariables", "URLExecute", "UnequalTo", "Unset", "URLExpand", "Unevaluated", "UnsetShared", "URLParse", "UniformDistribution", "UpArrow", "URLQueryDecode", "UniformGraphDistribution", "UpArrowBar", "URLQueryEncode", "UniformPolyhedron", "UpArrowDownArrow", "URLRead", "UniformSumDistribution", "Update", "URLResponseTime", "Uninstall", "UpdateInterval", "URLShorten", "Union", "UpdatePacletSites", "URLSubmit", "UnionedEntityClass", "UpdateSearchIndex", "UsingFrontEnd", "UnionPlus", "UpDownArrow", "UtilityFunction", "Unique", "UpEquilibrium", "ValenceErrorHandling", "VerifyDigitalSignature", "VertexStyle", "ValidationLength", "VerifyFileSignature", "VertexTextureCoordinates", "ValidationSet", "VerifyInterpretation", "VertexWeight", "ValueDimensions", "VerifySecurityCertificates", "VertexWeightedGraphQ", "ValuePreprocessingFunction", "VerifySolutions", "VerticalBar", "ValueQ", "VerifyTestAssumptions", "VerticalGauge", "Values", "VersionedPreferences", "VerticalSeparator", "Variables", "VertexAdd", "VerticalSlider", "Variance", "VertexCapacity", "VerticalTilde", "VarianceEquivalenceTest", "VertexColors", "Video", "VarianceEstimatorFunction", "VertexComponent", "VideoEncoding", "VarianceGammaDistribution", "VertexConnectivity", "VideoExtractFrames", "VarianceTest", "VertexContract", "VideoFrameList", "VectorAngle", "VertexCoordinates", "VideoFrameMap", "VectorAround", "VertexCorrelationSimilarity", "VideoPause", "VectorAspectRatio", "VertexCosineSimilarity", "VideoPlay", "VectorColorFunction", "VertexCount", "VideoQ", "VectorColorFunctionScaling", "VertexCoverQ", "VideoStop", "VectorDensityPlot", "VertexDataCoordinates", "VideoStream", "VectorGreater", "VertexDegree", "VideoStreams", "VectorGreaterEqual", "VertexDelete", "VideoTimeSeries", "VectorLess", "VertexDiceSimilarity", "VideoTracks", "VectorLessEqual", "VertexEccentricity", "VideoTrim", "VectorMarkers", "VertexInComponent", "ViewAngle", "VectorPlot", "VertexInDegree", "ViewCenter", "VectorPlot3D", "VertexIndex", "ViewMatrix", "VectorPoints", "VertexJaccardSimilarity", "ViewPoint", "VectorQ", "VertexLabels", "ViewProjection", "VectorRange", "VertexLabelStyle", "ViewRange", "Vectors", "VertexList", "ViewVector", "VectorScaling", "VertexNormals", "ViewVertical", "VectorSizes", "VertexOutComponent", "Visible", "VectorStyle", "VertexOutDegree", "VoiceStyleData", "Vee", "VertexQ", "VoigtDistribution", "Verbatim", "VertexReplace", "VolcanoData", "VerificationTest", "VertexShape", "Volume", "VerifyConvergence", "VertexShapeFunction", "VonMisesDistribution", "VerifyDerivedKey", "VertexSize", "VoronoiMesh", "WaitAll", "WeierstrassEta2", "WindowElements", "WaitNext", "WeierstrassEta3", "WindowFloating", "WakebyDistribution", "WeierstrassHalfPeriods", "WindowFrame", "WalleniusHypergeometricDistribution", "WeierstrassHalfPeriodW1", "WindowFrameElements", "WaringYuleDistribution", "WeierstrassHalfPeriodW2", "WindowMargins", "WarpingCorrespondence", "WeierstrassHalfPeriodW3", "WindowOpacity", "WarpingDistance", "WeierstrassInvariantG2", "WindowSize", "WatershedComponents", "WeierstrassInvariantG3", "WindowStatusArea", "WatsonUSquareTest", "WeierstrassInvariants", "WindowTitle", "WattsStrogatzGraphDistribution", "WeierstrassP", "WindowToolbars", "WaveletBestBasis", "WeierstrassPPrime", "WindSpeedData", "WaveletFilterCoefficients", "WeierstrassSigma", "WindVectorData", "WaveletImagePlot", "WeierstrassZeta", "WinsorizedMean", "WaveletListPlot", "WeightedAdjacencyGraph", "WinsorizedVariance", "WaveletMapIndexed", "WeightedAdjacencyMatrix", "WishartMatrixDistribution", "WaveletMatrixPlot", "WeightedData", "With", "WaveletPhi", "WeightedGraphQ", "WolframAlpha", "WaveletPsi", "Weights", "WolframLanguageData", "WaveletScale", "WelchWindow", "Word", "WaveletScalogram", "WheelGraph", "WordBoundary", "WaveletThreshold", "WhenEvent", "WordCharacter", "WeaklyConnectedComponents", "Which", "WordCloud", "WeaklyConnectedGraphComponents", "While", "WordCount", "WeaklyConnectedGraphQ", "White", "WordCounts", "WeakStationarity", "WhiteNoiseProcess", "WordData", "WeatherData", "WhitePoint", "WordDefinition", "WeatherForecastData", "Whitespace", "WordFrequency", "WebAudioSearch", "WhitespaceCharacter", "WordFrequencyData", "WebElementObject", "WhittakerM", "WordList", "WeberE", "WhittakerW", "WordOrientation", "WebExecute", "WienerFilter", "WordSearch", "WebImage", "WienerProcess", "WordSelectionFunction", "WebImageSearch", "WignerD", "WordSeparators", "WebSearch", "WignerSemicircleDistribution", "WordSpacings", "WebSessionObject", "WikidataData", "WordStem", "WebSessions", "WikidataSearch", "WordTranslation", "WebWindowObject", "WikipediaData", "WorkingPrecision", "Wedge", "WikipediaSearch", "WrapAround", "Wednesday", "WilksW", "Write", "WeibullDistribution", "WilksWTest", "WriteLine", "WeierstrassE1", "WindDirectionData", "WriteString", "WeierstrassE2", "WindingCount", "Wronskian", "WeierstrassE3", "WindingPolygon", "WeierstrassEta1", "WindowClickSelect", "XMLElement", "XMLTemplate", "Xor", "XMLObject", "Xnor", "XYZColor", "Yellow", "Yesterday", "YuleDissimilarity", "ZernikeR", "ZetaZero", "ZoomFactor", "ZeroSymmetric", "ZIPCodeData", "ZTest", "ZeroTest", "ZipfDistribution", "ZTransform", "Zeta", "ZoomCenter"] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab.rb new file mode 100644 index 0000000..d284401 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab.rb @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Matlab < RegexLexer + title "MATLAB" + desc "Matlab" + tag 'matlab' + aliases 'm' + filenames '*.m' + mimetypes 'text/x-matlab', 'application/x-matlab' + + def self.keywords + @keywords = Set.new %w( + arguments break case catch classdef continue else elseif end for + function global if import methods otherwise parfor persistent + properties return spmd switch try while + ) + end + + # self-modifying method that loads the builtins file + def self.builtins + Kernel::load File.join(Lexers::BASE_DIR, 'matlab/keywords.rb') + builtins + end + + state :root do + rule %r/\s+/m, Text # Whitespace + rule %r([{]%.*?%[}])m, Comment::Multiline + rule %r/%.*$/, Comment::Single + rule %r/([.][.][.])(.*?)$/ do + groups(Keyword, Comment) + end + + rule %r/^(!)(.*?)(?=%|$)/ do |m| + token Keyword, m[1] + delegate Shell, m[2] + end + + + rule %r/[a-zA-Z][_a-zA-Z0-9]*/m do |m| + match = m[0] + if self.class.keywords.include? match + token Keyword + elsif self.class.builtins.include? match + token Name::Builtin + else + token Name + end + end + + rule %r{[(){};:,\/\\\]\[]}, Punctuation + + rule %r/~=|==|<<|>>|[-~+\/*%=<>&^|.@]/, Operator + + + rule %r/(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float + rule %r/\d+e[+-]?[0-9]+/i, Num::Float + rule %r/\d+L/, Num::Integer::Long + rule %r/\d+/, Num::Integer + + rule %r/'(?=(.*'))/, Str::Single, :chararray + rule %r/"(?=(.*"))/, Str::Double, :string + rule %r/'/, Operator + end + + state :chararray do + rule %r/[^']+/, Str::Single + rule %r/''/, Str::Escape + rule %r/'/, Str::Single, :pop! + end + + state :string do + rule %r/[^"]+/, Str::Double + rule %r/""/, Str::Escape + rule %r/"/, Str::Double, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab/builtins.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab/builtins.rb new file mode 100644 index 0000000..63d9bb5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab/builtins.rb @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# automatically generated by `rake builtins:matlab` +module Rouge + module Lexers + def Matlab.builtins + @builtins ||= Set.new ["abs", "accumarray", "acos", "acosd", "acosh", "acot", "acotd", "acoth", "acsc", "acscd", "acsch", "actxcontrol", "actxcontrollist", "actxcontrolselect", "actxGetRunningServer", "actxserver", "add", "addboundary", "addcats", "addCause", "addClass", "addCondition", "addConditionsFrom", "addConstructor", "addCorrection", "addedge", "addevent", "addFields", "addFields", "addFile", "addFolderIncludingChildFiles", "addFunction", "addLabel", "addlistener", "addMethod", "addmulti", "addnode", "addOptional", "addParameter", "addParamValue", "addPath", "addpath", "addPlugin", "addpoints", "addpref", "addprop", "addprop", "addproperty", "addProperty", "addReference", "addRequired", "addsample", "addsampletocollection", "addShortcut", "addShutdownFile", "addStartupFile", "addTeardown", "addTeardown", "addtodate", "addToolbarExplorationButtons", "addts", "addvars", "adjacency", "airy", "align", "alim", "all", "allchild", "allowModelReferenceDiscreteSampleTimeInheritanceImpl", "alpha", "alphamap", "alphaShape", "alphaSpectrum", "alphaTriangulation", "amd", "analyzeCodeCompatibility", "ancestor", "and", "angle", "animatedline", "annotation", "ans", "any", "appdesigner", "append", "append", "applyFixture", "applyFixture", "area", "area", "area", "array2table", "array2timetable", "arrayfun", "ascii", "asec", "asecd", "asech", "asin", "asind", "asinh", "assert", "assertAccessed", "assertCalled", "assertClass", "assertEmpty", "assertEqual", "assertError", "assertFail", "assertFalse", "assertGreaterThan", "assertGreaterThanOrEqual", "assertInstanceOf", "assertLength", "assertLessThan", "assertLessThanOrEqual", "assertMatches", "assertNotAccessed", "assertNotCalled", "assertNotEmpty", "assertNotEqual", "assertNotSameHandle", "assertNotSet", "assertNumElements", "assertReturnsTrue", "assertSameHandle", "assertSet", "assertSize", "assertSubstring", "assertThat", "assertTrue", "assertUsing", "assertWarning", "assertWarningFree", "assignin", "assignOutputsWhen", "assumeAccessed", "assumeCalled", "assumeClass", "assumeEmpty", "assumeEqual", "assumeError", "assumeFail", "assumeFalse", "assumeGreaterThan", "assumeGreaterThanOrEqual", "assumeInstanceOf", "assumeLength", "assumeLessThan", "assumeLessThanOrEqual", "assumeMatches", "assumeNotAccessed", "assumeNotCalled", "assumeNotEmpty", "assumeNotEqual", "assumeNotSameHandle", "assumeNotSet", "assumeNumElements", "assumeReturnsTrue", "assumeSameHandle", "assumeSet", "assumeSize", "assumeSubstring", "assumeThat", "assumeTrue", "assumeUsing", "assumeWarning", "assumeWarningFree", "atan", "atan2", "atan2d", "atand", "atanh", "audiodevinfo", "audioinfo", "audioplayer", "audioread", "audiorecorder", "audiowrite", "autumn", "aviinfo", "axes", "axis", "axtoolbar", "axtoolbarbtn", "balance", "bandwidth", "bar", "bar3", "bar3h", "barh", "barycentricToCartesian", "baryToCart", "base2dec", "batchStartupOptionUsed", "bctree", "beep", "BeginInvoke", "bench", "besselh", "besseli", "besselj", "besselk", "bessely", "beta", "betainc", "betaincinv", "betaln", "between", "bfsearch", "bicg", "bicgstab", "bicgstabl", "biconncomp", "bin2dec", "binary", "binscatter", "bitand", "bitcmp", "bitget", "bitnot", "bitor", "bitset", "bitshift", "bitxor", "blanks", "blkdiag", "bone", "boundary", "boundary", "boundaryFacets", "boundaryshape", "boundingbox", "bounds", "box", "break", "brighten", "brush", "bsxfun", "build", "builddocsearchdb", "builtin", "bvp4c", "bvp5c", "bvpget", "bvpinit", "bvpset", "bvpxtend", "caldays", "caldiff", "calendar", "calendarDuration", "calllib", "callSoapService", "calmonths", "calquarters", "calweeks", "calyears", "camdolly", "cameratoolbar", "camlight", "camlookat", "camorbit", "campan", "campos", "camproj", "camroll", "camtarget", "camup", "camva", "camzoom", "cancel", "cancelled", "cart2pol", "cart2sph", "cartesianToBarycentric", "cartToBary", "cast", "cat", "cat", "categorical", "categories", "caxis", "cd", "cd", "cdf2rdf", "cdfepoch", "cdfinfo", "cdflib", "cdflib.close", "cdflib.closeVar", "cdflib.computeEpoch", "cdflib.computeEpoch16", "cdflib.create", "cdflib.createAttr", "cdflib.createVar", "cdflib.delete", "cdflib.deleteAttr", "cdflib.deleteAttrEntry", "cdflib.deleteAttrgEntry", "cdflib.deleteVar", "cdflib.deleteVarRecords", "cdflib.epoch16Breakdown", "cdflib.epochBreakdown", "cdflib.getAttrEntry", "cdflib.getAttrgEntry", "cdflib.getAttrMaxEntry", "cdflib.getAttrMaxgEntry", "cdflib.getAttrName", "cdflib.getAttrNum", "cdflib.getAttrScope", "cdflib.getCacheSize", "cdflib.getChecksum", "cdflib.getCompression", "cdflib.getCompressionCacheSize", "cdflib.getConstantNames", "cdflib.getConstantValue", "cdflib.getCopyright", "cdflib.getFileBackward", "cdflib.getFormat", "cdflib.getLibraryCopyright", "cdflib.getLibraryVersion", "cdflib.getMajority", "cdflib.getName", "cdflib.getNumAttrEntries", "cdflib.getNumAttrgEntries", "cdflib.getNumAttributes", "cdflib.getNumgAttributes", "cdflib.getReadOnlyMode", "cdflib.getStageCacheSize", "cdflib.getValidate", "cdflib.getVarAllocRecords", "cdflib.getVarBlockingFactor", "cdflib.getVarCacheSize", "cdflib.getVarCompression", "cdflib.getVarData", "cdflib.getVarMaxAllocRecNum", "cdflib.getVarMaxWrittenRecNum", "cdflib.getVarName", "cdflib.getVarNum", "cdflib.getVarNumRecsWritten", "cdflib.getVarPadValue", "cdflib.getVarRecordData", "cdflib.getVarReservePercent", "cdflib.getVarsMaxWrittenRecNum", "cdflib.getVarSparseRecords", "cdflib.getVersion", "cdflib.hyperGetVarData", "cdflib.hyperPutVarData", "cdflib.inquire", "cdflib.inquireAttr", "cdflib.inquireAttrEntry", "cdflib.inquireAttrgEntry", "cdflib.inquireVar", "cdflib.open", "cdflib.putAttrEntry", "cdflib.putAttrgEntry", "cdflib.putVarData", "cdflib.putVarRecordData", "cdflib.renameAttr", "cdflib.renameVar", "cdflib.setCacheSize", "cdflib.setChecksum", "cdflib.setCompression", "cdflib.setCompressionCacheSize", "cdflib.setFileBackward", "cdflib.setFormat", "cdflib.setMajority", "cdflib.setReadOnlyMode", "cdflib.setStageCacheSize", "cdflib.setValidate", "cdflib.setVarAllocBlockRecords", "cdflib.setVarBlockingFactor", "cdflib.setVarCacheSize", "cdflib.setVarCompression", "cdflib.setVarInitialRecs", "cdflib.setVarPadValue", "cdflib.SetVarReservePercent", "cdflib.setVarsCacheSize", "cdflib.setVarSparseRecords", "cdfread", "cdfwrite", "ceil", "cell", "cell2mat", "cell2struct", "cell2table", "celldisp", "cellfun", "cellplot", "cellstr", "centrality", "centroid", "cgs", "changeFields", "changeFields", "char", "char", "checkcode", "checkin", "checkout", "chol", "cholupdate", "choose", "circshift", "circumcenter", "circumcenters", "cla", "clabel", "class", "classdef", "classUnderlying", "clc", "clear", "clear", "clearAllMemoizedCaches", "clearCache", "clearMockHistory", "clearPersonalValue", "clearpoints", "clearTemporaryValue", "clearvars", "clf", "clibgen.buildInterface", "clibgen.ClassDefinition", "clibgen.ConstructorDefinition", "clibgen.EnumDefinition", "clibgen.FunctionDefinition", "clibgen.generateLibraryDefinition", "clibgen.LibraryDefinition", "clibgen.MethodDefinition", "clibgen.PropertyDefinition", "clibRelease", "clipboard", "clock", "clone", "close", "close", "close", "close", "close", "closeFile", "closereq", "cmopts", "cmpermute", "cmunique", "CodeCompatibilityAnalysis", "codeCompatibilityReport", "colamd", "collapse", "colon", "colorbar", "colorcube", "colordef", "colormap", "ColorSpec", "colperm", "COM", "com.mathworks.engine.MatlabEngine", "com.mathworks.matlab.types.CellStr", "com.mathworks.matlab.types.Complex", "com.mathworks.matlab.types.HandleObject", "com.mathworks.matlab.types.Struct", "combine", "Combine", "CombinedDatastore", "comet", "comet3", "compan", "compass", "complete", "complete", "complete", "complete", "complete", "complete", "complete", "complex", "compose", "computer", "cond", "condeig", "condensation", "condest", "coneplot", "conj", "conncomp", "containers.Map", "contains", "continue", "contour", "contour3", "contourc", "contourf", "contourslice", "contrast", "conv", "conv2", "convert", "convert", "convert", "convertCharsToStrings", "convertContainedStringsToChars", "convertLike", "convertStringsToChars", "convertvars", "convexHull", "convexHull", "convhull", "convhull", "convhulln", "convn", "cool", "copper", "copy", "copyElement", "copyfile", "copyHDU", "copyobj", "copyTo", "corrcoef", "cos", "cosd", "cosh", "cospi", "cot", "cotd", "coth", "count", "countcats", "countEachLabel", "cov", "cplxpair", "cputime", "createCategory", "createClassFromWsdl", "createFile", "createImg", "createLabel", "createMock", "createSampleTime", "createSharedTestFixture", "createSoapMessage", "createTbl", "createTestClassInstance", "createTestMethodInstance", "criticalAlpha", "cross", "csc", "cscd", "csch", "csvread", "csvwrite", "ctranspose", "cummax", "cummin", "cumprod", "cumsum", "cumtrapz", "curl", "currentProject", "customverctrl", "cylinder", "daqread", "daspect", "datacursormode", "datastore", "dataTipInteraction", "dataTipTextRow", "date", "datenum", "dateshift", "datestr", "datetick", "datetime", "datevec", "day", "days", "dbclear", "dbcont", "dbdown", "dblquad", "dbmex", "dbquit", "dbstack", "dbstatus", "dbstep", "dbstop", "dbtype", "dbup", "dde23", "ddeget", "ddensd", "ddesd", "ddeset", "deal", "deblank", "dec2base", "dec2bin", "dec2hex", "decic", "decomposition", "deconv", "defineArgument", "defineArgument", "defineArgument", "defineOutput", "defineOutput", "deg2rad", "degree", "del2", "delaunay", "delaunayn", "DelaunayTri", "DelaunayTri", "delaunayTriangulation", "delegateTo", "delegateTo", "delete", "delete", "delete", "delete", "delete", "deleteCol", "deleteFile", "deleteHDU", "deleteKey", "deleteproperty", "deleteRecord", "deleteRows", "delevent", "delimitedTextImportOptions", "delsample", "delsamplefromcollection", "demo", "det", "details", "detectImportOptions", "detrend", "detrend", "deval", "dfsearch", "diag", "diagnose", "dialog", "diary", "diff", "diffuse", "digraph", "dir", "dir", "disableDefaultInteractivity", "discretize", "disp", "disp", "disp", "display", "displayEmptyObject", "displayNonScalarObject", "displayScalarHandleToDeletedObject", "displayScalarObject", "dissect", "distances", "dither", "divergence", "dlmread", "dlmwrite", "dmperm", "doc", "docsearch", "done", "done", "dos", "dot", "double", "drag", "dragrect", "drawnow", "dsearchn", "duration", "dynamicprops", "echo", "echodemo", "edgeAttachments", "edgeAttachments", "edgecount", "edges", "edges", "edit", "eig", "eigs", "ellipj", "ellipke", "ellipsoid", "empty", "enableDefaultInteractivity", "enableNETfromNetworkDrive", "enableservice", "end", "EndInvoke", "endsWith", "enumeration", "eomday", "eps", "eq", "eq", "equilibrate", "erase", "eraseBetween", "erf", "erfc", "erfcinv", "erfcx", "erfinv", "error", "errorbar", "errordlg", "etime", "etree", "etreeplot", "eval", "evalc", "evalin", "event.DynamicPropertyEvent", "event.EventData", "event.hasListener", "event.listener", "event.PropertyEvent", "event.proplistener", "eventlisteners", "events", "events", "exceltime", "Execute", "exist", "exit", "exp", "expand", "expectedContentLength", "expectedContentLength", "expint", "expm", "expm1", "export", "export2wsdlg", "exportsetupdlg", "extractAfter", "extractBefore", "extractBetween", "eye", "ezcontour", "ezcontourf", "ezmesh", "ezmeshc", "ezplot", "ezplot3", "ezpolar", "ezsurf", "ezsurfc", "faceNormal", "faceNormals", "factor", "factorial", "false", "fatalAssertAccessed", "fatalAssertCalled", "fatalAssertClass", "fatalAssertEmpty", "fatalAssertEqual", "fatalAssertError", "fatalAssertFail", "fatalAssertFalse", "fatalAssertGreaterThan", "fatalAssertGreaterThanOrEqual", "fatalAssertInstanceOf", "fatalAssertLength", "fatalAssertLessThan", "fatalAssertLessThanOrEqual", "fatalAssertMatches", "fatalAssertNotAccessed", "fatalAssertNotCalled", "fatalAssertNotEmpty", "fatalAssertNotEqual", "fatalAssertNotSameHandle", "fatalAssertNotSet", "fatalAssertNumElements", "fatalAssertReturnsTrue", "fatalAssertSameHandle", "fatalAssertSet", "fatalAssertSize", "fatalAssertSubstring", "fatalAssertThat", "fatalAssertTrue", "fatalAssertUsing", "fatalAssertWarning", "fatalAssertWarningFree", "fclose", "fclose", "fcontour", "feather", "featureEdges", "featureEdges", "feof", "ferror", "feval", "Feval", "feval", "fewerbins", "fft", "fft2", "fftn", "fftshift", "fftw", "fgetl", "fgetl", "fgets", "fgets", "fieldnames", "figure", "figurepalette", "fileattrib", "fileDatastore", "filemarker", "fileMode", "fileName", "fileparts", "fileread", "filesep", "fill", "fill3", "fillmissing", "filloutliers", "filter", "filter", "filter2", "fimplicit", "fimplicit3", "find", "findall", "findCategory", "findedge", "findEvent", "findfigs", "findFile", "findgroups", "findLabel", "findnode", "findobj", "findobj", "findprop", "findstr", "finish", "fitsdisp", "fitsinfo", "fitsread", "fitswrite", "fix", "fixedWidthImportOptions", "flag", "flintmax", "flip", "flipdim", "flipedge", "fliplr", "flipud", "floor", "flow", "fmesh", "fminbnd", "fminsearch", "fopen", "fopen", "for", "format", "fplot", "fplot3", "fprintf", "fprintf", "frame2im", "fread", "fread", "freeBoundary", "freeBoundary", "freqspace", "frewind", "fscanf", "fscanf", "fseek", "fsurf", "ftell", "ftp", "full", "fullfile", "func2str", "function", "functions", "FunctionTestCase", "functiontests", "funm", "fwrite", "fwrite", "fzero", "gallery", "gamma", "gammainc", "gammaincinv", "gammaln", "gather", "gca", "gcbf", "gcbo", "gcd", "gcf", "gcmr", "gco", "ge", "genpath", "genvarname", "geoaxes", "geobasemap", "geobubble", "geodensityplot", "geolimits", "geoplot", "geoscatter", "geotickformat", "get", "get", "get", "get", "get", "get", "get", "get", "get", "get", "get", "getabstime", "getabstime", "getAColParms", "getappdata", "getaudiodata", "getBColParms", "GetCharArray", "getClass", "getColName", "getColType", "getConstantValue", "getCurrentTime", "getData", "getData", "getData", "getData", "getData", "getdatasamples", "getdatasamplesize", "getDiagnosticFor", "getDiagnosticFor", "getDiscreteStateImpl", "getDiscreteStateSpecificationImpl", "getdisp", "getenv", "getEqColType", "getfield", "getFields", "getFields", "getFileFormats", "getFooter", "getframe", "GetFullMatrix", "getGlobalNamesImpl", "getHdrSpace", "getHDUnum", "getHDUtype", "getHeader", "getHeaderImpl", "getIconImpl", "getImgSize", "getImgType", "getImpulseResponseLengthImpl", "getInputDimensionConstraintImpl", "getinterpmethod", "getLocation", "getLocation", "getMockHistory", "getNegativeDiagnosticFor", "getnext", "getNumCols", "getNumHDUs", "getNumInputs", "getNumInputsImpl", "getNumOutputs", "getNumOutputsImpl", "getNumRows", "getOpenFiles", "getOutputDataTypeImpl", "getOutputDimensionConstraintImpl", "getOutputSizeImpl", "getParameter", "getParameter", "getParameter", "getpixelposition", "getplayer", "getpoints", "getPostActValString", "getPostConditionString", "getPostDescriptionString", "getPostExpValString", "getPreDescriptionString", "getpref", "getProfiles", "getPropertyGroups", "getPropertyGroupsImpl", "getqualitydesc", "getReasonPhrase", "getReasonPhrase", "getReport", "getsamples", "getSampleTime", "getSampleTimeImpl", "getsampleusingtime", "getsampleusingtime", "getSharedTestFixtures", "getSimulateUsingImpl", "getSimulinkFunctionNamesImpl", "gettimeseriesnames", "getTimeStr", "gettsafteratevent", "gettsafterevent", "gettsatevent", "gettsbeforeatevent", "gettsbeforeevent", "gettsbetweenevents", "GetVariable", "getvaropts", "getVersion", "GetWorkspaceData", "ginput", "global", "gmres", "gobjects", "gplot", "grabcode", "gradient", "graph", "GraphPlot", "gray", "graymon", "grid", "griddata", "griddatan", "griddedInterpolant", "groot", "groupcounts", "groupsummary", "grouptransform", "gsvd", "gt", "gtext", "guidata", "guide", "guihandles", "gunzip", "gzip", "H5.close", "H5.garbage_collect", "H5.get_libversion", "H5.open", "H5.set_free_list_limits", "H5A.close", "H5A.create", "H5A.delete", "H5A.get_info", "H5A.get_name", "H5A.get_space", "H5A.get_type", "H5A.iterate", "H5A.open", "H5A.open_by_idx", "H5A.open_by_name", "H5A.read", "H5A.write", "h5create", "H5D.close", "H5D.create", "H5D.get_access_plist", "H5D.get_create_plist", "H5D.get_offset", "H5D.get_space", "H5D.get_space_status", "H5D.get_storage_size", "H5D.get_type", "H5D.open", "H5D.read", "H5D.set_extent", "H5D.vlen_get_buf_size", "H5D.write", "h5disp", "H5DS.attach_scale", "H5DS.detach_scale", "H5DS.get_label", "H5DS.get_num_scales", "H5DS.get_scale_name", "H5DS.is_scale", "H5DS.iterate_scales", "H5DS.set_label", "H5DS.set_scale", "H5E.clear", "H5E.get_major", "H5E.get_minor", "H5E.walk", "H5F.close", "H5F.create", "H5F.flush", "H5F.get_access_plist", "H5F.get_create_plist", "H5F.get_filesize", "H5F.get_freespace", "H5F.get_info", "H5F.get_mdc_config", "H5F.get_mdc_hit_rate", "H5F.get_mdc_size", "H5F.get_name", "H5F.get_obj_count", "H5F.get_obj_ids", "H5F.is_hdf5", "H5F.mount", "H5F.open", "H5F.reopen", "H5F.set_mdc_config", "H5F.unmount", "H5G.close", "H5G.create", "H5G.get_info", "H5G.open", "H5I.dec_ref", "H5I.get_file_id", "H5I.get_name", "H5I.get_ref", "H5I.get_type", "H5I.inc_ref", "H5I.is_valid", "h5info", "H5L.copy", "H5L.create_external", "H5L.create_hard", "H5L.create_soft", "H5L.delete", "H5L.exists", "H5L.get_info", "H5L.get_name_by_idx", "H5L.get_val", "H5L.iterate", "H5L.iterate_by_name", "H5L.move", "H5L.visit", "H5L.visit_by_name", "H5ML.compare_values", "H5ML.get_constant_names", "H5ML.get_constant_value", "H5ML.get_function_names", "H5ML.get_mem_datatype", "H5ML.hoffset", "H5ML.sizeof", "H5O.close", "H5O.copy", "H5O.get_comment", "H5O.get_comment_by_name", "H5O.get_info", "H5O.link", "H5O.open", "H5O.open_by_idx", "H5O.set_comment", "H5O.set_comment_by_name", "H5O.visit", "H5O.visit_by_name", "H5P.all_filters_avail", "H5P.close", "H5P.close_class", "H5P.copy", "H5P.create", "H5P.equal", "H5P.exist", "H5P.fill_value_defined", "H5P.get", "H5P.get_alignment", "H5P.get_alloc_time", "H5P.get_attr_creation_order", "H5P.get_attr_phase_change", "H5P.get_btree_ratios", "H5P.get_char_encoding", "H5P.get_chunk", "H5P.get_chunk_cache", "H5P.get_class", "H5P.get_class_name", "H5P.get_class_parent", "H5P.get_copy_object", "H5P.get_create_intermediate_group", "H5P.get_driver", "H5P.get_edc_check", "H5P.get_external", "H5P.get_external_count", "H5P.get_family_offset", "H5P.get_fapl_core", "H5P.get_fapl_family", "H5P.get_fapl_multi", "H5P.get_fclose_degree", "H5P.get_fill_time", "H5P.get_fill_value", "H5P.get_filter", "H5P.get_filter_by_id", "H5P.get_gc_references", "H5P.get_hyper_vector_size", "H5P.get_istore_k", "H5P.get_layout", "H5P.get_libver_bounds", "H5P.get_link_creation_order", "H5P.get_link_phase_change", "H5P.get_mdc_config", "H5P.get_meta_block_size", "H5P.get_multi_type", "H5P.get_nfilters", "H5P.get_nprops", "H5P.get_sieve_buf_size", "H5P.get_size", "H5P.get_sizes", "H5P.get_small_data_block_size", "H5P.get_sym_k", "H5P.get_userblock", "H5P.get_version", "H5P.isa_class", "H5P.iterate", "H5P.modify_filter", "H5P.remove_filter", "H5P.set", "H5P.set_alignment", "H5P.set_alloc_time", "H5P.set_attr_creation_order", "H5P.set_attr_phase_change", "H5P.set_btree_ratios", "H5P.set_char_encoding", "H5P.set_chunk", "H5P.set_chunk_cache", "H5P.set_copy_object", "H5P.set_create_intermediate_group", "H5P.set_deflate", "H5P.set_edc_check", "H5P.set_external", "H5P.set_family_offset", "H5P.set_fapl_core", "H5P.set_fapl_family", "H5P.set_fapl_log", "H5P.set_fapl_multi", "H5P.set_fapl_sec2", "H5P.set_fapl_split", "H5P.set_fapl_stdio", "H5P.set_fclose_degree", "H5P.set_fill_time", "H5P.set_fill_value", "H5P.set_filter", "H5P.set_fletcher32", "H5P.set_gc_references", "H5P.set_hyper_vector_size", "H5P.set_istore_k", "H5P.set_layout", "H5P.set_libver_bounds", "H5P.set_link_creation_order", "H5P.set_link_phase_change", "H5P.set_mdc_config", "H5P.set_meta_block_size", "H5P.set_multi_type", "H5P.set_nbit", "H5P.set_scaleoffset", "H5P.set_shuffle", "H5P.set_sieve_buf_size", "H5P.set_sizes", "H5P.set_small_data_block_size", "H5P.set_sym_k", "H5P.set_userblock", "H5R.create", "H5R.dereference", "H5R.get_name", "H5R.get_obj_type", "H5R.get_region", "h5read", "h5readatt", "H5S.close", "H5S.copy", "H5S.create", "H5S.create_simple", "H5S.extent_copy", "H5S.get_select_bounds", "H5S.get_select_elem_npoints", "H5S.get_select_elem_pointlist", "H5S.get_select_hyper_blocklist", "H5S.get_select_hyper_nblocks", "H5S.get_select_npoints", "H5S.get_select_type", "H5S.get_simple_extent_dims", "H5S.get_simple_extent_ndims", "H5S.get_simple_extent_npoints", "H5S.get_simple_extent_type", "H5S.is_simple", "H5S.offset_simple", "H5S.select_all", "H5S.select_elements", "H5S.select_hyperslab", "H5S.select_none", "H5S.select_valid", "H5S.set_extent_none", "H5S.set_extent_simple", "H5T.array_create", "H5T.close", "H5T.commit", "H5T.committed", "H5T.copy", "H5T.create", "H5T.detect_class", "H5T.enum_create", "H5T.enum_insert", "H5T.enum_nameof", "H5T.enum_valueof", "H5T.equal", "H5T.get_array_dims", "H5T.get_array_ndims", "H5T.get_class", "H5T.get_create_plist", "H5T.get_cset", "H5T.get_ebias", "H5T.get_fields", "H5T.get_inpad", "H5T.get_member_class", "H5T.get_member_index", "H5T.get_member_name", "H5T.get_member_offset", "H5T.get_member_type", "H5T.get_member_value", "H5T.get_native_type", "H5T.get_nmembers", "H5T.get_norm", "H5T.get_offset", "H5T.get_order", "H5T.get_pad", "H5T.get_precision", "H5T.get_sign", "H5T.get_size", "H5T.get_strpad", "H5T.get_super", "H5T.get_tag", "H5T.insert", "H5T.is_variable_str", "H5T.lock", "H5T.open", "H5T.pack", "H5T.set_cset", "H5T.set_ebias", "H5T.set_fields", "H5T.set_inpad", "H5T.set_norm", "H5T.set_offset", "H5T.set_order", "H5T.set_pad", "H5T.set_precision", "H5T.set_sign", "H5T.set_size", "H5T.set_strpad", "H5T.set_tag", "H5T.vlen_create", "h5write", "h5writeatt", "H5Z.filter_avail", "H5Z.get_filter_info", "hadamard", "handle", "hankel", "hasdata", "hasdata", "hasFactoryValue", "hasfile", "hasFrame", "hasnext", "hasPersonalValue", "hasTemporaryValue", "hdf5info", "hdf5read", "hdf5write", "hdfan", "hdfdf24", "hdfdfr8", "hdfh", "hdfhd", "hdfhe", "hdfhx", "hdfinfo", "hdfml", "hdfpt", "hdfread", "hdftool", "hdfv", "hdfvf", "hdfvh", "hdfvs", "head", "heatmap", "height", "help", "helpbrowser", "helpdesk", "helpdlg", "helpwin", "hess", "hex2dec", "hex2num", "hgexport", "hggroup", "hgload", "hgsave", "hgtransform", "hidden", "highlight", "hilb", "hist", "histc", "histcounts", "histcounts2", "histogram", "histogram2", "hms", "hold", "holes", "home", "horzcat", "horzcat", "horzcat", "hot", "hour", "hours", "hover", "hsv", "hsv2rgb", "hypot", "ichol", "idealfilter", "idivide", "ifft", "ifft2", "ifftn", "ifftshift", "ilu", "im2double", "im2frame", "im2java", "imag", "image", "imageDatastore", "imagesc", "imapprox", "imfinfo", "imformats", "imgCompress", "import", "importdata", "imread", "imresize", "imshow", "imtile", "imwrite", "incenter", "incenters", "incidence", "ind2rgb", "ind2sub", "indegree", "inedges", "Inf", "info", "infoImpl", "initialize", "initialize", "initialize", "initialize", "initialize", "initializeDatastore", "initializeDatastore", "inline", "inmem", "inner2outer", "innerjoin", "inOutStatus", "inpolygon", "input", "inputdlg", "inputname", "inputParser", "insertAfter", "insertATbl", "insertBefore", "insertBTbl", "insertCol", "insertImg", "insertRows", "inShape", "inspect", "instrcallback", "instrfind", "instrfindall", "int16", "int2str", "int32", "int64", "int8", "integral", "integral2", "integral3", "interp1", "interp1q", "interp2", "interp3", "interpft", "interpn", "interpstreamspeed", "intersect", "intersect", "intmax", "intmin", "inv", "invhilb", "invoke", "ipermute", "iqr", "is*", "isa", "isappdata", "isaUnderlying", "isbanded", "isbetween", "iscalendarduration", "iscategorical", "iscategory", "iscell", "iscellstr", "ischange", "ischar", "iscolumn", "iscom", "isCompatible", "isCompressedImg", "isConnected", "isdag", "isdatetime", "isdiag", "isdir", "isDiscreteStateSpecificationMutableImpl", "isDone", "isDoneImpl", "isdst", "isduration", "isEdge", "isempty", "isempty", "isenum", "isequal", "isequaln", "isequalwithequalnans", "isevent", "isfield", "isfile", "isfinite", "isfloat", "isfolder", "isfullfile", "isfullfile", "isgraphics", "ishandle", "ishermitian", "ishghandle", "ishold", "ishole", "isIllConditioned", "isInactivePropertyImpl", "isinf", "isInputComplexityMutableImpl", "isInputDataTypeMutableImpl", "isInputDirectFeedthroughImpl", "isInputSizeLockedImpl", "isInputSizeMutableImpl", "isinteger", "isinterface", "isInterior", "isinterior", "isisomorphic", "isjava", "isKey", "iskeyword", "isletter", "isLoaded", "islocalmax", "islocalmin", "isLocked", "islogical", "ismac", "ismatrix", "ismember", "ismembertol", "ismethod", "ismissing", "ismultigraph", "isnan", "isnat", "isNull", "isnumeric", "isobject", "isocaps", "isocolors", "isomorphism", "isonormals", "isordinal", "isosurface", "isoutlier", "isOutputComplexImpl", "isOutputFixedSizeImpl", "ispc", "isplaying", "ispref", "isprime", "isprop", "isprotected", "isreal", "isrecording", "isregular", "isrow", "isscalar", "issimplified", "issorted", "issortedrows", "isspace", "issparse", "isstr", "isstring", "isStringScalar", "isstrprop", "isstruct", "isstudent", "issymmetric", "istable", "istall", "istimetable", "istril", "istriu", "isTunablePropertyDataTypeMutableImpl", "isundefined", "isunix", "isvalid", "isvalid", "isvalid", "isvarname", "isvector", "isweekend", "javaaddpath", "javaArray", "javachk", "javaclasspath", "javaMethod", "javaMethodEDT", "javaObject", "javaObjectEDT", "javarmpath", "jet", "join", "join", "join", "jsondecode", "jsonencode", "juliandate", "keepMeasuring", "keyboard", "keys", "KeyValueDatastore", "KeyValueStore", "kron", "labeledge", "labelnode", "lag", "laplacian", "lasterr", "lasterror", "lastwarn", "layout", "lcm", "ldivide", "ldl", "le", "legend", "legendre", "length", "length", "length", "length", "lib.pointer", "libfunctions", "libfunctionsview", "libisloaded", "libpointer", "libstruct", "license", "light", "lightangle", "lighting", "lin2mu", "line", "lines", "LineSpec", "linkaxes", "linkdata", "linkprop", "linsolve", "linspace", "listdlg", "listener", "listfonts", "listModifiedFiles", "listRequiredFiles", "load", "load", "load", "loadlibrary", "loadobj", "loadObjectImpl", "localfunctions", "log", "log", "log", "log10", "log1p", "log2", "logical", "Logical", "loglog", "logm", "logspace", "lookfor", "lower", "ls", "lscov", "lsqminnorm", "lsqnonneg", "lsqr", "lt", "lu", "magic", "makehgtform", "mapreduce", "mapreducer", "mat2cell", "mat2str", "matchpairs", "material", "matfile", "matlab", "matlab", "matlab", "matlab.addons.disableAddon", "matlab.addons.enableAddon", "matlab.addons.install", "matlab.addons.installedAddons", "matlab.addons.isAddonEnabled", "matlab.addons.toolbox.installedToolboxes", "matlab.addons.toolbox.installToolbox", "matlab.addons.toolbox.packageToolbox", "matlab.addons.toolbox.toolboxVersion", "matlab.addons.toolbox.uninstallToolbox", "matlab.addons.uninstall", "matlab.apputil.create", "matlab.apputil.getInstalledAppInfo", "matlab.apputil.install", "matlab.apputil.package", "matlab.apputil.run", "matlab.apputil.uninstall", "matlab.codetools.requiredFilesAndProducts", "matlab.engine.connect_matlab", "matlab.engine.engineName", "matlab.engine.find_matlab", "matlab.engine.FutureResult", "matlab.engine.isEngineShared", "matlab.engine.MatlabEngine", "matlab.engine.shareEngine", "matlab.engine.start_matlab", "matlab.exception.JavaException", "matlab.exception.PyException", "matlab.graphics.Graphics", "matlab.graphics.GraphicsPlaceholder", "matlab.io.Datastore", "matlab.io.datastore.DsFileReader", "matlab.io.datastore.DsFileSet", "matlab.io.datastore.HadoopFileBased", "matlab.io.datastore.HadoopLocationBased", "matlab.io.datastore.Partitionable", "matlab.io.datastore.Shuffleable", "matlab.io.hdf4.sd", "matlab.io.hdf4.sd.attrInfo", "matlab.io.hdf4.sd.close", "matlab.io.hdf4.sd.create", "matlab.io.hdf4.sd.dimInfo", "matlab.io.hdf4.sd.endAccess", "matlab.io.hdf4.sd.fileInfo", "matlab.io.hdf4.sd.findAttr", "matlab.io.hdf4.sd.getCal", "matlab.io.hdf4.sd.getChunkInfo", "matlab.io.hdf4.sd.getCompInfo", "matlab.io.hdf4.sd.getDataStrs", "matlab.io.hdf4.sd.getDimID", "matlab.io.hdf4.sd.getDimScale", "matlab.io.hdf4.sd.getDimStrs", "matlab.io.hdf4.sd.getFilename", "matlab.io.hdf4.sd.getFillValue", "matlab.io.hdf4.sd.getInfo", "matlab.io.hdf4.sd.getRange", "matlab.io.hdf4.sd.idToRef", "matlab.io.hdf4.sd.idType", "matlab.io.hdf4.sd.isCoordVar", "matlab.io.hdf4.sd.isRecord", "matlab.io.hdf4.sd.nameToIndex", "matlab.io.hdf4.sd.nameToIndices", "matlab.io.hdf4.sd.readAttr", "matlab.io.hdf4.sd.readChunk", "matlab.io.hdf4.sd.readData", "matlab.io.hdf4.sd.refToIndex", "matlab.io.hdf4.sd.select", "matlab.io.hdf4.sd.setAttr", "matlab.io.hdf4.sd.setCal", "matlab.io.hdf4.sd.setChunk", "matlab.io.hdf4.sd.setCompress", "matlab.io.hdf4.sd.setDataStrs", "matlab.io.hdf4.sd.setDimName", "matlab.io.hdf4.sd.setDimScale", "matlab.io.hdf4.sd.setDimStrs", "matlab.io.hdf4.sd.setExternalFile", "matlab.io.hdf4.sd.setFillMode", "matlab.io.hdf4.sd.setFillValue", "matlab.io.hdf4.sd.setNBitDataSet", "matlab.io.hdf4.sd.setRange", "matlab.io.hdf4.sd.start", "matlab.io.hdf4.sd.writeChunk", "matlab.io.hdf4.sd.writeData", "matlab.io.hdfeos.gd", "matlab.io.hdfeos.gd.attach", "matlab.io.hdfeos.gd.close", "matlab.io.hdfeos.gd.compInfo", "matlab.io.hdfeos.gd.create", "matlab.io.hdfeos.gd.defBoxRegion", "matlab.io.hdfeos.gd.defComp", "matlab.io.hdfeos.gd.defDim", "matlab.io.hdfeos.gd.defField", "matlab.io.hdfeos.gd.defOrigin", "matlab.io.hdfeos.gd.defPixReg", "matlab.io.hdfeos.gd.defProj", "matlab.io.hdfeos.gd.defTile", "matlab.io.hdfeos.gd.defVrtRegion", "matlab.io.hdfeos.gd.detach", "matlab.io.hdfeos.gd.dimInfo", "matlab.io.hdfeos.gd.extractRegion", "matlab.io.hdfeos.gd.fieldInfo", "matlab.io.hdfeos.gd.getFillValue", "matlab.io.hdfeos.gd.getPixels", "matlab.io.hdfeos.gd.getPixValues", "matlab.io.hdfeos.gd.gridInfo", "matlab.io.hdfeos.gd.ij2ll", "matlab.io.hdfeos.gd.inqAttrs", "matlab.io.hdfeos.gd.inqDims", "matlab.io.hdfeos.gd.inqFields", "matlab.io.hdfeos.gd.inqGrid", "matlab.io.hdfeos.gd.interpolate", "matlab.io.hdfeos.gd.ll2ij", "matlab.io.hdfeos.gd.nEntries", "matlab.io.hdfeos.gd.open", "matlab.io.hdfeos.gd.originInfo", "matlab.io.hdfeos.gd.pixRegInfo", "matlab.io.hdfeos.gd.projInfo", "matlab.io.hdfeos.gd.readAttr", "matlab.io.hdfeos.gd.readBlkSomOffset", "matlab.io.hdfeos.gd.readField", "matlab.io.hdfeos.gd.readTile", "matlab.io.hdfeos.gd.regionInfo", "matlab.io.hdfeos.gd.setFillValue", "matlab.io.hdfeos.gd.setTileComp", "matlab.io.hdfeos.gd.sphereCodeToName", "matlab.io.hdfeos.gd.sphereNameToCode", "matlab.io.hdfeos.gd.tileInfo", "matlab.io.hdfeos.gd.writeAttr", "matlab.io.hdfeos.gd.writeBlkSomOffset", "matlab.io.hdfeos.gd.writeField", "matlab.io.hdfeos.gd.writeTile", "matlab.io.hdfeos.sw", "matlab.io.hdfeos.sw.attach", "matlab.io.hdfeos.sw.close", "matlab.io.hdfeos.sw.compInfo", "matlab.io.hdfeos.sw.create", "matlab.io.hdfeos.sw.defBoxRegion", "matlab.io.hdfeos.sw.defComp", "matlab.io.hdfeos.sw.defDataField", "matlab.io.hdfeos.sw.defDim", "matlab.io.hdfeos.sw.defDimMap", "matlab.io.hdfeos.sw.defGeoField", "matlab.io.hdfeos.sw.defTimePeriod", "matlab.io.hdfeos.sw.defVrtRegion", "matlab.io.hdfeos.sw.detach", "matlab.io.hdfeos.sw.dimInfo", "matlab.io.hdfeos.sw.extractPeriod", "matlab.io.hdfeos.sw.extractRegion", "matlab.io.hdfeos.sw.fieldInfo", "matlab.io.hdfeos.sw.geoMapInfo", "matlab.io.hdfeos.sw.getFillValue", "matlab.io.hdfeos.sw.idxMapInfo", "matlab.io.hdfeos.sw.inqAttrs", "matlab.io.hdfeos.sw.inqDataFields", "matlab.io.hdfeos.sw.inqDims", "matlab.io.hdfeos.sw.inqGeoFields", "matlab.io.hdfeos.sw.inqIdxMaps", "matlab.io.hdfeos.sw.inqMaps", "matlab.io.hdfeos.sw.inqSwath", "matlab.io.hdfeos.sw.mapInfo", "matlab.io.hdfeos.sw.nEntries", "matlab.io.hdfeos.sw.open", "matlab.io.hdfeos.sw.periodInfo", "matlab.io.hdfeos.sw.readAttr", "matlab.io.hdfeos.sw.readField", "matlab.io.hdfeos.sw.regionInfo", "matlab.io.hdfeos.sw.setFillValue", "matlab.io.hdfeos.sw.writeAttr", "matlab.io.hdfeos.sw.writeField", "matlab.io.MatFile", "matlab.io.saveVariablesToScript", "matlab.lang.correction.AppendArgumentsCorrection", "matlab.lang.makeUniqueStrings", "matlab.lang.makeValidName", "matlab.lang.OnOffSwitchState", "matlab.mex.MexHost", "matlab.mixin.Copyable", "matlab.mixin.CustomDisplay", "matlab.mixin.CustomDisplay.convertDimensionsToString", "matlab.mixin.CustomDisplay.displayPropertyGroups", "matlab.mixin.CustomDisplay.getClassNameForHeader", "matlab.mixin.CustomDisplay.getDeletedHandleText", "matlab.mixin.CustomDisplay.getDetailedFooter", "matlab.mixin.CustomDisplay.getDetailedHeader", "matlab.mixin.CustomDisplay.getHandleText", "matlab.mixin.CustomDisplay.getSimpleHeader", "matlab.mixin.Heterogeneous", "matlab.mixin.Heterogeneous.getDefaultScalarElement", "matlab.mixin.SetGet", "matlab.mixin.SetGetExactNames", "matlab.mixin.util.PropertyGroup", "matlab.mock.actions.AssignOutputs", "matlab.mock.actions.Invoke", "matlab.mock.actions.ReturnStoredValue", "matlab.mock.actions.StoreValue", "matlab.mock.actions.ThrowException", "matlab.mock.AnyArguments", "matlab.mock.constraints.Occurred", "matlab.mock.constraints.WasAccessed", "matlab.mock.constraints.WasCalled", "matlab.mock.constraints.WasSet", "matlab.mock.history.MethodCall", "matlab.mock.history.PropertyAccess", "matlab.mock.history.PropertyModification", "matlab.mock.history.SuccessfulMethodCall", "matlab.mock.history.SuccessfulPropertyAccess", "matlab.mock.history.SuccessfulPropertyModification", "matlab.mock.history.UnsuccessfulMethodCall", "matlab.mock.history.UnsuccessfulPropertyAccess", "matlab.mock.history.UnsuccessfulPropertyModification", "matlab.mock.InteractionHistory", "matlab.mock.InteractionHistory.forMock", "matlab.mock.MethodCallBehavior", "matlab.mock.PropertyBehavior", "matlab.mock.PropertyGetBehavior", "matlab.mock.PropertySetBehavior", "matlab.mock.TestCase", "matlab.mock.TestCase.forInteractiveUse", "matlab.net.ArrayFormat", "matlab.net.base64decode", "matlab.net.base64encode", "matlab.net.http.AuthenticationScheme", "matlab.net.http.AuthInfo", "matlab.net.http.Cookie", "matlab.net.http.CookieInfo", "matlab.net.http.CookieInfo.collectFromLog", "matlab.net.http.Credentials", "matlab.net.http.Disposition", "matlab.net.http.field.AcceptField", "matlab.net.http.field.AuthenticateField", "matlab.net.http.field.AuthenticationInfoField", "matlab.net.http.field.AuthorizationField", "matlab.net.http.field.ContentDispositionField", "matlab.net.http.field.ContentLengthField", "matlab.net.http.field.ContentLocationField", "matlab.net.http.field.ContentTypeField", "matlab.net.http.field.CookieField", "matlab.net.http.field.DateField", "matlab.net.http.field.GenericField", "matlab.net.http.field.GenericParameterizedField", "matlab.net.http.field.HTTPDateField", "matlab.net.http.field.IntegerField", "matlab.net.http.field.LocationField", "matlab.net.http.field.MediaRangeField", "matlab.net.http.field.SetCookieField", "matlab.net.http.field.URIReferenceField", "matlab.net.http.HeaderField", "matlab.net.http.HeaderField.displaySubclasses", "matlab.net.http.HTTPException", "matlab.net.http.HTTPOptions", "matlab.net.http.io.BinaryConsumer", "matlab.net.http.io.ContentConsumer", "matlab.net.http.io.ContentProvider", "matlab.net.http.io.FileConsumer", "matlab.net.http.io.FileProvider", "matlab.net.http.io.FormProvider", "matlab.net.http.io.GenericConsumer", "matlab.net.http.io.GenericProvider", "matlab.net.http.io.ImageConsumer", "matlab.net.http.io.ImageProvider", "matlab.net.http.io.JSONConsumer", "matlab.net.http.io.JSONProvider", "matlab.net.http.io.MultipartConsumer", "matlab.net.http.io.MultipartFormProvider", "matlab.net.http.io.MultipartProvider", "matlab.net.http.io.StringConsumer", "matlab.net.http.io.StringProvider", "matlab.net.http.LogRecord", "matlab.net.http.MediaType", "matlab.net.http.Message", "matlab.net.http.MessageBody", "matlab.net.http.MessageType", "matlab.net.http.ProgressMonitor", "matlab.net.http.ProtocolVersion", "matlab.net.http.RequestLine", "matlab.net.http.RequestMessage", "matlab.net.http.RequestMethod", "matlab.net.http.ResponseMessage", "matlab.net.http.StartLine", "matlab.net.http.StatusClass", "matlab.net.http.StatusCode", "matlab.net.http.StatusCode.fromValue", "matlab.net.http.StatusLine", "matlab.net.QueryParameter", "matlab.net.URI", "matlab.perftest.FixedTimeExperiment", "matlab.perftest.FrequentistTimeExperiment", "matlab.perftest.TestCase", "matlab.perftest.TimeExperiment", "matlab.perftest.TimeExperiment.limitingSamplingError", "matlab.perftest.TimeExperiment.withFixedSampleSize", "matlab.perftest.TimeResult", "matlab.project.createProject", "matlab.project.loadProject", "matlab.project.Project", "matlab.project.rootProject", "matlab.System", "matlab.system.display.Action", "matlab.system.display.Header", "matlab.system.display.Icon", "matlab.system.display.Section", "matlab.system.display.SectionGroup", "matlab.system.mixin.CustomIcon", "matlab.system.mixin.FiniteSource", "matlab.system.mixin.Nondirect", "matlab.system.mixin.Propagates", "matlab.system.mixin.SampleTime", "matlab.system.StringSet", "matlab.tall.blockMovingWindow", "matlab.tall.movingWindow", "matlab.tall.reduce", "matlab.tall.transform", "matlab.test.behavior.Missing", "matlab.uitest.TestCase", "matlab.uitest.TestCase.forInteractiveUse", "matlab.uitest.unlock", "matlab.unittest.constraints.AbsoluteTolerance", "matlab.unittest.constraints.AnyCellOf", "matlab.unittest.constraints.AnyElementOf", "matlab.unittest.constraints.BooleanConstraint", "matlab.unittest.constraints.CellComparator", "matlab.unittest.constraints.Constraint", "matlab.unittest.constraints.ContainsSubstring", "matlab.unittest.constraints.EndsWithSubstring", "matlab.unittest.constraints.Eventually", "matlab.unittest.constraints.EveryCellOf", "matlab.unittest.constraints.EveryElementOf", "matlab.unittest.constraints.HasElementCount", "matlab.unittest.constraints.HasField", "matlab.unittest.constraints.HasInf", "matlab.unittest.constraints.HasLength", "matlab.unittest.constraints.HasNaN", "matlab.unittest.constraints.HasSize", "matlab.unittest.constraints.HasUniqueElements", "matlab.unittest.constraints.IsAnything", "matlab.unittest.constraints.IsEmpty", "matlab.unittest.constraints.IsEqualTo", "matlab.unittest.constraints.IsFalse", "matlab.unittest.constraints.IsFile", "matlab.unittest.constraints.IsFinite", "matlab.unittest.constraints.IsFolder", "matlab.unittest.constraints.IsGreaterThan", "matlab.unittest.constraints.IsGreaterThanOrEqualTo", "matlab.unittest.constraints.IsInstanceOf", "matlab.unittest.constraints.IsLessThan", "matlab.unittest.constraints.IsLessThanOrEqualTo", "matlab.unittest.constraints.IsOfClass", "matlab.unittest.constraints.IsReal", "matlab.unittest.constraints.IsSameHandleAs", "matlab.unittest.constraints.IsSameSetAs", "matlab.unittest.constraints.IsScalar", "matlab.unittest.constraints.IsSparse", "matlab.unittest.constraints.IsSubsetOf", "matlab.unittest.constraints.IsSubstringOf", "matlab.unittest.constraints.IssuesNoWarnings", "matlab.unittest.constraints.IssuesWarnings", "matlab.unittest.constraints.IsSupersetOf", "matlab.unittest.constraints.IsTrue", "matlab.unittest.constraints.LogicalComparator", "matlab.unittest.constraints.Matches", "matlab.unittest.constraints.NumericComparator", "matlab.unittest.constraints.ObjectComparator", "matlab.unittest.constraints.PublicPropertyComparator", "matlab.unittest.constraints.PublicPropertyComparator.supportingAllValues", "matlab.unittest.constraints.RelativeTolerance", "matlab.unittest.constraints.ReturnsTrue", "matlab.unittest.constraints.StartsWithSubstring", "matlab.unittest.constraints.StringComparator", "matlab.unittest.constraints.StructComparator", "matlab.unittest.constraints.TableComparator", "matlab.unittest.constraints.Throws", "matlab.unittest.constraints.Tolerance", "matlab.unittest.diagnostics.ConstraintDiagnostic", "matlab.unittest.diagnostics.ConstraintDiagnostic.getDisplayableString", "matlab.unittest.diagnostics.Diagnostic", "matlab.unittest.diagnostics.DiagnosticResult", "matlab.unittest.diagnostics.DisplayDiagnostic", "matlab.unittest.diagnostics.FigureDiagnostic", "matlab.unittest.diagnostics.FileArtifact", "matlab.unittest.diagnostics.FrameworkDiagnostic", "matlab.unittest.diagnostics.FunctionHandleDiagnostic", "matlab.unittest.diagnostics.LoggedDiagnosticEventData", "matlab.unittest.diagnostics.ScreenshotDiagnostic", "matlab.unittest.diagnostics.StringDiagnostic", "matlab.unittest.fixtures.CurrentFolderFixture", "matlab.unittest.fixtures.Fixture", "matlab.unittest.fixtures.PathFixture", "matlab.unittest.fixtures.ProjectFixture", "matlab.unittest.fixtures.SuppressedWarningsFixture", "matlab.unittest.fixtures.TemporaryFolderFixture", "matlab.unittest.fixtures.WorkingFolderFixture", "matlab.unittest.measurement.DefaultMeasurementResult", "matlab.unittest.measurement.MeasurementResult", "matlab.unittest.parameters.ClassSetupParameter", "matlab.unittest.parameters.EmptyParameter", "matlab.unittest.parameters.MethodSetupParameter", "matlab.unittest.parameters.Parameter", "matlab.unittest.parameters.Parameter.fromData", "matlab.unittest.parameters.TestParameter", "matlab.unittest.plugins.codecoverage.CoberturaFormat", "matlab.unittest.plugins.codecoverage.CoverageReport", "matlab.unittest.plugins.codecoverage.ProfileReport", "matlab.unittest.plugins.CodeCoveragePlugin", "matlab.unittest.plugins.CodeCoveragePlugin.forFile", "matlab.unittest.plugins.CodeCoveragePlugin.forFolder", "matlab.unittest.plugins.CodeCoveragePlugin.forPackage", "matlab.unittest.plugins.diagnosticrecord.DiagnosticRecord", "matlab.unittest.plugins.diagnosticrecord.ExceptionDiagnosticRecord", "matlab.unittest.plugins.diagnosticrecord.LoggedDiagnosticRecord", "matlab.unittest.plugins.diagnosticrecord.QualificationDiagnosticRecord", "matlab.unittest.plugins.DiagnosticsOutputPlugin", "matlab.unittest.plugins.DiagnosticsRecordingPlugin", "matlab.unittest.plugins.DiagnosticsValidationPlugin", "matlab.unittest.plugins.FailOnWarningsPlugin", "matlab.unittest.plugins.LoggingPlugin", "matlab.unittest.plugins.LoggingPlugin.withVerbosity", "matlab.unittest.plugins.OutputStream", "matlab.unittest.plugins.plugindata.FinalizedResultPluginData", "matlab.unittest.plugins.plugindata.ImplicitFixturePluginData", "matlab.unittest.plugins.plugindata.PluginData", "matlab.unittest.plugins.plugindata.QualificationContext", "matlab.unittest.plugins.plugindata.SharedTestFixturePluginData", "matlab.unittest.plugins.plugindata.TestContentCreationPluginData", "matlab.unittest.plugins.plugindata.TestSuiteRunPluginData", "matlab.unittest.plugins.QualifyingPlugin", "matlab.unittest.plugins.StopOnFailuresPlugin", "matlab.unittest.plugins.TAPPlugin", "matlab.unittest.plugins.TAPPlugin.producingOriginalFormat", "matlab.unittest.plugins.TAPPlugin.producingVersion13", "matlab.unittest.plugins.testreport.DOCXTestReportPlugin", "matlab.unittest.plugins.testreport.HTMLTestReportPlugin", "matlab.unittest.plugins.testreport.PDFTestReportPlugin", "matlab.unittest.plugins.TestReportPlugin", "matlab.unittest.plugins.TestReportPlugin.producingDOCX", "matlab.unittest.plugins.TestReportPlugin.producingHTML", "matlab.unittest.plugins.TestReportPlugin.producingPDF", "matlab.unittest.plugins.TestRunnerPlugin", "matlab.unittest.plugins.TestRunProgressPlugin", "matlab.unittest.plugins.ToFile", "matlab.unittest.plugins.ToStandardOutput", "matlab.unittest.plugins.ToUniqueFile", "matlab.unittest.plugins.XMLPlugin", "matlab.unittest.plugins.XMLPlugin.producingJUnitFormat", "matlab.unittest.qualifications.Assertable", "matlab.unittest.qualifications.AssertionFailedException", "matlab.unittest.qualifications.Assumable", "matlab.unittest.qualifications.AssumptionFailedException", "matlab.unittest.qualifications.ExceptionEventData", "matlab.unittest.qualifications.FatalAssertable", "matlab.unittest.qualifications.FatalAssertionFailedException", "matlab.unittest.qualifications.QualificationEventData", "matlab.unittest.qualifications.Verifiable", "matlab.unittest.Scope", "matlab.unittest.selectors.AndSelector", "matlab.unittest.selectors.HasBaseFolder", "matlab.unittest.selectors.HasName", "matlab.unittest.selectors.HasParameter", "matlab.unittest.selectors.HasProcedureName", "matlab.unittest.selectors.HasSharedTestFixture", "matlab.unittest.selectors.HasSuperclass", "matlab.unittest.selectors.HasTag", "matlab.unittest.selectors.NotSelector", "matlab.unittest.selectors.OrSelector", "matlab.unittest.Test", "matlab.unittest.TestCase", "matlab.unittest.TestCase.forInteractiveUse", "matlab.unittest.TestResult", "matlab.unittest.TestRunner", "matlab.unittest.TestRunner.withNoPlugins", "matlab.unittest.TestRunner.withTextOutput", "matlab.unittest.TestSuite", "matlab.unittest.TestSuite.fromClass", "matlab.unittest.TestSuite.fromFile", "matlab.unittest.TestSuite.fromFolder", "matlab.unittest.TestSuite.fromMethod", "matlab.unittest.TestSuite.fromName", "matlab.unittest.TestSuite.fromPackage", "matlab.unittest.TestSuite.fromProject", "matlab.unittest.Verbosity", "matlab.wsdl.createWSDLClient", "matlab.wsdl.setWSDLToolPath", "matlabrc", "matlabroot", "matlabshared.supportpkg.checkForUpdate", "matlabshared.supportpkg.getInstalled", "matlabshared.supportpkg.getSupportPackageRoot", "matlabshared.supportpkg.setSupportPackageRoot", "max", "max", "maxflow", "MaximizeCommandWindow", "maxk", "maxNumCompThreads", "maxpartitions", "maxpartitions", "mean", "mean", "median", "median", "memmapfile", "memoize", "MemoizedFunction", "memory", "menu", "mergecats", "mergevars", "mesh", "meshc", "meshgrid", "meshz", "meta.abstractDetails", "meta.ArrayDimension", "meta.class", "meta.class.fromName", "meta.DynamicProperty", "meta.EnumeratedValue", "meta.event", "meta.FixedDimension", "meta.MetaData", "meta.method", "meta.package", "meta.package.fromName", "meta.package.getAllPackages", "meta.property", "meta.UnrestrictedDimension", "meta.Validation", "metaclass", "methods", "methodsview", "mex", "mex.getCompilerConfigurations", "MException", "MException.last", "mexext", "mexhost", "mfilename", "mget", "milliseconds", "min", "min", "MinimizeCommandWindow", "mink", "minres", "minspantree", "minus", "minute", "minutes", "mislocked", "missing", "mkdir", "mkdir", "mkpp", "mldivide", "mlint", "mlintrpt", "mlock", "mmfileinfo", "mod", "mode", "month", "more", "morebins", "movAbsHDU", "move", "move", "movefile", "movegui", "movevars", "movie", "movmad", "movmax", "movmean", "movmedian", "movmin", "movNamHDU", "movprod", "movRelHDU", "movstd", "movsum", "movvar", "mpower", "mput", "mrdivide", "msgbox", "mtimes", "mu2lin", "multibandread", "multibandwrite", "munlock", "mustBeFinite", "mustBeGreaterThan", "mustBeGreaterThanOrEqual", "mustBeInteger", "mustBeLessThan", "mustBeLessThanOrEqual", "mustBeMember", "mustBeNegative", "mustBeNonempty", "mustBeNonNan", "mustBeNonnegative", "mustBeNonpositive", "mustBeNonsparse", "mustBeNonzero", "mustBeNumeric", "mustBeNumericOrLogical", "mustBePositive", "mustBeReal", "namelengthmax", "NaN", "nargchk", "nargin", "nargin", "narginchk", "nargout", "nargout", "nargoutchk", "NaT", "native2unicode", "nccreate", "ncdisp", "nchoosek", "ncinfo", "ncread", "ncreadatt", "ncwrite", "ncwriteatt", "ncwriteschema", "ndgrid", "ndims", "ne", "nearest", "nearestNeighbor", "nearestNeighbor", "nearestNeighbor", "nearestvertex", "neighbors", "neighbors", "neighbors", "NET", "NET.addAssembly", "NET.Assembly", "NET.convertArray", "NET.createArray", "NET.createGeneric", "NET.disableAutoRelease", "NET.enableAutoRelease", "NET.GenericClass", "NET.invokeGenericMethod", "NET.isNETSupported", "NET.NetException", "NET.setStaticProperty", "netcdf.abort", "netcdf.close", "netcdf.copyAtt", "netcdf.create", "netcdf.defDim", "netcdf.defGrp", "netcdf.defVar", "netcdf.defVarChunking", "netcdf.defVarDeflate", "netcdf.defVarFill", "netcdf.defVarFletcher32", "netcdf.delAtt", "netcdf.endDef", "netcdf.getAtt", "netcdf.getChunkCache", "netcdf.getConstant", "netcdf.getConstantNames", "netcdf.getVar", "netcdf.inq", "netcdf.inqAtt", "netcdf.inqAttID", "netcdf.inqAttName", "netcdf.inqDim", "netcdf.inqDimID", "netcdf.inqDimIDs", "netcdf.inqFormat", "netcdf.inqGrpName", "netcdf.inqGrpNameFull", "netcdf.inqGrpParent", "netcdf.inqGrps", "netcdf.inqLibVers", "netcdf.inqNcid", "netcdf.inqUnlimDims", "netcdf.inqVar", "netcdf.inqVarChunking", "netcdf.inqVarDeflate", "netcdf.inqVarFill", "netcdf.inqVarFletcher32", "netcdf.inqVarID", "netcdf.inqVarIDs", "netcdf.open", "netcdf.putAtt", "netcdf.putVar", "netcdf.reDef", "netcdf.renameAtt", "netcdf.renameDim", "netcdf.renameVar", "netcdf.setChunkCache", "netcdf.setDefaultFormat", "netcdf.setFill", "netcdf.sync", "newline", "newplot", "nextfile", "nextpow2", "nnz", "nonzeros", "norm", "normalize", "normest", "not", "notebook", "notify", "now", "nsidedpoly", "nthroot", "null", "num2cell", "num2hex", "num2ruler", "num2str", "numArgumentsFromSubscript", "numboundaries", "numedges", "numel", "numnodes", "numpartitions", "numpartitions", "numRegions", "numsides", "nzmax", "ode113", "ode15i", "ode15s", "ode23", "ode23s", "ode23t", "ode23tb", "ode45", "odeget", "odeset", "odextend", "onCleanup", "ones", "onFailure", "onFailure", "open", "open", "openDiskFile", "openfig", "openFile", "opengl", "openProject", "openvar", "optimget", "optimset", "or", "ordeig", "orderfields", "ordqz", "ordschur", "orient", "orth", "outdegree", "outedges", "outerjoin", "outputImpl", "overlaps", "pack", "pad", "padecoef", "pagesetupdlg", "pan", "panInteraction", "parallelplot", "pareto", "parfor", "parquetDatastore", "parquetinfo", "parquetread", "parquetwrite", "parse", "parse", "parseSoapResponse", "partition", "partition", "partition", "parula", "pascal", "patch", "path", "path2rc", "pathsep", "pathtool", "pause", "pause", "pbaspect", "pcg", "pchip", "pcode", "pcolor", "pdepe", "pdeval", "peaks", "perimeter", "perimeter", "perl", "perms", "permute", "persistent", "pi", "pie", "pie3", "pink", "pinv", "planerot", "play", "play", "playblocking", "plot", "plot", "plot", "plot", "plot", "plot3", "plotbrowser", "plotedit", "plotmatrix", "plottools", "plotyy", "plus", "plus", "pointLocation", "pointLocation", "pol2cart", "polar", "polaraxes", "polarhistogram", "polarplot", "polarscatter", "poly", "polyarea", "polybuffer", "polyder", "polyeig", "polyfit", "polyint", "polyshape", "polyval", "polyvalm", "posixtime", "pow2", "power", "ppval", "predecessors", "prefdir", "preferences", "preferredBufferSize", "preferredBufferSize", "press", "preview", "preview", "primes", "print", "print", "printdlg", "printopt", "printpreview", "prism", "processInputSpecificationChangeImpl", "processTunedPropertiesImpl", "prod", "profile", "profsave", "progress", "propagatedInputComplexity", "propagatedInputDataType", "propagatedInputFixedSize", "propagatedInputSize", "propedit", "propedit", "properties", "propertyeditor", "psi", "publish", "PutCharArray", "putData", "putData", "putData", "putData", "putData", "putData", "putData", "putData", "PutFullMatrix", "PutWorkspaceData", "pwd", "pyargs", "pyversion", "qmr", "qr", "qrdelete", "qrinsert", "qrupdate", "quad", "quad2d", "quadgk", "quadl", "quadv", "quarter", "questdlg", "Quit", "quit", "quiver", "quiver3", "qz", "rad2deg", "rand", "rand", "randi", "randi", "randn", "randn", "randperm", "randperm", "RandStream", "RandStream", "RandStream.create", "RandStream.getGlobalStream", "RandStream.list", "RandStream.setGlobalStream", "rank", "rat", "rats", "rbbox", "rcond", "rdivide", "read", "read", "read", "read", "read", "readall", "readasync", "readATblHdr", "readBTblHdr", "readCard", "readcell", "readCol", "readFrame", "readimage", "readImg", "readKey", "readKeyCmplx", "readKeyDbl", "readKeyLongLong", "readKeyLongStr", "readKeyUnit", "readmatrix", "readRecord", "readtable", "readtimetable", "readvars", "real", "reallog", "realmax", "realmin", "realpow", "realsqrt", "record", "record", "recordblocking", "rectangle", "rectint", "recycle", "reducepatch", "reducevolume", "refresh", "refreshdata", "refreshSourceControl", "regexp", "regexpi", "regexprep", "regexptranslate", "regions", "regionZoomInteraction", "registerevent", "regmatlabserver", "rehash", "relationaloperators", "release", "release", "releaseImpl", "reload", "rem", "Remove", "remove", "RemoveAll", "removeCategory", "removecats", "removeFields", "removeFields", "removeFile", "removeLabel", "removeParameter", "removeParameter", "removePath", "removeReference", "removeShortcut", "removeShutdownFile", "removeStartupFile", "removeToolbarExplorationButtons", "removets", "removevars", "rename", "renamecats", "rendererinfo", "reordercats", "reordernodes", "repeat", "repeat", "repeat", "repeat", "repeat", "repelem", "replace", "replaceBetween", "replaceFields", "replaceFields", "repmat", "reportFinalizedResult", "resample", "resample", "rescale", "reset", "reset", "reset", "reset", "reset", "resetImpl", "reshape", "reshape", "residue", "resolve", "restartable", "restartable", "restartable", "restoredefaultpath", "result", "resume", "rethrow", "rethrow", "retime", "return", "returnStoredValueWhen", "reusable", "reusable", "reusable", "reverse", "rgb2gray", "rgb2hsv", "rgb2ind", "rgbplot", "ribbon", "rlim", "rmappdata", "rmboundary", "rmdir", "rmdir", "rmedge", "rmfield", "rmholes", "rmmissing", "rmnode", "rmoutliers", "rmpath", "rmpref", "rmprop", "rmslivers", "rng", "roots", "rose", "rosser", "rot90", "rotate", "rotate", "rotate3d", "rotateInteraction", "round", "rowfun", "rows2vars", "rref", "rsf2csf", "rtickangle", "rtickformat", "rticklabels", "rticks", "ruler2num", "rulerPanInteraction", "run", "run", "run", "run", "run", "runInParallel", "runperf", "runTest", "runTestClass", "runTestMethod", "runtests", "runTestSuite", "samplefun", "sampleSummary", "satisfiedBy", "satisfiedBy", "save", "save", "save", "saveas", "savefig", "saveobj", "saveObjectImpl", "savepath", "scale", "scatter", "scatter3", "scatteredInterpolant", "scatterhistogram", "schur", "scroll", "sec", "secd", "sech", "second", "seconds", "seek", "selectFailed", "selectIf", "selectIncomplete", "selectLogged", "selectmoveresize", "selectPassed", "semilogx", "semilogy", "send", "sendmail", "serial", "serialbreak", "seriallist", "set", "set", "set", "set", "set", "set", "set", "set", "set", "set", "set", "setabstime", "setabstime", "setappdata", "setBscale", "setcats", "setCompressionType", "setdatatype", "setdiff", "setdisp", "setenv", "setfield", "setHCompScale", "setHCompSmooth", "setinterpmethod", "setParameter", "setParameter", "setParameter", "setpixelposition", "setpref", "setProperties", "setstr", "setTileDim", "settimeseriesnames", "Setting", "settings", "SettingsGroup", "setToValue", "setTscale", "setuniformtime", "setup", "setupImpl", "setupSharedTestFixture", "setupTestClass", "setupTestMethod", "setvaropts", "setvartype", "setxor", "sgtitle", "shading", "sheetnames", "shg", "shiftdim", "shortestpath", "shortestpathtree", "show", "show", "show", "show", "showFiSettingsImpl", "showplottool", "showSimulateUsingImpl", "shrinkfaces", "shuffle", "shuffle", "sign", "simplify", "simplify", "sin", "sind", "single", "sinh", "sinpi", "size", "size", "size", "size", "size", "size", "size", "slice", "smooth3", "smoothdata", "snapnow", "sort", "sortboundaries", "sortByFixtures", "sortregions", "sortrows", "sortx", "sorty", "sound", "soundsc", "spalloc", "sparse", "spaugment", "spconvert", "spdiags", "specular", "speye", "spfun", "sph2cart", "sphere", "spinmap", "spline", "split", "split", "splitapply", "splitEachLabel", "splitlines", "splitvars", "spones", "spparms", "sprand", "sprandn", "sprandsym", "sprank", "spreadsheetDatastore", "spreadsheetImportOptions", "spring", "sprintf", "spy", "sqrt", "sqrtm", "squeeze", "ss2tf", "sscanf", "stack", "stackedplot", "stairs", "standardizeMissing", "start", "start", "start", "start", "start", "start", "start", "start", "start", "start", "start", "start", "startat", "startMeasuring", "startsWith", "startup", "stats", "std", "std", "stem", "stem3", "step", "stepImpl", "stlread", "stlwrite", "stop", "stop", "stopasync", "stopMeasuring", "storeValueWhen", "str2double", "str2func", "str2mat", "str2num", "strcat", "strcmp", "strcmpi", "stream2", "stream3", "streamline", "streamparticles", "streamribbon", "streamslice", "streamtube", "strfind", "string", "string", "string", "string", "string", "string", "strings", "strip", "strjoin", "strjust", "strlength", "strmatch", "strncmp", "strncmpi", "strread", "strrep", "strsplit", "strtok", "strtrim", "struct", "struct2cell", "struct2table", "structfun", "strvcat", "sub2ind", "subgraph", "subplot", "subsasgn", "subset", "subsindex", "subspace", "subsref", "substruct", "subtract", "subvolume", "successors", "sum", "sum", "summary", "summary", "summer", "superclasses", "support", "supportPackageInstaller", "supports", "supportsMultipleInstanceImpl", "surf", "surf2patch", "surface", "surfaceArea", "surfc", "surfl", "surfnorm", "svd", "svds", "swapbytes", "sylvester", "symamd", "symbfact", "symmlq", "symrcm", "symvar", "synchronize", "synchronize", "syntax", "system", "table", "table2array", "table2cell", "table2struct", "table2timetable", "tabularTextDatastore", "tail", "tall", "TallDatastore", "tallrng", "tan", "tand", "tanh", "tar", "tcpclient", "teardown", "teardownSharedTestFixture", "teardownTestClass", "teardownTestMethod", "tempdir", "tempname", "testsuite", "tetramesh", "texlabel", "text", "textread", "textscan", "textwrap", "tfqmr", "then", "then", "then", "then", "then", "thetalim", "thetatickformat", "thetaticklabels", "thetaticks", "thingSpeakRead", "thingSpeakWrite", "throw", "throwAsCaller", "throwExceptionWhen", "tic", "Tiff", "Tiff.computeStrip", "Tiff.computeTile", "Tiff.currentDirectory", "Tiff.getTag", "Tiff.getTagNames", "Tiff.getVersion", "Tiff.isTiled", "Tiff.lastDirectory", "Tiff.nextDirectory", "Tiff.numberOfStrips", "Tiff.numberOfTiles", "Tiff.readEncodedStrip", "Tiff.readEncodedTile", "Tiff.readRGBAImage", "Tiff.readRGBAStrip", "Tiff.readRGBATile", "Tiff.rewriteDirectory", "Tiff.setDirectory", "Tiff.setSubDirectory", "Tiff.setTag", "Tiff.writeDirectory", "Tiff.writeEncodedStrip", "Tiff.writeEncodedTile", "time", "timeit", "timeofday", "timer", "timerange", "timerfind", "timerfindall", "times", "timeseries", "timetable", "timetable2table", "timezones", "title", "toc", "todatenum", "toeplitz", "toolboxdir", "topkrows", "toposort", "trace", "transclosure", "transform", "TransformedDatastore", "translate", "transpose", "transreduction", "trapz", "treelayout", "treeplot", "triangulation", "triangulation", "tril", "trimesh", "triplequad", "triplot", "TriRep", "TriRep", "TriScatteredInterp", "TriScatteredInterp", "trisurf", "triu", "true", "tscollection", "tsdata.event", "tsearchn", "turningdist", "type", "type", "typecast", "tzoffset", "uialert", "uiaxes", "uibutton", "uibuttongroup", "uicheckbox", "uiconfirm", "uicontextmenu", "uicontrol", "uidatepicker", "uidropdown", "uieditfield", "uifigure", "uigauge", "uigetdir", "uigetfile", "uigetpref", "uigridlayout", "uiimage", "uiimport", "uiknob", "uilabel", "uilamp", "uilistbox", "uimenu", "uint16", "uint32", "uint64", "uint8", "uiopen", "uipanel", "uiprogressdlg", "uipushtool", "uiputfile", "uiradiobutton", "uiresume", "uisave", "uisetcolor", "uisetfont", "uisetpref", "uislider", "uispinner", "uistack", "uiswitch", "uitab", "uitabgroup", "uitable", "uitextarea", "uitogglebutton", "uitoggletool", "uitoolbar", "uitree", "uitreenode", "uiwait", "uminus", "underlyingValue", "undocheckout", "unicode2native", "union", "union", "unique", "uniquetol", "unix", "unloadlibrary", "unmesh", "unmkpp", "unregisterallevents", "unregisterevent", "unstack", "untar", "unwrap", "unzip", "updateDependencies", "updateImpl", "upgradePreviouslyInstalledSupportPackages", "uplus", "upper", "urlread", "urlwrite", "usejava", "userpath", "validate", "validate", "validate", "validate", "validateattributes", "validateFunctionSignaturesJSON", "validateInputsImpl", "validatePropertiesImpl", "validatestring", "ValueIterator", "values", "vander", "var", "var", "varargin", "varargout", "varfun", "vartype", "vecnorm", "vectorize", "ver", "verctrl", "verifyAccessed", "verifyCalled", "verifyClass", "verifyEmpty", "verifyEqual", "verifyError", "verifyFail", "verifyFalse", "verifyGreaterThan", "verifyGreaterThanOrEqual", "verifyInstanceOf", "verifyLength", "verifyLessThan", "verifyLessThanOrEqual", "verifyMatches", "verifyNotAccessed", "verifyNotCalled", "verifyNotEmpty", "verifyNotEqual", "verifyNotSameHandle", "verifyNotSet", "verifyNumElements", "verifyReturnsTrue", "verifySameHandle", "verifySet", "verifySize", "verifySubstring", "verifyThat", "verifyTrue", "verifyUsing", "verifyWarning", "verifyWarningFree", "verLessThan", "version", "vertcat", "vertcat", "vertcat", "vertexAttachments", "vertexAttachments", "vertexNormal", "VideoReader", "VideoWriter", "view", "viewmtx", "visdiff", "volume", "volumebounds", "voronoi", "voronoiDiagram", "voronoiDiagram", "voronoin", "wait", "waitbar", "waitfor", "waitforbuttonpress", "warndlg", "warning", "waterfall", "web", "weboptions", "webread", "websave", "webwrite", "week", "weekday", "what", "whatsnew", "when", "when", "when", "which", "while", "whitebg", "who", "who", "whos", "whos", "width", "wilkinson", "winopen", "winqueryreg", "winter", "withAnyInputs", "withExactInputs", "withNargout", "withtol", "wordcloud", "write", "write", "write", "writecell", "writeChecksum", "writeCol", "writeComment", "writeDate", "writeHistory", "writeImg", "writeKey", "writeKeyUnit", "writematrix", "writetable", "writetimetable", "writeVideo", "xcorr", "xcov", "xlabel", "xlim", "xline", "xlsfinfo", "xlsread", "xlswrite", "xmlread", "xmlwrite", "xor", "xor", "xslt", "xtickangle", "xtickformat", "xticklabels", "xticks", "year", "years", "ylabel", "ylim", "yline", "ymd", "ytickangle", "ytickformat", "yticklabels", "yticks", "yyaxis", "yyyymmdd", "zeros", "zip", "zlabel", "zlim", "zoom", "zoomInteraction", "ztickangle", "ztickformat", "zticklabels", "zticks"] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab/keywords.rb new file mode 100644 index 0000000..2324705 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/matlab/keywords.rb @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# DO NOT EDIT + +# This file is automatically generated by `rake builtins:matlab`. +# See tasks/builtins/matlab.rake for more info. + +module Rouge + module Lexers + def Matlab.builtins + @builtins ||= Set.new ["abs", "accumarray", "acos", "acosd", "acosh", "acot", "acotd", "acoth", "acsc", "acscd", "acsch", "actxcontrol", "actxcontrollist", "actxcontrolselect", "actxGetRunningServer", "actxserver", "add", "addboundary", "addcats", "addCause", "addClass", "addCondition", "addConditionsFrom", "addConstructor", "addCorrection", "addedge", "addevent", "addFields", "addFields", "addFile", "addFolderIncludingChildFiles", "addFunction", "addLabel", "addlistener", "addMethod", "addmulti", "addnode", "addOptional", "addParameter", "addParamValue", "addPath", "addpath", "addPlugin", "addpoints", "addpref", "addprop", "addprop", "addproperty", "addProperty", "addReference", "addRequired", "addsample", "addsampletocollection", "addShortcut", "addShutdownFile", "addStartupFile", "addTeardown", "addTeardown", "addtodate", "addToolbarExplorationButtons", "addts", "addvars", "adjacency", "airy", "align", "alim", "all", "allchild", "allowModelReferenceDiscreteSampleTimeInheritanceImpl", "alpha", "alphamap", "alphaShape", "alphaSpectrum", "alphaTriangulation", "amd", "analyzeCodeCompatibility", "ancestor", "and", "angle", "animatedline", "annotation", "ans", "any", "appdesigner", "append", "append", "applyFixture", "applyFixture", "area", "area", "area", "array2table", "array2timetable", "arrayfun", "ascii", "asec", "asecd", "asech", "asin", "asind", "asinh", "assert", "assertAccessed", "assertCalled", "assertClass", "assertEmpty", "assertEqual", "assertError", "assertFail", "assertFalse", "assertGreaterThan", "assertGreaterThanOrEqual", "assertInstanceOf", "assertLength", "assertLessThan", "assertLessThanOrEqual", "assertMatches", "assertNotAccessed", "assertNotCalled", "assertNotEmpty", "assertNotEqual", "assertNotSameHandle", "assertNotSet", "assertNumElements", "assertReturnsTrue", "assertSameHandle", "assertSet", "assertSize", "assertSubstring", "assertThat", "assertTrue", "assertUsing", "assertWarning", "assertWarningFree", "assignin", "assignOutputsWhen", "assumeAccessed", "assumeCalled", "assumeClass", "assumeEmpty", "assumeEqual", "assumeError", "assumeFail", "assumeFalse", "assumeGreaterThan", "assumeGreaterThanOrEqual", "assumeInstanceOf", "assumeLength", "assumeLessThan", "assumeLessThanOrEqual", "assumeMatches", "assumeNotAccessed", "assumeNotCalled", "assumeNotEmpty", "assumeNotEqual", "assumeNotSameHandle", "assumeNotSet", "assumeNumElements", "assumeReturnsTrue", "assumeSameHandle", "assumeSet", "assumeSize", "assumeSubstring", "assumeThat", "assumeTrue", "assumeUsing", "assumeWarning", "assumeWarningFree", "atan", "atan2", "atan2d", "atand", "atanh", "audiodevinfo", "audioinfo", "audioplayer", "audioread", "audiorecorder", "audiowrite", "autumn", "aviinfo", "axes", "axis", "axtoolbar", "axtoolbarbtn", "balance", "bandwidth", "bar", "bar3", "bar3h", "barh", "barycentricToCartesian", "baryToCart", "base2dec", "batchStartupOptionUsed", "bctree", "beep", "BeginInvoke", "bench", "besselh", "besseli", "besselj", "besselk", "bessely", "beta", "betainc", "betaincinv", "betaln", "between", "bfsearch", "bicg", "bicgstab", "bicgstabl", "biconncomp", "bin2dec", "binary", "binscatter", "bitand", "bitcmp", "bitget", "bitnot", "bitor", "bitset", "bitshift", "bitxor", "blanks", "blkdiag", "bone", "boundary", "boundary", "boundaryFacets", "boundaryshape", "boundingbox", "bounds", "box", "break", "brighten", "brush", "bsxfun", "build", "builddocsearchdb", "builtin", "bvp4c", "bvp5c", "bvpget", "bvpinit", "bvpset", "bvpxtend", "caldays", "caldiff", "calendar", "calendarDuration", "calllib", "callSoapService", "calmonths", "calquarters", "calweeks", "calyears", "camdolly", "cameratoolbar", "camlight", "camlookat", "camorbit", "campan", "campos", "camproj", "camroll", "camtarget", "camup", "camva", "camzoom", "cancel", "cancelled", "cart2pol", "cart2sph", "cartesianToBarycentric", "cartToBary", "cast", "cat", "cat", "categorical", "categories", "caxis", "cd", "cd", "cdf2rdf", "cdfepoch", "cdfinfo", "cdflib", "cdflib.close", "cdflib.closeVar", "cdflib.computeEpoch", "cdflib.computeEpoch16", "cdflib.create", "cdflib.createAttr", "cdflib.createVar", "cdflib.delete", "cdflib.deleteAttr", "cdflib.deleteAttrEntry", "cdflib.deleteAttrgEntry", "cdflib.deleteVar", "cdflib.deleteVarRecords", "cdflib.epoch16Breakdown", "cdflib.epochBreakdown", "cdflib.getAttrEntry", "cdflib.getAttrgEntry", "cdflib.getAttrMaxEntry", "cdflib.getAttrMaxgEntry", "cdflib.getAttrName", "cdflib.getAttrNum", "cdflib.getAttrScope", "cdflib.getCacheSize", "cdflib.getChecksum", "cdflib.getCompression", "cdflib.getCompressionCacheSize", "cdflib.getConstantNames", "cdflib.getConstantValue", "cdflib.getCopyright", "cdflib.getFileBackward", "cdflib.getFormat", "cdflib.getLibraryCopyright", "cdflib.getLibraryVersion", "cdflib.getMajority", "cdflib.getName", "cdflib.getNumAttrEntries", "cdflib.getNumAttrgEntries", "cdflib.getNumAttributes", "cdflib.getNumgAttributes", "cdflib.getReadOnlyMode", "cdflib.getStageCacheSize", "cdflib.getValidate", "cdflib.getVarAllocRecords", "cdflib.getVarBlockingFactor", "cdflib.getVarCacheSize", "cdflib.getVarCompression", "cdflib.getVarData", "cdflib.getVarMaxAllocRecNum", "cdflib.getVarMaxWrittenRecNum", "cdflib.getVarName", "cdflib.getVarNum", "cdflib.getVarNumRecsWritten", "cdflib.getVarPadValue", "cdflib.getVarRecordData", "cdflib.getVarReservePercent", "cdflib.getVarsMaxWrittenRecNum", "cdflib.getVarSparseRecords", "cdflib.getVersion", "cdflib.hyperGetVarData", "cdflib.hyperPutVarData", "cdflib.inquire", "cdflib.inquireAttr", "cdflib.inquireAttrEntry", "cdflib.inquireAttrgEntry", "cdflib.inquireVar", "cdflib.open", "cdflib.putAttrEntry", "cdflib.putAttrgEntry", "cdflib.putVarData", "cdflib.putVarRecordData", "cdflib.renameAttr", "cdflib.renameVar", "cdflib.setCacheSize", "cdflib.setChecksum", "cdflib.setCompression", "cdflib.setCompressionCacheSize", "cdflib.setFileBackward", "cdflib.setFormat", "cdflib.setMajority", "cdflib.setReadOnlyMode", "cdflib.setStageCacheSize", "cdflib.setValidate", "cdflib.setVarAllocBlockRecords", "cdflib.setVarBlockingFactor", "cdflib.setVarCacheSize", "cdflib.setVarCompression", "cdflib.setVarInitialRecs", "cdflib.setVarPadValue", "cdflib.SetVarReservePercent", "cdflib.setVarsCacheSize", "cdflib.setVarSparseRecords", "cdfread", "cdfwrite", "ceil", "cell", "cell2mat", "cell2struct", "cell2table", "celldisp", "cellfun", "cellplot", "cellstr", "centrality", "centroid", "cgs", "changeFields", "changeFields", "char", "char", "checkcode", "checkin", "checkout", "chol", "cholupdate", "choose", "circshift", "circumcenter", "circumcenters", "cla", "clabel", "class", "classdef", "classUnderlying", "clc", "clear", "clear", "clearAllMemoizedCaches", "clearCache", "clearMockHistory", "clearPersonalValue", "clearpoints", "clearTemporaryValue", "clearvars", "clf", "clibgen.buildInterface", "clibgen.ClassDefinition", "clibgen.ConstructorDefinition", "clibgen.EnumDefinition", "clibgen.FunctionDefinition", "clibgen.generateLibraryDefinition", "clibgen.LibraryDefinition", "clibgen.MethodDefinition", "clibgen.PropertyDefinition", "clibRelease", "clipboard", "clock", "clone", "close", "close", "close", "close", "close", "closeFile", "closereq", "cmopts", "cmpermute", "cmunique", "CodeCompatibilityAnalysis", "codeCompatibilityReport", "colamd", "collapse", "colon", "colorbar", "colorcube", "colordef", "colormap", "ColorSpec", "colperm", "COM", "com.mathworks.engine.MatlabEngine", "com.mathworks.matlab.types.CellStr", "com.mathworks.matlab.types.Complex", "com.mathworks.matlab.types.HandleObject", "com.mathworks.matlab.types.Struct", "combine", "Combine", "CombinedDatastore", "comet", "comet3", "compan", "compass", "complete", "complete", "complete", "complete", "complete", "complete", "complete", "complex", "compose", "computer", "cond", "condeig", "condensation", "condest", "coneplot", "conj", "conncomp", "containers.Map", "contains", "continue", "contour", "contour3", "contourc", "contourf", "contourslice", "contrast", "conv", "conv2", "convert", "convert", "convert", "convertCharsToStrings", "convertContainedStringsToChars", "convertLike", "convertStringsToChars", "convertvars", "convexHull", "convexHull", "convhull", "convhull", "convhulln", "convn", "cool", "copper", "copy", "copyElement", "copyfile", "copyHDU", "copyobj", "copyTo", "corrcoef", "cos", "cosd", "cosh", "cospi", "cot", "cotd", "coth", "count", "countcats", "countEachLabel", "cov", "cplxpair", "cputime", "createCategory", "createClassFromWsdl", "createFile", "createImg", "createLabel", "createMock", "createSampleTime", "createSharedTestFixture", "createSoapMessage", "createTbl", "createTestClassInstance", "createTestMethodInstance", "criticalAlpha", "cross", "csc", "cscd", "csch", "csvread", "csvwrite", "ctranspose", "cummax", "cummin", "cumprod", "cumsum", "cumtrapz", "curl", "currentProject", "customverctrl", "cylinder", "daqread", "daspect", "datacursormode", "datastore", "dataTipInteraction", "dataTipTextRow", "date", "datenum", "dateshift", "datestr", "datetick", "datetime", "datevec", "day", "days", "dbclear", "dbcont", "dbdown", "dblquad", "dbmex", "dbquit", "dbstack", "dbstatus", "dbstep", "dbstop", "dbtype", "dbup", "dde23", "ddeget", "ddensd", "ddesd", "ddeset", "deal", "deblank", "dec2base", "dec2bin", "dec2hex", "decic", "decomposition", "deconv", "defineArgument", "defineArgument", "defineArgument", "defineOutput", "defineOutput", "deg2rad", "degree", "del2", "delaunay", "delaunayn", "DelaunayTri", "DelaunayTri", "delaunayTriangulation", "delegateTo", "delegateTo", "delete", "delete", "delete", "delete", "delete", "deleteCol", "deleteFile", "deleteHDU", "deleteKey", "deleteproperty", "deleteRecord", "deleteRows", "delevent", "delimitedTextImportOptions", "delsample", "delsamplefromcollection", "demo", "det", "details", "detectImportOptions", "detrend", "detrend", "deval", "dfsearch", "diag", "diagnose", "dialog", "diary", "diff", "diffuse", "digraph", "dir", "dir", "disableDefaultInteractivity", "discretize", "disp", "disp", "disp", "display", "displayEmptyObject", "displayNonScalarObject", "displayScalarHandleToDeletedObject", "displayScalarObject", "dissect", "distances", "dither", "divergence", "dlmread", "dlmwrite", "dmperm", "doc", "docsearch", "done", "done", "dos", "dot", "double", "drag", "dragrect", "drawnow", "dsearchn", "duration", "dynamicprops", "echo", "echodemo", "edgeAttachments", "edgeAttachments", "edgecount", "edges", "edges", "edit", "eig", "eigs", "ellipj", "ellipke", "ellipsoid", "empty", "enableDefaultInteractivity", "enableNETfromNetworkDrive", "enableservice", "end", "EndInvoke", "endsWith", "enumeration", "eomday", "eps", "eq", "eq", "equilibrate", "erase", "eraseBetween", "erf", "erfc", "erfcinv", "erfcx", "erfinv", "error", "errorbar", "errordlg", "etime", "etree", "etreeplot", "eval", "evalc", "evalin", "event.DynamicPropertyEvent", "event.EventData", "event.hasListener", "event.listener", "event.PropertyEvent", "event.proplistener", "eventlisteners", "events", "events", "exceltime", "Execute", "exist", "exit", "exp", "expand", "expectedContentLength", "expectedContentLength", "expint", "expm", "expm1", "export", "export2wsdlg", "exportsetupdlg", "extractAfter", "extractBefore", "extractBetween", "eye", "ezcontour", "ezcontourf", "ezmesh", "ezmeshc", "ezplot", "ezplot3", "ezpolar", "ezsurf", "ezsurfc", "faceNormal", "faceNormals", "factor", "factorial", "false", "fatalAssertAccessed", "fatalAssertCalled", "fatalAssertClass", "fatalAssertEmpty", "fatalAssertEqual", "fatalAssertError", "fatalAssertFail", "fatalAssertFalse", "fatalAssertGreaterThan", "fatalAssertGreaterThanOrEqual", "fatalAssertInstanceOf", "fatalAssertLength", "fatalAssertLessThan", "fatalAssertLessThanOrEqual", "fatalAssertMatches", "fatalAssertNotAccessed", "fatalAssertNotCalled", "fatalAssertNotEmpty", "fatalAssertNotEqual", "fatalAssertNotSameHandle", "fatalAssertNotSet", "fatalAssertNumElements", "fatalAssertReturnsTrue", "fatalAssertSameHandle", "fatalAssertSet", "fatalAssertSize", "fatalAssertSubstring", "fatalAssertThat", "fatalAssertTrue", "fatalAssertUsing", "fatalAssertWarning", "fatalAssertWarningFree", "fclose", "fclose", "fcontour", "feather", "featureEdges", "featureEdges", "feof", "ferror", "feval", "Feval", "feval", "fewerbins", "fft", "fft2", "fftn", "fftshift", "fftw", "fgetl", "fgetl", "fgets", "fgets", "fieldnames", "figure", "figurepalette", "fileattrib", "fileDatastore", "filemarker", "fileMode", "fileName", "fileparts", "fileread", "filesep", "fill", "fill3", "fillmissing", "filloutliers", "filter", "filter", "filter2", "fimplicit", "fimplicit3", "find", "findall", "findCategory", "findedge", "findEvent", "findfigs", "findFile", "findgroups", "findLabel", "findnode", "findobj", "findobj", "findprop", "findstr", "finish", "fitsdisp", "fitsinfo", "fitsread", "fitswrite", "fix", "fixedWidthImportOptions", "flag", "flintmax", "flip", "flipdim", "flipedge", "fliplr", "flipud", "floor", "flow", "fmesh", "fminbnd", "fminsearch", "fopen", "fopen", "for", "format", "fplot", "fplot3", "fprintf", "fprintf", "frame2im", "fread", "fread", "freeBoundary", "freeBoundary", "freqspace", "frewind", "fscanf", "fscanf", "fseek", "fsurf", "ftell", "ftp", "full", "fullfile", "func2str", "function", "functions", "FunctionTestCase", "functiontests", "funm", "fwrite", "fwrite", "fzero", "gallery", "gamma", "gammainc", "gammaincinv", "gammaln", "gather", "gca", "gcbf", "gcbo", "gcd", "gcf", "gcmr", "gco", "ge", "genpath", "genvarname", "geoaxes", "geobasemap", "geobubble", "geodensityplot", "geolimits", "geoplot", "geoscatter", "geotickformat", "get", "get", "get", "get", "get", "get", "get", "get", "get", "get", "get", "getabstime", "getabstime", "getAColParms", "getappdata", "getaudiodata", "getBColParms", "GetCharArray", "getClass", "getColName", "getColType", "getConstantValue", "getCurrentTime", "getData", "getData", "getData", "getData", "getData", "getdatasamples", "getdatasamplesize", "getDiagnosticFor", "getDiagnosticFor", "getDiscreteStateImpl", "getDiscreteStateSpecificationImpl", "getdisp", "getenv", "getEqColType", "getfield", "getFields", "getFields", "getFileFormats", "getFooter", "getframe", "GetFullMatrix", "getGlobalNamesImpl", "getHdrSpace", "getHDUnum", "getHDUtype", "getHeader", "getHeaderImpl", "getIconImpl", "getImgSize", "getImgType", "getImpulseResponseLengthImpl", "getInputDimensionConstraintImpl", "getinterpmethod", "getLocation", "getLocation", "getMockHistory", "getNegativeDiagnosticFor", "getnext", "getNumCols", "getNumHDUs", "getNumInputs", "getNumInputsImpl", "getNumOutputs", "getNumOutputsImpl", "getNumRows", "getOpenFiles", "getOutputDataTypeImpl", "getOutputDimensionConstraintImpl", "getOutputSizeImpl", "getParameter", "getParameter", "getParameter", "getpixelposition", "getplayer", "getpoints", "getPostActValString", "getPostConditionString", "getPostDescriptionString", "getPostExpValString", "getPreDescriptionString", "getpref", "getProfiles", "getPropertyGroups", "getPropertyGroupsImpl", "getqualitydesc", "getReasonPhrase", "getReasonPhrase", "getReport", "getsamples", "getSampleTime", "getSampleTimeImpl", "getsampleusingtime", "getsampleusingtime", "getSharedTestFixtures", "getSimulateUsingImpl", "getSimulinkFunctionNamesImpl", "gettimeseriesnames", "getTimeStr", "gettsafteratevent", "gettsafterevent", "gettsatevent", "gettsbeforeatevent", "gettsbeforeevent", "gettsbetweenevents", "GetVariable", "getvaropts", "getVersion", "GetWorkspaceData", "ginput", "global", "gmres", "gobjects", "gplot", "grabcode", "gradient", "graph", "GraphPlot", "gray", "graymon", "grid", "griddata", "griddatan", "griddedInterpolant", "groot", "groupcounts", "groupsummary", "grouptransform", "gsvd", "gt", "gtext", "guidata", "guide", "guihandles", "gunzip", "gzip", "H5.close", "H5.garbage_collect", "H5.get_libversion", "H5.open", "H5.set_free_list_limits", "H5A.close", "H5A.create", "H5A.delete", "H5A.get_info", "H5A.get_name", "H5A.get_space", "H5A.get_type", "H5A.iterate", "H5A.open", "H5A.open_by_idx", "H5A.open_by_name", "H5A.read", "H5A.write", "h5create", "H5D.close", "H5D.create", "H5D.get_access_plist", "H5D.get_create_plist", "H5D.get_offset", "H5D.get_space", "H5D.get_space_status", "H5D.get_storage_size", "H5D.get_type", "H5D.open", "H5D.read", "H5D.set_extent", "H5D.vlen_get_buf_size", "H5D.write", "h5disp", "H5DS.attach_scale", "H5DS.detach_scale", "H5DS.get_label", "H5DS.get_num_scales", "H5DS.get_scale_name", "H5DS.is_scale", "H5DS.iterate_scales", "H5DS.set_label", "H5DS.set_scale", "H5E.clear", "H5E.get_major", "H5E.get_minor", "H5E.walk", "H5F.close", "H5F.create", "H5F.flush", "H5F.get_access_plist", "H5F.get_create_plist", "H5F.get_filesize", "H5F.get_freespace", "H5F.get_info", "H5F.get_mdc_config", "H5F.get_mdc_hit_rate", "H5F.get_mdc_size", "H5F.get_name", "H5F.get_obj_count", "H5F.get_obj_ids", "H5F.is_hdf5", "H5F.mount", "H5F.open", "H5F.reopen", "H5F.set_mdc_config", "H5F.unmount", "H5G.close", "H5G.create", "H5G.get_info", "H5G.open", "H5I.dec_ref", "H5I.get_file_id", "H5I.get_name", "H5I.get_ref", "H5I.get_type", "H5I.inc_ref", "H5I.is_valid", "h5info", "H5L.copy", "H5L.create_external", "H5L.create_hard", "H5L.create_soft", "H5L.delete", "H5L.exists", "H5L.get_info", "H5L.get_name_by_idx", "H5L.get_val", "H5L.iterate", "H5L.iterate_by_name", "H5L.move", "H5L.visit", "H5L.visit_by_name", "H5ML.compare_values", "H5ML.get_constant_names", "H5ML.get_constant_value", "H5ML.get_function_names", "H5ML.get_mem_datatype", "H5ML.hoffset", "H5ML.sizeof", "H5O.close", "H5O.copy", "H5O.get_comment", "H5O.get_comment_by_name", "H5O.get_info", "H5O.link", "H5O.open", "H5O.open_by_idx", "H5O.set_comment", "H5O.set_comment_by_name", "H5O.visit", "H5O.visit_by_name", "H5P.all_filters_avail", "H5P.close", "H5P.close_class", "H5P.copy", "H5P.create", "H5P.equal", "H5P.exist", "H5P.fill_value_defined", "H5P.get", "H5P.get_alignment", "H5P.get_alloc_time", "H5P.get_attr_creation_order", "H5P.get_attr_phase_change", "H5P.get_btree_ratios", "H5P.get_char_encoding", "H5P.get_chunk", "H5P.get_chunk_cache", "H5P.get_class", "H5P.get_class_name", "H5P.get_class_parent", "H5P.get_copy_object", "H5P.get_create_intermediate_group", "H5P.get_driver", "H5P.get_edc_check", "H5P.get_external", "H5P.get_external_count", "H5P.get_family_offset", "H5P.get_fapl_core", "H5P.get_fapl_family", "H5P.get_fapl_multi", "H5P.get_fclose_degree", "H5P.get_fill_time", "H5P.get_fill_value", "H5P.get_filter", "H5P.get_filter_by_id", "H5P.get_gc_references", "H5P.get_hyper_vector_size", "H5P.get_istore_k", "H5P.get_layout", "H5P.get_libver_bounds", "H5P.get_link_creation_order", "H5P.get_link_phase_change", "H5P.get_mdc_config", "H5P.get_meta_block_size", "H5P.get_multi_type", "H5P.get_nfilters", "H5P.get_nprops", "H5P.get_sieve_buf_size", "H5P.get_size", "H5P.get_sizes", "H5P.get_small_data_block_size", "H5P.get_sym_k", "H5P.get_userblock", "H5P.get_version", "H5P.isa_class", "H5P.iterate", "H5P.modify_filter", "H5P.remove_filter", "H5P.set", "H5P.set_alignment", "H5P.set_alloc_time", "H5P.set_attr_creation_order", "H5P.set_attr_phase_change", "H5P.set_btree_ratios", "H5P.set_char_encoding", "H5P.set_chunk", "H5P.set_chunk_cache", "H5P.set_copy_object", "H5P.set_create_intermediate_group", "H5P.set_deflate", "H5P.set_edc_check", "H5P.set_external", "H5P.set_family_offset", "H5P.set_fapl_core", "H5P.set_fapl_family", "H5P.set_fapl_log", "H5P.set_fapl_multi", "H5P.set_fapl_sec2", "H5P.set_fapl_split", "H5P.set_fapl_stdio", "H5P.set_fclose_degree", "H5P.set_fill_time", "H5P.set_fill_value", "H5P.set_filter", "H5P.set_fletcher32", "H5P.set_gc_references", "H5P.set_hyper_vector_size", "H5P.set_istore_k", "H5P.set_layout", "H5P.set_libver_bounds", "H5P.set_link_creation_order", "H5P.set_link_phase_change", "H5P.set_mdc_config", "H5P.set_meta_block_size", "H5P.set_multi_type", "H5P.set_nbit", "H5P.set_scaleoffset", "H5P.set_shuffle", "H5P.set_sieve_buf_size", "H5P.set_sizes", "H5P.set_small_data_block_size", "H5P.set_sym_k", "H5P.set_userblock", "H5R.create", "H5R.dereference", "H5R.get_name", "H5R.get_obj_type", "H5R.get_region", "h5read", "h5readatt", "H5S.close", "H5S.copy", "H5S.create", "H5S.create_simple", "H5S.extent_copy", "H5S.get_select_bounds", "H5S.get_select_elem_npoints", "H5S.get_select_elem_pointlist", "H5S.get_select_hyper_blocklist", "H5S.get_select_hyper_nblocks", "H5S.get_select_npoints", "H5S.get_select_type", "H5S.get_simple_extent_dims", "H5S.get_simple_extent_ndims", "H5S.get_simple_extent_npoints", "H5S.get_simple_extent_type", "H5S.is_simple", "H5S.offset_simple", "H5S.select_all", "H5S.select_elements", "H5S.select_hyperslab", "H5S.select_none", "H5S.select_valid", "H5S.set_extent_none", "H5S.set_extent_simple", "H5T.array_create", "H5T.close", "H5T.commit", "H5T.committed", "H5T.copy", "H5T.create", "H5T.detect_class", "H5T.enum_create", "H5T.enum_insert", "H5T.enum_nameof", "H5T.enum_valueof", "H5T.equal", "H5T.get_array_dims", "H5T.get_array_ndims", "H5T.get_class", "H5T.get_create_plist", "H5T.get_cset", "H5T.get_ebias", "H5T.get_fields", "H5T.get_inpad", "H5T.get_member_class", "H5T.get_member_index", "H5T.get_member_name", "H5T.get_member_offset", "H5T.get_member_type", "H5T.get_member_value", "H5T.get_native_type", "H5T.get_nmembers", "H5T.get_norm", "H5T.get_offset", "H5T.get_order", "H5T.get_pad", "H5T.get_precision", "H5T.get_sign", "H5T.get_size", "H5T.get_strpad", "H5T.get_super", "H5T.get_tag", "H5T.insert", "H5T.is_variable_str", "H5T.lock", "H5T.open", "H5T.pack", "H5T.set_cset", "H5T.set_ebias", "H5T.set_fields", "H5T.set_inpad", "H5T.set_norm", "H5T.set_offset", "H5T.set_order", "H5T.set_pad", "H5T.set_precision", "H5T.set_sign", "H5T.set_size", "H5T.set_strpad", "H5T.set_tag", "H5T.vlen_create", "h5write", "h5writeatt", "H5Z.filter_avail", "H5Z.get_filter_info", "hadamard", "handle", "hankel", "hasdata", "hasdata", "hasFactoryValue", "hasfile", "hasFrame", "hasnext", "hasPersonalValue", "hasTemporaryValue", "hdf5info", "hdf5read", "hdf5write", "hdfan", "hdfdf24", "hdfdfr8", "hdfh", "hdfhd", "hdfhe", "hdfhx", "hdfinfo", "hdfml", "hdfpt", "hdfread", "hdftool", "hdfv", "hdfvf", "hdfvh", "hdfvs", "head", "heatmap", "height", "help", "helpbrowser", "helpdesk", "helpdlg", "helpwin", "hess", "hex2dec", "hex2num", "hgexport", "hggroup", "hgload", "hgsave", "hgtransform", "hidden", "highlight", "hilb", "hist", "histc", "histcounts", "histcounts2", "histogram", "histogram2", "hms", "hold", "holes", "home", "horzcat", "horzcat", "horzcat", "hot", "hour", "hours", "hover", "hsv", "hsv2rgb", "hypot", "ichol", "idealfilter", "idivide", "ifft", "ifft2", "ifftn", "ifftshift", "ilu", "im2double", "im2frame", "im2java", "imag", "image", "imageDatastore", "imagesc", "imapprox", "imfinfo", "imformats", "imgCompress", "import", "importdata", "imread", "imresize", "imshow", "imtile", "imwrite", "incenter", "incenters", "incidence", "ind2rgb", "ind2sub", "indegree", "inedges", "Inf", "info", "infoImpl", "initialize", "initialize", "initialize", "initialize", "initialize", "initializeDatastore", "initializeDatastore", "inline", "inmem", "inner2outer", "innerjoin", "inOutStatus", "inpolygon", "input", "inputdlg", "inputname", "inputParser", "insertAfter", "insertATbl", "insertBefore", "insertBTbl", "insertCol", "insertImg", "insertRows", "inShape", "inspect", "instrcallback", "instrfind", "instrfindall", "int16", "int2str", "int32", "int64", "int8", "integral", "integral2", "integral3", "interp1", "interp1q", "interp2", "interp3", "interpft", "interpn", "interpstreamspeed", "intersect", "intersect", "intmax", "intmin", "inv", "invhilb", "invoke", "ipermute", "iqr", "is*", "isa", "isappdata", "isaUnderlying", "isbanded", "isbetween", "iscalendarduration", "iscategorical", "iscategory", "iscell", "iscellstr", "ischange", "ischar", "iscolumn", "iscom", "isCompatible", "isCompressedImg", "isConnected", "isdag", "isdatetime", "isdiag", "isdir", "isDiscreteStateSpecificationMutableImpl", "isDone", "isDoneImpl", "isdst", "isduration", "isEdge", "isempty", "isempty", "isenum", "isequal", "isequaln", "isequalwithequalnans", "isevent", "isfield", "isfile", "isfinite", "isfloat", "isfolder", "isfullfile", "isfullfile", "isgraphics", "ishandle", "ishermitian", "ishghandle", "ishold", "ishole", "isIllConditioned", "isInactivePropertyImpl", "isinf", "isInputComplexityMutableImpl", "isInputDataTypeMutableImpl", "isInputDirectFeedthroughImpl", "isInputSizeLockedImpl", "isInputSizeMutableImpl", "isinteger", "isinterface", "isInterior", "isinterior", "isisomorphic", "isjava", "isKey", "iskeyword", "isletter", "isLoaded", "islocalmax", "islocalmin", "isLocked", "islogical", "ismac", "ismatrix", "ismember", "ismembertol", "ismethod", "ismissing", "ismultigraph", "isnan", "isnat", "isNull", "isnumeric", "isobject", "isocaps", "isocolors", "isomorphism", "isonormals", "isordinal", "isosurface", "isoutlier", "isOutputComplexImpl", "isOutputFixedSizeImpl", "ispc", "isplaying", "ispref", "isprime", "isprop", "isprotected", "isreal", "isrecording", "isregular", "isrow", "isscalar", "issimplified", "issorted", "issortedrows", "isspace", "issparse", "isstr", "isstring", "isStringScalar", "isstrprop", "isstruct", "isstudent", "issymmetric", "istable", "istall", "istimetable", "istril", "istriu", "isTunablePropertyDataTypeMutableImpl", "isundefined", "isunix", "isvalid", "isvalid", "isvalid", "isvarname", "isvector", "isweekend", "javaaddpath", "javaArray", "javachk", "javaclasspath", "javaMethod", "javaMethodEDT", "javaObject", "javaObjectEDT", "javarmpath", "jet", "join", "join", "join", "jsondecode", "jsonencode", "juliandate", "keepMeasuring", "keyboard", "keys", "KeyValueDatastore", "KeyValueStore", "kron", "labeledge", "labelnode", "lag", "laplacian", "lasterr", "lasterror", "lastwarn", "layout", "lcm", "ldivide", "ldl", "le", "legend", "legendre", "length", "length", "length", "length", "lib.pointer", "libfunctions", "libfunctionsview", "libisloaded", "libpointer", "libstruct", "license", "light", "lightangle", "lighting", "lin2mu", "line", "lines", "LineSpec", "linkaxes", "linkdata", "linkprop", "linsolve", "linspace", "listdlg", "listener", "listfonts", "listModifiedFiles", "listRequiredFiles", "load", "load", "load", "loadlibrary", "loadobj", "loadObjectImpl", "localfunctions", "log", "log", "log", "log10", "log1p", "log2", "logical", "Logical", "loglog", "logm", "logspace", "lookfor", "lower", "ls", "lscov", "lsqminnorm", "lsqnonneg", "lsqr", "lt", "lu", "magic", "makehgtform", "mapreduce", "mapreducer", "mat2cell", "mat2str", "matchpairs", "material", "matfile", "matlab", "matlab", "matlab", "matlab.addons.disableAddon", "matlab.addons.enableAddon", "matlab.addons.install", "matlab.addons.installedAddons", "matlab.addons.isAddonEnabled", "matlab.addons.toolbox.installedToolboxes", "matlab.addons.toolbox.installToolbox", "matlab.addons.toolbox.packageToolbox", "matlab.addons.toolbox.toolboxVersion", "matlab.addons.toolbox.uninstallToolbox", "matlab.addons.uninstall", "matlab.apputil.create", "matlab.apputil.getInstalledAppInfo", "matlab.apputil.install", "matlab.apputil.package", "matlab.apputil.run", "matlab.apputil.uninstall", "matlab.codetools.requiredFilesAndProducts", "matlab.engine.connect_matlab", "matlab.engine.engineName", "matlab.engine.find_matlab", "matlab.engine.FutureResult", "matlab.engine.isEngineShared", "matlab.engine.MatlabEngine", "matlab.engine.shareEngine", "matlab.engine.start_matlab", "matlab.exception.JavaException", "matlab.exception.PyException", "matlab.graphics.Graphics", "matlab.graphics.GraphicsPlaceholder", "matlab.io.Datastore", "matlab.io.datastore.DsFileReader", "matlab.io.datastore.DsFileSet", "matlab.io.datastore.HadoopFileBased", "matlab.io.datastore.HadoopLocationBased", "matlab.io.datastore.Partitionable", "matlab.io.datastore.Shuffleable", "matlab.io.hdf4.sd", "matlab.io.hdf4.sd.attrInfo", "matlab.io.hdf4.sd.close", "matlab.io.hdf4.sd.create", "matlab.io.hdf4.sd.dimInfo", "matlab.io.hdf4.sd.endAccess", "matlab.io.hdf4.sd.fileInfo", "matlab.io.hdf4.sd.findAttr", "matlab.io.hdf4.sd.getCal", "matlab.io.hdf4.sd.getChunkInfo", "matlab.io.hdf4.sd.getCompInfo", "matlab.io.hdf4.sd.getDataStrs", "matlab.io.hdf4.sd.getDimID", "matlab.io.hdf4.sd.getDimScale", "matlab.io.hdf4.sd.getDimStrs", "matlab.io.hdf4.sd.getFilename", "matlab.io.hdf4.sd.getFillValue", "matlab.io.hdf4.sd.getInfo", "matlab.io.hdf4.sd.getRange", "matlab.io.hdf4.sd.idToRef", "matlab.io.hdf4.sd.idType", "matlab.io.hdf4.sd.isCoordVar", "matlab.io.hdf4.sd.isRecord", "matlab.io.hdf4.sd.nameToIndex", "matlab.io.hdf4.sd.nameToIndices", "matlab.io.hdf4.sd.readAttr", "matlab.io.hdf4.sd.readChunk", "matlab.io.hdf4.sd.readData", "matlab.io.hdf4.sd.refToIndex", "matlab.io.hdf4.sd.select", "matlab.io.hdf4.sd.setAttr", "matlab.io.hdf4.sd.setCal", "matlab.io.hdf4.sd.setChunk", "matlab.io.hdf4.sd.setCompress", "matlab.io.hdf4.sd.setDataStrs", "matlab.io.hdf4.sd.setDimName", "matlab.io.hdf4.sd.setDimScale", "matlab.io.hdf4.sd.setDimStrs", "matlab.io.hdf4.sd.setExternalFile", "matlab.io.hdf4.sd.setFillMode", "matlab.io.hdf4.sd.setFillValue", "matlab.io.hdf4.sd.setNBitDataSet", "matlab.io.hdf4.sd.setRange", "matlab.io.hdf4.sd.start", "matlab.io.hdf4.sd.writeChunk", "matlab.io.hdf4.sd.writeData", "matlab.io.hdfeos.gd", "matlab.io.hdfeos.gd.attach", "matlab.io.hdfeos.gd.close", "matlab.io.hdfeos.gd.compInfo", "matlab.io.hdfeos.gd.create", "matlab.io.hdfeos.gd.defBoxRegion", "matlab.io.hdfeos.gd.defComp", "matlab.io.hdfeos.gd.defDim", "matlab.io.hdfeos.gd.defField", "matlab.io.hdfeos.gd.defOrigin", "matlab.io.hdfeos.gd.defPixReg", "matlab.io.hdfeos.gd.defProj", "matlab.io.hdfeos.gd.defTile", "matlab.io.hdfeos.gd.defVrtRegion", "matlab.io.hdfeos.gd.detach", "matlab.io.hdfeos.gd.dimInfo", "matlab.io.hdfeos.gd.extractRegion", "matlab.io.hdfeos.gd.fieldInfo", "matlab.io.hdfeos.gd.getFillValue", "matlab.io.hdfeos.gd.getPixels", "matlab.io.hdfeos.gd.getPixValues", "matlab.io.hdfeos.gd.gridInfo", "matlab.io.hdfeos.gd.ij2ll", "matlab.io.hdfeos.gd.inqAttrs", "matlab.io.hdfeos.gd.inqDims", "matlab.io.hdfeos.gd.inqFields", "matlab.io.hdfeos.gd.inqGrid", "matlab.io.hdfeos.gd.interpolate", "matlab.io.hdfeos.gd.ll2ij", "matlab.io.hdfeos.gd.nEntries", "matlab.io.hdfeos.gd.open", "matlab.io.hdfeos.gd.originInfo", "matlab.io.hdfeos.gd.pixRegInfo", "matlab.io.hdfeos.gd.projInfo", "matlab.io.hdfeos.gd.readAttr", "matlab.io.hdfeos.gd.readBlkSomOffset", "matlab.io.hdfeos.gd.readField", "matlab.io.hdfeos.gd.readTile", "matlab.io.hdfeos.gd.regionInfo", "matlab.io.hdfeos.gd.setFillValue", "matlab.io.hdfeos.gd.setTileComp", "matlab.io.hdfeos.gd.sphereCodeToName", "matlab.io.hdfeos.gd.sphereNameToCode", "matlab.io.hdfeos.gd.tileInfo", "matlab.io.hdfeos.gd.writeAttr", "matlab.io.hdfeos.gd.writeBlkSomOffset", "matlab.io.hdfeos.gd.writeField", "matlab.io.hdfeos.gd.writeTile", "matlab.io.hdfeos.sw", "matlab.io.hdfeos.sw.attach", "matlab.io.hdfeos.sw.close", "matlab.io.hdfeos.sw.compInfo", "matlab.io.hdfeos.sw.create", "matlab.io.hdfeos.sw.defBoxRegion", "matlab.io.hdfeos.sw.defComp", "matlab.io.hdfeos.sw.defDataField", "matlab.io.hdfeos.sw.defDim", "matlab.io.hdfeos.sw.defDimMap", "matlab.io.hdfeos.sw.defGeoField", "matlab.io.hdfeos.sw.defTimePeriod", "matlab.io.hdfeos.sw.defVrtRegion", "matlab.io.hdfeos.sw.detach", "matlab.io.hdfeos.sw.dimInfo", "matlab.io.hdfeos.sw.extractPeriod", "matlab.io.hdfeos.sw.extractRegion", "matlab.io.hdfeos.sw.fieldInfo", "matlab.io.hdfeos.sw.geoMapInfo", "matlab.io.hdfeos.sw.getFillValue", "matlab.io.hdfeos.sw.idxMapInfo", "matlab.io.hdfeos.sw.inqAttrs", "matlab.io.hdfeos.sw.inqDataFields", "matlab.io.hdfeos.sw.inqDims", "matlab.io.hdfeos.sw.inqGeoFields", "matlab.io.hdfeos.sw.inqIdxMaps", "matlab.io.hdfeos.sw.inqMaps", "matlab.io.hdfeos.sw.inqSwath", "matlab.io.hdfeos.sw.mapInfo", "matlab.io.hdfeos.sw.nEntries", "matlab.io.hdfeos.sw.open", "matlab.io.hdfeos.sw.periodInfo", "matlab.io.hdfeos.sw.readAttr", "matlab.io.hdfeos.sw.readField", "matlab.io.hdfeos.sw.regionInfo", "matlab.io.hdfeos.sw.setFillValue", "matlab.io.hdfeos.sw.writeAttr", "matlab.io.hdfeos.sw.writeField", "matlab.io.MatFile", "matlab.io.saveVariablesToScript", "matlab.lang.correction.AppendArgumentsCorrection", "matlab.lang.makeUniqueStrings", "matlab.lang.makeValidName", "matlab.lang.OnOffSwitchState", "matlab.mex.MexHost", "matlab.mixin.Copyable", "matlab.mixin.CustomDisplay", "matlab.mixin.CustomDisplay.convertDimensionsToString", "matlab.mixin.CustomDisplay.displayPropertyGroups", "matlab.mixin.CustomDisplay.getClassNameForHeader", "matlab.mixin.CustomDisplay.getDeletedHandleText", "matlab.mixin.CustomDisplay.getDetailedFooter", "matlab.mixin.CustomDisplay.getDetailedHeader", "matlab.mixin.CustomDisplay.getHandleText", "matlab.mixin.CustomDisplay.getSimpleHeader", "matlab.mixin.Heterogeneous", "matlab.mixin.Heterogeneous.getDefaultScalarElement", "matlab.mixin.SetGet", "matlab.mixin.SetGetExactNames", "matlab.mixin.util.PropertyGroup", "matlab.mock.actions.AssignOutputs", "matlab.mock.actions.Invoke", "matlab.mock.actions.ReturnStoredValue", "matlab.mock.actions.StoreValue", "matlab.mock.actions.ThrowException", "matlab.mock.AnyArguments", "matlab.mock.constraints.Occurred", "matlab.mock.constraints.WasAccessed", "matlab.mock.constraints.WasCalled", "matlab.mock.constraints.WasSet", "matlab.mock.history.MethodCall", "matlab.mock.history.PropertyAccess", "matlab.mock.history.PropertyModification", "matlab.mock.history.SuccessfulMethodCall", "matlab.mock.history.SuccessfulPropertyAccess", "matlab.mock.history.SuccessfulPropertyModification", "matlab.mock.history.UnsuccessfulMethodCall", "matlab.mock.history.UnsuccessfulPropertyAccess", "matlab.mock.history.UnsuccessfulPropertyModification", "matlab.mock.InteractionHistory", "matlab.mock.InteractionHistory.forMock", "matlab.mock.MethodCallBehavior", "matlab.mock.PropertyBehavior", "matlab.mock.PropertyGetBehavior", "matlab.mock.PropertySetBehavior", "matlab.mock.TestCase", "matlab.mock.TestCase.forInteractiveUse", "matlab.net.ArrayFormat", "matlab.net.base64decode", "matlab.net.base64encode", "matlab.net.http.AuthenticationScheme", "matlab.net.http.AuthInfo", "matlab.net.http.Cookie", "matlab.net.http.CookieInfo", "matlab.net.http.CookieInfo.collectFromLog", "matlab.net.http.Credentials", "matlab.net.http.Disposition", "matlab.net.http.field.AcceptField", "matlab.net.http.field.AuthenticateField", "matlab.net.http.field.AuthenticationInfoField", "matlab.net.http.field.AuthorizationField", "matlab.net.http.field.ContentDispositionField", "matlab.net.http.field.ContentLengthField", "matlab.net.http.field.ContentLocationField", "matlab.net.http.field.ContentTypeField", "matlab.net.http.field.CookieField", "matlab.net.http.field.DateField", "matlab.net.http.field.GenericField", "matlab.net.http.field.GenericParameterizedField", "matlab.net.http.field.HTTPDateField", "matlab.net.http.field.IntegerField", "matlab.net.http.field.LocationField", "matlab.net.http.field.MediaRangeField", "matlab.net.http.field.SetCookieField", "matlab.net.http.field.URIReferenceField", "matlab.net.http.HeaderField", "matlab.net.http.HeaderField.displaySubclasses", "matlab.net.http.HTTPException", "matlab.net.http.HTTPOptions", "matlab.net.http.io.BinaryConsumer", "matlab.net.http.io.ContentConsumer", "matlab.net.http.io.ContentProvider", "matlab.net.http.io.FileConsumer", "matlab.net.http.io.FileProvider", "matlab.net.http.io.FormProvider", "matlab.net.http.io.GenericConsumer", "matlab.net.http.io.GenericProvider", "matlab.net.http.io.ImageConsumer", "matlab.net.http.io.ImageProvider", "matlab.net.http.io.JSONConsumer", "matlab.net.http.io.JSONProvider", "matlab.net.http.io.MultipartConsumer", "matlab.net.http.io.MultipartFormProvider", "matlab.net.http.io.MultipartProvider", "matlab.net.http.io.StringConsumer", "matlab.net.http.io.StringProvider", "matlab.net.http.LogRecord", "matlab.net.http.MediaType", "matlab.net.http.Message", "matlab.net.http.MessageBody", "matlab.net.http.MessageType", "matlab.net.http.ProgressMonitor", "matlab.net.http.ProtocolVersion", "matlab.net.http.RequestLine", "matlab.net.http.RequestMessage", "matlab.net.http.RequestMethod", "matlab.net.http.ResponseMessage", "matlab.net.http.StartLine", "matlab.net.http.StatusClass", "matlab.net.http.StatusCode", "matlab.net.http.StatusCode.fromValue", "matlab.net.http.StatusLine", "matlab.net.QueryParameter", "matlab.net.URI", "matlab.perftest.FixedTimeExperiment", "matlab.perftest.FrequentistTimeExperiment", "matlab.perftest.TestCase", "matlab.perftest.TimeExperiment", "matlab.perftest.TimeExperiment.limitingSamplingError", "matlab.perftest.TimeExperiment.withFixedSampleSize", "matlab.perftest.TimeResult", "matlab.project.createProject", "matlab.project.loadProject", "matlab.project.Project", "matlab.project.rootProject", "matlab.System", "matlab.system.display.Action", "matlab.system.display.Header", "matlab.system.display.Icon", "matlab.system.display.Section", "matlab.system.display.SectionGroup", "matlab.system.mixin.CustomIcon", "matlab.system.mixin.FiniteSource", "matlab.system.mixin.Nondirect", "matlab.system.mixin.Propagates", "matlab.system.mixin.SampleTime", "matlab.system.StringSet", "matlab.tall.blockMovingWindow", "matlab.tall.movingWindow", "matlab.tall.reduce", "matlab.tall.transform", "matlab.test.behavior.Missing", "matlab.uitest.TestCase", "matlab.uitest.TestCase.forInteractiveUse", "matlab.uitest.unlock", "matlab.unittest.constraints.AbsoluteTolerance", "matlab.unittest.constraints.AnyCellOf", "matlab.unittest.constraints.AnyElementOf", "matlab.unittest.constraints.BooleanConstraint", "matlab.unittest.constraints.CellComparator", "matlab.unittest.constraints.Constraint", "matlab.unittest.constraints.ContainsSubstring", "matlab.unittest.constraints.EndsWithSubstring", "matlab.unittest.constraints.Eventually", "matlab.unittest.constraints.EveryCellOf", "matlab.unittest.constraints.EveryElementOf", "matlab.unittest.constraints.HasElementCount", "matlab.unittest.constraints.HasField", "matlab.unittest.constraints.HasInf", "matlab.unittest.constraints.HasLength", "matlab.unittest.constraints.HasNaN", "matlab.unittest.constraints.HasSize", "matlab.unittest.constraints.HasUniqueElements", "matlab.unittest.constraints.IsAnything", "matlab.unittest.constraints.IsEmpty", "matlab.unittest.constraints.IsEqualTo", "matlab.unittest.constraints.IsFalse", "matlab.unittest.constraints.IsFile", "matlab.unittest.constraints.IsFinite", "matlab.unittest.constraints.IsFolder", "matlab.unittest.constraints.IsGreaterThan", "matlab.unittest.constraints.IsGreaterThanOrEqualTo", "matlab.unittest.constraints.IsInstanceOf", "matlab.unittest.constraints.IsLessThan", "matlab.unittest.constraints.IsLessThanOrEqualTo", "matlab.unittest.constraints.IsOfClass", "matlab.unittest.constraints.IsReal", "matlab.unittest.constraints.IsSameHandleAs", "matlab.unittest.constraints.IsSameSetAs", "matlab.unittest.constraints.IsScalar", "matlab.unittest.constraints.IsSparse", "matlab.unittest.constraints.IsSubsetOf", "matlab.unittest.constraints.IsSubstringOf", "matlab.unittest.constraints.IssuesNoWarnings", "matlab.unittest.constraints.IssuesWarnings", "matlab.unittest.constraints.IsSupersetOf", "matlab.unittest.constraints.IsTrue", "matlab.unittest.constraints.LogicalComparator", "matlab.unittest.constraints.Matches", "matlab.unittest.constraints.NumericComparator", "matlab.unittest.constraints.ObjectComparator", "matlab.unittest.constraints.PublicPropertyComparator", "matlab.unittest.constraints.PublicPropertyComparator.supportingAllValues", "matlab.unittest.constraints.RelativeTolerance", "matlab.unittest.constraints.ReturnsTrue", "matlab.unittest.constraints.StartsWithSubstring", "matlab.unittest.constraints.StringComparator", "matlab.unittest.constraints.StructComparator", "matlab.unittest.constraints.TableComparator", "matlab.unittest.constraints.Throws", "matlab.unittest.constraints.Tolerance", "matlab.unittest.diagnostics.ConstraintDiagnostic", "matlab.unittest.diagnostics.ConstraintDiagnostic.getDisplayableString", "matlab.unittest.diagnostics.Diagnostic", "matlab.unittest.diagnostics.DiagnosticResult", "matlab.unittest.diagnostics.DisplayDiagnostic", "matlab.unittest.diagnostics.FigureDiagnostic", "matlab.unittest.diagnostics.FileArtifact", "matlab.unittest.diagnostics.FrameworkDiagnostic", "matlab.unittest.diagnostics.FunctionHandleDiagnostic", "matlab.unittest.diagnostics.LoggedDiagnosticEventData", "matlab.unittest.diagnostics.ScreenshotDiagnostic", "matlab.unittest.diagnostics.StringDiagnostic", "matlab.unittest.fixtures.CurrentFolderFixture", "matlab.unittest.fixtures.Fixture", "matlab.unittest.fixtures.PathFixture", "matlab.unittest.fixtures.ProjectFixture", "matlab.unittest.fixtures.SuppressedWarningsFixture", "matlab.unittest.fixtures.TemporaryFolderFixture", "matlab.unittest.fixtures.WorkingFolderFixture", "matlab.unittest.measurement.DefaultMeasurementResult", "matlab.unittest.measurement.MeasurementResult", "matlab.unittest.parameters.ClassSetupParameter", "matlab.unittest.parameters.EmptyParameter", "matlab.unittest.parameters.MethodSetupParameter", "matlab.unittest.parameters.Parameter", "matlab.unittest.parameters.Parameter.fromData", "matlab.unittest.parameters.TestParameter", "matlab.unittest.plugins.codecoverage.CoberturaFormat", "matlab.unittest.plugins.codecoverage.CoverageReport", "matlab.unittest.plugins.codecoverage.ProfileReport", "matlab.unittest.plugins.CodeCoveragePlugin", "matlab.unittest.plugins.CodeCoveragePlugin.forFile", "matlab.unittest.plugins.CodeCoveragePlugin.forFolder", "matlab.unittest.plugins.CodeCoveragePlugin.forPackage", "matlab.unittest.plugins.diagnosticrecord.DiagnosticRecord", "matlab.unittest.plugins.diagnosticrecord.ExceptionDiagnosticRecord", "matlab.unittest.plugins.diagnosticrecord.LoggedDiagnosticRecord", "matlab.unittest.plugins.diagnosticrecord.QualificationDiagnosticRecord", "matlab.unittest.plugins.DiagnosticsOutputPlugin", "matlab.unittest.plugins.DiagnosticsRecordingPlugin", "matlab.unittest.plugins.DiagnosticsValidationPlugin", "matlab.unittest.plugins.FailOnWarningsPlugin", "matlab.unittest.plugins.LoggingPlugin", "matlab.unittest.plugins.LoggingPlugin.withVerbosity", "matlab.unittest.plugins.OutputStream", "matlab.unittest.plugins.plugindata.FinalizedResultPluginData", "matlab.unittest.plugins.plugindata.ImplicitFixturePluginData", "matlab.unittest.plugins.plugindata.PluginData", "matlab.unittest.plugins.plugindata.QualificationContext", "matlab.unittest.plugins.plugindata.SharedTestFixturePluginData", "matlab.unittest.plugins.plugindata.TestContentCreationPluginData", "matlab.unittest.plugins.plugindata.TestSuiteRunPluginData", "matlab.unittest.plugins.QualifyingPlugin", "matlab.unittest.plugins.StopOnFailuresPlugin", "matlab.unittest.plugins.TAPPlugin", "matlab.unittest.plugins.TAPPlugin.producingOriginalFormat", "matlab.unittest.plugins.TAPPlugin.producingVersion13", "matlab.unittest.plugins.testreport.DOCXTestReportPlugin", "matlab.unittest.plugins.testreport.HTMLTestReportPlugin", "matlab.unittest.plugins.testreport.PDFTestReportPlugin", "matlab.unittest.plugins.TestReportPlugin", "matlab.unittest.plugins.TestReportPlugin.producingDOCX", "matlab.unittest.plugins.TestReportPlugin.producingHTML", "matlab.unittest.plugins.TestReportPlugin.producingPDF", "matlab.unittest.plugins.TestRunnerPlugin", "matlab.unittest.plugins.TestRunProgressPlugin", "matlab.unittest.plugins.ToFile", "matlab.unittest.plugins.ToStandardOutput", "matlab.unittest.plugins.ToUniqueFile", "matlab.unittest.plugins.XMLPlugin", "matlab.unittest.plugins.XMLPlugin.producingJUnitFormat", "matlab.unittest.qualifications.Assertable", "matlab.unittest.qualifications.AssertionFailedException", "matlab.unittest.qualifications.Assumable", "matlab.unittest.qualifications.AssumptionFailedException", "matlab.unittest.qualifications.ExceptionEventData", "matlab.unittest.qualifications.FatalAssertable", "matlab.unittest.qualifications.FatalAssertionFailedException", "matlab.unittest.qualifications.QualificationEventData", "matlab.unittest.qualifications.Verifiable", "matlab.unittest.Scope", "matlab.unittest.selectors.AndSelector", "matlab.unittest.selectors.HasBaseFolder", "matlab.unittest.selectors.HasName", "matlab.unittest.selectors.HasParameter", "matlab.unittest.selectors.HasProcedureName", "matlab.unittest.selectors.HasSharedTestFixture", "matlab.unittest.selectors.HasSuperclass", "matlab.unittest.selectors.HasTag", "matlab.unittest.selectors.NotSelector", "matlab.unittest.selectors.OrSelector", "matlab.unittest.Test", "matlab.unittest.TestCase", "matlab.unittest.TestCase.forInteractiveUse", "matlab.unittest.TestResult", "matlab.unittest.TestRunner", "matlab.unittest.TestRunner.withNoPlugins", "matlab.unittest.TestRunner.withTextOutput", "matlab.unittest.TestSuite", "matlab.unittest.TestSuite.fromClass", "matlab.unittest.TestSuite.fromFile", "matlab.unittest.TestSuite.fromFolder", "matlab.unittest.TestSuite.fromMethod", "matlab.unittest.TestSuite.fromName", "matlab.unittest.TestSuite.fromPackage", "matlab.unittest.TestSuite.fromProject", "matlab.unittest.Verbosity", "matlab.wsdl.createWSDLClient", "matlab.wsdl.setWSDLToolPath", "matlabrc", "matlabroot", "matlabshared.supportpkg.checkForUpdate", "matlabshared.supportpkg.getInstalled", "matlabshared.supportpkg.getSupportPackageRoot", "matlabshared.supportpkg.setSupportPackageRoot", "max", "max", "maxflow", "MaximizeCommandWindow", "maxk", "maxNumCompThreads", "maxpartitions", "maxpartitions", "mean", "mean", "median", "median", "memmapfile", "memoize", "MemoizedFunction", "memory", "menu", "mergecats", "mergevars", "mesh", "meshc", "meshgrid", "meshz", "meta.abstractDetails", "meta.ArrayDimension", "meta.class", "meta.class.fromName", "meta.DynamicProperty", "meta.EnumeratedValue", "meta.event", "meta.FixedDimension", "meta.MetaData", "meta.method", "meta.package", "meta.package.fromName", "meta.package.getAllPackages", "meta.property", "meta.UnrestrictedDimension", "meta.Validation", "metaclass", "methods", "methodsview", "mex", "mex.getCompilerConfigurations", "MException", "MException.last", "mexext", "mexhost", "mfilename", "mget", "milliseconds", "min", "min", "MinimizeCommandWindow", "mink", "minres", "minspantree", "minus", "minute", "minutes", "mislocked", "missing", "mkdir", "mkdir", "mkpp", "mldivide", "mlint", "mlintrpt", "mlock", "mmfileinfo", "mod", "mode", "month", "more", "morebins", "movAbsHDU", "move", "move", "movefile", "movegui", "movevars", "movie", "movmad", "movmax", "movmean", "movmedian", "movmin", "movNamHDU", "movprod", "movRelHDU", "movstd", "movsum", "movvar", "mpower", "mput", "mrdivide", "msgbox", "mtimes", "mu2lin", "multibandread", "multibandwrite", "munlock", "mustBeFinite", "mustBeGreaterThan", "mustBeGreaterThanOrEqual", "mustBeInteger", "mustBeLessThan", "mustBeLessThanOrEqual", "mustBeMember", "mustBeNegative", "mustBeNonempty", "mustBeNonNan", "mustBeNonnegative", "mustBeNonpositive", "mustBeNonsparse", "mustBeNonzero", "mustBeNumeric", "mustBeNumericOrLogical", "mustBePositive", "mustBeReal", "namelengthmax", "NaN", "nargchk", "nargin", "nargin", "narginchk", "nargout", "nargout", "nargoutchk", "NaT", "native2unicode", "nccreate", "ncdisp", "nchoosek", "ncinfo", "ncread", "ncreadatt", "ncwrite", "ncwriteatt", "ncwriteschema", "ndgrid", "ndims", "ne", "nearest", "nearestNeighbor", "nearestNeighbor", "nearestNeighbor", "nearestvertex", "neighbors", "neighbors", "neighbors", "NET", "NET.addAssembly", "NET.Assembly", "NET.convertArray", "NET.createArray", "NET.createGeneric", "NET.disableAutoRelease", "NET.enableAutoRelease", "NET.GenericClass", "NET.invokeGenericMethod", "NET.isNETSupported", "NET.NetException", "NET.setStaticProperty", "netcdf.abort", "netcdf.close", "netcdf.copyAtt", "netcdf.create", "netcdf.defDim", "netcdf.defGrp", "netcdf.defVar", "netcdf.defVarChunking", "netcdf.defVarDeflate", "netcdf.defVarFill", "netcdf.defVarFletcher32", "netcdf.delAtt", "netcdf.endDef", "netcdf.getAtt", "netcdf.getChunkCache", "netcdf.getConstant", "netcdf.getConstantNames", "netcdf.getVar", "netcdf.inq", "netcdf.inqAtt", "netcdf.inqAttID", "netcdf.inqAttName", "netcdf.inqDim", "netcdf.inqDimID", "netcdf.inqDimIDs", "netcdf.inqFormat", "netcdf.inqGrpName", "netcdf.inqGrpNameFull", "netcdf.inqGrpParent", "netcdf.inqGrps", "netcdf.inqLibVers", "netcdf.inqNcid", "netcdf.inqUnlimDims", "netcdf.inqVar", "netcdf.inqVarChunking", "netcdf.inqVarDeflate", "netcdf.inqVarFill", "netcdf.inqVarFletcher32", "netcdf.inqVarID", "netcdf.inqVarIDs", "netcdf.open", "netcdf.putAtt", "netcdf.putVar", "netcdf.reDef", "netcdf.renameAtt", "netcdf.renameDim", "netcdf.renameVar", "netcdf.setChunkCache", "netcdf.setDefaultFormat", "netcdf.setFill", "netcdf.sync", "newline", "newplot", "nextfile", "nextpow2", "nnz", "nonzeros", "norm", "normalize", "normest", "not", "notebook", "notify", "now", "nsidedpoly", "nthroot", "null", "num2cell", "num2hex", "num2ruler", "num2str", "numArgumentsFromSubscript", "numboundaries", "numedges", "numel", "numnodes", "numpartitions", "numpartitions", "numRegions", "numsides", "nzmax", "ode113", "ode15i", "ode15s", "ode23", "ode23s", "ode23t", "ode23tb", "ode45", "odeget", "odeset", "odextend", "onCleanup", "ones", "onFailure", "onFailure", "open", "open", "openDiskFile", "openfig", "openFile", "opengl", "openProject", "openvar", "optimget", "optimset", "or", "ordeig", "orderfields", "ordqz", "ordschur", "orient", "orth", "outdegree", "outedges", "outerjoin", "outputImpl", "overlaps", "pack", "pad", "padecoef", "pagesetupdlg", "pan", "panInteraction", "parallelplot", "pareto", "parfor", "parquetDatastore", "parquetinfo", "parquetread", "parquetwrite", "parse", "parse", "parseSoapResponse", "partition", "partition", "partition", "parula", "pascal", "patch", "path", "path2rc", "pathsep", "pathtool", "pause", "pause", "pbaspect", "pcg", "pchip", "pcode", "pcolor", "pdepe", "pdeval", "peaks", "perimeter", "perimeter", "perl", "perms", "permute", "persistent", "pi", "pie", "pie3", "pink", "pinv", "planerot", "play", "play", "playblocking", "plot", "plot", "plot", "plot", "plot", "plot3", "plotbrowser", "plotedit", "plotmatrix", "plottools", "plotyy", "plus", "plus", "pointLocation", "pointLocation", "pol2cart", "polar", "polaraxes", "polarhistogram", "polarplot", "polarscatter", "poly", "polyarea", "polybuffer", "polyder", "polyeig", "polyfit", "polyint", "polyshape", "polyval", "polyvalm", "posixtime", "pow2", "power", "ppval", "predecessors", "prefdir", "preferences", "preferredBufferSize", "preferredBufferSize", "press", "preview", "preview", "primes", "print", "print", "printdlg", "printopt", "printpreview", "prism", "processInputSpecificationChangeImpl", "processTunedPropertiesImpl", "prod", "profile", "profsave", "progress", "propagatedInputComplexity", "propagatedInputDataType", "propagatedInputFixedSize", "propagatedInputSize", "propedit", "propedit", "properties", "propertyeditor", "psi", "publish", "PutCharArray", "putData", "putData", "putData", "putData", "putData", "putData", "putData", "putData", "PutFullMatrix", "PutWorkspaceData", "pwd", "pyargs", "pyversion", "qmr", "qr", "qrdelete", "qrinsert", "qrupdate", "quad", "quad2d", "quadgk", "quadl", "quadv", "quarter", "questdlg", "Quit", "quit", "quiver", "quiver3", "qz", "rad2deg", "rand", "rand", "randi", "randi", "randn", "randn", "randperm", "randperm", "RandStream", "RandStream", "RandStream.create", "RandStream.getGlobalStream", "RandStream.list", "RandStream.setGlobalStream", "rank", "rat", "rats", "rbbox", "rcond", "rdivide", "read", "read", "read", "read", "read", "readall", "readasync", "readATblHdr", "readBTblHdr", "readCard", "readcell", "readCol", "readFrame", "readimage", "readImg", "readKey", "readKeyCmplx", "readKeyDbl", "readKeyLongLong", "readKeyLongStr", "readKeyUnit", "readmatrix", "readRecord", "readtable", "readtimetable", "readvars", "real", "reallog", "realmax", "realmin", "realpow", "realsqrt", "record", "record", "recordblocking", "rectangle", "rectint", "recycle", "reducepatch", "reducevolume", "refresh", "refreshdata", "refreshSourceControl", "regexp", "regexpi", "regexprep", "regexptranslate", "regions", "regionZoomInteraction", "registerevent", "regmatlabserver", "rehash", "relationaloperators", "release", "release", "releaseImpl", "reload", "rem", "Remove", "remove", "RemoveAll", "removeCategory", "removecats", "removeFields", "removeFields", "removeFile", "removeLabel", "removeParameter", "removeParameter", "removePath", "removeReference", "removeShortcut", "removeShutdownFile", "removeStartupFile", "removeToolbarExplorationButtons", "removets", "removevars", "rename", "renamecats", "rendererinfo", "reordercats", "reordernodes", "repeat", "repeat", "repeat", "repeat", "repeat", "repelem", "replace", "replaceBetween", "replaceFields", "replaceFields", "repmat", "reportFinalizedResult", "resample", "resample", "rescale", "reset", "reset", "reset", "reset", "reset", "resetImpl", "reshape", "reshape", "residue", "resolve", "restartable", "restartable", "restartable", "restoredefaultpath", "result", "resume", "rethrow", "rethrow", "retime", "return", "returnStoredValueWhen", "reusable", "reusable", "reusable", "reverse", "rgb2gray", "rgb2hsv", "rgb2ind", "rgbplot", "ribbon", "rlim", "rmappdata", "rmboundary", "rmdir", "rmdir", "rmedge", "rmfield", "rmholes", "rmmissing", "rmnode", "rmoutliers", "rmpath", "rmpref", "rmprop", "rmslivers", "rng", "roots", "rose", "rosser", "rot90", "rotate", "rotate", "rotate3d", "rotateInteraction", "round", "rowfun", "rows2vars", "rref", "rsf2csf", "rtickangle", "rtickformat", "rticklabels", "rticks", "ruler2num", "rulerPanInteraction", "run", "run", "run", "run", "run", "runInParallel", "runperf", "runTest", "runTestClass", "runTestMethod", "runtests", "runTestSuite", "samplefun", "sampleSummary", "satisfiedBy", "satisfiedBy", "save", "save", "save", "saveas", "savefig", "saveobj", "saveObjectImpl", "savepath", "scale", "scatter", "scatter3", "scatteredInterpolant", "scatterhistogram", "schur", "scroll", "sec", "secd", "sech", "second", "seconds", "seek", "selectFailed", "selectIf", "selectIncomplete", "selectLogged", "selectmoveresize", "selectPassed", "semilogx", "semilogy", "send", "sendmail", "serial", "serialbreak", "seriallist", "set", "set", "set", "set", "set", "set", "set", "set", "set", "set", "set", "setabstime", "setabstime", "setappdata", "setBscale", "setcats", "setCompressionType", "setdatatype", "setdiff", "setdisp", "setenv", "setfield", "setHCompScale", "setHCompSmooth", "setinterpmethod", "setParameter", "setParameter", "setParameter", "setpixelposition", "setpref", "setProperties", "setstr", "setTileDim", "settimeseriesnames", "Setting", "settings", "SettingsGroup", "setToValue", "setTscale", "setuniformtime", "setup", "setupImpl", "setupSharedTestFixture", "setupTestClass", "setupTestMethod", "setvaropts", "setvartype", "setxor", "sgtitle", "shading", "sheetnames", "shg", "shiftdim", "shortestpath", "shortestpathtree", "show", "show", "show", "show", "showFiSettingsImpl", "showplottool", "showSimulateUsingImpl", "shrinkfaces", "shuffle", "shuffle", "sign", "simplify", "simplify", "sin", "sind", "single", "sinh", "sinpi", "size", "size", "size", "size", "size", "size", "size", "slice", "smooth3", "smoothdata", "snapnow", "sort", "sortboundaries", "sortByFixtures", "sortregions", "sortrows", "sortx", "sorty", "sound", "soundsc", "spalloc", "sparse", "spaugment", "spconvert", "spdiags", "specular", "speye", "spfun", "sph2cart", "sphere", "spinmap", "spline", "split", "split", "splitapply", "splitEachLabel", "splitlines", "splitvars", "spones", "spparms", "sprand", "sprandn", "sprandsym", "sprank", "spreadsheetDatastore", "spreadsheetImportOptions", "spring", "sprintf", "spy", "sqrt", "sqrtm", "squeeze", "ss2tf", "sscanf", "stack", "stackedplot", "stairs", "standardizeMissing", "start", "start", "start", "start", "start", "start", "start", "start", "start", "start", "start", "start", "startat", "startMeasuring", "startsWith", "startup", "stats", "std", "std", "stem", "stem3", "step", "stepImpl", "stlread", "stlwrite", "stop", "stop", "stopasync", "stopMeasuring", "storeValueWhen", "str2double", "str2func", "str2mat", "str2num", "strcat", "strcmp", "strcmpi", "stream2", "stream3", "streamline", "streamparticles", "streamribbon", "streamslice", "streamtube", "strfind", "string", "string", "string", "string", "string", "string", "strings", "strip", "strjoin", "strjust", "strlength", "strmatch", "strncmp", "strncmpi", "strread", "strrep", "strsplit", "strtok", "strtrim", "struct", "struct2cell", "struct2table", "structfun", "strvcat", "sub2ind", "subgraph", "subplot", "subsasgn", "subset", "subsindex", "subspace", "subsref", "substruct", "subtract", "subvolume", "successors", "sum", "sum", "summary", "summary", "summer", "superclasses", "support", "supportPackageInstaller", "supports", "supportsMultipleInstanceImpl", "surf", "surf2patch", "surface", "surfaceArea", "surfc", "surfl", "surfnorm", "svd", "svds", "swapbytes", "sylvester", "symamd", "symbfact", "symmlq", "symrcm", "symvar", "synchronize", "synchronize", "syntax", "system", "table", "table2array", "table2cell", "table2struct", "table2timetable", "tabularTextDatastore", "tail", "tall", "TallDatastore", "tallrng", "tan", "tand", "tanh", "tar", "tcpclient", "teardown", "teardownSharedTestFixture", "teardownTestClass", "teardownTestMethod", "tempdir", "tempname", "testsuite", "tetramesh", "texlabel", "text", "textread", "textscan", "textwrap", "tfqmr", "then", "then", "then", "then", "then", "thetalim", "thetatickformat", "thetaticklabels", "thetaticks", "thingSpeakRead", "thingSpeakWrite", "throw", "throwAsCaller", "throwExceptionWhen", "tic", "Tiff", "Tiff.computeStrip", "Tiff.computeTile", "Tiff.currentDirectory", "Tiff.getTag", "Tiff.getTagNames", "Tiff.getVersion", "Tiff.isTiled", "Tiff.lastDirectory", "Tiff.nextDirectory", "Tiff.numberOfStrips", "Tiff.numberOfTiles", "Tiff.readEncodedStrip", "Tiff.readEncodedTile", "Tiff.readRGBAImage", "Tiff.readRGBAStrip", "Tiff.readRGBATile", "Tiff.rewriteDirectory", "Tiff.setDirectory", "Tiff.setSubDirectory", "Tiff.setTag", "Tiff.writeDirectory", "Tiff.writeEncodedStrip", "Tiff.writeEncodedTile", "time", "timeit", "timeofday", "timer", "timerange", "timerfind", "timerfindall", "times", "timeseries", "timetable", "timetable2table", "timezones", "title", "toc", "todatenum", "toeplitz", "toolboxdir", "topkrows", "toposort", "trace", "transclosure", "transform", "TransformedDatastore", "translate", "transpose", "transreduction", "trapz", "treelayout", "treeplot", "triangulation", "triangulation", "tril", "trimesh", "triplequad", "triplot", "TriRep", "TriRep", "TriScatteredInterp", "TriScatteredInterp", "trisurf", "triu", "true", "tscollection", "tsdata.event", "tsearchn", "turningdist", "type", "type", "typecast", "tzoffset", "uialert", "uiaxes", "uibutton", "uibuttongroup", "uicheckbox", "uiconfirm", "uicontextmenu", "uicontrol", "uidatepicker", "uidropdown", "uieditfield", "uifigure", "uigauge", "uigetdir", "uigetfile", "uigetpref", "uigridlayout", "uiimage", "uiimport", "uiknob", "uilabel", "uilamp", "uilistbox", "uimenu", "uint16", "uint32", "uint64", "uint8", "uiopen", "uipanel", "uiprogressdlg", "uipushtool", "uiputfile", "uiradiobutton", "uiresume", "uisave", "uisetcolor", "uisetfont", "uisetpref", "uislider", "uispinner", "uistack", "uiswitch", "uitab", "uitabgroup", "uitable", "uitextarea", "uitogglebutton", "uitoggletool", "uitoolbar", "uitree", "uitreenode", "uiwait", "uminus", "underlyingValue", "undocheckout", "unicode2native", "union", "union", "unique", "uniquetol", "unix", "unloadlibrary", "unmesh", "unmkpp", "unregisterallevents", "unregisterevent", "unstack", "untar", "unwrap", "unzip", "updateDependencies", "updateImpl", "upgradePreviouslyInstalledSupportPackages", "uplus", "upper", "urlread", "urlwrite", "usejava", "userpath", "validate", "validate", "validate", "validate", "validateattributes", "validateFunctionSignaturesJSON", "validateInputsImpl", "validatePropertiesImpl", "validatestring", "ValueIterator", "values", "vander", "var", "var", "varargin", "varargout", "varfun", "vartype", "vecnorm", "vectorize", "ver", "verctrl", "verifyAccessed", "verifyCalled", "verifyClass", "verifyEmpty", "verifyEqual", "verifyError", "verifyFail", "verifyFalse", "verifyGreaterThan", "verifyGreaterThanOrEqual", "verifyInstanceOf", "verifyLength", "verifyLessThan", "verifyLessThanOrEqual", "verifyMatches", "verifyNotAccessed", "verifyNotCalled", "verifyNotEmpty", "verifyNotEqual", "verifyNotSameHandle", "verifyNotSet", "verifyNumElements", "verifyReturnsTrue", "verifySameHandle", "verifySet", "verifySize", "verifySubstring", "verifyThat", "verifyTrue", "verifyUsing", "verifyWarning", "verifyWarningFree", "verLessThan", "version", "vertcat", "vertcat", "vertcat", "vertexAttachments", "vertexAttachments", "vertexNormal", "VideoReader", "VideoWriter", "view", "viewmtx", "visdiff", "volume", "volumebounds", "voronoi", "voronoiDiagram", "voronoiDiagram", "voronoin", "wait", "waitbar", "waitfor", "waitforbuttonpress", "warndlg", "warning", "waterfall", "web", "weboptions", "webread", "websave", "webwrite", "week", "weekday", "what", "whatsnew", "when", "when", "when", "which", "while", "whitebg", "who", "who", "whos", "whos", "width", "wilkinson", "winopen", "winqueryreg", "winter", "withAnyInputs", "withExactInputs", "withNargout", "withtol", "wordcloud", "write", "write", "write", "writecell", "writeChecksum", "writeCol", "writeComment", "writeDate", "writeHistory", "writeImg", "writeKey", "writeKeyUnit", "writematrix", "writetable", "writetimetable", "writeVideo", "xcorr", "xcov", "xlabel", "xlim", "xline", "xlsfinfo", "xlsread", "xlswrite", "xmlread", "xmlwrite", "xor", "xor", "xslt", "xtickangle", "xtickformat", "xticklabels", "xticks", "year", "years", "ylabel", "ylim", "yline", "ymd", "ytickangle", "ytickformat", "yticklabels", "yticks", "yyaxis", "yyyymmdd", "zeros", "zip", "zlabel", "zlim", "zoom", "zoomInteraction", "ztickangle", "ztickformat", "zticklabels", "zticks"] + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/meson.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/meson.rb new file mode 100644 index 0000000..ab0bd64 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/meson.rb @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Meson < RegexLexer + title "Meson" + desc "Meson's specification language (mesonbuild.com)" + tag 'meson' + filenames 'meson.build', 'meson_options.txt' + mimetypes 'text/x-meson' + + def self.keywords + @keywords ||= %w( + continue break elif else endif + if true false foreach endforeach + ) + end + + def self.builtin_variables + @builtin_variables ||= %w( + meson host_machine build_machine target_machine + ) + end + + def self.builtin_functions + @builtin_functions ||= %w( + add_global_arguments add_project_arguments + add_global_link_arguments add_project_link_arguments add_test_setup add_languages + alias_target assert benchmark both_libraries build_target configuration_data configure_file + custom_target declare_dependency dependency disabler environment error executable + generator gettext get_option get_variable files find_library find_program + include_directories import install_data install_headers install_man install_subdir + is_disabler is_variable jar join_paths library message option project + run_target run_command set_variable subdir subdir_done + subproject summary shared_library shared_module static_library test vcs_tag warning + ) + end + + identifier = /[[:alpha:]_][[:alnum:]_]*/ + + def current_string + @current_string ||= StringRegister.new + end + + state :root do + rule %r/\n+/m, Text + + rule %r/[^\S\n]+/, Text + rule %r(#(.*)?\n?), Comment::Single + rule %r/[\[\]{}:(),;.]/, Punctuation + rule %r/\\\n/, Text + rule %r/\\/, Text + + rule %r/(in|and|or|not)\b/, Operator::Word + rule %r/[-+\/*%=<>]=?|!=/, Operator + + rule %r/([f]?)('''|['])/i do |m| + groups Str::Affix, Str + current_string.register type: m[1].downcase, delim: m[2] + push :generic_string + end + + rule %r/(?|->|<-|\\/|xor|/\\), Operator + rule %r(<|>|<=|>=|==|=|!=), Operator + rule %r(\+|-|\*|/|div|mod), Operator + rule %r(\\|\.\.|\+\+), Operator + rule %r([|()\[\]{},:;]), Punctuation + rule %r((true|false)\b), Keyword::Constant + rule %r(([+-]?)\d+(\.(?!\.)\d*)?([eE][-+]?\d+)?), Literal::Number + + rule id do |m| + if self.class.keywords.include? m[0] + token Keyword + elsif self.class.keywords_type.include? m[0] + token Keyword::Type + elsif self.class.builtins.include? m[0] + token Name::Builtin + elsif self.class.operators.include? m[0] + token Operator + else + token Name::Other + end + end + + rule %r(::\s*([^\W\d]\w*)(\s*\([^\)]*\))?), Name::Decorator + rule %r(\b([^\W\d]\w*)\b(\()) do + groups Name::Function, Punctuation + end + rule %r([^\W\d]\w*), Name::Other + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/moonscript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/moonscript.rb new file mode 100644 index 0000000..055422b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/moonscript.rb @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'lua.rb' + + class Moonscript < RegexLexer + title "MoonScript" + desc "Moonscript (http://www.moonscript.org)" + tag 'moonscript' + aliases 'moon' + filenames '*.moon' + mimetypes 'text/x-moonscript', 'application/x-moonscript' + + option :function_highlighting, 'Whether to highlight builtin functions (default: true)' + option :disabled_modules, 'builtin modules to disable' + + def initialize(*) + super + + @function_highlighting = bool_option(:function_highlighting) { true } + @disabled_modules = list_option(:disabled_modules) + end + + def self.detect?(text) + return true if text.shebang? 'moon' + end + + def builtins + return [] unless @function_highlighting + + @builtins ||= Set.new.tap do |builtins| + Rouge::Lexers::Lua.builtins.each do |mod, fns| + next if @disabled_modules.include? mod + builtins.merge(fns) + end + end + end + + state :root do + rule %r(#!(.*?)$), Comment::Preproc # shebang + rule %r//, Text, :main + end + + state :base do + ident = '(?:\w\w*)' + + rule %r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'), Num::Float + rule %r((?i)\d+e[+-]?\d+), Num::Float + rule %r((?i)0x[0-9a-f]*), Num::Hex + rule %r(\d+), Num::Integer + rule %r(@#{ident}*), Name::Variable::Instance + rule %r([A-Z]\w*), Name::Class + rule %r("?[^"]+":), Literal::String::Symbol + rule %r(#{ident}:), Literal::String::Symbol + rule %r(:#{ident}), Literal::String::Symbol + + rule %r(\s+), Text::Whitespace + rule %r((==|~=|!=|<=|>=|\.\.\.|\.\.|->|=>|[=+\-*/%^<>#!\\])), Operator + rule %r([\[\]\{\}\(\)\.,:;]), Punctuation + rule %r((and|or|not)\b), Operator::Word + + keywords = %w{ + break class continue do else elseif end extends for if import in + repeat return switch super then unless until using when with while + } + rule %r((#{keywords.join('|')})\b), Keyword + rule %r((local|export)\b), Keyword::Declaration + rule %r((true|false|nil)\b), Keyword::Constant + + rule %r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?) do |m| + name = m[0] + if self.builtins.include?(name) + token Name::Builtin + elsif name =~ /\./ + a, b = name.split('.', 2) + token Name, a + token Punctuation, '.' + token Name, b + else + token Name + end + end + end + + state :main do + rule %r(--.*$), Comment::Single + rule %r(\[(=*)\[.*?\]\1\])m, Str::Heredoc + + mixin :base + + rule %r('), Str::Single, :sqs + rule %r("), Str::Double, :dqs + end + + state :sqs do + rule %r('), Str::Single, :pop! + rule %r([^']+), Str::Single + end + + state :interpolation do + rule %r(\}), Str::Interpol, :pop! + mixin :base + end + + state :dqs do + rule %r(#\{), Str::Interpol, :interpolation + rule %r("), Str::Double, :pop! + rule %r(#[^{]), Str::Double + rule %r([^"#]+), Str::Double + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mosel.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mosel.rb new file mode 100644 index 0000000..bad56d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mosel.rb @@ -0,0 +1,228 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Mosel < RegexLexer + tag 'mosel' + filenames '*.mos' + title "Mosel" + desc "An optimization language used by Fico's Xpress." + # http://www.fico.com/en/products/fico-xpress-optimization-suite + filenames '*.mos' + + mimetypes 'text/x-mosel' + + id = /[a-zA-Z_][a-zA-Z0-9_]*/ + + ############################################################################################################################ + # General language lements + ############################################################################################################################ + + core_keywords = %w( + and array as + boolean break + case count counter + declarations div do dynamic + elif else end evaluation exit + false forall forward from function + if imports in include initialisations initializations integer inter is_binary is_continuous is_free is_integer is_partint is_semcont is_semint is_sos1 is_sos2 + linctr list + max min mod model mpvar + next not of options or + package parameters procedure + public prod range real record repeat requirements + set string sum + then to true + union until uses + version + while with + ) + + core_functions = %w( + abs arctan assert + bitflip bitneg bitset bitshift bittest bitval + ceil cos create currentdate currenttime cuthead cuttail + delcell exists exit exp exportprob + fclose fflush finalize findfirst findlast floor fopen fselect fskipline + getact getcoeff getcoeffs getdual getfid getfirst gethead getfname getlast getobjval getparam getrcost getreadcnt getreverse getsize getslack getsol gettail gettype getvars + iseof ishidden isodd ln log + makesos1 makesos2 maxlist minlist + publish + random read readln reset reverse round + setcoeff sethidden setioerr setname setparam setrandseed settype sin splithead splittail sqrt strfmt substr + timestamp + unpublish + write writeln + ) + + ############################################################################################################################ + # mmxprs module elements + ############################################################################################################################ + + mmxprs_functions = %w( + addmipsol + basisstability + calcsolinfo clearmipdir clearmodcut command copysoltoinit + defdelayedrows defsecurevecs + estimatemarginals + fixglobal + getbstat getdualray getiis getiissense getiistype getinfcause getinfeas getlb getloadedlinctrs getloadedmpvars getname getprimalray getprobstat getrange getsensrng getsize getsol getub getvars + implies indicator isiisvalid isintegral loadbasis + loadmipsol loadprob + maximize minimize + postsolve + readbasis readdirs readsol refinemipsol rejectintsol repairinfeas resetbasis resetiis resetsol + savebasis savemipsol savesol savestate selectsol setbstat setcallback setcbcutoff setgndata setlb setmipdir setmodcut setsol setub setucbdata stopoptimize + unloadprob + writebasis writedirs writeprob writesol + xor + ) + + mmxpres_constants = %w(XPRS_OPT XPRS_UNF XPRS_INF XPRS_UNB XPRS_OTH) + + mmxprs_parameters = %w(XPRS_colorder XPRS_enumduplpol XPRS_enummaxsol XPRS_enumsols XPRS_fullversion XPRS_loadnames XPRS_problem XPRS_probname XPRS_verbose) + + + ############################################################################################################################ + # mmsystem module elements + ############################################################################################################################ + + mmsystem_functions = %w( + addmonths + copytext cuttext + deltext + endswith expandpath + fcopy fdelete findfiles findtext fmove + getasnumber getchar getcwd getdate getday getdaynum getdays getdirsep + getendparse setendparse + getenv getfsize getfstat getftime gethour getminute getmonth getmsec getpathsep + getqtype setqtype + getsecond + getsepchar setsepchar + getsize + getstart setstart + getsucc setsucc + getsysinfo getsysstat gettime + gettmpdir + gettrim settrim + getweekday getyear + inserttext isvalid + makedir makepath newtar + newzip nextfield + openpipe + parseextn parseint parsereal parsetext pastetext pathmatch pathsplit + qsort quote + readtextline regmatch regreplace removedir removefiles + setchar setdate setday setenv sethour + setminute setmonth setmsec setsecond settime setyear sleep startswith system + tarlist textfmt tolower toupper trim + untar unzip + ziplist + ) + + mmsystem_parameters = %w(datefmt datetimefmt monthnames sys_endparse sys_fillchar sys_pid sys_qtype sys_regcache sys_sepchar) + + ############################################################################################################################ + # mmjobs module elements + ############################################################################################################################ + + mmjobs_instance_mgmt_functions = %w( + clearaliases connect + disconnect + findxsrvs + getaliases getbanner gethostalias + sethostalias + ) + + mmjobs_model_mgmt_functions = %w( + compile + detach + getannidents getannotations getexitcode getgid getid getnode getrmtid getstatus getuid + load + reset resetmodpar run + setcontrol setdefstream setmodpar setworkdir stop + unload + ) + + mmjobs_synchornization_functions = %w( + dropnextevent + getclass getfromgid getfromid getfromuid getnextevent getvalue + isqueueempty + nullevent + peeknextevent + send setgid setuid + wait waitfor + ) + + mmjobs_functions = mmjobs_instance_mgmt_functions + mmjobs_model_mgmt_functions + mmjobs_synchornization_functions + + mmjobs_parameters = %w(conntmpl defaultnode fsrvdelay fsrvnbiter fsrvport jobid keepalive nodenumber parentnumber) + + + state :whitespace do + # Spaces + rule %r/\s+/m, Text + # ! Comments + rule %r((!).*$\n?), Comment::Single + # (! Comments !) + rule %r(\(!.*?!\))m, Comment::Multiline + + end + + + # From Mosel documentation: + # Constant strings of characters must be quoted with single (') or double quote (") and may extend over several lines. Strings enclosed in double quotes may contain C-like escape sequences introduced by the 'backslash' + # character (\a \b \f \n \r \t \v \xxx with xxx being the character code as an octal number). + # Each sequence is replaced by the corresponding control character (e.g. \n is the `new line' command) or, if no control character exists, by the second character of the sequence itself (e.g. \\ is replaced by '\'). + # The escape sequences are not interpreted if they are contained in strings that are enclosed in single quotes. + + state :single_quotes do + rule %r/'/, Str::Single, :pop! + rule %r/[^']+/, Str::Single + end + + state :double_quotes do + rule %r/"/, Str::Double, :pop! + rule %r/(\\"|\\[0-7]{1,3}\D|\\[abfnrtv]|\\\\)/, Str::Escape + rule %r/[^"]/, Str::Double + end + + state :base do + + rule %r{"}, Str::Double, :double_quotes + rule %r{'}, Str::Single, :single_quotes + + rule %r{((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?}, Num + rule %r{[~!@#\$%\^&\*\(\)\+`\-={}\[\]:;<>\?,\.\/\|\\]}, Punctuation +# rule %r{'([^']|'')*'}, Str +# rule %r/"(\\\\|\\"|[^"])*"/, Str + + + + rule %r/(true|false)\b/i, Name::Builtin + rule %r/\b(#{core_keywords.join('|')})\b/i, Keyword + rule %r/\b(#{core_functions.join('|')})\b/, Name::Builtin + + + + rule %r/\b(#{mmxprs_functions.join('|')})\b/, Name::Function + rule %r/\b(#{mmxpres_constants.join('|')})\b/, Name::Constant + rule %r/\b(#{mmxprs_parameters.join('|')})\b/i, Name::Property + + rule %r/\b(#{mmsystem_functions.join('|')})\b/i, Name::Function + rule %r/\b(#{mmsystem_parameters.join('|')})\b/, Name::Property + + rule %r/\b(#{mmjobs_functions.join('|')})\b/i, Name::Function + rule %r/\b(#{mmjobs_parameters.join('|')})\b/, Name::Property + + rule id, Name + end + + state :root do + mixin :whitespace + mixin :base + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/msgtrans.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/msgtrans.rb new file mode 100644 index 0000000..4f21ca1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/msgtrans.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class MsgTrans < RegexLexer + title "MessageTrans" + desc "RISC OS message translator messages file" + tag 'msgtrans' + filenames 'Messages', 'Message[0-9]', 'Message[1-9][0-9]', 'Message[1-9][0-9][0-9]' + + state :root do + rule %r/^#[^\n]*/, Comment + rule %r/[^\t\n\r ,):?\/]+/, Name::Variable + rule %r/[\n\/?]/, Operator + rule %r/:/, Operator, :value + end + + state :value do + rule %r/\n/, Text, :pop! + rule %r/%[0-3%]/, Operator + rule %r/[^\n%]/, Literal::String + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mxml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mxml.rb new file mode 100644 index 0000000..4a9145a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/mxml.rb @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class MXML < RegexLexer + title "MXML" + desc "MXML" + tag 'mxml' + filenames '*.mxml' + mimetypes 'application/xv+xml' + + state :root do + rule %r/[^<&]+/, Text + rule %r/&\S*?;/, Name::Entity + + rule %r//, Comment::Preproc + rule %r/]*>/, Comment::Preproc + + rule %r(<\s*[\w:.-]+)m, Name::Tag, :tag # opening tags + rule %r(<\s*/\s*[\w:.-]+\s*>)m, Name::Tag # closing tags + end + + state :comment do + rule %r/[^-]+/m, Comment + rule %r/-->/, Comment, :pop! + rule %r/-/, Comment + end + + state :tag do + rule %r/\s+/m, Text + rule %r/[\w.:-]+\s*=/m, Name::Attribute, :attribute + rule %r(/?\s*>), Name::Tag, :root + end + + state :attribute do + rule %r/\s+/m, Text + rule %r/(")({|@{)/m do + groups Str, Punctuation + push :actionscript_attribute + end + rule %r/".*?"|'.*?'|[^\s>]+/, Str, :tag + end + + state :actionscript_content do + rule %r/\]\]\>/m, Comment::Preproc, :pop! + rule %r/.*?(?=\]\]\>)/m do + delegate Actionscript + end + end + + state :actionscript_attribute do + rule %r/(})(")/m do + groups Punctuation, Str + push :tag + end + rule %r/.*?(?=}")/m do + delegate Actionscript + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nasm.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nasm.rb new file mode 100644 index 0000000..2e2df7f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nasm.rb @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# Based on Chroma's NASM lexer implementation +# https://github.com/alecthomas/chroma/blob/498eaa690f5ac6ab0e3d6f46237e547a8935cdc7/lexers/n/nasm.go +module Rouge + module Lexers + class Nasm < RegexLexer + title "Nasm" + desc "Netwide Assembler" + + tag 'nasm' + filenames '*.asm' + mimetypes 'text/x-nasm' + + state :root do + rule %r/^\s*%/, Comment::Preproc, :preproc + + mixin :whitespace + mixin :punctuation + + rule %r/[a-z$._?][\w$.?#@~]*:/i, Name::Label + + rule %r/([a-z$._?][\w$.?#@~]*)(\s+)(equ)/i do + groups Name::Constant, Keyword::Declaration, Keyword::Declaration + push :instruction_args + end + rule %r/BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULE/, Keyword, :instruction_args + rule %r/(?:res|d)[bwdqt]|times/i, Keyword::Declaration, :instruction_args + rule %r/[a-z$._?][\w$.?#@~]*/i, Name::Function, :instruction_args + + rule %r/[\r\n]+/, Text + end + + state :instruction_args do + rule %r/"(\\\\"|[^"\\n])*"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`/, Str + rule %r/(?:0x[\da-f]+|$0[\da-f]*|\d+[\da-f]*h)/i, Num::Hex + rule %r/[0-7]+q/i, Num::Oct + rule %r/[01]+b/i, Num::Bin + rule %r/\d+\.e?\d+/i, Num::Float + rule %r/\d+/, Num::Integer + + mixin :punctuation + + rule %r/r\d[0-5]?[bwd]|[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]/i, Name::Builtin + rule %r/[a-z$._?][\w$.?#@~]*/i, Name::Variable + rule %r/[\r\n]+/, Text, :pop! + + mixin :whitespace + end + + state :preproc do + rule %r/[^;\n]+/, Comment::Preproc + rule %r/;.*?\n/, Comment::Single, :pop! + rule %r/\n/, Comment::Preproc, :pop! + end + + state :whitespace do + rule %r/\n/, Text + rule %r/[ \t]+/, Text + rule %r/;.*/, Comment::Single + end + + state :punctuation do + rule %r/[,():\[\]]+/, Punctuation + rule %r/[&|^<>+*\/%~-]+/, Operator + rule %r/\$+/, Keyword::Constant + rule %r/seg|wrt|strict/i, Operator::Word + rule %r/byte|[dq]?word/i, Keyword::Type + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nesasm.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nesasm.rb new file mode 100644 index 0000000..a296414 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nesasm.rb @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class NesAsm < RegexLexer + title "NesAsm" + desc "Nesasm3 assembly (6502 asm)" + tag 'nesasm' + aliases 'nes' + filenames '*.nesasm' + + def self.keywords + @keywords ||= %w( + ADC AND ASL BIT BRK CMP CPX CPY DEC EOR INC JMP JSR LDA LDX LDY LSR + NOP ORA ROL ROR RTI RTS SBC STA STX STY TAX TXA DEX INX TAY TYA DEY + INY BPL BMI BVC BVS BCC BCS BNE BEQ CLC SEC CLI SEI CLV CLD SED TXS + TSX PHA PLA PHP PLP + ) + end + + def self.keywords_type + @keywords_type ||= %w( + DB DW BYTE WORD + ) + end + + def self.keywords_reserved + @keywords_reserved ||= %w( + INCBIN INCLUDE ORG BANK RSSET RS MACRO ENDM DS PROC ENDP PROCGROUP + ENDPROCGROUP INCCHR DEFCHR ZP BSS CODE DATA IF IFDEF IFNDEF ELSE + ENDIF FAIL INESPRG INESCHR INESMAP INESMIR FUNC + ) + end + + state :root do + rule %r/\s+/m, Text + rule %r(;.*), Comment::Single + + rule %r/[\(\)\,\.\[\]]/, Punctuation + rule %r/\#?\%[0-1]+/, Num::Bin # #%00110011 %00110011 + rule %r/\#?\$\h+/, Num::Hex # $1f #$1f + rule %r/\#?\d+/, Num # 10 #10 + rule %r([~&*+=\|?:<>/-]), Operator + + rule %r/\#?\w+:?/i do |m| + name = m[0].upcase + + if self.class.keywords.include? name + token Keyword + elsif self.class.keywords_type.include? name + token Keyword::Type + elsif self.class.keywords_reserved.include? name + token Keyword::Reserved + else + token Name::Function + end + end + + rule %r/\#?(?:LOW|HIGH)\(.*\)/i, Keyword::Reserved # LOW() #HIGH() + + rule %r/\#\(/, Punctuation # #() + + rule %r/"/, Str, :string + + rule %r/'\w'/, Str::Char # 'A' for example + + rule %r/\\\??[\d@#]/, Name::Builtin # builtin parameters for use inside macros and functions: \1-\9 , \?1-\?9 , \# , \@ + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\"?/, Str::Escape + rule %r/[^"\\]+/m, Str + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nginx.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nginx.rb new file mode 100644 index 0000000..f2661cc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nginx.rb @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Nginx < RegexLexer + title "nginx" + desc 'configuration files for the nginx web server (nginx.org)' + tag 'nginx' + mimetypes 'text/x-nginx-conf' + filenames 'nginx.conf' + + id = /[^\s$;{}()#]+/ + + state :root do + rule %r/(include)(\s+)([^\s;]+)/ do + groups Keyword, Text, Name + end + + rule id, Keyword, :statement + + mixin :base + end + + state :block do + rule %r/}/, Punctuation, :pop! + rule id, Keyword::Namespace, :statement + mixin :base + end + + state :statement do + rule %r/{/ do + token Punctuation; pop!; push :block + end + + rule %r/;/, Punctuation, :pop! + + mixin :base + end + + state :base do + rule %r/\s+/, Text + + rule %r/#.*/, Comment::Single + rule %r/(?:on|off)\b/, Name::Constant + rule %r/[$][\w-]+/, Name::Variable + + # host/port + rule %r/([a-z0-9.-]+)(:)([0-9]+)/i do + groups Name::Function, Punctuation, Num::Integer + end + + # mimetype + rule %r([a-z-]+/[a-z-]+)i, Name::Class + + rule %r/\d+\.\d+/, Num::Float + rule %r/[0-9]+[kmg]?\b/i, Num::Integer + rule %r/(~)(\s*)([^\s{]+)/ do + groups Punctuation, Text, Str::Regex + end + + rule %r/[:=~]/, Punctuation + + # pathname + rule %r(/#{id}?), Name + + rule %r/[^#\s;{}$\\]+/, Str # catchall + + rule %r/[$;]/, Text + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nial.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nial.rb new file mode 100644 index 0000000..42b2260 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nial.rb @@ -0,0 +1,166 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Nial < RegexLexer + title 'Nial' + desc 'The Nial programming language (nial-array-language.org)' + tag 'nial' + filenames '*.ndf', '*.nlg' + + def self.keywords + @keywords ||= Set.new ["is", "gets", "op", "tr", ";", + "if", "then", "elseif", "else", + "endif", "case", "from", "endcase", + "begin", "end", "for", "with", + "endfor", "while", "do", "endwhile", + "repeat", "until", "endrepeat"] + end + + def self.operators + @operators||= Set.new [".", "!", "#", "+", "*", "-", "<<", + "/", "<", ">>", "<=", ">", "=", ">=", "@", "|", "~="] + end + + def self.punctuations + @punctuations ||= Set.new [ "{", "}", "[", "]", ",", "(", ")", ":=", ":", ";"] + end + + def self.transformers + @transformers ||= Set.new ["accumulate", "across", + "bycols", "bykey", "byrows", + "converse", "down", + "eachboth", "eachall", "each", + "eachleft", "eachright", + "filter", "fold", "fork", + "grade", "inner", "iterate", + "leaf", "no_tr", "outer", + "partition", "rank", "recur", + "reduce", "reducecols", "reducerows", + "sort", "team", "timeit", "twig"] + end + + def self.funcs + @funcs ||= Set.new ["operation", "expression", "and", "abs", + "allbools", "allints", "allchars", "allin", + "allreals", "allnumeric", "append", + "arcsin", "arccos", "appendfile", "apply", + "arctan", "atomic", "assign", "atversion", + "axes", "cart", "break", "blend", "breaklist", + "breakin", "bye", "callstack", "choose", "char", + "ceiling", "catenate", "charrep", "check_socket", + "cos", "content", "close", "clearws", + "clearprofile", "cols", "continue", "copyright", + "cosh", "cull", "count", "diverse", "deepplace", + "cutall", "cut", "display", "deparse", + "deepupdate", "descan", "depth", "diagram", + "div", "divide", "drop", "dropright", "edit", + "empty", "expression", "exit", "except", "erase", + "equal", "eval", "eraserecord", "execute", "exp", + "external", "exprs", "findall", "find", + "fault", "falsehood", "filestatus", "filelength", + "filepath", "filetally", "floor", "first", + "flip", "fuse", "fromraw", "front", + "gage", "getfile", "getdef", "getcommandline", + "getenv", "getname", "hitch", "grid", "getsyms", + "gradeup", "gt", "gte", "host", "in", "inverse", + "innerproduct", "inv", "ip", "ln", "link", "isboolean", + "isinteger", "ischar", "isfault", "isreal", "isphrase", + "isstring", "istruthvalue", "last", "laminate", + "like", "libpath", "library", "list", "load", + "loaddefs", "nonlocal", "max", "match", "log", + "lt", "lower", "lte", "mate", "min", "maxlength", + "mod", "mix", "minus", "nialroot", "mold", "not", + "numeric", "no_op", "no_expr", "notin", + "operation", "open", "or", "opposite", "opp", + "operators", "plus", "pick", "pack", "pass", "pair", "parse", + "paste", "phrase", "place", "picture", "placeall", + "power", "positions", "post", "quotient", "putfile", + "profile", "prod", "product", "profiletree", + "profiletable", "quiet_fault", "raise", "reach", + "random", "reciprocal", "read", "readfile", + "readchar", "readarray", "readfield", + "readscreen", "readrecord", "recip", "reshape", + "seek", "second", "rest", "reverse", "restart", + "return_status", "scan", "save", "rows", "rotate", + "seed", "see", "sublist", "sin", "simple", "shape", + "setformat", "setdeftrace", "set", "seeusercalls", + "seeprimcalls", "separator", "setwidth", "settrigger", + "setmessages", "setlogname", "setinterrupts", + "setprompt", "setprofile", "sinh", "single", + "sqrt", "solitary", "sketch", "sleep", + "socket_listen", "socket_accept", "socket_close", + "socket_bind", "socket_connect", "socket_getline", + "socket_receive", "socket_peek", "socket_read", + "socket_send", "socket_write", "solve", "split", + "sortup", "string", "status", "take", "symbols", + "sum", "system", "tan", "tally", "takeright", + "tanh", "tell", "tr", "times", "third", "time", + "toupper", "tolower", "timestamp", "tonumber", + "toraw", "toplevel", "transformer", "type", + "transpose", "trs", "truth", "unequal", + "variable", "valence", "up", "updateall", + "update", "vacate", "value", "version", "vars", + "void", "watch", "watchlist", "write", "writechars", + "writearray", "writefile", "writefield", + "writescreen", "writerecord"] + end + + def self.consts + @consts ||= Set.new %w(false null pi true) + end + + state :root do + rule %r/'/, Str::Single, :str + rule %r/\b[lo]+\b/, Num::Bin + rule %r/-?\d+((\.\d*)?[eE][+-]?\d|\.)\d*/, Num::Float + rule %r/\-?\d+/, Num::Integer + rule %r/`./, Str::Char + rule %r/"[^\s()\[\]{}#,;]*/, Str::Symbol + rule %r/\?[^\s()\[\]{}#,;]*/, Generic::Error + rule %r/%[^;]+;/, Comment::Multiline + rule %r/^#(.+\n)+\n/, Comment::Multiline + rule %r/:=|[\{\}\[\]\(\),:;]/ do |m| + if self.class.punctuations.include?(m[0]) + token Punctuation + else + token Text + end + end + # [".", "!", "#", "+", "*", "-", "<<", + # "/", "<", ">>", "<=", ">", "=", ">=", "@", "|", "~="] + rule %r'>>|>=|<=|~=|[\.!#+*\-=>|<|\+|-|\/|@|\$|~|&|%|\!|\?|\||\\|\[|\]/, Operator) + rule(/\.\.|\.|,|\[\.|\.\]|{\.|\.}|\(\.|\.\)|{|}|\(|\)|:|\^|`|;/, + Punctuation) + + # Strings + rule(/(?:\w+)"/,Str, :rdqs) + rule(/"""/, Str, :tdqs) + rule(/"/, Str, :dqs) + + # Char + rule(/'/, Str::Char, :chars) + + # Keywords + rule(%r[(#{Nim.underscorize(OPWORDS)})\b], Operator::Word) + rule(/(p_?r_?o_?c_?\s)(?![\(\[\]])/, Keyword, :funcname) + rule(%r[(#{Nim.underscorize(KEYWORDS)})\b], Keyword) + rule(%r[(#{Nim.underscorize(NAMESPACE)})\b], Keyword::Namespace) + rule(/(v_?a_?r)\b/, Keyword::Declaration) + rule(%r[(#{Nim.underscorize(TYPES)})\b], Keyword::Type) + rule(%r[(#{Nim.underscorize(PSEUDOKEYWORDS)})\b], Keyword::Pseudo) + # Identifiers + rule(/\b((?![_\d])\w)(((?!_)\w)|(_(?!_)\w))*/, Name) + + # Numbers + # Note: Have to do this with a block to push multiple states first, + # since we can't pass array of states like w/ Pygments. + rule(/[0-9][0-9_]*(?=([eE.]|'?[fF](32|64)))/) do + push :floatsuffix + push :floatnumber + token Num::Float + end + + rule(/0[xX][a-fA-F0-9][a-fA-F0-9_]*/, Num::Hex, :intsuffix) + rule(/0[bB][01][01_]*/, Num, :intsuffix) + rule(/0o[0-7][0-7_]*/, Num::Oct, :intsuffix) + rule(/[0-9][0-9_]*/, Num::Integer, :intsuffix) + + # Whitespace + rule(/\s+/, Text) + rule(/.+$/, Error) + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nix.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nix.rb new file mode 100644 index 0000000..7cc9a3a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/nix.rb @@ -0,0 +1,211 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Nix < RegexLexer + title 'Nix' + desc 'The Nix expression language (https://nixos.org/nix/manual/#ch-expression-language)' + tag 'nix' + aliases 'nixos' + filenames '*.nix' + + state :whitespaces do + rule %r/^\s*\n\s*$/m, Text + rule %r/\s+/, Text + end + + state :comment do + rule %r/#.*$/, Comment + rule %r(/\*), Comment, :multiline_comment + end + + state :multiline_comment do + rule %r(\*/), Comment, :pop! + rule %r/./, Comment + end + + state :number do + rule %r/[0-9]/, Num::Integer + end + + state :null do + rule %r/(null)/, Keyword::Constant + end + + state :boolean do + rule %r/(true|false)/, Keyword::Constant + end + + state :binding do + rule %r/[a-zA-Z_][a-zA-Z0-9-]*/, Name::Variable + end + + state :path do + word = "[a-zA-Z0-9\._-]+" + section = "(\/#{word})" + prefix = "[a-z\+]+:\/\/" + root = /#{section}+/.source + tilde = /~#{section}+/.source + basic = /#{word}(\/#{word})+/.source + url = /#{prefix}(\/?#{basic})/.source + rule %r/(#{root}|#{tilde}|#{basic}|#{url})/, Str::Other + end + + state :string do + rule %r/"/, Str::Double, :double_quoted_string + rule %r/''/, Str::Double, :indented_string + end + + state :string_content do + rule %r/\\./, Str::Escape + rule %r/\$\$/, Str::Escape + rule %r/\${/, Str::Interpol, :string_interpolated_arg + end + + state :indented_string_content do + rule %r/'''/, Str::Escape + rule %r/''\$/, Str::Escape + rule %r/\$\$/, Str::Escape + rule %r/''\\./, Str::Escape + rule %r/\${/, Str::Interpol, :string_interpolated_arg + end + + state :string_interpolated_arg do + mixin :expression + rule %r/}/, Str::Interpol, :pop! + end + + state :indented_string do + mixin :indented_string_content + rule %r/''/, Str::Double, :pop! + rule %r/./, Str::Double + end + + state :double_quoted_string do + mixin :string_content + rule %r/"/, Str::Double, :pop! + rule %r/./, Str::Double + end + + state :operator do + rule %r/(\.|\?|\+\+|\+|!=|!|\/\/|\=\=|&&|\|\||->|\/|\*|-|<|>|<=|=>)/, Operator + end + + state :assignment do + rule %r/(=)/, Operator + rule %r/(@)/, Operator + end + + state :accessor do + rule %r/(\$)/, Punctuation + end + + state :delimiter do + rule %r/(;|,|:)/, Punctuation + end + + state :atom_content do + mixin :expression + rule %r/\)/, Punctuation, :pop! + end + + state :atom do + rule %r/\(/, Punctuation, :atom_content + end + + state :list do + rule %r/\[/, Punctuation, :list_content + end + + state :list_content do + rule %r/\]/, Punctuation, :pop! + mixin :expression + end + + state :set do + rule %r/{/, Punctuation, :set_content + end + + state :set_content do + rule %r/}/, Punctuation, :pop! + mixin :expression + end + + state :expression do + mixin :ignore + mixin :comment + mixin :boolean + mixin :null + mixin :number + mixin :path + mixin :string + mixin :keywords + mixin :operator + mixin :accessor + mixin :assignment + mixin :delimiter + mixin :binding + mixin :atom + mixin :set + mixin :list + end + + state :keywords do + mixin :keywords_namespace + mixin :keywords_declaration + mixin :keywords_conditional + mixin :keywords_reserved + mixin :keywords_builtin + end + + state :keywords_namespace do + keywords = %w(with in inherit) + rule %r/(?:#{keywords.join('|')})\b/, Keyword::Namespace + end + + state :keywords_declaration do + keywords = %w(let) + rule %r/(?:#{keywords.join('|')})\b/, Keyword::Declaration + end + + state :keywords_conditional do + keywords = %w(if then else) + rule %r/(?:#{keywords.join('|')})\b/, Keyword + end + + state :keywords_reserved do + keywords = %w(rec assert map) + rule %r/(?:#{keywords.join('|')})\b/, Keyword::Reserved + end + + state :keywords_builtin do + keywords = %w( + abort + baseNameOf + builtins + derivation + fetchTarball + import + isNull + removeAttrs + throw + toString + ) + rule %r/(?:#{keywords.join('|')})\b/, Keyword::Reserved + end + + state :ignore do + mixin :whitespaces + end + + state :root do + mixin :ignore + mixin :expression + end + + start do + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_c.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_c.rb new file mode 100644 index 0000000..f147851 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_c.rb @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'c.rb' + load_lexer 'objective_c/common.rb' + + class ObjectiveC < C + extend ObjectiveCCommon + + tag 'objective_c' + title "Objective-C" + desc 'an extension of C commonly used to write Apple software' + aliases 'objc', 'obj-c', 'obj_c', 'objectivec', 'objective-c' + filenames '*.m', '*.h' + + mimetypes 'text/x-objective_c', 'application/x-objective_c' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_c/common.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_c/common.rb new file mode 100644 index 0000000..2cb8107 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_c/common.rb @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + module ObjectiveCCommon + def at_keywords + @at_keywords ||= %w( + selector private protected public encode synchronized try + throw catch finally end property synthesize dynamic optional + interface implementation import autoreleasepool + ) + end + + def at_builtins + @at_builtins ||= %w(true false YES NO) + end + + def builtins + @builtins ||= %w(YES NO nil) + end + + def self.extended(base) + base.prepend :statements do + rule %r/@"/, base::Str, :string + rule %r/@'(\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|\\.|[^\\'\n]')/, + base::Str::Char + rule %r/@(\d+[.]\d*|[.]\d+|\d+)e[+-]?\d+l?/i, + base::Num::Float + rule %r/@(\d+[.]\d*|[.]\d+|\d+f)f?/i, base::Num::Float + rule %r/@0x\h+[lL]?/, base::Num::Hex + rule %r/@0[0-7]+l?/i, base::Num::Oct + rule %r/@\d+l?/, base::Num::Integer + rule %r/\bin\b/, base::Keyword + + rule %r/@(?:interface|implementation)\b/, base::Keyword, :objc_classname + rule %r/@(?:class|protocol)\b/, base::Keyword, :forward_classname + + rule %r/@([[:alnum:]]+)/ do |m| + if base.at_keywords.include? m[1] + token base::Keyword + elsif base.at_builtins.include? m[1] + token base::Name::Builtin + else + token base::Error + end + end + + rule %r/[?]/, base::Punctuation, :ternary + rule %r/\[/, base::Punctuation, :message + rule %r/@\[/, base::Punctuation, :array_literal + rule %r/@\{/, base::Punctuation, :dictionary_literal + end + + id = /[a-z$_][a-z0-9$_]*/i + + base.state :ternary do + rule %r/:/, base::Punctuation, :pop! + mixin :statements + end + + base.state :message_shared do + rule %r/\]/, base::Punctuation, :pop! + rule %r/\{/, base::Punctuation, :pop! + rule %r/;/, base::Error + + mixin :statements + end + + base.state :message do + rule %r/(#{id})(\s*)(:)/ do + groups(base::Name::Function, base::Text, base::Punctuation) + goto :message_with_args + end + + rule %r/(#{id})(\s*)(\])/ do + groups(base::Name::Function, base::Text, base::Punctuation) + pop! + end + + mixin :message_shared + end + + base.state :message_with_args do + rule %r/\{/, base::Punctuation, :function + rule %r/(#{id})(\s*)(:)/ do + groups(base::Name::Function, base::Text, base::Punctuation) + pop! + end + + mixin :message_shared + end + + base.state :array_literal do + rule %r/]/, base::Punctuation, :pop! + rule %r/,/, base::Punctuation + mixin :statements + end + + base.state :dictionary_literal do + rule %r/}/, base::Punctuation, :pop! + rule %r/,/, base::Punctuation + mixin :statements + end + + base.state :objc_classname do + mixin :whitespace + + rule %r/(#{id})(\s*)(:)(\s*)(#{id})/ do + groups(base::Name::Class, base::Text, + base::Punctuation, base::Text, + base::Name::Class) + pop! + end + + rule %r/(#{id})(\s*)([(])(\s*)(#{id})(\s*)([)])/ do + groups(base::Name::Class, base::Text, + base::Punctuation, base::Text, + base::Name::Label, base::Text, + base::Punctuation) + pop! + end + + rule id, base::Name::Class, :pop! + end + + base.state :forward_classname do + mixin :whitespace + + rule %r/(#{id})(\s*)(,)(\s*)/ do + groups(base::Name::Class, base::Text, base::Punctuation, base::Text) + push + end + + rule %r/(#{id})(\s*)(;?)/ do + groups(base::Name::Class, base::Text, base::Punctuation) + pop! + end + end + + base.prepend :root do + rule %r( + ([-+])(\s*) + ([(].*?[)])?(\s*) + (?=#{id}:?) + )ix do |m| + token base::Keyword, m[1] + token base::Text, m[2] + recurse(m[3]) if m[3] + token base::Text, m[4] + push :method_definition + end + end + + base.state :method_definition do + rule %r/,/, base::Punctuation + rule %r/[.][.][.]/, base::Punctuation + rule %r/([(].*?[)])(#{id})/ do |m| + recurse m[1]; token base::Name::Variable, m[2] + end + + rule %r/(#{id})(\s*)(:)/m do + groups(base::Name::Function, base::Text, base::Punctuation) + end + + rule %r/;/, base::Punctuation, :pop! + + rule %r/{/ do + token base::Punctuation + goto :function + end + + mixin :inline_whitespace + rule %r(//.*?\n), base::Comment::Single + rule %r/\s+/m, base::Text + + rule(//) { pop! } + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_cpp.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_cpp.rb new file mode 100644 index 0000000..2160692 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/objective_cpp.rb @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'cpp.rb' + load_lexer 'objective_c/common.rb' + + class ObjectiveCpp < Cpp + extend ObjectiveCCommon + + tag 'objective_cpp' + title "Objective-C++" + desc 'an extension of C++ uncommonly used to write Apple software' + aliases 'objcpp', 'obj-cpp', 'obj_cpp', 'objectivecpp', + 'objc++', 'obj-c++', 'obj_c++', 'objectivec++' + filenames '*.mm', '*.h' + + mimetypes 'text/x-objective-c++', 'application/x-objective-c++' + + prepend :statements do + rule %r/(\.)(class)/ do + groups(Operator, Name::Builtin::Pseudo) + end + rule %r/(@selector)(\()(class)(\))/ do + groups(Keyword, Punctuation, Name::Builtin::Pseudo, Punctuation) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocaml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocaml.rb new file mode 100644 index 0000000..684b367 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocaml.rb @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'ocaml/common.rb' + + class OCaml < OCamlCommon + title "OCaml" + desc 'Objective Caml (ocaml.org)' + tag 'ocaml' + filenames '*.ml', '*.mli', '*.mll', '*.mly' + mimetypes 'text/x-ocaml' + + def self.keywords + @keywords ||= super + Set.new(%w( + match raise + )) + end + + state :root do + rule %r/\s+/m, Text + rule %r/false|true|[(][)]|\[\]/, Name::Builtin::Pseudo + rule %r/#{@@upper_id}(?=\s*[.])/, Name::Namespace, :dotted + rule %r/`#{@@id}/, Name::Tag + rule @@upper_id, Name::Class + rule %r/[(][*](?![)])/, Comment, :comment + rule @@id do |m| + match = m[0] + if self.class.keywords.include? match + token Keyword + elsif self.class.word_operators.include? match + token Operator::Word + elsif self.class.primitives.include? match + token Keyword::Type + else + token Name + end + end + + rule %r/[(){}\[\];]+/, Punctuation + rule @@operator, Operator + + rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float + rule %r/0x\h[\h_]*/i, Num::Hex + rule %r/0o[0-7][0-7_]*/i, Num::Oct + rule %r/0b[01][01_]*/i, Num::Bin + rule %r/\d[\d_]*/, Num::Integer + + rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char + rule %r/'[.]'/, Str::Char + rule %r/'/, Keyword + rule %r/"/, Str::Double, :string + rule %r/[~?]#{@@id}/, Name::Variable + end + + state :comment do + rule %r/[^(*)]+/, Comment + rule(/[(][*]/) { token Comment; push } + rule %r/[*][)]/, Comment, :pop! + rule %r/[(*)]/, Comment + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocaml/common.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocaml/common.rb new file mode 100644 index 0000000..bd6f93d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocaml/common.rb @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + # shared states with Reasonml and ReScript + class OCamlCommon < RegexLexer + def self.keywords + @keywords ||= Set.new %w( + as assert begin class constraint do done downto else end + exception external false for fun function functor if in + include inherit initializer lazy let module mutable new + nonrec object of open rec sig struct then to true try type + val virtual when while with + ) + end + + def self.word_operators + @word_operators ||= Set.new %w(and asr land lor lsl lxor mod or) + end + + def self.primitives + @primitives ||= Set.new %w(unit int float bool string char list array) + end + + @@operator = %r([;,_!$%&*+./:<=>?@^|~#-]+) + @@id = /[a-z_][\w']*/i + @@upper_id = /[A-Z][\w']*/ + + state :string do + rule %r/[^\\"]+/, Str::Double + mixin :escape_sequence + rule %r/\\\n/, Str::Double + rule %r/"/, Str::Double, :pop! + end + + state :escape_sequence do + rule %r/\\[\\"'ntbr]/, Str::Escape + rule %r/\\\d{3}/, Str::Escape + rule %r/\\x\h{2}/, Str::Escape + end + + state :dotted do + rule %r/\s+/m, Text + rule %r/[.]/, Punctuation + rule %r/#{@@upper_id}(?=\s*[.])/, Name::Namespace + rule @@upper_id, Name::Class, :pop! + rule @@id, Name, :pop! + rule %r/[({\[]/, Punctuation, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocl.rb new file mode 100644 index 0000000..6511ffa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ocl.rb @@ -0,0 +1,84 @@ +module Rouge + module Lexers + class OCL < RegexLexer + title "OCL" + desc "OMG Object Constraint Language (omg.org/spec/OCL)" + tag 'ocl' + aliases 'OCL' + filenames '*.ocl' + mimetypes 'text/x-ocl' + + def self.keywords + @keywords ||= Set.new %w( + context pre post inv init body def derive if then else endif import + package endpackage let in + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + Boolean Integer UnlimitedNatural Real String OrderedSet Tuple Bag Set + Sequence OclInvalid OclVoid TupleType OclState Collection OclMessage + ) + end + + def self.builtins + @builtins ||= Set.new %w( + self null result true false invalid @pre + ) + end + + def self.operators + @operators ||= Set.new %w( + or xor and not implies + ) + end + + def self.functions + @functions ||= Set.new %w( + oclAsSet oclIsNew oclIsUndefined oclIsInvalid oclAsType oclIsTypeOf + oclIsKindOf oclInState oclType oclLocale hasReturned result + isSignalSent isOperationCallabs floor round max min toString div mod + size substring concat toInteger toReal toUpperCase toLowerCase + indexOf equalsIgnoreCase at characters toBoolean includes excludes + count includesAll excludesAll isEmpty notEmpty sum product + selectByKind selectByType asBag asSequence asOrderedSet asSet flatten + union intersection including excluding symmetricDifferencecount + append prepend insertAt subOrderedSet first last reverse subSequence + any closure collect collectNested exists forAll isUnique iterate one + reject select sortedBy allInstances average conformsTo + ) + end + + state :single_string do + rule %r/\\./, Str::Escape + rule %r/'/, Str::Single, :pop! + rule %r/[^\\']+/, Str::Single + end + + state :root do + rule %r/\s+/m, Text + rule %r/--.*/, Comment::Single + rule %r/\d+/, Num::Integer + rule %r/'/, Str::Single, :single_string + rule %r([-|+*/<>=~!@#%&?^]), Operator + rule %r/[;:()\[\],.]/, Punctuation + rule %r/[a-zA-Z]\w*/ do |m| + if self.class.operators.include? m[0] + token Operator + elsif self.class.keywords_type.include? m[0] + token Keyword::Declaration + elsif self.class.keywords.include? m[0] + token Keyword + elsif self.class.builtins.include? m[0] + token Name::Builtin + elsif self.class.functions.include? m[0] + token Name::Function + else + token Name + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/openedge.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/openedge.rb new file mode 100644 index 0000000..8250127 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/openedge.rb @@ -0,0 +1,632 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class OpenEdge < RegexLexer + tag 'openedge' + aliases 'abl' + filenames '*.w', '*.i', '*.p', '*.cls', '*.df' + mimetypes 'text/x-openedge' + + title 'OpenEdge ABL' + desc 'The OpenEdge ABL programming language' + + id = /[a-zA-Z_&{}!][a-zA-Z0-9_\-&!}]*/ + + def self.keywords + @keywords ||= Set.new %w( + ABORT ABS ABSO ABSOL ABSOLU ABSOLUT ABSOLUTE ABSTRACT ACCELERATOR ACCEPT-CHANGES ACCEPT-ROW-CHANGES + ACCUM ACCUMU ACCUMUL ACCUMULA ACCUMULAT ACCUMULATE ACROSS ACTIVE ACTIVE-FORM ACTIVE-WINDOW ACTOR ADD + ADD-BUFFER ADD-CALC-COL ADD-CALC-COLU ADD-CALC-COLUM ADD-CALC-COLUMN ADD-COLUMNS-FROM + ADD-EVENTS-PROC ADD-EVENTS-PROCE ADD-EVENTS-PROCED ADD-EVENTS-PROCEDU ADD-EVENTS-PROCEDUR + ADD-EVENTS-PROCEDURE ADD-FIELDS-FROM ADD-FIRST ADD-HEADER-ENTRY ADD-INDEX-FIELD ADD-INTERVAL + ADD-LAST ADD-LIKE-COLUMN ADD-LIKE-FIELD ADD-LIKE-INDEX ADD-NEW-FIELD ADD-NEW-INDEX + ADD-SCHEMA-LOCATION ADD-SOURCE-BUFFER ADD-SUPER-PROC ADD-SUPER-PROCE ADD-SUPER-PROCED + ADD-SUPER-PROCEDU ADD-SUPER-PROCEDUR ADD-SUPER-PROCEDURE ADM-DATA ADVISE AFTER-BUFFER AFTER-ROWID + AFTER-TABLE ALERT-BOX ALIAS ALL ALLOW-COLUMN-SEARCHING ALLOW-PREV-DESERIALIZATION ALLOW-REPLICATION + ALTER ALTERNATE-KEY ALWAYS-ON-TOP AMBIG AMBIGU AMBIGUO AMBIGUOU AMBIGUOUS ANALYZ ANALYZE AND + ANSI-ONLY ANY ANY-KEY ANY-PRINTABLE ANYWHERE APPEND APPEND-CHILD APPEND-LINE APPL-ALERT APPL-ALERT- + APPL-ALERT-B APPL-ALERT-BO APPL-ALERT-BOX APPL-ALERT-BOXE APPL-ALERT-BOXES APPL-CONTEXT-ID + APPLICATION APPLY APPLY-CALLBACK APPSERVER-INFO APPSERVER-PASSWORD APPSERVER-USERID ARRAY-M ARRAY-ME + ARRAY-MES ARRAY-MESS ARRAY-MESSA ARRAY-MESSAG ARRAY-MESSAGE AS ASC ASCE ASCEN ASCEND ASCENDI + ASCENDIN ASCENDING AS-CURSOR ASK-OVERWRITE ASSEMBLY ASSIGN ASYNCHRONOUS ASYNC-REQUEST-COUNT + ASYNC-REQUEST-HANDLE AT ATTACH ATTACH-DATA-SOURCE ATTACHED-PAIRLIST ATTACHMENT ATTR ATTR- + ATTRIBUTE-NAMES ATTRIBUTE-TYPE ATTR-S ATTR-SP ATTR-SPA ATTR-SPAC ATTR-SPACE AUDIT-CONTROL + AUDIT-ENABLED AUDIT-EVENT-CONTEXT AUDIT-POLICY AUTHENTICATION-FAILED AUTHORIZATION AUTO-COMP + AUTO-COMPL AUTO-COMPLE AUTO-COMPLET AUTO-COMPLETI AUTO-COMPLETIO AUTO-COMPLETION AUTO-DELETE + AUTO-DELETE-XML AUTO-ENDKEY AUTO-END-KEY AUTO-GO AUTO-IND AUTO-INDE AUTO-INDEN AUTO-INDENT AUTOMATIC + AUTO-RESIZE AUTO-RET AUTO-RETU AUTO-RETUR AUTO-RETURN AUTO-SYNCHRONIZE AUTO-VAL AUTO-VALI AUTO-VALID + AUTO-VALIDA AUTO-VALIDAT AUTO-VALIDATE AUTO-Z AUTO-ZA AUTO-ZAP AVAIL AVAILA AVAILAB AVAILABL + AVAILABLE AVAILABLE-FORMATS AVE AVER AVERA AVERAG AVERAGE AVG BACK BACKG BACKGR BACKGRO BACKGROU + BACKGROUN BACKGROUND BACKSPACE BACK-TAB BACKWARD BACKWARDS BASE64 BASE64-DECODE BASE64-ENCODE + BASE-ADE BASE-KEY BASIC-LOGGING BATCH BATCH-MODE BATCH-SIZE BEFORE-BUFFER BEFORE-H BEFORE-HI + BEFORE-HID BEFORE-HIDE BEFORE-ROWID BEFORE-TABLE BEGIN-EVENT-GROUP BEGINS BELL BETWEEN BGC BGCO + BGCOL BGCOLO BGCOLOR BIG-ENDIAN BINARY BIND BIND-WHERE BLANK BLOB BLOCK BLOCK-ITERATION-DISPLAY + BLOCK-LEV BLOCK-LEVE BLOCK-LEVEL BORDER-B BORDER-BO BORDER-BOT BORDER-BOTT BORDER-BOTTO + BORDER-BOTTOM BORDER-BOTTOM-C BORDER-BOTTOM-CH BORDER-BOTTOM-CHA BORDER-BOTTOM-CHAR + BORDER-BOTTOM-CHARS BORDER-BOTTOM-P BORDER-BOTTOM-PI BORDER-BOTTOM-PIX BORDER-BOTTOM-PIXE + BORDER-BOTTOM-PIXEL BORDER-BOTTOM-PIXELS BORDER-L BORDER-LE BORDER-LEF BORDER-LEFT BORDER-LEFT-C + BORDER-LEFT-CH BORDER-LEFT-CHA BORDER-LEFT-CHAR BORDER-LEFT-CHARS BORDER-LEFT-P BORDER-LEFT-PI + BORDER-LEFT-PIX BORDER-LEFT-PIXE BORDER-LEFT-PIXEL BORDER-LEFT-PIXELS BORDER-R BORDER-RI BORDER-RIG + BORDER-RIGH BORDER-RIGHT BORDER-RIGHT-C BORDER-RIGHT-CH BORDER-RIGHT-CHA BORDER-RIGHT-CHAR + BORDER-RIGHT-CHARS BORDER-RIGHT-P BORDER-RIGHT-PI BORDER-RIGHT-PIX BORDER-RIGHT-PIXE + BORDER-RIGHT-PIXEL BORDER-RIGHT-PIXELS BORDER-T BORDER-TO BORDER-TOP BORDER-TOP-C BORDER-TOP-CH + BORDER-TOP-CHA BORDER-TOP-CHAR BORDER-TOP-CHARS BORDER-TOP-P BORDER-TOP-PI BORDER-TOP-PIX + BORDER-TOP-PIXE BORDER-TOP-PIXEL BORDER-TOP-PIXELS BOTH BOTTOM BOTTOM-COLUMN BOX BOX-SELECT + BOX-SELECTA BOX-SELECTAB BOX-SELECTABL BOX-SELECTABLE BREAK BREAK-LINE BROWSE BROWSE-COLUMN-DATA-TYPES + BROWSE-COLUMN-FORMATS BROWSE-COLUMN-LABELS BROWSE-HEADER BTOS BUFFER BUFFER-CHARS BUFFER-COMP + BUFFER-COMPA BUFFER-COMPAR BUFFER-COMPARE BUFFER-COPY BUFFER-CREATE BUFFER-DELETE BUFFER-FIELD + BUFFER-GROUP-ID BUFFER-GROUP-NAME BUFFER-HANDLE BUFFER-LINES BUFFER-N BUFFER-NA BUFFER-NAM + BUFFER-NAME BUFFER-PARTITION-ID BUFFER-RELEAS BUFFER-RELEASE BUFFER-TENANT-ID BUFFER-TENANT-NAME + BUFFER-VALIDATE BUFFER-VALUE BUTTON BUTTONS BY BY-POINTER BY-REFERENCE BYTE BYTES-READ BYTES-WRITTEN + BY-VALUE BY-VARIANT-POINT BY-VARIANT-POINTE BY-VARIANT-POINTER CACHE CACHE-SIZE CALL CALL-NAME + CALL-TYPE CANCEL-BREAK CANCEL-BUTTON CANCELLED CANCEL-PICK CANCEL-REQUESTS CANCEL-REQUESTS-AFTER + CAN-CREA CAN-CREAT CAN-CREATE CAN-DELE CAN-DELET CAN-DELETE CAN-DO CAN-DO-DOMAIN-SUPPORT CAN-FIND + CAN-QUERY CAN-READ CAN-SET CAN-WRIT CAN-WRITE CAPS CAREFUL-PAINT CASE CASE-SEN CASE-SENS CASE-SENSI + CASE-SENSIT CASE-SENSITI CASE-SENSITIV CASE-SENSITIVE CAST CATCH CDECL CENTER CENTERE CENTERED + CHAINED CHAR CHARA CHARAC CHARACT CHARACTE CHARACTER CHARACTER_LENGTH CHARSET CHECK CHECKED + CHECK-MEM-STOMP CHILD-BUFFER CHILD-NUM CHOICES CHOOSE CHR CLASS CLASS-TYPE CLEAR CLEAR-APPL-CONTEXT + CLEAR-LOG CLEAR-SELECT CLEAR-SELECTI CLEAR-SELECTIO CLEAR-SELECTION CLEAR-SORT-ARROW + CLEAR-SORT-ARROWS CLIENT-CONNECTION-ID CLIENT-PRINCIPAL CLIENT-TTY CLIENT-TYPE CLIENT-WORKSTATION + CLIPBOARD CLOB CLONE-NODE CLOSE CLOSE-LOG CODE CODEBASE-LOCATOR CODEPAGE CODEPAGE-CONVERT COL + COLLATE COL-OF COLON COLON-ALIGN COLON-ALIGNE COLON-ALIGNED COLOR COLOR-TABLE COLUMN COLUMN-BGC + COLUMN-BGCO COLUMN-BGCOL COLUMN-BGCOLO COLUMN-BGCOLOR COLUMN-CODEPAGE COLUMN-DCOLOR COLUMN-FGC + COLUMN-FGCO COLUMN-FGCOL COLUMN-FGCOLO COLUMN-FGCOLOR COLUMN-FONT COLUMN-LAB COLUMN-LABE + COLUMN-LABEL COLUMN-LABEL-BGC COLUMN-LABEL-BGCO COLUMN-LABEL-BGCOL COLUMN-LABEL-BGCOLO + COLUMN-LABEL-BGCOLOR COLUMN-LABEL-DCOLOR COLUMN-LABEL-FGC COLUMN-LABEL-FGCO COLUMN-LABEL-FGCOL + COLUMN-LABEL-FGCOLO COLUMN-LABEL-FGCOLOR COLUMN-LABEL-FONT COLUMN-LABEL-HEIGHT-C + COLUMN-LABEL-HEIGHT-CH COLUMN-LABEL-HEIGHT-CHA COLUMN-LABEL-HEIGHT-CHAR COLUMN-LABEL-HEIGHT-CHARS + COLUMN-LABEL-HEIGHT-P COLUMN-LABEL-HEIGHT-PI COLUMN-LABEL-HEIGHT-PIX COLUMN-LABEL-HEIGHT-PIXE + COLUMN-LABEL-HEIGHT-PIXEL COLUMN-LABEL-HEIGHT-PIXELS COLUMN-MOVABLE COLUMN-OF COLUMN-PFC COLUMN-PFCO + COLUMN-PFCOL COLUMN-PFCOLO COLUMN-PFCOLOR COLUMN-READ-ONLY COLUMN-RESIZABLE COLUMNS COLUMN-SC + COLUMN-SCR COLUMN-SCRO COLUMN-SCROL COLUMN-SCROLL COLUMN-SCROLLI COLUMN-SCROLLIN COLUMN-SCROLLING + COMBO-BOX COM-HANDLE COMMAND COMPARE COMPARES COMPILE COMPILER COMPLETE COMPONENT-HANDLE + COMPONENT-SELF COM-SELF CONFIG-NAME CONNECT CONNECTED CONSTRAINED CONSTRUCTOR CONTAINER-EVENT + CONTAINS CONTENTS CONTEXT CONTEXT-HELP CONTEXT-HELP-FILE CONTEXT-HELP-ID CONTEXT-POP CONTEXT-POPU + CONTEXT-POPUP CONTROL CONTROL-BOX CONTROL-CONT CONTROL-CONTA CONTROL-CONTAI CONTROL-CONTAIN + CONTROL-CONTAINE CONTROL-CONTAINER CONTROL-FRAM CONTROL-FRAME CONVERT CONVERT-3D CONVERT-3D- + CONVERT-3D-C CONVERT-3D-CO CONVERT-3D-COL CONVERT-3D-COLO CONVERT-3D-COLOR CONVERT-3D-COLORS + CONVERT-TO-OFFS CONVERT-TO-OFFSE CONVERT-TO-OFFSET COPY COPY-DATASET COPY-LOB COPY-SAX-ATTRIBUTES + COPY-TEMP-TABLE COUNT COUNT-OF COVERAGE CPCASE CPCOLL CPINT CPINTE CPINTER CPINTERN CPINTERNA + CPINTERNAL CPLOG CPPRINT CPRCODEIN CPRCODEOUT CPSTREAM CPTERM CRC-VAL CRC-VALU CRC-VALUE CREATE + CREATE-LIKE CREATE-LIKE-SEQUENTIAL CREATE-NODE CREATE-NODE-NAMESPACE CREATE-ON-ADD + CREATE-RESULT-LIST-ENTRY CREATE-TEST-FILE CTOS CURRENT CURRENT_DATE CURRENT-CHANGED CURRENT-COLUMN + CURRENT-ENV CURRENT-ENVI CURRENT-ENVIR CURRENT-ENVIRO CURRENT-ENVIRON CURRENT-ENVIRONM + CURRENT-ENVIRONME CURRENT-ENVIRONMEN CURRENT-ENVIRONMENT CURRENT-ITERATION CURRENT-LANG + CURRENT-LANGU CURRENT-LANGUA CURRENT-LANGUAG CURRENT-LANGUAGE CURRENT-QUERY CURRENT-REQUEST-INFO + CURRENT-RESPONSE-INFO CURRENT-RESULT-ROW CURRENT-ROW-MODIFIED CURRENT-VALUE CURRENT-WINDOW CURS + CURSO CURSOR CURSOR-CHAR CURSOR-DOWN CURSOR-LEFT CURSOR-LINE CURSOR-OFFSET CURSOR-RIGHT CURSOR-UP + CUT DATA-B DATABASE DATA-BI DATA-BIN DATA-BIND DATA-ENTRY-RET DATA-ENTRY-RETU DATA-ENTRY-RETUR + DATA-ENTRY-RETURN DATA-REFRESH-LINE DATA-REFRESH-PAGE DATA-REL DATA-RELA DATA-RELAT DATA-RELATI + DATA-RELATIO DATA-RELATION DATASERVERS DATASET DATASET-HANDLE DATA-SOURCE DATA-SOURCE-COMPLETE-MAP + DATA-SOURCE-MODIFIED DATA-SOURCE-ROWID DATA-T DATA-TY DATA-TYP DATA-TYPE DATE DATE-F DATE-FO + DATE-FOR DATE-FORM DATE-FORMA DATE-FORMAT DATETIME DATETIME-TZ DAY DBCODEPAGE DBCOLLATION DB-CONTEXT + DB-LIST DBNAME DBPARAM DB-REFERENCES DB-REMOTE-HOST DBREST DBRESTR DBRESTRI DBRESTRIC DBRESTRICT + DBRESTRICTI DBRESTRICTIO DBRESTRICTION DBRESTRICTIONS DBTASKID DBTYPE DBVERS DBVERSI DBVERSIO + DBVERSION DCOLOR DDE DDE-ERROR DDE-I DDE-ID DDE-ITEM DDE-NAME DDE-NOTIFY DDE-TOPIC DEBLANK DEBU + DEBUG DEBUG-ALERT DEBUGGER DEBUG-LIST DEBUG-SET-TENANT DEC DECI DECIM DECIMA DECIMAL DECIMALS + DECLARE DECLARE-NAMESPACE DECRYPT DEF DEFAULT DEFAULT-ACTION DEFAULT-BUFFER-HANDLE DEFAULT-BUT + DEFAULT-BUTT DEFAULT-BUTTO DEFAULT-BUTTON DEFAULT-COMMIT DEFAULT-EX DEFAULT-EXT DEFAULT-EXTE + DEFAULT-EXTEN DEFAULT-EXTENS DEFAULT-EXTENSI DEFAULT-EXTENSIO DEFAULT-EXTENSION DEFAULT-NOXL + DEFAULT-NOXLA DEFAULT-NOXLAT DEFAULT-NOXLATE DEFAULT-POP-UP DEFAULT-STRING DEFAULT-VALUE + DEFAULT-WINDOW DEFAUT-B DEFER-LOB-FETCH DEFI DEFIN DEFINE DEFINED DEFINE-USER-EVENT-MANAGER DEL + DELEGATE DELETE DELETE-CHAR DELETE-CHARACTER DELETE-COLUMN DELETE-CURRENT-ROW DELETE-END-LINE + DELETE-FIELD DELETE-HEADER-ENTRY DELETE-LINE DELETE-NODE DELETE-RESULT-LIST-ENTRY + DELETE-SELECTED-ROW DELETE-SELECTED-ROWS DELETE-WORD DELIMITER DESC DESCE DESCEN DESCEND DESCENDI + DESCENDIN DESCENDING DESCRIPT DESCRIPTI DESCRIPTIO DESCRIPTION DESELECT DESELECT-EXTEND + DESELECT-FOCUSED-ROW DESELECTION DESELECTION-EXTEND DESELECT-ROWS DESELECT-SELECTED-ROW DESTRUCTOR + DETACH DETACH-DATA-SOURCE DIALOG-BOX DIALOG-HELP DICT DICTI DICTIO DICTION DICTIONA DICTIONAR + DICTIONARY DIR DIRECTORY DISABLE DISABLE-AUTO-ZAP DISABLE-CONNECTIONS DISABLED DISABLE-DUMP-TRIGGERS + DISABLE-LOAD-TRIGGERS DISCON DISCONN DISCONNE DISCONNEC DISCONNECT DISMISS-MENU DISP DISPL DISPLA + DISPLAY DISPLAY-MESSAGE DISPLAY-T DISPLAY-TIMEZONE DISPLAY-TY DISPLAY-TYP DISPLAY-TYPE DISTINCT + DLL-CALL-TYPE DO DOMAIN-DESCRIPTION DOMAIN-NAME DOMAIN-TYPE DOS DOS-END DOTNET-CLR-LOADED DOUBLE + DOWN DRAG-ENABLED DROP DROP-DOWN DROP-DOWN-LIST DROP-FILE-NOTIFY DROP-TARGET DS-CLOSE-CURSOR + DSLOG-MANAGER DUMP DUMP-LOGGING-NOW DYNAMIC DYNAMIC-CAST DYNAMIC-CURRENT-VALUE DYNAMIC-ENUM + DYNAMIC-FUNC DYNAMIC-FUNCT DYNAMIC-FUNCTI DYNAMIC-FUNCTIO DYNAMIC-FUNCTION DYNAMIC-INVOKE + DYNAMIC-NEW DYNAMIC-NEXT-VALUE DYNAMIC-PROPERTY EACH ECHO EDGE EDGE-C EDGE-CH EDGE-CHA EDGE-CHAR + EDGE-CHARS EDGE-P EDGE-PI EDGE-PIX EDGE-PIXE EDGE-PIXEL EDGE-PIXELS EDIT-CAN-PASTE EDIT-CAN-UNDO + EDIT-CLEAR EDIT-COPY EDIT-CUT EDITING EDITOR EDITOR-BACKTAB EDITOR-TAB EDIT-PASTE EDIT-UNDO ELSE + EMPTY EMPTY-DATASET EMPTY-SELECTION EMPTY-TEMP-TABLE ENABLE ENABLE-CONNECTIONS ENABLED + ENABLED-FIELDS ENCODE ENCODE-DOMAIN-ACCESS-CODE ENCODING ENCRYPT ENCRYPT-AUDIT-MAC-KEY + ENCRYPTION-SALT END END-BOX-SELECTION END-DOCUMENT END-ELEMENT END-ERROR END-EVENT-GROUP + END-FILE-DROP ENDKEY END-KEY END-MOVE END-RESIZE END-ROW-RESIZE END-SEARCH END-USER-PROMPT ENTERED + ENTER-MENUBAR ENTITY-EXPANSION-LIMIT ENTRY ENTRY-TYPES-LIST ENUM EQ ERROR ERROR-COL ERROR-COLU + ERROR-COLUM ERROR-COLUMN ERROR-OBJECT ERROR-OBJECT-DETAIL ERROR-ROW ERROR-STACK-TRACE ERROR-STAT + ERROR-STATU ERROR-STATUS ERROR-STRING ESCAPE ETIME EVENT EVENT-GROUP-ID EVENT-PROCEDURE + EVENT-PROCEDURE-CONTEXT EVENTS EVENT-T EVENT-TY EVENT-TYP EVENT-TYPE EXCEPT EXCLUSIVE EXCLUSIVE-ID + EXCLUSIVE-L EXCLUSIVE-LO EXCLUSIVE-LOC EXCLUSIVE-LOCK EXCLUSIVE-WEB EXCLUSIVE-WEB- EXCLUSIVE-WEB-U + EXCLUSIVE-WEB-US EXCLUSIVE-WEB-USE EXCLUSIVE-WEB-USER EXECUTE EXECUTION-LOG EXISTS EXIT EXIT-CODE + EXP EXPAND EXPANDABLE EXPIRE EXPLICIT EXPORT EXPORT-PRINCIPAL EXTENDED EXTENT EXTERNAL EXTRACT FALSE + FALSE-LEAKS FETCH FETCH-SELECTED-ROW FGC FGCO FGCOL FGCOLO FGCOLOR FIELD FIELDS FILE FILE-ACCESS-D + FILE-ACCESS-DA FILE-ACCESS-DAT FILE-ACCESS-DATE FILE-ACCESS-T FILE-ACCESS-TI FILE-ACCESS-TIM + FILE-ACCESS-TIME FILE-CREATE-D FILE-CREATE-DA FILE-CREATE-DAT FILE-CREATE-DATE FILE-CREATE-T + FILE-CREATE-TI FILE-CREATE-TIM FILE-CREATE-TIME FILE-INFO FILE-INFOR FILE-INFORM FILE-INFORMA + FILE-INFORMAT FILE-INFORMATI FILE-INFORMATIO FILE-INFORMATION FILE-MOD-D FILE-MOD-DA FILE-MOD-DAT + FILE-MOD-DATE FILE-MOD-T FILE-MOD-TI FILE-MOD-TIM FILE-MOD-TIME FILENAME FILE-NAME FILE-OFF + FILE-OFFS FILE-OFFSE FILE-OFFSET FILE-SIZE FILE-TYPE FILL FILLED FILL-IN FILL-MODE FILL-WHERE-STRING + FILTERS FINAL FINALLY FIND FIND-BY-ROWID FIND-CASE-SENSITIVE FIND-CURRENT FINDER FIND-FIRST + FIND-GLOBAL FIND-LAST FIND-NEXT FIND-NEXT-OCCURRENCE FIND-PREVIOUS FIND-PREV-OCCURRENCE FIND-SELECT + FIND-UNIQUE FIND-WRAP-AROUND FIREHOSE-CURSOR FIRST FIRST-ASYNC FIRST-ASYNC- FIRST-ASYNCH-REQUEST + FIRST-ASYNC-R FIRST-ASYNC-RE FIRST-ASYNC-REQ FIRST-ASYNC-REQU FIRST-ASYNC-REQUE FIRST-ASYNC-REQUES + FIRST-ASYNC-REQUEST FIRST-BUFFER FIRST-CHILD FIRST-COLUMN FIRST-DATASET FIRST-DATA-SOURCE FIRST-FORM + FIRST-OBJECT FIRST-OF FIRST-PROC FIRST-PROCE FIRST-PROCED FIRST-PROCEDU FIRST-PROCEDUR + FIRST-PROCEDURE FIRST-QUERY FIRST-SERV FIRST-SERVE FIRST-SERVER FIRST-SERVER-SOCKET FIRST-SOCKET + FIRST-TAB-I FIRST-TAB-IT FIRST-TAB-ITE FIRST-TAB-ITEM FIT-LAST-COLUMN FIX-CODEPAGE FIXED-ONLY FLAGS + FLAT-BUTTON FLOAT FOCUS FOCUSED-ROW FOCUSED-ROW-SELECTED FOCUS-IN FONT FONT-TABLE FOR FORCE-FILE + FORE FOREG FOREGR FOREGRO FOREGROU FOREGROUN FOREGROUND FOREIGN-KEY-HIDDEN FORM FORMA FORMAT + FORMATTE FORMATTED FORM-INPUT FORM-LONG-INPUT FORWARD FORWARD-ONLY FORWARDS FRAGMEN FRAGMENT FRAM + FRAME FRAME-COL FRAME-DB FRAME-DOWN FRAME-FIELD FRAME-FILE FRAME-INDE FRAME-INDEX FRAME-LINE + FRAME-NAME FRAME-ROW FRAME-SPA FRAME-SPAC FRAME-SPACI FRAME-SPACIN FRAME-SPACING FRAME-VAL + FRAME-VALU FRAME-VALUE FRAME-X FRAME-Y FREQUENCY FROM FROM-C FROM-CH FROM-CHA FROM-CHAR FROM-CHARS + FROM-CUR FROM-CURR FROM-CURRE FROM-CURREN FROM-CURRENT FROMNOREORDER FROM-P FROM-PI FROM-PIX + FROM-PIXE FROM-PIXEL FROM-PIXELS FULL-HEIGHT FULL-HEIGHT-C FULL-HEIGHT-CH FULL-HEIGHT-CHA + FULL-HEIGHT-CHAR FULL-HEIGHT-CHARS FULL-HEIGHT-P FULL-HEIGHT-PI FULL-HEIGHT-PIX FULL-HEIGHT-PIXE + FULL-HEIGHT-PIXEL FULL-HEIGHT-PIXELS FULL-PATHN FULL-PATHNA FULL-PATHNAM FULL-PATHNAME FULL-WIDTH + FULL-WIDTH- FULL-WIDTH-C FULL-WIDTH-CH FULL-WIDTH-CHA FULL-WIDTH-CHAR FULL-WIDTH-CHARS FULL-WIDTH-P + FULL-WIDTH-PI FULL-WIDTH-PIX FULL-WIDTH-PIXE FULL-WIDTH-PIXEL FULL-WIDTH-PIXELS FUNCTION + FUNCTION-CALL-TYPE GATEWAY GATEWAYS GE GENERATE-MD5 GENERATE-PBE-KEY GENERATE-PBE-SALT + GENERATE-RANDOM-KEY GENERATE-UUID GET GET-ATTR-CALL-TYPE GET-ATTRIBUTE GET-ATTRIBUTE-NODE + GET-BINARY-DATA GET-BITS GET-BLUE GET-BLUE- GET-BLUE-V GET-BLUE-VA GET-BLUE-VAL GET-BLUE-VALU + GET-BLUE-VALUE GET-BROWSE-COL GET-BROWSE-COLU GET-BROWSE-COLUM GET-BROWSE-COLUMN GET-BUFFER-HANDLE + GETBYTE GET-BYTE GET-BYTE-ORDER GET-BYTES GET-BYTES-AVAILABLE GET-CALLBACK-PROC-CONTEXT + GET-CALLBACK-PROC-NAME GET-CGI-LIST GET-CGI-LONG-VALUE GET-CGI-VALUE GET-CHANGES GET-CHILD + GET-CHILD-REL GET-CHILD-RELA GET-CHILD-RELAT GET-CHILD-RELATI GET-CHILD-RELATIO GET-CHILD-RELATION + GET-CLASS GET-CLIENT GET-CODEPAGE GET-CODEPAGES GET-COLL GET-COLLA GET-COLLAT GET-COLLATI + GET-COLLATIO GET-COLLATION GET-COLLATIONS GET-COLUMN GET-CONFIG-VALUE GET-CURR GET-CURRE GET-CURREN + GET-CURRENT GET-DATASET-BUFFER GET-DB-CLIENT GET-DIR GET-DOCUMENT-ELEMENT GET-DOUBLE + GET-DROPPED-FILE GET-DYNAMIC GET-EFFECTIVE-TENANT-ID GET-EFFECTIVE-TENANT-NAME GET-ERROR-COLUMN + GET-ERROR-ROW GET-FILE GET-FILE-NAME GET-FILE-OFFSE GET-FILE-OFFSET GET-FIRS GET-FIRST GET-FLOAT + GET-GREEN GET-GREEN- GET-GREEN-V GET-GREEN-VA GET-GREEN-VAL GET-GREEN-VALU GET-GREEN-VALUE + GET-HEADER-ENTR GET-HEADER-ENTRY GET-INDEX-BY-NAMESPACE-NAME GET-INDEX-BY-QNAME GET-INT64 + GET-ITERATION GET-KEY-VAL GET-KEY-VALU GET-KEY-VALUE GET-LAST GET-LOCALNAME-BY-INDEX GET-LONG + GET-MESSAGE GET-MESSAGE-TYPE GET-NEXT GET-NODE GET-NUMBER GET-PARENT GET-POINTER-VALUE GET-PREV + GET-PRINTERS GET-PROPERTY GET-QNAME-BY-INDEX GET-RED GET-RED- GET-RED-V GET-RED-VA GET-RED-VAL + GET-RED-VALU GET-RED-VALUE GET-REL GET-RELA GET-RELAT GET-RELATI GET-RELATIO GET-RELATION + GET-REPOSITIONED-ROW GET-RGB GET-RGB- GET-RGB-V GET-RGB-VA GET-RGB-VAL GET-RGB-VALU GET-RGB-VALUE + GET-ROW GET-SAFE-USER GET-SELECTED GET-SELECTED- GET-SELECTED-W GET-SELECTED-WI GET-SELECTED-WID + GET-SELECTED-WIDG GET-SELECTED-WIDGE GET-SELECTED-WIDGET GET-SERIALIZED GET-SHORT GET-SIGNATURE + GET-SIZE GET-SOCKET-OPTION GET-SOURCE-BUFFER GET-STRING GET-TAB-ITEM GET-TEXT-HEIGHT + GET-TEXT-HEIGHT-C GET-TEXT-HEIGHT-CH GET-TEXT-HEIGHT-CHA GET-TEXT-HEIGHT-CHAR GET-TEXT-HEIGHT-CHARS + GET-TEXT-HEIGHT-P GET-TEXT-HEIGHT-PI GET-TEXT-HEIGHT-PIX GET-TEXT-HEIGHT-PIXE GET-TEXT-HEIGHT-PIXEL + GET-TEXT-HEIGHT-PIXELS GET-TEXT-WIDTH GET-TEXT-WIDTH-C GET-TEXT-WIDTH-CH GET-TEXT-WIDTH-CHA + GET-TEXT-WIDTH-CHAR GET-TEXT-WIDTH-CHARS GET-TEXT-WIDTH-P GET-TEXT-WIDTH-PI GET-TEXT-WIDTH-PIX + GET-TEXT-WIDTH-PIXE GET-TEXT-WIDTH-PIXEL GET-TEXT-WIDTH-PIXELS GET-TOP-BUFFER GET-TYPE-BY-INDEX + GET-TYPE-BY-NAMESPACE-NAME GET-TYPE-BY-QNAME GET-UNSIGNED-LONG GET-UNSIGNED-SHORT GET-URI-BY-INDEX + GET-VALUE-BY-INDEX GET-VALUE-BY-NAMESPACE-NAME GET-VALUE-BY-QNAME GET-WAIT GET-WAIT- GET-WAIT-S + GET-WAIT-ST GET-WAIT-STA GET-WAIT-STAT GET-WAIT-STATE GLOBAL GO GO-ON GO-PEND GO-PENDI GO-PENDIN + GO-PENDING GOTO GRANT GRANT-ARCHIVE GRAPHIC-E GRAPHIC-ED GRAPHIC-EDG GRAPHIC-EDGE GRAYED + GRID-FACTOR-H GRID-FACTOR-HO GRID-FACTOR-HOR GRID-FACTOR-HORI GRID-FACTOR-HORIZ GRID-FACTOR-HORIZO + GRID-FACTOR-HORIZON GRID-FACTOR-HORIZONT GRID-FACTOR-HORIZONTA GRID-FACTOR-HORIZONTAL GRID-FACTOR-V + GRID-FACTOR-VE GRID-FACTOR-VER GRID-FACTOR-VERT GRID-FACTOR-VERTI GRID-FACTOR-VERTIC + GRID-FACTOR-VERTICA GRID-FACTOR-VERTICAL GRID-SET GRID-SNAP GRID-UNIT-HEIGHT GRID-UNIT-HEIGHT-C + GRID-UNIT-HEIGHT-CH GRID-UNIT-HEIGHT-CHA GRID-UNIT-HEIGHT-CHAR GRID-UNIT-HEIGHT-CHARS + GRID-UNIT-HEIGHT-P GRID-UNIT-HEIGHT-PI GRID-UNIT-HEIGHT-PIX GRID-UNIT-HEIGHT-PIXE + GRID-UNIT-HEIGHT-PIXEL GRID-UNIT-HEIGHT-PIXELS GRID-UNIT-WIDTH GRID-UNIT-WIDTH-C GRID-UNIT-WIDTH-CH + GRID-UNIT-WIDTH-CHA GRID-UNIT-WIDTH-CHAR GRID-UNIT-WIDTH-CHARS GRID-UNIT-WIDTH-P GRID-UNIT-WIDTH-PI + GRID-UNIT-WIDTH-PIX GRID-UNIT-WIDTH-PIXE GRID-UNIT-WIDTH-PIXEL GRID-UNIT-WIDTH-PIXELS GRID-VISIBLE + GROUP GROUP-BOX GT GUID HANDLE HANDLER HAS-LOBS HAS-RECORDS HAVING HEADER HEIGHT HEIGHT-C HEIGHT-CH + HEIGHT-CHA HEIGHT-CHAR HEIGHT-CHARS HEIGHT-P HEIGHT-PI HEIGHT-PIX HEIGHT-PIXE HEIGHT-PIXEL + HEIGHT-PIXELS HELP HELP-CON HELP-CONT HELP-CONTE HELP-CONTEX HELP-CONTEXT HELPFILE-N HELPFILE-NA + HELPFILE-NAM HELPFILE-NAME HELP-TOPIC HEX-DECODE HEX-ENCODE HIDDEN HIDE HINT HOME HORI HORIZ + HORIZ-END HORIZ-HOME HORIZO HORIZON HORIZONT HORIZONTA HORIZONTAL HORIZ-SCROLL-DRAG HOST-BYTE-ORDER + HTML-CHARSET HTML-END-OF-LINE HTML-END-OF-PAGE HTML-FRAME-BEGIN HTML-FRAME-END HTML-HEADER-BEGIN + HTML-HEADER-END HTML-TITLE-BEGIN HTML-TITLE-END HWND ICFPARAM ICFPARAME ICFPARAMET ICFPARAMETE + ICFPARAMETER ICON IF IGNORE-CURRENT-MOD IGNORE-CURRENT-MODI IGNORE-CURRENT-MODIF + IGNORE-CURRENT-MODIFI IGNORE-CURRENT-MODIFIE IGNORE-CURRENT-MODIFIED IMAGE IMAGE-DOWN + IMAGE-INSENSITIVE IMAGE-SIZE IMAGE-SIZE-C IMAGE-SIZE-CH IMAGE-SIZE-CHA IMAGE-SIZE-CHAR + IMAGE-SIZE-CHARS IMAGE-SIZE-P IMAGE-SIZE-PI IMAGE-SIZE-PIX IMAGE-SIZE-PIXE IMAGE-SIZE-PIXEL + IMAGE-SIZE-PIXELS IMAGE-UP IMMEDIATE-DISPLAY IMPLEMENTS IMPORT IMPORT-NODE IMPORT-PRINCIPAL IN + INCREMENT-EXCLUSIVE-ID INDEX INDEXED-REPOSITION INDEX-HINT INDEX-INFO INDEX-INFOR INDEX-INFORM + INDEX-INFORMA INDEX-INFORMAT INDEX-INFORMATI INDEX-INFORMATIO INDEX-INFORMATION INDICATOR INFO INFOR + INFORM INFORMA INFORMAT INFORMATI INFORMATIO INFORMATION IN-HANDLE INHERIT-BGC INHERIT-BGCO + INHERIT-BGCOL INHERIT-BGCOLO INHERIT-BGCOLOR INHERIT-COLOR-MODE INHERIT-FGC INHERIT-FGCO + INHERIT-FGCOL INHERIT-FGCOLO INHERIT-FGCOLOR INHERITS INIT INITIAL INITIAL-DIR INITIAL-FILTER + INITIALIZE INITIALIZE-DOCUMENT-TYPE INITIATE INNER INNER-CHARS INNER-LINES INPUT INPUT-O INPUT-OU + INPUT-OUT INPUT-OUTP INPUT-OUTPU INPUT-OUTPUT INPUT-VALUE INSERT INSERT-ATTRIBUTE INSERT-B INSERT-BA + INSERT-BAC INSERT-BACK INSERT-BACKT INSERT-BACKTA INSERT-BACKTAB INSERT-BEFORE INSERT-COLUMN + INSERT-FIELD INSERT-FIELD-DATA INSERT-FIELD-LABEL INSERT-FILE INSERT-MODE INSERT-ROW INSERT-STRING + INSERT-T INSERT-TA INSERT-TAB INSTANTIATING-PROCEDURE INT INT64 INTE INTEG INTEGE INTEGER INTERFACE + INTERNAL-ENTRIES INTERVAL INTO INVOKE IS IS-ATTR IS-ATTR- IS-ATTR-S IS-ATTR-SP IS-ATTR-SPA + IS-ATTR-SPAC IS-ATTR-SPACE IS-CLAS IS-CLASS IS-CODEPAGE-FIXED IS-COLUMN-CODEPAGE IS-DB-MULTI-TENANT + IS-JSON IS-LEAD-BYTE IS-MULTI-TENANT ISO-DATE IS-OPEN IS-PARAMETER-SET IS-PARTITIONE IS-PARTITIONED + IS-ROW-SELECTED IS-SELECTED IS-XML ITEM ITEMS-PER-ROW ITERATION-CHANGED JOIN JOIN-BY-SQLDB + JOIN-ON-SELECT KBLABEL KEEP-CONNECTION-OPEN KEEP-FRAME-Z KEEP-FRAME-Z- KEEP-FRAME-Z-O + KEEP-FRAME-Z-OR KEEP-FRAME-Z-ORD KEEP-FRAME-Z-ORDE KEEP-FRAME-Z-ORDER KEEP-MESSAGES + KEEP-SECURITY-CACHE KEEP-TAB-ORDER KEY KEYCACHE-JOIN KEYCODE KEY-CODE KEYFUNC KEY-FUNC KEYFUNCT + KEY-FUNCT KEYFUNCTI KEY-FUNCTI KEYFUNCTIO KEY-FUNCTIO KEYFUNCTION KEY-FUNCTION KEYLABEL KEY-LABEL + KEYS KEYWORD KEYWORD-ALL LABEL LABEL-BGC LABEL-BGCO LABEL-BGCOL LABEL-BGCOLO LABEL-BGCOLOR LABEL-DC + LABEL-DCO LABEL-DCOL LABEL-DCOLO LABEL-DCOLOR LABEL-FGC LABEL-FGCO LABEL-FGCOL LABEL-FGCOLO + LABEL-FGCOLOR LABEL-FONT LABEL-PFC LABEL-PFCO LABEL-PFCOL LABEL-PFCOLO LABEL-PFCOLOR LABELS + LABELS-HAVE-COLONS LANDSCAPE LANGUAGE LANGUAGES LARGE LARGE-TO-SMALL LAST LAST-ASYNC LAST-ASYNC- + LAST-ASYNCH-REQUEST LAST-ASYNC-R LAST-ASYNC-RE LAST-ASYNC-REQ LAST-ASYNC-REQU LAST-ASYNC-REQUE + LAST-ASYNC-REQUES LAST-ASYNC-REQUEST LAST-BATCH LAST-CHILD LAST-EVEN LAST-EVENT LAST-FORM LASTKEY + LAST-KEY LAST-OBJECT LAST-OF LAST-PROCE LAST-PROCED LAST-PROCEDU LAST-PROCEDUR LAST-PROCEDURE + LAST-SERV LAST-SERVE LAST-SERVER LAST-SERVER-SOCKET LAST-SOCKET LAST-TAB-I LAST-TAB-IT LAST-TAB-ITE + LAST-TAB-ITEM LC LDBNAME LE LEADING LEAK-DETECTION LEAVE LEFT LEFT-ALIGN LEFT-ALIGNE LEFT-ALIGNED + LEFT-END LEFT-TRIM LENGTH LIBRARY LIBRARY-CALLING-CONVENTION LIKE LIKE-SEQUENTIAL LINE LINE-COUNT + LINE-COUNTE LINE-COUNTER LINE-DOWN LINE-LEFT LINE-RIGHT LINE-UP LIST-EVENTS LISTI LISTIN LISTING + LISTINGS LIST-ITEM-PAIRS LIST-ITEMS LIST-PROPERTY-NAMES LIST-QUERY-ATTRS LIST-SET-ATTRS LIST-WIDGETS + LITERAL-QUESTION LITTLE-ENDIAN LOAD LOAD-DOMAINS LOAD-FROM LOAD-ICON LOAD-IMAGE LOAD-IMAGE-DOWN + LOAD-IMAGE-INSENSITIVE LOAD-IMAGE-UP LOAD-MOUSE-P LOAD-MOUSE-PO LOAD-MOUSE-POI LOAD-MOUSE-POIN + LOAD-MOUSE-POINT LOAD-MOUSE-POINTE LOAD-MOUSE-POINTER LOAD-PICTURE LOAD-RESULT-INTO LOAD-SMALL-ICON + LOB-DIR LOCAL-HOST LOCAL-NAME LOCAL-PORT LOCAL-VERSION-INFO LOCATOR-COLUMN-NUMBER + LOCATOR-LINE-NUMBER LOCATOR-PUBLIC-ID LOCATOR-SYSTEM-ID LOCATOR-TYPE LOCKED LOCK-REGISTRATION LOG + LOG-AUDIT-EVENT LOG-ENTRY-TYPES LOGFILE-NAME LOGGING-LEVEL LOGICAL LOG-ID LOGIN-EXPIRATION-TIMESTAMP + LOGIN-HOST LOGIN-STATE LOG-MANAGER LOGOUT LOG-THRESHOLD LONG LONGCH LONGCHA LONGCHAR + LONGCHAR-TO-NODE-VALUE LOOKAHEAD LOOKUP LOWER LT MACHINE-CLASS MAIN-MENU MANDATORY MANUAL-HIGHLIGHT + MAP MARGIN-EXTRA MARGIN-HEIGHT MARGIN-HEIGHT-C MARGIN-HEIGHT-CH MARGIN-HEIGHT-CHA MARGIN-HEIGHT-CHAR + MARGIN-HEIGHT-CHARS MARGIN-HEIGHT-P MARGIN-HEIGHT-PI MARGIN-HEIGHT-PIX MARGIN-HEIGHT-PIXE + MARGIN-HEIGHT-PIXEL MARGIN-HEIGHT-PIXELS MARGIN-WIDTH MARGIN-WIDTH-C MARGIN-WIDTH-CH + MARGIN-WIDTH-CHA MARGIN-WIDTH-CHAR MARGIN-WIDTH-CHARS MARGIN-WIDTH-P MARGIN-WIDTH-PI + MARGIN-WIDTH-PIX MARGIN-WIDTH-PIXE MARGIN-WIDTH-PIXEL MARGIN-WIDTH-PIXELS MARK-NEW MARK-ROW-STATE + MATCHES MAX MAX-BUTTON MAX-CHARS MAX-DATA-GUESS MAX-HEIGHT MAX-HEIGHT-C MAX-HEIGHT-CH MAX-HEIGHT-CHA + MAX-HEIGHT-CHAR MAX-HEIGHT-CHARS MAX-HEIGHT-P MAX-HEIGHT-PI MAX-HEIGHT-PIX MAX-HEIGHT-PIXE + MAX-HEIGHT-PIXEL MAX-HEIGHT-PIXELS MAXIMIZE MAXIMUM MAXIMUM-LEVEL MAX-ROWS MAX-SIZE MAX-VAL MAX-VALU + MAX-VALUE MAX-WIDTH MAX-WIDTH-C MAX-WIDTH-CH MAX-WIDTH-CHA MAX-WIDTH-CHAR MAX-WIDTH-CHARS + MAX-WIDTH-P MAX-WIDTH-PI MAX-WIDTH-PIX MAX-WIDTH-PIXE MAX-WIDTH-PIXEL MAX-WIDTH-PIXELS MD5-DIGEST + MD5-VALUE MEMBER MEMPTR MEMPTR-TO-NODE-VALUE MENU MENUBAR MENU-BAR MENU-DROP MENU-ITEM MENU-K + MENU-KE MENU-KEY MENU-M MENU-MO MENU-MOU MENU-MOUS MENU-MOUSE MERGE-BY-FIELD MERGE-CHANGES + MERGE-ROW-CHANGES MESSAGE MESSAGE-AREA MESSAGE-AREA-FONT MESSAGE-AREA-MSG MESSAGE-DIGEST + MESSAGE-LINE MESSAGE-LINES METHOD MIN MIN-BUTTON MIN-COLUMN-WIDTH-C MIN-COLUMN-WIDTH-CH + MIN-COLUMN-WIDTH-CHA MIN-COLUMN-WIDTH-CHAR MIN-COLUMN-WIDTH-CHARS MIN-COLUMN-WIDTH-P + MIN-COLUMN-WIDTH-PI MIN-COLUMN-WIDTH-PIX MIN-COLUMN-WIDTH-PIXE MIN-COLUMN-WIDTH-PIXEL + MIN-COLUMN-WIDTH-PIXELS MIN-HEIGHT MIN-HEIGHT-C MIN-HEIGHT-CH MIN-HEIGHT-CHA MIN-HEIGHT-CHAR + MIN-HEIGHT-CHARS MIN-HEIGHT-P MIN-HEIGHT-PI MIN-HEIGHT-PIX MIN-HEIGHT-PIXE MIN-HEIGHT-PIXEL + MIN-HEIGHT-PIXELS MINI MINIM MINIMU MINIMUM MIN-SCHEMA-MARSHAL MIN-SCHEMA-MARSHALL MIN-SIZE MIN-VAL + MIN-VALU MIN-VALUE MIN-WIDTH MIN-WIDTH-C MIN-WIDTH-CH MIN-WIDTH-CHA MIN-WIDTH-CHAR MIN-WIDTH-CHARS + MIN-WIDTH-P MIN-WIDTH-PI MIN-WIDTH-PIX MIN-WIDTH-PIXE MIN-WIDTH-PIXEL MIN-WIDTH-PIXELS MOD MODIFIED + MODULO MONTH MOUSE MOUSE-P MOUSE-PO MOUSE-POI MOUSE-POIN MOUSE-POINT MOUSE-POINTE MOUSE-POINTER + MOVABLE MOVE MOVE-AFTER MOVE-AFTER- MOVE-AFTER-T MOVE-AFTER-TA MOVE-AFTER-TAB MOVE-AFTER-TAB- + MOVE-AFTER-TAB-I MOVE-AFTER-TAB-IT MOVE-AFTER-TAB-ITE MOVE-AFTER-TAB-ITEM MOVE-BEFOR MOVE-BEFORE + MOVE-BEFORE- MOVE-BEFORE-T MOVE-BEFORE-TA MOVE-BEFORE-TAB MOVE-BEFORE-TAB- MOVE-BEFORE-TAB-I + MOVE-BEFORE-TAB-IT MOVE-BEFORE-TAB-ITE MOVE-BEFORE-TAB-ITEM MOVE-COL MOVE-COLU MOVE-COLUM + MOVE-COLUMN MOVE-TO-B MOVE-TO-BO MOVE-TO-BOT MOVE-TO-BOTT MOVE-TO-BOTTO MOVE-TO-BOTTOM MOVE-TO-EOF + MOVE-TO-T MOVE-TO-TO MOVE-TO-TOP MPE MTIME MULTI-COMPILE MULTIPLE MULTIPLE-KEY MULTITASKING-INTERVAL + MUST-EXIST MUST-UNDERSTAND NAME NAMESPACE-PREFIX NAMESPACE-URI NATIVE NE NEEDS-APPSERVER-PROMPT + NEEDS-PROMPT NESTED NEW NEW-INSTANCE NEW-LINE NEW-ROW NEXT NEXT-COL NEXT-COLU NEXT-COLUM NEXT-COLUMN + NEXT-ERROR NEXT-FRAME NEXT-PROMPT NEXT-ROWID NEXT-SIBLING NEXT-TAB-I NEXT-TAB-ITE NEXT-TAB-ITEM + NEXT-VALUE NEXT-WORD NO NO-APPLY NO-ARRAY-M NO-ARRAY-ME NO-ARRAY-MES NO-ARRAY-MESS NO-ARRAY-MESSA + NO-ARRAY-MESSAG NO-ARRAY-MESSAGE NO-ASSIGN NO-ATTR NO-ATTR-L NO-ATTR-LI NO-ATTR-LIS NO-ATTR-LIST + NO-ATTR-S NO-ATTR-SP NO-ATTR-SPA NO-ATTR-SPAC NO-ATTR-SPACE NO-AUTO-TRI NO-AUTO-TRIM + NO-AUTO-VALIDATE NO-BIND-WHERE NO-BOX NO-COLUMN-SC NO-COLUMN-SCR NO-COLUMN-SCRO NO-COLUMN-SCROL + NO-COLUMN-SCROLL NO-COLUMN-SCROLLI NO-COLUMN-SCROLLIN NO-COLUMN-SCROLLING NO-CONSOLE NO-CONVERT + NO-CONVERT-3D NO-CONVERT-3D- NO-CONVERT-3D-C NO-CONVERT-3D-CO NO-CONVERT-3D-COL NO-CONVERT-3D-COLO + NO-CONVERT-3D-COLOR NO-CONVERT-3D-COLORS NO-CURRENT-VALUE NO-DEBUG NODE-TYPE NODE-VALUE + NODE-VALUE-TO-LONGCHAR NODE-VALUE-TO-MEMPTR NO-DRAG NO-ECHO NO-EMPTY-SPACE NO-ERROR NO-F NO-FI + NO-FIL NO-FILL NO-FIREHOSE-CURSOR NO-FOCUS NO-HELP NO-HIDE NO-INDEX-HINT NO-INHERIT-BGC + NO-INHERIT-BGCO NO-INHERIT-BGCOL NO-INHERIT-BGCOLO NO-INHERIT-BGCOLOR NO-INHERIT-FGC NO-INHERIT-FGCO + NO-INHERIT-FGCOL NO-INHERIT-FGCOLO NO-INHERIT-FGCOLOR NO-JOIN-BY-SQLDB NO-KEYCACHE-JOIN NO-LABEL + NO-LABELS NO-LOBS NO-LOCK NO-LOOKAHEAD NO-MAP NO-MES NO-MESS NO-MESSA NO-MESSAG NO-MESSAGE + NONAMESPACE-SCHEMA-LOCATION NONE NON-SERIALIZABLE NO-PAUSE NO-PREFE NO-PREFET NO-PREFETC NO-PREFETCH + NO-QUERY-O NO-QUERY-OR NO-QUERY-ORD NO-QUERY-ORDE NO-QUERY-ORDER NO-QUERY-ORDER- NO-QUERY-ORDER-A + NO-QUERY-ORDER-AD NO-QUERY-ORDER-ADD NO-QUERY-ORDER-ADDE NO-QUERY-ORDER-ADDED NO-QUERY-U NO-QUERY-UN + NO-QUERY-UNI NO-QUERY-UNIQ NO-QUERY-UNIQU NO-QUERY-UNIQUE NO-QUERY-UNIQUE- NO-QUERY-UNIQUE-A + NO-QUERY-UNIQUE-AD NO-QUERY-UNIQUE-ADD NO-QUERY-UNIQUE-ADDE NO-QUERY-UNIQUE-ADDED NO-RETURN-VAL + NO-RETURN-VALU NO-RETURN-VALUE NORMALIZE NO-ROW-MARKERS NO-SCHEMA-MARSHAL NO-SCHEMA-MARSHALL + NO-SCROLLBAR-V NO-SCROLLBAR-VE NO-SCROLLBAR-VER NO-SCROLLBAR-VERT NO-SCROLLBAR-VERTI + NO-SCROLLBAR-VERTIC NO-SCROLLBAR-VERTICA NO-SCROLLBAR-VERTICAL NO-SCROLLING NO-SEPARATE-CONNECTION + NO-SEPARATORS NOT NO-TAB NO-TAB- NO-TAB-S NO-TAB-ST NO-TAB-STO NO-TAB-STOP NOT-ACTIVE NO-UND NO-UNDE + NO-UNDER NO-UNDERL NO-UNDERLI NO-UNDERLIN NO-UNDERLINE NO-UNDO NO-VAL NO-VALI NO-VALID NO-VALIDA + NO-VALIDAT NO-VALIDATE NOW NO-WAIT NO-WORD-WRAP NULL NUM-ALI NUM-ALIA NUM-ALIAS NUM-ALIASE + NUM-ALIASES NUM-BUFFERS NUM-BUT NUM-BUTT NUM-BUTTO NUM-BUTTON NUM-BUTTONS NUM-CHILD-RELATIONS + NUM-CHILDREN NUM-COL NUM-COLU NUM-COLUM NUM-COLUMN NUM-COLUMNS NUM-COPIES NUM-DBS NUM-DROPPED-FILES + NUM-ENTRIES NUMERIC NUMERIC-DEC NUMERIC-DECI NUMERIC-DECIM NUMERIC-DECIMA NUMERIC-DECIMAL + NUMERIC-DECIMAL- NUMERIC-DECIMAL-P NUMERIC-DECIMAL-PO NUMERIC-DECIMAL-POI NUMERIC-DECIMAL-POIN + NUMERIC-DECIMAL-POINT NUMERIC-F NUMERIC-FO NUMERIC-FOR NUMERIC-FORM NUMERIC-FORMA NUMERIC-FORMAT + NUMERIC-SEP NUMERIC-SEPA NUMERIC-SEPAR NUMERIC-SEPARA NUMERIC-SEPARAT NUMERIC-SEPARATO + NUMERIC-SEPARATOR NUM-FIELDS NUM-FORMATS NUM-HEADER-ENTRIES NUM-ITEMS NUM-ITERATIONS NUM-LINES + NUM-LOCKED-COL NUM-LOCKED-COLU NUM-LOCKED-COLUM NUM-LOCKED-COLUMN NUM-LOCKED-COLUMNS NUM-LOG-FILES + NUM-MESSAGES NUM-PARAMETERS NUM-REFERENCES NUM-RELATIONS NUM-REPL NUM-REPLA NUM-REPLAC NUM-REPLACE + NUM-REPLACED NUM-RESULTS NUM-SELECTED NUM-SELECTED-ROWS NUM-SELECTED-WIDGETS NUM-SOURCE-BUFFERS + NUM-TABS NUM-TOP-BUFFERS NUM-TO-RETAIN NUM-VISIBLE-COL NUM-VISIBLE-COLU NUM-VISIBLE-COLUM + NUM-VISIBLE-COLUMN NUM-VISIBLE-COLUMNS OBJECT OCTET_LENGTH OCTET-LENGTH OF OFF OFF-END OFF-HOME OK + OK-CANCEL OLD OLE-INVOKE-LOCA OLE-INVOKE-LOCAL OLE-INVOKE-LOCALE OLE-NAMES-LOCA OLE-NAMES-LOCAL + OLE-NAMES-LOCALE ON ON-FRAME ON-FRAME- ON-FRAME-B ON-FRAME-BO ON-FRAME-BOR ON-FRAME-BORD + ON-FRAME-BORDE ON-FRAME-BORDER OPEN OPEN-LINE-ABOVE OPSYS OPTION OPTIONS OPTIONS-FILE OR + ORDERED-JOIN ORDINAL ORIENTATION ORIGIN-HANDLE ORIGIN-ROWID OS2 OS400 OS-APPEND OS-COMMAND OS-COPY + OS-CREATE-DIR OS-DELETE OS-DIR OS-DRIVE OS-DRIVES OS-ERROR OS-GETENV OS-RENAME OTHERWISE OUTER + OUTER-JOIN OUT-OF-DATA OUTPUT OVERLAY OVERRIDE OWNER OWNER-DOCUMENT PACKAGE-PRIVATE + PACKAGE-PROTECTED PAGE PAGE-BOT PAGE-BOTT PAGE-BOTTO PAGE-BOTTOM PAGED PAGE-DOWN PAGE-LEFT PAGE-NUM + PAGE-NUMB PAGE-NUMBE PAGE-NUMBER PAGE-RIGHT PAGE-RIGHT-TEXT PAGE-SIZE PAGE-TOP PAGE-UP PAGE-WID + PAGE-WIDT PAGE-WIDTH PARAM PARAME PARAMET PARAMETE PARAMETER PARENT PARENT-BUFFER + PARENT-FIELDS-AFTER PARENT-FIELDS-BEFORE PARENT-ID-FIELD PARENT-ID-RELATION PARENT-REL PARENT-RELA + PARENT-RELAT PARENT-RELATI PARENT-RELATIO PARENT-RELATION PARENT-WINDOW-CLOSE PARSE-STATUS + PARTIAL-KEY PASCAL PASSWORD-FIELD PASTE PATHNAME PAUSE PBE-HASH-ALG PBE-HASH-ALGO PBE-HASH-ALGOR + PBE-HASH-ALGORI PBE-HASH-ALGORIT PBE-HASH-ALGORITH PBE-HASH-ALGORITHM PBE-KEY-ROUNDS PDBNAME PERF + PERFO PERFOR PERFORM PERFORMA PERFORMAN PERFORMANC PERFORMANCE PERSIST PERSISTE PERSISTEN PERSISTENT + PERSISTENT-CACHE-DISABLED PERSISTENT-PROCEDURE PFC PFCO PFCOL PFCOLO PFCOLOR PICK PICK-AREA + PICK-BOTH PIXELS PIXELS-PER-COL PIXELS-PER-COLU PIXELS-PER-COLUM PIXELS-PER-COLUMN PIXELS-PER-ROW + POPUP-M POPUP-ME POPUP-MEN POPUP-MENU POPUP-O POPUP-ON POPUP-ONL POPUP-ONLY PORTRAIT POSITION + PRECISION PREFER-DATASET PREPARED PREPARE-STRING PREPROC PREPROCE PREPROCES PREPROCESS PRESEL + PRESELE PRESELEC PRESELECT PREV PREV-COL PREV-COLU PREV-COLUM PREV-COLUMN PREV-FRAME PREV-SIBLING + PREV-TAB-I PREV-TAB-IT PREV-TAB-ITE PREV-TAB-ITEM PREV-WORD PRIMARY PRIMARY-PASSPHRASE PRINTER + PRINTER-CONTROL-HANDLE PRINTER-HDC PRINTER-NAME PRINTER-PORT PRINTER-SETUP PRIVATE PRIVATE-D + PRIVATE-DA PRIVATE-DAT PRIVATE-DATA PRIVILEGES PROCE PROCED PROCEDU PROCEDUR PROCEDURE + PROCEDURE-CALL-TYPE PROCEDURE-COMPLETE PROCEDURE-NAME PROCEDURE-TYPE PROCESS PROCESS-ARCHITECTURE + PROC-HA PROC-HAN PROC-HAND PROC-HANDL PROC-HANDLE PROC-ST PROC-STA PROC-STAT PROC-STATU PROC-STATUS + PROC-TEXT PROC-TEXT-BUFFER PROFILE-FILE PROFILER PROFILING PROGRAM-NAME PROGRESS PROGRESS-S + PROGRESS-SO PROGRESS-SOU PROGRESS-SOUR PROGRESS-SOURC PROGRESS-SOURCE PROMPT PROMPT-F PROMPT-FO + PROMPT-FOR PROMSGS PROPATH PROPERTY PROTECTED PROVERS PROVERSI PROVERSIO PROVERSION PROXY + PROXY-PASSWORD PROXY-USERID PUBLIC PUBLIC-ID PUBLISH PUBLISHED-EVENTS PUT PUT-BITS PUTBYTE PUT-BYTE + PUT-BYTES PUT-DOUBLE PUT-FLOAT PUT-INT64 PUT-KEY-VAL PUT-KEY-VALU PUT-KEY-VALUE PUT-LONG PUT-SHORT + PUT-STRING PUT-UNSIGNED-LONG PUT-UNSIGNED-SHORT QUALIFIED-USER-ID QUERY QUERY-CLOSE QUERY-OFF-END + QUERY-OPEN QUERY-PREPARE QUERY-TUNING QUESTION QUIT QUOTER RADIO-BUTTONS RADIO-SET RANDOM RAW + RAW-TRANSFER RCODE-INFO RCODE-INFOR RCODE-INFORM RCODE-INFORMA RCODE-INFORMAT RCODE-INFORMATI + RCODE-INFORMATIO RCODE-INFORMATION READ READ-AVAILABLE READ-EXACT-NUM READ-FILE READ-JSON READKEY + READ-ONLY READ-RESPONSE READ-XML READ-XMLSCHEMA REAL RECALL RECID RECORD-LEN RECORD-LENG + RECORD-LENGT RECORD-LENGTH RECT RECTA RECTAN RECTANG RECTANGL RECTANGLE RECURSIVE REFERENCE-ONLY + REFRESH REFRESHABLE REFRESH-AUDIT-POLICY REGISTER-DOMAIN REINSTATE REJECT-CHANGES REJECTED + REJECT-ROW-CHANGES RELATION-FI RELATION-FIE RELATION-FIEL RELATION-FIELD RELATION-FIELDS + RELATIONS-ACTIVE RELEASE REMOTE REMOTE-HOST REMOTE-PORT REMOVE-ATTRIBUTE REMOVE-CHILD + REMOVE-EVENTS-PROC REMOVE-EVENTS-PROCE REMOVE-EVENTS-PROCED REMOVE-EVENTS-PROCEDU + REMOVE-EVENTS-PROCEDUR REMOVE-EVENTS-PROCEDURE REMOVE-SUPER-PROC REMOVE-SUPER-PROCE + REMOVE-SUPER-PROCED REMOVE-SUPER-PROCEDU REMOVE-SUPER-PROCEDUR REMOVE-SUPER-PROCEDURE REPEAT REPLACE + REPLACE-CHILD REPLACE-SELECTION-TEXT REPLICATION-CREATE REPLICATION-DELETE REPLICATION-WRITE REPORTS + REPOSITION REPOSITION-BACK REPOSITION-BACKW REPOSITION-BACKWA REPOSITION-BACKWAR REPOSITION-BACKWARD + REPOSITION-BACKWARDS REPOSITION-FORW REPOSITION-FORWA REPOSITION-FORWAR REPOSITION-FORWARD + REPOSITION-FORWARDS REPOSITION-MODE REPOSITION-PARENT-REL REPOSITION-PARENT-RELA + REPOSITION-PARENT-RELAT REPOSITION-PARENT-RELATI REPOSITION-PARENT-RELATIO REPOSITION-PARENT-RELATION + REPOSITION-TO-ROW REPOSITION-TO-ROWID REQUEST REQUEST-INFO RESET RESIZA RESIZAB RESIZABL RESIZABLE + RESIZE RESPONSE-INFO RESTART-ROW RESTART-ROWID RESULT RESUME-DISPLAY RETAIN RETAIN-S RETAIN-SH + RETAIN-SHA RETAIN-SHAP RETAIN-SHAPE RETRY RETRY-CANCEL RETURN RETURN-ALIGN RETURN-INS RETURN-INSE + RETURN-INSER RETURN-INSERT RETURN-INSERTE RETURN-INSERTED RETURNS RETURN-TO-START-DI + RETURN-TO-START-DIR RETURN-VAL RETURN-VALU RETURN-VALUE RETURN-VALUE-DATA-TYPE RETURN-VALUE-DLL-TYPE + REVERSE-FROM REVERT REVOKE RGB-V RGB-VA RGB-VAL RGB-VALU RGB-VALUE RIGHT RIGHT-ALIGN RIGHT-ALIGNE + RIGHT-ALIGNED RIGHT-END RIGHT-TRIM R-INDEX ROLE ROLES ROUND ROUNDED ROUTINE-LEVEL ROW ROW-CREATED + ROW-DELETED ROW-DISPLAY ROW-ENTRY ROW-HEIGHT ROW-HEIGHT-C ROW-HEIGHT-CH ROW-HEIGHT-CHA + ROW-HEIGHT-CHAR ROW-HEIGHT-CHARS ROW-HEIGHT-P ROW-HEIGHT-PI ROW-HEIGHT-PIX ROW-HEIGHT-PIXE + ROW-HEIGHT-PIXEL ROW-HEIGHT-PIXELS ROWID ROW-LEAVE ROW-MA ROW-MAR ROW-MARK ROW-MARKE ROW-MARKER + ROW-MARKERS ROW-MODIFIED ROW-OF ROW-RESIZABLE ROW-STATE ROW-UNMODIFIED RULE RULE-ROW RULE-Y RUN + RUN-PROC RUN-PROCE RUN-PROCED RUN-PROCEDU RUN-PROCEDUR RUN-PROCEDURE SAVE SAVE-AS SAVE-FILE + SAVE-ROW-CHANGES SAVE-WHERE-STRING SAX-ATTRIBUTES SAX-COMPLE SAX-COMPLET SAX-COMPLETE SAX-PARSE + SAX-PARSE-FIRST SAX-PARSE-NEXT SAX-PARSER-ERROR SAX-READER SAX-RUNNING SAX-UNINITIALIZED + SAX-WRITE-BEGIN SAX-WRITE-COMPLETE SAX-WRITE-CONTENT SAX-WRITE-ELEMENT SAX-WRITE-ERROR + SAX-WRITE-IDLE SAX-WRITER SAX-WRITE-TAG SAX-XML SCHEMA SCHEMA-CHANGE SCHEMA-LOCATION SCHEMA-MARSHAL + SCHEMA-PATH SCREEN SCREEN-IO SCREEN-LINES SCREEN-VAL SCREEN-VALU SCREEN-VALUE SCROLL SCROLLABLE + SCROLLBAR-DRAG SCROLLBAR-H SCROLLBAR-HO SCROLLBAR-HOR SCROLLBAR-HORI SCROLLBAR-HORIZ + SCROLLBAR-HORIZO SCROLLBAR-HORIZON SCROLLBAR-HORIZONT SCROLLBAR-HORIZONTA SCROLLBAR-HORIZONTAL + SCROLL-BARS SCROLLBAR-V SCROLLBAR-VE SCROLLBAR-VER SCROLLBAR-VERT SCROLLBAR-VERTI SCROLLBAR-VERTIC + SCROLLBAR-VERTICA SCROLLBAR-VERTICAL SCROLL-DELTA SCROLLED-ROW-POS SCROLLED-ROW-POSI + SCROLLED-ROW-POSIT SCROLLED-ROW-POSITI SCROLLED-ROW-POSITIO SCROLLED-ROW-POSITION SCROLL-HORIZONTAL + SCROLLING SCROLL-LEFT SCROLL-MODE SCROLL-NOTIFY SCROLL-OFFSET SCROLL-RIGHT SCROLL-TO-CURRENT-ROW + SCROLL-TO-I SCROLL-TO-IT SCROLL-TO-ITE SCROLL-TO-ITEM SCROLL-TO-SELECTED-ROW SCROLL-VERTICAL SDBNAME + SEAL SEAL-TIMESTAMP SEARCH SEARCH-SELF SEARCH-TARGER SEARCH-TARGET SECTION SECURITY-POLICY SEEK + SELECT SELECTABLE SELECT-ALL SELECTED SELECTED-ITEMS SELECT-EXTEND SELECT-FOCUSED-ROW SELECTION + SELECTION-END SELECTION-EXTEND SELECTION-LIST SELECTION-START SELECTION-TEXT SELECT-NEXT-ROW + SELECT-ON-JOIN SELECT-PREV-ROW SELECT-REPOSITIONED-ROW SELECT-ROW SELF SEND SEND-SQL + SEND-SQL-STATEMENT SENSITIVE SEPARATE-CONNECTION SEPARATOR-FGC SEPARATOR-FGCO SEPARATOR-FGCOL + SEPARATOR-FGCOLO SEPARATOR-FGCOLOR SEPARATORS SERIALIZABLE SERIALIZE-HIDDEN SERIALIZE-NAME + SERIALIZE-ROW SERVER SERVER-CONNECTION-BO SERVER-CONNECTION-BOU SERVER-CONNECTION-BOUN + SERVER-CONNECTION-BOUND SERVER-CONNECTION-BOUND-RE SERVER-CONNECTION-BOUND-REQ SERVER-CONNECTION-BOUND-REQU + SERVER-CONNECTION-BOUND-REQUE SERVER-CONNECTION-BOUND-REQUES SERVER-CONNECTION-BOUND-REQUEST + SERVER-CONNECTION-CO SERVER-CONNECTION-CON SERVER-CONNECTION-CONT SERVER-CONNECTION-CONTE + SERVER-CONNECTION-CONTEX SERVER-CONNECTION-CONTEXT SERVER-CONNECTION-ID SERVER-OPERATING-MODE + SERVER-SOCKET SESSION SESSION-END SESSION-ID SET SET-ACTOR SET-APPL-CONTEXT SET-ATTR-CALL-TYPE + SET-ATTRIBUTE SET-ATTRIBUTE-NODE SET-BLUE SET-BLUE- SET-BLUE-V SET-BLUE-VA SET-BLUE-VAL + SET-BLUE-VALU SET-BLUE-VALUE SET-BREAK SET-BUFFERS SET-BYTE-ORDER SET-CALLBACK SET-CALLBACK-PROCEDURE + SET-CELL-FOCUS SET-CLIENT SET-COMMIT SET-CONNECT-PROCEDURE SET-CONTENTS SET-CURRENT-VALUE + SET-DB-CLIENT SET-DB-LOGGING SET-DYNAMIC SET-EFFECTIVE-TENANT SET-EVENT-MANAGER-OPTION SET-GREEN + SET-GREEN- SET-GREEN-V SET-GREEN-VA SET-GREEN-VAL SET-GREEN-VALU SET-GREEN-VALUE SET-INPUT-SOURCE + SET-MUST-UNDERSTAND SET-NODE SET-NUMERIC-FORM SET-NUMERIC-FORMA SET-NUMERIC-FORMAT SET-OPTION + SET-OUTPUT-DESTINATION SET-PARAMETER SET-POINTER-VAL SET-POINTER-VALU SET-POINTER-VALUE SET-PROPERTY + SET-READ-RESPONSE-PROCEDURE SET-RED SET-RED- SET-RED-V SET-RED-VA SET-RED-VAL SET-RED-VALU + SET-RED-VALUE SET-REPOSITIONED-ROW SET-RGB SET-RGB- SET-RGB-V SET-RGB-VA SET-RGB-VAL SET-RGB-VALU + SET-RGB-VALUE SET-ROLE SET-ROLLBACK SET-SAFE-USER SET-SELECTION SET-SERIALIZED SET-SIZE + SET-SOCKET-OPTION SET-SORT-ARROW SET-STATE SETTINGS SETUSER SETUSERI SETUSERID SET-WAIT SET-WAIT- + SET-WAIT-S SET-WAIT-ST SET-WAIT-STA SET-WAIT-STAT SET-WAIT-STATE SHA1-DIGEST SHARE SHARE- SHARED + SHARE-L SHARE-LO SHARE-LOC SHARE-LOCK SHORT SHOW-IN-TASK SHOW-IN-TASKB SHOW-IN-TASKBA + SHOW-IN-TASKBAR SHOW-STAT SHOW-STATS SIDE-LAB SIDE-LABE SIDE-LABEL SIDE-LABEL-H SIDE-LABEL-HA + SIDE-LABEL-HAN SIDE-LABEL-HAND SIDE-LABEL-HANDL SIDE-LABEL-HANDLE SIDE-LABELS SIGNATURE + SIGNATURE-VALUE SILENT SIMPLE SINGLE SINGLE-CHARACTER SINGLE-RUN SINGLETON SIZE SIZE-C SIZE-CH + SIZE-CHA SIZE-CHAR SIZE-CHARS SIZE-P SIZE-PI SIZE-PIX SIZE-PIXE SIZE-PIXEL SIZE-PIXELS SKIP + SKIP-DELETED-REC SKIP-DELETED-RECO SKIP-DELETED-RECOR SKIP-DELETED-RECORD SKIP-GROUP-DUPLICATES + SKIP-SCHEMA-CHECK SLIDER SMALL-ICON SMALLINT SMALL-TITLE SOAP-FAULT SOAP-FAULT-ACTOR SOAP-FAULT-CODE + SOAP-FAULT-DETAIL SOAP-FAULT-MISUNDERSTOOD-HEADER SOAP-FAULT-NODE SOAP-FAULT-ROLE SOAP-FAULT-STRING + SOAP-FAULT-SUBCODE SOAP-HEADER SOAP-HEADER-ENTRYREF SOAP-VERSION SOCKET SOME SORT SORT-ASCENDING + SORT-NUMBER SOURCE SOURCE-PROCEDURE SPACE SQL SQRT SSL-SERVER-NAME STANDALONE START + START-BOX-SELECTION START-DOCUMENT START-ELEMENT START-EXTEND-BOX-SELECTION STARTING START-MEM-CHECK + START-MOVE START-RESIZE START-ROW-RESIZE START-SEARCH STARTUP-PARAMETERS STATE-DETAIL STATIC + STATISTICS STATUS STATUS-AREA STATUS-AREA-FONT STATUS-AREA-MSG STDCALL STOMP-DETECTION + STOMP-FREQUENCY STOP STOP-AFTER STOP-DISPLAY STOP-MEM-CHECK STOP-OBJECT STOP-PARSING STOPPE STOPPED + STORED-PROC STORED-PROCE STORED-PROCED STORED-PROCEDU STORED-PROCEDUR STORED-PROCEDURE STREAM + STREAM-HANDLE STREAM-IO STRETCH-TO-FIT STRICT STRICT-ENTITY-RESOLUTION STRING STRING-VALUE + STRING-XREF SUB- SUB-AVE SUB-AVER SUB-AVERA SUB-AVERAG SUB-AVERAGE SUB-COUNT SUB-MAX SUB-MAXI + SUB-MAXIM SUB-MAXIMU SUB-MAXIMUM SUB-MENU SUB-MENU-HELP SUB-MIN SUB-MINI SUB-MINIM SUB-MINIMU + SUB-MINIMUM SUBSCRIBE SUBST SUBSTI SUBSTIT SUBSTITU SUBSTITUT SUBSTITUTE SUBSTR SUBSTRI SUBSTRIN + SUBSTRING SUB-TOTAL SUBTYPE SUM SUMMARY SUM-MAX SUPER SUPER-PROC SUPER-PROCE SUPER-PROCED + SUPER-PROCEDU SUPER-PROCEDUR SUPER-PROCEDURE SUPER-PROCEDURES SUPPRESS-NAMESPACE-PROCESSING + SUPPRESS-W SUPPRESS-WA SUPPRESS-WAR SUPPRESS-WARN SUPPRESS-WARNI SUPPRESS-WARNIN SUPPRESS-WARNING + SUPPRESS-WARNINGS SUPPRESS-WARNINGS-LIST SUSPEND SYMMETRIC-ENCRYPTION-ALGORITHM SYMMETRIC-ENCRYPTION-IV + SYMMETRIC-ENCRYPTION-KEY SYMMETRIC-SUPPORT SYNCHRONIZE SYSTEM-ALERT SYSTEM-ALERT- SYSTEM-ALERT-B + SYSTEM-ALERT-BO SYSTEM-ALERT-BOX SYSTEM-ALERT-BOXE SYSTEM-ALERT-BOXES SYSTEM-DIALOG SYSTEM-HELP + SYSTEM-ID TAB TABLE TABLE-CRC-LIST TABLE-HANDLE TABLE-LIST TABLE-NUM TABLE-NUMB TABLE-NUMBE + TABLE-NUMBER TABLE-SCAN TAB-POSITION TAB-STOP TARGET TARGET-PROCEDURE TEMP-DIR TEMP-DIRE TEMP-DIREC + TEMP-DIRECT TEMP-DIRECTO TEMP-DIRECTOR TEMP-DIRECTORY TEMP-TABLE TEMP-TABLE-PREPAR + TEMP-TABLE-PREPARE TENANT TENANT-ID TENANT-NAME TENANT-NAME-TO-ID TENANT-WHERE TERM TERMINAL + TERMINATE TEXT TEXT-CURSOR TEXT-SEG TEXT-SEG- TEXT-SEG-G TEXT-SEG-GR TEXT-SEG-GRO TEXT-SEG-GROW + TEXT-SEG-GROWT TEXT-SEG-GROWTH TEXT-SELECTED THEN THIS-OBJECT THIS-PROCEDURE THREAD-SAFE THREE-D + THROUGH THROW THRU TIC-MARKS TIME TIME-SOURCE TIMEZONE TITLE TITLE-BGC TITLE-BGCO TITLE-BGCOL + TITLE-BGCOLO TITLE-BGCOLOR TITLE-DC TITLE-DCO TITLE-DCOL TITLE-DCOLO TITLE-DCOLOR TITLE-FGC + TITLE-FGCO TITLE-FGCOL TITLE-FGCOLO TITLE-FGCOLOR TITLE-FO TITLE-FON TITLE-FONT TO TODAY TOGGLE-BOX + TOOLTIP TOOLTIPS TOP TOP-COLUMN TOPIC TOP-NAV-QUERY TOP-ONLY TO-ROWID TOTAL TRACE-FILTER TRACING + TRACKING-CHANGES TRAILING TRANS TRANSACT TRANSACTI TRANSACTIO TRANSACTION TRANSACTION-MODE + TRANS-INIT-PROC TRANS-INIT-PROCE TRANS-INIT-PROCED TRANS-INIT-PROCEDU TRANS-INIT-PROCEDUR + TRANS-INIT-PROCEDURE TRANSPAR TRANSPARE TRANSPAREN TRANSPARENT TRIGGER TRIGGERS TRIM TRUE TRUNC + TRUNCA TRUNCAT TRUNCATE TTCODEPAGE TYPE TYPE-OF UNBOX UNBUFF UNBUFFE UNBUFFER UNBUFFERE UNBUFFERED + UNDERL UNDERLI UNDERLIN UNDERLINE UNDO UNDO-THROW-SCOPE UNFORM UNFORMA UNFORMAT UNFORMATT UNFORMATTE + UNFORMATTED UNION UNIQUE UNIQUE-ID UNIQUE-MATCH UNIX UNIX-END UNLESS-HIDDEN UNLOAD UNSIGNED-BYTE + UNSIGNED-INT64 UNSIGNED-INTEGER UNSIGNED-LONG UNSIGNED-SHORT UNSUBSCRIBE UP UPDATE UPDATE-ATTRIBUTE + UPPER URL URL-DECODE URL-ENCODE URL-PASSWORD URL-USERID USE USE-DIC USE-DICT USE-DICT- USE-DICT-E + USE-DICT-EX USE-DICT-EXP USE-DICT-EXPS USE-FILENAME USE-INDEX USER USER-DATA USE-REVVIDEO USERID + USER-ID USE-TEXT USE-UNDERLINE USE-WIDGET-POOL USING UTC-OFFSET V6DISPLAY V6FRAME VALIDATE + VALIDATE-DOMAIN-ACCESS-CODE VALIDATE-EXPRESSIO VALIDATE-EXPRESSION VALIDATE-MESSAGE VALIDATE-SEAL + VALIDATE-XML VALIDATION-ENABLED VALID-EVENT VALID-HANDLE VALID-OBJECT VALUE VALUE-CHANGED VALUES VAR + VARI VARIA VARIAB VARIABL VARIABLE VERB VERBO VERBOS VERBOSE VERSION VERT VERTI VERTIC VERTICA + VERTICAL VIEW VIEW-AS VIEW-FIRST-COLUMN-ON-REOPEN VIRTUAL-HEIGHT VIRTUAL-HEIGHT-C VIRTUAL-HEIGHT-CH + VIRTUAL-HEIGHT-CHA VIRTUAL-HEIGHT-CHAR VIRTUAL-HEIGHT-CHARS VIRTUAL-HEIGHT-P VIRTUAL-HEIGHT-PI + VIRTUAL-HEIGHT-PIX VIRTUAL-HEIGHT-PIXE VIRTUAL-HEIGHT-PIXEL VIRTUAL-HEIGHT-PIXELS VIRTUAL-WIDTH + VIRTUAL-WIDTH-C VIRTUAL-WIDTH-CH VIRTUAL-WIDTH-CHA VIRTUAL-WIDTH-CHAR VIRTUAL-WIDTH-CHARS + VIRTUAL-WIDTH-P VIRTUAL-WIDTH-PI VIRTUAL-WIDTH-PIX VIRTUAL-WIDTH-PIXE VIRTUAL-WIDTH-PIXEL + VIRTUAL-WIDTH-PIXELS VISIBLE VMS VOID WAIT WAIT-FOR WARNING WC-ADMIN-APP WEB-CON WEB-CONT WEB-CONTE + WEB-CONTEX WEB-CONTEXT WEB-NOTIFY WEEKDAY WHEN WHERE WHERE-STRING WHILE WIDGET WIDGET-E WIDGET-EN + WIDGET-ENT WIDGET-ENTE WIDGET-ENTER WIDGET-H WIDGET-HA WIDGET-HAN WIDGET-HAND WIDGET-HANDL + WIDGET-HANDLE WIDGET-ID WIDGET-L WIDGET-LE WIDGET-LEA WIDGET-LEAV WIDGET-LEAVE WIDGET-POOL WIDTH + WIDTH-C WIDTH-CH WIDTH-CHA WIDTH-CHAR WIDTH-CHARS WIDTH-P WIDTH-PI WIDTH-PIX WIDTH-PIXE WIDTH-PIXEL + WIDTH-PIXELS WINDOW WINDOW-CLOSE WINDOW-DELAYED-MIN WINDOW-DELAYED-MINI WINDOW-DELAYED-MINIM + WINDOW-DELAYED-MINIMI WINDOW-DELAYED-MINIMIZ WINDOW-DELAYED-MINIMIZE WINDOW-MAXIM WINDOW-MAXIMI + WINDOW-MAXIMIZ WINDOW-MAXIMIZE WINDOW-MAXIMIZED WINDOW-MINIM WINDOW-MINIMI WINDOW-MINIMIZ + WINDOW-MINIMIZE WINDOW-MINIMIZED WINDOW-NAME WINDOW-NORMAL WINDOW-RESIZED WINDOW-RESTORED WINDOW-STA + WINDOW-STAT WINDOW-STATE WINDOW-SYS WINDOW-SYST WINDOW-SYSTE WINDOW-SYSTEM WITH WORD-INDEX WORD-WRAP + WORK-AREA-HEIGHT-P WORK-AREA-HEIGHT-PI WORK-AREA-HEIGHT-PIX WORK-AREA-HEIGHT-PIXE + WORK-AREA-HEIGHT-PIXEL WORK-AREA-HEIGHT-PIXELS WORK-AREA-WIDTH-P WORK-AREA-WIDTH-PI + WORK-AREA-WIDTH-PIX WORK-AREA-WIDTH-PIXE WORK-AREA-WIDTH-PIXEL WORK-AREA-WIDTH-PIXELS WORK-AREA-X + WORK-AREA-Y WORKFILE WORK-TAB WORK-TABL WORK-TABLE WRITE WRITE-CDATA WRITE-CHARACTERS WRITE-COMMENT + WRITE-DATA WRITE-DATA-ELEMENT WRITE-EMPTY-ELEMENT WRITE-ENTITY-REF WRITE-EXTERNAL-DTD WRITE-FRAGMENT + WRITE-JSON WRITE-MESSAGE WRITE-PROCESSING-INSTRUCTION WRITE-STATUS WRITE-XML WRITE-XMLSCHEMA X XCODE + XCODE-SESSION-KEY X-DOCUMENT XML-DATA-TYPE XML-ENTITY-EXPANSION-LIMIT XML-NODE-NAME XML-NODE-TYPE + XML-SCHEMA-PAT XML-SCHEMA-PATH XML-STRICT-ENTITY-RESOLUTION XML-SUPPRESS-NAMESPACE-PROCESSING + X-NODEREF X-OF XOR XREF XREF-XML Y YEAR YEAR-OFFSET YES YES-NO YES-NO-CANCEL Y-OF + ) + end + + def self.keywords_prepro + @keywords_prepro ||= Set.new %w( + &ANALYZE-SUSPEND &ANALYZE-RESUME + &ELSE &ELSEIF &ENDIF &GLOB &GLOBAL-DEFINE &IF &MESSAGE &SCOP &SCOPED-DEFINE &THEN &UNDEF &UNDEFINE &WEBSTREAM + {&BATCH} {&BATCH-MODE} {&FILE-NAME} {&LINE-NUMBE} {&LINE-NUMBER} {&OPSYS} {&PROCESS-ARCHITECTURE} {&SEQUENCE} + {&WINDOW-SYS} {&WINDOW-SYSTEM} + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + BLOB CHARACTER CHAR CLOB COM-HANDLE DATE DATETIME DATETIME-TZ DECIMAL + DEC HANDLE INT64 INTEGER INT LOGICAL LONGCHAR MEMPTR RAW RECID ROWID + WIDGET-HANDLE VOID + ) + end + + state :statements do + mixin :singlelinecomment + mixin :multilinecomment + mixin :string + mixin :numeric + mixin :constant + mixin :operator + mixin :whitespace + mixin :preproc + mixin :decorator + mixin :function + end + + state :whitespace do + rule %r/\s+/m, Text + end + + state :singlelinecomment do + rule %r(//.*$), Comment::Single + end + + state :multilinecomment do + rule %r(/[*]), Comment::Multiline, :multilinecomment_content + end + + state :multilinecomment_content do + rule %r([*]/), Comment::Multiline, :pop! + rule %r(/[*]), Comment::Multiline, :multilinecomment_content + rule %r([^*/]+), Comment::Multiline + rule %r([*/]), Comment::Multiline + end + + state :string do + rule %r/"/, Str::Delimiter, :doublequotedstring + rule %r/'/, Str::Delimiter, :singlequotedstring + end + + state :numeric do + rule %r((?:\d+[.]\d*|[.]\d+)(?:e[+-]?\d+[lu]*)?)i, Num::Float + rule %r(\d+e[+-]?\d+[lu]*)i, Num::Float + rule %r/0x[0-9a-f]+[lu]*/i, Num::Hex + rule %r/0[0-7]+[lu]*/i, Num::Oct + rule %r/\d+[lu]*/i, Num::Integer + end + + state :constant do + rule %r/(?:TRUE|FALSE|YES|NO(?!\-)|\?)\b/i, Keyword::Constant + end + + state :operator do + rule %r([~!%^*+=\|?:<>/-]), Operator + rule %r/[()\[\],.]/, Punctuation + end + + state :doublequotedstring do + rule %r/\~[~nrt"]?/, Str::Escape + rule %r/[^\\"]+/, Str::Double + rule %r/"/, Str::Delimiter, :pop! + end + + state :singlequotedstring do + rule %r/\~[~nrt']?/, Str::Escape + rule %r/[^\\']+/, Str::Single + rule %r/'/, Str::Delimiter, :pop! + end + + state :preproc do + rule %r/(\&analyze-suspend|\&analyze-resume)/i, Comment::Preproc, :analyze_suspend_resume_content + rule %r/(\&scoped-define|\&global-define)\s*([\.\w\\\/-]*)/i , Comment::Preproc, :analyze_suspend_resume_content + mixin :include_file + end + + state :analyze_suspend_resume_content do + rule %r/.*(?=(?:\/\/|\/\*))/, Comment::Preproc, :pop! + rule %r/.*\n/, Comment::Preproc, :pop! + rule %r/.*/, Comment::Preproc, :pop! + end + + state :preproc_content do + rule %r/\n/, Text, :pop! + rule %r/\s+/, Text + + rule %r/({?&)(\S+)/ do + groups Comment::Preproc, Name::Other + end + + rule %r/"/, Str, :string + mixin :numeric + + rule %r/\S+/, Name + end + + state :include_file do + rule %r/(\{(?:[^\{\}]|(\g<0>))+\})/i , Comment::Preproc + end + + state :decorator do + rule %r/@#{id}/, Name::Decorator #, :decorator_content + end + + state :function do + rule %r/\!?#{id}(?=\s*\()/i , Name::Function + end + + state :root do + mixin :statements + + rule id do |m| + name = m[0].upcase + if self.class.keywords_prepro.include? name + token Comment::Preproc + elsif self.class.keywords.include? name + token Keyword + elsif self.class.keywords_type.include? name + token Keyword::Type + else + token Name::Variable + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/opentype_feature_file.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/opentype_feature_file.rb new file mode 100644 index 0000000..943d6ab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/opentype_feature_file.rb @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class OpenTypeFeatureFile < RegexLexer + title "OpenType Feature File" + desc "Feature specifications for an OpenType font (adobe-type-tools.github.io/afdko)" + tag 'opentype_feature_file' + aliases 'fea', 'opentype', 'opentypefeature' + filenames '*.fea' + + def self.keywords + @keywords ||= %w( + Ascender Attach AxisValue CapHeight CaretOffset CodePageRange + DesignAxis Descender ElidedFallbackName ElidedFallbackNameID + ElidableAxisValueName FeatUILabelNameID FeatUITooltipTextNameID + FontRevision FSType GlyphClassDef HorizAxis.BaseScriptList + HorizAxis.BaseTagList HorizAxis.MinMax IgnoreBaseGlyphs + IgnoreLigatures IgnoreMarks LigatureCaretByDev LigatureCaretByIndex + LigatureCaretByPos LineGap MarkAttachClass MarkAttachmentType NULL + OlderSiblingFontAttribute Panose ParamUILabelNameID RightToLeft + SampleTextNameID TypoAscender TypoDescender TypoLineGap UnicodeRange + UseMarkFilteringSet Vendor VertAdvanceY VertAxis.BaseScriptList + VertAxis.BaseTagList VertAxis.MinMax VertOriginY VertTypoAscender + VertTypoDescender VertTypoLineGap WeightClass WidthClass XHeight + + anchorDef anchor anonymous anon by contour cursive device enumerate + enum exclude_dflt featureNames feature flag from ignore include_dflt + include languagesystem language location lookupflag lookup markClass + mark nameid name parameters position pos required reversesub rsub + script sizemenuname substitute subtable sub table useExtension + valueRecordDef winAscent winDescent + ) + end + + + identifier = %r/[a-z_][a-z0-9\/_.-]*/i + + state :root do + rule %r/\s+/m, Text::Whitespace + rule %r/#.*$/, Comment + + # feature + rule %r/(anonymous|anon|feature|lookup|table)((?:\s)+)/ do + groups Keyword, Text + push :featurename + end + # } ; + rule %r/(\})((?:\s))/ do + groups Punctuation, Text + push :featurename + end + # solve include( ../path) + rule %r/include\b/i, Keyword, :includepath + + rule %r/[\-\[\]\/(){},.:;=%*<>']/, Punctuation + + rule %r/`.*?/, Str::Backtick + rule %r/\"/, Str, :strings + rule %r/\\[^.*\s]+/i, Str::Escape + + # classes, start with @ + rule %r/@#{identifier}/, Name::Class + + # using negative lookbehind so we don't match property names + rule %r/(?\?,\.\/\|\\]}, Punctuation + rule %r{'([^']|'')*'}, Str + rule %r/(true|false|nil)\b/i, Name::Builtin + rule %r/\b(#{keywords.join('|')})\b/i, Keyword + rule %r/\b(#{keywords_type.join('|')})\b/i, Keyword::Type + rule id, Name + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/perl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/perl.rb new file mode 100644 index 0000000..78d6bc6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/perl.rb @@ -0,0 +1,251 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Perl < RegexLexer + title "Perl" + desc "The Perl scripting language (perl.org)" + + tag 'perl' + aliases 'pl' + + filenames '*.pl', '*.pm', '*.t' + mimetypes 'text/x-perl', 'application/x-perl' + + def self.detect?(text) + return true if text.shebang? 'perl' + end + + keywords = %w( + case continue do else elsif for foreach if last my next our + redo reset then unless until while use print new BEGIN CHECK + INIT END return + ) + + builtins = %w( + abs accept alarm atan2 bind binmode bless caller chdir chmod + chomp chop chown chr chroot close closedir connect continue cos + crypt dbmclose dbmopen defined delete die dump each endgrent + endhostent endnetent endprotoent endpwent endservent eof eval + exec exists exit exp fcntl fileno flock fork format formline getc + getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent + getlogin getnetbyaddr getnetbyname getnetent getpeername + getpgrp getppid getpriority getprotobyname getprotobynumber + getprotoent getpwent getpwnam getpwuid getservbyname getservbyport + getservent getsockname getsockopt glob gmtime goto grep hex + import index int ioctl join keys kill last lc lcfirst length + link listen local localtime log lstat map mkdir msgctl msgget + msgrcv msgsnd my next no oct open opendir ord our pack package + pipe pop pos printf prototype push quotemeta rand read readdir + readline readlink readpipe recv redo ref rename require reverse + rewinddir rindex rmdir scalar seek seekdir select semctl semget + semop send setgrent sethostent setnetent setpgrp setpriority + setprotoent setpwent setservent setsockopt shift shmctl shmget + shmread shmwrite shutdown sin sleep socket socketpair sort splice + split sprintf sqrt srand stat study substr symlink syscall sysopen + sysread sysseek system syswrite tell telldir tie tied time times + tr truncate uc ucfirst umask undef unlink unpack unshift untie + utime values vec wait waitpid wantarray warn write + ) + + re_tok = Str::Regex + + state :balanced_regex do + rule %r(/(\\[\\/]|[^/])*/[egimosx]*)m, re_tok, :pop! + rule %r(!(\\[\\!]|[^!])*![egimosx]*)m, re_tok, :pop! + rule %r(\\(\\\\|[^\\])*\\[egimosx]*)m, re_tok, :pop! + rule %r({(\\[\\}]|[^}])*}[egimosx]*), re_tok, :pop! + rule %r(<(\\[\\>]|[^>])*>[egimosx]*), re_tok, :pop! + rule %r(\[(\\[\\\]]|[^\]])*\][egimosx]*), re_tok, :pop! + rule %r[\((\\[\\\)]|[^\)])*\)[egimosx]*], re_tok, :pop! + rule %r(@(\\[\\@]|[^@])*@[egimosx]*), re_tok, :pop! + rule %r(%(\\[\\%]|[^%])*%[egimosx]*), re_tok, :pop! + rule %r(\$(\\[\\\$]|[^\$])*\$[egimosx]*), re_tok, :pop! + end + + state :root do + rule %r/#.*/, Comment::Single + rule %r/^=[a-zA-Z0-9]+\s+.*?\n=cut/m, Comment::Multiline + rule %r/(?:#{keywords.join('|')})\b/, Keyword + + rule %r/(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)/ do + groups Keyword, Text, Name, Text, Punctuation, Text + + push :format + end + + rule %r/(?:eq|lt|gt|le|ge|ne|not|and|or|cmp)\b/, Operator::Word + + # substitution/transliteration: balanced delimiters + rule %r((?:s|tr|y){(\\\\|\\}|[^}])*}\s*), re_tok, :balanced_regex + rule %r((?:s|tr|y)<(\\\\|\\>|[^>])*>\s*), re_tok, :balanced_regex + rule %r((?:s|tr|y)\[(\\\\|\\\]|[^\]])*\]\s*), re_tok, :balanced_regex + rule %r[(?:s|tr|y)\((\\\\|\\\)|[^\)])*\)\s*], re_tok, :balanced_regex + + # substitution/transliteration: arbitrary non-whitespace delimiters + rule %r((?:s|tr|y)\s*([^\w\s])((\\\\|\\\1)|[^\1])*?\1((\\\\|\\\1)|[^\1])*?\1[msixpodualngcr]*)m, re_tok + rule %r((?:s|tr|y)\s+(\w)((\\\\|\\\1)|[^\1])*?\1((\\\\|\\\1)|[^\1])*?\1[msixpodualngcr]*)m, re_tok + + # matches: common case, m-optional + rule %r(m?/(\\\\|\\/|[^/\n])*/[msixpodualngc]*), re_tok + rule %r(m(?=[/!\\{<\[\(@%\$])), re_tok, :balanced_regex + + # arbitrary non-whitespace delimiters + rule %r(m\s*([^\w\s])((\\\\|\\\1)|[^\1])*?\1[msixpodualngc]*)m, re_tok + rule %r(m\s+(\w)((\\\\|\\\1)|[^\1])*?\1[msixpodualngc]*)m, re_tok + + rule %r(((?<==~)|(?<=\())\s*/(\\\\|\\/|[^/])*/[msixpodualngc]*), + re_tok, :balanced_regex + + rule %r/\s+/, Text + + rule(/(?=[a-z_]\w*(\s*#.*\n)*\s*=>)/i) { push :fat_comma } + + rule %r/(?:#{builtins.join('|')})\b/, Name::Builtin + rule %r/((__(DIE|WARN)__)|(DATA|STD(IN|OUT|ERR)))\b/, + Name::Builtin::Pseudo + + rule %r/<<([\'"]?)([a-zA-Z_][a-zA-Z0-9_]*)\1;?\n.*?\n\2\n/m, Str + + rule %r/(__(END|DATA)__)\b/, Comment::Preproc, :end_part + rule %r/\$\^[ADEFHILMOPSTWX]/, Name::Variable::Global + rule %r/\$[\\"'\[\]&`+*.,;=%~?@$!<>(^\|\/_-](?!\w)/, Name::Variable::Global + rule %r/[$@%&*][$@%&*#_]*(?=[a-z{\[;])/i, Name::Variable, :varname + + rule %r/[-+\/*%=<>&^\|!\\~]=?/, Operator + + rule %r/0_?[0-7]+(_[0-7]+)*/, Num::Oct + rule %r/0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*/, Num::Hex + rule %r/0b[01]+(_[01]+)*/, Num::Bin + rule %r/(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?/i, + Num::Float + rule %r/\d+(_\d*)*e[+-]?\d+(_\d*)*/i, Num::Float + rule %r/\d+(_\d+)*/, Num::Integer + + rule %r/'/, Punctuation, :sq + rule %r/"/, Punctuation, :dq + rule %r/`/, Punctuation, :bq + rule %r/<([^\s>]+)>/, re_tok + rule %r/(q|qq|qw|qr|qx)\{/, Str::Other, :cb_string + rule %r/(q|qq|qw|qr|qx)\(/, Str::Other, :rb_string + rule %r/(q|qq|qw|qr|qx)\[/, Str::Other, :sb_string + rule %r/(q|qq|qw|qr|qx)>|>=|<=|<=>|={3}|!=|=~|!~|&&?|\|\||\.{1,3}/, + Operator + rule %r/[()\[\]:;,<>\/?{}]/, Punctuation + rule(/(?=\w)/) { push :name } + end + + state :format do + rule %r/\.\n/, Str::Interpol, :pop! + rule %r/.*?\n/, Str::Interpol + end + + state :fat_comma do + rule %r/#.*/, Comment::Single + rule %r/\w+/, Str + rule %r/\s+/, Text + rule %r/=>/, Operator, :pop! + end + + state :name_common do + rule %r/\w+::/, Name::Namespace + rule %r/[\w:]+/, Name::Variable, :pop! + end + + state :varname do + rule %r/\s+/, Text + rule %r/[{\[]/, Punctuation, :pop! # hash syntax + rule %r/[),]/, Punctuation, :pop! # arg specifier + rule %r/[;]/, Punctuation, :pop! # postfix + mixin :name_common + end + + state :name do + mixin :name_common + rule %r/[A-Z_]+(?=[^a-zA-Z0-9_])/, Name::Constant, :pop! + rule(/(?=\W)/) { pop! } + end + + state :modulename do + rule %r/[a-z_]\w*/i, Name::Namespace, :pop! + end + + state :funcname do + rule %r/[a-zA-Z_]\w*[!?]?/, Name::Function + rule %r/\s+/, Text + + # argument declaration + rule %r/(\([$@%]*\))(\s*)/ do + groups Punctuation, Text + end + + rule %r/.*?{/, Punctuation, :pop! + rule %r/;/, Punctuation, :pop! + end + + state :sq do + rule %r/\\[\\']/, Str::Escape + rule %r/[^\\']+/, Str::Single + rule %r/'/, Punctuation, :pop! + rule %r/\\/, Str::Single + end + + state :dq do + mixin :string_intp + rule %r/\\[\\tnrabefluLUE"$@]/, Str::Escape + rule %r/\\0\d{2}/, Str::Escape + rule %r/\\o\{\d+\}/, Str::Escape + rule %r/\\x\h{2}/, Str::Escape + rule %r/\\x\{\h+\}/, Str::Escape + rule %r/\\c./, Str::Escape + rule %r/\\N\{[^\}]+\}/, Str::Escape + rule %r/[^\\"]+?/, Str::Double + rule %r/"/, Punctuation, :pop! + rule %r/\\/, Str::Escape + end + + state :bq do + mixin :string_intp + rule %r/\\[\\tnr`]/, Str::Escape + rule %r/[^\\`]+?/, Str::Backtick + rule %r/`/, Punctuation, :pop! + end + + [[:cb, '\{', '\}'], + [:rb, '\(', '\)'], + [:sb, '\[', '\]'], + [:lt, '<', '>']].each do |name, open, close| + tok = Str::Other + state :"#{name}_string" do + rule %r/\\[#{open}#{close}\\]/, tok + rule %r/\\/, tok + rule(/#{open}/) { token tok; push } + rule %r/#{close}/, tok, :pop! + rule %r/[^#{open}#{close}\\]+/, tok + end + end + + state :in_interp do + rule %r/}/, Str::Interpol, :pop! + rule %r/\s+/, Text + rule %r/[a-z_]\w*/i, Str::Interpol + end + + state :string_intp do + rule %r/[$@][{]/, Str::Interpol, :in_interp + rule %r/[$@][a-z_]\w*/i, Str::Interpol + end + + state :end_part do + # eat the rest of the stream + rule %r/.+/m, Comment::Preproc, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/php.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/php.rb new file mode 100644 index 0000000..1580b47 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/php.rb @@ -0,0 +1,381 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class PHP < TemplateLexer + title "PHP" + desc "The PHP scripting language (php.net)" + tag 'php' + aliases 'php', 'php3', 'php4', 'php5' + filenames '*.php', '*.php[345t]','*.phtml', + # Support Drupal file extensions, see: + # https://github.com/gitlabhq/gitlabhq/issues/8900 + '*.module', '*.inc', '*.profile', '*.install', '*.test' + mimetypes 'text/x-php' + + option :start_inline, 'Whether to start with inline php or require . (default: best guess)' + option :funcnamehighlighting, 'Whether to highlight builtin functions (default: true)' + option :disabledmodules, 'Disable certain modules from being highlighted as builtins (default: empty)' + + def initialize(*) + super + + # if truthy, the lexer starts highlighting with php code + # (no / do + token Comment::Preproc + reset_stack + end + end + + state :return do + rule(//) { pop! } + end + + state :start do + # We enter this state if we aren't sure whether the PHP in the text is + # delimited by \/@-]+/, Operator + end + + state :string do + rule %r/"/, Str::Double, :pop! + rule %r/[^\\{$"]+/, Str::Double + rule %r/\\u\{[0-9a-fA-F]+\}/, Str::Escape + rule %r/\\([efrntv\"$\\]|[0-7]{1,3}|[xX][0-9a-fA-F]{1,2})/, Str::Escape + rule %r/\$#{id}(\[\S+\]|->#{id})?/, Name::Variable + + rule %r/\{\$\{/, Str::Interpol, :string_interp_double + rule %r/\{(?=\$)/, Str::Interpol, :string_interp_single + rule %r/(\{)(\S+)(\})/ do + groups Str::Interpol, Name::Variable, Str::Interpol + end + + rule %r/[${\\]+/, Str::Double + end + + state :string_interp_double do + rule %r/\}\}/, Str::Interpol, :pop! + mixin :php + end + + state :string_interp_single do + rule %r/\}/, Str::Interpol, :pop! + mixin :php + end + + state :values do + # heredocs + rule %r/<<<(["']?)(#{id})\1\n.*?\n\s*\2;?/im, Str::Heredoc + + # numbers + rule %r/(\d[_\d]*)?\.(\d[_\d]*)?(e[+-]?\d[_\d]*)?/i, Num::Float + rule %r/0[0-7][0-7_]*/, Num::Oct + rule %r/0b[01][01_]*/i, Num::Bin + rule %r/0x[a-f0-9][a-f0-9_]*/i, Num::Hex + rule %r/\d[_\d]*/, Num::Integer + + # strings + rule %r/'([^'\\]*(?:\\.[^'\\]*)*)'/, Str::Single + rule %r/`([^`\\]*(?:\\.[^`\\]*)*)`/, Str::Backtick + rule %r/"/, Str::Double, :string + + # functions + rule %r/(function|fn)\b/i do + push :in_function_return + push :in_function_params + push :in_function_name + token Keyword + end + + # constants + rule %r/(true|false|null)\b/i, Keyword::Constant + + # objects + rule %r/new\b/i, Keyword, :in_new + end + + state :variables do + rule %r/\$\{\$+#{id}\}/, Name::Variable + rule %r/\$+#{id}/, Name::Variable + end + + state :whitespace do + rule %r/\s+/, Text + rule %r/#[^\[].*?$/, Comment::Single + rule %r(//.*?$), Comment::Single + rule %r(/\*\*(?!/).*?\*/)m, Comment::Doc + rule %r(/\*.*?\*/)m, Comment::Multiline + end + + state :root do + rule %r/<\?(php|=)?/i, Comment::Preproc, :php + rule(/.*?(?=<\?)|.*/m) { delegate parent } + end + + state :php do + mixin :escape + + mixin :whitespace + mixin :variables + mixin :values + + rule %r/(namespace) + (\s+) + (#{id_with_ns})/ix do |m| + groups Keyword::Namespace, Text, Name::Namespace + end + + rule %r/#\[.*\]$/, Name::Attribute + + rule %r/(class|interface|trait|extends|implements) + (\s+) + (#{id_with_ns})/ix do |m| + groups Keyword::Declaration, Text, Name::Class + end + + mixin :names + + rule %r/[;,\(\)\{\}\[\]]/, Punctuation + + mixin :operators + rule %r/[=?]/, Operator + end + + state :in_assign do + rule %r/,/, Punctuation, :pop! + rule %r/[\[\]]/, Punctuation + rule %r/\(/, Punctuation, :in_assign_function + mixin :escape + mixin :whitespace + mixin :values + mixin :variables + mixin :names + mixin :operators + mixin :return + end + + state :in_assign_function do + rule %r/\)/, Punctuation, :pop! + rule %r/,/, Punctuation + mixin :in_assign + end + + state :in_catch do + rule %r/\(/, Punctuation + rule %r/\|/, Operator + rule id_with_ns, Name::Class + mixin :escape + mixin :whitespace + mixin :return + end + + state :in_const do + rule id, Name::Constant + rule %r/=/, Operator, :in_assign + mixin :escape + mixin :whitespace + mixin :return + end + + state :in_function_body do + rule %r/{/, Punctuation, :push + rule %r/}/, Punctuation, :pop! + mixin :php + end + + state :in_function_name do + rule %r/&/, Operator + rule id, Name + rule %r/\(/, Punctuation, :pop! + mixin :escape + mixin :whitespace + mixin :return + end + + state :in_function_params do + rule %r/\)/, Punctuation, :pop! + rule %r/,/, Punctuation + rule %r/[.]{3}/, Punctuation + rule %r/=/, Operator, :in_assign + rule %r/\b(?:public|protected|private|readonly)\b/i, Keyword + rule %r/\??#{id}/, Keyword::Type, :in_assign + mixin :escape + mixin :whitespace + mixin :variables + mixin :return + end + + state :in_function_return do + rule %r/:/, Punctuation + rule %r/use\b/i, Keyword, :in_function_use + rule %r/\??#{id}/, Keyword::Type, :in_assign + rule %r/\{/ do + token Punctuation + goto :in_function_body + end + mixin :escape + mixin :whitespace + mixin :return + end + + state :in_function_use do + rule %r/[,\(]/, Punctuation + rule %r/&/, Operator + rule %r/\)/, Punctuation, :pop! + mixin :escape + mixin :whitespace + mixin :variables + mixin :return + end + + state :in_new do + rule %r/class\b/i do + token Keyword::Declaration + goto :in_new_class + end + rule id_with_ns, Name::Class, :pop! + mixin :escape + mixin :whitespace + mixin :return + end + + state :in_new_class do + rule %r/\}/, Punctuation, :pop! + rule %r/\{/, Punctuation + mixin :php + end + + state :in_use do + rule %r/[,\}]/, Punctuation + rule %r/(function|const)\b/i, Keyword + rule %r/(#{ns})(\{)/ do + groups Name::Namespace, Punctuation + end + rule %r/#{id_with_ns}(_#{id})+/, Name::Function + mixin :escape + mixin :whitespace + mixin :names + mixin :return + end + + state :in_visibility do + rule %r/\b(?:readonly|static)\b/i, Keyword + rule %r/(?=(abstract|const|function)\b)/i, Keyword, :pop! + rule %r/\??#{id}/, Keyword::Type, :pop! + mixin :escape + mixin :whitespace + mixin :return + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/php/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/php/keywords.rb new file mode 100644 index 0000000..5fa56ce --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/php/keywords.rb @@ -0,0 +1,202 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# DO NOT EDIT +# This file is automatically generated by `rake builtins:php`. +# See tasks/builtins/php.rake for more info. + +module Rouge + module Lexers + class PHP + def self.builtins + @builtins ||= {}.tap do |b| + b["Apache"] = Set.new ["apache_child_terminate", "apache_get_modules", "apache_get_version", "apache_getenv", "apache_lookup_uri", "apache_note", "apache_request_headers", "apache_reset_timeout", "apache_response_headers", "apache_setenv", "getallheaders", "virtual"] + b["APC"] = Set.new ["apc_add", "apc_bin_dump", "apc_bin_dumpfile", "apc_bin_load", "apc_bin_loadfile", "apc_cache_info", "apc_cas", "apc_clear_cache", "apc_compile_file", "apc_dec", "apc_define_constants", "apc_delete_file", "apc_delete", "apc_exists", "apc_fetch", "apc_inc", "apc_load_constants", "apc_sma_info", "apc_store"] + b["APCu"] = Set.new ["apcu_add", "apcu_cache_info", "apcu_cas", "apcu_clear_cache", "apcu_dec", "apcu_delete", "apcu_enabled", "apcu_entry", "apcu_exists", "apcu_fetch", "apcu_inc", "apcu_sma_info", "apcu_store"] + b["APD"] = Set.new ["apd_breakpoint", "apd_callstack", "apd_clunk", "apd_continue", "apd_croak", "apd_dump_function_table", "apd_dump_persistent_resources", "apd_dump_regular_resources", "apd_echo", "apd_get_active_symbols", "apd_set_pprof_trace", "apd_set_session_trace_socket", "apd_set_session_trace", "apd_set_session", "override_function", "rename_function"] + b["Array"] = Set.new ["array_change_key_case", "array_chunk", "array_column", "array_combine", "array_count_values", "array_diff_assoc", "array_diff_key", "array_diff_uassoc", "array_diff_ukey", "array_diff", "array_fill_keys", "array_fill", "array_filter", "array_flip", "array_intersect_assoc", "array_intersect_key", "array_intersect_uassoc", "array_intersect_ukey", "array_intersect", "array_key_exists", "array_key_first", "array_key_last", "array_keys", "array_map", "array_merge_recursive", "array_merge", "array_multisort", "array_pad", "array_pop", "array_product", "array_push", "array_rand", "array_reduce", "array_replace_recursive", "array_replace", "array_reverse", "array_search", "array_shift", "array_slice", "array_splice", "array_sum", "array_udiff_assoc", "array_udiff_uassoc", "array_udiff", "array_uintersect_assoc", "array_uintersect_uassoc", "array_uintersect", "array_unique", "array_unshift", "array_values", "array_walk_recursive", "array_walk", "array", "arsort", "asort", "compact", "count", "current", "each", "end", "extract", "in_array", "key_exists", "key", "krsort", "ksort", "list", "natcasesort", "natsort", "next", "pos", "prev", "range", "reset", "rsort", "shuffle", "sizeof", "sort", "uasort", "uksort", "usort"] + b["BBCode"] = Set.new ["bbcode_add_element", "bbcode_add_smiley", "bbcode_create", "bbcode_destroy", "bbcode_parse", "bbcode_set_arg_parser", "bbcode_set_flags"] + b["BC Math"] = Set.new ["bcadd", "bccomp", "bcdiv", "bcmod", "bcmul", "bcpow", "bcpowmod", "bcscale", "bcsqrt", "bcsub"] + b["bcompiler"] = Set.new ["bcompiler_load_exe", "bcompiler_load", "bcompiler_parse_class", "bcompiler_read", "bcompiler_write_class", "bcompiler_write_constant", "bcompiler_write_exe_footer", "bcompiler_write_file", "bcompiler_write_footer", "bcompiler_write_function", "bcompiler_write_functions_from_file", "bcompiler_write_header", "bcompiler_write_included_filename"] + b["Blenc"] = Set.new ["blenc_encrypt"] + b["Bzip2"] = Set.new ["bzclose", "bzcompress", "bzdecompress", "bzerrno", "bzerror", "bzerrstr", "bzflush", "bzopen", "bzread", "bzwrite"] + b["Cairo"] = Set.new ["cairo_create", "cairo_font_options_create", "cairo_font_options_equal", "cairo_font_options_get_antialias", "cairo_font_options_get_hint_metrics", "cairo_font_options_get_hint_style", "cairo_font_options_get_subpixel_order", "cairo_font_options_hash", "cairo_font_options_merge", "cairo_font_options_set_antialias", "cairo_font_options_set_hint_metrics", "cairo_font_options_set_hint_style", "cairo_font_options_set_subpixel_order", "cairo_font_options_status", "cairo_format_stride_for_width", "cairo_image_surface_create_for_data", "cairo_image_surface_create_from_png", "cairo_image_surface_create", "cairo_image_surface_get_data", "cairo_image_surface_get_format", "cairo_image_surface_get_height", "cairo_image_surface_get_stride", "cairo_image_surface_get_width", "cairo_matrix_create_scale", "cairo_matrix_create_translate", "cairo_matrix_invert", "cairo_matrix_multiply", "cairo_matrix_transform_distance", "cairo_matrix_transform_point", "cairo_matrix_translate", "cairo_pattern_add_color_stop_rgb", "cairo_pattern_add_color_stop_rgba", "cairo_pattern_create_for_surface", "cairo_pattern_create_linear", "cairo_pattern_create_radial", "cairo_pattern_create_rgb", "cairo_pattern_create_rgba", "cairo_pattern_get_color_stop_count", "cairo_pattern_get_color_stop_rgba", "cairo_pattern_get_extend", "cairo_pattern_get_filter", "cairo_pattern_get_linear_points", "cairo_pattern_get_matrix", "cairo_pattern_get_radial_circles", "cairo_pattern_get_rgba", "cairo_pattern_get_surface", "cairo_pattern_get_type", "cairo_pattern_set_extend", "cairo_pattern_set_filter", "cairo_pattern_set_matrix", "cairo_pattern_status", "cairo_pdf_surface_create", "cairo_pdf_surface_set_size", "cairo_ps_get_levels", "cairo_ps_level_to_string", "cairo_ps_surface_create", "cairo_ps_surface_dsc_begin_page_setup", "cairo_ps_surface_dsc_begin_setup", "cairo_ps_surface_dsc_comment", "cairo_ps_surface_get_eps", "cairo_ps_surface_restrict_to_level", "cairo_ps_surface_set_eps", "cairo_ps_surface_set_size", "cairo_scaled_font_create", "cairo_scaled_font_extents", "cairo_scaled_font_get_ctm", "cairo_scaled_font_get_font_face", "cairo_scaled_font_get_font_matrix", "cairo_scaled_font_get_font_options", "cairo_scaled_font_get_scale_matrix", "cairo_scaled_font_get_type", "cairo_scaled_font_glyph_extents", "cairo_scaled_font_status", "cairo_scaled_font_text_extents", "cairo_surface_copy_page", "cairo_surface_create_similar", "cairo_surface_finish", "cairo_surface_flush", "cairo_surface_get_content", "cairo_surface_get_device_offset", "cairo_surface_get_font_options", "cairo_surface_get_type", "cairo_surface_mark_dirty_rectangle", "cairo_surface_mark_dirty", "cairo_surface_set_device_offset", "cairo_surface_set_fallback_resolution", "cairo_surface_show_page", "cairo_surface_status", "cairo_surface_write_to_png", "cairo_svg_surface_create", "cairo_svg_surface_restrict_to_version", "cairo_svg_version_to_string"] + b["Calendar"] = Set.new ["cal_days_in_month", "cal_from_jd", "cal_info", "cal_to_jd", "easter_date", "easter_days", "frenchtojd", "gregoriantojd", "jddayofweek", "jdmonthname", "jdtofrench", "jdtogregorian", "jdtojewish", "jdtojulian", "jdtounix", "jewishtojd", "juliantojd", "unixtojd"] + b["chdb"] = Set.new ["chdb_create"] + b["Classkit"] = Set.new ["classkit_import", "classkit_method_add", "classkit_method_copy", "classkit_method_redefine", "classkit_method_remove", "classkit_method_rename"] + b["Classes/Object"] = Set.new ["__autoload", "call_user_method_array", "call_user_method", "class_alias", "class_exists", "get_called_class", "get_class_methods", "get_class_vars", "get_class", "get_declared_classes", "get_declared_interfaces", "get_declared_traits", "get_object_vars", "get_parent_class", "interface_exists", "is_a", "is_subclass_of", "method_exists", "property_exists", "trait_exists"] + b["CommonMark"] = Set.new ["CommonMark\\Parse", "CommonMark\\Render", "CommonMark\\Render\\HTML", "CommonMark\\Render\\Latex", "CommonMark\\Render\\Man", "CommonMark\\Render\\XML"] + b["COM"] = Set.new ["com_create_guid", "com_event_sink", "com_get_active_object", "com_load_typelib", "com_message_pump", "com_print_typeinfo", "variant_abs", "variant_add", "variant_and", "variant_cast", "variant_cat", "variant_cmp", "variant_date_from_timestamp", "variant_date_to_timestamp", "variant_div", "variant_eqv", "variant_fix", "variant_get_type", "variant_idiv", "variant_imp", "variant_int", "variant_mod", "variant_mul", "variant_neg", "variant_not", "variant_or", "variant_pow", "variant_round", "variant_set_type", "variant_set", "variant_sub", "variant_xor"] + b["Crack"] = Set.new ["crack_check", "crack_closedict", "crack_getlastmessage", "crack_opendict"] + b["CSPRNG"] = Set.new ["random_bytes", "random_int"] + b["Ctype"] = Set.new ["ctype_alnum", "ctype_alpha", "ctype_cntrl", "ctype_digit", "ctype_graph", "ctype_lower", "ctype_print", "ctype_punct", "ctype_space", "ctype_upper", "ctype_xdigit"] + b["CUBRID"] = Set.new ["cubrid_bind", "cubrid_close_prepare", "cubrid_close_request", "cubrid_col_get", "cubrid_col_size", "cubrid_column_names", "cubrid_column_types", "cubrid_commit", "cubrid_connect_with_url", "cubrid_connect", "cubrid_current_oid", "cubrid_disconnect", "cubrid_drop", "cubrid_error_code_facility", "cubrid_error_code", "cubrid_error_msg", "cubrid_execute", "cubrid_fetch", "cubrid_free_result", "cubrid_get_autocommit", "cubrid_get_charset", "cubrid_get_class_name", "cubrid_get_client_info", "cubrid_get_db_parameter", "cubrid_get_query_timeout", "cubrid_get_server_info", "cubrid_get", "cubrid_insert_id", "cubrid_is_instance", "cubrid_lob_close", "cubrid_lob_export", "cubrid_lob_get", "cubrid_lob_send", "cubrid_lob_size", "cubrid_lob2_bind", "cubrid_lob2_close", "cubrid_lob2_export", "cubrid_lob2_import", "cubrid_lob2_new", "cubrid_lob2_read", "cubrid_lob2_seek64", "cubrid_lob2_seek", "cubrid_lob2_size64", "cubrid_lob2_size", "cubrid_lob2_tell64", "cubrid_lob2_tell", "cubrid_lob2_write", "cubrid_lock_read", "cubrid_lock_write", "cubrid_move_cursor", "cubrid_next_result", "cubrid_num_cols", "cubrid_num_rows", "cubrid_pconnect_with_url", "cubrid_pconnect", "cubrid_prepare", "cubrid_put", "cubrid_rollback", "cubrid_schema", "cubrid_seq_drop", "cubrid_seq_insert", "cubrid_seq_put", "cubrid_set_add", "cubrid_set_autocommit", "cubrid_set_db_parameter", "cubrid_set_drop", "cubrid_set_query_timeout", "cubrid_version"] + b["cURL"] = Set.new ["curl_close", "curl_copy_handle", "curl_errno", "curl_error", "curl_escape", "curl_exec", "curl_file_create", "curl_getinfo", "curl_init", "curl_multi_add_handle", "curl_multi_close", "curl_multi_errno", "curl_multi_exec", "curl_multi_getcontent", "curl_multi_info_read", "curl_multi_init", "curl_multi_remove_handle", "curl_multi_select", "curl_multi_setopt", "curl_multi_strerror", "curl_pause", "curl_reset", "curl_setopt_array", "curl_setopt", "curl_share_close", "curl_share_errno", "curl_share_init", "curl_share_setopt", "curl_share_strerror", "curl_strerror", "curl_unescape", "curl_version"] + b["Cyrus"] = Set.new ["cyrus_authenticate", "cyrus_bind", "cyrus_close", "cyrus_connect", "cyrus_query", "cyrus_unbind"] + b["Date/Time"] = Set.new ["checkdate", "date_add", "date_create_from_format", "date_create_immutable_from_format", "date_create_immutable", "date_create", "date_date_set", "date_default_timezone_get", "date_default_timezone_set", "date_diff", "date_format", "date_get_last_errors", "date_interval_create_from_date_string", "date_interval_format", "date_isodate_set", "date_modify", "date_offset_get", "date_parse_from_format", "date_parse", "date_sub", "date_sun_info", "date_sunrise", "date_sunset", "date_time_set", "date_timestamp_get", "date_timestamp_set", "date_timezone_get", "date_timezone_set", "date", "getdate", "gettimeofday", "gmdate", "gmmktime", "gmstrftime", "idate", "localtime", "microtime", "mktime", "strftime", "strptime", "strtotime", "time", "timezone_abbreviations_list", "timezone_identifiers_list", "timezone_location_get", "timezone_name_from_abbr", "timezone_name_get", "timezone_offset_get", "timezone_open", "timezone_transitions_get", "timezone_version_get"] + b["DBA"] = Set.new ["dba_close", "dba_delete", "dba_exists", "dba_fetch", "dba_firstkey", "dba_handlers", "dba_insert", "dba_key_split", "dba_list", "dba_nextkey", "dba_open", "dba_optimize", "dba_popen", "dba_replace", "dba_sync"] + b["dBase"] = Set.new ["dbase_add_record", "dbase_close", "dbase_create", "dbase_delete_record", "dbase_get_header_info", "dbase_get_record_with_names", "dbase_get_record", "dbase_numfields", "dbase_numrecords", "dbase_open", "dbase_pack", "dbase_replace_record"] + b["DB++"] = Set.new ["dbplus_add", "dbplus_aql", "dbplus_chdir", "dbplus_close", "dbplus_curr", "dbplus_errcode", "dbplus_errno", "dbplus_find", "dbplus_first", "dbplus_flush", "dbplus_freealllocks", "dbplus_freelock", "dbplus_freerlocks", "dbplus_getlock", "dbplus_getunique", "dbplus_info", "dbplus_last", "dbplus_lockrel", "dbplus_next", "dbplus_open", "dbplus_prev", "dbplus_rchperm", "dbplus_rcreate", "dbplus_rcrtexact", "dbplus_rcrtlike", "dbplus_resolve", "dbplus_restorepos", "dbplus_rkeys", "dbplus_ropen", "dbplus_rquery", "dbplus_rrename", "dbplus_rsecindex", "dbplus_runlink", "dbplus_rzap", "dbplus_savepos", "dbplus_setindex", "dbplus_setindexbynumber", "dbplus_sql", "dbplus_tcl", "dbplus_tremove", "dbplus_undo", "dbplus_undoprepare", "dbplus_unlockrel", "dbplus_unselect", "dbplus_update", "dbplus_xlockrel", "dbplus_xunlockrel"] + b["dbx"] = Set.new ["dbx_close", "dbx_compare", "dbx_connect", "dbx_error", "dbx_escape_string", "dbx_fetch_row", "dbx_query", "dbx_sort"] + b["Direct IO"] = Set.new ["dio_close", "dio_fcntl", "dio_open", "dio_read", "dio_seek", "dio_stat", "dio_tcsetattr", "dio_truncate", "dio_write"] + b["Directory"] = Set.new ["chdir", "chroot", "closedir", "dir", "getcwd", "opendir", "readdir", "rewinddir", "scandir"] + b["DOM"] = Set.new ["dom_import_simplexml"] + b["Eio"] = Set.new ["eio_busy", "eio_cancel", "eio_chmod", "eio_chown", "eio_close", "eio_custom", "eio_dup2", "eio_event_loop", "eio_fallocate", "eio_fchmod", "eio_fchown", "eio_fdatasync", "eio_fstat", "eio_fstatvfs", "eio_fsync", "eio_ftruncate", "eio_futime", "eio_get_event_stream", "eio_get_last_error", "eio_grp_add", "eio_grp_cancel", "eio_grp_limit", "eio_grp", "eio_init", "eio_link", "eio_lstat", "eio_mkdir", "eio_mknod", "eio_nop", "eio_npending", "eio_nready", "eio_nreqs", "eio_nthreads", "eio_open", "eio_poll", "eio_read", "eio_readahead", "eio_readdir", "eio_readlink", "eio_realpath", "eio_rename", "eio_rmdir", "eio_seek", "eio_sendfile", "eio_set_max_idle", "eio_set_max_parallel", "eio_set_max_poll_reqs", "eio_set_max_poll_time", "eio_set_min_parallel", "eio_stat", "eio_statvfs", "eio_symlink", "eio_sync_file_range", "eio_sync", "eio_syncfs", "eio_truncate", "eio_unlink", "eio_utime", "eio_write"] + b["Enchant"] = Set.new ["enchant_broker_describe", "enchant_broker_dict_exists", "enchant_broker_free_dict", "enchant_broker_free", "enchant_broker_get_dict_path", "enchant_broker_get_error", "enchant_broker_init", "enchant_broker_list_dicts", "enchant_broker_request_dict", "enchant_broker_request_pwl_dict", "enchant_broker_set_dict_path", "enchant_broker_set_ordering", "enchant_dict_add_to_personal", "enchant_dict_add_to_session", "enchant_dict_check", "enchant_dict_describe", "enchant_dict_get_error", "enchant_dict_is_in_session", "enchant_dict_quick_check", "enchant_dict_store_replacement", "enchant_dict_suggest"] + b["Error Handling"] = Set.new ["debug_backtrace", "debug_print_backtrace", "error_clear_last", "error_get_last", "error_log", "error_reporting", "restore_error_handler", "restore_exception_handler", "set_error_handler", "set_exception_handler", "trigger_error", "user_error"] + b["Program execution"] = Set.new ["escapeshellarg", "escapeshellcmd", "exec", "passthru", "proc_close", "proc_get_status", "proc_nice", "proc_open", "proc_terminate", "shell_exec", "system"] + b["Exif"] = Set.new ["exif_imagetype", "exif_read_data", "exif_tagname", "exif_thumbnail", "read_exif_data"] + b["Expect"] = Set.new ["expect_expectl", "expect_popen"] + b["FAM"] = Set.new ["fam_cancel_monitor", "fam_close", "fam_monitor_collection", "fam_monitor_directory", "fam_monitor_file", "fam_next_event", "fam_open", "fam_pending", "fam_resume_monitor", "fam_suspend_monitor"] + b["Fann"] = Set.new ["fann_cascadetrain_on_data", "fann_cascadetrain_on_file", "fann_clear_scaling_params", "fann_copy", "fann_create_from_file", "fann_create_shortcut_array", "fann_create_shortcut", "fann_create_sparse_array", "fann_create_sparse", "fann_create_standard_array", "fann_create_standard", "fann_create_train_from_callback", "fann_create_train", "fann_descale_input", "fann_descale_output", "fann_descale_train", "fann_destroy_train", "fann_destroy", "fann_duplicate_train_data", "fann_get_activation_function", "fann_get_activation_steepness", "fann_get_bias_array", "fann_get_bit_fail_limit", "fann_get_bit_fail", "fann_get_cascade_activation_functions_count", "fann_get_cascade_activation_functions", "fann_get_cascade_activation_steepnesses_count", "fann_get_cascade_activation_steepnesses", "fann_get_cascade_candidate_change_fraction", "fann_get_cascade_candidate_limit", "fann_get_cascade_candidate_stagnation_epochs", "fann_get_cascade_max_cand_epochs", "fann_get_cascade_max_out_epochs", "fann_get_cascade_min_cand_epochs", "fann_get_cascade_min_out_epochs", "fann_get_cascade_num_candidate_groups", "fann_get_cascade_num_candidates", "fann_get_cascade_output_change_fraction", "fann_get_cascade_output_stagnation_epochs", "fann_get_cascade_weight_multiplier", "fann_get_connection_array", "fann_get_connection_rate", "fann_get_errno", "fann_get_errstr", "fann_get_layer_array", "fann_get_learning_momentum", "fann_get_learning_rate", "fann_get_MSE", "fann_get_network_type", "fann_get_num_input", "fann_get_num_layers", "fann_get_num_output", "fann_get_quickprop_decay", "fann_get_quickprop_mu", "fann_get_rprop_decrease_factor", "fann_get_rprop_delta_max", "fann_get_rprop_delta_min", "fann_get_rprop_delta_zero", "fann_get_rprop_increase_factor", "fann_get_sarprop_step_error_shift", "fann_get_sarprop_step_error_threshold_factor", "fann_get_sarprop_temperature", "fann_get_sarprop_weight_decay_shift", "fann_get_total_connections", "fann_get_total_neurons", "fann_get_train_error_function", "fann_get_train_stop_function", "fann_get_training_algorithm", "fann_init_weights", "fann_length_train_data", "fann_merge_train_data", "fann_num_input_train_data", "fann_num_output_train_data", "fann_print_error", "fann_randomize_weights", "fann_read_train_from_file", "fann_reset_errno", "fann_reset_errstr", "fann_reset_MSE", "fann_run", "fann_save_train", "fann_save", "fann_scale_input_train_data", "fann_scale_input", "fann_scale_output_train_data", "fann_scale_output", "fann_scale_train_data", "fann_scale_train", "fann_set_activation_function_hidden", "fann_set_activation_function_layer", "fann_set_activation_function_output", "fann_set_activation_function", "fann_set_activation_steepness_hidden", "fann_set_activation_steepness_layer", "fann_set_activation_steepness_output", "fann_set_activation_steepness", "fann_set_bit_fail_limit", "fann_set_callback", "fann_set_cascade_activation_functions", "fann_set_cascade_activation_steepnesses", "fann_set_cascade_candidate_change_fraction", "fann_set_cascade_candidate_limit", "fann_set_cascade_candidate_stagnation_epochs", "fann_set_cascade_max_cand_epochs", "fann_set_cascade_max_out_epochs", "fann_set_cascade_min_cand_epochs", "fann_set_cascade_min_out_epochs", "fann_set_cascade_num_candidate_groups", "fann_set_cascade_output_change_fraction", "fann_set_cascade_output_stagnation_epochs", "fann_set_cascade_weight_multiplier", "fann_set_error_log", "fann_set_input_scaling_params", "fann_set_learning_momentum", "fann_set_learning_rate", "fann_set_output_scaling_params", "fann_set_quickprop_decay", "fann_set_quickprop_mu", "fann_set_rprop_decrease_factor", "fann_set_rprop_delta_max", "fann_set_rprop_delta_min", "fann_set_rprop_delta_zero", "fann_set_rprop_increase_factor", "fann_set_sarprop_step_error_shift", "fann_set_sarprop_step_error_threshold_factor", "fann_set_sarprop_temperature", "fann_set_sarprop_weight_decay_shift", "fann_set_scaling_params", "fann_set_train_error_function", "fann_set_train_stop_function", "fann_set_training_algorithm", "fann_set_weight_array", "fann_set_weight", "fann_shuffle_train_data", "fann_subset_train_data", "fann_test_data", "fann_test", "fann_train_epoch", "fann_train_on_data", "fann_train_on_file", "fann_train"] + b["FrontBase"] = Set.new ["fbsql_affected_rows", "fbsql_autocommit", "fbsql_blob_size", "fbsql_change_user", "fbsql_clob_size", "fbsql_close", "fbsql_commit", "fbsql_connect", "fbsql_create_blob", "fbsql_create_clob", "fbsql_create_db", "fbsql_data_seek", "fbsql_database_password", "fbsql_database", "fbsql_db_query", "fbsql_db_status", "fbsql_drop_db", "fbsql_errno", "fbsql_error", "fbsql_fetch_array", "fbsql_fetch_assoc", "fbsql_fetch_field", "fbsql_fetch_lengths", "fbsql_fetch_object", "fbsql_fetch_row", "fbsql_field_flags", "fbsql_field_len", "fbsql_field_name", "fbsql_field_seek", "fbsql_field_table", "fbsql_field_type", "fbsql_free_result", "fbsql_get_autostart_info", "fbsql_hostname", "fbsql_insert_id", "fbsql_list_dbs", "fbsql_list_fields", "fbsql_list_tables", "fbsql_next_result", "fbsql_num_fields", "fbsql_num_rows", "fbsql_password", "fbsql_pconnect", "fbsql_query", "fbsql_read_blob", "fbsql_read_clob", "fbsql_result", "fbsql_rollback", "fbsql_rows_fetched", "fbsql_select_db", "fbsql_set_characterset", "fbsql_set_lob_mode", "fbsql_set_password", "fbsql_set_transaction", "fbsql_start_db", "fbsql_stop_db", "fbsql_table_name", "fbsql_tablename", "fbsql_username", "fbsql_warnings"] + b["FDF"] = Set.new ["fdf_add_doc_javascript", "fdf_add_template", "fdf_close", "fdf_create", "fdf_enum_values", "fdf_errno", "fdf_error", "fdf_get_ap", "fdf_get_attachment", "fdf_get_encoding", "fdf_get_file", "fdf_get_flags", "fdf_get_opt", "fdf_get_status", "fdf_get_value", "fdf_get_version", "fdf_header", "fdf_next_field_name", "fdf_open_string", "fdf_open", "fdf_remove_item", "fdf_save_string", "fdf_save", "fdf_set_ap", "fdf_set_encoding", "fdf_set_file", "fdf_set_flags", "fdf_set_javascript_action", "fdf_set_on_import_javascript", "fdf_set_opt", "fdf_set_status", "fdf_set_submit_form_action", "fdf_set_target_frame", "fdf_set_value", "fdf_set_version"] + b["Fileinfo"] = Set.new ["finfo_buffer", "finfo_close", "finfo_file", "finfo_open", "finfo_set_flags", "mime_content_type"] + b["filePro"] = Set.new ["filepro_fieldcount", "filepro_fieldname", "filepro_fieldtype", "filepro_fieldwidth", "filepro_retrieve", "filepro_rowcount", "filepro"] + b["Filesystem"] = Set.new ["basename", "chgrp", "chmod", "chown", "clearstatcache", "copy", "delete", "dirname", "disk_free_space", "disk_total_space", "diskfreespace", "fclose", "feof", "fflush", "fgetc", "fgetcsv", "fgets", "fgetss", "file_exists", "file_get_contents", "file_put_contents", "file", "fileatime", "filectime", "filegroup", "fileinode", "filemtime", "fileowner", "fileperms", "filesize", "filetype", "flock", "fnmatch", "fopen", "fpassthru", "fputcsv", "fputs", "fread", "fscanf", "fseek", "fstat", "ftell", "ftruncate", "fwrite", "glob", "is_dir", "is_executable", "is_file", "is_link", "is_readable", "is_uploaded_file", "is_writable", "is_writeable", "lchgrp", "lchown", "link", "linkinfo", "lstat", "mkdir", "move_uploaded_file", "parse_ini_file", "parse_ini_string", "pathinfo", "pclose", "popen", "readfile", "readlink", "realpath_cache_get", "realpath_cache_size", "realpath", "rename", "rewind", "rmdir", "set_file_buffer", "stat", "symlink", "tempnam", "tmpfile", "touch", "umask", "unlink"] + b["Filter"] = Set.new ["filter_has_var", "filter_id", "filter_input_array", "filter_input", "filter_list", "filter_var_array", "filter_var"] + b["FPM"] = Set.new ["fastcgi_finish_request"] + b["FriBiDi"] = Set.new ["fribidi_log2vis"] + b["FTP"] = Set.new ["ftp_alloc", "ftp_append", "ftp_cdup", "ftp_chdir", "ftp_chmod", "ftp_close", "ftp_connect", "ftp_delete", "ftp_exec", "ftp_fget", "ftp_fput", "ftp_get_option", "ftp_get", "ftp_login", "ftp_mdtm", "ftp_mkdir", "ftp_mlsd", "ftp_nb_continue", "ftp_nb_fget", "ftp_nb_fput", "ftp_nb_get", "ftp_nb_put", "ftp_nlist", "ftp_pasv", "ftp_put", "ftp_pwd", "ftp_quit", "ftp_raw", "ftp_rawlist", "ftp_rename", "ftp_rmdir", "ftp_set_option", "ftp_site", "ftp_size", "ftp_ssl_connect", "ftp_systype"] + b["Function handling"] = Set.new ["call_user_func_array", "call_user_func", "create_function", "forward_static_call_array", "forward_static_call", "func_get_arg", "func_get_args", "func_num_args", "function_exists", "get_defined_functions", "register_shutdown_function", "register_tick_function", "unregister_tick_function"] + b["GeoIP"] = Set.new ["geoip_asnum_by_name", "geoip_continent_code_by_name", "geoip_country_code_by_name", "geoip_country_code3_by_name", "geoip_country_name_by_name", "geoip_database_info", "geoip_db_avail", "geoip_db_filename", "geoip_db_get_all_info", "geoip_domain_by_name", "geoip_id_by_name", "geoip_isp_by_name", "geoip_netspeedcell_by_name", "geoip_org_by_name", "geoip_record_by_name", "geoip_region_by_name", "geoip_region_name_by_code", "geoip_setup_custom_directory", "geoip_time_zone_by_country_and_region"] + b["Gettext"] = Set.new ["bind_textdomain_codeset", "bindtextdomain", "dcgettext", "dcngettext", "dgettext", "dngettext", "gettext", "ngettext", "textdomain"] + b["GMP"] = Set.new ["gmp_abs", "gmp_add", "gmp_and", "gmp_binomial", "gmp_clrbit", "gmp_cmp", "gmp_com", "gmp_div_q", "gmp_div_qr", "gmp_div_r", "gmp_div", "gmp_divexact", "gmp_export", "gmp_fact", "gmp_gcd", "gmp_gcdext", "gmp_hamdist", "gmp_import", "gmp_init", "gmp_intval", "gmp_invert", "gmp_jacobi", "gmp_kronecker", "gmp_lcm", "gmp_legendre", "gmp_mod", "gmp_mul", "gmp_neg", "gmp_nextprime", "gmp_or", "gmp_perfect_power", "gmp_perfect_square", "gmp_popcount", "gmp_pow", "gmp_powm", "gmp_prob_prime", "gmp_random_bits", "gmp_random_range", "gmp_random_seed", "gmp_random", "gmp_root", "gmp_rootrem", "gmp_scan0", "gmp_scan1", "gmp_setbit", "gmp_sign", "gmp_sqrt", "gmp_sqrtrem", "gmp_strval", "gmp_sub", "gmp_testbit", "gmp_xor"] + b["GnuPG"] = Set.new ["gnupg_adddecryptkey", "gnupg_addencryptkey", "gnupg_addsignkey", "gnupg_cleardecryptkeys", "gnupg_clearencryptkeys", "gnupg_clearsignkeys", "gnupg_decrypt", "gnupg_decryptverify", "gnupg_encrypt", "gnupg_encryptsign", "gnupg_export", "gnupg_geterror", "gnupg_getprotocol", "gnupg_import", "gnupg_init", "gnupg_keyinfo", "gnupg_setarmor", "gnupg_seterrormode", "gnupg_setsignmode", "gnupg_sign", "gnupg_verify"] + b["Gupnp"] = Set.new ["gupnp_context_get_host_ip", "gupnp_context_get_port", "gupnp_context_get_subscription_timeout", "gupnp_context_host_path", "gupnp_context_new", "gupnp_context_set_subscription_timeout", "gupnp_context_timeout_add", "gupnp_context_unhost_path", "gupnp_control_point_browse_start", "gupnp_control_point_browse_stop", "gupnp_control_point_callback_set", "gupnp_control_point_new", "gupnp_device_action_callback_set", "gupnp_device_info_get_service", "gupnp_device_info_get", "gupnp_root_device_get_available", "gupnp_root_device_get_relative_location", "gupnp_root_device_new", "gupnp_root_device_set_available", "gupnp_root_device_start", "gupnp_root_device_stop", "gupnp_service_action_get", "gupnp_service_action_return_error", "gupnp_service_action_return", "gupnp_service_action_set", "gupnp_service_freeze_notify", "gupnp_service_info_get_introspection", "gupnp_service_info_get", "gupnp_service_introspection_get_state_variable", "gupnp_service_notify", "gupnp_service_proxy_action_get", "gupnp_service_proxy_action_set", "gupnp_service_proxy_add_notify", "gupnp_service_proxy_callback_set", "gupnp_service_proxy_get_subscribed", "gupnp_service_proxy_remove_notify", "gupnp_service_proxy_set_subscribed", "gupnp_service_thaw_notify"] + b["Hash"] = Set.new ["hash_algos", "hash_copy", "hash_equals", "hash_file", "hash_final", "hash_hkdf", "hash_hmac_algos", "hash_hmac_file", "hash_hmac", "hash_init", "hash_pbkdf2", "hash_update_file", "hash_update_stream", "hash_update", "hash"] + b["Hyperwave API"] = Set.new ["hwapi_attribute_new", "hwapi_content_new", "hwapi_hgcsp", "hwapi_object_new"] + b["Firebird/InterBase"] = Set.new ["fbird_add_user", "fbird_affected_rows", "fbird_backup", "fbird_blob_add", "fbird_blob_cancel", "fbird_blob_close", "fbird_blob_create", "fbird_blob_echo", "fbird_blob_get", "fbird_blob_import", "fbird_blob_info", "fbird_blob_open", "fbird_close", "fbird_commit_ret", "fbird_commit", "fbird_connect", "fbird_db_info", "fbird_delete_user", "fbird_drop_db", "fbird_errcode", "fbird_errmsg", "fbird_execute", "fbird_fetch_assoc", "fbird_fetch_object", "fbird_fetch_row", "fbird_field_info", "fbird_free_event_handler", "fbird_free_query", "fbird_free_result", "fbird_gen_id", "fbird_maintain_db", "fbird_modify_user", "fbird_name_result", "fbird_num_fields", "fbird_num_params", "fbird_param_info", "fbird_pconnect", "fbird_prepare", "fbird_query", "fbird_restore", "fbird_rollback_ret", "fbird_rollback", "fbird_server_info", "fbird_service_attach", "fbird_service_detach", "fbird_set_event_handler", "fbird_trans", "fbird_wait_event", "ibase_add_user", "ibase_affected_rows", "ibase_backup", "ibase_blob_add", "ibase_blob_cancel", "ibase_blob_close", "ibase_blob_create", "ibase_blob_echo", "ibase_blob_get", "ibase_blob_import", "ibase_blob_info", "ibase_blob_open", "ibase_close", "ibase_commit_ret", "ibase_commit", "ibase_connect", "ibase_db_info", "ibase_delete_user", "ibase_drop_db", "ibase_errcode", "ibase_errmsg", "ibase_execute", "ibase_fetch_assoc", "ibase_fetch_object", "ibase_fetch_row", "ibase_field_info", "ibase_free_event_handler", "ibase_free_query", "ibase_free_result", "ibase_gen_id", "ibase_maintain_db", "ibase_modify_user", "ibase_name_result", "ibase_num_fields", "ibase_num_params", "ibase_param_info", "ibase_pconnect", "ibase_prepare", "ibase_query", "ibase_restore", "ibase_rollback_ret", "ibase_rollback", "ibase_server_info", "ibase_service_attach", "ibase_service_detach", "ibase_set_event_handler", "ibase_trans", "ibase_wait_event"] + b["IBM DB2"] = Set.new ["db2_autocommit", "db2_bind_param", "db2_client_info", "db2_close", "db2_column_privileges", "db2_columns", "db2_commit", "db2_conn_error", "db2_conn_errormsg", "db2_connect", "db2_cursor_type", "db2_escape_string", "db2_exec", "db2_execute", "db2_fetch_array", "db2_fetch_assoc", "db2_fetch_both", "db2_fetch_object", "db2_fetch_row", "db2_field_display_size", "db2_field_name", "db2_field_num", "db2_field_precision", "db2_field_scale", "db2_field_type", "db2_field_width", "db2_foreign_keys", "db2_free_result", "db2_free_stmt", "db2_get_option", "db2_last_insert_id", "db2_lob_read", "db2_next_result", "db2_num_fields", "db2_num_rows", "db2_pclose", "db2_pconnect", "db2_prepare", "db2_primary_keys", "db2_procedure_columns", "db2_procedures", "db2_result", "db2_rollback", "db2_server_info", "db2_set_option", "db2_special_columns", "db2_statistics", "db2_stmt_error", "db2_stmt_errormsg", "db2_table_privileges", "db2_tables"] + b["iconv"] = Set.new ["iconv_get_encoding", "iconv_mime_decode_headers", "iconv_mime_decode", "iconv_mime_encode", "iconv_set_encoding", "iconv_strlen", "iconv_strpos", "iconv_strrpos", "iconv_substr", "iconv", "ob_iconv_handler"] + b["ID3"] = Set.new ["id3_get_frame_long_name", "id3_get_frame_short_name", "id3_get_genre_id", "id3_get_genre_list", "id3_get_genre_name", "id3_get_tag", "id3_get_version", "id3_remove_tag", "id3_set_tag"] + b["Informix"] = Set.new ["ifx_affected_rows", "ifx_blobinfile_mode", "ifx_byteasvarchar", "ifx_close", "ifx_connect", "ifx_copy_blob", "ifx_create_blob", "ifx_create_char", "ifx_do", "ifx_error", "ifx_errormsg", "ifx_fetch_row", "ifx_fieldproperties", "ifx_fieldtypes", "ifx_free_blob", "ifx_free_char", "ifx_free_result", "ifx_get_blob", "ifx_get_char", "ifx_getsqlca", "ifx_htmltbl_result", "ifx_nullformat", "ifx_num_fields", "ifx_num_rows", "ifx_pconnect", "ifx_prepare", "ifx_query", "ifx_textasvarchar", "ifx_update_blob", "ifx_update_char", "ifxus_close_slob", "ifxus_create_slob", "ifxus_free_slob", "ifxus_open_slob", "ifxus_read_slob", "ifxus_seek_slob", "ifxus_tell_slob", "ifxus_write_slob"] + b["IIS"] = Set.new ["iis_add_server", "iis_get_dir_security", "iis_get_script_map", "iis_get_server_by_comment", "iis_get_server_by_path", "iis_get_server_rights", "iis_get_service_state", "iis_remove_server", "iis_set_app_settings", "iis_set_dir_security", "iis_set_script_map", "iis_set_server_rights", "iis_start_server", "iis_start_service", "iis_stop_server", "iis_stop_service"] + b["GD and Image"] = Set.new ["gd_info", "getimagesize", "getimagesizefromstring", "image_type_to_extension", "image_type_to_mime_type", "image2wbmp", "imageaffine", "imageaffinematrixconcat", "imageaffinematrixget", "imagealphablending", "imageantialias", "imagearc", "imagebmp", "imagechar", "imagecharup", "imagecolorallocate", "imagecolorallocatealpha", "imagecolorat", "imagecolorclosest", "imagecolorclosestalpha", "imagecolorclosesthwb", "imagecolordeallocate", "imagecolorexact", "imagecolorexactalpha", "imagecolormatch", "imagecolorresolve", "imagecolorresolvealpha", "imagecolorset", "imagecolorsforindex", "imagecolorstotal", "imagecolortransparent", "imageconvolution", "imagecopy", "imagecopymerge", "imagecopymergegray", "imagecopyresampled", "imagecopyresized", "imagecreate", "imagecreatefrombmp", "imagecreatefromgd2", "imagecreatefromgd2part", "imagecreatefromgd", "imagecreatefromgif", "imagecreatefromjpeg", "imagecreatefrompng", "imagecreatefromstring", "imagecreatefromwbmp", "imagecreatefromwebp", "imagecreatefromxbm", "imagecreatefromxpm", "imagecreatetruecolor", "imagecrop", "imagecropauto", "imagedashedline", "imagedestroy", "imageellipse", "imagefill", "imagefilledarc", "imagefilledellipse", "imagefilledpolygon", "imagefilledrectangle", "imagefilltoborder", "imagefilter", "imageflip", "imagefontheight", "imagefontwidth", "imageftbbox", "imagefttext", "imagegammacorrect", "imagegd2", "imagegd", "imagegetclip", "imagegif", "imagegrabscreen", "imagegrabwindow", "imageinterlace", "imageistruecolor", "imagejpeg", "imagelayereffect", "imageline", "imageloadfont", "imageopenpolygon", "imagepalettecopy", "imagepalettetotruecolor", "imagepng", "imagepolygon", "imagepsbbox", "imagepsencodefont", "imagepsextendfont", "imagepsfreefont", "imagepsloadfont", "imagepsslantfont", "imagepstext", "imagerectangle", "imageresolution", "imagerotate", "imagesavealpha", "imagescale", "imagesetbrush", "imagesetclip", "imagesetinterpolation", "imagesetpixel", "imagesetstyle", "imagesetthickness", "imagesettile", "imagestring", "imagestringup", "imagesx", "imagesy", "imagetruecolortopalette", "imagettfbbox", "imagettftext", "imagetypes", "imagewbmp", "imagewebp", "imagexbm", "iptcembed", "iptcparse", "jpeg2wbmp", "png2wbmp"] + b["IMAP"] = Set.new ["imap_8bit", "imap_alerts", "imap_append", "imap_base64", "imap_binary", "imap_body", "imap_bodystruct", "imap_check", "imap_clearflag_full", "imap_close", "imap_create", "imap_createmailbox", "imap_delete", "imap_deletemailbox", "imap_errors", "imap_expunge", "imap_fetch_overview", "imap_fetchbody", "imap_fetchheader", "imap_fetchmime", "imap_fetchstructure", "imap_fetchtext", "imap_gc", "imap_get_quota", "imap_get_quotaroot", "imap_getacl", "imap_getmailboxes", "imap_getsubscribed", "imap_header", "imap_headerinfo", "imap_headers", "imap_last_error", "imap_list", "imap_listmailbox", "imap_listscan", "imap_listsubscribed", "imap_lsub", "imap_mail_compose", "imap_mail_copy", "imap_mail_move", "imap_mail", "imap_mailboxmsginfo", "imap_mime_header_decode", "imap_msgno", "imap_mutf7_to_utf8", "imap_num_msg", "imap_num_recent", "imap_open", "imap_ping", "imap_qprint", "imap_rename", "imap_renamemailbox", "imap_reopen", "imap_rfc822_parse_adrlist", "imap_rfc822_parse_headers", "imap_rfc822_write_address", "imap_savebody", "imap_scan", "imap_scanmailbox", "imap_search", "imap_set_quota", "imap_setacl", "imap_setflag_full", "imap_sort", "imap_status", "imap_subscribe", "imap_thread", "imap_timeout", "imap_uid", "imap_undelete", "imap_unsubscribe", "imap_utf7_decode", "imap_utf7_encode", "imap_utf8_to_mutf7", "imap_utf8"] + b["inclued"] = Set.new ["inclued_get_data"] + b["PHP Options/Info"] = Set.new ["assert_options", "assert", "cli_get_process_title", "cli_set_process_title", "dl", "extension_loaded", "gc_collect_cycles", "gc_disable", "gc_enable", "gc_enabled", "gc_mem_caches", "gc_status", "get_cfg_var", "get_current_user", "get_defined_constants", "get_extension_funcs", "get_include_path", "get_included_files", "get_loaded_extensions", "get_magic_quotes_gpc", "get_magic_quotes_runtime", "get_required_files", "get_resources", "getenv", "getlastmod", "getmygid", "getmyinode", "getmypid", "getmyuid", "getopt", "getrusage", "ini_alter", "ini_get_all", "ini_get", "ini_restore", "ini_set", "magic_quotes_runtime", "main", "memory_get_peak_usage", "memory_get_usage", "php_ini_loaded_file", "php_ini_scanned_files", "php_logo_guid", "php_sapi_name", "php_uname", "phpcredits", "phpinfo", "phpversion", "putenv", "restore_include_path", "set_include_path", "set_magic_quotes_runtime", "set_time_limit", "sys_get_temp_dir", "version_compare", "zend_logo_guid", "zend_thread_id", "zend_version"] + b["Ingres"] = Set.new ["ingres_autocommit_state", "ingres_autocommit", "ingres_charset", "ingres_close", "ingres_commit", "ingres_connect", "ingres_cursor", "ingres_errno", "ingres_error", "ingres_errsqlstate", "ingres_escape_string", "ingres_execute", "ingres_fetch_array", "ingres_fetch_assoc", "ingres_fetch_object", "ingres_fetch_proc_return", "ingres_fetch_row", "ingres_field_length", "ingres_field_name", "ingres_field_nullable", "ingres_field_precision", "ingres_field_scale", "ingres_field_type", "ingres_free_result", "ingres_next_error", "ingres_num_fields", "ingres_num_rows", "ingres_pconnect", "ingres_prepare", "ingres_query", "ingres_result_seek", "ingres_rollback", "ingres_set_environment", "ingres_unbuffered_query"] + b["Inotify"] = Set.new ["inotify_add_watch", "inotify_init", "inotify_queue_len", "inotify_read", "inotify_rm_watch"] + b["Grapheme"] = Set.new ["grapheme_extract", "grapheme_stripos", "grapheme_stristr", "grapheme_strlen", "grapheme_strpos", "grapheme_strripos", "grapheme_strrpos", "grapheme_strstr", "grapheme_substr"] + b["intl"] = Set.new ["intl_error_name", "intl_get_error_code", "intl_get_error_message", "intl_is_failure"] + b["IDN"] = Set.new ["idn_to_ascii", "idn_to_utf8"] + b["JSON"] = Set.new ["json_decode", "json_encode", "json_last_error_msg", "json_last_error"] + b["Judy"] = Set.new ["judy_type", "judy_version"] + b["KADM5"] = Set.new ["kadm5_chpass_principal", "kadm5_create_principal", "kadm5_delete_principal", "kadm5_destroy", "kadm5_flush", "kadm5_get_policies", "kadm5_get_principal", "kadm5_get_principals", "kadm5_init_with_password", "kadm5_modify_principal"] + b["LDAP"] = Set.new ["ldap_8859_to_t61", "ldap_add_ext", "ldap_add", "ldap_bind_ext", "ldap_bind", "ldap_close", "ldap_compare", "ldap_connect", "ldap_control_paged_result_response", "ldap_control_paged_result", "ldap_count_entries", "ldap_delete_ext", "ldap_delete", "ldap_dn2ufn", "ldap_err2str", "ldap_errno", "ldap_error", "ldap_escape", "ldap_exop_passwd", "ldap_exop_refresh", "ldap_exop_whoami", "ldap_exop", "ldap_explode_dn", "ldap_first_attribute", "ldap_first_entry", "ldap_first_reference", "ldap_free_result", "ldap_get_attributes", "ldap_get_dn", "ldap_get_entries", "ldap_get_option", "ldap_get_values_len", "ldap_get_values", "ldap_list", "ldap_mod_add_ext", "ldap_mod_add", "ldap_mod_del_ext", "ldap_mod_del", "ldap_mod_replace_ext", "ldap_mod_replace", "ldap_modify_batch", "ldap_modify", "ldap_next_attribute", "ldap_next_entry", "ldap_next_reference", "ldap_parse_exop", "ldap_parse_reference", "ldap_parse_result", "ldap_read", "ldap_rename_ext", "ldap_rename", "ldap_sasl_bind", "ldap_search", "ldap_set_option", "ldap_set_rebind_proc", "ldap_sort", "ldap_start_tls", "ldap_t61_to_8859", "ldap_unbind"] + b["Libevent"] = Set.new ["event_add", "event_base_free", "event_base_loop", "event_base_loopbreak", "event_base_loopexit", "event_base_new", "event_base_priority_init", "event_base_reinit", "event_base_set", "event_buffer_base_set", "event_buffer_disable", "event_buffer_enable", "event_buffer_fd_set", "event_buffer_free", "event_buffer_new", "event_buffer_priority_set", "event_buffer_read", "event_buffer_set_callback", "event_buffer_timeout_set", "event_buffer_watermark_set", "event_buffer_write", "event_del", "event_free", "event_new", "event_priority_set", "event_set", "event_timer_add", "event_timer_del", "event_timer_new", "event_timer_set"] + b["libxml"] = Set.new ["libxml_clear_errors", "libxml_disable_entity_loader", "libxml_get_errors", "libxml_get_last_error", "libxml_set_external_entity_loader", "libxml_set_streams_context", "libxml_use_internal_errors"] + b["LZF"] = Set.new ["lzf_compress", "lzf_decompress", "lzf_optimized_for"] + b["Mail"] = Set.new ["ezmlm_hash", "mail"] + b["Mailparse"] = Set.new ["mailparse_determine_best_xfer_encoding", "mailparse_msg_create", "mailparse_msg_extract_part_file", "mailparse_msg_extract_part", "mailparse_msg_extract_whole_part_file", "mailparse_msg_free", "mailparse_msg_get_part_data", "mailparse_msg_get_part", "mailparse_msg_get_structure", "mailparse_msg_parse_file", "mailparse_msg_parse", "mailparse_rfc822_parse_addresses", "mailparse_stream_encode", "mailparse_uudecode_all"] + b["Math"] = Set.new ["abs", "acos", "acosh", "asin", "asinh", "atan2", "atan", "atanh", "base_convert", "bindec", "ceil", "cos", "cosh", "decbin", "dechex", "decoct", "deg2rad", "exp", "expm1", "floor", "fmod", "getrandmax", "hexdec", "hypot", "intdiv", "is_finite", "is_infinite", "is_nan", "lcg_value", "log10", "log1p", "log", "max", "min", "mt_getrandmax", "mt_rand", "mt_srand", "octdec", "pi", "pow", "rad2deg", "rand", "round", "sin", "sinh", "sqrt", "srand", "tan", "tanh"] + b["MaxDB"] = Set.new ["maxdb_affected_rows", "maxdb_autocommit", "maxdb_bind_param", "maxdb_bind_result", "maxdb_change_user", "maxdb_character_set_name", "maxdb_client_encoding", "maxdb_close_long_data", "maxdb_close", "maxdb_commit", "maxdb_connect_errno", "maxdb_connect_error", "maxdb_connect", "maxdb_data_seek", "maxdb_debug", "maxdb_disable_reads_from_master", "maxdb_disable_rpl_parse", "maxdb_dump_debug_info", "maxdb_embedded_connect", "maxdb_enable_reads_from_master", "maxdb_enable_rpl_parse", "maxdb_errno", "maxdb_error", "maxdb_escape_string", "maxdb_execute", "maxdb_fetch_array", "maxdb_fetch_assoc", "maxdb_fetch_field_direct", "maxdb_fetch_field", "maxdb_fetch_fields", "maxdb_fetch_lengths", "maxdb_fetch_object", "maxdb_fetch_row", "maxdb_fetch", "maxdb_field_count", "maxdb_field_seek", "maxdb_field_tell", "maxdb_free_result", "maxdb_get_client_info", "maxdb_get_client_version", "maxdb_get_host_info", "maxdb_get_metadata", "maxdb_get_proto_info", "maxdb_get_server_info", "maxdb_get_server_version", "maxdb_info", "maxdb_init", "maxdb_insert_id", "maxdb_kill", "maxdb_master_query", "maxdb_more_results", "maxdb_multi_query", "maxdb_next_result", "maxdb_num_fields", "maxdb_num_rows", "maxdb_options", "maxdb_param_count", "maxdb_ping", "maxdb_prepare", "maxdb_query", "maxdb_real_connect", "maxdb_real_escape_string", "maxdb_real_query", "maxdb_report", "maxdb_rollback", "maxdb_rpl_parse_enabled", "maxdb_rpl_probe", "maxdb_rpl_query_type", "maxdb_select_db", "maxdb_send_long_data", "maxdb_send_query", "maxdb_server_end", "maxdb_server_init", "maxdb_set_opt", "maxdb_sqlstate", "maxdb_ssl_set", "maxdb_stat", "maxdb_stmt_affected_rows", "maxdb_stmt_bind_param", "maxdb_stmt_bind_result", "maxdb_stmt_close_long_data", "maxdb_stmt_close", "maxdb_stmt_data_seek", "maxdb_stmt_errno", "maxdb_stmt_error", "maxdb_stmt_execute", "maxdb_stmt_fetch", "maxdb_stmt_free_result", "maxdb_stmt_init", "maxdb_stmt_num_rows", "maxdb_stmt_param_count", "maxdb_stmt_prepare", "maxdb_stmt_reset", "maxdb_stmt_result_metadata", "maxdb_stmt_send_long_data", "maxdb_stmt_sqlstate", "maxdb_stmt_store_result", "maxdb_store_result", "maxdb_thread_id", "maxdb_thread_safe", "maxdb_use_result", "maxdb_warning_count"] + b["Multibyte String"] = Set.new ["mb_check_encoding", "mb_chr", "mb_convert_case", "mb_convert_encoding", "mb_convert_kana", "mb_convert_variables", "mb_decode_mimeheader", "mb_decode_numericentity", "mb_detect_encoding", "mb_detect_order", "mb_encode_mimeheader", "mb_encode_numericentity", "mb_encoding_aliases", "mb_ereg_match", "mb_ereg_replace_callback", "mb_ereg_replace", "mb_ereg_search_getpos", "mb_ereg_search_getregs", "mb_ereg_search_init", "mb_ereg_search_pos", "mb_ereg_search_regs", "mb_ereg_search_setpos", "mb_ereg_search", "mb_ereg", "mb_eregi_replace", "mb_eregi", "mb_get_info", "mb_http_input", "mb_http_output", "mb_internal_encoding", "mb_language", "mb_list_encodings", "mb_ord", "mb_output_handler", "mb_parse_str", "mb_preferred_mime_name", "mb_regex_encoding", "mb_regex_set_options", "mb_scrub", "mb_send_mail", "mb_split", "mb_str_split", "mb_strcut", "mb_strimwidth", "mb_stripos", "mb_stristr", "mb_strlen", "mb_strpos", "mb_strrchr", "mb_strrichr", "mb_strripos", "mb_strrpos", "mb_strstr", "mb_strtolower", "mb_strtoupper", "mb_strwidth", "mb_substitute_character", "mb_substr_count", "mb_substr"] + b["Mcrypt"] = Set.new ["mcrypt_cbc", "mcrypt_cfb", "mcrypt_create_iv", "mcrypt_decrypt", "mcrypt_ecb", "mcrypt_enc_get_algorithms_name", "mcrypt_enc_get_block_size", "mcrypt_enc_get_iv_size", "mcrypt_enc_get_key_size", "mcrypt_enc_get_modes_name", "mcrypt_enc_get_supported_key_sizes", "mcrypt_enc_is_block_algorithm_mode", "mcrypt_enc_is_block_algorithm", "mcrypt_enc_is_block_mode", "mcrypt_enc_self_test", "mcrypt_encrypt", "mcrypt_generic_deinit", "mcrypt_generic_end", "mcrypt_generic_init", "mcrypt_generic", "mcrypt_get_block_size", "mcrypt_get_cipher_name", "mcrypt_get_iv_size", "mcrypt_get_key_size", "mcrypt_list_algorithms", "mcrypt_list_modes", "mcrypt_module_close", "mcrypt_module_get_algo_block_size", "mcrypt_module_get_algo_key_size", "mcrypt_module_get_supported_key_sizes", "mcrypt_module_is_block_algorithm_mode", "mcrypt_module_is_block_algorithm", "mcrypt_module_is_block_mode", "mcrypt_module_open", "mcrypt_module_self_test", "mcrypt_ofb", "mdecrypt_generic"] + b["MCVE"] = Set.new ["m_checkstatus", "m_completeauthorizations", "m_connect", "m_connectionerror", "m_deletetrans", "m_destroyconn", "m_destroyengine", "m_getcell", "m_getcellbynum", "m_getcommadelimited", "m_getheader", "m_initconn", "m_initengine", "m_iscommadelimited", "m_maxconntimeout", "m_monitor", "m_numcolumns", "m_numrows", "m_parsecommadelimited", "m_responsekeys", "m_responseparam", "m_returnstatus", "m_setblocking", "m_setdropfile", "m_setip", "m_setssl_cafile", "m_setssl_files", "m_setssl", "m_settimeout", "m_sslcert_gen_hash", "m_transactionssent", "m_transinqueue", "m_transkeyval", "m_transnew", "m_transsend", "m_uwait", "m_validateidentifier", "m_verifyconnection", "m_verifysslcert"] + b["Memcache"] = Set.new ["memcache_debug"] + b["Mhash"] = Set.new ["mhash_count", "mhash_get_block_size", "mhash_get_hash_name", "mhash_keygen_s2k", "mhash"] + b["Ming"] = Set.new ["ming_keypress", "ming_setcubicthreshold", "ming_setscale", "ming_setswfcompression", "ming_useconstants", "ming_useswfversion"] + b["Misc."] = Set.new ["connection_aborted", "connection_status", "constant", "define", "defined", "die", "eval", "exit", "get_browser", "__halt_compiler", "highlight_file", "highlight_string", "hrtime", "ignore_user_abort", "pack", "php_check_syntax", "php_strip_whitespace", "sapi_windows_cp_conv", "sapi_windows_cp_get", "sapi_windows_cp_is_utf8", "sapi_windows_cp_set", "sapi_windows_generate_ctrl_event", "sapi_windows_set_ctrl_handler", "sapi_windows_vt100_support", "show_source", "sleep", "sys_getloadavg", "time_nanosleep", "time_sleep_until", "uniqid", "unpack", "usleep"] + b["mnoGoSearch"] = Set.new ["udm_add_search_limit", "udm_alloc_agent_array", "udm_alloc_agent", "udm_api_version", "udm_cat_list", "udm_cat_path", "udm_check_charset", "udm_clear_search_limits", "udm_crc32", "udm_errno", "udm_error", "udm_find", "udm_free_agent", "udm_free_ispell_data", "udm_free_res", "udm_get_doc_count", "udm_get_res_field", "udm_get_res_param", "udm_hash32", "udm_load_ispell_data", "udm_set_agent_param"] + b["Mongo"] = Set.new ["bson_decode", "bson_encode"] + b["mqseries"] = Set.new ["mqseries_back", "mqseries_begin", "mqseries_close", "mqseries_cmit", "mqseries_conn", "mqseries_connx", "mqseries_disc", "mqseries_get", "mqseries_inq", "mqseries_open", "mqseries_put1", "mqseries_put", "mqseries_set", "mqseries_strerror"] + b["Msession"] = Set.new ["msession_connect", "msession_count", "msession_create", "msession_destroy", "msession_disconnect", "msession_find", "msession_get_array", "msession_get_data", "msession_get", "msession_inc", "msession_list", "msession_listvar", "msession_lock", "msession_plugin", "msession_randstr", "msession_set_array", "msession_set_data", "msession_set", "msession_timeout", "msession_uniq", "msession_unlock"] + b["mSQL"] = Set.new ["msql_affected_rows", "msql_close", "msql_connect", "msql_create_db", "msql_createdb", "msql_data_seek", "msql_db_query", "msql_dbname", "msql_drop_db", "msql_error", "msql_fetch_array", "msql_fetch_field", "msql_fetch_object", "msql_fetch_row", "msql_field_flags", "msql_field_len", "msql_field_name", "msql_field_seek", "msql_field_table", "msql_field_type", "msql_fieldflags", "msql_fieldlen", "msql_fieldname", "msql_fieldtable", "msql_fieldtype", "msql_free_result", "msql_list_dbs", "msql_list_fields", "msql_list_tables", "msql_num_fields", "msql_num_rows", "msql_numfields", "msql_numrows", "msql_pconnect", "msql_query", "msql_regcase", "msql_result", "msql_select_db", "msql_tablename", "msql"] + b["Mssql"] = Set.new ["mssql_bind", "mssql_close", "mssql_connect", "mssql_data_seek", "mssql_execute", "mssql_fetch_array", "mssql_fetch_assoc", "mssql_fetch_batch", "mssql_fetch_field", "mssql_fetch_object", "mssql_fetch_row", "mssql_field_length", "mssql_field_name", "mssql_field_seek", "mssql_field_type", "mssql_free_result", "mssql_free_statement", "mssql_get_last_message", "mssql_guid_string", "mssql_init", "mssql_min_error_severity", "mssql_min_message_severity", "mssql_next_result", "mssql_num_fields", "mssql_num_rows", "mssql_pconnect", "mssql_query", "mssql_result", "mssql_rows_affected", "mssql_select_db"] + b["Mysql_xdevapi"] = Set.new ["expression", "getSession"] + b["MySQL"] = Set.new ["mysql_affected_rows", "mysql_client_encoding", "mysql_close", "mysql_connect", "mysql_create_db", "mysql_data_seek", "mysql_db_name", "mysql_db_query", "mysql_drop_db", "mysql_errno", "mysql_error", "mysql_escape_string", "mysql_fetch_array", "mysql_fetch_assoc", "mysql_fetch_field", "mysql_fetch_lengths", "mysql_fetch_object", "mysql_fetch_row", "mysql_field_flags", "mysql_field_len", "mysql_field_name", "mysql_field_seek", "mysql_field_table", "mysql_field_type", "mysql_free_result", "mysql_get_client_info", "mysql_get_host_info", "mysql_get_proto_info", "mysql_get_server_info", "mysql_info", "mysql_insert_id", "mysql_list_dbs", "mysql_list_fields", "mysql_list_processes", "mysql_list_tables", "mysql_num_fields", "mysql_num_rows", "mysql_pconnect", "mysql_ping", "mysql_query", "mysql_real_escape_string", "mysql_result", "mysql_select_db", "mysql_set_charset", "mysql_stat", "mysql_tablename", "mysql_thread_id", "mysql_unbuffered_query"] + b["Aliases and deprecated Mysqli"] = Set.new ["mysqli_bind_param", "mysqli_bind_result", "mysqli_client_encoding", "mysqli_connect", "mysqli_disable_rpl_parse", "mysqli_enable_reads_from_master", "mysqli_enable_rpl_parse", "mysqli_escape_string", "mysqli_execute", "mysqli_fetch", "mysqli_get_cache_stats", "mysqli_get_client_stats", "mysqli_get_links_stats", "mysqli_get_metadata", "mysqli_master_query", "mysqli_param_count", "mysqli_report", "mysqli_rpl_parse_enabled", "mysqli_rpl_probe", "mysqli_send_long_data", "mysqli_slave_query"] + b["Mysqlnd_memcache"] = Set.new ["mysqlnd_memcache_get_config", "mysqlnd_memcache_set"] + b["Mysqlnd_ms"] = Set.new ["mysqlnd_ms_dump_servers", "mysqlnd_ms_fabric_select_global", "mysqlnd_ms_fabric_select_shard", "mysqlnd_ms_get_last_gtid", "mysqlnd_ms_get_last_used_connection", "mysqlnd_ms_get_stats", "mysqlnd_ms_match_wild", "mysqlnd_ms_query_is_select", "mysqlnd_ms_set_qos", "mysqlnd_ms_set_user_pick_server", "mysqlnd_ms_xa_begin", "mysqlnd_ms_xa_commit", "mysqlnd_ms_xa_gc", "mysqlnd_ms_xa_rollback"] + b["mysqlnd_qc"] = Set.new ["mysqlnd_qc_clear_cache", "mysqlnd_qc_get_available_handlers", "mysqlnd_qc_get_cache_info", "mysqlnd_qc_get_core_stats", "mysqlnd_qc_get_normalized_query_trace_log", "mysqlnd_qc_get_query_trace_log", "mysqlnd_qc_set_cache_condition", "mysqlnd_qc_set_is_select", "mysqlnd_qc_set_storage_handler", "mysqlnd_qc_set_user_handlers"] + b["Mysqlnd_uh"] = Set.new ["mysqlnd_uh_convert_to_mysqlnd", "mysqlnd_uh_set_connection_proxy", "mysqlnd_uh_set_statement_proxy"] + b["Ncurses"] = Set.new ["ncurses_addch", "ncurses_addchnstr", "ncurses_addchstr", "ncurses_addnstr", "ncurses_addstr", "ncurses_assume_default_colors", "ncurses_attroff", "ncurses_attron", "ncurses_attrset", "ncurses_baudrate", "ncurses_beep", "ncurses_bkgd", "ncurses_bkgdset", "ncurses_border", "ncurses_bottom_panel", "ncurses_can_change_color", "ncurses_cbreak", "ncurses_clear", "ncurses_clrtobot", "ncurses_clrtoeol", "ncurses_color_content", "ncurses_color_set", "ncurses_curs_set", "ncurses_def_prog_mode", "ncurses_def_shell_mode", "ncurses_define_key", "ncurses_del_panel", "ncurses_delay_output", "ncurses_delch", "ncurses_deleteln", "ncurses_delwin", "ncurses_doupdate", "ncurses_echo", "ncurses_echochar", "ncurses_end", "ncurses_erase", "ncurses_erasechar", "ncurses_filter", "ncurses_flash", "ncurses_flushinp", "ncurses_getch", "ncurses_getmaxyx", "ncurses_getmouse", "ncurses_getyx", "ncurses_halfdelay", "ncurses_has_colors", "ncurses_has_ic", "ncurses_has_il", "ncurses_has_key", "ncurses_hide_panel", "ncurses_hline", "ncurses_inch", "ncurses_init_color", "ncurses_init_pair", "ncurses_init", "ncurses_insch", "ncurses_insdelln", "ncurses_insertln", "ncurses_insstr", "ncurses_instr", "ncurses_isendwin", "ncurses_keyok", "ncurses_keypad", "ncurses_killchar", "ncurses_longname", "ncurses_meta", "ncurses_mouse_trafo", "ncurses_mouseinterval", "ncurses_mousemask", "ncurses_move_panel", "ncurses_move", "ncurses_mvaddch", "ncurses_mvaddchnstr", "ncurses_mvaddchstr", "ncurses_mvaddnstr", "ncurses_mvaddstr", "ncurses_mvcur", "ncurses_mvdelch", "ncurses_mvgetch", "ncurses_mvhline", "ncurses_mvinch", "ncurses_mvvline", "ncurses_mvwaddstr", "ncurses_napms", "ncurses_new_panel", "ncurses_newpad", "ncurses_newwin", "ncurses_nl", "ncurses_nocbreak", "ncurses_noecho", "ncurses_nonl", "ncurses_noqiflush", "ncurses_noraw", "ncurses_pair_content", "ncurses_panel_above", "ncurses_panel_below", "ncurses_panel_window", "ncurses_pnoutrefresh", "ncurses_prefresh", "ncurses_putp", "ncurses_qiflush", "ncurses_raw", "ncurses_refresh", "ncurses_replace_panel", "ncurses_reset_prog_mode", "ncurses_reset_shell_mode", "ncurses_resetty", "ncurses_savetty", "ncurses_scr_dump", "ncurses_scr_init", "ncurses_scr_restore", "ncurses_scr_set", "ncurses_scrl", "ncurses_show_panel", "ncurses_slk_attr", "ncurses_slk_attroff", "ncurses_slk_attron", "ncurses_slk_attrset", "ncurses_slk_clear", "ncurses_slk_color", "ncurses_slk_init", "ncurses_slk_noutrefresh", "ncurses_slk_refresh", "ncurses_slk_restore", "ncurses_slk_set", "ncurses_slk_touch", "ncurses_standend", "ncurses_standout", "ncurses_start_color", "ncurses_termattrs", "ncurses_termname", "ncurses_timeout", "ncurses_top_panel", "ncurses_typeahead", "ncurses_ungetch", "ncurses_ungetmouse", "ncurses_update_panels", "ncurses_use_default_colors", "ncurses_use_env", "ncurses_use_extended_names", "ncurses_vidattr", "ncurses_vline", "ncurses_waddch", "ncurses_waddstr", "ncurses_wattroff", "ncurses_wattron", "ncurses_wattrset", "ncurses_wborder", "ncurses_wclear", "ncurses_wcolor_set", "ncurses_werase", "ncurses_wgetch", "ncurses_whline", "ncurses_wmouse_trafo", "ncurses_wmove", "ncurses_wnoutrefresh", "ncurses_wrefresh", "ncurses_wstandend", "ncurses_wstandout", "ncurses_wvline"] + b["Gopher"] = Set.new ["gopher_parsedir"] + b["Network"] = Set.new ["checkdnsrr", "closelog", "define_syslog_variables", "dns_check_record", "dns_get_mx", "dns_get_record", "fsockopen", "gethostbyaddr", "gethostbyname", "gethostbynamel", "gethostname", "getmxrr", "getprotobyname", "getprotobynumber", "getservbyname", "getservbyport", "header_register_callback", "header_remove", "header", "headers_list", "headers_sent", "http_response_code", "inet_ntop", "inet_pton", "ip2long", "long2ip", "openlog", "pfsockopen", "setcookie", "setrawcookie", "socket_get_status", "socket_set_blocking", "socket_set_timeout", "syslog"] + b["Newt"] = Set.new ["newt_bell", "newt_button_bar", "newt_button", "newt_centered_window", "newt_checkbox_get_value", "newt_checkbox_set_flags", "newt_checkbox_set_value", "newt_checkbox_tree_add_item", "newt_checkbox_tree_find_item", "newt_checkbox_tree_get_current", "newt_checkbox_tree_get_entry_value", "newt_checkbox_tree_get_multi_selection", "newt_checkbox_tree_get_selection", "newt_checkbox_tree_multi", "newt_checkbox_tree_set_current", "newt_checkbox_tree_set_entry_value", "newt_checkbox_tree_set_entry", "newt_checkbox_tree_set_width", "newt_checkbox_tree", "newt_checkbox", "newt_clear_key_buffer", "newt_cls", "newt_compact_button", "newt_component_add_callback", "newt_component_takes_focus", "newt_create_grid", "newt_cursor_off", "newt_cursor_on", "newt_delay", "newt_draw_form", "newt_draw_root_text", "newt_entry_get_value", "newt_entry_set_filter", "newt_entry_set_flags", "newt_entry_set", "newt_entry", "newt_finished", "newt_form_add_component", "newt_form_add_components", "newt_form_add_hot_key", "newt_form_destroy", "newt_form_get_current", "newt_form_run", "newt_form_set_background", "newt_form_set_height", "newt_form_set_size", "newt_form_set_timer", "newt_form_set_width", "newt_form_watch_fd", "newt_form", "newt_get_screen_size", "newt_grid_add_components_to_form", "newt_grid_basic_window", "newt_grid_free", "newt_grid_get_size", "newt_grid_h_close_stacked", "newt_grid_h_stacked", "newt_grid_place", "newt_grid_set_field", "newt_grid_simple_window", "newt_grid_v_close_stacked", "newt_grid_v_stacked", "newt_grid_wrapped_window_at", "newt_grid_wrapped_window", "newt_init", "newt_label_set_text", "newt_label", "newt_listbox_append_entry", "newt_listbox_clear_selection", "newt_listbox_clear", "newt_listbox_delete_entry", "newt_listbox_get_current", "newt_listbox_get_selection", "newt_listbox_insert_entry", "newt_listbox_item_count", "newt_listbox_select_item", "newt_listbox_set_current_by_key", "newt_listbox_set_current", "newt_listbox_set_data", "newt_listbox_set_entry", "newt_listbox_set_width", "newt_listbox", "newt_listitem_get_data", "newt_listitem_set", "newt_listitem", "newt_open_window", "newt_pop_help_line", "newt_pop_window", "newt_push_help_line", "newt_radio_get_current", "newt_radiobutton", "newt_redraw_help_line", "newt_reflow_text", "newt_refresh", "newt_resize_screen", "newt_resume", "newt_run_form", "newt_scale_set", "newt_scale", "newt_scrollbar_set", "newt_set_help_callback", "newt_set_suspend_callback", "newt_suspend", "newt_textbox_get_num_lines", "newt_textbox_reflowed", "newt_textbox_set_height", "newt_textbox_set_text", "newt_textbox", "newt_vertical_scrollbar", "newt_wait_for_key", "newt_win_choice", "newt_win_entries", "newt_win_menu", "newt_win_message", "newt_win_messagev", "newt_win_ternary"] + b["YP/NIS"] = Set.new ["yp_all", "yp_cat", "yp_err_string", "yp_errno", "yp_first", "yp_get_default_domain", "yp_master", "yp_match", "yp_next", "yp_order"] + b["NSAPI"] = Set.new ["nsapi_request_headers", "nsapi_response_headers", "nsapi_virtual"] + b["OAuth"] = Set.new ["oauth_get_sbs", "oauth_urlencode"] + b["OCI8"] = Set.new ["oci_bind_array_by_name", "oci_bind_by_name", "oci_cancel", "oci_client_version", "oci_close", "oci_commit", "oci_connect", "oci_define_by_name", "oci_error", "oci_execute", "oci_fetch_all", "oci_fetch_array", "oci_fetch_assoc", "oci_fetch_object", "oci_fetch_row", "oci_fetch", "oci_field_is_null", "oci_field_name", "oci_field_precision", "oci_field_scale", "oci_field_size", "oci_field_type_raw", "oci_field_type", "oci_free_descriptor", "oci_free_statement", "oci_get_implicit_resultset", "oci_internal_debug", "oci_lob_copy", "oci_lob_is_equal", "oci_new_collection", "oci_new_connect", "oci_new_cursor", "oci_new_descriptor", "oci_num_fields", "oci_num_rows", "oci_parse", "oci_password_change", "oci_pconnect", "oci_register_taf_callback", "oci_result", "oci_rollback", "oci_server_version", "oci_set_action", "oci_set_call_timeout", "oci_set_client_identifier", "oci_set_client_info", "oci_set_db_operation", "oci_set_edition", "oci_set_module_name", "oci_set_prefetch", "oci_statement_type", "oci_unregister_taf_callback"] + b["OPcache"] = Set.new ["opcache_compile_file", "opcache_get_configuration", "opcache_get_status", "opcache_invalidate", "opcache_is_script_cached", "opcache_reset"] + b["OpenAL"] = Set.new ["openal_buffer_create", "openal_buffer_data", "openal_buffer_destroy", "openal_buffer_get", "openal_buffer_loadwav", "openal_context_create", "openal_context_current", "openal_context_destroy", "openal_context_process", "openal_context_suspend", "openal_device_close", "openal_device_open", "openal_listener_get", "openal_listener_set", "openal_source_create", "openal_source_destroy", "openal_source_get", "openal_source_pause", "openal_source_play", "openal_source_rewind", "openal_source_set", "openal_source_stop", "openal_stream"] + b["OpenSSL"] = Set.new ["openssl_cipher_iv_length", "openssl_csr_export_to_file", "openssl_csr_export", "openssl_csr_get_public_key", "openssl_csr_get_subject", "openssl_csr_new", "openssl_csr_sign", "openssl_decrypt", "openssl_dh_compute_key", "openssl_digest", "openssl_encrypt", "openssl_error_string", "openssl_free_key", "openssl_get_cert_locations", "openssl_get_cipher_methods", "openssl_get_curve_names", "openssl_get_md_methods", "openssl_get_privatekey", "openssl_get_publickey", "openssl_open", "openssl_pbkdf2", "openssl_pkcs12_export_to_file", "openssl_pkcs12_export", "openssl_pkcs12_read", "openssl_pkcs7_decrypt", "openssl_pkcs7_encrypt", "openssl_pkcs7_read", "openssl_pkcs7_sign", "openssl_pkcs7_verify", "openssl_pkey_export_to_file", "openssl_pkey_export", "openssl_pkey_free", "openssl_pkey_get_details", "openssl_pkey_get_private", "openssl_pkey_get_public", "openssl_pkey_new", "openssl_private_decrypt", "openssl_private_encrypt", "openssl_public_decrypt", "openssl_public_encrypt", "openssl_random_pseudo_bytes", "openssl_seal", "openssl_sign", "openssl_spki_export_challenge", "openssl_spki_export", "openssl_spki_new", "openssl_spki_verify", "openssl_verify", "openssl_x509_check_private_key", "openssl_x509_checkpurpose", "openssl_x509_export_to_file", "openssl_x509_export", "openssl_x509_fingerprint", "openssl_x509_free", "openssl_x509_parse", "openssl_x509_read", "openssl_x509_verify"] + b["Output Control"] = Set.new ["flush", "ob_clean", "ob_end_clean", "ob_end_flush", "ob_flush", "ob_get_clean", "ob_get_contents", "ob_get_flush", "ob_get_length", "ob_get_level", "ob_get_status", "ob_gzhandler", "ob_implicit_flush", "ob_list_handlers", "ob_start", "output_add_rewrite_var", "output_reset_rewrite_vars"] + b["Paradox"] = Set.new ["px_close", "px_create_fp", "px_date2string", "px_delete_record", "px_delete", "px_get_field", "px_get_info", "px_get_parameter", "px_get_record", "px_get_schema", "px_get_value", "px_insert_record", "px_new", "px_numfields", "px_numrecords", "px_open_fp", "px_put_record", "px_retrieve_record", "px_set_blob_file", "px_set_parameter", "px_set_tablename", "px_set_targetencoding", "px_set_value", "px_timestamp2string", "px_update_record"] + b["Parsekit"] = Set.new ["parsekit_compile_file", "parsekit_compile_string", "parsekit_func_arginfo"] + b["Password Hashing"] = Set.new ["password_get_info", "password_hash", "password_needs_rehash", "password_verify"] + b["PCNTL"] = Set.new ["pcntl_alarm", "pcntl_async_signals", "pcntl_errno", "pcntl_exec", "pcntl_fork", "pcntl_get_last_error", "pcntl_getpriority", "pcntl_setpriority", "pcntl_signal_dispatch", "pcntl_signal_get_handler", "pcntl_signal", "pcntl_sigprocmask", "pcntl_sigtimedwait", "pcntl_sigwaitinfo", "pcntl_strerror", "pcntl_wait", "pcntl_waitpid", "pcntl_wexitstatus", "pcntl_wifexited", "pcntl_wifsignaled", "pcntl_wifstopped", "pcntl_wstopsig", "pcntl_wtermsig"] + b["PCRE"] = Set.new ["preg_filter", "preg_grep", "preg_last_error", "preg_match_all", "preg_match", "preg_quote", "preg_replace_callback_array", "preg_replace_callback", "preg_replace", "preg_split"] + b["PDF"] = Set.new ["PDF_activate_item", "PDF_add_annotation", "PDF_add_bookmark", "PDF_add_launchlink", "PDF_add_locallink", "PDF_add_nameddest", "PDF_add_note", "PDF_add_outline", "PDF_add_pdflink", "PDF_add_table_cell", "PDF_add_textflow", "PDF_add_thumbnail", "PDF_add_weblink", "PDF_arc", "PDF_arcn", "PDF_attach_file", "PDF_begin_document", "PDF_begin_font", "PDF_begin_glyph", "PDF_begin_item", "PDF_begin_layer", "PDF_begin_page_ext", "PDF_begin_page", "PDF_begin_pattern", "PDF_begin_template_ext", "PDF_begin_template", "PDF_circle", "PDF_clip", "PDF_close_image", "PDF_close_pdi_page", "PDF_close_pdi", "PDF_close", "PDF_closepath_fill_stroke", "PDF_closepath_stroke", "PDF_closepath", "PDF_concat", "PDF_continue_text", "PDF_create_3dview", "PDF_create_action", "PDF_create_annotation", "PDF_create_bookmark", "PDF_create_field", "PDF_create_fieldgroup", "PDF_create_gstate", "PDF_create_pvf", "PDF_create_textflow", "PDF_curveto", "PDF_define_layer", "PDF_delete_pvf", "PDF_delete_table", "PDF_delete_textflow", "PDF_delete", "PDF_encoding_set_char", "PDF_end_document", "PDF_end_font", "PDF_end_glyph", "PDF_end_item", "PDF_end_layer", "PDF_end_page_ext", "PDF_end_page", "PDF_end_pattern", "PDF_end_template", "PDF_endpath", "PDF_fill_imageblock", "PDF_fill_pdfblock", "PDF_fill_stroke", "PDF_fill_textblock", "PDF_fill", "PDF_findfont", "PDF_fit_image", "PDF_fit_pdi_page", "PDF_fit_table", "PDF_fit_textflow", "PDF_fit_textline", "PDF_get_apiname", "PDF_get_buffer", "PDF_get_errmsg", "PDF_get_errnum", "PDF_get_font", "PDF_get_fontname", "PDF_get_fontsize", "PDF_get_image_height", "PDF_get_image_width", "PDF_get_majorversion", "PDF_get_minorversion", "PDF_get_parameter", "PDF_get_pdi_parameter", "PDF_get_pdi_value", "PDF_get_value", "PDF_info_font", "PDF_info_matchbox", "PDF_info_table", "PDF_info_textflow", "PDF_info_textline", "PDF_initgraphics", "PDF_lineto", "PDF_load_3ddata", "PDF_load_font", "PDF_load_iccprofile", "PDF_load_image", "PDF_makespotcolor", "PDF_moveto", "PDF_new", "PDF_open_ccitt", "PDF_open_file", "PDF_open_gif", "PDF_open_image_file", "PDF_open_image", "PDF_open_jpeg", "PDF_open_memory_image", "PDF_open_pdi_document", "PDF_open_pdi_page", "PDF_open_pdi", "PDF_open_tiff", "PDF_pcos_get_number", "PDF_pcos_get_stream", "PDF_pcos_get_string", "PDF_place_image", "PDF_place_pdi_page", "PDF_process_pdi", "PDF_rect", "PDF_restore", "PDF_resume_page", "PDF_rotate", "PDF_save", "PDF_scale", "PDF_set_border_color", "PDF_set_border_dash", "PDF_set_border_style", "PDF_set_char_spacing", "PDF_set_duration", "PDF_set_gstate", "PDF_set_horiz_scaling", "PDF_set_info_author", "PDF_set_info_creator", "PDF_set_info_keywords", "PDF_set_info_subject", "PDF_set_info_title", "PDF_set_info", "PDF_set_layer_dependency", "PDF_set_leading", "PDF_set_parameter", "PDF_set_text_matrix", "PDF_set_text_pos", "PDF_set_text_rendering", "PDF_set_text_rise", "PDF_set_value", "PDF_set_word_spacing", "PDF_setcolor", "PDF_setdash", "PDF_setdashpattern", "PDF_setflat", "PDF_setfont", "PDF_setgray_fill", "PDF_setgray_stroke", "PDF_setgray", "PDF_setlinecap", "PDF_setlinejoin", "PDF_setlinewidth", "PDF_setmatrix", "PDF_setmiterlimit", "PDF_setpolydash", "PDF_setrgbcolor_fill", "PDF_setrgbcolor_stroke", "PDF_setrgbcolor", "PDF_shading_pattern", "PDF_shading", "PDF_shfill", "PDF_show_boxed", "PDF_show_xy", "PDF_show", "PDF_skew", "PDF_stringwidth", "PDF_stroke", "PDF_suspend_page", "PDF_translate", "PDF_utf16_to_utf8", "PDF_utf32_to_utf16", "PDF_utf8_to_utf16"] + b["PostgreSQL"] = Set.new ["pg_affected_rows", "pg_cancel_query", "pg_client_encoding", "pg_close", "pg_connect_poll", "pg_connect", "pg_connection_busy", "pg_connection_reset", "pg_connection_status", "pg_consume_input", "pg_convert", "pg_copy_from", "pg_copy_to", "pg_dbname", "pg_delete", "pg_end_copy", "pg_escape_bytea", "pg_escape_identifier", "pg_escape_literal", "pg_escape_string", "pg_execute", "pg_fetch_all_columns", "pg_fetch_all", "pg_fetch_array", "pg_fetch_assoc", "pg_fetch_object", "pg_fetch_result", "pg_fetch_row", "pg_field_is_null", "pg_field_name", "pg_field_num", "pg_field_prtlen", "pg_field_size", "pg_field_table", "pg_field_type_oid", "pg_field_type", "pg_flush", "pg_free_result", "pg_get_notify", "pg_get_pid", "pg_get_result", "pg_host", "pg_insert", "pg_last_error", "pg_last_notice", "pg_last_oid", "pg_lo_close", "pg_lo_create", "pg_lo_export", "pg_lo_import", "pg_lo_open", "pg_lo_read_all", "pg_lo_read", "pg_lo_seek", "pg_lo_tell", "pg_lo_truncate", "pg_lo_unlink", "pg_lo_write", "pg_meta_data", "pg_num_fields", "pg_num_rows", "pg_options", "pg_parameter_status", "pg_pconnect", "pg_ping", "pg_port", "pg_prepare", "pg_put_line", "pg_query_params", "pg_query", "pg_result_error_field", "pg_result_error", "pg_result_seek", "pg_result_status", "pg_select", "pg_send_execute", "pg_send_prepare", "pg_send_query_params", "pg_send_query", "pg_set_client_encoding", "pg_set_error_verbosity", "pg_socket", "pg_trace", "pg_transaction_status", "pg_tty", "pg_unescape_bytea", "pg_untrace", "pg_update", "pg_version"] + b["phpdbg"] = Set.new ["phpdbg_break_file", "phpdbg_break_function", "phpdbg_break_method", "phpdbg_break_next", "phpdbg_clear", "phpdbg_color", "phpdbg_end_oplog", "phpdbg_exec", "phpdbg_get_executable", "phpdbg_prompt", "phpdbg_start_oplog"] + b["POSIX"] = Set.new ["posix_access", "posix_ctermid", "posix_errno", "posix_get_last_error", "posix_getcwd", "posix_getegid", "posix_geteuid", "posix_getgid", "posix_getgrgid", "posix_getgrnam", "posix_getgroups", "posix_getlogin", "posix_getpgid", "posix_getpgrp", "posix_getpid", "posix_getppid", "posix_getpwnam", "posix_getpwuid", "posix_getrlimit", "posix_getsid", "posix_getuid", "posix_initgroups", "posix_isatty", "posix_kill", "posix_mkfifo", "posix_mknod", "posix_setegid", "posix_seteuid", "posix_setgid", "posix_setpgid", "posix_setrlimit", "posix_setsid", "posix_setuid", "posix_strerror", "posix_times", "posix_ttyname", "posix_uname"] + b["Proctitle"] = Set.new ["setproctitle", "setthreadtitle"] + b["PS"] = Set.new ["ps_add_bookmark", "ps_add_launchlink", "ps_add_locallink", "ps_add_note", "ps_add_pdflink", "ps_add_weblink", "ps_arc", "ps_arcn", "ps_begin_page", "ps_begin_pattern", "ps_begin_template", "ps_circle", "ps_clip", "ps_close_image", "ps_close", "ps_closepath_stroke", "ps_closepath", "ps_continue_text", "ps_curveto", "ps_delete", "ps_end_page", "ps_end_pattern", "ps_end_template", "ps_fill_stroke", "ps_fill", "ps_findfont", "ps_get_buffer", "ps_get_parameter", "ps_get_value", "ps_hyphenate", "ps_include_file", "ps_lineto", "ps_makespotcolor", "ps_moveto", "ps_new", "ps_open_file", "ps_open_image_file", "ps_open_image", "ps_open_memory_image", "ps_place_image", "ps_rect", "ps_restore", "ps_rotate", "ps_save", "ps_scale", "ps_set_border_color", "ps_set_border_dash", "ps_set_border_style", "ps_set_info", "ps_set_parameter", "ps_set_text_pos", "ps_set_value", "ps_setcolor", "ps_setdash", "ps_setflat", "ps_setfont", "ps_setgray", "ps_setlinecap", "ps_setlinejoin", "ps_setlinewidth", "ps_setmiterlimit", "ps_setoverprintmode", "ps_setpolydash", "ps_shading_pattern", "ps_shading", "ps_shfill", "ps_show_boxed", "ps_show_xy2", "ps_show_xy", "ps_show2", "ps_show", "ps_string_geometry", "ps_stringwidth", "ps_stroke", "ps_symbol_name", "ps_symbol_width", "ps_symbol", "ps_translate"] + b["Pspell"] = Set.new ["pspell_add_to_personal", "pspell_add_to_session", "pspell_check", "pspell_clear_session", "pspell_config_create", "pspell_config_data_dir", "pspell_config_dict_dir", "pspell_config_ignore", "pspell_config_mode", "pspell_config_personal", "pspell_config_repl", "pspell_config_runtogether", "pspell_config_save_repl", "pspell_new_config", "pspell_new_personal", "pspell_new", "pspell_save_wordlist", "pspell_store_replacement", "pspell_suggest"] + b["Radius"] = Set.new ["radius_acct_open", "radius_add_server", "radius_auth_open", "radius_close", "radius_config", "radius_create_request", "radius_cvt_addr", "radius_cvt_int", "radius_cvt_string", "radius_demangle_mppe_key", "radius_demangle", "radius_get_attr", "radius_get_tagged_attr_data", "radius_get_tagged_attr_tag", "radius_get_vendor_attr", "radius_put_addr", "radius_put_attr", "radius_put_int", "radius_put_string", "radius_put_vendor_addr", "radius_put_vendor_attr", "radius_put_vendor_int", "radius_put_vendor_string", "radius_request_authenticator", "radius_salt_encrypt_attr", "radius_send_request", "radius_server_secret", "radius_strerror"] + b["Rar"] = Set.new ["rar_wrapper_cache_stats"] + b["Readline"] = Set.new ["readline_add_history", "readline_callback_handler_install", "readline_callback_handler_remove", "readline_callback_read_char", "readline_clear_history", "readline_completion_function", "readline_info", "readline_list_history", "readline_on_new_line", "readline_read_history", "readline_redisplay", "readline_write_history", "readline"] + b["Recode"] = Set.new ["recode_file", "recode_string", "recode"] + b["POSIX Regex"] = Set.new ["ereg_replace", "ereg", "eregi_replace", "eregi", "split", "spliti", "sql_regcase"] + b["RpmInfo"] = Set.new ["rpmaddtag", "rpmdbinfo", "rpmdbsearch", "rpminfo", "rpmvercmp"] + b["RPM Reader"] = Set.new ["rpm_close", "rpm_get_tag", "rpm_is_valid", "rpm_open", "rpm_version"] + b["RRD"] = Set.new ["rrd_create", "rrd_error", "rrd_fetch", "rrd_first", "rrd_graph", "rrd_info", "rrd_last", "rrd_lastupdate", "rrd_restore", "rrd_tune", "rrd_update", "rrd_version", "rrd_xport", "rrdc_disconnect"] + b["runkit"] = Set.new ["runkit_class_adopt", "runkit_class_emancipate", "runkit_constant_add", "runkit_constant_redefine", "runkit_constant_remove", "runkit_function_add", "runkit_function_copy", "runkit_function_redefine", "runkit_function_remove", "runkit_function_rename", "runkit_import", "runkit_lint_file", "runkit_lint", "runkit_method_add", "runkit_method_copy", "runkit_method_redefine", "runkit_method_remove", "runkit_method_rename", "runkit_return_value_used", "runkit_sandbox_output_handler", "runkit_superglobals"] + b["runkit7"] = Set.new ["runkit7_constant_add", "runkit7_constant_redefine", "runkit7_constant_remove", "runkit7_function_add", "runkit7_function_copy", "runkit7_function_redefine", "runkit7_function_remove", "runkit7_function_rename", "runkit7_import", "runkit7_method_add", "runkit7_method_copy", "runkit7_method_redefine", "runkit7_method_remove", "runkit7_method_rename", "runkit7_object_id", "runkit7_superglobals", "runkit7_zval_inspect"] + b["Scoutapm"] = Set.new ["scoutapm_get_calls", "scoutapm_list_instrumented_functions"] + b["Seaslog"] = Set.new ["seaslog_get_author", "seaslog_get_version"] + b["Semaphore"] = Set.new ["ftok", "msg_get_queue", "msg_queue_exists", "msg_receive", "msg_remove_queue", "msg_send", "msg_set_queue", "msg_stat_queue", "sem_acquire", "sem_get", "sem_release", "sem_remove", "shm_attach", "shm_detach", "shm_get_var", "shm_has_var", "shm_put_var", "shm_remove_var", "shm_remove"] + b["Session PgSQL"] = Set.new ["session_pgsql_add_error", "session_pgsql_get_error", "session_pgsql_get_field", "session_pgsql_reset", "session_pgsql_set_field", "session_pgsql_status"] + b["Session"] = Set.new ["session_abort", "session_cache_expire", "session_cache_limiter", "session_commit", "session_create_id", "session_decode", "session_destroy", "session_encode", "session_gc", "session_get_cookie_params", "session_id", "session_is_registered", "session_module_name", "session_name", "session_regenerate_id", "session_register_shutdown", "session_register", "session_reset", "session_save_path", "session_set_cookie_params", "session_set_save_handler", "session_start", "session_status", "session_unregister", "session_unset", "session_write_close"] + b["Shared Memory"] = Set.new ["shmop_close", "shmop_delete", "shmop_open", "shmop_read", "shmop_size", "shmop_write"] + b["SimpleXML"] = Set.new ["simplexml_import_dom", "simplexml_load_file", "simplexml_load_string"] + b["SNMP"] = Set.new ["snmp_get_quick_print", "snmp_get_valueretrieval", "snmp_read_mib", "snmp_set_enum_print", "snmp_set_oid_numeric_print", "snmp_set_oid_output_format", "snmp_set_quick_print", "snmp_set_valueretrieval", "snmp2_get", "snmp2_getnext", "snmp2_real_walk", "snmp2_set", "snmp2_walk", "snmp3_get", "snmp3_getnext", "snmp3_real_walk", "snmp3_set", "snmp3_walk", "snmpget", "snmpgetnext", "snmprealwalk", "snmpset", "snmpwalk", "snmpwalkoid"] + b["SOAP"] = Set.new ["is_soap_fault", "use_soap_error_handler"] + b["Socket"] = Set.new ["socket_accept", "socket_addrinfo_bind", "socket_addrinfo_connect", "socket_addrinfo_explain", "socket_addrinfo_lookup", "socket_bind", "socket_clear_error", "socket_close", "socket_cmsg_space", "socket_connect", "socket_create_listen", "socket_create_pair", "socket_create", "socket_export_stream", "socket_get_option", "socket_getopt", "socket_getpeername", "socket_getsockname", "socket_import_stream", "socket_last_error", "socket_listen", "socket_read", "socket_recv", "socket_recvfrom", "socket_recvmsg", "socket_select", "socket_send", "socket_sendmsg", "socket_sendto", "socket_set_block", "socket_set_nonblock", "socket_set_option", "socket_setopt", "socket_shutdown", "socket_strerror", "socket_write", "socket_wsaprotocol_info_export", "socket_wsaprotocol_info_import", "socket_wsaprotocol_info_release"] + b["Sodium"] = Set.new ["sodium_add", "sodium_base642bin", "sodium_bin2base64", "sodium_bin2hex", "sodium_compare", "sodium_crypto_aead_aes256gcm_decrypt", "sodium_crypto_aead_aes256gcm_encrypt", "sodium_crypto_aead_aes256gcm_is_available", "sodium_crypto_aead_aes256gcm_keygen", "sodium_crypto_aead_chacha20poly1305_decrypt", "sodium_crypto_aead_chacha20poly1305_encrypt", "sodium_crypto_aead_chacha20poly1305_ietf_decrypt", "sodium_crypto_aead_chacha20poly1305_ietf_encrypt", "sodium_crypto_aead_chacha20poly1305_ietf_keygen", "sodium_crypto_aead_chacha20poly1305_keygen", "sodium_crypto_aead_xchacha20poly1305_ietf_decrypt", "sodium_crypto_aead_xchacha20poly1305_ietf_encrypt", "sodium_crypto_aead_xchacha20poly1305_ietf_keygen", "sodium_crypto_auth_keygen", "sodium_crypto_auth_verify", "sodium_crypto_auth", "sodium_crypto_box_keypair_from_secretkey_and_publickey", "sodium_crypto_box_keypair", "sodium_crypto_box_open", "sodium_crypto_box_publickey_from_secretkey", "sodium_crypto_box_publickey", "sodium_crypto_box_seal_open", "sodium_crypto_box_seal", "sodium_crypto_box_secretkey", "sodium_crypto_box_seed_keypair", "sodium_crypto_box", "sodium_crypto_generichash_final", "sodium_crypto_generichash_init", "sodium_crypto_generichash_keygen", "sodium_crypto_generichash_update", "sodium_crypto_generichash", "sodium_crypto_kdf_derive_from_key", "sodium_crypto_kdf_keygen", "sodium_crypto_kx_client_session_keys", "sodium_crypto_kx_keypair", "sodium_crypto_kx_publickey", "sodium_crypto_kx_secretkey", "sodium_crypto_kx_seed_keypair", "sodium_crypto_kx_server_session_keys", "sodium_crypto_pwhash_scryptsalsa208sha256_str_verify", "sodium_crypto_pwhash_scryptsalsa208sha256_str", "sodium_crypto_pwhash_scryptsalsa208sha256", "sodium_crypto_pwhash_str_needs_rehash", "sodium_crypto_pwhash_str_verify", "sodium_crypto_pwhash_str", "sodium_crypto_pwhash", "sodium_crypto_scalarmult_base", "sodium_crypto_scalarmult", "sodium_crypto_secretbox_keygen", "sodium_crypto_secretbox_open", "sodium_crypto_secretbox", "sodium_crypto_secretstream_xchacha20poly1305_init_pull", "sodium_crypto_secretstream_xchacha20poly1305_init_push", "sodium_crypto_secretstream_xchacha20poly1305_keygen", "sodium_crypto_secretstream_xchacha20poly1305_pull", "sodium_crypto_secretstream_xchacha20poly1305_push", "sodium_crypto_secretstream_xchacha20poly1305_rekey", "sodium_crypto_shorthash_keygen", "sodium_crypto_shorthash", "sodium_crypto_sign_detached", "sodium_crypto_sign_ed25519_pk_to_curve25519", "sodium_crypto_sign_ed25519_sk_to_curve25519", "sodium_crypto_sign_keypair_from_secretkey_and_publickey", "sodium_crypto_sign_keypair", "sodium_crypto_sign_open", "sodium_crypto_sign_publickey_from_secretkey", "sodium_crypto_sign_publickey", "sodium_crypto_sign_secretkey", "sodium_crypto_sign_seed_keypair", "sodium_crypto_sign_verify_detached", "sodium_crypto_sign", "sodium_crypto_stream_keygen", "sodium_crypto_stream_xor", "sodium_crypto_stream", "sodium_hex2bin", "sodium_increment", "sodium_memcmp", "sodium_memzero", "sodium_pad", "sodium_unpad"] + b["Solr"] = Set.new ["solr_get_version"] + b["SPL"] = Set.new ["class_implements", "class_parents", "class_uses", "iterator_apply", "iterator_count", "iterator_to_array", "spl_autoload_call", "spl_autoload_extensions", "spl_autoload_functions", "spl_autoload_register", "spl_autoload_unregister", "spl_autoload", "spl_classes", "spl_object_hash", "spl_object_id"] + b["SQLite"] = Set.new ["sqlite_array_query", "sqlite_busy_timeout", "sqlite_changes", "sqlite_close", "sqlite_column", "sqlite_create_aggregate", "sqlite_create_function", "sqlite_current", "sqlite_error_string", "sqlite_escape_string", "sqlite_exec", "sqlite_factory", "sqlite_fetch_all", "sqlite_fetch_array", "sqlite_fetch_column_types", "sqlite_fetch_object", "sqlite_fetch_single", "sqlite_fetch_string", "sqlite_field_name", "sqlite_has_more", "sqlite_has_prev", "sqlite_key", "sqlite_last_error", "sqlite_last_insert_rowid", "sqlite_libencoding", "sqlite_libversion", "sqlite_next", "sqlite_num_fields", "sqlite_num_rows", "sqlite_open", "sqlite_popen", "sqlite_prev", "sqlite_query", "sqlite_rewind", "sqlite_seek", "sqlite_single_query", "sqlite_udf_decode_binary", "sqlite_udf_encode_binary", "sqlite_unbuffered_query", "sqlite_valid"] + b["SQLSRV"] = Set.new ["sqlsrv_begin_transaction", "sqlsrv_cancel", "sqlsrv_client_info", "sqlsrv_close", "sqlsrv_commit", "sqlsrv_configure", "sqlsrv_connect", "sqlsrv_errors", "sqlsrv_execute", "sqlsrv_fetch_array", "sqlsrv_fetch_object", "sqlsrv_fetch", "sqlsrv_field_metadata", "sqlsrv_free_stmt", "sqlsrv_get_config", "sqlsrv_get_field", "sqlsrv_has_rows", "sqlsrv_next_result", "sqlsrv_num_fields", "sqlsrv_num_rows", "sqlsrv_prepare", "sqlsrv_query", "sqlsrv_rollback", "sqlsrv_rows_affected", "sqlsrv_send_stream_data", "sqlsrv_server_info"] + b["ssdeep"] = Set.new ["ssdeep_fuzzy_compare", "ssdeep_fuzzy_hash_filename", "ssdeep_fuzzy_hash"] + b["SSH2"] = Set.new ["ssh2_auth_agent", "ssh2_auth_hostbased_file", "ssh2_auth_none", "ssh2_auth_password", "ssh2_auth_pubkey_file", "ssh2_connect", "ssh2_disconnect", "ssh2_exec", "ssh2_fetch_stream", "ssh2_fingerprint", "ssh2_methods_negotiated", "ssh2_publickey_add", "ssh2_publickey_init", "ssh2_publickey_list", "ssh2_publickey_remove", "ssh2_scp_recv", "ssh2_scp_send", "ssh2_sftp_chmod", "ssh2_sftp_lstat", "ssh2_sftp_mkdir", "ssh2_sftp_readlink", "ssh2_sftp_realpath", "ssh2_sftp_rename", "ssh2_sftp_rmdir", "ssh2_sftp_stat", "ssh2_sftp_symlink", "ssh2_sftp_unlink", "ssh2_sftp", "ssh2_shell", "ssh2_tunnel"] + b["Statistic"] = Set.new ["stats_absolute_deviation", "stats_cdf_beta", "stats_cdf_binomial", "stats_cdf_cauchy", "stats_cdf_chisquare", "stats_cdf_exponential", "stats_cdf_f", "stats_cdf_gamma", "stats_cdf_laplace", "stats_cdf_logistic", "stats_cdf_negative_binomial", "stats_cdf_noncentral_chisquare", "stats_cdf_noncentral_f", "stats_cdf_noncentral_t", "stats_cdf_normal", "stats_cdf_poisson", "stats_cdf_t", "stats_cdf_uniform", "stats_cdf_weibull", "stats_covariance", "stats_dens_beta", "stats_dens_cauchy", "stats_dens_chisquare", "stats_dens_exponential", "stats_dens_f", "stats_dens_gamma", "stats_dens_laplace", "stats_dens_logistic", "stats_dens_normal", "stats_dens_pmf_binomial", "stats_dens_pmf_hypergeometric", "stats_dens_pmf_negative_binomial", "stats_dens_pmf_poisson", "stats_dens_t", "stats_dens_uniform", "stats_dens_weibull", "stats_harmonic_mean", "stats_kurtosis", "stats_rand_gen_beta", "stats_rand_gen_chisquare", "stats_rand_gen_exponential", "stats_rand_gen_f", "stats_rand_gen_funiform", "stats_rand_gen_gamma", "stats_rand_gen_ibinomial_negative", "stats_rand_gen_ibinomial", "stats_rand_gen_int", "stats_rand_gen_ipoisson", "stats_rand_gen_iuniform", "stats_rand_gen_noncentral_chisquare", "stats_rand_gen_noncentral_f", "stats_rand_gen_noncentral_t", "stats_rand_gen_normal", "stats_rand_gen_t", "stats_rand_get_seeds", "stats_rand_phrase_to_seeds", "stats_rand_ranf", "stats_rand_setall", "stats_skew", "stats_standard_deviation", "stats_stat_binomial_coef", "stats_stat_correlation", "stats_stat_factorial", "stats_stat_independent_t", "stats_stat_innerproduct", "stats_stat_paired_t", "stats_stat_percentile", "stats_stat_powersum", "stats_variance"] + b["Stomp"] = Set.new ["stomp_connect_error", "stomp_version"] + b["Stream"] = Set.new ["set_socket_blocking", "stream_bucket_append", "stream_bucket_make_writeable", "stream_bucket_new", "stream_bucket_prepend", "stream_context_create", "stream_context_get_default", "stream_context_get_options", "stream_context_get_params", "stream_context_set_default", "stream_context_set_option", "stream_context_set_params", "stream_copy_to_stream", "stream_filter_append", "stream_filter_prepend", "stream_filter_register", "stream_filter_remove", "stream_get_contents", "stream_get_filters", "stream_get_line", "stream_get_meta_data", "stream_get_transports", "stream_get_wrappers", "stream_is_local", "stream_isatty", "stream_notification_callback", "stream_register_wrapper", "stream_resolve_include_path", "stream_select", "stream_set_blocking", "stream_set_chunk_size", "stream_set_read_buffer", "stream_set_timeout", "stream_set_write_buffer", "stream_socket_accept", "stream_socket_client", "stream_socket_enable_crypto", "stream_socket_get_name", "stream_socket_pair", "stream_socket_recvfrom", "stream_socket_sendto", "stream_socket_server", "stream_socket_shutdown", "stream_supports_lock", "stream_wrapper_register", "stream_wrapper_restore", "stream_wrapper_unregister"] + b["String"] = Set.new ["addcslashes", "addslashes", "bin2hex", "chop", "chr", "chunk_split", "convert_cyr_string", "convert_uudecode", "convert_uuencode", "count_chars", "crc32", "crypt", "echo", "explode", "fprintf", "get_html_translation_table", "hebrev", "hebrevc", "hex2bin", "html_entity_decode", "htmlentities", "htmlspecialchars_decode", "htmlspecialchars", "implode", "join", "lcfirst", "levenshtein", "localeconv", "ltrim", "md5_file", "md5", "metaphone", "money_format", "nl_langinfo", "nl2br", "number_format", "ord", "parse_str", "print", "printf", "quoted_printable_decode", "quoted_printable_encode", "quotemeta", "rtrim", "setlocale", "sha1_file", "sha1", "similar_text", "soundex", "sprintf", "sscanf", "str_getcsv", "str_ireplace", "str_pad", "str_repeat", "str_replace", "str_rot13", "str_shuffle", "str_split", "str_word_count", "strcasecmp", "strchr", "strcmp", "strcoll", "strcspn", "strip_tags", "stripcslashes", "stripos", "stripslashes", "stristr", "strlen", "strnatcasecmp", "strnatcmp", "strncasecmp", "strncmp", "strpbrk", "strpos", "strrchr", "strrev", "strripos", "strrpos", "strspn", "strstr", "strtok", "strtolower", "strtoupper", "strtr", "substr_compare", "substr_count", "substr_replace", "substr", "trim", "ucfirst", "ucwords", "vfprintf", "vprintf", "vsprintf", "wordwrap"] + b["SVN"] = Set.new ["svn_add", "svn_auth_get_parameter", "svn_auth_set_parameter", "svn_blame", "svn_cat", "svn_checkout", "svn_cleanup", "svn_client_version", "svn_commit", "svn_delete", "svn_diff", "svn_export", "svn_fs_abort_txn", "svn_fs_apply_text", "svn_fs_begin_txn2", "svn_fs_change_node_prop", "svn_fs_check_path", "svn_fs_contents_changed", "svn_fs_copy", "svn_fs_delete", "svn_fs_dir_entries", "svn_fs_file_contents", "svn_fs_file_length", "svn_fs_is_dir", "svn_fs_is_file", "svn_fs_make_dir", "svn_fs_make_file", "svn_fs_node_created_rev", "svn_fs_node_prop", "svn_fs_props_changed", "svn_fs_revision_prop", "svn_fs_revision_root", "svn_fs_txn_root", "svn_fs_youngest_rev", "svn_import", "svn_log", "svn_ls", "svn_mkdir", "svn_repos_create", "svn_repos_fs_begin_txn_for_commit", "svn_repos_fs_commit_txn", "svn_repos_fs", "svn_repos_hotcopy", "svn_repos_open", "svn_repos_recover", "svn_revert", "svn_status", "svn_update"] + b["Swoole"] = Set.new ["swoole_async_dns_lookup", "swoole_async_read", "swoole_async_readfile", "swoole_async_set", "swoole_async_write", "swoole_async_writefile", "swoole_client_select", "swoole_cpu_num", "swoole_errno", "swoole_event_add", "swoole_event_defer", "swoole_event_del", "swoole_event_exit", "swoole_event_set", "swoole_event_wait", "swoole_event_write", "swoole_get_local_ip", "swoole_last_error", "swoole_load_module", "swoole_select", "swoole_set_process_name", "swoole_strerror", "swoole_timer_after", "swoole_timer_exists", "swoole_timer_tick", "swoole_version"] + b["Sybase"] = Set.new ["sybase_affected_rows", "sybase_close", "sybase_connect", "sybase_data_seek", "sybase_deadlock_retry_count", "sybase_fetch_array", "sybase_fetch_assoc", "sybase_fetch_field", "sybase_fetch_object", "sybase_fetch_row", "sybase_field_seek", "sybase_free_result", "sybase_get_last_message", "sybase_min_client_severity", "sybase_min_error_severity", "sybase_min_message_severity", "sybase_min_server_severity", "sybase_num_fields", "sybase_num_rows", "sybase_pconnect", "sybase_query", "sybase_result", "sybase_select_db", "sybase_set_message_handler", "sybase_unbuffered_query"] + b["Taint"] = Set.new ["is_tainted", "taint", "untaint"] + b["TCP"] = Set.new ["tcpwrap_check"] + b["Tidy"] = Set.new ["ob_tidyhandler", "tidy_access_count", "tidy_config_count", "tidy_error_count", "tidy_get_output", "tidy_warning_count"] + b["Tokenizer"] = Set.new ["token_get_all", "token_name"] + b["Trader"] = Set.new ["trader_acos", "trader_ad", "trader_add", "trader_adosc", "trader_adx", "trader_adxr", "trader_apo", "trader_aroon", "trader_aroonosc", "trader_asin", "trader_atan", "trader_atr", "trader_avgprice", "trader_bbands", "trader_beta", "trader_bop", "trader_cci", "trader_cdl2crows", "trader_cdl3blackcrows", "trader_cdl3inside", "trader_cdl3linestrike", "trader_cdl3outside", "trader_cdl3starsinsouth", "trader_cdl3whitesoldiers", "trader_cdlabandonedbaby", "trader_cdladvanceblock", "trader_cdlbelthold", "trader_cdlbreakaway", "trader_cdlclosingmarubozu", "trader_cdlconcealbabyswall", "trader_cdlcounterattack", "trader_cdldarkcloudcover", "trader_cdldoji", "trader_cdldojistar", "trader_cdldragonflydoji", "trader_cdlengulfing", "trader_cdleveningdojistar", "trader_cdleveningstar", "trader_cdlgapsidesidewhite", "trader_cdlgravestonedoji", "trader_cdlhammer", "trader_cdlhangingman", "trader_cdlharami", "trader_cdlharamicross", "trader_cdlhighwave", "trader_cdlhikkake", "trader_cdlhikkakemod", "trader_cdlhomingpigeon", "trader_cdlidentical3crows", "trader_cdlinneck", "trader_cdlinvertedhammer", "trader_cdlkicking", "trader_cdlkickingbylength", "trader_cdlladderbottom", "trader_cdllongleggeddoji", "trader_cdllongline", "trader_cdlmarubozu", "trader_cdlmatchinglow", "trader_cdlmathold", "trader_cdlmorningdojistar", "trader_cdlmorningstar", "trader_cdlonneck", "trader_cdlpiercing", "trader_cdlrickshawman", "trader_cdlrisefall3methods", "trader_cdlseparatinglines", "trader_cdlshootingstar", "trader_cdlshortline", "trader_cdlspinningtop", "trader_cdlstalledpattern", "trader_cdlsticksandwich", "trader_cdltakuri", "trader_cdltasukigap", "trader_cdlthrusting", "trader_cdltristar", "trader_cdlunique3river", "trader_cdlupsidegap2crows", "trader_cdlxsidegap3methods", "trader_ceil", "trader_cmo", "trader_correl", "trader_cos", "trader_cosh", "trader_dema", "trader_div", "trader_dx", "trader_ema", "trader_errno", "trader_exp", "trader_floor", "trader_get_compat", "trader_get_unstable_period", "trader_ht_dcperiod", "trader_ht_dcphase", "trader_ht_phasor", "trader_ht_sine", "trader_ht_trendline", "trader_ht_trendmode", "trader_kama", "trader_linearreg_angle", "trader_linearreg_intercept", "trader_linearreg_slope", "trader_linearreg", "trader_ln", "trader_log10", "trader_ma", "trader_macd", "trader_macdext", "trader_macdfix", "trader_mama", "trader_mavp", "trader_max", "trader_maxindex", "trader_medprice", "trader_mfi", "trader_midpoint", "trader_midprice", "trader_min", "trader_minindex", "trader_minmax", "trader_minmaxindex", "trader_minus_di", "trader_minus_dm", "trader_mom", "trader_mult", "trader_natr", "trader_obv", "trader_plus_di", "trader_plus_dm", "trader_ppo", "trader_roc", "trader_rocp", "trader_rocr100", "trader_rocr", "trader_rsi", "trader_sar", "trader_sarext", "trader_set_compat", "trader_set_unstable_period", "trader_sin", "trader_sinh", "trader_sma", "trader_sqrt", "trader_stddev", "trader_stoch", "trader_stochf", "trader_stochrsi", "trader_sub", "trader_sum", "trader_t3", "trader_tan", "trader_tanh", "trader_tema", "trader_trange", "trader_trima", "trader_trix", "trader_tsf", "trader_typprice", "trader_ultosc", "trader_var", "trader_wclprice", "trader_willr", "trader_wma"] + b["UI"] = Set.new ["UI\\Draw\\Text\\Font\\fontFamilies", "UI\\quit", "UI\\run"] + b["ODBC"] = Set.new ["odbc_autocommit", "odbc_binmode", "odbc_close_all", "odbc_close", "odbc_columnprivileges", "odbc_columns", "odbc_commit", "odbc_connect", "odbc_cursor", "odbc_data_source", "odbc_do", "odbc_error", "odbc_errormsg", "odbc_exec", "odbc_execute", "odbc_fetch_array", "odbc_fetch_into", "odbc_fetch_object", "odbc_fetch_row", "odbc_field_len", "odbc_field_name", "odbc_field_num", "odbc_field_precision", "odbc_field_scale", "odbc_field_type", "odbc_foreignkeys", "odbc_free_result", "odbc_gettypeinfo", "odbc_longreadlen", "odbc_next_result", "odbc_num_fields", "odbc_num_rows", "odbc_pconnect", "odbc_prepare", "odbc_primarykeys", "odbc_procedurecolumns", "odbc_procedures", "odbc_result_all", "odbc_result", "odbc_rollback", "odbc_setoption", "odbc_specialcolumns", "odbc_statistics", "odbc_tableprivileges", "odbc_tables"] + b["Uopz"] = Set.new ["uopz_add_function", "uopz_allow_exit", "uopz_backup", "uopz_compose", "uopz_copy", "uopz_del_function", "uopz_delete", "uopz_extend", "uopz_flags", "uopz_function", "uopz_get_exit_status", "uopz_get_hook", "uopz_get_mock", "uopz_get_property", "uopz_get_return", "uopz_get_static", "uopz_implement", "uopz_overload", "uopz_redefine", "uopz_rename", "uopz_restore", "uopz_set_hook", "uopz_set_mock", "uopz_set_property", "uopz_set_return", "uopz_set_static", "uopz_undefine", "uopz_unset_hook", "uopz_unset_mock", "uopz_unset_return"] + b["URL"] = Set.new ["base64_decode", "base64_encode", "get_headers", "get_meta_tags", "http_build_query", "parse_url", "rawurldecode", "rawurlencode", "urldecode", "urlencode"] + b["Variable handling"] = Set.new ["boolval", "debug_zval_dump", "doubleval", "empty", "floatval", "get_defined_vars", "get_resource_type", "gettype", "import_request_variables", "intval", "is_array", "is_bool", "is_callable", "is_countable", "is_double", "is_float", "is_int", "is_integer", "is_iterable", "is_long", "is_null", "is_numeric", "is_object", "is_real", "is_resource", "is_scalar", "is_string", "isset", "print_r", "serialize", "settype", "strval", "unserialize", "unset", "var_dump", "var_export"] + b["vpopmail"] = Set.new ["vpopmail_add_alias_domain_ex", "vpopmail_add_alias_domain", "vpopmail_add_domain_ex", "vpopmail_add_domain", "vpopmail_add_user", "vpopmail_alias_add", "vpopmail_alias_del_domain", "vpopmail_alias_del", "vpopmail_alias_get_all", "vpopmail_alias_get", "vpopmail_auth_user", "vpopmail_del_domain_ex", "vpopmail_del_domain", "vpopmail_del_user", "vpopmail_error", "vpopmail_passwd", "vpopmail_set_user_quota"] + b["WDDX"] = Set.new ["wddx_add_vars", "wddx_deserialize", "wddx_packet_end", "wddx_packet_start", "wddx_serialize_value", "wddx_serialize_vars"] + b["win32ps"] = Set.new ["win32_ps_list_procs", "win32_ps_stat_mem", "win32_ps_stat_proc"] + b["win32service"] = Set.new ["win32_continue_service", "win32_create_service", "win32_delete_service", "win32_get_last_control_message", "win32_pause_service", "win32_query_service_status", "win32_send_custom_control", "win32_set_service_exit_code", "win32_set_service_exit_mode", "win32_set_service_status", "win32_start_service_ctrl_dispatcher", "win32_start_service", "win32_stop_service"] + b["WinCache"] = Set.new ["wincache_fcache_fileinfo", "wincache_fcache_meminfo", "wincache_lock", "wincache_ocache_fileinfo", "wincache_ocache_meminfo", "wincache_refresh_if_changed", "wincache_rplist_fileinfo", "wincache_rplist_meminfo", "wincache_scache_info", "wincache_scache_meminfo", "wincache_ucache_add", "wincache_ucache_cas", "wincache_ucache_clear", "wincache_ucache_dec", "wincache_ucache_delete", "wincache_ucache_exists", "wincache_ucache_get", "wincache_ucache_inc", "wincache_ucache_info", "wincache_ucache_meminfo", "wincache_ucache_set", "wincache_unlock"] + b["xattr"] = Set.new ["xattr_get", "xattr_list", "xattr_remove", "xattr_set", "xattr_supported"] + b["xdiff"] = Set.new ["xdiff_file_bdiff_size", "xdiff_file_bdiff", "xdiff_file_bpatch", "xdiff_file_diff_binary", "xdiff_file_diff", "xdiff_file_merge3", "xdiff_file_patch_binary", "xdiff_file_patch", "xdiff_file_rabdiff", "xdiff_string_bdiff_size", "xdiff_string_bdiff", "xdiff_string_bpatch", "xdiff_string_diff_binary", "xdiff_string_diff", "xdiff_string_merge3", "xdiff_string_patch_binary", "xdiff_string_patch", "xdiff_string_rabdiff"] + b["Xhprof"] = Set.new ["xhprof_disable", "xhprof_enable", "xhprof_sample_disable", "xhprof_sample_enable"] + b["XML Parser"] = Set.new ["utf8_decode", "utf8_encode", "xml_error_string", "xml_get_current_byte_index", "xml_get_current_column_number", "xml_get_current_line_number", "xml_get_error_code", "xml_parse_into_struct", "xml_parse", "xml_parser_create_ns", "xml_parser_create", "xml_parser_free", "xml_parser_get_option", "xml_parser_set_option", "xml_set_character_data_handler", "xml_set_default_handler", "xml_set_element_handler", "xml_set_end_namespace_decl_handler", "xml_set_external_entity_ref_handler", "xml_set_notation_decl_handler", "xml_set_object", "xml_set_processing_instruction_handler", "xml_set_start_namespace_decl_handler", "xml_set_unparsed_entity_decl_handler"] + b["XML-RPC"] = Set.new ["xmlrpc_decode_request", "xmlrpc_decode", "xmlrpc_encode_request", "xmlrpc_encode", "xmlrpc_get_type", "xmlrpc_is_fault", "xmlrpc_parse_method_descriptions", "xmlrpc_server_add_introspection_data", "xmlrpc_server_call_method", "xmlrpc_server_create", "xmlrpc_server_destroy", "xmlrpc_server_register_introspection_callback", "xmlrpc_server_register_method", "xmlrpc_set_type"] + b["Yaml"] = Set.new ["yaml_emit_file", "yaml_emit", "yaml_parse_file", "yaml_parse_url", "yaml_parse"] + b["YAZ"] = Set.new ["yaz_addinfo", "yaz_ccl_conf", "yaz_ccl_parse", "yaz_close", "yaz_connect", "yaz_database", "yaz_element", "yaz_errno", "yaz_error", "yaz_es_result", "yaz_es", "yaz_get_option", "yaz_hits", "yaz_itemorder", "yaz_present", "yaz_range", "yaz_record", "yaz_scan_result", "yaz_scan", "yaz_schema", "yaz_search", "yaz_set_option", "yaz_sort", "yaz_syntax", "yaz_wait"] + b["Zip"] = Set.new ["zip_close", "zip_entry_close", "zip_entry_compressedsize", "zip_entry_compressionmethod", "zip_entry_filesize", "zip_entry_name", "zip_entry_open", "zip_entry_read", "zip_open", "zip_read"] + b["Zlib"] = Set.new ["deflate_add", "deflate_init", "gzclose", "gzcompress", "gzdecode", "gzdeflate", "gzencode", "gzeof", "gzfile", "gzgetc", "gzgets", "gzgetss", "gzinflate", "gzopen", "gzpassthru", "gzputs", "gzread", "gzrewind", "gzseek", "gztell", "gzuncompress", "gzwrite", "inflate_add", "inflate_get_read_len", "inflate_get_status", "inflate_init", "readgzfile", "zlib_decode", "zlib_encode", "zlib_get_coding_type"] + b["ZooKeeper"] = Set.new ["zookeeper_dispatch"] + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plain_text.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plain_text.rb new file mode 100644 index 0000000..db49767 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plain_text.rb @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class PlainText < Lexer + title "Plain Text" + desc "A boring lexer that doesn't highlight anything" + + tag 'plaintext' + aliases 'text' + filenames '*.txt', 'Messages' + mimetypes 'text/plain' + + attr_reader :token + def initialize(*) + super + + @token = token_option(:token) || Text + end + + def stream_tokens(string, &b) + yield self.token, string + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plist.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plist.rb new file mode 100644 index 0000000..bd0ed9b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plist.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + class Plist < RegexLexer + desc 'plist' + tag 'plist' + aliases 'plist' + filenames '*.plist', '*.pbxproj' + + mimetypes 'text/x-plist', 'application/x-plist' + + state :whitespace do + rule %r/\s+/, Text::Whitespace + end + + state :root do + rule %r{//.*$}, Comment + rule %r{/\*.+?\*/}m, Comment + mixin :whitespace + rule %r/{/, Punctuation, :dictionary + rule %r/\(/, Punctuation, :array + rule %r/"([^"\\]|\\.)*"/, Literal::String::Double + rule %r/'([^'\\]|\\.)*'/, Literal::String::Single + rule %r//, Punctuation, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plsql.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plsql.rb new file mode 100644 index 0000000..4674cc5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plsql.rb @@ -0,0 +1,578 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class PLSQL < RegexLexer + title "PLSQL" + desc "Procedural Language Structured Query Language for Oracle relational database" + tag 'plsql' + filenames '*.pls', '*.typ', '*.tps', '*.tpb', '*.pks', '*.pkb', '*.pkg', '*.trg' + mimetypes 'text/x-plsql' + + def self.keywords_reserved + @keywords_reserved ||= Set.new(%w( + ACCESSIBLE AGENT ALL ALTER AND ANY AS ASC BETWEEN BFILE_BASE BLOB_BASE BY + C CALLING CHARSET CHARSETFORM CHARSETID CHAR_BASE CHECK CLOB_BASE CLUSTER + COLLATE COMPILED COMPRESS CONNECT CONNECT_BY_ROOT CONSTRUCTOR CREATE CUSTOMDATUM + DATE_BASE DEFAULT DELETE DESC DISTINCT DROP DURATION ELSE ELSIF EXCEPT EXCLUSIVE + EXISTS EXIT FIXED FOR FORALL FROM GENERAL GRANT GROUP HAVING IDENTIFIED IN INDEX + INDICES INSERT INTERFACE INTERSECT INTO IS LARGE LIKE LIMITED LOCK LOOP MAXLEN + MINUS MODE NOCOMPRESS NOT NOWAIT NULL NUMBER_BASE OCICOLL OCIDATE OCIDATETIME + OCIDURATION OCIINTERVAL OCILOBLOCATOR OCINUMBER OCIRAW OCIREF OCIREFCURSOR + OCIROWID OCISTRING OCITYPE OF ON OPTION OR ORACLE ORADATA ORDER ORLANY ORLVARY + OUT OVERRIDING PARALLEL_ENABLE PARAMETER PASCAL PCTFREE PIPE PIPELINED POLYMORPHIC + PRAGMA PRIOR PUBLIC RAISE RECORD RELIES_ON REM RENAME RESOURCE RESULT REVOKE ROWID + SB1 SB2 SELECT SEPARATE SET SHARE SHORT SIZE SIZE_T SPARSE SQLCODE SQLDATA + SQLNAME SQLSTATE STANDARD START STORED STRUCT STYLE SYNONYM TABLE TDO THEN + TRANSACTIONAL TRIGGER UB1 UB4 UNION UNIQUE UNSIGNED UNTRUSTED UPDATE VALIST + VALUES VARIABLE VIEW VOID WHERE WHILE WITH + )) + end + + def self.keywords + @keywords ||= Set.new(%w( + ABORT ABS ABSENT ACCESS ACCESSED ACCOUNT ACL ACOS ACROSS ACTION ACTIONS + ACTIVATE ACTIVE ACTIVE_COMPONENT ACTIVE_DATA ACTIVE_FUNCTION ACTIVE_TAG ACTIVITY + ADAPTIVE_PLAN ADD ADD_COLUMN ADD_GROUP ADD_MONTHS ADG_REDIRECT_DML ADG_REDIRECT_PLSQL + ADJ_DATE ADMIN ADMINISTER ADMINISTRATOR ADVANCED ADVISE ADVISOR AFD_DISKSTRING + AFFINITY AFTER AGGREGATE AGGREGATES ALGORITHM ALIAS ALLOCATE ALLOW ALL_ROWS + ALTERNATE ALWAYS ANALYTIC ANALYTIC_VIEW_SQL ANALYZE ANCESTOR ANCILLARY AND_EQUAL + ANOMALY ANSI_REARCH ANSWER_QUERY_USING_STATS ANTIJOIN ANYSCHEMA ANY_VALUE + APPEND APPENDCHILDXML APPEND_VALUES APPLICATION APPLY APPROX_COUNT APPROX_COUNT_DISTINCT + APPROX_COUNT_DISTINCT_AGG APPROX_COUNT_DISTINCT_DETAIL APPROX_MEDIAN APPROX_PERCENTILE + APPROX_PERCENTILE_AGG APPROX_PERCENTILE_DETAIL APPROX_RANK APPROX_SUM ARCHIVAL + ARCHIVE ARCHIVED ARCHIVELOG ARRAY ARRAYS ASCII ASCIISTR ASIN ASIS ASSEMBLY + ASSIGN ASSOCIATE ASYNC ASYNCHRONOUS AS_JSON AT ATAN ATAN2 ATTRIBUTE ATTRIBUTES + AUDIT AUTHENTICATED AUTHENTICATION AUTHID AUTHORIZATION AUTO AUTOALLOCATE + AUTOEXTEND AUTOMATIC AUTO_LOGIN AUTO_REOPTIMIZE AVAILABILITY AVCACHE_OP AVERAGE_RANK + AVG AVMDX_OP AVRO AV_AGGREGATE AV_CACHE AW BACKGROUND BACKINGFILE BACKUP BAND_JOIN + BASIC BASICFILE BATCH BATCHSIZE BATCH_TABLE_ACCESS_BY_ROWID BECOME BEFORE + BEGIN BEGINNING BEGIN_OUTLINE_DATA BEHALF BEQUEATH BFILENAME BIGFILE BINARY + BINARY_DOUBLE_INFINITY BINARY_DOUBLE_NAN BINARY_FLOAT_INFINITY BINARY_FLOAT_NAN + BINDING BIND_AWARE BIN_TO_NUM BITAND BITMAP BITMAPS BITMAP_AND BITMAP_BIT_POSITION + BITMAP_BUCKET_NUMBER BITMAP_CONSTRUCT_AGG BITMAP_COUNT BITMAP_OR_AGG BITMAP_TREE + BITOR BITS BITXOR BIT_AND_AGG BIT_OR_AGG BIT_XOR_AGG BLOCK BLOCKCHAIN BLOCKING + BLOCKS BLOCKSIZE BLOCK_RANGE BODY BOOL BOOTSTRAP BOTH BOUND BRANCH BREADTH + BROADCAST BSON BUFFER BUFFER_CACHE BUFFER_POOL BUILD BULK BUSHY_JOIN BYPASS_RECURSIVE_CHECK + BYPASS_UJVC CACHE CACHE_CB CACHE_INSTANCES CACHE_TEMP_TABLE CACHING CALCULATED + CALL CALLBACK CANCEL CAPACITY CAPTION CAPTURE CARDINALITY CASCADE CASE CAST + CATALOG_DBLINK CATEGORY CDB$DEFAULT CDB_HTTP_HANDLER CEIL CELLMEMORY CELL_FLASH_CACHE + CERTIFICATE CFILE CHAINED CHANGE CHANGE_DUPKEY_ERROR_INDEX CHARTOROWID CHAR_CS + CHECKPOINT CHECKSUM CHECK_ACL_REWRITE CHILD CHOOSE CHR CHUNK CLASS CLASSIFICATION + CLASSIFIER CLAUSE CLEAN CLEANUP CLEAR CLIENT CLONE CLOSE CLOSEST CLOSE_CACHED_OPEN_CURSORS + CLOUD_IDENTITY CLUSTERING CLUSTERING_FACTOR CLUSTERS CLUSTER_BY_ROWID CLUSTER_DETAILS + CLUSTER_DISTANCE CLUSTER_ID CLUSTER_PROBABILITY CLUSTER_SET COALESCE COALESCE_SQ + COARSE COLAUTH COLD COLLATE COLLATION COLLECT COLUMN COLUMNAR COLUMNS COLUMN_AUTHORIZATION_INDICATOR + COLUMN_AUTH_INDICATOR COLUMN_STATS COLUMN_VALUE COMMENT COMMIT COMMITTED COMMON + COMMON_DATA_MAP COMPACT COMPATIBILITY COMPILE COMPLETE COMPLIANCE COMPONENT + COMPONENTS COMPOSE COMPOSITE COMPOSITE_LIMIT COMPOUND COMPUTATION COMPUTE + CONCAT CONDITION CONDITIONAL CONFIRM CONFORMING CONNECT_BY_CB_WHR_ONLY CONNECT_BY_COMBINE_SW + CONNECT_BY_COST_BASED CONNECT_BY_ELIM_DUPS CONNECT_BY_FILTERING CONNECT_BY_ISCYCLE + CONNECT_BY_ISLEAF CONNECT_BY_ROOT CONNECT_TIME CONSENSUS CONSIDER CONSISTENT + CONST CONSTANT CONSTRAINT CONSTRAINTS CONTAINER CONTAINERS CONTAINERS_DEFAULT + CONTAINER_DATA CONTAINER_DATA_ADMIT_NULL CONTAINER_MAP CONTAINER_MAP_OBJECT + CONTENT CONTENTS CONTEXT CONTINUE CONTROLFILE CONVERSION CONVERT CON_DBID_TO_ID + CON_GUID_TO_ID CON_ID CON_ID_FILTER CON_ID_TO_CON_NAME CON_ID_TO_DBID CON_ID_TO_GUID + CON_ID_TO_UID CON_NAME_TO_ID CON_UID_TO_ID COOKIE COPY CORR CORRUPTION CORRUPT_XID + CORRUPT_XID_ALL CORR_K CORR_S COS COSH COST COST_XML_QUERY_REWRITE COUNT COVAR_POP + COVAR_SAMP CO_AUTH_IND CPU_COSTING CPU_COUNT CPU_PER_CALL CPU_PER_SESSION + CPU_TIME CRASH CREATE_FILE_DEST CREATE_STORED_OUTLINES CREATION CREDENTIAL + CREDENTIALS CRITICAL CROSS CROSSEDITION CSCONVERT CUBE CUBE_AJ CUBE_GB CUBE_SJ + CUME_DIST CUME_DISTM CURRENT CURRENTV CURRENT_DATE CURRENT_INSTANCE CURRENT_PARTSET_KEY + CURRENT_SCHEMA CURRENT_SHARD_KEY CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER + CURSOR CURSOR_SHARING_EXACT CURSOR_SPECIFIC_SEGMENT CV CYCLE DAGG_OPTIM_GSETS + DANGLING DATA DATABASE DATABASES DATAFILE DATAFILES DATAMOVEMENT DATAOBJNO + DATAOBJ_TO_MAT_PARTITION DATAOBJ_TO_PARTITION DATAPUMP DATASTORE DATA_LINK_DML + DATA_SECURITY_REWRITE_LIMIT DATA_VALIDATE DATE_MODE DAYS DBA DBA_RECYCLEBIN + DBMS_STATS DBSTR2UTF8 DBTIMEZONE DB_ROLE_CHANGE DB_UNIQUE_NAME DB_VERSION + DDL DEALLOCATE DEBUG DEBUGGER DECLARE DECODE DECOMPOSE DECOMPRESS DECORRELATE + DECR DECREMENT DECRYPT DEDUPLICATE DEFAULTS DEFAULT_COLLATION DEFAULT_PDB_HINT + DEFERRABLE DEFERRED DEFINE DEFINED DEFINER DEFINITION DEGREE DELAY DELEGATE + DELETEXML DELETE_ALL DEMAND DENORM_AV DENSE_RANK DENSE_RANKM DEPENDENT DEPTH + DEQUEUE DEREF DEREF_NO_REWRITE DESCENDANT DESCRIPTION DESTROY DETACHED DETERMINED + DETERMINES DETERMINISTIC DG_GATHER_STATS DIAGNOSTICS DICTIONARY DIGEST DIMENSION + DIMENSIONS DIRECT DIRECTORY DIRECT_LOAD DIRECT_PATH DISABLE DISABLE_ALL DISABLE_CONTAINERS_DEFAULT + DISABLE_CONTAINER_MAP DISABLE_PARALLEL_DML DISABLE_PRESET DISABLE_RPKE DISALLOW + DISASSOCIATE DISCARD DISCONNECT DISK DISKGROUP DISKS DISMOUNT DISTINGUISHED + DISTRIBUTE DISTRIBUTED DIST_AGG_PROLLUP_PUSHDOWN DML DML_UPDATE DOCFIDELITY + DOCUMENT DOMAIN_INDEX_FILTER DOMAIN_INDEX_NO_SORT DOMAIN_INDEX_SORT DOWNGRADE + DRAIN_TIMEOUT DRIVING_SITE DROP_COLUMN DROP_GROUP DST_UPGRADE_INSERT_CONV + DUMP DUPLICATE DUPLICATED DV DYNAMIC DYNAMIC_SAMPLING DYNAMIC_SAMPLING_EST_CDN + EACH EDITION EDITIONABLE EDITIONING EDITIONS ELAPSED_TIME ELEMENT ELIMINATE_JOIN + ELIMINATE_OBY ELIMINATE_OUTER_JOIN ELIMINATE_SQ ELIM_GROUPBY EM EMPTY EMPTY_BLOB + EMPTY_CLOB ENABLE ENABLE_ALL ENABLE_PARALLEL_DML ENABLE_PRESET ENCODE ENCODING + ENCRYPT ENCRYPTION END END_OUTLINE_DATA ENFORCE ENFORCED ENQUEUE ENTERPRISE + ENTITYESCAPING ENTRY EQUIPART EQUIVALENT ERROR ERRORS ERROR_ARGUMENT ERROR_ON_OVERLAP_TIME + ESCAPE ESTIMATE EVAL EVALNAME EVALUATE EVALUATION EVEN EVENTS EVERY EXCEPTION + EXCEPTIONS EXCHANGE EXCLUDE EXCLUDING EXECUTE EXEMPT EXISTING EXISTSNODE EXP + EXPAND EXPAND_GSET_TO_UNION EXPAND_TABLE EXPIRE EXPLAIN EXPLOSION EXPORT EXPRESS + EXPR_CORR_CHECK EXTEND EXTENDED EXTENDS EXTENT EXTENTS EXTERNAL EXTERNALLY + EXTRA EXTRACT EXTRACTCLOBXML EXTRACTVALUE FACILITY FACT FACTOR FACTORIZE_JOIN + FAILED FAILED_LOGIN_ATTEMPTS FAILGROUP FAILOVER FAILURE FALSE FAMILY FAR FAST + FBTSCAN FEATURE FEATURE_COMPARE FEATURE_DETAILS FEATURE_ID FEATURE_SET FEATURE_VALUE + FEDERATION FETCH FILE FILEGROUP FILESTORE FILESYSTEM_LIKE_LOGGING FILE_NAME_CONVERT + FILTER FINAL FINE FINISH FIRST FIRSTM FIRST_ROWS FIRST_VALUE FIXED_VIEW_DATA + FLAGGER FLASHBACK FLASH_CACHE FLEX FLOB FLOOR FLUSH FOLDER FOLLOWING FOLLOWS + FORCE FORCE_JSON_TABLE_TRANSFORM FORCE_SPATIAL FORCE_XML_QUERY_REWRITE FOREIGN + FOREVER FORMAT FORWARD FRAGMENT_NUMBER FREE FREELIST FREELISTS FREEPOOLS FRESH + FRESH_MV FROM_TZ FTP FULL FULL_OUTER_JOIN_TO_OUTER FUNCTION FUNCTIONS GATHER_OPTIMIZER_STATISTICS + GATHER_PLAN_STATISTICS GBY_CONC_ROLLUP GBY_PUSHDOWN GENERATED GET GLOBAL GLOBALLY + GLOBAL_NAME GLOBAL_TOPIC_ENABLED GOLDENGATE GOTO GRANTED GRANULAR GREATEST + GROUPING GROUPING_ID GROUPS GROUP_BY GROUP_ID GUARANTEE GUARANTEED GUARD H + HALF_YEARS HASH HASHING HASHKEYS HASHSET_BUILD HASH_AJ HASH_SJ HEADER HEAP + HELP HEXTORAW HEXTOREF HIDDEN HIDE HIERARCHICAL HIERARCHIES HIERARCHY HIER_ANCESTOR + HIER_CAPTION HIER_CHILDREN HIER_CHILD_COUNT HIER_COLUMN HIER_CONDITION HIER_DEPTH + HIER_DESCRIPTION HIER_HAS_CHILDREN HIER_LAG HIER_LEAD HIER_LEVEL HIER_MEMBER_NAME + HIER_MEMBER_UNIQUE_NAME HIER_ORDER HIER_PARENT HIER_WINDOW HIGH HINTSET_BEGIN + HINTSET_END HOST HOT HOUR HOURS HTTP HWM_BROKERED HYBRID ID IDENTIFIER IDENTITY + IDGENERATORS IDLE IDLE_TIME IF IGNORE IGNORE_OPTIM_EMBEDDED_HINTS IGNORE_ROW_ON_DUPKEY_INDEX + IGNORE_WHERE_CLAUSE ILM IMMEDIATE IMMUTABLE IMPACT IMPORT INACTIVE INACTIVE_ACCOUNT_TIME + INCLUDE INCLUDES INCLUDE_VERSION INCLUDING INCOMING INCR INCREMENT INCREMENTAL + INDENT INDEXED INDEXES INDEXING INDEXTYPE INDEXTYPES INDEX_ASC INDEX_COMBINE + INDEX_DESC INDEX_FFS INDEX_FILTER INDEX_JOIN INDEX_ROWS INDEX_RRS INDEX_RS + INDEX_RS_ASC INDEX_RS_DESC INDEX_SCAN INDEX_SKIP_SCAN INDEX_SS INDEX_SS_ASC + INDEX_SS_DESC INDEX_STATS INDICATOR INFINITE INFORMATIONAL INHERIT INITCAP + INITIAL INITIALIZED INITIALLY INITRANS INLINE INLINE_XMLTYPE_NT INLINE_XT + INMEMORY INMEMORY_PRUNING INNER INPLACE INSENSITIVE INSERTCHILDXML INSERTCHILDXMLAFTER + INSERTCHILDXMLBEFORE INSERTXMLAFTER INSERTXMLBEFORE INSTALL INSTANCE INSTANCES + INSTANTIABLE INSTANTLY INSTEAD INSTR INSTR2 INSTR4 INSTRB INSTRC INTERLEAVED + INTERMEDIATE INTERNAL_CONVERT INTERNAL_USE INTERPRETED INTRA_CDB INVALIDATE + INVALIDATION INVISIBLE IN_MEMORY_METADATA IN_XQUERY IOSEEKTIM IOTFRSPEED IO_LOGICAL + IO_MEGABYTES IO_REQUESTS ISOLATE ISOLATION ISOLATION_LEVEL ITERATE ITERATION_NUMBER + JAVA JOB JOIN JSON JSONGET JSONPARSE JSONTOXML JSON_ARRAY JSON_ARRAYAGG JSON_EQUAL + JSON_EQUAL2 JSON_EXISTS JSON_EXISTS2 JSON_HASH JSON_LENGTH JSON_MERGEPATCH + JSON_MKMVI JSON_OBJECT JSON_OBJECTAGG JSON_PATCH JSON_QUERY JSON_SCALAR JSON_SERIALIZE + JSON_TABLE JSON_TEXTCONTAINS JSON_TEXTCONTAINS2 JSON_TRANSFORM JSON_VALUE + KEEP KEEP_DUPLICATES KERBEROS KEY KEYS KEYSIZE KEYSTORE KEY_LENGTH KILL + KURTOSIS_POP KURTOSIS_SAMP LABEL LAG LAG_DIFF LAG_DIFF_PERCENT LANGUAGE LAST + LAST_DAY LAST_VALUE LATERAL LAX LAYER LDAP_REGISTRATION LDAP_REGISTRATION_ENABLED + LDAP_REG_SYNC_INTERVAL LEAD LEADING LEAD_CDB LEAD_CDB_URI LEAD_DIFF LEAD_DIFF_PERCENT + LEAF LEAST LEAVES LEDGER LEFT LENGTH LENGTH2 LENGTH4 LENGTHB LENGTHC LESS + LEVEL LEVELS LIBRARY LIFE LIFECYCLE LIFETIME LIKE2 LIKE4 LIKEC LIMIT LINEAR + LINK LIST LISTAGG LN LNNVL LOAD LOB LOBNVL LOBS LOB_VALUE LOCALTIME LOCALTIMESTAMP + LOCAL_INDEXES LOCATION LOCATOR LOCKDOWN LOCKED LOCKING LOG LOGFILE LOGFILES + LOGGING LOGICAL LOGICAL_READS_PER_CALL LOGICAL_READS_PER_SESSION LOGMINING + LOGOFF LOGON LOG_READ_ONLY_VIOLATIONS LOST LOW LOWER LPAD LTRIM MAIN MAKE_REF + MANAGE MANAGED MANAGEMENT MANAGER MANDATORY MANUAL MAP MAPPER MAPPING MASTER + MATCH MATCHED MATCHES MATCH_NUMBER MATCH_RECOGNIZE MATERIALIZE MATERIALIZED + MATRIX MAX MAXARCHLOGS MAXDATAFILES MAXEXTENTS MAXIMIZE MAXINSTANCES MAXLOGFILES + MAXLOGHISTORY MAXLOGMEMBERS MAXSIZE MAXTRANS MAXVALUE MAX_AUDIT_SIZE MAX_DIAG_SIZE + MAX_PDB_SNAPSHOTS MAX_SHARED_TEMP_SIZE MBRC MEASURE MEASURES MEDIAN MEDIUM + MEMBER MEMCOMPRESS MEMOPTIMIZE MEMOPTIMIZE_WRITE MEMORY MERGE MERGE$ACTIONS + MERGE_AJ MERGE_CONST_ON MERGE_SJ METADATA METADATA_SOURCE_PDB METHOD MIGRATE + MIGRATE_CROSS_CON MIGRATION MIN MINEXTENTS MINIMIZE MINIMUM MINING MINUS_NULL + MINUTE MINUTES MINVALUE MIRROR MIRRORCOLD MIRRORHOT MISMATCH MISSING MLE MLSLABEL + MOD MODEL MODEL_COMPILE_SUBQUERY MODEL_DONTVERIFY_UNIQUENESS MODEL_DYNAMIC_SUBQUERY + MODEL_MIN_ANALYSIS MODEL_NB MODEL_NO_ANALYSIS MODEL_PBY MODEL_PUSH_REF MODEL_SV + MODIFICATION MODIFY MODIFY_COLUMN_TYPE MODULE MONITOR MONITORING MONTHS MONTHS_BETWEEN + MOUNT MOUNTPATH MOUNTPOINT MOVE MOVEMENT MULTIDIMENSIONAL MULTISET MULTIVALUE + MV_MERGE NAME NAMED NAMES NAMESPACE NAN NANVL NATIVE NATIVE_FULL_OUTER_JOIN + NATURAL NAV NCHAR_CS NCHR NEEDED NEG NESTED NESTED_ROLLUP_TOP NESTED_TABLE_FAST_INSERT + NESTED_TABLE_GET_REFS NESTED_TABLE_ID NESTED_TABLE_SET_REFS NESTED_TABLE_SET_SETID + NETWORK NEVER NEW NEW_TIME NEXT NEXT_DAY NLJ_BATCHING NLJ_INDEX_FILTER NLJ_INDEX_SCAN + NLJ_PREFETCH NLSSORT NLS_CALENDAR NLS_CHARACTERSET NLS_CHARSET_DECL_LEN NLS_CHARSET_ID + NLS_CHARSET_NAME NLS_COLLATION_ID NLS_COLLATION_NAME NLS_COMP NLS_CURRENCY + NLS_DATE_FORMAT NLS_DATE_LANGUAGE NLS_INITCAP NLS_ISO_CURRENCY NLS_LANG NLS_LANGUAGE + NLS_LENGTH_SEMANTICS NLS_LOWER NLS_NCHAR_CONV_EXCP NLS_NUMERIC_CHARACTERS + NLS_SORT NLS_SPECIAL_CHARS NLS_TERRITORY NLS_UPPER NL_AJ NL_SJ NO NOAPPEND + NOARCHIVELOG NOAUDIT NOCACHE NOCOPY NOCPU_COSTING NOCYCLE NODELAY NOENTITYESCAPING + NOEXTEND NOFORCE NOGUARANTEE NOKEEP NOLOCAL NOLOGGING NOMAPPING NOMAXVALUE + NOMINIMIZE NOMINVALUE NOMONITORING NONBLOCKING NONE NONEDITIONABLE NONPARTITIONED + NONSCHEMA NOORDER NOOVERRIDE NOPARALLEL NOPARALLEL_INDEX NORELOCATE NORELY + NOREPAIR NOREPLAY NORESETLOGS NOREVERSE NOREWRITE NORMAL NOROWDEPENDENCIES + NOSCALE NOSCHEMACHECK NOSEGMENT NOSHARD NOSORT NOSTRICT NOSWITCH NOTHING NOTIFICATION + NOVALIDATE NOW NO_ACCESS NO_ADAPTIVE_PLAN NO_ANSI_REARCH NO_ANSWER_QUERY_USING_STATS + NO_AUTO_REOPTIMIZE NO_BAND_JOIN NO_BASETABLE_MULTIMV_REWRITE NO_BATCH_TABLE_ACCESS_BY_ROWID + NO_BIND_AWARE NO_BUFFER NO_BUSHY_JOIN NO_CARTESIAN NO_CHECK_ACL_REWRITE NO_CLUSTERING + NO_CLUSTER_BY_ROWID NO_COALESCE_SQ NO_COMMON_DATA NO_CONNECT_BY_CB_WHR_ONLY + NO_CONNECT_BY_COMBINE_SW NO_CONNECT_BY_COST_BASED NO_CONNECT_BY_ELIM_DUPS + NO_CONNECT_BY_FILTERING NO_CONTAINERS NO_COST_XML_QUERY_REWRITE NO_CPU_COSTING + NO_CROSS_CONTAINER NO_DAGG_OPTIM_GSETS NO_DATA_SECURITY_REWRITE NO_DECORRELATE + NO_DIST_AGG_PROLLUP_PUSHDOWN NO_DOMAIN_INDEX_FILTER NO_DST_UPGRADE_INSERT_CONV + NO_ELIMINATE_JOIN NO_ELIMINATE_OBY NO_ELIMINATE_OUTER_JOIN NO_ELIMINATE_SQ + NO_ELIM_GROUPBY NO_EXPAND NO_EXPAND_GSET_TO_UNION NO_EXPAND_TABLE NO_FACT + NO_FACTORIZE_JOIN NO_FILTERING NO_FULL_OUTER_JOIN_TO_OUTER NO_GATHER_OPTIMIZER_STATISTICS + NO_GBY_PUSHDOWN NO_INDEX NO_INDEX_FFS NO_INDEX_SS NO_INMEMORY NO_INMEMORY_PRUNING + NO_JSON_TABLE_TRANSFORM NO_LOAD NO_MERGE NO_MODEL_PUSH_REF NO_MONITOR NO_MONITORING + NO_MULTIMV_REWRITE NO_NATIVE_FULL_OUTER_JOIN NO_NLJ_BATCHING NO_NLJ_PREFETCH + NO_OBJECT_LINK NO_OBY_GBYPD_SEPARATE NO_ORDER_ROLLUPS NO_OR_EXPAND NO_OUTER_JOIN_TO_ANTI + NO_OUTER_JOIN_TO_INNER NO_PARALLEL NO_PARALLEL_INDEX NO_PARTIAL_COMMIT NO_PARTIAL_JOIN + NO_PARTIAL_OSON_UPDATE NO_PARTIAL_ROLLUP_PUSHDOWN NO_PLACE_DISTINCT NO_PLACE_GROUP_BY + NO_PQ_CONCURRENT_UNION NO_PQ_EXPAND_TABLE NO_PQ_MAP NO_PQ_NONLEAF_SKEW NO_PQ_REPLICATE + NO_PQ_SKEW NO_PRUNE_GSETS NO_PULL_PRED NO_PUSH_HAVING_TO_GBY NO_PUSH_PRED + NO_PUSH_SUBQ NO_PX_FAULT_TOLERANCE NO_PX_JOIN_FILTER NO_QKN_BUFF NO_QUERY_TRANSFORMATION + NO_REF_CASCADE NO_REORDER_WIF NO_RESULT_CACHE NO_REWRITE NO_ROOT_SW_FOR_LOCAL + NO_SEMIJOIN NO_SEMI_TO_INNER NO_SET_GBY_PUSHDOWN NO_SET_TO_JOIN NO_SQL_TRANSLATION + NO_SQL_TUNE NO_STAR_TRANSFORMATION NO_STATEMENT_QUEUING NO_STATS_GSETS NO_SUBQUERY_PRUNING + NO_SUBSTRB_PAD NO_SWAP_JOIN_INPUTS NO_TABLE_LOOKUP_BY_NL NO_TEMP_TABLE NO_TRANSFORM_DISTINCT_AGG + NO_UNNEST NO_USE_CUBE NO_USE_DAGG_UNION_ALL_GSETS NO_USE_HASH NO_USE_HASH_AGGREGATION + NO_USE_HASH_GBY_FOR_DAGGPSHD NO_USE_HASH_GBY_FOR_PUSHDOWN NO_USE_INVISIBLE_INDEXES + NO_USE_MERGE NO_USE_NL NO_USE_PARTITION_WISE_DISTINCT NO_USE_PARTITION_WISE_GBY + NO_USE_PARTITION_WISE_WIF NO_USE_SCALABLE_GBY_INVDIST NO_USE_VECTOR_AGGREGATION + NO_VECTOR_TRANSFORM NO_VECTOR_TRANSFORM_DIMS NO_VECTOR_TRANSFORM_FACT NO_XDB_FASTPATH_INSERT + NO_XMLINDEX_REWRITE NO_XMLINDEX_REWRITE_IN_SELECT NO_XML_DML_REWRITE NO_XML_QUERY_REWRITE + NO_ZONEMAP NTH_VALUE NTILE NULLIF NULLS NUMTODSINTERVAL NUMTOYMINTERVAL NUM_INDEX_KEYS + NVL NVL2 OBJECT OBJECT2XML OBJNO OBJNO_REUSE OBJ_ID OBY_GBYPD_SEPARATE OCCURENCES + OCCURRENCES ODD OFF OFFLINE OFFSET OID OIDINDEX OLAP OLD OLD_PUSH_PRED OLS + OLTP OMIT ONE ONLINE ONLY OPAQUE OPAQUE_TRANSFORM OPAQUE_XCANONICAL OPCODE + OPEN OPERATIONS OPERATOR OPTIMAL OPTIMIZE OPTIMIZER_FEATURES_ENABLE OPTIMIZER_GOAL + OPT_ESTIMATE OPT_PARAM ORADEBUG ORA_BRANCH ORA_CHECK_ACL ORA_CHECK_PRIVILEGE + ORA_CHECK_SYS_PRIVILEGE ORA_CLUSTERING ORA_CONCAT_RWKEY ORA_DM_PARTITION_NAME + ORA_DST_AFFECTED ORA_DST_CONVERT ORA_DST_ERROR ORA_GET_ACLIDS ORA_GET_PRIVILEGES + ORA_HASH ORA_INVOKING_USER ORA_INVOKING_USERID ORA_INVOKING_XS_USER ORA_INVOKING_XS_USER_GUID + ORA_NORMALIZE ORA_PARTITION_VALIDATION ORA_RAWCOMPARE ORA_RAWCONCAT ORA_ROWSCN + ORA_ROWSCN_RAW ORA_ROWVERSION ORA_SEARCH_RWKEY ORA_SHARDSPACE_NAME ORA_SHARD_ID + ORA_TABVERSION ORA_WRITE_TIME ORDERED ORDERED_PREDICATES ORDER_KEY_VECTOR_USE + ORDER_SUBQ ORDINALITY ORGANIZATION OR_EXPAND OR_PREDICATES OSON OSON_DIAG + OSON_GET_CONTENT OTHER OTHERS OUTER OUTER_JOIN_TO_ANTI OUTER_JOIN_TO_INNER + OUTLINE OUTLINE_LEAF OUT_OF_LINE OVER OVERFLOW OVERFLOW_NOMOVE OVERLAPS OWN + OWNER OWNERSHIP PACKAGE PACKAGES PARALLEL PARALLEL_INDEX PARAM PARAMETERS + PARENT PARITY PART$NUM$INST PARTIAL PARTIALLY PARTIAL_JOIN PARTIAL_ROLLUP_PUSHDOWN + PARTITION PARTITIONING PARTITIONS PARTITIONSET PARTITION_CONTAINED PARTITION_HASH + PARTITION_LIST PARTITION_RANGE PASSING PASSIVE PASSWORD PASSWORDFILE_METADATA_CACHE + PASSWORD_GRACE_TIME PASSWORD_LIFE_TIME PASSWORD_LOCK_TIME PASSWORD_REUSE_MAX + PASSWORD_REUSE_TIME PASSWORD_ROLLOVER_TIME PASSWORD_VERIFY_FUNCTION PAST PATCH + PATH PATHS PATH_PREFIX PATTERN PBL_HS_BEGIN PBL_HS_END PCTINCREASE PCTTHRESHOLD + PCTUSED PCTVERSION PDB_LOCAL_ONLY PEER PEERS PENDING PER PERCENT PERCENTAGE + PERCENTILE_CONT PERCENTILE_DISC PERCENT_RANK PERCENT_RANKM PERFORMANCE PERIOD + PERMANENT PERMISSION PERMUTE PERSISTABLE PFILE PHV PHYSICAL PIKEY PIVOT PIV_GB + PIV_SSF PLACE_DISTINCT PLACE_GROUP_BY PLAN PLSCOPE_SETTINGS PLSQL_CCFLAGS + PLSQL_CODE_TYPE PLSQL_DEBUG PLSQL_OPTIMIZE_LEVEL PLSQL_WARNINGS PLUGGABLE + PMEM POINT POLICY POOL_16K POOL_2K POOL_32K POOL_4K POOL_8K PORT POSITION + POST_TRANSACTION POWER POWERMULTISET POWERMULTISET_BY_CARDINALITY PQ_CONCURRENT_UNION + PQ_DISTRIBUTE PQ_DISTRIBUTE_WINDOW PQ_EXPAND_TABLE PQ_FILTER PQ_MAP PQ_NOMAP + PQ_NONLEAF_SKEW PQ_REPLICATE PQ_SKEW PREBUILT PRECEDES PRECEDING PRECOMPUTE_SUBQUERY + PREDICATE_REORDERS PREDICTION PREDICTION_BOUNDS PREDICTION_COST PREDICTION_DETAILS + PREDICTION_PROBABILITY PREDICTION_SET PRELOAD PREPARE PRESENT PRESENTNNV PRESENTV + PRESERVE PRESERVE_OID PRETTY PREV PREVIOUS PRIMARY PRINTBLOBTOCLOB PRIORITY + PRIVATE PRIVATE_SGA PRIVILEGE PRIVILEGED PRIVILEGES PROCEDURAL PROCEDURE PROCESS + PROFILE PROGRAM PROJECT PROPAGATE PROPAGATION PROPERTY PROTECTED PROTECTION + PROTOCOL PROXY PRUNING PULL_PRED PURGE PUSH_HAVING_TO_GBY PUSH_PRED PUSH_SUBQ + PX_FAULT_TOLERANCE PX_GRANULE PX_JOIN_FILTER QB_NAME QUALIFY QUARANTINE QUARTERS + QUERY QUERY_BLOCK QUEUE QUEUE_CURR QUEUE_ROWP QUIESCE QUORUM QUOTA QUOTAGROUP + QUOTES RANDOM RANDOM_LOCAL RANGE RANK RANKM RAPIDLY RATIO_TO_REPORT RAWTOHEX + RAWTONHEX RAWTOREF RBA RBO_OUTLINE RDBA READ READS READ_OR_WRITE REALM REBALANCE + REBUILD RECONNECT RECORDS_PER_BLOCK RECOVER RECOVERABLE RECOVERY RECYCLE RECYCLEBIN + REDACTION REDEFINE REDO REDUCED REDUNDANCY REFERENCE REFERENCED REFERENCES + REFERENCING REFRESH REFTOHEX REFTORAW REF_CASCADE_CURSOR REGEXP_COUNT REGEXP_INSTR + REGEXP_LIKE REGEXP_REPLACE REGEXP_SUBSTR REGISTER REGR_AVGX REGR_AVGY REGR_COUNT + REGR_INTERCEPT REGR_R2 REGR_SLOPE REGR_SXX REGR_SXY REGR_SYY REGULAR REJECT + REKEY RELATIONAL RELOCATE RELY REMAINDER REMOTE REMOTE_MAPPED REMOVE REORDER_WIF + REPAIR REPEAT REPLACE REPLICATION REQUIRED RESERVOIR_SAMPLING RESET RESETLOGS + RESIZE RESOLVE RESOLVER RESPECT RESTART RESTORE RESTORE_AS_INTERVALS RESTRICT + RESTRICTED RESTRICT_ALL_REF_CONS RESULT_CACHE RESUMABLE RESUME RETENTION RETRY_ON_ROW_CHANGE + RETURN RETURNING REUSE REVERSE REWRITE REWRITE_OR_ERROR RIGHT RLS_FORCE ROLE + ROLES ROLESET ROLLBACK ROLLING ROLLOVER ROLLUP ROOT ROUND ROUND_TIES_TO_EVEN + ROW ROWDEPENDENCIES ROWIDTOCHAR ROWIDTONCHAR ROWID_MAPPING_TABLE ROWNUM ROWS + ROW_LENGTH ROW_NUMBER RPAD RTRIM RULE RULES RUNNING SALT SAMPLE SAVE SAVEPOINT + SAVE_AS_INTERVALS SB4 SCALAR SCALARS SCALE SCALE_ROWS SCAN SCAN_INSTANCES + SCHEDULER SCHEMA SCHEMACHECK SCN SCN_ASCENDING SCOPE SCRUB SDO_GEOM_KEY SDO_GEOM_MAX_X + SDO_GEOM_MAX_Y SDO_GEOM_MAX_Z SDO_GEOM_MBB SDO_GEOM_MBR SDO_GEOM_MIN_X SDO_GEOM_MIN_Y + SDO_GEOM_MIN_Z SDO_TOLERANCE SD_ALL SD_INHIBIT SD_SHOW SEARCH SECONDS SECRET + SECUREFILE SECUREFILE_DBA SECURITY SEED SEGMENT SEG_BLOCK SEG_FILE SELECTIVITY + SELF SEMIJOIN SEMIJOIN_DRIVER SEMI_TO_INNER SENSITIVE SEQUENCE SEQUENCED SEQUENTIAL + SERIAL SERIALIZABLE SERVERERROR SERVICE SERVICES SERVICE_NAME_CONVERT SESSION + SESSIONS_PER_USER SESSIONTIMEZONE SESSIONTZNAME SESSION_CACHED_CURSORS SETS + SETTINGS SET_GBY_PUSHDOWN SET_TO_JOIN SEVERE SHARD SHARDED SHARDS SHARDSPACE + SHARD_CHUNK_ID SHARED SHARED_POOL SHARE_OF SHARING SHD$COL$MAP SHELFLIFE SHOW + SHRINK SHUTDOWN SIBLING SIBLINGS SID SIGN SIGNAL_COMPONENT SIGNAL_FUNCTION + SIGNATURE SIMPLE SIN SINGLE SINGLETASK SINH SITE SKEWNESS_POP SKEWNESS_SAMP + SKIP SKIP_EXT_OPTIMIZER SKIP_PROXY SKIP_UNQ_UNUSABLE_IDX SKIP_UNUSABLE_INDEXES + SMALLFILE SNAPSHOT SOME SORT SOUNDEX SOURCE SOURCE_FILE_DIRECTORY SOURCE_FILE_NAME_CONVERT + SPACE SPATIAL SPECIFICATION SPFILE SPLIT SPREADSHEET SQL SQLLDR SQL_SCOPE + SQL_TRACE SQL_TRANSLATION_PROFILE SQRT STALE STANDALONE STANDARD_HASH STANDBY + STANDBYS STANDBY_MAX_DATA_DELAY STAR STARTUP STAR_TRANSFORMATION STATE STATEMENT + STATEMENTS STATEMENT_ID STATEMENT_QUEUING STATIC STATISTICS STATS_BINOMIAL_TEST + STATS_CROSSTAB STATS_F_TEST STATS_KS_TEST STATS_MODE STATS_MW_TEST STATS_ONE_WAY_ANOVA + STATS_T_TEST_INDEP STATS_T_TEST_INDEPU STATS_T_TEST_ONE STATS_T_TEST_PAIRED + STATS_WSR_TEST STDDEV STDDEV_POP STDDEV_SAMP STOP STORAGE STORAGE_INDEX STORE + STREAM STREAMS STRICT STRING STRINGS STRIP STRIPE_COLUMNS STRIPE_WIDTH STRUCTURE + SUBMULTISET SUBPARTITION SUBPARTITIONING SUBPARTITIONS SUBPARTITION_REL SUBQUERIES + SUBQUERY_PRUNING SUBSCRIBE SUBSET SUBSTITUTABLE SUBSTR SUBSTR2 SUBSTR4 SUBSTRB + SUBSTRC SUBTYPE SUCCESS SUCCESSFUL SUM SUMMARY SUPPLEMENTAL SUPPRESS_LOAD + SUSPEND SWAP_JOIN_INPUTS SWITCH SWITCHOVER SYNC SYNCHRONOUS SYSASM SYSAUX + SYSBACKUP SYSDATE SYSDBA SYSDG SYSGUID SYSKM SYSOBJ SYSOPER SYSRAC SYSTEM + SYSTEM_DEFINED SYSTEM_STATS SYSTIMESTAMP SYS_AUDIT SYS_CHECKACL SYS_CHECK_PRIVILEGE + SYS_CONNECT_BY_PATH SYS_CONS_ANY_SCALAR SYS_CONTEXT SYS_CTXINFOPK SYS_CTX_CONTAINS2 + SYS_CTX_MKIVIDX SYS_DBURIGEN SYS_DL_CURSOR SYS_DM_RXFORM_CHR SYS_DM_RXFORM_LAB + SYS_DM_RXFORM_NUM SYS_DOM_COMPARE SYS_DST_PRIM2SEC SYS_DST_SEC2PRIM SYS_ET_BFILE_TO_RAW + SYS_ET_BLOB_TO_IMAGE SYS_ET_IMAGE_TO_BLOB SYS_ET_RAW_TO_BFILE SYS_EXTPDTXT + SYS_EXTRACT_UTC SYS_FBT_INSDEL SYS_FILTER_ACLS SYS_FNMATCHES SYS_FNREPLACE + SYS_GETTOKENID SYS_GETXTIVAL SYS_GET_ACLIDS SYS_GET_ANY_SCALAR SYS_GET_COL_ACLIDS + SYS_GET_PRIVILEGES SYS_GUID SYS_MAKEXML SYS_MAKE_XMLNODEID SYS_MKXMLATTR SYS_MKXTI + SYS_OPTLOBPRBSC SYS_OPTXICMP SYS_OPTXQCASTASNQ SYS_OP_ADT2BIN SYS_OP_ADTCONS + SYS_OP_ALSCRVAL SYS_OP_ATG SYS_OP_BIN2ADT SYS_OP_BITVEC SYS_OP_BL2R SYS_OP_BLOOM_FILTER + SYS_OP_BLOOM_FILTER_LIST SYS_OP_C2C SYS_OP_CAST SYS_OP_CEG SYS_OP_CL2C SYS_OP_COMBINED_HASH + SYS_OP_COMP SYS_OP_CONVERT SYS_OP_COUNTCHG SYS_OP_CSCONV SYS_OP_CSCONVTEST + SYS_OP_CSR SYS_OP_CSX_PATCH SYS_OP_CYCLED_SEQ SYS_OP_DECOMP SYS_OP_DESCEND + SYS_OP_DISTINCT SYS_OP_DRA SYS_OP_DSB_DESERIALIZE SYS_OP_DSB_SERIALIZE SYS_OP_DUMP + SYS_OP_DV_CHECK SYS_OP_ENFORCE_NOT_NULL$ SYS_OP_EXTRACT SYS_OP_GROUPING SYS_OP_GUID + SYS_OP_HASH SYS_OP_HCS_TABLE SYS_OP_IIX SYS_OP_INTERVAL_HIGH_BOUND SYS_OP_ITR + SYS_OP_KEY_VECTOR_CREATE SYS_OP_KEY_VECTOR_FILTER SYS_OP_KEY_VECTOR_FILTER_LIST + SYS_OP_KEY_VECTOR_PAYLOAD SYS_OP_KEY_VECTOR_SUCCEEDED SYS_OP_KEY_VECTOR_USE + SYS_OP_LBID SYS_OP_LOBLOC2BLOB SYS_OP_LOBLOC2CLOB SYS_OP_LOBLOC2ID SYS_OP_LOBLOC2NCLOB + SYS_OP_LOBLOC2TYP SYS_OP_LSVI SYS_OP_LVL SYS_OP_MAKEOID SYS_OP_MAP_NONNULL + SYS_OP_MSR SYS_OP_NICOMBINE SYS_OP_NIEXTRACT SYS_OP_NII SYS_OP_NIX SYS_OP_NOEXPAND + SYS_OP_NTCIMG$ SYS_OP_NUMTORAW SYS_OP_OBJ_UPD_IN_TXN SYS_OP_OIDVALUE SYS_OP_OPNSIZE + SYS_OP_PAR SYS_OP_PARGID SYS_OP_PARGID_1 SYS_OP_PART_ID SYS_OP_PAR_1 SYS_OP_PIVOT + SYS_OP_R2O SYS_OP_RAWTONUM SYS_OP_RDTM SYS_OP_REF SYS_OP_RMTD SYS_OP_ROWIDTOOBJ + SYS_OP_RPB SYS_OP_TOSETID SYS_OP_TPR SYS_OP_TRTB SYS_OP_UNDESCEND SYS_OP_VECAND + SYS_OP_VECBIT SYS_OP_VECOR SYS_OP_VECTOR_GROUP_BY SYS_OP_VECXOR SYS_OP_VERSION + SYS_OP_VREF SYS_OP_VVD SYS_OP_XMLCONS_FOR_CSX SYS_OP_XPTHATG SYS_OP_XPTHIDX + SYS_OP_XPTHOP SYS_OP_XTNN SYS_OP_XTXT2SQLT SYS_OP_ZONE_ID SYS_ORDERKEY_DEPTH + SYS_ORDERKEY_MAXCHILD SYS_ORDERKEY_PARENT SYS_PARALLEL_TXN SYS_PATHID_IS_ATTR + SYS_PATHID_IS_NMSPC SYS_PATHID_LASTNAME SYS_PATHID_LASTNMSPC SYS_PATH_REVERSE + SYS_PLSQL_COUNT SYS_PLSQL_CPU SYS_PLSQL_IO SYS_PXQEXTRACT SYS_RAW_TO_XSID + SYS_REMAP_XMLTYPE SYS_RID_ORDER SYS_ROW_DELTA SYS_SC_2_XMLT SYS_SYNRCIREDO + SYS_TYPEID SYS_UMAKEXML SYS_XMLANALYZE SYS_XMLCONTAINS SYS_XMLCONV SYS_XMLEXNSURI + SYS_XMLGEN SYS_XMLINSTR SYS_XMLI_LOC_ISNODE SYS_XMLI_LOC_ISTEXT SYS_XMLLOCATOR_GETSVAL + SYS_XMLNODEID SYS_XMLNODEID_GETCID SYS_XMLNODEID_GETLOCATOR SYS_XMLNODEID_GETOKEY + SYS_XMLNODEID_GETPATHID SYS_XMLNODEID_GETPTRID SYS_XMLNODEID_GETRID SYS_XMLNODEID_GETSVAL + SYS_XMLNODEID_GETTID SYS_XMLTRANSLATE SYS_XMLTYPE2SQL SYS_XMLT_2_SC SYS_XQBASEURI + SYS_XQCASTABLEERRH SYS_XQCODEP2STR SYS_XQCODEPEQ SYS_XQCON2SEQ SYS_XQCONCAT + SYS_XQDELETE SYS_XQDFLTCOLATION SYS_XQDOC SYS_XQDOCURI SYS_XQDURDIV SYS_XQED4URI + SYS_XQENDSWITH SYS_XQERR SYS_XQERRH SYS_XQESHTMLURI SYS_XQEXLOBVAL SYS_XQEXSTWRP + SYS_XQEXTRACT SYS_XQEXTRREF SYS_XQEXVAL SYS_XQFB2STR SYS_XQFNBOOL SYS_XQFNCMP + SYS_XQFNDATIM SYS_XQFNLNAME SYS_XQFNNM SYS_XQFNNSURI SYS_XQFNPREDTRUTH SYS_XQFNQNM + SYS_XQFNROOT SYS_XQFORMATNUM SYS_XQFTCONTAIN SYS_XQFUNCR SYS_XQGETCONTENT + SYS_XQINDXOF SYS_XQINSERT SYS_XQINSPFX SYS_XQIRI2URI SYS_XQLANG SYS_XQLLNMFRMQNM + SYS_XQMKNODEREF SYS_XQNILLED SYS_XQNODENAME SYS_XQNORMSPACE SYS_XQNORMUCODE + SYS_XQNSP4PFX SYS_XQNSPFRMQNM SYS_XQPFXFRMQNM SYS_XQPOLYABS SYS_XQPOLYADD + SYS_XQPOLYCEL SYS_XQPOLYCST SYS_XQPOLYCSTBL SYS_XQPOLYDIV SYS_XQPOLYFLR SYS_XQPOLYMOD + SYS_XQPOLYMUL SYS_XQPOLYRND SYS_XQPOLYSQRT SYS_XQPOLYSUB SYS_XQPOLYUMUS SYS_XQPOLYUPLS + SYS_XQPOLYVEQ SYS_XQPOLYVGE SYS_XQPOLYVGT SYS_XQPOLYVLE SYS_XQPOLYVLT SYS_XQPOLYVNE + SYS_XQREF2VAL SYS_XQRENAME SYS_XQREPLACE SYS_XQRESVURI SYS_XQRNDHALF2EVN SYS_XQRSLVQNM + SYS_XQRYENVPGET SYS_XQRYVARGET SYS_XQRYWRP SYS_XQSEQ2CON SYS_XQSEQ2CON4XC + SYS_XQSEQDEEPEQ SYS_XQSEQINSB SYS_XQSEQRM SYS_XQSEQRVS SYS_XQSEQSUB SYS_XQSEQTYPMATCH + SYS_XQSTARTSWITH SYS_XQSTATBURI SYS_XQSTR2CODEP SYS_XQSTRJOIN SYS_XQSUBSTRAFT + SYS_XQSUBSTRBEF SYS_XQTOKENIZE SYS_XQTREATAS SYS_XQXFORM SYS_XQ_ASQLCNV SYS_XQ_ATOMCNVCHK + SYS_XQ_NRNG SYS_XQ_PKSQL2XML SYS_XQ_UPKXML2SQL SYS_XSID_TO_RAW SYS_ZMAP_FILTER + SYS_ZMAP_REFRESH TABAUTH TABLES TABLESPACE TABLESPACE_NO TABLE_LOOKUP_BY_NL + TABLE_STATS TABNO TAG TAN TANH TARGET TBL$OR$IDX$PART$NUM TEMP TEMPFILE TEMPLATE + TEMPORARY TEMP_TABLE TENANT_ID TEST TEXT THAN THE THREAD THROUGH TIER TIES + TIMEOUT TIMES TIMESTAMP_TO_NUMBER TIMEZONE_ABBR TIMEZONE_HOUR TIMEZONE_MINUTE + TIMEZONE_OFFSET TIMEZONE_REGION TIME_ZONE TIV_GB TIV_SSF TOKEN TOPLEVEL TO_ACLID + TO_APPROX_COUNT_DISTINCT TO_APPROX_PERCENTILE TO_BINARY_DOUBLE TO_BINARY_FLOAT + TO_BLOB TO_CHAR TO_CLOB TO_DATE TO_DSINTERVAL TO_ISO_STRING TO_LOB TO_MULTI_BYTE + TO_NCHAR TO_NCLOB TO_NUMBER TO_SINGLE_BYTE TO_TIME TO_TIMESTAMP TO_TIMESTAMP_TZ + TO_TIME_TZ TO_UTC_TIMESTAMP_TZ TO_YMINTERVAL TRACE TRACING TRACKING TRAILING + TRANSACTION TRANSFORM TRANSFORM_DISTINCT_AGG TRANSITION TRANSITIONAL TRANSLATE + TRANSLATION TRANSPORTABLE TREAT TRIGGERS TRIM TRUE TRUNC TRUNCATE TRUST TRUSTED + TUNING TX TYPE TYPENAME TYPES TZ_OFFSET UB2 UBA UCS2 UID UNARCHIVED UNBOUND + UNBOUNDED UNCONDITIONAL UNDER UNDO UNDROP UNIFORM UNINSTALL UNION_ALL UNISTR + UNITE UNIXTIME UNLIMITED UNLOAD UNLOCK UNMATCHED UNNEST UNNEST_INNERJ_DISTINCT_VIEW + UNNEST_NOSEMIJ_NODISTINCTVIEW UNNEST_SEMIJ_VIEW UNPACKED UNPIVOT UNPLUG UNPROTECTED + UNQUIESCE UNRECOVERABLE UNRESTRICTED UNSUBSCRIBE UNTIL UNUSABLE UNUSED UPDATABLE + UPDATED UPDATEXML UPD_INDEXES UPD_JOININDEX UPGRADE UPPER UPSERT USABLE USAGE + USE USER USERENV USERGROUP USERS USER_DATA USER_DEFINED USER_RECYCLEBIN USER_TABLESPACES + USE_ANTI USE_CONCAT USE_CUBE USE_DAGG_UNION_ALL_GSETS USE_HASH USE_HASH_AGGREGATION + USE_HASH_GBY_FOR_DAGGPSHD USE_HASH_GBY_FOR_PUSHDOWN USE_HIDDEN_PARTITIONS + USE_INVISIBLE_INDEXES USE_MERGE USE_MERGE_CARTESIAN USE_NL USE_NL_WITH_INDEX + USE_PARTITION_WISE_DISTINCT USE_PARTITION_WISE_GBY USE_PARTITION_WISE_WIF + USE_PRIVATE_OUTLINES USE_SCALABLE_GBY_INVDIST USE_SEMI USE_STORED_OUTLINES + USE_TTT_FOR_GSETS USE_VECTOR_AGGREGATION USE_WEAK_NAME_RESL USING USING_NO_EXPAND + UTF16BE UTF16LE UTF32 UTF8 V1 V2 VALIDATE VALIDATE_CONVERSION VALIDATION VALID_TIME_END + VALUE VARIANCE VARRAY VARRAYS VAR_POP VAR_SAMP VECTOR VECTOR_ENCODE VECTOR_READ + VECTOR_READ_TRACE VECTOR_TRANSFORM VECTOR_TRANSFORM_DIMS VECTOR_TRANSFORM_FACT + VERIFIER VERIFY VERSION VERSIONING VERSIONS VERSIONS_ENDSCN VERSIONS_ENDTIME + VERSIONS_OPERATION VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_XID VIEWS + VIOLATION VIRTUAL VISIBILITY VISIBLE VOLUME VSIZE WAIT WALLET WEEK WEEKS WELLFORMED + WHEN WHENEVER WHITESPACE WIDTH_BUCKET WINDOW WITHIN WITHOUT WITH_EXPRESSION + WITH_PLSQL WORK WRAPPED WRAPPER WRITE XDB_FASTPATH_INSERT XID XML XML2OBJECT + XMLATTRIBUTES XMLCAST XMLCDATA XMLCOLATTVAL XMLCOMMENT XMLCONCAT XMLDIFF XMLELEMENT + XMLEXISTS XMLEXISTS2 XMLFOREST XMLINDEX_REWRITE XMLINDEX_REWRITE_IN_SELECT + XMLINDEX_SEL_IDX_TBL XMLISNODE XMLISVALID XMLNAMESPACES XMLPARSE XMLPATCH + XMLPI XMLQUERY XMLQUERYVAL XMLROOT XMLSCHEMA XMLSERIALIZE XMLTABLE XMLTOJSON + XMLTOKENSET XMLTRANSFORM XMLTRANSFORMBLOB XMLTSET_DML_ENABLE XML_DIAG XML_DML_RWT_STMT + XPATHTABLE XS XS_SYS_CONTEXT X_DYN_PRUNE YEARS YES ZONEMAP + )) + end + + def self.keywords_func + @keywords_func ||= Set.new(%w( + ABS ACOS ADD_MONTHS APPROX_COUNT APPROX_COUNT_DISTINCT APPROX_COUNT_DISTINCT_AGG + APPROX_COUNT_DISTINCT_DETAIL APPROX_MEDIAN APPROX_PERCENTILE APPROX_PERCENTILE_AGG + APPROX_PERCENTILE_DETAIL APPROX_RANK APPROX_SUM ASCII ASCIISTR ASIN ATAN ATAN2 + AVG BFILENAME BIN_TO_NUM BITAND CARDINALITY CAST CEIL CHARTOROWID CHR CLUSTER_DETAILS + CLUSTER_DISTANCE CLUSTER_ID CLUSTER_PROBABILITY CLUSTER_SET COALESCE COLLATION + COLLECT COMPOSE CONCAT CONVERT CON_DBID_TO_ID CON_GUID_TO_ID CON_NAME_TO_ID + CON_UID_TO_ID CORR COS COSH COUNT COVAR_POP COVAR_SAMP CUME_DIST CURRENT_DATE + CURRENT_TIMESTAMP CV DATAOBJ_TO_MAT_PARTITION DATAOBJ_TO_PARTITION DBTIMEZONE + DECODE DECOMPOSE DENSE_RANK DEPTH DEREF DUMP EMPTY_BLOB EMPTY_CLOB EXISTSNODE + EXP EXTRACT EXTRACTVALUE FEATURE_COMPARE FEATURE_DETAILS FEATURE_ID FEATURE_SET + FEATURE_VALUE FIRST FIRST_VALUE FLOOR FROM_TZ GREATEST GROUPING GROUPING_ID + GROUP_ID HEXTORAW INITCAP INSTR ITERATION_NUMBER JSON_ARRAY JSON_ARRAYAGG + JSON_OBJECT JSON_OBJECTAGG JSON_QUERY JSON_TABLE JSON_VALUE LAG LAST LAST_DAY + LAST_VALUE LEAD LEAST LENGTH LISTAGG LN LNNVL LOCALTIMESTAMP LOG LOWER LPAD + LTRIM MAKE_REF MAX MEDIAN MIN MOD MONTHS_BETWEEN NANVL NCHR NEW_TIME NEXT_DAY + NLSSORT NLS_CHARSET_DECL_LEN NLS_CHARSET_ID NLS_CHARSET_NAME NLS_COLLATION_ID + NLS_COLLATION_NAME NLS_INITCAP NLS_LOWER NLS_UPPER NTH_VALUE NTILE NULLIF + NUMTODSINTERVAL NUMTOYMINTERVAL NVL NVL2 ORA_DM_PARTITION_NAME ORA_DST_AFFECTED + ORA_DST_CONVERT ORA_DST_ERROR ORA_HASH ORA_INVOKING_USER ORA_INVOKING_USERID + PATH PERCENTILE_CONT PERCENTILE_DISC PERCENT_RANK POWER POWERMULTISET POWERMULTISET_BY_CARDINALITY + PREDICTION PREDICTION_BOUNDS PREDICTION_COST PREDICTION_DETAILS PREDICTION_PROBABILITY + PREDICTION_SET PRESENTNNV PRESENTV PREVIOUS RANK RATIO_TO_REPORT RAWTOHEX + RAWTONHEX REFTOHEX REGEXP_COUNT REGEXP_INSTR REGEXP_REPLACE REGEXP_SUBSTR + REMAINDER REPLACE ROUND ROUND ROWIDTOCHAR ROWIDTONCHAR ROW_NUMBER RPAD RTRIM + SCN_TO_TIMESTAMP SESSIONTIMEZONE SET SIGN SIN SINH SOUNDEX SQRT STANDARD_HASH + STATS_BINOMIAL_TEST STATS_CROSSTAB STATS_F_TEST STATS_KS_TEST STATS_MODE STATS_MW_TEST + STATS_ONE_WAY_ANOVA STATS_WSR_TEST STDDEV STDDEV_POP STDDEV_SAMP SUBSTR SUM + SYSDATE SYSTIMESTAMP SYS_CONNECT_BY_PATH SYS_CONTEXT SYS_DBURIGEN SYS_EXTRACT_UTC + SYS_GUID SYS_OP_ZONE_ID SYS_TYPEID SYS_XMLAGG SYS_XMLGEN TAN TANH TIMESTAMP_TO_SCN + TO_APPROX_COUNT_DISTINCT TO_APPROX_PERCENTILE TO_BINARY_DOUBLE TO_BINARY_FLOAT + TO_BLOB TO_CHAR TO_CLOB TO_DATE TO_DSINTERVAL TO_LOB TO_MULTI_BYTE TO_NCHAR + TO_NCLOB TO_NUMBER TO_SINGLE_BYTE TO_TIMESTAMP TO_TIMESTAMP_TZ TO_YMINTERVAL + TRANSLATE TREAT TRIM TRUNC TZ_OFFSET UID UNISTR UPPER USER USERENV VALIDATE_CONVERSION + VALUE VARIANCE VAR_POP VAR_SAMP VSIZE WIDTH_BUCKET XMLAGG XMLCAST XMLCDATA + XMLCOLATTVAL XMLCOMMENT XMLCONCAT XMLDIFF XMLELEMENT XMLEXISTS XMLFOREST XMLISVALID + XMLPARSE XMLPATCH XMLPI XMLQUERY XMLROOT XMLSEQUENCE XMLSERIALIZE XMLTABLE + XMLTRANSFORM + )) + end + + def self.keywords_type + @keywords_type ||= Set.new(%w( + CHAR BYTE VARCHAR2 NCHAR NVARCHAR2 + NUMBER FLOAT BINARY_FLOAT BINARY_DOUBLE + LONG RAW + DATE TIMESTAMP INTERVAL LOCAL TIME ZONE TO MONTH SECOND YEAR DAY + BLOB CLOB NCLOB BFILE + UROWID + CHARACTER VARYING VARCHAR NATIONAL CHARACTER + NUMERIC DECIMAL DEC INTEGER INT SMALLINT + FLOAT DOUBLE PRECISION REAL + SDO_GEOMETRY SDO_TOPO_GEOMETRY SDO_GEORASTER + REF ANYTYPE ANYDATA ANYDATASET XMLTYPE HTTPURITYPE XDBURITYPE DUBRITYPE + BOOLEAN PLS_INTEGER BINARY_INTEGER SIMPLE_FLOAT SIMPLE_INTEGER SIMPLE_DOUBLE SYS_REFCURSOR + )) + end + + state :root do + delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' } + # eat whitespace including newlines + rule %r/\s+/m, Text + + # Comments + rule %r/--.*/, Comment::Single + rule %r(/\*), Comment::Multiline, :multiline_comments + + # literals + # Q' operator quoted string literal + rule %r/q'(.)/i do |m| + close = Regexp.escape(delimiter_map[m[1]] || m[1]) + # the opening q'X + token Operator + push do + rule %r/(?:#{close}[^']|[^#{close}]'|[^#{close}'])+/m, Str::Other + rule %r/#{close}'/, Operator, :pop! + end + end + rule %r/'/, Operator, :single_string + # A double-quoted string refers to a database object in our default SQL + rule %r/"/, Operator, :double_string + # preprocessor directive treated as special comment + rule %r/(\$(?:IF|THEN|ELSE|ELSIF|ERROR|END|(?:\$\$?[a-z]\w*)))(\s+)/im do + groups Comment::Preproc, Text + end + + # Numbers + rule %r/[+-]?(?:(?:\.\d+(?:[eE][+-]?\d+)?)|\d+\.(?:\d+(?:[eE][+-]?\d+)?)?)[fFdD]?/, Num::Float + rule %r/[+-]?\d+/, Num::Integer + + # Operators + # Special semi-operator, but this seems an appropriate classification + rule %r/%(?:TYPE|ROWTYPE|FOUND|ISOPEN|NOTFOUND|ROWCOUNT)\b/i, Name::Attribute + # longer ones come first on purpose! It matters to regex engine + rule %r/=>|\|\||\*\*|<<|>>|\.\.|<>|[:!~^<>]=|[-+%\/*=<>@&!^\[\]]/, Operator + rule %r/(NOT|AND|OR|LIKE|BETWEEN|IN)(\s)/im do + groups Operator::Word, Text + end + rule %r/(IS)(\s+)(?:(NOT)(\s+))?(NULL\b)/im do + groups Operator::Word, Text, Operator::Word, Text, Operator::Word + end + + # Punctuation + # special case of dot followed by a name. notice the lookahead assertion + rule %r/\.(?=\w)/ do + token Punctuation + push :dotnames + end + rule %r/[;:()\[\],.]/, Punctuation + + # Special processing for keywords with multiple contexts + # + # this madness is to keep the word "replace" from being treated as a builtin function in this context + rule %r/(create)(\s+)(?:(or)(\s+)(replace)(\s+))?(package|function|procedure|type)(?:(\s+)(body))?(\s+)([a-z][\w$]*)/im do + groups Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Name + end + # similar for MERGE keywords + rule %r/(when)(\s+)(?:(not)(\s+))?(matched)(\s+)(then)(\s+)(update|insert)\b(?:(\s+)(set)(\s+))?/im do + groups Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text + end + + # + # General keyword classification with sepcial attention to names + # in a chained "dot" notation. + # + rule %r/([a-zA-Z][\w$]*)(\.(?=\w))?/ do |m| + if self.class.keywords_type.include? m[1].upcase + tok = Keyword::Type + elsif self.class.keywords_func.include? m[1].upcase + tok = Name::Function + elsif self.class.keywords_reserved.include? m[1].upcase + tok = Keyword::Reserved + elsif self.class.keywords.include? m[1].upcase + tok = Keyword + else + tok = Name + end + groups tok, Punctuation + + if m[2] == "." + push :dotnames + end + end + end + + state :multiline_comments do + rule %r/([*][^\/]|[^*])+/m, Comment::Multiline + rule %r([*]\/), Comment::Multiline, :pop! + end + + state :single_string do + rule %r/\\./, Str::Escape + rule %r/''/, Str::Escape + rule %r/'/, Operator, :pop! + rule %r/[^\\']+/m, Str::Single + end + + state :double_string do + rule %r/\\./, Str::Escape + rule %r/""/, Str::Escape + rule %r/"/, Operator, :pop! + rule %r/[^\\"]+/m, Name::Variable + end + + state :dotnames do + # if we are followed by a dot and another name, we are an ordinary name + rule %r/([a-zA-Z][\w\$]*)(\.(?=\w))/ do + groups Name, Punctuation + end + # this rule WILL be true if something pushed into our state. That is our state contract + rule %r/[a-zA-Z][\w\$]*/ do |m| + if self.class.keywords_func.include? m[0].upcase + # The Function lookup allows collection methods like COUNT, FIRST, LAST, etc.. to be + # classified correctly. Occasionally misidentifies ordinary names as builtin functions, + # but seems to be as correct as we can get without becoming a full blown parser + token Name::Function + else + token Name + end + pop! + end + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/pony.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/pony.rb new file mode 100644 index 0000000..b0510b6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/pony.rb @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Pony < RegexLexer + tag 'pony' + filenames '*.pony' + + keywords = Set.new %w( + actor addressof and as + be break + class compiler_intrinsic consume continue + do + else elseif embed end error + for fun + if ifdef in interface is isnt + lambda let + match + new not + object + primitive + recover repeat return + struct + then this trait try type + until use + var + where while with + ) + + capabilities = Set.new %w( + box iso ref tag trn val + ) + + types = Set.new %w( + Number Signed Unsigned Float + I8 I16 I32 I64 I128 U8 U32 U64 U128 F32 F64 + EventID Align IntFormat NumberPrefix FloatFormat + Type + ) + + state :whitespace do + rule %r/\s+/m, Text + end + + state :root do + mixin :whitespace + rule %r/"""/, Str::Doc, :docstring + rule %r{//.*}, Comment::Single + rule %r{/(\\\n)?[*](.|\n)*?[*](\\\n)?/}, Comment::Multiline + rule %r/"/, Str, :string + rule %r([~!%^&*+=\|?:<>/-]), Operator + rule %r/(true|false|NULL)\b/, Name::Constant + rule %r{(?:[A-Z_][a-zA-Z0-9_]*)}, Name::Class + rule %r/[()\[\],.';]/, Punctuation + + # Numbers + rule %r/0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)[pP][+\-]?[0-9_]+[fFL]?[i]?/, Num::Float + rule %r/[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?/, Num::Float + rule %r/\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?/, Num::Float + rule %r/0[xX][0-9a-fA-F_]+/, Num::Hex + rule %r/(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?/, Num::Integer + + rule %r/[a-z_][a-z0-9_]*/io do |m| + match = m[0] + + if capabilities.include?(match) + token Keyword::Declaration + elsif keywords.include?(match) + token Keyword::Reserved + elsif types.include?(match) + token Keyword::Type + else + token Name + end + end + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape + rule %r/[^\\"\n]+/, Str + rule %r/\\\n/, Str + rule %r/\\/, Str # stray backslash + end + + state :docstring do + rule %r/"""/, Str::Doc, :pop! + rule %r/\n/, Str::Doc + rule %r/./, Str::Doc + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/postscript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/postscript.rb new file mode 100644 index 0000000..57e8b61 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/postscript.rb @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# Adapted from pygments PostScriptLexer +module Rouge + module Lexers + class PostScript < RegexLexer + title "PostScript" + desc "The PostScript language (adobe.com/devnet/postscript.html)" + tag "postscript" + aliases "postscr", "postscript", "ps", "eps" + filenames "*.ps", "*.eps" + mimetypes "application/postscript" + + def self.detect?(text) + return true if /^%!/ =~ text + end + + delimiter = %s"()<>\[\]{}/%\s" + delimiter_end = Regexp.new("(?=[#{delimiter}])") + valid_name_chars = Regexp.new("[^#{delimiter}]") + valid_name = /#{valid_name_chars}+#{delimiter_end}/ + + # These keywords taken from + # + # Is there an authoritative list anywhere that doesn't involve + # trawling documentation? + keywords = %w/abs add aload arc arcn array atan begin + bind ceiling charpath clip closepath concat + concatmatrix copy cos currentlinewidth currentmatrix + currentpoint curveto cvi cvs def defaultmatrix + dict dictstackoverflow div dtransform dup end + exch exec exit exp fill findfont floor get + getinterval grestore gsave identmatrix idiv + idtransform index invertmatrix itransform length + lineto ln load log loop matrix mod moveto + mul neg newpath pathforall pathbbox pop print + pstack put quit rand rangecheck rcurveto repeat + restore rlineto rmoveto roll rotate round run + save scale scalefont setdash setfont setgray + setlinecap setlinejoin setlinewidth setmatrix + setrgbcolor shfill show showpage sin sqrt + stack stringwidth stroke strokepath sub syntaxerror + transform translate truncate typecheck undefined + undefinedfilename undefinedresult/ + + state :root do + # All comment types + rule %r'^%!.+?$', Comment::Preproc + rule %r'%%.*?$', Comment::Special + rule %r'(^%.*?$){2,}', Comment::Multiline + rule %r'%.*?$', Comment::Single + + # String literals are awkward; enter separate state. + rule %r'\(', Str, :stringliteral + + # References + rule %r'/#{valid_name}', Name::Variable + + rule %r'[{}<>\[\]]', Punctuation + + rule %r'(?:#{keywords.join('|')})#{delimiter_end}', Name::Builtin + + # Conditionals / flow control + rule %r'(eq|ne|g[et]|l[et]|and|or|not|if(?:else)?|for(?:all)?)#{delimiter_end}', Keyword::Reserved + rule %r'(false|true)#{delimiter_end}', Keyword::Constant + + # Numbers + rule %r'<[0-9A-Fa-f]+>#{delimiter_end}', Num::Hex + # Slight abuse: use Oct to signify any explicit base system + rule %r'[0-9]+\#(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)((e|E)[0-9]+)?#{delimiter_end}', Num::Oct + rule %r'(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)((e|E)[0-9]+)?#{delimiter_end}', Num::Float + rule %r'(\-|\+)?[0-9]+#{delimiter_end}', Num::Integer + + # Names + rule valid_name, Name::Function # Anything else is executed + + rule %r'\s+', Text + end + + state :stringliteral do + rule %r'[^()\\]+', Str + rule %r'\\', Str::Escape, :escape + rule %r'\(', Str, :stringliteral + rule %r'\)', Str, :pop! + end + + state :escape do + rule %r'[0-8]{3}|n|r|t|b|f|\\|\(|\)', Str::Escape, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/powershell.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/powershell.rb new file mode 100644 index 0000000..72bb0ab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/powershell.rb @@ -0,0 +1,248 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + + class Powershell < RegexLexer + title 'powershell' + desc 'powershell' + tag 'powershell' + aliases 'posh', 'microsoftshell', 'msshell' + filenames '*.ps1', '*.psm1', '*.psd1', '*.psrc', '*.pssc' + mimetypes 'text/x-powershell' + + # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_cmdletbindingattribute?view=powershell-6 + ATTRIBUTES = %w( + ConfirmImpact DefaultParameterSetName HelpURI PositionalBinding + SupportsPaging SupportsShouldProcess + ) + + # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-6 + AUTO_VARS = %w( + \$\$ \$\? \$\^ \$_ + \$args \$ConsoleFileName \$Error \$Event \$EventArgs \$EventSubscriber + \$ExecutionContext \$false \$foreach \$HOME \$Host \$input \$IsCoreCLR + \$IsLinux \$IsMacOS \$IsWindows \$LastExitCode \$Matches \$MyInvocation + \$NestedPromptLevel \$null \$PID \$PROFILE \$PSBoundParameters \$PSCmdlet + \$PSCommandPath \$PSCulture \$PSDebugContext \$PSHOME \$PSItem + \$PSScriptRoot \$PSSenderInfo \$PSUICulture \$PSVersionTable \$PWD + \$REPORTERRORSHOWEXCEPTIONCLASS \$REPORTERRORSHOWINNEREXCEPTION + \$REPORTERRORSHOWSOURCE \$REPORTERRORSHOWSTACKTRACE + \$SENDER \$ShellId \$StackTrace \$switch \$this \$true + ).join('|') + + # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_reserved_words?view=powershell-6 + KEYWORDS = %w( + assembly exit process base filter public begin finally return break for + sequence catch foreach static class from switch command function throw + configuration hidden trap continue if try data in type define + inlinescript until do interface using dynamicparam module var else + namespace while elseif parallel workflow end param enum private + ).join('|') + + # https://devblogs.microsoft.com/scripting/powertip-find-a-list-of-powershell-type-accelerators/ + # ([PSObject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::Get).Keys -join ' ' + KEYWORDS_TYPE = %w( + Alias AllowEmptyCollection AllowEmptyString AllowNull ArgumentCompleter + array bool byte char CmdletBinding datetime decimal double DscResource + float single guid hashtable int int32 int16 long int64 ciminstance + cimclass cimtype cimconverter IPEndpoint NullString OutputType + ObjectSecurity Parameter PhysicalAddress pscredential PSDefaultValue + pslistmodifier psobject pscustomobject psprimitivedictionary ref + PSTypeNameAttribute regex DscProperty sbyte string SupportsWildcards + switch cultureinfo bigint securestring timespan uint16 uint32 uint64 + uri ValidateCount ValidateDrive ValidateLength ValidateNotNull + ValidateNotNullOrEmpty ValidatePattern ValidateRange ValidateScript + ValidateSet ValidateTrustedData ValidateUserDrive version void + ipaddress DscLocalConfigurationManager WildcardPattern X509Certificate + X500DistinguishedName xml CimSession adsi adsisearcher wmiclass wmi + wmisearcher mailaddress scriptblock psvariable type psmoduleinfo + powershell runspacefactory runspace initialsessionstate psscriptmethod + psscriptproperty psnoteproperty psaliasproperty psvariableproperty + ).join('|') + + OPERATORS = %w( + -split -isplit -csplit -join -is -isnot -as -eq -ieq -ceq -ne -ine -cne + -gt -igt -cgt -ge -ige -cge -lt -ilt -clt -le -ile -cle -like -ilike + -clike -notlike -inotlike -cnotlike -match -imatch -cmatch -notmatch + -inotmatch -cnotmatch -contains -icontains -ccontains -notcontains + -inotcontains -cnotcontains -replace -ireplace -creplace -shl -shr -band + -bor -bxor -and -or -xor -not \+= -= \*= \/= %= + ).join('|') + + MULTILINE_KEYWORDS = %w( + synopsis description parameter example inputs outputs notes link + component role functionality forwardhelptargetname forwardhelpcategory + remotehelprunspace externalhelp + ).join('|') + + state :variable do + rule %r/#{AUTO_VARS}/, Name::Builtin::Pseudo + rule %r/(\$)(?:(\w+)(:))?(\w+|\{(?:[^`]|`.)+?\})/ do + groups Name::Variable, Name::Namespace, Punctuation, Name::Variable + end + rule %r/\$\w+/, Name::Variable + rule %r/\$\{(?:[^`]|`.)+?\}/, Name::Variable + end + + state :multiline do + rule %r/\.(?:#{MULTILINE_KEYWORDS})/i, Comment::Special + rule %r/#>/, Comment::Multiline, :pop! + rule %r/[^#.]+?/m, Comment::Multiline + rule %r/[#.]+/, Comment::Multiline + end + + state :interpol do + rule %r/\)/, Str::Interpol, :pop! + mixin :root + end + + state :dq do + # NB: "abc$" is literally the string abc$. + # Here we prevent :interp from interpreting $" as a variable. + rule %r/(?:\$#?)?"/, Str::Double, :pop! + rule %r/\$\(/, Str::Interpol, :interpol + rule %r/`$/, Str::Escape # line continuation + rule %r/`./, Str::Escape + rule %r/[^"`$]+/, Str::Double + mixin :variable + end + + state :sq do + rule %r/'/, Str::Single, :pop! + rule %r/[^']+/, Str::Single + end + + state :heredoc do + rule %r/(?:\$#?)?"@/, Str::Heredoc, :pop! + rule %r/\$\(/, Str::Interpol, :interpol + rule %r/`$/, Str::Escape # line continuation + rule %r/`./, Str::Escape + rule %r/[^"`$]+?/m, Str::Heredoc + rule %r/"+/, Str::Heredoc + mixin :variable + end + + state :class do + rule %r/\{/, Punctuation, :pop! + rule %r/\s+/, Text::Whitespace + rule %r/\w+/, Name::Class + rule %r/[:,]/, Punctuation + end + + state :expr do + mixin :comments + rule %r/"/, Str::Double, :dq + rule %r/'/, Str::Single, :sq + rule %r/@"/, Str::Heredoc, :heredoc + rule %r/@'.*?'@/m, Str::Heredoc + rule %r/\d*\.\d+/, Num::Float + rule %r/\d+/, Num::Integer + rule %r/@\{/, Punctuation, :hasht + rule %r/@\(/, Punctuation, :array + rule %r/{/, Punctuation, :brace + rule %r/\[/, Punctuation, :bracket + end + + state :hasht do + rule %r/\}/, Punctuation, :pop! + rule %r/=/, Operator + rule %r/[,;]/, Punctuation + mixin :expr + rule %r/\w+/, Name::Other + mixin :variable + end + + state :array do + rule %r/\s+/, Text::Whitespace + rule %r/\)/, Punctuation, :pop! + rule %r/[,;]/, Punctuation + mixin :expr + mixin :variable + end + + state :brace do + rule %r/[}]/, Punctuation, :pop! + mixin :root + end + + state :bracket do + rule %r/\]/, Punctuation, :pop! + rule %r/[A-Za-z]\w+\./, Name + rule %r/([A-Za-z]\w+)/ do |m| + if ATTRIBUTES.include? m[0] + token Name::Builtin::Pseudo + else + token Name + end + end + mixin :root + end + + state :parameters do + rule %r/`./m, Str::Escape + rule %r/\)/ do + token Punctuation + pop!(2) if in_state?(:interpol) # pop :parameters and :interpol + end + rule %r/\s*?\n/, Text::Whitespace, :pop! + rule %r/[;(){}\]]/, Punctuation, :pop! + rule %r/[|=]/, Operator, :pop! + rule %r/[\/\\~\w][-.:\/\\~\w]*/, Name::Other + rule %r/\w[-\w]+/, Name::Other + mixin :root + end + + state :comments do + rule %r/\s+/, Text::Whitespace + rule %r/#.*/, Comment + rule %r/<#/, Comment::Multiline, :multiline + end + + state :root do + mixin :comments + rule %r/#requires\s-version \d(?:\.\d+)?/, Comment::Preproc + + rule %r/\.\.(?=\.?\d)/, Operator + rule %r/(?:#{OPERATORS})\b/i, Operator + + rule %r/(class)(\s+)(\w+)/i do + groups Keyword::Reserved, Text::Whitespace, Name::Class + push :class + end + rule %r/(function)(\s+)(?:(\w+)(:))?(\w[-\w]+)/i do + groups Keyword::Reserved, Text::Whitespace, Name::Namespace, Punctuation, Name::Function + end + rule %r/(?:#{KEYWORDS})\b(?![-.])/i, Keyword::Reserved + + rule %r/-{1,2}\w+/, Name::Tag + + rule %r/(\.)?([-\w]+)(\[)/ do |m| + groups Operator, Name, Punctuation + push :bracket + end + + rule %r/([\/\\~[a-z]][-.:\/\\~\w]*)(\n)?/i do |m| + groups Name, Text::Whitespace + push :parameters + end + + rule %r/(\.)([-\w]+)(?:(\()|(\n))?/ do |m| + groups Operator, Name::Function, Punctuation, Text::Whitespace + push :parameters unless m[3].nil? + end + + rule %r/\?/, Name::Function, :parameters + + mixin :expr + mixin :variable + + rule %r/[-+*\/%=!.&|]/, Operator + rule %r/[{}(),:;]/, Punctuation + + rule %r/`$/, Str::Escape # line continuation + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/praat.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/praat.rb new file mode 100644 index 0000000..1dc78a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/praat.rb @@ -0,0 +1,438 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Praat < RegexLexer + title "Praat" + desc "The Praat scripting language (praat.org)" + + tag 'praat' + + filenames '*.praat', '*.proc', '*.psc' + + def self.detect?(text) + return true if text.shebang? 'praat' + end + + def self.keywords + @keywords ||= %w( + if then else elsif elif endif fi for from to endfor endproc while + endwhile repeat until select plus minus demo assert stopwatch + nocheck nowarn noprogress editor endeditor clearinfo + ) + end + + def self.functions_string + @functions_string ||= %w( + backslashTrigraphsToUnicode$ chooseDirectory$ chooseReadFile$ + chooseWriteFile$ date$ demoKey$ do$ environment$ extractLine$ extractWord$ + fixed$ info$ left$ mid$ percent$ readFile$ replace$ replace_regex$ right$ + selected$ string$ unicodeToBackslashTrigraphs$ + ) + end + + def self.functions_numeric + @functions_numeric ||= %w( + abs appendFile appendFileLine appendInfo appendInfoLine arccos arccosh + arcsin arcsinh arctan arctan2 arctanh barkToHertz beginPause + beginSendPraat besselI besselK beta beta2 binomialP binomialQ boolean + ceiling chiSquareP chiSquareQ choice comment cos cosh createDirectory + deleteFile demoClicked demoClickedIn demoCommandKeyPressed + demoExtraControlKeyPressed demoInput demoKeyPressed + demoOptionKeyPressed demoShiftKeyPressed demoShow demoWaitForInput + demoWindowTitle demoX demoY differenceLimensToPhon do editor endPause + endSendPraat endsWith erb erbToHertz erf erfc exitScript exp + extractNumber fileReadable fisherP fisherQ floor gaussP gaussQ hash + hertzToBark hertzToErb hertzToMel hertzToSemitones imax imin + incompleteBeta incompleteGammaP index index_regex integer invBinomialP + invBinomialQ invChiSquareQ invFisherQ invGaussQ invSigmoid invStudentQ + length ln lnBeta lnGamma log10 log2 max melToHertz min minusObject + natural number numberOfColumns numberOfRows numberOfSelected + objectsAreIdentical option optionMenu pauseScript + phonToDifferenceLimens plusObject positive randomBinomial randomGauss + randomInteger randomPoisson randomUniform real readFile removeObject + rindex rindex_regex round runScript runSystem runSystem_nocheck + selectObject selected semitonesToHertz sentence sentencetext sigmoid + sin sinc sincpi sinh soundPressureToPhon sqrt startsWith studentP + studentQ tan tanh text variableExists word writeFile writeFileLine + writeInfo writeInfoLine + ) + end + + def self.functions_array + @functions_array ||= %w( + linear# randomGauss# randomInteger# randomUniform# zero# + ) + end + + def self.functions_matrix + @functions_matrix ||= %w( + linear## mul## mul_fast## mul_metal## mul_nt## mul_tn## mul_tt## outer## peaks## + randomGamma## randomGauss## randomInteger## randomUniform## softmaxPerRow## + solve## transpose## zero## + ) + end + + def self.functions_string_vector + @functions_string_vector ||= %w( + empty$# fileNames$# folderNames$# readLinesFromFile$# splitByWhitespace$# + ) + end + + def self.functions_builtin + @functions_builtin ||= + self.functions_string | + self.functions_numeric | + self.functions_array | + self.functions_matrix | + self.functions_string_vector + end + + def self.objects + @objects ||= %w( + Activation AffineTransform AmplitudeTier Art Artword Autosegment + BarkFilter BarkSpectrogram CCA Categories Cepstrogram Cepstrum + Cepstrumc ChebyshevSeries ClassificationTable Cochleagram Collection + ComplexSpectrogram Configuration Confusion ContingencyTable Corpus + Correlation Covariance CrossCorrelationTable CrossCorrelationTableList + CrossCorrelationTables DTW DataModeler Diagonalizer Discriminant + Dissimilarity Distance Distributions DurationTier EEG ERP ERPTier + EditCostsTable EditDistanceTable Eigen Excitation Excitations + ExperimentMFC FFNet FeatureWeights FileInMemory FilesInMemory Formant + FormantFilter FormantGrid FormantModeler FormantPoint FormantTier + GaussianMixture HMM HMM_Observation HMM_ObservationSequence HMM_State + HMM_StateSequence HMMObservation HMMObservationSequence HMMState + HMMStateSequence Harmonicity ISpline Index Intensity IntensityTier + IntervalTier KNN KlattGrid KlattTable LFCC LPC Label LegendreSeries + LinearRegression LogisticRegression LongSound Ltas MFCC MSpline ManPages + Manipulation Matrix MelFilter MelSpectrogram MixingMatrix Movie Network + OTGrammar OTHistory OTMulti PCA PairDistribution ParamCurve Pattern + Permutation Photo Pitch PitchModeler PitchTier PointProcess Polygon + Polynomial PowerCepstrogram PowerCepstrum Procrustes RealPoint RealTier + ResultsMFC Roots SPINET SSCP SVD Salience ScalarProduct Similarity + SimpleString SortedSetOfString Sound Speaker Spectrogram Spectrum + SpectrumTier SpeechSynthesizer SpellingChecker Strings StringsIndex + Table TableOfReal TextGrid TextInterval TextPoint TextTier Tier + Transition VocalTract VocalTractTier Weight WordList + ) + end + + def self.variables_numeric + @variables_numeric ||= %w( + all average e left macintosh mono pi praatVersion right stereo + undefined unix windows + ) + end + + def self.variables_string + @variables_string ||= %w( + praatVersion$ tab$ shellDirectory$ homeDirectory$ + preferencesDirectory$ newline$ temporaryDirectory$ + defaultDirectory$ + ) + end + + def self.object_attributes + @object_attributes ||= %w( + ncol nrow xmin ymin xmax ymax nx ny dx dy + ) + end + + state :root do + rule %r/(\s+)(#.*?$)/ do + groups Text, Comment::Single + end + + rule %r/^#.*?$/, Comment::Single + rule %r/;[^\n]*/, Comment::Single + rule %r/\s+/, Text + + rule %r/(\bprocedure)(\s+)/ do + groups Keyword, Text + push :procedure_definition + end + + rule %r/(\bcall)(\s+)/ do + groups Keyword, Text + push :procedure_call + end + + rule %r/@/, Name::Function, :procedure_call + + mixin :function_call + + rule %r/\b(?:select all)\b/, Keyword + + rule %r/(\bform\b)(\s+)([^\n]+)/ do + groups Keyword, Text, Literal::String + push :old_form + end + + rule %r/(print(?:line|tab)?|echo|exit|asserterror|pause|send(?:praat|socket)|include|execute|system(?:_nocheck)?)(\s+)/ do + groups Keyword, Text + push :string_unquoted + end + + rule %r/(goto|label)(\s+)(\w+)/ do + groups Keyword, Text, Name::Label + end + + mixin :variable_name + mixin :number + mixin :vector_literal + + rule %r/"/, Literal::String, :string + + rule %r/\b([A-Z][a-zA-Z0-9]+)(?=\s+\S+\n)/ do |m| + match = m[0] + if self.class.objects.include?(match) + token Name::Class + push :string_unquoted + else + token Keyword + end + end + + rule %r/\b(?=[A-Z])/, Text, :command + rule %r/(\.{3}|[)(,\$])/, Punctuation + + rule %r/[a_z]+/ do |m| + match = m[0] + if self.class.keywords.include?(match) + token Keyword + else + token Text + end + end + end + + state :command do + rule %r/( ?([^\s:\.'])+ ?)/, Keyword + mixin :string_interpolated + + rule %r/\.{3}/ do + token Keyword + pop! + push :old_arguments + end + + rule %r/:/ do + token Keyword + pop! + push :comma_list + end + + rule %r/[\s]/, Text, :pop! + end + + state :procedure_call do + mixin :string_interpolated + + rule %r/(:|\s*\()/, Punctuation, :pop! + + rule %r/'/, Name::Function + rule %r/[^:\('\s]+/, Name::Function + + rule %r/(?=\s+)/ do + token Text + pop! + push :old_arguments + end + end + + state :procedure_definition do + rule %r/(:|\s*\()/, Punctuation, :pop! + + rule %r/[^:\(\s]+/, Name::Function + + rule %r/(\s+)/, Text, :pop! + end + + state :function_call do + rule %r/\b([a-z][a-zA-Z0-9_.]+)(\$#|##|\$|#)?(?=\s*[:(])/ do |m| + match = m[0] + if self.class.functions_builtin.include?(match) + token Name::Function + push :function + elsif self.class.keywords.include?(match) + token Keyword + else + token Operator::Word + end + end + end + + state :function do + rule %r/\s+/, Text + + rule %r/(?::|\s*\()/ do + token Text + pop! + push :comma_list + end + end + + state :comma_list do + rule %r/(\s*\n\s*)(\.{3})/ do + groups Text, Punctuation + end + + rule %r/\s*[\]\})\n]/, Text, :pop! + + rule %r/\s+/, Text + rule %r/"/, Literal::String, :string + rule %r/\b(if|then|else|fi|endif)\b/, Keyword + + mixin :function_call + mixin :variable_name + mixin :operator + mixin :number + mixin :vector_literal + + rule %r/[()]/, Text + rule %r/,/, Punctuation + end + + state :old_arguments do + rule %r/\n/, Text, :pop! + + mixin :variable_name + mixin :operator + mixin :number + + rule %r/"/, Literal::String, :string + rule %r/[^\n]/, Text + end + + state :number do + rule %r/\n/, Text, :pop! + rule %r/\b\d+(\.\d*)?([eE][-+]?\d+)?%?/, Literal::Number + end + + state :variable_name do + mixin :operator + mixin :number + + rule %r/\b([A-Z][a-zA-Z0-9]+)_/ do |m| + match = m[1] + if (['Object'] | self.class.objects).include?(match) + token Name::Builtin + push :object_reference + else + token Name::Variable + end + end + + rule %r/\.?[a-z][a-zA-Z0-9_.]*(\$#|##|\$|#)?/ do |m| + match = m[0] + if self.class.variables_string.include?(match) || + self.class.variables_numeric.include?(match) + token Name::Builtin + elsif self.class.keywords.include?(match) + token Keyword + else + token Name::Variable + end + end + + rule %r/[\[\]]/, Text, :comma_list + mixin :string_interpolated + end + + state :vector_literal do + rule %r/(\{)/, Text, :comma_list + end + + state :object_reference do + mixin :string_interpolated + rule %r/([a-z][a-zA-Z0-9_]*|\d+)/, Name::Builtin + + rule %r/\.([a-z]+)\b/ do |m| + match = m[1] + if self.class.object_attributes.include?(match) + token Name::Builtin + pop! + end + end + + rule %r/\$/, Name::Builtin + rule %r/\[/, Text, :pop! + end + + state :operator do + # This rule incorrectly matches === or +++++, which are not operators + rule %r/([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)/, Operator + rule %r/(?/, Punctuation + + rule %r/"[^"]*"/, Str::Double + + rule %r/\d+\.\d+/, Num::Float + rule %r/\d+/, Num + end + + state :atoms do + rule %r/[[:lower:]]([[:word:]])*/, Str::Symbol + rule %r/'[^']*'/, Str::Symbol + end + + state :operators do + rule %r/(<|>|=<|>=|==|=:=|=|\/|\/\/|\*|\+|-)(?=\s|[a-zA-Z0-9\[])/, + Operator + rule %r/is/, Operator + rule %r/(mod|div|not)/, Operator + rule %r/[#&*+-.\/:<=>?@^~]+/, Operator + end + + state :variables do + rule %r/[A-Z]+\w*/, Name::Variable + rule %r/_[[:word:]]*/, Name::Variable + end + + state :root do + mixin :basic + mixin :atoms + mixin :variables + mixin :operators + end + + state :nested_comment do + rule %r(/\*), Comment::Multiline, :push + rule %r/\s*\*[^*\/]+/, Comment::Multiline + rule %r(\*/), Comment::Multiline, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/prometheus.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/prometheus.rb new file mode 100644 index 0000000..c27f7bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/prometheus.rb @@ -0,0 +1,122 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + class Prometheus < RegexLexer + desc 'prometheus' + tag 'prometheus' + aliases 'prometheus' + filenames '*.prometheus' + + mimetypes 'text/x-prometheus', 'application/x-prometheus' + + def self.functions + @functions ||= Set.new %w( + abs absent ceil changes clamp_max clamp_min count_scalar day_of_month + day_of_week days_in_month delta deriv drop_common_labels exp floor + histogram_quantile holt_winters hour idelta increase irate label_replace + ln log2 log10 month predict_linear rate resets round scalar sort + sort_desc sqrt time vector year avg_over_time min_over_time + max_over_time sum_over_time count_over_time quantile_over_time + stddev_over_time stdvar_over_time + ) + end + + state :root do + mixin :strings + mixin :whitespace + + rule %r/-?\d+\.\d+/, Num::Float + rule %r/-?\d+[smhdwy]?/, Num::Integer + + mixin :operators + + rule %r/(ignoring|on)(\()/ do + groups Keyword::Pseudo, Punctuation + push :label_list + end + rule %r/(group_left|group_right)(\()/ do + groups Keyword::Type, Punctuation + end + rule %r/(bool|offset)\b/, Keyword + rule %r/(without|by)\b/, Keyword, :label_list + rule %r/[\w:]+/ do |m| + if self.class.functions.include?(m[0]) + token Name::Builtin + else + token Name + end + end + + mixin :metrics + end + + state :metrics do + rule %r/[a-zA-Z0-9_-]+/, Name + + rule %r/[\(\)\]:.,]/, Punctuation + rule %r/\{/, Punctuation, :filters + rule %r/\[/, Punctuation + end + + state :strings do + rule %r/"/, Str::Double, :double_string_escaped + rule %r/'/, Str::Single, :single_string_escaped + rule %r/`.*`/, Str::Backtick + end + + [ + [:double, Str::Double, '"'], + [:single, Str::Single, "'"] + ].each do |name, tok, fin| + state :"#{name}_string_escaped" do + rule %r/\\[\\abfnrtv#{fin}]/, Str::Escape + rule %r/[^\\#{fin}]+/m, tok + rule %r/#{fin}/, tok, :pop! + end + end + + state :filters do + mixin :inline_whitespace + rule %r/,/, Punctuation + mixin :labels + mixin :filter_matching_operators + mixin :strings + rule %r/}/, Punctuation, :pop! + end + + state :label_list do + rule %r/\(/, Punctuation + rule %r/[a-zA-Z0-9_:-]+/, Name::Attribute + rule %r/,/, Punctuation + mixin :whitespace + rule %r/\)/, Punctuation, :pop! + end + + state :labels do + rule %r/[a-zA-Z0-9_:-]+/, Name::Attribute + end + + state :operators do + rule %r([+\-\*/%\^]), Operator # Arithmetic + rule %r(=|==|!=|<|>|<=|>=), Operator # Comparison + rule %r/and|or|unless/, Operator # Logical/Set + rule %r/(sum|min|max|avg|stddev|stdvar|count|count_values|bottomk|topk)\b/, Name::Function + end + + state :filter_matching_operators do + rule %r/!(=|~)|=~?/, Operator + end + + state :inline_whitespace do + rule %r/[ \t\r]+/, Text + end + + state :whitespace do + mixin :inline_whitespace + rule %r/\n\s*/m, Text + rule %r/#.*?$/, Comment + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/properties.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/properties.rb new file mode 100644 index 0000000..12ec807 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/properties.rb @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Properties < RegexLexer + title ".properties" + desc '.properties config files for Java' + tag 'properties' + + filenames '*.properties' + mimetypes 'text/x-java-properties' + + identifier = /[\w.-]+/ + + state :basic do + rule %r/[!#].*?\n/, Comment + rule %r/\s+/, Text + rule %r/\\\n/, Str::Escape + end + + state :root do + mixin :basic + + rule %r/(#{identifier})(\s*)([=:])/ do + groups Name::Property, Text, Punctuation + push :value + end + end + + state :value do + rule %r/\n/, Text, :pop! + mixin :basic + rule %r/"/, Str, :dq + rule %r/'.*?'/, Str + mixin :esc_str + rule %r/[^\\\n]+/, Str + end + + state :dq do + rule %r/"/, Str, :pop! + mixin :esc_str + rule %r/[^\\"]+/m, Str + end + + state :esc_str do + rule %r/\\u[0-9]{4}/, Str::Escape + rule %r/\\./m, Str::Escape + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/protobuf.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/protobuf.rb new file mode 100644 index 0000000..9ac6c97 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/protobuf.rb @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Protobuf < RegexLexer + title 'Protobuf' + desc 'Google\'s language-neutral, platform-neutral, extensible mechanism for serializing structured data' + tag 'protobuf' + aliases 'proto' + filenames '*.proto' + mimetypes 'text/x-proto' + + kw = /\b(ctype|default|extensions|import|max|oneof|option|optional|packed|repeated|required|returns|rpc|to)\b/ + datatype = /\b(bool|bytes|double|fixed32|fixed64|float|int32|int64|sfixed32|sfixed64|sint32|sint64|string|uint32|uint64)\b/ + + state :root do + rule %r/[\s]+/, Text + rule %r/[,;{}\[\]()]/, Punctuation + rule %r/\/(\\\n)?\/($|(.|\n)*?[^\\]$)/, Comment::Single + rule %r/\/(\\\n)?\*(.|\n)*?\*(\\\n)?\//, Comment::Multiline + rule kw, Keyword + rule datatype, Keyword::Type + rule %r/true|false/, Keyword::Constant + rule %r/(package)(\s+)/ do + groups Keyword::Namespace, Text + push :package + end + + rule %r/(message|extend)(\s+)/ do + groups Keyword::Declaration, Text + push :message + end + + rule %r/(enum|group|service)(\s+)/ do + groups Keyword::Declaration, Text + push :type + end + + rule %r/".*?"/, Str + rule %r/'.*?'/, Str + rule %r/(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*/, Num::Float + rule %r/(\d+\.\d*|\.\d+|\d+[fF])[fF]?/, Num::Float + rule %r/(\-?(inf|nan))\b/, Num::Float + rule %r/0x[0-9a-fA-F]+[LlUu]*/, Num::Hex + rule %r/0[0-7]+[LlUu]*/, Num::Oct + rule %r/\d+[LlUu]*/, Num::Integer + rule %r/[+-=]/, Operator + rule %r/([a-zA-Z_][\w.]*)([ \t]*)(=)/ do + groups Name::Attribute, Text, Operator + end + rule %r/[a-zA-Z_][\w.]*/, Name + end + + state :package do + rule %r/[a-zA-Z_]\w*/, Name::Namespace, :pop! + rule(//) { pop! } + end + + state :message do + rule %r/[a-zA-Z_]\w*/, Name::Class, :pop! + rule(//) { pop! } + end + + state :type do + rule %r/[a-zA-Z_]\w*/, Name, :pop! + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/puppet.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/puppet.rb new file mode 100644 index 0000000..9726bd9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/puppet.rb @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Puppet < RegexLexer + title "Puppet" + desc 'The Puppet configuration management language (puppetlabs.org)' + tag 'puppet' + aliases 'pp' + filenames '*.pp' + + def self.detect?(text) + return true if text.shebang? 'puppet-apply' + return true if text.shebang? 'puppet' + end + + def self.keywords + @keywords ||= Set.new %w( + and case class default define else elsif if in import inherits + node unless + ) + end + + def self.constants + @constants ||= Set.new %w( + false true undef + ) + end + + def self.metaparameters + @metaparameters ||= Set.new %w( + before require notify subscribe + ) + end + + id = /[a-z]\w*/ + cap_id = /[A-Z]\w*/ + qualname = /(::)?(#{id}::)*\w+/ + + state :whitespace do + rule %r/\s+/m, Text + rule %r/#.*?\n/, Comment + end + + state :root do + mixin :whitespace + + rule %r/[$]#{qualname}/, Name::Variable + rule %r/(#{id})(?=\s*[=+]>)/m do |m| + if self.class.metaparameters.include? m[0] + token Keyword::Pseudo + else + token Name::Property + end + end + + rule %r/(#{qualname})(?=\s*[(])/m, Name::Function + rule cap_id, Name::Class + + rule %r/[+=|~-]>|<[|~-]/, Punctuation + rule %r/[|:}();\[\]]/, Punctuation + + # HACK for case statements and selectors + rule %r/{/, Punctuation, :regex_allowed + rule %r/,/, Punctuation, :regex_allowed + + rule %r/(in|and|or)\b/, Operator::Word + rule %r/[=!<>]=/, Operator + rule %r/[=!]~/, Operator, :regex_allowed + rule %r([.=<>!+*/-]), Operator + + rule %r/(class|include)(\s*)(#{qualname})/ do + groups Keyword, Text, Name::Class + end + + rule %r/node\b/, Keyword, :regex_allowed + + rule %r/'(\\[\\']|[^'])*'/m, Str::Single + rule %r/"/, Str::Double, :dquotes + + rule %r/\d+([.]\d+)?(e[+-]\d+)?/, Num + + # a valid regex. TODO: regexes are only allowed + # in certain places in puppet. + rule qualname do |m| + if self.class.keywords.include? m[0] + token Keyword + elsif self.class.constants.include? m[0] + token Keyword::Constant + else + token Name + end + end + end + + state :regex_allowed do + mixin :whitespace + rule %r(/), Str::Regex, :regex + + rule(//) { pop! } + end + + state :regex do + rule %r(/), Str::Regex, :pop! + rule %r/\\./, Str::Escape + rule %r/[(){}]/, Str::Interpol + rule %r/\[/, Str::Interpol, :regex_class + rule %r/./, Str::Regex + end + + state :regex_class do + rule %r/\]/, Str::Interpol, :pop! + rule %r/(?>|\/\/|\*\*)=?/, Operator + rule %r/[-~+\/*%=<>&^|@]=?|!=/, Operator + + rule %r/(from)((?:\\\s|\s)+)(#{dotted_identifier})((?:\\\s|\s)+)(import)/ do + groups Keyword::Namespace, + Text, + Name, + Text, + Keyword::Namespace + end + + rule %r/(import)(\s+)(#{dotted_identifier})/ do + groups Keyword::Namespace, Text, Name + end + + rule %r/(def)((?:\s|\\\s)+)/ do + groups Keyword, Text + push :funcname + end + + rule %r/(class)((?:\s|\\\s)+)/ do + groups Keyword, Text + push :classname + end + + rule %r/([a-z_]\w*)[ \t]*(?=(\(.*\)))/m, Name::Function + rule %r/([A-Z_]\w*)[ \t]*(?=(\(.*\)))/m, Name::Class + + # TODO: not in python 3 + rule %r/`.*?`/, Str::Backtick + rule %r/([rfbu]{0,2})('''|"""|['"])/i do |m| + groups Str::Affix, Str::Heredoc + current_string.register type: m[1].downcase, delim: m[2] + push :generic_string + end + + # using negative lookbehind so we don't match property names + rule %r/(?>>|\.\.\.)\B/, Generic::Prompt, :doctest + rule %r/[^'"\\{]+?/, Str + rule %r/{{/, Str + + rule %r/'''|"""|['"]/ do |m| + token Str::Heredoc + if current_string.delim? m[0] + current_string.remove + pop! + end + end + + rule %r/(?=\\)/, Str, :generic_escape + + rule %r/{/ do |m| + if current_string.type? "f" + token Str::Interpol + push :generic_interpol + else + token Str + end + end + end + + state :generic_escape do + rule %r(\\ + ( [\\abfnrtv"'] + | \n + | newline + | N{[a-zA-Z][a-zA-Z ]+[a-zA-Z]} + | u[a-fA-F0-9]{4} + | U[a-fA-F0-9]{8} + | x[a-fA-F0-9]{2} + | [0-7]{1,3} + ) + )x do + current_string.type?("r") ? token(Str) : token(Str::Escape) + pop! + end + + rule %r/\\./, Str, :pop! + end + + state :doctest do + rule %r/\n\n/, Text, :pop! + + rule %r/'''|"""/ do + token Str::Heredoc + pop!(2) if in_state?(:generic_string) # pop :doctest and :generic_string + end + + mixin :root + end + + state :generic_interpol do + rule %r/[^{}!:]+/ do |m| + recurse m[0] + end + rule %r/![asr]/, Str::Interpol + rule %r/:/, Str::Interpol + rule %r/{/, Str::Interpol, :generic_interpol + rule %r/}/, Str::Interpol, :pop! + end + + class StringRegister < Array + def delim?(delim) + self.last[1] == delim + end + + def register(type: "u", delim: "'") + self.push [type, delim] + end + + def remove + self.pop + end + + def type?(type) + self.last[0].include? type + end + end + + private_constant :StringRegister + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/q.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/q.rb new file mode 100644 index 0000000..b0d49c5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/q.rb @@ -0,0 +1,125 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + class Q < RegexLexer + title 'Q' + desc 'The Q programming language (kx.com)' + tag 'q' + aliases 'kdb+' + filenames '*.q' + mimetypes 'text/x-q', 'application/x-q' + + identifier = /\.?[a-z][a-z0-9_.]*/i + + def self.keywords + @keywords ||= %w[do if while select update delete exec from by] + end + + def self.word_operators + @word_operators ||= %w[ + and or except inter like each cross vs sv within where in asof bin binr cor cov cut ej fby + div ij insert lj ljf mavg mcount mdev mmax mmin mmu mod msum over prior peach pj scan scov setenv ss + sublist uj union upsert wavg wsum xasc xbar xcol xcols xdesc xexp xgroup xkey xlog xprev xrank + ] + end + + def self.builtins + @builtins ||= %w[ + first enlist value type get set count string key max min sum prd last flip distinct raze neg + desc differ dsave dev eval exit exp fills fkeys floor getenv group gtime hclose hcount hdel hopen hsym + iasc idesc inv keys load log lsq ltime ltrim maxs md5 med meta mins next parse plist prds prev rand rank ratios + read0 read1 reciprocal reverse rload rotate rsave rtrim save sdev show signum sin sqrt ssr sums svar system + tables tan til trim txf ungroup var view views wj wj1 ww + ] + end + + state :root do + # q allows a file to start with a shebang + rule %r/#!(.*?)$/, Comment::Preproc, :top + rule %r//, Text, :top + end + + state :top do + # indented lines at the top of the file are ignored by q + rule %r/^[ \t\r]+.*$/, Comment::Special + rule %r/\n+/, Text + rule %r//, Text, :base + end + + state :base do + rule %r/\n+/m, Text + rule(/^.\)/, Keyword::Declaration) + + # Identifiers, word operators, etc. + rule %r/#{identifier}/ do |m| + if self.class.keywords.include? m[0] + token Keyword + elsif self.class.word_operators.include? m[0] + token Operator::Word + elsif self.class.builtins.include? m[0] + token Name::Builtin + elsif /^\.[zQqho]\./ =~ m[0] + token Name::Constant + else + token Name + end + end + + # White space and comments + rule(%r{\s+/.*}, Comment::Single) + rule(/[ \t\r]+/, Text::Whitespace) + rule(%r{^/$.*?^\\$}m, Comment::Multiline) + rule(%r{^\/[^\n]*$(\n[^\S\n]+.*$)*}, Comment::Multiline) + # til EOF comment + rule(/^\\$/, Comment, :bottom) + rule(/^\\\\\s+/, Keyword, :bottom) + + # Literals + ## strings + rule(/"/, Str, :string) + ## timespan/stamp constants + rule(/(?:\d+D|\d{4}\.[01]\d\.[0123]\d[DT])(?:[012]\d:[0-5]\d(?::[0-5]\d(?:\.\d+)?)?|([012]\d)?)[zpn]?\b/, + Literal::Date) + ## time/minute/second constants + rule(/[012]\d:[0-5]\d(?::[0-5]\d(\.\d+)?)?[uvtpn]?\b/, Literal::Date) + ## date constants + rule(/\d{4}\.[01]\d\.[0-3]\d[dpnzm]?\b/, Literal::Date) + ## special values + rule(/0[nNwW][hijefcpmdznuvt]?/, Keyword::Constant) + + # operators to match before numbers + rule(%r{'|\/:|\\:|':|\\|\/|0:|1:|2:}, Operator) + + ## numbers + rule(/(\d+[.]\d*|[.]\d+)(e[+-]?\d+)?[ef]?/, Num::Float) + rule(/\d+e[+-]?\d+[ef]?/, Num::Float) + rule(/\d+[ef]/, Num::Float) + rule(/0x[0-9a-f]+/i, Num::Hex) + rule(/[01]+b/, Num::Bin) + rule(/[0-9]+[hij]?/, Num::Integer) + ## symbols and paths + rule(%r{(`:[:a-z0-9._\/]*|`(?:[a-z0-9.][:a-z0-9._]*)?)}i, Str::Symbol) + rule(/(?:<=|>=|<>|::)|[?:$%&|@._#*^\-+~,!><=]:?/, Operator) + + rule %r/[{}\[\]();]/, Punctuation + + # commands + rule(/\\.*\n/, Text) + + end + + state :string do + rule %r/\\"/, Str + rule %r/"/, Str, :pop! + rule %r/\\([\\nr]|[01][0-7]{2})/, Str::Escape + rule %r/[^\\"\n]+/, Str + rule %r/\\/, Str # stray backslash + end + + state :bottom do + rule %r/.+\z/m, Comment::Multiline + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/qml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/qml.rb new file mode 100644 index 0000000..577939f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/qml.rb @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'javascript.rb' + + class Qml < Javascript + title "QML" + desc 'QML, a UI markup language' + tag 'qml' + aliases 'qml' + filenames '*.qml' + + mimetypes 'application/x-qml', 'text/x-qml' + + id_with_dots = /[$a-zA-Z_][a-zA-Z0-9_.]*/ + + prepend :root do + rule %r/(#{id_with_dots})(\s*)({)/ do + groups Keyword::Type, Text, Punctuation + push :type_block + end + rule %r/(#{id_with_dots})(\s+)(on)(\s+)(#{id_with_dots})(\s*)({)/ do + groups Keyword::Type, Text, Keyword, Text, Name::Label, Text, Punctuation + push :type_block + end + + rule %r/[{]/, Punctuation, :push + end + + state :type_block do + rule %r/(id)(\s*)(:)(\s*)(#{id_with_dots})/ do + groups Name::Label, Text, Punctuation, Text, Keyword::Declaration + end + + rule %r/(#{id_with_dots})(\s*)(:)/ do + groups Name::Label, Text, Punctuation + push :expr_start + end + + rule %r/(signal)(\s+)(#{id_with_dots})/ do + groups Keyword::Declaration, Text, Name::Label + push :signal + end + + rule %r/(property)(\s+)(#{id_with_dots})(\s+)(#{id_with_dots})(\s*)(:?)/ do + groups Keyword::Declaration, Text, Keyword::Type, Text, Name::Label, Text, Punctuation + push :expr_start + end + + rule %r/[}]/, Punctuation, :pop! + mixin :root + end + + state :signal do + mixin :comments_and_whitespace + rule %r/\(/ do + token Punctuation + goto :signal_args + end + rule %r//, Text, :pop! + end + + state :signal_args do + mixin :comments_and_whitespace + rule %r/(#{id_with_dots})(\s+)(#{id_with_dots})(\s*)(,?)/ do + groups Keyword::Type, Text, Name, Text, Punctuation + end + rule %r/\)/ , Punctuation, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/r.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/r.rb new file mode 100644 index 0000000..dc500e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/r.rb @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class R < RegexLexer + title "R" + desc 'The R statistics language (r-project.org)' + tag 'r' + aliases 'r', 'R', 's', 'S' + filenames '*.R', '*.r', '.Rhistory', '.Rprofile' + mimetypes 'text/x-r-source', 'text/x-r', 'text/x-R' + + mimetypes 'text/x-r', 'application/x-r' + + KEYWORDS = %w(if else for while repeat in next break function) + + KEYWORD_CONSTANTS = %w( + NULL Inf TRUE FALSE NaN NA + NA_integer_ NA_real_ NA_complex_ NA_character_ + ) + + BUILTIN_CONSTANTS = %w(LETTERS letters month.abb month.name pi T F) + + # These are all the functions in `base` that are implemented as a + # `.Primitive`, minus those functions that are also keywords. + PRIMITIVE_FUNCTIONS = %w( + abs acos acosh all any anyNA Arg as.call as.character + as.complex as.double as.environment as.integer as.logical + as.null.default as.numeric as.raw asin asinh atan atanh attr + attributes baseenv browser c call ceiling class Conj cos cosh + cospi cummax cummin cumprod cumsum digamma dim dimnames + emptyenv exp expression floor forceAndCall gamma gc.time + globalenv Im interactive invisible is.array is.atomic is.call + is.character is.complex is.double is.environment is.expression + is.finite is.function is.infinite is.integer is.language + is.list is.logical is.matrix is.na is.name is.nan is.null + is.numeric is.object is.pairlist is.raw is.recursive is.single + is.symbol lazyLoadDBfetch length lgamma list log max min + missing Mod names nargs nzchar oldClass on.exit pos.to.env + proc.time prod quote range Re rep retracemem return round + seq_along seq_len seq.int sign signif sin sinh sinpi sqrt + standardGeneric substitute sum switch tan tanh tanpi tracemem + trigamma trunc unclass untracemem UseMethod xtfrm + ) + + def self.detect?(text) + return true if text.shebang? 'Rscript' + end + + state :root do + rule %r/#'.*?$/, Comment::Doc + rule %r/#.*?$/, Comment::Single + rule %r/\s+/m, Text::Whitespace + + rule %r/`[^`]+?`/, Name + rule %r/'(\\.|.)*?'/m, Str::Single + rule %r/"(\\.|.)*?"/m, Str::Double + + rule %r/%[^%]*?%/, Operator + + rule %r/0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/, Num::Hex + rule %r/[+-]?(\d+([.]\d+)?|[.]\d+)([eE][+-]?\d+)?[Li]?/, Num + + # Only recognize built-in functions when they are actually used as a + # function call, i.e. followed by an opening parenthesis. + # `Name::Builtin` would be more logical, but is usually not + # highlighted specifically; thus use `Name::Function`. + rule %r/\b(??*+^/!=~$@:%&|]), Operator + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/racket.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/racket.rb new file mode 100644 index 0000000..a005439 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/racket.rb @@ -0,0 +1,568 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Racket < RegexLexer + title "Racket" + desc "Racket is a Lisp descended from Scheme (racket-lang.org)" + + tag 'racket' + filenames '*.rkt', '*.rktd', '*.rktl' + mimetypes 'text/x-racket', 'application/x-racket' + + def self.detect?(text) + text =~ /\A#lang\s*(.*?)$/ + lang_attr = $1 + return false unless lang_attr + return true if lang_attr =~ /racket|scribble/ + end + + def self.keywords + @keywords ||= Set.new %w( + ... and begin begin-for-syntax begin0 case case-lambda cond + datum->syntax-object define define-for-syntax define-logger + define-struct define-syntax define-syntax-rule + define-syntaxes define-values define-values-for-syntax delay + do expand-path fluid-let force hash-table-copy + hash-table-count hash-table-for-each hash-table-get + hash-table-iterate-first hash-table-iterate-key + hash-table-iterate-next hash-table-iterate-value + hash-table-map hash-table-put! hash-table-remove! + hash-table? if lambda let let* let*-values let-struct + let-syntax let-syntaxes let-values let/cc let/ec letrec + letrec-syntax letrec-syntaxes letrec-syntaxes+values + letrec-values list-immutable make-hash-table + make-immutable-hash-table make-namespace module module* + module-identifier=? module-label-identifier=? + module-template-identifier=? module-transformer-identifier=? + namespace-transformer-require or parameterize parameterize* + parameterize-break promise? prop:method-arity-error provide + provide-for-label provide-for-syntax quasiquote quasisyntax + quasisyntax/loc quote quote-syntax quote-syntax/prune + require require-for-label require-for-syntax + require-for-template set! set!-values syntax syntax-case + syntax-case* syntax-id-rules syntax-object->datum + syntax-rules syntax/loc tcp-abandon-port tcp-accept + tcp-accept-evt tcp-accept-ready? tcp-accept/enable-break + tcp-addresses tcp-close tcp-connect tcp-connect/enable-break + tcp-listen tcp-listener? tcp-port? time transcript-off + transcript-on udp-addresses udp-bind! udp-bound? udp-close + udp-connect! udp-connected? udp-multicast-interface + udp-multicast-join-group! udp-multicast-leave-group! + udp-multicast-loopback? udp-multicast-set-interface! + udp-multicast-set-loopback! udp-multicast-set-ttl! + udp-multicast-ttl udp-open-socket udp-receive! udp-receive!* + udp-receive!-evt udp-receive!/enable-break + udp-receive-ready-evt udp-send udp-send* udp-send-evt + udp-send-ready-evt udp-send-to udp-send-to* udp-send-to-evt + udp-send-to/enable-break udp-send/enable-break udp? unless + unquote unquote-splicing unsyntax unsyntax-splicing when + with-continuation-mark with-handlers with-handlers* + with-syntax λ) + end + + def self.builtins + @builtins ||= Set.new %w( + * + - / < <= = > >= + abort-current-continuation abs absolute-path? acos add1 + alarm-evt always-evt andmap angle append apply + arithmetic-shift arity-at-least arity-at-least-value + arity-at-least? asin assoc assq assv atan banner bitwise-and + bitwise-bit-field bitwise-bit-set? bitwise-ior bitwise-not + bitwise-xor boolean? bound-identifier=? box box-cas! + box-immutable box? break-enabled break-thread build-path + build-path/convention-type byte-pregexp byte-pregexp? + byte-ready? byte-regexp byte-regexp? byte? bytes + bytes->immutable-bytes bytes->list bytes->path + bytes->path-element bytes->string/latin-1 + bytes->string/locale bytes->string/utf-8 bytes-append + bytes-close-converter bytes-convert bytes-convert-end + bytes-converter? bytes-copy bytes-copy! + bytes-environment-variable-name? bytes-fill! bytes-length + bytes-open-converter bytes-ref bytes-set! bytes-utf-8-index + bytes-utf-8-length bytes-utf-8-ref bytes? + bytes? caaaar caaadr caaar caadar caaddr caadr caar cadaar + cadadr cadar caddar cadddr caddr cadr call-in-nested-thread + call-with-break-parameterization + call-with-composable-continuation + call-with-continuation-barrier call-with-continuation-prompt + call-with-current-continuation + call-with-default-reading-parameterization + call-with-escape-continuation call-with-exception-handler + call-with-immediate-continuation-mark call-with-input-file + call-with-output-file call-with-parameterization + call-with-semaphore call-with-semaphore/enable-break + call-with-values call/cc call/ec car cdaaar cdaadr cdaar + cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr + cdddr cddr cdr ceiling channel-get channel-put + channel-put-evt channel-put-evt? channel-try-get channel? + chaperone-box chaperone-continuation-mark-key chaperone-evt + chaperone-hash chaperone-of? chaperone-procedure + chaperone-prompt-tag chaperone-struct chaperone-struct-type + chaperone-vector chaperone? char->integer char-alphabetic? + char-blank? char-ci<=? char-ci=? + char-ci>? char-downcase char-foldcase char-general-category + char-graphic? char-iso-control? char-lower-case? + char-numeric? char-punctuation? char-ready? char-symbolic? + char-title-case? char-titlecase char-upcase char-upper-case? + char-utf-8-length char-whitespace? char<=? char=? char>? char? check-duplicate-identifier + checked-procedure-check-and-extract choice-evt cleanse-path + close-input-port close-output-port collect-garbage + collection-file-path collection-path compile + compile-allow-set!-undefined + compile-context-preservation-enabled + compile-enforce-module-constants compile-syntax + compiled-expression? compiled-module-expression? + complete-path? complex? cons continuation-mark-key? + continuation-mark-set->context continuation-mark-set->list + continuation-mark-set->list* continuation-mark-set-first + continuation-mark-set? continuation-marks + continuation-prompt-available? continuation-prompt-tag? + continuation? copy-file cos current-break-parameterization + current-code-inspector current-command-line-arguments + current-compile current-compiled-file-roots + current-continuation-marks current-custodian + current-directory current-directory-for-user current-drive + current-environment-variables current-error-port + current-eval current-evt-pseudo-random-generator + current-gc-milliseconds current-get-interaction-input-port + current-inexact-milliseconds current-input-port + current-inspector current-library-collection-paths + current-load current-load-extension + current-load-relative-directory current-load/use-compiled + current-locale current-memory-use current-milliseconds + current-module-declare-name current-module-declare-source + current-module-name-resolver current-module-path-for-load + current-namespace current-output-port + current-parameterization + current-preserved-thread-cell-values current-print + current-process-milliseconds current-prompt-read + current-pseudo-random-generator current-read-interaction + current-reader-guard current-readtable current-seconds + current-security-guard current-subprocess-custodian-mode + current-thread current-thread-group + current-thread-initial-stack-size + current-write-relative-directory custodian-box-value + custodian-box? custodian-limit-memory custodian-managed-list + custodian-memory-accounting-available? + custodian-require-memory custodian-shutdown-all custodian? + custom-print-quotable-accessor custom-print-quotable? + custom-write-accessor custom-write? date date* + date*-nanosecond date*-time-zone-name date*? date-day + date-dst? date-hour date-minute date-month date-second + date-time-zone-offset date-week-day date-year date-year-day + date? datum-intern-literal default-continuation-prompt-tag + delete-directory delete-file denominator directory-exists? + directory-list display displayln dump-memory-stats + dynamic-require dynamic-require-for-syntax dynamic-wind + environment-variables-copy environment-variables-names + environment-variables-ref environment-variables-set! + environment-variables? eof eof-object? ephemeron-value + ephemeron? eprintf eq-hash-code eq? equal-hash-code + equal-secondary-hash-code equal? equal?/recur eqv-hash-code + eqv? error error-display-handler error-escape-handler + error-print-context-length error-print-source-location + error-print-width error-value->string-handler eval + eval-jit-enabled eval-syntax even? evt? exact->inexact + exact-integer? exact-nonnegative-integer? + exact-positive-integer? exact? executable-yield-handler exit + exit-handler exn exn-continuation-marks exn-message + exn:break exn:break-continuation exn:break:hang-up + exn:break:hang-up? exn:break:terminate exn:break:terminate? + exn:break? exn:fail exn:fail:contract + exn:fail:contract:arity exn:fail:contract:arity? + exn:fail:contract:continuation + exn:fail:contract:continuation? + exn:fail:contract:divide-by-zero + exn:fail:contract:divide-by-zero? + exn:fail:contract:non-fixnum-result + exn:fail:contract:non-fixnum-result? + exn:fail:contract:variable exn:fail:contract:variable-id + exn:fail:contract:variable? exn:fail:contract? + exn:fail:filesystem exn:fail:filesystem:errno + exn:fail:filesystem:errno-errno exn:fail:filesystem:errno? + exn:fail:filesystem:exists exn:fail:filesystem:exists? + exn:fail:filesystem:missing-module + exn:fail:filesystem:missing-module-path + exn:fail:filesystem:missing-module? + exn:fail:filesystem:version exn:fail:filesystem:version? + exn:fail:filesystem? exn:fail:network exn:fail:network:errno + exn:fail:network:errno-errno exn:fail:network:errno? + exn:fail:network? exn:fail:out-of-memory + exn:fail:out-of-memory? exn:fail:read exn:fail:read-srclocs + exn:fail:read:eof exn:fail:read:eof? exn:fail:read:non-char + exn:fail:read:non-char? exn:fail:read? exn:fail:syntax + exn:fail:syntax-exprs exn:fail:syntax:missing-module + exn:fail:syntax:missing-module-path + exn:fail:syntax:missing-module? exn:fail:syntax:unbound + exn:fail:syntax:unbound? exn:fail:syntax? + exn:fail:unsupported exn:fail:unsupported? exn:fail:user + exn:fail:user? exn:fail? exn:missing-module-accessor + exn:missing-module? exn:srclocs-accessor exn:srclocs? exn? + exp expand expand-once expand-syntax expand-syntax-once + expand-syntax-to-top-form expand-to-top-form + expand-user-path explode-path expt file-exists? + file-or-directory-identity file-or-directory-modify-seconds + file-or-directory-permissions file-position file-position* + file-size file-stream-buffer-mode file-stream-port? + file-truncate filesystem-change-evt + filesystem-change-evt-cancel filesystem-change-evt? + filesystem-root-list find-executable-path + find-library-collection-paths find-system-path fixnum? + floating-point-bytes->real flonum? floor flush-output + for-each format fprintf free-identifier=? gcd + generate-temporaries gensym get-output-bytes + get-output-string getenv global-port-print-handler guard-evt + handle-evt handle-evt? hash hash-equal? hash-eqv? + hash-has-key? hash-placeholder? hash-ref! hasheq hasheqv + identifier-binding identifier-binding-symbol + identifier-label-binding identifier-prune-lexical-context + identifier-prune-to-source-module + identifier-remove-from-definition-context + identifier-template-binding identifier-transformer-binding + identifier? imag-part immutable? impersonate-box + impersonate-continuation-mark-key impersonate-hash + impersonate-procedure impersonate-prompt-tag + impersonate-struct impersonate-vector impersonator-ephemeron + impersonator-of? impersonator-prop:application-mark + impersonator-property-accessor-procedure? + impersonator-property? impersonator? inexact->exact + inexact-real? inexact? input-port? inspector? integer->char + integer->integer-bytes integer-bytes->integer integer-length + integer-sqrt integer-sqrt/remainder integer? + internal-definition-context-seal + internal-definition-context? keyword->string keywordbytes list->string + list->vector list-ref list-tail list? load load-extension + load-on-demand-enabled load-relative load-relative-extension + load/cd load/use-compiled local-expand + local-expand/capture-lifts local-transformer-expand + local-transformer-expand/capture-lifts + locale-string-encoding log log-max-level magnitude + make-arity-at-least make-bytes make-channel + make-continuation-mark-key make-continuation-prompt-tag + make-custodian make-custodian-box make-date make-date* + make-derived-parameter make-directory + make-environment-variables make-ephemeron make-exn + make-exn:break make-exn:break:hang-up + make-exn:break:terminate make-exn:fail + make-exn:fail:contract make-exn:fail:contract:arity + make-exn:fail:contract:continuation + make-exn:fail:contract:divide-by-zero + make-exn:fail:contract:non-fixnum-result + make-exn:fail:contract:variable make-exn:fail:filesystem + make-exn:fail:filesystem:errno + make-exn:fail:filesystem:exists + make-exn:fail:filesystem:missing-module + make-exn:fail:filesystem:version make-exn:fail:network + make-exn:fail:network:errno make-exn:fail:out-of-memory + make-exn:fail:read make-exn:fail:read:eof + make-exn:fail:read:non-char make-exn:fail:syntax + make-exn:fail:syntax:missing-module + make-exn:fail:syntax:unbound make-exn:fail:unsupported + make-exn:fail:user make-file-or-directory-link + make-hash-placeholder make-hasheq-placeholder make-hasheqv + make-hasheqv-placeholder make-immutable-hasheqv + make-impersonator-property make-input-port make-inspector + make-known-char-range-list make-output-port make-parameter + make-phantom-bytes make-pipe make-placeholder make-polar + make-prefab-struct make-pseudo-random-generator + make-reader-graph make-readtable make-rectangular + make-rename-transformer make-resolved-module-path + make-security-guard make-semaphore make-set!-transformer + make-shared-bytes make-sibling-inspector + make-special-comment make-srcloc make-string + make-struct-field-accessor make-struct-field-mutator + make-struct-type make-struct-type-property + make-syntax-delta-introducer make-syntax-introducer + make-thread-cell make-thread-group make-vector make-weak-box + make-weak-hasheqv make-will-executor map max mcar mcdr mcons + member memq memv min module->exports module->imports + module->language-info module->namespace + module-compiled-cross-phase-persistent? + module-compiled-exports module-compiled-imports + module-compiled-language-info module-compiled-name + module-compiled-submodules module-declared? + module-path-index-join module-path-index-resolve + module-path-index-split module-path-index-submodule + module-path-index? module-path? module-predefined? + module-provide-protected? modulo mpair? nack-guard-evt + namespace-attach-module namespace-attach-module-declaration + namespace-base-phase namespace-mapped-symbols + namespace-module-identifier namespace-module-registry + namespace-require namespace-require/constant + namespace-require/copy namespace-require/expansion-time + namespace-set-variable-value! namespace-symbol->identifier + namespace-syntax-introduce namespace-undefine-variable! + namespace-unprotect-module namespace-variable-value + namespace? negative? never-evt newline normal-case-path not + null null? number->string number? numerator object-name odd? + open-input-bytes open-input-file open-input-output-file + open-input-string open-output-bytes open-output-file + open-output-string ormap output-port? pair? + parameter-procedure=? parameter? parameterization? + path->bytes path->complete-path path->directory-path + path->string path-add-suffix path-convention-type + path-element->bytes path-element->string + path-for-some-system? path-list-string->path-list + path-replace-suffix path-string? path? peek-byte + peek-byte-or-special peek-bytes peek-bytes! + peek-bytes-avail! peek-bytes-avail!* + peek-bytes-avail!/enable-break peek-char + peek-char-or-special peek-string peek-string! phantom-bytes? + pipe-content-length placeholder-get placeholder-set! + placeholder? poll-guard-evt port-closed-evt port-closed? + port-commit-peeked port-count-lines! + port-count-lines-enabled port-counts-lines? + port-display-handler port-file-identity port-file-unlock + port-next-location port-print-handler port-progress-evt + port-provides-progress-evts? port-read-handler + port-try-file-lock? port-write-handler port-writes-atomic? + port-writes-special? port? positive? prefab-key->struct-type + prefab-key? prefab-struct-key pregexp pregexp? + primitive-closure? primitive-result-arity primitive? print + print-as-expression print-boolean-long-form print-box + print-graph print-hash-table print-mpair-curly-braces + print-pair-curly-braces print-reader-abbreviations + print-struct print-syntax-width print-unreadable + print-vector-length printf procedure->method procedure-arity + procedure-arity-includes? procedure-arity? + procedure-closure-contents-eq? procedure-extract-target + procedure-reduce-arity procedure-rename + procedure-struct-type? procedure? progress-evt? + prop:arity-string prop:checked-procedure + prop:custom-print-quotable prop:custom-write prop:equal+hash + prop:evt prop:exn:missing-module prop:exn:srclocs + prop:impersonator-of prop:input-port + prop:liberal-define-context prop:output-port prop:procedure + prop:rename-transformer prop:set!-transformer + pseudo-random-generator->vector + pseudo-random-generator-vector? pseudo-random-generator? + putenv quotient quotient/remainder raise + raise-argument-error raise-arguments-error raise-arity-error + raise-mismatch-error raise-range-error raise-result-error + raise-syntax-error raise-type-error raise-user-error random + random-seed rational? rationalize read read-accept-bar-quote + read-accept-box read-accept-compiled read-accept-dot + read-accept-graph read-accept-infix-dot read-accept-lang + read-accept-quasiquote read-accept-reader read-byte + read-byte-or-special read-bytes read-bytes! + read-bytes-avail! read-bytes-avail!* + read-bytes-avail!/enable-break read-bytes-line + read-case-sensitive read-char read-char-or-special + read-curly-brace-as-paren read-decimal-as-inexact + read-eval-print-loop read-language read-line + read-on-demand-source read-square-bracket-as-paren + read-string read-string! read-syntax read-syntax/recursive + read/recursive readtable-mapping readtable? + real->double-flonum real->floating-point-bytes + real->single-flonum real-part real? regexp regexp-match + regexp-match-peek regexp-match-peek-immediate + regexp-match-peek-positions + regexp-match-peek-positions-immediate + regexp-match-peek-positions-immediate/end + regexp-match-peek-positions/end regexp-match-positions + regexp-match-positions/end regexp-match/end regexp-match? + regexp-max-lookbehind regexp-replace regexp-replace* regexp? + relative-path? remainder rename-file-or-directory + rename-transformer-target rename-transformer? reroot-path + resolve-path resolved-module-path-name resolved-module-path? + reverse round seconds->date security-guard? + semaphore-peek-evt semaphore-peek-evt? semaphore-post + semaphore-try-wait? semaphore-wait + semaphore-wait/enable-break semaphore? + set!-transformer-procedure set!-transformer? set-box! + set-mcar! set-mcdr! set-phantom-bytes! + set-port-next-location! shared-bytes shell-execute + simplify-path sin single-flonum? sleep special-comment-value + special-comment? split-path sqrt srcloc srcloc->string + srcloc-column srcloc-line srcloc-position srcloc-source + srcloc-span srcloc? string string->bytes/latin-1 + string->bytes/locale string->bytes/utf-8 + string->immutable-string string->keyword string->list + string->number string->path string->path-element + string->symbol string->uninterned-symbol + string->unreadable-symbol string-append string-ci<=? + string-ci=? string-ci>? string-copy + string-copy! string-downcase + string-environment-variable-name? string-fill! + string-foldcase string-length string-locale-ci? string-locale-downcase + string-locale-upcase string-locale? string-normalize-nfc string-normalize-nfd + string-normalize-nfkc string-normalize-nfkd string-ref + string-set! string-titlecase string-upcase + string-utf-8-length string<=? string=? + string>? string? struct->vector struct-accessor-procedure? + struct-constructor-procedure? struct-info + struct-mutator-procedure? struct-predicate-procedure? + struct-type-info struct-type-make-constructor + struct-type-make-predicate + struct-type-property-accessor-procedure? + struct-type-property? struct-type? struct:arity-at-least + struct:date struct:date* struct:exn struct:exn:break + struct:exn:break:hang-up struct:exn:break:terminate + struct:exn:fail struct:exn:fail:contract + struct:exn:fail:contract:arity + struct:exn:fail:contract:continuation + struct:exn:fail:contract:divide-by-zero + struct:exn:fail:contract:non-fixnum-result + struct:exn:fail:contract:variable struct:exn:fail:filesystem + struct:exn:fail:filesystem:errno + struct:exn:fail:filesystem:exists + struct:exn:fail:filesystem:missing-module + struct:exn:fail:filesystem:version struct:exn:fail:network + struct:exn:fail:network:errno struct:exn:fail:out-of-memory + struct:exn:fail:read struct:exn:fail:read:eof + struct:exn:fail:read:non-char struct:exn:fail:syntax + struct:exn:fail:syntax:missing-module + struct:exn:fail:syntax:unbound struct:exn:fail:unsupported + struct:exn:fail:user struct:srcloc struct? sub1 subbytes + subprocess subprocess-group-enabled subprocess-kill + subprocess-pid subprocess-status subprocess-wait subprocess? + substring symbol->string symbol-interned? symbol-unreadable? + symbol? sync sync/enable-break sync/timeout + sync/timeout/enable-break syntax->list syntax-arm + syntax-column syntax-disarm syntax-e syntax-line + syntax-local-bind-syntaxes syntax-local-certifier + syntax-local-context syntax-local-expand-expression + syntax-local-get-shadower syntax-local-introduce + syntax-local-lift-context syntax-local-lift-expression + syntax-local-lift-module-end-declaration + syntax-local-lift-provide syntax-local-lift-require + syntax-local-lift-values-expression + syntax-local-make-definition-context + syntax-local-make-delta-introducer + syntax-local-module-defined-identifiers + syntax-local-module-exports + syntax-local-module-required-identifiers syntax-local-name + syntax-local-phase-level syntax-local-submodules + syntax-local-transforming-module-provides? + syntax-local-value syntax-local-value/immediate + syntax-original? syntax-position syntax-property + syntax-property-symbol-keys syntax-protect syntax-rearm + syntax-recertify syntax-shift-phase-level syntax-source + syntax-source-module syntax-span syntax-taint + syntax-tainted? syntax-track-origin + syntax-transforming-module-expression? syntax-transforming? + syntax? system-big-endian? system-idle-evt + system-language+country system-library-subpath + system-path-convention-type system-type tan terminal-port? + thread thread-cell-ref thread-cell-set! thread-cell-values? + thread-cell? thread-dead-evt thread-dead? thread-group? + thread-resume thread-resume-evt thread-rewind-receive + thread-running? thread-suspend thread-suspend-evt + thread-wait thread/suspend-to-kill thread? time-apply + truncate unbox uncaught-exception-handler + use-collection-link-paths use-compiled-file-paths + use-user-specific-search-paths values + variable-reference->empty-namespace + variable-reference->module-base-phase + variable-reference->module-declaration-inspector + variable-reference->module-path-index + variable-reference->module-source + variable-reference->namespace variable-reference->phase + variable-reference->resolved-module-path + variable-reference-constant? variable-reference? vector + vector->immutable-vector vector->list + vector->pseudo-random-generator + vector->pseudo-random-generator! vector->values vector-fill! + vector-immutable vector-length vector-ref vector-set! + vector-set-performance-stats! vector? version void void? + weak-box-value weak-box? will-execute will-executor? + will-register will-try-execute with-input-from-file + with-output-to-file wrap-evt write write-byte write-bytes + write-bytes-avail write-bytes-avail* write-bytes-avail-evt + write-bytes-avail/enable-break write-char write-special + write-special-avail* write-special-evt write-string zero? + ) + end + + # Since Racket allows identifiers to consist of nearly anything, + # it's simpler to describe what an ID is _not_. + id = /[^\s\(\)\[\]\{\}'`,.]+/i + + state :root do + # comments + rule %r/;.*$/, Comment::Single + rule %r/#!.*/, Comment::Single + rule %r/#\|/, Comment::Multiline, :block_comment + rule %r/#;/, Comment::Multiline, :sexp_comment + rule %r/\s+/m, Text + + rule %r/[+-]inf[.][f0]/, Num::Float + rule %r/[+-]nan[.]0/, Num::Float + rule %r/[-]min[.]0/, Num::Float + rule %r/[+]max[.]0/, Num::Float + + rule %r/-?\d+\.\d+/, Num::Float + rule %r/-?\d+/, Num::Integer + + rule %r/#:#{id}+/, Name::Tag # keyword + + rule %r/#b[01]+/, Num::Bin + rule %r/#o[0-7]+/, Num::Oct + rule %r/#d[0-9]+/, Num::Integer + rule %r/#x[0-9a-f]+/i, Num::Hex + rule %r/#[ei][\d.]+/, Num::Other + + rule %r/"(\\\\|\\"|[^"])*"/, Str + rule %r/['`]#{id}/i, Str::Symbol + rule %r/#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i, + Str::Char + rule %r/#t(rue)?|#f(alse)?/i, Name::Constant + rule %r/(?:'|#|`|,@|,|\.)/, Operator + + rule %r/(['#])(\s*)(\()/m do + groups Str::Symbol, Text, Punctuation + end + + # () [] {} are all permitted as like pairs + rule %r/\(|\[|\{/, Punctuation, :command + rule %r/\)|\]|\}/, Punctuation + + rule id, Name::Variable + end + + state :block_comment do + rule %r/[^|#]+/, Comment::Multiline + rule %r/\|#/, Comment::Multiline, :pop! + rule %r/#\|/, Comment::Multiline, :block_comment + rule %r/[|#]/, Comment::Multiline + end + + state :sexp_comment do + rule %r/[({\[]/, Comment::Multiline, :sexp_comment_inner + rule %r/"(?:\\"|[^"])*?"/, Comment::Multiline, :pop! + rule %r/[^\s]+/, Comment::Multiline, :pop! + rule(//) { pop! } + end + + state :sexp_comment_inner do + rule %r/[^(){}\[\]]+/, Comment::Multiline + rule %r/[)}\]]/, Comment::Multiline, :pop! + rule %r/[({\[]/, Comment::Multiline, :sexp_comment_inner + end + + state :command do + rule id, Name::Function do |m| + if self.class.keywords.include? m[0] + token Keyword + elsif self.class.builtins.include? m[0] + token Name::Builtin + else + token Name::Function + end + + pop! + end + + rule(//) { pop! } + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/reasonml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/reasonml.rb new file mode 100644 index 0000000..07c9f6c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/reasonml.rb @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'ocaml/common.rb' + + class ReasonML < OCamlCommon + title "ReasonML" + desc 'New syntax on top of OCaml ecosystem (reasonml.github.io)' + tag 'reasonml' + filenames '*.re', '*.rei' + mimetypes 'text/x-reasonml' + + def self.keywords + @keywords ||= super + Set.new(%w( + switch + )) + end + + state :root do + rule %r/\s+/m, Text + rule %r/false|true|[(][)]|\[\]/, Name::Builtin::Pseudo + rule %r/#{@@upper_id}(?=\s*[.])/, Name::Namespace, :dotted + rule %r/`#{@@id}/, Name::Tag + rule @@upper_id, Name::Class + rule %r(//.*), Comment::Single + rule %r(/\*), Comment::Multiline, :comment + rule @@id do |m| + match = m[0] + if self.class.keywords.include? match + token Keyword + elsif self.class.word_operators.include? match + token Operator::Word + elsif self.class.primitives.include? match + token Keyword::Type + else + token Name + end + end + + rule %r/[(){}\[\];]+/, Punctuation + rule @@operator, Operator + + rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float + rule %r/0x\h[\h_]*/i, Num::Hex + rule %r/0o[0-7][0-7_]*/i, Num::Oct + rule %r/0b[01][01_]*/i, Num::Bin + rule %r/\d[\d_]*/, Num::Integer + + rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char + rule %r/'[^'\/]'/, Str::Char + rule %r/'/, Keyword + rule %r/"/, Str::Double, :string + rule %r/[~?]#{@@id}/, Name::Variable + end + + state :comment do + rule %r([^/*]+), Comment::Multiline + rule %r(/\*), Comment::Multiline, :comment + rule %r(\*/), Comment::Multiline, :pop! + rule %r([*/]), Comment::Multiline + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rego.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rego.rb new file mode 100644 index 0000000..6ca1a5d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rego.rb @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Rego < RegexLexer + title "Rego" + desc "The Rego open-policy-agent (OPA) policy language (openpolicyagent.org)" + tag 'rego' + filenames '*.rego' + + def self.constants + @constants ||= Set.new %w( + true false null + ) + end + + def self.operators + @operators ||= Set.new %w( + as default else import not package some with + ) + end + + state :basic do + rule %r/\s+/, Text + rule %r/#.*/, Comment::Single + + rule %r/[\[\](){}|.,;!]/, Punctuation + + rule %r/"[^"]*"/, Str::Double + + rule %r/-?\d+\.\d+([eE][+-]?\d+)?/, Num::Float + rule %r/-?\d+([eE][+-]?\d+)?/, Num + + rule %r/\\u[0-9a-fA-F]{4}/, Num::Hex + rule %r/\\["\/bfnrt]/, Str::Escape + end + + state :operators do + rule %r/(=|!=|>=|<=|>|<|\+|-|\*|%|\/|\||&|:=)/, Operator + rule %r/[\/:?@^~]+/, Operator + end + + state :root do + mixin :basic + mixin :operators + + rule %r/[[:word:]]+/ do |m| + if self.class.constants.include? m[0] + token Keyword::Constant + elsif self.class.operators.include? m[0] + token Operator::Word + else + token Name + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rescript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rescript.rb new file mode 100644 index 0000000..35daf12 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rescript.rb @@ -0,0 +1,119 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'ocaml/common.rb' + + class ReScript < OCamlCommon + title "ReScript" + desc "The ReScript programming language (rescript-lang.org)" + tag 'rescript' + filenames '*.res', '*.resi' + mimetypes 'text/x-rescript' + + def self.keywords + @keywords ||= Set.new(%w( + open let rec and as exception assert lazy if else + for in to downto while switch when external type private + mutable constraint include module of with try import export + )) + end + + def self.types + @types ||= Set.new(%w( + bool int float char string + unit list array option ref exn format + )) + end + + def self.word_operators + @word_operators ||= Set.new(%w(mod land lor lxor lsl lsr asr or)) + end + + state :root do + rule %r/\s+/m, Text + rule %r([,.:?~\\]), Text + + # Boolean Literal + rule %r/\btrue|false\b/, Keyword::Constant + + # Module chain + rule %r/#{@@upper_id}(?=\s*[.])/, Name::Namespace, :dotted + + # Decorator + rule %r/@#{@@id}(\.#{@@id})*/, Name::Decorator + + # Poly variant + rule %r/\##{@@id}/, Name::Class + + # Variant or Module + rule @@upper_id, Name::Class + + # Comments + rule %r(//.*), Comment::Single + rule %r(/\*), Comment::Multiline, :comment + + # Keywords and identifiers + rule @@id do |m| + match = m[0] + if self.class.keywords.include? match + token Keyword + elsif self.class.word_operators.include? match + token Operator::Word + elsif self.class.types.include? match + token Keyword::Type + else + token Name + end + end + + # Braces + rule %r/[(){}\[\];]+/, Punctuation + + # Operators + rule %r([;_!$%&*+/<=>@^|-]+), Operator + + # Numbers + rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float + rule %r/0x\h[\h_]*/i, Num::Hex + rule %r/0o[0-7][0-7_]*/i, Num::Oct + rule %r/0b[01][01_]*/i, Num::Bin + rule %r/\d[\d_]*/, Num::Integer + + # String and Char + rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char + rule %r/'[^'\/]'/, Str::Char + rule %r/'/, Keyword + rule %r/"/, Str::Double, :string + + # Interpolated string + rule %r/`/ do + token Str::Double + push :interpolated_string + end + end + + state :comment do + rule %r([^/\*]+), Comment::Multiline + rule %r(/\*), Comment::Multiline, :comment + rule %r(\*/), Comment::Multiline, :pop! + rule %r([*/]), Comment::Multiline + end + + state :interpolated_string do + rule %r/[$]{/, Punctuation, :interpolated_expression + rule %r/`/, Str::Double, :pop! + rule %r/\\[$`]/, Str::Escape + rule %r/[^$`\\]+/, Str::Double + rule %r/[\\$]/, Str::Double + end + + state :interpolated_expression do + rule %r/}/, Punctuation, :pop! + mixin :root + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rml.rb new file mode 100644 index 0000000..0891470 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rml.rb @@ -0,0 +1,142 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class RML < RegexLexer + title "RML" + desc "A system agnostic domain-specific language for runtime monitoring and verification (https://rmlatdibris.github.io/)" + tag 'rml' + filenames '*.rml' + + def self.keywords + @keywords ||= Set.new %w( + matches not with empty + all if else true false + ) + end + + def self.arithmetic_keywords + @arithmetic_keywords ||= Set.new %w( + abs sin cos tan min max + ) + end + + id_char = /[a-zA-Z0-9_]/ + uppercase_id = /[A-Z]#{id_char}*/ + lowercase_id = /[a-z]#{id_char}*/ + + ellipsis = /(\.){3}/ + int = /[0-9]+/ + float = /#{int}\.#{int}/ + string = /'(\\'|[ a-zA-Z0-9_.])*'/ + + whitespace = /[ \t\r\n]+/ + comment = /\/\/[^\r\n]*/ + + state :common_rules do + rule %r/#{whitespace}/, Text + rule %r/#{comment}/, Comment::Single + rule %r/#{string}/, Literal::String + rule %r/#{float}/, Num::Float + rule %r/#{int}/, Num::Integer + end + + state :root do + mixin :common_rules + rule %r/(#{lowercase_id})(\()/ do + groups Name::Function, Operator + push :event_type_params + end + rule %r/#{lowercase_id}/ do |m| + if m[0] == 'with' + token Keyword + push :data_expression_with + elsif self.class.keywords.include? m[0] + token Keyword + else + token Name::Function + end + end + rule %r/\(|\{|\[/, Operator, :event_type_params + rule %r/[_\|]/, Operator + rule %r/#{uppercase_id}/, Name::Class, :equation_block_expression + rule %r/;/, Operator + end + + state :event_type_params do + mixin :common_rules + rule %r/\(|\{|\[/, Operator, :push + rule %r/\)|\}|\]/, Operator, :pop! + rule %r/#{lowercase_id}(?=:)/, Name::Entity + rule %r/(#{lowercase_id})/ do |m| + if self.class.keywords.include? m[0] + token Keyword + else + token Literal::String::Regex + end + end + rule %r/#{ellipsis}/, Literal::String::Symbol + rule %r/[_\|;,:]/, Operator + end + + state :equation_block_expression do + mixin :common_rules + rule %r/[<,>]/, Operator + rule %r/#{lowercase_id}/, Literal::String::Regex + rule %r/=/ do + token Operator + goto :exp + end + rule %r/;/, Operator, :pop! + end + + state :exp do + mixin :common_rules + rule %r/(if)(\()/ do + groups Keyword, Operator + push :data_expression + end + rule %r/let|var/, Keyword, :equation_block_expression + rule %r/(#{lowercase_id})(\()/ do + groups Name::Function, Operator + push :event_type_params + end + rule %r/(#{lowercase_id})/ do |m| + if self.class.keywords.include? m[0] + token Keyword + else + token Name::Function + end + end + rule %r/#{uppercase_id}(?=<)/, Name::Class, :data_expression + rule %r/#{uppercase_id}/, Name::Class + rule %r/[=(){}*+\/\\\|!>?]/, Operator + rule %r/;/, Operator, :pop! + end + + state :data_expression do + mixin :common_rules + rule %r/#{lowercase_id}/ do |m| + if (self.class.arithmetic_keywords | self.class.keywords).include? m[0] + token Keyword + else + token Literal::String::Regex + end + end + rule %r/\(/, Operator, :push + rule %r/\)/, Operator, :pop! + rule %r/(>)(?=[^A-Z;]+[A-Z;>])/, Operator, :pop! + rule %r/[*^?!%&\[\]<>\|+=:,.\/\\_-]/, Operator + rule %r/;/, Operator, :pop! + end + + state :data_expression_with do + mixin :common_rules + rule %r/>/, Operator + mixin :data_expression + + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/robot_framework.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/robot_framework.rb new file mode 100644 index 0000000..3675594 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/robot_framework.rb @@ -0,0 +1,249 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class RobotFramework < RegexLexer + tag 'robot_framework' + aliases 'robot', 'robot-framework' + + title "Robot Framework" + desc 'Robot Framework is a generic open source automation testing framework (robotframework.org)' + + filenames '*.robot' + mimetypes 'text/x-robot' + + def initialize(opts = {}) + super(opts) + @col = 0 + @next = nil + @is_template = false + end + + def self.settings_with_keywords + @settings_with_keywords ||= Set.new [ + "library", "resource", "setup", "teardown", "template", "suite setup", + "suite teardown", "task setup", "task teardown", "task template", + "test setup", "test teardown", "test template", "variables" + ] + end + + def self.settings_with_args + @settings_with_args ||= Set.new [ + "arguments", "default tags", "documentation", "force tags", + "metadata", "return", "tags", "timeout", "task timeout", + "test timeout" + ] + end + + id = %r/(?:\\|[^|$@&% \t\n])+(?: (?:\\.|[^|$@&% \t\n])+)*/ + bdd = %r/(?:Given|When|Then|And|But) /i + sep = %r/ +\| +|[ ]{2,}|\t+/ + + start do + push :prior_text + end + + state :prior_text do + rule %r/^[^*].*/, Text + rule(//) { pop! } + end + + # Mixins + + state :whitespace do + rule %r/\s+/, Text::Whitespace + end + + state :section_include do + mixin :end_section + mixin :sep + mixin :newline + end + + state :end_section do + rule(/(?=^(?:\| )?\*)/) { pop! } + end + + state :return do + rule(//) { pop! } + end + + state :sep do + rule %r/\| /, Text::Whitespace + + rule sep do + token Text::Whitespace + @col = @col + 1 + if @next + push @next + elsif @is_template + push :args + elsif @col == 1 + @next = :keyword + push :keyword + else + push :args + end + push :cell_start + end + + rule %r/\.\.\. */ do + token Text::Whitespace + @col = @col + 1 + push :args + end + + rule %r/ ?\|/, Text::Whitespace + end + + state :newline do + rule %r/\n/ do + token Text::Whitespace + @col = 0 + @next = nil + push :cell_start + end + end + + # States + + state :root do + mixin :whitespace + + rule %r/^(?:\| )?\*[* ]*([A-Z]+(?: [A-Z]+)?).*/i do |m| + token Generic::Heading, m[0] + case m[1].chomp("s").downcase + when "setting" then push :section_settings + when "test case" then push :section_tests + when "task" then push :section_tasks + when "keyword" then push :section_keywords + when "variable" then push :section_variables + end + end + end + + state :section_settings do + mixin :section_include + + rule %r/([A-Z]+(?: [A-Z]+)?)(:?)/i do |m| + match = m[1].downcase + @next = if self.class.settings_with_keywords.include? match + :keyword + elsif self.class.settings_with_args.include? match + :args + end + groups Name::Builtin::Pseudo, Punctuation + end + end + + state :section_tests do + mixin :section_include + + rule %r/[$@&%{}]+/, Name::Label + rule %r/( )(?![ |])/, Name::Label + + rule id do + @is_template = false + token Name::Label + end + end + + state :section_tasks do + mixin :section_tests + end + + state :section_keywords do + mixin :section_include + + rule %r/[$@&%]\{/ do + token Name::Variable + push :var + end + + rule %r/[$@&%{}]+/, Name::Label + rule %r/( )(?![ |])/, Name::Label + + rule id, Name::Label + end + + state :section_variables do + mixin :section_include + + rule %r/[$@&%]\{/ do + token Name::Variable + @next = :args + push :var + end + end + + state :cell_start do + rule %r/#.*/, Comment + mixin :return + end + + state :keyword do + rule %r/(\[)([A-Z]+(?: [A-Z]+)?)(\])/i do |m| + groups Punctuation, Name::Builtin::Pseudo, Punctuation + + match = m[2].downcase + @is_template = true if match == "template" + if self.class.settings_with_keywords.include? match + @next = :keyword + elsif self.class.settings_with_args.include? match + @next = :args + end + + pop! + end + + rule %r/[$@&%]\{/ do + token Name::Variable + @next = :keyword unless @next.nil? + push :var + end + + rule %r/FOR/i do + token Name::Function + @next = :keyword unless @next.nil? + end + + rule %r/( )(?![ |])/, Name::Function + + rule bdd, Name::Builtin + rule id do + token Name::Function + @next = nil + end + + mixin :return + end + + state :args do + rule %r/[$@&%]\{/ do + token Name::Variable + @next = :keyword unless @next.nil? + push :var + end + + rule %r/[$@&%]+/, Str + rule %r/( )(?![ |])/, Str + rule id, Str + + mixin :return + end + + state :var do + rule %r/(\})( )(=)/ do + groups Name::Variable, Text::Whitespace, Punctuation + pop! + end + rule %r/[$@&%]\{/, Name::Variable, :var + rule %r/[{\[]/, Name::Variable, :var + rule %r/[}\]]/, Name::Variable, :pop! + rule %r/[^$@&%{}\[\]]+/, Name::Variable + rule %r/\}\[/, Name::Variable + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ruby.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ruby.rb new file mode 100644 index 0000000..2f6be1a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ruby.rb @@ -0,0 +1,455 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Ruby < RegexLexer + title "Ruby" + desc "The Ruby programming language (ruby-lang.org)" + tag 'ruby' + aliases 'rb' + filenames '*.rb', '*.ruby', '*.rbw', '*.rake', '*.gemspec', '*.podspec', + 'Rakefile', 'Guardfile', 'Gemfile', 'Capfile', 'Podfile', + 'Vagrantfile', '*.ru', '*.prawn', 'Berksfile', '*.arb', + 'Dangerfile', 'Fastfile', 'Deliverfile', 'Appfile' + + mimetypes 'text/x-ruby', 'application/x-ruby' + + def self.detect?(text) + return true if text.shebang? 'ruby' + end + + state :symbols do + # symbols + rule %r( + : # initial : + @{0,2} # optional ivar, for :@foo and :@@foo + [\p{Ll}_]\p{Word}*[!?]? # the symbol + )xi, Str::Symbol + + # special symbols + rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)), + Str::Symbol + + rule %r/:'(\\\\|\\'|[^'])*'/, Str::Symbol + rule %r/:"/, Str::Symbol, :simple_sym + end + + state :sigil_strings do + # %-sigiled strings + # %(abc), %[abc], %, %.abc., %r.abc., etc + delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' } + rule %r/%([rqswQWxiI])?([^\p{Word}\s])/ do |m| + open = Regexp.escape(m[2]) + close = Regexp.escape(delimiter_map[m[2]] || m[2]) + interp = /[rQWxI]/ === m[1] || !m[1] + toktype = Str::Other + + puts " open: #{open.inspect}" if @debug + puts " close: #{close.inspect}" if @debug + + # regexes + if m[1] == 'r' + toktype = Str::Regex + push :regex_flags + end + + token toktype + + push do + uniq_chars = [open, close].uniq.join + uniq_chars = '' if open == close && open == "\\#" + rule %r/\\[##{uniq_chars}\\]/, Str::Escape + # nesting rules only with asymmetric delimiters + if open != close + rule %r/#{open}/ do + token toktype + push + end + end + rule %r/#{close}/, toktype, :pop! + + if interp + mixin :string_intp_escaped + rule %r/#/, toktype + else + rule %r/[\\#]/, toktype + end + + rule %r/[^##{uniq_chars}\\]+/m, toktype + end + end + end + + state :strings do + mixin :symbols + rule %r/\b[\p{Ll}_]\p{Word}*?[?!]?:\s+/, Str::Symbol, :expr_start + rule %r/'(\\\\|\\'|[^'])*'/, Str::Single + rule %r/"/, Str::Double, :simple_string + rule %r/(?_*\$?:"]), Name::Variable::Global + rule %r/\$-[0adFiIlpvw]/, Name::Variable::Global + rule %r/::/, Operator + + mixin :strings + + rule %r/(?:#{keywords.join('|')})(?=\W|$)/, Keyword, :expr_start + rule %r/(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start + rule %r/(not|and|or)\b/, Operator::Word, :expr_start + + rule %r( + (module) + (\s+) + ([\p{L}_][\p{L}0-9_]*(::[\p{L}_][\p{L}0-9_]*)*) + )x do + groups Keyword, Text, Name::Namespace + end + + rule %r/(def\b)(\s*)/ do + groups Keyword, Text + push :funcname + end + + rule %r/(class\b)(\s*)/ do + groups Keyword, Text + push :classname + end + + rule %r/(?:#{builtins_q.join('|')})[?]/, Name::Builtin, :expr_start + rule %r/(?:#{builtins_b.join('|')})!/, Name::Builtin, :expr_start + rule %r/(?=])/ do + groups Punctuation, Text, Name::Function + push :method_call + end + + rule %r/[\p{L}_]\p{Word}*[?!]/, Name, :expr_start + rule %r/[\p{L}_]\p{Word}*/, Name, :method_call + rule %r/\*\*|<>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\./, + Operator, :expr_start + rule %r/[-+\/*%=<>&!^|~]=?/, Operator, :expr_start + rule(/[?]/) { token Punctuation; push :ternary; push :expr_start } + rule %r<[\[({,:\\;/]>, Punctuation, :expr_start + rule %r<[\])}]>, Punctuation + end + + state :has_heredocs do + rule %r/(?>? | <=>? | >= | ===? + ) + )x do |m| + puts "matches: #{[m[0], m[1], m[2], m[3]].inspect}" if @debug + groups Name::Class, Operator, Name::Function + pop! + end + + rule(//) { pop! } + end + + state :classname do + rule %r/\s+/, Text + rule %r/\p{Word}+(::\p{Word}+)+/, Name::Class + + rule %r/\(/ do + token Punctuation + push :defexpr + push :expr_start + end + + # class << expr + rule %r/<=0?n[x]:"" + rule %r( + [?](\\[MC]-)* # modifiers + (\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S) + (?!\p{Word}) + )x, Str::Char, :pop! + + # special case for using a single space. Ruby demands that + # these be in a single line, otherwise it would make no sense. + rule %r/(\s*)(%[rqswQWxiI]? \S* )/ do + groups Text, Str::Other + pop! + end + + mixin :sigil_strings + + rule(//) { pop! } + end + + state :slash_regex do + mixin :string_intp + rule %r(\\\\), Str::Regex + rule %r(\\/), Str::Regex + rule %r([\\#]), Str::Regex + rule %r([^\\/#]+)m, Str::Regex + rule %r(/) do + token Str::Regex + goto :regex_flags + end + end + + state :end_part do + # eat up the rest of the stream as Comment::Preproc + rule %r/.+/m, Comment::Preproc, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rust.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rust.rb new file mode 100644 index 0000000..4f0aa8f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/rust.rb @@ -0,0 +1,260 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Rust < RegexLexer + title "Rust" + desc 'The Rust programming language (rust-lang.org)' + tag 'rust' + aliases 'rs', + # So that directives from https://github.com/budziq/rust-skeptic + # do not prevent highlighting. + 'rust,no_run', 'rs,no_run', + 'rust,ignore', 'rs,ignore', + 'rust,should_panic', 'rs,should_panic' + filenames '*.rs' + mimetypes 'text/x-rust' + + def self.detect?(text) + return true if text.shebang? 'rustc' + end + + def self.keywords + @keywords ||= %w( + as async await break const continue crate dyn else enum extern false + fn for if impl in let log loop match mod move mut pub ref return self + Self static struct super trait true type unsafe use where while + abstract become box do final macro + override priv typeof unsized virtual + yield try + union + ) + end + + def self.builtins + @builtins ||= Set.new %w( + Add BitAnd BitOr BitXor bool c_char c_double c_float char + c_int clock_t c_long c_longlong Copy c_schar c_short + c_uchar c_uint c_ulong c_ulonglong c_ushort c_void dev_t DIR + dirent Div Eq Err f32 f64 FILE float fpos_t + i16 i32 i64 i8 isize Index ino_t int intptr_t mode_t Mul + Neg None off_t Ok Option Ord Owned pid_t ptrdiff_t + Send Shl Shr size_t Some ssize_t str Sub time_t + u16 u32 u64 u8 usize uint uintptr_t + Box Vec String Rc Arc + u128 i128 Result Sync Pin Unpin Sized Drop drop Fn FnMut FnOnce + Clone PartialEq PartialOrd AsMut AsRef From Into Default + DoubleEndedIterator ExactSizeIterator Extend IntoIterator Iterator + FromIterator ToOwned ToString TryFrom TryInto + ) + end + + def macro_closed? + @macro_delims.values.all?(&:zero?) + end + + start { + @macro_delims = { ']' => 0, ')' => 0, '}' => 0 } + push :bol + } + + delim_map = { '[' => ']', '(' => ')', '{' => '}' } + + id = /[\p{XID_Start}_]\p{XID_Continue}*/ + hex = /[0-9a-f]/i + escapes = %r( + \\ ([nrt'"\\0] | x#{hex}{2} | u\{(#{hex}_*){1,6}\}) + )x + size = /8|16|32|64|128|size/ + + # Although not officially part of Rust, the rustdoc tool allows code in + # comments to begin with `#`. Code like this will be evaluated but not + # included in the HTML output produced by rustdoc. So that code intended + # for these comments can be higlighted with Rouge, the Rust lexer needs + # to check if the beginning of the line begins with a `# `. + state :bol do + mixin :whitespace + rule %r/#\s[^\n]*/, Comment::Special + rule(//) { pop! } + end + + state :attribute do + mixin :whitespace + mixin :has_literals + rule %r/[(,)=:]/, Name::Decorator + rule %r/\]/, Name::Decorator, :pop! + rule id, Name::Decorator + end + + state :whitespace do + rule %r/\s+/, Text + mixin :comments + end + + state :comments do + # Only 3 slashes are doc comments, `////` and beyond become normal + # comments again (for some reason), so match this before the + # doc line comments rather than figure out a + rule %r(////+[^\n]*), Comment::Single + # doc line comments — either inner (`//!`), or outer (`///`). + rule %r(//[/!][^\n]*), Comment::Doc + # otherwise, `//` is just a plain line comme + rule %r(//[^\n]*), Comment::Single + # /**/ and /***/ are self-closing block comments, not doc. Because this + # is self-closing, it doesn't enter the states for nested comments + rule %r(/\*\*\*?/), Comment::Multiline + # 3+ stars and it's a normal non-doc block comment. + rule %r(/\*\*\*+), Comment::Multiline, :nested_plain_block + # `/*!` and `/**` begin doc comments. These nest and can have internal + # block/doc comments, but they're still part of the documentation + # inside. + rule %r(/[*][*!]), Comment::Doc, :nested_doc_block + # any other /* is a plain multiline comment + rule %r(/[*]), Comment::Multiline, :nested_plain_block + end + + # Multiline/block comments fully nest. This is true for ones that are + # marked as documentation too. The behavior here is: + # + # - Anything inside a block doc comment is still included in the + # documentation, even if it's a nested non-doc block comment. For + # example: `/** /* still docs */ */` + # - Anything inside of a block non-doc comment is still just a normal + # comment, even if it's a nested block documentation comment. For + # example: `/* /** not docs */ */` + # + # This basically means: if (on the outermost level) the comment starts as + # one kind of block comment (either doc/non-doc), then everything inside + # of it, including nested block comments of the opposite type, needs to + # stay that type. + # + # Also note that single line comments do nothing anywhere inside of block + # comments, thankfully. + # + # We just define this as two states, because this seems easier than + # tracking it with instance vars. + [ + [:nested_plain_block, Comment::Multiline], + [:nested_doc_block, Comment::Doc] + ].each do |state_name, comment_token| + state state_name do + rule %r(\*/), comment_token, :pop! + rule %r(/\*), comment_token, state_name + # We only want to eat at most one `[*/]` at a time, + # but we can skip past non-`[*/]` in bulk. + rule %r([^*/]+|[*/]), comment_token + end + end + + state :root do + rule %r/\n/, Text, :bol + mixin :whitespace + rule %r/#!?\[/, Name::Decorator, :attribute + rule %r/\b(?:#{Rust.keywords.join('|')})\b/, Keyword + mixin :has_literals + + rule %r([=-]>), Keyword + rule %r(<->), Keyword + rule %r/[()\[\]{}|,:;]/, Punctuation + rule %r/[*\/!@~&+%^<>=\?-]|\.{2,3}/, Operator + + rule %r/([.]\s*)?#{id}(?=\s*[(])/m, Name::Function + rule %r/[.]\s*await\b/, Keyword + rule %r/[.]\s*#{id}/, Name::Property + rule %r/[.]\s*\d+/, Name::Attribute + rule %r/(#{id})(::)/m do + groups Name::Namespace, Punctuation + end + + # macros + rule %r/\bmacro_rules!/, Name::Decorator, :macro_rules + rule %r/#{id}!/, Name::Decorator, :macro + + rule %r/'static\b/, Keyword + rule %r/'#{id}/, Name::Variable + rule %r/#{id}/ do |m| + name = m[0] + if self.class.builtins.include? name + token Name::Builtin + else + token Name + end + end + end + + state :macro do + mixin :has_literals + + rule %r/[\[{(]/ do |m| + @macro_delims[delim_map[m[0]]] += 1 + puts " macro_delims: #{@macro_delims.inspect}" if @debug + token Punctuation + end + + rule %r/[\]})]/ do |m| + @macro_delims[m[0]] -= 1 + puts " macro_delims: #{@macro_delims.inspect}" if @debug + pop! if macro_closed? + token Punctuation + end + + # same as the rule in root, but don't push another macro state + rule %r/#{id}!/, Name::Decorator + mixin :root + + # No syntax errors in macros + rule %r/./, Text + end + + state :macro_rules do + rule %r/[$]#{id}(:#{id})?/, Name::Variable + rule %r/[$]/, Name::Variable + + mixin :macro + end + + state :has_literals do + # constants + rule %r/\b(?:true|false)\b/, Keyword::Constant + + # characters/bytes + rule %r( + b?' (?: #{escapes} | [^\\] ) ' + )x, Str::Char + + rule %r/b?"/, Str, :string + rule %r/b?r(#*)".*?"\1/m, Str + + # numbers + dot = /[.][0-9][0-9_]*/ + exp = /[eE][-+]?[0-9_]+/ + flt = /f32|f64/ + + rule %r( + [0-9][0-9_]* + (#{dot} #{exp}? #{flt}? + |#{dot}? #{exp} #{flt}? + |#{dot}? #{exp}? #{flt} + |[.](?![._\p{XID_Start}]) + ) + )x, Num::Float + + rule %r( + ( 0b[10_]+ + | 0x[0-9a-fA-F_]+ + | 0o[0-7_]+ + | [0-9][0-9_]* + ) (u#{size}?|i#{size})? + )x, Num::Integer + + end + + state :string do + rule %r/"/, Str, :pop! + rule escapes, Str::Escape + rule %r/[^"\\]+/m, Str + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sas.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sas.rb new file mode 100644 index 0000000..6095854 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sas.rb @@ -0,0 +1,563 @@ +# -*- coding: utf-8 -*- # + +module Rouge + module Lexers + class SAS < RegexLexer + title "SAS" + desc "SAS (Statistical Analysis Software)" + tag 'sas' + filenames '*.sas' + mimetypes 'application/x-sas', 'application/x-stat-sas', 'application/x-sas-syntax' + + def self.data_step_statements + # from Data step statements - SAS 9.4 Statements reference + # http://support.sas.com/documentation/cdl/en/lestmtsref/68024/PDF/default/lestmtsref.pdf + @data_step_statements ||= Set.new %w( + ABORT ARRAY ATTRIB BY CALL CARDS CARDS4 CATNAME CHECKPOINT + EXECUTE_ALWAYS CONTINUE DATA DATALINES DATALINES4 DELETE DESCRIBE + DISPLAY DM DO UNTIL WHILE DROP END ENDSAS ERROR EXECUTE FILE FILENAME + FOOTNOTE FORMAT GO TO IF THEN ELSE INFILE INFORMAT INPUT + KEEP LABEL LEAVE LENGTH LIBNAME LINK LIST LOCK LOSTCARD MERGE + MISSING MODIFY OPTIONS OUTPUT PAGE PUT PUTLOG REDIRECT REMOVE RENAME + REPLACE RESETLINE RETAIN RETURN RUN SASFILE SELECT SET SKIP STOP + SYSECHO TITLE UPDATE WHERE WINDOW X + ) + # label: + # Sum + end + + def self.sas_functions + # from SAS 9.4 Functions and CALL Routines reference + # http://support.sas.com/documentation/cdl/en/lefunctionsref/67960/PDF/default/lefunctionsref.pdf + @sas_functions ||= Set.new %w( + ABS ADDR ADDRLONG AIRY ALLCOMB ALLPERM ANYALNUM ANYALPHA ANYCNTRL + ANYDIGIT ANYFIRST ANYGRAPH ANYLOWER ANYNAME ANYPRINT ANYPUNCT + ANYSPACE ANYUPPER ANYXDIGIT ARCOS ARCOSH ARSIN ARSINH ARTANH ATAN + ATAN2 ATTRC ATTRN BAND BETA BETAINV BLACKCLPRC BLACKPTPRC + BLKSHCLPRC BLKSHPTPRC BLSHIFT BNOT BOR BRSHIFT BXOR BYTE CAT CATQ + CATS CATT CATX CDF CEIL CEILZ CEXIST CHAR CHOOSEC CHOOSEN CINV + CLOSE CMISS CNONCT COALESCE COALESCEC COLLATE COMB COMPARE COMPBL + COMPFUZZ COMPGED COMPLEV COMPOUND COMPRESS CONSTANT CONVX CONVXP + COS COSH COT COUNT COUNTC COUNTW CSC CSS CUMIPMT CUMPRINC CUROBS + CV DACCDB DACCDBSL DACCSL DACCSYD DACCTAB DAIRY DATDIF DATE + DATEJUL DATEPART DATETIME DAY DCLOSE DCREATE DEPDB DEPDBSL DEPSL + DEPSYD DEPTAB DEQUOTE DEVIANCE DHMS DIF DIGAMMA DIM DINFO DIVIDE + DNUM DOPEN DOPTNAME DOPTNUM DOSUBL DREAD DROPNOTE DSNAME + DSNCATLGD DUR DURP EFFRATE ENVLEN ERF ERFC EUCLID EXIST EXP FACT + FAPPEND FCLOSE FCOL FCOPY FDELETE FETCH FETCHOBS FEXIST FGET + FILEEXIST FILENAME FILEREF FINANCE FIND FINDC FINDW FINFO FINV + FIPNAME FIPNAMEL FIPSTATE FIRST FLOOR FLOORZ FMTINFO FNONCT FNOTE + FOPEN FOPTNAME FOPTNUM FPOINT FPOS FPUT FREAD FREWIND FRLEN FSEP + FUZZ FWRITE GAMINV GAMMA GARKHCLPRC GARKHPTPRC GCD GEODIST + GEOMEAN GEOMEANZ GETOPTION GETVARC GETVARN GRAYCODE HARMEAN + HARMEANZ HBOUND HMS HOLIDAY HOLIDAYCK HOLIDAYCOUNT HOLIDAYNAME + HOLIDAYNX HOLIDAYNY HOLIDAYTEST HOUR HTMLDECODE HTMLENCODE + IBESSEL IFC IFN INDEX INDEXC INDEXW INPUT INPUTC INPUTN INT + INTCINDEX INTCK INTCYCLE INTFIT INTFMT INTGET INTINDEX INTNX + INTRR INTSEAS INTSHIFT INTTEST INTZ IORCMSG IPMT IQR IRR JBESSEL + JULDATE JULDATE7 KURTOSIS LAG LARGEST LBOUND LCM LCOMB LEFT + LENGTH LENGTHC LENGTHM LENGTHN LEXCOMB LEXCOMBI LEXPERK LEXPERM + LFACT LGAMMA LIBNAME LIBREF LOG LOG1PX LOG10 LOG2 LOGBETA LOGCDF + LOGISTIC LOGPDF LOGSDF LOWCASE LPERM LPNORM MAD MARGRCLPRC + MARGRPTPRC MAX MD5 MDY MEAN MEDIAN MIN MINUTE MISSING MOD + MODEXIST MODULE MODULEC MODULEN MODZ MONTH MOPEN MORT MSPLINT + MVALID N NETPV NLITERAL NMISS NOMRATE NORMAL NOTALNUM NOTALPHA + NOTCNTRL NOTDIGIT NOTE NOTFIRST NOTGRAPH NOTLOWER NOTNAME + NOTPRINT NOTPUNCT NOTSPACE NOTUPPER NOTXDIGIT NPV NVALID NWKDOM + OPEN ORDINAL PATHNAME PCTL PDF PEEK PEEKC PEEKCLONG PEEKLONG PERM + PMT POINT POISSON PPMT PROBBETA PROBBNML PROBBNRM PROBCHI PROBF + PROBGAM PROBHYPR PROBIT PROBMC PROBNEGB PROBNORM PROBT PROPCASE + PRXCHANGE PRXMATCH PRXPAREN PRXPARSE PRXPOSN PTRLONGADD PUT PUTC + PUTN PVP QTR QUANTILE QUOTE RANBIN RANCAU RAND RANEXP RANGAM + RANGE RANK RANNOR RANPOI RANTBL RANTRI RANUNI RENAME REPEAT + RESOLVE REVERSE REWIND RIGHT RMS ROUND ROUNDE ROUNDZ SAVING + SAVINGS SCAN SDF SEC SECOND SHA256 SHA256HEX SHA256HMACHEX SIGN + SIN SINH SKEWNESS SLEEP SMALLEST SOAPWEB SOAPWEBMETA + SOAPWIPSERVICE SOAPWIPSRS SOAPWS SOAPWSMETA SOUNDEX SPEDIS SQRT + SQUANTILE STD STDERR STFIPS STNAME STNAMEL STRIP SUBPAD SUBSTR + SUBSTRN SUM SUMABS SYMEXIST SYMGET SYMGLOBL SYMLOCAL SYSEXIST + SYSGET SYSMSG SYSPARM SYSPROCESSID SYSPROCESSNAME SYSPROD SYSRC + SYSTEM TAN TANH TIME TIMEPART TIMEVALUE TINV TNONCT TODAY + TRANSLATE TRANSTRN TRANWRD TRIGAMMA TRIM TRIMN TRUNC TSO TYPEOF + TZONEID TZONENAME TZONEOFF TZONES2U TZONEU2S UNIFORM UPCASE + URLDECODE URLENCODE USS UUIDGEN VAR VARFMT VARINFMT VARLABEL + VARLEN VARNAME VARNUM VARRAY VARRAYX VARTYPE VERIFY VFORMAT + VFORMATD VFORMATDX VFORMATN VFORMATNX VFORMATW VFORMATWX VFORMATX + VINARRAY VINARRAYX VINFORMAT VINFORMATD VINFORMATDX VINFORMATN + VINFORMATNX VINFORMATW VINFORMATWX VINFORMATX VLABEL VLABELX + VLENGTH VLENGTHX VNAME VNAMEX VTYPE VTYPEX VVALUE VVALUEX WEEK + WEEKDAY WHICHC WHICHN WTO YEAR YIELDP YRDIF YYQ ZIPCITY + ZIPCITYDISTANCE ZIPFIPS ZIPNAME ZIPNAMEL ZIPSTATE + ) + end + + def self.sas_macro_statements + # from SAS 9.4 Macro Language Reference + # Chapter 12 + @sas_macro_statements ||= Set.new %w( + %COPY %DISPLAY %GLOBAL %INPUT %LET %MACRO %PUT %SYMDEL %SYSCALL + %SYSEXEC %SYSLPUT %SYSMACDELETE %SYSMSTORECLEAR %SYSRPUT %WINDOW + %ABORT %DO %TO %UNTIL %WHILE %END %GOTO %IF %THEN %ELSE %LOCAL + %RETURN + %INCLUDE %LIST %RUN + ) + # Omitted: + # %label: Identifies the destination of a %GOTO statement. + # %MEND + end + + def self.sas_macro_functions + # from SAS 9.4 Macro Language Reference + # Chapter 12 + + @sas_macro_functions ||= Set.new %w( + %BQUOTE %NRBQUOTE %EVAL %INDEX %LENGTH %QUOTE %NRQUOTE %SCAN + %QSCAN %STR %NRSTR %SUBSTR %QSUBSTR %SUPERQ %SYMEXIST %SYMGLOBL + %SYMLOCAL %SYSEVALF %SYSFUNC %QSYSFUNC %SYSGET %SYSMACEXEC + %SYSMACEXIST %SYSMEXECDEPTH %SYSMEXECNAME %SYSPROD %UNQUOTE + %UPCASE %QUPCASE + ) + end + + def self.sas_auto_macro_vars + # from SAS 9.4 Macro Language Reference + # Chapter 12 + + @sas_auto_macro_vars ||= Set.new %w( + &SYSADDRBITS &SYSBUFFR &SYSCC &SYSCHARWIDTH &SYSCMD &SYSDATASTEPPHASE &SYSDATE + &SYSDATE9 &SYSDAY &SYSDEVIC &SYSDMG &SYSDSN &SYSENCODING &SYSENDIAN &SYSENV + &SYSERR &SYSERRORTEXT &SYSFILRC &SYSHOSTINFOLONG &SYSHOSTNAME &SYSINDEX + &SYSINFO &SYSJOBID &SYSLAST &SYSLCKRC &SYSLIBRC &SYSLOGAPPLNAME &SYSMACRONAME + &SYSMENV &SYSMSG &SYSNCPU &SYSNOBS &SYSODSESCAPECHAR &SYSODSPATH &SYSPARM + &SYSPBUFF &SYSPRINTTOLIST &SYSPRINTTOLOG &SYSPROCESSID &SYSPROCESSMODE + &SYSPROCESSNAME &SYSPROCNAME &SYSRC &SYSSCP &SYSSCPL &SYSSITE &SYSSIZEOFLONG + &SYSSIZEOFPTR &SYSSIZEOFUNICODE &SYSSTARTID &SYSSTARTNAME &SYSTCPIPHOSTNAME + &SYSTIME &SYSTIMEZONE &SYSTIMEZONEIDENT &SYSTIMEZONEOFFSET &SYSUSERID &SYSVER + &SYSVLONG &SYSVLONG4 &SYSWARNINGTEXT + ) + end + + def self.proc_keywords + # Create a hash with keywords for common PROCs, keyed by PROC name + @proc_keywords ||= {} + + @proc_keywords["SQL"] ||= Set.new %w( + ALTER TABLE CONNECT CREATE INDEX VIEW DELETE DESCRIBE DISCONNECT DROP EXECUTE + INSERT RESET SELECT UPDATE VALIDATE ADD CONSTRAINT DROP FOREIGN KEY PRIMARY + MODIFY LIKE AS ORDER BY USING FROM INTO SET VALUES RESET DISTINCT UNIQUE + WHERE GROUP HAVING LEFT RIGHT INNER JOIN ON + ) + # from SAS 9.4 SQL Procedure User's Guide + + @proc_keywords["MEANS"] ||= Set.new %w( + BY CLASS FREQ ID OUTPUT OUT TYPES VAR WAYS WEIGHT + ATTRIB FORMAT LABEL WHERE + DESCENDING NOTSORTED + NOTHREADS NOTRAP PCTLDEF SUMSIZE THREADS CLASSDATA COMPLETETYPES + EXCLUSIVE MISSING FW MAXDEC NONOBS NOPRINT ORDER FORMATTED FREQ + UNFORMATTED PRINT PRINTALLTYPES PRINTIDVARS STACKODSOUTPUT + CHARTYPE DESCENDTYPES IDMIN + ALPHA EXCLNPWGT QMARKERS QMETHOD QNTLDEF VARDEF + CLM CSS CV KURTOSIS KURT LCLM MAX MEAN MIN MODE N + NMISS RANGE SKEWNESS SKEW STDDEV STD STDERR SUM SUMWGT UCLM USS VAR + MEDIAN P50 Q1 P25 Q3 P75 P1 P90 P5 P95 P10 P99 P20 P30 P40 P60 P70 + P80 QRANGE + PROBT PRT T + ASCENDING GROUPINTERNAL MLF PRELOADFMT + MAXID AUTOLABEL AUTONAME KEEPLEN LEVELS NOINHERIT + ) + # from BASE SAS 9.4 Procedures Guide, Fifth Edition + + @proc_keywords["DATASETS"] ||= Set.new %w( + AGE APPEND ATTRIB AUDIT CHANGE CONTENTS COPY DELETE EXCHANGE + EXCLUDE FORMAT IC CREATE DELETE REACTIVATE INDEX CENTILES INFORMAT + INITIATE LABEL LOG MODIFY REBUILD RENAME REPAIR RESUME SAVE SELECT + SUSPEND TERMINATE USER_VAR XATTR ADD OPTIONS REMOVE SET + ) + # from BASE SAS 9.4 Procedures Guide, Fifth Edition + + @proc_keywords["SORT"] ||= Set.new %w( + BY DESCENDING KEY ASCENDING ASC DESC DATECOPY FORCE OVERWRITE + PRESORTED SORTSIZE TAGSORT DUPOUT OUT UNIQUEOUT NODUPKEY NOUNIQUEKEY + NOTHREADS THREADS EQUALS NOEQUALS + ATTRIB FORMAT LABEL WHERE + ) + # from BASE SAS 9.4 Procedures Guide, Fifth Edition + + @proc_keywords["PRINT"] ||= Set.new %w( + BY DESCENDING NOTSORTED PAGEBY SUMBY ID STYLE SUM VAR CONTENTS DATA + GRANDTOTAL_LABEL HEADING LABEL SPLIT SUMLABEL NOSUMLABEL + BLANKLINE COUNT DOUBLE N NOOBS OBS ROUND + ROWS UNIFORM WIDTH + ATTRIB FORMAT LABEL WHERE + ) + # from BASE SAS 9.4 Procedures Guide, Fifth Edition + + @proc_keywords["APPEND"] ||= Set.new %w( + BASE APPENDVER DATA ENCRYPTKEY FORCE GETSORT NOWARN + ATTRIB FORMAT LABEL WHERE + ) + # from BASE SAS 9.4 Procedures Guide, Fifth Edition + + @proc_keywords["TRANSPOSE"] ||= Set.new %w( + DELIMITER LABEL LET NAME OUT PREFIX SUFFIX BY DESCENDING NOTSORTED + COPY ID IDLABEL VAR INDB + ATTRIB FORMAT LABEL WHERE + ) + # from BASE SAS 9.4 Procedures Guide, Fifth Edition + + @proc_keywords["FREQ"] ||= Set.new %w( + BY EXACT OUTPUT TABLES TEST WEIGHT + COMPRESS DATA FORMCHAR NLEVELS NOPRINT ORDER PAGE FORMATTED FREQ + INTERNAL + AGREE BARNARD BINOMIAL BIN CHISQ COMOR EQOR ZELEN FISHER JT KAPPA + KENTB TAUB LRCHI MCNEM MEASURES MHCHI OR ODDSRATIO PCHI PCORR RELRISK + RISKDIFF SCORR SMDCR SMDRC STUTC TAUC TREND WTKAP WTKAPPA + OUT AJCHI ALL BDCHI CMH CMH1 CMH2 CMHCOR CMHGA CMHRMS COCHQ CONTGY + CRAMV EQKAP EQWKP GAMMA GS GAILSIMON LAMCR LAMDAS LAMRC LGOR LGRRC1 + LGRRC2 MHOR MHRRC1 MHRRC2 N NMISS PHI PLCORR RDIF1 RDIF2 RISKDIFF1 + RISKDIFF2 RRC1 RELRISK1 RRC2 RELRISK2 RSK1 RISK1 RSK11 RISK11 RSK12 + RISK12 RSK21 RISK21 RSK22 RISK22 TSYMM BOWKER U UCR URC + CELLCHI2 CUMCOL DEVIATION EXPECTED MISSPRINT PEARSONREF PRINTWKTS + SCOROUT SPARSE STDRES TOTPCT + CONTENTS CROSSLIST FORMAT LIST MAXLEVELS NOCOL NOCUM NOFREQ NOPERCENT + NOPRINT NOROW NOSPARSE NOWARN PLOTS OUT OUTCUM OUTEXPECT OUTPCT + ZEROS + ) + # from Base SAS 9.4 Procedures Guide: Statistical Procedures, Fourth Edition + + @proc_keywords["CORR"] ||= Set.new %w( + BY FREQ ID PARTIAL VAR WEIGHT WITH + DATA OUTH OUTK OUTP OUTPLC OUTPLS OUTS + EXCLNPWGHT FISHER HOEFFDING KENDALL NOMISS PEARSON POLYCHORIC + POLYSERIAL ALPHA COV CSSCP SINGULAR SSCP VARDEF PLOTS MATRIX SCATTER + BEST NOCORR NOPRINT NOPROB NOSIMPLE RANK + ) + # from Base SAS 9.4 Procedures Guide: Statistical Procedures, Fourth Edition + + @proc_keywords["REPORT"] ||= Set.new %w( + BREAK BY DESCENDING NOTSORTED COLUMN COMPUTE STYLE LINE ENDCOMP + CALL DEFINE _ROW_ FREQ RBREAK WEIGHT + ATTRIB FORMAT LABEL WHERE + DATA NOALIAS NOCENTER NOCOMPLETECOLS NOCOMPLETEROWS NOTHREADS + NOWINDOWS OUT PCTLDEF THREADS WINDOWS COMPLETECOLS NOCOMPLETECOLS + COMPLETEROWS NOCOMPLETEROWS CONTENTS SPANROWS COMMAND HELP PROMPT + BOX BYPAGENO CENTER NOCENTER COLWIDTH FORMCHAR LS MISSING PANELS PS + PSPACE SHOWALL SPACING WRAP EXCLNPWGT QMARKERS QMETHOD QNTLDEF VARDEF + NAMED NOHEADER SPLIT HEADLINE HEADSKIP LIST NOEXEC OUTREPT PROFILE + REPORT + COLOR DOL DUL OL PAGE SKIP SUMMARIZE SUPPRESS UL + BLINK COMMAND HIGHLIGHT RVSVIDEO MERGE REPLACE URL URLBP URLP + AFTER BEFORE _PAGE_ LEFT RIGHT CHARACTER LENGTH + EXCLUSIVE MISSING MLF ORDER DATA FORMATTED FREQ INTERNAL PRELOADFMT + WIDTH + ACROSS ANALYSIS COMPUTED DISPLAY GROUP ORDER + CONTENTS FLOW ID NOPRINT NOZERO PAGE + CSS CV MAX MEAN MIN MODE N NMISS PCTN PCTSUM RANGE STD STDERR SUM + SUMWGT USS VAR + MEDIAN P50 Q1 P25 Q3 P75 P1 P90 P5 P95 P10 P99 P20 P30 P40 P60 P70 + P80 QRANGE + PROBT PRT T + ) + # from BASE SAS 9.4 Procedures Guide, Fifth Edition + + @proc_keywords["METALIB"] ||= Set.new %w( + OMR DBAUTH DBUSER DBPASSWORD EXCLUDE SELECT READ FOLDER FOLDERID + IMPACT_LIMIT NOEXEC PREFIX REPORT UPDATE_RULE DELETE NOADD NODELDUP + NOUPDATE + LIBID LIBRARY LIBURI + TYPE DETAIL SUMMARY + ) + # from SAS 9.4 Language Interfaces to Metadata, Third Edition + + @proc_keywords["GCHART"] ||= Set.new %w( + DATA ANNOTATE GOUT IMAGEMAP BLOCK HBAR HBAR3D VBAR VBAR3D PIE PIE3D + DONUT STAR ANNO + BY NOTE FORMAT LABEL WHERE + BLOCKMAX CAXIS COUTLINE CTEXT LEGEND NOHEADING NOLEGEND PATTERNID + GROUP MIDPOINT SUBGROUP WOUTLINE DESCRIPTION NAME DISCRETE LEVELS + OLD MISSING HTML_LEGEND HTML URL FREQ G100 SUMVAR TYPE + CAUTOREF CERROR CFRAME CLM CREF FRAME NOFRAME GSPACE IFRAME + IMAGESTYLE TILE FIT LAUTOREF NOSYMBOL PATTERNID SHAPE SPACE + SUBOUTSIDE WAUTOREF WIDTH WOUTLINE WREF + ASCENDING AUTOREF CLIPREF DESCENDING FRONTREF GAXIS MAXIS MINOR + NOAXIS NOBASEREF NOZERO RANGE AXIS REF CFREQ CFREQLABEL NONE CPERCENT + CPERCENTLABEL ERRORBAR BARS BOTH TOP FREQLABEL INSIDE MEAN MEANLABEL + NOSTATS OUTSIDE PERCENT PERCENTLABEL PERCENTSUM SUM + CFILL COUTLINE DETAIL_RADIUS EXPLODE FILL SOLID X INVISIBLE NOHEADING + RADIUS WOUTLINE DETAIL_THRESHOLD DETAIL_PERCENT DETAIL_SLICE + DETAIL_VALUE DONUTPCT LABEL ACROSS DOWN GROUP NOGROUPHEADING SUBGROUP + MATCHCOLOR OTHERCOLOR OTHERLABEL PERCENT ARROW PLABEL PPERCENT SLICE + VALUE + ANGLE ASCENDING CLOCKWISE DESCENDING JSTYLE + NOCONNECT STARMAX STARMIN + ) + # from SAS GRAPH 9.4 Reference, Fourth Edition + + @proc_keywords["GPLOT"] ||= Set.new %w( + DATA ANNOTATE GOUT IMAGEMAP UNIFORM BUBBLE BUBBLE2 PLOT PLOT2 + BCOLOR BFILL BFONT BLABEL BSCALE AREA RADIUS BSIZE DESCRIPTION NAME + AUTOHREF CAUTOHREF CHREF HAXIS HMINOR HREF HREVERSE HZERO LAUTOHREF + LHREF WAUTOHREF WHREF HTML URL + CAXIS CFRAME CTEXT DATAORDER FRAME NOFRAME FRONTREF GRID IFRAME + IMAGESTYLE TILE FIT NOAXIS + AUTOVREF CAUTOVREF CVREF LAUTOVREF LVREF VAXIS VMINOR VREF VREVERSE + VZERO WAUTOVREF WVREF + CBASELINE COUTLINE + AREAS GRID LEGEND NOLASTAREA NOLEGEND OVERLAY REGEQN SKIPMISS + ) + # from SAS GRAPH 9.4 Reference, Fourth Edition + + @proc_keywords["REG"] ||= Set.new %w( + MODEL BY FREQ ID VAR WEIGHT ADD CODE DELETE MTEST OUTPUT PAINT + PLOT PRINT REFIT RESTRICT REWEIGHT STORE TEST + ) + # from SAS/STAT 15.1 User's Guide + + @proc_keywords["SGPLOT"] ||= Set.new %w( + STYLEATTRS BAND X Y UPPER LOWER BLOCK BUBBLE DENSITY DOT DROPLINE + ELLIPSE ELLIPSEPARM FRINGE GRADLEGEND HBAR HBARBASIC HBARPARM + HBOX HEATMAP HEATMAPPARM HIGHLOW HISTOGRAM HLINE INSET KEYLEGEND + LINEPARM LOESS NEEDLE PBSPLINE POLYGON REFLINE REG SCATTER SERIES + SPLINE STEP SYMBOLCHAR SYMBOLIMAGE TEXT VBAR VBARBASIC VBARPARM + VBOX VECTOR VLINE WATERFALL XAXIS X2AXIS XAXISTABLE YAXIS Y2AXIS + YAXISTABLE + ) + # from ODS Graphics: Procedures Guide, Sixth Edition + return @proc_keywords + end + + def self.sas_proc_names + # from SAS Procedures by Name + # http://support.sas.com/documentation/cdl/en/allprodsproc/68038/HTML/default/viewer.htm#procedures.htm + + @sas_proc_names ||= Set.new %w( + ACCESS ACECLUS ADAPTIVEREG ALLELE ANOM ANOVA APPEND APPSRV ARIMA + AUTHLIB AUTOREG BCHOICE BOM BOXPLOT BTL BUILD CALENDAR CALIS CALLRFC + CANCORR CANDISC CAPABILITY CASECONTROL CATALOG CATMOD CDISC CDISC + CHART CIMPORT CLP CLUSTER COMPARE COMPILE COMPUTAB CONTENTS CONVERT + COPULA COPY CORR CORRESP COUNTREG CPM CPORT CUSUM CV2VIEW DATEKEYS + DATASETS DATASOURCE DB2EXT DB2UTIL DBCSTAB DBF DBLOAD DELETE DIF + DISCRIM DISPLAY DISTANCE DMSRVADM DMSRVDATASVC DMSRVPROCESSSVC + DOCUMENT DOWNLOAD DQLOCLST DQMATCH DQSCHEME DS2 DTREE ENTROPY ESM + EXPAND EXPLODE EXPORT FACTEX FACTOR FAMILY FASTCLUS FCMP FEDSQL FMM + FONTREG FORECAST FORMAT FORMS FREQ FSBROWSE FSEDIT FSLETTER FSLIST + FSVIEW G3D G3GRID GA GAM GAMPL GANNO GANTT GAREABAR GBARLINE GCHART + GCONTOUR GDEVICE GEE GENESELECT GENMOD GEOCODE GFONT GINSIDE GIS GKPI + GLIMMIX GLM GLMMOD GLMPOWER GLMSELECT GMAP GOPTIONS GPLOT GPROJECT + GRADAR GREDUCE GREMOVE GREPLAY GROOVY GSLIDE GTILE HADOOP HAPLOTYPE + HDMD HPBIN HPCANDISC HPCDM HPCOPULA HPCORR HPCOUNTREG HPDMDB HPDS2 + HPFMM HPGENSELECT HPIMPUTE HPLMIXED HPLOGISTIC HPMIXED HPNLMOD + HPPANEL HPPLS HPPRINCOMP HPQUANTSELECT HPQLIM HPREG HPSAMPLE + HPSEVERITY HPSPLIT HPSUMMARY HTSNP HTTP ICLIFETEST ICPHREG IML IMPORT + IMSTAT IMXFER INBREED INFOMAPS INTPOINT IOMOPERATE IRT ISHIKAWA ITEMS + JAVAINFO JSON KDE KRIGE2D LASR LATTICE LIFEREG LIFETEST LOAN + LOCALEDATA LOESS LOGISTIC LP LUA MACONTROL MAPIMPORT MCMC MDC MDDB + MDS MEANS METADATA METALIB METAOPERATE MI MIANALYZE MIGRATE MIXED + MODECLUS MODEL MSCHART MULTTEST MVPDIAGNOSE MVPMODEL MVPMONITOR + NESTED NETDRAW NETFLOW NLIN NLMIXED NLP NPAR1WAY ODSLIST ODSTABLE + ODSTEXT OLAP OLAPCONTENTS OLAPOPERATE OPERATE OPTEX OPTGRAPH OPTIONS + OPTLOAD OPTLP OPTLSO OPTMILP OPTMODEL OPTNET OPTQP OPTSAVE ORTHOREG + PANEL PARETO PDLREG PDS PDSCOPY PHREG PLAN PLM PLOT PLS PM PMENU + POWER PRESENV PRINCOMP PRINQUAL PRINT PRINTTO PROBIT PROTO PRTDEF + PRTEXP PSMOOTH PWENCODE QDEVICE QLIM QUANTLIFE QUANTREG QUANTSELECT + QUEST RANK RAREEVENTS RDC RDPOOL RDSEC RECOMMEND REG REGISTRY RELEASE + RELIABILITY REPORT RISK ROBUSTREG RSREG SCAPROC SCORE SEQDESIGN + SEQTEST SERVER SEVERITY SGDESIGN SGPANEL SGPLOT SGRENDER SGSCATTER + SHEWHART SIM2D SIMILARITY SIMLIN SIMNORMAL SOAP SORT SOURCE SPECTRA + SPP SQL SQOOP SSM STANDARD STATESPACE STDIZE STDRATE STEPDISC STP + STREAM SUMMARY SURVEYFREQ SURVEYIMPUTE SURVEYLOGISTIC SURVEYMEANS + SURVEYPHREG SURVEYREG SURVEYSELECT SYSLIN TABULATE TAPECOPY TAPELABEL + TEMPLATE TIMEDATA TIMEID TIMEPLOT TIMESERIES TPSPLINE TRANSPOSE + TRANSREG TRANTAB TREE TSCSREG TTEST UCM UNIVARIATE UPLOAD VARCLUS + VARCOMP VARIOGRAM VARMAX VASMP X11 X12 X13 XSL + ) + end + + state :basics do + # Rules to be parsed before the keywords (which are different depending + # on the context) + + rule %r/\s+/m, Text + + # Single-line comments (between * and ;) - these can actually go onto multiple lines + # case 1 - where it starts a line + rule %r/^\s*%?\*[^;]*;/m, Comment::Single + # case 2 - where it follows the previous statement on the line (after a semicolon) + rule %r/(;)(\s*)(%?\*[^;]*;)/m do + groups Punctuation, Text, Comment::Single + end + + # True multiline comments! + rule %r(/[*].*?[*]/)m, Comment::Multiline + + # date/time constants (Language Reference pp91-2) + rule %r/'[0-9a-z]+?'d/i, Literal::Date + rule %r/'.+?'dt/i, Literal::Date + rule %r/'[0-9:]+?([a|p]m)?'t/i, Literal::Date + + rule %r/'/, Str::Single, :single_string + rule %r/"/, Str::Double, :double_string + rule %r/&[a-z0-9_&.]+/i, Name::Variable + + # numeric constants (Language Reference p91) + rule %r/\d[0-9a-f]*x/i, Num::Hex + rule %r/\d[0-9e\-.]+/i, Num # scientific notation + + # auto variables from DATA step (Language Reference p46, p37) + rule %r/\b(_n_|_error_|_file_|_infile_|_msg_|_iorc_|_cmd_)\b/i, Name::Builtin::Pseudo + + # auto variable list names + rule %r/\b(_character_|_numeric_|_all_)\b/i, Name::Builtin + + # datalines/cards etc + rule %r/\b(datalines|cards)(\s*)(;)/i do + groups Keyword, Text, Punctuation + push :datalines + end + rule %r/\b(datalines4|cards4)(\s*)(;)/i do + groups Keyword, Text, Punctuation + push :datalines4 + end + + + # operators (Language Reference p96) + rule %r(\*\*|[\*/\+-]), Operator + rule %r/[^¬~]?=:?|[<>]=?:?/, Operator + rule %r/\b(eq|ne|gt|lt|ge|le|in)\b/i, Operator::Word + rule %r/[&|!¦¬∘~]/, Operator + rule %r/\b(and|or|not)\b/i, Operator::Word + rule %r/(<>|><)/, Operator # min/max + rule %r/\|\|/, Operator # concatenation + + # The OF operator should also be highlighted (Language Reference p49) + rule %r/\b(of)\b/i, Operator::Word + rule %r/\b(like)\b/i, Operator::Word # Language Ref p181 + + rule %r/\d+/, Num::Integer + + rule %r/\$/, Keyword::Type + + # Macro definitions + rule %r/(%macro|%mend)(\s*)(\w+)/i do + groups Keyword, Text, Name::Function + end + rule %r/%mend/, Keyword + + rule %r/%\w+/ do |m| + if self.class.sas_macro_statements.include? m[0].upcase + token Keyword + elsif self.class.sas_macro_functions.include? m[0].upcase + token Keyword + else + token Name + end + end + end + + state :basics2 do + # Rules to be parsed after the keywords (which are different depending + # on the context) + + # Missing values (Language Reference p81) + rule %r/\s\.[;\s]/, Keyword::Constant # missing + rule %r/\s\.[a-z_]/, Name::Constant # user-defined missing + + rule %r/[\(\),;:\{\}\[\]\\\.]/, Punctuation + + rule %r/@/, Str::Symbol # line hold specifiers + rule %r/\?/, Str::Symbol # used for format modifiers + + rule %r/[^\s]+/, Text # Fallback for anything we haven't matched so far + end + + state :root do + mixin :basics + + # PROC definitions + rule %r!(proc)(\s+)(\w+)!ix do |m| + @proc_name = m[3].upcase + puts " proc name: #{@proc_name}" if @debug + if self.class.sas_proc_names.include? @proc_name + groups Keyword, Text, Keyword + else + groups Keyword, Text, Name + end + + push :proc + end + + # Data step definitions + rule %r/(data)(\s+)([\w\.]+)/i do + groups Keyword, Text, Name::Variable + end + # Libname definitions + rule %r/(libname)(\s+)(\w+)/i do + groups Keyword, Text, Name::Variable + end + + rule %r/\w+/ do |m| + if self.class.data_step_statements.include? m[0].upcase + token Keyword + elsif self.class.sas_functions.include? m[0].upcase + token Keyword + else + token Name + end + end + + mixin :basics2 + end + + + state :single_string do + rule %r/''/, Str::Escape + rule %r/'/, Str::Single, :pop! + rule %r/[^']+/, Str::Single + end + + state :double_string do + rule %r/&[a-z0-9_&]+\.?/i, Str::Interpol + rule %r/""/, Str::Escape + rule %r/"/, Str::Double, :pop! + + rule %r/[^&"]+/, Str::Double + # Allow & to be used as character if not already matched as macro variable + rule %r/&/, Str::Double + end + + state :datalines do + rule %r/[^;]/, Literal::String::Heredoc + rule %r/;/, Punctuation, :pop! + end + + state :datalines4 do + rule %r/;{4}/, Punctuation, :pop! + rule %r/[^;]/, Literal::String::Heredoc + rule %r/;{,3}/, Literal::String::Heredoc + end + + + # PROCS + state :proc do + rule %r/(quit|run)/i, Keyword, :pop! + + mixin :basics + rule %r/\w+/ do |m| + if self.class.data_step_statements.include? m[0].upcase + token Keyword + elsif self.class.sas_functions.include? m[0].upcase + token Keyword + elsif self.class.proc_keywords.has_key?(@proc_name) and self.class.proc_keywords[@proc_name].include? m[0].upcase + token Keyword + else + token Name + end + end + + mixin :basics2 + end + + end #class SAS + end #module Lexers +end #module Rouge diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sass.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sass.rb new file mode 100644 index 0000000..7758beb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sass.rb @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'sass/common.rb' + + class Sass < SassCommon + include Indentation + + title "Sass" + desc 'The Sass stylesheet language language (sass-lang.com)' + + tag 'sass' + filenames '*.sass' + mimetypes 'text/x-sass' + + id = /[\w-]+/ + + state :root do + rule %r/[ \t]*\n/, Text + rule(/[ \t]*/) { |m| token Text; indentation(m[0]) } + end + + state :content do + # block comments + rule %r(//.*?$) do + token Comment::Single + pop!; starts_block :single_comment + end + + rule %r(/[*].*?\n) do + token Comment::Multiline + pop!; starts_block :multi_comment + end + + rule %r/@import\b/, Keyword, :import + + mixin :content_common + + rule %r(=#{id}), Name::Function, :value + rule %r([+]#{id}), Name::Decorator, :value + + rule %r/:/, Name::Attribute, :old_style_attr + + rule(/(?=[^\[\n]+?:([^a-z]|$))/) { push :attribute } + + rule(//) { push :selector } + end + + state :single_comment do + rule %r/.*?$/, Comment::Single, :pop! + end + + state :multi_comment do + rule %r/.*?\n/, Comment::Multiline, :pop! + end + + state :import do + rule %r/[ \t]+/, Text + rule %r/\S+/, Str + rule %r/\n/, Text, :pop! + end + + state :old_style_attr do + mixin :attr_common + rule(//) { pop!; push :value } + end + + state :end_section do + rule(/\n/) { token Text; reset_stack } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sass/common.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sass/common.rb new file mode 100644 index 0000000..ed92c5c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sass/common.rb @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + # shared states with SCSS + class SassCommon < RegexLexer + id = /[\w-]+/ + + state :content_common do + rule %r/@for\b/, Keyword, :for + rule %r/@(debug|warn|if|each|while|else|return|media)/, Keyword, :value + + rule %r/(@mixin)(\s+)(#{id})/ do + groups Keyword, Text, Name::Function + push :value + end + + rule %r/(@function)(\s+)(#{id})/ do + groups Keyword, Text, Name::Function + push :value + end + + rule %r/@extend\b/, Keyword, :selector + + rule %r/(@include)(\s+)(#{id})/ do + groups Keyword, Text, Name::Decorator + push :value + end + + rule %r/@#{id}/, Keyword, :selector + rule %r/&/, Keyword, :selector + + # $variable: assignment + rule %r/([$]#{id})([ \t]*)(:)/ do + groups Name::Variable, Text, Punctuation + push :value + end + end + + state :value do + mixin :end_section + rule %r/[ \t]+/, Text + rule %r/[$]#{id}/, Name::Variable + rule %r/url[(]/, Str::Other, :string_url + rule %r/#{id}(?=\s*[(])/, Name::Function + rule %r/%#{id}/, Name::Decorator + + # named literals + rule %r/(true|false)\b/, Name::Builtin::Pseudo + rule %r/(and|or|not)\b/, Operator::Word + + # colors and numbers + rule %r/#[a-z0-9]{1,6}/i, Num::Hex + rule %r/-?\d+(%|[a-z]+)?/, Num + rule %r/-?\d*\.\d+(%|[a-z]+)?/, Num::Integer + + mixin :has_strings + mixin :has_interp + + rule %r/[~^*!&%<>\|+=@:,.\/?-]+/, Operator + rule %r/[\[\]()]+/, Punctuation + rule %r(/[*]), Comment::Multiline, :inline_comment + rule %r(//[^\n]*), Comment::Single + + # identifiers + rule(id) do |m| + if CSS.builtins.include? m[0] + token Name::Builtin + elsif CSS.constants.include? m[0] + token Name::Constant + else + token Name + end + end + end + + state :has_interp do + rule %r/[#][{]/, Str::Interpol, :interpolation + end + + state :has_strings do + rule %r/"/, Str::Double, :dq + rule %r/'/, Str::Single, :sq + end + + state :interpolation do + rule %r/}/, Str::Interpol, :pop! + mixin :value + end + + state :selector do + mixin :end_section + + mixin :has_strings + mixin :has_interp + rule %r/[ \t]+/, Text + rule %r/:/, Name::Decorator, :pseudo_class + rule %r/[.]/, Name::Class, :class + rule %r/#/, Name::Namespace, :id + rule %r/%/, Name::Variable, :placeholder + rule id, Name::Tag + rule %r/&/, Keyword + rule %r/[~^*!&\[\]()<>\|+=@:;,.\/?-]/, Operator + end + + state :dq do + rule %r/"/, Str::Double, :pop! + mixin :has_interp + rule %r/(\\.|#(?![{])|[^\n"#])+/, Str::Double + end + + state :sq do + rule %r/'/, Str::Single, :pop! + mixin :has_interp + rule %r/(\\.|#(?![{])|[^\n'#])+/, Str::Single + end + + state :string_url do + rule %r/[)]/, Str::Other, :pop! + rule %r/(\\.|#(?![{])|[^\n)#])+/, Str::Other + mixin :has_interp + end + + state :selector_piece do + mixin :has_interp + rule(//) { pop! } + end + + state :pseudo_class do + rule id, Name::Decorator + mixin :selector_piece + end + + state :class do + rule id, Name::Class + mixin :selector_piece + end + + state :id do + rule id, Name::Namespace + mixin :selector_piece + end + + state :placeholder do + rule id, Name::Variable + mixin :selector_piece + end + + state :for do + rule %r/(from|to|through)/, Operator::Word + mixin :value + end + + state :attr_common do + mixin :has_interp + rule id do |m| + if CSS.attributes.include? m[0] + token Name::Label + else + token Name::Attribute + end + end + end + + state :attribute do + mixin :attr_common + + rule %r/([ \t]*)(:)/ do + groups Text, Punctuation + push :value + end + end + + state :inline_comment do + rule %r/(\\#|#(?=[^\n{])|\*(?=[^\n\/])|[^\n#*])+/, Comment::Multiline + mixin :has_interp + rule %r([*]/), Comment::Multiline, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scala.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scala.rb new file mode 100644 index 0000000..0758699 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scala.rb @@ -0,0 +1,172 @@ +# -*- coding: utf-8 # +# frozen_string_literal: true + +module Rouge + module Lexers + class Scala < RegexLexer + title "Scala" + desc "The Scala programming language (scala-lang.org)" + tag 'scala' + aliases 'scala' + filenames '*.scala', '*.sbt' + + mimetypes 'text/x-scala', 'application/x-scala' + + # As documented in the ENBF section of the scala specification + # https://scala-lang.org/files/archive/spec/2.13/13-syntax-summary.html + # https://en.wikipedia.org/wiki/Unicode_character_property#General_Category + whitespace = /\p{Space}/ + letter = /[\p{L}$_]/ + upper = /[\p{Lu}$_]/ + digits = /[0-9]/ + parens = /[(){}\[\]]/ + delims = %r([‘’".;,]) + + # negative lookahead to filter out other classes + op = %r( + (?!#{whitespace}|#{letter}|#{digits}|#{parens}|#{delims}) + [-!#%&*/:?@\\^\p{Sm}\p{So}] + )x + # manually removed +<=>|~ from regexp because they're in property Sm + # pp CHRS:(0x00..0x7f).map(&:chr).grep(/\p{Sm}/) + + idrest = %r(#{letter}(?:#{letter}|#{digits})*(?:(?<=_)#{op}+)?)x + + keywords = %w( + abstract case catch def do else extends final finally for forSome + if implicit lazy match new override private protected requires return + sealed super this throw try val var while with yield + ) + + state :root do + rule %r/(class|trait|object)(\s+)/ do + groups Keyword, Text + push :class + end + rule %r/'#{idrest}(?!')/, Str::Symbol + rule %r/[^\S\n]+/, Text + + rule %r(//.*), Comment::Single + rule %r(/\*), Comment::Multiline, :comment + + rule %r/@#{idrest}/, Name::Decorator + + rule %r/(def)(\s+)(#{idrest}|#{op}+|`[^`]+`)(\s*)/ do + groups Keyword, Text, Name::Function, Text + end + + rule %r/(val)(\s+)(#{idrest}|#{op}+|`[^`]+`)(\s*)/ do + groups Keyword, Text, Name::Variable, Text + end + + rule %r/(this)(\n*)(\.)(#{idrest})/ do + groups Keyword, Text, Operator, Name::Property + end + + rule %r/(#{idrest}|_)(\n*)(\.)(#{idrest})/ do + groups Name::Variable, Text, Operator, Name::Property + end + + rule %r/#{upper}#{idrest}\b/, Name::Class + + rule %r/(#{idrest})(#{whitespace}*)(\()/ do + groups Name::Function, Text, Operator + end + + rule %r/(\.)(#{idrest})/ do + groups Operator, Name::Property + end + + rule %r( + (#{keywords.join("|")})\b| + (<[%:-]|=>|>:|[#=@_\u21D2\u2190])(\b|(?=\s)|$) + )x, Keyword + rule %r/:(?!#{op})/, Keyword, :type + rule %r/(true|false|null)\b/, Keyword::Constant + rule %r/(import|package)(\s+)/ do + groups Keyword, Text + push :import + end + + rule %r/(type)(\s+)/ do + groups Keyword, Text + push :type + end + + rule %r/""".*?"""(?!")/m, Str + rule %r/"(\\\\|\\"|[^"])*"/, Str + rule %r/'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'/, Str::Char + + rule idrest, Name + rule %r/`[^`]+`/, Name + + rule %r/\[/, Operator, :typeparam + rule %r/[\(\)\{\};,.#]/, Operator + rule %r/#{op}+/, Operator + + rule %r/([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?/, Num::Float + rule %r/([0-9][0-9]*[fFdD])/, Num::Float + rule %r/0x[0-9a-fA-F]+/, Num::Hex + rule %r/[0-9]+L?/, Num::Integer + rule %r/\n/, Text + end + + state :class do + rule %r/(#{idrest}|#{op}+|`[^`]+`)(\s*)(\[)/ do + groups Name::Class, Text, Operator + push :typeparam + end + + rule %r/\s+/, Text + rule %r/{/, Operator, :pop! + rule %r/\(/, Operator, :pop! + rule %r(//.*), Comment::Single, :pop! + rule %r(#{idrest}|#{op}+|`[^`]+`), Name::Class, :pop! + end + + state :type do + rule %r/\s+/, Text + rule %r/<[%:]|>:|[#_\u21D2]|forSome|type/, Keyword + rule %r/([,\);}]|=>|=)(\s*)/ do + groups Operator, Text + pop! + end + rule %r/[\(\{]/, Operator, :type + + typechunk = /(?:#{idrest}|#{op}+\`[^`]+`)/ + rule %r/(#{typechunk}(?:\.#{typechunk})*)(\s*)(\[)/ do + groups Keyword::Type, Text, Operator + pop! + push :typeparam + end + + rule %r/(#{typechunk}(?:\.#{typechunk})*)(\s*)$/ do + groups Keyword::Type, Text + pop! + end + + rule %r(//.*), Comment::Single, :pop! + rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type + end + + state :typeparam do + rule %r/[\s,]+/, Text + rule %r/<[%:]|=>|>:|[#_\u21D2]|forSome|type/, Keyword + rule %r/([\]\)\}])/, Operator, :pop! + rule %r/[\(\[\{]/, Operator, :typeparam + rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type + end + + state :comment do + rule %r([^/\*]+), Comment::Multiline + rule %r(/\*), Comment::Multiline, :comment + rule %r(\*/), Comment::Multiline, :pop! + rule %r([*/]), Comment::Multiline + end + + state :import do + rule %r((#{idrest}|\.)+), Name::Namespace, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scheme.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scheme.rb new file mode 100644 index 0000000..96965d9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scheme.rb @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Scheme < RegexLexer + title "Scheme" + desc "The Scheme variant of Lisp" + + tag 'scheme' + filenames '*.scm', '*.ss' + mimetypes 'text/x-scheme', 'application/x-scheme' + + def self.keywords + @keywords ||= Set.new %w( + lambda define if else cond and or case let let* letrec begin + do delay set! => quote quasiquote unquote unquote-splicing + define-syntax let-syntax letrec-syntax syntax-rules + ) + end + + def self.builtins + @builtins ||= Set.new %w( + * + - / < <= = > >= abs acos angle append apply asin + assoc assq assv atan boolean? caaaar caaadr caaar caadar + caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr + cadr call-with-current-continuation call-with-input-file + call-with-output-file call-with-values call/cc car cdaaar cdaadr + cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr + cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? + char-ci=? char-ci>? char-downcase + char-lower-case? char-numeric? char-ready? char-upcase + char-upper-case? char-whitespace? char<=? char=? + char>? char? close-input-port close-output-port complex? cons + cos current-input-port current-output-port denominator + display dynamic-wind eof-object? eq? equal? eqv? eval + even? exact->inexact exact? exp expt floor for-each force gcd + imag-part inexact->exact inexact? input-port? integer->char + integer? interaction-environment lcm length list list->string + list->vector list-ref list-tail list? load log magnitude + make-polar make-rectangular make-string make-vector map + max member memq memv min modulo negative? newline not + null-environment null? number->string number? numerator odd? + open-input-file open-output-file output-port? pair? peek-char + port? positive? procedure? quotient rational? rationalize + read read-char real-part real? remainder reverse round + scheme-report-environment set-car! set-cdr! sin sqrt string + string->list string->number string->symbol string-append + string-ci<=? string-ci=? string-ci>? + string-copy string-fill! string-length string-ref + string-set! string<=? string=? + string>? string? substring symbol->string symbol? + tan transcript-off transcript-on truncate values vector + vector->list vector-fill! vector-length vector-ref + vector-set! vector? with-input-from-file with-output-to-file + write write-char zero? + ) + end + + id = /[a-z0-9!$\%&*+,\/:<=>?@^_~|-]+/i + + state :root do + # comments + rule %r/;.*$/, Comment::Single + rule %r/\s+/m, Text + rule %r/-?\d+\.\d+/, Num::Float + rule %r/-?\d+/, Num::Integer + + # Racket infinitites + rule %r/[+-]inf[.][f0]/, Num + + rule %r/#b[01]+/, Num::Bin + rule %r/#o[0-7]+/, Num::Oct + rule %r/#d[0-9]+/, Num::Integer + rule %r/#x[0-9a-f]+/i, Num::Hex + rule %r/#[ei][\d.]+/, Num::Other + + rule %r/"(\\\\|\\"|[^"])*"/, Str + rule %r/'#{id}/i, Str::Symbol + rule %r/#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i, + Str::Char + rule %r/#t|#f/, Name::Constant + rule %r/(?:'|#|`|,@|,|\.)/, Operator + + rule %r/(['#])(\s*)(\()/m do + groups Str::Symbol, Text, Punctuation + end + + rule %r/\(|\[/, Punctuation, :command + rule %r/\)|\]/, Punctuation + + rule id, Name::Variable + end + + state :command do + rule id, Name::Function do |m| + if self.class.keywords.include? m[0] + token Keyword + elsif self.class.builtins.include? m[0] + token Name::Builtin + else + token Name::Function + end + + pop! + end + + rule(//) { pop! } + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scss.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scss.rb new file mode 100644 index 0000000..7cf178c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/scss.rb @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'sass/common.rb' + + class Scss < SassCommon + title "SCSS" + desc "SCSS stylesheets (sass-lang.com)" + tag 'scss' + filenames '*.scss' + mimetypes 'text/x-scss' + + state :root do + rule %r/\s+/, Text + rule %r(//.*?$), Comment::Single + rule %r(/[*].*?[*]/)m, Comment::Multiline + rule %r/@import\b/, Keyword, :value + + mixin :content_common + + rule(/(?=[^;{}][;}])/) { push :attribute } + rule(/(?=[^;{}:\[]+:[^a-z])/) { push :attribute } + + rule(//) { push :selector } + end + + state :end_section do + rule %r/\n/, Text + rule(/[;{}]/) { token Punctuation; reset_stack } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sed.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sed.rb new file mode 100644 index 0000000..b3efe50 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sed.rb @@ -0,0 +1,173 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Sed < RegexLexer + title "sed" + desc 'sed, the ultimate stream editor' + + tag 'sed' + filenames '*.sed' + mimetypes 'text/x-sed' + + def self.detect?(text) + return true if text.shebang? 'sed' + end + + class Regex < RegexLexer + state :root do + rule %r/\\./, Str::Escape + rule %r/\[/, Punctuation, :brackets + rule %r/[$^.*]/, Operator + rule %r/[()]/, Punctuation + rule %r/./, Str::Regex + end + + state :brackets do + rule %r/\^/ do + token Punctuation + goto :brackets_int + end + + rule(//) { goto :brackets_int } + end + + state :brackets_int do + # ranges + rule %r/.-./, Name::Variable + rule %r/\]/, Punctuation, :pop! + rule %r/./, Str::Regex + end + end + + class Replacement < RegexLexer + state :root do + rule %r/\\./m, Str::Escape + rule %r/&/, Operator + rule %r/[^\\&]+/m, Text + end + end + + def regex + @regex ||= Regex.new(options) + end + + def replacement + @replacement ||= Replacement.new(options) + end + + start { regex.reset!; replacement.reset! } + + state :whitespace do + rule %r/\s+/m, Text + rule(/#.*?\n/) { token Comment; reset_stack } + rule(/\n/) { token Text; reset_stack } + rule(/;/) { token Punctuation; reset_stack } + end + + state :root do + mixin :addr_range + end + + edot = /\\.|./m + + state :command do + mixin :whitespace + + # subst and transliteration + rule %r/(s)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m| + token Keyword, m[1] + token Punctuation, m[2] + delegate regex, m[3] + token Punctuation, m[4] + delegate replacement, m[5] + token Punctuation, m[6] + + + goto :flags + end + + rule %r/(y)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m| + token Keyword, m[1] + token Punctuation, m[2] + delegate replacement, m[3] + token Punctuation, m[4] + delegate replacement, m[5] + token Punctuation, m[6] + + pop! + end + + # commands that take a text segment as an argument + rule %r/([aic])(\s*)/ do + groups Keyword, Text; goto :text + end + + rule %r/[pd]/, Keyword + + # commands that take a number argument + rule %r/([qQl])(\s+)(\d+)/i do + groups Keyword, Text, Num + pop! + end + + # no-argument commands + rule %r/[={}dDgGhHlnpPqx]/, Keyword, :pop! + + # commands that take a filename argument + rule %r/([rRwW])(\s+)(\S+)/ do + groups Keyword, Text, Name + pop! + end + + # commands that take a label argument + rule %r/([:btT])(\s+)(\S+)/ do + groups Keyword, Text, Name::Label + pop! + end + end + + state :addr_range do + mixin :whitespace + + ### address ranges ### + addr_tok = Keyword::Namespace + rule %r/\d+/, addr_tok + rule %r/[$,~+!]/, addr_tok + + rule %r((/)((?:\\.|.)*?)(/)) do |m| + token addr_tok, m[1]; delegate regex, m[2]; token addr_tok, m[3] + end + + # alternate regex rage delimiters + rule %r((\\)(.)((?:\\.|.)*?)(\2)) do |m| + token addr_tok, m[1] + m[2] + delegate regex, m[3] + token addr_tok, m[4] + end + + rule(//) { push :command } + end + + state :text do + rule %r/[^\\\n]+/, Str + rule %r/\\\n/, Str::Escape + rule %r/\\/, Str + rule %r/\n/, Text, :pop! + end + + state :flags do + rule %r/[gp]+/, Keyword, :pop! + + # writing to a file with the subst command. + # who'da thunk...? + rule %r/([wW])(\s+)(\S+)/ do + token Keyword; token Text; token Name + end + + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/shell.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/shell.rb new file mode 100644 index 0000000..3704066 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/shell.rb @@ -0,0 +1,205 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Shell < RegexLexer + title "shell" + desc "Various shell languages, including sh and bash" + + tag 'shell' + aliases 'bash', 'zsh', 'ksh', 'sh' + filenames '*.sh', '*.bash', '*.zsh', '*.ksh', '.bashrc', + '.kshrc', '.profile', + '.zshenv', '.zprofile', '.zshrc', '.zlogin', '.zlogout', + 'zshenv', 'zprofile', 'zshrc', 'zlogin', 'zlogout', + 'APKBUILD', 'PKGBUILD', '*.ebuild', + '*.eclass', '*.exheres-0', '*.exlib' + + mimetypes 'application/x-sh', 'application/x-shellscript', 'text/x-sh', + 'text/x-shellscript' + + def self.detect?(text) + return true if text.shebang?(/(ba|z|k)?sh/) + return true if text.start_with?('#compdef', '#autoload') + end + + KEYWORDS = %w( + if fi else while do done for then return function + select continue until esac elif in + ).join('|') + + BUILTINS = %w( + alias bg bind break builtin caller cd command compgen + complete declare dirs disown enable eval exec exit + export false fc fg getopts hash help history jobs let + local logout mapfile popd pushd pwd read readonly set + shift shopt source suspend test time times trap true type + typeset ulimit umask unalias unset wait + + cat tac nl od base32 base64 fmt pr fold head tail split csplit + wc sum cksum b2sum md5sum sha1sum sha224sum sha256sum sha384sum + sha512sum sort shuf uniq comm ptx tsort cut paste join tr expand + unexpand ls dir vdir dircolors cp dd install mv rm shred link ln + mkdir mkfifo mknod readlink rmdir unlink chown chgrp chmod touch + df du stat sync truncate echo printf yes expr tee basename dirname + pathchk mktemp realpath pwd stty printenv tty id logname whoami + groups users who date arch nproc uname hostname hostid uptime chcon + runcon chroot env nice nohup stdbuf timeout kill sleep factor numfmt + seq tar grep sudo awk sed gzip gunzip + ).join('|') + + state :basic do + rule %r/#.*$/, Comment + + rule %r/\b(#{KEYWORDS})\s*\b/, Keyword + rule %r/\bcase\b/, Keyword, :case + + rule %r/\b(#{BUILTINS})\s*\b(?!(\.|-))/, Name::Builtin + rule %r/[.](?=\s)/, Name::Builtin + + rule %r/(\b\w+)(=)/ do + groups Name::Variable, Operator + end + + rule %r/[\[\]{}()!=>]/, Operator + rule %r/&&|\|\|/, Operator + + # here-string + rule %r/<< ruby, + 'erb' => ERB.new(options), + 'javascript' => Javascript.new(options), + 'css' => CSS.new(options), + 'coffee' => Coffeescript.new(options), + 'markdown' => Markdown.new(options), + 'scss' => Scss.new(options), + 'sass' => Sass.new(options) + } + end + + start { ruby.reset!; html.reset! } + + state :root do + rule %r/\s*\n/, Text + rule(/\s*/) { |m| token Text; indentation(m[0]) } + end + + state :content do + mixin :css + + rule %r/\/#{dot}*/, Comment, :indented_block + + rule %r/(doctype)(\s+)(.*)/ do + groups Name::Namespace, Text::Whitespace, Text + pop! + end + + # filters, shamelessly ripped from HAML + rule %r/(\w*):\s*\n/ do |m| + token Name::Decorator + pop! + starts_block :filter_block + + filter_name = m[1].strip + + @filter_lexer = self.filters[filter_name] + @filter_lexer.reset! unless @filter_lexer.nil? + + puts " slim: filter #{filter_name.inspect} #{@filter_lexer.inspect}" if @debug + end + + # Text + rule %r([\|'](?=\s)) do + token Punctuation + pop! + starts_block :plain_block + goto :plain_block + end + + rule %r/-|==|=/, Punctuation, :ruby_line + + # Dynamic tags + rule %r/(\*)(#{ruby_chars}+\(.*?\))/ do |m| + token Punctuation, m[1] + delegate ruby, m[2] + push :tag + end + + rule %r/(\*)(#{ruby_chars}+)/ do |m| + token Punctuation, m[1] + delegate ruby, m[2] + push :tag + end + + #rule %r/<\w+(?=.*>)/, Keyword::Constant, :tag # Maybe do this, look ahead and stuff + rule %r(()) do |m| # Dirty html + delegate html, m[1] + pop! + end + + # Ordinary slim tags + rule %r/\w+/, Name::Tag, :tag + + end + + state :tag do + mixin :css + mixin :indented_block + mixin :interpolation + + # Whitespace control + rule %r/[<>]/, Punctuation + + # Trim whitespace + rule %r/\s+?/, Text::Whitespace + + # Splats, these two might be mergable? + rule %r/(\*)(#{ruby_chars}+)/ do |m| + token Punctuation, m[1] + delegate ruby, m[2] + end + + rule %r/(\*)(\{#{dot}+?\})/ do |m| + token Punctuation, m[1] + delegate ruby, m[2] + end + + # Attributes + rule %r/([\w\-]+)(\s*)(\=)/ do |m| + token Name::Attribute, m[1] + token Text::Whitespace, m[2] + token Punctuation, m[3] + push :html_attr + end + + # Ruby value + rule %r/(\=)(#{dot}+)/ do |m| + token Punctuation, m[1] + #token Keyword::Constant, m[2] + delegate ruby, m[2] + end + + # HTML Entities + rule(/&\S*?;/, Name::Entity) + + rule %r/#{dot}+?/, Text + + rule %r/\s*\n/, Text::Whitespace, :pop! + end + + state :css do + rule(/\.[\w-]*/) { token Name::Class; goto :tag } + rule(/#[a-zA-Z][\w:-]*/) { token Name::Function; goto :tag } + end + + state :html_attr do + # Strings, double/single quoted + rule(/\s*(['"])#{dot}*?\1/, Literal::String, :pop!) + + # Ruby stuff + rule(/(#{ruby_chars}+\(.*?\))/) { |m| delegate ruby, m[1]; pop! } + rule(/(#{ruby_chars}+)/) { |m| delegate ruby, m[1]; pop! } + + rule %r/\s+/, Text::Whitespace + end + + state :ruby_line do + # Need at top + mixin :indented_block + + rule(/[,\\]\s*\n/) { delegate ruby } + rule %r/[ ]\|[ \t]*\n/, Str::Escape + rule(/.*?(?=([,\\]$| \|)?[ \t]*$)/) { delegate ruby } + end + + state :filter_block do + rule %r/([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do + if @filter_lexer + delegate @filter_lexer + else + token Name::Decorator + end + end + + mixin :interpolation + mixin :indented_block + end + + state :plain_block do + mixin :interpolation + + rule %r(()) do |m| # Dirty html + delegate html, m[1] + end + + # HTML Entities + rule(/&\S*?;/, Name::Entity) + + #rule %r/([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do + rule %r/#{dot}+?/, Text + + mixin :indented_block + end + + state :interpolation do + rule %r/#[{]/, Str::Interpol, :ruby_interp + end + + state :ruby_interp do + rule %r/[}]/, Str::Interpol, :pop! + mixin :ruby_interp_inner + end + + state :ruby_interp_inner do + rule(/[{]/) { delegate ruby; push :ruby_interp_inner } + rule(/[}]/) { delegate ruby; pop! } + rule(/[^{}]+/) { delegate ruby } + end + + state :indented_block do + rule(/(?=|&!?,@%]) + + state :root do + rule %r/(<)(\w+:)(.*?)(>)/ do + groups Punctuation, Keyword, Text, Punctuation + end + + # mixin :squeak_fileout + mixin :whitespaces + mixin :method_definition + rule %r/([|])([\w\s]*)([|])/ do + groups Punctuation, Name::Variable, Punctuation + end + mixin :objects + rule %r/\^|:=|_/, Operator + + rule %r/[)}\]]/, Punctuation, :after_object + rule %r/[({\[!]/, Punctuation + end + + state :method_definition do + rule %r/([a-z]\w*:)(\s*)(\w+)/i do + groups Name::Function, Text, Name::Variable + end + + rule %r/^(\s*)(\b[a-z]\w*\b)(\s*)$/i do + groups Text, Name::Function, Text + end + + rule %r(^(\s*)(#{ops}+)(\s*)(\w+)(\s*)$) do + groups Text, Name::Function, Text, Name::Variable, Text + end + end + + state :block_variables do + mixin :whitespaces + rule %r/(:)(\s*)(\w+)/ do + groups Operator, Text, Name::Variable + end + + rule %r/[|]/, Punctuation, :pop! + + rule(//) { pop! } + end + + state :literals do + rule %r/'(''|.)*?'/m, Str, :after_object + rule %r/[$]./, Str::Char, :after_object + rule %r/#[(]/, Str::Symbol, :parenth + rule %r/(\d+r)?-?\d+(\.\d+)?(e-?\d+)?/, + Num, :after_object + rule %r/#("[^"]*"|#{ops}+|[\w:]+)/, + Str::Symbol, :after_object + end + + state :parenth do + rule %r/[)]/ do + token Str::Symbol + goto :after_object + end + + mixin :inner_parenth + end + + state :inner_parenth do + rule %r/#[(]/, Str::Symbol, :inner_parenth + rule %r/[)]/, Str::Symbol, :pop! + mixin :whitespaces + mixin :literals + rule %r/(#{ops}|[\w:])+/, Str::Symbol + end + + state :whitespaces do + rule %r/! !$/, Keyword # squeak chunk delimiter + rule %r/\s+/m, Text + rule %r/".*?"/m, Comment + end + + state :objects do + rule %r/\[/, Punctuation, :block_variables + rule %r/(self|super|true|false|nil|thisContext)\b/, + Name::Builtin::Pseudo, :after_object + rule %r/[A-Z]\w*(?!:)\b/, Name::Class, :after_object + rule %r/[a-z]\w*(?!:)\b/, Name::Variable, :after_object + mixin :literals + end + + state :after_object do + mixin :whitespaces + rule %r/(ifTrue|ifFalse|whileTrue|whileFalse|timesRepeat):/, + Name::Builtin, :pop! + rule %r/new(?!:)\b/, Name::Builtin + rule %r/:=|_/, Operator, :pop! + rule %r/[a-z]+\w*:/i, Name::Function, :pop! + rule %r/[a-z]+\w*/i, Name::Function + rule %r/#{ops}+/, Name::Function, :pop! + rule %r/[.]/, Punctuation, :pop! + rule %r/;/, Punctuation + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/smarty.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/smarty.rb new file mode 100644 index 0000000..9870e8b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/smarty.rb @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Smarty < TemplateLexer + title "Smarty" + desc 'Smarty Template Engine' + tag 'smarty' + aliases 'smarty' + filenames '*.tpl', '*.smarty' + mimetypes 'application/x-smarty', 'text/x-smarty' + + def self.builtins + @builtins ||= %w( + append assign block call capture config_load debug extends + for foreach foreachelse break continue function if elseif + else include include_php insert ldelim rdelim literal nocache + php section sectionelse setfilter strip while + counter cycle eval fetch html_checkboxes html_image html_options + html_radios html_select_date html_select_time html_table + mailto math textformat + capitalize cat count_characters count_paragraphs + count_sentences count_words date_format default escape + from_charset indent lower nl2br regex_replace replace spacify + string_format strip strip_tags to_charset truncate unescape + upper wordwrap + ) + end + + + state :root do + rule(/\{\s+/) { delegate parent } + + # block comments + rule %r/\{\*.*?\*\}/m, Comment + + rule %r/\{\/?(?![\s*])/ do + token Keyword + push :smarty + end + + + rule(/.+?(?={[\/a-zA-Z0-9$#*"'])/m) { delegate parent } + rule(/.+/m) { delegate parent } + end + + state :comment do + rule(/{\*/) { token Comment; push } + rule(/\*}/) { token Comment; pop! } + rule(/[^{}]+/m) { token Comment } + end + + state :smarty do + # allow nested tags + rule %r/\{\/?(?![\s*])/ do + token Keyword + push :smarty + end + + rule %r/}/, Keyword, :pop! + rule %r/\s+/m, Text + rule %r([~!%^&*()+=|\[\]:;,.<>/@?-]), Operator + rule %r/#[a-zA-Z_]\w*#/, Name::Variable + rule %r/\$[a-zA-Z_]\w*(\.\w+)*/, Name::Variable + rule %r/(true|false|null)\b/, Keyword::Constant + rule %r/[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?/, Num + rule %r/"(\\.|.)*?"/, Str::Double + rule %r/'(\\.|.)*?'/, Str::Single + + rule %r/([a-zA-Z_]\w*)/ do |m| + if self.class.builtins.include? m[0] + token Name::Builtin + else + token Name::Attribute + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sml.rb new file mode 100644 index 0000000..08ed1bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sml.rb @@ -0,0 +1,345 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SML < RegexLexer + title "SML" + desc 'Standard ML' + tag 'sml' + aliases 'ml' + filenames '*.sml', '*.sig', '*.fun' + + mimetypes 'text/x-standardml', 'application/x-standardml' + + def self.keywords + @keywords ||= Set.new %w( + abstype and andalso as case datatype do else end exception + fn fun handle if in infix infixr let local nonfix of op open + orelse raise rec then type val with withtype while + eqtype functor include sharing sig signature struct structure + where + ) + end + + def self.symbolic_reserved + @symbolic_reserved ||= Set.new %w(: | = => -> # :>) + end + + id = /[\w']+/i + symbol = %r([!%&$#/:<=>?@\\~`^|*+-]+) + + state :whitespace do + rule %r/\s+/m, Text + rule %r/[(][*]/, Comment, :comment + end + + state :delimiters do + rule %r/[(\[{]/, Punctuation, :main + rule %r/[)\]}]/, Punctuation, :pop! + + rule %r/\b(let|if|local)\b(?!')/ do + token Keyword::Reserved + push; push + end + + rule %r/\b(struct|sig|while)\b(?!')/ do + token Keyword::Reserved + push + end + + rule %r/\b(do|else|end|in|then)\b(?!')/, Keyword::Reserved, :pop! + end + + def token_for_id_with_dot(id) + if self.class.keywords.include? id + Error + else + Name::Namespace + end + end + + def token_for_final_id(id) + if self.class.keywords.include? id or self.class.symbolic_reserved.include? id + Error + else + Name + end + end + + def token_for_id(id) + if self.class.keywords.include? id + Keyword::Reserved + elsif self.class.symbolic_reserved.include? id + Punctuation + else + Name + end + end + + state :core do + rule %r/[()\[\]{},;_]|[.][.][.]/, Punctuation + rule %r/#"/, Str::Char, :char + rule %r/"/, Str::Double, :string + rule %r/~?0x[0-9a-fA-F]+/, Num::Hex + rule %r/0wx[0-9a-fA-F]+/, Num::Hex + rule %r/0w\d+/, Num::Integer + rule %r/~?\d+([.]\d+)?[eE]~?\d+/, Num::Float + rule %r/~?\d+[.]\d+/, Num::Float + rule %r/~?\d+/, Num::Integer + + rule %r/#\s*[1-9][0-9]*/, Name::Label + rule %r/#\s*#{id}/, Name::Label + rule %r/#\s+#{symbol}/, Name::Label + + rule %r/\b(datatype|abstype)\b(?!')/, Keyword::Reserved, :dname + rule(/(?=\bexception\b(?!'))/) { push :ename } + rule %r/\b(functor|include|open|signature|structure)\b(?!')/, + Keyword::Reserved, :sname + rule %r/\b(type|eqtype)\b(?!')/, Keyword::Reserved, :tname + + rule %r/'#{id}/, Name::Decorator + rule %r/(#{id})([.])/ do |m| + groups(token_for_id_with_dot(m[1]), Punctuation) + push :dotted + end + + rule id do |m| + token token_for_id(m[0]) + end + + rule symbol do |m| + token token_for_id(m[0]) + end + end + + state :dotted do + rule %r/(#{id})([.])/ do |m| + groups(token_for_id_with_dot(m[1]), Punctuation) + end + + rule id do |m| + token token_for_id(m[0]) + pop! + end + + rule symbol do |m| + token token_for_id(m[0]) + pop! + end + end + + state :root do + rule %r/#!.*?\n/, Comment::Preproc + rule(//) { push :main } + end + + state :main do + mixin :whitespace + + rule %r/\b(val|and)\b(?!')/, Keyword::Reserved, :vname + rule %r/\b(fun)\b(?!')/ do + token Keyword::Reserved + goto :main_fun + push :fname + end + + mixin :delimiters + mixin :core + end + + state :main_fun do + mixin :whitespace + rule %r/\b(fun|and)\b(?!')/, Keyword::Reserved, :fname + rule %r/\bval\b(?!')/ do + token Keyword::Reserved + goto :main + push :vname + end + + rule %r/[|]/, Punctuation, :fname + rule %r/\b(case|handle)\b(?!')/ do + token Keyword::Reserved + goto :main + end + + mixin :delimiters + mixin :core + end + + state :has_escapes do + rule %r/\\[\\"abtnvfr]/, Str::Escape + rule %r/\\\^[\x40-\x5e]/, Str::Escape + rule %r/\\[0-9]{3}/, Str::Escape + rule %r/\\u\h{4}/, Str::Escape + rule %r/\\\s+\\/, Str::Interpol + end + + state :string do + rule %r/[^"\\]+/, Str::Double + rule %r/"/, Str::Double, :pop! + mixin :has_escapes + end + + state :char do + rule %r/[^"\\]+/, Str::Char + rule %r/"/, Str::Char, :pop! + mixin :has_escapes + end + + state :breakout do + rule %r/(?=\b(#{SML.keywords.to_a.join('|')})\b(?!'))/ do + pop! + end + end + + state :sname do + mixin :whitespace + mixin :breakout + rule id, Name::Namespace + rule(//) { pop! } + end + + state :has_annotations do + rule %r/'[\w']*/, Name::Decorator + rule %r/[(]/, Punctuation, :tyvarseq + end + + state :fname do + mixin :whitespace + mixin :has_annotations + + rule id, Name::Function, :pop! + rule symbol, Name::Function, :pop! + end + + state :vname do + mixin :whitespace + mixin :has_annotations + + rule %r/(#{id})(\s*)(=(?!#{symbol}))/m do + groups Name::Variable, Text, Punctuation + pop! + end + + rule %r/(#{symbol})(\s*)(=(?!#{symbol}))/m do + groups Name::Variable, Text, Punctuation + end + + rule id, Name::Variable, :pop! + rule symbol, Name::Variable, :pop! + + rule(//) { pop! } + end + + state :tname do + mixin :whitespace + mixin :breakout + mixin :has_annotations + + rule %r/'[\w']*/, Name::Decorator + rule %r/[(]/, Punctuation, :tyvarseq + + rule %r(=(?!#{symbol})) do + token Punctuation + goto :typbind + end + + rule id, Keyword::Type + rule symbol, Keyword::Type + end + + state :typbind do + mixin :whitespace + + rule %r/\b(and)\b(?!')/ do + token Keyword::Reserved + goto :tname + end + + mixin :breakout + mixin :core + end + + state :dname do + mixin :whitespace + mixin :breakout + mixin :has_annotations + + rule %r/(=)(\s*)(datatype)\b/ do + groups Punctuation, Text, Keyword::Reserved + pop! + end + + rule %r(=(?!#{symbol})) do + token Punctuation + goto :datbind + push :datcon + end + + rule id, Keyword::Type + rule symbol, Keyword::Type + end + + state :datbind do + mixin :whitespace + rule %r/\b(and)\b(?!')/ do + token Keyword::Reserved; goto :dname + end + rule %r/\b(withtype)\b(?!')/ do + token Keyword::Reserved; goto :tname + end + rule %r/\bof\b(?!')/, Keyword::Reserved + rule %r/([|])(\s*)(#{id})/ do + groups(Punctuation, Text, Name::Class) + end + + rule %r/([|])(\s+)(#{symbol})/ do + groups(Punctuation, Text, Name::Class) + end + + mixin :breakout + mixin :core + end + + state :ename do + mixin :whitespace + rule %r/(exception|and)(\s+)(#{id})/ do + groups Keyword::Reserved, Text, Name::Class + end + + rule %r/(exception|and)(\s*)(#{symbol})/ do + groups Keyword::Reserved, Text, Name::Class + end + + rule %r/\b(of)\b(?!')/, Keyword::Reserved + mixin :breakout + mixin :core + end + + state :datcon do + mixin :whitespace + rule id, Name::Class, :pop! + rule symbol, Name::Class, :pop! + end + + state :tyvarseq do + mixin :whitespace + rule %r/'[\w']*/, Name::Decorator + rule id, Name + rule %r/,/, Punctuation + rule %r/[)]/, Punctuation, :pop! + rule symbol, Name + end + + state :comment do + rule %r/[^(*)]+/, Comment::Multiline + rule %r/[(][*]/ do + token Comment::Multiline; push + end + rule %r/[*][)]/, Comment::Multiline, :pop! + rule %r/[(*)]/, Comment::Multiline + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sparql.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sparql.rb new file mode 100644 index 0000000..77b664f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sparql.rb @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SPARQL < RegexLexer + title "SPARQL" + desc "Semantic Query Language, for RDF data" + tag 'sparql' + filenames '*.rq' + mimetypes 'application/sparql-query' + + def self.builtins + @builtins = Set.new %w[ + ABS AVG BNODE BOUND CEIL COALESCE CONCAT CONTAINS COUNT DATATYPE DAY + ENCODE_FOR_URI FLOOR GROUP_CONCAT HOURS IF IRI isBLANK isIRI + isLITERAL isNUMERIC isURI LANG LANGMATCHES LCASE MAX MD5 MIN MINUTES + MONTH NOW RAND REGEX REPLACE ROUND SAMETERM SAMPLE SECONDS SEPARATOR + SHA1 SHA256 SHA384 SHA512 STR STRAFTER STRBEFORE STRDT STRENDS + STRLANG STRLEN STRSTARTS STRUUID SUBSTR SUM TIMEZONE TZ UCASE URI + UUID YEAR + ] + end + + def self.keywords + @keywords = Set.new %w[ + ADD ALL AS ASC ASK BASE BIND BINDINGS BY CLEAR CONSTRUCT COPY CREATE + DATA DEFAULT DELETE DESC DESCRIBE DISTINCT DROP EXISTS FILTER FROM + GRAPH GROUP BY HAVING IN INSERT LIMIT LOAD MINUS MOVE NAMED NOT + OFFSET OPTIONAL ORDER PREFIX SELECT REDUCED SERVICE SILENT TO UNDEF + UNION USING VALUES WHERE WITH + ] + end + + state :root do + rule %r(\s+)m, Text::Whitespace + rule %r(#.*), Comment::Single + + rule %r("""), Str::Double, :string_double_literal + rule %r("), Str::Double, :string_double + rule %r('''), Str::Single, :string_single_literal + rule %r('), Str::Single, :string_single + + rule %r([$?][[:word:]]+), Name::Variable + rule %r(([[:word:]-]*)(:)([[:word:]-]+)?) do |m| + token Name::Namespace, m[1] + token Operator, m[2] + token Str::Symbol, m[3] + end + rule %r(<[^>]*>), Name::Namespace + rule %r(true|false)i, Keyword::Constant + rule %r/a\b/, Keyword + + rule %r([A-Z][[:word:]]+\b)i do |m| + if self.class.builtins.include? m[0].upcase + token Name::Builtin + elsif self.class.keywords.include? m[0].upcase + token Keyword + else + token Error + end + end + + rule %r([+\-]?(?:\d+\.\d*|\.\d+)(?:[e][+\-]?[0-9]+)?)i, Num::Float + rule %r([+\-]?\d+), Num::Integer + rule %r([\]\[(){}.,;=]), Punctuation + rule %r([/?*+=!<>]|&&|\|\||\^\^), Operator + end + + state :string_double_common do + mixin :string_escapes + rule %r(\\), Str::Double + rule %r([^"\\]+), Str::Double + end + + state :string_double do + rule %r(") do + token Str::Double + goto :string_end + end + mixin :string_double_common + end + + state :string_double_literal do + rule %r(""") do + token Str::Double + goto :string_end + end + rule %r("), Str::Double + mixin :string_double_common + end + + state :string_single_common do + mixin :string_escapes + rule %r(\\), Str::Single + rule %r([^'\\]+), Str::Single + end + + state :string_single do + rule %r(') do + token Str::Single + goto :string_end + end + mixin :string_single_common + end + + state :string_single_literal do + rule %r(''') do + token Str::Single + goto :string_end + end + rule %r('), Str::Single + mixin :string_single_common + end + + state :string_escapes do + rule %r(\\[tbnrf"'\\]), Str::Escape + rule %r(\\u\h{4}), Str::Escape + rule %r(\\U\h{8}), Str::Escape + end + + state :string_end do + rule %r((@)([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)) do + groups Operator, Name::Property + end + rule %r(\^\^), Operator + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sqf.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sqf.rb new file mode 100644 index 0000000..331dafc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sqf.rb @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SQF < RegexLexer + tag "sqf" + filenames "*.sqf" + + title "SQF" + desc "Status Quo Function, a Real Virtuality engine scripting language" + + def self.wordoperators + @wordoperators ||= Set.new %w( + and or not + ) + end + + def self.initializers + @initializers ||= Set.new %w( + private param params + ) + end + + def self.controlflow + @controlflow ||= Set.new %w( + if then else exitwith switch do case default while for from to step + foreach + ) + end + + def self.constants + @constants ||= Set.new %w( + true false player confignull controlnull displaynull grpnull + locationnull netobjnull objnull scriptnull tasknull teammembernull + ) + end + + def self.namespaces + @namespaces ||= Set.new %w( + currentnamespace missionnamespace parsingnamespace profilenamespace + uinamespace + ) + end + + def self.diag_commands + @diag_commands ||= Set.new %w( + diag_activemissionfsms diag_activesqfscripts diag_activesqsscripts + diag_activescripts diag_captureframe diag_captureframetofile + diag_captureslowframe diag_codeperformance diag_drawmode diag_enable + diag_enabled diag_fps diag_fpsmin diag_frameno diag_lightnewload + diag_list diag_log diag_logslowframe diag_mergeconfigfile + diag_recordturretlimits diag_setlightnew diag_ticktime diag_toggle + ) + end + + def self.commands + Kernel::load File.join(Lexers::BASE_DIR, "sqf/keywords.rb") + commands + end + + state :root do + # Whitespace + rule %r"\s+", Text + + # Preprocessor instructions + rule %r"/\*.*?\*/"m, Comment::Multiline + rule %r"//.*", Comment::Single + rule %r"#(define|undef|if(n)?def|else|endif|include)", Comment::Preproc + rule %r"\\\r?\n", Comment::Preproc + rule %r"__(EVAL|EXEC|LINE__|FILE__)", Name::Builtin + + # Literals + rule %r"\".*?\"", Literal::String + rule %r"'.*?'", Literal::String + rule %r"(\$|0x)[0-9a-fA-F]+", Literal::Number::Hex + rule %r"[0-9]+(\.)?(e[0-9]+)?", Literal::Number::Float + + # Symbols + rule %r"[\!\%\&\*\+\-\/\<\=\>\^\|\#]", Operator + rule %r"[\(\)\{\}\[\]\,\:\;]", Punctuation + + # Identifiers (variables and functions) + rule %r"[a-zA-Z0-9_]+" do |m| + name = m[0].downcase + if self.class.wordoperators.include? name + token Operator::Word + elsif self.class.initializers.include? name + token Keyword::Declaration + elsif self.class.controlflow.include? name + token Keyword::Reserved + elsif self.class.constants.include? name + token Keyword::Constant + elsif self.class.namespaces.include? name + token Keyword::Namespace + elsif self.class.diag_commands.include? name + token Name::Function + elsif self.class.commands.include? name + token Name::Function + elsif %r"_.+" =~ name + token Name::Variable + else + token Name::Variable::Global + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sqf/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sqf/keywords.rb new file mode 100644 index 0000000..c390dd6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sqf/keywords.rb @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SQF + def self.commands + @commands ||= Set.new ["abs", "acos", "actionids", "actionkeys", "actionkeysimages", "actionkeysnames", "actionkeysnamesarray", "actionname", "activateaddons", "activatekey", "add3denconnection", "add3deneventhandler", "addcamshake", "addforcegeneratorrtd", "additempool", "addmagazinepool", "addmissioneventhandler", "addmusiceventhandler", "addswitchableunit", "addtoremainscollector", "addweaponpool", "admin", "agent", "agltoasl", "aimpos", "airdensityrtd", "airplanethrottle", "airportside", "aisfinishheal", "alive", "allcontrols", "allmissionobjects", "allsimpleobjects", "allturrets", "allturrets", "allvariables", "allvariables", "allvariables", "allvariables", "allvariables", "allvariables", "allvariables", "animationnames", "animationstate", "asin", "asltoagl", "asltoatl", "assert", "assignedcargo", "assignedcommander", "assigneddriver", "assignedgunner", "assigneditems", "assignedtarget", "assignedteam", "assignedvehicle", "assignedvehiclerole", "atan", "atg", "atltoasl", "attachedobject", "attachedobjects", "attachedto", "attackenabled", "backpack", "backpackcargo", "backpackcontainer", "backpackitems", "backpackmagazines", "behaviour", "binocular", "boundingbox", "boundingboxreal", "boundingcenter", "breakout", "breakto", "buldozer_enableroaddiag", "buldozer_loadnewroads", "buttonaction", "buttonaction", "buttonsetaction", "calculatepath", "calculateplayervisibilitybyfriendly", "call", "camcommitted", "camdestroy", "cameraeffectenablehud", "camerainterest", "campreloaded", "camtarget", "camusenvg", "cancelsimpletaskdestination", "canfire", "canmove", "canstand", "cantriggerdynamicsimulation", "canunloadincombat", "captive", "captivenum", "case", "cbchecked", "ceil", "channelenabled", "checkaifeature", "classname", "clear3deninventory", "clearallitemsfrombackpack", "clearbackpackcargo", "clearbackpackcargoglobal", "cleargroupicons", "clearitemcargo", "clearitemcargoglobal", "clearmagazinecargo", "clearmagazinecargoglobal", "clearoverlay", "clearweaponcargo", "clearweaponcargoglobal", "closedialog", "closeoverlay", "collapseobjecttree", "collect3denhistory", "collectivertd", "combatmode", "commander", "commandgetout", "commandstop", "comment", "commitoverlay", "compile", "compilefinal", "completedfsm", "composetext", "confighierarchy", "configname", "configproperties", "configsourceaddonlist", "configsourcemod", "configsourcemodlist", "copytoclipboard", "cos", "count", "count", "count", "create3dencomposition", "create3denentity", "createagent", "createcenter", "createdialog", "creatediarylink", "creategeardialog", "creategroup", "createguardedpoint", "createlocation", "createmarker", "createmarkerlocal", "createmine", "createsimpleobject", "createsoundsource", "createteam", "createtrigger", "createvehicle", "createvehiclecrew", "crew", "ctaddheader", "ctaddrow", "ctclear", "ctcursel", "ctheadercount", "ctrlactivate", "ctrlangle", "ctrlautoscrolldelay", "ctrlautoscrollrewind", "ctrlautoscrollspeed", "ctrlchecked", "ctrlclassname", "ctrlcommitted", "ctrldelete", "ctrlenable", "ctrlenabled", "ctrlenabled", "ctrlfade", "ctrlhtmlloaded", "ctrlidc", "ctrlidd", "ctrlmapanimclear", "ctrlmapanimcommit", "ctrlmapanimdone", "ctrlmapmouseover", "ctrlmapscale", "ctrlmodel", "ctrlmodeldirandup", "ctrlmodelscale", "ctrlparent", "ctrlparentcontrolsgroup", "ctrlposition", "ctrlscale", "ctrlsetfocus", "ctrlsettext", "ctrlshow", "ctrlshown", "ctrltext", "ctrltext", "ctrltextheight", "ctrltextsecondary", "ctrltextwidth", "ctrltype", "ctrlvisible", "ctrowcount", "curatoraddons", "curatorcameraarea", "curatorcameraareaceiling", "curatoreditableobjects", "curatoreditingarea", "curatoreditingareatype", "curatorpoints", "curatorregisteredobjects", "curatorwaypointcost", "currentcommand", "currentmagazine", "currentmagazinedetail", "currentmuzzle", "currentpilot", "currenttask", "currenttasks", "currentthrowable", "currentvisionmode", "currentwaypoint", "currentweapon", "currentweaponmode", "currentzeroing", "cutobj", "cutrsc", "cuttext", "damage", "datetonumber", "deactivatekey", "debriefingtext", "debuglog", "decaygraphvalues", "default", "deg", "delete3denentities", "deletecenter", "deletecollection", "deletegroup", "deleteidentity", "deletelocation", "deletemarker", "deletemarkerlocal", "deletesite", "deletestatus", "deleteteam", "deletevehicle", "deletewaypoint", "detach", "detectedmines", "diag_captureframe", "diag_captureframetofile", "diag_captureslowframe", "diag_codeperformance", "diag_dynamicsimulationend", "diag_lightnewload", "diag_log", "diag_logslowframe", "diag_setlightnew", "didjipowner", "difficultyenabled", "difficultyoption", "direction", "direction", "disablemapindicators", "disableremotesensors", "disableuserinput", "displayparent", "dissolveteam", "do3denaction", "dogetout", "dostop", "drawicon3d", "drawline3d", "driver", "drop", "dynamicsimulationdistance", "dynamicsimulationdistancecoef", "dynamicsimulationenabled", "dynamicsimulationenabled", "echo", "edit3denmissionattributes", "effectivecommander", "enableaudiofeature", "enablecamshake", "enablecaustics", "enabledebriefingstats", "enablediaglegend", "enabledynamicsimulationsystem", "enableengineartillery", "enableenvironment", "enableradio", "enablesatnormalondetail", "enablesaving", "enablesentences", "enablestressdamage", "enableteamswitch", "enabletraffic", "enableweapondisassembly", "endmission", "enginesisonrtd", "enginespowerrtd", "enginesrpmrtd", "enginestorquertd", "entities", "entities", "estimatedtimeleft", "everybackpack", "everycontainer", "execfsm", "execvm", "exp", "expecteddestination", "exportjipmessages", "eyedirection", "eyepos", "face", "faction", "failmission", "fillweaponsfrompool", "finddisplay", "finite", "firstbackpack", "flag", "flaganimationphase", "flagowner", "flagside", "flagtexture", "fleeing", "floor", "for", "for", "forceatpositionrtd", "forcegeneratorrtd", "forcemap", "forcerespawn", "format", "formation", "formation", "formationdirection", "formationleader", "formationmembers", "formationposition", "formationtask", "formattext", "formleader", "fromeditor", "fuel", "fullcrew", "fullcrew", "gearidcammocount", "gearslotammocount", "gearslotdata", "get3denactionstate", "get3denconnections", "get3denentity", "get3denentityid", "get3dengrid", "get3denlayerentities", "get3denselected", "getaimingcoef", "getallenvsoundcontrollers", "getallhitpointsdamage", "getallownedmines", "getallsoundcontrollers", "getammocargo", "getanimaimprecision", "getanimspeedcoef", "getarray", "getartilleryammo", "getassignedcuratorlogic", "getassignedcuratorunit", "getbackpackcargo", "getbleedingremaining", "getburningvalue", "getcameraviewdirection", "getcenterofmass", "getconnecteduav", "getcontainermaxload", "getcustomaimcoef", "getcustomsoundcontroller", "getcustomsoundcontrollercount", "getdammage", "getdescription", "getdir", "getdirvisual", "getdiverstate", "getdlcassetsusagebyname", "getdlcs", "getdlcusagetime", "geteditorcamera", "geteditormode", "getenginetargetrpmrtd", "getfatigue", "getfieldmanualstartpage", "getforcedflagtexture", "getfuelcargo", "getgraphvalues", "getgroupiconparams", "getgroupicons", "getitemcargo", "getmagazinecargo", "getmarkercolor", "getmarkerpos", "getmarkerpos", "getmarkersize", "getmarkertype", "getmass", "getmissionconfig", "getmissionconfigvalue", "getmissionlayerentities", "getmissionpath", "getmodelinfo", "getnumber", "getobjectdlc", "getobjectfov", "getobjectmaterials", "getobjecttextures", "getobjecttype", "getoxygenremaining", "getpersonuseddlcs", "getpilotcameradirection", "getpilotcameraposition", "getpilotcamerarotation", "getpilotcameratarget", "getplatenumber", "getplayerchannel", "getplayerscores", "getplayeruid", "getpos", "getpos", "getposasl", "getposaslvisual", "getposaslw", "getposatl", "getposatlvisual", "getposvisual", "getposworld", "getposworldvisual", "getpylonmagazines", "getrepaircargo", "getrotorbrakertd", "getshotparents", "getslingload", "getstamina", "getstatvalue", "getsuppression", "getterrainheightasl", "gettext", "gettrimoffsetrtd", "getunitloadout", "getunitloadout", "getunitloadout", "getusermfdtext", "getusermfdvalue", "getvehiclecargo", "getweaponcargo", "getweaponsway", "getwingsorientationrtd", "getwingspositionrtd", "getwppos", "goggles", "goto", "group", "groupfromnetid", "groupid", "groupowner", "groupselectedunits", "gunner", "handgunitems", "handgunmagazine", "handgunweapon", "handshit", "haspilotcamera", "hcallgroups", "hcleader", "hcremoveallgroups", "hcselected", "hcshowbar", "headgear", "hidebody", "hideobject", "hideobjectglobal", "hint", "hintc", "hintcadet", "hintsilent", "hmd", "hostmission", "if", "image", "importallgroups", "importance", "incapacitatedstate", "inflamed", "infopanel", "infopanels", "ingameuiseteventhandler", "inheritsfrom", "inputaction", "isabletobreathe", "isagent", "isaimprecisionenabled", "isarray", "isautohoveron", "isautonomous", "isautostartupenabledrtd", "isautotrimonrtd", "isbleeding", "isburning", "isclass", "iscollisionlighton", "iscopilotenabled", "isdamageallowed", "isdlcavailable", "isengineon", "isforcedwalk", "isformationleader", "isgroupdeletedwhenempty", "ishidden", "isinremainscollector", "iskeyactive", "islaseron", "islighton", "islocalized", "ismanualfire", "ismarkedforcollection", "isnil", "isnull", "isnull", "isnull", "isnull", "isnull", "isnull", "isnull", "isnull", "isnull", "isnumber", "isobjecthidden", "isobjectrtd", "isonroad", "isplayer", "isrealtime", "isshowing3dicons", "issimpleobject", "issprintallowed", "isstaminaenabled", "istext", "istouchingground", "isturnedout", "isuavconnected", "isvehiclecargo", "isvehicleradaron", "iswalking", "isweapondeployed", "isweaponrested", "itemcargo", "items", "itemswithmagazines", "keyimage", "keyname", "landresult", "lasertarget", "lbadd", "lbclear", "lbclear", "lbcolor", "lbcolorright", "lbcursel", "lbcursel", "lbdata", "lbdelete", "lbpicture", "lbpictureright", "lbselection", "lbsetcolor", "lbsetcolorright", "lbsetcursel", "lbsetdata", "lbsetpicture", "lbsetpicturecolor", "lbsetpicturecolordisabled", "lbsetpicturecolorselected", "lbsetpictureright", "lbsetselectcolor", "lbsetselectcolorright", "lbsettext", "lbsettooltip", "lbsetvalue", "lbsize", "lbsize", "lbsort", "lbsort", "lbsort", "lbsortbyvalue", "lbsortbyvalue", "lbtext", "lbtextright", "lbvalue", "leader", "leader", "leader", "leaderboarddeinit", "leaderboardgetrows", "leaderboardinit", "leaderboardrequestrowsfriends", "leaderboardrequestrowsglobal", "leaderboardrequestrowsglobalarounduser", "leaderboardsrequestuploadscore", "leaderboardsrequestuploadscorekeepbest", "leaderboardstate", "lifestate", "lightdetachobject", "lightison", "linearconversion", "lineintersects", "lineintersectsobjs", "lineintersectssurfaces", "lineintersectswith", "list", "listremotetargets", "listvehiclesensors", "ln", "lnbaddarray", "lnbaddcolumn", "lnbaddrow", "lnbclear", "lnbclear", "lnbcolor", "lnbcolorright", "lnbcurselrow", "lnbcurselrow", "lnbdata", "lnbdeletecolumn", "lnbdeleterow", "lnbgetcolumnsposition", "lnbgetcolumnsposition", "lnbpicture", "lnbpictureright", "lnbsetcolor", "lnbsetcolorright", "lnbsetcolumnspos", "lnbsetcurselrow", "lnbsetdata", "lnbsetpicture", "lnbsetpicturecolor", "lnbsetpicturecolorright", "lnbsetpicturecolorselected", "lnbsetpicturecolorselectedright", "lnbsetpictureright", "lnbsettext", "lnbsettextright", "lnbsettooltip", "lnbsetvalue", "lnbsize", "lnbsize", "lnbsort", "lnbsortbyvalue", "lnbtext", "lnbtextright", "lnbvalue", "load", "loadabs", "loadbackpack", "loadfile", "loaduniform", "loadvest", "local", "local", "localize", "locationposition", "locked", "lockeddriver", "lockidentity", "log", "lognetwork", "lognetworkterminate", "magazinecargo", "magazines", "magazinesallturrets", "magazinesammo", "magazinesammocargo", "magazinesammofull", "magazinesdetail", "magazinesdetailbackpack", "magazinesdetailuniform", "magazinesdetailvest", "mapanimadd", "mapcenteroncamera", "mapgridposition", "markeralpha", "markerbrush", "markercolor", "markerdir", "markerpos", "markerpos", "markershape", "markersize", "markertext", "markertype", "matrixtranspose", "members", "menuaction", "menuadd", "menuchecked", "menuclear", "menuclear", "menucollapse", "menudata", "menudelete", "menuenable", "menuenabled", "menuexpand", "menuhover", "menuhover", "menupicture", "menusetaction", "menusetcheck", "menusetdata", "menusetpicture", "menusetvalue", "menushortcut", "menushortcuttext", "menusize", "menusort", "menutext", "menuurl", "menuvalue", "mineactive", "missiletarget", "missiletargetpos", "modparams", "moonphase", "morale", "move3dencamera", "moveout", "movetime", "movetocompleted", "movetofailed", "name", "name", "namesound", "nearestbuilding", "nearestbuilding", "nearestlocation", "nearestlocations", "nearestlocationwithdubbing", "nearestobject", "nearestobjects", "nearestterrainobjects", "needreload", "netid", "netid", "nextmenuitemindex", "not", "numberofenginesrtd", "numbertodate", "objectcurators", "objectfromnetid", "objectparent", "onbriefinggroup", "onbriefingnotes", "onbriefingplan", "onbriefingteamswitch", "oncommandmodechanged", "oneachframe", "ongroupiconclick", "ongroupiconoverenter", "ongroupiconoverleave", "onhcgroupselectionchanged", "onmapsingleclick", "onplayerconnected", "onplayerdisconnected", "onpreloadfinished", "onpreloadstarted", "onteamswitch", "opendlcpage", "openmap", "openmap", "opensteamapp", "openyoutubevideo", "owner", "param", "params", "parsenumber", "parsenumber", "parsesimplearray", "parsetext", "pickweaponpool", "pitch", "playableslotsnumber", "playersnumber", "playmission", "playmusic", "playmusic", "playscriptedmission", "playsound", "playsound", "playsound3d", "position", "position", "positioncameratoworld", "ppeffectcommitted", "ppeffectcommitted", "ppeffectcreate", "ppeffectdestroy", "ppeffectdestroy", "ppeffectenabled", "precision", "preloadcamera", "preloadsound", "preloadtitleobj", "preloadtitlersc", "preprocessfile", "preprocessfilelinenumbers", "primaryweapon", "primaryweaponitems", "primaryweaponmagazine", "priority", "private", "processdiarylink", "progressloadingscreen", "progressposition", "publicvariable", "publicvariableserver", "putweaponpool", "queryitemspool", "querymagazinepool", "queryweaponpool", "rad", "radiochannelcreate", "random", "random", "rank", "rankid", "rating", "rectangular", "registeredtasks", "reload", "reloadenabled", "remoteexec", "remoteexeccall", "remove3denconnection", "remove3deneventhandler", "remove3denlayer", "removeall3deneventhandlers", "removeallactions", "removeallassigneditems", "removeallcontainers", "removeallcuratoraddons", "removeallcuratorcameraareas", "removeallcuratoreditingareas", "removeallhandgunitems", "removeallitems", "removeallitemswithmagazines", "removeallmissioneventhandlers", "removeallmusiceventhandlers", "removeallownedmines", "removeallprimaryweaponitems", "removeallweapons", "removebackpack", "removebackpackglobal", "removefromremainscollector", "removegoggles", "removeheadgear", "removemissioneventhandler", "removemusiceventhandler", "removeswitchableunit", "removeuniform", "removevest", "requiredversion", "resetsubgroupdirection", "resources", "restarteditorcamera", "reverse", "roadat", "roadsconnectedto", "roledescription", "ropeattachedobjects", "ropeattachedto", "ropeattachenabled", "ropecreate", "ropecut", "ropedestroy", "ropeendposition", "ropelength", "ropes", "ropeunwind", "ropeunwound", "rotorsforcesrtd", "rotorsrpmrtd", "round", "save3deninventory", "saveoverlay", "savevar", "scopename", "score", "scoreside", "screenshot", "screentoworld", "scriptdone", "scriptname", "scudstate", "secondaryweapon", "secondaryweaponitems", "secondaryweaponmagazine", "selectbestplaces", "selectededitorobjects", "selectionnames", "selectmax", "selectmin", "selectplayer", "selectrandom", "selectrandomweighted", "sendaumessage", "sendudpmessage", "servercommand", "servercommandavailable", "servercommandexecutable", "set3denattributes", "set3dengrid", "set3deniconsvisible", "set3denlinesvisible", "set3denmissionattributes", "set3denmodelsvisible", "set3denselected", "setacctime", "setaperture", "setaperturenew", "setarmorypoints", "setcamshakedefparams", "setcamshakeparams", "setcompassoscillation", "setcurrentchannel", "setcustommissiondata", "setcustomsoundcontroller", "setdate", "setdefaultcamera", "setdetailmapblendpars", "setgroupiconsselectable", "setgroupiconsvisible", "sethorizonparallaxcoef", "sethudmovementlevels", "setinfopanel", "setlocalwindparams", "setmouseposition", "setmusiceventhandler", "setobjectviewdistance", "setobjectviewdistance", "setplayable", "setplayerrespawntime", "setshadowdistance", "setsimulweatherlayers", "setstaminascheme", "setstatvalue", "setsystemofunits", "setterraingrid", "settimemultiplier", "settrafficdensity", "settrafficdistance", "settrafficgap", "settrafficspeed", "setviewdistance", "setwind", "setwinddir", "showchat", "showcinemaborder", "showcommandingmenu", "showcompass", "showcuratorcompass", "showgps", "showhud", "showhud", "showmap", "showpad", "showradio", "showscoretable", "showsubtitles", "showuavfeed", "showwarrant", "showwatch", "showwaypoints", "side", "side", "side", "simpletasks", "simulationenabled", "simulclouddensity", "simulcloudocclusion", "simulinclouds", "sin", "size", "sizeof", "skill", "skiptime", "sleep", "sliderposition", "sliderposition", "sliderrange", "sliderrange", "slidersetposition", "slidersetrange", "slidersetspeed", "sliderspeed", "sliderspeed", "soldiermagazines", "someammo", "speaker", "speed", "speedmode", "sqrt", "squadparams", "stance", "startloadingscreen", "stopenginertd", "stopped", "str", "supportinfo", "surfaceiswater", "surfacenormal", "surfacetype", "switch", "switchcamera", "synchronizedobjects", "synchronizedtriggers", "synchronizedwaypoints", "synchronizedwaypoints", "systemchat", "tan", "taskalwaysvisible", "taskchildren", "taskcompleted", "taskcustomdata", "taskdescription", "taskdestination", "taskhint", "taskmarkeroffset", "taskparent", "taskresult", "taskstate", "tasktype", "teammember", "teamname", "teamtype", "terminate", "terrainintersect", "terrainintersectasl", "terrainintersectatasl", "text", "text", "textlog", "textlogformat", "tg", "throw", "titlecut", "titlefadeout", "titleobj", "titlersc", "titletext", "toarray", "tofixed", "tolower", "toloweransi", "tostring", "toupper", "toupperansi", "triggeractivated", "triggeractivation", "triggerammo", "triggerarea", "triggerattachedvehicle", "triggerstatements", "triggertext", "triggertimeout", "triggertimeoutcurrent", "triggertype", "try", "tvadd", "tvclear", "tvclear", "tvcollapse", "tvcollapseall", "tvcollapseall", "tvcount", "tvcursel", "tvcursel", "tvdata", "tvdelete", "tvexpand", "tvexpandall", "tvexpandall", "tvpicture", "tvpictureright", "tvsetcursel", "tvsetdata", "tvsetpicture", "tvsetpicturecolor", "tvsetpictureright", "tvsetpicturerightcolor", "tvsettext", "tvsettooltip", "tvsetvalue", "tvsort", "tvsortbyvalue", "tvtext", "tvtooltip", "tvvalue", "type", "type", "typename", "typeof", "uavcontrol", "uisleep", "unassigncurator", "unassignteam", "unassignvehicle", "underwater", "uniform", "uniformcontainer", "uniformitems", "uniformmagazines", "unitaddons", "unitaimposition", "unitaimpositionvisual", "unitbackpack", "unitisuav", "unitpos", "unitready", "unitrecoilcoefficient", "units", "units", "unlockachievement", "updateobjecttree", "useaiopermapobstructiontest", "useaisteeringcomponent", "vectordir", "vectordirvisual", "vectorlinearconversion", "vectormagnitude", "vectormagnitudesqr", "vectornormalized", "vectorup", "vectorupvisual", "vehicle", "vehiclecargoenabled", "vehiclereceiveremotetargets", "vehiclereportownposition", "vehiclereportremotetargets", "vehiclevarname", "velocity", "velocitymodelspace", "verifysignature", "vest", "vestcontainer", "vestitems", "vestmagazines", "visibleposition", "visiblepositionasl", "waituntil", "waypointattachedobject", "waypointattachedvehicle", "waypointbehaviour", "waypointcombatmode", "waypointcompletionradius", "waypointdescription", "waypointforcebehaviour", "waypointformation", "waypointhouseposition", "waypointloiterradius", "waypointloitertype", "waypointname", "waypointposition", "waypoints", "waypointscript", "waypointsenableduav", "waypointshow", "waypointspeed", "waypointstatements", "waypointtimeout", "waypointtimeoutcurrent", "waypointtype", "waypointvisible", "weaponcargo", "weaponinertia", "weaponlowered", "weapons", "weaponsitems", "weaponsitemscargo", "weaponstate", "weaponstate", "weightrtd", "wfsidetext", "wfsidetext", "wfsidetext", "while", "wingsforcesrtd", "with", "worldtoscreen", "action", "actionparams", "add3denlayer", "addaction", "addbackpack", "addbackpackcargo", "addbackpackcargoglobal", "addbackpackglobal", "addcuratoraddons", "addcuratorcameraarea", "addcuratoreditableobjects", "addcuratoreditingarea", "addcuratorpoints", "addeditorobject", "addeventhandler", "addforce", "addgoggles", "addgroupicon", "addhandgunitem", "addheadgear", "additem", "additemcargo", "additemcargoglobal", "additemtobackpack", "additemtouniform", "additemtovest", "addlivestats", "addmagazine", "addmagazine", "addmagazineammocargo", "addmagazinecargo", "addmagazinecargoglobal", "addmagazineglobal", "addmagazines", "addmagazineturret", "addmenu", "addmenuitem", "addmpeventhandler", "addownedmine", "addplayerscores", "addprimaryweaponitem", "addpublicvariableeventhandler", "addpublicvariableeventhandler", "addrating", "addresources", "addscore", "addscoreside", "addsecondaryweaponitem", "addteammember", "addtorque", "adduniform", "addvehicle", "addvest", "addwaypoint", "addweapon", "addweaponcargo", "addweaponcargoglobal", "addweaponglobal", "addweaponitem", "addweaponturret", "addweaponwithattachmentscargo", "addweaponwithattachmentscargoglobal", "aimedattarget", "allow3dmode", "allowcrewinimmobile", "allowcuratorlogicignoreareas", "allowdamage", "allowdammage", "allowfileoperations", "allowfleeing", "allowgetin", "allowsprint", "ammo", "ammoonpylon", "and", "and", "animate", "animatebay", "animatedoor", "animatepylon", "animatesource", "animationphase", "animationsourcephase", "append", "apply", "arrayintersect", "assignascargo", "assignascargoindex", "assignascommander", "assignasdriver", "assignasgunner", "assignasturret", "assigncurator", "assignitem", "assignteam", "assigntoairport", "atan2", "attachobject", "attachto", "backpackspacefor", "bezierinterpolation", "boundingbox", "boundingboxreal", "breakout", "buildingexit", "buildingpos", "buttonsetaction", "call", "callextension", "callextension", "camcommand", "camcommit", "camcommitprepared", "camconstuctionsetparams", "camcreate", "cameraeffect", "campreload", "campreparebank", "campreparedir", "campreparedive", "campreparefocus", "campreparefov", "campreparefovrange", "campreparepos", "campreparerelpos", "campreparetarget", "campreparetarget", "camsetbank", "camsetdir", "camsetdive", "camsetfocus", "camsetfov", "camsetfovrange", "camsetpos", "camsetrelpos", "camsettarget", "camsettarget", "canadd", "canadditemtobackpack", "canadditemtouniform", "canadditemtovest", "canslingload", "canvehiclecargo", "catch", "cbsetchecked", "checkaifeature", "checkvisibility", "clear3denattribute", "closedisplay", "commandartilleryfire", "commandchat", "commandfire", "commandfollow", "commandfsm", "commandmove", "commandradio", "commandsuppressivefire", "commandtarget", "commandwatch", "commandwatch", "configclasses", "confirmsensortarget", "connectterminaltouav", "controlsgroupctrl", "copywaypoints", "count", "countenemy", "countfriendly", "countside", "counttype", "countunknown", "create3denentity", "creatediaryrecord", "creatediarysubject", "createdisplay", "createmenu", "createmissiondisplay", "createmissiondisplay", "creatempcampaigndisplay", "createsimpletask", "createsite", "createtask", "createunit", "createunit", "createvehicle", "createvehiclelocal", "ctdata", "ctfindheaderrows", "ctfindrowheader", "ctheadercontrols", "ctremoveheaders", "ctremoverows", "ctrladdeventhandler", "ctrlanimatemodel", "ctrlanimationphasemodel", "ctrlchecked", "ctrlcommit", "ctrlcreate", "ctrlenable", "ctrlmapanimadd", "ctrlmapcursor", "ctrlmapscreentoworld", "ctrlmapworldtoscreen", "ctrlremovealleventhandlers", "ctrlremoveeventhandler", "ctrlsetactivecolor", "ctrlsetangle", "ctrlsetautoscrolldelay", "ctrlsetautoscrollrewind", "ctrlsetautoscrollspeed", "ctrlsetbackgroundcolor", "ctrlsetchecked", "ctrlsetchecked", "ctrlsetdisabledcolor", "ctrlseteventhandler", "ctrlsetfade", "ctrlsetfont", "ctrlsetfonth1", "ctrlsetfonth1b", "ctrlsetfonth2", "ctrlsetfonth2b", "ctrlsetfonth3", "ctrlsetfonth3b", "ctrlsetfonth4", "ctrlsetfonth4b", "ctrlsetfonth5", "ctrlsetfonth5b", "ctrlsetfonth6", "ctrlsetfonth6b", "ctrlsetfontheight", "ctrlsetfontheighth1", "ctrlsetfontheighth2", "ctrlsetfontheighth3", "ctrlsetfontheighth4", "ctrlsetfontheighth5", "ctrlsetfontheighth6", "ctrlsetfontheightsecondary", "ctrlsetfontp", "ctrlsetfontp", "ctrlsetfontpb", "ctrlsetfontsecondary", "ctrlsetforegroundcolor", "ctrlsetmodel", "ctrlsetmodeldirandup", "ctrlsetmodelscale", "ctrlsetpixelprecision", "ctrlsetpixelprecision", "ctrlsetposition", "ctrlsetpositionh", "ctrlsetpositionw", "ctrlsetpositionx", "ctrlsetpositiony", "ctrlsetscale", "ctrlsetstructuredtext", "ctrlsettext", "ctrlsettextcolor", "ctrlsettextcolorsecondary", "ctrlsettextsecondary", "ctrlsettooltip", "ctrlsettooltipcolorbox", "ctrlsettooltipcolorshade", "ctrlsettooltipcolortext", "ctrlshow", "ctrowcontrols", "ctsetcursel", "ctsetdata", "ctsetheadertemplate", "ctsetrowtemplate", "ctsetvalue", "ctvalue", "curatorcoef", "currentmagazinedetailturret", "currentmagazineturret", "currentweaponturret", "customchat", "customradio", "cutfadeout", "cutfadeout", "cutobj", "cutobj", "cutrsc", "cutrsc", "cuttext", "cuttext", "debugfsm", "deleteat", "deleteeditorobject", "deletegroupwhenempty", "deleterange", "deleteresources", "deletevehiclecrew", "diarysubjectexists", "directsay", "disableai", "disablecollisionwith", "disableconversation", "disablenvgequipment", "disabletiequipment", "disableuavconnectability", "displayaddeventhandler", "displayctrl", "displayremovealleventhandlers", "displayremoveeventhandler", "displayseteventhandler", "distance", "distance", "distance", "distance", "distance2d", "distancesqr", "distancesqr", "distancesqr", "distancesqr", "do", "do", "do", "do", "doartilleryfire", "dofire", "dofollow", "dofsm", "domove", "doorphase", "dosuppressivefire", "dotarget", "dowatch", "dowatch", "drawarrow", "drawellipse", "drawicon", "drawline", "drawlink", "drawlocation", "drawpolygon", "drawrectangle", "drawtriangle", "editobject", "editorseteventhandler", "else", "emptypositions", "enableai", "enableaifeature", "enableaifeature", "enableaimprecision", "enableattack", "enableautostartuprtd", "enableautotrimrtd", "enablechannel", "enablechannel", "enablecollisionwith", "enablecopilot", "enabledynamicsimulation", "enabledynamicsimulation", "enablefatigue", "enablegunlights", "enableinfopanelcomponent", "enableirlasers", "enablemimics", "enablepersonturret", "enablereload", "enableropeattach", "enablesimulation", "enablesimulationglobal", "enablestamina", "enableuavconnectability", "enableuavwaypoints", "enablevehiclecargo", "enablevehiclesensor", "enableweapondisassembly", "engineon", "evalobjectargument", "exec", "execeditorscript", "execfsm", "execvm", "exitwith", "fademusic", "faderadio", "fadesound", "fadespeech", "find", "find", "findcover", "findeditorobject", "findeditorobject", "findemptyposition", "findemptypositionready", "findif", "findnearestenemy", "fire", "fire", "fireattarget", "flyinheight", "flyinheightasl", "forceadduniform", "forceflagtexture", "forcefollowroad", "forcespeed", "forcewalk", "forceweaponfire", "foreach", "foreachmember", "foreachmemberagent", "foreachmemberteam", "forgettarget", "from", "get3denattribute", "get3denattribute", "get3denattribute", "get3denattribute", "get3denattribute", "get3denmissionattribute", "getartilleryeta", "getcargoindex", "getcompatiblepylonmagazines", "getcompatiblepylonmagazines", "getdir", "geteditorobjectscope", "getenvsoundcontroller", "getfriend", "getfsmvariable", "getgroupicon", "gethidefrom", "gethit", "gethitindex", "gethitpointdamage", "getobjectargument", "getobjectchildren", "getobjectproxy", "getpos", "getreldir", "getrelpos", "getsoundcontroller", "getsoundcontrollerresult", "getspeed", "getunittrait", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "getvariable", "glanceat", "globalchat", "globalradio", "groupchat", "groupradio", "groupselectunit", "hasweapon", "hcgroupparams", "hcremovegroup", "hcselectgroup", "hcsetgroup", "hideobject", "hideobjectglobal", "hideselection", "hintc", "hintc", "hintc", "htmlload", "in", "in", "in", "in", "inarea", "inarea", "inarea", "inarea", "inarea", "inareaarray", "inareaarray", "inareaarray", "inareaarray", "inflame", "infopanelcomponentenabled", "infopanelcomponents", "inpolygon", "inrangeofartillery", "inserteditorobject", "intersect", "isequalto", "isequaltype", "isequaltypeall", "isequaltypeany", "isequaltypearray", "isequaltypeparams", "isflashlighton", "isflatempty", "isirlaseron", "iskindof", "iskindof", "iskindof", "issensortargetconfirmed", "isuavconnectable", "isuniformallowed", "isvehiclesensorenabled", "join", "joinas", "joinassilent", "joinsilent", "joinstring", "kbadddatabase", "kbadddatabasetargets", "kbaddtopic", "kbhastopic", "kbreact", "kbremovetopic", "kbtell", "kbwassaid", "knowsabout", "knowsabout", "land", "landat", "lbadd", "lbcolor", "lbcolorright", "lbdata", "lbdelete", "lbisselected", "lbpicture", "lbpictureright", "lbsetcolor", "lbsetcolorright", "lbsetcursel", "lbsetdata", "lbsetpicture", "lbsetpicturecolor", "lbsetpicturecolordisabled", "lbsetpicturecolorselected", "lbsetpictureright", "lbsetpicturerightcolor", "lbsetpicturerightcolordisabled", "lbsetpicturerightcolorselected", "lbsetselectcolor", "lbsetselectcolorright", "lbsetselected", "lbsettext", "lbsettextright", "lbsettooltip", "lbsetvalue", "lbtext", "lbtextright", "lbvalue", "leavevehicle", "leavevehicle", "lightattachobject", "limitspeed", "linkitem", "listobjects", "lnbaddcolumn", "lnbaddrow", "lnbcolor", "lnbcolorright", "lnbdata", "lnbdeletecolumn", "lnbdeleterow", "lnbpicture", "lnbpictureright", "lnbsetcolor", "lnbsetcolorright", "lnbsetcolumnspos", "lnbsetcurselrow", "lnbsetdata", "lnbsetpicture", "lnbsetpicturecolor", "lnbsetpicturecolorright", "lnbsetpicturecolorselected", "lnbsetpicturecolorselectedright", "lnbsetpictureright", "lnbsettext", "lnbsettextright", "lnbsettooltip", "lnbsetvalue", "lnbsort", "lnbsortbyvalue", "lnbtext", "lnbtextright", "lnbvalue", "loadidentity", "loadmagazine", "loadoverlay", "loadstatus", "lock", "lock", "lockcamerato", "lockcargo", "lockcargo", "lockdriver", "lockedcargo", "lockedturret", "lockturret", "lockwp", "lookat", "lookatpos", "magazinesturret", "magazineturretammo", "mapcenteroncamera", "matrixmultiply", "max", "menuaction", "menuadd", "menuchecked", "menucollapse", "menudata", "menudelete", "menuenable", "menuenabled", "menuexpand", "menupicture", "menusetaction", "menusetcheck", "menusetdata", "menusetpicture", "menusetvalue", "menushortcut", "menushortcuttext", "menusize", "menusort", "menutext", "menuurl", "menuvalue", "min", "minedetectedby", "mod", "modeltoworld", "modeltoworldvisual", "modeltoworldvisualworld", "modeltoworldworld", "move", "moveinany", "moveincargo", "moveincargo", "moveincommander", "moveindriver", "moveingunner", "moveinturret", "moveobjecttoend", "moveto", "nearentities", "nearestobject", "nearestobject", "nearobjects", "nearobjectsready", "nearroads", "nearsupplies", "neartargets", "newoverlay", "nmenuitems", "objstatus", "ondoubleclick", "onmapsingleclick", "onshownewobject", "or", "or", "ordergetin", "param", "params", "playaction", "playactionnow", "playgesture", "playmove", "playmovenow", "posscreentoworld", "posworldtoscreen", "ppeffectadjust", "ppeffectadjust", "ppeffectcommit", "ppeffectcommit", "ppeffectcommit", "ppeffectenable", "ppeffectenable", "ppeffectenable", "ppeffectforceinnvg", "preloadobject", "progresssetposition", "publicvariableclient", "pushback", "pushbackunique", "radiochanneladd", "radiochannelremove", "radiochannelsetcallsign", "radiochannelsetlabel", "random", "registertask", "remotecontrol", "remoteexec", "remoteexeccall", "removeaction", "removealleventhandlers", "removeallmpeventhandlers", "removecuratoraddons", "removecuratorcameraarea", "removecuratoreditableobjects", "removecuratoreditingarea", "removediaryrecord", "removediarysubject", "removedrawicon", "removedrawlinks", "removeeventhandler", "removegroupicon", "removehandgunitem", "removeitem", "removeitemfrombackpack", "removeitemfromuniform", "removeitemfromvest", "removeitems", "removemagazine", "removemagazineglobal", "removemagazines", "removemagazinesturret", "removemagazineturret", "removemenuitem", "removemenuitem", "removempeventhandler", "removeownedmine", "removeprimaryweaponitem", "removesecondaryweaponitem", "removesimpletask", "removeteammember", "removeweapon", "removeweaponattachmentcargo", "removeweaponcargo", "removeweaponglobal", "removeweaponturret", "reportremotetarget", "resize", "respawnvehicle", "reveal", "reveal", "revealmine", "ropeattachto", "ropedetach", "saveidentity", "savestatus", "say", "say", "say2d", "say2d", "say3d", "say3d", "select", "select", "select", "select", "select", "select", "selectdiarysubject", "selecteditorobject", "selectionposition", "selectleader", "selectrandomweighted", "selectweapon", "selectweaponturret", "sendsimplecommand", "sendtask", "sendtaskresult", "servercommand", "set", "set3denattribute", "set3denlayer", "set3denlogictype", "set3denmissionattribute", "set3denobjecttype", "setactualcollectivertd", "setairplanethrottle", "setairportside", "setammo", "setammocargo", "setammoonpylon", "setanimspeedcoef", "setattributes", "setautonomous", "setbehaviour", "setbehaviourstrong", "setbleedingremaining", "setbrakesrtd", "setcamerainterest", "setcamuseti", "setcaptive", "setcenterofmass", "setcollisionlight", "setcombatmode", "setcombatmode", "setconvoyseparation", "setcuratorcameraareaceiling", "setcuratorcoef", "setcuratoreditingareatype", "setcuratorwaypointcost", "setcurrenttask", "setcurrentwaypoint", "setcustomaimcoef", "setcustomweightrtd", "setdamage", "setdammage", "setdebriefingtext", "setdestination", "setdiaryrecordtext", "setdir", "setdirection", "setdrawicon", "setdriveonpath", "setdropinterval", "setdynamicsimulationdistance", "setdynamicsimulationdistancecoef", "seteditormode", "seteditorobjectscope", "seteffectcondition", "seteffectivecommander", "setenginerpmrtd", "setface", "setfaceanimation", "setfatigue", "setfeaturetype", "setflaganimationphase", "setflagowner", "setflagside", "setflagtexture", "setfog", "setforcegeneratorrtd", "setformation", "setformation", "setformationtask", "setformdir", "setfriend", "setfromeditor", "setfsmvariable", "setfuel", "setfuelcargo", "setgroupicon", "setgroupiconparams", "setgroupid", "setgroupidglobal", "setgroupowner", "setgusts", "sethidebehind", "sethit", "sethitindex", "sethitpointdamage", "setidentity", "setimportance", "setleader", "setlightambient", "setlightattenuation", "setlightbrightness", "setlightcolor", "setlightdaylight", "setlightflaremaxdistance", "setlightflaresize", "setlightintensity", "setlightnings", "setlightuseflare", "setmagazineturretammo", "setmarkeralpha", "setmarkeralphalocal", "setmarkerbrush", "setmarkerbrushlocal", "setmarkercolor", "setmarkercolorlocal", "setmarkerdir", "setmarkerdirlocal", "setmarkerpos", "setmarkerposlocal", "setmarkershape", "setmarkershapelocal", "setmarkersize", "setmarkersizelocal", "setmarkertext", "setmarkertextlocal", "setmarkertype", "setmarkertypelocal", "setmass", "setmimic", "setmissiletarget", "setmissiletargetpos", "setmusiceffect", "setname", "setname", "setname", "setnamesound", "setobjectarguments", "setobjectmaterial", "setobjectmaterialglobal", "setobjectproxy", "setobjecttexture", "setobjecttextureglobal", "setovercast", "setowner", "setoxygenremaining", "setparticlecircle", "setparticleclass", "setparticlefire", "setparticleparams", "setparticlerandom", "setpilotcameradirection", "setpilotcamerarotation", "setpilotcameratarget", "setpilotlight", "setpipeffect", "setpitch", "setplatenumber", "setpos", "setposasl", "setposasl2", "setposaslw", "setposatl", "setposition", "setposworld", "setpylonloadout", "setpylonspriority", "setradiomsg", "setrain", "setrainbow", "setrandomlip", "setrank", "setrectangular", "setrepaircargo", "setrotorbrakertd", "setshotparents", "setside", "setsimpletaskalwaysvisible", "setsimpletaskcustomdata", "setsimpletaskdescription", "setsimpletaskdestination", "setsimpletasktarget", "setsimpletasktype", "setsize", "setskill", "setskill", "setslingload", "setsoundeffect", "setspeaker", "setspeech", "setspeedmode", "setstamina", "setsuppression", "settargetage", "settaskmarkeroffset", "settaskresult", "settaskstate", "settext", "settitleeffect", "settriggeractivation", "settriggerarea", "settriggerstatements", "settriggertext", "settriggertimeout", "settriggertype", "settype", "setunconscious", "setunitability", "setunitloadout", "setunitloadout", "setunitloadout", "setunitpos", "setunitposweak", "setunitrank", "setunitrecoilcoefficient", "setunittrait", "setunloadincombat", "setuseractiontext", "setusermfdtext", "setusermfdvalue", "setvariable", "setvariable", "setvariable", "setvariable", "setvariable", "setvariable", "setvariable", "setvariable", "setvectordir", "setvectordirandup", "setvectorup", "setvehicleammo", "setvehicleammodef", "setvehiclearmor", "setvehiclecargo", "setvehicleid", "setvehiclelock", "setvehicleposition", "setvehicleradar", "setvehiclereceiveremotetargets", "setvehiclereportownposition", "setvehiclereportremotetargets", "setvehicletipars", "setvehiclevarname", "setvelocity", "setvelocitymodelspace", "setvelocitytransformation", "setvisibleiftreecollapsed", "setwantedrpmrtd", "setwaves", "setwaypointbehaviour", "setwaypointcombatmode", "setwaypointcompletionradius", "setwaypointdescription", "setwaypointforcebehaviour", "setwaypointformation", "setwaypointhouseposition", "setwaypointloiterradius", "setwaypointloitertype", "setwaypointname", "setwaypointposition", "setwaypointscript", "setwaypointspeed", "setwaypointstatements", "setwaypointtimeout", "setwaypointtype", "setwaypointvisible", "setweaponreloadingtime", "setwinddir", "setwindforce", "setwindstr", "setwingforcescalertd", "setwppos", "show3dicons", "showlegend", "showneweditorobject", "showwaypoint", "sidechat", "sideradio", "skill", "skillfinal", "slidersetposition", "slidersetrange", "slidersetspeed", "sort", "spawn", "splitstring", "step", "stop", "suppressfor", "swimindepth", "switchaction", "switchcamera", "switchgesture", "switchlight", "switchmove", "synchronizeobjectsadd", "synchronizeobjectsremove", "synchronizetrigger", "synchronizewaypoint", "synchronizewaypoint", "targetknowledge", "targets", "targetsaggregate", "targetsquery", "then", "then", "throw", "to", "tofixed", "triggerattachobject", "triggerattachvehicle", "triggerdynamicsimulation", "try", "turretlocal", "turretowner", "turretunit", "tvadd", "tvcollapse", "tvcount", "tvdata", "tvdelete", "tvexpand", "tvpicture", "tvpictureright", "tvsetcolor", "tvsetcursel", "tvsetdata", "tvsetpicture", "tvsetpicturecolor", "tvsetpicturecolordisabled", "tvsetpicturecolorselected", "tvsetpictureright", "tvsetpicturerightcolor", "tvsetpicturerightcolordisabled", "tvsetpicturerightcolorselected", "tvsetselectcolor", "tvsettext", "tvsettooltip", "tvsetvalue", "tvsort", "tvsortbyvalue", "tvtext", "tvtooltip", "tvvalue", "unassignitem", "unitsbelowheight", "unitsbelowheight", "unlinkitem", "unregistertask", "updatedrawicon", "updatemenuitem", "useaudiotimeformoves", "vectoradd", "vectorcos", "vectorcrossproduct", "vectordiff", "vectordistance", "vectordistancesqr", "vectordotproduct", "vectorfromto", "vectormodeltoworld", "vectormodeltoworldvisual", "vectormultiply", "vectorworldtomodel", "vectorworldtomodelvisual", "vehiclechat", "vehicleradio", "waypointattachobject", "waypointattachvehicle", "weaponaccessories", "weaponaccessoriescargo", "weapondirection", "weaponsturret", "worldtomodel", "worldtomodelvisual", "acctime", "activatedaddons", "agents", "airdensitycurvertd", "all3denentities", "allairports", "allcurators", "allcutlayers", "alldead", "alldeadmen", "alldisplays", "allgroups", "allmapmarkers", "allmines", "allplayers", "allsites", "allunits", "allunitsuav", "armorypoints", "benchmark", "blufor", "briefingname", "buldozer_isenabledroaddiag", "buldozer_reloadopermap", "cadetmode", "cameraon", "cameraview", "campaignconfigfile", "cansuspend", "cheatsenabled", "civilian", "clearforcesrtd", "clearitempool", "clearmagazinepool", "clearradio", "clearweaponpool", "clientowner", "commandingmenu", "configfile", "confignull", "controlnull", "copyfromclipboard", "curatorcamera", "curatormouseover", "curatorselected", "current3denoperation", "currentchannel", "currentnamespace", "cursorobject", "cursortarget", "customwaypointposition", "date", "daytime", "diag_activemissionfsms", "diag_activescripts", "diag_activesqfscripts", "diag_activesqsscripts", "diag_deltatime", "diag_fps", "diag_fpsmin", "diag_frameno", "diag_ticktime", "dialog", "didjip", "difficulty", "difficultyenabledrtd", "disabledebriefingstats", "disableserialization", "displaynull", "distributionregion", "dynamicsimulationsystemenabled", "east", "enableenddialog", "endl", "endloadingscreen", "environmentenabled", "estimatedendservertime", "exit", "false", "finishmissioninit", "fog", "fogforecast", "fogparams", "forcedmap", "forceend", "forceweatherchange", "freelook", "get3dencamera", "get3deniconsvisible", "get3denlinesvisible", "get3denmouseover", "getartillerycomputersettings", "getaudiooptionvolumes", "getcalculateplayervisibilitybyfriendly", "getclientstate", "getclientstatenumber", "getcursorobjectparams", "getdlcassetsusage", "getelevationoffset", "getmissiondlcs", "getmissionlayers", "getmouseposition", "getmusicplayedtime", "getobjectviewdistance", "getremotesensorsdisabled", "getresolution", "getshadowdistance", "getsubtitleoptions", "getterraingrid", "gettotaldlcusagetime", "groupiconselectable", "groupiconsvisible", "grpnull", "gusts", "halt", "hasinterface", "hcshownbar", "hudmovementlevels", "humidity", "independent", "initambientlife", "is3den", "is3denmultiplayer", "isactionmenuvisible", "isautotest", "isdedicated", "isfilepatchingenabled", "isgamefocused", "isgamepaused", "isinstructorfigureenabled", "ismultiplayer", "ismultiplayersolo", "ispipenabled", "isremoteexecuted", "isremoteexecutedjip", "isserver", "issteammission", "isstreamfriendlyuienabled", "isstressdamageenabled", "istuthintsenabled", "isuicontext", "language", "librarycredits", "librarydisclaimers", "lightnings", "linebreak", "loadgame", "locationnull", "logentities", "mapanimclear", "mapanimcommit", "mapanimdone", "markasfinishedonsteam", "missionconfigfile", "missiondifficulty", "missionname", "missionnamespace", "missionstart", "missionversion", "moonintensity", "musicvolume", "netobjnull", "nextweatherchange", "nil", "objnull", "opencuratorinterface", "opfor", "overcast", "overcastforecast", "parsingnamespace", "particlesquality", "pi", "pixelgrid", "pixelgridbase", "pixelgridnouiscale", "pixelh", "pixelw", "playableunits", "player", "playerrespawntime", "playerside", "productversion", "profilename", "profilenamespace", "profilenamesteam", "radiovolume", "rain", "rainbow", "remoteexecutedowner", "resetcamshake", "resistance", "reversedmousey", "runinitscript", "safezoneh", "safezonew", "safezonewabs", "safezonex", "safezonexabs", "safezoney", "savegame", "savejoysticks", "saveprofilenamespace", "savingenabled", "scriptnull", "selectnoplayer", "servername", "servertime", "shownartillerycomputer", "shownchat", "showncompass", "showncuratorcompass", "showngps", "shownhud", "shownmap", "shownpad", "shownradio", "shownscoretable", "shownuavfeed", "shownwarrant", "shownwatch", "sideambientlife", "sideempty", "sideenemy", "sidefriendly", "sidelogic", "sideunknown", "simulweathersync", "slingloadassistantshown", "soundvolume", "sunormoon", "switchableunits", "systemofunits", "tasknull", "teammembernull", "teams", "teamswitch", "teamswitchenabled", "time", "timemultiplier", "true", "uinamespace", "userinputdisabled", "vehicles", "viewdistance", "visiblecompass", "visiblegps", "visiblemap", "visiblescoretable", "visiblewatch", "waves", "west", "wind", "winddir", "windrtd", "windstr", "worldname", "worldsize"] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sql.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sql.rb new file mode 100644 index 0000000..ff5c8a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/sql.rb @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SQL < RegexLexer + title "SQL" + desc "Structured Query Language, for relational databases" + tag 'sql' + filenames '*.sql' + mimetypes 'text/x-sql' + + def self.keywords + @keywords ||= Set.new %w( + ABORT ABS ABSOLUTE ACCESS ADA ADD ADMIN AFTER AGGREGATE ALIAS + ALL ALLOCATE ALTER ANALYSE ANALYZE AND ANY ARE AS ASC ASENSITIVE + ASSERTION ASSIGNMENT ASYMMETRIC AT ATOMIC AUTHORIZATION + AVG BACKWARD BEFORE BEGIN BETWEEN BITVAR BIT_LENGTH BOTH + BREADTH BY C CACHE CALL CALLED CARDINALITY CASCADE CASCADED + CASE CAST CATALOG CATALOG_NAME CHAIN CHARACTERISTICS + CHARACTER_LENGTH CHARACTER_SET_CATALOG CHARACTER_SET_NAME + CHARACTER_SET_SCHEMA CHAR_LENGTH CHECK CHECKED CHECKPOINT + CLASS CLASS_ORIGIN CLOB CLOSE CLUSTER COALSECE COBOL COLLATE + COLLATION COLLATION_CATALOG COLLATION_NAME COLLATION_SCHEMA + COLUMN COLUMN_NAME COMMAND_FUNCTION COMMAND_FUNCTION_CODE + COMMENT COMMIT COMMITTED COMPLETION CONDITION_NUMBER + CONNECT CONNECTION CONNECTION_NAME CONSTRAINT CONSTRAINTS + CONSTRAINT_CATALOG CONSTRAINT_NAME CONSTRAINT_SCHEMA + CONSTRUCTOR CONTAINS CONTINUE CONVERSION CONVERT COPY + CORRESPONTING COUNT CREATE CREATEDB CREATEUSER CROSS CUBE + CURRENT CURRENT_DATE CURRENT_PATH CURRENT_ROLE CURRENT_TIME + CURRENT_TIMESTAMP CURRENT_USER CURSOR CURSOR_NAME CYCLE DATA + DATABASE DATETIME_INTERVAL_CODE DATETIME_INTERVAL_PRECISION + DAY DEALLOCATE DECLARE DEFAULT DEFAULTS DEFERRABLE DEFERRED + DEFINED DEFINER DELETE DELIMITER DELIMITERS DEREF DESC DESCRIBE + DESCRIPTOR DESTROY DESTRUCTOR DETERMINISTIC DIAGNOSTICS + DICTIONARY DISCONNECT DISPATCH DISTINCT DO DOMAIN DROP + DYNAMIC DYNAMIC_FUNCTION DYNAMIC_FUNCTION_CODE EACH ELSE + ENCODING ENCRYPTED END END-EXEC EQUALS ESCAPE EVERY EXCEPT + ESCEPTION EXCLUDING EXCLUSIVE EXEC EXECUTE EXISTING EXISTS + EXPLAIN EXTERNAL EXTRACT FALSE FETCH FINAL FIRST FOLLOWING FOR + FORCE FOREIGN FORTRAN FORWARD FOUND FREE FREEZE FROM FULL FUNCTION + G GENERAL GENERATED GET GLOBAL GO GOTO GRANT GRANTED GROUP + GROUPING HANDLER HAVING HIERARCHY HOLD HOST IDENTITY IGNORE + ILIKE IMMEDIATE IMMUTABLE IMPLEMENTATION IMPLICIT IN INCLUDING + INCREMENT INDEX INDITCATOR INFIX INHERITS INITIALIZE INITIALLY + INNER INOUT INPUT INSENSITIVE INSERT INSTANTIABLE INSTEAD + INTERSECT INTO INVOKER IS ISNULL ISOLATION ITERATE JOIN KEY + KEY_MEMBER KEY_TYPE LANCOMPILER LANGUAGE LARGE LAST LATERAL + LEADING LEFT LENGTH LESS LEVEL LIKE LIMIT LISTEN LOAD LOCAL + LOCALTIME LOCALTIMESTAMP LOCATION LOCATOR LOCK LOWER MAP MATCH + MAX MAXVALUE MESSAGE_LENGTH MESSAGE_OCTET_LENGTH MESSAGE_TEXT + METHOD MIN MINUTE MINVALUE MOD MODE MODIFIES MODIFY MONTH + MORE MOVE MUMPS NAMES NATURAL NCLOB NEW NEXT + NO NOCREATEDB NOCREATEUSER NONE NOT NOTHING NOTIFY NOTNULL + NULL NULLABLE NULLIF OBJECT OCTET_LENGTH OF OFF OFFSET OIDS + OLD ON ONLY OPEN OPERATION OPERATOR OPTION OPTIONS OR ORDER + ORDINALITY OUT OUTER OUTPUT OVERLAPS OVERLAY OVERRIDING + OWNER PAD PARAMETER PARAMETERS PARAMETER_MODE PARAMATER_NAME + PARAMATER_ORDINAL_POSITION PARAMETER_SPECIFIC_CATALOG + PARAMETER_SPECIFIC_NAME PARAMATER_SPECIFIC_SCHEMA PARTIAL PARTITION + PASCAL PENDANT PLACING PLI POSITION POSTFIX PREFIX PRECEDING PREORDER + PREPARE PRESERVE PRIMARY PRIOR PRIVILEGES PROCEDURAL PROCEDURE + PUBLIC RANGE READ READS RECHECK RECURSIVE REF REFERENCES REFERENCING + REINDEX RELATIVE RENAME REPEATABLE REPLACE RESET RESTART + RESTRICT RESULT RETURN RETURNED_LENGTH RETURNED_OCTET_LENGTH + RETURNED_SQLSTATE RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP + ROUTINE ROUTINE_CATALOG ROUTINE_NAME ROUTINE_SCHEMA ROW ROWS + ROW_COUNT RULE SAVE_POINT SCALE SCHEMA SCHEMA_NAME SCOPE SCROLL + SEARCH SECOND SECURITY SELECT SELF SENSITIVE SERIALIZABLE + SERVER_NAME SESSION SESSION_USER SET SETOF SETS SHARE SHOW + SIMILAR SIMPLE SIZE SOME SOURCE SPACE SPECIFIC SPECIFICTYPE + SPECIFIC_NAME SQL SQLCODE SQLERROR SQLEXCEPTION SQLSTATE + SQLWARNINIG STABLE START STATE STATEMENT STATIC STATISTICS + STDIN STDOUT STORAGE STRICT STRUCTURE STYPE SUBCLASS_ORIGIN + SUBLIST SUBSTRING SUM SYMMETRIC SYSID SYSTEM SYSTEM_USER + TABLE TABLE_NAME TEMP TEMPLATE TEMPORARY TERMINATE THAN THEN + TIMEZONE_HOUR TIMEZONE_MINUTE TO TOAST TRAILING + TRANSATION TRANSACTIONS_COMMITTED TRANSACTIONS_ROLLED_BACK + TRANSATION_ACTIVE TRANSFORM TRANSFORMS TRANSLATE TRANSLATION + TREAT TRIGGER TRIGGER_CATALOG TRIGGER_NAME TRIGGER_SCHEMA TRIM + TRUE TRUNCATE TRUSTED TYPE UNCOMMITTED UNDER UNENCRYPTED UNION + UNIQUE UNKNOWN UNLISTEN UNNAMED UNNEST UNTIL UPDATE UPPER + USAGE USER USER_DEFINED_TYPE_CATALOG USER_DEFINED_TYPE_NAME + USER_DEFINED_TYPE_SCHEMA USING VACUUM VALID VALIDATOR VALUES + VARIABLE VERBOSE VERSION VIEW VOLATILE WHEN WHENEVER WHERE + WINDOW WITH WITHOUT WORK WRITE ZONE + ) + end + + def self.keywords_type + # sources: + # https://dev.mysql.com/doc/refman/5.7/en/numeric-type-overview.html + # https://dev.mysql.com/doc/refman/5.7/en/date-and-time-type-overview.html + # https://dev.mysql.com/doc/refman/5.7/en/string-type-overview.html + @keywords_type ||= Set.new(%w( + ZEROFILL UNSIGNED SIGNED SERIAL BIT TINYINT BOOL BOOLEAN SMALLINT + MEDIUMINT INT INTEGER BIGINT DECIMAL DEC NUMERIC FIXED FLOAT DOUBLE + PRECISION REAL + DATE DATETIME TIMESTAMP TIME YEAR + NATIONAL CHAR CHARACTER NCHAR BYTE + VARCHAR VARYING BINARY VARBINARY TINYBLOB TINYTEXT BLOB TEXT + MEDIUMBLOB MEDIUMTEXT LONGBLOB LONGTEXT ENUM + )) + end + + state :root do + rule %r/\s+/m, Text + rule %r/--.*/, Comment::Single + rule %r(/\*), Comment::Multiline, :multiline_comments + rule %r/\d+/, Num::Integer + rule %r/'/, Str::Single, :single_string + # A double-quoted string refers to a database object in our default SQL + # dialect, which is apropriate for e.g. MS SQL and PostgreSQL. + rule %r/"/, Name::Variable, :double_string + rule %r/`/, Name::Variable, :backtick + + rule %r/\w+/ do |m| + if self.class.keywords_type.include? m[0].upcase + token Name::Builtin + elsif self.class.keywords.include? m[0].upcase + token Keyword + else + token Name + end + end + + rule %r([+*/<>=~!@#%&|?^-]), Operator + rule %r/[;:()\[\]\{\},.]/, Punctuation + end + + state :multiline_comments do + rule %r(/[*]), Comment::Multiline, :multiline_comments + rule %r([*]/), Comment::Multiline, :pop! + rule %r([^/*]+), Comment::Multiline + rule %r([/*]), Comment::Multiline + end + + state :backtick do + rule %r/\\./, Str::Escape + rule %r/``/, Str::Escape + rule %r/`/, Name::Variable, :pop! + rule %r/[^\\`]+/, Name::Variable + end + + state :single_string do + rule %r/\\./, Str::Escape + rule %r/''/, Str::Escape + rule %r/'/, Str::Single, :pop! + rule %r/[^\\']+/, Str::Single + end + + state :double_string do + rule %r/\\./, Str::Escape + rule %r/""/, Str::Escape + rule %r/"/, Name::Variable, :pop! + rule %r/[^\\"]+/, Name::Variable + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ssh.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ssh.rb new file mode 100644 index 0000000..11369e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ssh.rb @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SSH < RegexLexer + tag 'ssh' + + title "SSH Config File" + desc 'A lexer for SSH configuration files' + filenames 'ssh_config' + + state :root do + rule %r/[a-z0-9]+/i, Keyword, :statement + mixin :base + end + + state :statement do + rule %r/\n/, Text, :pop! + rule %r/(?:yes|no|confirm|ask|always|auto|none|force)\b/, Name::Constant + + rule %r/\d+/, Num + rule %r/[^#\s;{}$\\]+/, Text + mixin :base + end + + state :base do + rule %r/\s+/, Text + rule %r/#.*/, Comment::Single + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/stan.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/stan.rb new file mode 100644 index 0000000..8208aee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/stan.rb @@ -0,0 +1,451 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Stan < RegexLexer + title "Stan" + desc 'Stan Modeling Language (mc-stan.org)' + tag 'stan' + filenames '*.stan', '*.stanfunctions' + + # optional comment or whitespace + WS = %r((?:\s|//.*?\n|/[*].*?[*]/)+) + ID = /[a-zA-Z_][a-zA-Z0-9_]*/ + RT = /(?:(?:[a-z_]\s*(?:\[[0-9, ]\])?)\s+)*/ + OP = Regexp.new([ + # Assigment operators + "=", + + # Comparison operators + "<", "<=", ">", ">=", "==", "!=", + + # Boolean operators + "!", "&&", "\\|\\|", + + # Real-valued arithmetic operators + "\\+", "-", "\\*", "/", "\\^", + + # Transposition operator + "'", + + # Elementwise functions + "\\.\\+", "\\.-", "\\.\\*", "\\./", "\\.\\^", + + # Matrix division operators + "\\\\", + + # Compound assigment operators + "\\+=", "-=", "\\*=", "/=", "\\.\\*=", "\\./=", + + # Sampling + "~", + + # Conditional operator + "\\?", ":" + ].join("|")) + + def self.keywords + @keywords ||= Set.new %w( + if else while for break continue print reject return + ) + end + + def self.types + @types ||= Set.new %w( + int real vector ordered positive_ordered simplex unit_vector + row_vector matrix cholesky_factor_corr cholesky_factor_cov corr_matrix + cov_matrix data void complex array + ) + end + + def self.reserved + @reserved ||= Set.new [ + # Reserved words from Stan language + "for", "in", "while", "repeat", "until", "if", "then", "else", "true", + "false", "target", "functions", "model", "data", "parameters", + "quantities", "transformed", "generated", + + # Reserved names from Stan implementation + "var", "fvar", "STAN_MAJOR", "STAN_MINOR", "STAN_PATCH", + "STAN_MATH_MAJOR", "STAN_MATH_MINOR", "STAN_MATH_PATCH", + + # Reserved names from C++ + "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", + "bitor", "bool", "break", "case", "catch", "char", "char16_t", + "char32_t", "class", "compl", "const", "constexpr", "const_cast", + "continue", "decltype", "default", "delete", "do", "double", + "dynamic_cast", "else", "enum", "explicit", "export", "extern", + "false", "float", "for", "friend", "goto", "if", "inline", "int", + "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq", + "nullptr", "operator", "or", "or_eq", "private", "protected", + "public", "register", "reinterpret_cast", "return", "short", "signed", + "sizeof", "static", "static_assert", "static_cast", "struct", + "switch", "template", "this", "thread_local", "throw", "true", "try", + "typedef", "typeid", "typename", "union", "unsigned", "using", + "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" + ] + end + + def self.builtin_functions + @builtin_functions ||= Set.new [ + # Integer-Valued Basic Functions + + ## Absolute functions + "abs", "int_step", + + ## Bound functions + "min", "max", + + ## Size functions + "size", + + # Real-Valued Basic Functions + + ## Log probability function + "target", "get_lp", + + ## Logical functions + "step", "is_inf", "is_nan", + + ## Step-like functions + "fabs", "fdim", "fmin", "fmax", "fmod", "floor", "ceil", "round", + "trunc", + + ## Power and logarithm functions + "sqrt", "cbrt", "square", "exp", "exp2", "log", "log2", "log10", + "pow", "inv", "inv_sqrt", "inv_square", + + ## Trigonometric functions + "hypot", "cos", "sin", "tan", "acos", "asin", "atan", "atan2", + + ## Hyperbolic trigonometric functions + "cosh", "sinh", "tanh", "acosh", "asinh", "atanh", + + ## Link functions + "logit", "inv_logit", "inv_cloglog", + + ## Probability-related functions + "erf", "erfc", "Phi", "inv_Phi", "Phi_approx", "binary_log_loss", + "owens_t", + + ## Combinatorial functions + "beta", "inc_beta", "lbeta", "tgamma", "lgamma", "digamma", + "trigamma", "lmgamma", "gamma_p", "gamma_q", + "binomial_coefficient_log", "choose", "bessel_first_kind", + "bessel_second_kind", "modified_bessel_first_kind", + "log_modified_bessel_first_kind", "modified_bessel_second_kind", + "falling_factorial", "lchoose", "log_falling_factorial", + "rising_factorial", "log_rising_factorial", + + ## Composed functions + "expm1", "fma", "multiply_log", "ldexp", "lmultiply", "log1p", + "log1m", "log1p_exp", "log1m_exp", "log_diff_exp", "log_mix", + "log_sum_exp", "log_inv_logit", "log_inv_logit_diff", + "log1m_inv_logit", + + ## Special functions + "lambert_w0", "lambert_wm1", + + # Complex-Valued Basic Functions + + ## Complex constructors and accessors + "to_complex", "get_real", "get_imag", + + ## Complex special functions + "arg", "norm", "conj", "proj", "polar", + + # Array Operations + + ## Reductions + "sum", "prod", "log_sum_exp", "mean", "variance", "sd", "distance", + "squared_distance", "quantile", + + ## Array size and dimension function + "dims", "num_elements", + + ## Array broadcasting + "rep_array", + + ## Array concatenation + "append_array", + + ## Sorting functions + "sort_asc", "sort_desc", "sort_indices_asc", "sort_indices_desc", + "rank", + + ## Reversing functions + "reverse", + + # Matrix Operations + + ## Integer-valued matrix size functions + "num_elements", "rows", "cols", + + ## Dot products and specialized products + "dot_product", "columns_dot_product", "rows_dot_product", "dot_self", + "columns_dot_self", "rows_dot_self", "tcrossprod", "crossprod", + "quad_form", "quad_form_diag", "quad_form_sym", "trace_quad_form", + "trace_gen_quad_form", "multiply_lower_tri_self_transpose", + "diag_pre_multiply", "diag_post_multiply", + + ## Broadcast functions + "rep_vector", "rep_row_vector", "rep_matrix", + "symmetrize_from_lower_tri", + + ## Diagonal matrix functions + "add_diag", "diagonal", "diag_matrix", "identity_matrix", + + ## Container construction functions + "linspaced_array", "linspaced_int_array", "linspaced_vector", + "linspaced_row_vector", "one_hot_int_array", "one_hot_array", + "one_hot_vector", "one_hot_row_vector", "ones_int_array", + "ones_array", "ones_vector", "ones_row_vector", "zeros_int_array", + "zeros_array", "zeros_vector", "zeros_row_vector", "uniform_simplex", + + ## Slicing and blocking functions + "col", "row", "block", "sub_col", "sub_row", "head", "tail", + "segment", + + ## Matrix concatenation + "append_col", "append_row", + + ## Special matrix functions + "softmax", "log_softmax", "cumulative_sum", + + ## Covariance functions + "cov_exp_quad", + + ## Linear algebra functions and solvers + "mdivide_left_tri_low", "mdivide_right_tri_low", "mdivide_left_spd", + "mdivide_right_spd", "matrix_exp", "matrix_exp_multiply", + "scale_matrix_exp_multiply", "matrix_power", "trace", "determinant", + "log_determinant", "inverse", "inverse_spd", "chol2inv", + "generalized_inverse", "eigenvalues_sym", "eigenvectors_sym", + "qr_thin_Q", "qr_thin_R", "qr_Q", "qr_R", "cholseky_decompose", + "singular_values", "svd_U", "svd_V", + + # Sparse Matrix Operations + + ## Conversion functions + "csr_extract_w", "csr_extract_v", "csr_extract_u", + "csr_to_dense_matrix", + + ## Sparse matrix arithmetic + "csr_matrix_times_vector", + + # Mixed Operations + "to_matrix", "to_vector", "to_row_vector", "to_array_2d", + "to_array_1d", + + # Higher-Order Functions + + ## Algebraic equation solver + "algebra_solver", "algebra_solver_newton", + + ## Ordinary differential equation + "ode_rk45", "ode_rk45_tol", "ode_ckrk", "ode_ckrk_tol", "ode_adams", + "ode_adams_tol", "ode_bdf", "ode_bdf_tol", "ode_adjoint_tol_ctl", + + ## 1D integrator + "integrate_1d", + + ## Reduce-sum function + "reduce_sum", "reduce_sum_static", + + ## Map-rect function + "map_rect", + + # Deprecated Functions + "integrate_ode_rk45", "integrate_ode", "integrate_ode_adams", + "integrate_ode_bdf", + + # Hidden Markov Models + "hmm_marginal", "hmm_latent_rng", "hmm_hidden_state_prob" + ] + end + + def self.distributions + @distributions ||= Set.new( + [ + # Discrete Distributions + + ## Binary Distributions + "bernoulli", "bernoulli_logit", "bernoulli_logit_glm", + + ## Bounded Discrete Distributions + "binomial", "binomial_logit", "beta_binomial", "hypergeometric", + "categorical", "categorical_logit_glm", "discrete_range", + "ordered_logistic", "ordered_logistic_glm", "ordered_probit", + + ## Unbounded Discrete Distributions + "neg_binomial", "neg_binomial_2", "neg_binomial_2_log", + "neg_binomial_2_log_glm", "poisson", "poisson_log", + "poisson_log_glm", + + ## Multivariate Discrete Distributions + "multinomial", "multinomial_logit", + + # Continuous Distributions + + ## Unbounded Continuous Distributions + "normal", "std_normal", "normal_id_glm", "exp_mod_normal", + "skew_normal", "student_t", "cauchy", "double_exponential", + "logistic", "gumbel", "skew_double_exponential", + + ## Positive Continuous Distributions + "lognormal", "chi_square", "inv_chi_square", + "scaled_inv_chi_square", "exponential", "gamma", "inv_gamma", + "weibull", "frechet", "rayleigh", + + ## Positive Lower-Bounded Distributions + "pareto", "pareto_type_2", "wiener", + + ## Continuous Distributions on [0, 1] + "beta", "beta_proportion", + + ## Circular Distributions + "von_mises", + + ## Bounded Continuous Distributions + "uniform", + + ## Distributions over Unbounded Vectors + "multi_normal", "multi_normal_prec", "multi_normal_cholesky", + "multi_gp", "multi_gp_cholesky", "multi_student_t", + "gaussian_dlm_obs", + + ## Simplex Distributions + "dirichlet", + + ## Correlation Matrix Distributions + "lkj_corr", "lkj_corr_cholesky", + + ## Covariance Matrix Distributions + "wishart", "inv_wishart" + ].product([ + "", "_lpmf", "_lupmf", "_lpdf", "_lcdf", "_lccdf", "_rng", "_log", + "_cdf_log", "_ccdf_log" + ]).map {|s| "#{s[0]}#{s[1]}"} + ) + end + + def self.constants + @constants ||= Set.new [ + # Mathematical constants + "pi", "e", "sqrt2", "log2", "log10", + + # Special values + "not_a_number", "positive_infinity", "negative_infinity", + "machine_precision" + ] + end + + state :root do + mixin :whitespace + rule %r/#include/, Comment::Preproc, :include + rule %r/#.*$/, Generic::Deleted + rule %r( + functions + |(?:transformed\s+)?data + |(?:transformed\s+)?parameters + |model + |generated\s+quantities + )x, Name::Namespace + rule %r(\{), Punctuation, :bracket_scope + mixin :scope + end + + state :include do + rule %r((\s+)(\S+)(\s*)) do |m| + token Text, m[1] + token Comment::PreprocFile, m[2] + token Text, m[3] + pop! + end + end + + state :whitespace do + rule %r(\n+)m, Text + rule %r(//(\\.|.)*?$), Comment::Single + mixin :inline_whitespace + end + + state :inline_whitespace do + rule %r([ \t\r]+), Text + rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline + end + + state :statements do + mixin :whitespace + rule %r/#include/, Comment::Preproc, :include + rule %r/#.*$/, Generic::Deleted + rule %r("), Str, :string + rule %r( + ( + ((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+|\d+) + (#{WS})[+-](#{WS}) + ((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+|\d+)i + ) + |((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+|\d+)i + |((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+) + )mx, Num::Float + rule %r/\d+/, Num::Integer + rule %r(\*/), Error + rule OP, Operator + rule %r([\[\],.;]), Punctuation + rule %r([|](?![|])), Punctuation + rule %r(T\b), Keyword::Reserved + rule %r((lower|upper)\b), Name::Attribute + rule ID do |m| + name = m[0] + + if self.class.keywords.include? name + token Keyword + elsif self.class.types.include? name + token Keyword::Type + elsif self.class.reserved.include? name + token Keyword::Reserved + else + token Name::Variable + end + end + end + + state :scope do + mixin :whitespace + rule %r( + (#{RT}) # Return type + (#{ID}) # Function name + (?=\([^;]*?\)) # Signature or arguments + )mx do |m| + recurse m[1] + + name = m[2] + if self.class.builtin_functions.include? name + token Name::Builtin, name + elsif self.class.distributions.include? name + token Name::Builtin, name + elsif self.class.constants.include? name + token Keyword::Constant + else + token Name::Function, name + end + end + rule %r(\{), Punctuation, :bracket_scope + rule %r(\(), Punctuation, :parens_scope + mixin :statements + end + + state :bracket_scope do + mixin :scope + rule %r(\}), Punctuation, :pop! + end + + state :parens_scope do + mixin :scope + rule %r(\)), Punctuation, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/stata.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/stata.rb new file mode 100644 index 0000000..d002316 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/stata.rb @@ -0,0 +1,165 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Stata < RegexLexer + title "Stata" + desc "The Stata programming language (www.stata.com)" + tag 'stata' + filenames '*.do', '*.ado' + mimetypes 'application/x-stata', 'text/x-stata' + + ### + # Stata reference manual is available online at: https://www.stata.com/features/documentation/ + ### + + # Partial list of common programming and estimation commands, as of Stata 16 + # Note: not all abbreviations are included + KEYWORDS = %w( + do run include clear assert set mata log + by bys bysort cap capt capture char class classutil which cdir confirm new existence creturn + _datasignature discard di dis disp displ displa display ereturn error _estimates exit file open read write seek close query findfile fvexpand + gettoken java home heapmax java_heapmax icd9 icd9p icd10 icd10cm icd10pcs initialize javacall levelsof + tempvar tempname tempfile macro shift uniq dups retokenize clean sizeof posof + makecns matcproc marksample mark markout markin svymarkout matlist + accum define dissimilarity eigenvalues get rowjoinbyname rownames score svd symeigen dir list ren rename + more pause plugin call postfile _predict preserve restore program define drop end python qui quietly noi noisily _return return _rmcoll rmsg _robust + serset locale_functions locale_ui signestimationsample checkestimationsample sleep syntax sysdir adopath adosize + tabdisp timer tokenize trace unab unabcmd varabbrev version viewsource + window fopen fsave manage menu push stopbox + net from cd link search install sj stb ado update uninstall pwd ssc ls + using insheet outsheet mkmat svmat sum summ summarize + graph gr_edit twoway histogram kdensity spikeplot + mi miss missing var varname order compress append + gen gene gener genera generat generate egen replace duplicates + estimates nlcom lincom test testnl predict suest + _regress reg regr regre regres regress probit logit ivregress logistic svy gmm ivprobit ivtobit + bsample assert codebook collapse compare contract copy count cross datasignature d ds desc describe destring tostring + drawnorm edit encode decode erase expand export filefilter fillin format frame frget frlink gsort + import dbase delimited excel fred haver sas sasxport5 sasxport8 spss infile infix input insobs inspect ipolate isid + joinby label language labelbook lookfor memory mem merge mkdir mvencode notes obs odbc order outfile + pctile xtile _pctile putmata range recast recode rename group reshape rm rmdir sample save saveold separate shell snapshot sort split splitsample stack statsby sysuse + type unicode use varmanage vl webuse xpose zipfile + number keep tab table tabulate stset stcox tsset xtset + ) + + # Complete list of functions by name, as of Stata 16 + PRIMITIVE_FUNCTIONS = %w( + abbrev abs acos acosh age age_frac asin asinh atan atan2 atanh autocode + betaden binomial binomialp binomialtail binormal birthday bofd byteorder + c _caller cauchy cauchyden cauchytail Cdhms ceil char chi2 chi2den chi2tail Chms + chop cholesky clip Clock clock clockdiff cloglog Cmdyhms Cofc cofC Cofd cofd coleqnumb + collatorlocale collatorversion colnfreeparms colnumb colsof comb cond corr cos cosh + daily date datediff datediff_frac day det dgammapda dgammapdada dgammapdadx dgammapdxdx dhms + diag diag0cnt digamma dofb dofC dofc dofh dofm dofq dofw dofy dow doy dunnettprob e el epsdouble + epsfloat exp expm1 exponential exponentialden exponentialtail + F Fden fileexists fileread filereaderror filewrite float floor fmtwidth frval _frval Ftail + fammaden gammap gammaptail get hadamard halfyear halfyearly has_eprop hh hhC hms hofd hours + hypergeometric hypergeometricp + I ibeta ibetatail igaussian igaussianden igaussiantail indexnot inlist inrange int inv invbinomial invbinomialtail + invcauchy invcauchytail invchi2 invchi2tail invcloglog invdunnettprob invexponential invexponentialtail invF + invFtail invgammap invgammaptail invibeta invibetatail invigaussian invigaussiantail invlaplace invlaplacetail + invlogistic invlogistictail invlogit invnbinomial invnbinomialtail invnchi2 invnchi2tail invnF invnFtail invnibeta invnormal invnt invnttail + invpoisson invpoissontail invsym invt invttail invtukeyprob invweibull invweibullph invweibullphtail invweibulltail irecode islepyear issymmetric + J laplace laplaceden laplacetail ln ln1m ln1p lncauchyden lnfactorial lngamma lnigammaden lnigaussianden lniwishartden lnlaplaceden lnmvnormalden + lnnormal lnnormalden lnnormalden lnnormalden lnwishartden log log10 log1m log1p logistic logisticden logistictail logit + matmissing matrix matuniform max maxbyte maxdouble maxfloat maxint maxlong mdy mdyhms mi min minbyte mindouble minfloat minint minlong minutes + missing mm mmC mod mofd month monthly mreldif msofhours msofminutes msofseconds + nbetaden nbinomial nbinomialp nbinomialtail nchi2 nchi2den nchi2tail nextbirthday nextleapyear nF nFden nFtail nibeta + normal normalden npnchi2 npnF npnt nt ntden nttail nullmat + plural poisson poissonp poissontail previousbirthday previousleapyear qofd quarter quarterly r rbeta rbinomial rcauchy rchi2 recode + real regexm regexr regexs reldif replay return rexponential rgamma rhypergeometric rigaussian rlaplace rlogistic rnormal + round roweqnumb rownfreeparms rownumb rowsof rpoisson rt runiform runiformint rweibull rweibullph + s scalar seconds sign sin sinh smallestdouble soundex soundex_nara sqrt ss ssC strcat strdup string stritrim strlen strlower + strltrim strmatch strofreal strpos strproper strreverse strrpos strrtrim strtoname strtrim strupper subinstr subinword substr sum sweep + t tan tanh tC tc td tden th tin tm tobytes tq trace trigamma trunc ttail tukeyprob tw twithin + uchar udstrlen udsubstr uisdigit uisletter uniform ustrcompare ustrcompareex ustrfix ustrfrom ustrinvalidcnt ustrleft ustrlen ustrlower + ustrltrim ustrnormalize ustrpos ustrregexm ustrregexra ustrregexrf ustrregexs ustrreverse ustrright ustrrpos ustrrtrim ustrsortkey + ustrsortkeyex ustrtitle ustrto ustrtohex ustrtoname ustrtrim ustrunescape ustrupper ustrword ustrwordcount usubinstr usubstr + vec vecdiag week weekly weibull weibullden weibullph weibullphden weibullphtail weibulltail wofd word wordbreaklocale wordcount + year yearly yh ym yofd yq yw + ) + + # Note: types `str1-str2045` handled separately below + def self.type_keywords + @type_keywords ||= Set.new %w(byte int long float double str strL numeric string integer scalar matrix local global numlist varlist newlist) + end + + # Stata commands used with braces. Includes all valid abbreviations for 'forvalues'. + def self.reserved_keywords + @reserved_keywords ||= Set.new %w(if else foreach forv forva forval forvalu forvalue forvalues to while in of continue break nobreak) + end + + ### + # Lexer state and rules + ### + state :root do + + # Pre-processor commands: # + rule %r/^\s*#.*$/, Comment::Preproc + + # Hashbang comments: *! + rule %r/^\*!.*$/, Comment::Hashbang + + # Single-line comment: * + rule %r/^\s*\*.*$/, Comment::Single + + # Keywords: recognize only when they are the first word + rule %r/^\s*(#{KEYWORDS.join('|')})\b/, Keyword + + # Whitespace. Classify `\n` as `Text` to avoid interference with `Comment` and `Keyword` above + rule(/[ \t]+/, Text::Whitespace) + rule(/[\n\r]+/, Text) + + # In-line comment: // + rule %r/\/\/.*?$/, Comment::Single + + # Multi-line comment: /* and */ + rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline + + # Strings indicated by compound double-quotes (`""') and double-quotes ("") + rule %r/`"(\\.|.)*?"'/, Str::Double + rule %r/"(\\.|.)*?"/, Str::Double + + # Format locals (`') and globals ($) as strings + rule %r/`(\\.|.)*?'/, Str::Double + rule %r/(??*+'^/\\!#.=~:&|]), Operator + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/supercollider.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/supercollider.rb new file mode 100644 index 0000000..b2831a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/supercollider.rb @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SuperCollider < RegexLexer + tag 'supercollider' + filenames '*.sc', '*.scd' + + title "SuperCollider" + desc 'A cross-platform interpreted programming language for sound synthesis, algorithmic composition, and realtime performance' + + def self.keywords + @keywords ||= Set.new %w( + var arg classvar const super this + ) + end + + # these aren't technically keywords, but we treat + # them as such because it makes things clearer 99% + # of the time + def self.reserved + @reserved ||= Set.new %w( + case do for forBy loop if while new newCopyArgs + ) + end + + def self.constants + @constants ||= Set.new %w( + true false nil inf thisThread + thisMethod thisFunction thisProcess + thisFunctionDef currentEnvironment + topEnvironment + ) + end + + state :whitespace do + rule %r/\s+/m, Text + end + + state :comments do + rule %r(//.*?$), Comment::Single + rule %r(/[*]) do + token Comment::Multiline + push :nested_comment + end + end + + state :nested_comment do + rule %r(/[*]), Comment::Multiline, :nested_comment + rule %r([*]/), Comment::Multiline, :pop! + rule %r([^*/]+)m, Comment::Multiline + rule %r/./, Comment::Multiline + end + + state :root do + mixin :whitespace + mixin :comments + + rule %r/[\-+]?0[xX]\h+/, Num::Hex + + # radix float + rule %r/[\-+]?\d+r[0-9a-zA-Z]*(\.[0-9A-Z]*)?/, Num::Float + + # normal float + rule %r/[\-+]?((\d+(\.\d+)?([eE][\-+]?\d+)?(pi)?)|pi)/, Num::Float + + rule %r/[\-+]?\d+/, Num::Integer + + rule %r/\$(\\.|.)/, Str::Char + + rule %r/"([^\\"]|\\.)*"/, Str + + # symbols (single-quote notation) + rule %r/'([^\\']|\\.)*'/, Str::Other + + # symbols (backslash notation) + rule %r/\\\w+/, Str::Other + + # symbol arg + rule %r/[A-Za-z_]\w*:/, Name::Label + + rule %r/[A-Z]\w*/, Name::Class + + # primitive + rule %r/_\w+/, Name::Function + + # main identifiers section + rule %r/[a-z]\w*/ do |m| + if self.class.keywords.include? m[0] + token Keyword + elsif self.class.constants.include? m[0] + token Keyword::Constant + elsif self.class.reserved.include? m[0] + token Keyword::Reserved + else + token Name + end + end + + # environment variables + rule %r/~\w+/, Name::Variable::Global + + rule %r/[\{\}()\[\];,\.]/, Punctuation + + # operators. treat # (array unpack) as an operator + rule %r/[\+\-\*\/&\|%<>=]+/, Operator + rule %r/[\^:#]/, Operator + + # treat curry argument as a special operator + rule %r/\b_\b/, Name::Builtin + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/svelte.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/svelte.rb new file mode 100644 index 0000000..b258e52 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/svelte.rb @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'html.rb' + + class Svelte < HTML + desc 'Svelte single-file components (https://svelte.dev/)' + tag 'svelte' + filenames '*.svelte' + mimetypes 'text/x-svelte', 'application/x-svelte' + + def initialize(*) + super + # todo add support for typescript script blocks + @js = Javascript.new(options) + end + + # Shorthand syntax for passing attributes - ex, `{src}` instead of `src={src}` + prepend :tag do + rule %r/(\{)\s*([a-zA-Z0-9_]+)\s*(})/m do + groups Str::Interpol, Name::Variable, Str::Interpol + pop! + end + end + + prepend :attr do + # Duplicate template_start mixin here with a pop! + # Because otherwise we'll never exit the attr state + rule %r/\{/ do + token Str::Interpol + pop! + push :template + end + end + + # handle templates within attribute single/double quotes + prepend :dq do + mixin :template_start + end + + prepend :sq do + mixin :template_start + end + + prepend :root do + # detect curly braces within HTML text (outside of tags/attributes) + rule %r/([^<&{]*)(\{)(\s*)/ do + groups Text, Str::Interpol, Text + push :template + end + end + + state :template_start do + # open template + rule %r/\s*\{\s*/, Str::Interpol, :template + end + + state :template do + # template end + rule %r/}/, Str::Interpol, :pop! + + # Allow JS lexer to handle matched curly braces within template + rule(/(?<=^|[^\\])\{.*?(?<=^|[^\\])\}/) do + delegate @js + end + + # keywords + rule %r/@(debug|html)\b/, Keyword + rule %r/(#await)(.*)(then|catch)(\s+)(\w+)/ do |m| + token Keyword, m[1] + delegate @js, m[2] + token Keyword, m[3] + token Text, m[4] + delegate @js, m[5] + end + rule %r/([#\/])(await|each|if|key)\b/, Keyword + rule %r/(:else)(\s+)(if)?\b/ do + groups Keyword, Text, Keyword + end + rule %r/:?(catch|then)\b/, Keyword + + # allow JS parser to handle anything that's not a curly brace + rule %r/[^{}]+/ do + delegate @js + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/swift.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/swift.rb new file mode 100644 index 0000000..96b85c1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/swift.rb @@ -0,0 +1,202 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Swift < RegexLexer + tag 'swift' + filenames '*.swift' + + title "Swift" + desc 'Multi paradigm, compiled programming language developed by Apple for iOS and OS X development. (developer.apple.com/swift)' + + id_head = /_|(?!\p{Mc})\p{Alpha}|[^\u0000-\uFFFF]/ + id_rest = /[\p{Alnum}_]|[^\u0000-\uFFFF]/ + id = /#{id_head}#{id_rest}*/ + + keywords = Set.new %w( + autoreleasepool await break case catch consume continue default defer discard do each else fallthrough guard if in for repeat return switch throw try where while + + as dynamicType is new super self Self Type + + associativity async didSet get infix inout isolated left mutating none nonmutating operator override postfix precedence precedencegroup prefix rethrows right set throws unowned weak willSet + ) + + declarations = Set.new %w( + actor any associatedtype borrowing class consuming deinit distributed dynamic enum convenience extension fileprivate final func import indirect init internal lazy let macro nonisolated open optional package private protocol public required some static struct subscript typealias var + ) + + constants = Set.new %w( + true false nil + ) + + start do + push :bol + @re_delim = "" # multi-line regex delimiter + end + + # beginning of line + state :bol do + rule %r/#(?![#"\/]).*/, Comment::Preproc + + mixin :inline_whitespace + + rule(//) { pop! } + end + + state :inline_whitespace do + rule %r/\s+/m, Text + mixin :has_comments + end + + state :whitespace do + rule %r/\n+/m, Text, :bol + rule %r(\/\/.*?$), Comment::Single, :bol + mixin :inline_whitespace + end + + state :has_comments do + rule %r(/[*]), Comment::Multiline, :nested_comment + end + + state :nested_comment do + mixin :has_comments + rule %r([*]/), Comment::Multiline, :pop! + rule %r([^*/]+)m, Comment::Multiline + rule %r/./, Comment::Multiline + end + + state :root do + mixin :whitespace + + rule %r/\$(([1-9]\d*)?\d)/, Name::Variable + rule %r/\$#{id}/, Name + rule %r/~Copyable\b/, Keyword::Type + + rule %r{[()\[\]{}:;,?\\]}, Punctuation + rule %r{(#*)/(?!\s).*(?!&|^.~]+), Operator + rule %r/@?"/, Str, :dq + rule %r/'(\\.|.)'/, Str::Char + rule %r/(\d+(?:_\d+)*\*|(?:\d+(?:_\d+)*)*\.\d+(?:_\d)*)(e[+-]?\d+(?:_\d)*)?/i, Num::Float + rule %r/\d+e[+-]?[0-9]+/i, Num::Float + rule %r/0o?[0-7]+(?:_[0-7]+)*/, Num::Oct + rule %r/0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*((\.[0-9A-F]+(?:_[0-9A-F]+)*)?p[+-]?\d+)?/, Num::Hex + rule %r/0b[01]+(?:_[01]+)*/, Num::Bin + rule %r{[\d]+(?:_\d+)*}, Num::Integer + + rule %r/@#{id}/, Keyword::Declaration + rule %r/##{id}/, Keyword + + rule %r/(private|internal)(\([ ]*)(\w+)([ ]*\))/ do |m| + if m[3] == 'set' + token Keyword::Declaration + else + groups Keyword::Declaration, Keyword::Declaration, Error, Keyword::Declaration + end + end + + rule %r/(unowned\([ ]*)(\w+)([ ]*\))/ do |m| + if m[2] == 'safe' || m[2] == 'unsafe' + token Keyword::Declaration + else + groups Keyword::Declaration, Error, Keyword::Declaration + end + end + + rule %r/(let|var)\b(\s*)(#{id})/ do + groups Keyword, Text, Name::Variable + end + + rule %r/(let|var)\b(\s*)([(])/ do + groups Keyword, Text, Punctuation + push :tuple + end + + rule %r/(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[(])/ do |m| + if m[0] =~ /^[[:upper:]]/ + token Keyword::Type + else + token Name::Function + end + end + + rule %r/as[?!]?(?=\s)/, Keyword + rule %r/try[!]?(?=\s)/, Keyword + + rule %r/(#?(?!default)(?![[:upper:]])#{id})(\s*)(:)/ do + groups Name::Variable, Text, Punctuation + end + + rule id do |m| + if keywords.include? m[0] + token Keyword + elsif declarations.include? m[0] + token Keyword::Declaration + elsif constants.include? m[0] + token Keyword::Constant + elsif m[0] =~ /^[[:upper:]]/ + token Keyword::Type + else + token Name + end + end + + rule %r/(`)(#{id})(`)/ do + groups Punctuation, Name::Variable, Punctuation + end + + rule %r{(#+)/\n} do |m| + @re_delim = m[1] + token Str::Regex + push :re_multi + end + end + + state :tuple do + rule %r/(#{id})/, Name::Variable + rule %r/(`)(#{id})(`)/ do + groups Punctuation, Name::Variable, Punctuation + end + rule %r/,/, Punctuation + rule %r/[(]/, Punctuation, :push + rule %r/[)]/, Punctuation, :pop! + mixin :inline_whitespace + end + + state :dq do + rule %r/\\[\\0tnr'"]/, Str::Escape + rule %r/\\[(]/, Str::Escape, :interp + rule %r/\\u\{\h{1,8}\}/, Str::Escape + rule %r/[^\\"]+/, Str + rule %r/"""/, Str, :pop! + rule %r/"/, Str, :pop! + end + + state :interp do + rule %r/[(]/, Punctuation, :interp_inner + rule %r/[)]/, Str::Escape, :pop! + mixin :root + end + + state :interp_inner do + rule %r/[(]/, Punctuation, :push + rule %r/[)]/, Punctuation, :pop! + mixin :root + end + + state :re_multi do + rule %r{^\s*/#+} do |m| + token Str::Regex + if m[0].end_with?("/#{@re_delim}") + @re_delim = "" + pop! + end + end + + rule %r/#.*/, Comment::Single + rule %r/./m, Str::Regex + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/systemd.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/systemd.rb new file mode 100644 index 0000000..b414abf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/systemd.rb @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class SystemD < RegexLexer + tag 'systemd' + aliases 'unit-file' + filenames '*.service' + mimetypes 'text/x-systemd-unit' + desc 'A lexer for systemd unit files' + + state :root do + rule %r/\s+/, Text + rule %r/[;#].*/, Comment + rule %r/\[.*?\]$/, Keyword + rule %r/(.*?)(=)(.*)(\\\n)/ do + groups Name::Tag, Punctuation, Text, Str::Escape + push :continuation + end + rule %r/(.*?)(=)(.*)/ do + groups Name::Tag, Punctuation, Text + end + end + + state :continuation do + rule %r/(.*?)(\\\n)/ do + groups Text, Str::Escape + end + rule %r/(.*)'?/, Text, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/syzlang.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/syzlang.rb new file mode 100644 index 0000000..dbaea03 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/syzlang.rb @@ -0,0 +1,316 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Syzlang < RegexLexer + title "Syzlang" + desc "Syscall description language used by syzkaller" + tag 'syzlang' + + def self.keywords + @keywords ||= Set.new %w( + align breaks_returns dec define disabled hex ignore_return in incdir + include inet inout oct opt out packed parent prog_timeout pseudo + resource size syscall timeout type varlen + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + array bitsize bool16 bool32 bool64 bool8 boolptr buffer bytesize + bytesize2 bytesize4 bytesize8 const csum filename fileoff flags fmt + int16 int16be int32 int32be int64 int64be int8 int8be intptr len + offsetof optional proc ptr ptr64 string stringnoz text vma vma64 void + ) + end + + comment = /#.*$/ + inline_spaces = /[ \t]+/ + spaces = /\s+/ + + state :inline_break do + rule inline_spaces, Text + rule %r//, Text, :pop! + end + + state :space_break do + rule spaces, Text + rule comment, Comment + rule %r//, Text, :pop! + end + + id = /[a-zA-Z_][a-zA-Z0-9_]*/ + num_id = /[a-zA-Z0-9_]+/ + + state :mixin_name do + rule id, Name + end + + state :mixin_number do + rule %r/-?0x[\da-f]+/i, Num::Hex + rule %r/-?\d+/, Num::Integer + rule %r/'[^']?'/, Str::Char + end + + state :mixin_string do + rule %r/"[^"]*"/, Str::Double + rule %r/`[^`]*`/, Str::Backtick + end + + state :mixin_term do + mixin :mixin_number + mixin :mixin_string + + # Keywords. + rule id do |m| + if self.class.keywords.include?(m[0]) + token Keyword + elsif self.class.keywords_type.include?(m[0]) + token Keyword::Type + else + token Name + end + end + + # Ranges. + rule %r/:/, Punctuation + + # "struct$type" struct name format. + rule %r/\$/, Name + end + + state :term_list do + rule spaces, Text + rule comment, Comment + mixin :mixin_term + rule %r/\[/, Punctuation, :term_list + rule %r/,/, Punctuation + rule %r/[\]\)]/, Punctuation, :pop! + end + + state :arg_type do + mixin :mixin_term + rule %r/\[/, Punctuation, :term_list + rule %r//, Text, :pop! + end + + state :include do + rule %r/(<)([^>]+)(>)/ do |m| + groups Punctuation, Str, Punctuation + end + rule %r//, Text, :pop! + end + + state :define_name do + mixin :mixin_name + rule %r//, Text, :pop! + end + + state :define_exp do + mixin :mixin_name + mixin :mixin_number + mixin :mixin_string + rule %r/[~!%\^&\*\-\+\/\|<>\?:]/, Operator + rule %r/[\(\){}\[\];,]/, Punctuation + rule inline_spaces, Text + rule %r//, Text, :pop! + end + + state :resource_name do + mixin :mixin_name + rule %r//, Text, :pop! + end + + state :resource_type do + rule %r/\[/, Punctuation, :arg_type + rule %r/\]/, Punctuation, :pop! + end + + state :resource_values do + rule %r/:/ do + token Punctuation + push :resource_values_list + push :space_break + end + rule %r//, Text, :pop! + end + + state :resource_values_list do + rule inline_spaces, Text + mixin :mixin_name + mixin :mixin_number + mixin :mixin_string + rule %r/,/, Punctuation, :space_break + rule %r//, Text, :pop! + end + + state :flags_list do + rule inline_spaces, Text + rule %r/\./, Punctuation + mixin :mixin_name + mixin :mixin_number + mixin :mixin_string + rule %r/,/, Punctuation, :space_break + rule %r//, Punctuation, :pop! + end + + state :syscall_args do + rule spaces, Text + rule comment, Comment + rule %r/\./, Punctuation + rule id do + token Name + push :arg_type + push :space_break + end + rule %r/,/, Punctuation + rule %r/\)/, Punctuation, :pop! + end + + state :syscall_retval do + mixin :mixin_name + rule %r//, Text, :pop! + end + + state :syscall_mods do + rule %r/\(/, Punctuation, :term_list + rule %r//, Text, :pop! + end + + state :struct_fields do + rule id do + token Name + push :space_break + push :struct_field_mods + push :inline_break + push :arg_type + push :space_break + end + rule %r/[}\]]/, Punctuation, :pop! + end + + state :struct_field_mods do + rule %r/\(/, Punctuation, :term_list + rule %r//, Text, :pop! + end + + state :struct_mods do + rule %r/\[/, Punctuation, :term_list + rule %r//, Text, :pop! + end + + state :type_name do + mixin :mixin_name + rule %r//, Text, :pop! + end + + state :type_args do + rule %r/\[/, Punctuation, :type_args_list + rule %r//, Text, :pop! + end + + state :type_args_list do + rule spaces, Text + rule comment, Comment + mixin :mixin_name + rule %r/,/, Punctuation + rule %r/\]/, Punctuation, :pop! + end + + state :type_body do + rule %r/[{\[]/ do + token Punctuation + pop! + push :space_break + push :struct_mods + push :inline_break + push :struct_fields + push :space_break + end + rule %r// do + pop! + push :arg_type + end + end + + state :root do + # Whitespace. + rule spaces, Text + + # Comments. + rule comment, Comment + + # Includes. + rule %r/(include|incdir)/ do + token Keyword + push :include + push :space_break + end + + # Defines. + rule %r/define/ do + token Keyword + push :define_exp + push :space_break + push :define_name + push :space_break + end + + # Resources. + rule %r/resource/ do + token Keyword + push :resource_values + push :inline_break + push :resource_type + push :inline_break + push :resource_name + push :space_break + end + + # Flags and strings. + rule %r/(#{id}|_)(#{spaces})(=)/ do |m| + if m[1] == "_" + groups Keyword, Text, Punctuation + else + groups Name, Text, Punctuation + end + push :flags_list + push :space_break + end + + # Syscalls. + rule %r/(#{id})(\$)?(#{num_id})?(#{spaces})?(\()/ do |m| + groups Name::Function, Punctuation, Name::Function::Magic, Text, Punctuation + push :syscall_mods + push :inline_break + push :syscall_retval + push :inline_break + push :syscall_args + push :space_break + end + + # Structs and unions. + rule %r/(#{id}|#{id}\$#{num_id})(#{spaces})?([{\[])/ do |m| + groups Name, Text, Punctuation + push :inline_break + push :struct_mods + push :inline_break + push :struct_fields + push :space_break + end + + # Types. + rule %r/type/ do + token Keyword + push :type_body + push :space_break + push :type_args + push :type_name + push :space_break + end + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/syzprog.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/syzprog.rb new file mode 100644 index 0000000..8cbcace --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/syzprog.rb @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Syzprog < RegexLexer + title "Syzprog" + desc "Program description language used by syzkaller" + tag 'syzprog' + + def self.keywords + @keywords ||= Set.new %w( + ANY ANYBLOB ANYPTR ANYPTR64 ANYPTRS ANYRES16 ANYRES32 ANYRES64 + ANYRESDEC ANYRESHEX ANYRESOCT ANYUNION AUTO false nil true void + async fail_nth rerun + ) + end + + comment = /#.*$/ + inline_spaces = /[ \t]+/ + eol_spaces = /[\n\r]+/ + spaces = /\s+/ + + id = /[a-zA-Z_][a-zA-Z0-9_]*/ + num_id = /[a-zA-Z0-9_]+/ + res_id = /r[0-9]+/ + + state :inline_break do + rule inline_spaces, Text + rule %r//, Text, :pop! + end + + state :eol_break do + rule eol_spaces, Text + rule comment, Comment + rule %r//, Text, :pop! + end + + state :space_break do + rule spaces, Text + rule comment, Comment + rule %r//, Text, :pop! + end + + state :mixin_number do + rule %r/-?0x[\da-f]+/i, Num::Hex + rule %r/-?\d+/, Num::Integer + end + + state :mixin_string do + rule %r/"[^"]*"/, Str::Double + rule %r/`[^`]*`/, Str::Backtick + rule %r/'[^']*'/, Str::Single + end + + state :mixin_term do + mixin :mixin_number + mixin :mixin_string + + rule %r/#{res_id}/, Keyword::Pseudo + rule id do |m| + if self.class.keywords.include?(m[0]) + token Keyword + else + token Name + end + end + end + + state :mods_list do + rule spaces, Text + rule comment, Comment + mixin :mixin_term + rule %r/[,:]/, Punctuation + rule %r/\)/, Punctuation, :pop! + end + + state :syscall_mods do + rule %r/\(/, Punctuation, :mods_list + rule %r//, Text, :pop! + end + + state :syscall_args do + rule spaces, Text + rule comment, Comment + mixin :mixin_term + mixin :mixin_number + mixin :mixin_string + # This punctuation is a part of the syntax: + rule %r/[@&=,<>{}\[\]]/, Punctuation + # This punctuation is not, highlight just in case: + rule %r/[!#\$%\^\*\-\+\/\|~:;.\?]/, Punctuation + rule %r/\(/, Punctuation, :syscall_args + rule %r/\)/, Punctuation, :pop! + end + + state :root do + # Whitespace. + rule spaces, Text + + # Comments. + rule comment, Comment + + # Return values. + rule %r/(#{res_id})(#{spaces})(=)/ do + groups Keyword::Pseudo, Text, Punctuation + end + + # Syscalls. + rule %r/(#{id})(\$)?(#{num_id})?(#{spaces})?(\()/ do |m| + groups Name::Function, Punctuation, Name::Function::Magic, Text, Punctuation + push :syscall_mods + push :inline_break + push :syscall_args + push :space_break + end + + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tap.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tap.rb new file mode 100644 index 0000000..5fab7fa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tap.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + class Tap < RegexLexer + title 'TAP' + desc 'Test Anything Protocol' + tag 'tap' + aliases 'tap' + filenames '*.tap' + + mimetypes 'text/x-tap', 'application/x-tap' + + state :root do + # A TAP version may be specified. + rule %r/^TAP version \d+\n/, Name::Namespace + + # Specify a plan with a plan line. + rule %r/^1\.\.\d+/, Keyword::Declaration, :plan + + # A test failure + rule %r/^(not ok)([^\S\n]*)(\d*)/ do + groups Generic::Error, Text, Literal::Number::Integer + push :test + end + + # A test success + rule %r/^(ok)([^\S\n]*)(\d*)/ do + groups Keyword::Reserved, Text, Literal::Number::Integer + push :test + end + + # Diagnostics start with a hash. + rule %r/^#.*\n/, Comment + + # TAP's version of an abort statement. + rule %r/^Bail out!.*\n/, Generic::Error + + # # TAP ignores any unrecognized lines. + rule %r/^.*\n/, Text + end + + state :plan do + # Consume whitespace (but not newline). + rule %r/[^\S\n]+/, Text + + # A plan may have a directive with it. + rule %r/#/, Comment, :directive + + # Or it could just end. + rule %r/\n/, Comment, :pop! + + # Anything else is wrong. + rule %r/.*\n/, Generic::Error, :pop! + end + + state :test do + # Consume whitespace (but not newline). + rule %r/[^\S\n]+/, Text + + # A test may have a directive with it. + rule %r/#/, Comment, :directive + + rule %r/\S+/, Text + + rule %r/\n/, Text, :pop! + end + + state :directive do + # Consume whitespace (but not newline). + rule %r/[^\S\n]+/, Comment + + # Extract todo items. + rule %r/(?i)\bTODO\b/, Comment::Preproc + + # Extract skip items. + rule %r/(?i)\bSKIP\S*/, Comment::Preproc + + rule %r/\S+/, Comment + + rule %r/\n/ do + token Comment + pop! 2 + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tcl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tcl.rb new file mode 100644 index 0000000..1bc6c86 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tcl.rb @@ -0,0 +1,198 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class TCL < RegexLexer + title "Tcl" + desc "The Tool Command Language (tcl.tk)" + tag 'tcl' + filenames '*.tcl' + mimetypes 'text/x-tcl', 'text/x-script.tcl', 'application/x-tcl' + + def self.detect?(text) + return true if text.shebang? 'tclsh' + return true if text.shebang? 'wish' + return true if text.shebang? 'jimsh' + end + + KEYWORDS = %w( + after apply array break catch continue elseif else error + eval expr for foreach global if namespace proc rename return + set switch then trace unset update uplevel upvar variable + vwait while + ) + + BUILTINS = %w( + append bgerror binary cd chan clock close concat dde dict + encoding eof exec exit fblocked fconfigure fcopy file + fileevent flush format gets glob history http incr info interp + join lappend lassign lindex linsert list llength load loadTk + lrange lrepeat lreplace lreverse lsearch lset lsort mathfunc + mathop memory msgcat open package pid pkg::create pkg_mkIndex + platform platform::shell puts pwd re_syntax read refchan + regexp registry regsub scan seek socket source split string + subst tell time tm unknown unload + ) + + OPEN = %w| \( \[ \{ " | + CLOSE = %w| \) \] \} | + ALL = OPEN + CLOSE + END_LINE = CLOSE + %w(; \n) + END_WORD = END_LINE + %w(\r \t \v) + + CHARS = lambda { |list| Regexp.new %/[#{list.join}]/ } + NOT_CHARS = lambda { |list| Regexp.new %/[^#{list.join}]/ } + + state :word do + rule %r/\{\*\}/, Keyword + + mixin :brace_abort + mixin :interp + rule %r/\{/, Punctuation, :brace + rule %r/\(/, Punctuation, :paren + rule %r/"/, Str::Double, :string + rule %r/#{NOT_CHARS[END_WORD]}+?(?=#{CHARS[OPEN+['\\\\']]})/, Text + end + + def self.gen_command_state(name='') + state(:"command#{name}") do + rule %r/#/, Comment, :comment + + mixin :word + + rule %r/(?=#{CHARS[END_WORD]})/ do + push :"params#{name}" + end + + rule %r/#{NOT_CHARS[END_WORD]}+/ do |m| + if KEYWORDS.include? m[0] + token Keyword + elsif BUILTINS.include? m[0] + token Name::Builtin + else + token Text + end + end + + mixin :whitespace + end + end + + def self.gen_delimiter_states(name, close, opts={}) + gen_command_state("_in_#{name}") + + state :"params_in_#{name}" do + rule close do + token Punctuation + pop! 2 + end + + # mismatched delimiters. Braced strings with mismatched + # closing delimiters should be okay, since this is standard + # practice, like {]]]]} + if opts[:strict] + rule CHARS[CLOSE - [close]], Error + else + rule CHARS[CLOSE - [close]], Text + end + + mixin :params + end + + state name do + rule close, Punctuation, :pop! + mixin :"command_in_#{name}" + end + end + + + # tcl is freaking impossible. If we're in braces and we encounter + # a close brace, we have to drop everything and close the brace. + # This is so silly things like {abc"def} and {abc]def} don't b0rk + # everything after them. + + # TODO: TCL seems to have this aborting behavior quite a lot. + # such things as [ abc" ] are a runtime error, but will still + # parse. Currently something like this will muck up the lex. + state :brace_abort do + rule %r/}/ do + if in_state? :brace + pop! until state? :brace + pop! + token Punctuation + else + token Error + end + end + end + + state :params do + rule %r/;/, Punctuation, :pop! + rule %r/\n/, Text, :pop! + rule %r/else|elseif|then/, Keyword + mixin :word + mixin :whitespace + rule %r/#{NOT_CHARS[END_WORD]}+/, Text + end + + gen_delimiter_states :brace, /\}/, :strict => false + gen_delimiter_states :paren, /\)/, :strict => true + gen_delimiter_states :bracket, /\]/, :strict => true + gen_command_state + + state :root do + mixin :command + end + + state :whitespace do + # not a multiline regex because we want to capture \n sometimes + rule %r/\s+/, Text + end + + state :interp do + rule %r/\[/, Punctuation, :bracket + rule %r/\$[a-z0-9.:-]+/, Name::Variable + rule %r/\$\{.*?\}/m, Name::Variable + rule %r/\$/, Text + + # escape sequences + rule %r/\\[0-7]{3}/, Str::Escape + rule %r/\\x[0-9a-f]{2}/i, Str::Escape + rule %r/\\u[0-9a-f]{4}/i, Str::Escape + rule %r/\\./m, Str::Escape + end + + state :comment do + rule %r/.*[^\\]\n/, Comment, :pop! + rule %r/.*\\\n/, Comment + end + + state :string do + rule %r/"/, Str::Double, :pop! + mixin :interp + rule %r/[^\\\[\$"{}]+/m, Str::Double + + # strings have to keep count of their internal braces, to support + # for example { "{ }" }. + rule %r/{/ do + @brace_count ||= 0 + @brace_count += 1 + + token Str::Double + end + + rule %r/}/ do + if in_state? :brace and @brace_count.to_i == 0 + pop! until state? :brace + pop! + token Punctuation + else + @brace_count -= 1 + token Str::Double + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/terraform.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/terraform.rb new file mode 100644 index 0000000..1732b93 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/terraform.rb @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'hcl.rb' + + class Terraform < Hcl + title "Terraform" + desc "Terraform HCL Interpolations" + + tag 'terraform' + aliases 'tf' + filenames '*.tf' + + def self.keywords + @keywords ||= Set.new %w( + terraform module provider variable resource data provisioner output + ) + end + + def self.declarations + @declarations ||= Set.new %w( + var local + ) + end + + def self.reserved + @reserved ||= Set.new %w() + end + + def self.constants + @constants ||= Set.new %w(true false null) + end + + def self.builtins + @builtins ||= %w() + end + + state :strings do + rule %r/\\./, Str::Escape + rule %r/\$\{/ do + token Keyword + push :interpolation + end + end + + state :dq do + rule %r/[^\\"\$]+/, Str::Double + mixin :strings + rule %r/"/, Str::Double, :pop! + end + + state :sq do + rule %r/[^\\'\$]+/, Str::Single + mixin :strings + rule %r/'/, Str::Single, :pop! + end + + state :heredoc do + rule %r/\n/, Str::Heredoc, :heredoc_nl + rule %r/[^$\n]+/, Str::Heredoc + rule %r/[$]/, Str::Heredoc + mixin :strings + end + + state :interpolation do + rule %r/\}/ do + token Keyword + pop! + end + + mixin :expression + end + + state :regexps do + rule %r/"\// do + token Str::Delimiter + goto :regexp_inner + end + end + + state :regexp_inner do + rule %r/[^"\/\\]+/, Str::Regex + rule %r/\\./, Str::Regex + rule %r/\/"/, Str::Delimiter, :pop! + rule %r/["\/]/, Str::Regex + end + + id = /[$a-z_\-][a-z0-9_\-]*/io + + state :expression do + mixin :regexps + mixin :primitives + rule %r/\s+/, Text + + rule %r(\+\+ | -- | ~ | && | \|\| | \\(?=\n) | << | >>>? | == | != )x, Operator + rule %r([-<>+*%&|\^/!=?:]=?), Operator + rule %r/[(\[,]/, Punctuation + rule %r/[)\].]/, Punctuation + + rule id do |m| + if self.class.keywords.include? m[0] + token Keyword + elsif self.class.declarations.include? m[0] + token Keyword::Declaration + elsif self.class.reserved.include? m[0] + token Keyword::Reserved + elsif self.class.constants.include? m[0] + token Keyword::Constant + elsif self.class.builtins.include? m[0] + token Name::Builtin + else + token Name::Other + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tex.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tex.rb new file mode 100644 index 0000000..52f4f58 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tex.rb @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class TeX < RegexLexer + title "TeX" + desc "The TeX typesetting system" + tag 'tex' + aliases 'TeX', 'LaTeX', 'latex' + + filenames '*.tex', '*.aux', '*.toc', '*.sty', '*.cls' + mimetypes 'text/x-tex', 'text/x-latex' + + def self.detect?(text) + return true if text =~ /\A\s*\\(documentclass|input|documentstyle|relax|ProvidesPackage|ProvidesClass)/ + end + + command = /\\([a-z]+|\s+|.)/i + + state :general do + rule %r/%.*$/, Comment + rule %r/[{}&_^]/, Punctuation + end + + state :root do + rule %r/\\\[/, Punctuation, :displaymath + rule %r/\\\(/, Punctuation, :inlinemath + rule %r/\$\$/, Punctuation, :displaymath + rule %r/\$/, Punctuation, :inlinemath + rule %r/\\(begin|end)\{.*?\}/, Name::Tag + + rule %r/(\\verb)\b(\S)(.*?)(\2)/ do + groups Name::Builtin, Keyword::Pseudo, Str::Other, Keyword::Pseudo + end + + rule command, Keyword, :command + mixin :general + rule %r/[^\\$%&_^{}]+/, Text + end + + state :math do + rule command, Name::Variable + mixin :general + rule %r/[0-9]+/, Num + rule %r/[-=!+*\/()\[\]]/, Operator + rule %r/[^=!+*\/()\[\]\\$%&_^{}0-9-]+/, Name::Builtin + end + + state :inlinemath do + rule %r/\\\)/, Punctuation, :pop! + rule %r/\$/, Punctuation, :pop! + mixin :math + end + + state :displaymath do + rule %r/\\\]/, Punctuation, :pop! + rule %r/\$\$/, Punctuation, :pop! + rule %r/\$/, Name::Builtin + mixin :math + end + + state :command do + rule %r/\[.*?\]/, Name::Attribute + rule %r/\*/, Keyword + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/toml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/toml.rb new file mode 100644 index 0000000..a3e5ae1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/toml.rb @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class TOML < RegexLexer + title "TOML" + desc 'the TOML configuration format (https://github.com/toml-lang/toml)' + tag 'toml' + + filenames '*.toml', 'Pipfile', 'poetry.lock' + mimetypes 'text/x-toml' + + # bare keys and quoted keys + identifier = %r/(?:\S+|"[^"]+"|'[^']+')/ + + state :basic do + rule %r/\s+/, Text + rule %r/#.*?$/, Comment + rule %r/(true|false)/, Keyword::Constant + + rule %r/(#{identifier})(\s*)(=)(\s*)(\{)/ do + groups Name::Property, Text, Operator, Text, Punctuation + push :inline + end + end + + state :root do + mixin :basic + + rule %r/(?/, Punctuation, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ttcn3.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ttcn3.rb new file mode 100644 index 0000000..6ccac4e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ttcn3.rb @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class TTCN3 < RegexLexer + title "TTCN3" + desc "The TTCN3 programming language (ttcn-3.org)" + + tag 'ttcn3' + filenames '*.ttcn', '*.ttcn3' + mimetypes 'text/x-ttcn3', 'text/x-ttcn' + + def self.keywords + @keywords ||= %w( + module import group type port component signature external + execute const template function altstep testcase var timer if + else select case for while do label goto start stop return + break int2char int2unichar int2bit int2enum int2hex int2oct + int2str int2float float2int char2int char2oct unichar2int + unichar2oct bit2int bit2hex bit2oct bit2str hex2int hex2bit + hex2oct hex2str oct2int oct2bit oct2hex oct2str oct2char + oct2unichar str2int str2hex str2oct str2float enum2int + any2unistr lengthof sizeof ispresent ischosen isvalue isbound + istemplatekind regexp substr replace encvalue decvalue + encvalue_unichar decvalue_unichar encvalue_o decvalue_o + get_stringencoding remove_bom rnd hostid send receive + setverdict + ) + end + + def self.reserved + @reserved ||= %w( + all alt apply assert at configuration conjunct const control + delta deterministic disjunct duration fail finished fuzzy from + history implies inconc inv lazy mod mode notinv now omit + onentry onexit par pass prev realtime seq setstate static + stepsize stream timestamp until values wait + ) + end + + def self.types + @types ||= %w( + anytype address boolean bitstring charstring hexstring octetstring + component enumerated float integer port record set of union universal + ) + end + + id = /[a-zA-Z_]\w*/ + digit = /\d_+\d|\d/ + bin_digit = /[01]_+[01]|[01]/ + oct_digit = /[0-7]_+[0-7]|[0-7]/ + hex_digit = /\h_+\h|\h/ + + state :statements do + rule %r/\n+/m, Text + rule %r/[ \t\r]+/, Text + rule %r/\\\n/, Text # line continuation + + rule %r(//(\\.|.)*?$), Comment::Single + rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline + + rule %r/"/, Str, :string + rule %r/'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char + + rule %r/#{digit}+\.#{digit}+([eE]#{digit}+)?[fd]?/i, Num::Float + rule %r/'#{bin_digit}+'B/i, Num::Bin + rule %r/'#{hex_digit}+'H/i, Num::Hex + rule %r/'#{oct_digit}+'O/i, Num::Oct + rule %r/#{digit}+/i, Num::Integer + + rule %r([~!%^&*+:=\|?<>/-]), Operator + rule %r/[()\[\]{},.;:]/, Punctuation + + rule %r/(?:true|false|null)\b/, Name::Builtin + + rule id do |m| + name = m[0] + if self.class.keywords.include? name + token Keyword + elsif self.class.types.include? name + token Keyword::Type + elsif self.class.reserved.include? name + token Keyword::Reserved + else + token Name + end + end + end + + state :root do + rule %r/module\b/, Keyword::Declaration, :module + rule %r/import\b/, Keyword::Namespace, :import + + mixin :statements + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape + rule %r/[^\\"\n]+/, Str + rule %r/\\\n/, Str + rule %r/\\/, Str # stray backslash + end + + state :module do + rule %r/\s+/m, Text + rule id, Name::Class, :pop! + end + + state :import do + rule %r/\s+/m, Text + rule %r/[\w.]+\*?/, Name::Namespace, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tulip.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tulip.rb new file mode 100644 index 0000000..9767bcb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/tulip.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + class Tulip < RegexLexer + desc 'the tulip programming language (twitter.com/tuliplang)' + tag 'tulip' + aliases 'tulip' + + filenames '*.tlp' + + mimetypes 'text/x-tulip', 'application/x-tulip' + + def self.detect?(text) + return true if text.shebang? 'tulip' + end + + id = /[a-z][\w-]*/i + upper_id = /[A-Z][\w-]*/ + + state :comments_and_whitespace do + rule %r/\s+/, Text + rule %r/#.*?$/, Comment + end + + state :root do + mixin :comments_and_whitespace + + rule %r/@#{id}/, Keyword + + + rule %r/(\\#{id})([{])/ do + groups Name::Function, Str + push :nested_string + end + + rule %r/([+]#{id})([{])/ do + groups Name::Decorator, Str + push :nested_string + end + + rule %r/\\#{id}/, Name::Function + rule %r/[+]#{id}/, Name::Decorator + + rule %r/"[{]/, Str, :dqi + rule %r/"/, Str, :dq + + rule %r/'{/, Str, :nested_string + rule %r/'#{id}/, Str + + rule %r/[.]#{id}/, Name::Tag + rule %r/[$]#{id}?/, Name::Variable + rule %r/-#{id}:?/, Name::Label + rule %r/%#{id}/, Name::Function + rule %r/`#{id}/, Operator::Word + + rule %r/[?~%._>,!\[\]:{}()=;\/-]/, Punctuation + + rule %r/[0-9]+([.][0-9]+)?/, Num + + rule %r/#{id}/, Name + + rule %r//, Comment::Preproc, :pop! + rule %r/[*:]/, Punctuation + rule %r/#{upper_id}/, Keyword::Type + rule %r/#{id}/, Name::Variable + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/turtle.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/turtle.rb new file mode 100644 index 0000000..46d5f4c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/turtle.rb @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Turtle < RegexLexer + title "Turtle/TriG" + desc "Terse RDF Triple Language, TriG" + tag 'turtle' + filenames '*.ttl', '*.trig' + mimetypes 'text/turtle', 'application/trig' + + state :root do + rule %r/@base\b/, Keyword::Declaration + rule %r/@prefix\b/, Keyword::Declaration + rule %r/true\b/, Keyword::Constant + rule %r/false\b/, Keyword::Constant + + rule %r/""".*?"""/m, Literal::String + rule %r/"([^"\\]|\\.)*"/, Literal::String + rule %r/'''.*?'''/m, Literal::String + rule %r/'([^'\\]|\\.)*'/, Literal::String + + rule %r/#.*$/, Comment::Single + + rule %r/@[^\s,.;]+/, Name::Attribute + + rule %r/[+-]?[0-9]+\.[0-9]*E[+-]?[0-9]+/, Literal::Number::Float + rule %r/[+-]?\.[0-9]+E[+-]?[0-9]+/, Literal::Number::Float + rule %r/[+-]?[0-9]+E[+-]?[0-9]+/, Literal::Number::Float + + rule %r/[+-]?[0-9]*\.[0-9]+?/, Literal::Number::Float + + rule %r/[+-]?[0-9]+/, Literal::Number::Integer + + rule %r/\./, Punctuation + rule %r/,/, Punctuation + rule %r/;/, Punctuation + rule %r/\(/, Punctuation + rule %r/\)/, Punctuation + rule %r/\{/, Punctuation + rule %r/\}/, Punctuation + rule %r/\[/, Punctuation + rule %r/\]/, Punctuation + rule %r/\^\^/, Punctuation + + rule %r/<[^>]*>/, Name::Label + + rule %r/base\b/i, Keyword::Declaration + rule %r/prefix\b/i, Keyword::Declaration + rule %r/GRAPH\b/, Keyword + rule %r/a\b/, Keyword + + rule %r/\s+/, Text::Whitespace + + rule %r/[^:;<>#\@"\(\).\[\]\{\} ]*:/, Name::Namespace + rule %r/[^:;<>#\@"\(\).\[\]\{\} ]+/, Name + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/twig.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/twig.rb new file mode 100644 index 0000000..036ee38 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/twig.rb @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'jinja.rb' + + class Twig < Jinja + title "Twig" + desc "Twig template engine (twig.sensiolabs.org)" + + tag "twig" + + filenames '*.twig' + + mimetypes 'application/x-twig', 'text/html+twig' + + def self.keywords + @keywords ||= %w(as do extends flush from import include use else starts + ends with without autoescape endautoescape block + endblock embed endembed filter endfilter for endfor + if endif macro endmacro sandbox endsandbox set endset + spaceless endspaceless) + end + + def self.tests + @tests ||= %w(constant defined divisibleby empty even iterable null odd + sameas) + end + + def self.pseudo_keywords + @pseudo_keywords ||= %w(true false none) + end + + def self.word_operators + @word_operators ||= %w(b-and b-or b-xor is in and or not) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/typescript.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/typescript.rb new file mode 100644 index 0000000..79a104b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/typescript.rb @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'javascript.rb' + load_lexer 'typescript/common.rb' + + class Typescript < Javascript + extend TypescriptCommon + + title "TypeScript" + desc "TypeScript, a superset of JavaScript (https://www.typescriptlang.org/)" + + tag 'typescript' + aliases 'ts' + + filenames '*.ts', '*.d.ts', '*.cts', '*.mts' + + mimetypes 'text/typescript' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/typescript/common.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/typescript/common.rb new file mode 100644 index 0000000..ec45efc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/typescript/common.rb @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + module TypescriptCommon + def keywords + @keywords ||= super + Set.new(%w( + is namespace static private protected public + implements readonly + )) + end + + def declarations + @declarations ||= super + Set.new(%w( + type abstract + )) + end + + def reserved + @reserved ||= super + Set.new(%w( + string any void number namespace module + declare default interface keyof + )) + end + + def builtins + @builtins ||= super + %w( + Capitalize ConstructorParameters Exclude Extract InstanceType + Lowercase NonNullable Omit OmitThisParameter Parameters + Partial Pick Readonly Record Required + ReturnType ThisParameterType ThisType Uncapitalize Uppercase + ) + end + + def self.extended(base) + base.prepend :root do + rule %r/[?][.]/, base::Punctuation + rule %r/[?]{2}/, base::Operator + + # Positive Examples: + # const cat = { name: "Garfield" } satisfies Person; + # import {something as thingy} from 'module' + # export { foo as default } + # ...spreadOperator as const; + # Negative Example: + # cy.get('kitten').as('friend') + rule %r{(?/, Keyword + + rule %r/[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation + rule %r/@"(\\.|.)*?"/, Str + rule %r/"(\\.|.)*?["\n]/, Str + rule %r/'(\\.|.)'/, Str::Char + rule %r/0x[0-9a-f]+[lu]?/i, Num + rule %r( + [0-9] + ([.][0-9]*)? # decimal + (e[+-][0-9]+)? # exponent + [fldu]? # type + )ix, Num + rule %r/\b(#{keywords.join('|')})\b/, Keyword + rule %r/\b(#{keywords_type.join('|')})\b/, Keyword::Type + rule %r/class|struct/, Keyword, :class + rule %r/namespace|using/, Keyword, :namespace + rule %r/#{id}(?=\s*[(])/, Name::Function + rule id, Name + + rule %r/#.*/, Comment::Preproc + end + + state :class do + mixin :whitespace + rule id, Name::Class, :pop! + end + + state :namespace do + mixin :whitespace + rule %r/(?=[(])/, Text, :pop! + rule %r/(#{id}|[.])+/, Name::Namespace, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/varnish.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/varnish.rb new file mode 100644 index 0000000..07c0c67 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/varnish.rb @@ -0,0 +1,168 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Varnish < RegexLexer + title 'VCL: Varnish Configuration Language' + desc 'The configuration language for Varnish HTTP Cache (varnish-cache.org)' + + tag 'vcl' + aliases 'varnishconf', 'varnish' + filenames '*.vcl' + mimetypes 'text/x-varnish', 'text/x-vcl' + + SPACE = '[ \f\n\r\t\v]+' + + # backend acl + def self.keywords + @keywords ||= Set.new %w[ + vcl set unset include import if else elseif elif elsif director probe + backend acl + + declare local + BOOL FLOAT INTEGER IP RTIME STRING TIME + ] + end + + def self.functions + @functions ||= Set.new %w[ + ban call hash_data new regsub regsuball return rollback + std.cache_req_body std.collect std.duration std.fileread std.healthy + std.integer std.ip std.log std.port std.querysort std.random std.real + std.real2time std.rollback std.set_ip_tos std.strstr std.syslog + std.time std.time2integer std.time2real std.timestamp std.tolower + std.toupper synth synthetic + ] + end + + def self.variables + @variables ||= Set.new %w[ + bereq bereq.backend bereq.between_bytes_timeout bereq.connect_timeout + bereq.first_byte_timeout bereq.method bereq.proto bereq.retries + bereq.uncacheable bereq.url bereq.xid beresp beresp.age + beresp.backend beresp.backend.ip beresp.backend.name beresp.do_esi + beresp.do_gunzip beresp.do_gzip beresp.do_stream beresp.grace + beresp.keep beresp.proto beresp.reason beresp.status + beresp.storage_hint beresp.ttl beresp.uncacheable beresp.was_304 + client.identity client.ip local.ip now obj.age obj.grace obj.hits + obj.keep obj.proto obj.reason obj.status obj.ttl obj.uncacheable + remote.ip req req.backend_hint req.can_gzip req.esi req.esi_level + req.hash_always_miss req.hash_ignore_busy req.method req.proto + req.restarts req.ttl req.url req.xid resp resp.proto resp.reason + resp.status server.hostname server.identity server.ip + ] + end + + # This is never used + # def self.routines + # @routines ||= Set.new %w[ + # backend_error backend_fetch backend_response purge deliver fini hash + # hit init miss pass pipe recv synth + # ] + # end + + state :root do + # long strings ({" ... "}) + rule %r/\{".*?"}/m, Str::Single + + # heredoc style long strings ({xyz"..."xyz}) + rule %r/\{(\w+)".*?"(\1)\}/m, Str::Single + + # comments + rule %r'/\*.*?\*/'m, Comment::Multiline + rule %r'(?://|#).*', Comment::Single + + rule %r/true|false/, Keyword::Constant + + # "wildcard variables" + var_prefix = Regexp.union(%w(beresp bereq resp req obj)) + rule %r/(?:#{var_prefix})\.http\.[\w.-]+/ do + token Name::Variable + end + + # local variables (var.*) + rule %r/(?:var)\.[\w.-]+/ do + token Name::Variable + end + + rule %r/(sub)(#{SPACE})([\w-]+)/ do + groups Keyword, Text, Name::Function + end + + # inline C (C{ ... }C) + rule %r/C\{/ do + token Comment::Preproc + push :inline_c + end + + rule %r/\.?[a-z_][\w.-]*/i do |m| + next token Keyword if self.class.keywords.include? m[0] + next token Name::Function if self.class.functions.include? m[0] + next token Name::Variable if self.class.variables.include? m[0] + token Text + end + + ## for number literals + + decimal = %r/[0-9]+/ + hex = %r/[0-9a-f]+/i + + numeric = %r{ + (?: + 0x#{hex} + (?:\.#{hex})? + (?:p[+-]?#{hex})? + ) + | + (?: + #{decimal} + (?:\.#{decimal})? + (?:e[+-]?#{decimal})? + ) + }xi + + # duration literals + duration_suffix = Regexp.union(%w(ms s m h d w y)) + rule %r/#{numeric}#{duration_suffix}/, Num::Other + + # numeric literals (integer / float) + rule numeric do |m| + case m[0] + when /^#{decimal}$/ + token Num::Integer + when /^0x#{hex}$/ + token Num::Integer + else + token Num::Float + end + end + + # standard strings + rule %r/"/, Str::Double, :string + + rule %r'[&|+-]{2}|[<=>!*/+-]=|<<|>>|!~|[-+*/%><=!&|~]', Operator + + rule %r/[{}();.,]/, Punctuation + + rule %r/\r\n?|\n/, Text + rule %r/./, Text + end + + state :string do + rule %r/"/, Str::Double, :pop! + rule %r/\\[\\"nt]/, Str::Escape + + rule %r/\r\n?|\n/, Str::Double + rule %r/./, Str::Double + end + + state :inline_c do + rule %r/}C/, Comment::Preproc, :pop! + rule %r/.*?(?=}C)/m do + delegate C + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vb.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vb.rb new file mode 100644 index 0000000..74870ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vb.rb @@ -0,0 +1,165 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class VisualBasic < RegexLexer + title "Visual Basic" + desc "Visual Basic" + tag 'vb' + aliases 'visualbasic' + filenames '*.vbs', '*.vb' + mimetypes 'text/x-visualbasic', 'application/x-visualbasic' + + def self.keywords + @keywords ||= Set.new %w( + AddHandler Alias ByRef ByVal CBool CByte CChar CDate CDbl CDec + CInt CLng CObj CSByte CShort CSng CStr CType CUInt CULng CUShort + Call Case Catch Class Const Continue Declare Default Delegate + Dim DirectCast Do Each Else ElseIf End EndIf Enum Erase Error + Event Exit False Finally For Friend Function Get Global GoSub + GoTo Handles If Implements Imports Inherits Interface Let + Lib Loop Me Module MustInherit MustOverride MyBase MyClass + Namespace Narrowing New Next Not NotInheritable NotOverridable + Nothing Of On Operator Option Optional Overloads Overridable + Overrides ParamArray Partial Private Property Protected Public + RaiseEvent ReDim ReadOnly RemoveHandler Resume Return Select Set + Shadows Shared Single Static Step Stop Structure Sub SyncLock + Then Throw To True Try TryCast Using Wend When While Widening + With WithEvents WriteOnly + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + Boolean Byte Char Date Decimal Double Integer Long Object + SByte Short Single String Variant UInteger ULong UShort + ) + end + + def self.operator_words + @operator_words ||= Set.new %w( + AddressOf And AndAlso As GetType In Is IsNot Like Mod Or OrElse + TypeOf Xor + ) + end + + def self.builtins + @builtins ||= Set.new %w( + Console ConsoleColor + ) + end + + id = /[a-z_]\w*/i + upper_id = /[A-Z]\w*/ + + state :whitespace do + rule %r/\s+/, Text + rule %r/\n/, Text, :bol + rule %r/rem\b.*?$/i, Comment::Single + rule %r(%\{.*?%\})m, Comment::Multiline + rule %r/'.*$/, Comment::Single + end + + state :bol do + rule %r/\s+/, Text + rule %r/<.*?>/, Name::Attribute + rule(//) { :pop! } + end + + state :root do + mixin :whitespace + rule %r( + [#]If\b .*? \bThen + | [#]ElseIf\b .*? \bThen + | [#]End \s+ If + | [#]Const + | [#]ExternalSource .*? \n + | [#]End \s+ ExternalSource + | [#]Region .*? \n + | [#]End \s+ Region + | [#]ExternalChecksum + )x, Comment::Preproc + rule %r/[.]/, Punctuation, :dotted + rule %r/[(){}!#,:]/, Punctuation + rule %r/Option\s+(Strict|Explicit|Compare)\s+(On|Off|Binary|Text)/, + Keyword::Declaration + rule %r/End\b/, Keyword, :end + rule %r/(Dim|Const)\b/, Keyword, :dim + rule %r/(Function|Sub|Property)\b/, Keyword, :funcname + rule %r/(Class|Structure|Enum)\b/, Keyword, :classname + rule %r/(Module|Namespace|Imports)\b/, Keyword, :namespace + + rule upper_id do |m| + match = m[0] + if self.class.keywords.include? match + token Keyword + elsif self.class.keywords_type.include? match + token Keyword::Type + elsif self.class.operator_words.include? match + token Operator::Word + elsif self.class.builtins.include? match + token Name::Builtin + else + token Name + end + end + + rule( + %r(&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|<=|>=|<>|[-&*/\\^+=<>.]), + Operator + ) + + rule %r/"/, Str, :string + rule %r/#{id}[%&@!#\$]?/, Name + rule %r/#.*?#/, Literal::Date + + rule %r/(\d+\.\d*|\d*\.\d+)(f[+-]?\d+)?/i, Num::Float + rule %r/\d+([SILDFR]|US|UI|UL)?/, Num::Integer + rule %r/&H[0-9a-f]+([SILDFR]|US|UI|UL)?/, Num::Integer + rule %r/&O[0-7]+([SILDFR]|US|UI|UL)?/, Num::Integer + + rule %r/_\n/, Keyword + end + + state :dotted do + mixin :whitespace + rule id, Name, :pop! + end + + state :string do + rule %r/""/, Str::Escape + rule %r/"C?/, Str, :pop! + rule %r/[^"]+/, Str + end + + state :dim do + mixin :whitespace + rule id, Name::Variable, :pop! + rule(//) { pop! } + end + + state :funcname do + mixin :whitespace + rule id, Name::Function, :pop! + end + + state :classname do + mixin :whitespace + rule id, Name::Class, :pop! + end + + state :namespace do + mixin :whitespace + rule %r/#{id}([.]#{id})*/, Name::Namespace, :pop! + end + + state :end do + mixin :whitespace + rule %r/(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b/, + Keyword, :pop! + rule(//) { pop! } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/velocity.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/velocity.rb new file mode 100644 index 0000000..4aa23ad --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/velocity.rb @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- # + +module Rouge + module Lexers + class Velocity < TemplateLexer + title 'Velocity' + desc 'Velocity is a Java-based template engine (velocity.apache.org)' + tag 'velocity' + filenames '*.vm', '*.velocity', '*.fhtml' + mimetypes 'text/html+velocity' + + id = /[a-z_]\w*/i + + state :root do + rule %r/[^{#$]+/ do + delegate parent + end + + rule %r/(#)(\*.*?\*)(#)/m, Comment::Multiline + rule %r/(##)(.*?$)/, Comment::Single + + rule %r/(#\{?)(#{id})(\}?)(\s?\()/m do + groups Punctuation, Name::Function, Punctuation, Punctuation + push :directive_params + end + + rule %r/(#\{?)(#{id})(\}|\b)/m do + groups Punctuation, Name::Function, Punctuation + end + + rule %r/\$\{?/, Punctuation, :variable + end + + state :variable do + rule %r/#{id}/, Name::Variable + rule %r/\(/, Punctuation, :func_params + rule %r/(\.)(#{id})/ do + groups Punctuation, Name::Variable + end + rule %r/\}/, Punctuation, :pop! + rule(//) { pop! } + end + + state :directive_params do + rule %r/(&&|\|\||==?|!=?|[-<>+*%&|^\/])|\b(eq|ne|gt|lt|ge|le|not|in)\b/, Operator + rule %r/\[/, Operator, :range_operator + rule %r/\b#{id}\b/, Name::Function + mixin :func_params + end + + state :range_operator do + rule %r/[.]{2}/, Operator + mixin :func_params + rule %r/\]/, Operator, :pop! + end + + state :func_params do + rule %r/\$\{?/, Punctuation, :variable + rule %r/\s+/, Text + rule %r/,/, Punctuation + rule %r/"(\\\\|\\"|[^"])*"/, Str::Double + rule %r/'(\\\\|\\'|[^'])*'/, Str::Single + rule %r/0[xX][0-9a-fA-F]+[Ll]?/, Num::Hex + rule %r/\b[0-9]+\b/, Num::Integer + rule %r/(true|false|null)\b/, Keyword::Constant + rule %r/[(\[]/, Punctuation, :push + rule %r/[)\]}]/, Punctuation, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/verilog.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/verilog.rb new file mode 100644 index 0000000..820c435 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/verilog.rb @@ -0,0 +1,163 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Verilog < RegexLexer + title "Verilog and System Verilog" + desc "The System Verilog hardware description language" + tag 'verilog' + filenames '*.v', '*.sv', '*.svh' + mimetypes 'text/x-verilog', 'text/x-systemverilog' + + id = /[a-zA-Z_][a-zA-Z0-9_]*/ + + def self.keywords + @keywords ||= Set.new %w( + alias always always_comb always_ff always_latch assert assert_strobe + assign assume automatic attribute before begin bind bins binsof break + case casex casez clocking config constraint context continue cover + covergroup coverpoint cross deassign defparam default design dist do + else end endattribute endcase endclass endclocking endconfig + endfunction endgenerate endgroup endinterface endmodule endpackage + endprimitive endprogram endproperty endspecify endsequence endtable + endtask expect export extends extern final first_match for force + foreach fork forkjoin forever function generate genvar if iff ifnone + ignore_bins illegal_bins import incdir include initial inside instance + interface intersect join join_any join_none liblist library local + localparam matches module modport new noshowcancelled null package + parameter primitive priority program property protected + pulsestyle_onevent pulsestyle_ondetect pure rand randc randcase + randsequence release return sequence showcancelled solve specify super + table task this throughout timeprecision timeunit type typedef unique + use wait wait_order while wildcard with within + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + and bit buf bufif0 bufif1 byte cell chandle class cmos const disable + edge enum event highz0 highz1 initial inout input int integer join + logic longint macromodule medium nand negedge nmos nor not + notif0 notif1 or output packed parameter pmos posedge pull0 pull1 + pulldown pullup rcmos real realtime ref reg repeat rnmos rpmos rtran + rtranif0 rtranif1 scalared shortint shortreal signed specparam + static string strength strong0 strong1 struct supply0 supply1 tagged + time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg union + unsigned uwire var vectored virtual void wait wand weak[01] wire wor + xnor xor + ) + end + + def self.keywords_system_task + @keyword_system_task ||= Set.new %w( + acos acosh asin asinh assertfailoff assertfailon assertkill + assertnonvacuouson assertoff asserton assertpassoff assertpasson + assertvacuousoff atan atan2 atanh bits bitstoreal bitstoshortreal + cast ceil changed changed_gclk changing_gclk clog2 cos cosh countones + coverage_control coverage_get coverage_get_max coverage_merge + coverage_save dimensions display displayb displayh displayo + dist_chi_square dist_erlang dist_exponential dist_normal dist_poisson + dist_t dist_uniform dumpall dumpfile dumpflush dumplimit dumpoff + dumpon dumpports dumpportsall dumpportsflush dumpportslimit + dumpportsoff dumpportson dumpvars error exit exp falling_gclk fclose + fdisplay fdisplayb fdisplayh fdisplayo fell fell_gclk feof ferror + fflush fgetc fgets finish floor fmonitor fmonitorb fmonitorh fmonitoro + fopen fread fscanf fseek fstrobe fstrobeb fstrobeh fstrobeo ftell + future_gclk fwrite fwriteb fwriteh fwriteo get_coverage high hypot + increment info isunbounded isunknown itor left ln load_coverage_db + log10 low monitor monitorb monitorh monitoro monitoroff monitoron + onehot onehot0 past past_gclk pow printtimescale q_add q_exam q_full + q_initialize q_remove random readmemb readmemh realtime realtobits + rewind right rising_gclk rose rose_gclk rtoi sampled + set_coverage_db_name sformat sformatf shortrealtobits signed sin sinh + size sqrt sscanf stable stable_gclk steady_gclk stime stop strobe + strobeb strobeh strobeo swrite swriteb swriteh swriteo system tan tanh + time timeformat typename ungetc unpacked_dimensions unsigned warning + write writeb writeh writememb writememh writeo + ) + end + + state :expr_bol do + mixin :inline_whitespace + rule %r/`define/, Comment::Preproc, :macro + + rule(//) { pop! } + end + + # :expr_bol is the same as :bol but without labels, since + # labels can only appear at the beginning of a statement. + state :bol do + rule %r/#{id}:(?!:)/, Name::Label + mixin :expr_bol + end + + state :inline_whitespace do + rule %r/[ \t\r]+/, Text + rule %r/\\\n/, Text # line continuation + rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline + end + + state :whitespace do + rule %r/\n+/m, Text, :bol + rule %r(//(\\.|.)*?$), Comment::Single, :bol + mixin :inline_whitespace + end + + state :expr_whitespace do + rule %r/\n+/m, Text, :expr_bol + mixin :whitespace + end + + state :string do + rule %r/"/, Str, :pop! + rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape + rule %r/[^\\"\n]+/, Str + rule %r/\\\n/, Str + rule %r/\\/, Str # stray backslash + end + + state :statement do + mixin :whitespace + rule %r/L?"/, Str, :string + rule %r/([0-9_]+\.[0-9_]*|[0-9_]*\.[0-9_]+)(e[+-]?[0-9_]+)?/i, Num::Float + rule %r/[0-9_]+e[+-]?[0-9_]+/i, Num::Float + rule %r/[0-9]*'h[0-9a-fA-F_?]+/, Num::Hex + rule %r/[0-9]*'b?[01xz_?]+/, Num::Bin + rule %r/[0-9]*'d[0-9_?]+/, Num::Integer + rule %r/[0-9_]+[lu]*/i, Num::Integer + rule %r([-~!%^&*+=\|?:<>/@{}]), Operator + rule %r/[()\[\],.$\#;]/, Punctuation + rule %r/`(\w+)/, Comment::Preproc + + rule id do |m| + name = m[0] + + if self.class.keywords.include? name + token Keyword + elsif self.class.keywords_type.include? name + token Keyword::Type + elsif self.class.keywords_system_task.include? name + token Name::Builtin + else + token Name + end + end + end + + state :root do + mixin :expr_whitespace + rule(//) { push :statement } + end + + state :macro do + rule %r/\n/, Comment::Preproc, :pop! + mixin :inline_whitespace + rule %r/;/, Punctuation + rule %r/\=/, Operator + rule %r/(\w+)/, Text + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vhdl.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vhdl.rb new file mode 100644 index 0000000..38ff5fc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vhdl.rb @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class VHDL < RegexLexer + title "VHDL 2008" + desc "Very High Speed Integrated Circuit Hardware Description Language" + tag 'vhdl' + + filenames '*.vhd', '*.vhdl', '*.vho' + + mimetypes 'text/x-vhdl' + def self.keywords + @keywords ||= Set.new %w( + access after alias all architecture array assert assume assume_guarantee attribute + begin block body buffer bus case component configuration constant context cover + default disconnect downto else elsif end entity exit fairness file for force function + generate generic group guarded if impure in inertial inout is label library linkage + literal loop map new next null of on open others out package parameter port postponed + procedure process property protected pure range record register reject release report + return select sequence severity shared signal strong subtype then to transport type + unaffected units until use variable vmode vprop vunit wait when while with + ) + end + + def self.keywords_type + @keywords_type ||= Set.new %w( + bit bit_vector boolean boolean_vector character integer integer_vector natural positive + real real_vector severity_level signed std_logic std_logic_vector std_ulogic + std_ulogic_vector string unsigned time time_vector + ) + end + + def self.operator_words + @operator_words ||= Set.new %w( + abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor + ) + end + + id = /[a-zA-Z][a-zA-Z0-9_]*/ + + state :whitespace do + rule %r/\s+/, Text + rule %r/\n/, Text + # Find Comments (VHDL doesn't support multiline comments) + rule %r/--.*$/, Comment::Single + end + + state :statements do + + # Find Numbers + rule %r/-?\d+/i, Num::Integer + rule %r/-?\d+[.]\d+/i, Num::Float + + # Find Strings + rule %r/[box]?"[^"]*"/i, Str::Single + rule %r/'[^']?'/i, Str::Char + + # Find Attributes + rule %r/'#{id}/i, Name::Attribute + + # Punctuations + rule %r/[(),:;]/, Punctuation + + # Boolean and NULL + rule %r/(?:true|false|null)\b/i, Name::Builtin + + rule id do |m| + match = m[0].downcase #convert to lower case + if self.class.keywords.include? match + token Keyword + elsif self.class.keywords_type.include? match + token Keyword::Type + elsif self.class.operator_words.include? match + token Operator::Word + else + token Name + end + end + + rule( + %r(=>|[*][*]|:=|\/=|>=|<=|<>|\?\?|\?=|\?\/=|\?>|\?<|\?>=|\?<=|<<|>>|[#&'*+-.\/:<=>\?@^]), + Operator + ) + + end + + state :root do + + mixin :whitespace + mixin :statements + + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/viml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/viml.rb new file mode 100644 index 0000000..9ef1776 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/viml.rb @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class VimL < RegexLexer + title "VimL" + desc "VimL, the scripting language for the Vim editor (vim.org)" + tag 'viml' + aliases 'vim', 'vimscript', 'ex' + filenames '*.vim', '*.vba', '.vimrc', '.exrc', '.gvimrc', + '_vimrc', '_exrc', '_gvimrc' # _ names for windows + + mimetypes 'text/x-vim' + + def self.keywords + Kernel::load File.join(Lexers::BASE_DIR, 'viml/keywords.rb') + self.keywords + end + + state :root do + rule %r/^(\s*)(".*?)$/ do + groups Text, Comment + end + + rule %r/^\s*\\/, Str::Escape + + rule %r/[ \t]+/, Text + + # TODO: regexes can have other delimiters + rule %r(/(\\\\|\\/|[^\n/])*/), Str::Regex + rule %r("(\\\\|\\"|[^\n"])*"), Str::Double + rule %r('(\\\\|\\'|[^\n'])*'), Str::Single + + # if it's not a string, it's a comment. + rule %r/(?<=\s)"[^-:.%#=*].*?$/, Comment + + rule %r/-?\d+/, Num + rule %r/#[0-9a-f]{6}/i, Num::Hex + rule %r/^:/, Punctuation + rule %r/[():<>+=!\[\]{}\|,~.-]/, Punctuation + rule %r/\b(let|if|else|endif|elseif|fun|function|endfunction)\b/, + Keyword + + rule %r/\b(NONE|bold|italic|underline|dark|light)\b/, Name::Builtin + + rule %r/[absg]:\w+\b/, Name::Variable + rule %r/\b\w+\b/ do |m| + name = m[0] + keywords = self.class.keywords + + if keywords[:command].include? name + token Keyword + elsif keywords[:function].include? name + token Name::Builtin + elsif keywords[:option].include? name + token Name::Builtin + elsif keywords[:auto].include? name + token Name::Builtin + else + token Text + end + end + + # no errors in VimL! + rule %r/./m, Text + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/viml/keywords.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/viml/keywords.rb new file mode 100644 index 0000000..662aa21 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/viml/keywords.rb @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# DO NOT EDIT +# This file is automatically generated by `rake builtins:viml`. +# See tasks/builtins/viml.rake for more info. + +module Rouge + module Lexers + class VimL + def self.keywords + @keywords ||= {}.tap do |kw| + kw[:command] = Set.new ["a", "ar", "args", "argl", "arglocal", "ba", "ball", "bm", "bmodified", "breaka", "breakadd", "bun", "bunload", "cabc", "cabclear", "cal", "call", "cc", "cf", "cfile", "changes", "cla", "clast", "cnf", "cnfile", "comc", "comclear", "cp", "cprevious", "cstag", "debugg", "debuggreedy", "deletl", "dep", "diffpu", "diffput", "dl", "dr", "drop", "ec", "em", "emenu", "ene", "enew", "files", "fini", "finish", "folddoc", "folddoclosed", "gr", "grep", "helpc", "helpclose", "his", "history", "il", "ilist", "isp", "isplit", "keepa", "l", "list", "laf", "lafter", "lbel", "lbelow", "lcscope", "lfdo", "lgrepa", "lgrepadd", "lma", "lo", "loadview", "lop", "lopen", "lua", "m", "move", "mes", "mkvie", "mkview", "nbc", "nbclose", "noh", "nohlsearch", "ol", "oldfiles", "pa", "packadd", "po", "pop", "prof", "profile", "pta", "ptag", "ptr", "ptrewind", "py3f", "py3file", "pythonx", "quita", "quitall", "redraws", "redrawstatus", "rew", "rewind", "rubyf", "rubyfile", "sIg", "sa", "sargument", "sba", "sball", "sbr", "sbrewind", "scl", "scscope", "sfir", "sfirst", "sgl", "sic", "sin", "sm", "smap", "snoreme", "spelld", "spelldump", "spellw", "spellwrong", "srg", "st", "stop", "stj", "stjump", "sunmenu", "syn", "tN", "tNext", "tabd", "tabdo", "tabm", "tabmove", "tabr", "tabrewind", "tch", "tchdir", "tf", "tfirst", "tlmenu", "tm", "tmenu", "to", "topleft", "tu", "tunmenu", "undol", "undolist", "up", "update", "vi", "visual", "vmapc", "vmapclear", "wa", "wall", "winp", "winpos", "wundo", "xme", "xr", "xrestore", "ab", "arga", "argadd", "argu", "argument", "bad", "badd", "bn", "bnext", "breakd", "breakdel", "bw", "bwipeout", "cabo", "cabove", "cat", "catch", "ccl", "cclose", "cfdo", "chd", "chdir", "cle", "clearjumps", "cnor", "comp", "compiler", "cpf", "cpfile", "cun", "delc", "delcommand", "deletp", "di", "display", "diffs", "diffsplit", "dli", "dlist", "ds", "dsearch", "echoe", "echoerr", "en", "endif", "eval", "filet", "fir", "first", "foldo", "foldopen", "grepa", "grepadd", "helpf", "helpfind", "i", "imapc", "imapclear", "iuna", "iunabbrev", "keepalt", "la", "last", "lan", "language", "lbo", "lbottom", "ld", "ldo", "lfir", "lfirst", "lh", "lhelpgrep", "lmak", "lmake", "loadk", "lp", "lprevious", "luado", "ma", "mark", "messages", "mod", "mode", "nbs", "nbstart", "nor", "omapc", "omapclear", "packl", "packloadall", "popu", "popup", "profd", "profdel", "ptf", "ptfirst", "pts", "ptselect", "pyx", "r", "read", "redrawt", "redrawtabline", "ri", "right", "rundo", "sIl", "sal", "sall", "sbf", "sbfirst", "sc", "scp", "se", "set", "sg", "sgn", "sie", "sip", "sme", "snoremenu", "spelli", "spellinfo", "spr", "sprevious", "sri", "sta", "stag", "stopi", "stopinsert", "sus", "suspend", "sync", "ta", "tag", "tabe", "tabedit", "tabn", "tabnext", "tabs", "tcld", "tcldo", "th", "throw", "tln", "tma", "tmap", "tp", "tprevious", "tunma", "tunmap", "unh", "unhide", "v", "vie", "view", "vne", "vnew", "wh", "while", "wn", "wnext", "wv", "wviminfo", "xmenu", "xunme", "abc", "abclear", "argd", "argdelete", "as", "ascii", "bd", "bdelete", "bo", "botright", "breakl", "breaklist", "cN", "cNext", "cad", "caddbuffer", "cb", "cbuffer", "cd", "cfir", "cfirst", "che", "checkpath", "clo", "close", "co", "copy", "con", "continue", "cq", "cquit", "cuna", "cunabbrev", "delel", "delf", "delfunction", "dif", "diffupdate", "difft", "diffthis", "do", "dsp", "dsplit", "echom", "echomsg", "endf", "endfunction", "ex", "filetype", "fix", "fixdel", "for", "gui", "helpg", "helpgrep", "ia", "in", "j", "join", "keepj", "keepjumps", "lab", "labove", "lat", "lc", "lcd", "le", "left", "lg", "lgetfile", "lhi", "lhistory", "lmapc", "lmapclear", "loadkeymap", "lpf", "lpfile", "luafile", "mak", "make", "mk", "mkexrc", "mz", "mzscheme", "new", "nore", "on", "only", "pc", "pclose", "pp", "ppop", "promptf", "promptfind", "ptj", "ptjump", "pu", "put", "py", "python", "pyxdo", "rec", "recover", "reg", "registers", "rightb", "rightbelow", "rv", "rviminfo", "sIn", "san", "sandbox", "sbl", "sblast", "scI", "scr", "scriptnames", "setf", "setfiletype", "sgI", "sgp", "sig", "sir", "smenu", "so", "source", "spellr", "spellrare", "sr", "srl", "star", "startinsert", "sts", "stselect", "sv", "sview", "syncbind", "tab", "tabf", "tabfind", "tabnew", "tags", "tclf", "tclfile", "tj", "tjump", "tlnoremenu", "tmapc", "tmapclear", "tr", "trewind", "u", "undo", "unl", "ve", "version", "vim", "vimgrep", "vs", "vsplit", "win", "winsize", "wp", "wprevious", "x", "xit", "xnoreme", "xunmenu", "abo", "aboveleft", "argdo", "au", "bel", "belowright", "bp", "bprevious", "bro", "browse", "cNf", "cNfile", "cadde", "caddexpr", "cbe", "cbefore", "cdo", "cg", "cgetfile", "checkt", "checktime", "cmapc", "cmapclear", "col", "colder", "conf", "confirm", "cr", "crewind", "cw", "cwindow", "delep", "dell", "diffg", "diffget", "dig", "digraphs", "doau", "e", "edit", "echon", "endfo", "endfor", "exi", "exit", "filt", "filter", "fo", "fold", "fu", "function", "gvim", "helpt", "helptags", "iabc", "iabclear", "inor", "ju", "jumps", "keepp", "keeppatterns", "lad", "laddexpr", "later", "lch", "lchdir", "lefta", "leftabove", "lgetb", "lgetbuffer", "ll", "lne", "lnext", "loc", "lockmarks", "lr", "lrewind", "lv", "lvimgrep", "marks", "mks", "mksession", "mzf", "mzfile", "nmapc", "nmapclear", "nos", "noswapfile", "opt", "options", "pe", "perl", "pre", "preserve", "promptr", "promptrepl", "ptl", "ptlast", "pw", "pwd", "pydo", "pyxfile", "red", "redo", "res", "resize", "ru", "runtime", "sI", "sIp", "sav", "saveas", "sbm", "sbmodified", "sce", "scripte", "scriptencoding", "setg", "setglobal", "sgc", "sgr", "sign", "sl", "sleep", "smile", "sor", "sort", "spellrepall", "srI", "srn", "startg", "startgreplace", "sun", "sunhide", "sw", "swapname", "syntime", "tabN", "tabNext", "tabfir", "tabfirst", "tabo", "tabonly", "tc", "tcl", "te", "tearoff", "tl", "tlast", "tlu", "tn", "tnext", "try", "una", "unabbreviate", "unlo", "unlockvar", "verb", "verbose", "vimgrepa", "vimgrepadd", "wN", "wNext", "winc", "wincmd", "wq", "xa", "xall", "xnoremenu", "xwininfo", "addd", "arge", "argedit", "bN", "bNext", "bf", "bfirst", "br", "brewind", "bufdo", "c", "change", "caddf", "caddfile", "cbel", "cbelow", "ce", "center", "cgetb", "cgetbuffer", "chi", "chistory", "cn", "cnext", "colo", "colorscheme", "cons", "const", "cs", "d", "delete", "deletel", "delm", "delmarks", "diffo", "diffoff", "dir", "doaut", "ea", "el", "else", "endt", "endtry", "exu", "exusage", "fin", "find", "foldc", "foldclose", "g", "h", "help", "hi", "if", "intro", "k", "lN", "lNext", "laddb", "laddbuffer", "lb", "lbuffer", "lcl", "lclose", "lex", "lexpr", "lgete", "lgetexpr", "lla", "llast", "lnew", "lnewer", "lockv", "lockvar", "ls", "lvimgrepa", "lvimgrepadd", "mat", "match", "mksp", "mkspell", "n", "next", "noa", "nu", "number", "ownsyntax", "ped", "pedit", "prev", "previous", "ps", "psearch", "ptn", "ptnext", "py3", "pyf", "pyfile", "q", "quit", "redi", "redir", "ret", "retab", "rub", "ruby", "sIc", "sIr", "sbN", "sbNext", "sbn", "sbnext", "scg", "scriptv", "scriptversion", "setl", "setlocal", "sge", "sh", "shell", "sil", "silent", "sla", "slast", "sn", "snext", "sp", "split", "spellrrare", "src", "srp", "startr", "startreplace", "sunme", "sy", "t", "tabc", "tabclose", "tabl", "tablast", "tabp", "tabprevious", "tcd", "ter", "terminal", "tlm", "tlunmenu", "tno", "tnoremap", "ts", "tselect", "undoj", "undojoin", "uns", "unsilent", "vert", "vertical", "viu", "viusage", "w", "write", "windo", "wqa", "wqall", "xmapc", "xmapclear", "xprop", "y", "yank", "al", "all", "argg", "argglobal", "b", "buffer", "bl", "blast", "brea", "break", "buffers", "ca", "caf", "cafter", "cbo", "cbottom", "cex", "cexpr", "cgete", "cgetexpr", "cl", "clist", "cnew", "cnewer", "com", "cope", "copen", "cscope", "debug", "deletep", "delp", "diffp", "diffpatch", "dj", "djump", "dp", "earlier", "elsei", "elseif", "endw", "endwhile", "f", "file", "fina", "finally", "foldd", "folddoopen", "go", "goto", "ha", "hardcopy", "hid", "hide", "ij", "ijump", "is", "isearch", "kee", "keepmarks", "lNf", "lNfile", "laddf", "laddfile", "lbe", "lbefore", "lcs", "lf", "lfile", "lgr", "lgrep", "lli", "llist", "lnf", "lnfile", "lol", "lolder", "lt", "ltag", "lw", "lwindow", "menut", "menutranslate", "mkv", "mkvimrc", "nb", "nbkey", "noautocmd", "o", "open", "p", "print", "perld", "perldo", "pro", "ptN", "ptNext", "ptp", "ptprevious", "py3do", "python3", "qa", "qall", "redr", "redraw", "retu", "return", "rubyd", "rubydo", "sIe", "sN", "sNext", "sb", "sbuffer", "sbp", "sbprevious", "sci", "scs", "sf", "sfind", "sgi", "si", "sim", "simalt", "smagic", "sno", "snomagic", "spe", "spellgood", "spellu", "spellundo", "sre", "srewind", "def", "endd", "enddef", "disa", "disassemble", "vim9", "vim9script", "imp", "import", "exp", "export"] + kw[:option] = Set.new ["acd", "ambw", "arshape", "background", "ballooneval", "bex", "bl", "brk", "buftype", "cf", "cinkeys", "cmdwinheight", "com", "completeslash", "cpoptions", "cscoperelative", "csre", "cursorcolumn", "delcombine", "digraph", "eadirection", "emo", "equalprg", "expandtab", "fdls", "fex", "fileignorecase", "fml", "foldlevel", "formatexpr", "gcr", "go", "guifontset", "helpheight", "history", "hlsearch", "imaf", "ims", "includeexpr", "infercase", "iskeyword", "keywordprg", "laststatus", "lispwords", "lrm", "magic", "maxfuncdepth", "menuitems", "mm", "modifiable", "mousemodel", "mzq", "numberwidth", "opfunc", "patchexpr", "pfn", "pp", "printfont", "pumwidth", "pythonthreehome", "redrawtime", "ri", "rs", "sb", "scroll", "sect", "sft", "shellredir", "shiftwidth", "showmatch", "signcolumn", "smarttab", "sp", "spf", "srr", "startofline", "suffixes", "switchbuf", "ta", "tagfunc", "tbi", "term", "termwintype", "tgc", "titlelen", "toolbariconsize", "ttimeout", "ttymouse", "twt", "undofile", "varsofttabstop", "verbosefile", "viminfofile", "wak", "weirdinvert", "wig", "wildoptions", "winheight", "wm", "wrapscan", "ai", "anti", "autochdir", "backspace", "balloonevalterm", "bexpr", "bo", "browsedir", "casemap", "cfu", "cino", "cmp", "comments", "concealcursor", "cpp", "cscopetag", "cst", "cursorline", "dex", "dip", "eb", "emoji", "errorbells", "exrc", "fdm", "ff", "filetype", "fmr", "foldlevelstart", "formatlistpat", "gd", "gp", "guifontwide", "helplang", "hk", "ic", "imak", "imsearch", "incsearch", "insertmode", "isp", "km", "lazyredraw", "list", "ls", "makeef", "maxmapdepth", "mfd", "mmd", "modified", "mouses", "mzquantum", "nuw", "osfiletype", "patchmode", "ph", "preserveindent", "printheader", "pvh", "pyx", "regexpengine", "rightleft", "rtp", "sbo", "scrollbind", "sections", "sh", "shellslash", "shm", "showmode", "siso", "smc", "spc", "spl", "ss", "statusline", "suffixesadd", "sws", "tabline", "taglength", "tbidi", "termbidi", "terse", "tgst", "titleold", "top", "ttimeoutlen", "ttyscroll", "tx", "undolevels", "vartabstop", "vfile", "virtualedit", "warn", "wfh", "wildchar", "wim", "winminheight", "wmh", "write", "akm", "antialias", "autoindent", "backup", "balloonexpr", "bg", "bomb", "bs", "cb", "ch", "cinoptions", "cms", "commentstring", "conceallevel", "cpt", "cscopetagorder", "csto", "cursorlineopt", "dg", "dir", "ed", "enc", "errorfile", "fcl", "fdn", "ffs", "fillchars", "fo", "foldmarker", "formatoptions", "gdefault", "grepformat", "guiheadroom", "hf", "hkmap", "icon", "imc", "imsf", "inde", "is", "isprint", "kmp", "lbr", "listchars", "lsp", "makeencoding", "maxmem", "mh", "mmp", "more", "mouseshape", "mzschemedll", "odev", "pa", "path", "pheader", "previewheight", "printmbcharset", "pvp", "pyxversion", "relativenumber", "rightleftcmd", "ru", "sbr", "scrollfocus", "secure", "shcf", "shelltemp", "shortmess", "showtabline", "sj", "smd", "spell", "splitbelow", "ssl", "stl", "sw", "sxe", "tabpagemax", "tagrelative", "tbis", "termencoding", "textauto", "thesaurus", "titlestring", "tpm", "ttm", "ttytype", "uc", "undoreload", "vb", "vi", "visualbell", "wb", "wfw", "wildcharm", "winaltkeys", "winminwidth", "wmnu", "writeany", "al", "ar", "autoread", "backupcopy", "bdir", "bh", "breakat", "bsdir", "cc", "charconvert", "cinw", "co", "compatible", "confirm", "crb", "cscopeverbose", "csverb", "cwh", "dict", "directory", "edcompatible", "encoding", "errorformat", "fcs", "fdo", "fic", "fixendofline", "foldclose", "foldmethod", "formatprg", "gfm", "grepprg", "guioptions", "hh", "hkmapp", "iconstring", "imcmdline", "imst", "indentexpr", "isf", "joinspaces", "kp", "lcs", "lm", "luadll", "makeprg", "maxmempattern", "mis", "mmt", "mouse", "mouset", "mzschemegcdll", "oft", "packpath", "pdev", "pi", "previewpopup", "printmbfont", "pvw", "qe", "remap", "rl", "rubydll", "sc", "scrolljump", "sel", "shell", "shelltype", "shortname", "shq", "slm", "sn", "spellcapcheck", "splitright", "ssop", "stmp", "swapfile", "sxq", "tabstop", "tags", "tbs", "termguicolors", "textmode", "tildeop", "tl", "tr", "tty", "tw", "udf", "updatecount", "vbs", "viewdir", "vop", "wc", "wh", "wildignore", "wincolor", "winptydll", "wmw", "writebackup", "aleph", "arab", "autowrite", "backupdir", "bdlay", "bin", "breakindent", "bsk", "ccv", "ci", "cinwords", "cocu", "complete", "copyindent", "cryptmethod", "csl", "cuc", "debug", "dictionary", "display", "ef", "endofline", "esckeys", "fdc", "fdt", "fileencoding", "fixeol", "foldcolumn", "foldminlines", "fp", "gfn", "gtl", "guipty", "hi", "hkp", "ignorecase", "imd", "imstatusfunc", "indentkeys", "isfname", "js", "langmap", "linebreak", "lmap", "lw", "mat", "maxmemtot", "mkspellmem", "mod", "mousef", "mousetime", "nf", "ofu", "para", "penc", "pm", "previewwindow", "printoptions", "pw", "quoteescape", "renderoptions", "rlc", "ruf", "scb", "scrolloff", "selection", "shellcmdflag", "shellxescape", "showbreak", "si", "sm", "so", "spellfile", "spr", "st", "sts", "swapsync", "syn", "tag", "tagstack", "tc", "termwinkey", "textwidth", "timeout", "tm", "ts", "ttybuiltin", "twk", "udir", "updatetime", "vdir", "viewoptions", "vsts", "wcm", "whichwrap", "wildignorecase", "window", "winwidth", "wop", "writedelay", "allowrevins", "arabic", "autowriteall", "backupext", "belloff", "binary", "breakindentopt", "bt", "cd", "cin", "clipboard", "cole", "completefunc", "cot", "cscopepathcomp", "cspc", "cul", "deco", "diff", "dy", "efm", "eol", "et", "fde", "fen", "fileencodings", "fk", "foldenable", "foldnestmax", "fs", "gfs", "gtt", "guitablabel", "hid", "hl", "im", "imdisable", "imstyle", "indk", "isi", "key", "langmenu", "lines", "lnr", "lz", "matchpairs", "mco", "ml", "modeline", "mousefocus", "mp", "nrformats", "omnifunc", "paragraphs", "perldll", "pmbcs", "printdevice", "prompt", "pythondll", "rdt", "report", "rnu", "ruler", "scf", "scrollopt", "selectmode", "shellpipe", "shellxquote", "showcmd", "sidescroll", "smartcase", "softtabstop", "spelllang", "sps", "sta", "su", "swb", "synmaxcol", "tagbsearch", "tal", "tcldll", "termwinscroll", "tf", "timeoutlen", "to", "tsl", "ttyfast", "tws", "ul", "ur", "ve", "vif", "vts", "wcr", "wi", "wildmenu", "winfixheight", "wiv", "wrap", "ws", "altkeymap", "arabicshape", "aw", "backupskip", "beval", "bk", "bri", "bufhidden", "cdpath", "cindent", "cm", "colorcolumn", "completeopt", "cp", "cscopeprg", "csprg", "culopt", "def", "diffexpr", "ea", "ei", "ep", "eventignore", "fdi", "fenc", "fileformat", "fkmap", "foldexpr", "foldopen", "fsync", "gfw", "guicursor", "guitabtooltip", "hidden", "hlg", "imactivatefunc", "imi", "inc", "inex", "isident", "keymap", "langnoremap", "linespace", "loadplugins", "ma", "matchtime", "mef", "mle", "modelineexpr", "mousehide", "mps", "nu", "opendevice", "paste", "pex", "pmbfn", "printencoding", "pt", "pythonhome", "re", "restorescreen", "ro", "rulerformat", "scl", "scs", "sessionoptions", "shellquote", "shiftround", "showfulltag", "sidescrolloff", "smartindent", "sol", "spellsuggest", "sr", "stal", "sua", "swf", "syntax", "tagcase", "tb", "tenc", "termwinsize", "tfu", "title", "toolbar", "tsr", "ttym", "twsl", "undodir", "ut", "verbose", "viminfo", "wa", "wd", "wic", "wildmode", "winfixwidth", "wiw", "wrapmargin", "ww", "ambiwidth", "ari", "awa", "balloondelay", "bevalterm", "bkc", "briopt", "buflisted", "cedit", "cink", "cmdheight", "columns", "completepopup", "cpo", "cscopequickfix", "csqf", "cursorbind", "define", "diffopt", "ead", "ek", "equalalways", "ex", "fdl", "fencs", "fileformats", "flp", "foldignore", "foldtext", "ft", "ghr", "guifont", "helpfile", "highlight", "hls", "imactivatekey", "iminsert", "include", "inf", "isk", "keymodel", "langremap", "lisp", "lpl", "macatsui", "maxcombine", "menc", "mls", "modelines", "mousem", "msm", "number", "operatorfunc", "pastetoggle", "pexpr", "popt", "printexpr", "pumheight", "pythonthreedll", "readonly", "revins", "rop", "runtimepath", "scr", "noacd", "noallowrevins", "noantialias", "noarabic", "noarshape", "noautoread", "noaw", "noballooneval", "nobevalterm", "nobk", "nobreakindent", "nocf", "nocindent", "nocopyindent", "nocscoperelative", "nocsre", "nocuc", "nocursorcolumn", "nodelcombine", "nodigraph", "noed", "noemo", "noeol", "noesckeys", "noexpandtab", "nofic", "nofixeol", "nofoldenable", "nogd", "nohid", "nohkmap", "nohls", "noicon", "noimc", "noimdisable", "noinfercase", "nojoinspaces", "nolangremap", "nolinebreak", "nolnr", "nolrm", "nomacatsui", "noml", "nomod", "nomodelineexpr", "nomodified", "nomousef", "nomousehide", "nonumber", "noopendevice", "nopi", "nopreviewwindow", "nopvw", "norelativenumber", "norestorescreen", "nori", "norl", "noro", "noru", "nosb", "noscb", "noscrollbind", "noscs", "nosft", "noshelltemp", "noshortname", "noshowfulltag", "noshowmode", "nosm", "nosmartindent", "nosmd", "nosol", "nosplitbelow", "nospr", "nossl", "nostartofline", "noswapfile", "nota", "notagrelative", "notbi", "notbs", "noterse", "notextmode", "notgst", "notimeout", "noto", "notr", "nottybuiltin", "notx", "noundofile", "novisualbell", "nowarn", "noweirdinvert", "nowfw", "nowildignorecase", "nowinfixheight", "nowiv", "nowrap", "nowrite", "nowritebackup", "noai", "noaltkeymap", "noar", "noarabicshape", "noautochdir", "noautowrite", "noawa", "noballoonevalterm", "nobin", "nobl", "nobri", "noci", "nocompatible", "nocp", "nocscopetag", "nocst", "nocul", "nocursorline", "nodg", "noea", "noedcompatible", "noemoji", "noequalalways", "noet", "noexrc", "nofileignorecase", "nofk", "nofs", "nogdefault", "nohidden", "nohkmapp", "nohlsearch", "noignorecase", "noimcmdline", "noincsearch", "noinsertmode", "nojs", "nolazyredraw", "nolisp", "noloadplugins", "nolz", "nomagic", "nomle", "nomodeline", "nomodifiable", "nomore", "nomousefocus", "nonu", "noodev", "nopaste", "nopreserveindent", "noprompt", "noreadonly", "noremap", "norevins", "norightleft", "nornu", "nors", "noruler", "nosc", "noscf", "noscrollfocus", "nosecure", "noshellslash", "noshiftround", "noshowcmd", "noshowmatch", "nosi", "nosmartcase", "nosmarttab", "nosn", "nospell", "nosplitright", "nosr", "nosta", "nostmp", "noswf", "notagbsearch", "notagstack", "notbidi", "notermbidi", "notextauto", "notf", "notildeop", "notitle", "notop", "nottimeout", "nottyfast", "noudf", "novb", "nowa", "nowb", "nowfh", "nowic", "nowildmenu", "nowinfixwidth", "nowmnu", "nowrapscan", "nowriteany", "nows", "noakm", "noanti", "noarab", "noari", "noautoindent", "noautowriteall", "nobackup", "nobeval", "nobinary", "nobomb", "nobuflisted", "nocin", "noconfirm", "nocrb", "nocscopeverbose", "nocsverb", "nocursorbind", "nodeco", "nodiff", "noeb", "noek", "noendofline", "noerrorbells", "noex", "nofen", "nofixendofline", "nofkmap", "nofsync", "noguipty", "nohk", "nohkp", "noic", "noim", "noimd", "noinf", "nois", "nolangnoremap", "nolbr", "nolist", "nolpl", "noma", "nomh", "invacd", "invallowrevins", "invantialias", "invarabic", "invarshape", "invautoread", "invaw", "invballooneval", "invbevalterm", "invbk", "invbreakindent", "invcf", "invcindent", "invcopyindent", "invcscoperelative", "invcsre", "invcuc", "invcursorcolumn", "invdelcombine", "invdigraph", "inved", "invemo", "inveol", "invesckeys", "invexpandtab", "invfic", "invfixeol", "invfoldenable", "invgd", "invhid", "invhkmap", "invhls", "invicon", "invimc", "invimdisable", "invinfercase", "invjoinspaces", "invlangremap", "invlinebreak", "invlnr", "invlrm", "invmacatsui", "invml", "invmod", "invmodelineexpr", "invmodified", "invmousef", "invmousehide", "invnumber", "invopendevice", "invpi", "invpreviewwindow", "invpvw", "invrelativenumber", "invrestorescreen", "invri", "invrl", "invro", "invru", "invsb", "invscb", "invscrollbind", "invscs", "invsft", "invshelltemp", "invshortname", "invshowfulltag", "invshowmode", "invsm", "invsmartindent", "invsmd", "invsol", "invsplitbelow", "invspr", "invssl", "invstartofline", "invswapfile", "invta", "invtagrelative", "invtbi", "invtbs", "invterse", "invtextmode", "invtgst", "invtimeout", "invto", "invtr", "invttybuiltin", "invtx", "invundofile", "invvisualbell", "invwarn", "invweirdinvert", "invwfw", "invwildignorecase", "invwinfixheight", "invwiv", "invwrap", "invwrite", "invwritebackup", "invai", "invaltkeymap", "invar", "invarabicshape", "invautochdir", "invautowrite", "invawa", "invballoonevalterm", "invbin", "invbl", "invbri", "invci", "invcompatible", "invcp", "invcscopetag", "invcst", "invcul", "invcursorline", "invdg", "invea", "invedcompatible", "invemoji", "invequalalways", "invet", "invexrc", "invfileignorecase", "invfk", "invfs", "invgdefault", "invhidden", "invhkmapp", "invhlsearch", "invignorecase", "invimcmdline", "invincsearch", "invinsertmode", "invjs", "invlazyredraw", "invlisp", "invloadplugins", "invlz", "invmagic", "invmle", "invmodeline", "invmodifiable", "invmore", "invmousefocus", "invnu", "invodev", "invpaste", "invpreserveindent", "invprompt", "invreadonly", "invremap", "invrevins", "invrightleft", "invrnu", "invrs", "invruler", "invsc", "invscf", "invscrollfocus", "invsecure", "invshellslash", "invshiftround", "invshowcmd", "invshowmatch", "invsi", "invsmartcase", "invsmarttab", "invsn", "invspell", "invsplitright", "invsr", "invsta", "invstmp", "invswf", "invtagbsearch", "invtagstack", "invtbidi", "invtermbidi", "invtextauto", "invtf", "invtildeop", "invtitle", "invtop", "invttimeout", "invttyfast", "invudf", "invvb", "invwa", "invwb", "invwfh", "invwic", "invwildmenu", "invwinfixwidth", "invwmnu", "invwrapscan", "invwriteany", "invws", "invakm", "invanti", "invarab", "invari", "invautoindent", "invautowriteall", "invbackup", "invbeval", "invbinary", "invbomb", "invbuflisted", "invcin", "invconfirm", "invcrb", "invcscopeverbose", "invcsverb", "invcursorbind", "invdeco", "invdiff", "inveb", "invek", "invendofline", "inverrorbells", "invex", "invfen", "invfixendofline", "invfkmap", "invfsync", "invguipty", "invhk", "invhkp", "invic", "invim", "invimd", "invinf", "invis", "invlangnoremap", "invlbr", "invlist", "invlpl", "invma", "invmh", "t_8b", "t_AB", "t_al", "t_bc", "t_BE", "t_ce", "t_cl", "t_Co", "t_Cs", "t_CV", "t_db", "t_DL", "t_EI", "t_F2", "t_F4", "t_F6", "t_F8", "t_fs", "t_IE", "t_k1", "t_k2", "t_K3", "t_K4", "t_K5", "t_K6", "t_K7", "t_K8", "t_K9", "t_kb", "t_KB", "t_kd", "t_KD", "t_ke", "t_KE", "t_KF", "t_KG", "t_kh", "t_KH", "t_kI", "t_KI", "t_KJ", "t_KK", "t_kl", "t_KL", "t_kN", "t_kP", "t_kr", "t_ks", "t_ku", "t_le", "t_mb", "t_md", "t_me", "t_mr", "t_ms", "t_nd", "t_op", "t_PE", "t_PS", "t_RB", "t_RC", "t_RF", "t_Ri", "t_RI", "t_RS", "t_RT", "t_RV", "t_Sb", "t_SC", "t_se", "t_Sf", "t_SH", "t_Si", "t_SI", "t_so", "t_sr", "t_SR", "t_ST", "t_te", "t_Te", "t_TE", "t_ti", "t_TI", "t_ts", "t_Ts", "t_u7", "t_ue", "t_us", "t_ut", "t_vb", "t_ve", "t_vi", "t_vs", "t_VS", "t_WP", "t_WS", "t_xn", "t_xs", "t_ZH", "t_ZR", "t_8f", "t_AF", "t_AL", "t_BD", "t_cd", "t_Ce", "t_cm", "t_cs", "t_CS", "t_da", "t_dl", "t_EC", "t_F1", "t_F3", "t_F5", "t_F7", "t_F9", "t_GP", "t_IS", "t_K1", "t_k3", "t_k4", "t_k5", "t_k6", "t_k7", "t_k8", "t_k9", "t_KA", "t_kB", "t_KC", "t_kD"] + kw[:auto] = Set.new ["BufAdd", "BufDelete", "BufFilePost", "BufHidden", "BufNew", "BufRead", "BufReadPost", "BufUnload", "BufWinEnter", "BufWinLeave", "BufWipeout", "BufWrite", "BufWriteCmd", "BufWritePost", "BufWritePre", "CmdlineChanged", "CmdlineEnter", "CmdlineLeave", "CmdUndefined", "CmdwinEnter", "CmdwinLeave", "ColorScheme", "ColorSchemePre", "CompleteChanged", "CompleteDone", "CompleteDonePre", "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI", "DiffUpdated", "DirChanged", "EncodingChanged", "ExitPre", "FileAppendCmd", "FileAppendPost", "FileAppendPre", "FileChangedRO", "FileChangedShell", "FileChangedShellPost", "FileEncoding", "FileReadCmd", "FileReadPost", "FileReadPre", "FileType", "FileWriteCmd", "FileWritePost", "FileWritePre", "FilterReadPost", "FilterReadPre", "FilterWritePost", "FilterWritePre", "FocusGained", "FocusLost", "FuncUndefined", "GUIEnter", "GUIFailed", "InsertChange", "InsertCharPre", "InsertEnter", "InsertLeave", "MenuPopup", "OptionSet", "QuickFixCmdPost", "QuickFixCmdPre", "QuitPre", "RemoteReply", "SafeState", "SafeStateAgain", "SessionLoadPost", "ShellCmdPost", "ShellFilterPost", "SourceCmd", "SourcePost", "SourcePre", "SpellFileMissing", "StdinReadPost", "StdinReadPre", "SwapExists", "Syntax", "TabClosed", "TabEnter", "TabLeave", "TabNew", "TermChanged", "TerminalOpen", "TerminalWinOpen", "TermResponse", "TextChanged", "TextChangedI", "TextChangedP", "TextYankPost", "User", "VimEnter", "VimLeave", "VimLeavePre", "VimResized", "WinEnter", "WinLeave", "WinNew", "BufCreate", "BufEnter", "BufFilePre", "BufLeave", "BufNewFile", "BufReadCmd", "BufReadPre"] + kw[:function] = Set.new ["abs", "appendbufline", "asin", "assert_fails", "assert_notmatch", "balloon_gettext", "bufadd", "bufname", "byteidx", "char2nr", "ch_evalexpr", "ch_log", "ch_readraw", "cindent", "complete_check", "cosh", "deepcopy", "diff_hlID", "eval", "exists", "feedkeys", "findfile", "fnamemodify", "foldtextresult", "get", "getchar", "getcmdtype", "getenv", "getftype", "getmatches", "getreg", "gettagstack", "getwinvar", "has_key", "histget", "iconv", "inputlist", "interrupt", "isnan", "job_start", "js_encode", "libcall", "list2str", "log", "mapcheck", "matchdelete", "max", "nextnonblank", "popup_atcursor", "popup_dialog", "popup_getoptions", "popup_notification", "prevnonblank", "prop_add", "prop_type_add", "pum_getpos", "rand", "reg_recording", "remote_foreground", "remove", "round", "screencol", "searchdecl", "serverlist", "setenv", "setpos", "settagstack", "sign_define", "sign_placelist", "sin", "sound_playevent", "split", "str2list", "strftime", "strpart", "submatch", "synID", "systemlist", "taglist", "term_dumpload", "term_getcursor", "term_getstatus", "term_sendkeys", "term_setsize", "test_autochdir", "test_getvalue", "test_null_dict", "test_null_string", "test_scrollbar", "test_unknown", "timer_start", "toupper", "type", "values", "winbufnr", "win_findbuf", "winheight", "winline", "winsaveview", "winwidth", "acos", "argc", "assert_beeps", "assert_false", "assert_report", "balloon_show", "bufexists", "bufnr", "byteidxcomp", "ch_canread", "ch_evalraw", "ch_logfile", "ch_sendexpr", "clearmatches", "complete_info", "count", "delete", "echoraw", "eventhandler", "exp", "filereadable", "float2nr", "foldclosed", "foreground", "getbufinfo", "getcharmod", "getcmdwintype", "getfontname", "getimstatus", "getmousepos", "getregtype", "getwininfo", "glob", "haslocaldir", "histnr", "indent", "inputrestore", "invert", "items", "job_status", "json_decode", "libcallnr", "listener_add", "log10", "match", "matchend", "min", "nr2char", "popup_beval", "popup_filter_menu", "popup_getpos", "popup_setoptions", "printf", "prop_clear", "prop_type_change", "pumvisible", "range", "reltime", "remote_peek", "rename", "rubyeval", "screenpos", "searchpair", "setbufline", "setfperm", "setqflist", "setwinvar", "sign_getdefined", "sign_undefine", "sinh", "sound_playfile", "sqrt", "str2nr", "strgetchar", "strptime", "substitute", "synIDattr", "tabpagebuflist", "tan", "term_dumpwrite", "term_getjob", "term_gettitle", "term_setansicolors", "term_start", "test_feedinput", "test_ignore_error", "test_null_job", "test_option_not_set", "test_setmouse", "test_void", "timer_stop", "tr", "undofile", "virtcol", "wincol", "win_getid", "win_id2tabwin", "winnr", "win_screenpos", "wordcount", "add", "argidx", "assert_equal", "assert_inrange", "assert_true", "balloon_split", "buflisted", "bufwinid", "call", "ch_close", "ch_getbufnr", "ch_open", "ch_sendraw", "col", "confirm", "cscope_connection", "deletebufline", "empty", "executable", "expand", "filewritable", "floor", "foldclosedend", "funcref", "getbufline", "getcharsearch", "getcompletion", "getfperm", "getjumplist", "getpid", "gettabinfo", "getwinpos", "glob2regpat", "hasmapto", "hlexists", "index", "inputsave", "isdirectory", "job_getchannel", "job_stop", "json_encode", "line", "listener_flush", "luaeval", "matchadd", "matchlist", "mkdir", "or", "popup_clear", "popup_filter_yesno", "popup_hide", "popup_settext", "prompt_setcallback", "prop_find", "prop_type_delete", "py3eval", "readdir", "reltimefloat", "remote_read", "repeat", "screenattr", "screenrow", "searchpairpos", "setbufvar", "setline", "setreg", "sha256", "sign_getplaced", "sign_unplace", "sort", "sound_stop", "srand", "strcharpart", "stridx", "strridx", "swapinfo", "synIDtrans", "tabpagenr", "tanh", "term_getaltscreen", "term_getline", "term_gettty", "term_setapi", "term_wait", "test_garbagecollect_now", "test_null_blob", "test_null_list", "test_override", "test_settime", "timer_info", "timer_stopall", "trim", "undotree", "visualmode", "windowsversion", "win_gettype", "win_id2win", "winrestcmd", "win_splitmove", "writefile", "and", "arglistid", "assert_equalfile", "assert_match", "atan", "browse", "bufload", "bufwinnr", "ceil", "ch_close_in", "ch_getjob", "ch_read", "ch_setoptions", "complete", "copy", "cursor", "did_filetype", "environ", "execute", "expandcmd", "filter", "fmod", "foldlevel", "function", "getbufvar", "getcmdline", "getcurpos", "getfsize", "getline", "getpos", "gettabvar", "getwinposx", "globpath", "histadd", "hlID", "input", "inputsecret", "isinf", "job_info", "join", "keys", "line2byte", "listener_remove", "map", "matchaddpos", "matchstr", "mode", "pathshorten", "popup_close", "popup_findinfo", "popup_menu", "popup_show", "prompt_setinterrupt", "prop_list", "prop_type_get", "pyeval", "readfile", "reltimestr", "remote_send", "resolve", "screenchar", "screenstring", "searchpos", "setcharsearch", "setloclist", "settabvar", "shellescape", "sign_jump", "sign_unplacelist", "sound_clear", "spellbadword", "state", "strchars", "string", "strtrans", "swapname", "synstack", "tabpagewinnr", "tempname", "term_getansicolors", "term_getscrolled", "term_list", "term_setkill", "test_alloc_fail", "test_garbagecollect_soon", "test_null_channel", "test_null_partial", "test_refcount", "test_srand_seed", "timer_pause", "tolower", "trunc", "uniq", "wildmenumode", "win_execute", "win_gotoid", "winlayout", "winrestview", "win_type", "xor", "append", "argv", "assert_exception", "assert_notequal", "atan2", "browsedir", "bufloaded", "byte2line", "changenr", "chdir", "ch_info", "ch_readblob", "ch_status", "complete_add", "cos", "debugbreak", "diff_filler", "escape", "exepath", "extend", "finddir", "fnameescape", "foldtext", "garbagecollect", "getchangelist", "getcmdpos", "getcwd", "getftime", "getloclist", "getqflist", "gettabwinvar", "getwinposy", "has", "histdel", "hostname", "inputdialog", "insert", "islocked", "job_setoptions", "js_decode", "len", "lispindent", "localtime", "maparg", "matcharg", "matchstrpos", "mzeval", "perleval", "popup_create", "popup_findpreview", "popup_move", "pow", "prompt_setprompt", "prop_remove", "prop_type_list", "pyxeval", "reg_executing", "remote_expr", "remote_startserver", "reverse", "screenchars", "search", "server2client", "setcmdpos", "setmatches", "settabwinvar", "shiftwidth", "sign_place", "simplify", "soundfold", "spellsuggest", "str2float", "strdisplaywidth", "strlen", "strwidth", "synconcealed", "system", "tagfiles", "term_dumpdiff", "term_getattr", "term_getsize", "term_scrape", "term_setrestore"] + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vue.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vue.rb new file mode 100644 index 0000000..5b64f3d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/vue.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'html.rb' + + class Vue < HTML + desc 'Vue.js single-file components' + tag 'vue' + aliases 'vuejs' + filenames '*.vue' + + mimetypes 'text/x-vue', 'application/x-vue' + + def initialize(*) + super + @js = Javascript.new(options) + end + + def lookup_lang(lang) + lang.downcase! + lang = lang.gsub(/["']*/, '') + case lang + when 'html' then HTML + when 'css' then CSS + when 'javascript' then Javascript + when 'sass' then Sass + when 'scss' then Scss + when 'coffee' then Coffeescript + # TODO: add more when the lexers are done + else + PlainText + end + end + + start { @js.reset! } + + prepend :root do + rule %r/(<)(\s*)(template)/ do + groups Name::Tag, Text, Keyword + @lang = HTML + push :template + push :lang_tag + end + + rule %r/(<)(\s*)(style)/ do + groups Name::Tag, Text, Keyword + @lang = CSS + push :style + push :lang_tag + end + + rule %r/(<)(\s*)(script)/ do + groups Name::Tag, Text, Keyword + @lang = Javascript + push :script + push :lang_tag + end + end + + prepend :tag do + rule %r/[a-zA-Z0-9_:#\[\]()*.-]+\s*=\s*/m, Name::Attribute, :attr + end + + state :style do + rule %r/(<\s*\/\s*)(style)(\s*>)/ do + groups Name::Tag, Keyword, Name::Tag + pop! + end + + mixin :style_content + mixin :embed + end + + state :script do + rule %r/(<\s*\/\s*)(script)(\s*>)/ do + groups Name::Tag, Keyword, Name::Tag + pop! + end + + mixin :script_content + mixin :embed + end + + state :lang_tag do + rule %r/(lang\s*=)(\s*)("(?:\\.|[^\\])*?"|'(\\.|[^\\])*?'|[^\s>]+)/ do |m| + groups Name::Attribute, Text, Str + @lang = lookup_lang(m[3]) + end + + mixin :tag + end + + state :template do + rule %r((<\s*/\s*)(template)(\s*>)) do + groups Name::Tag, Keyword, Name::Tag + pop! + end + + rule %r/{{/ do + token Str::Interpol + push :template_interpol + @js.reset! + end + + mixin :embed + end + + state :template_interpol do + rule %r/}}/, Str::Interpol, :pop! + rule %r/}/, Error + mixin :template_interpol_inner + end + + state :template_interpol_inner do + rule(/{/) { delegate @js; push } + rule(/}/) { delegate @js; pop! } + rule(/[^{}]+/) { delegate @js } + end + + state :embed do + rule(/[^{<]+/) { delegate @lang } + rule(/[<{][^<{]*/) { delegate @lang } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/wollok.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/wollok.rb new file mode 100644 index 0000000..5f46176 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/wollok.rb @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Wollok < RegexLexer + title 'Wollok' + desc 'Wollok lang' + tag 'wollok' + filenames '*.wlk', '*.wtest', '*.wpgm' + + keywords = %w(new super return if else var const override constructor) + + entity_name = /[a-zA-Z][a-zA-Z0-9]*/ + variable_naming = /_?#{entity_name}/ + + state :whitespaces_and_comments do + rule %r/\s+/m, Text::Whitespace + rule %r(//.*$), Comment::Single + rule %r(/\*(.|\s)*?\*/)m, Comment::Multiline + end + + state :root do + mixin :whitespaces_and_comments + rule %r/(import)(.+$)/ do + groups Keyword::Reserved, Text + end + rule %r/(class|object|mixin)/, Keyword::Reserved, :foo + rule %r/test|program/, Keyword::Reserved #, :chunk_naming + rule %r/(package)(\s+)(#{entity_name})/ do + groups Keyword::Reserved, Text::Whitespace, Name::Class + end + rule %r/{|}/, Text + mixin :keywords + mixin :symbols + mixin :objects + end + + state :foo do + mixin :whitespaces_and_comments + rule %r/inherits|mixed|with|and/, Keyword::Reserved + rule %r/#{entity_name}(?=\s*{)/ do |m| + token Name::Class + entities << m[0] + pop! + end + rule %r/#{entity_name}/ do |m| + token Name::Class + entities << m[0] + end + end + + state :keywords do + def any(expressions) + /#{expressions.map { |keyword| "#{keyword}\\b" }.join('|')}/ + end + + rule %r/self\b/, Name::Builtin::Pseudo + rule any(keywords), Keyword::Reserved + rule %r/(method)(\s+)(#{variable_naming})/ do + groups Keyword::Reserved, Text::Whitespace, Text + end + end + + state :objects do + rule variable_naming do |m| + variable = m[0] + if entities.include?(variable) || ('A'..'Z').cover?(variable[0]) + token Name::Class + else + token Keyword::Variable + end + end + rule %r/\.#{entity_name}/, Text + mixin :literals + end + + state :literals do + mixin :whitespaces_and_comments + rule %r/[0-9]+\.?[0-9]*/, Literal::Number + rule %r/"[^"]*"/m, Literal::String + rule %r/\[|\#{/, Punctuation, :lists + end + + state :lists do + rule %r/,/, Punctuation + rule %r/]|}/, Punctuation, :pop! + mixin :objects + end + + state :symbols do + rule %r/\+\+|--|\+=|-=|\*\*|!/, Operator + rule %r/\+|-|\*|\/|%/, Operator + rule %r/<=|=>|===|==|<|>/, Operator + rule %r/and\b|or\b|not\b/, Operator + rule %r/\(|\)|=/, Text + rule %r/,/, Punctuation + end + + private + + def entities + @entities ||= [] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xml.rb new file mode 100644 index 0000000..e313e02 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xml.rb @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class XML < RegexLexer + title "XML" + desc %q(XML) + tag 'xml' + filenames '*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl', '*.svg', + '*.plist' + mimetypes 'text/xml', 'application/xml', 'image/svg+xml', + 'application/rss+xml', 'application/atom+xml' + + # Documentation: https://www.w3.org/TR/xml11/#charsets and https://www.w3.org/TR/xml11/#sec-suggested-names + + def self.detect?(text) + return false if text.doctype?(/html/) + return true if text =~ /\A<\?xml\b/ + return true if text.doctype? + end + + state :root do + rule %r/[^<&]+/, Text + rule %r/&\S*?;/, Name::Entity + rule %r//, Comment::Preproc + rule %r//, Comment, :pop! + rule %r/-/, Comment + end + + state :tag do + rule %r/\s+/m, Text + rule %r/[\p{L}:_][\p{Word}\p{Cf}:.·-]*\s*=/m, Name::Attribute, :attr + rule %r(/?\s*>), Name::Tag, :pop! + end + + state :attr do + rule %r/\s+/m, Text + rule %r/".*?"|'.*?'|[^\s>]+/m, Str, :pop! + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xojo.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xojo.rb new file mode 100644 index 0000000..6c7d013 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xojo.rb @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Xojo < RegexLexer + title "Xojo" + desc "Xojo" + tag 'xojo' + aliases 'realbasic' + filenames '*.xojo_code', '*.xojo_window', '*.xojo_toolbar', '*.xojo_menu', '*.xojo_image', '*.rbbas', '*.rbfrm', '*.rbmnu', '*.rbres', '*.rbtbar' + + keywords = %w( + addhandler aggregates array asc assigns attributes begin break + byref byval call case catch class const continue color ctype declare + delegate dim do downto each else elseif end enum event exception + exit extends false finally for function global goto if + implements inherits interface lib loop mod module + new next nil object of optional paramarray + private property protected public raise raiseevent rect redim + removehandler return select shared soft static step sub super + then to true try until using var wend while + ) + + keywords_type = %w( + boolean byte cfstringref cgfloat cstring currency date datetime double int8 int16 + int32 int64 integer ostype pair pstring ptr short single + string structure variant uinteger uint8 uint16 uint32 uint64 + ushort windowptr wstring + ) + + operator_words = %w( + addressof weakaddressof and as in is isa mod not or xor + ) + + state :root do + rule %r/\s+/, Text::Whitespace + + rule %r/rem\b.*?$/i, Comment::Single + rule %r((?://|').*$), Comment::Single + rule %r/\#tag Note.*?\#tag EndNote/mi, Comment::Preproc + rule %r/\s*[#].*$/x, Comment::Preproc + + rule %r/".*?"/, Literal::String::Double + rule %r/[(){}!#,:]/, Punctuation + + rule %r/\b(?:#{keywords.join('|')})\b/i, Keyword + rule %r/\b(?:#{keywords_type.join('|')})\b/i, Keyword::Declaration + + rule %r/\b(?:#{operator_words.join('|')})\b/i, Operator + rule %r/[+-]?(\d+\.\d*|\d*\.\d+)/i, Literal::Number::Float + rule %r/[+-]?\d+/, Literal::Number::Integer + rule %r/&[CH][0-9a-f]+/i, Literal::Number::Hex + rule %r/&O[0-7]+/i, Literal::Number::Oct + + rule %r/\b[\w\.]+\b/i, Text + rule(%r(<=|>=|<>|[=><\+\-\*\/\\]), Operator) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xpath.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xpath.rb new file mode 100644 index 0000000..fb1d4a4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xpath.rb @@ -0,0 +1,332 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class XPath < RegexLexer + title 'XPath' + desc 'XML Path Language (XPath) 3.1' + tag 'xpath' + filenames '*.xpath' + + # Terminal literals: + # https://www.w3.org/TR/xpath-31/#terminal-symbols + def self.digits + @digits ||= %r/[0-9]+/ + end + + def self.decimalLiteral + @decimalLiteral ||= %r/\.#{digits}|#{digits}\.[0-9]*/ + end + + def self.doubleLiteral + @doubleLiteral ||= %r/(\.#{digits})|#{digits}(\.[0-9]*)?[eE][+-]?#{digits}/ + end + + def self.stringLiteral + @stringLiteral ||= %r/("(("")|[^"])*")|('(('')|[^'])*')/ + end + + def self.ncName + @ncName ||= %r/[a-z_][a-z_\-.0-9]*/i + end + + def self.qName + @qName ||= %r/(?:#{ncName})(?::#{ncName})?/ + end + + def self.uriQName + @uriQName ||= %r/Q\{[^{}]*\}#{ncName}/ + end + + def self.eqName + @eqName ||= %r/(?:#{uriQName}|#{qName})/ + end + + def self.commentStart + @commentStart ||= %r/\(:/ + end + + def self.openParen + @openParen ||= %r/\((?!:)/ + end + + # Terminal symbols: + # https://www.w3.org/TR/xpath-30/#id-terminal-delimitation + def self.kindTest + @kindTest ||= Regexp.union %w( + element attribute schema-element schema-attribute + comment text node document-node namespace-node + ) + end + + def self.kindTestForPI + @kindTestForPI ||= Regexp.union %w(processing-instruction) + end + + def self.axes + @axes ||= Regexp.union %w( + child descendant attribute self descendant-or-self + following-sibling following namespace + parent ancestor preceding-sibling preceding ancestor-or-self + ) + end + + def self.operators + @operators ||= Regexp.union %w(, => = := : >= >> > <= << < - * != + // / || |) + end + + def self.keywords + @keywords ||= Regexp.union %w(let for some every if then else return in satisfies) + end + + def self.word_operators + @word_operators ||= Regexp.union %w( + and or eq ge gt le lt ne is + div mod idiv + intersect except union + to + ) + end + + def self.constructorTypes + @constructorTypes ||= Regexp.union %w(function array map empty-sequence) + end + + # Mixin states: + + state :commentsAndWhitespace do + rule XPath.commentStart, Comment, :comment + rule %r/\s+/m, Text::Whitespace + end + + # Lexical states: + # https://www.w3.org/TR/xquery-xpath-parsing/#XPath-lexical-states + # https://lists.w3.org/Archives/Public/public-qt-comments/2004Aug/0127.html + # https://www.w3.org/TR/xpath-30/#id-revision-log + # https://www.w3.org/TR/xpath-31/#id-revision-log + + state :root do + mixin :commentsAndWhitespace + + # Literals + rule XPath.doubleLiteral, Num::Float + rule XPath.decimalLiteral, Num::Float + rule XPath.digits, Num + rule XPath.stringLiteral, Literal::String + + # Variables + rule %r/\$/, Name::Variable, :varname + + # Operators + rule XPath.operators, Operator + rule %r/#{XPath.word_operators}\b/, Operator::Word + rule %r/#{XPath.keywords}\b/, Keyword + rule %r/[?,{}()\[\]]/, Punctuation + + # Functions + rule %r/(function)(\s*)(#{XPath.openParen})/ do # function declaration + groups Keyword, Text::Whitespace, Punctuation + end + rule %r/(map|array|empty-sequence)/, Keyword # constructors + rule %r/(#{XPath.kindTest})(\s*)(#{XPath.openParen})/ do # kindtest + groups Keyword, Text::Whitespace, Punctuation + push :kindtest + end + rule %r/(#{XPath.kindTestForPI})(\s*)(#{XPath.openParen})/ do # processing instruction kindtest + groups Keyword, Text::Whitespace, Punctuation + push :kindtestforpi + end + rule %r/(#{XPath.eqName})(\s*)(#{XPath.openParen})/ do # function call + groups Name::Function, Text::Whitespace, Punctuation + end + rule %r/(#{XPath.eqName})(\s*)(#)(\s*)(\d+)/ do # namedFunctionRef + groups Name::Function, Text::Whitespace, Name::Function, Text::Whitespace, Name::Function + end + + # Type commands + rule %r/(cast|castable)(\s+)(as)/ do + groups Keyword, Text::Whitespace, Keyword + push :singletype + end + rule %r/(treat)(\s+)(as)/ do + groups Keyword, Text::Whitespace, Keyword + push :itemtype + end + rule %r/(instance)(\s+)(of)/ do + groups Keyword, Text::Whitespace, Keyword + push :itemtype + end + rule %r/(as)\b/ do + token Keyword + push :itemtype + end + + # Paths + rule %r/(#{XPath.ncName})(\s*)(:)(\s*)(\*)/ do + groups Name::Tag, Text::Whitespace, Punctuation, Text::Whitespace, Operator + end + rule %r/(\*)(\s*)(:)(\s*)(#{XPath.ncName})/ do + groups Operator, Text::Whitespace, Punctuation, Text::Whitespace, Name::Tag + end + rule %r/(#{XPath.axes})(\s*)(::)/ do + groups Keyword, Text::Whitespace, Operator + end + rule %r/\.\.|\.|\*/, Operator + rule %r/@/, Name::Attribute, :attrname + rule XPath.eqName, Name::Tag + end + + state :singletype do + mixin :commentsAndWhitespace + + # Type name + rule XPath.eqName do + token Keyword::Type + pop! + end + end + + state :itemtype do + mixin :commentsAndWhitespace + + # Type tests + rule %r/(#{XPath.kindTest})(\s*)(#{XPath.openParen})/ do + groups Keyword::Type, Text::Whitespace, Punctuation + # go to kindtest then occurrenceindicator + goto :occurrenceindicator + push :kindtest + end + rule %r/(#{XPath.kindTestForPI})(\s*)(#{XPath.openParen})/ do + groups Keyword::Type, Text::Whitespace, Punctuation + # go to kindtestforpi then occurrenceindicator + goto :occurrenceindicator + push :kindtestforpi + end + rule %r/(item)(\s*)(#{XPath.openParen})(\s*)(\))/ do + groups Keyword::Type, Text::Whitespace, Punctuation, Text::Whitespace, Punctuation + goto :occurrenceindicator + end + rule %r/(#{XPath.constructorTypes})(\s*)(#{XPath.openParen})/ do + groups Keyword::Type, Text::Whitespace, Punctuation + end + + # Type commands + rule %r/(cast|castable)(\s+)(as)/ do + groups Keyword, Text::Whitespace, Keyword + goto :singletype + end + rule %r/(treat)(\s+)(as)/ do + groups Keyword, Text::Whitespace, Keyword + goto :itemtype + end + rule %r/(instance)(\s+)(of)/ do + groups Keyword, Text::Whitespace, Keyword + goto :itemtype + end + rule %r/(as)\b/, Keyword + + # Operators + rule XPath.operators do + token Operator + pop! + end + rule %r/#{XPath.word_operators}\b/ do + token Operator::Word + pop! + end + rule %r/#{XPath.keywords}\b/ do + token Keyword + pop! + end + rule %r/[\[),]/ do + token Punctuation + pop! + end + + # Other types (e.g. xs:double) + rule XPath.eqName do + token Keyword::Type + goto :occurrenceindicator + end + end + + # For pseudo-parameters for the KindTest productions + state :kindtest do + mixin :commentsAndWhitespace + + # Pseudo-parameters: + rule %r/[?*]/, Operator + rule %r/,/, Punctuation + rule %r/(element|schema-element)(\s*)(#{XPath.openParen})/ do + groups Keyword::Type, Text::Whitespace, Punctuation + push :kindtest + end + rule XPath.eqName, Name::Tag + + # End of pseudo-parameters + rule %r/\)/, Punctuation, :pop! + end + + # Similar to :kindtest, but recognizes NCNames instead of EQNames + state :kindtestforpi do + mixin :commentsAndWhitespace + + # Pseudo-parameters + rule XPath.ncName, Name + rule XPath.stringLiteral, Literal::String + + # End of pseudo-parameters + rule %r/\)/, Punctuation, :pop! + end + + state :occurrenceindicator do + mixin :commentsAndWhitespace + + # Occurrence indicator + rule %r/[?*+]/ do + token Operator + pop! + end + + # Otherwise, lex it in root state: + rule %r/(?![?*+])/ do + pop! + end + end + + state :varname do + mixin :commentsAndWhitespace + + # Function call + rule %r/(#{XPath.eqName})(\s*)(#{XPath.openParen})/ do + groups Name::Variable, Text::Whitespace, Punctuation + pop! + end + + # Variable name + rule XPath.eqName, Name::Variable, :pop! + end + + state :attrname do + mixin :commentsAndWhitespace + + # Attribute name + rule XPath.eqName, Name::Attribute, :pop! + rule %r/\*/, Operator, :pop! + end + + state :comment do + # Comment end + rule %r/:\)/, Comment, :pop! + + # Nested comment + rule XPath.commentStart, Comment, :comment + + # Comment contents + rule %r/[^:(]+/m, Comment + rule %r/[:(]/, Comment + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xquery.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xquery.rb new file mode 100644 index 0000000..eb0d7a7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/xquery.rb @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + load_lexer 'xpath.rb' + class XQuery < XPath + title 'XQuery' + desc 'XQuery 3.1: An XML Query Language' + tag 'xquery' + filenames '*.xquery', '*.xq', '*.xqm' + mimetypes 'application/xquery' + + def self.keywords + @keywords ||= Regexp.union super, Regexp.union(%w( + xquery encoding version declare module + namespace copy-namespaces boundary-space construction + default collation base-uri preserve strip + ordering ordered unordered order empty greatest least + preserve no-preserve inherit no-inherit + decimal-format decimal-separator grouping-separator + infinity minus-sign NaN percent per-mille + zero-digit digit pattern-separator exponent-separator + import schema at element option + function external context item + typeswitch switch case + try catch + validate lax strict type + document element attribute text comment processing-instruction + for let where order group by return + allowing tumbling stable sliding window + start end only when previous next count collation + ascending descending + )) + end + + # Mixin states: + + state :tags do + rule %r/<#{XPath.qName}/, Name::Tag, :start_tag + rule %r//, Comment, :pop! + rule %r/-/, Comment + end + + state :start_tag do + rule %r/\s+/m, Text::Whitespace + rule %r/([\w.:-]+\s*=)(")/m do + groups Name::Attribute, Str + push :quot_attr + end + rule %r/([\w.:-]+\s*=)(')/m do + groups Name::Attribute, Str + push :apos_attr + end + rule %r/>/, Name::Tag, :tag_content + rule %r(/>), Name::Tag, :pop! + end + + state :quot_attr do + rule %r/"/, Str, :pop! + rule %r/\{\{/, Str + rule %r/\{/, Punctuation, :root + rule %r/[^"{>]+/m, Str + end + + state :apos_attr do + rule %r/'/, Str, :pop! + rule %r/\{\{/, Str + rule %r/\{/, Punctuation, :root + rule %r/[^'{>]+/m, Str + end + + state :tag_content do + rule %r/\s+/m, Text::Whitespace + mixin :tags + + rule %r/(\{\{|\}\})/, Text + rule %r/\{/, Punctuation, :root + + rule %r/[^{}<&]/, Text + + rule %r() do + token Name::Tag + pop! 2 # pop self and tag_start + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/yaml.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/yaml.rb new file mode 100644 index 0000000..1e949a6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/yaml.rb @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class YAML < RegexLexer + title "YAML" + desc "Yaml Ain't Markup Language (yaml.org)" + mimetypes 'text/x-yaml' + tag 'yaml' + aliases 'yml' + filenames '*.yaml', '*.yml' + + # Documentation: https://yaml.org/spec/1.2/spec.html + + def self.detect?(text) + # look for the %YAML directive + return true if text =~ /\A\s*%YAML/m + end + + # NB: Tabs are forbidden in YAML, which is why you see things + # like /[ ]+/. + + # reset the indentation levels + def reset_indent + puts " yaml: reset_indent" if @debug + @indent_stack = [0] + @next_indent = 0 + @block_scalar_indent = nil + end + + def indent + raise 'empty indent stack!' if @indent_stack.empty? + @indent_stack.last + end + + def dedent?(level) + level < self.indent + end + + def indent?(level) + level > self.indent + end + + # Save a possible indentation level + def save_indent(match) + @next_indent = match.size + puts " yaml: indent: #{self.indent}/#@next_indent" if @debug + puts " yaml: popping indent stack - before: #@indent_stack" if @debug + if dedent?(@next_indent) + @indent_stack.pop while dedent?(@next_indent) + puts " yaml: popping indent stack - after: #@indent_stack" if @debug + puts " yaml: indent: #{self.indent}/#@next_indent" if @debug + + # dedenting to a state not previously indented to is an error + [match[0...self.indent], match[self.indent..-1]] + else + [match, ''] + end + end + + def continue_indent(match) + puts " yaml: continue_indent" if @debug + @next_indent += match.size + end + + def set_indent(match, opts={}) + if indent < @next_indent + puts " yaml: indenting #{indent}/#{@next_indent}" if @debug + @indent_stack << @next_indent + end + + @next_indent += match.size unless opts[:implicit] + end + + plain_scalar_start = /[^ \t\n\r\f\v?:,\[\]{}#&*!\|>'"%@`]/ + + start { reset_indent } + + state :basic do + rule %r/#.*$/, Comment::Single + end + + state :root do + mixin :basic + + rule %r/\n+/, Text + + # trailing or pre-comment whitespace + rule %r/[ ]+(?=#|$)/, Text + + rule %r/^%YAML\b/ do + token Name::Tag + reset_indent + push :yaml_directive + end + + rule %r/^%TAG\b/ do + token Name::Tag + reset_indent + push :tag_directive + end + + # doc-start and doc-end indicators + rule %r/^(?:---|\.\.\.)(?= |$)/ do + token Name::Namespace + reset_indent + push :block_line + end + + # indentation spaces + rule %r/[ ]*(?!\s|$)/ do |m| + text, err = save_indent(m[0]) + token Text, text + token Error, err + push :block_line; push :indentation + end + end + + state :indentation do + rule(/\s*?\n/) { token Text; pop! 2 } + # whitespace preceding block collection indicators + rule %r/[ ]+(?=[-:?](?:[ ]|$))/ do |m| + token Text + continue_indent(m[0]) + end + + # block collection indicators + rule(/[?:-](?=[ ]|$)/) do |m| + set_indent m[0] + token Punctuation::Indicator + end + + # the beginning of a block line + rule(/[ ]*/) { |m| token Text; continue_indent(m[0]); pop! } + end + + # indented line in the block context + state :block_line do + # line end + rule %r/[ ]*(?=#|$)/, Text, :pop! + rule %r/[ ]+/, Text + # tags, anchors, and aliases + mixin :descriptors + # block collections and scalars + mixin :block_nodes + # flow collections and quoed scalars + mixin :flow_nodes + + # a plain scalar + rule %r/(?=#{plain_scalar_start}|[?:-][^ \t\n\r\f\v])/ do + token Name::Variable + push :plain_scalar_in_block_context + end + end + + state :descriptors do + # a full-form tag + rule %r/!<[0-9A-Za-z;\/?:@&=+$,_.!~*'()\[\]%-]+>/, Keyword::Type + + # a tag in the form '!', '!suffix' or '!handle!suffix' + rule %r( + (?:![\w-]+)? # handle + !(?:[\w;/?:@&=+$,.!~*\'()\[\]%-]*) # suffix + )x, Keyword::Type + + # an anchor + rule %r/&[\p{L}\p{Nl}\p{Nd}_-]+/, Name::Label + + # an alias + rule %r/\*[\p{L}\p{Nl}\p{Nd}_-]+/, Name::Variable + end + + state :block_nodes do + # implicit key + rule %r/([^#,?\[\]{}"'\n]+)(:)(?=\s|$)/ do |m| + groups Name::Attribute, Punctuation::Indicator + set_indent m[0], :implicit => true + end + + # literal and folded scalars + rule %r/[\|>][+-]?/ do + token Punctuation::Indicator + push :block_scalar_content + push :block_scalar_header + end + end + + state :flow_nodes do + rule %r/\[/, Punctuation::Indicator, :flow_sequence + rule %r/\{/, Punctuation::Indicator, :flow_mapping + rule %r/'/, Str::Single, :single_quoted_scalar + rule %r/"/, Str::Double, :double_quoted_scalar + end + + state :flow_collection do + rule %r/\s+/m, Text + mixin :basic + rule %r/[?:,]/, Punctuation::Indicator + mixin :descriptors + mixin :flow_nodes + + rule %r/(?=#{plain_scalar_start})/ do + push :plain_scalar_in_flow_context + end + end + + state :flow_sequence do + rule %r/\]/, Punctuation::Indicator, :pop! + mixin :flow_collection + end + + state :flow_mapping do + rule %r/\}/, Punctuation::Indicator, :pop! + mixin :flow_collection + end + + state :block_scalar_content do + rule %r/\n+/, Text + + # empty lines never dedent, but they might be part of the scalar. + rule %r/^[ ]+$/ do |m| + text = m[0] + indent_size = text.size + + indent_mark = @block_scalar_indent || indent_size + + token Text, text[0...indent_mark] + token Name::Constant, text[indent_mark..-1] + end + + # TODO: ^ doesn't actually seem to affect the match at all. + # Find a way to work around this limitation. + rule %r/^[ ]*/ do |m| + token Text + + indent_size = m[0].size + + dedent_level = @block_scalar_indent || self.indent + @block_scalar_indent ||= indent_size + + if indent_size < dedent_level + save_indent m[0] + pop! + push :indentation + end + end + + rule %r/[^\n\r\f\v]+/, Str + end + + state :block_scalar_header do + # optional indentation indicator and chomping flag, in either order + rule %r( + ( + ([1-9])[+-]? | [+-]?([1-9])? + )(?=[ ]|$) + )x do |m| + @block_scalar_indent = nil + goto :ignored_line + next if m[0].empty? + + increment = m[1] || m[2] + if increment + @block_scalar_indent = indent + increment.to_i + end + + token Punctuation::Indicator + end + end + + state :ignored_line do + mixin :basic + rule %r/[ ]+/, Text + rule %r/\n/, Text, :pop! + end + + state :quoted_scalar_whitespaces do + # leading and trailing whitespace is ignored + rule %r/^[ ]+/, Text + rule %r/[ ]+$/, Text + + rule %r/\n+/m, Text + + rule %r/[ ]+/, Name::Variable + end + + state :single_quoted_scalar do + mixin :quoted_scalar_whitespaces + rule %r/\\'/, Str::Escape + rule %r/'/, Str, :pop! + rule %r/[^\s']+/, Str + end + + state :double_quoted_scalar do + rule %r/"/, Str, :pop! + mixin :quoted_scalar_whitespaces + # escapes + rule %r/\\[0abt\tn\nvfre "\\N_LP]/, Str::Escape + rule %r/\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, + Str::Escape + rule %r/[^ \t\n\r\f\v"\\]+/, Str + end + + state :plain_scalar_in_block_context_new_line do + rule %r/^[ ]+\n/, Text + rule %r/\n+/m, Text + rule %r/^(?=---|\.\.\.)/ do + pop! 3 + end + + # dedent detection + rule %r/^[ ]*/ do |m| + token Text + pop! + + indent_size = m[0].size + + # dedent = end of scalar + if indent_size <= self.indent + pop! + save_indent(m[0]) + push :indentation + end + end + end + + state :plain_scalar_in_block_context do + # the : indicator ends a scalar + rule %r/[ ]*(?=:[ \n]|:$)/, Text, :pop! + rule %r/[ ]*:\S+/, Str + rule %r/[ ]+(?=#)/, Text, :pop! + rule %r/[ ]+$/, Text + # check for new documents or dedents at the new line + rule %r/\n+/ do + token Text + push :plain_scalar_in_block_context_new_line + end + + rule %r/[ ]+/, Str + rule %r((true|false|null)\b), Keyword::Constant + rule %r/\d+(?:\.\d+)?(?=(\r?\n)| +#)/, Literal::Number, :pop! + + # regular non-whitespace characters + rule %r/[^\s:]+/, Str + end + + state :plain_scalar_in_flow_context do + rule %r/[ ]*(?=[,:?\[\]{}])/, Text, :pop! + rule %r/[ ]+(?=#)/, Text, :pop! + rule %r/^[ ]+/, Text + rule %r/[ ]+$/, Text + rule %r/\n+/, Text + rule %r/[ ]+/, Name::Variable + rule %r/[^\s,:?\[\]{}]+/, Name::Variable + end + + state :yaml_directive do + rule %r/([ ]+)(\d+\.\d+)/ do + groups Text, Num + goto :ignored_line + end + end + + state :tag_directive do + rule %r( + ([ ]+)(!|![\w-]*!) # prefix + ([ ]+)(!|!?[\w;/?:@&=+$,.!~*'()\[\]%-]+) # tag handle + )x do + groups Text, Keyword::Type, Text, Keyword::Type + goto :ignored_line + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/yang.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/yang.rb new file mode 100644 index 0000000..a9d54f0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/yang.rb @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class YANG < RegexLexer + title 'YANG' + desc "Lexer for the YANG 1.1 modeling language (RFC7950)" + tag 'yang' + filenames '*.yang' + mimetypes 'application/yang' + + id = /[\w-]+(?=[^\w\-\:])\b/ + + #Keywords from RFC7950 ; oriented at BNF style + def self.top_stmts_keywords + @top_stms_keywords ||= Set.new %w( + module submodule + ) + end + + def self.module_header_stmts_keywords + @module_header_stmts_keywords ||= Set.new %w( + belongs-to namespace prefix yang-version + ) + end + + def self.meta_stmts_keywords + @meta_stmts_keywords ||= Set.new %w( + contact description organization reference revision + ) + end + + def self.linkage_stmts_keywords + @linkage_stmts_keywords ||= Set.new %w( + import include revision-date + ) + end + + def self.body_stmts_keywords + @body_stms_keywords ||= Set.new %w( + action argument augment deviation extension feature grouping identity + if-feature input notification output rpc typedef + ) + end + + def self.data_def_stmts_keywords + @data_def_stms_keywords ||= Set.new %w( + anydata anyxml case choice config container deviate leaf leaf-list + list must presence refine uses when + ) + end + + def self.type_stmts_keywords + @type_stmts_keywords ||= Set.new %w( + base bit default enum error-app-tag error-message fraction-digits + length max-elements min-elements modifier ordered-by path pattern + position range require-instance status type units value yin-element + ) + end + + def self.list_stmts_keywords + @list_stmts_keywords ||= Set.new %w( + key mandatory unique + ) + end + + #RFC7950 other keywords + def self.constants_keywords + @constants_keywords ||= Set.new %w( + add current delete deprecated false invert-match max min + not-supported obsolete replace true unbounded user + ) + end + + #RFC7950 Built-In Types + def self.types + @types ||= Set.new %w( + binary bits boolean decimal64 empty enumeration identityref + instance-identifier int16 int32 int64 int8 leafref string uint16 + uint32 uint64 uint8 union + ) + end + + state :comment do + rule %r/[^*\/]/, Comment + rule %r/\/\*/, Comment, :comment + rule %r/\*\//, Comment, :pop! + rule %r/[*\/]/, Comment + end + + #Keyword::Reserved + #groups Name::Tag, Text::Whitespace + state :root do + rule %r/\s+/, Text::Whitespace + rule %r/[\{\}\;]+/, Punctuation + rule %r/(?=\?-]|\.{1,3}/, Operator + end + + state :literals do + rule %r/\b(?:true|false|null)\b/, Keyword::Constant + rule %r( + ' (?: #{escapes} | [^\\] ) ' + )x, Str::Char + + rule %r/"/, Str, :string + rule %r/r(#*)".*?"\1/m, Str + + dot = /[.][0-9_]+/ + exp = /e[-+]?[0-9_]+/ + + rule %r( + [0-9]+ + (#{dot} #{exp}? + |#{dot}? #{exp} + ) + )x, Num::Float + + rule %r( + ( 0b[10_]+ + | 0x[0-9a-fA-F_]+ + | [0-9_]+ + ) + )x, Num::Integer + end + + state :string do + rule %r/"/, Str, :pop! + rule escapes, Str::Escape + rule %r/[^"\\]+/m, Str + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/plugins/redcarpet.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/plugins/redcarpet.rb new file mode 100644 index 0000000..2558e1b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/plugins/redcarpet.rb @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# this file is not require'd from the root. To use this plugin, run: +# +# require 'rouge/plugins/redcarpet' + +module Rouge + module Plugins + module Redcarpet + def block_code(code, language) + lexer = + begin + Lexer.find_fancy(language, code) + rescue Guesser::Ambiguous => e + e.alternatives.first + end + lexer ||= Lexers::PlainText + + # XXX HACK: Redcarpet strips hard tabs out of code blocks, + # so we assume you're not using leading spaces that aren't tabs, + # and just replace them here. + if lexer.tag == 'make' + code.gsub! %r/^ /, "\t" + end + + formatter = rouge_formatter(lexer) + formatter.format(lexer.lex(code)) + end + + # override this method for custom formatting behavior + def rouge_formatter(lexer) + Formatters::HTMLLegacy.new(:css_class => "highlight #{lexer.tag}") + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/regex_lexer.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/regex_lexer.rb new file mode 100644 index 0000000..a61883a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/regex_lexer.rb @@ -0,0 +1,498 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + # @abstract + # A stateful lexer that uses sets of regular expressions to + # tokenize a string. Most lexers are instances of RegexLexer. + class RegexLexer < Lexer + class InvalidRegex < StandardError + def initialize(re) + @re = re + end + + def to_s + "regex #{@re.inspect} matches empty string, but has no predicate!" + end + end + + class ClosedState < StandardError + attr_reader :state + def initialize(state) + @state = state + end + + def rule + @state.rules.last + end + + def to_s + rule = @state.rules.last + msg = "State :#{state.name} cannot continue after #{rule.inspect}, which will always match." + if rule.re.source.include?('*') + msg += " Consider replacing * with +." + end + + msg + end + end + + # A rule is a tuple of a regular expression to test, and a callback + # to perform if the test succeeds. + # + # @see StateDSL#rule + class Rule + attr_reader :callback + attr_reader :re + attr_reader :beginning_of_line + def initialize(re, callback) + @re = re + @callback = callback + @beginning_of_line = re.source[0] == ?^ + end + + def inspect + "#" + end + end + + # a State is a named set of rules that can be tested for or + # mixed in. + # + # @see RegexLexer.state + class State + attr_reader :name, :rules + def initialize(name, rules) + @name = name + @rules = rules + end + + def inspect + "#<#{self.class.name} #{@name.inspect}>" + end + end + + class StateDSL + attr_reader :rules, :name + def initialize(name, &defn) + @name = name + @defn = defn + @rules = [] + @loaded = false + @closed = false + end + + def to_state(lexer_class) + load! + rules = @rules.map do |rule| + rule.is_a?(String) ? lexer_class.get_state(rule) : rule + end + State.new(@name, rules) + end + + def prepended(&defn) + parent_defn = @defn + StateDSL.new(@name) do + instance_eval(&defn) + instance_eval(&parent_defn) + end + end + + def appended(&defn) + parent_defn = @defn + StateDSL.new(@name) do + instance_eval(&parent_defn) + instance_eval(&defn) + end + end + + protected + # Define a new rule for this state. + # + # @overload rule(re, token, next_state=nil) + # @overload rule(re, &callback) + # + # @param [Regexp] re + # a regular expression for this rule to test. + # @param [String] tok + # the token type to yield if `re` matches. + # @param [#to_s] next_state + # (optional) a state to push onto the stack if `re` matches. + # If `next_state` is `:pop!`, the state stack will be popped + # instead. + # @param [Proc] callback + # a block that will be evaluated in the context of the lexer + # if `re` matches. This block has access to a number of lexer + # methods, including {RegexLexer#push}, {RegexLexer#pop!}, + # {RegexLexer#token}, and {RegexLexer#delegate}. The first + # argument can be used to access the match groups. + def rule(re, tok=nil, next_state=nil, &callback) + raise ClosedState.new(self) if @closed + + if tok.nil? && callback.nil? + raise "please pass `rule` a token to yield or a callback" + end + + matches_empty = re =~ '' + + callback ||= case next_state + when :pop! + proc do |stream| + puts " yielding: #{tok.qualname}, #{stream[0].inspect}" if @debug + @output_stream.call(tok, stream[0]) + puts " popping stack: 1" if @debug + @stack.pop or raise 'empty stack!' + end + when :push + proc do |stream| + puts " yielding: #{tok.qualname}, #{stream[0].inspect}" if @debug + @output_stream.call(tok, stream[0]) + puts " pushing :#{@stack.last.name}" if @debug + @stack.push(@stack.last) + end + when Symbol + proc do |stream| + puts " yielding: #{tok.qualname}, #{stream[0].inspect}" if @debug + @output_stream.call(tok, stream[0]) + state = @states[next_state] || self.class.get_state(next_state) + puts " pushing :#{state.name}" if @debug + @stack.push(state) + end + when nil + # cannot use an empty-matching regexp with no predicate + raise InvalidRegex.new(re) if matches_empty + + proc do |stream| + puts " yielding: #{tok.qualname}, #{stream[0].inspect}" if @debug + @output_stream.call(tok, stream[0]) + end + else + raise "invalid next state: #{next_state.inspect}" + end + + rules << Rule.new(re, callback) + + close! if matches_empty && !context_sensitive?(re) + end + + def context_sensitive?(re) + source = re.source + return true if source =~ /[(][?] MAX_NULL_SCANS + puts " warning: too many scans without consuming the string!" if @debug + return false + end + else + @null_steps = 0 + end + + return true + end + end + end + + false + end + + # Yield a token. + # + # @param tok + # the token type + # @param val + # (optional) the string value to yield. If absent, this defaults + # to the entire last match. + def token(tok, val=@current_stream[0]) + yield_token(tok, val) + end + + # @deprecated + # + # Yield a token with the next matched group. Subsequent calls + # to this method will yield subsequent groups. + def group(tok) + raise "RegexLexer#group is deprecated: use #groups instead" + end + + # Yield tokens corresponding to the matched groups of the current + # match. + def groups(*tokens) + tokens.each_with_index do |tok, i| + yield_token(tok, @current_stream[i+1]) + end + end + + # Delegate the lex to another lexer. We use the `continue_lex` method + # so that #reset! will not be called. In this way, a single lexer + # can be repeatedly delegated to while maintaining its own internal + # state stack. + # + # @param [#lex] lexer + # The lexer or lexer class to delegate to + # @param [String] text + # The text to delegate. This defaults to the last matched string. + def delegate(lexer, text=nil) + puts " delegating to: #{lexer.inspect}" if @debug + text ||= @current_stream[0] + + lexer.continue_lex(text) do |tok, val| + puts " delegated token: #{tok.inspect}, #{val.inspect}" if @debug + yield_token(tok, val) + end + end + + def recurse(text=nil) + delegate(self.class, text) + end + + # Push a state onto the stack. If no state name is given and you've + # passed a block, a state will be dynamically created using the + # {StateDSL}. + def push(state_name=nil, &b) + push_state = if state_name + get_state(state_name) + elsif block_given? + StateDSL.new(b.inspect, &b).to_state(self.class) + else + # use the top of the stack by default + self.state + end + + puts " pushing: :#{push_state.name}" if @debug + stack.push(push_state) + end + + # Pop the state stack. If a number is passed in, it will be popped + # that number of times. + def pop!(times=1) + raise 'empty stack!' if stack.empty? + + puts " popping stack: #{times}" if @debug + + stack.pop(times) + + nil + end + + # replace the head of the stack with the given state + def goto(state_name) + raise 'empty stack!' if stack.empty? + + puts " going to: state :#{state_name} " if @debug + stack[-1] = get_state(state_name) + end + + # reset the stack back to `[:root]`. + def reset_stack + puts ' resetting stack' if @debug + stack.clear + stack.push get_state(:root) + end + + # Check if `state_name` is in the state stack. + def in_state?(state_name) + state_name = state_name.to_sym + stack.any? do |state| + state.name == state_name.to_sym + end + end + + # Check if `state_name` is the state on top of the state stack. + def state?(state_name) + state_name.to_sym == state.name + end + + private + def yield_token(tok, val) + return if val.nil? || val.empty? + puts " yielding: #{tok.qualname}, #{val.inspect}" if @debug + @output_stream.yield(tok, val) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/template_lexer.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/template_lexer.rb new file mode 100644 index 0000000..384b37b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/template_lexer.rb @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + # @abstract + # A TemplateLexer is one that accepts a :parent option, to specify + # which language is being templated. The lexer class can specify its + # own default for the parent lexer, which is otherwise defaulted to + # HTML. + class TemplateLexer < RegexLexer + # the parent lexer - the one being templated. + def parent + return @parent if instance_variable_defined? :@parent + @parent = lexer_option(:parent) || Lexers::HTML.new(@options) + end + + option :parent, "the parent language (default: html)" + + start { parent.reset! } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/tex_theme_renderer.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/tex_theme_renderer.rb new file mode 100644 index 0000000..e912e2e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/tex_theme_renderer.rb @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + class TexThemeRenderer + def initialize(theme, opts={}) + @theme = theme + @prefix = opts.fetch(:prefix) { 'RG' } + end + + # Our general strategy is this: + # + # * First, define the \RG{tokname}{content} command, which will + # expand into \RG@tok@tokname{content}. We use \csname...\endcsname + # to interpolate into a command. + # + # * Define the default RG* environment, which will enclose the whole + # thing. By default this will simply set \ttfamily (select monospace font) + # but it can be overridden with \renewcommand by the user to be + # any other formatting. + # + # * Define all the colors using xcolors \definecolor command. First we define + # every palette color with a name such as RG@palette@themneame@colorname. + # Then we find all foreground and background colors that have literal html + # colors embedded in them and define them with names such as + # RG@palette@themename@000000. While html allows three-letter colors such + # as #FFF, xcolor requires all six characters to be present, so we make sure + # to normalize that as well as the case convention in #inline_name. + # + # * Define the token commands RG@tok@xx. These will take the content as the + # argument and format it according to the theme, referring to the color + # in the palette. + def render(&b) + yield <<'END'.gsub('RG', @prefix) +\makeatletter +\def\RG#1#2{\csname RG@tok@#1\endcsname{#2}}% +\newenvironment{RG*}{\ttfamily}{\relax}% +END + + base = @theme.class.base_style + yield "\\definecolor{#{@prefix}@fgcolor}{HTML}{#{inline_name(base.fg || '#000000')}}" + yield "\\definecolor{#{@prefix}@bgcolor}{HTML}{#{inline_name(base.bg || '#FFFFFF')}}" + + render_palette(@theme.palette, &b) + + @theme.styles.each do |tok, style| + render_inline_pallete(style, &b) + end + + Token.each_token do |tok| + style = @theme.class.get_own_style(tok) + style ? render_style(tok, style, &b) : render_blank(tok, &b) + end + yield '\makeatother' + end + + def render_palette(palette, &b) + palette.each do |name, color| + hex = inline_name(color) + + yield "\\definecolor{#{palette_name(name)}}{HTML}{#{hex}}%" + end + end + + def render_inline_pallete(style, &b) + gen_inline(style[:fg], &b) + gen_inline(style[:bg], &b) + end + + def inline_name(color) + color =~ /^#(\h+)/ or return nil + + # xcolor does not support 3-character HTML colors, + # so we convert them here + case $1.size + when 6 + $1 + when 3 + # duplicate every character: abc -> aabbcc + $1.gsub(/\h/, '\0\0') + else + raise "invalid HTML color: #{$1}" + end.upcase + end + + def gen_inline(name, &b) + # detect inline colors + hex = inline_name(name) + return unless hex + + @gen_inline ||= {} + @gen_inline[hex] ||= begin + yield "\\definecolor{#{palette_name(hex)}}{HTML}{#{hex}}%" + end + end + + def camelize(name) + name.gsub(/_(.)/) { $1.upcase } + end + + def palette_name(name) + name = inline_name(name) || name.to_s + + "#{@prefix}@palette@#{camelize(@theme.name)}@#{camelize(name.to_s)}" + end + + def token_name(tok) + "\\csname #@prefix@tok@#{tok.shortname}\\endcsname" + end + + def render_blank(tok, &b) + "\\expandafter\\def#{token_name(tok)}#1{#1}" + end + + def render_style(tok, style, &b) + out = String.new('') + out << "\\expandafter\\def#{token_name(tok)}#1{" + out << "\\fboxsep=0pt\\colorbox{#{palette_name(style[:bg])}}{" if style[:bg] + out << '\\textbf{' if style[:bold] + out << '\\textit{' if style[:italic] + out << "\\textcolor{#{palette_name(style[:fg])}}{" if style[:fg] + out << "#1" + # close the right number of curlies + out << "}" if style[:bold] + out << "}" if style[:italic] + out << "}" if style[:fg] + out << "}" if style[:bg] + out << "}%" + yield out + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/text_analyzer.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/text_analyzer.rb new file mode 100644 index 0000000..0540ca4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/text_analyzer.rb @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + class TextAnalyzer < String + # Find a shebang. Returns nil if no shebang is present. + def shebang + return @shebang if instance_variable_defined? :@shebang + + self =~ /\A\s*#!(.*)$/ + @shebang = $1 + end + + # Check if the given shebang is present. + # + # This normalizes things so that `text.shebang?('bash')` will detect + # `#!/bash`, '#!/bin/bash', '#!/usr/bin/env bash', and '#!/bin/bash -x' + def shebang?(match) + return false unless shebang + match = /\b#{match}(\s|$)/ + match === shebang + end + + # Return the contents of the doctype tag if present, nil otherwise. + def doctype + return @doctype if instance_variable_defined? :@doctype + + self =~ %r(\A\s* + (?:<\?.*?\?>\s*)? # possible tag + + )xm + @doctype = $1 + end + + # Check if the doctype matches a given regexp or string + def doctype?(type=//) + type === doctype + end + + # Return true if the result of lexing with the given lexer contains no + # error tokens. + def lexes_cleanly?(lexer) + lexer.lex(self) do |(tok, _)| + return false if tok.name == 'Error' + end + + true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/theme.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/theme.rb new file mode 100644 index 0000000..4fae98b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/theme.rb @@ -0,0 +1,218 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + class Theme + include Token::Tokens + + class Style < Hash + def initialize(theme, hsh={}) + super() + @theme = theme + merge!(hsh) + end + + [:fg, :bg].each do |mode| + define_method mode do + return self[mode] unless @theme + @theme.palette(self[mode]) if self[mode] + end + end + + def render(selector, &b) + return enum_for(:render, selector).to_a.join("\n") unless b + + return if empty? + + yield "#{selector} {" + rendered_rules.each do |rule| + yield " #{rule};" + end + yield "}" + end + + def rendered_rules(&b) + return enum_for(:rendered_rules) unless b + yield "color: #{fg}" if fg + yield "background-color: #{bg}" if bg + yield "font-weight: bold" if self[:bold] + yield "font-style: italic" if self[:italic] + yield "text-decoration: underline" if self[:underline] + + (self[:rules] || []).each(&b) + end + end + + def styles + @styles ||= self.class.styles.dup + end + + @palette = {} + def self.palette(arg={}) + @palette ||= InheritableHash.new(superclass.palette) + + if arg.is_a? Hash + @palette.merge! arg + @palette + else + case arg + when /#[0-9a-f]+/i + arg + else + @palette[arg] or raise "not in palette: #{arg.inspect}" + end + end + end + + def palette(*a) self.class.palette(*a) end + + @styles = {} + def self.styles + @styles ||= InheritableHash.new(superclass.styles) + end + + def self.render(opts={}, &b) + new(opts).render(&b) + end + + def get_own_style(token) + self.class.get_own_style(token) + end + + def get_style(token) + self.class.get_style(token) + end + + def name + self.class.name + end + + class << self + def style(*tokens) + style = tokens.last.is_a?(Hash) ? tokens.pop : {} + + tokens.each do |tok| + styles[tok] = style + end + end + + def get_own_style(token) + token.token_chain.reverse_each do |anc| + return Style.new(self, styles[anc]) if styles[anc] + end + + nil + end + + def get_style(token) + get_own_style(token) || base_style + end + + def base_style + get_own_style(Token::Tokens::Text) + end + + def name(n=nil) + return @name if n.nil? + + @name = n.to_s + register(@name) + end + + def register(name) + Theme.registry[name.to_s] = self + end + + def find(n) + registry[n.to_s] + end + + def registry + @registry ||= {} + end + end + end + + module HasModes + def mode(arg=:absent) + return @mode if arg == :absent + + @modes ||= {} + @modes[arg] ||= get_mode(arg) + end + + def get_mode(mode) + return self if self.mode == mode + + new_name = "#{self.name}.#{mode}" + Class.new(self) { name(new_name); set_mode!(mode) } + end + + def set_mode!(mode) + @mode = mode + send("make_#{mode}!") + end + + def mode!(arg) + alt_name = "#{self.name}.#{arg}" + register(alt_name) + set_mode!(arg) + end + end + + class CSSTheme < Theme + def initialize(opts={}) + @scope = opts[:scope] || '.highlight' + end + + def render(&b) + return enum_for(:render).to_a.join("\n") unless b + + # shared styles for tableized line numbers + yield "#{@scope} table td { padding: 5px; }" + yield "#{@scope} table pre { margin: 0; }" + + styles.each do |tok, style| + Style.new(self, style).render(css_selector(tok), &b) + end + end + + def render_base(selector, &b) + self.class.base_style.render(selector, &b) + end + + def style_for(tok) + self.class.get_style(tok) + end + + private + def css_selector(token) + inflate_token(token).map do |tok| + raise "unknown token: #{tok.inspect}" if tok.shortname.nil? + + single_css_selector(tok) + end.join(', ') + end + + def single_css_selector(token) + return @scope if token == Text + + "#{@scope} .#{token.shortname}" + end + + # yield all of the tokens that should be styled the same + # as the given token. Essentially this recursively all of + # the subtokens, except those which are more specifically + # styled. + def inflate_token(tok, &b) + return enum_for(:inflate_token, tok) unless block_given? + + yield tok + tok.sub_tokens.each do |(_, st)| + next if styles[st] + + inflate_token(st, &b) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/base16.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/base16.rb new file mode 100644 index 0000000..6e77c6a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/base16.rb @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + # author Chris Kempson + # base16 default dark + # https://github.com/chriskempson/base16-default-schemes + class Base16 < CSSTheme + name 'base16' + + palette base00: "#181818" + palette base01: "#282828" + palette base02: "#383838" + palette base03: "#585858" + palette base04: "#b8b8b8" + palette base05: "#d8d8d8" + palette base06: "#e8e8e8" + palette base07: "#f8f8f8" + palette base08: "#ab4642" + palette base09: "#dc9656" + palette base0A: "#f7ca88" + palette base0B: "#a1b56c" + palette base0C: "#86c1b9" + palette base0D: "#7cafc2" + palette base0E: "#ba8baf" + palette base0F: "#a16946" + + extend HasModes + + def self.light! + mode :dark # indicate that there is a dark variant + mode! :light + end + + def self.dark! + mode :light # indicate that there is a light variant + mode! :dark + end + + def self.make_dark! + style Text, :fg => :base05, :bg => :base00 + end + + def self.make_light! + style Text, :fg => :base02 + end + + light! + + style Error, :fg => :base00, :bg => :base08 + style Comment, :fg => :base03 + + style Comment::Preproc, + Name::Tag, :fg => :base0A + + style Operator, + Punctuation, :fg => :base05 + + style Generic::Inserted, :fg => :base0B + style Generic::Deleted, :fg => :base08 + style Generic::Heading, :fg => :base0D, :bg => :base00, :bold => true + + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + + style Keyword, :fg => :base0E + style Keyword::Constant, + Keyword::Type, :fg => :base09 + + style Keyword::Declaration, :fg => :base09 + + style Literal::String, :fg => :base0B + style Literal::String::Affix, :fg => :base0E + style Literal::String::Regex, :fg => :base0C + + style Literal::String::Interpol, + Literal::String::Escape, :fg => :base0F + + style Name::Namespace, + Name::Class, + Name::Constant, :fg => :base0A + + style Name::Attribute, :fg => :base0D + + style Literal::Number, + Literal::String::Symbol, :fg => :base0B + + class Solarized < Base16 + name 'base16.solarized' + light! + # author "Ethan Schoonover (http://ethanschoonover.com/solarized)" + + palette base00: "#002b36" + palette base01: "#073642" + palette base02: "#586e75" + palette base03: "#657b83" + palette base04: "#839496" + palette base05: "#93a1a1" + palette base06: "#eee8d5" + palette base07: "#fdf6e3" + palette base08: "#dc322f" + palette base09: "#cb4b16" + palette base0A: "#b58900" + palette base0B: "#859900" + palette base0C: "#2aa198" + palette base0D: "#268bd2" + palette base0E: "#6c71c4" + palette base0F: "#d33682" + end + + class Monokai < Base16 + name 'base16.monokai' + dark! + + # author "Wimer Hazenberg (http://www.monokai.nl)" + palette base00: "#272822" + palette base01: "#383830" + palette base02: "#49483e" + palette base03: "#75715e" + palette base04: "#a59f85" + palette base05: "#f8f8f2" + palette base06: "#f5f4f1" + palette base07: "#f9f8f5" + palette base08: "#f92672" + palette base09: "#fd971f" + palette base0A: "#f4bf75" + palette base0B: "#a6e22e" + palette base0C: "#a1efe4" + palette base0D: "#66d9ef" + palette base0E: "#ae81ff" + palette base0F: "#cc6633" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/bw.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/bw.rb new file mode 100644 index 0000000..779359a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/bw.rb @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + # A port of the bw style from Pygments. + # See https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/styles/bw.py + class BlackWhiteTheme < CSSTheme + name 'bw' + + style Text, :fg => '#000000', :bg => '#ffffff' + + style Comment, :italic => true + style Comment::Preproc, :italic => false + + style Keyword, :bold => true + style Keyword::Pseudo, :bold => false + style Keyword::Type, :bold => false + + style Operator, :bold => true + + style Name::Class, :bold => true + style Name::Namespace, :bold => true + style Name::Exception, :bold => true + style Name::Entity, :bold => true + style Name::Tag, :bold => true + + style Literal::String, :italic => true + style Literal::String::Affix, :bold => true + style Literal::String::Interpol, :bold => true + style Literal::String::Escape, :bold => true + + style Generic::Heading, :bold => true + style Generic::Subheading, :bold => true + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + style Generic::Prompt, :bold => true + + style Error, :fg => '#FF0000' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/colorful.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/colorful.rb new file mode 100644 index 0000000..43acc90 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/colorful.rb @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + # stolen from pygments + class Colorful < CSSTheme + name 'colorful' + + style Text, :fg => "#bbbbbb", :bg => '#000' + + style Comment, :fg => "#888" + style Comment::Preproc, :fg => "#579" + style Comment::Special, :fg => "#cc0000", :bold => true + + style Keyword, :fg => "#080", :bold => true + style Keyword::Pseudo, :fg => "#038" + style Keyword::Type, :fg => "#339" + + style Operator, :fg => "#333" + style Operator::Word, :fg => "#000", :bold => true + + style Name::Builtin, :fg => "#007020" + style Name::Function, :fg => "#06B", :bold => true + style Name::Class, :fg => "#B06", :bold => true + style Name::Namespace, :fg => "#0e84b5", :bold => true + style Name::Exception, :fg => "#F00", :bold => true + style Name::Variable, :fg => "#963" + style Name::Variable::Instance, :fg => "#33B" + style Name::Variable::Class, :fg => "#369" + style Name::Variable::Global, :fg => "#d70", :bold => true + style Name::Constant, :fg => "#036", :bold => true + style Name::Label, :fg => "#970", :bold => true + style Name::Entity, :fg => "#800", :bold => true + style Name::Attribute, :fg => "#00C" + style Name::Tag, :fg => "#070" + style Name::Decorator, :fg => "#555", :bold => true + + style Literal::String, :bg => "#fff0f0" + style Literal::String::Affix, :fg => "#080", :bold => true + style Literal::String::Char, :fg => "#04D" + style Literal::String::Doc, :fg => "#D42" + style Literal::String::Interpol, :bg => "#eee" + style Literal::String::Escape, :fg => "#666", :bold => true + style Literal::String::Regex, :fg => "#000", :bg => "#fff0ff" + style Literal::String::Symbol, :fg => "#A60" + style Literal::String::Other, :fg => "#D20" + + style Literal::Number, :fg => "#60E", :bold => true + style Literal::Number::Integer, :fg => "#00D", :bold => true + style Literal::Number::Float, :fg => "#60E", :bold => true + style Literal::Number::Hex, :fg => "#058", :bold => true + style Literal::Number::Oct, :fg => "#40E", :bold => true + + style Generic::Heading, :fg => "#000080", :bold => true + style Generic::Subheading, :fg => "#800080", :bold => true + style Generic::Deleted, :fg => "#A00000" + style Generic::Inserted, :fg => "#00A000" + style Generic::Error, :fg => "#FF0000" + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + style Generic::Prompt, :fg => "#c65d09", :bold => true + style Generic::Output, :fg => "#888" + style Generic::Traceback, :fg => "#04D" + + style Error, :fg => "#F00", :bg => "#FAA" + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/github.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/github.rb new file mode 100644 index 0000000..27b8a5f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/github.rb @@ -0,0 +1,149 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class Github < CSSTheme + name 'github' + + # Primer primitives + # https://github.com/primer/primitives/tree/main/src/tokens + P_RED_0 = {:light => '#ffebe9', :dark => '#ffdcd7'} + P_RED_3 = {:dark => '#ff7b72'} + P_RED_5 = {:light => '#cf222e'} + P_RED_7 = {:light => '#82071e', :dark => '#8e1519'} + P_RED_8 = {:dark => '#67060c'} + P_ORANGE_2 = {:dark => '#ffa657'} + P_ORANGE_6 = {:light => '#953800'} + P_GREEN_0 = {:light => '#dafbe1', :dark => '#aff5b4'} + P_GREEN_1 = {:dark => '#7ee787'} + P_GREEN_6 = {:light => '#116329'} + P_GREEN_8 = {:dark => '#033a16'} + P_BLUE_1 = {:dark => '#a5d6ff'} + P_BLUE_2 = {:dark => '#79c0ff'} + P_BLUE_5 = {:dark => '#1f6feb'} + P_BLUE_6 = {:light => '#0550ae'} + P_BLUE_8 = {:light => '#0a3069'} + P_PURPLE_2 = {:dark => '#d2a8ff'} + P_PURPLE_5 = {:light => '#8250df'} + P_GRAY_0 = {:light => '#f6f8fa', :dark => '#f0f6fc'} + P_GRAY_1 = {:dark => '#c9d1d9'} + P_GRAY_3 = {:dark => '#8b949e'} + P_GRAY_5 = {:light => '#6e7781'} + P_GRAY_8 = {:dark => '#161b22'} + P_GRAY_9 = {:light => '#24292f'} + + extend HasModes + + def self.light! + mode :dark # indicate that there is a dark variant + mode! :light + end + + def self.dark! + mode :light # indicate that there is a light variant + mode! :dark + end + + def self.make_dark! + palette :comment => P_GRAY_3[@mode] + palette :constant => P_BLUE_2[@mode] + palette :entity => P_PURPLE_2[@mode] + palette :heading => P_BLUE_5[@mode] + palette :keyword => P_RED_3[@mode] + palette :string => P_BLUE_1[@mode] + palette :tag => P_GREEN_1[@mode] + palette :variable => P_ORANGE_2[@mode] + + palette :fgDefault => P_GRAY_1[@mode] + palette :bgDefault => P_GRAY_8[@mode] + + palette :fgInserted => P_GREEN_0[@mode] + palette :bgInserted => P_GREEN_8[@mode] + + palette :fgDeleted => P_RED_0[@mode] + palette :bgDeleted => P_RED_8[@mode] + + palette :fgError => P_GRAY_0[@mode] + palette :bgError => P_RED_7[@mode] + end + + def self.make_light! + palette :comment => P_GRAY_5[@mode] + palette :constant => P_BLUE_6[@mode] + palette :entity => P_PURPLE_5[@mode] + palette :heading => P_BLUE_6[@mode] + palette :keyword => P_RED_5[@mode] + palette :string => P_BLUE_8[@mode] + palette :tag => P_GREEN_6[@mode] + palette :variable => P_ORANGE_6[@mode] + + palette :fgDefault => P_GRAY_9[@mode] + palette :bgDefault => P_GRAY_0[@mode] + + palette :fgInserted => P_GREEN_6[@mode] + palette :bgInserted => P_GREEN_0[@mode] + + palette :fgDeleted => P_RED_7[@mode] + palette :bgDeleted => P_RED_0[@mode] + + palette :fgError => P_GRAY_0[@mode] + palette :bgError => P_RED_7[@mode] + end + + light! + + style Text, :fg => :fgDefault, :bg => :bgDefault + + style Keyword, :fg => :keyword + + style Generic::Error, :fg => :fgError + + style Generic::Deleted, :fg => :fgDeleted, :bg => :bgDeleted + + style Name::Builtin, + Name::Class, + Name::Constant, + Name::Namespace, :fg => :variable + + style Literal::String::Regex, + Name::Attribute, + Name::Tag, :fg => :tag + + style Generic::Inserted, :fg => :fgInserted, :bg => :bgInserted + style Generic::EmphStrong, :italic => true, :bold => true + + style Keyword::Constant, + Literal, + Literal::String::Backtick, + Name::Builtin::Pseudo, + Name::Exception, + Name::Label, + Name::Property, + Name::Variable, + Operator, :fg => :constant + + style Generic::Heading, + Generic::Subheading, :fg => :heading, :bold => true + + style Literal::String, :fg => :string + + style Name::Decorator, + Name::Function, :fg => :entity + + style Error, :fg => :fgError, :bg => :bgError + + style Comment, + Generic::Lineno, + Generic::Traceback, :fg => :comment + + style Name::Entity, + Literal::String::Interpol, :fg => :fgDefault + + style Generic::Emph, :fg => :fgDefault, :italic => true + + style Generic::Strong, :fg => :fgDefault, :bold => true + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/gruvbox.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/gruvbox.rb new file mode 100644 index 0000000..8faf4cc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/gruvbox.rb @@ -0,0 +1,173 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +# TODO how are we going to handle soft/hard contrast? + +module Rouge + module Themes + # Based on https://github.com/morhetz/gruvbox, with help from + # https://github.com/daveyarwood/gruvbox-pygments + class Gruvbox < CSSTheme + name 'gruvbox' + + # global Gruvbox colours {{{ + C_dark0_hard = '#1d2021' + C_dark0 ='#282828' + C_dark0_soft = '#32302f' + C_dark1 = '#3c3836' + C_dark2 = '#504945' + C_dark3 = '#665c54' + C_dark4 = '#7c6f64' + C_dark4_256 = '#7c6f64' + + C_gray_245 = '#928374' + C_gray_244 = '#928374' + + C_light0_hard = '#f9f5d7' + C_light0 = '#fbf1c7' + C_light0_soft = '#f2e5bc' + C_light1 = '#ebdbb2' + C_light2 = '#d5c4a1' + C_light3 = '#bdae93' + C_light4 = '#a89984' + C_light4_256 = '#a89984' + + C_bright_red = '#fb4934' + C_bright_green = '#b8bb26' + C_bright_yellow = '#fabd2f' + C_bright_blue = '#83a598' + C_bright_purple = '#d3869b' + C_bright_aqua = '#8ec07c' + C_bright_orange = '#fe8019' + + C_neutral_red = '#cc241d' + C_neutral_green = '#98971a' + C_neutral_yellow = '#d79921' + C_neutral_blue = '#458588' + C_neutral_purple = '#b16286' + C_neutral_aqua = '#689d6a' + C_neutral_orange = '#d65d0e' + + C_faded_red = '#9d0006' + C_faded_green = '#79740e' + C_faded_yellow = '#b57614' + C_faded_blue = '#076678' + C_faded_purple = '#8f3f71' + C_faded_aqua = '#427b58' + C_faded_orange = '#af3a03' + # }}} + + extend HasModes + + def self.light! + mode :dark # indicate that there is a dark variant + mode! :light + end + + def self.dark! + mode :light # indicate that there is a light variant + mode! :dark + end + + def self.make_dark! + palette bg0: C_dark0 + palette bg1: C_dark1 + palette bg2: C_dark2 + palette bg3: C_dark3 + palette bg4: C_dark4 + + palette gray: C_gray_245 + + palette fg0: C_light0 + palette fg1: C_light1 + palette fg2: C_light2 + palette fg3: C_light3 + palette fg4: C_light4 + + palette fg4_256: C_light4_256 + + palette red: C_bright_red + palette green: C_bright_green + palette yellow: C_bright_yellow + palette blue: C_bright_blue + palette purple: C_bright_purple + palette aqua: C_bright_aqua + palette orange: C_bright_orange + + end + + def self.make_light! + palette bg0: C_light0 + palette bg1: C_light1 + palette bg2: C_light2 + palette bg3: C_light3 + palette bg4: C_light4 + + palette gray: C_gray_244 + + palette fg0: C_dark0 + palette fg1: C_dark1 + palette fg2: C_dark2 + palette fg3: C_dark3 + palette fg4: C_dark4 + + palette fg4_256: C_dark4_256 + + palette red: C_faded_red + palette green: C_faded_green + palette yellow: C_faded_yellow + palette blue: C_faded_blue + palette purple: C_faded_purple + palette aqua: C_faded_aqua + palette orange: C_faded_orange + end + + dark! + mode :light + + style Text, :fg => :fg0, :bg => :bg0 + style Error, :fg => :red, :bg => :bg0, :bold => true + style Comment, :fg => :gray, :italic => true + + style Comment::Preproc, :fg => :aqua + + style Name::Tag, :fg => :red + + style Operator, + Punctuation, :fg => :fg0 + + style Generic::Inserted, :fg => :green, :bg => :bg0 + style Generic::Deleted, :fg => :red, :bg => :bg0 + style Generic::Heading, :fg => :green, :bold => true + + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + + style Keyword, :fg => :red + style Keyword::Constant, :fg => :purple + style Keyword::Type, :fg => :yellow + + style Keyword::Declaration, :fg => :orange + + style Literal::String, + Literal::String::Interpol, + Literal::String::Regex, :fg => :green, :italic => true + + style Literal::String::Affix, :fg => :red + + style Literal::String::Escape, :fg => :orange + + style Name::Namespace, + Name::Class, :fg => :aqua + + style Name::Constant, :fg => :purple + + style Name::Attribute, :fg => :green + + style Literal::Number, :fg => :purple + + style Literal::String::Symbol, :fg => :blue + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/igor_pro.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/igor_pro.rb new file mode 100644 index 0000000..abcc758 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/igor_pro.rb @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class IgorPro < CSSTheme + name 'igorpro' + + style Text, :fg => '#444444' + style Comment::Preproc, :fg => '#CC00A3' + style Comment::Special, :fg => '#CC00A3' + style Comment, :fg => '#FF0000' + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + style Keyword::Constant, :fg => '#C34E00' + style Keyword::Declaration, :fg => '#0000FF' + style Keyword::Reserved, :fg => '#007575' + style Keyword, :fg => '#0000FF' + style Literal::String, :fg => '#009C00' + style Literal::String::Affix, :fg => '#0000FF' + style Name::Builtin, :fg => '#C34E00' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/magritte.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/magritte.rb new file mode 100644 index 0000000..09fc1ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/magritte.rb @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class Magritte < CSSTheme + name 'magritte' + + palette :dragon => '#006c6c' + palette :black => '#000000' + palette :forest => '#007500' + palette :candy => '#ff0089' + palette :wine => '#7c0000' + palette :grape => '#4c48fe' + palette :dark => '#000707' + palette :cherry => '#f22700' + palette :white => '#ffffff' + palette :royal => '#19003a' + + palette :purple => '#840084' + palette :chocolate => '#920241' + palette :lavender => '#d8d9ff' + palette :eggshell => '#f3ffff' + palette :yellow => '#ffff3f' + + palette :lightgray => '#BBBBBB' + palette :darkgray => '#999999' + + style Text, :fg => :dark, :bg => :eggshell + style Generic::Lineno, :fg => :eggshell, :bg => :dark + + # style Generic::Prompt, :fg => :chilly, :bold => true + + style Comment, :fg => :dragon, :italic => true + style Comment::Preproc, :fg => :chocolate, :bold => true + style Error, :fg => :eggshell, :bg => :cherry + style Generic::Error, :fg => :cherry, :italic => true, :bold => true + style Keyword, :fg => :royal, :bold => true + style Operator, :fg => :grape, :bold => true + style Punctuation, :fg => :grape + style Generic::Deleted, :fg => :cherry + style Generic::Inserted, :fg => :forest + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + style Generic::Traceback, :fg => :black, :bg => :lavender + style Keyword::Constant, :fg => :forest, :bold => true + style Keyword::Namespace, + Keyword::Pseudo, + Keyword::Reserved, + Generic::Heading, + Generic::Subheading, :fg => :forest, :bold => true + style Keyword::Type, + Name::Constant, + Name::Class, + Name::Decorator, + Name::Namespace, + Name::Builtin::Pseudo, + Name::Exception, :fg => :chocolate, :bold => true + style Name::Label, + Name::Tag, :fg => :purple, :bold => true + style Literal::Number, + Literal::Date, :fg => :forest, :bold => true + style Literal::String::Symbol, :fg => :forest + style Literal::String, :fg => :wine, :bold => true + style Literal::String::Affix, :fg => :royal, :bold => true + style Literal::String::Escape, + Literal::String::Char, + Literal::String::Interpol, :fg => :purple, :bold => true + style Name::Builtin, :bold => true + style Name::Entity, :fg => :darkgray, :bold => true + style Text::Whitespace, :fg => :lightgray + style Generic::Output, :fg => :royal + style Name::Function, + Name::Property, + Name::Attribute, :fg => :candy + style Name::Variable, :fg => :candy, :bold => true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/molokai.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/molokai.rb new file mode 100644 index 0000000..33d0391 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/molokai.rb @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class Molokai < CSSTheme + name 'molokai' + + palette :black => '#1b1d1e' + palette :white => '#f8f8f2' + palette :blue => '#66d9ef' + palette :green => '#a6e22e' + palette :grey => '#403d3d' + palette :red => '#f92672' + palette :light_grey => '#465457' + palette :dark_blue => '#5e5d83' + palette :violet => '#af87ff' + palette :yellow => '#d7d787' + + style Comment, + Comment::Multiline, + Comment::Single, :fg => :dark_blue, :italic => true + style Comment::Preproc, :fg => :light_grey, :bold => true + style Comment::Special, :fg => :light_grey, :italic => true, :bold => true + style Error, :fg => :white, :bg => :grey + style Generic::Inserted, :fg => :green + style Generic::Deleted, :fg => :red + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Error, + Generic::Traceback, :fg => :red + style Generic::Heading, :fg => :grey + style Generic::Output, :fg => :grey + style Generic::Prompt, :fg => :blue + style Generic::Strong, :bold => true + style Generic::Subheading, :fg => :light_grey + style Keyword, + Keyword::Constant, + Keyword::Declaration, + Keyword::Pseudo, + Keyword::Reserved, + Keyword::Type, :fg => :blue, :bold => true + style Keyword::Namespace, + Operator::Word, + Operator, :fg => :red, :bold => true + style Literal::Number::Float, + Literal::Number::Hex, + Literal::Number::Integer::Long, + Literal::Number::Integer, + Literal::Number::Oct, + Literal::Number, + Literal::String::Escape, :fg => :violet + style Literal::String::Backtick, + Literal::String::Char, + Literal::String::Doc, + Literal::String::Double, + Literal::String::Heredoc, + Literal::String::Interpol, + Literal::String::Other, + Literal::String::Regex, + Literal::String::Single, + Literal::String::Symbol, + Literal::String, :fg => :yellow + style Name::Attribute, :fg => :green + style Name::Class, + Name::Decorator, + Name::Exception, + Name::Function, :fg => :green, :bold => true + style Name::Constant, :fg => :blue + style Name::Builtin::Pseudo, + Name::Builtin, + Name::Entity, + Name::Namespace, + Name::Variable::Class, + Name::Variable::Global, + Name::Variable::Instance, + Name::Variable, + Text::Whitespace, :fg => :white + style Name::Label, :fg => :white, :bold => true + style Name::Tag, :fg => :red + style Text, :fg => :white, :bg => :black + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/monokai.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/monokai.rb new file mode 100644 index 0000000..412f860 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/monokai.rb @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class Monokai < CSSTheme + name 'monokai' + + palette :black => '#000000' + palette :bright_green => '#a6e22e' + palette :bright_pink => '#f92672' + palette :carmine => '#960050' + palette :dark => '#49483e' + palette :dark_grey => '#888888' + palette :dark_red => '#aa0000' + palette :dimgrey => '#75715e' + palette :dimgreen => '#324932' + palette :dimred => '#493131' + palette :emperor => '#555555' + palette :grey => '#999999' + palette :light_grey => '#aaaaaa' + palette :light_violet => '#ae81ff' + palette :soft_cyan => '#66d9ef' + palette :soft_yellow => '#e6db74' + palette :very_dark => '#1e0010' + palette :whitish => '#f8f8f2' + palette :orange => '#f6aa11' + palette :white => '#ffffff' + + style Comment, + Comment::Multiline, + Comment::Single, :fg => :dimgrey, :italic => true + style Comment::Preproc, :fg => :dimgrey, :bold => true + style Comment::Special, :fg => :dimgrey, :italic => true, :bold => true + style Error, :fg => :carmine, :bg => :very_dark + style Generic::Inserted, :fg => :white, :bg => :dimgreen + style Generic::Deleted, :fg => :white, :bg => :dimred + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Error, + Generic::Traceback, :fg => :dark_red + style Generic::Heading, :fg => :grey + style Generic::Output, :fg => :dark_grey + style Generic::Prompt, :fg => :emperor + style Generic::Strong, :bold => true + style Generic::Subheading, :fg => :light_grey + style Keyword, + Keyword::Constant, + Keyword::Declaration, + Keyword::Pseudo, + Keyword::Reserved, + Keyword::Type, :fg => :soft_cyan, :bold => true + style Keyword::Namespace, + Operator::Word, + Operator, :fg => :bright_pink, :bold => true + style Literal::Number::Float, + Literal::Number::Hex, + Literal::Number::Integer::Long, + Literal::Number::Integer, + Literal::Number::Oct, + Literal::Number, + Literal::String::Escape, :fg => :light_violet + style Literal::String::Affix, :fg => :soft_cyan, :bold => true + style Literal::String::Backtick, + Literal::String::Char, + Literal::String::Doc, + Literal::String::Double, + Literal::String::Heredoc, + Literal::String::Interpol, + Literal::String::Other, + Literal::String::Regex, + Literal::String::Single, + Literal::String::Symbol, + Literal::String, :fg => :soft_yellow + style Name::Attribute, :fg => :bright_green + style Name::Class, + Name::Decorator, + Name::Exception, + Name::Function, :fg => :bright_green, :bold => true + style Name::Constant, :fg => :soft_cyan + style Name::Builtin::Pseudo, + Name::Builtin, + Name::Entity, + Name::Namespace, + Name::Variable::Class, + Name::Variable::Global, + Name::Variable::Instance, + Name::Variable, + Text::Whitespace, :fg => :whitish + style Name::Label, :fg => :whitish, :bold => true + style Name::Tag, :fg => :bright_pink + style Text, :fg => :whitish, :bg => :dark + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/monokai_sublime.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/monokai_sublime.rb new file mode 100644 index 0000000..b0f2cd6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/monokai_sublime.rb @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class MonokaiSublime < CSSTheme + name 'monokai.sublime' + + palette :black => '#000000' + palette :bright_green => '#a6e22e' + palette :bright_pink => '#f92672' + palette :carmine => '#960050' + palette :dark => '#49483e' + palette :dark_graphite => '#272822' + palette :dark_grey => '#888888' + palette :dark_red => '#aa0000' + palette :dimgrey => '#75715e' + palette :emperor => '#555555' + palette :grey => '#999999' + palette :light_grey => '#aaaaaa' + palette :light_violet => '#ae81ff' + palette :soft_cyan => '#66d9ef' + palette :soft_yellow => '#e6db74' + palette :very_dark => '#1e0010' + palette :whitish => '#f8f8f2' + palette :orange => '#f6aa11' + palette :white => '#ffffff' + + style Generic::Heading, :fg => :grey + style Literal::String::Regex, :fg => :orange + style Generic::Output, :fg => :dark_grey + style Generic::Prompt, :fg => :emperor + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + style Generic::Subheading, :fg => :light_grey + style Name::Builtin, :fg => :orange + style Comment::Multiline, + Comment::Preproc, + Comment::Single, + Comment::Special, + Comment, :fg => :dimgrey + style Error, + Generic::Error, + Generic::Traceback, :fg => :carmine + style Generic::Deleted, + Generic::Inserted, :fg => :dark + style Keyword::Constant, + Keyword::Declaration, + Keyword::Reserved, + Name::Constant, + Keyword::Type, :fg => :soft_cyan + style Literal::Number::Float, + Literal::Number::Hex, + Literal::Number::Integer::Long, + Literal::Number::Integer, + Literal::Number::Oct, + Literal::Number, + Literal::String::Char, + Literal::String::Escape, + Literal::String::Symbol, :fg => :light_violet + style Literal::String::Doc, + Literal::String::Double, + Literal::String::Backtick, + Literal::String::Heredoc, + Literal::String::Interpol, + Literal::String::Other, + Literal::String::Single, + Literal::String, :fg => :soft_yellow + style Name::Attribute, + Name::Class, + Name::Decorator, + Name::Exception, + Name::Function, :fg => :bright_green + style Name::Variable::Class, + Name::Namespace, + Name::Label, + Name::Entity, + Name::Builtin::Pseudo, + Name::Variable::Global, + Name::Variable::Instance, + Name::Variable, + Text::Whitespace, + Text, + Name, :fg => :white, :bg => :dark_graphite + style Operator::Word, + Name::Tag, + Keyword, + Keyword::Namespace, + Keyword::Pseudo, + Operator, :fg => :bright_pink + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/pastie.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/pastie.rb new file mode 100644 index 0000000..f10c7b0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/pastie.rb @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + # A port of the pastie style from Pygments. + # See https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/styles/pastie.py + class Pastie < CSSTheme + name 'pastie' + + style Comment, :fg => '#888888' + style Comment::Preproc, :fg => '#cc0000', :bold => true + style Comment::Special, :fg => '#cc0000', :bg => '#fff0f0', :bold => true + + style Error, :fg => '#a61717', :bg => '#e3d2d2' + style Generic::Error, :fg => '#aa0000' + + style Generic::Heading, :fg => '#333333' + style Generic::Subheading, :fg => '#666666' + + style Generic::Deleted, :fg => '#000000', :bg => '#ffdddd' + style Generic::Inserted, :fg => '#000000', :bg => '#ddffdd' + + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + + style Generic::Lineno, :fg => '#888888' + style Generic::Output, :fg => '#888888' + style Generic::Prompt, :fg => '#555555' + style Generic::Traceback, :fg => '#aa0000' + + style Keyword, :fg => '#008800', :bold => true + style Keyword::Pseudo, :fg => '#008800' + style Keyword::Type, :fg => '#888888', :bold => true + + style Num, :fg => '#0000dd', :bold => true + + style Str, :fg => '#dd2200', :bg => '#fff0f0' + style Str::Affix, :fg => '#008800', :bold => true + style Str::Escape, :fg => '#0044dd', :bg => '#fff0f0' + style Str::Interpol, :fg => '#3333bb', :bg => '#fff0f0' + style Str::Other, :fg => '#22bb22', :bg => '#f0fff0' + #style Str::Regex, :fg => '#008800', :bg => '#fff0ff' + # The background color on regex really doesn't look good, so let's drop it + style Str::Regex, :fg => '#008800' + style Str::Symbol, :fg => '#aa6600', :bg => '#fff0f0' + + style Name::Attribute, :fg => '#336699' + style Name::Builtin, :fg => '#003388' + style Name::Class, :fg => '#bb0066', :bold => true + style Name::Constant, :fg => '#003366', :bold => true + style Name::Decorator, :fg => '#555555' + style Name::Exception, :fg => '#bb0066', :bold => true + style Name::Function, :fg => '#0066bb', :bold => true + #style Name::Label, :fg => '#336699', :italic => true + # Name::Label is used for built-in CSS properties in Rouge, so let's drop italics + style Name::Label, :fg => '#336699' + style Name::Namespace, :fg => '#bb0066', :bold => true + style Name::Property, :fg => '#336699', :bold => true + style Name::Tag, :fg => '#bb0066', :bold => true + style Name::Variable, :fg => '#336699' + style Name::Variable::Global, :fg => '#dd7700' + style Name::Variable::Instance, :fg => '#3333bb' + + style Operator::Word, :fg => '#008800' + + style Text, {} + style Text::Whitespace, :fg => '#bbbbbb' + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/thankful_eyes.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/thankful_eyes.rb new file mode 100644 index 0000000..2f84209 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/thankful_eyes.rb @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class ThankfulEyes < CSSTheme + name 'thankful_eyes' + + # pallette, from GTKSourceView's ThankfulEyes + palette :cool_as_ice => '#6c8b9f' + palette :slate_blue => '#4e5d62' + palette :eggshell_cloud => '#dee5e7' + palette :krasna => '#122b3b' + palette :aluminum1 => '#fefeec' + palette :scarletred2 => '#cc0000' + palette :butter3 => '#c4a000' + palette :go_get_it => '#b2fd6d' + palette :chilly => '#a8e1fe' + palette :unicorn => '#faf6e4' + palette :sandy => '#f6dd62' + palette :pink_merengue => '#f696db' + palette :dune => '#fff0a6' + palette :backlit => '#4df4ff' + palette :schrill => '#ffb000' + + style Text, :fg => :unicorn, :bg => :krasna + style Generic::Lineno, :fg => :eggshell_cloud, :bg => :slate_blue + + style Generic::Prompt, :fg => :chilly, :bold => true + + style Comment, :fg => :cool_as_ice, :italic => true + style Comment::Preproc, :fg => :go_get_it, :bold => true + style Error, :fg => :aluminum1, :bg => :scarletred2 + style Generic::Error, :fg => :scarletred2, :italic => true, :bold => true + style Keyword, :fg => :sandy, :bold => true + style Operator, :fg => :backlit, :bold => true + style Punctuation, :fg => :backlit + style Generic::Deleted, :fg => :scarletred2 + style Generic::Inserted, :fg => :go_get_it + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + style Generic::Traceback, :fg => :eggshell_cloud, :bg => :slate_blue + style Keyword::Constant, :fg => :pink_merengue, :bold => true + style Keyword::Namespace, + Keyword::Pseudo, + Keyword::Reserved, + Generic::Heading, + Generic::Subheading, :fg => :schrill, :bold => true + style Keyword::Type, + Name::Constant, + Name::Class, + Name::Decorator, + Name::Namespace, + Name::Builtin::Pseudo, + Name::Exception, :fg => :go_get_it, :bold => true + style Name::Label, + Name::Tag, :fg => :schrill, :bold => true + style Literal::Number, + Literal::Date, + Literal::String::Symbol, :fg => :pink_merengue, :bold => true + style Literal::String, :fg => :dune, :bold => true + style Literal::String::Affix, :fg => :sandy, :bold => true + style Literal::String::Escape, + Literal::String::Char, + Literal::String::Interpol, :fg => :backlit, :bold => true + style Name::Builtin, :bold => true + style Name::Entity, :fg => '#999999', :bold => true + style Text::Whitespace, + Generic::Output, :fg => '#BBBBBB' + style Name::Function, + Name::Property, + Name::Attribute, :fg => :chilly + style Name::Variable, :fg => :chilly, :bold => true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/tulip.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/tulip.rb new file mode 100644 index 0000000..5429a66 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/themes/tulip.rb @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Themes + class Tulip < CSSTheme + name 'tulip' + + palette :purple => '#766DAF' + palette :lpurple => '#9f93e6' + palette :orange => '#FAAF4C' + palette :green => '#3FB34F' + palette :lgreen => '#41ff5b' + palette :yellow => '#FFF02A' + palette :black => '#000000' + palette :gray => '#6D6E70' + palette :red => '#CC0000' + palette :dark_purple => '#231529' + palette :lunicorn => '#faf8ed' + palette :white => '#FFFFFF' + palette :earth => '#181a27' + palette :dune => '#fff0a6' + + style Text, :fg => :white, :bg => :dark_purple + + style Comment, :fg => :gray, :italic => true + style Comment::Preproc, :fg => :lgreen, :bold => true + style Error, + Generic::Error, :fg => :white, :bg => :red + style Keyword, :fg => :yellow, :bold => true + style Operator, + Punctuation, :fg => :lgreen + style Generic::Deleted, :fg => :red + style Generic::Inserted, :fg => :green + style Generic::Emph, :italic => true + style Generic::EmphStrong, :italic => true, :bold => true + style Generic::Strong, :bold => true + style Generic::Traceback, + Generic::Lineno, :fg => :white, :bg => :purple + style Keyword::Constant, :fg => :lpurple, :bold => true + style Keyword::Namespace, + Keyword::Pseudo, + Keyword::Reserved, + Generic::Heading, + Generic::Subheading, :fg => :white, :bold => true + style Keyword::Type, + Name::Constant, + Name::Class, + Name::Decorator, + Name::Namespace, + Name::Builtin::Pseudo, + Name::Exception, :fg => :orange, :bold => true + style Name::Label, + Name::Tag, :fg => :lpurple, :bold => true + style Literal::Number, + Literal::Date, + Literal::String::Symbol, :fg => :lpurple, :bold => true + style Literal::String, :fg => :dune, :bold => true + style Literal::String::Affix, :fg => :yellow, :bold => true + style Literal::String::Escape, + Literal::String::Char, + Literal::String::Interpol, :fg => :orange, :bold => true + style Name::Builtin, :bold => true + style Name::Entity, :fg => '#999999', :bold => true + style Text::Whitespace, :fg => '#BBBBBB' + style Name::Function, + Name::Property, + Name::Attribute, :fg => :lgreen + style Name::Variable, :fg => :lgreen, :bold => true + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/token.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/token.rb new file mode 100644 index 0000000..9c3f867 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/token.rb @@ -0,0 +1,192 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + class Token + class << self + attr_reader :name + attr_reader :parent + attr_reader :shortname + + def cache + @cache ||= {} + end + + def sub_tokens + @sub_tokens ||= {} + end + + def [](qualname) + return qualname unless qualname.is_a? ::String + + Token.cache[qualname] + end + + def inspect + "" + end + + def matches?(other) + other.token_chain.include? self + end + + def token_chain + @token_chain ||= ancestors.take_while { |x| x != Token }.reverse + end + + def qualname + @qualname ||= token_chain.map(&:name).join('.') + end + + def register! + Token.cache[self.qualname] = self + parent.sub_tokens[self.name] = self + end + + def make_token(name, shortname, &b) + parent = self + Class.new(parent) do + @parent = parent + @name = name + @shortname = shortname + register! + class_eval(&b) if b + end + end + + def token(name, shortname, &b) + tok = make_token(name, shortname, &b) + const_set(name, tok) + end + + def each_token(&b) + Token.cache.each do |(_, t)| + b.call(t) + end + end + end + + module Tokens + def self.token(name, shortname, &b) + tok = Token.make_token(name, shortname, &b) + const_set(name, tok) + end + + # XXX IMPORTANT XXX + # For compatibility, this list must be kept in sync with + # pygments.token.STANDARD_TYPES + # please see https://github.com/jneen/rouge/wiki/List-of-tokens + token :Text, '' do + token :Whitespace, 'w' + end + + token :Escape, 'esc' + token :Error, 'err' + token :Other, 'x' + + token :Keyword, 'k' do + token :Constant, 'kc' + token :Declaration, 'kd' + token :Namespace, 'kn' + token :Pseudo, 'kp' + token :Reserved, 'kr' + token :Type, 'kt' + token :Variable, 'kv' + end + + token :Name, 'n' do + token :Attribute, 'na' + token :Builtin, 'nb' do + token :Pseudo, 'bp' + end + token :Class, 'nc' + token :Constant, 'no' + token :Decorator, 'nd' + token :Entity, 'ni' + token :Exception, 'ne' + token :Function, 'nf' do + token :Magic, 'fm' + end + token :Property, 'py' + token :Label, 'nl' + token :Namespace, 'nn' + token :Other, 'nx' + token :Tag, 'nt' + token :Variable, 'nv' do + token :Class, 'vc' + token :Global, 'vg' + token :Instance, 'vi' + token :Magic, 'vm' + end + end + + token :Literal, 'l' do + token :Date, 'ld' + + token :String, 's' do + token :Affix, 'sa' + token :Backtick, 'sb' + token :Char, 'sc' + token :Delimiter, 'dl' + token :Doc, 'sd' + token :Double, 's2' + token :Escape, 'se' + token :Heredoc, 'sh' + token :Interpol, 'si' + token :Other, 'sx' + token :Regex, 'sr' + token :Single, 's1' + token :Symbol, 'ss' + end + + token :Number, 'm' do + token :Bin, 'mb' + token :Float, 'mf' + token :Hex, 'mh' + token :Integer, 'mi' do + token :Long, 'il' + end + token :Oct, 'mo' + token :Other, 'mx' + end + end + + token :Operator, 'o' do + token :Word, 'ow' + end + + token :Punctuation, 'p' do + token :Indicator, 'pi' + end + + token :Comment, 'c' do + token :Hashbang, 'ch' + token :Doc, 'cd' + token :Multiline, 'cm' + token :Preproc, 'cp' + token :PreprocFile, 'cpf' + token :Single, 'c1' + token :Special, 'cs' + end + + token :Generic, 'g' do + token :Deleted, 'gd' + token :Emph, 'ge' + token :EmphStrong, 'ges' + token :Error, 'gr' + token :Heading, 'gh' + token :Inserted, 'gi' + token :Lineno, 'gl' + token :Output, 'go' + token :Prompt, 'gp' + token :Strong, 'gs' + token :Subheading, 'gu' + token :Traceback, 'gt' + end + + # convenience + Num = Literal::Number + Str = Literal::String + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/util.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/util.rb new file mode 100644 index 0000000..d204686 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/util.rb @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + class InheritableHash < Hash + def initialize(parent=nil) + @parent = parent + end + + def [](k) + value = super + return value if own_keys.include?(k) + + value || parent[k] + end + + def parent + @parent ||= {} + end + + def include?(k) + super or parent.include?(k) + end + + def each(&b) + keys.each do |k| + b.call(k, self[k]) + end + end + + alias own_keys keys + def keys + keys = own_keys.concat(parent.keys) + keys.uniq! + keys + end + end + + class InheritableList + include Enumerable + + def initialize(parent=nil) + @parent = parent + end + + def parent + @parent ||= [] + end + + def each(&b) + return enum_for(:each) unless block_given? + + parent.each(&b) + own_entries.each(&b) + end + + def own_entries + @own_entries ||= [] + end + + def push(o) + own_entries << o + end + alias << push + end + + # shared methods for some indentation-sensitive lexers + module Indentation + def reset! + super + @block_state = @block_indentation = nil + end + + # push a state for the next indented block + def starts_block(block_state) + @block_state = block_state + @block_indentation = @last_indentation || '' + puts " starts_block: #{block_state.inspect}" if @debug + puts " block_indentation: #{@block_indentation.inspect}" if @debug + end + + # handle a single indented line + def indentation(indent_str) + puts " indentation: #{indent_str.inspect}" if @debug + puts " block_indentation: #{@block_indentation.inspect}" if @debug + @last_indentation = indent_str + + # if it's an indent and we know where to go next, + # push that state. otherwise, push content and + # clear the block state. + if (@block_state && + indent_str.start_with?(@block_indentation) && + indent_str != @block_indentation + ) + push @block_state + else + @block_state = @block_indentation = nil + push :content + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/version.rb b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/version.rb new file mode 100644 index 0000000..1e112cf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/lib/rouge/version.rb @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + def self.version + "4.3.0" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/rouge.gemspec b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/rouge.gemspec new file mode 100644 index 0000000..f1a6509 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/rouge-4.3.0/rouge.gemspec @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require './lib/rouge/version' + +Gem::Specification.new do |s| + s.name = "rouge" + s.version = Rouge.version + s.authors = ["Jeanine Adkisson"] + s.email = ["jneen@jneen.net"] + s.summary = "A pure-ruby colorizer based on pygments" + s.description = <<-desc.strip.gsub(/\s+/, ' ') + Rouge aims to a be a simple, easy-to-extend drop-in replacement + for pygments. + desc + s.homepage = "http://rouge.jneen.net/" + s.files = Dir['Gemfile', 'LICENSE', 'rouge.gemspec', 'lib/**/*.rb', 'lib/**/*.yml', 'bin/rougify', 'lib/rouge/demos/*'] + s.executables = %w(rougify) + s.licenses = ['MIT', 'BSD-2-Clause'] + s.required_ruby_version = '>= 2.7' + s.metadata = { + "bug_tracker_uri" => "https://github.com/rouge-ruby/rouge/issues", + "changelog_uri" => "https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md", + "documentation_uri" => "https://rouge-ruby.github.io/docs/", + "source_code_uri" => "https://github.com/rouge-ruby/rouge" + } +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/.gitignore b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/.gitignore new file mode 100644 index 0000000..5fb70cb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/.gitignore @@ -0,0 +1,3 @@ +*.gem +Gemfile.lock +spec/store.yaml diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/.travis.yml b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/.travis.yml new file mode 100644 index 0000000..231fdba --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/.travis.yml @@ -0,0 +1,48 @@ +language: + ruby + +before_install: + gem install bundler + +script: + bundle exec rake spec + +rvm: + - ruby-head + - 2.0.0 + - 1.9.3 + - 1.9.2 + - 1.8.7 + - rbx-19mode + - rbx-18mode + - jruby-head + - jruby-19mode + - jruby-18mode + - ree + +env: + - YAMLER=syck + - YAMLER=psych + +matrix: + allow_failures: + - rvm: ruby-head + - rvm: rbx-19mode + - rvm: rbx-18mode + - rvm: jruby-head + - rvm: ree + + exclude: + - rvm: 1.8.7 + env: YAMLER=psych + - rvm: jruby-head + env: YAMLER=syck + - rvm: jruby-19mode + env: YAMLER=syck + - rvm: jruby-18mode + env: YAMLER=syck + +branches: + only: + - master + diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/CHANGES.md b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/CHANGES.md new file mode 100644 index 0000000..2120a0b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/CHANGES.md @@ -0,0 +1,154 @@ +1.0.5 +----- + +- fixed [#80](https://github.com/dtao/safe_yaml/issues/80): uninitialized constant DateTime + +1.0.2 +----- + +- added warning when using Psych + an older version of libyaml + +1.0.1 +----- + +- fixed handling for strings that look like (invalid) dates + +1.0.0 +----- + +- updated date parsing to use local timezone +- **now requiring "safe_yaml/load" provides `SafeYAML.load` without clobbering `YAML`** +- fixed handling of empty files +- fixed some (edge case) integer parsing bugs +- fixed some JRuby-specific issues + +0.9.7 +----- + +- made handling of document frontmatter more robust +- added more descriptive message to the warning for omitting the :safe option + +0.9.6 +----- + +- fixed handling of files with trailing content (after closing `---`) + +0.9.5 +----- + +- fixed permissions AGAIN + +0.9.4 +----- + +- corrected handling of symbols + +0.9.3 +----- + +- fixed permissions :( + +0.9.2 +----- + +- fixed error w/ parsing "!" when whitelisting tags +- fixed parsing of the number 0 (d'oh!) + +0.9.1 +----- + +- added Yecht support (JRuby) +- more bug fixes + +0.9.0 +----- + +- added `whitelist!` method for easily whitelisting tags +- added support for call-specific options +- removed deprecated methods + +0.8.6 +----- + +- fixed bug in float matcher + +0.8.5 +----- + +- performance improvements +- made less verbose by default +- bug fixes + +0.8.4 +----- + +- enhancements to parsing of integers, floats, and dates +- updated built-in whitelist +- more bug fixes + +0.8.3 +----- + +- fixed exception on parsing empty document +- fixed handling of octal & hexadecimal numbers + +0.8.2 +----- + +- bug fixes + +0.8.1 +----- + +- added `:raise_on_unknown_tag` option +- renamed `reset_defaults!` to `restore_defaults!` + +0.8 +--- + +- added tag whitelisting +- more API changes + +0.7 +--- + +- separated YAML engine support from Ruby version +- added support for binary scalars +- numerous bug fixes and enhancements + +0.6 +--- + +- several API changes +- added `SafeYAML::OPTIONS` for specifying default behavior + +0.5 +--- + +Added support for dates + +0.4 +--- + +- efficiency improvements +- made `YAML.load` use `YAML.safe_load` by default +- made symbol deserialization optional + +0.3 +--- + +Added Syck support + +0.2 +--- + +Added support for: + +- anchors & aliases +- booleans +- nils + +0.1 +--- + +Initial release \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/Gemfile b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/Gemfile new file mode 100644 index 0000000..24d7e3e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/Gemfile @@ -0,0 +1,11 @@ +source "https://rubygems.org" + +gemspec + +group :development do + gem "hashie" + gem "heredoc_unindent" + gem "rake" + gem "rspec" + gem "travis-lint" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/LICENSE.txt new file mode 100644 index 0000000..4b276dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2013 Dan Tao + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/README.md b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/README.md new file mode 100644 index 0000000..a7b7bdc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/README.md @@ -0,0 +1,191 @@ +SafeYAML +======== + +[![Build Status](https://travis-ci.org/dtao/safe_yaml.png)](http://travis-ci.org/dtao/safe_yaml) +[![Gem Version](https://badge.fury.io/rb/safe_yaml.png)](http://badge.fury.io/rb/safe_yaml) + +The **SafeYAML** gem provides an alternative implementation of `YAML.load` suitable for accepting user input in Ruby applications. Unlike Ruby's built-in implementation of `YAML.load`, SafeYAML's version will not expose apps to arbitrary code execution exploits (such as [the ones discovered](http://www.reddit.com/r/netsec/comments/167c11/serious_vulnerability_in_ruby_on_rails_allowing/) [in Rails in early 2013](http://www.h-online.com/open/news/item/Rails-developers-close-another-extremely-critical-flaw-1793511.html)). + +**If you encounter any issues with SafeYAML, check out the 'Common Issues' section below.** If you don't see anything that addresses the problem you're experiencing, by all means, [create an issue](https://github.com/dtao/safe_yaml/issues/new)! + +Installation +------------ + +Add this line to your application's Gemfile: + +```ruby +gem "safe_yaml" +``` + +Configuration +------------- + +If *all you do* is add SafeYAML to your project, then `YAML.load` will operate in "safe" mode, which means it won't deserialize arbitrary objects. However, it will issue a warning the first time you call it because you haven't explicitly specified whether you want safe or unsafe behavior by default. To specify this behavior (e.g., in a Rails initializer): + +```ruby +SafeYAML::OPTIONS[:default_mode] = :safe # or :unsafe +``` + +Another important option you might want to specify on startup is whether or not to allow *symbols* to be deserialized. The default setting is `false`, since symbols are not garbage collected in Ruby and so deserializing them from YAML may render your application vulnerable to a DOS (denial of service) attack. To allow symbol deserialization by default: + +```ruby +SafeYAML::OPTIONS[:deserialize_symbols] = true +``` + +For more information on these and other options, see the "Usage" section down below. + +What is this gem for, exactly? +------------------------------ + +Suppose your application were to use a popular open source library which contained code like this: + +```ruby +class ClassBuilder + def []=(key, value) + @class ||= Class.new + + @class.class_eval <<-EOS + def #{key} + #{value} + end + EOS + end + + def create + @class.new + end +end +``` + +Now, if you were to use `YAML.load` on user input anywhere in your application without the SafeYAML gem installed, an attacker who suspected you were using this library could send a request with a carefully-crafted YAML string to execute arbitrary code (yes, including `system("unix command")`) on your servers. + +This simple example demonstrates the vulnerability: + +```ruby +yaml = <<-EOYAML +--- !ruby/hash:ClassBuilder +"foo; end; puts %(I'm in yr system!); def bar": "baz" +EOYAML +``` + + > YAML.load(yaml) + I'm in yr system! + => #> + +With SafeYAML, the same attacker would be thwarted: + + > require "safe_yaml" + => true + > YAML.load(yaml, :safe => true) + => {"foo; end; puts %(I'm in yr system!); def bar"=>"baz"} + +Usage +----- + +When you require the safe_yaml gem in your project, `YAML.load` is patched to accept one additional (optional) `options` parameter. This changes the method signature as follows: + +- for Syck and Psych prior to Ruby 1.9.3: `YAML.load(yaml, options={})` +- for Psych in 1.9.3 and later: `YAML.load(yaml, filename=nil, options={})` + +The most important option is the `:safe` option (default: `true`), which controls whether or not to deserialize arbitrary objects when parsing a YAML document. The other options, along with explanations, are as follows. + +- `:deserialize_symbols` (default: `false`): Controls whether or not YAML will deserialize symbols. It is probably best to only enable this option where necessary, e.g. to make trusted libraries work. Symbols receive special treatment in Ruby and are not garbage collected, which means deserializing them indiscriminately may render your site vulnerable to a DOS attack. + +- `:whitelisted_tags`: Accepts an array of YAML tags that designate trusted types, e.g., ones that can be deserialized without worrying about any resulting security vulnerabilities. When any of the given tags are encountered in a YAML document, the associated data will be parsed by the underlying YAML engine (Syck or Psych) for the version of Ruby you are using. See the "Whitelisting Trusted Types" section below for more information. + +- `:custom_initializers`: Similar to the `:whitelisted_tags` option, but allows you to provide your own initializers for specified tags rather than using Syck or Psyck. Accepts a hash with string tags for keys and lambdas for values. + +- `:raise_on_unknown_tag` (default: `false`): Represents the highest possible level of paranoia. If the YAML engine encounters any tag other than ones that are automatically trusted by SafeYAML or that you've explicitly whitelisted, it will raise an exception. This may be a good choice if you expect to always be dealing with perfectly safe YAML and want your application to fail loudly upon encountering questionable data. + +All of the above options can be set at the global level via `SafeYAML::OPTIONS`. You can also set each one individually per call to `YAML.load`; an option explicitly passed to `load` will take precedence over an option specified globally. + +What if I don't *want* to patch `YAML`? +--------------------------------------- + +[Excellent question](https://github.com/dtao/safe_yaml/issues/47)! You can also get the methods `SafeYAML.load` and `SafeYAML.load_file` without touching the `YAML` module at all like this: + +```ruby +require "safe_yaml/load" # instead of require "safe_yaml" +``` + +This way, you can use `SafeYAML.load` to parse YAML that *you* don't trust, without affecting the rest of an application (if you're developing a library, for example). + +Supported Types +--------------- + +The way that SafeYAML works is by restricting the kinds of objects that can be deserialized via `YAML.load`. More specifically, only the following types of objects can be deserialized by default: + +- Hashes +- Arrays +- Strings +- Numbers +- Dates +- Times +- Booleans +- Nils + +Again, deserialization of symbols can be enabled globally by setting `SafeYAML::OPTIONS[:deserialize_symbols] = true`, or in a specific call to `YAML.load([some yaml], :deserialize_symbols => true)`. + +Whitelisting Trusted Types +-------------------------- + +SafeYAML supports whitelisting certain YAML tags for trusted types. This is handy when your application uses YAML to serialize and deserialize certain types not listed above, which you know to be free of any deserialization-related vulnerabilities. + +The easiest way to whitelist types is by calling `SafeYAML.whitelist!`, which can accept a variable number of safe types, e.g.: + +```ruby +SafeYAML.whitelist!(Foo, Bar) +``` + +You can also whitelist YAML *tags* via the `:whitelisted_tags` option: + +```ruby +# Using Syck +SafeYAML::OPTIONS[:whitelisted_tags] = ["tag:ruby.yaml.org,2002:object:OpenStruct"] + +# Using Psych +SafeYAML::OPTIONS[:whitelisted_tags] = ["!ruby/object:OpenStruct"] +``` + +And in case you were wondering: no, this feature will *not* allow would-be attackers to embed untrusted types within trusted types: + +```ruby +yaml = <<-EOYAML +--- !ruby/object:OpenStruct +table: + :backdoor: !ruby/hash:ClassBuilder + "foo; end; puts %(I'm in yr system!); def bar": "baz" +EOYAML +``` + + > YAML.safe_load(yaml) + => #"baz"}> + +Known Issues +------------ + +If you add SafeYAML to your project and start seeing any errors about missing keys, or you notice mysterious strings that look like `":foo"` (i.e., start with a colon), it's likely you're seeing errors from symbols being saved in YAML format. If you are able to modify the offending code, you might want to consider changing your YAML content to use plain vanilla strings instead of symbols. If not, you may need to set the `:deserialize_symbols` option to `true`, either in calls to `YAML.load` or---as a last resort---globally, with `SafeYAML::OPTIONS[:deserialize_symbols]`. + +Also be aware that some Ruby libraries, particularly those requiring inter-process communication, leverage YAML's object deserialization functionality and therefore may break or otherwise be impacted by SafeYAML. The following list includes known instances of SafeYAML's interaction with other Ruby gems: + +- [**ActiveRecord**](https://github.com/rails/rails/tree/master/activerecord): uses YAML to control serialization of model objects using the `serialize` class method. If you find that accessing serialized properties on your ActiveRecord models is causing errors, chances are you may need to: + 1. set the `:deserialize_symbols` option to `true`, + 2. whitelist some of the types in your serialized data via `SafeYAML.whitelist!` or the `:whitelisted_tags` option, or + 3. both +- [**delayed_job**](https://github.com/collectiveidea/delayed_job): Uses YAML to serialize the objects on which delayed methods are invoked (with `delay`). The safest solution in this case is to use `SafeYAML.whitelist!` to whitelist the types you need to serialize. +- [**Guard**](https://github.com/guard/guard): Uses YAML as a serialization format for notifications. The data serialized uses symbolic keys, so setting `SafeYAML::OPTIONS[:deserialize_symbols] = true` is necessary to allow Guard to work. +- [**sidekiq**](https://github.com/mperham/sidekiq): Uses a YAML configiuration file with symbolic keys, so setting `SafeYAML::OPTIONS[:deserialize_symbols] = true` should allow it to work. + +The above list will grow over time, as more issues are discovered. + +Versioning +---------- + +SafeYAML will follow [semantic versioning](http://semver.org/) so any updates to the first major version will maintain backwards compatability. So expect primarily bug fixes and feature enhancements (if anything!) from here on out... unless it makes sense to break the interface at some point and introduce a version 2.0, which I honestly think is unlikely. + +Requirements +------------ + +SafeYAML requires Ruby 1.8.7 or newer and works with both [Syck](http://www.ruby-doc.org/stdlib-1.8.7/libdoc/yaml/rdoc/YAML.html) and [Psych](http://github.com/tenderlove/psych). + +If you are using a version of Ruby where Psych is the default YAML engine (e.g., 1.9.3) but you want to use Syck, be sure to set `YAML::ENGINE.yamler = "syck"` **before** requiring the safe_yaml gem. diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/Rakefile b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/Rakefile new file mode 100644 index 0000000..2d9dbc3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/Rakefile @@ -0,0 +1,26 @@ +require "rspec/core/rake_task" + +desc "Run specs" +task :spec => ['spec:app', 'spec:lib'] + +namespace :spec do + desc "Run only specs tagged 'solo'" + RSpec::Core::RakeTask.new(:solo) do |t| + t.verbose = false + t.rspec_opts = %w(--color --tag solo) + end + + desc "Run only specs tagged NOT tagged 'libraries' (for applications)" + RSpec::Core::RakeTask.new(:app) do |t| + t.verbose = false + ENV["MONKEYPATCH_YAML"] = "true" + t.rspec_opts = %w(--color --tag ~libraries) + end + + desc "Run only specs tagged 'libraries'" + RSpec::Core::RakeTask.new(:lib) do |t| + t.verbose = false + ENV["MONKEYPATCH_YAML"] = "false" + t.rspec_opts = %w(--color --tag libraries) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/bin/safe_yaml b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/bin/safe_yaml new file mode 100755 index 0000000..1751a72 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/bin/safe_yaml @@ -0,0 +1,75 @@ +#!/usr/bin/env ruby + +$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib') + +require 'optparse' +require 'safe_yaml/load' + +options = {} +option_parser = OptionParser.new do |opts| + opts.banner = "Usage: safe_yaml [options]" + + opts.on("-f", "--file=", "Parse the given YAML file, dump the result to STDOUT") do |file| + options[:file] = file + end + + opts.on("--libyaml-check", "Check for libyaml vulnerability CVE-2014-2525 on your system") do + options[:libyaml_check] = true + end +end + +option_parser.parse! + +def report_libyaml_ok + puts "\e[32mGood news! You definitely have either a patched or up-to-date libyaml version :)\e[39m" +end + +def check_for_overflow_bug + YAML.load("--- !#{'%20' * 100}") + report_libyaml_ok +end + +def perform_libyaml_check(force=false) + unless SafeYAML::LibyamlChecker.libyaml_version_ok? + warn <<-EOM.gsub(/^ +/, ' ') + + \e[33mSafeYAML Warning\e[39m + \e[33m----------------\e[39m + + \e[31mYou may have an outdated version of libyaml (#{SafeYAML::LibyamlChecker::LIBYAML_VERSION}) installed on your system.\e[39m + + Prior to 0.1.6, libyaml is vulnerable to a heap overflow exploit from malicious YAML payloads. + + For more info, see: + https://www.ruby-lang.org/en/news/2014/03/29/heap-overflow-in-yaml-uri-escape-parsing-cve-2014-2525/ + EOM + end + + puts <<-EOM.gsub(/^ +/, ' ') + + Hit Enter to check if your version of libyaml is vulnerable. This will run a test \e[31mwhich may crash\e[39m + \e[31mthe current process\e[39m. If it does, your system is vulnerable and you should do something about it. + + Type "nm" and hit Enter if you don't want to run the check. + + See the project wiki for more info: + + https://github.com/dtao/safe_yaml/wiki/The-libyaml-vulnerability + EOM + + if STDIN.readline.chomp("\n") != 'nm' + check_for_overflow_bug + end +end + +if options[:libyaml_check] + perform_libyaml_check(options[:force_libyaml_check]) + +elsif options[:file] + yaml = File.read(options[:file]) + result = SafeYAML.load(yaml) + puts result.inspect + +else + puts option_parser.help +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/bundle_install_all_ruby_versions.sh b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/bundle_install_all_ruby_versions.sh new file mode 100755 index 0000000..902d127 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/bundle_install_all_ruby_versions.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" + +declare -a versions=("1.8.7" "1.9.2" "1.9.3" "2.0.0" "2.1.0" "2.1.1" "2.1.2" "ruby-head" "jruby") + +for i in "${versions[@]}" +do + rvm use $i + bundle install +done diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb new file mode 100644 index 0000000..db1957d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb @@ -0,0 +1,94 @@ +require "safe_yaml/load" + +module YAML + def self.load_with_options(yaml, *original_arguments) + filename, options = filename_and_options_from_arguments(original_arguments) + safe_mode = safe_mode_from_options("load", options) + arguments = [yaml] + + if safe_mode == :safe + arguments << filename if SafeYAML::YAML_ENGINE == "psych" + arguments << options_for_safe_load(options) + safe_load(*arguments) + else + arguments << filename if SafeYAML::MULTI_ARGUMENT_YAML_LOAD + unsafe_load(*arguments) + end + end + + def self.load_file_with_options(file, options={}) + safe_mode = safe_mode_from_options("load_file", options) + if safe_mode == :safe + safe_load_file(file, options_for_safe_load(options)) + else + unsafe_load_file(file) + end + end + + def self.safe_load(*args) + SafeYAML.load(*args) + end + + def self.safe_load_file(*args) + SafeYAML.load_file(*args) + end + + if SafeYAML::MULTI_ARGUMENT_YAML_LOAD + def self.unsafe_load_file(filename) + # https://github.com/tenderlove/psych/blob/v1.3.2/lib/psych.rb#L296-298 + File.open(filename, 'r:bom|utf-8') { |f| self.unsafe_load(f, filename) } + end + + else + def self.unsafe_load_file(filename) + # https://github.com/tenderlove/psych/blob/v1.2.2/lib/psych.rb#L231-233 + self.unsafe_load File.open(filename) + end + end + + class << self + alias_method :unsafe_load, :load + alias_method :load, :load_with_options + alias_method :load_file, :load_file_with_options + + private + def filename_and_options_from_arguments(arguments) + if arguments.count == 1 + if arguments.first.is_a?(String) + return arguments.first, {} + else + return nil, arguments.first || {} + end + + else + return arguments.first, arguments.last || {} + end + end + + def safe_mode_from_options(method, options={}) + if options[:safe].nil? + safe_mode = SafeYAML::OPTIONS[:default_mode] || :safe + + if SafeYAML::OPTIONS[:default_mode].nil? && !SafeYAML::OPTIONS[:suppress_warnings] + + Kernel.warn <<-EOWARNING.gsub(/^\s+/, '') + Called '#{method}' without the :safe option -- defaulting to #{safe_mode} mode. + You can avoid this warning in the future by setting the SafeYAML::OPTIONS[:default_mode] option (to :safe or :unsafe). + EOWARNING + + SafeYAML::OPTIONS[:suppress_warnings] = true + end + + return safe_mode + end + + options[:safe] ? :safe : :unsafe + end + + def options_for_safe_load(base_options) + options = base_options.dup + options.delete(:safe) + options + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/deep.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/deep.rb new file mode 100644 index 0000000..6a5e037 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/deep.rb @@ -0,0 +1,34 @@ +module SafeYAML + class Deep + def self.freeze(object) + object.each do |*entry| + value = entry.last + case value + when String, Regexp + value.freeze + when Enumerable + Deep.freeze(value) + end + end + + return object.freeze + end + + def self.copy(object) + duplicate = object.dup rescue object + + case object + when Array + (0...duplicate.count).each do |i| + duplicate[i] = Deep.copy(duplicate[i]) + end + when Hash + duplicate.keys.each do |key| + duplicate[key] = Deep.copy(duplicate[key]) + end + end + + duplicate + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/libyaml_checker.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/libyaml_checker.rb new file mode 100644 index 0000000..1ae2423 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/libyaml_checker.rb @@ -0,0 +1,36 @@ +require "set" + +module SafeYAML + class LibyamlChecker + LIBYAML_VERSION = Psych::LIBYAML_VERSION rescue nil + + # Do proper version comparison (e.g. so 0.1.10 is >= 0.1.6) + SAFE_LIBYAML_VERSION = Gem::Version.new("0.1.6") + + KNOWN_PATCHED_LIBYAML_VERSIONS = Set.new([ + # http://people.canonical.com/~ubuntu-security/cve/2014/CVE-2014-2525.html + "0.1.4-2ubuntu0.12.04.3", + "0.1.4-2ubuntu0.12.10.3", + "0.1.4-2ubuntu0.13.10.3", + "0.1.4-3ubuntu3", + + # https://security-tracker.debian.org/tracker/CVE-2014-2525 + "0.1.3-1+deb6u4", + "0.1.4-2+deb7u4", + "0.1.4-3.2" + ]).freeze + + def self.libyaml_version_ok? + return true if YAML_ENGINE != "psych" || defined?(JRUBY_VERSION) + return true if Gem::Version.new(LIBYAML_VERSION || "0") >= SAFE_LIBYAML_VERSION + return libyaml_patched? + end + + def self.libyaml_patched? + return false if (`which dpkg` rescue '').empty? + libyaml_version = `dpkg -s libyaml-0-2`.match(/^Version: (.*)$/) + return false if libyaml_version.nil? + KNOWN_PATCHED_LIBYAML_VERSIONS.include?(libyaml_version[1]) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb new file mode 100644 index 0000000..5ea0f60 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb @@ -0,0 +1,181 @@ +require "set" +require "yaml" + +# This needs to be defined up front in case any internal classes need to base +# their behavior off of this. +module SafeYAML + YAML_ENGINE = defined?(YAML::ENGINE) ? YAML::ENGINE.yamler : (defined?(Psych) && YAML == Psych ? "psych" : "syck") +end + +require "safe_yaml/libyaml_checker" +require "safe_yaml/deep" +require "safe_yaml/parse/hexadecimal" +require "safe_yaml/parse/sexagesimal" +require "safe_yaml/parse/date" +require "safe_yaml/transform/transformation_map" +require "safe_yaml/transform/to_boolean" +require "safe_yaml/transform/to_date" +require "safe_yaml/transform/to_float" +require "safe_yaml/transform/to_integer" +require "safe_yaml/transform/to_nil" +require "safe_yaml/transform/to_symbol" +require "safe_yaml/transform" +require "safe_yaml/resolver" +require "safe_yaml/syck_hack" if SafeYAML::YAML_ENGINE == "syck" && defined?(JRUBY_VERSION) + +module SafeYAML + MULTI_ARGUMENT_YAML_LOAD = YAML.method(:load).arity != 1 + + DEFAULT_OPTIONS = Deep.freeze({ + :default_mode => nil, + :suppress_warnings => false, + :deserialize_symbols => false, + :whitelisted_tags => [], + :custom_initializers => {}, + :raise_on_unknown_tag => false + }) + + OPTIONS = Deep.copy(DEFAULT_OPTIONS) + + PREDEFINED_TAGS = {} + + if YAML_ENGINE == "syck" + YAML.tagged_classes.each do |tag, klass| + PREDEFINED_TAGS[klass] = tag + end + + else + # Special tags appear to be hard-coded in Psych: + # https://github.com/tenderlove/psych/blob/v1.3.4/lib/psych/visitors/to_ruby.rb + # Fortunately, there aren't many that SafeYAML doesn't already support. + PREDEFINED_TAGS.merge!({ + Exception => "!ruby/exception", + Range => "!ruby/range", + Regexp => "!ruby/regexp", + }) + end + + Deep.freeze(PREDEFINED_TAGS) + + module_function + + def restore_defaults! + OPTIONS.clear.merge!(Deep.copy(DEFAULT_OPTIONS)) + end + + def tag_safety_check!(tag, options) + return if tag.nil? || tag == "!" + if options[:raise_on_unknown_tag] && !options[:whitelisted_tags].include?(tag) && !tag_is_explicitly_trusted?(tag) + raise "Unknown YAML tag '#{tag}'" + end + end + + def whitelist!(*classes) + classes.each do |klass| + whitelist_class!(klass) + end + end + + def whitelist_class!(klass) + raise "#{klass} not a Class" unless klass.is_a?(::Class) + + klass_name = klass.name + raise "#{klass} cannot be anonymous" if klass_name.nil? || klass_name.empty? + + # Whitelist any built-in YAML tags supplied by Syck or Psych. + predefined_tag = PREDEFINED_TAGS[klass] + if predefined_tag + OPTIONS[:whitelisted_tags] << predefined_tag + return + end + + # Exception is exceptional (har har). + tag_class = klass < Exception ? "exception" : "object" + + tag_prefix = case YAML_ENGINE + when "psych" then "!ruby/#{tag_class}" + when "syck" then "tag:ruby.yaml.org,2002:#{tag_class}" + else raise "unknown YAML_ENGINE #{YAML_ENGINE}" + end + OPTIONS[:whitelisted_tags] << "#{tag_prefix}:#{klass_name}" + end + + if YAML_ENGINE == "psych" + def tag_is_explicitly_trusted?(tag) + false + end + + else + TRUSTED_TAGS = Set.new([ + "tag:yaml.org,2002:binary", + "tag:yaml.org,2002:bool#no", + "tag:yaml.org,2002:bool#yes", + "tag:yaml.org,2002:float", + "tag:yaml.org,2002:float#fix", + "tag:yaml.org,2002:int", + "tag:yaml.org,2002:map", + "tag:yaml.org,2002:null", + "tag:yaml.org,2002:seq", + "tag:yaml.org,2002:str", + "tag:yaml.org,2002:timestamp", + "tag:yaml.org,2002:timestamp#ymd" + ]).freeze + + def tag_is_explicitly_trusted?(tag) + TRUSTED_TAGS.include?(tag) + end + end + + if SafeYAML::YAML_ENGINE == "psych" + require "safe_yaml/psych_handler" + require "safe_yaml/psych_resolver" + require "safe_yaml/safe_to_ruby_visitor" + + def self.load(yaml, filename=nil, options={}) + # If the user hasn't whitelisted any tags, we can go with this implementation which is + # significantly faster. + if (options && options[:whitelisted_tags] || SafeYAML::OPTIONS[:whitelisted_tags]).empty? + safe_handler = SafeYAML::PsychHandler.new(options) do |result| + return result + end + arguments_for_parse = [yaml] + arguments_for_parse << filename if SafeYAML::MULTI_ARGUMENT_YAML_LOAD + Psych::Parser.new(safe_handler).parse(*arguments_for_parse) + return safe_handler.result + + else + safe_resolver = SafeYAML::PsychResolver.new(options) + tree = SafeYAML::MULTI_ARGUMENT_YAML_LOAD ? + Psych.parse(yaml, filename) : + Psych.parse(yaml) + return safe_resolver.resolve_node(tree) + end + end + + def self.load_file(filename, options={}) + if SafeYAML::MULTI_ARGUMENT_YAML_LOAD + File.open(filename, 'r:bom|utf-8') { |f| self.load(f, filename, options) } + + else + # Ruby pukes on 1.9.2 if we try to open an empty file w/ 'r:bom|utf-8'; + # so we'll not specify those flags here. This mirrors the behavior for + # unsafe_load_file so it's probably preferable anyway. + self.load File.open(filename), nil, options + end + end + + else + require "safe_yaml/syck_resolver" + require "safe_yaml/syck_node_monkeypatch" + + def self.load(yaml, options={}) + resolver = SafeYAML::SyckResolver.new(SafeYAML::OPTIONS.merge(options || {})) + tree = YAML.parse(yaml) + return resolver.resolve_node(tree) + end + + def self.load_file(filename, options={}) + File.open(filename) { |f| self.load(f, options) } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/date.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/date.rb new file mode 100644 index 0000000..3a30a8b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/date.rb @@ -0,0 +1,37 @@ +require 'time' + +module SafeYAML + class Parse + class Date + # This one's easy enough :) + DATE_MATCHER = /\A(\d{4})-(\d{2})-(\d{2})\Z/.freeze + + # This unbelievable little gem is taken basically straight from the YAML spec, but made + # slightly more readable (to my poor eyes at least) to me: + # http://yaml.org/type/timestamp.html + TIME_MATCHER = /\A\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d{2}:\d{2}(?:\.\d*)?\s*(?:Z|[-+]\d{1,2}(?::?\d{2})?)?\Z/.freeze + + SECONDS_PER_DAY = 60 * 60 * 24 + MICROSECONDS_PER_SECOND = 1000000 + + # So this is weird. In Ruby 1.8.7, the DateTime#sec_fraction method returned fractional + # seconds in units of DAYS for some reason. In 1.9.2, they changed the units -- much more + # reasonably -- to seconds. + SEC_FRACTION_MULTIPLIER = RUBY_VERSION == "1.8.7" ? (SECONDS_PER_DAY * MICROSECONDS_PER_SECOND) : MICROSECONDS_PER_SECOND + + # The DateTime class has a #to_time method in Ruby 1.9+; + # Before that we'll just need to convert DateTime to Time ourselves. + TO_TIME_AVAILABLE = DateTime.instance_methods.include?(:to_time) + + def self.value(value) + d = DateTime.parse(value) + + return d.to_time if TO_TIME_AVAILABLE + + usec = d.sec_fraction * SEC_FRACTION_MULTIPLIER + time = Time.utc(d.year, d.month, d.day, d.hour, d.min, d.sec, usec) - (d.offset * SECONDS_PER_DAY) + time.getlocal + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/hexadecimal.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/hexadecimal.rb new file mode 100644 index 0000000..8da3624 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/hexadecimal.rb @@ -0,0 +1,12 @@ +module SafeYAML + class Parse + class Hexadecimal + MATCHER = /\A[-+]?0x[0-9a-fA-F_]+\Z/.freeze + + def self.value(value) + # This is safe to do since we already validated the value. + return Integer(value.gsub(/_/, "")) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/sexagesimal.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/sexagesimal.rb new file mode 100644 index 0000000..3fff5bb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/sexagesimal.rb @@ -0,0 +1,26 @@ +module SafeYAML + class Parse + class Sexagesimal + INTEGER_MATCHER = /\A[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\Z/.freeze + FLOAT_MATCHER = /\A[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]*\Z/.freeze + + def self.value(value) + before_decimal, after_decimal = value.split(".") + + whole_part = 0 + multiplier = 1 + + before_decimal = before_decimal.split(":") + until before_decimal.empty? + whole_part += (Float(before_decimal.pop) * multiplier) + multiplier *= 60 + end + + result = whole_part + result += Float("." + after_decimal) unless after_decimal.nil? + result *= -1 if value[0] == "-" + result + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_handler.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_handler.rb new file mode 100644 index 0000000..cf016a3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_handler.rb @@ -0,0 +1,99 @@ +require "psych" +require "base64" + +module SafeYAML + class PsychHandler < Psych::Handler + def initialize(options, &block) + @options = SafeYAML::OPTIONS.merge(options || {}) + @block = block + @initializers = @options[:custom_initializers] || {} + @anchors = {} + @stack = [] + @current_key = nil + @result = nil + @begun = false + end + + def result + @begun ? @result : false + end + + def add_to_current_structure(value, anchor=nil, quoted=nil, tag=nil) + value = Transform.to_proper_type(value, quoted, tag, @options) + + @anchors[anchor] = value if anchor + + if !@begun + @begun = true + @result = value + @current_structure = @result + return + end + + if @current_structure.respond_to?(:<<) + @current_structure << value + + elsif @current_structure.respond_to?(:[]=) + if @current_key.nil? + @current_key = value + + else + if @current_key == "<<" + @current_structure.merge!(value) + else + @current_structure[@current_key] = value + end + + @current_key = nil + end + + else + raise "Don't know how to add to a #{@current_structure.class}!" + end + end + + def end_current_structure + @stack.pop + @current_structure = @stack.last + end + + def streaming? + true + end + + # event handlers + def alias(anchor) + add_to_current_structure(@anchors[anchor]) + end + + def scalar(value, anchor, tag, plain, quoted, style) + add_to_current_structure(value, anchor, quoted, tag) + end + + def end_document(implicit) + @block.call(@result) + end + + def start_mapping(anchor, tag, implicit, style) + map = @initializers.include?(tag) ? @initializers[tag].call : {} + self.add_to_current_structure(map, anchor) + @current_structure = map + @stack.push(map) + end + + def end_mapping + self.end_current_structure() + end + + def start_sequence(anchor, tag, implicit, style) + seq = @initializers.include?(tag) ? @initializers[tag].call : [] + self.add_to_current_structure(seq, anchor) + @current_structure = seq + @stack.push(seq) + end + + def end_sequence + self.end_current_structure() + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_resolver.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_resolver.rb new file mode 100644 index 0000000..851989b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_resolver.rb @@ -0,0 +1,52 @@ +module SafeYAML + class PsychResolver < Resolver + NODE_TYPES = { + Psych::Nodes::Document => :root, + Psych::Nodes::Mapping => :map, + Psych::Nodes::Sequence => :seq, + Psych::Nodes::Scalar => :scalar, + Psych::Nodes::Alias => :alias + }.freeze + + def initialize(options={}) + super + @aliased_nodes = {} + end + + def resolve_root(root) + resolve_seq(root).first + end + + def resolve_alias(node) + resolve_node(@aliased_nodes[node.anchor]) + end + + def native_resolve(node) + @visitor ||= SafeYAML::SafeToRubyVisitor.new(self) + @visitor.accept(node) + end + + def get_node_type(node) + NODE_TYPES[node.class] + end + + def get_node_tag(node) + node.tag + end + + def get_node_value(node) + @aliased_nodes[node.anchor] = node if node.respond_to?(:anchor) && node.anchor + + case get_node_type(node) + when :root, :map, :seq + node.children + when :scalar + node.value + end + end + + def value_is_quoted?(node) + node.quoted + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/resolver.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/resolver.rb new file mode 100644 index 0000000..e4de157 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/resolver.rb @@ -0,0 +1,94 @@ +module SafeYAML + class Resolver + def initialize(options) + @options = SafeYAML::OPTIONS.merge(options || {}) + @whitelist = @options[:whitelisted_tags] || [] + @initializers = @options[:custom_initializers] || {} + @raise_on_unknown_tag = @options[:raise_on_unknown_tag] + end + + def resolve_node(node) + return node if !node + return self.native_resolve(node) if tag_is_whitelisted?(self.get_node_tag(node)) + + case self.get_node_type(node) + when :root + resolve_root(node) + when :map + resolve_map(node) + when :seq + resolve_seq(node) + when :scalar + resolve_scalar(node) + when :alias + resolve_alias(node) + else + raise "Don't know how to resolve this node: #{node.inspect}" + end + end + + def resolve_map(node) + tag = get_and_check_node_tag(node) + hash = @initializers.include?(tag) ? @initializers[tag].call : {} + map = normalize_map(self.get_node_value(node)) + + # Take the "<<" key nodes first, as these are meant to approximate a form of inheritance. + inheritors = map.select { |key_node, value_node| resolve_node(key_node) == "<<" } + inheritors.each do |key_node, value_node| + merge_into_hash(hash, resolve_node(value_node)) + end + + # All that's left should be normal (non-"<<") nodes. + (map - inheritors).each do |key_node, value_node| + hash[resolve_node(key_node)] = resolve_node(value_node) + end + + return hash + end + + def resolve_seq(node) + seq = self.get_node_value(node) + + tag = get_and_check_node_tag(node) + arr = @initializers.include?(tag) ? @initializers[tag].call : [] + + seq.inject(arr) { |array, n| array << resolve_node(n) } + end + + def resolve_scalar(node) + Transform.to_proper_type(self.get_node_value(node), self.value_is_quoted?(node), get_and_check_node_tag(node), @options) + end + + def get_and_check_node_tag(node) + tag = self.get_node_tag(node) + SafeYAML.tag_safety_check!(tag, @options) + tag + end + + def tag_is_whitelisted?(tag) + @whitelist.include?(tag) + end + + def options + @options + end + + private + def normalize_map(map) + # Syck creates Hashes from maps. + if map.is_a?(Hash) + map.inject([]) { |arr, key_and_value| arr << key_and_value } + + # Psych is really weird; it flattens out a Hash completely into: [key, value, key, value, ...] + else + map.each_slice(2).to_a + end + end + + def merge_into_hash(hash, array) + array.each do |key, value| + hash[key] = value + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/safe_to_ruby_visitor.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/safe_to_ruby_visitor.rb new file mode 100644 index 0000000..b980445 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/safe_to_ruby_visitor.rb @@ -0,0 +1,29 @@ +module SafeYAML + class SafeToRubyVisitor < Psych::Visitors::ToRuby + INITIALIZE_ARITY = superclass.instance_method(:initialize).arity + + def initialize(resolver) + case INITIALIZE_ARITY + when 2 + # https://github.com/tenderlove/psych/blob/v2.0.0/lib/psych/visitors/to_ruby.rb#L14-L28 + loader = Psych::ClassLoader.new + scanner = Psych::ScalarScanner.new(loader) + super(scanner, loader) + + else + super() + end + + @resolver = resolver + end + + def accept(node) + if node.tag + SafeYAML.tag_safety_check!(node.tag, @resolver.options) + return super + end + + @resolver.resolve_node(node) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb new file mode 100644 index 0000000..e02a0fc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb @@ -0,0 +1,39 @@ +require 'safe_yaml/load' +require 'yaml/store' + +module SafeYAML + + class Store < YAML::Store + + # Override YAML::Store#initialize to accept additional option + # +safe_yaml_opts+. + def initialize(file_name, yaml_opts = {}, safe_yaml_opts = {}) + @safe_yaml_opts = safe_yaml_opts + super(file_name, yaml_opts) + end + + # Override YAML::Store#load to use SafeYAML.load instead of + # YAML.load (via #safe_yaml_load). + #-- + # PStore#load is private, while YAML::Store#load is public. + #++ + def load(content) + table = safe_yaml_load(content) + table == false ? {} : table + end + + private + + if SafeYAML::YAML_ENGINE == 'psych' + def safe_yaml_load(content) + SafeYAML.load(content, nil, @safe_yaml_opts) + end + else + def safe_yaml_load(content) + SafeYAML.load(content, @safe_yaml_opts) + end + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_hack.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_hack.rb new file mode 100644 index 0000000..08a5e47 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_hack.rb @@ -0,0 +1,36 @@ +# Hack to JRuby 1.8's YAML Parser Yecht +# +# This file is always loaded AFTER either syck or psych are already +# loaded. It then looks at what constants are available and creates +# a consistent view on all rubys. +# +# Taken from rubygems and modified. +# See https://github.com/rubygems/rubygems/blob/master/lib/rubygems/syck_hack.rb + +module YAML + # In newer 1.9.2, there is a Syck toplevel constant instead of it + # being underneith YAML. If so, reference it back under YAML as + # well. + if defined? ::Syck + # for tests that change YAML::ENGINE + # 1.8 does not support the second argument to const_defined? + remove_const :Syck rescue nil + + Syck = ::Syck + + # JRuby's "Syck" is called "Yecht" + elsif defined? YAML::Yecht + Syck = YAML::Yecht + end +end + +# Sometime in the 1.9 dev cycle, the Syck constant was moved from under YAML +# to be a toplevel constant. So gemspecs created under these versions of Syck +# will have references to Syck::DefaultKey. +# +# So we need to be sure that we reference Syck at the toplevel too so that +# we can always load these kind of gemspecs. +# +if !defined?(Syck) + Syck = YAML::Syck +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_node_monkeypatch.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_node_monkeypatch.rb new file mode 100644 index 0000000..c026376 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_node_monkeypatch.rb @@ -0,0 +1,43 @@ +# This is, admittedly, pretty insane. Fundamentally the challenge here is this: if we want to allow +# whitelisting of tags (while still leveraging Syck's internal functionality), then we have to +# change how Syck::Node#transform works. But since we (SafeYAML) do not control instantiation of +# Syck::Node objects, we cannot, for example, subclass Syck::Node and override #tranform the "easy" +# way. So the only choice is to monkeypatch, like this. And the only way to make this work +# recursively with potentially call-specific options (that my feeble brain can think of) is to set +# pseudo-global options on the first call and unset them once the recursive stack has fully unwound. + +monkeypatch = <<-EORUBY + class Node + @@safe_transform_depth = 0 + @@safe_transform_whitelist = nil + + def safe_transform(options={}) + begin + @@safe_transform_depth += 1 + @@safe_transform_whitelist ||= options[:whitelisted_tags] + + if self.type_id + SafeYAML.tag_safety_check!(self.type_id, options) + return unsafe_transform if @@safe_transform_whitelist.include?(self.type_id) + end + + SafeYAML::SyckResolver.new.resolve_node(self) + + ensure + @@safe_transform_depth -= 1 + if @@safe_transform_depth == 0 + @@safe_transform_whitelist = nil + end + end + end + + alias_method :unsafe_transform, :transform + alias_method :transform, :safe_transform + end +EORUBY + +if defined?(YAML::Syck::Node) + YAML::Syck.module_eval monkeypatch +else + Syck.module_eval monkeypatch +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_resolver.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_resolver.rb new file mode 100644 index 0000000..10d55ab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_resolver.rb @@ -0,0 +1,38 @@ +module SafeYAML + class SyckResolver < Resolver + QUOTE_STYLES = [ + :quote1, + :quote2 + ].freeze + + NODE_TYPES = { + Hash => :map, + Array => :seq, + String => :scalar + }.freeze + + def initialize(options={}) + super + end + + def native_resolve(node) + node.transform(self.options) + end + + def get_node_type(node) + NODE_TYPES[node.value.class] + end + + def get_node_tag(node) + node.type_id + end + + def get_node_value(node) + node.value + end + + def value_is_quoted?(node) + QUOTE_STYLES.include?(node.instance_variable_get(:@style)) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform.rb new file mode 100644 index 0000000..d61d1a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform.rb @@ -0,0 +1,41 @@ +require 'base64' + +module SafeYAML + class Transform + TRANSFORMERS = [ + Transform::ToSymbol.new, + Transform::ToInteger.new, + Transform::ToFloat.new, + Transform::ToNil.new, + Transform::ToBoolean.new, + Transform::ToDate.new + ] + + def self.to_guessed_type(value, quoted=false, options=nil) + return value if quoted + + if value.is_a?(String) + TRANSFORMERS.each do |transformer| + success, transformed_value = transformer.method(:transform?).arity == 1 ? + transformer.transform?(value) : + transformer.transform?(value, options) + + return transformed_value if success + end + end + + value + end + + def self.to_proper_type(value, quoted=false, tag=nil, options=nil) + case tag + when "tag:yaml.org,2002:binary", "x-private:binary", "!binary" + decoded = Base64.decode64(value) + decoded = decoded.force_encoding(value.encoding) if decoded.respond_to?(:force_encoding) + decoded + else + self.to_guessed_type(value, quoted, options) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_boolean.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_boolean.rb new file mode 100644 index 0000000..99dc85e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_boolean.rb @@ -0,0 +1,21 @@ +module SafeYAML + class Transform + class ToBoolean + include TransformationMap + + set_predefined_values({ + "yes" => true, + "on" => true, + "true" => true, + "no" => false, + "off" => false, + "false" => false + }) + + def transform?(value) + return false if value.length > 5 + return PREDEFINED_VALUES.include?(value), PREDEFINED_VALUES[value] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_date.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_date.rb new file mode 100644 index 0000000..4bfe552 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_date.rb @@ -0,0 +1,13 @@ +module SafeYAML + class Transform + class ToDate + def transform?(value) + return true, Date.parse(value) if Parse::Date::DATE_MATCHER.match(value) + return true, Parse::Date.value(value) if Parse::Date::TIME_MATCHER.match(value) + false + rescue ArgumentError + return true, value + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_float.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_float.rb new file mode 100644 index 0000000..4ee3f5f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_float.rb @@ -0,0 +1,33 @@ +module SafeYAML + class Transform + class ToFloat + Infinity = 1.0 / 0.0 + NaN = 0.0 / 0.0 + + PREDEFINED_VALUES = { + ".inf" => Infinity, + ".Inf" => Infinity, + ".INF" => Infinity, + "-.inf" => -Infinity, + "-.Inf" => -Infinity, + "-.INF" => -Infinity, + ".nan" => NaN, + ".NaN" => NaN, + ".NAN" => NaN, + }.freeze + + MATCHER = /\A[-+]?(?:\d[\d_]*)?\.[\d_]+(?:[eE][-+][\d]+)?\Z/.freeze + + def transform?(value) + return true, Float(value) if MATCHER.match(value) + try_edge_cases?(value) + end + + def try_edge_cases?(value) + return true, PREDEFINED_VALUES[value] if PREDEFINED_VALUES.include?(value) + return true, Parse::Sexagesimal.value(value) if Parse::Sexagesimal::FLOAT_MATCHER.match(value) + return false + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_integer.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_integer.rb new file mode 100644 index 0000000..9a5f563 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_integer.rb @@ -0,0 +1,26 @@ +module SafeYAML + class Transform + class ToInteger + MATCHERS = Deep.freeze([ + /\A[-+]?(0|([1-9][0-9_,]*))\Z/, # decimal + /\A0[0-7]+\Z/, # octal + /\A0x[0-9a-f]+\Z/i, # hexadecimal + /\A0b[01_]+\Z/ # binary + ]) + + def transform?(value) + MATCHERS.each_with_index do |matcher, idx| + value = value.gsub(/[_,]/, "") if idx == 0 + return true, Integer(value) if matcher.match(value) + end + try_edge_cases?(value) + end + + def try_edge_cases?(value) + return true, Parse::Hexadecimal.value(value) if Parse::Hexadecimal::MATCHER.match(value) + return true, Parse::Sexagesimal.value(value) if Parse::Sexagesimal::INTEGER_MATCHER.match(value) + return false + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_nil.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_nil.rb new file mode 100644 index 0000000..1f61756 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_nil.rb @@ -0,0 +1,18 @@ +module SafeYAML + class Transform + class ToNil + include TransformationMap + + set_predefined_values({ + "" => nil, + "~" => nil, + "null" => nil + }) + + def transform?(value) + return false if value.length > 4 + return PREDEFINED_VALUES.include?(value), PREDEFINED_VALUES[value] + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_symbol.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_symbol.rb new file mode 100644 index 0000000..36a72bb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_symbol.rb @@ -0,0 +1,17 @@ +module SafeYAML + class Transform + class ToSymbol + def transform?(value, options=SafeYAML::OPTIONS) + if options[:deserialize_symbols] && value =~ /\A:./ + if value =~ /\A:(["'])(.*)\1\Z/ + return true, $2.sub(/^:/, "").to_sym + else + return true, value.sub(/^:/, "").to_sym + end + end + + return false + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/transformation_map.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/transformation_map.rb new file mode 100644 index 0000000..d4e45ec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/transformation_map.rb @@ -0,0 +1,47 @@ +module SafeYAML + class Transform + module TransformationMap + def self.included(base) + base.extend(ClassMethods) + end + + class CaseAgnosticMap < Hash + def initialize(*args) + super + end + + def include?(key) + super(key.downcase) + end + + def [](key) + super(key.downcase) + end + + # OK, I actually don't think it's all that important that this map be + # frozen. + def freeze + self + end + end + + module ClassMethods + def set_predefined_values(predefined_values) + if SafeYAML::YAML_ENGINE == "syck" + expanded_map = predefined_values.inject({}) do |hash, (key, value)| + hash[key] = value + hash[key.capitalize] = value + hash[key.upcase] = value + hash + end + else + expanded_map = CaseAgnosticMap.new + expanded_map.merge!(predefined_values) + end + + self.const_set(:PREDEFINED_VALUES, expanded_map.freeze) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/version.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/version.rb new file mode 100644 index 0000000..89ff3b0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/lib/safe_yaml/version.rb @@ -0,0 +1,3 @@ +module SafeYAML + VERSION = "1.0.5" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/run_specs_all_ruby_versions.sh b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/run_specs_all_ruby_versions.sh new file mode 100755 index 0000000..54a1f4b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/run_specs_all_ruby_versions.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" + +rvm use 1.8.7 +bundle exec rake spec + +rvm use 1.9.2 +YAMLER=syck bundle exec rake spec + +YAMLER=psych bundle exec rake spec + +rvm use 1.9.3 +YAMLER=syck bundle exec rake spec + +YAMLER=psych bundle exec rake spec + +rvm use 2.0.0 +bundle exec rake spec + +rvm use 2.1.0 +bundle exec rake spec + +rvm use 2.1.1 +bundle exec rake spec + +rvm use 2.1.2 +bundle exec rake spec + +rvm use ruby-head +bundle exec rake spec + +rvm use jruby +JRUBY_OPTS=--1.8 bundle exec rake spec + +JRUBY_OPTS=--1.9 bundle exec rake spec + +JRUBY_OPTS=--2.0 bundle exec rake spec diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/safe_yaml.gemspec b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/safe_yaml.gemspec new file mode 100644 index 0000000..4f4432a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/safe_yaml.gemspec @@ -0,0 +1,19 @@ +# -*- encoding: utf-8 -*- +require File.join(File.dirname(__FILE__), "lib", "safe_yaml", "version") + +Gem::Specification.new do |gem| + gem.name = "safe_yaml" + gem.version = SafeYAML::VERSION + gem.authors = "Dan Tao" + gem.email = "daniel.tao@gmail.com" + gem.description = %q{Parse YAML safely} + gem.summary = %q{SameYAML provides an alternative implementation of YAML.load suitable for accepting user input in Ruby applications.} + gem.homepage = "https://github.com/dtao/safe_yaml" + gem.license = "MIT" + gem.files = `git ls-files`.split($\) + gem.test_files = gem.files.grep(%r{^spec/}) + gem.require_paths = ["lib"] + gem.executables = ["safe_yaml"] + + gem.required_ruby_version = ">= 1.8.7" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.2.yaml b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.2.yaml new file mode 100644 index 0000000..bdd70cc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.2.yaml @@ -0,0 +1,2 @@ +--- !ruby/object:ExploitableBackDoor +foo: bar diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.3.yaml b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.3.yaml new file mode 100644 index 0000000..c24e04b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.3.yaml @@ -0,0 +1,2 @@ +--- !ruby/hash:ExploitableBackDoor +foo: bar diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/issue48.txt b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/issue48.txt new file mode 100644 index 0000000..97d1f68 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/issue48.txt @@ -0,0 +1,20 @@ +--- +title: Blah +key: value +--- + +I'm going to inject a bunch of YAML-looking stuff below and it should all just get ignored. + +foo: bar + +- foo +- bar + +:foo +42 +~ + +--- +text: | + Look, I'm another YAML document! +--- diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/issue49.yml b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/issue49.yml new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/libyaml_checker_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/libyaml_checker_spec.rb new file mode 100644 index 0000000..b5b290b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/libyaml_checker_spec.rb @@ -0,0 +1,69 @@ +require "spec_helper" + +describe SafeYAML::LibyamlChecker do + describe "check_libyaml_version" do + REAL_YAML_ENGINE = SafeYAML::YAML_ENGINE + REAL_LIBYAML_VERSION = SafeYAML::LibyamlChecker::LIBYAML_VERSION + + let(:libyaml_patched) { false } + + before :each do + allow(SafeYAML::LibyamlChecker).to receive(:libyaml_patched?).and_return(libyaml_patched) + end + + after :each do + silence_warnings do + SafeYAML::YAML_ENGINE = REAL_YAML_ENGINE + SafeYAML::LibyamlChecker::LIBYAML_VERSION = REAL_LIBYAML_VERSION + end + end + + def test_libyaml_version_ok(expected_result, yaml_engine, libyaml_version=nil) + silence_warnings do + SafeYAML.const_set("YAML_ENGINE", yaml_engine) + SafeYAML::LibyamlChecker.const_set("LIBYAML_VERSION", libyaml_version) + expect(SafeYAML::LibyamlChecker.libyaml_version_ok?).to eq(expected_result) + end + end + + unless defined?(JRUBY_VERSION) + it "issues no warnings when 'Syck' is the YAML engine" do + test_libyaml_version_ok(true, "syck") + end + + it "issues a warning if Psych::LIBYAML_VERSION is not defined" do + test_libyaml_version_ok(false, "psych") + end + + it "issues a warning if Psych::LIBYAML_VERSION is < 0.1.6" do + test_libyaml_version_ok(false, "psych", "0.1.5") + end + + it "issues no warning if Psych::LIBYAML_VERSION is == 0.1.6" do + test_libyaml_version_ok(true, "psych", "0.1.6") + end + + it "issues no warning if Psych::LIBYAML_VERSION is > 0.1.6" do + test_libyaml_version_ok(true, "psych", "1.0.0") + end + + it "does a proper version comparison (not just a string comparison)" do + test_libyaml_version_ok(true, "psych", "0.1.10") + end + + context "when the system has a known patched libyaml version" do + let(:libyaml_patched) { true } + + it "issues no warning, even when Psych::LIBYAML_VERSION < 0.1.6" do + test_libyaml_version_ok(true, "psych", "0.1.4") + end + end + end + + if defined?(JRUBY_VERSION) + it "issues no warning, as JRuby doesn't use libyaml" do + test_libyaml_version_ok(true, "psych", "0.1.4") + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/psych_resolver_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/psych_resolver_spec.rb new file mode 100644 index 0000000..a9e76b5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/psych_resolver_spec.rb @@ -0,0 +1,10 @@ +require "spec_helper" + +if SafeYAML::YAML_ENGINE == "psych" + require "safe_yaml/psych_resolver" + + describe SafeYAML::PsychResolver do + include ResolverSpecs + let(:resolver) { SafeYAML::PsychResolver.new } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/resolver_specs.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/resolver_specs.rb new file mode 100644 index 0000000..1b981e5 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/resolver_specs.rb @@ -0,0 +1,278 @@ +module ResolverSpecs + def self.included(base) + base.module_eval do + let(:resolver) { nil } + let(:result) { @result } + + before :each do + # See the comment in the first before :each block in safe_yaml_spec.rb. + require "safe_yaml" + end + + def parse(yaml) + tree = YAML.parse(yaml.unindent) + @result = resolver.resolve_node(tree) + end + + # Isn't this how I should've been doing it all along? + def parse_and_test(yaml) + safe_result = parse(yaml) + + exception_thrown = nil + + unsafe_result = begin + YAML.unsafe_load(yaml) + rescue Exception => e + exception_thrown = e + end + + if exception_thrown + # If the underlying YAML parser (e.g. Psych) threw an exception, I'm + # honestly not sure what the right thing to do is. For now I'll just + # print a warning. Should SafeYAML fail when Psych fails? + Kernel.warn "\n" + Kernel.warn "Discrepancy between SafeYAML and #{SafeYAML::YAML_ENGINE} on input:\n" + Kernel.warn "#{yaml.unindent}\n" + Kernel.warn "SafeYAML result:" + Kernel.warn "#{safe_result.inspect}\n" + Kernel.warn "#{SafeYAML::YAML_ENGINE} result:" + Kernel.warn "#{exception_thrown.inspect}\n" + + else + expect(safe_result).to eq(unsafe_result) + end + end + + context "by default" do + it "translates maps to hashes" do + parse <<-YAML + potayto: potahto + tomayto: tomahto + YAML + + expect(result).to eq({ + "potayto" => "potahto", + "tomayto" => "tomahto" + }) + end + + it "translates sequences to arrays" do + parse <<-YAML + - foo + - bar + - baz + YAML + + expect(result).to eq(["foo", "bar", "baz"]) + end + + it "translates most values to strings" do + parse "string: value" + expect(result).to eq({ "string" => "value" }) + end + + it "does not deserialize symbols" do + parse ":symbol: value" + expect(result).to eq({ ":symbol" => "value" }) + end + + it "translates valid integral numbers to integers" do + parse "integer: 1" + expect(result).to eq({ "integer" => 1 }) + end + + it "translates valid decimal numbers to floats" do + parse "float: 3.14" + expect(result).to eq({ "float" => 3.14 }) + end + + it "translates valid dates" do + parse "date: 2013-01-24" + expect(result).to eq({ "date" => Date.parse("2013-01-24") }) + end + + it "translates valid true/false values to booleans" do + parse <<-YAML + - yes + - true + - no + - false + YAML + + expect(result).to eq([true, true, false, false]) + end + + it "translates valid nulls to nil" do + parse <<-YAML + - + - ~ + - null + YAML + + expect(result).to eq([nil] * 3) + end + + it "matches the behavior of the underlying YAML engine w/ respect to capitalization of boolean values" do + parse_and_test <<-YAML + - true + - True + - TRUE + - tRue + - TRue + - False + - FALSE + - fAlse + - FALse + YAML + + # using Syck: [true, true, true, "tRue", "TRue", false, false, "fAlse", "FALse"] + # using Psych: all booleans + end + + it "matches the behavior of the underlying YAML engine w/ respect to capitalization of nil values" do + parse_and_test <<-YAML + - Null + - NULL + - nUll + - NUll + YAML + + # using Syck: [nil, nil, "nUll", "NUll"] + # using Psych: all nils + end + + it "translates quoted empty strings to strings (not nil)" do + parse "foo: ''" + expect(result).to eq({ "foo" => "" }) + end + + it "correctly reverse-translates strings encoded via #to_yaml" do + parse "5.10".to_yaml + expect(result).to eq("5.10") + end + + it "does not specially parse any double-quoted strings" do + parse <<-YAML + - "1" + - "3.14" + - "true" + - "false" + - "2013-02-03" + - "2013-02-03 16:27:00 -0600" + YAML + + expect(result).to eq(["1", "3.14", "true", "false", "2013-02-03", "2013-02-03 16:27:00 -0600"]) + end + + it "does not specially parse any single-quoted strings" do + parse <<-YAML + - '1' + - '3.14' + - 'true' + - 'false' + - '2013-02-03' + - '2013-02-03 16:27:00 -0600' + YAML + + expect(result).to eq(["1", "3.14", "true", "false", "2013-02-03", "2013-02-03 16:27:00 -0600"]) + end + + it "deals just fine with nested maps" do + parse <<-YAML + foo: + bar: + marco: polo + YAML + + expect(result).to eq({ "foo" => { "bar" => { "marco" => "polo" } } }) + end + + it "deals just fine with nested sequences" do + parse <<-YAML + - foo + - + - bar1 + - bar2 + - + - baz1 + - baz2 + YAML + + expect(result).to eq(["foo", ["bar1", "bar2", ["baz1", "baz2"]]]) + end + + it "applies the same transformations to keys as to values" do + parse <<-YAML + foo: string + :bar: symbol + 1: integer + 3.14: float + 2013-01-24: date + YAML + + expect(result).to eq({ + "foo" => "string", + ":bar" => "symbol", + 1 => "integer", + 3.14 => "float", + Date.parse("2013-01-24") => "date", + }) + end + + it "applies the same transformations to elements in sequences as to all values" do + parse <<-YAML + - foo + - :bar + - 1 + - 3.14 + - 2013-01-24 + YAML + + expect(result).to eq(["foo", ":bar", 1, 3.14, Date.parse("2013-01-24")]) + end + end + + context "for Ruby version #{RUBY_VERSION}" do + it "translates valid time values" do + parse "time: 2013-01-29 05:58:00 -0800" + expect(result).to eq({ "time" => Time.utc(2013, 1, 29, 13, 58, 0) }) + end + + it "applies the same transformation to elements in sequences" do + parse "- 2013-01-29 05:58:00 -0800" + expect(result).to eq([Time.utc(2013, 1, 29, 13, 58, 0)]) + end + + it "applies the same transformation to keys" do + parse "2013-01-29 05:58:00 -0800: time" + expect(result).to eq({ Time.utc(2013, 1, 29, 13, 58, 0) => "time" }) + end + end + + context "with symbol deserialization enabled" do + before :each do + SafeYAML::OPTIONS[:deserialize_symbols] = true + end + + after :each do + SafeYAML.restore_defaults! + end + + it "translates values starting with ':' to symbols" do + parse "symbol: :value" + expect(result).to eq({ "symbol" => :value }) + end + + it "applies the same transformation to keys" do + parse ":bar: symbol" + expect(result).to eq({ :bar => "symbol" }) + end + + it "applies the same transformation to elements in sequences" do + parse "- :bar" + expect(result).to eq([:bar]) + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/safe_yaml_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/safe_yaml_spec.rb new file mode 100644 index 0000000..aa701a4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/safe_yaml_spec.rb @@ -0,0 +1,731 @@ +require "spec_helper" + +describe YAML do + def safe_load_round_trip(object, options={}) + yaml = object.to_yaml + if SafeYAML::YAML_ENGINE == "psych" + YAML.safe_load(yaml, nil, options) + else + YAML.safe_load(yaml, options) + end + end + + before :each do + # Need to require this here (as opposed to somewhere up higher in the file) + # to ensure that safe_yaml isn't loaded and therefore YAML isn't monkey- + # patched, for tests that require only safe_yaml/load. + require "safe_yaml" + require "exploitable_back_door" + + SafeYAML.restore_defaults! + end + + after :each do + SafeYAML.restore_defaults! + end + + describe "unsafe_load" do + if SafeYAML::YAML_ENGINE == "psych" && RUBY_VERSION >= "1.9.3" + it "allows exploits through objects defined in YAML w/ !ruby/hash via custom :[]= methods" do + backdoor = YAML.unsafe_load("--- !ruby/hash:ExploitableBackDoor\nfoo: bar\n") + expect(backdoor).to be_exploited_through_setter + end + + it "allows exploits through objects defined in YAML w/ !ruby/object via the :init_with method" do + backdoor = YAML.unsafe_load("--- !ruby/object:ExploitableBackDoor\nfoo: bar\n") + expect(backdoor).to be_exploited_through_init_with + end + end + + it "allows exploits through objects w/ sensitive instance variables defined in YAML w/ !ruby/object" do + backdoor = YAML.unsafe_load("--- !ruby/object:ExploitableBackDoor\nfoo: bar\n") + expect(backdoor).to be_exploited_through_ivars + end + + context "with special whitelisted tags defined" do + before :each do + SafeYAML::whitelist!(OpenStruct) + end + + it "effectively ignores the whitelist (since everything is whitelisted)" do + result = YAML.unsafe_load <<-YAML.unindent + --- !ruby/object:OpenStruct + table: + :backdoor: !ruby/object:ExploitableBackDoor + foo: bar + YAML + + expect(result).to be_a(OpenStruct) + expect(result.backdoor).to be_exploited_through_ivars + end + end + end + + describe "safe_load" do + it "does NOT allow exploits through objects defined in YAML w/ !ruby/hash" do + object = YAML.safe_load("--- !ruby/hash:ExploitableBackDoor\nfoo: bar\n") + expect(object).not_to be_a(ExploitableBackDoor) + end + + it "does NOT allow exploits through objects defined in YAML w/ !ruby/object" do + object = YAML.safe_load("--- !ruby/object:ExploitableBackDoor\nfoo: bar\n") + expect(object).not_to be_a(ExploitableBackDoor) + end + + context "for YAML engine #{SafeYAML::YAML_ENGINE}" do + if SafeYAML::YAML_ENGINE == "psych" + let(:options) { nil } + let(:arguments) { ["foo: bar", nil, options] } + + context "when no tags are whitelisted" do + it "constructs a SafeYAML::PsychHandler to resolve nodes as they're parsed, for optimal performance" do + expect(Psych::Parser).to receive(:new).with an_instance_of(SafeYAML::PsychHandler) + # This won't work now; we just want to ensure Psych::Parser#parse was in fact called. + YAML.safe_load(*arguments) rescue nil + end + end + + context "when whitelisted tags are specified" do + let(:options) { + { :whitelisted_tags => ["foo"] } + } + + it "instead uses Psych to construct a full tree before examining the nodes" do + expect(Psych).to receive(:parse) + # This won't work now; we just want to ensure Psych::Parser#parse was in fact called. + YAML.safe_load(*arguments) rescue nil + end + end + end + + if SafeYAML::YAML_ENGINE == "syck" + it "uses Syck internally to parse YAML" do + expect(YAML).to receive(:parse).with("foo: bar") + # This won't work now; we just want to ensure YAML::parse was in fact called. + YAML.safe_load("foo: bar") rescue nil + end + end + end + + it "loads a plain ol' YAML document just fine" do + result = YAML.safe_load <<-YAML.unindent + foo: + number: 1 + boolean: true + nil: ~ + string: Hello, there! + symbol: :blah + sequence: + - hi + - bye + YAML + + expect(result).to eq({ + "foo" => { + "number" => 1, + "boolean" => true, + "nil" => nil, + "string" => "Hello, there!", + "symbol" => ":blah", + "sequence" => ["hi", "bye"] + } + }) + end + + it "works for YAML documents with anchors and aliases" do + result = YAML.safe_load <<-YAML + - &id001 {} + - *id001 + - *id001 + YAML + + expect(result).to eq([{}, {}, {}]) + end + + it "works for YAML documents with binary tagged keys" do + result = YAML.safe_load <<-YAML + ? !!binary > + Zm9v + : "bar" + ? !!binary > + YmFy + : "baz" + YAML + + expect(result).to eq({"foo" => "bar", "bar" => "baz"}) + end + + it "works for YAML documents with binary tagged values" do + result = YAML.safe_load <<-YAML + "foo": !!binary > + YmFy + "bar": !!binary > + YmF6 + YAML + + expect(result).to eq({"foo" => "bar", "bar" => "baz"}) + end + + it "works for YAML documents with binary tagged array values" do + result = YAML.safe_load <<-YAML + - !binary |- + Zm9v + - !binary |- + YmFy + YAML + + expect(result).to eq(["foo", "bar"]) + end + + it "works for YAML documents with sections" do + result = YAML.safe_load <<-YAML + mysql: &mysql + adapter: mysql + pool: 30 + login: &login + username: user + password: password123 + development: &development + <<: *mysql + <<: *login + host: localhost + YAML + + expect(result).to eq({ + "mysql" => { + "adapter" => "mysql", + "pool" => 30 + }, + "login" => { + "username" => "user", + "password" => "password123" + }, + "development" => { + "adapter" => "mysql", + "pool" => 30, + "username" => "user", + "password" => "password123", + "host" => "localhost" + } + }) + end + + it "correctly prefers explicitly defined values over default values from included sections" do + # Repeating this test 100 times to increase the likelihood of running into an issue caused by + # non-deterministic hash key enumeration. + 100.times do + result = YAML.safe_load <<-YAML + defaults: &defaults + foo: foo + bar: bar + baz: baz + custom: + <<: *defaults + bar: custom_bar + baz: custom_baz + YAML + + expect(result["custom"]).to eq({ + "foo" => "foo", + "bar" => "custom_bar", + "baz" => "custom_baz" + }) + end + end + + it "works with multi-level inheritance" do + result = YAML.safe_load <<-YAML + defaults: &defaults + foo: foo + bar: bar + baz: baz + custom: &custom + <<: *defaults + bar: custom_bar + baz: custom_baz + grandcustom: &grandcustom + <<: *custom + YAML + + expect(result).to eq({ + "defaults" => { "foo" => "foo", "bar" => "bar", "baz" => "baz" }, + "custom" => { "foo" => "foo", "bar" => "custom_bar", "baz" => "custom_baz" }, + "grandcustom" => { "foo" => "foo", "bar" => "custom_bar", "baz" => "custom_baz" } + }) + end + + it "returns false when parsing an empty document" do + expect([ + YAML.safe_load(""), + YAML.safe_load(" "), + YAML.safe_load("\n") + ]).to eq([false, false, false]) + end + + it "returns nil when parsing a single value representing nil" do + expect([ + YAML.safe_load("~"), + YAML.safe_load("null") + ]).to eq([nil, nil]) + end + + context "with custom initializers defined" do + before :each do + if SafeYAML::YAML_ENGINE == "psych" + SafeYAML::OPTIONS[:custom_initializers] = { + "!set" => lambda { Set.new }, + "!hashiemash" => lambda { Hashie::Mash.new } + } + else + SafeYAML::OPTIONS[:custom_initializers] = { + "tag:yaml.org,2002:set" => lambda { Set.new }, + "tag:yaml.org,2002:hashiemash" => lambda { Hashie::Mash.new } + } + end + end + + it "will use a custom initializer to instantiate an array-like class upon deserialization" do + result = YAML.safe_load <<-YAML.unindent + --- !set + - 1 + - 2 + - 3 + YAML + + expect(result).to be_a(Set) + expect(result.to_a).to match_array([1, 2, 3]) + end + + it "will use a custom initializer to instantiate a hash-like class upon deserialization" do + result = YAML.safe_load <<-YAML.unindent + --- !hashiemash + foo: bar + YAML + + expect(result).to be_a(Hashie::Mash) + expect(result.to_hash).to eq({ "foo" => "bar" }) + end + end + + context "with special whitelisted tags defined" do + before :each do + SafeYAML::whitelist!(OpenStruct) + + # Necessary for deserializing OpenStructs properly. + SafeYAML::OPTIONS[:deserialize_symbols] = true + end + + it "will allow objects to be deserialized for whitelisted tags" do + result = YAML.safe_load("--- !ruby/object:OpenStruct\ntable:\n foo: bar\n") + expect(result).to be_a(OpenStruct) + expect(result.instance_variable_get(:@table)).to eq({ "foo" => "bar" }) + end + + it "will not deserialize objects without whitelisted tags" do + result = YAML.safe_load("--- !ruby/hash:ExploitableBackDoor\nfoo: bar\n") + expect(result).not_to be_a(ExploitableBackDoor) + expect(result).to eq({ "foo" => "bar" }) + end + + it "will not allow non-whitelisted objects to be embedded within objects with whitelisted tags" do + result = YAML.safe_load <<-YAML.unindent + --- !ruby/object:OpenStruct + table: + :backdoor: !ruby/object:ExploitableBackDoor + foo: bar + YAML + + expect(result).to be_a(OpenStruct) + expect(result.backdoor).not_to be_a(ExploitableBackDoor) + expect(result.backdoor).to eq({ "foo" => "bar" }) + end + + context "with the :raise_on_unknown_tag option enabled" do + before :each do + SafeYAML::OPTIONS[:raise_on_unknown_tag] = true + end + + after :each do + SafeYAML.restore_defaults! + end + + it "raises an exception if a non-nil, non-whitelisted tag is encountered" do + expect { + YAML.safe_load <<-YAML.unindent + --- !ruby/object:Unknown + foo: bar + YAML + }.to raise_error + end + + it "checks all tags, even those within objects with trusted tags" do + expect { + YAML.safe_load <<-YAML.unindent + --- !ruby/object:OpenStruct + table: + :backdoor: !ruby/object:Unknown + foo: bar + YAML + }.to raise_error + end + + it "does not raise an exception as long as all tags are whitelisted" do + result = YAML.safe_load <<-YAML.unindent + --- !ruby/object:OpenStruct + table: + :backdoor: + string: foo + integer: 1 + float: 3.14 + symbol: :bar + date: 2013-02-20 + array: [] + hash: {} + YAML + + expect(result).to be_a(OpenStruct) + expect(result.backdoor).to eq({ + "string" => "foo", + "integer" => 1, + "float" => 3.14, + "symbol" => :bar, + "date" => Date.parse("2013-02-20"), + "array" => [], + "hash" => {} + }) + end + + it "does not raise an exception on the non-specific '!' tag" do + result = nil + expect { result = YAML.safe_load "--- ! 'foo'" }.to_not raise_error + expect(result).to eq("foo") + end + + context "with whitelisted custom class" do + class SomeClass + attr_accessor :foo + end + let(:instance) { SomeClass.new } + + before do + SafeYAML::whitelist!(SomeClass) + instance.foo = 'with trailing whitespace: ' + end + + it "does not raise an exception on the non-specific '!' tag" do + result = nil + expect { result = YAML.safe_load(instance.to_yaml) }.to_not raise_error + expect(result.foo).to eq('with trailing whitespace: ') + end + end + end + end + + context "when options are passed direclty to #load which differ from the defaults" do + let(:default_options) { {} } + + before :each do + SafeYAML::OPTIONS.merge!(default_options) + end + + context "(for example, when symbol deserialization is enabled by default)" do + let(:default_options) { { :deserialize_symbols => true } } + + it "goes with the default option when it is not overridden" do + silence_warnings do + expect(YAML.load(":foo: bar")).to eq({ :foo => "bar" }) + end + end + + it "allows the default option to be overridden on a per-call basis" do + silence_warnings do + expect(YAML.load(":foo: bar", :deserialize_symbols => false)).to eq({ ":foo" => "bar" }) + expect(YAML.load(":foo: bar", :deserialize_symbols => true)).to eq({ :foo => "bar" }) + end + end + end + + context "(or, for example, when certain tags are whitelisted)" do + let(:default_options) { + { + :deserialize_symbols => true, + :whitelisted_tags => SafeYAML::YAML_ENGINE == "psych" ? + ["!ruby/object:OpenStruct"] : + ["tag:ruby.yaml.org,2002:object:OpenStruct"] + } + } + + it "goes with the default option when it is not overridden" do + result = safe_load_round_trip(OpenStruct.new(:foo => "bar")) + expect(result).to be_a(OpenStruct) + expect(result.foo).to eq("bar") + end + + it "allows the default option to be overridden on a per-call basis" do + result = safe_load_round_trip(OpenStruct.new(:foo => "bar"), :whitelisted_tags => []) + expect(result).to eq({ "table" => { :foo => "bar" } }) + + result = safe_load_round_trip(OpenStruct.new(:foo => "bar"), :deserialize_symbols => false, :whitelisted_tags => []) + expect(result).to eq({ "table" => { ":foo" => "bar" } }) + end + end + end + end + + describe "unsafe_load_file" do + if SafeYAML::YAML_ENGINE == "psych" && RUBY_VERSION >= "1.9.3" + it "allows exploits through objects defined in YAML w/ !ruby/hash via custom :[]= methods" do + backdoor = YAML.unsafe_load_file "spec/exploit.1.9.3.yaml" + expect(backdoor).to be_exploited_through_setter + end + end + + if SafeYAML::YAML_ENGINE == "psych" && RUBY_VERSION >= "1.9.2" + it "allows exploits through objects defined in YAML w/ !ruby/object via the :init_with method" do + backdoor = YAML.unsafe_load_file "spec/exploit.1.9.2.yaml" + expect(backdoor).to be_exploited_through_init_with + end + end + + it "allows exploits through objects w/ sensitive instance variables defined in YAML w/ !ruby/object" do + backdoor = YAML.unsafe_load_file "spec/exploit.1.9.2.yaml" + expect(backdoor).to be_exploited_through_ivars + end + end + + describe "safe_load_file" do + it "does NOT allow exploits through objects defined in YAML w/ !ruby/hash" do + object = YAML.safe_load_file "spec/exploit.1.9.3.yaml" + expect(object).not_to be_a(ExploitableBackDoor) + end + + it "does NOT allow exploits through objects defined in YAML w/ !ruby/object" do + object = YAML.safe_load_file "spec/exploit.1.9.2.yaml" + expect(object).not_to be_a(ExploitableBackDoor) + end + + it "returns false when parsing an empty file" do + expect(YAML.safe_load_file("spec/issue49.yml")).to eq(false) + end + end + + describe "load" do + let(:options) { {} } + + let (:arguments) { + if SafeYAML::MULTI_ARGUMENT_YAML_LOAD + ["foo: bar", nil, options] + else + ["foo: bar", options] + end + } + + context "as long as a :default_mode has been specified" do + it "doesn't issue a warning for safe mode, since an explicit mode has been set" do + SafeYAML::OPTIONS[:default_mode] = :safe + expect(Kernel).not_to receive(:warn) + YAML.load(*arguments) + end + + it "doesn't issue a warning for unsafe mode, since an explicit mode has been set" do + SafeYAML::OPTIONS[:default_mode] = :unsafe + expect(Kernel).not_to receive(:warn) + YAML.load(*arguments) + end + end + + context "when the :safe options is specified" do + let(:safe_mode) { true } + let(:options) { { :safe => safe_mode } } + + it "doesn't issue a warning" do + expect(Kernel).not_to receive(:warn) + YAML.load(*arguments) + end + + it "calls #safe_load if the :safe option is set to true" do + expect(YAML).to receive(:safe_load) + YAML.load(*arguments) + end + + context "when the :safe option is set to false" do + let(:safe_mode) { false } + + it "calls #unsafe_load if the :safe option is set to false" do + expect(YAML).to receive(:unsafe_load) + YAML.load(*arguments) + end + end + end + + it "issues a warning when the :safe option is omitted" do + silence_warnings do + expect(Kernel).to receive(:warn) + YAML.load(*arguments) + end + end + + it "only issues a warning once (to avoid spamming an app's output)" do + silence_warnings do + expect(Kernel).to receive(:warn).once + 2.times { YAML.load(*arguments) } + end + end + + it "defaults to safe mode if the :safe option is omitted" do + silence_warnings do + expect(YAML).to receive(:safe_load) + YAML.load(*arguments) + end + end + + context "with the default mode set to :unsafe" do + before :each do + SafeYAML::OPTIONS[:default_mode] = :unsafe + end + + it "defaults to unsafe mode if the :safe option is omitted" do + silence_warnings do + expect(YAML).to receive(:unsafe_load) + YAML.load(*arguments) + end + end + + it "calls #safe_load if the :safe option is set to true" do + expect(YAML).to receive(:safe_load) + YAML.load(*(arguments + [{ :safe => true }])) + end + end + end + + describe "load_file" do + let(:filename) { "spec/exploit.1.9.2.yaml" } # doesn't really matter + + it "issues a warning if the :safe option is omitted" do + silence_warnings do + expect(Kernel).to receive(:warn) + YAML.load_file(filename) + end + end + + it "doesn't issue a warning as long as the :safe option is specified" do + expect(Kernel).not_to receive(:warn) + YAML.load_file(filename, :safe => true) + end + + it "defaults to safe mode if the :safe option is omitted" do + silence_warnings do + expect(YAML).to receive(:safe_load_file) + YAML.load_file(filename) + end + end + + it "calls #safe_load_file if the :safe option is set to true" do + expect(YAML).to receive(:safe_load_file) + YAML.load_file(filename, :safe => true) + end + + it "calls #unsafe_load_file if the :safe option is set to false" do + expect(YAML).to receive(:unsafe_load_file) + YAML.load_file(filename, :safe => false) + end + + context "with arbitrary object deserialization enabled by default" do + before :each do + SafeYAML::OPTIONS[:default_mode] = :unsafe + end + + it "defaults to unsafe mode if the :safe option is omitted" do + silence_warnings do + expect(YAML).to receive(:unsafe_load_file) + YAML.load_file(filename) + end + end + + it "calls #safe_load if the :safe option is set to true" do + expect(YAML).to receive(:safe_load_file) + YAML.load_file(filename, :safe => true) + end + end + + it "handles files starting with --- (see issue #48)" do + expect(YAML.load_file("spec/issue48.txt", :safe => true)).to eq({ + "title" => "Blah", + "key" => "value" + }) + end + + it "handles content starting with --- (see issue #48)" do + yaml = File.read("spec/issue48.txt") + expect(YAML.load(yaml, :safe => true)).to eq({ + "title" => "Blah", + "key" => "value" + }) + end + end + + describe "whitelist!" do + context "not a class" do + it "should raise" do + expect { SafeYAML::whitelist! :foo }.to raise_error(/not a Class/) + expect(SafeYAML::OPTIONS[:whitelisted_tags]).to be_empty + end + end + + context "anonymous class" do + it "should raise" do + expect { SafeYAML::whitelist! Class.new }.to raise_error(/cannot be anonymous/) + expect(SafeYAML::OPTIONS[:whitelisted_tags]).to be_empty + end + end + + context "with a Class as its argument" do + it "should configure correctly" do + expect { SafeYAML::whitelist! OpenStruct }.to_not raise_error + expect(SafeYAML::OPTIONS[:whitelisted_tags].grep(/OpenStruct\Z/)).not_to be_empty + end + + it "successfully deserializes the specified class" do + SafeYAML.whitelist!(OpenStruct) + + # necessary for properly assigning OpenStruct attributes + SafeYAML::OPTIONS[:deserialize_symbols] = true + + result = safe_load_round_trip(OpenStruct.new(:foo => "bar")) + expect(result).to be_a(OpenStruct) + expect(result.foo).to eq("bar") + end + + it "works for ranges" do + SafeYAML.whitelist!(Range) + expect(safe_load_round_trip(1..10)).to eq(1..10) + end + + it "works for regular expressions" do + SafeYAML.whitelist!(Regexp) + expect(safe_load_round_trip(/foo/)).to eq(/foo/) + end + + it "works for multiple classes" do + SafeYAML.whitelist!(Range, Regexp) + expect(safe_load_round_trip([(1..10), /bar/])).to eq([(1..10), /bar/]) + end + + it "works for arbitrary Exception subclasses" do + class CustomException < Exception + attr_reader :custom_message + + def initialize(custom_message) + @custom_message = custom_message + end + end + + SafeYAML.whitelist!(CustomException) + + ex = safe_load_round_trip(CustomException.new("blah")) + expect(ex).to be_a(CustomException) + expect(ex.custom_message).to eq("blah") + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/spec_helper.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/spec_helper.rb new file mode 100644 index 0000000..967b2d3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/spec_helper.rb @@ -0,0 +1,42 @@ +HERE = File.dirname(__FILE__) unless defined?(HERE) +ROOT = File.join(HERE, "..") unless defined?(ROOT) + +$LOAD_PATH << File.join(ROOT, "lib") +$LOAD_PATH << File.join(HERE, "support") + +require "yaml" +if ENV["YAMLER"] && defined?(YAML::ENGINE) + YAML::ENGINE.yamler = ENV["YAMLER"] +end + +ruby_version = defined?(JRUBY_VERSION) ? "JRuby #{JRUBY_VERSION} in #{RUBY_VERSION} mode" : "Ruby #{RUBY_VERSION}" +yaml_engine = defined?(YAML::ENGINE) ? YAML::ENGINE.yamler : "syck" +libyaml_version = yaml_engine == "psych" && Psych.const_defined?("LIBYAML_VERSION", false) ? Psych::LIBYAML_VERSION : "N/A" + +env_info = [ + ruby_version, + "YAML: #{yaml_engine} (#{YAML::VERSION}) (libyaml: #{libyaml_version})", + "Monkeypatch: #{ENV['MONKEYPATCH_YAML']}" +] + +puts env_info.join(", ") + +# Caching references to these methods before loading safe_yaml in order to test +# that they aren't touched unless you actually require safe_yaml (see yaml_spec.rb). +ORIGINAL_YAML_LOAD = YAML.method(:load) +ORIGINAL_YAML_LOAD_FILE = YAML.method(:load_file) + +require "safe_yaml/load" +require "ostruct" +require "hashie" +require "heredoc_unindent" + +# Stolen from Rails: +# https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L10-25 +def silence_warnings + $VERBOSE = nil; yield +ensure + $VERBOSE = true +end + +require File.join(HERE, "resolver_specs") diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/store_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/store_spec.rb new file mode 100644 index 0000000..aafcfd4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/store_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +require 'safe_yaml/store' + +describe SafeYAML::Store do + + let(:file) { 'spec/store.yaml' } + let(:content) { "--- \nfoo: 42\n:bar: \"party\"\n" } + + before do + # Rewrite file on every test, as its contents are potentially modified by + # SafeYAML::Store#transaction + File.open(file, 'w') { |f| f.write(content) } + end + + def expect_safe_load(options = {}) + load_args = [content, options] + load_args.insert(1, nil) if SafeYAML::YAML_ENGINE == 'psych' + + expect(SafeYAML).to receive(:load).with(*load_args).and_call_original + expect(YAML).not_to receive(:load) + end + + let(:init_args) { [file] } + subject { described_class.new(*init_args) } + + it 'should be a YAML::Store' do + expect(subject).to be_a(YAML::Store) + end + + it 'should be a SafeYAML::Store' do + expect(subject).to be_a(SafeYAML::Store) + end + + it 'should use SafeYAML.load instead of YAML.load' do + expect_safe_load + expect(subject.transaction { subject['foo'] }).to eq(42) + end + + it 'preserves default SafeYAML behavior' do + expect(subject.transaction { subject[:bar] }).to eq(nil) + expect(subject.transaction { subject[':bar'] }).to eq('party') + end + + + describe 'with options' do + + let(:init_args) { super().insert(2, :deserialize_symbols => true) } + + it 'should accept options for SafeYAML.load' do + expect_safe_load(:deserialize_symbols => true) + expect(subject.transaction { subject[:bar] }).to eq('party') + end + + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/support/exploitable_back_door.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/support/exploitable_back_door.rb new file mode 100644 index 0000000..48754b4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/support/exploitable_back_door.rb @@ -0,0 +1,29 @@ +class ExploitableBackDoor + def exploited? + @exploited_through_setter || @exploited_through_init_with || @exploited_through_ivars + end + + def exploited_through_setter? + @exploited_through_setter + end + + def exploited_through_init_with? + @exploited_through_init_with + end + + def exploited_through_ivars? + self.instance_variables.any? + end + + def init_with(command) + # Note: this is how bad this COULD be. + # system("#{command}") + @exploited_through_init_with = true + end + + def []=(command, arguments) + # Note: this is how bad this COULD be. + # system("#{command} #{arguments}") + @exploited_through_setter = true + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/syck_resolver_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/syck_resolver_spec.rb new file mode 100644 index 0000000..bec729b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/syck_resolver_spec.rb @@ -0,0 +1,10 @@ +require "spec_helper" + +if SafeYAML::YAML_ENGINE == "syck" + require "safe_yaml/syck_resolver" + + describe SafeYAML::SyckResolver do + include ResolverSpecs + let(:resolver) { SafeYAML::SyckResolver.new } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/base64_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/base64_spec.rb new file mode 100644 index 0000000..f4d83d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/base64_spec.rb @@ -0,0 +1,11 @@ +require "spec_helper" + +describe SafeYAML::Transform do + it "should return the same encoding when decoding Base64" do + value = "c3VyZS4=" + decoded = SafeYAML::Transform.to_proper_type(value, false, "!binary") + + expect(decoded).to eq("sure.") + expect(decoded.encoding).to eq(value.encoding) if decoded.respond_to?(:encoding) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_date_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_date_spec.rb new file mode 100644 index 0000000..31bdb41 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_date_spec.rb @@ -0,0 +1,60 @@ +require "spec_helper" + +describe SafeYAML::Transform::ToDate do + it "returns true when the value matches a valid Date" do + expect(subject.transform?("2013-01-01")).to eq([true, Date.parse("2013-01-01")]) + end + + it "returns false when the value does not match a valid Date" do + expect(subject.transform?("foobar")).to be_falsey + end + + it "returns false when the value does not end with a Date" do + expect(subject.transform?("2013-01-01\nNOT A DATE")).to be_falsey + end + + it "returns false when the value does not begin with a Date" do + expect(subject.transform?("NOT A DATE\n2013-01-01")).to be_falsey + end + + it "correctly parses the remaining formats of the YAML spec" do + equivalent_values = [ + "2001-12-15T02:59:43.1Z", # canonical + "2001-12-14t21:59:43.10-05:00", # iso8601 + "2001-12-14 21:59:43.10 -5", # space separated + "2001-12-15 2:59:43.10" # no time zone (Z) + ] + + equivalent_values.each do |value| + success, result = subject.transform?(value) + expect(success).to be_truthy + expect(result).to eq(Time.utc(2001, 12, 15, 2, 59, 43, 100000)) + end + end + + it "converts times to the local timezone" do + success, result = subject.transform?("2012-12-01 10:33:45 +11:00") + expect(success).to be_truthy + expect(result).to eq(Time.utc(2012, 11, 30, 23, 33, 45)) + expect(result.gmt_offset).to eq(Time.local(2012, 11, 30).gmt_offset) + end + + it "returns strings for invalid dates" do + expect(subject.transform?("0000-00-00")).to eq([true, "0000-00-00"]) + expect(subject.transform?("2013-13-01")).to eq([true, "2013-13-01"]) + expect(subject.transform?("2014-01-32")).to eq([true, "2014-01-32"]) + end + + it "returns strings for invalid date/times" do + expect(subject.transform?("0000-00-00 00:00:00 -0000")).to eq([true, "0000-00-00 00:00:00 -0000"]) + expect(subject.transform?("2013-13-01 21:59:43 -05:00")).to eq([true, "2013-13-01 21:59:43 -05:00"]) + expect(subject.transform?("2013-01-32 21:59:43 -05:00")).to eq([true, "2013-01-32 21:59:43 -05:00"]) + expect(subject.transform?("2013-01-30 25:59:43 -05:00")).to eq([true, "2013-01-30 25:59:43 -05:00"]) + expect(subject.transform?("2013-01-30 21:69:43 -05:00")).to eq([true, "2013-01-30 21:69:43 -05:00"]) + + # Interesting. It seems that in some older Ruby versions, the below actually parses successfully + # w/ DateTime.parse; but it fails w/ YAML.load. Whom to follow??? + + # subject.transform?("2013-01-30 21:59:63 -05:00").should == [true, "2013-01-30 21:59:63 -05:00"] + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_float_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_float_spec.rb new file mode 100644 index 0000000..d4d813f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_float_spec.rb @@ -0,0 +1,42 @@ +require "spec_helper" + +describe SafeYAML::Transform::ToFloat do + it "returns true when the value matches a valid Float" do + expect(subject.transform?("20.00")).to eq([true, 20.0]) + end + + it "returns false when the value does not match a valid Float" do + expect(subject.transform?("foobar")).to be_falsey + end + + it "returns false when the value spans multiple lines" do + expect(subject.transform?("20.00\nNOT A FLOAT")).to be_falsey + end + + it "correctly parses all formats in the YAML spec" do + # canonical + expect(subject.transform?("6.8523015e+5")).to eq([true, 685230.15]) + + # exponentioal + expect(subject.transform?("685.230_15e+03")).to eq([true, 685230.15]) + + # fixed + expect(subject.transform?("685_230.15")).to eq([true, 685230.15]) + + # sexagesimal + expect(subject.transform?("190:20:30.15")).to eq([true, 685230.15]) + + # infinity + expect(subject.transform?("-.inf")).to eq([true, (-1.0 / 0.0)]) + + # not a number + # NOTE: can't use == here since NaN != NaN + success, result = subject.transform?(".NaN") + expect(success).to be_truthy; expect(result).to be_nan + end + + # issue 29 + it "returns false for the string '.'" do + expect(subject.transform?(".")).to be_falsey + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_integer_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_integer_spec.rb new file mode 100644 index 0000000..6c6723b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_integer_spec.rb @@ -0,0 +1,64 @@ +require "spec_helper" + +describe SafeYAML::Transform::ToInteger do + it "returns true when the value matches a valid Integer" do + expect(subject.transform?("10")).to eq([true, 10]) + end + + it "returns false when the value does not match a valid Integer" do + expect(subject.transform?("foobar")).to be_falsey + end + + it "returns false when the value spans multiple lines" do + expect(subject.transform?("10\nNOT AN INTEGER")).to be_falsey + end + + it "allows commas in the number" do + expect(subject.transform?("1,000")).to eq([true, 1000]) + end + + it "correctly parses numbers in octal format" do + expect(subject.transform?("010")).to eq([true, 8]) + end + + it "correctly parses numbers in hexadecimal format" do + expect(subject.transform?("0x1FF")).to eq([true, 511]) + end + + it "defaults to a string for a number that resembles octal format but is not" do + expect(subject.transform?("09")).to be_falsey + end + + it "correctly parses 0 in decimal" do + expect(subject.transform?("0")).to eq([true, 0]) + end + + it "defaults to a string for a number that resembles hexadecimal format but is not" do + expect(subject.transform?("0x1G")).to be_falsey + end + + it "correctly parses all formats in the YAML spec" do + # canonical + expect(subject.transform?("685230")).to eq([true, 685230]) + + # decimal + expect(subject.transform?("+685_230")).to eq([true, 685230]) + + # octal + expect(subject.transform?("02472256")).to eq([true, 685230]) + + # hexadecimal: + expect(subject.transform?("0x_0A_74_AE")).to eq([true, 685230]) + + # binary + expect(subject.transform?("0b1010_0111_0100_1010_1110")).to eq([true, 685230]) + + # sexagesimal + expect(subject.transform?("190:20:30")).to eq([true, 685230]) + end + + # see https://github.com/dtao/safe_yaml/pull/51 + it "strips out underscores before parsing decimal values" do + expect(subject.transform?("_850_")).to eq([true, 850]) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_symbol_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_symbol_spec.rb new file mode 100644 index 0000000..59cd242 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/transform/to_symbol_spec.rb @@ -0,0 +1,51 @@ +require "spec_helper" + +describe SafeYAML::Transform::ToSymbol do + def with_symbol_deserialization_value(value) + symbol_deserialization_flag = SafeYAML::OPTIONS[:deserialize_symbols] + SafeYAML::OPTIONS[:deserialize_symbols] = value + + yield + + ensure + SafeYAML::OPTIONS[:deserialize_symbols] = symbol_deserialization_flag + end + + def with_symbol_deserialization(&block) + with_symbol_deserialization_value(true, &block) + end + + def without_symbol_deserialization(&block) + with_symbol_deserialization_value(false, &block) + end + + it "returns true when the value matches a valid Symbol" do + with_symbol_deserialization { expect(subject.transform?(":foo")[0]).to be_truthy } + end + + it "returns true when the value matches a valid String+Symbol" do + with_symbol_deserialization { expect(subject.transform?(':"foo"')[0]).to be_truthy } + end + + it "returns true when the value matches a valid String+Symbol with 's" do + with_symbol_deserialization { expect(subject.transform?(":'foo'")[0]).to be_truthy } + end + + it "returns true when the value has special characters and is wrapped in a String" do + with_symbol_deserialization { expect(subject.transform?(':"foo.bar"')[0]).to be_truthy } + end + + it "returns false when symbol deserialization is disabled" do + without_symbol_deserialization { expect(subject.transform?(":foo")).to be_falsey } + end + + it "returns false when the value does not match a valid Symbol" do + with_symbol_deserialization { expect(subject.transform?("foo")).to be_falsey } + end + + it "returns false when the symbol does not begin the line" do + with_symbol_deserialization do + expect(subject.transform?("NOT A SYMBOL\n:foo")).to be_falsey + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/yaml_spec.rb b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/yaml_spec.rb new file mode 100644 index 0000000..2c2bd18 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/safe_yaml-1.0.5/spec/yaml_spec.rb @@ -0,0 +1,15 @@ +# See https://github.com/dtao/safe_yaml/issues/47 + +require "spec_helper" + +describe YAML do + context "when you've only required safe_yaml/load", :libraries => true do + it "YAML.load doesn't get monkey patched" do + expect(YAML.method(:load)).to eq(ORIGINAL_YAML_LOAD) + end + + it "YAML.load_file doesn't get monkey patched" do + expect(YAML.method(:load_file)).to eq(ORIGINAL_YAML_LOAD_FILE) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/LICENSE b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/LICENSE new file mode 100644 index 0000000..d3857dc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2022, なつき + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/README.md b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/README.md new file mode 100644 index 0000000..d4c0a11 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/README.md @@ -0,0 +1,48 @@ +# Embedded Sass Host for Ruby + +[![build](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml) +[![gem](https://badge.fury.io/rb/sass-embedded.svg)](https://rubygems.org/gems/sass-embedded) + +This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md). + +It exposes a Ruby API for Sass that's backed by a native [Dart Sass](https://sass-lang.com/dart-sass) executable. + +## Install + +``` sh +gem install sass-embedded +``` + +## Usage + +The Ruby API provides two entrypoints for compiling Sass to CSS. + +- `Sass.compile` takes a path to a Sass file and return the result of compiling that file to CSS. + +``` ruby +require 'sass-embedded' + +result = Sass.compile('style.scss') +puts result.css + +compressed = Sass.compile('style.scss', style: :compressed) +puts compressed.css +``` + +- `Sass.compile_string` takes a string that represents the contents of a Sass file and return the result of compiling that file to CSS. + +``` ruby +require 'sass-embedded' + +result = Sass.compile_string('h1 { font-size: 40px; }') +puts result.css + +compressed = Sass.compile_string('h1 { font-size: 40px; }', style: :compressed) +puts compressed.css +``` + +See [rubydoc.info/gems/sass-embedded/Sass](https://rubydoc.info/gems/sass-embedded/Sass) for full API documentation. + +--- + +Disclaimer: this is not an official Google product. diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/exe/sass b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/exe/sass new file mode 100755 index 0000000..ca4c0c2 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/exe/sass @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative '../ext/sass/cli' + +module Sass + # The `sass` command line interface + module CLI + begin + Kernel.exec(*COMMAND, *ARGV) + rescue Errno::ENOENT + require_relative '../lib/sass/elf' + + raise if ELF::INTERPRETER.nil? + + Kernel.exec(ELF::INTERPRETER, *COMMAND, *ARGV) + end + end + + private_constant :CLI +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/cli.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/cli.rb new file mode 100644 index 0000000..e98400b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/cli.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Sass + module CLI + COMMAND = [ + File.absolute_path('dart-sass/src/dart', __dir__).freeze, + File.absolute_path('dart-sass/src/sass.snapshot', __dir__).freeze + ].freeze + end + + private_constant :CLI +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/sass b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/sass new file mode 100755 index 0000000..cb4fd25 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/sass @@ -0,0 +1,20 @@ +#!/bin/sh + +# This script drives the standalone dart-sass package, which bundles together a +# Dart executable and a snapshot of dart-sass. + +follow_links() { + # Use `readlink -f` if it exists, but fall back to manually following symlnks + # for systems (like older Mac OS) where it doesn't. + file="$1" + if readlink -f "$file" 2>&-; then return; fi + + while [ -h "$file" ]; do + file="$(readlink "$file")" + done + echo "$file" +} + +# Unlike $0, $BASH_SOURCE points to the absolute path of this file. +path=`dirname "$(follow_links "$0")"` +exec "$path/src/dart" "$path/src/sass.snapshot" "$@" diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/LICENSE b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/LICENSE new file mode 100644 index 0000000..4ddaee7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/LICENSE @@ -0,0 +1,1727 @@ +Dart Sass license: + +Copyright (c) 2016, Google Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +-------------------------------------------------------------------------------- + +Dart SDK license: + +Copyright 2012, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +_fe_analyzer_shared license: + +Copyright 2019, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +_macros and macros license: + +Copyright 2024, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +analyzer, protobuf and protoc_plugin license: + +Copyright 2013, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +archive license: + +The MIT License + +Copyright (c) 2013-2021 Brendan Duncan. +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +args, csslib and logging license: + +Copyright 2013, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +async, cli_util, collection, mime, source_map_stack_trace, stream_channel and +typed_data license: + +Copyright 2015, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +boolean_selector, meta and shelf_packages_handler license: + +Copyright 2016, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +charcode license: + +Copyright 2014, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +checked_yaml license: + +Copyright 2019, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +cli_pkg license: + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------------------------------------------------------------------- + +cli_repl license: + +Copyright (c) 2018, Jennifer Thakar. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of the project nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +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. + + +-------------------------------------------------------------------------------- + +convert, crypto, shelf_static and vm_service license: + +Copyright 2015, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +coverage, dart_style, dartdoc, glob, http, http_parser, matcher, path, pool, +pub_semver, source_span, string_scanner, test and watcher license: + +Copyright 2014, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +dart_mappable and type_plus license: + +MIT License + +Copyright (c) 2021 Kilian Schulte + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------------------------------------------------------------------- + +ffi and package_config license: + +Copyright 2019, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +file license: + +Copyright 2017, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + +-------------------------------------------------------------------------------- + +fixnum, http_multi_server, oauth2, shelf, shelf_web_socket, source_maps and +stack_trace license: + +Copyright 2014, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +frontend_server_client license: + +Copyright 2020, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +grinder and webkit_inspection_protocol license: + +Copyright 2013, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +html license: + +Copyright (c) 2006-2012 The Authors + +Contributors: +James Graham - jg307@cam.ac.uk +Anne van Kesteren - annevankesteren@gmail.com +Lachlan Hunt - lachlan.hunt@lachy.id.au +Matt McDonald - kanashii@kanashii.ca +Sam Ruby - rubys@intertwingly.net +Ian Hickson (Google) - ian@hixie.ch +Thomas Broyer - t.broyer@ltgt.net +Jacques Distler - distler@golem.ph.utexas.edu +Henri Sivonen - hsivonen@iki.fi +Adam Barth - abarth@webkit.org +Eric Seidel - eric@webkit.org +The Mozilla Foundation (contributions from Henri Sivonen since 2008) +David Flanagan (Mozilla) - dflanagan@mozilla.com +Google LLC (contributed the Dart port) - misc@dartlang.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +-------------------------------------------------------------------------------- + +io, stream_transform and term_glyph license: + +Copyright 2017, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +js license: + +Copyright 2012, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +json_annotation license: + +Copyright 2017, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +lints license: + +Copyright 2021, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +markdown license: + +Copyright 2012, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +native_stack_traces license: + +Copyright 2020, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +native_synchronization license: + +Copyright 2023, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +node_interop license: + +Copyright (c) 2017, Anatoly Pulyaevskiy. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +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 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. + + +-------------------------------------------------------------------------------- + +node_preamble license: + +The MIT License (MIT) + +Copyright (c) 2015 Michael Bullington + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +=== + +Copyright 2012, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +petitparser and xml license: + +The MIT License + +Copyright (c) 2006-2023 Lukas Renggli. +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +-------------------------------------------------------------------------------- + +pub_api_client license: + +MIT License + +Copyright (c) 2020 Leo Farias + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +-------------------------------------------------------------------------------- + +pubspec license: + +Copyright (c) 2015, Anders Holmgren. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +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 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. + + +-------------------------------------------------------------------------------- + +pubspec_parse license: + +Copyright 2018, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +quiver and retry license: + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +-------------------------------------------------------------------------------- + +test_api and test_core license: + +Copyright 2018, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +test_descriptor and web_socket_channel license: + +Copyright 2016, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +test_process license: + +Copyright 2017, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +uri license: + +Copyright 2013, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +web license: + +Copyright 2023, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +web_socket license: + +Copyright 2024, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. + + +-------------------------------------------------------------------------------- + +yaml license: + +Copyright (c) 2014, the Dart project authors. +Copyright (c) 2006, Kirill Simonov. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/dart b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/dart new file mode 100755 index 0000000..920d231 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/dart differ diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/sass.snapshot b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/sass.snapshot new file mode 100644 index 0000000..0260d48 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/dart-sass/src/sass.snapshot differ diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/embedded_sass_pb.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/embedded_sass_pb.rb new file mode 100644 index 0000000..f515ba6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/ext/sass/embedded_sass_pb.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: embedded_sass.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x13\x65mbedded_sass.proto\x12\x16sass.embedded_protocol\"\xe8\x10\n\x0eInboundMessage\x12P\n\x0f\x63ompile_request\x18\x02 \x01(\x0b\x32\x35.sass.embedded_protocol.InboundMessage.CompileRequestH\x00\x12\\\n\x15\x63\x61nonicalize_response\x18\x03 \x01(\x0b\x32;.sass.embedded_protocol.InboundMessage.CanonicalizeResponseH\x00\x12P\n\x0fimport_response\x18\x04 \x01(\x0b\x32\x35.sass.embedded_protocol.InboundMessage.ImportResponseH\x00\x12Y\n\x14\x66ile_import_response\x18\x05 \x01(\x0b\x32\x39.sass.embedded_protocol.InboundMessage.FileImportResponseH\x00\x12]\n\x16\x66unction_call_response\x18\x06 \x01(\x0b\x32;.sass.embedded_protocol.InboundMessage.FunctionCallResponseH\x00\x12P\n\x0fversion_request\x18\x07 \x01(\x0b\x32\x35.sass.embedded_protocol.InboundMessage.VersionRequestH\x00\x1a\x1c\n\x0eVersionRequest\x12\n\n\x02id\x18\x01 \x01(\r\x1a\x98\x07\n\x0e\x43ompileRequest\x12S\n\x06string\x18\x02 \x01(\x0b\x32\x41.sass.embedded_protocol.InboundMessage.CompileRequest.StringInputH\x00\x12\x0e\n\x04path\x18\x03 \x01(\tH\x00\x12\x32\n\x05style\x18\x04 \x01(\x0e\x32#.sass.embedded_protocol.OutputStyle\x12\x12\n\nsource_map\x18\x05 \x01(\x08\x12Q\n\timporters\x18\x06 \x03(\x0b\x32>.sass.embedded_protocol.InboundMessage.CompileRequest.Importer\x12\x18\n\x10global_functions\x18\x07 \x03(\t\x12\x13\n\x0b\x61lert_color\x18\x08 \x01(\x08\x12\x13\n\x0b\x61lert_ascii\x18\t \x01(\x08\x12\x0f\n\x07verbose\x18\n \x01(\x08\x12\x12\n\nquiet_deps\x18\x0b \x01(\x08\x12\"\n\x1asource_map_include_sources\x18\x0c \x01(\x08\x12\x0f\n\x07\x63harset\x18\r \x01(\x08\x12\x0e\n\x06silent\x18\x0e \x01(\x08\x12\x19\n\x11\x66\x61tal_deprecation\x18\x0f \x03(\t\x12\x1b\n\x13silence_deprecation\x18\x10 \x03(\t\x12\x1a\n\x12\x66uture_deprecation\x18\x11 \x03(\t\x1a\xac\x01\n\x0bStringInput\x12\x0e\n\x06source\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\x12.\n\x06syntax\x18\x03 \x01(\x0e\x32\x1e.sass.embedded_protocol.Syntax\x12P\n\x08importer\x18\x04 \x01(\x0b\x32>.sass.embedded_protocol.InboundMessage.CompileRequest.Importer\x1a\xc5\x01\n\x08Importer\x12\x0e\n\x04path\x18\x01 \x01(\tH\x00\x12\x15\n\x0bimporter_id\x18\x02 \x01(\rH\x00\x12\x1a\n\x10\x66ile_importer_id\x18\x03 \x01(\rH\x00\x12L\n\x15node_package_importer\x18\x05 \x01(\x0b\x32+.sass.embedded_protocol.NodePackageImporterH\x00\x12\x1c\n\x14non_canonical_scheme\x18\x04 \x03(\tB\n\n\x08importerB\x07\n\x05inputJ\x04\x08\x01\x10\x02\x1ak\n\x14\x43\x61nonicalizeResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12\r\n\x03url\x18\x02 \x01(\tH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x12\x1d\n\x15\x63ontaining_url_unused\x18\x04 \x01(\x08\x42\x08\n\x06result\x1a\x93\x02\n\x0eImportResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12V\n\x07success\x18\x02 \x01(\x0b\x32\x43.sass.embedded_protocol.InboundMessage.ImportResponse.ImportSuccessH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x1a\x81\x01\n\rImportSuccess\x12\x10\n\x08\x63ontents\x18\x01 \x01(\t\x12.\n\x06syntax\x18\x02 \x01(\x0e\x32\x1e.sass.embedded_protocol.Syntax\x12\x1b\n\x0esource_map_url\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x11\n\x0f_source_map_urlB\x08\n\x06result\x1an\n\x12\x46ileImportResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12\x12\n\x08\x66ile_url\x18\x02 \x01(\tH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x12\x1d\n\x15\x63ontaining_url_unused\x18\x04 \x01(\x08\x42\x08\n\x06result\x1a\x90\x01\n\x14\x46unctionCallResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12\x30\n\x07success\x18\x02 \x01(\x0b\x32\x1d.sass.embedded_protocol.ValueH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x12\x1f\n\x17\x61\x63\x63\x65ssed_argument_lists\x18\x04 \x03(\rB\x08\n\x06resultB\t\n\x07message\"\xcb\x0f\n\x0fOutboundMessage\x12\x36\n\x05\x65rror\x18\x01 \x01(\x0b\x32%.sass.embedded_protocol.ProtocolErrorH\x00\x12S\n\x10\x63ompile_response\x18\x02 \x01(\x0b\x32\x37.sass.embedded_protocol.OutboundMessage.CompileResponseH\x00\x12\x45\n\tlog_event\x18\x03 \x01(\x0b\x32\x30.sass.embedded_protocol.OutboundMessage.LogEventH\x00\x12[\n\x14\x63\x61nonicalize_request\x18\x04 \x01(\x0b\x32;.sass.embedded_protocol.OutboundMessage.CanonicalizeRequestH\x00\x12O\n\x0eimport_request\x18\x05 \x01(\x0b\x32\x35.sass.embedded_protocol.OutboundMessage.ImportRequestH\x00\x12X\n\x13\x66ile_import_request\x18\x06 \x01(\x0b\x32\x39.sass.embedded_protocol.OutboundMessage.FileImportRequestH\x00\x12\\\n\x15\x66unction_call_request\x18\x07 \x01(\x0b\x32;.sass.embedded_protocol.OutboundMessage.FunctionCallRequestH\x00\x12S\n\x10version_response\x18\x08 \x01(\x0b\x32\x37.sass.embedded_protocol.OutboundMessage.VersionResponseH\x00\x1a\x8e\x01\n\x0fVersionResponse\x12\n\n\x02id\x18\x05 \x01(\r\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12\x18\n\x10\x63ompiler_version\x18\x02 \x01(\t\x12\x1e\n\x16implementation_version\x18\x03 \x01(\t\x12\x1b\n\x13implementation_name\x18\x04 \x01(\t\x1a\xa2\x03\n\x0f\x43ompileResponse\x12Y\n\x07success\x18\x02 \x01(\x0b\x32\x46.sass.embedded_protocol.OutboundMessage.CompileResponse.CompileSuccessH\x00\x12Y\n\x07\x66\x61ilure\x18\x03 \x01(\x0b\x32\x46.sass.embedded_protocol.OutboundMessage.CompileResponse.CompileFailureH\x00\x12\x13\n\x0bloaded_urls\x18\x04 \x03(\t\x1a\x37\n\x0e\x43ompileSuccess\x12\x0b\n\x03\x63ss\x18\x01 \x01(\t\x12\x12\n\nsource_map\x18\x02 \x01(\tJ\x04\x08\x03\x10\x04\x1a{\n\x0e\x43ompileFailure\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x30\n\x04span\x18\x02 \x01(\x0b\x32\".sass.embedded_protocol.SourceSpan\x12\x13\n\x0bstack_trace\x18\x03 \x01(\t\x12\x11\n\tformatted\x18\x04 \x01(\tB\x08\n\x06resultJ\x04\x08\x01\x10\x02\x1a\xf1\x01\n\x08LogEvent\x12\x32\n\x04type\x18\x02 \x01(\x0e\x32$.sass.embedded_protocol.LogEventType\x12\x0f\n\x07message\x18\x03 \x01(\t\x12\x35\n\x04span\x18\x04 \x01(\x0b\x32\".sass.embedded_protocol.SourceSpanH\x00\x88\x01\x01\x12\x13\n\x0bstack_trace\x18\x05 \x01(\t\x12\x11\n\tformatted\x18\x06 \x01(\t\x12\x1d\n\x10\x64\x65precation_type\x18\x07 \x01(\tH\x01\x88\x01\x01\x42\x07\n\x05_spanB\x13\n\x11_deprecation_typeJ\x04\x08\x01\x10\x02\x1a\x8e\x01\n\x13\x43\x61nonicalizeRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x13\n\x0bimporter_id\x18\x03 \x01(\r\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x13\n\x0b\x66rom_import\x18\x05 \x01(\x08\x12\x1b\n\x0e\x63ontaining_url\x18\x06 \x01(\tH\x00\x88\x01\x01\x42\x11\n\x0f_containing_urlJ\x04\x08\x02\x10\x03\x1a\x43\n\rImportRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x13\n\x0bimporter_id\x18\x03 \x01(\r\x12\x0b\n\x03url\x18\x04 \x01(\tJ\x04\x08\x02\x10\x03\x1a\x8c\x01\n\x11\x46ileImportRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x13\n\x0bimporter_id\x18\x03 \x01(\r\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x13\n\x0b\x66rom_import\x18\x05 \x01(\x08\x12\x1b\n\x0e\x63ontaining_url\x18\x06 \x01(\tH\x00\x88\x01\x01\x42\x11\n\x0f_containing_urlJ\x04\x08\x02\x10\x03\x1a\x8e\x01\n\x13\x46unctionCallRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x0e\n\x04name\x18\x03 \x01(\tH\x00\x12\x15\n\x0b\x66unction_id\x18\x04 \x01(\rH\x00\x12\x30\n\targuments\x18\x05 \x03(\x0b\x32\x1d.sass.embedded_protocol.ValueB\x0c\n\nidentifierJ\x04\x08\x02\x10\x03\x42\t\n\x07message\"e\n\rProtocolError\x12\x37\n\x04type\x18\x01 \x01(\x0e\x32).sass.embedded_protocol.ProtocolErrorType\x12\n\n\x02id\x18\x02 \x01(\r\x12\x0f\n\x07message\x18\x03 \x01(\t\"\x87\x02\n\nSourceSpan\x12\x0c\n\x04text\x18\x01 \x01(\t\x12@\n\x05start\x18\x02 \x01(\x0b\x32\x31.sass.embedded_protocol.SourceSpan.SourceLocation\x12\x43\n\x03\x65nd\x18\x03 \x01(\x0b\x32\x31.sass.embedded_protocol.SourceSpan.SourceLocationH\x00\x88\x01\x01\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x0f\n\x07\x63ontext\x18\x05 \x01(\t\x1a>\n\x0eSourceLocation\x12\x0e\n\x06offset\x18\x01 \x01(\r\x12\x0c\n\x04line\x18\x02 \x01(\r\x12\x0e\n\x06\x63olumn\x18\x03 \x01(\rB\x06\n\x04_end\"\xb8\x13\n\x05Value\x12\x36\n\x06string\x18\x01 \x01(\x0b\x32$.sass.embedded_protocol.Value.StringH\x00\x12\x36\n\x06number\x18\x02 \x01(\x0b\x32$.sass.embedded_protocol.Value.NumberH\x00\x12;\n\trgb_color\x18\x03 \x01(\x0b\x32&.sass.embedded_protocol.Value.RgbColorH\x00\x12;\n\thsl_color\x18\x04 \x01(\x0b\x32&.sass.embedded_protocol.Value.HslColorH\x00\x12\x32\n\x04list\x18\x05 \x01(\x0b\x32\".sass.embedded_protocol.Value.ListH\x00\x12\x30\n\x03map\x18\x06 \x01(\x0b\x32!.sass.embedded_protocol.Value.MapH\x00\x12;\n\tsingleton\x18\x07 \x01(\x0e\x32&.sass.embedded_protocol.SingletonValueH\x00\x12K\n\x11\x63ompiler_function\x18\x08 \x01(\x0b\x32..sass.embedded_protocol.Value.CompilerFunctionH\x00\x12\x43\n\rhost_function\x18\t \x01(\x0b\x32*.sass.embedded_protocol.Value.HostFunctionH\x00\x12\x43\n\rargument_list\x18\n \x01(\x0b\x32*.sass.embedded_protocol.Value.ArgumentListH\x00\x12;\n\thwb_color\x18\x0b \x01(\x0b\x32&.sass.embedded_protocol.Value.HwbColorH\x00\x12@\n\x0b\x63\x61lculation\x18\x0c \x01(\x0b\x32).sass.embedded_protocol.Value.CalculationH\x00\x12\x45\n\x0e\x63ompiler_mixin\x18\r \x01(\x0b\x32+.sass.embedded_protocol.Value.CompilerMixinH\x00\x1a&\n\x06String\x12\x0c\n\x04text\x18\x01 \x01(\t\x12\x0e\n\x06quoted\x18\x02 \x01(\x08\x1a\x41\n\x06Number\x12\r\n\x05value\x18\x01 \x01(\x01\x12\x12\n\nnumerators\x18\x02 \x03(\t\x12\x14\n\x0c\x64\x65nominators\x18\x03 \x03(\t\x1a\x43\n\x08RgbColor\x12\x0b\n\x03red\x18\x01 \x01(\r\x12\r\n\x05green\x18\x02 \x01(\r\x12\x0c\n\x04\x62lue\x18\x03 \x01(\r\x12\r\n\x05\x61lpha\x18\x04 \x01(\x01\x1aM\n\x08HslColor\x12\x0b\n\x03hue\x18\x01 \x01(\x01\x12\x12\n\nsaturation\x18\x02 \x01(\x01\x12\x11\n\tlightness\x18\x03 \x01(\x01\x12\r\n\x05\x61lpha\x18\x04 \x01(\x01\x1aL\n\x08HwbColor\x12\x0b\n\x03hue\x18\x01 \x01(\x01\x12\x11\n\twhiteness\x18\x02 \x01(\x01\x12\x11\n\tblackness\x18\x03 \x01(\x01\x12\r\n\x05\x61lpha\x18\x04 \x01(\x01\x1a\x87\x01\n\x04List\x12\x38\n\tseparator\x18\x01 \x01(\x0e\x32%.sass.embedded_protocol.ListSeparator\x12\x14\n\x0chas_brackets\x18\x02 \x01(\x08\x12/\n\x08\x63ontents\x18\x03 \x03(\x0b\x32\x1d.sass.embedded_protocol.Value\x1a\xa2\x01\n\x03Map\x12\x38\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\'.sass.embedded_protocol.Value.Map.Entry\x1a\x61\n\x05\x45ntry\x12*\n\x03key\x18\x01 \x01(\x0b\x32\x1d.sass.embedded_protocol.Value\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.sass.embedded_protocol.Value\x1a\x1e\n\x10\x43ompilerFunction\x12\n\n\x02id\x18\x01 \x01(\r\x1a-\n\x0cHostFunction\x12\n\n\x02id\x18\x01 \x01(\r\x12\x11\n\tsignature\x18\x02 \x01(\t\x1a\x1b\n\rCompilerMixin\x12\n\n\x02id\x18\x01 \x01(\r\x1a\xa1\x02\n\x0c\x41rgumentList\x12\n\n\x02id\x18\x01 \x01(\r\x12\x38\n\tseparator\x18\x02 \x01(\x0e\x32%.sass.embedded_protocol.ListSeparator\x12/\n\x08\x63ontents\x18\x03 \x03(\x0b\x32\x1d.sass.embedded_protocol.Value\x12J\n\x08keywords\x18\x04 \x03(\x0b\x32\x38.sass.embedded_protocol.Value.ArgumentList.KeywordsEntry\x1aN\n\rKeywordsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.sass.embedded_protocol.Value:\x02\x38\x01\x1a\xef\x04\n\x0b\x43\x61lculation\x12\x0c\n\x04name\x18\x01 \x01(\t\x12M\n\targuments\x18\x02 \x03(\x0b\x32:.sass.embedded_protocol.Value.Calculation.CalculationValue\x1a\x95\x02\n\x10\x43\x61lculationValue\x12\x36\n\x06number\x18\x01 \x01(\x0b\x32$.sass.embedded_protocol.Value.NumberH\x00\x12\x10\n\x06string\x18\x02 \x01(\tH\x00\x12\x17\n\rinterpolation\x18\x03 \x01(\tH\x00\x12S\n\toperation\x18\x04 \x01(\x0b\x32>.sass.embedded_protocol.Value.Calculation.CalculationOperationH\x00\x12@\n\x0b\x63\x61lculation\x18\x05 \x01(\x0b\x32).sass.embedded_protocol.Value.CalculationH\x00\x42\x07\n\x05value\x1a\xea\x01\n\x14\x43\x61lculationOperation\x12=\n\x08operator\x18\x01 \x01(\x0e\x32+.sass.embedded_protocol.CalculationOperator\x12H\n\x04left\x18\x02 \x01(\x0b\x32:.sass.embedded_protocol.Value.Calculation.CalculationValue\x12I\n\x05right\x18\x03 \x01(\x0b\x32:.sass.embedded_protocol.Value.Calculation.CalculationValueB\x07\n\x05value\"4\n\x13NodePackageImporter\x12\x1d\n\x15\x65ntry_point_directory\x18\x01 \x01(\t*+\n\x0bOutputStyle\x12\x0c\n\x08\x45XPANDED\x10\x00\x12\x0e\n\nCOMPRESSED\x10\x01*)\n\x06Syntax\x12\x08\n\x04SCSS\x10\x00\x12\x0c\n\x08INDENTED\x10\x01\x12\x07\n\x03\x43SS\x10\x02*?\n\x0cLogEventType\x12\x0b\n\x07WARNING\x10\x00\x12\x17\n\x13\x44\x45PRECATION_WARNING\x10\x01\x12\t\n\x05\x44\x45\x42UG\x10\x02*8\n\x11ProtocolErrorType\x12\t\n\x05PARSE\x10\x00\x12\n\n\x06PARAMS\x10\x01\x12\x0c\n\x08INTERNAL\x10\x02*?\n\rListSeparator\x12\t\n\x05\x43OMMA\x10\x00\x12\t\n\x05SPACE\x10\x01\x12\t\n\x05SLASH\x10\x02\x12\r\n\tUNDECIDED\x10\x03*/\n\x0eSingletonValue\x12\x08\n\x04TRUE\x10\x00\x12\t\n\x05\x46\x41LSE\x10\x01\x12\x08\n\x04NULL\x10\x02*A\n\x13\x43\x61lculationOperator\x12\x08\n\x04PLUS\x10\x00\x12\t\n\x05MINUS\x10\x01\x12\t\n\x05TIMES\x10\x02\x12\n\n\x06\x44IVIDE\x10\x03\x42#\n\x1f\x63om.sass_lang.embedded_protocolP\x01\x62\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Sass + module EmbeddedProtocol + InboundMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage").msgclass + InboundMessage::VersionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.VersionRequest").msgclass + InboundMessage::CompileRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CompileRequest").msgclass + InboundMessage::CompileRequest::StringInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CompileRequest.StringInput").msgclass + InboundMessage::CompileRequest::Importer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CompileRequest.Importer").msgclass + InboundMessage::CanonicalizeResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CanonicalizeResponse").msgclass + InboundMessage::ImportResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.ImportResponse").msgclass + InboundMessage::ImportResponse::ImportSuccess = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.ImportResponse.ImportSuccess").msgclass + InboundMessage::FileImportResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.FileImportResponse").msgclass + InboundMessage::FunctionCallResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.FunctionCallResponse").msgclass + OutboundMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage").msgclass + OutboundMessage::VersionResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.VersionResponse").msgclass + OutboundMessage::CompileResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CompileResponse").msgclass + OutboundMessage::CompileResponse::CompileSuccess = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CompileResponse.CompileSuccess").msgclass + OutboundMessage::CompileResponse::CompileFailure = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CompileResponse.CompileFailure").msgclass + OutboundMessage::LogEvent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.LogEvent").msgclass + OutboundMessage::CanonicalizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CanonicalizeRequest").msgclass + OutboundMessage::ImportRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.ImportRequest").msgclass + OutboundMessage::FileImportRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.FileImportRequest").msgclass + OutboundMessage::FunctionCallRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.FunctionCallRequest").msgclass + ProtocolError = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.ProtocolError").msgclass + SourceSpan = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.SourceSpan").msgclass + SourceSpan::SourceLocation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.SourceSpan.SourceLocation").msgclass + Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value").msgclass + Value::String = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.String").msgclass + Value::Number = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Number").msgclass + Value::RgbColor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.RgbColor").msgclass + Value::HslColor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.HslColor").msgclass + Value::HwbColor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.HwbColor").msgclass + Value::List = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.List").msgclass + Value::Map = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Map").msgclass + Value::Map::Entry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Map.Entry").msgclass + Value::CompilerFunction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.CompilerFunction").msgclass + Value::HostFunction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.HostFunction").msgclass + Value::CompilerMixin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.CompilerMixin").msgclass + Value::ArgumentList = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.ArgumentList").msgclass + Value::Calculation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Calculation").msgclass + Value::Calculation::CalculationValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Calculation.CalculationValue").msgclass + Value::Calculation::CalculationOperation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Calculation.CalculationOperation").msgclass + NodePackageImporter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.NodePackageImporter").msgclass + OutputStyle = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutputStyle").enummodule + Syntax = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Syntax").enummodule + LogEventType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.LogEventType").enummodule + ProtocolErrorType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.ProtocolErrorType").enummodule + ListSeparator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.ListSeparator").enummodule + SingletonValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.SingletonValue").enummodule + CalculationOperator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.CalculationOperator").enummodule + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass-embedded.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass-embedded.rb new file mode 100755 index 0000000..91324f6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass-embedded.rb @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative 'sass/embedded' diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/calculation_value.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/calculation_value.rb new file mode 100644 index 0000000..68f69de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/calculation_value.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Sass + # The type of values that can be arguments to a SassCalculation. + # + # @see https://sass-lang.com/documentation/js-api/types/calculationvalue/ + module CalculationValue + private + + def assert_calculation_value(value, name = nil) + if !value.is_a?(Sass::CalculationValue) || (value.is_a?(Sass::Value::String) && value.quoted?) + raise Sass::ScriptError.new( + "#{value} must be one of SassNumber, unquoted SassString, SassCalculation, CalculationOperation", name + ) + end + + value + end + end +end + +require_relative 'calculation_value/calculation_operation' diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/calculation_value/calculation_operation.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/calculation_value/calculation_operation.rb new file mode 100644 index 0000000..55347d1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/calculation_value/calculation_operation.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module Sass + module CalculationValue + # A binary operation that can appear in a SassCalculation. + # + # @see https://sass-lang.com/documentation/js-api/classes/calculationoperation/ + class CalculationOperation + include CalculationValue + + OPERATORS = %w[+ - * /].freeze + + private_constant :OPERATORS + + # @param operator [::String] + # @param left [CalculationValue] + # @param right [CalculationValue] + def initialize(operator, left, right) + raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator) + + @operator = operator.freeze + @left = assert_calculation_value(left, 'left') + @right = assert_calculation_value(right, 'right') + end + + # @return [::String] + attr_reader :operator + + # @return [CalculationValue] + attr_reader :left + + # @return [CalculationValue] + attr_reader :right + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::CalculationValue::CalculationOperation) && + other.operator == operator && + other.left == left && + other.right == right + end + + # @return [Integer] + def hash + @hash ||= [operator, left, right].hash + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/canonicalize_context.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/canonicalize_context.rb new file mode 100644 index 0000000..2f48dc8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/canonicalize_context.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Sass + # Contextual information passed to `canonicalize` and `find_file_url`. + # Not all importers will need this information to resolve loads, but some may find it useful. + # + # @see https://sass-lang.com/documentation/js-api/interfaces/canonicalizecontext/ + class CanonicalizeContext + # @return [String, nil] + def containing_url + @containing_url_unused = false + @containing_url + end + + # @return [Boolean] + attr_reader :from_import + + # @!visibility private + def initialize(canonicalize_request) + @containing_url_unused = true + @containing_url = canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url + @from_import = canonicalize_request.from_import + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compile_result.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compile_result.rb new file mode 100644 index 0000000..9ed7a92 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compile_result.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Sass + # The result of compiling Sass to CSS. Returned by {Sass.compile} and {Sass.compile_string}. + # + # @see https://sass-lang.com/documentation/js-api/interfaces/compileresult/ + class CompileResult + # @return [String] + attr_reader :css + + # @return [String, nil] + attr_reader :source_map + + # @return [Array] + attr_reader :loaded_urls + + # @!visibility private + def initialize(css, source_map, loaded_urls) + @css = css + @source_map = source_map + @loaded_urls = loaded_urls + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler.rb new file mode 100644 index 0000000..96377bb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler.rb @@ -0,0 +1,212 @@ +# frozen_string_literal: true + +require_relative 'canonicalize_context' +require_relative 'compile_result' +require_relative 'compiler/channel' +require_relative 'compiler/connection' +require_relative 'compiler/dispatcher' +require_relative 'compiler/host' +require_relative 'compiler/varint' +require_relative 'embedded/version' +require_relative 'embedded_protocol' +require_relative 'exception' +require_relative 'fork_tracker' +require_relative 'logger/silent' +require_relative 'logger/source_location' +require_relative 'logger/source_span' +require_relative 'node_package_importer' +require_relative 'serializer' +require_relative 'value' + +module Sass + # A synchronous {Compiler}. + # Each compiler instance exposes the {#compile} and {#compile_string} methods within the lifespan of the compiler. + # + # @example + # sass = Sass::Compiler.new + # result = sass.compile_string('h1 { font-size: 40px; }') + # result = sass.compile('style.scss') + # sass.close + # @see https://sass-lang.com/documentation/js-api/classes/compiler/ + class Compiler + def initialize + @channel = Channel.new(Dispatcher) + end + + # Compiles the Sass file at +path+ to CSS. + # @param path [String] + # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ + # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to + # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. + # @param source_map [Boolean] Whether or not Sass should generate a source map. + # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. + # @param style [Symbol] The OutputStyle of the compiled CSS. + # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. + # @param importers [Array] Custom importers that control how Sass resolves loads from rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error + # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. + # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and + # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or + # not to use colors depending on whether the user is using an interactive terminal. + # @param fatal_deprecations [Array] A set of deprecations to treat as fatal. + # @param future_deprecations [Array] A set of future deprecations to opt into early. + # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. + # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by + # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. + # Stylesheets that are imported relative to the entrypoint are not considered dependencies. + # @param silence_deprecations [Array] A set of active deprecations to ignore. + # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per + # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every + # deprecation warning it encounters. + # @return [CompileResult] + # @raise [ArgumentError, CompileError] + # @see https://sass-lang.com/documentation/js-api/functions/compile/ + def compile(path, + load_paths: [], + + charset: true, + source_map: false, + source_map_include_sources: false, + style: :expanded, + + functions: {}, + importers: [], + + alert_ascii: false, + alert_color: nil, + fatal_deprecations: [], + future_deprecations: [], + logger: nil, + quiet_deps: false, + silence_deprecations: [], + verbose: false) + raise ArgumentError, 'path must be set' if path.nil? + + Host.new(@channel).compile_request( + path:, + source: nil, + importer: nil, + load_paths:, + syntax: nil, + url: nil, + charset:, + source_map:, + source_map_include_sources:, + style:, + functions:, + importers:, + alert_color:, + alert_ascii:, + fatal_deprecations:, + future_deprecations:, + logger:, + quiet_deps:, + silence_deprecations:, + verbose: + ) + end + + # Compiles a stylesheet whose contents is +source+ to CSS. + # @param source [String] + # @param importer [Object] The importer to use to handle loads that are relative to the entrypoint stylesheet. + # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param syntax [Symbol] The Syntax to use to parse the entrypoint stylesheet. + # @param url [String] The canonical URL of the entrypoint stylesheet. If this is passed along with +importer+, it's + # used to resolve relative loads in the entrypoint stylesheet. + # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ + # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to + # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. + # @param source_map [Boolean] Whether or not Sass should generate a source map. + # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. + # @param style [Symbol] The OutputStyle of the compiled CSS. + # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. + # @param importers [Array] Custom importers that control how Sass resolves loads from rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error + # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. + # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and + # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or + # not to use colors depending on whether the user is using an interactive terminal. + # @param fatal_deprecations [Array] A set of deprecations to treat as fatal. + # @param future_deprecations [Array] A set of future deprecations to opt into early. + # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. + # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by + # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. + # Stylesheets that are imported relative to the entrypoint are not considered dependencies. + # @param silence_deprecations [Array] A set of active deprecations to ignore. + # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per + # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every + # deprecation warning it encounters. + # @return [CompileResult] + # @raise [ArgumentError, CompileError] + # @see https://sass-lang.com/documentation/js-api/functions/compilestring/ + def compile_string(source, + importer: nil, + load_paths: [], + syntax: :scss, + url: nil, + + charset: true, + source_map: false, + source_map_include_sources: false, + style: :expanded, + + functions: {}, + importers: [], + + alert_ascii: false, + alert_color: nil, + fatal_deprecations: [], + future_deprecations: [], + logger: nil, + quiet_deps: false, + silence_deprecations: [], + verbose: false) + raise ArgumentError, 'source must be set' if source.nil? + + Host.new(@channel).compile_request( + path: nil, + source:, + importer:, + load_paths:, + syntax:, + url:, + charset:, + source_map:, + source_map_include_sources:, + style:, + functions:, + importers:, + alert_color:, + alert_ascii:, + fatal_deprecations:, + future_deprecations:, + logger:, + quiet_deps:, + silence_deprecations:, + verbose: + ) + end + + # @return [String] Information about the Sass implementation. + # @see https://sass-lang.com/documentation/js-api/variables/info/ + def info + @info ||= [ + ['sass-embedded', Embedded::VERSION, '(Embedded Host)', '[Ruby]'].join("\t"), + Host.new(@channel).version_request.join("\t") + ].join("\n").freeze + end + + def close + @channel.close + end + + def closed? + @channel.closed? + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/channel.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/channel.rb new file mode 100644 index 0000000..174f495 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/channel.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +module Sass + class Compiler + # The {Channel} class. + # + # It manages the lifecycle of {Dispatcher}. + class Channel + def initialize(dispatcher_class) + @dispatcher_class = dispatcher_class + @dispatcher = @dispatcher_class.new + @mutex = Mutex.new + end + + def close + @mutex.synchronize do + unless @dispatcher.nil? + @dispatcher.close + @dispatcher = nil + end + end + end + + def closed? + @mutex.synchronize do + @dispatcher.nil? + end + end + + def stream(host) + @mutex.synchronize do + raise IOError, 'closed compiler' if @dispatcher.nil? + + Stream.new(@dispatcher, host) + rescue Errno::EBUSY + @dispatcher = @dispatcher_class.new + Stream.new(@dispatcher, host) + end + end + + # The {Stream} between {Dispatcher} and {Host}. + class Stream + attr_reader :id + + def initialize(dispatcher, host) + @dispatcher = dispatcher + @id = @dispatcher.subscribe(host) + end + + def close + @dispatcher.unsubscribe(@id) + end + + def error(...) + @dispatcher.error(...) + end + + def send_proto(...) + @dispatcher.send_proto(...) + end + end + + private_constant :Stream + end + + private_constant :Channel + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/connection.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/connection.rb new file mode 100644 index 0000000..d59f46d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/connection.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +require 'open3' + +require_relative '../../../ext/sass/cli' + +module Sass + class Compiler + # The stdio based {Connection} between the {Dispatcher} and the compiler. + # + # It runs the `sass --embedded` command. + class Connection + def initialize + @mutex = Mutex.new + @stdin, @stdout, @stderr, @wait_thread = begin + Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) + rescue Errno::ENOENT + require_relative '../elf' + + raise if ELF::INTERPRETER.nil? + + Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__) + end + + @stdin.binmode + + # # https://dart.dev/tools/dart-devtools + # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') + # Kernel.warn(@stdout.readline, uplevel: 0) + # Kernel.warn(@stdout.readline, uplevel: 0) + # end + + @stdout.binmode + + @wait_thread.name = "sass-embedded-process-waiter-#{id}" + end + + def id + @wait_thread.pid + end + + def listen(dispatcher) + Thread.new do + Thread.current.name = "sass-embedded-process-stdout-poller-#{id}" + loop do + length = Varint.read(@stdout) + id = Varint.read(@stdout) + proto = @stdout.read(length - Varint.length(id)) + dispatcher.receive_proto(id, proto) + end + rescue IOError, Errno::EBADF, Errno::EPROTO => e + dispatcher.error(e) + @mutex.synchronize do + @stdout.close + end + end + + Thread.new do + Thread.current.name = "sass-embedded-process-stderr-poller-#{id}" + loop do + Kernel.warn(@stderr.readline, uplevel: 0) + end + rescue IOError, Errno::EBADF + @mutex.synchronize do + @stderr.close + end + end + end + + def close + @mutex.synchronize do + @stdin.close + @wait_thread.join + @stdout.close + @stderr.close + end + end + + def closed? + @mutex.synchronize do + @stdin.closed? && !@wait_thread.alive? + end + end + + def write(id, proto) + buffer = [] + Varint.write(buffer, Varint.length(id) + proto.length) + Varint.write(buffer, id) + @mutex.synchronize do + @stdin.write(buffer.pack('C*'), proto) + end + end + end + + private_constant :Connection + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/dispatcher.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/dispatcher.rb new file mode 100644 index 0000000..9fda6df --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/dispatcher.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true + +module Sass + class Compiler + # The {Dispatcher} class. + # + # It dispatches messages between multiple instances of {Host} and a single {Connection} to the compiler. + class Dispatcher + def initialize + @id = 1 + @observers = {}.compare_by_identity + @mutex = Mutex.new + @connection = Connection.new + @connection.listen(self) + ForkTracker.add(self) + end + + def subscribe(observer) + @mutex.synchronize do + raise Errno::EBUSY if _closed? + + id = @id + @id = id.next + @observers[id] = observer + id + end + end + + def unsubscribe(id) + @mutex.synchronize do + @observers.delete(id) + + return unless @observers.empty? + + if _closed? + Thread.new do + close + end + else + _idle + end + end + end + + def close + @mutex.synchronize do + _close + end + @connection.close + ForkTracker.delete(self) + end + + def closed? + @connection.closed? + end + + def error(error) + observers = @mutex.synchronize do + _close + @observers.values + end + + if observers.empty? + close + else + observers.each do |observer| + observer.error(error) + end + end + end + + def receive_proto(id, proto) + case id + when 1...0xffffffff + @mutex.synchronize { @observers[id] }&.receive_proto(proto) + when 0 + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + @mutex.synchronize { @observers[message.id] }&.public_send(oneof, message) + when 0xffffffff + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + raise Errno::EPROTO, message.message + else + raise Errno::EPROTO + end + end + + def send_proto(...) + @connection.write(...) + end + + private + + def _close + @id = 0xffffffff + end + + def _closed? + @id == 0xffffffff + end + + def _idle + @id = 1 + end + + def _idle? + @id == 1 + end + end + + private_constant :Dispatcher + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host.rb new file mode 100644 index 0000000..b1506c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host.rb @@ -0,0 +1,226 @@ +# frozen_string_literal: true + +require_relative 'host/function_registry' +require_relative 'host/importer_registry' +require_relative 'host/logger_registry' +require_relative 'host/protofier' +require_relative 'host/structifier' + +module Sass + class Compiler + # The {Host} class. + # + # It communicates with {Dispatcher} and handles the host logic. + class Host + def initialize(channel) + @channel = channel + end + + def compile_request(path:, + source:, + importer:, + load_paths:, + syntax:, + url:, + charset:, + source_map:, + source_map_include_sources:, + style:, + functions:, + importers:, + alert_ascii:, + alert_color:, + fatal_deprecations:, + future_deprecations:, + logger:, + quiet_deps:, + silence_deprecations:, + verbose:) + alert_color = Exception.to_tty? if alert_color.nil? + + @function_registry = FunctionRegistry.new(functions, alert_color:) + @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:) + @logger_registry = LoggerRegistry.new(logger) + + compile_request = EmbeddedProtocol::InboundMessage::CompileRequest.new( + string: unless source.nil? + EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( + source: source.to_str, + url: url&.to_s, + syntax: @importer_registry.syntax_to_proto(syntax), + importer: (@importer_registry.register(importer) unless importer.nil?) + ) + end, + path: (File.absolute_path(path) unless path.nil?), + style: case style&.to_sym + when :expanded + EmbeddedProtocol::OutputStyle::EXPANDED + when :compressed + EmbeddedProtocol::OutputStyle::COMPRESSED + else + raise ArgumentError, 'style must be one of :expanded, :compressed' + end, + charset:, + source_map:, + source_map_include_sources:, + importers: @importer_registry.importers, + global_functions: @function_registry.global_functions, + alert_ascii:, + alert_color:, + fatal_deprecation: fatal_deprecations.map(&:to_s), + future_deprecation: future_deprecations.map(&:to_s), + quiet_deps:, + silent: logger == Logger.silent, + silence_deprecation: silence_deprecations.map(&:to_s), + verbose: + ) + + compile_response = await do + send_message(compile_request:) + end + + oneof = compile_response.result + result = compile_response.public_send(oneof) + case oneof + when :failure + raise CompileError.new( + result.message, + result.formatted == '' ? nil : result.formatted, + result.stack_trace == '' ? nil : result.stack_trace, + result.span.nil? ? nil : Logger::SourceSpan.new(result.span), + compile_response.loaded_urls.to_a + ) + when :success + CompileResult.new( + result.css, + result.source_map == '' ? nil : result.source_map, + compile_response.loaded_urls.to_a + ) + else + raise ArgumentError, "Unknown CompileResponse.result #{result}" + end + end + + def version_request + version_response = await0 do + send_message0(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( + id: + )) + end + + info = [ + version_response.implementation_name, + version_response.implementation_version, + '(Sass Compiler)' + ] + + case version_response.implementation_name + when 'dart-sass' + info << '[Dart]' + end + + info + end + + def compile_response(message) + @result = message + @queue.close + end + + def version_response(message) + @result = message + @queue.close + end + + def error(message) + case message + when EmbeddedProtocol::ProtocolError + raise Errno::EPROTO, message.message + else + @error ||= message + @queue.close + end + end + + def log_event(message) + @logger_registry.log(message) + end + + def canonicalize_request(message) + send_message(canonicalize_response: @importer_registry.canonicalize(message)) + end + + def import_request(message) + send_message(import_response: @importer_registry.import(message)) + end + + def file_import_request(message) + send_message(file_import_response: @importer_registry.file_import(message)) + end + + def function_call_request(message) + send_message(function_call_response: @function_registry.function_call(message)) + end + + def receive_proto(proto) + @queue.push(proto) + end + + private + + def await0 + listen do + yield + + @queue.pop + end + end + + def await + listen do + yield + + while (proto = @queue.pop) + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + public_send(oneof, message) + end + rescue Exception => e # rubocop:disable Lint/RescueException + @stream.error(e) + raise + end + end + + def listen + @queue = Queue.new + @stream = @channel.stream(self) + + yield + + raise @error if @error + + @result + ensure + @stream&.close + @queue&.close + end + + def id + @stream.id + end + + def send_message0(...) + inbound_message = EmbeddedProtocol::InboundMessage.new(...) + @stream.send_proto(0, EmbeddedProtocol::InboundMessage.encode(inbound_message)) + end + + def send_message(...) + inbound_message = EmbeddedProtocol::InboundMessage.new(...) + @stream.send_proto(id, EmbeddedProtocol::InboundMessage.encode(inbound_message)) + end + end + + private_constant :Host + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/function_registry.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/function_registry.rb new file mode 100644 index 0000000..75fbb7e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/function_registry.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +module Sass + class Compiler + class Host + # The {FunctionRegistry} class. + # + # It stores sass custom functions and handles function calls. + class FunctionRegistry + attr_reader :global_functions + + def initialize(functions, alert_color:) + functions = functions.transform_keys(&:to_s) + + @global_functions = functions.keys + @functions_by_name = functions.transform_keys do |signature| + index = signature.index('(') + if index + signature.slice(0, index) + else + signature + end + end + + @id = 0 + @functions_by_id = {}.compare_by_identity + @ids_by_function = {}.compare_by_identity + + @highlight = alert_color + end + + def register(function) + @ids_by_function.fetch(function) do |fn| + id = @id + @id = id.next + + @functions_by_id[id] = fn + @ids_by_function[fn] = id + end + end + + def function_call(function_call_request) + oneof = function_call_request.identifier + identifier = function_call_request.public_send(oneof) + function = case oneof + when :name + @functions_by_name[identifier] + when :function_id + @functions_by_id[identifier] + else + raise ArgumentError, "Unknown FunctionCallRequest.identifier #{identifier}" + end + + arguments = function_call_request.arguments.map do |argument| + protofier.from_proto(argument) + end + + success = protofier.to_proto(function.call(arguments)) + accessed_argument_lists = arguments.filter_map do |argument| + if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval { @keywords_accessed } + argument.instance_eval { @id } + end + end + + EmbeddedProtocol::InboundMessage::FunctionCallResponse.new( + id: function_call_request.id, + success:, + accessed_argument_lists: + ) + rescue StandardError => e + EmbeddedProtocol::InboundMessage::FunctionCallResponse.new( + id: function_call_request.id, + error: e.full_message(highlight: @highlight, order: :top) + ) + end + + private + + def protofier + @protofier ||= Protofier.new(self) + end + end + + private_constant :FunctionRegistry + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/importer_registry.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/importer_registry.rb new file mode 100644 index 0000000..4ebc3dd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/importer_registry.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +module Sass + class Compiler + class Host + # The {ImporterRegistry} class. + # + # It stores importers and handles import requests. + class ImporterRegistry + attr_reader :importers + + def initialize(importers, load_paths, alert_color:) + @id = 0 + @importers_by_id = {}.compare_by_identity + @importers = importers + .map { |importer| register(importer) } + .concat( + load_paths.map do |load_path| + EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( + path: File.absolute_path(load_path) + ) + end + ) + + @highlight = alert_color + end + + def register(importer) + if importer.is_a?(Sass::NodePackageImporter) + EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( + node_package_importer: EmbeddedProtocol::NodePackageImporter.new( + entry_point_directory: importer.instance_eval { @entry_point_directory } + ) + ) + else + importer = Structifier.to_struct(importer, :canonicalize, :load, :non_canonical_scheme, :find_file_url) + + is_importer = importer.respond_to?(:canonicalize) && importer.respond_to?(:load) + is_file_importer = importer.respond_to?(:find_file_url) + + raise ArgumentError, 'importer must be an Importer or a FileImporter' if is_importer == is_file_importer + + id = @id + @id = id.next + + @importers_by_id[id] = importer + if is_importer + EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( + importer_id: id, + non_canonical_scheme: if importer.respond_to?(:non_canonical_scheme) + non_canonical_scheme = importer.non_canonical_scheme + if non_canonical_scheme.is_a?(String) + [non_canonical_scheme] + else + non_canonical_scheme || [] + end + else + [] + end + ) + else + EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( + file_importer_id: id + ) + end + end + end + + def canonicalize(canonicalize_request) + importer = @importers_by_id[canonicalize_request.importer_id] + canonicalize_context = CanonicalizeContext.new(canonicalize_request) + url = importer.canonicalize(canonicalize_request.url, + canonicalize_context)&.to_s + + EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( + id: canonicalize_request.id, + url:, + containing_url_unused: canonicalize_context.instance_eval { @containing_url_unused } + ) + rescue StandardError => e + EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( + id: canonicalize_request.id, + error: e.full_message(highlight: @highlight, order: :top) + ) + end + + def import(import_request) + importer = @importers_by_id[import_request.importer_id] + importer_result = Structifier.to_struct importer.load(import_request.url), :contents, :syntax, :source_map_url + + EmbeddedProtocol::InboundMessage::ImportResponse.new( + id: import_request.id, + success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new( + contents: importer_result.contents.to_str, + syntax: syntax_to_proto(importer_result.syntax), + source_map_url: (importer_result.source_map_url&.to_s if importer_result.respond_to?(:source_map_url)) + ) + ) + rescue StandardError => e + EmbeddedProtocol::InboundMessage::ImportResponse.new( + id: import_request.id, + error: e.full_message(highlight: @highlight, order: :top) + ) + end + + def file_import(file_import_request) + importer = @importers_by_id[file_import_request.importer_id] + canonicalize_context = CanonicalizeContext.new(file_import_request) + file_url = importer.find_file_url(file_import_request.url, + canonicalize_context)&.to_s + + EmbeddedProtocol::InboundMessage::FileImportResponse.new( + id: file_import_request.id, + file_url:, + containing_url_unused: canonicalize_context.instance_eval { @containing_url_unused } + ) + rescue StandardError => e + EmbeddedProtocol::InboundMessage::FileImportResponse.new( + id: file_import_request.id, + error: e.full_message(highlight: @highlight, order: :top) + ) + end + + def syntax_to_proto(syntax) + case syntax&.to_sym + when :scss + EmbeddedProtocol::Syntax::SCSS + when :indented + EmbeddedProtocol::Syntax::INDENTED + when :css + EmbeddedProtocol::Syntax::CSS + else + raise ArgumentError, 'syntax must be one of :scss, :indented, :css' + end + end + end + + private_constant :ImporterRegistry + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/logger_registry.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/logger_registry.rb new file mode 100644 index 0000000..e216c19 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/logger_registry.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +module Sass + class Compiler + class Host + # The {LoggerRegistry} class. + # + # It stores logger and handles log events. + class LoggerRegistry + def initialize(logger) + logger = Structifier.to_struct(logger, :debug, :warn) + + { debug: DebugContext, warn: WarnContext }.each do |symbol, context_class| + next unless logger.respond_to?(symbol) + + define_singleton_method(symbol) do |event| + logger.public_send(symbol, event.message, context_class.new(event)) + end + end + end + + def log(event) + case event.type + when :DEBUG + debug(event) + when :DEPRECATION_WARNING, :WARNING + warn(event) + else + raise ArgumentError, "Unknown LogEvent.type #{event.type}" + end + end + + private + + def debug(event) + Kernel.warn(event.formatted) + end + + def warn(event) + Kernel.warn(event.formatted) + end + + # Contextual information passed to `debug`. + class DebugContext + # @return [Logger::SourceSpan, nil] + attr_reader :span + + def initialize(event) + @span = event.span.nil? ? nil : Logger::SourceSpan.new(event.span) + end + end + + private_constant :DebugContext + + # Contextual information passed to `warn`. + class WarnContext < DebugContext + # @return [Boolean] + attr_reader :deprecation + + # @return [String, nil] + attr_reader :deprecation_type + + # @return [String] + attr_reader :stack + + def initialize(event) + super + @deprecation = event.type == :DEPRECATION_WARNING + @deprecation_type = (event.deprecation_type if @deprecation) + @stack = event.stack_trace + end + end + + private_constant :WarnContext + end + + private_constant :LoggerRegistry + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/protofier.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/protofier.rb new file mode 100644 index 0000000..8b0e6ee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/protofier.rb @@ -0,0 +1,390 @@ +# frozen_string_literal: true + +module Sass + class Compiler + class Host + # The {Protofier} class. + # + # It converts Pure Ruby types and Protobuf Ruby types. + class Protofier + def initialize(function_registry) + @function_registry = function_registry + end + + def to_proto(obj) + case obj + when Sass::Value::String + EmbeddedProtocol::Value.new( + string: EmbeddedProtocol::Value::String.new( + text: obj.text.to_str, + quoted: obj.quoted? + ) + ) + when Sass::Value::Number + EmbeddedProtocol::Value.new( + number: Number.to_proto(obj) + ) + when Sass::Value::Color + if obj.instance_eval { !defined?(@hue) } + EmbeddedProtocol::Value.new( + rgb_color: EmbeddedProtocol::Value::RgbColor.new( + red: obj.red, + green: obj.green, + blue: obj.blue, + alpha: obj.alpha.to_f + ) + ) + elsif obj.instance_eval { !defined?(@saturation) } + EmbeddedProtocol::Value.new( + hwb_color: EmbeddedProtocol::Value::HwbColor.new( + hue: obj.hue.to_f, + whiteness: obj.whiteness.to_f, + blackness: obj.blackness.to_f, + alpha: obj.alpha.to_f + ) + ) + else + EmbeddedProtocol::Value.new( + hsl_color: EmbeddedProtocol::Value::HslColor.new( + hue: obj.hue.to_f, + saturation: obj.saturation.to_f, + lightness: obj.lightness.to_f, + alpha: obj.alpha.to_f + ) + ) + end + when Sass::Value::ArgumentList + EmbeddedProtocol::Value.new( + argument_list: EmbeddedProtocol::Value::ArgumentList.new( + id: obj.instance_eval { @id }, + contents: obj.to_a.map { |element| to_proto(element) }, + keywords: obj.keywords.to_h { |key, value| [key.to_s, to_proto(value)] }, + separator: ListSeparator.to_proto(obj.separator) + ) + ) + when Sass::Value::List + EmbeddedProtocol::Value.new( + list: EmbeddedProtocol::Value::List.new( + contents: obj.to_a.map { |element| to_proto(element) }, + separator: ListSeparator.to_proto(obj.separator), + has_brackets: obj.bracketed? + ) + ) + when Sass::Value::Map + EmbeddedProtocol::Value.new( + map: EmbeddedProtocol::Value::Map.new( + entries: obj.contents.map do |key, value| + EmbeddedProtocol::Value::Map::Entry.new( + key: to_proto(key), + value: to_proto(value) + ) + end + ) + ) + when Sass::Value::Function + if obj.instance_eval { @id } + EmbeddedProtocol::Value.new( + compiler_function: EmbeddedProtocol::Value::CompilerFunction.new( + id: obj.instance_eval { @id } + ) + ) + else + EmbeddedProtocol::Value.new( + host_function: EmbeddedProtocol::Value::HostFunction.new( + id: @function_registry.register(obj.callback), + signature: obj.signature + ) + ) + end + when Sass::Value::Mixin + EmbeddedProtocol::Value.new( + compiler_mixin: EmbeddedProtocol::Value::CompilerMixin.new( + id: obj.instance_eval { @id } + ) + ) + when Sass::Value::Calculation + EmbeddedProtocol::Value.new( + calculation: Calculation.to_proto(obj) + ) + when Sass::Value::Boolean + EmbeddedProtocol::Value.new( + singleton: obj.value ? :TRUE : :FALSE + ) + when Sass::Value::Null + EmbeddedProtocol::Value.new( + singleton: :NULL + ) + else + raise Sass::ScriptError, "Unknown Sass::Value #{obj}" + end + end + + def from_proto(proto) + oneof = proto.value + obj = proto.public_send(oneof) + case oneof + when :string + Sass::Value::String.new( + obj.text, + quoted: obj.quoted + ) + when :number + Number.from_proto(obj) + when :rgb_color + Sass::Value::Color.new( + red: obj.red, + green: obj.green, + blue: obj.blue, + alpha: obj.alpha + ) + when :hsl_color + Sass::Value::Color.new( + hue: obj.hue, + saturation: obj.saturation, + lightness: obj.lightness, + alpha: obj.alpha + ) + when :hwb_color + Sass::Value::Color.new( + hue: obj.hue, + whiteness: obj.whiteness, + blackness: obj.blackness, + alpha: obj.alpha + ) + when :argument_list + Sass::Value::ArgumentList.new( + obj.contents.map do |element| + from_proto(element) + end, + obj.keywords.entries.to_h do |key, value| + [key.to_sym, from_proto(value)] + end, + ListSeparator.from_proto(obj.separator) + ).instance_eval do + @id = obj.id + self + end + when :list + Sass::Value::List.new( + obj.contents.map do |element| + from_proto(element) + end, + separator: ListSeparator.from_proto(obj.separator), + bracketed: obj.has_brackets + ) + when :map + Sass::Value::Map.new( + obj.entries.to_h do |entry| + [from_proto(entry.key), from_proto(entry.value)] + end + ) + when :compiler_function + Sass::Value::Function.new(nil).instance_eval do + @id = obj.id + self + end + when :host_function + raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' + when :compiler_mixin + Sass::Value::Mixin.send(:new).instance_eval do + @id = obj.id + self + end + when :calculation + Calculation.from_proto(obj) + when :singleton + case obj + when :TRUE + Sass::Value::Boolean::TRUE + when :FALSE + Sass::Value::Boolean::FALSE + when :NULL + Sass::Value::Null::NULL + else + raise Sass::ScriptError, "Unknown Value.singleton #{obj}" + end + else + raise Sass::ScriptError, "Unknown Value.value #{obj}" + end + end + + # The {Number} Protofier. + module Number + module_function + + def to_proto(obj) + EmbeddedProtocol::Value::Number.new( + value: obj.value.to_f, + numerators: obj.numerator_units, + denominators: obj.denominator_units + ) + end + + def from_proto(obj) + Sass::Value::Number.new( + obj.value, { + numerator_units: obj.numerators.to_a, + denominator_units: obj.denominators.to_a + } + ) + end + end + + private_constant :Number + + # The {Calculation} Protofier. + module Calculation + module_function + + def to_proto(obj) + EmbeddedProtocol::Value::Calculation.new( + name: obj.name, + arguments: obj.arguments.map { |argument| CalculationValue.to_proto(argument) } + ) + end + + def from_proto(obj) + Sass::Value::Calculation.send( + :new, + obj.name, + obj.arguments.map { |argument| CalculationValue.from_proto(argument) } + ) + end + end + + private_constant :Calculation + + # The {CalculationValue} Protofier. + module CalculationValue + module_function + + def to_proto(value) + case value + when Sass::Value::Number + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + number: Number.to_proto(value) + ) + when Sass::Value::Calculation + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + calculation: Calculation.to_proto(value) + ) + when Sass::Value::String + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + string: value.text + ) + when Sass::CalculationValue::CalculationOperation + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + operation: EmbeddedProtocol::Value::Calculation::CalculationOperation.new( + operator: CalculationOperator.to_proto(value.operator), + left: to_proto(value.left), + right: to_proto(value.right) + ) + ) + else + raise Sass::ScriptError, "Unknown CalculationValue #{value}" + end + end + + def from_proto(value) + oneof = value.value + obj = value.public_send(oneof) + case oneof + when :number + Number.from_proto(obj) + when :calculation + Calculation.from_proto(obj) + when :string + Sass::Value::String.new(obj, quoted: false) + when :operation + Sass::CalculationValue::CalculationOperation.new( + CalculationOperator.from_proto(obj.operator), + from_proto(obj.left), + from_proto(obj.right) + ) + else + raise Sass::ScriptError, "Unknown CalculationValue #{value}" + end + end + end + + private_constant :CalculationValue + + # The {CalculationOperator} Protofier. + module CalculationOperator + module_function + + def to_proto(operator) + case operator + when '+' + :PLUS + when '-' + :MINUS + when '*' + :TIMES + when '/' + :DIVIDE + else + raise Sass::ScriptError, "Unknown CalculationOperator #{separator}" + end + end + + def from_proto(operator) + case operator + when :PLUS + '+' + when :MINUS + '-' + when :TIMES + '*' + when :DIVIDE + '/' + else + raise Sass::ScriptError, "Unknown CalculationOperator #{separator}" + end + end + end + + private_constant :CalculationOperator + + # The {ListSeparator} Protofier. + module ListSeparator + module_function + + def to_proto(separator) + case separator + when ',' + :COMMA + when ' ' + :SPACE + when '/' + :SLASH + when nil + :UNDECIDED + else + raise Sass::ScriptError, "Unknown ListSeparator #{separator}" + end + end + + def from_proto(separator) + case separator + when :COMMA + ',' + when :SPACE + ' ' + when :SLASH + '/' + when :UNDECIDED + nil + else + raise Sass::ScriptError, "Unknown ListSeparator #{separator}" + end + end + end + + private_constant :ListSeparator + end + + private_constant :Protofier + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/structifier.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/structifier.rb new file mode 100644 index 0000000..80b2157 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/host/structifier.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Sass + class Compiler + class Host + # The {Structifier} module. + # + # It converts {::Hash} to {Struct}-like objects. + module Structifier + module_function + + def to_struct(obj, *symbols) + return obj unless obj.is_a?(Hash) + + struct = Object.new + symbols.each do |key| + next unless obj.key?(key) + + value = obj[key] + if value.respond_to?(:call) + struct.define_singleton_method key do |*args, **kwargs| + value.call(*args, **kwargs) + end + else + struct.define_singleton_method key do + value + end + end + end + struct + end + end + + private_constant :Structifier + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/varint.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/varint.rb new file mode 100644 index 0000000..7987779 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/compiler/varint.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Sass + class Compiler + # The {Varint} module. + # + # It reads and writes varints. + module Varint + module_function + + def length(value) + return 1 if value < 128 + + (value.bit_length + 6) / 7 + end + + def read(readable) + value = bits = 0 + loop do + byte = readable.readbyte + value |= (byte & 0x7f) << bits + bits += 7 + break if byte < 0x80 + end + value + end + + def write(writeable, value) + until value < 0x80 + writeable << ((value & 0x7f) | 0x80) + value >>= 7 + end + writeable << value + end + end + + private_constant :Varint + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/elf.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/elf.rb new file mode 100644 index 0000000..6b81cac --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/elf.rb @@ -0,0 +1,276 @@ +# frozen_string_literal: true + +module Sass + # The {ELF} class. + # + # It parses ELF header to extract interpreter. + # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h + # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c + class ELF + # rubocop:disable Naming/ConstantName + + # 32-bit ELF base types. + Elf32_Addr = :__u32 + Elf32_Half = :__u16 + Elf32_Off = :__u32 + Elf32_Sword = :__s32 + Elf32_Word = :__u32 + + # 64-bit ELF base types. + Elf64_Addr = :__u64 + Elf64_Half = :__u16 + Elf64_SHalf = :__s16 + Elf64_Off = :__u64 + Elf64_Sword = :__s32 + Elf64_Word = :__u32 + Elf64_Xword = :__u64 + Elf64_Sxword = :__s64 + + # rubocop:enable Naming/ConstantName + + # These constants are for the segment types stored in the image headers + PT_NULL = 0 + PT_LOAD = 1 + PT_DYNAMIC = 2 + PT_INTERP = 3 + PT_NOTE = 4 + PT_SHLIB = 5 + PT_PHDR = 6 + PT_TLS = 7 + PT_LOOS = 0x60000000 + PT_HIOS = 0x6fffffff + PT_LOPROC = 0x70000000 + PT_HIPROC = 0x7fffffff + PT_GNU_EH_FRAME = (PT_LOOS + 0x474e550) + PT_GNU_STACK = (PT_LOOS + 0x474e551) + PT_GNU_RELRO = (PT_LOOS + 0x474e552) + PT_GNU_PROPERTY = (PT_LOOS + 0x474e553) + + # These constants define the different elf file types + ET_NONE = 0 + ET_REL = 1 + ET_EXEC = 2 + ET_DYN = 3 + ET_CORE = 4 + ET_LOPROC = 0xff00 + ET_HIPROC = 0xffff + + EI_NIDENT = 16 + + # rubocop:disable Naming/ConstantName + + Elf32_Ehdr = [ + [:unsigned_char, :e_ident, EI_NIDENT], + [Elf32_Half, :e_type], + [Elf32_Half, :e_machine], + [Elf32_Word, :e_version], + [Elf32_Addr, :e_entry], + [Elf32_Off, :e_phoff], + [Elf32_Off, :e_shoff], + [Elf32_Word, :e_flags], + [Elf32_Half, :e_ehsize], + [Elf32_Half, :e_phentsize], + [Elf32_Half, :e_phnum], + [Elf32_Half, :e_shentsize], + [Elf32_Half, :e_shnum], + [Elf32_Half, :e_shstrndx] + ].freeze + + Elf64_Ehdr = [ + [:unsigned_char, :e_ident, EI_NIDENT], + [Elf64_Half, :e_type], + [Elf64_Half, :e_machine], + [Elf64_Word, :e_version], + [Elf64_Addr, :e_entry], + [Elf64_Off, :e_phoff], + [Elf64_Off, :e_shoff], + [Elf64_Word, :e_flags], + [Elf64_Half, :e_ehsize], + [Elf64_Half, :e_phentsize], + [Elf64_Half, :e_phnum], + [Elf64_Half, :e_shentsize], + [Elf64_Half, :e_shnum], + [Elf64_Half, :e_shstrndx] + ].freeze + + Elf32_Phdr = [ + [Elf32_Word, :p_type], + [Elf32_Off, :p_offset], + [Elf32_Addr, :p_vaddr], + [Elf32_Addr, :p_paddr], + [Elf32_Word, :p_filesz], + [Elf32_Word, :p_memsz], + [Elf32_Word, :p_flags], + [Elf32_Word, :p_align] + ].freeze + + Elf64_Phdr = [ + [Elf64_Word, :p_type], + [Elf64_Word, :p_flags], + [Elf64_Off, :p_offset], + [Elf64_Addr, :p_vaddr], + [Elf64_Addr, :p_paddr], + [Elf64_Xword, :p_filesz], + [Elf64_Xword, :p_memsz], + [Elf64_Xword, :p_align] + ].freeze + + # rubocop:enable Naming/ConstantName + + # e_ident[] indexes + EI_MAG0 = 0 + EI_MAG1 = 1 + EI_MAG2 = 2 + EI_MAG3 = 3 + EI_CLASS = 4 + EI_DATA = 5 + EI_VERSION = 6 + EI_OSABI = 7 + EI_PAD = 8 + + # EI_MAG + ELFMAG0 = 0x7f + ELFMAG1 = 'E'.ord + ELFMAG2 = 'L'.ord + ELFMAG3 = 'F'.ord + ELFMAG = [ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3].pack('C*') + SELFMAG = 4 + + # e_ident[EI_CLASS] + ELFCLASSNONE = 0 + ELFCLASS32 = 1 + ELFCLASS64 = 2 + ELFCLASSNUM = 3 + + # e_ident[EI_DATA] + ELFDATANONE = 0 + ELFDATA2LSB = 1 + ELFDATA2MSB = 2 + + def initialize(buffer) + @buffer = buffer + @ehdr = read_ehdr + @buffer.seek(@ehdr[:e_phoff], IO::SEEK_SET) + @proghdrs = Array.new(@ehdr[:e_phnum]) do + read_phdr + end + end + + def relocatable? + @ehdr[:e_type] == ET_REL + end + + def executable? + @ehdr[:e_type] == ET_EXEC + end + + def shared_object? + @ehdr[:e_type] == ET_DYN + end + + def core? + @ehdr[:e_type] == ET_CORE + end + + def interpreter + phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP } + return if phdr.nil? + + @buffer.seek(phdr[:p_offset], IO::SEEK_SET) + interpreter = @buffer.read(phdr[:p_filesz]) + raise ArgumentError unless interpreter.end_with?("\0") + + interpreter.chomp!("\0") + end + + private + + def file_class + @ehdr[:e_ident][EI_CLASS] + end + + def data_encoding + @ehdr[:e_ident][EI_DATA] + end + + def read_ehdr + @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') } + raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG + + case file_class + when ELFCLASS32 + Elf32_Ehdr + when ELFCLASS64 + Elf64_Ehdr + else + raise ArgumentError + end.drop(1).to_h do |field| + [field[1], read1(field[0])] + end.merge!(@ehdr) + end + + def read_phdr + case file_class + when ELFCLASS32 + Elf32_Phdr + when ELFCLASS64 + Elf64_Phdr + else + raise ArgumentError + end.to_h do |field| + [field[1], read1(field[0])] + end + end + + def explicit_endian + case data_encoding + when ELFDATA2LSB + '<' + when ELFDATA2MSB + '>' + else + raise ArgumentError + end + end + + def read1(type) + case type + when :__u8 + @buffer.read(1).unpack1('C') + when :__u16 + @buffer.read(2).unpack1("S#{explicit_endian}") + when :__u32 + @buffer.read(4).unpack1("L#{explicit_endian}") + when :__u64 + @buffer.read(8).unpack1("Q#{explicit_endian}") + when :__s8 + @buffer.read(1).unpack1('c') + when :__s16 + @buffer.read(2).unpack1("s#{explicit_endian}") + when :__s32 + @buffer.read(4).unpack1("l#{explicit_endian}") + when :__s64 + @buffer.read(8).unpack1("q#{explicit_endian}") + else + raise ArgumentError + end + end + + INTERPRETER = begin + proc_self_exe = '/proc/self/exe' + if File.exist?(proc_self_exe) + File.open(proc_self_exe, 'rb') do |file| + elf = ELF.new(file) + interpreter = elf.interpreter + if interpreter.nil? && elf.shared_object? + File.readlink(proc_self_exe) + else + interpreter + end + end + end + end + end + + private_constant :ELF +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded.rb new file mode 100644 index 0000000..714e864 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +require_relative 'compiler' + +# The Sass module. +# +# This communicates with Embedded Dart Sass using the Embedded Sass protocol. +# +# @example +# Sass.compile('style.scss') +# +# @example +# Sass.compile_string('h1 { font-size: 40px; }') +module Sass + @compiler = nil + @mutex = Mutex.new + + # rubocop:disable Layout/LineLength + class << self + # Compiles the Sass file at +path+ to CSS. + # @overload compile(path, load_paths: [], charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, fatal_deprecations: [], future_deprecations: [], logger: nil, quiet_deps: false, silence_deprecations: [], verbose: false) + # @param (see Compiler#compile) + # @return (see Compiler#compile) + # @raise (see Compiler#compile) + # @see Compiler#compile + def compile(...) + compiler.compile(...) + end + + # Compiles a stylesheet whose contents is +source+ to CSS. + # @overload compile_string(source, importer: nil, load_paths: [], syntax: :scss, url: nil, charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, fatal_deprecations: [], future_deprecations: [], logger: nil, quiet_deps: false, silence_deprecations: [], verbose: false) + # @param (see Compiler#compile_string) + # @return (see Compiler#compile_string) + # @raise (see Compiler#compile_string) + # @see Compiler#compile_string + def compile_string(...) + compiler.compile_string(...) + end + + # @param (see Compiler#info) + # @return (see Compiler#info) + # @raise (see Compiler#info) + # @see Compiler#info + def info + compiler.info + end + + private + + def compiler + return @compiler if @compiler + + @mutex.synchronize do + return @compiler if @compiler + + compiler = Class.new(Compiler) do + def initialize + @channel = Compiler.const_get(:Channel).new(Class.new(Compiler.const_get(:Dispatcher)) do + def initialize + super + + idle_timeout = 10 + @last_accessed_time = current_time + + Thread.new do + Thread.current.name = "sass-embedded-connection-reaper-#{@connection.id}" + duration = idle_timeout + loop do + sleep(duration.negative? ? idle_timeout : duration) + break if @mutex.synchronize do + raise Errno::EBUSY if _closed? + + duration = idle_timeout - (current_time - @last_accessed_time) + duration.negative? && _idle? && _close + end + end + close + rescue Errno::EBUSY + # do nothing + end + end + + private + + def _idle + super + + @last_accessed_time = current_time + end + + def current_time + Process.clock_gettime(Process::CLOCK_MONOTONIC) + end + end) + end + end.new + + at_exit do + compiler.close + end + + @compiler = compiler + end + end + end + # rubocop:enable Layout/LineLength +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded/version.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded/version.rb new file mode 100644 index 0000000..0438664 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Sass + module Embedded + VERSION = '1.77.8' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded_protocol.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded_protocol.rb new file mode 100644 index 0000000..1031afb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/embedded_protocol.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Sass + # @see https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md + module EmbeddedProtocol + require_relative '../../ext/sass/embedded_sass_pb' + end + + private_constant :EmbeddedProtocol +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/exception.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/exception.rb new file mode 100644 index 0000000..bc88235 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/exception.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +module Sass + # An exception thrown because a Sass compilation failed. + class CompileError < StandardError + # @return [String, nil] + attr_reader :sass_stack + + # @return [Logger::SourceSpan, nil] + attr_reader :span + + # @return [Array] + attr_reader :loaded_urls + + # @!visibility private + def initialize(message, full_message, sass_stack, span, loaded_urls) + super(message) + + @full_message = full_message + @sass_stack = sass_stack + @span = span + @loaded_urls = loaded_urls + end + + # @return [String] + def full_message(highlight: nil, order: nil, **) + return super if @full_message.nil? + + highlight = Exception.to_tty? if highlight.nil? + if highlight + @full_message.dup + else + @full_message.gsub(/\e\[[0-9;]*m/, '') + end + end + + # @return [String] + def to_css + content = full_message(highlight: false, order: :top) + + <<~CSS.freeze + /* #{content.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ + + body::before { + position: static; + display: block; + padding: 1em; + margin: 0 0 1em; + border-width: 0 0 2px; + border-bottom-style: solid; + font-family: monospace, monospace; + white-space: pre; + content: #{Serializer.serialize_quoted_string(content).gsub(/[^[:ascii:]][\h\t ]?/) do |match| + replacement = "\\#{match.ord.to_s(16)}" + replacement << " #{match[1]}" if match.length > 1 + replacement + end}; + } + CSS + end + end + + # An exception thrown by Sass Script. + # @!visibility private + class ScriptError < StandardError + def initialize(message, name = nil) + super(name.nil? ? message : "$#{name}: #{message}") + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/fork_tracker.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/fork_tracker.rb new file mode 100644 index 0000000..2453bae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/fork_tracker.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Sass + # The {ForkTracker} module. + # + # It tracks objects that need to be closed after `Process.fork`. + module ForkTracker + HASH = {}.compare_by_identity + + MUTEX = Mutex.new + + private_constant :HASH, :MUTEX + + module_function + + def add(obj) + MUTEX.synchronize do + HASH[obj] = true + end + end + + def delete(obj) + MUTEX.synchronize do + HASH.delete(obj) + end + end + + def each(...) + MUTEX.synchronize do + HASH.keys + end.each(...) + end + + # The {CoreExt} module. + # + # It closes objects after `Process.fork`. + module CoreExt + def _fork + pid = super + ForkTracker.each(&:close) if pid.zero? + pid + end + end + + private_constant :CoreExt + + Process.singleton_class.prepend(CoreExt) if Process.respond_to?(:_fork) + end + + private_constant :ForkTracker +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/silent.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/silent.rb new file mode 100644 index 0000000..f090efa --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/silent.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Sass + # A namespace for built-in Loggers. + # + # @see https://sass-lang.com/documentation/js-api/modules/logger/ + module Logger + module_function + + # A Logger that silently ignores all warnings and debug messages. + # + # @see https://sass-lang.com/documentation/js-api/variables/logger.silent/ + def silent + Silent + end + + # A Logger that silently ignores all warnings and debug messages. + module Silent + module_function + + def warn(message, options); end + + def debug(message, options); end + end + + private_constant :Silent + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/source_location.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/source_location.rb new file mode 100644 index 0000000..19a4d32 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/source_location.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Sass + module Logger + # A specific location within a source file. + # + # This is always associated with a {SourceSpan} which indicates which file it refers to. + # + # @see https://sass-lang.com/documentation/js-api/interfaces/sourcelocation/ + class SourceLocation + # @return [Integer] + attr_reader :offset, :line, :column + + # @!visibility private + def initialize(source_location) + @offset = source_location.offset + @line = source_location.line + @column = source_location.column + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/source_span.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/source_span.rb new file mode 100644 index 0000000..3f22ca3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/logger/source_span.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Sass + module Logger + # A span of text within a source file. + # + # @see https://sass-lang.com/documentation/js-api/interfaces/sourcespan/ + class SourceSpan + # @return [SourceLocation] + attr_reader :start, :end + + # @return [String] + attr_reader :text + + # @return [String, nil] + attr_reader :url, :context + + # @!visibility private + def initialize(source_span) + @start = source_span.start.nil? ? nil : Logger::SourceLocation.new(source_span.start) + @end = source_span.end.nil? ? nil : Logger::SourceLocation.new(source_span.end) + @text = source_span.text + @url = source_span.url == '' ? nil : source_span.url + @context = source_span.context == '' ? nil : source_span.context + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/node_package_importer.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/node_package_importer.rb new file mode 100644 index 0000000..07d6d54 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/node_package_importer.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Sass + # The built-in Node.js package importer. This loads pkg: URLs from node_modules + # according to the standard Node.js resolution algorithm. + # + # @see https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/ + class NodePackageImporter + # @param entry_point_directory [String] The directory where the {NodePackageImporter} should start when resolving + # `pkg:` URLs in sources other than files on disk. + def initialize(entry_point_directory) + raise ArgumentError, 'entry_point_directory must be set' if entry_point_directory.nil? + + @entry_point_directory = File.absolute_path(entry_point_directory) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/serializer.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/serializer.rb new file mode 100644 index 0000000..8216eeb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/serializer.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Sass + # The {Serializer} module. + module Serializer + module_function + + CSS_ESCAPE = { + "\0" => "\uFFFD", + '\\' => '\\\\', + '"' => '\\"', + "'" => "\\'", + **[*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"].product( + [*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil] + ).to_h do |c, x| + ["#{c}#{x}".freeze, "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze] + end + }.freeze + + private_constant :CSS_ESCAPE + + def serialize_quoted_string(string) + if !string.include?('"') || string.include?("'") + %("#{string.gsub(/[\0\\"]|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}") + else + %('#{string.gsub(/[\0\\']|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}') + end + end + + def serialize_unquoted_string(string) + string.tr("\0", "\uFFFD").gsub(/\n */, ' ') + end + end + + private_constant :Serializer +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value.rb new file mode 100644 index 0000000..a3cbec1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +module Sass + # The abstract base class of Sass's value types. + # + # @see https://sass-lang.com/documentation/js-api/classes/value/ + module Value + # @return [::String, nil] + def separator + nil + end + + # @return [::Boolean] + def bracketed? + false + end + + # @return [::Boolean] + def eql?(other) + self == other + end + + # @param index [Numeric] + # @return [Value] + def [](index) + at(index) + end + + # @param index [Numeric] + # @return [Value] + def at(index) + index < 1 && index >= -1 ? self : nil + end + + # @return [Array] + def to_a + [self] + end + + # @return [::Boolean] + def to_bool + true + end + + # @return [Map, nil] + def to_map + nil + end + + # @return [Value, nil] + def to_nil + self + end + + # @return [Boolean] + # @raise [ScriptError] + def assert_boolean(name = nil) + raise Sass::ScriptError.new("#{self} is not a boolean", name) + end + + # @return [Calculation] + # @raise [ScriptError] + def assert_calculation(name = nil) + raise Sass::ScriptError.new("#{self} is not a calculation", name) + end + + # @return [Color] + # @raise [ScriptError] + def assert_color(name = nil) + raise Sass::ScriptError.new("#{self} is not a color", name) + end + + # @return [Function] + # @raise [ScriptError] + def assert_function(name = nil) + raise Sass::ScriptError.new("#{self} is not a function", name) + end + + # @return [Map] + # @raise [ScriptError] + def assert_map(name = nil) + raise Sass::ScriptError.new("#{self} is not a map", name) + end + + # @return [Mixin] + # @raise [ScriptError] + def assert_mixin(name = nil) + raise Sass::ScriptError.new("#{self} is not a mixin", name) + end + + # @return [Number] + # @raise [ScriptError] + def assert_number(name = nil) + raise Sass::ScriptError.new("#{self} is not a number", name) + end + + # @return [String] + # @raise [ScriptError] + def assert_string(name = nil) + raise Sass::ScriptError.new("#{self} is not a string", name) + end + + # @param sass_index [Number] + # @return [Integer] + def sass_index_to_array_index(sass_index, name = nil) + index = sass_index.assert_number(name).assert_integer(name) + raise Sass::ScriptError.new('List index may not be 0', name) if index.zero? + + if index.abs > to_a_length + raise Sass::ScriptError.new("Invalid index #{sass_index} for a list with #{to_a_length} elements", name) + end + + index.negative? ? to_a_length + index : index - 1 + end + + private + + def to_a_length + 1 + end + end +end + +require_relative 'calculation_value' +require_relative 'value/list' +require_relative 'value/argument_list' +require_relative 'value/boolean' +require_relative 'value/calculation' +require_relative 'value/color' +require_relative 'value/function' +require_relative 'value/fuzzy_math' +require_relative 'value/map' +require_relative 'value/mixin' +require_relative 'value/null' +require_relative 'value/number' +require_relative 'value/string' diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/argument_list.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/argument_list.rb new file mode 100644 index 0000000..8055011 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/argument_list.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's argument list type. + # + # An argument list comes from a rest argument. It's distinct from a normal {List} in that it may contain a keyword + # map as well as the positional arguments. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/ + class ArgumentList < List + # @param contents [Array] + # @param keywords [Hash] + # @param separator [::String] + def initialize(contents = [], keywords = {}, separator = ',') + super(contents, separator:) + + @id = 0 + @keywords_accessed = false + @keywords = keywords.freeze + end + + # @return [Hash] + def keywords + @keywords_accessed = true + @keywords + end + + private + + def initialize_dup(orig) + @id = 0 + super + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/boolean.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/boolean.rb new file mode 100644 index 0000000..ea4d418 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/boolean.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's boolean type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassboolean/ + class Boolean + include Value + + # @param value [::Boolean] + def initialize(value) + @value = value + end + + # @return [::Boolean] + attr_reader :value + + # @return [Boolean] + def ! + value ? Boolean::FALSE : Boolean::TRUE + end + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::Boolean) && other.value == value + end + + # @return [Integer] + def hash + @hash ||= value.hash + end + + alias to_bool value + + # @return [Boolean] + def assert_boolean(_name = nil) + self + end + + # Sass's true value. + TRUE = Boolean.new(true) + + # Sass's false value. + FALSE = Boolean.new(false) + + def self.new(value) + value ? Boolean::TRUE : Boolean::FALSE + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/calculation.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/calculation.rb new file mode 100644 index 0000000..32f26c0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/calculation.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's calculation type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sasscalculation/ + class Calculation + include Value + include CalculationValue + + class << self + private :new + + # @param argument [CalculationValue] + # @return [Calculation] + def calc(argument) + new('calc', [argument]) + end + + # @param arguments [Array] + # @return [Calculation] + def min(arguments) + new('min', arguments) + end + + # @param arguments [Array] + # @return [Calculation] + def max(arguments) + new('max', arguments) + end + + # @param min [CalculationValue] + # @param value [CalculationValue] + # @param max [CalculationValue] + # @return [Calculation] + def clamp(min, value = nil, max = nil) + if (value.nil? && !valid_clamp_arg?(min)) || + (max.nil? && [min, value].none? { |x| x && valid_clamp_arg?(x) }) + raise Sass::ScriptError, 'Argument must be an unquoted SassString.' + end + + new('clamp', [min, value, max].compact) + end + + private + + def valid_clamp_arg?(value) + value.is_a?(Sass::Value::String) && !value.quoted? + end + end + + private + + def initialize(name, arguments) + arguments.each do |value| + assert_calculation_value(value) + end + + @name = name.freeze + @arguments = arguments.freeze + end + + public + + # @return [::String] + attr_reader :name + + # @return [Array] + attr_reader :arguments + + # @return [Calculation] + def assert_calculation(_name = nil) + self + end + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::Calculation) && + other.name == name && + other.arguments == arguments + end + + # @return [Integer] + def hash + @hash ||= [name, *arguments].hash + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/color.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/color.rb new file mode 100644 index 0000000..bcfd191 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/color.rb @@ -0,0 +1,253 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's color type. + # + # No matter what representation was originally used to create this color, all of its channels are accessible. + # + # @see https://sass-lang.com/documentation/js-api/classes/sasscolor/ + class Color + include Value + + # @param red [Numeric] + # @param green [Numeric] + # @param blue [Numeric] + # @param hue [Numeric] + # @param saturation [Numeric] + # @param lightness [Numeric] + # @param whiteness [Numeric] + # @param blackness [Numeric] + # @param alpha [Numeric] + def initialize(red: nil, + green: nil, + blue: nil, + hue: nil, + saturation: nil, + lightness: nil, + whiteness: nil, + blackness: nil, + alpha: 1) + @alpha = alpha.nil? ? 1 : FuzzyMath.assert_between(alpha, 0, 1, 'alpha') + if red && green && blue + @red = FuzzyMath.assert_between(FuzzyMath.round(red), 0, 255, 'red') + @green = FuzzyMath.assert_between(FuzzyMath.round(green), 0, 255, 'green') + @blue = FuzzyMath.assert_between(FuzzyMath.round(blue), 0, 255, 'blue') + elsif hue && saturation && lightness + @hue = hue % 360 + @saturation = FuzzyMath.assert_between(saturation, 0, 100, 'saturation') + @lightness = FuzzyMath.assert_between(lightness, 0, 100, 'lightness') + elsif hue && whiteness && blackness + @hue = hue % 360 + @whiteness = FuzzyMath.assert_between(whiteness, 0, 100, 'whiteness') + @blackness = FuzzyMath.assert_between(blackness, 0, 100, 'blackness') + hwb_to_rgb + @whiteness = @blackness = nil + else + raise Sass::ScriptError, 'Invalid Color' + end + end + + # @return [Integer] + def red + hsl_to_rgb unless defined?(@red) + + @red + end + + # @return [Integer] + def green + hsl_to_rgb unless defined?(@green) + + @green + end + + # @return [Integer] + def blue + hsl_to_rgb unless defined?(@blue) + + @blue + end + + # @return [Numeric] + def hue + rgb_to_hsl unless defined?(@hue) + + @hue + end + + # @return [Numeric] + def saturation + rgb_to_hsl unless defined?(@saturation) + + @saturation + end + + # @return [Numeric] + def lightness + rgb_to_hsl unless defined?(@lightness) + + @lightness + end + + # @return [Numeric] + def whiteness + @whiteness ||= Rational([red, green, blue].min, 255) * 100 + end + + # @return [Numeric] + def blackness + @blackness ||= 100 - (Rational([red, green, blue].max, 255) * 100) + end + + # @return [Numeric] + attr_reader :alpha + + # @param red [Numeric] + # @param green [Numeric] + # @param blue [Numeric] + # @param hue [Numeric] + # @param saturation [Numeric] + # @param lightness [Numeric] + # @param whiteness [Numeric] + # @param blackness [Numeric] + # @param alpha [Numeric] + # @return [Color] + def change(red: nil, + green: nil, + blue: nil, + hue: nil, + saturation: nil, + lightness: nil, + whiteness: nil, + blackness: nil, + alpha: nil) + if whiteness || blackness + Sass::Value::Color.new(hue: hue || self.hue, + whiteness: whiteness || self.whiteness, + blackness: blackness || self.blackness, + alpha: alpha || self.alpha) + elsif hue || saturation || lightness + Sass::Value::Color.new(hue: hue || self.hue, + saturation: saturation || self.saturation, + lightness: lightness || self.lightness, + alpha: alpha || self.alpha) + elsif red || green || blue + Sass::Value::Color.new(red: red ? FuzzyMath.round(red) : self.red, + green: green ? FuzzyMath.round(green) : self.green, + blue: blue ? FuzzyMath.round(blue) : self.blue, + alpha: alpha || self.alpha) + else + dup.instance_eval do + @alpha = FuzzyMath.assert_between(alpha, 0, 1, 'alpha') + self + end + end + end + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::Color) && + other.red == red && + other.green == green && + other.blue == blue && + other.alpha == alpha + end + + # @return [Integer] + def hash + @hash ||= [red, green, blue, alpha].hash + end + + # @return [Color] + def assert_color(_name = nil) + self + end + + private + + def rgb_to_hsl + scaled_red = Rational(red, 255) + scaled_green = Rational(green, 255) + scaled_blue = Rational(blue, 255) + + max = [scaled_red, scaled_green, scaled_blue].max + min = [scaled_red, scaled_green, scaled_blue].min + delta = max - min + + if max == min + @hue = 0 + elsif max == scaled_red + @hue = ((scaled_green - scaled_blue) * 60 / delta) % 360 + elsif max == scaled_green + @hue = (((scaled_blue - scaled_red) * 60 / delta) + 120) % 360 + elsif max == scaled_blue + @hue = (((scaled_red - scaled_green) * 60 / delta) + 240) % 360 + end + + lightness = @lightness = (max + min) * 50 + + @saturation = if max == min + 0 + elsif lightness < 50 + delta * 100 / (max + min) + else + delta * 100 / (2 - max - min) + end + end + + def hsl_to_rgb + scaled_hue = Rational(hue, 360) + scaled_saturation = Rational(saturation, 100) + scaled_lightness = Rational(lightness, 100) + + tmp2 = if scaled_lightness <= 0.5 + scaled_lightness * (scaled_saturation + 1) + else + scaled_lightness + scaled_saturation - (scaled_lightness * scaled_saturation) + end + tmp1 = (scaled_lightness * 2) - tmp2 + @red = FuzzyMath.round(hsl_hue_to_rgb(tmp1, tmp2, scaled_hue + Rational(1, 3)) * 255) + @green = FuzzyMath.round(hsl_hue_to_rgb(tmp1, tmp2, scaled_hue) * 255) + @blue = FuzzyMath.round(hsl_hue_to_rgb(tmp1, tmp2, scaled_hue - Rational(1, 3)) * 255) + end + + def hsl_hue_to_rgb(tmp1, tmp2, hue) + hue += 1 if hue.negative? + hue -= 1 if hue > 1 + + if hue < Rational(1, 6) + tmp1 + ((tmp2 - tmp1) * hue * 6) + elsif hue < Rational(1, 2) + tmp2 + elsif hue < Rational(2, 3) + tmp1 + ((tmp2 - tmp1) * (Rational(2, 3) - hue) * 6) + else + tmp1 + end + end + + def hwb_to_rgb + scaled_hue = Rational(hue, 360) + scaled_whiteness = Rational(whiteness, 100) + scaled_blackness = Rational(blackness, 100) + + sum = scaled_whiteness + scaled_blackness + if sum > 1 + scaled_whiteness /= sum + scaled_blackness /= sum + end + + factor = 1 - scaled_whiteness - scaled_blackness + @red = hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue + Rational(1, 3)) + @green = hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue) + @blue = hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue - Rational(1, 3)) + end + + def hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue) + channel = (hsl_hue_to_rgb(0, 1, scaled_hue) * factor) + scaled_whiteness + FuzzyMath.round(channel * 255) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/function.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/function.rb new file mode 100644 index 0000000..0e5e998 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/function.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's function type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassfunction/ + class Function + include Value + + # @param signature [::String] + # @param callback [Proc] + def initialize(signature, &callback) + raise Sass::ScriptError, 'no block given' unless signature.nil? || callback + + @signature = signature.freeze + @callback = callback.freeze + end + + # @return [Integer, nil] + protected attr_reader :id + + # @return [::String, nil] + attr_reader :signature + + # @return [Proc, nil] + attr_reader :callback + + # @return [::Boolean] + def ==(other) + if id.nil? + other.equal?(self) + else + other.is_a?(Sass::Value::Function) && other.id == id + end + end + + # @return [Integer] + def hash + @hash ||= id.nil? ? signature.hash : id.hash + end + + # @return [Function] + def assert_function(_name = nil) + self + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/fuzzy_math.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/fuzzy_math.rb new file mode 100644 index 0000000..5fc6bc6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/fuzzy_math.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's {FuzzyMath} module. + module FuzzyMath + PRECISION = 10 + + EPSILON = 10.pow(-PRECISION - 1) + + INVERSE_EPSILON = 1 / EPSILON + + module_function + + def equals(number1, number2) + (number1 - number2).abs < EPSILON + end + + def less_than(number1, number2) + number1 < number2 && !equals(number1, number2) + end + + def less_than_or_equals(number1, number2) + number1 < number2 || equals(number1, number2) + end + + def greater_than(number1, number2) + number1 > number2 && !equals(number1, number2) + end + + def greater_than_or_equals(number1, number2) + number1 > number2 || equals(number1, number2) + end + + def integer?(number) + return false unless number.finite? + return true if number.integer? + + equals((number - 0.5).abs % 1, 0.5) + end + + def to_i(number) + integer?(number) ? number.round : nil + end + + def round(number) + if number.positive? + less_than(number % 1, 0.5) ? number.floor : number.ceil + else + less_than_or_equals(number % 1, 0.5) ? number.floor : number.ceil + end + end + + def between(number, min, max) + return min if equals(number, min) + return max if equals(number, max) + return number if number > min && number < max + + nil + end + + def assert_between(number, min, max, name) + result = between(number, min, max) + return result unless result.nil? + + raise Sass::ScriptError.new("#{number} must be between #{min} and #{max}.", name) + end + + def hash(number) + if number.finite? + (number * INVERSE_EPSILON).round.hash + else + number.hash + end + end + end + + private_constant :FuzzyMath + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/list.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/list.rb new file mode 100644 index 0000000..dac01e6 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/list.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's list type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sasslist/ + class List + include Value + + # @param contents [Array] + # @param separator [::String] + # @param bracketed [::Boolean] + def initialize(contents = [], separator: ',', bracketed: false) + if separator.nil? && contents.length > 1 + raise Sass::ScriptError, 'A list with more than one element must have an explicit separator' + end + + @contents = contents.freeze + @separator = separator.freeze + @bracketed = bracketed.freeze + end + + # @return [::String, nil] + attr_reader :separator + + # @return [::Boolean] + def bracketed? + @bracketed + end + + # @return [::Boolean] + def ==(other) + (other.is_a?(Sass::Value::List) && + other.to_a == to_a && + other.separator == separator && + other.bracketed? == bracketed?) || + (to_a.empty? && other.is_a?(Sass::Value::Map) && other.to_a.empty?) + end + + # @param index [Numeric] + # @return [Value] + def at(index) + index = index.floor + index = to_a.length + index if index.negative? + return nil if index.negative? || index >= to_a.length + + to_a[index] + end + + # @return [Integer] + def hash + @hash ||= contents.hash + end + + # @return [Array] + def to_a + @contents + end + + # @return [Map, nil] + def to_map + to_a.empty? ? Sass::Value::Map.new({}) : nil + end + + # @return [Map] + # @raise [ScriptError] + def assert_map(name = nil) + to_a.empty? ? Sass::Value::Map.new({}) : super.assert_map(name) + end + + private + + def to_a_length + to_a.length + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/map.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/map.rb new file mode 100644 index 0000000..8e1a62f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/map.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's map type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassmap/ + class Map + include Value + + # @param contents [Hash] + def initialize(contents = {}) + @contents = contents.freeze + end + + # @return [Hash] + attr_reader :contents + + # @return [::String, nil] + def separator + contents.empty? ? nil : ',' + end + + # @return [::Boolean] + def ==(other) + (other.is_a?(Sass::Value::Map) && other.contents == contents) || + (contents.empty? && other.is_a?(Sass::Value::List) && other.to_a.empty?) + end + + # @param index [Numeric, Value] + # @return [List<(Value, Value)>, Value] + def at(index) + if index.is_a?(Numeric) + index = index.floor + index = to_a_length + index if index.negative? + return nil if index.negative? || index >= to_a_length + + Sass::Value::List.new(contents.to_a[index], separator: ' ') + else + contents[index] + end + end + + # @return [Integer] + def hash + @hash ||= contents.hash + end + + # @return [Array>] + def to_a + contents.map { |key, value| Sass::Value::List.new([key, value], separator: ' ') } + end + + # @return [Map] + def to_map + self + end + + # @return [Map] + def assert_map(_name = nil) + self + end + + private + + def to_a_length + contents.length + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/mixin.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/mixin.rb new file mode 100644 index 0000000..2f65fdb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/mixin.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's mixin type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassmixin/ + class Mixin + include Value + + class << self + private :new + end + + # @return [Integer] + protected attr_reader :id + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::Mixin) && other.id == id + end + + # @return [Integer] + def hash + @hash ||= id.hash + end + + # @return [Mixin] + def assert_mixin(_name = nil) + self + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/null.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/null.rb new file mode 100644 index 0000000..c680a30 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/null.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's null type. + # + # @see https://sass-lang.com/documentation/js-api/variables/sassnull/ + class Null + include Value + + def initialize + @value = nil + end + + # @return [nil] + attr_reader :value + + # @return [Boolean] + def ! + Boolean::TRUE + end + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::Null) + end + + # @return [Integer] + def hash + @hash ||= value.hash + end + + # @return [::Boolean] + def to_bool + false + end + + alias to_nil value + + # Sass's null value. + NULL = Null.new + + def self.new + NULL + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/number.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/number.rb new file mode 100644 index 0000000..69bd416 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/number.rb @@ -0,0 +1,366 @@ +# frozen_string_literal: true + +require_relative 'number/unit' + +module Sass + module Value + # Sass's number type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassnumber/ + class Number + include Value + include CalculationValue + + # @param value [Numeric] + # @param unit [::String, Hash] + # @option unit [Array<::String>] :numerator_units + # @option unit [Array<::String>] :denominator_units + def initialize(value, unit = nil) + case unit + when nil + numerator_units = [] + denominator_units = [] + when ::String + numerator_units = [unit] + denominator_units = [] + when ::Hash + numerator_units = unit.fetch(:numerator_units, []) + unless numerator_units.is_a?(Array) + raise Sass::ScriptError, "invalid numerator_units #{numerator_units.inspect}" + end + + denominator_units = unit.fetch(:denominator_units, []) + unless denominator_units.is_a?(Array) + raise Sass::ScriptError, "invalid denominator_units #{denominator_units.inspect}" + end + else + raise Sass::ScriptError, "invalid unit #{unit.inspect}" + end + + unless denominator_units.empty? && numerator_units.empty? + value = value.dup + numerator_units = numerator_units.dup + new_denominator_units = [] + + denominator_units.each do |denominator_unit| + index = numerator_units.find_index do |numerator_unit| + factor = Unit.conversion_factor(denominator_unit, numerator_unit) + if factor.nil? + false + else + value *= factor + true + end + end + if index.nil? + new_denominator_units.push(denominator_unit) + else + numerator_units.delete_at(index) + end + end + + denominator_units = new_denominator_units + end + + @value = value.freeze + @numerator_units = numerator_units.each(&:freeze).freeze + @denominator_units = denominator_units.each(&:freeze).freeze + end + + # @return [Numeric] + attr_reader :value + + # @return [Array<::String>] + attr_reader :numerator_units, :denominator_units + + # @return [::Boolean] + def ==(other) + return false unless other.is_a?(Sass::Value::Number) + + return false if numerator_units.length != other.numerator_units.length || + denominator_units.length != other.denominator_units.length + + return FuzzyMath.equals(value, other.value) if unitless? + + if Unit.canonicalize_units(numerator_units) != Unit.canonicalize_units(other.numerator_units) && + Unit.canonicalize_units(denominator_units) != Unit.canonicalize_units(other.denominator_units) + return false + end + + FuzzyMath.equals( + (value * + Unit.canonical_multiplier(numerator_units) / + Unit.canonical_multiplier(denominator_units)), + (other.value * + Unit.canonical_multiplier(other.numerator_units) / + Unit.canonical_multiplier(other.denominator_units)) + ) + end + + # @return [Integer] + def hash + @hash ||= FuzzyMath.hash(canonical_units_value) + end + + # @return [::Boolean] + def unitless? + numerator_units.empty? && denominator_units.empty? + end + + # @return [Number] + # @raise [ScriptError] + def assert_unitless(name = nil) + raise Sass::ScriptError.new("Expected #{self} to have no units", name) unless unitless? + + self + end + + # @return [::Boolean] + def units? + !unitless? + end + + # @param unit [::String] + # @return [::Boolean] + def unit?(unit) + single_unit? && numerator_units.first == unit + end + + # @param unit [::String] + # @return [Number] + # @raise [ScriptError] + def assert_unit(unit, name = nil) + raise Sass::ScriptError.new("Expected #{self} to have unit #{unit.inspect}", name) unless unit?(unit) + + self + end + + # @return [::Boolean] + def integer? + FuzzyMath.integer?(value) + end + + # @return [Integer] + # @raise [ScriptError] + def assert_integer(name = nil) + raise Sass::ScriptError.new("#{self} is not an integer", name) unless integer? + + to_i + end + + # @return [Integer] + def to_i + FuzzyMath.to_i(value) + end + + # @param min [Numeric] + # @param max [Numeric] + # @return [Numeric] + # @raise [ScriptError] + def assert_between(min, max, name = nil) + FuzzyMath.assert_between(value, min, max, name) + end + + # @param unit [::String] + # @return [::Boolean] + def compatible_with_unit?(unit) + single_unit? && !Unit.conversion_factor(numerator_units.first, unit).nil? + end + + # @param new_numerator_units [Array<::String>] + # @param new_denominator_units [Array<::String>] + # @return [Number] + def convert(new_numerator_units, new_denominator_units, name = nil) + Number.new(convert_value(new_numerator_units, new_denominator_units, name), { + numerator_units: new_numerator_units, + denominator_units: new_denominator_units + }) + end + + # @param new_numerator_units [Array<::String>] + # @param new_denominator_units [Array<::String>] + # @return [Numeric] + def convert_value(new_numerator_units, new_denominator_units, name = nil) + coerce_or_convert_value(new_numerator_units, new_denominator_units, + coerce_unitless: false, + name:) + end + + # @param other [Number] + # @return [Number] + def convert_to_match(other, name = nil, other_name = nil) + Number.new(convert_value_to_match(other, name, other_name), { + numerator_units: other.numerator_units, + denominator_units: other.denominator_units + }) + end + + # @param other [Number] + # @return [Numeric] + def convert_value_to_match(other, name = nil, other_name = nil) + coerce_or_convert_value(other.numerator_units, other.denominator_units, + coerce_unitless: false, + name:, + other:, + other_name:) + end + + # @param new_numerator_units [Array<::String>] + # @param new_denominator_units [Array<::String>] + # @return [Number] + def coerce(new_numerator_units, new_denominator_units, name = nil) + Number.new(coerce_value(new_numerator_units, new_denominator_units, name), { + numerator_units: new_numerator_units, + denominator_units: new_denominator_units + }) + end + + # @param new_numerator_units [Array<::String>] + # @param new_denominator_units [Array<::String>] + # @return [Numeric] + def coerce_value(new_numerator_units, new_denominator_units, name = nil) + coerce_or_convert_value(new_numerator_units, new_denominator_units, + coerce_unitless: true, + name:) + end + + # @param unit [::String] + # @return [Numeric] + def coerce_value_to_unit(unit, name = nil) + coerce_value([unit], [], name) + end + + # @param other [Number] + # @return [Number] + def coerce_to_match(other, name = nil, other_name = nil) + Number.new(coerce_value_to_match(other, name, other_name), { + numerator_units: other.numerator_units, + denominator_units: other.denominator_units + }) + end + + # @param other [Number] + # @return [Numeric] + def coerce_value_to_match(other, name = nil, other_name = nil) + coerce_or_convert_value(other.numerator_units, other.denominator_units, + coerce_unitless: true, + name:, + other:, + other_name:) + end + + # @return [Number] + def assert_number(_name = nil) + self + end + + private + + def single_unit? + numerator_units.length == 1 && denominator_units.empty? + end + + def canonical_units_value + if unitless? + value + elsif single_unit? + value * Unit.canonical_multiplier_for_unit(numerator_units.first) + else + value * Unit.canonical_multiplier(numerator_units) / Unit.canonical_multiplier(denominator_units) + end + end + + def coerce_or_convert_value(new_numerator_units, new_denominator_units, + coerce_unitless:, + name: nil, + other: nil, + other_name: nil) + if other && (other.numerator_units != new_denominator_units && other.denominator_units != new_denominator_units) + raise Sass::ScriptError, "Expect #{other} to have units #{unit_string(new_numerator_units, + new_denominator_units).inspect}" + end + + return value if numerator_units == new_numerator_units && denominator_units == new_denominator_units + + return value if numerator_units == new_numerator_units && denominator_units == new_denominator_units + + other_unitless = new_numerator_units.empty? && new_denominator_units.empty? + + return value if coerce_unitless && (unitless? || other_unitless) + + compatibility_error = lambda { + unless other.nil? + message = +"#{self} and" + message << " $#{other_name}:" unless other_name.nil? + message << " #{other} have incompatible units" + message << " (one has units and the other doesn't)" if unitless? || other_unitless + return Sass::ScriptError.new(message, name) + end + + return Sass::ScriptError.new("Expected #{self} to have no units", name) unless other_unitless + + if new_numerator_units.length == 1 && new_denominator_units.empty? + type = Unit::TYPES_BY_UNIT[new_numerator_units.first] + return Sass::ScriptError.new( + "Expected #{self} to have a #{type} unit (#{Unit::UNITS_BY_TYPE[type].join(', ')})", name + ) + end + + unit_length = new_numerator_units.length + new_denominator_units.length + units = unit_string(new_numerator_units, new_denominator_units) + Sass::ScriptError.new("Expected #{self} to have unit#{unit_length > 1 ? 's' : ''} #{units}", name) + } + + result = value + + old_numerator_units = numerator_units.dup + new_numerator_units.each do |new_numerator_unit| + index = old_numerator_units.find_index do |old_numerator_unit| + factor = Unit.conversion_factor(new_numerator_unit, old_numerator_unit) + if factor.nil? + false + else + result *= factor + true + end + end + raise compatibility_error.call if index.nil? + + old_numerator_units.delete_at(index) + end + + old_denominator_units = denominator_units.dup + new_denominator_units.each do |new_denominator_unit| + index = old_denominator_units.find_index do |old_denominator_unit| + factor = Unit.conversion_factor(new_denominator_unit, old_denominator_unit) + if factor.nil? + false + else + result /= factor + true + end + end + raise compatibility_error.call if index.nil? + + old_denominator_units.delete_at(index) + end + + raise compatibility_error.call unless old_numerator_units.empty? && old_denominator_units.empty? + + result + end + + def unit_string(numerator_units, denominator_units) + if numerator_units.empty? + return 'no units' if denominator_units.empty? + + return denominator_units.length == 1 ? "#{denominator_units.first}^-1" : "(#{denominator_units.join('*')})^-1" + end + + return numerator_units.join('*') if denominator_units.empty? + + "#{numerator_units.join('*')}/#{denominator_units.join('*')}" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/number/unit.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/number/unit.rb new file mode 100644 index 0000000..bb0a418 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/number/unit.rb @@ -0,0 +1,186 @@ +# frozen_string_literal: true + +module Sass + module Value + class Number + # The {Unit} module. + module Unit + CONVERSIONS = { + # Length + 'in' => { + 'in' => Rational(1), + 'cm' => Rational(1, 2.54), + 'pc' => Rational(1, 6), + 'mm' => Rational(1, 25.4), + 'q' => Rational(1, 101.6), + 'pt' => Rational(1, 72), + 'px' => Rational(1, 96) + }, + 'cm' => { + 'in' => Rational(2.54), + 'cm' => Rational(1), + 'pc' => Rational(2.54, 6), + 'mm' => Rational(1, 10), + 'q' => Rational(1, 40), + 'pt' => Rational(2.54, 72), + 'px' => Rational(2.54, 96) + }, + 'pc' => { + 'in' => Rational(6), + 'cm' => Rational(6, 2.54), + 'pc' => Rational(1), + 'mm' => Rational(6, 25.4), + 'q' => Rational(6, 101.6), + 'pt' => Rational(1, 12), + 'px' => Rational(1, 16) + }, + 'mm' => { + 'in' => Rational(25.4), + 'cm' => Rational(10), + 'pc' => Rational(25.4, 6), + 'mm' => Rational(1), + 'q' => Rational(1, 4), + 'pt' => Rational(25.4, 72), + 'px' => Rational(25.4, 96) + }, + 'q' => { + 'in' => Rational(101.6), + 'cm' => Rational(40), + 'pc' => Rational(101.6, 6), + 'mm' => Rational(4), + 'q' => Rational(1), + 'pt' => Rational(101.6, 72), + 'px' => Rational(101.6, 96) + }, + 'pt' => { + 'in' => Rational(72), + 'cm' => Rational(72, 2.54), + 'pc' => Rational(12), + 'mm' => Rational(72, 25.4), + 'q' => Rational(72, 101.6), + 'pt' => Rational(1), + 'px' => Rational(3, 4) + }, + 'px' => { + 'in' => Rational(96), + 'cm' => Rational(96, 2.54), + 'pc' => Rational(16), + 'mm' => Rational(96, 25.4), + 'q' => Rational(96, 101.6), + 'pt' => Rational(4, 3), + 'px' => Rational(1) + }, + + # Rotation + 'deg' => { + 'deg' => Rational(1), + 'grad' => Rational(9, 10), + 'rad' => Rational(180, Math::PI), + 'turn' => Rational(360) + }, + 'grad' => { + 'deg' => Rational(10, 9), + 'grad' => Rational(1), + 'rad' => Rational(200, Math::PI), + 'turn' => Rational(400) + }, + 'rad' => { + 'deg' => Rational(Math::PI, 180), + 'grad' => Rational(Math::PI, 200), + 'rad' => Rational(1), + 'turn' => Rational(Math::PI * 2) + }, + 'turn' => { + 'deg' => Rational(1, 360), + 'grad' => Rational(1, 400), + 'rad' => Rational(1, Math::PI * 2), + 'turn' => Rational(1) + }, + + # Time + 's' => { + 's' => Rational(1), + 'ms' => Rational(1, 1000) + }, + 'ms' => { + 's' => Rational(1000), + 'ms' => Rational(1) + }, + + # Frequency + 'Hz' => { + 'Hz' => Rational(1), + 'kHz' => Rational(1000) + }, + 'kHz' => { + 'Hz' => Rational(1, 1000), + 'kHz' => Rational(1) + }, + + # Pixel density + 'dpi' => { + 'dpi' => Rational(1), + 'dpcm' => Rational(2.54), + 'dppx' => Rational(96) + }, + 'dpcm' => { + 'dpi' => Rational(1, 2.54), + 'dpcm' => Rational(1), + 'dppx' => Rational(96, 2.54) + }, + 'dppx' => { + 'dpi' => Rational(1, 96), + 'dpcm' => Rational(2.54, 96), + 'dppx' => Rational(1) + } + }.freeze + + UNITS_BY_TYPE = { + time: %w[s ms], + frequency: %w[Hz kHz], + 'pixel density': %w[dpi dpcm dppx] + }.freeze + + TYPES_BY_UNIT = UNITS_BY_TYPE.invert + .to_a + .flat_map { |pair| pair[0].map { |key| [key, pair[1]] } } + .to_h + + module_function + + def conversion_factor(unit1, unit2) + return 1 if unit1 == unit2 + + CONVERSIONS.dig(unit1, unit2) + end + + def canonicalize_units(units) + return units if units.empty? + + if units.length == 1 + type = TYPES_BY_UNIT[units.first] + return type.nil? ? units : [UNITS_BY_TYPE[type].first] + end + + units.map do |unit| + type = TYPES_BY_UNIT[unit] + type.nil? ? units : [UNITS_BY_TYPE[type].first] + end.sort + end + + def canonical_multiplier(units) + units.reduce(1) do |multiplier, unit| + multiplier * canonical_multiplier_for_unit(unit) + end + end + + def canonical_multiplier_for_unit(unit) + inner_map = CONVERSIONS[unit] + inner_map.nil? ? 1 : 1 / inner_map.values.first + end + end + + private_constant :Unit + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/string.rb b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/string.rb new file mode 100644 index 0000000..1738355 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/sass-embedded-1.77.8-x86_64-linux-gnu/lib/sass/value/string.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's string type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassstring/ + class String + include Value + include CalculationValue + + # @param text [::String] + # @param quoted [::Boolean] + def initialize(text = '', quoted: true) + @text = text.freeze + @quoted = quoted + end + + # @return [::String] + attr_reader :text + + # @return [::Boolean] + def quoted? + @quoted + end + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::String) && other.text == text + end + + # @return [Integer] + def hash + @hash ||= text.hash + end + + # @return [String] + def assert_string(_name = nil) + self + end + + # @param sass_index [Number] + # @return [Integer] + def sass_index_to_string_index(sass_index, name = nil) + index = sass_index.assert_number(name).assert_integer(name) + raise Sass::ScriptError.new('String index may not be 0', name) if index.zero? + + if index.abs > text.length + raise Sass::ScriptError.new("Invalid index #{sass_index} for a string with #{text.length} characters", name) + end + + index.negative? ? text.length + index : index - 1 + end + + # @return [String] + def to_s + @quoted ? Serializer.serialize_quoted_string(@text) : Serializer.serialize_unquoted_string(@text) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/COPYING b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/COPYING new file mode 100644 index 0000000..1f233f1 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/COPYING @@ -0,0 +1,56 @@ +StringScanner is copyrighted free software by Minero Aoki. +You can redistribute it and/or modify it under either the terms of the +2-clause BSDL (see the file LICENSE.txt), or the conditions below: + +1. You may make and give away verbatim copies of the source form of the + software without restriction, provided that you duplicate all of the + original copyright notices and associated disclaimers. + +2. You may modify your copy of the software in any way, provided that + you do at least ONE of the following: + + a. place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said + modifications to Usenet or an equivalent medium, or by allowing + the author to include your modifications in the software. + + b. use the modified software only within your corporation or + organization. + + c. give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d. make other distribution arrangements with the author. + +3. You may distribute the software in object code or binary form, + provided that you do at least ONE of the following: + + a. distribute the binaries and library files of the software, + together with instructions (in the manual page or equivalent) + on where to get the original distribution. + + b. accompany the distribution with the machine-readable source of + the software. + + c. give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d. make other distribution arrangements with the author. + +4. You may modify and include the part of the software into any other + software (possibly commercial). But some files in the distribution + are not written by the author, so that they are not under these terms. + + For the list of those files and their copying conditions, see the + file LEGAL. + +5. The scripts and library files supplied as input to or produced as + output from the software do not automatically fall under the + copyright of the software, but belong to whomever generated them, + and may be sold commercially, and may be aggregated with this + software. + +6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. diff --git a/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/LICENSE.txt new file mode 100644 index 0000000..4bda213 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (C) 1999-2006 Minero Aoki. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +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. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. diff --git a/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/Makefile b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/Makefile new file mode 100644 index 0000000..ffc6618 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/Makefile @@ -0,0 +1,269 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +V0 = $(V:0=) +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@ :) +ECHO = $(ECHO1:0=@ echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /usr/include/ruby-3.2.0 +hdrdir = $(topdir) +arch_hdrdir = /usr/include/ruby-3.2.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/usr +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(DESTDIR)/usr +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(sitelibdir)/$(sitearch) +sitelibdir = $(sitedir)/$(ruby_version) +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(DESTDIR)/usr/share/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib/x86_64-linux-gnu +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(DESTDIR)/usr/share/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(exec_prefix)/include +runstatedir = $(localstatedir)/run +localstatedir = $(DESTDIR)/var +sharedstatedir = $(DESTDIR)/usr/com +sysconfdir = $(DESTDIR)/etc +datadir = $(DESTDIR)/usr/share +datarootdir = $(prefix)/share +libexecdir = $(DESTDIR)/usr/libexec +sbindir = $(DESTDIR)/usr/bin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC_WRAPPER = +CC = x86_64-unknown-linux-gnu-gcc +CXX = x86_64-unknown-linux-gnu-g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static $(MAINLIBS) +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) +CSRCFLAG = $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = +optflags = -O3 -fno-fast-math +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef +cppflags = +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -fPIC $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -DHAVE_ONIG_REGION_MEMSIZE $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer $(ARCH_FLAG) +ldflags = -L. -Wl,-z,relro,-z,now -Wl,--as-needed -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed +dldflags = -Wl,-z,relro,-z,now -Wl,--as-needed +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CC) -shared +LDSHAREDXX = $(CXX) -shared +AR = x86_64-unknown-linux-gnu-gcc-ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 3.2.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = rm -fr +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lm -lpthread -lc +ORIG_SRCS = strscan.c +SRCS = $(ORIG_SRCS) +OBJS = strscan.o +HDRS = +LOCAL_HDRS = +TARGET = strscan +TARGET_NAME = strscan +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = $(TARGET).so +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(sitehdrdir)$(target_prefix) +ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix) +TARGET_SO_DIR = +TARGET_SO = $(TARGET_SO_DIR)$(DLLIB) +CLEANLIBS = $(TARGET_SO) false +CLEANOBJS = $(OBJS) *.bak +TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time + +all: $(DLLIB) +static: $(STATIC_LIB) +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP) + $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) +clean-static:: + -$(Q)$(RM) $(STATIC_LIB) +install-rb: pre-install-rb do-install-rb install-rb-default +install-rb-default: pre-install-rb-default do-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +do-install-rb: +do-install-rb-default: +pre-install-rb-default: + @$(NULLCMD) +$(TARGET_SO_DIR_TIMESTAMP): + $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) + $(Q) $(TOUCH) $@ + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + +.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S + +.cc.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cc.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.mm.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.mm.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cxx.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cxx.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cpp.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cpp.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.c.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.c.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.m.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.m.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +$(TARGET_SO): $(OBJS) Makefile + $(ECHO) linking shared-object $(DLLIB) + -$(Q)$(RM) $(@) + $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) + + + +$(OBJS): $(HDRS) $(ruby_headers) diff --git a/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/extconf.rb b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/extconf.rb new file mode 100644 index 0000000..bd65606 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/extconf.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +require 'mkmf' +if RUBY_ENGINE == 'ruby' + $INCFLAGS << " -I$(top_srcdir)" if $extmk + have_func("onig_region_memsize", "ruby.h") + have_func("rb_reg_onig_match", "ruby.h") + create_makefile 'strscan' +else + File.write('Makefile', dummy_makefile("").join) +end diff --git a/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/strscan.c b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/strscan.c new file mode 100644 index 0000000..0400089 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/ext/strscan/strscan.c @@ -0,0 +1,1741 @@ +/* + $Id$ + + Copyright (c) 1999-2006 Minero Aoki + + This program is free software. + You can redistribute this program under the terms of the Ruby's or 2-clause + BSD License. For details, see the COPYING and LICENSE.txt files. +*/ + +#include "ruby/ruby.h" +#include "ruby/re.h" +#include "ruby/encoding.h" + +#ifdef RUBY_EXTCONF_H +# include RUBY_EXTCONF_H +#endif + +#ifdef HAVE_ONIG_REGION_MEMSIZE +extern size_t onig_region_memsize(const struct re_registers *regs); +#endif + +#include + +#define STRSCAN_VERSION "3.1.0" + +/* ======================================================================= + Data Type Definitions + ======================================================================= */ + +static VALUE StringScanner; +static VALUE ScanError; +static ID id_byteslice; + +struct strscanner +{ + /* multi-purpose flags */ + unsigned long flags; +#define FLAG_MATCHED (1 << 0) + + /* the string to scan */ + VALUE str; + + /* scan pointers */ + long prev; /* legal only when MATCHED_P(s) */ + long curr; /* always legal */ + + /* the regexp register; legal only when MATCHED_P(s) */ + struct re_registers regs; + + /* regexp used for last scan */ + VALUE regex; + + /* anchor mode */ + bool fixed_anchor_p; +}; + +#define MATCHED_P(s) ((s)->flags & FLAG_MATCHED) +#define MATCHED(s) (s)->flags |= FLAG_MATCHED +#define CLEAR_MATCH_STATUS(s) (s)->flags &= ~FLAG_MATCHED + +#define S_PBEG(s) (RSTRING_PTR((s)->str)) +#define S_LEN(s) (RSTRING_LEN((s)->str)) +#define S_PEND(s) (S_PBEG(s) + S_LEN(s)) +#define CURPTR(s) (S_PBEG(s) + (s)->curr) +#define S_RESTLEN(s) (S_LEN(s) - (s)->curr) + +#define EOS_P(s) ((s)->curr >= RSTRING_LEN(p->str)) + +#define GET_SCANNER(obj,var) do {\ + (var) = check_strscan(obj);\ + if (NIL_P((var)->str)) rb_raise(rb_eArgError, "uninitialized StringScanner object");\ +} while (0) + +/* ======================================================================= + Function Prototypes + ======================================================================= */ + +static inline long minl _((const long n, const long x)); +static VALUE extract_range _((struct strscanner *p, long beg_i, long end_i)); +static VALUE extract_beg_len _((struct strscanner *p, long beg_i, long len)); + +static struct strscanner *check_strscan _((VALUE obj)); +static void strscan_mark _((void *p)); +static void strscan_free _((void *p)); +static size_t strscan_memsize _((const void *p)); +static VALUE strscan_s_allocate _((VALUE klass)); +static VALUE strscan_initialize _((int argc, VALUE *argv, VALUE self)); +static VALUE strscan_init_copy _((VALUE vself, VALUE vorig)); + +static VALUE strscan_s_mustc _((VALUE self)); +static VALUE strscan_terminate _((VALUE self)); +static VALUE strscan_clear _((VALUE self)); +static VALUE strscan_get_string _((VALUE self)); +static VALUE strscan_set_string _((VALUE self, VALUE str)); +static VALUE strscan_concat _((VALUE self, VALUE str)); +static VALUE strscan_get_pos _((VALUE self)); +static VALUE strscan_set_pos _((VALUE self, VALUE pos)); +static VALUE strscan_do_scan _((VALUE self, VALUE regex, + int succptr, int getstr, int headonly)); +static VALUE strscan_scan _((VALUE self, VALUE re)); +static VALUE strscan_match_p _((VALUE self, VALUE re)); +static VALUE strscan_skip _((VALUE self, VALUE re)); +static VALUE strscan_check _((VALUE self, VALUE re)); +static VALUE strscan_scan_full _((VALUE self, VALUE re, + VALUE succp, VALUE getp)); +static VALUE strscan_scan_until _((VALUE self, VALUE re)); +static VALUE strscan_skip_until _((VALUE self, VALUE re)); +static VALUE strscan_check_until _((VALUE self, VALUE re)); +static VALUE strscan_search_full _((VALUE self, VALUE re, + VALUE succp, VALUE getp)); +static void adjust_registers_to_matched _((struct strscanner *p)); +static VALUE strscan_getch _((VALUE self)); +static VALUE strscan_get_byte _((VALUE self)); +static VALUE strscan_getbyte _((VALUE self)); +static VALUE strscan_peek _((VALUE self, VALUE len)); +static VALUE strscan_peep _((VALUE self, VALUE len)); +static VALUE strscan_unscan _((VALUE self)); +static VALUE strscan_bol_p _((VALUE self)); +static VALUE strscan_eos_p _((VALUE self)); +static VALUE strscan_empty_p _((VALUE self)); +static VALUE strscan_rest_p _((VALUE self)); +static VALUE strscan_matched_p _((VALUE self)); +static VALUE strscan_matched _((VALUE self)); +static VALUE strscan_matched_size _((VALUE self)); +static VALUE strscan_aref _((VALUE self, VALUE idx)); +static VALUE strscan_pre_match _((VALUE self)); +static VALUE strscan_post_match _((VALUE self)); +static VALUE strscan_rest _((VALUE self)); +static VALUE strscan_rest_size _((VALUE self)); + +static VALUE strscan_inspect _((VALUE self)); +static VALUE inspect1 _((struct strscanner *p)); +static VALUE inspect2 _((struct strscanner *p)); + +/* ======================================================================= + Utils + ======================================================================= */ + +static VALUE +str_new(struct strscanner *p, const char *ptr, long len) +{ + VALUE str = rb_str_new(ptr, len); + rb_enc_copy(str, p->str); + return str; +} + +static inline long +minl(const long x, const long y) +{ + return (x < y) ? x : y; +} + +static VALUE +extract_range(struct strscanner *p, long beg_i, long end_i) +{ + if (beg_i > S_LEN(p)) return Qnil; + end_i = minl(end_i, S_LEN(p)); + return str_new(p, S_PBEG(p) + beg_i, end_i - beg_i); +} + +static VALUE +extract_beg_len(struct strscanner *p, long beg_i, long len) +{ + if (beg_i > S_LEN(p)) return Qnil; + len = minl(len, S_LEN(p) - beg_i); + return str_new(p, S_PBEG(p) + beg_i, len); +} + +/* ======================================================================= + Constructor + ======================================================================= */ + +static void +strscan_mark(void *ptr) +{ + struct strscanner *p = ptr; + rb_gc_mark(p->str); + rb_gc_mark(p->regex); +} + +static void +strscan_free(void *ptr) +{ + struct strscanner *p = ptr; + onig_region_free(&(p->regs), 0); + ruby_xfree(p); +} + +static size_t +strscan_memsize(const void *ptr) +{ + const struct strscanner *p = ptr; + size_t size = sizeof(*p) - sizeof(p->regs); +#ifdef HAVE_ONIG_REGION_MEMSIZE + size += onig_region_memsize(&p->regs); +#endif + return size; +} + +static const rb_data_type_t strscanner_type = { + "StringScanner", + {strscan_mark, strscan_free, strscan_memsize}, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY +}; + +static VALUE +strscan_s_allocate(VALUE klass) +{ + struct strscanner *p; + VALUE obj = TypedData_Make_Struct(klass, struct strscanner, &strscanner_type, p); + + CLEAR_MATCH_STATUS(p); + onig_region_init(&(p->regs)); + p->str = Qnil; + p->regex = Qnil; + return obj; +} + +/* + * call-seq: + * StringScanner.new(string, fixed_anchor: false) + * StringScanner.new(string, dup = false) + * + * Creates a new StringScanner object to scan over the given +string+. + * + * If +fixed_anchor+ is +true+, +\A+ always matches the beginning of + * the string. Otherwise, +\A+ always matches the current position. + * + * +dup+ argument is obsolete and not used now. + */ +static VALUE +strscan_initialize(int argc, VALUE *argv, VALUE self) +{ + struct strscanner *p; + VALUE str, options; + + p = check_strscan(self); + rb_scan_args(argc, argv, "11", &str, &options); + options = rb_check_hash_type(options); + if (!NIL_P(options)) { + VALUE fixed_anchor; + ID keyword_ids[1]; + keyword_ids[0] = rb_intern("fixed_anchor"); + rb_get_kwargs(options, keyword_ids, 0, 1, &fixed_anchor); + if (fixed_anchor == Qundef) { + p->fixed_anchor_p = false; + } + else { + p->fixed_anchor_p = RTEST(fixed_anchor); + } + } + else { + p->fixed_anchor_p = false; + } + StringValue(str); + p->str = str; + + return self; +} + +static struct strscanner * +check_strscan(VALUE obj) +{ + return rb_check_typeddata(obj, &strscanner_type); +} + +/* + * call-seq: + * dup + * clone + * + * Duplicates a StringScanner object. + */ +static VALUE +strscan_init_copy(VALUE vself, VALUE vorig) +{ + struct strscanner *self, *orig; + + self = check_strscan(vself); + orig = check_strscan(vorig); + if (self != orig) { + self->flags = orig->flags; + self->str = orig->str; + self->prev = orig->prev; + self->curr = orig->curr; + if (rb_reg_region_copy(&self->regs, &orig->regs)) + rb_memerror(); + RB_GC_GUARD(vorig); + } + + return vself; +} + +/* ======================================================================= + Instance Methods + ======================================================================= */ + +/* + * call-seq: StringScanner.must_C_version + * + * This method is defined for backward compatibility. + */ +static VALUE +strscan_s_mustc(VALUE self) +{ + return self; +} + +/* + * Reset the scan pointer (index 0) and clear matching data. + */ +static VALUE +strscan_reset(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + p->curr = 0; + CLEAR_MATCH_STATUS(p); + return self; +} + +/* + * call-seq: + * terminate + * clear + * + * Sets the scan pointer to the end of the string and clear matching data. + */ +static VALUE +strscan_terminate(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + p->curr = S_LEN(p); + CLEAR_MATCH_STATUS(p); + return self; +} + +/* + * Equivalent to #terminate. + * This method is obsolete; use #terminate instead. + */ +static VALUE +strscan_clear(VALUE self) +{ + rb_warning("StringScanner#clear is obsolete; use #terminate instead"); + return strscan_terminate(self); +} + +/* + * Returns the string being scanned. + */ +static VALUE +strscan_get_string(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + return p->str; +} + +/* + * call-seq: string=(str) + * + * Changes the string being scanned to +str+ and resets the scanner. + * Returns +str+. + */ +static VALUE +strscan_set_string(VALUE self, VALUE str) +{ + struct strscanner *p = check_strscan(self); + + StringValue(str); + p->str = str; + p->curr = 0; + CLEAR_MATCH_STATUS(p); + return str; +} + +/* + * call-seq: + * concat(str) + * <<(str) + * + * Appends +str+ to the string being scanned. + * This method does not affect scan pointer. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.scan(/Fri /) + * s << " +1000 GMT" + * s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT" + * s.scan(/Dec/) # -> "Dec" + */ +static VALUE +strscan_concat(VALUE self, VALUE str) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + StringValue(str); + rb_str_append(p->str, str); + return self; +} + +/* + * Returns the byte position of the scan pointer. In the 'reset' position, this + * value is zero. In the 'terminated' position (i.e. the string is exhausted), + * this value is the bytesize of the string. + * + * In short, it's a 0-based index into bytes of the string. + * + * s = StringScanner.new('test string') + * s.pos # -> 0 + * s.scan_until /str/ # -> "test str" + * s.pos # -> 8 + * s.terminate # -> # + * s.pos # -> 11 + */ +static VALUE +strscan_get_pos(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + return INT2FIX(p->curr); +} + +/* + * Returns the character position of the scan pointer. In the 'reset' position, this + * value is zero. In the 'terminated' position (i.e. the string is exhausted), + * this value is the size of the string. + * + * In short, it's a 0-based index into the string. + * + * s = StringScanner.new("abc\u00e4def\u00f6ghi") + * s.charpos # -> 0 + * s.scan_until(/\u00e4/) # -> "abc\u00E4" + * s.pos # -> 5 + * s.charpos # -> 4 + */ +static VALUE +strscan_get_charpos(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + + return LONG2NUM(rb_enc_strlen(S_PBEG(p), CURPTR(p), rb_enc_get(p->str))); +} + +/* + * call-seq: pos=(n) + * + * Sets the byte position of the scan pointer. + * + * s = StringScanner.new('test string') + * s.pos = 7 # -> 7 + * s.rest # -> "ring" + */ +static VALUE +strscan_set_pos(VALUE self, VALUE v) +{ + struct strscanner *p; + long i; + + GET_SCANNER(self, p); + i = NUM2INT(v); + if (i < 0) i += S_LEN(p); + if (i < 0) rb_raise(rb_eRangeError, "index out of range"); + if (i > S_LEN(p)) rb_raise(rb_eRangeError, "index out of range"); + p->curr = i; + return LONG2NUM(i); +} + +static inline UChar * +match_target(struct strscanner *p) +{ + if (p->fixed_anchor_p) { + return (UChar *)S_PBEG(p); + } + else + { + return (UChar *)CURPTR(p); + } +} + +static inline void +set_registers(struct strscanner *p, size_t length) +{ + const int at = 0; + OnigRegion *regs = &(p->regs); + onig_region_clear(regs); + if (onig_region_set(regs, at, 0, 0)) return; + if (p->fixed_anchor_p) { + regs->beg[at] = p->curr; + regs->end[at] = p->curr + length; + } + else + { + regs->end[at] = length; + } +} + +static inline void +succ(struct strscanner *p) +{ + if (p->fixed_anchor_p) { + p->curr = p->regs.end[0]; + } + else + { + p->curr += p->regs.end[0]; + } +} + +static inline long +last_match_length(struct strscanner *p) +{ + if (p->fixed_anchor_p) { + return p->regs.end[0] - p->prev; + } + else + { + return p->regs.end[0]; + } +} + +static inline long +adjust_register_position(struct strscanner *p, long position) +{ + if (p->fixed_anchor_p) { + return position; + } + else { + return p->prev + position; + } +} + +/* rb_reg_onig_match is available in Ruby 3.3 and later. */ +#ifndef HAVE_RB_REG_ONIG_MATCH +static OnigPosition +rb_reg_onig_match(VALUE re, VALUE str, + OnigPosition (*match)(regex_t *reg, VALUE str, struct re_registers *regs, void *args), + void *args, struct re_registers *regs) +{ + regex_t *reg = rb_reg_prepare_re(re, str); + + bool tmpreg = reg != RREGEXP_PTR(re); + if (!tmpreg) RREGEXP(re)->usecnt++; + + OnigPosition result = match(reg, str, regs, args); + + if (!tmpreg) RREGEXP(re)->usecnt--; + if (tmpreg) { + if (RREGEXP(re)->usecnt) { + onig_free(reg); + } + else { + onig_free(RREGEXP_PTR(re)); + RREGEXP_PTR(re) = reg; + } + } + + if (result < 0) { + if (result != ONIG_MISMATCH) { + rb_raise(ScanError, "regexp buffer overflow"); + } + } + + return result; +} +#endif + +static OnigPosition +strscan_match(regex_t *reg, VALUE str, struct re_registers *regs, void *args_ptr) +{ + struct strscanner *p = (struct strscanner *)args_ptr; + + return onig_match(reg, + match_target(p), + (UChar* )(CURPTR(p) + S_RESTLEN(p)), + (UChar* )CURPTR(p), + regs, + ONIG_OPTION_NONE); +} + +static OnigPosition +strscan_search(regex_t *reg, VALUE str, struct re_registers *regs, void *args_ptr) +{ + struct strscanner *p = (struct strscanner *)args_ptr; + + return onig_search(reg, + match_target(p), + (UChar *)(CURPTR(p) + S_RESTLEN(p)), + (UChar *)CURPTR(p), + (UChar *)(CURPTR(p) + S_RESTLEN(p)), + regs, + ONIG_OPTION_NONE); +} + +static VALUE +strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly) +{ + struct strscanner *p; + + if (headonly) { + if (!RB_TYPE_P(pattern, T_REGEXP)) { + StringValue(pattern); + } + } + else { + Check_Type(pattern, T_REGEXP); + } + GET_SCANNER(self, p); + + CLEAR_MATCH_STATUS(p); + if (S_RESTLEN(p) < 0) { + return Qnil; + } + + if (RB_TYPE_P(pattern, T_REGEXP)) { + p->regex = pattern; + OnigPosition ret = rb_reg_onig_match(pattern, + p->str, + headonly ? strscan_match : strscan_search, + (void *)p, + &(p->regs)); + + if (ret == ONIG_MISMATCH) { + return Qnil; + } + } + else { + rb_enc_check(p->str, pattern); + if (S_RESTLEN(p) < RSTRING_LEN(pattern)) { + return Qnil; + } + if (memcmp(CURPTR(p), RSTRING_PTR(pattern), RSTRING_LEN(pattern)) != 0) { + return Qnil; + } + set_registers(p, RSTRING_LEN(pattern)); + } + + MATCHED(p); + p->prev = p->curr; + + if (succptr) { + succ(p); + } + { + const long length = last_match_length(p); + if (getstr) { + return extract_beg_len(p, p->prev, length); + } + else { + return INT2FIX(length); + } + } +} + +/* + * call-seq: scan(pattern) => String + * + * Tries to match with +pattern+ at the current position. If there's a match, + * the scanner advances the "scan pointer" and returns the matched string. + * Otherwise, the scanner returns +nil+. + * + * s = StringScanner.new('test string') + * p s.scan(/\w+/) # -> "test" + * p s.scan(/\w+/) # -> nil + * p s.scan(/\s+/) # -> " " + * p s.scan("str") # -> "str" + * p s.scan(/\w+/) # -> "ing" + * p s.scan(/./) # -> nil + * + */ +static VALUE +strscan_scan(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 1, 1, 1); +} + +/* + * call-seq: match?(pattern) + * + * Tests whether the given +pattern+ is matched from the current scan pointer. + * Returns the length of the match, or +nil+. The scan pointer is not advanced. + * + * s = StringScanner.new('test string') + * p s.match?(/\w+/) # -> 4 + * p s.match?(/\w+/) # -> 4 + * p s.match?("test") # -> 4 + * p s.match?(/\s+/) # -> nil + */ +static VALUE +strscan_match_p(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 0, 0, 1); +} + +/* + * call-seq: skip(pattern) + * + * Attempts to skip over the given +pattern+ beginning with the scan pointer. + * If it matches, the scan pointer is advanced to the end of the match, and the + * length of the match is returned. Otherwise, +nil+ is returned. + * + * It's similar to #scan, but without returning the matched string. + * + * s = StringScanner.new('test string') + * p s.skip(/\w+/) # -> 4 + * p s.skip(/\w+/) # -> nil + * p s.skip(/\s+/) # -> 1 + * p s.skip("st") # -> 2 + * p s.skip(/\w+/) # -> 4 + * p s.skip(/./) # -> nil + * + */ +static VALUE +strscan_skip(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 1, 0, 1); +} + +/* + * call-seq: check(pattern) + * + * This returns the value that #scan would return, without advancing the scan + * pointer. The match register is affected, though. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.check /Fri/ # -> "Fri" + * s.pos # -> 0 + * s.matched # -> "Fri" + * s.check /12/ # -> nil + * s.matched # -> nil + * + * Mnemonic: it "checks" to see whether a #scan will return a value. + */ +static VALUE +strscan_check(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 0, 1, 1); +} + +/* + * call-seq: scan_full(pattern, advance_pointer_p, return_string_p) + * + * Tests whether the given +pattern+ is matched from the current scan pointer. + * Advances the scan pointer if +advance_pointer_p+ is true. + * Returns the matched string if +return_string_p+ is true. + * The match register is affected. + * + * "full" means "#scan with full parameters". + */ +static VALUE +strscan_scan_full(VALUE self, VALUE re, VALUE s, VALUE f) +{ + return strscan_do_scan(self, re, RTEST(s), RTEST(f), 1); +} + +/* + * call-seq: scan_until(pattern) + * + * Scans the string _until_ the +pattern+ is matched. Returns the substring up + * to and including the end of the match, advancing the scan pointer to that + * location. If there is no match, +nil+ is returned. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.scan_until(/1/) # -> "Fri Dec 1" + * s.pre_match # -> "Fri Dec " + * s.scan_until(/XYZ/) # -> nil + */ +static VALUE +strscan_scan_until(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 1, 1, 0); +} + +/* + * call-seq: exist?(pattern) + * + * Looks _ahead_ to see if the +pattern+ exists _anywhere_ in the string, + * without advancing the scan pointer. This predicates whether a #scan_until + * will return a value. + * + * s = StringScanner.new('test string') + * s.exist? /s/ # -> 3 + * s.scan /test/ # -> "test" + * s.exist? /s/ # -> 2 + * s.exist? /e/ # -> nil + */ +static VALUE +strscan_exist_p(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 0, 0, 0); +} + +/* + * call-seq: skip_until(pattern) + * + * Advances the scan pointer until +pattern+ is matched and consumed. Returns + * the number of bytes advanced, or +nil+ if no match was found. + * + * Look ahead to match +pattern+, and advance the scan pointer to the _end_ + * of the match. Return the number of characters advanced, or +nil+ if the + * match was unsuccessful. + * + * It's similar to #scan_until, but without returning the intervening string. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.skip_until /12/ # -> 10 + * s # + */ +static VALUE +strscan_skip_until(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 1, 0, 0); +} + +/* + * call-seq: check_until(pattern) + * + * This returns the value that #scan_until would return, without advancing the + * scan pointer. The match register is affected, though. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.check_until /12/ # -> "Fri Dec 12" + * s.pos # -> 0 + * s.matched # -> 12 + * + * Mnemonic: it "checks" to see whether a #scan_until will return a value. + */ +static VALUE +strscan_check_until(VALUE self, VALUE re) +{ + return strscan_do_scan(self, re, 0, 1, 0); +} + +/* + * call-seq: search_full(pattern, advance_pointer_p, return_string_p) + * + * Scans the string _until_ the +pattern+ is matched. + * Advances the scan pointer if +advance_pointer_p+, otherwise not. + * Returns the matched string if +return_string_p+ is true, otherwise + * returns the number of bytes advanced. + * This method does affect the match register. + */ +static VALUE +strscan_search_full(VALUE self, VALUE re, VALUE s, VALUE f) +{ + return strscan_do_scan(self, re, RTEST(s), RTEST(f), 0); +} + +static void +adjust_registers_to_matched(struct strscanner *p) +{ + onig_region_clear(&(p->regs)); + if (p->fixed_anchor_p) { + onig_region_set(&(p->regs), 0, (int)p->prev, (int)p->curr); + } + else { + onig_region_set(&(p->regs), 0, 0, (int)(p->curr - p->prev)); + } +} + +/* + * Scans one character and returns it. + * This method is multibyte character sensitive. + * + * s = StringScanner.new("ab") + * s.getch # => "a" + * s.getch # => "b" + * s.getch # => nil + * + * s = StringScanner.new("\244\242".force_encoding("euc-jp")) + * s.getch # => "\x{A4A2}" # Japanese hira-kana "A" in EUC-JP + * s.getch # => nil + */ +static VALUE +strscan_getch(VALUE self) +{ + struct strscanner *p; + long len; + + GET_SCANNER(self, p); + CLEAR_MATCH_STATUS(p); + if (EOS_P(p)) + return Qnil; + + len = rb_enc_mbclen(CURPTR(p), S_PEND(p), rb_enc_get(p->str)); + len = minl(len, S_RESTLEN(p)); + p->prev = p->curr; + p->curr += len; + MATCHED(p); + adjust_registers_to_matched(p); + return extract_range(p, + adjust_register_position(p, p->regs.beg[0]), + adjust_register_position(p, p->regs.end[0])); +} + +/* + * Scans one byte and returns it. + * This method is not multibyte character sensitive. + * See also: #getch. + * + * s = StringScanner.new('ab') + * s.get_byte # => "a" + * s.get_byte # => "b" + * s.get_byte # => nil + * + * s = StringScanner.new("\244\242".force_encoding("euc-jp")) + * s.get_byte # => "\xA4" + * s.get_byte # => "\xA2" + * s.get_byte # => nil + */ +static VALUE +strscan_get_byte(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + CLEAR_MATCH_STATUS(p); + if (EOS_P(p)) + return Qnil; + + p->prev = p->curr; + p->curr++; + MATCHED(p); + adjust_registers_to_matched(p); + return extract_range(p, + adjust_register_position(p, p->regs.beg[0]), + adjust_register_position(p, p->regs.end[0])); +} + +/* + * Equivalent to #get_byte. + * This method is obsolete; use #get_byte instead. + */ +static VALUE +strscan_getbyte(VALUE self) +{ + rb_warning("StringScanner#getbyte is obsolete; use #get_byte instead"); + return strscan_get_byte(self); +} + +/* + * call-seq: peek(len) + * + * Extracts a string corresponding to string[pos,len], without + * advancing the scan pointer. + * + * s = StringScanner.new('test string') + * s.peek(7) # => "test st" + * s.peek(7) # => "test st" + * + */ +static VALUE +strscan_peek(VALUE self, VALUE vlen) +{ + struct strscanner *p; + long len; + + GET_SCANNER(self, p); + + len = NUM2LONG(vlen); + if (EOS_P(p)) + return str_new(p, "", 0); + + len = minl(len, S_RESTLEN(p)); + return extract_beg_len(p, p->curr, len); +} + +/* + * Equivalent to #peek. + * This method is obsolete; use #peek instead. + */ +static VALUE +strscan_peep(VALUE self, VALUE vlen) +{ + rb_warning("StringScanner#peep is obsolete; use #peek instead"); + return strscan_peek(self, vlen); +} + +/* + * Sets the scan pointer to the previous position. Only one previous position is + * remembered, and it changes with each scanning operation. + * + * s = StringScanner.new('test string') + * s.scan(/\w+/) # => "test" + * s.unscan + * s.scan(/../) # => "te" + * s.scan(/\d/) # => nil + * s.unscan # ScanError: unscan failed: previous match record not exist + */ +static VALUE +strscan_unscan(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) + rb_raise(ScanError, "unscan failed: previous match record not exist"); + p->curr = p->prev; + CLEAR_MATCH_STATUS(p); + return self; +} + +/* + * Returns +true+ if and only if the scan pointer is at the beginning of the line. + * + * s = StringScanner.new("test\ntest\n") + * s.bol? # => true + * s.scan(/te/) + * s.bol? # => false + * s.scan(/st\n/) + * s.bol? # => true + * s.terminate + * s.bol? # => true + */ +static VALUE +strscan_bol_p(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (CURPTR(p) > S_PEND(p)) return Qnil; + if (p->curr == 0) return Qtrue; + return (*(CURPTR(p) - 1) == '\n') ? Qtrue : Qfalse; +} + +/* + * Returns +true+ if the scan pointer is at the end of the string. + * + * s = StringScanner.new('test string') + * p s.eos? # => false + * s.scan(/test/) + * p s.eos? # => false + * s.terminate + * p s.eos? # => true + */ +static VALUE +strscan_eos_p(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + return EOS_P(p) ? Qtrue : Qfalse; +} + +/* + * Equivalent to #eos?. + * This method is obsolete, use #eos? instead. + */ +static VALUE +strscan_empty_p(VALUE self) +{ + rb_warning("StringScanner#empty? is obsolete; use #eos? instead"); + return strscan_eos_p(self); +} + +/* + * Returns true if and only if there is more data in the string. See #eos?. + * This method is obsolete; use #eos? instead. + * + * s = StringScanner.new('test string') + * # These two are opposites + * s.eos? # => false + * s.rest? # => true + */ +static VALUE +strscan_rest_p(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + return EOS_P(p) ? Qfalse : Qtrue; +} + +/* + * Returns +true+ if and only if the last match was successful. + * + * s = StringScanner.new('test string') + * s.match?(/\w+/) # => 4 + * s.matched? # => true + * s.match?(/\d+/) # => nil + * s.matched? # => false + */ +static VALUE +strscan_matched_p(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + return MATCHED_P(p) ? Qtrue : Qfalse; +} + +/* + * Returns the last matched string. + * + * s = StringScanner.new('test string') + * s.match?(/\w+/) # -> 4 + * s.matched # -> "test" + */ +static VALUE +strscan_matched(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + return extract_range(p, + adjust_register_position(p, p->regs.beg[0]), + adjust_register_position(p, p->regs.end[0])); +} + +/* + * Returns the size of the most recent match in bytes, or +nil+ if there + * was no recent match. This is different than matched.size, + * which will return the size in characters. + * + * s = StringScanner.new('test string') + * s.check /\w+/ # -> "test" + * s.matched_size # -> 4 + * s.check /\d+/ # -> nil + * s.matched_size # -> nil + */ +static VALUE +strscan_matched_size(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + return LONG2NUM(p->regs.end[0] - p->regs.beg[0]); +} + +static int +name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end, rb_encoding *enc) +{ + int num; + + num = onig_name_to_backref_number(RREGEXP_PTR(regexp), + (const unsigned char* )name, (const unsigned char* )name_end, regs); + if (num >= 1) { + return num; + } + else { + rb_enc_raise(enc, rb_eIndexError, "undefined group name reference: %.*s", + rb_long2int(name_end - name), name); + } + + UNREACHABLE; +} + +/* + * call-seq: [](n) + * + * Returns the n-th subgroup in the most recent match. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " + * s[0] # -> "Fri Dec 12 " + * s[1] # -> "Fri" + * s[2] # -> "Dec" + * s[3] # -> "12" + * s.post_match # -> "1975 14:39" + * s.pre_match # -> "" + * + * s.reset + * s.scan(/(?\w+) (?\w+) (?\d+) /) # -> "Fri Dec 12 " + * s[0] # -> "Fri Dec 12 " + * s[1] # -> "Fri" + * s[2] # -> "Dec" + * s[3] # -> "12" + * s[:wday] # -> "Fri" + * s[:month] # -> "Dec" + * s[:day] # -> "12" + * s.post_match # -> "1975 14:39" + * s.pre_match # -> "" + */ +static VALUE +strscan_aref(VALUE self, VALUE idx) +{ + const char *name; + struct strscanner *p; + long i; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + + switch (TYPE(idx)) { + case T_SYMBOL: + idx = rb_sym2str(idx); + /* fall through */ + case T_STRING: + if (!RTEST(p->regex)) return Qnil; + RSTRING_GETMEM(idx, name, i); + i = name_to_backref_number(&(p->regs), p->regex, name, name + i, rb_enc_get(idx)); + break; + default: + i = NUM2LONG(idx); + } + + if (i < 0) + i += p->regs.num_regs; + if (i < 0) return Qnil; + if (i >= p->regs.num_regs) return Qnil; + if (p->regs.beg[i] == -1) return Qnil; + + return extract_range(p, + adjust_register_position(p, p->regs.beg[i]), + adjust_register_position(p, p->regs.end[i])); +} + +/* + * call-seq: size + * + * Returns the amount of subgroups in the most recent match. + * The full match counts as a subgroup. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " + * s.size # -> 4 + */ +static VALUE +strscan_size(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + return INT2FIX(p->regs.num_regs); +} + +/* + * call-seq: captures + * + * Returns the subgroups in the most recent match (not including the full match). + * If nothing was priorly matched, it returns nil. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.scan(/(\w+) (\w+) (\d+) (1980)?/) # -> "Fri Dec 12 " + * s.captures # -> ["Fri", "Dec", "12", nil] + * s.scan(/(\w+) (\w+) (\d+) (1980)?/) # -> nil + * s.captures # -> nil + */ +static VALUE +strscan_captures(VALUE self) +{ + struct strscanner *p; + int i, num_regs; + VALUE new_ary; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + + num_regs = p->regs.num_regs; + new_ary = rb_ary_new2(num_regs); + + for (i = 1; i < num_regs; i++) { + VALUE str; + if (p->regs.beg[i] == -1) + str = Qnil; + else + str = extract_range(p, + adjust_register_position(p, p->regs.beg[i]), + adjust_register_position(p, p->regs.end[i])); + rb_ary_push(new_ary, str); + } + + return new_ary; +} + +/* + * call-seq: + * scanner.values_at( i1, i2, ... iN ) -> an_array + * + * Returns the subgroups in the most recent match at the given indices. + * If nothing was priorly matched, it returns nil. + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " + * s.values_at 0, -1, 5, 2 # -> ["Fri Dec 12 ", "12", nil, "Dec"] + * s.scan(/(\w+) (\w+) (\d+) /) # -> nil + * s.values_at 0, -1, 5, 2 # -> nil + */ + +static VALUE +strscan_values_at(int argc, VALUE *argv, VALUE self) +{ + struct strscanner *p; + long i; + VALUE new_ary; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + + new_ary = rb_ary_new2(argc); + for (i = 0; ipre-match (in the regular expression sense) of the last scan. + * + * s = StringScanner.new('test string') + * s.scan(/\w+/) # -> "test" + * s.scan(/\s+/) # -> " " + * s.pre_match # -> "test" + * s.post_match # -> "string" + */ +static VALUE +strscan_pre_match(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + return extract_range(p, + 0, + adjust_register_position(p, p->regs.beg[0])); +} + +/* + * Returns the post-match (in the regular expression sense) of the last scan. + * + * s = StringScanner.new('test string') + * s.scan(/\w+/) # -> "test" + * s.scan(/\s+/) # -> " " + * s.pre_match # -> "test" + * s.post_match # -> "string" + */ +static VALUE +strscan_post_match(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (! MATCHED_P(p)) return Qnil; + return extract_range(p, + adjust_register_position(p, p->regs.end[0]), + S_LEN(p)); +} + +/* + * Returns the "rest" of the string (i.e. everything after the scan pointer). + * If there is no more data (eos? = true), it returns "". + */ +static VALUE +strscan_rest(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + if (EOS_P(p)) { + return str_new(p, "", 0); + } + return extract_range(p, p->curr, S_LEN(p)); +} + +/* + * s.rest_size is equivalent to s.rest.size. + */ +static VALUE +strscan_rest_size(VALUE self) +{ + struct strscanner *p; + long i; + + GET_SCANNER(self, p); + if (EOS_P(p)) { + return INT2FIX(0); + } + i = S_RESTLEN(p); + return INT2FIX(i); +} + +/* + * s.restsize is equivalent to s.rest_size. + * This method is obsolete; use #rest_size instead. + */ +static VALUE +strscan_restsize(VALUE self) +{ + rb_warning("StringScanner#restsize is obsolete; use #rest_size instead"); + return strscan_rest_size(self); +} + +#define INSPECT_LENGTH 5 + +/* + * Returns a string that represents the StringScanner object, showing: + * - the current position + * - the size of the string + * - the characters surrounding the scan pointer + * + * s = StringScanner.new("Fri Dec 12 1975 14:39") + * s.inspect # -> '#' + * s.scan_until /12/ # -> "Fri Dec 12" + * s.inspect # -> '#' + */ +static VALUE +strscan_inspect(VALUE self) +{ + struct strscanner *p; + VALUE a, b; + + p = check_strscan(self); + if (NIL_P(p->str)) { + a = rb_sprintf("#<%"PRIsVALUE" (uninitialized)>", rb_obj_class(self)); + return a; + } + if (EOS_P(p)) { + a = rb_sprintf("#<%"PRIsVALUE" fin>", rb_obj_class(self)); + return a; + } + if (p->curr == 0) { + b = inspect2(p); + a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld @ %"PRIsVALUE">", + rb_obj_class(self), + p->curr, S_LEN(p), + b); + return a; + } + a = inspect1(p); + b = inspect2(p); + a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld %"PRIsVALUE" @ %"PRIsVALUE">", + rb_obj_class(self), + p->curr, S_LEN(p), + a, b); + return a; +} + +static VALUE +inspect1(struct strscanner *p) +{ + VALUE str; + long len; + + if (p->curr == 0) return rb_str_new2(""); + if (p->curr > INSPECT_LENGTH) { + str = rb_str_new_cstr("..."); + len = INSPECT_LENGTH; + } + else { + str = rb_str_new(0, 0); + len = p->curr; + } + rb_str_cat(str, CURPTR(p) - len, len); + return rb_str_dump(str); +} + +static VALUE +inspect2(struct strscanner *p) +{ + VALUE str; + long len; + + if (EOS_P(p)) return rb_str_new2(""); + len = S_RESTLEN(p); + if (len > INSPECT_LENGTH) { + str = rb_str_new(CURPTR(p), INSPECT_LENGTH); + rb_str_cat2(str, "..."); + } + else { + str = rb_str_new(CURPTR(p), len); + } + return rb_str_dump(str); +} + +/* + * call-seq: + * scanner.fixed_anchor? -> true or false + * + * Whether +scanner+ uses fixed anchor mode or not. + * + * If fixed anchor mode is used, +\A+ always matches the beginning of + * the string. Otherwise, +\A+ always matches the current position. + */ +static VALUE +strscan_fixed_anchor_p(VALUE self) +{ + struct strscanner *p; + p = check_strscan(self); + return p->fixed_anchor_p ? Qtrue : Qfalse; +} + +typedef struct { + VALUE self; + VALUE captures; +} named_captures_data; + +static int +named_captures_iter(const OnigUChar *name, + const OnigUChar *name_end, + int back_num, + int *back_refs, + OnigRegex regex, + void *arg) +{ + named_captures_data *data = arg; + + VALUE key = rb_str_new((const char *)name, name_end - name); + VALUE value = RUBY_Qnil; + int i; + for (i = 0; i < back_num; i++) { + value = strscan_aref(data->self, INT2NUM(back_refs[i])); + } + rb_hash_aset(data->captures, key, value); + return 0; +} + +/* + * call-seq: + * scanner.named_captures -> hash + * + * Returns a hash of string variables matching the regular expression. + * + * scan = StringScanner.new('foobarbaz') + * scan.match?(/(?foo)(?bar)(?baz)/) + * scan.named_captures # -> {"f"=>"foo", "r"=>"bar", "z"=>"baz"} + */ +static VALUE +strscan_named_captures(VALUE self) +{ + struct strscanner *p; + GET_SCANNER(self, p); + named_captures_data data; + data.self = self; + data.captures = rb_hash_new(); + if (!RB_NIL_P(p->regex)) { + onig_foreach_name(RREGEXP_PTR(p->regex), named_captures_iter, &data); + } + + return data.captures; +} + +/* ======================================================================= + Ruby Interface + ======================================================================= */ + +/* + * Document-class: StringScanner + * + * StringScanner provides for lexical scanning operations on a String. Here is + * an example of its usage: + * + * require 'strscan' + * + * s = StringScanner.new('This is an example string') + * s.eos? # -> false + * + * p s.scan(/\w+/) # -> "This" + * p s.scan(/\w+/) # -> nil + * p s.scan(/\s+/) # -> " " + * p s.scan(/\s+/) # -> nil + * p s.scan(/\w+/) # -> "is" + * s.eos? # -> false + * + * p s.scan(/\s+/) # -> " " + * p s.scan(/\w+/) # -> "an" + * p s.scan(/\s+/) # -> " " + * p s.scan(/\w+/) # -> "example" + * p s.scan(/\s+/) # -> " " + * p s.scan(/\w+/) # -> "string" + * s.eos? # -> true + * + * p s.scan(/\s+/) # -> nil + * p s.scan(/\w+/) # -> nil + * + * Scanning a string means remembering the position of a scan pointer, + * which is just an index. The point of scanning is to move forward a bit at + * a time, so matches are sought after the scan pointer; usually immediately + * after it. + * + * Given the string "test string", here are the pertinent scan pointer + * positions: + * + * t e s t s t r i n g + * 0 1 2 ... 1 + * 0 + * + * When you #scan for a pattern (a regular expression), the match must occur + * at the character after the scan pointer. If you use #scan_until, then the + * match can occur anywhere after the scan pointer. In both cases, the scan + * pointer moves just beyond the last character of the match, ready to + * scan again from the next character onwards. This is demonstrated by the + * example above. + * + * == Method Categories + * + * There are other methods besides the plain scanners. You can look ahead in + * the string without actually scanning. You can access the most recent match. + * You can modify the string being scanned, reset or terminate the scanner, + * find out or change the position of the scan pointer, skip ahead, and so on. + * + * === Advancing the Scan Pointer + * + * - #getch + * - #get_byte + * - #scan + * - #scan_until + * - #skip + * - #skip_until + * + * === Looking Ahead + * + * - #check + * - #check_until + * - #exist? + * - #match? + * - #peek + * + * === Finding Where we Are + * + * - #beginning_of_line? (#bol?) + * - #eos? + * - #rest? + * - #rest_size + * - #pos + * + * === Setting Where we Are + * + * - #reset + * - #terminate + * - #pos= + * + * === Match Data + * + * - #matched + * - #matched? + * - #matched_size + * - #[] + * - #pre_match + * - #post_match + * + * === Miscellaneous + * + * - << + * - #concat + * - #string + * - #string= + * - #unscan + * + * There are aliases to several of the methods. + */ +void +Init_strscan(void) +{ +#ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); +#endif + +#undef rb_intern + ID id_scanerr = rb_intern("ScanError"); + VALUE tmp; + + id_byteslice = rb_intern("byteslice"); + + StringScanner = rb_define_class("StringScanner", rb_cObject); + ScanError = rb_define_class_under(StringScanner, "Error", rb_eStandardError); + if (!rb_const_defined(rb_cObject, id_scanerr)) { + rb_const_set(rb_cObject, id_scanerr, ScanError); + } + tmp = rb_str_new2(STRSCAN_VERSION); + rb_obj_freeze(tmp); + rb_const_set(StringScanner, rb_intern("Version"), tmp); + tmp = rb_str_new2("$Id$"); + rb_obj_freeze(tmp); + rb_const_set(StringScanner, rb_intern("Id"), tmp); + + rb_define_alloc_func(StringScanner, strscan_s_allocate); + rb_define_private_method(StringScanner, "initialize", strscan_initialize, -1); + rb_define_private_method(StringScanner, "initialize_copy", strscan_init_copy, 1); + rb_define_singleton_method(StringScanner, "must_C_version", strscan_s_mustc, 0); + rb_define_method(StringScanner, "reset", strscan_reset, 0); + rb_define_method(StringScanner, "terminate", strscan_terminate, 0); + rb_define_method(StringScanner, "clear", strscan_clear, 0); + rb_define_method(StringScanner, "string", strscan_get_string, 0); + rb_define_method(StringScanner, "string=", strscan_set_string, 1); + rb_define_method(StringScanner, "concat", strscan_concat, 1); + rb_define_method(StringScanner, "<<", strscan_concat, 1); + rb_define_method(StringScanner, "pos", strscan_get_pos, 0); + rb_define_method(StringScanner, "pos=", strscan_set_pos, 1); + rb_define_method(StringScanner, "charpos", strscan_get_charpos, 0); + rb_define_method(StringScanner, "pointer", strscan_get_pos, 0); + rb_define_method(StringScanner, "pointer=", strscan_set_pos, 1); + + rb_define_method(StringScanner, "scan", strscan_scan, 1); + rb_define_method(StringScanner, "skip", strscan_skip, 1); + rb_define_method(StringScanner, "match?", strscan_match_p, 1); + rb_define_method(StringScanner, "check", strscan_check, 1); + rb_define_method(StringScanner, "scan_full", strscan_scan_full, 3); + + rb_define_method(StringScanner, "scan_until", strscan_scan_until, 1); + rb_define_method(StringScanner, "skip_until", strscan_skip_until, 1); + rb_define_method(StringScanner, "exist?", strscan_exist_p, 1); + rb_define_method(StringScanner, "check_until", strscan_check_until, 1); + rb_define_method(StringScanner, "search_full", strscan_search_full, 3); + + rb_define_method(StringScanner, "getch", strscan_getch, 0); + rb_define_method(StringScanner, "get_byte", strscan_get_byte, 0); + rb_define_method(StringScanner, "getbyte", strscan_getbyte, 0); + rb_define_method(StringScanner, "peek", strscan_peek, 1); + rb_define_method(StringScanner, "peep", strscan_peep, 1); + + rb_define_method(StringScanner, "unscan", strscan_unscan, 0); + + rb_define_method(StringScanner, "beginning_of_line?", strscan_bol_p, 0); + rb_alias(StringScanner, rb_intern("bol?"), rb_intern("beginning_of_line?")); + rb_define_method(StringScanner, "eos?", strscan_eos_p, 0); + rb_define_method(StringScanner, "empty?", strscan_empty_p, 0); + rb_define_method(StringScanner, "rest?", strscan_rest_p, 0); + + rb_define_method(StringScanner, "matched?", strscan_matched_p, 0); + rb_define_method(StringScanner, "matched", strscan_matched, 0); + rb_define_method(StringScanner, "matched_size", strscan_matched_size, 0); + rb_define_method(StringScanner, "[]", strscan_aref, 1); + rb_define_method(StringScanner, "pre_match", strscan_pre_match, 0); + rb_define_method(StringScanner, "post_match", strscan_post_match, 0); + rb_define_method(StringScanner, "size", strscan_size, 0); + rb_define_method(StringScanner, "captures", strscan_captures, 0); + rb_define_method(StringScanner, "values_at", strscan_values_at, -1); + + rb_define_method(StringScanner, "rest", strscan_rest, 0); + rb_define_method(StringScanner, "rest_size", strscan_rest_size, 0); + rb_define_method(StringScanner, "restsize", strscan_restsize, 0); + + rb_define_method(StringScanner, "inspect", strscan_inspect, 0); + + rb_define_method(StringScanner, "fixed_anchor?", strscan_fixed_anchor_p, 0); + + rb_define_method(StringScanner, "named_captures", strscan_named_captures, 0); +} diff --git a/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/lib/strscan.so b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/lib/strscan.so new file mode 100755 index 0000000..23d5768 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/strscan-3.1.0/lib/strscan.so differ diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/.github/workflows/ci.yml b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/.github/workflows/ci.yml new file mode 100644 index 0000000..f3b8591 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI +on: [push] + +jobs: + test: + if: "!contains(github.event.head_commit.message, 'ci skip')" + + continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }} + + strategy: + fail-fast: false + + matrix: + os: [ubuntu] + ruby: [2.4, 2.5, 2.6, 2.7] + + runs-on: ${{ matrix.os }}-latest + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: ${{ matrix.ruby }} + + - run: bundle install + - run: bundle exec rspec diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/.gitignore b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/.gitignore new file mode 100644 index 0000000..b91d764 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/.gitignore @@ -0,0 +1,11 @@ +.DS_Store +pkg +tmp +*.cache +doc +vendor +/.bundle +Gemfile.lock + +# tempfiles +*~ diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Gemfile b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Gemfile new file mode 100644 index 0000000..735dba7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in test-gem.gemspec +gemspec + +gem 'tins', '~> 1.0.0' # Ruby 1.9 compat diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/History.rdoc b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/History.rdoc new file mode 100644 index 0000000..d01b923 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/History.rdoc @@ -0,0 +1,142 @@ +3.0.2 / 2021-09-19 +================== + +- fix align_column for nil values and colspan + +3.0.1 / 2021-05-10 +================== + +- Support for unicode-display_width 2.0 +- Fix issue where last row of an empty table changed format + +3.0.0 / 2020-01-27 +================== + +- Support for (optional) Unicode border styles on tables. In order to support decent looking Unicode borders, different types of intersections get different types of intersection characters. This has the side effect of subtle formatting differences even for the ASCII table border case due to removal of certain intersections near colspans. + +For example, previously the output of a table may be: + +------+-----+ + | Title | + +------+-----+ + | Char | Num | + +------+-----+ + | a | 1 | + | b | 2 | + | c | 3 | + +------+-----+ + +And now the `+` character above the word Title is removed, as it is no longer considered an intersection: + + +------------+ + | Title | + +------+-----+ + | Char | Num | + +------+-----+ + | a | 1 | + | b | 2 | + +------+-----+ + +- The default border remains an ASCII border for backwards compatibility, however multiple border classes are included / documented, and user defined border types can be applied as needed. + +In support of this update, the following issues were addressed: +- colspan creates conflict with colorize (#95) +- Use nice UTF box-drawing characters by default (#99) + - Note that `AsciiBorder` is stll the default +- Border-left and border-right style (#100) +- Helper function to style as Markdown (#111) + - Achieved using `MarkdownBorder` + +2.0.0 / 2020-10-28 +================== + +- Drops official support for Ruby 1.9.x with and of life on 2015-02-23 +- Drops official support for Ruby 2.0.x with and of life on 2016-02-24 +- Drops official support for Ruby 2.1.x with and of life on 2017-03-31 +- Drops official support for Ruby 2.2.x with and of life on 2018-03-31 +- Drops official support for Ruby 2.3.x with and of life on 2019-03-31 + +1.8.0 / 2017-05-16 +================== + +* Top and bottom borders can be disabled (@kubakrzempek, #83) +* `unicode-display-width` dependency relaxes (@mvz, #88) + +* Readme and docs fixes (@loualrid, #82 and @leoarnold, #86) +* Fixed some test-related warnings (@juanitofatas, #81 and @mvz, #89) + +1.7.3 / 2016-09-21 +================== + +* Fixed compatibility issues for Ruby 1.9, 2.0, 2.1. (@vivekbisen, #80) + +1.7.2 / 2016-09-09 +================== + +* Fix packing table to a minimal width (@vizv, #76) + +1.7.1 / 2016-08-29 +================== + +* Update `unicode-display_width` to fix behavior with signal traps [#78, @jrmhaig] + +1.7.0 / 2016-08-29 +================== + +All props to @vizv for this release! + + * Fixed some spec failures + * Added support for full-width characters (East Asian alphabets, etc) + +1.6.0 / 2016-06-06 +================== + + * Added table styles - margin_left, all_separators. + +1.4.3 / 2011-10-13 +================== + + * Optimize for faster table output. + +1.4.2 / 2010-01-14 +================== + + * Fixed some bugs with colspan + +=== 1.4.1 / 2009-12-18 + +* Fix column alignment with separators. + +=== 1.4.0 / 2009-12-18 + +* Can now add :seperator arbitrarily in a table [thanks splattael] +* Fix common typo: seperator -> separator [thanks splattael] + +=== 1.3.0 / 2009-10-16 + +* Major refactoring (functionality remains the same) + +=== 1.2.0 / 2009-08-06 + +* Added colspan support to table + +=== 1.1.0 / 2009-08-06 + +* Added colspan support to table + +=== 1.1.0 / 2009-07-13 + +* Added Table#== + +=== 1.0.5 / 2009-03-14 + +* Allowing nil to be passed to table for headings +* Revised doc to show that rows can be splatted now +* Misc refactoring + +=== 1.0.3 / 2009-01-15 + +* Moved yield or eval to Terminal::Table initialize where it belongs + +=== 1.0.0 / 2009-01-13 + +* Initial release diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/LICENSE.txt new file mode 100644 index 0000000..e888cec --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2008-2017 TJ Holowaychuk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Manifest b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Manifest new file mode 100644 index 0000000..3cc3140 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Manifest @@ -0,0 +1,27 @@ +Gemfile +History.rdoc +README.rdoc +Rakefile +Todo.rdoc +examples/examples.rb +lib/terminal-table.rb +lib/terminal-table/cell.rb +lib/terminal-table/import.rb +lib/terminal-table/row.rb +lib/terminal-table/separator.rb +lib/terminal-table/style.rb +lib/terminal-table/table.rb +lib/terminal-table/table_helper.rb +lib/terminal-table/version.rb +spec/cell_spec.rb +spec/row_spec.rb +spec/spec_helper.rb +spec/table_helper_spec.rb +spec/table_spec.rb +tasks/docs.rake +tasks/gemspec.rake +tasks/spec.rake +terminal-table.gemspec +terminal-table.sublime-project +terminal-table.sublime-workspace +Manifest diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/README.md b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/README.md new file mode 100644 index 0000000..5f0ecc9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/README.md @@ -0,0 +1,417 @@ +[![CI status](https://github.com/tj/terminal-table/workflows/CI/badge.svg)](https://github.com/tj/terminal-table/actions) +[![Gem Version](https://badge.fury.io/rb/terminal-table.svg)](https://badge.fury.io/rb/terminal-table) + +# Terminal Table + +## Description + +Terminal Table is a fast and simple, yet feature rich table generator +written in Ruby. It supports ASCII and Unicode formatted tables. + +## Installation + +``` +$ gem install terminal-table +``` +## Usage + +### Basics + +To use Terminal Table: + +```ruby +require 'terminal-table' +``` +To generate a table, provide an array of arrays (which are interpreted as +rows): + +```ruby +rows = [] +rows << ['One', 1] +rows << ['Two', 2] +rows << ['Three', 3] +table = Terminal::Table.new :rows => rows + +# > puts table +# +# +-------+---+ +# | One | 1 | +# | Two | 2 | +# | Three | 3 | +# +-------+---+ +``` +The constructor can also be given a block which is either yielded the Table +object or instance evaluated: + +```ruby +table = Terminal::Table.new do |t| + t.rows = rows +end + +table = Terminal::Table.new do + self.rows = rows +end +``` +Adding rows one by one: + +```ruby +table = Terminal::Table.new do |t| + t << ['One', 1] + t.add_row ['Two', 2] +end +``` +To add separators between rows: + +```ruby +table = Terminal::Table.new do |t| + t << ['One', 1] # Using << (push) as an alias for add_row + t << :separator # Using << with :separator as an alias for add_separator + t.add_row ['Two', 2] + t.add_separator # Note - this version allows setting the separator's border_type + t.add_row ['Three', 3] +end + +# > puts table +# +# +-------+---+ +# | One | 1 | +# +-------+---+ +# | Two | 2 | +# +-------+---+ +# | Three | 3 | +# +-------+---+ +``` +Cells can handle multiline content: + +```ruby +table = Terminal::Table.new do |t| + t << ['One', 1] + t << :separator + t.add_row ["Two\nDouble", 2] + t.add_separator + t.add_row ['Three', 3] +end + +# > puts table +# +# +--------+---+ +# | One | 1 | +# +--------+---+ +# | Two | 2 | +# | Double | | +# +--------+---+ +# | Three | 3 | +# +--------+---+ +``` +### Head + +To add a head to the table: + +```ruby +table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows + +# > puts table +# +# +-------+--------+ +# | Word | Number | +# +-------+--------+ +# | One | 1 | +# | Two | 2 | +# | Three | 3 | +# +-------+--------+ +``` +### Title + +To add a title to the table: + +```ruby +table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows + +# > puts table +# +# +---------------------+ +# | Cheatsheet | +# +------------+--------+ +# | Word | Number | +# +------------+--------+ +# | One | 1 | +# | Two | 2 | +# | Three | 3 | +# +------------+--------+ +``` +### Alignment + +To align the second column to the right: + +```ruby +table.align_column(1, :right) + +# > puts table +# +# +-------+--------+ +# | Word | Number | +# +-------+--------+ +# | One | 1 | +# | Two | 2 | +# | Three | 3 | +# +-------+--------+ +``` +To align an individual cell, you specify the cell value in a hash along the +alignment: + +```ruby +table << ["Four", {:value => 4.0, :alignment => :center}] + +# > puts table +# +# +-------+--------+ +# | Word | Number | +# +-------+--------+ +# | One | 1 | +# | Two | 2 | +# | Three | 3 | +# | Four | 4.0 | +# +-------+--------+ +``` +### Style + +To specify style options: + +```ruby +table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80} + +# > puts table +# +# +--------------------------------------+---------------------------------------+ +# | Word | Number | +# +--------------------------------------+---------------------------------------+ +# | One | 1 | +# | Two | 2 | +# | Three | 3 | +# +--------------------------------------+---------------------------------------+ +``` +And change styles on the fly: + +```ruby +table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"} + +# > puts table +# +# x======================================x +# | Cheatsheet | +# x====================x=================x +# | Word | Number | +# x====================x=================x +# | One | 1 | +# | Two | 2 | +# | Three | 3 | +# x====================x=================x +``` +You can also use styles to add a separator after every row: + +```ruby +table = Terminal::Table.new do |t| + t.add_row [1, 'One'] + t.add_row [2, 'Two'] + t.add_row [3, 'Three'] + t.style = {:all_separators => true} +end + +# > puts table +# +# +---+-------+ +# | 1 | One | +# +---+-------+ +# | 2 | Two | +# +---+-------+ +# | 3 | Three | +# +---+-------+ +``` +You can also use styles to disable top and bottom borders of the table. + +```ruby +table = Terminal::Table.new do |t| + t.headings = ['id', 'name'] + t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']] + t.style = { :border_top => false, :border_bottom => false } +end + +# > puts table +# | id | name | +# +----+-------+ +# | 1 | One | +# | 2 | Two | +# | 3 | Three | +``` + +And also to disable left and right borders of the table. + +```ruby +table = Terminal::Table.new do |t| + t.headings = ['id', 'name'] + t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']] + t.style = { :border_left => false, :border_right => false } +end + +# > puts table +# ----+------- +# id | name +# ----+------- +# 1 | One +# 2 | Two +# 3 | Three +# ----+------- +``` + +To change the default style options: + +```ruby +Terminal::Table::Style.defaults = {:width => 80} +``` +All Table objects created afterwards will inherit these defaults. + +### Constructor options and setter methods + +Valid options for the constructor are `:rows`, `:headings`, `:style` and `:title` - +and all options can also be set on the created table object by their setter +method: + +```ruby +table = Terminal::Table.new +table.title = "Cheatsheet" +table.headings = ['Word', 'Number'] +table.rows = rows +table.style = {:width => 40} +``` + +## New Formatting + +### Unicode Table Borders +Support for Unicode 'box art' borders presented a challenge, as the original terminal-table only handled three border types: horizontal (x), vertical (y), and intersection (i). For proper box-art, it became necessary to enable different types of corners/edges for multiple intersection types. + +For the sake of backward compatiblity, the previous interface is still supported, as this gem has been around a long time and making breaking changes would have been inconvenient. The new interface is required for any complex and/or Unicode style bordering. A few variations on border style are supported via some new classes and creation of additional classes (or modification of characters used in existing ones) will allow for customized border types. + +The simplest way to use an alternate border is one of the following: +``` +table.style = { :border => :unicode } +table.style = { :border => :unicode_round } +table.style = { :border => :unicode_thick_edge } +``` + +These are a convenience wrapper around setting border using an instance of a class that inherits from Table::Terminal::Border +``` +table.style = { :border => Terminal::Table::UnicodeBorder.new() } +table.style = { :border => Terminal::Table::UnicodeRoundBorder.new() } +table.style = { :border => Terminal::Table::UnicodeThickEdgeBorder.new() } +``` + +If you define a custom class and wish to use the symbol shortcut, you must namespace within `Terminal::Table` and end your class name with `Border`. + +### Markdown Compatiblity +Per popular request, Markdown formatted tables can be generated by using the following border style: + +``` +table.style = { :border => :markdown } +``` + +### Ascii Borders +Ascii borders are default, but can be explicitly set with: +``` +table.style = { :border => :ascii } +``` + +### Customizing Borders +Inside the `UnicodeBorder` class, there are definitions for a variety of corner/intersection and divider types. + +```ruby +@data = { + nil => nil, + nw: "┌", nx: "─", n: "┬", ne: "┐", + yw: "│", y: "│", ye: "│", + aw: "╞", ax: "═", ai: "╪", ae: "╡", ad: '╤', au: "╧", # double + bw: "┝", bx: "━", bi: "┿", be: "┥", bd: '┯', bu: "┷", # heavy/bold/thick + w: "├", x: "─", i: "┼", e: "┤", dn: "┬", up: "┴", # normal div + sw: "└", sx: "─", s: "┴", se: "┘", + # alternative dots/dashes + x_dot4: '┈', x_dot3: '┄', x_dash: '╌', + bx_dot4: '┉', bx_dot3: '┅', bx_dash: '╍', +} +``` + +Note that many are defined as directional (:nw == north-west), others defined in terms of 'x' or 'y'. +The border that separates headings (below each heading) is of type `:double` and is defined with `a*` entries. +Alternate `:heavy` types that can be applied to separators can be defined with `b*` entries. + +When defining a new set of borders, it's probably easiest to define a new class that inherits from UnicodeBorder and replaces the `@data` Hash. +However, these elements can be these can be overridden by poking setting the Hash, should the need arise: + +``` +table.style = {border: :unicode} +table.style.border[:nw] = '*' # Override the north-west corner of the table +``` + +### Customizing row separators + +Row-separators can now be customized in a variety of ways. The default separator's border_type is referred to as `:div`. Additional separator border types (e.g. `:double`, `:heavy`, `:dash` - see full list below) can be applied to separate the sections (e.g. header/footer/title). + +The separator's `border_type` may be specified when a user-defined separator is added. Alternatively, borders may be adjusted after the table's rows are elaborated, but before the table is rendered. + +Separator `border_type`s can be adjusted to be heavy, use double-lines, and different dash/dot styles. The border type should be one of: + + div dash dot3 dot4 + thick thick_dash thick_dot3 thick_dot4 + heavy heavy_dash heavy_dot3 heavy_dot4 + bold bold_dash bold_dot3 bold_dot4 + double + +To manually set the separator border_type, the `add_separator` method may be called. +```ruby +add_separator(border_type: :heavy_dash) +``` + +Alternatively, if `style: :all_separators` is used at the table level, it may be necessary to elaborate the implicit Separator rows prior to rendering. +```ruby +table = Terminal::Table.new do |t| + t.add_row [1, 'One'] + t.add_row [2, 'Two'] + t.add_row [3, 'Three'] + t.style = {:all_separators => true} +end +rows = table.elaborate_rows +rows[2].border_type = :heavy # modify separator row: emphasize below title +puts table.render +``` + +## Example: Displaying a small CSV spreadsheet + +This example code demonstrates using Terminal-table and CSV to display a small spreadsheet. + +```ruby +#!/usr/bin/env ruby +require "csv" +require "terminal-table" +use_stdin = ARGV[0].nil? || (ARGV[0] == '-') +io_object = use_stdin ? $stdin : File.open(ARGV[0], 'r') +csv = CSV.new(io_object) +csv_array = csv.to_a +user_table = Terminal::Table.new do |v| + v.style = { :border => :unicode_round } # >= v3.0.0 + v.title = "Some Title" + v.headings = csv_array[0] + v.rows = csv_array[1..-1] +end +puts user_table +``` + +See also `examples/show_csv_table.rb` in the source distribution. + +## More examples + +For more examples, please see the `examples` directory included in the +source distribution. + +## Author + +TJ Holowaychuk + +Unicode table support by Ben Bowers https://github.com/nanobowers diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Rakefile b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Rakefile new file mode 100644 index 0000000..609f869 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Rakefile @@ -0,0 +1,15 @@ +require 'bundler' +Bundler.setup +Bundler::GemHelper.install_tasks + +require 'rake' +require 'rspec/core/rake_task' + +desc "Run all examples" +RSpec::Core::RakeTask.new(:spec) do |t| + t.ruby_opts = %w[-w] + t.rspec_opts = %w[--color] +end + +desc "Default: Run specs" +task :default => [:spec] diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Todo.rdoc b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Todo.rdoc new file mode 100644 index 0000000..071b202 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/Todo.rdoc @@ -0,0 +1,14 @@ + +== Major: + +* Nothing + +== Minor: + +* Programmatically add separator rows +* Add multi-column sorting +* Change; pre-create Cell and Heading objects to clean up Table a bit + +== Brainstorming: + +* Nothing \ No newline at end of file diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/data.csv b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/data.csv new file mode 100644 index 0000000..2af8d47 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/data.csv @@ -0,0 +1,4 @@ +First Name,Last Name,Email +TJ,Holowaychuk,tj@vision-media.ca +Bob,Someone,bob@vision-media.ca +Joe,Whatever,joe@vision-media.ca diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/examples.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/examples.rb new file mode 100755 index 0000000..ebf6893 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/examples.rb @@ -0,0 +1,83 @@ +$:.unshift File.dirname(__FILE__) + '/../lib' +require 'terminal-table/import' + +puts +puts table(['a', 'b'], [1, 2], [3, 4]) + +puts +puts table(['name', 'content'], ['ftp.example.com', '1.1.1.1'], ['www.example.com', '|lalalala|lalala|']) + +puts +t = table ['a', 'b'] +t.style = {:padding_left => 2, :width => 80} +t << [1, 2] +t << [3, 4] +t << :separator +t << [4, 6] +puts t + +puts +user_table = table do |v| + v.title = "Contact Information" + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do |v| + v.style.width = 80 + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do + self.headings = 'First Name', 'Last Name', 'Email' + add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca'] + add_row ['Bob', 'Someone', 'bob@vision-media.ca'] + add_row ['Joe', 'Whatever', 'joe@vision-media.ca'] + add_separator + add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }] + align_column 1, :center +end +puts user_table + +puts +user_table = table do + self.headings = ['First Name', 'Last Name', {:value => 'Phones', :colspan => 2, :alignment => :center}] + add_row ['Bob', 'Someone', '123', '456'] + add_row :separator + add_row ['TJ', 'Holowaychuk', {:value => "No phones\navaiable", :colspan => 2, :alignment => :center}] + add_row :separator + add_row ['Joe', 'Whatever', '4324', '343242'] +end +puts user_table + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table([nil, 'Lines'], *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table(nil, *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +table = table([{ :value => 'Stats', :colspan => 2, :alignment => :center }], *rows) +table.align_column 1, :right +puts table diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/examples_unicode.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/examples_unicode.rb new file mode 100755 index 0000000..56717e3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/examples_unicode.rb @@ -0,0 +1,89 @@ +#!/usr/bin/env ruby + +$:.unshift File.dirname(__FILE__) + '/../lib' +require 'terminal-table/import' + +Terminal::Table::Style.defaults = { :border => :unicode_round } +# Terminal::Table::UnicodeThickEdgeBorder.new() + +puts +puts table(['a', 'b'], [1, 2], [3, 4]) + +puts +puts table(['name', 'content'], ['ftp.example.com', '1.1.1.1'], ['www.example.com', '|lalalala|lalala|']) + +puts +t = table ['a', 'b'] +t.style = {:padding_left => 2, :width => 80} +t << [1, 2] +t << [3, 4] +t << :separator +t << [4, 6] +puts t + +puts +user_table = table do |v| + v.title = "Contact Information" + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do |v| + v.style.width = 80 + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do + self.headings = 'First Name', 'Last Name', 'Email' + add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca'] + add_row ['Bob', 'Someone', 'bob@vision-media.ca'] + add_row ['Joe', 'Whatever', 'joe@vision-media.ca'] + add_separator + add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }] + align_column 1, :center +end +puts user_table + +puts +user_table = table do + self.headings = ['First Name', 'Last Name', {:value => 'Phones', :colspan => 2, :alignment => :center}] + #add_row ['Bob', 'Someone', '123', '456'] + add_row [{:value => "Bob Someone", :colspan => 3, :alignment => :center}, '123456'] + add_row :separator + add_row ['TJ', 'Holowaychuk', {:value => "No phones\navaiable", :colspan => 2, :alignment => :center}] + add_row :separator + add_row ['Joe', 'Whatever', '4324', '343242'] +end +puts user_table + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table([nil, 'Lines'], *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table(nil, *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +table = table([{ :value => 'Stats', :colspan => 2, :alignment => :center }], *rows) +table.align_column 1, :right +puts table diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue100.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue100.rb new file mode 100755 index 0000000..41527be --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue100.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +# Methods to suppress left/right borders using border_left & border_right + +require_relative "../lib/terminal-table" +table = Terminal::Table.new do |t| + t.headings = ['id', 'name'] + t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']] + t.style = { :border_left => false, :border_top => false, :border_bottom => false } +end + +puts table +puts + +# no right +table.style = {:border_right => false } +puts table +puts + +# no right +table.style = {:border_left => true } +puts table +puts + +table.style.border = Terminal::Table::UnicodeBorder.new +puts table + + +table.style = {:border_right => false, :border_left => true } +puts table + +table.style = {:border_right => true, :border_left => false } +puts table + diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue111.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue111.rb new file mode 100755 index 0000000..a7a6c71 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue111.rb @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../lib/terminal-table" +puts Terminal::Table.new(headings: ['heading A', 'heading B'], rows: [['a', 'b'], ['a', 'b']], style: {border: Terminal::Table::MarkdownBorder.new}) + diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue118.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue118.rb new file mode 100755 index 0000000..e94eb71 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue118.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +require_relative '../lib/terminal-table' + +puts Terminal::Table.new(headings: ['a', 'b', 'c', 'd'], style: { border: :unicode }) + +puts + +tbl = Terminal::Table.new do |t| + t.style = { border: :unicode } + t.add_separator + t.add_separator + t.add_row ['x','y','z'] + t.add_separator + t.add_separator +end +puts tbl + +puts + +puts Terminal::Table.new(headings: [['a', 'b', 'c', 'd'], ['cat','dog','frog','mouse']], style: { border: :unicode }) + +puts + +puts Terminal::Table.new(headings: ['a', 'b', 'c', 'd']) + +puts + +tbl = Terminal::Table.new do |t| + t.add_separator + t.add_separator + t.add_row ['x','y','z'] + t.add_separator + t.add_separator +end +puts tbl diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue95.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue95.rb new file mode 100755 index 0000000..e6ddbf8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/issue95.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +require 'colorize' +require_relative '../lib/terminal-table.rb' + +original_sample_data = [ +["Sep 2016", 33, [-38, -53.52], 46, [-25, -35.21]], +["Oct 2016", 35, [2, 6.06], 50, [4, 8.69]] +] + +table = Terminal::Table.new headings: ["Month".cyan,"Monthly IT".cyan,"IT Difference OPM".cyan, +"Monthly OOT".cyan,"OOT Difference OPM".cyan], rows: original_sample_data + +table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".blue, border_i: "+".blue } + +puts table + +puts "" +puts "^ good table" +puts "v wonky table" +puts "" + +split_column_sample_data = [ +["Sep 2016", 33, -38, -53.52, 46, -25, -35.21], +["Oct 2016", 35, 2, 6.06, 50, 4, 8.69] +] + +table = Terminal::Table.new headings: ["Month".cyan,"Monthly IT".cyan, +{value: "IT Difference OPM".cyan, colspan: 2}, "Monthly OOT".cyan, +{value: "OOT Difference OPM".cyan, colspan: 2}], rows: split_column_sample_data + +table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".blue, border_i: "+".blue } + +puts table + + +table = Terminal::Table.new headings: ["Month","Monthly IT", +{value: "IT Difference OPM", colspan: 2}, "Monthly OOT", +{value: "OOT Difference OPM", colspan: 2}], rows: split_column_sample_data + +table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".cyan, border_i: "+" } + +puts table diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/show_csv_table.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/show_csv_table.rb new file mode 100755 index 0000000..1bb368a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/show_csv_table.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +require "csv" +$LOAD_PATH << "#{__dir__}/../lib" +require "terminal-table" + +# +# Usage: +# ./show_csv_table.rb data.csv +# cat data.csv | ./show_csv_table.rb +# cat data.csv | ./show_csv_table.rb - +# +# +# Reads a CSV from $stdin if no argument given, or argument is '-' +# otherwise interprets first cmdline argument as the CSV filename +# +use_stdin = ARGV[0].nil? || (ARGV[0] == '-') +io_object = use_stdin ? $stdin : File.open(ARGV[0], 'r') +csv = CSV.new(io_object) + +# +# Convert to an array for use w/ terminal-table +# The assumption is that this is a pretty small spreadsheet. +# +csv_array = csv.to_a + +user_table = Terminal::Table.new do |v| + v.style = { :border => :unicode_round } # >= v3.0.0 + v.title = "Some Title" + v.headings = csv_array[0] + v.rows = csv_array[1..-1] +end + +puts user_table diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/strong_separator.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/strong_separator.rb new file mode 100755 index 0000000..52ad195 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/examples/strong_separator.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +require_relative "../lib/terminal-table" + +# +# An example of how to manually add separators with non-default +# border_type to enable a footer row. +# +table = Terminal::Table.new do |t| + # set the style + t.style = { border: :unicode_thick_edge } + + # header row + t.headings = ['fruit', 'count'] + + # some row data + t.add_row ['apples', 7] + t.add_row ['bananas', 19] + t.add_separator border_type: :strong + # footer row + t.add_row ['total', 26] +end + +puts table.render diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table.rb new file mode 100644 index 0000000..ebea259 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table.rb @@ -0,0 +1,26 @@ +#-- +# Copyright (c) 2008-2009 TJ Holowaychuk +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + +%w(cell row separator style table table_helper util version).each do |file| + require_relative "./terminal-table/#{file}" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/cell.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/cell.rb new file mode 100644 index 0000000..0ec261d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/cell.rb @@ -0,0 +1,94 @@ +require 'unicode/display_width' + +module Terminal + class Table + class Cell + ## + # Cell value. + + attr_reader :value + + ## + # Column span. + + attr_reader :colspan + + ## + # Initialize with _options_. + + def initialize options = nil + @value, options = options, {} unless Hash === options + @value = options.fetch :value, value + @alignment = options.fetch :alignment, nil + @colspan = options.fetch :colspan, 1 + @width = options.fetch :width, @value.to_s.size + @index = options.fetch :index + @table = options.fetch :table + end + + def alignment? + !@alignment.nil? + end + + def alignment + @alignment || @table.style.alignment || :left + end + + def alignment=(val) + supported = %w(left center right) + if supported.include?(val.to_s) + @alignment = val + else + raise "Aligment must be one of: #{supported.join(' ')}" + end + end + + def align(val, position, length) + positions = { :left => :ljust, :right => :rjust, :center => :center } + val.public_send(positions[position], length) + end + def lines + @value.to_s.split(/\n/) + end + + ## + # Render the cell. + + def render(line = 0) + left = " " * @table.style.padding_left + right = " " * @table.style.padding_right + display_width = Unicode::DisplayWidth.of(Util::ansi_escape(lines[line])) + render_width = lines[line].to_s.size - display_width + width + align("#{left}#{lines[line]}#{right}", alignment, render_width + @table.cell_padding) + end + alias :to_s :render + + ## + # Returns the longest line in the cell and + # removes all ANSI escape sequences (e.g. color) + + def value_for_column_width_recalc + lines.map{ |s| Util::ansi_escape(s) }.max_by{ |s| Unicode::DisplayWidth.of(s) } + end + + ## + # Returns the width of this cell + + def width + padding = (colspan - 1) * @table.cell_spacing + inner_width = (1..@colspan).to_a.inject(0) do |w, counter| + w + @table.column_width(@index + counter - 1) + end + inner_width + padding + end + + def inspect + fields = %i[alignment colspan index value width].map do |name| + val = self.instance_variable_get('@'+name.to_s) + "@#{name}=#{val.inspect}" + end.join(', ') + return "#<#{self.class} #{fields}>" + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/import.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/import.rb new file mode 100644 index 0000000..33b2791 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/import.rb @@ -0,0 +1,3 @@ +require 'terminal-table' #required as some people require this file directly from their Gemfiles + +include Terminal::Table::TableHelper diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/row.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/row.rb new file mode 100644 index 0000000..a549008 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/row.rb @@ -0,0 +1,66 @@ +module Terminal + class Table + class Row + + ## + # Row cells + + attr_reader :cells + + attr_reader :table + + ## + # Initialize with _width_ and _options_. + + def initialize table, array = [], **_kwargs + @cell_index = 0 + @table = table + @cells = [] + array.each { |item| self << item } + end + + def add_cell item + options = item.is_a?(Hash) ? item : {:value => item} + cell = Cell.new(options.merge(:index => @cell_index, :table => @table)) + @cell_index += cell.colspan + @cells << cell + end + alias << add_cell + + def [] index + cells[index] + end + + def height + cells.map { |c| c.lines.count }.max || 0 + end + + def render + vleft, vcenter, vright = @table.style.vertical + (0...height).to_a.map do |line| + vleft + cells.map do |cell| + cell.render(line) + end.join(vcenter) + vright + end.join("\n") + end + + def number_of_columns + @cells.collect(&:colspan).inject(0, &:+) + end + + # used to find indices where we have table '+' crossings. + # in cases where the colspan > 1, then we will skip over some numbers + # if colspan is always 1, then the list should be incrementing by 1. + # + # skip 0 entry, because it's the left side. + # skip last entry, because it's the right side. + # we only care about "+/T" style crossings. + def crossings + idx = 0 + @cells[0...-1].map { |c| idx += c.colspan } + end + + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/separator.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/separator.rb new file mode 100644 index 0000000..0413925 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/separator.rb @@ -0,0 +1,66 @@ +module Terminal + class Table + class Separator < Row + + ## + # `prevrow`, `nextrow` contain references to adjacent rows. + # + # `border_type` is a symbol used to control which type of border is used + # on the separator (:top for top-edge, :bot for bottom-edge, + # :div for interior, and :strong for emphasized-interior) + # + # `implicit` is false for user-added separators, and true for + # implicit/auto-generated separators. + + def initialize(*args, border_type: :div, implicit: false) + super + @prevrow, @nextrow = nil, nil + @border_type = border_type + @implicit = implicit + end + + attr_accessor :border_type + attr_reader :implicit + + def render + left_edge, ctrflat, ctrud, right_edge, ctrdn, ctrup = @table.style.horizontal(border_type) + + prev_crossings = @prevrow.respond_to?(:crossings) ? @prevrow.crossings : [] + next_crossings = @nextrow.respond_to?(:crossings) ? @nextrow.crossings : [] + rval = [left_edge] + numcols = @table.number_of_columns + (0...numcols).each do |idx| + rval << ctrflat * (@table.column_width(idx) + @table.cell_padding) + pcinc = prev_crossings.include?(idx+1) + ncinc = next_crossings.include?(idx+1) + border_center = if pcinc && ncinc + ctrud + elsif pcinc + ctrup + elsif ncinc + ctrdn + elsif !ctrud.empty? + # special case if the center-up-down intersection is empty + # which happens when verticals/intersections are removed. in that case + # we do not want to replace with a flat element so return empty-string in else block + ctrflat + else + '' + end + rval << border_center if idx < numcols-1 + end + + rval << right_edge + rval.join + end + + # Save off neighboring rows, so that we can use them later in determining + # which types of table edges to use. + def save_adjacent_rows(prevrow, nextrow) + @prevrow = prevrow + @nextrow = nextrow + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/style.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/style.rb new file mode 100644 index 0000000..dc89737 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/style.rb @@ -0,0 +1,284 @@ +# coding: utf-8 +require 'forwardable' + +module Terminal + class Table + + class Border + + attr_accessor :data, :top, :bottom, :left, :right + def initialize + @top, @bottom, @left, @right = true, true, true, true + end + def []=(key, val) + @data[key] = val + end + def [](key) + @data[key] + end + def initialize_dup(other) + super + @data = other.data.dup + end + def remove_verticals + self.class.const_get("VERTICALS").each { |key| @data[key] = "" } + self.class.const_get("INTERSECTIONS").each { |key| @data[key] = "" } + end + def remove_horizontals + self.class.const_get("HORIZONTALS").each { |key| @data[key] = "" } + end + + # If @left, return the edge else empty-string. + def maybeleft(key) ; @left ? @data[key] : '' ; end + + # If @right, return the edge else empty-string. + def mayberight(key) ; @right ? @data[key] : '' ; end + + end + + class AsciiBorder < Border + HORIZONTALS = %i[x] + VERTICALS = %i[y] + INTERSECTIONS = %i[i] + + def initialize + super + @data = { x: "-", y: "|", i: "+" } + end + + # Get vertical border elements + # @return [Array] 3-element list of [left, center, right] + def vertical + [maybeleft(:y), @data[:y], mayberight(:y)] # left, center, right + end + + # Get horizontal border elements + # @return [Array] a 6 element list of: [i-left, horizontal-bar, i-up/down, i-right, i-down, i-up] + def horizontal(_type) + x, i = @data[:x], @data[:i] + [maybeleft(:i), x, i, mayberight(:i), i, i] + end + end + + class MarkdownBorder < AsciiBorder + def initialize + super + @top, @bottom = false, false + @data = { x: "-", y: "|", i: "|" } + end + end + + class UnicodeBorder < Border + + ALLOWED_SEPARATOR_BORDER_STYLES = %i[ + top bot + div dash dot3 dot4 + thick thick_dash thick_dot3 thick_dot4 + heavy heavy_dash heavy_dot3 heavy_dot4 + bold bold_dash bold_dot3 bold_dot4 + double + ] + + HORIZONTALS = %i[x sx ax bx nx bx_dot3 bx_dot4 bx_dash x_dot3 x_dot4 x_dash] + VERTICALS = %i[y yw ye] + INTERSECTIONS = %i[nw n ne nd + aw ai ae ad au + bw bi be bd bu + w i e dn up + sw s se su] + def initialize + super + @data = { + nil => nil, + nw: "┌", nx: "─", n: "┬", ne: "┐", + yw: "│", y: "│", ye: "│", + aw: "╞", ax: "═", ai: "╪", ae: "╡", ad: '╤', au: "╧", # double + bw: "┝", bx: "━", bi: "┿", be: "┥", bd: '┯', bu: "┷", # heavy/bold/thick + w: "├", x: "─", i: "┼", e: "┤", dn: "┬", up: "┴", # normal div + sw: "└", sx: "─", s: "┴", se: "┘", + # alternative dots/dashes + x_dot4: '┈', x_dot3: '┄', x_dash: '╌', + bx_dot4: '┉', bx_dot3: '┅', bx_dash: '╍', + } + end + # Get vertical border elements + # @return [Array] 3-element list of [left, center, right] + def vertical + [maybeleft(:yw), @data[:y], mayberight(:ye)] + end + + # Get horizontal border elements + # @return [Array] a 6 element list of: [i-left, horizontal-bar, i-up/down, i-right, i-down, i-up] + def horizontal(type) + raise ArgumentError, "Border type is #{type.inspect}, must be one of #{ALLOWED_SEPARATOR_BORDER_STYLES.inspect}" unless ALLOWED_SEPARATOR_BORDER_STYLES.include?(type) + lookup = case type + when :top + [:nw, :nx, :n, :ne, :n, nil] + when :bot + [:sw, :sx, :s, :se, nil, :s] + when :double + # typically used for the separator below the heading row or above a footer row) + [:aw, :ax, :ai, :ae, :ad, :au] + when :thick, :thick_dash, :thick_dot3, :thick_dot4, + :heavy, :heavy_dash, :heavy_dot3, :heavy_dot4, + :bold, :bold_dash, :bold_dot3, :bold_dot4 + # alternate thick/bold border + xref = type.to_s.sub(/^(thick|heavy|bold)/,'bx').to_sym + [:bw, xref, :bi, :be, :bd, :bu] + when :dash, :dot3, :dot4 + # alternate thin dividers + xref = "x_#{type}".to_sym + [:w, xref, :i, :e, :dn, :up] + else # :div (center, non-emphasized) + [:w, :x, :i, :e, :dn, :up] + end + rval = lookup.map { |key| @data.fetch(key) } + rval[0] = '' unless @left + rval[3] = '' unless @right + rval + end + end + + # Unicode Border With rounded edges + class UnicodeRoundBorder < UnicodeBorder + def initialize + super + @data.merge!({nw: '╭', ne: '╮', sw: '╰', se: '╯'}) + end + end + + # Unicode Border with thick outer edges + class UnicodeThickEdgeBorder < UnicodeBorder + def initialize + super + @data = { + nil => nil, + nw: "┏", nx: "━", n: "┯", ne: "┓", nd: nil, + yw: "┃", y: "│", ye: "┃", + aw: "┣", ax: "═", ai: "╪", ae: "┫", ad: '╤', au: "╧", # double + bw: "┣", bx: "━", bi: "┿", be: "┫", bd: '┯', bu: "┷", # heavy/bold/thick + w: "┠", x: "─", i: "┼", e: "┨", dn: "┬", up: "┴", # normal div + sw: "┗", sx: "━", s: "┷", se: "┛", su: nil, + # alternative dots/dashes + x_dot4: '┈', x_dot3: '┄', x_dash: '╌', + bx_dot4: '┉', bx_dot3: '┅', bx_dash: '╍', + } + end + end + + # A Style object holds all the formatting information for a Table object + # + # To create a table with a certain style, use either the constructor + # option :style, the Table#style object or the Table#style= method + # + # All these examples have the same effect: + # + # # by constructor + # @table = Table.new(:style => {:padding_left => 2, :width => 40}) + # + # # by object + # @table.style.padding_left = 2 + # @table.style.width = 40 + # + # # by method + # @table.style = {:padding_left => 2, :width => 40} + # + # To set a default style for all tables created afterwards use Style.defaults= + # + # Terminal::Table::Style.defaults = {:width => 80} + # + class Style + extend Forwardable + def_delegators :@border, :vertical, :horizontal, :remove_verticals, :remove_horizontals + + @@defaults = { + :border => AsciiBorder.new, + :padding_left => 1, :padding_right => 1, + :margin_left => '', + :width => nil, :alignment => nil, + :all_separators => false, + } + + ## settors/gettor for legacy ascii borders + def border_x=(val) ; @border[:x] = val ; end + def border_y=(val) ; @border[:y] = val ; end + def border_i=(val) ; @border[:i] = val ; end + def border_y ; @border[:y] ; end + def border_y_width ; Util::ansi_escape(@border[:y]).length ; end + + # Accessor for instance of Border + attr_reader :border + def border=(val) + if val.is_a? Symbol + # convert symbol name like :foo_bar to get class FooBarBorder + klass_str = val.to_s.split('_').collect(&:capitalize).join + "Border" + begin + klass = Terminal::Table::const_get(klass_str) + @border = klass.new + rescue NameError + raise "Cannot lookup class Terminal::Table::#{klass_str} from symbol #{val.inspect}" + end + else + @border = val + end + end + + def border_top=(val) ; @border.top = val ; end + def border_bottom=(val) ; @border.bottom = val ; end + def border_left=(val) ; @border.left = val ; end + def border_right=(val) ; @border.right = val ; end + + def border_top ; @border.top ; end + def border_bottom ; @border.bottom ; end + def border_left ; @border.left ; end + def border_right ; @border.right ; end + + + attr_accessor :padding_left + attr_accessor :padding_right + + attr_accessor :margin_left + + attr_accessor :width + attr_accessor :alignment + + attr_accessor :all_separators + + + def initialize options = {} + apply self.class.defaults.merge(options) + end + + def apply options + options.each do |m, v| + __send__ "#{m}=", v + end + end + + class << self + def defaults + klass_defaults = @@defaults.dup + # border is an object that needs to be duplicated on instantiation, + # otherwise everything will be referencing the same object-id. + klass_defaults[:border] = klass_defaults[:border].dup + klass_defaults + end + + def defaults= options + @@defaults = defaults.merge(options) + end + + end + + def on_change attr + method_name = :"#{attr}=" + old_method = method method_name + define_singleton_method(method_name) do |value| + old_method.call value + yield attr.to_sym, value + end + end + + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/table.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/table.rb new file mode 100644 index 0000000..f483e31 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/table.rb @@ -0,0 +1,372 @@ +require 'unicode/display_width' + +module Terminal + class Table + + attr_reader :title + attr_reader :headings + + ## + # Generates a ASCII/Unicode table with the given _options_. + + def initialize options = {}, &block + @elaborated = false + @headings = [] + @rows = [] + @column_widths = [] + self.style = options.fetch :style, {} + self.headings = options.fetch :headings, [] + self.rows = options.fetch :rows, [] + self.title = options.fetch :title, nil + yield_or_eval(&block) if block + + style.on_change(:width) { require_column_widths_recalc } + end + + ## + # Align column _n_ to the given _alignment_ of :center, :left, or :right. + + def align_column n, alignment + # nil forces the column method to return the cell itself + column(n, nil).each do |cell| + cell.alignment = alignment unless cell.alignment? + end + end + + ## + # Add a row. + + def add_row array + row = array == :separator ? Separator.new(self) : Row.new(self, array) + @rows << row + require_column_widths_recalc unless row.is_a?(Separator) + end + alias :<< :add_row + + ## + # Add a separator. + + def add_separator(border_type: :div) + @rows << Separator.new(self, border_type: border_type) + end + + def cell_spacing + cell_padding + style.border_y_width + end + + def cell_padding + style.padding_left + style.padding_right + end + + ## + # Return column _n_. + + def column n, method = :value, array = rows + array.map { |row| + # for each cells in a row, find the column with index + # just greater than the required one, and go back one. + index = col = 0 + row.cells.each do |cell| + break if index > n + index += cell.colspan + col += 1 + end + cell = row[col - 1] + cell && method ? cell.__send__(method) : cell + }.compact + end + + ## + # Return _n_ column including headings. + + def column_with_headings n, method = :value + column n, method, headings_with_rows + end + + ## + # Return columns. + + def columns + (0...number_of_columns).map { |n| column n } + end + + ## + # Return length of column _n_. + + def column_width n + column_widths[n] || 0 + end + alias length_of_column column_width # for legacy support + + ## + # Return total number of columns available. + + def number_of_columns + headings_with_rows.map { |r| r.number_of_columns }.max || 0 + end + + ## + # Set the headings + + def headings= arrays + arrays = [arrays] unless arrays.first.is_a?(Array) + @headings = arrays.map do |array| + row = Row.new(self, array) + require_column_widths_recalc + row + end + end + + ## + # Elaborate rows to form an Array of Rows and Separators with adjacency properties added. + # + # This is separated from the String rendering so that certain features may be tweaked + # before the String is built. + + def elaborate_rows + + buffer = style.border_top ? [Separator.new(self, border_type: :top, implicit: true)] : [] + unless @title.nil? + buffer << Row.new(self, [title_cell_options]) + buffer << Separator.new(self, implicit: true) + end + @headings.each do |row| + unless row.cells.empty? + buffer << row + buffer << Separator.new(self, border_type: :double, implicit: true) + end + end + if style.all_separators + @rows.each_with_index do |row, idx| + # last separator is bottom, others are :div + border_type = (idx == @rows.size - 1) ? :bot : :div + buffer << row + buffer << Separator.new(self, border_type: border_type, implicit: true) + end + else + buffer += @rows + buffer << Separator.new(self, border_type: :bot, implicit: true) if style.border_bottom + end + + # After all implicit Separators are inserted we need to save off the + # adjacent rows so that we can decide what type of intersections to use + # based on column spans in the adjacent row(s). + buffer.each_with_index do |r, idx| + if r.is_a?(Separator) + prev_row = idx > 0 ? buffer[idx - 1] : nil + next_row = buffer.fetch(idx + 1, nil) + r.save_adjacent_rows(prev_row, next_row) + end + end + + @elaborated = true + @rows = buffer + end + + ## + # Render the table. + + def render + elaborate_rows unless @elaborated + @rows.map { |r| style.margin_left + r.render.rstrip }.join("\n") + end + alias :to_s :render + + ## + # Return rows without separator rows. + + def rows + @rows.reject { |row| row.is_a? Separator } + end + + def rows= array + @rows = [] + array.each { |arr| self << arr } + end + + def style=(options) + style.apply options + end + + def style + @style ||= Style.new + end + + def title=(title) + @title = title + require_column_widths_recalc + end + + ## + # Check if _other_ is equal to self. _other_ is considered equal + # if it contains the same headings and rows. + + def == other + if other.respond_to? :render and other.respond_to? :rows + self.headings == other.headings and self.rows == other.rows + end + end + + private + + def columns_width + column_widths.inject(0) { |s, i| s + i + cell_spacing } + style.border_y_width + end + + def recalc_column_widths + @require_column_widths_recalc = false + n_cols = number_of_columns + space_width = cell_spacing + return if n_cols == 0 + + # prepare rows + all_rows = headings_with_rows + all_rows << Row.new(self, [title_cell_options]) unless @title.nil? + + # DP states, dp[colspan][index][split_offset] => column_width. + dp = [] + + # prepare initial value for DP. + all_rows.each do |row| + index = 0 + row.cells.each do |cell| + cell_value = cell.value_for_column_width_recalc + cell_width = Unicode::DisplayWidth.of(cell_value.to_s) + colspan = cell.colspan + + # find column width from each single cell. + dp[colspan] ||= [] + dp[colspan][index] ||= [0] # add a fake cell with length 0. + dp[colspan][index][colspan] ||= 0 # initialize column length to 0. + + # the last index `colspan` means width of the single column (split + # at end of each column), not a width made up of multiple columns. + single_column_length = [cell_width, dp[colspan][index][colspan]].max + dp[colspan][index][colspan] = single_column_length + + index += colspan + end + end + + # run DP. + (1..n_cols).each do |colspan| + dp[colspan] ||= [] + (0..n_cols-colspan).each do |index| + dp[colspan][index] ||= [1] + (1...colspan).each do |offset| + # processed level became reverse map from width => [offset, ...]. + left_colspan = offset + left_index = index + left_width = dp[left_colspan][left_index].keys.first + + right_colspan = colspan - left_colspan + right_index = index + offset + right_width = dp[right_colspan][right_index].keys.first + + dp[colspan][index][offset] = left_width + right_width + space_width + end + + # reverse map it for resolution (max width and short offset first). + rmap = {} + dp[colspan][index].each_with_index do |width, offset| + rmap[width] ||= [] + rmap[width] << offset + end + + # sort reversely and store it back. + dp[colspan][index] = Hash[rmap.sort.reverse] + end + end + + resolve = lambda do |colspan, full_width, index = 0| + # stop if reaches the bottom level. + return @column_widths[index] = full_width if colspan == 1 + + # choose best split offset for partition, or second best result + # if first one is not dividable. + candidate_offsets = dp[colspan][index].collect(&:last).flatten + offset = candidate_offsets[0] + offset = candidate_offsets[1] if offset == colspan + + # prepare for next round. + left_colspan = offset + left_index = index + left_width = dp[left_colspan][left_index].keys.first + + right_colspan = colspan - left_colspan + right_index = index + offset + right_width = dp[right_colspan][right_index].keys.first + + # calculate reference column width, give remaining spaces to left. + total_non_space_width = full_width - (colspan - 1) * space_width + ref_column_width = total_non_space_width / colspan + remainder = total_non_space_width % colspan + rem_left_width = [remainder, left_colspan].min + rem_right_width = remainder - rem_left_width + ref_left_width = ref_column_width * left_colspan + + (left_colspan - 1) * space_width + rem_left_width + ref_right_width = ref_column_width * right_colspan + + (right_colspan - 1) * space_width + rem_right_width + + # at most one width can be greater than the reference width. + if left_width <= ref_left_width and right_width <= ref_right_width + # use refernce width (evenly partition). + left_width = ref_left_width + right_width = ref_right_width + else + # the wider one takes its value, shorter one takes the rest. + if left_width > ref_left_width + right_width = full_width - left_width - space_width + else + left_width = full_width - right_width - space_width + end + end + + # run next round. + resolve.call(left_colspan, left_width, left_index) + resolve.call(right_colspan, right_width, right_index) + end + + full_width = dp[n_cols][0].keys.first + unless style.width.nil? + new_width = style.width - space_width - style.border_y_width + if new_width < full_width + raise "Table width exceeds wanted width " + + "of #{style.width} characters." + end + full_width = new_width + end + + resolve.call(n_cols, full_width) + end + + ## + # Return headings combined with rows. + + def headings_with_rows + @headings + rows + end + + def yield_or_eval &block + return unless block + if block.arity > 0 + yield self + else + self.instance_eval(&block) + end + end + + def title_cell_options + {:value => @title, :alignment => :center, :colspan => number_of_columns} + end + + def require_column_widths_recalc + @require_column_widths_recalc = true + end + + def column_widths + recalc_column_widths if @require_column_widths_recalc + @column_widths + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/table_helper.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/table_helper.rb new file mode 100644 index 0000000..5a85325 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/table_helper.rb @@ -0,0 +1,9 @@ +module Terminal + class Table + module TableHelper + def table headings = [], *rows, &block + Terminal::Table.new :headings => headings.to_a, :rows => rows, &block + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/util.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/util.rb new file mode 100644 index 0000000..a584c3d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/util.rb @@ -0,0 +1,13 @@ +module Terminal + class Table + module Util + # removes all ANSI escape sequences (e.g. color) + def ansi_escape(line) + line.to_s.gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, ''). + gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, ''). + gsub(/(\x03|\x1a)/, '') + end + module_function :ansi_escape + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/version.rb b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/version.rb new file mode 100644 index 0000000..42c0c18 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/lib/terminal-table/version.rb @@ -0,0 +1,5 @@ +module Terminal + class Table + VERSION = '3.0.2' + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/terminal-table.gemspec b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/terminal-table.gemspec new file mode 100644 index 0000000..6ccc546 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/terminal-table-3.0.2/terminal-table.gemspec @@ -0,0 +1,26 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'terminal-table/version' + +Gem::Specification.new do |spec| + spec.name = "terminal-table" + spec.version = Terminal::Table::VERSION + spec.authors = ["TJ Holowaychuk", "Scott J. Goldman"] + spec.email = ["tj@vision-media.ca"] + + spec.summary = "Simple, feature rich ascii table generation library" + spec.homepage = "https://github.com/tj/terminal-table" + spec.license = "MIT" + + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + spec.require_paths = ["lib"] + + spec.add_development_dependency "bundler", "~> 2" + spec.add_development_dependency "rake", "~> 13.0" + spec.add_development_dependency "rspec", ">= 3.0" + spec.add_development_dependency "term-ansicolor" + spec.add_development_dependency "pry" + + spec.add_runtime_dependency "unicode-display_width", [">= 1.1.1", "< 3"] +end diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/CHANGELOG.md b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/CHANGELOG.md new file mode 100644 index 0000000..307f42e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/CHANGELOG.md @@ -0,0 +1,196 @@ +# CHANGELOG + +## 2.5.0 + +- Unicode 15.1 + +## 2.4.2 + +More performance improvements: + +- Optimize lookup of first 4096 codepoints +- Avoid overwrite lookup if no overwrites are set + +## 2.4.1 + +- Improve general performance! +- Further improve performance for ASCII strings + +*You should really upgrade - it's much faster now!* + +## 2.4.0 +- Improve performance for ASCII-only strings, by @fatkodima +- Require Ruby 2.4 + +## 2.3.0 + +- Unicode 15.0 + +## 2.2.0 + +- Add *Hangul Jamo Extended-B* block to zero-width chars, thanks @ninjalj #22 + +## 2.1.0 + +- Unicode 14.0 + +## 2.0.0 + +- Release 2.0.0 +- Supports Ruby 3.0 + +## 2.0.0.pre2 + +- Update 2.0 branch to Unicode 13 + +## 2.0.0.pre1 + +Will be published as non-pre version on rubygems.org when Ruby 3.0 is released (December 2020) + +- Introduce new class-based API, which remembers your string-width configuration. See README for details. +- Remove auto-loading of string extension + - You can: `require "unicode/display_width/string_ext"` to continue to use the string extension + - The manual opt-out `require "unicode/display_width/no_string_ext"` is not needed anymore and will + issue a warning in the future +- Remove (already deprecated) String#display_size and String#display_width aliases + +Refactorings / Internal Changes: + +- Freeze string literals +- The Unicode::DisplayWidth now is class, instead of a module, this enables the new config-object API + +## 1.8.0 + +- Unicode 14.0 (last release of 1.x) + +## 1.7.0 + +- Unicode 13 + +## 1.6.1 + +- Fix that ambiguous and overwrite options where ignored for emoji-measuring + +## 1.6.0 + +- Unicode 12.1 + +## 1.5.0 + +- Unicode 12 + +## 1.4.1 + +- Only bundle required lib/* and data/* files in actual rubygem, patch by @tas50 + +## 1.4.0 + +- Unicode 11 + +## 1.3.3 + +- Replace Gem::Util.gunzip with direct zlib implementation + This removes the dependency on rubygems, fixes #17 + +## 1.3.2 + +- Explicitly load rubygems/util, fixes regression in 1.3.1 (autoload issue) + +## 1.3.1 + +- Use `Gem::Util` for `gunzip`, removes deprecation warning, patch by @Schwad + +## 1.3.0 + +- Unicode 10 + +## 1.2.1 + +- Fix bug that `emoji: true` would fail for emoji without modifier + +## 1.2.0 + +- Add zero-width codepoint ranges: U+2060..U+206F, U+FFF0..U+FFF8, U+E0000..U+E0FFF +- Add full-witdh codepoint ranges: U+3400..U+4DBF, U+4E00..U+9FFF, U+F900..U+FAFF, U+20000..U+2FFFD, U+30000..U+3FFFD +- Experimental emoji support using the [unicode-emoji](https://github.com/janlelis/unicode-emoji) gem +- Fix minor bug in index compression scheme + +## 1.1.3 + +- Fix that non-UTF-8 encodings do not throw errors, patch by @windwiny + +## 1.1.2 + +- Reduce memory consumption and increase performance, patch by @rrosenblum + +## 1.1.1 + +- Always load index into memory, fixes #9 + +## 1.1.0 + +- Support Unicode 9.0 + +## 1.0.5 + +- Actually include new index from 1.0.4 + +## 1.0.4 + +- New index format (much smaller) and internal API changes +- Move index generation to a builder plugin for the unicoder gem +- No public API changes + +## 1.0.3 + +- Avoid circular dependency warning + +## 1.0.2 + +- Fix error that gemspec might be invalid under some circumstances (see gh#6) + +## 1.0.1 + +- Inofficially allow Ruby 1.9 + +## 1.0.0 + +- Faster than 0.3.1 +- Advanced determination of character width +- This includes: Treat width of most chars of general categories (Mn, Me, Cf) as 0 +- This includes: Introduce list of characters with special widths +- Allow custom overrides for specific codepoints +- Set required Ruby version to 2.0 +- Add NO_STRING_EXT mode to disable monkey patching +- Internal API & index format changed drastically +- Remove require 'unicode/display_size' (use 'unicode/display_width' instead) + +## 0.3.1 + +- Faster than 0.3.0 +- Deprecate usage of aliases: String#display_size and String#display_length +- Eliminate Ruby warnings (@amatsuda) + +## 0.3.0 + +- Update EastAsianWidth from 7.0 to 8.0 +- Add rake task to update EastAsianWidth.txt +- Move code to generate index from library to Rakefile +- Update project's meta files +- Deprecate requiring 'unicode-display_size' + +## 0.2.0 + +- Update EastAsianWidth from 6.0 to 7.0 +- Don't build index table automatically when not available +- Don't include EastAsianWidth.txt in gem (only index) + + +## 0.1.0 + +- Fix github issue #1 + + +## 0.1.0 + +- Initial release diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/MIT-LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/MIT-LICENSE.txt new file mode 100644 index 0000000..ae6e469 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/MIT-LICENSE.txt @@ -0,0 +1,22 @@ +The MIT LICENSE + +Copyright (c) 2011, 2015-2023 Jan Lelis + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/README.md b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/README.md new file mode 100644 index 0000000..5bd4b64 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/README.md @@ -0,0 +1,171 @@ +## Unicode::DisplayWidth [![[version]](https://badge.fury.io/rb/unicode-display_width.svg)](https://badge.fury.io/rb/unicode-display_width) [](https://github.com/janlelis/unicode-display_width/actions?query=workflow%3ATest) + +Determines the monospace display width of a string in Ruby. Useful for all kinds of terminal-based applications. Implementation based on [EastAsianWidth.txt](https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt) and other data, 100% in Ruby. It does not rely on the OS vendor (like [wcwidth()](https://github.com/janlelis/wcswidth-ruby)) to provide an up-to-date method for measuring string width. + +Unicode version: **15.1.0** (September 2023) + +Supported Rubies: **3.2**, **3.1**, **3.0**, **2.7** + +Old Rubies which might still work: **2.6**, **2.5**, **2.4** + +For even older Rubies, use version 2.3.0 of this gem: **2.3**, **2.2**, **2.1**, **2.0**, **1.9** + +## Version 2.4.2 — Performance Updates + +**If you use this gem, you should really upgrade to 2.4.2 or newer. It's often 100x faster, sometimes even 1000x and more!** + +This is possible because the gem now detects if you use very basic (and common) characters, like ASCII characters. Furthermore, the charachter width lookup code has been optimized, so even when full-width characters are involved, the gem is much faster now. + +## Version 2.0 — Breaking Changes + +Some features of this library were marked deprecated for a long time and have been removed with Version 2.0: + +- Aliases of display_width (…\_size, …\_length) have been removed +- Auto-loading of string core extension has been removed: + +If you are relying on the `String#display_width` string extension to be automatically loaded (old behavior), please load it explicitly now: + +```ruby +require "unicode/display_width/string_ext" +``` + +You could also change your `Gemfile` line to achieve this: + +```ruby +gem "unicode-display_width", require: "unicode/display_width/string_ext" +``` + +## Introduction to Character Widths + +Guessing the correct space a character will consume on terminals is not easy. There is no single standard. Most implementations combine data from [East Asian Width](https://www.unicode.org/reports/tr11/), some [General Categories](https://en.wikipedia.org/wiki/Unicode_character_property#General_Category), and hand-picked adjustments. + +### How this Library Handles Widths + +Further at the top means higher precedence. Please expect changes to this algorithm with every MINOR version update (the X in 1.X.0)! + +Width | Characters | Comment +-------|------------------------------|-------------------------------------------------- +X | (user defined) | Overwrites any other values +-1 | `"\b"` | Backspace (total width never below 0) +0 | `"\0"`, `"\x05"`, `"\a"`, `"\n"`, `"\v"`, `"\f"`, `"\r"`, `"\x0E"`, `"\x0F"` | [C0 control codes](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C0_.28ASCII_and_derivatives.29) which do not change horizontal width +1 | `"\u{00AD}"` | SOFT HYPHEN +2 | `"\u{2E3A}"` | TWO-EM DASH +3 | `"\u{2E3B}"` | THREE-EM DASH +0 | General Categories: Mn, Me, Cf (non-arabic) | Excludes ARABIC format characters +0 | `"\u{1160}".."\u{11FF}"`, `"\u{D7B0}".."\u{D7FF}"` | HANGUL JUNGSEONG +0 | `"\u{2060}".."\u{206F}"`, `"\u{FFF0}".."\u{FFF8}"`, `"\u{E0000}".."\u{E0FFF}"` | Ignorable ranges +2 | East Asian Width: F, W | Full-width characters +2 | `"\u{3400}".."\u{4DBF}"`, `"\u{4E00}".."\u{9FFF}"`, `"\u{F900}".."\u{FAFF}"`, `"\u{20000}".."\u{2FFFD}"`, `"\u{30000}".."\u{3FFFD}"` | Full-width ranges +1 or 2 | East Asian Width: A | Ambiguous characters, user defined, default: 1 +1 | All other codepoints | - + +## Install + +Install the gem with: + + $ gem install unicode-display_width + +Or add to your Gemfile: + + gem 'unicode-display_width' + +## Usage + +### Classic API + +```ruby +require 'unicode/display_width' + +Unicode::DisplayWidth.of("⚀") # => 1 +Unicode::DisplayWidth.of("一") # => 2 +``` + +#### Ambiguous Characters + +The second parameter defines the value returned by characters defined as ambiguous: + +```ruby +Unicode::DisplayWidth.of("·", 1) # => 1 +Unicode::DisplayWidth.of("·", 2) # => 2 +``` + +#### Custom Overwrites + +You can overwrite how to handle specific code points by passing a hash (or even a proc) as third parameter: + +```ruby +Unicode::DisplayWidth.of("a\tb", 1, "\t".ord => 10)) # => tab counted as 10, so result is 12 +``` + +Please note that using overwrites disables some perfomance optimizations of this gem. + + +#### Emoji Support + +Emoji width support is included, but in must be activated manually. It will adjust the string's size for modifier and zero-width joiner sequences. You also need to add the [unicode-emoji](https://github.com/janlelis/unicode-emoji) gem to your Gemfile: + +```ruby +gem 'unicode-display_width' +gem 'unicode-emoji' +``` + +Enable the emoji string width adjustments by passing `emoji: true` as fourth parameter: + +```ruby +Unicode::DisplayWidth.of "🤾🏽‍♀️" # => 5 +Unicode::DisplayWidth.of "🤾🏽‍♀️", 1, {}, emoji: true # => 2 +``` + +#### Usage with String Extension + +```ruby +require 'unicode/display_width/string_ext' + +"⚀".display_width # => 1 +'一'.display_width # => 2 +``` + +### Modern API: Keyword-arguments Based Config Object + +Version 2.0 introduces a keyword-argument based API, which allows you to save your configuration for later-reuse. This requires an extra line of code, but has the advantage that you'll need to define your string-width options only once: + +```ruby +require 'unicode/display_width' + +display_width = Unicode::DisplayWidth.new( + # ambiguous: 1, + overwrite: { "A".ord => 100 }, + emoji: true, +) + +display_width.of "⚀" # => 1 +display_width.of "🤾🏽‍♀️" # => 2 +display_width.of "A" # => 100 +``` + +### Usage From the CLI + +Use this one-liner to print out display widths for strings from the command-line: + +``` +$ gem install unicode-display_width +$ ruby -r unicode/display_width -e 'puts Unicode::DisplayWidth.of $*[0]' -- "一" +``` +Replace "一" with the actual string to measure + +## Other Implementations & Discussion + +- Python: https://github.com/jquast/wcwidth +- JavaScript: https://github.com/mycoboco/wcwidth.js +- C: https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c +- C for Julia: https://github.com/JuliaLang/utf8proc/issues/2 +- Golang: https://github.com/rivo/uniseg + +See [unicode-x](https://github.com/janlelis/unicode-x) for more Unicode related micro libraries. + +## Copyright & Info + +- Copyright (c) 2011, 2015-2023 Jan Lelis, https://janlelis.com, released under the MIT +license +- Early versions based on runpaint's unicode-data interface: Copyright (c) 2009 Run Paint Run Run +- Unicode data: https://www.unicode.org/copyright.html#Exhibit1 diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/data/display_width.marshal.gz b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/data/display_width.marshal.gz new file mode 100644 index 0000000..0160b75 Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/data/display_width.marshal.gz differ diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width.rb b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width.rb new file mode 100644 index 0000000..bbd7026 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +require_relative "display_width/constants" +require_relative "display_width/index" + +module Unicode + class DisplayWidth + INITIAL_DEPTH = 0x10000 + ASCII_NON_ZERO_REGEX = /[\0\x05\a\b\n\v\f\r\x0E\x0F]/ + FIRST_4096 = decompress_index(INDEX[0][0], 1) + + def self.of(string, ambiguous = 1, overwrite = {}, options = {}) + if overwrite.empty? + # Optimization for ASCII-only strings without certain control symbols + if string.ascii_only? + if string.match?(ASCII_NON_ZERO_REGEX) + res = string.gsub(ASCII_NON_ZERO_REGEX, "").size - string.count("\b") + res < 0 ? 0 : res + else + string.size + end + else + width_no_overwrite(string, ambiguous, options) + end + else + width_all_features(string, ambiguous, overwrite, options) + end + end + + def self.width_no_overwrite(string, ambiguous, options = {}) + # Sum of all chars widths + res = string.codepoints.sum{ |codepoint| + if codepoint > 15 && codepoint < 161 # very common + next 1 + elsif codepoint < 0x1001 + width = FIRST_4096[codepoint] + else + width = INDEX + depth = INITIAL_DEPTH + while (width = width[codepoint / depth]).instance_of? Array + codepoint %= depth + depth /= 16 + end + end + + width == :A ? ambiguous : (width || 1) + } + + # Substract emoji error + res -= emoji_extra_width_of(string, ambiguous) if options[:emoji] + + # Return result + prevent negative lengths + res < 0 ? 0 : res + end + + # Same as .width_no_overwrite - but with applying overwrites for each char + def self.width_all_features(string, ambiguous, overwrite, options) + # Sum of all chars widths + res = string.codepoints.sum{ |codepoint| + next overwrite[codepoint] if overwrite[codepoint] + + if codepoint > 15 && codepoint < 161 # very common + next 1 + elsif codepoint < 0x1001 + width = FIRST_4096[codepoint] + else + width = INDEX + depth = INITIAL_DEPTH + while (width = width[codepoint / depth]).instance_of? Array + codepoint %= depth + depth /= 16 + end + end + + width == :A ? ambiguous : (width || 1) + } + + # Substract emoji error + res -= emoji_extra_width_of(string, ambiguous, overwrite) if options[:emoji] + + # Return result + prevent negative lengths + res < 0 ? 0 : res + end + + + def self.emoji_extra_width_of(string, ambiguous = 1, overwrite = {}, _ = {}) + require "unicode/emoji" + + extra_width = 0 + modifier_regex = /[#{ Unicode::Emoji::EMOJI_MODIFIERS.pack("U*") }]/ + zwj_regex = /(?<=#{ [Unicode::Emoji::ZWJ].pack("U") })./ + + string.scan(Unicode::Emoji::REGEX){ |emoji| + extra_width += 2 * emoji.scan(modifier_regex).size + + emoji.scan(zwj_regex){ |zwj_succ| + extra_width += self.of(zwj_succ, ambiguous, overwrite) + } + } + + extra_width + end + + def initialize(ambiguous: 1, overwrite: {}, emoji: false) + @ambiguous = ambiguous + @overwrite = overwrite + @emoji = emoji + end + + def get_config(**kwargs) + [ + kwargs[:ambiguous] || @ambiguous, + kwargs[:overwrite] || @overwrite, + { emoji: kwargs[:emoji] || @emoji }, + ] + end + + def of(string, **kwargs) + self.class.of(string, *get_config(**kwargs)) + end + end +end + diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/constants.rb b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/constants.rb new file mode 100644 index 0000000..038b0b0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/constants.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Unicode + class DisplayWidth + VERSION = "2.5.0" + UNICODE_VERSION = "15.1.0" + DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../../../data/") + INDEX_FILENAME = DATA_DIRECTORY + "/display_width.marshal.gz" + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb new file mode 100644 index 0000000..f81df7f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require "zlib" +require_relative "constants" + +module Unicode + class DisplayWidth + File.open(INDEX_FILENAME, "rb") do |file| + serialized_data = Zlib::GzipReader.new(file).read + serialized_data.force_encoding Encoding::BINARY + INDEX = Marshal.load(serialized_data) + end + + def self.decompress_index(index, level) + index.flat_map{ |value| + if level > 0 + if value.instance_of?(Array) + value[15] ||= nil + decompress_index(value, level - 1) + else + decompress_index([value] * 16, level - 1) + end + else + if value.instance_of?(Array) + value[15] ||= nil + value + else + [value] * 16 + end + end + } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/no_string_ext.rb b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/no_string_ext.rb new file mode 100644 index 0000000..2601497 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/no_string_ext.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +warn "You are loading 'unicode-display_width/no_string_ext'\n" \ + "Beginning with version 2.0, this is not necessary anymore\n"\ + "You can just require 'unicode-display_width' now and no\n"\ + "string extension will be loaded" + +require_relative "../display_width" diff --git a/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/string_ext.rb b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/string_ext.rb new file mode 100644 index 0000000..88df9ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/string_ext.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require_relative "../display_width" unless defined? Unicode::DisplayWidth + +class String + def display_width(ambiguous = 1, overwrite = {}, options = {}) + Unicode::DisplayWidth.of(self, ambiguous, overwrite, options) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/Gemfile b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/Gemfile new file mode 100644 index 0000000..10284be --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gemspec + +gem "rake" +gem "test-unit" diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/LICENSE.txt b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/LICENSE.txt new file mode 100644 index 0000000..a009cae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +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. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/README.md b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/README.md new file mode 100644 index 0000000..0027072 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/README.md @@ -0,0 +1,61 @@ +# Webrick + +WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server. + +WEBrick features complete logging of both server operations and HTTP access. + +WEBrick supports both basic and digest authentication in addition to algorithms not in RFC 2617. + +A WEBrick server can be composed of multiple WEBrick servers or servlets to provide differing behavior on a per-host or per-path basis. WEBrick includes servlets for handling CGI scripts, ERB pages, Ruby blocks and directory listings. + +WEBrick also includes tools for daemonizing a process and starting a process at a higher privilege level and dropping permissions. + +## Installation + +Add this line to your application's Gemfile: + +```ruby +gem 'webrick' +``` + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install webrick + +## Usage + +To create a new WEBrick::HTTPServer that will listen to connections on port 8000 and serve documents from the current user's public_html folder: + +```ruby +require 'webrick' + +root = File.expand_path '~/public_html' +server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root +``` + +To run the server you will need to provide a suitable shutdown hook as +starting the server blocks the current thread: + +```ruby +trap 'INT' do server.shutdown end + +server.start +``` + +## Development + +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/webrick. + +## License + +The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause). diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/Rakefile b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/Rakefile new file mode 100644 index 0000000..5a7afab --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/Rakefile @@ -0,0 +1,17 @@ +require "bundler/gem_tasks" +require "rake/testtask" + +Rake::TestTask.new(:test) do |t| + t.libs << "test/lib" + t.ruby_opts << "-rhelper" + t.test_files = FileList["test/**/test_*.rb"] +end + +task :sync_tool do + require 'fileutils' + FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib" + FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib" + FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib" +end + +task :default => :test diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick.rb new file mode 100644 index 0000000..b854b68 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick.rb @@ -0,0 +1,232 @@ +# frozen_string_literal: false +## +# = WEB server toolkit. +# +# WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, +# a proxy server, and a virtual-host server. WEBrick features complete +# logging of both server operations and HTTP access. WEBrick supports both +# basic and digest authentication in addition to algorithms not in RFC 2617. +# +# A WEBrick server can be composed of multiple WEBrick servers or servlets to +# provide differing behavior on a per-host or per-path basis. WEBrick +# includes servlets for handling CGI scripts, ERB pages, Ruby blocks and +# directory listings. +# +# WEBrick also includes tools for daemonizing a process and starting a process +# at a higher privilege level and dropping permissions. +# +# == Security +# +# *Warning:* WEBrick is not recommended for production. It only implements +# basic security checks. +# +# == Starting an HTTP server +# +# To create a new WEBrick::HTTPServer that will listen to connections on port +# 8000 and serve documents from the current user's public_html folder: +# +# require 'webrick' +# +# root = File.expand_path '~/public_html' +# server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root +# +# To run the server you will need to provide a suitable shutdown hook as +# starting the server blocks the current thread: +# +# trap 'INT' do server.shutdown end +# +# server.start +# +# == Custom Behavior +# +# The easiest way to have a server perform custom operations is through +# WEBrick::HTTPServer#mount_proc. The block given will be called with a +# WEBrick::HTTPRequest with request info and a WEBrick::HTTPResponse which +# must be filled in appropriately: +# +# server.mount_proc '/' do |req, res| +# res.body = 'Hello, world!' +# end +# +# Remember that +server.mount_proc+ must precede +server.start+. +# +# == Servlets +# +# Advanced custom behavior can be obtained through mounting a subclass of +# WEBrick::HTTPServlet::AbstractServlet. Servlets provide more modularity +# when writing an HTTP server than mount_proc allows. Here is a simple +# servlet: +# +# class Simple < WEBrick::HTTPServlet::AbstractServlet +# def do_GET request, response +# status, content_type, body = do_stuff_with request +# +# response.status = 200 +# response['Content-Type'] = 'text/plain' +# response.body = 'Hello, World!' +# end +# end +# +# To initialize the servlet you mount it on the server: +# +# server.mount '/simple', Simple +# +# See WEBrick::HTTPServlet::AbstractServlet for more details. +# +# == Virtual Hosts +# +# A server can act as a virtual host for multiple host names. After creating +# the listening host, additional hosts that do not listen can be created and +# attached as virtual hosts: +# +# server = WEBrick::HTTPServer.new # ... +# +# vhost = WEBrick::HTTPServer.new :ServerName => 'vhost.example', +# :DoNotListen => true, # ... +# vhost.mount '/', ... +# +# server.virtual_host vhost +# +# If no +:DocumentRoot+ is provided and no servlets or procs are mounted on the +# main server it will return 404 for all URLs. +# +# == HTTPS +# +# To create an HTTPS server you only need to enable SSL and provide an SSL +# certificate name: +# +# require 'webrick' +# require 'webrick/https' +# +# cert_name = [ +# %w[CN localhost], +# ] +# +# server = WEBrick::HTTPServer.new(:Port => 8000, +# :SSLEnable => true, +# :SSLCertName => cert_name) +# +# This will start the server with a self-generated self-signed certificate. +# The certificate will be changed every time the server is restarted. +# +# To create a server with a pre-determined key and certificate you can provide +# them: +# +# require 'webrick' +# require 'webrick/https' +# require 'openssl' +# +# cert = OpenSSL::X509::Certificate.new File.read '/path/to/cert.pem' +# pkey = OpenSSL::PKey::RSA.new File.read '/path/to/pkey.pem' +# +# server = WEBrick::HTTPServer.new(:Port => 8000, +# :SSLEnable => true, +# :SSLCertificate => cert, +# :SSLPrivateKey => pkey) +# +# == Proxy Server +# +# WEBrick can act as a proxy server: +# +# require 'webrick' +# require 'webrick/httpproxy' +# +# proxy = WEBrick::HTTPProxyServer.new :Port => 8000 +# +# trap 'INT' do proxy.shutdown end +# +# See WEBrick::HTTPProxy for further details including modifying proxied +# responses. +# +# == Basic and Digest authentication +# +# WEBrick provides both Basic and Digest authentication for regular and proxy +# servers. See WEBrick::HTTPAuth, WEBrick::HTTPAuth::BasicAuth and +# WEBrick::HTTPAuth::DigestAuth. +# +# == WEBrick as a daemonized Web Server +# +# WEBrick can be run as a daemonized server for small loads. +# +# === Daemonizing +# +# To start a WEBrick server as a daemon simple run WEBrick::Daemon.start +# before starting the server. +# +# === Dropping Permissions +# +# WEBrick can be started as one user to gain permission to bind to port 80 or +# 443 for serving HTTP or HTTPS traffic then can drop these permissions for +# regular operation. To listen on all interfaces for HTTP traffic: +# +# sockets = WEBrick::Utils.create_listeners nil, 80 +# +# Then drop privileges: +# +# WEBrick::Utils.su 'www' +# +# Then create a server that does not listen by default: +# +# server = WEBrick::HTTPServer.new :DoNotListen => true, # ... +# +# Then overwrite the listening sockets with the port 80 sockets: +# +# server.listeners.replace sockets +# +# === Logging +# +# WEBrick can separately log server operations and end-user access. For +# server operations: +# +# log_file = File.open '/var/log/webrick.log', 'a+' +# log = WEBrick::Log.new log_file +# +# For user access logging: +# +# access_log = [ +# [log_file, WEBrick::AccessLog::COMBINED_LOG_FORMAT], +# ] +# +# server = WEBrick::HTTPServer.new :Logger => log, :AccessLog => access_log +# +# See WEBrick::AccessLog for further log formats. +# +# === Log Rotation +# +# To rotate logs in WEBrick on a HUP signal (like syslogd can send), open the +# log file in 'a+' mode (as above) and trap 'HUP' to reopen the log file: +# +# trap 'HUP' do log_file.reopen '/path/to/webrick.log', 'a+' +# +# == Copyright +# +# Author: IPR -- Internet Programming with Ruby -- writers +# +# Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +#-- +# $IPR: webrick.rb,v 1.12 2002/10/01 17:16:31 gotoyuzo Exp $ + +module WEBrick +end + +require 'webrick/compat.rb' + +require 'webrick/version.rb' +require 'webrick/config.rb' +require 'webrick/log.rb' +require 'webrick/server.rb' +require_relative 'webrick/utils.rb' +require 'webrick/accesslog' + +require 'webrick/htmlutils.rb' +require 'webrick/httputils.rb' +require 'webrick/cookie.rb' +require 'webrick/httpversion.rb' +require 'webrick/httpstatus.rb' +require 'webrick/httprequest.rb' +require 'webrick/httpresponse.rb' +require 'webrick/httpserver.rb' +require 'webrick/httpservlet.rb' +require 'webrick/httpauth.rb' diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/accesslog.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/accesslog.rb new file mode 100644 index 0000000..fccfd65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/accesslog.rb @@ -0,0 +1,157 @@ +# frozen_string_literal: true +#-- +# accesslog.rb -- Access log handling utilities +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2002 keita yamaguchi +# Copyright (c) 2002 Internet Programming with Ruby writers +# +# $IPR: accesslog.rb,v 1.1 2002/10/01 17:16:32 gotoyuzo Exp $ + +module WEBrick + + ## + # AccessLog provides logging to various files in various formats. + # + # Multiple logs may be written to at the same time: + # + # access_log = [ + # [$stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT], + # [$stderr, WEBrick::AccessLog::REFERER_LOG_FORMAT], + # ] + # + # server = WEBrick::HTTPServer.new :AccessLog => access_log + # + # Custom log formats may be defined. WEBrick::AccessLog provides a subset + # of the formatting from Apache's mod_log_config + # http://httpd.apache.org/docs/mod/mod_log_config.html#formats. See + # AccessLog::setup_params for a list of supported options + + module AccessLog + + ## + # Raised if a parameter such as %e, %i, %o or %n is used without fetching + # a specific field. + + class AccessLogError < StandardError; end + + ## + # The Common Log Format's time format + + CLF_TIME_FORMAT = "[%d/%b/%Y:%H:%M:%S %Z]" + + ## + # Common Log Format + + COMMON_LOG_FORMAT = "%h %l %u %t \"%r\" %s %b" + + ## + # Short alias for Common Log Format + + CLF = COMMON_LOG_FORMAT + + ## + # Referer Log Format + + REFERER_LOG_FORMAT = "%{Referer}i -> %U" + + ## + # User-Agent Log Format + + AGENT_LOG_FORMAT = "%{User-Agent}i" + + ## + # Combined Log Format + + COMBINED_LOG_FORMAT = "#{CLF} \"%{Referer}i\" \"%{User-agent}i\"" + + module_function + + # This format specification is a subset of mod_log_config of Apache: + # + # %a:: Remote IP address + # %b:: Total response size + # %e{variable}:: Given variable in ENV + # %f:: Response filename + # %h:: Remote host name + # %{header}i:: Given request header + # %l:: Remote logname, always "-" + # %m:: Request method + # %{attr}n:: Given request attribute from req.attributes + # %{header}o:: Given response header + # %p:: Server's request port + # %{format}p:: The canonical port of the server serving the request or the + # actual port or the client's actual port. Valid formats are + # canonical, local or remote. + # %q:: Request query string + # %r:: First line of the request + # %s:: Request status + # %t:: Time the request was received + # %T:: Time taken to process the request + # %u:: Remote user from auth + # %U:: Unparsed URI + # %%:: Literal % + + def setup_params(config, req, res) + params = Hash.new("") + params["a"] = req.peeraddr[3] + params["b"] = res.sent_size + params["e"] = ENV + params["f"] = res.filename || "" + params["h"] = req.peeraddr[2] + params["i"] = req + params["l"] = "-" + params["m"] = req.request_method + params["n"] = req.attributes + params["o"] = res + params["p"] = req.port + params["q"] = req.query_string + params["r"] = req.request_line.sub(/\x0d?\x0a\z/o, '') + params["s"] = res.status # won't support "%>s" + params["t"] = req.request_time + params["T"] = Time.now - req.request_time + params["u"] = req.user || "-" + params["U"] = req.unparsed_uri + params["v"] = config[:ServerName] + params + end + + ## + # Formats +params+ according to +format_string+ which is described in + # setup_params. + + def format(format_string, params) + format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z%])/){ + param, spec = $1, $2 + case spec[0] + when ?e, ?i, ?n, ?o + raise AccessLogError, + "parameter is required for \"#{spec}\"" unless param + (param = params[spec][param]) ? escape(param) : "-" + when ?t + params[spec].strftime(param || CLF_TIME_FORMAT) + when ?p + case param + when 'remote' + escape(params["i"].peeraddr[1].to_s) + else + escape(params["p"].to_s) + end + when ?% + "%" + else + escape(params[spec].to_s) + end + } + end + + ## + # Escapes control characters in +data+ + + def escape(data) + data = data.gsub(/[[:cntrl:]\\]+/) {$&.dump[1...-1]} + data.untaint if RUBY_VERSION < '2.7' + data + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/cgi.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/cgi.rb new file mode 100644 index 0000000..f22480b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/cgi.rb @@ -0,0 +1,313 @@ +# frozen_string_literal: true +# +# cgi.rb -- Yet another CGI library +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $Id$ + +require_relative "httprequest" +require_relative "httpresponse" +require_relative "config" +require "stringio" + +module WEBrick + + # A CGI library using WEBrick requests and responses. + # + # Example: + # + # class MyCGI < WEBrick::CGI + # def do_GET req, res + # res.body = 'it worked!' + # res.status = 200 + # end + # end + # + # MyCGI.new.start + + class CGI + + # The CGI error exception class + + CGIError = Class.new(StandardError) + + ## + # The CGI configuration. This is based on WEBrick::Config::HTTP + + attr_reader :config + + ## + # The CGI logger + + attr_reader :logger + + ## + # Creates a new CGI interface. + # + # The first argument in +args+ is a configuration hash which would update + # WEBrick::Config::HTTP. + # + # Any remaining arguments are stored in the @options instance + # variable for use by a subclass. + + def initialize(*args) + if defined?(MOD_RUBY) + unless ENV.has_key?("GATEWAY_INTERFACE") + Apache.request.setup_cgi_env + end + end + if %r{HTTP/(\d+\.\d+)} =~ ENV["SERVER_PROTOCOL"] + httpv = $1 + end + @config = WEBrick::Config::HTTP.dup.update( + :ServerSoftware => ENV["SERVER_SOFTWARE"] || "null", + :HTTPVersion => HTTPVersion.new(httpv || "1.0"), + :RunOnCGI => true, # to detect if it runs on CGI. + :NPH => false # set true to run as NPH script. + ) + if config = args.shift + @config.update(config) + end + @config[:Logger] ||= WEBrick::BasicLog.new($stderr) + @logger = @config[:Logger] + @options = args + end + + ## + # Reads +key+ from the configuration + + def [](key) + @config[key] + end + + ## + # Starts the CGI process with the given environment +env+ and standard + # input and output +stdin+ and +stdout+. + + def start(env=ENV, stdin=$stdin, stdout=$stdout) + sock = WEBrick::CGI::Socket.new(@config, env, stdin, stdout) + req = HTTPRequest.new(@config) + res = HTTPResponse.new(@config) + unless @config[:NPH] or defined?(MOD_RUBY) + def res.setup_header + unless @header["status"] + phrase = HTTPStatus::reason_phrase(@status) + @header["status"] = "#{@status} #{phrase}" + end + super + end + def res.status_line + "" + end + end + + begin + req.parse(sock) + req.script_name = (env["SCRIPT_NAME"] || File.expand_path($0)).dup + req.path_info = (env["PATH_INFO"] || "").dup + req.query_string = env["QUERY_STRING"] + req.user = env["REMOTE_USER"] + res.request_method = req.request_method + res.request_uri = req.request_uri + res.request_http_version = req.http_version + res.keep_alive = req.keep_alive? + self.service(req, res) + rescue HTTPStatus::Error => ex + res.set_error(ex) + rescue HTTPStatus::Status => ex + res.status = ex.code + rescue Exception => ex + @logger.error(ex) + res.set_error(ex, true) + ensure + req.fixup + if defined?(MOD_RUBY) + res.setup_header + Apache.request.status_line = "#{res.status} #{res.reason_phrase}" + Apache.request.status = res.status + table = Apache.request.headers_out + res.header.each{|key, val| + case key + when /^content-encoding$/i + Apache::request.content_encoding = val + when /^content-type$/i + Apache::request.content_type = val + else + table[key] = val.to_s + end + } + res.cookies.each{|cookie| + table.add("Set-Cookie", cookie.to_s) + } + Apache.request.send_http_header + res.send_body(sock) + else + res.send_response(sock) + end + end + end + + ## + # Services the request +req+ which will fill in the response +res+. See + # WEBrick::HTTPServlet::AbstractServlet#service for details. + + def service(req, res) + method_name = "do_" + req.request_method.gsub(/-/, "_") + if respond_to?(method_name) + __send__(method_name, req, res) + else + raise HTTPStatus::MethodNotAllowed, + "unsupported method `#{req.request_method}'." + end + end + + ## + # Provides HTTP socket emulation from the CGI environment + + class Socket # :nodoc: + include Enumerable + + private + + def initialize(config, env, stdin, stdout) + @config = config + @env = env + @header_part = StringIO.new + @body_part = stdin + @out_port = stdout + @out_port.binmode + + @server_addr = @env["SERVER_ADDR"] || "0.0.0.0" + @server_name = @env["SERVER_NAME"] + @server_port = @env["SERVER_PORT"] + @remote_addr = @env["REMOTE_ADDR"] + @remote_host = @env["REMOTE_HOST"] || @remote_addr + @remote_port = @env["REMOTE_PORT"] || 0 + + begin + @header_part << request_line << CRLF + setup_header + @header_part << CRLF + @header_part.rewind + rescue Exception + raise CGIError, "invalid CGI environment" + end + end + + def request_line + meth = @env["REQUEST_METHOD"] || "GET" + unless url = @env["REQUEST_URI"] + url = (@env["SCRIPT_NAME"] || File.expand_path($0)).dup + url << @env["PATH_INFO"].to_s + url = WEBrick::HTTPUtils.escape_path(url) + if query_string = @env["QUERY_STRING"] + unless query_string.empty? + url << "?" << query_string + end + end + end + # we cannot get real HTTP version of client ;) + httpv = @config[:HTTPVersion] + return "#{meth} #{url} HTTP/#{httpv}" + end + + def setup_header + @env.each{|key, value| + case key + when "CONTENT_TYPE", "CONTENT_LENGTH" + add_header(key.gsub(/_/, "-"), value) + when /^HTTP_(.*)/ + add_header($1.gsub(/_/, "-"), value) + end + } + end + + def add_header(hdrname, value) + unless value.empty? + @header_part << hdrname << ": " << value << CRLF + end + end + + def input + @header_part.eof? ? @body_part : @header_part + end + + public + + def peeraddr + [nil, @remote_port, @remote_host, @remote_addr] + end + + def addr + [nil, @server_port, @server_name, @server_addr] + end + + def gets(eol=LF, size=nil) + input.gets(eol, size) + end + + def read(size=nil) + input.read(size) + end + + def each + input.each{|line| yield(line) } + end + + def eof? + input.eof? + end + + def <<(data) + @out_port << data + end + + def write(data) + @out_port.write(data) + end + + def cert + return nil unless defined?(OpenSSL) + if pem = @env["SSL_SERVER_CERT"] + OpenSSL::X509::Certificate.new(pem) unless pem.empty? + end + end + + def peer_cert + return nil unless defined?(OpenSSL) + if pem = @env["SSL_CLIENT_CERT"] + OpenSSL::X509::Certificate.new(pem) unless pem.empty? + end + end + + def peer_cert_chain + return nil unless defined?(OpenSSL) + if @env["SSL_CLIENT_CERT_CHAIN_0"] + keys = @env.keys + certs = keys.sort.collect{|k| + if /^SSL_CLIENT_CERT_CHAIN_\d+$/ =~ k + if pem = @env[k] + OpenSSL::X509::Certificate.new(pem) unless pem.empty? + end + end + } + certs.compact + end + end + + def cipher + return nil unless defined?(OpenSSL) + if cipher = @env["SSL_CIPHER"] + ret = [ cipher ] + ret << @env["SSL_PROTOCOL"] + ret << @env["SSL_CIPHER_USEKEYSIZE"] + ret << @env["SSL_CIPHER_ALGKEYSIZE"] + ret + end + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/compat.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/compat.rb new file mode 100644 index 0000000..842da1e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/compat.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true +# +# compat.rb -- cross platform compatibility +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2002 GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: compat.rb,v 1.6 2002/10/01 17:16:32 gotoyuzo Exp $ + +## +# System call error module used by webrick for cross platform compatibility. +# +# EPROTO:: protocol error +# ECONNRESET:: remote host reset the connection request +# ECONNABORTED:: Client sent TCP reset (RST) before server has accepted the +# connection requested by client. +# +module Errno + ## + # Protocol error. + + class EPROTO < SystemCallError; end + + ## + # Remote host reset the connection request. + + class ECONNRESET < SystemCallError; end + + ## + # Client sent TCP reset (RST) before server has accepted the connection + # requested by client. + + class ECONNABORTED < SystemCallError; end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/config.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/config.rb new file mode 100644 index 0000000..d67375c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/config.rb @@ -0,0 +1,158 @@ +# frozen_string_literal: true +# +# config.rb -- Default configurations. +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: config.rb,v 1.52 2003/07/22 19:20:42 gotoyuzo Exp $ + +require_relative 'version' +require_relative 'httpversion' +require_relative 'httputils' +require_relative 'utils' +require_relative 'log' + +module WEBrick + module Config + LIBDIR = File::dirname(__FILE__) # :nodoc: + + # for GenericServer + General = Hash.new { |hash, key| + case key + when :ServerName + hash[key] = Utils.getservername + else + nil + end + }.update( + :BindAddress => nil, # "0.0.0.0" or "::" or nil + :Port => nil, # users MUST specify this!! + :MaxClients => 100, # maximum number of the concurrent connections + :ServerType => nil, # default: WEBrick::SimpleServer + :Logger => nil, # default: WEBrick::Log.new + :ServerSoftware => "WEBrick/#{WEBrick::VERSION} " + + "(Ruby/#{RUBY_VERSION}/#{RUBY_RELEASE_DATE})", + :TempDir => ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp', + :DoNotListen => false, + :StartCallback => nil, + :StopCallback => nil, + :AcceptCallback => nil, + :DoNotReverseLookup => true, + :ShutdownSocketWithoutClose => false, + ) + + # for HTTPServer, HTTPRequest, HTTPResponse ... + HTTP = General.dup.update( + :Port => 80, + :RequestTimeout => 30, + :HTTPVersion => HTTPVersion.new("1.1"), + :AccessLog => nil, + :MimeTypes => HTTPUtils::DefaultMimeTypes, + :DirectoryIndex => ["index.html","index.htm","index.cgi","index.rhtml"], + :DocumentRoot => nil, + :DocumentRootOptions => { :FancyIndexing => true }, + :RequestCallback => nil, + :ServerAlias => nil, + :InputBufferSize => 65536, # input buffer size in reading request body + :OutputBufferSize => 65536, # output buffer size in sending File or IO + + # for HTTPProxyServer + :ProxyAuthProc => nil, + :ProxyContentHandler => nil, + :ProxyVia => true, + :ProxyTimeout => true, + :ProxyURI => nil, + + :CGIInterpreter => nil, + :CGIPathEnv => nil, + + # workaround: if Request-URIs contain 8bit chars, + # they should be escaped before calling of URI::parse(). + :Escape8bitURI => false + ) + + ## + # Default configuration for WEBrick::HTTPServlet::FileHandler + # + # :AcceptableLanguages:: + # Array of languages allowed for accept-language. There is no default + # :DirectoryCallback:: + # Allows preprocessing of directory requests. There is no default + # callback. + # :FancyIndexing:: + # If true, show an index for directories. The default is true. + # :FileCallback:: + # Allows preprocessing of file requests. There is no default callback. + # :HandlerCallback:: + # Allows preprocessing of requests. There is no default callback. + # :HandlerTable:: + # Maps file suffixes to file handlers. DefaultFileHandler is used by + # default but any servlet can be used. + # :NondisclosureName:: + # Do not show files matching this array of globs. .ht* and *~ are + # excluded by default. + # :UserDir:: + # Directory inside ~user to serve content from for /~user requests. + # Only works if mounted on /. Disabled by default. + + FileHandler = { + :NondisclosureName => [".ht*", "*~"], + :FancyIndexing => false, + :HandlerTable => {}, + :HandlerCallback => nil, + :DirectoryCallback => nil, + :FileCallback => nil, + :UserDir => nil, # e.g. "public_html" + :AcceptableLanguages => [] # ["en", "ja", ... ] + } + + ## + # Default configuration for WEBrick::HTTPAuth::BasicAuth + # + # :AutoReloadUserDB:: Reload the user database provided by :UserDB + # automatically? + + BasicAuth = { + :AutoReloadUserDB => true, + } + + ## + # Default configuration for WEBrick::HTTPAuth::DigestAuth. + # + # :Algorithm:: MD5, MD5-sess (default), SHA1, SHA1-sess + # :Domain:: An Array of URIs that define the protected space + # :Qop:: 'auth' for authentication, 'auth-int' for integrity protection or + # both + # :UseOpaque:: Should the server send opaque values to the client? This + # helps prevent replay attacks. + # :CheckNc:: Should the server check the nonce count? This helps the + # server detect replay attacks. + # :UseAuthenticationInfoHeader:: Should the server send an + # AuthenticationInfo header? + # :AutoReloadUserDB:: Reload the user database provided by :UserDB + # automatically? + # :NonceExpirePeriod:: How long should we store used nonces? Default is + # 30 minutes. + # :NonceExpireDelta:: How long is a nonce valid? Default is 1 minute + # :InternetExplorerHack:: Hack which allows Internet Explorer to work. + # :OperaHack:: Hack which allows Opera to work. + + DigestAuth = { + :Algorithm => 'MD5-sess', # or 'MD5' + :Domain => nil, # an array includes domain names. + :Qop => [ 'auth' ], # 'auth' or 'auth-int' or both. + :UseOpaque => true, + :UseNextNonce => false, + :CheckNc => false, + :UseAuthenticationInfoHeader => true, + :AutoReloadUserDB => true, + :NonceExpirePeriod => 30*60, + :NonceExpireDelta => 60, + :InternetExplorerHack => true, + :OperaHack => true, + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/cookie.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/cookie.rb new file mode 100644 index 0000000..7b18782 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/cookie.rb @@ -0,0 +1,172 @@ +# frozen_string_literal: true +# +# cookie.rb -- Cookie class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: cookie.rb,v 1.16 2002/09/21 12:23:35 gotoyuzo Exp $ + +require 'time' +require_relative 'httputils' + +module WEBrick + + ## + # Processes HTTP cookies + + class Cookie + + ## + # The cookie name + + attr_reader :name + + ## + # The cookie value + + attr_accessor :value + + ## + # The cookie version + + attr_accessor :version + + ## + # The cookie domain + attr_accessor :domain + + ## + # The cookie path + + attr_accessor :path + + ## + # Is this a secure cookie? + + attr_accessor :secure + + ## + # The cookie comment + + attr_accessor :comment + + ## + # The maximum age of the cookie + + attr_accessor :max_age + + #attr_accessor :comment_url, :discard, :port + + ## + # Creates a new cookie with the given +name+ and +value+ + + def initialize(name, value) + @name = name + @value = value + @version = 0 # Netscape Cookie + + @domain = @path = @secure = @comment = @max_age = + @expires = @comment_url = @discard = @port = nil + end + + ## + # Sets the cookie expiration to the time +t+. The expiration time may be + # a false value to disable expiration or a Time or HTTP format time string + # to set the expiration date. + + def expires=(t) + @expires = t && (t.is_a?(Time) ? t.httpdate : t.to_s) + end + + ## + # Retrieves the expiration time as a Time + + def expires + @expires && Time.parse(@expires) + end + + ## + # The cookie string suitable for use in an HTTP header + + def to_s + ret = +"" + ret << @name << "=" << @value + ret << "; " << "Version=" << @version.to_s if @version > 0 + ret << "; " << "Domain=" << @domain if @domain + ret << "; " << "Expires=" << @expires if @expires + ret << "; " << "Max-Age=" << @max_age.to_s if @max_age + ret << "; " << "Comment=" << @comment if @comment + ret << "; " << "Path=" << @path if @path + ret << "; " << "Secure" if @secure + ret + end + + ## + # Parses a Cookie field sent from the user-agent. Returns an array of + # cookies. + + def self.parse(str) + if str + ret = [] + cookie = nil + ver = 0 + str.split(/;\s+/).each{|x| + key, val = x.split(/=/,2) + val = val ? HTTPUtils::dequote(val) : "" + case key + when "$Version"; ver = val.to_i + when "$Path"; cookie.path = val + when "$Domain"; cookie.domain = val + when "$Port"; cookie.port = val + else + ret << cookie if cookie + cookie = self.new(key, val) + cookie.version = ver + end + } + ret << cookie if cookie + ret + end + end + + ## + # Parses the cookie in +str+ + + def self.parse_set_cookie(str) + cookie_elem = str.split(/;/) + first_elem = cookie_elem.shift + first_elem.strip! + key, value = first_elem.split(/=/, 2) + cookie = new(key, HTTPUtils.dequote(value)) + cookie_elem.each{|pair| + pair.strip! + key, value = pair.split(/=/, 2) + if value + value = HTTPUtils.dequote(value.strip) + end + case key.downcase + when "domain" then cookie.domain = value + when "path" then cookie.path = value + when "expires" then cookie.expires = value + when "max-age" then cookie.max_age = Integer(value) + when "comment" then cookie.comment = value + when "version" then cookie.version = Integer(value) + when "secure" then cookie.secure = true + end + } + return cookie + end + + ## + # Parses the cookies in +str+ + + def self.parse_set_cookies(str) + return str.split(/,(?=[^;,]*=)|,$/).collect{|c| + parse_set_cookie(c) + } + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/htmlutils.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/htmlutils.rb new file mode 100644 index 0000000..7ff0bde --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/htmlutils.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true +#-- +# htmlutils.rb -- HTMLUtils Module +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: htmlutils.rb,v 1.7 2002/09/21 12:23:35 gotoyuzo Exp $ + +module WEBrick + module HTMLUtils + + ## + # Escapes &, ", > and < in +string+ + + def escape(string) + return "" unless string + str = string.b + str.gsub!(/&/n, '&') + str.gsub!(/\"/n, '"') + str.gsub!(/>/n, '>') + str.gsub!(/ 'DigestAuth example realm' } + # + # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file' + # htpasswd.auth_type = WEBrick::HTTPAuth::DigestAuth + # htpasswd.set_passwd config[:Realm], 'username', 'password' + # htpasswd.flush + # + # The +:Realm+ is used to provide different access to different groups + # across several resources on a server. Typically you'll need only one + # realm for a server. + # + # This database can be used to create an authenticator: + # + # config[:UserDB] = htpasswd + # + # digest_auth = WEBrick::HTTPAuth::DigestAuth.new config + # + # To authenticate a request call #authenticate with a request and response + # object in a servlet: + # + # def do_GET req, res + # @authenticator.authenticate req, res + # end + # + # For digest authentication the authenticator must not be created every + # request, it must be passed in as an option via WEBrick::HTTPServer#mount. + + module HTTPAuth + module_function + + def _basic_auth(req, res, realm, req_field, res_field, err_type, + block) # :nodoc: + user = pass = nil + if /^Basic\s+(.*)/o =~ req[req_field] + userpass = $1 + user, pass = userpass.unpack("m*")[0].split(":", 2) + end + if block.call(user, pass) + req.user = user + return + end + res[res_field] = "Basic realm=\"#{realm}\"" + raise err_type + end + + ## + # Simple wrapper for providing basic authentication for a request. When + # called with a request +req+, response +res+, authentication +realm+ and + # +block+ the block will be called with a +username+ and +password+. If + # the block returns true the request is allowed to continue, otherwise an + # HTTPStatus::Unauthorized error is raised. + + def basic_auth(req, res, realm, &block) # :yield: username, password + _basic_auth(req, res, realm, "Authorization", "WWW-Authenticate", + HTTPStatus::Unauthorized, block) + end + + ## + # Simple wrapper for providing basic authentication for a proxied request. + # When called with a request +req+, response +res+, authentication +realm+ + # and +block+ the block will be called with a +username+ and +password+. + # If the block returns true the request is allowed to continue, otherwise + # an HTTPStatus::ProxyAuthenticationRequired error is raised. + + def proxy_basic_auth(req, res, realm, &block) # :yield: username, password + _basic_auth(req, res, realm, "Proxy-Authorization", "Proxy-Authenticate", + HTTPStatus::ProxyAuthenticationRequired, block) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/authenticator.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/authenticator.rb new file mode 100644 index 0000000..a6ee28d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/authenticator.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true +#-- +# httpauth/authenticator.rb -- Authenticator mix-in module. +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: authenticator.rb,v 1.3 2003/02/20 07:15:47 gotoyuzo Exp $ + +module WEBrick + module HTTPAuth + + ## + # Module providing generic support for both Digest and Basic + # authentication schemes. + + module Authenticator + + RequestField = "Authorization" # :nodoc: + ResponseField = "WWW-Authenticate" # :nodoc: + ResponseInfoField = "Authentication-Info" # :nodoc: + AuthException = HTTPStatus::Unauthorized # :nodoc: + + ## + # Method of authentication, must be overridden by the including class + + AuthScheme = nil + + ## + # The realm this authenticator covers + + attr_reader :realm + + ## + # The user database for this authenticator + + attr_reader :userdb + + ## + # The logger for this authenticator + + attr_reader :logger + + private + + # :stopdoc: + + ## + # Initializes the authenticator from +config+ + + def check_init(config) + [:UserDB, :Realm].each{|sym| + unless config[sym] + raise ArgumentError, "Argument #{sym.inspect} missing." + end + } + @realm = config[:Realm] + @userdb = config[:UserDB] + @logger = config[:Logger] || Log::new($stderr) + @reload_db = config[:AutoReloadUserDB] + @request_field = self::class::RequestField + @response_field = self::class::ResponseField + @resp_info_field = self::class::ResponseInfoField + @auth_exception = self::class::AuthException + @auth_scheme = self::class::AuthScheme + end + + ## + # Ensures +req+ has credentials that can be authenticated. + + def check_scheme(req) + unless credentials = req[@request_field] + error("no credentials in the request.") + return nil + end + unless match = /^#{@auth_scheme}\s+/i.match(credentials) + error("invalid scheme in %s.", credentials) + info("%s: %s", @request_field, credentials) if $DEBUG + return nil + end + return match.post_match + end + + def log(meth, fmt, *args) + msg = format("%s %s: ", @auth_scheme, @realm) + msg << fmt % args + @logger.__send__(meth, msg) + end + + def error(fmt, *args) + if @logger.error? + log(:error, fmt, *args) + end + end + + def info(fmt, *args) + if @logger.info? + log(:info, fmt, *args) + end + end + + # :startdoc: + end + + ## + # Module providing generic support for both Digest and Basic + # authentication schemes for proxies. + + module ProxyAuthenticator + RequestField = "Proxy-Authorization" # :nodoc: + ResponseField = "Proxy-Authenticate" # :nodoc: + InfoField = "Proxy-Authentication-Info" # :nodoc: + AuthException = HTTPStatus::ProxyAuthenticationRequired # :nodoc: + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/basicauth.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/basicauth.rb new file mode 100644 index 0000000..cc8137a --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/basicauth.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true +# +# httpauth/basicauth.rb -- HTTP basic access authentication +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: basicauth.rb,v 1.5 2003/02/20 07:15:47 gotoyuzo Exp $ + +require_relative '../config' +require_relative '../httpstatus' +require_relative 'authenticator' + +module WEBrick + module HTTPAuth + + ## + # Basic Authentication for WEBrick + # + # Use this class to add basic authentication to a WEBrick servlet. + # + # Here is an example of how to set up a BasicAuth: + # + # config = { :Realm => 'BasicAuth example realm' } + # + # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file', password_hash: :bcrypt + # htpasswd.set_passwd config[:Realm], 'username', 'password' + # htpasswd.flush + # + # config[:UserDB] = htpasswd + # + # basic_auth = WEBrick::HTTPAuth::BasicAuth.new config + + class BasicAuth + include Authenticator + + AuthScheme = "Basic" # :nodoc: + + ## + # Used by UserDB to create a basic password entry + + def self.make_passwd(realm, user, pass) + pass ||= "" + pass.crypt(Utils::random_string(2)) + end + + attr_reader :realm, :userdb, :logger + + ## + # Creates a new BasicAuth instance. + # + # See WEBrick::Config::BasicAuth for default configuration entries + # + # You must supply the following configuration entries: + # + # :Realm:: The name of the realm being protected. + # :UserDB:: A database of usernames and passwords. + # A WEBrick::HTTPAuth::Htpasswd instance should be used. + + def initialize(config, default=Config::BasicAuth) + check_init(config) + @config = default.dup.update(config) + end + + ## + # Authenticates a +req+ and returns a 401 Unauthorized using +res+ if + # the authentication was not correct. + + def authenticate(req, res) + unless basic_credentials = check_scheme(req) + challenge(req, res) + end + userid, password = basic_credentials.unpack("m*")[0].split(":", 2) + password ||= "" + if userid.empty? + error("user id was not given.") + challenge(req, res) + end + unless encpass = @userdb.get_passwd(@realm, userid, @reload_db) + error("%s: the user is not allowed.", userid) + challenge(req, res) + end + + case encpass + when /\A\$2[aby]\$/ + password_matches = BCrypt::Password.new(encpass.sub(/\A\$2[aby]\$/, '$2a$')) == password + else + password_matches = password.crypt(encpass) == encpass + end + + unless password_matches + error("%s: password unmatch.", userid) + challenge(req, res) + end + info("%s: authentication succeeded.", userid) + req.user = userid + end + + ## + # Returns a challenge response which asks for authentication information + + def challenge(req, res) + res[@response_field] = "#{@auth_scheme} realm=\"#{@realm}\"" + raise @auth_exception + end + end + + ## + # Basic authentication for proxy servers. See BasicAuth for details. + + class ProxyBasicAuth < BasicAuth + include ProxyAuthenticator + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/digestauth.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/digestauth.rb new file mode 100644 index 0000000..25ce8ba --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/digestauth.rb @@ -0,0 +1,395 @@ +# frozen_string_literal: true +# +# httpauth/digestauth.rb -- HTTP digest access authentication +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. +# Copyright (c) 2003 H.M. +# +# The original implementation is provided by H.M. +# URL: http://rwiki.jin.gr.jp/cgi-bin/rw-cgi.rb?cmd=view;name= +# %C7%A7%BE%DA%B5%A1%C7%BD%A4%F2%B2%FE%C2%A4%A4%B7%A4%C6%A4%DF%A4%EB +# +# $IPR: digestauth.rb,v 1.5 2003/02/20 07:15:47 gotoyuzo Exp $ + +require_relative '../config' +require_relative '../httpstatus' +require_relative 'authenticator' +require 'digest/md5' +require 'digest/sha1' + +module WEBrick + module HTTPAuth + + ## + # RFC 2617 Digest Access Authentication for WEBrick + # + # Use this class to add digest authentication to a WEBrick servlet. + # + # Here is an example of how to set up DigestAuth: + # + # config = { :Realm => 'DigestAuth example realm' } + # + # htdigest = WEBrick::HTTPAuth::Htdigest.new 'my_password_file' + # htdigest.set_passwd config[:Realm], 'username', 'password' + # htdigest.flush + # + # config[:UserDB] = htdigest + # + # digest_auth = WEBrick::HTTPAuth::DigestAuth.new config + # + # When using this as with a servlet be sure not to create a new DigestAuth + # object in the servlet's #initialize. By default WEBrick creates a new + # servlet instance for every request and the DigestAuth object must be + # used across requests. + + class DigestAuth + include Authenticator + + AuthScheme = "Digest" # :nodoc: + + ## + # Struct containing the opaque portion of the digest authentication + + OpaqueInfo = Struct.new(:time, :nonce, :nc) # :nodoc: + + ## + # Digest authentication algorithm + + attr_reader :algorithm + + ## + # Quality of protection. RFC 2617 defines "auth" and "auth-int" + + attr_reader :qop + + ## + # Used by UserDB to create a digest password entry + + def self.make_passwd(realm, user, pass) + pass ||= "" + Digest::MD5::hexdigest([user, realm, pass].join(":")) + end + + ## + # Creates a new DigestAuth instance. Be sure to use the same DigestAuth + # instance for multiple requests as it saves state between requests in + # order to perform authentication. + # + # See WEBrick::Config::DigestAuth for default configuration entries + # + # You must supply the following configuration entries: + # + # :Realm:: The name of the realm being protected. + # :UserDB:: A database of usernames and passwords. + # A WEBrick::HTTPAuth::Htdigest instance should be used. + + def initialize(config, default=Config::DigestAuth) + check_init(config) + @config = default.dup.update(config) + @algorithm = @config[:Algorithm] + @domain = @config[:Domain] + @qop = @config[:Qop] + @use_opaque = @config[:UseOpaque] + @use_next_nonce = @config[:UseNextNonce] + @check_nc = @config[:CheckNc] + @use_auth_info_header = @config[:UseAuthenticationInfoHeader] + @nonce_expire_period = @config[:NonceExpirePeriod] + @nonce_expire_delta = @config[:NonceExpireDelta] + @internet_explorer_hack = @config[:InternetExplorerHack] + + case @algorithm + when 'MD5','MD5-sess' + @h = Digest::MD5 + when 'SHA1','SHA1-sess' # it is a bonus feature :-) + @h = Digest::SHA1 + else + msg = format('Algorithm "%s" is not supported.', @algorithm) + raise ArgumentError.new(msg) + end + + @instance_key = hexdigest(self.__id__, Time.now.to_i, Process.pid) + @opaques = {} + @last_nonce_expire = Time.now + @mutex = Thread::Mutex.new + end + + ## + # Authenticates a +req+ and returns a 401 Unauthorized using +res+ if + # the authentication was not correct. + + def authenticate(req, res) + unless result = @mutex.synchronize{ _authenticate(req, res) } + challenge(req, res) + end + if result == :nonce_is_stale + challenge(req, res, true) + end + return true + end + + ## + # Returns a challenge response which asks for authentication information + + def challenge(req, res, stale=false) + nonce = generate_next_nonce(req) + if @use_opaque + opaque = generate_opaque(req) + @opaques[opaque].nonce = nonce + end + + param = Hash.new + param["realm"] = HTTPUtils::quote(@realm) + param["domain"] = HTTPUtils::quote(@domain.to_a.join(" ")) if @domain + param["nonce"] = HTTPUtils::quote(nonce) + param["opaque"] = HTTPUtils::quote(opaque) if opaque + param["stale"] = stale.to_s + param["algorithm"] = @algorithm + param["qop"] = HTTPUtils::quote(@qop.to_a.join(",")) if @qop + + res[@response_field] = + "#{@auth_scheme} " + param.map{|k,v| "#{k}=#{v}" }.join(", ") + info("%s: %s", @response_field, res[@response_field]) if $DEBUG + raise @auth_exception + end + + private + + # :stopdoc: + + MustParams = ['username','realm','nonce','uri','response'] + MustParamsAuth = ['cnonce','nc'] + + def _authenticate(req, res) + unless digest_credentials = check_scheme(req) + return false + end + + auth_req = split_param_value(digest_credentials) + if auth_req['qop'] == "auth" || auth_req['qop'] == "auth-int" + req_params = MustParams + MustParamsAuth + else + req_params = MustParams + end + req_params.each{|key| + unless auth_req.has_key?(key) + error('%s: parameter missing. "%s"', auth_req['username'], key) + raise HTTPStatus::BadRequest + end + } + + if !check_uri(req, auth_req) + raise HTTPStatus::BadRequest + end + + if auth_req['realm'] != @realm + error('%s: realm unmatch. "%s" for "%s"', + auth_req['username'], auth_req['realm'], @realm) + return false + end + + auth_req['algorithm'] ||= 'MD5' + if auth_req['algorithm'].upcase != @algorithm.upcase + error('%s: algorithm unmatch. "%s" for "%s"', + auth_req['username'], auth_req['algorithm'], @algorithm) + return false + end + + if (@qop.nil? && auth_req.has_key?('qop')) || + (@qop && (! @qop.member?(auth_req['qop']))) + error('%s: the qop is not allowed. "%s"', + auth_req['username'], auth_req['qop']) + return false + end + + password = @userdb.get_passwd(@realm, auth_req['username'], @reload_db) + unless password + error('%s: the user is not allowed.', auth_req['username']) + return false + end + + nonce_is_invalid = false + if @use_opaque + info("@opaque = %s", @opaque.inspect) if $DEBUG + if !(opaque = auth_req['opaque']) + error('%s: opaque is not given.', auth_req['username']) + nonce_is_invalid = true + elsif !(opaque_struct = @opaques[opaque]) + error('%s: invalid opaque is given.', auth_req['username']) + nonce_is_invalid = true + elsif !check_opaque(opaque_struct, req, auth_req) + @opaques.delete(auth_req['opaque']) + nonce_is_invalid = true + end + elsif !check_nonce(req, auth_req) + nonce_is_invalid = true + end + + if /-sess$/i =~ auth_req['algorithm'] + ha1 = hexdigest(password, auth_req['nonce'], auth_req['cnonce']) + else + ha1 = password + end + + if auth_req['qop'] == "auth" || auth_req['qop'] == nil + ha2 = hexdigest(req.request_method, auth_req['uri']) + ha2_res = hexdigest("", auth_req['uri']) + elsif auth_req['qop'] == "auth-int" + body_digest = @h.new + req.body { |chunk| body_digest.update(chunk) } + body_digest = body_digest.hexdigest + ha2 = hexdigest(req.request_method, auth_req['uri'], body_digest) + ha2_res = hexdigest("", auth_req['uri'], body_digest) + end + + if auth_req['qop'] == "auth" || auth_req['qop'] == "auth-int" + param2 = ['nonce', 'nc', 'cnonce', 'qop'].map{|key| + auth_req[key] + }.join(':') + digest = hexdigest(ha1, param2, ha2) + digest_res = hexdigest(ha1, param2, ha2_res) + else + digest = hexdigest(ha1, auth_req['nonce'], ha2) + digest_res = hexdigest(ha1, auth_req['nonce'], ha2_res) + end + + if digest != auth_req['response'] + error("%s: digest unmatch.", auth_req['username']) + return false + elsif nonce_is_invalid + error('%s: digest is valid, but nonce is not valid.', + auth_req['username']) + return :nonce_is_stale + elsif @use_auth_info_header + auth_info = { + 'nextnonce' => generate_next_nonce(req), + 'rspauth' => digest_res + } + if @use_opaque + opaque_struct.time = req.request_time + opaque_struct.nonce = auth_info['nextnonce'] + opaque_struct.nc = "%08x" % (auth_req['nc'].hex + 1) + end + if auth_req['qop'] == "auth" || auth_req['qop'] == "auth-int" + ['qop','cnonce','nc'].each{|key| + auth_info[key] = auth_req[key] + } + end + res[@resp_info_field] = auth_info.keys.map{|key| + if key == 'nc' + key + '=' + auth_info[key] + else + key + "=" + HTTPUtils::quote(auth_info[key]) + end + }.join(', ') + end + info('%s: authentication succeeded.', auth_req['username']) + req.user = auth_req['username'] + return true + end + + def split_param_value(string) + ret = {} + string.scan(/\G\s*([\w\-.*%!]+)=\s*(?:\"((?>\\.|[^\"])*)\"|([^,\"]*))\s*,?/) do + ret[$1] = $3 || $2.gsub(/\\(.)/, "\\1") + end + ret + end + + def generate_next_nonce(req) + now = "%012d" % req.request_time.to_i + pk = hexdigest(now, @instance_key)[0,32] + nonce = [now + ":" + pk].pack("m0") # it has 60 length of chars. + nonce + end + + def check_nonce(req, auth_req) + username = auth_req['username'] + nonce = auth_req['nonce'] + + pub_time, pk = nonce.unpack("m*")[0].split(":", 2) + if (!pub_time || !pk) + error("%s: empty nonce is given", username) + return false + elsif (hexdigest(pub_time, @instance_key)[0,32] != pk) + error("%s: invalid private-key: %s for %s", + username, hexdigest(pub_time, @instance_key)[0,32], pk) + return false + end + + diff_time = req.request_time.to_i - pub_time.to_i + if (diff_time < 0) + error("%s: difference of time-stamp is negative.", username) + return false + elsif diff_time > @nonce_expire_period + error("%s: nonce is expired.", username) + return false + end + + return true + end + + def generate_opaque(req) + @mutex.synchronize{ + now = req.request_time + if now - @last_nonce_expire > @nonce_expire_delta + @opaques.delete_if{|key,val| + (now - val.time) > @nonce_expire_period + } + @last_nonce_expire = now + end + begin + opaque = Utils::random_string(16) + end while @opaques[opaque] + @opaques[opaque] = OpaqueInfo.new(now, nil, '00000001') + opaque + } + end + + def check_opaque(opaque_struct, req, auth_req) + if (@use_next_nonce && auth_req['nonce'] != opaque_struct.nonce) + error('%s: nonce unmatched. "%s" for "%s"', + auth_req['username'], auth_req['nonce'], opaque_struct.nonce) + return false + elsif !check_nonce(req, auth_req) + return false + end + if (@check_nc && auth_req['nc'] != opaque_struct.nc) + error('%s: nc unmatched."%s" for "%s"', + auth_req['username'], auth_req['nc'], opaque_struct.nc) + return false + end + true + end + + def check_uri(req, auth_req) + uri = auth_req['uri'] + if uri != req.request_uri.to_s && uri != req.unparsed_uri && + (@internet_explorer_hack && uri != req.path) + error('%s: uri unmatch. "%s" for "%s"', auth_req['username'], + auth_req['uri'], req.request_uri.to_s) + return false + end + true + end + + def hexdigest(*args) + @h.hexdigest(args.join(":")) + end + + # :startdoc: + end + + ## + # Digest authentication for proxy servers. See DigestAuth for details. + + class ProxyDigestAuth < DigestAuth + include ProxyAuthenticator + + private + def check_uri(req, auth_req) # :nodoc: + return true + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htdigest.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htdigest.rb new file mode 100644 index 0000000..c7e853b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htdigest.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true +# +# httpauth/htdigest.rb -- Apache compatible htdigest file +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: htdigest.rb,v 1.4 2003/07/22 19:20:45 gotoyuzo Exp $ + +require_relative 'userdb' +require_relative 'digestauth' +require 'tempfile' + +module WEBrick + module HTTPAuth + + ## + # Htdigest accesses apache-compatible digest password files. Passwords are + # matched to a realm where they are valid. For security, the path for a + # digest password database should be stored outside of the paths available + # to the HTTP server. + # + # Htdigest is intended for use with WEBrick::HTTPAuth::DigestAuth and + # stores passwords using cryptographic hashes. + # + # htpasswd = WEBrick::HTTPAuth::Htdigest.new 'my_password_file' + # htpasswd.set_passwd 'my realm', 'username', 'password' + # htpasswd.flush + + class Htdigest + include UserDB + + ## + # Open a digest password database at +path+ + + def initialize(path) + @path = path + @mtime = Time.at(0) + @digest = Hash.new + @mutex = Thread::Mutex::new + @auth_type = DigestAuth + File.open(@path,"a").close unless File.exist?(@path) + reload + end + + ## + # Reloads passwords from the database + + def reload + mtime = File::mtime(@path) + if mtime > @mtime + @digest.clear + File.open(@path){|io| + while line = io.gets + line.chomp! + user, realm, pass = line.split(/:/, 3) + unless @digest[realm] + @digest[realm] = Hash.new + end + @digest[realm][user] = pass + end + } + @mtime = mtime + end + end + + ## + # Flush the password database. If +output+ is given the database will + # be written there instead of to the original path. + + def flush(output=nil) + output ||= @path + tmp = Tempfile.create("htpasswd", File::dirname(output)) + renamed = false + begin + each{|item| tmp.puts(item.join(":")) } + tmp.close + File::rename(tmp.path, output) + renamed = true + ensure + tmp.close + File.unlink(tmp.path) if !renamed + end + end + + ## + # Retrieves a password from the database for +user+ in +realm+. If + # +reload_db+ is true the database will be reloaded first. + + def get_passwd(realm, user, reload_db) + reload() if reload_db + if hash = @digest[realm] + hash[user] + end + end + + ## + # Sets a password in the database for +user+ in +realm+ to +pass+. + + def set_passwd(realm, user, pass) + @mutex.synchronize{ + unless @digest[realm] + @digest[realm] = Hash.new + end + @digest[realm][user] = make_passwd(realm, user, pass) + } + end + + ## + # Removes a password from the database for +user+ in +realm+. + + def delete_passwd(realm, user) + if hash = @digest[realm] + hash.delete(user) + end + end + + ## + # Iterate passwords in the database. + + def each # :yields: [user, realm, password_hash] + @digest.keys.sort.each{|realm| + hash = @digest[realm] + hash.keys.sort.each{|user| + yield([user, realm, hash[user]]) + } + } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htgroup.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htgroup.rb new file mode 100644 index 0000000..108c9d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htgroup.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true +# +# httpauth/htgroup.rb -- Apache compatible htgroup file +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: htgroup.rb,v 1.1 2003/02/16 22:22:56 gotoyuzo Exp $ + +require 'tempfile' + +module WEBrick + module HTTPAuth + + ## + # Htgroup accesses apache-compatible group files. Htgroup can be used to + # provide group-based authentication for users. Currently Htgroup is not + # directly integrated with any authenticators in WEBrick. For security, + # the path for a digest password database should be stored outside of the + # paths available to the HTTP server. + # + # Example: + # + # htgroup = WEBrick::HTTPAuth::Htgroup.new 'my_group_file' + # htgroup.add 'superheroes', %w[spiderman batman] + # + # htgroup.members('superheroes').include? 'magneto' # => false + + class Htgroup + + ## + # Open a group database at +path+ + + def initialize(path) + @path = path + @mtime = Time.at(0) + @group = Hash.new + File.open(@path,"a").close unless File.exist?(@path) + reload + end + + ## + # Reload groups from the database + + def reload + if (mtime = File::mtime(@path)) > @mtime + @group.clear + File.open(@path){|io| + while line = io.gets + line.chomp! + group, members = line.split(/:\s*/) + @group[group] = members.split(/\s+/) + end + } + @mtime = mtime + end + end + + ## + # Flush the group database. If +output+ is given the database will be + # written there instead of to the original path. + + def flush(output=nil) + output ||= @path + tmp = Tempfile.create("htgroup", File::dirname(output)) + begin + @group.keys.sort.each{|group| + tmp.puts(format("%s: %s", group, self.members(group).join(" "))) + } + ensure + tmp.close + if $! + File.unlink(tmp.path) + else + return File.rename(tmp.path, output) + end + end + end + + ## + # Retrieve the list of members from +group+ + + def members(group) + reload + @group[group] || [] + end + + ## + # Add an Array of +members+ to +group+ + + def add(group, members) + @group[group] = members(group) | members + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htpasswd.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htpasswd.rb new file mode 100644 index 0000000..9a48e57 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/htpasswd.rb @@ -0,0 +1,158 @@ +# frozen_string_literal: true +# +# httpauth/htpasswd -- Apache compatible htpasswd file +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: htpasswd.rb,v 1.4 2003/07/22 19:20:45 gotoyuzo Exp $ + +require_relative 'userdb' +require_relative 'basicauth' +require 'tempfile' + +module WEBrick + module HTTPAuth + + ## + # Htpasswd accesses apache-compatible password files. Passwords are + # matched to a realm where they are valid. For security, the path for a + # password database should be stored outside of the paths available to the + # HTTP server. + # + # Htpasswd is intended for use with WEBrick::HTTPAuth::BasicAuth. + # + # To create an Htpasswd database with a single user: + # + # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file' + # htpasswd.set_passwd 'my realm', 'username', 'password' + # htpasswd.flush + + class Htpasswd + include UserDB + + ## + # Open a password database at +path+ + + def initialize(path, password_hash: nil) + @path = path + @mtime = Time.at(0) + @passwd = Hash.new + @auth_type = BasicAuth + @password_hash = password_hash + + case @password_hash + when nil + # begin + # require "string/crypt" + # rescue LoadError + # warn("Unable to load string/crypt, proceeding with deprecated use of String#crypt, consider using password_hash: :bcrypt") + # end + @password_hash = :crypt + when :crypt + # require "string/crypt" + when :bcrypt + require "bcrypt" + else + raise ArgumentError, "only :crypt and :bcrypt are supported for password_hash keyword argument" + end + + File.open(@path,"a").close unless File.exist?(@path) + reload + end + + ## + # Reload passwords from the database + + def reload + mtime = File::mtime(@path) + if mtime > @mtime + @passwd.clear + File.open(@path){|io| + while line = io.gets + line.chomp! + case line + when %r!\A[^:]+:[a-zA-Z0-9./]{13}\z! + if @password_hash == :bcrypt + raise StandardError, ".htpasswd file contains crypt password, only bcrypt passwords supported" + end + user, pass = line.split(":") + when %r!\A[^:]+:\$2[aby]\$\d{2}\$.{53}\z! + if @password_hash == :crypt + raise StandardError, ".htpasswd file contains bcrypt password, only crypt passwords supported" + end + user, pass = line.split(":") + when /:\$/, /:{SHA}/ + raise NotImplementedError, + 'MD5, SHA1 .htpasswd file not supported' + else + raise StandardError, 'bad .htpasswd file' + end + @passwd[user] = pass + end + } + @mtime = mtime + end + end + + ## + # Flush the password database. If +output+ is given the database will + # be written there instead of to the original path. + + def flush(output=nil) + output ||= @path + tmp = Tempfile.create("htpasswd", File::dirname(output)) + renamed = false + begin + each{|item| tmp.puts(item.join(":")) } + tmp.close + File::rename(tmp.path, output) + renamed = true + ensure + tmp.close + File.unlink(tmp.path) if !renamed + end + end + + ## + # Retrieves a password from the database for +user+ in +realm+. If + # +reload_db+ is true the database will be reloaded first. + + def get_passwd(realm, user, reload_db) + reload() if reload_db + @passwd[user] + end + + ## + # Sets a password in the database for +user+ in +realm+ to +pass+. + + def set_passwd(realm, user, pass) + if @password_hash == :bcrypt + # Cost of 5 to match Apache default, and because the + # bcrypt default of 10 will introduce significant delays + # for every request. + @passwd[user] = BCrypt::Password.create(pass, :cost=>5) + else + @passwd[user] = make_passwd(realm, user, pass) + end + end + + ## + # Removes a password from the database for +user+ in +realm+. + + def delete_passwd(realm, user) + @passwd.delete(user) + end + + ## + # Iterate passwords in the database. + + def each # :yields: [user, password] + @passwd.keys.sort.each{|user| + yield([user, @passwd[user]]) + } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/userdb.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/userdb.rb new file mode 100644 index 0000000..0d0f72b --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpauth/userdb.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +#-- +# httpauth/userdb.rb -- UserDB mix-in module. +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: userdb.rb,v 1.2 2003/02/20 07:15:48 gotoyuzo Exp $ + +module WEBrick + module HTTPAuth + + ## + # User database mixin for HTTPAuth. This mixin dispatches user record + # access to the underlying auth_type for this database. + + module UserDB + + ## + # The authentication type. + # + # WEBrick::HTTPAuth::BasicAuth or WEBrick::HTTPAuth::DigestAuth are + # built-in. + + attr_accessor :auth_type + + ## + # Creates an obscured password in +realm+ with +user+ and +password+ + # using the auth_type of this database. + + def make_passwd(realm, user, pass) + @auth_type::make_passwd(realm, user, pass) + end + + ## + # Sets a password in +realm+ with +user+ and +password+ for the + # auth_type of this database. + + def set_passwd(realm, user, pass) + self[user] = pass + end + + ## + # Retrieves a password in +realm+ for +user+ for the auth_type of this + # database. +reload_db+ is a dummy value. + + def get_passwd(realm, user, reload_db=false) + make_passwd(realm, user, self[user]) + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpproxy.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpproxy.rb new file mode 100644 index 0000000..196682e --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpproxy.rb @@ -0,0 +1,354 @@ +# frozen_string_literal: true +# +# httpproxy.rb -- HTTPProxy Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2002 GOTO Kentaro +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httpproxy.rb,v 1.18 2003/03/08 18:58:10 gotoyuzo Exp $ +# $kNotwork: straw.rb,v 1.3 2002/02/12 15:13:07 gotoken Exp $ + +require_relative "httpserver" +require "net/http" + +module WEBrick + + NullReader = Object.new # :nodoc: + class << NullReader # :nodoc: + def read(*args) + nil + end + alias gets read + end + + FakeProxyURI = Object.new # :nodoc: + class << FakeProxyURI # :nodoc: + def method_missing(meth, *args) + if %w(scheme host port path query userinfo).member?(meth.to_s) + return nil + end + super + end + end + + # :startdoc: + + ## + # An HTTP Proxy server which proxies GET, HEAD and POST requests. + # + # To create a simple proxy server: + # + # require 'webrick' + # require 'webrick/httpproxy' + # + # proxy = WEBrick::HTTPProxyServer.new Port: 8000 + # + # trap 'INT' do proxy.shutdown end + # trap 'TERM' do proxy.shutdown end + # + # proxy.start + # + # See ::new for proxy-specific configuration items. + # + # == Modifying proxied responses + # + # To modify content the proxy server returns use the +:ProxyContentHandler+ + # option: + # + # handler = proc do |req, res| + # if res['content-type'] == 'text/plain' then + # res.body << "\nThis content was proxied!\n" + # end + # end + # + # proxy = + # WEBrick::HTTPProxyServer.new Port: 8000, ProxyContentHandler: handler + + class HTTPProxyServer < HTTPServer + + ## + # Proxy server configurations. The proxy server handles the following + # configuration items in addition to those supported by HTTPServer: + # + # :ProxyAuthProc:: Called with a request and response to authorize a + # request + # :ProxyVia:: Appended to the via header + # :ProxyURI:: The proxy server's URI + # :ProxyContentHandler:: Called with a request and response and allows + # modification of the response + # :ProxyTimeout:: Sets the proxy timeouts to 30 seconds for open and 60 + # seconds for read operations + + def initialize(config={}, default=Config::HTTP) + super(config, default) + c = @config + @via = "#{c[:HTTPVersion]} #{c[:ServerName]}:#{c[:Port]}" + end + + # :stopdoc: + def service(req, res) + if req.request_method == "CONNECT" + do_CONNECT(req, res) + elsif req.unparsed_uri =~ %r!^http://! + proxy_service(req, res) + else + super(req, res) + end + end + + def proxy_auth(req, res) + if proc = @config[:ProxyAuthProc] + proc.call(req, res) + end + req.header.delete("proxy-authorization") + end + + def proxy_uri(req, res) + # should return upstream proxy server's URI + return @config[:ProxyURI] + end + + def proxy_service(req, res) + # Proxy Authentication + proxy_auth(req, res) + + begin + public_send("do_#{req.request_method}", req, res) + rescue NoMethodError + raise HTTPStatus::MethodNotAllowed, + "unsupported method `#{req.request_method}'." + rescue => err + logger.debug("#{err.class}: #{err.message}") + raise HTTPStatus::ServiceUnavailable, err.message + end + + # Process contents + if handler = @config[:ProxyContentHandler] + handler.call(req, res) + end + end + + def do_CONNECT(req, res) + # Proxy Authentication + proxy_auth(req, res) + + ua = Thread.current[:WEBrickSocket] # User-Agent + raise HTTPStatus::InternalServerError, + "[BUG] cannot get socket" unless ua + + host, port = req.unparsed_uri.split(":", 2) + # Proxy authentication for upstream proxy server + if proxy = proxy_uri(req, res) + proxy_request_line = "CONNECT #{host}:#{port} HTTP/1.0" + if proxy.userinfo + credentials = "Basic " + [proxy.userinfo].pack("m0") + end + host, port = proxy.host, proxy.port + end + + begin + @logger.debug("CONNECT: upstream proxy is `#{host}:#{port}'.") + os = TCPSocket.new(host, port) # origin server + + if proxy + @logger.debug("CONNECT: sending a Request-Line") + os << proxy_request_line << CRLF + @logger.debug("CONNECT: > #{proxy_request_line}") + if credentials + @logger.debug("CONNECT: sending credentials") + os << "Proxy-Authorization: " << credentials << CRLF + end + os << CRLF + proxy_status_line = os.gets(LF) + @logger.debug("CONNECT: read Status-Line from the upstream server") + @logger.debug("CONNECT: < #{proxy_status_line}") + if %r{^HTTP/\d+\.\d+\s+200\s*} =~ proxy_status_line + while line = os.gets(LF) + break if /\A(#{CRLF}|#{LF})\z/om =~ line + end + else + raise HTTPStatus::BadGateway + end + end + @logger.debug("CONNECT #{host}:#{port}: succeeded") + res.status = HTTPStatus::RC_OK + rescue => ex + @logger.debug("CONNECT #{host}:#{port}: failed `#{ex.message}'") + res.set_error(ex) + raise HTTPStatus::EOFError + ensure + if handler = @config[:ProxyContentHandler] + handler.call(req, res) + end + res.send_response(ua) + access_log(@config, req, res) + + # Should clear request-line not to send the response twice. + # see: HTTPServer#run + req.parse(NullReader) rescue nil + end + + begin + while fds = IO::select([ua, os]) + if fds[0].member?(ua) + buf = ua.readpartial(1024); + @logger.debug("CONNECT: #{buf.bytesize} byte from User-Agent") + os.write(buf) + elsif fds[0].member?(os) + buf = os.readpartial(1024); + @logger.debug("CONNECT: #{buf.bytesize} byte from #{host}:#{port}") + ua.write(buf) + end + end + rescue + os.close + @logger.debug("CONNECT #{host}:#{port}: closed") + end + + raise HTTPStatus::EOFError + end + + def do_GET(req, res) + perform_proxy_request(req, res, Net::HTTP::Get) + end + + def do_HEAD(req, res) + perform_proxy_request(req, res, Net::HTTP::Head) + end + + def do_POST(req, res) + perform_proxy_request(req, res, Net::HTTP::Post, req.body_reader) + end + + def do_OPTIONS(req, res) + res['allow'] = "GET,HEAD,POST,OPTIONS,CONNECT" + end + + private + + # Some header fields should not be transferred. + HopByHop = %w( connection keep-alive proxy-authenticate upgrade + proxy-authorization te trailers transfer-encoding ) + ShouldNotTransfer = %w( set-cookie proxy-connection ) + def split_field(f) f ? f.split(/,\s+/).collect{|i| i.downcase } : [] end + + def choose_header(src, dst) + connections = split_field(src['connection']) + src.each{|key, value| + key = key.downcase + if HopByHop.member?(key) || # RFC2616: 13.5.1 + connections.member?(key) || # RFC2616: 14.10 + ShouldNotTransfer.member?(key) # pragmatics + @logger.debug("choose_header: `#{key}: #{value}'") + next + end + dst[key] = value + } + end + + # Net::HTTP is stupid about the multiple header fields. + # Here is workaround: + def set_cookie(src, dst) + if str = src['set-cookie'] + cookies = [] + str.split(/,\s*/).each{|token| + if /^[^=]+;/o =~ token + cookies[-1] << ", " << token + elsif /=/o =~ token + cookies << token + else + cookies[-1] << ", " << token + end + } + dst.cookies.replace(cookies) + end + end + + def set_via(h) + if @config[:ProxyVia] + if h['via'] + h['via'] << ", " << @via + else + h['via'] = @via + end + end + end + + def setup_proxy_header(req, res) + # Choose header fields to transfer + header = Hash.new + choose_header(req, header) + set_via(header) + return header + end + + def setup_upstream_proxy_authentication(req, res, header) + if upstream = proxy_uri(req, res) + if upstream.userinfo + header['proxy-authorization'] = + "Basic " + [upstream.userinfo].pack("m0") + end + return upstream + end + return FakeProxyURI + end + + def create_net_http(uri, upstream) + Net::HTTP.new(uri.host, uri.port, upstream.host, upstream.port) + end + + def perform_proxy_request(req, res, req_class, body_stream = nil) + uri = req.request_uri + path = uri.path.dup + path << "?" << uri.query if uri.query + header = setup_proxy_header(req, res) + upstream = setup_upstream_proxy_authentication(req, res, header) + + body_tmp = [] + http = create_net_http(uri, upstream) + req_fib = Fiber.new do + http.start do + if @config[:ProxyTimeout] + ################################## these issues are + http.open_timeout = 30 # secs # necessary (maybe because + http.read_timeout = 60 # secs # Ruby's bug, but why?) + ################################## + end + if body_stream && req['transfer-encoding'] =~ /\bchunked\b/i + header['Transfer-Encoding'] = 'chunked' + end + http_req = req_class.new(path, header) + http_req.body_stream = body_stream if body_stream + http.request(http_req) do |response| + # Persistent connection requirements are mysterious for me. + # So I will close the connection in every response. + res['proxy-connection'] = "close" + res['connection'] = "close" + + # stream Net::HTTP::HTTPResponse to WEBrick::HTTPResponse + res.status = response.code.to_i + res.chunked = response.chunked? + choose_header(response, res) + set_cookie(response, res) + set_via(res) + response.read_body do |buf| + body_tmp << buf + Fiber.yield # wait for res.body Proc#call + end + end # http.request + end + end + req_fib.resume # read HTTP response headers and first chunk of the body + res.body = ->(socket) do + while buf = body_tmp.shift + socket.write(buf) + buf.clear + req_fib.resume # continue response.read_body + end + end + end + # :stopdoc: + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httprequest.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httprequest.rb new file mode 100644 index 0000000..680ac65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httprequest.rb @@ -0,0 +1,640 @@ +# frozen_string_literal: true +# +# httprequest.rb -- HTTPRequest Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httprequest.rb,v 1.64 2003/07/13 17:18:22 gotoyuzo Exp $ + +require 'fiber' +require 'uri' +require_relative 'httpversion' +require_relative 'httpstatus' +require_relative 'httputils' +require_relative 'cookie' + +module WEBrick + + ## + # An HTTP request. This is consumed by service and do_* methods in + # WEBrick servlets + + class HTTPRequest + + BODY_CONTAINABLE_METHODS = [ "POST", "PUT" ] # :nodoc: + + # :section: Request line + + ## + # The complete request line such as: + # + # GET / HTTP/1.1 + + attr_reader :request_line + + ## + # The request method, GET, POST, PUT, etc. + + attr_reader :request_method + + ## + # The unparsed URI of the request + + attr_reader :unparsed_uri + + ## + # The HTTP version of the request + + attr_reader :http_version + + # :section: Request-URI + + ## + # The parsed URI of the request + + attr_reader :request_uri + + ## + # The request path + + attr_reader :path + + ## + # The script name (CGI variable) + + attr_accessor :script_name + + ## + # The path info (CGI variable) + + attr_accessor :path_info + + ## + # The query from the URI of the request + + attr_accessor :query_string + + # :section: Header and entity body + + ## + # The raw header of the request + + attr_reader :raw_header + + ## + # The parsed header of the request + + attr_reader :header + + ## + # The parsed request cookies + + attr_reader :cookies + + ## + # The Accept header value + + attr_reader :accept + + ## + # The Accept-Charset header value + + attr_reader :accept_charset + + ## + # The Accept-Encoding header value + + attr_reader :accept_encoding + + ## + # The Accept-Language header value + + attr_reader :accept_language + + # :section: + + ## + # The remote user (CGI variable) + + attr_accessor :user + + ## + # The socket address of the server + + attr_reader :addr + + ## + # The socket address of the client + + attr_reader :peeraddr + + ## + # Hash of request attributes + + attr_reader :attributes + + ## + # Is this a keep-alive connection? + + attr_reader :keep_alive + + ## + # The local time this request was received + + attr_reader :request_time + + ## + # Creates a new HTTP request. WEBrick::Config::HTTP is the default + # configuration. + + def initialize(config) + @config = config + @buffer_size = @config[:InputBufferSize] + @logger = config[:Logger] + + @request_line = @request_method = + @unparsed_uri = @http_version = nil + + @request_uri = @host = @port = @path = nil + @script_name = @path_info = nil + @query_string = nil + @query = nil + @form_data = nil + + @raw_header = Array.new + @header = nil + @cookies = [] + @accept = [] + @accept_charset = [] + @accept_encoding = [] + @accept_language = [] + @body = +"" + + @addr = @peeraddr = nil + @attributes = {} + @user = nil + @keep_alive = false + @request_time = nil + + @remaining_size = nil + @socket = nil + + @forwarded_proto = @forwarded_host = @forwarded_port = + @forwarded_server = @forwarded_for = nil + end + + ## + # Parses a request from +socket+. This is called internally by + # WEBrick::HTTPServer. + + def parse(socket=nil) + @socket = socket + begin + @peeraddr = socket.respond_to?(:peeraddr) ? socket.peeraddr : [] + @addr = socket.respond_to?(:addr) ? socket.addr : [] + rescue Errno::ENOTCONN + raise HTTPStatus::EOFError + end + + read_request_line(socket) + if @http_version.major > 0 + read_header(socket) + @header['cookie'].each{|cookie| + @cookies += Cookie::parse(cookie) + } + @accept = HTTPUtils.parse_qvalues(self['accept']) + @accept_charset = HTTPUtils.parse_qvalues(self['accept-charset']) + @accept_encoding = HTTPUtils.parse_qvalues(self['accept-encoding']) + @accept_language = HTTPUtils.parse_qvalues(self['accept-language']) + end + return if @request_method == "CONNECT" + return if @unparsed_uri == "*" + + begin + setup_forwarded_info + @request_uri = parse_uri(@unparsed_uri) + @path = HTTPUtils::unescape(@request_uri.path) + @path = HTTPUtils::normalize_path(@path) + @host = @request_uri.host + @port = @request_uri.port + @query_string = @request_uri.query + @script_name = "" + @path_info = @path.dup + rescue + raise HTTPStatus::BadRequest, "bad URI `#{@unparsed_uri}'." + end + + if /\Aclose\z/io =~ self["connection"] + @keep_alive = false + elsif /\Akeep-alive\z/io =~ self["connection"] + @keep_alive = true + elsif @http_version < "1.1" + @keep_alive = false + else + @keep_alive = true + end + end + + ## + # Generate HTTP/1.1 100 continue response if the client expects it, + # otherwise does nothing. + + def continue # :nodoc: + if self['expect'] == '100-continue' && @config[:HTTPVersion] >= "1.1" + @socket << "HTTP/#{@config[:HTTPVersion]} 100 continue#{CRLF}#{CRLF}" + @header.delete('expect') + end + end + + ## + # Returns the request body. + + def body(&block) # :yields: body_chunk + block ||= Proc.new{|chunk| @body << chunk } + read_body(@socket, block) + @body.empty? ? nil : @body + end + + ## + # Prepares the HTTPRequest object for use as the + # source for IO.copy_stream + + def body_reader + @body_tmp = [] + @body_rd = Fiber.new do + body do |buf| + @body_tmp << buf + Fiber.yield + end + end + @body_rd.resume # grab the first chunk and yield + self + end + + # for IO.copy_stream. + def readpartial(size, buf = ''.b) # :nodoc + res = @body_tmp.shift or raise EOFError, 'end of file reached' + if res.length > size + @body_tmp.unshift(res[size..-1]) + res = res[0..size - 1] + end + buf.replace(res) + res.clear + # get more chunks - check alive? because we can take a partial chunk + @body_rd.resume if @body_rd.alive? + buf + end + + ## + # Request query as a Hash + + def query + unless @query + parse_query() + end + @query + end + + ## + # The content-length header + + def content_length + return Integer(self['content-length']) + end + + ## + # The content-type header + + def content_type + return self['content-type'] + end + + ## + # Retrieves +header_name+ + + def [](header_name) + if @header + value = @header[header_name.downcase] + value.empty? ? nil : value.join(", ") + end + end + + ## + # Iterates over the request headers + + def each + if @header + @header.each{|k, v| + value = @header[k] + yield(k, value.empty? ? nil : value.join(", ")) + } + end + end + + ## + # The host this request is for + + def host + return @forwarded_host || @host + end + + ## + # The port this request is for + + def port + return @forwarded_port || @port + end + + ## + # The server name this request is for + + def server_name + return @forwarded_server || @config[:ServerName] + end + + ## + # The client's IP address + + def remote_ip + return self["client-ip"] || @forwarded_for || @peeraddr[3] + end + + ## + # Is this an SSL request? + + def ssl? + return @request_uri.scheme == "https" + end + + ## + # Should the connection this request was made on be kept alive? + + def keep_alive? + @keep_alive + end + + def to_s # :nodoc: + ret = @request_line.dup + @raw_header.each{|line| ret << line } + ret << CRLF + ret << body if body + ret + end + + ## + # Consumes any remaining body and updates keep-alive status + + def fixup() # :nodoc: + begin + body{|chunk| } # read remaining body + rescue HTTPStatus::Error => ex + @logger.error("HTTPRequest#fixup: #{ex.class} occurred.") + @keep_alive = false + rescue => ex + @logger.error(ex) + @keep_alive = false + end + end + + # This method provides the metavariables defined by the revision 3 + # of "The WWW Common Gateway Interface Version 1.1" + # To browse the current document of CGI Version 1.1, see below: + # http://tools.ietf.org/html/rfc3875 + + def meta_vars + meta = Hash.new + + cl = self["Content-Length"] + ct = self["Content-Type"] + meta["CONTENT_LENGTH"] = cl if cl.to_i > 0 + meta["CONTENT_TYPE"] = ct.dup if ct + meta["GATEWAY_INTERFACE"] = "CGI/1.1" + meta["PATH_INFO"] = @path_info ? @path_info.dup : "" + #meta["PATH_TRANSLATED"] = nil # no plan to be provided + meta["QUERY_STRING"] = @query_string ? @query_string.dup : "" + meta["REMOTE_ADDR"] = @peeraddr[3] + meta["REMOTE_HOST"] = @peeraddr[2] + #meta["REMOTE_IDENT"] = nil # no plan to be provided + meta["REMOTE_USER"] = @user + meta["REQUEST_METHOD"] = @request_method.dup + meta["REQUEST_URI"] = @request_uri.to_s + meta["SCRIPT_NAME"] = @script_name.dup + meta["SERVER_NAME"] = @host + meta["SERVER_PORT"] = @port.to_s + meta["SERVER_PROTOCOL"] = "HTTP/" + @config[:HTTPVersion].to_s + meta["SERVER_SOFTWARE"] = @config[:ServerSoftware].dup + + self.each{|key, val| + next if /^content-type$/i =~ key + next if /^content-length$/i =~ key + name = "HTTP_" + key + name.gsub!(/-/o, "_") + name.upcase! + meta[name] = val + } + + meta + end + + private + + # :stopdoc: + + MAX_URI_LENGTH = 2083 # :nodoc: + + # same as Mongrel, Thin and Puma + MAX_HEADER_LENGTH = (112 * 1024) # :nodoc: + + def read_request_line(socket) + @request_line = read_line(socket, MAX_URI_LENGTH) if socket + raise HTTPStatus::EOFError unless @request_line + + @request_bytes = @request_line.bytesize + if @request_bytes >= MAX_URI_LENGTH and @request_line[-1, 1] != LF + raise HTTPStatus::RequestURITooLarge + end + + @request_time = Time.now + if /^(\S+)\s+(\S++)(?:\s+HTTP\/(\d+\.\d+))?\r?\n/mo =~ @request_line + @request_method = $1 + @unparsed_uri = $2 + @http_version = HTTPVersion.new($3 ? $3 : "0.9") + else + rl = @request_line.sub(/\x0d?\x0a\z/o, '') + raise HTTPStatus::BadRequest, "bad Request-Line `#{rl}'." + end + end + + def read_header(socket) + if socket + while line = read_line(socket) + break if /\A(#{CRLF}|#{LF})\z/om =~ line + if (@request_bytes += line.bytesize) > MAX_HEADER_LENGTH + raise HTTPStatus::RequestEntityTooLarge, 'headers too large' + end + @raw_header << line + end + end + @header = HTTPUtils::parse_header(@raw_header.join) + end + + def parse_uri(str, scheme="http") + if @config[:Escape8bitURI] + str = HTTPUtils::escape8bit(str) + end + str.sub!(%r{\A/+}o, '/') + uri = URI::parse(str) + return uri if uri.absolute? + if @forwarded_host + host, port = @forwarded_host, @forwarded_port + elsif self["host"] + host, port = parse_host_request_line(self["host"]) + elsif @addr.size > 0 + host, port = @addr[2], @addr[1] + else + host, port = @config[:ServerName], @config[:Port] + end + uri.scheme = @forwarded_proto || scheme + uri.host = host + uri.port = port ? port.to_i : nil + return URI::parse(uri.to_s) + end + + def parse_host_request_line(host) + pattern = /\A(#{URI::REGEXP::PATTERN::HOST})(?::(\d+))?\z/no + host.scan(pattern)[0] + end + + def read_body(socket, block) + return unless socket + if tc = self['transfer-encoding'] + case tc + when /\Achunked\z/io then read_chunked(socket, block) + else raise HTTPStatus::NotImplemented, "Transfer-Encoding: #{tc}." + end + elsif self['content-length'] || @remaining_size + @remaining_size ||= self['content-length'].to_i + while @remaining_size > 0 + sz = [@buffer_size, @remaining_size].min + break unless buf = read_data(socket, sz) + @remaining_size -= buf.bytesize + block.call(buf) + end + if @remaining_size > 0 && @socket.eof? + raise HTTPStatus::BadRequest, "invalid body size." + end + elsif BODY_CONTAINABLE_METHODS.member?(@request_method) + raise HTTPStatus::LengthRequired + end + return @body + end + + def read_chunk_size(socket) + line = read_line(socket) + if /^([0-9a-fA-F]+)(?:;(\S+))?/ =~ line + chunk_size = $1.hex + chunk_ext = $2 + [ chunk_size, chunk_ext ] + else + raise HTTPStatus::BadRequest, "bad chunk `#{line}'." + end + end + + def read_chunked(socket, block) + chunk_size, = read_chunk_size(socket) + while chunk_size > 0 + begin + sz = [ chunk_size, @buffer_size ].min + data = read_data(socket, sz) # read chunk-data + if data.nil? || data.bytesize != sz + raise HTTPStatus::BadRequest, "bad chunk data size." + end + block.call(data) + end while (chunk_size -= sz) > 0 + + read_line(socket) # skip CRLF + chunk_size, = read_chunk_size(socket) + end + read_header(socket) # trailer + CRLF + @header.delete("transfer-encoding") + @remaining_size = 0 + end + + def _read_data(io, method, *arg) + begin + WEBrick::Utils.timeout(@config[:RequestTimeout]){ + return io.__send__(method, *arg) + } + rescue Errno::ECONNRESET + return nil + rescue Timeout::Error + raise HTTPStatus::RequestTimeout + end + end + + def read_line(io, size=4096) + _read_data(io, :gets, LF, size) + end + + def read_data(io, size) + _read_data(io, :read, size) + end + + def parse_query() + begin + if @request_method == "GET" || @request_method == "HEAD" + @query = HTTPUtils::parse_query(@query_string) + elsif self['content-type'] =~ /^application\/x-www-form-urlencoded/ + @query = HTTPUtils::parse_query(body) + elsif self['content-type'] =~ /^multipart\/form-data; boundary=(.+)/ + boundary = HTTPUtils::dequote($1) + @query = HTTPUtils::parse_form_data(body, boundary) + else + @query = Hash.new + end + rescue => ex + raise HTTPStatus::BadRequest, ex.message + end + end + + PrivateNetworkRegexp = / + ^unknown$| + ^((::ffff:)?127.0.0.1|::1)$| + ^(::ffff:)?(10|172\.(1[6-9]|2[0-9]|3[01])|192\.168)\. + /ixo + + # It's said that all X-Forwarded-* headers will contain more than one + # (comma-separated) value if the original request already contained one of + # these headers. Since we could use these values as Host header, we choose + # the initial(first) value. (apr_table_mergen() adds new value after the + # existing value with ", " prefix) + def setup_forwarded_info + if @forwarded_server = self["x-forwarded-server"] + @forwarded_server = @forwarded_server.split(",", 2).first + end + if @forwarded_proto = self["x-forwarded-proto"] + @forwarded_proto = @forwarded_proto.split(",", 2).first + end + if host_port = self["x-forwarded-host"] + host_port = host_port.split(",", 2).first + if host_port =~ /\A(\[[0-9a-fA-F:]+\])(?::(\d+))?\z/ + @forwarded_host = $1 + tmp = $2 + else + @forwarded_host, tmp = host_port.split(":", 2) + end + @forwarded_port = (tmp || (@forwarded_proto == "https" ? 443 : 80)).to_i + end + if addrs = self["x-forwarded-for"] + addrs = addrs.split(",").collect(&:strip) + addrs.reject!{|ip| PrivateNetworkRegexp =~ ip } + @forwarded_for = addrs.first + end + end + + # :startdoc: + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpresponse.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpresponse.rb new file mode 100644 index 0000000..dde0261 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpresponse.rb @@ -0,0 +1,588 @@ +# frozen_string_literal: true +# +# httpresponse.rb -- HTTPResponse Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httpresponse.rb,v 1.45 2003/07/11 11:02:25 gotoyuzo Exp $ + +require 'time' +require 'uri' +require_relative 'httpversion' +require_relative 'htmlutils' +require_relative 'httputils' +require_relative 'httpstatus' + +module WEBrick + ## + # An HTTP response. This is filled in by the service or do_* methods of a + # WEBrick HTTP Servlet. + + class HTTPResponse + class InvalidHeader < StandardError + end + + ## + # HTTP Response version + + attr_reader :http_version + + ## + # Response status code (200) + + attr_reader :status + + ## + # Response header + + attr_reader :header + + ## + # Response cookies + + attr_reader :cookies + + ## + # Response reason phrase ("OK") + + attr_accessor :reason_phrase + + ## + # Body may be: + # * a String; + # * an IO-like object that responds to +#read+ and +#readpartial+; + # * a Proc-like object that responds to +#call+. + # + # In the latter case, either #chunked= should be set to +true+, + # or header['content-length'] explicitly provided. + # Example: + # + # server.mount_proc '/' do |req, res| + # res.chunked = true + # # or + # # res.header['content-length'] = 10 + # res.body = proc { |out| out.write(Time.now.to_s) } + # end + + attr_accessor :body + + ## + # Request method for this response + + attr_accessor :request_method + + ## + # Request URI for this response + + attr_accessor :request_uri + + ## + # Request HTTP version for this response + + attr_accessor :request_http_version + + ## + # Filename of the static file in this response. Only used by the + # FileHandler servlet. + + attr_accessor :filename + + ## + # Is this a keep-alive response? + + attr_accessor :keep_alive + + ## + # Configuration for this response + + attr_reader :config + + ## + # Bytes sent in this response + + attr_reader :sent_size + + ## + # Set the response body proc as an streaming/upgrade response. + + attr_accessor :upgrade + + ## + # Creates a new HTTP response object. WEBrick::Config::HTTP is the + # default configuration. + + def initialize(config) + @config = config + @buffer_size = config[:OutputBufferSize] + @logger = config[:Logger] + @header = Hash.new + @status = HTTPStatus::RC_OK + @reason_phrase = nil + @http_version = HTTPVersion::convert(@config[:HTTPVersion]) + @body = +"" + @keep_alive = true + @cookies = [] + @request_method = nil + @request_uri = nil + @request_http_version = @http_version # temporary + @chunked = false + @filename = nil + @sent_size = 0 + @bodytempfile = nil + end + + ## + # The response's HTTP status line + + def status_line + "HTTP/#@http_version #@status #@reason_phrase".rstrip << CRLF + end + + ## + # Sets the response's status to the +status+ code + + def status=(status) + @status = status + @reason_phrase = HTTPStatus::reason_phrase(status) + end + + ## + # Retrieves the response header +field+ + + def [](field) + @header[field.downcase] + end + + ## + # Sets the response header +field+ to +value+ + + def []=(field, value) + @chunked = value.to_s.downcase == 'chunked' if field.downcase == 'transfer-encoding' + @header[field.downcase] = value.to_s + end + + ## + # The content-length header + + def content_length + if len = self['content-length'] + return Integer(len) + end + end + + ## + # Sets the content-length header to +len+ + + def content_length=(len) + self['content-length'] = len.to_s + end + + ## + # The content-type header + + def content_type + self['content-type'] + end + + ## + # Sets the content-type header to +type+ + + def content_type=(type) + self['content-type'] = type + end + + ## + # Iterates over each header in the response + + def each + @header.each{|field, value| yield(field, value) } + end + + ## + # Will this response body be returned using chunked transfer-encoding? + + def chunked? + @chunked + end + + ## + # Enables chunked transfer encoding. + + def chunked=(val) + @chunked = val ? true : false + end + + ## + # Will this response's connection be kept alive? + + def keep_alive? + @keep_alive + end + + ## + # Sets the response to be a streaming/upgrade response. + # This will disable keep-alive and chunked transfer encoding. + + def upgrade!(protocol) + @upgrade = protocol + @keep_alive = false + @chunked = false + end + + ## + # Sends the response on +socket+ + + def send_response(socket) # :nodoc: + begin + setup_header() + send_header(socket) + send_body(socket) + rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ENOTCONN => ex + @logger.debug(ex) + @keep_alive = false + rescue Exception => ex + @logger.error(ex) + @keep_alive = false + end + end + + ## + # Sets up the headers for sending + + def setup_header() # :nodoc: + @reason_phrase ||= HTTPStatus::reason_phrase(@status) + @header['server'] ||= @config[:ServerSoftware] + @header['date'] ||= Time.now.httpdate + + if @upgrade + @header['connection'] = 'upgrade' + @header['upgrade'] = @upgrade + @keep_alive = false + + return + end + + # HTTP/0.9 features + if @request_http_version < "1.0" + @http_version = HTTPVersion.new("0.9") + @keep_alive = false + end + + # HTTP/1.0 features + if @request_http_version < "1.1" + if chunked? + @chunked = false + ver = @request_http_version.to_s + msg = "chunked is set for an HTTP/#{ver} request. (ignored)" + @logger.warn(msg) + end + end + + # Determine the message length (RFC2616 -- 4.4 Message Length) + if @status == 304 || @status == 204 || HTTPStatus::info?(@status) + @header.delete('content-length') + @body = "" + elsif chunked? + @header["transfer-encoding"] = "chunked" + @header.delete('content-length') + elsif %r{^multipart/byteranges} =~ @header['content-type'] + @header.delete('content-length') + elsif @header['content-length'].nil? + if @body.respond_to?(:bytesize) + @header['content-length'] = @body.bytesize.to_s + else + @header['connection'] = 'close' + end + end + + # Keep-Alive connection. + if @header['connection'] == "close" + @keep_alive = false + elsif keep_alive? + if chunked? || @header['content-length'] || @status == 304 || @status == 204 || HTTPStatus.info?(@status) + @header['connection'] = "Keep-Alive" + else + msg = "Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true" + @logger.warn(msg) + @header['connection'] = "close" + @keep_alive = false + end + else + @header['connection'] = "close" + end + + # Location is a single absoluteURI. + if location = @header['location'] + if @request_uri + @header['location'] = @request_uri.merge(location).to_s + end + end + end + + def make_body_tempfile # :nodoc: + return if @bodytempfile + bodytempfile = Tempfile.create("webrick") + if @body.nil? + # nothing + elsif @body.respond_to? :readpartial + IO.copy_stream(@body, bodytempfile) + @body.close + elsif @body.respond_to? :call + @body.call(bodytempfile) + else + bodytempfile.write @body + end + bodytempfile.rewind + @body = @bodytempfile = bodytempfile + @header['content-length'] = bodytempfile.stat.size.to_s + end + + def remove_body_tempfile # :nodoc: + if @bodytempfile + @bodytempfile.close + File.unlink @bodytempfile.path + @bodytempfile = nil + end + end + + + ## + # Sends the headers on +socket+ + + def send_header(socket) # :nodoc: + if @http_version.major > 0 + data = status_line().dup + @header.each{|key, value| + tmp = key.gsub(/\bwww|^te$|\b\w/){ $&.upcase } + data << "#{tmp}: #{check_header(value)}" << CRLF + } + @cookies.each{|cookie| + data << "Set-Cookie: " << check_header(cookie.to_s) << CRLF + } + data << CRLF + socket.write(data) + end + rescue InvalidHeader => e + @header.clear + @cookies.clear + set_error e + retry + end + + ## + # Sends the body on +socket+ + + def send_body(socket) # :nodoc: + if @body.respond_to? :readpartial then + send_body_io(socket) + elsif @body.respond_to?(:call) then + send_body_proc(socket) + else + send_body_string(socket) + end + end + + ## + # Redirects to +url+ with a WEBrick::HTTPStatus::Redirect +status+. + # + # Example: + # + # res.set_redirect WEBrick::HTTPStatus::TemporaryRedirect + + def set_redirect(status, url) + url = URI(url).to_s + @body = "#{url}.\n" + @header['location'] = url + raise status + end + + ## + # Creates an error page for exception +ex+ with an optional +backtrace+ + + def set_error(ex, backtrace=false) + case ex + when HTTPStatus::Status + @keep_alive = false if HTTPStatus::error?(ex.code) + self.status = ex.code + else + @keep_alive = false + self.status = HTTPStatus::RC_INTERNAL_SERVER_ERROR + end + @header['content-type'] = "text/html; charset=ISO-8859-1" + + if respond_to?(:create_error_page) + create_error_page() + return + end + + if @request_uri + host, port = @request_uri.host, @request_uri.port + else + host, port = @config[:ServerName], @config[:Port] + end + + error_body(backtrace, ex, host, port) + end + + private + + def check_header(header_value) + header_value = header_value.to_s + if /[\r\n]/ =~ header_value + raise InvalidHeader + else + header_value + end + end + + # :stopdoc: + + def error_body(backtrace, ex, host, port) + @body = +"" + @body << <<-_end_of_html_ + + + #{HTMLUtils::escape(@reason_phrase)} + +

    #{HTMLUtils::escape(@reason_phrase)}

    + #{HTMLUtils::escape(ex.message)} +
    + _end_of_html_ + + if backtrace && $DEBUG + @body << "backtrace of `#{HTMLUtils::escape(ex.class.to_s)}' " + @body << "#{HTMLUtils::escape(ex.message)}" + @body << "
    "
    +        ex.backtrace.each{|line| @body << "\t#{line}\n"}
    +        @body << "

    " + end + + @body << <<-_end_of_html_ +
    + #{HTMLUtils::escape(@config[:ServerSoftware])} at + #{host}:#{port} +
    + + + _end_of_html_ + end + + def send_body_io(socket) + begin + if @request_method == "HEAD" + # do nothing + elsif chunked? + buf = +'' + begin + @body.readpartial(@buffer_size, buf) + size = buf.bytesize + data = +"#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}" + socket.write(data) + data.clear + @sent_size += size + rescue EOFError + break + end while true + buf.clear + socket.write("0#{CRLF}#{CRLF}") + else + if %r{\Abytes (\d+)-(\d+)/\d+\z} =~ @header['content-range'] + offset = $1.to_i + size = $2.to_i - offset + 1 + else + offset = nil + size = @header['content-length'] + size = size.to_i if size + end + begin + @sent_size = IO.copy_stream(@body, socket, size, offset) + rescue NotImplementedError + @body.seek(offset, IO::SEEK_SET) + @sent_size = IO.copy_stream(@body, socket, size) + end + end + ensure + @body.close + end + remove_body_tempfile + end + + def send_body_string(socket) + if @request_method == "HEAD" + # do nothing + elsif chunked? + body ? @body.bytesize : 0 + while buf = @body[@sent_size, @buffer_size] + break if buf.empty? + size = buf.bytesize + data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}" + buf.clear + socket.write(data) + @sent_size += size + end + socket.write("0#{CRLF}#{CRLF}") + else + if @body && @body.bytesize > 0 + socket.write(@body) + @sent_size = @body.bytesize + end + end + end + + def send_body_proc(socket) + if @request_method == "HEAD" + # do nothing + elsif chunked? + @body.call(ChunkedWrapper.new(socket, self)) + socket.write("0#{CRLF}#{CRLF}") + else + if @bodytempfile + @bodytempfile.rewind + IO.copy_stream(@bodytempfile, socket) + else + @body.call(socket) + end + + if content_length = @header['content-length'] + @sent_size = content_length.to_i + end + end + end + + class ChunkedWrapper + def initialize(socket, resp) + @socket = socket + @resp = resp + end + + def write(buf) + return 0 if buf.empty? + socket = @socket + @resp.instance_eval { + size = buf.bytesize + data = +"#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}" + socket.write(data) + data.clear + @sent_size += size + size + } + end + + def <<(*buf) + write(buf) + self + end + end + + # preserved for compatibility with some 3rd-party handlers + def _write_data(socket, data) + socket << data + end + + # :startdoc: + end + +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/https.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/https.rb new file mode 100644 index 0000000..7f00b30 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/https.rb @@ -0,0 +1,152 @@ +# frozen_string_literal: true +# +# https.rb -- SSL/TLS enhancement for HTTPServer +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2001 GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: https.rb,v 1.15 2003/07/22 19:20:42 gotoyuzo Exp $ + +require_relative 'ssl' +require_relative 'httpserver' + +module WEBrick + module Config + HTTP.update(SSL) + end + + ## + #-- + # Adds SSL functionality to WEBrick::HTTPRequest + + class HTTPRequest + + ## + # HTTP request SSL cipher + + attr_reader :cipher + + ## + # HTTP request server certificate + + attr_reader :server_cert + + ## + # HTTP request client certificate + + attr_reader :client_cert + + # :stopdoc: + + alias orig_parse parse + + def parse(socket=nil) + if socket.respond_to?(:cert) + @server_cert = socket.cert || @config[:SSLCertificate] + @client_cert = socket.peer_cert + @client_cert_chain = socket.peer_cert_chain + @cipher = socket.cipher + end + orig_parse(socket) + end + + alias orig_parse_uri parse_uri + + def parse_uri(str, scheme="https") + if server_cert + return orig_parse_uri(str, scheme) + end + return orig_parse_uri(str) + end + private :parse_uri + + alias orig_meta_vars meta_vars + + def meta_vars + meta = orig_meta_vars + if server_cert + meta["HTTPS"] = "on" + meta["SSL_SERVER_CERT"] = @server_cert.to_pem + meta["SSL_CLIENT_CERT"] = @client_cert ? @client_cert.to_pem : "" + if @client_cert_chain + @client_cert_chain.each_with_index{|cert, i| + meta["SSL_CLIENT_CERT_CHAIN_#{i}"] = cert.to_pem + } + end + meta["SSL_CIPHER"] = @cipher[0] + meta["SSL_PROTOCOL"] = @cipher[1] + meta["SSL_CIPHER_USEKEYSIZE"] = @cipher[2].to_s + meta["SSL_CIPHER_ALGKEYSIZE"] = @cipher[3].to_s + end + meta + end + + # :startdoc: + end + + ## + #-- + # Fake WEBrick::HTTPRequest for lookup_server + + class SNIRequest + + ## + # The SNI hostname + + attr_reader :host + + ## + # The socket address of the server + + attr_reader :addr + + ## + # The port this request is for + + attr_reader :port + + ## + # Creates a new SNIRequest. + + def initialize(sslsocket, hostname) + @host = hostname + @addr = sslsocket.addr + @port = @addr[1] + end + end + + + ## + #-- + # Adds SSL functionality to WEBrick::HTTPServer + + class HTTPServer < ::WEBrick::GenericServer + ## + # ServerNameIndication callback + + def ssl_servername_callback(sslsocket, hostname = nil) + req = SNIRequest.new(sslsocket, hostname) + server = lookup_server(req) + server ? server.ssl_context : nil + end + + # :stopdoc: + + ## + # Check whether +server+ is also SSL server. + # Also +server+'s SSL context will be created. + + alias orig_virtual_host virtual_host + + def virtual_host(server) + if @config[:SSLEnable] && !server.ssl_context + raise ArgumentError, "virtual host must set SSLEnable to true" + end + orig_virtual_host(server) + end + + # :startdoc: + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb new file mode 100644 index 0000000..0d261bf --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb @@ -0,0 +1,294 @@ +# frozen_string_literal: true +# +# httpserver.rb -- HTTPServer Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httpserver.rb,v 1.63 2002/10/01 17:16:32 gotoyuzo Exp $ + +require 'io/wait' +require_relative 'server' +require_relative 'httputils' +require_relative 'httpstatus' +require_relative 'httprequest' +require_relative 'httpresponse' +require_relative 'httpservlet' +require_relative 'accesslog' + +module WEBrick + class HTTPServerError < ServerError; end + + ## + # An HTTP Server + + class HTTPServer < ::WEBrick::GenericServer + ## + # Creates a new HTTP server according to +config+ + # + # An HTTP server uses the following attributes: + # + # :AccessLog:: An array of access logs. See WEBrick::AccessLog + # :BindAddress:: Local address for the server to bind to + # :DocumentRoot:: Root path to serve files from + # :DocumentRootOptions:: Options for the default HTTPServlet::FileHandler + # :HTTPVersion:: The HTTP version of this server + # :Port:: Port to listen on + # :RequestCallback:: Called with a request and response before each + # request is serviced. + # :RequestTimeout:: Maximum time to wait between requests + # :ServerAlias:: Array of alternate names for this server for virtual + # hosting + # :ServerName:: Name for this server for virtual hosting + + def initialize(config={}, default=Config::HTTP) + super(config, default) + @http_version = HTTPVersion::convert(@config[:HTTPVersion]) + + @mount_tab = MountTable.new + if @config[:DocumentRoot] + mount("/", HTTPServlet::FileHandler, @config[:DocumentRoot], + @config[:DocumentRootOptions]) + end + + unless @config[:AccessLog] + @config[:AccessLog] = [ + [ $stderr, AccessLog::COMMON_LOG_FORMAT ], + [ $stderr, AccessLog::REFERER_LOG_FORMAT ] + ] + end + + @virtual_hosts = Array.new + end + + ## + # Processes requests on +sock+ + + def run(sock) + while true + req = create_request(@config) + res = create_response(@config) + server = self + begin + timeout = @config[:RequestTimeout] + while timeout > 0 + break if sock.to_io.wait_readable(0.5) + break if @status != :Running + timeout -= 0.5 + end + raise HTTPStatus::EOFError if timeout <= 0 || @status != :Running + raise HTTPStatus::EOFError if sock.eof? + req.parse(sock) + res.request_method = req.request_method + res.request_uri = req.request_uri + res.request_http_version = req.http_version + res.keep_alive = req.keep_alive? + server = lookup_server(req) || self + if callback = server[:RequestCallback] + callback.call(req, res) + elsif callback = server[:RequestHandler] + msg = ":RequestHandler is deprecated, please use :RequestCallback" + @logger.warn(msg) + callback.call(req, res) + end + server.service(req, res) + rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex + res.set_error(ex) + rescue HTTPStatus::Error => ex + @logger.error(ex.message) + res.set_error(ex) + rescue HTTPStatus::Status => ex + res.status = ex.code + rescue StandardError => ex + @logger.error(ex) + res.set_error(ex, true) + ensure + if req.request_line + if req.keep_alive? && res.keep_alive? + req.fixup() + end + res.send_response(sock) + server.access_log(@config, req, res) + end + end + break if @http_version < "1.1" + break unless req.keep_alive? + break unless res.keep_alive? + end + end + + ## + # Services +req+ and fills in +res+ + + def service(req, res) + if req.unparsed_uri == "*" + if req.request_method == "OPTIONS" + do_OPTIONS(req, res) + raise HTTPStatus::OK + end + raise HTTPStatus::NotFound, "`#{req.unparsed_uri}' not found." + end + + servlet, options, script_name, path_info = search_servlet(req.path) + raise HTTPStatus::NotFound, "`#{req.path}' not found." unless servlet + req.script_name = script_name + req.path_info = path_info + si = servlet.get_instance(self, *options) + @logger.debug(format("%s is invoked.", si.class.name)) + si.service(req, res) + end + + ## + # The default OPTIONS request handler says GET, HEAD, POST and OPTIONS + # requests are allowed. + + def do_OPTIONS(req, res) + res["allow"] = "GET,HEAD,POST,OPTIONS" + end + + ## + # Mounts +servlet+ on +dir+ passing +options+ to the servlet at creation + # time + + def mount(dir, servlet, *options) + @logger.debug(sprintf("%s is mounted on %s.", servlet.inspect, dir)) + @mount_tab[dir] = [ servlet, options ] + end + + ## + # Mounts +proc+ or +block+ on +dir+ and calls it with a + # WEBrick::HTTPRequest and WEBrick::HTTPResponse + + def mount_proc(dir, proc=nil, &block) + proc ||= block + raise HTTPServerError, "must pass a proc or block" unless proc + mount(dir, HTTPServlet::ProcHandler.new(proc)) + end + + ## + # Unmounts +dir+ + + def unmount(dir) + @logger.debug(sprintf("unmount %s.", dir)) + @mount_tab.delete(dir) + end + alias umount unmount + + ## + # Finds a servlet for +path+ + + def search_servlet(path) + script_name, path_info = @mount_tab.scan(path) + servlet, options = @mount_tab[script_name] + if servlet + [ servlet, options, script_name, path_info ] + end + end + + ## + # Adds +server+ as a virtual host. + + def virtual_host(server) + @virtual_hosts << server + @virtual_hosts = @virtual_hosts.sort_by{|s| + num = 0 + num -= 4 if s[:BindAddress] + num -= 2 if s[:Port] + num -= 1 if s[:ServerName] + num + } + end + + ## + # Finds the appropriate virtual host to handle +req+ + + def lookup_server(req) + @virtual_hosts.find{|s| + (s[:BindAddress].nil? || req.addr[3] == s[:BindAddress]) && + (s[:Port].nil? || req.port == s[:Port]) && + ((s[:ServerName].nil? || req.host == s[:ServerName]) || + (!s[:ServerAlias].nil? && s[:ServerAlias].find{|h| h === req.host})) + } + end + + ## + # Logs +req+ and +res+ in the access logs. +config+ is used for the + # server name. + + def access_log(config, req, res) + param = AccessLog::setup_params(config, req, res) + @config[:AccessLog].each{|logger, fmt| + logger << AccessLog::format(fmt+"\n", param) + } + end + + ## + # Creates the HTTPRequest used when handling the HTTP + # request. Can be overridden by subclasses. + def create_request(with_webrick_config) + HTTPRequest.new(with_webrick_config) + end + + ## + # Creates the HTTPResponse used when handling the HTTP + # request. Can be overridden by subclasses. + def create_response(with_webrick_config) + HTTPResponse.new(with_webrick_config) + end + + ## + # Mount table for the path a servlet is mounted on in the directory space + # of the server. Users of WEBrick can only access this indirectly via + # WEBrick::HTTPServer#mount, WEBrick::HTTPServer#unmount and + # WEBrick::HTTPServer#search_servlet + + class MountTable # :nodoc: + def initialize + @tab = Hash.new + compile + end + + def [](dir) + dir = normalize(dir) + @tab[dir] + end + + def []=(dir, val) + dir = normalize(dir) + @tab[dir] = val + compile + val + end + + def delete(dir) + dir = normalize(dir) + res = @tab.delete(dir) + compile + res + end + + def scan(path) + @scanner =~ path + [ $&, $' ] + end + + private + + def compile + k = @tab.keys + k.sort! + k.reverse! + k.collect!{|path| Regexp.escape(path) } + @scanner = Regexp.new("\\A(" + k.join("|") +")(?=/|\\z)") + end + + def normalize(dir) + ret = dir ? dir.dup : +"" + ret.sub!(%r|/+\z|, "") + ret + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet.rb new file mode 100644 index 0000000..4cb1822 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true +# +# httpservlet.rb -- HTTPServlet Utility File +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httpservlet.rb,v 1.21 2003/02/23 12:24:46 gotoyuzo Exp $ + +require_relative 'httpservlet/abstract' +require_relative 'httpservlet/filehandler' +require_relative 'httpservlet/cgihandler' +require_relative 'httpservlet/erbhandler' +require_relative 'httpservlet/prochandler' + +module WEBrick + module HTTPServlet + FileHandler.add_handler("cgi", CGIHandler) + FileHandler.add_handler("rhtml", ERBHandler) + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/abstract.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/abstract.rb new file mode 100644 index 0000000..6fae4de --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/abstract.rb @@ -0,0 +1,152 @@ +# frozen_string_literal: true +# +# httpservlet.rb -- HTTPServlet Module +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: abstract.rb,v 1.24 2003/07/11 11:16:46 gotoyuzo Exp $ + +require_relative '../htmlutils' +require_relative '../httputils' +require_relative '../httpstatus' + +module WEBrick + module HTTPServlet + class HTTPServletError < StandardError; end + + ## + # AbstractServlet allows HTTP server modules to be reused across multiple + # servers and allows encapsulation of functionality. + # + # By default a servlet will respond to GET, HEAD (through an alias to GET) + # and OPTIONS requests. + # + # By default a new servlet is initialized for every request. A servlet + # instance can be reused by overriding ::get_instance in the + # AbstractServlet subclass. + # + # == A Simple Servlet + # + # class Simple < WEBrick::HTTPServlet::AbstractServlet + # def do_GET request, response + # status, content_type, body = do_stuff_with request + # + # response.status = status + # response['Content-Type'] = content_type + # response.body = body + # end + # + # def do_stuff_with request + # return 200, 'text/plain', 'you got a page' + # end + # end + # + # This servlet can be mounted on a server at a given path: + # + # server.mount '/simple', Simple + # + # == Servlet Configuration + # + # Servlets can be configured via initialize. The first argument is the + # HTTP server the servlet is being initialized for. + # + # class Configurable < Simple + # def initialize server, color, size + # super server + # @color = color + # @size = size + # end + # + # def do_stuff_with request + # content = "

    Hello, World!" + # + # return 200, "text/html", content + # end + # end + # + # This servlet must be provided two arguments at mount time: + # + # server.mount '/configurable', Configurable, 'red', '2em' + + class AbstractServlet + + ## + # Factory for servlet instances that will handle a request from +server+ + # using +options+ from the mount point. By default a new servlet + # instance is created for every call. + + def self.get_instance(server, *options) + self.new(server, *options) + end + + ## + # Initializes a new servlet for +server+ using +options+ which are + # stored as-is in +@options+. +@logger+ is also provided. + + def initialize(server, *options) + @server = @config = server + @logger = @server[:Logger] + @options = options + end + + ## + # Dispatches to a +do_+ method based on +req+ if such a method is + # available. (+do_GET+ for a GET request). Raises a MethodNotAllowed + # exception if the method is not implemented. + + def service(req, res) + method_name = "do_" + req.request_method.gsub(/-/, "_") + if respond_to?(method_name) + __send__(method_name, req, res) + else + raise HTTPStatus::MethodNotAllowed, + "unsupported method `#{req.request_method}'." + end + end + + ## + # Raises a NotFound exception + + def do_GET(req, res) + raise HTTPStatus::NotFound, "not found." + end + + ## + # Dispatches to do_GET + + def do_HEAD(req, res) + do_GET(req, res) + end + + ## + # Returns the allowed HTTP request methods + + def do_OPTIONS(req, res) + m = self.methods.grep(/\Ado_([A-Z]+)\z/) {$1} + m.sort! + res["allow"] = m.join(",") + end + + private + + ## + # Redirects to a path ending in / + + def redirect_to_directory_uri(req, res) + if req.path[-1] != ?/ + location = WEBrick::HTTPUtils.escape_path(req.path + "/") + if req.query_string && req.query_string.bytesize > 0 + location << "?" << req.query_string + end + res.set_redirect(HTTPStatus::MovedPermanently, location) + end + end + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/cgi_runner.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/cgi_runner.rb new file mode 100644 index 0000000..b0948ae --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/cgi_runner.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true +# +# cgi_runner.rb -- CGI launcher. +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: cgi_runner.rb,v 1.9 2002/09/25 11:33:15 gotoyuzo Exp $ + +def sysread(io, size) + buf = +"" + while size > 0 + tmp = io.sysread(size) + buf << tmp + size -= tmp.bytesize + end + return buf +end + +STDIN.binmode + +len = sysread(STDIN, 8).to_i +out = sysread(STDIN, len) +STDOUT.reopen(File.open(out, "w")) + +len = sysread(STDIN, 8).to_i +err = sysread(STDIN, len) +STDERR.reopen(File.open(err, "w")) + +len = sysread(STDIN, 8).to_i +dump = sysread(STDIN, len) +hash = Marshal.restore(dump) +ENV.keys.each{|name| ENV.delete(name) } +hash.each{|k, v| ENV[k] = v if v } + +dir = File::dirname(ENV["SCRIPT_FILENAME"]) +Dir::chdir dir + +if ARGV[0] + argv = ARGV.dup + argv << ENV["SCRIPT_FILENAME"] + exec(*argv) + # NOTREACHED +end +exec ENV["SCRIPT_FILENAME"] diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/cgihandler.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/cgihandler.rb new file mode 100644 index 0000000..450aa38 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/cgihandler.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true +# +# cgihandler.rb -- CGIHandler Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: cgihandler.rb,v 1.27 2003/03/21 19:56:01 gotoyuzo Exp $ + +require 'rbconfig' +require 'tempfile' +require_relative '../config' +require_relative 'abstract' + +module WEBrick + module HTTPServlet + + ## + # Servlet for handling CGI scripts + # + # Example: + # + # server.mount('/cgi/my_script', WEBrick::HTTPServlet::CGIHandler, + # '/path/to/my_script') + + class CGIHandler < AbstractServlet + Ruby = RbConfig.ruby # :nodoc: + CGIRunner = "\"#{Ruby}\" \"#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb\"" # :nodoc: + CGIRunnerArray = [Ruby, "#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb".freeze].freeze # :nodoc: + + ## + # Creates a new CGI script servlet for the script at +name+ + + def initialize(server, name) + super(server, name) + @script_filename = name + @tempdir = server[:TempDir] + interpreter = server[:CGIInterpreter] + if interpreter.is_a?(Array) + @cgicmd = CGIRunnerArray + interpreter + else + @cgicmd = "#{CGIRunner} #{interpreter}" + end + end + + # :stopdoc: + + def do_GET(req, res) + cgi_in = IO::popen(@cgicmd, "wb") + cgi_out = Tempfile.new("webrick.cgiout.", @tempdir, mode: IO::BINARY) + cgi_out.set_encoding("ASCII-8BIT") + cgi_err = Tempfile.new("webrick.cgierr.", @tempdir, mode: IO::BINARY) + cgi_err.set_encoding("ASCII-8BIT") + begin + cgi_in.sync = true + meta = req.meta_vars + meta["SCRIPT_FILENAME"] = @script_filename + meta["PATH"] = @config[:CGIPathEnv] + meta.delete("HTTP_PROXY") + if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM + meta["SystemRoot"] = ENV["SystemRoot"] + end + dump = Marshal.dump(meta) + + cgi_in.write("%8d" % cgi_out.path.bytesize) + cgi_in.write(cgi_out.path) + cgi_in.write("%8d" % cgi_err.path.bytesize) + cgi_in.write(cgi_err.path) + cgi_in.write("%8d" % dump.bytesize) + cgi_in.write(dump) + + req.body { |chunk| cgi_in.write(chunk) } + ensure + cgi_in.close + status = $?.exitstatus + sleep 0.1 if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM + data = cgi_out.read + cgi_out.close(true) + if errmsg = cgi_err.read + if errmsg.bytesize > 0 + @logger.error("CGIHandler: #{@script_filename}:\n" + errmsg) + end + end + cgi_err.close(true) + end + + if status != 0 + @logger.error("CGIHandler: #{@script_filename} exit with #{status}") + end + + data = "" unless data + raw_header, body = data.split(/^[\xd\xa]+/, 2) + raise HTTPStatus::InternalServerError, + "Premature end of script headers: #{@script_filename}" if body.nil? + + begin + header = HTTPUtils::parse_header(raw_header) + if /^(\d+)/ =~ header['status'][0] + res.status = $1.to_i + header.delete('status') + end + if header.has_key?('location') + # RFC 3875 6.2.3, 6.2.4 + res.status = 302 unless (300...400) === res.status + end + if header.has_key?('set-cookie') + header['set-cookie'].each{|k| + res.cookies << Cookie.parse_set_cookie(k) + } + header.delete('set-cookie') + end + header.each{|key, val| res[key] = val.join(", ") } + rescue => ex + raise HTTPStatus::InternalServerError, ex.message + end + res.body = body + end + alias do_POST do_GET + + # :startdoc: + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/erbhandler.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/erbhandler.rb new file mode 100644 index 0000000..3b232f7 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/erbhandler.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true +# +# erbhandler.rb -- ERBHandler Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: erbhandler.rb,v 1.25 2003/02/24 19:25:31 gotoyuzo Exp $ + +require_relative 'abstract' + +require 'erb' + +module WEBrick + module HTTPServlet + + ## + # ERBHandler evaluates an ERB file and returns the result. This handler + # is automatically used if there are .rhtml files in a directory served by + # the FileHandler. + # + # ERBHandler supports GET and POST methods. + # + # The ERB file is evaluated with the local variables +servlet_request+ and + # +servlet_response+ which are a WEBrick::HTTPRequest and + # WEBrick::HTTPResponse respectively. + # + # Example .rhtml file: + # + # Request to <%= servlet_request.request_uri %> + # + # Query params <%= servlet_request.query.inspect %> + + class ERBHandler < AbstractServlet + + ## + # Creates a new ERBHandler on +server+ that will evaluate and serve the + # ERB file +name+ + + def initialize(server, name) + super(server, name) + @script_filename = name + end + + ## + # Handles GET requests + + def do_GET(req, res) + unless defined?(ERB) + @logger.warn "#{self.class}: ERB not defined." + raise HTTPStatus::Forbidden, "ERBHandler cannot work." + end + begin + data = File.open(@script_filename, &:read) + res.body = evaluate(ERB.new(data), req, res) + res['content-type'] ||= + HTTPUtils::mime_type(@script_filename, @config[:MimeTypes]) + rescue StandardError + raise + rescue Exception => ex + @logger.error(ex) + raise HTTPStatus::InternalServerError, ex.message + end + end + + ## + # Handles POST requests + + alias do_POST do_GET + + private + + ## + # Evaluates +erb+ providing +servlet_request+ and +servlet_response+ as + # local variables. + + def evaluate(erb, servlet_request, servlet_response) + Module.new.module_eval{ + servlet_request.meta_vars + servlet_request.query + erb.result(binding) + } + end + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/filehandler.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/filehandler.rb new file mode 100644 index 0000000..7ab88bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/filehandler.rb @@ -0,0 +1,552 @@ +# frozen_string_literal: true +# +# filehandler.rb -- FileHandler Module +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: filehandler.rb,v 1.44 2003/06/07 01:34:51 gotoyuzo Exp $ + +require 'time' + +require_relative '../htmlutils' +require_relative '../httputils' +require_relative '../httpstatus' + +module WEBrick + module HTTPServlet + + ## + # Servlet for serving a single file. You probably want to use the + # FileHandler servlet instead as it handles directories and fancy indexes. + # + # Example: + # + # server.mount('/my_page.txt', WEBrick::HTTPServlet::DefaultFileHandler, + # '/path/to/my_page.txt') + # + # This servlet handles If-Modified-Since and Range requests. + + class DefaultFileHandler < AbstractServlet + + ## + # Creates a DefaultFileHandler instance for the file at +local_path+. + + def initialize(server, local_path) + super(server, local_path) + @local_path = local_path + end + + # :stopdoc: + + def do_GET(req, res) + st = File::stat(@local_path) + mtime = st.mtime + res['etag'] = sprintf("%x-%x-%x", st.ino, st.size, st.mtime.to_i) + + if not_modified?(req, res, mtime, res['etag']) + res.body = '' + raise HTTPStatus::NotModified + elsif req['range'] + make_partial_content(req, res, @local_path, st.size) + raise HTTPStatus::PartialContent + else + mtype = HTTPUtils::mime_type(@local_path, @config[:MimeTypes]) + res['content-type'] = mtype + res['content-length'] = st.size.to_s + res['last-modified'] = mtime.httpdate + res.body = File.open(@local_path, "rb") + end + end + + def not_modified?(req, res, mtime, etag) + if ir = req['if-range'] + begin + if Time.httpdate(ir) >= mtime + return true + end + rescue + if HTTPUtils::split_header_value(ir).member?(res['etag']) + return true + end + end + end + + if (ims = req['if-modified-since']) && Time.parse(ims) >= mtime + return true + end + + if (inm = req['if-none-match']) && + HTTPUtils::split_header_value(inm).member?(res['etag']) + return true + end + + return false + end + + # returns a lambda for webrick/httpresponse.rb send_body_proc + def multipart_body(body, parts, boundary, mtype, filesize) + lambda do |socket| + begin + begin + first = parts.shift + last = parts.shift + socket.write( + "--#{boundary}#{CRLF}" \ + "Content-Type: #{mtype}#{CRLF}" \ + "Content-Range: bytes #{first}-#{last}/#{filesize}#{CRLF}" \ + "#{CRLF}" + ) + + begin + IO.copy_stream(body, socket, last - first + 1, first) + rescue NotImplementedError + body.seek(first, IO::SEEK_SET) + IO.copy_stream(body, socket, last - first + 1) + end + socket.write(CRLF) + end while parts[0] + socket.write("--#{boundary}--#{CRLF}") + ensure + body.close + end + end + end + + def make_partial_content(req, res, filename, filesize) + mtype = HTTPUtils::mime_type(filename, @config[:MimeTypes]) + unless ranges = HTTPUtils::parse_range_header(req['range']) + raise HTTPStatus::BadRequest, + "Unrecognized range-spec: \"#{req['range']}\"" + end + File.open(filename, "rb"){|io| + if ranges.size > 1 + time = Time.now + boundary = "#{time.sec}_#{time.usec}_#{Process::pid}" + parts = [] + ranges.each {|range| + prange = prepare_range(range, filesize) + next if prange[0] < 0 + parts.concat(prange) + } + raise HTTPStatus::RequestRangeNotSatisfiable if parts.empty? + res["content-type"] = "multipart/byteranges; boundary=#{boundary}" + if req.http_version < '1.1' + res['connection'] = 'close' + else + res.chunked = true + end + res.body = multipart_body(io.dup, parts, boundary, mtype, filesize) + elsif range = ranges[0] + first, last = prepare_range(range, filesize) + raise HTTPStatus::RequestRangeNotSatisfiable if first < 0 + res['content-type'] = mtype + res['content-range'] = "bytes #{first}-#{last}/#{filesize}" + res['content-length'] = (last - first + 1).to_s + res.body = io.dup + else + raise HTTPStatus::BadRequest + end + } + end + + def prepare_range(range, filesize) + first = range.first < 0 ? filesize + range.first : range.first + return -1, -1 if first < 0 || first >= filesize + last = range.last < 0 ? filesize + range.last : range.last + last = filesize - 1 if last >= filesize + return first, last + end + + # :startdoc: + end + + ## + # Serves a directory including fancy indexing and a variety of other + # options. + # + # Example: + # + # server.mount('/assets', WEBrick::HTTPServlet::FileHandler, + # '/path/to/assets') + + class FileHandler < AbstractServlet + HandlerTable = Hash.new # :nodoc: + + ## + # Allow custom handling of requests for files with +suffix+ by class + # +handler+ + + def self.add_handler(suffix, handler) + HandlerTable[suffix] = handler + end + + ## + # Remove custom handling of requests for files with +suffix+ + + def self.remove_handler(suffix) + HandlerTable.delete(suffix) + end + + ## + # Creates a FileHandler servlet on +server+ that serves files starting + # at directory +root+ + # + # +options+ may be a Hash containing keys from + # WEBrick::Config::FileHandler or +true+ or +false+. + # + # If +options+ is true or false then +:FancyIndexing+ is enabled or + # disabled respectively. + + def initialize(server, root, options={}, default=Config::FileHandler) + @config = server.config + @logger = @config[:Logger] + @root = File.expand_path(root) + if options == true || options == false + options = { :FancyIndexing => options } + end + @options = default.dup.update(options) + end + + # :stopdoc: + + def set_filesystem_encoding(str) + enc = Encoding.find('filesystem') + if enc == Encoding::US_ASCII + str.b + else + str.dup.force_encoding(enc) + end + end + + def service(req, res) + # if this class is mounted on "/" and /~username is requested. + # we're going to override path information before invoking service. + if defined?(Etc) && @options[:UserDir] && req.script_name.empty? + if %r|^(/~([^/]+))| =~ req.path_info + script_name, user = $1, $2 + path_info = $' + begin + passwd = Etc::getpwnam(user) + @root = File::join(passwd.dir, @options[:UserDir]) + req.script_name = script_name + req.path_info = path_info + rescue + @logger.debug "#{self.class}#do_GET: getpwnam(#{user}) failed" + end + end + end + prevent_directory_traversal(req, res) + super(req, res) + end + + def do_GET(req, res) + unless exec_handler(req, res) + set_dir_list(req, res) + end + end + + def do_POST(req, res) + unless exec_handler(req, res) + raise HTTPStatus::NotFound, "`#{req.path}' not found." + end + end + + def do_OPTIONS(req, res) + unless exec_handler(req, res) + super(req, res) + end + end + + # ToDo + # RFC2518: HTTP Extensions for Distributed Authoring -- WEBDAV + # + # PROPFIND PROPPATCH MKCOL DELETE PUT COPY MOVE + # LOCK UNLOCK + + # RFC3253: Versioning Extensions to WebDAV + # (Web Distributed Authoring and Versioning) + # + # VERSION-CONTROL REPORT CHECKOUT CHECK_IN UNCHECKOUT + # MKWORKSPACE UPDATE LABEL MERGE ACTIVITY + + private + + def trailing_pathsep?(path) + # check for trailing path separator: + # File.dirname("/aaaa/bbbb/") #=> "/aaaa") + # File.dirname("/aaaa/bbbb/x") #=> "/aaaa/bbbb") + # File.dirname("/aaaa/bbbb") #=> "/aaaa") + # File.dirname("/aaaa/bbbbx") #=> "/aaaa") + return File.dirname(path) != File.dirname(path+"x") + end + + def prevent_directory_traversal(req, res) + # Preventing directory traversal on Windows platforms; + # Backslashes (0x5c) in path_info are not interpreted as special + # character in URI notation. So the value of path_info should be + # normalize before accessing to the filesystem. + + # dirty hack for filesystem encoding; in nature, File.expand_path + # should not be used for path normalization. [Bug #3345] + path = req.path_info.dup.force_encoding(Encoding.find("filesystem")) + if trailing_pathsep?(req.path_info) + # File.expand_path removes the trailing path separator. + # Adding a character is a workaround to save it. + # File.expand_path("/aaa/") #=> "/aaa" + # File.expand_path("/aaa/" + "x") #=> "/aaa/x" + expanded = File.expand_path(path + "x") + expanded.chop! # remove trailing "x" + else + expanded = File.expand_path(path) + end + expanded.force_encoding(req.path_info.encoding) + req.path_info = expanded + end + + def exec_handler(req, res) + raise HTTPStatus::NotFound, "`#{req.path}' not found." unless @root + if set_filename(req, res) + handler = get_handler(req, res) + call_callback(:HandlerCallback, req, res) + h = handler.get_instance(@config, res.filename) + h.service(req, res) + return true + end + call_callback(:HandlerCallback, req, res) + return false + end + + def get_handler(req, res) + suffix1 = (/\.(\w+)\z/ =~ res.filename) && $1.downcase + if /\.(\w+)\.([\w\-]+)\z/ =~ res.filename + if @options[:AcceptableLanguages].include?($2.downcase) + suffix2 = $1.downcase + end + end + handler_table = @options[:HandlerTable] + return handler_table[suffix1] || handler_table[suffix2] || + HandlerTable[suffix1] || HandlerTable[suffix2] || + DefaultFileHandler + end + + def set_filename(req, res) + res.filename = @root + path_info = req.path_info.scan(%r|/[^/]*|) + + path_info.unshift("") # dummy for checking @root dir + while base = path_info.first + base = set_filesystem_encoding(base) + break if base == "/" + break unless File.directory?(File.expand_path(res.filename + base)) + shift_path_info(req, res, path_info) + call_callback(:DirectoryCallback, req, res) + end + + if base = path_info.first + base = set_filesystem_encoding(base) + if base == "/" + if file = search_index_file(req, res) + shift_path_info(req, res, path_info, file) + call_callback(:FileCallback, req, res) + return true + end + shift_path_info(req, res, path_info) + elsif file = search_file(req, res, base) + shift_path_info(req, res, path_info, file) + call_callback(:FileCallback, req, res) + return true + else + raise HTTPStatus::NotFound, "`#{req.path}' not found." + end + end + + return false + end + + def check_filename(req, res, name) + if nondisclosure_name?(name) || windows_ambiguous_name?(name) + @logger.warn("the request refers nondisclosure name `#{name}'.") + raise HTTPStatus::NotFound, "`#{req.path}' not found." + end + end + + def shift_path_info(req, res, path_info, base=nil) + tmp = path_info.shift + base = base || set_filesystem_encoding(tmp) + req.path_info = path_info.join + req.script_name << base + res.filename = File.expand_path(res.filename + base) + check_filename(req, res, File.basename(res.filename)) + end + + def search_index_file(req, res) + @config[:DirectoryIndex].each{|index| + if file = search_file(req, res, "/"+index) + return file + end + } + return nil + end + + def search_file(req, res, basename) + langs = @options[:AcceptableLanguages] + path = res.filename + basename + if File.file?(path) + return basename + elsif langs.size > 0 + req.accept_language.each{|lang| + path_with_lang = path + ".#{lang}" + if langs.member?(lang) && File.file?(path_with_lang) + return basename + ".#{lang}" + end + } + (langs - req.accept_language).each{|lang| + path_with_lang = path + ".#{lang}" + if File.file?(path_with_lang) + return basename + ".#{lang}" + end + } + end + return nil + end + + def call_callback(callback_name, req, res) + if cb = @options[callback_name] + cb.call(req, res) + end + end + + def windows_ambiguous_name?(name) + return true if /[. ]+\z/ =~ name + return true if /::\$DATA\z/ =~ name + return false + end + + def nondisclosure_name?(name) + @options[:NondisclosureName].each{|pattern| + if File.fnmatch(pattern, name, File::FNM_CASEFOLD) + return true + end + } + return false + end + + def set_dir_list(req, res) + redirect_to_directory_uri(req, res) + unless @options[:FancyIndexing] + raise HTTPStatus::Forbidden, "no access permission to `#{req.path}'" + end + local_path = res.filename + list = Dir::entries(local_path).collect{|name| + next if name == "." || name == ".." + next if nondisclosure_name?(name) + next if windows_ambiguous_name?(name) + st = (File::stat(File.join(local_path, name)) rescue nil) + if st.nil? + [ name, nil, -1 ] + elsif st.directory? + [ name + "/", st.mtime, -1 ] + else + [ name, st.mtime, st.size ] + end + } + list.compact! + + query = req.query + + d0 = nil + idx = nil + %w[N M S].each_with_index do |q, i| + if d = query.delete(q) + idx ||= i + d0 ||= d + end + end + d0 ||= "A" + idx ||= 0 + d1 = (d0 == "A") ? "D" : "A" + + if d0 == "A" + list.sort!{|a,b| a[idx] <=> b[idx] } + else + list.sort!{|a,b| b[idx] <=> a[idx] } + end + + namewidth = query["NameWidth"] + if namewidth == "*" + namewidth = nil + elsif !namewidth or (namewidth = namewidth.to_i) < 2 + namewidth = 25 + end + query = query.inject('') {|s, (k, v)| s << '&' << HTMLUtils::escape("#{k}=#{v}")}.dup + + type = +"text/html" + case enc = Encoding.find('filesystem') + when Encoding::US_ASCII, Encoding::ASCII_8BIT + else + type << "; charset=\"#{enc.name}\"" + end + res['content-type'] = type + + title = "Index of #{HTMLUtils::escape(req.path)}" + res.body = +<<-_end_of_html_ + + + + #{title} + + + +

    #{title}

    + _end_of_html_ + + res.body << "\n" + res.body << "" + res.body << "" + res.body << "\n" + res.body << "\n" + res.body << "\n" + + query.sub!(/\A&/, '?') + list.unshift [ "..", File::mtime(local_path+"/.."), -1 ] + list.each{ |name, time, size| + if name == ".." + dname = "Parent Directory" + elsif namewidth and name.size > namewidth + dname = name[0...(namewidth - 2)] << '..' + else + dname = name + end + s = +"" + s << "" + s << "\n" + res.body << s + } + res.body << "
    NameLast modifiedSize
    #{HTMLUtils::escape(dname)}" << (time ? time.strftime("%Y/%m/%d %H:%M") : "") << "" << (size >= 0 ? size.to_s : "-") << "
    " + res.body << "
    " + + res.body << <<-_end_of_html_ +
    + #{HTMLUtils::escape(@config[:ServerSoftware])}
    + at #{req.host}:#{req.port} +
    + + + _end_of_html_ + end + + # :startdoc: + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb new file mode 100644 index 0000000..92e4f80 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true +# +# prochandler.rb -- ProcHandler Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: prochandler.rb,v 1.7 2002/09/21 12:23:42 gotoyuzo Exp $ + +require_relative 'abstract' + +module WEBrick + module HTTPServlet + + ## + # Mounts a proc at a path that accepts a request and response. + # + # Instead of mounting this servlet with WEBrick::HTTPServer#mount use + # WEBrick::HTTPServer#mount_proc: + # + # server.mount_proc '/' do |req, res| + # res.body = 'it worked!' + # res.status = 200 + # end + + class ProcHandler < AbstractServlet + # :stopdoc: + def get_instance(server, *options) + self + end + + def initialize(proc) + @proc = proc + end + + def do_GET(request, response) + @proc.call(request, response) + end + + alias do_POST do_GET + alias do_PUT do_GET + # :startdoc: + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpstatus.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpstatus.rb new file mode 100644 index 0000000..c21c1d4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpstatus.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true +#-- +# httpstatus.rb -- HTTPStatus Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httpstatus.rb,v 1.11 2003/03/24 20:18:55 gotoyuzo Exp $ + +require_relative 'accesslog' + +module WEBrick + + ## + # This module is used to manager HTTP status codes. + # + # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more + # information. + module HTTPStatus + + ## + # Root of the HTTP status class hierarchy + class Status < StandardError + class << self + attr_reader :code, :reason_phrase # :nodoc: + end + + # Returns the HTTP status code + def code() self::class::code end + + # Returns the HTTP status description + def reason_phrase() self::class::reason_phrase end + + alias to_i code # :nodoc: + end + + # Root of the HTTP info statuses + class Info < Status; end + # Root of the HTTP success statuses + class Success < Status; end + # Root of the HTTP redirect statuses + class Redirect < Status; end + # Root of the HTTP error statuses + class Error < Status; end + # Root of the HTTP client error statuses + class ClientError < Error; end + # Root of the HTTP server error statuses + class ServerError < Error; end + + class EOFError < StandardError; end + + # HTTP status codes and descriptions + StatusMessage = { # :nodoc: + 100 => 'Continue', + 101 => 'Switching Protocols', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 207 => 'Multi-Status', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Large', + 415 => 'Unsupported Media Type', + 416 => 'Request Range Not Satisfiable', + 417 => 'Expectation Failed', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 426 => 'Upgrade Required', + 428 => 'Precondition Required', + 429 => 'Too Many Requests', + 431 => 'Request Header Fields Too Large', + 451 => 'Unavailable For Legal Reasons', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported', + 507 => 'Insufficient Storage', + 511 => 'Network Authentication Required', + } + + # Maps a status code to the corresponding Status class + CodeToError = {} # :nodoc: + + # Creates a status or error class for each status code and + # populates the CodeToError map. + StatusMessage.each{|code, message| + message.freeze + var_name = message.gsub(/[ \-]/,'_').upcase + err_name = message.gsub(/[ \-]/,'') + + case code + when 100...200; parent = Info + when 200...300; parent = Success + when 300...400; parent = Redirect + when 400...500; parent = ClientError + when 500...600; parent = ServerError + end + + const_set("RC_#{var_name}", code) + err_class = Class.new(parent) + err_class.instance_variable_set(:@code, code) + err_class.instance_variable_set(:@reason_phrase, message) + const_set(err_name, err_class) + CodeToError[code] = err_class + } + + ## + # Returns the description corresponding to the HTTP status +code+ + # + # WEBrick::HTTPStatus.reason_phrase 404 + # => "Not Found" + def reason_phrase(code) + StatusMessage[code.to_i] + end + + ## + # Is +code+ an informational status? + def info?(code) + code.to_i >= 100 and code.to_i < 200 + end + + ## + # Is +code+ a successful status? + def success?(code) + code.to_i >= 200 and code.to_i < 300 + end + + ## + # Is +code+ a redirection status? + def redirect?(code) + code.to_i >= 300 and code.to_i < 400 + end + + ## + # Is +code+ an error status? + def error?(code) + code.to_i >= 400 and code.to_i < 600 + end + + ## + # Is +code+ a client error status? + def client_error?(code) + code.to_i >= 400 and code.to_i < 500 + end + + ## + # Is +code+ a server error status? + def server_error?(code) + code.to_i >= 500 and code.to_i < 600 + end + + ## + # Returns the status class corresponding to +code+ + # + # WEBrick::HTTPStatus[302] + # => WEBrick::HTTPStatus::NotFound + # + def self.[](code) + CodeToError[code] + end + + module_function :reason_phrase + module_function :info?, :success?, :redirect?, :error? + module_function :client_error?, :server_error? + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httputils.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httputils.rb new file mode 100644 index 0000000..48aa137 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httputils.rb @@ -0,0 +1,523 @@ +# frozen_string_literal: true +# +# httputils.rb -- HTTPUtils Module +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httputils.rb,v 1.34 2003/06/05 21:34:08 gotoyuzo Exp $ + +require 'socket' +require 'tempfile' + +module WEBrick + CR = "\x0d" # :nodoc: + LF = "\x0a" # :nodoc: + CRLF = "\x0d\x0a" # :nodoc: + + ## + # HTTPUtils provides utility methods for working with the HTTP protocol. + # + # This module is generally used internally by WEBrick + + module HTTPUtils + + ## + # Normalizes a request path. Raises an exception if the path cannot be + # normalized. + + def normalize_path(path) + raise "abnormal path `#{path}'" if path[0] != ?/ + ret = path.dup + + ret.gsub!(%r{/+}o, '/') # // => / + while ret.sub!(%r'/\.(?:/|\Z)', '/'); end # /. => / + while ret.sub!(%r'/(?!\.\./)[^/]+/\.\.(?:/|\Z)', '/'); end # /foo/.. => /foo + + raise "abnormal path `#{path}'" if %r{/\.\.(/|\Z)} =~ ret + ret + end + module_function :normalize_path + + ## + # Default mime types + + DefaultMimeTypes = { + "ai" => "application/postscript", + "asc" => "text/plain", + "avi" => "video/x-msvideo", + "avif" => "image/avif", + "bin" => "application/octet-stream", + "bmp" => "image/bmp", + "class" => "application/octet-stream", + "cer" => "application/pkix-cert", + "crl" => "application/pkix-crl", + "crt" => "application/x-x509-ca-cert", + #"crl" => "application/x-pkcs7-crl", + "css" => "text/css", + "dms" => "application/octet-stream", + "doc" => "application/msword", + "dvi" => "application/x-dvi", + "eps" => "application/postscript", + "etx" => "text/x-setext", + "exe" => "application/octet-stream", + "gif" => "image/gif", + "htm" => "text/html", + "html" => "text/html", + "ico" => "image/x-icon", + "jpe" => "image/jpeg", + "jpeg" => "image/jpeg", + "jpg" => "image/jpeg", + "js" => "application/javascript", + "json" => "application/json", + "lha" => "application/octet-stream", + "lzh" => "application/octet-stream", + "mjs" => "application/javascript", + "mov" => "video/quicktime", + "mp4" => "video/mp4", + "mpe" => "video/mpeg", + "mpeg" => "video/mpeg", + "mpg" => "video/mpeg", + "otf" => "font/otf", + "pbm" => "image/x-portable-bitmap", + "pdf" => "application/pdf", + "pgm" => "image/x-portable-graymap", + "png" => "image/png", + "pnm" => "image/x-portable-anymap", + "ppm" => "image/x-portable-pixmap", + "ppt" => "application/vnd.ms-powerpoint", + "ps" => "application/postscript", + "qt" => "video/quicktime", + "ras" => "image/x-cmu-raster", + "rb" => "text/plain", + "rd" => "text/plain", + "rtf" => "application/rtf", + "sgm" => "text/sgml", + "sgml" => "text/sgml", + "svg" => "image/svg+xml", + "tif" => "image/tiff", + "tiff" => "image/tiff", + "ttc" => "font/collection", + "ttf" => "font/ttf", + "txt" => "text/plain", + "wasm" => "application/wasm", + "webm" => "video/webm", + "webmanifest" => "application/manifest+json", + "webp" => "image/webp", + "woff" => "font/woff", + "woff2" => "font/woff2", + "xbm" => "image/x-xbitmap", + "xhtml" => "text/html", + "xls" => "application/vnd.ms-excel", + "xml" => "text/xml", + "xpm" => "image/x-xpixmap", + "xwd" => "image/x-xwindowdump", + "zip" => "application/zip", + } + + ## + # Loads Apache-compatible mime.types in +file+. + + def load_mime_types(file) + # note: +file+ may be a "| command" for now; some people may + # rely on this, but currently we do not use this method by default. + File.open(file){ |io| + hash = Hash.new + io.each{ |line| + next if /^#/ =~ line + line.chomp! + mimetype, ext0 = line.split(/\s+/, 2) + next unless ext0 + next if ext0.empty? + ext0.split(/\s+/).each{ |ext| hash[ext] = mimetype } + } + hash + } + end + module_function :load_mime_types + + ## + # Returns the mime type of +filename+ from the list in +mime_tab+. If no + # mime type was found application/octet-stream is returned. + + def mime_type(filename, mime_tab) + suffix1 = (/\.(\w+)$/ =~ filename && $1.downcase) + suffix2 = (/\.(\w+)\.[\w\-]+$/ =~ filename && $1.downcase) + mime_tab[suffix1] || mime_tab[suffix2] || "application/octet-stream" + end + module_function :mime_type + + ## + # Parses an HTTP header +raw+ into a hash of header fields with an Array + # of values. + + def parse_header(raw) + header = Hash.new([].freeze) + field = nil + raw.each_line{|line| + case line + when /^([A-Za-z0-9!\#$%&'*+\-.^_`|~]+):\s*(.*?)\s*\z/om + field, value = $1, $2 + field.downcase! + header[field] = [] unless header.has_key?(field) + header[field] << value + when /^\s+(.*?)\s*\z/om + value = $1 + unless field + raise HTTPStatus::BadRequest, "bad header '#{line}'." + end + header[field][-1] << " " << value + else + raise HTTPStatus::BadRequest, "bad header '#{line}'." + end + } + header.each{|key, values| + values.each(&:strip!) + } + header + end + module_function :parse_header + + ## + # Splits a header value +str+ according to HTTP specification. + + def split_header_value(str) + str.scan(%r'\G((?:"(?:\\.|[^"])+?"|[^",]+)+) + (?:,\s*|\Z)'xn).flatten + end + module_function :split_header_value + + ## + # Parses a Range header value +ranges_specifier+ + + def parse_range_header(ranges_specifier) + if /^bytes=(.*)/ =~ ranges_specifier + byte_range_set = split_header_value($1) + byte_range_set.collect{|range_spec| + case range_spec + when /^(\d+)-(\d+)/ then $1.to_i .. $2.to_i + when /^(\d+)-/ then $1.to_i .. -1 + when /^-(\d+)/ then -($1.to_i) .. -1 + else return nil + end + } + end + end + module_function :parse_range_header + + ## + # Parses q values in +value+ as used in Accept headers. + + def parse_qvalues(value) + tmp = [] + if value + parts = value.split(/,\s*/) + parts.each {|part| + if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part) + val = m[1] + q = (m[2] or 1).to_f + tmp.push([val, q]) + end + } + tmp = tmp.sort_by{|val, q| -q} + tmp.collect!{|val, q| val} + end + return tmp + end + module_function :parse_qvalues + + ## + # Removes quotes and escapes from +str+ + + def dequote(str) + ret = (/\A"(.*)"\Z/ =~ str) ? $1 : str.dup + ret.gsub!(/\\(.)/, "\\1") + ret + end + module_function :dequote + + ## + # Quotes and escapes quotes in +str+ + + def quote(str) + +'"' << str.gsub(/[\\\"]/o, "\\\1") << '"' + end + module_function :quote + + ## + # Stores multipart form data. FormData objects are created when + # WEBrick::HTTPUtils.parse_form_data is called. + + class FormData < String + EmptyRawHeader = [].freeze # :nodoc: + EmptyHeader = {}.freeze # :nodoc: + + ## + # The name of the form data part + + attr_accessor :name + + ## + # The filename of the form data part + + attr_accessor :filename + + attr_accessor :next_data # :nodoc: + protected :next_data + + ## + # Creates a new FormData object. + # + # +args+ is an Array of form data entries. One FormData will be created + # for each entry. + # + # This is called by WEBrick::HTTPUtils.parse_form_data for you + + def initialize(*args) + @name = @filename = @next_data = nil + if args.empty? + @raw_header = [] + @header = nil + super("") + else + @raw_header = EmptyRawHeader + @header = EmptyHeader + super(args.shift) + unless args.empty? + @next_data = self.class.new(*args) + end + end + end + + ## + # Retrieves the header at the first entry in +key+ + + def [](*key) + begin + @header[key[0].downcase].join(", ") + rescue StandardError, NameError + super + end + end + + ## + # Adds +str+ to this FormData which may be the body, a header or a + # header entry. + # + # This is called by WEBrick::HTTPUtils.parse_form_data for you + + def <<(str) + if @header + super + elsif str == CRLF + @header = HTTPUtils::parse_header(@raw_header.join) + if cd = self['content-disposition'] + if /\s+name="(.*?)"/ =~ cd then @name = $1 end + if /\s+filename="(.*?)"/ =~ cd then @filename = $1 end + end + else + @raw_header << str + end + self + end + + ## + # Adds +data+ at the end of the chain of entries + # + # This is called by WEBrick::HTTPUtils.parse_form_data for you. + + def append_data(data) + tmp = self + while tmp + unless tmp.next_data + tmp.next_data = data + break + end + tmp = tmp.next_data + end + self + end + + ## + # Yields each entry in this FormData + + def each_data + tmp = self + while tmp + next_data = tmp.next_data + yield(tmp) + tmp = next_data + end + end + + ## + # Returns all the FormData as an Array + + def list + ret = [] + each_data{|data| + ret << data.to_s + } + ret + end + + ## + # A FormData will behave like an Array + + alias :to_ary :list + + ## + # This FormData's body + + def to_s + String.new(self) + end + end + + ## + # Parses the query component of a URI in +str+ + + def parse_query(str) + query = Hash.new + if str + str.split(/[&;]/).each{|x| + next if x.empty? + key, val = x.split(/=/,2) + key = unescape_form(key) + val = unescape_form(val.to_s) + val = FormData.new(val) + val.name = key + if query.has_key?(key) + query[key].append_data(val) + next + end + query[key] = val + } + end + query + end + module_function :parse_query + + ## + # Parses form data in +io+ with the given +boundary+ + + def parse_form_data(io, boundary) + boundary_regexp = /\A--#{Regexp.quote(boundary)}(--)?#{CRLF}\z/ + form_data = Hash.new + return form_data unless io + data = nil + io.each_line{|line| + if boundary_regexp =~ line + if data + data.chop! + key = data.name + if form_data.has_key?(key) + form_data[key].append_data(data) + else + form_data[key] = data + end + end + data = FormData.new + next + else + if data + data << line + end + end + } + return form_data + end + module_function :parse_form_data + + ##### + + reserved = ';/?:@&=+$,' + num = '0123456789' + lowalpha = 'abcdefghijklmnopqrstuvwxyz' + upalpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + mark = '-_.!~*\'()' + unreserved = num + lowalpha + upalpha + mark + control = (0x0..0x1f).collect{|c| c.chr }.join + "\x7f" + space = " " + delims = '<>#%"' + unwise = '{}|\\^[]`' + nonascii = (0x80..0xff).collect{|c| c.chr }.join + + module_function + + # :stopdoc: + + def _make_regex(str) /([#{Regexp.escape(str)}])/n end + def _make_regex!(str) /([^#{Regexp.escape(str)}])/n end + def _escape(str, regex) + str = str.b + str.gsub!(regex) {"%%%02X" % $1.ord} + # %-escaped string should contain US-ASCII only + str.force_encoding(Encoding::US_ASCII) + end + def _unescape(str, regex) + str = str.b + str.gsub!(regex) {$1.hex.chr} + # encoding of %-unescaped string is unknown + str + end + + UNESCAPED = _make_regex(control+space+delims+unwise+nonascii) + UNESCAPED_FORM = _make_regex(reserved+control+delims+unwise+nonascii) + NONASCII = _make_regex(nonascii) + ESCAPED = /%([0-9a-fA-F]{2})/ + UNESCAPED_PCHAR = _make_regex!(unreserved+":@&=+$,") + + # :startdoc: + + ## + # Escapes HTTP reserved and unwise characters in +str+ + + def escape(str) + _escape(str, UNESCAPED) + end + + ## + # Unescapes HTTP reserved and unwise characters in +str+ + + def unescape(str) + _unescape(str, ESCAPED) + end + + ## + # Escapes form reserved characters in +str+ + + def escape_form(str) + ret = _escape(str, UNESCAPED_FORM) + ret.gsub!(/ /, "+") + ret + end + + ## + # Unescapes form reserved characters in +str+ + + def unescape_form(str) + _unescape(str.gsub(/\+/, " "), ESCAPED) + end + + ## + # Escapes path +str+ + + def escape_path(str) + result = +"" + str.scan(%r{/([^/]*)}).each{|i| + result << "/" << _escape(i[0], UNESCAPED_PCHAR) + } + return result + end + + ## + # Escapes 8 bit characters in +str+ + + def escape8bit(str) + _escape(str, NONASCII) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpversion.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpversion.rb new file mode 100644 index 0000000..6349590 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpversion.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +#-- +# HTTPVersion.rb -- presentation of HTTP version +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httpversion.rb,v 1.5 2002/09/21 12:23:37 gotoyuzo Exp $ + +module WEBrick + + ## + # Represents an HTTP protocol version + + class HTTPVersion + include Comparable + + ## + # The major protocol version number + + attr_accessor :major + + ## + # The minor protocol version number + + attr_accessor :minor + + ## + # Converts +version+ into an HTTPVersion + + def self.convert(version) + version.is_a?(self) ? version : new(version) + end + + ## + # Creates a new HTTPVersion from +version+. + + def initialize(version) + case version + when HTTPVersion + @major, @minor = version.major, version.minor + when String + if /^(\d+)\.(\d+)$/ =~ version + @major, @minor = $1.to_i, $2.to_i + end + end + if @major.nil? || @minor.nil? + raise ArgumentError, + format("cannot convert %s into %s", version.class, self.class) + end + end + + ## + # Compares this version with +other+ according to the HTTP specification + # rules. + + def <=>(other) + unless other.is_a?(self.class) + other = self.class.new(other) + end + if (ret = @major <=> other.major) == 0 + return @minor <=> other.minor + end + return ret + end + + ## + # The HTTP version as show in the HTTP request and response. For example, + # "1.1" + + def to_s + format("%d.%d", @major, @minor) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/log.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/log.rb new file mode 100644 index 0000000..4de4bee --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/log.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true +#-- +# log.rb -- Log Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: log.rb,v 1.26 2002/10/06 17:06:10 gotoyuzo Exp $ + +module WEBrick + + ## + # A generic logging class + + class BasicLog + + # Fatal log level which indicates a server crash + + FATAL = 1 + + # Error log level which indicates a recoverable error + + ERROR = 2 + + # Warning log level which indicates a possible problem + + WARN = 3 + + # Information log level which indicates possibly useful information + + INFO = 4 + + # Debugging error level for messages used in server development or + # debugging + + DEBUG = 5 + + # log-level, messages above this level will be logged + attr_accessor :level + + ## + # Initializes a new logger for +log_file+ that outputs messages at +level+ + # or higher. +log_file+ can be a filename, an IO-like object that + # responds to #<< or nil which outputs to $stderr. + # + # If no level is given INFO is chosen by default + + def initialize(log_file=nil, level=nil) + @level = level || INFO + case log_file + when String + @log = File.open(log_file, "a+") + @log.sync = true + @opened = true + when NilClass + @log = $stderr + else + @log = log_file # requires "<<". (see BasicLog#log) + end + end + + ## + # Closes the logger (also closes the log device associated to the logger) + def close + @log.close if @opened + @log = nil + end + + ## + # Logs +data+ at +level+ if the given level is above the current log + # level. + + def log(level, data) + if @log && level <= @level + data += "\n" if /\n\Z/ !~ data + @log << data + end + end + + ## + # Synonym for log(INFO, obj.to_s) + def <<(obj) + log(INFO, obj.to_s) + end + + # Shortcut for logging a FATAL message + def fatal(msg) log(FATAL, "FATAL " + format(msg)); end + # Shortcut for logging an ERROR message + def error(msg) log(ERROR, "ERROR " + format(msg)); end + # Shortcut for logging a WARN message + def warn(msg) log(WARN, "WARN " + format(msg)); end + # Shortcut for logging an INFO message + def info(msg) log(INFO, "INFO " + format(msg)); end + # Shortcut for logging a DEBUG message + def debug(msg) log(DEBUG, "DEBUG " + format(msg)); end + + # Will the logger output FATAL messages? + def fatal?; @level >= FATAL; end + # Will the logger output ERROR messages? + def error?; @level >= ERROR; end + # Will the logger output WARN messages? + def warn?; @level >= WARN; end + # Will the logger output INFO messages? + def info?; @level >= INFO; end + # Will the logger output DEBUG messages? + def debug?; @level >= DEBUG; end + + private + + ## + # Formats +arg+ for the logger + # + # * If +arg+ is an Exception, it will format the error message and + # the back trace. + # * If +arg+ responds to #to_str, it will return it. + # * Otherwise it will return +arg+.inspect. + def format(arg) + if arg.is_a?(Exception) + +"#{arg.class}: #{AccessLog.escape(arg.message)}\n\t" << + arg.backtrace.join("\n\t") << "\n" + elsif arg.respond_to?(:to_str) + AccessLog.escape(arg.to_str) + else + arg.inspect + end + end + end + + ## + # A logging class that prepends a timestamp to each message. + + class Log < BasicLog + # Format of the timestamp which is applied to each logged line. The + # default is "[%Y-%m-%d %H:%M:%S]" + attr_accessor :time_format + + ## + # Same as BasicLog#initialize + # + # You can set the timestamp format through #time_format + def initialize(log_file=nil, level=nil) + super(log_file, level) + @time_format = "[%Y-%m-%d %H:%M:%S]" + end + + ## + # Same as BasicLog#log + def log(level, data) + tmp = Time.now.strftime(@time_format) + tmp << " " << data + super(level, tmp) + end + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/server.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/server.rb new file mode 100644 index 0000000..f085d5d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/server.rb @@ -0,0 +1,381 @@ +# frozen_string_literal: true +# +# server.rb -- GenericServer Class +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: server.rb,v 1.62 2003/07/22 19:20:43 gotoyuzo Exp $ + +require 'socket' +require_relative 'config' +require_relative 'log' + +module WEBrick + + ## + # Server error exception + + class ServerError < StandardError; end + + ## + # Base server class + + class SimpleServer + + ## + # A SimpleServer only yields when you start it + + def SimpleServer.start + yield + end + end + + ## + # A generic module for daemonizing a process + + class Daemon + + ## + # Performs the standard operations for daemonizing a process. Runs a + # block, if given. + + def Daemon.start + Process.daemon + File.umask(0) + yield if block_given? + end + end + + ## + # Base TCP server class. You must subclass GenericServer and provide a #run + # method. + + class GenericServer + + ## + # The server status. One of :Stop, :Running or :Shutdown + + attr_reader :status + + ## + # The server configuration + + attr_reader :config + + ## + # The server logger. This is independent from the HTTP access log. + + attr_reader :logger + + ## + # Tokens control the number of outstanding clients. The + # :MaxClients configuration sets this. + + attr_reader :tokens + + ## + # Sockets listening for connections. + + attr_reader :listeners + + ## + # Creates a new generic server from +config+. The default configuration + # comes from +default+. + + def initialize(config={}, default=Config::General) + @config = default.dup.update(config) + @status = :Stop + @config[:Logger] ||= Log::new + @logger = @config[:Logger] + + @tokens = Thread::SizedQueue.new(@config[:MaxClients]) + @config[:MaxClients].times{ @tokens.push(nil) } + + webrickv = WEBrick::VERSION + rubyv = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]" + @logger.info("WEBrick #{webrickv}") + @logger.info("ruby #{rubyv}") + + @listeners = [] + @shutdown_pipe = nil + unless @config[:DoNotListen] + raise ArgumentError, "Port must be an integer" unless @config[:Port].to_s == @config[:Port].to_i.to_s + + @config[:Port] = @config[:Port].to_i + if @config[:Listen] + warn(":Listen option is deprecated; use GenericServer#listen", uplevel: 1) + end + listen(@config[:BindAddress], @config[:Port]) + if @config[:Port] == 0 + @config[:Port] = @listeners[0].addr[1] + end + end + end + + ## + # Retrieves +key+ from the configuration + + def [](key) + @config[key] + end + + ## + # Adds listeners from +address+ and +port+ to the server. See + # WEBrick::Utils::create_listeners for details. + + def listen(address, port) + @listeners += Utils::create_listeners(address, port) + end + + ## + # Starts the server and runs the +block+ for each connection. This method + # does not return until the server is stopped from a signal handler or + # another thread using #stop or #shutdown. + # + # If the block raises a subclass of StandardError the exception is logged + # and ignored. If an IOError or Errno::EBADF exception is raised the + # exception is ignored. If an Exception subclass is raised the exception + # is logged and re-raised which stops the server. + # + # To completely shut down a server call #shutdown from ensure: + # + # server = WEBrick::GenericServer.new + # # or WEBrick::HTTPServer.new + # + # begin + # server.start + # ensure + # server.shutdown + # end + + def start(&block) + raise ServerError, "already started." if @status != :Stop + server_type = @config[:ServerType] || SimpleServer + + setup_shutdown_pipe + + server_type.start{ + @logger.info \ + "#{self.class}#start: pid=#{$$} port=#{@config[:Port]}" + @status = :Running + call_callback(:StartCallback) + + shutdown_pipe = @shutdown_pipe + + thgroup = ThreadGroup.new + begin + while @status == :Running + begin + sp = shutdown_pipe[0] + if svrs = IO.select([sp, *@listeners]) + if svrs[0].include? sp + # swallow shutdown pipe + buf = String.new + nil while String === + sp.read_nonblock([sp.nread, 8].max, buf, exception: false) + break + end + svrs[0].each{|svr| + @tokens.pop # blocks while no token is there. + if sock = accept_client(svr) + unless config[:DoNotReverseLookup].nil? + sock.do_not_reverse_lookup = !!config[:DoNotReverseLookup] + end + th = start_thread(sock, &block) + th[:WEBrickThread] = true + thgroup.add(th) + else + @tokens.push(nil) + end + } + end + rescue Errno::EBADF, Errno::ENOTSOCK, IOError => ex + # if the listening socket was closed in GenericServer#shutdown, + # IO::select raise it. + rescue StandardError => ex + msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}" + @logger.error msg + rescue Exception => ex + @logger.fatal ex + raise + end + end + ensure + cleanup_shutdown_pipe(shutdown_pipe) + cleanup_listener + @status = :Shutdown + @logger.info "going to shutdown ..." + thgroup.list.each{|th| th.join if th[:WEBrickThread] } + call_callback(:StopCallback) + @logger.info "#{self.class}#start done." + @status = :Stop + end + } + end + + ## + # Stops the server from accepting new connections. + + def stop + if @status == :Running + @status = :Shutdown + end + + alarm_shutdown_pipe {|f| f.write_nonblock("\0")} + end + + ## + # Shuts down the server and all listening sockets. New listeners must be + # provided to restart the server. + + def shutdown + stop + + alarm_shutdown_pipe(&:close) + end + + ## + # You must subclass GenericServer and implement \#run which accepts a TCP + # client socket + + def run(sock) + @logger.fatal "run() must be provided by user." + end + + private + + # :stopdoc: + + ## + # Accepts a TCP client socket from the TCP server socket +svr+ and returns + # the client socket. + + def accept_client(svr) + case sock = svr.to_io.accept_nonblock(exception: false) + when :wait_readable + nil + else + if svr.respond_to?(:start_immediately) + sock = OpenSSL::SSL::SSLSocket.new(sock, ssl_context) + sock.sync_close = true + # we cannot do OpenSSL::SSL::SSLSocket#accept here because + # a slow client can prevent us from accepting connections + # from other clients + end + sock + end + rescue Errno::ECONNRESET, Errno::ECONNABORTED, + Errno::EPROTO, Errno::EINVAL + nil + rescue StandardError => ex + msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}" + @logger.error msg + nil + end + + ## + # Starts a server thread for the client socket +sock+ that runs the given + # +block+. + # + # Sets the socket to the :WEBrickSocket thread local variable + # in the thread. + # + # If any errors occur in the block they are logged and handled. + + def start_thread(sock, &block) + Thread.start{ + begin + Thread.current[:WEBrickSocket] = sock + begin + addr = sock.peeraddr + @logger.debug "accept: #{addr[3]}:#{addr[1]}" + rescue SocketError + @logger.debug "accept:
    " + raise + end + if sock.respond_to?(:sync_close=) && @config[:SSLStartImmediately] + WEBrick::Utils.timeout(@config[:RequestTimeout]) do + begin + sock.accept # OpenSSL::SSL::SSLSocket#accept + rescue Errno::ECONNRESET, Errno::ECONNABORTED, + Errno::EPROTO, Errno::EINVAL + Thread.exit + end + end + end + call_callback(:AcceptCallback, sock) + block ? block.call(sock) : run(sock) + rescue Errno::ENOTCONN + @logger.debug "Errno::ENOTCONN raised" + rescue ServerError => ex + msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}" + @logger.error msg + rescue Exception => ex + @logger.error ex + ensure + @tokens.push(nil) + Thread.current[:WEBrickSocket] = nil + if addr + @logger.debug "close: #{addr[3]}:#{addr[1]}" + else + @logger.debug "close:
    " + end + sock.close + end + } + end + + ## + # Calls the callback +callback_name+ from the configuration with +args+ + + def call_callback(callback_name, *args) + @config[callback_name]&.call(*args) + end + + def setup_shutdown_pipe + return @shutdown_pipe ||= IO.pipe + end + + def cleanup_shutdown_pipe(shutdown_pipe) + @shutdown_pipe = nil + shutdown_pipe&.each(&:close) + end + + def alarm_shutdown_pipe + _, pipe = @shutdown_pipe # another thread may modify @shutdown_pipe. + if pipe + if !pipe.closed? + begin + yield pipe + rescue IOError # closed by another thread. + end + end + end + end + + def cleanup_listener + @listeners.each{|s| + if @logger.debug? + addr = s.addr + @logger.debug("close TCPSocket(#{addr[2]}, #{addr[1]})") + end + begin + s.shutdown + rescue Errno::ENOTCONN + # when `Errno::ENOTCONN: Socket is not connected' on some platforms, + # call #close instead of #shutdown. + # (ignore @config[:ShutdownSocketWithoutClose]) + s.close + else + unless @config[:ShutdownSocketWithoutClose] + s.close + end + end + } + @listeners.clear + end + end # end of GenericServer +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/ssl.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/ssl.rb new file mode 100644 index 0000000..6937f93 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/ssl.rb @@ -0,0 +1,219 @@ +# frozen_string_literal: true +# +# ssl.rb -- SSL/TLS enhancement for GenericServer +# +# Copyright (c) 2003 GOTOU Yuuzou All rights reserved. +# +# $Id$ + +require 'webrick' +require 'openssl' + +module WEBrick + module Config + svrsoft = General[:ServerSoftware] + osslv = ::OpenSSL::OPENSSL_VERSION.split[1] + + ## + # Default SSL server configuration. + # + # WEBrick can automatically create a self-signed certificate if + # :SSLCertName is set. For more information on the various + # SSL options see OpenSSL::SSL::SSLContext. + # + # :ServerSoftware :: + # The server software name used in the Server: header. + # :SSLEnable :: false, + # Enable SSL for this server. Defaults to false. + # :SSLCertificate :: + # The SSL certificate for the server. + # :SSLPrivateKey :: + # The SSL private key for the server certificate. + # :SSLClientCA :: nil, + # Array of certificates that will be sent to the client. + # :SSLExtraChainCert :: nil, + # Array of certificates that will be added to the certificate chain + # :SSLCACertificateFile :: nil, + # Path to a CA certificate file + # :SSLCACertificatePath :: nil, + # Path to a directory containing CA certificates + # :SSLCertificateStore :: nil, + # OpenSSL::X509::Store used for certificate validation of the client + # :SSLTmpDhCallback :: nil, + # Callback invoked when DH parameters are required. + # :SSLVerifyClient :: + # Sets whether the client is verified. This defaults to VERIFY_NONE + # which is typical for an HTTPS server. + # :SSLVerifyDepth :: + # Number of CA certificates to walk when verifying a certificate chain + # :SSLVerifyCallback :: + # Custom certificate verification callback + # :SSLServerNameCallback:: + # Custom servername indication callback + # :SSLTimeout :: + # Maximum session lifetime + # :SSLOptions :: + # Various SSL options + # :SSLCiphers :: + # Ciphers to be used + # :SSLStartImmediately :: + # Immediately start SSL upon connection? Defaults to true + # :SSLCertName :: + # SSL certificate name. Must be set to enable automatic certificate + # creation. + # :SSLCertComment :: + # Comment used during automatic certificate creation. + + SSL = { + :ServerSoftware => "#{svrsoft} OpenSSL/#{osslv}", + :SSLEnable => false, + :SSLCertificate => nil, + :SSLPrivateKey => nil, + :SSLClientCA => nil, + :SSLExtraChainCert => nil, + :SSLCACertificateFile => nil, + :SSLCACertificatePath => nil, + :SSLCertificateStore => nil, + :SSLTmpDhCallback => nil, + :SSLVerifyClient => ::OpenSSL::SSL::VERIFY_NONE, + :SSLVerifyDepth => nil, + :SSLVerifyCallback => nil, # custom verification + :SSLTimeout => nil, + :SSLOptions => nil, + :SSLCiphers => nil, + :SSLStartImmediately => true, + # Must specify if you use auto generated certificate. + :SSLCertName => nil, + :SSLCertComment => "Generated by Ruby/OpenSSL" + } + General.update(SSL) + end + + module Utils + ## + # Creates a self-signed certificate with the given number of +bits+, + # the issuer +cn+ and a +comment+ to be stored in the certificate. + + def create_self_signed_cert(bits, cn, comment) + rsa = if $VERBOSE + OpenSSL::PKey::RSA.new(bits){|p, n| + case p + when 0; $stderr.putc "." # BN_generate_prime + when 1; $stderr.putc "+" # BN_generate_prime + when 2; $stderr.putc "*" # searching good prime, + # n = #of try, + # but also data from BN_generate_prime + when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q, + # but also data from BN_generate_prime + else; $stderr.putc "*" # BN_generate_prime + end + } + else + OpenSSL::PKey::RSA.new(bits) + end + cert = OpenSSL::X509::Certificate.new + cert.version = 2 + cert.serial = 1 + name = (cn.kind_of? String) ? OpenSSL::X509::Name.parse(cn) + : OpenSSL::X509::Name.new(cn) + cert.subject = name + cert.issuer = name + cert.not_before = Time.now + cert.not_after = Time.now + (365*24*60*60) + cert.public_key = rsa.public_key + + ef = OpenSSL::X509::ExtensionFactory.new(nil,cert) + ef.issuer_certificate = cert + cert.extensions = [ + ef.create_extension("basicConstraints","CA:FALSE"), + ef.create_extension("keyUsage", "keyEncipherment, digitalSignature, keyAgreement, dataEncipherment"), + ef.create_extension("subjectKeyIdentifier", "hash"), + ef.create_extension("extendedKeyUsage", "serverAuth"), + ef.create_extension("nsComment", comment), + ] + aki = ef.create_extension("authorityKeyIdentifier", + "keyid:always,issuer:always") + cert.add_extension(aki) + cert.sign(rsa, "SHA256") + + return [ cert, rsa ] + end + module_function :create_self_signed_cert + end + + ## + #-- + # Updates WEBrick::GenericServer with SSL functionality + + class GenericServer + + ## + # SSL context for the server when run in SSL mode + + def ssl_context # :nodoc: + @ssl_context ||= begin + if @config[:SSLEnable] + ssl_context = setup_ssl_context(@config) + @logger.info("\n" + @config[:SSLCertificate].to_text) + ssl_context + end + end + end + + undef listen + + ## + # Updates +listen+ to enable SSL when the SSL configuration is active. + + def listen(address, port) # :nodoc: + listeners = Utils::create_listeners(address, port) + if @config[:SSLEnable] + listeners.collect!{|svr| + ssvr = ::OpenSSL::SSL::SSLServer.new(svr, ssl_context) + ssvr.start_immediately = @config[:SSLStartImmediately] + ssvr + } + end + @listeners += listeners + setup_shutdown_pipe + end + + ## + # Sets up an SSL context for +config+ + + def setup_ssl_context(config) # :nodoc: + unless config[:SSLCertificate] + cn = config[:SSLCertName] + comment = config[:SSLCertComment] + cert, key = Utils::create_self_signed_cert(2048, cn, comment) + config[:SSLCertificate] = cert + config[:SSLPrivateKey] = key + end + ctx = OpenSSL::SSL::SSLContext.new + ctx.key = config[:SSLPrivateKey] + ctx.cert = config[:SSLCertificate] + ctx.client_ca = config[:SSLClientCA] + ctx.extra_chain_cert = config[:SSLExtraChainCert] + ctx.ca_file = config[:SSLCACertificateFile] + ctx.ca_path = config[:SSLCACertificatePath] + ctx.cert_store = config[:SSLCertificateStore] + ctx.tmp_dh_callback = config[:SSLTmpDhCallback] + ctx.verify_mode = config[:SSLVerifyClient] + ctx.verify_depth = config[:SSLVerifyDepth] + ctx.verify_callback = config[:SSLVerifyCallback] + ctx.servername_cb = config[:SSLServerNameCallback] || proc { |args| ssl_servername_callback(*args) } + ctx.timeout = config[:SSLTimeout] + ctx.options = config[:SSLOptions] + ctx.ciphers = config[:SSLCiphers] + ctx + end + + ## + # ServerNameIndication callback + + def ssl_servername_callback(sslsocket, hostname = nil) + # default + end + + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/utils.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/utils.rb new file mode 100644 index 0000000..e4902d0 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/utils.rb @@ -0,0 +1,265 @@ +# frozen_string_literal: true +# +# utils.rb -- Miscellaneous utilities +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: utils.rb,v 1.10 2003/02/16 22:22:54 gotoyuzo Exp $ + +require 'socket' +require 'io/nonblock' +require 'etc' + +module WEBrick + module Utils + ## + # Sets IO operations on +io+ to be non-blocking + def set_non_blocking(io) + io.nonblock = true if io.respond_to?(:nonblock=) + end + module_function :set_non_blocking + + ## + # Sets the close on exec flag for +io+ + def set_close_on_exec(io) + io.close_on_exec = true if io.respond_to?(:close_on_exec=) + end + module_function :set_close_on_exec + + ## + # Changes the process's uid and gid to the ones of +user+ + def su(user) + if pw = Etc.getpwnam(user) + Process::initgroups(user, pw.gid) + Process::Sys::setgid(pw.gid) + Process::Sys::setuid(pw.uid) + else + warn("WEBrick::Utils::su doesn't work on this platform", uplevel: 1) + end + end + module_function :su + + ## + # The server hostname + def getservername + Socket::gethostname + end + module_function :getservername + + ## + # Creates TCP server sockets bound to +address+:+port+ and returns them. + # + # It will create IPV4 and IPV6 sockets on all interfaces. + def create_listeners(address, port) + unless port + raise ArgumentError, "must specify port" + end + sockets = Socket.tcp_server_sockets(address, port) + sockets = sockets.map {|s| + s.autoclose = false + ts = TCPServer.for_fd(s.fileno) + s.close + ts + } + return sockets + end + module_function :create_listeners + + ## + # Characters used to generate random strings + RAND_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "0123456789" + + "abcdefghijklmnopqrstuvwxyz" + + ## + # Generates a random string of length +len+ + def random_string(len) + rand_max = RAND_CHARS.bytesize + ret = +"" + len.times{ ret << RAND_CHARS[rand(rand_max)] } + ret + end + module_function :random_string + + ########### + + require "timeout" + require "singleton" + + ## + # Class used to manage timeout handlers across multiple threads. + # + # Timeout handlers should be managed by using the class methods which are + # synchronized. + # + # id = TimeoutHandler.register(10, Timeout::Error) + # begin + # sleep 20 + # puts 'foo' + # ensure + # TimeoutHandler.cancel(id) + # end + # + # will raise Timeout::Error + # + # id = TimeoutHandler.register(10, Timeout::Error) + # begin + # sleep 5 + # puts 'foo' + # ensure + # TimeoutHandler.cancel(id) + # end + # + # will print 'foo' + # + class TimeoutHandler + include Singleton + + ## + # Mutex used to synchronize access across threads + TimeoutMutex = Thread::Mutex.new # :nodoc: + + ## + # Registers a new timeout handler + # + # +time+:: Timeout in seconds + # +exception+:: Exception to raise when timeout elapsed + def TimeoutHandler.register(seconds, exception) + at = Process.clock_gettime(Process::CLOCK_MONOTONIC) + seconds + instance.register(Thread.current, at, exception) + end + + ## + # Cancels the timeout handler +id+ + def TimeoutHandler.cancel(id) + instance.cancel(Thread.current, id) + end + + def self.terminate + instance.terminate + end + + ## + # Creates a new TimeoutHandler. You should use ::register and ::cancel + # instead of creating the timeout handler directly. + def initialize + TimeoutMutex.synchronize{ + @timeout_info = Hash.new + } + @queue = Thread::Queue.new + @watcher = nil + end + + # :nodoc: + private \ + def watch + to_interrupt = [] + while true + now = Process.clock_gettime(Process::CLOCK_MONOTONIC) + wakeup = nil + to_interrupt.clear + TimeoutMutex.synchronize{ + @timeout_info.each {|thread, ary| + next unless ary + ary.each{|info| + time, exception = *info + if time < now + to_interrupt.push [thread, info.object_id, exception] + elsif !wakeup || time < wakeup + wakeup = time + end + } + } + } + to_interrupt.each {|arg| interrupt(*arg)} + if !wakeup + @queue.pop + elsif (wakeup -= now) > 0 + begin + (th = Thread.start {@queue.pop}).join(wakeup) + ensure + th&.kill&.join + end + end + @queue.clear + end + end + + # :nodoc: + private \ + def watcher + (w = @watcher)&.alive? and return w # usual case + TimeoutMutex.synchronize{ + (w = @watcher)&.alive? and next w # pathological check + @watcher = Thread.start(&method(:watch)) + } + end + + ## + # Interrupts the timeout handler +id+ and raises +exception+ + def interrupt(thread, id, exception) + if cancel(thread, id) && thread.alive? + thread.raise(exception, "execution timeout") + end + end + + ## + # Registers a new timeout handler + # + # +time+:: Timeout in seconds + # +exception+:: Exception to raise when timeout elapsed + def register(thread, time, exception) + info = nil + TimeoutMutex.synchronize{ + (@timeout_info[thread] ||= []) << (info = [time, exception]) + } + @queue.push nil + watcher + return info.object_id + end + + ## + # Cancels the timeout handler +id+ + def cancel(thread, id) + TimeoutMutex.synchronize{ + if ary = @timeout_info[thread] + ary.delete_if{|info| info.object_id == id } + if ary.empty? + @timeout_info.delete(thread) + end + return true + end + return false + } + end + + ## + def terminate + TimeoutMutex.synchronize{ + @timeout_info.clear + @watcher&.kill&.join + } + end + end + + ## + # Executes the passed block and raises +exception+ if execution takes more + # than +seconds+. + # + # If +seconds+ is zero or nil, simply executes the block + def timeout(seconds, exception=Timeout::Error) + return yield if seconds.nil? or seconds.zero? + # raise ThreadError, "timeout within critical session" if Thread.critical + id = TimeoutHandler.register(seconds, exception) + begin + yield(seconds) + ensure + TimeoutHandler.cancel(id) + end + end + module_function :timeout + end +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/version.rb b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/version.rb new file mode 100644 index 0000000..ceeefc3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/version.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +#-- +# version.rb -- version and release date +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU +# Copyright (c) 2003 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: version.rb,v 1.74 2003/07/22 19:20:43 gotoyuzo Exp $ + +module WEBrick + + ## + # The WEBrick version + + VERSION = "1.8.1" +end diff --git a/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/webrick.gemspec b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/webrick.gemspec new file mode 100644 index 0000000..31423e9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/webrick.gemspec @@ -0,0 +1,70 @@ +# frozen_string_literal: true +begin + require_relative 'lib/webrick/version' +rescue LoadError + # for Ruby core repository + require_relative 'version' +end + +Gem::Specification.new do |s| + s.name = "webrick" + s.version = WEBrick::VERSION + s.summary = "HTTP server toolkit" + s.description = "WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server." + + s.require_path = %w{lib} + s.files = [ + "Gemfile", + "LICENSE.txt", + "README.md", + "Rakefile", + "lib/webrick.rb", + "lib/webrick/accesslog.rb", + "lib/webrick/cgi.rb", + "lib/webrick/compat.rb", + "lib/webrick/config.rb", + "lib/webrick/cookie.rb", + "lib/webrick/htmlutils.rb", + "lib/webrick/httpauth.rb", + "lib/webrick/httpauth/authenticator.rb", + "lib/webrick/httpauth/basicauth.rb", + "lib/webrick/httpauth/digestauth.rb", + "lib/webrick/httpauth/htdigest.rb", + "lib/webrick/httpauth/htgroup.rb", + "lib/webrick/httpauth/htpasswd.rb", + "lib/webrick/httpauth/userdb.rb", + "lib/webrick/httpproxy.rb", + "lib/webrick/httprequest.rb", + "lib/webrick/httpresponse.rb", + "lib/webrick/https.rb", + "lib/webrick/httpserver.rb", + "lib/webrick/httpservlet.rb", + "lib/webrick/httpservlet/abstract.rb", + "lib/webrick/httpservlet/cgi_runner.rb", + "lib/webrick/httpservlet/cgihandler.rb", + "lib/webrick/httpservlet/erbhandler.rb", + "lib/webrick/httpservlet/filehandler.rb", + "lib/webrick/httpservlet/prochandler.rb", + "lib/webrick/httpstatus.rb", + "lib/webrick/httputils.rb", + "lib/webrick/httpversion.rb", + "lib/webrick/log.rb", + "lib/webrick/server.rb", + "lib/webrick/ssl.rb", + "lib/webrick/utils.rb", + "lib/webrick/version.rb", + "webrick.gemspec", + ] + s.required_ruby_version = ">= 2.4.0" + + s.authors = ["TAKAHASHI Masayoshi", "GOTOU YUUZOU", "Eric Wong"] + s.email = [nil, nil, 'normal@ruby-lang.org'] + s.homepage = "https://github.com/ruby/webrick" + s.licenses = ["Ruby", "BSD-2-Clause"] + + if s.respond_to?(:metadata=) + s.metadata = { + "bug_tracker_uri" => "https://github.com/ruby/webrick/issues", + } + end +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/addressable-2.8.7.gemspec b/vendor/bundle/ruby/3.2.0/specifications/addressable-2.8.7.gemspec new file mode 100644 index 0000000..f227c00 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/addressable-2.8.7.gemspec @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- +# stub: addressable 2.8.7 ruby lib + +Gem::Specification.new do |s| + s.name = "addressable".freeze + s.version = "2.8.7" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md#v2.8.7" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Bob Aman".freeze] + s.date = "2024-06-21" + s.description = "Addressable is an alternative implementation to the URI implementation that is\npart of Ruby's standard library. It is flexible, offers heuristic parsing, and\nadditionally provides extensive support for IRIs and URI templates.\n".freeze + s.email = "bob@sporkmonger.com".freeze + s.extra_rdoc_files = ["README.md".freeze] + s.files = ["README.md".freeze] + s.homepage = "https://github.com/sporkmonger/addressable".freeze + s.licenses = ["Apache-2.0".freeze] + s.rdoc_options = ["--main".freeze, "README.md".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "URI Implementation".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, [">= 2.0.2", "< 7.0"]) + s.add_development_dependency(%q.freeze, [">= 1.0", "< 3.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/bigdecimal-3.1.8.gemspec b/vendor/bundle/ruby/3.2.0/specifications/bigdecimal-3.1.8.gemspec new file mode 100644 index 0000000..d709627 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/bigdecimal-3.1.8.gemspec @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +# stub: bigdecimal 3.1.8 ruby lib +# stub: ext/bigdecimal/extconf.rb + +Gem::Specification.new do |s| + s.name = "bigdecimal".freeze + s.version = "3.1.8" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "changelog_uri" => "https://github.com/ruby/bigdecimal/blob/master/CHANGES.md" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Kenta Murata".freeze, "Zachary Scott".freeze, "Shigeo Kobayashi".freeze] + s.date = "2024-05-07" + s.description = "This library provides arbitrary-precision decimal floating-point number class.".freeze + s.email = ["mrkn@mrkn.jp".freeze] + s.extensions = ["ext/bigdecimal/extconf.rb".freeze] + s.files = ["ext/bigdecimal/extconf.rb".freeze] + s.homepage = "https://github.com/ruby/bigdecimal".freeze + s.licenses = ["Ruby".freeze, "BSD-2-Clause".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.5.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Arbitrary-precision decimal floating-point number library.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/colorator-1.1.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/colorator-1.1.0.gemspec new file mode 100644 index 0000000..a5851a4 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/colorator-1.1.0.gemspec @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +# stub: colorator 1.1.0 ruby lib + +Gem::Specification.new do |s| + s.name = "colorator".freeze + s.version = "1.1.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Parker Moore".freeze, "Brandon Mathis".freeze] + s.date = "2016-06-29" + s.email = ["parkrmoore@gmail.com".freeze, "brandon@imathis.com".freeze] + s.extra_rdoc_files = ["README.markdown".freeze, "LICENSE".freeze] + s.files = ["LICENSE".freeze, "README.markdown".freeze] + s.homepage = "https://github.com/octopress/colorator".freeze + s.licenses = ["MIT".freeze] + s.rdoc_options = ["--charset=UTF-8".freeze] + s.rubygems_version = "3.4.10".freeze + s.summary = "Colorize your text in the terminal.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["~> 3.1"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/concurrent-ruby-1.3.4.gemspec b/vendor/bundle/ruby/3.2.0/specifications/concurrent-ruby-1.3.4.gemspec new file mode 100644 index 0000000..6bdb4ea --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/concurrent-ruby-1.3.4.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +# stub: concurrent-ruby 1.3.4 ruby lib/concurrent-ruby + +Gem::Specification.new do |s| + s.name = "concurrent-ruby".freeze + s.version = "1.3.4" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "changelog_uri" => "https://github.com/ruby-concurrency/concurrent-ruby/blob/master/CHANGELOG.md", "source_code_uri" => "https://github.com/ruby-concurrency/concurrent-ruby" } if s.respond_to? :metadata= + s.require_paths = ["lib/concurrent-ruby".freeze] + s.authors = ["Jerry D'Antonio".freeze, "Petr Chalupa".freeze, "The Ruby Concurrency Team".freeze] + s.date = "2024-08-10" + s.description = "Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.\nInspired by Erlang, Clojure, Go, JavaScript, actors, and classic concurrency patterns.\n".freeze + s.email = "concurrent-ruby@googlegroups.com".freeze + s.extra_rdoc_files = ["README.md".freeze, "LICENSE.txt".freeze, "CHANGELOG.md".freeze] + s.files = ["CHANGELOG.md".freeze, "LICENSE.txt".freeze, "README.md".freeze] + s.homepage = "http://www.concurrent-ruby.com".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.3".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Modern concurrency tools for Ruby. Inspired by Erlang, Clojure, Scala, Haskell, F#, C#, Java, and classic concurrency patterns.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/em-websocket-0.5.3.gemspec b/vendor/bundle/ruby/3.2.0/specifications/em-websocket-0.5.3.gemspec new file mode 100644 index 0000000..689ce59 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/em-websocket-0.5.3.gemspec @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +# stub: em-websocket 0.5.3 ruby lib + +Gem::Specification.new do |s| + s.name = "em-websocket".freeze + s.version = "0.5.3" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Ilya Grigorik".freeze, "Martyn Loughran".freeze] + s.date = "2021-11-11" + s.description = "EventMachine based WebSocket server".freeze + s.email = ["ilya@igvita.com".freeze, "me@mloughran.com".freeze] + s.homepage = "http://github.com/igrigorik/em-websocket".freeze + s.licenses = ["MIT".freeze] + s.rubygems_version = "3.4.10".freeze + s.summary = "EventMachine based WebSocket server".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, [">= 0.12.9"]) + s.add_runtime_dependency(%q.freeze, ["~> 0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/eventmachine-1.2.7.gemspec b/vendor/bundle/ruby/3.2.0/specifications/eventmachine-1.2.7.gemspec new file mode 100644 index 0000000..32722db Binary files /dev/null and b/vendor/bundle/ruby/3.2.0/specifications/eventmachine-1.2.7.gemspec differ diff --git a/vendor/bundle/ruby/3.2.0/specifications/ffi-1.17.0-x86_64-linux-gnu.gemspec b/vendor/bundle/ruby/3.2.0/specifications/ffi-1.17.0-x86_64-linux-gnu.gemspec new file mode 100644 index 0000000..bfd1cdd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/ffi-1.17.0-x86_64-linux-gnu.gemspec @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +# stub: ffi 1.17.0 x86_64-linux-gnu lib + +Gem::Specification.new do |s| + s.name = "ffi".freeze + s.version = "1.17.0" + s.platform = "x86_64-linux-gnu".freeze + + s.required_rubygems_version = Gem::Requirement.new(">= 3.3.22".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/ffi/ffi/issues", "changelog_uri" => "https://github.com/ffi/ffi/blob/master/CHANGELOG.md", "documentation_uri" => "https://github.com/ffi/ffi/wiki", "mailing_list_uri" => "http://groups.google.com/group/ruby-ffi", "source_code_uri" => "https://github.com/ffi/ffi/", "wiki_uri" => "https://github.com/ffi/ffi/wiki" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Wayne Meissner".freeze] + s.date = "2024-06-02" + s.description = "Ruby FFI library".freeze + s.email = "wmeissner@gmail.com".freeze + s.homepage = "https://github.com/ffi/ffi/wiki".freeze + s.licenses = ["BSD-3-Clause".freeze] + s.rdoc_options = ["--exclude=ext/ffi_c/.*\\.o$".freeze, "--exclude=ffi_c\\.(bundle|so)$".freeze] + s.required_ruby_version = Gem::Requirement.new([">= 2.5".freeze, "< 3.4.dev".freeze]) + s.rubygems_version = "3.4.10".freeze + s.summary = "Ruby FFI".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["~> 13.0"]) + s.add_development_dependency(%q.freeze, ["~> 1.1"]) + s.add_development_dependency(%q.freeze, ["~> 1.0"]) + s.add_development_dependency(%q.freeze, ["~> 2.14.1"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/forwardable-extended-2.6.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/forwardable-extended-2.6.0.gemspec new file mode 100644 index 0000000..48a6ad8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/forwardable-extended-2.6.0.gemspec @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- +# stub: forwardable-extended 2.6.0 ruby lib + +Gem::Specification.new do |s| + s.name = "forwardable-extended".freeze + s.version = "2.6.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Jordon Bedwell".freeze] + s.date = "2016-04-06" + s.description = "Forwardable with hash, and instance variable extensions.".freeze + s.email = ["jordon@envygeeks.io".freeze] + s.homepage = "http://github.com/envygeeks/forwardable-extended".freeze + s.licenses = ["MIT".freeze] + s.rubygems_version = "3.4.10".freeze + s.summary = "Forwardable with hash, and instance variable extensions.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/google-protobuf-4.27.3-x86_64-linux.gemspec b/vendor/bundle/ruby/3.2.0/specifications/google-protobuf-4.27.3-x86_64-linux.gemspec new file mode 100644 index 0000000..71d349d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/google-protobuf-4.27.3-x86_64-linux.gemspec @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +# stub: google-protobuf 4.27.3 x86_64-linux lib + +Gem::Specification.new do |s| + s.name = "google-protobuf".freeze + s.version = "4.27.3" + s.platform = "x86_64-linux".freeze + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "source_code_uri" => "https://github.com/protocolbuffers/protobuf/tree/v4.27.3/ruby" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Protobuf Authors".freeze] + s.date = "2024-07-31" + s.description = "Protocol Buffers are Google's data interchange format.".freeze + s.email = "protobuf@googlegroups.com".freeze + s.homepage = "https://developers.google.com/protocol-buffers".freeze + s.licenses = ["BSD-3-Clause".freeze] + s.required_ruby_version = Gem::Requirement.new([">= 3.0".freeze, "< 3.4.dev".freeze]) + s.rubygems_version = "3.4.10".freeze + s.summary = "Protocol Buffers".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["= 1.2.1"]) + s.add_runtime_dependency(%q.freeze, [">= 0"]) + s.add_runtime_dependency(%q.freeze, [">= 13"]) + s.add_development_dependency(%q.freeze, ["~> 1"]) + s.add_development_dependency(%q.freeze, ["~> 1"]) + s.add_development_dependency(%q.freeze, ["~> 1.1.0"]) + s.add_development_dependency(%q.freeze, ["~> 3.0", ">= 3.0.9"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/http_parser.rb-0.8.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/http_parser.rb-0.8.0.gemspec new file mode 100644 index 0000000..b917689 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/http_parser.rb-0.8.0.gemspec @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- +# stub: http_parser.rb 0.8.0 ruby lib +# stub: ext/ruby_http_parser/extconf.rb + +Gem::Specification.new do |s| + s.name = "http_parser.rb".freeze + s.version = "0.8.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Marc-Andre Cournoyer".freeze, "Aman Gupta".freeze] + s.date = "2021-09-01" + s.description = "Ruby bindings to https://github.com/joyent/http-parser and https://github.com/http-parser/http-parser.java".freeze + s.email = ["macournoyer@gmail.com".freeze, "aman@tmm1.net".freeze] + s.extensions = ["ext/ruby_http_parser/extconf.rb".freeze] + s.files = ["ext/ruby_http_parser/extconf.rb".freeze] + s.homepage = "https://github.com/tmm1/http_parser.rb".freeze + s.licenses = ["MIT".freeze] + s.rubygems_version = "3.4.10".freeze + s.summary = "Simple callback-based HTTP request/response parser".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["~> 1.0"]) + s.add_development_dependency(%q.freeze, ["~> 3"]) + s.add_development_dependency(%q.freeze, ["~> 2.1"]) + s.add_development_dependency(%q.freeze, ["~> 1.0"]) + s.add_development_dependency(%q.freeze, ["~> 1.9"]) + s.add_development_dependency(%q.freeze, ["~> 1.3"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/i18n-1.14.5.gemspec b/vendor/bundle/ruby/3.2.0/specifications/i18n-1.14.5.gemspec new file mode 100644 index 0000000..91b7093 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/i18n-1.14.5.gemspec @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +# stub: i18n 1.14.5 ruby lib + +Gem::Specification.new do |s| + s.name = "i18n".freeze + s.version = "1.14.5" + + s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/ruby-i18n/i18n/issues", "changelog_uri" => "https://github.com/ruby-i18n/i18n/releases", "documentation_uri" => "https://guides.rubyonrails.org/i18n.html", "source_code_uri" => "https://github.com/ruby-i18n/i18n" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Sven Fuchs".freeze, "Joshua Harvey".freeze, "Matt Aimonetti".freeze, "Stephan Soller".freeze, "Saimon Moore".freeze, "Ryan Bigg".freeze] + s.date = "2024-05-06" + s.description = "New wave Internationalization support for Ruby.".freeze + s.email = "rails-i18n@googlegroups.com".freeze + s.homepage = "https://github.com/ruby-i18n/i18n".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "New wave Internationalization support for Ruby".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 1.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/jekyll-4.3.3.gemspec b/vendor/bundle/ruby/3.2.0/specifications/jekyll-4.3.3.gemspec new file mode 100644 index 0000000..4dedd2c --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/jekyll-4.3.3.gemspec @@ -0,0 +1,45 @@ +# -*- encoding: utf-8 -*- +# stub: jekyll 4.3.3 ruby lib + +Gem::Specification.new do |s| + s.name = "jekyll".freeze + s.version = "4.3.3" + + s.required_rubygems_version = Gem::Requirement.new(">= 2.7.0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/jekyll/jekyll/issues", "changelog_uri" => "https://github.com/jekyll/jekyll/releases", "homepage_uri" => "https://jekyllrb.com", "source_code_uri" => "https://github.com/jekyll/jekyll" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Tom Preston-Werner".freeze, "Parker Moore".freeze, "Matt Rogers".freeze] + s.bindir = "exe".freeze + s.date = "2023-12-27" + s.description = "Jekyll is a simple, blog aware, static site generator.".freeze + s.email = ["maintainers@jekyllrb.com".freeze] + s.executables = ["jekyll".freeze] + s.extra_rdoc_files = ["README.markdown".freeze, "LICENSE".freeze] + s.files = ["LICENSE".freeze, "README.markdown".freeze, "exe/jekyll".freeze] + s.homepage = "https://jekyllrb.com".freeze + s.licenses = ["MIT".freeze] + s.rdoc_options = ["--charset=UTF-8".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.5.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "A simple, blog aware, static site generator.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 2.4"]) + s.add_runtime_dependency(%q.freeze, ["~> 1.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 0.5"]) + s.add_runtime_dependency(%q.freeze, ["~> 1.0"]) + s.add_runtime_dependency(%q.freeze, [">= 2.0", "< 4.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 2.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 2.3", ">= 2.3.1"]) + s.add_runtime_dependency(%q.freeze, ["~> 1.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 4.0"]) + s.add_runtime_dependency(%q.freeze, [">= 0.3.6", "< 0.5"]) + s.add_runtime_dependency(%q.freeze, ["~> 0.9"]) + s.add_runtime_dependency(%q.freeze, [">= 3.0", "< 5.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 1.0"]) + s.add_runtime_dependency(%q.freeze, [">= 1.8", "< 4.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 1.7"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/jekyll-sass-converter-3.0.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/jekyll-sass-converter-3.0.0.gemspec new file mode 100644 index 0000000..3354ec3 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/jekyll-sass-converter-3.0.0.gemspec @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +# stub: jekyll-sass-converter 3.0.0 ruby lib + +Gem::Specification.new do |s| + s.name = "jekyll-sass-converter".freeze + s.version = "3.0.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Parker Moore".freeze] + s.date = "2022-12-21" + s.email = ["parkrmoore@gmail.com".freeze] + s.homepage = "https://github.com/jekyll/jekyll-sass-converter".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.6.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "A basic Sass converter for Jekyll.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 1.54"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, ["~> 0.12.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/jekyll-watch-2.2.1.gemspec b/vendor/bundle/ruby/3.2.0/specifications/jekyll-watch-2.2.1.gemspec new file mode 100644 index 0000000..bb02aa9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/jekyll-watch-2.2.1.gemspec @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +# stub: jekyll-watch 2.2.1 ruby lib + +Gem::Specification.new do |s| + s.name = "jekyll-watch".freeze + s.version = "2.2.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Parker Moore".freeze] + s.date = "2019-03-22" + s.email = ["parkrmoore@gmail.com".freeze] + s.homepage = "https://github.com/jekyll/jekyll-watch".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Rebuild your Jekyll site when a file changes with the `--watch` switch.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 3.0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 3.6", "< 5.0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, ["~> 3.0"]) + s.add_development_dependency(%q.freeze, ["~> 0.5"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/kramdown-2.4.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/kramdown-2.4.0.gemspec new file mode 100644 index 0000000..66f7c7f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/kramdown-2.4.0.gemspec @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +# stub: kramdown 2.4.0 ruby lib + +Gem::Specification.new do |s| + s.name = "kramdown".freeze + s.version = "2.4.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Thomas Leitner".freeze] + s.date = "2022-04-25" + s.description = "kramdown is yet-another-markdown-parser but fast, pure Ruby,\nusing a strict syntax definition and supporting several common extensions.\n".freeze + s.email = "t_leitner@gmx.at".freeze + s.executables = ["kramdown".freeze] + s.files = ["bin/kramdown".freeze] + s.homepage = "http://kramdown.gettalong.org".freeze + s.licenses = ["MIT".freeze] + s.rdoc_options = ["--main".freeze, "lib/kramdown/document.rb".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.3".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "kramdown is a fast, pure-Ruby Markdown-superset converter.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, ["~> 5.0"]) + s.add_development_dependency(%q.freeze, ["~> 3.0", ">= 3.26.0"]) + s.add_development_dependency(%q.freeze, ["~> 1.5.1"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/kramdown-parser-gfm-1.1.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/kramdown-parser-gfm-1.1.0.gemspec new file mode 100644 index 0000000..d9a7c64 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/kramdown-parser-gfm-1.1.0.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +# stub: kramdown-parser-gfm 1.1.0 ruby lib + +Gem::Specification.new do |s| + s.name = "kramdown-parser-gfm".freeze + s.version = "1.1.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Thomas Leitner".freeze] + s.date = "2019-05-29" + s.email = "t_leitner@gmx.at".freeze + s.homepage = "https://github.com/kramdown/parser-gfm".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.3".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "kramdown-parser-gfm provides a kramdown parser for the GFM dialect of Markdown".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 2.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/liquid-4.0.4.gemspec b/vendor/bundle/ruby/3.2.0/specifications/liquid-4.0.4.gemspec new file mode 100644 index 0000000..ec4783d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/liquid-4.0.4.gemspec @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +# stub: liquid 4.0.4 ruby lib + +Gem::Specification.new do |s| + s.name = "liquid".freeze + s.version = "4.0.4" + + s.required_rubygems_version = Gem::Requirement.new(">= 1.3.7".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "allowed_push_host" => "https://rubygems.org" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Tobias L\u00FCtke".freeze] + s.date = "2023-01-11" + s.email = ["tobi@leetsoft.com".freeze] + s.extra_rdoc_files = ["History.md".freeze, "README.md".freeze] + s.files = ["History.md".freeze, "README.md".freeze] + s.homepage = "http://www.liquidmarkup.org".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.1.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "A secure, non-evaling end user template engine with aesthetic markup.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["~> 13.0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/listen-3.9.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/listen-3.9.0.gemspec new file mode 100644 index 0000000..7a44d4d --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/listen-3.9.0.gemspec @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +# stub: listen 3.9.0 ruby lib + +Gem::Specification.new do |s| + s.name = "listen".freeze + s.version = "3.9.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "allowed_push_host" => "https://rubygems.org", "bug_tracker_uri" => "https://github.com/guard/listen/issues", "changelog_uri" => "https://github.com/guard/listen/releases", "documentation_uri" => "https://www.rubydoc.info/gems/listen/3.9.0", "homepage_uri" => "https://github.com/guard/listen", "source_code_uri" => "https://github.com/guard/listen/tree/v3.9.0" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Thibaud Guillaume-Gentil".freeze] + s.date = "2024-02-24" + s.description = "The Listen gem listens to file modifications and notifies you about the changes. Works everywhere!".freeze + s.email = "thibaud@thibaud.gg".freeze + s.executables = ["listen".freeze] + s.files = ["bin/listen".freeze] + s.homepage = "https://github.com/guard/listen".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Listen to file modifications".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 0.10", ">= 0.10.3"]) + s.add_runtime_dependency(%q.freeze, ["~> 0.9", ">= 0.9.10"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/mercenary-0.4.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/mercenary-0.4.0.gemspec new file mode 100644 index 0000000..008beeb --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/mercenary-0.4.0.gemspec @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +# stub: mercenary 0.4.0 ruby lib + +Gem::Specification.new do |s| + s.name = "mercenary".freeze + s.version = "0.4.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Tom Preston-Werner".freeze, "Parker Moore".freeze] + s.date = "2020-01-18" + s.description = "Lightweight and flexible library for writing command-line apps in Ruby.".freeze + s.email = ["tom@mojombo.com".freeze, "parkrmoore@gmail.com".freeze] + s.homepage = "https://github.com/jekyll/mercenary".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Lightweight and flexible library for writing command-line apps in Ruby.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, ["~> 3.0"]) + s.add_development_dependency(%q.freeze, ["~> 0.10.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/pathutil-0.16.2.gemspec b/vendor/bundle/ruby/3.2.0/specifications/pathutil-0.16.2.gemspec new file mode 100644 index 0000000..c187499 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/pathutil-0.16.2.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +# stub: pathutil 0.16.2 ruby lib + +Gem::Specification.new do |s| + s.name = "pathutil".freeze + s.version = "0.16.2" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Jordon Bedwell".freeze] + s.date = "2018-10-30" + s.description = "Like Pathname but a little less insane.".freeze + s.email = ["jordon@envygeeks.io".freeze] + s.homepage = "http://github.com/envygeeks/pathutil".freeze + s.licenses = ["MIT".freeze] + s.rubygems_version = "3.4.10".freeze + s.summary = "Almost like Pathname but just a little less insane.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 2.6"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/public_suffix-6.0.1.gemspec b/vendor/bundle/ruby/3.2.0/specifications/public_suffix-6.0.1.gemspec new file mode 100644 index 0000000..6378e59 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/public_suffix-6.0.1.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +# stub: public_suffix 6.0.1 ruby lib + +Gem::Specification.new do |s| + s.name = "public_suffix".freeze + s.version = "6.0.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/weppos/publicsuffix-ruby/issues", "changelog_uri" => "https://github.com/weppos/publicsuffix-ruby/blob/master/CHANGELOG.md", "documentation_uri" => "https://rubydoc.info/gems/public_suffix/6.0.1", "homepage_uri" => "https://simonecarletti.com/code/publicsuffix-ruby", "source_code_uri" => "https://github.com/weppos/publicsuffix-ruby/tree/v6.0.1" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Simone Carletti".freeze] + s.date = "2024-07-23" + s.description = "PublicSuffix can parse and decompose a domain name into top level domain, domain and subdomains.".freeze + s.email = ["weppos@weppos.net".freeze] + s.extra_rdoc_files = ["LICENSE.txt".freeze] + s.files = ["LICENSE.txt".freeze] + s.homepage = "https://simonecarletti.com/code/publicsuffix-ruby".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 3.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Domain name parser based on the Public Suffix List.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/rake-13.2.1.gemspec b/vendor/bundle/ruby/3.2.0/specifications/rake-13.2.1.gemspec new file mode 100644 index 0000000..bd5eb07 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/rake-13.2.1.gemspec @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +# stub: rake 13.2.1 ruby lib + +Gem::Specification.new do |s| + s.name = "rake".freeze + s.version = "13.2.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/ruby/rake/issues", "changelog_uri" => "https://github.com/ruby/rake/blob/v13.2.1/History.rdoc", "documentation_uri" => "https://ruby.github.io/rake", "source_code_uri" => "https://github.com/ruby/rake/tree/v13.2.1" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Hiroshi SHIBATA".freeze, "Eric Hodel".freeze, "Jim Weirich".freeze] + s.bindir = "exe".freeze + s.date = "2024-04-05" + s.description = "Rake is a Make-like program implemented in Ruby. Tasks and dependencies are\nspecified in standard Ruby syntax.\nRake has the following features:\n * Rakefiles (rake's version of Makefiles) are completely defined in standard Ruby syntax.\n No XML files to edit. No quirky Makefile syntax to worry about (is that a tab or a space?)\n * Users can specify tasks with prerequisites.\n * Rake supports rule patterns to synthesize implicit tasks.\n * Flexible FileLists that act like arrays but know about manipulating file names and paths.\n * Supports parallel execution of tasks.\n".freeze + s.email = ["hsbt@ruby-lang.org".freeze, "drbrain@segment7.net".freeze, "".freeze] + s.executables = ["rake".freeze] + s.files = ["exe/rake".freeze] + s.homepage = "https://github.com/ruby/rake".freeze + s.licenses = ["MIT".freeze] + s.rdoc_options = ["--main".freeze, "README.rdoc".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.3".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Rake is a Make-like program implemented in Ruby".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/rb-fsevent-0.11.2.gemspec b/vendor/bundle/ruby/3.2.0/specifications/rb-fsevent-0.11.2.gemspec new file mode 100644 index 0000000..fa6580f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/rb-fsevent-0.11.2.gemspec @@ -0,0 +1,27 @@ +# -*- encoding: utf-8 -*- +# stub: rb-fsevent 0.11.2 ruby lib + +Gem::Specification.new do |s| + s.name = "rb-fsevent".freeze + s.version = "0.11.2" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "source_code_uri" => "https://github.com/thibaudgg/rb-fsevent" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Thibaud Guillaume-Gentil".freeze, "Travis Tilley".freeze] + s.date = "2022-08-29" + s.description = "FSEvents API with Signals catching (without RubyCocoa)".freeze + s.email = ["thibaud@thibaud.gg".freeze, "ttilley@gmail.com".freeze] + s.homepage = "http://rubygems.org/gems/rb-fsevent".freeze + s.licenses = ["MIT".freeze] + s.rubygems_version = "3.4.10".freeze + s.summary = "Very simple & usable FSEvents API".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["~> 3.6"]) + s.add_development_dependency(%q.freeze, ["~> 4.2"]) + s.add_development_dependency(%q.freeze, ["~> 12.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/rb-inotify-0.11.1.gemspec b/vendor/bundle/ruby/3.2.0/specifications/rb-inotify-0.11.1.gemspec new file mode 100644 index 0000000..871c4a9 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/rb-inotify-0.11.1.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +# stub: rb-inotify 0.11.1 ruby lib + +Gem::Specification.new do |s| + s.name = "rb-inotify".freeze + s.version = "0.11.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Natalie Weizenbaum".freeze, "Samuel Williams".freeze] + s.date = "2024-05-19" + s.email = ["nex342@gmail.com".freeze, "samuel.williams@oriontransfer.co.nz".freeze] + s.homepage = "https://github.com/guard/rb-inotify".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.5".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "A Ruby wrapper for Linux inotify, using FFI".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 1.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/rexml-3.3.5.gemspec b/vendor/bundle/ruby/3.2.0/specifications/rexml-3.3.5.gemspec new file mode 100644 index 0000000..88711bc --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/rexml-3.3.5.gemspec @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +# stub: rexml 3.3.5 ruby lib + +Gem::Specification.new do |s| + s.name = "rexml".freeze + s.version = "3.3.5" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "changelog_uri" => "https://github.com/ruby/rexml/releases/tag/v3.3.5" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Kouhei Sutou".freeze] + s.date = "2024-08-12" + s.description = "An XML toolkit for Ruby".freeze + s.email = ["kou@cozmixng.org".freeze] + s.extra_rdoc_files = ["LICENSE.txt".freeze, "NEWS.md".freeze, "README.md".freeze, "doc/rexml/context.rdoc".freeze, "doc/rexml/tasks/rdoc/child.rdoc".freeze, "doc/rexml/tasks/rdoc/document.rdoc".freeze, "doc/rexml/tasks/rdoc/element.rdoc".freeze, "doc/rexml/tasks/rdoc/node.rdoc".freeze, "doc/rexml/tasks/rdoc/parent.rdoc".freeze, "doc/rexml/tasks/tocs/child_toc.rdoc".freeze, "doc/rexml/tasks/tocs/document_toc.rdoc".freeze, "doc/rexml/tasks/tocs/element_toc.rdoc".freeze, "doc/rexml/tasks/tocs/master_toc.rdoc".freeze, "doc/rexml/tasks/tocs/node_toc.rdoc".freeze, "doc/rexml/tasks/tocs/parent_toc.rdoc".freeze, "doc/rexml/tutorial.rdoc".freeze] + s.files = ["LICENSE.txt".freeze, "NEWS.md".freeze, "README.md".freeze, "doc/rexml/context.rdoc".freeze, "doc/rexml/tasks/rdoc/child.rdoc".freeze, "doc/rexml/tasks/rdoc/document.rdoc".freeze, "doc/rexml/tasks/rdoc/element.rdoc".freeze, "doc/rexml/tasks/rdoc/node.rdoc".freeze, "doc/rexml/tasks/rdoc/parent.rdoc".freeze, "doc/rexml/tasks/tocs/child_toc.rdoc".freeze, "doc/rexml/tasks/tocs/document_toc.rdoc".freeze, "doc/rexml/tasks/tocs/element_toc.rdoc".freeze, "doc/rexml/tasks/tocs/master_toc.rdoc".freeze, "doc/rexml/tasks/tocs/node_toc.rdoc".freeze, "doc/rexml/tasks/tocs/parent_toc.rdoc".freeze, "doc/rexml/tutorial.rdoc".freeze] + s.homepage = "https://github.com/ruby/rexml".freeze + s.licenses = ["BSD-2-Clause".freeze] + s.rdoc_options = ["--main".freeze, "README.md".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.5.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "An XML toolkit for Ruby".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, [">= 0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/rouge-4.3.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/rouge-4.3.0.gemspec new file mode 100644 index 0000000..67ac5a8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/rouge-4.3.0.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +# stub: rouge 4.3.0 ruby lib + +Gem::Specification.new do |s| + s.name = "rouge".freeze + s.version = "4.3.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/rouge-ruby/rouge/issues", "changelog_uri" => "https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md", "documentation_uri" => "https://rouge-ruby.github.io/docs/", "source_code_uri" => "https://github.com/rouge-ruby/rouge" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Jeanine Adkisson".freeze] + s.date = "2024-06-14" + s.description = "Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.".freeze + s.email = ["jneen@jneen.net".freeze] + s.executables = ["rougify".freeze] + s.files = ["bin/rougify".freeze] + s.homepage = "http://rouge.jneen.net/".freeze + s.licenses = ["MIT".freeze, "BSD-2-Clause".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.7".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "A pure-ruby colorizer based on pygments".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/safe_yaml-1.0.5.gemspec b/vendor/bundle/ruby/3.2.0/specifications/safe_yaml-1.0.5.gemspec new file mode 100644 index 0000000..dc638cd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/safe_yaml-1.0.5.gemspec @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +# stub: safe_yaml 1.0.5 ruby lib + +Gem::Specification.new do |s| + s.name = "safe_yaml".freeze + s.version = "1.0.5" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Dan Tao".freeze] + s.date = "2019-02-22" + s.description = "Parse YAML safely".freeze + s.email = "daniel.tao@gmail.com".freeze + s.executables = ["safe_yaml".freeze] + s.files = ["bin/safe_yaml".freeze] + s.homepage = "https://github.com/dtao/safe_yaml".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 1.8.7".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "SameYAML provides an alternative implementation of YAML.load suitable for accepting user input in Ruby applications.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/sass-embedded-1.77.8-x86_64-linux-gnu.gemspec b/vendor/bundle/ruby/3.2.0/specifications/sass-embedded-1.77.8-x86_64-linux-gnu.gemspec new file mode 100644 index 0000000..2024b25 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/sass-embedded-1.77.8-x86_64-linux-gnu.gemspec @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- +# stub: sass-embedded 1.77.8 x86_64-linux-gnu lib + +Gem::Specification.new do |s| + s.name = "sass-embedded".freeze + s.version = "1.77.8" + s.platform = "x86_64-linux-gnu".freeze + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/sass-contrib/sass-embedded-host-ruby/issues", "documentation_uri" => "https://rubydoc.info/gems/sass-embedded/1.77.8", "funding_uri" => "https://github.com/sponsors/ntkme", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.77.8" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["\u306A\u3064\u304D".freeze] + s.bindir = "exe".freeze + s.date = "2024-07-11" + s.description = "A Ruby library that will communicate with Embedded Dart Sass using the Embedded Sass protocol.".freeze + s.email = ["i@ntk.me".freeze] + s.executables = ["sass".freeze] + s.files = ["exe/sass".freeze] + s.homepage = "https://github.com/sass-contrib/sass-embedded-host-ruby".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 3.2".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Use dart-sass with Ruby!".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_runtime_dependency(%q.freeze, ["~> 4.26"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/strscan-3.1.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/strscan-3.1.0.gemspec new file mode 100644 index 0000000..1559dfd --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/strscan-3.1.0.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +# stub: strscan 3.1.0 ruby lib +# stub: ext/strscan/extconf.rb + +Gem::Specification.new do |s| + s.name = "strscan".freeze + s.version = "3.1.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Minero Aoki".freeze, "Sutou Kouhei".freeze, "Charles Oliver Nutter".freeze] + s.date = "2024-02-04" + s.description = "Provides lexical scanning operations on a String.".freeze + s.email = [nil, "kou@cozmixng.org".freeze, "headius@headius.com".freeze] + s.extensions = ["ext/strscan/extconf.rb".freeze] + s.files = ["ext/strscan/extconf.rb".freeze] + s.homepage = "https://github.com/ruby/strscan".freeze + s.licenses = ["Ruby".freeze, "BSD-2-Clause".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Provides lexical scanning operations on a String.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/terminal-table-3.0.2.gemspec b/vendor/bundle/ruby/3.2.0/specifications/terminal-table-3.0.2.gemspec new file mode 100644 index 0000000..5606f7f --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/terminal-table-3.0.2.gemspec @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +# stub: terminal-table 3.0.2 ruby lib + +Gem::Specification.new do |s| + s.name = "terminal-table".freeze + s.version = "3.0.2" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["TJ Holowaychuk".freeze, "Scott J. Goldman".freeze] + s.date = "2021-09-19" + s.email = ["tj@vision-media.ca".freeze] + s.homepage = "https://github.com/tj/terminal-table".freeze + s.licenses = ["MIT".freeze] + s.rubygems_version = "3.4.10".freeze + s.summary = "Simple, feature rich ascii table generation library".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["~> 2"]) + s.add_development_dependency(%q.freeze, ["~> 13.0"]) + s.add_development_dependency(%q.freeze, [">= 3.0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 0"]) + s.add_runtime_dependency(%q.freeze, [">= 1.1.1", "< 3"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/unicode-display_width-2.5.0.gemspec b/vendor/bundle/ruby/3.2.0/specifications/unicode-display_width-2.5.0.gemspec new file mode 100644 index 0000000..99c57f8 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/unicode-display_width-2.5.0.gemspec @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +# stub: unicode-display_width 2.5.0 ruby lib + +Gem::Specification.new do |s| + s.name = "unicode-display_width".freeze + s.version = "2.5.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/janlelis/unicode-display_width/issues", "changelog_uri" => "https://github.com/janlelis/unicode-display_width/blob/main/CHANGELOG.md", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/janlelis/unicode-display_width" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["Jan Lelis".freeze] + s.date = "2023-10-01" + s.description = "[Unicode 15.1.0] Determines the monospace display width of a string using EastAsianWidth.txt, Unicode general category, and other data.".freeze + s.email = ["hi@ruby.consulting".freeze] + s.extra_rdoc_files = ["README.md".freeze, "MIT-LICENSE.txt".freeze, "CHANGELOG.md".freeze] + s.files = ["CHANGELOG.md".freeze, "MIT-LICENSE.txt".freeze, "README.md".freeze] + s.homepage = "https://github.com/janlelis/unicode-display_width".freeze + s.licenses = ["MIT".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "Determines the monospace display width of a string in Ruby.".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version + + s.specification_version = 4 + + s.add_development_dependency(%q.freeze, ["~> 3.4"]) + s.add_development_dependency(%q.freeze, ["~> 13.0"]) +end diff --git a/vendor/bundle/ruby/3.2.0/specifications/webrick-1.8.1.gemspec b/vendor/bundle/ruby/3.2.0/specifications/webrick-1.8.1.gemspec new file mode 100644 index 0000000..5133d65 --- /dev/null +++ b/vendor/bundle/ruby/3.2.0/specifications/webrick-1.8.1.gemspec @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +# stub: webrick 1.8.1 ruby lib + +Gem::Specification.new do |s| + s.name = "webrick".freeze + s.version = "1.8.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "bug_tracker_uri" => "https://github.com/ruby/webrick/issues" } if s.respond_to? :metadata= + s.require_paths = ["lib".freeze] + s.authors = ["TAKAHASHI Masayoshi".freeze, "GOTOU YUUZOU".freeze, "Eric Wong".freeze] + s.date = "2023-01-27" + s.description = "WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server.".freeze + s.email = [nil, nil, "normal@ruby-lang.org".freeze] + s.homepage = "https://github.com/ruby/webrick".freeze + s.licenses = ["Ruby".freeze, "BSD-2-Clause".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze) + s.rubygems_version = "3.4.10".freeze + s.summary = "HTTP server toolkit".freeze + + s.installed_by_version = "3.4.10" if s.respond_to? :installed_by_version +end